@netless/window-manager 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var Rg=require("p-retry"),jg=require("emittery"),E=require("lodash"),I=require("white-web-sdk"),_g=require("uuid"),Vg=require("@juggle/resize-observer"),Og=require("video.js");function cl(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function $g(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(i){if(i!=="default"){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var Oh=cl(Rg),Ti=cl(jg),_u=cl(Og),se=(e=>(e.AppMove="AppMove",e.AppFocus="AppFocus",e.AppResize="AppResize",e.AppBoxStateChange="AppBoxStateChange",e.GetAttributes="GetAttributes",e.UpdateWindowManagerWrapper="UpdateWindowManagerWrapper",e.InitReplay="InitReplay",e.WindowCreated="WindowCreated",e.SetMainViewScenePath="SetMainViewScenePath",e.SetMainViewSceneIndex="SetMainViewSceneIndex",e.SetAppFocusIndex="SetAppFocusIndex",e.SwitchViewsToFreedom="SwitchViewsToFreedom",e.MoveCamera="MoveCamera",e.MoveCameraToContain="MoveCameraToContain",e.CursorMove="CursorMove",e.RootDirRemoved="RootDirRemoved",e.Refresh="Refresh",e.InitMainViewCamera="InitMainViewCamera",e))(se||{});const Ko="__WindowManger",Mo="__WindowMangerEnsureReconnected__";var Be=(e=>(e.Size="size",e.Position="position",e.SceneIndex="SceneIndex",e.ZIndex="zIndex",e))(Be||{}),$h=(e=>(e.setBoxSize="setBoxSize",e.setBoxMinSize="setBoxMinSize",e.destroy="destroy",e))($h||{}),qo=(e=>(e.StartCreate="StartCreate",e))(qo||{}),ea=(e=>(e.Leave="leave",e.Normal="normal",e))(ea||{});const Vu="2.16.1",Ug=340/720,Wg=340/720,Hg=9/16,ze="/",Uh="/init",Wh=50,G=new Ti.default;class Fg{constructor(){this.list=[],this.isEmit=!1,this.invoked=()=>{this.currentInvoker=void 0,this.list.length===0&&(this.clear(),this.emitReady())},this.clear=()=>{clearInterval(this.timer),this.timer=void 0}}initInterval(){return setInterval(()=>{this.invoke()},50)}push(t){this.list.push(t),this.invoke(),this.timer===void 0&&this.list.length>0&&(this.timer=this.initInterval())}invoke(){if(this.list.length===0||this.currentInvoker!==void 0)return;const t=this.list.shift();t&&(this.currentInvoker=t,t().then(()=>{this.invoked()}).catch(i=>{console.error(`[WindowManager]: create app error: ${i.message}`),this.invoked()}))}emitReady(){this.isEmit||setTimeout(()=>{G.emit("ready")},Wh),this.isEmit=!0}empty(){this.list=[],this.clear()}destroy(){this.timer&&this.clear()}}const _=new Ti.default,Qg="__WindowManagerAppCache";let Jn,Ou;const Zg=async()=>{Jn=await Xg()},Yg=(e,t)=>{if(!!Jn)return Kg(Jn,{kind:e,sourceCode:t})},Gg=async e=>Jn?await Jg(Jn,e):null;function Xg(){return new Promise((e,t)=>{const i=indexedDB.open(Qg,2);i.onerror=n=>{t(n)},i.onupgradeneeded=n=>{const r=n.target.result;r.objectStoreNames.contains("apps")||(Ou=r.createObjectStore("apps",{keyPath:"kind"}),Ou.createIndex("kind","kind",{unique:!0}))},i.onsuccess=()=>{const n=i.result;e(n)}})}function Jg(e,t){return new Promise((i,n)=>{const s=e.transaction(["apps"]).objectStore("apps").index("kind").get(t);s.onerror=o=>n(o),s.onsuccess=()=>{s.result?i(s.result):i(null)}})}function Kg(e,t){return new Promise((i,n)=>{const r=e.transaction(["apps"],"readwrite").objectStore("apps").add(t);r.onsuccess=()=>i(),r.onerror=()=>n()})}const qg="NetlessApp",em=1e4,tm=async e=>{const t=await Gg(e);if(t)return t.sourceCode;{const n=await(await rm(e,{timeout:em})).text();return await Yg(e,n),n}},$u=(e,t)=>{let i=Function(e+`
2
- ;return ${t}`)();return typeof i=="undefined"&&(i=window[t]),i},im=async(e,t,i)=>{const n=i||qg+t;G.emit("loadApp",{kind:t,status:"start"});let r;try{if(r=await tm(e),!r||r.length===0)throw G.emit("loadApp",{kind:t,status:"failed",reason:"script is empty."}),new Error("[WindowManager]: script is empty.")}catch(s){throw G.emit("loadApp",{kind:t,status:"failed",reason:s.message}),s}return nm(r,n,t)},nm=(e,t,i)=>{try{const n=$u(e,t);return G.emit("loadApp",{kind:i,status:"success"}),n}catch(n){if(n.message.includes("Can only have one anonymous define call per script file")){const r=window.define;typeof r=="function"&&r.amd&&delete r.amd;const s=$u(e,t);return G.emit("loadApp",{kind:i,status:"success"}),s}throw G.emit("loadApp",{kind:i,status:"failed",reason:n.message}),n}};async function rm(e,t){const{timeout:i=1e4}=t,n=new AbortController,r=setTimeout(()=>n.abort(),i),s=await fetch(e,{...t,signal:n.signal,headers:{"content-type":"text/plain"}});return clearTimeout(r),s}class sm{constructor(){this.kindEmitters=new Map,this.registered=new Map,this.appClassesCache=new Map,this.appClasses=new Map,this.syncRegisterApp=null,this.onSyncRegisterAppChange=t=>{this.register({kind:t.kind,src:t.src})}}setSyncRegisterApp(t){this.syncRegisterApp=t}async register(t){this.appClassesCache.delete(t.kind),this.registered.set(t.kind,t);const i=t.src;let n;if(typeof i=="string"&&(n=async()=>{const r=await im(i,t.kind,t.name);return r.__esModule?r.default:r},this.syncRegisterApp&&this.syncRegisterApp({kind:t.kind,src:i,name:t.name})),typeof i=="function"&&(n=async()=>{let r=await i();if(r)return(r.__esModule||r.default)&&(r=r.default),r;throw new Error(`[WindowManager]: load remote script failed, ${i}`)}),typeof i=="object"&&(n=async()=>i),this.appClasses.set(t.kind,async()=>{let r=this.appClassesCache.get(t.kind);return r||(r=n(),this.appClassesCache.set(t.kind,r)),r}),t.addHooks){const r=this.createKindEmitter(t.kind);r&&t.addHooks(r)}}unregister(t){this.appClasses.delete(t),this.appClassesCache.delete(t),this.registered.delete(t);const i=this.kindEmitters.get(t);i&&(i.clearListeners(),this.kindEmitters.delete(t))}async notifyApp(t,i,n){const r=this.kindEmitters.get(t);await(r==null?void 0:r.emit(i,n))}createKindEmitter(t){if(!this.kindEmitters.has(t)){const i=new Ti.default;this.kindEmitters.set(t,i)}return this.kindEmitters.get(t)}}const Te=new sm,om=async e=>{var i,n;const t=await((i=Te.appClasses.get(e))==null?void 0:i());return t&&((n=t.config)==null?void 0:n.singleton)?e:`${e}-${_g.v4().replace("-","").slice(0,8)}`},xi=(e,t)=>{if(e.focusScenePath!==t)return e.focusScenePath=t,e},ta=(e,t)=>{if(e&&e.isWritable&&e.state.sceneState.scenePath!==t){const i=t==="/"?"":t;e.setScenePath(i)}},am=(e,t,i)=>{var n;if(e&&t){const s=(n=en(e)[t])==null?void 0:n[i];if(s)return`${t}/${s.name}`}},ia=(e,t,i)=>{e&&e.scenePathType(t)!==I.ScenePathType.None&&e.removeScenes(t,i)},lm=(e,t)=>{_.once(e).then(t)};E.debounce((e,t)=>{e.emit("mainViewModeChange",t)},200);const um=(e,t,i=0)=>{const n=en(e)[t];if(!n)return;const r=n[i];if(!r)return;const s=r.name;return t===ze?`/${s}`:`${t}/${s}`},en=e=>e.entireScenes(),Rn=(e,t,i,n)=>{var r;for(let s=0;s<i.length;++s)if((r=i[s].name)!=null&&r.includes("/"))throw new Error("scenes name can not have '/'");return e==null?void 0:e.putScenes(t,i,n)},cm=e=>e.startsWith("/"),Co=e=>{const t=e.split("/");t.pop();let i=t.join("/");return i===""&&(i="/"),i},hm=e=>e.endsWith("/")?e.slice(0,-1):e,Uu=e=>{const t=e.split(".").map(i=>i.padStart(2,"0")).join("");return parseInt(t)},Hh=e=>new Promise(t=>setTimeout(t,e)),dm=e=>e.split("").reduce((i,n)=>(n===ze&&(i+=1),i),0)===1;class fm{constructor(t){this.manager=t,this.displayer=this.manager.displayer,this.mainMagixEventListener=i=>{if(i.authorId!==this.displayer.observerId){const n=i.payload;switch(n.eventName){case se.AppMove:{this.appMoveHandler(n.payload);break}case se.AppResize:{this.appResizeHandler(n.payload);break}case se.AppBoxStateChange:{this.boxStateChangeHandler(n.payload);break}case se.SetMainViewScenePath:{this.setMainViewScenePathHandler(n.payload);break}case se.CursorMove:{this.cursorMoveHandler(n.payload);break}case se.RootDirRemoved:{this.rootDirRemovedHandler();break}case se.Refresh:{this.refreshHandler();break}case se.InitMainViewCamera:{this.initMainViewCameraHandler();break}case se.SetAppFocusIndex:{this.setAppFocusViewIndexHandler(n.payload);break}}}},this.appMoveHandler=i=>{var n;(n=this.boxManager)==null||n.moveBox(i)},this.appResizeHandler=i=>{var n,r;(n=this.boxManager)==null||n.resizeBox(Object.assign(i,{skipUpdate:!0})),(r=this.manager.room)==null||r.refreshViewSize()},this.boxStateChangeHandler=i=>{G.emit("boxStateChange",i)},this.setMainViewScenePathHandler=({nextScenePath:i})=>{xi(this.manager.mainView,i),G.emit("mainViewScenePathChange",i)},this.cursorMoveHandler=i=>{_.emit("cursorMove",i)},this.rootDirRemovedHandler=()=>{this.manager.createRootDirScenesCallback(),this.manager.mainViewProxy.rebind(),_.emit("rootDirRemoved")},this.refreshHandler=()=>{this.manager.windowManger._refresh()},this.initMainViewCameraHandler=()=>{this.manager.mainViewProxy.addCameraReaction()},this.setAppFocusViewIndexHandler=i=>{if(i.type==="main")this.manager.setSceneIndexWithoutSync(i.index);else if(i.type==="app"&&i.appID){const n=this.manager.appProxies.get(i.appID);n&&n.setSceneIndexWithoutSync(i.index)}}}get boxManager(){return this.manager.boxManager}addListeners(){this.displayer.addMagixEventListener(Ko,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(Ko,this.mainMagixEventListener)}}class Fh extends Error{constructor(){super(...arguments),this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class pm extends Error{constructor(t){super(`[WindowManager]: app ${t} need register or provide src`)}}class Oe extends Error{constructor(){super(...arguments),this.message="[WindowManager]: AppManager must be initialized"}}class Qh extends Error{constructor(t){super(`[WindowManager]: white-web-sdk version must large than ${t}`)}}class Zh extends Error{constructor(){super(...arguments),this.message="[WindowManager]: kind must be a valid string"}}class Yh extends Error{constructor(){super(...arguments),this.message="[WindowManager]: box need created"}}class Gh extends Error{constructor(){super(...arguments),this.message='[WindowManager]: ScenePath should start with "/"'}}class Xh extends Error{constructor(){super(...arguments),this.message="[WindowManager]: boxManager not found"}}class Jh extends Error{constructor(){super(...arguments),this.message="[WindowManager]: room phase only Connected can be bindContainer"}}const Kh="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",gm=Kh.length,Wu=Array(20),Li=()=>{for(let e=0;e<20;e++)Wu[e]=Kh.charAt(Math.random()*gm);return Wu.join("")};class dr{constructor(){this.disposers=new Map}add(t,i=Li()){return this.flush(i),this.disposers.set(i,t()),i}addDisposer(t,i=Li()){return this.flush(i),this.disposers.set(i,t),i}addEventListener(t,i,n,r,s=Li()){return this.add(()=>(t.addEventListener(i,n,r),()=>t.removeEventListener(i,n,r)),s),s}setTimeout(t,i,n=Li()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(n),t()},i);return()=>window.clearTimeout(r)},n)}setInterval(t,i,n=Li()){return this.add(()=>{const r=window.setInterval(t,i);return()=>window.clearInterval(r)},n)}remove(t){const i=this.disposers.get(t);return this.disposers.delete(t),i}flush(t){const i=this.remove(t);if(i)try{i()}catch(n){console.error(n)}}flushAll(){this.disposers.forEach(t=>{try{t()}catch(i){console.error(i)}}),this.disposers.clear()}}const qh=e=>(t,i)=>{if(t!==void 0)if(I.listenUpdated){const n=r=>{r.map(o=>o.kind).includes(e)&&i()};return I.listenUpdated(t,n),i(),()=>I.unlistenUpdated(t,n)}else return I.reaction(()=>t,()=>{i()},{fireImmediately:!0})},kn=(e,t,i)=>{let n=null;const r=I.reaction(e,()=>{n&&(n(),n=null);const s=e();E.isObject(s)?(n=()=>I.unlistenUpdated(s,t),I.listenUpdated(s,t)):i==null||i(s)},{fireImmediately:!0});return()=>{n==null||n(),r()}};qh(I.UpdateEventKind.Removed);qh(I.UpdateEventKind.Inserted);class mm{constructor(){this.listeners=new Set}get length(){return this.listeners.size}dispatch(t){this.listeners.forEach(i=>i(t))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}}const bo=Object.keys;function Hu(e){return Boolean(E.has(e,"__isRef"))}function vm(e){return{k:Li(),v:e,__isRef:!0}}const Ke="_WM-STORAGE_";class Fu{constructor(t,i,n){if(this.maxIllusionQueueSize=500,this._sideEffect=new dr,this._destroyed=!1,this._refMap=new WeakMap,this._lastValue=new Map,this.onStateChanged=new mm,n&&!E.isObject(n))throw new Error(`Default state for Storage ${i} is not an object.`);this._context=t,this.id=i||null,this._state={};const r=this._getRawState(this._state);this._context.getIsWritable()&&(this.id===null?t.isAddApp&&n&&this.setState(n):(r===this._state||!E.isObject(r))&&(E.get(this._context.getAttributes(),[Ke])||this._context.updateAttributes([Ke],{}),this._context.updateAttributes([Ke,this.id],this._state),n&&this.setState(n))),bo(r).forEach(s=>{if(!(this.id===null&&s===Ke))try{const o=E.isObject(r[s])?JSON.parse(JSON.stringify(r[s])):r[s];Hu(o)?(this._state[s]=o.v,E.isObject(o.v)&&this._refMap.set(o.v,o)):this._state[s]=o}catch(o){console.error(o)}}),this._sideEffect.addDisposer(kn(()=>this.id===null?t.getAttributes():E.get(t.getAttributes(),[Ke,this.id]),this._updateProperties.bind(this),this.destroy.bind(this)))}get state(){return this._destroyed&&console.warn(`Accessing state on destroyed Storage "${this.id}"`),this._state}addStateChangedListener(t){return this.onStateChanged.addListener(t),()=>this.onStateChanged.removeListener(t)}ensureState(t){return this.setState(bo(t).reduce((i,n)=>(E.has(this._state,n)||(i[n]=t[n]),i),{}))}setState(t){if(this._destroyed){console.error(new Error(`Cannot call setState on destroyed Storage "${this.id}".`));return}if(!this._context.getIsWritable()){console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`),t);return}const i=bo(t);i.length>0&&i.forEach(n=>{const r=t[n];if(r!==this._state[n])if(r===void 0)this._lastValue.set(n,this._state[n]),delete this._state[n],this._setRawState(n,r);else{this._lastValue.set(n,this._state[n]),this._state[n]=r;let s=r;if(E.isObject(r)){let o=this._refMap.get(r);o||(o=vm(r),this._refMap.set(r,o)),s=o}this._setRawState(n,s)}})}emptyStorage(){if(!(E.size(this._state)<=0)){if(this._destroyed){console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));return}if(!this._context.getIsWritable()){console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));return}this.setState(E.mapValues(this._state,E.noop))}}deleteStorage(){if(this.id===null)throw new Error("Cannot delete main Storage");if(!this._context.getIsWritable()){console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));return}this.destroy(),this._context.updateAttributes([Ke,this.id],void 0)}get destroyed(){return this._destroyed}destroy(){this._destroyed=!0,this._sideEffect.flushAll()}_getRawState(t){var i;return this.id===null?(i=this._context.getAttributes())!=null?i:t:E.get(this._context.getAttributes(),[Ke,this.id],t)}_setRawState(t,i){if(this.id===null){if(t===Ke)throw new Error(`Cannot set attribute internal filed "${Ke}"`);return this._context.updateAttributes([t],i)}else return this._context.updateAttributes([Ke,this.id,t],i)}_updateProperties(t){var i;if(this._destroyed){console.error(new Error(`Cannot call _updateProperties on destroyed Storage "${this.id}".`));return}if(t.length>0){const n={};for(let r=0;r<t.length;r++)try{const s=t[r],o=s.key;if(this.id===null&&o===Ke)continue;const a=E.isObject(s.value)?JSON.parse(JSON.stringify(s.value)):s.value;let l;switch(this._lastValue.has(o)&&(l=this._lastValue.get(o),this._lastValue.delete(o)),s.kind){case 2:{E.has(this._state,o)&&(l=this._state[o],delete this._state[o]),n[o]={oldValue:l};break}default:{let u=a;if(Hu(a)){const{k:c,v:h}=a,m=this._state[o];E.isObject(m)&&((i=this._refMap.get(m))==null?void 0:i.k)===c?u=m:(u=h,E.isObject(h)&&this._refMap.set(h,a))}u!==this._state[o]&&(l=this._state[o],this._state[o]=u),n[o]={newValue:u,oldValue:l};break}}}catch(s){console.error(s)}this.onStateChanged.dispatch(n)}}}class fr{constructor(t,i,n,r,s){this.manager=t,this.boxManager=i,this.appId=n,this.appProxy=r,this.appOptions=s,this.mobxUtils={autorun:I.autorun,reaction:I.reaction,toJS:I.toJS},this.objectUtils={listenUpdated:I.listenUpdated,unlistenUpdated:I.unlistenUpdated,listenDisposed:I.listenDisposed,unlistenDisposed:I.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,this.getManager=()=>this.manager,this.getBoxManager=()=>this.boxManager,this.getWindowManager=()=>this.manager.windowManger,this.getBoxStatus=()=>this.manager.store.getBoxStatus(this.appId),this.getLastNotMinimizedBoxStatus=()=>this.manager.store.getLastNotMinimizedBoxStatus(this.appId),this.getDisplayer=()=>this.manager.displayer,this.getAppProxy=()=>this.appProxy,this.getAttributes=()=>this.appProxy.attributes,this.getScenes=()=>{const o=this.store.getAppAttributes(this.appId);return o!=null&&o.isDynamicPPT?this.appProxy.scenes:o==null?void 0:o.options.scenes},this.getView=()=>this.appProxy.view,this.mountView=o=>{const a=this.getView();a&&(a.divElement=o,setTimeout(()=>{var l;(l=this.getRoom())==null||l.refreshViewSize(),G.emit("onAppViewMounted",{appId:this.appId,view:a})},1e3))},this.getInitScenePath=()=>this.manager.getAppInitPath(this.appId),this.getIsWritable=()=>this.manager.canOperate,this.getBox=()=>{const o=this.boxManager.getBox(this.appId);if(o)return o;throw new Yh},this.getRoom=()=>this.manager.room,this.setAttributes=o=>{this.manager.safeSetAttributes({[this.appId]:o})},this.updateAttributes=(o,a)=>{this.manager.attributes[this.appId]&&this.manager.safeUpdateAttributes([this.appId,...o],a)},this.setScenePath=async o=>{var a;!this.appProxy.box||(this.appProxy.setFullPath(o),(a=this.getRoom())==null||a.setScenePath(o))},this.getAppOptions=()=>typeof this.appOptions=="function"?this.appOptions():this.appOptions,this.createStorage=(o,a)=>{const l=new Fu(this,o,a);return this.emitter.on("destroy",()=>{l.destroy()}),l},this.dispatchMagixEvent=(...o)=>{var l;const a=`${this.appId}:${o[0]}`;return(l=this.manager.room)==null?void 0:l.dispatchMagixEvent(a,o[1])},this.addMagixEventListener=(o,a,l)=>{const u=`${this.appId}:${o}`;return this.manager.displayer.addMagixEventListener(u,a,l),()=>this.manager.displayer.removeMagixEventListener(u,a)},this.removeMagixEventListener=this.manager.displayer.removeMagixEventListener.bind(this.manager.displayer),this.nextPage=async()=>{const o=this.pageState.index+1;return o>this.pageState.length-1?(console.warn("[WindowManager] nextPage: index out of range"),!1):(this.appProxy.setSceneIndex(o),!0)},this.jumpPage=async o=>0<=o&&o<this.pageState.length?(this.appProxy.setSceneIndex(o),!0):(console.warn("[WindowManager] nextPage: index out of range"),!1),this.prevPage=async()=>{const o=this.pageState.index-1;return o<0?(console.warn("[WindowManager] prevPage: index out of range"),!1):(this.appProxy.setSceneIndex(o),!0)},this.addPage=async o=>{const a=o==null?void 0:o.after,l=o==null?void 0:o.scene,u=this.appProxy.scenePath;if(!!u)if(a){const c=this.pageState.index+1;Rn(this.manager.room,u,[l||{}],c)}else Rn(this.manager.room,u,[l||{}])},this.removePage=async o=>{const a=o===void 0?this.pageState.index:o;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):a<0||a>=this.pageState.length?(console.warn(`[WindowManager]: page index ${o} out of range`),!1):this.appProxy.removeSceneByIndex(a)},this.emitter=r.appEmitter,this.isAddApp=r.isAddApp}get storage(){return this._storage||(this._storage=new Fu(this)),this._storage}get pageState(){return this.appProxy.pageState}get kind(){return this.appProxy.kind}dispatchAppEvent(t,i){_.emit(`custom-${this.kind}`,{kind:this.kind,appId:this.appId,type:t,value:i})}}fr.kind="AppContext";class wm{constructor(t){this.params=t,this.sceneNode=null,this.onSceneChange=r=>{this.sceneNode=r,this.params.notifyPageStateChange()};const{displayer:i,scenePath:n}=this.params;n&&(this.sceneNode=i.createScenesCallback(n,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}))}getFullPath(t){var n;const i=(n=this.sceneNode)==null?void 0:n.scenes;if(this.params.scenePath&&i){const r=i[t];if(r)return`${this.params.scenePath}/${r}`}}toObject(){var t,i;return{index:((t=this.params.view)==null?void 0:t.focusSceneIndex)||0,length:((i=this.sceneNode)==null?void 0:i.scenes.length)||0}}destroy(){var t;(t=this.sceneNode)==null||t.dispose()}}var ed={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(i=!1));function r(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,m){if(typeof c!="function")throw new TypeError("The listener must be a function");var v=new r(c,h||l,m),w=i?i+u:u;return l._events[w]?l._events[w].fn?l._events[w]=[l._events[w],v]:l._events[w].push(v):(l._events[w]=v,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new n:delete l._events[u]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)t.call(c,h)&&u.push(i?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},a.prototype.listeners=function(u){var c=i?i+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var m=0,v=h.length,w=new Array(v);m<v;m++)w[m]=h[m].fn;return w},a.prototype.listenerCount=function(u){var c=i?i+u:u,h=this._events[c];return h?h.fn?1:h.length:0},a.prototype.emit=function(u,c,h,m,v,w){var x=i?i+u:u;if(!this._events[x])return!1;var d=this._events[x],f=arguments.length,g,p;if(d.fn){switch(d.once&&this.removeListener(u,d.fn,void 0,!0),f){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,c),!0;case 3:return d.fn.call(d.context,c,h),!0;case 4:return d.fn.call(d.context,c,h,m),!0;case 5:return d.fn.call(d.context,c,h,m,v),!0;case 6:return d.fn.call(d.context,c,h,m,v,w),!0}for(p=1,g=new Array(f-1);p<f;p++)g[p-1]=arguments[p];d.fn.apply(d.context,g)}else{var y=d.length,S;for(p=0;p<y;p++)switch(d[p].once&&this.removeListener(u,d[p].fn,void 0,!0),f){case 1:d[p].fn.call(d[p].context);break;case 2:d[p].fn.call(d[p].context,c);break;case 3:d[p].fn.call(d[p].context,c,h);break;case 4:d[p].fn.call(d[p].context,c,h,m);break;default:if(!g)for(S=1,g=new Array(f-1);S<f;S++)g[S-1]=arguments[S];d[p].fn.apply(d[p].context,g)}}return!0},a.prototype.on=function(u,c,h){return s(this,u,c,h,!1)},a.prototype.once=function(u,c,h){return s(this,u,c,h,!0)},a.prototype.removeListener=function(u,c,h,m){var v=i?i+u:u;if(!this._events[v])return this;if(!c)return o(this,v),this;var w=this._events[v];if(w.fn)w.fn===c&&(!m||w.once)&&(!h||w.context===h)&&o(this,v);else{for(var x=0,d=[],f=w.length;x<f;x++)(w[x].fn!==c||m&&!w[x].once||h&&w[x].context!==h)&&d.push(w[x]);d.length?this._events[v]=d.length===1?d[0]:d:o(this,v)}return this},a.prototype.removeAllListeners=function(u){var c;return u?(c=i?i+u:u,this._events[c]&&o(this,c)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,e.exports=a})(ed);var na=ed.exports;/*! *****************************************************************************
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var er=require("p-retry"),tr=require("emittery"),w=require("lodash"),f=require("white-web-sdk"),ir=require("uuid"),sr=require("@juggle/resize-observer");function es(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var ts=es(er),ve=es(tr),R=(i=>(i.AppMove="AppMove",i.AppFocus="AppFocus",i.AppResize="AppResize",i.AppBoxStateChange="AppBoxStateChange",i.GetAttributes="GetAttributes",i.UpdateWindowManagerWrapper="UpdateWindowManagerWrapper",i.InitReplay="InitReplay",i.WindowCreated="WindowCreated",i.SetMainViewScenePath="SetMainViewScenePath",i.SetMainViewSceneIndex="SetMainViewSceneIndex",i.SetAppFocusIndex="SetAppFocusIndex",i.SwitchViewsToFreedom="SwitchViewsToFreedom",i.MoveCamera="MoveCamera",i.MoveCameraToContain="MoveCameraToContain",i.CursorMove="CursorMove",i.RootDirRemoved="RootDirRemoved",i.Refresh="Refresh",i.InitMainViewCamera="InitMainViewCamera",i))(R||{});const Gt="__WindowManger",Lt="__WindowMangerEnsureReconnected__";var ee=(i=>(i.Size="size",i.Position="position",i.SceneIndex="SceneIndex",i.ZIndex="zIndex",i))(ee||{}),is=(i=>(i.setBoxSize="setBoxSize",i.setBoxMinSize="setBoxMinSize",i.destroy="destroy",i))(is||{}),Qt=(i=>(i.StartCreate="StartCreate",i))(Qt||{}),Yt=(i=>(i.Leave="leave",i.Normal="normal",i))(Yt||{});const Bi="2.16.1",rr=340/720,ar=340/720,nr=9/16,q="/",ss="/init",rs=50,L=new ve.default;class or{constructor(){this.list=[],this.isEmit=!1,this.invoked=()=>{this.currentInvoker=void 0,this.list.length===0&&(this.clear(),this.emitReady())},this.clear=()=>{clearInterval(this.timer),this.timer=void 0}}initInterval(){return setInterval(()=>{this.invoke()},50)}push(e){this.list.push(e),this.invoke(),this.timer===void 0&&this.list.length>0&&(this.timer=this.initInterval())}invoke(){if(this.list.length===0||this.currentInvoker!==void 0)return;const e=this.list.shift();e&&(this.currentInvoker=e,e().then(()=>{this.invoked()}).catch(t=>{console.error(`[WindowManager]: create app error: ${t.message}`),this.invoked()}))}emitReady(){this.isEmit||setTimeout(()=>{L.emit("ready")},rs),this.isEmit=!0}empty(){this.list=[],this.clear()}destroy(){this.timer&&this.clear()}}const A=new ve.default,hr="__WindowManagerAppCache";let He,Ni;const cr=async()=>{He=await dr()},lr=(i,e)=>{if(!!He)return pr(He,{kind:i,sourceCode:e})},ur=async i=>He?await gr(He,i):null;function dr(){return new Promise((i,e)=>{const t=indexedDB.open(hr,2);t.onerror=s=>{e(s)},t.onupgradeneeded=s=>{const r=s.target.result;r.objectStoreNames.contains("apps")||(Ni=r.createObjectStore("apps",{keyPath:"kind"}),Ni.createIndex("kind","kind",{unique:!0}))},t.onsuccess=()=>{const s=t.result;i(s)}})}function gr(i,e){return new Promise((t,s)=>{const n=i.transaction(["apps"]).objectStore("apps").index("kind").get(e);n.onerror=a=>s(a),n.onsuccess=()=>{n.result?t(n.result):t(null)}})}function pr(i,e){return new Promise((t,s)=>{const r=i.transaction(["apps"],"readwrite").objectStore("apps").add(e);r.onsuccess=()=>t(),r.onerror=()=>s()})}const mr="NetlessApp",fr=1e4,Mr=async i=>{const e=await ur(i);if(e)return e.sourceCode;{const s=await(await Sr(i,{timeout:fr})).text();return await lr(i,s),s}},zi=(i,e)=>{let t=Function(i+`
2
+ ;return ${e}`)();return typeof t=="undefined"&&(t=window[e]),t},wr=async(i,e,t)=>{const s=t||mr+e;L.emit("loadApp",{kind:e,status:"start"});let r;try{if(r=await Mr(i),!r||r.length===0)throw L.emit("loadApp",{kind:e,status:"failed",reason:"script is empty."}),new Error("[WindowManager]: script is empty.")}catch(n){throw L.emit("loadApp",{kind:e,status:"failed",reason:n.message}),n}return xr(r,s,e)},xr=(i,e,t)=>{try{const s=zi(i,e);return L.emit("loadApp",{kind:t,status:"success"}),s}catch(s){if(s.message.includes("Can only have one anonymous define call per script file")){const r=window.define;typeof r=="function"&&r.amd&&delete r.amd;const n=zi(i,e);return L.emit("loadApp",{kind:t,status:"success"}),n}throw L.emit("loadApp",{kind:t,status:"failed",reason:s.message}),s}};async function Sr(i,e){const{timeout:t=1e4}=e,s=new AbortController,r=setTimeout(()=>s.abort(),t),n=await fetch(i,{...e,signal:s.signal,headers:{"content-type":"text/plain"}});return clearTimeout(r),n}class br{constructor(){this.kindEmitters=new Map,this.registered=new Map,this.appClassesCache=new Map,this.appClasses=new Map,this.syncRegisterApp=null,this.onSyncRegisterAppChange=e=>{this.register({kind:e.kind,src:e.src})}}setSyncRegisterApp(e){this.syncRegisterApp=e}async register(e){this.appClassesCache.delete(e.kind),this.registered.set(e.kind,e);const t=e.src;let s;if(typeof t=="string"&&(s=async()=>{const r=await wr(t,e.kind,e.name);return r.__esModule?r.default:r},this.syncRegisterApp&&this.syncRegisterApp({kind:e.kind,src:t,name:e.name})),typeof t=="function"&&(s=async()=>{let r=await t();if(r)return(r.__esModule||r.default)&&(r=r.default),r;throw new Error(`[WindowManager]: load remote script failed, ${t}`)}),typeof t=="object"&&(s=async()=>t),this.appClasses.set(e.kind,async()=>{let r=this.appClassesCache.get(e.kind);return r||(r=s(),this.appClassesCache.set(e.kind,r)),r}),e.addHooks){const r=this.createKindEmitter(e.kind);r&&e.addHooks(r)}}unregister(e){this.appClasses.delete(e),this.appClassesCache.delete(e),this.registered.delete(e);const t=this.kindEmitters.get(e);t&&(t.clearListeners(),this.kindEmitters.delete(e))}async notifyApp(e,t,s){const r=this.kindEmitters.get(e);await(r==null?void 0:r.emit(t,s))}createKindEmitter(e){if(!this.kindEmitters.has(e)){const t=new ve.default;this.kindEmitters.set(e,t)}return this.kindEmitters.get(e)}}const J=new br,vr=async i=>{var t,s;const e=await((t=J.appClasses.get(i))==null?void 0:t());return e&&((s=e.config)==null?void 0:s.singleton)?i:`${i}-${ir.v4().replace("-","").slice(0,8)}`},be=(i,e)=>{if(i.focusScenePath!==e)return i.focusScenePath=e,i},Ht=(i,e)=>{if(i&&i.isWritable&&i.state.sceneState.scenePath!==e){const t=e==="/"?"":e;i.setScenePath(t)}},Ir=(i,e,t)=>{var s;if(i&&e){const n=(s=Pe(i)[e])==null?void 0:s[t];if(n)return`${e}/${n.name}`}},Jt=(i,e,t)=>{i&&i.scenePathType(e)!==f.ScenePathType.None&&i.removeScenes(e,t)},yr=(i,e)=>{A.once(i).then(e)};w.debounce((i,e)=>{i.emit("mainViewModeChange",e)},200);const Cr=(i,e,t=0)=>{const s=Pe(i)[e];if(!s)return;const r=s[t];if(!r)return;const n=r.name;return e===q?`/${n}`:`${e}/${n}`},Pe=i=>i.entireScenes(),$e=(i,e,t,s)=>{var r;for(let n=0;n<t.length;++n)if((r=t[n].name)!=null&&r.includes("/"))throw new Error("scenes name can not have '/'");return i==null?void 0:i.putScenes(e,t,s)},Ar=i=>i.startsWith("/"),Et=i=>{const e=i.split("/");e.pop();let t=e.join("/");return t===""&&(t="/"),t},Br=i=>i.endsWith("/")?i.slice(0,-1):i,Di=i=>{const e=i.split(".").map(t=>t.padStart(2,"0")).join("");return parseInt(e)},as=i=>new Promise(e=>setTimeout(e,i)),Nr=i=>i.split("").reduce((t,s)=>(s===q&&(t+=1),t),0)===1;class zr{constructor(e){this.manager=e,this.displayer=this.manager.displayer,this.mainMagixEventListener=t=>{if(t.authorId!==this.displayer.observerId){const s=t.payload;switch(s.eventName){case R.AppMove:{this.appMoveHandler(s.payload);break}case R.AppResize:{this.appResizeHandler(s.payload);break}case R.AppBoxStateChange:{this.boxStateChangeHandler(s.payload);break}case R.SetMainViewScenePath:{this.setMainViewScenePathHandler(s.payload);break}case R.CursorMove:{this.cursorMoveHandler(s.payload);break}case R.RootDirRemoved:{this.rootDirRemovedHandler();break}case R.Refresh:{this.refreshHandler();break}case R.InitMainViewCamera:{this.initMainViewCameraHandler();break}case R.SetAppFocusIndex:{this.setAppFocusViewIndexHandler(s.payload);break}}}},this.appMoveHandler=t=>{var s;(s=this.boxManager)==null||s.moveBox(t)},this.appResizeHandler=t=>{var s,r;(s=this.boxManager)==null||s.resizeBox(Object.assign(t,{skipUpdate:!0})),(r=this.manager.room)==null||r.refreshViewSize()},this.boxStateChangeHandler=t=>{L.emit("boxStateChange",t)},this.setMainViewScenePathHandler=({nextScenePath:t})=>{be(this.manager.mainView,t),L.emit("mainViewScenePathChange",t)},this.cursorMoveHandler=t=>{A.emit("cursorMove",t)},this.rootDirRemovedHandler=()=>{this.manager.createRootDirScenesCallback(),this.manager.mainViewProxy.rebind(),A.emit("rootDirRemoved")},this.refreshHandler=()=>{this.manager.windowManger._refresh()},this.initMainViewCameraHandler=()=>{this.manager.mainViewProxy.addCameraReaction()},this.setAppFocusViewIndexHandler=t=>{if(t.type==="main")this.manager.setSceneIndexWithoutSync(t.index);else if(t.type==="app"&&t.appID){const s=this.manager.appProxies.get(t.appID);s&&s.setSceneIndexWithoutSync(t.index)}}}get boxManager(){return this.manager.boxManager}addListeners(){this.displayer.addMagixEventListener(Gt,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(Gt,this.mainMagixEventListener)}}class ns extends Error{constructor(){super(...arguments),this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class Dr extends Error{constructor(e){super(`[WindowManager]: app ${e} need register or provide src`)}}class te extends Error{constructor(){super(...arguments),this.message="[WindowManager]: AppManager must be initialized"}}class os extends Error{constructor(e){super(`[WindowManager]: white-web-sdk version must large than ${e}`)}}class hs extends Error{constructor(){super(...arguments),this.message="[WindowManager]: kind must be a valid string"}}class cs extends Error{constructor(){super(...arguments),this.message="[WindowManager]: box need created"}}class ls extends Error{constructor(){super(...arguments),this.message='[WindowManager]: ScenePath should start with "/"'}}class us extends Error{constructor(){super(...arguments),this.message="[WindowManager]: boxManager not found"}}class ds extends Error{constructor(){super(...arguments),this.message="[WindowManager]: room phase only Connected can be bindContainer"}}const gs="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Tr=gs.length,Ti=Array(20),Be=()=>{for(let i=0;i<20;i++)Ti[i]=gs.charAt(Math.random()*Tr);return Ti.join("")};class Ke{constructor(){this.disposers=new Map}add(e,t=Be()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=Be()){return this.flush(t),this.disposers.set(t,e),t}addEventListener(e,t,s,r,n=Be()){return this.add(()=>(e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)),n),n}setTimeout(e,t,s=Be()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(s),e()},t);return()=>window.clearTimeout(r)},s)}setInterval(e,t,s=Be()){return this.add(()=>{const r=window.setInterval(e,t);return()=>window.clearInterval(r)},s)}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){const t=this.remove(e);if(t)try{t()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(e=>{try{e()}catch(t){console.error(t)}}),this.disposers.clear()}}const ps=i=>(e,t)=>{if(e!==void 0)if(f.listenUpdated){const s=r=>{r.map(a=>a.kind).includes(i)&&t()};return f.listenUpdated(e,s),t(),()=>f.unlistenUpdated(e,s)}else return f.reaction(()=>e,()=>{t()},{fireImmediately:!0})},_e=(i,e,t)=>{let s=null;const r=f.reaction(i,()=>{s&&(s(),s=null);const n=i();w.isObject(n)?(s=()=>f.unlistenUpdated(n,e),f.listenUpdated(n,e)):t==null||t(n)},{fireImmediately:!0});return()=>{s==null||s(),r()}};ps(f.UpdateEventKind.Removed);ps(f.UpdateEventKind.Inserted);class Pr{constructor(){this.listeners=new Set}get length(){return this.listeners.size}dispatch(e){this.listeners.forEach(t=>t(e))}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}}const Vt=Object.keys;function Pi(i){return Boolean(w.has(i,"__isRef"))}function Lr(i){return{k:Be(),v:i,__isRef:!0}}const se="_WM-STORAGE_";class Li{constructor(e,t,s){if(this.maxIllusionQueueSize=500,this._sideEffect=new Ke,this._destroyed=!1,this._refMap=new WeakMap,this._lastValue=new Map,this.onStateChanged=new Pr,s&&!w.isObject(s))throw new Error(`Default state for Storage ${t} is not an object.`);this._context=e,this.id=t||null,this._state={};const r=this._getRawState(this._state);this._context.getIsWritable()&&(this.id===null?e.isAddApp&&s&&this.setState(s):(r===this._state||!w.isObject(r))&&(w.get(this._context.getAttributes(),[se])||this._context.updateAttributes([se],{}),this._context.updateAttributes([se,this.id],this._state),s&&this.setState(s))),Vt(r).forEach(n=>{if(!(this.id===null&&n===se))try{const a=w.isObject(r[n])?JSON.parse(JSON.stringify(r[n])):r[n];Pi(a)?(this._state[n]=a.v,w.isObject(a.v)&&this._refMap.set(a.v,a)):this._state[n]=a}catch(a){console.error(a)}}),this._sideEffect.addDisposer(_e(()=>this.id===null?e.getAttributes():w.get(e.getAttributes(),[se,this.id]),this._updateProperties.bind(this),this.destroy.bind(this)))}get state(){return this._destroyed&&console.warn(`Accessing state on destroyed Storage "${this.id}"`),this._state}addStateChangedListener(e){return this.onStateChanged.addListener(e),()=>this.onStateChanged.removeListener(e)}ensureState(e){return this.setState(Vt(e).reduce((t,s)=>(w.has(this._state,s)||(t[s]=e[s]),t),{}))}setState(e){if(this._destroyed){console.error(new Error(`Cannot call setState on destroyed Storage "${this.id}".`));return}if(!this._context.getIsWritable()){console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`),e);return}const t=Vt(e);t.length>0&&t.forEach(s=>{const r=e[s];if(r!==this._state[s])if(r===void 0)this._lastValue.set(s,this._state[s]),delete this._state[s],this._setRawState(s,r);else{this._lastValue.set(s,this._state[s]),this._state[s]=r;let n=r;if(w.isObject(r)){let a=this._refMap.get(r);a||(a=Lr(r),this._refMap.set(r,a)),n=a}this._setRawState(s,n)}})}emptyStorage(){if(!(w.size(this._state)<=0)){if(this._destroyed){console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));return}if(!this._context.getIsWritable()){console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));return}this.setState(w.mapValues(this._state,w.noop))}}deleteStorage(){if(this.id===null)throw new Error("Cannot delete main Storage");if(!this._context.getIsWritable()){console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));return}this.destroy(),this._context.updateAttributes([se,this.id],void 0)}get destroyed(){return this._destroyed}destroy(){this._destroyed=!0,this._sideEffect.flushAll()}_getRawState(e){var t;return this.id===null?(t=this._context.getAttributes())!=null?t:e:w.get(this._context.getAttributes(),[se,this.id],e)}_setRawState(e,t){if(this.id===null){if(e===se)throw new Error(`Cannot set attribute internal filed "${se}"`);return this._context.updateAttributes([e],t)}else return this._context.updateAttributes([se,this.id,e],t)}_updateProperties(e){var t;if(this._destroyed){console.error(new Error(`Cannot call _updateProperties on destroyed Storage "${this.id}".`));return}if(e.length>0){const s={};for(let r=0;r<e.length;r++)try{const n=e[r],a=n.key;if(this.id===null&&a===se)continue;const o=w.isObject(n.value)?JSON.parse(JSON.stringify(n.value)):n.value;let h;switch(this._lastValue.has(a)&&(h=this._lastValue.get(a),this._lastValue.delete(a)),n.kind){case 2:{w.has(this._state,a)&&(h=this._state[a],delete this._state[a]),s[a]={oldValue:h};break}default:{let c=o;if(Pi(o)){const{k:l,v:u}=o,d=this._state[a];w.isObject(d)&&((t=this._refMap.get(d))==null?void 0:t.k)===l?c=d:(c=u,w.isObject(u)&&this._refMap.set(u,o))}c!==this._state[a]&&(h=this._state[a],this._state[a]=c),s[a]={newValue:c,oldValue:h};break}}}catch(n){console.error(n)}this.onStateChanged.dispatch(s)}}}class qe{constructor(e,t,s,r,n){this.manager=e,this.boxManager=t,this.appId=s,this.appProxy=r,this.appOptions=n,this.mobxUtils={autorun:f.autorun,reaction:f.reaction,toJS:f.toJS},this.objectUtils={listenUpdated:f.listenUpdated,unlistenUpdated:f.unlistenUpdated,listenDisposed:f.listenDisposed,unlistenDisposed:f.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,this.getManager=()=>this.manager,this.getBoxManager=()=>this.boxManager,this.getWindowManager=()=>this.manager.windowManger,this.getBoxStatus=()=>this.manager.store.getBoxStatus(this.appId),this.getLastNotMinimizedBoxStatus=()=>this.manager.store.getLastNotMinimizedBoxStatus(this.appId),this.getDisplayer=()=>this.manager.displayer,this.getAppProxy=()=>this.appProxy,this.getAttributes=()=>this.appProxy.attributes,this.getScenes=()=>{const a=this.store.getAppAttributes(this.appId);return a!=null&&a.isDynamicPPT?this.appProxy.scenes:a==null?void 0:a.options.scenes},this.getView=()=>this.appProxy.view,this.mountView=a=>{const o=this.getView();o&&(o.divElement=a,setTimeout(()=>{var h;(h=this.getRoom())==null||h.refreshViewSize(),L.emit("onAppViewMounted",{appId:this.appId,view:o})},1e3))},this.getInitScenePath=()=>this.manager.getAppInitPath(this.appId),this.getIsWritable=()=>this.manager.canOperate,this.getBox=()=>{const a=this.boxManager.getBox(this.appId);if(a)return a;throw new cs},this.getRoom=()=>this.manager.room,this.setAttributes=a=>{this.manager.safeSetAttributes({[this.appId]:a})},this.updateAttributes=(a,o)=>{this.manager.attributes[this.appId]&&this.manager.safeUpdateAttributes([this.appId,...a],o)},this.setScenePath=async a=>{var o;!this.appProxy.box||(this.appProxy.setFullPath(a),(o=this.getRoom())==null||o.setScenePath(a))},this.getAppOptions=()=>typeof this.appOptions=="function"?this.appOptions():this.appOptions,this.createStorage=(a,o)=>{const h=new Li(this,a,o);return this.emitter.on("destroy",()=>{h.destroy()}),h},this.dispatchMagixEvent=(...a)=>{var h;const o=`${this.appId}:${a[0]}`;return(h=this.manager.room)==null?void 0:h.dispatchMagixEvent(o,a[1])},this.addMagixEventListener=(a,o,h)=>{const c=`${this.appId}:${a}`;return this.manager.displayer.addMagixEventListener(c,o,h),()=>this.manager.displayer.removeMagixEventListener(c,o)},this.removeMagixEventListener=this.manager.displayer.removeMagixEventListener.bind(this.manager.displayer),this.nextPage=async()=>{const a=this.pageState.index+1;return a>this.pageState.length-1?(console.warn("[WindowManager] nextPage: index out of range"),!1):(this.appProxy.setSceneIndex(a),!0)},this.jumpPage=async a=>0<=a&&a<this.pageState.length?(this.appProxy.setSceneIndex(a),!0):(console.warn("[WindowManager] nextPage: index out of range"),!1),this.prevPage=async()=>{const a=this.pageState.index-1;return a<0?(console.warn("[WindowManager] prevPage: index out of range"),!1):(this.appProxy.setSceneIndex(a),!0)},this.addPage=async a=>{const o=a==null?void 0:a.after,h=a==null?void 0:a.scene,c=this.appProxy.scenePath;if(!!c)if(o){const l=this.pageState.index+1;$e(this.manager.room,c,[h||{}],l)}else $e(this.manager.room,c,[h||{}])},this.removePage=async a=>{const o=a===void 0?this.pageState.index:a;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):o<0||o>=this.pageState.length?(console.warn(`[WindowManager]: page index ${a} out of range`),!1):this.appProxy.removeSceneByIndex(o)},this.emitter=r.appEmitter,this.isAddApp=r.isAddApp}get storage(){return this._storage||(this._storage=new Li(this)),this._storage}get pageState(){return this.appProxy.pageState}get kind(){return this.appProxy.kind}dispatchAppEvent(e,t){A.emit(`custom-${this.kind}`,{kind:this.kind,appId:this.appId,type:e,value:t})}}qe.kind="AppContext";class Er{constructor(e){this.params=e,this.sceneNode=null,this.onSceneChange=r=>{this.sceneNode=r,this.params.notifyPageStateChange()};const{displayer:t,scenePath:s}=this.params;s&&(this.sceneNode=t.createScenesCallback(s,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}))}getFullPath(e){var s;const t=(s=this.sceneNode)==null?void 0:s.scenes;if(this.params.scenePath&&t){const r=t[e];if(r)return`${this.params.scenePath}/${r}`}}toObject(){var e,t;return{index:((e=this.params.view)==null?void 0:e.focusSceneIndex)||0,length:((t=this.sceneNode)==null?void 0:t.scenes.length)||0}}destroy(){var e;(e=this.sceneNode)==null||e.dispose()}}var ms={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var m=new r(l,u||h,d),g=t?t+c:c;return h._events[g]?h._events[g].fn?h._events[g]=[h._events[g],m]:h._events[g].push(m):(h._events[g]=m,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new s:delete h._events[c]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)e.call(l,u)&&c.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=t?t+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,m=u.length,g=new Array(m);d<m;d++)g[d]=u[d].fn;return g},o.prototype.listenerCount=function(c){var l=t?t+c:c,u=this._events[l];return u?u.fn?1:u.length:0},o.prototype.emit=function(c,l,u,d,m,g){var b=t?t+c:c;if(!this._events[b])return!1;var M=this._events[b],N=arguments.length,z,v;if(M.fn){switch(M.once&&this.removeListener(c,M.fn,void 0,!0),N){case 1:return M.fn.call(M.context),!0;case 2:return M.fn.call(M.context,l),!0;case 3:return M.fn.call(M.context,l,u),!0;case 4:return M.fn.call(M.context,l,u,d),!0;case 5:return M.fn.call(M.context,l,u,d,m),!0;case 6:return M.fn.call(M.context,l,u,d,m,g),!0}for(v=1,z=new Array(N-1);v<N;v++)z[v-1]=arguments[v];M.fn.apply(M.context,z)}else{var Z=M.length,_;for(v=0;v<Z;v++)switch(M[v].once&&this.removeListener(c,M[v].fn,void 0,!0),N){case 1:M[v].fn.call(M[v].context);break;case 2:M[v].fn.call(M[v].context,l);break;case 3:M[v].fn.call(M[v].context,l,u);break;case 4:M[v].fn.call(M[v].context,l,u,d);break;default:if(!z)for(_=1,z=new Array(N-1);_<N;_++)z[_-1]=arguments[_];M[v].fn.apply(M[v].context,z)}}return!0},o.prototype.on=function(c,l,u){return n(this,c,l,u,!1)},o.prototype.once=function(c,l,u){return n(this,c,l,u,!0)},o.prototype.removeListener=function(c,l,u,d){var m=t?t+c:c;if(!this._events[m])return this;if(!l)return a(this,m),this;var g=this._events[m];if(g.fn)g.fn===l&&(!d||g.once)&&(!u||g.context===u)&&a(this,m);else{for(var b=0,M=[],N=g.length;b<N;b++)(g[b].fn!==l||d&&!g[b].once||u&&g[b].context!==u)&&M.push(g[b]);M.length?this._events[m]=M.length===1?M[0]:M:a(this,m)}return this},o.prototype.removeAllListeners=function(c){var l;return c?(l=t?t+c:c,this._events[l]&&a(this,l)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(ms);var Xt=ms.exports;/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -12,38 +12,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var Ae=function(){return Ae=Object.assign||function(t){for(var i,n=1,r=arguments.length;n<r;n++){i=arguments[n];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},Ae.apply(this,arguments)};function hl(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i}var Io=0,td=typeof window!="undefined"&&window.requestAnimationFrame!==void 0?function(e){return window.requestAnimationFrame(e)}:function(e){var t=Date.now(),i=Math.max(0,16.7-(t-Io));Io=t+i,setTimeout(function(){return e(Io)},i)},ym=function(e){var t=[],i=[],n=0,r=!1,s=0,o=new WeakSet,a=new WeakSet,l={cancel:function(u){var c=i.indexOf(u);o.add(u),c!==-1&&i.splice(c,1)},process:function(u){var c;if(r=!0,c=[i,t],t=c[0],i=c[1],i.length=0,n=t.length,n){var h;for(s=0;s<n;s++)h=t[s],h(u),a.has(h)===!0&&!o.has(h)&&(l.schedule(h),e(!0))}r=!1},schedule:function(u,c,h){c===void 0&&(c=!1),h===void 0&&(h=!1);var m=h&&r,v=m?t:i;o.delete(u),c&&a.add(u),v.indexOf(u)===-1&&(v.push(u),m&&(n=t.length))}};return l},xm=40,Qu=1/60*1e3,ns=!0,Kn=!1,ra=!1,Pn={delta:0,timestamp:0},dl=["read","update","preRender","render","postRender"],Sm=function(e){return Kn=e},id=dl.reduce(function(e,t){return e[t]=ym(Sm),e},{}),Mm=dl.reduce(function(e,t){var i=id[t];return e[t]=function(n,r,s){return r===void 0&&(r=!1),s===void 0&&(s=!1),Kn||bm(),i.schedule(n,r,s),n},e},{}),Cm=function(e){return id[e].process(Pn)},nd=function(e){Kn=!1,Pn.delta=ns?Qu:Math.max(Math.min(e-Pn.timestamp,xm),1),ns||(Qu=Pn.delta),Pn.timestamp=e,ra=!0,dl.forEach(Cm),ra=!1,Kn&&(ns=!1,td(nd))},bm=function(){Kn=!0,ns=!0,ra||td(nd)},rd=function(e,t){return function(i){return Math.max(Math.min(i,t),e)}},rs=function(e){return e%1?Number(e.toFixed(5)):e},sd=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,Ks={test:function(e){return typeof e=="number"},parse:parseFloat,transform:function(e){return e}},jn=Ae(Ae({},Ks),{transform:rd(0,1)}),jr=Ae(Ae({},Ks),{default:1}),fl=function(e){return{test:function(t){return typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1},parse:parseFloat,transform:function(t){return""+t+e}}},ni=fl("deg"),_n=fl("%"),U=fl("px"),Zu=Ae(Ae({},_n),{parse:function(e){return _n.parse(e)/100},transform:function(e){return _n.transform(e*100)}}),Im=function(e){return e.substring(e.indexOf("(")+1,e.lastIndexOf(")"))},Tm=rd(0,255),sa=function(e){return e.red!==void 0},oa=function(e){return e.hue!==void 0};function Am(e){return Im(e).replace(/(,|\/)/g," ").split(/ \s*/)}var od=function(e){return function(t){if(typeof t!="string")return t;for(var i={},n=Am(t),r=0;r<4;r++)i[e[r]]=n[r]!==void 0?parseFloat(n[r]):1;return i}},Em=function(e){var t=e.red,i=e.green,n=e.blue,r=e.alpha,s=r===void 0?1:r;return"rgba("+t+", "+i+", "+n+", "+s+")"},Nm=function(e){var t=e.hue,i=e.saturation,n=e.lightness,r=e.alpha,s=r===void 0?1:r;return"hsla("+t+", "+i+", "+n+", "+s+")"},To=Ae(Ae({},Ks),{transform:function(e){return Math.round(Tm(e))}});function pl(e,t){return e.startsWith(t)&&sd.test(e)}var ss={test:function(e){return typeof e=="string"?pl(e,"rgb"):sa(e)},parse:od(["red","green","blue","alpha"]),transform:function(e){var t=e.red,i=e.green,n=e.blue,r=e.alpha,s=r===void 0?1:r;return Em({red:To.transform(t),green:To.transform(i),blue:To.transform(n),alpha:rs(jn.transform(s))})}},Ao={test:function(e){return typeof e=="string"?pl(e,"hsl"):oa(e)},parse:od(["hue","saturation","lightness","alpha"]),transform:function(e){var t=e.hue,i=e.saturation,n=e.lightness,r=e.alpha,s=r===void 0?1:r;return Nm({hue:Math.round(t),saturation:_n.transform(rs(i)),lightness:_n.transform(rs(n)),alpha:rs(jn.transform(s))})}},Yu=Ae(Ae({},ss),{test:function(e){return typeof e=="string"&&pl(e,"#")},parse:function(e){var t="",i="",n="";return e.length>4?(t=e.substr(1,2),i=e.substr(3,2),n=e.substr(5,2)):(t=e.substr(1,1),i=e.substr(2,1),n=e.substr(3,1),t+=t,i+=i,n+=n),{red:parseInt(t,16),green:parseInt(i,16),blue:parseInt(n,16),alpha:1}}}),rt={test:function(e){return typeof e=="string"&&sd.test(e)||sa(e)||oa(e)},parse:function(e){return ss.test(e)?ss.parse(e):Ao.test(e)?Ao.parse(e):Yu.test(e)?Yu.parse(e):e},transform:function(e){return sa(e)?ss.transform(e):oa(e)?Ao.transform(e):e}},gl=function(e){var t=e.onRead,i=e.onRender,n=e.uncachedValues,r=n===void 0?new Set:n,s=e.useCache,o=s===void 0?!0:s;return function(a){a===void 0&&(a={});var l=hl(a,[]),u={},c=[],h=!1;function m(w,x){w.startsWith("--")&&(l.hasCSSVariable=!0);var d=u[w];u[w]=x,u[w]!==d&&(c.indexOf(w)===-1&&c.push(w),h||(h=!0,Mm.render(v.render)))}var v={get:function(w,x){x===void 0&&(x=!1);var d=!x&&o&&!r.has(w)&&u[w]!==void 0;return d?u[w]:t(w,l)},set:function(w,x){if(typeof w=="string")m(w,x);else for(var d in w)m(d,w[d]);return this},render:function(w){return w===void 0&&(w=!1),(h||w===!0)&&(i(u,l,c),h=!1,c.length=0),this}};return v}},km=/([a-z])([A-Z])/g,Pm="$1-$2",qs=function(e){return e.replace(km,Pm).toLowerCase()},ad=new Map,ml=new Map,ld=["Webkit","Moz","O","ms",""],zm=ld.length,Bm=typeof document!="undefined",Eo,ud=function(e,t){return ml.set(e,qs(t))},Dm=function(e){Eo=Eo||document.createElement("div");for(var t=0;t<zm;t++){var i=ld[t],n=i==="",r=n?e:i+e.charAt(0).toUpperCase()+e.slice(1);if(r in Eo.style||n){if(n&&e==="clipPath"&&ml.has(e))return;ad.set(e,r),ud(e,(n?"":"-")+qs(r))}}},Lm=function(e){return ud(e,e)},cd=function(e,t){t===void 0&&(t=!1);var i=t?ml:ad;return i.has(e)||(Bm?Dm(e):Lm(e)),i.get(e)||e},Rm=["","X","Y","Z"],jm=["translate","scale","rotate","skew","transformPerspective"],aa=jm.reduce(function(e,t){return Rm.reduce(function(i,n){return i.push(t+n),i},e)},["x","y","z"]),_m=aa.reduce(function(e,t){return e[t]=!0,e},{});function vl(e){return _m[e]===!0}function Vm(e,t){return aa.indexOf(e)-aa.indexOf(t)}var Om=new Set(["originX","originY","originZ"]);function $m(e){return Om.has(e)}var Gu=Ae(Ae({},Ks),{transform:Math.round}),Um={color:rt,backgroundColor:rt,outlineColor:rt,fill:rt,stroke:rt,borderColor:rt,borderTopColor:rt,borderRightColor:rt,borderBottomColor:rt,borderLeftColor:rt,borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,radius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,size:U,top:U,right:U,bottom:U,left:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,rotate:ni,rotateX:ni,rotateY:ni,rotateZ:ni,scale:jr,scaleX:jr,scaleY:jr,scaleZ:jr,skew:ni,skewX:ni,skewY:ni,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,opacity:jn,originX:Zu,originY:Zu,originZ:U,zIndex:Gu,fillOpacity:jn,strokeOpacity:jn,numOctaves:Gu},wl=function(e){return Um[e]},Wm=function(e,t){return t&&typeof e=="number"?t.transform(e):e},Vn="scrollLeft",On="scrollTop",hd=new Set([Vn,On]),Hm=new Set([Vn,On,"transform"]),Fm={x:"translateX",y:"translateY",z:"translateZ"};function dd(e){return typeof e=="function"}function Qm(e,t,i,n,r,s){s===void 0&&(s=!0);var o="",a=!1;i.sort(Vm);for(var l=i.length,u=0;u<l;u++){var c=i[u];o+=(Fm[c]||c)+"("+t[c]+") ",a=c==="z"?!0:a}return!a&&r?o+="translateZ(0)":o=o.trim(),dd(e.transform)?o=e.transform(t,n?"":o):s&&n&&(o="none"),o}function Zm(e,t,i,n,r,s,o,a){t===void 0&&(t=!0),i===void 0&&(i={}),n===void 0&&(n={}),r===void 0&&(r={}),s===void 0&&(s=[]),o===void 0&&(o=!1),a===void 0&&(a=!0);var l=!0,u=!1,c=!1;for(var h in e){var m=e[h],v=wl(h),w=Wm(m,v);vl(h)?(u=!0,n[h]=w,s.push(h),l&&(v.default&&m!==v.default||!v.default&&m!==0)&&(l=!1)):$m(h)?(r[h]=w,c=!0):(!Hm.has(h)||!dd(w))&&(i[cd(h,o)]=w)}return(u||typeof e.transform=="function")&&(i.transform=Qm(e,n,s,l,t,a)),c&&(i.transformOrigin=(r.originX||"50%")+" "+(r.originY||"50%")+" "+(r.originZ||0)),i}function yl(e){var t=e===void 0?{}:e,i=t.enableHardwareAcceleration,n=i===void 0?!0:i,r=t.isDashCase,s=r===void 0?!0:r,o=t.allowTransformNone,a=o===void 0?!0:o,l={},u={},c={},h=[];return function(m){return h.length=0,Zm(m,n,l,u,c,h,s,a),l}}function Ym(e,t){var i=t.element,n=t.preparseOutput,r=wl(e);if(vl(e))return r&&r.default||0;if(hd.has(e))return i[e];var s=window.getComputedStyle(i,null).getPropertyValue(cd(e,!0))||0;return n&&r&&r.test(s)&&r.parse?r.parse(s):s}function Gm(e,t,i){var n=t.element,r=t.buildStyles,s=t.hasCSSVariable;if(Object.assign(n.style,r(e)),s)for(var o=i.length,a=0;a<o;a++){var l=i[a];l.startsWith("--")&&n.style.setProperty(l,e[l])}i.indexOf(Vn)!==-1&&(n[Vn]=e[Vn]),i.indexOf(On)!==-1&&(n[On]=e[On])}var Xm=gl({onRead:Ym,onRender:Gm,uncachedValues:hd});function Jm(e,t){t===void 0&&(t={});var i=t.enableHardwareAcceleration,n=t.allowTransformNone,r=hl(t,["enableHardwareAcceleration","allowTransformNone"]);return Xm(Ae({element:e,buildStyles:yl({enableHardwareAcceleration:i,allowTransformNone:n}),preparseOutput:!0},r))}var fd=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues"]),Xu=.5,pd=function(){return{style:{}}},No=function(e,t){return U.transform(e*t)},Km={x:0,y:0,width:0,height:0};function Ju(e,t,i){return typeof e=="string"?e:U.transform(t+i*e)}function qm(e,t,i){return Ju(t,e.x,e.width)+" "+Ju(i,e.y,e.height)}var gd={enableHardwareAcceleration:!1,isDashCase:!1};function ev(e,t,i,n,r,s){t===void 0&&(t=Km),n===void 0&&(n=yl(gd)),r===void 0&&(r=pd()),s===void 0&&(s=!0);var o=e.attrX,a=e.attrY,l=e.originX,u=e.originY,c=e.pathLength,h=e.pathSpacing,m=h===void 0?1:h,v=e.pathOffset,w=v===void 0?0:v,x=hl(e,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]),d=n(x);for(var f in d)if(f==="transform")r.style.transform=d[f];else{var g=s&&!fd.has(f)?qs(f):f;r[g]=d[f]}return(l!==void 0||u!==void 0||d.transform)&&(r.style.transformOrigin=qm(t,l!==void 0?l:Xu,u!==void 0?u:Xu)),o!==void 0&&(r.x=o),a!==void 0&&(r.y=a),i!==void 0&&c!==void 0&&(r[s?"stroke-dashoffset":"strokeDashoffset"]=No(-w,i),r[s?"stroke-dasharray":"strokeDasharray"]=No(c,i)+" "+No(m,i)),r}function tv(e,t,i){i===void 0&&(i=!0);var n=pd(),r=yl(gd);return function(s){return ev(s,e,t,r,n,i)}}var iv=function(e){return typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()},nv=function(e){try{return iv(e)}catch{return{x:0,y:0,width:0,height:0}}},rv=function(e){return e.tagName==="path"},sv=gl({onRead:function(e,t){var i=t.element;if(e=fd.has(e)?e:qs(e),vl(e)){var n=wl(e);return n&&n.default||0}else return i.getAttribute(e)},onRender:function(e,t){var i=t.element,n=t.buildAttrs,r=n(e);for(var s in r)s==="style"?Object.assign(i.style,r.style):i.setAttribute(s,r[s])}}),ov=function(e){var t=nv(e),i=rv(e)&&e.getTotalLength?e.getTotalLength():void 0;return sv({element:e,buildAttrs:tv(t,i)})},av=gl({useCache:!1,onRead:function(e){return e==="scrollTop"?window.pageYOffset:window.pageXOffset},onRender:function(e){var t=e.scrollTop,i=t===void 0?0:t,n=e.scrollLeft,r=n===void 0?0:n;return window.scrollTo(r,i)}}),la=new WeakMap,lv=function(e){return e instanceof HTMLElement||typeof e.click=="function"},uv=function(e){return e instanceof SVGElement||"ownerSVGElement"in e},cv=function(e,t){var i;return e===window?i=av(e):lv(e)?i=Jm(e,t):uv(e)&&(i=ov(e)),la.set(e,i),i},hv=function(e,t){return la.has(e)?la.get(e):cv(e,t)};function dv(e,t){var i=typeof e=="string"?document.querySelector(e):e;return hv(i,t)}var ot=function(t,i,n,r){var s=n?n.call(r,t,i):void 0;if(s!==void 0)return!!s;if(t===i)return!0;if(typeof t!="object"||!t||typeof i!="object"||!i)return!1;var o=Object.keys(t),a=Object.keys(i);if(o.length!==a.length)return!1;for(var l=Object.prototype.hasOwnProperty.bind(i),u=0;u<o.length;u++){var c=o[u];if(!l(c))return!1;var h=t[c],m=i[c];if(s=n?n.call(r,h,m,c):void 0,s===!1||s===void 0&&h!==m)return!1}return!0};const md="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",fv=md.length,Ku=Array(20),yn=()=>{for(let e=0;e<20;e++)Ku[e]=md.charAt(Math.random()*fv);return Ku.join("")};class Ss{constructor(){this.disposers=new Map}add(t,i=yn()){return this.flush(i),this.disposers.set(i,t()),i}addDisposer(t,i=yn()){return this.flush(i),this.disposers.set(i,t),i}addEventListener(t,i,n,r,s=yn()){return this.add(()=>(t.addEventListener(i,n,r),()=>t.removeEventListener(i,n,r)),s),s}setTimeout(t,i,n=yn()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(n),t()},i);return()=>window.clearTimeout(r)},n)}setInterval(t,i,n=yn()){return this.add(()=>{const r=window.setInterval(t,i);return()=>window.clearInterval(r)},n)}remove(t){const i=this.disposers.get(t);return this.disposers.delete(t),i}flush(t){const i=this.remove(t);if(i)try{i()}catch(n){console.error(n)}}flushAll(){this.disposers.forEach(t=>{try{t()}catch(i){console.error(i)}}),this.disposers.clear()}}var pv=Object.defineProperty,ko=(typeof require!="undefined"&&require,(e,t,i)=>(((n,r,s)=>{r in n?pv(n,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[r]=s})(e,typeof t!="symbol"?t+"":t,i),i));class pr{constructor(t,i){ko(this,"_value"),ko(this,"_beforeDestroys"),ko(this,"_subscribers"),this._value=t,i&&(this.compare=i)}get value(){return this._value}setValue(t,i){if(!this.compare(t,this._value)){const n=this._value;this._value=t,this._subscribers&&this._subscribers.forEach(r=>r(t,n,i))}}reaction(t){return this._subscribers||(this._subscribers=new Set),this._subscribers.add(t),()=>{this._subscribers&&this._subscribers.delete(t)}}subscribe(t,i){const n=this.reaction(t);return t(this._value,void 0,i),n}derive(t,i,n){const r=new pr(t(this.value,void 0,n),i),s=this.reaction((o,a,l)=>{r.setValue(t(o,a,l))});return r.addBeforeDestroy(s),r}destroy(){this._beforeDestroys&&(this._beforeDestroys.forEach(t=>t()),this._beforeDestroys.clear()),this._subscribers&&this._subscribers.clear()}addBeforeDestroy(t){return this._beforeDestroys||(this._beforeDestroys=new Set),this._beforeDestroys.add(t),()=>{this._beforeDestroys&&this._beforeDestroys.delete(t)}}compare(t,i){return t===i}}function gv(e,t,i,n){let r=e.map(o=>o.value);const s=new pr(t(r,void 0,n),i);return e.forEach((o,a)=>{const l=o.reaction((u,c,h)=>{const m=r.slice();m[a]=u;const v=r;r=m,s.setValue(t(m,v,h),h)});s.addBeforeDestroy(l)}),s}function vd(e,t){Object.keys(t).forEach(i=>{mv(e,i,t[i])})}function mv(e,t,i){var n;return Object.defineProperties(e,{[t]:{get:()=>i.value},[`_${t}$`]:{value:i},[`set${n=t,n[0].toUpperCase()+n.slice(1)}`]:{value:(r,s)=>i.setValue(r,s)}}),e}function wd(e){const t=i=>{const n=e.addDisposer(()=>{i.destroy()});return i.addBeforeDestroy(()=>{e.remove(n)}),i};return{bindSideEffect:t,combine:(i,n,r,s)=>t(gv(i,n,r,s)),createVal:(i,n)=>t(new pr(i,n))}}var xl=(e=>(e.Light="light",e.Dark="dark",e.Auto="auto",e))(xl||{}),N=(e=>(e.Normal="normal",e.Minimized="minimized",e.Maximized="maximized",e))(N||{}),oe=(e=>(e.DarkMode="dark_mode",e.PrefersColorScheme="prefers_color_scheme",e.Close="close",e.Focus="focus",e.Blur="blur",e.Move="move",e.Resize="resize",e.IntrinsicMove="intrinsic_move",e.IntrinsicResize="intrinsic_resize",e.VisualResize="visual_resize",e.ZIndex="z_index",e.State="state",e.Minimized="minimized",e.Maximized="maximized",e.Readonly="readonly",e.Destroyed="destroyed",e.BoxStatus="box_status",e.LastNotMinimizedBoxStatus="last_not_minimized_box_status",e.ForceTop="force_top",e.ForceNormal="force_normal",e))(oe||{}),Ie=(e=>(e.Close="close",e.Maximize="maximize",e.Minimize="minimize",e))(Ie||{}),at=(e=>(e.North="n",e.South="s",e.West="w",e.East="e",e.NorthWest="nw",e.NorthEast="ne",e.SouthEast="se",e.SouthWest="sw",e))(at||{});const Po="dh";function Pe(e,t,i){return Math.min(Math.max(e,t),i)}function Fi(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}function qu(e){return e.touches?e.touches[0]:e}function vv(){return Date.now().toString().slice(6)+Math.random().toString().slice(2,8)}let wv=1;function yv(){return`New Box ${wv++}`}function xv(e){return Boolean(e)}function _r(e){return!e}class yd{constructor({readonly:t=!1,title:i,buttons:n,onEvent:r,onDragStart:s,namespace:o="telebox",state:a=N.Normal,boxStatus:l,forceTop:u=!1,forceNormal:c=!1}={}){this.$btns=[],this.sideEffect=new Ss,this.lastTitleBarClick={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarClick=h=>{var m;if(this.readonly||h.button!==0||(m=h.target.dataset)!=null&&m.teleTitleBarNoDblClick)return;Fi(h);const v=Date.now();v-this.lastTitleBarClick.timestamp<=500?Math.abs(h.clientX-this.lastTitleBarClick.clientX)<=5&&Math.abs(h.clientY-this.lastTitleBarClick.clientY)<=5&&this.onEvent&&this.onEvent({type:Ie.Maximize}):this.onDragStart&&this.onDragStart(h),this.lastTitleBarClick.timestamp=v,this.lastTitleBarClick.clientX=h.clientX,this.lastTitleBarClick.clientY=h.clientY},this.lastTitleBarTouch={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarTouch=h=>{var m;if(this.readonly||(m=h.target.dataset)!=null&&m.teleTitleBarNoDblClick)return;Fi(h);const v=Date.now(),{clientX:w=this.lastTitleBarTouch.clientX+100,clientY:x=this.lastTitleBarTouch.clientY+100}=h.touches[0]||{};v-this.lastTitleBarTouch.timestamp<=500?Math.abs(w-this.lastTitleBarTouch.clientX)<=10&&Math.abs(x-this.lastTitleBarTouch.clientY)<=10&&this.onEvent&&this.onEvent({type:Ie.Maximize}):this.onDragStart&&this.onDragStart(h),this.lastTitleBarTouch.timestamp=v,this.lastTitleBarTouch.clientX=w,this.lastTitleBarTouch.clientY=x},this.readonly=t,this.onEvent=r,this.onDragStart=s,this.namespace=o,this.title=i,this.state=a,this.boxStatus=l,this.forceTop=u,this.forceNormal=c,this.buttons=n||(c?[{type:Ie.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}]:[{type:Ie.Minimize,iconClassName:this.wrapClassName("titlebar-icon-minimize")},{type:Ie.Maximize,iconClassName:this.wrapClassName("titlebar-icon-maximize"),isActive:h=>h===N.Maximized},{type:Ie.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}]),this.$dragArea=this.renderDragArea()}setTitle(t){this.title=t,this.$title&&(this.$title.textContent=t,this.$title.title=t)}setState(t){this.state!==t&&(this.state=t,this.buttons.forEach((i,n)=>{i.isActive&&this.$btns[n].classList.toggle("is-active",i.isActive(t))}))}setBoxStatus(t){this.boxStatus!==t&&(this.boxStatus=t,t&&this.buttons.forEach((i,n)=>{i.isActive&&this.$btns[n].classList.toggle("is-active",i.isActive(t))}))}setReadonly(t){this.readonly!==t&&(this.readonly=t)}render(){if(!this.$titleBar){this.$titleBar=document.createElement("div"),this.$titleBar.className=this.wrapClassName("titlebar");const t=document.createElement("div");t.className=this.wrapClassName("title-area"),t.dataset.teleBoxHandle=Po,this.$title=document.createElement("h1"),this.$title.className=this.wrapClassName("title"),this.$title.dataset.teleBoxHandle=Po,this.title&&(this.$title.textContent=this.title,this.$title.title=this.title),t.appendChild(this.$title),t.appendChild(this.$dragArea);const i=document.createElement("div");i.className=this.wrapClassName("titlebar-btns"),this.buttons.forEach(({iconClassName:n,isActive:r},s)=>{const o=String(s),a=document.createElement("button");a.className=`${this.wrapClassName("titlebar-btn")} ${n}`,a.dataset.teleTitleBarBtnIndex=o,a.dataset.teleTitleBarNoDblClick="true",r&&a.classList.toggle("is-active",r(this.boxStatus||this.state)),this.$btns.push(a),i.appendChild(a)}),this.sideEffect.addEventListener(i,"click",n=>{var r;if(this.readonly)return;const s=n.target,o=Number((r=s.dataset)==null?void 0:r.teleTitleBarBtnIndex);if(!Number.isNaN(o)&&o<this.buttons.length){Fi(n);const a=this.buttons[o];this.onEvent&&this.onEvent({type:a.type,value:a.value})}}),this.$titleBar.appendChild(t),this.$titleBar.appendChild(i)}return this.$titleBar}renderDragArea(){const t=document.createElement("div");return t.className=this.wrapClassName("drag-area"),t.dataset.teleBoxHandle=Po,this.sideEffect.addEventListener(t,"mousedown",this.handleTitleBarClick),this.sideEffect.addEventListener(t,"touchstart",this.handleTitleBarTouch,{passive:!0}),t}dragHandle(){return this.$titleBar}wrapClassName(t){return`${this.namespace}-${t}`}destroy(){this.sideEffect.flushAll(),this.$titleBar&&(this.$titleBar=void 0,this.$title=void 0,this.$btns.length=0,this.onDragStart=void 0,this.onEvent=void 0)}}class Sv{constructor({id:t=vv(),title:i=yv(),prefersColorScheme:n=xl.Light,darkMode:r,visible:s=!0,width:o=.5,height:a=.5,minWidth:l=0,minHeight:u=0,x:c=.1,y:h=.1,minimized:m=!1,maximized:v=!1,readonly:w=!1,resizable:x=!0,draggable:d=!0,fence:f=!0,fixRatio:g=!1,focus:p=!1,zIndex:y=100,namespace:S="telebox",titleBar:A,content:k,footer:z,styles:B,containerRect:ee={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collectorRect:b,boxStatus:M,lastNotMinimizedBoxStatus:V,forceTop:D=!1,forceNormal:Z=!1,isDragContent:te=!1}={}){this._renderSideEffect=new Ss,this.handleTrackStart=P=>{var X;return(X=this._handleTrackStart)==null?void 0:X.call(this,P)},this._sideEffect=new Ss,this._valSideEffectBinder=wd(this._sideEffect);const{combine:he,createVal:Y}=this._valSideEffectBinder;this.id=t,this.namespace=S,this.events=new na,this._delegateEvents=new na;const ke=Y(M),ki=Y(V),ei=Y(n);ei.reaction((P,X,j)=>{j||this.events.emit(oe.PrefersColorScheme,P)});const kt=Y(Boolean(r));r==null&&ei.subscribe((P,X,j)=>{this._sideEffect.add(()=>{if(P==="auto"){const fe=window.matchMedia("(prefers-color-scheme: dark)");if(fe){kt.setValue(fe.matches,j);const zi=Rr=>{kt.setValue(Rr.matches,j)};return fe.addListener(zi),()=>fe.removeListener(zi)}else return ec}else return kt.setValue(P==="dark",j),ec},"prefers-color-scheme")}),kt.reaction((P,X,j)=>{j||this.events.emit(oe.DarkMode,P)});const mn=Y(ee,ot),T=Y(b,ot),R=Y(D);R.reaction((P,X,j)=>{j||this.events.emit(oe.ForceTop,P||!1)});const H=Y(Z);H.reaction((P,X,j)=>{j||this.events.emit(oe.ForceNormal,P||!1)});const ie=Y(te),ne=Y(i);ne.reaction((P,X,j)=>{j||this.titleBar.setTitle(P)});const Je=Y(s);Je.reaction((P,X,j)=>{!j&&!P&&this.events.emit(oe.Close)});const Qe=Y(w);Qe.reaction((P,X,j)=>{j||this.events.emit(oe.Readonly,P)});const ti=Y(x),Pt=Y(d),kg=Y(f),Pg=Y(g),Bu=Y(y);Bu.reaction((P,X,j)=>{j||this.events.emit(oe.ZIndex,P)});const Du=Y(p);Du.reaction((P,X,j)=>{j||this.events.emit(P?oe.Focus:oe.Blur)});const Pi=Y(m);Pi.reaction((P,X,j)=>{j||this.events.emit(oe.Minimized,P)});const ii=Y(v);ii.reaction((P,X,j)=>{j||this.events.emit(oe.Maximized,P)});const Lu=he([Pi,ii,ke],([P,X,j])=>P?N.Minimized:X?N.Maximized:j||N.Normal);Lu.reaction((P,X,j)=>{j||this.events.emit(oe.State,P)});const Dr=Y({width:Pe(l,0,1),height:Pe(u,0,1)},ot),vn=Y({width:Pe(o,Dr.value.width,1),height:Pe(a,Dr.value.height,1)},ot);Dr.reaction((P,X,j)=>{vn.setValue({width:Pe(o,P.width,1),height:Pe(a,P.height,1)},j)}),vn.reaction((P,X,j)=>{j||this.events.emit(oe.IntrinsicResize,P)});const wn=he([vn,ii,ke],([P,X,j])=>X||j===N.Maximized?{width:1,height:1}:P,ot);wn.reaction((P,X,j)=>{j||this.events.emit(oe.Resize,P)});const Ru=he([wn,Pi,mn,T,ke],([P,X,j,fe,zi])=>(X||zi===N.Minimized)&&fe?{width:fe.width/P.width/j.width,height:fe.height/P.height/j.height}:P,ot);Ru.reaction((P,X,j)=>{j||this.events.emit(oe.VisualResize,P)});const So=Y({x:Pe(c,0,1),y:Pe(h,0,1)},ot);So.reaction((P,X,j)=>{j||this.events.emit(oe.IntrinsicMove,P)});const Lr=he([So,vn,mn,T,Pi,ii,ke,ki],([P,X,j,fe,zi,Rr,ju,Lg])=>(zi||ju===N.Minimized)&&fe?Rr||Lg===N.Maximized?{x:(fe.x+fe.width/2)/j.width-1/2,y:(fe.y+fe.height/2)/j.height-1/2}:{x:(fe.x+fe.width/2)/j.width-X.width/2,y:(fe.y+fe.height/2)/j.height-X.height/2}:Rr||ju===N.Maximized?{x:0,y:0}:P,ot);Lr.reaction((P,X,j)=>{j||this.events.emit(oe.Move,P)}),this.titleBar=A||new yd({readonly:Qe.value,title:ne.value,namespace:this.namespace,boxStatus:ke.value,forceTop:R.value,forceNormal:H.value,onDragStart:P=>{var X;return(X=this._handleTrackStart)==null?void 0:X.call(this,P)},onEvent:P=>{if(this._delegateEvents.listeners.length>0)this._delegateEvents.emit(P.type);else switch(P.type){case Ie.Maximize:{ke.value||ii.setValue(!ii.value);break}case Ie.Minimize:{ke.value||Pi.setValue(!0);break}case Ie.Close:{Je.setValue(!1);break}default:{console.error("Unsupported titleBar event:",P);break}}}}),Qe.reaction(P=>{this.titleBar.setReadonly(P)}),ke.reaction(P=>{this.titleBar.setBoxStatus(P)});const zg=Y(k),Bg=Y(z),Dg=Y(B);vd(this,{prefersColorScheme:ei,darkMode:kt,containerRect:mn,collectorRect:T,title:ne,visible:Je,readonly:Qe,resizable:ti,draggable:Pt,fence:kg,fixRatio:Pg,focus:Du,zIndex:Bu,minimized:Pi,maximized:ii,$userContent:zg,$userFooter:Bg,$userStyles:Dg,forceTop:R,forceNormal:H,isDragContent:ie}),this._state$=Lu,this._minSize$=Dr,this._size$=wn,this._intrinsicSize$=vn,this._visualSize$=Ru,this._coord$=Lr,this._intrinsicCoord$=So,this._boxStatus$=ke,this._lastNotMinimizedBoxStatus$=ki,this.fixRatio&&this.transform(Lr.value.x,Lr.value.y,wn.value.width,wn.value.height,!0),this.$box=this.render()}get boxStatus(){return this._boxStatus$.value}set boxStatus(t){this._boxStatus$.setValue(t)}get lastNotMinimizedBoxStatus(){return this._lastNotMinimizedBoxStatus$.value}get darkMode(){return this._darkMode$.value}get state(){return this._state$.value}setState(t,i=!1){switch(t){case N.Maximized:{this.setMinimized(!1,i),this.setMaximized(!0,i);break}case N.Minimized:{this.setMinimized(!0,i),this.setMaximized(!1,i);break}default:{this.setMinimized(!1,i),this.setMaximized(!1,i);break}}return this}setBoxStatus(t,i=!1){return t===N.Minimized?this._boxStatus$.value&&this._boxStatus$.value!==N.Minimized&&this.setLastNotMinimizedBoxStatus(this._boxStatus$.value,i):this.setLastNotMinimizedBoxStatus(void 0,i),this._boxStatus$.setValue(t,i),i||this.events.emit(oe.BoxStatus,{id:this.id,boxStatus:t}),this}setLastNotMinimizedBoxStatus(t,i=!1){return this._lastNotMinimizedBoxStatus$.setValue(t,i),i||this.events.emit(oe.LastNotMinimizedBoxStatus,{id:this.id,lastNotMinimizedBoxStatus:t}),this}get minWidth(){return this._minSize$.value.width}get minHeight(){return this._minSize$.value.height}setMinWidth(t,i=!1){return this._minSize$.setValue({width:t,height:this.minHeight},i),this}setMinHeight(t,i=!1){return this._minSize$.setValue({width:this.minWidth,height:t},i),this}get intrinsicWidth(){return this._intrinsicSize$.value.width}get intrinsicHeight(){return this._intrinsicSize$.value.height}resize(t,i,n=!1){return this._intrinsicSize$.setValue({width:t,height:i},n),this}get width(){return this._size$.value.width}get height(){return this._size$.value.height}get absoluteWidth(){return this.width*this.containerRect.width}get absoluteHeight(){return this.height*this.containerRect.height}get visualWidth(){return this._visualSize$.value.width}get visualHeight(){return this._visualSize$.value.height}get intrinsicX(){return this._intrinsicCoord$.value.x}get intrinsicY(){return this._intrinsicCoord$.value.y}move(t,i,n=!1){return this._intrinsicCoord$.setValue({x:t,y:i},n),this}get x(){return this._coord$.value.x}get y(){return this._coord$.value.y}transform(t,i,n,r,s=!1){if(this.fixRatio){const o=this.intrinsicHeight/this.intrinsicWidth*n;i!==this.intrinsicY&&(i-=o-r),r=o}return i<0&&(i=0,r>this.intrinsicHeight&&(r=this.intrinsicHeight)),this._intrinsicCoord$.setValue({x:n>=this.minWidth?t:this.intrinsicX,y:r>=this.minHeight?i:this.intrinsicY},s),this._intrinsicSize$.setValue({width:Pe(n,this.minWidth,1),height:Pe(r,this.minHeight,1)},s),this}mount(t){return t.appendChild(this.render()),this}unmount(){return this.$box&&this.$box.remove(),this}mountContent(t){return this.set$userContent(t),this}unmountContent(){return this.set$userContent(void 0),this}mountFooter(t){return this.set$userFooter(t),this}unmountFooter(){return this.set$userFooter(void 0),this}getUserStyles(){return this.$userStyles}mountStyles(t){let i;return typeof t=="string"?(i=document.createElement("style"),i.textContent=t):i=t,this.set$userStyles(i),this}unmountStyles(){return this.set$userStyles(void 0),this}render(t){if(t){if(t===this.$box)return this.$box;this.$box=t}else{if(this.$box)return this.$box;this.$box=document.createElement("div")}this._renderSideEffect.flushAll(),this.$box.classList.add(this.wrapClassName("box"));const i=(h,m,v,w=xv)=>this._renderSideEffect.add(()=>{const x=this.wrapClassName(v);return m.subscribe(d=>{h.classList.toggle(x,w(d))})});i(this.$box,this._readonly$,"readonly"),i(this.$box,this._draggable$,"no-drag",_r),i(this.$box,this._resizable$,"no-resize",_r),i(this.$box,this._focus$,"blur",_r),i(this.$box,this._darkMode$,"color-scheme-dark"),i(this.$box,this._darkMode$,"color-scheme-light",_r),this._renderSideEffect.add(()=>{const h=this.wrapClassName("minimized"),m=this.wrapClassName("maximized"),v="box-maximized-timer";return this._state$.subscribe(w=>{this.$box.classList.toggle(h,w===N.Minimized),w===N.Maximized?(this._renderSideEffect.flush(v),this.$box.classList.toggle(m,!0)):this._renderSideEffect.setTimeout(()=>{this.$box.classList.toggle(m,!1)},0,v)})}),this._renderSideEffect.add(()=>this._visible$.subscribe(h=>{h?this.$box.style.removeProperty("display"):this.$box.style.display="none"})),this._renderSideEffect.add(()=>this._zIndex$.subscribe(h=>{this.$box.style.zIndex=String(h)}));const n=dv(this.$box);this.$box.dataset.teleBoxID=this.id,this.$box.style.width=this.absoluteWidth+"px",this.$box.style.height=this.absoluteHeight+"px";const r=this.x*this.containerRect.width+this.containerRect.x,s=this.y*this.containerRect.height+this.containerRect.y;this.$box.style.transform=`translate(${r-10}px,${s-10}px)`,this._valSideEffectBinder.combine([this._coord$,this._size$,this._minimized$,this._containerRect$,this._collectorRect$,this._boxStatus$],([h,m,v,w,x,d])=>{const f=m.width*w.width,g=m.height*w.height;return{width:f+((v||d===N.Minimized)&&x?1:0),height:g+((v||d===N.Minimized)&&x?1:0),x:h.x*w.width,y:h.y*w.height,scaleX:(v||d===N.Minimized)&&x?x.width/f:1,scaleY:(v||d===N.Minimized)&&x?x.height/g:1}},ot).subscribe(h=>{n.set(h)}),n.set({x:r,y:s});const o=document.createElement("div");o.className=this.wrapClassName("box-main"),this.$box.appendChild(o);const a=document.createElement("div");a.className=this.wrapClassName("titlebar-wrap"),a.appendChild(this.titleBar.render()),this.$titleBar=a;const l=document.createElement("div");l.className=this.wrapClassName("content-wrap");const u=document.createElement("div");u.className=this.wrapClassName("content")+" tele-fancy-scrollbar",this.$content=u,this.isDragContent&&this.$content.appendChild(this.titleBar.$dragArea),this._renderSideEffect.add(()=>{let h;return this._$userStyles$.subscribe(m=>{h&&h.remove(),h=m,m&&l.appendChild(m)})}),this._renderSideEffect.add(()=>{let h;return this._$userContent$.subscribe(m=>{h&&h.remove(),h=m,m&&u.appendChild(m)})}),l.appendChild(u);const c=document.createElement("div");return c.className=this.wrapClassName("footer-wrap"),this.$footer=c,this._renderSideEffect.add(()=>{let h;return this._$userFooter$.subscribe(m=>{h&&h.remove(),h=m,m&&c.appendChild(m)})}),o.appendChild(a),o.appendChild(l),o.appendChild(c),this._renderResizeHandlers(),this.$box}_renderResizeHandlers(){const t=document.createElement("div");t.className=this.wrapClassName("resize-handles"),Object.values(at).forEach(x=>{const d=document.createElement("div");d.className=this.wrapClassName(x)+" "+this.wrapClassName("resize-handle"),d.dataset.teleBoxHandle=x,t.appendChild(d)}),this.$box.appendChild(t);const i="handle-tracking-listener",n=this.wrapClassName("transforming");let r,s=0,o=0,a=0,l=0,u=0,c=0,h;const m=x=>{if(this.state!==N.Normal)return;Fi(x);let{pageX:d,pageY:f}=qu(x);f<0&&(f=0);const g=(d-u)/this.containerRect.width,p=(f-c)/this.containerRect.height;switch(h){case at.North:{this.transform(this.x,o+p,this.width,l-p);break}case at.South:{this.transform(this.x,this.y,this.width,l+p);break}case at.West:{this.transform(s+g,this.y,a-g,this.height);break}case at.East:{this.transform(this.x,this.y,a+g,this.height);break}case at.NorthWest:{this.transform(s+g,o+p,a-g,l-p);break}case at.NorthEast:{this.transform(this.x,o+p,a+g,l-p);break}case at.SouthEast:{this.transform(this.x,this.y,a+g,l+p);break}case at.SouthWest:{this.transform(s+g,this.y,a-g,l+p);break}default:{if(this.fence)this.move(Pe(s+g,0,1-this.width),Pe(o+p,0,1-this.height));else{const y=20/this.containerRect.width,S=20/this.containerRect.height;this.move(Pe(s+g,y-this.width,1-y),Pe(o+p,0,1-S))}break}}},v=x=>{h=void 0,r&&(Fi(x),this.$box.classList.toggle(n,!1),this._sideEffect.flush(i),r.remove())},w=x=>{var d;if(this.readonly||x.button!=null&&x.button!==0||!this.draggable||h||this.state!==N.Normal)return;const f=x.target;if((d=f.dataset)!=null&&d.teleBoxHandle){Fi(x),s=this.x,o=this.y,a=this.width,l=this.height,{pageX:u,pageY:c}=qu(x),h=f.dataset.teleBoxHandle,r||(r=document.createElement("div"));const g=h?this.wrapClassName(`cursor-${h}`):"";r.className=this.wrapClassName(`track-mask${g?` ${g}`:""}`),this.$box.appendChild(r),this.$box.classList.add(n),this._sideEffect.add(()=>(window.addEventListener("mousemove",m),window.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("mouseup",v),window.addEventListener("touchend",v,{passive:!1}),window.addEventListener("touchcancel",v,{passive:!1}),()=>{window.removeEventListener("mousemove",m),window.removeEventListener("touchmove",m),window.removeEventListener("mouseup",v),window.removeEventListener("touchend",v),window.removeEventListener("touchcancel",v)}),i)}};this._handleTrackStart=w,this._sideEffect.addEventListener(t,"mousedown",w,{},"box-resizeHandles-mousedown"),this._sideEffect.addEventListener(t,"touchstart",w,{passive:!1},"box-resizeHandles-touchstart")}destroy(){this.$box.remove(),this.events.emit(oe.Destroyed),this._sideEffect.flushAll(),this._renderSideEffect.flushAll(),this.events.removeAllListeners(),this._delegateEvents.removeAllListeners()}wrapClassName(t){return`${this.namespace}-${t}`}}function ec(){}var Mv="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K";class cn{constructor({visible:t=!0,readonly:i=!1,darkMode:n=!1,namespace:r="telebox",styles:s={},onClick:o,getBoxesStatus:a}){this.$appMenuContainer=document.createElement("div"),this.handleCollectorClick=()=>{!this._readonly&&this.onClick&&this.onClick()},this._visible=t,this._readonly=i,this._darkMode=n,this.namespace=r,this.styles=s,this.onClick=o,this.getBoxesStatus=a}get boxesStatus(){var t;return(t=this.getBoxesStatus)==null?void 0:t.call(this)}get visible(){return this._visible}get readonly(){return this._readonly}get darkMode(){return this._darkMode}mount(t){return t.appendChild(this.render()),this}unmount(){return this.$collector&&this.$collector.remove(),this}hasMinimizedBox(){const t=this.boxesStatus;if(t){for(const i of t.values())if(i===N.Minimized)return!0}return!1}updateBoxesStatus(){const t=this.hasMinimizedBox();this.setVisible(t)}setVisible(t){return this._visible!==t&&(this._visible=t,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-visible"),t)),this}setReadonly(t){return this._readonly!==t&&(this._readonly=t,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-readonly"),t)),this}setDarkMode(t){return this._darkMode!==t&&(this._darkMode=t,this.$collector&&(this.$collector.classList.toggle(this.wrapClassName("color-scheme-dark"),t),this.$collector.classList.toggle(this.wrapClassName("color-scheme-light"),!t))),this}setStyles(t){if(Object.assign(this.styles,t),this.$collector){const i=this.$collector;Object.keys(t).forEach(n=>{const r=t[n];r!=null&&(i.style[n]=r)})}return this}render(){return this.$collector||(this.$collector=document.createElement("button"),this.$collector.className=this.wrapClassName("collector"),this.$collector.style.backgroundImage=`url('${Mv}')`,this.$collector.addEventListener("click",this.handleCollectorClick),this._visible&&this.$collector.classList.add(this.wrapClassName("collector-visible")),this._readonly&&this.$collector.classList.add(this.wrapClassName("collector-readonly")),this.$collector.classList.add(this.wrapClassName(this._darkMode?"color-scheme-dark":"color-scheme-light")),this.$appMenuContainer.classList.add(this.wrapClassName("collector-shadow")),this.$collector.append(this.$appMenuContainer),this.setStyles(this.styles)),this.$collector}destroy(){this.$collector&&(this.$collector.removeEventListener("click",this.handleCollectorClick),this.$collector.remove(),this.$collector=void 0),this.onClick=void 0}wrapClassName(t){return`${this.namespace}-${t}`}}cn.kind="TeleBoxCollector";var ce=(e=>(e.Focused="focused",e.Blurred="blurred",e.Created="created",e.Removed="removed",e.State="state",e.Maximized="maximized",e.Minimized="minimized",e.Move="move",e.Resize="resize",e.IntrinsicMove="intrinsic_move",e.IntrinsicResize="intrinsic_resize",e.VisualResize="visual_resize",e.ZIndex="z_index",e.PrefersColorScheme="prefers_color_scheme",e.DarkMode="dark_mode",e.BoxStatus="box_status",e.LastNotMinimizedBoxStatus="last_not_minimized_box_status",e))(ce||{});class Cv extends yd{constructor(t){super(t),this.boxes=t.boxes,this.focusedBox=t.focusedBox,this.containerRect=t.containerRect,this.darkMode=t.darkMode,this.getBoxesStatus=t.getBoxesStatus}get boxesStatus(){var t;return(t=this.getBoxesStatus)==null?void 0:t.call(this)}hasMaximizedBoxInStatus(){if(this.getBoxesStatus){const t=this.getBoxesStatus();if(t.size)return!![...t.values()].find(n=>n===N.Maximized)}return!1}get MaximizedBoxes(){if(this.getBoxesStatus){const t=this.getBoxesStatus();if(t)return this.boxes.filter(i=>t&&t.get(i.id)===N.Maximized&&!i.forceTop)}return[]}focusBox(t){var i,n;if(!(this.focusedBox&&this.focusedBox===t)){if(this.$titles){const{children:r}=this.$titles.firstElementChild;if(this.state===N.Maximized&&!this.hasMaximizedBoxInStatus())for(let s=r.length-1;s>=0;s-=1){const o=r[s],a=(i=o.dataset)==null?void 0:i.teleBoxID;a&&(t&&a===t.id?o.classList.toggle(this.wrapClassName("titles-tab-focus"),!0):this.focusedBox&&a===this.focusedBox.id&&o.classList.toggle(this.wrapClassName("titles-tab-focus"),!1))}else if(this.hasMaximizedBoxInStatus())for(let s=r.length-1;s>=0;s-=1){const o=r[s],a=(n=o.dataset)==null?void 0:n.teleBoxID;a&&(t&&a===t.id?o.classList.toggle(this.wrapClassName("titles-tab-focus"),!0):this.focusedBox&&a===this.focusedBox.id&&o.classList.toggle(this.wrapClassName("titles-tab-focus"),!1))}}this.focusedBox=t}}setContainerRect(t){if(this.containerRect=t,this.$titleBar){const{x:i,y:n,width:r}=t;this.$titleBar.style.transform=`translate(${i}px, ${n}px)`,this.$titleBar.style.width=r+"px"}}updateBoxesStatus(){this.hasMaximizedBoxInStatus()&&this.setBoxStatus(N.Maximized),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===N.Maximized&&this.boxes.length>0||this.hasMaximizedBoxInStatus()),this.updateTitles()}setBoxes(t){this.boxes=t,this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===N.Maximized&&t.length>0||this.hasMaximizedBoxInStatus()),this.updateTitles()}setState(t){super.setState(t),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),t===N.Maximized&&this.boxes.length>0||this.hasMaximizedBoxInStatus()),this.updateTitles()}setReadonly(t){super.setReadonly(t),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("readonly"),this.readonly)}setDarkMode(t){t!==this.darkMode&&(this.darkMode=t,this.$titleBar&&(this.$titleBar.classList.toggle(this.wrapClassName("color-scheme-dark"),t),this.$titleBar.classList.toggle(this.wrapClassName("color-scheme-light"),!t)))}render(){const t=super.render(),{x:i,y:n,width:r}=this.containerRect;t.style.transform=`translate(${i}px, ${n}px)`,t.style.width=r+"px",t.classList.add(this.wrapClassName("max-titlebar")),t.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===N.Maximized&&this.boxes.length>0),t.classList.toggle(this.wrapClassName("readonly"),this.readonly),t.classList.add(this.wrapClassName(this.darkMode?"color-scheme-dark":"color-scheme-light"));const s=document.createElement("div");return s.classList.add(this.wrapClassName("titles-area")),t.insertBefore(s,t.firstElementChild),this.updateTitles(),t}destroy(){super.destroy(),this.$titles=void 0,this.boxes.length=0,this.focusedBox=void 0}updateTitles(){this.$titleBar&&(this.state===N.Maximized||this.hasMaximizedBoxInStatus())&&(this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"),this.boxes.length===1||this.hasMaximizedBoxInStatus()&&this.MaximizedBoxes.length===1),this.boxes.length===1||this.hasMaximizedBoxInStatus()&&this.MaximizedBoxes.length===1?this.setTitle(this.boxes[0].title):this.$titleBar.replaceChild(this.renderTitles(),this.$titleBar.firstElementChild))}renderTitles(){this.$titles=document.createElement("div"),this.$titles.className=this.wrapClassName("titles"),this.$titles.addEventListener("wheel",i=>{i.currentTarget.scrollBy({left:i.deltaY>0?250:-250,behavior:"smooth"})},{passive:!1});const t=document.createElement("div");return t.className=this.wrapClassName("titles-content"),this.$titles.appendChild(t),(this.hasMaximizedBoxInStatus()?this.MaximizedBoxes:this.boxes).forEach(i=>{const n=document.createElement("button");n.className=this.wrapClassName("titles-tab"),n.textContent=i.title,n.dataset.teleBoxID=i.id,n.dataset.teleTitleBarNoDblClick="true",this.focusedBox&&i.id===this.focusedBox.id&&n.classList.add(this.wrapClassName("titles-tab-focus")),t.appendChild(n)}),this.$titles}}class bv{constructor(t){this.namespace="telebox-app-menu",this.badge=document.createElement("div"),this.menuView=document.createElement("div"),this.containerClickHandler=()=>{if(this.manager.readonly)return;getComputedStyle(this.menuView).display==="flex"?this.menuView.style.display="none":this.menuView.style.display="flex"},this.menuViewClickHandler=i=>{i.stopPropagation(),i.stopImmediatePropagation();const r=i.target.getAttribute(`data-${this.c("app-id")}`);if(r){const s=this.manager.getLastNotMinimizedBoxStatus(r)||N.Normal,o=(s===N.Maximized?this.manager.getMaxMaximizedBoxZIndex():this.manager.getMaxNormalBoxZIndex())+1;this.manager.setBox(r,{status:s,zIndex:o},!1,()=>{this.manager.focusBox(r)});return}},this.updatePrefersColorSchemeHandler=()=>{this.container.classList.remove(this.theme),this.theme=this.manager.prefersColorScheme,this.container.classList.add(this.theme)},this.appMenuChange=()=>{const i=this.manager.getMinimizedBoxesStatus();this.render(i)},this.container=t.container,this.manager=t.manager,this.theme=t.theme,this.getBoxesStatus=t.getBoxesStatus,this.init()}get boxesStatus(){var t;return((t=this.getBoxesStatus)==null?void 0:t.call(this))||new Map}get minimizedBoxesStatus(){const t=[];return this.boxesStatus.forEach(i=>{i===N.Minimized&&t.push(i)}),t}c(t){return`${this.namespace}-${t}`}setContainer(t){this.container&&this.container.remove(),this.container=t,this.init()}createDefaultAppMenu(){this.badge.classList.add(this.c("app-menu-badge")),this.menuView.classList.add(this.c("app-menu-tooltip")),this.container.classList.add(this.c("app-menu-container"),this.theme),this.menuView.addEventListener("click",this.menuViewClickHandler),this.container.append(this.badge,this.menuView)}async init(){this.createDefaultAppMenu(),this.appMenuChange()}createMinimizedItem(t){const i=document.createElement("div");i.classList.add(this.c("app-menu-item")),i.setAttribute(`data-${this.c("app-id")}`,t);const n=document.createElement("div");n.classList.add(this.c("app-menu-item-title"));const r=this.manager.getBox(t);return n.innerText=(r==null?void 0:r.title)||t,i.appendChild(n),i}renderMenuView(t){const i=[];t.forEach((n,r)=>{i.push(this.createMinimizedItem(r))}),this.menuView.append(...i)}render(t){this.menuView.style.display="none",this.badge.innerText="",this.menuView.innerHTML="",t.size===0?this.container.style.display="none":(this.badge.innerText=t.size.toString(),this.renderMenuView(t),this.container.style.display="block")}destroy(){this.badge.remove(),this.menuView.removeEventListener("click",this.menuViewClickHandler),this.menuView.remove(),this.container.remove()}}class gr{constructor({root:t=document.body,prefersColorScheme:i=xl.Light,minimized:n=!1,maximized:r=!1,fence:s=!0,containerRect:o={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collector:a,namespace:l="telebox",readonly:u=!1,useBoxesStatus:c=!1}={}){this.events=new na,this._sideEffect=new Ss,this.useBoxesStatus=c;const{combine:h,createVal:m}=wd(this._sideEffect);this.root=t,this.namespace=l,this.boxes$=m([]),this.topBox$=this.boxes$.derive(b=>{if(b.length>0){let M;return b.reduce((D,Z)=>Z.forceTop||Z.boxStatus&&Z.boxStatus===N.Minimized?D:D?D.zIndex>Z.zIndex?D:Z:(D=Z,D),M)}}),this.boxesStatus$=new Map,this.lastNotMinimizedBoxesStatus$=new Map;const v=window.matchMedia("(prefers-color-scheme: dark)"),w=m(!1);v&&(w.setValue(v.matches),this._sideEffect.add(()=>{const b=M=>{w.setValue(M.matches)};return v.addListener(b),()=>v.removeListener(b)}));const x=m(i);x.reaction((b,M,V)=>{this.boxes.forEach(D=>D.setPrefersColorScheme(b,V)),V||this.events.emit(ce.PrefersColorScheme,b)}),this._darkMode$=h([w,x],([b,M])=>M==="auto"?b:M==="dark"),this._darkMode$.reaction((b,M,V)=>{this.boxes.forEach(D=>D.setDarkMode(b,V)),V||this.events.emit(ce.DarkMode,b)});const d=m(u);d.reaction((b,M,V)=>{this.boxes.forEach(D=>D.setReadonly(b,V))});const f=m(n),g=m(r);g.reaction((b,M,V)=>{this.boxes.forEach(D=>D.setMaximized(b,V)),V||this.events.emit(ce.Maximized,b)});const p=h([f,g],([b,M])=>b?N.Minimized:M?N.Maximized:N.Normal);p.reaction((b,M,V)=>{this.maxTitleBar.setState(b),V||this.events.emit(ce.State,b)});const y=m(s);y.subscribe((b,M,V)=>{this.boxes.forEach(D=>D.setFence(b,V))});const S=m(o,ot);S.reaction((b,M,V)=>{this.boxes.forEach(D=>D.setContainerRect(b,V)),this.maxTitleBar.setContainerRect(b)});const A=m(a===null?null:a||new cn({visible:n,readonly:u,namespace:l}).mount(t));A.subscribe(b=>{b&&(b.setVisible(f.value),b.setReadonly(d.value),b.setDarkMode(this._darkMode$.value),this.useBoxesStatus&&this.appMenu&&this.appMenu.setContainer(b.$appMenuContainer),this._sideEffect.add(()=>(b.getBoxesStatus=()=>this.boxesStatus$,b.onClick=()=>{d.value||(this.useBoxesStatus?this.useBoxesStatus&&this.appMenu&&this.appMenu.containerClickHandler():f.setValue(!1))},()=>b.destroy()),"collect-onClick"))}),d.subscribe(b=>{var M;return(M=A.value)==null?void 0:M.setReadonly(b)}),this._darkMode$.subscribe(b=>{var M;(M=A.value)==null||M.setDarkMode(b)}),this._calcCollectorRect=()=>{var b;if((b=A.value)!=null&&b.$collector){const{x:M,y:V,width:D,height:Z}=A.value.$collector.getBoundingClientRect(),te=this.root.getBoundingClientRect();return{x:M-te.x,y:V-te.y,width:D,height:Z}}},this._setCollectorRect=b=>{var M;(M=A.value)!=null&&M.$collector&&k.setValue(b)};const k=m(f.value?this._calcCollectorRect():void 0);k.subscribe((b,M,V)=>{this.boxes.forEach(D=>{D.setCollectorRect(b,V)})}),f.subscribe((b,M,V)=>{var D;(D=A.value)==null||D.setVisible(b),b&&this._setCollectorRect(this._calcCollectorRect()),this.boxes.forEach(Z=>Z.setMinimized(b,V)),V||this.events.emit(ce.Minimized,b)});const z=this.wrapClassName("titlebar-icon-close"),B=b=>{var M;if(d.value)return;const V=b.target;if(!!V.tagName)for(let D=V;D;D=D.parentElement){if(D.classList&&D.classList.contains(z))return;const Z=(M=D.dataset)==null?void 0:M.teleBoxID;if(Z){const te=this.getBox(Z);if(te){if(!this.useBoxesStatus)this.makeBoxTop(te);else if(te.boxStatus&&te.boxStatus===N.Normal){const he=this.getMaxNormalBoxZIndex();he>te.zIndex&&this.setBox(te,{zIndex:he+1},!1)}else if(te.boxStatus&&te.boxStatus===N.Maximized){const he=this.getMaxMaximizedBoxZIndex();he>te.zIndex&&this.setBox(te,{zIndex:he+1},!1),this.makeMaximizedTopBoxFocus()}this.focusBox(te);return}}}};this._sideEffect.addEventListener(window,"mousedown",B,!0),this._sideEffect.addEventListener(window,"touchstart",B,!0),this.maxTitleBar=new Cv({darkMode:this.darkMode,readonly:d.value,namespace:this.namespace,state:p.value,boxes:this.boxes$.value,containerRect:S.value,getBoxesStatus:()=>this.boxesStatus$,onEvent:b=>{switch(b.type){case Ie.Maximize:{if(this.hasBoxesStatus()){let M=this.maxTitleBar.focusedBox;if(M||(M=this.getMaximizedTopBox()),M!=null&&M.id){const V=this.getBox(M.id);V&&this.setBox(V,{status:N.Normal,zIndex:this.getMaxNormalBoxZIndex()+1},!1,()=>{this.makeMaximizedTopBoxFocus()})}}else g.setValue(!g.value);break}case Ie.Minimize:{if(this.hasBoxesStatus()){let M=this.maxTitleBar.focusedBox;if(M||(M=this.getMaximizedTopBox()),M!=null&&M.id){const V=this.getBox(M.id);if(V){let D=!1;V.focus&&(this.blurBox(V),D=!0),this.setBox(V,{status:N.Minimized,zIndex:-1},!1),D?this.focusTopBox():this.makeMaximizedTopBoxFocus()}}}else f.setValue(!0);break}case oe.Close:{if(this.hasBoxesStatus()){let M=this.maxTitleBar.focusedBox;if(M||(M=this.getMaximizedTopBox()),M!=null&&M.id){const V=this.getBox(M.id);if(V){let D=!1;V.focus&&(this.blurBox(V),D=!0),this.remove(V,!1),D?this.focusTopBox():this.makeMaximizedTopBoxFocus()}}}else this.removeTopBox(),this.focusTopBox();break}}}}),d.subscribe(b=>this.maxTitleBar.setReadonly(b)),this._darkMode$.subscribe(b=>{this.maxTitleBar.setDarkMode(b)}),this.boxes$.reaction(b=>{this.maxTitleBar.setBoxes(b)}),vd(this,{prefersColorScheme:x,containerRect:S,collector:A,collectorRect:k,readonly:d,fence:y,minimized:f,maximized:g}),this._state$=p,this.root.appendChild(this.maxTitleBar.render()),c&&(this.appMenu=this.createMinimizedAppMenu())}get boxes(){return this.boxes$.value}get topBox(){return this.topBox$.value}get forceTopBoxes(){return this.boxes.find(t=>t.forceTop)}get maxForceTopBox(){return this.boxes.reduce((t,i)=>{var n;return i.forceTop&&i.zIndex>((n=t==null?void 0:t.zIndex)!=null?n:0)?i:t},void 0)}get forceNormalBoxes(){return this.boxes.find(t=>t.forceNormal)}get darkMode(){return this._darkMode$.value}get state(){return this._state$.value}setState(t,i=!1){switch(t){case N.Maximized:{this.setMinimized(!1,i),this.setMaximized(!0,i);break}case N.Minimized:{this.setMinimized(!0,i),this.setMaximized(!1,i);break}default:{this.setMinimized(!1,i),this.setMaximized(!1,i);break}}return this}setBoxStatus(t,i,n=!1){if(i){const r=this.boxesStatus$.get(t);this.boxesStatus$.set(t,i),i===N.Minimized&&r!==N.Minimized?this.setLastNotMinimizedBoxStatus(t,r,n):r===N.Minimized&&i!==N.Minimized&&this.setLastNotMinimizedBoxStatus(t,void 0,n)}else this.boxesStatus$.delete(t),this.setLastNotMinimizedBoxStatus(t,void 0,n);n||this.events.emit(ce.BoxStatus,{id:t,boxStatus:i})}getBoxStatus(t){return this.boxesStatus$.get(t)}get boxesStatus(){return this.boxesStatus$}get lastNotMinimizedBoxesStatus(){return this.lastNotMinimizedBoxesStatus$}setBoxesStatus(t,i=!1){this.boxesStatus$=t,this.effectBoxesStatusChange(i)}getBoxesStatus(){return this.boxesStatus$}effectBoxStatusChange(){!this.useBoxesStatus||(this.collector&&(this.collector.updateBoxesStatus(),this.hasMinimizedBox()&&this._setCollectorRect(this._calcCollectorRect())),this.appMenu&&this.appMenu.appMenuChange(),this.maxTitleBar&&this.maxTitleBar.updateBoxesStatus())}effectBoxesStatusTimerFunc(t){if(!this.useBoxesStatus)return;let i;const n=this.topBox;this.boxes.forEach(r=>{var s;const o=this.boxesStatus$.get(r.id);o&&(o!==N.Minimized&&!this.isForceTop(r)&&r.zIndex>((s=i==null?void 0:i.zIndex)!=null?s:0)&&(i=r),r.setBoxStatus(o,t))}),this.effectBoxStatusChange(),i&&n!==i&&this.topBox$.setValue(i),!i&&n&&this.topBox$.setValue(void 0)}async effectBoxesStatusChange(t=!1){var i,n;if(!this.useBoxesStatus){this.effectBoxesStatusTimer&&this.effectBoxesStatusTimer.timer&&(clearTimeout(this.effectBoxesStatusTimer.timer),this.effectBoxesStatusTimer.resolve&&this.effectBoxesStatusTimer.resolve(!!((i=this.effectBoxesStatusTimer)!=null&&i.skipUpdate))),this.effectBoxesStatusTimer=void 0;return}if(this.effectBoxesStatusTimer&&this.effectBoxesStatusTimer.timer)if(this.effectBoxesStatusTimer.skipUpdate!==t)clearTimeout(this.effectBoxesStatusTimer.timer),this.effectBoxesStatusTimer.resolve&&this.effectBoxesStatusTimer.resolve(!!((n=this.effectBoxesStatusTimer)!=null&&n.skipUpdate)),this.effectBoxesStatusTimer.skipUpdate=t;else return;if(this.effectBoxesStatusTimer||(this.effectBoxesStatusTimer={skipUpdate:t,timer:void 0,resolve:void 0}),this.effectBoxesStatusTimer){const r=await new Promise(s=>{this.effectBoxesStatusTimer.resolve=s,this.effectBoxesStatusTimer.timer=setTimeout(()=>{this.effectBoxesStatusTimer&&this.effectBoxesStatusTimer.resolve&&this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate)},100)});this.effectBoxesStatusTimerFunc(r),this.effectBoxesStatusTimer=void 0}}hasBoxesStatus(){return this.useBoxesStatus?this.boxesStatus$.size>0:!1}hasMinimizedBox(){return this.useBoxesStatus?this.boxes.some(t=>t.boxStatus&&t.boxStatus===N.Minimized):!1}getMinimizedBoxesStatus(){const t=new Map;return this.boxesStatus$.forEach((i,n)=>{i===N.Minimized&&t.set(n,i)}),t}getNotMinimizedBoxesStatus(){const t=new Map;return this.boxesStatus$.forEach((i,n)=>{i!==N.Minimized&&t.set(n,i)}),t}getAllMaximizedBoxesStatus(){const t=new Map;return this.boxesStatus$.forEach((i,n)=>{i===N.Maximized&&t.set(n,i)}),t}getAllNormalBoxesStatus(){const t=new Map;return this.boxesStatus$.forEach((i,n)=>{i===N.Normal&&t.set(n,i)}),t}getLastNotMinimizedBoxStatus(t){return this.lastNotMinimizedBoxesStatus$.get(t)}setLastNotMinimizedBoxStatus(t,i,n=!1){i?this.lastNotMinimizedBoxesStatus$.set(t,i):this.lastNotMinimizedBoxesStatus$.delete(t),n||this.events.emit(ce.LastNotMinimizedBoxStatus,{id:t,boxStatus:i})}setLastNotMinimizedBoxesStatus(t,i=!1){this.lastNotMinimizedBoxesStatus$=t,this.effectLastNotMinimizedBoxStatusChange(i)}async effectLastNotMinimizedBoxStatusChange(t=!1){var i,n;if(!this.useBoxesStatus){this.effectLastNotMinimizedBoxStatusTimer&&this.effectLastNotMinimizedBoxStatusTimer.timer&&(clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer),this.effectLastNotMinimizedBoxStatusTimer.resolve&&this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((i=this.effectLastNotMinimizedBoxStatusTimer)!=null&&i.skipUpdate))),this.effectLastNotMinimizedBoxStatusTimer=void 0;return}if(this.effectLastNotMinimizedBoxStatusTimer&&this.effectLastNotMinimizedBoxStatusTimer.timer)if(clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer),this.effectLastNotMinimizedBoxStatusTimer.skipUpdate!==t)this.effectLastNotMinimizedBoxStatusTimer.resolve&&this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((n=this.effectLastNotMinimizedBoxStatusTimer)!=null&&n.skipUpdate)),this.effectLastNotMinimizedBoxStatusTimer.skipUpdate=t;else return;if(this.effectLastNotMinimizedBoxStatusTimer||(this.effectLastNotMinimizedBoxStatusTimer={skipUpdate:t,timer:void 0,resolve:void 0}),this.effectLastNotMinimizedBoxStatusTimer){const r=await new Promise(s=>{this.effectLastNotMinimizedBoxStatusTimer.resolve=s,this.effectLastNotMinimizedBoxStatusTimer.timer=setTimeout(()=>{this.effectLastNotMinimizedBoxStatusTimer&&this.effectLastNotMinimizedBoxStatusTimer.resolve&&this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate)},100)});this.effectLastNotMinimizedBoxStatusFunc(r),this.effectLastNotMinimizedBoxStatusTimer=void 0}}effectLastNotMinimizedBoxStatusFunc(t=!1){!this.useBoxesStatus||this.boxes.forEach(i=>{const n=this.lastNotMinimizedBoxesStatus$.get(i.id);n&&i.setLastNotMinimizedBoxStatus(n,t)})}getUnabledBoxesStatusZIndex(){return this.topBox?this.topBox.zIndex:99}getMaxMaximizedBoxZIndex(){return this.useBoxesStatus?this.boxes.reduce((t,i)=>i.boxStatus&&i.boxStatus===N.Maximized&&!this.isForceTop(i)?Math.max(t,i.zIndex):t,99):this.getUnabledBoxesStatusZIndex()}getMaxNormalBoxZIndex(){return this.useBoxesStatus?this.boxes.reduce((t,i)=>i.boxStatus&&i.boxStatus===N.Normal&&!this.isForceTop(i)?Math.max(t,i.zIndex):t,299):this.getUnabledBoxesStatusZIndex()}getMaxForceTopBoxZIndex(){return this.useBoxesStatus?this.boxes.reduce((t,i)=>i.boxStatus&&this.isForceTop(i)?Math.max(t,i.zIndex):t,699):this.getUnabledBoxesStatusZIndex()}isForceNormal(t){return t._forceNormal$.value}isForceTop(t){return t._forceTop$.value}create(t={},i=!0){const n=new Sv({zIndex:t.forceTop?this.getMaxForceTopBoxZIndex()+1:this.getMaxNormalBoxZIndex()+1,...i?this.smartPosition(t):t,darkMode:this.darkMode,prefersColorScheme:this.prefersColorScheme,maximized:this.maximized,minimized:this.minimized,fence:this.fence,namespace:this.namespace,containerRect:this.containerRect,readonly:this.readonly,collectorRect:this.collectorRect});return n.mount(this.root),this.boxes$.setValue([...this.boxes,n]),n.boxStatus&&this.useBoxesStatus&&this.setBox(n,{status:n.boxStatus,lastNotMinimizedBoxStatus:n._lastNotMinimizedBoxStatus$.value},!0),n.focus&&(this.focusBox(n),i&&this.makeBoxTop(n)),n._delegateEvents.on(Ie.Maximize,()=>{if(this.useBoxesStatus&&n.boxStatus){if(n._forceNormal$.value)return;n.boxStatus===N.Maximized?this.setBox(n.id,{status:N.Normal,zIndex:this.getMaxNormalBoxZIndex()+1},!1):([...this.boxes].filter(r=>r.boxStatus===N.Normal&&!this.isForceNormal(r)).sort((r,s)=>r.zIndex-s.zIndex).forEach(r=>{r.boxStatus===N.Normal&&this.setBox(r.id,{status:N.Maximized,zIndex:this.getMaxMaximizedBoxZIndex()+1},!1)}),this.makeMaximizedTopBoxFocus())}else this.setMaximized(!this.maximized)}),n._delegateEvents.on(Ie.Minimize,()=>{if(n.boxStatus&&this.useBoxesStatus){if(n._forceNormal$.value)return;n.focus&&this.blurBox(n),this.setBox(n,{status:N.Minimized,zIndex:-1},!1,()=>{this.focusTopBox()})}else this.setMinimized(!0)}),n._delegateEvents.on(Ie.Close,()=>{this.useBoxesStatus&&n.focus&&this.blurBox(n),this.remove(n),this.focusTopBox()}),n._coord$.reaction((r,s,o)=>{o||this.events.emit(ce.Move,n)}),n._size$.reaction((r,s,o)=>{o||this.events.emit(ce.Resize,n)}),n._intrinsicCoord$.reaction((r,s,o)=>{o||this.events.emit(ce.IntrinsicMove,n)}),n._intrinsicSize$.reaction((r,s,o)=>{o||this.events.emit(ce.IntrinsicResize,n)}),n._visualSize$.reaction((r,s,o)=>{o||this.events.emit(ce.VisualResize,n)}),n._zIndex$.reaction((r,s,o)=>{if(this.boxes.length>0){let a;const l=this.boxes.reduce((u,c)=>this.isForceTop(c)||c.boxStatus&&c.boxStatus===N.Minimized?u:u?u.zIndex>c.zIndex?u:c:(u=c,u),a);this.topBox$.setValue(l)}o||this.events.emit(ce.ZIndex,n)}),this.events.emit(ce.Created,n),n}query(t){return t?this.boxes.filter(this.teleBoxMatcher(t)):[...this.boxes]}queryOne(t){return t?this.boxes.find(this.teleBoxMatcher(t)):this.boxes[0]}update(t,i,n=!1){const r=this.boxes.find(s=>s.id===t);if(r)return this.updateBox(r,i,n)}updateAll(t,i=!1){this.boxes.forEach(n=>{this.updateBox(n,t,i)})}setBox(t,i,n=!1,r){const s=this.getBox(t);if(s){const{status:o,zIndex:a,lastNotMinimizedBoxStatus:l}=i;o&&(this.setBoxStatus(s.id,o,n),s.setBoxStatus(o,n),this.effectBoxStatusChange()),a&&s.setZIndex(a,n),l&&(this.setLastNotMinimizedBoxStatus(s.id,l,n),s.setLastNotMinimizedBoxStatus(l,n)),r&&r()}}remove(t,i=!1,n){const r=this.getBox(t),s=this.getBoxIndex(t);if(s>=0){const o=this.boxes.slice(),a=o.splice(s,1);return this.boxes$.setValue(o),a.forEach(l=>l.destroy()),r&&this.useBoxesStatus&&(this.setBoxStatus(r.id,void 0,i),this.setLastNotMinimizedBoxStatus(r.id,void 0,i),this.effectBoxStatusChange(),n&&n()),i||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(ce.Removed,a)),a[0]}}removeTopBox(){if(this.topBox)return this.remove(this.topBox)}removeAll(t=!1){const i=this.boxes$.value;return this.boxes$.setValue([]),i.forEach(n=>n.destroy()),this.boxesStatus$.clear(),this.lastNotMinimizedBoxesStatus$.clear(),t||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(ce.Removed,i)),i}destroy(t=!1){this.events.removeAllListeners(),this._sideEffect.flushAll(),this.removeAll(t),Object.keys(this).forEach(i=>{const n=this[i];n instanceof pr&&n.destroy()})}wrapClassName(t){return`${this.namespace}-${t}`}focusBox(t,i=!1){const n=this.getBox(t);n&&(this.boxes.forEach(r=>{if(n===r){let s=!1;n.focus||(s=!0,n.setFocus(!0,i)),s&&!i&&this.events.emit(ce.Focused,n)}else r.focus&&this.blurBox(r,i)}),this.useBoxesStatus?this.useBoxesStatus&&this.maxTitleBar.hasMaximizedBoxInStatus()&&this.makeMaximizedTopBoxFocus():this.maxTitleBar.focusBox(n))}focusTopBox(){if(this.topBox&&!this.topBox.focus)return this.focusBox(this.topBox)}blurBox(t,i=!1){const n=this.getBox(t);n&&(n.focus&&(n.setFocus(!1,i),i||this.events.emit(ce.Blurred,n)),this.maxTitleBar.focusedBox===n&&this.maxTitleBar.focusBox())}blurAll(t=!1){this.boxes.forEach(i=>{i.focus&&(i.setFocus(!1,t),t||this.events.emit(ce.Blurred,i))}),this.maxTitleBar.focusedBox&&this.maxTitleBar.focusBox()}teleBoxMatcher(t){const i=Object.keys(t);return n=>i.every(r=>t[r]===n[r])}updateBox(t,i,n=!1){(i.x!=null||i.y!=null)&&t.move(i.x==null?t.intrinsicX:i.x,i.y==null?t.intrinsicY:i.y,n),(i.width!=null||i.height!=null)&&t.resize(i.width==null?t.intrinsicWidth:i.width,i.height==null?t.intrinsicHeight:i.height,n),i.title!=null&&(t.setTitle(i.title),this.maxTitleBar.updateTitles()),i.visible!=null&&t.setVisible(i.visible,n),i.minHeight!=null&&t.setMinHeight(i.minHeight,n),i.minWidth!=null&&t.setMinWidth(i.minWidth,n),i.resizable!=null&&t.setResizable(i.resizable,n),i.draggable!=null&&t.setDraggable(i.draggable,n),i.fixRatio!=null&&t.setFixRatio(i.fixRatio,n),i.zIndex!=null&&t.setZIndex(i.zIndex,n),i.content!=null&&t.mountContent(i.content),i.footer!=null&&t.mountFooter(i.footer),this.useBoxesStatus&&(i.boxStatus||i.lastNotMinimizedBoxStatus)&&this.setBox(t,{status:i.boxStatus,lastNotMinimizedBoxStatus:i.lastNotMinimizedBoxStatus},n),i.forceTop!=null&&t.setForceTop(i.forceTop,n),i.forceNormal!=null&&t.setForceNormal(i.forceNormal,n)}smartPosition(t={}){let{x:i,y:n}=t;const{width:r=.5,height:s=.5}=t;if(i==null){let o=20;if(t.forceTop){const a=this.maxForceTopBox||this.topBox;a&&(o=a.intrinsicX*this.containerRect.width+20,o>this.containerRect.width-r*this.containerRect.width&&(o=20))}else this.topBox?(o=this.topBox.intrinsicX*this.containerRect.width+20,o>this.containerRect.width-r*this.containerRect.width&&(o=20)):this.hasMinimizedBox()&&(o=[...this.boxes].filter(a=>a.boxStatus&&a.boxStatus===N.Minimized&&a.lastNotMinimizedBoxStatus&&a.lastNotMinimizedBoxStatus===N.Normal).reduce((a,l)=>Math.max(a,l.intrinsicX*this.containerRect.width+20),o));i=o/this.containerRect.width}if(n==null){let o=20;if(t.forceTop){const a=this.maxForceTopBox||this.topBox;a&&(o=a.intrinsicY*this.containerRect.height+20,o>this.containerRect.height-s*this.containerRect.height&&(o=20))}else this.topBox?(o=this.topBox.intrinsicY*this.containerRect.height+20,o>this.containerRect.height-s*this.containerRect.height&&(o=20)):this.hasMinimizedBox()&&(o=[...this.boxes].filter(a=>a.boxStatus&&a.boxStatus===N.Minimized&&a.lastNotMinimizedBoxStatus&&a.lastNotMinimizedBoxStatus===N.Normal).reduce((a,l)=>Math.max(a,l.intrinsicY*this.containerRect.height+20),o));n=o/this.containerRect.height}return{...t,x:i,y:n,width:r,height:s}}makeBoxTop(t,i=!1){!this.useBoxesStatus&&this.topBox?t!==this.topBox&&t.setZIndex(this.topBox.zIndex+1,i):this.useBoxesStatus}getMaximizedTopBox(){if(!this.useBoxesStatus)return;let t;return this.maxTitleBar.hasMaximizedBoxInStatus()&&(t=this.maxTitleBar.MaximizedBoxes.reduce((i,n)=>i&&i.zIndex>n.zIndex?i:n)),t}makeMaximizedTopBoxFocus(){if(!this.useBoxesStatus)return;const t=this.getMaximizedTopBox();this.maxTitleBar.focusBox(t)}getBoxIndex(t){return typeof t=="string"?this.boxes.findIndex(i=>i.id===t):this.boxes.findIndex(i=>i===t)}getBox(t){return typeof t=="string"?this.boxes.find(i=>i.id===t):t}createMinimizedAppMenu(){var t,i;if((t=this.collector)!=null&&t.$appMenuContainer)return new bv({manager:this,container:(i=this.collector)==null?void 0:i.$appMenuContainer,theme:this.prefersColorScheme?"dark":"light",getBoxesStatus:()=>this.boxesStatus$})}}gr.kind="TeleBoxManager";const Iv=(e,t,i,n,r)=>{const s=At(mr,Q.extendClass);return new s({safeSetAttributes:o=>e.safeSetAttributes(o),getMainView:()=>e.mainView,updateAppState:(...o)=>{var a;return(a=e.appManager)==null?void 0:a.store.updateAppState(...o)},setBoxStatus:(o,a)=>{var l;return(l=e.appManager)==null?void 0:l.store.setBoxStatus(o,a)},setLastNotMinimizedBoxStatus:(o,a)=>{var l;return(l=e.appManager)==null?void 0:l.store.setLastNotMinimizedBoxStatus(o,a)},canOperate:()=>e.canOperate,notifyContainerRectUpdate:o=>{var a;return(a=e.appManager)==null?void 0:a.notifyContainerRectUpdate(o)},cleanFocus:()=>{var o;return(o=e.appManager)==null?void 0:o.store.cleanFocus()},setAppFocus:o=>{var a;return(a=e.appManager)==null?void 0:a.store.setAppFocus(o,!0)},callbacks:t,emitter:i,boxEmitter:n},r)};class mr{constructor(t,i){this.context=t,this.createTeleBoxManagerConfig=i;const{emitter:n,callbacks:r,boxEmitter:s}=t;this.teleBoxManager=this.setupBoxManager(i),this.teleBoxManager._state$.reaction(o=>{r.emit("boxStateChange",o),n.emit("boxStateChange",o)}),this.teleBoxManager._darkMode$.reaction(o=>{r.emit("darkModeChange",o)}),this.teleBoxManager._prefersColorScheme$.reaction(o=>{r.emit("prefersColorSchemeChange",o)}),this.teleBoxManager._minimized$.reaction(o=>{o||setTimeout(()=>{const a=.001*(Math.random()>.5?1:-1);this.teleBoxManager.boxes.forEach(l=>{l.resize(l.intrinsicWidth+a,l.intrinsicHeight+a,!0)})},400)}),this.teleBoxManager.events.on("minimized",o=>{if(this.context.safeSetAttributes({minimized:o}),o)this.context.cleanFocus(),this.blurAllBox();else{const a=this.getTopBox();a&&(this.context.setAppFocus(a.id),this.focusBox({appId:a.id},!1))}}),this.teleBoxManager.events.on("maximized",o=>{this.context.safeSetAttributes({maximized:o})}),this.teleBoxManager.events.on("removed",o=>{o.forEach(a=>{s.emit("close",{appId:a.id})})}),this.teleBoxManager.events.on("intrinsic_move",E.debounce(o=>{s.emit("move",{appId:o.id,x:o.intrinsicX,y:o.intrinsicY})},50)),this.teleBoxManager.events.on("intrinsic_resize",E.debounce(o=>{s.emit("resize",{appId:o.id,width:o.intrinsicWidth,height:o.intrinsicHeight})},200)),this.teleBoxManager.events.on("focused",o=>{o&&(this.canOperate?s.emit("focus",{appId:o.id}):this.teleBoxManager.blurBox(o.id))}),this.teleBoxManager.events.on("blurred",o=>{o&&this.canOperate&&s.emit("blurred",{appId:o.id})}),this.teleBoxManager.events.on("z_index",o=>{this.context.updateAppState(o.id,Be.ZIndex,o.zIndex)}),this.teleBoxManager.events.on("box_status",o=>{this.canOperate&&this.context.setBoxStatus(o.id,o.boxStatus)}),this.teleBoxManager.events.on("last_not_minimized_box_status",o=>{this.canOperate&&this.context.setLastNotMinimizedBoxStatus(o.id,o.boxStatus)}),n.on("playgroundSizeChange",()=>this.updateManagerRect()),n.on("updateManagerRect",()=>this.updateManagerRect())}get mainView(){return this.context.getMainView()}get canOperate(){return this.context.canOperate()}get boxState(){return this.teleBoxManager.state}get maximized(){return this.teleBoxManager.maximized}get minimized(){return this.teleBoxManager.minimized}get darkMode(){return this.teleBoxManager.darkMode}get prefersColorScheme(){return this.teleBoxManager.prefersColorScheme}get boxSize(){return this.teleBoxManager.boxes.length}createBox(t){var u,c,h;if(!this.teleBoxManager)return;let{minwidth:i=Ug,minheight:n=Wg}=(u=t.app.config)!=null?u:{};const{width:r,height:s}=(c=t.app.config)!=null?c:{},o=((h=t.options)==null?void 0:h.title)||t.appId,a=this.teleBoxManager.containerRect;i>1&&(i=i/a.width),n>1&&(n=n/a.height);const l={title:o,minWidth:i,minHeight:n,width:r,height:s,id:t.appId,boxStatus:t.boxStatus,forceTop:t.forceTop,forceNormal:t.forceNormal,isDragContent:t.isDragContent};this.teleBoxManager.create(l,t.smartPosition),this.context.emitter.emit(`${t.appId}${se.WindowCreated}`)}setBoxInitState(t){const i=this.teleBoxManager.queryOne({id:t});i&&i.state===N.Maximized&&this.context.boxEmitter.emit("resize",{appId:t,x:i.x,y:i.y,width:i.intrinsicWidth,height:i.intrinsicHeight})}setBoxesStatus(t){const i=new Map(Object.entries(t!=null?t:{}));this.teleBoxManager.setBoxesStatus(i,!0),this.context.callbacks.emit("onBoxesStatusChange",i),this.context.emitter.emit("boxesStatusChange",i)}setLastNotMinimizedBoxesStatus(t){const i=new Map(Object.entries(t!=null?t:{}));this.teleBoxManager.setLastNotMinimizedBoxesStatus(i,!0),this.context.callbacks.emit("onLastNotMinimizedBoxesStatusChange",i),this.context.emitter.emit("lastNotMinimizedBoxesStatusChange",i)}setupBoxManager(t){const i=Q.wrapper?Q.wrapper:document.body,n=i.getBoundingClientRect(),r={root:i,containerRect:{x:0,y:0,width:n.width,height:n.height},fence:!1,prefersColorScheme:t==null?void 0:t.prefersColorScheme,useBoxesStatus:(t==null?void 0:t.useBoxesStatus)||!1},s=At(gr,Q.extendClass),o=new s(r);this.teleBoxManager&&this.teleBoxManager.destroy(),this.teleBoxManager=o;const a=(t==null?void 0:t.collectorContainer)||Q.wrapper;return a&&this.setCollectorContainer(a),o}setCollectorContainer(t){var r;const i=At(cn,Q.extendClass),n=new i({styles:(r=this.createTeleBoxManagerConfig)==null?void 0:r.collectorStyles}).mount(t);this.teleBoxManager.setCollector(n)}getBox(t){return this.teleBoxManager.queryOne({id:t})}closeBox(t,i=!1){return this.teleBoxManager.remove(t,i)}boxIsFocus(t){const i=this.getBox(t);return i==null?void 0:i.focus}getFocusBox(){return this.teleBoxManager.query({focus:!0})[0]}getTopBox(){return this.teleBoxManager.topBox}updateBoxState(t){if(!t)return;const i=this.getBox(t.id);i&&(this.teleBoxManager.update(i.id,{x:t.x,y:t.y,width:t.width||.5,height:t.height||.5,zIndex:t.zIndex,boxStatus:t.boxStatus,lastNotMinimizedBoxStatus:t.lastNotMinimizedBoxStatus,forceTop:t.forceTop,forceNormal:t.forceNormal,isDragContent:t.isDragContent},!0),setTimeout(()=>{t.focus&&this.teleBoxManager.focusBox(i.id,!0),t.maximized!=null&&this.teleBoxManager.setMaximized(Boolean(t.maximized),!0),t.minimized!=null&&this.teleBoxManager.setMinimized(Boolean(t.minimized),!0)},50),t.boxStatus||this.context.callbacks.emit("boxStateChange",this.teleBoxManager.state))}updateManagerRect(){var i;const t=(i=this.mainView.divElement)==null?void 0:i.getBoundingClientRect();if(t&&t.width>0&&t.height>0){const n={x:0,y:0,width:t.width,height:t.height};this.teleBoxManager.setContainerRect(n),this.context.notifyContainerRectUpdate(this.teleBoxManager.containerRect)}}moveBox({appId:t,x:i,y:n}){this.teleBoxManager.update(t,{x:i,y:n},!0)}focusBox({appId:t},i=!0){this.teleBoxManager.focusBox(t,i)}resizeBox({appId:t,width:i,height:n,skipUpdate:r}){this.teleBoxManager.update(t,{width:i,height:n},r)}setBoxMinSize(t){this.teleBoxManager.update(t.appId,{minWidth:t.minWidth,minHeight:t.minHeight},!0)}setBoxTitle(t){this.teleBoxManager.update(t.appId,{title:t.title},!0)}blurAllBox(){this.teleBoxManager.blurAll()}updateAll(t){this.teleBoxManager.updateAll(t)}setMaximized(t,i=!0){t!==this.maximized&&this.teleBoxManager.setMaximized(t,i)}setMinimized(t,i=!0){this.teleBoxManager.setMinimized(t,i)}focusTopBox(){if(this.teleBoxManager.query().length>=1){const i=this.getTopBox();i&&this.focusBox({appId:i.id},!1)}}updateBox(t,i,n=!0){this.teleBoxManager.update(t,i,n)}setReadonly(t){this.teleBoxManager.setReadonly(t)}setPrefersColorScheme(t){this.teleBoxManager.setPrefersColorScheme(t)}setZIndex(t,i,n=!0){this.teleBoxManager.update(t,{zIndex:i},n)}destroy(){this.teleBoxManager.destroy()}}mr.kind="BoxManager";function tc(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?e:JSON.stringify(e)}function oi(e,t){if(e===void 0)return"undefined";if(e===null)return"null";const i=typeof e;if(i==="bigint")return`${e}n`;if(i==="symbol")return String(e);if(i==="function")return`[Function ${e.name||"anonymous"}]`;if(i!=="object")return i==="string"?JSON.stringify(e):String(e);const n=e;if(t!=null&&t.has(n))return"[Circular]";const r=t!=null?t:new WeakSet;r.add(n);try{return Array.isArray(e)?`[${Array.from(e,a=>oi(a,r)).join(",")}]`:e instanceof Date?JSON.stringify(e.toISOString()):e instanceof RegExp?String(e):`{${Object.keys(e).map(a=>{let l;try{l=e[a]}catch{return`${tc(a)}:[Threw]`}return`${tc(a)}:${oi(l,r)}`}).join(",")}}`}catch{return"[Unserializable]"}finally{r.delete(n)}}function Tv(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Date)&&!(e instanceof RegExp)}const ic=1500;function Av(e){if(e.length<=ic)return e;const t="\u2026";return e.slice(0,ic-t.length)+t}function Ev(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}const et=(...e)=>{Q.debug&&console.log("[WindowManager]:",...e)};class zn{constructor(t,i){this.name=t,this.debounceTime=i,this.pendingArgs=null,this.flushTimer=null}flush(){this.flushTimer=null;const t=this.pendingArgs;this.pendingArgs=null,t!==null&&console.log(`[window-manager][${this.name}]: ${t.join(", ")}`)}log(...t){const i=this.debounceTime;if(i!=null&&i>0){this.pendingArgs=t,this.flushTimer!=null&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>this.flush(),i);return}console.log(`[window-manager][${this.name}]: ${t.join(", ")}`)}destroy(){this.flushTimer!=null&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.pendingArgs=null}}class Nv{constructor(t,i,n){this.logger=t,this.name=i,this.debounceTime=n,this.pendingArgs=null,this.flushTimer=null,this.pendingShallowMerge=null,this.shallowMergeTimer=null,this.pendingUpdateSegments=null,this.updateMergeTimer=null}emitInfo(t){this.logger.info(Av(t))}flush(){this.flushTimer=null;const t=this.pendingArgs;this.pendingArgs=null,t!==null&&this.emitInfo(`[WindowManager][${this.name}]: ${t.join(", ")}`)}flushShallowMerge(){this.shallowMergeTimer=null;const t=this.pendingShallowMerge;if(this.pendingShallowMerge=null,t===null)return;const i=t.kind==="record"?oi(t.data):oi(t.value);if(this.emitInfo(`[WindowManager][${this.name}]: ${t.label} ${i}`),t.kind==="record")for(const n of Object.keys(t.data))delete t.data[n]}log(...t){const i=this.debounceTime;if(i!=null&&i>0){this.pendingArgs=t,this.flushTimer!=null&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>this.flush(),i);return}this.emitInfo(`[WindowManager][${this.name}]: ${t.join(", ")}`)}logDebouncedShallowMerge(t,i){var o;const n=this.debounceTime,r=n!=null&&n>0,s=a=>{this.emitInfo(`[WindowManager][${this.name}]: ${t} ${a}`)};if(!r){s(oi(i));return}this.shallowMergeTimer!=null&&(clearTimeout(this.shallowMergeTimer),this.shallowMergeTimer=null),Tv(i)?((o=this.pendingShallowMerge)==null?void 0:o.kind)==="record"?this.pendingShallowMerge={kind:"record",label:t,data:{...this.pendingShallowMerge.data,...i}}:this.pendingShallowMerge={kind:"record",label:t,data:{...i}}:this.pendingShallowMerge={kind:"atom",label:t,value:i},this.shallowMergeTimer=setTimeout(()=>this.flushShallowMerge(),n)}flushUpdateAttributesMerge(){this.updateMergeTimer=null;const t=this.pendingUpdateSegments;if(this.pendingUpdateSegments=null,t===null||t.length===0)return;const i=t.map(n=>`${n.keys.join(", ")} ${oi(n.value)}`);this.emitInfo(`[WindowManager][${this.name}]: safeUpdateAttributes ${i.join(" | ")}`);for(const n of t)n.keys.length=0,n.value=void 0;t.length=0}logDebouncedUpdateAttributes(t,i){const n=this.debounceTime,r=n!=null&&n>0,s=[...t];if(!r){this.emitInfo(`[WindowManager][${this.name}]: safeUpdateAttributes ${s.join(", ")} ${oi(i)}`);return}if(this.updateMergeTimer!=null&&(clearTimeout(this.updateMergeTimer),this.updateMergeTimer=null),this.pendingUpdateSegments===null||this.pendingUpdateSegments.length===0)this.pendingUpdateSegments=[{keys:s,value:i}];else{const o=this.pendingUpdateSegments[this.pendingUpdateSegments.length-1];Ev(o.keys,s)?o.value=i:this.pendingUpdateSegments.push({keys:s,value:i})}this.updateMergeTimer=setTimeout(()=>this.flushUpdateAttributesMerge(),n)}destroy(){this.flushTimer!=null&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.shallowMergeTimer!=null&&(clearTimeout(this.shallowMergeTimer),this.shallowMergeTimer=null),this.updateMergeTimer!=null&&(clearTimeout(this.updateMergeTimer),this.updateMergeTimer=null),this.pendingArgs=null,this.pendingShallowMerge=null,this.pendingUpdateSegments=null}dispose(){this.destroy()}}const kv=e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");i.className="netless-window-manager-sizer";const n=document.createElement("div");n.className="netless-window-manager-wrapper";const r=document.createElement("div");return r.className="netless-window-manager-main-view",t.appendChild(i),i.appendChild(n),n.appendChild(r),e.appendChild(t),Q.wrapper=n,{playground:t,wrapper:n,sizer:i,mainViewElement:r}},Pv=()=>{if(Uu(I.WhiteVersion)<Uu(Vu))throw new Qh(Vu)},ua=(e,t)=>{var s;const i=(e==null?void 0:e.state.roomMembers)||[];let n=-1,r;for(const o of i)((s=o.payload)==null?void 0:s.uid)===t&&n<o.memberId&&(n=o.memberId,r=o);return r},zv=async e=>{let t=e.getInvisiblePlugin(Q.kind);if(t)return t;let i;const n=new Promise(u=>{Q._resolve=i=u});let r=!1;const s=Bv(e);!e.isWritable&&s&&(r=!0,await Oh.default(async u=>{et(`switching to writable (x${u})`),await e.setWritable(!0)},{retries:10,maxTimeout:5e3})),e.isWritable?(et("creating InvisiblePlugin..."),e.createInvisiblePlugin(Q,{}).catch(console.warn)):(s&&console.warn("[WindowManager]: failed to switch to writable"),console.warn("[WindowManager]: waiting for others to create the plugin..."));const o=setTimeout(()=>{console.warn("[WindowManager]: no one called createInvisiblePlugin() after 20 seconds")},2e4),a=setTimeout(()=>{throw new Error("[WindowManager]: no one called createInvisiblePlugin() after 60 seconds")},6e4),l=setInterval(()=>{t=e.getInvisiblePlugin(Q.kind),t&&(clearTimeout(a),clearTimeout(o),clearInterval(l),i(t),r&&e.isWritable&&setTimeout(()=>e.setWritable(!1).catch(console.warn),500))},200);return n},Bv=e=>{try{const t=atob(e.roomToken.slice(12)),i=t.indexOf("&role=");return+t[i+6]<2}catch(t){return console.error(t),!1}};function qn(){}function xd(e){return e()}function nc(){return Object.create(null)}function eo(e){e.forEach(xd)}function Sd(e){return typeof e=="function"}function Dv(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}let Vr;function Ms(e,t){return Vr||(Vr=document.createElement("a")),Vr.href=t,e===Vr.href}function Lv(e){return Object.keys(e).length===0}function Mt(e,t){e.appendChild(t)}function to(e,t,i){e.insertBefore(t,i||null)}function vr(e){e.parentNode&&e.parentNode.removeChild(e)}function Vt(e){return document.createElement(e)}function Sl(e){return document.createTextNode(e)}function ca(){return Sl(" ")}function le(e,t,i){i==null?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function Rv(e){return Array.from(e.childNodes)}function Md(e,t){t=""+t,e.data!==t&&(e.data=t)}function ye(e,t,i,n){i==null?e.style.removeProperty(t):e.style.setProperty(t,i,n?"important":"")}let Ml;function $n(e){Ml=e}const Ri=[],rc=[];let Qi=[];const sc=[],jv=Promise.resolve();let ha=!1;function _v(){ha||(ha=!0,jv.then(Cd))}function da(e){Qi.push(e)}const zo=new Set;let Bi=0;function Cd(){if(Bi!==0)return;const e=Ml;do{try{for(;Bi<Ri.length;){const t=Ri[Bi];Bi++,$n(t),Vv(t.$$)}}catch(t){throw Ri.length=0,Bi=0,t}for($n(null),Ri.length=0,Bi=0;rc.length;)rc.pop()();for(let t=0;t<Qi.length;t+=1){const i=Qi[t];zo.has(i)||(zo.add(i),i())}Qi.length=0}while(Ri.length);for(;sc.length;)sc.pop()();ha=!1,zo.clear(),$n(e)}function Vv(e){if(e.fragment!==null){e.update(),eo(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(da)}}function Ov(e){const t=[],i=[];Qi.forEach(n=>e.indexOf(n)===-1?t.push(n):i.push(n)),i.forEach(n=>n()),Qi=t}const $v=new Set;function Uv(e,t){e&&e.i&&($v.delete(e),e.i(t))}function Wv(e,t,i,n){const{fragment:r,after_update:s}=e.$$;r&&r.m(t,i),n||da(()=>{const o=e.$$.on_mount.map(xd).filter(Sd);e.$$.on_destroy?e.$$.on_destroy.push(...o):eo(o),e.$$.on_mount=[]}),s.forEach(da)}function Hv(e,t){const i=e.$$;i.fragment!==null&&(Ov(i.after_update),eo(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}function Fv(e,t){e.$$.dirty[0]===-1&&(Ri.push(e),_v(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Qv(e,t,i,n,r,s,o,a=[-1]){const l=Ml;$n(e);const u=e.$$={fragment:null,ctx:[],props:s,update:qn,not_equal:r,bound:nc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:nc(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(u.root);let c=!1;if(u.ctx=i?i(e,t.props||{},(h,m,...v)=>{const w=v.length?v[0]:m;return u.ctx&&r(u.ctx[h],u.ctx[h]=w)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](w),c&&Fv(e,h)),m}):[],u.update(),c=!0,eo(u.before_update),u.fragment=n?n(u.ctx):!1,t.target){if(t.hydrate){const h=Rv(t.target);u.fragment&&u.fragment.l(h),h.forEach(vr)}else u.fragment&&u.fragment.c();t.intro&&Uv(e.$$.fragment),Wv(e,t.target,t.anchor,t.customElement),Cd()}$n(l)}class Zv{$destroy(){Hv(this,1),this.$destroy=qn}$on(t,i){if(!Sd(i))return qn;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(i),()=>{const r=n.indexOf(i);r!==-1&&n.splice(r,1)}}$set(t){this.$$set&&!Lv(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function oc(e){let t,i,n,r,s,o,a,l=e[18]&&ac(e),u=e[19]&&lc(e);return{c(){t=Vt("div"),i=Vt("div"),l&&l.c(),n=ca(),r=Vt("span"),s=Sl(e[1]),o=ca(),u&&u.c(),ye(r,"overflow","hidden"),ye(r,"white-space","nowrap"),ye(r,"text-overflow","ellipsis"),ye(r,"max-width","80px"),le(i,"class",e[9]),ye(i,"background-color",e[3]),ye(i,"color",e[10]),ye(i,"opacity",e[12]),le(t,"class",a="netless-window-manager-cursor-name "+e[16]+" "+e[15])},m(c,h){to(c,t,h),Mt(t,i),l&&l.m(i,null),Mt(i,n),Mt(i,r),Mt(r,s),Mt(i,o),u&&u.m(i,null)},p(c,h){c[18]?l?l.p(c,h):(l=ac(c),l.c(),l.m(i,n)):l&&(l.d(1),l=null),h&2&&Md(s,c[1]),c[19]?u?u.p(c,h):(u=lc(c),u.c(),u.m(i,null)):u&&(u.d(1),u=null),h&512&&le(i,"class",c[9]),h&8&&ye(i,"background-color",c[3]),h&1024&&ye(i,"color",c[10]),h&4096&&ye(i,"opacity",c[12]),h&98304&&a!==(a="netless-window-manager-cursor-name "+c[16]+" "+c[15])&&le(t,"class",a)},d(c){c&&vr(t),l&&l.d(),u&&u.d()}}}function ac(e){let t,i;return{c(){t=Vt("img"),le(t,"class","netless-window-manager-cursor-selector-avatar"),le(t,"style",e[20]()),Ms(t.src,i=e[8])||le(t,"src",i),le(t,"alt","avatar")},m(n,r){to(n,t,r)},p(n,r){r&256&&!Ms(t.src,i=n[8])&&le(t,"src",i)},d(n){n&&vr(t)}}}function lc(e){let t,i;return{c(){t=Vt("span"),i=Sl(e[2]),le(t,"class","netless-window-manager-cursor-tag-name"),ye(t,"background-color",e[11])},m(n,r){to(n,t,r),Mt(t,i)},p(n,r){r&4&&Md(i,n[2]),r&2048&&ye(t,"background-color",n[11])},d(n){n&&vr(t)}}}function Yv(e){let t,i,n,r,s,o,a,l=!e[14]&&oc(e);return{c(){t=Vt("div"),l&&l.c(),i=ca(),n=Vt("div"),r=Vt("img"),le(r,"class",s="netless-window-manager-cursor-"+e[4]+"-image "+e[15]),Ms(r.src,o=e[7])||le(r,"src",o),le(r,"alt",e[4]),le(n,"class","cursor-image-wrapper"),le(t,"class",a="netless-window-manager-cursor-mid"+(e[13]?" netless-window-manager-cursor-custom":"")),ye(t,"transform","translateX("+e[5]+"px) translateY("+e[6]+"px)"),ye(t,"display",e[17]),le(t,"data-cursor-uid",e[0])},m(u,c){to(u,t,c),l&&l.m(t,null),Mt(t,i),Mt(t,n),Mt(n,r)},p(u,[c]){u[14]?l&&(l.d(1),l=null):l?l.p(u,c):(l=oc(u),l.c(),l.m(t,i)),c&32784&&s!==(s="netless-window-manager-cursor-"+u[4]+"-image "+u[15])&&le(r,"class",s),c&128&&!Ms(r.src,o=u[7])&&le(r,"src",o),c&16&&le(r,"alt",u[4]),c&8192&&a!==(a="netless-window-manager-cursor-mid"+(u[13]?" netless-window-manager-cursor-custom":""))&&le(t,"class",a),c&96&&ye(t,"transform","translateX("+u[5]+"px) translateY("+u[6]+"px)"),c&131072&&ye(t,"display",u[17]),c&1&&le(t,"data-cursor-uid",u[0])},i:qn,o:qn,d(u){u&&vr(t),l&&l.d()}}}function Gv(e,t,i){let n,r,s,o,a,l,u,c,{uid:h}=t,{cursorName:m}=t,{tagName:v}=t,{backgroundColor:w}=t,{appliance:x}=t,{x:d}=t,{y:f}=t,{src:g}=t,{visible:p}=t,{avatar:y}=t,{theme:S}=t,{color:A}=t,{cursorTagBackgroundColor:k}=t,{opacity:z}=t,{pencilEraserSize:B}=t,{custom:ee}=t;const b=()=>Object.entries({width:(n?19:28)+"px",height:(n?19:28)+"px",position:n?"initial":"absolute","border-color":n?"white":w,"margin-right":(n?4:0)+"px"}).map(([M,V])=>`${M}: ${V}`).join(";");return e.$$set=M=>{"uid"in M&&i(0,h=M.uid),"cursorName"in M&&i(1,m=M.cursorName),"tagName"in M&&i(2,v=M.tagName),"backgroundColor"in M&&i(3,w=M.backgroundColor),"appliance"in M&&i(4,x=M.appliance),"x"in M&&i(5,d=M.x),"y"in M&&i(6,f=M.y),"src"in M&&i(7,g=M.src),"visible"in M&&i(21,p=M.visible),"avatar"in M&&i(8,y=M.avatar),"theme"in M&&i(9,S=M.theme),"color"in M&&i(10,A=M.color),"cursorTagBackgroundColor"in M&&i(11,k=M.cursorTagBackgroundColor),"opacity"in M&&i(12,z=M.opacity),"pencilEraserSize"in M&&i(22,B=M.pencilEraserSize),"custom"in M&&i(13,ee=M.custom)},e.$$.update=()=>{e.$$.dirty&2&&(n=!E.isEmpty(m)),e.$$.dirty&4&&i(19,r=!E.isEmpty(v)),e.$$.dirty&256&&i(18,s=!E.isEmpty(y)),e.$$.dirty&2097152&&i(17,o=p?"":"none"),e.$$.dirty&16&&i(14,a=x===I.ApplianceNames.laserPointer),e.$$.dirty&16400&&i(23,l=a||x===I.ApplianceNames.pencilEraser),e.$$.dirty&8388608&&i(16,u=l?"netless-window-manager-laserPointer-pencilEraser-offset":""),e.$$.dirty&4194304&&i(15,c=B===3?"netless-window-manager-pencilEraser-3-offset":"")},[h,m,v,w,x,d,f,g,y,S,A,k,z,ee,a,c,u,o,s,r,b,p,B,l]}class Xv extends Zv{constructor(t){super(),Qv(this,t,Gv,Yv,Dv,{uid:0,cursorName:1,tagName:2,backgroundColor:3,appliance:4,x:5,y:6,src:7,visible:21,avatar:8,theme:9,color:10,cursorTagBackgroundColor:11,opacity:12,pencilEraserSize:22,custom:13})}}const bd="data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle cx='12' cy='12' r='2.5' stroke='%23000' stroke-linejoin='square'/%3E%3Ccircle cx='12' cy='12' r='3.5' stroke='%23FFF'/%3E%3C/g%3E%3C/svg%3E";function Id(e){return`data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle cx='12' cy='12' r='2.5' stroke='%23${e}' stroke-linejoin='square'/%3E%3Ccircle cx='12' cy='12' r='3.5' stroke='%23${e}'/%3E%3C/g%3E%3C/svg%3E`}function ji(e){return`data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg' fill='none'%3E%3Cpath d='M5 12H19' stroke='%23${e}' stroke-linejoin='round'/%3E%3Cpath d='M12 5V19' stroke='%23${e}' stroke-linejoin='round'/%3E%3C/svg%3E`}function ri(e){return`url("${e}") 12 12, auto`}function Jv(e){let t="";for(const i in e)t+=`.netless-whiteboard.${i} {cursor: ${e[i]}}
16
- `;return t}const Or=document.createElement("style");function Kv(e){const[t,i,n]=e.strokeColor,r=((1<<24)+(t<<16)+(i<<8)+n).toString(16).slice(1);return Or.textContent=Jv({"cursor-pencil":ri(Id(r)),"cursor-eraser":ri(bd),"cursor-rectangle":ri(ji(r)),"cursor-ellipse":ri(ji(r)),"cursor-straight":ri(ji(r)),"cursor-arrow":ri(ji(r)),"cursor-shape":ri(ji(r))}),document.head.appendChild(Or),()=>{Or.parentNode!=null&&document.head.removeChild(Or)}}const qv=new Set([I.ApplianceNames.rectangle,I.ApplianceNames.ellipse,I.ApplianceNames.straight,I.ApplianceNames.arrow,I.ApplianceNames.shape]);function uc(e,t){if(e===I.ApplianceNames.pencil)return Id(t);if(e===I.ApplianceNames.eraser)return bd;if(qv.has(e))return ji(t)}class ew{constructor(t,i,n,r){this.manager=t,this.memberId=i,this.cursorManager=n,this.wrapper=r,this.style="default",this.move=s=>{var o;if(s.type==="main"){const a=this.cursorManager.wrapperRect;this.component&&a&&(this.autoHidden(),this.moveCursor(s,a,this.manager.mainView))}else{const a=this.cursorManager.focusView,l=(o=a==null?void 0:a.divElement)==null?void 0:o.getBoundingClientRect(),u=a==null?void 0:a.camera;a&&l&&u&&this.component&&(this.autoHidden(),this.moveCursor(s,l,a))}},this.setStyle=s=>{this.style=s,this.component&&this.component.$set({src:this.getIcon(),custom:this.isCustomIcon()})},this.leave=()=>{this.hide()},this.updateMember(),this.createCursor(),this.autoHidden(),this.setStyle(n.style)}moveCursor(t,i,n){var l,u;const{x:r,y:s,type:o}=t,a=n==null?void 0:n.screen.convertPointToScreen(r,s);if(a){let c=a.x-2,h=a.y-18;if(this.isCustomIcon()&&(c-=11,h+=4),o==="app"){const m=this.cursorManager.wrapperRect;m&&(c=c+i.x-m.x,h=h+i.y-m.y)}a.x<0||a.x>i.width||a.y<0||a.y>i.height?(l=this.component)==null||l.$set({visible:!1,x:c,y:h}):(u=this.component)==null||u.$set({visible:!0,x:c,y:h})}}get memberApplianceName(){var t,i;return(i=(t=this.member)==null?void 0:t.memberState)==null?void 0:i.currentApplianceName}get memberColor(){var i,n;return`rgb(${(n=(i=this.member)==null?void 0:i.memberState)==null?void 0:n.strokeColor.join(",")})`}get memberColorHex(){var r,s;const[t,i,n]=((s=(r=this.member)==null?void 0:r.memberState)==null?void 0:s.strokeColor)||[236,52,85];return((1<<24)+(t<<16)+(i<<8)+n).toString(16).slice(1)}get payload(){var t;return(t=this.member)==null?void 0:t.payload}get memberCursorName(){var t,i;return((t=this.payload)==null?void 0:t.nickName)||((i=this.payload)==null?void 0:i.cursorName)||this.memberId}get memberTheme(){var t;return(t=this.payload)!=null&&t.theme?"netless-window-manager-cursor-inner-mellow":"netless-window-manager-cursor-inner"}get memberCursorTextColor(){var t;return((t=this.payload)==null?void 0:t.cursorTextColor)||"#FFFFFF"}get memberCursorTagBackgroundColor(){var t;return((t=this.payload)==null?void 0:t.cursorTagBackgroundColor)||this.memberColor}get memberAvatar(){var t;return(t=this.payload)==null?void 0:t.avatar}get memberOpacity(){return!this.memberCursorName&&!this.memberAvatar?0:1}get memberTagName(){var t;return(t=this.payload)==null?void 0:t.cursorTagName}autoHidden(){this.timer&&clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.hide()},1e3*10)}async createCursor(){this.member&&this.wrapper&&(this.component=new Xv({target:this.wrapper,props:this.initProps()}))}initProps(){var t;return{uid:this.memberId,x:0,y:0,appliance:this.memberApplianceName,avatar:this.memberAvatar,src:this.getIcon(),custom:this.isCustomIcon(),visible:!1,backgroundColor:this.memberColor,cursorName:this.memberCursorName,theme:this.memberTheme,color:this.memberCursorTextColor,cursorTagBackgroundColor:this.memberCursorTagBackgroundColor,opacity:this.memberOpacity,tagName:this.memberTagName,pencilEraserSize:(t=this.member)==null?void 0:t.memberState.pencilEraserSize}}getIcon(){var l;if(!this.member)return;const{memberApplianceName:t,memberColorHex:i}=this,{userApplianceIcons:n,applianceIcons:r}=this.cursorManager;let s=this.memberApplianceName;s===I.ApplianceNames.pencilEraser&&(s=`${s}${((l=this.member)==null?void 0:l.memberState.pencilEraserSize)||1}`);const o=s&&n[s];if(o)return o;if(this.style==="custom"&&t){const u=uc(t,i);if(u)return u}return r[s||I.ApplianceNames.shape]||r[I.ApplianceNames.shape]}isCustomIcon(){var o;if(!this.member)return!1;const{memberApplianceName:t,memberColorHex:i}=this,{userApplianceIcons:n}=this.cursorManager;let r=this.memberApplianceName;return r===I.ApplianceNames.pencilEraser&&(r=`${r}${((o=this.member)==null?void 0:o.memberState.pencilEraserSize)||1}`),r&&n[r]?!1:!!(this.style==="custom"&&t&&uc(t,i))}updateMember(){return this.member=ua(this.manager.room,this.memberId),this.updateComponent(),this.member}updateComponent(){var t;(t=this.component)==null||t.$set(E.omit(this.initProps(),["x","y"]))}destroy(){this.component&&this.component.$destroy(),this.cursorManager.cursorInstances.delete(this.memberId),this.timer&&clearTimeout(this.timer)}hide(){this.component&&(this.component.$set({visible:!1}),this.destroy())}}var tw="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5Gh6Fy8Jk+/NkcCAlAAuUkoW4g0B+d5tLS05O/r67O8eGxsDNra2uDy8nKsoKCAwCIQDxQa0yTxgrvCYXyTk5Ml+Orf2dlJeeHIyAigFSE/P38ELfUNqNdSkjgF5FF89jL1TU1NlQwODl5gZPujp6cHWltbUw7Koc7Pz8mkZpHPFeFrJuZeqLnoMoPoZqe0JjDP/IZgnyLUG/o8NDRkuo5Ua2pjY6MC4oFCFf1cA0oKzRSOp6enRfTaGh0d/QxBt+1CUVgnOTs7+xrHfQzGyOcKkK3QTJMnQffZ6e/v/xwttmsHqqmpKXbdycnJCxy7ABLh3FEgVZ6hZJhnFZoFFMF0d3c/w7v+dyookXBnZ2c/xvHfhriVcvXfdBRItsxjnOhYqjwjoAimq6vrCysoGofk+Ph4Esd/F/UdiFtJAGUd2DygTpp5dmBUUJ2dnc9VUALm8PDwJY7/BPU9VD8k3M4RC6kskxZMKigKIMLN9vf3p3H8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BhY2l0eT0iMC4zNSIgc3Ryb2tlPSJ3aGl0ZSIvPgo8L3N2Zz4K",uw="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzQiIGhlaWdodD0iNTAiIHZpZXdCb3g9IjAgMCAzNCA1MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3QgeD0iMC41IiB5PSIwLjUiIHdpZHRoPSIzMyIgaGVpZ2h0PSI0OSIgcng9IjMuNSIgZmlsbD0iYmxhY2siIGZpbGwtb3BhY2l0eT0iMC4zNSIgc3Ryb2tlPSJ3aGl0ZSIvPgo8L3N2Zz4K";const cw={[I.ApplianceNames.pencil]:tw,[I.ApplianceNames.selector]:iw,[I.ApplianceNames.eraser]:nw,[I.ApplianceNames.shape]:rw,[I.ApplianceNames.text]:sw,[I.ApplianceNames.laserPointer]:ow,pencilEraser1:aw,pencilEraser2:lw,pencilEraser3:uw},cc="local-cursor";class wr{constructor(t,i,n,r){var a;this.manager=t,this.enableCursor=i,this.cursorInstances=new Map,this.userApplianceIcons={},this.sideEffectManager=new dr,this.store=this.manager.store,this.leaveFlag=!0,this._style="default",this.onCursorMove=l=>{const u=this.initCursorInstance(l.uid);if(l.state===ea.Leave)u.leave();else{const c=u.updateMember();this.canMoveCursor(c)&&u.move(l.position)}},this.initCursorInstance=l=>{let u=this.cursorInstances.get(l);return u||(u=new ew(this.manager,l,this,Q.wrapper),this.cursorInstances.set(l,u)),u},this.mouseMoveListener_=(l,u)=>{const c=this.getType(l);this.updateCursor(c,l.clientX,l.clientY),u&&this.showPencilEraserIfNeeded(c,l.clientX,l.clientY)},this.mouseMoveTimer=0,this.mouseMoveListener=l=>{const u=l.pointerType==="touch";if(u&&!l.isPrimary)return;const c=Date.now();if(c-this.mouseMoveTimer>48){if(this.mouseMoveTimer=c,Q.supportAppliancePlugin&&I.isRoom(Q.displayer)&&Q.displayer.disableDeviceInputs){this.leaveFlag&&(this.manager.dispatchInternalEvent(se.CursorMove,{uid:this.manager.uid,state:ea.Leave}),this.leaveFlag=!1);return}this.mouseMoveListener_(l,u),this.leaveFlag=!0}},this.mouseLeaveListener=()=>{this.hideCursor(this.manager.uid)},this.getPoint=(l,u,c)=>{var m;const h=(m=l==null?void 0:l.divElement)==null?void 0:m.getBoundingClientRect();if(h)return l==null?void 0:l.convertToPointInWorld({x:u-h.x,y:c-h.y})},this.getType=l=>{var h;const u=l.target,c=this.manager.focusApp;switch(u.parentElement){case this.mainViewElement:return{type:"main"};case((h=c==null?void 0:c.view)==null?void 0:h.divElement):return{type:"app"};default:return{type:"main"}}},this.roomMembers=(a=this.manager.room)==null?void 0:a.state.roomMembers;const s=Q.wrapper;s&&this.setupWrapper(s),this.sideEffectManager.add(()=>_.on("cursorMove",this.onCursorMove)),this.sideEffectManager.add(()=>_.on("playgroundSizeChange",()=>this.updateContainerRect()));const o=this.manager.room;o&&this.sideEffectManager.add(()=>{const l=u=>{this.style==="custom"&&u.memberState&&this.enableCustomCursor()};return o.callbacks.on("onRoomStateChanged",l),()=>o.callbacks.off("onRoomStateChanged",l)}),r&&(this.userApplianceIcons=r),this.style=(n==null?void 0:n.style)||"default"}get applianceIcons(){return{...cw,...this.userApplianceIcons}}get style(){return this._style}set style(t){this._style!==t&&(this._style=t,this.cursorInstances.forEach(i=>{i.setStyle(t)}),t==="custom"?this.enableCustomCursor():this.sideEffectManager.flush(cc))}enableCustomCursor(){this.sideEffectManager.add(()=>Kv(this.manager.getMemberState()),cc)}canMoveCursor(t){const i=(t==null?void 0:t.memberState.currentApplianceName)===I.ApplianceNames.laserPointer;return this.enableCursor||i}setupWrapper(t){this.sideEffectManager.add(()=>(t.addEventListener("pointerenter",this.mouseMoveListener),t.addEventListener("pointermove",this.mouseMoveListener),t.addEventListener("pointerleave",this.mouseLeaveListener),()=>{t.removeEventListener("pointerenter",this.mouseMoveListener),t.removeEventListener("pointermove",this.mouseMoveListener),t.removeEventListener("pointerleave",this.mouseLeaveListener)})),this.wrapperRect=t.getBoundingClientRect()}setMainViewDivElement(t){this.mainViewElement=t}get boxState(){return this.store.getBoxState()}get focusView(){var t;return(t=this.manager.focusApp)==null?void 0:t.view}showPencilEraserIfNeeded(t,i,n){const r=ua(this.manager.room,this.manager.uid),s=(r==null?void 0:r.memberState.currentApplianceName)===I.ApplianceNames.pencilEraser;if(this.wrapperRect&&this.manager.canOperate&&this.canMoveCursor(r)&&s){const o=t.type==="main"?this.manager.mainView:this.focusView,a=this.getPoint(o,i,n);a&&this.onCursorMove({uid:this.manager.uid,position:{x:a.x,y:a.y,type:t.type}})}}updateCursor(t,i,n){const r=ua(this.manager.room,this.manager.uid);if(this.wrapperRect&&this.manager.canOperate&&this.canMoveCursor(r)){const s=t.type==="main"?this.manager.mainView:this.focusView,o=this.getPoint(s,i,n);o&&this.manager.dispatchInternalEvent(se.CursorMove,{uid:this.manager.uid,position:{x:o.x,y:o.y,type:t.type}})}}updateContainerRect(){var t,i;this.containerRect=(t=Q.container)==null?void 0:t.getBoundingClientRect(),this.wrapperRect=(i=Q.wrapper)==null?void 0:i.getBoundingClientRect()}deleteCursor(t){this.store.cleanCursor(t);const i=this.cursorInstances.get(t);i&&i.destroy()}hideCursor(t){const i=this.cursorInstances.get(t);i&&i.hide()}destroy(){this.sideEffectManager.flushAll(),this.cursorInstances.size&&(this.cursorInstances.forEach(t=>{t.destroy()}),this.cursorInstances.clear())}}wr.kind="CursorManager";function At(e,t){if(e.kind&&t&&Object.keys(t).includes(e.kind))switch(e.kind){case"AppManager":return(t==null?void 0:t.AppManager)||Sr;case"BoxManager":return(t==null?void 0:t.BoxManager)||mr;case"AttributesDelegate":return(t==null?void 0:t.AttributesDelegate)||yr;case"CursorManager":return(t==null?void 0:t.CursorManager)||wr;case"AppProxy":return(t==null?void 0:t.AppProxy)||xr;case"AppContext":return(t==null?void 0:t.AppContext)||fr;case"TeleBoxManager":return(t==null?void 0:t.TeleBoxManager)||gr;case"TeleBoxCollector":return(t==null?void 0:t.TeleBoxCollector)||cn;default:return e}return e}var xe=(e=>(e.Apps="apps",e.Focus="focus",e.State="state",e.BoxState="boxState",e.MainViewCamera="mainViewCamera",e.MainViewSize="mainViewSize",e.Broadcaster="broadcaster",e.Cursors="cursors",e.Position="position",e.CursorState="cursorState",e.FullPath="fullPath",e.Registered="registered",e.IframeBridge="iframeBridge",e.BoxesStatus="boxesStatus",e.LastNotMinimizedBoxesStatus="lastNotMinimizedBoxesStatus",e))(xe||{});class yr{constructor(t){this.context=t,this.setAppFocus=(i,n)=>{n?this.context.safeSetAttributes({focus:i}):this.context.safeSetAttributes({focus:void 0})}}setContext(t){this.context=t}get attributes(){return this.context.getAttributes()}apps(){return E.get(this.attributes,["apps"])}get focus(){return E.get(this.attributes,["focus"])}getAppAttributes(t){return E.get(this.apps(),[t])}getAppState(t){return E.get(this.apps(),[t,"state"])}getMaximized(){return E.get(this.attributes,["maximized"])}getMinimized(){return E.get(this.attributes,["minimized"])}getBoxesStatus(){return E.get(this.attributes,["boxesStatus"])}getBoxStatus(t){return E.get(this.attributes,["boxesStatus",t])}setBoxStatus(t,i){this.attributes.boxesStatus||this.context.safeSetAttributes({boxesStatus:{}}),this.getBoxStatus(t)!==i&&this.context.safeUpdateAttributes(["boxesStatus",t],i)}getLastNotMinimizedBoxesStatus(){return E.get(this.attributes,["lastNotMinimizedBoxesStatus"])}getLastNotMinimizedBoxStatus(t){return E.get(this.attributes,["lastNotMinimizedBoxesStatus",t])}setLastNotMinimizedBoxStatus(t,i){this.attributes.lastNotMinimizedBoxesStatus||this.context.safeSetAttributes({lastNotMinimizedBoxesStatus:{}}),this.getLastNotMinimizedBoxStatus(t)!==i&&this.context.safeUpdateAttributes(["lastNotMinimizedBoxesStatus",t],i)}setupAppAttributes(t,i,n){this.attributes.apps||this.context.safeSetAttributes({apps:{}});const s=["scenePath","title"];n||s.push("scenes");const o=E.pick(t.options,s),a={kind:t.kind,options:o,isDynamicPPT:n,forceTop:t.forceTop,forceNormal:t.forceNormal,isDragContent:t.isDragContent};typeof t.src=="string"&&(a.src=t.src),a.createdAt=Date.now(),this.context.safeUpdateAttributes(["apps",i],a),this.context.safeUpdateAttributes(["apps",i,"state"],{[Be.Size]:{},[Be.Position]:{},[Be.SceneIndex]:0})}updateAppState(t,i,n){E.get(this.attributes,["apps",t,"state"])&&this.context.safeUpdateAttributes(["apps",t,"state",i],n)}cleanAppAttributes(t){this.context.safeUpdateAttributes(["apps",t],void 0),this.context.safeSetAttributes({[t]:void 0}),this.attributes.focus===t&&this.cleanFocus()}cleanFocus(){this.context.safeSetAttributes({focus:void 0})}getAppSceneIndex(t){var i;return(i=this.getAppState(t))==null?void 0:i[Be.SceneIndex]}getAppScenePath(t){var i,n;return(n=(i=this.getAppAttributes(t))==null?void 0:i.options)==null?void 0:n.scenePath}getMainViewScenePath(){return this.attributes._mainScenePath}getMainViewSceneIndex(){return this.attributes._mainSceneIndex}getBoxState(){return this.attributes.boxState}setMainViewScenePath(t){this.context.safeSetAttributes({_mainScenePath:t})}setMainViewSceneIndex(t){this.context.safeSetAttributes({_mainSceneIndex:t})}getMainViewCamera(){return E.get(this.attributes,["mainViewCamera"])}getMainViewSize(){return E.get(this.attributes,["mainViewSize"])}setMainViewCamera(t){this.context.safeSetAttributes({mainViewCamera:{...t}})}setMainViewSize(t){t.width===0||t.height===0||this.context.safeSetAttributes({mainViewSize:{...t}})}setMainViewCameraAndSize(t,i){i.width===0||i.height===0||this.context.safeSetAttributes({mainViewCamera:{...t},mainViewSize:{...i}})}updateCursor(t,i){E.get(this.attributes,["cursors"])||this.context.safeUpdateAttributes(["cursors"],{}),E.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"position"],i)}updateCursorState(t,i){E.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"cursorState"],i)}getCursorState(t){return E.get(this.attributes,["cursors",t,"cursorState"])}cleanCursor(t){this.context.safeUpdateAttributes(["cursors",t],void 0)}setMainViewFocusPath(t){const i=this.getMainViewScenePath();i&&xi(t,i)}getIframeBridge(){return E.get(this.attributes,["iframeBridge"])}setIframeBridge(t){if(E.isObject(t)){const i=this.getIframeBridge();for(const n in t){const r=t[n];i[n]!==r&&this.context.safeUpdateAttributes(["iframeBridge",n],r)}}}}yr.kind="AttributesDelegate";const hw=(e,t={getAttributes:()=>{throw new Error("getAttributes not implemented")},safeSetAttributes:()=>{throw new Error("safeSetAttributes not implemented")},safeUpdateAttributes:()=>{throw new Error("safeUpdateAttributes not implemented")}})=>{const i=At(yr,e);return new i(t)},Cl=(e,t)=>{let i=0;const n=t.length-1;return e===t.index?e===n?i=e-1:i=t.index+1:i=t.index,i},lt=new Ti.default,Td=class{constructor(e,t,i,n){var r;this.params=e,this.manager=t,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.store=this.manager.store,this.status="normal",this.getAppInitState=s=>{var y,S,A,k;const o=this.store.getAppState(s);if(!o)return;const a=o==null?void 0:o[Be.Position],l=this.store.focus,u=o==null?void 0:o[Be.Size],c=o==null?void 0:o[Be.SceneIndex],h=(y=this.attributes)==null?void 0:y.maximized,m=(S=this.attributes)==null?void 0:S.minimized,v=(A=this.store.getBoxStatus(s))!=null?A:void 0,w=(k=this.store.getLastNotMinimizedBoxStatus(s))!=null?k:void 0,{forceTop:x,forceNormal:d,isDragContent:f}=this.store.getAppAttributes(s),g=o==null?void 0:o.zIndex;let p={maximized:h,minimized:m,zIndex:g};return a&&(p={...p,id:s,x:a.x,y:a.y}),l===s&&(p={...p,focus:!0}),u&&(p={...p,width:u.width,height:u.height}),c&&(p={...p,sceneIndex:c}),v&&(p={...p,boxStatus:v}),w&&(p={...p,lastNotMinimizedBoxStatus:w}),x&&(p={...p,forceTop:x}),d&&(p={...p,forceNormal:d}),f&&(p={...p,isDragContent:f}),p},this.appAttributesUpdateListener=s=>{this.manager.refresher.add(s,()=>I.autorun(()=>{const o=this.manager.attributes[s];o&&this.appEmitter.emit("attributesUpdate",o)})),this.manager.refresher.add(this.stateKey,()=>I.autorun(()=>{var a,l,u,c;const o=(a=this.appAttributes)==null?void 0:a.state;(o==null?void 0:o.zIndex)>0&&o.zIndex!==((l=this.box)==null?void 0:l.zIndex)&&((u=this.boxManager)==null||u.setZIndex(s,o.zIndex),(c=this.boxManager)==null||c.focusBox({appId:s}))})),this.manager.refresher.add(`${s}-fullPath`,()=>I.autorun(()=>{var a;const o=(a=this.appAttributes)==null?void 0:a.fullPath;this.setFocusScenePathHandler(o),this._prevFullPath!==o&&(this.notifyPageStateChange(),this._prevFullPath=o)}))},this.setFocusScenePathHandler=E.debounce(s=>{var o;this.view&&s&&s!==((o=this.view)==null?void 0:o.focusScenePath)&&(xi(this.view,s),G.emit("onAppScenePathChange",{appId:this.id,view:this.view}))},50),this.notifyPageStateChange=E.debounce(()=>{this.appEmitter.emit("pageStateChange",this.pageState)},50),this.notifyBoxStatusChange=s=>{this.appEmitter.emit("boxStatusChange",{appId:this.id,status:s})},this.kind=e.kind,this.id=i,this.stateKey=`${this.id}_state`,this.appProxies.set(this.id,this),this.appEmitter=new Ti.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=n,this.initScenes(),(r=this.params.options)!=null&&r.scenePath&&this.createView(),this._pageState=new wm({displayer:this.manager.displayer,scenePath:this.scenePath,view:this.view,notifyPageStateChange:this.notifyPageStateChange})}initScenes(){var t;const e=this.params.options;e&&(this.scenePath=e.scenePath,((t=this.appAttributes)==null?void 0:t.isDynamicPPT)&&this.scenePath?this.scenes=en(this.manager.displayer)[this.scenePath]:this.scenes=e.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get viewIndex(){var e;return(e=this.view)==null?void 0:e.focusSceneIndex}get isWritable(){var e;return this.manager.canOperate&&!((e=this.box)!=null&&e.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}get Logger(){return this.manager.windowManger.Logger}getFullScenePath(){if(this.scenePath)return E.get(this.appAttributes,[xe.FullPath])||this.getFullScenePathFromScenes()}getFullScenePathFromScenes(){const e=E.get(this.appAttributes,["state","SceneIndex"],0),t=am(this.manager.room,this.scenePath,e);return t&&this.setFullPath(t),t}setFullPath(e){this.manager.safeUpdateAttributes(["apps",this.id,xe.FullPath],e)}async baseInsertApp(e=!1,t=N.Normal){var s;const i=this.params;if(!i.kind)throw this.Logger&&this.Logger.error("[WindowManager]: kind require"),new Error("[WindowManager]: kind require");const n=await((s=Te.appClasses.get(i.kind))==null?void 0:s()),r=Te.registered.get(i.kind);if(n)await this.setupApp(this.id,e,n,i.options,r==null?void 0:r.appOptions,this.manager.useBoxesStatus?t:void 0,i.forceTop,i.forceNormal,i.isDragContent);else throw this.Logger&&this.Logger.error(`[WindowManager]: app load failed ${i.kind} ${i.src}`),new Error(`[WindowManager]: app load failed ${i.kind} ${i.src}`);return _.emit("updateManagerRect"),{appId:this.id,app:n}}get box(){var e;return(e=this.boxManager)==null?void 0:e.getBox(this.id)}async setupApp(e,t,i,n,r,s,o,a,l){var h;if(et("setupApp",e,i,n,s,o,a,l),!this.boxManager)throw new Xh;const u=At(fr,Q.extendClass),c=new u(this.manager,this.boxManager,e,this,r);this.appContext=c;try{_.once(`${e}${se.WindowCreated}`).then(async()=>{var w;let m;t||(m=this.getAppInitState(e),(w=this.boxManager)==null||w.updateBoxState(m)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(e),this.setViewFocusScenePath();let v;this.manager.isReplay&&(v=this.manager.mainView.scenePath),setTimeout(async()=>{this.Logger&&this.Logger.info(`[WindowManager]: setup app ${this.kind}, appId: ${e}`);const x=await i.setup(c);this.appResult=x,Te.notifyApp(this.kind,"created",{appId:e,result:x}),this.afterSetupApp(m),this.fixMobileSize(),v&&this.manager.mainViewProxy.setFocusScenePath(v),G.emit("onAppSetup",e)},Wh)}),(h=this.boxManager)==null||h.createBox({appId:e,app:i,options:n,canOperate:this.manager.canOperate,smartPosition:this.isAddApp,boxStatus:s,forceTop:o,forceNormal:a,isDragContent:l}),this.isAddApp&&this.box&&(s&&this.store.setBoxStatus(e,s),this.store.updateAppState(e,Be.ZIndex,this.box.zIndex),this.store.updateAppState(e,Be.Size,{width:this.box.intrinsicWidth,height:this.box.intrinsicHeight}),this.boxManager.focusBox({appId:e},!1))}catch(m){throw this.Logger&&this.Logger.error(`[WindowManager]: app setup error: ${m.message}`),new Error(`[WindowManager]: app setup error: ${m.message}`)}}fixMobileSize(){var t,i;const e=(t=this.boxManager)==null?void 0:t.getBox(this.id);e&&((i=this.boxManager)==null||i.resizeBox({appId:this.id,width:e.intrinsicWidth+.001,height:e.intrinsicHeight+.001,skipUpdate:!0}))}afterSetupApp(e){var t;e&&(!(e!=null&&e.x)||!e.y)&&((t=this.boxManager)==null||t.setBoxInitState(this.id))}async onSeek(e){var i;this.appEmitter.emit("seek",e).catch(n=>{console.log(`[WindowManager]: emit seek error: ${n.message}`)});const t=this.getAppInitState(this.id);(i=this.boxManager)==null||i.updateBoxState(t)}async onReconnected(){var s;if(!Boolean(this.manager.attributes.apps[this.id])){await this.destroy(!0,!1,!0);return}this.appEmitter.emit("reconnected",void 0);const t=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const i=this.params,n=At(Td,Q.extendClass);await new n(i,this.manager,this.id,this.isAddApp).baseInsertApp(!0,t==null?void 0:t.boxStatus),(s=this.boxManager)==null||s.updateBoxState(t)}async onRemoveScene(e){if(this.scenePath&&e.startsWith(this.scenePath+"/")){let t=this.pageState.index,i=this._pageState.getFullPath(t);i||(t=0,i=this._pageState.getFullPath(t)),i&&this.setFullPath(i),this.setViewFocusScenePath(),this.view&&(this.view.focusSceneIndex=t)}}emitAppSceneStateChange(e){this.appEmitter.emit("sceneStateChange",e)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(e){return(t,i)=>{var n,r,s,o;if(!!this.manager.canOperate)switch(t){case"setBoxSize":{(n=this.boxManager)==null||n.resizeBox({appId:e,width:i.width,height:i.height,skipUpdate:!1});break}case"setBoxMinSize":{(r=this.boxManager)==null||r.setBoxMinSize({appId:e,minWidth:i.minwidth,minHeight:i.minheight});break}case"setBoxTitle":{(s=this.boxManager)==null||s.setBoxTitle({appId:e,title:i.title});break}case $h.destroy:{if(this.status==="destroyed")return;this.destroy(!0,!1,!0,i==null?void 0:i.error),i!=null&&i.error&&console.error(i==null?void 0:i.error);break}case"focus":{(o=this.boxManager)==null||o.focusBox({appId:this.id}),lt.emit("focus",{appId:this.id});break}}}}setScenePath(){if(!this.manager.canOperate)return;const e=this.getFullScenePath();this.manager.room&&e&&this.view&&ta(this.manager.room,e)}setViewFocusScenePath(){const e=this.getFullScenePath();return e&&this.view&&xi(this.view,e),e}async createView(){const e=await this.viewManager.createView(this.id);return this.setViewFocusScenePath(),e}get pageState(){return this._pageState.toObject()}async removeSceneByIndex(e){const t=this._pageState.getFullPath(e);if(t){const i=Cl(e,this.pageState);return this.setSceneIndexWithoutSync(i),this.manager.dispatchInternalEvent(se.SetAppFocusIndex,{type:"app",appID:this.id,index:i}),setTimeout(()=>{ia(this.manager.room,t,e)},100),!0}else return!1}setSceneIndexWithoutSync(e){this.view&&(this.view.focusSceneIndex=e)}setSceneIndex(e){if(this.view){this.view.focusSceneIndex=e;const t=this._pageState.getFullPath(e);t&&this.setFullPath(t)}}async destroy(e,t,i,n){var r;if(this.status!=="destroyed"){this.status="destroyed";try{await Te.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:n})}catch(s){this.Logger&&this.Logger.error(`[WindowManager]: notifyApp error: ${s.message}`),console.error("[WindowManager]: notifyApp error",s.message,s.stack)}this.appEmitter.clearListeners(),_.emit(`destroy-${this.id}`,{error:n}),e&&((r=this.boxManager)==null||r.closeBox(this.id,i)),t&&(this.store.cleanAppAttributes(this.id),this.scenePath&&ia(this.manager.room,this.scenePath)),this.appProxies.delete(this.id),this._pageState.destroy(),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),this.manager.refresher.remove(this.id),this.manager.refresher.remove(this.stateKey),this.manager.refresher.remove(`${this.id}-fullPath`),this._prevFullPath=void 0,this.Logger&&this.Logger.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`)}}close(){return this.destroy(!0,!0,!1)}};let xr=Td;xr.kind="AppProxy";class dw{constructor(t){this.displayer=t,this.views=new Map}createView(t){const i=Ad(this.displayer);return this.views.set(t,i),i}getView(t){return this.views.get(t)}destroyView(t){const i=this.views.get(t);if(i){try{i.release()}catch{}this.views.delete(t)}}setViewScenePath(t,i){const n=this.views.get(t);n&&(n.focusScenePath=i)}destroy(){this.views.forEach(t=>{try{t.release()}catch{}}),this.views.clear()}}const Ad=e=>{const t=e.views.createView();return fw(t),t},fw=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class pw{constructor(t){this.manager=t,this.polling=!1,this.started=!1,this.mainViewIsAddListener=!1,this.isForcingMainViewDivElement=!1,this.wrapperRectWorkaroundFrame=0,this.store=this.manager.store,this.viewMode=this.manager.windowManger.viewMode,this.sideEffectManager=new dr,this.playgroundSizeChangeListenerLocalConsole=new zn("playgroundSizeChangeListener",100),this.sizeUpdatedLocalConsole=new zn("sizeUpdated",100),this.cameraUpdatedLocalConsole=new zn("cameraUpdated",100),this.cameraReactionLocalConsole=new zn("cameraReaction",100),this.syncCamera=()=>{if(!this.polling||this.viewMode!==I.ViewMode.Broadcaster)return;const{mainViewCamera:n}=this;n&&n.id!==this.manager.uid&&this.moveCameraSizeByAttributes()},this.startListenWritableChange=()=>{this.sideEffectManager.add(()=>_.on("writableChange",n=>{n&&this.ensureCameraAndSize(),this.manager.room&&this.syncMainView(this.manager.room)}))},this.onWrapperRectChange=n=>{this.pendingWrapperRectChange=n,this.wrapperRectWorkaroundFrame&&cancelAnimationFrame(this.wrapperRectWorkaroundFrame),this.wrapperRectWorkaroundFrame=requestAnimationFrame(this.runWrapperRectWorkaround)},this.runWrapperRectWorkaround=()=>{this.wrapperRectWorkaroundFrame=0;const n=this.pendingWrapperRectChange,r=this.mainView.divElement;if(this.pendingWrapperRectChange=void 0,!n||!r)return;const s=r.getBoundingClientRect(),o={width:s.width,height:s.height},a=Math.abs(n.width-o.width)<=.5&&Math.abs(n.height-o.height)<=.5,l=Math.abs(this.mainView.size.width-o.width)>.5||Math.abs(this.mainView.size.height-o.height)>.5;a&&l&&this.forceSyncMainViewDivElement(`wrapperRectChange:${n.origin||"unknown"}`,o,r)},this.addCameraReaction=()=>{this.manager.refresher.add(xe.MainViewCamera,this.cameraReaction)},this.cameraReaction=()=>I.reaction(()=>this.mainViewCamera,n=>{n&&n.id!==this.manager.uid&&(this.moveCameraToContian(this.mainViewSize),this.moveCamera(n),this.cameraReactionLocalConsole.log(`camera: ${JSON.stringify(n)}, current size: ${JSON.stringify(this.mainViewSize)}`))},{fireImmediately:!0}),this.sizeChangeHandler=E.debounce(n=>{n&&(this.moveCameraToContian(n),this.moveCamera(this.mainViewCamera),console.log("[window-manager] sizeChangeHandler current size and camera"+JSON.stringify(n)+JSON.stringify(this.mainViewCamera)+JSON.stringify(this.mainView.camera)+JSON.stringify(this.mainView.size))),this.ensureMainViewSize()},30),this.onUpdateContainerSizeRatio=()=>{const n=this.store.getMainViewSize();console.log("[window-manager] onUpdateContainerSizeRatio "+JSON.stringify(n)),this.sizeChangeHandler(n)},this.onCameraUpdatedByDevice=n=>{this.viewMode!==I.ViewMode.Follower&&(this.store.setMainViewCamera({...n,id:this.manager.uid}),E.isEqual(this.mainViewSize,{...this.mainView.size,id:this.manager.uid})||this.setMainViewSize(this.view.size))},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=E.debounce(n=>{this.store.setMainViewSize({...n,id:this.manager.uid})},50),this._syncMainViewTimer=0,this.handleCameraOrSizeUpdated=()=>{G.emit("cameraStateChange",this.cameraState),this.manager.room&&this.manager.room.syncMainView&&(clearTimeout(this._syncMainViewTimer),this._syncMainViewTimer=setTimeout(this.syncMainView,100,this.manager.room)),this.ensureMainViewSize()},this.onCameraUpdated=n=>{this.cameraUpdatedLocalConsole.log(JSON.stringify(n)),this.handleCameraOrSizeUpdated()},this.onSizeUpdated=n=>{this.sizeUpdatedLocalConsole.log(JSON.stringify(n)),this.handleCameraOrSizeUpdated()},this.syncMainView=n=>{n.isWritable&&n.syncMainView(this.mainView)},this.setViewMode=n=>{this.viewMode=n},this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),_.once("mainViewMounted").then(()=>{this.addMainViewListener(),this.start(),this.ensureCameraAndSize(),this.startListenWritableChange()});const i=()=>{var n,r,s,o,a,l,u,c;this.playgroundSizeChangeListenerLocalConsole.log(JSON.stringify(this.mainView.camera),JSON.stringify(this.mainView.size),JSON.stringify(this.mainViewSize),JSON.stringify(this.mainViewCamera),window.outerHeight,window.outerWidth,(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:"null",(o=(s=window.visualViewport)==null?void 0:s.height)!=null?o:"null",(l=(a=window.visualViewport)==null?void 0:a.offsetLeft)!=null?l:"null",(c=(u=window.visualViewport)==null?void 0:u.offsetTop)!=null?c:"null"),this.sizeChangeHandler(this.mainViewSize)};this.sideEffectManager.add(()=>_.on("playgroundSizeChange",i)),this.sideEffectManager.add(()=>_.on("containerSizeRatioUpdate",this.onUpdateContainerSizeRatio)),this.sideEffectManager.add(()=>_.on("wrapperRectChange",this.onWrapperRectChange)),this.sideEffectManager.add(()=>_.on("startReconnect",()=>{this.didRelease||this.mainView.release()})),this.sideEffectManager.setInterval(this.syncCamera,1500)}ensureCameraAndSize(){this.viewMode===I.ViewMode.Broadcaster&&(!this.mainViewCamera||!this.mainViewSize)&&(this.manager.dispatchInternalEvent(se.InitMainViewCamera),this.setCameraAndSize())}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}get didRelease(){return E.get(this.view,["didRelease"])}moveCameraSizeByAttributes(){this.moveCameraToContian(this.mainViewSize),this.moveCamera(this.mainViewCamera)}forceSyncMainViewDivElement(t,i,n){var a,l;const{width:r,height:s}=this.mainView.size;let o=n;if(!(Math.abs(r-i.width)<=.5&&Math.abs(s-i.height)<=.5)){if(this.isForcingMainViewDivElement){console.log("[window-manager] skipForceSyncMainViewDivElement "+JSON.stringify({reason:t,observedSize:i,viewSize:this.mainView.size}));return}this.isForcingMainViewDivElement=!0;try{const c=this.mainView.screen,h=c==null?void 0:c.resizeObserver;typeof(c==null?void 0:c.refreshSize)=="function"&&(console.log("[window-manager] forceSyncMainViewDivElement observerReset "+JSON.stringify({reason:t,viewSize:this.mainView.size,observedSize:i})),(a=h==null?void 0:h.disconnect)==null||a.call(h),c.refreshSize(i.width,i.height),(l=h==null?void 0:h.observe)==null||l.call(h,n))}finally{queueMicrotask(()=>{const u=o.getBoundingClientRect();console.log("[window-manager] forceSyncMainViewDivElementResult "+JSON.stringify({reason:t,viewSize:this.mainView.size,rect:{width:u.width,height:u.height}})),this.isForcingMainViewDivElement=!1})}}}start(){console.log("[window-manager] start attributes size:"+JSON.stringify(this.mainViewSize)),this.sizeChangeHandler(this.mainViewSize),!this.started&&(this.addCameraListener(),this.addCameraReaction(),this.manager.room&&this.syncMainView(this.manager.room),this.started=!0,this.mainView.focusScenePath&&this.manager.windowManger.onMainViewScenePathChangeHandler(this.mainView.focusScenePath),console.log("[window-manager] start end mainView size:"+JSON.stringify(this.mainView.size)))}setCameraAndSize(){const t={...this.mainView.camera,id:this.manager.uid},i={...this.mainView.size,id:this.manager.uid};this.store.setMainViewCameraAndSize(t,i)}get view(){return this.mainView}get cameraState(){return{...this.view.camera,...this.view.size}}createMainView(){const t=Ad(this.manager.displayer),i=this.store.getMainViewScenePath();return i&&xi(t,i),t}onReconnect(){if(this.didRelease)this.rebind();else{const t=this.store.getMainViewScenePath();this.setFocusScenePath(t)}}setFocusScenePath(t){if(t)return xi(this.view,t)}rebind(){const t=this.mainView.divElement,i=this.mainView.disableCameraTransform;this.stop(),this.didRelease||this.mainView.release(),this.removeMainViewListener(),this.mainView=this.createMainView(),this.mainView.disableCameraTransform=i,this.mainView.divElement=t,this.addMainViewListener(),this.start(),G.emit("onMainViewRebind",this.mainView)}addMainViewListener(){this.mainViewIsAddListener||this.view.divElement&&(this.view.divElement.addEventListener("click",this.mainViewClickListener),this.view.divElement.addEventListener("touchend",this.mainViewClickListener),this.mainViewIsAddListener=!0)}removeMainViewListener(){this.view.divElement&&(this.view.divElement.removeEventListener("click",this.mainViewClickListener),this.view.divElement.removeEventListener("touchend",this.mainViewClickListener)),this.mainViewIsAddListener=!1}async mainViewClickHandler(){var t;!this.manager.canOperate||(this.store.cleanFocus(),(t=this.manager.boxManager)==null||t.blurAllBox())}addCameraListener(){this.view.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.on("onCameraUpdated",this.onCameraUpdated),this.view.callbacks.on("onSizeUpdated",this.onSizeUpdated)}removeCameraListener(){this.view.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.off("onCameraUpdated",this.onCameraUpdated),this.view.callbacks.off("onSizeUpdated",this.onSizeUpdated)}ensureMainViewSize(){(!this.mainViewSize||this.mainViewSize.width===0||this.mainViewSize.height===0)&&this.mainView.size.width>0&&this.mainView.size.height>0&&this.setMainViewSize(this.mainView.size)}moveCameraToContian(t){E.isEmpty(t)||(this.view.moveCameraToContain({width:t.width,height:t.height,originX:-t.width/2,originY:-t.height/2,animationMode:I.AnimationMode.Immediately}),this.scale=this.view.camera.scale)}moveCamera(t){if(!E.isEmpty(t)){if(E.isEqual(t,this.view.camera))return;const{centerX:i,centerY:n,scale:r}=t,s=r*(this.scale||1);this.view.moveCamera({centerX:i,centerY:n,scale:s,animationMode:I.AnimationMode.Immediately})}}stop(){this.removeCameraListener(),this.manager.refresher.remove(xe.MainViewCamera),this.manager.refresher.remove(xe.MainViewSize),this.started=!1}destroy(){console.log("[window-manager] destroy "),this.wrapperRectWorkaroundFrame&&(cancelAnimationFrame(this.wrapperRectWorkaroundFrame),this.wrapperRectWorkaroundFrame=0),this.playgroundSizeChangeListenerLocalConsole.destroy(),this.sizeUpdatedLocalConsole.destroy(),this.cameraUpdatedLocalConsole.destroy(),this.cameraReactionLocalConsole.destroy(),this.removeMainViewListener(),this.stop(),this.sideEffectManager.flushAll()}}class gw{constructor(t){this.context=t,this.addRedoUndoListeners=i=>{if(i===void 0)this.addViewCallbacks(this.context.mainView(),this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate);else{const n=this.context.getAppProxy(i);n&&n.view&&this.addViewCallbacks(n.view,this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate)}},this.addViewCallbacks=(i,n,r)=>{n(i.canRedoSteps),r(i.canUndoSteps),i.callbacks.on("onCanRedoStepsUpdate",n),i.callbacks.on("onCanUndoStepsUpdate",r)},this.disposeViewCallbacks=i=>{i.callbacks.off("onCanRedoStepsUpdate",this.onCanRedoStepsUpdate),i.callbacks.off("onCanUndoStepsUpdate",this.onCanUndoStepsUpdate)},this.onCanRedoStepsUpdate=i=>{G.emit("canRedoStepsChange",i)},this.onCanUndoStepsUpdate=i=>{G.emit("canUndoStepsChange",i)},this.disposePrevFocusViewRedoUndoListeners=i=>{let n;if(i===void 0)n=this.context.mainView();else{const r=this.context.getAppProxy(i);r&&r.view&&(n=r.view)}n&&this.disposeViewCallbacks(n)},_.on("focusedChange",i=>{this.disposePrevFocusViewRedoUndoListeners(i.prev),setTimeout(()=>{this.addRedoUndoListeners(i.focused)},0)}),_.on("rootDirRemoved",()=>{this.disposePrevFocusViewRedoUndoListeners(t.focus()),this.addRedoUndoListeners(t.focus())}),this.addRedoUndoListeners(t.focus())}destroy(){this.disposePrevFocusViewRedoUndoListeners(this.context.focus())}}class Sr{constructor(t){this.windowManger=t,this.appProxies=new Map,this.appStatus=new Map,this.isReplay=this.windowManger.isReplay,this.mainViewScenesLength=0,this.callbacksNode=null,this.appCreateQueue=new Fg,this.sideEffectManager=new dr,this.sceneState=null,this.rootDirRemoving=!1,this._useBoxesStatus=!1,this.onRemoveScenes=async i=>{var r,s;const{scenePath:n}=i;if(n===ze){console.log("[window-manager] onRemoveScenes ROOT_DIR"),await this.onRootDirRemoved(),this.dispatchInternalEvent(se.RootDirRemoved);return}if(dm(n)){let o=this.mainView.focusSceneIndex||0,a=(r=this.callbacksNode)==null?void 0:r.scenes[o];a||(o=0,a=(s=this.callbacksNode)==null?void 0:s.scenes[o]),a&&(console.log(`[window-manager] onRemoveScenes setMainViewScenePath ${ze}${a}`),this.setMainViewScenePath(`${ze}${a}`)),await this.setMainViewSceneIndex(o)}else this.appProxies.forEach(o=>{o.onRemoveScene(n)})},this.onReadonlyChanged=()=>{this.appProxies.forEach(i=>{i.emitAppIsWritableChange()})},this.onPlayerSeekStart=async()=>{await this.closeAll()},this.onPlayerSeekDone=async i=>{await this._attributesUpdateCallback(this.attributes.apps),this.appProxies.forEach(n=>{n.onSeek(i)})},this.createRootDirScenesCallback=()=>{let i=!1;this.callbacksNode&&(this.callbacksNode.dispose(),i=!0),this.callbacksNode=this.displayer.createScenesCallback(ze,{onAddScene:this.onSceneChange,onRemoveScene:async(n,r)=>{await this.onSceneChange(n),_.emit("rootDirSceneRemoved",r)}}),this.callbacksNode&&(this.updateSceneState(this.callbacksNode),this.mainViewScenesLength=this.callbacksNode.scenes.length,i&&this.emitMainViewScenesChange(this.callbacksNode.scenes.length))},this.removeSceneByIndex=async i=>{var s;const n=Cl(i,this.windowManger.pageState);this.setSceneIndexWithoutSync(n),this.dispatchInternalEvent(se.SetAppFocusIndex,{type:"main",index:n});const r=(s=this.callbacksNode)==null?void 0:s.scenes[i];return setTimeout(()=>{r&&ia(this.room,`${ze}${r}`,i)},100),new Promise((o,a)=>{_.once("rootDirSceneRemoved").then(l=>{l===r&&o(!0)}).catch(l=>{console.log(`[WindowManager]: removePage error: ${l}`),a(!1)})})},this.setSceneIndexWithoutSync=i=>{var r;const n=(r=this.callbacksNode)==null?void 0:r.scenes[i];n&&this.mainViewProxy.setFocusScenePath(`${ze}${n}`)},this.onSceneChange=i=>(this.mainViewScenesLength=i.scenes.length,this.updateSceneState(i),this.emitMainViewScenesChange(this.mainViewScenesLength)),this.emitMainViewScenesChange=i=>Promise.all([G.emit("mainViewScenesLengthChange",i),_.emit("changePageState")]),this.updateSceneState=i=>{const n=this.store.getMainViewSceneIndex()||0;let r=i.scenes[n];r||(r=i.scenes[this.mainView.focusSceneIndex||0]),this.sceneState={scenePath:`${ze}${r}`,contextPath:i.path,index:n,scenes:i.scenes.map(s=>({name:s})),sceneName:r},G.emit("sceneStateChange",this.sceneState)},this.onBoxMove=i=>{this.dispatchInternalEvent(se.AppMove,i),this.store.updateAppState(i.appId,Be.Position,{x:i.x,y:i.y}),G.emit("onBoxMove",i)},this.onBoxResize=i=>{i.width&&i.height&&(this.dispatchInternalEvent(se.AppResize,i),this.store.updateAppState(i.appId,Be.Size,{width:i.width,height:i.height}),G.emit("onBoxResize",i))},this.onBoxFocus=i=>{this.windowManger.safeSetAttributes({focus:i.appId}),G.emit("onBoxFocus",i)},this.onBoxBlurred=i=>{this.attributes.focus===i.appId&&(this.windowManger.safeSetAttributes({focus:void 0}),G.emit("onBoxBlurred",i))},this.onBoxClose=i=>{const n=this.appProxies.get(i.appId);n&&n.destroy(!1,!0,!0,i.error),G.emit("onBoxClose",i)},this.onBoxStateChange=i=>{this.dispatchInternalEvent(se.AppBoxStateChange,i),G.emit("onBoxStateChange",i)},this.notifyBoxesStatusChange=E.debounce(()=>{var n;(n=this.boxManager)==null||n.setBoxesStatus(this.attributes.boxesStatus);const i=Object.entries(this.attributes.boxesStatus);i.length>0&&i.forEach(([r,s])=>{const o=this.appProxies.get(r);o&&o.notifyBoxStatusChange(s)})},100),this.addBoxesStatusChangeListener=()=>{this.refresher.add("boxesStatus",()=>kn(()=>this.attributes.boxesStatus,()=>{this.notifyBoxesStatusChange()})),this.refresher.add("lastNotMinimizedBoxesStatus",()=>kn(()=>this.attributes.lastNotMinimizedBoxesStatus,()=>{var i;(i=this.boxManager)==null||i.setLastNotMinimizedBoxesStatus(this.attributes.lastNotMinimizedBoxesStatus)}))},this.addAppsChangeListener=()=>{this.refresher.add("apps",()=>kn(()=>this.attributes.apps,()=>{this.attributesUpdateCallback(this.attributes.apps)}))},this.addAppCloseListener=()=>{this.refresher.add("appsClose",()=>kn(()=>this.attributes.apps,i=>{i.some(n=>n.kind===I.UpdateEventKind.Removed)&&this.onAppDelete(this.attributes.apps)}))},this.onMainViewIndexChange=i=>{i!==void 0&&this._prevSceneIndex!==i&&(G.emit("mainViewSceneIndexChange",i),_.emit("changePageState"),this.callbacksNode&&this.updateSceneState(this.callbacksNode),this._prevSceneIndex=i)},this.onFocusChange=i=>{var n;this._prevFocused!==i&&(G.emit("focusedChange",i),_.emit("focusedChange",{focused:i,prev:this._prevFocused}),this._prevFocused=i,i!==void 0&&((n=this.boxManager)==null||n.focusBox({appId:i}),setTimeout(()=>{const r=this.appProxies.get(i);r&&Te.notifyApp(r.kind,"focus",{appId:i})},0)))},this.attributesUpdateCallback=E.debounce(i=>this._attributesUpdateCallback(i),100),this._appIds=[],this.onRegisteredChange=i=>{!i||Object.entries(i).forEach(([n,r])=>{Te.appClasses.has(n)||Te.register({kind:n,src:r.src,name:r.name})})},this.onMinimized=i=>{var n,r;((n=this.boxManager)==null?void 0:n.minimized)!==i&&(i===!0&&((r=this.boxManager)==null||r.blurAllBox()),setTimeout(()=>{var s;(s=this.boxManager)==null||s.setMinimized(Boolean(i))},0))},this.onAppDelete=async i=>{const n=Object.keys(i);for(const[r,s]of this.appProxies.entries())n.includes(r)||await s.destroy(!0,!1,!0)},this.closeAll=async()=>{for(const[i,n]of this.appProxies.entries())await n.destroy(!0,!1,!0)},this.displayerStateListener=i=>{this.appProxies.forEach(n=>{n.appEmitter.emit("roomStateChange",i)}),_.emit("observerIdChange",this.displayer.observerId)},this.displayerWritableListener=i=>{var s,o;const n=!i,r=this.windowManger.readonly===void 0||this.windowManger.readonly===!1;this.windowManger.readonly===void 0?(s=this.boxManager)==null||s.setReadonly(i):(o=this.boxManager)==null||o.setReadonly(!(n&&r)),this.appProxies.forEach(a=>{a.emitAppIsWritableChange()}),_.emit("writableChange",n)},this.updateSceneIndex=()=>{const i=this.store.getMainViewScenePath(),n=Co(i),r=en(this.displayer)[n];if(r.length){const s=i.replace(n,"").replace("/",""),o=r.findIndex(a=>a.name===s);E.isInteger(o)&&o>=0&&this.safeSetAttributes({_mainSceneIndex:o})}},this.updateRootDirRemoving=i=>{this.rootDirRemoving=i},this.displayer=t.displayer,this.store=hw(Q.extendClass,{getAttributes:()=>this.attributes,safeSetAttributes:i=>this.safeSetAttributes(i),safeUpdateAttributes:(i,n)=>this.safeUpdateAttributes(i,n)}),this.mainViewProxy=new pw(this),this.viewManager=new dw(this.displayer),this.appListeners=new fm(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=Ng,this.refresher.setRoom(this.room),this.refresher.setContext({emitter:_}),this.sideEffectManager.addDisposer(()=>{var i,n;this.appCreateQueue.destroy(),this.mainViewProxy.destroy(),this.refresher.destroy(),this.viewManager.destroy(),(i=this.boxManager)==null||i.destroy(),(n=this.callbacksNode)==null||n.dispose()}),_.once("onCreated").then(()=>this.onCreated()),_.on("onReconnected",()=>this.onReconnected()),I.isPlayer(this.displayer)&&(_.on("seekStart",this.onPlayerSeekStart),_.on("seek",this.onPlayerSeekDone)),_.on("removeScenes",this.onRemoveScenes),_.on("setReadonly",this.onReadonlyChanged),this.createRootDirScenesCallback(),Te.setSyncRegisterApp(i=>{this.safeUpdateAttributes([xe.Registered,i.kind],i)})}get useBoxesStatus(){return this._useBoxesStatus}set useBoxesStatus(t){this._useBoxesStatus=t}getMemberState(){var t;return((t=this.room)==null?void 0:t.state.memberState)||{strokeColor:[0,0,0]}}async onRootDirRemoved(t=!0){this.setMainViewScenePath(Uh),this.createRootDirScenesCallback();for(const[i,n]of this.appProxies.entries())n.view&&await this.closeApp(i,t);this.mainViewProxy.rebind(),_.emit("rootDirRemoved"),this.updateRootDirRemoving(!1)}get eventName(){return I.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return I.isRoom(this.displayer)?this.displayer:void 0}get mainView(){return this.mainViewProxy.view}get polling(){return this.mainViewProxy.polling}set polling(t){this.mainViewProxy.polling=t}get focusApp(){if(this.store.focus)return this.appProxies.get(this.store.focus)}get uid(){var t;return((t=this.room)==null?void 0:t.uid)||""}get Logger(){return this.windowManger.Logger}getMainViewSceneDir(){const t=this.store.getMainViewScenePath();if(t)return Co(t);throw new Error("[WindowManager]: mainViewSceneDir not found")}async onCreated(){var t;if(Object.keys(this.attributes.apps).length&&this.store.focus&&(this._focusAppId=this.store.focus,await new Promise(i=>{this._focusAppCreatedResolve=i,this._resolveTimer=setTimeout(()=>{i(this.appProxies.get(this._focusAppId||""))},500)}).then(()=>{this._resolveTimer=void 0,this._focusAppCreatedResolve=void 0,this.focusByAttributes(this.attributes.apps)})),await this._attributesUpdateCallback(this.attributes.apps),_.emit("updateManagerRect"),lt.on("move",this.onBoxMove),lt.on("resize",this.onBoxResize),lt.on("focus",this.onBoxFocus),lt.on("close",this.onBoxClose),lt.on("boxStateChange",this.onBoxStateChange),lt.on("blurred",this.onBoxBlurred),this.addAppsChangeListener(),this.addAppCloseListener(),this.addBoxesStatusChangeListener(),this.refresher.add("maximized",()=>I.autorun(()=>{var n;const i=this.attributes.maximized;(n=this.boxManager)==null||n.setMaximized(Boolean(i))})),this.refresher.add("minimized",()=>I.autorun(()=>{const i=this.attributes.minimized;this.onMinimized(i)})),this.refresher.add("mainViewIndex",()=>I.autorun(()=>{const i=E.get(this.attributes,"_mainSceneIndex");this.onMainViewIndexChange(i)})),this.refresher.add("focusedChange",()=>I.autorun(()=>{const i=E.get(this.attributes,"focus");this.onFocusChange(i)})),this.refresher.add("registeredChange",()=>I.autorun(()=>{const i=E.get(this.attributes,xe.Registered);this.onRegisteredChange(i)})),!this.attributes.apps||Object.keys(this.attributes.apps).length===0){const i=this.store.getMainViewScenePath();if(!i)return;this.resetScenePath(i)}this.displayerWritableListener(!((t=this.room)!=null&&t.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener),this.focusByAttributes(this.attributes.apps),this._prevFocused=this.attributes.focus,Q.supportAppliancePlugin||this.sideEffectManager.add(()=>{const i=new gw({mainView:()=>this.mainViewProxy.view,focus:()=>this.attributes.focus,getAppProxy:n=>this.appProxies.get(n)});return()=>i.destroy()})}notifyAppsChange(t){(this._appIds.length!==t.length||!this._appIds.every(i=>t.includes(i)))&&(this._appIds=t,G.emit("appsChange",t))}async _attributesUpdateCallback(t){if(t&&Q.container){const i=Object.keys(t);i.length===0&&this.appCreateQueue.emitReady();const r=E.orderBy(i.map(s=>({id:s,createdAt:t[s].createdAt})),"createdAt","asc").map(({id:s})=>s);this.notifyAppsChange(r);for(const s of r)if(!this.appProxies.has(s)&&!this.appStatus.has(s)){const o=t[s];try{if(!this.attributes[s])throw this.Logger&&this.Logger.error(`[WindowManager]: appAttributes is undefined, appId: ${s}`),new Error("appAttributes is undefined");this.appCreateQueue.push(async()=>{this.appStatus.set(s,qo.StartCreate);const l=await this.baseInsertApp({kind:o.kind,options:o.options,isDynamicPPT:o.isDynamicPPT,forceNormal:o.forceNormal,forceTop:o.forceTop,isDragContent:o.isDragContent},s,!1);return l&&this._focusAppId===s&&this._focusAppCreatedResolve&&(this._resolveTimer&&clearTimeout(this._resolveTimer),this._focusAppCreatedResolve(l)),l}),this.focusByAttributes(t)}catch(a){console.warn("[WindowManager]: Insert App Error",a)}}}}refresh(){this.attributesUpdateCallback(this.attributes.apps)}setBoxManager(t){this.boxManager=t}resetMaximized(){var t;(t=this.boxManager)==null||t.setMaximized(Boolean(this.store.getMaximized()))}resetMinimized(){var t;(t=this.boxManager)==null||t.setMinimized(Boolean(this.store.getMinimized()))}bindMainView(t,i){const n=this.mainViewProxy.view;n.disableCameraTransform=i,n.divElement=t,n.focusScenePath||this.setMainViewFocusPath(),_.emit("mainViewMounted"),G.emit("onMainViewMounted",n);const r=this.hasRoot(n.divElement),s=this.getRectByDivElement(n.divElement);let o=`[window-manager] bindMainView hasRoot:${r}, rect:${JSON.stringify(s)}, outerHeight:${window.outerHeight}, outerWidth:${window.outerWidth}`;const a=window.visualViewport;a&&(o+=`, visualViewportWidth:${a.width}, visualViewportHeight:${a.height}, visualViewportOffsetLeft:${a.offsetLeft}, visualViewportOffsetTop:${a.offsetTop}`),console.log(o)}hasRoot(t){let i=t;for(;i;){if(i.parentElement===document.body)return!0;i=i.parentElement}return!1}getRectByDivElement(t){return t.getBoundingClientRect()}setMainViewFocusPath(t){var n;const i=t||this.store.getMainViewScenePath();if(i)return xi(this.mainView,i),((n=this.mainView)==null?void 0:n.focusScenePath)===i}resetScenePath(t){this.displayer.state.sceneState.scenePath!==t&&ta(this.room,t)}async addApp(t,i){var o;et("addApp",t),(o=this.windowManger.Logger)==null||o.info(`[WindowManager]: addApp ${t.kind}, isDynamicPPT: ${i}`);const{appId:n,needFocus:r}=await this.beforeAddApp(t,i),s=await this.baseInsertApp(t,n,!0,r);return this.afterAddApp(s),s==null?void 0:s.id}async beforeAddApp(t,i){var o,a;const n=await om(t.kind);this.appStatus.set(n,qo.StartCreate);const r=(o=t.attributes)!=null?o:{};this.safeUpdateAttributes([n],r),this.store.setupAppAttributes(t,n,i);const s=!((a=this.boxManager)!=null&&a.minimized);return s&&this.store.setAppFocus(n,!0),{appId:n,needFocus:s}}afterAddApp(t){var i,n;if(t&&t.box){const r=t.box;lt.emit("move",{appId:t.id,x:r==null?void 0:r.intrinsicX,y:r==null?void 0:r.intrinsicY}),this.store.updateAppState(t.id,Be.ZIndex,r.zIndex)}(i=this.boxManager)!=null&&i.minimized&&((n=this.boxManager)==null||n.setMinimized(!1,!1))}async closeApp(t,i=!0){const n=this.appProxies.get(t);n&&await n.destroy(!0,i,!1)}async baseInsertApp(t,i,n,r){var a;if(this.appProxies.has(i)){(a=this.windowManger.Logger)==null||a.warn(`[WindowManager]: app duplicate exists and cannot be created again, appId: ${i}`);return}const s=At(xr,Q.extendClass),o=new s(t,this,i,n);if(o)return await o.baseInsertApp(r),this.appStatus.delete(i),o;throw this.appStatus.delete(i),this.Logger&&this.Logger.error(`[WindowManager]: initialize AppProxy failed, appId: ${i}`),new Error("[WindowManger]: initialize AppProxy failed")}safeSetAttributes(t){this.windowManger.safeSetAttributes(t)}safeUpdateAttributes(t,i){this.windowManger.safeUpdateAttributes(t,i)}async setMainViewScenePath(t){if(this.room){const i=this.displayer.scenePathType(t);if(Co(t)!==ze)throw this.Logger&&this.Logger.error('[WindowManager]: main view scenePath must in root dir "/"'),new Error('[WindowManager]: main view scenePath must in root dir "/"');if(i===I.ScenePathType.None)throw this.Logger&&this.Logger.error(`[WindowManager]: ${t} not valid scene`),new Error(`[WindowManager]: ${t} not valid scene`);if(i===I.ScenePathType.Page)await this._setMainViewScenePath(t);else if(i===I.ScenePathType.Dir){const r=um(this.displayer,t);r&&await this._setMainViewScenePath(r)}}}async _setMainViewScenePath(t){this.setMainViewFocusPath(t)&&(this.safeSetAttributes({_mainScenePath:t}),this.store.setMainViewFocusPath(this.mainView),this.updateSceneIndex(),this.dispatchSetMainViewScenePath(t))}async setMainViewSceneIndex(t){var i;if(this.room){if(this.store.getMainViewSceneIndex()===t)return;const n=(i=this.callbacksNode)==null?void 0:i.scenes[t],r=`${ze}${n}`;if(n)this.setMainViewFocusPath(r)&&(this.store.setMainViewScenePath(r),this.store.setMainViewSceneIndex(t),this.dispatchSetMainViewScenePath(r));else throw this.Logger&&this.Logger.error(`[WindowManager]: ${t} not valid index`),new Error(`[WindowManager]: ${t} not valid index`)}}dispatchSetMainViewScenePath(t){this.dispatchInternalEvent(se.SetMainViewScenePath,{nextScenePath:t}),G.emit("mainViewScenePathChange",t),ta(this.room,t)}getAppInitPath(t){var n;const i=this.store.getAppAttributes(t);if(i)return(n=i==null?void 0:i.options)==null?void 0:n.scenePath}safeDispatchMagixEvent(t,i){this.canOperate&&this.displayer.dispatchMagixEvent(t,i)}focusByAttributes(t){var i;if(t&&Object.keys(t).length===((i=this.boxManager)==null?void 0:i.boxSize)){const n=this.store.focus;n&&this.boxManager.focusBox({appId:n})}}async onReconnected(){await this._attributesUpdateCallback(this.attributes.apps);const i=Array.from(this.appProxies.values()).map(n=>n.onReconnected());this.mainViewProxy.onReconnect(),await Promise.all(i),this.callbacksNode&&this.onSceneChange(this.callbacksNode)}notifyContainerRectUpdate(t){this.appProxies.forEach(i=>{i.appEmitter.emit("containerRectUpdate",t)})}dispatchInternalEvent(t,i){this.safeDispatchMagixEvent(Ko,{eventName:t,payload:i})}destroy(){this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),lt.clearListeners(),_.clearListeners(),this.appProxies.size&&this.appProxies.forEach(t=>{t.destroy(!0,!1,!0)}),G.clearListeners(),this.sideEffectManager.flushAll(),this._prevFocused=void 0,this._prevSceneIndex=void 0,this._resolveTimer&&clearTimeout(this._resolveTimer),this._focusAppCreatedResolve=void 0,this._resolveTimer=void 0}}Sr.kind="AppManager";const mw=window.ResizeObserver||Vg.ResizeObserver;class bl{constructor(t){this.emitter=t,this.updateSizerLocalConsole=new zn("updateSizer",100)}static create(t,i,n,r){const s=new bl(r);return s.observePlaygroundSize(t,i,n),s}observePlaygroundSize(t,i,n){this.updateSizer(t.getBoundingClientRect(),i,n,"observePlaygroundSize"),this.containerResizeObserver=new mw(r=>{var o;const s=(o=r[0])==null?void 0:o.contentRect;s&&(this.updateSizer(s,i,n,"containerResizeObserver"),this.emitter.emit("playgroundSizeChange",s))}),this.disposer=this.emitter.on("containerSizeRatioUpdate",()=>{const r=t.getBoundingClientRect();this.updateSizer(r,i,n,"containerSizeRatioUpdate"),this.emitter.emit("playgroundSizeChange",r)}),this.containerResizeObserver.observe(t)}updateSizer({width:t,height:i},n,r,s){if(t&&i){i/t>Q.containerSizeRatio?(i=t*Q.containerSizeRatio,n.classList.toggle("netless-window-manager-sizer-horizontal",!0)):(t=i/Q.containerSizeRatio,n.classList.toggle("netless-window-manager-sizer-horizontal",!1)),r.style.width=`${t}px`,r.style.height=`${i}px`;const o=r.getBoundingClientRect();this.updateSizerLocalConsole.log(`from ${s}, traget size: ${JSON.stringify({width:t,height:i})}, wrapperRect: ${o.width} ${o.height}`),this.emitter.emit("wrapperRectChange",{width:o.width,height:o.height,origin:s})}}disconnect(){var t,i;this.updateSizerLocalConsole.destroy(),(t=this.containerResizeObserver)==null||t.disconnect(),(i=this.disposer)==null||i.call(this),this.disposer=void 0}}class vw{constructor(t){this.manager=t,_.on("changePageState",()=>{G.emit("pageStateChange",this.toObject())})}get index(){return this.manager.store.getMainViewSceneIndex()||0}get length(){return this.manager.mainViewScenesLength||0}toObject(){return{index:this.index>=this.length?this.length-1:this.index,length:this.length}}}class ww{constructor(t){this.ctx=t,this.reactors=new Map,this.disposers=new Map,this.onPhaseChanged=async i=>{var n,r;i===I.RoomPhase.Reconnecting&&this.ctx.emitter.emit("startReconnect"),i===I.RoomPhase.Connected&&this.phase===I.RoomPhase.Reconnecting&&((n=this.room)!=null&&n.isWritable?(r=this.room)==null||r.dispatchMagixEvent(Mo,{}):(await Hh(500),this.onReconnected())),this.phase=i},this.onReconnected=E.debounce(()=>{this._onReconnected()},1e3),this._onReconnected=()=>{et("onReconnected refresh reactors"),this.releaseDisposers(),this.reactors.forEach((i,n)=>{E.isFunction(i)&&this.disposers.set(n,i())}),this.ctx.emitter.emit("onReconnected")}}setRoom(t){this.room=t,this.phase=t==null?void 0:t.phase,t&&(t.callbacks.off("onPhaseChanged",this.onPhaseChanged),t.callbacks.on("onPhaseChanged",this.onPhaseChanged),t.addMagixEventListener(Mo,i=>{i.authorId===t.observerId&&this.onReconnected()},{fireSelfEventAfterCommit:!0}))}setContext(t){this.ctx=t}releaseDisposers(){this.disposers.forEach(t=>{E.isFunction(t)&&t()}),this.disposers.clear()}refresh(){this._onReconnected()}add(t,i){const n=this.disposers.get(t);n&&E.isFunction(n)&&n(),E.isFunction(i)&&(this.reactors.set(t,i),this.disposers.set(t,i()))}remove(t){this.reactors.has(t)&&this.reactors.delete(t);const i=this.disposers.get(t);i&&(E.isFunction(i)&&i(),this.disposers.delete(t))}hasReactor(t){return this.reactors.has(t)}destroy(){var t,i;(t=this.room)==null||t.callbacks.off("onPhaseChanged",this.onPhaseChanged),(i=this.room)==null||i.removeMagixEventListener(Mo,this.onReconnected),this.releaseDisposers()}}const yw=(e,t)=>{if(I.isPlayer(e))Sw(e);else{if(e=e,Object.getOwnPropertyDescriptor(e,"disableCameraTransform"))return;Object.defineProperty(e,"disableCameraTransform",{get(){return t.mainView.disableCameraTransform},set(s){t.mainView.disableCameraTransform=s}}),Object.defineProperty(e,"canUndoSteps",{get(){return t.canUndoSteps}}),Object.defineProperty(e,"canRedoSteps",{get(){return t.canRedoSteps}});const n=e.scalePptToFit;e.scalePptToFit=(...s)=>{var o;n.call(e,...s),(o=t.appManager)!=null&&o.mainViewProxy&&t.appManager.mainViewProxy.setCameraAndSize()};const r=e.putScenes;e.putScenes=(...s)=>{const[o,a]=s,l=t.mainView.focusScenePath;if(l&&o&&a){console.log("[window-manager] putScenes "+JSON.stringify(s));for(const u of a)if(`${o}${u.name}`===l){console.error(`[window-manager] putScenes: scene name can not be the same as the current scene path: ${l}`);return}}return r.call(e,...s)},e.moveCamera=s=>t.moveCamera(s),e.moveCameraToContain=(...s)=>t.moveCameraToContain(...s),e.convertToPointInWorld=(...s)=>t.mainView.convertToPointInWorld(...s),e.setCameraBound=(...s)=>t.mainView.setCameraBound(...s),e.scenePreview=(...s)=>t.mainView.scenePreview(...s),e.fillSceneSnapshot=(...s)=>t.mainView.fillSceneSnapshot(...s),e.generateScreenshot=(...s)=>t.mainView.generateScreenshot(...s),e.setMemberState=(...s)=>t.mainView.setMemberState(...s),e.redo=()=>t.redo(),e.undo=()=>t.undo(),e.cleanCurrentScene=()=>t.cleanCurrentScene(),e.delete=()=>t.delete(),e.copy=()=>t.copy(),e.paste=()=>t.paste(),e.duplicate=()=>t.duplicate(),e.insertImage=(...s)=>t.insertImage(...s),e.completeImageUpload=(...s)=>t.completeImageUpload(...s),e.insertText=(...s)=>t.insertText(...s),e.lockImage=(...s)=>t.lockImage(...s),e.lockImages=(...s)=>t.lockImages(...s),xw(e,t)}},xw=(e,t)=>{const i=e.removeScenes;e.removeScenes=(n,r)=>{var o;n===ze&&((o=t.appManager)==null||o.updateRootDirRemoving(!0));const s=i.call(e,n);return _.emit("removeScenes",{scenePath:n,index:r}),s}},Sw=e=>{const t=e.seekToProgressTime;async function i(n){await _.emit("seekStart");const r=await t.call(e,n);return _.emit("seek",n),r}e.seekToProgressTime=i};var Mw=`.netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}@media (hover: none){.netless-app-docs-viewer-footer-btn:hover{background:transparent!important}}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:3em;margin:0;padding:0 2px;text-align:right;font-size:13px;line-height:1;font-weight:400;font-family:inherit;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text;-webkit-tap-highlight-color:rgba(0,0,0,0)}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input{color:#a6a6a8}.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:active,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:focus,.telebox-color-scheme-dark .netless-app-docs-viewer-page-number-input:hover{color:#222}.telebox-color-scheme-dark .netless-app-docs-viewer-footer{color:#a6a6a8;background:#2d2d33;border-top:none}.telebox-color-scheme-dark .netless-app-docs-viewer-footer-btn:hover{background:#212126}.telebox-color-scheme-dark .netless-app-docs-viewer-preview{background:rgba(50,50,50,.9)}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.4);box-shadow:1px 1px 8px #ffffffb3;opacity:0;transition:background .4s,opacity .4s 3s,transform .2s;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.6);opacity:1;transition:background .4s,opacity .4s 3s!important}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.5)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.6)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1;transition:background .4s,opacity .4s,transform .2s}.page-renderer-pages-container{position:relative;overflow:hidden}.page-renderer-page{position:absolute;top:0;left:0;background-position:center;background-size:cover;background-repeat:no-repeat}.page-renderer-pages-container.is-hwa .page-renderer-page{will-change:transform}.page-renderer-page-img{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view,.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}
17
- `;const Cw=(e,t,i,n)=>{if(i==="length"||i==="prototype"||i==="arguments"||i==="caller")return;const r=Object.getOwnPropertyDescriptor(e,i),s=Object.getOwnPropertyDescriptor(t,i);!bw(r,s)&&n||Object.defineProperty(e,i,s)},bw=function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},Iw=(e,t)=>{const i=Object.getPrototypeOf(t);i!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,i)},Tw=(e,t)=>`/* Wrapped ${e}*/
18
- ${t}`,Aw=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ew=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Nw=(e,t,i)=>{const n=i===""?"":`with ${i.trim()}() `,r=Tw.bind(null,n,t.toString());Object.defineProperty(r,"name",Ew),Object.defineProperty(e,"toString",{...Aw,value:r})};function kw(e,t,{ignoreNonConfigurable:i=!1}={}){const{name:n}=e;for(const r of Reflect.ownKeys(t))Cw(e,t,r,i);return Iw(e,t),Nw(e,t,n),e}const Pw=(e,t={})=>{if(typeof e!="function")throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:i=0,maxWait:n=Number.POSITIVE_INFINITY,before:r=!1,after:s=!0}=t;if(!r&&!s)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let o,a,l;const u=function(...c){const h=this,m=()=>{o=void 0,a&&(clearTimeout(a),a=void 0),s&&(l=e.apply(h,c))},v=()=>{a=void 0,o&&(clearTimeout(o),o=void 0),s&&(l=e.apply(h,c))},w=r&&!o;return clearTimeout(o),o=setTimeout(m,i),n>0&&n!==Number.POSITIVE_INFINITY&&!a&&(a=setTimeout(v,n)),w&&(l=e.apply(h,c)),l};return kw(u,e),u.cancel=()=>{o&&(clearTimeout(o),o=void 0),a&&(clearTimeout(a),a=void 0)},u};var zw="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Bw=87,Dw=20,hc=[],Lw=()=>{for(let e=0;e<Dw;e++)hc[e]=zw.charAt(Math.random()*Bw);return hc.join("")};function Ed(e){try{return e()}catch(t){console.error(t)}}var io=class{constructor(){this.push=this.addDisposer,this.disposers=new Map}addDisposer(e,t=this.genUID()){return this.flush(t),this.disposers.set(t,Array.isArray(e)?Rw(e):e),t}add(e,t=this.genUID()){const i=e();return i?this.addDisposer(i,t):t}addEventListener(e,t,i,n,r=this.genUID()){return e.addEventListener(t,i,n),this.addDisposer(()=>e.removeEventListener(t,i,n),r),r}setTimeout(e,t,i=this.genUID()){const n=window.setTimeout(()=>{this.remove(i),e()},t);return this.addDisposer(()=>window.clearTimeout(n),i)}setInterval(e,t,i=this.genUID()){const n=window.setInterval(e,t);return this.addDisposer(()=>window.clearInterval(n),i)}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){const t=this.remove(e);t&&t()}flushAll(){this.disposers.forEach(Ed),this.disposers.clear()}genUID(){let e;do e=Lw();while(this.disposers.has(e));return e}};function Rw(e){return()=>e.forEach(Ed)}var fi=[],jw=function(){return fi.some(function(e){return e.activeTargets.length>0})},_w=function(){return fi.some(function(e){return e.skippedTargets.length>0})},dc="ResizeObserver loop completed with undelivered notifications.",Vw=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:dc}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=dc),window.dispatchEvent(e)},er;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(er||(er={}));var pi=function(e){return Object.freeze(e)},Ow=function(){function e(t,i){this.inlineSize=t,this.blockSize=i,pi(this)}return e}(),Nd=function(){function e(t,i,n,r){return this.x=t,this.y=i,this.width=n,this.height=r,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,pi(this)}return e.prototype.toJSON=function(){var t=this,i=t.x,n=t.y,r=t.top,s=t.right,o=t.bottom,a=t.left,l=t.width,u=t.height;return{x:i,y:n,top:r,right:s,bottom:o,left:a,width:l,height:u}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),Il=function(e){return e instanceof SVGElement&&"getBBox"in e},kd=function(e){if(Il(e)){var t=e.getBBox(),i=t.width,n=t.height;return!i&&!n}var r=e,s=r.offsetWidth,o=r.offsetHeight;return!(s||o||e.getClientRects().length)},fc=function(e){var t;if(e instanceof Element)return!0;var i=(t=e==null?void 0:e.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(i&&e instanceof i.Element)},$w=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},Un=typeof window!="undefined"?window:{},$r=new WeakMap,pc=/auto|scroll/,Uw=/^tb|vertical/,Ww=/msie|trident/i.test(Un.navigator&&Un.navigator.userAgent),st=function(e){return parseFloat(e||"0")},Zi=function(e,t,i){return e===void 0&&(e=0),t===void 0&&(t=0),i===void 0&&(i=!1),new Ow((i?t:e)||0,(i?e:t)||0)},gc=pi({devicePixelContentBoxSize:Zi(),borderBoxSize:Zi(),contentBoxSize:Zi(),contentRect:new Nd(0,0,0,0)}),Pd=function(e,t){if(t===void 0&&(t=!1),$r.has(e)&&!t)return $r.get(e);if(kd(e))return $r.set(e,gc),gc;var i=getComputedStyle(e),n=Il(e)&&e.ownerSVGElement&&e.getBBox(),r=!Ww&&i.boxSizing==="border-box",s=Uw.test(i.writingMode||""),o=!n&&pc.test(i.overflowY||""),a=!n&&pc.test(i.overflowX||""),l=n?0:st(i.paddingTop),u=n?0:st(i.paddingRight),c=n?0:st(i.paddingBottom),h=n?0:st(i.paddingLeft),m=n?0:st(i.borderTopWidth),v=n?0:st(i.borderRightWidth),w=n?0:st(i.borderBottomWidth),x=n?0:st(i.borderLeftWidth),d=h+u,f=l+c,g=x+v,p=m+w,y=a?e.offsetHeight-p-e.clientHeight:0,S=o?e.offsetWidth-g-e.clientWidth:0,A=r?d+g:0,k=r?f+p:0,z=n?n.width:st(i.width)-A-S,B=n?n.height:st(i.height)-k-y,ee=z+d+S+g,b=B+f+y+p,M=pi({devicePixelContentBoxSize:Zi(Math.round(z*devicePixelRatio),Math.round(B*devicePixelRatio),s),borderBoxSize:Zi(ee,b,s),contentBoxSize:Zi(z,B,s),contentRect:new Nd(h,l,z,B)});return $r.set(e,M),M},zd=function(e,t,i){var n=Pd(e,i),r=n.borderBoxSize,s=n.contentBoxSize,o=n.devicePixelContentBoxSize;switch(t){case er.DEVICE_PIXEL_CONTENT_BOX:return o;case er.BORDER_BOX:return r;default:return s}},Hw=function(){function e(t){var i=Pd(t);this.target=t,this.contentRect=i.contentRect,this.borderBoxSize=pi([i.borderBoxSize]),this.contentBoxSize=pi([i.contentBoxSize]),this.devicePixelContentBoxSize=pi([i.devicePixelContentBoxSize])}return e}(),Bd=function(e){if(kd(e))return 1/0;for(var t=0,i=e.parentNode;i;)t+=1,i=i.parentNode;return t},Fw=function(){var e=1/0,t=[];fi.forEach(function(o){if(o.activeTargets.length!==0){var a=[];o.activeTargets.forEach(function(u){var c=new Hw(u.target),h=Bd(u.target);a.push(c),u.lastReportedSize=zd(u.target,u.observedBox),h<e&&(e=h)}),t.push(function(){o.callback.call(o.observer,a,o.observer)}),o.activeTargets.splice(0,o.activeTargets.length)}});for(var i=0,n=t;i<n.length;i++){var r=n[i];r()}return e},mc=function(e){fi.forEach(function(i){i.activeTargets.splice(0,i.activeTargets.length),i.skippedTargets.splice(0,i.skippedTargets.length),i.observationTargets.forEach(function(r){r.isActive()&&(Bd(r.target)>e?i.activeTargets.push(r):i.skippedTargets.push(r))})})},Qw=function(){var e=0;for(mc(e);jw();)e=Fw(),mc(e);return _w()&&Vw(),e>0},Bo,Dd=[],Zw=function(){return Dd.splice(0).forEach(function(e){return e()})},Yw=function(e){if(!Bo){var t=0,i=document.createTextNode(""),n={characterData:!0};new MutationObserver(function(){return Zw()}).observe(i,n),Bo=function(){i.textContent="".concat(t?t--:t++)}}Dd.push(e),Bo()},Gw=function(e){Yw(function(){requestAnimationFrame(e)})},os=0,Xw=function(){return!!os},Jw=250,Kw={attributes:!0,characterData:!0,childList:!0,subtree:!0},vc=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],wc=function(e){return e===void 0&&(e=0),Date.now()+e},Do=!1,qw=function(){function e(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return e.prototype.run=function(t){var i=this;if(t===void 0&&(t=Jw),!Do){Do=!0;var n=wc(t);Gw(function(){var r=!1;try{r=Qw()}finally{if(Do=!1,t=n-wc(),!Xw())return;r?i.run(1e3):t>0?i.run(t):i.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,i=function(){return t.observer&&t.observer.observe(document.body,Kw)};document.body?i():Un.addEventListener("DOMContentLoaded",i)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),vc.forEach(function(i){return Un.addEventListener(i,t.listener,!0)}))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),vc.forEach(function(i){return Un.removeEventListener(i,t.listener,!0)}),this.stopped=!0)},e}(),fa=new qw,yc=function(e){!os&&e>0&&fa.start(),os+=e,!os&&fa.stop()},ey=function(e){return!Il(e)&&!$w(e)&&getComputedStyle(e).display==="inline"},ty=function(){function e(t,i){this.target=t,this.observedBox=i||er.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=zd(this.target,this.observedBox,!0);return ey(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),iy=function(){function e(t,i){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=i}return e}(),Ur=new WeakMap,xc=function(e,t){for(var i=0;i<e.length;i+=1)if(e[i].target===t)return i;return-1},Wr=function(){function e(){}return e.connect=function(t,i){var n=new iy(t,i);Ur.set(t,n)},e.observe=function(t,i,n){var r=Ur.get(t),s=r.observationTargets.length===0;xc(r.observationTargets,i)<0&&(s&&fi.push(r),r.observationTargets.push(new ty(i,n&&n.box)),yc(1),fa.schedule())},e.unobserve=function(t,i){var n=Ur.get(t),r=xc(n.observationTargets,i),s=n.observationTargets.length===1;r>=0&&(s&&fi.splice(fi.indexOf(n),1),n.observationTargets.splice(r,1),yc(-1))},e.disconnect=function(t){var i=this,n=Ur.get(t);n.observationTargets.slice().forEach(function(r){return i.unobserve(t,r.target)}),n.activeTargets.splice(0,n.activeTargets.length)},e}(),ny=function(){function e(t){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof t!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");Wr.connect(this,t)}return e.prototype.observe=function(t,i){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!fc(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");Wr.observe(this,t,i)},e.prototype.unobserve=function(t){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!fc(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");Wr.unobserve(this,t)},e.prototype.disconnect=function(){Wr.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();function ry(e){const t="http://www.w3.org/2000/svg",i=document.createElementNS(t,"svg");i.setAttribute("class",`${e}-footer-icon-sidebar`),i.setAttribute("viewBox","0 0 64 64");const n=document.createElementNS(t,"path");return n.setAttribute("fill","currentColor"),n.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),i.appendChild(n),i}function sy(e){const t="http://www.w3.org/2000/svg",i=document.createElementNS(t,"svg");i.setAttribute("class",`${e}-footer-icon-arrow-left`),i.setAttribute("viewBox","0 0 500 500");const n=document.createElementNS(t,"path");return n.setAttribute("fill","currentColor"),n.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),i.appendChild(n),i}function oy(e){const t="http://www.w3.org/2000/svg",i=document.createElementNS(t,"svg");i.setAttribute("class",`${e}-footer-icon-arrow-right`),i.setAttribute("viewBox","0 0 500 500");const n=document.createElementNS(t,"path");return n.setAttribute("fill","currentColor"),n.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),i.appendChild(n),i}function ay(e){const t="http://www.w3.org/2000/svg",i=document.createElementNS(t,"svg");i.setAttribute("class",`${e}-footer-icon-play`),i.setAttribute("viewBox","0 0 500 500");const n=document.createElementNS(t,"path");return n.setAttribute("fill","currentColor"),n.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),i.appendChild(n),i}function ly(e){const t="http://www.w3.org/2000/svg",i=document.createElementNS(t,"svg");i.setAttribute("class",`${e}-footer-icon-pause`),i.setAttribute("viewBox","0 0 500 500");const n=document.createElementNS(t,"path");return n.setAttribute("fill","currentColor"),n.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),i.appendChild(n),i}const Jt=typeof window!="undefined",Ld=Jt&&!("onscroll"in window)||typeof navigator!="undefined"&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),Rd=Jt&&"IntersectionObserver"in window,jd=Jt&&"classList"in document.createElement("p"),_d=Jt&&window.devicePixelRatio>1,uy={elements_selector:".lazy",container:Ld||Jt?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_bg_set:"bg-set",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1,restore_on_error:!1},Vd=e=>Object.assign({},uy,e),Sc=function(e,t){let i;const n="LazyLoad::Initialized",r=new e(t);try{i=new CustomEvent(n,{detail:{instance:r}})}catch{i=document.createEvent("CustomEvent"),i.initCustomEvent(n,!1,!1,{instance:r})}window.dispatchEvent(i)},cy=(e,t)=>{if(!!t)if(!t.length)Sc(e,t);else for(let i=0,n;n=t[i];i+=1)Sc(e,n)},Et="src",Tl="srcset",Al="sizes",Od="poster",Mr="llOriginalAttrs",$d="data",El="loading",Ud="loaded",Wd="applied",hy="entered",Nl="error",Hd="native",Fd="data-",Qd="ll-status",De=(e,t)=>e.getAttribute(Fd+t),dy=(e,t,i)=>{const n=Fd+t;if(i===null){e.removeAttribute(n);return}e.setAttribute(n,i)},Cr=e=>De(e,Qd),Ai=(e,t)=>dy(e,Qd,t),no=e=>Ai(e,null),kl=e=>Cr(e)===null,fy=e=>Cr(e)===El,py=e=>Cr(e)===Nl,Pl=e=>Cr(e)===Hd,gy=[El,Ud,Wd,Nl],my=e=>gy.indexOf(Cr(e))>=0,Kt=(e,t,i,n)=>{if(!(!e||typeof e!="function")){if(n!==void 0){e(t,i,n);return}if(i!==void 0){e(t,i);return}e(t)}},hn=(e,t)=>{if(t!==""){if(jd){e.classList.add(t);return}e.className+=(e.className?" ":"")+t}},ut=(e,t)=>{if(t!==""){if(jd){e.classList.remove(t);return}e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")}},vy=e=>{e.llTempImage=document.createElement("IMG")},wy=e=>{delete e.llTempImage},Zd=e=>e.llTempImage,ro=(e,t)=>{if(!t)return;const i=t._observer;!i||i.unobserve(e)},yy=e=>{e.disconnect()},xy=(e,t,i)=>{t.unobserve_entered&&ro(e,i)},zl=(e,t)=>{!e||(e.loadingCount+=t)},Sy=e=>{!e||(e.toLoadCount-=1)},Yd=(e,t)=>{!e||(e.toLoadCount=t)},My=e=>e.loadingCount>0,Cy=e=>e.toLoadCount>0,Gd=e=>{let t=[];for(let i=0,n;n=e.children[i];i+=1)n.tagName==="SOURCE"&&t.push(n);return t},Bl=(e,t)=>{const i=e.parentNode;if(!i||i.tagName!=="PICTURE")return;Gd(i).forEach(t)},Xd=(e,t)=>{Gd(e).forEach(t)},so=[Et],Jd=[Et,Od],tr=[Et,Tl,Al],Kd=[$d],oo=e=>!!e[Mr],qd=e=>e[Mr],ef=e=>delete e[Mr],tn=(e,t)=>{if(oo(e))return;const i={};t.forEach(n=>{i[n]=e.getAttribute(n)}),e[Mr]=i},by=e=>{oo(e)||(e[Mr]={backgroundImage:e.style.backgroundImage})},Iy=(e,t,i)=>{if(!i){e.removeAttribute(t);return}e.setAttribute(t,i)},Si=(e,t)=>{if(!oo(e))return;const i=qd(e);t.forEach(n=>{Iy(e,n,i[n])})},Ty=e=>{if(!oo(e))return;const t=qd(e);e.style.backgroundImage=t.backgroundImage},tf=(e,t,i)=>{hn(e,t.class_applied),Ai(e,Wd),i&&(t.unobserve_completed&&ro(e,t),Kt(t.callback_applied,e,i))},nf=(e,t,i)=>{hn(e,t.class_loading),Ai(e,El),i&&(zl(i,1),Kt(t.callback_loading,e,i))},Ot=(e,t,i)=>{!i||e.setAttribute(t,i)},Mc=(e,t)=>{Ot(e,Al,De(e,t.data_sizes)),Ot(e,Tl,De(e,t.data_srcset)),Ot(e,Et,De(e,t.data_src))},Ay=(e,t)=>{Bl(e,i=>{tn(i,tr),Mc(i,t)}),tn(e,tr),Mc(e,t)},Ey=(e,t)=>{tn(e,so),Ot(e,Et,De(e,t.data_src))},Ny=(e,t)=>{Xd(e,i=>{tn(i,so),Ot(i,Et,De(i,t.data_src))}),tn(e,Jd),Ot(e,Od,De(e,t.data_poster)),Ot(e,Et,De(e,t.data_src)),e.load()},ky=(e,t)=>{tn(e,Kd),Ot(e,$d,De(e,t.data_src))},Py=(e,t,i)=>{const n=De(e,t.data_bg),r=De(e,t.data_bg_hidpi),s=_d&&r?r:n;!s||(e.style.backgroundImage=`url("${s}")`,Zd(e).setAttribute(Et,s),nf(e,t,i))},zy=(e,t,i)=>{const n=De(e,t.data_bg_multi),r=De(e,t.data_bg_multi_hidpi),s=_d&&r?r:n;!s||(e.style.backgroundImage=s,tf(e,t,i))},By=(e,t,i)=>{const n=De(e,t.data_bg_set);if(!n)return;const r=n.split("|");let s=r.map(o=>`image-set(${o})`);e.style.backgroundImage=s.join(),e.style.backgroundImage===""&&(s=r.map(o=>`-webkit-image-set(${o})`),e.style.backgroundImage=s.join()),tf(e,t,i)},rf={IMG:Ay,IFRAME:Ey,VIDEO:Ny,OBJECT:ky},Dy=(e,t)=>{const i=rf[e.tagName];!i||i(e,t)},Ly=(e,t,i)=>{const n=rf[e.tagName];!n||(n(e,t),nf(e,t,i))},Ry=["IMG","IFRAME","VIDEO","OBJECT"],jy=e=>Ry.indexOf(e.tagName)>-1,sf=(e,t)=>{t&&!My(t)&&!Cy(t)&&Kt(e.callback_finish,t)},Cc=(e,t,i)=>{e.addEventListener(t,i),e.llEvLisnrs[t]=i},_y=(e,t,i)=>{e.removeEventListener(t,i)},Dl=e=>!!e.llEvLisnrs,Vy=(e,t,i)=>{Dl(e)||(e.llEvLisnrs={});const n=e.tagName==="VIDEO"?"loadeddata":"load";Cc(e,n,t),Cc(e,"error",i)},pa=e=>{if(!Dl(e))return;const t=e.llEvLisnrs;for(let i in t){const n=t[i];_y(e,i,n)}delete e.llEvLisnrs},of=(e,t,i)=>{wy(e),zl(i,-1),Sy(i),ut(e,t.class_loading),t.unobserve_completed&&ro(e,i)},Oy=(e,t,i,n)=>{const r=Pl(t);of(t,i,n),hn(t,i.class_loaded),Ai(t,Ud),Kt(i.callback_loaded,t,n),r||sf(i,n)},$y=(e,t,i,n)=>{const r=Pl(t);of(t,i,n),hn(t,i.class_error),Ai(t,Nl),Kt(i.callback_error,t,n),i.restore_on_error&&Si(t,tr),r||sf(i,n)},Ll=(e,t,i)=>{const n=Zd(e)||e;if(Dl(n))return;Vy(n,o=>{Oy(o,e,t,i),pa(n)},o=>{$y(o,e,t,i),pa(n)})},Uy=(e,t,i)=>{vy(e),Ll(e,t,i),by(e),Py(e,t,i),zy(e,t,i),By(e,t,i)},Wy=(e,t,i)=>{Ll(e,t,i),Ly(e,t,i)},Rl=(e,t,i)=>{jy(e)?Wy(e,t,i):Uy(e,t,i)},Hy=(e,t,i)=>{e.setAttribute("loading","lazy"),Ll(e,t,i),Dy(e,t),Ai(e,Hd)},bc=e=>{e.removeAttribute(Et),e.removeAttribute(Tl),e.removeAttribute(Al)},Fy=e=>{Bl(e,t=>{bc(t)}),bc(e)},af=e=>{Bl(e,t=>{Si(t,tr)}),Si(e,tr)},Qy=e=>{Xd(e,t=>{Si(t,so)}),Si(e,Jd),e.load()},Zy=e=>{Si(e,so)},Yy=e=>{Si(e,Kd)},Gy={IMG:af,IFRAME:Zy,VIDEO:Qy,OBJECT:Yy},Xy=e=>{const t=Gy[e.tagName];if(!t){Ty(e);return}t(e)},Jy=(e,t)=>{kl(e)||Pl(e)||(ut(e,t.class_entered),ut(e,t.class_exited),ut(e,t.class_applied),ut(e,t.class_loading),ut(e,t.class_loaded),ut(e,t.class_error))},Ky=(e,t)=>{Xy(e),Jy(e,t),no(e),ef(e)},qy=(e,t,i,n)=>{!i.cancel_on_exit||!fy(e)||e.tagName==="IMG"&&(pa(e),Fy(e),af(e),ut(e,i.class_loading),zl(n,-1),no(e),Kt(i.callback_cancel,e,t,n))},ex=(e,t,i,n)=>{const r=my(e);Ai(e,hy),hn(e,i.class_entered),ut(e,i.class_exited),xy(e,i,n),Kt(i.callback_enter,e,t,n),!r&&Rl(e,i,n)},tx=(e,t,i,n)=>{kl(e)||(hn(e,i.class_exited),qy(e,t,i,n),Kt(i.callback_exit,e,t,n))},ix=["IMG","IFRAME","VIDEO"],lf=e=>e.use_native&&"loading"in HTMLImageElement.prototype,nx=(e,t,i)=>{e.forEach(n=>{ix.indexOf(n.tagName)!==-1&&Hy(n,t,i)}),Yd(i,0)},rx=e=>e.isIntersecting||e.intersectionRatio>0,sx=e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),ox=(e,t,i)=>{e.forEach(n=>rx(n)?ex(n.target,n,t,i):tx(n.target,n,t,i))},ax=(e,t)=>{t.forEach(i=>{e.observe(i)})},lx=(e,t)=>{yy(e),ax(e,t)},ux=(e,t)=>{!Rd||lf(e)||(t._observer=new IntersectionObserver(i=>{ox(i,e,t)},sx(e)))},uf=e=>Array.prototype.slice.call(e),Cs=e=>e.container.querySelectorAll(e.elements_selector),cx=e=>uf(e).filter(kl),hx=e=>py(e),dx=e=>uf(e).filter(hx),Ic=(e,t)=>cx(e||Cs(t)),fx=(e,t)=>{dx(Cs(e)).forEach(n=>{ut(n,e.class_error),no(n)}),t.update()},px=(e,t)=>{!Jt||(t._onlineHandler=()=>{fx(e,t)},window.addEventListener("online",t._onlineHandler))},gx=e=>{!Jt||window.removeEventListener("online",e._onlineHandler)},br=function(e,t){const i=Vd(e);this._settings=i,this.loadingCount=0,ux(i,this),px(i,this),this.update(t)};br.prototype={update:function(e){const t=this._settings,i=Ic(e,t);if(Yd(this,i.length),Ld||!Rd){this.loadAll(i);return}if(lf(t)){nx(i,t,this);return}lx(this._observer,i)},destroy:function(){this._observer&&this._observer.disconnect(),gx(this),Cs(this._settings).forEach(e=>{ef(e)}),delete this._observer,delete this._settings,delete this._onlineHandler,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;Ic(e,t).forEach(n=>{ro(n,this),Rl(n,t,this)})},restoreAll:function(){const e=this._settings;Cs(e).forEach(t=>{Ky(t,e)})}};br.load=(e,t)=>{const i=Vd(t);Rl(e,i)};br.resetStatus=e=>{no(e)};Jt&&cy(br,window.lazyLoadOptions);class cf{constructor({readonly:t,box:i,pages:n,onNewPageIndex:r,onPlay:s}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new io,n.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=t,this.box=i,this.pages=n,this.onNewPageIndex=r,this.onPlay=s,this.onPageIndexChanged=()=>{},this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add(()=>{const t=new br({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>t.destroy()},"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.$content.classList.toggle(this.wrapClassName("readonly"),t),this.$footer.classList.toggle(this.wrapClassName("readonly"),t),this.$pageNumberInput.disabled=t)}destroy(){this.sideEffect.flushAll(),this.unmount()}setPageIndex(t){Number.isNaN(t)||(this.pageIndex=t,this.$pageNumberInput.value=String(t+1),this.onPageIndexChanged(t))}setSmallBox(t){this.isSmallBox!==t&&(this.isSmallBox=t,this.$footer.classList.toggle(this.wrapClassName("float-footer"),t))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const t=document.createElement("div");t.className=this.wrapClassName("content"),this.$content=t,this.readonly&&t.classList.add(this.wrapClassName("readonly")),t.appendChild(this.renderPreviewMask()),t.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const t=document.createElement("div");t.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=t;const i=this.wrapClassName("preview-page"),n=this.wrapClassName("preview-page-name");this.pages.forEach((r,s)=>{var o;const a=(o=r.thumbnail)!=null?o:r.src.startsWith("ppt")?void 0:r.src;if(!a)return;const l=String(s),u=document.createElement("a");u.className=i+" "+this.wrapClassName(`preview-page-${s}`),u.setAttribute("href","#"),u.dataset.pageIndex=l;const c=document.createElement("span");c.className=n,c.textContent=String(s+1),c.dataset.pageIndex=l;const h=document.createElement("img");h.width=r.width,h.height=r.height,h.dataset.src=a,h.dataset.pageIndex=l,u.appendChild(h),u.appendChild(c),t.appendChild(u)}),this.sideEffect.addEventListener(t,"click",r=>{var s;if(this.readonly)return;const o=(s=r.target.dataset)==null?void 0:s.pageIndex;o&&(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),this.onNewPageIndex(Number(o)),this.togglePreview(!1))})}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",t=>{this.readonly||t.target===this.$previewMask&&this.togglePreview(!1)})),this.$previewMask}renderFooter(){if(!this.$footer){const t=document.createElement("div");if(t.className=this.wrapClassName("footer"),this.$footer=t,this.readonly&&t.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&t.classList.add(this.wrapClassName("float-footer")),this.pages.some(l=>l.thumbnail||!l.src.startsWith("ppt"))){const l=this.renderFooterBtn("btn-sidebar",ry(this.namespace));this.sideEffect.addEventListener(l,"click",()=>{this.readonly||this.togglePreview()}),this.$footer.appendChild(l)}const i=document.createElement("div");i.className=this.wrapClassName("page-jumps");const n=this.renderFooterBtn("btn-page-back",sy(this.namespace));if(this.sideEffect.addEventListener(n,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)}),i.appendChild(n),this.onPlay){const l=this.renderFooterBtn("btn-page-play",ay(this.namespace),ly(this.namespace)),u=()=>{this.sideEffect.setTimeout(()=>{l.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)},500,"returnPlay")};this.sideEffect.addEventListener(l,"click",()=>{this.readonly||(l.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),u())}),i.appendChild(l)}const r=this.renderFooterBtn("btn-page-next",oy(this.namespace));this.sideEffect.addEventListener(r,"click",()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)}),i.appendChild(r);const s=document.createElement("div");s.className=this.wrapClassName("page-number");const o=document.createElement("input");o.className=this.wrapClassName("page-number-input"),o.value=String(this.pageIndex+1),this.readonly&&(o.disabled=!0),this.$pageNumberInput=o,this.sideEffect.addEventListener(o,"focus",()=>{o.select()}),this.sideEffect.addEventListener(o,"change",()=>{this.readonly||o.value&&this.onNewPageIndex(Number(o.value)-1)});const a=document.createElement("span");a.textContent=" / "+this.pages.length,s.appendChild(o),s.appendChild(a),this.$footer.appendChild(i),this.$footer.appendChild(s)}return this.$footer}renderFooterBtn(t,i,n){const r=document.createElement("button");return r.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(t),r.appendChild(i),n&&r.appendChild(n),r}togglePreview(t){if(this.isShowPreview=t!=null?t:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const i=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));i&&this.$preview.scrollTo({top:i.offsetTop-16})}}wrapClassName(t){return`${this.namespace}-${t}`}}function nn(e,t,i){return Math.min(Math.max(e,t),i)}function Tc(e){return e.touches?e.touches[0]:e}function hf(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}function df(e){if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"}class mx{constructor(t){var i,n,r;this.velocity=0,this.paused=!0,this._animationFrameID=null,this._loopTimestamp=0,this.looper=s=>{if(this.paused)return;let o=Math.floor((s-this._loopTimestamp)/1e3*60)+1;for(this._loopTimestamp=s;o-- >0;)this.stepper();this.onStep(this.current,this),!this.paused&&this.current!==this.target&&window.requestAnimationFrame(this.looper)},this.current=(i=t.start)!=null?i:0,this.target=this.current,this.stiffness=(n=t.stiffness)!=null?n:170,this.damping=(r=t.damping)!=null?r:26,this.onStep=t.onStep}stepTo(t,i){this.paused&&i!=null&&(this.current=i),this.paused=!1,this.target=t,this.onStep(this.current,this),this._loopTimestamp=Date.now(),window.requestAnimationFrame(this.looper)}pause(){this.paused=!0}destroy(){this.pause()}stepper(){const t=-this.stiffness*(this.current-this.target),i=-this.damping*this.velocity,n=this.velocity+(t+i)/60,r=this.current+n/60;Math.abs(n-0)<.01&&Math.abs(r-this.target)<.01?(this.current=this.target,this.velocity=0):(this.current=r,this.velocity=n)}}class vx{constructor(t,i,n,r){this.scale=1,this.lastVisit=Date.now(),this.pageOffsetY=0,this.pageOffsetX=0,this.visible=!0,this.index=t,this.page=i,this.scale=n,this.pageOffsetX=(r-i.width)/2;const s=document.createElement("div");s.className="page-renderer-page",s.dataset.index=`${t}`,s.style.width=`${i.width*n}px`,s.style.height=`${i.height*n}px`,i.thumbnail&&(s.style.backgroundImage=`url("${i.thumbnail}")`);const o=document.createElement("img");o.className="page-renderer-page-img",o.width=i.width,o.height=i.height,o.src=i.src,s.appendChild(o),this.$page=s}translateY(t){Math.abs(t-this.pageOffsetY)>=.001&&(this.pageOffsetY=t,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setScale(t){Math.abs(t-this.scale)>=.001&&(this.scale=t,this.$page.style.width=`${this.page.width*this.scale}px`,this.$page.style.height=`${this.page.height*this.scale}px`,this.$page.style.transform=`translate(${this.pageOffsetX*this.scale}px, ${this.pageOffsetY*this.scale}px)`)}setVisible(t){t!==this.visible&&(this.visible=t,this.$page.style.opacity=t?"1":"0")}}const wx=window.requestIdleCallback||(e=>window.setTimeout(e,5e3)),yx=window.cancelIdleCallback||window.clearTimeout;class xx{constructor(t,i,n){this.pages=t,this.pagesIntrinsicWidth=i,this.scale=n,this.els=new Map,this.maxElCount=200,this.gcTimer=null,this.gc=()=>{if(this.gcTimer=null,this.els.size>this.maxElCount){const r=[...this.els.values()].sort((s,o)=>o.lastVisit-s.lastVisit);for(let s=Math.floor(this.maxElCount/4);s<r.length;s++)this.els.delete(r[s].index)}}}getEl(t){let i=this.els.get(t);return i||(i=new vx(t,this.pages[t],this.scale,this.pagesIntrinsicWidth),this.els.set(t,i)),i.lastVisit=Date.now(),this.els.size>this.maxElCount&&this.gcTimer===null&&(this.gcTimer=wx(this.gc)),i}setScale(t){t!==this.scale&&(this.scale=t,this.els.forEach(i=>i.setScale(t)))}destroy(){this.els.clear(),this.gcTimer!==null&&(yx(this.gcTimer),this.gcTimer=null)}}class Sx{constructor(t){this._hwaTimeout=NaN,this._turnOffHWA=()=>{window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN,this.$pages.classList.toggle("is-hwa",!1)},this.pagesScrollTop=t.pagesScrollTop||0,this.containerWidth=t.containerWidth||1,this.containerHeight=t.containerHeight||1,this.pages=t.pages.map(s=>{if(s.thumbnail)return s;try{const o=new URL(s.src);return o.searchParams.set("x-oss-process","image/resize,l_50"),{...s,thumbnail:o.toString()}}catch(o){return console.error(o),s}});const i=Array(this.pages.length);let n=1/0,r=0;this.pagesIntrinsicHeight=this.pages.reduce((s,o,a)=>(i[a]=s,o.width>r&&(r=o.width),o.height<=n&&(n=o.height),s+o.height),0),this.pagesIntrinsicWidth=r,this.pagesMinHeight=n,this.pagesIntrinsicYs=i,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.onPageIndexChanged=t.onPageIndexChanged,this.pageScrollIndex=0,this.pagesScrollTop!==0&&(this.pageScrollIndex=this.findScrollPageIndex(),this.onPageIndexChanged&&this.pageScrollIndex>0&&this.onPageIndexChanged(this.pageScrollIndex)),this.pageElManager=new xx(this.pages,r,this.scale),this.$pages=this.renderPages()}setContainerSize(t,i){t>0&&i>0&&(t!==this.containerWidth||i!==this.containerHeight)&&(this.containerWidth=t,this.containerHeight=i,this.$pages.style.width=`${this.containerWidth}px`,this.$pages.style.height=`${this.containerHeight}px`,this.scale=this._calcScale(),this.threshold=this._calcThreshold(),this.pageElManager.setScale(this.scale),this.$pages.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}renderPages(){const t=document.createElement("div");return t.className="page-renderer-pages-container",t.style.width=`${this.containerWidth}px`,t.style.height=`${this.containerHeight}px`,t}pagesScrollTo(t,i){if(t=nn(t,0,this.pagesIntrinsicHeight-this.containerHeight/this.scale),i||Math.abs(t-this.pagesScrollTop)>=.001){this._turnOnHWA(),this.pagesScrollTop=t;const n=this.findScrollPageIndex(),r=Math.max(n-this.threshold,0),s=Math.min(n+this.threshold,this.pages.length-1);for(let o=0;o<this.$pages.children.length;o++){const a=this.$pages.children[o],l=Number(a.dataset.index);l>=r&&l<=s||(a.remove(),o--)}for(let o=r;o<=s;o++){const a=this.pageElManager.getEl(o);a.$page.parentElement!==this.$pages&&this.$pages.appendChild(a.$page),a.translateY(this.pagesIntrinsicYs[o]-this.pagesScrollTop)}n!==this.pageScrollIndex&&(this.pageScrollIndex=n,this.onPageIndexChanged&&this.onPageIndexChanged(n))}}findScrollPageIndex(){for(let t=0;t<this.pagesIntrinsicYs.length;t++)if(this.pagesIntrinsicYs[t]+this.pages[t].height-this.pagesScrollTop>=.001)return t;return this.pagesIntrinsicYs.length-1}mount(t){t.appendChild(this.$pages),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$pages.remove()}destroy(){this.unmount(),this.onPageIndexChanged=void 0,this.pageElManager.destroy(),this._hwaTimeout&&(window.clearTimeout(this._hwaTimeout),this._hwaTimeout=NaN)}_calcScale(){return this.containerWidth/this.pagesIntrinsicWidth||1}_calcThreshold(){return nn(Math.ceil(this.containerHeight/this.scale/this.pagesMinHeight/2),1,this.pages.length)}_turnOnHWA(){this._hwaTimeout?window.clearTimeout(this._hwaTimeout):this.$pages.classList.toggle("is-hwa",!0),this._hwaTimeout=window.setTimeout(this._turnOffHWA,1e3)}}const Mx=30;class Cx{constructor(t){this.sideEffect=new io,this.pagesScrollTop=t.pagesScrollTop||0,this.containerWidth=t.containerWidth||1,this.containerHeight=t.containerHeight||1,this.pagesWidth=t.pagesWidth||1,this.pagesHeight=t.pagesHeight||1,this.scale=this._calcScale(),this.scrollbarMinHeight=t.scrollbarMinHeight||Mx,this.scrollbarHeight=this._calcScrollbarHeight(),this.readonly=t.readonly,this.wrapClassName=t.wrapClassName,this.onDragScroll=t.onDragScroll,this.$scrollbar=this.renderScrollbar()}mount(t){t.appendChild(this.$scrollbar),this.pagesScrollTo(this.pagesScrollTop,!0)}unmount(){this.$scrollbar.remove()}setReadonly(t){this.readonly=t}setContainerSize(t,i){t>0&&i>0&&(t!==this.containerWidth||i!==this.containerHeight)&&(this.containerWidth=t,this.containerHeight=i,this.scale=this._calcScale(),this._updateScrollbarHeight(),this.$scrollbar.parentElement&&this.pagesScrollTo(this.pagesScrollTop,!0))}pagesScrollTo(t,i){if(t=nn(t,0,this.pagesHeight-this.containerHeight/this.scale),i||Math.abs(t-this.pagesScrollTop)>=.001){this.pagesScrollTop=t;const n=this.pagesScrollTop*this.scale,r=this.pagesHeight*this.scale,s=n/(r-this.containerHeight)*(this.containerHeight-this.scrollbarHeight);window.requestAnimationFrame?window.requestAnimationFrame(()=>{this.$scrollbar.style.transform=`translateY(${s}px)`}):this.$scrollbar.style.transform=`translateY(${s}px)`}}destroy(){this.unmount(),this.onDragScroll=void 0,this.sideEffect.flushAll()}renderScrollbar(){const t=document.createElement("button");t.className=this.wrapClassName("scrollbar"),t.style.minHeight=`${this.scrollbarMinHeight}px`,t.style.height=`${this.scrollbarHeight}px`;const i=n=>{if(this.readonly||n.button!=null&&n.button!==0)return;hf(n);const r=this.wrapClassName("scrollbar-dragging");t.classList.toggle(r,!0);const s=this.pagesScrollTop,{clientY:o}=Tc(n),a=u=>{if(this.readonly)return;const{clientY:c}=Tc(u),h=(c-o)/this.scale;Math.abs(h)>0&&this.onDragScroll&&this.onDragScroll(s+h*(this.pagesHeight*this.scale/this.containerHeight))},l=()=>{t.classList.toggle(r,!1),window.removeEventListener("mousemove",a,!0),window.removeEventListener("touchmove",a,!0),window.removeEventListener("mouseup",l,!0),window.removeEventListener("touchend",l,!0),window.removeEventListener("touchcancel",l,!0)};window.addEventListener("mousemove",a,!0),window.addEventListener("touchmove",a,!0),window.addEventListener("mouseup",l,!0),window.addEventListener("touchend",l,!0),window.addEventListener("touchcancel",l,!0)};return this.sideEffect.addEventListener(t,"mousedown",i),this.sideEffect.addEventListener(t,"touchstart",i),t}_calcScale(){return this.containerWidth/this.pagesWidth||1}_calcScrollbarHeight(){return nn(this.containerHeight/(this.pagesHeight*this.scale)*this.containerHeight,this.scrollbarMinHeight,this.containerHeight)}_updateScrollbarHeight(){const t=this._calcScrollbarHeight();Math.abs(t-this.scrollbarHeight)>.001&&(this.scrollbarHeight=t,this.$scrollbar.style.height=`${t}px`)}}const bx=window.ResizeObserver||ny,xn=640;class Ix{constructor({context:t,whiteboardView:i,readonly:n,box:r,pages:s,pageScrollTop:o=0,mountWhiteboard:a,onUserScroll:l,baseScenePath:u,appId:c}){this.sideEffect=new io,this.userScrolling=!1,this.docsViewReadonly=!1,this.onNewPageIndex=w=>{this.scrollToPage(w)},this.toPdf=async()=>{const w=document.createElement("canvas"),x=w.getContext("2d");if(!x||!this.baseScenePath){this.reportProgress(100,null);return}const d=this.whiteboardView.focusScenePath||`${this.baseScenePath}/1`,f=this.pages[0],{jsPDF:g}=await Promise.resolve().then(function(){return $g(require("jspdf"))}),p=new g({format:[f.width,f.height],orientation:f.width>f.height?"l":"p",compress:!0});for(const[S,A]of this.pages.entries()){const{width:k,height:z,src:B}=A;w.width=k,w.height=z;const ee=k>z?"l":"p";S>0&&p.addPage([k,z],ee);const b=await this.getBase64FromUrl(B),M=document.createElement("img");M.src=b,await new Promise(Y=>M.onload=Y),x.drawImage(M,0,0);const V=w.toDataURL("image/png");x.clearRect(0,0,k,z);const D={centerX:k/2,centerY:z/2+S*z,scale:1},Z=this.context.manager.windowManger;Z._appliancePlugin?await Z._appliancePlugin.screenshotToCanvasAsync(x,d,k,z,D):this.whiteboardView.screenshotToCanvas(x,d,k,z,D);const te=w.toDataURL("image/png");p.addImage(V,"PNG",0,0,k,z,"","FAST"),p.addImage(te,"PNG",0,0,k,z,"","FAST"),x.clearRect(0,0,k,z),Math.ceil((S+1)/this.pages.length*100)<100&&this.reportProgress(Math.ceil((S+1)/this.pages.length*100),null)}const y=p.output("arraybuffer");this.reportProgress(100,{pdf:y,title:this.box.title})},this.context=t,this.whiteboardView=i,this.readonly=n,this.box=r,this.pages=s,this.baseScenePath=u,this.appId=c,this.mountWhiteboard=a,this._onUserScroll=l;const h=this.debounce(()=>{this.userScrolling=!1,this._onUserScroll&&this._onUserScroll(this.pageRenderer.pagesScrollTop)},{wait:80},"debounce-updateUserScroll");this.updateUserScroll=()=>{this.userScrolling=!0,h()},this.viewer=new cf({readonly:n,box:r,pages:s,onNewPageIndex:this.onNewPageIndex});const{width:m,height:v}=this.whiteboardView.size;this.pageRenderer=new Sx({pagesScrollTop:o,pages:this.pages,containerWidth:m,containerHeight:v,onPageIndexChanged:this.viewer.setPageIndex.bind(this.viewer)}),this.scrollbar=new Cx({pagesScrollTop:this.pageRenderer.pagesScrollTop,containerWidth:m,containerHeight:v,pagesWidth:this.pageRenderer.pagesIntrinsicWidth,pagesHeight:this.pageRenderer.pagesIntrinsicHeight,readonly:this.readonly,wrapClassName:this.wrapClassName.bind(this),onDragScroll:w=>{this.pageScrollTo(w),this.updateUserScroll()}}),this.pageScrollStepper=new mx({start:this.pageRenderer.pagesScrollTop,onStep:w=>{this.pageScrollTo(w)}}),this.render()}setDocsViewReadonly(t){this.docsViewReadonly=t}mount(){this.viewer.mount(),this.setupScrollListener();const t=this.debounce(this.renderRatioHeight.bind(this),{wait:80});return this.sideEffect.add(()=>{const i=new bx(t);return i.observe(this.viewer.$content),()=>i.disconnect()}),this.sideEffect.setTimeout(()=>{this.userScrolling||this.pageScrollTo(this.pageRenderer.pagesScrollTop)},100),this.sideEffect.add(()=>{const i=n=>{n.data.type==="@netless/_request_save_pdf_"&&n.data.appId===this.appId&&this.toPdf().catch(()=>this.reportProgress(100,null))};return window.addEventListener("message",i),()=>{window.removeEventListener("message",i)}}),this}unmount(){return this.viewer.unmount(),this}setReadonly(t){this.readonly!==t&&(this.readonly=t,this.viewer.setReadonly(t),this.scrollbar.setReadonly(t))}destroy(){this.sideEffect.flushAll(),this.pageScrollStepper.destroy(),this._onUserScroll=void 0,this.unmount(),this.viewer.destroy(),this.pageRenderer.destroy(),this.scrollbar.destroy()}syncPageScrollTop(t){!this.userScrolling&&t>=0&&Math.abs(this.pageRenderer.pagesScrollTop-t)>.01&&this.pageScrollStepper.stepTo(t,this.pageRenderer.pagesScrollTop)}render(){this.pageRenderer.mount(this.viewer.$content),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.scrollbar.mount(this.viewer.$content),this.renderRatioHeight()}renderRatioHeight(){const t=this.box.absoluteHeight,i=t<=xn;if(this.viewer.setSmallBox(i),i){const n=26/xn,r=26/t,s=26/xn,o=0,a=Math.max((n+s-(r+o))/2,0);if(this.box.$titleBar){const l=r+a;this.box.$titleBar.style.height=`${l*100}%`}if(this.box.$footer){const l=o+a;this.box.$footer.style.height=`${l*100}%`}}else{if(this.box.$titleBar){const n=Math.max(26/xn,26/t);this.box.$titleBar.style.height=`${n*100}%`}if(this.box.$footer){const n=Math.max(26/xn,26/t);this.box.$footer.style.height=`${n*100}%`}}}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",t=>{hf(t),this.readonly||(this.pageScrollTo(this.pageRenderer.pagesScrollTop+t.deltaY),this.updateUserScroll())},{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",t=>{this.readonly||t.touches.length<=1||this.updateUserScroll()},{passive:!0,capture:!0})),this.$whiteboardView}scrollTopPageToEl(t){return t*this.pageRenderer.scale}scrollTopElToPage(t){return t/this.pageRenderer.scale}elScrollTo(t){this.pageScrollTo(this.scrollTopElToPage(t))}pageScrollTo(t){const i=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:nn(t+i,i,this.pageRenderer.pagesIntrinsicHeight-i),animationMode:"immediately"})}scrollToPage(t){if(!this.readonly&&!Number.isNaN(t)){const i=this.pageRenderer.pagesIntrinsicYs[t];i>=0&&(this.pageScrollTo(i+5/this.pageRenderer.scale),this.updateUserScroll())}}setupScrollListener(){this.sideEffect.add(()=>{const t=i=>{const{width:n,height:r}=this.whiteboardView.size;if(n<=0||r<=0)return;const s=i.centerY-this.pageRenderer.containerHeight/this.pageRenderer.scale/2;this.pageRenderer.pagesScrollTo(s),this.scrollbar.pagesScrollTo(s)};return this.whiteboardView.callbacks.on("onCameraUpdated",t),()=>this.whiteboardView.callbacks.off("onCameraUpdated",t)}),this.sideEffect.add(()=>{const{updateUserScroll:t}=this;return this.whiteboardView.callbacks.on("onCameraUpdatedByDevice",t),()=>this.whiteboardView.callbacks.off("onCameraUpdatedByDevice",t)}),this.sideEffect.add(()=>{const t=({width:i,height:n})=>{if(i<=0||n<=0)return;this.pageRenderer.setContainerSize(i,n),this.scrollbar.setContainerSize(i,n);const{pagesIntrinsicWidth:r,pagesIntrinsicHeight:s}=this.pageRenderer;this.whiteboardView.moveCameraToContain({originX:0,originY:this.pageRenderer.pagesScrollTop,width:r,height:n/this.pageRenderer.scale,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.pageRenderer.scale,minContentMode:()=>this.pageRenderer.scale,centerX:r/2,centerY:s/2,width:r,height:s})};return this.whiteboardView.callbacks.on("onSizeUpdated",t),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",t)}},"whiteboard-size-update"),this.sideEffect.addEventListener(window,"keyup",t=>{if(this.readonly||!this.box.focus||this.box.minimized||df(t.target)||this.docsViewReadonly)return;let i=null;switch(t.key){case"PageDown":{i=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"PageUp":{i=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/this.pageRenderer.scale;break}case"ArrowDown":{i=this.pageRenderer.pagesScrollTop+this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}case"ArrowUp":{i=this.pageRenderer.pagesScrollTop-this.pageRenderer.containerHeight/4/this.pageRenderer.scale;break}}i!==null&&(this._onUserScroll?this._onUserScroll(i):(this.pageScrollTo(i),this.updateUserScroll()))},{capture:!0})}debounce(t,i,n){const r=Pw(t,i);return this.sideEffect.addDisposer(()=>r.cancel(),n),r}wrapClassName(t){return"netless-app-docs-viewer-static-"+t}async getBase64FromUrl(t){const n=await(await fetch(this._invalidate(t))).blob();return new Promise(r=>{const s=new FileReader;s.readAsDataURL(n),s.onloadend=()=>{const o=s.result;r(o)}})}_invalidate(t){try{const i=new URL(t);return i.searchParams.set("t",Date.now().toString()),i.toString()}catch{return t}}reportProgress(t,i){window.postMessage({type:"@netless/_result_save_pdf_",appId:this.appId,progress:t,result:i})}}class Tx{constructor({context:t,whiteboardView:i,box:n,pages:r}){this.sideEffect=new io,this.docsViewReadonly=!1,this.onPlayPPT=()=>{const s=this.context.getRoom();s&&s.pptNextStep()},this._scaleDocsToFitImpl=()=>{const s=this.pages[this.getPageIndex()];s&&(this.whiteboardView.moveCameraToContain({originX:-s.width/2,originY:-s.height/2,width:s.width,height:s.height,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>this.whiteboardView.camera.scale,minContentMode:()=>this.whiteboardView.camera.scale,centerX:0,centerY:0,width:s.width,height:s.height}))},this._scaleDocsToFitDebounced=()=>{this.sideEffect.setTimeout(this._scaleDocsToFitImpl,1e3,"_scaleDocsToFitDebounced")},this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=s=>{this.jumpToPage(s,!0)},this.context=t,this.whiteboardView=i,this.box=n,this.pages=r,this.displayer=t.getDisplayer(),this.viewer=new cf({readonly:!t.getIsWritable(),box:n,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render(),this.sideEffect.add(()=>{const s=o=>{this.viewer.setReadonly(!o)};return this.context.emitter.on("writableChange",s),()=>this.context.emitter.off("writableChange",s)}),this.sideEffect.add(()=>{const s=o=>{this.jumpToPage(o.index)};return this.context.emitter.on("sceneStateChange",s),()=>this.context.emitter.off("sceneStateChange",s)})}setDocsViewReadonly(t){this.docsViewReadonly=t}mount(){this.viewer.mount();const t=this.getPageIndex();return t!==0&&this.jumpToPage(t),this.scaleDocsToFit(),this.sideEffect.add(()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)})),this}unmount(){return this.viewer.unmount(),this}destroy(){this.sideEffect.flushAll(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(t,i){var n,r;if(t=nn(t,0,this.pages.length-1),t!==this.getPageIndex()&&this.context.getIsWritable()){const s=this.context.getInitScenePath(),o=(r=(n=this.context.getScenes())==null?void 0:n[t])==null?void 0:r.name;s&&o&&this.context.setScenePath(`${s}/${o}`),this.scaleDocsToFit()}if(t!==this.viewer.pageIndex&&this.viewer.setPageIndex(t),i){const s=this.context.getRoom();if(s){const o=s.state.globalState.__pptState;s.setGlobalState({__pptState:o&&{uuid:o.uuid,pageIndex:t,disableAutoPlay:o.disableAutoPlay}})}}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",t=>{var i;if(!this.docsViewReadonly&&this.box.focus&&!df(t.target))switch(t.key){case"ArrowUp":case"ArrowLeft":{this.jumpToPage(this.getPageIndex()-1,!0);break}case"ArrowRight":case"ArrowDown":{(i=this.context.getRoom())==null||i.pptNextStep();break}}})}renderMask(){if(!this.$mask){const t=document.createElement("div");t.className=this.wrapClassName("mask"),this.$mask=t;const i=document.createElement("button");i.className=this.wrapClassName("back");const n=document.createElement("button");n.className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",t=>{var i;const n=this.context.getRoom();if(n&&n.state.memberState.currentApplianceName==="clicker"){for(let r=t.target;r;r=r.parentElement)if((i=r.classList)!=null&&i.contains("ppt-event-source"))return;n.pptNextStep()}}),this.context.mountView(this.$whiteboardView)),this.$whiteboardView}wrapClassName(t){return"netless-app-docs-viewer-dynamic-"+t}}const Ax="DocsViewer",ga={kind:Ax,setup(e){const t=e.getBox(),i=e.getScenes();if(!i)throw new Error("[Docs Viewer]: scenes not found.");const n=e.getView();if(!n)throw new Error("[Docs Viewer]: no whiteboard view.");const r=i.map(({ppt:a})=>a?{width:a.width,height:a.height,src:a.src,thumbnail:a.previewURL}:null).filter(a=>Boolean(a));if(r.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(Mw);let s=null;return r[0].src.startsWith("ppt")?s=Nx(e,n,t,r):s=Ex(e,n,t,r),(e.getAppOptions()||{}).justDocsViewReadonly&&s.setDocsViewReadonly(!0),{setDocsViewReadonly:a=>{s==null||s.setDocsViewReadonly(a)}}}};function Ex(e,t,i,n){var r;t.disableCameraTransform=!e.getIsWritable();const s=new Ix({context:e,whiteboardView:t,readonly:!e.getIsWritable(),box:i,pages:n,pageScrollTop:(r=e.getAttributes())==null?void 0:r.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:o=>{var a;((a=e.getAttributes())==null?void 0:a.pageScrollTop)!==o&&!i.readonly&&e.updateAttributes(["pageScrollTop"],o)},baseScenePath:e.getInitScenePath(),appId:e.appId}).mount();return s.viewer.onPageIndexChanged=o=>{e.dispatchAppEvent("pageStateChange",{index:o,length:n.length})},e.dispatchAppEvent("pageStateChange",{index:s.viewer.pageIndex,length:n.length}),e.emitter.on("attributesUpdate",o=>{o&&o.pageScrollTop!=null&&s.syncPageScrollTop(o.pageScrollTop)}),e.emitter.on("writableChange",o=>{s.setReadonly(!o),t.disableCameraTransform=!o}),s}function Nx(e,t,i,n){t.disableCameraTransform=!0;const r=new Tx({context:e,whiteboardView:t,box:i,pages:n}).mount();return r.viewer.onPageIndexChanged=s=>{e.dispatchAppEvent("pageStateChange",{index:s,length:n.length})},e.dispatchAppEvent("pageStateChange",{index:r.getPageIndex(),length:n.length}),e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",({width:s,height:o})=>{if(n.length>0&&i.state!=="maximized"){const{width:a,height:l}=n[0],c=l/a*s-o;c!==0&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:i.width,height:i.height+c/i.containerRect.height})}}),r}const kx=async()=>{const e=await Promise.resolve().then(function(){return mM});return Q.debug&&e.setOptions({verbose:!0}),e.default||e},Px=()=>{Q.register({kind:ga.kind,src:ga}),Q.register({kind:"MediaPlayer",src:kx})},zx={DocsViewer:ga.kind,MediaPlayer:"MediaPlayer"};const zt={Ready:"Ready",RootRect:"ReplayRootRect",Message:"message",ComputeStyle:"computeStyle",Load:"load",DisplayerState:"displayerState",Show:"show",Hide:"hide"},Bx=(e,t)=>new Array(e).fill(0).map((i,n)=>t(n)),K=class{constructor(e,t){this.manager=e,this.appManager=t,this.magixEventMap=new Map,this.cssList=[],this.allowAppliances=["clicker"],this.bridgeDisposer=E.noop,this.rootRect=null,this.sideEffectManager=new dr,this.execListenIframe=E.debounce(i=>{this.listenIframe(i)},50),this.onPhaseChangedListener=i=>{i===I.PlayerPhase.Playing&&this.computedStyleAndIframeDisplay()},this.stateChangeListener=i=>{i={...i},i.cameraState=this.manager.cameraState,this.postMessage({kind:"RoomStateChanged",payload:i}),i.cameraState&&(K.emitter.emit("GetRootRect"),this.computedStyle(i)),i.memberState&&(this.computedZindex(),this.updateStyle()),i.sceneState&&this.computedIframeDisplay(i,this.attributes)},this.displayer=K.displayer=t.displayer,this.iframe=this._createIframe(),this.sideEffectManager.addDisposer(K.emitter.on("ReplayRootRect",i=>{this.rootRect=i}),zt.RootRect),this.sideEffectManager.addDisposer(K.emitter.on("HideIframe",()=>{this.iframe.className=K.hiddenClass}),zt.Hide),this.sideEffectManager.addDisposer(K.emitter.on("DispayIframe",()=>{this.iframe.className=""}),zt.Show),this.sideEffectManager.addDisposer(K.emitter.on("created",()=>{this.bridgeDisposer(),this.bridgeDisposer=I.autorun(()=>{var n;const i=this.attributes;if(i.url){const r=(n=this.iframe)==null?void 0:n.src;r&&r!==i.url&&this.execListenIframe(i)}i.displaySceneDir&&this.computedIframeDisplay(this.displayer.state,i),(i.width||i.height)&&this.iframe&&(this.iframe.width=`${i.width}px`,this.iframe.height=`${i.height}px`),this.postMessage({kind:"AttributesUpdate",payload:i})})})),this.sideEffectManager.addDisposer(e.emitter.on("cameraStateChange",()=>{this.computedStyle(this.displayer.state)})),K.onCreate(this)}static onCreate(e){K.emitter.emit("StartCreate"),K.emitter.emit("OnCreate",e),K.emitter.emit("created")}insert(e){const t={url:e.url,width:e.width,height:e.height,displaySceneDir:e.displaySceneDir,useClicker:e.useClicker||!1,useSelector:e.useSelector};this.setAttributes(t);const i=()=>{this.getIframe(),this.listenIframe(this.attributes),this.listenDisplayerState(),K.emitter.emit("GetRootRect")};if(this.getIframe())i();else{const n=this.sideEffectManager.addDisposer(K.emitter.on("WrapperDidMount",()=>{i(),this.sideEffectManager.flush(n)})),r=this.sideEffectManager.addDisposer(K.emitter.on("WrapperDidUpdate",()=>{i(),this.sideEffectManager.flush(r)}))}return this.attributes.useSelector&&this.allowAppliances.push("selector"),this.computedStyle(this.displayer.state),this.listenDisplayerCallbacks(),this.getComputedIframeStyle(),this.sideEffectManager.addEventListener(window,"message",this.messageListener.bind(this),void 0,zt.Message),K.alreadyCreate=!0,this}getComputedIframeStyle(){this.sideEffectManager.setTimeout(()=>{this.iframe&&getComputedStyle(this.iframe)},200,zt.ComputeStyle)}destroy(){this.sideEffectManager.flushAll(),K.emitter.emit("Destory"),K.alreadyCreate=!1,K.emitter.clearListeners()}getIframe(){return this.iframe||(this.iframe=this._createIframe()),this.iframe}setIframeSize(e){this.iframe&&(this.iframe.width=`${e.width}px`,this.iframe.height=`${e.height}px`,this.setAttributes({width:e.width,height:e.height}))}get attributes(){return this.appManager.store.getIframeBridge()}setAttributes(e){this.appManager.store.setIframeBridge(e)}_createIframe(){const e=document.createElement("iframe");return e.id="IframeBridge",e.className=K.hiddenClass,this.appManager.mainView.divElement&&this.appManager.mainView.divElement.appendChild(e),e}scaleIframeToFit(e=I.AnimationMode.Immediately){if(!this.inDisplaySceneDir)return;const{width:t=1280,height:i=720}=this.attributes,n=t?-t/2:0,r=i?-i/2:0;this.manager.moveCameraToContain({originX:n,originY:r,width:t,height:i,animationMode:e})}get isReplay(){return this.manager.isReplay}handleSetPage(e){if(this.isReplay||!this.attributes.displaySceneDir)return;const t=e.payload,i=this.displayer,n=i.entireScenes()[this.attributes.displaySceneDir];if(!n||n.length!==t){const r=Bx(t,s=>({name:String(s+1)}));i.putScenes(this.attributes.displaySceneDir,r),this.manager.setMainViewScenePath(this.attributes.displaySceneDir)}}listenIframe(e){const t=i=>{var n;this.postMessage({kind:"Init",payload:{attributes:this.attributes,roomState:(n=K.displayer)==null?void 0:n.state,currentPage:this.currentPage,observerId:this.displayer.observerId}}),K.emitter.emit("IframeLoad",i),this.sideEffectManager.addDisposer(K.emitter.on("Ready",()=>{var r;this.postMessage((r=this.attributes.lastEvent)==null?void 0:r.payload)}),zt.Ready),this.computedStyleAndIframeDisplay()};e.url&&this.iframe.src!==e.url&&(this.src_url_equal_anchor||(this.src_url_equal_anchor=document.createElement("a")),this.src_url_equal_anchor.href=e.url,this.src_url_equal_anchor.href!==this.iframe.src&&(this.iframe.src=e.url)),this.iframe.width=`${e.width}px`,this.iframe.height=`${e.height}px`,this.sideEffectManager.addEventListener(this.iframe,"load",t,void 0,zt.Load)}listenDisplayerState(){this.isReplay&&(this.displayer._phase===I.PlayerPhase.Playing&&this.computedStyleAndIframeDisplay(),this.sideEffectManager.add(()=>(this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChangedListener),()=>this.displayer.callbacks.off("onPhaseChanged",this.onPhaseChangedListener)),zt.DisplayerState)),this.computedStyleAndIframeDisplay()}computedStyleAndIframeDisplay(){this.computedStyle(this.displayer.state),this.computedIframeDisplay(this.displayer.state,this.attributes)}listenDisplayerCallbacks(){this.displayer.callbacks.on(this.callbackName,this.stateChangeListener)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}computedStyle(e){const t=this.manager.cameraState,i=this.attributes.width||1280,n=this.attributes.height||720;if(this.iframe){const{width:r,height:s,scale:o,centerX:a,centerY:l}=t,u=this.rootRect||{x:0,y:0},c=`${r/2+u.x}px`,h=`${s/2+u.y}px`,m=`transform-origin: ${c} ${h};`,v=(r-i)/2*o,w=(s-n)/2*o,x=-(a*o)+v,d=-(l*o)+w,f=`transform: translate(${x}px,${d}px) scale(${o}, ${o});`,A=["position: absolute;","border: 0.1px solid rgba(0,0,0,0);","top: 0px;","left: 0px;",m,f];this.cssList=A,this.computedZindex(),this.updateStyle()}}computedIframeDisplay(e,t){this.inDisplaySceneDir?K.emitter.emit("DispayIframe"):K.emitter.emit("HideIframe")}computedZindex(){const e="z-index: -1;",t=this.cssList.findIndex(i=>i===e);t!==-1&&this.cssList.splice(t,1),(!this.isClicker()||this.isDisableInput)&&this.cssList.push(e)}updateStyle(){this.iframe.style.cssText=this.cssList.join(" ")}get iframeOrigin(){if(this.iframe)try{return new URL(this.iframe.src).origin}catch(e){console.warn(e)}}messageListener(e){if(et("<<<",JSON.stringify(e.data)),e.origin!==this.iframeOrigin)return;const t=e.data;switch(t.kind){case"SetAttributes":{this.handleSetAttributes(t);break}case"RegisterMagixEvent":{this.handleRegisterMagixEvent(t);break}case"RemoveMagixEvent":{this.handleRemoveMagixEvent(t);break}case"DispatchMagixEvent":{this.handleDispatchMagixEvent(t);break}case"RemoveAllMagixEvent":{this.handleRemoveAllMagixEvent();break}case"NextPage":{this.handleNextPage();break}case"PrevPage":{this.handlePrevPage();break}case"SDKCreate":{this.handleSDKCreate();break}case"SetPage":{this.handleSetPage(t);break}case"GetAttributes":{this.handleGetAttributes();break}case"PageTo":{this.handlePageTo(t);break}default:{et(`${t.kind} not allow event.`);break}}}handleSDKCreate(){this.postMessage({kind:"Init",payload:{attributes:this.attributes,roomState:this.displayer.state,currentPage:this.currentPage,observerId:this.displayer.observerId}})}handleDispatchMagixEvent(e){const t=e.payload;this.appManager.safeDispatchMagixEvent(t.event,t.payload)}handleSetAttributes(e){this.setAttributes(e.payload)}handleRegisterMagixEvent(e){const t=e.payload,i=n=>{n.authorId!==this.displayer.observerId&&this.postMessage({kind:"ReciveMagixEvent",payload:n})};this.magixEventMap.set(t,i),this.displayer.addMagixEventListener(t,i)}handleRemoveMagixEvent(e){const t=e.payload,i=this.magixEventMap.get(t);this.displayer.removeMagixEventListener(t,i)}handleNextPage(){this.manager.canOperate&&(this.manager.nextPage(),this.dispatchMagixEvent("NextPage",{}))}handlePrevPage(){this.manager.canOperate&&(this.manager.prevPage(),this.dispatchMagixEvent("PrevPage",{}))}handlePageTo(e){if(this.manager.canOperate){const t=e.payload;if(!Number.isSafeInteger(t)||t<=0)return;this.manager.setMainViewSceneIndex(t-1),this.dispatchMagixEvent("PageTo",t-1)}}handleRemoveAllMagixEvent(){this.magixEventMap.forEach((e,t)=>{this.displayer.removeMagixEventListener(t,e)}),this.magixEventMap.clear()}handleGetAttributes(){this.postMessage({kind:"GetAttributes",payload:this.attributes})}postMessage(e){var t;this.iframe&&((t=this.iframe.contentWindow)==null||t.postMessage(JSON.parse(JSON.stringify(e)),"*"))}dispatchMagixEvent(e,t){this.manager.canOperate&&(this.setAttributes({lastEvent:{name:e,payload:t}}),this.displayer.dispatchMagixEvent(e,t))}get currentIndex(){return this.manager.mainViewSceneIndex}get currentPage(){return this.currentIndex+1}get totalPage(){return this.manager.mainViewScenesLength}get readonly(){return!this.displayer.isWritable}get inDisplaySceneDir(){return this.manager.mainViewSceneDir===this.attributes.displaySceneDir}isClicker(){if(this.readonly)return!1;const e=this.displayer.state.memberState.currentApplianceName;return this.allowAppliances.includes(e)}get isDisableInput(){return"disableDeviceInputs"in this.displayer?this.displayer.disableDeviceInputs:!0}};let dn=K;dn.kind="IframeBridge";dn.hiddenClass="netless-iframe-brdige-hidden";dn.emitter=new Ti.default;dn.displayer=null;dn.alreadyCreate=!1;var Ei={exports:{}},J={};/*
19
- object-assign
20
- (c) Sindre Sorhus
21
- @license MIT
22
- */var Ac=Object.getOwnPropertySymbols,Dx=Object.prototype.hasOwnProperty,Lx=Object.prototype.propertyIsEnumerable;function Rx(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function jx(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var t={},i=0;i<10;i++)t["_"+String.fromCharCode(i)]=i;var n=Object.getOwnPropertyNames(t).map(function(s){return t[s]});if(n.join("")!=="0123456789")return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(s){r[s]=s}),Object.keys(Object.assign({},r)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}var ff=jx()?Object.assign:function(e,t){for(var i,n=Rx(e),r,s=1;s<arguments.length;s++){i=Object(arguments[s]);for(var o in i)Dx.call(i,o)&&(n[o]=i[o]);if(Ac){r=Ac(i);for(var a=0;a<r.length;a++)Lx.call(i,r[a])&&(n[r[a]]=i[r[a]])}}return n};/** @license React v16.14.0
23
- * react.production.min.js
24
- *
25
- * Copyright (c) Facebook, Inc. and its affiliates.
26
- *
27
- * This source code is licensed under the MIT license found in the
28
- * LICENSE file in the root directory of this source tree.
29
- */var jl=ff,nt=typeof Symbol=="function"&&Symbol.for,Ir=nt?Symbol.for("react.element"):60103,_x=nt?Symbol.for("react.portal"):60106,Vx=nt?Symbol.for("react.fragment"):60107,Ox=nt?Symbol.for("react.strict_mode"):60108,$x=nt?Symbol.for("react.profiler"):60114,Ux=nt?Symbol.for("react.provider"):60109,Wx=nt?Symbol.for("react.context"):60110,Hx=nt?Symbol.for("react.forward_ref"):60112,Fx=nt?Symbol.for("react.suspense"):60113,Qx=nt?Symbol.for("react.memo"):60115,Zx=nt?Symbol.for("react.lazy"):60116,Ec=typeof Symbol=="function"&&Symbol.iterator;function Tr(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var pf={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},gf={};function fn(e,t,i){this.props=e,this.context=t,this.refs=gf,this.updater=i||pf}fn.prototype.isReactComponent={};fn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error(Tr(85));this.updater.enqueueSetState(this,e,t,"setState")};fn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function mf(){}mf.prototype=fn.prototype;function _l(e,t,i){this.props=e,this.context=t,this.refs=gf,this.updater=i||pf}var Vl=_l.prototype=new mf;Vl.constructor=_l;jl(Vl,fn.prototype);Vl.isPureReactComponent=!0;var Ol={current:null},vf=Object.prototype.hasOwnProperty,wf={key:!0,ref:!0,__self:!0,__source:!0};function yf(e,t,i){var n,r={},s=null,o=null;if(t!=null)for(n in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)vf.call(t,n)&&!wf.hasOwnProperty(n)&&(r[n]=t[n]);var a=arguments.length-2;if(a===1)r.children=i;else if(1<a){for(var l=Array(a),u=0;u<a;u++)l[u]=arguments[u+2];r.children=l}if(e&&e.defaultProps)for(n in a=e.defaultProps,a)r[n]===void 0&&(r[n]=a[n]);return{$$typeof:Ir,type:e,key:s,ref:o,props:r,_owner:Ol.current}}function Yx(e,t){return{$$typeof:Ir,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function $l(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ir}function Gx(e){var t={"=":"=0",":":"=2"};return"$"+(""+e).replace(/[=:]/g,function(i){return t[i]})}var xf=/\/+/g,bs=[];function Sf(e,t,i,n){if(bs.length){var r=bs.pop();return r.result=e,r.keyPrefix=t,r.func=i,r.context=n,r.count=0,r}return{result:e,keyPrefix:t,func:i,context:n,count:0}}function Mf(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>bs.length&&bs.push(e)}function ma(e,t,i,n){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(r){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case Ir:case _x:s=!0}}if(s)return i(n,e,t===""?"."+Lo(e,0):t),1;if(s=0,t=t===""?".":t+":",Array.isArray(e))for(var o=0;o<e.length;o++){r=e[o];var a=t+Lo(r,o);s+=ma(r,a,i,n)}else if(e===null||typeof e!="object"?a=null:(a=Ec&&e[Ec]||e["@@iterator"],a=typeof a=="function"?a:null),typeof a=="function")for(e=a.call(e),o=0;!(r=e.next()).done;)r=r.value,a=t+Lo(r,o++),s+=ma(r,a,i,n);else if(r==="object")throw i=""+e,Error(Tr(31,i==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":i,""));return s}function va(e,t,i){return e==null?0:ma(e,"",t,i)}function Lo(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Gx(e.key):t.toString(36)}function Xx(e,t){e.func.call(e.context,t,e.count++)}function Jx(e,t,i){var n=e.result,r=e.keyPrefix;e=e.func.call(e.context,t,e.count++),Array.isArray(e)?wa(e,n,i,function(s){return s}):e!=null&&($l(e)&&(e=Yx(e,r+(!e.key||t&&t.key===e.key?"":(""+e.key).replace(xf,"$&/")+"/")+i)),n.push(e))}function wa(e,t,i,n,r){var s="";i!=null&&(s=(""+i).replace(xf,"$&/")+"/"),t=Sf(t,s,n,r),va(e,Jx,t),Mf(t)}var Cf={current:null};function Nt(){var e=Cf.current;if(e===null)throw Error(Tr(321));return e}var Kx={ReactCurrentDispatcher:Cf,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:Ol,IsSomeRendererActing:{current:!1},assign:jl};J.Children={map:function(e,t,i){if(e==null)return e;var n=[];return wa(e,n,null,t,i),n},forEach:function(e,t,i){if(e==null)return e;t=Sf(null,null,t,i),va(e,Xx,t),Mf(t)},count:function(e){return va(e,function(){return null},null)},toArray:function(e){var t=[];return wa(e,t,null,function(i){return i}),t},only:function(e){if(!$l(e))throw Error(Tr(143));return e}};J.Component=fn;J.Fragment=Vx;J.Profiler=$x;J.PureComponent=_l;J.StrictMode=Ox;J.Suspense=Fx;J.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Kx;J.cloneElement=function(e,t,i){if(e==null)throw Error(Tr(267,e));var n=jl({},e.props),r=e.key,s=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,o=Ol.current),t.key!==void 0&&(r=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)vf.call(t,l)&&!wf.hasOwnProperty(l)&&(n[l]=t[l]===void 0&&a!==void 0?a[l]:t[l])}var l=arguments.length-2;if(l===1)n.children=i;else if(1<l){a=Array(l);for(var u=0;u<l;u++)a[u]=arguments[u+2];n.children=a}return{$$typeof:Ir,type:e.type,key:r,ref:s,props:n,_owner:o}};J.createContext=function(e,t){return t===void 0&&(t=null),e={$$typeof:Wx,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider={$$typeof:Ux,_context:e},e.Consumer=e};J.createElement=yf;J.createFactory=function(e){var t=yf.bind(null,e);return t.type=e,t};J.createRef=function(){return{current:null}};J.forwardRef=function(e){return{$$typeof:Hx,render:e}};J.isValidElement=$l;J.lazy=function(e){return{$$typeof:Zx,_ctor:e,_status:-1,_result:null}};J.memo=function(e,t){return{$$typeof:Qx,type:e,compare:t===void 0?null:t}};J.useCallback=function(e,t){return Nt().useCallback(e,t)};J.useContext=function(e,t){return Nt().useContext(e,t)};J.useDebugValue=function(){};J.useEffect=function(e,t){return Nt().useEffect(e,t)};J.useImperativeHandle=function(e,t,i){return Nt().useImperativeHandle(e,t,i)};J.useLayoutEffect=function(e,t){return Nt().useLayoutEffect(e,t)};J.useMemo=function(e,t){return Nt().useMemo(e,t)};J.useReducer=function(e,t,i){return Nt().useReducer(e,t,i)};J.useRef=function(e){return Nt().useRef(e)};J.useState=function(e){return Nt().useState(e)};J.version="16.14.0";Ei.exports=J;var F=Ei.exports,bf={exports:{}},Xe={},If={exports:{}},Tf={};/** @license React v0.19.1
30
- * scheduler.production.min.js
31
- *
32
- * Copyright (c) Facebook, Inc. and its affiliates.
33
- *
34
- * This source code is licensed under the MIT license found in the
35
- * LICENSE file in the root directory of this source tree.
36
- */(function(e){var t,i,n,r,s;if(typeof window=="undefined"||typeof MessageChannel!="function"){var o=null,a=null,l=function(){if(o!==null)try{var T=e.unstable_now();o(!0,T),o=null}catch(R){throw setTimeout(l,0),R}},u=Date.now();e.unstable_now=function(){return Date.now()-u},t=function(T){o!==null?setTimeout(t,0,T):(o=T,setTimeout(l,0))},i=function(T,R){a=setTimeout(T,R)},n=function(){clearTimeout(a)},r=function(){return!1},s=e.unstable_forceFrameRate=function(){}}else{var c=window.performance,h=window.Date,m=window.setTimeout,v=window.clearTimeout;if(typeof console!="undefined"){var w=window.cancelAnimationFrame;typeof window.requestAnimationFrame!="function"&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),typeof w!="function"&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills")}if(typeof c=="object"&&typeof c.now=="function")e.unstable_now=function(){return c.now()};else{var x=h.now();e.unstable_now=function(){return h.now()-x}}var d=!1,f=null,g=-1,p=5,y=0;r=function(){return e.unstable_now()>=y},s=function(){},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):p=0<T?Math.floor(1e3/T):5};var S=new MessageChannel,A=S.port2;S.port1.onmessage=function(){if(f!==null){var T=e.unstable_now();y=T+p;try{f(!0,T)?A.postMessage(null):(d=!1,f=null)}catch(R){throw A.postMessage(null),R}}else d=!1},t=function(T){f=T,d||(d=!0,A.postMessage(null))},i=function(T,R){g=m(function(){T(e.unstable_now())},R)},n=function(){v(g),g=-1}}function k(T,R){var H=T.length;T.push(R);e:for(;;){var ie=H-1>>>1,ne=T[ie];if(ne!==void 0&&0<ee(ne,R))T[ie]=R,T[H]=ne,H=ie;else break e}}function z(T){return T=T[0],T===void 0?null:T}function B(T){var R=T[0];if(R!==void 0){var H=T.pop();if(H!==R){T[0]=H;e:for(var ie=0,ne=T.length;ie<ne;){var Je=2*(ie+1)-1,Qe=T[Je],ti=Je+1,Pt=T[ti];if(Qe!==void 0&&0>ee(Qe,H))Pt!==void 0&&0>ee(Pt,Qe)?(T[ie]=Pt,T[ti]=H,ie=ti):(T[ie]=Qe,T[Je]=H,ie=Je);else if(Pt!==void 0&&0>ee(Pt,H))T[ie]=Pt,T[ti]=H,ie=ti;else break e}}return R}return null}function ee(T,R){var H=T.sortIndex-R.sortIndex;return H!==0?H:T.id-R.id}var b=[],M=[],V=1,D=null,Z=3,te=!1,he=!1,Y=!1;function ke(T){for(var R=z(M);R!==null;){if(R.callback===null)B(M);else if(R.startTime<=T)B(M),R.sortIndex=R.expirationTime,k(b,R);else break;R=z(M)}}function ki(T){if(Y=!1,ke(T),!he)if(z(b)!==null)he=!0,t(ei);else{var R=z(M);R!==null&&i(ki,R.startTime-T)}}function ei(T,R){he=!1,Y&&(Y=!1,n()),te=!0;var H=Z;try{for(ke(R),D=z(b);D!==null&&(!(D.expirationTime>R)||T&&!r());){var ie=D.callback;if(ie!==null){D.callback=null,Z=D.priorityLevel;var ne=ie(D.expirationTime<=R);R=e.unstable_now(),typeof ne=="function"?D.callback=ne:D===z(b)&&B(b),ke(R)}else B(b);D=z(b)}if(D!==null)var Je=!0;else{var Qe=z(M);Qe!==null&&i(ki,Qe.startTime-R),Je=!1}return Je}finally{D=null,Z=H,te=!1}}function kt(T){switch(T){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var mn=s;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_continueExecution=function(){he||te||(he=!0,t(ei))},e.unstable_getCurrentPriorityLevel=function(){return Z},e.unstable_getFirstCallbackNode=function(){return z(b)},e.unstable_next=function(T){switch(Z){case 1:case 2:case 3:var R=3;break;default:R=Z}var H=Z;Z=R;try{return T()}finally{Z=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=mn,e.unstable_runWithPriority=function(T,R){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var H=Z;Z=T;try{return R()}finally{Z=H}},e.unstable_scheduleCallback=function(T,R,H){var ie=e.unstable_now();if(typeof H=="object"&&H!==null){var ne=H.delay;ne=typeof ne=="number"&&0<ne?ie+ne:ie,H=typeof H.timeout=="number"?H.timeout:kt(T)}else H=kt(T),ne=ie;return H=ne+H,T={id:V++,callback:R,priorityLevel:T,startTime:ne,expirationTime:H,sortIndex:-1},ne>ie?(T.sortIndex=ne,k(M,T),z(b)===null&&T===z(M)&&(Y?n():Y=!0,i(ki,ne-ie))):(T.sortIndex=H,k(b,T),he||te||(he=!0,t(ei))),T},e.unstable_shouldYield=function(){var T=e.unstable_now();ke(T);var R=z(b);return R!==D&&D!==null&&R!==null&&R.callback!==null&&R.startTime<=T&&R.expirationTime<D.expirationTime||r()},e.unstable_wrapCallback=function(T){var R=Z;return function(){var H=Z;Z=R;try{return T.apply(this,arguments)}finally{Z=H}}}})(Tf);If.exports=Tf;/** @license React v16.14.0
37
- * react-dom.production.min.js
38
- *
39
- * Copyright (c) Facebook, Inc. and its affiliates.
40
- *
41
- * This source code is licensed under the MIT license found in the
42
- * LICENSE file in the root directory of this source tree.
43
- */var ao=Ei.exports,Ee=ff,ve=If.exports;function C(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}if(!ao)throw Error(C(227));function qx(e,t,i,n,r,s,o,a,l){var u=Array.prototype.slice.call(arguments,3);try{t.apply(i,u)}catch(c){this.onError(c)}}var Wn=!1,Is=null,Ts=!1,ya=null,e0={onError:function(e){Wn=!0,Is=e}};function t0(e,t,i,n,r,s,o,a,l){Wn=!1,Is=null,qx.apply(e0,arguments)}function i0(e,t,i,n,r,s,o,a,l){if(t0.apply(this,arguments),Wn){if(Wn){var u=Is;Wn=!1,Is=null}else throw Error(C(198));Ts||(Ts=!0,ya=u)}}var Ul=null,Af=null,Ef=null;function Nc(e,t,i){var n=e.type||"unknown-event";e.currentTarget=Ef(i),i0(n,t,void 0,e),e.currentTarget=null}var As=null,_i={};function Nf(){if(As)for(var e in _i){var t=_i[e],i=As.indexOf(e);if(!(-1<i))throw Error(C(96,e));if(!Es[i]){if(!t.extractEvents)throw Error(C(97,e));Es[i]=t,i=t.eventTypes;for(var n in i){var r=void 0,s=i[n],o=t,a=n;if(xa.hasOwnProperty(a))throw Error(C(99,a));xa[a]=s;var l=s.phasedRegistrationNames;if(l){for(r in l)l.hasOwnProperty(r)&&kc(l[r],o,a);r=!0}else s.registrationName?(kc(s.registrationName,o,a),r=!0):r=!1;if(!r)throw Error(C(98,n,e))}}}}function kc(e,t,i){if(rn[e])throw Error(C(100,e));rn[e]=t,Wl[e]=t.eventTypes[i].dependencies}var Es=[],xa={},rn={},Wl={};function kf(e){var t=!1,i;for(i in e)if(e.hasOwnProperty(i)){var n=e[i];if(!_i.hasOwnProperty(i)||_i[i]!==n){if(_i[i])throw Error(C(102,i));_i[i]=n,t=!0}}t&&Nf()}var qt=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),Sa=null,Yi=null,Gi=null;function Pc(e){if(e=Af(e)){if(typeof Sa!="function")throw Error(C(280));var t=e.stateNode;t&&(t=Ul(t),Sa(e.stateNode,e.type,t))}}function Pf(e){Yi?Gi?Gi.push(e):Gi=[e]:Yi=e}function zf(){if(Yi){var e=Yi,t=Gi;if(Gi=Yi=null,Pc(e),t)for(e=0;e<t.length;e++)Pc(t[e])}}function Hl(e,t){return e(t)}function Bf(e,t,i,n,r){return e(t,i,n,r)}function Fl(){}var Df=Hl,li=!1,Ro=!1;function Ql(){(Yi!==null||Gi!==null)&&(Fl(),zf())}function Lf(e,t,i){if(Ro)return e(t,i);Ro=!0;try{return Df(e,t,i)}finally{Ro=!1,Ql()}}var n0=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,zc=Object.prototype.hasOwnProperty,Bc={},Dc={};function r0(e){return zc.call(Dc,e)?!0:zc.call(Bc,e)?!1:n0.test(e)?Dc[e]=!0:(Bc[e]=!0,!1)}function s0(e,t,i,n){if(i!==null&&i.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return n?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function o0(e,t,i,n){if(t===null||typeof t=="undefined"||s0(e,t,i,n))return!0;if(n)return!1;if(i!==null)switch(i.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ne(e,t,i,n,r,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=n,this.attributeNamespace=r,this.mustUseProperty=i,this.propertyName=e,this.type=t,this.sanitizeURL=s}var we={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){we[e]=new Ne(e,0,!1,e,null,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];we[t]=new Ne(t,1,!1,e[1],null,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){we[e]=new Ne(e,2,!1,e.toLowerCase(),null,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){we[e]=new Ne(e,2,!1,e,null,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){we[e]=new Ne(e,3,!1,e.toLowerCase(),null,!1)});["checked","multiple","muted","selected"].forEach(function(e){we[e]=new Ne(e,3,!0,e,null,!1)});["capture","download"].forEach(function(e){we[e]=new Ne(e,4,!1,e,null,!1)});["cols","rows","size","span"].forEach(function(e){we[e]=new Ne(e,6,!1,e,null,!1)});["rowSpan","start"].forEach(function(e){we[e]=new Ne(e,5,!1,e.toLowerCase(),null,!1)});var Zl=/[\-:]([a-z])/g;function Yl(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Zl,Yl);we[t]=new Ne(t,1,!1,e,null,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Zl,Yl);we[t]=new Ne(t,1,!1,e,"http://www.w3.org/1999/xlink",!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Zl,Yl);we[t]=new Ne(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1)});["tabIndex","crossOrigin"].forEach(function(e){we[e]=new Ne(e,1,!1,e.toLowerCase(),null,!1)});we.xlinkHref=new Ne("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0);["src","href","action","formAction"].forEach(function(e){we[e]=new Ne(e,1,!1,e.toLowerCase(),null,!0)});var tt=ao.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;tt.hasOwnProperty("ReactCurrentDispatcher")||(tt.ReactCurrentDispatcher={current:null});tt.hasOwnProperty("ReactCurrentBatchConfig")||(tt.ReactCurrentBatchConfig={suspense:null});function Gl(e,t,i,n){var r=we.hasOwnProperty(t)?we[t]:null,s=r!==null?r.type===0:n?!1:!(!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N");s||(o0(t,i,r,n)&&(i=null),n||r===null?r0(t)&&(i===null?e.removeAttribute(t):e.setAttribute(t,""+i)):r.mustUseProperty?e[r.propertyName]=i===null?r.type===3?!1:"":i:(t=r.attributeName,n=r.attributeNamespace,i===null?e.removeAttribute(t):(r=r.type,i=r===3||r===4&&i===!0?"":""+i,n?e.setAttributeNS(n,t,i):e.setAttribute(t,i))))}var a0=/^(.*)[\\\/]/,_e=typeof Symbol=="function"&&Symbol.for,Hr=_e?Symbol.for("react.element"):60103,Vi=_e?Symbol.for("react.portal"):60106,ai=_e?Symbol.for("react.fragment"):60107,Rf=_e?Symbol.for("react.strict_mode"):60108,as=_e?Symbol.for("react.profiler"):60114,jf=_e?Symbol.for("react.provider"):60109,_f=_e?Symbol.for("react.context"):60110,l0=_e?Symbol.for("react.concurrent_mode"):60111,Xl=_e?Symbol.for("react.forward_ref"):60112,ls=_e?Symbol.for("react.suspense"):60113,Ma=_e?Symbol.for("react.suspense_list"):60120,Jl=_e?Symbol.for("react.memo"):60115,Vf=_e?Symbol.for("react.lazy"):60116,Of=_e?Symbol.for("react.block"):60121,Lc=typeof Symbol=="function"&&Symbol.iterator;function Sn(e){return e===null||typeof e!="object"?null:(e=Lc&&e[Lc]||e["@@iterator"],typeof e=="function"?e:null)}function u0(e){if(e._status===-1){e._status=0;var t=e._ctor;t=t(),e._result=t,t.then(function(i){e._status===0&&(i=i.default,e._status=1,e._result=i)},function(i){e._status===0&&(e._status=2,e._result=i)})}}function Tt(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ai:return"Fragment";case Vi:return"Portal";case as:return"Profiler";case Rf:return"StrictMode";case ls:return"Suspense";case Ma:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _f:return"Context.Consumer";case jf:return"Context.Provider";case Xl:var t=e.render;return t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case Jl:return Tt(e.type);case Of:return Tt(e.render);case Vf:if(e=e._status===1?e._result:null)return Tt(e)}return null}function Kl(e){var t="";do{e:switch(e.tag){case 3:case 4:case 6:case 7:case 10:case 9:var i="";break e;default:var n=e._debugOwner,r=e._debugSource,s=Tt(e.type);i=null,n&&(i=Tt(n.type)),n=s,s="",r?s=" (at "+r.fileName.replace(a0,"")+":"+r.lineNumber+")":i&&(s=" (created by "+i+")"),i=`
44
- in `+(n||"Unknown")+s}t+=i,e=e.return}while(e);return t}function Yt(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}function $f(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function c0(e){var t=$f(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&typeof i!="undefined"&&typeof i.get=="function"&&typeof i.set=="function"){var r=i.get,s=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(o){n=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Fr(e){e._valueTracker||(e._valueTracker=c0(e))}function Uf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),n="";return e&&(n=$f(e)?e.checked?"true":"false":e.value),e=n,e!==i?(t.setValue(e),!0):!1}function Ca(e,t){var i=t.checked;return Ee({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i!=null?i:e._wrapperState.initialChecked})}function Rc(e,t){var i=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;i=Yt(t.value!=null?t.value:i),e._wrapperState={initialChecked:n,initialValue:i,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Wf(e,t){t=t.checked,t!=null&&Gl(e,"checked",t,!1)}function ba(e,t){Wf(e,t);var i=Yt(t.value),n=t.type;if(i!=null)n==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ia(e,t.type,i):t.hasOwnProperty("defaultValue")&&Ia(e,t.type,Yt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function jc(e,t,i){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!(n!=="submit"&&n!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,i||t===e.value||(e.value=t),e.defaultValue=t}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function Ia(e,t,i){(t!=="number"||e.ownerDocument.activeElement!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}function h0(e){var t="";return ao.Children.forEach(e,function(i){i!=null&&(t+=i)}),t}function Ta(e,t){return e=Ee({children:void 0},t),(t=h0(t.children))&&(e.children=t),e}function Xi(e,t,i,n){if(e=e.options,t){t={};for(var r=0;r<i.length;r++)t["$"+i[r]]=!0;for(i=0;i<e.length;i++)r=t.hasOwnProperty("$"+e[i].value),e[i].selected!==r&&(e[i].selected=r),r&&n&&(e[i].defaultSelected=!0)}else{for(i=""+Yt(i),t=null,r=0;r<e.length;r++){if(e[r].value===i){e[r].selected=!0,n&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function Aa(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(C(91));return Ee({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function _c(e,t){var i=t.value;if(i==null){if(i=t.children,t=t.defaultValue,i!=null){if(t!=null)throw Error(C(92));if(Array.isArray(i)){if(!(1>=i.length))throw Error(C(93));i=i[0]}t=i}t==null&&(t=""),i=t}e._wrapperState={initialValue:Yt(i)}}function Hf(e,t){var i=Yt(t.value),n=Yt(t.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),t.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),n!=null&&(e.defaultValue=""+n)}function Vc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}var Ff={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function Qf(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ea(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Qf(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Qr,Zf=function(e){return typeof MSApp!="undefined"&&MSApp.execUnsafeLocalFunction?function(t,i,n,r){MSApp.execUnsafeLocalFunction(function(){return e(t,i,n,r)})}:e}(function(e,t){if(e.namespaceURI!==Ff.svg||"innerHTML"in e)e.innerHTML=t;else{for(Qr=Qr||document.createElement("div"),Qr.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Qr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ir(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}function Zr(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var Oi={animationend:Zr("Animation","AnimationEnd"),animationiteration:Zr("Animation","AnimationIteration"),animationstart:Zr("Animation","AnimationStart"),transitionend:Zr("Transition","TransitionEnd")},jo={},Yf={};qt&&(Yf=document.createElement("div").style,"AnimationEvent"in window||(delete Oi.animationend.animation,delete Oi.animationiteration.animation,delete Oi.animationstart.animation),"TransitionEvent"in window||delete Oi.transitionend.transition);function lo(e){if(jo[e])return jo[e];if(!Oi[e])return e;var t=Oi[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in Yf)return jo[e]=t[i];return e}var Gf=lo("animationend"),Xf=lo("animationiteration"),Jf=lo("animationstart"),Kf=lo("transitionend"),Bn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Oc=new(typeof WeakMap=="function"?WeakMap:Map);function ql(e){var t=Oc.get(e);return t===void 0&&(t=new Map,Oc.set(e,t)),t}function Ni(e){var t=e,i=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.effectTag&1026)!==0&&(i=t.return),e=t.return;while(e)}return t.tag===3?i:null}function qf(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function $c(e){if(Ni(e)!==e)throw Error(C(188))}function d0(e){var t=e.alternate;if(!t){if(t=Ni(e),t===null)throw Error(C(188));return t!==e?null:e}for(var i=e,n=t;;){var r=i.return;if(r===null)break;var s=r.alternate;if(s===null){if(n=r.return,n!==null){i=n;continue}break}if(r.child===s.child){for(s=r.child;s;){if(s===i)return $c(r),e;if(s===n)return $c(r),t;s=s.sibling}throw Error(C(188))}if(i.return!==n.return)i=r,n=s;else{for(var o=!1,a=r.child;a;){if(a===i){o=!0,i=r,n=s;break}if(a===n){o=!0,n=r,i=s;break}a=a.sibling}if(!o){for(a=s.child;a;){if(a===i){o=!0,i=s,n=r;break}if(a===n){o=!0,n=s,i=r;break}a=a.sibling}if(!o)throw Error(C(189))}}if(i.alternate!==n)throw Error(C(190))}if(i.tag!==3)throw Error(C(188));return i.stateNode.current===i?e:t}function ep(e){if(e=d0(e),!e)return null;for(var t=e;;){if(t.tag===5||t.tag===6)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function sn(e,t){if(t==null)throw Error(C(30));return e==null?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function eu(e,t,i){Array.isArray(e)?e.forEach(t,i):e&&t.call(i,e)}var Mn=null;function f0(e){if(e){var t=e._dispatchListeners,i=e._dispatchInstances;if(Array.isArray(t))for(var n=0;n<t.length&&!e.isPropagationStopped();n++)Nc(e,t[n],i[n]);else t&&Nc(e,t,i);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function uo(e){if(e!==null&&(Mn=sn(Mn,e)),e=Mn,Mn=null,e){if(eu(e,f0),Mn)throw Error(C(95));if(Ts)throw e=ya,Ts=!1,ya=null,e}}function tu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}function tp(e){if(!qt)return!1;e="on"+e;var t=e in document;return t||(t=document.createElement("div"),t.setAttribute(e,"return;"),t=typeof t[e]=="function"),t}var Ns=[];function ip(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>Ns.length&&Ns.push(e)}function np(e,t,i,n){if(Ns.length){var r=Ns.pop();return r.topLevelType=e,r.eventSystemFlags=n,r.nativeEvent=t,r.targetInst=i,r}return{topLevelType:e,eventSystemFlags:n,nativeEvent:t,targetInst:i,ancestors:[]}}function rp(e){var t=e.targetInst,i=t;do{if(!i){e.ancestors.push(i);break}var n=i;if(n.tag===3)n=n.stateNode.containerInfo;else{for(;n.return;)n=n.return;n=n.tag!==3?null:n.stateNode.containerInfo}if(!n)break;t=i.tag,t!==5&&t!==6||e.ancestors.push(i),i=Er(n)}while(i);for(i=0;i<e.ancestors.length;i++){t=e.ancestors[i];var r=tu(e.nativeEvent);n=e.topLevelType;var s=e.nativeEvent,o=e.eventSystemFlags;i===0&&(o|=64);for(var a=null,l=0;l<Es.length;l++){var u=Es[l];u&&(u=u.extractEvents(n,t,s,r,o))&&(a=sn(a,u))}uo(a)}}function Na(e,t,i){if(!i.has(e)){switch(e){case"scroll":Dn(t,"scroll",!0);break;case"focus":case"blur":Dn(t,"focus",!0),Dn(t,"blur",!0),i.set("blur",null),i.set("focus",null);break;case"cancel":case"close":tp(e)&&Dn(t,e,!0);break;case"invalid":case"submit":case"reset":break;default:Bn.indexOf(e)===-1&&re(e,t)}i.set(e,null)}}var sp,iu,op,ka=!1,ct=[],$t=null,Ut=null,Wt=null,nr=new Map,rr=new Map,Cn=[],Pa="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput close cancel copy cut paste click change contextmenu reset submit".split(" "),p0="focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture".split(" ");function g0(e,t){var i=ql(t);Pa.forEach(function(n){Na(n,t,i)}),p0.forEach(function(n){Na(n,t,i)})}function za(e,t,i,n,r){return{blockedOn:e,topLevelType:t,eventSystemFlags:i|32,nativeEvent:r,container:n}}function Uc(e,t){switch(e){case"focus":case"blur":$t=null;break;case"dragenter":case"dragleave":Ut=null;break;case"mouseover":case"mouseout":Wt=null;break;case"pointerover":case"pointerout":nr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":rr.delete(t.pointerId)}}function bn(e,t,i,n,r,s){return e===null||e.nativeEvent!==s?(e=za(t,i,n,r,s),t!==null&&(t=Nr(t),t!==null&&iu(t)),e):(e.eventSystemFlags|=n,e)}function m0(e,t,i,n,r){switch(t){case"focus":return $t=bn($t,e,t,i,n,r),!0;case"dragenter":return Ut=bn(Ut,e,t,i,n,r),!0;case"mouseover":return Wt=bn(Wt,e,t,i,n,r),!0;case"pointerover":var s=r.pointerId;return nr.set(s,bn(nr.get(s)||null,e,t,i,n,r)),!0;case"gotpointercapture":return s=r.pointerId,rr.set(s,bn(rr.get(s)||null,e,t,i,n,r)),!0}return!1}function v0(e){var t=Er(e.target);if(t!==null){var i=Ni(t);if(i!==null){if(t=i.tag,t===13){if(t=qf(i),t!==null){e.blockedOn=t,ve.unstable_runWithPriority(e.priority,function(){op(i)});return}}else if(t===3&&i.stateNode.hydrate){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function us(e){if(e.blockedOn!==null)return!1;var t=su(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(t!==null){var i=Nr(t);return i!==null&&iu(i),e.blockedOn=t,!1}return!0}function Wc(e,t,i){us(e)&&i.delete(t)}function w0(){for(ka=!1;0<ct.length;){var e=ct[0];if(e.blockedOn!==null){e=Nr(e.blockedOn),e!==null&&sp(e);break}var t=su(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);t!==null?e.blockedOn=t:ct.shift()}$t!==null&&us($t)&&($t=null),Ut!==null&&us(Ut)&&(Ut=null),Wt!==null&&us(Wt)&&(Wt=null),nr.forEach(Wc),rr.forEach(Wc)}function In(e,t){e.blockedOn===t&&(e.blockedOn=null,ka||(ka=!0,ve.unstable_scheduleCallback(ve.unstable_NormalPriority,w0)))}function ap(e){function t(r){return In(r,e)}if(0<ct.length){In(ct[0],e);for(var i=1;i<ct.length;i++){var n=ct[i];n.blockedOn===e&&(n.blockedOn=null)}}for($t!==null&&In($t,e),Ut!==null&&In(Ut,e),Wt!==null&&In(Wt,e),nr.forEach(t),rr.forEach(t),i=0;i<Cn.length;i++)n=Cn[i],n.blockedOn===e&&(n.blockedOn=null);for(;0<Cn.length&&(i=Cn[0],i.blockedOn===null);)v0(i),i.blockedOn===null&&Cn.shift()}var lp={},up=new Map,nu=new Map,y0=["abort","abort",Gf,"animationEnd",Xf,"animationIteration",Jf,"animationStart","canplay","canPlay","canplaythrough","canPlayThrough","durationchange","durationChange","emptied","emptied","encrypted","encrypted","ended","ended","error","error","gotpointercapture","gotPointerCapture","load","load","loadeddata","loadedData","loadedmetadata","loadedMetadata","loadstart","loadStart","lostpointercapture","lostPointerCapture","playing","playing","progress","progress","seeking","seeking","stalled","stalled","suspend","suspend","timeupdate","timeUpdate",Kf,"transitionEnd","waiting","waiting"];function ru(e,t){for(var i=0;i<e.length;i+=2){var n=e[i],r=e[i+1],s="on"+(r[0].toUpperCase()+r.slice(1));s={phasedRegistrationNames:{bubbled:s,captured:s+"Capture"},dependencies:[n],eventPriority:t},nu.set(n,t),up.set(n,s),lp[r]=s}}ru("blur blur cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focus focus input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange".split(" "),0);ru("drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel".split(" "),1);ru(y0,2);for(var Hc="change selectionchange textInput compositionstart compositionend compositionupdate".split(" "),_o=0;_o<Hc.length;_o++)nu.set(Hc[_o],0);var x0=ve.unstable_UserBlockingPriority,S0=ve.unstable_runWithPriority,cs=!0;function re(e,t){Dn(t,e,!1)}function Dn(e,t,i){var n=nu.get(t);switch(n===void 0?2:n){case 0:n=M0.bind(null,t,1,e);break;case 1:n=C0.bind(null,t,1,e);break;default:n=co.bind(null,t,1,e)}i?e.addEventListener(t,n,!0):e.addEventListener(t,n,!1)}function M0(e,t,i,n){li||Fl();var r=co,s=li;li=!0;try{Bf(r,e,t,i,n)}finally{(li=s)||Ql()}}function C0(e,t,i,n){S0(x0,co.bind(null,e,t,i,n))}function co(e,t,i,n){if(cs)if(0<ct.length&&-1<Pa.indexOf(e))e=za(null,e,t,i,n),ct.push(e);else{var r=su(e,t,i,n);if(r===null)Uc(e,n);else if(-1<Pa.indexOf(e))e=za(r,e,t,i,n),ct.push(e);else if(!m0(r,e,t,i,n)){Uc(e,n),e=np(e,n,null,t);try{Lf(rp,e)}finally{ip(e)}}}}function su(e,t,i,n){if(i=tu(n),i=Er(i),i!==null){var r=Ni(i);if(r===null)i=null;else{var s=r.tag;if(s===13){if(i=qf(r),i!==null)return i;i=null}else if(s===3){if(r.stateNode.hydrate)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}e=np(e,n,i,t);try{Lf(rp,e)}finally{ip(e)}return null}var Hn={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},b0=["Webkit","ms","Moz","O"];Object.keys(Hn).forEach(function(e){b0.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Hn[t]=Hn[e]})});function cp(e,t,i){return t==null||typeof t=="boolean"||t===""?"":i||typeof t!="number"||t===0||Hn.hasOwnProperty(e)&&Hn[e]?(""+t).trim():t+"px"}function hp(e,t){e=e.style;for(var i in t)if(t.hasOwnProperty(i)){var n=i.indexOf("--")===0,r=cp(i,t[i],n);i==="float"&&(i="cssFloat"),n?e.setProperty(i,r):e[i]=r}}var I0=Ee({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ba(e,t){if(t){if(I0[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(C(137,e,""));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(C(60));if(!(typeof t.dangerouslySetInnerHTML=="object"&&"__html"in t.dangerouslySetInnerHTML))throw Error(C(61))}if(t.style!=null&&typeof t.style!="object")throw Error(C(62,""))}}function Da(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Fc=Ff.html;function wt(e,t){e=e.nodeType===9||e.nodeType===11?e:e.ownerDocument;var i=ql(e);t=Wl[t];for(var n=0;n<t.length;n++)Na(t[n],e,i)}function ks(){}function La(e){if(e=e||(typeof document!="undefined"?document:void 0),typeof e=="undefined")return null;try{return e.activeElement||e.body}catch{return e.body}}function Qc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Zc(e,t){var i=Qc(e);e=0;for(var n;i;){if(i.nodeType===3){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function dp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?dp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yc(){for(var e=window,t=La();t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=La(e.document)}return t}function Ra(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var fp="$",pp="/$",ou="$?",au="$!",Vo=null,Oo=null;function gp(e,t){switch(e){case"button":case"input":case"select":case"textarea":return!!t.autoFocus}return!1}function ja(e,t){return e==="textarea"||e==="option"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var $o=typeof setTimeout=="function"?setTimeout:void 0,T0=typeof clearTimeout=="function"?clearTimeout:void 0;function Ji(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break}return e}function Gc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i===fp||i===au||i===ou){if(t===0)return e;t--}else i===pp&&t++}e=e.previousSibling}return null}var lu=Math.random().toString(36).slice(2),Dt="__reactInternalInstance$"+lu,Ps="__reactEventHandlers$"+lu,Ar="__reactContainere$"+lu;function Er(e){var t=e[Dt];if(t)return t;for(var i=e.parentNode;i;){if(t=i[Ar]||i[Dt]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Gc(e);e!==null;){if(i=e[Dt])return i;e=Gc(e)}return t}e=i,i=e.parentNode}return null}function Nr(e){return e=e[Dt]||e[Ar],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Mi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(C(33))}function uu(e){return e[Ps]||null}function yt(e){do e=e.return;while(e&&e.tag!==5);return e||null}function mp(e,t){var i=e.stateNode;if(!i)return null;var n=Ul(i);if(!n)return null;i=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(e=e.type,n=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!n;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(C(231,t,typeof i));return i}function Xc(e,t,i){(t=mp(e,i.dispatchConfig.phasedRegistrationNames[t]))&&(i._dispatchListeners=sn(i._dispatchListeners,t),i._dispatchInstances=sn(i._dispatchInstances,e))}function A0(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,i=[];t;)i.push(t),t=yt(t);for(t=i.length;0<t--;)Xc(i[t],"captured",e);for(t=0;t<i.length;t++)Xc(i[t],"bubbled",e)}}function _a(e,t,i){e&&i&&i.dispatchConfig.registrationName&&(t=mp(e,i.dispatchConfig.registrationName))&&(i._dispatchListeners=sn(i._dispatchListeners,t),i._dispatchInstances=sn(i._dispatchInstances,e))}function E0(e){e&&e.dispatchConfig.registrationName&&_a(e._targetInst,null,e)}function on(e){eu(e,A0)}var Lt=null,cu=null,hs=null;function vp(){if(hs)return hs;var e,t=cu,i=t.length,n,r="value"in Lt?Lt.value:Lt.textContent,s=r.length;for(e=0;e<i&&t[e]===r[e];e++);var o=i-e;for(n=1;n<=o&&t[i-n]===r[s-n];n++);return hs=r.slice(e,1<n?1-n:void 0)}function ds(){return!0}function zs(){return!1}function Fe(e,t,i,n){this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=i,e=this.constructor.Interface;for(var r in e)e.hasOwnProperty(r)&&((t=e[r])?this[r]=t(i):r==="target"?this.target=n:this[r]=i[r]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?ds:zs,this.isPropagationStopped=zs,this}Ee(Fe.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!="unknown"&&(e.returnValue=!1),this.isDefaultPrevented=ds)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!="unknown"&&(e.cancelBubble=!0),this.isPropagationStopped=ds)},persist:function(){this.isPersistent=ds},isPersistent:zs,destructor:function(){var e=this.constructor.Interface,t;for(t in e)this[t]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=zs,this._dispatchInstances=this._dispatchListeners=null}});Fe.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null};Fe.extend=function(e){function t(){}function i(){return n.apply(this,arguments)}var n=this;t.prototype=n.prototype;var r=new t;return Ee(r,i.prototype),i.prototype=r,i.prototype.constructor=i,i.Interface=Ee({},n.Interface,e),i.extend=n.extend,wp(i),i};wp(Fe);function N0(e,t,i,n){if(this.eventPool.length){var r=this.eventPool.pop();return this.call(r,e,t,i,n),r}return new this(e,t,i,n)}function k0(e){if(!(e instanceof this))throw Error(C(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function wp(e){e.eventPool=[],e.getPooled=N0,e.release=k0}var P0=Fe.extend({data:null}),z0=Fe.extend({data:null}),B0=[9,13,27,32],hu=qt&&"CompositionEvent"in window,Fn=null;qt&&"documentMode"in document&&(Fn=document.documentMode);var D0=qt&&"TextEvent"in window&&!Fn,yp=qt&&(!hu||Fn&&8<Fn&&11>=Fn),Jc=String.fromCharCode(32),vt={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["compositionend","keypress","textInput","paste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"blur compositionend keydown keypress keyup mousedown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"blur compositionstart keydown keypress keyup mousedown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"blur compositionupdate keydown keypress keyup mousedown".split(" ")}},Kc=!1;function xp(e,t){switch(e){case"keyup":return B0.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"blur":return!0;default:return!1}}function Sp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var $i=!1;function L0(e,t){switch(e){case"compositionend":return Sp(t);case"keypress":return t.which!==32?null:(Kc=!0,Jc);case"textInput":return e=t.data,e===Jc&&Kc?null:e;default:return null}}function R0(e,t){if($i)return e==="compositionend"||!hu&&xp(e,t)?(e=vp(),hs=cu=Lt=null,$i=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return yp&&t.locale!=="ko"?null:t.data;default:return null}}var j0={eventTypes:vt,extractEvents:function(e,t,i,n){var r;if(hu)e:{switch(e){case"compositionstart":var s=vt.compositionStart;break e;case"compositionend":s=vt.compositionEnd;break e;case"compositionupdate":s=vt.compositionUpdate;break e}s=void 0}else $i?xp(e,i)&&(s=vt.compositionEnd):e==="keydown"&&i.keyCode===229&&(s=vt.compositionStart);return s?(yp&&i.locale!=="ko"&&($i||s!==vt.compositionStart?s===vt.compositionEnd&&$i&&(r=vp()):(Lt=n,cu="value"in Lt?Lt.value:Lt.textContent,$i=!0)),s=P0.getPooled(s,t,i,n),r?s.data=r:(r=Sp(i),r!==null&&(s.data=r)),on(s),r=s):r=null,(e=D0?L0(e,i):R0(e,i))?(t=z0.getPooled(vt.beforeInput,t,i,n),t.data=e,on(t)):t=null,r===null?t:t===null?r:[r,t]}},_0={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Mp(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!_0[e.type]:t==="textarea"}var Cp={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"blur change click focus input keydown keyup selectionchange".split(" ")}};function bp(e,t,i){return e=Fe.getPooled(Cp.change,e,t,i),e.type="change",Pf(i),on(e),e}var Qn=null,sr=null;function V0(e){uo(e)}function ho(e){var t=Mi(e);if(Uf(t))return e}function O0(e,t){if(e==="change")return t}var Va=!1;qt&&(Va=tp("input")&&(!document.documentMode||9<document.documentMode));function qc(){Qn&&(Qn.detachEvent("onpropertychange",Ip),sr=Qn=null)}function Ip(e){if(e.propertyName==="value"&&ho(sr))if(e=bp(sr,e,tu(e)),li)uo(e);else{li=!0;try{Hl(V0,e)}finally{li=!1,Ql()}}}function $0(e,t,i){e==="focus"?(qc(),Qn=t,sr=i,Qn.attachEvent("onpropertychange",Ip)):e==="blur"&&qc()}function U0(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ho(sr)}function W0(e,t){if(e==="click")return ho(t)}function H0(e,t){if(e==="input"||e==="change")return ho(t)}var F0={eventTypes:Cp,_isInputEventSupported:Va,extractEvents:function(e,t,i,n){var r=t?Mi(t):window,s=r.nodeName&&r.nodeName.toLowerCase();if(s==="select"||s==="input"&&r.type==="file")var o=O0;else if(Mp(r))if(Va)o=H0;else{o=U0;var a=$0}else(s=r.nodeName)&&s.toLowerCase()==="input"&&(r.type==="checkbox"||r.type==="radio")&&(o=W0);if(o&&(o=o(e,t)))return bp(o,i,n);a&&a(e,r,t),e==="blur"&&(e=r._wrapperState)&&e.controlled&&r.type==="number"&&Ia(r,"number",r.value)}},kr=Fe.extend({view:null,detail:null}),Q0={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Z0(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Q0[e])?!!t[e]:!1}function du(){return Z0}var eh=0,th=0,ih=!1,nh=!1,Pr=kr.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:du,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},movementX:function(e){if("movementX"in e)return e.movementX;var t=eh;return eh=e.screenX,ih?e.type==="mousemove"?e.screenX-t:0:(ih=!0,0)},movementY:function(e){if("movementY"in e)return e.movementY;var t=th;return th=e.screenY,nh?e.type==="mousemove"?e.screenY-t:0:(nh=!0,0)}}),Tp=Pr.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),Tn={mouseEnter:{registrationName:"onMouseEnter",dependencies:["mouseout","mouseover"]},mouseLeave:{registrationName:"onMouseLeave",dependencies:["mouseout","mouseover"]},pointerEnter:{registrationName:"onPointerEnter",dependencies:["pointerout","pointerover"]},pointerLeave:{registrationName:"onPointerLeave",dependencies:["pointerout","pointerover"]}},Y0={eventTypes:Tn,extractEvents:function(e,t,i,n,r){var s=e==="mouseover"||e==="pointerover",o=e==="mouseout"||e==="pointerout";if(s&&(r&32)===0&&(i.relatedTarget||i.fromElement)||!o&&!s)return null;if(s=n.window===n?n:(s=n.ownerDocument)?s.defaultView||s.parentWindow:window,o){if(o=t,t=(t=i.relatedTarget||i.toElement)?Er(t):null,t!==null){var a=Ni(t);(t!==a||t.tag!==5&&t.tag!==6)&&(t=null)}}else o=null;if(o===t)return null;if(e==="mouseout"||e==="mouseover")var l=Pr,u=Tn.mouseLeave,c=Tn.mouseEnter,h="mouse";else(e==="pointerout"||e==="pointerover")&&(l=Tp,u=Tn.pointerLeave,c=Tn.pointerEnter,h="pointer");if(e=o==null?s:Mi(o),s=t==null?s:Mi(t),u=l.getPooled(u,o,i,n),u.type=h+"leave",u.target=e,u.relatedTarget=s,i=l.getPooled(c,t,i,n),i.type=h+"enter",i.target=s,i.relatedTarget=e,n=o,h=t,n&&h)e:{for(l=n,c=h,o=0,e=l;e;e=yt(e))o++;for(e=0,t=c;t;t=yt(t))e++;for(;0<o-e;)l=yt(l),o--;for(;0<e-o;)c=yt(c),e--;for(;o--;){if(l===c||l===c.alternate)break e;l=yt(l),c=yt(c)}l=null}else l=null;for(c=l,l=[];n&&n!==c&&(o=n.alternate,!(o!==null&&o===c));)l.push(n),n=yt(n);for(n=[];h&&h!==c&&(o=h.alternate,!(o!==null&&o===c));)n.push(h),h=yt(h);for(h=0;h<l.length;h++)_a(l[h],"bubbled",u);for(h=n.length;0<h--;)_a(n[h],"captured",i);return(r&64)===0?[u]:[u,i]}};function G0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ci=typeof Object.is=="function"?Object.is:G0,X0=Object.prototype.hasOwnProperty;function or(e,t){if(Ci(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(n=0;n<i.length;n++)if(!X0.call(t,i[n])||!Ci(e[i[n]],t[i[n]]))return!1;return!0}var J0=qt&&"documentMode"in document&&11>=document.documentMode,Ap={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange".split(" ")}},Ui=null,Oa=null,Zn=null,$a=!1;function rh(e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;return $a||Ui==null||Ui!==La(i)?null:(i=Ui,"selectionStart"in i&&Ra(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Zn&&or(Zn,i)?null:(Zn=i,e=Fe.getPooled(Ap.select,Oa,e,t),e.type="select",e.target=Ui,on(e),e))}var K0={eventTypes:Ap,extractEvents:function(e,t,i,n,r,s){if(r=s||(n.window===n?n.document:n.nodeType===9?n:n.ownerDocument),!(s=!r)){e:{r=ql(r),s=Wl.onSelect;for(var o=0;o<s.length;o++)if(!r.has(s[o])){r=!1;break e}r=!0}s=!r}if(s)return null;switch(r=t?Mi(t):window,e){case"focus":(Mp(r)||r.contentEditable==="true")&&(Ui=r,Oa=t,Zn=null);break;case"blur":Zn=Oa=Ui=null;break;case"mousedown":$a=!0;break;case"contextmenu":case"mouseup":case"dragend":return $a=!1,rh(i,n);case"selectionchange":if(J0)break;case"keydown":case"keyup":return rh(i,n)}return null}},q0=Fe.extend({animationName:null,elapsedTime:null,pseudoElement:null}),eS=Fe.extend({clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tS=kr.extend({relatedTarget:null});function fs(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}var iS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nS={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},rS=kr.extend({key:function(e){if(e.key){var t=iS[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=fs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?nS[e.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:du,charCode:function(e){return e.type==="keypress"?fs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?fs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),sS=Pr.extend({dataTransfer:null}),oS=kr.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:du}),aS=Fe.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),lS=Pr.extend({deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),uS={eventTypes:lp,extractEvents:function(e,t,i,n){var r=up.get(e);if(!r)return null;switch(e){case"keypress":if(fs(i)===0)return null;case"keydown":case"keyup":e=rS;break;case"blur":case"focus":e=tS;break;case"click":if(i.button===2)return null;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":e=Pr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":e=sS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":e=oS;break;case Gf:case Xf:case Jf:e=q0;break;case Kf:e=aS;break;case"scroll":e=kr;break;case"wheel":e=lS;break;case"copy":case"cut":case"paste":e=eS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":e=Tp;break;default:e=Fe}return t=e.getPooled(r,t,i,n),on(t),t}};if(As)throw Error(C(101));As=Array.prototype.slice.call("ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" "));Nf();var cS=Nr;Ul=uu;Af=cS;Ef=Mi;kf({SimpleEventPlugin:uS,EnterLeaveEventPlugin:Y0,ChangeEventPlugin:F0,SelectEventPlugin:K0,BeforeInputEventPlugin:j0});var Ua=[],Wi=-1;function q(e){0>Wi||(e.current=Ua[Wi],Ua[Wi]=null,Wi--)}function ue(e,t){Wi++,Ua[Wi]=e.current,e.current=t}var Gt={},Ce={current:Gt},Le={current:!1},bi=Gt;function an(e,t){var i=e.type.contextTypes;if(!i)return Gt;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in i)r[s]=t[s];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=r),r}function Re(e){return e=e.childContextTypes,e!=null}function Bs(){q(Le),q(Ce)}function sh(e,t,i){if(Ce.current!==Gt)throw Error(C(168));ue(Ce,t),ue(Le,i)}function Ep(e,t,i){var n=e.stateNode;if(e=t.childContextTypes,typeof n.getChildContext!="function")return i;n=n.getChildContext();for(var r in n)if(!(r in e))throw Error(C(108,Tt(t)||"Unknown",r));return Ee({},i,{},n)}function ps(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Gt,bi=Ce.current,ue(Ce,e),ue(Le,Le.current),!0}function oh(e,t,i){var n=e.stateNode;if(!n)throw Error(C(169));i?(e=Ep(e,t,bi),n.__reactInternalMemoizedMergedChildContext=e,q(Le),q(Ce),ue(Ce,e)):q(Le),ue(Le,i)}var hS=ve.unstable_runWithPriority,fu=ve.unstable_scheduleCallback,Np=ve.unstable_cancelCallback,ah=ve.unstable_requestPaint,Wa=ve.unstable_now,dS=ve.unstable_getCurrentPriorityLevel,fo=ve.unstable_ImmediatePriority,kp=ve.unstable_UserBlockingPriority,Pp=ve.unstable_NormalPriority,zp=ve.unstable_LowPriority,Bp=ve.unstable_IdlePriority,Dp={},fS=ve.unstable_shouldYield,pS=ah!==void 0?ah:function(){},St=null,gs=null,Uo=!1,lh=Wa(),Ze=1e4>lh?Wa:function(){return Wa()-lh};function po(){switch(dS()){case fo:return 99;case kp:return 98;case Pp:return 97;case zp:return 96;case Bp:return 95;default:throw Error(C(332))}}function Lp(e){switch(e){case 99:return fo;case 98:return kp;case 97:return Pp;case 96:return zp;case 95:return Bp;default:throw Error(C(332))}}function Xt(e,t){return e=Lp(e),hS(e,t)}function Rp(e,t,i){return e=Lp(e),fu(e,t,i)}function uh(e){return St===null?(St=[e],gs=fu(fo,jp)):St.push(e),Dp}function mt(){if(gs!==null){var e=gs;gs=null,Np(e)}jp()}function jp(){if(!Uo&&St!==null){Uo=!0;var e=0;try{var t=St;Xt(99,function(){for(;e<t.length;e++){var i=t[e];do i=i(!0);while(i!==null)}}),St=null}catch(i){throw St!==null&&(St=St.slice(e+1)),fu(fo,mt),i}finally{Uo=!1}}}function ms(e,t,i){return i/=10,1073741821-(((1073741821-e+t/10)/i|0)+1)*i}function qe(e,t){if(e&&e.defaultProps){t=Ee({},t),e=e.defaultProps;for(var i in e)t[i]===void 0&&(t[i]=e[i])}return t}var Ds={current:null},Ls=null,Hi=null,Rs=null;function pu(){Rs=Hi=Ls=null}function gu(e){var t=Ds.current;q(Ds),e.type._context._currentValue=t}function _p(e,t){for(;e!==null;){var i=e.alternate;if(e.childExpirationTime<t)e.childExpirationTime=t,i!==null&&i.childExpirationTime<t&&(i.childExpirationTime=t);else if(i!==null&&i.childExpirationTime<t)i.childExpirationTime=t;else break;e=e.return}}function Ki(e,t){Ls=e,Rs=Hi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.expirationTime>=t&&(ht=!0),e.firstContext=null)}function Ge(e,t){if(Rs!==e&&t!==!1&&t!==0)if((typeof t!="number"||t===1073741823)&&(Rs=e,t=1073741823),t={context:e,observedBits:t,next:null},Hi===null){if(Ls===null)throw Error(C(308));Hi=t,Ls.dependencies={expirationTime:0,firstContext:t,responders:null}}else Hi=Hi.next=t;return e._currentValue}var Bt=!1;function mu(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function vu(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function Ht(e,t){return e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null},e.next=e}function Ft(e,t){if(e=e.updateQueue,e!==null){e=e.shared;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}}function ch(e,t){var i=e.alternate;i!==null&&vu(i,e),e=e.updateQueue,i=e.baseQueue,i===null?(e.baseQueue=t.next=t,t.next=t):(t.next=i.next,i.next=t)}function ar(e,t,i,n){var r=e.updateQueue;Bt=!1;var s=r.baseQueue,o=r.shared.pending;if(o!==null){if(s!==null){var a=s.next;s.next=o.next,o.next=a}s=o,r.shared.pending=null,a=e.alternate,a!==null&&(a=a.updateQueue,a!==null&&(a.baseQueue=o))}if(s!==null){a=s.next;var l=r.baseState,u=0,c=null,h=null,m=null;if(a!==null){var v=a;do{if(o=v.expirationTime,o<n){var w={expirationTime:v.expirationTime,suspenseConfig:v.suspenseConfig,tag:v.tag,payload:v.payload,callback:v.callback,next:null};m===null?(h=m=w,c=l):m=m.next=w,o>u&&(u=o)}else{m!==null&&(m=m.next={expirationTime:1073741823,suspenseConfig:v.suspenseConfig,tag:v.tag,payload:v.payload,callback:v.callback,next:null}),pg(o,v.suspenseConfig);e:{var x=e,d=v;switch(o=t,w=i,d.tag){case 1:if(x=d.payload,typeof x=="function"){l=x.call(w,l,o);break e}l=x;break e;case 3:x.effectTag=x.effectTag&-4097|64;case 0:if(x=d.payload,o=typeof x=="function"?x.call(w,l,o):x,o==null)break e;l=Ee({},l,o);break e;case 2:Bt=!0}}v.callback!==null&&(e.effectTag|=32,o=r.effects,o===null?r.effects=[v]:o.push(v))}if(v=v.next,v===null||v===a){if(o=r.shared.pending,o===null)break;v=s.next=o.next,o.next=a,r.baseQueue=s=o,r.shared.pending=null}}while(1)}m===null?c=l:m.next=h,r.baseState=c,r.baseQueue=m,yo(u),e.expirationTime=u,e.memoizedState=l}}function hh(e,t,i){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var n=e[t],r=n.callback;if(r!==null){if(n.callback=null,n=r,r=i,typeof n!="function")throw Error(C(191,n));n.call(r)}}}var Yn=tt.ReactCurrentBatchConfig,Vp=new ao.Component().refs;function js(e,t,i,n){t=e.memoizedState,i=i(n,t),i=i==null?t:Ee({},t,i),e.memoizedState=i,e.expirationTime===0&&(e.updateQueue.baseState=i)}var go={isMounted:function(e){return(e=e._reactInternalFiber)?Ni(e)===e:!1},enqueueSetState:function(e,t,i){e=e._reactInternalFiber;var n=pt(),r=Yn.suspense;n=wi(n,e,r),r=Ht(n,r),r.payload=t,i!=null&&(r.callback=i),Ft(e,r),Zt(e,n)},enqueueReplaceState:function(e,t,i){e=e._reactInternalFiber;var n=pt(),r=Yn.suspense;n=wi(n,e,r),r=Ht(n,r),r.tag=1,r.payload=t,i!=null&&(r.callback=i),Ft(e,r),Zt(e,n)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var i=pt(),n=Yn.suspense;i=wi(i,e,n),n=Ht(i,n),n.tag=2,t!=null&&(n.callback=t),Ft(e,n),Zt(e,i)}};function dh(e,t,i,n,r,s,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,s,o):t.prototype&&t.prototype.isPureReactComponent?!or(i,n)||!or(r,s):!0}function Op(e,t,i){var n=!1,r=Gt,s=t.contextType;return typeof s=="object"&&s!==null?s=Ge(s):(r=Re(t)?bi:Ce.current,n=t.contextTypes,s=(n=n!=null)?an(e,r):Gt),t=new t(i,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=go,e.stateNode=t,t._reactInternalFiber=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=s),t}function fh(e,t,i,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(i,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(i,n),t.state!==e&&go.enqueueReplaceState(t,t.state,null)}function Ha(e,t,i,n){var r=e.stateNode;r.props=i,r.state=e.memoizedState,r.refs=Vp,mu(e);var s=t.contextType;typeof s=="object"&&s!==null?r.context=Ge(s):(s=Re(t)?bi:Ce.current,r.context=an(e,s)),ar(e,i,r,n),r.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(js(e,t,s,i),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(t=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),t!==r.state&&go.enqueueReplaceState(r,r.state,null),ar(e,i,r,n),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.effectTag|=4)}var Yr=Array.isArray;function An(e,t,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(C(309));var n=i.stateNode}if(!n)throw Error(C(147,e));var r=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===r?t.ref:(t=function(s){var o=n.refs;o===Vp&&(o=n.refs={}),s===null?delete o[r]:o[r]=s},t._stringRef=r,t)}if(typeof e!="string")throw Error(C(284));if(!i._owner)throw Error(C(290,e))}return e}function Gr(e,t){if(e.type!=="textarea")throw Error(C(31,Object.prototype.toString.call(t)==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":t,""))}function $p(e){function t(d,f){if(e){var g=d.lastEffect;g!==null?(g.nextEffect=f,d.lastEffect=f):d.firstEffect=d.lastEffect=f,f.nextEffect=null,f.effectTag=8}}function i(d,f){if(!e)return null;for(;f!==null;)t(d,f),f=f.sibling;return null}function n(d,f){for(d=new Map;f!==null;)f.key!==null?d.set(f.key,f):d.set(f.index,f),f=f.sibling;return d}function r(d,f){return d=Ii(d,f),d.index=0,d.sibling=null,d}function s(d,f,g){return d.index=g,e?(g=d.alternate,g!==null?(g=g.index,g<f?(d.effectTag=2,f):g):(d.effectTag=2,f)):f}function o(d){return e&&d.alternate===null&&(d.effectTag=2),d}function a(d,f,g,p){return f===null||f.tag!==6?(f=Yo(g,d.mode,p),f.return=d,f):(f=r(f,g),f.return=d,f)}function l(d,f,g,p){return f!==null&&f.elementType===g.type?(p=r(f,g.props),p.ref=An(d,f,g),p.return=d,p):(p=xs(g.type,g.key,g.props,null,d.mode,p),p.ref=An(d,f,g),p.return=d,p)}function u(d,f,g,p){return f===null||f.tag!==4||f.stateNode.containerInfo!==g.containerInfo||f.stateNode.implementation!==g.implementation?(f=Go(g,d.mode,p),f.return=d,f):(f=r(f,g.children||[]),f.return=d,f)}function c(d,f,g,p,y){return f===null||f.tag!==7?(f=_t(g,d.mode,p,y),f.return=d,f):(f=r(f,g),f.return=d,f)}function h(d,f,g){if(typeof f=="string"||typeof f=="number")return f=Yo(""+f,d.mode,g),f.return=d,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case Hr:return g=xs(f.type,f.key,f.props,null,d.mode,g),g.ref=An(d,null,f),g.return=d,g;case Vi:return f=Go(f,d.mode,g),f.return=d,f}if(Yr(f)||Sn(f))return f=_t(f,d.mode,g,null),f.return=d,f;Gr(d,f)}return null}function m(d,f,g,p){var y=f!==null?f.key:null;if(typeof g=="string"||typeof g=="number")return y!==null?null:a(d,f,""+g,p);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Hr:return g.key===y?g.type===ai?c(d,f,g.props.children,p,y):l(d,f,g,p):null;case Vi:return g.key===y?u(d,f,g,p):null}if(Yr(g)||Sn(g))return y!==null?null:c(d,f,g,p,null);Gr(d,g)}return null}function v(d,f,g,p,y){if(typeof p=="string"||typeof p=="number")return d=d.get(g)||null,a(f,d,""+p,y);if(typeof p=="object"&&p!==null){switch(p.$$typeof){case Hr:return d=d.get(p.key===null?g:p.key)||null,p.type===ai?c(f,d,p.props.children,y,p.key):l(f,d,p,y);case Vi:return d=d.get(p.key===null?g:p.key)||null,u(f,d,p,y)}if(Yr(p)||Sn(p))return d=d.get(g)||null,c(f,d,p,y,null);Gr(f,p)}return null}function w(d,f,g,p){for(var y=null,S=null,A=f,k=f=0,z=null;A!==null&&k<g.length;k++){A.index>k?(z=A,A=null):z=A.sibling;var B=m(d,A,g[k],p);if(B===null){A===null&&(A=z);break}e&&A&&B.alternate===null&&t(d,A),f=s(B,f,k),S===null?y=B:S.sibling=B,S=B,A=z}if(k===g.length)return i(d,A),y;if(A===null){for(;k<g.length;k++)A=h(d,g[k],p),A!==null&&(f=s(A,f,k),S===null?y=A:S.sibling=A,S=A);return y}for(A=n(d,A);k<g.length;k++)z=v(A,d,k,g[k],p),z!==null&&(e&&z.alternate!==null&&A.delete(z.key===null?k:z.key),f=s(z,f,k),S===null?y=z:S.sibling=z,S=z);return e&&A.forEach(function(ee){return t(d,ee)}),y}function x(d,f,g,p){var y=Sn(g);if(typeof y!="function")throw Error(C(150));if(g=y.call(g),g==null)throw Error(C(151));for(var S=y=null,A=f,k=f=0,z=null,B=g.next();A!==null&&!B.done;k++,B=g.next()){A.index>k?(z=A,A=null):z=A.sibling;var ee=m(d,A,B.value,p);if(ee===null){A===null&&(A=z);break}e&&A&&ee.alternate===null&&t(d,A),f=s(ee,f,k),S===null?y=ee:S.sibling=ee,S=ee,A=z}if(B.done)return i(d,A),y;if(A===null){for(;!B.done;k++,B=g.next())B=h(d,B.value,p),B!==null&&(f=s(B,f,k),S===null?y=B:S.sibling=B,S=B);return y}for(A=n(d,A);!B.done;k++,B=g.next())B=v(A,d,k,B.value,p),B!==null&&(e&&B.alternate!==null&&A.delete(B.key===null?k:B.key),f=s(B,f,k),S===null?y=B:S.sibling=B,S=B);return e&&A.forEach(function(b){return t(d,b)}),y}return function(d,f,g,p){var y=typeof g=="object"&&g!==null&&g.type===ai&&g.key===null;y&&(g=g.props.children);var S=typeof g=="object"&&g!==null;if(S)switch(g.$$typeof){case Hr:e:{for(S=g.key,y=f;y!==null;){if(y.key===S){switch(y.tag){case 7:if(g.type===ai){i(d,y.sibling),f=r(y,g.props.children),f.return=d,d=f;break e}break;default:if(y.elementType===g.type){i(d,y.sibling),f=r(y,g.props),f.ref=An(d,y,g),f.return=d,d=f;break e}}i(d,y);break}else t(d,y);y=y.sibling}g.type===ai?(f=_t(g.props.children,d.mode,p,g.key),f.return=d,d=f):(p=xs(g.type,g.key,g.props,null,d.mode,p),p.ref=An(d,f,g),p.return=d,d=p)}return o(d);case Vi:e:{for(y=g.key;f!==null;){if(f.key===y)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){i(d,f.sibling),f=r(f,g.children||[]),f.return=d,d=f;break e}else{i(d,f);break}else t(d,f);f=f.sibling}f=Go(g,d.mode,p),f.return=d,d=f}return o(d)}if(typeof g=="string"||typeof g=="number")return g=""+g,f!==null&&f.tag===6?(i(d,f.sibling),f=r(f,g),f.return=d,d=f):(i(d,f),f=Yo(g,d.mode,p),f.return=d,d=f),o(d);if(Yr(g))return w(d,f,g,p);if(Sn(g))return x(d,f,g,p);if(S&&Gr(d,g),typeof g=="undefined"&&!y)switch(d.tag){case 1:case 0:throw d=d.type,Error(C(152,d.displayName||d.name||"Component"))}return i(d,f)}}var ln=$p(!0),wu=$p(!1),zr={},ft={current:zr},lr={current:zr},ur={current:zr};function ui(e){if(e===zr)throw Error(C(174));return e}function Fa(e,t){switch(ue(ur,t),ue(lr,e),ue(ft,zr),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ea(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ea(t,e)}q(ft),ue(ft,t)}function un(){q(ft),q(lr),q(ur)}function ph(e){ui(ur.current);var t=ui(ft.current),i=Ea(t,e.type);t!==i&&(ue(lr,e),ue(ft,i))}function yu(e){lr.current===e&&(q(ft),q(lr))}var ae={current:0};function _s(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data===ou||i.data===au))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.effectTag&64)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function xu(e,t){return{responder:e,props:t}}var vs=tt.ReactCurrentDispatcher,Ye=tt.ReactCurrentBatchConfig,Rt=0,de=null,Se=null,Me=null,Vs=!1;function Ve(){throw Error(C(321))}function Su(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!Ci(e[i],t[i]))return!1;return!0}function Mu(e,t,i,n,r,s){if(Rt=s,de=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,vs.current=e===null||e.memoizedState===null?gS:mS,e=i(n,r),t.expirationTime===Rt){s=0;do{if(t.expirationTime=0,!(25>s))throw Error(C(301));s+=1,Me=Se=null,t.updateQueue=null,vs.current=vS,e=i(n,r)}while(t.expirationTime===Rt)}if(vs.current=Us,t=Se!==null&&Se.next!==null,Rt=0,Me=Se=de=null,Vs=!1,t)throw Error(C(300));return e}function qi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Me===null?de.memoizedState=Me=e:Me=Me.next=e,Me}function pn(){if(Se===null){var e=de.alternate;e=e!==null?e.memoizedState:null}else e=Se.next;var t=Me===null?de.memoizedState:Me.next;if(t!==null)Me=t,Se=e;else{if(e===null)throw Error(C(310));Se=e,e={memoizedState:Se.memoizedState,baseState:Se.baseState,baseQueue:Se.baseQueue,queue:Se.queue,next:null},Me===null?de.memoizedState=Me=e:Me=Me.next=e}return Me}function gi(e,t){return typeof t=="function"?t(e):t}function Xr(e){var t=pn(),i=t.queue;if(i===null)throw Error(C(311));i.lastRenderedReducer=e;var n=Se,r=n.baseQueue,s=i.pending;if(s!==null){if(r!==null){var o=r.next;r.next=s.next,s.next=o}n.baseQueue=r=s,i.pending=null}if(r!==null){r=r.next,n=n.baseState;var a=o=s=null,l=r;do{var u=l.expirationTime;if(u<Rt){var c={expirationTime:l.expirationTime,suspenseConfig:l.suspenseConfig,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null};a===null?(o=a=c,s=n):a=a.next=c,u>de.expirationTime&&(de.expirationTime=u,yo(u))}else a!==null&&(a=a.next={expirationTime:1073741823,suspenseConfig:l.suspenseConfig,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null}),pg(u,l.suspenseConfig),n=l.eagerReducer===e?l.eagerState:e(n,l.action);l=l.next}while(l!==null&&l!==r);a===null?s=n:a.next=o,Ci(n,t.memoizedState)||(ht=!0),t.memoizedState=n,t.baseState=s,t.baseQueue=a,i.lastRenderedState=n}return[t.memoizedState,i.dispatch]}function Jr(e){var t=pn(),i=t.queue;if(i===null)throw Error(C(311));i.lastRenderedReducer=e;var n=i.dispatch,r=i.pending,s=t.memoizedState;if(r!==null){i.pending=null;var o=r=r.next;do s=e(s,o.action),o=o.next;while(o!==r);Ci(s,t.memoizedState)||(ht=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),i.lastRenderedState=s}return[s,n]}function Wo(e){var t=qi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e=t.queue={pending:null,dispatch:null,lastRenderedReducer:gi,lastRenderedState:e},e=e.dispatch=Zp.bind(null,de,e),[t.memoizedState,e]}function Qa(e,t,i,n){return e={tag:e,create:t,destroy:i,deps:n,next:null},t=de.updateQueue,t===null?(t={lastEffect:null},de.updateQueue=t,t.lastEffect=e.next=e):(i=t.lastEffect,i===null?t.lastEffect=e.next=e:(n=i.next,i.next=e,e.next=n,t.lastEffect=e)),e}function Up(){return pn().memoizedState}function Za(e,t,i,n){var r=qi();de.effectTag|=e,r.memoizedState=Qa(1|t,i,void 0,n===void 0?null:n)}function Cu(e,t,i,n){var r=pn();n=n===void 0?null:n;var s=void 0;if(Se!==null){var o=Se.memoizedState;if(s=o.destroy,n!==null&&Su(n,o.deps)){Qa(t,i,s,n);return}}de.effectTag|=e,r.memoizedState=Qa(1|t,i,s,n)}function gh(e,t){return Za(516,4,e,t)}function Os(e,t){return Cu(516,4,e,t)}function Wp(e,t){return Cu(4,2,e,t)}function Hp(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Fp(e,t,i){return i=i!=null?i.concat([e]):null,Cu(4,2,Hp.bind(null,t,e),i)}function bu(){}function mh(e,t){return qi().memoizedState=[e,t===void 0?null:t],e}function $s(e,t){var i=pn();t=t===void 0?null:t;var n=i.memoizedState;return n!==null&&t!==null&&Su(t,n[1])?n[0]:(i.memoizedState=[e,t],e)}function Qp(e,t){var i=pn();t=t===void 0?null:t;var n=i.memoizedState;return n!==null&&t!==null&&Su(t,n[1])?n[0]:(e=e(),i.memoizedState=[e,t],e)}function Iu(e,t,i){var n=po();Xt(98>n?98:n,function(){e(!0)}),Xt(97<n?97:n,function(){var r=Ye.suspense;Ye.suspense=t===void 0?null:t;try{e(!1),i()}finally{Ye.suspense=r}})}function Zp(e,t,i){var n=pt(),r=Yn.suspense;n=wi(n,e,r),r={expirationTime:n,suspenseConfig:r,action:i,eagerReducer:null,eagerState:null,next:null};var s=t.pending;if(s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r,s=e.alternate,e===de||s!==null&&s===de)Vs=!0,r.expirationTime=Rt,de.expirationTime=Rt;else{if(e.expirationTime===0&&(s===null||s.expirationTime===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,i);if(r.eagerReducer=s,r.eagerState=a,Ci(a,o))return}catch{}finally{}Zt(e,n)}}var Us={readContext:Ge,useCallback:Ve,useContext:Ve,useEffect:Ve,useImperativeHandle:Ve,useLayoutEffect:Ve,useMemo:Ve,useReducer:Ve,useRef:Ve,useState:Ve,useDebugValue:Ve,useResponder:Ve,useDeferredValue:Ve,useTransition:Ve},gS={readContext:Ge,useCallback:mh,useContext:Ge,useEffect:gh,useImperativeHandle:function(e,t,i){return i=i!=null?i.concat([e]):null,Za(4,2,Hp.bind(null,t,e),i)},useLayoutEffect:function(e,t){return Za(4,2,e,t)},useMemo:function(e,t){var i=qi();return t=t===void 0?null:t,e=e(),i.memoizedState=[e,t],e},useReducer:function(e,t,i){var n=qi();return t=i!==void 0?i(t):t,n.memoizedState=n.baseState=t,e=n.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},e=e.dispatch=Zp.bind(null,de,e),[n.memoizedState,e]},useRef:function(e){var t=qi();return e={current:e},t.memoizedState=e},useState:Wo,useDebugValue:bu,useResponder:xu,useDeferredValue:function(e,t){var i=Wo(e),n=i[0],r=i[1];return gh(function(){var s=Ye.suspense;Ye.suspense=t===void 0?null:t;try{r(e)}finally{Ye.suspense=s}},[e,t]),n},useTransition:function(e){var t=Wo(!1),i=t[0];return t=t[1],[mh(Iu.bind(null,t,e),[t,e]),i]}},mS={readContext:Ge,useCallback:$s,useContext:Ge,useEffect:Os,useImperativeHandle:Fp,useLayoutEffect:Wp,useMemo:Qp,useReducer:Xr,useRef:Up,useState:function(){return Xr(gi)},useDebugValue:bu,useResponder:xu,useDeferredValue:function(e,t){var i=Xr(gi),n=i[0],r=i[1];return Os(function(){var s=Ye.suspense;Ye.suspense=t===void 0?null:t;try{r(e)}finally{Ye.suspense=s}},[e,t]),n},useTransition:function(e){var t=Xr(gi),i=t[0];return t=t[1],[$s(Iu.bind(null,t,e),[t,e]),i]}},vS={readContext:Ge,useCallback:$s,useContext:Ge,useEffect:Os,useImperativeHandle:Fp,useLayoutEffect:Wp,useMemo:Qp,useReducer:Jr,useRef:Up,useState:function(){return Jr(gi)},useDebugValue:bu,useResponder:xu,useDeferredValue:function(e,t){var i=Jr(gi),n=i[0],r=i[1];return Os(function(){var s=Ye.suspense;Ye.suspense=t===void 0?null:t;try{r(e)}finally{Ye.suspense=s}},[e,t]),n},useTransition:function(e){var t=Jr(gi),i=t[0];return t=t[1],[$s(Iu.bind(null,t,e),[t,e]),i]}},bt=null,jt=null,mi=!1;function Yp(e,t){var i=dt(5,null,null,0);i.elementType="DELETED",i.type="DELETED",i.stateNode=t,i.return=e,i.effectTag=8,e.lastEffect!==null?(e.lastEffect.nextEffect=i,e.lastEffect=i):e.firstEffect=e.lastEffect=i}function vh(e,t){switch(e.tag){case 5:var i=e.type;return t=t.nodeType!==1||i.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,!0):!1;case 13:return!1;default:return!1}}function Ya(e){if(mi){var t=jt;if(t){var i=t;if(!vh(e,t)){if(t=Ji(i.nextSibling),!t||!vh(e,t)){e.effectTag=e.effectTag&-1025|2,mi=!1,bt=e;return}Yp(bt,i)}bt=e,jt=Ji(t.firstChild)}else e.effectTag=e.effectTag&-1025|2,mi=!1,bt=e}}function wh(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;bt=e}function Kr(e){if(e!==bt)return!1;if(!mi)return wh(e),mi=!0,!1;var t=e.type;if(e.tag!==5||t!=="head"&&t!=="body"&&!ja(t,e.memoizedProps))for(t=jt;t;)Yp(e,t),t=Ji(t.nextSibling);if(wh(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(C(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var i=e.data;if(i===pp){if(t===0){jt=Ji(e.nextSibling);break e}t--}else i!==fp&&i!==au&&i!==ou||t++}e=e.nextSibling}jt=null}}else jt=bt?Ji(e.stateNode.nextSibling):null;return!0}function Ho(){jt=bt=null,mi=!1}var wS=tt.ReactCurrentOwner,ht=!1;function $e(e,t,i,n){t.child=e===null?wu(t,null,i,n):ln(t,e.child,i,n)}function yh(e,t,i,n,r){i=i.render;var s=t.ref;return Ki(t,r),n=Mu(e,t,i,n,s,r),e!==null&&!ht?(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=r&&(e.expirationTime=0),It(e,t,r)):(t.effectTag|=1,$e(e,t,n,r),t.child)}function xh(e,t,i,n,r,s){if(e===null){var o=i.type;return typeof o=="function"&&!ku(o)&&o.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(t.tag=15,t.type=o,Gp(e,t,o,n,r,s)):(e=xs(i.type,null,n,null,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}return o=e.child,r<s&&(r=o.memoizedProps,i=i.compare,i=i!==null?i:or,i(r,n)&&e.ref===t.ref)?It(e,t,s):(t.effectTag|=1,e=Ii(o,n),e.ref=t.ref,e.return=t,t.child=e)}function Gp(e,t,i,n,r,s){return e!==null&&or(e.memoizedProps,n)&&e.ref===t.ref&&(ht=!1,r<s)?(t.expirationTime=e.expirationTime,It(e,t,s)):Ga(e,t,i,n,s)}function Xp(e,t){var i=t.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(t.effectTag|=128)}function Ga(e,t,i,n,r){var s=Re(i)?bi:Ce.current;return s=an(t,s),Ki(t,r),i=Mu(e,t,i,n,s,r),e!==null&&!ht?(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=r&&(e.expirationTime=0),It(e,t,r)):(t.effectTag|=1,$e(e,t,i,r),t.child)}function Sh(e,t,i,n,r){if(Re(i)){var s=!0;ps(t)}else s=!1;if(Ki(t,r),t.stateNode===null)e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),Op(t,i,n),Ha(t,i,n,r),n=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,u=i.contextType;typeof u=="object"&&u!==null?u=Ge(u):(u=Re(i)?bi:Ce.current,u=an(t,u));var c=i.getDerivedStateFromProps,h=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&fh(t,o,n,u),Bt=!1;var m=t.memoizedState;o.state=m,ar(t,n,o,r),l=t.memoizedState,a!==n||m!==l||Le.current||Bt?(typeof c=="function"&&(js(t,i,c,n),l=t.memoizedState),(a=Bt||dh(t,i,a,n,m,l,u))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.effectTag|=4)):(typeof o.componentDidMount=="function"&&(t.effectTag|=4),t.memoizedProps=n,t.memoizedState=l),o.props=n,o.state=l,o.context=u,n=a):(typeof o.componentDidMount=="function"&&(t.effectTag|=4),n=!1)}else o=t.stateNode,vu(e,t),a=t.memoizedProps,o.props=t.type===t.elementType?a:qe(t.type,a),l=o.context,u=i.contextType,typeof u=="object"&&u!==null?u=Ge(u):(u=Re(i)?bi:Ce.current,u=an(t,u)),c=i.getDerivedStateFromProps,(h=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&fh(t,o,n,u),Bt=!1,l=t.memoizedState,o.state=l,ar(t,n,o,r),m=t.memoizedState,a!==n||l!==m||Le.current||Bt?(typeof c=="function"&&(js(t,i,c,n),m=t.memoizedState),(c=Bt||dh(t,i,a,n,l,m,u))?(h||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,m,u),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,m,u)),typeof o.componentDidUpdate=="function"&&(t.effectTag|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.effectTag|=256)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=256),t.memoizedProps=n,t.memoizedState=m),o.props=n,o.state=m,o.context=u,n=c):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=256),n=!1);return Xa(e,t,i,n,s,r)}function Xa(e,t,i,n,r,s){Xp(e,t);var o=(t.effectTag&64)!==0;if(!n&&!o)return r&&oh(t,i,!1),It(e,t,s);n=t.stateNode,wS.current=t;var a=o&&typeof i.getDerivedStateFromError!="function"?null:n.render();return t.effectTag|=1,e!==null&&o?(t.child=ln(t,e.child,null,s),t.child=ln(t,null,a,s)):$e(e,t,a,s),t.memoizedState=n.state,r&&oh(t,i,!0),t.child}function Mh(e){var t=e.stateNode;t.pendingContext?sh(e,t.pendingContext,t.pendingContext!==t.context):t.context&&sh(e,t.context,!1),Fa(e,t.containerInfo)}var Fo={dehydrated:null,retryTime:0};function Ch(e,t,i){var n=t.mode,r=t.pendingProps,s=ae.current,o=!1,a;if((a=(t.effectTag&64)!==0)||(a=(s&2)!==0&&(e===null||e.memoizedState!==null)),a?(o=!0,t.effectTag&=-65):e!==null&&e.memoizedState===null||r.fallback===void 0||r.unstable_avoidThisFallback===!0||(s|=1),ue(ae,s&1),e===null){if(r.fallback!==void 0&&Ya(t),o){if(o=r.fallback,r=_t(null,n,0,null),r.return=t,(t.mode&2)===0)for(e=t.memoizedState!==null?t.child.child:t.child,r.child=e;e!==null;)e.return=r,e=e.sibling;return i=_t(o,n,i,null),i.return=t,r.sibling=i,t.memoizedState=Fo,t.child=r,i}return n=r.children,t.memoizedState=null,t.child=wu(t,null,n,i)}if(e.memoizedState!==null){if(e=e.child,n=e.sibling,o){if(r=r.fallback,i=Ii(e,e.pendingProps),i.return=t,(t.mode&2)===0&&(o=t.memoizedState!==null?t.child.child:t.child,o!==e.child))for(i.child=o;o!==null;)o.return=i,o=o.sibling;return n=Ii(n,r),n.return=t,i.sibling=n,i.childExpirationTime=0,t.memoizedState=Fo,t.child=i,n}return i=ln(t,e.child,r.children,i),t.memoizedState=null,t.child=i}if(e=e.child,o){if(o=r.fallback,r=_t(null,n,0,null),r.return=t,r.child=e,e!==null&&(e.return=r),(t.mode&2)===0)for(e=t.memoizedState!==null?t.child.child:t.child,r.child=e;e!==null;)e.return=r,e=e.sibling;return i=_t(o,n,i,null),i.return=t,r.sibling=i,i.effectTag|=2,r.childExpirationTime=0,t.memoizedState=Fo,t.child=r,i}return t.memoizedState=null,t.child=ln(t,e,r.children,i)}function bh(e,t){e.expirationTime<t&&(e.expirationTime=t);var i=e.alternate;i!==null&&i.expirationTime<t&&(i.expirationTime=t),_p(e.return,t)}function Qo(e,t,i,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:i,tailExpiration:0,tailMode:r,lastEffect:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=n,o.tail=i,o.tailExpiration=0,o.tailMode=r,o.lastEffect=s)}function Ih(e,t,i){var n=t.pendingProps,r=n.revealOrder,s=n.tail;if($e(e,t,n.children,i),n=ae.current,(n&2)!==0)n=n&1|2,t.effectTag|=64;else{if(e!==null&&(e.effectTag&64)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&bh(e,i);else if(e.tag===19)bh(e,i);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(ue(ae,n),(t.mode&2)===0)t.memoizedState=null;else switch(r){case"forwards":for(i=t.child,r=null;i!==null;)e=i.alternate,e!==null&&_s(e)===null&&(r=i),i=i.sibling;i=r,i===null?(r=t.child,t.child=null):(r=i.sibling,i.sibling=null),Qo(t,!1,r,i,s,t.lastEffect);break;case"backwards":for(i=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&_s(e)===null){t.child=r;break}e=r.sibling,r.sibling=i,i=r,r=e}Qo(t,!0,i,null,s,t.lastEffect);break;case"together":Qo(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function It(e,t,i){e!==null&&(t.dependencies=e.dependencies);var n=t.expirationTime;if(n!==0&&yo(n),t.childExpirationTime<i)return null;if(e!==null&&t.child!==e.child)throw Error(C(153));if(t.child!==null){for(e=t.child,i=Ii(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=Ii(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}var Jp,Ja,Kp,qp;Jp=function(e,t){for(var i=t.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}};Ja=function(){};Kp=function(e,t,i,n,r){var s=e.memoizedProps;if(s!==n){var o=t.stateNode;switch(ui(ft.current),e=null,i){case"input":s=Ca(o,s),n=Ca(o,n),e=[];break;case"option":s=Ta(o,s),n=Ta(o,n),e=[];break;case"select":s=Ee({},s,{value:void 0}),n=Ee({},n,{value:void 0}),e=[];break;case"textarea":s=Aa(o,s),n=Aa(o,n),e=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(o.onclick=ks)}Ba(i,n);var a,l;i=null;for(a in s)if(!n.hasOwnProperty(a)&&s.hasOwnProperty(a)&&s[a]!=null)if(a==="style")for(l in o=s[a],o)o.hasOwnProperty(l)&&(i||(i={}),i[l]="");else a!=="dangerouslySetInnerHTML"&&a!=="children"&&a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(rn.hasOwnProperty(a)?e||(e=[]):(e=e||[]).push(a,null));for(a in n){var u=n[a];if(o=s!=null?s[a]:void 0,n.hasOwnProperty(a)&&u!==o&&(u!=null||o!=null))if(a==="style")if(o){for(l in o)!o.hasOwnProperty(l)||u&&u.hasOwnProperty(l)||(i||(i={}),i[l]="");for(l in u)u.hasOwnProperty(l)&&o[l]!==u[l]&&(i||(i={}),i[l]=u[l])}else i||(e||(e=[]),e.push(a,i)),i=u;else a==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,o=o?o.__html:void 0,u!=null&&o!==u&&(e=e||[]).push(a,u)):a==="children"?o===u||typeof u!="string"&&typeof u!="number"||(e=e||[]).push(a,""+u):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&(rn.hasOwnProperty(a)?(u!=null&&wt(r,a),e||o===u||(e=[])):(e=e||[]).push(a,u))}i&&(e=e||[]).push("style",i),r=e,(t.updateQueue=r)&&(t.effectTag|=4)}};qp=function(e,t,i,n){i!==n&&(t.effectTag|=4)};function qr(e,t){switch(e.tailMode){case"hidden":t=e.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var n=null;i!==null;)i.alternate!==null&&(n=i),i=i.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function yS(e,t,i){var n=t.pendingProps;switch(t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return Re(t.type)&&Bs(),null;case 3:return un(),q(Le),q(Ce),i=t.stateNode,i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),e!==null&&e.child!==null||!Kr(t)||(t.effectTag|=4),Ja(t),null;case 5:yu(t),i=ui(ur.current);var r=t.type;if(e!==null&&t.stateNode!=null)Kp(e,t,r,n,i),e.ref!==t.ref&&(t.effectTag|=128);else{if(!n){if(t.stateNode===null)throw Error(C(166));return null}if(e=ui(ft.current),Kr(t)){n=t.stateNode,r=t.type;var s=t.memoizedProps;switch(n[Dt]=t,n[Ps]=s,r){case"iframe":case"object":case"embed":re("load",n);break;case"video":case"audio":for(e=0;e<Bn.length;e++)re(Bn[e],n);break;case"source":re("error",n);break;case"img":case"image":case"link":re("error",n),re("load",n);break;case"form":re("reset",n),re("submit",n);break;case"details":re("toggle",n);break;case"input":Rc(n,s),re("invalid",n),wt(i,"onChange");break;case"select":n._wrapperState={wasMultiple:!!s.multiple},re("invalid",n),wt(i,"onChange");break;case"textarea":_c(n,s),re("invalid",n),wt(i,"onChange")}Ba(r,s),e=null;for(var o in s)if(s.hasOwnProperty(o)){var a=s[o];o==="children"?typeof a=="string"?n.textContent!==a&&(e=["children",a]):typeof a=="number"&&n.textContent!==""+a&&(e=["children",""+a]):rn.hasOwnProperty(o)&&a!=null&&wt(i,o)}switch(r){case"input":Fr(n),jc(n,s,!0);break;case"textarea":Fr(n),Vc(n);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(n.onclick=ks)}i=e,t.updateQueue=i,i!==null&&(t.effectTag|=4)}else{switch(o=i.nodeType===9?i:i.ownerDocument,e===Fc&&(e=Qf(r)),e===Fc?r==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=o.createElement(r,{is:n.is}):(e=o.createElement(r),r==="select"&&(o=e,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):e=o.createElementNS(e,r),e[Dt]=t,e[Ps]=n,Jp(e,t,!1,!1),t.stateNode=e,o=Da(r,n),r){case"iframe":case"object":case"embed":re("load",e),a=n;break;case"video":case"audio":for(a=0;a<Bn.length;a++)re(Bn[a],e);a=n;break;case"source":re("error",e),a=n;break;case"img":case"image":case"link":re("error",e),re("load",e),a=n;break;case"form":re("reset",e),re("submit",e),a=n;break;case"details":re("toggle",e),a=n;break;case"input":Rc(e,n),a=Ca(e,n),re("invalid",e),wt(i,"onChange");break;case"option":a=Ta(e,n);break;case"select":e._wrapperState={wasMultiple:!!n.multiple},a=Ee({},n,{value:void 0}),re("invalid",e),wt(i,"onChange");break;case"textarea":_c(e,n),a=Aa(e,n),re("invalid",e),wt(i,"onChange");break;default:a=n}Ba(r,a);var l=a;for(s in l)if(l.hasOwnProperty(s)){var u=l[s];s==="style"?hp(e,u):s==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&Zf(e,u)):s==="children"?typeof u=="string"?(r!=="textarea"||u!=="")&&ir(e,u):typeof u=="number"&&ir(e,""+u):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(rn.hasOwnProperty(s)?u!=null&&wt(i,s):u!=null&&Gl(e,s,u,o))}switch(r){case"input":Fr(e),jc(e,n,!1);break;case"textarea":Fr(e),Vc(e);break;case"option":n.value!=null&&e.setAttribute("value",""+Yt(n.value));break;case"select":e.multiple=!!n.multiple,i=n.value,i!=null?Xi(e,!!n.multiple,i,!1):n.defaultValue!=null&&Xi(e,!!n.multiple,n.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=ks)}gp(r,n)&&(t.effectTag|=4)}t.ref!==null&&(t.effectTag|=128)}return null;case 6:if(e&&t.stateNode!=null)qp(e,t,e.memoizedProps,n);else{if(typeof n!="string"&&t.stateNode===null)throw Error(C(166));i=ui(ur.current),ui(ft.current),Kr(t)?(i=t.stateNode,n=t.memoizedProps,i[Dt]=t,i.nodeValue!==n&&(t.effectTag|=4)):(i=(i.nodeType===9?i:i.ownerDocument).createTextNode(n),i[Dt]=t,t.stateNode=i)}return null;case 13:return q(ae),n=t.memoizedState,(t.effectTag&64)!==0?(t.expirationTime=i,t):(i=n!==null,n=!1,e===null?t.memoizedProps.fallback!==void 0&&Kr(t):(r=e.memoizedState,n=r!==null,i||r===null||(r=e.child.sibling,r!==null&&(s=t.firstEffect,s!==null?(t.firstEffect=r,r.nextEffect=s):(t.firstEffect=t.lastEffect=r,r.nextEffect=null),r.effectTag=8))),i&&!n&&(t.mode&2)!==0&&(e===null&&t.memoizedProps.unstable_avoidThisFallback!==!0||(ae.current&1)!==0?ge===vi&&(ge=Fs):((ge===vi||ge===Fs)&&(ge=mo),hr!==0&&We!==null&&(di(We,je),yg(We,hr)))),(i||n)&&(t.effectTag|=4),null);case 4:return un(),Ja(t),null;case 10:return gu(t),null;case 17:return Re(t.type)&&Bs(),null;case 19:if(q(ae),n=t.memoizedState,n===null)return null;if(r=(t.effectTag&64)!==0,s=n.rendering,s===null){if(r)qr(n,!1);else if(ge!==vi||e!==null&&(e.effectTag&64)!==0)for(s=t.child;s!==null;){if(e=_s(s),e!==null){for(t.effectTag|=64,qr(n,!1),r=e.updateQueue,r!==null&&(t.updateQueue=r,t.effectTag|=4),n.lastEffect===null&&(t.firstEffect=null),t.lastEffect=n.lastEffect,n=t.child;n!==null;)r=n,s=i,r.effectTag&=2,r.nextEffect=null,r.firstEffect=null,r.lastEffect=null,e=r.alternate,e===null?(r.childExpirationTime=0,r.expirationTime=s,r.child=null,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null):(r.childExpirationTime=e.childExpirationTime,r.expirationTime=e.expirationTime,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,s=e.dependencies,r.dependencies=s===null?null:{expirationTime:s.expirationTime,firstContext:s.firstContext,responders:s.responders}),n=n.sibling;return ue(ae,ae.current&1|2),t.child}s=s.sibling}}else{if(!r)if(e=_s(s),e!==null){if(t.effectTag|=64,r=!0,i=e.updateQueue,i!==null&&(t.updateQueue=i,t.effectTag|=4),qr(n,!0),n.tail===null&&n.tailMode==="hidden"&&!s.alternate)return t=t.lastEffect=n.lastEffect,t!==null&&(t.nextEffect=null),null}else 2*Ze()-n.renderingStartTime>n.tailExpiration&&1<i&&(t.effectTag|=64,r=!0,qr(n,!1),t.expirationTime=t.childExpirationTime=i-1);n.isBackwards?(s.sibling=t.child,t.child=s):(i=n.last,i!==null?i.sibling=s:t.child=s,n.last=s)}return n.tail!==null?(n.tailExpiration===0&&(n.tailExpiration=Ze()+500),i=n.tail,n.rendering=i,n.tail=i.sibling,n.lastEffect=t.lastEffect,n.renderingStartTime=Ze(),i.sibling=null,t=ae.current,ue(ae,r?t&1|2:t&1),i):null}throw Error(C(156,t.tag))}function xS(e){switch(e.tag){case 1:Re(e.type)&&Bs();var t=e.effectTag;return t&4096?(e.effectTag=t&-4097|64,e):null;case 3:if(un(),q(Le),q(Ce),t=e.effectTag,(t&64)!==0)throw Error(C(285));return e.effectTag=t&-4097|64,e;case 5:return yu(e),null;case 13:return q(ae),t=e.effectTag,t&4096?(e.effectTag=t&-4097|64,e):null;case 19:return q(ae),null;case 4:return un(),null;case 10:return gu(e),null;default:return null}}function Tu(e,t){return{value:e,source:t,stack:Kl(t)}}var SS=typeof WeakSet=="function"?WeakSet:Set;function Ka(e,t){var i=t.source,n=t.stack;n===null&&i!==null&&(n=Kl(i)),i!==null&&Tt(i.type),t=t.value,e!==null&&e.tag===1&&Tt(e.type);try{console.error(t)}catch(r){setTimeout(function(){throw r})}}function MS(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(i){yi(e,i)}}function Th(e){var t=e.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){yi(e,i)}else t.current=null}function CS(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(t.effectTag&256&&e!==null){var i=e.memoizedProps,n=e.memoizedState;e=t.stateNode,t=e.getSnapshotBeforeUpdate(t.elementType===t.type?i:qe(t.type,i),n),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(C(163))}function eg(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var i=t=t.next;do{if((i.tag&e)===e){var n=i.destroy;i.destroy=void 0,n!==void 0&&n()}i=i.next}while(i!==t)}}function tg(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var i=t=t.next;do{if((i.tag&e)===e){var n=i.create;i.destroy=n()}i=i.next}while(i!==t)}}function bS(e,t,i){switch(i.tag){case 0:case 11:case 15:case 22:tg(3,i);return;case 1:if(e=i.stateNode,i.effectTag&4)if(t===null)e.componentDidMount();else{var n=i.elementType===i.type?t.memoizedProps:qe(i.type,t.memoizedProps);e.componentDidUpdate(n,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}t=i.updateQueue,t!==null&&hh(i,t,e);return;case 3:if(t=i.updateQueue,t!==null){if(e=null,i.child!==null)switch(i.child.tag){case 5:e=i.child.stateNode;break;case 1:e=i.child.stateNode}hh(i,t,e)}return;case 5:e=i.stateNode,t===null&&i.effectTag&4&&gp(i.type,i.memoizedProps)&&e.focus();return;case 6:return;case 4:return;case 12:return;case 13:i.memoizedState===null&&(i=i.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&ap(i))));return;case 19:case 17:case 20:case 21:return}throw Error(C(163))}function Ah(e,t,i){switch(typeof ol=="function"&&ol(t),t.tag){case 0:case 11:case 14:case 15:case 22:if(e=t.updateQueue,e!==null&&(e=e.lastEffect,e!==null)){var n=e.next;Xt(97<i?97:i,function(){var r=n;do{var s=r.destroy;if(s!==void 0){var o=t;try{s()}catch(a){yi(o,a)}}r=r.next}while(r!==n)})}break;case 1:Th(t),i=t.stateNode,typeof i.componentWillUnmount=="function"&&MS(t,i);break;case 5:Th(t);break;case 4:ng(e,t,i)}}function ig(e){var t=e.alternate;e.return=null,e.child=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.alternate=null,e.firstEffect=null,e.lastEffect=null,e.pendingProps=null,e.memoizedProps=null,e.stateNode=null,t!==null&&ig(t)}function Eh(e){return e.tag===5||e.tag===3||e.tag===4}function Nh(e){e:{for(var t=e.return;t!==null;){if(Eh(t)){var i=t;break e}t=t.return}throw Error(C(160))}switch(t=i.stateNode,i.tag){case 5:var n=!1;break;case 3:t=t.containerInfo,n=!0;break;case 4:t=t.containerInfo,n=!0;break;default:throw Error(C(161))}i.effectTag&16&&(ir(t,""),i.effectTag&=-17);e:t:for(i=e;;){for(;i.sibling===null;){if(i.return===null||Eh(i.return)){i=null;break e}i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.effectTag&2||i.child===null||i.tag===4)continue t;i.child.return=i,i=i.child}if(!(i.effectTag&2)){i=i.stateNode;break e}}n?qa(e,i,t):el(e,i,t)}function qa(e,t,i){var n=e.tag,r=n===5||n===6;if(r)e=r?e.stateNode:e.stateNode.instance,t?i.nodeType===8?i.parentNode.insertBefore(e,t):i.insertBefore(e,t):(i.nodeType===8?(t=i.parentNode,t.insertBefore(e,i)):(t=i,t.appendChild(e)),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=ks));else if(n!==4&&(e=e.child,e!==null))for(qa(e,t,i),e=e.sibling;e!==null;)qa(e,t,i),e=e.sibling}function el(e,t,i){var n=e.tag,r=n===5||n===6;if(r)e=r?e.stateNode:e.stateNode.instance,t?i.insertBefore(e,t):i.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for(el(e,t,i),e=e.sibling;e!==null;)el(e,t,i),e=e.sibling}function ng(e,t,i){for(var n=t,r=!1,s,o;;){if(!r){r=n.return;e:for(;;){if(r===null)throw Error(C(160));switch(s=r.stateNode,r.tag){case 5:o=!1;break e;case 3:s=s.containerInfo,o=!0;break e;case 4:s=s.containerInfo,o=!0;break e}r=r.return}r=!0}if(n.tag===5||n.tag===6){e:for(var a=e,l=n,u=i,c=l;;)if(Ah(a,c,u),c.child!==null&&c.tag!==4)c.child.return=c,c=c.child;else{if(c===l)break e;for(;c.sibling===null;){if(c.return===null||c.return===l)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}o?(a=s,l=n.stateNode,a.nodeType===8?a.parentNode.removeChild(l):a.removeChild(l)):s.removeChild(n.stateNode)}else if(n.tag===4){if(n.child!==null){s=n.stateNode.containerInfo,o=!0,n.child.return=n,n=n.child;continue}}else if(Ah(e,n,i),n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return,n.tag===4&&(r=!1)}n.sibling.return=n.return,n=n.sibling}}function Zo(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:eg(3,t);return;case 1:return;case 5:var i=t.stateNode;if(i!=null){var n=t.memoizedProps,r=e!==null?e.memoizedProps:n;e=t.type;var s=t.updateQueue;if(t.updateQueue=null,s!==null){for(i[Ps]=n,e==="input"&&n.type==="radio"&&n.name!=null&&Wf(i,n),Da(e,r),t=Da(e,n),r=0;r<s.length;r+=2){var o=s[r],a=s[r+1];o==="style"?hp(i,a):o==="dangerouslySetInnerHTML"?Zf(i,a):o==="children"?ir(i,a):Gl(i,o,a,t)}switch(e){case"input":ba(i,n);break;case"textarea":Hf(i,n);break;case"select":t=i._wrapperState.wasMultiple,i._wrapperState.wasMultiple=!!n.multiple,e=n.value,e!=null?Xi(i,!!n.multiple,e,!1):t!==!!n.multiple&&(n.defaultValue!=null?Xi(i,!!n.multiple,n.defaultValue,!0):Xi(i,!!n.multiple,n.multiple?[]:"",!1))}}}return;case 6:if(t.stateNode===null)throw Error(C(162));t.stateNode.nodeValue=t.memoizedProps;return;case 3:t=t.stateNode,t.hydrate&&(t.hydrate=!1,ap(t.containerInfo));return;case 12:return;case 13:if(i=t,t.memoizedState===null?n=!1:(n=!0,i=t.child,Nu=Ze()),i!==null)e:for(e=i;;){if(e.tag===5)s=e.stateNode,n?(s=s.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(s=e.stateNode,r=e.memoizedProps.style,r=r!=null&&r.hasOwnProperty("display")?r.display:null,s.style.display=cp("display",r));else if(e.tag===6)e.stateNode.nodeValue=n?"":e.memoizedProps;else if(e.tag===13&&e.memoizedState!==null&&e.memoizedState.dehydrated===null){s=e.child.sibling,s.return=e,e=s;continue}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===i)break;for(;e.sibling===null;){if(e.return===null||e.return===i)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}kh(t);return;case 19:kh(t);return;case 17:return}throw Error(C(163))}function kh(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new SS),t.forEach(function(n){var r=DS.bind(null,e,n);i.has(n)||(i.add(n),n.then(r,r))})}}var IS=typeof WeakMap=="function"?WeakMap:Map;function rg(e,t,i){i=Ht(i,null),i.tag=3,i.payload={element:null};var n=t.value;return i.callback=function(){Ys||(Ys=!0,tl=n),Ka(e,t)},i}function sg(e,t,i){i=Ht(i,null),i.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var r=t.value;i.payload=function(){return Ka(e,t),n(r)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(i.callback=function(){typeof n!="function"&&(Qt===null?Qt=new Set([this]):Qt.add(this),Ka(e,t));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),i}var TS=Math.ceil,Ws=tt.ReactCurrentDispatcher,og=tt.ReactCurrentOwner,me=0,Au=8,it=16,gt=32,vi=0,Hs=1,ag=2,Fs=3,mo=4,Eu=5,$=me,We=null,W=null,je=0,ge=vi,vo=null,Ct=1073741823,cr=1073741823,Qs=null,hr=0,Zs=!1,Nu=0,lg=500,L=null,Ys=!1,tl=null,Qt=null,Gs=!1,Gn=null,Ln=90,ci=null,Xn=0,il=null,ws=0;function pt(){return($&(it|gt))!==me?1073741821-(Ze()/10|0):ws!==0?ws:ws=1073741821-(Ze()/10|0)}function wi(e,t,i){if(t=t.mode,(t&2)===0)return 1073741823;var n=po();if((t&4)===0)return n===99?1073741823:1073741822;if(($&it)!==me)return je;if(i!==null)e=ms(e,i.timeoutMs|0||5e3,250);else switch(n){case 99:e=1073741823;break;case 98:e=ms(e,150,100);break;case 97:case 96:e=ms(e,5e3,250);break;case 95:e=2;break;default:throw Error(C(326))}return We!==null&&e===je&&--e,e}function Zt(e,t){if(50<Xn)throw Xn=0,il=null,Error(C(185));if(e=wo(e,t),e!==null){var i=po();t===1073741823?($&Au)!==me&&($&(it|gt))===me?nl(e):(He(e),$===me&&mt()):He(e),($&4)===me||i!==98&&i!==99||(ci===null?ci=new Map([[e,t]]):(i=ci.get(e),(i===void 0||i>t)&&ci.set(e,t)))}}function wo(e,t){e.expirationTime<t&&(e.expirationTime=t);var i=e.alternate;i!==null&&i.expirationTime<t&&(i.expirationTime=t);var n=e.return,r=null;if(n===null&&e.tag===3)r=e.stateNode;else for(;n!==null;){if(i=n.alternate,n.childExpirationTime<t&&(n.childExpirationTime=t),i!==null&&i.childExpirationTime<t&&(i.childExpirationTime=t),n.return===null&&n.tag===3){r=n.stateNode;break}n=n.return}return r!==null&&(We===r&&(yo(t),ge===mo&&di(r,je)),yg(r,t)),r}function ys(e){var t=e.lastExpiredTime;if(t!==0||(t=e.firstPendingTime,!wg(e,t)))return t;var i=e.lastPingedTime;return e=e.nextKnownPendingLevel,e=i>e?i:e,2>=e&&t!==e?0:e}function He(e){if(e.lastExpiredTime!==0)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=uh(nl.bind(null,e));else{var t=ys(e),i=e.callbackNode;if(t===0)i!==null&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var n=pt();if(t===1073741823?n=99:t===1||t===2?n=95:(n=10*(1073741821-t)-10*(1073741821-n),n=0>=n?99:250>=n?98:5250>=n?97:95),i!==null){var r=e.callbackPriority;if(e.callbackExpirationTime===t&&r>=n)return;i!==Dp&&Np(i)}e.callbackExpirationTime=t,e.callbackPriority=n,t=t===1073741823?uh(nl.bind(null,e)):Rp(n,ug.bind(null,e),{timeout:10*(1073741821-t)-Ze()}),e.callbackNode=t}}}function ug(e,t){if(ws=0,t)return t=pt(),al(e,t),He(e),null;var i=ys(e);if(i!==0){if(t=e.callbackNode,($&(it|gt))!==me)throw Error(C(327));if(gn(),e===We&&i===je||hi(e,i),W!==null){var n=$;$|=it;var r=fg();do try{NS();break}catch(a){dg(e,a)}while(1);if(pu(),$=n,Ws.current=r,ge===Hs)throw t=vo,hi(e,i),di(e,i),He(e),t;if(W===null)switch(r=e.finishedWork=e.current.alternate,e.finishedExpirationTime=i,n=ge,We=null,n){case vi:case Hs:throw Error(C(345));case ag:al(e,2<i?2:i);break;case Fs:if(di(e,i),n=e.lastSuspendedTime,i===n&&(e.nextKnownPendingLevel=rl(r)),Ct===1073741823&&(r=Nu+lg-Ze(),10<r)){if(Zs){var s=e.lastPingedTime;if(s===0||s>=i){e.lastPingedTime=i,hi(e,i);break}}if(s=ys(e),s!==0&&s!==i)break;if(n!==0&&n!==i){e.lastPingedTime=n;break}e.timeoutHandle=$o(si.bind(null,e),r);break}si(e);break;case mo:if(di(e,i),n=e.lastSuspendedTime,i===n&&(e.nextKnownPendingLevel=rl(r)),Zs&&(r=e.lastPingedTime,r===0||r>=i)){e.lastPingedTime=i,hi(e,i);break}if(r=ys(e),r!==0&&r!==i)break;if(n!==0&&n!==i){e.lastPingedTime=n;break}if(cr!==1073741823?n=10*(1073741821-cr)-Ze():Ct===1073741823?n=0:(n=10*(1073741821-Ct)-5e3,r=Ze(),i=10*(1073741821-i)-r,n=r-n,0>n&&(n=0),n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*TS(n/1960))-n,i<n&&(n=i)),10<n){e.timeoutHandle=$o(si.bind(null,e),n);break}si(e);break;case Eu:if(Ct!==1073741823&&Qs!==null){s=Ct;var o=Qs;if(n=o.busyMinDurationMs|0,0>=n?n=0:(r=o.busyDelayMs|0,s=Ze()-(10*(1073741821-s)-(o.timeoutMs|0||5e3)),n=s<=r?0:r+n-s),10<n){di(e,i),e.timeoutHandle=$o(si.bind(null,e),n);break}}si(e);break;default:throw Error(C(329))}if(He(e),e.callbackNode===t)return ug.bind(null,e)}}return null}function nl(e){var t=e.lastExpiredTime;if(t=t!==0?t:1073741823,($&(it|gt))!==me)throw Error(C(327));if(gn(),e===We&&t===je||hi(e,t),W!==null){var i=$;$|=it;var n=fg();do try{ES();break}catch(r){dg(e,r)}while(1);if(pu(),$=i,Ws.current=n,ge===Hs)throw i=vo,hi(e,t),di(e,t),He(e),i;if(W!==null)throw Error(C(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,We=null,si(e),He(e)}return null}function AS(){if(ci!==null){var e=ci;ci=null,e.forEach(function(t,i){al(i,t),He(i)}),mt()}}function cg(e,t){var i=$;$|=1;try{return e(t)}finally{$=i,$===me&&mt()}}function hg(e,t){var i=$;$&=-2,$|=Au;try{return e(t)}finally{$=i,$===me&&mt()}}function hi(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,T0(i)),W!==null)for(i=W.return;i!==null;){var n=i;switch(n.tag){case 1:n=n.type.childContextTypes,n!=null&&Bs();break;case 3:un(),q(Le),q(Ce);break;case 5:yu(n);break;case 4:un();break;case 13:q(ae);break;case 19:q(ae);break;case 10:gu(n)}i=i.return}We=e,W=Ii(e.current,null),je=t,ge=vi,vo=null,cr=Ct=1073741823,Qs=null,hr=0,Zs=!1}function dg(e,t){do{try{if(pu(),vs.current=Us,Vs)for(var i=de.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}if(Rt=0,Me=Se=de=null,Vs=!1,W===null||W.return===null)return ge=Hs,vo=t,W=null;e:{var r=e,s=W.return,o=W,a=t;if(t=je,o.effectTag|=2048,o.firstEffect=o.lastEffect=null,a!==null&&typeof a=="object"&&typeof a.then=="function"){var l=a;if((o.mode&2)===0){var u=o.alternate;u?(o.updateQueue=u.updateQueue,o.memoizedState=u.memoizedState,o.expirationTime=u.expirationTime):(o.updateQueue=null,o.memoizedState=null)}var c=(ae.current&1)!==0,h=s;do{var m;if(m=h.tag===13){var v=h.memoizedState;if(v!==null)m=v.dehydrated!==null;else{var w=h.memoizedProps;m=w.fallback===void 0?!1:w.unstable_avoidThisFallback!==!0?!0:!c}}if(m){var x=h.updateQueue;if(x===null){var d=new Set;d.add(l),h.updateQueue=d}else x.add(l);if((h.mode&2)===0){if(h.effectTag|=64,o.effectTag&=-2981,o.tag===1)if(o.alternate===null)o.tag=17;else{var f=Ht(1073741823,null);f.tag=2,Ft(o,f)}o.expirationTime=1073741823;break e}a=void 0,o=t;var g=r.pingCache;if(g===null?(g=r.pingCache=new IS,a=new Set,g.set(l,a)):(a=g.get(l),a===void 0&&(a=new Set,g.set(l,a))),!a.has(o)){a.add(o);var p=BS.bind(null,r,l,o);l.then(p,p)}h.effectTag|=4096,h.expirationTime=t;break e}h=h.return}while(h!==null);a=Error((Tt(o.type)||"A React component")+` suspended while rendering, but no fallback UI was specified.
45
-
46
- Add a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.`+Kl(o))}ge!==Eu&&(ge=ag),a=Tu(a,o),h=s;do{switch(h.tag){case 3:l=a,h.effectTag|=4096,h.expirationTime=t;var y=rg(h,l,t);ch(h,y);break e;case 1:l=a;var S=h.type,A=h.stateNode;if((h.effectTag&64)===0&&(typeof S.getDerivedStateFromError=="function"||A!==null&&typeof A.componentDidCatch=="function"&&(Qt===null||!Qt.has(A)))){h.effectTag|=4096,h.expirationTime=t;var k=sg(h,l,t);ch(h,k);break e}}h=h.return}while(h!==null)}W=mg(W)}catch(z){t=z;continue}break}while(1)}function fg(){var e=Ws.current;return Ws.current=Us,e===null?Us:e}function pg(e,t){e<Ct&&2<e&&(Ct=e),t!==null&&e<cr&&2<e&&(cr=e,Qs=t)}function yo(e){e>hr&&(hr=e)}function ES(){for(;W!==null;)W=gg(W)}function NS(){for(;W!==null&&!fS();)W=gg(W)}function gg(e){var t=vg(e.alternate,e,je);return e.memoizedProps=e.pendingProps,t===null&&(t=mg(e)),og.current=null,t}function mg(e){W=e;do{var t=W.alternate;if(e=W.return,(W.effectTag&2048)===0){if(t=yS(t,W,je),je===1||W.childExpirationTime!==1){for(var i=0,n=W.child;n!==null;){var r=n.expirationTime,s=n.childExpirationTime;r>i&&(i=r),s>i&&(i=s),n=n.sibling}W.childExpirationTime=i}if(t!==null)return t;e!==null&&(e.effectTag&2048)===0&&(e.firstEffect===null&&(e.firstEffect=W.firstEffect),W.lastEffect!==null&&(e.lastEffect!==null&&(e.lastEffect.nextEffect=W.firstEffect),e.lastEffect=W.lastEffect),1<W.effectTag&&(e.lastEffect!==null?e.lastEffect.nextEffect=W:e.firstEffect=W,e.lastEffect=W))}else{if(t=xS(W),t!==null)return t.effectTag&=2047,t;e!==null&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(t=W.sibling,t!==null)return t;W=e}while(W!==null);return ge===vi&&(ge=Eu),null}function rl(e){var t=e.expirationTime;return e=e.childExpirationTime,t>e?t:e}function si(e){var t=po();return Xt(99,kS.bind(null,e,t)),null}function kS(e,t){do gn();while(Gn!==null);if(($&(it|gt))!==me)throw Error(C(327));var i=e.finishedWork,n=e.finishedExpirationTime;if(i===null)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,i===e.current)throw Error(C(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var r=rl(i);if(e.firstPendingTime=r,n<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:n<=e.firstSuspendedTime&&(e.firstSuspendedTime=n-1),n<=e.lastPingedTime&&(e.lastPingedTime=0),n<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===We&&(W=We=null,je=0),1<i.effectTag?i.lastEffect!==null?(i.lastEffect.nextEffect=i,r=i.firstEffect):r=i:r=i.firstEffect,r!==null){var s=$;$|=gt,og.current=null,Vo=cs;var o=Yc();if(Ra(o)){if("selectionStart"in o)var a={start:o.selectionStart,end:o.selectionEnd};else e:{a=(a=o.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,c=l.focusNode;l=l.focusOffset;try{a.nodeType,c.nodeType}catch{a=null;break e}var h=0,m=-1,v=-1,w=0,x=0,d=o,f=null;t:for(;;){for(var g;d!==a||u!==0&&d.nodeType!==3||(m=h+u),d!==c||l!==0&&d.nodeType!==3||(v=h+l),d.nodeType===3&&(h+=d.nodeValue.length),(g=d.firstChild)!==null;)f=d,d=g;for(;;){if(d===o)break t;if(f===a&&++w===u&&(m=h),f===c&&++x===l&&(v=h),(g=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=g}a=m===-1||v===-1?null:{start:m,end:v}}else a=null}a=a||{start:0,end:0}}else a=null;Oo={activeElementDetached:null,focusedElem:o,selectionRange:a},cs=!1,L=r;do try{PS()}catch(B){if(L===null)throw Error(C(330));yi(L,B),L=L.nextEffect}while(L!==null);L=r;do try{for(o=e,a=t;L!==null;){var p=L.effectTag;if(p&16&&ir(L.stateNode,""),p&128){var y=L.alternate;if(y!==null){var S=y.ref;S!==null&&(typeof S=="function"?S(null):S.current=null)}}switch(p&1038){case 2:Nh(L),L.effectTag&=-3;break;case 6:Nh(L),L.effectTag&=-3,Zo(L.alternate,L);break;case 1024:L.effectTag&=-1025;break;case 1028:L.effectTag&=-1025,Zo(L.alternate,L);break;case 4:Zo(L.alternate,L);break;case 8:u=L,ng(o,u,a),ig(u)}L=L.nextEffect}}catch(B){if(L===null)throw Error(C(330));yi(L,B),L=L.nextEffect}while(L!==null);if(S=Oo,y=Yc(),p=S.focusedElem,a=S.selectionRange,y!==p&&p&&p.ownerDocument&&dp(p.ownerDocument.documentElement,p)){for(a!==null&&Ra(p)&&(y=a.start,S=a.end,S===void 0&&(S=y),"selectionStart"in p?(p.selectionStart=y,p.selectionEnd=Math.min(S,p.value.length)):(S=(y=p.ownerDocument||document)&&y.defaultView||window,S.getSelection&&(S=S.getSelection(),u=p.textContent.length,o=Math.min(a.start,u),a=a.end===void 0?o:Math.min(a.end,u),!S.extend&&o>a&&(u=a,a=o,o=u),u=Zc(p,o),c=Zc(p,a),u&&c&&(S.rangeCount!==1||S.anchorNode!==u.node||S.anchorOffset!==u.offset||S.focusNode!==c.node||S.focusOffset!==c.offset)&&(y=y.createRange(),y.setStart(u.node,u.offset),S.removeAllRanges(),o>a?(S.addRange(y),S.extend(c.node,c.offset)):(y.setEnd(c.node,c.offset),S.addRange(y)))))),y=[],S=p;S=S.parentNode;)S.nodeType===1&&y.push({element:S,left:S.scrollLeft,top:S.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<y.length;p++)S=y[p],S.element.scrollLeft=S.left,S.element.scrollTop=S.top}cs=!!Vo,Oo=Vo=null,e.current=i,L=r;do try{for(p=e;L!==null;){var A=L.effectTag;if(A&36&&bS(p,L.alternate,L),A&128){y=void 0;var k=L.ref;if(k!==null){var z=L.stateNode;switch(L.tag){case 5:y=z;break;default:y=z}typeof k=="function"?k(y):k.current=y}}L=L.nextEffect}}catch(B){if(L===null)throw Error(C(330));yi(L,B),L=L.nextEffect}while(L!==null);L=null,pS(),$=s}else e.current=i;if(Gs)Gs=!1,Gn=e,Ln=t;else for(L=r;L!==null;)t=L.nextEffect,L.nextEffect=null,L=t;if(t=e.firstPendingTime,t===0&&(Qt=null),t===1073741823?e===il?Xn++:(Xn=0,il=e):Xn=0,typeof sl=="function"&&sl(i.stateNode,n),He(e),Ys)throw Ys=!1,e=tl,tl=null,e;return($&Au)!==me||mt(),null}function PS(){for(;L!==null;){var e=L.effectTag;(e&256)!==0&&CS(L.alternate,L),(e&512)===0||Gs||(Gs=!0,Rp(97,function(){return gn(),null})),L=L.nextEffect}}function gn(){if(Ln!==90){var e=97<Ln?97:Ln;return Ln=90,Xt(e,zS)}}function zS(){if(Gn===null)return!1;var e=Gn;if(Gn=null,($&(it|gt))!==me)throw Error(C(331));var t=$;for($|=gt,e=e.current.firstEffect;e!==null;){try{var i=e;if((i.effectTag&512)!==0)switch(i.tag){case 0:case 11:case 15:case 22:eg(5,i),tg(5,i)}}catch(n){if(e===null)throw Error(C(330));yi(e,n)}i=e.nextEffect,e.nextEffect=null,e=i}return $=t,mt(),!0}function Ph(e,t,i){t=Tu(i,t),t=rg(e,t,1073741823),Ft(e,t),e=wo(e,1073741823),e!==null&&He(e)}function yi(e,t){if(e.tag===3)Ph(e,e,t);else for(var i=e.return;i!==null;){if(i.tag===3){Ph(i,e,t);break}else if(i.tag===1){var n=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Qt===null||!Qt.has(n))){e=Tu(t,e),e=sg(i,e,1073741823),Ft(i,e),i=wo(i,1073741823),i!==null&&He(i);break}}i=i.return}}function BS(e,t,i){var n=e.pingCache;n!==null&&n.delete(t),We===e&&je===i?ge===mo||ge===Fs&&Ct===1073741823&&Ze()-Nu<lg?hi(e,je):Zs=!0:wg(e,i)&&(t=e.lastPingedTime,t!==0&&t<i||(e.lastPingedTime=i,He(e)))}function DS(e,t){var i=e.stateNode;i!==null&&i.delete(t),t=0,t===0&&(t=pt(),t=wi(t,e,null)),e=wo(e,t),e!==null&&He(e)}var vg;vg=function(e,t,i){var n=t.expirationTime;if(e!==null){var r=t.pendingProps;if(e.memoizedProps!==r||Le.current)ht=!0;else{if(n<i){switch(ht=!1,t.tag){case 3:Mh(t),Ho();break;case 5:if(ph(t),t.mode&4&&i!==1&&r.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:Re(t.type)&&ps(t);break;case 4:Fa(t,t.stateNode.containerInfo);break;case 10:n=t.memoizedProps.value,r=t.type._context,ue(Ds,r._currentValue),r._currentValue=n;break;case 13:if(t.memoizedState!==null)return n=t.child.childExpirationTime,n!==0&&n>=i?Ch(e,t,i):(ue(ae,ae.current&1),t=It(e,t,i),t!==null?t.sibling:null);ue(ae,ae.current&1);break;case 19:if(n=t.childExpirationTime>=i,(e.effectTag&64)!==0){if(n)return Ih(e,t,i);t.effectTag|=64}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null),ue(ae,ae.current),!n)return null}return It(e,t,i)}ht=!1}}else ht=!1;switch(t.expirationTime=0,t.tag){case 2:if(n=t.type,e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,r=an(t,Ce.current),Ki(t,i),r=Mu(null,t,n,e,r,i),t.effectTag|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,Re(n)){var s=!0;ps(t)}else s=!1;t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,mu(t);var o=n.getDerivedStateFromProps;typeof o=="function"&&js(t,n,o,e),r.updater=go,t.stateNode=r,r._reactInternalFiber=t,Ha(t,n,e,i),t=Xa(null,t,n,!0,s,i)}else t.tag=0,$e(null,t,r,i),t=t.child;return t;case 16:e:{if(r=t.elementType,e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,u0(r),r._status!==1)throw r._result;switch(r=r._result,t.type=r,s=t.tag=jS(r),e=qe(r,e),s){case 0:t=Ga(null,t,r,e,i);break e;case 1:t=Sh(null,t,r,e,i);break e;case 11:t=yh(null,t,r,e,i);break e;case 14:t=xh(null,t,r,qe(r.type,e),n,i);break e}throw Error(C(306,r,""))}return t;case 0:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:qe(n,r),Ga(e,t,n,r,i);case 1:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:qe(n,r),Sh(e,t,n,r,i);case 3:if(Mh(t),n=t.updateQueue,e===null||n===null)throw Error(C(282));if(n=t.pendingProps,r=t.memoizedState,r=r!==null?r.element:null,vu(e,t),ar(t,n,null,i),n=t.memoizedState.element,n===r)Ho(),t=It(e,t,i);else{if((r=t.stateNode.hydrate)&&(jt=Ji(t.stateNode.containerInfo.firstChild),bt=t,r=mi=!0),r)for(i=wu(t,null,n,i),t.child=i;i;)i.effectTag=i.effectTag&-3|1024,i=i.sibling;else $e(e,t,n,i),Ho();t=t.child}return t;case 5:return ph(t),e===null&&Ya(t),n=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,ja(n,r)?o=null:s!==null&&ja(n,s)&&(t.effectTag|=16),Xp(e,t),t.mode&4&&i!==1&&r.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):($e(e,t,o,i),t=t.child),t;case 6:return e===null&&Ya(t),null;case 13:return Ch(e,t,i);case 4:return Fa(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=ln(t,null,n,i):$e(e,t,n,i),t.child;case 11:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:qe(n,r),yh(e,t,n,r,i);case 7:return $e(e,t,t.pendingProps,i),t.child;case 8:return $e(e,t,t.pendingProps.children,i),t.child;case 12:return $e(e,t,t.pendingProps.children,i),t.child;case 10:e:{n=t.type._context,r=t.pendingProps,o=t.memoizedProps,s=r.value;var a=t.type._context;if(ue(Ds,a._currentValue),a._currentValue=s,o!==null)if(a=o.value,s=Ci(a,s)?0:(typeof n._calculateChangedBits=="function"?n._calculateChangedBits(a,s):1073741823)|0,s===0){if(o.children===r.children&&!Le.current){t=It(e,t,i);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var l=a.dependencies;if(l!==null){o=a.child;for(var u=l.firstContext;u!==null;){if(u.context===n&&(u.observedBits&s)!==0){a.tag===1&&(u=Ht(i,null),u.tag=2,Ft(a,u)),a.expirationTime<i&&(a.expirationTime=i),u=a.alternate,u!==null&&u.expirationTime<i&&(u.expirationTime=i),_p(a.return,i),l.expirationTime<i&&(l.expirationTime=i);break}u=u.next}}else o=a.tag===10&&a.type===t.type?null:a.child;if(o!==null)o.return=a;else for(o=a;o!==null;){if(o===t){o=null;break}if(a=o.sibling,a!==null){a.return=o.return,o=a;break}o=o.return}a=o}$e(e,t,r.children,i),t=t.child}return t;case 9:return r=t.type,s=t.pendingProps,n=s.children,Ki(t,i),r=Ge(r,s.unstable_observedBits),n=n(r),t.effectTag|=1,$e(e,t,n,i),t.child;case 14:return r=t.type,s=qe(r,t.pendingProps),s=qe(r.type,s),xh(e,t,r,s,n,i);case 15:return Gp(e,t,t.type,t.pendingProps,n,i);case 17:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:qe(n,r),e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,Re(n)?(e=!0,ps(t)):e=!1,Ki(t,i),Op(t,n,r),Ha(t,n,r,i),Xa(null,t,n,!0,e,i);case 19:return Ih(e,t,i)}throw Error(C(156,t.tag))};var sl=null,ol=null;function LS(e){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined")return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var i=t.inject(e);sl=function(n){try{t.onCommitFiberRoot(i,n,void 0,(n.current.effectTag&64)===64)}catch{}},ol=function(n){try{t.onCommitFiberUnmount(i,n)}catch{}}}catch{}return!0}function RS(e,t,i,n){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childExpirationTime=this.expirationTime=0,this.alternate=null}function dt(e,t,i,n){return new RS(e,t,i,n)}function ku(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jS(e){if(typeof e=="function")return ku(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Xl)return 11;if(e===Jl)return 14}return 2}function Ii(e,t){var i=e.alternate;return i===null?(i=dt(e.tag,t,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=t,i.effectTag=0,i.nextEffect=null,i.firstEffect=null,i.lastEffect=null),i.childExpirationTime=e.childExpirationTime,i.expirationTime=e.expirationTime,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,t=e.dependencies,i.dependencies=t===null?null:{expirationTime:t.expirationTime,firstContext:t.firstContext,responders:t.responders},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function xs(e,t,i,n,r,s){var o=2;if(n=e,typeof e=="function")ku(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ai:return _t(i.children,r,s,t);case l0:o=8,r|=7;break;case Rf:o=8,r|=1;break;case as:return e=dt(12,i,t,r|8),e.elementType=as,e.type=as,e.expirationTime=s,e;case ls:return e=dt(13,i,t,r),e.type=ls,e.elementType=ls,e.expirationTime=s,e;case Ma:return e=dt(19,i,t,r),e.elementType=Ma,e.expirationTime=s,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case jf:o=10;break e;case _f:o=9;break e;case Xl:o=11;break e;case Jl:o=14;break e;case Vf:o=16,n=null;break e;case Of:o=22;break e}throw Error(C(130,e==null?e:typeof e,""))}return t=dt(o,i,t,r),t.elementType=e,t.type=n,t.expirationTime=s,t}function _t(e,t,i,n){return e=dt(7,e,n,t),e.expirationTime=i,e}function Yo(e,t,i){return e=dt(6,e,null,t),e.expirationTime=i,e}function Go(e,t,i){return t=dt(4,e.children!==null?e.children:[],e.key,t),t.expirationTime=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function _S(e,t,i){this.tag=t,this.current=null,this.containerInfo=e,this.pingCache=this.pendingChildren=null,this.finishedExpirationTime=0,this.finishedWork=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=i,this.callbackNode=null,this.callbackPriority=90,this.lastExpiredTime=this.lastPingedTime=this.nextKnownPendingLevel=this.lastSuspendedTime=this.firstSuspendedTime=this.firstPendingTime=0}function wg(e,t){var i=e.firstSuspendedTime;return e=e.lastSuspendedTime,i!==0&&i>=t&&e<=t}function di(e,t){var i=e.firstSuspendedTime,n=e.lastSuspendedTime;i<t&&(e.firstSuspendedTime=t),(n>t||i===0)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function yg(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var i=e.firstSuspendedTime;i!==0&&(t>=i?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function al(e,t){var i=e.lastExpiredTime;(i===0||i>t)&&(e.lastExpiredTime=t)}function Xs(e,t,i,n){var r=t.current,s=pt(),o=Yn.suspense;s=wi(s,r,o);e:if(i){i=i._reactInternalFiber;t:{if(Ni(i)!==i||i.tag!==1)throw Error(C(170));var a=i;do{switch(a.tag){case 3:a=a.stateNode.context;break t;case 1:if(Re(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break t}}a=a.return}while(a!==null);throw Error(C(171))}if(i.tag===1){var l=i.type;if(Re(l)){i=Ep(i,l,a);break e}}i=a}else i=Gt;return t.context===null?t.context=i:t.pendingContext=i,t=Ht(s,o),t.payload={element:e},n=n===void 0?null:n,n!==null&&(t.callback=n),Ft(r,t),Zt(r,s),s}function Xo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function zh(e,t){e=e.memoizedState,e!==null&&e.dehydrated!==null&&e.retryTime<t&&(e.retryTime=t)}function Pu(e,t){zh(e,t),(e=e.alternate)&&zh(e,t)}function zu(e,t,i){i=i!=null&&i.hydrate===!0;var n=new _S(e,t,i),r=dt(3,null,null,t===2?7:t===1?3:0);n.current=r,r.stateNode=n,mu(r),e[Ar]=n.current,i&&t!==0&&g0(e,e.nodeType===9?e:e.ownerDocument),this._internalRoot=n}zu.prototype.render=function(e){Xs(e,this._internalRoot,null,null)};zu.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;Xs(null,e,null,function(){t[Ar]=null})};function Br(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function VS(e,t){if(t||(t=e?e.nodeType===9?e.documentElement:e.firstChild:null,t=!(!t||t.nodeType!==1||!t.hasAttribute("data-reactroot"))),!t)for(var i;i=e.lastChild;)e.removeChild(i);return new zu(e,0,t?{hydrate:!0}:void 0)}function xo(e,t,i,n,r){var s=i._reactRootContainer;if(s){var o=s._internalRoot;if(typeof r=="function"){var a=r;r=function(){var u=Xo(o);a.call(u)}}Xs(t,o,e,r)}else{if(s=i._reactRootContainer=VS(i,n),o=s._internalRoot,typeof r=="function"){var l=r;r=function(){var u=Xo(o);l.call(u)}}hg(function(){Xs(t,o,e,r)})}return Xo(o)}function OS(e,t,i){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Vi,key:n==null?null:""+n,children:e,containerInfo:t,implementation:i}}sp=function(e){if(e.tag===13){var t=ms(pt(),150,100);Zt(e,t),Pu(e,t)}};iu=function(e){e.tag===13&&(Zt(e,3),Pu(e,3))};op=function(e){if(e.tag===13){var t=pt();t=wi(t,e,null),Zt(e,t),Pu(e,t)}};Sa=function(e,t,i){switch(t){case"input":if(ba(e,i),t=i.name,i.type==="radio"&&t!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<i.length;t++){var n=i[t];if(n!==e&&n.form===e.form){var r=uu(n);if(!r)throw Error(C(90));Uf(n),ba(n,r)}}}break;case"textarea":Hf(e,i);break;case"select":t=i.value,t!=null&&Xi(e,!!i.multiple,t,!1)}};Hl=cg;Bf=function(e,t,i,n,r){var s=$;$|=4;try{return Xt(98,e.bind(null,t,i,n,r))}finally{$=s,$===me&&mt()}};Fl=function(){($&(1|it|gt))===me&&(AS(),gn())};Df=function(e,t){var i=$;$|=2;try{return e(t)}finally{$=i,$===me&&mt()}};function xg(e,t){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Br(t))throw Error(C(200));return OS(e,t,null,i)}var $S={Events:[Nr,Mi,uu,kf,xa,on,function(e){eu(e,E0)},Pf,zf,co,uo,gn,{current:!1}]};(function(e){var t=e.findFiberByHostInstance;return LS(Ee({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:tt.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=ep(i),i===null?null:i.stateNode},findFiberByHostInstance:function(i){return t?t(i):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))})({findFiberByHostInstance:Er,bundleType:0,version:"16.14.0",rendererPackageName:"react-dom"});Xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=$S;Xe.createPortal=xg;Xe.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternalFiber;if(t===void 0)throw typeof e.render=="function"?Error(C(188)):Error(C(268,Object.keys(e)));return e=ep(t),e=e===null?null:e.stateNode,e};Xe.flushSync=function(e,t){if(($&(it|gt))!==me)throw Error(C(187));var i=$;$|=1;try{return Xt(99,e.bind(null,t))}finally{$=i,mt()}};Xe.hydrate=function(e,t,i){if(!Br(t))throw Error(C(200));return xo(null,e,t,!0,i)};Xe.render=function(e,t,i){if(!Br(t))throw Error(C(200));return xo(null,e,t,!1,i)};Xe.unmountComponentAtNode=function(e){if(!Br(e))throw Error(C(40));return e._reactRootContainer?(hg(function(){xo(null,null,e,!1,function(){e._reactRootContainer=null,e[Ar]=null})}),!0):!1};Xe.unstable_batchedUpdates=cg;Xe.unstable_createPortal=function(e,t){return xg(e,t,2<arguments.length&&arguments[2]!==void 0?arguments[2]:null)};Xe.unstable_renderSubtreeIntoContainer=function(e,t,i,n){if(!Br(i))throw Error(C(200));if(e==null||e._reactInternalFiber===void 0)throw Error(C(38));return xo(e,t,i,!1,n)};Xe.version="16.14.0";function Sg(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Sg)}catch(e){console.error(e)}}Sg(),bf.exports=Xe;var es=bf.exports,US=Object.defineProperty,WS=Object.defineProperties,HS=Object.getOwnPropertyDescriptors,Bh=Object.getOwnPropertySymbols,FS=Object.prototype.hasOwnProperty,QS=Object.prototype.propertyIsEnumerable,Dh=(e,t,i)=>t in e?US(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Ue=(e,t)=>{for(var i in t||(t={}))FS.call(t,i)&&Dh(e,i,t[i]);if(Bh)for(var i of Bh(t))QS.call(t,i)&&Dh(e,i,t[i]);return e};const ZS="0.1.0-alpha.5",Mg={src:"",currentTime:0,hostTime:0,muted:!1,paused:!0,volume:1},Cg={currentTimeMaxError:1,syncInterval:1e3,retryInterval:15e3,verbose:!1,log:console.log.bind(console)};let xt=Cg;function bg(e){xt=Ue(Ue({},Cg),e)}function ts(e,t){if(e.paused)return e.currentTime;const i=function(n){if(n.player)return n.player.beginTimestamp+n.player.progressTime;if(n.room)return n.room.calibrationTimestamp}(t);return i?e.currentTime+(i-e.hostTime)/1e3:e.currentTime}const YS=navigator.userAgent.includes("Safari"),GS=navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPad"),Ig=[".aac",".mid",".midi",".mp3",".ogg",".oga",".wav",".weba"];var XS=typeof global=="object"&&global&&global.Object===Object&&global,JS=typeof self=="object"&&self&&self.Object===Object&&self,Tg=XS||JS||Function("return this")(),Js=Tg.Symbol,Ag=Object.prototype,KS=Ag.hasOwnProperty,qS=Ag.toString,En=Js?Js.toStringTag:void 0,eM=Object.prototype.toString,Lh=Js?Js.toStringTag:void 0;function tM(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Lh&&Lh in Object(e)?function(t){var i=KS.call(t,En),n=t[En];try{t[En]=void 0;var r=!0}catch{}var s=qS.call(t);return r&&(i?t[En]=n:delete t[En]),s}(e):function(t){return eM.call(t)}(e)}var iM=/\s/,nM=/^\s+/;function rM(e){return e&&e.slice(0,function(t){for(var i=t.length;i--&&iM.test(t.charAt(i)););return i}(e)+1).replace(nM,"")}function ll(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var sM=/^[-+]0x[0-9a-f]+$/i,oM=/^0b[01]+$/i,aM=/^0o[0-7]+$/i,lM=parseInt;function Rh(e){if(typeof e=="number")return e;if(function(n){return typeof n=="symbol"||function(r){return r!=null&&typeof r=="object"}(n)&&tM(n)=="[object Symbol]"}(e))return NaN;if(ll(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ll(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=rM(e);var i=oM.test(e);return i||aM.test(e)?lM(e.slice(2),i?2:8):sM.test(e)?NaN:+e}var Jo=function(){return Tg.Date.now()},uM=Math.max,cM=Math.min;function is(e,t,i){var n,r,s,o,a,l,u=0,c=!1,h=!1,m=!0;if(typeof e!="function")throw new TypeError("Expected a function");function v(p){var y=n,S=r;return n=r=void 0,u=p,o=e.apply(S,y)}function w(p){return u=p,a=setTimeout(d,t),c?v(p):o}function x(p){var y=p-l;return l===void 0||y>=t||y<0||h&&p-u>=s}function d(){var p=Jo();if(x(p))return f(p);a=setTimeout(d,function(y){var S=t-(y-l);return h?cM(S,s-(y-u)):S}(p))}function f(p){return a=void 0,m&&n?v(p):(n=r=void 0,o)}function g(){var p=Jo(),y=x(p);if(n=arguments,r=this,l=p,y){if(a===void 0)return w(l);if(h)return clearTimeout(a),a=setTimeout(d,t),v(l)}return a===void 0&&(a=setTimeout(d,t)),o}return t=Rh(t)||0,ll(i)&&(c=!!i.leading,s=(h="maxWait"in i)?uM(Rh(i.maxWait)||0,t):s,m="trailing"in i?!!i.trailing:m),g.cancel=function(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0},g.flush=function(){return a===void 0?o:f(Jo())},g}class jh extends Ei.exports.Component{constructor(t){super(t),this.seeking=!1,this.mobileSeeking=!1,this.track=null,this.hoverTime=null,this.offset=0,this.secondsPrefix="00:00:",this.minutesPrefix="00:",this.seekPause=!1,this.handleTouchSeeking=i=>{let n=0;for(let r=0;r<i.changedTouches.length;r++)n=i.changedTouches[r].pageX;n=n<0?0:n,this.mobileSeeking&&this.changeCurrentTimePosition(n)},this.handleSeeking=i=>{this.seeking&&this.changeCurrentTimePosition(i.pageX)},this.setTrackWidthState=()=>{this.track&&this.setState({trackWidth:this.track.offsetWidth})},this.handleTrackHover=(i,n)=>{if(this.track){const r=this.props.scale||1;let s;s=i?0:(n.pageX-this.track.getBoundingClientRect().left)/r,this.setState({seekHoverPosition:s,trackWidth:this.track.offsetWidth})}},this.mouseSeekingHandler=i=>{this.setSeeking(!1,i),this.onMouseUp()},this.setSeeking=(i,n)=>{n.preventDefault(),this.handleSeeking(n),this.seeking=i,this.setState({seekHoverPosition:i?this.state.seekHoverPosition:0})},this.mobileTouchSeekingHandler=()=>{this.setMobileSeeking(!1)},this.setMobileSeeking=i=>{this.mobileSeeking=i,this.setState({seekHoverPosition:i?this.state.seekHoverPosition:0})},this.renderBufferProgress=()=>{if(this.props.buffered){const i=Ue(Ue({},this.getPositionStyle(this.props.buffered)),this.props.bufferColor&&{backgroundColor:this.props.bufferColor});return F.createElement("div",{className:"buffered",style:i})}return null},this.renderProgress=()=>{const i=Ue(Ue({},this.getPositionStyle(this.props.current)),this.props.sliderColor&&{backgroundColor:this.props.sliderColor});return F.createElement("div",{className:"connect",style:i})},this.renderHoverProgress=()=>{const i=Ue(Ue({},this.getSeekHoverPosition()),this.props.sliderHoverColor&&{backgroundColor:this.props.sliderHoverColor});return F.createElement("div",{className:"seek-hover",style:i})},this.renderThumb=()=>F.createElement("div",{className:this.isThumbActive()?"thumb active":"thumb",style:this.getThumbHandlerPosition()},F.createElement("div",{style:{backgroundColor:this.props.thumbColor},className:"handler"})),this.onMouseDown=i=>{var n,r;this.props.pause&&!this.props.paused&&(this.props.pause(),this.seekPause=!0),this.setSeeking(!0,i),(r=(n=this.props).onSeekStart)==null||r.call(n)},this.onMouseUp=()=>{var i,n;this.props.play&&this.seekPause&&(this.props.play(),this.seekPause=!1),(n=(i=this.props).onSeekEnd)==null||n.call(i)},this.props.secondsPrefix&&(this.secondsPrefix=this.props.secondsPrefix),this.props.minutesPrefix&&(this.minutesPrefix=this.props.minutesPrefix),this.state={ready:!1,trackWidth:0,seekHoverPosition:0}}componentDidMount(){this.setTrackWidthState(),window.addEventListener("resize",this.setTrackWidthState),window.addEventListener("mousemove",this.handleSeeking),window.addEventListener("mouseup",this.mouseSeekingHandler),window.addEventListener("touchmove",this.handleTouchSeeking),window.addEventListener("touchend",this.mobileTouchSeekingHandler)}componentWillUnmount(){window.removeEventListener("resize",this.setTrackWidthState),window.removeEventListener("mousemove",this.handleSeeking),window.removeEventListener("mouseup",this.mouseSeekingHandler),window.removeEventListener("touchmove",this.handleTouchSeeking),window.removeEventListener("touchend",this.mobileTouchSeekingHandler)}changeCurrentTimePosition(t){if(this.track){const i=this.props.scale||1;let n=(t-this.track.getBoundingClientRect().left)/i;n=Math.min(this.state.trackWidth,Math.max(0,n)),this.setState({seekHoverPosition:n});const r=+(n/this.state.trackWidth*this.props.total).toFixed(0);this.props.onChange(r)}}getPositionStyle(t){return{transform:`scaleX(${100*t/this.props.total/100})`}}getThumbHandlerPosition(){return{transform:`translateX(${this.state.trackWidth/(this.props.total/this.props.current)}px)`}}getSeekHoverPosition(){return{transform:`scaleX(${100*this.state.seekHoverPosition/this.state.trackWidth/100})`}}getHoverTimePosition(){let t=0;return this.hoverTime&&(t=this.state.seekHoverPosition-this.hoverTime.offsetWidth/2,this.props.limitTimeTooltipBySides&&(t<0?t=0:t+this.hoverTime.offsetWidth>this.state.trackWidth&&(t=this.state.trackWidth-this.hoverTime.offsetWidth))),{transform:`translateX(${t}px)`}}secondsToTime(t){t=Math.round(t+this.offset);const i=Math.floor(t/3600),n=t%3600,r=Math.floor(n/60),s=Math.ceil(n%60);return{hh:i.toString(),mm:r<10?"0"+r:r.toString(),ss:s<10?"0"+s:s.toString()}}getHoverTime(){const t=100*this.state.seekHoverPosition/this.state.trackWidth,i=Math.floor(+t*(this.props.total/100)),n=this.secondsToTime(i);return this.props.total+this.offset<60?this.secondsPrefix+n.ss:this.props.total+this.offset<3600?this.minutesPrefix+n.mm+":"+n.ss:n.hh+":"+n.mm+":"+n.ss}isThumbActive(){return this.state.seekHoverPosition>0||this.seeking}drawHoverTime(){return this.props.hideHoverTime?null:F.createElement("div",{className:this.isThumbActive()?"hover-time active":"hover-time",style:this.getHoverTimePosition(),ref:t=>this.hoverTime=t},this.getHoverTime())}render(){return F.createElement("div",{className:"seek-slider"},F.createElement("div",{className:"track",ref:t=>this.track=t,onMouseMove:t=>this.handleTrackHover(!1,t),onMouseLeave:t=>this.handleTrackHover(!0,t),onMouseDown:this.onMouseDown,onTouchStart:t=>{this.setMobileSeeking(!0),this.onMouseDown(t)},onMouseUp:this.onMouseUp,onTouchEnd:this.onMouseUp},F.createElement("div",{className:"main"},this.renderBufferProgress(),this.renderHoverProgress(),this.renderProgress())),this.drawHoverTime(),this.renderThumb())}}class hM extends Ei.exports.Component{constructor(t){super(t),this.stageVolume=0,this.updateVolumeTimer=0,this.onVolumeSeeking=!1,this.onClickOperationButton=()=>{const{paused:i}=this.props;i?this.props.play():this.props.pause()},this.operationButton=()=>{const{paused:i}=this.props;return i?F.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNOCA1LjE0djE0bDExLTdsLTExLTd6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="}):F.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMTloNFY1aC00TTYgMTloNFY1SDZ2MTR6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="})},this.operationVolumeButton=()=>this.props.volume>.9?F.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMy4yM3YyLjA2YzIuODkuODYgNSAzLjU0IDUgNi43MXMtMi4xMSA1Ljg0LTUgNi43djIuMDdjNC0uOTEgNy00LjQ5IDctOC43N2MwLTQuMjgtMy03Ljg2LTctOC43N00xNi41IDEyYzAtMS43Ny0xLTMuMjktMi41LTQuMDNWMTZjMS41LS43MSAyLjUtMi4yNCAyLjUtNE0zIDl2Nmg0bDUgNVY0TDcgOUgzeiIgZmlsbD0iI2ZmZiI+PC9wYXRoPjwvc3ZnPgo="}):this.props.volume===0?F.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNyA5djZoNGw1IDVWNGwtNSA1SDd6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="}):F.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNSA5djZoNGw1IDVWNEw5IDltOS41IDNjMC0xLjc3LTEtMy4yOS0yLjUtNC4wM1YxNmMxLjUtLjcxIDIuNS0yLjI0IDIuNS00eiIgZmlsbD0iI2ZmZiI+PC9wYXRoPjwvc3ZnPgo="}),this.handleClickVolume=()=>{this.props.volume===0?this.stageVolume!==0?this.props.setVolume(this.stageVolume):this.props.setVolume(1):(this.stageVolume=this.props.volume,this.props.setVolume(0))},this.onChange=i=>{this.setState({currentTime:i}),i&&this.changeTime(i)},this.changeTime=is(i=>{this.props.setCurrentTime(i)},50),this.onVolumeChange=i=>{this.changeVolume(i),this.setState({seekVolume:i/100})},this.changeVolume=is(i=>{this.props.setVolume(i/100)},50),this.onVolumeSeekStart=()=>{this.onVolumeSeeking=!0},this.onVolumeSeekEnd=is(()=>{this.onVolumeSeeking=!1},500),this.onProgressSeekStart=()=>this.setState({isPlayerSeeking:!0}),this.onProgressSeekEnd=is(()=>{this.setState({isPlayerSeeking:!1})},500),this.state={isPlayerSeeking:!1,isVolumeHover:!1,seekVolume:1,visible:!0,currentTime:0},this.stageVolume=t.volume}componentDidMount(){this.updateVolumeTimer=setInterval(()=>{this.onVolumeSeeking||this.setState({seekVolume:this.props.volume}),this.state.isPlayerSeeking||this.setState({currentTime:this.props.currentTime})},100)}componentWillUnmount(){this.updateVolumeTimer&&clearInterval(this.updateVolumeTimer)}render(){const{duration:t,currentTime:i}=this.props;return F.createElement("div",{className:"player-controller",style:{opacity:this.props.visible?"1":"0"}},F.createElement("div",{className:"player-controller-progress"},F.createElement(jh,{total:t,current:this.state.currentTime,onChange:this.onChange,buffered:this.props.buffered,bufferColor:"rgba(255,255,255,0.3)",hideHoverTime:!0,limitTimeTooltipBySides:!0,onSeekStart:this.onProgressSeekStart,onSeekEnd:this.onProgressSeekEnd,play:this.props.play,pause:this.props.pause,paused:this.props.paused,scale:this.props.scale})),F.createElement("div",{className:"player-controller-actions"},F.createElement("div",{className:"player-controller-actions-left"},F.createElement("div",{onClick:this.onClickOperationButton,className:"player-controller-play"},this.operationButton()),F.createElement("div",{className:"player-volume-box",onMouseEnter:()=>this.setState({isVolumeHover:!0}),onMouseLeave:()=>this.setState({isVolumeHover:!1})},F.createElement("div",{onClick:this.handleClickVolume,className:"player-volume"},this.operationVolumeButton()),F.createElement("div",{className:"player-volume-slider"},F.createElement(jh,{total:100,current:100*this.state.seekVolume,onChange:this.onVolumeChange,onSeekStart:this.onVolumeSeekStart,onSeekEnd:this.onVolumeSeekEnd,scale:this.props.scale,limitTimeTooltipBySides:!0,hideHoverTime:!0})))),F.createElement("div",{className:"player-mid-box-time"},_h(Math.floor(i/1e3))," /"," ",_h(Math.floor(t/1e3)))))}}function _h(e){const t=e%60,i=(e-t)/60;if(i>=60){const n=i%60;return`${Nn((i-n)/60)}:${Nn(n)}:${Nn(t)}`}return`${Nn(i)}:${Nn(t)}`}function Nn(e){return e<=9?`0${e}`:`${e}`}let dM=99999;var ul,Di;(Di=ul||(ul={}))[Di.Idle=0]="Idle",Di[Di.Playing=1]="Playing",Di[Di.Paused=2]="Paused";let be={};function pe(e,...t){xt.verbose&&console.log(`[RTCEffect] ${e}`,...t)}function fM(e,t,i){function n(s){be[s].playState===0?(e.playEffect(s,i,0,1,0,100,!1,0).then(()=>{pe(">>> Play Success",{playingId:s})}),be[s].playState=1):pe(">>> Skip Play",{playingId:s,state:be[s].playState})}function r(s){be[s].playState=0,be[s].previousVideoJSAdvance=0,be[s].previousSeekTargetTime=0,be[s].previousBeginSeekTime=0}t.one("ready",()=>{var s;const o=((s=t==null?void 0:t.tagAttributes)==null?void 0:s.src)||"";Ig.includes("."+o.split(".").pop()||"")||(pe(">>> Mute js player",{src:o}),t.muted(!0),t.muted=l=>!1);const a=function(){const l=dM--,u={playState:ul.Idle,previousVideoJSAdvance:0,previousSeekTargetTime:0,previousBeginSeekTime:0};return be[l]=u,l}();pe(">>> Setup",{playingId:a,src:o}),e.addListener("error",l=>{pe(">>> Error",{soundId:l}),r(l)}),e.addListener("effectFinished",l=>{pe(">>> Finished",{soundId:l}),r(l)}),t.on("play",()=>{switch(be[a].playState){case 0:pe(">>> Start play",{playingId:a}),n(a);break;case 2:pe(">>> Resume play",{playingId:a}),e.resumeEffect(a),be[a].playState=1}}),t.on("pause",()=>{const l=be[a].playState;switch(l){case 1:pe(">>> Pause play",{playingId:a}),e.pauseEffect(a),be[a].playState=2;break;default:pe(">>> Skip Pause",{playingId:a,currenState:l})}}),t.on("timeupdate",()=>{e.getEffectCurrentPosition(a).then(l=>{const u=be[a],c=l/1e3,h=t.currentTime(),m=u.previousSeekTargetTime!==0&&u.previousBeginSeekTime!==0;if(pe(`>>> EffectSecond rtc: ${c} js: ${h} seeking: ${m}`,{playingId:a}),u.playState==0)return void(t.paused()||(pe(">>> Play effect due to time update.",{playingId:a}),n(a)));if(m&&c<u.previousSeekTargetTime)return;if(u.playState!==1)return void pe(">>> Skip timupdate",{playingId:a,state:u.playState,jsTime:t.currentTime(),rtcEffectTime:c});function v(x,d){e.setEffectPosition(d,1e3*x),u.previousBeginSeekTime=Date.now()/1e3,u.previousSeekTargetTime=x}const w=u.previousBeginSeekTime;if(l>0){const x=h-c,d=Math.abs(x),f=.5;if(d>f)if(m){const g=u.previousSeekTargetTime-c,p=Date.now()/1e3-w,y=p+(x>0?x:0),S=h+y;v(S,a),pe(">>> Start seeking after seeking lag",{jsPlayerTime:h,rtcEffectTime:c,jsPlayerTimerAdvance:x,lastSeekingCost:p,estimatedRTCLag:y,targetRTCSeekTime:S,previousBeginSeekTime:w,timeElapse:g})}else if(d>10)v(h,a),pe(">>> DirectSeek",{time:h,rtcEffectTime:c,jsPlayerTimerAdvance:x});else{const g=u.previousVideoJSAdvance,p=0,y=h+p;u.previousVideoJSAdvance=p,v(y,a),pe(">>> Start seeking with lag",{jsPlayerTime:h,rtcEffectTime:c,jsPlayerTimerAdvance:x,previousAdvance:g,estimatedRTCLag:p,targetRTCSeekTime:y})}else m&&(pe(">>> SeekingFinish no lag",{jsPlayerTime:h,rtcEffectTime:c,jsPlayerTimerAdvance:x,previousBeginSeekTime:w,rtcLagTolerance:f}),u.previousBeginSeekTime=0,u.previousSeekTargetTime=0)}})}),t.on("dispose",()=>{be[a].playState&&(e.stopEffect(a),delete be[a],pe(">>> Dispose",{playingId:a}))})})}class Vh extends Ei.exports.Component{constructor(){super(...arguments),this.putAttributes=t=>{const{context:i}=this.props,n=i.getAttributes()||{};for(const r in t)n[r]!==t[r]&&i.updateAttributes([r],t[r])}}render(){const{context:t}=this.props,i=t.getRoom(),n=i?void 0:t.getDisplayer(),r=this.putAttributes;return F.createElement(pM,{room:i,player:n,context:t,plugin:{putAttributes:r}})}}class pM extends Ei.exports.Component{constructor(t){super(t),this.alertMask=null,this.container=F.createRef(),this.controllerHiddenTimer=0,this.syncPlayerTimer=0,this.retryCount=0,this.decreaseRetryTimer=0,this.noSoundSyncCount=0,this.everPlayed=!1,this.showController=()=>{this.setState({controllerVisible:!0}),this.debounceHidingController()},this.play=()=>{var i;const n=(i=this.props.room)==null?void 0:i.calibrationTimestamp;this.debug(">>> play",{paused:!1,hostTime:n}),this.isEnabled()&&this.props.plugin.putAttributes({paused:!1,hostTime:n})},this.pause=()=>{const i=ts(this.getAttributes(),this.props);this.debug(">>> pause",{paused:!0,currentTime:i}),this.isEnabled()&&this.props.plugin.putAttributes({paused:!0,currentTime:i})},this.setVolume=i=>{this.debug(">>> volume",{volume:i}),this.isEnabled()&&this.props.plugin.putAttributes({volume:i}),this.isEnabled()&&this.props.plugin.putAttributes({volume:i,muted:i===0})},this.setCurrentTime=i=>{var n;const r=(n=this.props.room)==null?void 0:n.calibrationTimestamp;this.debug(">>> seek",{currentTime:i/1e3,hostTime:r}),this.isEnabled()&&this.props.plugin.putAttributes({currentTime:i/1e3,hostTime:r})},this.resetPlayer=()=>{var i;(i=this.player)==null||i.autoplay(!1),this.state.NoSound||(this.debug(">>> ended",{paused:!0,currentTime:0}),this.isEnabled()&&this.props.plugin.putAttributes({paused:!0,currentTime:0}))},this.syncPlayerWithAttributes=()=>{var i;const n=this.getAttributes();if(!n)return;const r=this.player;if(!r||this.state.NoSound&&(this.noSoundSyncCount+=1)%8!=0)return;r.paused()!==n.paused&&(this.debug("<<< paused -> %o",n.paused),n.paused?r.pause():((i=r.play())==null||i.catch(this.catchPlayFail),this.everPlayed=!0)),r.muted()!==n.muted&&(this.debug("<<< muted -> %o",n.muted),r.muted(n.muted)),r.volume()!==n.volume&&(this.debug("<<< volume -> %o",n.volume),r.volume(n.volume));const s=ts(n,this.props);let o=xt.currentTimeMaxError;if(this.state.NoSound&&(o*=3),s>r.duration())this.resetPlayer();else if(Math.abs(r.currentTime()-s)>o){if(this.debug("<<< currentTime -> %o",s),GS)return void(this.everPlayed?r.currentTime(s):this.debug("<<< ignore iOS idle time update. -> %o (ignored)",s));r.currentTime(s)}},this.debounceHidingController=()=>{this.controllerHiddenTimer&&(clearTimeout(this.controllerHiddenTimer),this.controllerHiddenTimer=0),this.controllerHiddenTimer=setTimeout(()=>{this.setState({controllerVisible:!1}),this.controllerHiddenTimer=0},3e3)},this.decreaseRetryCount=()=>{this.player&&this.retryCount>0&&(this.retryCount=this.retryCount-1)},this.catchPlayFail=i=>{var n,r;const s=String(i);if(YS&&s.includes("NotAllowedError")||s.includes("interact"))(n=this.player)==null||n.autoplay("any"),this.setState({NoSound:!0});else{const o=(r=this.player)==null?void 0:r.error();o&&(this.retryCount<=3?(this.initPlayer(),this.retryCount=this.retryCount+1):(this.debug("catch videojs media error",o),this.setState({MediaError:!0}))),this.debug("catch error",i)}},this.fixPlayFail=()=>{this.debug("try to fix play state"),this.setState({NoSound:!1});const{muted:i,volume:n}=this.getAttributes();this.player&&(this.player.muted(i),this.player.volume(n))},this.initPlayer=async()=>{var i;(i=this.player)==null||i.dispose(),this.player=void 0,this.debug("creating elements ...");const{type:n,src:r,poster:s}=this.getAttributes(),o=document.createElement("div");o.setAttribute("data-vjs-player","");const a=document.createElement("video");a.className="video-js",a.crossOrigin="anonymous",s&&(a.poster=s),a.setAttribute("playsInline",""),a.setAttribute("webkit-playsinline","");const l=document.createElement("source");new URL(r).pathname.endsWith(".m3u8")?l.type="application/x-mpegURL":a.src=r,l.src=r,n&&(l.type=n),a.appendChild(l),o.appendChild(a),this.container.current.appendChild(o),await new Promise(m=>(window.requestAnimationFrame||window.setTimeout)(m)),this.debug("initializing videojs() ...");const u=_u.default(a);this.player=u,window.player=u,u.one("loadedmetadata",this.gracefullyUpdate);const c=window.__mediaPlayerAudioEffectClient;c!==void 0&&fM(c,u,r);const h=window.__pcmProxy;h!==void 0&&(u.one("play",()=>{const m=h.connect(a);this.audioSource=m,this.debug("Connect to PCMProxy ",r)}),u.one("dispose",()=>{this.audioSource&&(this.audioSource.disconnect(),this.audioSource=void 0,this.debug("Disconnect from PCMProxy",r))})),u.on("ready",()=>{var m;(m=xt.onPlayer)==null||m.call(xt,u),u.on("timeupdate",this.gracefullyUpdate),u.on("volumechange",this.gracefullyUpdate),u.on("seeked",this.gracefullyUpdate),u.on("play",this.gracefullyUpdate),u.on("pause",this.gracefullyUpdate),u.on("ended",this.resetPlayer)}),u.on("error",this.catchPlayFail),this.setState({MediaError:!1})},this.gracefullyUpdate=()=>this.setState({updater:!this.state.updater}),this.setupAlert=i=>{i&&(i.addEventListener("touchstart",this.fixPlayFail),i.addEventListener("click",this.fixPlayFail)),this.alertMask=i},this.setupReload=i=>{i&&(i.addEventListener("touchstart",this.initPlayer),i.addEventListener("click",this.initPlayer))},this.state={NoSound:!1,MediaError:!1,updater:!1,controllerVisible:!1},t.room&&function(i){if(!i.calibrationTimestamp)throw new Error("@netless/app-media-player@0.1.0-alpha.5 requires white-web-sdk@^2.13.8 to work properly.")}(t.room)}getAttributes(){const{context:t}=this.props;let i=t.getAttributes();if(i){if(i=Ue(Ue({},Mg),i),this.player){let r=ts(i,this.props),s=this.player.duration();!i.paused&&r>s&&(n=Ue({},i),i=WS(n,HS({currentTime:0,paused:!0})),this.resetPlayer())}var n;return i}}isShowingPoster(){const t=this.getAttributes();return!(t!=null&&t.src)||Ig.some(i=>t.src.endsWith(i))}render(){var t,i;if(!this.props.room&&!this.props.player)return null;const n=this.getAttributes();if(!n)return null;const r=1e3*(((t=this.player)==null?void 0:t.duration())||1e3),s=((i=this.player)==null?void 0:i.bufferedPercent())||0;return F.createElement("div",{className:this.isEnabled()?"vjs-p":"vjs-p disabled",onMouseEnter:this.showController,onMouseMove:this.showController},F.createElement("div",{className:"video-js-plugin-player",ref:this.container}),this.isShowingPoster()&&F.createElement("div",{className:"video-js-plugin-poster"},n.poster&&F.createElement("img",{src:n.poster,alt:"",draggable:!1})),F.createElement(hM,{duration:r,volume:n.volume,setVolume:this.setVolume,paused:n.paused,play:this.play,pause:this.pause,currentTime:1e3*ts(n,this.props),setCurrentTime:this.setCurrentTime,buffered:r*s,visible:!0}),this.state.NoSound&&F.createElement("div",{ref:this.setupAlert,className:"videojs-plugin-muted-alert"}),this.state.MediaError&&F.createElement("div",{className:"videojs-plugin-recovery-mode"},F.createElement("button",{ref:this.setupReload},"Reload Player")))}debug(t,...i){xt.verbose&&xt.log(`[MediaPlayer] ${t}`,...i)}componentDidMount(){this.debug("app version =","0.1.0-alpha.5"),this.debug("video.js version =",_u.default.VERSION),this.initPlayer(),this.props.context.emitter.on("attributesUpdate",this.syncPlayerWithAttributes),this.syncPlayerTimer=setInterval(this.syncPlayerWithAttributes,xt.syncInterval),this.decreaseRetryTimer=setInterval(this.decreaseRetryCount,xt.retryInterval)}componentWillUnmount(){var t;this.debug("unmount"),this.props.context.emitter.off("attributesUpdate",this.syncPlayerWithAttributes),(t=this.player)==null||t.dispose(),clearInterval(this.syncPlayerTimer),clearInterval(this.decreaseRetryTimer)}isEnabled(){return this.props.context.getIsWritable()}}const gM={kind:"MediaPlayer",setup(e){let t=e.getAttributes();if(!t||!t.src)return e.emitter.emit("destroy",{error:new Error("[MediaPlayer]: Missing 'attributes'.'src'.")});t=Ue(Ue({},Mg),t);const i=e.getBox();i.mountStyles(`.vjs-p{display:flex;flex-grow:1}.vjs-p *{pointer-events:auto}.vjs-p.disabled *{pointer-events:none}.vjs-p .video-js-plugin-poster{position:absolute;top:0;left:0;right:0;bottom:0;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgQAAACACAYAAAB0vHFxAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAACBKADAAQAAAABAAAAgAAAAACE3oPTAAAKXUlEQVR4Ae3dYW4ktxEG0LW9FwkC2McycokAOUGAXMLwtQwYvomdP4akHUnNnm6SVUU+/xqpe8ji+yiDWz3a/e7L5v/98se//3pL8K9//O+7t19Hv85eX7RP9vnllz2h4/rkd+wz+ir/0cLfjv/9t1/6igABAgQIENhRwIFgx9StmQABAgQIPAg4EDyA+JIAAQIECOwo8HXHRVvzPIHRzwBHjz9PKudMo31Hj59TdZ2qsueXvb5sO0GHIFsi6iFAgAABAgECOgQB6KbsJ5Dtt0L6rWyPkeRXO+fs+WWvL1v6OgTZElEPAQIECBAIENAhCEA3ZT8Bzwj7WUaMJL8I9X5zZs8ve339kugzkg5BH0ejECBAgACB0gIO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+jc8eQ317v3bPLrLWq8twK995cOwVtdrwkQIECAwKYC5TsE1f4mqNn7jM9s8b7zya+v5+zR5DdbfK/5eu8vHYK99o/VEiBAgACBDwWaHYLezyg+rOLGN6Pra53QWtdvLP3UW6N9WkVmr09+xwnKr7ZP9vyOdcdfze7Tuz4dgvF7ygwECBAgQCC9QLNDEL2C3ieg3utp1de63rueZ8fLXt+z6+l9f3af7PX1zuPZ8bL7ZK/vWW/39xWYvT90CPrmZzQCBAgQIFBSwIGgZGyKJkCAAAECfQUcCPp6Go0AAQIECJQUaH6GIPpT1iVVFX1aIHp/zX5GdxqmyI3yKxLUJ2XK7xOYv78d7XNcXf+rOgT9TY1IgAABAgTKCTQ7BLv/CWr0+kePn31HVl9/9frv7o/q669e/+753V1/6/277Q8dgtaOcJ0AAQIECGwg0OwQbGBwuMTRz5BGj3+4OBdvC8jvNmHoAPIL5Td5MgEdgmSBKIcAAQIECEQI3O4QrP6MZfT6Ro8fsal2mlN+tdOWX+38VN9XQIegr6fRCBAgQIBASQEHgpKxKZoAAQIECPQVcCDo62k0AgQIECBQUuD2Zwiyr3r1Z4Srry/7/rpbn/zuCsa+X36x/mY/Fnh2f+oQHHu6SoAAAQIEthBYvkOwRYoW+anAsyfkTwdyIURAfiHs3SYdnd/o8btBFBlIh6BIUMokQIAAAQIjBRwIRuoamwABAgQIFBFwICgSlDIJECBAgMBIAQeCkbrGJkCAAAECRQQcCIoEpUwCBAgQIDBSwG8ZjNQ19nABnzIeTjx0AvkN5R0+ePb8stc3PKAnJ9AheBLM7QQIECBAYEUBHYIVU91oTf49+9phy09+IwXsr+d0dQie83I3AQIECBBYUkCHYMlY8yxq9DO80ePnkYypZLTv6PFj1PaZNXt+2evLtlN0CLIloh4CBAgQIBAg4EAQgG5KAgQIECCQTcCBIFsi6iFAgAABAgEC/wdVfx9UuC8B6AAAAABJRU5ErkJggg==);background-repeat:repeat-x;background-position:0 50%;display:flex;align-items:center;justify-content:center}.vjs-p .video-js-plugin-poster img{box-shadow:0 0 5px 10px #0006}.vjs-p .player-controller,.vjs-p .videojs-plugin-muted-alert{pointer-events:auto}.vjs-p.disabled .videojs-plugin-close-icon,.vjs-p.disabled .player-controller{pointer-events:none}.vjs-p .video-js-plugin-player{position:absolute;top:0;left:0;right:0;bottom:0}.video-js,[data-vjs-player]{width:100%;height:100%}.vjs-p .videojs-plugin-muted-alert{pointer-events:auto;cursor:pointer;position:absolute;top:0;left:0;right:0;bottom:0;z-index:43}.vjs-p .videojs-plugin-muted-alert:before{pointer-events:auto;cursor:pointer;position:absolute;top:0;left:0;right:0;bottom:0;z-index:43;content:"\\f104";background:rgba(0,0,0,.3);font-family:VideoJS;font-size:2em;display:flex;align-items:center;justify-content:center;color:#fff}.vjs-p .videojs-plugin-recovery-mode{pointer-events:auto;cursor:pointer;position:absolute;top:0;left:0;right:0;bottom:0;z-index:44}.vjs-p .videojs-plugin-recovery-mode button{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.vjs-p .seek-slider{position:relative;width:100%}.vjs-p .seek-slider:focus{outline:none}.vjs-p .seek-slider .track{padding:10px 0;cursor:pointer;outline:none}.vjs-p .seek-slider .track:focus{border:0;outline:none}.vjs-p .seek-slider .track .main{width:100%;height:3px;background-color:#ffffff4d;border-radius:30px;position:absolute;left:0;top:8.5px;transition:transform .4s;outline:none}.vjs-p .seek-slider .track .main:focus{border:0;outline:none}.vjs-p .seek-slider .track .main .buffered{position:absolute;background-color:#ffffff4d;width:100%;height:100%;transform:scaleX(.8);z-index:2;transform-origin:0 0}.vjs-p .seek-slider .track .main .seek-hover{position:absolute;background-color:#ffffff80;width:100%;height:100%;z-index:1;transform:scaleX(.6);transform-origin:0 0;opacity:0;transition:opacity .4s}.vjs-p .seek-slider .track .main .connect{position:absolute;background-color:#fff;width:100%;height:100%;z-index:3;left:0;transform:scaleX(.13);transform-origin:0 0}.vjs-p .seek-slider .track.active .main{transform:scaleY(2)}.vjs-p .seek-slider .thumb{pointer-events:none;position:absolute;width:12px;height:12px;left:-6px;top:4px;z-index:4;transform:translate(100px)}.vjs-p .seek-slider .thumb .handler{border-radius:100%;width:100%;height:100%;background-color:#fff;opacity:0;transform:scale(.4);cursor:pointer;transition:transform .2s;pointer-events:none}.vjs-p .seek-slider .thumb.active .handler{opacity:1;transform:scale(1)}.vjs-p .seek-slider .hover-time{position:absolute;background-color:#0000004d;line-height:18px;font-size:16px;color:#ddd;top:-25px;left:0;padding:5px 10px;border-radius:5px;box-shadow:0 0 5px #0000004d;opacity:0;transform:translate(150px);pointer-events:none}.vjs-p .seek-slider .hover-time.active{opacity:1}.vjs-p .seek-slider:hover .track .main .seek-hover{opacity:1}.vjs-p .player-controller{position:absolute;z-index:100;bottom:0px;left:0;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:stretch;height:64px;background-image:linear-gradient(0deg,#000,transparent);transition:opacity .2s;color:#fff}.vjs-p .player-menu-box{display:flex;align-items:center;justify-content:center;flex-direction:column;margin-bottom:40px}.vjs-p .player-menu-cell{width:100%;text-align:center;font-size:12px;color:#7a7b7c}.vjs-p .player-multiple-play{width:64px;height:120px}.vjs-p .player-controller-actions-left{display:flex;justify-content:center;align-items:center;flex-shrink:0}.vjs-p .player-right-box{font-size:14px;color:#7a7b7c;cursor:pointer;margin-right:12px}.vjs-p .player-controller-actions{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-left:8px;padding-right:8px;margin-top:2px}.vjs-p .player-mid-box-time{font-size:9px;display:flex;justify-content:center;align-items:center;color:#fff;flex-shrink:0;margin-right:8px;font-family:monospace}.vjs-p .player-controller-play{display:flex;align-items:center;justify-content:center;cursor:pointer;padding-right:4px}.vjs-p .player-controller-progress{width:calc(100% - 28px);margin-left:14px;display:flex;align-items:center;justify-content:center;margin-top:8px}.vjs-p .player-volume{display:flex;align-items:center;justify-content:center;cursor:pointer;margin-right:16px;margin-left:8px}.vjs-p .player-volume-slider{width:60px;margin-right:12px;display:flex;align-items:center}.vjs-p .player-volume-box{display:flex;flex-direction:row}.netless-app-media-player-container{display:flex;position:relative;height:100%}
47
- `);const n=document.createElement("div");if(n.classList.add("netless-app-media-player-container"),es.render(F.createElement(Vh,{context:e}),n),i.mountContent(n),e.emitter.on("destroy",()=>{console.log("[MediaPlayer]: destroy"),es.unmountComponentAtNode(n)}),window.__pcmProxy){const r=()=>{document.visibilityState==="hidden"?(console.log("[MediaPlayer]: visibilitychange -> hidden. unmount for pcmproxy"),es.unmountComponentAtNode(n)):(console.log("[MediaPlayer]: visibilitychange -> visible. mount for pcmproxy"),es.render(F.createElement(Vh,{context:e}),n))};document.addEventListener("visibilitychange",r),e.emitter.on("destroy",()=>{document.removeEventListener("visibilitychange",r)})}}};var mM=Object.freeze(Object.defineProperty({__proto__:null,Version:ZS,default:gM,setOptions:bg},Symbol.toStringTag,{value:"Module"}));class vM extends Ti.default{_inject(t){this.context=t}}class Eg{constructor(t){this.extends=new Map,this.context={manager:this,windowManager:t.windowManager,internalEmitter:t.internalEmitter},t.container&&this.refreshContainer(t.container)}refreshContainer(t){this.context.windowManagerContainer=t,this.extends.forEach(i=>{i._inject(this.context)})}hasRegister(t){return Te.appClasses.has(t)}use(t){this.extends.set(t.kind,t),t._inject(this.context),t.onCreate()}destroy(){this.extends.forEach(t=>{this.extends.delete(t.kind),t.onDestroy()})}}function wM(e,t){if(e.kind&&t&&Object.keys(t).includes(e.kind))switch(e.kind){case"AppManager":return(t==null?void 0:t.AppManager)||Sr;case"BoxManager":return(t==null?void 0:t.BoxManager)||mr;case"AttributesDelegate":return(t==null?void 0:t.AttributesDelegate)||yr;case"CursorManager":return(t==null?void 0:t.CursorManager)||wr;case"AppProxy":return(t==null?void 0:t.AppProxy)||xr;case"AppContext":return(t==null?void 0:t.AppContext)||fr;case"TeleBoxManager":return(t==null?void 0:t.TeleBoxManager)||gr;case"TeleBoxCollector":return(t==null?void 0:t.TeleBoxCollector)||cn;default:return e}return e}const Ng=new ww({emitter:_}),O=class extends I.InvisiblePlugin{constructor(e){super(e),this.version="1.0.14",this.dependencies={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"0.3.0",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1",uuid:"^7.0.3","video.js":">=7"},peerDependencies:{jspdf:"2.5.1","white-web-sdk":"^2.16.54"},devDependencies:{"@hyrious/dts":"^0.2.2","@netless/app-docs-viewer":"^0.2.19","@netless/app-media-player":"0.1.4","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"1.0.0-next.30","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",jspdf:"^2.5.1",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1","side-effect-manager":"0.1.5",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.9.9",vitest:"^0.14.1","white-web-sdk":"^2.16.54"}},this.emitter=G,this.viewMode=I.ViewMode.Broadcaster,this.isReplay=I.isPlayer(this.displayer),this._cursorUIDs=[],this.containerSizeRatio=O.containerSizeRatio,this.onMainViewScenePathChangeHandler=t=>{const i=this.mainView.divElement;if(i){const n=i.querySelector(".background img");if(n){const r=n==null?void 0:n.getBoundingClientRect(),s=window.getComputedStyle(n),o=(r==null?void 0:r.width)>0&&(r==null?void 0:r.height)>0&&s.display!=="none",a=this.mainView.camera;console.log("[window-manager] backgroundImageVisible:"+o+" camera:"+JSON.stringify(a));return}console.log("[window-manager] onMainViewScenePathChange scenePath:"+t+" backgroundImageVisible is not found");return}console.log("[window-manager] onMainViewScenePathChange scenePath:"+t+" mainViewElement is not found")},O.displayer=e.displayer,window.NETLESS_DEPS={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"0.3.0",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1",uuid:"^7.0.3","video.js":">=7"},peerDependencies:{jspdf:"2.5.1","white-web-sdk":"^2.16.54"},devDependencies:{"@hyrious/dts":"^0.2.2","@netless/app-docs-viewer":"^0.2.19","@netless/app-media-player":"0.1.4","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"1.0.0-next.30","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",jspdf:"^2.5.1",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1","side-effect-manager":"0.1.5",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.9.9",vitest:"^0.14.1","white-web-sdk":"^2.16.54"}},this.emitter.on("mainViewScenePathChange",this.onMainViewScenePathChangeHandler)}get Logger(){return this._roomLogger}static onCreate(e){O._resolve(e)}static async mount(e,t){var u;const i=e.room;O.container=e.container,O.supportAppliancePlugin=e.supportAppliancePlugin;const n=e.containerSizeRatio,r=e.debug,s=e.cursor;O.params=e,O.extendClass=t,O.displayer=e.room,Pv();let o;if(I.isRoom(i)){if(i.phase!==I.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");i.phase===I.RoomPhase.Connected&&i.isWritable&&(i.disableSerialization=!1),o=await this.initManager(i),o&&(o._roomLogger=i.logger,o.attributesDeboundceLog=new Nv(o._roomLogger,"attributes",300),O.registered.size>0&&o._roomLogger.info(`[WindowManager] registered apps: ${JSON.stringify(Array.from(O.registered.keys()))}`))}if(O.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");if(this.debug=Boolean(r),this.debug&&bg({verbose:!0}),o!=null&&o._roomLogger?o._roomLogger.info(`[WindowManager] Already insert room version: ${o.version}`):et("Already insert room",o),I.isRoom(this.displayer)){if(!o)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await Oh.default(async c=>{if(o=i.getInvisiblePlugin(O.kind),!o)throw et(`manager is empty. retrying ${c}`),new Error},{retries:10,maxTimeout:5e3});if(!o)throw new Error("[WindowManager]: create manager failed");n&&(O.containerSizeRatio=n),await o.ensureAttributes();const a=At(Sr,O.extendClass),l=At(wr,O.extendClass);o._fullscreen=e.fullscreen,o.appManager=new a(o),o.appManager.polling=e.polling||!1,o._pageState=new vw(o.appManager),o.cursorManager=new l(o.appManager,Boolean(s),e.cursorOptions,e.applianceIcons),o.extendPluginManager=new Eg({internalEmitter:_,windowManager:o}),n&&(o.containerSizeRatio=n),e.container&&o.bindContainer(e.container),yw(i,o),_.emit("onCreated"),O.isCreated=!0,o._roomLogger&&o.attributes.registered&&Object.keys(o.attributes.registered).length>0&&o._roomLogger.info(`[WindowManager] attributes registered apps: ${JSON.stringify(Array.from(Object.keys(o.attributes.registered)))}`);try{await Zg()}catch(c){(u=o._roomLogger)==null||u.warn(`[WindowManager] indexedDB open failed: ${c.message}`),console.warn("[WindowManager]: indexedDB open failed"),console.log(c)}return o.emitter.on("mainViewScenePathChange",o.onMainViewScenePathChangeHandler),o}static initManager(e){return zv(e)}static initContainer(e,t,i){const{chessboard:n,overwriteStyles:r,fullscreen:s}=i;O.container||(O.container=t);const{playground:o,wrapper:a,sizer:l,mainViewElement:u}=kv(t);if(O.playground=o,n&&l.classList.add("netless-window-manager-chess-sizer"),s&&l.classList.add("netless-window-manager-fullscreen"),r){const c=document.createElement("style");c.textContent=r,o.appendChild(c)}return e.containerResizeObserver=bl.create(o,l,a,_),O.wrapper=a,O.sizer=l,u}static get registered(){return Te.registered}bindContainer(e){var t,i,n,r,s,o;if(I.isRoom(this.displayer)&&this.room.phase!==I.RoomPhase.Connected)throw new Jh;if(O.isCreated&&O.container)O.container.firstChild&&e.appendChild(O.container.firstChild);else if(O.params){const a=O.params,l=O.initContainer(this,e,a);this.boxManager&&this.boxManager.destroy();const u=Iv(this,G,_,lt,{collectorContainer:a.collectorContainer,collectorStyles:a.collectorStyles,prefersColorScheme:a.prefersColorScheme,useBoxesStatus:a.useBoxesStatus});this.boxManager=u,this.appManager&&(this.appManager.useBoxesStatus=a.useBoxesStatus||!1,this.appManager.setBoxManager(u)),this.bindMainView(l,a.disableCameraTransform),O.wrapper&&((t=this.cursorManager)==null||t.setupWrapper(O.wrapper))}_.emit("updateManagerRect"),(i=this.appManager)==null||i.refresh(),(n=this.appManager)==null||n.resetMaximized(),(r=this.appManager)==null||r.resetMinimized(),(s=this.appManager)==null||s.displayerWritableListener(!this.room.isWritable),O.container=e,(o=this.extendPluginManager)==null||o.refreshContainer(e)}bindCollectorContainer(e){O.isCreated&&this.boxManager?this.boxManager.setCollectorContainer(e):O.params&&(O.params.collectorContainer=e)}static register(e){return Te.register(e)}static unregister(e){return Te.unregister(e)}async addApp(e){if(this.appManager)return this.appManager.rootDirRemoving?new Promise((t,i)=>{_.once("rootDirRemoved").then(async()=>{try{const n=await this._addApp(e);t(n)}catch(n){i(n.message)}})}):this._addApp(e);throw new Oe}async _addApp(e){var t,i,n;if(this.appManager){if(!e.kind||typeof e.kind!="string")throw new Zh;e.src&&typeof e.src=="string"&&Te.register({kind:e.kind,src:e.src});const r=await((t=Te.appClasses.get(e.kind))==null?void 0:t());if(r&&((i=r.config)==null?void 0:i.singleton)&&this.appManager.appProxies.has(e.kind))throw new Fh;const s=this.setupScenePath(e,this.appManager);return s===void 0?void 0:((n=e==null?void 0:e.options)!=null&&n.scenePath&&(e.options.scenePath=hm(e.options.scenePath)),await this.appManager.addApp(e,Boolean(s)))}else throw new Oe}setupScenePath(e,t){let i=!1;if(e.options){const{scenePath:n,scenes:r}=e.options;if(n){if(!cm(n))throw new Gh;const s=Object.keys(this.apps||{});for(const o of s){const a=t.store.getAppScenePath(o);if(a&&a===n){if(console.warn(`[WindowManager]: ScenePath "${n}" already opened`),this.boxManager){const l=this.boxManager.getTopBox();l&&(this.boxManager.setZIndex(o,l.zIndex+1,!1),this.boxManager.focusBox({appId:o},!1))}return}}}n&&r&&r.length>0&&(this.isDynamicPPT(r)?(i=!0,en(this.displayer)[n]||Rn(this.room,n,r)):en(this.displayer)[n]||Rn(this.room,n,[{name:r[0].name}])),n&&r===void 0&&Rn(this.room,n,[{}])}return i}async setMainViewScenePath(e){this.appManager&&await this.appManager.setMainViewScenePath(e)}async setMainViewSceneIndex(e){this.appManager&&await this.appManager.setMainViewSceneIndex(e)}async nextPage(){if(this.appManager){const e=this.mainViewSceneIndex+1;return e>=this.mainViewScenesLength?(console.warn("[WindowManager]: current page is the last page"),!1):(await this.appManager.setMainViewSceneIndex(e),!0)}else return!1}async prevPage(){if(this.appManager){const e=this.mainViewSceneIndex-1;return e<0?(console.warn("[WindowManager]: current page is the first page"),!1):(await this.appManager.setMainViewSceneIndex(e),!0)}else return!1}async jumpPage(e){return this.appManager?e<0||e>=this.pageState.length?(console.warn(`[WindowManager]: index ${e} out of range`),!1):(await this.appManager.setMainViewSceneIndex(e),!0):!1}async addPage(e){if(this.appManager){const t=e==null?void 0:e.after,i=e==null?void 0:e.scene;if(t){const n=this.mainViewSceneIndex+1;this.room.putScenes(ze,[i||{}],n)}else this.room.putScenes(ze,[i||{}])}}async removePage(e){if(this.appManager){const t=e===void 0?this.pageState.index:e;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):t<0||t>=this.pageState.length?(console.warn(`[WindowManager]: index ${e} out of range`),!1):this.appManager.removeSceneByIndex(t)}else return!1}getMainViewScenePath(){var e;return(e=this.appManager)==null?void 0:e.store.getMainViewScenePath()}getMainViewSceneIndex(){var e;return(e=this.appManager)==null?void 0:e.store.getMainViewSceneIndex()}setReadonly(e){var t;this.readonly=e,(t=this.boxManager)==null||t.setReadonly(e),_.emit("setReadonly",e)}switchMainViewToWriter(){var e;return(e=this.appManager)==null?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){lm(`destroy-${e}`,t)}onAppEvent(e,t){return _.on(`custom-${e}`,t)}setViewMode(e){var t,i,n,r;(e===I.ViewMode.Broadcaster||e===I.ViewMode.Follower)&&(this.canOperate&&e===I.ViewMode.Broadcaster&&((t=this.appManager)==null||t.mainViewProxy.setCameraAndSize()),(i=this.appManager)==null||i.mainViewProxy.start()),e===I.ViewMode.Freedom&&((n=this.appManager)==null||n.mainViewProxy.stop()),this.viewMode=e,(r=this.appManager)==null||r.mainViewProxy.setViewMode(e)}setBoxState(e){if(!!this.canOperate)switch(e){case"normal":this.setMaximized(!1),this.setMinimized(!1);break;case"maximized":this.setMaximized(!0),this.setMinimized(!1);break;case"minimized":this.setMinimized(!0);break}}setMaximized(e){var t;!this.canOperate||(t=this.boxManager)==null||t.setMaximized(e,!1)}setMinimized(e){var t;!this.canOperate||(t=this.boxManager)==null||t.setMinimized(e,!1)}setBoxStatus(e,t){var i;!this.canOperate||(i=this.appManager)==null||i.store.setBoxStatus(e,t)}setLastNotMinimizedBoxStatus(e,t){var i;!this.canOperate||(i=this.appManager)==null||i.store.setLastNotMinimizedBoxStatus(e,t)}setFullscreen(e){var t;this._fullscreen!==e&&(this._fullscreen=e,(t=O.sizer)==null||t.classList.toggle("netless-window-manager-fullscreen",e),G.emit("fullscreenChange",e))}get cursorUIDs(){return this._cursorUIDs}setCursorUIDs(e){var t,i;if(this._cursorUIDs=e||[],this._cursorUIDs.length===0)(t=this._cursorUIDsStyleDOM)==null||t.remove();else{this._cursorUIDsStyleDOM||(this._cursorUIDsStyleDOM=document.createElement("style")),(i=O.playground)==null||i.appendChild(this._cursorUIDsStyleDOM);let n="[data-cursor-uid] { display: none }";for(const r of this._cursorUIDs)n+=`
48
- [data-cursor-uid="${r}"] { display: flex }`;this._cursorUIDsStyleDOM.textContent=n}}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new Oe}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new Oe}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new Oe}get apps(){var e;return(e=this.appManager)==null?void 0:e.store.apps()}get boxState(){var e;if(this.appManager)return(e=this.appManager.boxManager)==null?void 0:e.boxState;throw new Oe}get boxStatus(){if(this.appManager)return this.appManager.store.getBoxesStatus();throw new Oe}get lastNotMinimizedBoxStatus(){if(this.appManager)return this.appManager.store.getLastNotMinimizedBoxesStatus();throw new Oe}get darkMode(){var e,t;return Boolean((t=(e=this.appManager)==null?void 0:e.boxManager)==null?void 0:t.darkMode)}get prefersColorScheme(){var e;if(this.appManager)return(e=this.appManager.boxManager)==null?void 0:e.prefersColorScheme;throw new Oe}get focused(){return this.attributes.focus}get focusedView(){var e,t;return((t=(e=this.appManager)==null?void 0:e.focusApp)==null?void 0:t.view)||this.mainView}get polling(){var e;return((e=this.appManager)==null?void 0:e.polling)||!1}set polling(e){this.appManager&&(this.appManager.polling=e)}get cursorStyle(){var e;return((e=this.cursorManager)==null?void 0:e.style)||"default"}set cursorStyle(e){if(!this.cursorManager)throw new Error("[WindowManager]: cursor is not enabled, please set { cursor: true }.");this.cursorManager.style=e}get mainViewSceneIndex(){var e;return((e=this._pageState)==null?void 0:e.index)||0}get mainViewSceneDir(){var e;if(this.appManager)return(e=this.appManager)==null?void 0:e.getMainViewSceneDir();throw new Oe}get topApp(){var e,t;return(t=(e=this.boxManager)==null?void 0:e.getTopBox())==null?void 0:t.id}get mainViewScenesLength(){var e;return((e=this._pageState)==null?void 0:e.length)||0}get canRedoSteps(){var e;return((e=this.focusedView)==null?void 0:e.canRedoSteps)||0}get canUndoSteps(){var e;return((e=this.focusedView)==null?void 0:e.canUndoSteps)||0}get sceneState(){if(this.appManager)return this.appManager.sceneState;throw new Oe}get pageState(){if(this._pageState)return this._pageState.toObject();throw new Oe}get fullscreen(){return Boolean(this._fullscreen)}queryAll(){var e;return Array.from(((e=this.appManager)==null?void 0:e.appProxies.values())||[])}queryOne(e){var t;return(t=this.appManager)==null?void 0:t.appProxies.get(e)}async closeApp(e){var t;return(t=this.appManager)==null?void 0:t.closeApp(e)}focusApp(e){var i,n,r;const t=(i=this.boxManager)==null?void 0:i.getBox(e);t&&((n=this.boxManager)==null||n.focusBox({appId:e},!1),((r=this.boxManager)==null?void 0:r.teleBoxManager).makeBoxTop(t,!1))}moveCamera(e){const t=E.omit(e,["animationMode"]),i={...this.mainView.camera};E.isEqual({...i,...t},i)||(this.mainView.moveCamera(e),setTimeout(()=>{var n;(n=this.appManager)==null||n.mainViewProxy.setCameraAndSize()},500))}moveCameraToContain(e){this.mainView.moveCameraToContain(e),setTimeout(()=>{var t;(t=this.appManager)==null||t.mainViewProxy.setCameraAndSize()},500)}convertToPointInWorld(e){return this.mainView.convertToPointInWorld(e)}setCameraBound(e){this.mainView.setCameraBound(e)}onDestroy(){this._destroy()}destroy(){this._destroy()}_destroy(){var e,t,i,n,r,s,o;(e=this.attributesDeboundceLog)==null||e.destroy(),this.attributesDeboundceLog=void 0,(t=this.containerResizeObserver)==null||t.disconnect(),(i=this.appManager)==null||i.destroy(),(n=this.cursorManager)==null||n.destroy(),(r=this.extendPluginManager)==null||r.destroy(),O.container=void 0,O.wrapper=void 0,O.sizer=void 0,O.isCreated=!1,O.playground&&((s=O.playground.parentNode)==null||s.removeChild(O.playground)),O.params=void 0,this.emitter.off("mainViewScenePathChange",this.onMainViewScenePathChangeHandler),(o=this._iframeBridge)==null||o.destroy(),this._iframeBridge=void 0,et("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,Boolean(t)),(i=this.cursorManager)==null||i.setMainViewDivElement(e))}get canOperate(){return I.isRoom(this.displayer)?this.displayer.isWritable&&this.displayer.phase===I.RoomPhase.Connected:!1}get room(){return this.displayer}safeSetAttributes(e){this.canOperate&&(this.setAttributes(e),this.attributesDeboundceLog&&this.attributesDeboundceLog.logDebouncedShallowMerge("safeSetAttributes",e))}safeUpdateAttributes(e,t){this.canOperate&&(this.updateAttributes(e,t),this.attributesDeboundceLog&&this.attributesDeboundceLog.logDebouncedUpdateAttributes(e,t))}setPrefersColorScheme(e){var t,i;(i=(t=this.appManager)==null?void 0:t.boxManager)==null||i.setPrefersColorScheme(e)}cleanCurrentScene(){var e,t;et("clean current scene"),(e=this.focusedView)==null||e.cleanCurrentScene(),this.Logger&&this.Logger.info(`[WindowManager]: cleanCurrentScene ${(t=this.focusedView)==null?void 0:t.focusScenePath}`)}redo(){var e;return((e=this.focusedView)==null?void 0:e.redo())||0}undo(){var e;return((e=this.focusedView)==null?void 0:e.undo())||0}delete(){var e,t;(e=this.focusedView)==null||e.delete(),this.Logger&&this.Logger.info(`[WindowManager]: delete ${(t=this.focusedView)==null?void 0:t.focusScenePath}`)}copy(){var e;(e=this.focusedView)==null||e.copy()}paste(){var e;(e=this.focusedView)==null||e.paste()}duplicate(){var e;(e=this.focusedView)==null||e.duplicate()}insertText(e,t,i){var n;return((n=this.focusedView)==null?void 0:n.insertText(e,t,i))||""}insertImage(e){var t;return(t=this.focusedView)==null?void 0:t.insertImage(e)}completeImageUpload(e,t){var i;return(i=this.focusedView)==null?void 0:i.completeImageUpload(e,t)}lockImage(e,t){var i;return(i=this.focusedView)==null?void 0:i.lockImage(e,t)}lockImages(e){var t;return(t=this.focusedView)==null?void 0:t.lockImages(e)}refresh(){var e;this._refresh(),(e=this.appManager)==null||e.dispatchInternalEvent(se.Refresh)}_refresh(){var e,t;(e=this.appManager)==null||e.mainViewProxy.rebind(),O.container&&this.bindContainer(O.container),(t=this.appManager)==null||t.refresher.refresh()}setContainerSizeRatio(e){if(!E.isNumber(e)||!(e>0))throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a positive number. but got ${e}`);O.containerSizeRatio=e,this.containerSizeRatio=e,_.emit("containerSizeRatioUpdate",e)}isDynamicPPT(e){var i,n;const t=(n=(i=e[0])==null?void 0:i.ppt)==null?void 0:n.src;return t==null?void 0:t.startsWith("pptx://")}async ensureAttributes(){E.isNull(this.attributes)&&await Hh(50),E.isObject(this.attributes)&&(this.attributes[xe.Apps]||this.safeSetAttributes({[xe.Apps]:{}}),this.attributes[xe.Cursors]||this.safeSetAttributes({[xe.Cursors]:{}}),this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:Uh}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:0}),this.attributes[xe.Registered]||this.safeSetAttributes({[xe.Registered]:{}}),this.attributes[xe.IframeBridge]||this.safeSetAttributes({[xe.IframeBridge]:{}}))}getIframeBridge(){if(!this.appManager)throw new Error("[WindowManager]: should call getIframeBridge() after await mount()");return this._iframeBridge||(this._iframeBridge=new dn(this,this.appManager)),this._iframeBridge}useExtendPlugin(e){var t;(t=this.extendPluginManager)==null||t.use(e)}};let Q=O;Q.kind="WindowManager";Q.debug=!1;Q.containerSizeRatio=Hg;Q.isCreated=!1;Q._resolve=e=>{};Px();exports.AppContext=fr;exports.AppCreateError=Fh;exports.AppManager=Sr;exports.AppManagerNotInitError=Oe;exports.AppNotRegisterError=pm;exports.AppProxy=xr;exports.AttributesDelegate=yr;exports.BindContainerRoomPhaseInvalidError=Jh;exports.BoxManager=mr;exports.BoxManagerNotFoundError=Xh;exports.BoxNotCreatedError=Yh;exports.BuiltinApps=zx;exports.CursorManager=wr;exports.ExtendPlugin=vM;exports.ExtendPluginManager=Eg;exports.InvalidScenePath=Gh;exports.ParamsInvalidError=Zh;exports.TeleBoxCollector=cn;exports.TeleBoxManager=gr;exports.WhiteWebSDKInvalidError=Qh;exports.WindowManager=Q;exports.calculateNextIndex=Cl;exports.getExtendClass=wM;exports.reconnectRefresher=Ng;
15
+ ***************************************************************************** */var X=function(){return X=Object.assign||function(e){for(var t,s=1,r=arguments.length;s<r;s++){t=arguments[s];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},X.apply(this,arguments)};function oi(i,e){var t={};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&e.indexOf(s)<0&&(t[s]=i[s]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(i);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(i,s[r])&&(t[s[r]]=i[s[r]]);return t}var jt=0,fs=typeof window!="undefined"&&window.requestAnimationFrame!==void 0?function(i){return window.requestAnimationFrame(i)}:function(i){var e=Date.now(),t=Math.max(0,16.7-(e-jt));jt=e+t,setTimeout(function(){return i(jt)},t)},Vr=function(i){var e=[],t=[],s=0,r=!1,n=0,a=new WeakSet,o=new WeakSet,h={cancel:function(c){var l=t.indexOf(c);a.add(c),l!==-1&&t.splice(l,1)},process:function(c){var l;if(r=!0,l=[t,e],e=l[0],t=l[1],t.length=0,s=e.length,s){var u;for(n=0;n<s;n++)u=e[n],u(c),o.has(u)===!0&&!a.has(u)&&(h.schedule(u),i(!0))}r=!1},schedule:function(c,l,u){l===void 0&&(l=!1),u===void 0&&(u=!1);var d=u&&r,m=d?e:t;a.delete(c),l&&o.add(c),m.indexOf(c)===-1&&(m.push(c),d&&(s=e.length))}};return h},jr=40,Ei=1/60*1e3,ft=!0,Je=!1,Kt=!1,Oe={delta:0,timestamp:0},hi=["read","update","preRender","render","postRender"],Rr=function(i){return Je=i},Ms=hi.reduce(function(i,e){return i[e]=Vr(Rr),i},{}),kr=hi.reduce(function(i,e){var t=Ms[e];return i[e]=function(s,r,n){return r===void 0&&(r=!1),n===void 0&&(n=!1),Je||_r(),t.schedule(s,r,n),s},i},{}),Ur=function(i){return Ms[i].process(Oe)},ws=function(i){Je=!1,Oe.delta=ft?Ei:Math.max(Math.min(i-Oe.timestamp,jr),1),ft||(Ei=Oe.delta),Oe.timestamp=i,Kt=!0,hi.forEach(Ur),Kt=!1,Je&&(ft=!1,fs(ws))},_r=function(){Je=!0,ft=!0,Kt||fs(ws)},xs=function(i,e){return function(t){return Math.max(Math.min(t,e),i)}},Mt=function(i){return i%1?Number(i.toFixed(5)):i},Ss=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i,bt={test:function(i){return typeof i=="number"},parse:parseFloat,transform:function(i){return i}},Ze=X(X({},bt),{transform:xs(0,1)}),dt=X(X({},bt),{default:1}),ci=function(i){return{test:function(e){return typeof e=="string"&&e.endsWith(i)&&e.split(" ").length===1},parse:parseFloat,transform:function(e){return""+e+i}}},we=ci("deg"),Fe=ci("%"),T=ci("px"),Vi=X(X({},Fe),{parse:function(i){return Fe.parse(i)/100},transform:function(i){return Fe.transform(i*100)}}),Or=function(i){return i.substring(i.indexOf("(")+1,i.lastIndexOf(")"))},Wr=xs(0,255),qt=function(i){return i.red!==void 0},ei=function(i){return i.hue!==void 0};function $r(i){return Or(i).replace(/(,|\/)/g," ").split(/ \s*/)}var bs=function(i){return function(e){if(typeof e!="string")return e;for(var t={},s=$r(e),r=0;r<4;r++)t[i[r]]=s[r]!==void 0?parseFloat(s[r]):1;return t}},Zr=function(i){var e=i.red,t=i.green,s=i.blue,r=i.alpha,n=r===void 0?1:r;return"rgba("+e+", "+t+", "+s+", "+n+")"},Fr=function(i){var e=i.hue,t=i.saturation,s=i.lightness,r=i.alpha,n=r===void 0?1:r;return"hsla("+e+", "+t+", "+s+", "+n+")"},Rt=X(X({},bt),{transform:function(i){return Math.round(Wr(i))}});function li(i,e){return i.startsWith(e)&&Ss.test(i)}var wt={test:function(i){return typeof i=="string"?li(i,"rgb"):qt(i)},parse:bs(["red","green","blue","alpha"]),transform:function(i){var e=i.red,t=i.green,s=i.blue,r=i.alpha,n=r===void 0?1:r;return Zr({red:Rt.transform(e),green:Rt.transform(t),blue:Rt.transform(s),alpha:Mt(Ze.transform(n))})}},kt={test:function(i){return typeof i=="string"?li(i,"hsl"):ei(i)},parse:bs(["hue","saturation","lightness","alpha"]),transform:function(i){var e=i.hue,t=i.saturation,s=i.lightness,r=i.alpha,n=r===void 0?1:r;return Fr({hue:Math.round(e),saturation:Fe.transform(Mt(t)),lightness:Fe.transform(Mt(s)),alpha:Mt(Ze.transform(n))})}},ji=X(X({},wt),{test:function(i){return typeof i=="string"&&li(i,"#")},parse:function(i){var e="",t="",s="";return i.length>4?(e=i.substr(1,2),t=i.substr(3,2),s=i.substr(5,2)):(e=i.substr(1,1),t=i.substr(2,1),s=i.substr(3,1),e+=e,t+=t,s+=s),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(s,16),alpha:1}}}),ne={test:function(i){return typeof i=="string"&&Ss.test(i)||qt(i)||ei(i)},parse:function(i){return wt.test(i)?wt.parse(i):kt.test(i)?kt.parse(i):ji.test(i)?ji.parse(i):i},transform:function(i){return qt(i)?wt.transform(i):ei(i)?kt.transform(i):i}},ui=function(i){var e=i.onRead,t=i.onRender,s=i.uncachedValues,r=s===void 0?new Set:s,n=i.useCache,a=n===void 0?!0:n;return function(o){o===void 0&&(o={});var h=oi(o,[]),c={},l=[],u=!1;function d(g,b){g.startsWith("--")&&(h.hasCSSVariable=!0);var M=c[g];c[g]=b,c[g]!==M&&(l.indexOf(g)===-1&&l.push(g),u||(u=!0,kr.render(m.render)))}var m={get:function(g,b){b===void 0&&(b=!1);var M=!b&&a&&!r.has(g)&&c[g]!==void 0;return M?c[g]:e(g,h)},set:function(g,b){if(typeof g=="string")d(g,b);else for(var M in g)d(M,g[M]);return this},render:function(g){return g===void 0&&(g=!1),(u||g===!0)&&(t(c,h,l),u=!1,l.length=0),this}};return m}},Gr=/([a-z])([A-Z])/g,Qr="$1-$2",vt=function(i){return i.replace(Gr,Qr).toLowerCase()},vs=new Map,di=new Map,Is=["Webkit","Moz","O","ms",""],Yr=Is.length,Hr=typeof document!="undefined",Ut,ys=function(i,e){return di.set(i,vt(e))},Jr=function(i){Ut=Ut||document.createElement("div");for(var e=0;e<Yr;e++){var t=Is[e],s=t==="",r=s?i:t+i.charAt(0).toUpperCase()+i.slice(1);if(r in Ut.style||s){if(s&&i==="clipPath"&&di.has(i))return;vs.set(i,r),ys(i,(s?"":"-")+vt(r))}}},Xr=function(i){return ys(i,i)},Cs=function(i,e){e===void 0&&(e=!1);var t=e?di:vs;return t.has(i)||(Hr?Jr(i):Xr(i)),t.get(i)||i},Kr=["","X","Y","Z"],qr=["translate","scale","rotate","skew","transformPerspective"],ti=qr.reduce(function(i,e){return Kr.reduce(function(t,s){return t.push(e+s),t},i)},["x","y","z"]),ea=ti.reduce(function(i,e){return i[e]=!0,i},{});function gi(i){return ea[i]===!0}function ta(i,e){return ti.indexOf(i)-ti.indexOf(e)}var ia=new Set(["originX","originY","originZ"]);function sa(i){return ia.has(i)}var Ri=X(X({},bt),{transform:Math.round}),ra={color:ne,backgroundColor:ne,outlineColor:ne,fill:ne,stroke:ne,borderColor:ne,borderTopColor:ne,borderRightColor:ne,borderBottomColor:ne,borderLeftColor:ne,borderWidth:T,borderTopWidth:T,borderRightWidth:T,borderBottomWidth:T,borderLeftWidth:T,borderRadius:T,radius:T,borderTopLeftRadius:T,borderTopRightRadius:T,borderBottomRightRadius:T,borderBottomLeftRadius:T,width:T,maxWidth:T,height:T,maxHeight:T,size:T,top:T,right:T,bottom:T,left:T,padding:T,paddingTop:T,paddingRight:T,paddingBottom:T,paddingLeft:T,margin:T,marginTop:T,marginRight:T,marginBottom:T,marginLeft:T,rotate:we,rotateX:we,rotateY:we,rotateZ:we,scale:dt,scaleX:dt,scaleY:dt,scaleZ:dt,skew:we,skewX:we,skewY:we,distance:T,translateX:T,translateY:T,translateZ:T,x:T,y:T,z:T,perspective:T,opacity:Ze,originX:Vi,originY:Vi,originZ:T,zIndex:Ri,fillOpacity:Ze,strokeOpacity:Ze,numOctaves:Ri},pi=function(i){return ra[i]},aa=function(i,e){return e&&typeof i=="number"?e.transform(i):i},Ge="scrollLeft",Qe="scrollTop",As=new Set([Ge,Qe]),na=new Set([Ge,Qe,"transform"]),oa={x:"translateX",y:"translateY",z:"translateZ"};function Bs(i){return typeof i=="function"}function ha(i,e,t,s,r,n){n===void 0&&(n=!0);var a="",o=!1;t.sort(ta);for(var h=t.length,c=0;c<h;c++){var l=t[c];a+=(oa[l]||l)+"("+e[l]+") ",o=l==="z"?!0:o}return!o&&r?a+="translateZ(0)":a=a.trim(),Bs(i.transform)?a=i.transform(e,s?"":a):n&&s&&(a="none"),a}function ca(i,e,t,s,r,n,a,o){e===void 0&&(e=!0),t===void 0&&(t={}),s===void 0&&(s={}),r===void 0&&(r={}),n===void 0&&(n=[]),a===void 0&&(a=!1),o===void 0&&(o=!0);var h=!0,c=!1,l=!1;for(var u in i){var d=i[u],m=pi(u),g=aa(d,m);gi(u)?(c=!0,s[u]=g,n.push(u),h&&(m.default&&d!==m.default||!m.default&&d!==0)&&(h=!1)):sa(u)?(r[u]=g,l=!0):(!na.has(u)||!Bs(g))&&(t[Cs(u,a)]=g)}return(c||typeof i.transform=="function")&&(t.transform=ha(i,s,n,h,e,o)),l&&(t.transformOrigin=(r.originX||"50%")+" "+(r.originY||"50%")+" "+(r.originZ||0)),t}function mi(i){var e=i===void 0?{}:i,t=e.enableHardwareAcceleration,s=t===void 0?!0:t,r=e.isDashCase,n=r===void 0?!0:r,a=e.allowTransformNone,o=a===void 0?!0:a,h={},c={},l={},u=[];return function(d){return u.length=0,ca(d,s,h,c,l,u,n,o),h}}function la(i,e){var t=e.element,s=e.preparseOutput,r=pi(i);if(gi(i))return r&&r.default||0;if(As.has(i))return t[i];var n=window.getComputedStyle(t,null).getPropertyValue(Cs(i,!0))||0;return s&&r&&r.test(n)&&r.parse?r.parse(n):n}function ua(i,e,t){var s=e.element,r=e.buildStyles,n=e.hasCSSVariable;if(Object.assign(s.style,r(i)),n)for(var a=t.length,o=0;o<a;o++){var h=t[o];h.startsWith("--")&&s.style.setProperty(h,i[h])}t.indexOf(Ge)!==-1&&(s[Ge]=i[Ge]),t.indexOf(Qe)!==-1&&(s[Qe]=i[Qe])}var da=ui({onRead:la,onRender:ua,uncachedValues:As});function ga(i,e){e===void 0&&(e={});var t=e.enableHardwareAcceleration,s=e.allowTransformNone,r=oi(e,["enableHardwareAcceleration","allowTransformNone"]);return da(X({element:i,buildStyles:mi({enableHardwareAcceleration:t,allowTransformNone:s}),preparseOutput:!0},r))}var Ns=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues"]),ki=.5,zs=function(){return{style:{}}},_t=function(i,e){return T.transform(i*e)},pa={x:0,y:0,width:0,height:0};function Ui(i,e,t){return typeof i=="string"?i:T.transform(e+t*i)}function ma(i,e,t){return Ui(e,i.x,i.width)+" "+Ui(t,i.y,i.height)}var Ds={enableHardwareAcceleration:!1,isDashCase:!1};function fa(i,e,t,s,r,n){e===void 0&&(e=pa),s===void 0&&(s=mi(Ds)),r===void 0&&(r=zs()),n===void 0&&(n=!0);var a=i.attrX,o=i.attrY,h=i.originX,c=i.originY,l=i.pathLength,u=i.pathSpacing,d=u===void 0?1:u,m=i.pathOffset,g=m===void 0?0:m,b=oi(i,["attrX","attrY","originX","originY","pathLength","pathSpacing","pathOffset"]),M=s(b);for(var N in M)if(N==="transform")r.style.transform=M[N];else{var z=n&&!Ns.has(N)?vt(N):N;r[z]=M[N]}return(h!==void 0||c!==void 0||M.transform)&&(r.style.transformOrigin=ma(e,h!==void 0?h:ki,c!==void 0?c:ki)),a!==void 0&&(r.x=a),o!==void 0&&(r.y=o),t!==void 0&&l!==void 0&&(r[n?"stroke-dashoffset":"strokeDashoffset"]=_t(-g,t),r[n?"stroke-dasharray":"strokeDasharray"]=_t(l,t)+" "+_t(d,t)),r}function Ma(i,e,t){t===void 0&&(t=!0);var s=zs(),r=mi(Ds);return function(n){return fa(n,i,e,r,s,t)}}var wa=function(i){return typeof i.getBBox=="function"?i.getBBox():i.getBoundingClientRect()},xa=function(i){try{return wa(i)}catch{return{x:0,y:0,width:0,height:0}}},Sa=function(i){return i.tagName==="path"},ba=ui({onRead:function(i,e){var t=e.element;if(i=Ns.has(i)?i:vt(i),gi(i)){var s=pi(i);return s&&s.default||0}else return t.getAttribute(i)},onRender:function(i,e){var t=e.element,s=e.buildAttrs,r=s(i);for(var n in r)n==="style"?Object.assign(t.style,r.style):t.setAttribute(n,r[n])}}),va=function(i){var e=xa(i),t=Sa(i)&&i.getTotalLength?i.getTotalLength():void 0;return ba({element:i,buildAttrs:Ma(e,t)})},Ia=ui({useCache:!1,onRead:function(i){return i==="scrollTop"?window.pageYOffset:window.pageXOffset},onRender:function(i){var e=i.scrollTop,t=e===void 0?0:e,s=i.scrollLeft,r=s===void 0?0:s;return window.scrollTo(r,t)}}),ii=new WeakMap,ya=function(i){return i instanceof HTMLElement||typeof i.click=="function"},Ca=function(i){return i instanceof SVGElement||"ownerSVGElement"in i},Aa=function(i,e){var t;return i===window?t=Ia(i):ya(i)?t=ga(i,e):Ca(i)&&(t=va(i)),ii.set(i,t),t},Ba=function(i,e){return ii.has(i)?ii.get(i):Aa(i,e)};function Na(i,e){var t=typeof i=="string"?document.querySelector(i):i;return Ba(t,e)}var oe=function(e,t,s,r){var n=s?s.call(r,e,t):void 0;if(n!==void 0)return!!n;if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;var a=Object.keys(e),o=Object.keys(t);if(a.length!==o.length)return!1;for(var h=Object.prototype.hasOwnProperty.bind(t),c=0;c<a.length;c++){var l=a[c];if(!h(l))return!1;var u=e[l],d=t[l];if(n=s?s.call(r,u,d,l):void 0,n===!1||n===void 0&&u!==d)return!1}return!0};const Ts="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",za=Ts.length,_i=Array(20),Ue=()=>{for(let i=0;i<20;i++)_i[i]=Ts.charAt(Math.random()*za);return _i.join("")};class xt{constructor(){this.disposers=new Map}add(e,t=Ue()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=Ue()){return this.flush(t),this.disposers.set(t,e),t}addEventListener(e,t,s,r,n=Ue()){return this.add(()=>(e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)),n),n}setTimeout(e,t,s=Ue()){return this.add(()=>{const r=window.setTimeout(()=>{this.remove(s),e()},t);return()=>window.clearTimeout(r)},s)}setInterval(e,t,s=Ue()){return this.add(()=>{const r=window.setInterval(e,t);return()=>window.clearInterval(r)},s)}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){const t=this.remove(e);if(t)try{t()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(e=>{try{e()}catch(t){console.error(t)}}),this.disposers.clear()}}var Da=Object.defineProperty,Ot=(typeof require!="undefined"&&require,(i,e,t)=>(((s,r,n)=>{r in s?Da(s,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[r]=n})(i,typeof e!="symbol"?e+"":e,t),t));class et{constructor(e,t){Ot(this,"_value"),Ot(this,"_beforeDestroys"),Ot(this,"_subscribers"),this._value=e,t&&(this.compare=t)}get value(){return this._value}setValue(e,t){if(!this.compare(e,this._value)){const s=this._value;this._value=e,this._subscribers&&this._subscribers.forEach(r=>r(e,s,t))}}reaction(e){return this._subscribers||(this._subscribers=new Set),this._subscribers.add(e),()=>{this._subscribers&&this._subscribers.delete(e)}}subscribe(e,t){const s=this.reaction(e);return e(this._value,void 0,t),s}derive(e,t,s){const r=new et(e(this.value,void 0,s),t),n=this.reaction((a,o,h)=>{r.setValue(e(a,o,h))});return r.addBeforeDestroy(n),r}destroy(){this._beforeDestroys&&(this._beforeDestroys.forEach(e=>e()),this._beforeDestroys.clear()),this._subscribers&&this._subscribers.clear()}addBeforeDestroy(e){return this._beforeDestroys||(this._beforeDestroys=new Set),this._beforeDestroys.add(e),()=>{this._beforeDestroys&&this._beforeDestroys.delete(e)}}compare(e,t){return e===t}}function Ta(i,e,t,s){let r=i.map(a=>a.value);const n=new et(e(r,void 0,s),t);return i.forEach((a,o)=>{const h=a.reaction((c,l,u)=>{const d=r.slice();d[o]=c;const m=r;r=d,n.setValue(e(d,m,u),u)});n.addBeforeDestroy(h)}),n}function Ps(i,e){Object.keys(e).forEach(t=>{Pa(i,t,e[t])})}function Pa(i,e,t){var s;return Object.defineProperties(i,{[e]:{get:()=>t.value},[`_${e}$`]:{value:t},[`set${s=e,s[0].toUpperCase()+s.slice(1)}`]:{value:(r,n)=>t.setValue(r,n)}}),i}function Ls(i){const e=t=>{const s=i.addDisposer(()=>{t.destroy()});return t.addBeforeDestroy(()=>{i.remove(s)}),t};return{bindSideEffect:e,combine:(t,s,r,n)=>e(Ta(t,s,r,n)),createVal:(t,s)=>e(new et(t,s))}}var fi=(i=>(i.Light="light",i.Dark="dark",i.Auto="auto",i))(fi||{}),x=(i=>(i.Normal="normal",i.Minimized="minimized",i.Maximized="maximized",i))(x||{}),k=(i=>(i.DarkMode="dark_mode",i.PrefersColorScheme="prefers_color_scheme",i.Close="close",i.Focus="focus",i.Blur="blur",i.Move="move",i.Resize="resize",i.IntrinsicMove="intrinsic_move",i.IntrinsicResize="intrinsic_resize",i.VisualResize="visual_resize",i.ZIndex="z_index",i.State="state",i.Minimized="minimized",i.Maximized="maximized",i.Readonly="readonly",i.Destroyed="destroyed",i.BoxStatus="box_status",i.LastNotMinimizedBoxStatus="last_not_minimized_box_status",i.ForceTop="force_top",i.ForceNormal="force_normal",i))(k||{}),H=(i=>(i.Close="close",i.Maximize="maximize",i.Minimize="minimize",i))(H||{}),he=(i=>(i.North="n",i.South="s",i.West="w",i.East="e",i.NorthWest="nw",i.NorthEast="ne",i.SouthEast="se",i.SouthWest="sw",i))(he||{});const Wt="dh";function K(i,e,t){return Math.min(Math.max(i,e),t)}function De(i){i.stopPropagation(),i.cancelable&&i.preventDefault()}function Oi(i){return i.touches?i.touches[0]:i}function La(){return Date.now().toString().slice(6)+Math.random().toString().slice(2,8)}let Ea=1;function Va(){return`New Box ${Ea++}`}function ja(i){return Boolean(i)}function gt(i){return!i}class Es{constructor({readonly:e=!1,title:t,buttons:s,onEvent:r,onDragStart:n,namespace:a="telebox",state:o=x.Normal,boxStatus:h,forceTop:c=!1,forceNormal:l=!1}={}){this.$btns=[],this.sideEffect=new xt,this.lastTitleBarClick={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarClick=u=>{var d;if(this.readonly||u.button!==0||(d=u.target.dataset)!=null&&d.teleTitleBarNoDblClick)return;De(u);const m=Date.now();m-this.lastTitleBarClick.timestamp<=500?Math.abs(u.clientX-this.lastTitleBarClick.clientX)<=5&&Math.abs(u.clientY-this.lastTitleBarClick.clientY)<=5&&this.onEvent&&this.onEvent({type:H.Maximize}):this.onDragStart&&this.onDragStart(u),this.lastTitleBarClick.timestamp=m,this.lastTitleBarClick.clientX=u.clientX,this.lastTitleBarClick.clientY=u.clientY},this.lastTitleBarTouch={timestamp:0,clientX:-100,clientY:-100},this.handleTitleBarTouch=u=>{var d;if(this.readonly||(d=u.target.dataset)!=null&&d.teleTitleBarNoDblClick)return;De(u);const m=Date.now(),{clientX:g=this.lastTitleBarTouch.clientX+100,clientY:b=this.lastTitleBarTouch.clientY+100}=u.touches[0]||{};m-this.lastTitleBarTouch.timestamp<=500?Math.abs(g-this.lastTitleBarTouch.clientX)<=10&&Math.abs(b-this.lastTitleBarTouch.clientY)<=10&&this.onEvent&&this.onEvent({type:H.Maximize}):this.onDragStart&&this.onDragStart(u),this.lastTitleBarTouch.timestamp=m,this.lastTitleBarTouch.clientX=g,this.lastTitleBarTouch.clientY=b},this.readonly=e,this.onEvent=r,this.onDragStart=n,this.namespace=a,this.title=t,this.state=o,this.boxStatus=h,this.forceTop=c,this.forceNormal=l,this.buttons=s||(l?[{type:H.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}]:[{type:H.Minimize,iconClassName:this.wrapClassName("titlebar-icon-minimize")},{type:H.Maximize,iconClassName:this.wrapClassName("titlebar-icon-maximize"),isActive:u=>u===x.Maximized},{type:H.Close,iconClassName:this.wrapClassName("titlebar-icon-close")}]),this.$dragArea=this.renderDragArea()}setTitle(e){this.title=e,this.$title&&(this.$title.textContent=e,this.$title.title=e)}setState(e){this.state!==e&&(this.state=e,this.buttons.forEach((t,s)=>{t.isActive&&this.$btns[s].classList.toggle("is-active",t.isActive(e))}))}setBoxStatus(e){this.boxStatus!==e&&(this.boxStatus=e,e&&this.buttons.forEach((t,s)=>{t.isActive&&this.$btns[s].classList.toggle("is-active",t.isActive(e))}))}setReadonly(e){this.readonly!==e&&(this.readonly=e)}render(){if(!this.$titleBar){this.$titleBar=document.createElement("div"),this.$titleBar.className=this.wrapClassName("titlebar");const e=document.createElement("div");e.className=this.wrapClassName("title-area"),e.dataset.teleBoxHandle=Wt,this.$title=document.createElement("h1"),this.$title.className=this.wrapClassName("title"),this.$title.dataset.teleBoxHandle=Wt,this.title&&(this.$title.textContent=this.title,this.$title.title=this.title),e.appendChild(this.$title),e.appendChild(this.$dragArea);const t=document.createElement("div");t.className=this.wrapClassName("titlebar-btns"),this.buttons.forEach(({iconClassName:s,isActive:r},n)=>{const a=String(n),o=document.createElement("button");o.className=`${this.wrapClassName("titlebar-btn")} ${s}`,o.dataset.teleTitleBarBtnIndex=a,o.dataset.teleTitleBarNoDblClick="true",r&&o.classList.toggle("is-active",r(this.boxStatus||this.state)),this.$btns.push(o),t.appendChild(o)}),this.sideEffect.addEventListener(t,"click",s=>{var r;if(this.readonly)return;const n=s.target,a=Number((r=n.dataset)==null?void 0:r.teleTitleBarBtnIndex);if(!Number.isNaN(a)&&a<this.buttons.length){De(s);const o=this.buttons[a];this.onEvent&&this.onEvent({type:o.type,value:o.value})}}),this.$titleBar.appendChild(e),this.$titleBar.appendChild(t)}return this.$titleBar}renderDragArea(){const e=document.createElement("div");return e.className=this.wrapClassName("drag-area"),e.dataset.teleBoxHandle=Wt,this.sideEffect.addEventListener(e,"mousedown",this.handleTitleBarClick),this.sideEffect.addEventListener(e,"touchstart",this.handleTitleBarTouch,{passive:!0}),e}dragHandle(){return this.$titleBar}wrapClassName(e){return`${this.namespace}-${e}`}destroy(){this.sideEffect.flushAll(),this.$titleBar&&(this.$titleBar=void 0,this.$title=void 0,this.$btns.length=0,this.onDragStart=void 0,this.onEvent=void 0)}}class Ra{constructor({id:e=La(),title:t=Va(),prefersColorScheme:s=fi.Light,darkMode:r,visible:n=!0,width:a=.5,height:o=.5,minWidth:h=0,minHeight:c=0,x:l=.1,y:u=.1,minimized:d=!1,maximized:m=!1,readonly:g=!1,resizable:b=!0,draggable:M=!0,fence:N=!0,fixRatio:z=!1,focus:v=!1,zIndex:Z=100,namespace:_="telebox",titleBar:W,content:ie,footer:Ie,styles:ge,containerRect:Ve={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collectorRect:S,boxStatus:p,lastNotMinimizedBoxStatus:B,forceTop:D=!1,forceNormal:Y=!1,isDragContent:F=!1}={}){this._renderSideEffect=new xt,this.handleTrackStart=I=>{var E;return(E=this._handleTrackStart)==null?void 0:E.call(this,I)},this._sideEffect=new xt,this._valSideEffectBinder=Ls(this._sideEffect);const{combine:ae,createVal:V}=this._valSideEffectBinder;this.id=e,this.namespace=_,this.events=new Xt,this._delegateEvents=new Xt;const le=V(p),bi=V(B),Ct=V(s);Ct.reaction((I,E,y)=>{y||this.events.emit(k.PrefersColorScheme,I)});const je=V(Boolean(r));r==null&&Ct.subscribe((I,E,y)=>{this._sideEffect.add(()=>{if(I==="auto"){const $=window.matchMedia("(prefers-color-scheme: dark)");if($){je.setValue($.matches,y);const Ce=ut=>{je.setValue(ut.matches,y)};return $.addListener(Ce),()=>$.removeListener(Ce)}else return Wi}else return je.setValue(I==="dark",y),Wi},"prefers-color-scheme")}),je.reaction((I,E,y)=>{y||this.events.emit(k.DarkMode,I)});const At=V(Ve,oe),Bt=V(S,oe),Nt=V(D);Nt.reaction((I,E,y)=>{y||this.events.emit(k.ForceTop,I||!1)});const zt=V(Y);zt.reaction((I,E,y)=>{y||this.events.emit(k.ForceNormal,I||!1)});const Fs=V(F),Dt=V(t);Dt.reaction((I,E,y)=>{y||this.titleBar.setTitle(I)});const Tt=V(n);Tt.reaction((I,E,y)=>{!y&&!I&&this.events.emit(k.Close)});const ht=V(g);ht.reaction((I,E,y)=>{y||this.events.emit(k.Readonly,I)});const Gs=V(b),Qs=V(M),Ys=V(N),Hs=V(z),vi=V(Z);vi.reaction((I,E,y)=>{y||this.events.emit(k.ZIndex,I)});const Ii=V(v);Ii.reaction((I,E,y)=>{y||this.events.emit(I?k.Focus:k.Blur)});const ye=V(d);ye.reaction((I,E,y)=>{y||this.events.emit(k.Minimized,I)});const Me=V(m);Me.reaction((I,E,y)=>{y||this.events.emit(k.Maximized,I)});const yi=ae([ye,Me,le],([I,E,y])=>I?x.Minimized:E?x.Maximized:y||x.Normal);yi.reaction((I,E,y)=>{y||this.events.emit(k.State,I)});const ct=V({width:K(h,0,1),height:K(c,0,1)},oe),Re=V({width:K(a,ct.value.width,1),height:K(o,ct.value.height,1)},oe);ct.reaction((I,E,y)=>{Re.setValue({width:K(a,I.width,1),height:K(o,I.height,1)},y)}),Re.reaction((I,E,y)=>{y||this.events.emit(k.IntrinsicResize,I)});const ke=ae([Re,Me,le],([I,E,y])=>E||y===x.Maximized?{width:1,height:1}:I,oe);ke.reaction((I,E,y)=>{y||this.events.emit(k.Resize,I)});const Ci=ae([ke,ye,At,Bt,le],([I,E,y,$,Ce])=>(E||Ce===x.Minimized)&&$?{width:$.width/I.width/y.width,height:$.height/I.height/y.height}:I,oe);Ci.reaction((I,E,y)=>{y||this.events.emit(k.VisualResize,I)});const Pt=V({x:K(l,0,1),y:K(u,0,1)},oe);Pt.reaction((I,E,y)=>{y||this.events.emit(k.IntrinsicMove,I)});const lt=ae([Pt,Re,At,Bt,ye,Me,le,bi],([I,E,y,$,Ce,ut,Ai,qs])=>(Ce||Ai===x.Minimized)&&$?ut||qs===x.Maximized?{x:($.x+$.width/2)/y.width-1/2,y:($.y+$.height/2)/y.height-1/2}:{x:($.x+$.width/2)/y.width-E.width/2,y:($.y+$.height/2)/y.height-E.height/2}:ut||Ai===x.Maximized?{x:0,y:0}:I,oe);lt.reaction((I,E,y)=>{y||this.events.emit(k.Move,I)}),this.titleBar=W||new Es({readonly:ht.value,title:Dt.value,namespace:this.namespace,boxStatus:le.value,forceTop:Nt.value,forceNormal:zt.value,onDragStart:I=>{var E;return(E=this._handleTrackStart)==null?void 0:E.call(this,I)},onEvent:I=>{if(this._delegateEvents.listeners.length>0)this._delegateEvents.emit(I.type);else switch(I.type){case H.Maximize:{le.value||Me.setValue(!Me.value);break}case H.Minimize:{le.value||ye.setValue(!0);break}case H.Close:{Tt.setValue(!1);break}default:{console.error("Unsupported titleBar event:",I);break}}}}),ht.reaction(I=>{this.titleBar.setReadonly(I)}),le.reaction(I=>{this.titleBar.setBoxStatus(I)});const Js=V(ie),Xs=V(Ie),Ks=V(ge);Ps(this,{prefersColorScheme:Ct,darkMode:je,containerRect:At,collectorRect:Bt,title:Dt,visible:Tt,readonly:ht,resizable:Gs,draggable:Qs,fence:Ys,fixRatio:Hs,focus:Ii,zIndex:vi,minimized:ye,maximized:Me,$userContent:Js,$userFooter:Xs,$userStyles:Ks,forceTop:Nt,forceNormal:zt,isDragContent:Fs}),this._state$=yi,this._minSize$=ct,this._size$=ke,this._intrinsicSize$=Re,this._visualSize$=Ci,this._coord$=lt,this._intrinsicCoord$=Pt,this._boxStatus$=le,this._lastNotMinimizedBoxStatus$=bi,this.fixRatio&&this.transform(lt.value.x,lt.value.y,ke.value.width,ke.value.height,!0),this.$box=this.render()}get boxStatus(){return this._boxStatus$.value}set boxStatus(e){this._boxStatus$.setValue(e)}get lastNotMinimizedBoxStatus(){return this._lastNotMinimizedBoxStatus$.value}get darkMode(){return this._darkMode$.value}get state(){return this._state$.value}setState(e,t=!1){switch(e){case x.Maximized:{this.setMinimized(!1,t),this.setMaximized(!0,t);break}case x.Minimized:{this.setMinimized(!0,t),this.setMaximized(!1,t);break}default:{this.setMinimized(!1,t),this.setMaximized(!1,t);break}}return this}setBoxStatus(e,t=!1){return e===x.Minimized?this._boxStatus$.value&&this._boxStatus$.value!==x.Minimized&&this.setLastNotMinimizedBoxStatus(this._boxStatus$.value,t):this.setLastNotMinimizedBoxStatus(void 0,t),this._boxStatus$.setValue(e,t),t||this.events.emit(k.BoxStatus,{id:this.id,boxStatus:e}),this}setLastNotMinimizedBoxStatus(e,t=!1){return this._lastNotMinimizedBoxStatus$.setValue(e,t),t||this.events.emit(k.LastNotMinimizedBoxStatus,{id:this.id,lastNotMinimizedBoxStatus:e}),this}get minWidth(){return this._minSize$.value.width}get minHeight(){return this._minSize$.value.height}setMinWidth(e,t=!1){return this._minSize$.setValue({width:e,height:this.minHeight},t),this}setMinHeight(e,t=!1){return this._minSize$.setValue({width:this.minWidth,height:e},t),this}get intrinsicWidth(){return this._intrinsicSize$.value.width}get intrinsicHeight(){return this._intrinsicSize$.value.height}resize(e,t,s=!1){return this._intrinsicSize$.setValue({width:e,height:t},s),this}get width(){return this._size$.value.width}get height(){return this._size$.value.height}get absoluteWidth(){return this.width*this.containerRect.width}get absoluteHeight(){return this.height*this.containerRect.height}get visualWidth(){return this._visualSize$.value.width}get visualHeight(){return this._visualSize$.value.height}get intrinsicX(){return this._intrinsicCoord$.value.x}get intrinsicY(){return this._intrinsicCoord$.value.y}move(e,t,s=!1){return this._intrinsicCoord$.setValue({x:e,y:t},s),this}get x(){return this._coord$.value.x}get y(){return this._coord$.value.y}transform(e,t,s,r,n=!1){if(this.fixRatio){const a=this.intrinsicHeight/this.intrinsicWidth*s;t!==this.intrinsicY&&(t-=a-r),r=a}return t<0&&(t=0,r>this.intrinsicHeight&&(r=this.intrinsicHeight)),this._intrinsicCoord$.setValue({x:s>=this.minWidth?e:this.intrinsicX,y:r>=this.minHeight?t:this.intrinsicY},n),this._intrinsicSize$.setValue({width:K(s,this.minWidth,1),height:K(r,this.minHeight,1)},n),this}mount(e){return e.appendChild(this.render()),this}unmount(){return this.$box&&this.$box.remove(),this}mountContent(e){return this.set$userContent(e),this}unmountContent(){return this.set$userContent(void 0),this}mountFooter(e){return this.set$userFooter(e),this}unmountFooter(){return this.set$userFooter(void 0),this}getUserStyles(){return this.$userStyles}mountStyles(e){let t;return typeof e=="string"?(t=document.createElement("style"),t.textContent=e):t=e,this.set$userStyles(t),this}unmountStyles(){return this.set$userStyles(void 0),this}render(e){if(e){if(e===this.$box)return this.$box;this.$box=e}else{if(this.$box)return this.$box;this.$box=document.createElement("div")}this._renderSideEffect.flushAll(),this.$box.classList.add(this.wrapClassName("box"));const t=(u,d,m,g=ja)=>this._renderSideEffect.add(()=>{const b=this.wrapClassName(m);return d.subscribe(M=>{u.classList.toggle(b,g(M))})});t(this.$box,this._readonly$,"readonly"),t(this.$box,this._draggable$,"no-drag",gt),t(this.$box,this._resizable$,"no-resize",gt),t(this.$box,this._focus$,"blur",gt),t(this.$box,this._darkMode$,"color-scheme-dark"),t(this.$box,this._darkMode$,"color-scheme-light",gt),this._renderSideEffect.add(()=>{const u=this.wrapClassName("minimized"),d=this.wrapClassName("maximized"),m="box-maximized-timer";return this._state$.subscribe(g=>{this.$box.classList.toggle(u,g===x.Minimized),g===x.Maximized?(this._renderSideEffect.flush(m),this.$box.classList.toggle(d,!0)):this._renderSideEffect.setTimeout(()=>{this.$box.classList.toggle(d,!1)},0,m)})}),this._renderSideEffect.add(()=>this._visible$.subscribe(u=>{u?this.$box.style.removeProperty("display"):this.$box.style.display="none"})),this._renderSideEffect.add(()=>this._zIndex$.subscribe(u=>{this.$box.style.zIndex=String(u)}));const s=Na(this.$box);this.$box.dataset.teleBoxID=this.id,this.$box.style.width=this.absoluteWidth+"px",this.$box.style.height=this.absoluteHeight+"px";const r=this.x*this.containerRect.width+this.containerRect.x,n=this.y*this.containerRect.height+this.containerRect.y;this.$box.style.transform=`translate(${r-10}px,${n-10}px)`,this._valSideEffectBinder.combine([this._coord$,this._size$,this._minimized$,this._containerRect$,this._collectorRect$,this._boxStatus$],([u,d,m,g,b,M])=>{const N=d.width*g.width,z=d.height*g.height;return{width:N+((m||M===x.Minimized)&&b?1:0),height:z+((m||M===x.Minimized)&&b?1:0),x:u.x*g.width,y:u.y*g.height,scaleX:(m||M===x.Minimized)&&b?b.width/N:1,scaleY:(m||M===x.Minimized)&&b?b.height/z:1}},oe).subscribe(u=>{s.set(u)}),s.set({x:r,y:n});const a=document.createElement("div");a.className=this.wrapClassName("box-main"),this.$box.appendChild(a);const o=document.createElement("div");o.className=this.wrapClassName("titlebar-wrap"),o.appendChild(this.titleBar.render()),this.$titleBar=o;const h=document.createElement("div");h.className=this.wrapClassName("content-wrap");const c=document.createElement("div");c.className=this.wrapClassName("content")+" tele-fancy-scrollbar",this.$content=c,this.isDragContent&&this.$content.appendChild(this.titleBar.$dragArea),this._renderSideEffect.add(()=>{let u;return this._$userStyles$.subscribe(d=>{u&&u.remove(),u=d,d&&h.appendChild(d)})}),this._renderSideEffect.add(()=>{let u;return this._$userContent$.subscribe(d=>{u&&u.remove(),u=d,d&&c.appendChild(d)})}),h.appendChild(c);const l=document.createElement("div");return l.className=this.wrapClassName("footer-wrap"),this.$footer=l,this._renderSideEffect.add(()=>{let u;return this._$userFooter$.subscribe(d=>{u&&u.remove(),u=d,d&&l.appendChild(d)})}),a.appendChild(o),a.appendChild(h),a.appendChild(l),this._renderResizeHandlers(),this.$box}_renderResizeHandlers(){const e=document.createElement("div");e.className=this.wrapClassName("resize-handles"),Object.values(he).forEach(b=>{const M=document.createElement("div");M.className=this.wrapClassName(b)+" "+this.wrapClassName("resize-handle"),M.dataset.teleBoxHandle=b,e.appendChild(M)}),this.$box.appendChild(e);const t="handle-tracking-listener",s=this.wrapClassName("transforming");let r,n=0,a=0,o=0,h=0,c=0,l=0,u;const d=b=>{if(this.state!==x.Normal)return;De(b);let{pageX:M,pageY:N}=Oi(b);N<0&&(N=0);const z=(M-c)/this.containerRect.width,v=(N-l)/this.containerRect.height;switch(u){case he.North:{this.transform(this.x,a+v,this.width,h-v);break}case he.South:{this.transform(this.x,this.y,this.width,h+v);break}case he.West:{this.transform(n+z,this.y,o-z,this.height);break}case he.East:{this.transform(this.x,this.y,o+z,this.height);break}case he.NorthWest:{this.transform(n+z,a+v,o-z,h-v);break}case he.NorthEast:{this.transform(this.x,a+v,o+z,h-v);break}case he.SouthEast:{this.transform(this.x,this.y,o+z,h+v);break}case he.SouthWest:{this.transform(n+z,this.y,o-z,h+v);break}default:{if(this.fence)this.move(K(n+z,0,1-this.width),K(a+v,0,1-this.height));else{const Z=20/this.containerRect.width,_=20/this.containerRect.height;this.move(K(n+z,Z-this.width,1-Z),K(a+v,0,1-_))}break}}},m=b=>{u=void 0,r&&(De(b),this.$box.classList.toggle(s,!1),this._sideEffect.flush(t),r.remove())},g=b=>{var M;if(this.readonly||b.button!=null&&b.button!==0||!this.draggable||u||this.state!==x.Normal)return;const N=b.target;if((M=N.dataset)!=null&&M.teleBoxHandle){De(b),n=this.x,a=this.y,o=this.width,h=this.height,{pageX:c,pageY:l}=Oi(b),u=N.dataset.teleBoxHandle,r||(r=document.createElement("div"));const z=u?this.wrapClassName(`cursor-${u}`):"";r.className=this.wrapClassName(`track-mask${z?` ${z}`:""}`),this.$box.appendChild(r),this.$box.classList.add(s),this._sideEffect.add(()=>(window.addEventListener("mousemove",d),window.addEventListener("touchmove",d,{passive:!1}),window.addEventListener("mouseup",m),window.addEventListener("touchend",m,{passive:!1}),window.addEventListener("touchcancel",m,{passive:!1}),()=>{window.removeEventListener("mousemove",d),window.removeEventListener("touchmove",d),window.removeEventListener("mouseup",m),window.removeEventListener("touchend",m),window.removeEventListener("touchcancel",m)}),t)}};this._handleTrackStart=g,this._sideEffect.addEventListener(e,"mousedown",g,{},"box-resizeHandles-mousedown"),this._sideEffect.addEventListener(e,"touchstart",g,{passive:!1},"box-resizeHandles-touchstart")}destroy(){this.$box.remove(),this.events.emit(k.Destroyed),this._sideEffect.flushAll(),this._renderSideEffect.flushAll(),this.events.removeAllListeners(),this._delegateEvents.removeAllListeners()}wrapClassName(e){return`${this.namespace}-${e}`}}function Wi(){}var ka="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K";class Le{constructor({visible:e=!0,readonly:t=!1,darkMode:s=!1,namespace:r="telebox",styles:n={},onClick:a,getBoxesStatus:o}){this.$appMenuContainer=document.createElement("div"),this.handleCollectorClick=()=>{!this._readonly&&this.onClick&&this.onClick()},this._visible=e,this._readonly=t,this._darkMode=s,this.namespace=r,this.styles=n,this.onClick=a,this.getBoxesStatus=o}get boxesStatus(){var e;return(e=this.getBoxesStatus)==null?void 0:e.call(this)}get visible(){return this._visible}get readonly(){return this._readonly}get darkMode(){return this._darkMode}mount(e){return e.appendChild(this.render()),this}unmount(){return this.$collector&&this.$collector.remove(),this}hasMinimizedBox(){const e=this.boxesStatus;if(e){for(const t of e.values())if(t===x.Minimized)return!0}return!1}updateBoxesStatus(){const e=this.hasMinimizedBox();this.setVisible(e)}setVisible(e){return this._visible!==e&&(this._visible=e,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-visible"),e)),this}setReadonly(e){return this._readonly!==e&&(this._readonly=e,this.$collector&&this.$collector.classList.toggle(this.wrapClassName("collector-readonly"),e)),this}setDarkMode(e){return this._darkMode!==e&&(this._darkMode=e,this.$collector&&(this.$collector.classList.toggle(this.wrapClassName("color-scheme-dark"),e),this.$collector.classList.toggle(this.wrapClassName("color-scheme-light"),!e))),this}setStyles(e){if(Object.assign(this.styles,e),this.$collector){const t=this.$collector;Object.keys(e).forEach(s=>{const r=e[s];r!=null&&(t.style[s]=r)})}return this}render(){return this.$collector||(this.$collector=document.createElement("button"),this.$collector.className=this.wrapClassName("collector"),this.$collector.style.backgroundImage=`url('${ka}')`,this.$collector.addEventListener("click",this.handleCollectorClick),this._visible&&this.$collector.classList.add(this.wrapClassName("collector-visible")),this._readonly&&this.$collector.classList.add(this.wrapClassName("collector-readonly")),this.$collector.classList.add(this.wrapClassName(this._darkMode?"color-scheme-dark":"color-scheme-light")),this.$appMenuContainer.classList.add(this.wrapClassName("collector-shadow")),this.$collector.append(this.$appMenuContainer),this.setStyles(this.styles)),this.$collector}destroy(){this.$collector&&(this.$collector.removeEventListener("click",this.handleCollectorClick),this.$collector.remove(),this.$collector=void 0),this.onClick=void 0}wrapClassName(e){return`${this.namespace}-${e}`}}Le.kind="TeleBoxCollector";var O=(i=>(i.Focused="focused",i.Blurred="blurred",i.Created="created",i.Removed="removed",i.State="state",i.Maximized="maximized",i.Minimized="minimized",i.Move="move",i.Resize="resize",i.IntrinsicMove="intrinsic_move",i.IntrinsicResize="intrinsic_resize",i.VisualResize="visual_resize",i.ZIndex="z_index",i.PrefersColorScheme="prefers_color_scheme",i.DarkMode="dark_mode",i.BoxStatus="box_status",i.LastNotMinimizedBoxStatus="last_not_minimized_box_status",i))(O||{});class Ua extends Es{constructor(e){super(e),this.boxes=e.boxes,this.focusedBox=e.focusedBox,this.containerRect=e.containerRect,this.darkMode=e.darkMode,this.getBoxesStatus=e.getBoxesStatus}get boxesStatus(){var e;return(e=this.getBoxesStatus)==null?void 0:e.call(this)}hasMaximizedBoxInStatus(){if(this.getBoxesStatus){const e=this.getBoxesStatus();if(e.size)return!![...e.values()].find(s=>s===x.Maximized)}return!1}get MaximizedBoxes(){if(this.getBoxesStatus){const e=this.getBoxesStatus();if(e)return this.boxes.filter(t=>e&&e.get(t.id)===x.Maximized&&!t.forceTop)}return[]}focusBox(e){var t,s;if(!(this.focusedBox&&this.focusedBox===e)){if(this.$titles){const{children:r}=this.$titles.firstElementChild;if(this.state===x.Maximized&&!this.hasMaximizedBoxInStatus())for(let n=r.length-1;n>=0;n-=1){const a=r[n],o=(t=a.dataset)==null?void 0:t.teleBoxID;o&&(e&&o===e.id?a.classList.toggle(this.wrapClassName("titles-tab-focus"),!0):this.focusedBox&&o===this.focusedBox.id&&a.classList.toggle(this.wrapClassName("titles-tab-focus"),!1))}else if(this.hasMaximizedBoxInStatus())for(let n=r.length-1;n>=0;n-=1){const a=r[n],o=(s=a.dataset)==null?void 0:s.teleBoxID;o&&(e&&o===e.id?a.classList.toggle(this.wrapClassName("titles-tab-focus"),!0):this.focusedBox&&o===this.focusedBox.id&&a.classList.toggle(this.wrapClassName("titles-tab-focus"),!1))}}this.focusedBox=e}}setContainerRect(e){if(this.containerRect=e,this.$titleBar){const{x:t,y:s,width:r}=e;this.$titleBar.style.transform=`translate(${t}px, ${s}px)`,this.$titleBar.style.width=r+"px"}}updateBoxesStatus(){this.hasMaximizedBoxInStatus()&&this.setBoxStatus(x.Maximized),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===x.Maximized&&this.boxes.length>0||this.hasMaximizedBoxInStatus()),this.updateTitles()}setBoxes(e){this.boxes=e,this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===x.Maximized&&e.length>0||this.hasMaximizedBoxInStatus()),this.updateTitles()}setState(e){super.setState(e),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"),e===x.Maximized&&this.boxes.length>0||this.hasMaximizedBoxInStatus()),this.updateTitles()}setReadonly(e){super.setReadonly(e),this.$titleBar&&this.$titleBar.classList.toggle(this.wrapClassName("readonly"),this.readonly)}setDarkMode(e){e!==this.darkMode&&(this.darkMode=e,this.$titleBar&&(this.$titleBar.classList.toggle(this.wrapClassName("color-scheme-dark"),e),this.$titleBar.classList.toggle(this.wrapClassName("color-scheme-light"),!e)))}render(){const e=super.render(),{x:t,y:s,width:r}=this.containerRect;e.style.transform=`translate(${t}px, ${s}px)`,e.style.width=r+"px",e.classList.add(this.wrapClassName("max-titlebar")),e.classList.toggle(this.wrapClassName("max-titlebar-maximized"),this.state===x.Maximized&&this.boxes.length>0),e.classList.toggle(this.wrapClassName("readonly"),this.readonly),e.classList.add(this.wrapClassName(this.darkMode?"color-scheme-dark":"color-scheme-light"));const n=document.createElement("div");return n.classList.add(this.wrapClassName("titles-area")),e.insertBefore(n,e.firstElementChild),this.updateTitles(),e}destroy(){super.destroy(),this.$titles=void 0,this.boxes.length=0,this.focusedBox=void 0}updateTitles(){this.$titleBar&&(this.state===x.Maximized||this.hasMaximizedBoxInStatus())&&(this.$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"),this.boxes.length===1||this.hasMaximizedBoxInStatus()&&this.MaximizedBoxes.length===1),this.boxes.length===1||this.hasMaximizedBoxInStatus()&&this.MaximizedBoxes.length===1?this.setTitle(this.boxes[0].title):this.$titleBar.replaceChild(this.renderTitles(),this.$titleBar.firstElementChild))}renderTitles(){this.$titles=document.createElement("div"),this.$titles.className=this.wrapClassName("titles"),this.$titles.addEventListener("wheel",t=>{t.currentTarget.scrollBy({left:t.deltaY>0?250:-250,behavior:"smooth"})},{passive:!1});const e=document.createElement("div");return e.className=this.wrapClassName("titles-content"),this.$titles.appendChild(e),(this.hasMaximizedBoxInStatus()?this.MaximizedBoxes:this.boxes).forEach(t=>{const s=document.createElement("button");s.className=this.wrapClassName("titles-tab"),s.textContent=t.title,s.dataset.teleBoxID=t.id,s.dataset.teleTitleBarNoDblClick="true",this.focusedBox&&t.id===this.focusedBox.id&&s.classList.add(this.wrapClassName("titles-tab-focus")),e.appendChild(s)}),this.$titles}}class _a{constructor(e){this.namespace="telebox-app-menu",this.badge=document.createElement("div"),this.menuView=document.createElement("div"),this.containerClickHandler=()=>{if(this.manager.readonly)return;getComputedStyle(this.menuView).display==="flex"?this.menuView.style.display="none":this.menuView.style.display="flex"},this.menuViewClickHandler=t=>{t.stopPropagation(),t.stopImmediatePropagation();const r=t.target.getAttribute(`data-${this.c("app-id")}`);if(r){const n=this.manager.getLastNotMinimizedBoxStatus(r)||x.Normal,a=(n===x.Maximized?this.manager.getMaxMaximizedBoxZIndex():this.manager.getMaxNormalBoxZIndex())+1;this.manager.setBox(r,{status:n,zIndex:a},!1,()=>{this.manager.focusBox(r)});return}},this.updatePrefersColorSchemeHandler=()=>{this.container.classList.remove(this.theme),this.theme=this.manager.prefersColorScheme,this.container.classList.add(this.theme)},this.appMenuChange=()=>{const t=this.manager.getMinimizedBoxesStatus();this.render(t)},this.container=e.container,this.manager=e.manager,this.theme=e.theme,this.getBoxesStatus=e.getBoxesStatus,this.init()}get boxesStatus(){var e;return((e=this.getBoxesStatus)==null?void 0:e.call(this))||new Map}get minimizedBoxesStatus(){const e=[];return this.boxesStatus.forEach(t=>{t===x.Minimized&&e.push(t)}),e}c(e){return`${this.namespace}-${e}`}setContainer(e){this.container&&this.container.remove(),this.container=e,this.init()}createDefaultAppMenu(){this.badge.classList.add(this.c("app-menu-badge")),this.menuView.classList.add(this.c("app-menu-tooltip")),this.container.classList.add(this.c("app-menu-container"),this.theme),this.menuView.addEventListener("click",this.menuViewClickHandler),this.container.append(this.badge,this.menuView)}async init(){this.createDefaultAppMenu(),this.appMenuChange()}createMinimizedItem(e){const t=document.createElement("div");t.classList.add(this.c("app-menu-item")),t.setAttribute(`data-${this.c("app-id")}`,e);const s=document.createElement("div");s.classList.add(this.c("app-menu-item-title"));const r=this.manager.getBox(e);return s.innerText=(r==null?void 0:r.title)||e,t.appendChild(s),t}renderMenuView(e){const t=[];e.forEach((s,r)=>{t.push(this.createMinimizedItem(r))}),this.menuView.append(...t)}render(e){this.menuView.style.display="none",this.badge.innerText="",this.menuView.innerHTML="",e.size===0?this.container.style.display="none":(this.badge.innerText=e.size.toString(),this.renderMenuView(e),this.container.style.display="block")}destroy(){this.badge.remove(),this.menuView.removeEventListener("click",this.menuViewClickHandler),this.menuView.remove(),this.container.remove()}}class tt{constructor({root:e=document.body,prefersColorScheme:t=fi.Light,minimized:s=!1,maximized:r=!1,fence:n=!0,containerRect:a={x:0,y:0,width:window.innerWidth,height:window.innerHeight},collector:o,namespace:h="telebox",readonly:c=!1,useBoxesStatus:l=!1}={}){this.events=new Xt,this._sideEffect=new xt,this.useBoxesStatus=l;const{combine:u,createVal:d}=Ls(this._sideEffect);this.root=e,this.namespace=h,this.boxes$=d([]),this.topBox$=this.boxes$.derive(S=>{if(S.length>0){let p;return S.reduce((D,Y)=>Y.forceTop||Y.boxStatus&&Y.boxStatus===x.Minimized?D:D?D.zIndex>Y.zIndex?D:Y:(D=Y,D),p)}}),this.boxesStatus$=new Map,this.lastNotMinimizedBoxesStatus$=new Map;const m=window.matchMedia("(prefers-color-scheme: dark)"),g=d(!1);m&&(g.setValue(m.matches),this._sideEffect.add(()=>{const S=p=>{g.setValue(p.matches)};return m.addListener(S),()=>m.removeListener(S)}));const b=d(t);b.reaction((S,p,B)=>{this.boxes.forEach(D=>D.setPrefersColorScheme(S,B)),B||this.events.emit(O.PrefersColorScheme,S)}),this._darkMode$=u([g,b],([S,p])=>p==="auto"?S:p==="dark"),this._darkMode$.reaction((S,p,B)=>{this.boxes.forEach(D=>D.setDarkMode(S,B)),B||this.events.emit(O.DarkMode,S)});const M=d(c);M.reaction((S,p,B)=>{this.boxes.forEach(D=>D.setReadonly(S,B))});const N=d(s),z=d(r);z.reaction((S,p,B)=>{this.boxes.forEach(D=>D.setMaximized(S,B)),B||this.events.emit(O.Maximized,S)});const v=u([N,z],([S,p])=>S?x.Minimized:p?x.Maximized:x.Normal);v.reaction((S,p,B)=>{this.maxTitleBar.setState(S),B||this.events.emit(O.State,S)});const Z=d(n);Z.subscribe((S,p,B)=>{this.boxes.forEach(D=>D.setFence(S,B))});const _=d(a,oe);_.reaction((S,p,B)=>{this.boxes.forEach(D=>D.setContainerRect(S,B)),this.maxTitleBar.setContainerRect(S)});const W=d(o===null?null:o||new Le({visible:s,readonly:c,namespace:h}).mount(e));W.subscribe(S=>{S&&(S.setVisible(N.value),S.setReadonly(M.value),S.setDarkMode(this._darkMode$.value),this.useBoxesStatus&&this.appMenu&&this.appMenu.setContainer(S.$appMenuContainer),this._sideEffect.add(()=>(S.getBoxesStatus=()=>this.boxesStatus$,S.onClick=()=>{M.value||(this.useBoxesStatus?this.useBoxesStatus&&this.appMenu&&this.appMenu.containerClickHandler():N.setValue(!1))},()=>S.destroy()),"collect-onClick"))}),M.subscribe(S=>{var p;return(p=W.value)==null?void 0:p.setReadonly(S)}),this._darkMode$.subscribe(S=>{var p;(p=W.value)==null||p.setDarkMode(S)}),this._calcCollectorRect=()=>{var S;if((S=W.value)!=null&&S.$collector){const{x:p,y:B,width:D,height:Y}=W.value.$collector.getBoundingClientRect(),F=this.root.getBoundingClientRect();return{x:p-F.x,y:B-F.y,width:D,height:Y}}},this._setCollectorRect=S=>{var p;(p=W.value)!=null&&p.$collector&&ie.setValue(S)};const ie=d(N.value?this._calcCollectorRect():void 0);ie.subscribe((S,p,B)=>{this.boxes.forEach(D=>{D.setCollectorRect(S,B)})}),N.subscribe((S,p,B)=>{var D;(D=W.value)==null||D.setVisible(S),S&&this._setCollectorRect(this._calcCollectorRect()),this.boxes.forEach(Y=>Y.setMinimized(S,B)),B||this.events.emit(O.Minimized,S)});const Ie=this.wrapClassName("titlebar-icon-close"),ge=S=>{var p;if(M.value)return;const B=S.target;if(!!B.tagName)for(let D=B;D;D=D.parentElement){if(D.classList&&D.classList.contains(Ie))return;const Y=(p=D.dataset)==null?void 0:p.teleBoxID;if(Y){const F=this.getBox(Y);if(F){if(!this.useBoxesStatus)this.makeBoxTop(F);else if(F.boxStatus&&F.boxStatus===x.Normal){const ae=this.getMaxNormalBoxZIndex();ae>F.zIndex&&this.setBox(F,{zIndex:ae+1},!1)}else if(F.boxStatus&&F.boxStatus===x.Maximized){const ae=this.getMaxMaximizedBoxZIndex();ae>F.zIndex&&this.setBox(F,{zIndex:ae+1},!1),this.makeMaximizedTopBoxFocus()}this.focusBox(F);return}}}};this._sideEffect.addEventListener(window,"mousedown",ge,!0),this._sideEffect.addEventListener(window,"touchstart",ge,!0),this.maxTitleBar=new Ua({darkMode:this.darkMode,readonly:M.value,namespace:this.namespace,state:v.value,boxes:this.boxes$.value,containerRect:_.value,getBoxesStatus:()=>this.boxesStatus$,onEvent:S=>{switch(S.type){case H.Maximize:{if(this.hasBoxesStatus()){let p=this.maxTitleBar.focusedBox;if(p||(p=this.getMaximizedTopBox()),p!=null&&p.id){const B=this.getBox(p.id);B&&this.setBox(B,{status:x.Normal,zIndex:this.getMaxNormalBoxZIndex()+1},!1,()=>{this.makeMaximizedTopBoxFocus()})}}else z.setValue(!z.value);break}case H.Minimize:{if(this.hasBoxesStatus()){let p=this.maxTitleBar.focusedBox;if(p||(p=this.getMaximizedTopBox()),p!=null&&p.id){const B=this.getBox(p.id);if(B){let D=!1;B.focus&&(this.blurBox(B),D=!0),this.setBox(B,{status:x.Minimized,zIndex:-1},!1),D?this.focusTopBox():this.makeMaximizedTopBoxFocus()}}}else N.setValue(!0);break}case k.Close:{if(this.hasBoxesStatus()){let p=this.maxTitleBar.focusedBox;if(p||(p=this.getMaximizedTopBox()),p!=null&&p.id){const B=this.getBox(p.id);if(B){let D=!1;B.focus&&(this.blurBox(B),D=!0),this.remove(B,!1),D?this.focusTopBox():this.makeMaximizedTopBoxFocus()}}}else this.removeTopBox(),this.focusTopBox();break}}}}),M.subscribe(S=>this.maxTitleBar.setReadonly(S)),this._darkMode$.subscribe(S=>{this.maxTitleBar.setDarkMode(S)}),this.boxes$.reaction(S=>{this.maxTitleBar.setBoxes(S)}),Ps(this,{prefersColorScheme:b,containerRect:_,collector:W,collectorRect:ie,readonly:M,fence:Z,minimized:N,maximized:z}),this._state$=v,this.root.appendChild(this.maxTitleBar.render()),l&&(this.appMenu=this.createMinimizedAppMenu())}get boxes(){return this.boxes$.value}get topBox(){return this.topBox$.value}get forceTopBoxes(){return this.boxes.find(e=>e.forceTop)}get maxForceTopBox(){return this.boxes.reduce((e,t)=>{var s;return t.forceTop&&t.zIndex>((s=e==null?void 0:e.zIndex)!=null?s:0)?t:e},void 0)}get forceNormalBoxes(){return this.boxes.find(e=>e.forceNormal)}get darkMode(){return this._darkMode$.value}get state(){return this._state$.value}setState(e,t=!1){switch(e){case x.Maximized:{this.setMinimized(!1,t),this.setMaximized(!0,t);break}case x.Minimized:{this.setMinimized(!0,t),this.setMaximized(!1,t);break}default:{this.setMinimized(!1,t),this.setMaximized(!1,t);break}}return this}setBoxStatus(e,t,s=!1){if(t){const r=this.boxesStatus$.get(e);this.boxesStatus$.set(e,t),t===x.Minimized&&r!==x.Minimized?this.setLastNotMinimizedBoxStatus(e,r,s):r===x.Minimized&&t!==x.Minimized&&this.setLastNotMinimizedBoxStatus(e,void 0,s)}else this.boxesStatus$.delete(e),this.setLastNotMinimizedBoxStatus(e,void 0,s);s||this.events.emit(O.BoxStatus,{id:e,boxStatus:t})}getBoxStatus(e){return this.boxesStatus$.get(e)}get boxesStatus(){return this.boxesStatus$}get lastNotMinimizedBoxesStatus(){return this.lastNotMinimizedBoxesStatus$}setBoxesStatus(e,t=!1){this.boxesStatus$=e,this.effectBoxesStatusChange(t)}getBoxesStatus(){return this.boxesStatus$}effectBoxStatusChange(){!this.useBoxesStatus||(this.collector&&(this.collector.updateBoxesStatus(),this.hasMinimizedBox()&&this._setCollectorRect(this._calcCollectorRect())),this.appMenu&&this.appMenu.appMenuChange(),this.maxTitleBar&&this.maxTitleBar.updateBoxesStatus())}effectBoxesStatusTimerFunc(e){if(!this.useBoxesStatus)return;let t;const s=this.topBox;this.boxes.forEach(r=>{var n;const a=this.boxesStatus$.get(r.id);a&&(a!==x.Minimized&&!this.isForceTop(r)&&r.zIndex>((n=t==null?void 0:t.zIndex)!=null?n:0)&&(t=r),r.setBoxStatus(a,e))}),this.effectBoxStatusChange(),t&&s!==t&&this.topBox$.setValue(t),!t&&s&&this.topBox$.setValue(void 0)}async effectBoxesStatusChange(e=!1){var t,s;if(!this.useBoxesStatus){this.effectBoxesStatusTimer&&this.effectBoxesStatusTimer.timer&&(clearTimeout(this.effectBoxesStatusTimer.timer),this.effectBoxesStatusTimer.resolve&&this.effectBoxesStatusTimer.resolve(!!((t=this.effectBoxesStatusTimer)!=null&&t.skipUpdate))),this.effectBoxesStatusTimer=void 0;return}if(this.effectBoxesStatusTimer&&this.effectBoxesStatusTimer.timer)if(this.effectBoxesStatusTimer.skipUpdate!==e)clearTimeout(this.effectBoxesStatusTimer.timer),this.effectBoxesStatusTimer.resolve&&this.effectBoxesStatusTimer.resolve(!!((s=this.effectBoxesStatusTimer)!=null&&s.skipUpdate)),this.effectBoxesStatusTimer.skipUpdate=e;else return;if(this.effectBoxesStatusTimer||(this.effectBoxesStatusTimer={skipUpdate:e,timer:void 0,resolve:void 0}),this.effectBoxesStatusTimer){const r=await new Promise(n=>{this.effectBoxesStatusTimer.resolve=n,this.effectBoxesStatusTimer.timer=setTimeout(()=>{this.effectBoxesStatusTimer&&this.effectBoxesStatusTimer.resolve&&this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer.skipUpdate)},100)});this.effectBoxesStatusTimerFunc(r),this.effectBoxesStatusTimer=void 0}}hasBoxesStatus(){return this.useBoxesStatus?this.boxesStatus$.size>0:!1}hasMinimizedBox(){return this.useBoxesStatus?this.boxes.some(e=>e.boxStatus&&e.boxStatus===x.Minimized):!1}getMinimizedBoxesStatus(){const e=new Map;return this.boxesStatus$.forEach((t,s)=>{t===x.Minimized&&e.set(s,t)}),e}getNotMinimizedBoxesStatus(){const e=new Map;return this.boxesStatus$.forEach((t,s)=>{t!==x.Minimized&&e.set(s,t)}),e}getAllMaximizedBoxesStatus(){const e=new Map;return this.boxesStatus$.forEach((t,s)=>{t===x.Maximized&&e.set(s,t)}),e}getAllNormalBoxesStatus(){const e=new Map;return this.boxesStatus$.forEach((t,s)=>{t===x.Normal&&e.set(s,t)}),e}getLastNotMinimizedBoxStatus(e){return this.lastNotMinimizedBoxesStatus$.get(e)}setLastNotMinimizedBoxStatus(e,t,s=!1){t?this.lastNotMinimizedBoxesStatus$.set(e,t):this.lastNotMinimizedBoxesStatus$.delete(e),s||this.events.emit(O.LastNotMinimizedBoxStatus,{id:e,boxStatus:t})}setLastNotMinimizedBoxesStatus(e,t=!1){this.lastNotMinimizedBoxesStatus$=e,this.effectLastNotMinimizedBoxStatusChange(t)}async effectLastNotMinimizedBoxStatusChange(e=!1){var t,s;if(!this.useBoxesStatus){this.effectLastNotMinimizedBoxStatusTimer&&this.effectLastNotMinimizedBoxStatusTimer.timer&&(clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer),this.effectLastNotMinimizedBoxStatusTimer.resolve&&this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((t=this.effectLastNotMinimizedBoxStatusTimer)!=null&&t.skipUpdate))),this.effectLastNotMinimizedBoxStatusTimer=void 0;return}if(this.effectLastNotMinimizedBoxStatusTimer&&this.effectLastNotMinimizedBoxStatusTimer.timer)if(clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer),this.effectLastNotMinimizedBoxStatusTimer.skipUpdate!==e)this.effectLastNotMinimizedBoxStatusTimer.resolve&&this.effectLastNotMinimizedBoxStatusTimer.resolve(!!((s=this.effectLastNotMinimizedBoxStatusTimer)!=null&&s.skipUpdate)),this.effectLastNotMinimizedBoxStatusTimer.skipUpdate=e;else return;if(this.effectLastNotMinimizedBoxStatusTimer||(this.effectLastNotMinimizedBoxStatusTimer={skipUpdate:e,timer:void 0,resolve:void 0}),this.effectLastNotMinimizedBoxStatusTimer){const r=await new Promise(n=>{this.effectLastNotMinimizedBoxStatusTimer.resolve=n,this.effectLastNotMinimizedBoxStatusTimer.timer=setTimeout(()=>{this.effectLastNotMinimizedBoxStatusTimer&&this.effectLastNotMinimizedBoxStatusTimer.resolve&&this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate)},100)});this.effectLastNotMinimizedBoxStatusFunc(r),this.effectLastNotMinimizedBoxStatusTimer=void 0}}effectLastNotMinimizedBoxStatusFunc(e=!1){!this.useBoxesStatus||this.boxes.forEach(t=>{const s=this.lastNotMinimizedBoxesStatus$.get(t.id);s&&t.setLastNotMinimizedBoxStatus(s,e)})}getUnabledBoxesStatusZIndex(){return this.topBox?this.topBox.zIndex:99}getMaxMaximizedBoxZIndex(){return this.useBoxesStatus?this.boxes.reduce((e,t)=>t.boxStatus&&t.boxStatus===x.Maximized&&!this.isForceTop(t)?Math.max(e,t.zIndex):e,99):this.getUnabledBoxesStatusZIndex()}getMaxNormalBoxZIndex(){return this.useBoxesStatus?this.boxes.reduce((e,t)=>t.boxStatus&&t.boxStatus===x.Normal&&!this.isForceTop(t)?Math.max(e,t.zIndex):e,299):this.getUnabledBoxesStatusZIndex()}getMaxForceTopBoxZIndex(){return this.useBoxesStatus?this.boxes.reduce((e,t)=>t.boxStatus&&this.isForceTop(t)?Math.max(e,t.zIndex):e,699):this.getUnabledBoxesStatusZIndex()}isForceNormal(e){return e._forceNormal$.value}isForceTop(e){return e._forceTop$.value}create(e={},t=!0){const s=new Ra({zIndex:e.forceTop?this.getMaxForceTopBoxZIndex()+1:this.getMaxNormalBoxZIndex()+1,...t?this.smartPosition(e):e,darkMode:this.darkMode,prefersColorScheme:this.prefersColorScheme,maximized:this.maximized,minimized:this.minimized,fence:this.fence,namespace:this.namespace,containerRect:this.containerRect,readonly:this.readonly,collectorRect:this.collectorRect});return s.mount(this.root),this.boxes$.setValue([...this.boxes,s]),s.boxStatus&&this.useBoxesStatus&&this.setBox(s,{status:s.boxStatus,lastNotMinimizedBoxStatus:s._lastNotMinimizedBoxStatus$.value},!0),s.focus&&(this.focusBox(s),t&&this.makeBoxTop(s)),s._delegateEvents.on(H.Maximize,()=>{if(this.useBoxesStatus&&s.boxStatus){if(s._forceNormal$.value)return;s.boxStatus===x.Maximized?this.setBox(s.id,{status:x.Normal,zIndex:this.getMaxNormalBoxZIndex()+1},!1):([...this.boxes].filter(r=>r.boxStatus===x.Normal&&!this.isForceNormal(r)).sort((r,n)=>r.zIndex-n.zIndex).forEach(r=>{r.boxStatus===x.Normal&&this.setBox(r.id,{status:x.Maximized,zIndex:this.getMaxMaximizedBoxZIndex()+1},!1)}),this.makeMaximizedTopBoxFocus())}else this.setMaximized(!this.maximized)}),s._delegateEvents.on(H.Minimize,()=>{if(s.boxStatus&&this.useBoxesStatus){if(s._forceNormal$.value)return;s.focus&&this.blurBox(s),this.setBox(s,{status:x.Minimized,zIndex:-1},!1,()=>{this.focusTopBox()})}else this.setMinimized(!0)}),s._delegateEvents.on(H.Close,()=>{this.useBoxesStatus&&s.focus&&this.blurBox(s),this.remove(s),this.focusTopBox()}),s._coord$.reaction((r,n,a)=>{a||this.events.emit(O.Move,s)}),s._size$.reaction((r,n,a)=>{a||this.events.emit(O.Resize,s)}),s._intrinsicCoord$.reaction((r,n,a)=>{a||this.events.emit(O.IntrinsicMove,s)}),s._intrinsicSize$.reaction((r,n,a)=>{a||this.events.emit(O.IntrinsicResize,s)}),s._visualSize$.reaction((r,n,a)=>{a||this.events.emit(O.VisualResize,s)}),s._zIndex$.reaction((r,n,a)=>{if(this.boxes.length>0){let o;const h=this.boxes.reduce((c,l)=>this.isForceTop(l)||l.boxStatus&&l.boxStatus===x.Minimized?c:c?c.zIndex>l.zIndex?c:l:(c=l,c),o);this.topBox$.setValue(h)}a||this.events.emit(O.ZIndex,s)}),this.events.emit(O.Created,s),s}query(e){return e?this.boxes.filter(this.teleBoxMatcher(e)):[...this.boxes]}queryOne(e){return e?this.boxes.find(this.teleBoxMatcher(e)):this.boxes[0]}update(e,t,s=!1){const r=this.boxes.find(n=>n.id===e);if(r)return this.updateBox(r,t,s)}updateAll(e,t=!1){this.boxes.forEach(s=>{this.updateBox(s,e,t)})}setBox(e,t,s=!1,r){const n=this.getBox(e);if(n){const{status:a,zIndex:o,lastNotMinimizedBoxStatus:h}=t;a&&(this.setBoxStatus(n.id,a,s),n.setBoxStatus(a,s),this.effectBoxStatusChange()),o&&n.setZIndex(o,s),h&&(this.setLastNotMinimizedBoxStatus(n.id,h,s),n.setLastNotMinimizedBoxStatus(h,s)),r&&r()}}remove(e,t=!1,s){const r=this.getBox(e),n=this.getBoxIndex(e);if(n>=0){const a=this.boxes.slice(),o=a.splice(n,1);return this.boxes$.setValue(a),o.forEach(h=>h.destroy()),r&&this.useBoxesStatus&&(this.setBoxStatus(r.id,void 0,t),this.setLastNotMinimizedBoxStatus(r.id,void 0,t),this.effectBoxStatusChange(),s&&s()),t||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(O.Removed,o)),o[0]}}removeTopBox(){if(this.topBox)return this.remove(this.topBox)}removeAll(e=!1){const t=this.boxes$.value;return this.boxes$.setValue([]),t.forEach(s=>s.destroy()),this.boxesStatus$.clear(),this.lastNotMinimizedBoxesStatus$.clear(),e||(this.boxes.length<=0&&(this.setMaximized(!1),this.setMinimized(!1)),this.events.emit(O.Removed,t)),t}destroy(e=!1){this.events.removeAllListeners(),this._sideEffect.flushAll(),this.removeAll(e),Object.keys(this).forEach(t=>{const s=this[t];s instanceof et&&s.destroy()})}wrapClassName(e){return`${this.namespace}-${e}`}focusBox(e,t=!1){const s=this.getBox(e);s&&(this.boxes.forEach(r=>{if(s===r){let n=!1;s.focus||(n=!0,s.setFocus(!0,t)),n&&!t&&this.events.emit(O.Focused,s)}else r.focus&&this.blurBox(r,t)}),this.useBoxesStatus?this.useBoxesStatus&&this.maxTitleBar.hasMaximizedBoxInStatus()&&this.makeMaximizedTopBoxFocus():this.maxTitleBar.focusBox(s))}focusTopBox(){if(this.topBox&&!this.topBox.focus)return this.focusBox(this.topBox)}blurBox(e,t=!1){const s=this.getBox(e);s&&(s.focus&&(s.setFocus(!1,t),t||this.events.emit(O.Blurred,s)),this.maxTitleBar.focusedBox===s&&this.maxTitleBar.focusBox())}blurAll(e=!1){this.boxes.forEach(t=>{t.focus&&(t.setFocus(!1,e),e||this.events.emit(O.Blurred,t))}),this.maxTitleBar.focusedBox&&this.maxTitleBar.focusBox()}teleBoxMatcher(e){const t=Object.keys(e);return s=>t.every(r=>e[r]===s[r])}updateBox(e,t,s=!1){(t.x!=null||t.y!=null)&&e.move(t.x==null?e.intrinsicX:t.x,t.y==null?e.intrinsicY:t.y,s),(t.width!=null||t.height!=null)&&e.resize(t.width==null?e.intrinsicWidth:t.width,t.height==null?e.intrinsicHeight:t.height,s),t.title!=null&&(e.setTitle(t.title),this.maxTitleBar.updateTitles()),t.visible!=null&&e.setVisible(t.visible,s),t.minHeight!=null&&e.setMinHeight(t.minHeight,s),t.minWidth!=null&&e.setMinWidth(t.minWidth,s),t.resizable!=null&&e.setResizable(t.resizable,s),t.draggable!=null&&e.setDraggable(t.draggable,s),t.fixRatio!=null&&e.setFixRatio(t.fixRatio,s),t.zIndex!=null&&e.setZIndex(t.zIndex,s),t.content!=null&&e.mountContent(t.content),t.footer!=null&&e.mountFooter(t.footer),this.useBoxesStatus&&(t.boxStatus||t.lastNotMinimizedBoxStatus)&&this.setBox(e,{status:t.boxStatus,lastNotMinimizedBoxStatus:t.lastNotMinimizedBoxStatus},s),t.forceTop!=null&&e.setForceTop(t.forceTop,s),t.forceNormal!=null&&e.setForceNormal(t.forceNormal,s)}smartPosition(e={}){let{x:t,y:s}=e;const{width:r=.5,height:n=.5}=e;if(t==null){let a=20;if(e.forceTop){const o=this.maxForceTopBox||this.topBox;o&&(a=o.intrinsicX*this.containerRect.width+20,a>this.containerRect.width-r*this.containerRect.width&&(a=20))}else this.topBox?(a=this.topBox.intrinsicX*this.containerRect.width+20,a>this.containerRect.width-r*this.containerRect.width&&(a=20)):this.hasMinimizedBox()&&(a=[...this.boxes].filter(o=>o.boxStatus&&o.boxStatus===x.Minimized&&o.lastNotMinimizedBoxStatus&&o.lastNotMinimizedBoxStatus===x.Normal).reduce((o,h)=>Math.max(o,h.intrinsicX*this.containerRect.width+20),a));t=a/this.containerRect.width}if(s==null){let a=20;if(e.forceTop){const o=this.maxForceTopBox||this.topBox;o&&(a=o.intrinsicY*this.containerRect.height+20,a>this.containerRect.height-n*this.containerRect.height&&(a=20))}else this.topBox?(a=this.topBox.intrinsicY*this.containerRect.height+20,a>this.containerRect.height-n*this.containerRect.height&&(a=20)):this.hasMinimizedBox()&&(a=[...this.boxes].filter(o=>o.boxStatus&&o.boxStatus===x.Minimized&&o.lastNotMinimizedBoxStatus&&o.lastNotMinimizedBoxStatus===x.Normal).reduce((o,h)=>Math.max(o,h.intrinsicY*this.containerRect.height+20),a));s=a/this.containerRect.height}return{...e,x:t,y:s,width:r,height:n}}makeBoxTop(e,t=!1){!this.useBoxesStatus&&this.topBox?e!==this.topBox&&e.setZIndex(this.topBox.zIndex+1,t):this.useBoxesStatus}getMaximizedTopBox(){if(!this.useBoxesStatus)return;let e;return this.maxTitleBar.hasMaximizedBoxInStatus()&&(e=this.maxTitleBar.MaximizedBoxes.reduce((t,s)=>t&&t.zIndex>s.zIndex?t:s)),e}makeMaximizedTopBoxFocus(){if(!this.useBoxesStatus)return;const e=this.getMaximizedTopBox();this.maxTitleBar.focusBox(e)}getBoxIndex(e){return typeof e=="string"?this.boxes.findIndex(t=>t.id===e):this.boxes.findIndex(t=>t===e)}getBox(e){return typeof e=="string"?this.boxes.find(t=>t.id===e):e}createMinimizedAppMenu(){var e,t;if((e=this.collector)!=null&&e.$appMenuContainer)return new _a({manager:this,container:(t=this.collector)==null?void 0:t.$appMenuContainer,theme:this.prefersColorScheme?"dark":"light",getBoxesStatus:()=>this.boxesStatus$})}}tt.kind="TeleBoxManager";const Oa=(i,e,t,s,r)=>{const n=de(it,P.extendClass);return new n({safeSetAttributes:a=>i.safeSetAttributes(a),getMainView:()=>i.mainView,updateAppState:(...a)=>{var o;return(o=i.appManager)==null?void 0:o.store.updateAppState(...a)},setBoxStatus:(a,o)=>{var h;return(h=i.appManager)==null?void 0:h.store.setBoxStatus(a,o)},setLastNotMinimizedBoxStatus:(a,o)=>{var h;return(h=i.appManager)==null?void 0:h.store.setLastNotMinimizedBoxStatus(a,o)},canOperate:()=>i.canOperate,notifyContainerRectUpdate:a=>{var o;return(o=i.appManager)==null?void 0:o.notifyContainerRectUpdate(a)},cleanFocus:()=>{var a;return(a=i.appManager)==null?void 0:a.store.cleanFocus()},setAppFocus:a=>{var o;return(o=i.appManager)==null?void 0:o.store.setAppFocus(a,!0)},callbacks:e,emitter:t,boxEmitter:s},r)};class it{constructor(e,t){this.context=e,this.createTeleBoxManagerConfig=t;const{emitter:s,callbacks:r,boxEmitter:n}=e;this.teleBoxManager=this.setupBoxManager(t),this.teleBoxManager._state$.reaction(a=>{r.emit("boxStateChange",a),s.emit("boxStateChange",a)}),this.teleBoxManager._darkMode$.reaction(a=>{r.emit("darkModeChange",a)}),this.teleBoxManager._prefersColorScheme$.reaction(a=>{r.emit("prefersColorSchemeChange",a)}),this.teleBoxManager._minimized$.reaction(a=>{a||setTimeout(()=>{const o=.001*(Math.random()>.5?1:-1);this.teleBoxManager.boxes.forEach(h=>{h.resize(h.intrinsicWidth+o,h.intrinsicHeight+o,!0)})},400)}),this.teleBoxManager.events.on("minimized",a=>{if(this.context.safeSetAttributes({minimized:a}),a)this.context.cleanFocus(),this.blurAllBox();else{const o=this.getTopBox();o&&(this.context.setAppFocus(o.id),this.focusBox({appId:o.id},!1))}}),this.teleBoxManager.events.on("maximized",a=>{this.context.safeSetAttributes({maximized:a})}),this.teleBoxManager.events.on("removed",a=>{a.forEach(o=>{n.emit("close",{appId:o.id})})}),this.teleBoxManager.events.on("intrinsic_move",w.debounce(a=>{n.emit("move",{appId:a.id,x:a.intrinsicX,y:a.intrinsicY})},50)),this.teleBoxManager.events.on("intrinsic_resize",w.debounce(a=>{n.emit("resize",{appId:a.id,width:a.intrinsicWidth,height:a.intrinsicHeight})},200)),this.teleBoxManager.events.on("focused",a=>{a&&(this.canOperate?n.emit("focus",{appId:a.id}):this.teleBoxManager.blurBox(a.id))}),this.teleBoxManager.events.on("blurred",a=>{a&&this.canOperate&&n.emit("blurred",{appId:a.id})}),this.teleBoxManager.events.on("z_index",a=>{this.context.updateAppState(a.id,ee.ZIndex,a.zIndex)}),this.teleBoxManager.events.on("box_status",a=>{this.canOperate&&this.context.setBoxStatus(a.id,a.boxStatus)}),this.teleBoxManager.events.on("last_not_minimized_box_status",a=>{this.canOperate&&this.context.setLastNotMinimizedBoxStatus(a.id,a.boxStatus)}),s.on("playgroundSizeChange",()=>this.updateManagerRect()),s.on("updateManagerRect",()=>this.updateManagerRect())}get mainView(){return this.context.getMainView()}get canOperate(){return this.context.canOperate()}get boxState(){return this.teleBoxManager.state}get maximized(){return this.teleBoxManager.maximized}get minimized(){return this.teleBoxManager.minimized}get darkMode(){return this.teleBoxManager.darkMode}get prefersColorScheme(){return this.teleBoxManager.prefersColorScheme}get boxSize(){return this.teleBoxManager.boxes.length}createBox(e){var c,l,u;if(!this.teleBoxManager)return;let{minwidth:t=rr,minheight:s=ar}=(c=e.app.config)!=null?c:{};const{width:r,height:n}=(l=e.app.config)!=null?l:{},a=((u=e.options)==null?void 0:u.title)||e.appId,o=this.teleBoxManager.containerRect;t>1&&(t=t/o.width),s>1&&(s=s/o.height);const h={title:a,minWidth:t,minHeight:s,width:r,height:n,id:e.appId,boxStatus:e.boxStatus,forceTop:e.forceTop,forceNormal:e.forceNormal,isDragContent:e.isDragContent};this.teleBoxManager.create(h,e.smartPosition),this.context.emitter.emit(`${e.appId}${R.WindowCreated}`)}setBoxInitState(e){const t=this.teleBoxManager.queryOne({id:e});t&&t.state===x.Maximized&&this.context.boxEmitter.emit("resize",{appId:e,x:t.x,y:t.y,width:t.intrinsicWidth,height:t.intrinsicHeight})}setBoxesStatus(e){const t=new Map(Object.entries(e!=null?e:{}));this.teleBoxManager.setBoxesStatus(t,!0),this.context.callbacks.emit("onBoxesStatusChange",t),this.context.emitter.emit("boxesStatusChange",t)}setLastNotMinimizedBoxesStatus(e){const t=new Map(Object.entries(e!=null?e:{}));this.teleBoxManager.setLastNotMinimizedBoxesStatus(t,!0),this.context.callbacks.emit("onLastNotMinimizedBoxesStatusChange",t),this.context.emitter.emit("lastNotMinimizedBoxesStatusChange",t)}setupBoxManager(e){const t=P.wrapper?P.wrapper:document.body,s=t.getBoundingClientRect(),r={root:t,containerRect:{x:0,y:0,width:s.width,height:s.height},fence:!1,prefersColorScheme:e==null?void 0:e.prefersColorScheme,useBoxesStatus:(e==null?void 0:e.useBoxesStatus)||!1},n=de(tt,P.extendClass),a=new n(r);this.teleBoxManager&&this.teleBoxManager.destroy(),this.teleBoxManager=a;const o=(e==null?void 0:e.collectorContainer)||P.wrapper;return o&&this.setCollectorContainer(o),a}setCollectorContainer(e){var r;const t=de(Le,P.extendClass),s=new t({styles:(r=this.createTeleBoxManagerConfig)==null?void 0:r.collectorStyles}).mount(e);this.teleBoxManager.setCollector(s)}getBox(e){return this.teleBoxManager.queryOne({id:e})}closeBox(e,t=!1){return this.teleBoxManager.remove(e,t)}boxIsFocus(e){const t=this.getBox(e);return t==null?void 0:t.focus}getFocusBox(){return this.teleBoxManager.query({focus:!0})[0]}getTopBox(){return this.teleBoxManager.topBox}updateBoxState(e){if(!e)return;const t=this.getBox(e.id);t&&(this.teleBoxManager.update(t.id,{x:e.x,y:e.y,width:e.width||.5,height:e.height||.5,zIndex:e.zIndex,boxStatus:e.boxStatus,lastNotMinimizedBoxStatus:e.lastNotMinimizedBoxStatus,forceTop:e.forceTop,forceNormal:e.forceNormal,isDragContent:e.isDragContent},!0),setTimeout(()=>{e.focus&&this.teleBoxManager.focusBox(t.id,!0),e.maximized!=null&&this.teleBoxManager.setMaximized(Boolean(e.maximized),!0),e.minimized!=null&&this.teleBoxManager.setMinimized(Boolean(e.minimized),!0)},50),e.boxStatus||this.context.callbacks.emit("boxStateChange",this.teleBoxManager.state))}updateManagerRect(){var t;const e=(t=this.mainView.divElement)==null?void 0:t.getBoundingClientRect();if(e&&e.width>0&&e.height>0){const s={x:0,y:0,width:e.width,height:e.height};this.teleBoxManager.setContainerRect(s),this.context.notifyContainerRectUpdate(this.teleBoxManager.containerRect)}}moveBox({appId:e,x:t,y:s}){this.teleBoxManager.update(e,{x:t,y:s},!0)}focusBox({appId:e},t=!0){this.teleBoxManager.focusBox(e,t)}resizeBox({appId:e,width:t,height:s,skipUpdate:r}){this.teleBoxManager.update(e,{width:t,height:s},r)}setBoxMinSize(e){this.teleBoxManager.update(e.appId,{minWidth:e.minWidth,minHeight:e.minHeight},!0)}setBoxTitle(e){this.teleBoxManager.update(e.appId,{title:e.title},!0)}blurAllBox(){this.teleBoxManager.blurAll()}updateAll(e){this.teleBoxManager.updateAll(e)}setMaximized(e,t=!0){e!==this.maximized&&this.teleBoxManager.setMaximized(e,t)}setMinimized(e,t=!0){this.teleBoxManager.setMinimized(e,t)}focusTopBox(){if(this.teleBoxManager.query().length>=1){const t=this.getTopBox();t&&this.focusBox({appId:t.id},!1)}}updateBox(e,t,s=!0){this.teleBoxManager.update(e,t,s)}setReadonly(e){this.teleBoxManager.setReadonly(e)}setPrefersColorScheme(e){this.teleBoxManager.setPrefersColorScheme(e)}setZIndex(e,t,s=!0){this.teleBoxManager.update(e,{zIndex:t},s)}destroy(){this.teleBoxManager.destroy()}}it.kind="BoxManager";function $i(i){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(i)?i:JSON.stringify(i)}function Se(i,e){if(i===void 0)return"undefined";if(i===null)return"null";const t=typeof i;if(t==="bigint")return`${i}n`;if(t==="symbol")return String(i);if(t==="function")return`[Function ${i.name||"anonymous"}]`;if(t!=="object")return t==="string"?JSON.stringify(i):String(i);const s=i;if(e!=null&&e.has(s))return"[Circular]";const r=e!=null?e:new WeakSet;r.add(s);try{return Array.isArray(i)?`[${Array.from(i,o=>Se(o,r)).join(",")}]`:i instanceof Date?JSON.stringify(i.toISOString()):i instanceof RegExp?String(i):`{${Object.keys(s).map(o=>{let h;try{h=s[o]}catch{return`${$i(o)}:[Threw]`}return`${$i(o)}:${Se(h,r)}`}).join(",")}}`}catch{return"[Unserializable]"}finally{r.delete(s)}}function Wa(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp)}const Zi=1500;function $a(i){if(i.length<=Zi)return i;const e="\u2026";return i.slice(0,Zi-e.length)+e}function Za(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!==e[t])return!1;return!0}const re=(...i)=>{P.debug&&console.log("[WindowManager]:",...i)};class We{constructor(e,t){this.name=e,this.debounceTime=t,this.pendingArgs=null,this.flushTimer=null}flush(){this.flushTimer=null;const e=this.pendingArgs;this.pendingArgs=null,e!==null&&console.log(`[window-manager][${this.name}]: ${e.join(", ")}`)}log(...e){const t=this.debounceTime;if(t!=null&&t>0){this.pendingArgs=e,this.flushTimer!=null&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>this.flush(),t);return}console.log(`[window-manager][${this.name}]: ${e.join(", ")}`)}destroy(){this.flushTimer!=null&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.pendingArgs=null}}class Fa{constructor(e,t,s){this.logger=e,this.name=t,this.debounceTime=s,this.pendingArgs=null,this.flushTimer=null,this.pendingShallowMerge=null,this.shallowMergeTimer=null,this.pendingUpdateSegments=null,this.updateMergeTimer=null}emitInfo(e){this.logger.info($a(e))}flush(){this.flushTimer=null;const e=this.pendingArgs;this.pendingArgs=null,e!==null&&this.emitInfo(`[WindowManager][${this.name}]: ${e.join(", ")}`)}flushShallowMerge(){this.shallowMergeTimer=null;const e=this.pendingShallowMerge;if(this.pendingShallowMerge=null,e===null)return;const t=e.kind==="record"?Se(e.data):Se(e.value);if(this.emitInfo(`[WindowManager][${this.name}]: ${e.label} ${t}`),e.kind==="record")for(const s of Object.keys(e.data))delete e.data[s]}log(...e){const t=this.debounceTime;if(t!=null&&t>0){this.pendingArgs=e,this.flushTimer!=null&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>this.flush(),t);return}this.emitInfo(`[WindowManager][${this.name}]: ${e.join(", ")}`)}logDebouncedShallowMerge(e,t){var a;const s=this.debounceTime,r=s!=null&&s>0,n=o=>{this.emitInfo(`[WindowManager][${this.name}]: ${e} ${o}`)};if(!r){n(Se(t));return}this.shallowMergeTimer!=null&&(clearTimeout(this.shallowMergeTimer),this.shallowMergeTimer=null),Wa(t)?((a=this.pendingShallowMerge)==null?void 0:a.kind)==="record"?this.pendingShallowMerge={kind:"record",label:e,data:{...this.pendingShallowMerge.data,...t}}:this.pendingShallowMerge={kind:"record",label:e,data:{...t}}:this.pendingShallowMerge={kind:"atom",label:e,value:t},this.shallowMergeTimer=setTimeout(()=>this.flushShallowMerge(),s)}flushUpdateAttributesMerge(){this.updateMergeTimer=null;const e=this.pendingUpdateSegments;if(this.pendingUpdateSegments=null,e===null||e.length===0)return;const t=e.map(s=>`${s.keys.join(", ")} ${Se(s.value)}`);this.emitInfo(`[WindowManager][${this.name}]: safeUpdateAttributes ${t.join(" | ")}`);for(const s of e)s.keys.length=0,s.value=void 0;e.length=0}logDebouncedUpdateAttributes(e,t){const s=this.debounceTime,r=s!=null&&s>0,n=[...e];if(!r){this.emitInfo(`[WindowManager][${this.name}]: safeUpdateAttributes ${n.join(", ")} ${Se(t)}`);return}if(this.updateMergeTimer!=null&&(clearTimeout(this.updateMergeTimer),this.updateMergeTimer=null),this.pendingUpdateSegments===null||this.pendingUpdateSegments.length===0)this.pendingUpdateSegments=[{keys:n,value:t}];else{const a=this.pendingUpdateSegments[this.pendingUpdateSegments.length-1];Za(a.keys,n)?a.value=t:this.pendingUpdateSegments.push({keys:n,value:t})}this.updateMergeTimer=setTimeout(()=>this.flushUpdateAttributesMerge(),s)}destroy(){this.flushTimer!=null&&(clearTimeout(this.flushTimer),this.flushTimer=null),this.shallowMergeTimer!=null&&(clearTimeout(this.shallowMergeTimer),this.shallowMergeTimer=null),this.updateMergeTimer!=null&&(clearTimeout(this.updateMergeTimer),this.updateMergeTimer=null),this.pendingArgs=null,this.pendingShallowMerge=null,this.pendingUpdateSegments=null}dispose(){this.destroy()}}const Ga=i=>{const e=document.createElement("div");e.className="netless-window-manager-playground";const t=document.createElement("div");t.className="netless-window-manager-sizer";const s=document.createElement("div");s.className="netless-window-manager-wrapper";const r=document.createElement("div");return r.className="netless-window-manager-main-view",e.appendChild(t),t.appendChild(s),s.appendChild(r),i.appendChild(e),P.wrapper=s,{playground:e,wrapper:s,sizer:t,mainViewElement:r}},Qa=()=>{if(Di(f.WhiteVersion)<Di(Bi))throw new os(Bi)},si=(i,e)=>{var n;const t=(i==null?void 0:i.state.roomMembers)||[];let s=-1,r;for(const a of t)((n=a.payload)==null?void 0:n.uid)===e&&s<a.memberId&&(s=a.memberId,r=a);return r},Ya=async i=>{let e=i.getInvisiblePlugin(P.kind);if(e)return e;let t;const s=new Promise(c=>{P._resolve=t=c});let r=!1;const n=Ha(i);!i.isWritable&&n&&(r=!0,await ts.default(async c=>{re(`switching to writable (x${c})`),await i.setWritable(!0)},{retries:10,maxTimeout:5e3})),i.isWritable?(re("creating InvisiblePlugin..."),i.createInvisiblePlugin(P,{}).catch(console.warn)):(n&&console.warn("[WindowManager]: failed to switch to writable"),console.warn("[WindowManager]: waiting for others to create the plugin..."));const a=setTimeout(()=>{console.warn("[WindowManager]: no one called createInvisiblePlugin() after 20 seconds")},2e4),o=setTimeout(()=>{throw new Error("[WindowManager]: no one called createInvisiblePlugin() after 60 seconds")},6e4),h=setInterval(()=>{e=i.getInvisiblePlugin(P.kind),e&&(clearTimeout(o),clearTimeout(a),clearInterval(h),t(e),r&&i.isWritable&&setTimeout(()=>i.setWritable(!1).catch(console.warn),500))},200);return s},Ha=i=>{try{const e=atob(i.roomToken.slice(12)),t=e.indexOf("&role=");return+e[t+6]<2}catch(e){return console.error(e),!1}};function Xe(){}function Vs(i){return i()}function Fi(){return Object.create(null)}function It(i){i.forEach(Vs)}function js(i){return typeof i=="function"}function Ja(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}let pt;function St(i,e){return pt||(pt=document.createElement("a")),pt.href=e,i===pt.href}function Xa(i){return Object.keys(i).length===0}function ue(i,e){i.appendChild(e)}function yt(i,e,t){i.insertBefore(e,t||null)}function st(i){i.parentNode&&i.parentNode.removeChild(i)}function me(i){return document.createElement(i)}function Mi(i){return document.createTextNode(i)}function ri(){return Mi(" ")}function U(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function Ka(i){return Array.from(i.childNodes)}function Rs(i,e){e=""+e,i.data!==e&&(i.data=e)}function G(i,e,t,s){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,s?"important":"")}let wi;function Ye(i){wi=i}const Ne=[],Gi=[];let Te=[];const Qi=[],qa=Promise.resolve();let ai=!1;function en(){ai||(ai=!0,qa.then(ks))}function ni(i){Te.push(i)}const $t=new Set;let Ae=0;function ks(){if(Ae!==0)return;const i=wi;do{try{for(;Ae<Ne.length;){const e=Ne[Ae];Ae++,Ye(e),tn(e.$$)}}catch(e){throw Ne.length=0,Ae=0,e}for(Ye(null),Ne.length=0,Ae=0;Gi.length;)Gi.pop()();for(let e=0;e<Te.length;e+=1){const t=Te[e];$t.has(t)||($t.add(t),t())}Te.length=0}while(Ne.length);for(;Qi.length;)Qi.pop()();ai=!1,$t.clear(),Ye(i)}function tn(i){if(i.fragment!==null){i.update(),It(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ni)}}function sn(i){const e=[],t=[];Te.forEach(s=>i.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),Te=e}const rn=new Set;function an(i,e){i&&i.i&&(rn.delete(i),i.i(e))}function nn(i,e,t,s){const{fragment:r,after_update:n}=i.$$;r&&r.m(e,t),s||ni(()=>{const a=i.$$.on_mount.map(Vs).filter(js);i.$$.on_destroy?i.$$.on_destroy.push(...a):It(a),i.$$.on_mount=[]}),n.forEach(ni)}function on(i,e){const t=i.$$;t.fragment!==null&&(sn(t.after_update),It(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function hn(i,e){i.$$.dirty[0]===-1&&(Ne.push(i),en(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function cn(i,e,t,s,r,n,a,o=[-1]){const h=wi;Ye(i);const c=i.$$={fragment:null,ctx:[],props:n,update:Xe,not_equal:r,bound:Fi(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(h?h.$$.context:[])),callbacks:Fi(),dirty:o,skip_bound:!1,root:e.target||h.$$.root};a&&a(c.root);let l=!1;if(c.ctx=t?t(i,e.props||{},(u,d,...m)=>{const g=m.length?m[0]:d;return c.ctx&&r(c.ctx[u],c.ctx[u]=g)&&(!c.skip_bound&&c.bound[u]&&c.bound[u](g),l&&hn(i,u)),d}):[],c.update(),l=!0,It(c.before_update),c.fragment=s?s(c.ctx):!1,e.target){if(e.hydrate){const u=Ka(e.target);c.fragment&&c.fragment.l(u),u.forEach(st)}else c.fragment&&c.fragment.c();e.intro&&an(i.$$.fragment),nn(i,e.target,e.anchor,e.customElement),ks()}Ye(h)}class ln{$destroy(){on(this,1),this.$destroy=Xe}$on(e,t){if(!js(t))return Xe;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Xa(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function Yi(i){let e,t,s,r,n,a,o,h=i[18]&&Hi(i),c=i[19]&&Ji(i);return{c(){e=me("div"),t=me("div"),h&&h.c(),s=ri(),r=me("span"),n=Mi(i[1]),a=ri(),c&&c.c(),G(r,"overflow","hidden"),G(r,"white-space","nowrap"),G(r,"text-overflow","ellipsis"),G(r,"max-width","80px"),U(t,"class",i[9]),G(t,"background-color",i[3]),G(t,"color",i[10]),G(t,"opacity",i[12]),U(e,"class",o="netless-window-manager-cursor-name "+i[16]+" "+i[15])},m(l,u){yt(l,e,u),ue(e,t),h&&h.m(t,null),ue(t,s),ue(t,r),ue(r,n),ue(t,a),c&&c.m(t,null)},p(l,u){l[18]?h?h.p(l,u):(h=Hi(l),h.c(),h.m(t,s)):h&&(h.d(1),h=null),u&2&&Rs(n,l[1]),l[19]?c?c.p(l,u):(c=Ji(l),c.c(),c.m(t,null)):c&&(c.d(1),c=null),u&512&&U(t,"class",l[9]),u&8&&G(t,"background-color",l[3]),u&1024&&G(t,"color",l[10]),u&4096&&G(t,"opacity",l[12]),u&98304&&o!==(o="netless-window-manager-cursor-name "+l[16]+" "+l[15])&&U(e,"class",o)},d(l){l&&st(e),h&&h.d(),c&&c.d()}}}function Hi(i){let e,t;return{c(){e=me("img"),U(e,"class","netless-window-manager-cursor-selector-avatar"),U(e,"style",i[20]()),St(e.src,t=i[8])||U(e,"src",t),U(e,"alt","avatar")},m(s,r){yt(s,e,r)},p(s,r){r&256&&!St(e.src,t=s[8])&&U(e,"src",t)},d(s){s&&st(e)}}}function Ji(i){let e,t;return{c(){e=me("span"),t=Mi(i[2]),U(e,"class","netless-window-manager-cursor-tag-name"),G(e,"background-color",i[11])},m(s,r){yt(s,e,r),ue(e,t)},p(s,r){r&4&&Rs(t,s[2]),r&2048&&G(e,"background-color",s[11])},d(s){s&&st(e)}}}function un(i){let e,t,s,r,n,a,o,h=!i[14]&&Yi(i);return{c(){e=me("div"),h&&h.c(),t=ri(),s=me("div"),r=me("img"),U(r,"class",n="netless-window-manager-cursor-"+i[4]+"-image "+i[15]),St(r.src,a=i[7])||U(r,"src",a),U(r,"alt",i[4]),U(s,"class","cursor-image-wrapper"),U(e,"class",o="netless-window-manager-cursor-mid"+(i[13]?" netless-window-manager-cursor-custom":"")),G(e,"transform","translateX("+i[5]+"px) translateY("+i[6]+"px)"),G(e,"display",i[17]),U(e,"data-cursor-uid",i[0])},m(c,l){yt(c,e,l),h&&h.m(e,null),ue(e,t),ue(e,s),ue(s,r)},p(c,[l]){c[14]?h&&(h.d(1),h=null):h?h.p(c,l):(h=Yi(c),h.c(),h.m(e,t)),l&32784&&n!==(n="netless-window-manager-cursor-"+c[4]+"-image "+c[15])&&U(r,"class",n),l&128&&!St(r.src,a=c[7])&&U(r,"src",a),l&16&&U(r,"alt",c[4]),l&8192&&o!==(o="netless-window-manager-cursor-mid"+(c[13]?" netless-window-manager-cursor-custom":""))&&U(e,"class",o),l&96&&G(e,"transform","translateX("+c[5]+"px) translateY("+c[6]+"px)"),l&131072&&G(e,"display",c[17]),l&1&&U(e,"data-cursor-uid",c[0])},i:Xe,o:Xe,d(c){c&&st(e),h&&h.d()}}}function dn(i,e,t){let s,r,n,a,o,h,c,l,{uid:u}=e,{cursorName:d}=e,{tagName:m}=e,{backgroundColor:g}=e,{appliance:b}=e,{x:M}=e,{y:N}=e,{src:z}=e,{visible:v}=e,{avatar:Z}=e,{theme:_}=e,{color:W}=e,{cursorTagBackgroundColor:ie}=e,{opacity:Ie}=e,{pencilEraserSize:ge}=e,{custom:Ve}=e;const S=()=>Object.entries({width:(s?19:28)+"px",height:(s?19:28)+"px",position:s?"initial":"absolute","border-color":s?"white":g,"margin-right":(s?4:0)+"px"}).map(([p,B])=>`${p}: ${B}`).join(";");return i.$$set=p=>{"uid"in p&&t(0,u=p.uid),"cursorName"in p&&t(1,d=p.cursorName),"tagName"in p&&t(2,m=p.tagName),"backgroundColor"in p&&t(3,g=p.backgroundColor),"appliance"in p&&t(4,b=p.appliance),"x"in p&&t(5,M=p.x),"y"in p&&t(6,N=p.y),"src"in p&&t(7,z=p.src),"visible"in p&&t(21,v=p.visible),"avatar"in p&&t(8,Z=p.avatar),"theme"in p&&t(9,_=p.theme),"color"in p&&t(10,W=p.color),"cursorTagBackgroundColor"in p&&t(11,ie=p.cursorTagBackgroundColor),"opacity"in p&&t(12,Ie=p.opacity),"pencilEraserSize"in p&&t(22,ge=p.pencilEraserSize),"custom"in p&&t(13,Ve=p.custom)},i.$$.update=()=>{i.$$.dirty&2&&(s=!w.isEmpty(d)),i.$$.dirty&4&&t(19,r=!w.isEmpty(m)),i.$$.dirty&256&&t(18,n=!w.isEmpty(Z)),i.$$.dirty&2097152&&t(17,a=v?"":"none"),i.$$.dirty&16&&t(14,o=b===f.ApplianceNames.laserPointer),i.$$.dirty&16400&&t(23,h=o||b===f.ApplianceNames.pencilEraser),i.$$.dirty&8388608&&t(16,c=h?"netless-window-manager-laserPointer-pencilEraser-offset":""),i.$$.dirty&4194304&&t(15,l=ge===3?"netless-window-manager-pencilEraser-3-offset":"")},[u,d,m,g,b,M,N,z,Z,_,W,ie,Ie,Ve,o,l,c,a,n,r,S,v,ge,h]}class gn extends ln{constructor(e){super(),cn(this,e,dn,un,Ja,{uid:0,cursorName:1,tagName:2,backgroundColor:3,appliance:4,x:5,y:6,src:7,visible:21,avatar:8,theme:9,color:10,cursorTagBackgroundColor:11,opacity:12,pencilEraserSize:22,custom:13})}}const Us="data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle cx='12' cy='12' r='2.5' stroke='%23000' stroke-linejoin='square'/%3E%3Ccircle cx='12' cy='12' r='3.5' stroke='%23FFF'/%3E%3C/g%3E%3C/svg%3E";function _s(i){return`data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Ccircle cx='12' cy='12' r='2.5' stroke='%23${i}' stroke-linejoin='square'/%3E%3Ccircle cx='12' cy='12' r='3.5' stroke='%23${i}'/%3E%3C/g%3E%3C/svg%3E`}function ze(i){return`data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg' fill='none'%3E%3Cpath d='M5 12H19' stroke='%23${i}' stroke-linejoin='round'/%3E%3Cpath d='M12 5V19' stroke='%23${i}' stroke-linejoin='round'/%3E%3C/svg%3E`}function xe(i){return`url("${i}") 12 12, auto`}function pn(i){let e="";for(const t in i)e+=`.netless-whiteboard.${t} {cursor: ${i[t]}}
16
+ `;return e}const mt=document.createElement("style");function mn(i){const[e,t,s]=i.strokeColor,r=((1<<24)+(e<<16)+(t<<8)+s).toString(16).slice(1);return mt.textContent=pn({"cursor-pencil":xe(_s(r)),"cursor-eraser":xe(Us),"cursor-rectangle":xe(ze(r)),"cursor-ellipse":xe(ze(r)),"cursor-straight":xe(ze(r)),"cursor-arrow":xe(ze(r)),"cursor-shape":xe(ze(r))}),document.head.appendChild(mt),()=>{mt.parentNode!=null&&document.head.removeChild(mt)}}const fn=new Set([f.ApplianceNames.rectangle,f.ApplianceNames.ellipse,f.ApplianceNames.straight,f.ApplianceNames.arrow,f.ApplianceNames.shape]);function Xi(i,e){if(i===f.ApplianceNames.pencil)return _s(e);if(i===f.ApplianceNames.eraser)return Us;if(fn.has(i))return ze(e)}class Mn{constructor(e,t,s,r){this.manager=e,this.memberId=t,this.cursorManager=s,this.wrapper=r,this.style="default",this.move=n=>{var a;if(n.type==="main"){const o=this.cursorManager.wrapperRect;this.component&&o&&(this.autoHidden(),this.moveCursor(n,o,this.manager.mainView))}else{const o=this.cursorManager.focusView,h=(a=o==null?void 0:o.divElement)==null?void 0:a.getBoundingClientRect(),c=o==null?void 0:o.camera;o&&h&&c&&this.component&&(this.autoHidden(),this.moveCursor(n,h,o))}},this.setStyle=n=>{this.style=n,this.component&&this.component.$set({src:this.getIcon(),custom:this.isCustomIcon()})},this.leave=()=>{this.hide()},this.updateMember(),this.createCursor(),this.autoHidden(),this.setStyle(s.style)}moveCursor(e,t,s){var h,c;const{x:r,y:n,type:a}=e,o=s==null?void 0:s.screen.convertPointToScreen(r,n);if(o){let l=o.x-2,u=o.y-18;if(this.isCustomIcon()&&(l-=11,u+=4),a==="app"){const d=this.cursorManager.wrapperRect;d&&(l=l+t.x-d.x,u=u+t.y-d.y)}o.x<0||o.x>t.width||o.y<0||o.y>t.height?(h=this.component)==null||h.$set({visible:!1,x:l,y:u}):(c=this.component)==null||c.$set({visible:!0,x:l,y:u})}}get memberApplianceName(){var e,t;return(t=(e=this.member)==null?void 0:e.memberState)==null?void 0:t.currentApplianceName}get memberColor(){var t,s;return`rgb(${(s=(t=this.member)==null?void 0:t.memberState)==null?void 0:s.strokeColor.join(",")})`}get memberColorHex(){var r,n;const[e,t,s]=((n=(r=this.member)==null?void 0:r.memberState)==null?void 0:n.strokeColor)||[236,52,85];return((1<<24)+(e<<16)+(t<<8)+s).toString(16).slice(1)}get payload(){var e;return(e=this.member)==null?void 0:e.payload}get memberCursorName(){var e,t;return((e=this.payload)==null?void 0:e.nickName)||((t=this.payload)==null?void 0:t.cursorName)||this.memberId}get memberTheme(){var e;return(e=this.payload)!=null&&e.theme?"netless-window-manager-cursor-inner-mellow":"netless-window-manager-cursor-inner"}get memberCursorTextColor(){var e;return((e=this.payload)==null?void 0:e.cursorTextColor)||"#FFFFFF"}get memberCursorTagBackgroundColor(){var e;return((e=this.payload)==null?void 0:e.cursorTagBackgroundColor)||this.memberColor}get memberAvatar(){var e;return(e=this.payload)==null?void 0:e.avatar}get memberOpacity(){return!this.memberCursorName&&!this.memberAvatar?0:1}get memberTagName(){var e;return(e=this.payload)==null?void 0:e.cursorTagName}autoHidden(){this.timer&&clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.hide()},1e3*10)}async createCursor(){this.member&&this.wrapper&&(this.component=new gn({target:this.wrapper,props:this.initProps()}))}initProps(){var e;return{uid:this.memberId,x:0,y:0,appliance:this.memberApplianceName,avatar:this.memberAvatar,src:this.getIcon(),custom:this.isCustomIcon(),visible:!1,backgroundColor:this.memberColor,cursorName:this.memberCursorName,theme:this.memberTheme,color:this.memberCursorTextColor,cursorTagBackgroundColor:this.memberCursorTagBackgroundColor,opacity:this.memberOpacity,tagName:this.memberTagName,pencilEraserSize:(e=this.member)==null?void 0:e.memberState.pencilEraserSize}}getIcon(){var h;if(!this.member)return;const{memberApplianceName:e,memberColorHex:t}=this,{userApplianceIcons:s,applianceIcons:r}=this.cursorManager;let n=this.memberApplianceName;n===f.ApplianceNames.pencilEraser&&(n=`${n}${((h=this.member)==null?void 0:h.memberState.pencilEraserSize)||1}`);const a=n&&s[n];if(a)return a;if(this.style==="custom"&&e){const c=Xi(e,t);if(c)return c}return r[n||f.ApplianceNames.shape]||r[f.ApplianceNames.shape]}isCustomIcon(){var a;if(!this.member)return!1;const{memberApplianceName:e,memberColorHex:t}=this,{userApplianceIcons:s}=this.cursorManager;let r=this.memberApplianceName;return r===f.ApplianceNames.pencilEraser&&(r=`${r}${((a=this.member)==null?void 0:a.memberState.pencilEraserSize)||1}`),r&&s[r]?!1:!!(this.style==="custom"&&e&&Xi(e,t))}updateMember(){return this.member=si(this.manager.room,this.memberId),this.updateComponent(),this.member}updateComponent(){var e;(e=this.component)==null||e.$set(w.omit(this.initProps(),["x","y"]))}destroy(){this.component&&this.component.$destroy(),this.cursorManager.cursorInstances.delete(this.memberId),this.timer&&clearTimeout(this.timer)}hide(){this.component&&(this.component.$set({visible:!1}),this.destroy())}}var wn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9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[f.ApplianceNames.eraser]:Sn,[f.ApplianceNames.shape]:bn,[f.ApplianceNames.text]:vn,[f.ApplianceNames.laserPointer]:In,pencilEraser1:yn,pencilEraser2:Cn,pencilEraser3:An},Ki="local-cursor";class rt{constructor(e,t,s,r){var o;this.manager=e,this.enableCursor=t,this.cursorInstances=new Map,this.userApplianceIcons={},this.sideEffectManager=new Ke,this.store=this.manager.store,this.leaveFlag=!0,this._style="default",this.onCursorMove=h=>{const c=this.initCursorInstance(h.uid);if(h.state===Yt.Leave)c.leave();else{const l=c.updateMember();this.canMoveCursor(l)&&c.move(h.position)}},this.initCursorInstance=h=>{let c=this.cursorInstances.get(h);return c||(c=new Mn(this.manager,h,this,P.wrapper),this.cursorInstances.set(h,c)),c},this.mouseMoveListener_=(h,c)=>{const l=this.getType(h);this.updateCursor(l,h.clientX,h.clientY),c&&this.showPencilEraserIfNeeded(l,h.clientX,h.clientY)},this.mouseMoveTimer=0,this.mouseMoveListener=h=>{const c=h.pointerType==="touch";if(c&&!h.isPrimary)return;const l=Date.now();if(l-this.mouseMoveTimer>48){if(this.mouseMoveTimer=l,P.supportAppliancePlugin&&f.isRoom(P.displayer)&&P.displayer.disableDeviceInputs){this.leaveFlag&&(this.manager.dispatchInternalEvent(R.CursorMove,{uid:this.manager.uid,state:Yt.Leave}),this.leaveFlag=!1);return}this.mouseMoveListener_(h,c),this.leaveFlag=!0}},this.mouseLeaveListener=()=>{this.hideCursor(this.manager.uid)},this.getPoint=(h,c,l)=>{var d;const u=(d=h==null?void 0:h.divElement)==null?void 0:d.getBoundingClientRect();if(u)return h==null?void 0:h.convertToPointInWorld({x:c-u.x,y:l-u.y})},this.getType=h=>{var u;const c=h.target,l=this.manager.focusApp;switch(c.parentElement){case this.mainViewElement:return{type:"main"};case((u=l==null?void 0:l.view)==null?void 0:u.divElement):return{type:"app"};default:return{type:"main"}}},this.roomMembers=(o=this.manager.room)==null?void 0:o.state.roomMembers;const n=P.wrapper;n&&this.setupWrapper(n),this.sideEffectManager.add(()=>A.on("cursorMove",this.onCursorMove)),this.sideEffectManager.add(()=>A.on("playgroundSizeChange",()=>this.updateContainerRect()));const a=this.manager.room;a&&this.sideEffectManager.add(()=>{const h=c=>{this.style==="custom"&&c.memberState&&this.enableCustomCursor()};return a.callbacks.on("onRoomStateChanged",h),()=>a.callbacks.off("onRoomStateChanged",h)}),r&&(this.userApplianceIcons=r),this.style=(s==null?void 0:s.style)||"default"}get applianceIcons(){return{...Bn,...this.userApplianceIcons}}get style(){return this._style}set style(e){this._style!==e&&(this._style=e,this.cursorInstances.forEach(t=>{t.setStyle(e)}),e==="custom"?this.enableCustomCursor():this.sideEffectManager.flush(Ki))}enableCustomCursor(){this.sideEffectManager.add(()=>mn(this.manager.getMemberState()),Ki)}canMoveCursor(e){const t=(e==null?void 0:e.memberState.currentApplianceName)===f.ApplianceNames.laserPointer;return this.enableCursor||t}setupWrapper(e){this.sideEffectManager.add(()=>(e.addEventListener("pointerenter",this.mouseMoveListener),e.addEventListener("pointermove",this.mouseMoveListener),e.addEventListener("pointerleave",this.mouseLeaveListener),()=>{e.removeEventListener("pointerenter",this.mouseMoveListener),e.removeEventListener("pointermove",this.mouseMoveListener),e.removeEventListener("pointerleave",this.mouseLeaveListener)})),this.wrapperRect=e.getBoundingClientRect()}setMainViewDivElement(e){this.mainViewElement=e}get boxState(){return this.store.getBoxState()}get focusView(){var e;return(e=this.manager.focusApp)==null?void 0:e.view}showPencilEraserIfNeeded(e,t,s){const r=si(this.manager.room,this.manager.uid),n=(r==null?void 0:r.memberState.currentApplianceName)===f.ApplianceNames.pencilEraser;if(this.wrapperRect&&this.manager.canOperate&&this.canMoveCursor(r)&&n){const a=e.type==="main"?this.manager.mainView:this.focusView,o=this.getPoint(a,t,s);o&&this.onCursorMove({uid:this.manager.uid,position:{x:o.x,y:o.y,type:e.type}})}}updateCursor(e,t,s){const r=si(this.manager.room,this.manager.uid);if(this.wrapperRect&&this.manager.canOperate&&this.canMoveCursor(r)){const n=e.type==="main"?this.manager.mainView:this.focusView,a=this.getPoint(n,t,s);a&&this.manager.dispatchInternalEvent(R.CursorMove,{uid:this.manager.uid,position:{x:a.x,y:a.y,type:e.type}})}}updateContainerRect(){var e,t;this.containerRect=(e=P.container)==null?void 0:e.getBoundingClientRect(),this.wrapperRect=(t=P.wrapper)==null?void 0:t.getBoundingClientRect()}deleteCursor(e){this.store.cleanCursor(e);const t=this.cursorInstances.get(e);t&&t.destroy()}hideCursor(e){const t=this.cursorInstances.get(e);t&&t.hide()}destroy(){this.sideEffectManager.flushAll(),this.cursorInstances.size&&(this.cursorInstances.forEach(e=>{e.destroy()}),this.cursorInstances.clear())}}rt.kind="CursorManager";function de(i,e){if(i.kind&&e&&Object.keys(e).includes(i.kind))switch(i.kind){case"AppManager":return(e==null?void 0:e.AppManager)||ot;case"BoxManager":return(e==null?void 0:e.BoxManager)||it;case"AttributesDelegate":return(e==null?void 0:e.AttributesDelegate)||at;case"CursorManager":return(e==null?void 0:e.CursorManager)||rt;case"AppProxy":return(e==null?void 0:e.AppProxy)||nt;case"AppContext":return(e==null?void 0:e.AppContext)||qe;case"TeleBoxManager":return(e==null?void 0:e.TeleBoxManager)||tt;case"TeleBoxCollector":return(e==null?void 0:e.TeleBoxCollector)||Le;default:return i}return i}var Q=(i=>(i.Apps="apps",i.Focus="focus",i.State="state",i.BoxState="boxState",i.MainViewCamera="mainViewCamera",i.MainViewSize="mainViewSize",i.Broadcaster="broadcaster",i.Cursors="cursors",i.Position="position",i.CursorState="cursorState",i.FullPath="fullPath",i.Registered="registered",i.IframeBridge="iframeBridge",i.BoxesStatus="boxesStatus",i.LastNotMinimizedBoxesStatus="lastNotMinimizedBoxesStatus",i))(Q||{});class at{constructor(e){this.context=e,this.setAppFocus=(t,s)=>{s?this.context.safeSetAttributes({focus:t}):this.context.safeSetAttributes({focus:void 0})}}setContext(e){this.context=e}get attributes(){return this.context.getAttributes()}apps(){return w.get(this.attributes,["apps"])}get focus(){return w.get(this.attributes,["focus"])}getAppAttributes(e){return w.get(this.apps(),[e])}getAppState(e){return w.get(this.apps(),[e,"state"])}getMaximized(){return w.get(this.attributes,["maximized"])}getMinimized(){return w.get(this.attributes,["minimized"])}getBoxesStatus(){return w.get(this.attributes,["boxesStatus"])}getBoxStatus(e){return w.get(this.attributes,["boxesStatus",e])}setBoxStatus(e,t){this.attributes.boxesStatus||this.context.safeSetAttributes({boxesStatus:{}}),this.getBoxStatus(e)!==t&&this.context.safeUpdateAttributes(["boxesStatus",e],t)}getLastNotMinimizedBoxesStatus(){return w.get(this.attributes,["lastNotMinimizedBoxesStatus"])}getLastNotMinimizedBoxStatus(e){return w.get(this.attributes,["lastNotMinimizedBoxesStatus",e])}setLastNotMinimizedBoxStatus(e,t){this.attributes.lastNotMinimizedBoxesStatus||this.context.safeSetAttributes({lastNotMinimizedBoxesStatus:{}}),this.getLastNotMinimizedBoxStatus(e)!==t&&this.context.safeUpdateAttributes(["lastNotMinimizedBoxesStatus",e],t)}setupAppAttributes(e,t,s){this.attributes.apps||this.context.safeSetAttributes({apps:{}});const n=["scenePath","title"];s||n.push("scenes");const a=w.pick(e.options,n),o={kind:e.kind,options:a,isDynamicPPT:s,forceTop:e.forceTop,forceNormal:e.forceNormal,isDragContent:e.isDragContent};typeof e.src=="string"&&(o.src=e.src),o.createdAt=Date.now(),this.context.safeUpdateAttributes(["apps",t],o),this.context.safeUpdateAttributes(["apps",t,"state"],{[ee.Size]:{},[ee.Position]:{},[ee.SceneIndex]:0})}updateAppState(e,t,s){w.get(this.attributes,["apps",e,"state"])&&this.context.safeUpdateAttributes(["apps",e,"state",t],s)}cleanAppAttributes(e){this.context.safeUpdateAttributes(["apps",e],void 0),this.context.safeSetAttributes({[e]:void 0}),this.attributes.focus===e&&this.cleanFocus()}cleanFocus(){this.context.safeSetAttributes({focus:void 0})}getAppSceneIndex(e){var t;return(t=this.getAppState(e))==null?void 0:t[ee.SceneIndex]}getAppScenePath(e){var t,s;return(s=(t=this.getAppAttributes(e))==null?void 0:t.options)==null?void 0:s.scenePath}getMainViewScenePath(){return this.attributes._mainScenePath}getMainViewSceneIndex(){return this.attributes._mainSceneIndex}getBoxState(){return this.attributes.boxState}setMainViewScenePath(e){this.context.safeSetAttributes({_mainScenePath:e})}setMainViewSceneIndex(e){this.context.safeSetAttributes({_mainSceneIndex:e})}getMainViewCamera(){return w.get(this.attributes,["mainViewCamera"])}getMainViewSize(){return w.get(this.attributes,["mainViewSize"])}setMainViewCamera(e){this.context.safeSetAttributes({mainViewCamera:{...e}})}setMainViewSize(e){e.width===0||e.height===0||this.context.safeSetAttributes({mainViewSize:{...e}})}setMainViewCameraAndSize(e,t){t.width===0||t.height===0||this.context.safeSetAttributes({mainViewCamera:{...e},mainViewSize:{...t}})}updateCursor(e,t){w.get(this.attributes,["cursors"])||this.context.safeUpdateAttributes(["cursors"],{}),w.get(this.attributes,["cursors",e])||this.context.safeUpdateAttributes(["cursors",e],{}),this.context.safeUpdateAttributes(["cursors",e,"position"],t)}updateCursorState(e,t){w.get(this.attributes,["cursors",e])||this.context.safeUpdateAttributes(["cursors",e],{}),this.context.safeUpdateAttributes(["cursors",e,"cursorState"],t)}getCursorState(e){return w.get(this.attributes,["cursors",e,"cursorState"])}cleanCursor(e){this.context.safeUpdateAttributes(["cursors",e],void 0)}setMainViewFocusPath(e){const t=this.getMainViewScenePath();t&&be(e,t)}getIframeBridge(){return w.get(this.attributes,["iframeBridge"])}setIframeBridge(e){if(w.isObject(e)){const t=this.getIframeBridge();for(const s in e){const r=e[s];t[s]!==r&&this.context.safeUpdateAttributes(["iframeBridge",s],r)}}}}at.kind="AttributesDelegate";const Nn=(i,e={getAttributes:()=>{throw new Error("getAttributes not implemented")},safeSetAttributes:()=>{throw new Error("safeSetAttributes not implemented")},safeUpdateAttributes:()=>{throw new Error("safeUpdateAttributes not implemented")}})=>{const t=de(at,i);return new t(e)},xi=(i,e)=>{let t=0;const s=e.length-1;return i===e.index?i===s?t=i-1:t=e.index+1:t=e.index,t},ce=new ve.default,Os=class{constructor(i,e,t,s){var r;this.params=i,this.manager=e,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.store=this.manager.store,this.status="normal",this.getAppInitState=n=>{var Z,_,W,ie;const a=this.store.getAppState(n);if(!a)return;const o=a==null?void 0:a[ee.Position],h=this.store.focus,c=a==null?void 0:a[ee.Size],l=a==null?void 0:a[ee.SceneIndex],u=(Z=this.attributes)==null?void 0:Z.maximized,d=(_=this.attributes)==null?void 0:_.minimized,m=(W=this.store.getBoxStatus(n))!=null?W:void 0,g=(ie=this.store.getLastNotMinimizedBoxStatus(n))!=null?ie:void 0,{forceTop:b,forceNormal:M,isDragContent:N}=this.store.getAppAttributes(n),z=a==null?void 0:a.zIndex;let v={maximized:u,minimized:d,zIndex:z};return o&&(v={...v,id:n,x:o.x,y:o.y}),h===n&&(v={...v,focus:!0}),c&&(v={...v,width:c.width,height:c.height}),l&&(v={...v,sceneIndex:l}),m&&(v={...v,boxStatus:m}),g&&(v={...v,lastNotMinimizedBoxStatus:g}),b&&(v={...v,forceTop:b}),M&&(v={...v,forceNormal:M}),N&&(v={...v,isDragContent:N}),v},this.appAttributesUpdateListener=n=>{this.manager.refresher.add(n,()=>f.autorun(()=>{const a=this.manager.attributes[n];a&&this.appEmitter.emit("attributesUpdate",a)})),this.manager.refresher.add(this.stateKey,()=>f.autorun(()=>{var o,h,c,l;const a=(o=this.appAttributes)==null?void 0:o.state;(a==null?void 0:a.zIndex)>0&&a.zIndex!==((h=this.box)==null?void 0:h.zIndex)&&((c=this.boxManager)==null||c.setZIndex(n,a.zIndex),(l=this.boxManager)==null||l.focusBox({appId:n}))})),this.manager.refresher.add(`${n}-fullPath`,()=>f.autorun(()=>{var o;const a=(o=this.appAttributes)==null?void 0:o.fullPath;this.setFocusScenePathHandler(a),this._prevFullPath!==a&&(this.notifyPageStateChange(),this._prevFullPath=a)}))},this.setFocusScenePathHandler=w.debounce(n=>{var a;this.view&&n&&n!==((a=this.view)==null?void 0:a.focusScenePath)&&(be(this.view,n),L.emit("onAppScenePathChange",{appId:this.id,view:this.view}))},50),this.notifyPageStateChange=w.debounce(()=>{this.appEmitter.emit("pageStateChange",this.pageState)},50),this.notifyBoxStatusChange=n=>{this.appEmitter.emit("boxStatusChange",{appId:this.id,status:n})},this.kind=i.kind,this.id=t,this.stateKey=`${this.id}_state`,this.appProxies.set(this.id,this),this.appEmitter=new ve.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=s,this.initScenes(),(r=this.params.options)!=null&&r.scenePath&&this.createView(),this._pageState=new Er({displayer:this.manager.displayer,scenePath:this.scenePath,view:this.view,notifyPageStateChange:this.notifyPageStateChange})}initScenes(){var e;const i=this.params.options;i&&(this.scenePath=i.scenePath,((e=this.appAttributes)==null?void 0:e.isDynamicPPT)&&this.scenePath?this.scenes=Pe(this.manager.displayer)[this.scenePath]:this.scenes=i.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get viewIndex(){var i;return(i=this.view)==null?void 0:i.focusSceneIndex}get isWritable(){var i;return this.manager.canOperate&&!((i=this.box)!=null&&i.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}get Logger(){return this.manager.windowManger.Logger}getFullScenePath(){if(this.scenePath)return w.get(this.appAttributes,[Q.FullPath])||this.getFullScenePathFromScenes()}getFullScenePathFromScenes(){const i=w.get(this.appAttributes,["state","SceneIndex"],0),e=Ir(this.manager.room,this.scenePath,i);return e&&this.setFullPath(e),e}setFullPath(i){this.manager.safeUpdateAttributes(["apps",this.id,Q.FullPath],i)}async baseInsertApp(i=!1,e=x.Normal){var n;const t=this.params;if(!t.kind)throw this.Logger&&this.Logger.error("[WindowManager]: kind require"),new Error("[WindowManager]: kind require");const s=await((n=J.appClasses.get(t.kind))==null?void 0:n()),r=J.registered.get(t.kind);if(s)await this.setupApp(this.id,i,s,t.options,r==null?void 0:r.appOptions,this.manager.useBoxesStatus?e:void 0,t.forceTop,t.forceNormal,t.isDragContent);else throw this.Logger&&this.Logger.error(`[WindowManager]: app load failed ${t.kind} ${t.src}`),new Error(`[WindowManager]: app load failed ${t.kind} ${t.src}`);return A.emit("updateManagerRect"),{appId:this.id,app:s}}get box(){var i;return(i=this.boxManager)==null?void 0:i.getBox(this.id)}async setupApp(i,e,t,s,r,n,a,o,h){var u;if(re("setupApp",i,t,s,n,a,o,h),!this.boxManager)throw new us;const c=de(qe,P.extendClass),l=new c(this.manager,this.boxManager,i,this,r);this.appContext=l;try{A.once(`${i}${R.WindowCreated}`).then(async()=>{var g;let d;e||(d=this.getAppInitState(i),(g=this.boxManager)==null||g.updateBoxState(d)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(i),this.setViewFocusScenePath();let m;this.manager.isReplay&&(m=this.manager.mainView.scenePath),setTimeout(async()=>{this.Logger&&this.Logger.info(`[WindowManager]: setup app ${this.kind}, appId: ${i}`);const b=await t.setup(l);this.appResult=b,J.notifyApp(this.kind,"created",{appId:i,result:b}),this.afterSetupApp(d),this.fixMobileSize(),m&&this.manager.mainViewProxy.setFocusScenePath(m),L.emit("onAppSetup",i)},rs)}),(u=this.boxManager)==null||u.createBox({appId:i,app:t,options:s,canOperate:this.manager.canOperate,smartPosition:this.isAddApp,boxStatus:n,forceTop:a,forceNormal:o,isDragContent:h}),this.isAddApp&&this.box&&(n&&this.store.setBoxStatus(i,n),this.store.updateAppState(i,ee.ZIndex,this.box.zIndex),this.store.updateAppState(i,ee.Size,{width:this.box.intrinsicWidth,height:this.box.intrinsicHeight}),this.boxManager.focusBox({appId:i},!1))}catch(d){throw this.Logger&&this.Logger.error(`[WindowManager]: app setup error: ${d.message}`),new Error(`[WindowManager]: app setup error: ${d.message}`)}}fixMobileSize(){var e,t;const i=(e=this.boxManager)==null?void 0:e.getBox(this.id);i&&((t=this.boxManager)==null||t.resizeBox({appId:this.id,width:i.intrinsicWidth+.001,height:i.intrinsicHeight+.001,skipUpdate:!0}))}afterSetupApp(i){var e;i&&(!(i!=null&&i.x)||!i.y)&&((e=this.boxManager)==null||e.setBoxInitState(this.id))}async onSeek(i){var t;this.appEmitter.emit("seek",i).catch(s=>{console.log(`[WindowManager]: emit seek error: ${s.message}`)});const e=this.getAppInitState(this.id);(t=this.boxManager)==null||t.updateBoxState(e)}async onReconnected(){var n;if(!Boolean(this.manager.attributes.apps[this.id])){await this.destroy(!0,!1,!0);return}this.appEmitter.emit("reconnected",void 0);const e=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const t=this.params,s=de(Os,P.extendClass);await new s(t,this.manager,this.id,this.isAddApp).baseInsertApp(!0,e==null?void 0:e.boxStatus),(n=this.boxManager)==null||n.updateBoxState(e)}async onRemoveScene(i){if(this.scenePath&&i.startsWith(this.scenePath+"/")){let e=this.pageState.index,t=this._pageState.getFullPath(e);t||(e=0,t=this._pageState.getFullPath(e)),t&&this.setFullPath(t),this.setViewFocusScenePath(),this.view&&(this.view.focusSceneIndex=e)}}emitAppSceneStateChange(i){this.appEmitter.emit("sceneStateChange",i)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(i){return(e,t)=>{var s,r,n,a;if(!!this.manager.canOperate)switch(e){case"setBoxSize":{(s=this.boxManager)==null||s.resizeBox({appId:i,width:t.width,height:t.height,skipUpdate:!1});break}case"setBoxMinSize":{(r=this.boxManager)==null||r.setBoxMinSize({appId:i,minWidth:t.minwidth,minHeight:t.minheight});break}case"setBoxTitle":{(n=this.boxManager)==null||n.setBoxTitle({appId:i,title:t.title});break}case is.destroy:{if(this.status==="destroyed")return;this.destroy(!0,!1,!0,t==null?void 0:t.error),t!=null&&t.error&&console.error(t==null?void 0:t.error);break}case"focus":{(a=this.boxManager)==null||a.focusBox({appId:this.id}),ce.emit("focus",{appId:this.id});break}}}}setScenePath(){if(!this.manager.canOperate)return;const i=this.getFullScenePath();this.manager.room&&i&&this.view&&Ht(this.manager.room,i)}setViewFocusScenePath(){const i=this.getFullScenePath();return i&&this.view&&be(this.view,i),i}async createView(){const i=await this.viewManager.createView(this.id);return this.setViewFocusScenePath(),i}get pageState(){return this._pageState.toObject()}async removeSceneByIndex(i){const e=this._pageState.getFullPath(i);if(e){const t=xi(i,this.pageState);return this.setSceneIndexWithoutSync(t),this.manager.dispatchInternalEvent(R.SetAppFocusIndex,{type:"app",appID:this.id,index:t}),setTimeout(()=>{Jt(this.manager.room,e,i)},100),!0}else return!1}setSceneIndexWithoutSync(i){this.view&&(this.view.focusSceneIndex=i)}setSceneIndex(i){if(this.view){this.view.focusSceneIndex=i;const e=this._pageState.getFullPath(i);e&&this.setFullPath(e)}}async destroy(i,e,t,s){var r;if(this.status!=="destroyed"){this.status="destroyed";try{await J.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:s})}catch(n){this.Logger&&this.Logger.error(`[WindowManager]: notifyApp error: ${n.message}`),console.error("[WindowManager]: notifyApp error",n.message,n.stack)}this.appEmitter.clearListeners(),A.emit(`destroy-${this.id}`,{error:s}),i&&((r=this.boxManager)==null||r.closeBox(this.id,t)),e&&(this.store.cleanAppAttributes(this.id),this.scenePath&&Jt(this.manager.room,this.scenePath)),this.appProxies.delete(this.id),this._pageState.destroy(),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),this.manager.refresher.remove(this.id),this.manager.refresher.remove(this.stateKey),this.manager.refresher.remove(`${this.id}-fullPath`),this._prevFullPath=void 0,this.Logger&&this.Logger.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`)}}close(){return this.destroy(!0,!0,!1)}};let nt=Os;nt.kind="AppProxy";class zn{constructor(e){this.displayer=e,this.views=new Map}createView(e){const t=Ws(this.displayer);return this.views.set(e,t),t}getView(e){return this.views.get(e)}destroyView(e){const t=this.views.get(e);if(t){try{t.release()}catch{}this.views.delete(e)}}setViewScenePath(e,t){const s=this.views.get(e);s&&(s.focusScenePath=t)}destroy(){this.views.forEach(e=>{try{e.release()}catch{}}),this.views.clear()}}const Ws=i=>{const e=i.views.createView();return Dn(e),e},Dn=i=>{i.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class Tn{constructor(e){this.manager=e,this.polling=!1,this.started=!1,this.mainViewIsAddListener=!1,this.isForcingMainViewDivElement=!1,this.wrapperRectWorkaroundFrame=0,this.store=this.manager.store,this.viewMode=this.manager.windowManger.viewMode,this.sideEffectManager=new Ke,this.playgroundSizeChangeListenerLocalConsole=new We("playgroundSizeChangeListener",100),this.sizeUpdatedLocalConsole=new We("sizeUpdated",100),this.cameraUpdatedLocalConsole=new We("cameraUpdated",100),this.cameraReactionLocalConsole=new We("cameraReaction",100),this.syncCamera=()=>{if(!this.polling||this.viewMode!==f.ViewMode.Broadcaster)return;const{mainViewCamera:s}=this;s&&s.id!==this.manager.uid&&this.moveCameraSizeByAttributes()},this.startListenWritableChange=()=>{this.sideEffectManager.add(()=>A.on("writableChange",s=>{s&&this.ensureCameraAndSize(),this.manager.room&&this.syncMainView(this.manager.room)}))},this.onWrapperRectChange=s=>{this.pendingWrapperRectChange=s,this.wrapperRectWorkaroundFrame&&cancelAnimationFrame(this.wrapperRectWorkaroundFrame),this.wrapperRectWorkaroundFrame=requestAnimationFrame(this.runWrapperRectWorkaround)},this.runWrapperRectWorkaround=()=>{this.wrapperRectWorkaroundFrame=0;const s=this.pendingWrapperRectChange,r=this.mainView.divElement;if(this.pendingWrapperRectChange=void 0,!s||!r)return;const n=r.getBoundingClientRect(),a={width:n.width,height:n.height},o=Math.abs(s.width-a.width)<=.5&&Math.abs(s.height-a.height)<=.5,h=Math.abs(this.mainView.size.width-a.width)>.5||Math.abs(this.mainView.size.height-a.height)>.5;o&&h&&this.forceSyncMainViewDivElement(`wrapperRectChange:${s.origin||"unknown"}`,a,r)},this.addCameraReaction=()=>{this.manager.refresher.add(Q.MainViewCamera,this.cameraReaction)},this.cameraReaction=()=>f.reaction(()=>this.mainViewCamera,s=>{s&&s.id!==this.manager.uid&&(this.moveCameraToContian(this.mainViewSize),this.moveCamera(s),this.cameraReactionLocalConsole.log(`camera: ${JSON.stringify(s)}, current size: ${JSON.stringify(this.mainViewSize)}`))},{fireImmediately:!0}),this.sizeChangeHandler=w.debounce(s=>{s&&(this.moveCameraToContian(s),this.moveCamera(this.mainViewCamera),console.log("[window-manager] sizeChangeHandler current size and camera"+JSON.stringify(s)+JSON.stringify(this.mainViewCamera)+JSON.stringify(this.mainView.camera)+JSON.stringify(this.mainView.size))),this.ensureMainViewSize()},30),this.onUpdateContainerSizeRatio=()=>{const s=this.store.getMainViewSize();console.log("[window-manager] onUpdateContainerSizeRatio "+JSON.stringify(s)),this.sizeChangeHandler(s)},this.onCameraUpdatedByDevice=s=>{this.viewMode!==f.ViewMode.Follower&&(this.store.setMainViewCamera({...s,id:this.manager.uid}),w.isEqual(this.mainViewSize,{...this.mainView.size,id:this.manager.uid})||this.setMainViewSize(this.view.size))},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=w.debounce(s=>{this.store.setMainViewSize({...s,id:this.manager.uid})},50),this._syncMainViewTimer=0,this.handleCameraOrSizeUpdated=()=>{L.emit("cameraStateChange",this.cameraState),this.manager.room&&this.manager.room.syncMainView&&(clearTimeout(this._syncMainViewTimer),this._syncMainViewTimer=setTimeout(this.syncMainView,100,this.manager.room)),this.ensureMainViewSize()},this.onCameraUpdated=s=>{this.cameraUpdatedLocalConsole.log(JSON.stringify(s)),this.handleCameraOrSizeUpdated()},this.onSizeUpdated=s=>{this.sizeUpdatedLocalConsole.log(JSON.stringify(s)),this.handleCameraOrSizeUpdated()},this.syncMainView=s=>{s.isWritable&&s.syncMainView(this.mainView)},this.setViewMode=s=>{this.viewMode=s},this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),A.once("mainViewMounted").then(()=>{this.addMainViewListener(),this.start(),this.ensureCameraAndSize(),this.startListenWritableChange()});const t=()=>{var s,r,n,a,o,h,c,l;this.playgroundSizeChangeListenerLocalConsole.log(JSON.stringify(this.mainView.camera),JSON.stringify(this.mainView.size),JSON.stringify(this.mainViewSize),JSON.stringify(this.mainViewCamera),window.outerHeight,window.outerWidth,(r=(s=window.visualViewport)==null?void 0:s.width)!=null?r:"null",(a=(n=window.visualViewport)==null?void 0:n.height)!=null?a:"null",(h=(o=window.visualViewport)==null?void 0:o.offsetLeft)!=null?h:"null",(l=(c=window.visualViewport)==null?void 0:c.offsetTop)!=null?l:"null"),this.sizeChangeHandler(this.mainViewSize)};this.sideEffectManager.add(()=>A.on("playgroundSizeChange",t)),this.sideEffectManager.add(()=>A.on("containerSizeRatioUpdate",this.onUpdateContainerSizeRatio)),this.sideEffectManager.add(()=>A.on("wrapperRectChange",this.onWrapperRectChange)),this.sideEffectManager.add(()=>A.on("startReconnect",()=>{this.didRelease||this.mainView.release()})),this.sideEffectManager.setInterval(this.syncCamera,1500)}ensureCameraAndSize(){this.viewMode===f.ViewMode.Broadcaster&&(!this.mainViewCamera||!this.mainViewSize)&&(this.manager.dispatchInternalEvent(R.InitMainViewCamera),this.setCameraAndSize())}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}get didRelease(){return w.get(this.view,["didRelease"])}moveCameraSizeByAttributes(){this.moveCameraToContian(this.mainViewSize),this.moveCamera(this.mainViewCamera)}forceSyncMainViewDivElement(e,t,s){var o,h;const{width:r,height:n}=this.mainView.size,a=s;if(!(Math.abs(r-t.width)<=.5&&Math.abs(n-t.height)<=.5)){if(this.isForcingMainViewDivElement){console.log("[window-manager] skipForceSyncMainViewDivElement "+JSON.stringify({reason:e,observedSize:t,viewSize:this.mainView.size}));return}this.isForcingMainViewDivElement=!0;try{const l=this.mainView.screen,u=l==null?void 0:l.resizeObserver;typeof(l==null?void 0:l.refreshSize)=="function"&&(console.log("[window-manager] forceSyncMainViewDivElement observerReset "+JSON.stringify({reason:e,viewSize:this.mainView.size,observedSize:t})),(o=u==null?void 0:u.disconnect)==null||o.call(u),l.refreshSize(t.width,t.height),(h=u==null?void 0:u.observe)==null||h.call(u,s))}finally{queueMicrotask(()=>{const c=a.getBoundingClientRect();console.log("[window-manager] forceSyncMainViewDivElementResult "+JSON.stringify({reason:e,viewSize:this.mainView.size,rect:{width:c.width,height:c.height}})),this.isForcingMainViewDivElement=!1})}}}start(){console.log("[window-manager] start attributes size:"+JSON.stringify(this.mainViewSize)),this.sizeChangeHandler(this.mainViewSize),!this.started&&(this.addCameraListener(),this.addCameraReaction(),this.manager.room&&this.syncMainView(this.manager.room),this.started=!0,this.mainView.focusScenePath&&this.manager.windowManger.onMainViewScenePathChangeHandler(this.mainView.focusScenePath),console.log("[window-manager] start end mainView size:"+JSON.stringify(this.mainView.size)))}setCameraAndSize(){const e={...this.mainView.camera,id:this.manager.uid},t={...this.mainView.size,id:this.manager.uid};this.store.setMainViewCameraAndSize(e,t)}get view(){return this.mainView}get cameraState(){return{...this.view.camera,...this.view.size}}createMainView(){const e=Ws(this.manager.displayer),t=this.store.getMainViewScenePath();return t&&be(e,t),e}onReconnect(){if(this.didRelease)this.rebind();else{const e=this.store.getMainViewScenePath();this.setFocusScenePath(e)}}setFocusScenePath(e){if(e)return be(this.view,e)}rebind(){const e=this.mainView.divElement,t=this.mainView.disableCameraTransform;this.stop(),this.didRelease||this.mainView.release(),this.removeMainViewListener(),this.mainView=this.createMainView(),this.mainView.disableCameraTransform=t,this.mainView.divElement=e,this.addMainViewListener(),this.start(),L.emit("onMainViewRebind",this.mainView)}addMainViewListener(){this.mainViewIsAddListener||this.view.divElement&&(this.view.divElement.addEventListener("click",this.mainViewClickListener),this.view.divElement.addEventListener("touchend",this.mainViewClickListener),this.mainViewIsAddListener=!0)}removeMainViewListener(){this.view.divElement&&(this.view.divElement.removeEventListener("click",this.mainViewClickListener),this.view.divElement.removeEventListener("touchend",this.mainViewClickListener)),this.mainViewIsAddListener=!1}async mainViewClickHandler(){var e;!this.manager.canOperate||(this.store.cleanFocus(),(e=this.manager.boxManager)==null||e.blurAllBox())}addCameraListener(){this.view.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.on("onCameraUpdated",this.onCameraUpdated),this.view.callbacks.on("onSizeUpdated",this.onSizeUpdated)}removeCameraListener(){this.view.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.off("onCameraUpdated",this.onCameraUpdated),this.view.callbacks.off("onSizeUpdated",this.onSizeUpdated)}ensureMainViewSize(){(!this.mainViewSize||this.mainViewSize.width===0||this.mainViewSize.height===0)&&this.mainView.size.width>0&&this.mainView.size.height>0&&this.setMainViewSize(this.mainView.size)}moveCameraToContian(e){w.isEmpty(e)||(this.view.moveCameraToContain({width:e.width,height:e.height,originX:-e.width/2,originY:-e.height/2,animationMode:f.AnimationMode.Immediately}),this.scale=this.view.camera.scale)}moveCamera(e){if(!w.isEmpty(e)){if(w.isEqual(e,this.view.camera))return;const{centerX:t,centerY:s,scale:r}=e,n=r*(this.scale||1);this.view.moveCamera({centerX:t,centerY:s,scale:n,animationMode:f.AnimationMode.Immediately})}}stop(){this.removeCameraListener(),this.manager.refresher.remove(Q.MainViewCamera),this.manager.refresher.remove(Q.MainViewSize),this.started=!1}destroy(){console.log("[window-manager] destroy "),this.wrapperRectWorkaroundFrame&&(cancelAnimationFrame(this.wrapperRectWorkaroundFrame),this.wrapperRectWorkaroundFrame=0),this.playgroundSizeChangeListenerLocalConsole.destroy(),this.sizeUpdatedLocalConsole.destroy(),this.cameraUpdatedLocalConsole.destroy(),this.cameraReactionLocalConsole.destroy(),this.removeMainViewListener(),this.stop(),this.sideEffectManager.flushAll()}}class Pn{constructor(e){this.context=e,this.addRedoUndoListeners=t=>{if(t===void 0)this.addViewCallbacks(this.context.mainView(),this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate);else{const s=this.context.getAppProxy(t);s&&s.view&&this.addViewCallbacks(s.view,this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate)}},this.addViewCallbacks=(t,s,r)=>{s(t.canRedoSteps),r(t.canUndoSteps),t.callbacks.on("onCanRedoStepsUpdate",s),t.callbacks.on("onCanUndoStepsUpdate",r)},this.disposeViewCallbacks=t=>{t.callbacks.off("onCanRedoStepsUpdate",this.onCanRedoStepsUpdate),t.callbacks.off("onCanUndoStepsUpdate",this.onCanUndoStepsUpdate)},this.onCanRedoStepsUpdate=t=>{L.emit("canRedoStepsChange",t)},this.onCanUndoStepsUpdate=t=>{L.emit("canUndoStepsChange",t)},this.disposePrevFocusViewRedoUndoListeners=t=>{let s;if(t===void 0)s=this.context.mainView();else{const r=this.context.getAppProxy(t);r&&r.view&&(s=r.view)}s&&this.disposeViewCallbacks(s)},A.on("focusedChange",t=>{this.disposePrevFocusViewRedoUndoListeners(t.prev),setTimeout(()=>{this.addRedoUndoListeners(t.focused)},0)}),A.on("rootDirRemoved",()=>{this.disposePrevFocusViewRedoUndoListeners(e.focus()),this.addRedoUndoListeners(e.focus())}),this.addRedoUndoListeners(e.focus())}destroy(){this.disposePrevFocusViewRedoUndoListeners(this.context.focus())}}class ot{constructor(e){this.windowManger=e,this.appProxies=new Map,this.appStatus=new Map,this.isReplay=this.windowManger.isReplay,this.mainViewScenesLength=0,this.callbacksNode=null,this.appCreateQueue=new or,this.sideEffectManager=new Ke,this.sceneState=null,this.rootDirRemoving=!1,this._useBoxesStatus=!1,this.onRemoveScenes=async t=>{var r,n;const{scenePath:s}=t;if(s===q){console.log("[window-manager] onRemoveScenes ROOT_DIR"),await this.onRootDirRemoved(),this.dispatchInternalEvent(R.RootDirRemoved);return}if(Nr(s)){let a=this.mainView.focusSceneIndex||0,o=(r=this.callbacksNode)==null?void 0:r.scenes[a];o||(a=0,o=(n=this.callbacksNode)==null?void 0:n.scenes[a]),o&&(console.log(`[window-manager] onRemoveScenes setMainViewScenePath ${q}${o}`),this.setMainViewScenePath(`${q}${o}`)),await this.setMainViewSceneIndex(a)}else this.appProxies.forEach(a=>{a.onRemoveScene(s)})},this.onReadonlyChanged=()=>{this.appProxies.forEach(t=>{t.emitAppIsWritableChange()})},this.onPlayerSeekStart=async()=>{await this.closeAll()},this.onPlayerSeekDone=async t=>{await this._attributesUpdateCallback(this.attributes.apps),this.appProxies.forEach(s=>{s.onSeek(t)})},this.createRootDirScenesCallback=()=>{let t=!1;this.callbacksNode&&(this.callbacksNode.dispose(),t=!0),this.callbacksNode=this.displayer.createScenesCallback(q,{onAddScene:this.onSceneChange,onRemoveScene:async(s,r)=>{await this.onSceneChange(s),A.emit("rootDirSceneRemoved",r)}}),this.callbacksNode&&(this.updateSceneState(this.callbacksNode),this.mainViewScenesLength=this.callbacksNode.scenes.length,t&&this.emitMainViewScenesChange(this.callbacksNode.scenes.length))},this.removeSceneByIndex=async t=>{var n;const s=xi(t,this.windowManger.pageState);this.setSceneIndexWithoutSync(s),this.dispatchInternalEvent(R.SetAppFocusIndex,{type:"main",index:s});const r=(n=this.callbacksNode)==null?void 0:n.scenes[t];return setTimeout(()=>{r&&Jt(this.room,`${q}${r}`,t)},100),new Promise((a,o)=>{A.once("rootDirSceneRemoved").then(h=>{h===r&&a(!0)}).catch(h=>{console.log(`[WindowManager]: removePage error: ${h}`),o(!1)})})},this.setSceneIndexWithoutSync=t=>{var r;const s=(r=this.callbacksNode)==null?void 0:r.scenes[t];s&&this.mainViewProxy.setFocusScenePath(`${q}${s}`)},this.onSceneChange=t=>(this.mainViewScenesLength=t.scenes.length,this.updateSceneState(t),this.emitMainViewScenesChange(this.mainViewScenesLength)),this.emitMainViewScenesChange=t=>Promise.all([L.emit("mainViewScenesLengthChange",t),A.emit("changePageState")]),this.updateSceneState=t=>{const s=this.store.getMainViewSceneIndex()||0;let r=t.scenes[s];r||(r=t.scenes[this.mainView.focusSceneIndex||0]),this.sceneState={scenePath:`${q}${r}`,contextPath:t.path,index:s,scenes:t.scenes.map(n=>({name:n})),sceneName:r},L.emit("sceneStateChange",this.sceneState)},this.onBoxMove=t=>{this.dispatchInternalEvent(R.AppMove,t),this.store.updateAppState(t.appId,ee.Position,{x:t.x,y:t.y}),L.emit("onBoxMove",t)},this.onBoxResize=t=>{t.width&&t.height&&(this.dispatchInternalEvent(R.AppResize,t),this.store.updateAppState(t.appId,ee.Size,{width:t.width,height:t.height}),L.emit("onBoxResize",t))},this.onBoxFocus=t=>{this.windowManger.safeSetAttributes({focus:t.appId}),L.emit("onBoxFocus",t)},this.onBoxBlurred=t=>{this.attributes.focus===t.appId&&(this.windowManger.safeSetAttributes({focus:void 0}),L.emit("onBoxBlurred",t))},this.onBoxClose=t=>{const s=this.appProxies.get(t.appId);s&&s.destroy(!1,!0,!0,t.error),L.emit("onBoxClose",t)},this.onBoxStateChange=t=>{this.dispatchInternalEvent(R.AppBoxStateChange,t),L.emit("onBoxStateChange",t)},this.notifyBoxesStatusChange=w.debounce(()=>{var s;(s=this.boxManager)==null||s.setBoxesStatus(this.attributes.boxesStatus);const t=Object.entries(this.attributes.boxesStatus);t.length>0&&t.forEach(([r,n])=>{const a=this.appProxies.get(r);a&&a.notifyBoxStatusChange(n)})},100),this.addBoxesStatusChangeListener=()=>{this.refresher.add("boxesStatus",()=>_e(()=>this.attributes.boxesStatus,()=>{this.notifyBoxesStatusChange()})),this.refresher.add("lastNotMinimizedBoxesStatus",()=>_e(()=>this.attributes.lastNotMinimizedBoxesStatus,()=>{var t;(t=this.boxManager)==null||t.setLastNotMinimizedBoxesStatus(this.attributes.lastNotMinimizedBoxesStatus)}))},this.addAppsChangeListener=()=>{this.refresher.add("apps",()=>_e(()=>this.attributes.apps,()=>{this.attributesUpdateCallback(this.attributes.apps)}))},this.addAppCloseListener=()=>{this.refresher.add("appsClose",()=>_e(()=>this.attributes.apps,t=>{t.some(s=>s.kind===f.UpdateEventKind.Removed)&&this.onAppDelete(this.attributes.apps)}))},this.onMainViewIndexChange=t=>{t!==void 0&&this._prevSceneIndex!==t&&(L.emit("mainViewSceneIndexChange",t),A.emit("changePageState"),this.callbacksNode&&this.updateSceneState(this.callbacksNode),this._prevSceneIndex=t)},this.onFocusChange=t=>{var s;this._prevFocused!==t&&(L.emit("focusedChange",t),A.emit("focusedChange",{focused:t,prev:this._prevFocused}),this._prevFocused=t,t!==void 0&&((s=this.boxManager)==null||s.focusBox({appId:t}),setTimeout(()=>{const r=this.appProxies.get(t);r&&J.notifyApp(r.kind,"focus",{appId:t})},0)))},this.attributesUpdateCallback=w.debounce(t=>this._attributesUpdateCallback(t),100),this._appIds=[],this.onRegisteredChange=t=>{!t||Object.entries(t).forEach(([s,r])=>{J.appClasses.has(s)||J.register({kind:s,src:r.src,name:r.name})})},this.onMinimized=t=>{var s,r;((s=this.boxManager)==null?void 0:s.minimized)!==t&&(t===!0&&((r=this.boxManager)==null||r.blurAllBox()),setTimeout(()=>{var n;(n=this.boxManager)==null||n.setMinimized(Boolean(t))},0))},this.onAppDelete=async t=>{const s=Object.keys(t);for(const[r,n]of this.appProxies.entries())s.includes(r)||await n.destroy(!0,!1,!0)},this.closeAll=async()=>{for(const[t,s]of this.appProxies.entries())await s.destroy(!0,!1,!0)},this.displayerStateListener=t=>{this.appProxies.forEach(s=>{s.appEmitter.emit("roomStateChange",t)}),A.emit("observerIdChange",this.displayer.observerId)},this.displayerWritableListener=t=>{var n,a;const s=!t,r=this.windowManger.readonly===void 0||this.windowManger.readonly===!1;this.windowManger.readonly===void 0?(n=this.boxManager)==null||n.setReadonly(t):(a=this.boxManager)==null||a.setReadonly(!(s&&r)),this.appProxies.forEach(o=>{o.emitAppIsWritableChange()}),A.emit("writableChange",s)},this.updateSceneIndex=()=>{const t=this.store.getMainViewScenePath(),s=Et(t),r=Pe(this.displayer)[s];if(r.length){const n=t.replace(s,"").replace("/",""),a=r.findIndex(o=>o.name===n);w.isInteger(a)&&a>=0&&this.safeSetAttributes({_mainSceneIndex:a})}},this.updateRootDirRemoving=t=>{this.rootDirRemoving=t},this.displayer=e.displayer,this.store=Nn(P.extendClass,{getAttributes:()=>this.attributes,safeSetAttributes:t=>this.safeSetAttributes(t),safeUpdateAttributes:(t,s)=>this.safeUpdateAttributes(t,s)}),this.mainViewProxy=new Tn(this),this.viewManager=new zn(this.displayer),this.appListeners=new zr(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=Zs,this.refresher.setRoom(this.room),this.refresher.setContext({emitter:A}),this.sideEffectManager.addDisposer(()=>{var t,s;this.appCreateQueue.destroy(),this.mainViewProxy.destroy(),this.refresher.destroy(),this.viewManager.destroy(),(t=this.boxManager)==null||t.destroy(),(s=this.callbacksNode)==null||s.dispose()}),A.once("onCreated").then(()=>this.onCreated()),A.on("onReconnected",()=>this.onReconnected()),f.isPlayer(this.displayer)&&(A.on("seekStart",this.onPlayerSeekStart),A.on("seek",this.onPlayerSeekDone)),A.on("removeScenes",this.onRemoveScenes),A.on("setReadonly",this.onReadonlyChanged),this.createRootDirScenesCallback(),J.setSyncRegisterApp(t=>{this.safeUpdateAttributes([Q.Registered,t.kind],t)})}get useBoxesStatus(){return this._useBoxesStatus}set useBoxesStatus(e){this._useBoxesStatus=e}getMemberState(){var e;return((e=this.room)==null?void 0:e.state.memberState)||{strokeColor:[0,0,0]}}async onRootDirRemoved(e=!0){this.setMainViewScenePath(ss),this.createRootDirScenesCallback();for(const[t,s]of this.appProxies.entries())s.view&&await this.closeApp(t,e);this.mainViewProxy.rebind(),A.emit("rootDirRemoved"),this.updateRootDirRemoving(!1)}get eventName(){return f.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return f.isRoom(this.displayer)?this.displayer:void 0}get mainView(){return this.mainViewProxy.view}get polling(){return this.mainViewProxy.polling}set polling(e){this.mainViewProxy.polling=e}get focusApp(){if(this.store.focus)return this.appProxies.get(this.store.focus)}get uid(){var e;return((e=this.room)==null?void 0:e.uid)||""}get Logger(){return this.windowManger.Logger}getMainViewSceneDir(){const e=this.store.getMainViewScenePath();if(e)return Et(e);throw new Error("[WindowManager]: mainViewSceneDir not found")}async onCreated(){var e;if(Object.keys(this.attributes.apps).length&&this.store.focus&&(this._focusAppId=this.store.focus,await new Promise(t=>{this._focusAppCreatedResolve=t,this._resolveTimer=setTimeout(()=>{t(this.appProxies.get(this._focusAppId||""))},500)}).then(()=>{this._resolveTimer=void 0,this._focusAppCreatedResolve=void 0,this.focusByAttributes(this.attributes.apps)})),await this._attributesUpdateCallback(this.attributes.apps),A.emit("updateManagerRect"),ce.on("move",this.onBoxMove),ce.on("resize",this.onBoxResize),ce.on("focus",this.onBoxFocus),ce.on("close",this.onBoxClose),ce.on("boxStateChange",this.onBoxStateChange),ce.on("blurred",this.onBoxBlurred),this.addAppsChangeListener(),this.addAppCloseListener(),this.addBoxesStatusChangeListener(),this.refresher.add("maximized",()=>f.autorun(()=>{var s;const t=this.attributes.maximized;(s=this.boxManager)==null||s.setMaximized(Boolean(t))})),this.refresher.add("minimized",()=>f.autorun(()=>{const t=this.attributes.minimized;this.onMinimized(t)})),this.refresher.add("mainViewIndex",()=>f.autorun(()=>{const t=w.get(this.attributes,"_mainSceneIndex");this.onMainViewIndexChange(t)})),this.refresher.add("focusedChange",()=>f.autorun(()=>{const t=w.get(this.attributes,"focus");this.onFocusChange(t)})),this.refresher.add("registeredChange",()=>f.autorun(()=>{const t=w.get(this.attributes,Q.Registered);this.onRegisteredChange(t)})),!this.attributes.apps||Object.keys(this.attributes.apps).length===0){const t=this.store.getMainViewScenePath();if(!t)return;this.resetScenePath(t)}this.displayerWritableListener(!((e=this.room)!=null&&e.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener),this.focusByAttributes(this.attributes.apps),this._prevFocused=this.attributes.focus,P.supportAppliancePlugin||this.sideEffectManager.add(()=>{const t=new Pn({mainView:()=>this.mainViewProxy.view,focus:()=>this.attributes.focus,getAppProxy:s=>this.appProxies.get(s)});return()=>t.destroy()})}notifyAppsChange(e){(this._appIds.length!==e.length||!this._appIds.every(t=>e.includes(t)))&&(this._appIds=e,L.emit("appsChange",e))}async _attributesUpdateCallback(e){if(e&&P.container){const t=Object.keys(e);t.length===0&&this.appCreateQueue.emitReady();const r=w.orderBy(t.map(n=>({id:n,createdAt:e[n].createdAt})),"createdAt","asc").map(({id:n})=>n);this.notifyAppsChange(r);for(const n of r)if(!this.appProxies.has(n)&&!this.appStatus.has(n)){const a=e[n];try{if(!this.attributes[n])throw this.Logger&&this.Logger.error(`[WindowManager]: appAttributes is undefined, appId: ${n}`),new Error("appAttributes is undefined");this.appCreateQueue.push(async()=>{this.appStatus.set(n,Qt.StartCreate);const h=await this.baseInsertApp({kind:a.kind,options:a.options,isDynamicPPT:a.isDynamicPPT,forceNormal:a.forceNormal,forceTop:a.forceTop,isDragContent:a.isDragContent},n,!1);return h&&this._focusAppId===n&&this._focusAppCreatedResolve&&(this._resolveTimer&&clearTimeout(this._resolveTimer),this._focusAppCreatedResolve(h)),h}),this.focusByAttributes(e)}catch(o){console.warn("[WindowManager]: Insert App Error",o)}}}}refresh(){this.attributesUpdateCallback(this.attributes.apps)}setBoxManager(e){this.boxManager=e}resetMaximized(){var e;(e=this.boxManager)==null||e.setMaximized(Boolean(this.store.getMaximized()))}resetMinimized(){var e;(e=this.boxManager)==null||e.setMinimized(Boolean(this.store.getMinimized()))}bindMainView(e,t){const s=this.mainViewProxy.view;s.disableCameraTransform=t,s.divElement=e,s.focusScenePath||this.setMainViewFocusPath(),A.emit("mainViewMounted"),L.emit("onMainViewMounted",s);const r=this.hasRoot(s.divElement),n=this.getRectByDivElement(s.divElement);let a=`[window-manager] bindMainView hasRoot:${r}, rect:${JSON.stringify(n)}, outerHeight:${window.outerHeight}, outerWidth:${window.outerWidth}`;const o=window.visualViewport;o&&(a+=`, visualViewportWidth:${o.width}, visualViewportHeight:${o.height}, visualViewportOffsetLeft:${o.offsetLeft}, visualViewportOffsetTop:${o.offsetTop}`),console.log(a)}hasRoot(e){let t=e;for(;t;){if(t.parentElement===document.body)return!0;t=t.parentElement}return!1}getRectByDivElement(e){return e.getBoundingClientRect()}setMainViewFocusPath(e){var s;const t=e||this.store.getMainViewScenePath();if(t)return be(this.mainView,t),((s=this.mainView)==null?void 0:s.focusScenePath)===t}resetScenePath(e){this.displayer.state.sceneState.scenePath!==e&&Ht(this.room,e)}async addApp(e,t){var a;re("addApp",e),(a=this.windowManger.Logger)==null||a.info(`[WindowManager]: addApp ${e.kind}, isDynamicPPT: ${t}`);const{appId:s,needFocus:r}=await this.beforeAddApp(e,t),n=await this.baseInsertApp(e,s,!0,r);return this.afterAddApp(n),n==null?void 0:n.id}async beforeAddApp(e,t){var a,o;const s=await vr(e.kind);this.appStatus.set(s,Qt.StartCreate);const r=(a=e.attributes)!=null?a:{};this.safeUpdateAttributes([s],r),this.store.setupAppAttributes(e,s,t);const n=!((o=this.boxManager)!=null&&o.minimized);return n&&this.store.setAppFocus(s,!0),{appId:s,needFocus:n}}afterAddApp(e){var t,s;if(e&&e.box){const r=e.box;ce.emit("move",{appId:e.id,x:r==null?void 0:r.intrinsicX,y:r==null?void 0:r.intrinsicY}),this.store.updateAppState(e.id,ee.ZIndex,r.zIndex)}(t=this.boxManager)!=null&&t.minimized&&((s=this.boxManager)==null||s.setMinimized(!1,!1))}async closeApp(e,t=!0){const s=this.appProxies.get(e);s&&await s.destroy(!0,t,!1)}async baseInsertApp(e,t,s,r){var o;if(this.appProxies.has(t)){(o=this.windowManger.Logger)==null||o.warn(`[WindowManager]: app duplicate exists and cannot be created again, appId: ${t}`);return}const n=de(nt,P.extendClass),a=new n(e,this,t,s);if(a)return await a.baseInsertApp(r),this.appStatus.delete(t),a;throw this.appStatus.delete(t),this.Logger&&this.Logger.error(`[WindowManager]: initialize AppProxy failed, appId: ${t}`),new Error("[WindowManger]: initialize AppProxy failed")}safeSetAttributes(e){this.windowManger.safeSetAttributes(e)}safeUpdateAttributes(e,t){this.windowManger.safeUpdateAttributes(e,t)}async setMainViewScenePath(e){if(this.room){const t=this.displayer.scenePathType(e);if(Et(e)!==q)throw this.Logger&&this.Logger.error('[WindowManager]: main view scenePath must in root dir "/"'),new Error('[WindowManager]: main view scenePath must in root dir "/"');if(t===f.ScenePathType.None)throw this.Logger&&this.Logger.error(`[WindowManager]: ${e} not valid scene`),new Error(`[WindowManager]: ${e} not valid scene`);if(t===f.ScenePathType.Page)await this._setMainViewScenePath(e);else if(t===f.ScenePathType.Dir){const r=Cr(this.displayer,e);r&&await this._setMainViewScenePath(r)}}}async _setMainViewScenePath(e){this.setMainViewFocusPath(e)&&(this.safeSetAttributes({_mainScenePath:e}),this.store.setMainViewFocusPath(this.mainView),this.updateSceneIndex(),this.dispatchSetMainViewScenePath(e))}async setMainViewSceneIndex(e){var t;if(this.room){if(this.store.getMainViewSceneIndex()===e)return;const s=(t=this.callbacksNode)==null?void 0:t.scenes[e],r=`${q}${s}`;if(s)this.setMainViewFocusPath(r)&&(this.store.setMainViewScenePath(r),this.store.setMainViewSceneIndex(e),this.dispatchSetMainViewScenePath(r));else throw this.Logger&&this.Logger.error(`[WindowManager]: ${e} not valid index`),new Error(`[WindowManager]: ${e} not valid index`)}}dispatchSetMainViewScenePath(e){this.dispatchInternalEvent(R.SetMainViewScenePath,{nextScenePath:e}),L.emit("mainViewScenePathChange",e),Ht(this.room,e)}getAppInitPath(e){var s;const t=this.store.getAppAttributes(e);if(t)return(s=t==null?void 0:t.options)==null?void 0:s.scenePath}safeDispatchMagixEvent(e,t){this.canOperate&&this.displayer.dispatchMagixEvent(e,t)}focusByAttributes(e){var t;if(e&&Object.keys(e).length===((t=this.boxManager)==null?void 0:t.boxSize)){const s=this.store.focus;s&&this.boxManager.focusBox({appId:s})}}async onReconnected(){await this._attributesUpdateCallback(this.attributes.apps);const t=Array.from(this.appProxies.values()).map(s=>s.onReconnected());this.mainViewProxy.onReconnect(),await Promise.all(t),this.callbacksNode&&this.onSceneChange(this.callbacksNode)}notifyContainerRectUpdate(e){this.appProxies.forEach(t=>{t.appEmitter.emit("containerRectUpdate",e)})}dispatchInternalEvent(e,t){this.safeDispatchMagixEvent(Gt,{eventName:e,payload:t})}destroy(){this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),ce.clearListeners(),A.clearListeners(),this.appProxies.size&&this.appProxies.forEach(e=>{e.destroy(!0,!1,!0)}),L.clearListeners(),this.sideEffectManager.flushAll(),this._prevFocused=void 0,this._prevSceneIndex=void 0,this._resolveTimer&&clearTimeout(this._resolveTimer),this._focusAppCreatedResolve=void 0,this._resolveTimer=void 0}}ot.kind="AppManager";const Ln=window.ResizeObserver||sr.ResizeObserver;class Si{constructor(e){this.emitter=e,this.updateSizerLocalConsole=new We("updateSizer",100)}static create(e,t,s,r){const n=new Si(r);return n.observePlaygroundSize(e,t,s),n}observePlaygroundSize(e,t,s){this.updateSizer(e.getBoundingClientRect(),t,s,"observePlaygroundSize"),this.containerResizeObserver=new Ln(r=>{var a;const n=(a=r[0])==null?void 0:a.contentRect;n&&(this.updateSizer(n,t,s,"containerResizeObserver"),this.emitter.emit("playgroundSizeChange",n))}),this.disposer=this.emitter.on("containerSizeRatioUpdate",()=>{const r=e.getBoundingClientRect();this.updateSizer(r,t,s,"containerSizeRatioUpdate"),this.emitter.emit("playgroundSizeChange",r)}),this.containerResizeObserver.observe(e)}updateSizer({width:e,height:t},s,r,n){if(e&&t){t/e>P.containerSizeRatio?(t=e*P.containerSizeRatio,s.classList.toggle("netless-window-manager-sizer-horizontal",!0)):(e=t/P.containerSizeRatio,s.classList.toggle("netless-window-manager-sizer-horizontal",!1)),r.style.width=`${e}px`,r.style.height=`${t}px`;const a=r.getBoundingClientRect();this.updateSizerLocalConsole.log(`from ${n}, traget size: ${JSON.stringify({width:e,height:t})}, wrapperRect: ${a.width} ${a.height}`),this.emitter.emit("wrapperRectChange",{width:a.width,height:a.height,origin:n})}}disconnect(){var e,t;this.updateSizerLocalConsole.destroy(),(e=this.containerResizeObserver)==null||e.disconnect(),(t=this.disposer)==null||t.call(this),this.disposer=void 0}}class En{constructor(e){this.manager=e,A.on("changePageState",()=>{L.emit("pageStateChange",this.toObject())})}get index(){return this.manager.store.getMainViewSceneIndex()||0}get length(){return this.manager.mainViewScenesLength||0}toObject(){return{index:this.index>=this.length?this.length-1:this.index,length:this.length}}}class Vn{constructor(e){this.ctx=e,this.reactors=new Map,this.disposers=new Map,this.onPhaseChanged=async t=>{var s,r;t===f.RoomPhase.Reconnecting&&this.ctx.emitter.emit("startReconnect"),t===f.RoomPhase.Connected&&this.phase===f.RoomPhase.Reconnecting&&((s=this.room)!=null&&s.isWritable?(r=this.room)==null||r.dispatchMagixEvent(Lt,{}):(await as(500),this.onReconnected())),this.phase=t},this.onReconnected=w.debounce(()=>{this._onReconnected()},1e3),this._onReconnected=()=>{re("onReconnected refresh reactors"),this.releaseDisposers(),this.reactors.forEach((t,s)=>{w.isFunction(t)&&this.disposers.set(s,t())}),this.ctx.emitter.emit("onReconnected")}}setRoom(e){this.room=e,this.phase=e==null?void 0:e.phase,e&&(e.callbacks.off("onPhaseChanged",this.onPhaseChanged),e.callbacks.on("onPhaseChanged",this.onPhaseChanged),e.addMagixEventListener(Lt,t=>{t.authorId===e.observerId&&this.onReconnected()},{fireSelfEventAfterCommit:!0}))}setContext(e){this.ctx=e}releaseDisposers(){this.disposers.forEach(e=>{w.isFunction(e)&&e()}),this.disposers.clear()}refresh(){this._onReconnected()}add(e,t){const s=this.disposers.get(e);s&&w.isFunction(s)&&s(),w.isFunction(t)&&(this.reactors.set(e,t),this.disposers.set(e,t()))}remove(e){this.reactors.has(e)&&this.reactors.delete(e);const t=this.disposers.get(e);t&&(w.isFunction(t)&&t(),this.disposers.delete(e))}hasReactor(e){return this.reactors.has(e)}destroy(){var e,t;(e=this.room)==null||e.callbacks.off("onPhaseChanged",this.onPhaseChanged),(t=this.room)==null||t.removeMagixEventListener(Lt,this.onReconnected),this.releaseDisposers()}}const jn=(i,e)=>{if(f.isPlayer(i))kn(i);else{if(i=i,Object.getOwnPropertyDescriptor(i,"disableCameraTransform"))return;Object.defineProperty(i,"disableCameraTransform",{get(){return e.mainView.disableCameraTransform},set(n){e.mainView.disableCameraTransform=n}}),Object.defineProperty(i,"canUndoSteps",{get(){return e.canUndoSteps}}),Object.defineProperty(i,"canRedoSteps",{get(){return e.canRedoSteps}});const s=i.scalePptToFit;i.scalePptToFit=(...n)=>{var a;s.call(i,...n),(a=e.appManager)!=null&&a.mainViewProxy&&e.appManager.mainViewProxy.setCameraAndSize()};const r=i.putScenes;i.putScenes=(...n)=>{const[a,o]=n,h=e.mainView.focusScenePath;if(h&&a&&o){console.log("[window-manager] putScenes "+JSON.stringify(n));for(const c of o)if(`${a}${c.name}`===h){console.error(`[window-manager] putScenes: scene name can not be the same as the current scene path: ${h}`);return}}return r.call(i,...n)},i.moveCamera=n=>e.moveCamera(n),i.moveCameraToContain=(...n)=>e.moveCameraToContain(...n),i.convertToPointInWorld=(...n)=>e.mainView.convertToPointInWorld(...n),i.setCameraBound=(...n)=>e.mainView.setCameraBound(...n),i.scenePreview=(...n)=>e.mainView.scenePreview(...n),i.fillSceneSnapshot=(...n)=>e.mainView.fillSceneSnapshot(...n),i.generateScreenshot=(...n)=>e.mainView.generateScreenshot(...n),i.setMemberState=(...n)=>e.mainView.setMemberState(...n),i.redo=()=>e.redo(),i.undo=()=>e.undo(),i.cleanCurrentScene=()=>e.cleanCurrentScene(),i.delete=()=>e.delete(),i.copy=()=>e.copy(),i.paste=()=>e.paste(),i.duplicate=()=>e.duplicate(),i.insertImage=(...n)=>e.insertImage(...n),i.completeImageUpload=(...n)=>e.completeImageUpload(...n),i.insertText=(...n)=>e.insertText(...n),i.lockImage=(...n)=>e.lockImage(...n),i.lockImages=(...n)=>e.lockImages(...n),Rn(i,e)}},Rn=(i,e)=>{const t=i.removeScenes;i.removeScenes=(s,r)=>{var a;s===q&&((a=e.appManager)==null||a.updateRootDirRemoving(!0));const n=t.call(i,s);return A.emit("removeScenes",{scenePath:s,index:r}),n}},kn=i=>{const e=i.seekToProgressTime;async function t(s){await A.emit("seekStart");const r=await e.call(i,s);return A.emit("seek",s),r}i.seekToProgressTime=t},Un=async()=>{const i=await Promise.resolve().then(function(){return require("./app-media-player.js")});return P.debug&&i.setOptions({verbose:!0}),i.default||i},_n=async()=>{const i=await Promise.resolve().then(function(){return require("./app-docs-viewer.js")});return i.default||i},On=async()=>{const i=await Promise.resolve().then(function(){return require("./app-presentation.js")});return i.default||i},Wn=()=>{P.register({kind:fe.DocsViewer,src:_n}),P.register({kind:fe.MediaPlayer,src:Un}),P.register({kind:fe.Presentation,src:On,appOptions:{reScaleOnPageChange:!0,debounceSync:!0,useScrollbar:!0}})},fe={DocsViewer:"DocsViewer",MediaPlayer:"MediaPlayer",Presentation:"Presentation"};const pe={Ready:"Ready",RootRect:"ReplayRootRect",Message:"message",ComputeStyle:"computeStyle",Load:"load",DisplayerState:"displayerState",Show:"show",Hide:"hide"},$n=(i,e)=>new Array(i).fill(0).map((t,s)=>e(s)),j=class{constructor(i,e){this.manager=i,this.appManager=e,this.magixEventMap=new Map,this.cssList=[],this.allowAppliances=["clicker"],this.bridgeDisposer=w.noop,this.rootRect=null,this.sideEffectManager=new Ke,this.execListenIframe=w.debounce(t=>{this.listenIframe(t)},50),this.onPhaseChangedListener=t=>{t===f.PlayerPhase.Playing&&this.computedStyleAndIframeDisplay()},this.stateChangeListener=t=>{t={...t},t.cameraState=this.manager.cameraState,this.postMessage({kind:"RoomStateChanged",payload:t}),t.cameraState&&(j.emitter.emit("GetRootRect"),this.computedStyle(t)),t.memberState&&(this.computedZindex(),this.updateStyle()),t.sceneState&&this.computedIframeDisplay(t,this.attributes)},this.displayer=j.displayer=e.displayer,this.iframe=this._createIframe(),this.sideEffectManager.addDisposer(j.emitter.on("ReplayRootRect",t=>{this.rootRect=t}),pe.RootRect),this.sideEffectManager.addDisposer(j.emitter.on("HideIframe",()=>{this.iframe.className=j.hiddenClass}),pe.Hide),this.sideEffectManager.addDisposer(j.emitter.on("DispayIframe",()=>{this.iframe.className=""}),pe.Show),this.sideEffectManager.addDisposer(j.emitter.on("created",()=>{this.bridgeDisposer(),this.bridgeDisposer=f.autorun(()=>{var s;const t=this.attributes;if(t.url){const r=(s=this.iframe)==null?void 0:s.src;r&&r!==t.url&&this.execListenIframe(t)}t.displaySceneDir&&this.computedIframeDisplay(this.displayer.state,t),(t.width||t.height)&&this.iframe&&(this.iframe.width=`${t.width}px`,this.iframe.height=`${t.height}px`),this.postMessage({kind:"AttributesUpdate",payload:t})})})),this.sideEffectManager.addDisposer(i.emitter.on("cameraStateChange",()=>{this.computedStyle(this.displayer.state)})),j.onCreate(this)}static onCreate(i){j.emitter.emit("StartCreate"),j.emitter.emit("OnCreate",i),j.emitter.emit("created")}insert(i){const e={url:i.url,width:i.width,height:i.height,displaySceneDir:i.displaySceneDir,useClicker:i.useClicker||!1,useSelector:i.useSelector};this.setAttributes(e);const t=()=>{this.getIframe(),this.listenIframe(this.attributes),this.listenDisplayerState(),j.emitter.emit("GetRootRect")};if(this.getIframe())t();else{const s=this.sideEffectManager.addDisposer(j.emitter.on("WrapperDidMount",()=>{t(),this.sideEffectManager.flush(s)})),r=this.sideEffectManager.addDisposer(j.emitter.on("WrapperDidUpdate",()=>{t(),this.sideEffectManager.flush(r)}))}return this.attributes.useSelector&&this.allowAppliances.push("selector"),this.computedStyle(this.displayer.state),this.listenDisplayerCallbacks(),this.getComputedIframeStyle(),this.sideEffectManager.addEventListener(window,"message",this.messageListener.bind(this),void 0,pe.Message),j.alreadyCreate=!0,this}getComputedIframeStyle(){this.sideEffectManager.setTimeout(()=>{this.iframe&&getComputedStyle(this.iframe)},200,pe.ComputeStyle)}destroy(){this.sideEffectManager.flushAll(),j.emitter.emit("Destory"),j.alreadyCreate=!1,j.emitter.clearListeners()}getIframe(){return this.iframe||(this.iframe=this._createIframe()),this.iframe}setIframeSize(i){this.iframe&&(this.iframe.width=`${i.width}px`,this.iframe.height=`${i.height}px`,this.setAttributes({width:i.width,height:i.height}))}get attributes(){return this.appManager.store.getIframeBridge()}setAttributes(i){this.appManager.store.setIframeBridge(i)}_createIframe(){const i=document.createElement("iframe");return i.id="IframeBridge",i.className=j.hiddenClass,this.appManager.mainView.divElement&&this.appManager.mainView.divElement.appendChild(i),i}scaleIframeToFit(i=f.AnimationMode.Immediately){if(!this.inDisplaySceneDir)return;const{width:e=1280,height:t=720}=this.attributes,s=e?-e/2:0,r=t?-t/2:0;this.manager.moveCameraToContain({originX:s,originY:r,width:e,height:t,animationMode:i})}get isReplay(){return this.manager.isReplay}handleSetPage(i){if(this.isReplay||!this.attributes.displaySceneDir)return;const e=i.payload,t=this.displayer,s=t.entireScenes()[this.attributes.displaySceneDir];if(!s||s.length!==e){const r=$n(e,n=>({name:String(n+1)}));t.putScenes(this.attributes.displaySceneDir,r),this.manager.setMainViewScenePath(this.attributes.displaySceneDir)}}listenIframe(i){const e=t=>{var s;this.postMessage({kind:"Init",payload:{attributes:this.attributes,roomState:(s=j.displayer)==null?void 0:s.state,currentPage:this.currentPage,observerId:this.displayer.observerId}}),j.emitter.emit("IframeLoad",t),this.sideEffectManager.addDisposer(j.emitter.on("Ready",()=>{var r;this.postMessage((r=this.attributes.lastEvent)==null?void 0:r.payload)}),pe.Ready),this.computedStyleAndIframeDisplay()};i.url&&this.iframe.src!==i.url&&(this.src_url_equal_anchor||(this.src_url_equal_anchor=document.createElement("a")),this.src_url_equal_anchor.href=i.url,this.src_url_equal_anchor.href!==this.iframe.src&&(this.iframe.src=i.url)),this.iframe.width=`${i.width}px`,this.iframe.height=`${i.height}px`,this.sideEffectManager.addEventListener(this.iframe,"load",e,void 0,pe.Load)}listenDisplayerState(){this.isReplay&&(this.displayer._phase===f.PlayerPhase.Playing&&this.computedStyleAndIframeDisplay(),this.sideEffectManager.add(()=>(this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChangedListener),()=>this.displayer.callbacks.off("onPhaseChanged",this.onPhaseChangedListener)),pe.DisplayerState)),this.computedStyleAndIframeDisplay()}computedStyleAndIframeDisplay(){this.computedStyle(this.displayer.state),this.computedIframeDisplay(this.displayer.state,this.attributes)}listenDisplayerCallbacks(){this.displayer.callbacks.on(this.callbackName,this.stateChangeListener)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}computedStyle(i){const e=this.manager.cameraState,t=this.attributes.width||1280,s=this.attributes.height||720;if(this.iframe){const{width:r,height:n,scale:a,centerX:o,centerY:h}=e,c=this.rootRect||{x:0,y:0},l=`${r/2+c.x}px`,u=`${n/2+c.y}px`,d=`transform-origin: ${l} ${u};`,m=(r-t)/2*a,g=(n-s)/2*a,b=-(o*a)+m,M=-(h*a)+g,N=`transform: translate(${b}px,${M}px) scale(${a}, ${a});`,W=["position: absolute;","border: 0.1px solid rgba(0,0,0,0);","top: 0px;","left: 0px;",d,N];this.cssList=W,this.computedZindex(),this.updateStyle()}}computedIframeDisplay(i,e){this.inDisplaySceneDir?j.emitter.emit("DispayIframe"):j.emitter.emit("HideIframe")}computedZindex(){const i="z-index: -1;",e=this.cssList.findIndex(t=>t===i);e!==-1&&this.cssList.splice(e,1),(!this.isClicker()||this.isDisableInput)&&this.cssList.push(i)}updateStyle(){this.iframe.style.cssText=this.cssList.join(" ")}get iframeOrigin(){if(this.iframe)try{return new URL(this.iframe.src).origin}catch(i){console.warn(i)}}messageListener(i){if(re("<<<",JSON.stringify(i.data)),i.origin!==this.iframeOrigin)return;const e=i.data;switch(e.kind){case"SetAttributes":{this.handleSetAttributes(e);break}case"RegisterMagixEvent":{this.handleRegisterMagixEvent(e);break}case"RemoveMagixEvent":{this.handleRemoveMagixEvent(e);break}case"DispatchMagixEvent":{this.handleDispatchMagixEvent(e);break}case"RemoveAllMagixEvent":{this.handleRemoveAllMagixEvent();break}case"NextPage":{this.handleNextPage();break}case"PrevPage":{this.handlePrevPage();break}case"SDKCreate":{this.handleSDKCreate();break}case"SetPage":{this.handleSetPage(e);break}case"GetAttributes":{this.handleGetAttributes();break}case"PageTo":{this.handlePageTo(e);break}default:{re(`${e.kind} not allow event.`);break}}}handleSDKCreate(){this.postMessage({kind:"Init",payload:{attributes:this.attributes,roomState:this.displayer.state,currentPage:this.currentPage,observerId:this.displayer.observerId}})}handleDispatchMagixEvent(i){const e=i.payload;this.appManager.safeDispatchMagixEvent(e.event,e.payload)}handleSetAttributes(i){this.setAttributes(i.payload)}handleRegisterMagixEvent(i){const e=i.payload,t=s=>{s.authorId!==this.displayer.observerId&&this.postMessage({kind:"ReciveMagixEvent",payload:s})};this.magixEventMap.set(e,t),this.displayer.addMagixEventListener(e,t)}handleRemoveMagixEvent(i){const e=i.payload,t=this.magixEventMap.get(e);this.displayer.removeMagixEventListener(e,t)}handleNextPage(){this.manager.canOperate&&(this.manager.nextPage(),this.dispatchMagixEvent("NextPage",{}))}handlePrevPage(){this.manager.canOperate&&(this.manager.prevPage(),this.dispatchMagixEvent("PrevPage",{}))}handlePageTo(i){if(this.manager.canOperate){const e=i.payload;if(!Number.isSafeInteger(e)||e<=0)return;this.manager.setMainViewSceneIndex(e-1),this.dispatchMagixEvent("PageTo",e-1)}}handleRemoveAllMagixEvent(){this.magixEventMap.forEach((i,e)=>{this.displayer.removeMagixEventListener(e,i)}),this.magixEventMap.clear()}handleGetAttributes(){this.postMessage({kind:"GetAttributes",payload:this.attributes})}postMessage(i){var e;this.iframe&&((e=this.iframe.contentWindow)==null||e.postMessage(JSON.parse(JSON.stringify(i)),"*"))}dispatchMagixEvent(i,e){this.manager.canOperate&&(this.setAttributes({lastEvent:{name:i,payload:e}}),this.displayer.dispatchMagixEvent(i,e))}get currentIndex(){return this.manager.mainViewSceneIndex}get currentPage(){return this.currentIndex+1}get totalPage(){return this.manager.mainViewScenesLength}get readonly(){return!this.displayer.isWritable}get inDisplaySceneDir(){return this.manager.mainViewSceneDir===this.attributes.displaySceneDir}isClicker(){if(this.readonly)return!1;const i=this.displayer.state.memberState.currentApplianceName;return this.allowAppliances.includes(i)}get isDisableInput(){return"disableDeviceInputs"in this.displayer?this.displayer.disableDeviceInputs:!0}};let Ee=j;Ee.kind="IframeBridge";Ee.hiddenClass="netless-iframe-brdige-hidden";Ee.emitter=new ve.default;Ee.displayer=null;Ee.alreadyCreate=!1;class Zn extends ve.default{_inject(e){this.context=e}}class $s{constructor(e){this.extends=new Map,this.context={manager:this,windowManager:e.windowManager,internalEmitter:e.internalEmitter},e.container&&this.refreshContainer(e.container)}refreshContainer(e){this.context.windowManagerContainer=e,this.extends.forEach(t=>{t._inject(this.context)})}hasRegister(e){return J.appClasses.has(e)}use(e){this.extends.set(e.kind,e),e._inject(this.context),e.onCreate()}destroy(){this.extends.forEach(e=>{this.extends.delete(e.kind),e.onDestroy()})}}function Fn(i,e){if(i.kind&&e&&Object.keys(e).includes(i.kind))switch(i.kind){case"AppManager":return(e==null?void 0:e.AppManager)||ot;case"BoxManager":return(e==null?void 0:e.BoxManager)||it;case"AttributesDelegate":return(e==null?void 0:e.AttributesDelegate)||at;case"CursorManager":return(e==null?void 0:e.CursorManager)||rt;case"AppProxy":return(e==null?void 0:e.AppProxy)||nt;case"AppContext":return(e==null?void 0:e.AppContext)||qe;case"TeleBoxManager":return(e==null?void 0:e.TeleBoxManager)||tt;case"TeleBoxCollector":return(e==null?void 0:e.TeleBoxCollector)||Le;default:return i}return i}const Zt="Slide",Ft=fe.Presentation,Gn=1,Qn=4;function qi(i){return typeof i=="number"&&Number.isFinite(i)&&i>=Gn&&i<=Qn}const Zs=new Vn({emitter:A}),C=class extends f.InvisiblePlugin{constructor(i){super(i),this.version="1.0.15",this.dependencies={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"0.3.0",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1",uuid:"^7.0.3","video.js":">=7"},peerDependencies:{jspdf:"2.5.1","white-web-sdk":"^2.16.54"},devDependencies:{"@hyrious/dts":"^0.2.2","@netless/app-docs-viewer":"^0.2.19","@netless/app-media-player":"0.1.4","@netless/app-presentation":"^0.1.9","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"1.0.0-next.30","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",jspdf:"^2.5.1",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1","side-effect-manager":"0.1.5",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.9.9",vitest:"^0.14.1","white-web-sdk":"^2.16.54"}},this.emitter=L,this.viewMode=f.ViewMode.Broadcaster,this.isReplay=f.isPlayer(this.displayer),this._cursorUIDs=[],this.containerSizeRatio=C.containerSizeRatio,this.onMainViewScenePathChangeHandler=e=>{const t=this.mainView.divElement;if(t){const s=t.querySelector(".background img");if(s){const r=s==null?void 0:s.getBoundingClientRect(),n=window.getComputedStyle(s),a=(r==null?void 0:r.width)>0&&(r==null?void 0:r.height)>0&&n.display!=="none",o=this.mainView.camera;console.log("[window-manager] backgroundImageVisible:"+a+" camera:"+JSON.stringify(o));return}console.log("[window-manager] onMainViewScenePathChange scenePath:"+e+" backgroundImageVisible is not found");return}console.log("[window-manager] onMainViewScenePathChange scenePath:"+e+" mainViewElement is not found")},C.displayer=i.displayer,window.NETLESS_DEPS={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"0.3.0",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1",uuid:"^7.0.3","video.js":">=7"},peerDependencies:{jspdf:"2.5.1","white-web-sdk":"^2.16.54"},devDependencies:{"@hyrious/dts":"^0.2.2","@netless/app-docs-viewer":"^0.2.19","@netless/app-media-player":"0.1.4","@netless/app-presentation":"^0.1.9","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"1.0.0-next.30","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",jspdf:"^2.5.1",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1","side-effect-manager":"0.1.5",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.9.9",vitest:"^0.14.1","white-web-sdk":"^2.16.54"}},this.emitter.on("mainViewScenePathChange",this.onMainViewScenePathChangeHandler)}get Logger(){return this._roomLogger}static onCreate(i){C._resolve(i)}static async mount(i,e){var c;const t=i.room;C.container=i.container,C.supportAppliancePlugin=i.supportAppliancePlugin;const s=i.containerSizeRatio,r=i.debug,n=i.cursor;C.params=i,C.extendClass=e,C.displayer=i.room,Qa();let a;if(f.isRoom(t)){if(t.phase!==f.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");t.phase===f.RoomPhase.Connected&&t.isWritable&&(t.disableSerialization=!1),a=await this.initManager(t),a&&(a._roomLogger=t.logger,a.attributesDeboundceLog=new Fa(a._roomLogger,"attributes",300),C.registered.size>0&&a._roomLogger.info(`[WindowManager] registered apps: ${JSON.stringify(Array.from(C.registered.keys()))}`))}if(C.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");if(this.debug=Boolean(r),a!=null&&a._roomLogger?a._roomLogger.info(`[WindowManager] Already insert room version: ${a.version}`):re("Already insert room",a),f.isRoom(this.displayer)){if(!a)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await ts.default(async l=>{if(a=t.getInvisiblePlugin(C.kind),!a)throw re(`manager is empty. retrying ${l}`),new Error},{retries:10,maxTimeout:5e3});if(!a)throw new Error("[WindowManager]: create manager failed");s&&(C.containerSizeRatio=s),await a.ensureAttributes();const o=de(ot,C.extendClass),h=de(rt,C.extendClass);a._fullscreen=i.fullscreen,a.appManager=new o(a),a.appManager.polling=i.polling||!1,a._pageState=new En(a.appManager),a.cursorManager=new h(a.appManager,Boolean(n),i.cursorOptions,i.applianceIcons),a.extendPluginManager=new $s({internalEmitter:A,windowManager:a}),s&&(a.containerSizeRatio=s),i.container&&a.bindContainer(i.container),jn(t,a),A.emit("onCreated"),C.isCreated=!0,a._roomLogger&&a.attributes.registered&&Object.keys(a.attributes.registered).length>0&&a._roomLogger.info(`[WindowManager] attributes registered apps: ${JSON.stringify(Array.from(Object.keys(a.attributes.registered)))}`);try{await cr()}catch(l){(c=a._roomLogger)==null||c.warn(`[WindowManager] indexedDB open failed: ${l.message}`),console.warn("[WindowManager]: indexedDB open failed"),console.log(l)}return a.emitter.on("mainViewScenePathChange",a.onMainViewScenePathChangeHandler),a}static initManager(i){return Ya(i)}static initContainer(i,e,t){const{chessboard:s,overwriteStyles:r,fullscreen:n}=t;C.container||(C.container=e);const{playground:a,wrapper:o,sizer:h,mainViewElement:c}=Ga(e);if(C.playground=a,s&&h.classList.add("netless-window-manager-chess-sizer"),n&&h.classList.add("netless-window-manager-fullscreen"),r){const l=document.createElement("style");l.textContent=r,a.appendChild(l)}return i.containerResizeObserver=Si.create(a,h,o,A),C.wrapper=o,C.sizer=h,c}static get registered(){return J.registered}bindContainer(i){var e,t,s,r,n,a;if(f.isRoom(this.displayer)&&this.room.phase!==f.RoomPhase.Connected)throw new ds;if(C.isCreated&&C.container)C.container.firstChild&&i.appendChild(C.container.firstChild);else if(C.params){const o=C.params,h=C.initContainer(this,i,o);this.boxManager&&this.boxManager.destroy();const c=Oa(this,L,A,ce,{collectorContainer:o.collectorContainer,collectorStyles:o.collectorStyles,prefersColorScheme:o.prefersColorScheme,useBoxesStatus:o.useBoxesStatus});this.boxManager=c,this.appManager&&(this.appManager.useBoxesStatus=o.useBoxesStatus||!1,this.appManager.setBoxManager(c)),this.bindMainView(h,o.disableCameraTransform),C.wrapper&&((e=this.cursorManager)==null||e.setupWrapper(C.wrapper))}A.emit("updateManagerRect"),(t=this.appManager)==null||t.refresh(),(s=this.appManager)==null||s.resetMaximized(),(r=this.appManager)==null||r.resetMinimized(),(n=this.appManager)==null||n.displayerWritableListener(!this.room.isWritable),C.container=i,(a=this.extendPluginManager)==null||a.refreshContainer(i)}bindCollectorContainer(i){C.isCreated&&this.boxManager?this.boxManager.setCollectorContainer(i):C.params&&(C.params.collectorContainer=i)}static register(i){return J.register(i)}static unregister(i){return J.unregister(i)}async addApp(i){if(this.appManager)return this.appManager.rootDirRemoving?new Promise((e,t)=>{A.once("rootDirRemoved").then(async()=>{try{const s=await this._addApp(i);e(s)}catch(s){t(s.message)}})}):this._addApp(i);throw new te}async _addApp(i){var e,t,s;if(this.appManager){if(!i.kind||typeof i.kind!="string")throw new hs;i.src&&typeof i.src=="string"&&J.register({kind:i.kind,src:i.src});const r=await((e=J.appClasses.get(i.kind))==null?void 0:e());if(r&&((t=r.config)==null?void 0:t.singleton)&&this.appManager.appProxies.has(i.kind))throw new ns;const n=this.setupScenePath(i,this.appManager);return n===void 0?void 0:((s=i==null?void 0:i.options)!=null&&s.scenePath&&(i.options.scenePath=Br(i.options.scenePath)),await this.appManager.addApp(i,Boolean(n)))}else throw new te}setupScenePath(i,e){let t=!1;if(i.options){const{scenePath:s,scenes:r}=i.options;if(s){if(!Ar(s))throw new ls;const n=Object.keys(this.apps||{});for(const a of n){const o=e.store.getAppScenePath(a);if(o&&o===s){if(console.warn(`[WindowManager]: ScenePath "${s}" already opened`),this.boxManager){const h=this.boxManager.getTopBox();h&&(this.boxManager.setZIndex(a,h.zIndex+1,!1),this.boxManager.focusBox({appId:a},!1))}return}}}s&&r&&r.length>0&&(this.isDynamicPPT(r)?(t=!0,Pe(this.displayer)[s]||$e(this.room,s,r)):Pe(this.displayer)[s]||$e(this.room,s,[{name:r[0].name}])),s&&r===void 0&&$e(this.room,s,[{}])}return t}async setMainViewScenePath(i){this.appManager&&await this.appManager.setMainViewScenePath(i)}async setMainViewSceneIndex(i){this.appManager&&await this.appManager.setMainViewSceneIndex(i)}async nextPage(){if(this.appManager){const i=this.mainViewSceneIndex+1;return i>=this.mainViewScenesLength?(console.warn("[WindowManager]: current page is the last page"),!1):(await this.appManager.setMainViewSceneIndex(i),!0)}else return!1}async prevPage(){if(this.appManager){const i=this.mainViewSceneIndex-1;return i<0?(console.warn("[WindowManager]: current page is the first page"),!1):(await this.appManager.setMainViewSceneIndex(i),!0)}else return!1}async jumpPage(i){return this.appManager?i<0||i>=this.pageState.length?(console.warn(`[WindowManager]: index ${i} out of range`),!1):(await this.appManager.setMainViewSceneIndex(i),!0):!1}async addPage(i){if(this.appManager){const e=i==null?void 0:i.after,t=i==null?void 0:i.scene;if(e){const s=this.mainViewSceneIndex+1;this.room.putScenes(q,[t||{}],s)}else this.room.putScenes(q,[t||{}])}}async removePage(i){if(this.appManager){const e=i===void 0?this.pageState.index:i;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):e<0||e>=this.pageState.length?(console.warn(`[WindowManager]: index ${i} out of range`),!1):this.appManager.removeSceneByIndex(e)}else return!1}getMainViewScenePath(){var i;return(i=this.appManager)==null?void 0:i.store.getMainViewScenePath()}getMainViewSceneIndex(){var i;return(i=this.appManager)==null?void 0:i.store.getMainViewSceneIndex()}setReadonly(i){var e;this.readonly=i,(e=this.boxManager)==null||e.setReadonly(i),A.emit("setReadonly",i)}switchMainViewToWriter(){var i;return(i=this.appManager)==null?void 0:i.mainViewProxy.mainViewClickHandler()}onAppDestroy(i,e){yr(`destroy-${i}`,e)}onAppEvent(i,e){return A.on(`custom-${i}`,e)}setViewMode(i){var e,t,s,r;(i===f.ViewMode.Broadcaster||i===f.ViewMode.Follower)&&(this.canOperate&&i===f.ViewMode.Broadcaster&&((e=this.appManager)==null||e.mainViewProxy.setCameraAndSize()),(t=this.appManager)==null||t.mainViewProxy.start()),i===f.ViewMode.Freedom&&((s=this.appManager)==null||s.mainViewProxy.stop()),this.viewMode=i,(r=this.appManager)==null||r.mainViewProxy.setViewMode(i)}setBoxState(i){if(!!this.canOperate)switch(i){case"normal":this.setMaximized(!1),this.setMinimized(!1);break;case"maximized":this.setMaximized(!0),this.setMinimized(!1);break;case"minimized":this.setMinimized(!0);break}}setMaximized(i){var e;!this.canOperate||(e=this.boxManager)==null||e.setMaximized(i,!1)}setMinimized(i){var e;!this.canOperate||(e=this.boxManager)==null||e.setMinimized(i,!1)}setBoxStatus(i,e){var t;!this.canOperate||(t=this.appManager)==null||t.store.setBoxStatus(i,e)}setLastNotMinimizedBoxStatus(i,e){var t;!this.canOperate||(t=this.appManager)==null||t.store.setLastNotMinimizedBoxStatus(i,e)}setFullscreen(i){var e;this._fullscreen!==i&&(this._fullscreen=i,(e=C.sizer)==null||e.classList.toggle("netless-window-manager-fullscreen",i),L.emit("fullscreenChange",i))}get cursorUIDs(){return this._cursorUIDs}setCursorUIDs(i){var e,t;if(this._cursorUIDs=i||[],this._cursorUIDs.length===0)(e=this._cursorUIDsStyleDOM)==null||e.remove();else{this._cursorUIDsStyleDOM||(this._cursorUIDsStyleDOM=document.createElement("style")),(t=C.playground)==null||t.appendChild(this._cursorUIDsStyleDOM);let s="[data-cursor-uid] { display: none }";for(const r of this._cursorUIDs)s+=`
17
+ [data-cursor-uid="${r}"] { display: flex }`;this._cursorUIDsStyleDOM.textContent=s}}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new te}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new te}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new te}get apps(){var i;return(i=this.appManager)==null?void 0:i.store.apps()}get boxState(){var i;if(this.appManager)return(i=this.appManager.boxManager)==null?void 0:i.boxState;throw new te}get boxStatus(){if(this.appManager)return this.appManager.store.getBoxesStatus();throw new te}get lastNotMinimizedBoxStatus(){if(this.appManager)return this.appManager.store.getLastNotMinimizedBoxesStatus();throw new te}get darkMode(){var i,e;return Boolean((e=(i=this.appManager)==null?void 0:i.boxManager)==null?void 0:e.darkMode)}get prefersColorScheme(){var i;if(this.appManager)return(i=this.appManager.boxManager)==null?void 0:i.prefersColorScheme;throw new te}get focused(){return this.attributes.focus}get focusedView(){var i,e;return((e=(i=this.appManager)==null?void 0:i.focusApp)==null?void 0:e.view)||this.mainView}get polling(){var i;return((i=this.appManager)==null?void 0:i.polling)||!1}set polling(i){this.appManager&&(this.appManager.polling=i)}get cursorStyle(){var i;return((i=this.cursorManager)==null?void 0:i.style)||"default"}set cursorStyle(i){if(!this.cursorManager)throw new Error("[WindowManager]: cursor is not enabled, please set { cursor: true }.");this.cursorManager.style=i}get mainViewSceneIndex(){var i;return((i=this._pageState)==null?void 0:i.index)||0}get mainViewSceneDir(){var i;if(this.appManager)return(i=this.appManager)==null?void 0:i.getMainViewSceneDir();throw new te}get topApp(){var i,e;return(e=(i=this.boxManager)==null?void 0:i.getTopBox())==null?void 0:e.id}get mainViewScenesLength(){var i;return((i=this._pageState)==null?void 0:i.length)||0}get canRedoSteps(){var i;return((i=this.focusedView)==null?void 0:i.canRedoSteps)||0}get canUndoSteps(){var i;return((i=this.focusedView)==null?void 0:i.canUndoSteps)||0}get sceneState(){if(this.appManager)return this.appManager.sceneState;throw new te}get pageState(){if(this._pageState)return this._pageState.toObject();throw new te}get fullscreen(){return Boolean(this._fullscreen)}queryAll(){var i;return Array.from(((i=this.appManager)==null?void 0:i.appProxies.values())||[])}queryOne(i){var e;return(e=this.appManager)==null?void 0:e.appProxies.get(i)}dispatchDocsEvent(i,e={}){var u;const t=e.appId||this.focused;if(!t)return console.warn("not found "+(e.appId||"focused app")),!1;const s=this.queryOne(t);if(!s)return console.warn("not found app with id "+t),!1;const r=t.startsWith(`${fe.DocsViewer}-`)||s.kind===fe.DocsViewer,n=t.startsWith(`${Ft}-`)||s.kind===Ft,a=t.startsWith(`${Zt}-`)||s.kind===Zt;let o=s.kind;if(r?o=fe.DocsViewer:n?o=Ft:a&&(o=Zt),!C.registered.has(o))return console.warn("not registered app kind "+o),!1;let h,c,l;if(r){const d=(u=s.box)==null?void 0:u.$footer;if(!d)return console.warn("not found app with id "+t),!1;const m=g=>{g&&g.dispatchEvent(new MouseEvent("click"))};switch(i){case"prevPage":case"prevStep":m(d.querySelector('button[class$="btn-page-back"]'));break;case"nextPage":case"nextStep":m(d.querySelector('button[class$="btn-page-next"]'));break;case"jumpToPage":if(h=e.page,c=d.querySelector('input[class$="page-number-input"]'),!c||typeof h!="number")return console.warn("failed to jump"+(h?" to page "+h:"")),!1;c.value=""+h,c.dispatchEvent(new InputEvent("change"));break;case"scalePage":return console.warn("not supported event "+i+" for app kind "+o),!1;default:return console.warn("unknown event "+i),!1}return!0}if(n){const d=s.appResult;if(!d)return console.warn("not found app with id "+t),!1;switch(i){case"prevPage":case"prevStep":return d.prevPage();case"nextPage":case"nextStep":return d.nextPage();case"jumpToPage":return h=e.page,typeof h!="number"?(console.warn("failed to jump"+(h?" to page "+h:"")),!1):d.jumpPage(h-1);case"scalePage":if(l=e.scale,!qi(l))return console.warn("failed to scale, scale should be a number from 1 to 4"),!1;try{return d.moveCamera({centerX:0,centerY:0,scale:d.getOriginScale()*l}),!0}catch(m){return console.warn(m),!1}default:return console.warn("unknown event "+i),!1}}if(a){const d=s.appResult;if(!d)return console.warn("not found app with id "+t),!1;switch(i){case"prevPage":return d.prevPage();case"nextPage":return d.nextPage();case"prevStep":return d.prevStep();case"nextStep":return d.nextStep();case"jumpToPage":return h=e.page,typeof h!="number"?(console.warn("failed to jump"+(h?" to page "+h:"")),!1):d.jumpToPage(h);case"scalePage":return l=e.scale,qi(l)?(d.scaleView(l),!0):(console.warn("failed to scale, scale should be a number from 1 to 4"),!1);default:return console.warn("unknown event "+i),!1}}return console.warn("not supported app kind "+s.kind),!1}async closeApp(i){var e;return(e=this.appManager)==null?void 0:e.closeApp(i)}focusApp(i){var t,s,r;const e=(t=this.boxManager)==null?void 0:t.getBox(i);e&&((s=this.boxManager)==null||s.focusBox({appId:i},!1),((r=this.boxManager)==null?void 0:r.teleBoxManager).makeBoxTop(e,!1))}moveCamera(i){const e=w.omit(i,["animationMode"]),t={...this.mainView.camera};w.isEqual({...t,...e},t)||(this.mainView.moveCamera(i),setTimeout(()=>{var s;(s=this.appManager)==null||s.mainViewProxy.setCameraAndSize()},500))}moveCameraToContain(i){this.mainView.moveCameraToContain(i),setTimeout(()=>{var e;(e=this.appManager)==null||e.mainViewProxy.setCameraAndSize()},500)}convertToPointInWorld(i){return this.mainView.convertToPointInWorld(i)}setCameraBound(i){this.mainView.setCameraBound(i)}onDestroy(){this._destroy()}destroy(){this._destroy()}_destroy(){var i,e,t,s,r,n,a;(i=this.attributesDeboundceLog)==null||i.destroy(),this.attributesDeboundceLog=void 0,(e=this.containerResizeObserver)==null||e.disconnect(),(t=this.appManager)==null||t.destroy(),(s=this.cursorManager)==null||s.destroy(),(r=this.extendPluginManager)==null||r.destroy(),C.container=void 0,C.wrapper=void 0,C.sizer=void 0,C.isCreated=!1,C.playground&&((n=C.playground.parentNode)==null||n.removeChild(C.playground)),C.params=void 0,this.emitter.off("mainViewScenePathChange",this.onMainViewScenePathChangeHandler),(a=this._iframeBridge)==null||a.destroy(),this._iframeBridge=void 0,re("Destroyed")}bindMainView(i,e){var t;this.appManager&&(this.appManager.bindMainView(i,Boolean(e)),(t=this.cursorManager)==null||t.setMainViewDivElement(i))}get canOperate(){return f.isRoom(this.displayer)?this.displayer.isWritable&&this.displayer.phase===f.RoomPhase.Connected:!1}get room(){return this.displayer}safeSetAttributes(i){this.canOperate&&(this.setAttributes(i),this.attributesDeboundceLog&&this.attributesDeboundceLog.logDebouncedShallowMerge("safeSetAttributes",i))}safeUpdateAttributes(i,e){this.canOperate&&(this.updateAttributes(i,e),this.attributesDeboundceLog&&this.attributesDeboundceLog.logDebouncedUpdateAttributes(i,e))}setPrefersColorScheme(i){var e,t;(t=(e=this.appManager)==null?void 0:e.boxManager)==null||t.setPrefersColorScheme(i)}cleanCurrentScene(){var i,e;re("clean current scene"),(i=this.focusedView)==null||i.cleanCurrentScene(),this.Logger&&this.Logger.info(`[WindowManager]: cleanCurrentScene ${(e=this.focusedView)==null?void 0:e.focusScenePath}`)}redo(){var i;return((i=this.focusedView)==null?void 0:i.redo())||0}undo(){var i;return((i=this.focusedView)==null?void 0:i.undo())||0}delete(){var i,e;(i=this.focusedView)==null||i.delete(),this.Logger&&this.Logger.info(`[WindowManager]: delete ${(e=this.focusedView)==null?void 0:e.focusScenePath}`)}copy(){var i;(i=this.focusedView)==null||i.copy()}paste(){var i;(i=this.focusedView)==null||i.paste()}duplicate(){var i;(i=this.focusedView)==null||i.duplicate()}insertText(i,e,t){var s;return((s=this.focusedView)==null?void 0:s.insertText(i,e,t))||""}insertImage(i){var e;return(e=this.focusedView)==null?void 0:e.insertImage(i)}completeImageUpload(i,e){var t;return(t=this.focusedView)==null?void 0:t.completeImageUpload(i,e)}lockImage(i,e){var t;return(t=this.focusedView)==null?void 0:t.lockImage(i,e)}lockImages(i){var e;return(e=this.focusedView)==null?void 0:e.lockImages(i)}refresh(){var i;this._refresh(),(i=this.appManager)==null||i.dispatchInternalEvent(R.Refresh)}_refresh(){var i,e;(i=this.appManager)==null||i.mainViewProxy.rebind(),C.container&&this.bindContainer(C.container),(e=this.appManager)==null||e.refresher.refresh()}setContainerSizeRatio(i){if(!w.isNumber(i)||!(i>0))throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a positive number. but got ${i}`);C.containerSizeRatio=i,this.containerSizeRatio=i,A.emit("containerSizeRatioUpdate",i)}isDynamicPPT(i){var t,s;const e=(s=(t=i[0])==null?void 0:t.ppt)==null?void 0:s.src;return e==null?void 0:e.startsWith("pptx://")}async ensureAttributes(){w.isNull(this.attributes)&&await as(50),w.isObject(this.attributes)&&(this.attributes[Q.Apps]||this.safeSetAttributes({[Q.Apps]:{}}),this.attributes[Q.Cursors]||this.safeSetAttributes({[Q.Cursors]:{}}),this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:ss}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:0}),this.attributes[Q.Registered]||this.safeSetAttributes({[Q.Registered]:{}}),this.attributes[Q.IframeBridge]||this.safeSetAttributes({[Q.IframeBridge]:{}}))}getIframeBridge(){if(!this.appManager)throw new Error("[WindowManager]: should call getIframeBridge() after await mount()");return this._iframeBridge||(this._iframeBridge=new Ee(this,this.appManager)),this._iframeBridge}useExtendPlugin(i){var e;(e=this.extendPluginManager)==null||e.use(i)}};let P=C;P.kind="WindowManager";P.debug=!1;P.containerSizeRatio=nr;P.isCreated=!1;P._resolve=i=>{};Wn();exports.AppContext=qe;exports.AppCreateError=ns;exports.AppManager=ot;exports.AppManagerNotInitError=te;exports.AppNotRegisterError=Dr;exports.AppProxy=nt;exports.AttributesDelegate=at;exports.BindContainerRoomPhaseInvalidError=ds;exports.BoxManager=it;exports.BoxManagerNotFoundError=us;exports.BoxNotCreatedError=cs;exports.BuiltinApps=fe;exports.CursorManager=rt;exports.ExtendPlugin=Zn;exports.ExtendPluginManager=$s;exports.InvalidScenePath=ls;exports.ParamsInvalidError=hs;exports.TeleBoxCollector=Le;exports.TeleBoxManager=tt;exports.WhiteWebSDKInvalidError=os;exports.WindowManager=P;exports.calculateNextIndex=xi;exports.getExtendClass=Fn;exports.reconnectRefresher=Zs;
49
18
  //# sourceMappingURL=index.js.map