import{d as t}from"./p-7f5e6a6c.js";import{b as s}from"./p-add1e9ec.js";import{b as i}from"./p-f146219b.js";import{L as e,S as h}from"./p-350daa19.js";import{e as r}from"./p-6923bbba.js";class n{constructor(t={}){this.previousWidth=s.window.width,this.previousHeight=s.window.height,this.previousIsLandscape=this.isLandscape,this.options={onlyListenToWidthChanges:!1},this.options=Object.assign(Object.assign({},this.options),t)}async hasResized(){if(i.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 s.window.width>s.window.height}get sameWidth(){return this.previousWidth===s.window.width}get sameHeight(){return this.previousHeight===s.window.height}resetPreviousValues(){this.previousWidth=s.window.width,this.previousHeight=s.window.height,this.previousIsLandscape=this.isLandscape}}class o extends e{constructor(){super(...arguments),this.resizeHandler=new n({onlyListenToWidthChanges:!0}),this.debouncedNotify=t((()=>this.notify()),10),this.notify=async()=>{await this.resizeHandler.hasResized()&&super.notify(void 0)}}connect(){super.connect(),this.el&&this.el.addEventListener("resize",this.debouncedNotify,{passive:!0})}disconnect(){super.disconnect(),this.el&&this.el.removeEventListener("resize",this.debouncedNotify)}}const u=t=>parseInt(t.slice(0,-2),10),c=u(r.balBreakpointTablet),a=u(r.balBreakpointDesktop),l=u(r.balBreakpointHighDefinition),d=u(r.balBreakpointWidescreen),p=u(r.balBreakpointFullhd),b=t=>t.innerWidth<c,f=t=>{const s=t.innerWidth;return s>=c&&s<a},g=t=>b(t)||f(t),m={mobile:b,tablet:f,touch:g,desktop:t=>!g(t),highDefinition:t=>{const s=t.innerWidth;return s>=l&&s<d},widescreen:t=>{const s=t.innerWidth;return s>=d&&s<p},fullhd:t=>t.innerWidth>=p},w=new class{constructor(){this.breakpoints=[],s.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(m).filter((t=>m[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")}}},j={mobile:!1,tablet:!1,touch:!1,desktop:!1,highDefinition:!1,widescreen:!1,fullhd:!1},D=new class extends h{constructor(){super((t=>t.breakpointListener(this.state))),this.state=j,this.listener=new o,this.listener.connect(),this.listener.add((()=>{w.detect();const t=w.toObject();this.isEqual(t)||(this.state=t,this.notify())}))}attach(t){super.attach(t),w.detect(),this.state=w.toObject(),this.notify()}isEqual(t){return JSON.stringify(this.state)===JSON.stringify(t)}};export{o as B,D as a,w as b}