var a=null;function V(e=!1){if(e)return"dev-token";if(a!==null)return a;if(typeof window>"u"||typeof location>"u")throw new Error("getToken() is only available in browser environments");let t=location.hash.slice(1);if(!t)throw new Error("No token found in URL hash");let n=new URLSearchParams(t).get("mb_token");if(!n)throw new Error('Token "mb_token" not found in URL hash');return a=decodeURIComponent(n),a}var u=null,g=new Set;function Z(){return u}function q(e){if(g.add(e),u!==null)try{e(u)}catch{}return()=>{g.delete(e)}}function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function H(e){return w(e)&&e.type==="adapt-darkMode"&&typeof e.darkMode=="boolean"}function I(e){return w(e)&&e.type==="adapt-autoResizing"&&typeof e.autoResizing=="boolean"}function R(e){return Number.isFinite(e)&&e>=1}function P(e){return w(e)&&typeof e.postMessage=="function"}function c(){return typeof window<"u"&&typeof document<"u"&&typeof window.postMessage=="function"}function v(){if(!c())return!1;try{return window.self!==window.top}catch{return!0}}var l=-1,r=-1,f=-1,y=-1,m=null,U=16,b=0,_=5;function z(){let{body:e,documentElement:t}=document;if(!e)return null;let n=getComputedStyle(e),s=parseFloat(n.marginTop)||0,d=parseFloat(n.marginBottom)||0,L=parseFloat(n.marginLeft)||0,E=parseFloat(n.marginRight)||0,o=getComputedStyle(t),B=parseFloat(o.paddingTop)||0,F=parseFloat(o.paddingBottom)||0,S=parseFloat(o.paddingLeft)||0,W=parseFloat(o.paddingRight)||0,A=parseFloat(o.borderTopWidth)||0,x=parseFloat(o.borderBottomWidth)||0,D=parseFloat(o.borderLeftWidth)||0,C=parseFloat(o.borderRightWidth)||0,h=Math.max(e.scrollHeight,e.offsetHeight),O=Math.max(e.scrollWidth,e.offsetWidth),M=h+s+d+B+F+A+x,k=O+L+E+S+W+D+C;return!R(k)||!R(M)||b>=_&&y>0&&Math.abs(h-r)<=2?null:(y=h,{width:k,height:M+1})}function i(){if(!c()||!v())return;let e=window.parent;if(!P(e))return;let t=document.body?Math.max(document.body.scrollWidth,document.body.offsetWidth):0;t!==f&&f!==-1&&(b=0,y=-1),f=t;let n=z();if(!n)return;let{width:s,height:d}=n;if(!(s===l&&d===r)){l=s,r=d,b++;try{e.postMessage({type:"adapt-resize",width:s,height:d},"*")}catch{}}}function p(){m===null&&(m=setTimeout(()=>{m=null,i()},U))}function N(){let e=z();if(!e){if(r>0)try{window.parent.postMessage({type:"adapt-resize",width:l,height:r},"*")}catch{}return}let{width:t,height:n}=e;l=t,r=n;try{window.parent.postMessage({type:"adapt-resize",width:t,height:n},"*")}catch{}}function j(e){let t;try{t=e.data}catch{return}if(H(t)){u=t.darkMode;for(let n of g)try{n(t.darkMode)}catch{}}I(t)&&t.autoResizing&&N()}function T(){if(!c()||!v())return;let e=document.createElement("style");e.textContent=`
    html, body {
      box-sizing: border-box;
    }
    *, *::before, *::after {
      box-sizing: inherit;
    }
  `,document.head.appendChild(e),window.addEventListener("message",j);let t=new ResizeObserver(p);document.body&&t.observe(document.body),document.documentElement&&t.observe(document.documentElement),document.body&&new MutationObserver(p).observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),document.addEventListener("load",p,!0),document.fonts?.ready?.then(()=>{i()}),document.readyState==="complete"?i():window.addEventListener("load",()=>{i()}),setTimeout(i,50),setTimeout(i,150)}c()&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",T):T());export{Z as getDarkMode,V as getToken,q as listenDarkMode};
//# sourceMappingURL=browser.mjs.map
