@kosdev-code/kos-ui-sdk 2.1.28 → 2.1.29

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.
@@ -1 +1 @@
1
- {"version":3,"file":"kosModel.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kosModel.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA6lB5C,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CA0DjD"}
1
+ {"version":3,"file":"kosModel.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/core/core/decorators/kosModel.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwmB5C,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CA0DjD"}
@@ -214,7 +214,7 @@ export declare class KosModelContainer<T extends IKosDataModel> implements IKosM
214
214
  */
215
215
  private _evictModels;
216
216
  /**
217
- * Log capacity exceeded warning (Zone 3)
217
+ * Log capacity exceeded info (Zone 3)
218
218
  * @private
219
219
  */
220
220
  private _logCapacityWarning;
@@ -1 +1 @@
1
- {"version":3,"file":"kos-container-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/core/kos-container-model.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"kos-container-model.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/kos-ui-sdk/src/core/core/kos-container-model.ts"],"names":[],"mappings":"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"}
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var jh=Object.defineProperty;var Bh=(t,e,s)=>e in t?jh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var l=(t,e,s)=>(Bh(t,typeof e!="symbol"?e+"":e,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("loglevel"),M=require("mobx"),b=require("robot3"),ze=require("date-fns"),T=require("@emotion/react/jsx-runtime"),en=require("@emotion/styled"),Sa=require("react-dom"),rt=require("@emotion/react"),g=require("react"),tn=require("mobx-react-lite"),Hh=require("@use-gesture/react"),Kr="method",Ia="topic",Kt="url",Ns="request-id",qr="response-id",sn="status",je="dst-addr",Oa="src-addr",Ce="type",rn="ordered",on="tracker",$a="Content-Type",Ca="Cache-Control",Da="requestId",xa=process.env.KOS_LOGIN_URL||"http://localhost",Aa=process.env.KOS_APP_PORT||"8080",Kh=`${xa}:${Aa}`,pr="{MODEL_ID}";var Us=(t=>(t.SEND="/ws/log/msg/send",t.RECEIVED="/ws/log/msg/receive",t))(Us||{}),Ra=(t=>(t.MSG_RECEIVE="/mock/msg/receive",t))(Ra||{});const nn="/kos/model/ready/";D.info("Initializing event bus");globalThis.kos=globalThis.kos||{};globalThis.kos.subscriptions=globalThis.kos.subscriptions||{};const q=globalThis.kos.subscriptions,qh=()=>Symbol("eventKey");function an(t){return q[t]&&Object.getOwnPropertySymbols(q[t]).length>0}function C(t,e){const s=qh();return q[t]||(D.debug(`Initializing subscription for ${t}`),q[t]={}),D.debug(`Subscribing to ${t} with id ${s.toString()}`),q[t][s]=e,{count:q[t]?Object.getOwnPropertySymbols(q[t]).length:0,unsubscribe:()=>(D.debug(`Unsubscribing from ${t} with id ${s.toString()}`),q[t]&&q[t][s]&&delete q[t][s],q[t]&&Object.getOwnPropertySymbols(q[t]).length===0&&delete q[t],{count:q[t]?Object.getOwnPropertySymbols(q[t]).length:0})}}function V(t,e,s={}){if(!q[t]||Object.getOwnPropertySymbols(q[t]).length===0)return D.debug(`No subscriptions for ${t}. Not publishing.`),{eventType:t,subscribers:0};const r=Object.getOwnPropertySymbols(q[t]).length;return Object.getOwnPropertySymbols(q[t]).forEach(o=>{if(s.sync){const n=s.sync;D.debug(`Performing sync publish for ${t} with sync id ${n}`),q[t][o]({body:e,headers:s}).then(i=>{D.debug(`Response recieved for ${n}, publishing back to source.`),V(n,i)})}else D.debug(`Performing async publish for ${t}`),q[t][o]({body:e,headers:s})}),{eventType:t,subscribers:r}}function zh(){D.warn("Resetting event bus"),Object.keys(q).forEach(t=>delete q[t])}function Pa(t,e){const s=C(t,r=>{s.unsubscribe(),e(r)});return s.unsubscribe}function cn(t,e){return new Promise((s,r)=>{let o=null;const n=Pa(t,i=>{o&&clearTimeout(o),s(i)});e&&(o=setTimeout(()=>{n(),r(new Error(`Timeout waiting for event: ${t}`))},e))})}const Vh=Object.freeze(Object.defineProperty({__proto__:null,hasEventSubscriptions:an,once:Pa,publish:V,reset:zh,subscribe:C,waitFor:cn},Symbol.toStringTag,{value:"Module"}));function zr(t,e){const s=C(t,r=>{s.unsubscribe(),e(r)});return s.unsubscribe}function Vr(t,e){return new Promise((s,r)=>{let o=null;const n=zr(t,i=>{o&&clearTimeout(o),s(i)});e&&(o=setTimeout(()=>{n(),r(new Error(`Timeout waiting for event: ${t}`))},e))})}function ka(t,e){const s=t.map(r=>Vr(r,e));return Promise.all(s)}function La(t,e){return new Promise((s,r)=>{const o=[];let n=null,i=!1;const a=()=>{o.forEach(c=>c()),n&&clearTimeout(n)};t.forEach(c=>{const u=zr(c,d=>{i||(i=!0,a(),s({eventType:c,data:d}))});o.push(u)}),e&&(n=setTimeout(()=>{i||(i=!0,a(),r(new Error(`Timeout waiting for any event: ${t.join(", ")}`)))},e))})}function Fa(t,e,s){return C(t,o=>{o&&e(o)&&s(o)}).unsubscribe}function Na(t,e,s){return C(t,o=>{if(o){const n=e(o);s(n)}}).unsubscribe}function Ua(t,e,s){let r=null;const o=C(t,n=>{r&&clearTimeout(r),r=setTimeout(()=>{s(n)},e)});return()=>{r&&clearTimeout(r),o.unsubscribe()}}function ja(t,e,s){let r=0,o=null;const n=C(t,i=>{const a=Date.now(),c=a-r;c>=e?(r=a,s(i)):o||(o=setTimeout(()=>{r=Date.now(),s(i),o=null},e-c))});return()=>{o&&clearTimeout(o),n.unsubscribe()}}function Ba(t,e,s){let r=[],o=null;const n=()=>{r.length>0&&(s([...r]),r=[])},i=C(t,a=>{a&&(r.push(a),o||(o=setTimeout(()=>{n(),o=null},e)))});return()=>{o&&(clearTimeout(o),n()),i.unsubscribe()}}function ln(t,e=1){const s=[];return C(t,r=>{r&&(s.push(r),s.length>e&&s.shift())}),{subscribe:r=>(s.forEach(o=>r(o)),C(t,r))}}function Ha(t,e){const s=t.map(r=>C(r,o=>{o&&e(r,o)}));return()=>{s.forEach(r=>r.unsubscribe())}}function Ka(t,e){let s=t;const r=[],o=new Set;return Object.values(e).forEach(n=>{Object.keys(n).forEach(i=>{o.add(i)})}),o.forEach(n=>{const{unsubscribe:i}=C(n,a=>{const c=e[s];c&&c[n]&&(s=c[n](a))});r.push(i)}),{get state(){return s},unsubscribe:()=>{r.forEach(n=>n())}}}function qa(t,e,s,r){const o=Vr(e,r);return V(t,s),o}async function*za(t){const e=[],s=[],r=C(t,o=>{o&&(s.length>0?s.shift()(o):e.push(o))});try{for(;;)e.length>0?yield e.shift():yield await new Promise(o=>{s.push(o)})}finally{r.unsubscribe()}}const Gh={once:zr,waitFor:Vr,waitForAll:ka,race:La,filter:Fa,map:Na,debounce:Ua,throttle:ja,buffer:Ba,replay:ln,merge:Ha,stateMachine:Ka,request:qa,eventIterator:za},Yh=Object.freeze(Object.defineProperty({__proto__:null,EventBusFunctional:Gh,buffer:Ba,debounce:Ua,eventIterator:za,filter:Fa,map:Na,merge:Ha,once:zr,race:La,replay:ln,request:qa,stateMachine:Ka,throttle:ja,waitFor:Vr,waitForAll:ka},Symbol.toStringTag,{value:"Module"}));async function Gr(t,e){const{getCurrentState:s,transformState:r,shouldUseFetchedState:o,timeout:n}=e,i=cn(t,n),a=await s(),c=r?r(a):a;return o&&o(c)?(i.catch(()=>{}),c):await Promise.race([i,new Promise(d=>{setTimeout(()=>d(c),100)})])}function Va(t,e,s){const{getCurrentState:r,transformState:o}=s;let n=!1;const i=C(t,a=>{a&&(n=!0,e(a))});return Promise.resolve(r()).then(a=>{const c=o?o(a):a;n||e(c)}).catch(a=>{console.error("Failed to fetch initial state:",a)}),i.unsubscribe}function Ga(t,e){let s;const r=new Set,o=async()=>{try{typeof e=="string"?s=await(await fetch(e)).json():s=await e(),r.forEach(a=>a(s))}catch(a){throw console.error("Failed to fetch initial state:",a),a}};C(t,a=>{a!=null&&a.body&&(s=a.body,r.forEach(c=>c(s)))});let n=!1;const i=()=>{n||(n=!0,o())};return{get state(){return s},async getState(){return i(),s===void 0&&await new Promise(a=>{const c=()=>{s!==void 0?a():setTimeout(c,10)};c()}),s},subscribe(a){return i(),r.add(a),s!==void 0&&a(s),()=>{r.delete(a)}},async refresh(){return await o(),s}}}async function un(t,e){if(typeof t=="string")return Gr(t,e);const s=t,{getCurrentState:r,shouldUseFetchedState:o,timeout:n}=e,i=await r(),a=e.transformState?e.transformState(i):i;if(o&&o(a))return a;const c=s.map(d=>cn(d,n)),u=await Promise.all(c);return u[u.length-1]}function Ya(t,e,s){const{fetchMissedEvents:r,checkInterval:o=3e4,deduplicateById:n}=s,i=new Set,a=C(t,async u=>{if(u){if(n){const d=n(u);if(i.has(d))return;i.add(d),i.size>1e3&&Array.from(i).slice(0,500).forEach(f=>i.delete(f))}await e(u)}}),c=setInterval(async()=>{try{const u=await r(),d=Array.isArray(u)?u:[u];for(const h of d)if(n){const f=n(h);i.has(f)||(i.add(f),await e(h))}else await e(h)}catch(u){console.error("Failed to fetch missed events:",u)}},o);return()=>{a.unsubscribe(),clearInterval(c)}}function Wa(t){const{connectEvent:e,disconnectEvent:s,errorEvent:r,dataEvent:o,fetchInitialState:n,reconnectDelay:i=5e3}=t,a={state:"disconnected",data:void 0,async waitForConnection(d){if(a.state==="connected"&&a.data)return a.data;const h=await Gr(e,{getCurrentState:n,shouldUseFetchedState:f=>!!f,timeout:d});return a.state="connected",a.data=h,u(),h},subscribe(d){return c.add(d),d(a),()=>{c.delete(d)}},async reconnect(){a.state="connecting",u();try{const d=await n();a.state="connected",a.data=d,u()}catch{a.state="error",u(),setTimeout(()=>{a.state==="error"&&a.reconnect()},i)}}},c=new Set,u=()=>{c.forEach(d=>d(a))};return C(e,d=>{a.state="connected",d!=null&&d.body&&(a.data=d.body),u()}),C(s,()=>{a.state="disconnected",u(),setTimeout(()=>{a.state==="disconnected"&&a.reconnect()},i)}),r&&C(r,()=>{a.state="error",u()}),o&&C(o,d=>{d!=null&&d.body&&a.state==="connected"&&(a.data=d.body,u())}),a.reconnect(),a}const Wh={waitForOrGetState:Gr,subscribeWithInitialState:Va,createStatefulEventStream:Ga,waitForAllWithState:un,createResilientEventHandler:Ya,createConnectionStateManager:Wa},Qh=Object.freeze(Object.defineProperty({__proto__:null,EventBusState:Wh,createConnectionStateManager:Wa,createResilientEventHandler:Ya,createStatefulEventStream:Ga,subscribeWithInitialState:Va,waitForAllWithState:un,waitForOrGetState:Gr},Symbol.toStringTag,{value:"Module"})),Zh=(t,e=0)=>{if(!+t)return{value:0,scale:"bytes",toString:()=>"0 bytes"};const s=1024,r=e<0?0:e,o=["bytes","KB","MB","GB","TB"],n=Math.floor(Math.log(t)/Math.log(s)),i=parseFloat((t/Math.pow(s,n)).toFixed(r)),a=o[n];return{value:i,scale:a,toString:()=>`${i} ${a}`}};function dn(t){let e="pending",s;const r=t.then(n=>{e="success",s=n},n=>{e="error",s=n});return{read:()=>{switch(e){case"pending":throw r;case"error":throw s;default:return s}}}}function dt(){return"xxxxxxxx-xxxx-4xxx-2xxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function Xh(t,e){e.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(r=>{const o=Object.getOwnPropertyDescriptor(s.prototype,r);Object.defineProperty(t.prototype,r,o)})})}function Jh(t,e){const s=t??[],r=e??[];return s.length!==r.length?!1:s.every((o,n)=>o===r[n])}const hn=(t,e)=>{const s=t.map(n=>n.id);return e.map(n=>n.id).filter(n=>!s.includes(n))},Qa=t=>t,Za=t=>t,ef=({container:t,onAddItem:e,onUpdateItem:s,onRemoveItem:r=Qa,idMapper:o=Za})=>n=>{const i=n.map(o),c=hn(i,t.data).map(r).filter(Boolean);t.removeAll(c);const u=i.map(d=>{const h=t.getModel(d.id);return h&&s?s(d,h):e(d)}).filter(Boolean);t.addAll(u)},tf=({container:t,onAddItem:e,onRemoveItem:s=Qa,idMapper:r=Za})=>o=>{const n=o.map(r);hn(n,t.models).forEach(s),n.forEach(e)},sf=({items:t,onAddItem:e,onRemoveItem:s,idMapper:r=o=>o})=>o=>{const n=o.map(r);hn(n,t).forEach(s),n.forEach(e)},rf=(t,e="parent-")=>{let s=t;return s.startsWith(e)&&(s=s.replace(e,"")),s},$i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),Ci=[{amount:60,name:"seconds"},{amount:60,name:"minutes"},{amount:24,name:"hours"},{amount:7,name:"days"},{amount:4.34524,name:"weeks"},{amount:12,name:"months"},{amount:Number.POSITIVE_INFINITY,name:"years"}];function Xa(t){let e=(t.getTime()-Date.now())/1e3;for(let s=0;s<=Ci.length;s++){const r=Ci[s];if(Math.abs(e)<r.amount)return $i.format(Math.round(e),r.name);e/=r.amount}return $i.format(Math.round(e),"years")}const fn=t=>t%4===0&&t%100!==0||t%400===0,pn=(t,e)=>[31,fn(t)?29:28,31,30,31,30,31,31,30,31,30,31][e],Ja=(t,e)=>{const s=new Date(t),r=t.getDate();return s.setDate(1),s.setMonth(s.getMonth()+e),s.setDate(Math.min(r,pn(s.getFullYear(),s.getMonth()))),s},ec=(t,e)=>{const s=new Date(t);return s.setDate(s.getDate()+e),s},Dt="en-US",tc={short:{year:"numeric",month:"2-digit",day:"2-digit"},medium:{year:"numeric",month:"short",day:"2-digit"},long:{year:"numeric",month:"long",day:"numeric"},full:{year:"numeric",month:"long",day:"numeric",weekday:"long"}},sc={short:{hour:"2-digit",minute:"2-digit",hour12:!0},medium:{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0},long:{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZoneName:"short"},full:{hour:"2-digit",minute:"2-digit",hour12:!0,timeZoneName:"long"}},rc=(t,{dateStyle:e="short",locales:s=Dt}={dateStyle:"short",locales:Dt})=>{const r=e==="short"?tc.short:{dateStyle:e};return new Intl.DateTimeFormat(s,r).format(t)},oc=(t,{locales:e=Dt,timeStyle:s="short"}={locales:Dt,timeStyle:"short"})=>{const r=sc[s];return new Intl.DateTimeFormat(e,r).format(t)},nc=(t,{dateStyle:e="short",locales:s=Dt,timeStyle:r="short"}={dateStyle:"short",locales:Dt,timeStyle:"short"})=>{const o={...e&&tc[e],...r&&sc[r]};return new Intl.DateTimeFormat(s,o).format(t)},of=Object.freeze(Object.defineProperty({__proto__:null,addDaysToDate:ec,addMonthsToDate:Ja,formatDate:rc,formatDateSince:Xa,formatDateTime:nc,formatTime:oc,getDaysInMonth:pn,isLeapYear:fn},Symbol.toStringTag,{value:"Module"}));function ic(t,e,s=300){let r;return(...o)=>{clearTimeout(r),r=setTimeout(()=>{e.apply(t,o)},s)}}const te="canvas-renderer",go=new Map,Di=new Map,mo=new Map,yo=new Map,js=(t,e)=>{ac[t]=e},ac={indexExtension:{registerIndexExtension:(t,e)=>{const s=yo.get(t)||{};Object.assign(s,e),yo.set(t,e)},loadIndexExtensions:t=>yo.get(t)||{}},loader:{registerLoader:(t,e)=>{Di.set(t,e)},executeLoader:async(t,e)=>{const s=Di.get(t);if(s)return await s(e)}},propertyMapper:{registerPropertyMapper:(t,e)=>{mo.set(t,e)},hasMapper:t=>mo.has(t),executeMapper:(t,e,s)=>{const r=mo.get(t);return r?r(e,s):""}},dataMapper:{registerDataMapper:(t,e)=>{const s=go.get(t)||[];s.push(e),go.set(t,s)},executeMapper:async(t,e,s)=>{const r=go.get(t);if(!r)return{};const o={};for(const n of r){const i=await n(e,s);Object.assign(o,i)}return o}},canvas:{registerRenderer:(t,e)=>{if(!$[te]){console.warn(`Canvas renderer extension point is not registered. Cannot register renderer "${t}".`);return}$[te].register(t,e)}}},$=ac,nf=async({context:t,extension:e})=>{const s=await $.loader.executeLoader(e,{});return t==null||t.set(e,s),s},af=async({extension:t,contextData:e,data:s})=>await $.dataMapper.executeMapper(t,s,e),cf=async({extension:t,contextData:e,data:s})=>await $.propertyMapper.executeMapper(t,s,e),lf=Object.freeze(Object.defineProperty({__proto__:null,executeDataMapperExtension:af,executeLoaderExtension:nf,executePropertyMapperExtension:cf},Symbol.toStringTag,{value:"Module"})),uf="Extensions";class df{constructor(){l(this,"extensions");this.extensions={}}register(e,s,r){this.extensions[e]={},this.extensions[e][s]={component:r}}get(e,s){if(!this.extensions[e])throw new Error(`Extension point ${e} not found`);return this.extensions[e][s]}get allExtensions(){return this.extensions}}const ye=(t=null)=>(t||window.location.search.replace("?","")).split("&").map(e=>{const[s,r]=e.split("=");return[s,decodeURIComponent(r||"")]}).reduce((e,[s,r])=>(e[s]=r,e),{}),cc="studio.tools.preview",hf="studio.relax.store.validation",lc="studio.log.debug",uc="studio.log.info",ff={profiles:[cc]};var _a;const pf=((_a=globalThis.getKosConfig)==null?void 0:_a.call(globalThis))||JSON.stringify(ff),dc=JSON.parse(pf);globalThis.kosConfig=dc;const gn=dc,hc=()=>gn.profiles||[],Ro=t=>hc().includes(t),gf=()=>gn.logging||!1,mf=()=>{const t=Ro(lc),e=Ro(uc);return t?"DEBUG":e?"INFO":void 0},fc=()=>{const t=ye(),e=mf(),r=t.kosLogLevel??e??window.kosLogLevel??process.env.KOS_LOG_LEVEL;return r||"WARN"},pc=()=>window.kosMessageLogging||process.env.KOS_MESSAGE_LOGGING==="true",gc=()=>window.kosMessageStudioLogging||process.env.KOS_MESSAGE_STUDIO_LOGGING==="true",mc="ws-log",yf=D.methodFactory,yc=pc(),bf=gc();D.methodFactory=function(t,e,s){const r=yf(t,e,s);return function(...o){var c;const n=s?String(s):"",i=n?`[${String(n).substring(n.lastIndexOf(":")+1)}] | `:"[root] | ",a=o.map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(" ");r(`${i}${a}`),(c=globalThis==null?void 0:globalThis.kosConfig)!=null&&c.logging&&globalThis.kosLog&&(s!==mc||yc&&bf)&&globalThis.kosLog(`UI: ${i}${a}`)}};let bc=fc();D.setLevel(bc);window.setKosLogLevel=t=>{bc=t,D.setLevel(t)};const gr=D.getLogger(mc);window.enableKosMessageLog=()=>{gr.setLevel(D.levels.INFO)};window.disableKosMessageLog=()=>{gr.setLevel(D.levels.ERROR)};yc?window.enableKosMessageLog():window.disableKosMessageLog();const vf=["color: black","display: block","background-color: lightgreen","padding: 4px","margin: 0","text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)","box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset","font-weight: bold"].join(";"),wf=["color: black","display: block","padding: 4px","background-color: yellow","margin: 0","text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)","box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset","font-weight: bold"].join(";"),Ws=t=>e=>{D.getLevel()<=t&&e()},m={...D,ifDebug:Ws(D.levels.DEBUG),ifInfo:Ws(D.levels.INFO),ifWarn:Ws(D.levels.WARN),ifError:Ws(D.levels.ERROR),getLogger:t=>D.getLogger(`kos::${t}`),getLoggers:()=>D.getLoggers(),createLogger:({name:t,group:e})=>{var n,i,a,c;const s=`${e?`${e}:`:"kos"}::${t}`,r=D.getLogger(s);let o=(i=(n=globalThis.kos.logOverrides)==null?void 0:n.find(u=>u.name===s))==null?void 0:i.level;return o?r.setLevel(o):(o=(c=(a=globalThis.kos.logOverrides)==null?void 0:a.find(u=>s.startsWith(u.name)))==null?void 0:c.level,o&&r.setLevel(o)),r},wsSend:(...t)=>{const e=String(t).replace(/\n/g,"\\n");gr.info(`%c⬆ ${e}`,vf)},wsReceive:(...t)=>{const e=String(t).replace(/\n/g,"\\n");gr.info(`%c⬇ ${e}`,wf)}},vc="featureFlagResolver",Qs=new Map;js(vc,{register:(t,e)=>{var s;Qs.has(t)||Qs.set(t,[]),(s=Qs.get(t))==null||s.push(e)},execute:async(t,e)=>{const s=Qs.get(t);if(!s)return[];const r=s.map(a=>a(e)),n=(await Promise.allSettled(r)).map(a=>a.status==="fulfilled"?a.value:(m.info(`Feature flag resolver ${t} failed: ${a.reason}`),[])).flat(),i=Array.from(new Set(n)).reduce((a,c)=>(a[c]=!0,a),{});return Ec.updateFlags(i),Object.keys(i)}});const Ef="kos.loader.featureFlag";class wc{constructor(e={}){l(this,"flags",{});this.flags=e}isFeatureEnabled(e){return!!this.flags[e]}enableFeature(e){this.flags[e]=!0}disableFeature(e){this.flags[e]=!1}toggleFeature(e){this.flags[e]=!this.flags[e]}updateFlags(e){this.flags={...this.flags,...e}}}window.KosFeatureFlags=window.KosFeatureFlags??new wc;const Ec=window.KosFeatureFlags,Mc=(t,e,s)=>{s/=100;const r=e*Math.min(s,1-s)/100,o=n=>{const i=(n+t/30)%12,a=s-r*Math.max(Math.min(i-3,9-i,1),-1);return Math.round(255*a).toString(16).padStart(2,"0")};return`#${o(0)}${o(8)}${o(4)}`},Tc=t=>{const s=new RegExp("hsl\\((\\d+),\\s+(\\d+)\\%,\\s+(\\d+)\\%\\)").exec(t);if(!s)throw Error("Invalid HSL string");return Mc(parseInt(s[1]),parseInt(s[2]),parseInt(s[3]))},_c=(t,e)=>getComputedStyle(t).getPropertyValue(e),Mf=(t,e)=>Tc(_c(t,e)),Tf=(t,e)=>{const s={...t};return s.id&&delete s.id,s},Po=(t,e,s=Tf)=>{const r=s(t,e);M.runInAction(()=>{Object.assign(e,r)})},ee=Symbol("SubscriptionHandlers"),F=Symbol("DependencyModels"),gs=Symbol("FutureService"),Ge=Symbol("ChildModels"),ms=Symbol("ParentModel"),ys=Symbol("LogConfig"),ar=Symbol("ReferenceConfig"),mn=Symbol("KosModelSymbol"),at=Symbol("ModelEffects"),Ye=Symbol("CompanionParentModel"),yn=Symbol("FutureContainerSetup"),bn=Symbol("MultipleFutureContainerSetup"),bs=Symbol("FutureAliases"),vn=Symbol("TroubleAwareSetup"),wn=Symbol("LoggerSetup"),En=Symbol("ContainerAwareSetup"),Bs=Symbol("StateMachineSetup"),Ot=Symbol("StateEntryHandlers"),vs=Symbol("StateExitHandlers"),_f=Symbol("StateActionHandlers"),Hs=Symbol("OptionsRequired"),Sf=m.createLogger({group:"decorators",name:"fsm-injection"});function Sc(t){const e=t[Bs];if(!e)return;const{config:s,options:r}=e;Cf(t,s,r),Df(t,r);const o=$f(t);If(t,s,r,o),Of(t,s,r)}function If(t,e,s,r){t.transition=Rf(t,e,s,r.entry,r.exit),t.canTransition=Bf(t,e,s),t.isInState=Hf(t,s)}function Of(t,e,s){xf(t),Af(t,e,s)}function $f(t){const e=t.constructor.prototype[Ot]||new Map,s=t.constructor.prototype[vs]||new Map;return{entry:e,exit:s}}function Cf(t,e,s){t._fsmConfig=e,t._fsmOptions=s}function Df(t,e){const{stateProperty:s,trackHistory:r}=e,o=t._fsmConfig;t[s]=o.initial,t._fsmInitialized=!0,t.isTransitioning=!1,r&&(t.stateHistory=[{state:o.initial,timestamp:new Date}])}function xf(t){Object.defineProperty(t,"isFsmInitialized",{get(){return this._fsmInitialized},enumerable:!0,configurable:!0})}function Af(t,e,s){const{stateProperty:r}=s;Object.defineProperty(t,"allowedTransitions",{get(){if(!this._fsmInitialized)return[];const o=this[r],n=this._fsmConfig.states[o];return n!=null&&n.on?Object.keys(n.on):[]},enumerable:!0,configurable:!0})}function Rf(t,e,s,r,o){const{stateProperty:n,throwOnInvalid:i}=s;return function(a){if(!this._fsmInitialized){Pf(e.initializeAt,i);return}const c=this[n],u=kf(c,a,this._fsmConfig,i);u&&Ff(this,c,u,a,n,r,o,s)}}function Pf(t,e){const s=`Cannot transition: FSM not initialized. Waiting for ${t} lifecycle phase.`;if(e)throw new Error(s);console.warn(s)}function kf(t,e,s,r){var i;const o=s.states[t],n=(i=o==null?void 0:o.on)==null?void 0:i[e];if(!n){Lf(t,e,r);return}return n}function Lf(t,e,s){const r=`Invalid transition: Event "${e}" not allowed from state "${t}"`;if(s)throw new Error(r);console.warn(r)}function Ff(t,e,s,r,o,n,i,a){t.isTransitioning=!0;try{Nf(t,e,i),t[o]=s,jf(t,s,r,a),Uf(t,s,n)}finally{t.isTransitioning=!1}}function Nf(t,e,s){const r=s.get(e);r&&typeof t[r]=="function"&&t[r]()}function Uf(t,e,s){const r=s.get(e);r&&typeof t[r]=="function"&&t[r]()}function jf(t,e,s,r){r.trackHistory&&t.stateHistory&&t.stateHistory.push({state:e,timestamp:new Date,event:s})}function Bf(t,e,s){const{stateProperty:r}=s;return function(o){var a;if(!this._fsmInitialized)return!1;const n=this[r],i=this._fsmConfig.states[n];return((a=i==null?void 0:i.on)==null?void 0:a[o])!==void 0}}function Hf(t,e){const{stateProperty:s}=e;return function(r){return this._fsmInitialized?this[s]===r:!1}}function Ic(t,e){const s=t[Bs];if(!s)return;const{config:r,options:o}=s,{stateProperty:n}=o;r.initializeAt===e&&(t._fsmInitialized||(Kf(t,n,r.initial),t._fsmInitialized=!0,qf(t,r.initial,o),zf(t,r.initial),Sf.debug(`FSM initialized for model ${t.id} at lifecycle ${e} with initial state "${r.initial}"`)))}function Kf(t,e,s){t[e]=s}function qf(t,e,s){s.trackHistory&&t.stateHistory&&t.stateHistory.push({state:e,timestamp:new Date})}function zf(t,e){const r=(t.constructor.prototype[Ot]||new Map).get(e);r&&typeof t[r]=="function"&&t[r]()}const De=(t,e)=>{t[Ge]=t[Ge]||{},t[Ge][e]=!0},ht=t=>`{PROP_${String(t)}}`,Vf=t=>`{PROP_${String(t)}}`,Gf=ht("kosParentId"),Yr=t=>e=>{e[ms]=e[ms]||{};const s=(t==null?void 0:t.parentId)||Gf;e[ms]={parentId:s},e.prototype[Hs]=!0};function Yf(t){return e=>{const s=(t==null?void 0:t.mode)||"decorator",r=(t==null?void 0:t.parentProperty)||"companionParent",o=(t==null?void 0:t.excludeProperties)||[],n=t==null?void 0:t.lifecycle;return Yr()(e),e.prototype[Ye]={mode:s,parentProperty:r,excludeProperties:o,lifecycle:n},e}}function Oc(t){return e=>{const s=t!=null&&t.legacy?"_models":(t==null?void 0:t.containerProperty)||"container",r=(t==null?void 0:t.includeMethods)!==!1,o=(t==null?void 0:t.includeGetters)!==!1,n=(t==null?void 0:t.modelsProperty)||"models",i=(t==null?void 0:t.containerOptions)||{};return e.prototype[En]={containerProperty:s,includeMethods:r,includeGetters:o,modelsProperty:n,containerOptions:i,legacy:(t==null?void 0:t.legacy)||!1},e}}function Wf(t,e,s){const r=s.value;s.value=function(...o){const n=Y.getContext(this.id);return o.push(n),r.apply(this,o)}}const Wr=Symbol("KosExecutionContext");function Mn(t){return t&&typeof t=="object"&&Wr in t}function Qf(t){return e=>{const s=(t==null?void 0:t.mode)||"full",r=(t==null?void 0:t.handlerProperty)||"futureHandler";return e.prototype[yn]={mode:s,handlerProperty:r},e}}function Zf(t){return e=>{const s=(t==null?void 0:t.mode)||"full",r=(t==null?void 0:t.handlerProperty)||"futureHandler";return e.prototype[bn]={mode:s,handlerProperty:r},e}}var x=(t=>(t.INIT="init",t.LOAD="load",t.READY="ready",t.ACTIVATE="activate",t.ONLINE="online",t))(x||{}),Ve=(t=>(t.CREATE="create",t.CONTINUE="continue",t.FAIL="fail",t))(Ve||{});const Xf=Object.freeze(Object.defineProperty({__proto__:null,DependencyLifecycle:x,DependencyResolutionPolicy:Ve},Symbol.toStringTag,{value:"Module"})),ke=Symbol("HttpRouteHandlers"),xi="__httpBrowserRouter";function Qr(t){return function(s){return function(r,o,n){r[ke]=r[ke]||[];const i={method:t,path:s,handler:o};return r[ke].push(i),r[F]=r[F]||{},r[F][xi]||(r[F][xi]={modelType:"browser-router-model",lifecycle:x.INIT}),n}}}const $c=Qr("GET"),Ks=Qr("POST"),Jf=Qr("PUT"),Cc=Qr("DELETE"),ep=Cc;function mr(t){return!!(t!=null&&t[ke])&&t[ke].length>0}function Dc(t){return(t==null?void 0:t[ke])||[]}const tp=({group:t}={group:""})=>e=>{e[ys]=e[ys]||{},e[ys]={group:t}};class xc{static create({modelId:e,modelTypeName:s,component:r}){const o=[r??"kos",s,e].filter(Boolean).join(".");return m.createLogger({name:o})}}function Ac(t){return e=>{const s=(t==null?void 0:t.loggerProperty)||"logger",r=t==null?void 0:t.loggerContext;e.prototype[wn]={loggerProperty:s,loggerContext:r};const o=()=>{var i;return(i=e.prototype[mn])==null?void 0:i.type};let n;return Object.defineProperty(e.prototype,s,{get(){if(!n){const i=o();n=xc.create({modelTypeName:r||i,component:"kos-model"})}return n},enumerable:!1,configurable:!1}),e}}function Rc(t){return(e,s,r)=>{e[at]=e[at]||{},e[at][s]={dependencies:t==null?void 0:t.dependencies,value:r.value},r.value=function(){throw new Error(`Method ${s} cannot be called directly.`)}}}const sp=t=>(e,s)=>{e[ar]=e[ar]||{},e[ar][s]=t},bo=m.createLogger({name:"resolve-parameters"}),Me=({value:t,modelId:e,modelData:s})=>{let r=t;if(Array.isArray(r))return[...t];if(typeof r!="string"&&typeof r!="object")return r;if(typeof r=="object")r=Object.keys(r).reduce((o,n)=>(o[n]=Me({value:r[n],modelId:e,modelData:s}),o),{});else if(typeof r=="string"){const o=new RegExp("{PROP_(.+?)}","g");let n=r!=null&&r.includes(pr)?r.replace(pr,e):r;if(s){let i=!1;const a=/^{PROP_.+?}$/.test(n);if(n=n.replace(o,(c,u)=>{if(Object.getOwnPropertyNames(s).includes(u)||Object.getOwnPropertyNames(Object.getPrototypeOf(s)).includes(u)){const h=s[u];return h?(bo.debug(`Resolved ${c} to ${h}`),h):(bo[a?"debug":"warn"](`Property ${u} is falsy${a?"":" in composite string"}, marking for undefined return`),i=!0,c)}return bo[a?"debug":"warn"](`Property ${u} not found in modelData${a?"":" for composite string"}`),c}),i)return}return n}else return r;return r},ct=Symbol("ServiceRequestHandlers"),Ai=new WeakMap;function ft(t){return(e,s,r)=>{var a;e[ct]=e[ct]||{};const o=r.value,n={...t,handlerMethod:s,originalHandler:o},i=`${((a=t.method)==null?void 0:a.toUpperCase())||"GET"}:${String(t.path)}`;if(e[ct][i]=n,!t.lifecycle){const c=function(...u){const d=u[u.length-1],h=async f=>{const p=Ai.get(c);if(!p)throw new Error("Service request metadata not found for method");try{const{default:y}=await Promise.resolve().then(()=>al),w=Me({value:p.path,modelId:this.id,modelData:this}),E={...typeof p.pathParams=="function"?p.pathParams(this):p.pathParams||{},...(f==null?void 0:f.pathParams)||{}},_={...typeof p.queryParams=="function"?p.queryParams(this):p.queryParams||{},...(f==null?void 0:f.queryParams)||{}},k=(f==null?void 0:f.body)||(typeof p.body=="function"?p.body(this):p.body),O={...(typeof p.requestOptions=="function"?p.requestOptions(this,...u):p.requestOptions)||{},...(f==null?void 0:f.requestOptions)||{}},S={};Object.keys(E).length>0&&(S.path=E),Object.keys(_).length>0&&(S.query=_);const z=(p.method||"get").toLowerCase(),j=y,[Z,Ke]=z==="get"?await j.get(w,S,O):z==="post"?await j.post(w,S,k,O):z==="put"?await j.put(w,S,k,O):z==="delete"?await j.delete(w,S,k,O):await j.get(w,S,O);if(Z){if(p.errorHandler)switch(p.errorHandler.strategy){case"log":return console.error(`Service request error: ${Z}`),p.errorHandler.onError&&p.errorHandler.onError(new Error(Z),this),[null,p.errorHandler.defaultValue];case"ignore":return[null,p.errorHandler.defaultValue];case"default":return[null,p.errorHandler.defaultValue];case"throw":default:return[Z,null]}return[Z,null]}let qe=Ke;return p.transform&&(qe=p.transform(Ke)),[null,qe]}catch(y){return[y.message||"Unknown error",null]}};if(Mn(d))return d.$request=h,o.apply(this,u);{const f={[Wr]:!0,$request:h};return o.apply(this,[...u,f])}};Ai.set(c,n),r.value=c}return r}}var Pc=(t=>(t.GET="GET",t.PUT="PUT",t.POST="POST",t.DELETE="DELETE",t))(Pc||{}),de=(t=>(t.IMMEDIATE="immediate",t.SINGLE="single",t.TTL="ttl",t.PERMANENT="permanent",t.MANUAL="manual",t))(de||{}),it=(t=>(t.ALL="all",t.AFTER_REQUEST="after-request",t.AFTER_RESPONSE="after-response",t.NONE="none",t))(it||{});const rp=m.createLogger({name:"kos-state-machine"});function op(t,e){return s=>(s.prototype[Bs]={config:{...t,initializeAt:t.initializeAt||x.READY},options:{stateProperty:(e==null?void 0:e.stateProperty)||"currentState",trackHistory:(e==null?void 0:e.trackHistory)||!1,throwOnInvalid:(e==null?void 0:e.throwOnInvalid)!==!1}},s)}function np(t){return(e,s)=>{e[Ot]||(e[Ot]=new Map),e[Ot].set(t,s)}}function ip(t){return(e,s)=>{e[vs]||(e[vs]=new Map),e[vs].set(t,s)}}function ap(t){return(e,s,r)=>{const o=r.value;return r.value=function(...n){var u,d;if(!this.isFsmInitialized)return o.apply(this,n);const a=this.currentState;if(!t.allowedStates.includes(a)){const h=`Method ${String(s)} cannot be called from state "${a}". Allowed states: ${t.allowedStates.join(", ")}`;if(t.throwOnInvalid!==void 0?t.throwOnInvalid:((d=(u=this[Bs])==null?void 0:u.options)==null?void 0:d.throwOnInvalid)!==!1)throw new Error(h);rp.warn(h);return}return o.apply(this,n)},r}}function cp(t){return e=>{const s=(t==null?void 0:t.pathProperty)||"path";return e.prototype[vn]={pathProperty:s},e.prototype[F]=e.prototype[F]||{},e.prototype[F].troubleContainer={modelType:"trouble-container-model",id:"trouble-container-model",options:{},lazy:!1},e}}const qt=({modelType:t,id:e,options:s,lifecycle:r,resolutionPolicy:o})=>(n,i)=>{n[F]=n[F]||{},n[F][i]={modelType:t,id:e,options:s,lifecycle:r||x.INIT,resolutionPolicy:o}};class kc{constructor(e,s){l(this,"futures");l(this,"defaultContext");l(this,"context");l(this,"disposers",new Map);l(this,"container");this.futures=An.map(new Map),this.context="",this.defaultContext=s||"",this.container=e,M.makeAutoObservable(this)}get allFutures(){return Array.from(this.futures.values())}get future(){return this.futures.get(this.defaultContext)}addFuture(e,s){this.futures.set(s||e.id,e),this.context=s||e.id;const r=W(()=>{var o,n;(e.endState||e.progress)&&((n=(o=this.container)==null?void 0:o.onFutureUpdate)==null||n.call(o,e))});this.disposers.set(s||e.id,r)}removeFuture(e){var s;this.futures.delete(e||this.context),(s=this.disposers.get(e||this.context))==null||s(),this.disposers.delete(e||this.context)}getFuture(e){return this.futures.get(e||this.context)}get futureMap(){return this.futures}}class Zr{constructor(e){l(this,"disposer");l(this,"_future");l(this,"container");l(this,"onFutureUpdate");this._future=void 0,this.container=e,M.makeAutoObservable(this)}removeFuture(){var e;this._future=void 0,(e=this.disposer)==null||e.call(this),this.disposer=void 0}get future(){return this._future}getFuture(){return this._future}addFuture(e){this._future=e;const s=W(()=>{var r,o;(e.endState||e.progress)&&((o=(r=this.container)==null?void 0:r.onFutureUpdate)==null||o.call(r,e))});this.disposer=s}get allFutures(){return this._future?[this._future]:[]}get timeRemaining(){var e;return((e=this._future)==null?void 0:e.timeRemaining)||""}get status(){var e;return((e=this._future)==null?void 0:e.status)||"NOT_RESOLVED"}get progress(){var e;return((e=this._future)==null?void 0:e.progress)||-1}async cancel(){if(this._future)try{await this._future.cancelFuture()}catch(e){throw m.error(e),e}}}const Lc=(t,e)=>{const s=e.type;return t[s]||(t[s]=[]),t[s].push(e),t},Fc=Symbol("KosObservableData"),Jt=Symbol("revision");var LT;class Nc{constructor(){l(this,"map");l(this,LT,1);l(this,"atomMap",new Map);l(this,"proxyHandler",{get:(e,s)=>{var r;return s===Jt||e[s]!==void 0?e[s]:this.atomMap.has(s)&&(r=this.atomMap.get(s))!=null&&r.reportObserved()?this.getValue(s):this.getValue(s)},set:(e,s,r)=>{var o;return this.map.has(s),this.setValue(s,r),this.atomMap.has(s)||this.atomMap.set(s,M.createAtom(s.toString())),(o=this.atomMap.get(s))==null||o.reportChanged(),!0},ownKeys:()=>Array.from(this.map.keys())});this.map=M.observable.map(new Map),M.makeObservable(this,{[Jt]:M.observable})}setValue(e,s){const r=this.map.has(e);this.map.set(e,s),r||M.action(()=>{this[Jt]++})()}getValue(e){return this.map.get(e)}has(e){return this.map.has(e)}get entries(){return Array.from(this.map.entries())}get keys(){return this[Jt],Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}setValues(e){e&&Object.keys(e).forEach(s=>{this.setValue(s,e[s])})}get proxy(){return new Proxy(this,this.proxyHandler)}}LT=Jt;Nc.prototype[Fc]=!0;function lp(t,e){return new Proxy(t,{construct:(s,r)=>{const o=new t(...r);return o.setValues(e),o.proxy}})}const Oe=t=>{const e=lp(Nc,t);return new e(t)};function up(t,e){return t.length!==e.length?!1:t.every(s=>e.includes(s))}class Tn{constructor({container:e,key:s}){l(this,"_container");l(this,"_map");l(this,"_key");l(this,"data");this._container=e,this._map=M.observable.map(new Map),this._key=s,this.data=Oe(),this.generateIndex(),M.autorun(()=>{this._container.revision&&this.generateIndex()}),M.makeAutoObservable(this)}refresh(){this.generateIndex()}addItemToIndex(e,s,r=this._map,o=this.data){const n=r.get(e)||new Set;n.add(s),r.set(e,n),o[e]=Array.from(n)}resolveIndex(e,s){this.data.keys.filter(o=>!Object.keys(s).includes(o)).forEach(o=>{delete this.data[o],this._map.delete(o)}),Object.keys(s).forEach(o=>{const n=s[o],i=this.data[o]||[];if(up(n,i))m.debug(`KosContainerIndex - Index ${o} is the same`);else{this.data[o]=n;const a=e.get(o)||new Set;this._map.set(o,a)}})}generateIndex(){M.runInAction(async()=>{const e=new Map,s={};for(const r of this._container.data){const o=typeof this._key=="function"?await this._key(r):r[this._key];Array.isArray(o)?o.forEach(n=>{this.addItemToIndex(n,r,e,s)}):typeof o=="string"||typeof o=="number"?this.addItemToIndex(String(o),r,e,s):typeof o=="boolean"&&this.addItemToIndex(String(o),r,e,s)}this.resolveIndex(e,s)})}get keys(){return Array.from(this._map.keys())}get index(){return this._map}getByKey(e){const s=this._map.get(e);return s?Array.from(s):[]}}function dp(t,e,s=[]){const r=Object.getOwnPropertyDescriptors(t);return Object.keys(r).filter(i=>M.isComputedProp(t,i)).filter(i=>s.includes(i)).map(i=>M.reaction(()=>t[i],(a,c)=>{e({name:i,newValue:a,oldValue:c})}))}const ne=m.createLogger({name:"kos-container-model"});class xe{constructor(e){l(this,"_data");l(this,"_sortKey");l(this,"_revision");l(this,"_index");l(this,"_optionsMap");l(this,"_disposerMap",new Map);l(this,"_parentId");l(this,"idx");l(this,"_maxCapacity");l(this,"_evictionStrategy");l(this,"_evictionBatchSize");l(this,"_insertionOrder",[]);l(this,"_accessTimes");l(this,"_customEvictionFilter");this._data=M.observable.map(new Map),this._sortKey=e==null?void 0:e.sortKey,this._revision=1;const s=e!=null&&e.extensionId?$.indexExtension.loadIndexExtensions(e.extensionId):{},r=(e==null?void 0:e.indexMap)||{};this._optionsMap={...r,...s};const o=e!=null&&e.indexMap?Object.keys(e.indexMap).reduce((n,i)=>(n[i]=void 0,n),{}):{};this._index=M.observable.map(o),this.idx=Oe(),this._parentId=e==null?void 0:e.parentId,this._maxCapacity=e==null?void 0:e.maxCapacity,this._evictionStrategy=(e==null?void 0:e.evictionStrategy)||"fifo",this._evictionBatchSize=(e==null?void 0:e.evictionBatchSize)??Math.max(10,Math.ceil(((e==null?void 0:e.maxCapacity)??100)*.1)),this._customEvictionFilter=e==null?void 0:e.customEvictionFilter,this._evictionStrategy==="lru"&&this._maxCapacity&&(this._accessTimes=M.observable.map(new Map)),M.makeAutoObservable(this),this.init()}init(){Object.keys(this._optionsMap).forEach(e=>{const s=this._optionsMap[e],r=new Tn({container:this,key:s});this._index.set(e,r),this.idx[e]=r.data})}[Symbol.iterator](){return this.data[Symbol.iterator]()}get index(){return this._index}get revision(){return this._revision}get indexKeys(){return Array.from(this.index.keys()).reduce((e,s)=>{var r;return e[s]=(r=this.index.get(s))==null?void 0:r.keys,e},{})}sortFn(e,s){const r=this._sortKey;return r?String(e[r]).localeCompare(String(s[r]),void 0,{numeric:!0}):0}get data(){const e=Array.from(this._data.values());return this._sortKey&&e.sort(this.sortFn.bind(this)),e}increment(){M.runInAction(()=>{this._revision=this._revision+1})}addAll(e){M.runInAction(()=>{e.forEach(s=>this.addModel(s,!0))}),this.increment()}removeAll(e){M.runInAction(()=>{e.forEach(s=>this.removeModel(s,!0)),this.increment()})}async removeAndDestroy(e){const s=this.getModel(e);if(!s){ne.debug(`Model ${e} not found in container, skipping destroy`);return}this.removeModel(e);try{await Ie(s)}catch(r){throw ne.error(`Failed to destroy model ${e}:`,r),r}}async removeAndDestroyAll(e){const s=e.map(n=>this.getModel(n)).filter(n=>n!==void 0);if(s.length===0){ne.debug("No models found to destroy");return}this.removeAll(e);const r=await Promise.allSettled(s.map(n=>Ie(n)));r.forEach((n,i)=>{n.status==="rejected"&&ne.error(`Failed to destroy model ${s[i].id}:`,n.reason)});const o=r.filter(n=>n.status==="rejected");if(o.length>0)throw new Error(`Failed to destroy ${o.length} of ${s.length} models`)}addModel(e,s){this._persistModel(e),this._trackModelMetadata(e),this._establishModelRelationships(e),this._enforceCapacityLimits(),this._configureModelMonitoring(e),s||this.increment()}_persistModel(e){this._data.set(e.id||"",e)}_trackModelMetadata(e){this._maxCapacity&&(this._insertionOrder.push(e.id||""),this._accessTimes&&this._accessTimes.set(e.id||"",Date.now()))}_establishModelRelationships(e){e.id&&this._parentId&&Y.setParentContext(e.id,this._parentId)}_enforceCapacityLimits(){this._maxCapacity&&this._data.size>this._maxCapacity&&this._evictModels()}_configureModelMonitoring(e){const s=this._disposerMap.get(e.id);s&&(s(),this._disposerMap.delete(e.id));const r=Object.entries(this._optionsMap||{}),o=Object.values(this._optionsMap||{}),n=new Map(r.map(([u,d])=>[d,u])),i=u=>{var h,f;o.includes(u.name)&&((h=this.index.get(n.get(u.name)))==null||h.refresh());const d=r.filter(([,p])=>typeof p=="function");for(const[p]of d)(f=this.index.get(p))==null||f.refresh()},a=dp(e,i,o.filter(u=>typeof u=="string")),c=M.observe(e,i);this._disposerMap.set(e.id||"",()=>[c,...a].forEach(u=>u()))}removeModel(e,s){this._data.delete(e);const r=this._insertionOrder.indexOf(e);r!==-1&&this._insertionOrder.splice(r,1),this._accessTimes&&this._accessTimes.delete(e),s||this.increment();const o=this._disposerMap.get(e);o&&(o(),this._disposerMap.delete(e))}updateModel(e){this._data.set(e.id||"",e),this.increment()}getModel(e){const s=this._data.get(e);return s&&this._accessTimes&&this._accessTimes.set(e,Date.now()),s}getIndexKeys(e){return this.index.has(e)?this.index.get(e).keys??[]:(ne.info(`index ${e} not found in ${Array.from(this.index.keys())}`),[])}getIndexByKey(e,s){if(this.index.has(e)){const r=this.index.get(e);return r.index.has(s)?r.getByKey(s):(ne.info(`key ${s} not found in ${e} index: ${Array.from(r.index.keys())}`),[])}else return ne.info(`index ${e} not found in ${Array.from(this.index.keys())}`),[]}async _evictModels(){if(!this._maxCapacity)return;const e=this._data.size-this._maxCapacity;if(e<=0)return;const s=Math.min(this._evictionBatchSize,e);this._logCapacityWarning(s);const r=this._selectModelsForEviction(s);await this._removeEvictedModels(r),this._logEvictionComplete(r.length),this.increment()}_logCapacityWarning(e){ne.warn(`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${e} models using ${this._evictionStrategy} strategy. This may indicate missing cleanup handlers or data inconsistency.`,{parentId:this._parentId})}_selectModelsForEviction(e){switch(this._evictionStrategy){case"fifo":return this._selectFifoModels(e);case"lru":return this._selectLruModels(e);case"custom":return this._selectCustomModels(e);default:return this._selectFifoModels(e)}}_selectFifoModels(e){const s=[];for(let r=0;r<e&&this._insertionOrder.length>0;r++){const o=this._insertionOrder.shift();if(!o)continue;const n=this._data.get(o);n&&s.push(n)}return s}_selectLruModels(e){const s=[];return this._accessTimes&&Array.from(this._accessTimes.entries()).sort((o,n)=>o[1]-n[1]).slice(0,e).forEach(([o])=>{const n=this._data.get(o);n&&s.push(n)}),s}_selectCustomModels(e){return this._customEvictionFilter?this._customEvictionFilter(this.data).slice(0,e):(ne.error("Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",{parentId:this._parentId}),this._selectFifoModels(e))}async _removeEvictedModels(e){for(const s of e)ne.warn(`Evicting model: ${s.id} (type: ${s.constructor.name})`,{modelId:s.id,parentId:this._parentId,strategy:this._evictionStrategy}),this.removeModel(s.id,!0),Ie(s).catch(r=>ne.error(`Failed to destroy evicted model ${s.id}:`,r))}_logEvictionComplete(e){ne.info(`Evicted ${e} models. Current size: ${this._data.size}/${this._maxCapacity}`,{parentId:this._parentId})}async clear(){this._data.forEach(e=>{const s=e.id;Ie(e).then(()=>{ne.debug(`${s} destroyed, removing from map`),this.removeModel(s,!0)}).catch(r=>ne.error(r))}),this.increment()}filter(e,s){return this.data.filter(e,s)}sort(e){return this.data.sort(e)}map(e,s){return this.data.map(e,s)}forEach(e,s){this.data.forEach(e,s)}toJSON(){return{indexes:this.indexKeys,data:this.data.map(s=>({id:s.id,type:s.constructor.name}))}}}var v=(t=>(t.CREATING="creating",t.CREATED="created",t.INITIALIZING="initializing",t.INITIALIZED="initialized",t.LOADING="loading",t.LOADED="loaded",t.ONLINE="online",t.READYING="readying",t.READY="ready",t.READY_FAILED="ready_failed",t.RESETTING="resetting",t.RESET="reset",t.OFFLINE="offline",t.UNLOADING="unloading",t.UNLOADED="unloaded",t.FAILED="failed",t.INACTIVE="inactive",t.ACTIVE="active",t.ACTIVATING="activating",t.DEACTIVATING="deactivating",t))(v||{}),L=(t=>(t.CREATE="create",t.INITIALIZE="init",t.LOAD="load",t.READY="ready",t.GO_ONLINE="go_online",t.GO_OFFLINE="go_offline",t.RESET="go_offline",t.UNLOAD="unload",t.FAILED="failed",t.GO_ACTIVE="go_active",t.GO_INACTIVE="go_inactive",t.TIMEOUT="timeout",t))(L||{});const he=async t=>{if(t.id){const e=I.getInstance().modelManager.getModelById(t.id);if(!e)throw new Error(`Model with ID ${t.id} not found`);await(e==null?void 0:e.whenReady())}else throw new Error("Data model must have a valid ID");return t},Ie=async t=>{await I.getInstance().whenReady(),await I.getInstance().modelManager.initiateDestroyModel(t)},hp=async t=>{if(await I.getInstance().whenReady(),!t.id)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t.id);e&&await e.fsm.transitionTo(L.UNLOAD,v.UNLOADED)},fp=async t=>{await I.getInstance().whenReady(),await I.getInstance().modelManager.reloadModel(t),m.debug(`reload model initiated for model ${t.id}, model ready: ${yr(t)} - ${Date.now()} `),await he(t),m.debug(`reload model complete for model ${t.id}, model ready: ${yr(t)} - ${Date.now()} `)},pp=async t=>{if(await I.getInstance().whenReady(),!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);return e==null?void 0:e.modelTypeName},Uc=async t=>{if(await I.getInstance().whenReady(),!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);return{model:e==null?void 0:e.modelData,type:e==null?void 0:e.modelTypeName}},$e=t=>{if(!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);return{model:e==null?void 0:e.modelData,type:e==null?void 0:e.modelTypeName}},jc=(t,e)=>{if(!t)throw new Error("Model type is required");return I.getInstance().modelManager.getModelsByType(t).filter(o=>Object.keys(e).every(n=>o[n]===e[n]))},gp=(t,e)=>jc(t,e)[0],mp=(t,e)=>{if(!t.id)throw new Error("Model ID is required");const s=I.getInstance().modelManager.getModelById(t.id);if(!s)throw new Error("Model not found");const r=s.companionModels.get(e);return r==null?void 0:r.modelData},Bc=t=>{if(!t.id)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t.id);if(!e)throw new Error("Model not found");return Array.from(e.companionModels.all()).map(r=>r.modelData)},yp=t=>{if(!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);if(!e)throw new Error("Model not found");return e.companionModels.data},ko=(t,e)=>{const s=I.getInstance().modelManager.getModelById(t);if(!s){m.info(`Model not found for id ${t}`);return}return Array.from(s.companionModels.all()).find(o=>e(o.modelData))},_e=t=>e=>Object.getPrototypeOf(e).modelTypeId===t,yr=t=>{const e=I.getInstance().modelManager.getModelById(t.id);if(!e)throw new Error("Model not found");return e.isReady()},bp=m.createLogger({name:"kos-model-factory"}),ws={byModelType:t=>I.getInstance().modelManager.getModelFactory(t),getModelInstance:(t,e,s)=>{const r=ws.byModelType(e);if(!r)throw bp.error(`No registered factory found for model type ${e}. Please register a factory for this model type. `),Error(`No factory found for model type ${e}`);return r.build(t,s)}},ae={Factory:{create:t=>e=>(s,r)=>(r&&Y.setParentContext(e,r),ws.getModelInstance(e,t,s))},Singleton:{create:t=>(e,s)=>(s&&Y.setParentContext(t,s),ws.getModelInstance(t,t,e))},Model:{instance:t=>e=>ws.getModelInstance(e,t)}};window.KosRegistry=window.KosRegistry||{coreModels:new Map,preloadModels:[],companionModels:new Map,models:new Map};const Ri=window.KosRegistry.coreModels,vo=window.KosRegistry.preloadModels,wo=window.KosRegistry.companionModels,Zs=window.KosRegistry.models,A={model:{registerLegacyModel:t=>(e,s)=>(Ri.set(e,s),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}),preloadModel:t=>e=>(vo.includes(e)||vo.push(e),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}),register:t=>(e,s)=>{const r=Eo(e)?e.registration():e;return Zs.set(r.type,r),Eo(e)&&e.relatedModels.forEach(o=>Zs.set(o.type,o.registration())),I.getInstance().isReady&&(I.getInstance().modelManager.registry.models[r.type]||(console.info(`Model with type ${r.type} doesn't exist. Adding new registration`),I.getInstance().modelManager.registry.models[r.type]=r.registration[r.type],Eo(e)&&e.relatedModels.forEach(o=>I.getInstance().modelManager.registry.models[o.type]=o.registration().registration))),s&&A.model.preloadModel(t)(r.type),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}},get:t=>Zs.get(t),getAll:()=>Array.from(Zs.entries()),getPreloadModels:()=>vo,getLegacyModels:()=>Array.from(Ri.entries()).reduce((t,[e,s])=>(t[e]=s,t),{})},companion:{register:t=>(e,s)=>{const r=wo.get(e)||[];return r.push(s),wo.set(e,r),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}},getAll:()=>Array.from(wo.entries())}},Hc=A.model.registerLegacyModel,Kc=A.model.register,vp=A.companion.register,wp=A.model.preloadModel,_n=t=>typeof t.updateModel=="function",Eo=t=>t.registration!==void 0&&typeof t.registration=="function";class qc{constructor(e){l(this,"singleton");l(this,"type");l(this,"loader");l(this,"class");l(this,"guard");l(this,"factory");l(this,"relatedModels",[]);this.singleton=e.singleton,this.guard=_e(e.type),this.type=e.type,this.loader=`kos.extension.model.loader.${e.type}`,this.factory=e.factory,this.class=e.class}addRelatedModel(e){this.relatedModels.push(e)}registerRelatedModels(){this.relatedModels.forEach(e=>e.register())}register(){A.model.register({})(this.registration()),this.registerRelatedModels()}}class be extends qc{constructor(e){super({...e,singleton:!1,factory:ae.Factory.create(e.type)})}instance(e){const s=this.factory(e);return{get:()=>{const r=$e(e);if(!r)throw new Error("Model not found with id "+e);if(this.guard(r))return r;throw new Error("Model is not of type "+this.type)},forceUpdate:{options:r=>({build:()=>{const o=s(r);if(this.guard(o)){if(_n(o))o.updateModel(r);else throw new Error(`Model ${this.type} is not updateable. Please implement UpdateAware interface`);return o}else throw new Error("Model is not of type "+this.type)}})},options:r=>({build:()=>{const o=s(r);if(this.guard(o))return o;throw new Error("Model is not of type "+this.type)}})}}registration(){return{type:this.type,predicate:this.guard,registration:{[this.type]:{class:this.class,singleton:!1}},factory:this.factory}}}class Se extends qc{constructor(e){super({...e,singleton:!0,factory:ae.Singleton.create(e.type)})}instance(){const e=this.factory;return{get:()=>{const r=$e(this.type);if(!r)throw new Error("Model not found with id "+this.type);if(this.guard(r))return r;throw new Error(`Model is not of type ${this.type}. Received type ${Object.getPrototypeOf(r).modelTypeId}`)},forceUpdate:{options:r=>({build:()=>{const o=e(r);if(this.guard(o)){if(_n(o))o.updateModel(r);else throw new Error(`Model ${this.type} is not updateable. Please implement UpdateAware interface`);return o}else throw new Error(`Model is not of type ${this.type}. Received type ${Object.getPrototypeOf(o).modelTypeId}`)}})},options:r=>({build:()=>{const o=e(r);if(this.guard(o))return o;throw new Error(`Model is not of type ${this.type}. Received type ${Object.getPrototypeOf(o).modelTypeId}`)}})}}registration(){return{type:this.type,predicate:this.guard,registration:{[this.type]:{class:this.class,singleton:!0}},factory:this.factory}}}const Lo=m.createLogger({group:"decorators",name:"kos-model"});function Ep(t,e,s){var n;const r=(n=t[ms])==null?void 0:n.parentId;if(!r)return;const o=Me({value:r,modelData:s,modelId:e});o&&typeof o=="string"&&Y.setParentContext(e,o)}function Mp(t){const e=t[gs];e&&Object.entries(e).forEach(([s,{handler:r}])=>{t[s]=r})}function Tp(t,e){const s=t[F]||{};Object.entries(s).forEach(([r,o])=>{const n=Me({value:o.id||o.modelType,modelData:t,modelId:e}),i=Object.entries((o==null?void 0:o.options)||{}).reduce((a,[c,u])=>(a[c]=Me({value:u,modelData:t,modelId:e}),a),{});if(typeof n=="string"){if(!o.lazy){const a=I.getInstance().modelManager.createModelInstance(o.modelType,n,i);t[r]=a.data}I.getInstance().modelManager.addDependency(e,n)}})}function _p(t){const e=t[yn];if(!e)return;const{mode:s,handlerProperty:r}=e,o=new Zr(t);t[r]=o,s==="full"&&(Object.defineProperty(t,"future",{get(){return o.future},enumerable:!0,configurable:!0}),Object.defineProperty(t,"progress",{get(){var n;return((n=o.future)==null?void 0:n.progress)||0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"status",{get(){var n;return((n=o.future)==null?void 0:n.status)||"IDLE"},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isRunning",{get(){return o.future?!o.future.endState:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isCancelled",{get(){var n;return((n=o.future)==null?void 0:n.status)==="CANCELLED"||!1},enumerable:!0,configurable:!0}),t.cancelFuture=async()=>{o.future&&await o.future.cancelFuture()})}function Sp(t){const e=t[bn];if(!e)return;const{mode:s,handlerProperty:r}=e,o=new kc(t);t[r]=o,Object.defineProperty(t,"future",{get(){return o.future},enumerable:!0,configurable:!0});const n=t[bs];n instanceof Map&&n.forEach(i=>{const a=`${i}Future`;Object.defineProperty(t,a,{get(){return o.futureMap.get(i)},enumerable:!0,configurable:!0}),s==="full"&&(Object.defineProperty(t,`${i}Progress`,{get(){const c=o.futureMap.get(i);return(c==null?void 0:c.progress)||0},enumerable:!0,configurable:!0}),Object.defineProperty(t,`${i}Status`,{get(){const c=o.futureMap.get(i);return(c==null?void 0:c.status)||"IDLE"},enumerable:!0,configurable:!0}),Object.defineProperty(t,`${i}IsRunning`,{get(){const c=o.futureMap.get(i);return c?!c.endState:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,`${i}IsCancelled`,{get(){const c=o.futureMap.get(i);return(c==null?void 0:c.status)==="CANCELLED"||!1},enumerable:!0,configurable:!0}),t[`cancel${i.charAt(0).toUpperCase()}${i.slice(1)}`]=async()=>{const c=o.futureMap.get(i);c&&await c.cancelFuture()})}),s==="full"&&(Object.defineProperty(t,"progress",{get(){var i;return((i=o.future)==null?void 0:i.progress)||0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"status",{get(){var i;return((i=o.future)==null?void 0:i.status)||"IDLE"},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isRunning",{get(){return o.future?!o.future.endState:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isCancelled",{get(){var i;return((i=o.future)==null?void 0:i.status)==="CANCELLED"||!1},enumerable:!0,configurable:!0}),t.cancelFuture=async()=>{o.future&&await o.future.cancelFuture()})}function Ip(t){const e=t[vn];if(!e)return;const{pathProperty:s}=e;Object.defineProperty(t,"troubles",{get(){const r=this[s];if(r==null){const o=`@kosTroubleAware: Path property '${s}' is undefined on model ${this.id||"unknown"}. Returning empty troubles array.`;return this.logger&&typeof this.logger.warn=="function"?this.logger.warn(o):console.warn(o),[]}return this.troubleContainer.troubles.getIndexByKey("byIface",r).sort((o,n)=>n.rank-o.rank)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"troubleStatus",{get(){return""},enumerable:!0,configurable:!0}),Object.defineProperty(t,"troublesByType",{get(){return this.troubles.reduce(Lc,{})},enumerable:!0,configurable:!0})}function Op(t,e){const s=t[En];if(!s)return;const{containerProperty:r,includeMethods:o,includeGetters:n,modelsProperty:i,containerOptions:a,legacy:c}=s,u={...a,parentId:a.parentId||e},d=new xe(u);t[r]=d,t[Ge]||(t[Ge]={}),t[Ge][r]=d,o&&(t.getModel=h=>d.getModel(h),t.addModel=h=>{d.addModel(h)},t.removeModel=h=>{d.removeModel(h)},t.addAll=h=>{d.addAll(h)},t.removeAll=h=>{d.removeAll(h)},t.removeAndDestroy=async h=>d.removeAndDestroy(h),t.removeAndDestroyAll=async h=>d.removeAndDestroyAll(h)),n&&(Object.defineProperty(t,i,{get(){return d},enumerable:!0,configurable:!0}),Object.defineProperty(t,"data",{get(){return d.data},enumerable:!0,configurable:!0}))}function $p(t,e){const s=t.constructor.prototype[Ye];if(!s)return;const{mode:r,parentProperty:o,excludeProperties:n}=s,i=e[o];if(!i){Lo.warn(`Companion decorator configured but no parent model found at '${o}'`);return}if(t.getCompanionParent=()=>i,r==="composition")return;const a=["init","load","unload","ready","dispose","destroy","activate"],c=["getDependencies","getChildren","update","toJSON","forceUpdate","makeAutoObservable","runInAction","transaction","observe","unobserve","intercept","spy","trace","getCompanionParent"],u=p=>{const y=i.constructor.prototype[ee]||{};return Object.values(y).some(w=>{const E=w==null?void 0:w.handler;return E===i[p]||E===i.constructor.prototype[p]})},d=p=>p==="constructor"||p.startsWith("_")||p.startsWith("__")||a.includes(p)||c.includes(p)||n.includes(p)||u(p)||p in t,h=new Set;Object.getOwnPropertyNames(i).filter(p=>!d(p)).forEach(p=>h.add(p));let f=Object.getPrototypeOf(i);for(;f&&f!==Object.prototype;)Object.getOwnPropertyNames(f).filter(p=>!d(p)).forEach(p=>h.add(p)),f=Object.getPrototypeOf(f);for(const p of h)try{const y=i[p];typeof y=="function"?t[p]=(...w)=>y.apply(i,w):Object.defineProperty(t,p,{get:()=>i[p],set:w=>{i[p]=w},enumerable:!0,configurable:!0})}catch(y){Lo.debug(`Skipping companion proxy for property ${p}:`,y)}}function Cp(t){try{return M.makeAutoObservable(t)}catch(e){return Lo.error("Failed to make observable:",e),t}}const Dp={construct(t,e){var c;const[s,r={}]=e,o=Y.createContext(s);Ep(t,s,r);const i=!!t.prototype[wn]?null:m.createLogger({name:t.prototype.modelTypeId,group:((c=t[ys])==null?void 0:c.group)??"kos-model"}),a=new t(s,r,{logger:i,kosContext:o});return Mp(a),_p(a),Sp(a),Ip(a),Op(a,s),$p(a,r),Sc(a),Tp(a,s),Cp(a)}};function R(t){return e=>{var n,i;const s=e,r=typeof t=="string"?{modelTypeId:t,autoRegister:!1}:{autoRegister:!1,...t};s.prototype.modelTypeId=r.modelTypeId,s.prototype[mn]=!0,(n=s.prototype)[ee]??(n[ee]={}),(i=s.prototype)[F]??(i[F]={}),r.optionsRequired&&(s.prototype[Hs]=!0),m.ifDebug(()=>{m.debug(`Registering model with id ${r.modelTypeId}`)});const o=new Proxy(s,Dp);if(r.singleton!==void 0){let a;r.singleton?a=new Se({class:o,type:r.modelTypeId}):a=new be({class:o,type:r.modelTypeId}),Object.defineProperty(o,"Registration",{value:a,writable:!1,enumerable:!0,configurable:!1}),r.autoRegister&&a.register()}return o}}const xp=({topic:t,handler:e,websocket:s=!1,condition:r=()=>!0})=>o=>{o[ee]=o[ee]||{},Array.isArray(t)?t.forEach(n=>{o[ee][n]={websocket:s,handler:e,condition:r}}):o[ee][t]={websocket:s,handler:ic(o,M.action(e),200),condition:r}};function zc(t,e,s){const r={};if(!t.endsWith("/*"))return r;const o=t.slice(0,-2);if(e.startsWith(o)){const n=e.slice(o.length+1),i=s||"path";r[i]=n}return r}function Vc(t){return t.endsWith("/*")}function H(t){return(e,s,r)=>{const o=Ap(t,r);kp(e,t.topic,o),t.replay&&Lp(t.topic,t.replay.bufferSize)}}function Ap(t,e){const{condition:s=(S,z)=>!0,transform:r=S=>S,websocket:o=!1,fos:n=!1,bridge:i=!1,skipParse:a=!1,lifecycle:c,destinationAddress:u,debounce:d,throttle:h,buffer:f,filter:p,once:y,wildcardName:w,flow:E,requiresBaseline:_}=t,k=e.value,U=Rp(k,{debounce:d,throttle:h,buffer:f,once:y}),O=Pp(p,s);return{websocket:o,fos:n,bridge:i,handler:U,condition:O,transform:r,lifecycle:c,skipParse:a,destinationAddress:u,wildcardName:w,flow:E,requiresBaseline:_}}function Rp(t,e){var n,i;let s=t;const r=typeof e.debounce=="number"?e.debounce:(n=e.debounce)==null?void 0:n.delay,o=typeof e.throttle=="number"?e.throttle:(i=e.throttle)==null?void 0:i.interval;return r&&r>0?s=Fp(s,e.debounce):o&&o>0?s=Bp(s,e.throttle):e.buffer?s=Hp(async function(c){for(const u of c)await s.call(this,u)},e.buffer):e.once&&(s=Kp(s)),s}function Pp(t,e){return t?(s,r,o)=>t(o)?e(s,r,o):!1:e}function kp(t,e,s){t[ee]=t[ee]||{},Array.isArray(e)?e.forEach(r=>{t[ee][r]=s}):t[ee][e]=s}function Lp(t,e){qp(t,e)}function Fp(t,e){const s=typeof e=="number"?e:e.delay;return Np(e)==="discard"?Up(t,s):jp(t,s)}function Np(t){return(typeof t=="object"?t.discardIntermediate:!1)?"discard":"accumulate"}function Up(t,e){let s=null;return function(r){s&&clearTimeout(s),s=setTimeout(()=>{t.call(this,r),s=null},e)}}function jp(t,e){let s=null,r=[];return function(o){r.push(o),s&&clearTimeout(s),s=setTimeout(()=>{const n=[...r];r=[],t.call(this,n),s=null},e)}}function Bp(t,e){const s=typeof e=="number"?e:e.interval,r=typeof e=="object"?e.discardIntermediate:!1;let o=0,n=null,i=[],a=!1;const c=function(){if(i.length>0){const u=[...i];i=[],t.call(this,u)}};return function(u){const d=Date.now(),h=d-o;r?h>=s?(o=d,t.call(this,u)):n||(n=setTimeout(()=>{o=Date.now(),t.call(this,u),n=null},s-h)):(i.push(u),h>=s?(o=d,c.call(this)):a||(a=!0,n=setTimeout(()=>{o=Date.now(),c.call(this),n=null,a=!1},s-h)))}}function Hp(t,e){const s=[];let r=null;const o=e.maxSize||1e3,n=i=>{s.length>0&&(t.call(i,[...s]),s.length=0)};return function(i){if(s.push(i),s.length>=o){r&&(clearTimeout(r),r=null),n(this);return}r||(r=setTimeout(()=>{n(this),r=null},e.time))}}function Kp(t){let e=!1;return function(s){e||(e=!0,t.call(this,s))}}function qp(t,e){(Array.isArray(t)?t:[t]).forEach(r=>{ln(r,e)})}const Mo=new Map,Gc={addToDeletionQueue:(t,e)=>{const s=Mo.get(t)||[];s.push(e),Mo.set(t,s)},cancelDeletion:t=>{const e=Mo.get(t);e&&e.forEach(s=>{clearTimeout(s)})}},zp=m.createLogger({name:"kos-dependency-manager"});class Vp{constructor(){l(this,"_usedByCache",new Map);l(this,"_usesCache",new Map)}add(e,s){Gc.cancelDeletion(s);const r=this._usedByCache.get(s)||[];r.includes(e)||r.push(e),this._usedByCache.set(s,r);const o=this._usesCache.get(e)||[];o.includes(s)||o.push(s),this._usesCache.set(e,o)}remove(e,s){const r=this._usedByCache.get(s)||[];this._usedByCache.set(s,r.filter(n=>n!==e));const o=this._usesCache.get(e)||[];this._usesCache.set(e,o.filter(n=>n!==s))}canDestroy(e){const s=this._usedByCache.get(e);return s!=null&&s.length?(zp.info(`Model ${e} is still used by: ${s.join(", ")}`),!1):!0}clear(){this._usedByCache.clear(),this._usesCache.clear()}}const Pi=m.createLogger({name:"kos-model-cache"});class Gp{constructor(e=[]){l(this,"_modelsById",M.observable.map(new Map));l(this,"_toDelete",new Map);l(this,"_preloaded",[]);l(this,"_isPreloaded",!1);this.preloadKeys=e}get models(){return Array.from(this._modelsById.values()).map(e=>e).filter(e=>!this._toDelete.has(e.modelId))}getModelById(e){if(e&&!this._toDelete.has(e))return this._modelsById.get(e)}addModel(e){const s=this.getModelById(e.modelId)||e;return this._modelsById.set(s.modelId,s),s}removeModel(e){this._modelsById.delete(e),this._toDelete.delete(e)}hasModel(e){return!!e&&this._modelsById.has(e)&&!this._toDelete.has(e)}restoreFromDeleteCache(e){if(e&&this._toDelete.has(e)){const s=this._toDelete.get(e);this._toDelete.delete(e),this._modelsById.set(e,s)}}markForDeletion(e){this._modelsById.delete(e.modelId),this._toDelete.set(e.modelId,e)}preload(e){return this._isPreloaded?(Pi.debug("Returning cached preloaded models"),this._preloaded):(this._preloaded=this.preloadKeys.map(s=>(Pi.debug(`Preloading model: ${typeof s=="string"?s:s.modelType}`),e(s))).filter(s=>!!s),this._isPreloaded=!0,this._preloaded)}}class cr extends Error{constructor(s,r,o){super(s,{cause:o});l(this,"context");l(this,"originalCause");this.name="KosModelError",this.context=r,this.originalCause=o,o!=null&&o.stack&&(this.stack=`${this.stack}
1
+ "use strict";var jh=Object.defineProperty;var Bh=(t,e,s)=>e in t?jh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var l=(t,e,s)=>(Bh(t,typeof e!="symbol"?e+"":e,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("loglevel"),M=require("mobx"),b=require("robot3"),ze=require("date-fns"),T=require("@emotion/react/jsx-runtime"),en=require("@emotion/styled"),Sa=require("react-dom"),rt=require("@emotion/react"),g=require("react"),tn=require("mobx-react-lite"),Hh=require("@use-gesture/react"),Kr="method",Ia="topic",Kt="url",Ns="request-id",qr="response-id",sn="status",je="dst-addr",Oa="src-addr",Ce="type",rn="ordered",on="tracker",$a="Content-Type",Ca="Cache-Control",Da="requestId",xa=process.env.KOS_LOGIN_URL||"http://localhost",Aa=process.env.KOS_APP_PORT||"8080",Kh=`${xa}:${Aa}`,pr="{MODEL_ID}";var Us=(t=>(t.SEND="/ws/log/msg/send",t.RECEIVED="/ws/log/msg/receive",t))(Us||{}),Ra=(t=>(t.MSG_RECEIVE="/mock/msg/receive",t))(Ra||{});const nn="/kos/model/ready/";D.info("Initializing event bus");globalThis.kos=globalThis.kos||{};globalThis.kos.subscriptions=globalThis.kos.subscriptions||{};const q=globalThis.kos.subscriptions,qh=()=>Symbol("eventKey");function an(t){return q[t]&&Object.getOwnPropertySymbols(q[t]).length>0}function C(t,e){const s=qh();return q[t]||(D.debug(`Initializing subscription for ${t}`),q[t]={}),D.debug(`Subscribing to ${t} with id ${s.toString()}`),q[t][s]=e,{count:q[t]?Object.getOwnPropertySymbols(q[t]).length:0,unsubscribe:()=>(D.debug(`Unsubscribing from ${t} with id ${s.toString()}`),q[t]&&q[t][s]&&delete q[t][s],q[t]&&Object.getOwnPropertySymbols(q[t]).length===0&&delete q[t],{count:q[t]?Object.getOwnPropertySymbols(q[t]).length:0})}}function V(t,e,s={}){if(!q[t]||Object.getOwnPropertySymbols(q[t]).length===0)return D.debug(`No subscriptions for ${t}. Not publishing.`),{eventType:t,subscribers:0};const r=Object.getOwnPropertySymbols(q[t]).length;return Object.getOwnPropertySymbols(q[t]).forEach(o=>{if(s.sync){const n=s.sync;D.debug(`Performing sync publish for ${t} with sync id ${n}`),q[t][o]({body:e,headers:s}).then(i=>{D.debug(`Response recieved for ${n}, publishing back to source.`),V(n,i)})}else D.debug(`Performing async publish for ${t}`),q[t][o]({body:e,headers:s})}),{eventType:t,subscribers:r}}function zh(){D.warn("Resetting event bus"),Object.keys(q).forEach(t=>delete q[t])}function Pa(t,e){const s=C(t,r=>{s.unsubscribe(),e(r)});return s.unsubscribe}function cn(t,e){return new Promise((s,r)=>{let o=null;const n=Pa(t,i=>{o&&clearTimeout(o),s(i)});e&&(o=setTimeout(()=>{n(),r(new Error(`Timeout waiting for event: ${t}`))},e))})}const Vh=Object.freeze(Object.defineProperty({__proto__:null,hasEventSubscriptions:an,once:Pa,publish:V,reset:zh,subscribe:C,waitFor:cn},Symbol.toStringTag,{value:"Module"}));function zr(t,e){const s=C(t,r=>{s.unsubscribe(),e(r)});return s.unsubscribe}function Vr(t,e){return new Promise((s,r)=>{let o=null;const n=zr(t,i=>{o&&clearTimeout(o),s(i)});e&&(o=setTimeout(()=>{n(),r(new Error(`Timeout waiting for event: ${t}`))},e))})}function ka(t,e){const s=t.map(r=>Vr(r,e));return Promise.all(s)}function La(t,e){return new Promise((s,r)=>{const o=[];let n=null,i=!1;const a=()=>{o.forEach(c=>c()),n&&clearTimeout(n)};t.forEach(c=>{const u=zr(c,d=>{i||(i=!0,a(),s({eventType:c,data:d}))});o.push(u)}),e&&(n=setTimeout(()=>{i||(i=!0,a(),r(new Error(`Timeout waiting for any event: ${t.join(", ")}`)))},e))})}function Fa(t,e,s){return C(t,o=>{o&&e(o)&&s(o)}).unsubscribe}function Na(t,e,s){return C(t,o=>{if(o){const n=e(o);s(n)}}).unsubscribe}function Ua(t,e,s){let r=null;const o=C(t,n=>{r&&clearTimeout(r),r=setTimeout(()=>{s(n)},e)});return()=>{r&&clearTimeout(r),o.unsubscribe()}}function ja(t,e,s){let r=0,o=null;const n=C(t,i=>{const a=Date.now(),c=a-r;c>=e?(r=a,s(i)):o||(o=setTimeout(()=>{r=Date.now(),s(i),o=null},e-c))});return()=>{o&&clearTimeout(o),n.unsubscribe()}}function Ba(t,e,s){let r=[],o=null;const n=()=>{r.length>0&&(s([...r]),r=[])},i=C(t,a=>{a&&(r.push(a),o||(o=setTimeout(()=>{n(),o=null},e)))});return()=>{o&&(clearTimeout(o),n()),i.unsubscribe()}}function ln(t,e=1){const s=[];return C(t,r=>{r&&(s.push(r),s.length>e&&s.shift())}),{subscribe:r=>(s.forEach(o=>r(o)),C(t,r))}}function Ha(t,e){const s=t.map(r=>C(r,o=>{o&&e(r,o)}));return()=>{s.forEach(r=>r.unsubscribe())}}function Ka(t,e){let s=t;const r=[],o=new Set;return Object.values(e).forEach(n=>{Object.keys(n).forEach(i=>{o.add(i)})}),o.forEach(n=>{const{unsubscribe:i}=C(n,a=>{const c=e[s];c&&c[n]&&(s=c[n](a))});r.push(i)}),{get state(){return s},unsubscribe:()=>{r.forEach(n=>n())}}}function qa(t,e,s,r){const o=Vr(e,r);return V(t,s),o}async function*za(t){const e=[],s=[],r=C(t,o=>{o&&(s.length>0?s.shift()(o):e.push(o))});try{for(;;)e.length>0?yield e.shift():yield await new Promise(o=>{s.push(o)})}finally{r.unsubscribe()}}const Gh={once:zr,waitFor:Vr,waitForAll:ka,race:La,filter:Fa,map:Na,debounce:Ua,throttle:ja,buffer:Ba,replay:ln,merge:Ha,stateMachine:Ka,request:qa,eventIterator:za},Yh=Object.freeze(Object.defineProperty({__proto__:null,EventBusFunctional:Gh,buffer:Ba,debounce:Ua,eventIterator:za,filter:Fa,map:Na,merge:Ha,once:zr,race:La,replay:ln,request:qa,stateMachine:Ka,throttle:ja,waitFor:Vr,waitForAll:ka},Symbol.toStringTag,{value:"Module"}));async function Gr(t,e){const{getCurrentState:s,transformState:r,shouldUseFetchedState:o,timeout:n}=e,i=cn(t,n),a=await s(),c=r?r(a):a;return o&&o(c)?(i.catch(()=>{}),c):await Promise.race([i,new Promise(d=>{setTimeout(()=>d(c),100)})])}function Va(t,e,s){const{getCurrentState:r,transformState:o}=s;let n=!1;const i=C(t,a=>{a&&(n=!0,e(a))});return Promise.resolve(r()).then(a=>{const c=o?o(a):a;n||e(c)}).catch(a=>{console.error("Failed to fetch initial state:",a)}),i.unsubscribe}function Ga(t,e){let s;const r=new Set,o=async()=>{try{typeof e=="string"?s=await(await fetch(e)).json():s=await e(),r.forEach(a=>a(s))}catch(a){throw console.error("Failed to fetch initial state:",a),a}};C(t,a=>{a!=null&&a.body&&(s=a.body,r.forEach(c=>c(s)))});let n=!1;const i=()=>{n||(n=!0,o())};return{get state(){return s},async getState(){return i(),s===void 0&&await new Promise(a=>{const c=()=>{s!==void 0?a():setTimeout(c,10)};c()}),s},subscribe(a){return i(),r.add(a),s!==void 0&&a(s),()=>{r.delete(a)}},async refresh(){return await o(),s}}}async function un(t,e){if(typeof t=="string")return Gr(t,e);const s=t,{getCurrentState:r,shouldUseFetchedState:o,timeout:n}=e,i=await r(),a=e.transformState?e.transformState(i):i;if(o&&o(a))return a;const c=s.map(d=>cn(d,n)),u=await Promise.all(c);return u[u.length-1]}function Ya(t,e,s){const{fetchMissedEvents:r,checkInterval:o=3e4,deduplicateById:n}=s,i=new Set,a=C(t,async u=>{if(u){if(n){const d=n(u);if(i.has(d))return;i.add(d),i.size>1e3&&Array.from(i).slice(0,500).forEach(f=>i.delete(f))}await e(u)}}),c=setInterval(async()=>{try{const u=await r(),d=Array.isArray(u)?u:[u];for(const h of d)if(n){const f=n(h);i.has(f)||(i.add(f),await e(h))}else await e(h)}catch(u){console.error("Failed to fetch missed events:",u)}},o);return()=>{a.unsubscribe(),clearInterval(c)}}function Wa(t){const{connectEvent:e,disconnectEvent:s,errorEvent:r,dataEvent:o,fetchInitialState:n,reconnectDelay:i=5e3}=t,a={state:"disconnected",data:void 0,async waitForConnection(d){if(a.state==="connected"&&a.data)return a.data;const h=await Gr(e,{getCurrentState:n,shouldUseFetchedState:f=>!!f,timeout:d});return a.state="connected",a.data=h,u(),h},subscribe(d){return c.add(d),d(a),()=>{c.delete(d)}},async reconnect(){a.state="connecting",u();try{const d=await n();a.state="connected",a.data=d,u()}catch{a.state="error",u(),setTimeout(()=>{a.state==="error"&&a.reconnect()},i)}}},c=new Set,u=()=>{c.forEach(d=>d(a))};return C(e,d=>{a.state="connected",d!=null&&d.body&&(a.data=d.body),u()}),C(s,()=>{a.state="disconnected",u(),setTimeout(()=>{a.state==="disconnected"&&a.reconnect()},i)}),r&&C(r,()=>{a.state="error",u()}),o&&C(o,d=>{d!=null&&d.body&&a.state==="connected"&&(a.data=d.body,u())}),a.reconnect(),a}const Wh={waitForOrGetState:Gr,subscribeWithInitialState:Va,createStatefulEventStream:Ga,waitForAllWithState:un,createResilientEventHandler:Ya,createConnectionStateManager:Wa},Qh=Object.freeze(Object.defineProperty({__proto__:null,EventBusState:Wh,createConnectionStateManager:Wa,createResilientEventHandler:Ya,createStatefulEventStream:Ga,subscribeWithInitialState:Va,waitForAllWithState:un,waitForOrGetState:Gr},Symbol.toStringTag,{value:"Module"})),Zh=(t,e=0)=>{if(!+t)return{value:0,scale:"bytes",toString:()=>"0 bytes"};const s=1024,r=e<0?0:e,o=["bytes","KB","MB","GB","TB"],n=Math.floor(Math.log(t)/Math.log(s)),i=parseFloat((t/Math.pow(s,n)).toFixed(r)),a=o[n];return{value:i,scale:a,toString:()=>`${i} ${a}`}};function dn(t){let e="pending",s;const r=t.then(n=>{e="success",s=n},n=>{e="error",s=n});return{read:()=>{switch(e){case"pending":throw r;case"error":throw s;default:return s}}}}function dt(){return"xxxxxxxx-xxxx-4xxx-2xxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function Xh(t,e){e.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(r=>{const o=Object.getOwnPropertyDescriptor(s.prototype,r);Object.defineProperty(t.prototype,r,o)})})}function Jh(t,e){const s=t??[],r=e??[];return s.length!==r.length?!1:s.every((o,n)=>o===r[n])}const hn=(t,e)=>{const s=t.map(n=>n.id);return e.map(n=>n.id).filter(n=>!s.includes(n))},Qa=t=>t,Za=t=>t,ef=({container:t,onAddItem:e,onUpdateItem:s,onRemoveItem:r=Qa,idMapper:o=Za})=>n=>{const i=n.map(o),c=hn(i,t.data).map(r).filter(Boolean);t.removeAll(c);const u=i.map(d=>{const h=t.getModel(d.id);return h&&s?s(d,h):e(d)}).filter(Boolean);t.addAll(u)},tf=({container:t,onAddItem:e,onRemoveItem:s=Qa,idMapper:r=Za})=>o=>{const n=o.map(r);hn(n,t.models).forEach(s),n.forEach(e)},sf=({items:t,onAddItem:e,onRemoveItem:s,idMapper:r=o=>o})=>o=>{const n=o.map(r);hn(n,t).forEach(s),n.forEach(e)},rf=(t,e="parent-")=>{let s=t;return s.startsWith(e)&&(s=s.replace(e,"")),s},$i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),Ci=[{amount:60,name:"seconds"},{amount:60,name:"minutes"},{amount:24,name:"hours"},{amount:7,name:"days"},{amount:4.34524,name:"weeks"},{amount:12,name:"months"},{amount:Number.POSITIVE_INFINITY,name:"years"}];function Xa(t){let e=(t.getTime()-Date.now())/1e3;for(let s=0;s<=Ci.length;s++){const r=Ci[s];if(Math.abs(e)<r.amount)return $i.format(Math.round(e),r.name);e/=r.amount}return $i.format(Math.round(e),"years")}const fn=t=>t%4===0&&t%100!==0||t%400===0,pn=(t,e)=>[31,fn(t)?29:28,31,30,31,30,31,31,30,31,30,31][e],Ja=(t,e)=>{const s=new Date(t),r=t.getDate();return s.setDate(1),s.setMonth(s.getMonth()+e),s.setDate(Math.min(r,pn(s.getFullYear(),s.getMonth()))),s},ec=(t,e)=>{const s=new Date(t);return s.setDate(s.getDate()+e),s},Dt="en-US",tc={short:{year:"numeric",month:"2-digit",day:"2-digit"},medium:{year:"numeric",month:"short",day:"2-digit"},long:{year:"numeric",month:"long",day:"numeric"},full:{year:"numeric",month:"long",day:"numeric",weekday:"long"}},sc={short:{hour:"2-digit",minute:"2-digit",hour12:!0},medium:{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0},long:{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0,timeZoneName:"short"},full:{hour:"2-digit",minute:"2-digit",hour12:!0,timeZoneName:"long"}},rc=(t,{dateStyle:e="short",locales:s=Dt}={dateStyle:"short",locales:Dt})=>{const r=e==="short"?tc.short:{dateStyle:e};return new Intl.DateTimeFormat(s,r).format(t)},oc=(t,{locales:e=Dt,timeStyle:s="short"}={locales:Dt,timeStyle:"short"})=>{const r=sc[s];return new Intl.DateTimeFormat(e,r).format(t)},nc=(t,{dateStyle:e="short",locales:s=Dt,timeStyle:r="short"}={dateStyle:"short",locales:Dt,timeStyle:"short"})=>{const o={...e&&tc[e],...r&&sc[r]};return new Intl.DateTimeFormat(s,o).format(t)},of=Object.freeze(Object.defineProperty({__proto__:null,addDaysToDate:ec,addMonthsToDate:Ja,formatDate:rc,formatDateSince:Xa,formatDateTime:nc,formatTime:oc,getDaysInMonth:pn,isLeapYear:fn},Symbol.toStringTag,{value:"Module"}));function ic(t,e,s=300){let r;return(...o)=>{clearTimeout(r),r=setTimeout(()=>{e.apply(t,o)},s)}}const te="canvas-renderer",go=new Map,Di=new Map,mo=new Map,yo=new Map,js=(t,e)=>{ac[t]=e},ac={indexExtension:{registerIndexExtension:(t,e)=>{const s=yo.get(t)||{};Object.assign(s,e),yo.set(t,e)},loadIndexExtensions:t=>yo.get(t)||{}},loader:{registerLoader:(t,e)=>{Di.set(t,e)},executeLoader:async(t,e)=>{const s=Di.get(t);if(s)return await s(e)}},propertyMapper:{registerPropertyMapper:(t,e)=>{mo.set(t,e)},hasMapper:t=>mo.has(t),executeMapper:(t,e,s)=>{const r=mo.get(t);return r?r(e,s):""}},dataMapper:{registerDataMapper:(t,e)=>{const s=go.get(t)||[];s.push(e),go.set(t,s)},executeMapper:async(t,e,s)=>{const r=go.get(t);if(!r)return{};const o={};for(const n of r){const i=await n(e,s);Object.assign(o,i)}return o}},canvas:{registerRenderer:(t,e)=>{if(!$[te]){console.warn(`Canvas renderer extension point is not registered. Cannot register renderer "${t}".`);return}$[te].register(t,e)}}},$=ac,nf=async({context:t,extension:e})=>{const s=await $.loader.executeLoader(e,{});return t==null||t.set(e,s),s},af=async({extension:t,contextData:e,data:s})=>await $.dataMapper.executeMapper(t,s,e),cf=async({extension:t,contextData:e,data:s})=>await $.propertyMapper.executeMapper(t,s,e),lf=Object.freeze(Object.defineProperty({__proto__:null,executeDataMapperExtension:af,executeLoaderExtension:nf,executePropertyMapperExtension:cf},Symbol.toStringTag,{value:"Module"})),uf="Extensions";class df{constructor(){l(this,"extensions");this.extensions={}}register(e,s,r){this.extensions[e]={},this.extensions[e][s]={component:r}}get(e,s){if(!this.extensions[e])throw new Error(`Extension point ${e} not found`);return this.extensions[e][s]}get allExtensions(){return this.extensions}}const ye=(t=null)=>(t||window.location.search.replace("?","")).split("&").map(e=>{const[s,r]=e.split("=");return[s,decodeURIComponent(r||"")]}).reduce((e,[s,r])=>(e[s]=r,e),{}),cc="studio.tools.preview",hf="studio.relax.store.validation",lc="studio.log.debug",uc="studio.log.info",ff={profiles:[cc]};var _a;const pf=((_a=globalThis.getKosConfig)==null?void 0:_a.call(globalThis))||JSON.stringify(ff),dc=JSON.parse(pf);globalThis.kosConfig=dc;const gn=dc,hc=()=>gn.profiles||[],Ro=t=>hc().includes(t),gf=()=>gn.logging||!1,mf=()=>{const t=Ro(lc),e=Ro(uc);return t?"DEBUG":e?"INFO":void 0},fc=()=>{const t=ye(),e=mf(),r=t.kosLogLevel??e??window.kosLogLevel??process.env.KOS_LOG_LEVEL;return r||"WARN"},pc=()=>window.kosMessageLogging||process.env.KOS_MESSAGE_LOGGING==="true",gc=()=>window.kosMessageStudioLogging||process.env.KOS_MESSAGE_STUDIO_LOGGING==="true",mc="ws-log",yf=D.methodFactory,yc=pc(),bf=gc();D.methodFactory=function(t,e,s){const r=yf(t,e,s);return function(...o){var c;const n=s?String(s):"",i=n?`[${String(n).substring(n.lastIndexOf(":")+1)}] | `:"[root] | ",a=o.map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(" ");r(`${i}${a}`),(c=globalThis==null?void 0:globalThis.kosConfig)!=null&&c.logging&&globalThis.kosLog&&(s!==mc||yc&&bf)&&globalThis.kosLog(`UI: ${i}${a}`)}};let bc=fc();D.setLevel(bc);window.setKosLogLevel=t=>{bc=t,D.setLevel(t)};const gr=D.getLogger(mc);window.enableKosMessageLog=()=>{gr.setLevel(D.levels.INFO)};window.disableKosMessageLog=()=>{gr.setLevel(D.levels.ERROR)};yc?window.enableKosMessageLog():window.disableKosMessageLog();const vf=["color: black","display: block","background-color: lightgreen","padding: 4px","margin: 0","text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)","box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset","font-weight: bold"].join(";"),wf=["color: black","display: block","padding: 4px","background-color: yellow","margin: 0","text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)","box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset","font-weight: bold"].join(";"),Ws=t=>e=>{D.getLevel()<=t&&e()},m={...D,ifDebug:Ws(D.levels.DEBUG),ifInfo:Ws(D.levels.INFO),ifWarn:Ws(D.levels.WARN),ifError:Ws(D.levels.ERROR),getLogger:t=>D.getLogger(`kos::${t}`),getLoggers:()=>D.getLoggers(),createLogger:({name:t,group:e})=>{var n,i,a,c;const s=`${e?`${e}:`:"kos"}::${t}`,r=D.getLogger(s);let o=(i=(n=globalThis.kos.logOverrides)==null?void 0:n.find(u=>u.name===s))==null?void 0:i.level;return o?r.setLevel(o):(o=(c=(a=globalThis.kos.logOverrides)==null?void 0:a.find(u=>s.startsWith(u.name)))==null?void 0:c.level,o&&r.setLevel(o)),r},wsSend:(...t)=>{const e=String(t).replace(/\n/g,"\\n");gr.info(`%c⬆ ${e}`,vf)},wsReceive:(...t)=>{const e=String(t).replace(/\n/g,"\\n");gr.info(`%c⬇ ${e}`,wf)}},vc="featureFlagResolver",Qs=new Map;js(vc,{register:(t,e)=>{var s;Qs.has(t)||Qs.set(t,[]),(s=Qs.get(t))==null||s.push(e)},execute:async(t,e)=>{const s=Qs.get(t);if(!s)return[];const r=s.map(a=>a(e)),n=(await Promise.allSettled(r)).map(a=>a.status==="fulfilled"?a.value:(m.info(`Feature flag resolver ${t} failed: ${a.reason}`),[])).flat(),i=Array.from(new Set(n)).reduce((a,c)=>(a[c]=!0,a),{});return Ec.updateFlags(i),Object.keys(i)}});const Ef="kos.loader.featureFlag";class wc{constructor(e={}){l(this,"flags",{});this.flags=e}isFeatureEnabled(e){return!!this.flags[e]}enableFeature(e){this.flags[e]=!0}disableFeature(e){this.flags[e]=!1}toggleFeature(e){this.flags[e]=!this.flags[e]}updateFlags(e){this.flags={...this.flags,...e}}}window.KosFeatureFlags=window.KosFeatureFlags??new wc;const Ec=window.KosFeatureFlags,Mc=(t,e,s)=>{s/=100;const r=e*Math.min(s,1-s)/100,o=n=>{const i=(n+t/30)%12,a=s-r*Math.max(Math.min(i-3,9-i,1),-1);return Math.round(255*a).toString(16).padStart(2,"0")};return`#${o(0)}${o(8)}${o(4)}`},Tc=t=>{const s=new RegExp("hsl\\((\\d+),\\s+(\\d+)\\%,\\s+(\\d+)\\%\\)").exec(t);if(!s)throw Error("Invalid HSL string");return Mc(parseInt(s[1]),parseInt(s[2]),parseInt(s[3]))},_c=(t,e)=>getComputedStyle(t).getPropertyValue(e),Mf=(t,e)=>Tc(_c(t,e)),Tf=(t,e)=>{const s={...t};return s.id&&delete s.id,s},Po=(t,e,s=Tf)=>{const r=s(t,e);M.runInAction(()=>{Object.assign(e,r)})},ee=Symbol("SubscriptionHandlers"),F=Symbol("DependencyModels"),gs=Symbol("FutureService"),Ge=Symbol("ChildModels"),ms=Symbol("ParentModel"),ys=Symbol("LogConfig"),ar=Symbol("ReferenceConfig"),mn=Symbol("KosModelSymbol"),at=Symbol("ModelEffects"),Ye=Symbol("CompanionParentModel"),yn=Symbol("FutureContainerSetup"),bn=Symbol("MultipleFutureContainerSetup"),bs=Symbol("FutureAliases"),vn=Symbol("TroubleAwareSetup"),wn=Symbol("LoggerSetup"),En=Symbol("ContainerAwareSetup"),Bs=Symbol("StateMachineSetup"),Ot=Symbol("StateEntryHandlers"),vs=Symbol("StateExitHandlers"),_f=Symbol("StateActionHandlers"),Hs=Symbol("OptionsRequired"),Sf=m.createLogger({group:"decorators",name:"fsm-injection"});function Sc(t){const e=t[Bs];if(!e)return;const{config:s,options:r}=e;Cf(t,s,r),Df(t,r);const o=$f(t);If(t,s,r,o),Of(t,s,r)}function If(t,e,s,r){t.transition=Rf(t,e,s,r.entry,r.exit),t.canTransition=Bf(t,e,s),t.isInState=Hf(t,s)}function Of(t,e,s){xf(t),Af(t,e,s)}function $f(t){const e=t.constructor.prototype[Ot]||new Map,s=t.constructor.prototype[vs]||new Map;return{entry:e,exit:s}}function Cf(t,e,s){t._fsmConfig=e,t._fsmOptions=s}function Df(t,e){const{stateProperty:s,trackHistory:r}=e,o=t._fsmConfig;t[s]=o.initial,t._fsmInitialized=!0,t.isTransitioning=!1,r&&(t.stateHistory=[{state:o.initial,timestamp:new Date}])}function xf(t){Object.defineProperty(t,"isFsmInitialized",{get(){return this._fsmInitialized},enumerable:!0,configurable:!0})}function Af(t,e,s){const{stateProperty:r}=s;Object.defineProperty(t,"allowedTransitions",{get(){if(!this._fsmInitialized)return[];const o=this[r],n=this._fsmConfig.states[o];return n!=null&&n.on?Object.keys(n.on):[]},enumerable:!0,configurable:!0})}function Rf(t,e,s,r,o){const{stateProperty:n,throwOnInvalid:i}=s;return function(a){if(!this._fsmInitialized){Pf(e.initializeAt,i);return}const c=this[n],u=kf(c,a,this._fsmConfig,i);u&&Ff(this,c,u,a,n,r,o,s)}}function Pf(t,e){const s=`Cannot transition: FSM not initialized. Waiting for ${t} lifecycle phase.`;if(e)throw new Error(s);console.warn(s)}function kf(t,e,s,r){var i;const o=s.states[t],n=(i=o==null?void 0:o.on)==null?void 0:i[e];if(!n){Lf(t,e,r);return}return n}function Lf(t,e,s){const r=`Invalid transition: Event "${e}" not allowed from state "${t}"`;if(s)throw new Error(r);console.warn(r)}function Ff(t,e,s,r,o,n,i,a){t.isTransitioning=!0;try{Nf(t,e,i),t[o]=s,jf(t,s,r,a),Uf(t,s,n)}finally{t.isTransitioning=!1}}function Nf(t,e,s){const r=s.get(e);r&&typeof t[r]=="function"&&t[r]()}function Uf(t,e,s){const r=s.get(e);r&&typeof t[r]=="function"&&t[r]()}function jf(t,e,s,r){r.trackHistory&&t.stateHistory&&t.stateHistory.push({state:e,timestamp:new Date,event:s})}function Bf(t,e,s){const{stateProperty:r}=s;return function(o){var a;if(!this._fsmInitialized)return!1;const n=this[r],i=this._fsmConfig.states[n];return((a=i==null?void 0:i.on)==null?void 0:a[o])!==void 0}}function Hf(t,e){const{stateProperty:s}=e;return function(r){return this._fsmInitialized?this[s]===r:!1}}function Ic(t,e){const s=t[Bs];if(!s)return;const{config:r,options:o}=s,{stateProperty:n}=o;r.initializeAt===e&&(t._fsmInitialized||(Kf(t,n,r.initial),t._fsmInitialized=!0,qf(t,r.initial,o),zf(t,r.initial),Sf.debug(`FSM initialized for model ${t.id} at lifecycle ${e} with initial state "${r.initial}"`)))}function Kf(t,e,s){t[e]=s}function qf(t,e,s){s.trackHistory&&t.stateHistory&&t.stateHistory.push({state:e,timestamp:new Date})}function zf(t,e){const r=(t.constructor.prototype[Ot]||new Map).get(e);r&&typeof t[r]=="function"&&t[r]()}const De=(t,e)=>{t[Ge]=t[Ge]||{},t[Ge][e]=!0},ht=t=>`{PROP_${String(t)}}`,Vf=t=>`{PROP_${String(t)}}`,Gf=ht("kosParentId"),Yr=t=>e=>{e[ms]=e[ms]||{};const s=(t==null?void 0:t.parentId)||Gf;e[ms]={parentId:s},e.prototype[Hs]=!0};function Yf(t){return e=>{const s=(t==null?void 0:t.mode)||"decorator",r=(t==null?void 0:t.parentProperty)||"companionParent",o=(t==null?void 0:t.excludeProperties)||[],n=t==null?void 0:t.lifecycle;return Yr()(e),e.prototype[Ye]={mode:s,parentProperty:r,excludeProperties:o,lifecycle:n},e}}function Oc(t){return e=>{const s=t!=null&&t.legacy?"_models":(t==null?void 0:t.containerProperty)||"container",r=(t==null?void 0:t.includeMethods)!==!1,o=(t==null?void 0:t.includeGetters)!==!1,n=(t==null?void 0:t.modelsProperty)||"models",i=(t==null?void 0:t.containerOptions)||{};return e.prototype[En]={containerProperty:s,includeMethods:r,includeGetters:o,modelsProperty:n,containerOptions:i,legacy:(t==null?void 0:t.legacy)||!1},e}}function Wf(t,e,s){const r=s.value;s.value=function(...o){const n=Y.getContext(this.id);return o.push(n),r.apply(this,o)}}const Wr=Symbol("KosExecutionContext");function Mn(t){return t&&typeof t=="object"&&Wr in t}function Qf(t){return e=>{const s=(t==null?void 0:t.mode)||"full",r=(t==null?void 0:t.handlerProperty)||"futureHandler";return e.prototype[yn]={mode:s,handlerProperty:r},e}}function Zf(t){return e=>{const s=(t==null?void 0:t.mode)||"full",r=(t==null?void 0:t.handlerProperty)||"futureHandler";return e.prototype[bn]={mode:s,handlerProperty:r},e}}var x=(t=>(t.INIT="init",t.LOAD="load",t.READY="ready",t.ACTIVATE="activate",t.ONLINE="online",t))(x||{}),Ve=(t=>(t.CREATE="create",t.CONTINUE="continue",t.FAIL="fail",t))(Ve||{});const Xf=Object.freeze(Object.defineProperty({__proto__:null,DependencyLifecycle:x,DependencyResolutionPolicy:Ve},Symbol.toStringTag,{value:"Module"})),ke=Symbol("HttpRouteHandlers"),xi="__httpBrowserRouter";function Qr(t){return function(s){return function(r,o,n){r[ke]=r[ke]||[];const i={method:t,path:s,handler:o};return r[ke].push(i),r[F]=r[F]||{},r[F][xi]||(r[F][xi]={modelType:"browser-router-model",lifecycle:x.INIT}),n}}}const $c=Qr("GET"),Ks=Qr("POST"),Jf=Qr("PUT"),Cc=Qr("DELETE"),ep=Cc;function mr(t){return!!(t!=null&&t[ke])&&t[ke].length>0}function Dc(t){return(t==null?void 0:t[ke])||[]}const tp=({group:t}={group:""})=>e=>{e[ys]=e[ys]||{},e[ys]={group:t}};class xc{static create({modelId:e,modelTypeName:s,component:r}){const o=[r??"kos",s,e].filter(Boolean).join(".");return m.createLogger({name:o})}}function Ac(t){return e=>{const s=(t==null?void 0:t.loggerProperty)||"logger",r=t==null?void 0:t.loggerContext;e.prototype[wn]={loggerProperty:s,loggerContext:r};const o=()=>{var i;return(i=e.prototype[mn])==null?void 0:i.type};let n;return Object.defineProperty(e.prototype,s,{get(){if(!n){const i=o();n=xc.create({modelTypeName:r||i,component:"kos-model"})}return n},enumerable:!1,configurable:!1}),e}}function Rc(t){return(e,s,r)=>{e[at]=e[at]||{},e[at][s]={dependencies:t==null?void 0:t.dependencies,value:r.value},r.value=function(){throw new Error(`Method ${s} cannot be called directly.`)}}}const sp=t=>(e,s)=>{e[ar]=e[ar]||{},e[ar][s]=t},bo=m.createLogger({name:"resolve-parameters"}),Me=({value:t,modelId:e,modelData:s})=>{let r=t;if(Array.isArray(r))return[...t];if(typeof r!="string"&&typeof r!="object")return r;if(typeof r=="object")r=Object.keys(r).reduce((o,n)=>(o[n]=Me({value:r[n],modelId:e,modelData:s}),o),{});else if(typeof r=="string"){const o=new RegExp("{PROP_(.+?)}","g");let n=r!=null&&r.includes(pr)?r.replace(pr,e):r;if(s){let i=!1;const a=/^{PROP_.+?}$/.test(n);if(n=n.replace(o,(c,u)=>{if(Object.getOwnPropertyNames(s).includes(u)||Object.getOwnPropertyNames(Object.getPrototypeOf(s)).includes(u)){const h=s[u];return h?(bo.debug(`Resolved ${c} to ${h}`),h):(bo[a?"debug":"warn"](`Property ${u} is falsy${a?"":" in composite string"}, marking for undefined return`),i=!0,c)}return bo[a?"debug":"warn"](`Property ${u} not found in modelData${a?"":" for composite string"}`),c}),i)return}return n}else return r;return r},ct=Symbol("ServiceRequestHandlers"),Ai=new WeakMap;function ft(t){return(e,s,r)=>{var a;e[ct]=e[ct]||{};const o=r.value,n={...t,handlerMethod:s,originalHandler:o},i=`${((a=t.method)==null?void 0:a.toUpperCase())||"GET"}:${String(t.path)}`;if(e[ct][i]=n,!t.lifecycle){const c=function(...u){const d=u[u.length-1],h=async f=>{const p=Ai.get(c);if(!p)throw new Error("Service request metadata not found for method");try{const{default:y}=await Promise.resolve().then(()=>al),w=Me({value:p.path,modelId:this.id,modelData:this}),E={...typeof p.pathParams=="function"?p.pathParams(this):p.pathParams||{},...(f==null?void 0:f.pathParams)||{}},_={...typeof p.queryParams=="function"?p.queryParams(this):p.queryParams||{},...(f==null?void 0:f.queryParams)||{}},k=(f==null?void 0:f.body)||(typeof p.body=="function"?p.body(this):p.body),O={...(typeof p.requestOptions=="function"?p.requestOptions(this,...u):p.requestOptions)||{},...(f==null?void 0:f.requestOptions)||{}},S={};Object.keys(E).length>0&&(S.path=E),Object.keys(_).length>0&&(S.query=_);const z=(p.method||"get").toLowerCase(),j=y,[Z,Ke]=z==="get"?await j.get(w,S,O):z==="post"?await j.post(w,S,k,O):z==="put"?await j.put(w,S,k,O):z==="delete"?await j.delete(w,S,k,O):await j.get(w,S,O);if(Z){if(p.errorHandler)switch(p.errorHandler.strategy){case"log":return console.error(`Service request error: ${Z}`),p.errorHandler.onError&&p.errorHandler.onError(new Error(Z),this),[null,p.errorHandler.defaultValue];case"ignore":return[null,p.errorHandler.defaultValue];case"default":return[null,p.errorHandler.defaultValue];case"throw":default:return[Z,null]}return[Z,null]}let qe=Ke;return p.transform&&(qe=p.transform(Ke)),[null,qe]}catch(y){return[y.message||"Unknown error",null]}};if(Mn(d))return d.$request=h,o.apply(this,u);{const f={[Wr]:!0,$request:h};return o.apply(this,[...u,f])}};Ai.set(c,n),r.value=c}return r}}var Pc=(t=>(t.GET="GET",t.PUT="PUT",t.POST="POST",t.DELETE="DELETE",t))(Pc||{}),de=(t=>(t.IMMEDIATE="immediate",t.SINGLE="single",t.TTL="ttl",t.PERMANENT="permanent",t.MANUAL="manual",t))(de||{}),it=(t=>(t.ALL="all",t.AFTER_REQUEST="after-request",t.AFTER_RESPONSE="after-response",t.NONE="none",t))(it||{});const rp=m.createLogger({name:"kos-state-machine"});function op(t,e){return s=>(s.prototype[Bs]={config:{...t,initializeAt:t.initializeAt||x.READY},options:{stateProperty:(e==null?void 0:e.stateProperty)||"currentState",trackHistory:(e==null?void 0:e.trackHistory)||!1,throwOnInvalid:(e==null?void 0:e.throwOnInvalid)!==!1}},s)}function np(t){return(e,s)=>{e[Ot]||(e[Ot]=new Map),e[Ot].set(t,s)}}function ip(t){return(e,s)=>{e[vs]||(e[vs]=new Map),e[vs].set(t,s)}}function ap(t){return(e,s,r)=>{const o=r.value;return r.value=function(...n){var u,d;if(!this.isFsmInitialized)return o.apply(this,n);const a=this.currentState;if(!t.allowedStates.includes(a)){const h=`Method ${String(s)} cannot be called from state "${a}". Allowed states: ${t.allowedStates.join(", ")}`;if(t.throwOnInvalid!==void 0?t.throwOnInvalid:((d=(u=this[Bs])==null?void 0:u.options)==null?void 0:d.throwOnInvalid)!==!1)throw new Error(h);rp.warn(h);return}return o.apply(this,n)},r}}function cp(t){return e=>{const s=(t==null?void 0:t.pathProperty)||"path";return e.prototype[vn]={pathProperty:s},e.prototype[F]=e.prototype[F]||{},e.prototype[F].troubleContainer={modelType:"trouble-container-model",id:"trouble-container-model",options:{},lazy:!1},e}}const qt=({modelType:t,id:e,options:s,lifecycle:r,resolutionPolicy:o})=>(n,i)=>{n[F]=n[F]||{},n[F][i]={modelType:t,id:e,options:s,lifecycle:r||x.INIT,resolutionPolicy:o}};class kc{constructor(e,s){l(this,"futures");l(this,"defaultContext");l(this,"context");l(this,"disposers",new Map);l(this,"container");this.futures=An.map(new Map),this.context="",this.defaultContext=s||"",this.container=e,M.makeAutoObservable(this)}get allFutures(){return Array.from(this.futures.values())}get future(){return this.futures.get(this.defaultContext)}addFuture(e,s){this.futures.set(s||e.id,e),this.context=s||e.id;const r=W(()=>{var o,n;(e.endState||e.progress)&&((n=(o=this.container)==null?void 0:o.onFutureUpdate)==null||n.call(o,e))});this.disposers.set(s||e.id,r)}removeFuture(e){var s;this.futures.delete(e||this.context),(s=this.disposers.get(e||this.context))==null||s(),this.disposers.delete(e||this.context)}getFuture(e){return this.futures.get(e||this.context)}get futureMap(){return this.futures}}class Zr{constructor(e){l(this,"disposer");l(this,"_future");l(this,"container");l(this,"onFutureUpdate");this._future=void 0,this.container=e,M.makeAutoObservable(this)}removeFuture(){var e;this._future=void 0,(e=this.disposer)==null||e.call(this),this.disposer=void 0}get future(){return this._future}getFuture(){return this._future}addFuture(e){this._future=e;const s=W(()=>{var r,o;(e.endState||e.progress)&&((o=(r=this.container)==null?void 0:r.onFutureUpdate)==null||o.call(r,e))});this.disposer=s}get allFutures(){return this._future?[this._future]:[]}get timeRemaining(){var e;return((e=this._future)==null?void 0:e.timeRemaining)||""}get status(){var e;return((e=this._future)==null?void 0:e.status)||"NOT_RESOLVED"}get progress(){var e;return((e=this._future)==null?void 0:e.progress)||-1}async cancel(){if(this._future)try{await this._future.cancelFuture()}catch(e){throw m.error(e),e}}}const Lc=(t,e)=>{const s=e.type;return t[s]||(t[s]=[]),t[s].push(e),t},Fc=Symbol("KosObservableData"),Jt=Symbol("revision");var LT;class Nc{constructor(){l(this,"map");l(this,LT,1);l(this,"atomMap",new Map);l(this,"proxyHandler",{get:(e,s)=>{var r;return s===Jt||e[s]!==void 0?e[s]:this.atomMap.has(s)&&(r=this.atomMap.get(s))!=null&&r.reportObserved()?this.getValue(s):this.getValue(s)},set:(e,s,r)=>{var o;return this.map.has(s),this.setValue(s,r),this.atomMap.has(s)||this.atomMap.set(s,M.createAtom(s.toString())),(o=this.atomMap.get(s))==null||o.reportChanged(),!0},ownKeys:()=>Array.from(this.map.keys())});this.map=M.observable.map(new Map),M.makeObservable(this,{[Jt]:M.observable})}setValue(e,s){const r=this.map.has(e);this.map.set(e,s),r||M.action(()=>{this[Jt]++})()}getValue(e){return this.map.get(e)}has(e){return this.map.has(e)}get entries(){return Array.from(this.map.entries())}get keys(){return this[Jt],Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}setValues(e){e&&Object.keys(e).forEach(s=>{this.setValue(s,e[s])})}get proxy(){return new Proxy(this,this.proxyHandler)}}LT=Jt;Nc.prototype[Fc]=!0;function lp(t,e){return new Proxy(t,{construct:(s,r)=>{const o=new t(...r);return o.setValues(e),o.proxy}})}const Oe=t=>{const e=lp(Nc,t);return new e(t)};function up(t,e){return t.length!==e.length?!1:t.every(s=>e.includes(s))}class Tn{constructor({container:e,key:s}){l(this,"_container");l(this,"_map");l(this,"_key");l(this,"data");this._container=e,this._map=M.observable.map(new Map),this._key=s,this.data=Oe(),this.generateIndex(),M.autorun(()=>{this._container.revision&&this.generateIndex()}),M.makeAutoObservable(this)}refresh(){this.generateIndex()}addItemToIndex(e,s,r=this._map,o=this.data){const n=r.get(e)||new Set;n.add(s),r.set(e,n),o[e]=Array.from(n)}resolveIndex(e,s){this.data.keys.filter(o=>!Object.keys(s).includes(o)).forEach(o=>{delete this.data[o],this._map.delete(o)}),Object.keys(s).forEach(o=>{const n=s[o],i=this.data[o]||[];if(up(n,i))m.debug(`KosContainerIndex - Index ${o} is the same`);else{this.data[o]=n;const a=e.get(o)||new Set;this._map.set(o,a)}})}generateIndex(){M.runInAction(async()=>{const e=new Map,s={};for(const r of this._container.data){const o=typeof this._key=="function"?await this._key(r):r[this._key];Array.isArray(o)?o.forEach(n=>{this.addItemToIndex(n,r,e,s)}):typeof o=="string"||typeof o=="number"?this.addItemToIndex(String(o),r,e,s):typeof o=="boolean"&&this.addItemToIndex(String(o),r,e,s)}this.resolveIndex(e,s)})}get keys(){return Array.from(this._map.keys())}get index(){return this._map}getByKey(e){const s=this._map.get(e);return s?Array.from(s):[]}}function dp(t,e,s=[]){const r=Object.getOwnPropertyDescriptors(t);return Object.keys(r).filter(i=>M.isComputedProp(t,i)).filter(i=>s.includes(i)).map(i=>M.reaction(()=>t[i],(a,c)=>{e({name:i,newValue:a,oldValue:c})}))}const ne=m.createLogger({name:"kos-container-model"});class xe{constructor(e){l(this,"_data");l(this,"_sortKey");l(this,"_revision");l(this,"_index");l(this,"_optionsMap");l(this,"_disposerMap",new Map);l(this,"_parentId");l(this,"idx");l(this,"_maxCapacity");l(this,"_evictionStrategy");l(this,"_evictionBatchSize");l(this,"_insertionOrder",[]);l(this,"_accessTimes");l(this,"_customEvictionFilter");this._data=M.observable.map(new Map),this._sortKey=e==null?void 0:e.sortKey,this._revision=1;const s=e!=null&&e.extensionId?$.indexExtension.loadIndexExtensions(e.extensionId):{},r=(e==null?void 0:e.indexMap)||{};this._optionsMap={...r,...s};const o=e!=null&&e.indexMap?Object.keys(e.indexMap).reduce((n,i)=>(n[i]=void 0,n),{}):{};this._index=M.observable.map(o),this.idx=Oe(),this._parentId=e==null?void 0:e.parentId,this._maxCapacity=e==null?void 0:e.maxCapacity,this._evictionStrategy=(e==null?void 0:e.evictionStrategy)||"fifo",this._evictionBatchSize=(e==null?void 0:e.evictionBatchSize)??Math.max(10,Math.ceil(((e==null?void 0:e.maxCapacity)??100)*.1)),this._customEvictionFilter=e==null?void 0:e.customEvictionFilter,this._evictionStrategy==="lru"&&this._maxCapacity&&(this._accessTimes=M.observable.map(new Map)),M.makeAutoObservable(this),this.init()}init(){Object.keys(this._optionsMap).forEach(e=>{const s=this._optionsMap[e],r=new Tn({container:this,key:s});this._index.set(e,r),this.idx[e]=r.data})}[Symbol.iterator](){return this.data[Symbol.iterator]()}get index(){return this._index}get revision(){return this._revision}get indexKeys(){return Array.from(this.index.keys()).reduce((e,s)=>{var r;return e[s]=(r=this.index.get(s))==null?void 0:r.keys,e},{})}sortFn(e,s){const r=this._sortKey;return r?String(e[r]).localeCompare(String(s[r]),void 0,{numeric:!0}):0}get data(){const e=Array.from(this._data.values());return this._sortKey&&e.sort(this.sortFn.bind(this)),e}increment(){M.runInAction(()=>{this._revision=this._revision+1})}addAll(e){M.runInAction(()=>{e.forEach(s=>this.addModel(s,!0))}),this.increment()}removeAll(e){M.runInAction(()=>{e.forEach(s=>this.removeModel(s,!0)),this.increment()})}async removeAndDestroy(e){const s=this.getModel(e);if(!s){ne.debug(`Model ${e} not found in container, skipping destroy`);return}this.removeModel(e);try{await Ie(s)}catch(r){throw ne.error(`Failed to destroy model ${e}:`,r),r}}async removeAndDestroyAll(e){const s=e.map(n=>this.getModel(n)).filter(n=>n!==void 0);if(s.length===0){ne.debug("No models found to destroy");return}this.removeAll(e);const r=await Promise.allSettled(s.map(n=>Ie(n)));r.forEach((n,i)=>{n.status==="rejected"&&ne.error(`Failed to destroy model ${s[i].id}:`,n.reason)});const o=r.filter(n=>n.status==="rejected");if(o.length>0)throw new Error(`Failed to destroy ${o.length} of ${s.length} models`)}addModel(e,s){this._persistModel(e),this._trackModelMetadata(e),this._establishModelRelationships(e),this._enforceCapacityLimits(),this._configureModelMonitoring(e),s||this.increment()}_persistModel(e){this._data.set(e.id||"",e)}_trackModelMetadata(e){this._maxCapacity&&(this._insertionOrder.push(e.id||""),this._accessTimes&&this._accessTimes.set(e.id||"",Date.now()))}_establishModelRelationships(e){e.id&&this._parentId&&Y.setParentContext(e.id,this._parentId)}_enforceCapacityLimits(){this._maxCapacity&&this._data.size>this._maxCapacity&&this._evictModels()}_configureModelMonitoring(e){const s=this._disposerMap.get(e.id);s&&(s(),this._disposerMap.delete(e.id));const r=Object.entries(this._optionsMap||{}),o=Object.values(this._optionsMap||{}),n=new Map(r.map(([u,d])=>[d,u])),i=u=>{var h,f;o.includes(u.name)&&((h=this.index.get(n.get(u.name)))==null||h.refresh());const d=r.filter(([,p])=>typeof p=="function");for(const[p]of d)(f=this.index.get(p))==null||f.refresh()},a=dp(e,i,o.filter(u=>typeof u=="string")),c=M.observe(e,i);this._disposerMap.set(e.id||"",()=>[c,...a].forEach(u=>u()))}removeModel(e,s){this._data.delete(e);const r=this._insertionOrder.indexOf(e);r!==-1&&this._insertionOrder.splice(r,1),this._accessTimes&&this._accessTimes.delete(e),s||this.increment();const o=this._disposerMap.get(e);o&&(o(),this._disposerMap.delete(e))}updateModel(e){this._data.set(e.id||"",e),this.increment()}getModel(e){const s=this._data.get(e);return s&&this._accessTimes&&this._accessTimes.set(e,Date.now()),s}getIndexKeys(e){return this.index.has(e)?this.index.get(e).keys??[]:(ne.info(`index ${e} not found in ${Array.from(this.index.keys())}`),[])}getIndexByKey(e,s){if(this.index.has(e)){const r=this.index.get(e);return r.index.has(s)?r.getByKey(s):(ne.info(`key ${s} not found in ${e} index: ${Array.from(r.index.keys())}`),[])}else return ne.info(`index ${e} not found in ${Array.from(this.index.keys())}`),[]}async _evictModels(){if(!this._maxCapacity)return;const e=this._data.size-this._maxCapacity;if(e<=0)return;const s=Math.min(this._evictionBatchSize,e);this._logCapacityWarning(s);const r=this._selectModelsForEviction(s);await this._removeEvictedModels(r),this._logEvictionComplete(r.length),this.increment()}_logCapacityWarning(e){ne.info(`Container capacity exceeded (${this._data.size}/${this._maxCapacity}). Evicting ${e} models using ${this._evictionStrategy} strategy.`,{parentId:this._parentId})}_selectModelsForEviction(e){switch(this._evictionStrategy){case"fifo":return this._selectFifoModels(e);case"lru":return this._selectLruModels(e);case"custom":return this._selectCustomModels(e);default:return this._selectFifoModels(e)}}_selectFifoModels(e){const s=[];for(let r=0;r<e&&this._insertionOrder.length>0;r++){const o=this._insertionOrder.shift();if(!o)continue;const n=this._data.get(o);n&&s.push(n)}return s}_selectLruModels(e){const s=[];return this._accessTimes&&Array.from(this._accessTimes.entries()).sort((o,n)=>o[1]-n[1]).slice(0,e).forEach(([o])=>{const n=this._data.get(o);n&&s.push(n)}),s}_selectCustomModels(e){return this._customEvictionFilter?this._customEvictionFilter(this.data).slice(0,e):(ne.error("Custom eviction strategy specified but no customEvictionFilter provided. Falling back to FIFO.",{parentId:this._parentId}),this._selectFifoModels(e))}async _removeEvictedModels(e){for(const s of e)ne.info(`Evicting model: ${s.id} (type: ${s.constructor.name})`,{modelId:s.id,parentId:this._parentId,strategy:this._evictionStrategy}),this.removeModel(s.id,!0),Ie(s).catch(r=>ne.error(`Failed to destroy evicted model ${s.id}:`,r))}_logEvictionComplete(e){ne.info(`Evicted ${e} models. Current size: ${this._data.size}/${this._maxCapacity}`,{parentId:this._parentId})}async clear(){this._data.forEach(e=>{const s=e.id;Ie(e).then(()=>{ne.debug(`${s} destroyed, removing from map`),this.removeModel(s,!0)}).catch(r=>ne.error(r))}),this.increment()}filter(e,s){return this.data.filter(e,s)}sort(e){return this.data.sort(e)}map(e,s){return this.data.map(e,s)}forEach(e,s){this.data.forEach(e,s)}toJSON(){return{indexes:this.indexKeys,data:this.data.map(s=>({id:s.id,type:s.constructor.name}))}}}var v=(t=>(t.CREATING="creating",t.CREATED="created",t.INITIALIZING="initializing",t.INITIALIZED="initialized",t.LOADING="loading",t.LOADED="loaded",t.ONLINE="online",t.READYING="readying",t.READY="ready",t.READY_FAILED="ready_failed",t.RESETTING="resetting",t.RESET="reset",t.OFFLINE="offline",t.UNLOADING="unloading",t.UNLOADED="unloaded",t.FAILED="failed",t.INACTIVE="inactive",t.ACTIVE="active",t.ACTIVATING="activating",t.DEACTIVATING="deactivating",t))(v||{}),L=(t=>(t.CREATE="create",t.INITIALIZE="init",t.LOAD="load",t.READY="ready",t.GO_ONLINE="go_online",t.GO_OFFLINE="go_offline",t.RESET="go_offline",t.UNLOAD="unload",t.FAILED="failed",t.GO_ACTIVE="go_active",t.GO_INACTIVE="go_inactive",t.TIMEOUT="timeout",t))(L||{});const he=async t=>{if(t.id){const e=I.getInstance().modelManager.getModelById(t.id);if(!e)throw new Error(`Model with ID ${t.id} not found`);await(e==null?void 0:e.whenReady())}else throw new Error("Data model must have a valid ID");return t},Ie=async t=>{await I.getInstance().whenReady(),await I.getInstance().modelManager.initiateDestroyModel(t)},hp=async t=>{if(await I.getInstance().whenReady(),!t.id)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t.id);e&&await e.fsm.transitionTo(L.UNLOAD,v.UNLOADED)},fp=async t=>{await I.getInstance().whenReady(),await I.getInstance().modelManager.reloadModel(t),m.debug(`reload model initiated for model ${t.id}, model ready: ${yr(t)} - ${Date.now()} `),await he(t),m.debug(`reload model complete for model ${t.id}, model ready: ${yr(t)} - ${Date.now()} `)},pp=async t=>{if(await I.getInstance().whenReady(),!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);return e==null?void 0:e.modelTypeName},Uc=async t=>{if(await I.getInstance().whenReady(),!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);return{model:e==null?void 0:e.modelData,type:e==null?void 0:e.modelTypeName}},$e=t=>{if(!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);return{model:e==null?void 0:e.modelData,type:e==null?void 0:e.modelTypeName}},jc=(t,e)=>{if(!t)throw new Error("Model type is required");return I.getInstance().modelManager.getModelsByType(t).filter(o=>Object.keys(e).every(n=>o[n]===e[n]))},gp=(t,e)=>jc(t,e)[0],mp=(t,e)=>{if(!t.id)throw new Error("Model ID is required");const s=I.getInstance().modelManager.getModelById(t.id);if(!s)throw new Error("Model not found");const r=s.companionModels.get(e);return r==null?void 0:r.modelData},Bc=t=>{if(!t.id)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t.id);if(!e)throw new Error("Model not found");return Array.from(e.companionModels.all()).map(r=>r.modelData)},yp=t=>{if(!t)throw new Error("Model ID is required");const e=I.getInstance().modelManager.getModelById(t);if(!e)throw new Error("Model not found");return e.companionModels.data},ko=(t,e)=>{const s=I.getInstance().modelManager.getModelById(t);if(!s){m.info(`Model not found for id ${t}`);return}return Array.from(s.companionModels.all()).find(o=>e(o.modelData))},_e=t=>e=>Object.getPrototypeOf(e).modelTypeId===t,yr=t=>{const e=I.getInstance().modelManager.getModelById(t.id);if(!e)throw new Error("Model not found");return e.isReady()},bp=m.createLogger({name:"kos-model-factory"}),ws={byModelType:t=>I.getInstance().modelManager.getModelFactory(t),getModelInstance:(t,e,s)=>{const r=ws.byModelType(e);if(!r)throw bp.error(`No registered factory found for model type ${e}. Please register a factory for this model type. `),Error(`No factory found for model type ${e}`);return r.build(t,s)}},ae={Factory:{create:t=>e=>(s,r)=>(r&&Y.setParentContext(e,r),ws.getModelInstance(e,t,s))},Singleton:{create:t=>(e,s)=>(s&&Y.setParentContext(t,s),ws.getModelInstance(t,t,e))},Model:{instance:t=>e=>ws.getModelInstance(e,t)}};window.KosRegistry=window.KosRegistry||{coreModels:new Map,preloadModels:[],companionModels:new Map,models:new Map};const Ri=window.KosRegistry.coreModels,vo=window.KosRegistry.preloadModels,wo=window.KosRegistry.companionModels,Zs=window.KosRegistry.models,A={model:{registerLegacyModel:t=>(e,s)=>(Ri.set(e,s),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}),preloadModel:t=>e=>(vo.includes(e)||vo.push(e),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}),register:t=>(e,s)=>{const r=Eo(e)?e.registration():e;return Zs.set(r.type,r),Eo(e)&&e.relatedModels.forEach(o=>Zs.set(o.type,o.registration())),I.getInstance().isReady&&(I.getInstance().modelManager.registry.models[r.type]||(console.info(`Model with type ${r.type} doesn't exist. Adding new registration`),I.getInstance().modelManager.registry.models[r.type]=r.registration[r.type],Eo(e)&&e.relatedModels.forEach(o=>I.getInstance().modelManager.registry.models[o.type]=o.registration().registration))),s&&A.model.preloadModel(t)(r.type),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}},get:t=>Zs.get(t),getAll:()=>Array.from(Zs.entries()),getPreloadModels:()=>vo,getLegacyModels:()=>Array.from(Ri.entries()).reduce((t,[e,s])=>(t[e]=s,t),{})},companion:{register:t=>(e,s)=>{const r=wo.get(e)||[];return r.push(s),wo.set(e,r),{preload:A.model.preloadModel(t),model:A.model.register(t),companion:A.companion.register(t),legacy:A.model.registerLegacyModel(t),root:t}},getAll:()=>Array.from(wo.entries())}},Hc=A.model.registerLegacyModel,Kc=A.model.register,vp=A.companion.register,wp=A.model.preloadModel,_n=t=>typeof t.updateModel=="function",Eo=t=>t.registration!==void 0&&typeof t.registration=="function";class qc{constructor(e){l(this,"singleton");l(this,"type");l(this,"loader");l(this,"class");l(this,"guard");l(this,"factory");l(this,"relatedModels",[]);this.singleton=e.singleton,this.guard=_e(e.type),this.type=e.type,this.loader=`kos.extension.model.loader.${e.type}`,this.factory=e.factory,this.class=e.class}addRelatedModel(e){this.relatedModels.push(e)}registerRelatedModels(){this.relatedModels.forEach(e=>e.register())}register(){A.model.register({})(this.registration()),this.registerRelatedModels()}}class be extends qc{constructor(e){super({...e,singleton:!1,factory:ae.Factory.create(e.type)})}instance(e){const s=this.factory(e);return{get:()=>{const r=$e(e);if(!r)throw new Error("Model not found with id "+e);if(this.guard(r))return r;throw new Error("Model is not of type "+this.type)},forceUpdate:{options:r=>({build:()=>{const o=s(r);if(this.guard(o)){if(_n(o))o.updateModel(r);else throw new Error(`Model ${this.type} is not updateable. Please implement UpdateAware interface`);return o}else throw new Error("Model is not of type "+this.type)}})},options:r=>({build:()=>{const o=s(r);if(this.guard(o))return o;throw new Error("Model is not of type "+this.type)}})}}registration(){return{type:this.type,predicate:this.guard,registration:{[this.type]:{class:this.class,singleton:!1}},factory:this.factory}}}class Se extends qc{constructor(e){super({...e,singleton:!0,factory:ae.Singleton.create(e.type)})}instance(){const e=this.factory;return{get:()=>{const r=$e(this.type);if(!r)throw new Error("Model not found with id "+this.type);if(this.guard(r))return r;throw new Error(`Model is not of type ${this.type}. Received type ${Object.getPrototypeOf(r).modelTypeId}`)},forceUpdate:{options:r=>({build:()=>{const o=e(r);if(this.guard(o)){if(_n(o))o.updateModel(r);else throw new Error(`Model ${this.type} is not updateable. Please implement UpdateAware interface`);return o}else throw new Error(`Model is not of type ${this.type}. Received type ${Object.getPrototypeOf(o).modelTypeId}`)}})},options:r=>({build:()=>{const o=e(r);if(this.guard(o))return o;throw new Error(`Model is not of type ${this.type}. Received type ${Object.getPrototypeOf(o).modelTypeId}`)}})}}registration(){return{type:this.type,predicate:this.guard,registration:{[this.type]:{class:this.class,singleton:!0}},factory:this.factory}}}const Lo=m.createLogger({group:"decorators",name:"kos-model"});function Ep(t,e,s){var n;const r=(n=t[ms])==null?void 0:n.parentId;if(!r)return;const o=Me({value:r,modelData:s,modelId:e});o&&typeof o=="string"&&Y.setParentContext(e,o)}function Mp(t){const e=t[gs];e&&Object.entries(e).forEach(([s,{handler:r}])=>{t[s]=r})}function Tp(t,e){const s=t[F]||{};Object.entries(s).forEach(([r,o])=>{const n=Me({value:o.id||o.modelType,modelData:t,modelId:e}),i=Object.entries((o==null?void 0:o.options)||{}).reduce((a,[c,u])=>(a[c]=Me({value:u,modelData:t,modelId:e}),a),{});if(typeof n=="string"){if(!o.lazy){const a=I.getInstance().modelManager.createModelInstance(o.modelType,n,i);t[r]=a.data}I.getInstance().modelManager.addDependency(e,n)}})}function _p(t){const e=t[yn];if(!e)return;const{mode:s,handlerProperty:r}=e,o=new Zr(t);t[r]=o,s==="full"&&(Object.defineProperty(t,"future",{get(){return o.future},enumerable:!0,configurable:!0}),Object.defineProperty(t,"progress",{get(){var n;return((n=o.future)==null?void 0:n.progress)||0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"status",{get(){var n;return((n=o.future)==null?void 0:n.status)||"IDLE"},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isRunning",{get(){return o.future?!o.future.endState:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isCancelled",{get(){var n;return((n=o.future)==null?void 0:n.status)==="CANCELLED"||!1},enumerable:!0,configurable:!0}),t.cancelFuture=async()=>{o.future&&await o.future.cancelFuture()})}function Sp(t){const e=t[bn];if(!e)return;const{mode:s,handlerProperty:r}=e,o=new kc(t);t[r]=o,Object.defineProperty(t,"future",{get(){return o.future},enumerable:!0,configurable:!0});const n=t[bs];n instanceof Map&&n.forEach(i=>{const a=`${i}Future`;Object.defineProperty(t,a,{get(){return o.futureMap.get(i)},enumerable:!0,configurable:!0}),s==="full"&&(Object.defineProperty(t,`${i}Progress`,{get(){const c=o.futureMap.get(i);return(c==null?void 0:c.progress)||0},enumerable:!0,configurable:!0}),Object.defineProperty(t,`${i}Status`,{get(){const c=o.futureMap.get(i);return(c==null?void 0:c.status)||"IDLE"},enumerable:!0,configurable:!0}),Object.defineProperty(t,`${i}IsRunning`,{get(){const c=o.futureMap.get(i);return c?!c.endState:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,`${i}IsCancelled`,{get(){const c=o.futureMap.get(i);return(c==null?void 0:c.status)==="CANCELLED"||!1},enumerable:!0,configurable:!0}),t[`cancel${i.charAt(0).toUpperCase()}${i.slice(1)}`]=async()=>{const c=o.futureMap.get(i);c&&await c.cancelFuture()})}),s==="full"&&(Object.defineProperty(t,"progress",{get(){var i;return((i=o.future)==null?void 0:i.progress)||0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"status",{get(){var i;return((i=o.future)==null?void 0:i.status)||"IDLE"},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isRunning",{get(){return o.future?!o.future.endState:!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isCancelled",{get(){var i;return((i=o.future)==null?void 0:i.status)==="CANCELLED"||!1},enumerable:!0,configurable:!0}),t.cancelFuture=async()=>{o.future&&await o.future.cancelFuture()})}function Ip(t){const e=t[vn];if(!e)return;const{pathProperty:s}=e;Object.defineProperty(t,"troubles",{get(){const r=this[s];if(r==null){const o=`@kosTroubleAware: Path property '${s}' is undefined on model ${this.id||"unknown"}. Returning empty troubles array.`;return this.logger&&typeof this.logger.warn=="function"?this.logger.warn(o):console.warn(o),[]}return this.troubleContainer.troubles.getIndexByKey("byIface",r).sort((o,n)=>n.rank-o.rank)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"troubleStatus",{get(){return""},enumerable:!0,configurable:!0}),Object.defineProperty(t,"troublesByType",{get(){return this.troubles.reduce(Lc,{})},enumerable:!0,configurable:!0})}function Op(t,e){const s=t[En];if(!s)return;const{containerProperty:r,includeMethods:o,includeGetters:n,modelsProperty:i,containerOptions:a,legacy:c}=s,u={...a,parentId:a.parentId||e},d=new xe(u);t[r]=d,t[Ge]||(t[Ge]={}),t[Ge][r]=d,o&&(t.getModel=h=>d.getModel(h),t.addModel=h=>{d.addModel(h)},t.removeModel=h=>{d.removeModel(h)},t.addAll=h=>{d.addAll(h)},t.removeAll=h=>{d.removeAll(h)},t.removeAndDestroy=async h=>d.removeAndDestroy(h),t.removeAndDestroyAll=async h=>d.removeAndDestroyAll(h)),n&&(Object.defineProperty(t,i,{get(){return d},enumerable:!0,configurable:!0}),Object.defineProperty(t,"data",{get(){return d.data},enumerable:!0,configurable:!0}))}function $p(t,e){const s=t.constructor.prototype[Ye];if(!s)return;const{mode:r,parentProperty:o,excludeProperties:n}=s,i=e.companionParent;if(!i){Lo.warn("Companion decorator configured but no parent model found in initialData.companionParent");return}if(t.getCompanionParent=()=>i,Object.defineProperty(t,o,{get:()=>i,enumerable:!0,configurable:!0}),r==="composition")return;const a=["init","load","unload","ready","dispose","destroy","activate"],c=["getDependencies","getChildren","update","toJSON","forceUpdate","makeAutoObservable","runInAction","transaction","observe","unobserve","intercept","spy","trace","getCompanionParent"],u=p=>{const y=i.constructor.prototype[ee]||{};return Object.values(y).some(w=>{const E=w==null?void 0:w.handler;return E===i[p]||E===i.constructor.prototype[p]})},d=p=>p==="constructor"||p.startsWith("_")||p.startsWith("__")||a.includes(p)||c.includes(p)||n.includes(p)||u(p)||p in t,h=new Set;Object.getOwnPropertyNames(i).filter(p=>!d(p)).forEach(p=>h.add(p));let f=Object.getPrototypeOf(i);for(;f&&f!==Object.prototype;)Object.getOwnPropertyNames(f).filter(p=>!d(p)).forEach(p=>h.add(p)),f=Object.getPrototypeOf(f);for(const p of h)try{const y=i[p];typeof y=="function"?t[p]=(...w)=>y.apply(i,w):Object.defineProperty(t,p,{get:()=>i[p],set:w=>{i[p]=w},enumerable:!0,configurable:!0})}catch(y){Lo.debug(`Skipping companion proxy for property ${p}:`,y)}}function Cp(t){try{return M.makeAutoObservable(t)}catch(e){return Lo.error("Failed to make observable:",e),t}}const Dp={construct(t,e){var c;const[s,r={}]=e,o=Y.createContext(s);Ep(t,s,r);const i=!!t.prototype[wn]?null:m.createLogger({name:t.prototype.modelTypeId,group:((c=t[ys])==null?void 0:c.group)??"kos-model"}),a=new t(s,r,{logger:i,kosContext:o});return $p(a,r),Mp(a),_p(a),Sp(a),Ip(a),Op(a,s),Sc(a),Tp(a,s),Cp(a)}};function R(t){return e=>{var n,i;const s=e,r=typeof t=="string"?{modelTypeId:t,autoRegister:!1}:{autoRegister:!1,...t};s.prototype.modelTypeId=r.modelTypeId,s.prototype[mn]=!0,(n=s.prototype)[ee]??(n[ee]={}),(i=s.prototype)[F]??(i[F]={}),r.optionsRequired&&(s.prototype[Hs]=!0),m.ifDebug(()=>{m.debug(`Registering model with id ${r.modelTypeId}`)});const o=new Proxy(s,Dp);if(r.singleton!==void 0){let a;r.singleton?a=new Se({class:o,type:r.modelTypeId}):a=new be({class:o,type:r.modelTypeId}),Object.defineProperty(o,"Registration",{value:a,writable:!1,enumerable:!0,configurable:!1}),r.autoRegister&&a.register()}return o}}const xp=({topic:t,handler:e,websocket:s=!1,condition:r=()=>!0})=>o=>{o[ee]=o[ee]||{},Array.isArray(t)?t.forEach(n=>{o[ee][n]={websocket:s,handler:e,condition:r}}):o[ee][t]={websocket:s,handler:ic(o,M.action(e),200),condition:r}};function zc(t,e,s){const r={};if(!t.endsWith("/*"))return r;const o=t.slice(0,-2);if(e.startsWith(o)){const n=e.slice(o.length+1),i=s||"path";r[i]=n}return r}function Vc(t){return t.endsWith("/*")}function H(t){return(e,s,r)=>{const o=Ap(t,r);kp(e,t.topic,o),t.replay&&Lp(t.topic,t.replay.bufferSize)}}function Ap(t,e){const{condition:s=(S,z)=>!0,transform:r=S=>S,websocket:o=!1,fos:n=!1,bridge:i=!1,skipParse:a=!1,lifecycle:c,destinationAddress:u,debounce:d,throttle:h,buffer:f,filter:p,once:y,wildcardName:w,flow:E,requiresBaseline:_}=t,k=e.value,U=Rp(k,{debounce:d,throttle:h,buffer:f,once:y}),O=Pp(p,s);return{websocket:o,fos:n,bridge:i,handler:U,condition:O,transform:r,lifecycle:c,skipParse:a,destinationAddress:u,wildcardName:w,flow:E,requiresBaseline:_}}function Rp(t,e){var n,i;let s=t;const r=typeof e.debounce=="number"?e.debounce:(n=e.debounce)==null?void 0:n.delay,o=typeof e.throttle=="number"?e.throttle:(i=e.throttle)==null?void 0:i.interval;return r&&r>0?s=Fp(s,e.debounce):o&&o>0?s=Bp(s,e.throttle):e.buffer?s=Hp(async function(c){for(const u of c)await s.call(this,u)},e.buffer):e.once&&(s=Kp(s)),s}function Pp(t,e){return t?(s,r,o)=>t(o)?e(s,r,o):!1:e}function kp(t,e,s){t[ee]=t[ee]||{},Array.isArray(e)?e.forEach(r=>{t[ee][r]=s}):t[ee][e]=s}function Lp(t,e){qp(t,e)}function Fp(t,e){const s=typeof e=="number"?e:e.delay;return Np(e)==="discard"?Up(t,s):jp(t,s)}function Np(t){return(typeof t=="object"?t.discardIntermediate:!1)?"discard":"accumulate"}function Up(t,e){let s=null;return function(r){s&&clearTimeout(s),s=setTimeout(()=>{t.call(this,r),s=null},e)}}function jp(t,e){let s=null,r=[];return function(o){r.push(o),s&&clearTimeout(s),s=setTimeout(()=>{const n=[...r];r=[],t.call(this,n),s=null},e)}}function Bp(t,e){const s=typeof e=="number"?e:e.interval,r=typeof e=="object"?e.discardIntermediate:!1;let o=0,n=null,i=[],a=!1;const c=function(){if(i.length>0){const u=[...i];i=[],t.call(this,u)}};return function(u){const d=Date.now(),h=d-o;r?h>=s?(o=d,t.call(this,u)):n||(n=setTimeout(()=>{o=Date.now(),t.call(this,u),n=null},s-h)):(i.push(u),h>=s?(o=d,c.call(this)):a||(a=!0,n=setTimeout(()=>{o=Date.now(),c.call(this),n=null,a=!1},s-h)))}}function Hp(t,e){const s=[];let r=null;const o=e.maxSize||1e3,n=i=>{s.length>0&&(t.call(i,[...s]),s.length=0)};return function(i){if(s.push(i),s.length>=o){r&&(clearTimeout(r),r=null),n(this);return}r||(r=setTimeout(()=>{n(this),r=null},e.time))}}function Kp(t){let e=!1;return function(s){e||(e=!0,t.call(this,s))}}function qp(t,e){(Array.isArray(t)?t:[t]).forEach(r=>{ln(r,e)})}const Mo=new Map,Gc={addToDeletionQueue:(t,e)=>{const s=Mo.get(t)||[];s.push(e),Mo.set(t,s)},cancelDeletion:t=>{const e=Mo.get(t);e&&e.forEach(s=>{clearTimeout(s)})}},zp=m.createLogger({name:"kos-dependency-manager"});class Vp{constructor(){l(this,"_usedByCache",new Map);l(this,"_usesCache",new Map)}add(e,s){Gc.cancelDeletion(s);const r=this._usedByCache.get(s)||[];r.includes(e)||r.push(e),this._usedByCache.set(s,r);const o=this._usesCache.get(e)||[];o.includes(s)||o.push(s),this._usesCache.set(e,o)}remove(e,s){const r=this._usedByCache.get(s)||[];this._usedByCache.set(s,r.filter(n=>n!==e));const o=this._usesCache.get(e)||[];this._usesCache.set(e,o.filter(n=>n!==s))}canDestroy(e){const s=this._usedByCache.get(e);return s!=null&&s.length?(zp.info(`Model ${e} is still used by: ${s.join(", ")}`),!1):!0}clear(){this._usedByCache.clear(),this._usesCache.clear()}}const Pi=m.createLogger({name:"kos-model-cache"});class Gp{constructor(e=[]){l(this,"_modelsById",M.observable.map(new Map));l(this,"_toDelete",new Map);l(this,"_preloaded",[]);l(this,"_isPreloaded",!1);this.preloadKeys=e}get models(){return Array.from(this._modelsById.values()).map(e=>e).filter(e=>!this._toDelete.has(e.modelId))}getModelById(e){if(e&&!this._toDelete.has(e))return this._modelsById.get(e)}addModel(e){const s=this.getModelById(e.modelId)||e;return this._modelsById.set(s.modelId,s),s}removeModel(e){this._modelsById.delete(e),this._toDelete.delete(e)}hasModel(e){return!!e&&this._modelsById.has(e)&&!this._toDelete.has(e)}restoreFromDeleteCache(e){if(e&&this._toDelete.has(e)){const s=this._toDelete.get(e);this._toDelete.delete(e),this._modelsById.set(e,s)}}markForDeletion(e){this._modelsById.delete(e.modelId),this._toDelete.set(e.modelId,e)}preload(e){return this._isPreloaded?(Pi.debug("Returning cached preloaded models"),this._preloaded):(this._preloaded=this.preloadKeys.map(s=>(Pi.debug(`Preloading model: ${typeof s=="string"?s:s.modelType}`),e(s))).filter(s=>!!s),this._isPreloaded=!0,this._preloaded)}}class cr extends Error{constructor(s,r,o){super(s,{cause:o});l(this,"context");l(this,"originalCause");this.name="KosModelError",this.context=r,this.originalCause=o,o!=null&&o.stack&&(this.stack=`${this.stack}
2
2
  Caused by: ${o.stack}`)}toDetailedString(){const s=[`KosModelError: ${this.message}`,"","Context:",` Model Type: ${this.context.modelType}`,` Model ID: ${this.context.modelId}`];return this.context.parentModel&&s.push(` Parent Model: ${this.context.parentModel.type} [${this.context.parentModel.id}]`),this.context.lifecycle&&s.push(` Lifecycle: ${this.context.lifecycle}`),this.context.operation&&s.push(` Operation: ${this.context.operation}`),this.context.options&&Object.keys(this.context.options).length>0&&s.push(` Options: ${JSON.stringify(this.context.options,null,2)}`),this.originalCause&&s.push("",`Original Error: ${this.originalCause.message}`),s.join(`
3
3
  `)}}function $t(t,e){const s=t instanceof Error?t:new Error(String(t));return t instanceof cr?new cr(`${t.message} (enriched with additional context)`,{...t.context,...e},t.originalCause||s):new cr(`Error in ${e.operation||"model operation"}: ${s.message}`,e,s)}function Yp(t,e){t.length!==0&&(m.error(`${e} - ${t.length} error(s) occurred:`),t.forEach(({error:s,context:r},o)=>{const n=s instanceof cr?s:$t(s,r);m.error(` [${o+1}/${t.length}] ${n.toDetailedString()}`)}))}function ki(t,e){console.error("Model instantiation failed",{modelType:e.modelType,options:e.options,registryId:e.registryId,error:t instanceof Error?t.message:String(t),stack:t instanceof Error?t.stack:void 0,timestamp:new Date().toISOString()})}const Yc=t=>typeof t=="function",Xs=m.createLogger({name:"kos-companion-instantiator"});class Wp{constructor(e,s,r){this.registry=e,this.cache=s,this.createModel=r}createCompanionModels(e,s,r){const o=this.getCompanionDefinitions(e.modelTypeName);r!==void 0&&Xs.debug(`Creating ${r} lifecycle companions for ${e.modelTypeName} [${e.modelId}]`);for(const n of o){const i=this.resolveCompanionType(n,e,s,r);i&&this.shouldCreateCompanion(i.lifecycle,r)&&this.instantiateCompanion(i.type,e,s,r)}}getCompanionDefinitions(e){var s;return((s=this.registry.companionModels)==null?void 0:s[e])||[]}resolveCompanionType(e,s,r,o){return Yc(e.type)?this.resolveFactoryCompanion(e,s,r,o):this.resolveStringCompanion(e)}resolveFactoryCompanion(e,s,r,o){const n=e.type(s.modelData,r);if(!n)return Xs.debug(`Companion factory returned undefined for ${s.modelTypeName} at ${o||"INIT"} phase`),null;const i=this.extractLifecycleFromType(n);return{type:n,lifecycle:i}}resolveStringCompanion(e){return{type:e.type,lifecycle:e.lifecycle}}extractLifecycleFromType(e){const s=this.registry.models[e];if(!(s!=null&&s.class))return;const r=s.class.prototype[Ye];return r==null?void 0:r.lifecycle}shouldCreateCompanion(e,s){return s!==void 0?e===s:e===void 0}instantiateCompanion(e,s,r,o){const n=this.generateCompanionId(e,s.modelId);if(this.companionAlreadyExists(n,e,s.modelTypeName))return;const i=this.createCompanionInstance(e,n,s,r);i&&(this.attachCompanionToParent(i,s),Xs.debug(`Created ${o||"INIT"} companion ${e} for ${s.modelTypeName} [${s.modelId}]`))}generateCompanionId(e,s){return`${e}-${s}`}companionAlreadyExists(e,s,r){return this.cache.hasModel(e)?(Xs.debug(`Companion ${s} already exists for ${r}`),!0):!1}createCompanionInstance(e,s,r,o){const n=this.createModel(e,s,{data:o,companionParent:r.modelData,kosParentId:r.modelId});return(n==null?void 0:n.model)||null}attachCompanionToParent(e,s){e[Ye]=s,s.addCompanionModel(e)}}function Wc(t,e){return`${nn}${t}${e?`/${e}`:`/${t}`}`}function Qc(t){return`${nn}${t}`}function To(t){const e=[];return new Promise((s,r)=>{for(const{condition:o,onMatch:n}of t){const i=M.when(o,()=>{e.forEach(a=>a());try{n==null||n(),s()}catch(a){r(a)}});e.push(i)}})}const Zc=5e3,Qp=t=>t.fsm.transitionTo(L.GO_ACTIVE,v.ACTIVE),Zp=t=>t.whenReady(),Xp=t=>t.fsm.transitionTo(L.LOAD,v.LOADED),Jp=t=>t.fsm.transitionTo(L.UNLOAD,v.UNLOADED),eg=t=>t.fsm.transitionTo(L.INITIALIZE,v.INITIALIZED);var Sn=(t=>(t.ACTIVE="active",t.READY="ready",t.LOAD="load",t.UNLOAD="unload",t.INIT="init",t))(Sn||{});const lr={active:Qp,ready:Zp,load:Xp,unload:Jp,init:eg};class Xc extends Error{constructor(s,r){super(s);l(this,"model");this.model=r}}const Jc=(t,e,s)=>{let r;return{promise:new Promise((i,a)=>{r=setTimeout(()=>{m.error(`Model ${e.modelId} - ${e.modelTypeName} - ${s} timed out after ${t}ms`),a(new Xc(`${e.modelId} - ${e.modelTypeName} - ${s}`,e))},t)}),cancel:()=>{r&&clearTimeout(r)}}},tg=t=>typeof t.toJSON=="function",Es=t=>t[F]!==void 0,In=t=>t.revision!==void 0&&t.index!==void 0,el=t=>{if(t){if(Es(t))return t;if(In(t))return t.data;if(t instanceof Map||t instanceof M.ObservableMap||t instanceof Set)return Array.from(t.values()).filter(Es);if(Array.isArray(t))return t.filter(Es)}},tl=(t,e)=>{var f;const s=e.id||e.modelType,r=Me({value:s,modelData:t.modelData,modelId:t.modelId}),o=e.resolutionPolicy||Ve.CREATE;m.debug(`Resolving dependent model ${e.modelType} with id ${r} (policy: ${o})`);const n=Object.keys((e==null?void 0:e.options)||{}).reduce((p,y)=>{const w=e.options[y];return p[y]=Me({value:w,modelData:t.modelData,modelId:t.modelId}),p},{}),i=I.getInstance().modelManager,a=i.registry.models[e.modelType];if(!a){const p=`No model registered for type ${e.modelType}`;if(m.error(`Failed to resolve dependency for model ${t.modelId}:
4
4
  - Dependency Type: ${e.modelType}