@spearwolf/shadow-objects 0.32.0 → 0.33.0
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/CHANGELOG.md +64 -0
- package/README.md +49 -13
- package/bundle.js +7 -7
- package/package.json +2 -2
- package/src/elements/ShaeEntElement.d.ts +4 -4
- package/src/elements/ShaeEntElement.d.ts.map +1 -1
- package/src/elements/ShaeEntElement.js +4 -5
- package/src/elements/ShaeEntElement.js.map +2 -2
- package/src/elements/ShaePropElement.d.ts +5 -5
- package/src/elements/ShaePropElement.d.ts.map +1 -1
- package/src/elements/ShaePropElement.js +2 -2
- package/src/elements/ShaePropElement.js.map +2 -2
- package/src/elements/ShaeWorkerElement.d.ts.map +1 -1
- package/src/elements/ShaeWorkerElement.js +31 -6
- package/src/elements/ShaeWorkerElement.js.map +2 -2
- package/src/in-the-dark/Kernel.d.ts +5 -0
- package/src/in-the-dark/Kernel.d.ts.map +1 -1
- package/src/in-the-dark/Kernel.js +49 -24
- package/src/in-the-dark/Kernel.js.map +2 -2
- package/src/in-the-dark/Registry.d.ts +1 -1
- package/src/in-the-dark/Registry.d.ts.map +1 -1
- package/src/in-the-dark/Registry.js +24 -20
- package/src/in-the-dark/Registry.js.map +2 -2
- package/src/in-the-dark/ShadowObject.d.ts +1 -1
- package/src/in-the-dark/ShadowObject.d.ts.map +1 -1
- package/src/in-the-dark/ShadowObject.js +2 -2
- package/src/in-the-dark/ShadowObject.js.map +2 -2
- package/src/in-the-dark/SignalsPath.d.ts.map +1 -1
- package/src/in-the-dark/SignalsPath.js.map +2 -2
- package/src/in-the-dark/importModule.js +3 -3
- package/src/in-the-dark/importModule.js.map +2 -2
- package/src/types.d.ts +4 -4
- package/src/types.d.ts.map +1 -1
- package/src/utils/ConsoleLogger.d.ts.map +1 -1
- package/src/utils/ConsoleLogger.js +3 -2
- package/src/utils/ConsoleLogger.js.map +2 -2
- package/src/utils/FrameLoop.d.ts +1 -1
- package/src/utils/FrameLoop.d.ts.map +1 -1
- package/src/utils/FrameLoop.js +0 -2
- package/src/utils/FrameLoop.js.map +2 -2
- package/src/utils/attr-utils.d.ts.map +1 -1
- package/src/utils/attr-utils.js +1 -1
- package/src/utils/attr-utils.js.map +2 -2
- package/src/utils/generateUUID.d.ts +1 -1
- package/src/utils/generateUUID.d.ts.map +1 -1
- package/src/utils/props-utils.d.ts +1 -1
- package/src/utils/props-utils.d.ts.map +1 -1
- package/src/utils/waitForMessageOfType.d.ts +5 -1
- package/src/utils/waitForMessageOfType.d.ts.map +1 -1
- package/src/utils/waitForMessageOfType.js +12 -2
- package/src/utils/waitForMessageOfType.js.map +2 -2
- package/src/view/ComponentChanges.d.ts +4 -1
- package/src/view/ComponentChanges.d.ts.map +1 -1
- package/src/view/ComponentChanges.js +20 -6
- package/src/view/ComponentChanges.js.map +2 -2
- package/src/view/ComponentContext.d.ts +43 -1
- package/src/view/ComponentContext.d.ts.map +1 -1
- package/src/view/ComponentContext.js +123 -47
- package/src/view/ComponentContext.js.map +2 -2
- package/src/view/ComponentMemory.js +3 -1
- package/src/view/ComponentMemory.js.map +2 -2
- package/src/view/IShadowObjectEnvProxy.d.ts +6 -0
- package/src/view/IShadowObjectEnvProxy.d.ts.map +1 -1
- package/src/view/LocalShadowObjectEnv.d.ts +1 -1
- package/src/view/LocalShadowObjectEnv.d.ts.map +1 -1
- package/src/view/LocalShadowObjectEnv.js +11 -6
- package/src/view/LocalShadowObjectEnv.js.map +2 -2
- package/src/view/RemoteWorkerEnv.d.ts +42 -0
- package/src/view/RemoteWorkerEnv.d.ts.map +1 -1
- package/src/view/RemoteWorkerEnv.js +130 -18
- package/src/view/RemoteWorkerEnv.js.map +2 -2
- package/src/view/ShadowEnv.d.ts +25 -1
- package/src/view/ShadowEnv.d.ts.map +1 -1
- package/src/view/ShadowEnv.js +103 -29
- package/src/view/ShadowEnv.js.map +2 -2
- package/src/view/ViewComponent.d.ts +22 -1
- package/src/view/ViewComponent.d.ts.map +1 -1
- package/src/view/ViewComponent.js +66 -22
- package/src/view/ViewComponent.js.map +2 -2
- package/src/worker/MessageRouter.d.ts.map +1 -1
- package/src/worker/MessageRouter.js +7 -5
- package/src/worker/MessageRouter.js.map +2 -2
package/bundle.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
@file @spearwolf/shadow-objects - a reactive entity-component framework that feels at home in the shadows
|
|
3
3
|
@author Wolfger Schramm <wolfger@spearwolf.de>
|
|
4
|
-
@version 0.
|
|
4
|
+
@version 0.33.0+bundle.20260815
|
|
5
5
|
|
|
6
6
|
Copyright 2026 Wolfger Schramm
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ See the License for the specific language governing permissions and
|
|
|
18
18
|
limitations under the License.
|
|
19
19
|
|
|
20
20
|
*/
|
|
21
|
-
var ht="shaeRequestEntParent",lt="shaeReRequestEntParent",Ns="shae-worker",ct="shae-ent",_s="shae-prop",oe="token",q="forward-custom-events";var ut="local",$s="no-autostart",dt="no-structured-clone",V="auto-sync";var ft="name",pt="value",gt="type",yt="no-trim";var ve="*",Bs=1,Yt=2,Jt=4,H=Symbol.for("eventize"),Ki="[eventize]",Xt=s=>s===ve,Vs=s=>{switch(typeof s){case"string":case"symbol":return!0;default:return!1}},Us=typeof console<"u",Yi=Us?console[console.warn?"warn":"log"].bind(console,Ki):()=>{},Ji=(s,e,t)=>(Object.defineProperty(s,e,{value:t,configurable:!0}),s),Xi=0,Zt=class{static publish(s){s.sort((e,t)=>e.order-t.order).forEach(e=>e.replay())}events=new Map;eventNames=new Set;add(s){Array.isArray(s)?s.forEach(e=>this.eventNames.add(e)):this.eventNames.add(s)}remove(s){Array.isArray(s)?s.forEach(e=>this.eventNames.delete(e)):this.eventNames.delete(s),this.clear(s)}clear(s){Array.isArray(s)?s.forEach(e=>this.events.delete(e)):this.events.delete(s)}retain(s,e){this.eventNames.has(s)&&this.events.set(s,{args:e,order:Xi++})}isKnown(s){return this.eventNames.has(s)}replayTo(s,e,t=[]){if(Xt(s))this.eventNames.forEach(i=>this.replayTo(i,e,t));else if(this.events.has(s)){let{order:i,args:r}=this.events.get(s);t.push({order:i,replay:()=>e.apply(s,r)})}return t}},Qt=(s,e,t,i)=>{if(typeof e=="function"){let r=e.apply(s,t);r!=null&&i?.(r)}},Zi=(s,e,t,i)=>Qt(e,e.emit,[s].concat(t),i),er=s=>{switch(typeof s){case"function":return Bs;case"string":case"symbol":return Yt;case"object":return Jt}},tr=0,sr=()=>++tr,Gs=class{id;eventName;isCatchEmAll;priority;listener;listenerObject;listenerType;callAfterApply;isRemoved;refCount;constructor(s,e,t,i=null){this.id=sr(),this.eventName=s,this.isCatchEmAll=Xt(s),this.listener=t,this.listenerObject=i,this.priority=e,this.listenerType=er(t),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(s,e=null){if(s===this)return!0;let t=typeof s;return t==="number"&&s===this.id?!0:e===null&&(t==="string"||t==="symbol")?s===ve||s===this.eventName:this.listener===s&&this.listenerObject===e}apply(s,e,t){if(this.isRemoved)return;let{listener:i,listenerObject:r}=this;switch(this.listenerType){case Bs:Qt(r,i,e,t),this.callAfterApply&&this.callAfterApply();break;case Yt:Qt(r,r[i],e,t),this.callAfterApply&&this.callAfterApply();break;case Jt:{let n=i[s];if(this.isCatchEmAll||this.eventName===s){if(typeof n=="function"){let o=n.apply(i,e);o!=null&&t?.(o)}else Zi(s,i,e,t);this.callAfterApply&&this.callAfterApply()}break}}}},ir=(s,e)=>s.priority!==e.priority?e.priority-s.priority:s.id-e.id,rr=(s,e)=>{let t=0,i=s.length;for(;t<i;){let r=t+i>>>1;ir(e,s[r])<0?i=r:t=r+1}return t},Ws=s=>s?.slice(0),js=(s,e)=>{let t=s.indexOf(e);t>-1&&s.splice(t,1)},nr=s=>s===Jt||s===Yt,Kt=(s,e,t)=>{let i=s.findIndex(r=>r.isEqual(e,t));i>-1&&(s[i].isRemoved=!0,s.splice(i,1))},qt=(s,e,t)=>{let i=[];for(let r of s)(e==null&&r.listenerObject===t||r.eventName===e&&r.listener===t)&&i.push(r);for(let r of i)Kt(s,r,void 0)},Ht=s=>{s&&(s.forEach(e=>{e.isRemoved=!0}),s.length=0)},or=(s,e)=>s.listenerType===e.listenerType?s.priority===e.priority&&s.eventName===e.eventName&&s.listenerObject===e.listenerObject&&s.listener===e.listener:!1,ar=(s,e)=>{if(nr(s.listenerType))return e.find(t=>or(s,t))},hr=(s,e)=>{let t=ar(s,e);return t?(t.refCount+=1,t):(e.splice(rr(e,s),0,s),s)},lr=class{namedListeners;catchEmAllListeners;getListenersForEventName=s=>{let e=this.namedListeners.get(s);return e||(e=[],this.namedListeners.set(s,e)),e};constructor(){this.namedListeners=new Map,this.catchEmAllListeners=[]}add(s){return hr(s,s.isCatchEmAll?this.catchEmAllListeners:this.getListenersForEventName(s.eventName))}remove(s,e,t=!1){if(e==null&&Array.isArray(s)){s.forEach(i=>this.remove(i,null,t));return}if(s==null||e==null&&Xt(s)){this.removeAllListeners();return}if(e==null&&Vs(s)){this.removeByEventName(s);return}if(s instanceof Gs){this.removeByEventListener(s);return}if(t){this.removeByEventNameAndListenerObject(s,e);return}this.removeByListener(s,e)}removeByEventName(s){Ht(this.namedListeners.get(s)),this.namedListeners.delete(s)}removeByEventListener(s){s.isRemoved||(s.refCount-=1,!(s.refCount>=1)&&(s.isRemoved=!0,this.namedListeners.forEach((e,t)=>{js(e,s),e.length===0&&this.namedListeners.delete(t)}),js(this.catchEmAllListeners,s)))}removeByEventNameAndListenerObject(s,e){this.namedListeners.forEach((t,i)=>{qt(t,s,e),t.length===0&&this.namedListeners.delete(i)})}removeByListener(s,e){let t=typeof s=="object";this.namedListeners.forEach((i,r)=>{Kt(i,s,e),t&&qt(i,void 0,s),i.length===0&&this.namedListeners.delete(r)}),Kt(this.catchEmAllListeners,s,e),t&&qt(this.catchEmAllListeners,void 0,s)}removeAllListeners(){this.namedListeners.forEach(s=>Ht(s)),this.namedListeners.clear(),Ht(this.catchEmAllListeners)}forEach(s,e){let t=Ws(this.catchEmAllListeners),i=Ws(this.namedListeners.get(s));if(s===ve||!i||i.length===0)t.forEach(e);else if(t.length===0)i.forEach(e);else{let r=i.length,n=t.length,o=0,a=0;for(;o<r||a<n;){if(o<r){let f=i[o];if(a>=n||f.priority>=t[a].priority){e(f),++o;continue}}a<n&&(e(t[a]),++a)}}}getSubscriptionCount(){let s=this.catchEmAllListeners.length;for(let e of this.namedListeners.values())s+=e.length;return s}},ae=s=>!!(s&&s[H]);function We(s){if(ae(s))return s;let e=new lr,t=new Zt;return Ji(s,H,{keeper:t,store:e}),s}var Q={Max:Number.POSITIVE_INFINITY,Critical:1e9,High:1e6,Normal:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0},cr=(s,e,t,i,r,n,o)=>{let a=s.add(new Gs(t,i,r,n));return e.replayTo(t,a,o),a},qs=(s,e,t,i)=>{let r=t.length,n=typeof t[0],o,a,f,m;if(r>=2&&r<=3&&n==="number"?(o=ve,[a,f,m]=t):r>=3&&r<=4&&typeof t[1]=="number"?[o,a,f,m]=t:(a=Q.Default,n==="string"||n==="symbol"||Array.isArray(t[0])?[o,f,m]=t:(o=ve,[f,m]=t)),!f)throw Us&&Yi("called with insufficient arguments!",t),new Error("subscribeTo() called with insufficient arguments");let P=c=>j=>cr(s,e,j,c,f,m,i);return Array.isArray(o)?o.map(c=>Array.isArray(c)?P(c[1])(c[0]):P(a)(c)):P(a)(o)},ur=(s,e,t)=>{let i=[],r=qs(s,e,t,i);return Zt.publish(i),r},dr=(s,e,t)=>{let i=[];return{listeners:qs(s,e,t,i),publishRetained:()=>Zt.publish(i)}},Fs=s=>e=>{e.callAfterApply=()=>{s?.()}},Hs=(s,e)=>Object.assign(()=>A(s,e),Array.isArray(e)?{listeners:e}:{listener:e}),Is=(s,e,t,i)=>{if(e===ve)throw new Error("emit() must be called with a concrete event name \u2014 '*' is reserved for subscribing to all events and cannot be emitted");let{store:r,keeper:n}=s[H];r.forEach(e,o=>o.apply(e,t,i)),n.retain(e,t)},Qs=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>Is(s,r,t,i)):Is(s,e,t,i)},zs=(s,e,t,i)=>{if(e===ve)throw new Error("emit() must be called with a concrete event name \u2014 '*' is reserved for subscribing to all events and cannot be emitted");let r=s,n=r[e];if(typeof n=="function"){let a=n.apply(s,t);a!=null&&i?.(a);return}let o=r.emit;if(typeof o=="function"){let a=o.apply(s,[e,...t]);a!=null&&i?.(a)}},Ks=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>zs(s,r,t,i)):zs(s,e,t,i)},Ys=s=>s!=null&&typeof s=="object";function w(s,...e){let t=We(s),{store:i,keeper:r}=t[H];return Hs(t,ur(i,r,e))}function k(s,...e){let t=We(s),{store:i,keeper:r}=t[H],{listeners:n,publishRetained:o}=dr(i,r,e),a=Hs(t,n),f=!1,m=()=>{f||(a(),f=!0)};return Array.isArray(n)?n.forEach(Fs(m)):Fs(m)(n),o(),m}function Ae(s,e){return new Promise(t=>{k(s,e,t)})}function A(s,e,t){if(!ae(s))return;let{store:i,keeper:r}=s[H],n=typeof e,o=t!=null&&(n==="string"||n==="symbol");i.remove(e,t,o),Array.isArray(e)?r.remove(e.filter(a=>typeof a=="string")):Vs(e)&&r.remove(e)}function y(s,e,...t){ae(s)?Qs(s,e,t):Ys(s)&&Ks(s,e,t)}function fr(s,e,...t){let i=[],r=n=>{i.push(n)};return ae(s)?Qs(s,e,t,r):Ys(s)&&Ks(s,e,t,r),i=i.map(n=>Array.isArray(n)?Promise.all(n):Promise.resolve(n)),i.length>0?Promise.all(i):Promise.resolve()}function ee(s,e){let t=We(s),{keeper:i}=t[H];i.add(e)}function he(s,e){if(!ae(s))throw new Error("object is not eventized");let{keeper:t}=s[H];t.clear(e)}function pr(s,e){if(!ae(s))throw new Error("object is not eventized");let{keeper:t}=s[H];t.remove(e)}var gr=w,yr=k,vr=A,mr=y,br=fr,wr=Ae,Cr=ee,Er=he,Sr=pr,O=(()=>{let s=(e={})=>We(e);return s.inject=(e={})=>(e=We(e),Object.assign(e,{on:(...t)=>gr(e,...t),once:(...t)=>yr(e,...t),onceAsync:t=>wr(e,t),off:(t,i)=>vr(e,t,i),emit:(t,...i)=>mr(e,t,...i),emitAsync:(t,...i)=>br(e,t,...i),retain:t=>Cr(e,t),retainClear:t=>Er(e,t),unretain:t=>Sr(e,t)}),e),s.is=ae,s})();var es=s=>ae(s)?s[H]?.store?.getSubscriptionCount()??0:0;var K=Symbol.for("signal"),Pe=Symbol.for("effect"),Js=Symbol.for("destroySignal"),Xs=Symbol.for("createEffect"),kr=Symbol.for("destroyEffect"),Oe="value",ns="mute",os="unmute",le="destroy",je=Symbol.for("recall"),Fe=O(),we=O(),me=O(),ti=O(),be=class{static current;delayedEffects=[];batch(e,t){let i=this.delayedEffects.length;for(let r=0;r<i;r++){let[n,o]=this.delayedEffects[r];if(!(n>t)){if(n===t){o.add(e);return}this.delayedEffects.splice(r,0,[t,new Set([e])]);return}}this.delayedEffects.push([t,new Set([e])])}flush(){this.run(),this.delayedEffects.length=0}run(){let e=new Set,t=[];try{t.push(w(me,(i,r)=>{r===je&&e.add(i)}),w(ti,i=>{e.add(i)}));for(let[,i]of this.delayedEffects)for(let r of i)e.has(r)||y(me,r,r,je)}finally{for(let i of t)i()}}},si=()=>be.current;function N(s){let e=be.current;e?e=void 0:e=be.current=new be;try{s()}finally{e&&(be.current=void 0,e.run())}}var ts=0;function Et(s){ts++;try{s()}finally{ts--}}function as(){return ts>0}var mt=class{[Pe];constructor(e){this[Pe]=e,k(e,le,()=>{this[Pe]=void 0})}run=()=>this[Pe]?.run();destroy=()=>{this[Pe]?.destroy(),this[Pe]=void 0}},ss=[],ii=()=>ss.at(-1),Ar=(s,e)=>{ss.push(s);try{return e()}finally{ss.pop()}};var Te=new WeakMap,vt=new Set,te=class s{#e=new Set;#t=new Set;#s=new Map;#r=new WeakMap;#i=new Map;#n=new Set;#o=new Set;#a;#l;static get(e){if(e!=null)return e instanceof s?e:Te.get(e)}static findOrCreate(e){if(e==null)throw new Error("Cannot create a group with a null object");return new s(e)}static destroy(e){console.warn("SignalGroup.destroy(obj) is deprecated. Use SignalGroup.delete(obj) instead."),s.delete(e)}static delete(e){Te.get(e)?.clear()}static clear(){for(let e of[...vt])e.clear();vt.clear()}constructor(e){if(e!=null&&e instanceof s)return e;if(e??=this,Te.has(e))return Te.get(e);this.#l=new WeakRef(e),Te.set(e,this),vt.add(this),O(this)}attachGroup(e){if(e===this)throw new Error("Cannot attach a group to itself");return this.#e.add(e),e.#a&&e.#a!==this&&e.#a.#e.delete(e),e.#a=this,e}detachGroup(e){return e!==this&&this.#e.has(e)&&(this.#e.delete(e),e.#a=void 0),e}attachSignal(e){let t=R(e);if(t?.destroyed)throw new Error("Cannot attach a destroyed signal to a group");return t&&this.#t.add(t),e}attachSignalByName(e,t){if(t){this.attachSignal(t);let i=R(t);this.#s.set(e,i),this.#i.has(e)?this.#i.get(e).push(i):this.#i.set(e,[i]),this.#r.has(i)?this.#r.get(i).add(e):this.#r.set(i,new Set([e]))}else this.#s.delete(e);return t}hasSignal(e){return this.#s.has(e)||!!this.#a?.hasSignal(e)}signal(e){return this.#s.get(e)?.object??this.#a?.signal(e)}detachSignal(e){let t=R(e);if(t&&(this.#t.delete(t),this.#r.has(t))){let i=this.#r.get(t);for(let r of i)if(this.#i.has(r)){let n=this.#i.get(r);n.splice(n.indexOf(t),1),n.length===0?(this.#s.delete(r),this.#i.delete(r)):this.#s.get(r)===t&&this.#s.set(r,n.at(-1))}i.clear(),this.#r.delete(t)}return e}attachEffect(e){return this.#n.add(e),e}runEffects(){for(let e of this.#n)e.run();for(let e of this.#e)e.runEffects()}attachLink(e){if(e?.isDestroyed)throw new Error("Cannot attach a destroyed link to a group");return e&&this.#o.add(e),e}detachLink(e){return e&&this.#o.delete(e),e}destroy(){console.warn("SignalGroup#destroy is deprecated. Use SignalGroup#clear instead."),this.clear()}clear(){y(this,le,this),A(this);for(let e of this.#e)e.clear();for(let e of this.#n)e.destroy();for(let e of this.#t)L(e);for(let e of this.#o)e.destroy();if(this.#e.clear(),this.#t.clear(),this.#s.clear(),this.#i.clear(),this.#n.clear(),this.#o.clear(),this.#a?.detachGroup(this),this.#l){let e=this.#l.deref();e!==void 0&&Te.delete(e),this.#l=void 0}vt.delete(this)}},bt=class{#e;#t;constructor(e="id",t=1){this.#e=e,this.#t=t}make(){return Symbol(`${this.#e}${this.#t++}`)}},Pr=s=>s!=null&&typeof s.then=="function",is=class s{static idGen=new bt("ef");static count=0;static maxDepth=256;id;callback;#e;#t=new Set;#s=new Set;#r=new Map;#i=new Set;childEffects=[];curChildEffectSlot=0;autorun=!0;shouldRun=!0;priority;#n;#o=!1;#a=0;constructor(e,t){O(this),this.callback=e;let i;t?.attach!=null&&(i=te.findOrCreate(t.attach),i.attachEffect(this)),this.autorun=t?.autorun??!0,this.#n=t?.dependencies?t.dependencies.map(r=>{switch(typeof r){case"string":case"symbol":return i.signal(r);default:return r}}):void 0,this.id=s.idGen.make(),this.priority=t?.priority??0,w(me,this.id,je,this),++s.count}hasStaticDeps(){return this.#n!=null&&this.#n.length>0}saveSignalsFromDeps(){for(let e of this.#n)this.whenSignalIsRead(R(e).id)}static createEffect(e,t,i){let r=Array.isArray(t)?t:void 0,n=r?i??{dependencies:r}:t;n&&r&&(n.dependencies=r);let o,a=ii();return a!=null?(o=a.getCurrentChildEffect(),o==null&&(o=new s(e,n),a.attachChildEffect(o),y(me,Xs,o)),a.curChildEffectSlot++):(o=new s(e,n),y(me,Xs,o)),o.hasStaticDeps()?o.saveSignalsFromDeps():o.autorun&&o.run(),new mt(o)}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(e){this.childEffects.push(e)}run=()=>{if(this.#o||!this.shouldRun)return;let e=si();if(e){e.batch(this.id,this.priority);return}if(this.#a>=s.maxDepth)throw new Error(`[signalize] Effect ${this.id.toString()} exceeded maxDepth=${s.maxDepth}: an effect callback recursively re-triggered itself (likely by writing a signal it depends on). Break the cycle, or raise EffectImpl.maxDepth if the recursion is intentional.`);this.#a++;try{if(this.runCleanupCallback(),this.destroyChildEffects(),this.curChildEffectSlot=0,this.shouldRun=!1,y(ti,this.id,this.id),this.hasStaticDeps())this.#e=this.callback();else{this.#s.clear();for(let t of this.#t)this.#s.add(t);this.#e=Ar(this,this.callback),this.cleanupLostSignals(),this.#i.clear()}}finally{this.#a--}};[je](){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(e){this.#s.delete(e),this.#t.has(e)||(this.#t.add(e),this.#r.set(e,[w(Fe,e,this.priority,je,this),k(we,e,Js,this)]))}[Js](e){!this.#i.has(e)&&this.#t.has(e)&&(this.#i.add(e),this.unsubscribeSignal(e),this.#i.size===this.#t.size&&this.destroy())}cleanupLostSignals(){for(let e of this.#s)this.unsubscribeSignal(e),this.#t.delete(e)}destroyChildEffects(){for(let e of this.childEffects)e.destroy();this.childEffects.length=0}unsubscribeSignal(e){this.#r.has(e)&&(this.#r.get(e).forEach(t=>{t()}),this.#r.delete(e))}runCleanupCallback(){if(this.#e!=null){let e=this.#e;this.#e=void 0,Pr(e)?Promise.resolve(e).then(t=>{typeof t=="function"&&t()}):e()}}destroy=()=>{this.#o||(y(this,le,this),A(this),y(me,kr,this),this.runCleanupCallback(),this.destroyChildEffects(),A(Fe,this),A(me,this),A(we,this),this.#o=!0,this.#t.clear(),this.#s.clear(),this.#r.clear(),this.#i.clear(),--s.count)}},S=(...s)=>is.createEffect(...s);var Ie=new WeakMap,Tr=s=>{let e=Ie.get(s);return e||(e={},Ie.set(s,e)),e},U=(s,e)=>Ie.get(s)?.signals?.get(e);var ri=(s,e,t)=>{let i=Tr(s);i.signals??=new Map,i.signals.set(e,t)};function ze(...s){for(let e of s)if(Ie.has(e)){let t=Ie.get(e);if(t.signals){for(let i of t.signals.values())L(i);t.signals.clear(),t.signals=void 0}}}function ni(s){let e=R(Ce(s)?s:U(...s));e!=null&&!e.muted&&!e.destroyed&&rs(e.id,e.value,{touch:!0})}function xe(s){return Ce(s)?R(s)?.value:R(U(...s))?.value}var wt=class{[K];constructor(e){this[K]=e}get get(){return this[K].reader}get set(){return this[K].writer}get value(){return xe(this.get)}set value(e){this.set(e)}onChange(e){let{destroy:t}=S(()=>e(this.value),[this.get]);return t}get muted(){return this[K].muted}set muted(e){this[K].muted=e}touch(){ni(this)}destroy(){L(this)}},Or=new bt("si"),Zs=!1;function xr(){Zs||(Zs=!0,console.warn("signalReader(callback) is deprecated and will be removed in a future release. Use Signal.onChange(callback) instead \u2014 it returns an unsubscribe function for proper cleanup."))}function ei(s){as()||ii()?.whenSignalIsRead(s)}function rs(s,e,t){as()||y(Fe,s,e,t)}var Ce=s=>s!=null&&s[K]!=null,Mr=s=>{let e=t=>(s.destroyed||s.beforeRead?.(),t?(xr(),S(()=>(s.destroyed||ei(s.id),t(s.value)),[e])):s.destroyed||ei(s.id),s.value);return Object.defineProperty(e,K,{value:s}),e},Ct=class s{static instanceCount=0;id;lazy;get[K](){return this}compare;beforeRead;muted=!1;destroyed=!1;#e=void 0;get value(){return this.lazy&&(this.#e=this.valueFn(),this.valueFn=void 0,this.lazy=!1),this.#e}set value(e){this.#e=e}valueFn;reader;writer=(e,t)=>{let i=t?.lazy??!1,n=t?.compare??this.compare??((a,f)=>a===f);if((i!==this.lazy||i&&e!==this.valueFn||!i&&!n(e,this.#e))&&(i?(this.#e=void 0,this.valueFn=e,this.lazy=!0):(this.#e=e,this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){rs(this.id,this.#e);return}(t?.touch??!1)&&!this.muted&&!this.destroyed&&rs(this.id,this.#e,{touch:!0})};object;constructor(e,t){this.id=Or.make(),++s.instanceCount,this.lazy=e,this.lazy?(this.value=void 0,this.valueFn=t):(this.value=t,this.valueFn=void 0),this.reader=Mr(this),this.object=new wt(this)}},R=s=>s?.[K];function p(s=void 0,e){let t;if(Ce(s))t=R(s);else{let i=e?.lazy??!1;t=new Ct(i,s),t.beforeRead=e?.beforeRead,t.compare=e?.compare}return e?.attach!=null&&te.findOrCreate(e.attach).attachSignal(t),t.object}var L=(...s)=>{for(let e of s){let t=R(e);t!=null&&!t.destroyed&&(t.destroyed=!0,t.beforeRead=void 0,--Ct.instanceCount,y(we,t.id,t.id))}};function St(s,e){let t=p(),i=e?.attach!=null?te.findOrCreate(e.attach):void 0;i!=null&&(e?.name?i.attachSignalByName(e.name,t):i.attachSignal(t));let r=S(()=>{N(()=>{t.set(s())})},{autorun:!(e?.lazy??!1),priority:e?.priority??Q.C,attach:i}),n=R(t);return n.beforeRead=r.run,k(we,n.id,r.destroy),t.get}var At=class{#e=!1;#t;source;lastValue;isDestroyed=!1;constructor(e){O(this),this.source=R(e),this.#t=w(Fe,this.source.id,(t,i)=>{!this.#e&&!this.isDestroyed&&(i?.touch===!0?this.touch():this.write())}),k(we,this.source.id,()=>this.destroy())}attach(e){let t=te.findOrCreate(e);return t.attachLink(this),k(this,le,()=>{t.detachLink(this)}),t}nextValue(){return new Promise((e,t)=>{let i=[],r=()=>i.forEach(n=>{n()});i.push(k(this,Oe,n=>{r(),e(n)}),k(this,le,()=>{r(),t()}))})}async*asyncValues(e){ee(this,Oe);try{let t=0;for(;!this.isDestroyed;)try{let i=await this.nextValue();if(e?.(i,t++))break;yield i}catch{break}}finally{he(this,Oe)}}destroy(){this.isDestroyed||(this.#t?.(),this.#t=void 0,y(this,le,this),he(this,Oe),A(this),this.lastValue=void 0,this.isDestroyed=!0,Object.freeze(this))}get isMuted(){return this.#e}mute(){return!this.isDestroyed&&!this.#e&&(this.#e=!0,y(this,ns,this)),this}unmute(){return!this.isDestroyed&&this.#e&&(this.#e=!1,y(this,os,this)),this}toggleMute(){return this.isDestroyed||(this.#e=!this.#e,y(this,this.#e?ns:os,this)),this.#e}updateValue(e){if(!this.#e&&!this.isDestroyed){let{value:t}=this.source;e(t),y(this,Oe,t),this.lastValue=t}}},hs=class extends At{target;constructor(e,t){super(e),this.target=R(t),k(we,this.target.id,()=>this.destroy()),this.touch()}touch(){return this.updateValue(e=>{this.target.writer(e,{touch:!0})}),this}write(){this.updateValue(e=>{this.target.writer(e)})}},ls=class extends At{target;constructor(e,t){super(e),this.target=t,this.touch()}touch(){return this.updateValue(e=>{this.target(e)}),this}write(){this.updateValue(e=>{this.target(e)})}},kt=new Map;function _(s,e,t){let i=R(s),r=R(e),n=r??e,o;if(kt.has(i)){if(o=kt.get(i),o.has(n))return o.get(n)}else o=new Map,kt.set(i,o);let a=r!=null?new hs(s,r):new ls(s,e),f=t?.attach;return f&&a.attach(f),o.set(n,a),k(a,le,()=>{o.delete(n),o.size===0&&kt.delete(i)}),a}var Pt=class s{static fromProps(e,t){let i=new s,r=t?t.map(n=>[n,e[n]]):Object.entries(e);for(let[n,o]of r)i.#e.set(n,p(o));return i}#e=new Map;keys(){return this.#e.keys()}signals(){return this.#e.values()}entries(){return this.#e.entries()}clear(){for(let e of this.#e.values())e.destroy();this.#e.clear()}has(e){return this.#e.has(e)}get(e){if(!this.#e.has(e)){let t=p();return this.#e.set(e,t),t}return this.#e.get(e)}update(e){e.size&&N(()=>{for(let[t,i]of e.entries())this.get(t).set(i)})}updateFromProps(e,t){N(()=>{let i=t?t.map(r=>[r,e[r]]):Object.entries(e);for(let[r,n]of i)this.get(r).set(n)})}};var se=(s=>(s[s.StructuralChanges=1]="StructuralChanges",s[s.ContentUpdates=2]="ContentUpdates",s[s.Removal=3]="Removal",s))(se||{}),E=(s=>(s[s.CreateEntities=1]="CreateEntities",s[s.DestroyEntities=2]="DestroyEntities",s[s.SetParent=3]="SetParent",s[s.UpdateOrder=4]="UpdateOrder",s[s.ChangeProperties=5]="ChangeProperties",s[s.ChangeToken=6]="ChangeToken",s[s.SendEvents=7]="SendEvents",s))(E||{}),Ee=Symbol.for("ShadowEntsGlobalNS"),ie="#void",oi="contextLost",ai="configure",hi="changeTrail",li="destroy",ci="loaded",ui="appliedChangeTrail",di="importedModule",fi="destroyed",Me="messageToView",pi=6e4,gi=6e4,yi=5e3,vi=5e3,cs="shadowObjects";function mi(s,e){s.indexOf(e)===-1&&s.push(e)}function us(s,e){let t=s.indexOf(e);t!==-1&&s.splice(t,1),s.push(e)}function ce(s,e){let t=s.indexOf(e);t!==-1&&s.splice(t,1)}var Se=s=>typeof s=="string"?s.trim()||Ee:typeof s=="symbol"?s:Ee;var Be="#root",Ve=class{#e;get uuid(){return this.#e}#t=0;constructor(e){this.#e=e}#s=!0;#r=0;#i=0;hasChanges(){return this.#t>0}get isNew(){return this.#s}get isCreated(){return this.#r>0&&this.#r>this.#i}get isDestroyed(){return this.#i>0&&this.#i>=this.#r}#n=ie;#o;#a=0;#l=!1;#c;#u;#h;create(e=ie,t,i=0,r=!1){this.#t++,this.#r++,this.#c=e,this.#u=t??Be,this.#h=i||void 0,this.#l=r}destroy(){this.#i++,this.#t++}clear(){this.#t=0,this.#s=!1,this.#c=void 0,this.#u=void 0,this.#h=void 0,this.#p.clear(),this.#g.length=0,this.#d.length=0,this.#f.clear()}changeToken(e){e===this.#n?this.#c=void 0:(this.#c=e,this.#t++)}setParent(e){e===this.#o?this.#u=void 0:(this.#u=e??Be,this.#t++)}changeOrder(e){e===this.#a?this.#h=void 0:(this.#h=e,this.#t++)}#y=new Map;#p=new Map;#g=[];changeProperty(e,t,i){let r=this.#y.get(e);i==null&&t!==r||i!=null&&!i(t,r)?(this.#p.set(e,t),us(this.#g,e),this.#t++):(this.#p.delete(e),ce(this.#g,e))}removeProperty(e){let t=this.#y.has(e);this.#p.has(e)?(this.#p.delete(e),t||ce(this.#g,e)):t&&(us(this.#g,e),this.#t++)}#d=[];#f=new Set;createEvent(e,t,i){this.#d.push({type:e,data:t}),i?.forEach(r=>this.#f.add(r)),this.#t++}transferEventsTo(e){this.#d.length>0&&(e.#d.push(...this.#d),this.#d.length=0),this.#f.size>0&&(e.#f=new Set([...e.#f,...this.#f]),this.#f.clear())}buildChangeTrail(e,t){let{isNew:i,isCreated:r,isDestroyed:n}=this;if(!(i&&n))switch(t){case se.StructuralChanges:i?e.push(this.makeCreateEntityChange()):n||(this.#u!==void 0&&!(this.#u===Be&&this.#o===void 0)?e.push(this.makeSetParentChange()):this.#h!==void 0&&this.#h!==this.#a&&e.push(this.makeUpdateOrderChange()),this.#c!==void 0&&this.#c!==this.#n&&e.push(this.makeChangeToken()));break;case se.ContentUpdates:!i&&r&&this.#g.length>0&&e.push(this.makeChangePropertyChange()),this.#d.length>0&&e.push(this.makeEvents());break;case se.Removal:n&&e.push(this.makeDestroyEntityChange());break}}makeEvents(){let e={type:E.SendEvents,uuid:this.#e,events:this.#d.slice(0)};return this.#f.size>0&&(e.transferables=Array.from(this.#f)),e}makeCreateEntityChange(){let e={type:E.CreateEntities,uuid:this.#e,token:this.#c};if(this.#n=this.#c,this.#u!==void 0){let t=this.#u===Be?void 0:this.#u;this.#o=t,t!==void 0&&(e.parentUuid=t)}return this.#p.size>0&&(e.properties=Array.from(this.#p.entries()).filter(([,t])=>t!==void 0),e.properties.forEach(([t,i])=>this.#y.set(t,i))),this.#h!==void 0&&this.#h!==this.#a&&(e.order=this.#a=this.#h),this.#l&&(e.autoDestructionOnParentRemoval=!0),e}makeDestroyEntityChange(){return{type:E.DestroyEntities,uuid:this.#e}}makeSetParentChange(){this.#o=this.#u===Be?void 0:this.#u;let e={type:E.SetParent,uuid:this.#e,parentUuid:this.#o};return this.#h!==void 0&&this.#h!==this.#a&&(e.order=this.#a=this.#h),e}makeUpdateOrderChange(){return this.#a=this.#h??0,{type:E.UpdateOrder,uuid:this.#e,order:this.#a}}makeChangeToken(){return this.#n=this.#c??ie,{type:E.ChangeToken,uuid:this.#e,token:this.#n}}makeChangePropertyChange(){let e=this.#g.map(t=>{if(this.#p.has(t)){let i=this.#p.get(t);return this.#y.set(t,i),[t,i]}else return this.#y.delete(t),[t,void 0]});return{type:E.ChangeProperties,uuid:this.#e,properties:e}}};var bi=s=>{if(!(s===void 0||s.length===0))return s.filter(e=>e.length===1||e[1]!==void 0)},ds=(s,e)=>{if(s===e||e===void 0)return s;if(s===void 0)return bi(e);for(let[t,i]of e){let r=s.find(([n])=>n===t);r===void 0?s.push([t,i]):r[1]=i}return bi(s)};var Tt=class{#e=new Map;get[Symbol.iterator](){return this.#e.entries.bind(this.#e)}clear(){this.#e.clear()}isEmpty(){return this.#e.size===0}hasComponentState(e){return this.#e.has(e)}getComponentState(e){return this.#e.get(e)}write(e){for(let t of e)if(t.type===E.CreateEntities)this.createEntity(t);else if(this.#e.has(t.uuid))switch(t.type){case E.DestroyEntities:this.destroyEntity(t);break;case E.SetParent:this.setParent(t);break;case E.UpdateOrder:this.updateOrder(t);break;case E.ChangeToken:this.changeToken(t);break;case E.ChangeProperties:this.changeProperties(t);break}}changeProperties({uuid:e,properties:t}){let i=this.getComponentState(e);i.properties=ds(i.properties,t)}changeToken({uuid:e,token:t}){this.getComponentState(e).token=t||ie}updateOrder({uuid:e,order:t}){this.getComponentState(e).order=t??0}setParent({uuid:e,parentUuid:t,order:i}){let r=this.getComponentState(e);r.parentUuid=t,r.order=i??0}destroyEntity({uuid:e}){this.#e.delete(e)}createEntity({uuid:e,token:t,parentUuid:i,order:r,properties:n,autoDestructionOnParentRemoval:o}){this.#e.set(e,{token:t||ie,parentUuid:i,order:r??0,properties:ds(void 0,n),...o?{autoDestructionOnParentRemoval:!0}:{}})}};var F=class s{static{this.ReRequestParentRoots="re-request-parent-roots"}static getContextsMap(){return globalThis.__shadowEntsContexts==null&&(globalThis.__shadowEntsContexts=new Map),globalThis.__shadowEntsContexts}static get(e){let t=Se(e),i=s.getContextsMap();return i.has(t)?i.get(t):new s(t)}#e=new Map;#t=[];#s=new Tt;constructor(e=Ee){let t=Se(e),i=s.getContextsMap();if(i.has(t))return i.get(t);this.ns=t,i.set(t,this)}addComponent(e){let t;this.#e.has(e.uuid)?(t=this.#e.get(e.uuid),t.component=e,t.children=[]):(t={component:e,children:[],changes:new Ve(e.uuid),propIsEqual:void 0},this.#e.set(e.uuid,t)),t.changes.create(e.token,e.parent?.uuid,e.order,e.autoDestructionOnParentRemoval),e.parent?(this.addToChildren(e.parent,e),t.changes.setParent(e.parent.uuid)):this.#n(e,this.#t),this.#o=void 0}hasComponent(e){return this.#e.has(e.uuid)}hasComponents(){return this.#e.size>0}isRootComponent(e){return this.#t.includes(e.uuid)}destroyComponent(e){if(this.hasComponent(e)){let t=this.#e.get(e.uuid);t.children.slice(0).forEach(i=>this.#e.get(i)?.component.removeFromParent()),t.changes.destroy(),this.#o=void 0}}getChildren(e){return this.#e.get(e.uuid)?.children.map(t=>this.#e.get(t).component)??[]}removeFromParent(e,t){if(this.hasComponent(t)){let i=this.#e.get(e),r=this.#e.get(t.uuid),n=r.children.indexOf(e);n!==-1&&(r.children.splice(n,1),i.changes.setParent(void 0)),this.#n(i.component,this.#t),this.#o=void 0}}moveToRoot(e){let t=this.#e.get(e);t&&(t.changes?.setParent(void 0),this.#n(t.component,this.#t)),this.#o=void 0}changeToken(e,t){this.#e.get(e.uuid)?.changes.changeToken(t)}isChildOf(e,t){return this.hasComponent(t)?this.#e.get(t.uuid).children.includes(e.uuid):!1}addToChildren(e,t){let i=this.#e.get(e.uuid);if(i)this.#n(t,i.children),this.#e.get(t.uuid)?.changes.setParent(e.uuid),ce(this.#t,t.uuid),this.#o=void 0;else throw new Error(`the view component ${e.uuid} cannot have a child added to it because the component do not exist!`)}removeSubTree(e){let t=this.#e.get(e);t&&(t.children.slice(0).forEach(i=>this.removeSubTree(i)),this.destroyComponent(t.component),this.#r(e))}setProperty(e,t,i,r){let n=this.#e.get(e.uuid);return n!=null?(r!=null?(n.propIsEqual??=new Map,n.propIsEqual.set(t,r)):n.propIsEqual?.has(t)&&n.propIsEqual.delete(t),n.changes.changeProperty(t,i,r)):!1}removeProperty(e,t){this.#e.get(e.uuid)?.changes.removeProperty(t)}changeOrder(e){if(e.parent){let t=this.#e.get(e.parent.uuid);ce(t.children,e.uuid),this.#n(e,t.children)}else ce(this.#t,e.uuid),this.#n(e,this.#t);this.#e.get(e.uuid)?.changes.changeOrder(e.order),this.#o=void 0}traverseLevelOrderBFS(){return this.#a().map(e=>e.component)}dispatchShadowObjectsEvent(e,t,i,r){this.#e.get(e.uuid)?.changes.createEvent(t,i,r)}broadcastEvent(e,t=void 0){for(let i of this.traverseLevelOrderBFS())i.dispatchEvent(e,t,!1)}dispatchMessage(e,t,i=void 0,r=!1){this.#e.get(e)?.component.dispatchEvent(t,i,r)}dispatchReRequestParentRoots(){for(let e of this.#t)this.dispatchMessage(e,s.ReRequestParentRoots)}buildChangeTrails(e=!0){let t=[];if(!this.hasComponents())return t;let i=this.#i();for(let r of i)r.buildChangeTrail(t,se.StructuralChanges);for(let r of i)r.buildChangeTrail(t,se.ContentUpdates);for(let r of i)r.buildChangeTrail(t,se.Removal),(r.isDestroyed||r.isNew&&!r.isCreated)&&this.#r(r.uuid),e&&r.clear();return this.#s.write(t),t}reCreateChanges(){if(!this.#s.isEmpty()){this.buildChangeTrails(!1);for(let[e,t]of this.#s){let i=this.#e.get(e);if(i){let r=new Ve(e);if(r.create(t.token,t.parentUuid,t.order,t.autoDestructionOnParentRemoval),t.properties)for(let[n,o]of t.properties)r.changeProperty(n,o,i.propIsEqual?.get(n));i.changes.transferEventsTo(r),i.changes.clear(),i.changes=r}}this.#s.clear(),this.broadcastEvent(oi)}}clear(){if(this.#o=void 0,this.#s.clear(),this.#t.slice(0).forEach(e=>this.removeSubTree(e)),this.#t.length!==0)throw new Error("component-context panic: #rootComponents is not empty!");if(this.#e.size!==0)throw new Error("component-context panic: #components is not empty!")}#r(e){this.#e.has(e)&&(this.#e.delete(e),ce(this.#t,e),this.#o=void 0)}#i(){return this.#a().filter(e=>e.changes.hasChanges()).map(e=>e.changes)}#n(e,t){if(t.length===0){t.push(e.uuid);return}if(t.includes(e.uuid))return;let i=t.length,r=new Array(i);if(r[0]=this.#e.get(t[0]).component,e.order<r[0].order){t.unshift(e.uuid);return}if(i===1){t.push(e.uuid);return}let n=i-1;if(r[n]=this.#e.get(t[n]).component,e.order>=r[n].order){t.push(e.uuid);return}if(i===2){t.splice(1,0,e.uuid);return}for(let o=n-1;o>=1;o--)if(r[o]=this.#e.get(t[o]).component,e.order>=r[o].order){t.splice(o+1,0,e.uuid);return}}#o;#a(){if(this.#o)return this.#o;let e=new Map,t=(i,r)=>{let n=this.#e.get(i);if(n!=null){e.has(r)?e.get(r).push(n):e.set(r,[n]);for(let o of n.children)t(o,r+1)}};return this.#t.forEach(i=>t(i,0)),this.#o=Array.from(e.entries()).sort((i,r)=>i[0]-r[0]).flatMap(([,i])=>i),this.#o}};function Ue(s){return function(e,t){let i=s?.name||t.name,r=!!(s?.readAsValue??!1);return{get(){let n=U(this,i);if(n)return r?n.value:n.get()},set(n){U(this,i)?.set(n)},init(n){let o=p(n,s);return ri(this,i,o),te.findOrCreate(this).attachSignalByName(i,o),o.value}}}}var z="ConsoleLogger",I=`${z}Storage`,Rr=!!(globalThis.location?.host?.startsWith("localhost")??!1),qe="localStorage"in globalThis,Ot=Symbol.for(z),wi=!1,Ci=s=>{if(typeof s=="boolean")return s;switch(s.toLowerCase()){case"true":case"yes":case"on":return!0;default:return!1}},ps=s=>[qe?z:void 0,...Array.isArray(s)?s:[s]].filter(Boolean).join(".");function fs(s,e=void 0,t){let i=ps(s),r=qe?localStorage.getItem(i):globalThis[I]?.[i];return r!=null?e(r):t}function Ge(s,e){qe?localStorage.setItem(ps(s),e):(globalThis[I]==null&&(globalThis[I]={},console.debug(`${z}: Initialize`,{[I]:globalThis[I]})),globalThis[I][ps(s)]=e)}var D=class s{constructor(e){this.enable=!0,this.namespace=(e||"").trim()||z,wi||(s.loadConfig(),wi=!0);let t=[this.namespace,"enable"];this.enable=fs(t,Ci,this.enable),Ge(t,qe?this.enable?"true":"false":this.enable)}static{this.sharedConfig={enable:Rr,debug:!1,info:!0,warn:!0,"styles.debug":"color: #111; background: #999; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.info":"color: #020; background: #8a8; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.warn":"color: #fa0; background: #a98; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.error":"color: #ff0; background: #a00; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em"}}static get isEnabled(){return s.sharedConfig.enable}static get isDebug(){return s.sharedConfig.enable&&s.sharedConfig.debug}static{this.sharedStyles={get debug(){return s.sharedConfig["styles.debug"]},set debug(e){s.sharedConfig["styles.debug"]=e},get info(){return s.sharedConfig["styles.info"]},set info(e){s.sharedConfig["styles.info"]=e},get warn(){return s.sharedConfig["styles.warn"]},set warn(e){s.sharedConfig["styles.warn"]=e},get error(){return s.sharedConfig["styles.error"]},set error(e){s.sharedConfig["styles.error"]=e}}}static loadConfig(){qe?(["enable","debug","info","warn"].forEach(e=>{this.sharedConfig[e]=fs(e,Ci,this.sharedConfig[e])}),["debug","info","warn","error"].forEach(e=>{this.sharedStyles[e]=fs(["styles",e],void 0,this.sharedStyles[e])}),s.isDebug&&console.debug(`${z}: Load config from localStorage`,s.sharedConfig),globalThis[z]?.[Ot]||(globalThis[z]??={[Ot]:!0,get enable(){return s.sharedConfig.enable},set enable(e){s.sharedConfig.enable=e,Ge("enable",e?"true":"false")},get debug(){return s.sharedConfig.debug},set debug(e){s.sharedConfig.debug=e,Ge("debug",e?"true":"false")},get info(){return s.sharedConfig.info},set info(e){s.sharedConfig.info=e,Ge("info",e?"true":"false")},get warn(){return s.sharedConfig.warn},set warn(e){s.sharedConfig.warn=e,Ge("warn",e?"true":"false")}})):globalThis[I]?.[Ot]||(globalThis[I]={[Ot]:!0,...s.sharedConfig,...globalThis[I]},s.sharedConfig=globalThis[I],s.isDebug&&console.debug(`${z}: Load config from ${I}`,globalThis[I]))}get isEnabled(){return this.enable&&s.sharedConfig.enable}get isDebug(){return this.isEnabled&&s.sharedConfig.debug}get isInfo(){return this.isEnabled&&s.sharedConfig.info}get isWarn(){return this.isEnabled&&s.sharedConfig.warn}debug(...e){this.#e("debug",s.sharedStyles.debug,e)}info(...e){this.#e("info",s.sharedStyles.info,e)}warn(...e){this.#e("warn",s.sharedStyles.warn,e)}error(...e){this.#e("error",s.sharedStyles.error,e)}#e(e,t,i){console[e](`%c${this.namespace}`,t,...i)}};var Lr=Object.create,vs=Object.defineProperty,Dr=Object.getOwnPropertyDescriptor,Si=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),Le=s=>{throw TypeError(s)},Nr=(s,e,t)=>e in s?vs(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ei=(s,e)=>vs(s,"name",{value:e,configurable:!0}),_r=s=>[,,,Lr(s?.[Si("metadata")]??null)],ki=["class","method","getter","setter","accessor","field","value","get","set"],He=s=>s!==void 0&&typeof s!="function"?Le("Function expected"):s,$r=(s,e,t,i,r)=>({kind:ki[s],name:e,metadata:i,addInitializer:n=>t._?Le("Already initialized"):r.push(He(n||null))}),Ai=(s,e)=>Nr(e,Si("metadata"),s[3]),xt=(s,e,t,i)=>{for(var r=0,n=s[e>>1],o=n&&n.length;r<o;r++)e&1?n[r].call(t):i=n[r].call(t,i);return i},Pi=(s,e,t,i,r,n)=>{var o,a,f,m,P,c=e&7,j=!!(e&8),C=!!(e&16),M=c>3?s.length+1:c?j?1:2:0,l=ki[c+5],h=c>3&&(s[M-1]=[]),d=s[M]||(s[M]=[]),u=c&&(!C&&!j&&(r=r.prototype),c<5&&(c>3||!C)&&Dr(c<4?r:{get[t](){return b(this,n)},set[t](v){return $(this,n,v)}},t));c?C&&c<4&&Ei(n,(c>2?"set ":c>1?"get ":"")+t):Ei(r,t);for(var g=i.length-1;g>=0;g--)m=$r(c,t,f={},s[3],d),c&&(m.static=j,m.private=C,P=m.access={has:C?v=>Wr(r,v):v=>t in v},c^3&&(P.get=C?v=>(c^1?b:Mt)(v,r,c^4?n:u.get):v=>v[t]),c>2&&(P.set=C?(v,B)=>$(v,r,B,c^4?n:u.set):(v,B)=>v[t]=B)),a=(0,i[g])(c?c<4?C?n:u[l]:c>4?void 0:{get:u.get,set:u.set}:r,m),f._=1,c^4||a===void 0?He(a)&&(c>4?h.unshift(a):c?C?n=a:u[l]=a:r=a):typeof a!="object"||a===null?Le("Object expected"):(He(o=a.get)&&(u.get=o),He(o=a.set)&&(u.set=o),He(o=a.init)&&h.unshift(o));return c||Ai(s,r),u&&vs(r,t,u),C?c^4?n:u:r},ms=(s,e,t)=>e.has(s)||Le("Cannot "+t),Wr=(s,e)=>Object(e)!==e?Le('Cannot use the "in" operator on this value'):s.has(e),b=(s,e,t)=>(ms(s,e,"read from private field"),t?t.call(s):e.get(s)),G=(s,e,t)=>e.has(s)?Le("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),$=(s,e,t,i)=>(ms(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),Mt=(s,e,t)=>(ms(s,e,"access private method"),t),Ti,Oi,T,re,Re,Qe,Ye,ke,de,bs,ws,Rt,gs,Ke,ys,xi;Oi=[Ue()],Ti=[Ue()];var fe=class ue{constructor(){G(this,Ke),G(this,T),G(this,re),G(this,Re,!1),G(this,Qe,!1),G(this,Ye,!1),G(this,ke),this.logger=new D("ShadowEnv"),this.ns$=p(),G(this,bs,xt(de,8,this,!1)),xt(de,11,this),G(this,ws,xt(de,12,this,!1)),xt(de,15,this),G(this,Rt,!1),this.ready=async()=>this.isReady?this:Ae(this,ue.ContextCreated),G(this,gs,()=>{b(this,Re)&&Mt(this,Ke,ys).call(this)});let e=this;ee(e,ue.ContextCreated),w(e,ue.ContextLost,Q.AAA,()=>{he(e,ue.ContextCreated)}),S(()=>{if(this.viewReady&&this.proxyReady)return this.view.reCreateChanges(),y(e,ue.ContextCreated,e),b(this,Qe)&&($(this,Qe,!1),Mt(this,Ke,ys).call(this)),()=>{y(e,ue.ContextLost,e)}},[U(this,"viewReady"),U(this,"proxyReady")])}static get(e){if(e!=null)return globalThis.__shadowEnvs?.get(e)}get isDestroyed(){return b(this,Rt)}get view(){return b(this,T)}set view(e){e!==b(this,T)&&(b(this,T)&&b(this,T).ns&&globalThis.__shadowEnvs&&globalThis.__shadowEnvs.delete(b(this,T).ns),$(this,T,e??void 0),b(this,T)&&b(this,T).ns&&(globalThis.__shadowEnvs??=new Map,globalThis.__shadowEnvs.has(b(this,T).ns)&&globalThis.__shadowEnvs.get(b(this,T).ns)!==this&&this.logger.isWarn&&this.logger.warn("overwrite a namespace already in use",b(this,T).ns,globalThis.__shadowEnvs.get(b(this,T).ns)),globalThis.__shadowEnvs.set(b(this,T).ns,this)),this.viewReady=!!e)}get envProxy(){return b(this,re)}set envProxy(e){if(e!==b(this,re)){let t=b(this,re);$(this,re,e??void 0),b(this,re)&&(b(this,re).onMessageToView=Mt(this,Ke,xi).bind(this)),t&&t.destroy(),this.proxyReady=!1,e?.start().then(()=>{this.proxyReady=!0}).catch(i=>{this.logger.error("failed to start envProxy",i),this.proxyReady=!1})}}get isReady(){return!!(b(this,T)&&b(this,re)&&this.proxyReady&&!this.isDestroyed)}sync(){if(!this.isReady){$(this,Qe,!0);return}b(this,Re)||($(this,Re,!0),queueMicrotask(b(this,gs)))}syncWait(){return $(this,Ye,!0),this.sync(),b(this,ke)?b(this,ke):($(this,ke,Ae(this,ue.AfterSync).then(e=>($(this,ke,void 0),e))),b(this,ke))}destroy(){let e=b(this,T)?.ns;this.envProxy?.destroy(),this.envProxy=void 0,this.view=void 0,e&&globalThis.__shadowEnvs.has(e)&&globalThis.__shadowEnvs.get(e)===this&&globalThis.__shadowEnvs.delete(e),ze(this),A(this),$(this,Rt,!0),Object.freeze(this)}};de=_r(null);T=new WeakMap;re=new WeakMap;Re=new WeakMap;Qe=new WeakMap;Ye=new WeakMap;ke=new WeakMap;bs=new WeakMap;ws=new WeakMap;Rt=new WeakMap;gs=new WeakMap;Ke=new WeakSet;ys=async function(){if($(this,Re,!1),this.isReady){let s=this.view.buildChangeTrails();if(s.length>0)try{let e=b(this,Ye);$(this,Ye,!1),await this.envProxy.applyChangeTrail(s,e)}catch(e){this.logger.error("failed to apply change trail",e)}finally{y(this,fe.AfterSync,s)}}};xi=function(s){this.logger.isDebug&&this.logger.debug("onMessageToView",s.type,s.data),this.view?.dispatchMessage(s.uuid,s.type,s.data,s.traverseChildren)};Pi(de,4,"viewReady",Oi,fe,bs);Pi(de,4,"proxyReady",Ti,fe,ws);Ai(de,fe);fe.AfterSync="afterSync";fe.ContextLost="contextLost";fe.ContextCreated="contextCreated";var Y=fe;var x=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],jr=()=>{let s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(x[s&255]+x[s>>8&255]+x[s>>16&255]+x[s>>24&255]+"-"+x[e&255]+x[e>>8&255]+"-"+x[e>>16&15|64]+x[e>>24&255]+"-"+x[t&63|128]+x[t>>8&255]+"-"+x[t>>16&255]+x[t>>24&255]+x[i&255]+x[i>>8&255]+x[i>>16&255]+x[i>>24&255]).toLowerCase()},Mi=()=>globalThis?.crypto?.randomUUID?.()??jr();var Je=class extends Error{constructor(e){super(e),this.name="ViewComponentError"}},Lt=class s{#e;#t;#s;#r;#i=0;#n;get uuid(){return this.#e}get token(){return this.#t}set token(e){e??=ie,e!==this.#t&&(this.#t=e,this.#s?.changeToken(this,e))}get parent(){return this.#r}set parent(e){if(e){if(e.#s!==this.#s)throw new Je("cannot set parent from different context");e.addChild(this)}else this.removeFromParent()}get context(){return this.#s}set context(e){this.#s!=e&&(this.#s&&this.destroy(),this.#s=e,e&&e.addComponent(this))}get order(){return this.#i}set order(e){let t=this.#i;this.#i=e??0,t!==this.#i&&this.#s.changeOrder(this)}get autoDestructionOnParentRemoval(){return this.#n}constructor(e,t){O(this),t instanceof s&&(t={parent:t}),this.#e=t?.uuid??Mi(),this.#t=e,this.#i=t?.order??0,this.#r=t?.parent,this.#n=t?.autoDestructionOnParentRemoval??!1;let i=t?.context??F.get();if(this.#r&&this.#r.#s!==i)throw new Je("cannot set parent from different context");this.context=i}isChildOf(e){return this.#r===e}removeFromParent(){this.#r?(this.#s?.removeFromParent(this.uuid,this.#r),this.#r=void 0):this.#s?.moveToRoot(this.uuid)}addChild(e){if(e.#s!==this.#s)throw new Je("cannot add a child from another context");e.isChildOf(this)||(e.removeFromParent(),e.#r=this,this.#s.addToChildren(this,e))}setProperty(e,t,i){this.#s.setProperty(this,e,t,i)}removeProperty(e){this.#s.removeProperty(this,e)}dispatchShadowObjectsEvent(e,t,i){this.#s.dispatchShadowObjectsEvent(this,e,t,i)}dispatchEvent(e,t,i){if(y(this,e,t),i)for(let r of this.#s.getChildren(this))r.dispatchEvent(e,t,i)}destroy(){this.removeFromParent(),this.#s?.destroyComponent(this),this.#s=void 0}};var Xe=new Set(["on","true","yes","local","1"]);var Ri=s=>Se(s.getAttribute("ns")),et=(s,e)=>{if(s.hasAttribute(e)){let t=s.getAttribute(e)?.trim()?.toLowerCase()||"1";return Xe.has(t)}return!1};var Li=(s,e)=>{e.set(Ri(s))},Cs=new Set,Es=!1,Fr=s=>{Cs.add(s),Es||(Es=!0,queueMicrotask(()=>{Es=!1;for(let e of Cs)Y.get(e)?.sync();Cs.clear()}))},pe=class extends HTMLElement{constructor(){super(),this.isShaeElement=!0,this.ns$=p(Ee),this.ns$.onChange(e=>{typeof e=="string"&&e.length>0?this.getAttribute("ns")!==e&&this.setAttribute("ns",e):this.removeAttribute("ns")}),Li(this,this.ns$)}static{this.observedAttributes=["ns"]}get ns(){return this.ns$.value}set ns(e){typeof e=="symbol"?this.ns$.set(e):this.ns$.set(Se(e))}attributeChangedCallback(e){e==="ns"&&Li(this,this.ns$)}syncShadowObjects(){Fr(this.ns)}};var Dt=class extends pe{constructor(){super(),this.isShaeEntElement=!0,this.componentContext$=p(),this.viewComponent$=p(),this.token$=p(),this.forwardCustomEvents$=p(!1),this.#n=!0,this.#y=()=>{let e=this.findShadowRootHost();e!=null&&this.dispatchEvent(new CustomEvent(lt,{bubbles:!0,composed:!0,detail:{requester:this,shadowRootHost:e}}))},this.#p=e=>{let t=e.detail?.requester;if(t===this||!t?.isShaeEntElement||t.ns!==this.ns)return;e.detail?.shadowRootHost&&this.#c()},this.#g=e=>{let t=e.detail?.requester;t!==this&&t?.isShaeEntElement&&t.ns===this.ns&&(e.stopPropagation(),t.#h(this))},this.ns$.onChange(e=>{this.componentContext$.set(F.get(e)),this.isConnected&&this.#c()}),this.#d(),this.token$.onChange(e=>{e==null?this.removeAttribute(oe):this.getAttribute(oe)!==e&&this.setAttribute(oe,e)}),this.#f(),this.forwardCustomEvents$.onChange(e=>{if(!e)this.removeAttribute(q);else if(e===!0)this.hasAttribute(q)||this.setAttribute(q,"");else{let t=Array.from(e).join(",");this.getAttribute(q)!==t&&this.setAttribute(q,t)}}),S(()=>{let e=this.viewComponent$.get();if(e){let t=w(e,F.ReRequestParentRoots,()=>this.#l()),i=e.context?.ns;return()=>{t(),e.destroy(),i&&i!==this.ns?Y.get(i)?.sync():this.syncShadowObjects()}}}),S(()=>{let e=this.viewComponent$.get();if(!e)return;let t=Object.hasOwn(e,"dispatchEvent")?Object.getPrototypeOf(e).dispatchEvent:e.dispatchEvent,i=this.forwardCustomEvents$.get();if(!i)return;let r=i instanceof Set?i:void 0,n=(o,a,f)=>{t.call(e,o,a,f),o!==F.ReRequestParentRoots&&(r&&!r.has(o)||this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:a})))};return Object.defineProperty(e,"dispatchEvent",{value:n,writable:!0,configurable:!0}),()=>{Object.hasOwn(e,"dispatchEvent")&&e.dispatchEvent===n&&delete e.dispatchEvent}}),this.token$.onChange(e=>{let t=this.viewComponent$.value;t&&(t.token=e,this.syncShadowObjects())}),this.style.display="contents"}static{this.observedAttributes=[...pe.observedAttributes,oe,q]}get componentContext(){return this.componentContext$.value}get viewComponent(){return this.viewComponent$.value}get uuid(){return this.viewComponent?.uuid}get token(){return this.token$.value}set token(e){this.token$.set(e)}#e;#t;#s(){this.#t?.();let e=this.componentContext$.onChange(t=>{let i=this.token$.value,r=this.viewComponent$.value;r?r.context=t:t&&(r=new Lt(i,{context:t}),this.viewComponent$.set(r)),this.syncShadowObjects()});this.#t=()=>{e()}}#r(){this.#t?.(),this.#t=void 0}#i;#n;findShadowRootHost(){if(this.#n){this.#n=!1;let e=this;for(;e;){if(e.parentElement==null){let t=e.parentNode;t&&(this.#i=t.host);break}e=e.parentElement}}return this.#i}getParentNodeForObserver(){let e=this.parentNode;return e||(e.host??e)}connectedCallback(){this.#n=!0,this.addEventListener("slotchange",this.#y,{capture:!1,passive:!1}),this.addEventListener(ht,this.#g,{capture:!1,passive:!1}),this.#s(),Et(()=>this.#d()),Et(()=>this.#f()),this.componentContext==null&&this.componentContext$.set(F.get(this.ns)),this.#c(),this.componentContext?.dispatchReRequestParentRoots(),this.#o(),this.syncShadowObjects()}#o(){this.#a();let e=this.getParentNodeForObserver();e&&(this.#e=new MutationObserver((t,i)=>{for(let{target:r,removedNodes:n}of t)if(r===e){for(let o of n)if(o===this){this.#a(),this.onParentChanged(this.getParentNodeForObserver(),e);break}}}),this.#e.observe(e,{childList:!0,subtree:!1,attributes:!1}))}onParentChanged(e,t){this.#h(void 0),this.#c()}#a(){this.#e?.disconnect(),this.#e=void 0}attributeChangedCallback(e){super.attributeChangedCallback(e),e===oe?this.#d():e===q&&this.#f()}disconnectedCallback(){this.#n=!0,this.#a(),this.removeEventListener("slotchange",this.#y,{capture:!1}),this.removeEventListener(ht,this.#g,{capture:!1}),this.#h(void 0),this.componentContext$.set(void 0),this.syncShadowObjects(),this.#r()}#l(){this.isConnected&&(this.#h(void 0),this.#c())}#c(){this.dispatchEvent(new CustomEvent(ht,{bubbles:!0,composed:!0,detail:{requester:this}}))}#u;#h(e){if(this.entParentNode!==e)if(this.entParentNode&&this.entParentNode.removeEventListener(lt,this.#p,{capture:!1}),this.entParentNode=e,this.entParentNode&&this.entParentNode.addEventListener(lt,this.#p,{capture:!1,passive:!1}),this.#u?.(),this.#u=void 0,e){let t=S(()=>{let i=this.viewComponent$.get();if(i){let r=e.viewComponent$.get();i.parent=r&&r.context===i.context?r:void 0,i.parent==null&&queueMicrotask(()=>{this.#c()}),this.syncShadowObjects()}});this.#u=()=>t.destroy()}else{let t=this.viewComponent;t.parent&&(t.parent=void 0,this.syncShadowObjects())}}#y;#p;#g;#d(){if(this.hasAttribute(oe)){let e=this.getAttribute(oe)?.trim()||void 0;this.token$.set(e)}}#f(){if(this.hasAttribute(q)){let e=this.getAttribute(q);!e||e.trim().length===0?this.forwardCustomEvents$.set(!0):this.forwardCustomEvents$.set(new Set(e.split(",").map(t=>t.trim()).filter(t=>t.length>0)))}else this.forwardCustomEvents$.set(!1)}};customElements.define(ct,Dt);var Ir=s=>{let e=s.parentElement;for(;e;){if(e.isShaeEntElement)return e;e=e.parentElement}},zr=new Set(["string","text","number","bigint","float","int","integer","hex","hexadecimal","oct","octal","bin","binary","bool","boolean","[]","text[]","string[]","number[]","float[]","int[]","integer[]","hex[]","hexadecimal[]","oct[]","octal[]","bin[]","binary[]","bool[]","boolean[]","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array","json"]),Nt=class extends HTMLElement{constructor(){super(),this.isShaeEntElement=!0,this.entNode$=p(),this.viewComponent$=p(),this.name$=p(),this.valueIn$=p(),this.valueOut$=p(),this.type$=p(),this.shouldTrim$=p(!0),this.logger=new D("ShaePropElement"),this.#e=()=>{this.entNode$.set(Ir(this))},this.#t=()=>{queueMicrotask(()=>{this.isConnected||this.entNode$.set(void 0)})},this.#s=()=>{this.name$.set(this.getAttribute(ft)?.trim()??void 0)},this.#r=()=>{this.valueIn$.set(this.getAttribute(pt))},this.#i=()=>{let e=this.getAttribute(gt)?.trim().toLowerCase();e&&!zr.has(e)&&(this.logger.isWarn&&this.logger.warn(`[${this.name}] unknown type "${e}"`,{shaeProp:this}),e=void 0),this.type$.set(e)},this.#n=()=>{this.shouldTrim$.set(!et(this,yt))},this.entNode$.onChange(e=>{if(e){let t=_(e.viewComponent$,this.viewComponent$);return()=>{t.destroy()}}else this.viewComponent$.set(void 0)}),S(()=>{let e=this.viewComponent$.get();if(e){let t=this.name$.get();if(t){let i=this.valueOut$.get();this.logger.isDebug&&this.logger.debug(`[${this.name}] view-component set-property`,t,i,e.uuid,{viewComponent:e,shaeProp:this}),e.setProperty(t,i),this.isConnected&&this.entNode?.syncShadowObjects()}}}),S(()=>{let e=this.type$.get(),t=this.shouldTrim$.get(),i=this.valueIn$.get();if(t&&typeof i=="string"&&(i=i.trim()),i=i||void 0,i!=null&&typeof i=="string"&&e)switch(e){case"string":case"text":break;case"number":i=Number(i);break;case"bigint":i=BigInt(i);break;case"float":i=parseFloat(i);break;case"int":case"integer":i=parseInt(i,10);break;case"hex":case"hexadecimal":i=parseInt(i,16);break;case"oct":case"octal":i=parseInt(i,8);break;case"bin":case"binary":i=parseInt(i,2);break;case"bool":case"boolean":i=Xe.has(i.toLowerCase());break;case"[]":case"text[]":case"string[]":i=i.split(/\W+/);break;case"number[]":i=i.split(/\s+/).map(r=>Number(r));break;case"float[]":i=i.split(/\s+/).map(r=>parseFloat(r));break;case"int[]":case"integer[]":i=i.split(/\s+/).map(r=>parseInt(r));break;case"hex[]":case"hexadecimal[]":i=i.split(/\W+/).map(r=>parseInt(r,16));break;case"oct[]":case"octal[]":i=i.split(/\W+/).map(r=>parseInt(r,8));break;case"bin[]":case"binary[]":i=i.split(/\W+/).map(r=>parseInt(r,2));break;case"bool[]":case"boolean[]":i=i.split(/\W+/).map(r=>Xe.has(r.toLowerCase()));break;case"int8array":i=new Int8Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint8array":i=new Uint8Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint8clampedarray":i=new Uint8ClampedArray(i.split(/\W+/).map(r=>Number(r)));break;case"int16array":i=new Int16Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint16array":i=new Uint16Array(i.split(/\W+/).map(r=>Number(r)));break;case"int32array":i=new Int32Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint32array":i=new Uint32Array(i.split(/\W+/).map(r=>Number(r)));break;case"float32array":i=new Float32Array(i.split(/\s+/).map(r=>Number(r)));break;case"float64array":i=new Float64Array(i.split(/\s+/).map(r=>Number(r)));break;case"bigint64array":i=new BigInt64Array(i.split(/\W+/).map(r=>BigInt(r)));break;case"biguint64array":i=new BigUint64Array(i.split(/\W+/).map(r=>BigInt(r)));break;case"json":i=JSON.parse(i);break;default:this.logger.isWarn&&this.logger.warn(`[${this.name}] unknown type "${e}"`,{value:i,shaeProp:this})}this.valueOut$.set(i)}),N(()=>{this.#s(),this.#r(),this.#i(),this.#n()}),this.style.display="contents"}static{this.observedAttributes=[ft,pt,gt,yt]}get name(){return this.name$.value}get value(){return this.valueOut$.value}set value(e){this.valueIn$.set(e)}get shouldTrim(){return this.shouldTrim$.value}get entNode(){return this.entNode$.value}set entNode(e){this.entNode$.set(e)}get viewComponent(){return this.viewComponent$.value}connectedCallback(){N(()=>{this.#e(),this.#s(),this.#r(),this.#i(),this.#n()})}attributeChangedCallback(e){switch(e){case ft:this.#s();break;case pt:this.#r();break;case gt:this.#i();break;case yt:this.#n();break}}disconnectedCallback(){this.#t()}#e;#t;#s;#r;#i;#n};customElements.whenDefined(ct).then(()=>customElements.define(_s,Nt));var Ss=null,tt=class s{static{this.OnFrame=Symbol("onFrame")}#e=0;#t=0;constructor(){if(Ss)return Ss;O(this),Ss=this}start(e){if(e!=null)return es(this)===0&&this.#r(),w(this,s.OnFrame,e),this.#t++,()=>{this.stop(e)}}stop(e){A(this,s.OnFrame,e),es(this)===0&&this.#i()}#s=e=>{y(this,s.OnFrame,e),this.#r()};#r(){this.#e=requestAnimationFrame(this.#s)}#i(){cancelAnimationFrame(this.#e),this.#e=0}};async function ks(s,e,t,i=!0){if(t.has(e)){console.warn("importModule: skipping already imported module",e);return}else t.add(e);e.extends&&await Promise.all(e.extends.map(n=>ks(s,n,t,!1)));let{registry:r}=s;if(e.define)for(let[n,o]of Object.entries(e.define))r.define(n,o);if(e.routes)for(let[n,o]of Object.entries(e.routes))r.appendRoute(n,o);await(e.initialize?.({define:(n,o)=>r.define(n,o),kernel:s,registry:r})??Promise.resolve()),i&&s.upgradeEntities()}var _t=s=>s??void 0;var As=Symbol("onCreate"),J=Symbol("onDestroy"),Di=Symbol("onParentChanged"),$t=Symbol("onViewEvent");var Br=Object.create,Ps=Object.defineProperty,Vr=Object.getOwnPropertyDescriptor,$i=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),Ne=s=>{throw TypeError(s)},Ur=(s,e,t)=>e in s?Ps(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ni=(s,e)=>Ps(s,"name",{value:e,configurable:!0}),Gr=s=>[,,,Br(s?.[$i("metadata")]??null)],Wi=["class","method","getter","setter","accessor","field","value","get","set"],st=s=>s!==void 0&&typeof s!="function"?Ne("Function expected"):s,qr=(s,e,t,i,r)=>({kind:Wi[s],name:e,metadata:i,addInitializer:n=>t._?Ne("Already initialized"):r.push(st(n||null))}),ji=(s,e)=>Ur(e,$i("metadata"),s[3]),_i=(s,e,t,i)=>{for(var r=0,n=s[e>>1],o=n&&n.length;r<o;r++)e&1?n[r].call(t):i=n[r].call(t,i);return i},Hr=(s,e,t,i,r,n)=>{var o,a,f,m,P,c=e&7,j=!!(e&8),C=!!(e&16),M=c>3?s.length+1:c?j?1:2:0,l=Wi[c+5],h=c>3&&(s[M-1]=[]),d=s[M]||(s[M]=[]),u=c&&(!C&&!j&&(r=r.prototype),c<5&&(c>3||!C)&&Vr(c<4?r:{get[t](){return W(this,n)},set[t](v){return rt(this,n,v)}},t));c?C&&c<4&&Ni(n,(c>2?"set ":c>1?"get ":"")+t):Ni(r,t);for(var g=i.length-1;g>=0;g--)m=qr(c,t,f={},s[3],d),c&&(m.static=j,m.private=C,P=m.access={has:C?v=>Qr(r,v):v=>t in v},c^3&&(P.get=C?v=>(c^1?W:ge)(v,r,c^4?n:u.get):v=>v[t]),c>2&&(P.set=C?(v,B)=>rt(v,r,B,c^4?n:u.set):(v,B)=>v[t]=B)),a=(0,i[g])(c?c<4?C?n:u[l]:c>4?void 0:{get:u.get,set:u.set}:r,m),f._=1,c^4||a===void 0?st(a)&&(c>4?h.unshift(a):c?C?n=a:u[l]=a:r=a):typeof a!="object"||a===null?Ne("Object expected"):(st(o=a.get)&&(u.get=o),st(o=a.set)&&(u.set=o),st(o=a.init)&&h.unshift(o));return c||ji(s,r),u&&Ps(r,t,u),C?c^4?n:u:r},Ts=(s,e,t)=>e.has(s)||Ne("Cannot "+t),Qr=(s,e)=>Object(e)!==e?Ne('Cannot use the "in" operator on this value'):s.has(e),W=(s,e,t)=>(Ts(s,e,"read from private field"),t?t.call(s):e.get(s)),Wt=(s,e,t)=>e.has(s)?Ne("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),rt=(s,e,t,i)=>(Ts(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),ge=(s,e,t)=>(Ts(s,e,"access private method"),t),Fi,X,ye,nt,Os,ne,jt,it,De="value";Fi=[Ue({name:De})];var Z=class{constructor(e){Wt(this,ne),Wt(this,X,[]),Wt(this,ye),Wt(this,Os,_i(nt,8,this)),_i(nt,11,this),this.value$=void 0,ee(this,De),this.value$=U(this,De),this.value$.onChange(t=>y(this,De,t)),e&&this.add(...e)}add(...e){return W(this,X).push(...e),ge(this,ne,it).call(this),ge(this,ne,jt).call(this,e)}unshift(...e){return W(this,X).unshift(...e),ge(this,ne,it).call(this),ge(this,ne,jt).call(this,e)}remove(...e){ge(this,ne,jt).call(this,e)()}clear(){W(this,X).length=0,ge(this,ne,it).call(this)}dispose(){this.clear(),W(this,ye)?.destroy(),rt(this,ye,void 0),he(this,De),A(this),this.value$.destroy(),ze(this)}};nt=Gr(null);X=new WeakMap;ye=new WeakMap;Os=new WeakMap;ne=new WeakSet;jt=function(s){return()=>{for(let e of s){let t=W(this,X).indexOf(e);t!==-1&&W(this,X).splice(t,1)}ge(this,ne,it).call(this)}};it=function(){W(this,ye)?.destroy(),W(this,X).length===0?(rt(this,ye,void 0),this.value=void 0):(rt(this,ye,S(()=>{let s;for(let e of W(this,X)){let t=xe(e);if(t!=null){s=t;break}}this.value=s},W(this,X))),W(this,ye).run())};Hr(nt,4,"value",Fi,Z,Os);ji(nt,Z);Z.Value=De;var xs=new Map,Ms=!1,Kr=(s,e)=>{xs.set(s,e),Ms||(Ms=!0,queueMicrotask(()=>{Ms=!1;let t=Array.from(xs.entries());xs.clear();for(let[i,r]of t)i.set(r)}))},Ft=class{#e;#t;#s=new Pt;#r=new Map;#i=new Map;#n;#o;#a=new Set;#l=[];#c=0;get kernel(){return this.#e}get uuid(){return this.#t}get order(){return this.#c}set order(e){this.#c!==e&&(this.#c=e,this.#n&&this.parent.resortChildren())}get parentUuid(){return this.#n||void 0}set parentUuid(e){if(this.#n!==e){let t=e?this.#e.getEntity(e):void 0;this.removeFromParent(),this.#n=e||void 0,this.#o=t,this.#o&&this.#o.addChild(this),this.#p()}}get parent(){return!this.#o&&this.#n&&(this.#o=this.#e.getEntity(this.#n)),this.#o}set parent(e){this.parentUuid=e?.uuid}get hasParent(){return!!this.#n}get children(){return this.#l}constructor(e,t){this.#e=e,this.#t=t,k(this,J,Q.Min,this)}traverse(e){e(this);for(let t of this.#l)t.traverse(e)}[J](){this.#s.clear(),A(this),this.#h?.();for(let e of this.#i.values())e.cleanup(),e.signal.destroy();this.#i.clear();for(let e of this.#r.values())e.context.set(void 0),e.unsubscribePathValue(),e.unsubscribeFromParent?.(),e.valuePath.dispose(),e.inherited.destroy(),e.provide.destroy(),e.context.destroy();this.#n=void 0,this.#o=void 0,this.#a.clear(),this.#l.length=0}addChild(e){if(this.#l.length===0){this.#a.add(e.uuid),this.#l.push(e);return}if(this.#a.has(e.uuid))throw new Error(`child with uuid: ${e.uuid} already exists! parentUuid: ${this.uuid}`);this.#a.add(e.uuid),this.#l.push(e),this.resortChildren();for(let[,t]of e.#r)e.#v(t)}resortChildren(){this.#l.sort((e,t)=>e.order-t.order)}removeChild(e){this.#a.has(e.uuid)&&(this.#a.delete(e.uuid),this.#l.splice(this.#l.indexOf(e),1))}removeFromParent(){if(this.#o){this.#o.removeChild(this),this.#o=void 0,this.#n=void 0;for(let[,e]of this.#r)e.unsubscribeFromParent&&(e.unsubscribeFromParent(),e.unsubscribeFromParent=void 0);this.#y()}}#u=!1;#h;get autoDestructionOnParentRemoval(){return this.#u}set autoDestructionOnParentRemoval(e){this.#u!==e&&(this.#u=e,this.#p())}#y(){this.#h&&(this.#h(),this.#h=void 0)}#p(){this.#y(),this.#u&&this.#o&&(this.#h=k(this.#o,J,Q.Max,()=>{this.#h=void 0,this.#e.destroyEntity(this.#t)}))}reSubscribeToParentContexts(){for(let[,e]of this.#r)this.#v(e)}dispatchMessageToView(e,t,i,r=!1){this.#e.dispatchMessageToView({uuid:this.#t,type:e,data:t,transferables:i,traverseChildren:r})}dispatchViewEvents(e){for(let{type:t,data:i}of e)y(this,$t,t,i)}dispatchViewEvent(e,t){this.dispatchViewEvents([{type:e,data:t}])}#g(e){return this.#s.get(e)}getPropertyReader(e){return this.#g(e).get}getPropertyWriter(e){return this.#g(e).set}setProperties(e){this.clearTruthyPropsCache(),N(()=>{for(let[t,i]of e)this.setProperty(t,i)})}setProperty(e,t){this.getPropertyWriter(e)(t)}getProperty(e){return xe(this.getPropertyReader(e))}propKeys(){return Array.from(this.#s.keys())}propEntries(){return Array.from(this.#s.entries()).map(([e,t])=>[e,t.value])}#d;clearTruthyPropsCache(){this.#d=void 0}truthyProps(){if(this.#d)return this.#d.size?this.#d:void 0;let e=new Set;for(let[t,i]of this.#s.entries())if(typeof t=="string"){let r=i.value;r!=null&&r!==!1&&r!==""&&e.add(t)}return this.#d=e,e.size?e:void 0}hasContext(e){return this.#r.has(e)}useContext(e){return this.#f(e).context.get}useParentContext(e){return this.#f(e).inherited.get}provideContext(e){return this.#f(e).provide}provideGlobalContext(e){if(this.#i.has(e))return this.#i.get(e).signal;let t=this.#e.findOrCreateRootContext(e),i=p(),r=t.add(i);return this.#i.set(e,{cleanup:r,signal:i}),i}#f(e){if(this.#r.has(e))return this.#r.get(e);let t=p(),i=p(),r=p(),n=new Z([i,t]),o=w(n,Z.Value,f=>{Kr(r,f)}),a={name:e,inherited:t,provide:i,context:r,valuePath:n,unsubscribePathValue:o};return this.#r.set(e,a),this.#v(a),a}#v(e){if(e.unsubscribeFromParent?.(),e.unsubscribeFromParent=void 0,this.parent){let t=this.parent.#f(e.name),i=_(t.context,e.inherited);e.unsubscribeFromParent=i.destroy.bind(i)}else{let t=this.#e.findOrCreateRootContext(e.name),i=_(t.value$,e.inherited);e.unsubscribeFromParent=i.destroy.bind(i)}}};var Ii=s=>{let e=s.split("@").map(t=>t.trim());if(e.length===2&&e[1])return e[0]?{key:`${e[0]}@${e[1]}`,prop:e[1],token:e[0]}:{key:e[1],prop:e[1]}},It=(s,e)=>{for(let t of e)s.add(t)},Yr=(s,e)=>{if(s!=null)for(let t of s.constructors)e.add(t)},ot=class{static get(e){return e??Jr}#e=new Map;#t=new Map;#s=new Map;define(e,t){this.#e.has(e)?mi(this.#e.get(e).constructors,t):this.#e.set(e,{token:e,constructors:[t]})}appendRoute(e,t){let i=Ii(e);i?this.#s.has(i.key)?It(this.#s.get(i.key).routes,t):this.#s.set(i.key,{routes:new Set(t),token:i.token}):this.#t.has(e)?It(this.#t.get(e),t):this.#t.set(e,new Set(t))}clearRoute(e){let t=Ii(e);t?this.#s.delete(t.key):this.#t.delete(e)}findTokensByRoute(e,t){let i=new Set([e]),r=this.#t.has(e)?[...this.#t.get(e)]:[];for(;r.length;){let n=r.shift();i.has(n)||(i.add(n),this.#t.has(n)&&r.push(...Array.from(this.#t.get(n)).filter(o=>!i.has(o))))}if(t){for(let o of t)this.#s.has(o)&&It(i,this.#s.get(o).routes);let n;do{n=i.size;for(let o of new Set(i))for(let a of t){let f=`${o}@${a}`;this.#s.has(f)&&It(i,this.#s.get(f).routes)}}while(n!==i.size)}return i}findConstructors(e,t){let i=this.findTokensByRoute(e,t),r=new Set;for(let n of i)Yr(this.#e.get(n),r);return r.size>0?Array.from(r):void 0}hasToken(e){return this.#e.has(e)}hasRoute(e){return this.#t.has(e)}clear(){this.#e.clear(),this.#t.clear(),this.#s.clear()}},Jr=new ot;var zi=s=>s.displayName||s.name,Bi=!1,Vi=!1,Ui=!1,Gi=!1,qi=!1,zt=class{constructor(e){this.logger=new D("Kernel"),this.#e=new Map,this.#t=new Set,this.#i=!0,this.#n=new Map,O(this),this.registry=ot.get(e)}#e;#t;#s;#r;#i;#n;getEntity(e){let t=this.#e.get(e)?.entity;if(!t)throw new Error(`entity with uuid "${e}" not found!`);return t}hasEntity(e){return this.#e.has(e)}traverseLevelOrderBFS(e=!1){if(this.#i){let t=new Map,i=(r,n)=>{let o=this.getEntity(r);t.has(n)?t.get(n).push(o):t.set(n,[o]);for(let a of o.children)i(a.uuid,n+1)};this.#t.forEach(r=>{i(r,0)}),this.#s=Array.from(t.entries()).sort((r,n)=>r[0]-n[0]).flatMap(([,r])=>r),this.#r=this.#s.slice().reverse(),this.#i=!1}return e?this.#r:this.#s}getEntityGraph(){return Array.from(this.#t).map(e=>this.getEntityGraphNode(e))}getEntityGraphNode(e){if(!this.#e.has(e))return;let{token:t,entity:i}=this.#e.get(e);return{token:t,entity:i,props:Object.fromEntries(i.propEntries()),children:i.children.map(r=>this.getEntityGraphNode(r.uuid))}}upgradeEntities(){let e=new Map;for(let t of this.traverseLevelOrderBFS(!0))e.set(t.uuid,this.updateShadowObjects(t.uuid,2));for(let t of this.traverseLevelOrderBFS(!1))this.updateShadowObjects(t.uuid,1,e.get(t.uuid));e.clear()}run(e){this.logger.isDebug&&this.logger.debug("sync",e),N(()=>{for(let t of e.changeTrail)this.parse(t)})}parse(e){switch(e.type){case E.CreateEntities:this.createEntity(e.uuid,e.token,e.parentUuid,e.order,e.properties,e.autoDestructionOnParentRemoval),this.#i=!0;break;case E.DestroyEntities:this.destroyEntity(e.uuid),this.#i=!0;break;case E.SetParent:this.setParent(e.uuid,e.parentUuid,e.order),this.#i=!0;break;case E.UpdateOrder:this.updateOrder(e.uuid,e.order),this.#i=!0;break;case E.ChangeProperties:this.changeProperties(e.uuid,e.properties);break;case E.ChangeToken:this.changeToken(e.uuid,e.token);break;case E.SendEvents:this.dispatchEventsToEntity(e.uuid,e.events);break}}createEntity(e,t,i,r=0,n,o=!1){let a=new Ft(this,e);a.order=r;let f={token:t,entity:a,usedConstructors:new Map};this.#e.set(e,f),i&&(a.parentUuid=i),a.autoDestructionOnParentRemoval=o,a.hasParent||this.#t.add(e),n&&a.setProperties(n),this.createShadowObjects(e)}destroyEntity(e){if(!this.#e.has(e))return;let{entity:t,usedConstructors:i}=this.#e.get(e),r=[...t.children];for(let n of r)n.autoDestructionOnParentRemoval?this.destroyEntity(n.uuid):(n.removeFromParent(),this.#t.add(n.uuid));t.removeFromParent(),y(t,J,t),i.clear(),this.#e.delete(t.uuid),this.#t.delete(t.uuid),this.#i=!0}setParent(e,t,i=0){let r=this.getEntity(e);if(!(r.parentUuid===t&&r.order===i)){if(t&&!this.#e.has(t))throw new Error(`entity with uuid "${t}" not found!`);r.removeFromParent(),r.order=i,r.parentUuid=t,r.hasParent?this.#t.delete(e):this.#t.add(e),r.reSubscribeToParentContexts(),queueMicrotask(()=>{this.logger.isDebug&&this.logger.debug("entity.onParentChanged",{uuid:e,parentUuid:t,order:i,entity:r}),y(r,Di,r)})}}updateOrder(e,t){this.getEntity(e).order=t}dispatchEventsToEntity(e,t){this.getEntity(e)?.dispatchViewEvents(t)}changeProperties(e,t){this.getEntity(e).setProperties(t),this.updateShadowObjects(e)}changeToken(e,t){if(!this.#e.has(e))return;let i=this.#e.get(e);i.token!==t&&(i.token=t,this.updateShadowObjects(e))}dispatchMessageToView(e){queueMicrotask(()=>{y(this,Me,e)})}updateShadowObjects(e,t=0,i){let r=this.#e.get(e);i??=new Set(this.registry.findConstructors(r.token,r.entity.truthyProps()));let n=t===0||t===2,o=t===0||t===1;if(n){for(let[a,f]of r.usedConstructors)if(!i.has(a)){r.usedConstructors.delete(a);for(let m of f)this.destroyShadowObject(m,r.entity)}}if(o)for(let a of i)r.usedConstructors.has(a)||this.constructShadowObject(a,r);return i}constructShadowObject(e,t){let i=new Set,r=new Set,n=new Map,o=new Map,a=new Map,f=new Map,m=new Map,P=new Map,c=new Map,j=new Map,C=(l,h)=>{!qi&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useProperty()" is now passed as {compare} argument. Please update your code accordingly.'),qi=!0);let d=typeof h=="function"?{compare:h}:h,u=c.get(l);if(u===void 0){u=p(void 0,d).get,c.set(l,u),j.set(l,d?.compare);let g=_(t.entity.getPropertyReader(l),u);r.add(g.destroy.bind(g))}else d?.compare!=null&&j.get(l)!==d.compare&&console.warn(`[shadow-objects] useProperty("${l}"): the cached signal already exists with a different (or no) {compare} function \u2014 the new options are ignored. Pass options only on the first call per property.`);return u},M=O(new e({entity:t.entity,provideContext(l,h,d){!Bi&&d!=null&&typeof d=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideContext()" is now passed as {compare} argument. Please update your code accordingly.'),Bi=!0);let u=typeof d=="function"?{compare:d}:d,g=m.get(l);if(g==null){let v=Ce(h),B=v?void 0:_t(h);if(g=p(B,u?.compare?{compare:u.compare}:void 0),v){let $e=_(h,g);r.add($e.destroy.bind($e))}let _e=_(g,t.entity.provideContext(l));r.add(_e.destroy.bind(_e)),m.set(l,g)}return g!=null&&(u?.clearOnDestroy??!0)&&r.add(()=>{g.set(void 0)}),g},provideGlobalContext(l,h,d){!Vi&&d!=null&&typeof d=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideGlobalContext()" is now passed as {compare} argument. Please update your code accordingly.'),Vi=!0);let u=typeof d=="function"?{compare:d}:d,g=P.get(l);if(g==null){let v=Ce(h),B=v?void 0:_t(h);if(g=p(B,u?.compare?{compare:u.compare}:void 0),v){let $e=_(h,g);r.add($e.destroy.bind($e))}let _e=_(g,t.entity.provideGlobalContext(l));r.add(_e.destroy.bind(_e)),P.set(l,g)}return g!=null&&(u?.clearOnDestroy??!0)&&r.add(()=>{g.set(void 0)}),g},useContext(l,h){!Ui&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useContext()" is now passed as {compare} argument. Please update your code accordingly.'),Ui=!0);let d=typeof h=="function"?{compare:h}:h,u=n.get(l);if(u===void 0){u=p(void 0,d).get,n.set(l,u),o.set(l,d?.compare);let g=_(t.entity.useContext(l),u);r.add(g.destroy.bind(g))}else d?.compare!=null&&o.get(l)!==d.compare&&console.warn(`[shadow-objects] useContext("${String(l)}"): the cached signal already exists with a different (or no) {compare} function \u2014 the new options are ignored. Pass options only on the first call per context.`);return u},useParentContext(l,h){!Gi&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useParentContext()" is now passed as {compare} argument. Please update your code accordingly.'),Gi=!0);let d=typeof h=="function"?{compare:h}:h,u=a.get(l);if(u===void 0){u=p(void 0,d).get,a.set(l,u),f.set(l,d?.compare);let g=_(t.entity.useParentContext(l),u);r.add(g.destroy.bind(g))}else d?.compare!=null&&f.get(l)!==d.compare&&console.warn(`[shadow-objects] useParentContext("${String(l)}"): the cached signal already exists with a different (or no) {compare} function \u2014 the new options are ignored. Pass options only on the first call per parent context.`);return u},dispatchMessageToView(l,h,d,u=!1){t.entity.dispatchMessageToView(l,h,d,u)},useProperty:C,useProperties(l){let h={};for(let d in l)Object.hasOwn(l,d)&&(h[d]=C(l[d]));return h},createResource(l,h){let d=p(),u=S(()=>{let g=_t(l());return d.set(g),g!==void 0&&h?()=>{h(g),d.set(void 0)}:()=>{d.set(void 0)}});return r.add(()=>{u.destroy(),d.set(void 0),L(d)}),d},createEffect(...l){let h=S(...l);return r.add(h.destroy),h},createSignal(...l){let h=p(...l);return r.add(()=>{L(h)}),h},createMemo(...l){let h=St(...l);return r.add(()=>{L(h)}),h},on(...l){let[h]=l;if(typeof h=="string"||typeof h=="symbol"||Array.isArray(h)){let u=w(t.entity,...l);return r.add(u),u}let d=w(...l);return r.add(d),Object.assign(()=>{r.delete(d),d()},d)},once(...l){let[h]=l;if(typeof h=="string"||typeof h=="symbol"||Array.isArray(h)){let u=k(t.entity,...l);return r.add(u),u}let d=k(...l);return r.add(d),Object.assign(()=>{r.delete(d),d()},d)},emit(...l){let[h]=l;typeof h=="string"||typeof h=="symbol"||Array.isArray(h)?y(t.entity,...l):y(...l)},onViewEvent(l){let h=w(t.entity,$t,(d,u)=>{l(d,u)});r.add(h)},onDestroy(l){i.add(l)}}));return this.logger.isInfo&&this.logger.info("create shadow-object",zi(e),{shadowObject:M,entity:t.entity}),k(t.entity,J,Q.Low,()=>{this.logger.isInfo&&this.logger.info("destroy shadow-object",zi(e),{shadowObject:M,entity:t.entity});for(let h of i)h();for(let h of r)h();for(let h of n.values())L(h);for(let h of a.values())L(h);for(let h of c.values())L(h);for(let h of m.values())L(h);for(let h of P.values())L(h);i.clear(),r.clear(),n.clear(),a.clear(),c.clear(),m.clear(),P.clear();let l=t.usedConstructors.get(e);l&&(l.delete(M),l.size===0&&t.usedConstructors.delete(e))}),t.usedConstructors.has(e)?t.usedConstructors.get(e).add(M):t.usedConstructors.set(e,new Set([M])),this.attachShadowObject(M,t.entity),M}createShadowObjects(e){let t=this.#e.get(e);this.registry.findConstructors(t.token,t.entity.truthyProps())?.forEach(i=>{this.constructShadowObject(i,t)})}findShadowObjects(e){if(!this.#e.has(e))return[];let{usedConstructors:t}=this.#e.get(e);return Array.from(new Set(Array.from(t.values()).flatMap(i=>Array.from(i))))}attachShadowObject(e,t){w(t,e),typeof e[As]=="function"&&e[As](t)}destroyShadowObject(e,t){typeof e[J]=="function"&&e[J](t),y(e,J,t),A(t,e)}findOrCreateRootContext(e){let t=this.#n.get(e);return t||(t=new Z,this.#n.set(e,t)),t}destroy(){for(let e of this.#n.values())e.dispose();this.#n.clear();for(let e of this.traverseLevelOrderBFS().reverse())this.destroyEntity(e.uuid)}};var Bt=s=>(typeof s=="string"&&(s=new URL(s,globalThis.location.href)),s.toString());function Hi(s){return s.map(e=>{if(e.transferables&&e.transferables.length>0){let{transferables:t,...i}=e;return structuredClone(i,{transfer:t})}else return structuredClone(e)})}var Vt=class{constructor(e){this.#e=new Set,this.isLocalEnv=!0,this.disableStructuredClone=!1,this.kernel=new zt(e),w(this.kernel,Me,t=>{if(this.onMessageToView!=null){let{type:i,uuid:r,traverseChildren:n}=t,o=structuredClone(t.data,{transfer:t.transferables});this.onMessageToView({type:i,uuid:r,data:o,traverseChildren:n})}})}#e;get registry(){return this.kernel.registry}start(){return Promise.resolve()}applyChangeTrail(e,t){let i={changeTrail:this.disableStructuredClone?e:Hi(e)},r;try{this.kernel.run(i),r=Promise.resolve()}catch(n){r=Promise.reject(n)}return r}async importScript(e){let t=await import(Bt(e));t[cs]&&await this.importModule(t[cs])}async importModule(e){return ks(this.kernel,e,this.#e)}destroy(){this.kernel.destroy(),this.registry.clear(),this.#e.clear()}};function Rs(s){let e=new Blob([s],{type:"text/javascript"}),t=URL.createObjectURL(e),i=new Worker(t);return URL.revokeObjectURL(t),i}function Ls(){return Rs(`var _i=Object.defineProperty;var xt=Object.getOwnPropertySymbols;var Fs=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable;var Vi=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),$s=s=>{throw TypeError(s)};var ts=(s,e,t)=>e in s?_i(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ss=(s,e)=>{for(var t in e||(e={}))Fs.call(e,t)&&ts(s,t,e[t]);if(xt)for(var t of xt(e))Gs.call(e,t)&&ts(s,t,e[t]);return s};var Ns=(s,e)=>{var t={};for(var i in s)Fs.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&xt)for(var i of xt(s))e.indexOf(i)<0&&Gs.call(s,i)&&(t[i]=s[i]);return t};var y=(s,e,t)=>ts(s,typeof e!="symbol"?e+"":e,t),is=(s,e,t)=>e.has(s)||$s("Cannot "+t);var n=(s,e,t)=>(is(s,e,"read from private field"),t?t.call(s):e.get(s)),d=(s,e,t)=>e.has(s)?$s("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),g=(s,e,t,i)=>(is(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),C=(s,e,t)=>(is(s,e,"access private method"),t);var Mt=(s,e,t,i)=>({set _(r){g(s,e,r,t)},get _(){return n(s,e,i)}});var rs=function(s,e){this[0]=s,this[1]=e},Us=(s,e,t)=>{var i=(c,p,w,A)=>{try{var v=t[c](p),G=(p=v.value)instanceof rs,R=v.done;Promise.resolve(G?p[0]:p).then(S=>G?i(c==="return"?c:"next",p[1]?{done:S.done,value:S.value}:S,w,A):w({value:S,done:R})).catch(S=>i("throw",S,w,A))}catch(S){A(S)}},r=(c,p,w,A)=>a[c]=v=>(p=new Promise((G,R,S)=>(S=()=>i(c,v,G,R),o?o.then(S):S())),A=()=>o===w&&(o=0),o=w=p.then(A,A),p),o,a={};return t=t.apply(s,e),a[Vi("asyncIterator")]=()=>a,r("next"),r("throw"),r("return"),a};var le=(s=>(s[s.CreateEntities=1]="CreateEntities",s[s.DestroyEntities=2]="DestroyEntities",s[s.SetParent=3]="SetParent",s[s.UpdateOrder=4]="UpdateOrder",s[s.ChangeProperties=5]="ChangeProperties",s[s.ChangeToken=6]="ChangeToken",s[s.SendEvents=7]="SendEvents",s))(le||{});var js="configure",_s="changeTrail",Vs="destroy",Is="loaded",ns="appliedChangeTrail",Lt="importedModule",Ws="destroyed",ht="messageToView";var Rt="shadowObjects";var $="ConsoleLogger",z=\`\${$}Storage\`,Hs,Ks,Js,Ii=!!((Js=(Ks=(Hs=globalThis.location)==null?void 0:Hs.host)==null?void 0:Ks.startsWith("localhost"))!=null&&Js),ft="localStorage"in globalThis,Tt=Symbol.for($),Qs=!1,qs=s=>{if(typeof s=="boolean")return s;switch(s.toLowerCase()){case"true":case"yes":case"on":return!0;default:return!1}},as=s=>[ft?$:void 0,...Array.isArray(s)?s:[s]].filter(Boolean).join(".");function os(s,e=void 0,t){var o;let i=as(s),r=ft?localStorage.getItem(i):(o=globalThis[z])==null?void 0:o[i];return r!=null?e(r):t}function lt(s,e){ft?localStorage.setItem(as(s),e):(globalThis[z]==null&&(globalThis[z]={},console.debug(\`\${$}: Initialize\`,{[z]:globalThis[z]})),globalThis[z][as(s)]=e)}var ze,ut,m=class m{constructor(e){d(this,ze);this.enable=!0,this.namespace=(e||"").trim()||$,Qs||(m.loadConfig(),Qs=!0);let t=[this.namespace,"enable"];this.enable=os(t,qs,this.enable),lt(t,ft?this.enable?"true":"false":this.enable)}static get isEnabled(){return m.sharedConfig.enable}static get isDebug(){return m.sharedConfig.enable&&m.sharedConfig.debug}static loadConfig(){var e,t,i;ft?(["enable","debug","info","warn"].forEach(r=>{this.sharedConfig[r]=os(r,qs,this.sharedConfig[r])}),["debug","info","warn","error"].forEach(r=>{this.sharedStyles[r]=os(["styles",r],void 0,this.sharedStyles[r])}),m.isDebug&&console.debug(\`\${$}: Load config from localStorage\`,m.sharedConfig),(e=globalThis[$])!=null&&e[Tt]||(t=globalThis[$])!=null||(globalThis[$]={[Tt]:!0,get enable(){return m.sharedConfig.enable},set enable(r){m.sharedConfig.enable=r,lt("enable",r?"true":"false")},get debug(){return m.sharedConfig.debug},set debug(r){m.sharedConfig.debug=r,lt("debug",r?"true":"false")},get info(){return m.sharedConfig.info},set info(r){m.sharedConfig.info=r,lt("info",r?"true":"false")},get warn(){return m.sharedConfig.warn},set warn(r){m.sharedConfig.warn=r,lt("warn",r?"true":"false")}})):(i=globalThis[z])!=null&&i[Tt]||(globalThis[z]=ss(ss({[Tt]:!0},m.sharedConfig),globalThis[z]),m.sharedConfig=globalThis[z],m.isDebug&&console.debug(\`\${$}: Load config from \${z}\`,globalThis[z]))}get isEnabled(){return this.enable&&m.sharedConfig.enable}get isDebug(){return this.isEnabled&&m.sharedConfig.debug}get isInfo(){return this.isEnabled&&m.sharedConfig.info}get isWarn(){return this.isEnabled&&m.sharedConfig.warn}debug(...e){C(this,ze,ut).call(this,"debug",m.sharedStyles.debug,e)}info(...e){C(this,ze,ut).call(this,"info",m.sharedStyles.info,e)}warn(...e){C(this,ze,ut).call(this,"warn",m.sharedStyles.warn,e)}error(...e){C(this,ze,ut).call(this,"error",m.sharedStyles.error,e)}};ze=new WeakSet,ut=function(e,t,i){console[e](\`%c\${this.namespace}\`,t,...i)},m.sharedConfig={enable:Ii,debug:!1,info:!0,warn:!0,"styles.debug":"color: #111; background: #999; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.info":"color: #020; background: #8a8; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.warn":"color: #fa0; background: #a98; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.error":"color: #ff0; background: #a00; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em"},m.sharedStyles={get debug(){return m.sharedConfig["styles.debug"]},set debug(e){m.sharedConfig["styles.debug"]=e},get info(){return m.sharedConfig["styles.info"]},set info(e){m.sharedConfig["styles.info"]=e},get warn(){return m.sharedConfig["styles.warn"]},set warn(e){m.sharedConfig["styles.warn"]=e},get error(){return m.sharedConfig["styles.error"]},set error(e){m.sharedConfig["styles.error"]=e}};var Dt=m;var Fe="*",si=1,fs=2,ds=4,ue=Symbol.for("eventize"),Wi="[eventize]",gs=s=>s===Fe,ii=s=>{switch(typeof s){case"string":case"symbol":return!0;default:return!1}},ri=typeof console!="undefined",Qi=ri?console[console.warn?"warn":"log"].bind(console,Wi):()=>{},qi=(s,e,t)=>(Object.defineProperty(s,e,{value:t,configurable:!0}),s),Hi=0,ys=class{constructor(){y(this,"events",new Map);y(this,"eventNames",new Set)}static publish(s){s.sort((e,t)=>e.order-t.order).forEach(e=>e.replay())}add(s){Array.isArray(s)?s.forEach(e=>this.eventNames.add(e)):this.eventNames.add(s)}remove(s){Array.isArray(s)?s.forEach(e=>this.eventNames.delete(e)):this.eventNames.delete(s),this.clear(s)}clear(s){Array.isArray(s)?s.forEach(e=>this.events.delete(e)):this.events.delete(s)}retain(s,e){this.eventNames.has(s)&&this.events.set(s,{args:e,order:Hi++})}isKnown(s){return this.eventNames.has(s)}replayTo(s,e,t=[]){if(gs(s))this.eventNames.forEach(i=>this.replayTo(i,e,t));else if(this.events.has(s)){let{order:i,args:r}=this.events.get(s);t.push({order:i,replay:()=>e.apply(s,r)})}return t}},ls=(s,e,t,i)=>{if(typeof e=="function"){let r=e.apply(s,t);r!=null&&(i==null||i(r))}},Ki=(s,e,t,i)=>ls(e,e.emit,[s].concat(t),i),Ji=s=>{switch(typeof s){case"function":return si;case"string":case"symbol":return fs;case"object":return ds}},Yi=0,Xi=()=>++Yi,ni=class{constructor(s,e,t,i=null){y(this,"id");y(this,"eventName");y(this,"isCatchEmAll");y(this,"priority");y(this,"listener");y(this,"listenerObject");y(this,"listenerType");y(this,"callAfterApply");y(this,"isRemoved");y(this,"refCount");this.id=Xi(),this.eventName=s,this.isCatchEmAll=gs(s),this.listener=t,this.listenerObject=i,this.priority=e,this.listenerType=Ji(t),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(s,e=null){if(s===this)return!0;let t=typeof s;return t==="number"&&s===this.id?!0:e===null&&(t==="string"||t==="symbol")?s===Fe||s===this.eventName:this.listener===s&&this.listenerObject===e}apply(s,e,t){if(this.isRemoved)return;let{listener:i,listenerObject:r}=this;switch(this.listenerType){case si:ls(r,i,e,t),this.callAfterApply&&this.callAfterApply();break;case fs:ls(r,r[i],e,t),this.callAfterApply&&this.callAfterApply();break;case ds:{let o=i[s];if(this.isCatchEmAll||this.eventName===s){if(typeof o=="function"){let a=o.apply(i,e);a!=null&&(t==null||t(a))}else Ki(s,i,e,t);this.callAfterApply&&this.callAfterApply()}break}}}},Zi=(s,e)=>s.priority!==e.priority?e.priority-s.priority:s.id-e.id,er=(s,e)=>{let t=0,i=s.length;for(;t<i;){let r=t+i>>>1;Zi(e,s[r])<0?i=r:t=r+1}return t},Ys=s=>s==null?void 0:s.slice(0),Xs=(s,e)=>{let t=s.indexOf(e);t>-1&&s.splice(t,1)},tr=s=>s===ds||s===fs,us=(s,e,t)=>{let i=s.findIndex(r=>r.isEqual(e,t));i>-1&&(s[i].isRemoved=!0,s.splice(i,1))},cs=(s,e,t)=>{let i=[];for(let r of s)(e==null&&r.listenerObject===t||r.eventName===e&&r.listener===t)&&i.push(r);for(let r of i)us(s,r,void 0)},hs=s=>{s&&(s.forEach(e=>{e.isRemoved=!0}),s.length=0)},sr=(s,e)=>s.listenerType===e.listenerType?s.priority===e.priority&&s.eventName===e.eventName&&s.listenerObject===e.listenerObject&&s.listener===e.listener:!1,ir=(s,e)=>{if(tr(s.listenerType))return e.find(t=>sr(s,t))},rr=(s,e)=>{let t=ir(s,e);return t?(t.refCount+=1,t):(e.splice(er(e,s),0,s),s)},nr=class{constructor(){y(this,"namedListeners");y(this,"catchEmAllListeners");y(this,"getListenersForEventName",s=>{let e=this.namedListeners.get(s);return e||(e=[],this.namedListeners.set(s,e)),e});this.namedListeners=new Map,this.catchEmAllListeners=[]}add(s){return rr(s,s.isCatchEmAll?this.catchEmAllListeners:this.getListenersForEventName(s.eventName))}remove(s,e,t=!1){if(e==null&&Array.isArray(s)){s.forEach(i=>this.remove(i,null,t));return}if(s==null||e==null&&gs(s)){this.removeAllListeners();return}if(e==null&&ii(s)){this.removeByEventName(s);return}if(s instanceof ni){this.removeByEventListener(s);return}if(t){this.removeByEventNameAndListenerObject(s,e);return}this.removeByListener(s,e)}removeByEventName(s){hs(this.namedListeners.get(s)),this.namedListeners.delete(s)}removeByEventListener(s){s.isRemoved||(s.refCount-=1,!(s.refCount>=1)&&(s.isRemoved=!0,this.namedListeners.forEach((e,t)=>{Xs(e,s),e.length===0&&this.namedListeners.delete(t)}),Xs(this.catchEmAllListeners,s)))}removeByEventNameAndListenerObject(s,e){this.namedListeners.forEach((t,i)=>{cs(t,s,e),t.length===0&&this.namedListeners.delete(i)})}removeByListener(s,e){let t=typeof s=="object";this.namedListeners.forEach((i,r)=>{us(i,s,e),t&&cs(i,void 0,s),i.length===0&&this.namedListeners.delete(r)}),us(this.catchEmAllListeners,s,e),t&&cs(this.catchEmAllListeners,void 0,s)}removeAllListeners(){this.namedListeners.forEach(s=>hs(s)),this.namedListeners.clear(),hs(this.catchEmAllListeners)}forEach(s,e){let t=Ys(this.catchEmAllListeners),i=Ys(this.namedListeners.get(s));if(s===Fe||!i||i.length===0)t.forEach(e);else if(t.length===0)i.forEach(e);else{let r=i.length,o=t.length,a=0,c=0;for(;a<r||c<o;){if(a<r){let p=i[a];if(c>=o||p.priority>=t[c].priority){e(p),++a;continue}}c<o&&(e(t[c]),++c)}}}getSubscriptionCount(){let s=this.catchEmAllListeners.length;for(let e of this.namedListeners.values())s+=e.length;return s}},Ge=s=>!!(s&&s[ue]);function dt(s){if(Ge(s))return s;let e=new nr,t=new ys;return qi(s,ue,{keeper:t,store:e}),s}var be={Max:Number.POSITIVE_INFINITY,Critical:1e9,High:1e6,Normal:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0},or=(s,e,t,i,r,o,a)=>{let c=s.add(new ni(t,i,r,o));return e.replayTo(t,c,a),c},oi=(s,e,t,i)=>{let r=t.length,o=typeof t[0],a,c,p,w;if(r>=2&&r<=3&&o==="number"?(a=Fe,[c,p,w]=t):r>=3&&r<=4&&typeof t[1]=="number"?[a,c,p,w]=t:(c=be.Default,o==="string"||o==="symbol"||Array.isArray(t[0])?[a,p,w]=t:(a=Fe,[p,w]=t)),!p)throw ri&&Qi("called with insufficient arguments!",t),new Error("subscribeTo() called with insufficient arguments");let A=v=>G=>or(s,e,G,v,p,w,i);return Array.isArray(a)?a.map(v=>Array.isArray(v)?A(v[1])(v[0]):A(c)(v)):A(c)(a)},ar=(s,e,t)=>{let i=[],r=oi(s,e,t,i);return ys.publish(i),r},cr=(s,e,t)=>{let i=[];return{listeners:oi(s,e,t,i),publishRetained:()=>ys.publish(i)}},Zs=s=>e=>{e.callAfterApply=()=>{s==null||s()}},ai=(s,e)=>Object.assign(()=>L(s,e),Array.isArray(e)?{listeners:e}:{listener:e}),ei=(s,e,t,i)=>{if(e===Fe)throw new Error("emit() must be called with a concrete event name \\u2014 '*' is reserved for subscribing to all events and cannot be emitted");let{store:r,keeper:o}=s[ue];r.forEach(e,a=>a.apply(e,t,i)),o.retain(e,t)},ci=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>ei(s,r,t,i)):ei(s,e,t,i)},ti=(s,e,t,i)=>{if(e===Fe)throw new Error("emit() must be called with a concrete event name \\u2014 '*' is reserved for subscribing to all events and cannot be emitted");let r=s,o=r[e];if(typeof o=="function"){let c=o.apply(s,t);c!=null&&(i==null||i(c));return}let a=r.emit;if(typeof a=="function"){let c=a.apply(s,[e,...t]);c!=null&&(i==null||i(c))}},hi=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>ti(s,r,t,i)):ti(s,e,t,i)},li=s=>s!=null&&typeof s=="object";function T(s,...e){let t=dt(s),{store:i,keeper:r}=t[ue];return ai(t,ar(i,r,e))}function k(s,...e){let t=dt(s),{store:i,keeper:r}=t[ue],{listeners:o,publishRetained:a}=cr(i,r,e),c=ai(t,o),p=!1,w=()=>{p||(c(),p=!0)};return Array.isArray(o)?o.forEach(Zs(w)):Zs(w)(o),a(),w}function hr(s,e){return new Promise(t=>{k(s,e,t)})}function L(s,e,t){if(!Ge(s))return;let{store:i,keeper:r}=s[ue],o=typeof e,a=t!=null&&(o==="string"||o==="symbol");i.remove(e,t,a),Array.isArray(e)?r.remove(e.filter(c=>typeof c=="string")):ii(e)&&r.remove(e)}function E(s,e,...t){Ge(s)?ci(s,e,t):li(s)&&hi(s,e,t)}function lr(s,e,...t){let i=[],r=o=>{i.push(o)};return Ge(s)?ci(s,e,t,r):li(s)&&hi(s,e,t,r),i=i.map(o=>Array.isArray(o)?Promise.all(o):Promise.resolve(o)),i.length>0?Promise.all(i):Promise.resolve()}function gt(s,e){let t=dt(s),{keeper:i}=t[ue];i.add(e)}function He(s,e){if(!Ge(s))throw new Error("object is not eventized");let{keeper:t}=s[ue];t.clear(e)}function ur(s,e){if(!Ge(s))throw new Error("object is not eventized");let{keeper:t}=s[ue];t.remove(e)}var fr=T,dr=k,gr=L,yr=E,pr=lr,vr=hr,mr=gt,br=He,wr=ur,V=(()=>{let s=(e={})=>dt(e);return s.inject=(e={})=>(e=dt(e),Object.assign(e,{on:(...t)=>fr(e,...t),once:(...t)=>dr(e,...t),onceAsync:t=>vr(e,t),off:(t,i)=>gr(e,t,i),emit:(t,...i)=>yr(e,t,...i),emitAsync:(t,...i)=>pr(e,t,...i),retain:t=>mr(e,t),retainClear:t=>br(e,t),unretain:t=>wr(e,t)}),e),s.is=Ge,s})();async function ps(s,e,t,i=!0){var o,a;if(t.has(e)){console.warn("importModule: skipping already imported module",e);return}else t.add(e);e.extends&&await Promise.all(e.extends.map(c=>ps(s,c,t,!1)));let{registry:r}=s;if(e.define)for(let[c,p]of Object.entries(e.define))r.define(c,p);if(e.routes)for(let[c,p]of Object.entries(e.routes))r.appendRoute(c,p);await((a=(o=e.initialize)==null?void 0:o.call(e,{define:(c,p)=>r.define(c,p),kernel:s,registry:r}))!=null?a:Promise.resolve()),i&&s.upgradeEntities()}var ne=Symbol.for("signal"),Ke=Symbol.for("effect"),ui=Symbol.for("destroySignal"),fi=Symbol.for("createEffect"),Er=Symbol.for("destroyEffect"),et="value",ws="mute",Es="unmute",ke="destroy",yt=Symbol.for("recall"),pt=V(),Ie=V(),$e=V(),vi=V(),Ae=class{constructor(){y(this,"delayedEffects",[])}batch(e,t){let i=this.delayedEffects.length;for(let r=0;r<i;r++){let[o,a]=this.delayedEffects[r];if(!(o>t)){if(o===t){a.add(e);return}this.delayedEffects.splice(r,0,[t,new Set([e])]);return}}this.delayedEffects.push([t,new Set([e])])}flush(){this.run(),this.delayedEffects.length=0}run(){let e=new Set,t=[];try{t.push(T($e,(i,r)=>{r===yt&&e.add(i)}),T(vi,i=>{e.add(i)}));for(let[,i]of this.delayedEffects)for(let r of i)e.has(r)||E($e,r,r,yt)}finally{for(let i of t)i()}}};y(Ae,"current");var mi=()=>Ae.current;function Pe(s){let e=Ae.current;e?e=void 0:e=Ae.current=new Ae;try{s()}finally{e&&(Ae.current=void 0,e.run())}}var Sr=0;function Ss(){return Sr>0}var yi;yi=Ke;var zt=class{constructor(e){y(this,yi);y(this,"run",()=>{var e;return(e=this[Ke])==null?void 0:e.run()});y(this,"destroy",()=>{var e;(e=this[Ke])==null||e.destroy(),this[Ke]=void 0});this[Ke]=e,k(e,ke,()=>{this[Ke]=void 0})}},vs=[],bi=()=>vs.at(-1),Cr=(s,e)=>{vs.push(s);try{return e()}finally{vs.pop()}};var Je=new WeakMap,Bt=new Set,se,Ne,H,fe,ie,Ue,je,K,_e,Ye=class Ye{constructor(e){d(this,se,new Set);d(this,Ne,new Set);d(this,H,new Map);d(this,fe,new WeakMap);d(this,ie,new Map);d(this,Ue,new Set);d(this,je,new Set);d(this,K);d(this,_e);if(e!=null&&e instanceof Ye)return e;if(e!=null||(e=this),Je.has(e))return Je.get(e);g(this,_e,new WeakRef(e)),Je.set(e,this),Bt.add(this),V(this)}static get(e){if(e!=null)return e instanceof Ye?e:Je.get(e)}static findOrCreate(e){if(e==null)throw new Error("Cannot create a group with a null object");return new Ye(e)}static destroy(e){console.warn("SignalGroup.destroy(obj) is deprecated. Use SignalGroup.delete(obj) instead."),Ye.delete(e)}static delete(e){var t;(t=Je.get(e))==null||t.clear()}static clear(){for(let e of[...Bt])e.clear();Bt.clear()}attachGroup(e){if(e===this)throw new Error("Cannot attach a group to itself");return n(this,se).add(e),n(e,K)&&n(e,K)!==this&&n(n(e,K),se).delete(e),g(e,K,this),e}detachGroup(e){return e!==this&&n(this,se).has(e)&&(n(this,se).delete(e),g(e,K,void 0)),e}attachSignal(e){let t=D(e);if(t!=null&&t.destroyed)throw new Error("Cannot attach a destroyed signal to a group");return t&&n(this,Ne).add(t),e}attachSignalByName(e,t){if(t){this.attachSignal(t);let i=D(t);n(this,H).set(e,i),n(this,ie).has(e)?n(this,ie).get(e).push(i):n(this,ie).set(e,[i]),n(this,fe).has(i)?n(this,fe).get(i).add(e):n(this,fe).set(i,new Set([e]))}else n(this,H).delete(e);return t}hasSignal(e){var t;return n(this,H).has(e)||!!((t=n(this,K))!=null&&t.hasSignal(e))}signal(e){var t,i,r;return(r=(t=n(this,H).get(e))==null?void 0:t.object)!=null?r:(i=n(this,K))==null?void 0:i.signal(e)}detachSignal(e){let t=D(e);if(t&&(n(this,Ne).delete(t),n(this,fe).has(t))){let i=n(this,fe).get(t);for(let r of i)if(n(this,ie).has(r)){let o=n(this,ie).get(r);o.splice(o.indexOf(t),1),o.length===0?(n(this,H).delete(r),n(this,ie).delete(r)):n(this,H).get(r)===t&&n(this,H).set(r,o.at(-1))}i.clear(),n(this,fe).delete(t)}return e}attachEffect(e){return n(this,Ue).add(e),e}runEffects(){for(let e of n(this,Ue))e.run();for(let e of n(this,se))e.runEffects()}attachLink(e){if(e!=null&&e.isDestroyed)throw new Error("Cannot attach a destroyed link to a group");return e&&n(this,je).add(e),e}detachLink(e){return e&&n(this,je).delete(e),e}destroy(){console.warn("SignalGroup#destroy is deprecated. Use SignalGroup#clear instead."),this.clear()}clear(){var e;E(this,ke,this),L(this);for(let t of n(this,se))t.clear();for(let t of n(this,Ue))t.destroy();for(let t of n(this,Ne))N(t);for(let t of n(this,je))t.destroy();if(n(this,se).clear(),n(this,Ne).clear(),n(this,H).clear(),n(this,ie).clear(),n(this,Ue).clear(),n(this,je).clear(),(e=n(this,K))==null||e.detachGroup(this),n(this,_e)){let t=n(this,_e).deref();t!==void 0&&Je.delete(t),g(this,_e,void 0)}Bt.delete(this)}};se=new WeakMap,Ne=new WeakMap,H=new WeakMap,fe=new WeakMap,ie=new WeakMap,Ue=new WeakMap,je=new WeakMap,K=new WeakMap,_e=new WeakMap;var de=Ye,mt,bt,Ft=class{constructor(e="id",t=1){d(this,mt);d(this,bt);g(this,mt,e),g(this,bt,t)}make(){return Symbol(\`\${n(this,mt)}\${Mt(this,bt)._++}\`)}};mt=new WeakMap,bt=new WeakMap;var Ar=s=>s!=null&&typeof s.then=="function",we,re,Ee,Se,Ce,Ve,Xe,Ze,I=class I{constructor(e,t){y(this,"id");y(this,"callback");d(this,we);d(this,re,new Set);d(this,Ee,new Set);d(this,Se,new Map);d(this,Ce,new Set);y(this,"childEffects",[]);y(this,"curChildEffectSlot",0);y(this,"autorun",!0);y(this,"shouldRun",!0);y(this,"priority");d(this,Ve);d(this,Xe,!1);d(this,Ze,0);y(this,"run",()=>{if(n(this,Xe)||!this.shouldRun)return;let e=mi();if(e){e.batch(this.id,this.priority);return}if(n(this,Ze)>=I.maxDepth)throw new Error(\`[signalize] Effect \${this.id.toString()} exceeded maxDepth=\${I.maxDepth}: an effect callback recursively re-triggered itself (likely by writing a signal it depends on). Break the cycle, or raise EffectImpl.maxDepth if the recursion is intentional.\`);Mt(this,Ze)._++;try{if(this.runCleanupCallback(),this.destroyChildEffects(),this.curChildEffectSlot=0,this.shouldRun=!1,E(vi,this.id,this.id),this.hasStaticDeps())g(this,we,this.callback());else{n(this,Ee).clear();for(let t of n(this,re))n(this,Ee).add(t);g(this,we,Cr(this,this.callback)),this.cleanupLostSignals(),n(this,Ce).clear()}}finally{Mt(this,Ze)._--}});y(this,"destroy",()=>{n(this,Xe)||(E(this,ke,this),L(this),E($e,Er,this),this.runCleanupCallback(),this.destroyChildEffects(),L(pt,this),L($e,this),L(Ie,this),g(this,Xe,!0),n(this,re).clear(),n(this,Ee).clear(),n(this,Se).clear(),n(this,Ce).clear(),--I.count)});var r,o;V(this),this.callback=e;let i;(t==null?void 0:t.attach)!=null&&(i=de.findOrCreate(t.attach),i.attachEffect(this)),this.autorun=(r=t==null?void 0:t.autorun)!=null?r:!0,g(this,Ve,t!=null&&t.dependencies?t.dependencies.map(a=>{switch(typeof a){case"string":case"symbol":return i.signal(a);default:return a}}):void 0),this.id=I.idGen.make(),this.priority=(o=t==null?void 0:t.priority)!=null?o:0,T($e,this.id,yt,this),++I.count}hasStaticDeps(){return n(this,Ve)!=null&&n(this,Ve).length>0}saveSignalsFromDeps(){for(let e of n(this,Ve))this.whenSignalIsRead(D(e).id)}static createEffect(e,t,i){let r=Array.isArray(t)?t:void 0,o=r?i!=null?i:{dependencies:r}:t;o&&r&&(o.dependencies=r);let a,c=bi();return c!=null?(a=c.getCurrentChildEffect(),a==null&&(a=new I(e,o),c.attachChildEffect(a),E($e,fi,a)),c.curChildEffectSlot++):(a=new I(e,o),E($e,fi,a)),a.hasStaticDeps()?a.saveSignalsFromDeps():a.autorun&&a.run(),new zt(a)}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(e){this.childEffects.push(e)}[yt](){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(e){n(this,Ee).delete(e),n(this,re).has(e)||(n(this,re).add(e),n(this,Se).set(e,[T(pt,e,this.priority,yt,this),k(Ie,e,ui,this)]))}[ui](e){!n(this,Ce).has(e)&&n(this,re).has(e)&&(n(this,Ce).add(e),this.unsubscribeSignal(e),n(this,Ce).size===n(this,re).size&&this.destroy())}cleanupLostSignals(){for(let e of n(this,Ee))this.unsubscribeSignal(e),n(this,re).delete(e)}destroyChildEffects(){for(let e of this.childEffects)e.destroy();this.childEffects.length=0}unsubscribeSignal(e){n(this,Se).has(e)&&(n(this,Se).get(e).forEach(t=>{t()}),n(this,Se).delete(e))}runCleanupCallback(){if(n(this,we)!=null){let e=n(this,we);g(this,we,void 0),Ar(e)?Promise.resolve(e).then(t=>{typeof t=="function"&&t()}):e()}}};we=new WeakMap,re=new WeakMap,Ee=new WeakMap,Se=new WeakMap,Ce=new WeakMap,Ve=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,y(I,"idGen",new Ft("ef")),y(I,"count",0),y(I,"maxDepth",256);var ms=I,ge=(...s)=>ms.createEffect(...s);var vt=new WeakMap,kr=s=>{let e=vt.get(s);return e||(e={},vt.set(s,e)),e},Oe=(s,e)=>{var t,i;return(i=(t=vt.get(s))==null?void 0:t.signals)==null?void 0:i.get(e)};var wi=(s,e,t)=>{var r;let i=kr(s);(r=i.signals)!=null||(i.signals=new Map),i.signals.set(e,t)};function Cs(...s){for(let e of s)if(vt.has(e)){let t=vt.get(e);if(t.signals){for(let i of t.signals.values())N(i);t.signals.clear(),t.signals=void 0}}}function Ei(s){let e=D(We(s)?s:Oe(...s));e!=null&&!e.muted&&!e.destroyed&&bs(e.id,e.value,{touch:!0})}function tt(s){var e,t;return We(s)?(e=D(s))==null?void 0:e.value:(t=D(Oe(...s)))==null?void 0:t.value}var pi;pi=ne;var Gt=class{constructor(e){y(this,pi);this[ne]=e}get get(){return this[ne].reader}get set(){return this[ne].writer}get value(){return tt(this.get)}set value(e){this.set(e)}onChange(e){let{destroy:t}=ge(()=>e(this.value),[this.get]);return t}get muted(){return this[ne].muted}set muted(e){this[ne].muted=e}touch(){Ei(this)}destroy(){N(this)}},Pr=new Ft("si"),di=!1;function Or(){di||(di=!0,console.warn("signalReader(callback) is deprecated and will be removed in a future release. Use Signal.onChange(callback) instead \\u2014 it returns an unsubscribe function for proper cleanup."))}function gi(s){var e;Ss()||(e=bi())==null||e.whenSignalIsRead(s)}function bs(s,e,t){Ss()||E(pt,s,e,t)}var We=s=>s!=null&&s[ne]!=null,xr=s=>{let e=t=>{var i;return s.destroyed||(i=s.beforeRead)==null||i.call(s),t?(Or(),ge(()=>(s.destroyed||gi(s.id),t(s.value)),[e])):s.destroyed||gi(s.id),s.value};return Object.defineProperty(e,ne,{value:s}),e},J,Nt=class Nt{constructor(e,t){y(this,"id");y(this,"lazy");y(this,"compare");y(this,"beforeRead");y(this,"muted",!1);y(this,"destroyed",!1);d(this,J);y(this,"valueFn");y(this,"reader");y(this,"writer",(e,t)=>{var c,p,w;let i=(c=t==null?void 0:t.lazy)!=null?c:!1,r=(p=t==null?void 0:t.compare)!=null?p:this.compare,o=r!=null?r:((A,v)=>A===v);if((i!==this.lazy||i&&e!==this.valueFn||!i&&!o(e,n(this,J)))&&(i?(g(this,J,void 0),this.valueFn=e,this.lazy=!0):(g(this,J,e),this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){bs(this.id,n(this,J));return}(w=t==null?void 0:t.touch)!=null&&w&&!this.muted&&!this.destroyed&&bs(this.id,n(this,J),{touch:!0})});y(this,"object");this.id=Pr.make(),++Nt.instanceCount,this.lazy=e,this.lazy?(this.value=void 0,this.valueFn=t):(this.value=t,this.valueFn=void 0),this.reader=xr(this),this.object=new Gt(this)}get[ne](){return this}get value(){return this.lazy&&(g(this,J,this.valueFn()),this.valueFn=void 0,this.lazy=!1),n(this,J)}set value(e){g(this,J,e)}};J=new WeakMap,y(Nt,"instanceCount",0);var $t=Nt,D=s=>s==null?void 0:s[ne];function x(s=void 0,e){var i;let t;if(We(s))t=D(s);else{let r=(i=e==null?void 0:e.lazy)!=null?i:!1;t=new $t(r,s),t.beforeRead=e==null?void 0:e.beforeRead,t.compare=e==null?void 0:e.compare}return(e==null?void 0:e.attach)!=null&&de.findOrCreate(e.attach).attachSignal(t),t.object}var N=(...s)=>{for(let e of s){let t=D(e);t!=null&&!t.destroyed&&(t.destroyed=!0,t.beforeRead=void 0,--$t.instanceCount,E(Ie,t.id,t.id))}};function Ut(s,e){var a,c;let t=x(),i=(e==null?void 0:e.attach)!=null?de.findOrCreate(e.attach):void 0;i!=null&&(e!=null&&e.name?i.attachSignalByName(e.name,t):i.attachSignal(t));let r=ge(()=>{Pe(()=>{t.set(s())})},{autorun:!((a=e==null?void 0:e.lazy)!=null&&a),priority:(c=e==null?void 0:e.priority)!=null?c:be.C,attach:i}),o=D(t);return o.beforeRead=r.run,k(Ie,o.id,r.destroy),t.get}var F,st,_t=class{constructor(e){d(this,F,!1);d(this,st);y(this,"source");y(this,"lastValue");y(this,"isDestroyed",!1);V(this),this.source=D(e),g(this,st,T(pt,this.source.id,(t,i)=>{!n(this,F)&&!this.isDestroyed&&((i==null?void 0:i.touch)===!0?this.touch():this.write())})),k(Ie,this.source.id,()=>this.destroy())}attach(e){let t=de.findOrCreate(e);return t.attachLink(this),k(this,ke,()=>{t.detachLink(this)}),t}nextValue(){return new Promise((e,t)=>{let i=[],r=()=>i.forEach(o=>{o()});i.push(k(this,et,o=>{r(),e(o)}),k(this,ke,()=>{r(),t()}))})}asyncValues(e){return Us(this,null,function*(){gt(this,et);try{let t=0;for(;!this.isDestroyed;)try{let i=yield new rs(this.nextValue());if(e!=null&&e(i,t++))break;yield i}catch(i){break}}finally{He(this,et)}})}destroy(){var e;this.isDestroyed||((e=n(this,st))==null||e.call(this),g(this,st,void 0),E(this,ke,this),He(this,et),L(this),this.lastValue=void 0,this.isDestroyed=!0,Object.freeze(this))}get isMuted(){return n(this,F)}mute(){return!this.isDestroyed&&!n(this,F)&&(g(this,F,!0),E(this,ws,this)),this}unmute(){return!this.isDestroyed&&n(this,F)&&(g(this,F,!1),E(this,Es,this)),this}toggleMute(){return this.isDestroyed||(g(this,F,!n(this,F)),E(this,n(this,F)?ws:Es,this)),n(this,F)}updateValue(e){if(!n(this,F)&&!this.isDestroyed){let{value:t}=this.source;e(t),E(this,et,t),this.lastValue=t}}};F=new WeakMap,st=new WeakMap;var As=class extends _t{constructor(t,i){super(t);y(this,"target");this.target=D(i),k(Ie,this.target.id,()=>this.destroy()),this.touch()}touch(){return this.updateValue(t=>{this.target.writer(t,{touch:!0})}),this}write(){this.updateValue(t=>{this.target.writer(t)})}},ks=class extends _t{constructor(t,i){super(t);y(this,"target");this.target=i,this.touch()}touch(){return this.updateValue(t=>{this.target(t)}),this}write(){this.updateValue(t=>{this.target(t)})}},jt=new Map;function Y(s,e,t){let i=D(s),r=D(e),o=r!=null?r:e,a;if(jt.has(i)){if(a=jt.get(i),a.has(o))return a.get(o)}else a=new Map,jt.set(i,a);let c=r!=null?new As(s,r):new ks(s,e),p=t==null?void 0:t.attach;return p&&c.attach(p),a.set(o,c),k(c,ke,()=>{a.delete(o),a.size===0&&jt.delete(i)}),c}var U,Ps=class Ps{constructor(){d(this,U,new Map)}static fromProps(e,t){let i=new Ps,r=t?t.map(o=>[o,e[o]]):Object.entries(e);for(let[o,a]of r)n(i,U).set(o,x(a));return i}keys(){return n(this,U).keys()}signals(){return n(this,U).values()}entries(){return n(this,U).entries()}clear(){for(let e of n(this,U).values())e.destroy();n(this,U).clear()}has(e){return n(this,U).has(e)}get(e){if(!n(this,U).has(e)){let t=x();return n(this,U).set(e,t),t}return n(this,U).get(e)}update(e){e.size&&Pe(()=>{for(let[t,i]of e.entries())this.get(t).set(i)})}updateFromProps(e,t){Pe(()=>{let i=t?t.map(r=>[r,e[r]]):Object.entries(e);for(let[r,o]of i)this.get(r).set(o)})}};U=new WeakMap;var Vt=Ps;var It=s=>s!=null?s:void 0;var Os=Symbol("onCreate"),oe=Symbol("onDestroy"),Si=Symbol("onParentChanged"),Wt=Symbol("onViewEvent");function Ci(s){return function(e,t){var o;let i=(s==null?void 0:s.name)||t.name,r=!!((o=s==null?void 0:s.readAsValue)!=null&&o);return{get(){let a=Oe(this,i);if(a)return r?a.value:a.get()},set(a){var c;(c=Oe(this,i))==null||c.set(a)},init(a){let c=x(a,s);return wi(this,i,c),de.findOrCreate(this).attachSignalByName(i,c),c.value}}}}var Mr=Object.create,xs=Object.defineProperty,Lr=Object.getOwnPropertyDescriptor,Pi=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),rt=s=>{throw TypeError(s)},Rr=(s,e,t)=>e in s?xs(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ai=(s,e)=>xs(s,"name",{value:e,configurable:!0}),Tr=s=>{var e;return[,,,Mr((e=s==null?void 0:s[Pi("metadata")])!=null?e:null)]},Oi=["class","method","getter","setter","accessor","field","value","get","set"],wt=s=>s!==void 0&&typeof s!="function"?rt("Function expected"):s,Dr=(s,e,t,i,r)=>({kind:Oi[s],name:e,metadata:i,addInitializer:o=>t._?rt("Already initialized"):r.push(wt(o||null))}),xi=(s,e)=>Rr(e,Pi("metadata"),s[3]),ki=(s,e,t,i)=>{for(var r=0,o=s[e>>1],a=o&&o.length;r<a;r++)e&1?o[r].call(t):i=o[r].call(t,i);return i},Br=(s,e,t,i,r,o)=>{var a,c,p,w,A,v=e&7,G=!!(e&8),R=!!(e&16),S=v>3?s.length+1:v?G?1:2:0,l=Oi[v+5],h=v>3&&(s[S-1]=[]),u=s[S]||(s[S]=[]),f=v&&(!R&&!G&&(r=r.prototype),v<5&&(v>3||!R)&&Lr(v<4?r:{get[t](){return j(this,o)},set[t](O){return St(this,o,O)}},t));v?R&&v<4&&Ai(o,(v>2?"set ":v>1?"get ":"")+t):Ai(r,t);for(var b=i.length-1;b>=0;b--)w=Dr(v,t,p={},s[3],u),v&&(w.static=G,w.private=R,A=w.access={has:R?O=>zr(r,O):O=>t in O},v^3&&(A.get=R?O=>(v^1?j:xe)(O,r,v^4?o:f.get):O=>O[t]),v>2&&(A.set=R?(O,he)=>St(O,r,he,v^4?o:f.set):(O,he)=>O[t]=he)),c=(0,i[b])(v?v<4?R?o:f[l]:v>4?void 0:{get:f.get,set:f.set}:r,w),p._=1,v^4||c===void 0?wt(c)&&(v>4?h.unshift(c):v?R?o=c:f[l]=c:r=c):typeof c!="object"||c===null?rt("Object expected"):(wt(a=c.get)&&(f.get=a),wt(a=c.set)&&(f.set=a),wt(a=c.init)&&h.unshift(a));return v||xi(s,r),f&&xs(r,t,f),R?v^4?o:f:r},Ms=(s,e,t)=>e.has(s)||rt("Cannot "+t),zr=(s,e)=>Object(e)!==e?rt('Cannot use the "in" operator on this value'):s.has(e),j=(s,e,t)=>(Ms(s,e,"read from private field"),t?t.call(s):e.get(s)),Qt=(s,e,t)=>e.has(s)?rt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),St=(s,e,t,i)=>(Ms(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),xe=(s,e,t)=>(Ms(s,e,"access private method"),t),Mi,ae,Me,Ct,Ls,ye,qt,Et,it="value";Mi=[Ci({name:it})];var ce=class{constructor(e){Qt(this,ye),Qt(this,ae,[]),Qt(this,Me),Qt(this,Ls,ki(Ct,8,this)),ki(Ct,11,this),this.value$=void 0,gt(this,it),this.value$=Oe(this,it),this.value$.onChange(t=>E(this,it,t)),e&&this.add(...e)}add(...e){return j(this,ae).push(...e),xe(this,ye,Et).call(this),xe(this,ye,qt).call(this,e)}unshift(...e){return j(this,ae).unshift(...e),xe(this,ye,Et).call(this),xe(this,ye,qt).call(this,e)}remove(...e){xe(this,ye,qt).call(this,e)()}clear(){j(this,ae).length=0,xe(this,ye,Et).call(this)}dispose(){var e;this.clear(),(e=j(this,Me))==null||e.destroy(),St(this,Me,void 0),He(this,it),L(this),this.value$.destroy(),Cs(this)}};Ct=Tr(null);ae=new WeakMap;Me=new WeakMap;Ls=new WeakMap;ye=new WeakSet;qt=function(s){return()=>{for(let e of s){let t=j(this,ae).indexOf(e);t!==-1&&j(this,ae).splice(t,1)}xe(this,ye,Et).call(this)}};Et=function(){var s;(s=j(this,Me))==null||s.destroy(),j(this,ae).length===0?(St(this,Me,void 0),this.value=void 0):(St(this,Me,ge(()=>{let e;for(let t of j(this,ae)){let i=tt(t);if(i!=null){e=i;break}}this.value=e},j(this,ae))),j(this,Me).run())};Br(Ct,4,"value",Mi,ce,Ls);xi(Ct,ce);ce.Value=it;var Rs=new Map,Ts=!1,Fr=(s,e)=>{Rs.set(s,e),Ts||(Ts=!0,queueMicrotask(()=>{Ts=!1;let t=Array.from(Rs.entries());Rs.clear();for(let[i,r]of t)i.set(r)}))},X,Qe,Le,Z,Re,W,B,pe,Q,nt,qe,ve,P,Ds,Bs,zs,Te,At,Ht,Kt=class{constructor(e,t){d(this,P);d(this,X);d(this,Qe);d(this,Le,new Vt);d(this,Z,new Map);d(this,Re,new Map);d(this,W);d(this,B);d(this,pe,new Set);d(this,Q,[]);d(this,nt,0);d(this,qe,!1);d(this,ve);d(this,Te);g(this,X,e),g(this,Qe,t),k(this,oe,be.Min,this)}get kernel(){return n(this,X)}get uuid(){return n(this,Qe)}get order(){return n(this,nt)}set order(e){n(this,nt)!==e&&(g(this,nt,e),n(this,W)&&this.parent.resortChildren())}get parentUuid(){return n(this,W)||void 0}set parentUuid(e){if(n(this,W)!==e){let t=e?n(this,X).getEntity(e):void 0;this.removeFromParent(),g(this,W,e||void 0),g(this,B,t),n(this,B)&&n(this,B).addChild(this),C(this,P,Bs).call(this)}}get parent(){return!n(this,B)&&n(this,W)&&g(this,B,n(this,X).getEntity(n(this,W))),n(this,B)}set parent(e){this.parentUuid=e==null?void 0:e.uuid}get hasParent(){return!!n(this,W)}get children(){return n(this,Q)}traverse(e){e(this);for(let t of n(this,Q))t.traverse(e)}[oe](){var e,t;n(this,Le).clear(),L(this),(e=n(this,ve))==null||e.call(this);for(let i of n(this,Re).values())i.cleanup(),i.signal.destroy();n(this,Re).clear();for(let i of n(this,Z).values())i.context.set(void 0),i.unsubscribePathValue(),(t=i.unsubscribeFromParent)==null||t.call(i),i.valuePath.dispose(),i.inherited.destroy(),i.provide.destroy(),i.context.destroy();g(this,W,void 0),g(this,B,void 0),n(this,pe).clear(),n(this,Q).length=0}addChild(e){var t;if(n(this,Q).length===0){n(this,pe).add(e.uuid),n(this,Q).push(e);return}if(n(this,pe).has(e.uuid))throw new Error(\`child with uuid: \${e.uuid} already exists! parentUuid: \${this.uuid}\`);n(this,pe).add(e.uuid),n(this,Q).push(e),this.resortChildren();for(let[,i]of n(e,Z))C(t=e,P,Ht).call(t,i)}resortChildren(){n(this,Q).sort((e,t)=>e.order-t.order)}removeChild(e){n(this,pe).has(e.uuid)&&(n(this,pe).delete(e.uuid),n(this,Q).splice(n(this,Q).indexOf(e),1))}removeFromParent(){if(n(this,B)){n(this,B).removeChild(this),g(this,B,void 0),g(this,W,void 0);for(let[,e]of n(this,Z))e.unsubscribeFromParent&&(e.unsubscribeFromParent(),e.unsubscribeFromParent=void 0);C(this,P,Ds).call(this)}}get autoDestructionOnParentRemoval(){return n(this,qe)}set autoDestructionOnParentRemoval(e){n(this,qe)!==e&&(g(this,qe,e),C(this,P,Bs).call(this))}reSubscribeToParentContexts(){for(let[,e]of n(this,Z))C(this,P,Ht).call(this,e)}dispatchMessageToView(e,t,i,r=!1){n(this,X).dispatchMessageToView({uuid:n(this,Qe),type:e,data:t,transferables:i,traverseChildren:r})}dispatchViewEvents(e){for(let{type:t,data:i}of e)E(this,Wt,t,i)}dispatchViewEvent(e,t){this.dispatchViewEvents([{type:e,data:t}])}getPropertyReader(e){return C(this,P,zs).call(this,e).get}getPropertyWriter(e){return C(this,P,zs).call(this,e).set}setProperties(e){this.clearTruthyPropsCache(),Pe(()=>{for(let[t,i]of e)this.setProperty(t,i)})}setProperty(e,t){this.getPropertyWriter(e)(t)}getProperty(e){return tt(this.getPropertyReader(e))}propKeys(){return Array.from(n(this,Le).keys())}propEntries(){return Array.from(n(this,Le).entries()).map(([e,t])=>[e,t.value])}clearTruthyPropsCache(){g(this,Te,void 0)}truthyProps(){if(n(this,Te))return n(this,Te).size?n(this,Te):void 0;let e=new Set;for(let[t,i]of n(this,Le).entries())if(typeof t=="string"){let r=i.value;r!=null&&r!==!1&&r!==""&&e.add(t)}return g(this,Te,e),e.size?e:void 0}hasContext(e){return n(this,Z).has(e)}useContext(e){return C(this,P,At).call(this,e).context.get}useParentContext(e){return C(this,P,At).call(this,e).inherited.get}provideContext(e){return C(this,P,At).call(this,e).provide}provideGlobalContext(e){if(n(this,Re).has(e))return n(this,Re).get(e).signal;let t=n(this,X).findOrCreateRootContext(e),i=x(),r=t.add(i);return n(this,Re).set(e,{cleanup:r,signal:i}),i}};X=new WeakMap,Qe=new WeakMap,Le=new WeakMap,Z=new WeakMap,Re=new WeakMap,W=new WeakMap,B=new WeakMap,pe=new WeakMap,Q=new WeakMap,nt=new WeakMap,qe=new WeakMap,ve=new WeakMap,P=new WeakSet,Ds=function(){n(this,ve)&&(n(this,ve).call(this),g(this,ve,void 0))},Bs=function(){C(this,P,Ds).call(this),n(this,qe)&&n(this,B)&&g(this,ve,k(n(this,B),oe,be.Max,()=>{g(this,ve,void 0),n(this,X).destroyEntity(n(this,Qe))}))},zs=function(e){return n(this,Le).get(e)},Te=new WeakMap,At=function(e){if(n(this,Z).has(e))return n(this,Z).get(e);let t=x(),i=x(),r=x(),o=new ce([i,t]),a=T(o,ce.Value,p=>{Fr(r,p)}),c={name:e,inherited:t,provide:i,context:r,valuePath:o,unsubscribePathValue:a};return n(this,Z).set(e,c),C(this,P,Ht).call(this,c),c},Ht=function(e){var t,i;if((t=e.unsubscribeFromParent)==null||t.call(e),e.unsubscribeFromParent=void 0,this.parent){let r=C(i=this.parent,P,At).call(i,e.name),o=Y(r.context,e.inherited);e.unsubscribeFromParent=o.destroy.bind(o)}else{let r=n(this,X).findOrCreateRootContext(e.name),o=Y(r.value$,e.inherited);e.unsubscribeFromParent=o.destroy.bind(o)}};function Li(s,e){s.indexOf(e)===-1&&s.push(e)}var Ri=s=>{let e=s.split("@").map(t=>t.trim());if(e.length===2&&e[1])return e[0]?{key:\`\${e[0]}@\${e[1]}\`,prop:e[1],token:e[0]}:{key:e[1],prop:e[1]}},Jt=(s,e)=>{for(let t of e)s.add(t)},Gr=(s,e)=>{if(s!=null)for(let t of s.constructors)e.add(t)},me,_,q,kt=class{constructor(){d(this,me,new Map);d(this,_,new Map);d(this,q,new Map)}static get(e){return e!=null?e:$r}define(e,t){n(this,me).has(e)?Li(n(this,me).get(e).constructors,t):n(this,me).set(e,{token:e,constructors:[t]})}appendRoute(e,t){let i=Ri(e);i?n(this,q).has(i.key)?Jt(n(this,q).get(i.key).routes,t):n(this,q).set(i.key,{routes:new Set(t),token:i.token}):n(this,_).has(e)?Jt(n(this,_).get(e),t):n(this,_).set(e,new Set(t))}clearRoute(e){let t=Ri(e);t?n(this,q).delete(t.key):n(this,_).delete(e)}findTokensByRoute(e,t){let i=new Set([e]),r=n(this,_).has(e)?[...n(this,_).get(e)]:[];for(;r.length;){let o=r.shift();i.has(o)||(i.add(o),n(this,_).has(o)&&r.push(...Array.from(n(this,_).get(o)).filter(a=>!i.has(a))))}if(t){for(let a of t)n(this,q).has(a)&&Jt(i,n(this,q).get(a).routes);let o;do{o=i.size;for(let a of new Set(i))for(let c of t){let p=\`\${a}@\${c}\`;n(this,q).has(p)&&Jt(i,n(this,q).get(p).routes)}}while(o!==i.size)}return i}findConstructors(e,t){let i=this.findTokensByRoute(e,t),r=new Set;for(let o of i)Gr(n(this,me).get(o),r);return r.size>0?Array.from(r):void 0}hasToken(e){return n(this,me).has(e)}hasRoute(e){return n(this,_).has(e)}clear(){n(this,me).clear(),n(this,_).clear(),n(this,q).clear()}};me=new WeakMap,_=new WeakMap,q=new WeakMap;var $r=new kt;var Ti=s=>s.displayName||s.name,Di=!1,Bi=!1,zi=!1,Fi=!1,Gi=!1,M,ee,ot,Pt,te,De,Yt=class{constructor(e){d(this,M);d(this,ee);d(this,ot);d(this,Pt);d(this,te);d(this,De);this.logger=new Dt("Kernel"),g(this,M,new Map),g(this,ee,new Set),g(this,te,!0),g(this,De,new Map),V(this),this.registry=kt.get(e)}getEntity(e){var i;let t=(i=n(this,M).get(e))==null?void 0:i.entity;if(!t)throw new Error(\`entity with uuid "\${e}" not found!\`);return t}hasEntity(e){return n(this,M).has(e)}traverseLevelOrderBFS(e=!1){if(n(this,te)){let t=new Map,i=(r,o)=>{let a=this.getEntity(r);t.has(o)?t.get(o).push(a):t.set(o,[a]);for(let c of a.children)i(c.uuid,o+1)};n(this,ee).forEach(r=>{i(r,0)}),g(this,ot,Array.from(t.entries()).sort((r,o)=>r[0]-o[0]).flatMap(([,r])=>r)),g(this,Pt,n(this,ot).slice().reverse()),g(this,te,!1)}return e?n(this,Pt):n(this,ot)}getEntityGraph(){return Array.from(n(this,ee)).map(e=>this.getEntityGraphNode(e))}getEntityGraphNode(e){if(!n(this,M).has(e))return;let{token:t,entity:i}=n(this,M).get(e);return{token:t,entity:i,props:Object.fromEntries(i.propEntries()),children:i.children.map(r=>this.getEntityGraphNode(r.uuid))}}upgradeEntities(){let e=new Map;for(let t of this.traverseLevelOrderBFS(!0))e.set(t.uuid,this.updateShadowObjects(t.uuid,2));for(let t of this.traverseLevelOrderBFS(!1))this.updateShadowObjects(t.uuid,1,e.get(t.uuid));e.clear()}run(e){this.logger.isDebug&&this.logger.debug("sync",e),Pe(()=>{for(let t of e.changeTrail)this.parse(t)})}parse(e){switch(e.type){case le.CreateEntities:this.createEntity(e.uuid,e.token,e.parentUuid,e.order,e.properties,e.autoDestructionOnParentRemoval),g(this,te,!0);break;case le.DestroyEntities:this.destroyEntity(e.uuid),g(this,te,!0);break;case le.SetParent:this.setParent(e.uuid,e.parentUuid,e.order),g(this,te,!0);break;case le.UpdateOrder:this.updateOrder(e.uuid,e.order),g(this,te,!0);break;case le.ChangeProperties:this.changeProperties(e.uuid,e.properties);break;case le.ChangeToken:this.changeToken(e.uuid,e.token);break;case le.SendEvents:this.dispatchEventsToEntity(e.uuid,e.events);break}}createEntity(e,t,i,r=0,o,a=!1){let c=new Kt(this,e);c.order=r;let p={token:t,entity:c,usedConstructors:new Map};n(this,M).set(e,p),i&&(c.parentUuid=i),c.autoDestructionOnParentRemoval=a,c.hasParent||n(this,ee).add(e),o&&c.setProperties(o),this.createShadowObjects(e)}destroyEntity(e){if(!n(this,M).has(e))return;let{entity:t,usedConstructors:i}=n(this,M).get(e),r=[...t.children];for(let o of r)o.autoDestructionOnParentRemoval?this.destroyEntity(o.uuid):(o.removeFromParent(),n(this,ee).add(o.uuid));t.removeFromParent(),E(t,oe,t),i.clear(),n(this,M).delete(t.uuid),n(this,ee).delete(t.uuid),g(this,te,!0)}setParent(e,t,i=0){let r=this.getEntity(e);if(!(r.parentUuid===t&&r.order===i)){if(t&&!n(this,M).has(t))throw new Error(\`entity with uuid "\${t}" not found!\`);r.removeFromParent(),r.order=i,r.parentUuid=t,r.hasParent?n(this,ee).delete(e):n(this,ee).add(e),r.reSubscribeToParentContexts(),queueMicrotask(()=>{this.logger.isDebug&&this.logger.debug("entity.onParentChanged",{uuid:e,parentUuid:t,order:i,entity:r}),E(r,Si,r)})}}updateOrder(e,t){this.getEntity(e).order=t}dispatchEventsToEntity(e,t){var i;(i=this.getEntity(e))==null||i.dispatchViewEvents(t)}changeProperties(e,t){this.getEntity(e).setProperties(t),this.updateShadowObjects(e)}changeToken(e,t){if(!n(this,M).has(e))return;let i=n(this,M).get(e);i.token!==t&&(i.token=t,this.updateShadowObjects(e))}dispatchMessageToView(e){queueMicrotask(()=>{E(this,ht,e)})}updateShadowObjects(e,t=0,i){let r=n(this,M).get(e);i!=null||(i=new Set(this.registry.findConstructors(r.token,r.entity.truthyProps())));let o=t===0||t===2,a=t===0||t===1;if(o){for(let[c,p]of r.usedConstructors)if(!i.has(c)){r.usedConstructors.delete(c);for(let w of p)this.destroyShadowObject(w,r.entity)}}if(a)for(let c of i)r.usedConstructors.has(c)||this.constructShadowObject(c,r);return i}constructShadowObject(e,t){let i=new Set,r=new Set,o=new Map,a=new Map,c=new Map,p=new Map,w=new Map,A=new Map,v=new Map,G=new Map,R=(l,h)=>{!Gi&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useProperty()" is now passed as {compare} argument. Please update your code accordingly.'),Gi=!0);let u=typeof h=="function"?{compare:h}:h,f=v.get(l);if(f===void 0){f=x(void 0,u).get,v.set(l,f),G.set(l,u==null?void 0:u.compare);let b=Y(t.entity.getPropertyReader(l),f);r.add(b.destroy.bind(b))}else(u==null?void 0:u.compare)!=null&&G.get(l)!==u.compare&&console.warn(\`[shadow-objects] useProperty("\${l}"): the cached signal already exists with a different (or no) {compare} function \\u2014 the new options are ignored. Pass options only on the first call per property.\`);return f},S=V(new e({entity:t.entity,provideContext(l,h,u){var O;!Di&&u!=null&&typeof u=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideContext()" is now passed as {compare} argument. Please update your code accordingly.'),Di=!0);let f=typeof u=="function"?{compare:u}:u,b=w.get(l);if(b==null){let he=We(h),es=he?void 0:It(h);if(b=x(es,f!=null&&f.compare?{compare:f.compare}:void 0),he){let ct=Y(h,b);r.add(ct.destroy.bind(ct))}let at=Y(b,t.entity.provideContext(l));r.add(at.destroy.bind(at)),w.set(l,b)}return b!=null&&((O=f==null?void 0:f.clearOnDestroy)==null||O)&&r.add(()=>{b.set(void 0)}),b},provideGlobalContext(l,h,u){var O;!Bi&&u!=null&&typeof u=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideGlobalContext()" is now passed as {compare} argument. Please update your code accordingly.'),Bi=!0);let f=typeof u=="function"?{compare:u}:u,b=A.get(l);if(b==null){let he=We(h),es=he?void 0:It(h);if(b=x(es,f!=null&&f.compare?{compare:f.compare}:void 0),he){let ct=Y(h,b);r.add(ct.destroy.bind(ct))}let at=Y(b,t.entity.provideGlobalContext(l));r.add(at.destroy.bind(at)),A.set(l,b)}return b!=null&&((O=f==null?void 0:f.clearOnDestroy)==null||O)&&r.add(()=>{b.set(void 0)}),b},useContext(l,h){!zi&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useContext()" is now passed as {compare} argument. Please update your code accordingly.'),zi=!0);let u=typeof h=="function"?{compare:h}:h,f=o.get(l);if(f===void 0){f=x(void 0,u).get,o.set(l,f),a.set(l,u==null?void 0:u.compare);let b=Y(t.entity.useContext(l),f);r.add(b.destroy.bind(b))}else(u==null?void 0:u.compare)!=null&&a.get(l)!==u.compare&&console.warn(\`[shadow-objects] useContext("\${String(l)}"): the cached signal already exists with a different (or no) {compare} function \\u2014 the new options are ignored. Pass options only on the first call per context.\`);return f},useParentContext(l,h){!Fi&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useParentContext()" is now passed as {compare} argument. Please update your code accordingly.'),Fi=!0);let u=typeof h=="function"?{compare:h}:h,f=c.get(l);if(f===void 0){f=x(void 0,u).get,c.set(l,f),p.set(l,u==null?void 0:u.compare);let b=Y(t.entity.useParentContext(l),f);r.add(b.destroy.bind(b))}else(u==null?void 0:u.compare)!=null&&p.get(l)!==u.compare&&console.warn(\`[shadow-objects] useParentContext("\${String(l)}"): the cached signal already exists with a different (or no) {compare} function \\u2014 the new options are ignored. Pass options only on the first call per parent context.\`);return f},dispatchMessageToView(l,h,u,f=!1){t.entity.dispatchMessageToView(l,h,u,f)},useProperty:R,useProperties(l){let h={};for(let u in l)Object.hasOwn(l,u)&&(h[u]=R(l[u]));return h},createResource(l,h){let u=x(),f=ge(()=>{let b=It(l());return u.set(b),b!==void 0&&h?()=>{h(b),u.set(void 0)}:()=>{u.set(void 0)}});return r.add(()=>{f.destroy(),u.set(void 0),N(u)}),u},createEffect(...l){let h=ge(...l);return r.add(h.destroy),h},createSignal(...l){let h=x(...l);return r.add(()=>{N(h)}),h},createMemo(...l){let h=Ut(...l);return r.add(()=>{N(h)}),h},on(...l){let[h]=l;if(typeof h=="string"||typeof h=="symbol"||Array.isArray(h)){let f=T(t.entity,...l);return r.add(f),f}let u=T(...l);return r.add(u),Object.assign(()=>{r.delete(u),u()},u)},once(...l){let[h]=l;if(typeof h=="string"||typeof h=="symbol"||Array.isArray(h)){let f=k(t.entity,...l);return r.add(f),f}let u=k(...l);return r.add(u),Object.assign(()=>{r.delete(u),u()},u)},emit(...l){let[h]=l;typeof h=="string"||typeof h=="symbol"||Array.isArray(h)?E(t.entity,...l):E(...l)},onViewEvent(l){let h=T(t.entity,Wt,(u,f)=>{l(u,f)});r.add(h)},onDestroy(l){i.add(l)}}));return this.logger.isInfo&&this.logger.info("create shadow-object",Ti(e),{shadowObject:S,entity:t.entity}),k(t.entity,oe,be.Low,()=>{this.logger.isInfo&&this.logger.info("destroy shadow-object",Ti(e),{shadowObject:S,entity:t.entity});for(let h of i)h();for(let h of r)h();for(let h of o.values())N(h);for(let h of c.values())N(h);for(let h of v.values())N(h);for(let h of w.values())N(h);for(let h of A.values())N(h);i.clear(),r.clear(),o.clear(),c.clear(),v.clear(),w.clear(),A.clear();let l=t.usedConstructors.get(e);l&&(l.delete(S),l.size===0&&t.usedConstructors.delete(e))}),t.usedConstructors.has(e)?t.usedConstructors.get(e).add(S):t.usedConstructors.set(e,new Set([S])),this.attachShadowObject(S,t.entity),S}createShadowObjects(e){var i;let t=n(this,M).get(e);(i=this.registry.findConstructors(t.token,t.entity.truthyProps()))==null||i.forEach(r=>{this.constructShadowObject(r,t)})}findShadowObjects(e){if(!n(this,M).has(e))return[];let{usedConstructors:t}=n(this,M).get(e);return Array.from(new Set(Array.from(t.values()).flatMap(i=>Array.from(i))))}attachShadowObject(e,t){T(t,e),typeof e[Os]=="function"&&e[Os](t)}destroyShadowObject(e,t){typeof e[oe]=="function"&&e[oe](t),E(e,oe,t),L(t,e)}findOrCreateRootContext(e){let t=n(this,De).get(e);return t||(t=new ce,n(this,De).set(e,t)),t}destroy(){for(let e of n(this,De).values())e.dispose();n(this,De).clear();for(let e of this.traverseLevelOrderBFS().reverse())this.destroyEntity(e.uuid)}};M=new WeakMap,ee=new WeakMap,ot=new WeakMap,Pt=new WeakMap,te=new WeakMap,De=new WeakMap;var $i=s=>(typeof s=="string"&&(s=new URL(s,globalThis.location.href)),s.toString());var Ot,Be,Ni,Ui,ji,Xt=class{constructor(e){d(this,Be);d(this,Ot,new Set);var t,i;this.kernel=(t=e==null?void 0:e.kernel)!=null?t:new Yt,this.postMessage=(i=e==null?void 0:e.postMessage)!=null?i:self.postMessage.bind(self),T(this.kernel,ht,"onMessageToView",this)}route(e){var t;switch(e.data.type){case js:C(this,Be,Ni).call(this,e.data);break;case _s:C(this,Be,Ui).call(this,e.data);break;case Vs:C(this,Be,ji).call(this,e.data);break;default:console.warn("[MessageRouter] unknown message",(t=e.data.type)!=null?t:e.data)}}onMessageToView(e){let r=e,{transferables:t}=r,i=Ns(r,["transferables"]);this.postMessage({type:ht,data:i},{transfer:t})}};Ot=new WeakMap,Be=new WeakSet,Ni=async function(e){try{let t=await import($i(e.importModule));t[Rt]?(await ps(this.kernel,t[Rt],n(this,Ot)),this.postMessage({type:Lt,url:e.importModule})):this.postMessage({type:Lt,url:e.importModule,error:\`module has no "\${Rt}" export\`})}catch(t){console.error("[MessageRouter] failed to import module",t),this.postMessage({type:Lt,url:e.importModule,error:\`\${t}\`})}},Ui=function(e){try{this.kernel.run(e)}catch(t){console.error("[MessageRouter] failed to apply change trail",t),this.postMessage({type:ns,serial:e.serial,error:t.toString()})}e.serial&&this.postMessage({type:ns,serial:e.serial})},ji=function(e){console.debug("[MessageRouter] on destroy",e),L(this.kernel,this),n(this,Ot).clear(),this.postMessage({type:Ws})};var Zt=class{constructor(){this.onmessage=e=>{var t;e.data.type===$?globalThis[z]=e.data.config:((t=this.router)!=null||(this.router=new Xt),this.router.route(e))}}start(){self.addEventListener("message",this.onmessage),self.postMessage({type:Is})}};console.debug("@spearwolf/shadow-objects/WorkerRuntime: hello!");var Nr=new Zt;Nr.start();
|
|
21
|
+
var pt="shaeRequestEntParent",gt="shaeReRequestEntParent",Us="shae-worker",yt="shae-ent",Vs="shae-prop",ce="token",q="forward-custom-events";var vt="local",Bs="no-autostart",mt="no-structured-clone",H="auto-sync";var bt="name",wt="value",Et="type",Ct="no-trim";var Ce="*",Ys=1,ss=2,is=4,Q=Symbol.for("eventize"),or="[eventize]",rs=s=>s===Ce,Js=s=>{switch(typeof s){case"string":case"symbol":return!0;default:return!1}},Xs=typeof console<"u",ar=Xs?console[console.warn?"warn":"log"].bind(console,or):()=>{},hr=(s,e,t)=>(Object.defineProperty(s,e,{value:t,configurable:!0}),s),lr=0,ns=class{static publish(s){s.sort((e,t)=>e.order-t.order).forEach(e=>e.replay())}events=new Map;eventNames=new Set;add(s){Array.isArray(s)?s.forEach(e=>this.eventNames.add(e)):this.eventNames.add(s)}remove(s){Array.isArray(s)?s.forEach(e=>this.eventNames.delete(e)):this.eventNames.delete(s),this.clear(s)}clear(s){Array.isArray(s)?s.forEach(e=>this.events.delete(e)):this.events.delete(s)}retain(s,e){this.eventNames.has(s)&&this.events.set(s,{args:e,order:lr++})}isKnown(s){return this.eventNames.has(s)}replayTo(s,e,t=[]){if(rs(s))this.eventNames.forEach(i=>this.replayTo(i,e,t));else if(this.events.has(s)){let{order:i,args:r}=this.events.get(s);t.push({order:i,replay:()=>e.apply(s,r)})}return t}},es=(s,e,t,i)=>{if(typeof e=="function"){let r=e.apply(s,t);r!=null&&i?.(r)}},cr=(s,e,t,i)=>es(e,e.emit,[s].concat(t),i),ur=s=>{switch(typeof s){case"function":return Ys;case"string":case"symbol":return ss;case"object":return is}},dr=0,fr=()=>++dr,Zs=class{id;eventName;isCatchEmAll;priority;listener;listenerObject;listenerType;callAfterApply;isRemoved;refCount;constructor(s,e,t,i=null){this.id=fr(),this.eventName=s,this.isCatchEmAll=rs(s),this.listener=t,this.listenerObject=i,this.priority=e,this.listenerType=ur(t),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(s,e=null){if(s===this)return!0;let t=typeof s;return t==="number"&&s===this.id?!0:e===null&&(t==="string"||t==="symbol")?s===Ce||s===this.eventName:this.listener===s&&this.listenerObject===e}apply(s,e,t){if(this.isRemoved)return;let{listener:i,listenerObject:r}=this;switch(this.listenerType){case Ys:es(r,i,e,t),this.callAfterApply&&this.callAfterApply();break;case ss:es(r,r[i],e,t),this.callAfterApply&&this.callAfterApply();break;case is:{let n=i[s];if(this.isCatchEmAll||this.eventName===s){if(typeof n=="function"){let o=n.apply(i,e);o!=null&&t?.(o)}else cr(s,i,e,t);this.callAfterApply&&this.callAfterApply()}break}}}},pr=(s,e)=>s.priority!==e.priority?e.priority-s.priority:s.id-e.id,gr=(s,e)=>{let t=0,i=s.length;for(;t<i;){let r=t+i>>>1;pr(e,s[r])<0?i=r:t=r+1}return t},Gs=s=>s?.slice(0),qs=(s,e)=>{let t=s.indexOf(e);t>-1&&s.splice(t,1)},yr=s=>s===is||s===ss,ts=(s,e,t)=>{let i=s.findIndex(r=>r.isEqual(e,t));i>-1&&(s[i].isRemoved=!0,s.splice(i,1))},Xt=(s,e,t)=>{let i=[];for(let r of s)(e==null&&r.listenerObject===t||r.eventName===e&&r.listener===t)&&i.push(r);for(let r of i)ts(s,r,void 0)},Zt=s=>{s&&(s.forEach(e=>{e.isRemoved=!0}),s.length=0)},vr=(s,e)=>s.listenerType===e.listenerType?s.priority===e.priority&&s.eventName===e.eventName&&s.listenerObject===e.listenerObject&&s.listener===e.listener:!1,mr=(s,e)=>{if(yr(s.listenerType))return e.find(t=>vr(s,t))},br=(s,e)=>{let t=mr(s,e);return t?(t.refCount+=1,t):(e.splice(gr(e,s),0,s),s)},wr=class{namedListeners;catchEmAllListeners;getListenersForEventName=s=>{let e=this.namedListeners.get(s);return e||(e=[],this.namedListeners.set(s,e)),e};constructor(){this.namedListeners=new Map,this.catchEmAllListeners=[]}add(s){return br(s,s.isCatchEmAll?this.catchEmAllListeners:this.getListenersForEventName(s.eventName))}remove(s,e,t=!1){if(e==null&&Array.isArray(s)){s.forEach(i=>this.remove(i,null,t));return}if(s==null||e==null&&rs(s)){this.removeAllListeners();return}if(e==null&&Js(s)){this.removeByEventName(s);return}if(s instanceof Zs){this.removeByEventListener(s);return}if(t){this.removeByEventNameAndListenerObject(s,e);return}this.removeByListener(s,e)}removeByEventName(s){Zt(this.namedListeners.get(s)),this.namedListeners.delete(s)}removeByEventListener(s){s.isRemoved||(s.refCount-=1,!(s.refCount>=1)&&(s.isRemoved=!0,this.namedListeners.forEach((e,t)=>{qs(e,s),e.length===0&&this.namedListeners.delete(t)}),qs(this.catchEmAllListeners,s)))}removeByEventNameAndListenerObject(s,e){this.namedListeners.forEach((t,i)=>{Xt(t,s,e),t.length===0&&this.namedListeners.delete(i)})}removeByListener(s,e){let t=typeof s=="object";this.namedListeners.forEach((i,r)=>{ts(i,s,e),t&&Xt(i,void 0,s),i.length===0&&this.namedListeners.delete(r)}),ts(this.catchEmAllListeners,s,e),t&&Xt(this.catchEmAllListeners,void 0,s)}removeAllListeners(){this.namedListeners.forEach(s=>Zt(s)),this.namedListeners.clear(),Zt(this.catchEmAllListeners)}forEach(s,e){let t=Gs(this.catchEmAllListeners),i=Gs(this.namedListeners.get(s));if(s===Ce||!i||i.length===0)t.forEach(e);else if(t.length===0)i.forEach(e);else{let r=i.length,n=t.length,o=0,a=0;for(;o<r||a<n;){if(o<r){let f=i[o];if(a>=n||f.priority>=t[a].priority){e(f),++o;continue}}a<n&&(e(t[a]),++a)}}}getSubscriptionCount(){let s=this.catchEmAllListeners.length;for(let e of this.namedListeners.values())s+=e.length;return s}},ue=s=>!!(s&&s[Q]);function qe(s){if(ue(s))return s;let e=new wr,t=new ns;return hr(s,Q,{keeper:t,store:e}),s}var K={Max:Number.POSITIVE_INFINITY,Critical:1e9,High:1e6,Normal:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0},Er=(s,e,t,i,r,n,o)=>{let a=s.add(new Zs(t,i,r,n));return e.replayTo(t,a,o),a},ei=(s,e,t,i)=>{let r=t.length,n=typeof t[0],o,a,f,m;if(r>=2&&r<=3&&n==="number"?(o=Ce,[a,f,m]=t):r>=3&&r<=4&&typeof t[1]=="number"?[o,a,f,m]=t:(a=K.Default,n==="string"||n==="symbol"||Array.isArray(t[0])?[o,f,m]=t:(o=Ce,[f,m]=t)),!f)throw Xs&&ar("called with insufficient arguments!",t),new Error("subscribeTo() called with insufficient arguments");let P=c=>D=>Er(s,e,D,c,f,m,i);return Array.isArray(o)?o.map(c=>Array.isArray(c)?P(c[1])(c[0]):P(a)(c)):P(a)(o)},Cr=(s,e,t)=>{let i=[],r=ei(s,e,t,i);return ns.publish(i),r},Sr=(s,e,t)=>{let i=[];return{listeners:ei(s,e,t,i),publishRetained:()=>ns.publish(i)}},Hs=s=>e=>{e.callAfterApply=()=>{s?.()}},ti=(s,e)=>Object.assign(()=>A(s,e),Array.isArray(e)?{listeners:e}:{listener:e}),Qs=(s,e,t,i)=>{if(e===Ce)throw new Error("emit() must be called with a concrete event name \u2014 '*' is reserved for subscribing to all events and cannot be emitted");let{store:r,keeper:n}=s[Q];r.forEach(e,o=>o.apply(e,t,i)),n.retain(e,t)},si=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>Qs(s,r,t,i)):Qs(s,e,t,i)},Ks=(s,e,t,i)=>{if(e===Ce)throw new Error("emit() must be called with a concrete event name \u2014 '*' is reserved for subscribing to all events and cannot be emitted");let r=s,n=r[e];if(typeof n=="function"){let a=n.apply(s,t);a!=null&&i?.(a);return}let o=r.emit;if(typeof o=="function"){let a=o.apply(s,[e,...t]);a!=null&&i?.(a)}},ii=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>Ks(s,r,t,i)):Ks(s,e,t,i)},ri=s=>s!=null&&typeof s=="object";function b(s,...e){let t=qe(s),{store:i,keeper:r}=t[Q];return ti(t,Cr(i,r,e))}function C(s,...e){let t=qe(s),{store:i,keeper:r}=t[Q],{listeners:n,publishRetained:o}=Sr(i,r,e),a=ti(t,n),f=!1,m=()=>{f||(a(),f=!0)};return Array.isArray(n)?n.forEach(Hs(m)):Hs(m)(n),o(),m}function St(s,e){return new Promise(t=>{C(s,e,t)})}function A(s,e,t){if(!ue(s))return;let{store:i,keeper:r}=s[Q],n=typeof e,o=t!=null&&(n==="string"||n==="symbol");i.remove(e,t,o),Array.isArray(e)?r.remove(e.filter(a=>typeof a=="string")):Js(e)&&r.remove(e)}function g(s,e,...t){ue(s)?si(s,e,t):ri(s)&&ii(s,e,t)}function kr(s,e,...t){let i=[],r=n=>{i.push(n)};return ue(s)?si(s,e,t,r):ri(s)&&ii(s,e,t,r),i=i.map(n=>Array.isArray(n)?Promise.all(n):Promise.resolve(n)),i.length>0?Promise.all(i):Promise.resolve()}function Y(s,e){let t=qe(s),{keeper:i}=t[Q];i.add(e)}function de(s,e){if(!ue(s))throw new Error("object is not eventized");let{keeper:t}=s[Q];t.clear(e)}function Ar(s,e){if(!ue(s))throw new Error("object is not eventized");let{keeper:t}=s[Q];t.remove(e)}var Pr=b,Tr=C,xr=A,Or=g,Rr=kr,Mr=St,Lr=Y,Dr=de,Nr=Ar,T=(()=>{let s=(e={})=>qe(e);return s.inject=(e={})=>(e=qe(e),Object.assign(e,{on:(...t)=>Pr(e,...t),once:(...t)=>Tr(e,...t),onceAsync:t=>Mr(e,t),off:(t,i)=>xr(e,t,i),emit:(t,...i)=>Or(e,t,...i),emitAsync:(t,...i)=>Rr(e,t,...i),retain:t=>Lr(e,t),retainClear:t=>Dr(e,t),unretain:t=>Nr(e,t)}),e),s.is=ue,s})();var os=s=>ue(s)?s[Q]?.store?.getSubscriptionCount()??0:0;var J=Symbol.for("signal"),De=Symbol.for("effect"),ni=Symbol.for("destroySignal"),oi=Symbol.for("createEffect"),_r=Symbol.for("destroyEffect"),_e="value",us="mute",ds="unmute",pe="destroy",Wr="off",Qe=Symbol.for("recall"),Ke=T(),fe=T(),Se=T(),ci=T(),ke=class{static current;delayedEffects=[];batch(e,t){let i=this.delayedEffects.length;for(let r=0;r<i;r++){let[n,o]=this.delayedEffects[r];if(!(n>t)){if(n===t){o.add(e);return}this.delayedEffects.splice(r,0,[t,new Set([e])]);return}}this.delayedEffects.push([t,new Set([e])])}flush(){this.run(),this.delayedEffects.length=0}run(){let e=new Set,t=[];try{t.push(b(Se,(i,r)=>{r===Qe&&e.add(i)}),b(ci,i=>{e.add(i)}));for(let[,i]of this.delayedEffects)for(let r of i)e.has(r)||g(Se,r,r,Qe)}finally{for(let i of t)i()}}},ui=()=>ke.current;function W(s){let e=ke.current;e?e=void 0:e=ke.current=new ke;try{s()}finally{e&&(ke.current=void 0,e.run())}}var as=0;function xt(s){as++;try{s()}finally{as--}}function fs(){return as>0}var kt=class{[De];constructor(e){this[De]=e,C(e,pe,()=>{this[De]=void 0})}run=()=>this[De]?.run();destroy=()=>{this[De]?.destroy(),this[De]=void 0}},hs=[],di=()=>hs.at(-1),$r=(s,e)=>{hs.push(s);try{return e()}finally{hs.pop()}};var Ne=new WeakMap,He=new Set,ai=new FinalizationRegistry(s=>{He.has(s)&&s.clear()});var re=class s{#e=new Set;#t=new Set;#s=new Map;#i=new WeakMap;#r=new Map;#n=new Set;#a=new Set;#o;#h;static get(e){if(e!=null)return e instanceof s?e:Ne.get(e)}static findOrCreate(e){if(e==null)throw new Error("Cannot create a group with a null object");return new s(e)}static destroy(e){console.warn("SignalGroup.destroy(obj) is deprecated. Use SignalGroup.delete(obj) instead."),s.delete(e)}static delete(e){Ne.get(e)?.clear()}static clear(){for(let e of[...He])e.clear();He.clear()}constructor(e){if(e!=null&&e instanceof s)return e;if(e??=this,Ne.has(e))return Ne.get(e);this.#h=new WeakRef(e),Ne.set(e,this),He.add(this),e!==this&&ai.register(e,this,this),T(this)}attachGroup(e){if(e===this)throw new Error("Cannot attach a group to itself");return this.#e.add(e),e.#o&&e.#o!==this&&e.#o.#e.delete(e),e.#o=this,e}detachGroup(e){return e!==this&&this.#e.has(e)&&(this.#e.delete(e),e.#o=void 0),e}attachSignal(e){let t=R(e);if(t?.destroyed)throw new Error("Cannot attach a destroyed signal to a group");return t&&this.#t.add(t),e}attachSignalByName(e,t){if(t){this.attachSignal(t);let i=R(t);this.#s.set(e,i);let r=this.#r.get(e);r?r.add(i):this.#r.set(e,new Set([i])),this.#i.has(i)?this.#i.get(i).add(e):this.#i.set(i,new Set([e]))}else this.#s.delete(e);return t}hasSignal(e){return this.#s.has(e)||!!this.#o?.hasSignal(e)}signal(e){return this.#s.get(e)?.object??this.#o?.signal(e)}detachSignal(e){let t=R(e);if(t&&(this.#t.delete(t),this.#i.has(t))){let i=this.#i.get(t);for(let r of i){let n=this.#r.get(r);if(n){if(n.delete(t),n.size===0)this.#s.delete(r),this.#r.delete(r);else if(this.#s.get(r)===t){let o;for(let a of n)o=a;this.#s.set(r,o)}}}i.clear(),this.#i.delete(t)}return e}attachEffect(e){return this.#n.add(e),e}runEffects(){for(let e of this.#n)e.run();for(let e of this.#e)e.runEffects()}attachLink(e){if(e?.isDestroyed)throw new Error("Cannot attach a destroyed link to a group");return e&&this.#a.add(e),e}detachLink(e){return e&&this.#a.delete(e),e}destroy(){console.warn("SignalGroup#destroy is deprecated. Use SignalGroup#clear instead."),this.clear()}off(){for(let e of this.#e)e.off();for(let e of this.#n)e.destroy();this.#n.clear();for(let e of this.#a)e.destroy();this.#a.clear();for(let e of this.#t)e.destroyed||g(fe,e.id,e.id,{detach:!0});g(this,Wr,this)}clear(){g(this,pe,this),A(this);for(let e of this.#e)e.clear();for(let e of this.#n)e.destroy();for(let e of this.#t)M(e);for(let e of this.#a)e.destroy();if(this.#e.clear(),this.#t.clear(),this.#s.clear(),this.#r.clear(),this.#n.clear(),this.#a.clear(),this.#o?.detachGroup(this),this.#h){let e=this.#h.deref();e!==void 0&&Ne.delete(e),this.#h=void 0}He.delete(this),ai.unregister(this)}},At=class{#e;#t;constructor(e="id",t=1){this.#e=e,this.#t=t}make(){return Symbol(`${this.#e}${this.#t++}`)}},Fr=s=>s!=null&&typeof s.then=="function",ls=class s{static idGen=new At("ef");static count=0;static maxDepth=256;id;callback;#e;#t=new Set;#s=new Set;#i=new Map;#r=new Set;childEffects=[];curChildEffectSlot=0;autorun=!0;shouldRun=!0;priority;#n;#a=!1;#o=0;constructor(e,t){T(this),this.callback=e;let i;t?.attach!=null&&(i=re.findOrCreate(t.attach),i.attachEffect(this)),this.autorun=t?.autorun??!0,this.#n=t?.dependencies?t.dependencies.map(r=>{switch(typeof r){case"string":case"symbol":return i.signal(r);default:return r}}):void 0,this.id=s.idGen.make(),this.priority=t?.priority??0,b(Se,this.id,Qe,this),++s.count}hasStaticDeps(){return this.#n!=null&&this.#n.length>0}saveSignalsFromDeps(){for(let e of this.#n)this.whenSignalIsRead(R(e).id)}static createEffect(e,t,i){let r=Array.isArray(t)?t:void 0,n=r?i??{dependencies:r}:t;n&&r&&(n.dependencies=r);let o,a=di();return a!=null?(o=a.getCurrentChildEffect(),o==null&&(o=new s(e,n),a.attachChildEffect(o),g(Se,oi,o)),a.curChildEffectSlot++):(o=new s(e,n),g(Se,oi,o)),o.hasStaticDeps()?o.saveSignalsFromDeps():o.autorun&&o.run(),new kt(o)}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(e){this.childEffects.push(e)}run=()=>{if(this.#a||!this.shouldRun)return;let e=ui();if(e){e.batch(this.id,this.priority);return}if(this.#o>=s.maxDepth)throw new Error(`[signalize] Effect ${this.id.toString()} exceeded maxDepth=${s.maxDepth}: an effect callback recursively re-triggered itself (likely by writing a signal it depends on). Break the cycle, or raise EffectImpl.maxDepth if the recursion is intentional.`);this.#o++;try{if(this.runCleanupCallback(),this.destroyChildEffects(),this.curChildEffectSlot=0,this.shouldRun=!1,g(ci,this.id,this.id),this.hasStaticDeps())this.#e=this.callback();else{this.#s.clear();for(let t of this.#t)this.#s.add(t);this.#e=$r(this,this.callback),this.cleanupLostSignals(),this.#r.clear()}}finally{this.#o--}};[Qe](){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(e){this.#s.delete(e),this.#t.has(e)||(this.#t.add(e),this.#i.set(e,[b(Ke,e,this.priority,Qe,this),C(fe,e,ni,this)]))}[ni](e,t){if(this.#t.has(e)){if(t?.detach){this.unsubscribeSignal(e),this.#t.delete(e),this.#r.delete(e),this.#s.delete(e),this.#t.size===0&&this.destroy();return}this.#r.has(e)||(this.#r.add(e),this.unsubscribeSignal(e),this.#r.size===this.#t.size&&this.destroy())}}cleanupLostSignals(){for(let e of this.#s)this.unsubscribeSignal(e),this.#t.delete(e)}destroyChildEffects(){for(let e of this.childEffects)e.destroy();this.childEffects.length=0}unsubscribeSignal(e){this.#i.has(e)&&(this.#i.get(e).forEach(t=>{t()}),this.#i.delete(e))}runCleanupCallback(){if(this.#e!=null){let e=this.#e;this.#e=void 0,Fr(e)?Promise.resolve(e).then(t=>{typeof t=="function"&&t()}):e()}}destroy=()=>{this.#a||(g(this,pe,this),A(this),g(Se,_r,this),this.runCleanupCallback(),this.destroyChildEffects(),A(Ke,this),A(Se,this),A(fe,this),this.#a=!0,this.#t.clear(),this.#s.clear(),this.#i.clear(),this.#r.clear(),--s.count)}},S=ls.createEffect;var Ye=new WeakMap,jr=s=>{let e=Ye.get(s);return e||(e={},Ye.set(s,e)),e},G=(s,e)=>Ye.get(s)?.signals?.get(e);var fi=(s,e,t)=>{let i=jr(s);i.signals??=new Map,i.signals.set(e,t)};function Je(...s){for(let e of s)if(Ye.has(e)){let t=Ye.get(e);if(t.signals){for(let i of t.signals.values())M(i);t.signals.clear(),t.signals=void 0}}}function pi(s){let e=R(Ae(s)?s:G(...s));e!=null&&!e.muted&&!e.destroyed&&cs(e.id,e.value,{touch:!0})}function We(s){return Ae(s)?R(s)?.value:R(G(...s))?.value}var Pt=class{[J];constructor(e){this[J]=e}get get(){return this[J].reader}get set(){return this[J].writer}get value(){return We(this.get)}set value(e){this.set(e)}onChange(e){let{destroy:t}=S(()=>e(this.value),[this.get]);return t}get muted(){return this[J].muted}set muted(e){this[J].muted=e}touch(){pi(this)}destroy(){M(this)}},zr=new At("si"),hi=!1;function Ir(){hi||(hi=!0,console.warn("signalReader(callback) is deprecated and will be removed in a future release. Use Signal.onChange(callback) instead \u2014 it returns an unsubscribe function for proper cleanup."))}function li(s){fs()||di()?.whenSignalIsRead(s)}function cs(s,e,t){fs()||g(Ke,s,e,t)}var Ae=s=>s!=null&&s[J]!=null,Ur=s=>{let e=t=>(s.destroyed||s.beforeRead?.(),t?(Ir(),S(()=>(s.destroyed||li(s.id),t(s.value)),[e])):s.destroyed||li(s.id),s.value);return Object.defineProperty(e,J,{value:s}),e},Tt=class s{static instanceCount=0;id;lazy;get[J](){return this}compare;beforeRead;muted=!1;destroyed=!1;#e=void 0;get value(){return this.lazy&&(this.#e=this.valueFn(),this.valueFn=void 0,this.lazy=!1),this.#e}set value(e){this.#e=e}valueFn;reader;writer=(e,t)=>{let i=t?.lazy??!1,n=t?.compare??this.compare??((a,f)=>a===f);if((i!==this.lazy||i&&e!==this.valueFn||!i&&!n(e,this.#e))&&(i?(this.#e=void 0,this.valueFn=e,this.lazy=!0):(this.#e=e,this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){cs(this.id,this.#e);return}(t?.touch??!1)&&!this.muted&&!this.destroyed&&cs(this.id,this.#e,{touch:!0})};object;constructor(e,t){this.id=zr.make(),++s.instanceCount,this.lazy=e,this.lazy?(this.value=void 0,this.valueFn=t):(this.value=t,this.valueFn=void 0),this.reader=Ur(this),this.object=new Pt(this)}},R=s=>s?.[J];function y(s=void 0,e){let t;if(Ae(s))t=R(s);else{let i=e?.lazy??!1;t=new Tt(i,s),t.beforeRead=e?.beforeRead,t.compare=e?.compare}return e?.attach!=null&&re.findOrCreate(e.attach).attachSignal(t),t.object}var M=(...s)=>{for(let e of s){let t=R(e);t!=null&&!t.destroyed&&(t.destroyed=!0,t.beforeRead=void 0,--Tt.instanceCount,g(fe,t.id,t.id))}};function Ot(s,e){let t=y(),i=e?.attach!=null?re.findOrCreate(e.attach):void 0;i!=null&&(e?.name?i.attachSignalByName(e.name,t):i.attachSignal(t));let r=S(()=>{W(()=>{t.set(s())})},{autorun:!(e?.lazy??!1),priority:e?.priority??K.C,attach:i}),n=R(t);return n.beforeRead=r.run,C(fe,n.id,r.destroy),t.get}var Mt=class{#e=!1;#t;source;lastValue;isDestroyed=!1;constructor(e){T(this),this.source=R(e),this.#t=b(Ke,this.source.id,(t,i)=>{!this.#e&&!this.isDestroyed&&(i?.touch===!0?this.touch():this.write())}),C(fe,this.source.id,()=>this.destroy())}attach(e){let t=re.findOrCreate(e);return t.attachLink(this),C(this,pe,()=>{t.detachLink(this)}),t}nextValue(){return new Promise((e,t)=>{let i=[],r=()=>i.forEach(n=>{n()});i.push(C(this,_e,n=>{r(),e(n)}),C(this,pe,()=>{r(),t()}))})}async*asyncValues(e){Y(this,_e);try{let t=0;for(;!this.isDestroyed;)try{let i=await this.nextValue();if(e?.(i,t++))break;yield i}catch{break}}finally{de(this,_e)}}destroy(){this.isDestroyed||(this.#t?.(),this.#t=void 0,g(this,pe,this),de(this,_e),A(this),this.lastValue=void 0,this.isDestroyed=!0,Object.freeze(this))}get isMuted(){return this.#e}mute(){return!this.isDestroyed&&!this.#e&&(this.#e=!0,g(this,us,this)),this}unmute(){return!this.isDestroyed&&this.#e&&(this.#e=!1,g(this,ds,this)),this}toggleMute(){return this.isDestroyed||(this.#e=!this.#e,g(this,this.#e?us:ds,this)),this.#e}updateValue(e){if(!this.#e&&!this.isDestroyed){let{value:t}=this.source;e(t),g(this,_e,t),this.lastValue=t}}},ps=class extends Mt{target;constructor(e,t){super(e),this.target=R(t),C(fe,this.target.id,()=>this.destroy()),this.touch()}touch(){return this.updateValue(e=>{this.target.writer(e,{touch:!0})}),this}write(){this.updateValue(e=>{this.target.writer(e)})}},gs=class extends Mt{target;constructor(e,t){super(e),this.target=t,this.touch()}touch(){return this.updateValue(e=>{this.target(e)}),this}write(){this.updateValue(e=>{this.target(e)})}},Rt=new Map;function $(s,e,t){let i=R(s),r=R(e),n=r??e,o;if(Rt.has(i)){if(o=Rt.get(i),o.has(n))return o.get(n)}else o=new Map,Rt.set(i,o);let a=r!=null?new ps(s,r):new gs(s,e),f=t?.attach;return f&&a.attach(f),o.set(n,a),C(a,pe,()=>{o.delete(n),o.size===0&&Rt.delete(i)}),a}var Lt=class s{static fromProps(e,t){let i=new s,r=t?t.map(n=>[n,e[n]]):Object.entries(e);for(let[n,o]of r)i.#e.set(n,y(o));return i}#e=new Map;keys(){return this.#e.keys()}signals(){return this.#e.values()}entries(){return this.#e.entries()}clear(){for(let e of this.#e.values())e.destroy();this.#e.clear()}has(e){return this.#e.has(e)}get(e){if(!this.#e.has(e)){let t=y();return this.#e.set(e,t),t}return this.#e.get(e)}update(e){e.size&&W(()=>{for(let[t,i]of e.entries())this.get(t).set(i)})}updateFromProps(e,t){W(()=>{let i=t?t.map(r=>[r,e[r]]):Object.entries(e);for(let[r,n]of i)this.get(r).set(n)})}};var ne=(s=>(s[s.StructuralChanges=1]="StructuralChanges",s[s.ContentUpdates=2]="ContentUpdates",s[s.Removal=3]="Removal",s))(ne||{}),E=(s=>(s[s.CreateEntities=1]="CreateEntities",s[s.DestroyEntities=2]="DestroyEntities",s[s.SetParent=3]="SetParent",s[s.UpdateOrder=4]="UpdateOrder",s[s.ChangeProperties=5]="ChangeProperties",s[s.ChangeToken=6]="ChangeToken",s[s.SendEvents=7]="SendEvents",s))(E||{}),Pe=Symbol.for("ShadowEntsGlobalNS"),F="#void",gi="contextLost",yi="configure",vi="changeTrail",mi="destroy",bi="loaded",wi="appliedChangeTrail",Ei="importedModule",Ci="destroyed",$e="messageToView",Si=6e4,ki=6e4,Ai=5e3,Pi=5e3,ys="shadowObjects";function Ti(s,e){s.indexOf(e)===-1&&s.push(e)}function vs(s,e){let t=s.indexOf(e);t!==-1&&s.splice(t,1),s.push(e)}function oe(s,e){let t=s.indexOf(e);t!==-1&&s.splice(t,1)}var Te=s=>typeof s=="string"?s.trim()||Pe:typeof s=="symbol"?s:Pe;var Xe="#root",Ze=class{#e;get uuid(){return this.#e}#t=0;constructor(e){this.#e=e}#s=!0;#i=0;#r=0;hasChanges(){return this.#t>0}get isNew(){return this.#s}get isCreated(){return this.#i>0&&this.#i>this.#r}get isDestroyed(){return this.#r>0&&this.#r>=this.#i}#n=F;#a;#o=0;#h=!1;#l;#u;#c;create(e=F,t,i=0,r=!1){this.#t++,this.#i++,this.#l=e,this.#u=t??Xe,this.#c=i||void 0,this.#h=r}destroy(){this.#r++,this.#t++}clear(){this.#t=0,this.#s=!1,this.#l=void 0,this.#u=void 0,this.#c=void 0,this.#p.clear(),this.#g.length=0,this.#d.length=0,this.#f.clear()}changeToken(e){e??=F,e===this.#n?this.#l=this.#s?e:void 0:(this.#l=e,this.#t++)}setParent(e){e===this.#a?this.#u=void 0:(this.#u=e??Xe,this.#t++)}changeOrder(e){e===this.#o?this.#c=void 0:(this.#c=e,this.#t++)}#y=new Map;#p=new Map;#g=[];changeProperty(e,t,i){let r=this.#y.get(e),n=i==null&&t!==r||i!=null&&!i(t,r);return n?(this.#p.set(e,t),vs(this.#g,e),this.#t++):(this.#p.delete(e),oe(this.#g,e)),n}removeProperty(e){let t=this.#y.has(e);this.#p.has(e)?(this.#p.delete(e),t||oe(this.#g,e)):t&&(vs(this.#g,e),this.#t++)}#d=[];#f=new Set;createEvent(e,t,i){this.#d.push({type:e,data:t});for(let r of i??[])this.#f.add(r);this.#t++}transferEventsTo(e){this.#d.length>0&&(e.#d.push(...this.#d),this.#d.length=0),this.#f.size>0&&(e.#f=new Set([...e.#f,...this.#f]),this.#f.clear())}buildChangeTrail(e,t){let{isNew:i,isCreated:r,isDestroyed:n}=this;if(!(i&&n))switch(t){case ne.StructuralChanges:i?e.push(this.makeCreateEntityChange()):n||(this.#u!==void 0&&!(this.#u===Xe&&this.#a===void 0)?e.push(this.makeSetParentChange()):this.#c!==void 0&&this.#c!==this.#o&&e.push(this.makeUpdateOrderChange()),this.#l!==void 0&&this.#l!==this.#n&&e.push(this.makeChangeToken()));break;case ne.ContentUpdates:!i&&r&&this.#g.length>0&&e.push(this.makeChangePropertyChange()),this.#d.length>0&&e.push(this.makeEvents());break;case ne.Removal:n&&e.push(this.makeDestroyEntityChange());break}}makeEvents(){let e={type:E.SendEvents,uuid:this.#e,events:this.#d.slice(0)};return this.#f.size>0&&(e.transferables=Array.from(this.#f)),e}makeCreateEntityChange(){let e=this.#l??this.#n,t={type:E.CreateEntities,uuid:this.#e,token:e};if(this.#n=e,this.#u!==void 0){let i=this.#u===Xe?void 0:this.#u;this.#a=i,i!==void 0&&(t.parentUuid=i)}if(this.#p.size>0){t.properties=Array.from(this.#p.entries()).filter(([,i])=>i!==void 0);for(let[i,r]of t.properties)this.#y.set(i,r)}return this.#c!==void 0&&this.#c!==this.#o&&(t.order=this.#o=this.#c),this.#h&&(t.autoDestructionOnParentRemoval=!0),t}makeDestroyEntityChange(){return{type:E.DestroyEntities,uuid:this.#e}}makeSetParentChange(){this.#a=this.#u===Xe?void 0:this.#u;let e={type:E.SetParent,uuid:this.#e,parentUuid:this.#a};return this.#c!==void 0&&this.#c!==this.#o&&(e.order=this.#o=this.#c),e}makeUpdateOrderChange(){return this.#o=this.#c??0,{type:E.UpdateOrder,uuid:this.#e,order:this.#o}}makeChangeToken(){return this.#n=this.#l??F,{type:E.ChangeToken,uuid:this.#e,token:this.#n}}makeChangePropertyChange(){let e=this.#g.map(t=>{if(this.#p.has(t)){let i=this.#p.get(t);return i===void 0?this.#y.delete(t):this.#y.set(t,i),[t,i]}else return this.#y.delete(t),[t,void 0]});return{type:E.ChangeProperties,uuid:this.#e,properties:e}}};var xi=s=>{if(!(s===void 0||s.length===0))return s.filter(e=>e.length===1||e[1]!==void 0)},ms=(s,e)=>{if(s===e||e===void 0)return s;if(s===void 0)return xi(e);for(let[t,i]of e){let r=s.find(([n])=>n===t);r===void 0?s.push([t,i]):r[1]=i}return xi(s)};var Dt=class{#e=new Map;get[Symbol.iterator](){return this.#e.entries.bind(this.#e)}clear(){this.#e.clear()}isEmpty(){return this.#e.size===0}hasComponentState(e){return this.#e.has(e)}getComponentState(e){return this.#e.get(e)}write(e){for(let t of e)if(t.type===E.CreateEntities)this.createEntity(t);else if(this.#e.has(t.uuid))switch(t.type){case E.DestroyEntities:this.destroyEntity(t);break;case E.SetParent:this.setParent(t);break;case E.UpdateOrder:this.updateOrder(t);break;case E.ChangeToken:this.changeToken(t);break;case E.ChangeProperties:this.changeProperties(t);break}}changeProperties({uuid:e,properties:t}){let i=this.getComponentState(e);i.properties=ms(i.properties,t)}changeToken({uuid:e,token:t}){this.getComponentState(e).token=t||F}updateOrder({uuid:e,order:t}){this.getComponentState(e).order=t??0}setParent({uuid:e,parentUuid:t,order:i}){let r=this.getComponentState(e);r.parentUuid=t,i!==void 0&&(r.order=i)}destroyEntity({uuid:e}){this.#e.delete(e)}createEntity({uuid:e,token:t,parentUuid:i,order:r,properties:n,autoDestructionOnParentRemoval:o}){this.#e.set(e,{token:t||F,parentUuid:i,order:r??0,properties:ms(void 0,n),...o?{autoDestructionOnParentRemoval:!0}:{}})}};var et=class extends Error{constructor(e="the component context has been disposed"){super(e),this.name="ComponentContextDisposedError"}},I=class s{static{this.ReRequestParentRoots="re-request-parent-roots"}static getContextsMap(){return globalThis.__shadowEntsContexts==null&&(globalThis.__shadowEntsContexts=new Map),globalThis.__shadowEntsContexts}static get(e){let t=Te(e),i=s.getContextsMap();return i.has(t)?i.get(t):new s(t)}#e=new Map;#t=[];#s=!1;#i=new Dt;constructor(e=Pe){let t=Te(e),i=s.getContextsMap();if(i.has(t))return i.get(t);this.ns=t,i.set(t,this)}get isDisposed(){return this.#s}addComponent(e){if(this.#s)throw new et(`the view component ${e.uuid} cannot join the component context because it has been disposed`);let t=this.#e.get(e.uuid);if(t){if(t.component!==e)for(let i of t.children.slice(0))this.#e.get(i)?.component.removeFromParent();t.component=e,t.children=[]}else t={component:e,children:[],changes:new Ze(e.uuid),propIsEqual:void 0},this.#e.set(e.uuid,t);t.changes.create(e.token,e.parent?.uuid,e.order,e.autoDestructionOnParentRemoval),e.parent?(this.addToChildren(e.parent,e),t.changes.setParent(e.parent.uuid)):this.#o(e,this.#t),this.#h=void 0}hasComponent(e){return this.#e.has(e.uuid)}hasComponents(){return this.#e.size>0}isRootComponent(e){return this.#t.includes(e.uuid)}destroyComponent(e){if(this.hasComponent(e)){let t=this.#e.get(e.uuid);for(let i of t.children.slice(0))this.#e.get(i)?.component.removeFromParent();t.changes.destroy(),this.#h=void 0}}getChildren(e){return this.#e.get(e.uuid)?.children.map(t=>this.#e.get(t).component)??[]}removeFromParent(e,t){if(this.hasComponent(t)){let i=this.#e.get(e);if(i===void 0)return;let r=this.#e.get(t.uuid),n=r.children.indexOf(e);n!==-1&&(r.children.splice(n,1),i.changes.setParent(void 0)),this.#o(i.component,this.#t),this.#h=void 0}}moveToRoot(e){let t=this.#e.get(e);t&&(t.changes?.setParent(void 0),this.#o(t.component,this.#t)),this.#h=void 0}changeToken(e,t){this.#e.get(e.uuid)?.changes.changeToken(t)}isChildOf(e,t){return this.hasComponent(t)?this.#e.get(t.uuid).children.includes(e.uuid):!1}addToChildren(e,t){let i=this.#e.get(e.uuid);if(i)this.#o(t,i.children),this.#e.get(t.uuid)?.changes.setParent(e.uuid),oe(this.#t,t.uuid),this.#h=void 0;else throw new Error(`the view component ${e.uuid} cannot have a child added to it because the component do not exist!`)}removeSubTree(e){this.#r(e,new Set)}#r(e,t){if(t.has(e))return;t.add(e);let i=this.#e.get(e);if(i){for(let r of i.children.slice(0))this.#r(r,t);this.destroyComponent(i.component),this.#n(e)}}setProperty(e,t,i,r){let n=this.#e.get(e.uuid);return n!=null?(r!=null?(n.propIsEqual??=new Map,n.propIsEqual.set(t,r)):n.propIsEqual?.has(t)&&n.propIsEqual.delete(t),n.changes.changeProperty(t,i,r)):!1}removeProperty(e,t){this.#e.get(e.uuid)?.changes.removeProperty(t)}changeOrder(e){let t=this.#e.get(e.uuid);if(t===void 0)return;let i=e.parent?this.#e.get(e.parent.uuid):void 0;i!==void 0?(oe(i.children,e.uuid),this.#o(e,i.children)):e.parent==null&&(oe(this.#t,e.uuid),this.#o(e,this.#t)),t.changes.changeOrder(e.order),this.#h=void 0}traverseLevelOrderBFS(){return this.#l().map(e=>e.component)}dispatchShadowObjectsEvent(e,t,i,r){this.#e.get(e.uuid)?.changes.createEvent(t,i,r)}broadcastEvent(e,t=void 0){for(let i of this.traverseLevelOrderBFS())i.dispatchEvent(e,t,!1)}dispatchMessage(e,t,i=void 0,r=!1){this.#e.get(e)?.component.dispatchEvent(t,i,r)}dispatchReRequestParentRoots(){for(let e of this.#t)this.dispatchMessage(e,s.ReRequestParentRoots)}buildChangeTrails(e=!0){let t=[];if(!this.hasComponents())return t;let i=this.#a();for(let r of i)r.buildChangeTrail(t,ne.StructuralChanges);for(let r of i)r.buildChangeTrail(t,ne.ContentUpdates);for(let r of i)r.buildChangeTrail(t,ne.Removal),(r.isDestroyed||r.isNew&&!r.isCreated)&&this.#n(r.uuid),e&&r.clear();return this.#i.write(t),t}reCreateChanges(){if(!this.#i.isEmpty()){this.buildChangeTrails(!1);for(let[e,t]of this.#i){let i=this.#e.get(e);if(i){let r=new Ze(e);if(r.create(t.token,t.parentUuid,t.order,t.autoDestructionOnParentRemoval),t.properties)for(let[n,o]of t.properties)r.changeProperty(n,o,i.propIsEqual?.get(n));i.changes.transferEventsTo(r),i.changes.clear(),i.changes=r}}this.#i.clear(),this.broadcastEvent(gi)}}clear(){this.#h=void 0,this.#i.clear();for(let e of this.#t.slice(0))this.removeSubTree(e);if(this.#t.length!==0)throw new Error("component-context panic: #rootComponents is not empty!");if(this.#e.size!==0)throw new Error("component-context panic: #components is not empty!")}dispose(){if(this.#s)return;for(let{component:t}of Array.from(this.#e.values()))t.destroy();this.clear(),this.#s=!0;let e=s.getContextsMap();this.ns!=null&&e.get(this.ns)===this&&e.delete(this.ns)}#n(e){let t=this.#e.get(e);if(t===void 0)return;let i=t.component.parent?.uuid;if(i!==void 0){let r=this.#e.get(i);r!==void 0&&oe(r.children,e)}this.#e.delete(e),oe(this.#t,e),this.#h=void 0}#a(){return this.#l().filter(e=>e.changes.hasChanges()).map(e=>e.changes)}#o(e,t){if(t.includes(e.uuid))return;let{order:i}=e;for(let r=0;r<t.length;r++){let n=this.#e.get(t[r])?.component;if(n!==void 0&&i<n.order){t.splice(r,0,e.uuid);return}}t.push(e.uuid)}#h;#l(){if(this.#h)return this.#h;let e=new Map,t=(i,r)=>{let n=this.#e.get(i);if(n==null)return;let o=e.get(r);o?o.push(n):e.set(r,[n]);for(let a of n.children)t(a,r+1)};for(let i of this.#t)t(i,0);return this.#h=Array.from(e.entries()).sort((i,r)=>i[0]-r[0]).flatMap(([,i])=>i),this.#h}};function tt(s){return function(e,t){let i=s?.name||t.name,r=!!(s?.readAsValue??!1);return{get(){let n=G(this,i);if(n)return r?n.value:n.get()},set(n){G(this,i)?.set(n)},init(n){let o=y(n,s);return fi(this,i,o),re.findOrCreate(this).attachSignalByName(i,o),o.value}}}}var V="ConsoleLogger",U=`${V}Storage`,Vr=!!(globalThis.location?.host?.startsWith("localhost")??!1),it="localStorage"in globalThis,Nt=Symbol.for(V),Oi=!1,Ri=s=>{if(typeof s=="boolean")return s;switch(s.toLowerCase()){case"true":case"yes":case"on":return!0;default:return!1}},ws=s=>[it?V:void 0,...Array.isArray(s)?s:[s]].filter(Boolean).join(".");function bs(s,e,t){let i=ws(s),r=it?localStorage.getItem(i):globalThis[U]?.[i];return r==null?t:e?e(r):r}function st(s,e){it?localStorage.setItem(ws(s),e):(globalThis[U]==null&&(globalThis[U]={},console.debug(`${V}: Initialize`,{[U]:globalThis[U]})),globalThis[U][ws(s)]=e)}var N=class s{constructor(e){this.enable=!0,this.namespace=(e||"").trim()||V,Oi||(s.loadConfig(),Oi=!0);let t=[this.namespace,"enable"];this.enable=bs(t,Ri,this.enable),st(t,it?this.enable?"true":"false":this.enable)}static{this.sharedConfig={enable:Vr,debug:!1,info:!0,warn:!0,"styles.debug":"color: #111; background: #999; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.info":"color: #020; background: #8a8; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.warn":"color: #fa0; background: #a98; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.error":"color: #ff0; background: #a00; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em"}}static get isEnabled(){return s.sharedConfig.enable}static get isDebug(){return s.sharedConfig.enable&&s.sharedConfig.debug}static{this.sharedStyles={get debug(){return s.sharedConfig["styles.debug"]},set debug(e){s.sharedConfig["styles.debug"]=e},get info(){return s.sharedConfig["styles.info"]},set info(e){s.sharedConfig["styles.info"]=e},get warn(){return s.sharedConfig["styles.warn"]},set warn(e){s.sharedConfig["styles.warn"]=e},get error(){return s.sharedConfig["styles.error"]},set error(e){s.sharedConfig["styles.error"]=e}}}static loadConfig(){it?(["enable","debug","info","warn"].forEach(e=>{this.sharedConfig[e]=bs(e,Ri,this.sharedConfig[e])}),["debug","info","warn","error"].forEach(e=>{this.sharedStyles[e]=bs(["styles",e],void 0,this.sharedStyles[e])}),s.isDebug&&console.debug(`${V}: Load config from localStorage`,s.sharedConfig),globalThis[V]?.[Nt]||(globalThis[V]??={[Nt]:!0,get enable(){return s.sharedConfig.enable},set enable(e){s.sharedConfig.enable=e,st("enable",e?"true":"false")},get debug(){return s.sharedConfig.debug},set debug(e){s.sharedConfig.debug=e,st("debug",e?"true":"false")},get info(){return s.sharedConfig.info},set info(e){s.sharedConfig.info=e,st("info",e?"true":"false")},get warn(){return s.sharedConfig.warn},set warn(e){s.sharedConfig.warn=e,st("warn",e?"true":"false")}})):globalThis[U]?.[Nt]||(globalThis[U]={[Nt]:!0,...s.sharedConfig,...globalThis[U]},s.sharedConfig=globalThis[U],s.isDebug&&console.debug(`${V}: Load config from ${U}`,globalThis[U]))}get isEnabled(){return this.enable&&s.sharedConfig.enable}get isDebug(){return this.isEnabled&&s.sharedConfig.debug}get isInfo(){return this.isEnabled&&s.sharedConfig.info}get isWarn(){return this.isEnabled&&s.sharedConfig.warn}debug(...e){this.#e("debug",s.sharedStyles.debug,e)}info(...e){this.#e("info",s.sharedStyles.info,e)}warn(...e){this.#e("warn",s.sharedStyles.warn,e)}error(...e){this.#e("error",s.sharedStyles.error,e)}#e(e,t,i){console[e](`%c${this.namespace}`,t,...i)}};var Br=Object.create,ks=Object.defineProperty,Gr=Object.getOwnPropertyDescriptor,Li=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),ze=s=>{throw TypeError(s)},qr=(s,e,t)=>e in s?ks(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mi=(s,e)=>ks(s,"name",{value:e,configurable:!0}),Hr=s=>[,,,Br(s?.[Li("metadata")]??null)],Di=["class","method","getter","setter","accessor","field","value","get","set"],rt=s=>s!==void 0&&typeof s!="function"?ze("Function expected"):s,Qr=(s,e,t,i,r)=>({kind:Di[s],name:e,metadata:i,addInitializer:n=>t._?ze("Already initialized"):r.push(rt(n||null))}),Ni=(s,e)=>qr(e,Li("metadata"),s[3]),_t=(s,e,t,i)=>{for(var r=0,n=s[e>>1],o=n&&n.length;r<o;r++)e&1?n[r].call(t):i=n[r].call(t,i);return i},_i=(s,e,t,i,r,n)=>{var o,a,f,m,P,c=e&7,D=!!(e&8),w=!!(e&16),O=c>3?s.length+1:c?D?1:2:0,le=Di[c+5],u=c>3&&(s[O-1]=[]),l=s[O]||(s[O]=[]),h=c&&(!w&&!D&&(r=r.prototype),c<5&&(c>3||!w)&&Gr(c<4?r:{get[t](){return v(this,n)},set[t](d){return k(this,n,d)}},t));c?w&&c<4&&Mi(n,(c>2?"set ":c>1?"get ":"")+t):Mi(r,t);for(var p=i.length-1;p>=0;p--)m=Qr(c,t,f={},s[3],l),c&&(m.static=D,m.private=w,P=m.access={has:w?d=>Kr(r,d):d=>t in d},c^3&&(P.get=w?d=>(c^1?v:xe)(d,r,c^4?n:h.get):d=>d[t]),c>2&&(P.set=w?(d,_)=>k(d,r,_,c^4?n:h.set):(d,_)=>d[t]=_)),a=(0,i[p])(c?c<4?w?n:h[le]:c>4?void 0:{get:h.get,set:h.set}:r,m),f._=1,c^4||a===void 0?rt(a)&&(c>4?u.unshift(a):c?w?n=a:h[le]=a:r=a):typeof a!="object"||a===null?ze("Object expected"):(rt(o=a.get)&&(h.get=o),rt(o=a.set)&&(h.set=o),rt(o=a.init)&&u.unshift(o));return c||Ni(s,r),h&&ks(r,t,h),w?c^4?n:h:r},As=(s,e,t)=>e.has(s)||ze("Cannot "+t),Kr=(s,e)=>Object(e)!==e?ze('Cannot use the "in" operator on this value'):s.has(e),v=(s,e,t)=>(As(s,e,"read from private field"),t?t.call(s):e.get(s)),j=(s,e,t)=>e.has(s)?ze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),k=(s,e,t,i)=>(As(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),xe=(s,e,t)=>(As(s,e,"access private method"),t),Wi,$i,L,X,Oe,Re,je,ae,ve,Ps,Ts,Z,Fe,Wt,ge,Es,Cs,Ss,Fi,ji,me=class extends Error{constructor(e="the shadow environment has been destroyed"){super(e),this.name="ShadowEnvDestroyedError"}};$i=[tt()],Wi=[tt()];var ee=class ye{constructor(){j(this,ge),j(this,L),j(this,X),j(this,Oe,!1),j(this,Re,!1),j(this,je,!1),j(this,ae),this.logger=new N("ShadowEnv"),this.ns$=y(),j(this,Ps,_t(ve,8,this,!1)),_t(ve,11,this),j(this,Ts,_t(ve,12,this,!1)),_t(ve,15,this),j(this,Z,!1),j(this,Fe),j(this,Wt),this.ready=async()=>{if(v(this,Z))throw new me;return this.isReady?this:Promise.race([St(this,ye.ContextCreated),xe(this,ge,Es).call(this)])},j(this,Cs,()=>{v(this,Oe)&&xe(this,ge,Ss).call(this)});let e=this;Y(e,ye.ContextCreated),b(e,ye.ContextLost,K.AAA,()=>{de(e,ye.ContextCreated)}),S(()=>{if(this.viewReady&&this.proxyReady)return this.view.reCreateChanges(),g(e,ye.ContextCreated,e),v(this,Re)&&(k(this,Re,!1),xe(this,ge,Ss).call(this)),()=>{g(e,ye.ContextLost,e)}},[G(this,"viewReady"),G(this,"proxyReady")])}static get(e){if(e!=null)return globalThis.__shadowEnvs?.get(e)}get isDestroyed(){return v(this,Z)}get view(){return v(this,L)}set view(e){e!==v(this,L)&&(v(this,L)?.ns&&globalThis.__shadowEnvs&&globalThis.__shadowEnvs.delete(v(this,L).ns),k(this,L,e??void 0),v(this,L)?.ns&&(globalThis.__shadowEnvs??=new Map,globalThis.__shadowEnvs.has(v(this,L).ns)&&globalThis.__shadowEnvs.get(v(this,L).ns)!==this&&this.logger.isWarn&&this.logger.warn("overwrite a namespace already in use",v(this,L).ns,globalThis.__shadowEnvs.get(v(this,L).ns)),globalThis.__shadowEnvs.set(v(this,L).ns,this)),this.viewReady=!!e)}get envProxy(){return v(this,X)}set envProxy(e){if(e!==v(this,X)){let t=v(this,X);k(this,X,e??void 0),v(this,X)&&(v(this,X).onMessageToView=xe(this,ge,Fi).bind(this),v(this,X).onProxyFailed=xe(this,ge,ji).bind(this)),t&&t.destroy(),this.proxyReady=!1,e?.start().then(()=>{this.proxyReady=!0}).catch(i=>{this.logger.error("failed to start envProxy",i),this.proxyReady=!1})}}get isReady(){return!!(v(this,L)&&v(this,X)&&this.proxyReady&&!this.isDestroyed)}sync(){if(!v(this,Z)){if(!this.isReady){k(this,Re,!0);return}v(this,Oe)||(k(this,Oe,!0),queueMicrotask(v(this,Cs)))}}syncWait(){return v(this,Z)?Promise.reject(new me):(k(this,je,!0),this.sync(),v(this,ae)?v(this,ae):(k(this,ae,Promise.race([St(this,ye.AfterSync),xe(this,ge,Es).call(this)]).then(e=>(k(this,ae,void 0),e),e=>{throw k(this,ae,void 0),e})),v(this,ae)))}destroy(){var e;if(v(this,Z))return;k(this,Z,!0),k(this,Oe,!1),k(this,Re,!1),k(this,je,!1);let t=v(this,L)?.ns;this.envProxy=void 0,this.view=void 0;let i=globalThis.__shadowEnvs;t&&i?.get(t)===this&&i.delete(t),(e=v(this,Wt))==null||e.call(this,new me),k(this,ae,void 0),Je(this),A(this),Object.freeze(this)}};ve=Hr(null);L=new WeakMap;X=new WeakMap;Oe=new WeakMap;Re=new WeakMap;je=new WeakMap;ae=new WeakMap;Ps=new WeakMap;Ts=new WeakMap;Z=new WeakMap;Fe=new WeakMap;Wt=new WeakMap;ge=new WeakSet;Es=function(){return v(this,Fe)==null&&(k(this,Fe,new Promise((s,e)=>{k(this,Wt,e)})),v(this,Fe).catch(()=>{})),v(this,Fe)};Cs=new WeakMap;Ss=async function(){if(k(this,Oe,!1),v(this,Z))return;if(!this.isReady){k(this,Re,!0);return}let s=this.view.buildChangeTrails(),e=v(this,je);k(this,je,!1);try{s.length>0&&await this.envProxy.applyChangeTrail(s,e)}catch(t){this.logger.error("failed to apply change trail",t)}finally{g(this,ee.AfterSync,s)}};Fi=function(s){this.logger.isDebug&&this.logger.debug("onMessageToView",s.type,s.data),this.view?.dispatchMessage(s.uuid,s.type,s.data,s.traverseChildren)};ji=function(s){if(!v(this,Z)){this.logger.error("the environment proxy failed",s);try{g(this,ee.ProxyFailed,s,this)}finally{this.proxyReady=!1}}};_i(ve,4,"viewReady",$i,ee,Ps);_i(ve,4,"proxyReady",Wi,ee,Ts);Ni(ve,ee);ee.AfterSync="afterSync";ee.ContextLost="contextLost";ee.ContextCreated="contextCreated";ee.ProxyFailed="proxyFailed";var B=ee;var x=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Yr=()=>{let s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(x[s&255]+x[s>>8&255]+x[s>>16&255]+x[s>>24&255]+"-"+x[e&255]+x[e>>8&255]+"-"+x[e>>16&15|64]+x[e>>24&255]+"-"+x[t&63|128]+x[t>>8&255]+"-"+x[t>>16&255]+x[t>>24&255]+x[i&255]+x[i>>8&255]+x[i>>16&255]+x[i>>24&255]).toLowerCase()},zi=()=>globalThis?.crypto?.randomUUID?.()??Yr();var Ie=class extends Error{constructor(e){super(e),this.name="ViewComponentError"}};function Ii(s,e){if(s.context==null)throw new Ie("cannot add a child to a destroyed view component");if(s.context!==e)throw new Ie("cannot add a child from another context")}var $t=class s{#e;#t;#s;#i;#r=0;#n;get uuid(){return this.#e}get token(){return this.#t}set token(e){e??=F,e!==this.#t&&(this.#t=e,this.#s?.changeToken(this,e))}get parent(){return this.#i}set parent(e){e?e.addChild(this):this.removeFromParent()}get context(){return this.#s}set context(e){let t=e??void 0;if(this.#s!==t){if(t?.isDisposed)throw new et(`the view component ${this.#e} cannot join the component context because it has been disposed`);this.#s&&this.destroy(),this.#s=t;try{t?.addComponent(this)}catch(i){throw this.#s=void 0,i}}}get isDestroyed(){return this.#s==null}get order(){return this.#r}set order(e){let t=this.#r;this.#r=e??0,t!==this.#r&&this.#s?.changeOrder(this)}get autoDestructionOnParentRemoval(){return this.#n}constructor(e,t){T(this),t instanceof s&&(t={parent:t}),this.#e=t?.uuid??zi(),this.#t=e??F,this.#r=t?.order??0,this.#i=t?.parent,this.#n=t?.autoDestructionOnParentRemoval??!1;let i=t?.context??I.get();this.#i&&Ii(this.#i,i),this.context=i}isChildOf(e){return this.#i===e}removeFromParent(){this.#i?(this.#s?.removeFromParent(this.uuid,this.#i),this.#i=void 0):this.#s?.moveToRoot(this.uuid)}addChild(e){if(e.#s==null)throw new Ie("cannot add a destroyed view component as a child");Ii(this,e.#s);for(let t=this;t!=null;t=t.#i)if(t===e)throw new Ie("cannot add the component itself or one of its ancestors as a child: this would create a cycle");e.isChildOf(this)||(e.removeFromParent(),e.#i=this,this.#s.addToChildren(this,e))}setProperty(e,t,i){return this.#s?.setProperty(this,e,t,i)??!1}removeProperty(e){this.#s?.removeProperty(this,e)}dispatchShadowObjectsEvent(e,t,i){this.#s?.dispatchShadowObjectsEvent(this,e,t,i)}dispatchEvent(e,t,i){if(g(this,e,t),i)for(let r of this.#s?.getChildren(this)??[])r.dispatchEvent(e,t,i)}destroy(){this.removeFromParent(),this.#s?.destroyComponent(this),this.#s=void 0}};var nt=new Set(["on","true","yes","local","1"]);var Ui=s=>Te(s.getAttribute("ns")??void 0),at=(s,e)=>{if(s.hasAttribute(e)){let t=s.getAttribute(e)?.trim()?.toLowerCase()||"1";return nt.has(t)}return!1};var Vi=(s,e)=>{e.set(Ui(s))},xs=new Set,Os=!1,Jr=s=>{xs.add(s),Os||(Os=!0,queueMicrotask(()=>{Os=!1;for(let e of xs)B.get(e)?.sync();xs.clear()}))},be=class extends HTMLElement{constructor(){super(),this.isShaeElement=!0,this.ns$=y(Pe),this.ns$.onChange(e=>{typeof e=="string"&&e.length>0?this.getAttribute("ns")!==e&&this.setAttribute("ns",e):this.removeAttribute("ns")}),Vi(this,this.ns$)}static{this.observedAttributes=["ns"]}get ns(){return this.ns$.value}set ns(e){typeof e=="symbol"?this.ns$.set(e):this.ns$.set(Te(e))}attributeChangedCallback(e){e==="ns"&&Vi(this,this.ns$)}syncShadowObjects(){Jr(this.ns)}};var Ft=class extends be{constructor(){super(),this.isShaeEntElement=!0,this.componentContext$=y(),this.viewComponent$=y(),this.token$=y(),this.forwardCustomEvents$=y(!1),this.#n=!0,this.#y=()=>{let e=this.findShadowRootHost();e!=null&&this.dispatchEvent(new CustomEvent(gt,{bubbles:!0,composed:!0,detail:{requester:this,shadowRootHost:e}}))},this.#p=e=>{let t=e.detail?.requester;if(t===this||!t?.isShaeEntElement||t.ns!==this.ns)return;e.detail?.shadowRootHost&&this.#l()},this.#g=e=>{let t=e.detail?.requester;t!==this&&t?.isShaeEntElement&&t.ns===this.ns&&(e.stopPropagation(),t.#c(this))},this.ns$.onChange(e=>{this.componentContext$.set(I.get(e)),this.isConnected&&this.#l()}),this.#d(),this.token$.onChange(e=>{e==null?this.removeAttribute(ce):this.getAttribute(ce)!==e&&this.setAttribute(ce,e)}),this.#f(),this.forwardCustomEvents$.onChange(e=>{if(!e)this.removeAttribute(q);else if(e===!0)this.hasAttribute(q)||this.setAttribute(q,"");else{let t=Array.from(e).join(",");this.getAttribute(q)!==t&&this.setAttribute(q,t)}}),S(()=>{let e=this.viewComponent$.get();if(e){let t=b(e,I.ReRequestParentRoots,()=>this.#h()),i=e.context?.ns;return()=>{t(),e.destroy(),i&&i!==this.ns?B.get(i)?.sync():this.syncShadowObjects()}}}),S(()=>{let e=this.viewComponent$.get();if(!e)return;let t=Object.hasOwn(e,"dispatchEvent")?Object.getPrototypeOf(e).dispatchEvent:e.dispatchEvent,i=this.forwardCustomEvents$.get();if(!i)return;let r=i instanceof Set?i:void 0,n=(o,a,f)=>{t.call(e,o,a,f),o!==I.ReRequestParentRoots&&(r&&!r.has(o)||this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:a})))};return Object.defineProperty(e,"dispatchEvent",{value:n,writable:!0,configurable:!0}),()=>{Object.hasOwn(e,"dispatchEvent")&&e.dispatchEvent===n&&delete e.dispatchEvent}}),this.token$.onChange(e=>{let t=this.viewComponent$.value;t&&(t.token=e,this.syncShadowObjects())}),this.style.display="contents"}static{this.observedAttributes=[...be.observedAttributes,ce,q]}get componentContext(){return this.componentContext$.value}get viewComponent(){return this.viewComponent$.value}get uuid(){return this.viewComponent?.uuid}get token(){return this.token$.value}set token(e){this.token$.set(e)}#e;#t;#s(){this.#t?.();let e=this.componentContext$.onChange(t=>{let i=this.token$.value,r=this.viewComponent$.value;r?r.context=t:t&&(r=new $t(i??F,{context:t}),this.viewComponent$.set(r)),this.syncShadowObjects()});this.#t=()=>{e()}}#i(){this.#t?.(),this.#t=void 0}#r;#n;findShadowRootHost(){if(this.#n){this.#n=!1;let e=this;for(;e;){if(e.parentElement==null){let t=e.parentNode;t&&(this.#r=t.host);break}e=e.parentElement}}return this.#r}getParentNodeForObserver(){return this.parentNode??this.getRootNode()?.host??void 0}connectedCallback(){this.#n=!0,this.addEventListener("slotchange",this.#y,{capture:!1,passive:!1}),this.addEventListener(pt,this.#g,{capture:!1,passive:!1}),this.#s(),xt(()=>this.#d()),xt(()=>this.#f()),this.componentContext==null&&this.componentContext$.set(I.get(this.ns)),this.#l(),this.componentContext?.dispatchReRequestParentRoots(),this.#a(),this.syncShadowObjects()}#a(){this.#o();let e=this.getParentNodeForObserver();e&&(this.#e=new MutationObserver((t,i)=>{for(let{target:r,removedNodes:n}of t)if(r===e){for(let o of n)if(o===this){this.#o(),this.onParentChanged(this.getParentNodeForObserver(),e);break}}}),this.#e.observe(e,{childList:!0,subtree:!1,attributes:!1}))}onParentChanged(e,t){this.#c(void 0),this.#l()}#o(){this.#e?.disconnect(),this.#e=void 0}attributeChangedCallback(e){super.attributeChangedCallback(e),e===ce?this.#d():e===q&&this.#f()}disconnectedCallback(){this.#n=!0,this.#o(),this.removeEventListener("slotchange",this.#y,{capture:!1}),this.removeEventListener(pt,this.#g,{capture:!1}),this.#c(void 0),this.componentContext$.set(void 0),this.syncShadowObjects(),this.#i()}#h(){this.isConnected&&(this.#c(void 0),this.#l())}#l(){this.dispatchEvent(new CustomEvent(pt,{bubbles:!0,composed:!0,detail:{requester:this}}))}#u;#c(e){if(this.entParentNode!==e)if(this.entParentNode&&this.entParentNode.removeEventListener(gt,this.#p,{capture:!1}),this.entParentNode=e,this.entParentNode&&this.entParentNode.addEventListener(gt,this.#p,{capture:!1,passive:!1}),this.#u?.(),this.#u=void 0,e){let t=S(()=>{let i=this.viewComponent$.get();if(i){let r=e.viewComponent$.get();i.parent=r&&r.context===i.context?r:void 0,i.parent==null&&queueMicrotask(()=>{this.#l()}),this.syncShadowObjects()}});this.#u=()=>t.destroy()}else{let t=this.viewComponent;t?.parent&&(t.parent=void 0,this.syncShadowObjects())}}#y;#p;#g;#d(){if(this.hasAttribute(ce)){let e=this.getAttribute(ce)?.trim()||void 0;this.token$.set(e)}}#f(){if(this.hasAttribute(q)){let e=this.getAttribute(q);!e||e.trim().length===0?this.forwardCustomEvents$.set(!0):this.forwardCustomEvents$.set(new Set(e.split(",").map(t=>t.trim()).filter(t=>t.length>0)))}else this.forwardCustomEvents$.set(!1)}};customElements.define(yt,Ft);var Xr=s=>{let e=s.parentElement;for(;e;){if(e.isShaeEntElement)return e;e=e.parentElement}},Zr=new Set(["string","text","number","bigint","float","int","integer","hex","hexadecimal","oct","octal","bin","binary","bool","boolean","[]","text[]","string[]","number[]","float[]","int[]","integer[]","hex[]","hexadecimal[]","oct[]","octal[]","bin[]","binary[]","bool[]","boolean[]","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array","json"]),jt=class extends HTMLElement{constructor(){super(),this.isShaePropElement=!0,this.entNode$=y(),this.viewComponent$=y(),this.name$=y(),this.valueIn$=y(),this.valueOut$=y(),this.type$=y(),this.shouldTrim$=y(!0),this.logger=new N("ShaePropElement"),this.#e=()=>{this.entNode$.set(Xr(this))},this.#t=()=>{queueMicrotask(()=>{this.isConnected||this.entNode$.set(void 0)})},this.#s=()=>{this.name$.set(this.getAttribute(bt)?.trim()??void 0)},this.#i=()=>{this.valueIn$.set(this.getAttribute(wt))},this.#r=()=>{let e=this.getAttribute(Et)?.trim().toLowerCase();e&&!Zr.has(e)&&(this.logger.isWarn&&this.logger.warn(`[${this.name}] unknown type "${e}"`,{shaeProp:this}),e=void 0),this.type$.set(e)},this.#n=()=>{this.shouldTrim$.set(!at(this,Ct))},this.entNode$.onChange(e=>{if(e){let t=$(e.viewComponent$,this.viewComponent$);return()=>{t.destroy()}}else this.viewComponent$.set(void 0)}),S(()=>{let e=this.viewComponent$.get();if(e){let t=this.name$.get();if(t){let i=this.valueOut$.get();this.logger.isDebug&&this.logger.debug(`[${this.name}] view-component set-property`,t,i,e.uuid,{viewComponent:e,shaeProp:this}),e.setProperty(t,i),this.isConnected&&this.entNode?.syncShadowObjects()}}}),S(()=>{let e=this.type$.get(),t=this.shouldTrim$.get(),i=this.valueIn$.get();if(t&&typeof i=="string"&&(i=i.trim()),i=i||void 0,i!=null&&typeof i=="string"&&e)switch(e){case"string":case"text":break;case"number":i=Number(i);break;case"bigint":i=BigInt(i);break;case"float":i=parseFloat(i);break;case"int":case"integer":i=parseInt(i,10);break;case"hex":case"hexadecimal":i=parseInt(i,16);break;case"oct":case"octal":i=parseInt(i,8);break;case"bin":case"binary":i=parseInt(i,2);break;case"bool":case"boolean":i=nt.has(i.toLowerCase());break;case"[]":case"text[]":case"string[]":i=i.split(/\W+/);break;case"number[]":i=i.split(/\s+/).map(r=>Number(r));break;case"float[]":i=i.split(/\s+/).map(r=>parseFloat(r));break;case"int[]":case"integer[]":i=i.split(/\s+/).map(r=>parseInt(r,10));break;case"hex[]":case"hexadecimal[]":i=i.split(/\W+/).map(r=>parseInt(r,16));break;case"oct[]":case"octal[]":i=i.split(/\W+/).map(r=>parseInt(r,8));break;case"bin[]":case"binary[]":i=i.split(/\W+/).map(r=>parseInt(r,2));break;case"bool[]":case"boolean[]":i=i.split(/\W+/).map(r=>nt.has(r.toLowerCase()));break;case"int8array":i=new Int8Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint8array":i=new Uint8Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint8clampedarray":i=new Uint8ClampedArray(i.split(/\W+/).map(r=>Number(r)));break;case"int16array":i=new Int16Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint16array":i=new Uint16Array(i.split(/\W+/).map(r=>Number(r)));break;case"int32array":i=new Int32Array(i.split(/\W+/).map(r=>Number(r)));break;case"uint32array":i=new Uint32Array(i.split(/\W+/).map(r=>Number(r)));break;case"float32array":i=new Float32Array(i.split(/\s+/).map(r=>Number(r)));break;case"float64array":i=new Float64Array(i.split(/\s+/).map(r=>Number(r)));break;case"bigint64array":i=new BigInt64Array(i.split(/\W+/).map(r=>BigInt(r)));break;case"biguint64array":i=new BigUint64Array(i.split(/\W+/).map(r=>BigInt(r)));break;case"json":i=JSON.parse(i);break;default:this.logger.isWarn&&this.logger.warn(`[${this.name}] unknown type "${e}"`,{value:i,shaeProp:this})}this.valueOut$.set(i)}),W(()=>{this.#s(),this.#i(),this.#r(),this.#n()}),this.style.display="contents"}static{this.observedAttributes=[bt,wt,Et,Ct]}get name(){return this.name$.value}get value(){return this.valueOut$.value}set value(e){this.valueIn$.set(e)}get shouldTrim(){return this.shouldTrim$.value}get entNode(){return this.entNode$.value}set entNode(e){this.entNode$.set(e)}get viewComponent(){return this.viewComponent$.value}connectedCallback(){W(()=>{this.#e(),this.#s(),this.#i(),this.#r(),this.#n()})}attributeChangedCallback(e){switch(e){case bt:this.#s();break;case wt:this.#i();break;case Et:this.#r();break;case Ct:this.#n();break}}disconnectedCallback(){this.#t()}#e;#t;#s;#i;#r;#n};customElements.whenDefined(yt).then(()=>customElements.define(Vs,jt));var Rs=null,ht=class s{static{this.OnFrame=Symbol("onFrame")}#e=0;constructor(){if(Rs)return Rs;T(this),Rs=this}start(e){if(e!=null)return os(this)===0&&this.#s(),b(this,s.OnFrame,e),()=>{this.stop(e)}}stop(e){A(this,s.OnFrame,e),os(this)===0&&this.#i()}#t=e=>{g(this,s.OnFrame,e),this.#s()};#s(){this.#e=requestAnimationFrame(this.#t)}#i(){cancelAnimationFrame(this.#e),this.#e=0}};async function Ms(s,e,t,i=!0){if(t.has(e)){console.warn("importModule: skipping already imported module",e);return}else t.add(e);e.extends&&await Promise.all(e.extends.map(n=>Ms(s,n,t,!1)));let{registry:r}=s;if(e.define)for(let[n,o]of Object.entries(e.define))r.define(n,o);if(e.routes)for(let[n,o]of Object.entries(e.routes))r.appendRoute(n,o);await(e.initialize?.({define:(n,o)=>r.define(n,o),kernel:s,registry:r})??Promise.resolve()),i&&s.upgradeEntities()}var zt=s=>s??void 0;var Ls=Symbol("onCreate"),te=Symbol("onDestroy"),Bi=Symbol("onParentChanged"),It=Symbol("onViewEvent");var en=Object.create,Ds=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,Hi=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),Ve=s=>{throw TypeError(s)},sn=(s,e,t)=>e in s?Ds(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Gi=(s,e)=>Ds(s,"name",{value:e,configurable:!0}),rn=s=>[,,,en(s?.[Hi("metadata")]??null)],Qi=["class","method","getter","setter","accessor","field","value","get","set"],lt=s=>s!==void 0&&typeof s!="function"?Ve("Function expected"):s,nn=(s,e,t,i,r)=>({kind:Qi[s],name:e,metadata:i,addInitializer:n=>t._?Ve("Already initialized"):r.push(lt(n||null))}),Ki=(s,e)=>sn(e,Hi("metadata"),s[3]),qi=(s,e,t,i)=>{for(var r=0,n=s[e>>1],o=n&&n.length;r<o;r++)e&1?n[r].call(t):i=n[r].call(t,i);return i},on=(s,e,t,i,r,n)=>{var o,a,f,m,P,c=e&7,D=!!(e&8),w=!!(e&16),O=c>3?s.length+1:c?D?1:2:0,le=Qi[c+5],u=c>3&&(s[O-1]=[]),l=s[O]||(s[O]=[]),h=c&&(!w&&!D&&(r=r.prototype),c<5&&(c>3||!w)&&tn(c<4?r:{get[t](){return z(this,n)},set[t](d){return ut(this,n,d)}},t));c?w&&c<4&&Gi(n,(c>2?"set ":c>1?"get ":"")+t):Gi(r,t);for(var p=i.length-1;p>=0;p--)m=nn(c,t,f={},s[3],l),c&&(m.static=D,m.private=w,P=m.access={has:w?d=>an(r,d):d=>t in d},c^3&&(P.get=w?d=>(c^1?z:we)(d,r,c^4?n:h.get):d=>d[t]),c>2&&(P.set=w?(d,_)=>ut(d,r,_,c^4?n:h.set):(d,_)=>d[t]=_)),a=(0,i[p])(c?c<4?w?n:h[le]:c>4?void 0:{get:h.get,set:h.set}:r,m),f._=1,c^4||a===void 0?lt(a)&&(c>4?u.unshift(a):c?w?n=a:h[le]=a:r=a):typeof a!="object"||a===null?Ve("Object expected"):(lt(o=a.get)&&(h.get=o),lt(o=a.set)&&(h.set=o),lt(o=a.init)&&u.unshift(o));return c||Ki(s,r),h&&Ds(r,t,h),w?c^4?n:h:r},Ns=(s,e,t)=>e.has(s)||Ve("Cannot "+t),an=(s,e)=>Object(e)!==e?Ve('Cannot use the "in" operator on this value'):s.has(e),z=(s,e,t)=>(Ns(s,e,"read from private field"),t?t.call(s):e.get(s)),Ut=(s,e,t)=>e.has(s)?Ve("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),ut=(s,e,t,i)=>(Ns(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),we=(s,e,t)=>(Ns(s,e,"access private method"),t),Yi,se,Ee,dt,_s,he,Vt,ct,Ue="value";Yi=[tt({name:Ue})];var ie=class{constructor(e){Ut(this,he),Ut(this,se,[]),Ut(this,Ee),Ut(this,_s,qi(dt,8,this)),qi(dt,11,this),this.value$=void 0,Y(this,Ue),this.value$=G(this,Ue),this.value$.onChange(t=>g(this,Ue,t)),e&&this.add(...e)}add(...e){return z(this,se).push(...e),we(this,he,ct).call(this),we(this,he,Vt).call(this,e)}unshift(...e){return z(this,se).unshift(...e),we(this,he,ct).call(this),we(this,he,Vt).call(this,e)}remove(...e){we(this,he,Vt).call(this,e)()}clear(){z(this,se).length=0,we(this,he,ct).call(this)}dispose(){this.clear(),z(this,Ee)?.destroy(),ut(this,Ee,void 0),de(this,Ue),A(this),this.value$.destroy(),Je(this)}};dt=rn(null);se=new WeakMap;Ee=new WeakMap;_s=new WeakMap;he=new WeakSet;Vt=function(s){return()=>{for(let e of s){let t=z(this,se).indexOf(e);t!==-1&&z(this,se).splice(t,1)}we(this,he,ct).call(this)}};ct=function(){z(this,Ee)?.destroy(),z(this,se).length===0?(ut(this,Ee,void 0),this.value=void 0):(ut(this,Ee,S(()=>{let s;for(let e of z(this,se)){let t=We(e);if(t!=null){s=t;break}}this.value=s},z(this,se))),z(this,Ee).run())};on(dt,4,"value",Yi,ie,_s);Ki(dt,ie);ie.Value=Ue;var Ws=new Map,$s=!1,hn=(s,e)=>{Ws.set(s,e),$s||($s=!0,queueMicrotask(()=>{$s=!1;let t=Array.from(Ws.entries());Ws.clear();for(let[i,r]of t)i.set(r)}))},Bt=class{#e;#t;#s=new Lt;#i=new Map;#r=new Map;#n;#a;#o=new Set;#h=[];#l=0;get kernel(){return this.#e}get uuid(){return this.#t}get order(){return this.#l}set order(e){this.#l!==e&&(this.#l=e,this.#n&&this.parent.resortChildren())}get parentUuid(){return this.#n||void 0}set parentUuid(e){if(this.#n!==e){let t=e?this.#e.getEntity(e):void 0;this.removeFromParent(),this.#n=e||void 0,this.#a=t,this.#a&&this.#a.addChild(this),this.#p()}}get parent(){return!this.#a&&this.#n&&(this.#a=this.#e.getEntity(this.#n)),this.#a}set parent(e){this.parentUuid=e?.uuid}get hasParent(){return!!this.#n}get children(){return this.#h}constructor(e,t){this.#e=e,this.#t=t,C(this,te,K.Min,this)}traverse(e){e(this);for(let t of this.#h)t.traverse(e)}[te](){this.#s.clear(),A(this),this.#c?.();for(let e of this.#r.values())e.cleanup(),e.signal.destroy();this.#r.clear();for(let e of this.#i.values())e.context.set(void 0),e.unsubscribePathValue(),e.unsubscribeFromParent?.(),e.valuePath.dispose(),e.inherited.destroy(),e.provide.destroy(),e.context.destroy();this.#n=void 0,this.#a=void 0,this.#o.clear(),this.#h.length=0}addChild(e){if(this.#h.length===0){this.#o.add(e.uuid),this.#h.push(e);return}if(this.#o.has(e.uuid))throw new Error(`child with uuid: ${e.uuid} already exists! parentUuid: ${this.uuid}`);this.#o.add(e.uuid),this.#h.push(e),this.resortChildren();for(let[,t]of e.#i)e.#v(t)}resortChildren(){this.#h.sort((e,t)=>e.order-t.order)}removeChild(e){this.#o.has(e.uuid)&&(this.#o.delete(e.uuid),this.#h.splice(this.#h.indexOf(e),1))}removeFromParent(){if(this.#a){this.#a.removeChild(this),this.#a=void 0,this.#n=void 0;for(let[,e]of this.#i)e.unsubscribeFromParent&&(e.unsubscribeFromParent(),e.unsubscribeFromParent=void 0);this.#y()}}#u=!1;#c;get autoDestructionOnParentRemoval(){return this.#u}set autoDestructionOnParentRemoval(e){this.#u!==e&&(this.#u=e,this.#p())}#y(){this.#c&&(this.#c(),this.#c=void 0)}#p(){this.#y(),this.#u&&this.#a&&(this.#c=C(this.#a,te,K.Max,()=>{this.#c=void 0,this.#e.destroyEntity(this.#t)}))}reSubscribeToParentContexts(){for(let[,e]of this.#i)this.#v(e)}dispatchMessageToView(e,t,i,r=!1){this.#e.dispatchMessageToView({uuid:this.#t,type:e,data:t,transferables:i,traverseChildren:r})}dispatchViewEvents(e){for(let{type:t,data:i}of e)g(this,It,t,i)}dispatchViewEvent(e,t){this.dispatchViewEvents([{type:e,data:t}])}#g(e){return this.#s.get(e)}getPropertyReader(e){return this.#g(e).get}getPropertyWriter(e){return this.#g(e).set}setProperties(e){this.clearTruthyPropsCache(),W(()=>{for(let[t,i]of e)this.setProperty(t,i)})}setProperty(e,t){this.getPropertyWriter(e)(t)}getProperty(e){return We(this.getPropertyReader(e))}propKeys(){return Array.from(this.#s.keys())}propEntries(){return Array.from(this.#s.entries()).map(([e,t])=>[e,t.value])}#d;clearTruthyPropsCache(){this.#d=void 0}truthyProps(){if(this.#d)return this.#d.size?this.#d:void 0;let e=new Set;for(let[t,i]of this.#s.entries())if(typeof t=="string"){let r=i.value;r!=null&&r!==!1&&r!==""&&e.add(t)}return this.#d=e,e.size?e:void 0}hasContext(e){return this.#i.has(e)}useContext(e){return this.#f(e).context.get}useParentContext(e){return this.#f(e).inherited.get}provideContext(e){return this.#f(e).provide}provideGlobalContext(e){if(this.#r.has(e))return this.#r.get(e).signal;let t=this.#e.findOrCreateRootContext(e),i=y(),r=t.add(i);return this.#r.set(e,{cleanup:r,signal:i}),i}#f(e){if(this.#i.has(e))return this.#i.get(e);let t=y(),i=y(),r=y(),n=new ie([i,t]),o=b(n,ie.Value,f=>{hn(r,f)}),a={name:e,inherited:t,provide:i,context:r,valuePath:n,unsubscribePathValue:o};return this.#i.set(e,a),this.#v(a),a}#v(e){if(e.unsubscribeFromParent?.(),e.unsubscribeFromParent=void 0,this.parent){let t=this.parent.#f(e.name),i=$(t.context,e.inherited);e.unsubscribeFromParent=i.destroy.bind(i)}else{let t=this.#e.findOrCreateRootContext(e.name),i=$(t.value$,e.inherited);e.unsubscribeFromParent=i.destroy.bind(i)}}};var Ji=s=>{let e=s.split("@").map(t=>t.trim());if(e.length===2&&e[1])return e[0]?{key:`${e[0]}@${e[1]}`,prop:e[1],token:e[0]}:{key:e[1],prop:e[1]}},Gt=(s,e)=>{for(let t of e)s.add(t)},ln=(s,e)=>{if(s!=null)for(let t of s.constructors)e.add(t)},Me=class{static get(e){return e??cn}#e=new Map;#t=new Map;#s=new Map;define(e,t){let i=this.#e.get(e);i?Ti(i.constructors,t):this.#e.set(e,{token:e,constructors:[t]})}appendRoute(e,t){let i=Ji(e);if(i){let r=this.#s.get(i.key);r?Gt(r.routes,t):this.#s.set(i.key,{routes:new Set(t),token:i.token})}else{let r=this.#t.get(e);r?Gt(r,t):this.#t.set(e,new Set(t))}}clearRoute(e){let t=Ji(e);t?this.#s.delete(t.key):this.#t.delete(e)}findTokensByRoute(e,t){let i=new Set([e]),r=Array.from(this.#t.get(e)??[]);for(let n=r.shift();n!==void 0;n=r.shift()){if(i.has(n))continue;i.add(n);let o=this.#t.get(n);o&&r.push(...Array.from(o).filter(a=>!i.has(a)))}if(t){for(let o of t){let a=this.#s.get(o);a&&Gt(i,a.routes)}let n;do{n=i.size;for(let o of new Set(i))for(let a of t){let f=this.#s.get(`${o}@${a}`);f&&Gt(i,f.routes)}}while(n!==i.size)}return i}findConstructors(e,t){let i=this.findTokensByRoute(e,t),r=new Set;for(let n of i)ln(this.#e.get(n),r);return r.size>0?Array.from(r):void 0}hasToken(e){return this.#e.has(e)}hasRoute(e){return this.#t.has(e)}clear(){this.#e.clear(),this.#t.clear(),this.#s.clear()}},cn=new Me;var Xi=s=>s.displayName||s.name,Zi=!1,er=!1,tr=!1,sr=!1,ir=!1,qt=class{constructor(e){this.logger=new N("Kernel"),this.#e=new Map,this.#t=new Set,this.#s=[],this.#i=[],this.#r=!0,this.#n=new Map,T(this),this.registry=Me.get(e)}#e;#t;#s;#i;#r;#n;getEntity(e){return this.#a(e).entity}#a(e){let t=this.#e.get(e);if(t===void 0)throw new Error(`entity with uuid "${e}" not found!`);return t}hasEntity(e){return this.#e.has(e)}traverseLevelOrderBFS(e=!1){if(this.#r){let t=new Map,i=(r,n)=>{let o=this.getEntity(r),a=t.get(n);a?a.push(o):t.set(n,[o]);for(let f of o.children)i(f.uuid,n+1)};this.#t.forEach(r=>{i(r,0)}),this.#s=Array.from(t.entries()).sort((r,n)=>r[0]-n[0]).flatMap(([,r])=>r),this.#i=this.#s.slice().reverse(),this.#r=!1}return e?this.#i:this.#s}getEntityGraph(){return Array.from(this.#t).map(e=>this.getEntityGraphNode(e)).filter(e=>e!==void 0)}getEntityGraphNode(e){let t=this.#e.get(e);if(t===void 0)return;let{token:i,entity:r}=t;return{token:i,entity:r,props:Object.fromEntries(r.propEntries()),children:r.children.map(n=>this.getEntityGraphNode(n.uuid)).filter(n=>n!==void 0)}}upgradeEntities(){let e=new Map;for(let t of this.traverseLevelOrderBFS(!0))this.hasEntity(t.uuid)&&e.set(t.uuid,this.updateShadowObjects(t.uuid,2));for(let t of this.traverseLevelOrderBFS(!1))this.hasEntity(t.uuid)&&this.updateShadowObjects(t.uuid,1,e.get(t.uuid));e.clear()}run(e){this.logger.isDebug&&this.logger.debug("sync",e),W(()=>{for(let t of e.changeTrail)this.parse(t)})}parse(e){switch(e.type){case E.CreateEntities:this.createEntity(e.uuid,e.token,e.parentUuid,e.order,e.properties,e.autoDestructionOnParentRemoval),this.#r=!0;break;case E.DestroyEntities:this.destroyEntity(e.uuid),this.#r=!0;break;case E.SetParent:this.setParent(e.uuid,e.parentUuid,e.order),this.#r=!0;break;case E.UpdateOrder:this.updateOrder(e.uuid,e.order),this.#r=!0;break;case E.ChangeProperties:this.changeProperties(e.uuid,e.properties);break;case E.ChangeToken:this.changeToken(e.uuid,e.token);break;case E.SendEvents:this.dispatchEventsToEntity(e.uuid,e.events);break}}createEntity(e,t,i,r=0,n,o=!1){let a=new Bt(this,e);a.order=r;let f={token:t,entity:a,usedConstructors:new Map};this.#e.set(e,f),i&&(a.parentUuid=i),a.autoDestructionOnParentRemoval=o,a.hasParent||this.#t.add(e),n&&a.setProperties(n),this.createShadowObjects(f)}destroyEntity(e){let t=this.#e.get(e);if(t===void 0)return;let{entity:i,usedConstructors:r}=t,n=[...i.children];for(let o of n)o.autoDestructionOnParentRemoval?this.destroyEntity(o.uuid):(o.removeFromParent(),this.#t.add(o.uuid));i.removeFromParent(),g(i,te,i),r.clear(),this.#e.delete(i.uuid),this.#t.delete(i.uuid),this.#r=!0}setParent(e,t,i){let r=this.getEntity(e),n=i??r.order;if(!(r.parentUuid===t&&r.order===n)){if(t&&!this.#e.has(t))throw new Error(`entity with uuid "${t}" not found!`);r.removeFromParent(),r.order=n,r.parentUuid=t,r.hasParent?this.#t.delete(e):this.#t.add(e),r.reSubscribeToParentContexts(),queueMicrotask(()=>{this.logger.isDebug&&this.logger.debug("entity.onParentChanged",{uuid:e,parentUuid:t,order:n,entity:r}),g(r,Bi,r)})}}updateOrder(e,t){this.getEntity(e).order=t}dispatchEventsToEntity(e,t){this.getEntity(e)?.dispatchViewEvents(t)}changeProperties(e,t){this.getEntity(e).setProperties(t),this.updateShadowObjects(e)}changeToken(e,t){let i=this.#e.get(e);i!==void 0&&i.token!==t&&(i.token=t,this.updateShadowObjects(e))}dispatchMessageToView(e){queueMicrotask(()=>{g(this,$e,e)})}updateShadowObjects(e,t=0,i){let r=this.#a(e);i??=new Set(this.registry.findConstructors(r.token,r.entity.truthyProps()));let n=t===0||t===2,o=t===0||t===1;if(n){for(let[a,f]of r.usedConstructors)if(!i.has(a)){r.usedConstructors.delete(a);for(let m of f)this.destroyShadowObject(m,r.entity)}}if(o)for(let a of i)r.usedConstructors.has(a)||this.constructShadowObject(a,r);return i}constructShadowObject(e,t){let i=new Set,r=new Set,n=new Map,o=new Map,a=new Map,f=new Map,m=new Map,P=new Map,c=new Map,D=new Map,w=(u,l)=>{!ir&&l!=null&&typeof l=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useProperty()" is now passed as {compare} argument. Please update your code accordingly.'),ir=!0);let h=typeof l=="function"?{compare:l}:l,p=c.get(u);if(p===void 0){p=y(void 0,h).get,c.set(u,p),D.set(u,h?.compare);let d=$(t.entity.getPropertyReader(u),p);r.add(d.destroy.bind(d))}else h?.compare!=null&&D.get(u)!==h.compare&&console.warn(`[shadow-objects] useProperty("${u}"): the cached signal already exists with a different (or no) {compare} function \u2014 the new options are ignored. Pass options only on the first call per property.`);return p},O=T(new e({entity:t.entity,provideContext(u,l,h){!Zi&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideContext()" is now passed as {compare} argument. Please update your code accordingly.'),Zi=!0);let p=typeof h=="function"?{compare:h}:h,d=m.get(u);if(d==null){let _=Ae(l),Jt=_?void 0:zt(l);if(d=y(Jt,p?.compare?{compare:p.compare}:void 0),_){let Ge=$(l,d);r.add(Ge.destroy.bind(Ge))}let Be=$(d,t.entity.provideContext(u));r.add(Be.destroy.bind(Be)),m.set(u,d)}return d!=null&&(p?.clearOnDestroy??!0)&&r.add(()=>{d.set(void 0)}),d},provideGlobalContext(u,l,h){!er&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideGlobalContext()" is now passed as {compare} argument. Please update your code accordingly.'),er=!0);let p=typeof h=="function"?{compare:h}:h,d=P.get(u);if(d==null){let _=Ae(l),Jt=_?void 0:zt(l);if(d=y(Jt,p?.compare?{compare:p.compare}:void 0),_){let Ge=$(l,d);r.add(Ge.destroy.bind(Ge))}let Be=$(d,t.entity.provideGlobalContext(u));r.add(Be.destroy.bind(Be)),P.set(u,d)}return d!=null&&(p?.clearOnDestroy??!0)&&r.add(()=>{d.set(void 0)}),d},useContext(u,l){!tr&&l!=null&&typeof l=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useContext()" is now passed as {compare} argument. Please update your code accordingly.'),tr=!0);let h=typeof l=="function"?{compare:l}:l,p=n.get(u);if(p===void 0){p=y(void 0,h).get,n.set(u,p),o.set(u,h?.compare);let d=$(t.entity.useContext(u),p);r.add(d.destroy.bind(d))}else h?.compare!=null&&o.get(u)!==h.compare&&console.warn(`[shadow-objects] useContext("${String(u)}"): the cached signal already exists with a different (or no) {compare} function \u2014 the new options are ignored. Pass options only on the first call per context.`);return p},useParentContext(u,l){!sr&&l!=null&&typeof l=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useParentContext()" is now passed as {compare} argument. Please update your code accordingly.'),sr=!0);let h=typeof l=="function"?{compare:l}:l,p=a.get(u);if(p===void 0){p=y(void 0,h).get,a.set(u,p),f.set(u,h?.compare);let d=$(t.entity.useParentContext(u),p);r.add(d.destroy.bind(d))}else h?.compare!=null&&f.get(u)!==h.compare&&console.warn(`[shadow-objects] useParentContext("${String(u)}"): the cached signal already exists with a different (or no) {compare} function \u2014 the new options are ignored. Pass options only on the first call per parent context.`);return p},dispatchMessageToView(u,l,h,p=!1){t.entity.dispatchMessageToView(u,l,h,p)},useProperty:w,useProperties(u){let l={};for(let h in u)Object.hasOwn(u,h)&&(l[h]=w(u[h]));return l},createResource(u,l){let h=y(),p=S(()=>{let d=zt(u());return h.set(d),d!==void 0&&l?()=>{l(d),h.set(void 0)}:()=>{h.set(void 0)}});return r.add(()=>{p.destroy(),h.set(void 0),M(h)}),h},createEffect(...u){let l=S(...u);return r.add(l.destroy),l},createSignal(...u){let l=y(...u);return r.add(()=>{M(l)}),l},createMemo(...u){let l=Ot(...u);return r.add(()=>{M(l)}),l},on(...u){let[l]=u;if(typeof l=="string"||typeof l=="symbol"||Array.isArray(l)){let p=b(t.entity,...u);return r.add(p),p}let h=b(...u);return r.add(h),Object.assign(()=>{r.delete(h),h()},h)},once(...u){let[l]=u;if(typeof l=="string"||typeof l=="symbol"||Array.isArray(l)){let p=C(t.entity,...u);return r.add(p),p}let h=C(...u);return r.add(h),Object.assign(()=>{r.delete(h),h()},h)},emit(...u){let[l]=u;typeof l=="string"||typeof l=="symbol"||Array.isArray(l)?g(t.entity,...u):g(...u)},onViewEvent(u){let l=b(t.entity,It,(h,p)=>{u(h,p)});r.add(l)},onDestroy(u){i.add(u)}}));this.logger.isInfo&&this.logger.info("create shadow-object",Xi(e),{shadowObject:O,entity:t.entity}),C(t.entity,te,K.Low,()=>{this.logger.isInfo&&this.logger.info("destroy shadow-object",Xi(e),{shadowObject:O,entity:t.entity});for(let l of i)l();for(let l of r)l();for(let l of n.values())M(l);for(let l of a.values())M(l);for(let l of c.values())M(l);for(let l of m.values())M(l);for(let l of P.values())M(l);i.clear(),r.clear(),n.clear(),a.clear(),c.clear(),m.clear(),P.clear();let u=t.usedConstructors.get(e);u&&(u.delete(O),u.size===0&&t.usedConstructors.delete(e))});let le=t.usedConstructors.get(e);return le?le.add(O):t.usedConstructors.set(e,new Set([O])),this.attachShadowObject(O,t.entity),O}createShadowObjects(e){this.registry.findConstructors(e.token,e.entity.truthyProps())?.forEach(t=>{this.constructShadowObject(t,e)})}findShadowObjects(e){let t=this.#e.get(e);if(t===void 0)return[];let{usedConstructors:i}=t;return Array.from(new Set(Array.from(i.values()).flatMap(r=>Array.from(r))))}attachShadowObject(e,t){b(t,e),typeof e[Ls]=="function"&&e[Ls](t)}destroyShadowObject(e,t){typeof e[te]=="function"&&e[te](t),g(e,te,t),A(t,e)}findOrCreateRootContext(e){let t=this.#n.get(e);return t||(t=new ie,this.#n.set(e,t)),t}destroy(){for(let e of this.#n.values())e.dispose();this.#n.clear();for(let e of this.traverseLevelOrderBFS().reverse())this.destroyEntity(e.uuid)}};var Ht=s=>(typeof s=="string"&&(s=new URL(s,globalThis.location.href)),s.toString());function rr(s){return s.map(e=>{if(e.transferables&&e.transferables.length>0){let{transferables:t,...i}=e;return structuredClone(i,{transfer:t})}else return structuredClone(e)})}var Qt=class{constructor(e){this.#e=new Set,this.isLocalEnv=!0,this.disableStructuredClone=!1,this.kernel=new qt(e),this.#t=this.kernel.registry===Me.get(),b(this.kernel,$e,t=>{let i=this.onMessageToView;if(i==null)return;let{type:r,uuid:n,traverseChildren:o}=t,a=structuredClone(t.data,{transfer:t.transferables});i.call(this,{type:r,uuid:n,data:a,traverseChildren:o})})}#e;#t;get registry(){return this.kernel.registry}start(){return Promise.resolve()}applyChangeTrail(e,t){let i={changeTrail:this.disableStructuredClone?e:rr(e)},r;try{this.kernel.run(i),r=Promise.resolve()}catch(n){r=Promise.reject(n)}return r}async importScript(e){let t=await import(Ht(e));t[ys]&&await this.importModule(t[ys])}async importModule(e){return Ms(this.kernel,e,this.#e)}destroy(){this.kernel.destroy(),this.#t||this.registry.clear(),this.#e.clear()}};function Fs(s){let e=new Blob([s],{type:"text/javascript"}),t=URL.createObjectURL(e),i=new Worker(t);return URL.revokeObjectURL(t),i}function js(){return Fs(`var Qi=Object.defineProperty;var Rt=Object.getOwnPropertySymbols;var Ns=Object.prototype.hasOwnProperty,Us=Object.prototype.propertyIsEnumerable;var qi=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),_s=s=>{throw TypeError(s)};var is=(s,e,t)=>e in s?Qi(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,rs=(s,e)=>{for(var t in e||(e={}))Ns.call(e,t)&&is(s,t,e[t]);if(Rt)for(var t of Rt(e))Us.call(e,t)&&is(s,t,e[t]);return s};var js=(s,e)=>{var t={};for(var i in s)Ns.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&Rt)for(var i of Rt(s))e.indexOf(i)<0&&Us.call(s,i)&&(t[i]=s[i]);return t};var y=(s,e,t)=>is(s,typeof e!="symbol"?e+"":e,t),ns=(s,e,t)=>e.has(s)||_s("Cannot "+t);var n=(s,e,t)=>(ns(s,e,"read from private field"),t?t.call(s):e.get(s)),f=(s,e,t)=>e.has(s)?_s("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),g=(s,e,t,i)=>(ns(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),S=(s,e,t)=>(ns(s,e,"access private method"),t);var Tt=(s,e,t,i)=>({set _(r){g(s,e,r,t)},get _(){return n(s,e,i)}});var os=function(s,e){this[0]=s,this[1]=e},Vs=(s,e,t)=>{var i=(c,d,w,k)=>{try{var v=t[c](d),B=(d=v.value)instanceof os,M=v.done;Promise.resolve(B?d[0]:d).then(C=>B?i(c==="return"?c:"next",d[1]?{done:C.done,value:C.value}:C,w,k):w({value:C,done:M})).catch(C=>i("throw",C,w,k))}catch(C){k(C)}},r=(c,d,w,k)=>a[c]=v=>(d=new Promise((B,M,C)=>(C=()=>i(c,v,B,M),o?o.then(C):C())),k=()=>o===w&&(o=0),o=w=d.then(k,k),d),o,a={};return t=t.apply(s,e),a[qi("asyncIterator")]=()=>a,r("next"),r("throw"),r("return"),a};var ae=(s=>(s[s.CreateEntities=1]="CreateEntities",s[s.DestroyEntities=2]="DestroyEntities",s[s.SetParent=3]="SetParent",s[s.UpdateOrder=4]="UpdateOrder",s[s.ChangeProperties=5]="ChangeProperties",s[s.ChangeToken=6]="ChangeToken",s[s.SendEvents=7]="SendEvents",s))(ae||{});var Ws="configure",Is="changeTrail",Qs="destroy",qs="loaded",as="appliedChangeTrail",Dt="importedModule",Ks="destroyed",ut="messageToView";var zt="shadowObjects";var F="ConsoleLogger",D=\`\${F}Storage\`,Ys,Xs,Zs,Ki=!!((Zs=(Xs=(Ys=globalThis.location)==null?void 0:Ys.host)==null?void 0:Xs.startsWith("localhost"))!=null&&Zs),gt="localStorage"in globalThis,Bt=Symbol.for(F),Hs=!1,Js=s=>{if(typeof s=="boolean")return s;switch(s.toLowerCase()){case"true":case"yes":case"on":return!0;default:return!1}},ls=s=>[gt?F:void 0,...Array.isArray(s)?s:[s]].filter(Boolean).join(".");function cs(s,e,t){var o;let i=ls(s),r=gt?localStorage.getItem(i):(o=globalThis[D])==null?void 0:o[i];return r==null?t:e?e(r):r}function ft(s,e){gt?localStorage.setItem(ls(s),e):(globalThis[D]==null&&(globalThis[D]={},console.debug(\`\${F}: Initialize\`,{[D]:globalThis[D]})),globalThis[D][ls(s)]=e)}var $e,dt,b=class b{constructor(e){f(this,$e);this.enable=!0,this.namespace=(e||"").trim()||F,Hs||(b.loadConfig(),Hs=!0);let t=[this.namespace,"enable"];this.enable=cs(t,Js,this.enable),ft(t,gt?this.enable?"true":"false":this.enable)}static get isEnabled(){return b.sharedConfig.enable}static get isDebug(){return b.sharedConfig.enable&&b.sharedConfig.debug}static loadConfig(){var e,t,i;gt?(["enable","debug","info","warn"].forEach(r=>{this.sharedConfig[r]=cs(r,Js,this.sharedConfig[r])}),["debug","info","warn","error"].forEach(r=>{this.sharedStyles[r]=cs(["styles",r],void 0,this.sharedStyles[r])}),b.isDebug&&console.debug(\`\${F}: Load config from localStorage\`,b.sharedConfig),(e=globalThis[F])!=null&&e[Bt]||(t=globalThis[F])!=null||(globalThis[F]={[Bt]:!0,get enable(){return b.sharedConfig.enable},set enable(r){b.sharedConfig.enable=r,ft("enable",r?"true":"false")},get debug(){return b.sharedConfig.debug},set debug(r){b.sharedConfig.debug=r,ft("debug",r?"true":"false")},get info(){return b.sharedConfig.info},set info(r){b.sharedConfig.info=r,ft("info",r?"true":"false")},get warn(){return b.sharedConfig.warn},set warn(r){b.sharedConfig.warn=r,ft("warn",r?"true":"false")}})):(i=globalThis[D])!=null&&i[Bt]||(globalThis[D]=rs(rs({[Bt]:!0},b.sharedConfig),globalThis[D]),b.sharedConfig=globalThis[D],b.isDebug&&console.debug(\`\${F}: Load config from \${D}\`,globalThis[D]))}get isEnabled(){return this.enable&&b.sharedConfig.enable}get isDebug(){return this.isEnabled&&b.sharedConfig.debug}get isInfo(){return this.isEnabled&&b.sharedConfig.info}get isWarn(){return this.isEnabled&&b.sharedConfig.warn}debug(...e){S(this,$e,dt).call(this,"debug",b.sharedStyles.debug,e)}info(...e){S(this,$e,dt).call(this,"info",b.sharedStyles.info,e)}warn(...e){S(this,$e,dt).call(this,"warn",b.sharedStyles.warn,e)}error(...e){S(this,$e,dt).call(this,"error",b.sharedStyles.error,e)}};$e=new WeakSet,dt=function(e,t,i){console[e](\`%c\${this.namespace}\`,t,...i)},b.sharedConfig={enable:Ki,debug:!1,info:!0,warn:!0,"styles.debug":"color: #111; background: #999; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.info":"color: #020; background: #8a8; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.warn":"color: #fa0; background: #a98; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em","styles.error":"color: #ff0; background: #a00; display: inline-block; padding: 0 0.25em; margin: 0; border-radius: 0.25em"},b.sharedStyles={get debug(){return b.sharedConfig["styles.debug"]},set debug(e){b.sharedConfig["styles.debug"]=e},get info(){return b.sharedConfig["styles.info"]},set info(e){b.sharedConfig["styles.info"]=e},get warn(){return b.sharedConfig["styles.warn"]},set warn(e){b.sharedConfig["styles.warn"]=e},get error(){return b.sharedConfig["styles.error"]},set error(e){b.sharedConfig["styles.error"]=e}};var Ft=b;var Ne="*",ni=1,gs=2,ys=4,ce=Symbol.for("eventize"),Hi="[eventize]",ps=s=>s===Ne,oi=s=>{switch(typeof s){case"string":case"symbol":return!0;default:return!1}},ai=typeof console!="undefined",Ji=ai?console[console.warn?"warn":"log"].bind(console,Hi):()=>{},Yi=(s,e,t)=>(Object.defineProperty(s,e,{value:t,configurable:!0}),s),Xi=0,vs=class{constructor(){y(this,"events",new Map);y(this,"eventNames",new Set)}static publish(s){s.sort((e,t)=>e.order-t.order).forEach(e=>e.replay())}add(s){Array.isArray(s)?s.forEach(e=>this.eventNames.add(e)):this.eventNames.add(s)}remove(s){Array.isArray(s)?s.forEach(e=>this.eventNames.delete(e)):this.eventNames.delete(s),this.clear(s)}clear(s){Array.isArray(s)?s.forEach(e=>this.events.delete(e)):this.events.delete(s)}retain(s,e){this.eventNames.has(s)&&this.events.set(s,{args:e,order:Xi++})}isKnown(s){return this.eventNames.has(s)}replayTo(s,e,t=[]){if(ps(s))this.eventNames.forEach(i=>this.replayTo(i,e,t));else if(this.events.has(s)){let{order:i,args:r}=this.events.get(s);t.push({order:i,replay:()=>e.apply(s,r)})}return t}},fs=(s,e,t,i)=>{if(typeof e=="function"){let r=e.apply(s,t);r!=null&&(i==null||i(r))}},Zi=(s,e,t,i)=>fs(e,e.emit,[s].concat(t),i),er=s=>{switch(typeof s){case"function":return ni;case"string":case"symbol":return gs;case"object":return ys}},tr=0,sr=()=>++tr,ci=class{constructor(s,e,t,i=null){y(this,"id");y(this,"eventName");y(this,"isCatchEmAll");y(this,"priority");y(this,"listener");y(this,"listenerObject");y(this,"listenerType");y(this,"callAfterApply");y(this,"isRemoved");y(this,"refCount");this.id=sr(),this.eventName=s,this.isCatchEmAll=ps(s),this.listener=t,this.listenerObject=i,this.priority=e,this.listenerType=er(t),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(s,e=null){if(s===this)return!0;let t=typeof s;return t==="number"&&s===this.id?!0:e===null&&(t==="string"||t==="symbol")?s===Ne||s===this.eventName:this.listener===s&&this.listenerObject===e}apply(s,e,t){if(this.isRemoved)return;let{listener:i,listenerObject:r}=this;switch(this.listenerType){case ni:fs(r,i,e,t),this.callAfterApply&&this.callAfterApply();break;case gs:fs(r,r[i],e,t),this.callAfterApply&&this.callAfterApply();break;case ys:{let o=i[s];if(this.isCatchEmAll||this.eventName===s){if(typeof o=="function"){let a=o.apply(i,e);a!=null&&(t==null||t(a))}else Zi(s,i,e,t);this.callAfterApply&&this.callAfterApply()}break}}}},ir=(s,e)=>s.priority!==e.priority?e.priority-s.priority:s.id-e.id,rr=(s,e)=>{let t=0,i=s.length;for(;t<i;){let r=t+i>>>1;ir(e,s[r])<0?i=r:t=r+1}return t},ei=s=>s==null?void 0:s.slice(0),ti=(s,e)=>{let t=s.indexOf(e);t>-1&&s.splice(t,1)},nr=s=>s===ys||s===gs,ds=(s,e,t)=>{let i=s.findIndex(r=>r.isEqual(e,t));i>-1&&(s[i].isRemoved=!0,s.splice(i,1))},hs=(s,e,t)=>{let i=[];for(let r of s)(e==null&&r.listenerObject===t||r.eventName===e&&r.listener===t)&&i.push(r);for(let r of i)ds(s,r,void 0)},us=s=>{s&&(s.forEach(e=>{e.isRemoved=!0}),s.length=0)},or=(s,e)=>s.listenerType===e.listenerType?s.priority===e.priority&&s.eventName===e.eventName&&s.listenerObject===e.listenerObject&&s.listener===e.listener:!1,ar=(s,e)=>{if(nr(s.listenerType))return e.find(t=>or(s,t))},cr=(s,e)=>{let t=ar(s,e);return t?(t.refCount+=1,t):(e.splice(rr(e,s),0,s),s)},lr=class{constructor(){y(this,"namedListeners");y(this,"catchEmAllListeners");y(this,"getListenersForEventName",s=>{let e=this.namedListeners.get(s);return e||(e=[],this.namedListeners.set(s,e)),e});this.namedListeners=new Map,this.catchEmAllListeners=[]}add(s){return cr(s,s.isCatchEmAll?this.catchEmAllListeners:this.getListenersForEventName(s.eventName))}remove(s,e,t=!1){if(e==null&&Array.isArray(s)){s.forEach(i=>this.remove(i,null,t));return}if(s==null||e==null&&ps(s)){this.removeAllListeners();return}if(e==null&&oi(s)){this.removeByEventName(s);return}if(s instanceof ci){this.removeByEventListener(s);return}if(t){this.removeByEventNameAndListenerObject(s,e);return}this.removeByListener(s,e)}removeByEventName(s){us(this.namedListeners.get(s)),this.namedListeners.delete(s)}removeByEventListener(s){s.isRemoved||(s.refCount-=1,!(s.refCount>=1)&&(s.isRemoved=!0,this.namedListeners.forEach((e,t)=>{ti(e,s),e.length===0&&this.namedListeners.delete(t)}),ti(this.catchEmAllListeners,s)))}removeByEventNameAndListenerObject(s,e){this.namedListeners.forEach((t,i)=>{hs(t,s,e),t.length===0&&this.namedListeners.delete(i)})}removeByListener(s,e){let t=typeof s=="object";this.namedListeners.forEach((i,r)=>{ds(i,s,e),t&&hs(i,void 0,s),i.length===0&&this.namedListeners.delete(r)}),ds(this.catchEmAllListeners,s,e),t&&hs(this.catchEmAllListeners,void 0,s)}removeAllListeners(){this.namedListeners.forEach(s=>us(s)),this.namedListeners.clear(),us(this.catchEmAllListeners)}forEach(s,e){let t=ei(this.catchEmAllListeners),i=ei(this.namedListeners.get(s));if(s===Ne||!i||i.length===0)t.forEach(e);else if(t.length===0)i.forEach(e);else{let r=i.length,o=t.length,a=0,c=0;for(;a<r||c<o;){if(a<r){let d=i[a];if(c>=o||d.priority>=t[c].priority){e(d),++a;continue}}c<o&&(e(t[c]),++c)}}}getSubscriptionCount(){let s=this.catchEmAllListeners.length;for(let e of this.namedListeners.values())s+=e.length;return s}},Ue=s=>!!(s&&s[ce]);function yt(s){if(Ue(s))return s;let e=new lr,t=new vs;return Yi(s,ce,{keeper:t,store:e}),s}var we={Max:Number.POSITIVE_INFINITY,Critical:1e9,High:1e6,Normal:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0},hr=(s,e,t,i,r,o,a)=>{let c=s.add(new ci(t,i,r,o));return e.replayTo(t,c,a),c},li=(s,e,t,i)=>{let r=t.length,o=typeof t[0],a,c,d,w;if(r>=2&&r<=3&&o==="number"?(a=Ne,[c,d,w]=t):r>=3&&r<=4&&typeof t[1]=="number"?[a,c,d,w]=t:(c=we.Default,o==="string"||o==="symbol"||Array.isArray(t[0])?[a,d,w]=t:(a=Ne,[d,w]=t)),!d)throw ai&&Ji("called with insufficient arguments!",t),new Error("subscribeTo() called with insufficient arguments");let k=v=>B=>hr(s,e,B,v,d,w,i);return Array.isArray(a)?a.map(v=>Array.isArray(v)?k(v[1])(v[0]):k(c)(v)):k(c)(a)},ur=(s,e,t)=>{let i=[],r=li(s,e,t,i);return vs.publish(i),r},fr=(s,e,t)=>{let i=[];return{listeners:li(s,e,t,i),publishRetained:()=>vs.publish(i)}},si=s=>e=>{e.callAfterApply=()=>{s==null||s()}},hi=(s,e)=>Object.assign(()=>x(s,e),Array.isArray(e)?{listeners:e}:{listener:e}),ii=(s,e,t,i)=>{if(e===Ne)throw new Error("emit() must be called with a concrete event name \\u2014 '*' is reserved for subscribing to all events and cannot be emitted");let{store:r,keeper:o}=s[ce];r.forEach(e,a=>a.apply(e,t,i)),o.retain(e,t)},ui=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>ii(s,r,t,i)):ii(s,e,t,i)},ri=(s,e,t,i)=>{if(e===Ne)throw new Error("emit() must be called with a concrete event name \\u2014 '*' is reserved for subscribing to all events and cannot be emitted");let r=s,o=r[e];if(typeof o=="function"){let c=o.apply(s,t);c!=null&&(i==null||i(c));return}let a=r.emit;if(typeof a=="function"){let c=a.apply(s,[e,...t]);c!=null&&(i==null||i(c))}},fi=(s,e,t,i)=>{Array.isArray(e)?e.forEach(r=>ri(s,r,t,i)):ri(s,e,t,i)},di=s=>s!=null&&typeof s=="object";function L(s,...e){let t=yt(s),{store:i,keeper:r}=t[ce];return hi(t,ur(i,r,e))}function A(s,...e){let t=yt(s),{store:i,keeper:r}=t[ce],{listeners:o,publishRetained:a}=fr(i,r,e),c=hi(t,o),d=!1,w=()=>{d||(c(),d=!0)};return Array.isArray(o)?o.forEach(si(w)):si(w)(o),a(),w}function dr(s,e){return new Promise(t=>{A(s,e,t)})}function x(s,e,t){if(!Ue(s))return;let{store:i,keeper:r}=s[ce],o=typeof e,a=t!=null&&(o==="string"||o==="symbol");i.remove(e,t,a),Array.isArray(e)?r.remove(e.filter(c=>typeof c=="string")):oi(e)&&r.remove(e)}function E(s,e,...t){Ue(s)?ui(s,e,t):di(s)&&fi(s,e,t)}function gr(s,e,...t){let i=[],r=o=>{i.push(o)};return Ue(s)?ui(s,e,t,r):di(s)&&fi(s,e,t,r),i=i.map(o=>Array.isArray(o)?Promise.all(o):Promise.resolve(o)),i.length>0?Promise.all(i):Promise.resolve()}function pt(s,e){let t=yt(s),{keeper:i}=t[ce];i.add(e)}function Ke(s,e){if(!Ue(s))throw new Error("object is not eventized");let{keeper:t}=s[ce];t.clear(e)}function yr(s,e){if(!Ue(s))throw new Error("object is not eventized");let{keeper:t}=s[ce];t.remove(e)}var pr=L,vr=A,mr=x,br=E,wr=gr,Er=dr,Sr=pt,Cr=Ke,kr=yr,_=(()=>{let s=(e={})=>yt(e);return s.inject=(e={})=>(e=yt(e),Object.assign(e,{on:(...t)=>pr(e,...t),once:(...t)=>vr(e,...t),onceAsync:t=>Er(e,t),off:(t,i)=>mr(e,t,i),emit:(t,...i)=>br(e,t,...i),emitAsync:(t,...i)=>wr(e,t,...i),retain:t=>Sr(e,t),retainClear:t=>Cr(e,t),unretain:t=>kr(e,t)}),e),s.is=Ue,s})();async function ms(s,e,t,i=!0){var o,a;if(t.has(e)){console.warn("importModule: skipping already imported module",e);return}else t.add(e);e.extends&&await Promise.all(e.extends.map(c=>ms(s,c,t,!1)));let{registry:r}=s;if(e.define)for(let[c,d]of Object.entries(e.define))r.define(c,d);if(e.routes)for(let[c,d]of Object.entries(e.routes))r.appendRoute(c,d);await((a=(o=e.initialize)==null?void 0:o.call(e,{define:(c,d)=>r.define(c,d),kernel:s,registry:r}))!=null?a:Promise.resolve()),i&&s.upgradeEntities()}var te=Symbol.for("signal"),He=Symbol.for("effect"),gi=Symbol.for("destroySignal"),yi=Symbol.for("createEffect"),Ar=Symbol.for("destroyEffect"),et="value",Ss="mute",Cs="unmute",Oe="destroy",Pr="off",mt=Symbol.for("recall"),bt=_(),Pe=_(),_e=_(),Ei=_(),Ae=class{constructor(){y(this,"delayedEffects",[])}batch(e,t){let i=this.delayedEffects.length;for(let r=0;r<i;r++){let[o,a]=this.delayedEffects[r];if(!(o>t)){if(o===t){a.add(e);return}this.delayedEffects.splice(r,0,[t,new Set([e])]);return}}this.delayedEffects.push([t,new Set([e])])}flush(){this.run(),this.delayedEffects.length=0}run(){let e=new Set,t=[];try{t.push(L(_e,(i,r)=>{r===mt&&e.add(i)}),L(Ei,i=>{e.add(i)}));for(let[,i]of this.delayedEffects)for(let r of i)e.has(r)||E(_e,r,r,mt)}finally{for(let i of t)i()}}};y(Ae,"current");var Si=()=>Ae.current;function xe(s){let e=Ae.current;e?e=void 0:e=Ae.current=new Ae;try{s()}finally{e&&(Ae.current=void 0,e.run())}}var Or=0;function ks(){return Or>0}var bi;bi=He;var Gt=class{constructor(e){y(this,bi);y(this,"run",()=>{var e;return(e=this[He])==null?void 0:e.run()});y(this,"destroy",()=>{var e;(e=this[He])==null||e.destroy(),this[He]=void 0});this[He]=e,A(e,Oe,()=>{this[He]=void 0})}},bs=[],Ci=()=>bs.at(-1),xr=(s,e)=>{bs.push(s);try{return e()}finally{bs.pop()}};var Je=new WeakMap,vt=new Set,pi=new FinalizationRegistry(s=>{vt.has(s)&&s.clear()});var Q,Ee,q,le,Se,he,ue,K,je,Ye=class Ye{constructor(e){f(this,Q,new Set);f(this,Ee,new Set);f(this,q,new Map);f(this,le,new WeakMap);f(this,Se,new Map);f(this,he,new Set);f(this,ue,new Set);f(this,K);f(this,je);if(e!=null&&e instanceof Ye)return e;if(e!=null||(e=this),Je.has(e))return Je.get(e);g(this,je,new WeakRef(e)),Je.set(e,this),vt.add(this),e!==this&&pi.register(e,this,this),_(this)}static get(e){if(e!=null)return e instanceof Ye?e:Je.get(e)}static findOrCreate(e){if(e==null)throw new Error("Cannot create a group with a null object");return new Ye(e)}static destroy(e){console.warn("SignalGroup.destroy(obj) is deprecated. Use SignalGroup.delete(obj) instead."),Ye.delete(e)}static delete(e){var t;(t=Je.get(e))==null||t.clear()}static clear(){for(let e of[...vt])e.clear();vt.clear()}attachGroup(e){if(e===this)throw new Error("Cannot attach a group to itself");return n(this,Q).add(e),n(e,K)&&n(e,K)!==this&&n(n(e,K),Q).delete(e),g(e,K,this),e}detachGroup(e){return e!==this&&n(this,Q).has(e)&&(n(this,Q).delete(e),g(e,K,void 0)),e}attachSignal(e){let t=R(e);if(t!=null&&t.destroyed)throw new Error("Cannot attach a destroyed signal to a group");return t&&n(this,Ee).add(t),e}attachSignalByName(e,t){if(t){this.attachSignal(t);let i=R(t);n(this,q).set(e,i);let r=n(this,Se).get(e);r?r.add(i):n(this,Se).set(e,new Set([i])),n(this,le).has(i)?n(this,le).get(i).add(e):n(this,le).set(i,new Set([e]))}else n(this,q).delete(e);return t}hasSignal(e){var t;return n(this,q).has(e)||!!((t=n(this,K))!=null&&t.hasSignal(e))}signal(e){var t,i,r;return(r=(t=n(this,q).get(e))==null?void 0:t.object)!=null?r:(i=n(this,K))==null?void 0:i.signal(e)}detachSignal(e){let t=R(e);if(t&&(n(this,Ee).delete(t),n(this,le).has(t))){let i=n(this,le).get(t);for(let r of i){let o=n(this,Se).get(r);if(o){if(o.delete(t),o.size===0)n(this,q).delete(r),n(this,Se).delete(r);else if(n(this,q).get(r)===t){let a;for(let c of o)a=c;n(this,q).set(r,a)}}}i.clear(),n(this,le).delete(t)}return e}attachEffect(e){return n(this,he).add(e),e}runEffects(){for(let e of n(this,he))e.run();for(let e of n(this,Q))e.runEffects()}attachLink(e){if(e!=null&&e.isDestroyed)throw new Error("Cannot attach a destroyed link to a group");return e&&n(this,ue).add(e),e}detachLink(e){return e&&n(this,ue).delete(e),e}destroy(){console.warn("SignalGroup#destroy is deprecated. Use SignalGroup#clear instead."),this.clear()}off(){for(let e of n(this,Q))e.off();for(let e of n(this,he))e.destroy();n(this,he).clear();for(let e of n(this,ue))e.destroy();n(this,ue).clear();for(let e of n(this,Ee))e.destroyed||E(Pe,e.id,e.id,{detach:!0});E(this,Pr,this)}clear(){var e;E(this,Oe,this),x(this);for(let t of n(this,Q))t.clear();for(let t of n(this,he))t.destroy();for(let t of n(this,Ee))G(t);for(let t of n(this,ue))t.destroy();if(n(this,Q).clear(),n(this,Ee).clear(),n(this,q).clear(),n(this,Se).clear(),n(this,he).clear(),n(this,ue).clear(),(e=n(this,K))==null||e.detachGroup(this),n(this,je)){let t=n(this,je).deref();t!==void 0&&Je.delete(t),g(this,je,void 0)}vt.delete(this),pi.unregister(this)}};Q=new WeakMap,Ee=new WeakMap,q=new WeakMap,le=new WeakMap,Se=new WeakMap,he=new WeakMap,ue=new WeakMap,K=new WeakMap,je=new WeakMap;var ge=Ye,Et,St,$t=class{constructor(e="id",t=1){f(this,Et);f(this,St);g(this,Et,e),g(this,St,t)}make(){return Symbol(\`\${n(this,Et)}\${Tt(this,St)._++}\`)}};Et=new WeakMap,St=new WeakMap;var Mr=s=>s!=null&&typeof s.then=="function",Ce,V,fe,ke,de,Ve,Xe,Ze,j=class j{constructor(e,t){y(this,"id");y(this,"callback");f(this,Ce);f(this,V,new Set);f(this,fe,new Set);f(this,ke,new Map);f(this,de,new Set);y(this,"childEffects",[]);y(this,"curChildEffectSlot",0);y(this,"autorun",!0);y(this,"shouldRun",!0);y(this,"priority");f(this,Ve);f(this,Xe,!1);f(this,Ze,0);y(this,"run",()=>{if(n(this,Xe)||!this.shouldRun)return;let e=Si();if(e){e.batch(this.id,this.priority);return}if(n(this,Ze)>=j.maxDepth)throw new Error(\`[signalize] Effect \${this.id.toString()} exceeded maxDepth=\${j.maxDepth}: an effect callback recursively re-triggered itself (likely by writing a signal it depends on). Break the cycle, or raise EffectImpl.maxDepth if the recursion is intentional.\`);Tt(this,Ze)._++;try{if(this.runCleanupCallback(),this.destroyChildEffects(),this.curChildEffectSlot=0,this.shouldRun=!1,E(Ei,this.id,this.id),this.hasStaticDeps())g(this,Ce,this.callback());else{n(this,fe).clear();for(let t of n(this,V))n(this,fe).add(t);g(this,Ce,xr(this,this.callback)),this.cleanupLostSignals(),n(this,de).clear()}}finally{Tt(this,Ze)._--}});y(this,"destroy",()=>{n(this,Xe)||(E(this,Oe,this),x(this),E(_e,Ar,this),this.runCleanupCallback(),this.destroyChildEffects(),x(bt,this),x(_e,this),x(Pe,this),g(this,Xe,!0),n(this,V).clear(),n(this,fe).clear(),n(this,ke).clear(),n(this,de).clear(),--j.count)});var r,o;_(this),this.callback=e;let i;(t==null?void 0:t.attach)!=null&&(i=ge.findOrCreate(t.attach),i.attachEffect(this)),this.autorun=(r=t==null?void 0:t.autorun)!=null?r:!0,g(this,Ve,t!=null&&t.dependencies?t.dependencies.map(a=>{switch(typeof a){case"string":case"symbol":return i.signal(a);default:return a}}):void 0),this.id=j.idGen.make(),this.priority=(o=t==null?void 0:t.priority)!=null?o:0,L(_e,this.id,mt,this),++j.count}hasStaticDeps(){return n(this,Ve)!=null&&n(this,Ve).length>0}saveSignalsFromDeps(){for(let e of n(this,Ve))this.whenSignalIsRead(R(e).id)}static createEffect(e,t,i){let r=Array.isArray(t)?t:void 0,o=r?i!=null?i:{dependencies:r}:t;o&&r&&(o.dependencies=r);let a,c=Ci();return c!=null?(a=c.getCurrentChildEffect(),a==null&&(a=new j(e,o),c.attachChildEffect(a),E(_e,yi,a)),c.curChildEffectSlot++):(a=new j(e,o),E(_e,yi,a)),a.hasStaticDeps()?a.saveSignalsFromDeps():a.autorun&&a.run(),new Gt(a)}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(e){this.childEffects.push(e)}[mt](){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(e){n(this,fe).delete(e),n(this,V).has(e)||(n(this,V).add(e),n(this,ke).set(e,[L(bt,e,this.priority,mt,this),A(Pe,e,gi,this)]))}[gi](e,t){if(n(this,V).has(e)){if(t!=null&&t.detach){this.unsubscribeSignal(e),n(this,V).delete(e),n(this,de).delete(e),n(this,fe).delete(e),n(this,V).size===0&&this.destroy();return}n(this,de).has(e)||(n(this,de).add(e),this.unsubscribeSignal(e),n(this,de).size===n(this,V).size&&this.destroy())}}cleanupLostSignals(){for(let e of n(this,fe))this.unsubscribeSignal(e),n(this,V).delete(e)}destroyChildEffects(){for(let e of this.childEffects)e.destroy();this.childEffects.length=0}unsubscribeSignal(e){n(this,ke).has(e)&&(n(this,ke).get(e).forEach(t=>{t()}),n(this,ke).delete(e))}runCleanupCallback(){if(n(this,Ce)!=null){let e=n(this,Ce);g(this,Ce,void 0),Mr(e)?Promise.resolve(e).then(t=>{typeof t=="function"&&t()}):e()}}};Ce=new WeakMap,V=new WeakMap,fe=new WeakMap,ke=new WeakMap,de=new WeakMap,Ve=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,y(j,"idGen",new $t("ef")),y(j,"count",0),y(j,"maxDepth",256);var ws=j,ye=ws.createEffect;var wt=new WeakMap,Lr=s=>{let e=wt.get(s);return e||(e={},wt.set(s,e)),e},Me=(s,e)=>{var t,i;return(i=(t=wt.get(s))==null?void 0:t.signals)==null?void 0:i.get(e)};var ki=(s,e,t)=>{var r;let i=Lr(s);(r=i.signals)!=null||(i.signals=new Map),i.signals.set(e,t)};function As(...s){for(let e of s)if(wt.has(e)){let t=wt.get(e);if(t.signals){for(let i of t.signals.values())G(i);t.signals.clear(),t.signals=void 0}}}function Ai(s){let e=R(We(s)?s:Me(...s));e!=null&&!e.muted&&!e.destroyed&&Es(e.id,e.value,{touch:!0})}function tt(s){var e,t;return We(s)?(e=R(s))==null?void 0:e.value:(t=R(Me(...s)))==null?void 0:t.value}var wi;wi=te;var Nt=class{constructor(e){y(this,wi);this[te]=e}get get(){return this[te].reader}get set(){return this[te].writer}get value(){return tt(this.get)}set value(e){this.set(e)}onChange(e){let{destroy:t}=ye(()=>e(this.value),[this.get]);return t}get muted(){return this[te].muted}set muted(e){this[te].muted=e}touch(){Ai(this)}destroy(){G(this)}},Rr=new $t("si"),vi=!1;function Tr(){vi||(vi=!0,console.warn("signalReader(callback) is deprecated and will be removed in a future release. Use Signal.onChange(callback) instead \\u2014 it returns an unsubscribe function for proper cleanup."))}function mi(s){var e;ks()||(e=Ci())==null||e.whenSignalIsRead(s)}function Es(s,e,t){ks()||E(bt,s,e,t)}var We=s=>s!=null&&s[te]!=null,Dr=s=>{let e=t=>{var i;return s.destroyed||(i=s.beforeRead)==null||i.call(s),t?(Tr(),ye(()=>(s.destroyed||mi(s.id),t(s.value)),[e])):s.destroyed||mi(s.id),s.value};return Object.defineProperty(e,te,{value:s}),e},H,_t=class _t{constructor(e,t){y(this,"id");y(this,"lazy");y(this,"compare");y(this,"beforeRead");y(this,"muted",!1);y(this,"destroyed",!1);f(this,H);y(this,"valueFn");y(this,"reader");y(this,"writer",(e,t)=>{var c,d,w;let i=(c=t==null?void 0:t.lazy)!=null?c:!1,r=(d=t==null?void 0:t.compare)!=null?d:this.compare,o=r!=null?r:((k,v)=>k===v);if((i!==this.lazy||i&&e!==this.valueFn||!i&&!o(e,n(this,H)))&&(i?(g(this,H,void 0),this.valueFn=e,this.lazy=!0):(g(this,H,e),this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){Es(this.id,n(this,H));return}(w=t==null?void 0:t.touch)!=null&&w&&!this.muted&&!this.destroyed&&Es(this.id,n(this,H),{touch:!0})});y(this,"object");this.id=Rr.make(),++_t.instanceCount,this.lazy=e,this.lazy?(this.value=void 0,this.valueFn=t):(this.value=t,this.valueFn=void 0),this.reader=Dr(this),this.object=new Nt(this)}get[te](){return this}get value(){return this.lazy&&(g(this,H,this.valueFn()),this.valueFn=void 0,this.lazy=!1),n(this,H)}set value(e){g(this,H,e)}};H=new WeakMap,y(_t,"instanceCount",0);var Ut=_t,R=s=>s==null?void 0:s[te];function O(s=void 0,e){var i;let t;if(We(s))t=R(s);else{let r=(i=e==null?void 0:e.lazy)!=null?i:!1;t=new Ut(r,s),t.beforeRead=e==null?void 0:e.beforeRead,t.compare=e==null?void 0:e.compare}return(e==null?void 0:e.attach)!=null&&ge.findOrCreate(e.attach).attachSignal(t),t.object}var G=(...s)=>{for(let e of s){let t=R(e);t!=null&&!t.destroyed&&(t.destroyed=!0,t.beforeRead=void 0,--Ut.instanceCount,E(Pe,t.id,t.id))}};function jt(s,e){var a,c;let t=O(),i=(e==null?void 0:e.attach)!=null?ge.findOrCreate(e.attach):void 0;i!=null&&(e!=null&&e.name?i.attachSignalByName(e.name,t):i.attachSignal(t));let r=ye(()=>{xe(()=>{t.set(s())})},{autorun:!((a=e==null?void 0:e.lazy)!=null&&a),priority:(c=e==null?void 0:e.priority)!=null?c:we.C,attach:i}),o=R(t);return o.beforeRead=r.run,A(Pe,o.id,r.destroy),t.get}var z,st,Wt=class{constructor(e){f(this,z,!1);f(this,st);y(this,"source");y(this,"lastValue");y(this,"isDestroyed",!1);_(this),this.source=R(e),g(this,st,L(bt,this.source.id,(t,i)=>{!n(this,z)&&!this.isDestroyed&&((i==null?void 0:i.touch)===!0?this.touch():this.write())})),A(Pe,this.source.id,()=>this.destroy())}attach(e){let t=ge.findOrCreate(e);return t.attachLink(this),A(this,Oe,()=>{t.detachLink(this)}),t}nextValue(){return new Promise((e,t)=>{let i=[],r=()=>i.forEach(o=>{o()});i.push(A(this,et,o=>{r(),e(o)}),A(this,Oe,()=>{r(),t()}))})}asyncValues(e){return Vs(this,null,function*(){pt(this,et);try{let t=0;for(;!this.isDestroyed;)try{let i=yield new os(this.nextValue());if(e!=null&&e(i,t++))break;yield i}catch(i){break}}finally{Ke(this,et)}})}destroy(){var e;this.isDestroyed||((e=n(this,st))==null||e.call(this),g(this,st,void 0),E(this,Oe,this),Ke(this,et),x(this),this.lastValue=void 0,this.isDestroyed=!0,Object.freeze(this))}get isMuted(){return n(this,z)}mute(){return!this.isDestroyed&&!n(this,z)&&(g(this,z,!0),E(this,Ss,this)),this}unmute(){return!this.isDestroyed&&n(this,z)&&(g(this,z,!1),E(this,Cs,this)),this}toggleMute(){return this.isDestroyed||(g(this,z,!n(this,z)),E(this,n(this,z)?Ss:Cs,this)),n(this,z)}updateValue(e){if(!n(this,z)&&!this.isDestroyed){let{value:t}=this.source;e(t),E(this,et,t),this.lastValue=t}}};z=new WeakMap,st=new WeakMap;var Ps=class extends Wt{constructor(t,i){super(t);y(this,"target");this.target=R(i),A(Pe,this.target.id,()=>this.destroy()),this.touch()}touch(){return this.updateValue(t=>{this.target.writer(t,{touch:!0})}),this}write(){this.updateValue(t=>{this.target.writer(t)})}},Os=class extends Wt{constructor(t,i){super(t);y(this,"target");this.target=i,this.touch()}touch(){return this.updateValue(t=>{this.target(t)}),this}write(){this.updateValue(t=>{this.target(t)})}},Vt=new Map;function J(s,e,t){let i=R(s),r=R(e),o=r!=null?r:e,a;if(Vt.has(i)){if(a=Vt.get(i),a.has(o))return a.get(o)}else a=new Map,Vt.set(i,a);let c=r!=null?new Ps(s,r):new Os(s,e),d=t==null?void 0:t.attach;return d&&c.attach(d),a.set(o,c),A(c,Oe,()=>{a.delete(o),a.size===0&&Vt.delete(i)}),c}var $,xs=class xs{constructor(){f(this,$,new Map)}static fromProps(e,t){let i=new xs,r=t?t.map(o=>[o,e[o]]):Object.entries(e);for(let[o,a]of r)n(i,$).set(o,O(a));return i}keys(){return n(this,$).keys()}signals(){return n(this,$).values()}entries(){return n(this,$).entries()}clear(){for(let e of n(this,$).values())e.destroy();n(this,$).clear()}has(e){return n(this,$).has(e)}get(e){if(!n(this,$).has(e)){let t=O();return n(this,$).set(e,t),t}return n(this,$).get(e)}update(e){e.size&&xe(()=>{for(let[t,i]of e.entries())this.get(t).set(i)})}updateFromProps(e,t){xe(()=>{let i=t?t.map(r=>[r,e[r]]):Object.entries(e);for(let[r,o]of i)this.get(r).set(o)})}};$=new WeakMap;var It=xs;var Qt=s=>s!=null?s:void 0;var Ms=Symbol("onCreate"),se=Symbol("onDestroy"),Pi=Symbol("onParentChanged"),qt=Symbol("onViewEvent");function Oi(s){return function(e,t){var o;let i=(s==null?void 0:s.name)||t.name,r=!!((o=s==null?void 0:s.readAsValue)!=null&&o);return{get(){let a=Me(this,i);if(a)return r?a.value:a.get()},set(a){var c;(c=Me(this,i))==null||c.set(a)},init(a){let c=O(a,s);return ki(this,i,c),ge.findOrCreate(this).attachSignalByName(i,c),c.value}}}}var zr=Object.create,Ls=Object.defineProperty,Br=Object.getOwnPropertyDescriptor,Li=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),rt=s=>{throw TypeError(s)},Fr=(s,e,t)=>e in s?Ls(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xi=(s,e)=>Ls(s,"name",{value:e,configurable:!0}),Gr=s=>{var e;return[,,,zr((e=s==null?void 0:s[Li("metadata")])!=null?e:null)]},Ri=["class","method","getter","setter","accessor","field","value","get","set"],Ct=s=>s!==void 0&&typeof s!="function"?rt("Function expected"):s,$r=(s,e,t,i,r)=>({kind:Ri[s],name:e,metadata:i,addInitializer:o=>t._?rt("Already initialized"):r.push(Ct(o||null))}),Ti=(s,e)=>Fr(e,Li("metadata"),s[3]),Mi=(s,e,t,i)=>{for(var r=0,o=s[e>>1],a=o&&o.length;r<a;r++)e&1?o[r].call(t):i=o[r].call(t,i);return i},Nr=(s,e,t,i,r,o)=>{var a,c,d,w,k,v=e&7,B=!!(e&8),M=!!(e&16),C=v>3?s.length+1:v?B?1:2:0,at=Ri[v+5],u=v>3&&(s[C-1]=[]),h=s[C]||(s[C]=[]),l=v&&(!M&&!B&&(r=r.prototype),v<5&&(v>3||!M)&&Br(v<4?r:{get[t](){return N(this,o)},set[t](m){return At(this,o,m)}},t));v?M&&v<4&&xi(o,(v>2?"set ":v>1?"get ":"")+t):xi(r,t);for(var p=i.length-1;p>=0;p--)w=$r(v,t,d={},s[3],h),v&&(w.static=B,w.private=M,k=w.access={has:M?m=>Ur(r,m):m=>t in m},v^3&&(k.get=M?m=>(v^1?N:Le)(m,r,v^4?o:l.get):m=>m[t]),v>2&&(k.set=M?(m,oe)=>At(m,r,oe,v^4?o:l.set):(m,oe)=>m[t]=oe)),c=(0,i[p])(v?v<4?M?o:l[at]:v>4?void 0:{get:l.get,set:l.set}:r,w),d._=1,v^4||c===void 0?Ct(c)&&(v>4?u.unshift(c):v?M?o=c:l[at]=c:r=c):typeof c!="object"||c===null?rt("Object expected"):(Ct(a=c.get)&&(l.get=a),Ct(a=c.set)&&(l.set=a),Ct(a=c.init)&&u.unshift(a));return v||Ti(s,r),l&&Ls(r,t,l),M?v^4?o:l:r},Rs=(s,e,t)=>e.has(s)||rt("Cannot "+t),Ur=(s,e)=>Object(e)!==e?rt('Cannot use the "in" operator on this value'):s.has(e),N=(s,e,t)=>(Rs(s,e,"read from private field"),t?t.call(s):e.get(s)),Kt=(s,e,t)=>e.has(s)?rt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),At=(s,e,t,i)=>(Rs(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),Le=(s,e,t)=>(Rs(s,e,"access private method"),t),Di,ie,Re,Pt,Ts,pe,Ht,kt,it="value";Di=[Oi({name:it})];var re=class{constructor(e){Kt(this,pe),Kt(this,ie,[]),Kt(this,Re),Kt(this,Ts,Mi(Pt,8,this)),Mi(Pt,11,this),this.value$=void 0,pt(this,it),this.value$=Me(this,it),this.value$.onChange(t=>E(this,it,t)),e&&this.add(...e)}add(...e){return N(this,ie).push(...e),Le(this,pe,kt).call(this),Le(this,pe,Ht).call(this,e)}unshift(...e){return N(this,ie).unshift(...e),Le(this,pe,kt).call(this),Le(this,pe,Ht).call(this,e)}remove(...e){Le(this,pe,Ht).call(this,e)()}clear(){N(this,ie).length=0,Le(this,pe,kt).call(this)}dispose(){var e;this.clear(),(e=N(this,Re))==null||e.destroy(),At(this,Re,void 0),Ke(this,it),x(this),this.value$.destroy(),As(this)}};Pt=Gr(null);ie=new WeakMap;Re=new WeakMap;Ts=new WeakMap;pe=new WeakSet;Ht=function(s){return()=>{for(let e of s){let t=N(this,ie).indexOf(e);t!==-1&&N(this,ie).splice(t,1)}Le(this,pe,kt).call(this)}};kt=function(){var s;(s=N(this,Re))==null||s.destroy(),N(this,ie).length===0?(At(this,Re,void 0),this.value=void 0):(At(this,Re,ye(()=>{let e;for(let t of N(this,ie)){let i=tt(t);if(i!=null){e=i;break}}this.value=e},N(this,ie))),N(this,Re).run())};Nr(Pt,4,"value",Di,re,Ts);Ti(Pt,re);re.Value=it;var Ds=new Map,zs=!1,_r=(s,e)=>{Ds.set(s,e),zs||(zs=!0,queueMicrotask(()=>{zs=!1;let t=Array.from(Ds.entries());Ds.clear();for(let[i,r]of t)i.set(r)}))},Y,Ie,Te,X,De,W,T,ve,I,nt,Qe,me,P,Bs,Fs,Gs,ze,Ot,Jt,Yt=class{constructor(e,t){f(this,P);f(this,Y);f(this,Ie);f(this,Te,new It);f(this,X,new Map);f(this,De,new Map);f(this,W);f(this,T);f(this,ve,new Set);f(this,I,[]);f(this,nt,0);f(this,Qe,!1);f(this,me);f(this,ze);g(this,Y,e),g(this,Ie,t),A(this,se,we.Min,this)}get kernel(){return n(this,Y)}get uuid(){return n(this,Ie)}get order(){return n(this,nt)}set order(e){n(this,nt)!==e&&(g(this,nt,e),n(this,W)&&this.parent.resortChildren())}get parentUuid(){return n(this,W)||void 0}set parentUuid(e){if(n(this,W)!==e){let t=e?n(this,Y).getEntity(e):void 0;this.removeFromParent(),g(this,W,e||void 0),g(this,T,t),n(this,T)&&n(this,T).addChild(this),S(this,P,Fs).call(this)}}get parent(){return!n(this,T)&&n(this,W)&&g(this,T,n(this,Y).getEntity(n(this,W))),n(this,T)}set parent(e){this.parentUuid=e==null?void 0:e.uuid}get hasParent(){return!!n(this,W)}get children(){return n(this,I)}traverse(e){e(this);for(let t of n(this,I))t.traverse(e)}[se](){var e,t;n(this,Te).clear(),x(this),(e=n(this,me))==null||e.call(this);for(let i of n(this,De).values())i.cleanup(),i.signal.destroy();n(this,De).clear();for(let i of n(this,X).values())i.context.set(void 0),i.unsubscribePathValue(),(t=i.unsubscribeFromParent)==null||t.call(i),i.valuePath.dispose(),i.inherited.destroy(),i.provide.destroy(),i.context.destroy();g(this,W,void 0),g(this,T,void 0),n(this,ve).clear(),n(this,I).length=0}addChild(e){var t;if(n(this,I).length===0){n(this,ve).add(e.uuid),n(this,I).push(e);return}if(n(this,ve).has(e.uuid))throw new Error(\`child with uuid: \${e.uuid} already exists! parentUuid: \${this.uuid}\`);n(this,ve).add(e.uuid),n(this,I).push(e),this.resortChildren();for(let[,i]of n(e,X))S(t=e,P,Jt).call(t,i)}resortChildren(){n(this,I).sort((e,t)=>e.order-t.order)}removeChild(e){n(this,ve).has(e.uuid)&&(n(this,ve).delete(e.uuid),n(this,I).splice(n(this,I).indexOf(e),1))}removeFromParent(){if(n(this,T)){n(this,T).removeChild(this),g(this,T,void 0),g(this,W,void 0);for(let[,e]of n(this,X))e.unsubscribeFromParent&&(e.unsubscribeFromParent(),e.unsubscribeFromParent=void 0);S(this,P,Bs).call(this)}}get autoDestructionOnParentRemoval(){return n(this,Qe)}set autoDestructionOnParentRemoval(e){n(this,Qe)!==e&&(g(this,Qe,e),S(this,P,Fs).call(this))}reSubscribeToParentContexts(){for(let[,e]of n(this,X))S(this,P,Jt).call(this,e)}dispatchMessageToView(e,t,i,r=!1){n(this,Y).dispatchMessageToView({uuid:n(this,Ie),type:e,data:t,transferables:i,traverseChildren:r})}dispatchViewEvents(e){for(let{type:t,data:i}of e)E(this,qt,t,i)}dispatchViewEvent(e,t){this.dispatchViewEvents([{type:e,data:t}])}getPropertyReader(e){return S(this,P,Gs).call(this,e).get}getPropertyWriter(e){return S(this,P,Gs).call(this,e).set}setProperties(e){this.clearTruthyPropsCache(),xe(()=>{for(let[t,i]of e)this.setProperty(t,i)})}setProperty(e,t){this.getPropertyWriter(e)(t)}getProperty(e){return tt(this.getPropertyReader(e))}propKeys(){return Array.from(n(this,Te).keys())}propEntries(){return Array.from(n(this,Te).entries()).map(([e,t])=>[e,t.value])}clearTruthyPropsCache(){g(this,ze,void 0)}truthyProps(){if(n(this,ze))return n(this,ze).size?n(this,ze):void 0;let e=new Set;for(let[t,i]of n(this,Te).entries())if(typeof t=="string"){let r=i.value;r!=null&&r!==!1&&r!==""&&e.add(t)}return g(this,ze,e),e.size?e:void 0}hasContext(e){return n(this,X).has(e)}useContext(e){return S(this,P,Ot).call(this,e).context.get}useParentContext(e){return S(this,P,Ot).call(this,e).inherited.get}provideContext(e){return S(this,P,Ot).call(this,e).provide}provideGlobalContext(e){if(n(this,De).has(e))return n(this,De).get(e).signal;let t=n(this,Y).findOrCreateRootContext(e),i=O(),r=t.add(i);return n(this,De).set(e,{cleanup:r,signal:i}),i}};Y=new WeakMap,Ie=new WeakMap,Te=new WeakMap,X=new WeakMap,De=new WeakMap,W=new WeakMap,T=new WeakMap,ve=new WeakMap,I=new WeakMap,nt=new WeakMap,Qe=new WeakMap,me=new WeakMap,P=new WeakSet,Bs=function(){n(this,me)&&(n(this,me).call(this),g(this,me,void 0))},Fs=function(){S(this,P,Bs).call(this),n(this,Qe)&&n(this,T)&&g(this,me,A(n(this,T),se,we.Max,()=>{g(this,me,void 0),n(this,Y).destroyEntity(n(this,Ie))}))},Gs=function(e){return n(this,Te).get(e)},ze=new WeakMap,Ot=function(e){if(n(this,X).has(e))return n(this,X).get(e);let t=O(),i=O(),r=O(),o=new re([i,t]),a=L(o,re.Value,d=>{_r(r,d)}),c={name:e,inherited:t,provide:i,context:r,valuePath:o,unsubscribePathValue:a};return n(this,X).set(e,c),S(this,P,Jt).call(this,c),c},Jt=function(e){var t,i;if((t=e.unsubscribeFromParent)==null||t.call(e),e.unsubscribeFromParent=void 0,this.parent){let r=S(i=this.parent,P,Ot).call(i,e.name),o=J(r.context,e.inherited);e.unsubscribeFromParent=o.destroy.bind(o)}else{let r=n(this,Y).findOrCreateRootContext(e.name),o=J(r.value$,e.inherited);e.unsubscribeFromParent=o.destroy.bind(o)}};function zi(s,e){s.indexOf(e)===-1&&s.push(e)}var Bi=s=>{let e=s.split("@").map(t=>t.trim());if(e.length===2&&e[1])return e[0]?{key:\`\${e[0]}@\${e[1]}\`,prop:e[1],token:e[0]}:{key:e[1],prop:e[1]}},Xt=(s,e)=>{for(let t of e)s.add(t)},jr=(s,e)=>{if(s!=null)for(let t of s.constructors)e.add(t)},Be,ne,be,xt=class{constructor(){f(this,Be,new Map);f(this,ne,new Map);f(this,be,new Map)}static get(e){return e!=null?e:Vr}define(e,t){let i=n(this,Be).get(e);i?zi(i.constructors,t):n(this,Be).set(e,{token:e,constructors:[t]})}appendRoute(e,t){let i=Bi(e);if(i){let r=n(this,be).get(i.key);r?Xt(r.routes,t):n(this,be).set(i.key,{routes:new Set(t),token:i.token})}else{let r=n(this,ne).get(e);r?Xt(r,t):n(this,ne).set(e,new Set(t))}}clearRoute(e){let t=Bi(e);t?n(this,be).delete(t.key):n(this,ne).delete(e)}findTokensByRoute(e,t){var o;let i=new Set([e]),r=Array.from((o=n(this,ne).get(e))!=null?o:[]);for(let a=r.shift();a!==void 0;a=r.shift()){if(i.has(a))continue;i.add(a);let c=n(this,ne).get(a);c&&r.push(...Array.from(c).filter(d=>!i.has(d)))}if(t){for(let c of t){let d=n(this,be).get(c);d&&Xt(i,d.routes)}let a;do{a=i.size;for(let c of new Set(i))for(let d of t){let w=n(this,be).get(\`\${c}@\${d}\`);w&&Xt(i,w.routes)}}while(a!==i.size)}return i}findConstructors(e,t){let i=this.findTokensByRoute(e,t),r=new Set;for(let o of i)jr(n(this,Be).get(o),r);return r.size>0?Array.from(r):void 0}hasToken(e){return n(this,Be).has(e)}hasRoute(e){return n(this,ne).has(e)}clear(){n(this,Be).clear(),n(this,ne).clear(),n(this,be).clear()}};Be=new WeakMap,ne=new WeakMap,be=new WeakMap;var Vr=new xt;var Fi=s=>s.displayName||s.name,Gi=!1,$i=!1,Ni=!1,Ui=!1,_i=!1,U,Z,qe,ot,ee,Fe,Mt,$s,Zt=class{constructor(e){f(this,Mt);f(this,U);f(this,Z);f(this,qe);f(this,ot);f(this,ee);f(this,Fe);this.logger=new Ft("Kernel"),g(this,U,new Map),g(this,Z,new Set),g(this,qe,[]),g(this,ot,[]),g(this,ee,!0),g(this,Fe,new Map),_(this),this.registry=xt.get(e)}getEntity(e){return S(this,Mt,$s).call(this,e).entity}hasEntity(e){return n(this,U).has(e)}traverseLevelOrderBFS(e=!1){if(n(this,ee)){let t=new Map,i=(r,o)=>{let a=this.getEntity(r),c=t.get(o);c?c.push(a):t.set(o,[a]);for(let d of a.children)i(d.uuid,o+1)};n(this,Z).forEach(r=>{i(r,0)}),g(this,qe,Array.from(t.entries()).sort((r,o)=>r[0]-o[0]).flatMap(([,r])=>r)),g(this,ot,n(this,qe).slice().reverse()),g(this,ee,!1)}return e?n(this,ot):n(this,qe)}getEntityGraph(){return Array.from(n(this,Z)).map(e=>this.getEntityGraphNode(e)).filter(e=>e!==void 0)}getEntityGraphNode(e){let t=n(this,U).get(e);if(t===void 0)return;let{token:i,entity:r}=t;return{token:i,entity:r,props:Object.fromEntries(r.propEntries()),children:r.children.map(o=>this.getEntityGraphNode(o.uuid)).filter(o=>o!==void 0)}}upgradeEntities(){let e=new Map;for(let t of this.traverseLevelOrderBFS(!0))this.hasEntity(t.uuid)&&e.set(t.uuid,this.updateShadowObjects(t.uuid,2));for(let t of this.traverseLevelOrderBFS(!1))this.hasEntity(t.uuid)&&this.updateShadowObjects(t.uuid,1,e.get(t.uuid));e.clear()}run(e){this.logger.isDebug&&this.logger.debug("sync",e),xe(()=>{for(let t of e.changeTrail)this.parse(t)})}parse(e){switch(e.type){case ae.CreateEntities:this.createEntity(e.uuid,e.token,e.parentUuid,e.order,e.properties,e.autoDestructionOnParentRemoval),g(this,ee,!0);break;case ae.DestroyEntities:this.destroyEntity(e.uuid),g(this,ee,!0);break;case ae.SetParent:this.setParent(e.uuid,e.parentUuid,e.order),g(this,ee,!0);break;case ae.UpdateOrder:this.updateOrder(e.uuid,e.order),g(this,ee,!0);break;case ae.ChangeProperties:this.changeProperties(e.uuid,e.properties);break;case ae.ChangeToken:this.changeToken(e.uuid,e.token);break;case ae.SendEvents:this.dispatchEventsToEntity(e.uuid,e.events);break}}createEntity(e,t,i,r=0,o,a=!1){let c=new Yt(this,e);c.order=r;let d={token:t,entity:c,usedConstructors:new Map};n(this,U).set(e,d),i&&(c.parentUuid=i),c.autoDestructionOnParentRemoval=a,c.hasParent||n(this,Z).add(e),o&&c.setProperties(o),this.createShadowObjects(d)}destroyEntity(e){let t=n(this,U).get(e);if(t===void 0)return;let{entity:i,usedConstructors:r}=t,o=[...i.children];for(let a of o)a.autoDestructionOnParentRemoval?this.destroyEntity(a.uuid):(a.removeFromParent(),n(this,Z).add(a.uuid));i.removeFromParent(),E(i,se,i),r.clear(),n(this,U).delete(i.uuid),n(this,Z).delete(i.uuid),g(this,ee,!0)}setParent(e,t,i){let r=this.getEntity(e),o=i!=null?i:r.order;if(!(r.parentUuid===t&&r.order===o)){if(t&&!n(this,U).has(t))throw new Error(\`entity with uuid "\${t}" not found!\`);r.removeFromParent(),r.order=o,r.parentUuid=t,r.hasParent?n(this,Z).delete(e):n(this,Z).add(e),r.reSubscribeToParentContexts(),queueMicrotask(()=>{this.logger.isDebug&&this.logger.debug("entity.onParentChanged",{uuid:e,parentUuid:t,order:o,entity:r}),E(r,Pi,r)})}}updateOrder(e,t){this.getEntity(e).order=t}dispatchEventsToEntity(e,t){var i;(i=this.getEntity(e))==null||i.dispatchViewEvents(t)}changeProperties(e,t){this.getEntity(e).setProperties(t),this.updateShadowObjects(e)}changeToken(e,t){let i=n(this,U).get(e);i!==void 0&&i.token!==t&&(i.token=t,this.updateShadowObjects(e))}dispatchMessageToView(e){queueMicrotask(()=>{E(this,ut,e)})}updateShadowObjects(e,t=0,i){let r=S(this,Mt,$s).call(this,e);i!=null||(i=new Set(this.registry.findConstructors(r.token,r.entity.truthyProps())));let o=t===0||t===2,a=t===0||t===1;if(o){for(let[c,d]of r.usedConstructors)if(!i.has(c)){r.usedConstructors.delete(c);for(let w of d)this.destroyShadowObject(w,r.entity)}}if(a)for(let c of i)r.usedConstructors.has(c)||this.constructShadowObject(c,r);return i}constructShadowObject(e,t){let i=new Set,r=new Set,o=new Map,a=new Map,c=new Map,d=new Map,w=new Map,k=new Map,v=new Map,B=new Map,M=(u,h)=>{!_i&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useProperty()" is now passed as {compare} argument. Please update your code accordingly.'),_i=!0);let l=typeof h=="function"?{compare:h}:h,p=v.get(u);if(p===void 0){p=O(void 0,l).get,v.set(u,p),B.set(u,l==null?void 0:l.compare);let m=J(t.entity.getPropertyReader(u),p);r.add(m.destroy.bind(m))}else(l==null?void 0:l.compare)!=null&&B.get(u)!==l.compare&&console.warn(\`[shadow-objects] useProperty("\${u}"): the cached signal already exists with a different (or no) {compare} function \\u2014 the new options are ignored. Pass options only on the first call per property.\`);return p},C=_(new e({entity:t.entity,provideContext(u,h,l){var oe;!Gi&&l!=null&&typeof l=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideContext()" is now passed as {compare} argument. Please update your code accordingly.'),Gi=!0);let p=typeof l=="function"?{compare:l}:l,m=w.get(u);if(m==null){let ct=We(h),ss=ct?void 0:Qt(h);if(m=O(ss,p!=null&&p.compare?{compare:p.compare}:void 0),ct){let ht=J(h,m);r.add(ht.destroy.bind(ht))}let lt=J(m,t.entity.provideContext(u));r.add(lt.destroy.bind(lt)),w.set(u,m)}return m!=null&&((oe=p==null?void 0:p.clearOnDestroy)==null||oe)&&r.add(()=>{m.set(void 0)}),m},provideGlobalContext(u,h,l){var oe;!$i&&l!=null&&typeof l=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "provideGlobalContext()" is now passed as {compare} argument. Please update your code accordingly.'),$i=!0);let p=typeof l=="function"?{compare:l}:l,m=k.get(u);if(m==null){let ct=We(h),ss=ct?void 0:Qt(h);if(m=O(ss,p!=null&&p.compare?{compare:p.compare}:void 0),ct){let ht=J(h,m);r.add(ht.destroy.bind(ht))}let lt=J(m,t.entity.provideGlobalContext(u));r.add(lt.destroy.bind(lt)),k.set(u,m)}return m!=null&&((oe=p==null?void 0:p.clearOnDestroy)==null||oe)&&r.add(()=>{m.set(void 0)}),m},useContext(u,h){!Ni&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useContext()" is now passed as {compare} argument. Please update your code accordingly.'),Ni=!0);let l=typeof h=="function"?{compare:h}:h,p=o.get(u);if(p===void 0){p=O(void 0,l).get,o.set(u,p),a.set(u,l==null?void 0:l.compare);let m=J(t.entity.useContext(u),p);r.add(m.destroy.bind(m))}else(l==null?void 0:l.compare)!=null&&a.get(u)!==l.compare&&console.warn(\`[shadow-objects] useContext("\${String(u)}"): the cached signal already exists with a different (or no) {compare} function \\u2014 the new options are ignored. Pass options only on the first call per context.\`);return p},useParentContext(u,h){!Ui&&h!=null&&typeof h=="function"&&(console.warn('[shadow-objects] Deprecation Warning: The "isEqual" option of "useParentContext()" is now passed as {compare} argument. Please update your code accordingly.'),Ui=!0);let l=typeof h=="function"?{compare:h}:h,p=c.get(u);if(p===void 0){p=O(void 0,l).get,c.set(u,p),d.set(u,l==null?void 0:l.compare);let m=J(t.entity.useParentContext(u),p);r.add(m.destroy.bind(m))}else(l==null?void 0:l.compare)!=null&&d.get(u)!==l.compare&&console.warn(\`[shadow-objects] useParentContext("\${String(u)}"): the cached signal already exists with a different (or no) {compare} function \\u2014 the new options are ignored. Pass options only on the first call per parent context.\`);return p},dispatchMessageToView(u,h,l,p=!1){t.entity.dispatchMessageToView(u,h,l,p)},useProperty:M,useProperties(u){let h={};for(let l in u)Object.hasOwn(u,l)&&(h[l]=M(u[l]));return h},createResource(u,h){let l=O(),p=ye(()=>{let m=Qt(u());return l.set(m),m!==void 0&&h?()=>{h(m),l.set(void 0)}:()=>{l.set(void 0)}});return r.add(()=>{p.destroy(),l.set(void 0),G(l)}),l},createEffect(...u){let h=ye(...u);return r.add(h.destroy),h},createSignal(...u){let h=O(...u);return r.add(()=>{G(h)}),h},createMemo(...u){let h=jt(...u);return r.add(()=>{G(h)}),h},on(...u){let[h]=u;if(typeof h=="string"||typeof h=="symbol"||Array.isArray(h)){let p=L(t.entity,...u);return r.add(p),p}let l=L(...u);return r.add(l),Object.assign(()=>{r.delete(l),l()},l)},once(...u){let[h]=u;if(typeof h=="string"||typeof h=="symbol"||Array.isArray(h)){let p=A(t.entity,...u);return r.add(p),p}let l=A(...u);return r.add(l),Object.assign(()=>{r.delete(l),l()},l)},emit(...u){let[h]=u;typeof h=="string"||typeof h=="symbol"||Array.isArray(h)?E(t.entity,...u):E(...u)},onViewEvent(u){let h=L(t.entity,qt,(l,p)=>{u(l,p)});r.add(h)},onDestroy(u){i.add(u)}}));this.logger.isInfo&&this.logger.info("create shadow-object",Fi(e),{shadowObject:C,entity:t.entity}),A(t.entity,se,we.Low,()=>{this.logger.isInfo&&this.logger.info("destroy shadow-object",Fi(e),{shadowObject:C,entity:t.entity});for(let h of i)h();for(let h of r)h();for(let h of o.values())G(h);for(let h of c.values())G(h);for(let h of v.values())G(h);for(let h of w.values())G(h);for(let h of k.values())G(h);i.clear(),r.clear(),o.clear(),c.clear(),v.clear(),w.clear(),k.clear();let u=t.usedConstructors.get(e);u&&(u.delete(C),u.size===0&&t.usedConstructors.delete(e))});let at=t.usedConstructors.get(e);return at?at.add(C):t.usedConstructors.set(e,new Set([C])),this.attachShadowObject(C,t.entity),C}createShadowObjects(e){var t;(t=this.registry.findConstructors(e.token,e.entity.truthyProps()))==null||t.forEach(i=>{this.constructShadowObject(i,e)})}findShadowObjects(e){let t=n(this,U).get(e);if(t===void 0)return[];let{usedConstructors:i}=t;return Array.from(new Set(Array.from(i.values()).flatMap(r=>Array.from(r))))}attachShadowObject(e,t){L(t,e),typeof e[Ms]=="function"&&e[Ms](t)}destroyShadowObject(e,t){typeof e[se]=="function"&&e[se](t),E(e,se,t),x(t,e)}findOrCreateRootContext(e){let t=n(this,Fe).get(e);return t||(t=new re,n(this,Fe).set(e,t)),t}destroy(){for(let e of n(this,Fe).values())e.dispose();n(this,Fe).clear();for(let e of this.traverseLevelOrderBFS().reverse())this.destroyEntity(e.uuid)}};U=new WeakMap,Z=new WeakMap,qe=new WeakMap,ot=new WeakMap,ee=new WeakMap,Fe=new WeakMap,Mt=new WeakSet,$s=function(e){let t=n(this,U).get(e);if(t===void 0)throw new Error(\`entity with uuid "\${e}" not found!\`);return t};var ji=s=>(typeof s=="string"&&(s=new URL(s,globalThis.location.href)),s.toString());var Lt,Ge,Vi,Wi,Ii,es=class{constructor(e){f(this,Ge);f(this,Lt,new Set);var t,i;this.kernel=(t=e==null?void 0:e.kernel)!=null?t:new Zt,this.postMessage=(i=e==null?void 0:e.postMessage)!=null?i:self.postMessage.bind(self),L(this.kernel,ut,"onMessageToView",this)}route(e){var t;switch(e.data.type){case Ws:S(this,Ge,Vi).call(this,e.data);break;case Is:S(this,Ge,Wi).call(this,e.data);break;case Qs:S(this,Ge,Ii).call(this,e.data);break;default:console.warn("[MessageRouter] unknown message",(t=e.data.type)!=null?t:e.data)}}onMessageToView(e){let r=e,{transferables:t}=r,i=js(r,["transferables"]);this.postMessage({type:ut,data:i},{transfer:t})}};Lt=new WeakMap,Ge=new WeakSet,Vi=async function(e){let t=e.importModule;try{if(!t)throw new Error('missing "importModule" url');let i=await import(ji(t));i[zt]?(await ms(this.kernel,i[zt],n(this,Lt)),this.postMessage({type:Dt,url:t})):this.postMessage({type:Dt,url:t,error:\`module has no "\${zt}" export\`})}catch(i){console.error("[MessageRouter] failed to import module",i),this.postMessage({type:Dt,url:t,error:\`\${i}\`})}},Wi=function(e){try{this.kernel.run(e)}catch(t){console.error("[MessageRouter] failed to apply change trail",t),this.postMessage({type:as,serial:e.serial,error:\`\${t}\`})}e.serial&&this.postMessage({type:as,serial:e.serial})},Ii=function(e){console.debug("[MessageRouter] on destroy",e),x(this.kernel,this),n(this,Lt).clear(),this.postMessage({type:Ks})};var ts=class{constructor(){this.onmessage=e=>{var t;e.data.type===F?globalThis[D]=e.data.config:((t=this.router)!=null||(this.router=new es),this.router.route(e))}}start(){self.addEventListener("message",this.onmessage),self.postMessage({type:qs})}};console.debug("@spearwolf/shadow-objects/WorkerRuntime: hello!");var Wr=new ts;Wr.start();
|
|
22
22
|
/*! Bundled license information:
|
|
23
23
|
|
|
24
24
|
@spearwolf/eventize/lib/index.mjs:
|
|
@@ -43,13 +43,13 @@ var ht="shaeRequestEntParent",lt="shaeReRequestEntParent",Ns="shae-worker",ct="s
|
|
|
43
43
|
limitations under the License.
|
|
44
44
|
*)
|
|
45
45
|
|
|
46
|
-
@spearwolf/signalize/dist/signalize.
|
|
46
|
+
@spearwolf/signalize/dist/signalize.DjCVnTTt.js:
|
|
47
47
|
@spearwolf/signalize/dist/index.js:
|
|
48
48
|
@spearwolf/signalize/dist/decorators.js:
|
|
49
49
|
(*!
|
|
50
50
|
@file @spearwolf/signalize - signals and effects for all
|
|
51
51
|
@author Wolfger Schramm <wolfger@spearwolf.de>
|
|
52
|
-
@version 0.
|
|
52
|
+
@version 0.30.0+esm.20260520
|
|
53
53
|
|
|
54
54
|
Copyright 2022-2026 Wolfger Schramm
|
|
55
55
|
|
|
@@ -67,7 +67,7 @@ var ht="shaeRequestEntParent",lt="shaeReRequestEntParent",Ns="shae-worker",ct="s
|
|
|
67
67
|
|
|
68
68
|
*)
|
|
69
69
|
*/
|
|
70
|
-
`)}var
|
|
70
|
+
`)}var nr=()=>new js;var ft=(s,e,t=1e3,i,r)=>new Promise((n,o)=>{if(r?.aborted){o(r.reason);return}let a,f,m=()=>{clearTimeout(a),s.removeEventListener("message",f),r?.removeEventListener("abort",P)};function P(){m(),o(r.reason)}t!==0&&t!==1/0&&(a=setTimeout(()=>{m(),o(new Error(`Timeout waiting for message of type: ${e}`))},t)),f=c=>{if(c.data.type===e)try{(!i||i(c.data))&&(m(),n())}catch(D){m(),o(D)}},r?.addEventListener("abort",P,{once:!0}),s.addEventListener("message",f)});var un=s=>{let e;if(s!=null&&Array.isArray(s))for(let t of s)t.transferables&&(e?e=[...e,...t.transferables]:e=t.transferables,delete t.transferables);return e},zs=class extends Error{constructor(e,t,i){super(t,i),this.name="WorkerFailedError",this.type=e}},Le=class extends Error{constructor(e="the worker environment has been destroyed"){super(e),this.name="WorkerDestroyedError"}},Kt=class s{constructor(){this.#t=!1,this.#s=0,this.#i=new AbortController,this.logger=new N("RemoteWorkerEnv"),Y(this,s.WorkerLoaded),Y(this,s.WorkerFailed)}static{this.WorkerLoaded="workerLoaded"}static{this.WorkerFailed="workerFailed"}#e;#t;#s;#i;get isDestroyed(){return this.#t}get workerLoaded(){let{signal:e}=this.#i;return e.aborted?Promise.reject(e.reason):new Promise((t,i)=>{let r,n=!1,o=()=>{n||(n=!0,r?.(),i(e.reason))};r=C(this,s.WorkerLoaded,a=>{n||(n=!0,e.removeEventListener("abort",o),t(a))}),!n&&e.addEventListener("abort",o,{once:!0})})}async start(){let{signal:e}=this.#i;if(e.aborted)throw e.reason;if(this.#t)throw new Le;if(this.#e)return this.logger.isWarn&&this.logger.warn("already started"),this.workerLoaded.then(()=>{if(this.isDestroyed)throw new Le});let t=this.#e=nr();t.addEventListener("error",this.onWorkerError.bind(this)),t.addEventListener("messageerror",this.onWorkerMessageError.bind(this)),this.configureConsoleLogger(t);try{if(await ft(t,bi,Si,void 0,e),this.isDestroyed)throw new Le;t.addEventListener("message",this.onMessageFromWorker.bind(this)),queueMicrotask(()=>{g(this,s.WorkerLoaded,this)})}catch(i){throw i!==e.reason&&this.logger.error("failed to start",i),this.#e=void 0,this.#t||t.terminate(),i}}applyChangeTrail(e,t){let{signal:i}=this.#i;if(i.aborted)return Promise.reject(i.reason);let r=this.#e;if(r==null)return Promise.reject(new Le);let n=un(e),o={type:vi,changeTrail:e},a=++this.#s;return t&&(o.serial=a),r.postMessage(o,n??[]),t?ft(r,wi,Ai,f=>{if(f.error)throw f.error;return f.serial===a},i):Promise.resolve()}importScript(e){let{signal:t}=this.#i;if(t.aborted)return Promise.reject(t.reason);let i=this.#e;return i==null?Promise.reject(new Le):(e=Ht(e),i.postMessage({type:yi,importModule:e}),ft(i,Ei,ki,r=>{if(r.error)throw r.error;return r.url===e},t))}destroy(){if(!this.#e)return;let e=this.#e;this.#e=void 0,this.#t=!0,e.postMessage({type:mi}),ft(e,Ci,Pi).finally(()=>{e.terminate()})}onWorkerError(e){this.handleWorkerFailure("error",e,e.message||"the worker reported an error")}onWorkerMessageError(e){this.handleWorkerFailure("messageerror",e,"the worker sent a message that could not be deserialized")}handleWorkerFailure(e,t,i){if(this.#t)return;this.#t=!0;let r=new zs(e,i,{cause:e==="error"?t.error??t:t});this.logger.error(i,t);let n=this.#e;this.#e=void 0,this.#i.abort(r),n?.terminate();try{this.onProxyFailed?.(r)}catch(o){this.logger.error("the proxy-failed callback threw",o)}g(this,s.WorkerFailed,{env:this,type:e,message:i,reason:r,event:t})}onMessageFromWorker(e){e.data?.type===$e?this.onMessageToView?.(e.data.data):this.logger.isDebug&&this.logger.debug("message from worker",e)}configureConsoleLogger(e){let t=`${V}.RemoteWorkerEnv.workerConfig`,i=JSON.parse(localStorage.getItem(t)??"{}");this.logger.isInfo&&this.logger.info("load console-logger worker config",{localStorageKey:t,workerConfig:i}),e.postMessage({type:V,config:{...N.sharedConfig,enable:this.logger.isEnabled,...i,...N.isEnabled?{}:{enable:!1}}})}};var Yt=class s extends be{constructor(){super(),this.isShaeWorkerElement=!0,this.shadowEnv=new B,this.logger=new N("ShaeWorkerElement"),this.autostart=!0,this.isConnected$=y(!1),this.autoSync$=y(s.DefaultAutoSync),this.src$=y(""),this.#e=!1,this.#t=!1,this.#a=e=>{e instanceof me||this.logger.error("shadowEnv failed",e)},this.ns$.onChange(e=>{this.shadowEnv.view=I.get(e)}),b(this.shadowEnv,B.ContextCreated,()=>{this.#r?.run(),this.dispatchEvent(new CustomEvent(B.ContextCreated.toLowerCase(),{bubbles:!1,detail:{shadowEnv:this.shadowEnv}}))}),b(this.shadowEnv,B.ContextLost,()=>{this.dispatchEvent(new CustomEvent(B.ContextLost.toLowerCase(),{bubbles:!1,detail:{shadowEnv:this.shadowEnv}}))}),b(this.shadowEnv,B.ProxyFailed,e=>{this.dispatchEvent(new CustomEvent(B.ProxyFailed.toLowerCase(),{bubbles:!1,detail:{shadowEnv:this.shadowEnv,reason:e}}))}),this.autoSync$.onChange(e=>{let t=this.hasAttribute(H),i=t?this.getAttribute(H):void 0;e===s.DefaultAutoSync?t&&i!==e&&this.setAttribute(H,e):i!==e&&this.setAttribute(H,e)}),this.#h(),this.#n(),this.style.display="contents"}static{this.observedAttributes=[...be.observedAttributes,vt,"src",mt,H]}static{this.DefaultAutoSync="frame"}#e;#t;#s;#i;#r;#n(){this.#r=S(()=>{let e=this.src$.get();e&&this.importScript(e).catch(this.#a)},{autorun:!1})}#a;get shouldAutostart(){return this.autostart&&!at(this,Bs)}get autoSync(){return this.autoSync$.value}set autoSync(e){typeof e!="string"&&(e=e?s.DefaultAutoSync:"no"),this.autoSync$.set(`${e}`.trim().toLowerCase())}get frameLoop(){return this.#s??=new ht,this.#s}[ht.OnFrame](){this.syncShadowObjects()}async importScript(e){if(!e)throw new Error("src is blank");let t=await this.shadowEnv.ready();this.logger.isInfo&&this.logger.info("shadowEnv importScript:",e,{shadowEnv:t});let i=t.envProxy;if(i==null)throw new me;return await i.importScript(e),this}connectedCallback(){W(()=>{let e=this.getAttribute(H);e!=null&&this.autoSync$.set(e),this.isConnected$.set(!0)}),this.shouldAutostart&&this.start().catch(this.#a)}disconnectedCallback(){this.isConnected$.set(!1),this.#o()}attributeChangedCallback(e){if(super.attributeChangedCallback(e),e===vt&&this.shadowEnv.envProxy!=null)throw new Error('Changing the "local" attribute after the shadowEnv has been created is not supported.');if(e===mt&&this.#l(),e===H&&(this.autoSync=this.hasAttribute(H)?this.getAttribute(H):!0),e==="src"){let t=(this.getAttribute("src")||"").trim();this.src$.set(t),this.shadowEnv.isReady&&this.#r?.run()}}start(){if(!this.#t){if(this.#e=!1,this.shadowEnv.view??=I.get(this.ns),this.shadowEnv.envProxy==null){let e=at(this,vt)?new Qt:new Kt;this.shadowEnv.envProxy=e,this.#l()}this.#t=!0}return this.shadowEnv.ready()}destroy(){this.#i?.destroy(),this.#r?.destroy(),M(this.isConnected$,this.autoSync$,this.src$),this.shadowEnv.envProxy=void 0,this.shadowEnv.destroy()}#o(){this.#e||(this.#e=!0,queueMicrotask(()=>{this.#e&&this.destroy()}))}#h(){this.#i=S(()=>{if(this.isConnected$.get()){let e=(this.autoSync$.get()||s.DefaultAutoSync).trim().toLowerCase(),t;if(["true","yes","on","frame","auto-sync"].includes(e))return this.logger.isDebug&&this.logger.debug("auto-sync",e,this),this.frameLoop.start(this),()=>{this.frameLoop.stop(this)};if(e.toLowerCase().endsWith("fps")){let i=parseInt(e,10);i>0?t=Math.floor(1e3/i):this.logger.isWarn&&this.logger.warn(`invalid auto-sync value: ${e}`)}else t=parseInt(e,10),isNaN(t)&&(t=void 0,["false","no","off"].includes(e)||this.logger.error(`invalid auto-sync value: ${e}`));if(t!==void 0&&t>0){this.logger.isDebug&&this.logger.debug("auto-sync interval (ms)",t,this);let i=setInterval(()=>{this.syncShadowObjects()},t);return()=>{clearInterval(i)}}else this.logger.isDebug&&this.logger.debug("auto-sync off",this)}},[this.autoSync$,this.isConnected$])}#l(){let e=this.shadowEnv.envProxy;e?.isLocalEnv&&(e.disableStructuredClone=this.hasAttribute(mt))}};customElements.define(Us,Yt);globalThis.SHADOW_ENTS_BUNDLE_LOADED=!0;
|
|
71
71
|
/*! Bundled license information:
|
|
72
72
|
|
|
73
73
|
@spearwolf/eventize/lib/index.mjs:
|
|
@@ -92,13 +92,13 @@ var ht="shaeRequestEntParent",lt="shaeReRequestEntParent",Ns="shae-worker",ct="s
|
|
|
92
92
|
limitations under the License.
|
|
93
93
|
*)
|
|
94
94
|
|
|
95
|
-
@spearwolf/signalize/dist/signalize.
|
|
95
|
+
@spearwolf/signalize/dist/signalize.DjCVnTTt.js:
|
|
96
96
|
@spearwolf/signalize/dist/index.js:
|
|
97
97
|
@spearwolf/signalize/dist/decorators.js:
|
|
98
98
|
(*!
|
|
99
99
|
@file @spearwolf/signalize - signals and effects for all
|
|
100
100
|
@author Wolfger Schramm <wolfger@spearwolf.de>
|
|
101
|
-
@version 0.
|
|
101
|
+
@version 0.30.0+esm.20260520
|
|
102
102
|
|
|
103
103
|
Copyright 2022-2026 Wolfger Schramm
|
|
104
104
|
|