import{h as t,j as s,r as i}from"./p-4f82c566.js";import{b as e}from"./p-e680e7e4.js";import{b as h}from"./p-da187899.js";import{L as r,S as n}from"./p-ab217a42.js";import{e as o}from"./p-06d9cc63.js";class c{constructor(t={}){this.previousWidth=e.window.width,this.previousHeight=e.window.height,this.previousIsLandscape=this.isLandscape,this.options={onlyListenToWidthChanges:!1},this.options=Object.assign(Object.assign({},this.options),t)}async hasResized(){if(h.hasTouchScreen){if(!this.sameWidth||this.previousIsLandscape!==this.isLandscape)return this.resetPreviousValues(),!0}else if(this.options.onlyListenToWidthChanges){if(!this.sameWidth)return this.resetPreviousValues(),!0}else if(!this.sameWidth||!this.sameHeight)return this.resetPreviousValues(),!0;return!1}get isLandscape(){return e.window.width>e.window.height}get sameWidth(){return this.previousWidth===e.window.width}get sameHeight(){return this.previousHeight===e.window.height}resetPreviousValues(){this.previousWidth=e.window.width,this.previousHeight=e.window.height,this.previousIsLandscape=this.isLandscape}}class u extends r{constructor(){super(...arguments),this.resizeHandler=new c({onlyListenToWidthChanges:!0}),this.debouncedNotify=t((()=>this.notify()),10),this.notify=async()=>{await this.resizeHandler.hasResized()&&super.notify(void 0)}}connect(){super.connect(),this.el&&s(this.el,"resize",this.debouncedNotify,{passive:!0})}disconnect(){super.disconnect(),this.el&&i(this.el,"resize",this.debouncedNotify)}}const a=t=>parseInt(t.slice(0,-2),10),l=a(o.balBreakpointTablet),d=a(o.balBreakpointDesktop),p=a(o.balBreakpointHighDefinition),f=a(o.balBreakpointWidescreen),b=a(o.balBreakpointFullhd),g=t=>t.innerWidth<l,m=t=>{const s=t.innerWidth;return s>=l&&s<d},w=t=>g(t)||m(t),j={mobile:g,tablet:m,touch:w,desktop:t=>!w(t),highDefinition:t=>{const s=t.innerWidth;return s>=p&&s<f},widescreen:t=>{const s=t.innerWidth;return s>=f&&s<b},fullhd:t=>t.innerWidth>=b};class D{constructor(){this.breakpoints=[],e.hasWindow&&(this.win=window,this.win.BaloiseDesignSystem=this.win.BaloiseDesignSystem||{},this.detect())}get isMobile(){return this.includes("mobile")}get isTablet(){return this.includes("tablet")}get isTouch(){return this.includes("touch")}get isDesktop(){return this.includes("desktop")}get isHighDefinition(){return this.includes("highDefinition")}get isWidescreen(){return this.includes("widescreen")}get isFullHD(){return this.includes("fullhd")}includes(t){var s;return this.detect(),!!(null===(s=this.breakpoints)||void 0===s?void 0:s.includes(t))}detect(){return this.win&&(this.breakpoints=Object.keys(j).filter((t=>j[t](this.win))),this.win.BaloiseDesignSystem.breakpoints=this.breakpoints,this.win.BaloiseDesignSystem.platforms=this.breakpoints),this.breakpoints}toObject(){return{mobile:this.breakpoints.includes("mobile"),tablet:this.breakpoints.includes("tablet"),touch:this.breakpoints.includes("touch"),desktop:this.breakpoints.includes("desktop"),highDefinition:this.breakpoints.includes("highDefinition"),widescreen:this.breakpoints.includes("widescreen"),fullhd:this.breakpoints.includes("fullhd")}}}const k=new D,v={mobile:!1,tablet:!1,touch:!1,desktop:!1,highDefinition:!1,widescreen:!1,fullhd:!1};class O extends n{constructor(){super((t=>t.breakpointListener(this.state))),this.state=v,this.listener=new u,this.debouncedNotify=t((()=>this.notify()),50),this.listener.connect(),this.listener.add((()=>{k.detect();const t=k.toObject();this.isEqual(t)||(this.state=t,this.debouncedNotify())}))}attach(t){super.attach(t),k.detect();const s=k.toObject();this.isEqual(s)||(this.state=s,this.debouncedNotify())}isEqual(t){return JSON.stringify(this.state)===JSON.stringify(t)}}const y=new O;export{u as B,y as a,k as b,O as c,D as d}