@netless/window-manager 1.0.0-canary.4 → 1.0.0-canary.5

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.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var IS=Object.defineProperty,bS=Object.defineProperties;var ES=Object.getOwnPropertyDescriptors;var tg=Object.getOwnPropertySymbols;var AS=Object.prototype.hasOwnProperty,TS=Object.prototype.propertyIsEnumerable;var ig=(_,se,$e)=>se in _?IS(_,se,{enumerable:!0,configurable:!0,writable:!0,value:$e}):_[se]=$e,Z=(_,se)=>{for(var $e in se||(se={}))AS.call(se,$e)&&ig(_,$e,se[$e]);if(tg)for(var $e of tg(se))TS.call(se,$e)&&ig(_,$e,se[$e]);return _},gt=(_,se)=>bS(_,ES(se));(function(_,se){typeof exports=="object"&&typeof module!="undefined"?se(exports,require("p-retry"),require("emittery"),require("lodash"),require("white-web-sdk"),require("uuid"),require("side-effect-manager"),require("value-enhancer"),require("@juggle/resize-observer"),require("video.js")):typeof define=="function"&&define.amd?define(["exports","p-retry","emittery","lodash","white-web-sdk","uuid","side-effect-manager","value-enhancer","@juggle/resize-observer","video.js"],se):(_=typeof globalThis!="undefined"?globalThis:_||self,se(_.WindowManager={},_.pRetry,_.Emittery,_.lodash,_.whiteWebSdk,_.uuid,_.sideEffectManager,_.valueEnhancer,_.resizeObserver,_.p$1))})(this,function(_,se,$e,b,E,ng,be,A,uu,rg){"use strict";function Js(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var sg=Js(se),Pt=Js($e),cu=Js(rg),G=(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))(G||{});const Ks="__WindowManger",qs="__WindowMangerEnsureReconnected__";var Pe=(e=>(e.Size="size",e.Position="position",e.SceneIndex="SceneIndex",e.ZIndex="zIndex",e))(Pe||{}),du=(e=>(e.setBoxSize="setBoxSize",e.setBoxMinSize="setBoxMinSize",e.destroy="destroy",e))(du||{}),eo=(e=>(e.StartCreate="StartCreate",e))(eo||{}),hu=(e=>(e.Leave="leave",e.Normal="normal",e))(hu||{});const pu="2.16.1",og=340/720,ag=340/720,lg=9/16,ke="/",fu="/init",gu=50,mu=500,ne=new Pt.default;class ug{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(()=>{ne.emit("ready")},gu),this.isEmit=!0}empty(){this.list=[],this.clear()}destroy(){this.timer&&this.clear()}}const L=new Pt.default,cg="__WindowManagerAppCache";let on,vu;const dg=async()=>{on=await fg()},hg=(e,t)=>{if(!!on)return mg(on,{kind:e,sourceCode:t})},pg=async e=>on?await gg(on,e):null;function fg(){return new Promise((e,t)=>{const i=indexedDB.open(cg,2);i.onerror=n=>{t(n)},i.onupgradeneeded=n=>{const r=n.target.result;r.objectStoreNames.contains("apps")||(vu=r.createObjectStore("apps",{keyPath:"kind"}),vu.createIndex("kind","kind",{unique:!0}))},i.onsuccess=()=>{const n=i.result;e(n)}})}function gg(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 mg(e,t){return new Promise((i,n)=>{const r=e.transaction(["apps"],"readwrite").objectStore("apps").add(t);r.onsuccess=()=>i(),r.onerror=()=>n()})}const vg="NetlessApp",wg=1e4,yg=async e=>{const t=await pg(e);if(t)return t.sourceCode;{const n=await(await Sg(e,{timeout:wg})).text();return await hg(e,n),n}},wu=(e,t)=>{let i=Function(e+`
2
- ;return ${t}`)();return typeof i=="undefined"&&(i=window[t]),i},xg=async(e,t,i)=>{const n=i||vg+t;ne.emit("loadApp",{kind:t,status:"start"});try{const r=await yg(e);if(!r||r.length===0){ne.emit("loadApp",{kind:t,status:"failed",reason:"script is empty."});return}try{const s=wu(r,n);return ne.emit("loadApp",{kind:t,status:"success"}),s}catch(s){if(s.message.includes("Can only have one anonymous define call per script file")){const o=window.define;typeof o=="function"&&o.amd&&delete o.amd;const a=wu(r,n);return ne.emit("loadApp",{kind:t,status:"success"}),a}ne.emit("loadApp",{kind:t,status:"failed",reason:s.message})}}catch(r){ne.emit("loadApp",{kind:t,status:"failed",reason:r.message})}};async function Sg(e,t){const{timeout:i=1e4}=t,n=new AbortController,r=setTimeout(()=>n.abort(),i),s=await fetch(e,gt(Z({},t),{signal:n.signal,headers:{"content-type":"text/plain"}}));return clearTimeout(r),s}class Cg{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()=>{let r=await xg(i,t.kind,t.name);if(r)return r.__esModule&&(r=r.default),r;throw new Error(`[WindowManager]: load remote script failed, ${i}`)},this.syncRegisterApp&&this.syncRegisterApp({kind:t.kind,src:i,name:t.name})):typeof i=="function"?n=i: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 Pt.default;this.kindEmitters.set(t,i)}return this.kindEmitters.get(t)}}const ze=new Cg,Mg=async e=>{var i,n;const t=await((i=ze.appClasses.get(e))==null?void 0:i());return t&&((n=t.config)==null?void 0:n.singleton)?e:`${e}-${ng.v4().replace("-","").slice(0,8)}`},ti=(e,t)=>{if(e.focusScenePath!==t)return e.focusScenePath=t,e},yu=e=>{e.didRelease||e.release()},to=(e,t)=>{if(e&&e.isWritable&&e.state.sceneState.scenePath!==t){const i=t==="/"?"":t;e.setScenePath(i)}},Ig=(e,t,i)=>{var n;if(e&&t){const s=(n=ii(e)[t])==null?void 0:n[i];if(s)return`${t}/${s.name}`}},io=(e,t,i)=>{e&&e.scenePathType(t)!==E.ScenePathType.None&&e.removeScenes(t,i)},bg=(e,t)=>{L.once(e).then(t)};b.debounce((e,t)=>{e.emit("mainViewModeChange",t)},200);const Eg=(e,t,i=0)=>{const n=ii(e)[t];if(!n)return;const r=n[i];if(!r)return;const s=r.name;return t===ke?`/${s}`:`${t}/${s}`},ii=e=>e.entireScenes(),ni=(e,t,i,n)=>e==null?void 0:e.putScenes(t,i,n),Ag=e=>e.startsWith("/"),no=e=>{const t=e.split("/");t.pop();let i=t.join("/");return i===""&&(i="/"),i},Tg=e=>e.endsWith("/")?e.slice(0,-1):e,xu=e=>{const t=e.split(".").map(i=>i.padStart(2,"0")).join("");return parseInt(t)},Su=e=>new Promise(t=>setTimeout(t,e)),Ng=e=>e.split("").reduce((i,n)=>(n===ke&&(i+=1),i),0)===1;class Pg{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 G.AppMove:{this.appMoveHandler(n.payload);break}case G.AppResize:{this.appResizeHandler(n.payload);break}case G.AppBoxStateChange:{this.boxStateChangeHandler(n.payload);break}case G.SetMainViewScenePath:{this.setMainViewScenePathHandler(n.payload);break}case G.MoveCamera:{this.moveCameraHandler(n.payload);break}case G.MoveCameraToContain:{this.moveCameraToContainHandler(n.payload);break}case G.CursorMove:{this.cursorMoveHandler(n.payload);break}case G.RootDirRemoved:{this.rootDirRemovedHandler();break}case G.Refresh:{this.refreshHandler();break}case G.InitMainViewCamera:{this.initMainViewCameraHandler();break}case G.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=>{ne.emit("boxStateChange",i)},this.setMainViewScenePathHandler=({nextScenePath:i})=>{ti(this.manager.mainView,i),ne.emit("mainViewScenePathChange",i)},this.moveCameraHandler=i=>{b.isEqual(b.omit(i,["animationMode"]),Z({},this.manager.mainView.camera))||this.manager.mainView.moveCamera(i)},this.moveCameraToContainHandler=i=>{this.manager.mainView.moveCameraToContain(i)},this.cursorMoveHandler=i=>{L.emit("cursorMove",i)},this.rootDirRemovedHandler=()=>{this.manager.createRootDirScenesCallback(),this.manager.mainViewProxy.rebind(),L.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(Ks,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(Ks,this.mainMagixEventListener)}}class Cu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class kg extends Error{constructor(t){super(`[WindowManager]: app ${t} need register or provide src`)}}class Xe extends Error{constructor(){super(...arguments);this.message="[WindowManager]: AppManager must be initialized"}}class Mu extends Error{constructor(t){super(`[WindowManager]: white-web-sdk version must large than ${t}`)}}class Iu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: kind must be a valid string"}}class bu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: box need created"}}class Eu extends Error{constructor(){super(...arguments);this.message='[WindowManager]: ScenePath should start with "/"'}}class Au extends Error{constructor(){super(...arguments);this.message="[WindowManager]: boxManager not found"}}class Tu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: room phase only Connected can be bindContainer"}}const Nu=e=>(t,i)=>{if(t!==void 0)if(E.listenUpdated){const n=r=>{r.map(o=>o.kind).includes(e)&&i()};return E.listenUpdated(t,n),i(),()=>E.unlistenUpdated(t,n)}else return E.reaction(()=>t,()=>{i()},{fireImmediately:!0})},Pu=(e,t,i)=>{let n=null;const r=E.reaction(e,()=>{n&&(n(),n=null);const s=e();b.isObject(s)?(n=()=>E.unlistenUpdated(s,t),E.listenUpdated(s,t)):i==null||i(s)},{fireImmediately:!0});return()=>{n==null||n(),r()}},zg=Nu(E.UpdateEventKind.Removed);Nu(E.UpdateEventKind.Inserted);const ro=Object.keys;function ku(e){return Boolean(b.has(e,"__isRef"))}function Dg(e){return{k:be.genUID(),v:e,__isRef:!0}}class Lg{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 Je="_WM-STORAGE_";class zu{constructor(t,i,n){if(this._sideEffect=new be.SideEffectManager,this._destroyed=!1,this._refMap=new WeakMap,this._lastValue=new Map,this.onStateChanged=new Lg,n&&!b.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.isWritable&&(this.id===null?t.isAddApp&&n&&this.setState(n):(r===this._state||!b.isObject(r))&&(b.get(this._context.getAttributes(),[Je])||this._context.updateAttributes([Je],{}),this._context.updateAttributes([Je,this.id],this._state),n&&this.setState(n))),ro(r).forEach(s=>{if(!(this.id===null&&s===Je))try{const o=b.isObject(r[s])?JSON.parse(JSON.stringify(r[s])):r[s];ku(o)?(this._state[s]=o.v,b.isObject(o.v)&&this._refMap.set(o.v,o)):this._state[s]=o}catch(o){console.error(o)}}),this._sideEffect.addDisposer(Pu(()=>this.id===null?t.getAttributes():b.get(t.getAttributes(),[Je,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(ro(t).reduce((i,n)=>(b.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.isWritable){console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`),t);return}const i=ro(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(b.isObject(r)){let o=this._refMap.get(r);o||(o=Dg(r),this._refMap.set(r,o)),s=o}this._setRawState(n,s)}})}emptyStorage(){if(!(b.size(this._state)<=0)){if(this._destroyed){console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));return}if(!this._context.isWritable){console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));return}this.setState(b.mapValues(this._state,b.noop))}}deleteStorage(){if(this.id===null)throw new Error("Cannot delete main Storage");if(!this._context.isWritable){console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));return}this.destroy(),this._context.updateAttributes([Je,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:b.get(this._context.getAttributes(),[Je,this.id],t)}_setRawState(t,i){if(this.id===null){if(t===Je)throw new Error(`Cannot set attribute internal filed "${Je}"`);return this._context.updateAttributes([t],i)}else return this._context.updateAttributes([Je,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===Je)continue;const a=b.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:{b.has(this._state,o)&&(l=this._state[o],delete this._state[o]),n[o]={oldValue:l};break}default:{let u=a;if(ku(a)){const{k:c,v:d}=a,m=this._state[o];b.isObject(m)&&((i=this._refMap.get(m))==null?void 0:i.k)===c?u=m:(u=d,b.isObject(d)&&this._refMap.set(d,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 jg{constructor(t,i,n){this.appContext=t,this.appProxy=i,this.removeViewWrapper=n,this.nextPage=async()=>{const s=this.pageState.index+1;return this.jumpPage(s)},this.prevPage=async()=>{const s=this.pageState.index-1;return this.jumpPage(s)},this.jumpPage=async s=>s<0||s>=this.pageState.length?(console.warn(`[WindowManager]: index ${s} out of range`),!1):(this.appProxy.setSceneIndex(s),!0),this.addPage=async s=>{const o=s==null?void 0:s.after,a=s==null?void 0:s.scene,l=this.appProxy.scenePath;if(!!l)if(o){const u=this.pageState.index+1;ni(this.appContext.room,l,[a||{}],u)}else ni(this.appContext.room,l,[a||{}])},this.removePage=async s=>{const o=s===void 0?this.pageState.index:s;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 ${s} out of range`),!1):this.appProxy.removeSceneByIndex(o)};const r=new A.Val(i.pageState);this.pageState$=r,i.appEmitter.on("pageStateChange",s=>{r.setValue(s)})}get view(){return this.appContext.view}get pageState(){return this.pageState$.value}moveCamera(t){this.appProxy.moveCamera(t)}destroy(){this.removeViewWrapper()}}const Rg=e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");return i.className="netless-window-manager-main-view",t.appendChild(i),e.appendChild(t),{playground:t,mainViewElement:i}},Vg=()=>{if(xu(E.WhiteVersion)<xu(pu))throw new Mu(pu)},Du=(e,t)=>{const i=e==null?void 0:e.state.roomMembers;return i==null?void 0:i.find(n=>{var r;return((r=n.payload)==null?void 0:r.uid)===t})},Bg=e=>e.map(t=>{var i;return Z({uid:((i=t.payload)==null?void 0:i.uid)||""},t)});class Og{constructor(t,i,n,r,s){this.manager=t,this.boxManager=i,this.appId=n,this.appProxy=r,this.appOptions=s,this.mobxUtils={autorun:E.autorun,reaction:E.reaction,toJS:E.toJS},this.objectUtils={listenUpdated:E.listenUpdated,unlistenUpdated:E.unlistenUpdated,listenDisposed:E.listenDisposed,unlistenDisposed:E.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,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.createWhiteBoardView=o=>{var c;if(this.whiteBoardView)return this.whiteBoardView;let a=this.view;a||(a=this.appProxy.createAppDir());const l=document.createElement("div");l.className="window-manager-view-wrapper",(c=this.box.$content.parentElement)==null||c.appendChild(l);const u=()=>{var d;(d=this.box.$content.parentElement)==null||d.removeChild(l)};return a.divElement=l,this.isAddApp&&this.initPageSize(o),this.whiteBoardView=new jg(this,this.appProxy,u),this.whiteBoardView},this.initPageSize=o=>{if(!b.isNumber(o)||!this.appProxy.scenePath||this.appProxy.pageState.length>=o)return;if(o<=0||o>=mu)throw Error(`[WindowManager]: size ${o} muse be in range [1, ${mu}]`);const a=o-this.appProxy.pageState.length,l=this.appProxy.pageState.length,u=new Array(a).fill({}).map((c,d)=>({name:`${l+d+1}`}));ni(this.room,this.appProxy.scenePath,u)},this.getInitScenePath=()=>this.manager.getAppInitPath(this.appId),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.room)==null||a.setScenePath(o))},this.getAppOptions=()=>typeof this.appOptions=="function"?this.appOptions():this.appOptions,this.createStorage=(o,a)=>{const l=new zu(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.emitter=r.appEmitter,this.isAddApp=r.isAddApp}get displayer(){return this.manager.displayer}get view(){return this.appProxy.view}get isWritable(){return this.manager.canOperate}get box(){const t=this.boxManager.getBox(this.appId);if(t)return t;throw new bu}get room(){return this.manager.room}get members(){return this.manager.members}get memberState(){const t=Du(this.room,this.manager.uid);if(!t)throw new Error(`Member ${this.manager.uid} not found.`);return Z({uid:this.manager.uid},t)}get storage(){return this._storage||(this._storage=new zu(this)),this._storage}}class _g{constructor(t){this.params=t,this.sceneNode=null,this.createSceneNode=r=>(this.scenePath=r,this.sceneNode&&this.sceneNode.dispose(),this.sceneNode=this.params.displayer.createScenesCallback(r,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}),this.sceneNode),this.onSceneChange=()=>{this.params.notifyPageStateChange()};const{displayer:i,scenePath:n}=this.params;this.view=this.params.view,n&&(this.scenePath=n,this.sceneNode=i.createScenesCallback(n,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}))}setView(t){this.view=t}getFullPath(t){var n;const i=(n=this.sceneNode)==null?void 0:n.scenes;if(this.scenePath&&i){const r=i[t];if(r)return`${this.scenePath}/${r}`}}toObject(){var t,i;return{index:((t=this.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()}}class Lu{constructor(t){this.saveCamera=t,this.onRemoteUpdate=b.throttle((i,n)=>{if(this.remoteCamera=i,this.remoteSize=n,this.remoteSize&&this.rect){let r;n.width<n.height?r=this.rect.width/n.width:r=this.rect.height/n.height;const s=i.scale*r,o=()=>{var a;return(a=this.view)==null?void 0:a.moveCamera({centerX:i.centerX,centerY:i.centerY,scale:s,animationMode:E.AnimationMode.Immediately})};b.delay(o,50)}},50),this.onLocalSizeUpdate=i=>{if(this.rect&&this.view){let n;i.width<i.height?n=this.rect.width/i.width:n=this.rect.height/i.height;const r=this.view.camera.scale/n;console.log("onLocalSizeUpdate",r.toFixed(3),n.toFixed(3)),this.view.moveCamera({scale:r,animationMode:E.AnimationMode.Immediately})}}}setRect(t){this.rect=t,this.remoteCamera&&this.remoteSize&&this.onRemoteUpdate(this.remoteCamera,this.remoteSize)}setView(t){this.view=t}onLocalCameraUpdate(t){this.saveCamera(t),this.remoteCamera=t}}class Ug{constructor(t){this.appProxy=t,this.sem=new be.SideEffectManager,this.bindView=n=>{!n||(this.synchronizer.setView(n),this.sem.add(()=>(n.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),()=>n.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice))))},this.onCameraUpdatedByDevice=n=>{var s;this.synchronizer.onLocalCameraUpdate(n);const r=(s=this.appProxy.box)==null?void 0:s.contentStageRect;if(r){const o={width:r.width,height:r.height,id:this.appProxy.uid};b.isEqual(o,this.appProxy.size$.value)||this.appProxy.storeSize(o)}},this.synchronizer=new Lu(n=>{this.appProxy.storeCamera(Z({id:this.appProxy.uid},n))}),this.bindView(t.view),this.sem.add(()=>this.appProxy.camera$.subscribe(n=>{const r=this.appProxy.size$.value;n&&r&&this.synchronizer.onRemoteUpdate(n,r)}));const i=this.appProxy.box;i&&i.contentStageRect&&(this.synchronizer.setRect(i.contentStageRect),this.sem.add(()=>i._contentStageRect$.subscribe(n=>{n&&this.synchronizer.setRect(n)})),this.appProxy.size$.value||this.appProxy.storeSize({id:this.appProxy.uid,width:i.contentStageRect.width,height:i.contentStageRect.height}))}destroy(){this.sem.flushAll()}}const mt=new Pt.default,so=(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};var he=(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.Camera="camera",e.Size="size",e))(he||{});class $g{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 b.get(this.attributes,["apps"])}get focus(){return b.get(this.attributes,["focus"])}getAppAttributes(t){return b.get(this.apps(),[t])}getAppState(t){return b.get(this.apps(),[t,"state"])}getMaximized(){return b.get(this.attributes,["maximized"])}getMinimized(){return b.get(this.attributes,["minimized"])}setupAppAttributes(t,i,n){this.attributes.apps||this.context.safeSetAttributes({apps:{}});const s=["scenePath","title"];n||s.push("scenes");const o=b.pick(t.options,s),a={kind:t.kind,options:o,isDynamicPPT:n};typeof t.src=="string"&&(a.src=t.src),a.createdAt=Date.now(),this.context.safeUpdateAttributes(["apps",i],a),this.context.safeUpdateAttributes(["apps",i,"state"],{[Pe.Size]:{},[Pe.Position]:{},[Pe.SceneIndex]:0})}updateAppState(t,i,n){b.get(this.attributes,["apps",t,"state"])&&this.context.safeUpdateAttributes(["apps",t,"state",i],n)}updateAppAttributes(t,i,n){this.context.safeUpdateAttributes(["apps",t,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[Pe.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 b.get(this.attributes,["mainViewCamera"])}getMainViewSize(){return b.get(this.attributes,["mainViewSize"])}setMainViewCamera(t){this.context.safeSetAttributes({mainViewCamera:Z({},t)})}setMainViewSize(t){this.context.safeSetAttributes({mainViewSize:Z({},t)})}setMainViewCameraAndSize(t,i){this.context.safeSetAttributes({mainViewCamera:Z({},t),mainViewSize:Z({},i)})}updateCursor(t,i){b.get(this.attributes,["cursors"])||this.context.safeUpdateAttributes(["cursors"],{}),b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"position"],i)}updateCursorState(t,i){b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"cursorState"],i)}getCursorState(t){return b.get(this.attributes,["cursors",t,"cursorState"])}cleanCursor(t){this.context.safeUpdateAttributes(["cursors",t],void 0)}setMainViewFocusPath(t){const i=this.getMainViewScenePath();i&&ti(t,i)}}const Hg=new $g({getAttributes:()=>{throw new Error("getAttributes not implemented")},safeSetAttributes:()=>{throw new Error("safeSetAttributes not implemented")},safeUpdateAttributes:()=>{throw new Error("safeUpdateAttributes not implemented")}}),Ti=(...e)=>{Ie.debug&&console.log("[WindowManager]:",...e)};class oo{constructor(t,i,n,r){var s;this.params=t,this.manager=i,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.store=this.manager.store,this.uid=this.manager.uid,this.status="normal",this.sideEffectManager=new be.SideEffectManager,this.camera$=new A.Val(void 0),this.size$=new A.Val(void 0),this.box$=new A.Val(void 0),this.view$=new A.Val(void 0),this.getAppInitState=o=>{var p,h;const a=this.store.getAppState(o);if(!a)return;const l=a==null?void 0:a[Pe.Position],u=this.store.focus,c=a==null?void 0:a[Pe.Size],d=a==null?void 0:a[Pe.SceneIndex],m=(p=this.attributes)==null?void 0:p.maximized,w=(h=this.attributes)==null?void 0:h.minimized,y=a==null?void 0:a.zIndex;let M={maximized:m,minimized:w,zIndex:y};return l&&(M=gt(Z({},M),{id:o,x:l.x,y:l.y})),u===o&&(M=gt(Z({},M),{focus:!0})),c&&(M=gt(Z({},M),{width:c.width,height:c.height})),d&&(M=gt(Z({},M),{sceneIndex:d})),M},this.appAttributesUpdateListener=o=>{var a,l,u;(a=this.manager.refresher)==null||a.add(o,()=>E.autorun(()=>{const c=this.manager.attributes[o];c&&this.appEmitter.emit("attributesUpdate",c)})),(l=this.manager.refresher)==null||l.add(this.stateKey,()=>E.autorun(()=>{var d,m,w;const c=(d=this.appAttributes)==null?void 0:d.state;(c==null?void 0:c.zIndex)>0&&c.zIndex!==((m=this.box)==null?void 0:m.zIndex)&&((w=this.boxManager)==null||w.setZIndex(o,c.zIndex))})),(u=this.manager.refresher)==null||u.add(`${o}-fullPath`,()=>E.autorun(()=>{var d;const c=(d=this.appAttributes)==null?void 0:d.fullPath;this.setFocusScenePathHandler(c),this._prevFullPath!==c&&(this.notifyPageStateChange(),this._prevFullPath=c)}))},this.setFocusScenePathHandler=b.debounce(o=>{var a;this.view&&o&&o!==((a=this.view)==null?void 0:a.focusScenePath)&&ti(this.view,o)},50),this.notifyPageStateChange=b.debounce(()=>{this.pageState&&this.appEmitter.emit("pageStateChange",this.pageState)},50),this.storeCamera=o=>{this.store.updateAppAttributes(this.id,he.Camera,o)},this.storeSize=o=>{this.store.updateAppAttributes(this.id,he.Size,o)},this.moveCamera=o=>{if(!this.camera$.value)return;const a=Z(Z({},this.camera$.value),o);this.storeCamera(a)},this.kind=t.kind,this.id=n,this.appScenePath=`/${this.id}-app-dir`,this.stateKey=`${this.id}_state`,this.appProxies.set(this.id,this),this.appEmitter=new Pt.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=r,this.initScenes(),(s=this.params.options)!=null&&s.scenePath&&this.createView(),this.scenePath||(this.scenePath=this.appScenePath),this._pageState=new _g({displayer:this.manager.displayer,scenePath:this.scenePath,view:this.view,notifyPageStateChange:this.notifyPageStateChange}),this.sideEffectManager.add(()=>()=>this._pageState.destroy()),this.sideEffectManager.add(()=>L.on("roomMembersChange",o=>{this.appEmitter.emit("roomMembersChange",o)})),this.camera$.setValue(E.toJS(this.appAttributes.camera)),this.size$.setValue(E.toJS(this.appAttributes.size)),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-camera`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.camera},o=>{o&&o.id!==this.uid&&this.camera$.setValue(E.toJS(o))}))),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-size`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.size},o=>{o&&o.id!==this.uid&&this.size$.setValue(E.toJS(o))}))),A.combine([this.box$,this.view$]).subscribe(([o,a])=>{if(o&&a){const l=new Ug(this);this.appViewSync=l,this.sideEffectManager.add(()=>()=>l.destroy())}})}createAppDir(){const t=this.scenePath||this.appScenePath;this._pageState.createSceneNode(t)||(ni(this.manager.room,t,[{name:"1"}]),this._pageState.createSceneNode(t),this.setSceneIndex(0)),this.scenes=ii(this.manager.displayer)[t];const n=this.createView();return this._pageState.setView(n),n}initScenes(){var i;const t=this.params.options;t&&(this.scenePath=t.scenePath,((i=this.appAttributes)==null?void 0:i.isDynamicPPT)&&this.scenePath?this.scenes=ii(this.manager.displayer)[this.scenePath]:this.scenes=t.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get viewIndex(){var t;return(t=this.view)==null?void 0:t.focusSceneIndex}get isWritable(){var t;return this.manager.canOperate&&!((t=this.box)!=null&&t.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}getFullScenePath(){if(this.scenePath)return b.get(this.appAttributes,[he.FullPath])||this.getFullScenePathFromScenes()}getFullScenePathFromScenes(){const t=b.get(this.appAttributes,["state","SceneIndex"],0),i=Ig(this.manager.room,this.scenePath,t);return i&&this.setFullPath(i),i}setFullPath(t){this.store.updateAppAttributes(this.id,he.FullPath,t)}async baseInsertApp(t=!1){var s;const i=this.params;if(!i.kind)throw new Error("[WindowManager]: kind require");const n=await((s=ze.appClasses.get(i.kind))==null?void 0:s()),r=ze.registered.get(i.kind);if(n)await this.setupApp(this.id,t,n,i.options,r==null?void 0:r.appOptions);else throw new Error(`[WindowManager]: app load failed ${i.kind} ${i.src}`);return L.emit("updateManagerRect"),{appId:this.id,app:n}}get box(){return this.box$.value}async setupApp(t,i,n,r,s){var a;if(Ti("setupApp",t,n,r),!this.boxManager)throw new Au;const o=new Og(this.manager,this.boxManager,t,this,s);this.appContext=o;try{L.once(`${t}${G.WindowCreated}`).then(async()=>{var c;let u;i||(u=this.getAppInitState(t),(c=this.boxManager)==null||c.updateBoxState(u)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(t),this.setViewFocusScenePath(),setTimeout(async()=>{const d=await n.setup(o);this.appResult=d,ze.notifyApp(this.kind,"created",{appId:t,result:d}),this.fixMobileSize()},gu)});const l=(a=this.boxManager)==null?void 0:a.createBox({appId:t,app:n,options:r,canOperate:this.manager.canOperate,smartPosition:this.isAddApp});this.box$.setValue(l),this.isAddApp&&this.box&&(this.store.updateAppState(t,Pe.ZIndex,this.box.zIndex),this.boxManager.focusBox({appId:t},!1))}catch(l){throw console.error(l),new Error(`[WindowManager]: app setup error: ${l.message}`)}}fixMobileSize(){var i,n;const t=(i=this.boxManager)==null?void 0:i.getBox(this.id);t&&((n=this.boxManager)==null||n.resizeBox({appId:this.id,width:t.intrinsicWidth+.001,height:t.intrinsicHeight+.001,skipUpdate:!0}))}async onSeek(t){var n;this.appEmitter.emit("seek",t).catch(r=>{console.log(`[WindowManager]: emit seek error: ${r.message}`)});const i=this.getAppInitState(this.id);(n=this.boxManager)==null||n.updateBoxState(i)}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 i=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const n=this.params;await new oo(n,this.manager,this.id,this.isAddApp).baseInsertApp(!0),(s=this.boxManager)==null||s.updateBoxState(i)}async onRemoveScene(t){if(this.scenePath&&t.startsWith(this.scenePath+"/")){let i=this.pageState.index,n=this._pageState.getFullPath(i);n||(i=0,n=this._pageState.getFullPath(i)),n&&this.setFullPath(n),this.setViewFocusScenePath(),this.view&&(this.view.focusSceneIndex=i)}}emitAppSceneStateChange(t){this.appEmitter.emit("sceneStateChange",t)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(t){return(i,n)=>{var r,s,o,a;if(!!this.manager.canOperate)switch(i){case"setBoxSize":{(r=this.boxManager)==null||r.resizeBox({appId:t,width:n.width,height:n.height,skipUpdate:!1});break}case"setBoxMinSize":{(s=this.boxManager)==null||s.setBoxMinSize({appId:t,minWidth:n.minwidth,minHeight:n.minheight});break}case"setBoxTitle":{(o=this.boxManager)==null||o.setBoxTitle({appId:t,title:n.title});break}case du.destroy:{if(this.status==="destroyed")return;this.destroy(!0,!1,!0,n==null?void 0:n.error),n!=null&&n.error&&console.error(n==null?void 0:n.error);break}case"focus":{(a=this.boxManager)==null||a.focusBox({appId:this.id}),mt.emit("focus",{appId:this.id});break}}}}setScenePath(){if(!this.manager.canOperate)return;const t=this.getFullScenePath();this.manager.room&&t&&this.view&&to(this.manager.room,t)}setViewFocusScenePath(){const t=this.getFullScenePath();return t&&this.view&&ti(this.view,t),t}createView(){const t=this.viewManager.createView(this.id);return this.view$.setValue(t),this.setViewFocusScenePath(),t}get pageState(){return this._pageState.toObject()}async removeSceneByIndex(t){const i=this._pageState.getFullPath(t);if(i&&this.pageState){const n=so(t,this.pageState);return this.setSceneIndexWithoutSync(n),this.manager.dispatchInternalEvent(G.SetAppFocusIndex,{type:"app",appID:this.id,index:n}),setTimeout(()=>{io(this.manager.room,i,t)},100),!0}else return!1}setSceneIndexWithoutSync(t){this.view&&(this.view.focusSceneIndex=t)}setSceneIndex(t){if(this.view){this.view.focusSceneIndex=t;const i=this._pageState.getFullPath(t);i&&this.setFullPath(i)}}async destroy(t,i,n,r){var s,o,a,l;if(this.status!=="destroyed"){this.status="destroyed";try{await ze.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:r})}catch(u){console.error("[WindowManager]: notifyApp error",u.message,u.stack)}this.appEmitter.clearListeners(),this.sideEffectManager.flushAll(),L.emit(`destroy-${this.id}`,{error:r}),t&&((s=this.boxManager)==null||s.closeBox(this.id,n)),i&&(this.store.cleanAppAttributes(this.id),this.scenePath&&io(this.manager.room,this.scenePath)),this.appProxies.delete(this.id),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),(o=this.manager.refresher)==null||o.remove(this.id),(a=this.manager.refresher)==null||a.remove(this.stateKey),(l=this.manager.refresher)==null||l.remove(`${this.id}-fullPath`),this._prevFullPath=void 0,this.camera$.destroy(),this.size$.destroy(),this.box$.destroy()}}close(){return this.destroy(!0,!0,!1)}}class Wg{constructor(t){this.displayer=t,this.views=new Map}createView(t){const i=ju(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 ju=e=>{const t=e.views.createView();return Fg(t),t},Fg=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class Qg{constructor(t){var n;this.manager=t,this.started=!1,this.mainViewIsAddListener=!1,this.store=this.manager.store,this.sideEffectManager=new be.SideEffectManager,this.startListenWritableChange=()=>{this.sideEffectManager.add(()=>L.on("writableChange",r=>{r&&this.ensureCameraAndSize()}))},this.addCameraReaction=()=>{var r;(r=this.manager.refresher)==null||r.add(he.MainViewCamera,this.cameraReaction)},this.cameraReaction=()=>E.reaction(()=>this.mainViewCamera,r=>{r&&r.id!==this.manager.uid&&this.synchronizer.onRemoteUpdate(r,this.mainViewSize)},{fireImmediately:!0}),this.sizeChangeHandler=b.debounce(r=>{},30),this.onUpdateContainerSizeRatio=()=>{const r=this.store.getMainViewSize();this.sizeChangeHandler(r),r.id===this.manager.uid&&this.setCameraAndSize()},this.onCameraUpdatedByDevice=r=>{this.synchronizer.onLocalCameraUpdate(r);const s=this.getStageSize();s&&!b.isEqual(s,this.mainViewSize)&&this.setMainViewSize(s)},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=b.debounce(r=>{this.store.setMainViewSize(gt(Z({},r),{id:this.manager.uid}))},50),this.onCameraOrSizeUpdated=()=>{ne.emit("cameraStateChange",this.cameraState)},this.synchronizer=new Lu(r=>this.store.setMainViewCamera(gt(Z({},r),{id:this.manager.uid}))),this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),L.once("mainViewMounted").then(()=>{this.addMainViewListener(),this.start(),this.ensureCameraAndSize(),this.startListenWritableChange()}),this.sideEffectManager.add(()=>L.on("containerSizeRatioUpdate",this.onUpdateContainerSizeRatio)),this.sideEffectManager.add(()=>L.on("startReconnect",()=>{yu(this.mainView)}));const i=(n=this.manager.boxManager)==null?void 0:n.stageRect;i&&this.synchronizer.setRect(i),this.sideEffectManager.add(()=>L.on("playgroundSizeChange",r=>{this.synchronizer.setRect(r)}))}ensureCameraAndSize(){(!this.mainViewCamera||!this.mainViewSize)&&(this.manager.dispatchInternalEvent(G.InitMainViewCamera),this.setCameraAndSize())}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}get didRelease(){return b.get(this.view,["didRelease"])}moveCameraSizeByAttributes(){this.synchronizer.onRemoteUpdate(this.mainViewCamera,this.mainViewSize)}start(){this.started||(this.sizeChangeHandler(this.mainViewSize),this.addCameraListener(),this.addCameraReaction(),this.started=!0)}setCameraAndSize(){const t=this.getStageSize();if(t){const i=gt(Z({},this.mainView.camera),{id:this.manager.uid}),n=gt(Z({},t),{id:this.manager.uid});this.store.setMainViewCameraAndSize(i,n)}}get view(){return this.mainView}get cameraState(){return Z(Z({},this.view.camera),this.view.size)}createMainView(){const t=ju(this.manager.displayer),i=this.store.getMainViewScenePath();return i&&ti(t,i),this.synchronizer.setView(t),t}onReconnect(){if(this.didRelease)this.rebind();else{const t=this.store.getMainViewScenePath();this.setFocusScenePath(t)}}setFocusScenePath(t){if(t)return ti(this.view,t)}rebind(){const t=this.mainView.divElement,i=this.mainView.disableCameraTransform;this.stop(),yu(this.mainView),this.removeMainViewListener(),this.mainView=this.createMainView(),this.mainView.disableCameraTransform=i,this.mainView.divElement=t,this.addMainViewListener(),this.start()}getStageSize(){var i;const t=(i=this.manager.boxManager)==null?void 0:i.stageRect;if(t)return{width:t.width,height:t.height}}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.onCameraOrSizeUpdated),this.view.callbacks.on("onSizeUpdated",this.onCameraOrSizeUpdated)}removeCameraListener(){this.view.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.off("onCameraUpdated",this.onCameraOrSizeUpdated),this.view.callbacks.off("onSizeUpdated",this.onCameraOrSizeUpdated)}stop(){var t,i;this.removeCameraListener(),(t=this.manager.refresher)==null||t.remove(he.MainViewCamera),(i=this.manager.refresher)==null||i.remove(he.MainViewSize),this.started=!1}destroy(){this.removeMainViewListener(),this.stop(),this.sideEffectManager.flushAll()}}class Zg{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=>{ne.emit("canRedoStepsChange",i)},this.onCanUndoStepsUpdate=i=>{ne.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)},L.on("focusedChange",i=>{this.disposePrevFocusViewRedoUndoListeners(i.prev),setTimeout(()=>{this.addRedoUndoListeners(i.focused)},0)}),L.on("rootDirRemoved",()=>{this.disposePrevFocusViewRedoUndoListeners(t.focus()),this.addRedoUndoListeners(t.focus())}),this.addRedoUndoListeners(t.focus())}destroy(){this.disposePrevFocusViewRedoUndoListeners(this.context.focus())}}class Gg{constructor(t){this.windowManger=t,this.appProxies=new Map,this.appStatus=new Map,this.store=Hg,this.isReplay=this.windowManger.isReplay,this.mainViewScenesLength=0,this.callbacksNode=null,this.appCreateQueue=new ug,this.sideEffectManager=new be.SideEffectManager,this.sceneState=null,this.rootDirRemoving=!1,this.onRemoveScenes=async i=>{var r,s;const{scenePath:n}=i;if(n===ke){await this.onRootDirRemoved(),this.dispatchInternalEvent(G.RootDirRemoved);return}if(Ng(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&&this.setMainViewScenePath(`${ke}${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(ke,{onAddScene:this.onSceneChange,onRemoveScene:async(n,r)=>{await this.onSceneChange(n),L.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=so(i,this.windowManger.pageState);this.setSceneIndexWithoutSync(n),this.dispatchInternalEvent(G.SetAppFocusIndex,{type:"main",index:n});const r=(s=this.callbacksNode)==null?void 0:s.scenes[i];return setTimeout(()=>{r&&io(this.room,`${ke}${r}`,i)},100),new Promise((o,a)=>{L.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(`${ke}${n}`)},this.onSceneChange=i=>(this.mainViewScenesLength=i.scenes.length,this.updateSceneState(i),this.emitMainViewScenesChange(this.mainViewScenesLength)),this.emitMainViewScenesChange=i=>Promise.all([ne.emit("mainViewScenesLengthChange",i),L.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:`${ke}${r}`,contextPath:i.path,index:n,scenes:i.scenes.map(s=>({name:s})),sceneName:r},ne.emit("sceneStateChange",this.sceneState)},this.onBoxMove=i=>{this.dispatchInternalEvent(G.AppMove,i),this.store.updateAppState(i.appId,Pe.Position,{x:i.x,y:i.y})},this.onBoxResize=i=>{i.width&&i.height&&(this.dispatchInternalEvent(G.AppResize,i),this.store.updateAppState(i.appId,Pe.Size,{width:i.width,height:i.height}))},this.onBoxFocus=i=>{this.windowManger.safeSetAttributes({focus:i.appId})},this.onBoxClose=i=>{const n=this.appProxies.get(i.appId);n&&n.destroy(!1,!0,!0,i.error)},this.onBoxStateChange=i=>{this.dispatchInternalEvent(G.AppBoxStateChange,i)},this.addAppsChangeListener=()=>{var i;(i=this.refresher)==null||i.add("apps",()=>Pu(()=>this.attributes.apps,()=>{this.attributesUpdateCallback(this.attributes.apps)}))},this.addAppCloseListener=()=>{var i;(i=this.refresher)==null||i.add("appsClose",()=>zg(this.attributes.apps,()=>{this.onAppDelete(this.attributes.apps)}))},this.onMainViewIndexChange=i=>{i!==void 0&&this._prevSceneIndex!==i&&(ne.emit("mainViewSceneIndexChange",i),L.emit("changePageState"),this.callbacksNode&&this.updateSceneState(this.callbacksNode),this._prevSceneIndex=i)},this.onFocusChange=i=>{var n;this._prevFocused!==i&&(ne.emit("focusedChange",i),L.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&&ze.notifyApp(r.kind,"focus",{appId:i})},0)))},this.attributesUpdateCallback=b.debounce(i=>this._attributesUpdateCallback(i),100),this.onRegisteredChange=i=>{!i||Object.entries(i).forEach(([n,r])=>{ze.appClasses.has(n)||ze.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=>{const n=i.sceneState;if(n){const r=n.scenePath;this.appProxies.forEach(s=>{s.scenePath&&r.startsWith(s.scenePath)&&(s.emitAppSceneStateChange(n),s.setFullPath(r))})}this.appProxies.forEach(r=>{r.appEmitter.emit("roomStateChange",i)}),i.roomMembers&&L.emit("roomMembersChange",this.members),L.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()}),n===!0?(this.mainView.disableCameraTransform=!1,this.room&&this.room.disableSerialization===!0&&(this.room.disableSerialization=!1)):this.mainView.disableCameraTransform=!0,L.emit("writableChange",n)},this.updateSceneIndex=()=>{const i=this.store.getMainViewScenePath(),n=no(i),r=ii(this.displayer)[n];if(r.length){const s=i.replace(n,"").replace("/",""),o=r.findIndex(a=>a.name===s);b.isInteger(o)&&o>=0&&this.safeSetAttributes({_mainSceneIndex:o})}},this.updateRootDirRemoving=i=>{this.rootDirRemoving=i},this.displayer=t.displayer,this.store.setContext({getAttributes:()=>this.attributes,safeSetAttributes:i=>this.safeSetAttributes(i),safeUpdateAttributes:(i,n)=>this.safeUpdateAttributes(i,n)}),this.mainViewProxy=new Qg(this),this.viewManager=new Wg(this.displayer),this.appListeners=new Pg(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=Gf,this.refresher.setRoom(this.room),this.refresher.setContext({emitter:L}),this.sideEffectManager.add(()=>()=>{var i,n,r;this.appCreateQueue.destroy(),this.mainViewProxy.destroy(),(i=this.refresher)==null||i.destroy(),this.viewManager.destroy(),(n=this.boxManager)==null||n.destroy(),(r=this.callbacksNode)==null||r.dispose()}),L.once("onCreated").then(()=>this.onCreated()),L.on("onReconnected",()=>this.onReconnected()),E.isPlayer(this.displayer)&&(L.on("seekStart",this.onPlayerSeekStart),L.on("seek",this.onPlayerSeekDone)),L.on("removeScenes",this.onRemoveScenes),L.on("setReadonly",this.onReadonlyChanged),this.createRootDirScenesCallback(),ze.setSyncRegisterApp(i=>{this.safeUpdateAttributes([he.Registered,i.kind],i)})}async onRootDirRemoved(t=!0){this.setMainViewScenePath(fu),this.createRootDirScenesCallback();for(const[i,n]of this.appProxies.entries())n.view&&await this.closeApp(i,t);this.mainViewProxy.rebind(),L.emit("rootDirRemoved"),this.updateRootDirRemoving(!1)}get eventName(){return E.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return E.isRoom(this.displayer)?this.displayer:void 0}get mainView(){return this.mainViewProxy.view}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 members(){return Bg(this.displayer.state.roomMembers)}getMainViewSceneDir(){const t=this.store.getMainViewScenePath();if(t)return no(t);throw new Error("[WindowManager]: mainViewSceneDir not found")}async onCreated(){var t,i,n,r,s,o;if(await this.attributesUpdateCallback(this.attributes.apps),L.emit("updateManagerRect"),mt.on("move",this.onBoxMove),mt.on("resize",this.onBoxResize),mt.on("focus",this.onBoxFocus),mt.on("close",this.onBoxClose),mt.on("boxStateChange",this.onBoxStateChange),this.addAppsChangeListener(),this.addAppCloseListener(),(t=this.refresher)==null||t.add("maximized",()=>E.autorun(()=>{var l;const a=this.attributes.maximized;(l=this.boxManager)==null||l.setMaximized(Boolean(a))})),(i=this.refresher)==null||i.add("minimized",()=>E.autorun(()=>{const a=this.attributes.minimized;this.onMinimized(a)})),(n=this.refresher)==null||n.add("mainViewIndex",()=>E.autorun(()=>{const a=b.get(this.attributes,"_mainSceneIndex");this.onMainViewIndexChange(a)})),(r=this.refresher)==null||r.add("focusedChange",()=>E.autorun(()=>{const a=b.get(this.attributes,"focus");this.onFocusChange(a)})),(s=this.refresher)==null||s.add("registeredChange",()=>E.autorun(()=>{const a=b.get(this.attributes,he.Registered);this.onRegisteredChange(a)})),!this.attributes.apps||Object.keys(this.attributes.apps).length===0){const a=this.store.getMainViewScenePath();if(!a)return;this.resetScenePath(a)}this.displayerWritableListener(!((o=this.room)!=null&&o.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener),this._prevFocused=this.attributes.focus,this.sideEffectManager.add(()=>{const a=new Zg({mainView:()=>this.mainViewProxy.view,focus:()=>this.attributes.focus,getAppProxy:l=>this.appProxies.get(l)});return()=>a.destroy()})}async _attributesUpdateCallback(t){if(t&&Ie.container){const i=Object.keys(t);i.length===0&&this.appCreateQueue.emitReady();const n=i.map(r=>({id:r,createdAt:t[r].createdAt}));for(const{id:r}of b.orderBy(n,"createdAt","asc"))if(!this.appProxies.has(r)&&!this.appStatus.has(r)){const s=t[r];try{if(!this.attributes[r])throw new Error("appAttributes is undefined");this.appCreateQueue.push(()=>(this.appStatus.set(r,eo.StartCreate),this.baseInsertApp({kind:s.kind,options:s.options,isDynamicPPT:s.isDynamicPPT},r,!1))),this.focusByAttributes(t)}catch(o){console.warn("[WindowManager]: Insert App Error",o)}}}}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(),L.emit("mainViewMounted")}setMainViewFocusPath(t){var n;const i=t||this.store.getMainViewScenePath();if(i)return ti(this.mainView,i),((n=this.mainView)==null?void 0:n.focusScenePath)===i}resetScenePath(t){this.displayer.state.sceneState.scenePath!==t&&to(this.room,t)}async addApp(t,i){Ti("addApp",t);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 Mg(t.kind);this.appStatus.set(n,eo.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;mt.emit("move",{appId:t.id,x:r==null?void 0:r.intrinsicX,y:r==null?void 0:r.intrinsicY}),this.store.updateAppState(t.id,Pe.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&&n.destroy(!0,i,!1)}async baseInsertApp(t,i,n,r){if(this.appProxies.has(i)){console.warn("[WindowManager]: app duplicate exists and cannot be created again");return}const s=new oo(t,this,i,n);if(s)return await s.baseInsertApp(r),this.appStatus.delete(i),s;throw this.appStatus.delete(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(no(t)!==ke)throw new Error('[WindowManager]: main view scenePath must in root dir "/"');if(i===E.ScenePathType.None)throw new Error(`[WindowManager]: ${t} not valid scene`);if(i===E.ScenePathType.Page)await this._setMainViewScenePath(t);else if(i===E.ScenePathType.Dir){const r=Eg(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=`${ke}${n}`;if(n)this.setMainViewFocusPath(r)&&(this.store.setMainViewScenePath(r),this.safeSetAttributes({_mainSceneIndex:t}),this.dispatchSetMainViewScenePath(r));else throw new Error(`[WindowManager]: ${t} not valid index`)}}dispatchSetMainViewScenePath(t){this.dispatchInternalEvent(G.SetMainViewScenePath,{nextScenePath:t}),to(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(){const i=Array.from(this.appProxies.values()).map(n=>n.onReconnected());this.mainViewProxy.onReconnect(),await Promise.all(i)}notifyContainerRectUpdate(t){this.appProxies.forEach(i=>{i.appEmitter.emit("containerRectUpdate",t)})}dispatchInternalEvent(t,i){this.safeDispatchMagixEvent(Ks,{eventName:t,payload:i})}destroy(){this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),mt.clearListeners(),L.clearListeners(),this.appProxies.size&&this.appProxies.forEach(t=>{t.destroy(!0,!1,!0)}),ne.clearListeners(),this.sideEffectManager.flushAll(),this._prevFocused=void 0,this._prevSceneIndex=void 0}}/*! *****************************************************************************
2
+ ;return ${t}`)();return typeof i=="undefined"&&(i=window[t]),i},xg=async(e,t,i)=>{const n=i||vg+t;ne.emit("loadApp",{kind:t,status:"start"});try{const r=await yg(e);if(!r||r.length===0){ne.emit("loadApp",{kind:t,status:"failed",reason:"script is empty."});return}try{const s=wu(r,n);return ne.emit("loadApp",{kind:t,status:"success"}),s}catch(s){if(s.message.includes("Can only have one anonymous define call per script file")){const o=window.define;typeof o=="function"&&o.amd&&delete o.amd;const a=wu(r,n);return ne.emit("loadApp",{kind:t,status:"success"}),a}ne.emit("loadApp",{kind:t,status:"failed",reason:s.message})}}catch(r){ne.emit("loadApp",{kind:t,status:"failed",reason:r.message})}};async function Sg(e,t){const{timeout:i=1e4}=t,n=new AbortController,r=setTimeout(()=>n.abort(),i),s=await fetch(e,gt(Z({},t),{signal:n.signal,headers:{"content-type":"text/plain"}}));return clearTimeout(r),s}class Cg{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()=>{let r=await xg(i,t.kind,t.name);if(r)return r.__esModule&&(r=r.default),r;throw new Error(`[WindowManager]: load remote script failed, ${i}`)},this.syncRegisterApp&&this.syncRegisterApp({kind:t.kind,src:i,name:t.name})):typeof i=="function"?n=i: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 Pt.default;this.kindEmitters.set(t,i)}return this.kindEmitters.get(t)}}const ze=new Cg,Mg=async e=>{var i,n;const t=await((i=ze.appClasses.get(e))==null?void 0:i());return t&&((n=t.config)==null?void 0:n.singleton)?e:`${e}-${ng.v4().replace("-","").slice(0,8)}`},ti=(e,t)=>{if(e.focusScenePath!==t)return e.focusScenePath=t,e},yu=e=>{e.didRelease||e.release()},to=(e,t)=>{if(e&&e.isWritable&&e.state.sceneState.scenePath!==t){const i=t==="/"?"":t;e.setScenePath(i)}},Ig=(e,t,i)=>{var n;if(e&&t){const s=(n=ii(e)[t])==null?void 0:n[i];if(s)return`${t}/${s.name}`}},io=(e,t,i)=>{e&&e.scenePathType(t)!==E.ScenePathType.None&&e.removeScenes(t,i)},bg=(e,t)=>{L.once(e).then(t)};b.debounce((e,t)=>{e.emit("mainViewModeChange",t)},200);const Eg=(e,t,i=0)=>{const n=ii(e)[t];if(!n)return;const r=n[i];if(!r)return;const s=r.name;return t===ke?`/${s}`:`${t}/${s}`},ii=e=>e.entireScenes(),ni=(e,t,i,n)=>e==null?void 0:e.putScenes(t,i,n),Ag=e=>e.startsWith("/"),no=e=>{const t=e.split("/");t.pop();let i=t.join("/");return i===""&&(i="/"),i},Tg=e=>e.endsWith("/")?e.slice(0,-1):e,xu=e=>{const t=e.split(".").map(i=>i.padStart(2,"0")).join("");return parseInt(t)},Su=e=>new Promise(t=>setTimeout(t,e)),Ng=e=>e.split("").reduce((i,n)=>(n===ke&&(i+=1),i),0)===1;class Pg{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 G.AppMove:{this.appMoveHandler(n.payload);break}case G.AppResize:{this.appResizeHandler(n.payload);break}case G.AppBoxStateChange:{this.boxStateChangeHandler(n.payload);break}case G.SetMainViewScenePath:{this.setMainViewScenePathHandler(n.payload);break}case G.MoveCamera:{this.moveCameraHandler(n.payload);break}case G.MoveCameraToContain:{this.moveCameraToContainHandler(n.payload);break}case G.CursorMove:{this.cursorMoveHandler(n.payload);break}case G.RootDirRemoved:{this.rootDirRemovedHandler();break}case G.Refresh:{this.refreshHandler();break}case G.InitMainViewCamera:{this.initMainViewCameraHandler();break}case G.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=>{ne.emit("boxStateChange",i)},this.setMainViewScenePathHandler=({nextScenePath:i})=>{ti(this.manager.mainView,i),ne.emit("mainViewScenePathChange",i)},this.moveCameraHandler=i=>{b.isEqual(b.omit(i,["animationMode"]),Z({},this.manager.mainView.camera))||this.manager.mainView.moveCamera(i)},this.moveCameraToContainHandler=i=>{this.manager.mainView.moveCameraToContain(i)},this.cursorMoveHandler=i=>{L.emit("cursorMove",i)},this.rootDirRemovedHandler=()=>{this.manager.createRootDirScenesCallback(),this.manager.mainViewProxy.rebind(),L.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(Ks,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(Ks,this.mainMagixEventListener)}}class Cu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class kg extends Error{constructor(t){super(`[WindowManager]: app ${t} need register or provide src`)}}class Xe extends Error{constructor(){super(...arguments);this.message="[WindowManager]: AppManager must be initialized"}}class Mu extends Error{constructor(t){super(`[WindowManager]: white-web-sdk version must large than ${t}`)}}class Iu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: kind must be a valid string"}}class bu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: box need created"}}class Eu extends Error{constructor(){super(...arguments);this.message='[WindowManager]: ScenePath should start with "/"'}}class Au extends Error{constructor(){super(...arguments);this.message="[WindowManager]: boxManager not found"}}class Tu extends Error{constructor(){super(...arguments);this.message="[WindowManager]: room phase only Connected can be bindContainer"}}const Nu=e=>(t,i)=>{if(t!==void 0)if(E.listenUpdated){const n=r=>{r.map(o=>o.kind).includes(e)&&i()};return E.listenUpdated(t,n),i(),()=>E.unlistenUpdated(t,n)}else return E.reaction(()=>t,()=>{i()},{fireImmediately:!0})},Pu=(e,t,i)=>{let n=null;const r=E.reaction(e,()=>{n&&(n(),n=null);const s=e();b.isObject(s)?(n=()=>E.unlistenUpdated(s,t),E.listenUpdated(s,t)):i==null||i(s)},{fireImmediately:!0});return()=>{n==null||n(),r()}},zg=Nu(E.UpdateEventKind.Removed);Nu(E.UpdateEventKind.Inserted);const ro=Object.keys;function ku(e){return Boolean(b.has(e,"__isRef"))}function Dg(e){return{k:be.genUID(),v:e,__isRef:!0}}class Lg{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 Je="_WM-STORAGE_";class zu{constructor(t,i,n){if(this._sideEffect=new be.SideEffectManager,this._destroyed=!1,this._refMap=new WeakMap,this._lastValue=new Map,this.onStateChanged=new Lg,n&&!b.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.isWritable&&(this.id===null?t.isAddApp&&n&&this.setState(n):(r===this._state||!b.isObject(r))&&(b.get(this._context.getAttributes(),[Je])||this._context.updateAttributes([Je],{}),this._context.updateAttributes([Je,this.id],this._state),n&&this.setState(n))),ro(r).forEach(s=>{if(!(this.id===null&&s===Je))try{const o=b.isObject(r[s])?JSON.parse(JSON.stringify(r[s])):r[s];ku(o)?(this._state[s]=o.v,b.isObject(o.v)&&this._refMap.set(o.v,o)):this._state[s]=o}catch(o){console.error(o)}}),this._sideEffect.addDisposer(Pu(()=>this.id===null?t.getAttributes():b.get(t.getAttributes(),[Je,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(ro(t).reduce((i,n)=>(b.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.isWritable){console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`),t);return}const i=ro(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(b.isObject(r)){let o=this._refMap.get(r);o||(o=Dg(r),this._refMap.set(r,o)),s=o}this._setRawState(n,s)}})}emptyStorage(){if(!(b.size(this._state)<=0)){if(this._destroyed){console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));return}if(!this._context.isWritable){console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));return}this.setState(b.mapValues(this._state,b.noop))}}deleteStorage(){if(this.id===null)throw new Error("Cannot delete main Storage");if(!this._context.isWritable){console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));return}this.destroy(),this._context.updateAttributes([Je,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:b.get(this._context.getAttributes(),[Je,this.id],t)}_setRawState(t,i){if(this.id===null){if(t===Je)throw new Error(`Cannot set attribute internal filed "${Je}"`);return this._context.updateAttributes([t],i)}else return this._context.updateAttributes([Je,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===Je)continue;const a=b.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:{b.has(this._state,o)&&(l=this._state[o],delete this._state[o]),n[o]={oldValue:l};break}default:{let u=a;if(ku(a)){const{k:c,v:d}=a,m=this._state[o];b.isObject(m)&&((i=this._refMap.get(m))==null?void 0:i.k)===c?u=m:(u=d,b.isObject(d)&&this._refMap.set(d,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 jg{constructor(t,i,n){this.appContext=t,this.appProxy=i,this.removeViewWrapper=n,this.nextPage=async()=>{const s=this.pageState.index+1;return this.jumpPage(s)},this.prevPage=async()=>{const s=this.pageState.index-1;return this.jumpPage(s)},this.jumpPage=async s=>s<0||s>=this.pageState.length?(console.warn(`[WindowManager]: index ${s} out of range`),!1):(this.appProxy.setSceneIndex(s),!0),this.addPage=async s=>{const o=s==null?void 0:s.after,a=s==null?void 0:s.scene,l=this.appProxy.scenePath;if(!!l)if(o){const u=this.pageState.index+1;ni(this.appContext.room,l,[a||{}],u)}else ni(this.appContext.room,l,[a||{}])},this.removePage=async s=>{const o=s===void 0?this.pageState.index:s;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 ${s} out of range`),!1):this.appProxy.removeSceneByIndex(o)};const r=new A.Val(i.pageState);this.pageState$=r,i.appEmitter.on("pageStateChange",s=>{r.setValue(s)})}get view(){return this.appContext.view}get pageState(){return this.pageState$.value}moveCamera(t){this.appProxy.moveCamera(t)}destroy(){this.removeViewWrapper()}}const Rg=e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");return i.className="netless-window-manager-main-view",t.appendChild(i),e.appendChild(t),{playground:t,mainViewElement:i}},Vg=()=>{if(xu(E.WhiteVersion)<xu(pu))throw new Mu(pu)},Du=(e,t)=>{const i=e==null?void 0:e.state.roomMembers;return i==null?void 0:i.find(n=>{var r;return((r=n.payload)==null?void 0:r.uid)===t})},Bg=e=>e.map(t=>{var i;return Z({uid:((i=t.payload)==null?void 0:i.uid)||""},t)});class Og{constructor(t,i,n,r,s){this.manager=t,this.boxManager=i,this.appId=n,this.appProxy=r,this.appOptions=s,this.mobxUtils={autorun:E.autorun,reaction:E.reaction,toJS:E.toJS},this.objectUtils={listenUpdated:E.listenUpdated,unlistenUpdated:E.unlistenUpdated,listenDisposed:E.listenDisposed,unlistenDisposed:E.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,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.createWhiteBoardView=o=>{var c;if(this.whiteBoardView)return this.whiteBoardView;let a=this.view;a||(a=this.appProxy.createAppDir());const l=document.createElement("div");l.className="window-manager-view-wrapper",(c=this.box.$content.parentElement)==null||c.appendChild(l);const u=()=>{var d;(d=this.box.$content.parentElement)==null||d.removeChild(l)};return a.divElement=l,this.isAddApp&&this.initPageSize(o),this.whiteBoardView=new jg(this,this.appProxy,u),this.whiteBoardView},this.initPageSize=o=>{if(!b.isNumber(o)||!this.appProxy.scenePath||this.appProxy.pageState.length>=o)return;if(o<=0||o>=mu)throw Error(`[WindowManager]: size ${o} muse be in range [1, ${mu}]`);const a=o-this.appProxy.pageState.length,l=this.appProxy.pageState.length,u=new Array(a).fill({}).map((c,d)=>({name:`${l+d+1}`}));ni(this.room,this.appProxy.scenePath,u)},this.getInitScenePath=()=>this.manager.getAppInitPath(this.appId),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.room)==null||a.setScenePath(o))},this.getAppOptions=()=>typeof this.appOptions=="function"?this.appOptions():this.appOptions,this.createStorage=(o,a)=>{const l=new zu(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.emitter=r.appEmitter,this.isAddApp=r.isAddApp}get displayer(){return this.manager.displayer}get view(){return this.appProxy.view}get isWritable(){return this.manager.canOperate}get box(){const t=this.boxManager.getBox(this.appId);if(t)return t;throw new bu}get room(){return this.manager.room}get members(){return this.manager.members}get memberState(){const t=Du(this.room,this.manager.uid);if(!t)throw new Error(`Member ${this.manager.uid} not found.`);return Z({uid:this.manager.uid},t)}get storage(){return this._storage||(this._storage=new zu(this)),this._storage}}class _g{constructor(t){this.params=t,this.sceneNode=null,this.createSceneNode=r=>(this.scenePath=r,this.sceneNode&&this.sceneNode.dispose(),this.sceneNode=this.params.displayer.createScenesCallback(r,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}),this.sceneNode),this.onSceneChange=()=>{this.params.notifyPageStateChange()};const{displayer:i,scenePath:n}=this.params;this.view=this.params.view,n&&(this.scenePath=n,this.sceneNode=i.createScenesCallback(n,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}))}setView(t){this.view=t}getFullPath(t){var n;const i=(n=this.sceneNode)==null?void 0:n.scenes;if(this.scenePath&&i){const r=i[t];if(r)return`${this.scenePath}/${r}`}}toObject(){var t,i;return{index:((t=this.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()}}class Lu{constructor(t){this.saveCamera=t,this.onRemoteUpdate=b.throttle((i,n)=>{if(this.remoteCamera=i,this.remoteSize=n,this.remoteSize&&this.rect){let r;n.width<n.height?r=this.rect.width/n.width:r=this.rect.height/n.height;const s=i.scale*r,o=()=>{var a;return(a=this.view)==null?void 0:a.moveCamera({centerX:i.centerX,centerY:i.centerY,scale:s,animationMode:E.AnimationMode.Immediately})};b.delay(o,50)}},50),this.onLocalSizeUpdate=i=>{if(this.rect&&this.view){let n;i.width<i.height?n=this.rect.width/i.width:n=this.rect.height/i.height;const r=this.view.camera.scale/n;this.view.moveCamera({scale:r,animationMode:E.AnimationMode.Immediately})}}}setRect(t){this.rect=t,this.remoteCamera&&this.remoteSize&&this.onRemoteUpdate(this.remoteCamera,this.remoteSize)}setView(t){this.view=t}onLocalCameraUpdate(t){this.saveCamera(t),this.remoteCamera=t}}class Ug{constructor(t){this.appProxy=t,this.sem=new be.SideEffectManager,this.bindView=n=>{!n||(this.synchronizer.setView(n),this.sem.add(()=>(n.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),()=>n.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice))))},this.onCameraUpdatedByDevice=n=>{var s;this.synchronizer.onLocalCameraUpdate(n);const r=(s=this.appProxy.box)==null?void 0:s.contentStageRect;if(r){const o={width:r.width,height:r.height,id:this.appProxy.uid};b.isEqual(o,this.appProxy.size$.value)||this.appProxy.storeSize(o)}},this.synchronizer=new Lu(n=>{this.appProxy.storeCamera(Z({id:this.appProxy.uid},n))}),this.bindView(t.view),this.sem.add(()=>this.appProxy.camera$.subscribe(n=>{const r=this.appProxy.size$.value;n&&r&&this.synchronizer.onRemoteUpdate(n,r)}));const i=this.appProxy.box;i&&i.contentStageRect&&(this.synchronizer.setRect(i.contentStageRect),this.sem.add(()=>i._contentStageRect$.subscribe(n=>{n&&this.synchronizer.setRect(n)})),this.appProxy.size$.value||this.appProxy.storeSize({id:this.appProxy.uid,width:i.contentStageRect.width,height:i.contentStageRect.height}))}destroy(){this.sem.flushAll()}}const mt=new Pt.default,so=(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};var he=(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.Camera="camera",e.Size="size",e))(he||{});class $g{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 b.get(this.attributes,["apps"])}get focus(){return b.get(this.attributes,["focus"])}getAppAttributes(t){return b.get(this.apps(),[t])}getAppState(t){return b.get(this.apps(),[t,"state"])}getMaximized(){return b.get(this.attributes,["maximized"])}getMinimized(){return b.get(this.attributes,["minimized"])}setupAppAttributes(t,i,n){this.attributes.apps||this.context.safeSetAttributes({apps:{}});const s=["scenePath","title"];n||s.push("scenes");const o=b.pick(t.options,s),a={kind:t.kind,options:o,isDynamicPPT:n};typeof t.src=="string"&&(a.src=t.src),a.createdAt=Date.now(),this.context.safeUpdateAttributes(["apps",i],a),this.context.safeUpdateAttributes(["apps",i,"state"],{[Pe.Size]:{},[Pe.Position]:{},[Pe.SceneIndex]:0})}updateAppState(t,i,n){b.get(this.attributes,["apps",t,"state"])&&this.context.safeUpdateAttributes(["apps",t,"state",i],n)}updateAppAttributes(t,i,n){this.context.safeUpdateAttributes(["apps",t,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[Pe.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 b.get(this.attributes,["mainViewCamera"])}getMainViewSize(){return b.get(this.attributes,["mainViewSize"])}setMainViewCamera(t){this.context.safeSetAttributes({mainViewCamera:Z({},t)})}setMainViewSize(t){this.context.safeSetAttributes({mainViewSize:Z({},t)})}setMainViewCameraAndSize(t,i){this.context.safeSetAttributes({mainViewCamera:Z({},t),mainViewSize:Z({},i)})}updateCursor(t,i){b.get(this.attributes,["cursors"])||this.context.safeUpdateAttributes(["cursors"],{}),b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"position"],i)}updateCursorState(t,i){b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"cursorState"],i)}getCursorState(t){return b.get(this.attributes,["cursors",t,"cursorState"])}cleanCursor(t){this.context.safeUpdateAttributes(["cursors",t],void 0)}setMainViewFocusPath(t){const i=this.getMainViewScenePath();i&&ti(t,i)}}const Hg=new $g({getAttributes:()=>{throw new Error("getAttributes not implemented")},safeSetAttributes:()=>{throw new Error("safeSetAttributes not implemented")},safeUpdateAttributes:()=>{throw new Error("safeUpdateAttributes not implemented")}}),Ti=(...e)=>{Ie.debug&&console.log("[WindowManager]:",...e)};class oo{constructor(t,i,n,r){var s;this.params=t,this.manager=i,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.store=this.manager.store,this.uid=this.manager.uid,this.status="normal",this.sideEffectManager=new be.SideEffectManager,this.camera$=new A.Val(void 0),this.size$=new A.Val(void 0),this.box$=new A.Val(void 0),this.view$=new A.Val(void 0),this.getAppInitState=o=>{var p,h;const a=this.store.getAppState(o);if(!a)return;const l=a==null?void 0:a[Pe.Position],u=this.store.focus,c=a==null?void 0:a[Pe.Size],d=a==null?void 0:a[Pe.SceneIndex],m=(p=this.attributes)==null?void 0:p.maximized,w=(h=this.attributes)==null?void 0:h.minimized,y=a==null?void 0:a.zIndex;let M={maximized:m,minimized:w,zIndex:y};return l&&(M=gt(Z({},M),{id:o,x:l.x,y:l.y})),u===o&&(M=gt(Z({},M),{focus:!0})),c&&(M=gt(Z({},M),{width:c.width,height:c.height})),d&&(M=gt(Z({},M),{sceneIndex:d})),M},this.appAttributesUpdateListener=o=>{var a,l,u;(a=this.manager.refresher)==null||a.add(o,()=>E.autorun(()=>{const c=this.manager.attributes[o];c&&this.appEmitter.emit("attributesUpdate",c)})),(l=this.manager.refresher)==null||l.add(this.stateKey,()=>E.autorun(()=>{var d,m,w;const c=(d=this.appAttributes)==null?void 0:d.state;(c==null?void 0:c.zIndex)>0&&c.zIndex!==((m=this.box)==null?void 0:m.zIndex)&&((w=this.boxManager)==null||w.setZIndex(o,c.zIndex))})),(u=this.manager.refresher)==null||u.add(`${o}-fullPath`,()=>E.autorun(()=>{var d;const c=(d=this.appAttributes)==null?void 0:d.fullPath;this.setFocusScenePathHandler(c),this._prevFullPath!==c&&(this.notifyPageStateChange(),this._prevFullPath=c)}))},this.setFocusScenePathHandler=b.debounce(o=>{var a;this.view&&o&&o!==((a=this.view)==null?void 0:a.focusScenePath)&&ti(this.view,o)},50),this.notifyPageStateChange=b.debounce(()=>{this.pageState&&this.appEmitter.emit("pageStateChange",this.pageState)},50),this.storeCamera=o=>{this.store.updateAppAttributes(this.id,he.Camera,o)},this.storeSize=o=>{this.store.updateAppAttributes(this.id,he.Size,o)},this.moveCamera=o=>{if(!this.camera$.value)return;const a=Z(Z({},this.camera$.value),o);this.storeCamera(a)},this.kind=t.kind,this.id=n,this.appScenePath=`/${this.id}-app-dir`,this.stateKey=`${this.id}_state`,this.appProxies.set(this.id,this),this.appEmitter=new Pt.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=r,this.initScenes(),(s=this.params.options)!=null&&s.scenePath&&this.createView(),this.scenePath||(this.scenePath=this.appScenePath),this._pageState=new _g({displayer:this.manager.displayer,scenePath:this.scenePath,view:this.view,notifyPageStateChange:this.notifyPageStateChange}),this.sideEffectManager.add(()=>()=>this._pageState.destroy()),this.sideEffectManager.add(()=>L.on("roomMembersChange",o=>{this.appEmitter.emit("roomMembersChange",o)})),this.camera$.setValue(E.toJS(this.appAttributes.camera)),this.size$.setValue(E.toJS(this.appAttributes.size)),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-camera`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.camera},o=>{o&&o.id!==this.uid&&this.camera$.setValue(E.toJS(o))}))),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-size`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.size},o=>{o&&o.id!==this.uid&&this.size$.setValue(E.toJS(o))}))),A.combine([this.box$,this.view$]).subscribe(([o,a])=>{if(o&&a){const l=new Ug(this);this.appViewSync=l,this.sideEffectManager.add(()=>()=>l.destroy())}})}createAppDir(){const t=this.scenePath||this.appScenePath;this._pageState.createSceneNode(t)||(ni(this.manager.room,t,[{name:"1"}]),this._pageState.createSceneNode(t),this.setSceneIndex(0)),this.scenes=ii(this.manager.displayer)[t];const n=this.createView();return this._pageState.setView(n),n}initScenes(){var i;const t=this.params.options;t&&(this.scenePath=t.scenePath,((i=this.appAttributes)==null?void 0:i.isDynamicPPT)&&this.scenePath?this.scenes=ii(this.manager.displayer)[this.scenePath]:this.scenes=t.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get viewIndex(){var t;return(t=this.view)==null?void 0:t.focusSceneIndex}get isWritable(){var t;return this.manager.canOperate&&!((t=this.box)!=null&&t.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}getFullScenePath(){if(this.scenePath)return b.get(this.appAttributes,[he.FullPath])||this.getFullScenePathFromScenes()}getFullScenePathFromScenes(){const t=b.get(this.appAttributes,["state","SceneIndex"],0),i=Ig(this.manager.room,this.scenePath,t);return i&&this.setFullPath(i),i}setFullPath(t){this.store.updateAppAttributes(this.id,he.FullPath,t)}async baseInsertApp(t=!1){var s;const i=this.params;if(!i.kind)throw new Error("[WindowManager]: kind require");const n=await((s=ze.appClasses.get(i.kind))==null?void 0:s()),r=ze.registered.get(i.kind);if(n)await this.setupApp(this.id,t,n,i.options,r==null?void 0:r.appOptions);else throw new Error(`[WindowManager]: app load failed ${i.kind} ${i.src}`);return L.emit("updateManagerRect"),{appId:this.id,app:n}}get box(){return this.box$.value}async setupApp(t,i,n,r,s){var a;if(Ti("setupApp",t,n,r),!this.boxManager)throw new Au;const o=new Og(this.manager,this.boxManager,t,this,s);this.appContext=o;try{L.once(`${t}${G.WindowCreated}`).then(async()=>{var c;let u;i||(u=this.getAppInitState(t),(c=this.boxManager)==null||c.updateBoxState(u)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(t),this.setViewFocusScenePath(),setTimeout(async()=>{const d=await n.setup(o);this.appResult=d,ze.notifyApp(this.kind,"created",{appId:t,result:d}),this.fixMobileSize()},gu)});const l=(a=this.boxManager)==null?void 0:a.createBox({appId:t,app:n,options:r,canOperate:this.manager.canOperate,smartPosition:this.isAddApp});this.box$.setValue(l),this.isAddApp&&this.box&&(this.store.updateAppState(t,Pe.ZIndex,this.box.zIndex),this.boxManager.focusBox({appId:t},!1))}catch(l){throw console.error(l),new Error(`[WindowManager]: app setup error: ${l.message}`)}}fixMobileSize(){var i,n;const t=(i=this.boxManager)==null?void 0:i.getBox(this.id);t&&((n=this.boxManager)==null||n.resizeBox({appId:this.id,width:t.intrinsicWidth+.001,height:t.intrinsicHeight+.001,skipUpdate:!0}))}async onSeek(t){var n;this.appEmitter.emit("seek",t).catch(r=>{console.log(`[WindowManager]: emit seek error: ${r.message}`)});const i=this.getAppInitState(this.id);(n=this.boxManager)==null||n.updateBoxState(i)}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 i=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const n=this.params;await new oo(n,this.manager,this.id,this.isAddApp).baseInsertApp(!0),(s=this.boxManager)==null||s.updateBoxState(i)}async onRemoveScene(t){if(this.scenePath&&t.startsWith(this.scenePath+"/")){let i=this.pageState.index,n=this._pageState.getFullPath(i);n||(i=0,n=this._pageState.getFullPath(i)),n&&this.setFullPath(n),this.setViewFocusScenePath(),this.view&&(this.view.focusSceneIndex=i)}}emitAppSceneStateChange(t){this.appEmitter.emit("sceneStateChange",t)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(t){return(i,n)=>{var r,s,o,a;if(!!this.manager.canOperate)switch(i){case"setBoxSize":{(r=this.boxManager)==null||r.resizeBox({appId:t,width:n.width,height:n.height,skipUpdate:!1});break}case"setBoxMinSize":{(s=this.boxManager)==null||s.setBoxMinSize({appId:t,minWidth:n.minwidth,minHeight:n.minheight});break}case"setBoxTitle":{(o=this.boxManager)==null||o.setBoxTitle({appId:t,title:n.title});break}case du.destroy:{if(this.status==="destroyed")return;this.destroy(!0,!1,!0,n==null?void 0:n.error),n!=null&&n.error&&console.error(n==null?void 0:n.error);break}case"focus":{(a=this.boxManager)==null||a.focusBox({appId:this.id}),mt.emit("focus",{appId:this.id});break}}}}setScenePath(){if(!this.manager.canOperate)return;const t=this.getFullScenePath();this.manager.room&&t&&this.view&&to(this.manager.room,t)}setViewFocusScenePath(){const t=this.getFullScenePath();return t&&this.view&&ti(this.view,t),t}createView(){const t=this.viewManager.createView(this.id);return this.view$.setValue(t),this.setViewFocusScenePath(),t}get pageState(){return this._pageState.toObject()}async removeSceneByIndex(t){const i=this._pageState.getFullPath(t);if(i&&this.pageState){const n=so(t,this.pageState);return this.setSceneIndexWithoutSync(n),this.manager.dispatchInternalEvent(G.SetAppFocusIndex,{type:"app",appID:this.id,index:n}),setTimeout(()=>{io(this.manager.room,i,t)},100),!0}else return!1}setSceneIndexWithoutSync(t){this.view&&(this.view.focusSceneIndex=t)}setSceneIndex(t){if(this.view){this.view.focusSceneIndex=t;const i=this._pageState.getFullPath(t);i&&this.setFullPath(i)}}async destroy(t,i,n,r){var s,o,a,l;if(this.status!=="destroyed"){this.status="destroyed";try{await ze.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:r})}catch(u){console.error("[WindowManager]: notifyApp error",u.message,u.stack)}this.appEmitter.clearListeners(),this.sideEffectManager.flushAll(),L.emit(`destroy-${this.id}`,{error:r}),t&&((s=this.boxManager)==null||s.closeBox(this.id,n)),i&&(this.store.cleanAppAttributes(this.id),this.scenePath&&io(this.manager.room,this.scenePath)),this.appProxies.delete(this.id),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),(o=this.manager.refresher)==null||o.remove(this.id),(a=this.manager.refresher)==null||a.remove(this.stateKey),(l=this.manager.refresher)==null||l.remove(`${this.id}-fullPath`),this._prevFullPath=void 0,this.camera$.destroy(),this.size$.destroy(),this.box$.destroy()}}close(){return this.destroy(!0,!0,!1)}}class Wg{constructor(t){this.displayer=t,this.views=new Map}createView(t){const i=ju(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 ju=e=>{const t=e.views.createView();return Fg(t),t},Fg=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class Qg{constructor(t){var n;this.manager=t,this.started=!1,this.mainViewIsAddListener=!1,this.store=this.manager.store,this.sideEffectManager=new be.SideEffectManager,this.startListenWritableChange=()=>{this.sideEffectManager.add(()=>L.on("writableChange",r=>{r&&this.ensureCameraAndSize()}))},this.addCameraReaction=()=>{var r;(r=this.manager.refresher)==null||r.add(he.MainViewCamera,this.cameraReaction)},this.cameraReaction=()=>E.reaction(()=>this.mainViewCamera,r=>{r&&r.id!==this.manager.uid&&this.synchronizer.onRemoteUpdate(r,this.mainViewSize)},{fireImmediately:!0}),this.sizeChangeHandler=b.debounce(r=>{},30),this.onUpdateContainerSizeRatio=()=>{const r=this.store.getMainViewSize();this.sizeChangeHandler(r),r.id===this.manager.uid&&this.setCameraAndSize()},this.onCameraUpdatedByDevice=r=>{this.synchronizer.onLocalCameraUpdate(r);const s=this.getStageSize();s&&!b.isEqual(s,this.mainViewSize)&&this.setMainViewSize(s)},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=b.debounce(r=>{this.store.setMainViewSize(gt(Z({},r),{id:this.manager.uid}))},50),this.onCameraOrSizeUpdated=()=>{ne.emit("cameraStateChange",this.cameraState)},this.synchronizer=new Lu(r=>this.store.setMainViewCamera(gt(Z({},r),{id:this.manager.uid}))),this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),L.once("mainViewMounted").then(()=>{this.addMainViewListener(),this.start(),this.ensureCameraAndSize(),this.startListenWritableChange()}),this.sideEffectManager.add(()=>L.on("containerSizeRatioUpdate",this.onUpdateContainerSizeRatio)),this.sideEffectManager.add(()=>L.on("startReconnect",()=>{yu(this.mainView)}));const i=(n=this.manager.boxManager)==null?void 0:n.stageRect;i&&this.synchronizer.setRect(i),this.sideEffectManager.add(()=>L.on("playgroundSizeChange",r=>{this.synchronizer.setRect(r)}))}ensureCameraAndSize(){(!this.mainViewCamera||!this.mainViewSize)&&(this.manager.dispatchInternalEvent(G.InitMainViewCamera),this.setCameraAndSize())}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}get didRelease(){return b.get(this.view,["didRelease"])}moveCameraSizeByAttributes(){this.synchronizer.onRemoteUpdate(this.mainViewCamera,this.mainViewSize)}start(){this.started||(this.sizeChangeHandler(this.mainViewSize),this.addCameraListener(),this.addCameraReaction(),this.started=!0)}setCameraAndSize(){const t=this.getStageSize();if(t){const i=gt(Z({},this.mainView.camera),{id:this.manager.uid}),n=gt(Z({},t),{id:this.manager.uid});this.store.setMainViewCameraAndSize(i,n)}}get view(){return this.mainView}get cameraState(){return Z(Z({},this.view.camera),this.view.size)}createMainView(){const t=ju(this.manager.displayer),i=this.store.getMainViewScenePath();return i&&ti(t,i),this.synchronizer.setView(t),t}onReconnect(){if(this.didRelease)this.rebind();else{const t=this.store.getMainViewScenePath();this.setFocusScenePath(t)}}setFocusScenePath(t){if(t)return ti(this.view,t)}rebind(){const t=this.mainView.divElement,i=this.mainView.disableCameraTransform;this.stop(),yu(this.mainView),this.removeMainViewListener(),this.mainView=this.createMainView(),this.mainView.disableCameraTransform=i,this.mainView.divElement=t,this.addMainViewListener(),this.start()}getStageSize(){var i;const t=(i=this.manager.boxManager)==null?void 0:i.stageRect;if(t)return{width:t.width,height:t.height}}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.onCameraOrSizeUpdated),this.view.callbacks.on("onSizeUpdated",this.onCameraOrSizeUpdated)}removeCameraListener(){this.view.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.off("onCameraUpdated",this.onCameraOrSizeUpdated),this.view.callbacks.off("onSizeUpdated",this.onCameraOrSizeUpdated)}stop(){var t,i;this.removeCameraListener(),(t=this.manager.refresher)==null||t.remove(he.MainViewCamera),(i=this.manager.refresher)==null||i.remove(he.MainViewSize),this.started=!1}destroy(){this.removeMainViewListener(),this.stop(),this.sideEffectManager.flushAll()}}class Zg{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=>{ne.emit("canRedoStepsChange",i)},this.onCanUndoStepsUpdate=i=>{ne.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)},L.on("focusedChange",i=>{this.disposePrevFocusViewRedoUndoListeners(i.prev),setTimeout(()=>{this.addRedoUndoListeners(i.focused)},0)}),L.on("rootDirRemoved",()=>{this.disposePrevFocusViewRedoUndoListeners(t.focus()),this.addRedoUndoListeners(t.focus())}),this.addRedoUndoListeners(t.focus())}destroy(){this.disposePrevFocusViewRedoUndoListeners(this.context.focus())}}class Gg{constructor(t){this.windowManger=t,this.appProxies=new Map,this.appStatus=new Map,this.store=Hg,this.isReplay=this.windowManger.isReplay,this.mainViewScenesLength=0,this.callbacksNode=null,this.appCreateQueue=new ug,this.sideEffectManager=new be.SideEffectManager,this.sceneState=null,this.rootDirRemoving=!1,this.onRemoveScenes=async i=>{var r,s;const{scenePath:n}=i;if(n===ke){await this.onRootDirRemoved(),this.dispatchInternalEvent(G.RootDirRemoved);return}if(Ng(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&&this.setMainViewScenePath(`${ke}${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(ke,{onAddScene:this.onSceneChange,onRemoveScene:async(n,r)=>{await this.onSceneChange(n),L.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=so(i,this.windowManger.pageState);this.setSceneIndexWithoutSync(n),this.dispatchInternalEvent(G.SetAppFocusIndex,{type:"main",index:n});const r=(s=this.callbacksNode)==null?void 0:s.scenes[i];return setTimeout(()=>{r&&io(this.room,`${ke}${r}`,i)},100),new Promise((o,a)=>{L.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(`${ke}${n}`)},this.onSceneChange=i=>(this.mainViewScenesLength=i.scenes.length,this.updateSceneState(i),this.emitMainViewScenesChange(this.mainViewScenesLength)),this.emitMainViewScenesChange=i=>Promise.all([ne.emit("mainViewScenesLengthChange",i),L.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:`${ke}${r}`,contextPath:i.path,index:n,scenes:i.scenes.map(s=>({name:s})),sceneName:r},ne.emit("sceneStateChange",this.sceneState)},this.onBoxMove=i=>{this.dispatchInternalEvent(G.AppMove,i),this.store.updateAppState(i.appId,Pe.Position,{x:i.x,y:i.y})},this.onBoxResize=i=>{i.width&&i.height&&(this.dispatchInternalEvent(G.AppResize,i),this.store.updateAppState(i.appId,Pe.Size,{width:i.width,height:i.height}))},this.onBoxFocus=i=>{this.windowManger.safeSetAttributes({focus:i.appId})},this.onBoxClose=i=>{const n=this.appProxies.get(i.appId);n&&n.destroy(!1,!0,!0,i.error)},this.onBoxStateChange=i=>{this.dispatchInternalEvent(G.AppBoxStateChange,i)},this.addAppsChangeListener=()=>{var i;(i=this.refresher)==null||i.add("apps",()=>Pu(()=>this.attributes.apps,()=>{this.attributesUpdateCallback(this.attributes.apps)}))},this.addAppCloseListener=()=>{var i;(i=this.refresher)==null||i.add("appsClose",()=>zg(this.attributes.apps,()=>{this.onAppDelete(this.attributes.apps)}))},this.onMainViewIndexChange=i=>{i!==void 0&&this._prevSceneIndex!==i&&(ne.emit("mainViewSceneIndexChange",i),L.emit("changePageState"),this.callbacksNode&&this.updateSceneState(this.callbacksNode),this._prevSceneIndex=i)},this.onFocusChange=i=>{var n;this._prevFocused!==i&&(ne.emit("focusedChange",i),L.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&&ze.notifyApp(r.kind,"focus",{appId:i})},0)))},this.attributesUpdateCallback=b.debounce(i=>this._attributesUpdateCallback(i),100),this.onRegisteredChange=i=>{!i||Object.entries(i).forEach(([n,r])=>{ze.appClasses.has(n)||ze.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=>{const n=i.sceneState;if(n){const r=n.scenePath;this.appProxies.forEach(s=>{s.scenePath&&r.startsWith(s.scenePath)&&(s.emitAppSceneStateChange(n),s.setFullPath(r))})}this.appProxies.forEach(r=>{r.appEmitter.emit("roomStateChange",i)}),i.roomMembers&&L.emit("roomMembersChange",this.members),L.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()}),n===!0?(this.mainView.disableCameraTransform=!1,this.room&&this.room.disableSerialization===!0&&(this.room.disableSerialization=!1)):this.mainView.disableCameraTransform=!0,L.emit("writableChange",n)},this.updateSceneIndex=()=>{const i=this.store.getMainViewScenePath(),n=no(i),r=ii(this.displayer)[n];if(r.length){const s=i.replace(n,"").replace("/",""),o=r.findIndex(a=>a.name===s);b.isInteger(o)&&o>=0&&this.safeSetAttributes({_mainSceneIndex:o})}},this.updateRootDirRemoving=i=>{this.rootDirRemoving=i},this.displayer=t.displayer,this.store.setContext({getAttributes:()=>this.attributes,safeSetAttributes:i=>this.safeSetAttributes(i),safeUpdateAttributes:(i,n)=>this.safeUpdateAttributes(i,n)}),this.mainViewProxy=new Qg(this),this.viewManager=new Wg(this.displayer),this.appListeners=new Pg(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=Gf,this.refresher.setRoom(this.room),this.refresher.setContext({emitter:L}),this.sideEffectManager.add(()=>()=>{var i,n,r;this.appCreateQueue.destroy(),this.mainViewProxy.destroy(),(i=this.refresher)==null||i.destroy(),this.viewManager.destroy(),(n=this.boxManager)==null||n.destroy(),(r=this.callbacksNode)==null||r.dispose()}),L.once("onCreated").then(()=>this.onCreated()),L.on("onReconnected",()=>this.onReconnected()),E.isPlayer(this.displayer)&&(L.on("seekStart",this.onPlayerSeekStart),L.on("seek",this.onPlayerSeekDone)),L.on("removeScenes",this.onRemoveScenes),L.on("setReadonly",this.onReadonlyChanged),this.createRootDirScenesCallback(),ze.setSyncRegisterApp(i=>{this.safeUpdateAttributes([he.Registered,i.kind],i)})}async onRootDirRemoved(t=!0){this.setMainViewScenePath(fu),this.createRootDirScenesCallback();for(const[i,n]of this.appProxies.entries())n.view&&await this.closeApp(i,t);this.mainViewProxy.rebind(),L.emit("rootDirRemoved"),this.updateRootDirRemoving(!1)}get eventName(){return E.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return E.isRoom(this.displayer)?this.displayer:void 0}get mainView(){return this.mainViewProxy.view}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 members(){return Bg(this.displayer.state.roomMembers)}getMainViewSceneDir(){const t=this.store.getMainViewScenePath();if(t)return no(t);throw new Error("[WindowManager]: mainViewSceneDir not found")}async onCreated(){var t,i,n,r,s,o;if(await this.attributesUpdateCallback(this.attributes.apps),L.emit("updateManagerRect"),mt.on("move",this.onBoxMove),mt.on("resize",this.onBoxResize),mt.on("focus",this.onBoxFocus),mt.on("close",this.onBoxClose),mt.on("boxStateChange",this.onBoxStateChange),this.addAppsChangeListener(),this.addAppCloseListener(),(t=this.refresher)==null||t.add("maximized",()=>E.autorun(()=>{var l;const a=this.attributes.maximized;(l=this.boxManager)==null||l.setMaximized(Boolean(a))})),(i=this.refresher)==null||i.add("minimized",()=>E.autorun(()=>{const a=this.attributes.minimized;this.onMinimized(a)})),(n=this.refresher)==null||n.add("mainViewIndex",()=>E.autorun(()=>{const a=b.get(this.attributes,"_mainSceneIndex");this.onMainViewIndexChange(a)})),(r=this.refresher)==null||r.add("focusedChange",()=>E.autorun(()=>{const a=b.get(this.attributes,"focus");this.onFocusChange(a)})),(s=this.refresher)==null||s.add("registeredChange",()=>E.autorun(()=>{const a=b.get(this.attributes,he.Registered);this.onRegisteredChange(a)})),!this.attributes.apps||Object.keys(this.attributes.apps).length===0){const a=this.store.getMainViewScenePath();if(!a)return;this.resetScenePath(a)}this.displayerWritableListener(!((o=this.room)!=null&&o.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener),this._prevFocused=this.attributes.focus,this.sideEffectManager.add(()=>{const a=new Zg({mainView:()=>this.mainViewProxy.view,focus:()=>this.attributes.focus,getAppProxy:l=>this.appProxies.get(l)});return()=>a.destroy()})}async _attributesUpdateCallback(t){if(t&&Ie.container){const i=Object.keys(t);i.length===0&&this.appCreateQueue.emitReady();const n=i.map(r=>({id:r,createdAt:t[r].createdAt}));for(const{id:r}of b.orderBy(n,"createdAt","asc"))if(!this.appProxies.has(r)&&!this.appStatus.has(r)){const s=t[r];try{if(!this.attributes[r])throw new Error("appAttributes is undefined");this.appCreateQueue.push(()=>(this.appStatus.set(r,eo.StartCreate),this.baseInsertApp({kind:s.kind,options:s.options,isDynamicPPT:s.isDynamicPPT},r,!1))),this.focusByAttributes(t)}catch(o){console.warn("[WindowManager]: Insert App Error",o)}}}}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(),L.emit("mainViewMounted")}setMainViewFocusPath(t){var n;const i=t||this.store.getMainViewScenePath();if(i)return ti(this.mainView,i),((n=this.mainView)==null?void 0:n.focusScenePath)===i}resetScenePath(t){this.displayer.state.sceneState.scenePath!==t&&to(this.room,t)}async addApp(t,i){Ti("addApp",t);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 Mg(t.kind);this.appStatus.set(n,eo.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;mt.emit("move",{appId:t.id,x:r==null?void 0:r.intrinsicX,y:r==null?void 0:r.intrinsicY}),this.store.updateAppState(t.id,Pe.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&&n.destroy(!0,i,!1)}async baseInsertApp(t,i,n,r){if(this.appProxies.has(i)){console.warn("[WindowManager]: app duplicate exists and cannot be created again");return}const s=new oo(t,this,i,n);if(s)return await s.baseInsertApp(r),this.appStatus.delete(i),s;throw this.appStatus.delete(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(no(t)!==ke)throw new Error('[WindowManager]: main view scenePath must in root dir "/"');if(i===E.ScenePathType.None)throw new Error(`[WindowManager]: ${t} not valid scene`);if(i===E.ScenePathType.Page)await this._setMainViewScenePath(t);else if(i===E.ScenePathType.Dir){const r=Eg(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=`${ke}${n}`;if(n)this.setMainViewFocusPath(r)&&(this.store.setMainViewScenePath(r),this.safeSetAttributes({_mainSceneIndex:t}),this.dispatchSetMainViewScenePath(r));else throw new Error(`[WindowManager]: ${t} not valid index`)}}dispatchSetMainViewScenePath(t){this.dispatchInternalEvent(G.SetMainViewScenePath,{nextScenePath:t}),to(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(){const i=Array.from(this.appProxies.values()).map(n=>n.onReconnected());this.mainViewProxy.onReconnect(),await Promise.all(i)}notifyContainerRectUpdate(t){this.appProxies.forEach(i=>{i.appEmitter.emit("containerRectUpdate",t)})}dispatchInternalEvent(t,i){this.safeDispatchMagixEvent(Ks,{eventName:t,payload:i})}destroy(){this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),mt.clearListeners(),L.clearListeners(),this.appProxies.size&&this.appProxies.forEach(t=>{t.destroy(!0,!1,!0)}),ne.clearListeners(),this.sideEffectManager.flushAll(),this._prevFocused=void 0,this._prevSceneIndex=void 0}}/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -43,4 +43,4 @@ object-assign
43
43
  in `+(n||"Unknown")+s}t+=i,e=e.return}while(e);return t}function Rt(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}function rh(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function g0(e){var t=rh(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 Wr(e){e._valueTracker||(e._valueTracker=g0(e))}function sh(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),n="";return e&&(n=rh(e)?e.checked?"true":"false":e.value),e=n,e!==i?(t.setValue(e),!0):!1}function ba(e,t){var i=t.checked;return Ce({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i!=null?i:e._wrapperState.initialChecked})}function oh(e,t){var i=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;i=Rt(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 ah(e,t){t=t.checked,t!=null&&xa(e,"checked",t,!1)}function Ea(e,t){ah(e,t);var i=Rt(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")?Aa(e,t.type,i):t.hasOwnProperty("defaultValue")&&Aa(e,t.type,Rt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lh(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 Aa(e,t,i){(t!=="number"||e.ownerDocument.activeElement!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}function m0(e){var t="";return Rr.Children.forEach(e,function(i){i!=null&&(t+=i)}),t}function Ta(e,t){return e=Ce({children:void 0},t),(t=m0(t.children))&&(e.children=t),e}function $i(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=""+Rt(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 Na(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(S(91));return Ce({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function uh(e,t){var i=t.value;if(i==null){if(i=t.children,t=t.defaultValue,i!=null){if(t!=null)throw Error(S(92));if(Array.isArray(i)){if(!(1>=i.length))throw Error(S(93));i=i[0]}t=i}t==null&&(t=""),i=t}e._wrapperState={initialValue:Rt(i)}}function ch(e,t){var i=Rt(t.value),n=Rt(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 dh(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}var hh={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function ph(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 Pa(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?ph(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Fr,fh=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!==hh.svg||"innerHTML"in e)e.innerHTML=t;else{for(Fr=Fr||document.createElement("div"),Fr.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Fr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function An(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}function Qr(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var Hi={animationend:Qr("Animation","AnimationEnd"),animationiteration:Qr("Animation","AnimationIteration"),animationstart:Qr("Animation","AnimationStart"),transitionend:Qr("Transition","TransitionEnd")},ka={},gh={};jt&&(gh=document.createElement("div").style,"AnimationEvent"in window||(delete Hi.animationend.animation,delete Hi.animationiteration.animation,delete Hi.animationstart.animation),"TransitionEvent"in window||delete Hi.transitionend.transition);function Zr(e){if(ka[e])return ka[e];if(!Hi[e])return e;var t=Hi[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in gh)return ka[e]=t[i];return e}var mh=Zr("animationend"),vh=Zr("animationiteration"),wh=Zr("animationstart"),yh=Zr("transitionend"),Tn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),xh=new(typeof WeakMap=="function"?WeakMap:Map);function za(e){var t=xh.get(e);return t===void 0&&(t=new Map,xh.set(e,t)),t}function hi(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 Sh(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 Ch(e){if(hi(e)!==e)throw Error(S(188))}function v0(e){var t=e.alternate;if(!t){if(t=hi(e),t===null)throw Error(S(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 Ch(r),e;if(s===n)return Ch(r),t;s=s.sibling}throw Error(S(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(S(189))}}if(i.alternate!==n)throw Error(S(190))}if(i.tag!==3)throw Error(S(188));return i.stateNode.current===i?e:t}function Mh(e){if(e=v0(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 Wi(e,t){if(t==null)throw Error(S(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 Da(e,t,i){Array.isArray(e)?e.forEach(t,i):e&&t.call(i,e)}var Nn=null;function w0(e){if(e){var t=e._dispatchListeners,i=e._dispatchInstances;if(Array.isArray(t))for(var n=0;n<t.length&&!e.isPropagationStopped();n++)Od(e,t[n],i[n]);else t&&Od(e,t,i);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function Gr(e){if(e!==null&&(Nn=Wi(Nn,e)),e=Nn,Nn=null,e){if(Da(e,w0),Nn)throw Error(S(95));if(Br)throw e=ua,Br=!1,ua=null,e}}function La(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}function Ih(e){if(!jt)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 Yr=[];function bh(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>Yr.length&&Yr.push(e)}function Eh(e,t,i,n){if(Yr.length){var r=Yr.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 Ah(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=Bn(n)}while(i);for(i=0;i<e.ancestors.length;i++){t=e.ancestors[i];var r=La(e.nativeEvent);n=e.topLevelType;var s=e.nativeEvent,o=e.eventSystemFlags;i===0&&(o|=64);for(var a=null,l=0;l<_r.length;l++){var u=_r[l];u&&(u=u.extractEvents(n,t,s,r,o))&&(a=Wi(a,u))}Gr(a)}}function ja(e,t,i){if(!i.has(e)){switch(e){case"scroll":jn(t,"scroll",!0);break;case"focus":case"blur":jn(t,"focus",!0),jn(t,"blur",!0),i.set("blur",null),i.set("focus",null);break;case"cancel":case"close":Ih(e)&&jn(t,e,!0);break;case"invalid":case"submit":case"reset":break;default:Tn.indexOf(e)===-1&&X(e,t)}i.set(e,null)}}var Th,Ra,Nh,Va=!1,lt=[],Vt=null,Bt=null,Ot=null,Pn=new Map,kn=new Map,zn=[],Ba="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(" "),y0="focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture".split(" ");function x0(e,t){var i=za(t);Ba.forEach(function(n){ja(n,t,i)}),y0.forEach(function(n){ja(n,t,i)})}function Oa(e,t,i,n,r){return{blockedOn:e,topLevelType:t,eventSystemFlags:i|32,nativeEvent:r,container:n}}function Ph(e,t){switch(e){case"focus":case"blur":Vt=null;break;case"dragenter":case"dragleave":Bt=null;break;case"mouseover":case"mouseout":Ot=null;break;case"pointerover":case"pointerout":Pn.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":kn.delete(t.pointerId)}}function Dn(e,t,i,n,r,s){return e===null||e.nativeEvent!==s?(e=Oa(t,i,n,r,s),t!==null&&(t=On(t),t!==null&&Ra(t)),e):(e.eventSystemFlags|=n,e)}function S0(e,t,i,n,r){switch(t){case"focus":return Vt=Dn(Vt,e,t,i,n,r),!0;case"dragenter":return Bt=Dn(Bt,e,t,i,n,r),!0;case"mouseover":return Ot=Dn(Ot,e,t,i,n,r),!0;case"pointerover":var s=r.pointerId;return Pn.set(s,Dn(Pn.get(s)||null,e,t,i,n,r)),!0;case"gotpointercapture":return s=r.pointerId,kn.set(s,Dn(kn.get(s)||null,e,t,i,n,r)),!0}return!1}function C0(e){var t=Bn(e.target);if(t!==null){var i=hi(t);if(i!==null){if(t=i.tag,t===13){if(t=Sh(i),t!==null){e.blockedOn=t,ce.unstable_runWithPriority(e.priority,function(){Nh(i)});return}}else if(t===3&&i.stateNode.hydrate){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Xr(e){if(e.blockedOn!==null)return!1;var t=Ha(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(t!==null){var i=On(t);return i!==null&&Ra(i),e.blockedOn=t,!1}return!0}function kh(e,t,i){Xr(e)&&i.delete(t)}function M0(){for(Va=!1;0<lt.length;){var e=lt[0];if(e.blockedOn!==null){e=On(e.blockedOn),e!==null&&Th(e);break}var t=Ha(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);t!==null?e.blockedOn=t:lt.shift()}Vt!==null&&Xr(Vt)&&(Vt=null),Bt!==null&&Xr(Bt)&&(Bt=null),Ot!==null&&Xr(Ot)&&(Ot=null),Pn.forEach(kh),kn.forEach(kh)}function Ln(e,t){e.blockedOn===t&&(e.blockedOn=null,Va||(Va=!0,ce.unstable_scheduleCallback(ce.unstable_NormalPriority,M0)))}function zh(e){function t(r){return Ln(r,e)}if(0<lt.length){Ln(lt[0],e);for(var i=1;i<lt.length;i++){var n=lt[i];n.blockedOn===e&&(n.blockedOn=null)}}for(Vt!==null&&Ln(Vt,e),Bt!==null&&Ln(Bt,e),Ot!==null&&Ln(Ot,e),Pn.forEach(t),kn.forEach(t),i=0;i<zn.length;i++)n=zn[i],n.blockedOn===e&&(n.blockedOn=null);for(;0<zn.length&&(i=zn[0],i.blockedOn===null);)C0(i),i.blockedOn===null&&zn.shift()}var Dh={},Lh=new Map,_a=new Map,I0=["abort","abort",mh,"animationEnd",vh,"animationIteration",wh,"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",yh,"transitionEnd","waiting","waiting"];function Ua(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},_a.set(n,t),Lh.set(n,s),Dh[r]=s}}Ua("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),Ua("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),Ua(I0,2);for(var jh="change selectionchange textInput compositionstart compositionend compositionupdate".split(" "),$a=0;$a<jh.length;$a++)_a.set(jh[$a],0);var b0=ce.unstable_UserBlockingPriority,E0=ce.unstable_runWithPriority,Jr=!0;function X(e,t){jn(t,e,!1)}function jn(e,t,i){var n=_a.get(t);switch(n===void 0?2:n){case 0:n=A0.bind(null,t,1,e);break;case 1:n=T0.bind(null,t,1,e);break;default:n=Kr.bind(null,t,1,e)}i?e.addEventListener(t,n,!0):e.addEventListener(t,n,!1)}function A0(e,t,i,n){ci||ga();var r=Kr,s=ci;ci=!0;try{Qd(r,e,t,i,n)}finally{(ci=s)||va()}}function T0(e,t,i,n){E0(b0,Kr.bind(null,e,t,i,n))}function Kr(e,t,i,n){if(Jr)if(0<lt.length&&-1<Ba.indexOf(e))e=Oa(null,e,t,i,n),lt.push(e);else{var r=Ha(e,t,i,n);if(r===null)Ph(e,n);else if(-1<Ba.indexOf(e))e=Oa(r,e,t,i,n),lt.push(e);else if(!S0(r,e,t,i,n)){Ph(e,n),e=Eh(e,n,null,t);try{Gd(Ah,e)}finally{bh(e)}}}}function Ha(e,t,i,n){if(i=La(n),i=Bn(i),i!==null){var r=hi(i);if(r===null)i=null;else{var s=r.tag;if(s===13){if(i=Sh(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=Eh(e,n,i,t);try{Gd(Ah,e)}finally{bh(e)}return null}var Rn={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},N0=["Webkit","ms","Moz","O"];Object.keys(Rn).forEach(function(e){N0.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Rn[t]=Rn[e]})});function Rh(e,t,i){return t==null||typeof t=="boolean"||t===""?"":i||typeof t!="number"||t===0||Rn.hasOwnProperty(e)&&Rn[e]?(""+t).trim():t+"px"}function Vh(e,t){e=e.style;for(var i in t)if(t.hasOwnProperty(i)){var n=i.indexOf("--")===0,r=Rh(i,t[i],n);i==="float"&&(i="cssFloat"),n?e.setProperty(i,r):e[i]=r}}var P0=Ce({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 Wa(e,t){if(t){if(P0[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(S(137,e,""));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(S(60));if(!(typeof t.dangerouslySetInnerHTML=="object"&&"__html"in t.dangerouslySetInnerHTML))throw Error(S(61))}if(t.style!=null&&typeof t.style!="object")throw Error(S(62,""))}}function Fa(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 Bh=hh.html;function St(e,t){e=e.nodeType===9||e.nodeType===11?e:e.ownerDocument;var i=za(e);t=ha[t];for(var n=0;n<t.length;n++)ja(t[n],e,i)}function qr(){}function Qa(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 Oh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function _h(e,t){var i=Oh(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=Oh(i)}}function Uh(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Uh(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function $h(){for(var e=window,t=Qa();t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=Qa(e.document)}return t}function Za(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 Hh="$",Wh="/$",Ga="$?",Ya="$!",Xa=null,Ja=null;function Fh(e,t){switch(e){case"button":case"input":case"select":case"textarea":return!!t.autoFocus}return!1}function Ka(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 qa=typeof setTimeout=="function"?setTimeout:void 0,k0=typeof clearTimeout=="function"?clearTimeout:void 0;function Fi(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break}return e}function Qh(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i===Hh||i===Ya||i===Ga){if(t===0)return e;t--}else i===Wh&&t++}e=e.previousSibling}return null}var el=Math.random().toString(36).slice(2),_t="__reactInternalInstance$"+el,es="__reactEventHandlers$"+el,Vn="__reactContainere$"+el;function Bn(e){var t=e[_t];if(t)return t;for(var i=e.parentNode;i;){if(t=i[Vn]||i[_t]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Qh(e);e!==null;){if(i=e[_t])return i;e=Qh(e)}return t}e=i,i=e.parentNode}return null}function On(e){return e=e[_t]||e[Vn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function pi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(S(33))}function tl(e){return e[es]||null}function Ct(e){do e=e.return;while(e&&e.tag!==5);return e||null}function Zh(e,t){var i=e.stateNode;if(!i)return null;var n=ca(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(S(231,t,typeof i));return i}function Gh(e,t,i){(t=Zh(e,i.dispatchConfig.phasedRegistrationNames[t]))&&(i._dispatchListeners=Wi(i._dispatchListeners,t),i._dispatchInstances=Wi(i._dispatchInstances,e))}function z0(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,i=[];t;)i.push(t),t=Ct(t);for(t=i.length;0<t--;)Gh(i[t],"captured",e);for(t=0;t<i.length;t++)Gh(i[t],"bubbled",e)}}function il(e,t,i){e&&i&&i.dispatchConfig.registrationName&&(t=Zh(e,i.dispatchConfig.registrationName))&&(i._dispatchListeners=Wi(i._dispatchListeners,t),i._dispatchInstances=Wi(i._dispatchInstances,e))}function D0(e){e&&e.dispatchConfig.registrationName&&il(e._targetInst,null,e)}function Qi(e){Da(e,z0)}var Ut=null,nl=null,ts=null;function Yh(){if(ts)return ts;var e,t=nl,i=t.length,n,r="value"in Ut?Ut.value:Ut.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 ts=r.slice(e,1<n?1-n:void 0)}function is(){return!0}function ns(){return!1}function je(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)?is:ns,this.isPropagationStopped=ns,this}Ce(je.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!="unknown"&&(e.returnValue=!1),this.isDefaultPrevented=is)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!="unknown"&&(e.cancelBubble=!0),this.isPropagationStopped=is)},persist:function(){this.isPersistent=is},isPersistent:ns,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=ns,this._dispatchInstances=this._dispatchListeners=null}}),je.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},je.extend=function(e){function t(){}function i(){return n.apply(this,arguments)}var n=this;t.prototype=n.prototype;var r=new t;return Ce(r,i.prototype),i.prototype=r,i.prototype.constructor=i,i.Interface=Ce({},n.Interface,e),i.extend=n.extend,Xh(i),i},Xh(je);function L0(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 j0(e){if(!(e instanceof this))throw Error(S(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function Xh(e){e.eventPool=[],e.getPooled=L0,e.release=j0}var R0=je.extend({data:null}),V0=je.extend({data:null}),B0=[9,13,27,32],rl=jt&&"CompositionEvent"in window,_n=null;jt&&"documentMode"in document&&(_n=document.documentMode);var O0=jt&&"TextEvent"in window&&!_n,Jh=jt&&(!rl||_n&&8<_n&&11>=_n),Kh=String.fromCharCode(32),Mt={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(" ")}},qh=!1;function ep(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 tp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zi=!1;function _0(e,t){switch(e){case"compositionend":return tp(t);case"keypress":return t.which!==32?null:(qh=!0,Kh);case"textInput":return e=t.data,e===Kh&&qh?null:e;default:return null}}function U0(e,t){if(Zi)return e==="compositionend"||!rl&&ep(e,t)?(e=Yh(),ts=nl=Ut=null,Zi=!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 Jh&&t.locale!=="ko"?null:t.data;default:return null}}var $0={eventTypes:Mt,extractEvents:function(e,t,i,n){var r;if(rl)e:{switch(e){case"compositionstart":var s=Mt.compositionStart;break e;case"compositionend":s=Mt.compositionEnd;break e;case"compositionupdate":s=Mt.compositionUpdate;break e}s=void 0}else Zi?ep(e,i)&&(s=Mt.compositionEnd):e==="keydown"&&i.keyCode===229&&(s=Mt.compositionStart);return s?(Jh&&i.locale!=="ko"&&(Zi||s!==Mt.compositionStart?s===Mt.compositionEnd&&Zi&&(r=Yh()):(Ut=n,nl="value"in Ut?Ut.value:Ut.textContent,Zi=!0)),s=R0.getPooled(s,t,i,n),r?s.data=r:(r=tp(i),r!==null&&(s.data=r)),Qi(s),r=s):r=null,(e=O0?_0(e,i):U0(e,i))?(t=V0.getPooled(Mt.beforeInput,t,i,n),t.data=e,Qi(t)):t=null,r===null?t:t===null?r:[r,t]}},H0={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 ip(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!H0[e.type]:t==="textarea"}var np={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"blur change click focus input keydown keyup selectionchange".split(" ")}};function rp(e,t,i){return e=je.getPooled(np.change,e,t,i),e.type="change",Wd(i),Qi(e),e}var Un=null,$n=null;function W0(e){Gr(e)}function rs(e){var t=pi(e);if(sh(t))return e}function F0(e,t){if(e==="change")return t}var sl=!1;jt&&(sl=Ih("input")&&(!document.documentMode||9<document.documentMode));function sp(){Un&&(Un.detachEvent("onpropertychange",op),$n=Un=null)}function op(e){if(e.propertyName==="value"&&rs($n))if(e=rp($n,e,La(e)),ci)Gr(e);else{ci=!0;try{fa(W0,e)}finally{ci=!1,va()}}}function Q0(e,t,i){e==="focus"?(sp(),Un=t,$n=i,Un.attachEvent("onpropertychange",op)):e==="blur"&&sp()}function Z0(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return rs($n)}function G0(e,t){if(e==="click")return rs(t)}function Y0(e,t){if(e==="input"||e==="change")return rs(t)}var X0={eventTypes:np,_isInputEventSupported:sl,extractEvents:function(e,t,i,n){var r=t?pi(t):window,s=r.nodeName&&r.nodeName.toLowerCase();if(s==="select"||s==="input"&&r.type==="file")var o=F0;else if(ip(r))if(sl)o=Y0;else{o=Z0;var a=Q0}else(s=r.nodeName)&&s.toLowerCase()==="input"&&(r.type==="checkbox"||r.type==="radio")&&(o=G0);if(o&&(o=o(e,t)))return rp(o,i,n);a&&a(e,r,t),e==="blur"&&(e=r._wrapperState)&&e.controlled&&r.type==="number"&&Aa(r,"number",r.value)}},Hn=je.extend({view:null,detail:null}),J0={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function K0(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=J0[e])?!!t[e]:!1}function ol(){return K0}var ap=0,lp=0,up=!1,cp=!1,Wn=Hn.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:ol,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=ap;return ap=e.screenX,up?e.type==="mousemove"?e.screenX-t:0:(up=!0,0)},movementY:function(e){if("movementY"in e)return e.movementY;var t=lp;return lp=e.screenY,cp?e.type==="mousemove"?e.screenY-t:0:(cp=!0,0)}}),dp=Wn.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),Fn={mouseEnter:{registrationName:"onMouseEnter",dependencies:["mouseout","mouseover"]},mouseLeave:{registrationName:"onMouseLeave",dependencies:["mouseout","mouseover"]},pointerEnter:{registrationName:"onPointerEnter",dependencies:["pointerout","pointerover"]},pointerLeave:{registrationName:"onPointerLeave",dependencies:["pointerout","pointerover"]}},q0={eventTypes:Fn,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)?Bn(t):null,t!==null){var a=hi(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=Wn,u=Fn.mouseLeave,c=Fn.mouseEnter,d="mouse";else(e==="pointerout"||e==="pointerover")&&(l=dp,u=Fn.pointerLeave,c=Fn.pointerEnter,d="pointer");if(e=o==null?s:pi(o),s=t==null?s:pi(t),u=l.getPooled(u,o,i,n),u.type=d+"leave",u.target=e,u.relatedTarget=s,i=l.getPooled(c,t,i,n),i.type=d+"enter",i.target=s,i.relatedTarget=e,n=o,d=t,n&&d)e:{for(l=n,c=d,o=0,e=l;e;e=Ct(e))o++;for(e=0,t=c;t;t=Ct(t))e++;for(;0<o-e;)l=Ct(l),o--;for(;0<e-o;)c=Ct(c),e--;for(;o--;){if(l===c||l===c.alternate)break e;l=Ct(l),c=Ct(c)}l=null}else l=null;for(c=l,l=[];n&&n!==c&&(o=n.alternate,!(o!==null&&o===c));)l.push(n),n=Ct(n);for(n=[];d&&d!==c&&(o=d.alternate,!(o!==null&&o===c));)n.push(d),d=Ct(d);for(d=0;d<l.length;d++)il(l[d],"bubbled",u);for(d=n.length;0<d--;)il(n[d],"captured",i);return(r&64)===0?[u]:[u,i]}};function ex(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var fi=typeof Object.is=="function"?Object.is:ex,tx=Object.prototype.hasOwnProperty;function Qn(e,t){if(fi(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(!tx.call(t,i[n])||!fi(e[i[n]],t[i[n]]))return!1;return!0}var ix=jt&&"documentMode"in document&&11>=document.documentMode,hp={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange".split(" ")}},Gi=null,al=null,Zn=null,ll=!1;function pp(e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;return ll||Gi==null||Gi!==Qa(i)?null:(i=Gi,"selectionStart"in i&&Za(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&&Qn(Zn,i)?null:(Zn=i,e=je.getPooled(hp.select,al,e,t),e.type="select",e.target=Gi,Qi(e),e))}var nx={eventTypes:hp,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=za(r),s=ha.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?pi(t):window,e){case"focus":(ip(r)||r.contentEditable==="true")&&(Gi=r,al=t,Zn=null);break;case"blur":Zn=al=Gi=null;break;case"mousedown":ll=!0;break;case"contextmenu":case"mouseup":case"dragend":return ll=!1,pp(i,n);case"selectionchange":if(ix)break;case"keydown":case"keyup":return pp(i,n)}return null}},rx=je.extend({animationName:null,elapsedTime:null,pseudoElement:null}),sx=je.extend({clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ox=Hn.extend({relatedTarget:null});function ss(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 ax={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lx={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"},ux=Hn.extend({key:function(e){if(e.key){var t=ax[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ss(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?lx[e.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:ol,charCode:function(e){return e.type==="keypress"?ss(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ss(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),cx=Wn.extend({dataTransfer:null}),dx=Hn.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:ol}),hx=je.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),px=Wn.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}),fx={eventTypes:Dh,extractEvents:function(e,t,i,n){var r=Lh.get(e);if(!r)return null;switch(e){case"keypress":if(ss(i)===0)return null;case"keydown":case"keyup":e=ux;break;case"blur":case"focus":e=ox;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=Wn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":e=cx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":e=dx;break;case mh:case vh:case wh:e=rx;break;case yh:e=hx;break;case"scroll":e=Hn;break;case"wheel":e=px;break;case"copy":case"cut":case"paste":e=sx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":e=dp;break;default:e=je}return t=e.getPooled(r,t,i,n),Qi(t),t}};if(Or)throw Error(S(101));Or=Array.prototype.slice.call("ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" ")),_d();var gx=On;ca=tl,Vd=gx,Bd=pi,$d({SimpleEventPlugin:fx,EnterLeaveEventPlugin:q0,ChangeEventPlugin:X0,SelectEventPlugin:nx,BeforeInputEventPlugin:$0});var ul=[],Yi=-1;function Y(e){0>Yi||(e.current=ul[Yi],ul[Yi]=null,Yi--)}function q(e,t){Yi++,ul[Yi]=e.current,e.current=t}var $t={},ge={current:$t},Ae={current:!1},gi=$t;function Xi(e,t){var i=e.type.contextTypes;if(!i)return $t;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 Te(e){return e=e.childContextTypes,e!=null}function os(){Y(Ae),Y(ge)}function fp(e,t,i){if(ge.current!==$t)throw Error(S(168));q(ge,t),q(Ae,i)}function gp(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(S(108,xt(t)||"Unknown",r));return Ce({},i,{},n)}function as(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||$t,gi=ge.current,q(ge,e),q(Ae,Ae.current),!0}function mp(e,t,i){var n=e.stateNode;if(!n)throw Error(S(169));i?(e=gp(e,t,gi),n.__reactInternalMemoizedMergedChildContext=e,Y(Ae),Y(ge),q(ge,e)):Y(Ae),q(Ae,i)}var mx=ce.unstable_runWithPriority,cl=ce.unstable_scheduleCallback,vp=ce.unstable_cancelCallback,wp=ce.unstable_requestPaint,dl=ce.unstable_now,vx=ce.unstable_getCurrentPriorityLevel,ls=ce.unstable_ImmediatePriority,yp=ce.unstable_UserBlockingPriority,xp=ce.unstable_NormalPriority,Sp=ce.unstable_LowPriority,Cp=ce.unstable_IdlePriority,Mp={},wx=ce.unstable_shouldYield,yx=wp!==void 0?wp:function(){},It=null,us=null,hl=!1,Ip=dl(),Qe=1e4>Ip?dl:function(){return dl()-Ip};function cs(){switch(vx()){case ls:return 99;case yp:return 98;case xp:return 97;case Sp:return 96;case Cp:return 95;default:throw Error(S(332))}}function bp(e){switch(e){case 99:return ls;case 98:return yp;case 97:return xp;case 96:return Sp;case 95:return Cp;default:throw Error(S(332))}}function Ht(e,t){return e=bp(e),mx(e,t)}function Ep(e,t,i){return e=bp(e),cl(e,t,i)}function Ap(e){return It===null?(It=[e],us=cl(ls,Tp)):It.push(e),Mp}function ut(){if(us!==null){var e=us;us=null,vp(e)}Tp()}function Tp(){if(!hl&&It!==null){hl=!0;var e=0;try{var t=It;Ht(99,function(){for(;e<t.length;e++){var i=t[e];do i=i(!0);while(i!==null)}}),It=null}catch(i){throw It!==null&&(It=It.slice(e+1)),cl(ls,ut),i}finally{hl=!1}}}function ds(e,t,i){return i/=10,1073741821-(((1073741821-e+t/10)/i|0)+1)*i}function tt(e,t){if(e&&e.defaultProps){t=Ce({},t),e=e.defaultProps;for(var i in e)t[i]===void 0&&(t[i]=e[i])}return t}var hs={current:null},ps=null,Ji=null,fs=null;function pl(){fs=Ji=ps=null}function fl(e){var t=hs.current;Y(hs),e.type._context._currentValue=t}function Np(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){ps=e,fs=Ji=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.expirationTime>=t&&(dt=!0),e.firstContext=null)}function Ze(e,t){if(fs!==e&&t!==!1&&t!==0)if((typeof t!="number"||t===1073741823)&&(fs=e,t=1073741823),t={context:e,observedBits:t,next:null},Ji===null){if(ps===null)throw Error(S(308));Ji=t,ps.dependencies={expirationTime:0,firstContext:t,responders:null}}else Ji=Ji.next=t;return e._currentValue}var Wt=!1;function gl(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function ml(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function Ft(e,t){return e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null},e.next=e}function Qt(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 Pp(e,t){var i=e.alternate;i!==null&&ml(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 Gn(e,t,i,n){var r=e.updateQueue;Wt=!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,d=null,m=null;if(a!==null){var w=a;do{if(o=w.expirationTime,o<n){var y={expirationTime:w.expirationTime,suspenseConfig:w.suspenseConfig,tag:w.tag,payload:w.payload,callback:w.callback,next:null};m===null?(d=m=y,c=l):m=m.next=y,o>u&&(u=o)}else{m!==null&&(m=m.next={expirationTime:1073741823,suspenseConfig:w.suspenseConfig,tag:w.tag,payload:w.payload,callback:w.callback,next:null}),Af(o,w.suspenseConfig);e:{var M=e,p=w;switch(o=t,y=i,p.tag){case 1:if(M=p.payload,typeof M=="function"){l=M.call(y,l,o);break e}l=M;break e;case 3:M.effectTag=M.effectTag&-4097|64;case 0:if(M=p.payload,o=typeof M=="function"?M.call(y,l,o):M,o==null)break e;l=Ce({},l,o);break e;case 2:Wt=!0}}w.callback!==null&&(e.effectTag|=32,o=r.effects,o===null?r.effects=[w]:o.push(w))}if(w=w.next,w===null||w===a){if(o=r.shared.pending,o===null)break;w=s.next=o.next,o.next=a,r.baseQueue=s=o,r.shared.pending=null}}while(1)}m===null?c=l:m.next=d,r.baseState=c,r.baseQueue=m,Us(u),e.expirationTime=u,e.memoizedState=l}}function kp(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(S(191,n));n.call(r)}}}var Yn=et.ReactCurrentBatchConfig,zp=new Rr.Component().refs;function gs(e,t,i,n){t=e.memoizedState,i=i(n,t),i=i==null?t:Ce({},t,i),e.memoizedState=i,e.expirationTime===0&&(e.updateQueue.baseState=i)}var ms={isMounted:function(e){return(e=e._reactInternalFiber)?hi(e)===e:!1},enqueueSetState:function(e,t,i){e=e._reactInternalFiber;var n=pt(),r=Yn.suspense;n=Si(n,e,r),r=Ft(n,r),r.payload=t,i!=null&&(r.callback=i),Qt(e,r),Xt(e,n)},enqueueReplaceState:function(e,t,i){e=e._reactInternalFiber;var n=pt(),r=Yn.suspense;n=Si(n,e,r),r=Ft(n,r),r.tag=1,r.payload=t,i!=null&&(r.callback=i),Qt(e,r),Xt(e,n)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var i=pt(),n=Yn.suspense;i=Si(i,e,n),n=Ft(i,n),n.tag=2,t!=null&&(n.callback=t),Qt(e,n),Xt(e,i)}};function Dp(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?!Qn(i,n)||!Qn(r,s):!0}function Lp(e,t,i){var n=!1,r=$t,s=t.contextType;return typeof s=="object"&&s!==null?s=Ze(s):(r=Te(t)?gi:ge.current,n=t.contextTypes,s=(n=n!=null)?Xi(e,r):$t),t=new t(i,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ms,e.stateNode=t,t._reactInternalFiber=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=s),t}function jp(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&&ms.enqueueReplaceState(t,t.state,null)}function vl(e,t,i,n){var r=e.stateNode;r.props=i,r.state=e.memoizedState,r.refs=zp,gl(e);var s=t.contextType;typeof s=="object"&&s!==null?r.context=Ze(s):(s=Te(t)?gi:ge.current,r.context=Xi(e,s)),Gn(e,i,r,n),r.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(gs(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&&ms.enqueueReplaceState(r,r.state,null),Gn(e,i,r,n),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.effectTag|=4)}var vs=Array.isArray;function Xn(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(S(309));var n=i.stateNode}if(!n)throw Error(S(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===zp&&(o=n.refs={}),s===null?delete o[r]:o[r]=s},t._stringRef=r,t)}if(typeof e!="string")throw Error(S(284));if(!i._owner)throw Error(S(290,e))}return e}function ws(e,t){if(e.type!=="textarea")throw Error(S(31,Object.prototype.toString.call(t)==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":t,""))}function Rp(e){function t(p,h){if(e){var f=p.lastEffect;f!==null?(f.nextEffect=h,p.lastEffect=h):p.firstEffect=p.lastEffect=h,h.nextEffect=null,h.effectTag=8}}function i(p,h){if(!e)return null;for(;h!==null;)t(p,h),h=h.sibling;return null}function n(p,h){for(p=new Map;h!==null;)h.key!==null?p.set(h.key,h):p.set(h.index,h),h=h.sibling;return p}function r(p,h){return p=bi(p,h),p.index=0,p.sibling=null,p}function s(p,h,f){return p.index=f,e?(f=p.alternate,f!==null?(f=f.index,f<h?(p.effectTag=2,h):f):(p.effectTag=2,h)):h}function o(p){return e&&p.alternate===null&&(p.effectTag=2),p}function a(p,h,f,g){return h===null||h.tag!==6?(h=Kl(f,p.mode,g),h.return=p,h):(h=r(h,f),h.return=p,h)}function l(p,h,f,g){return h!==null&&h.elementType===f.type?(g=r(h,f.props),g.ref=Xn(p,h,f),g.return=p,g):(g=$s(f.type,f.key,f.props,null,p.mode,g),g.ref=Xn(p,h,f),g.return=p,g)}function u(p,h,f,g){return h===null||h.tag!==4||h.stateNode.containerInfo!==f.containerInfo||h.stateNode.implementation!==f.implementation?(h=ql(f,p.mode,g),h.return=p,h):(h=r(h,f.children||[]),h.return=p,h)}function c(p,h,f,g,v){return h===null||h.tag!==7?(h=Jt(f,p.mode,g,v),h.return=p,h):(h=r(h,f),h.return=p,h)}function d(p,h,f){if(typeof h=="string"||typeof h=="number")return h=Kl(""+h,p.mode,f),h.return=p,h;if(typeof h=="object"&&h!==null){switch(h.$$typeof){case Ur:return f=$s(h.type,h.key,h.props,null,p.mode,f),f.ref=Xn(p,null,h),f.return=p,f;case Ui:return h=ql(h,p.mode,f),h.return=p,h}if(vs(h)||En(h))return h=Jt(h,p.mode,f,null),h.return=p,h;ws(p,h)}return null}function m(p,h,f,g){var v=h!==null?h.key:null;if(typeof f=="string"||typeof f=="number")return v!==null?null:a(p,h,""+f,g);if(typeof f=="object"&&f!==null){switch(f.$$typeof){case Ur:return f.key===v?f.type===di?c(p,h,f.props.children,g,v):l(p,h,f,g):null;case Ui:return f.key===v?u(p,h,f,g):null}if(vs(f)||En(f))return v!==null?null:c(p,h,f,g,null);ws(p,f)}return null}function w(p,h,f,g,v){if(typeof g=="string"||typeof g=="number")return p=p.get(f)||null,a(h,p,""+g,v);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Ur:return p=p.get(g.key===null?f:g.key)||null,g.type===di?c(h,p,g.props.children,v,g.key):l(h,p,g,v);case Ui:return p=p.get(g.key===null?f:g.key)||null,u(h,p,g,v)}if(vs(g)||En(g))return p=p.get(f)||null,c(h,p,g,v,null);ws(h,g)}return null}function y(p,h,f,g){for(var v=null,C=null,x=h,N=h=0,z=null;x!==null&&N<f.length;N++){x.index>N?(z=x,x=null):z=x.sibling;var P=m(p,x,f[N],g);if(P===null){x===null&&(x=z);break}e&&x&&P.alternate===null&&t(p,x),h=s(P,h,N),C===null?v=P:C.sibling=P,C=P,x=z}if(N===f.length)return i(p,x),v;if(x===null){for(;N<f.length;N++)x=d(p,f[N],g),x!==null&&(h=s(x,h,N),C===null?v=x:C.sibling=x,C=x);return v}for(x=n(p,x);N<f.length;N++)z=w(x,p,N,f[N],g),z!==null&&(e&&z.alternate!==null&&x.delete(z.key===null?N:z.key),h=s(z,h,N),C===null?v=z:C.sibling=z,C=z);return e&&x.forEach(function(ee){return t(p,ee)}),v}function M(p,h,f,g){var v=En(f);if(typeof v!="function")throw Error(S(150));if(f=v.call(f),f==null)throw Error(S(151));for(var C=v=null,x=h,N=h=0,z=null,P=f.next();x!==null&&!P.done;N++,P=f.next()){x.index>N?(z=x,x=null):z=x.sibling;var ee=m(p,x,P.value,g);if(ee===null){x===null&&(x=z);break}e&&x&&ee.alternate===null&&t(p,x),h=s(ee,h,N),C===null?v=ee:C.sibling=ee,C=ee,x=z}if(P.done)return i(p,x),v;if(x===null){for(;!P.done;N++,P=f.next())P=d(p,P.value,g),P!==null&&(h=s(P,h,N),C===null?v=P:C.sibling=P,C=P);return v}for(x=n(p,x);!P.done;N++,P=f.next())P=w(x,p,N,P.value,g),P!==null&&(e&&P.alternate!==null&&x.delete(P.key===null?N:P.key),h=s(P,h,N),C===null?v=P:C.sibling=P,C=P);return e&&x.forEach(function(te){return t(p,te)}),v}return function(p,h,f,g){var v=typeof f=="object"&&f!==null&&f.type===di&&f.key===null;v&&(f=f.props.children);var C=typeof f=="object"&&f!==null;if(C)switch(f.$$typeof){case Ur:e:{for(C=f.key,v=h;v!==null;){if(v.key===C){switch(v.tag){case 7:if(f.type===di){i(p,v.sibling),h=r(v,f.props.children),h.return=p,p=h;break e}break;default:if(v.elementType===f.type){i(p,v.sibling),h=r(v,f.props),h.ref=Xn(p,v,f),h.return=p,p=h;break e}}i(p,v);break}else t(p,v);v=v.sibling}f.type===di?(h=Jt(f.props.children,p.mode,g,f.key),h.return=p,p=h):(g=$s(f.type,f.key,f.props,null,p.mode,g),g.ref=Xn(p,h,f),g.return=p,p=g)}return o(p);case Ui:e:{for(v=f.key;h!==null;){if(h.key===v)if(h.tag===4&&h.stateNode.containerInfo===f.containerInfo&&h.stateNode.implementation===f.implementation){i(p,h.sibling),h=r(h,f.children||[]),h.return=p,p=h;break e}else{i(p,h);break}else t(p,h);h=h.sibling}h=ql(f,p.mode,g),h.return=p,p=h}return o(p)}if(typeof f=="string"||typeof f=="number")return f=""+f,h!==null&&h.tag===6?(i(p,h.sibling),h=r(h,f),h.return=p,p=h):(i(p,h),h=Kl(f,p.mode,g),h.return=p,p=h),o(p);if(vs(f))return y(p,h,f,g);if(En(f))return M(p,h,f,g);if(C&&ws(p,f),typeof f=="undefined"&&!v)switch(p.tag){case 1:case 0:throw p=p.type,Error(S(152,p.displayName||p.name||"Component"))}return i(p,h)}}var qi=Rp(!0),wl=Rp(!1),Jn={},ct={current:Jn},Kn={current:Jn},qn={current:Jn};function mi(e){if(e===Jn)throw Error(S(174));return e}function yl(e,t){switch(q(qn,t),q(Kn,e),q(ct,Jn),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Pa(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Pa(t,e)}Y(ct),q(ct,t)}function en(){Y(ct),Y(Kn),Y(qn)}function Vp(e){mi(qn.current);var t=mi(ct.current),i=Pa(t,e.type);t!==i&&(q(Kn,e),q(ct,i))}function xl(e){Kn.current===e&&(Y(ct),Y(Kn))}var K={current:0};function ys(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===Ga||i.data===Ya))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 Sl(e,t){return{responder:e,props:t}}var xs=et.ReactCurrentDispatcher,Ge=et.ReactCurrentBatchConfig,Zt=0,re=null,me=null,ve=null,Ss=!1;function Re(){throw Error(S(321))}function Cl(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!fi(e[i],t[i]))return!1;return!0}function Ml(e,t,i,n,r,s){if(Zt=s,re=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,xs.current=e===null||e.memoizedState===null?xx:Sx,e=i(n,r),t.expirationTime===Zt){s=0;do{if(t.expirationTime=0,!(25>s))throw Error(S(301));s+=1,ve=me=null,t.updateQueue=null,xs.current=Cx,e=i(n,r)}while(t.expirationTime===Zt)}if(xs.current=Es,t=me!==null&&me.next!==null,Zt=0,ve=me=re=null,Ss=!1,t)throw Error(S(300));return e}function tn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ve===null?re.memoizedState=ve=e:ve=ve.next=e,ve}function nn(){if(me===null){var e=re.alternate;e=e!==null?e.memoizedState:null}else e=me.next;var t=ve===null?re.memoizedState:ve.next;if(t!==null)ve=t,me=e;else{if(e===null)throw Error(S(310));me=e,e={memoizedState:me.memoizedState,baseState:me.baseState,baseQueue:me.baseQueue,queue:me.queue,next:null},ve===null?re.memoizedState=ve=e:ve=ve.next=e}return ve}function vi(e,t){return typeof t=="function"?t(e):t}function Cs(e){var t=nn(),i=t.queue;if(i===null)throw Error(S(311));i.lastRenderedReducer=e;var n=me,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<Zt){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>re.expirationTime&&(re.expirationTime=u,Us(u))}else a!==null&&(a=a.next={expirationTime:1073741823,suspenseConfig:l.suspenseConfig,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null}),Af(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,fi(n,t.memoizedState)||(dt=!0),t.memoizedState=n,t.baseState=s,t.baseQueue=a,i.lastRenderedState=n}return[t.memoizedState,i.dispatch]}function Ms(e){var t=nn(),i=t.queue;if(i===null)throw Error(S(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);fi(s,t.memoizedState)||(dt=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),i.lastRenderedState=s}return[s,n]}function Il(e){var t=tn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e=t.queue={pending:null,dispatch:null,lastRenderedReducer:vi,lastRenderedState:e},e=e.dispatch=Fp.bind(null,re,e),[t.memoizedState,e]}function bl(e,t,i,n){return e={tag:e,create:t,destroy:i,deps:n,next:null},t=re.updateQueue,t===null?(t={lastEffect:null},re.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 Bp(){return nn().memoizedState}function El(e,t,i,n){var r=tn();re.effectTag|=e,r.memoizedState=bl(1|t,i,void 0,n===void 0?null:n)}function Al(e,t,i,n){var r=nn();n=n===void 0?null:n;var s=void 0;if(me!==null){var o=me.memoizedState;if(s=o.destroy,n!==null&&Cl(n,o.deps)){bl(t,i,s,n);return}}re.effectTag|=e,r.memoizedState=bl(1|t,i,s,n)}function Op(e,t){return El(516,4,e,t)}function Is(e,t){return Al(516,4,e,t)}function _p(e,t){return Al(4,2,e,t)}function Up(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 $p(e,t,i){return i=i!=null?i.concat([e]):null,Al(4,2,Up.bind(null,t,e),i)}function Tl(){}function Hp(e,t){return tn().memoizedState=[e,t===void 0?null:t],e}function bs(e,t){var i=nn();t=t===void 0?null:t;var n=i.memoizedState;return n!==null&&t!==null&&Cl(t,n[1])?n[0]:(i.memoizedState=[e,t],e)}function Wp(e,t){var i=nn();t=t===void 0?null:t;var n=i.memoizedState;return n!==null&&t!==null&&Cl(t,n[1])?n[0]:(e=e(),i.memoizedState=[e,t],e)}function Nl(e,t,i){var n=cs();Ht(98>n?98:n,function(){e(!0)}),Ht(97<n?97:n,function(){var r=Ge.suspense;Ge.suspense=t===void 0?null:t;try{e(!1),i()}finally{Ge.suspense=r}})}function Fp(e,t,i){var n=pt(),r=Yn.suspense;n=Si(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===re||s!==null&&s===re)Ss=!0,r.expirationTime=Zt,re.expirationTime=Zt;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,fi(a,o))return}catch{}finally{}Xt(e,n)}}var Es={readContext:Ze,useCallback:Re,useContext:Re,useEffect:Re,useImperativeHandle:Re,useLayoutEffect:Re,useMemo:Re,useReducer:Re,useRef:Re,useState:Re,useDebugValue:Re,useResponder:Re,useDeferredValue:Re,useTransition:Re},xx={readContext:Ze,useCallback:Hp,useContext:Ze,useEffect:Op,useImperativeHandle:function(e,t,i){return i=i!=null?i.concat([e]):null,El(4,2,Up.bind(null,t,e),i)},useLayoutEffect:function(e,t){return El(4,2,e,t)},useMemo:function(e,t){var i=tn();return t=t===void 0?null:t,e=e(),i.memoizedState=[e,t],e},useReducer:function(e,t,i){var n=tn();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=Fp.bind(null,re,e),[n.memoizedState,e]},useRef:function(e){var t=tn();return e={current:e},t.memoizedState=e},useState:Il,useDebugValue:Tl,useResponder:Sl,useDeferredValue:function(e,t){var i=Il(e),n=i[0],r=i[1];return Op(function(){var s=Ge.suspense;Ge.suspense=t===void 0?null:t;try{r(e)}finally{Ge.suspense=s}},[e,t]),n},useTransition:function(e){var t=Il(!1),i=t[0];return t=t[1],[Hp(Nl.bind(null,t,e),[t,e]),i]}},Sx={readContext:Ze,useCallback:bs,useContext:Ze,useEffect:Is,useImperativeHandle:$p,useLayoutEffect:_p,useMemo:Wp,useReducer:Cs,useRef:Bp,useState:function(){return Cs(vi)},useDebugValue:Tl,useResponder:Sl,useDeferredValue:function(e,t){var i=Cs(vi),n=i[0],r=i[1];return Is(function(){var s=Ge.suspense;Ge.suspense=t===void 0?null:t;try{r(e)}finally{Ge.suspense=s}},[e,t]),n},useTransition:function(e){var t=Cs(vi),i=t[0];return t=t[1],[bs(Nl.bind(null,t,e),[t,e]),i]}},Cx={readContext:Ze,useCallback:bs,useContext:Ze,useEffect:Is,useImperativeHandle:$p,useLayoutEffect:_p,useMemo:Wp,useReducer:Ms,useRef:Bp,useState:function(){return Ms(vi)},useDebugValue:Tl,useResponder:Sl,useDeferredValue:function(e,t){var i=Ms(vi),n=i[0],r=i[1];return Is(function(){var s=Ge.suspense;Ge.suspense=t===void 0?null:t;try{r(e)}finally{Ge.suspense=s}},[e,t]),n},useTransition:function(e){var t=Ms(vi),i=t[0];return t=t[1],[bs(Nl.bind(null,t,e),[t,e]),i]}},bt=null,Gt=null,wi=!1;function Qp(e,t){var i=ft(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 Zp(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 Pl(e){if(wi){var t=Gt;if(t){var i=t;if(!Zp(e,t)){if(t=Fi(i.nextSibling),!t||!Zp(e,t)){e.effectTag=e.effectTag&-1025|2,wi=!1,bt=e;return}Qp(bt,i)}bt=e,Gt=Fi(t.firstChild)}else e.effectTag=e.effectTag&-1025|2,wi=!1,bt=e}}function Gp(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;bt=e}function As(e){if(e!==bt)return!1;if(!wi)return Gp(e),wi=!0,!1;var t=e.type;if(e.tag!==5||t!=="head"&&t!=="body"&&!Ka(t,e.memoizedProps))for(t=Gt;t;)Qp(e,t),t=Fi(t.nextSibling);if(Gp(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(S(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var i=e.data;if(i===Wh){if(t===0){Gt=Fi(e.nextSibling);break e}t--}else i!==Hh&&i!==Ya&&i!==Ga||t++}e=e.nextSibling}Gt=null}}else Gt=bt?Fi(e.stateNode.nextSibling):null;return!0}function kl(){Gt=bt=null,wi=!1}var Mx=et.ReactCurrentOwner,dt=!1;function Ve(e,t,i,n){t.child=e===null?wl(t,null,i,n):qi(t,e.child,i,n)}function Yp(e,t,i,n,r){i=i.render;var s=t.ref;return Ki(t,r),n=Ml(e,t,i,n,s,r),e!==null&&!dt?(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=r&&(e.expirationTime=0),Et(e,t,r)):(t.effectTag|=1,Ve(e,t,n,r),t.child)}function Xp(e,t,i,n,r,s){if(e===null){var o=i.type;return typeof o=="function"&&!Jl(o)&&o.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(t.tag=15,t.type=o,Jp(e,t,o,n,r,s)):(e=$s(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:Qn,i(r,n)&&e.ref===t.ref)?Et(e,t,s):(t.effectTag|=1,e=bi(o,n),e.ref=t.ref,e.return=t,t.child=e)}function Jp(e,t,i,n,r,s){return e!==null&&Qn(e.memoizedProps,n)&&e.ref===t.ref&&(dt=!1,r<s)?(t.expirationTime=e.expirationTime,Et(e,t,s)):zl(e,t,i,n,s)}function Kp(e,t){var i=t.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(t.effectTag|=128)}function zl(e,t,i,n,r){var s=Te(i)?gi:ge.current;return s=Xi(t,s),Ki(t,r),i=Ml(e,t,i,n,s,r),e!==null&&!dt?(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=r&&(e.expirationTime=0),Et(e,t,r)):(t.effectTag|=1,Ve(e,t,i,r),t.child)}function qp(e,t,i,n,r){if(Te(i)){var s=!0;as(t)}else s=!1;if(Ki(t,r),t.stateNode===null)e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),Lp(t,i,n),vl(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=Ze(u):(u=Te(i)?gi:ge.current,u=Xi(t,u));var c=i.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&jp(t,o,n,u),Wt=!1;var m=t.memoizedState;o.state=m,Gn(t,n,o,r),l=t.memoizedState,a!==n||m!==l||Ae.current||Wt?(typeof c=="function"&&(gs(t,i,c,n),l=t.memoizedState),(a=Wt||Dp(t,i,a,n,m,l,u))?(d||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,ml(e,t),a=t.memoizedProps,o.props=t.type===t.elementType?a:tt(t.type,a),l=o.context,u=i.contextType,typeof u=="object"&&u!==null?u=Ze(u):(u=Te(i)?gi:ge.current,u=Xi(t,u)),c=i.getDerivedStateFromProps,(d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&jp(t,o,n,u),Wt=!1,l=t.memoizedState,o.state=l,Gn(t,n,o,r),m=t.memoizedState,a!==n||l!==m||Ae.current||Wt?(typeof c=="function"&&(gs(t,i,c,n),m=t.memoizedState),(c=Wt||Dp(t,i,a,n,l,m,u))?(d||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 Dl(e,t,i,n,s,r)}function Dl(e,t,i,n,r,s){Kp(e,t);var o=(t.effectTag&64)!==0;if(!n&&!o)return r&&mp(t,i,!1),Et(e,t,s);n=t.stateNode,Mx.current=t;var a=o&&typeof i.getDerivedStateFromError!="function"?null:n.render();return t.effectTag|=1,e!==null&&o?(t.child=qi(t,e.child,null,s),t.child=qi(t,null,a,s)):Ve(e,t,a,s),t.memoizedState=n.state,r&&mp(t,i,!0),t.child}function ef(e){var t=e.stateNode;t.pendingContext?fp(e,t.pendingContext,t.pendingContext!==t.context):t.context&&fp(e,t.context,!1),yl(e,t.containerInfo)}var Ll={dehydrated:null,retryTime:0};function tf(e,t,i){var n=t.mode,r=t.pendingProps,s=K.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),q(K,s&1),e===null){if(r.fallback!==void 0&&Pl(t),o){if(o=r.fallback,r=Jt(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=Jt(o,n,i,null),i.return=t,r.sibling=i,t.memoizedState=Ll,t.child=r,i}return n=r.children,t.memoizedState=null,t.child=wl(t,null,n,i)}if(e.memoizedState!==null){if(e=e.child,n=e.sibling,o){if(r=r.fallback,i=bi(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=bi(n,r),n.return=t,i.sibling=n,i.childExpirationTime=0,t.memoizedState=Ll,t.child=i,n}return i=qi(t,e.child,r.children,i),t.memoizedState=null,t.child=i}if(e=e.child,o){if(o=r.fallback,r=Jt(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=Jt(o,n,i,null),i.return=t,r.sibling=i,i.effectTag|=2,r.childExpirationTime=0,t.memoizedState=Ll,t.child=r,i}return t.memoizedState=null,t.child=qi(t,e,r.children,i)}function nf(e,t){e.expirationTime<t&&(e.expirationTime=t);var i=e.alternate;i!==null&&i.expirationTime<t&&(i.expirationTime=t),Np(e.return,t)}function jl(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 rf(e,t,i){var n=t.pendingProps,r=n.revealOrder,s=n.tail;if(Ve(e,t,n.children,i),n=K.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&&nf(e,i);else if(e.tag===19)nf(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(q(K,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&&ys(e)===null&&(r=i),i=i.sibling;i=r,i===null?(r=t.child,t.child=null):(r=i.sibling,i.sibling=null),jl(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&&ys(e)===null){t.child=r;break}e=r.sibling,r.sibling=i,i=r,r=e}jl(t,!0,i,null,s,t.lastEffect);break;case"together":jl(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function Et(e,t,i){e!==null&&(t.dependencies=e.dependencies);var n=t.expirationTime;if(n!==0&&Us(n),t.childExpirationTime<i)return null;if(e!==null&&t.child!==e.child)throw Error(S(153));if(t.child!==null){for(e=t.child,i=bi(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=bi(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}var sf,Rl,of,af;sf=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}},Rl=function(){},of=function(e,t,i,n,r){var s=e.memoizedProps;if(s!==n){var o=t.stateNode;switch(mi(ct.current),e=null,i){case"input":s=ba(o,s),n=ba(o,n),e=[];break;case"option":s=Ta(o,s),n=Ta(o,n),e=[];break;case"select":s=Ce({},s,{value:void 0}),n=Ce({},n,{value:void 0}),e=[];break;case"textarea":s=Na(o,s),n=Na(o,n),e=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(o.onclick=qr)}Wa(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"&&(Bi.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"&&(Bi.hasOwnProperty(a)?(u!=null&&St(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)}},af=function(e,t,i,n){i!==n&&(t.effectTag|=4)};function Ts(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 Ix(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 Te(t.type)&&os(),null;case 3:return en(),Y(Ae),Y(ge),i=t.stateNode,i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),e!==null&&e.child!==null||!As(t)||(t.effectTag|=4),Rl(t),null;case 5:xl(t),i=mi(qn.current);var r=t.type;if(e!==null&&t.stateNode!=null)of(e,t,r,n,i),e.ref!==t.ref&&(t.effectTag|=128);else{if(!n){if(t.stateNode===null)throw Error(S(166));return null}if(e=mi(ct.current),As(t)){n=t.stateNode,r=t.type;var s=t.memoizedProps;switch(n[_t]=t,n[es]=s,r){case"iframe":case"object":case"embed":X("load",n);break;case"video":case"audio":for(e=0;e<Tn.length;e++)X(Tn[e],n);break;case"source":X("error",n);break;case"img":case"image":case"link":X("error",n),X("load",n);break;case"form":X("reset",n),X("submit",n);break;case"details":X("toggle",n);break;case"input":oh(n,s),X("invalid",n),St(i,"onChange");break;case"select":n._wrapperState={wasMultiple:!!s.multiple},X("invalid",n),St(i,"onChange");break;case"textarea":uh(n,s),X("invalid",n),St(i,"onChange")}Wa(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]):Bi.hasOwnProperty(o)&&a!=null&&St(i,o)}switch(r){case"input":Wr(n),lh(n,s,!0);break;case"textarea":Wr(n),dh(n);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(n.onclick=qr)}i=e,t.updateQueue=i,i!==null&&(t.effectTag|=4)}else{switch(o=i.nodeType===9?i:i.ownerDocument,e===Bh&&(e=ph(r)),e===Bh?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[_t]=t,e[es]=n,sf(e,t,!1,!1),t.stateNode=e,o=Fa(r,n),r){case"iframe":case"object":case"embed":X("load",e),a=n;break;case"video":case"audio":for(a=0;a<Tn.length;a++)X(Tn[a],e);a=n;break;case"source":X("error",e),a=n;break;case"img":case"image":case"link":X("error",e),X("load",e),a=n;break;case"form":X("reset",e),X("submit",e),a=n;break;case"details":X("toggle",e),a=n;break;case"input":oh(e,n),a=ba(e,n),X("invalid",e),St(i,"onChange");break;case"option":a=Ta(e,n);break;case"select":e._wrapperState={wasMultiple:!!n.multiple},a=Ce({},n,{value:void 0}),X("invalid",e),St(i,"onChange");break;case"textarea":uh(e,n),a=Na(e,n),X("invalid",e),St(i,"onChange");break;default:a=n}Wa(r,a);var l=a;for(s in l)if(l.hasOwnProperty(s)){var u=l[s];s==="style"?Vh(e,u):s==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&fh(e,u)):s==="children"?typeof u=="string"?(r!=="textarea"||u!=="")&&An(e,u):typeof u=="number"&&An(e,""+u):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Bi.hasOwnProperty(s)?u!=null&&St(i,s):u!=null&&xa(e,s,u,o))}switch(r){case"input":Wr(e),lh(e,n,!1);break;case"textarea":Wr(e),dh(e);break;case"option":n.value!=null&&e.setAttribute("value",""+Rt(n.value));break;case"select":e.multiple=!!n.multiple,i=n.value,i!=null?$i(e,!!n.multiple,i,!1):n.defaultValue!=null&&$i(e,!!n.multiple,n.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=qr)}Fh(r,n)&&(t.effectTag|=4)}t.ref!==null&&(t.effectTag|=128)}return null;case 6:if(e&&t.stateNode!=null)af(e,t,e.memoizedProps,n);else{if(typeof n!="string"&&t.stateNode===null)throw Error(S(166));i=mi(qn.current),mi(ct.current),As(t)?(i=t.stateNode,n=t.memoizedProps,i[_t]=t,i.nodeValue!==n&&(t.effectTag|=4)):(i=(i.nodeType===9?i:i.ownerDocument).createTextNode(n),i[_t]=t,t.stateNode=i)}return null;case 13:return Y(K),n=t.memoizedState,(t.effectTag&64)!==0?(t.expirationTime=i,t):(i=n!==null,n=!1,e===null?t.memoizedProps.fallback!==void 0&&As(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||(K.current&1)!==0?le===yi&&(le=ks):((le===yi||le===ks)&&(le=zs),tr!==0&&Be!==null&&(Ei(Be,Ne),Df(Be,tr)))),(i||n)&&(t.effectTag|=4),null);case 4:return en(),Rl(t),null;case 10:return fl(t),null;case 17:return Te(t.type)&&os(),null;case 19:if(Y(K),n=t.memoizedState,n===null)return null;if(r=(t.effectTag&64)!==0,s=n.rendering,s===null){if(r)Ts(n,!1);else if(le!==yi||e!==null&&(e.effectTag&64)!==0)for(s=t.child;s!==null;){if(e=ys(s),e!==null){for(t.effectTag|=64,Ts(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 q(K,K.current&1|2),t.child}s=s.sibling}}else{if(!r)if(e=ys(s),e!==null){if(t.effectTag|=64,r=!0,i=e.updateQueue,i!==null&&(t.updateQueue=i,t.effectTag|=4),Ts(n,!0),n.tail===null&&n.tailMode==="hidden"&&!s.alternate)return t=t.lastEffect=n.lastEffect,t!==null&&(t.nextEffect=null),null}else 2*Qe()-n.renderingStartTime>n.tailExpiration&&1<i&&(t.effectTag|=64,r=!0,Ts(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=Qe()+500),i=n.tail,n.rendering=i,n.tail=i.sibling,n.lastEffect=t.lastEffect,n.renderingStartTime=Qe(),i.sibling=null,t=K.current,q(K,r?t&1|2:t&1),i):null}throw Error(S(156,t.tag))}function bx(e){switch(e.tag){case 1:Te(e.type)&&os();var t=e.effectTag;return t&4096?(e.effectTag=t&-4097|64,e):null;case 3:if(en(),Y(Ae),Y(ge),t=e.effectTag,(t&64)!==0)throw Error(S(285));return e.effectTag=t&-4097|64,e;case 5:return xl(e),null;case 13:return Y(K),t=e.effectTag,t&4096?(e.effectTag=t&-4097|64,e):null;case 19:return Y(K),null;case 4:return en(),null;case 10:return fl(e),null;default:return null}}function Vl(e,t){return{value:e,source:t,stack:Ia(t)}}var Ex=typeof WeakSet=="function"?WeakSet:Set;function Bl(e,t){var i=t.source,n=t.stack;n===null&&i!==null&&(n=Ia(i)),i!==null&&xt(i.type),t=t.value,e!==null&&e.tag===1&&xt(e.type);try{console.error(t)}catch(r){setTimeout(function(){throw r})}}function Ax(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(i){Ii(e,i)}}function lf(e){var t=e.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){Ii(e,i)}else t.current=null}function Tx(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:tt(t.type,i),n),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(S(163))}function uf(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 cf(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 Nx(e,t,i){switch(i.tag){case 0:case 11:case 15:case 22:cf(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:tt(i.type,t.memoizedProps);e.componentDidUpdate(n,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}t=i.updateQueue,t!==null&&kp(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}kp(i,t,e)}return;case 5:e=i.stateNode,t===null&&i.effectTag&4&&Fh(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&&zh(i))));return;case 19:case 17:case 20:case 21:return}throw Error(S(163))}function df(e,t,i){switch(typeof Xl=="function"&&Xl(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;Ht(97<i?97:i,function(){var r=n;do{var s=r.destroy;if(s!==void 0){var o=t;try{s()}catch(a){Ii(o,a)}}r=r.next}while(r!==n)})}break;case 1:lf(t),i=t.stateNode,typeof i.componentWillUnmount=="function"&&Ax(t,i);break;case 5:lf(t);break;case 4:gf(e,t,i)}}function hf(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&&hf(t)}function pf(e){return e.tag===5||e.tag===3||e.tag===4}function ff(e){e:{for(var t=e.return;t!==null;){if(pf(t)){var i=t;break e}t=t.return}throw Error(S(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(S(161))}i.effectTag&16&&(An(t,""),i.effectTag&=-17);e:t:for(i=e;;){for(;i.sibling===null;){if(i.return===null||pf(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?Ol(e,i,t):_l(e,i,t)}function Ol(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=qr));else if(n!==4&&(e=e.child,e!==null))for(Ol(e,t,i),e=e.sibling;e!==null;)Ol(e,t,i),e=e.sibling}function _l(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(_l(e,t,i),e=e.sibling;e!==null;)_l(e,t,i),e=e.sibling}function gf(e,t,i){for(var n=t,r=!1,s,o;;){if(!r){r=n.return;e:for(;;){if(r===null)throw Error(S(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(df(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(df(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 Ul(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:uf(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[es]=n,e==="input"&&n.type==="radio"&&n.name!=null&&ah(i,n),Fa(e,r),t=Fa(e,n),r=0;r<s.length;r+=2){var o=s[r],a=s[r+1];o==="style"?Vh(i,a):o==="dangerouslySetInnerHTML"?fh(i,a):o==="children"?An(i,a):xa(i,o,a,t)}switch(e){case"input":Ea(i,n);break;case"textarea":ch(i,n);break;case"select":t=i._wrapperState.wasMultiple,i._wrapperState.wasMultiple=!!n.multiple,e=n.value,e!=null?$i(i,!!n.multiple,e,!1):t!==!!n.multiple&&(n.defaultValue!=null?$i(i,!!n.multiple,n.defaultValue,!0):$i(i,!!n.multiple,n.multiple?[]:"",!1))}}}return;case 6:if(t.stateNode===null)throw Error(S(162));t.stateNode.nodeValue=t.memoizedProps;return;case 3:t=t.stateNode,t.hydrate&&(t.hydrate=!1,zh(t.containerInfo));return;case 12:return;case 13:if(i=t,t.memoizedState===null?n=!1:(n=!0,i=t.child,Wl=Qe()),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=Rh("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}mf(t);return;case 19:mf(t);return;case 17:return}throw Error(S(163))}function mf(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ex),t.forEach(function(n){var r=Ox.bind(null,e,n);i.has(n)||(i.add(n),n.then(r,r))})}}var Px=typeof WeakMap=="function"?WeakMap:Map;function vf(e,t,i){i=Ft(i,null),i.tag=3,i.payload={element:null};var n=t.value;return i.callback=function(){Rs||(Rs=!0,Fl=n),Bl(e,t)},i}function wf(e,t,i){i=Ft(i,null),i.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var r=t.value;i.payload=function(){return Bl(e,t),n(r)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(i.callback=function(){typeof n!="function"&&(Yt===null?Yt=new Set([this]):Yt.add(this),Bl(e,t));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),i}var kx=Math.ceil,Ns=et.ReactCurrentDispatcher,yf=et.ReactCurrentOwner,ae=0,$l=8,it=16,ht=32,yi=0,Ps=1,xf=2,ks=3,zs=4,Hl=5,j=ae,Be=null,V=null,Ne=0,le=yi,Ds=null,At=1073741823,er=1073741823,Ls=null,tr=0,js=!1,Wl=0,Sf=500,T=null,Rs=!1,Fl=null,Yt=null,Vs=!1,ir=null,nr=90,xi=null,rr=0,Ql=null,Bs=0;function pt(){return(j&(it|ht))!==ae?1073741821-(Qe()/10|0):Bs!==0?Bs:Bs=1073741821-(Qe()/10|0)}function Si(e,t,i){if(t=t.mode,(t&2)===0)return 1073741823;var n=cs();if((t&4)===0)return n===99?1073741823:1073741822;if((j&it)!==ae)return Ne;if(i!==null)e=ds(e,i.timeoutMs|0||5e3,250);else switch(n){case 99:e=1073741823;break;case 98:e=ds(e,150,100);break;case 97:case 96:e=ds(e,5e3,250);break;case 95:e=2;break;default:throw Error(S(326))}return Be!==null&&e===Ne&&--e,e}function Xt(e,t){if(50<rr)throw rr=0,Ql=null,Error(S(185));if(e=Os(e,t),e!==null){var i=cs();t===1073741823?(j&$l)!==ae&&(j&(it|ht))===ae?Zl(e):(Oe(e),j===ae&&ut()):Oe(e),(j&4)===ae||i!==98&&i!==99||(xi===null?xi=new Map([[e,t]]):(i=xi.get(e),(i===void 0||i>t)&&xi.set(e,t)))}}function Os(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&&(Be===r&&(Us(t),le===zs&&Ei(r,Ne)),Df(r,t)),r}function _s(e){var t=e.lastExpiredTime;if(t!==0||(t=e.firstPendingTime,!zf(e,t)))return t;var i=e.lastPingedTime;return e=e.nextKnownPendingLevel,e=i>e?i:e,2>=e&&t!==e?0:e}function Oe(e){if(e.lastExpiredTime!==0)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=Ap(Zl.bind(null,e));else{var t=_s(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!==Mp&&vp(i)}e.callbackExpirationTime=t,e.callbackPriority=n,t=t===1073741823?Ap(Zl.bind(null,e)):Ep(n,Cf.bind(null,e),{timeout:10*(1073741821-t)-Qe()}),e.callbackNode=t}}}function Cf(e,t){if(Bs=0,t)return t=pt(),eu(e,t),Oe(e),null;var i=_s(e);if(i!==0){if(t=e.callbackNode,(j&(it|ht))!==ae)throw Error(S(327));if(rn(),e===Be&&i===Ne||Ci(e,i),V!==null){var n=j;j|=it;var r=Ef();do try{Lx();break}catch(a){bf(e,a)}while(1);if(pl(),j=n,Ns.current=r,le===Ps)throw t=Ds,Ci(e,i),Ei(e,i),Oe(e),t;if(V===null)switch(r=e.finishedWork=e.current.alternate,e.finishedExpirationTime=i,n=le,Be=null,n){case yi:case Ps:throw Error(S(345));case xf:eu(e,2<i?2:i);break;case ks:if(Ei(e,i),n=e.lastSuspendedTime,i===n&&(e.nextKnownPendingLevel=Gl(r)),At===1073741823&&(r=Wl+Sf-Qe(),10<r)){if(js){var s=e.lastPingedTime;if(s===0||s>=i){e.lastPingedTime=i,Ci(e,i);break}}if(s=_s(e),s!==0&&s!==i)break;if(n!==0&&n!==i){e.lastPingedTime=n;break}e.timeoutHandle=qa(Mi.bind(null,e),r);break}Mi(e);break;case zs:if(Ei(e,i),n=e.lastSuspendedTime,i===n&&(e.nextKnownPendingLevel=Gl(r)),js&&(r=e.lastPingedTime,r===0||r>=i)){e.lastPingedTime=i,Ci(e,i);break}if(r=_s(e),r!==0&&r!==i)break;if(n!==0&&n!==i){e.lastPingedTime=n;break}if(er!==1073741823?n=10*(1073741821-er)-Qe():At===1073741823?n=0:(n=10*(1073741821-At)-5e3,r=Qe(),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*kx(n/1960))-n,i<n&&(n=i)),10<n){e.timeoutHandle=qa(Mi.bind(null,e),n);break}Mi(e);break;case Hl:if(At!==1073741823&&Ls!==null){s=At;var o=Ls;if(n=o.busyMinDurationMs|0,0>=n?n=0:(r=o.busyDelayMs|0,s=Qe()-(10*(1073741821-s)-(o.timeoutMs|0||5e3)),n=s<=r?0:r+n-s),10<n){Ei(e,i),e.timeoutHandle=qa(Mi.bind(null,e),n);break}}Mi(e);break;default:throw Error(S(329))}if(Oe(e),e.callbackNode===t)return Cf.bind(null,e)}}return null}function Zl(e){var t=e.lastExpiredTime;if(t=t!==0?t:1073741823,(j&(it|ht))!==ae)throw Error(S(327));if(rn(),e===Be&&t===Ne||Ci(e,t),V!==null){var i=j;j|=it;var n=Ef();do try{Dx();break}catch(r){bf(e,r)}while(1);if(pl(),j=i,Ns.current=n,le===Ps)throw i=Ds,Ci(e,t),Ei(e,t),Oe(e),i;if(V!==null)throw Error(S(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Be=null,Mi(e),Oe(e)}return null}function zx(){if(xi!==null){var e=xi;xi=null,e.forEach(function(t,i){eu(i,t),Oe(i)}),ut()}}function Mf(e,t){var i=j;j|=1;try{return e(t)}finally{j=i,j===ae&&ut()}}function If(e,t){var i=j;j&=-2,j|=$l;try{return e(t)}finally{j=i,j===ae&&ut()}}function Ci(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,k0(i)),V!==null)for(i=V.return;i!==null;){var n=i;switch(n.tag){case 1:n=n.type.childContextTypes,n!=null&&os();break;case 3:en(),Y(Ae),Y(ge);break;case 5:xl(n);break;case 4:en();break;case 13:Y(K);break;case 19:Y(K);break;case 10:fl(n)}i=i.return}Be=e,V=bi(e.current,null),Ne=t,le=yi,Ds=null,er=At=1073741823,Ls=null,tr=0,js=!1}function bf(e,t){do{try{if(pl(),xs.current=Es,Ss)for(var i=re.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}if(Zt=0,ve=me=re=null,Ss=!1,V===null||V.return===null)return le=Ps,Ds=t,V=null;e:{var r=e,s=V.return,o=V,a=t;if(t=Ne,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=(K.current&1)!==0,d=s;do{var m;if(m=d.tag===13){var w=d.memoizedState;if(w!==null)m=w.dehydrated!==null;else{var y=d.memoizedProps;m=y.fallback===void 0?!1:y.unstable_avoidThisFallback!==!0?!0:!c}}if(m){var M=d.updateQueue;if(M===null){var p=new Set;p.add(l),d.updateQueue=p}else M.add(l);if((d.mode&2)===0){if(d.effectTag|=64,o.effectTag&=-2981,o.tag===1)if(o.alternate===null)o.tag=17;else{var h=Ft(1073741823,null);h.tag=2,Qt(o,h)}o.expirationTime=1073741823;break e}a=void 0,o=t;var f=r.pingCache;if(f===null?(f=r.pingCache=new Px,a=new Set,f.set(l,a)):(a=f.get(l),a===void 0&&(a=new Set,f.set(l,a))),!a.has(o)){a.add(o);var g=Bx.bind(null,r,l,o);l.then(g,g)}d.effectTag|=4096,d.expirationTime=t;break e}d=d.return}while(d!==null);a=Error((xt(o.type)||"A React component")+` suspended while rendering, but no fallback UI was specified.
44
44
 
45
45
  Add a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.`+Ia(o))}le!==Hl&&(le=xf),a=Vl(a,o),d=s;do{switch(d.tag){case 3:l=a,d.effectTag|=4096,d.expirationTime=t;var v=vf(d,l,t);Pp(d,v);break e;case 1:l=a;var C=d.type,x=d.stateNode;if((d.effectTag&64)===0&&(typeof C.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Yt===null||!Yt.has(x)))){d.effectTag|=4096,d.expirationTime=t;var N=wf(d,l,t);Pp(d,N);break e}}d=d.return}while(d!==null)}V=Nf(V)}catch(z){t=z;continue}break}while(1)}function Ef(){var e=Ns.current;return Ns.current=Es,e===null?Es:e}function Af(e,t){e<At&&2<e&&(At=e),t!==null&&e<er&&2<e&&(er=e,Ls=t)}function Us(e){e>tr&&(tr=e)}function Dx(){for(;V!==null;)V=Tf(V)}function Lx(){for(;V!==null&&!wx();)V=Tf(V)}function Tf(e){var t=kf(e.alternate,e,Ne);return e.memoizedProps=e.pendingProps,t===null&&(t=Nf(e)),yf.current=null,t}function Nf(e){V=e;do{var t=V.alternate;if(e=V.return,(V.effectTag&2048)===0){if(t=Ix(t,V,Ne),Ne===1||V.childExpirationTime!==1){for(var i=0,n=V.child;n!==null;){var r=n.expirationTime,s=n.childExpirationTime;r>i&&(i=r),s>i&&(i=s),n=n.sibling}V.childExpirationTime=i}if(t!==null)return t;e!==null&&(e.effectTag&2048)===0&&(e.firstEffect===null&&(e.firstEffect=V.firstEffect),V.lastEffect!==null&&(e.lastEffect!==null&&(e.lastEffect.nextEffect=V.firstEffect),e.lastEffect=V.lastEffect),1<V.effectTag&&(e.lastEffect!==null?e.lastEffect.nextEffect=V:e.firstEffect=V,e.lastEffect=V))}else{if(t=bx(V),t!==null)return t.effectTag&=2047,t;e!==null&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(t=V.sibling,t!==null)return t;V=e}while(V!==null);return le===yi&&(le=Hl),null}function Gl(e){var t=e.expirationTime;return e=e.childExpirationTime,t>e?t:e}function Mi(e){var t=cs();return Ht(99,jx.bind(null,e,t)),null}function jx(e,t){do rn();while(ir!==null);if((j&(it|ht))!==ae)throw Error(S(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(S(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var r=Gl(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===Be&&(V=Be=null,Ne=0),1<i.effectTag?i.lastEffect!==null?(i.lastEffect.nextEffect=i,r=i.firstEffect):r=i:r=i.firstEffect,r!==null){var s=j;j|=ht,yf.current=null,Xa=Jr;var o=$h();if(Za(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 d=0,m=-1,w=-1,y=0,M=0,p=o,h=null;t:for(;;){for(var f;p!==a||u!==0&&p.nodeType!==3||(m=d+u),p!==c||l!==0&&p.nodeType!==3||(w=d+l),p.nodeType===3&&(d+=p.nodeValue.length),(f=p.firstChild)!==null;)h=p,p=f;for(;;){if(p===o)break t;if(h===a&&++y===u&&(m=d),h===c&&++M===l&&(w=d),(f=p.nextSibling)!==null)break;p=h,h=p.parentNode}p=f}a=m===-1||w===-1?null:{start:m,end:w}}else a=null}a=a||{start:0,end:0}}else a=null;Ja={activeElementDetached:null,focusedElem:o,selectionRange:a},Jr=!1,T=r;do try{Rx()}catch(P){if(T===null)throw Error(S(330));Ii(T,P),T=T.nextEffect}while(T!==null);T=r;do try{for(o=e,a=t;T!==null;){var g=T.effectTag;if(g&16&&An(T.stateNode,""),g&128){var v=T.alternate;if(v!==null){var C=v.ref;C!==null&&(typeof C=="function"?C(null):C.current=null)}}switch(g&1038){case 2:ff(T),T.effectTag&=-3;break;case 6:ff(T),T.effectTag&=-3,Ul(T.alternate,T);break;case 1024:T.effectTag&=-1025;break;case 1028:T.effectTag&=-1025,Ul(T.alternate,T);break;case 4:Ul(T.alternate,T);break;case 8:u=T,gf(o,u,a),hf(u)}T=T.nextEffect}}catch(P){if(T===null)throw Error(S(330));Ii(T,P),T=T.nextEffect}while(T!==null);if(C=Ja,v=$h(),g=C.focusedElem,a=C.selectionRange,v!==g&&g&&g.ownerDocument&&Uh(g.ownerDocument.documentElement,g)){for(a!==null&&Za(g)&&(v=a.start,C=a.end,C===void 0&&(C=v),"selectionStart"in g?(g.selectionStart=v,g.selectionEnd=Math.min(C,g.value.length)):(C=(v=g.ownerDocument||document)&&v.defaultView||window,C.getSelection&&(C=C.getSelection(),u=g.textContent.length,o=Math.min(a.start,u),a=a.end===void 0?o:Math.min(a.end,u),!C.extend&&o>a&&(u=a,a=o,o=u),u=_h(g,o),c=_h(g,a),u&&c&&(C.rangeCount!==1||C.anchorNode!==u.node||C.anchorOffset!==u.offset||C.focusNode!==c.node||C.focusOffset!==c.offset)&&(v=v.createRange(),v.setStart(u.node,u.offset),C.removeAllRanges(),o>a?(C.addRange(v),C.extend(c.node,c.offset)):(v.setEnd(c.node,c.offset),C.addRange(v)))))),v=[],C=g;C=C.parentNode;)C.nodeType===1&&v.push({element:C,left:C.scrollLeft,top:C.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;g<v.length;g++)C=v[g],C.element.scrollLeft=C.left,C.element.scrollTop=C.top}Jr=!!Xa,Ja=Xa=null,e.current=i,T=r;do try{for(g=e;T!==null;){var x=T.effectTag;if(x&36&&Nx(g,T.alternate,T),x&128){v=void 0;var N=T.ref;if(N!==null){var z=T.stateNode;switch(T.tag){case 5:v=z;break;default:v=z}typeof N=="function"?N(v):N.current=v}}T=T.nextEffect}}catch(P){if(T===null)throw Error(S(330));Ii(T,P),T=T.nextEffect}while(T!==null);T=null,yx(),j=s}else e.current=i;if(Vs)Vs=!1,ir=e,nr=t;else for(T=r;T!==null;)t=T.nextEffect,T.nextEffect=null,T=t;if(t=e.firstPendingTime,t===0&&(Yt=null),t===1073741823?e===Ql?rr++:(rr=0,Ql=e):rr=0,typeof Yl=="function"&&Yl(i.stateNode,n),Oe(e),Rs)throw Rs=!1,e=Fl,Fl=null,e;return(j&$l)!==ae||ut(),null}function Rx(){for(;T!==null;){var e=T.effectTag;(e&256)!==0&&Tx(T.alternate,T),(e&512)===0||Vs||(Vs=!0,Ep(97,function(){return rn(),null})),T=T.nextEffect}}function rn(){if(nr!==90){var e=97<nr?97:nr;return nr=90,Ht(e,Vx)}}function Vx(){if(ir===null)return!1;var e=ir;if(ir=null,(j&(it|ht))!==ae)throw Error(S(331));var t=j;for(j|=ht,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:uf(5,i),cf(5,i)}}catch(n){if(e===null)throw Error(S(330));Ii(e,n)}i=e.nextEffect,e.nextEffect=null,e=i}return j=t,ut(),!0}function Pf(e,t,i){t=Vl(i,t),t=vf(e,t,1073741823),Qt(e,t),e=Os(e,1073741823),e!==null&&Oe(e)}function Ii(e,t){if(e.tag===3)Pf(e,e,t);else for(var i=e.return;i!==null;){if(i.tag===3){Pf(i,e,t);break}else if(i.tag===1){var n=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Yt===null||!Yt.has(n))){e=Vl(t,e),e=wf(i,e,1073741823),Qt(i,e),i=Os(i,1073741823),i!==null&&Oe(i);break}}i=i.return}}function Bx(e,t,i){var n=e.pingCache;n!==null&&n.delete(t),Be===e&&Ne===i?le===zs||le===ks&&At===1073741823&&Qe()-Wl<Sf?Ci(e,Ne):js=!0:zf(e,i)&&(t=e.lastPingedTime,t!==0&&t<i||(e.lastPingedTime=i,Oe(e)))}function Ox(e,t){var i=e.stateNode;i!==null&&i.delete(t),t=0,t===0&&(t=pt(),t=Si(t,e,null)),e=Os(e,t),e!==null&&Oe(e)}var kf;kf=function(e,t,i){var n=t.expirationTime;if(e!==null){var r=t.pendingProps;if(e.memoizedProps!==r||Ae.current)dt=!0;else{if(n<i){switch(dt=!1,t.tag){case 3:ef(t),kl();break;case 5:if(Vp(t),t.mode&4&&i!==1&&r.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:Te(t.type)&&as(t);break;case 4:yl(t,t.stateNode.containerInfo);break;case 10:n=t.memoizedProps.value,r=t.type._context,q(hs,r._currentValue),r._currentValue=n;break;case 13:if(t.memoizedState!==null)return n=t.child.childExpirationTime,n!==0&&n>=i?tf(e,t,i):(q(K,K.current&1),t=Et(e,t,i),t!==null?t.sibling:null);q(K,K.current&1);break;case 19:if(n=t.childExpirationTime>=i,(e.effectTag&64)!==0){if(n)return rf(e,t,i);t.effectTag|=64}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null),q(K,K.current),!n)return null}return Et(e,t,i)}dt=!1}}else dt=!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=Xi(t,ge.current),Ki(t,i),r=Ml(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,Te(n)){var s=!0;as(t)}else s=!1;t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,gl(t);var o=n.getDerivedStateFromProps;typeof o=="function"&&gs(t,n,o,e),r.updater=ms,t.stateNode=r,r._reactInternalFiber=t,vl(t,n,e,i),t=Dl(null,t,n,!0,s,i)}else t.tag=0,Ve(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,f0(r),r._status!==1)throw r._result;switch(r=r._result,t.type=r,s=t.tag=$x(r),e=tt(r,e),s){case 0:t=zl(null,t,r,e,i);break e;case 1:t=qp(null,t,r,e,i);break e;case 11:t=Yp(null,t,r,e,i);break e;case 14:t=Xp(null,t,r,tt(r.type,e),n,i);break e}throw Error(S(306,r,""))}return t;case 0:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:tt(n,r),zl(e,t,n,r,i);case 1:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:tt(n,r),qp(e,t,n,r,i);case 3:if(ef(t),n=t.updateQueue,e===null||n===null)throw Error(S(282));if(n=t.pendingProps,r=t.memoizedState,r=r!==null?r.element:null,ml(e,t),Gn(t,n,null,i),n=t.memoizedState.element,n===r)kl(),t=Et(e,t,i);else{if((r=t.stateNode.hydrate)&&(Gt=Fi(t.stateNode.containerInfo.firstChild),bt=t,r=wi=!0),r)for(i=wl(t,null,n,i),t.child=i;i;)i.effectTag=i.effectTag&-3|1024,i=i.sibling;else Ve(e,t,n,i),kl();t=t.child}return t;case 5:return Vp(t),e===null&&Pl(t),n=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,Ka(n,r)?o=null:s!==null&&Ka(n,s)&&(t.effectTag|=16),Kp(e,t),t.mode&4&&i!==1&&r.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(Ve(e,t,o,i),t=t.child),t;case 6:return e===null&&Pl(t),null;case 13:return tf(e,t,i);case 4:return yl(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=qi(t,null,n,i):Ve(e,t,n,i),t.child;case 11:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:tt(n,r),Yp(e,t,n,r,i);case 7:return Ve(e,t,t.pendingProps,i),t.child;case 8:return Ve(e,t,t.pendingProps.children,i),t.child;case 12:return Ve(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(q(hs,a._currentValue),a._currentValue=s,o!==null)if(a=o.value,s=fi(a,s)?0:(typeof n._calculateChangedBits=="function"?n._calculateChangedBits(a,s):1073741823)|0,s===0){if(o.children===r.children&&!Ae.current){t=Et(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=Ft(i,null),u.tag=2,Qt(a,u)),a.expirationTime<i&&(a.expirationTime=i),u=a.alternate,u!==null&&u.expirationTime<i&&(u.expirationTime=i),Np(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}Ve(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=Ze(r,s.unstable_observedBits),n=n(r),t.effectTag|=1,Ve(e,t,n,i),t.child;case 14:return r=t.type,s=tt(r,t.pendingProps),s=tt(r.type,s),Xp(e,t,r,s,n,i);case 15:return Jp(e,t,t.type,t.pendingProps,n,i);case 17:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:tt(n,r),e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,Te(n)?(e=!0,as(t)):e=!1,Ki(t,i),Lp(t,n,r),vl(t,n,r,i),Dl(null,t,n,!0,e,i);case 19:return rf(e,t,i)}throw Error(S(156,t.tag))};var Yl=null,Xl=null;function _x(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);Yl=function(n){try{t.onCommitFiberRoot(i,n,void 0,(n.current.effectTag&64)===64)}catch{}},Xl=function(n){try{t.onCommitFiberUnmount(i,n)}catch{}}}catch{}return!0}function Ux(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 ft(e,t,i,n){return new Ux(e,t,i,n)}function Jl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $x(e){if(typeof e=="function")return Jl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Sa)return 11;if(e===Ma)return 14}return 2}function bi(e,t){var i=e.alternate;return i===null?(i=ft(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 $s(e,t,i,n,r,s){var o=2;if(n=e,typeof e=="function")Jl(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case di:return Jt(i.children,r,s,t);case p0:o=8,r|=7;break;case Kd:o=8,r|=1;break;case $r:return e=ft(12,i,t,r|8),e.elementType=$r,e.type=$r,e.expirationTime=s,e;case Hr:return e=ft(13,i,t,r),e.type=Hr,e.elementType=Hr,e.expirationTime=s,e;case Ca:return e=ft(19,i,t,r),e.elementType=Ca,e.expirationTime=s,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qd:o=10;break e;case eh:o=9;break e;case Sa:o=11;break e;case Ma:o=14;break e;case th:o=16,n=null;break e;case ih:o=22;break e}throw Error(S(130,e==null?e:typeof e,""))}return t=ft(o,i,t,r),t.elementType=e,t.type=n,t.expirationTime=s,t}function Jt(e,t,i,n){return e=ft(7,e,n,t),e.expirationTime=i,e}function Kl(e,t,i){return e=ft(6,e,null,t),e.expirationTime=i,e}function ql(e,t,i){return t=ft(4,e.children!==null?e.children:[],e.key,t),t.expirationTime=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Hx(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 zf(e,t){var i=e.firstSuspendedTime;return e=e.lastSuspendedTime,i!==0&&i>=t&&e<=t}function Ei(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 Df(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 eu(e,t){var i=e.lastExpiredTime;(i===0||i>t)&&(e.lastExpiredTime=t)}function Hs(e,t,i,n){var r=t.current,s=pt(),o=Yn.suspense;s=Si(s,r,o);e:if(i){i=i._reactInternalFiber;t:{if(hi(i)!==i||i.tag!==1)throw Error(S(170));var a=i;do{switch(a.tag){case 3:a=a.stateNode.context;break t;case 1:if(Te(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break t}}a=a.return}while(a!==null);throw Error(S(171))}if(i.tag===1){var l=i.type;if(Te(l)){i=gp(i,l,a);break e}}i=a}else i=$t;return t.context===null?t.context=i:t.pendingContext=i,t=Ft(s,o),t.payload={element:e},n=n===void 0?null:n,n!==null&&(t.callback=n),Qt(r,t),Xt(r,s),s}function tu(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 Lf(e,t){e=e.memoizedState,e!==null&&e.dehydrated!==null&&e.retryTime<t&&(e.retryTime=t)}function iu(e,t){Lf(e,t),(e=e.alternate)&&Lf(e,t)}function nu(e,t,i){i=i!=null&&i.hydrate===!0;var n=new Hx(e,t,i),r=ft(3,null,null,t===2?7:t===1?3:0);n.current=r,r.stateNode=n,gl(r),e[Vn]=n.current,i&&t!==0&&x0(e,e.nodeType===9?e:e.ownerDocument),this._internalRoot=n}nu.prototype.render=function(e){Hs(e,this._internalRoot,null,null)},nu.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;Hs(null,e,null,function(){t[Vn]=null})};function sr(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Wx(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 nu(e,0,t?{hydrate:!0}:void 0)}function Ws(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=tu(o);a.call(u)}}Hs(t,o,e,r)}else{if(s=i._reactRootContainer=Wx(i,n),o=s._internalRoot,typeof r=="function"){var l=r;r=function(){var u=tu(o);l.call(u)}}If(function(){Hs(t,o,e,r)})}return tu(o)}function Fx(e,t,i){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ui,key:n==null?null:""+n,children:e,containerInfo:t,implementation:i}}Th=function(e){if(e.tag===13){var t=ds(pt(),150,100);Xt(e,t),iu(e,t)}},Ra=function(e){e.tag===13&&(Xt(e,3),iu(e,3))},Nh=function(e){if(e.tag===13){var t=pt();t=Si(t,e,null),Xt(e,t),iu(e,t)}},pa=function(e,t,i){switch(t){case"input":if(Ea(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=tl(n);if(!r)throw Error(S(90));sh(n),Ea(n,r)}}}break;case"textarea":ch(e,i);break;case"select":t=i.value,t!=null&&$i(e,!!i.multiple,t,!1)}},fa=Mf,Qd=function(e,t,i,n,r){var s=j;j|=4;try{return Ht(98,e.bind(null,t,i,n,r))}finally{j=s,j===ae&&ut()}},ga=function(){(j&(1|it|ht))===ae&&(zx(),rn())},Zd=function(e,t){var i=j;j|=2;try{return e(t)}finally{j=i,j===ae&&ut()}};function jf(e,t){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sr(t))throw Error(S(200));return Fx(e,t,null,i)}var Qx={Events:[On,pi,tl,$d,da,Qi,function(e){Da(e,D0)},Wd,Fd,Kr,Gr,rn,{current:!1}]};(function(e){var t=e.findFiberByHostInstance;return _x(Ce({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:et.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Mh(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:Bn,bundleType:0,version:"16.14.0",rendererPackageName:"react-dom"}),Fe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Qx,Fe.createPortal=jf,Fe.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(S(188)):Error(S(268,Object.keys(e)));return e=Mh(t),e=e===null?null:e.stateNode,e},Fe.flushSync=function(e,t){if((j&(it|ht))!==ae)throw Error(S(187));var i=j;j|=1;try{return Ht(99,e.bind(null,t))}finally{j=i,ut()}},Fe.hydrate=function(e,t,i){if(!sr(t))throw Error(S(200));return Ws(null,e,t,!0,i)},Fe.render=function(e,t,i){if(!sr(t))throw Error(S(200));return Ws(null,e,t,!1,i)},Fe.unmountComponentAtNode=function(e){if(!sr(e))throw Error(S(40));return e._reactRootContainer?(If(function(){Ws(null,null,e,!1,function(){e._reactRootContainer=null,e[Vn]=null})}),!0):!1},Fe.unstable_batchedUpdates=Mf,Fe.unstable_createPortal=function(e,t){return jf(e,t,2<arguments.length&&arguments[2]!==void 0?arguments[2]:null)},Fe.unstable_renderSubtreeIntoContainer=function(e,t,i,n){if(!sr(i))throw Error(S(200));if(e==null||e._reactInternalFiber===void 0)throw Error(S(38));return Ws(e,t,i,!1,n)},Fe.version="16.14.0";function Rf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Rf)}catch(e){console.error(e)}}Rf(),Ld.exports=Fe;var Vf=Ld.exports,Zx=Object.defineProperty,Gx=Object.defineProperties,Yx=Object.getOwnPropertyDescriptors,Bf=Object.getOwnPropertySymbols,Xx=Object.prototype.hasOwnProperty,Jx=Object.prototype.propertyIsEnumerable,Of=(e,t,i)=>t in e?Zx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,_e=(e,t)=>{for(var i in t||(t={}))Xx.call(t,i)&&Of(e,i,t[i]);if(Bf)for(var i of Bf(t))Jx.call(t,i)&&Of(e,i,t[i]);return e};const _f={src:"",currentTime:0,hostTime:0,muted:!1,paused:!0,volume:1},Uf={currentTimeMaxError:1,syncInterval:1e3,retryInterval:15e3,verbose:!1,log:console.log.bind(console)};let Kt=Uf;function Kx(e){Kt=_e(_e({},Uf),e)}function Fs(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 qx=navigator.userAgent.includes("Safari"),eS=[".aac",".mid",".midi",".mp3",".ogg",".oga",".wav",".weba"];var tS=typeof global=="object"&&global&&global.Object===Object&&global,iS=typeof self=="object"&&self&&self.Object===Object&&self,$f=tS||iS||Function("return this")(),Qs=$f.Symbol,Hf=Object.prototype,nS=Hf.hasOwnProperty,rS=Hf.toString,or=Qs?Qs.toStringTag:void 0,sS=Object.prototype.toString,Wf=Qs?Qs.toStringTag:void 0;function oS(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Wf&&Wf in Object(e)?function(t){var i=nS.call(t,or),n=t[or];try{t[or]=void 0;var r=!0}catch{}var s=rS.call(t);return r&&(i?t[or]=n:delete t[or]),s}(e):function(t){return sS.call(t)}(e)}var aS=/\s/,lS=/^\s+/;function uS(e){return e&&e.slice(0,function(t){for(var i=t.length;i--&&aS.test(t.charAt(i)););return i}(e)+1).replace(lS,"")}function ru(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var cS=/^[-+]0x[0-9a-f]+$/i,dS=/^0b[01]+$/i,hS=/^0o[0-7]+$/i,pS=parseInt;function Ff(e){if(typeof e=="number")return e;if(function(n){return typeof n=="symbol"||function(r){return r!=null&&typeof r=="object"}(n)&&oS(n)=="[object Symbol]"}(e))return NaN;if(ru(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ru(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=uS(e);var i=dS.test(e);return i||hS.test(e)?pS(e.slice(2),i?2:8):cS.test(e)?NaN:+e}var su=function(){return $f.Date.now()},fS=Math.max,gS=Math.min;function Zs(e,t,i){var n,r,s,o,a,l,u=0,c=!1,d=!1,m=!0;if(typeof e!="function")throw new TypeError("Expected a function");function w(g){var v=n,C=r;return n=r=void 0,u=g,o=e.apply(C,v)}function y(g){return u=g,a=setTimeout(p,t),c?w(g):o}function M(g){var v=g-l;return l===void 0||v>=t||v<0||d&&g-u>=s}function p(){var g=su();if(M(g))return h(g);a=setTimeout(p,function(v){var C=t-(v-l);return d?gS(C,s-(v-u)):C}(g))}function h(g){return a=void 0,m&&n?w(g):(n=r=void 0,o)}function f(){var g=su(),v=M(g);if(n=arguments,r=this,l=g,v){if(a===void 0)return y(l);if(d)return clearTimeout(a),a=setTimeout(p,t),w(l)}return a===void 0&&(a=setTimeout(p,t)),o}return t=Ff(t)||0,ru(i)&&(c=!!i.leading,s=(d="maxWait"in i)?fS(Ff(i.maxWait)||0,t):s,m="trailing"in i?!!i.trailing:m),f.cancel=function(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0},f.flush=function(){return a===void 0?o:h(su())},f}class Qf extends ui.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=_e(_e({},this.getPositionStyle(this.props.buffered)),this.props.bufferColor&&{backgroundColor:this.props.bufferColor});return $.createElement("div",{className:"buffered",style:i})}return null},this.renderProgress=()=>{const i=_e(_e({},this.getPositionStyle(this.props.current)),this.props.sliderColor&&{backgroundColor:this.props.sliderColor});return $.createElement("div",{className:"connect",style:i})},this.renderHoverProgress=()=>{const i=_e(_e({},this.getSeekHoverPosition()),this.props.sliderHoverColor&&{backgroundColor:this.props.sliderHoverColor});return $.createElement("div",{className:"seek-hover",style:i})},this.renderThumb=()=>$.createElement("div",{className:this.isThumbActive()?"thumb active":"thumb",style:this.getThumbHandlerPosition()},$.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:$.createElement("div",{className:this.isThumbActive()?"hover-time active":"hover-time",style:this.getHoverTimePosition(),ref:t=>this.hoverTime=t},this.getHoverTime())}render(){return $.createElement("div",{className:"seek-slider"},$.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},$.createElement("div",{className:"main"},this.renderBufferProgress(),this.renderHoverProgress(),this.renderProgress())),this.drawHoverTime(),this.renderThumb())}}class mS extends ui.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?$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNOCA1LjE0djE0bDExLTdsLTExLTd6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="}):$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMTloNFY1aC00TTYgMTloNFY1SDZ2MTR6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="})},this.operationVolumeButton=()=>this.props.volume>.9?$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMy4yM3YyLjA2YzIuODkuODYgNSAzLjU0IDUgNi43MXMtMi4xMSA1Ljg0LTUgNi43djIuMDdjNC0uOTEgNy00LjQ5IDctOC43N2MwLTQuMjgtMy03Ljg2LTctOC43N00xNi41IDEyYzAtMS43Ny0xLTMuMjktMi41LTQuMDNWMTZjMS41LS43MSAyLjUtMi4yNCAyLjUtNE0zIDl2Nmg0bDUgNVY0TDcgOUgzeiIgZmlsbD0iI2ZmZiI+PC9wYXRoPjwvc3ZnPgo="}):this.props.volume===0?$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNyA5djZoNGw1IDVWNGwtNSA1SDd6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="}):$.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=Zs(i=>{this.props.setCurrentTime(i)},50),this.onVolumeChange=i=>{this.changeVolume(i),this.setState({seekVolume:i/100})},this.changeVolume=Zs(i=>{this.props.setVolume(i/100)},50),this.onVolumeSeekStart=()=>{this.onVolumeSeeking=!0},this.onVolumeSeekEnd=Zs(()=>{this.onVolumeSeeking=!1},500),this.onProgressSeekStart=()=>this.setState({isPlayerSeeking:!0}),this.onProgressSeekEnd=Zs(()=>{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 $.createElement("div",{className:"player-controller",style:{opacity:this.props.visible?"1":"0"}},$.createElement("div",{className:"player-controller-progress"},$.createElement(Qf,{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})),$.createElement("div",{className:"player-controller-actions"},$.createElement("div",{className:"player-controller-actions-left"},$.createElement("div",{onClick:this.onClickOperationButton,className:"player-controller-play"},this.operationButton()),$.createElement("div",{className:"player-volume-box",onMouseEnter:()=>this.setState({isVolumeHover:!0}),onMouseLeave:()=>this.setState({isVolumeHover:!1})},$.createElement("div",{onClick:this.handleClickVolume,className:"player-volume"},this.operationVolumeButton()),$.createElement("div",{className:"player-volume-slider"},$.createElement(Qf,{total:100,current:100*this.state.seekVolume,onChange:this.onVolumeChange,onSeekStart:this.onVolumeSeekStart,onSeekEnd:this.onVolumeSeekEnd,scale:this.props.scale,limitTimeTooltipBySides:!0,hideHoverTime:!0})))),$.createElement("div",{className:"player-mid-box-time"},Zf(Math.floor(i/1e3))," /"," ",Zf(Math.floor(t/1e3)))))}}function Zf(e){const t=e%60,i=(e-t)/60;if(i>=60){const n=i%60;return`${ar((i-n)/60)}:${ar(n)}:${ar(t)}`}return`${ar(i)}:${ar(t)}`}function ar(e){return e<=9?`0${e}`:`${e}`}class vS extends ui.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 $.createElement(wS,{room:i,player:n,context:t,plugin:{putAttributes:r}})}}class wS extends ui.exports.Component{constructor(t){super(t),this.alertMask=null,this.container=$.createRef(),this.controllerHiddenTimer=0,this.syncPlayerTimer=0,this.retryCount=0,this.decreaseRetryTimer=0,this.noSoundSyncCount=0,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=Fs(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)),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=Fs(n,this.props);let o=Kt.currentTimeMaxError;this.state.NoSound&&(o*=3),s>r.duration()?this.resetPlayer():Math.abs(r.currentTime()-s)>o&&(this.debug("<<< currentTime -> %o",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(qx&&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",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(c=>(window.requestAnimationFrame||window.setTimeout)(c)),this.debug("initializing videojs() ...");const u=cu.default(a);this.player=u,window.player=u,u.one("loadedmetadata",this.gracefullyUpdate),u.on("ready",()=>{var c;(c=Kt.onPlayer)==null||c.call(Kt,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=_e(_e({},_f),i),this.player){let r=Fs(i,this.props),s=this.player.duration();!i.paused&&r>s&&(n=_e({},i),i=Gx(n,Yx({currentTime:0,paused:!0})),this.resetPlayer())}var n;return i}}isShowingPoster(){const t=this.getAttributes();return!(t!=null&&t.src)||eS.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 $.createElement("div",{className:this.isEnabled()?"vjs-p":"vjs-p disabled",onMouseEnter:this.showController,onMouseMove:this.showController},$.createElement("div",{className:"video-js-plugin-player",ref:this.container}),this.isShowingPoster()&&$.createElement("div",{className:"video-js-plugin-poster"},n.poster&&$.createElement("img",{src:n.poster,alt:"",draggable:!1})),$.createElement(mS,{duration:r,volume:n.volume,setVolume:this.setVolume,paused:n.paused,play:this.play,pause:this.pause,currentTime:1e3*Fs(n,this.props),setCurrentTime:this.setCurrentTime,buffered:r*s,visible:!0}),this.state.NoSound&&$.createElement("div",{ref:this.setupAlert,className:"videojs-plugin-muted-alert"}),this.state.MediaError&&$.createElement("div",{className:"videojs-plugin-recovery-mode"},$.createElement("button",{ref:this.setupReload},"Reload Player")))}debug(t,...i){Kt.verbose&&Kt.log(`[MediaPlayer] ${t}`,...i)}componentDidMount(){this.debug("app version =","0.1.0-alpha.5"),this.debug("video.js version =",cu.default.VERSION),this.initPlayer(),this.props.context.emitter.on("attributesUpdate",this.syncPlayerWithAttributes),this.syncPlayerTimer=setInterval(this.syncPlayerWithAttributes,Kt.syncInterval),this.decreaseRetryTimer=setInterval(this.decreaseRetryCount,Kt.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 ou={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=_e(_e({},_f),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+WWvL1v6OgTZElEPAQIECBAIENAhCEA3ZT8Bzwj7WUaMJL8I9X5zZs8ve339kugzkg5BH0ejECBAgACB0gIOBKXjUzwBAgQIEOgj4EDQx9EoBAgQIECgtIADQen4FE+AAAECBPoIOBD0cTQKAQIECBAoLeC3DErHp/iWgE8Zt4RyX5df7nxa1Y3Ob/T4rfWtdl2HYLVErYcAAQIECFwQWL5DsPoJcvX1XdjTpd4iv1JxvStWfu9IfCORwLP7U4cgUXhKIUCAAAECUQIOBFHy5iVAgAABAokEHAgShaEUAgQIECAQJXD7MwTPPqOIWujVeUevb/T4V9ftfecE5HfOKetd8suajLoiBHQIItTNSYAAAQIEkgnc7hAkW0/3ckb/e9qjx+8OYsBvBOT3DUe5L+RXLjIFDxTQIRiIa2gCBAgQIFBFoNkh2P0Z2+j1jx4/+0asvv7q9d/dH9XXX73+3fO7u/7W+3fbHzoErR3hOgECBAgQ2ECg2SHwjG2DXRC4xOj9tdufAHpHLb/eonPHk9+xd7TPcXX9r+oQ9Dc1IgECBAgQKCfgQFAuMgUTIECAAIH+Ag4E/U2NSIAAAQIEygk0P0MQvaLsz3hb9bWu840WOJ5ffsc+2a/KL3tC6jsSmL1/dQiO0nCNAAECBAhsItDsEMw+oTzrHl1f61OorevPrvfZ+6N9WvVmr09+xwnKr7ZP9vyOdcdfze7Tuz4dgvF7ygwECBAgQCC9QLNDkH0F0X+C45NdoHZ99rf8aguofqRA7/8/6BCMTMvYBAgQIECgiED5DkHvZyhFcjtdJp/TVClvlF/KWE4XJb/TVG68INB7f+kQXAjBWwgQIECAwGoCDgSrJWo9BAgQIEDggoADwQU0byFAgAABAqsJfO39DGI1IOuJFbA/Y/3vzi6/u4Kx7189v7vru/v+2HTfz65D8N7EdwgQIECAwHYCw3/LYLUT1HY7pLFg+TaAkl+WX/KAGuXJrwEUfLlaPjoEwRvG9AQIECBAIIPA8A5B779JKQOaGl4F5PtqUfGV/Cqm9lqz/F4tMr6qlo8OQcZdpCYCBAgQIDBZYHiHoNozlMn+5aeTb+0I5Se/2gK5q6/286VDkHs/qY4AAQIECEwRcCCYwmwSAgQIECCQW8CBIHc+qiNAgAABAlMEhn+GYMoqTEKAAAEC7wSqPcN+twDfmCqgQzCV22QECBAgQCCnQHiHoPoJtlV/63rObfFaVfX6X1dy7VX19Vev/1pqr++qvv7q9b8m4dVHAtny1SH4KCXfI0CAAAECmwmEdwiq/U1Om+2PL/Kpnbj85FdbYO3qs/186hCsvd+sjgABAgQInBJwIDjF5CYCBAgQILC2gAPB2vlaHQECBAgQOCUQ/hmCbJ+yPKW20U3yqR22/ORXW2Dt6qN/Ph/n1yFYe79ZHQECBAgQOCXgQHCKyU0ECBAgQGBtAQeCtfO1OgIECBAgcErAgeAUk5sIECBAgMDaAg4Ea+drdQQIECBA4JTA1+///OGnoztd52N/fC7g58PPx+e748sX+8P+qLQ/dAiO0nKNAAECBAhsIuBAsEnQlkmAAAECBI4EHAiOdFwjQIAAAQKbCDgQbBK0ZRIgQIAAgSMBB4IjHdcIECBAgMAmAuH/lsHP//zvb5tYl1ymfErG9lK0/F4oSr6QX8nYThcdne/j/DoEp6NzIwECBAgQWFfAgWDdbK2MAAECBAicFnAgOE3lRgIECBAgsK5A+GcIfv39Pz++5X18pvH2mtfzBeQz37znjPLrqTl/LPnNN585Y7Z8dQhmpm8uAgQIECCQVCC8Q1C9I9Cqv3U96b54Kat6/S8Lufii+vqr138xtpe3VV9/9fpfgvDiQ4Fs+eoQfBiTbxIgQIAAgb0EwjsEe3FbLQECBOYJZPsT6LyVm+mKgA7BFTXvIUCAAAECiwk4ECwWqOUQIECAAIErAg4EV9S8hwABAgQILCYw/DMEnmEttmMeliPfB5BiX8qvWGAP5crvASTZl9Xy0SFItoGUQ4AAAQIEIgSGdwiy/U1MEcgrzynf2unKT361BXJXX+3nS4cg935SHQECBAgQmCIwvENQ7RnKFPWFJpFv7TDlJ7/aArmrr/bzpUOQez+pjgABAgQITBH4Wu0EM0XFJGkE7M80UVwqRH6X2NK8afX87q7v7vvTBP13IToE2RJRDwECBAgQCBBwIAhANyUBAgQIEMgm4ECQLRH1ECBAgACBAIHhv2Uwek2rPcPp7cWnt+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%}
46
- `);const n=document.createElement("div");n.classList.add("netless-app-media-player-container"),Vf.render($.createElement(vS,{context:e}),n),i.mountContent(n),e.emitter.on("destroy",()=>{console.log("[MediaPlayer]: destroy"),Vf.unmountComponentAtNode(n)})}},yS=()=>{Ie.debug&&Kx({verbose:!0}),Ie.register({kind:qo.kind,src:qo}),Ie.register({kind:ou.kind,src:ou})},xS={DocsViewer:qo.kind,MediaPlayer:ou.kind};var DS="",LS="",jS="";const Gf=new kv({emitter:L}),B=class extends E.InvisiblePlugin{constructor(e){super(e);this.version="1.0.0-canary.4",this.dependencies={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.12",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@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.22","@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",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",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}},this.emitter=ne,this.viewMode=E.ViewMode.Broadcaster,this.isReplay=E.isPlayer(this.displayer),this.containerSizeRatio=B.containerSizeRatio,B.displayer=e.displayer,window.NETLESS_DEPS={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.12",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@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.22","@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",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",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}}}static async mount(e){var o;const t=e.room;B.container=e.container;const i=e.containerSizeRatio,n=e.debug,r=e.cursor;B.params=e,B.displayer=e.room,Vg();let s;if(E.isRoom(t)){if(t.phase!==E.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");t.phase===E.RoomPhase.Connected&&t.isWritable&&(t.disableSerialization=!1),s=await this.initManager(t)}if(B.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");if(this.debug=Boolean(n),Ti("Already insert room",s),E.isRoom(this.displayer)){if(!s)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await sg.default(async a=>{if(s=await t.getInvisiblePlugin(B.kind),!s)throw Ti(`manager is empty. retrying ${a}`),new Error},{retries:10});if(!s)throw new Error("[WindowManager]: create manager failed");i&&(B.containerSizeRatio=i),await s.ensureAttributes(),s.appManager=new Gg(s),s._pageState=new Pv(s.appManager),s.cursorManager=new Nv(s.appManager,Boolean(r),e.applianceIcons),i&&(s.containerSizeRatio=i),s.boxManager=nv(s,ne,L,mt,{collectorContainer:e.collectorContainer,collectorStyles:e.collectorStyles,prefersColorScheme:e.prefersColorScheme,stageRatio:e.containerSizeRatio}),(o=s.appManager)==null||o.setBoxManager(s.boxManager),e.container&&s.bindContainer(e.container),zv(t,s),L.emit("onCreated"),B.isCreated=!0;try{await dg()}catch(a){console.warn("[WindowManager]: indexedDB open failed"),console.log(a)}return s}static async initManager(e){let t=e.getInvisiblePlugin(B.kind);if(!t&&E.isRoom(e))if(e.isWritable===!1){try{await e.setWritable(!0)}catch{throw new Error("[WindowManger]: room must be switched to be writable")}t=await e.createInvisiblePlugin(B,{}),t.ensureAttributes(),await Su(500),await e.setWritable(!1)}else t=await e.createInvisiblePlugin(B,{});return t}static initContainer(e,t){B.container||(B.container=e);const{playground:i,mainViewElement:n}=Rg(e);if(B.playground=i,t){const r=document.createElement("style");r.textContent=t,i.appendChild(r)}return n}static get registered(){return ze.registered}bindContainer(e){var t,i,n,r,s;if(E.isRoom(this.displayer)&&this.room.phase!==E.RoomPhase.Connected)throw new Tu;if(B.isCreated&&B.container)B.container.firstChild&&e.appendChild(B.container.firstChild);else if(B.params){const o=B.params,a=B.initContainer(e,o.overwriteStyles);this.boxManager&&B.playground&&this.boxManager.setRoot(B.playground),this.bindMainView(a,o.disableCameraTransform),B.playground&&((t=this.cursorManager)==null||t.setupWrapper(B.playground))}L.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),B.container=e}bindCollectorContainer(e){B.isCreated&&this.boxManager?this.boxManager.setCollector(e):B.params&&(B.params.collectorContainer=e)}static register(e){return ze.register(e)}static unregister(e){return ze.unregister(e)}async addApp(e){if(this.appManager)return this.appManager.rootDirRemoving?new Promise((t,i)=>{L.once("rootDirRemoved").then(async()=>{try{const n=await this._addApp(e);t(n)}catch(n){i(n.message)}})}):this._addApp(e);throw new Xe}async _addApp(e){var t,i,n;if(this.appManager){if(!e.kind||typeof e.kind!="string")throw new Iu;const r=await((t=ze.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 Cu;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=Tg(e.options.scenePath)),await this.appManager.addApp(e,Boolean(s)))}else throw new Xe}setupScenePath(e,t){let i=!1;if(e.options){const{scenePath:n,scenes:r}=e.options;if(n){if(!Ag(n))throw new Eu;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)}return}}}n&&r&&r.length>0&&(this.isDynamicPPT(r)?(i=!0,ii(this.displayer)[n]||ni(this.room,n,r)):ii(this.displayer)[n]||ni(this.room,n,[{name:r[0].name}])),n&&r===void 0&&ni(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 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(ke,[i||{}],n)}else this.room.putScenes(ke,[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),L.emit("setReadonly",e)}switchMainViewToWriter(){var e;return(e=this.appManager)==null?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){bg(`destroy-${e}`,t)}setViewMode(e){var t,i,n;e===E.ViewMode.Broadcaster&&(this.canOperate&&((t=this.appManager)==null||t.mainViewProxy.setCameraAndSize()),(i=this.appManager)==null||i.mainViewProxy.start()),e===E.ViewMode.Freedom&&((n=this.appManager)==null||n.mainViewProxy.stop()),this.viewMode=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)}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new Xe}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new Xe}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new Xe}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 Xe}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 Xe}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 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 Xe}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 Xe}get pageState(){if(this._pageState)return this._pageState.toObject();throw new Xe}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)}moveCamera(e){var n;const t=b.omit(e,["animationMode"]),i=Z({},this.mainView.camera);b.isEqual(Z(Z({},i),t),i)||(this.mainView.moveCamera(e),(n=this.appManager)==null||n.dispatchInternalEvent(G.MoveCamera,e),setTimeout(()=>{var r;(r=this.appManager)==null||r.mainViewProxy.setCameraAndSize()},500))}moveCameraToContain(e){var t;this.mainView.moveCameraToContain(e),(t=this.appManager)==null||t.dispatchInternalEvent(G.MoveCameraToContain,e),setTimeout(()=>{var i;(i=this.appManager)==null||i.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;(e=this.appManager)==null||e.destroy(),(t=this.cursorManager)==null||t.destroy(),B.container=void 0,B.isCreated=!1,B.playground&&((i=B.playground.parentNode)==null||i.removeChild(B.playground)),B.params=void 0,Ti("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,Boolean(t)),(i=this.cursorManager)==null||i.setMainViewDivElement(e))}get canOperate(){return E.isRoom(this.displayer)?this.displayer.isWritable&&this.displayer.phase===E.RoomPhase.Connected:!1}get room(){return this.displayer}safeSetAttributes(e){this.canOperate&&this.setAttributes(e)}safeUpdateAttributes(e,t){this.canOperate&&this.updateAttributes(e,t)}setPrefersColorScheme(e){var t,i;(i=(t=this.appManager)==null?void 0:t.boxManager)==null||i.setPrefersColorScheme(e)}cleanCurrentScene(){var e;(e=this.focusedView)==null||e.cleanCurrentScene()}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;(e=this.focusedView)==null||e.delete()}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(G.Refresh)}_refresh(){var e,t,i;(e=this.appManager)==null||e.mainViewProxy.rebind(),B.container&&this.bindContainer(B.container),(i=(t=this.appManager)==null?void 0:t.refresher)==null||i.refresh()}setContainerSizeRatio(e){if(!b.isNumber(e))throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${e}`);B.containerSizeRatio=e,this.containerSizeRatio=e,L.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(){b.isNull(this.attributes)&&await Su(50),b.isObject(this.attributes)&&(this.attributes[he.Apps]||this.safeSetAttributes({[he.Apps]:{}}),this.attributes[he.Cursors]||this.safeSetAttributes({[he.Cursors]:{}}),this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:fu}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:0}),this.attributes[he.Registered]||this.safeSetAttributes({[he.Registered]:{}}))}};let Ie=B;Ie.kind="WindowManager",Ie.debug=!1,Ie.containerSizeRatio=lg,Ie.isCreated=!1,yS(),_.AppCreateError=Cu,_.AppManagerNotInitError=Xe,_.AppNotRegisterError=kg,_.BindContainerRoomPhaseInvalidError=Tu,_.BoxManagerNotFoundError=Au,_.BoxNotCreatedError=bu,_.BuiltinApps=xS,_.InvalidScenePath=Eu,_.ParamsInvalidError=Iu,_.WhiteWebSDKInvalidError=Mu,_.WindowManager=Ie,_.calculateNextIndex=so,_.reconnectRefresher=Gf,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
46
+ `);const n=document.createElement("div");n.classList.add("netless-app-media-player-container"),Vf.render($.createElement(vS,{context:e}),n),i.mountContent(n),e.emitter.on("destroy",()=>{console.log("[MediaPlayer]: destroy"),Vf.unmountComponentAtNode(n)})}},yS=()=>{Ie.debug&&Kx({verbose:!0}),Ie.register({kind:qo.kind,src:qo}),Ie.register({kind:ou.kind,src:ou})},xS={DocsViewer:qo.kind,MediaPlayer:ou.kind};var DS="",LS="",jS="";const Gf=new kv({emitter:L}),B=class extends E.InvisiblePlugin{constructor(e){super(e);this.version="1.0.0-canary.5",this.dependencies={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.13",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@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.22","@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",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",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}},this.emitter=ne,this.viewMode=E.ViewMode.Broadcaster,this.isReplay=E.isPlayer(this.displayer),this.containerSizeRatio=B.containerSizeRatio,B.displayer=e.displayer,window.NETLESS_DEPS={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.13",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@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.22","@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",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",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}}}static async mount(e){var o;const t=e.room;B.container=e.container;const i=e.containerSizeRatio,n=e.debug,r=e.cursor;B.params=e,B.displayer=e.room,Vg();let s;if(E.isRoom(t)){if(t.phase!==E.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");t.phase===E.RoomPhase.Connected&&t.isWritable&&(t.disableSerialization=!1),s=await this.initManager(t)}if(B.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");if(this.debug=Boolean(n),Ti("Already insert room",s),E.isRoom(this.displayer)){if(!s)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await sg.default(async a=>{if(s=await t.getInvisiblePlugin(B.kind),!s)throw Ti(`manager is empty. retrying ${a}`),new Error},{retries:10});if(!s)throw new Error("[WindowManager]: create manager failed");i&&(B.containerSizeRatio=i),await s.ensureAttributes(),s.appManager=new Gg(s),s._pageState=new Pv(s.appManager),s.cursorManager=new Nv(s.appManager,Boolean(r),e.applianceIcons),i&&(s.containerSizeRatio=i),s.boxManager=nv(s,ne,L,mt,{collectorContainer:e.collectorContainer,collectorStyles:e.collectorStyles,prefersColorScheme:e.prefersColorScheme,stageRatio:e.containerSizeRatio}),(o=s.appManager)==null||o.setBoxManager(s.boxManager),e.container&&s.bindContainer(e.container),zv(t,s),L.emit("onCreated"),B.isCreated=!0;try{await dg()}catch(a){console.warn("[WindowManager]: indexedDB open failed"),console.log(a)}return s}static async initManager(e){let t=e.getInvisiblePlugin(B.kind);if(!t&&E.isRoom(e))if(e.isWritable===!1){try{await e.setWritable(!0)}catch{throw new Error("[WindowManger]: room must be switched to be writable")}t=await e.createInvisiblePlugin(B,{}),t.ensureAttributes(),await Su(500),await e.setWritable(!1)}else t=await e.createInvisiblePlugin(B,{});return t}static initContainer(e,t){B.container||(B.container=e);const{playground:i,mainViewElement:n}=Rg(e);if(B.playground=i,t){const r=document.createElement("style");r.textContent=t,i.appendChild(r)}return n}static get registered(){return ze.registered}bindContainer(e){var t,i,n,r,s;if(E.isRoom(this.displayer)&&this.room.phase!==E.RoomPhase.Connected)throw new Tu;if(B.isCreated&&B.container)B.container.firstChild&&e.appendChild(B.container.firstChild);else if(B.params){const o=B.params,a=B.initContainer(e,o.overwriteStyles);this.boxManager&&B.playground&&this.boxManager.setRoot(B.playground),this.bindMainView(a,o.disableCameraTransform),B.playground&&((t=this.cursorManager)==null||t.setupWrapper(B.playground))}L.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),B.container=e}bindCollectorContainer(e){B.isCreated&&this.boxManager?this.boxManager.setCollector(e):B.params&&(B.params.collectorContainer=e)}static register(e){return ze.register(e)}static unregister(e){return ze.unregister(e)}async addApp(e){if(this.appManager)return this.appManager.rootDirRemoving?new Promise((t,i)=>{L.once("rootDirRemoved").then(async()=>{try{const n=await this._addApp(e);t(n)}catch(n){i(n.message)}})}):this._addApp(e);throw new Xe}async _addApp(e){var t,i,n;if(this.appManager){if(!e.kind||typeof e.kind!="string")throw new Iu;const r=await((t=ze.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 Cu;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=Tg(e.options.scenePath)),await this.appManager.addApp(e,Boolean(s)))}else throw new Xe}setupScenePath(e,t){let i=!1;if(e.options){const{scenePath:n,scenes:r}=e.options;if(n){if(!Ag(n))throw new Eu;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)}return}}}n&&r&&r.length>0&&(this.isDynamicPPT(r)?(i=!0,ii(this.displayer)[n]||ni(this.room,n,r)):ii(this.displayer)[n]||ni(this.room,n,[{name:r[0].name}])),n&&r===void 0&&ni(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 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(ke,[i||{}],n)}else this.room.putScenes(ke,[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),L.emit("setReadonly",e)}switchMainViewToWriter(){var e;return(e=this.appManager)==null?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){bg(`destroy-${e}`,t)}setViewMode(e){var t,i,n;e===E.ViewMode.Broadcaster&&(this.canOperate&&((t=this.appManager)==null||t.mainViewProxy.setCameraAndSize()),(i=this.appManager)==null||i.mainViewProxy.start()),e===E.ViewMode.Freedom&&((n=this.appManager)==null||n.mainViewProxy.stop()),this.viewMode=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)}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new Xe}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new Xe}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new Xe}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 Xe}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 Xe}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 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 Xe}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 Xe}get pageState(){if(this._pageState)return this._pageState.toObject();throw new Xe}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)}moveCamera(e){var n;const t=b.omit(e,["animationMode"]),i=Z({},this.mainView.camera);b.isEqual(Z(Z({},i),t),i)||(this.mainView.moveCamera(e),(n=this.appManager)==null||n.dispatchInternalEvent(G.MoveCamera,e),setTimeout(()=>{var r;(r=this.appManager)==null||r.mainViewProxy.setCameraAndSize()},500))}moveCameraToContain(e){var t;this.mainView.moveCameraToContain(e),(t=this.appManager)==null||t.dispatchInternalEvent(G.MoveCameraToContain,e),setTimeout(()=>{var i;(i=this.appManager)==null||i.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;(e=this.appManager)==null||e.destroy(),(t=this.cursorManager)==null||t.destroy(),B.container=void 0,B.isCreated=!1,B.playground&&((i=B.playground.parentNode)==null||i.removeChild(B.playground)),B.params=void 0,Ti("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,Boolean(t)),(i=this.cursorManager)==null||i.setMainViewDivElement(e))}get canOperate(){return E.isRoom(this.displayer)?this.displayer.isWritable&&this.displayer.phase===E.RoomPhase.Connected:!1}get room(){return this.displayer}safeSetAttributes(e){this.canOperate&&this.setAttributes(e)}safeUpdateAttributes(e,t){this.canOperate&&this.updateAttributes(e,t)}setPrefersColorScheme(e){var t,i;(i=(t=this.appManager)==null?void 0:t.boxManager)==null||i.setPrefersColorScheme(e)}cleanCurrentScene(){var e;(e=this.focusedView)==null||e.cleanCurrentScene()}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;(e=this.focusedView)==null||e.delete()}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(G.Refresh)}_refresh(){var e,t,i;(e=this.appManager)==null||e.mainViewProxy.rebind(),B.container&&this.bindContainer(B.container),(i=(t=this.appManager)==null?void 0:t.refresher)==null||i.refresh()}setContainerSizeRatio(e){if(!b.isNumber(e))throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${e}`);B.containerSizeRatio=e,this.containerSizeRatio=e,L.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(){b.isNull(this.attributes)&&await Su(50),b.isObject(this.attributes)&&(this.attributes[he.Apps]||this.safeSetAttributes({[he.Apps]:{}}),this.attributes[he.Cursors]||this.safeSetAttributes({[he.Cursors]:{}}),this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:fu}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:0}),this.attributes[he.Registered]||this.safeSetAttributes({[he.Registered]:{}}))}};let Ie=B;Ie.kind="WindowManager",Ie.debug=!1,Ie.containerSizeRatio=lg,Ie.isCreated=!1,yS(),_.AppCreateError=Cu,_.AppManagerNotInitError=Xe,_.AppNotRegisterError=kg,_.BindContainerRoomPhaseInvalidError=Tu,_.BoxManagerNotFoundError=Au,_.BoxNotCreatedError=bu,_.BuiltinApps=xS,_.InvalidScenePath=Eu,_.ParamsInvalidError=Iu,_.WhiteWebSDKInvalidError=Mu,_.WindowManager=Ie,_.calculateNextIndex=so,_.reconnectRefresher=Gf,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});