@motifx/core 1.0.1

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.
@@ -0,0 +1,2 @@
1
+ function t(t){setTimeout(()=>{throw t},0)}class e{unexpectedErrorHandler=t;listeners=[];_isDevelopment=!1;_enableConsoleLogging=!0;setDevelopmentMode(t){this._isDevelopment=t}setConsoleLogging(t){this._enableConsoleLogging=t}isDevelopment(){return this._isDevelopment||!0===globalThis.__MOTIF_DEV__}reportSuppressed(t,e){this.logIfDev(t,e)}report(t){this._enableConsoleLogging&&(void 0!==t.cause?console.error(t.message,t.cause):console.error(t.message));try{const e=globalThis.__MOTIF_DEVTOOLS_BUS__;e&&"function"==typeof e.publish&&e.publish("error:caught",{context:t.code??t.name,error:this.serializeError(t)})}catch{}this.emit(t)}logIfDev(t,e){this.isDevelopment()&&this._enableConsoleLogging&&console.error(`[motifjs Error - ${t}]`,e);try{const i=globalThis.__MOTIF_DEVTOOLS_BUS__;i&&"function"==typeof i.publish&&i.publish("error:caught",{context:t,error:this.serializeError(e)})}catch{}}serializeError(t){if(!t)return{message:"Unknown error"};if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack,cause:t.cause?this.serializeError(t.cause):void 0};if("object"==typeof t)try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}return String(t)}addListener(t){return this.listeners.push(t),()=>{const e=this.listeners.indexOf(t);-1!==e&&this.listeners.splice(e,1)}}emit(t){for(const e of this.listeners.slice())e(t)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}safeCall(t,e,i){try{return t()}catch(t){return this.logIfDev(e,t),this.onUnexpectedError(t),i}}async safeCallAsync(t,e,i){try{return await t()}catch(t){return this.logIfDev(e,t),this.onUnexpectedError(t),i}}safeCallSilent(t,e){try{t()}catch(t){this.logIfDev(e,t)}}async safeCallSilentAsync(t,e){try{return await t()}catch(t){this.logIfDev(e,t)}}wrapSafe(t,e){return(...i)=>{try{return t(...i)}catch(t){return this.logIfDev(e,t),void this.onUnexpectedError(t)}}}wrapSafeAsync(t,e){return async(...i)=>{try{return await t(...i)}catch(t){return this.logIfDev(e,t),void this.onUnexpectedError(t)}}}}const i=new e;function s(t,e,s){return i.safeCall(t,e,s)}function n(t,e,s){return i.safeCallAsync(t,e,s)}function o(t,e){i.safeCallSilent(t,e)}function r(t){i.setUnexpectedErrorHandler(t)}const a={enabled:!1,listeners:new Set,warnings:[],routes:null};function c(){return a.enabled||!0===globalThis.__MOTIF_DEV__}function l(){if(!a.enabled&&(a.enabled=function(){try{if("undefined"==typeof window)return!1;const t=window;if(!0===t.__motif_DEVTOOLS)return!0;if(!0===globalThis.__MOTIF_DEVTOOLS__)return!0;if(!0===globalThis.__MOTIF_DEVTOOLS_FLAG)return!0;const e=t.location&&t.location.search||"";return!(!e||!/(?:[?&])devtools=1(?:&|$)/i.test(e))}catch{return!1}}(),a.enabled))try{window.__motifDevBus={on:u,emit:d,warn:p,getWarnings:f,isEnabled:h,setRoutes:m,getRoutes:_}}catch{}}function h(){return a.enabled}function u(t){return a.listeners.add(t),()=>{a.listeners.delete(t)}}function d(t,e){const i={type:t,payload:e};for(const t of a.listeners)try{t(i)}catch{}try{const i=globalThis.__MOTIF_DEVTOOLS_BUS__;i&&"function"==typeof i.publish&&i.publish("devtools:"+t,e)}catch{}}function p(t,e,i){if(!c())return;const s={code:t,message:e,details:i};a.warnings.push(s);try{"undefined"!=typeof console&&(void 0===i?console.warn(`[motifjs] ${t}: ${e}`):console.warn(`[motifjs] ${t}: ${e}`,i))}catch{}d("warning",s)}function f(){return a.warnings.slice()}function m(t){a.routes=t}function _(){return a.routes}const g={MJX101:t=>`dom.createElement('${t}'): no document is available (no DOM environment).`,MJX102:t=>`Invalid element selector "${t}".`,MJX103:t=>`dom.createElementNS('${t}') failed.`,MJX104:()=>"Skipped inserting a component into the DOM because it contains its own parent.",MJX105:()=>"Applying router link classes failed.",MJX106:()=>"The placeholder parent changed; rebuilding the component.",MJX107:()=>"Disposing a child component failed.",MJX108:()=>"Component is disposed; the result of doWork was discarded.",MJX109:()=>"A content block child was removed because its content body is being disposed.",MJX110:t=>`Lazy timeout: the component did not load within ${t} ms.`,MJX111:()=>"Lazy aborted: loading the component was cancelled.",MJX112:t=>`resolveComponent: the factory chain exceeded ${t} levels; a factory may be returning itself.`,MJX113:()=>"The transport slot has no parent; mount the slot before transporting into it.",MJX114:()=>"Placing the navigation target into its host failed.",MJX115:()=>"Disposing the previous navigation target failed.",MJX116:t=>`Timeout: the listener guard did not settle within ${t} ms.`,MJX117:()=>"Detaching a control failed.",MJX118:()=>"The onRemove callback failed while detaching a control.",MJX119:()=>"Moving a fragment's DOM range stopped: its end marker was not found (possible infinite loop).",MJX120:()=>"Scanning a fragment's DOM range stopped: its end marker was not found (possible infinite loop).",MJX121:(t,e)=>`This code was compiled for compiler contract ${t}, but the @motifx/core runtime implements contract ${e}. Install matching versions of @motifx/compiler and @motifx/core, and rebuild packages that ship compiled JSX.`,MJX122:t=>`The component ${t} hook threw.`,MJX123:t=>`The '${t}' event handler threw.`,MJX201:()=>"ListBinding: renderFn must return a component instance, a component class, or a factory function.",MJX202:(t,e)=>`ListBinding: duplicate key "${String(t)}" at index ${e}. Rows are matched by the item object, not by key, so rendering is not affected; keep keys unique so they identify items.`,MJX203:t=>`An effect ran ${t} times in one flush and keeps triggering itself; it is skipped for the rest of this flush. It probably writes a value it reads (for example state.n++). Wrap the write in untracked(...).`,MJX204:()=>"A component reached a text binding and was not written to the DOM. For a template prop that can change later, write a getter: {() => props.tpl}. Templates that are ready at setup also work as {props.tpl}.",MJX205:()=>"Virtualization: the watch callback threw.",MJX206:()=>"Virtualization: autoRefresh stopped; dataRequest may be changing the reactive data it reads on every refresh.",MJX207:()=>"Virtualization: loading data failed.",MJX208:()=>"An effect threw.",MJX301:(t,e)=>`RouterView outlet '${t}' was not built within ${e} ms, so the route chain cannot be mounted. Does the layout component render a <RouterView>?`,MJX302:t=>`Named route '${t}' was not found.`,MJX303:t=>`Redirect loop or too many redirects: ${t}`,MJX304:()=>"Route execution failed.",MJX305:()=>"The error fallback route failed.",MJX306:t=>`The ${t} hook threw.`,MJX307:()=>"Disposing a route component failed.",MJX308:()=>"The stack navigation transition failed.",MJX309:()=>"Router is not initialized. Call useRouter() before navigating.",MJX310:t=>`Route path cannot be empty; use '/' for the default child. Under parent "${t}".`,MJX311:(t,e)=>`Child route path should start with '/': "${t}" under parent "${e}".`,MJX312:t=>`Child route path resolves to the same full path as its parent: "${t}".`,MJX313:t=>`Multiple routes resolve to the same full path: "${t}".`,MJX314:(t,e)=>`Child route alias should start with '/': "${t}" under parent "${e}".`,MJX315:t=>`Route alias resolves to the route's own path: "${t}".`,MJX316:t=>`Multiple routes use the same alias: "${t}".`,MJX401:t=>`Service not registered for token: ${t}`,MJX402:t=>`Async factory used with get() for token ${t}; use getAsync().`,MJX403:()=>"Invalid service descriptor.",MJX404:t=>`Cyclic dependency detected: ${t}`,MJX405:()=>"Only one ApplicationBuilder instance is allowed.",MJX406:t=>`Application.run: host not found for selector: ${t}`,MJX407:t=>`getService: no ServiceProvider found for token '${t}'.`,MJX408:(t,e)=>`getService failed for token '${t}': ${e}`,MJX409:t=>`inject(${t}) was called outside a service construction; call it in a field initializer or constructor of a class the ServiceProvider creates.`,MJX410:(t,e)=>`Multiple sources provided for token '${t}': ${e}. Resolution order is useValue > useFactory > useClass.`,MJX411:t=>`'deps' must be an array for token '${t}'; the invalid deps are ignored.`,MJX413:t=>`Service '${t}' is registered with a function that cannot be constructed. Use { useValue: fn } to provide the function itself or { useFactory: fn } to create the service.`,MJX414:(t,e)=>`FromService failed for token '${t}': ${e}`,MJX501:()=>"Disposable already disposed.",MJX502:()=>"Cannot register a disposable on itself.",MJX503:()=>"Errors were thrown while disposing a store.",MJX504:()=>"A disposable was added to a DisposableStore that is already disposed; the added object will leak.",MJX505:()=>"Cannot dispose a disposable on itself.",MJX507:(t,e,i)=>`[${t}] potential listener LEAK: ${e} listeners already; most frequent stack (${i}):`,MJX601:()=>"Sequence contains no elements.",MJX602:()=>"Circuit is open.",MJX603:()=>"Bulkhead queue is full.",MJX604:()=>"Rate limit exceeded.",MJX605:()=>"Operation timed out.",MJX607:()=>"A history must be created with at least one entry.",MJX608:()=>"Method not implemented.",MJX609:()=>"OperationRunner: the operation threw.",MJX610:()=>"Matching the request path failed.",MJX611:()=>"The devtools panel failed to load."};class y extends Error{code;constructor(t,e,i){super(e,i),this.name="MotifError",this.code=t}}function v(t,...e){return`[motifjs] ${t}: ${g[t](...e)}`}function w(t,...e){return new y(t,v(t,...e))}function b(t,e,...s){i.report(new y(t,v(t,...s),{cause:e}))}function S(t,e,...i){try{const s=t();s&&"function"==typeof s.then&&s.then(void 0,t=>b(e,t,...i))}catch(t){b(e,t,...i)}}function M(t,e,i){p(t,g[t](...e),i)}const C=new class{disposableTracker=null;notifyCreated(t){return this.disposableTracker?.trackDisposable(t),t}notifyDisposed(t){this.disposableTracker?.markAsDisposed(t)}notifyOwner(t,e){this.disposableTracker?.setParent(t,e)}toDisposable(t){let e=!0;const i={dispose:()=>{e&&(e=!1,this.notifyDisposed(i),t())}};return this.notifyCreated(i)}};class k{_items=new Set;_closed=!1;constructor(){C.notifyCreated(this)}get isDisposed(){return this._closed}add(t){if(!t)return t;if(t===this)throw w("MJX502");return C.notifyOwner(t,this),this._closed?M("MJX504",[],(new Error).stack):this._items.add(t),t}delete(t){if(t){if(t===this)throw w("MJX505");this._items.delete(t),t.dispose()}}detach(t){t&&this._items.delete(t)&&C.notifyOwner(t,null)}clear(){if(0===this._items.size)return;const t=[];for(const e of this._items)try{e?.dispose()}catch(e){t.push(e)}if(this._items.clear(),1===t.length)throw t[0];if(t.length>1)throw new y("MJX503",v("MJX503"),{cause:new AggregateError(t)})}dispose(){this._closed||(C.notifyDisposed(this),this._closed=!0,this.clear())}}class A{_disposables=new k;constructor(){C.notifyCreated(this),C.notifyOwner(this._disposables,this)}dispose(){C.notifyDisposed(this);const t=this._disposables;t&&"function"==typeof t.dispose?t.dispose():M("MJX501",[],{disposable:this})}_register(t){if(t===this)throw w("MJX502");return this._disposables.add(t)}}const D=Symbol("");let E=!0,x={enabled:!1,key:""};function T(t){let e=t;for(;e&&e["[__raw__]"];)e=e["[__raw__]"];return e}function O(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function N(t){return"object"==typeof t&&null!==t}const P=new Set(Object.values(Object.getOwnPropertyDescriptors(Symbol)).map(t=>t.value).filter(t=>"symbol"==typeof t));function L(t){return"symbol"==typeof t&&P.has(t)}const X=new Map([["[object Object]",1],["[object Array]",1],["[object Map]",2],["[object Set]",2],["[object WeakMap]",2],["[object WeakSet]",2]]);const I=/^(?:0|[1-9]\d*)$/,R=[];let J=0;function F(t){R[J++]=E,E=t}function H(){F(!1)}function j(){E=!(J>0)||R[--J]}const B=[];class z{component;itemsFn;renderFn;options;propertyName="__list__";dataSource;dataMember;formatString;converter;converterBack;updateMode;_isActive=!1;_effectCleanup;_rendered=[];_identityMap=new WeakMap;container=li("list-container");constructor(t,e,i,s){this.component=t,this.itemsFn=e,this.renderFn=i,this.options=s,this.component.controls.add(this.container)}activate(){this._isActive||(this._isActive=!0,this._setupBinding())}deactivate(){this._isActive&&(this._isActive=!1,this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0),this._disposeAll())}reActivate(){this.deactivate(),this.activate()}_disposeAll(){this._rendered.forEach(t=>{try{t.dispose&&t.dispose()}catch{}}),this._rendered=[],this._identityMap=new WeakMap}_toArray(t){return t?Array.isArray(t)?t:"function"==typeof t?this._toArray(t()):t[Symbol.iterator]?Array.from(t):[]:[]}_getComponentKey(t){try{const e=t.props;if(e&&"function"==typeof e.indexkey)return e.indexkey();if(e&&void 0!==e.indexkey&&null!==e.indexkey)return e.indexkey}catch{}try{const e=t.motif.options?.__key;if(void 0!==e)return e}catch{}}isPreCreated(t){return null!==t.element||null!==t.parent}_render(t,e){return At(()=>{const i=this.renderFn(t,e);return this.processRendered(i,t)})}processRendered(t,e){const i=ti(t);if(!(i instanceof ke))throw w("MJX201");try{i._base.itemRef=e}catch{}try{i.motif.options.__fromList=!0}catch{}return void 0===i.__listAdopted&&(i.__listAdopted=null!==i.parent&&void 0!==i.parent),i}olditems=[];get _indexSensitive(){try{return this.renderFn.length>=2}catch{return!0}}static _isPrimitive(t){return null===t||"object"!=typeof t}_setupBinding(){const t=()=>{const t=this._toArray(this.itemsFn()),e=this.olditems,i=this._rendered;if(this.olditems.length>0){const e=new Set;for(const i of t)e.add(T(i));for(const t of this.olditems){const i=T(t);if(!e.has(i)){const t=this._identityMap.get(i);if(t){this._identityMap.delete(i);for(const e of t)try{e.dispose()}catch{}}}}}const s=[],n=new Set,o=new Map,r=new Set,a=new Map,c=t=>!(!t||t.isDisposed||r.has(t)||t.__listAdopted),l=Math.min(t.length,e.length);for(let s=0;s<l;s++){const n=t[s];if(!z._isPrimitive(n))continue;if(!Object.is(e[s],n))continue;const o=i[s];c(o)&&(a.set(s,o),r.add(o))}let h=null;if(!this._indexSensitive){h=new Map;for(let t=0;t<e.length;t++){const s=e[t];if(!z._isPrimitive(s))continue;const n=i[t];if(!c(n))continue;const o=h.get(s);o?o.push(n):h.set(s,[n])}}const u=new Map;return t.forEach((t,e)=>{let i;if("object"==typeof t&&null!==t){const s=T(t),n=u.get(s)??0;u.set(s,n+1);let o=this._identityMap.get(s);o||(o=[],this._identityMap.set(s,o));const r=o[n];r&&!r.isDisposed?i=r:(i=this._render(t,e),o[n]=i)}else{let s=a.get(e);if(!s&&h){const e=h.get(t);e&&e.length&&(s=e.shift(),r.add(s))}i=s||this._render(t,e)}const c=this._getComponentKey(i);null!=c&&(o.has(c)?M("MJX202",[c,e]):o.set(c,e)),s.push(i),n.add(i)}),u.forEach((t,e)=>{const i=this._identityMap.get(e);i&&i.length>t&&(i.length=t)}),this._rendered.forEach(t=>{if(!n.has(t)&&!t.__listAdopted)try{t.dispose()}catch{}}),this._syncContainer(s),this._rendered=s,this.olditems=t.slice(),t.length};this._effectCleanup=St(()=>t())}_syncContainer(t){const e=this.container.controls,i=e.items;if(0===i.length){for(const i of t)try{e.add(i)}catch{}return}const s=new Map;i.forEach((t,e)=>s.set(t,e));const n=t.map(t=>{const e=s.get(t);return void 0===e?-1:e}),o=new Set(function(t){const e=new Array(t.length).fill(-1),i=[];for(let s=0;s<t.length;s++){const n=t[s];if(-1===n)continue;if(0===i.length||t[i[i.length-1]]<n){e[s]=i.length>0?i[i.length-1]:-1,i.push(s);continue}let o=0,r=i.length-1;for(;o<r;){const e=o+r>>1;t[i[e]]<n?o=e+1:r=e}n<t[i[o]]&&(e[s]=o>0?i[o-1]:-1,i[o]=s)}const s=[];let n=i.length>0?i[i.length-1]:-1;for(;-1!==n;)s.push(n),n=e[n];return s.reverse()}(n));let r=null;for(let s=t.length-1;s>=0;s--){const a=t[s];try{if(-1===n[s])if(r){const t=i.indexOf(r);e.add(t>=0?t:i.length,a)}else e.add(a);else o.has(s)||e.move(a,r)}catch{}r=a}}}class V{Key;value}class W{ItemAdded;ItemAddedBefore;ItemSplice;__list=[];_map=new Set;Dispose(){this.__list=[]}Add(t){this._map.add(t);var e=this.__list.push(t)-1;return null!=this.ItemAdded&&this.ItemAdded(t),e}AddBefore(t){this._map.add(t);var e=this.__list.unshift(t)-1;return null!=this.ItemAddedBefore&&this.ItemAddedBefore(t),e}Insert(t,e){this._map.add(e);var i=this.__list.splice(t,0,e);return null!=this.ItemSplice&&this.ItemSplice(t,e),i}get items(){return this.__list}clear(){return this._map.clear(),this.__list.splice(0),this.__list=[],this.__list}get count(){return this.__list.length}remove(t){return this._map.delete(t),this.__list.splice(this.__list.indexOf(t),1),t=null,[]}indexOf(t){return this.__list.indexOf(t)}FindFromKey(t,e){return this.__list.filter(i=>i[t]===e)}removeIndex(t){var e=this.__list.splice(t,1);return e.forEach(t=>{this._map.delete(t)}),e}has(t){return this._map.has(t)}item(t){return this.__list[t]}forEach(t){this.__list?.forEach(t)}ReverseClone(){return this.__list.reverse()}filter(t){return this.__list.filter(t)}}function $(t){let e=!0;return{dispose(){e&&(e=!1,t())}}}function U(t){return"/"+t.replace(/^\/+|\/+$/g,"")}function q(t){try{if(t.isDisposed)return null;if(t.element.nodeType!==Node.COMMENT_NODE&&t.element.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.element.nodeType!==Node.TEXT_NODE)return t;if(t.parent)return q(t.parent)}catch(t){throw t}return null}class K{threshold;name;_origins=new Map;_quietChecks=0;constructor(t,e){this.threshold=t,this.name=e}check(t){if(this.threshold<=0||t<this.threshold)return;const e=(new Error).stack??"";if(this._origins.set(e,(this._origins.get(e)??0)+1),this._quietChecks--,this._quietChecks<=0){this._quietChecks=this.threshold/2;const[e,i]=this._busiestOrigin();M("MJX507",[this.name,t,i],e)}return()=>{this._origins.set(e,(this._origins.get(e)??0)-1)}}_busiestOrigin(){let t=["",0];for(const e of this._origins)e[1]>t[1]&&(t=e);return t}}class G{__values=new W;Add(t,e){var i=new V;i.Key=t,i.value=e;var s=this.__values.Add(i);return null!=this.OnItemAdded&&this.OnItemAdded(i.Key,i.value),s}has(t){return!!this.filter(e=>e.Key==t)[0]}item(t){return this.filter(e=>e.Key==t)[0]}OnItemAdded;removeIndex(t){return this.__values.removeIndex(t-1)}remove(t){this.__values.filter(e=>e.Key==t).forEach(t=>{this.__values.remove(t)})}clear(){this.__values.clear()}forEach(t){this.__values.forEach(t)}get values(){return this.__values}filter(t){return this.__values.items.filter(t)}find(t,e){return this.__values.items.find(t)}}function Y(){const t={value:void 0,linked:!1};return t.before=t,t.after=t,t}class Q{_ring=Y();_count=0;get size(){return this._count}isEmpty(){return 0===this._count}push(t){return this._link(t,this._ring.before)}unshift(t){return this._link(t,this._ring)}pop(){return this._take(this._ring.before)}shift(){return this._take(this._ring.after)}clear(){for(let t=this._ring.after;t!==this._ring;t=t.after)t.linked=!1;this._ring=Y(),this._count=0}*[Symbol.iterator](){const t=this._ring;for(let e=t.after;e!==t;e=e.after)yield e.value}_link(t,e){const i={value:t,before:e,after:e.after,linked:!0};return e.after.before=i,e.after=i,this._count++,()=>this._unlink(i)}_take(t){if(t===this._ring)return;const e=t.value;return this._unlink(t),e}_unlink(t){t.linked&&(t.linked=!1,t.before.after=t.after,t.after.before=t.before,this._count--)}}function Z(t){return"function"==typeof t?t:()=>t}function tt(t){return"function"==typeof t?t():t}function et(t,e){return t>e?1:t<e?-1:0}class it{source;constructor(t){this.source=Array.isArray(t)?t:Array.from(t)}static from(t){return new it(t)}where(t){return new it(this.source.filter(t))}select(t){return new it(this.source.map(t))}orderBy(t){return new it([...this.source].sort((e,i)=>et(t(e),t(i))))}orderByDescending(t){return new it([...this.source].sort((e,i)=>et(t(i),t(e))))}distinctBy(t){const e=new Set;return new it(this.source.filter(i=>{const s=t(i);return!e.has(s)&&(e.add(s),!0)}))}groupBy(t){const e=new Map;for(const i of this.source){const s=t(i),n=e.get(s);n?n.push(i):e.set(s,[i])}return new it(Array.from(e,([t,e])=>({key:t,items:e})))}first(){if(0===this.source.length)throw w("MJX601");return this.source[0]}firstOrDefault(){return this.source[0]}any(t){return t?this.source.some(t):this.source.length>0}all(t){return this.source.every(t)}aggregate(t,e){return this.source.reduce(e,t)}toArray(){return[...this.source]}[Symbol.iterator](){return this.source[Symbol.iterator]()}}const st=new Set,nt=new Set;function ot(t){1===t||st.has(t)||(c()?(nt.delete(t),st.add(t),M("MJX121",[t,1])):nt.add(t))}var rt;!function(t){t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",t[t.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",t[t.ENTITY_NODE=6]="ENTITY_NODE",t[t.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE",t[t.DOCUMENT_NODE=9]="DOCUMENT_NODE",t[t.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",t[t.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE",t[t.NOTATION_NODE=12]="NOTATION_NODE"}(rt||(rt={}));class at{fn;callback;deps=[];active=!0;running=!1;scheduler;constructor(t,e){this.fn=t,this.callback=e}run(){let t;if(this.active&&!this.running){bt(this),lt.push(this),this.running=!0;try{t=this.fn()}finally{lt.pop(),this.running=!1,this.callback&&this.callback(t)}}}stop(){this.active=!1,bt(this)}}const ct=new WeakMap,lt=[],ht=new Set;let ut,dt=!1,pt=!1,ft=-1;const mt=new WeakMap;function _t(t={}){pt=!!t.enabled,ft="number"==typeof t.threshold?t.threshold:pt?200:-1,ut=pt&&ft>0?new K(ft,t.name??"reactivity-core"):void 0}function gt(t,e){if(!E)return;const i=T(t),s=lt[lt.length-1];if(!s||!s.active)return;let n=ct.get(i);n||ct.set(i,n=new Map);let o=n.get(e);if(o||n.set(e,o=new Set),!o.has(s)&&(o.add(s),s.deps.push([i,e]),pt&&ut&&ft>0))try{const t=ut.check(o.size);if(t){let e=mt.get(o);e||(e=new Map,mt.set(o,e)),e.set(s,t)}}catch{}}function yt(t,e){const i=T(t),s=ct.get(i);if(!s)return;const n=s.get(e);if(!n)return;let o=!1;n.forEach(t=>{t.active&&(t.scheduler?vt(t.scheduler):(ht.add(t),o=!0))}),o&&function(){if(dt)return;dt=!0,Promise.resolve().then(()=>{const t=new Map;try{for(;ht.size>0;){const e=Array.from(ht);ht.clear();for(const i of e){const e=(t.get(i)??0)+1;t.set(i,e),e>wt?e===wt+1&&M("MJX203",[wt],{fn:String(i.fn).slice(0,200)}):vt(()=>i.run())}}}finally{ht.clear(),dt=!1}})}()}function vt(t){try{t()}catch(t){b("MJX208",t)}}const wt=50;function bt(t){for(const[e,i]of t.deps){const s=ct.get(e);if(!s)continue;const n=s.get(i);if(n){n.delete(t);try{const e=mt.get(n),i=e?.get(t);if(i){try{i()}catch{}e.delete(t)}}catch{}0===n.size&&s.delete(i),0===s.size&&ct.delete(e)}}t.deps=[]}function St(t,e){const i=new at(t,e);return vt(()=>i.run()),()=>i.stop()}function Mt(t){if(!t.pushed)return;t.pushed=!1;const e=lt.lastIndexOf(t.effect);e>=0&&lt.splice(e,1)}const Ct={capture:()=>({effect:lt[lt.length-1],pushed:!1}),suspend:(t,e)=>(Mt(t),e),resume:(t,e)=>(t.effect&&t.effect.active&&!t.pushed&&(lt.push(t.effect),t.pushed=!0),e),end(t){Mt(t)}},kt=new at(()=>{});function At(t){lt.push(kt);try{return t()}finally{lt.pop()}}function Dt(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"checkbox"===e||"radio"===e}function Et(t){if(t){if(Dt(t))return!!t.checked;if(function(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"number"===e||"range"===e}(t)){const e=t.value;if(""===e||null==e)return null;const i="number"==typeof t.valueAsNumber?t.valueAsNumber:Number(e);return Number.isFinite(i)?i:null}return t.value}}kt.active=!1;class xt{propertyName;dataSource;dataMember;formatString;converter;converterBack;setter;formatInfo;updateMode="onPropertyChanged";_isActive=!1;_component;_effectCleanup;_memberPath=null;_memberPathSource;constructor(t,e,i,s,n,o){this._component=t,this.propertyName=e,this.dataSource=i,this.dataMember=s,this.formatString=n,this.formatInfo=o,this._memberPath=s?s.split("."):null,this._memberPathSource=s}activate(){this._isActive||(this._isActive=!0,this._setupBinding())}deactivate(){this._isActive&&(this._isActive=!1,this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0))}reActivate(){this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0),this._setupBinding()}functional(t){return"function"==typeof t&&(t=this.functional(t())),t}_setupBinding(){const t=()=>{let t=this.dataSource;if(this.dataMember){this._memberPathSource!==this.dataMember&&(this._memberPath=this.dataMember.split("."),this._memberPathSource=this.dataMember);for(const e of this._memberPath)null!=t&&(t=t[e])}return t=this.functional(t),this.formatString&&null!=t&&(t=this._applyFormat(t,this.formatString)),this.converter&&(t=this.converter(t)),t},e=()=>{const e=t();return this._updateComponentProperty(e),e};this._effectCleanup=St(()=>e())}_updateComponentProperty(t){switch(this.propertyName.toLowerCase()){case"wait":{const e=this._component;if(!e||e.isDisposed)return;const i=!!t;e.isBuilt?e.isWait=!!i:e.isWait=i;break}case"display":{const e=this._component;if(!e||e.isDisposed)return;const i=t;e.isBuilt,e.isWait=!i;break}case"text":case"textcontent":this._component.setText(t);break;case"innerhtml":case"html":this._component.element.innerHTML=t,this._component.motif.trigger("htmlChanged",{value:t});break;case"visible":case"visibility":t?this._component.motif.show():this._component.motif.hide();break;case"style":"object"==typeof t&&this._component.style(t);break;case"model":{const e=this._component.element;if(!e)break;Dt(e)?e.checked=!!t:e.value=null==t?"":t;break}case"when":break;default:this._component.element&&this.propertyName in this._component.element?this._component.element[this.propertyName]=t:this.propertyName in this._component&&(this._component[this.propertyName]=t)}}_applyFormat(t,e){const i=this.formatInfo?.locale,s=this.formatInfo?.currency;if("number"==typeof t){if(e.includes("C")||e.includes("c"))return s?new Intl.NumberFormat(i,{style:"currency",currency:s}).format(t):new Intl.NumberFormat(i,{minimumFractionDigits:2,maximumFractionDigits:2}).format(t);if(e.includes("P")||e.includes("p"))return new Intl.NumberFormat(i,{style:"percent"}).format(t);if(e.includes("N")||e.includes("n")){const s=parseInt(e.match(/\d+/)?.[0]||"2");return new Intl.NumberFormat(i,{minimumFractionDigits:s,maximumFractionDigits:s}).format(t)}}if(t instanceof Date){if(e.includes("d"))return t.toLocaleDateString(i);if(e.includes("t"))return t.toLocaleTimeString(i)}return t?.toString()||""}}class Tt{_items=[];_component;_branchScope=null;constructor(t){this._component=t,this.add=this.add.bind(this),this.remove=this.remove.bind(this),this.clear=this.clear.bind(this),this.activateAll=this.activateAll.bind(this),this.deactivateAll=this.deactivateAll.bind(this),this.reActivateAll=this.reActivateAll.bind(this),this.when=this.when.bind(this),this.text=this.text.bind(this),this.value=this.value.bind(this),this.list=this.list.bind(this),this.loop=this.loop.bind(this),this.method=this.method.bind(this),this.watch=this.watch.bind(this),this.display=this.display.bind(this),this.wait=this.wait.bind(this)}_own(t){this._branchScope?this._branchScope.push(t):this._component.motif.register($(()=>{try{t()}catch{}}))}when(t,e){var i=new ki;this._component.controls.add(i);let s,n=!1;const o=St(t,t=>{n&&(Object.is(s,t)||!s&&!t)||(n=!0,s=t,At(()=>{t?i.navigate(e(t)):i.navigate(li())}))});return this._own(o),null}get items(){return[...this._items]}text(t){this.add("textContent",t)}value(t){this.add("value",t)}add(...t){let e;if(1===t.length&&"object"==typeof t[0]&&"propertyName"in t[0])e=t[0];else{const[i,s,n,o,r]=t;e=new xt(this._component,i,s,n,o,r)}return this._items.push(e),this._component.isBuilt&&e.activate(),e}wait(t){const e=new xt(this._component,"isWait",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}display(t){const e=new xt(this._component,"isWait",()=>!t());return this._items.push(e),this._component.isBuilt&&e.activate(),e}html(t){const e=new xt(this._component,"innerHTML",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}list(t,e,i){const s=new z(this._component,t,e,i);return this._items.push(s),this._component.isBuilt&&s.activate(),s}loop(t,e,i){const s=new z(this._component,t,e,i);return this._items.push(s),this._component.isBuilt&&s.activate(),s}method(t){const e=this._component;let i=null,s=null;const n=(t,i)=>{i?(e.controls.insert(e.controls.items.indexOf(i),t),e.controls.remove(i)):e.controls.add(t)},o=St(t,t=>{if(e.isDisposed)return;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||i&&null==t)return i?void i.setText(t):(i=new ii(fi.createTextNode(t)),n(i,s),void(s=null));s||(s=new ki,n(s,i),i=null),s.navigate(null==t?li():t)});e.motif.register($(()=>{try{o()}catch{}}))}ternary(t,e,i){const s=new ki;return this._component.controls.add(s),this._ternaryCallTop(t,()=>{e(s)},()=>{i(s)}),null}_ternarySchedule(t,e,i,s){let n,o=!0,r=!1,a=[];const c=()=>{const t=a;a=[];for(const e of t)try{e()}catch{}},l=St(t,t=>{if(!o&&Object.is(n,t))return;n=t;const l=()=>{c();const s=this._branchScope;this._branchScope=a;try{t?e():i()}finally{this._branchScope=s}};if(o)return o=!1,void At(l);s(()=>{r||this._component.isDisposed||l()})});this._own(()=>{r=!0,l(),c()})}ternaryCall=(t,e,i)=>{this._ternarySchedule(t,e,i,t=>queueMicrotask(t))};_ternaryCallTop=(t,e,i)=>{this._ternarySchedule(t,e,i,t=>setTimeout(t,0))};watch(t){const e=St(()=>{t()});this._component.motif.register($(()=>{try{e()}catch{}}))}remove(t){const e=this._items.indexOf(t);e>-1&&(this._items.splice(e,1),t.deactivate())}clear(){this._items.forEach(t=>t.deactivate()),this._items=[]}activateAll(){this._items.forEach(t=>{t.activate()})}model(...t){var e="";this._component.element&&(e=this._component.element.tagName);var i="value";switch(e.toLowerCase()){case"input":i="model";break;case"select":case"textarea":i="value";break;case"img":case"audio":case"video":i="src"}let s;if(1===t.length&&"object"==typeof t[0])s=t[0];else if("function"==typeof t[0]&&"function"==typeof t[1])s=new xt(this._component,i,t[0]),s.setter=t[1];else{const[e,n,o,r]=t;s=new xt(this._component,i,e,n,o,r)}const n=e.toLowerCase();if("input"===n||"select"===n||"textarea"===n){const t=()=>{try{const t=this._component.element;if(!t)return;let e=Et(t);const i=s;if("function"==typeof i.converterBack&&(e=i.converterBack(e)),"function"==typeof i.setter)return void i.setter(e);const n=i.dataMember,o=i.dataSource;if(n&&null!=o){const t=n.split(".");let i=o;for(let e=0;e<t.length-1&&null!=i;e++)i=i[t[e]];null!=i&&(i[t[t.length-1]]=e)}else null!=o&&"object"==typeof o&&"value"in o&&(o.value=e)}catch{}};this._component.motif.on("input",t),this._component.motif.on("change",t)}return this._items.push(s),this._component.isBuilt&&s.activate(),s}deactivateAll(){this._items.forEach(t=>t.deactivate()),this._items=[]}reActivateAll(){for(const t of[...this._items])if("function"==typeof t.reActivate)try{t.reActivate()}catch(t){b("MJX208",t)}}switchCase(t,e,i){const s=new ki;var n;this._component.controls.add(s);var o=!1;const r=St(t,t=>{if(n==t)return;n=t;const r=String(t);if(Object.prototype.hasOwnProperty.call(e,r))e[r](s),o=!1;else if(i){if(o)return;o=!0,i(s)}else{if(o)return;o=!0,s.navigate(li())}});return this._component.motif.register($(()=>{try{r()}catch{}})),null}}class Ot{_subscriptions=[];_delivery;_subscribe;_disposed=!1;get event(){return this._subscribe||(this._subscribe=(t,e,i)=>{if(this._disposed)return{dispose(){}};const s={handler:e?t.bind(e):t,active:!0};this._writable().push(s);const n={dispose:()=>this._unsubscribe(s)};return i instanceof k?i.add(n):Array.isArray(i)&&i.push(n),n}),this._subscribe}fire(t){this._resume(),0!==this._subscriptions.length&&(this._delivery={targets:this._subscriptions,value:t,next:0},this._resume())}dispose(){if(!this._disposed){this._disposed=!0;for(const t of this._subscriptions)t.active=!1;this._subscriptions=[],this._delivery=void 0}}_writable(){return this._delivery&&this._delivery.targets===this._subscriptions&&(this._subscriptions=this._subscriptions.slice()),this._subscriptions}_unsubscribe(t){if(!t.active)return;t.active=!1;const e=this._writable(),i=e.indexOf(t);-1!==i&&e.splice(i,1)}_resume(){const t=this._delivery;if(t){for(;t.next<t.targets.length;){const e=t.targets[t.next++];if(e.active)try{e.handler(t.value)}catch(t){i.onUnexpectedError(t)}}this._delivery===t&&(this._delivery=void 0)}}}class Nt{component;_emitters=new Map;_sourceDisposables=new Map;_listenerDisposables=new Map;constructor(t){this.component=t,this.fire=this.fire.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.createEvent=this.createEvent.bind(this),this.getOrCreateEmitter=this.getOrCreateEmitter.bind(this),this.addSource=this.addSource.bind(this),this.clear=this.clear.bind(this)}fire(t,e){try{const i=this._emitters?.get(t.toLowerCase());i&&i.fire(e)}catch{}}on(t,e){try{this.createEvent(t,e)}catch{}}off(t,e){const i=String(t).toLowerCase(),s=this._listenerDisposables.get(i);if(!s)return this;const n=s.get(e);return s.delete(e),n?.forEach(t=>{try{t.dispose()}catch{}}),this}getOrCreateEmitter(t){let e=this._emitters.get(t);return e||(this._emitters.set(t,new Ot),e=this._emitters.get(t)),e}createEvent(t,e){const i=String(t).toLowerCase(),s=i.startsWith("on")?"x:"+i.slice(2):i,n=t=>{let i;return S(()=>(i=e.length<=1?e(t):e(this.component,t),i),"MJX122",s),i},o=this.getOrCreateEmitter(i).event(t=>n(t));let r=this._listenerDisposables.get(i);r||(r=new Map,this._listenerDisposables.set(i,r));const a=r.get(e);return a?a.push(o):r.set(e,[o]),this}addSource(t,e){const i=String(t).toLowerCase(),s=this.getOrCreateEmitter(i),n=t=>t(t=>s.fire(t));let o;try{o=n(e instanceof Ot?e.event:e)}catch{}if(o){let t=this._sourceDisposables.get(i);t||(t=new Set,this._sourceDisposables.set(i,t)),t.add(o),this.component.motif.register(C.toDisposable(()=>{try{o?.dispose()}catch{}try{t?.delete(o)}catch{}}))}return this}clear(t){if(t){const e=t.toLowerCase(),i=this._sourceDisposables.get(e);i?.forEach(t=>{try{t.dispose()}catch{}}),this._sourceDisposables.delete(e);const s=this._emitters.get(e);try{s?.dispose()}catch{}this._emitters.delete(e),this._listenerDisposables.delete(e)}else for(const t of Array.from(this._emitters.keys()))this.clear(t);return this}}const Pt=new Set(["focus","blur","click","pause","submit","reset","scrollTo","scrollBy","select","scrollIntoView","requestFullscreen","exitFullscreen","requestPointerLock","exitPointerLock","play","requestPictureInPicture","exitPictureInPicture","show","showModal","close","showPopover","hidePopover","togglePopover","requestSubmit","checkValidity","reportValidity","showPicker","load","setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Lt={show:"close",showModal:"close",showPopover:"hidePopover"},Xt=new Set(["close","hidePopover","requestSubmit","checkValidity","reportValidity","showPicker","load"]),It=new Set(["setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Rt=new Set(["checked","selected","muted","indeterminate","srcObject"]);class Jt{_parent;_attrMap=new Map;_watchers=new Map;constructor(t){this._parent=t}get attributes(){return Array.from(this._attrMap.entries(),([t,e])=>({name:String(t),value:e}))}add(t){if(null!==t&&"object"==typeof t&&!Array.isArray(t)){const e=t;Reflect.ownKeys(e).forEach(t=>{this.parse(e[t],t)})}return this._parent}remove(t){const e=this._watchers.get(t);if(e){try{e.stop()}catch{}try{e.binding&&this._parent.bindings.remove(e.binding)}catch{}this._watchers.delete(t)}this._attrMap.delete(t);const i=this._getElement();if(i)try{i.removeAttribute(t)}catch{}return this._parent}has(t){return(this._parent.element instanceof HTMLElement||this._parent.element instanceof Element)&&this._parent.element.hasAttribute(t)}get(t){const e=this._getElement();if(e){const i=e.getAttribute(t);if(null!=i)return i}const i=this._attrMap.get(t);return null==i?null:String(i)}parse(t,e){if("function"==typeof t){const i=this._watchers.get(e);if(i){try{i.stop()}catch{}try{i.binding&&this._parent.bindings.remove(i.binding)}catch{}this._watchers.delete(e)}const s=()=>St(()=>{const i=t();this._applyValue(e,i)});let n=s();const o=()=>{try{n()}catch{}},r={propertyName:`__attr:${String(e)}`,dataSource:null,activate(){},deactivate(){o()},reActivate(){o(),n=s()}};try{this._parent.bindings.add(r)}catch{}this._watchers.set(e,{stop:o,binding:r})}else this._applyValue(e,t)}_applyValue(t,e){if(!t)return;const i=this._getElement();try{"function"==typeof e&&"function"==typeof(e=e())&&(e=e())}catch{}if(i&&"string"==typeof t&&Pt.has(t)){const s=t,n=i[s];if("function"==typeof n){const o=(t,e)=>{try{Array.isArray(e)?t.apply(i,e):void 0===e?t.call(i):t.call(i,e)}catch{}},r=t=>{try{queueMicrotask(t)}catch{try{setTimeout(t,0)}catch{}}},a=()=>{this._attrMap.set(t,e)};if("focus"===s){return r(()=>{if(!1===e){const t=i.blur;"function"==typeof t&&o(t)}else!0===e?o(n):("object"==typeof e&&null!=e&&!0!==e||Array.isArray(e),o(n,e))}),void a()}if("blur"===s||"click"===s||"pause"===s||"submit"===s||"reset"===s){return r(()=>{e&&o(n)}),void a()}if("scrollTo"===s||"scrollBy"===s){return r(()=>{(Array.isArray(e)||e&&"object"==typeof e)&&o(n,e)}),void a()}if("select"===s){return r(()=>{if(e)o(n);else{const t=i;if("function"==typeof t.setSelectionRange)try{t.setSelectionRange(0,0)}catch{}}}),void a()}if("scrollIntoView"===s){return r(()=>{!0===e||null==e?o(n):o(n,e)}),void a()}if("requestFullscreen"===s){return r(()=>{if(e)o(n);else try{const t=document;t&&t.fullscreenElement===i&&"function"==typeof t.exitFullscreen&&t.exitFullscreen()}catch{}}),void a()}if("exitFullscreen"===s){return r(()=>{if(e)try{const t=document;t&&"function"==typeof t.exitFullscreen&&t.exitFullscreen()}catch{}}),void a()}if("requestPointerLock"===s){return r(()=>{if(e)o(n);else try{const t=document;t&&"function"==typeof t.exitPointerLock&&t.exitPointerLock()}catch{}}),void a()}if("exitPointerLock"===s){return r(()=>{if(e)try{const t=document;t&&"function"==typeof t.exitPointerLock&&t.exitPointerLock()}catch{}}),void a()}if("play"===s){return r(()=>{if(e)try{const t=n.call(i);t&&"function"==typeof t.then&&t.catch(()=>{})}catch{}else{const t=i.pause;"function"==typeof t&&o(t)}}),void a()}if("requestPictureInPicture"===s){return r(()=>{if(e)try{const t=n.call(i);t&&"function"==typeof t.then&&t.catch(()=>{})}catch{}}),void a()}if("exitPictureInPicture"===s){return r(()=>{if(e)try{const t=document;if(t&&"function"==typeof t.exitPictureInPicture){const e=t.exitPictureInPicture();e&&"function"==typeof e.then&&e.catch(()=>{})}}catch{}}),void a()}if(s in Lt){return r(()=>{if(!1===e){const t=i[Lt[s]];"function"==typeof t&&o(t)}else e&&o(n)}),void a()}if("togglePopover"===s){return r(()=>{if("boolean"==typeof e)try{n.call(i,e)}catch{}else e&&o(n)}),void a()}if(Xt.has(s)){return r(()=>{!0===e?o(n):e&&o(n,e)}),void a()}if(It.has(s)){return r(()=>{null!=e&&!1!==e&&o(n,e)}),void a()}return null==e||!1===e?void this._attrMap.delete(t):void a()}}if("string"==typeof t&&Rt.has(t)){const s=this._parent.element??i;if(s)try{"srcObject"===t?s.srcObject=e??null:s[t]=!!e}catch{}return void(null==e||!1===e?this._attrMap.delete(t):this._attrMap.set(t,e))}if("boolean"==typeof e&&"string"==typeof t&&(t.startsWith("aria-")||t.startsWith("data-"))){if(i)try{i.setAttribute(t,String(e))}catch{}return void this._attrMap.set(t,e)}const s="boolean"==typeof e;if(null==e||!1===e){if(i)try{i.removeAttribute(String(t))}catch{}this._attrMap.delete(t)}else{if("value"===t)try{const t=this._parent.element,i=String(e);t.value!==i&&(t.value=i)}catch{}else if("textContent"===t||"innerText"===t||"innerHTML"===t){if(Re(e))return void this._parent.setText(e);try{this._parent.element[t]=e}catch{}}else if(i)try{s&&!0===e?i.setAttribute(String(t),""):i.setAttribute(String(t),e)}catch{}this._attrMap.set(t,e)}}_getElement(){const t=this._parent?.element;return t instanceof HTMLElement||t instanceof Element?t:null}hasMethodState(t){return!(!this._getElement()||!t)&&!!this.getMethodState(t)}getMethodState(t){const e=this._getElement();if(!e||!t)return!1;switch(String(t)){case"focus":case"blur":try{return(document&&document.activeElement)===e}catch{return!1}case"select":{const t=e;if("number"==typeof t.selectionStart&&"number"==typeof t.selectionEnd)try{return t.selectionEnd-t.selectionStart>0}catch{return!1}return!1}default:return!1}}}class Ft{_parent;constructor(t){this._parent=t}_counts=new Map;_staticSet=new Set;_watchers=new Map;_watcherSeq=0;add(...t){for(const i of t)if("function"==typeof i)this._addReactive(i);else if(Array.isArray(i))this._addStaticFromArray(i);else if(i&&"object"==typeof i)this._addStaticFromObject(i);else{var e=String(i??"").trim();e.split(" ").length>1?this._addStaticFromArray(e.split(" ")):this._addStaticFromString(e)}return this._parent}remove(t){const e=this._getElement();if(Array.isArray(t)){const i=new Set(this._staticSet);for(const e of t)for(const t of this._splitClasses(String(e)))this._staticSet.delete(t);this._applySourceDiff("static",i,new Set(this._staticSet),e)}else if("**"===t){for(const[t,i]of Array.from(this._watchers.entries())){const s=new Set(i.set);this._applySourceDiff(t,s,new Set,e);try{i.binding&&this._parent.bindings.remove(i.binding)}catch{}try{i.stop()}catch{}this._watchers.delete(t)}const t=new Set(this._staticSet);if(this._staticSet.clear(),this._applySourceDiff("static",t,new Set,e),e)try{e.removeAttribute("class")}catch{}this._counts.clear()}else{const i=new Set(this._staticSet);for(const e of this._splitClasses(String(t)))this._staticSet.delete(e);this._applySourceDiff("static",i,new Set(this._staticSet),e)}return this._parent}has(t){const e=this._getElement(),i=String(t??"").trim();return!!i&&!(!e||!e.classList.contains(i))}_getElement(){const t=this._parent?.element;return t instanceof Element?t:null}_splitClasses(t){return(t||"").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}_normalizeToSet(t,e){const i=new Set;if(null==t)return i;if("string"==typeof t)for(const e of this._splitClasses(t))i.add(e);else if(Array.isArray(t)){for(const s of t)if(null!=s)if("string"==typeof s)for(const t of this._splitClasses(s))i.add(t);else if(Array.isArray(s))for(const t of this._normalizeToSet(s))i.add(t);else if("object"==typeof s){const t=s;for(const e of Object.keys(t)){if(t[e])for(const t of this._splitClasses(String(e)))i.add(t)}}else if("boolean"==typeof s){if(e&&s)for(const t of this._splitClasses(String(e)))i.add(t)}else for(const t of this._splitClasses(String(s)))i.add(t)}else if("object"==typeof t){const e=t;for(const t of Object.keys(e)){if(e[t])for(const e of this._splitClasses(String(t)))i.add(e)}}else if("boolean"==typeof t){if(e&&t)for(const t of this._splitClasses(String(e)))i.add(t)}else for(const e of this._splitClasses(String(t)))i.add(e);return i}_applySourceDiff(t,e,i,s){for(const t of e)if(!i.has(t)){const e=(this._counts.get(t)||0)-1;if(e<=0){if(this._counts.delete(t),s)try{s.classList.remove(t)}catch{}}else this._counts.set(t,e)}for(const t of i)if(!e.has(t)){const e=this._counts.get(t)||0,i=e+1;if(this._counts.set(t,i),0===e&&s)try{s.classList.add(t)}catch{}}}_addStaticFromString(t){if(!t)return;const e=this._getElement(),i=new Set(this._staticSet);for(const e of this._splitClasses(t))this._staticSet.add(e);this._applySourceDiff("static",i,new Set(this._staticSet),e)}_addStaticFromArray(t){const e=this._getElement(),i=new Set(this._staticSet);for(const e of t)if(null!=e)if("string"==typeof e)for(const t of this._splitClasses(e))this._staticSet.add(t);else if(Array.isArray(e)){const t=this._normalizeToSet(e);for(const e of t)this._staticSet.add(e)}else if("object"==typeof e){const t=e;for(const e of Object.keys(t)){const i=t[e];if("function"==typeof i){const i=this._splitClasses(String(e));for(const s of i)this._addReactive(t[e],s)}else{const t=this._splitClasses(String(e));if(i)for(const e of t)this._staticSet.add(e);else for(const e of t)this._staticSet.delete(e)}}}else{if("boolean"==typeof e)continue;if("function"==typeof e)this._addReactive(e);else for(const t of this._splitClasses(String(e)))this._staticSet.add(t)}this._applySourceDiff("static",i,new Set(this._staticSet),e)}_addStaticFromObject(t){const e=this._getElement(),i=new Set(this._staticSet);for(const e of Object.keys(t)){const i=t[e],s=this._splitClasses(String(e));if(i)for(const t of s)this._staticSet.add(t);else for(const t of s)this._staticSet.delete(t)}this._applySourceDiff("static",i,new Set(this._staticSet),e)}_addReactive(t,e){const i="fx#"+ ++this._watcherSeq,s={stop:()=>{},binding:void 0,set:new Set},n=this._getElement(),o=()=>St(()=>{let o;try{const i=t();o=this._normalizeToSet(i,e)}catch{o=new Set}const r=new Set(s.set);this._applySourceDiff(i,r,o,n),s.set=o});let r=o();const a=()=>{try{r()}catch{}},c={propertyName:`__class:${i}`,dataSource:null,activate(){},deactivate:()=>{a();const t=this._getElement(),e=new Set(s.set);this._applySourceDiff(i,e,new Set,t),s.set.clear()},reActivate:()=>{a(),r=o()}};try{this._parent.bindings.add(c)}catch{}s.stop=a,s.binding=c,this._watchers.set(i,s)}}const Ht={cancel(){},addEventListener(){},removeEventListener(){},oncancel:null,playState:"finished"};function jt(t){const e=t.substring(0,Math.max(0,t.length-1)).replace(",",".");return 1e3*Number(e)}function Bt(t,e){const i=i=>(t[`${e}-${i}`]||"").split(", "),s=i("delay"),n=i("duration");let o=-1/0;for(let t=0;t<n.length;t++){const e=jt(n[t])+jt(s[t%s.length]);o=Math.max(o,e)}return{kind:e,longest:o,tracks:n.length}}const zt=/(?:^|\W)(?:transform|all)(?:,|$)/;function Vt(t,e){if(!t)return{type:"animation",timeout:0,propCount:0,hasTransform:!1};const i={transition:Bt(t,"transition"),animation:Bt(t,"animation")};let s,n;if("transition"===e||"animation"===e){const t=i[e];s=t.longest>0?t:null,n=s?s.longest:0}else{const{transition:t,animation:e}=i;n=Math.max(t.longest,e.longest),s=n>0?t.longest>e.longest?t:e:null}const o=s?s.kind:null;return{type:o,timeout:n,propCount:s?s.tracks:0,hasTransform:"transition"===o&&zt.test(t.transitionProperty)}}function Wt(t,e,i){if(t.isConnected&&8!==t.nodeType)return Vt(fi.window.getComputedStyle(t),i);const s=fi.createElement("div");s.setAttribute("style","width:0!important;height:0!important;display:none"),fi.body.appendChild(s),s.setAttribute("class",e);try{return Vt(fi.window.getComputedStyle(s),i)}finally{s.remove()}}function $t(t,e,i,s,n=!1){if(!1===e.css)return s(),()=>{};const o=function(t,e,i=!1){const s=t.name||"motif";if("enter"===e){const e={from:t.enterFromClass??`${s}-enter-from`,active:t.enterActiveClass??`${s}-enter-active`,to:t.enterToClass??`${s}-enter-to`};return i?{from:t.appearFromClass??e.from,active:t.appearActiveClass??e.active,to:t.appearToClass??e.to}:e}return{from:t.leaveFromClass??`${s}-leave-from`,active:t.leaveActiveClass??`${s}-leave-active`,to:t.leaveToClass??`${s}-leave-to`}}(e,i,n),r=e=>{e&&e.split(/\s+/).forEach(e=>{if(e)try{t.classList.add(e)}catch{}})},a=e=>{e&&e.split(/\s+/).forEach(e=>{if(e)try{t.classList.remove(e)}catch{}})};let c,l=!1,h=null,u=null;const d=()=>{if(!l){l=!0,(()=>{if(a(o.from),a(o.to),a(o.active),void 0!==c){try{clearTimeout(c)}catch{}c=void 0}if(h&&u){try{t.removeEventListener(h,u)}catch{}u=null}})();try{s()}catch{}}};r(o.from),r(o.active);try{t.offsetHeight}catch{}return(t=>{const e=globalThis.requestAnimationFrame;"function"==typeof e?e(()=>t()):setTimeout(t,16)})(()=>{if(l)return;a(o.from),r(o.to);let s=0,n=1;const p=e.duration;if("number"==typeof p)s=p,h="animation"===e.type?"animationend":"transitionend";else if(p&&"object"==typeof p)s=("enter"===i?p.enter:p.leave)??0,h="animation"===e.type?"animationend":"transitionend";else{const i=function(t,e){return Vt(fi.window.getComputedStyle(t),e)}(t,e.type);s=i.timeout,n=i.propCount||1,h="animation"===i.type?"animationend":"transitionend"}if(!s||s<=0)return void d();let f=0;u=e=>{e&&e.target!==t||++f>=n&&d()};try{t.addEventListener(h,u)}catch{}c=setTimeout(d,s+60)}),d}class Ut{_component;options;constructor(t,e){this._component=t,this.options=e}show(){return this._component._show()}hide(){return this._component._hide()}toggle(){this._component._toggle()}on(t,e,i=!0){return this._component._on(t,e,i)}off(t,e){return this._component._off(t,e)}trigger(t,e){return this._component._trigger(t,e)}addHandler(t,e){this._component._addHandler(t,e)}clear(){return this._component._clear()}register(t){this._component._register(t)}setDisposable(t){this._component._register(C.toDisposable(t))}stopAnimations(){return this._component._stopAnimations()}}const qt=Symbol("SignalTarget"),Kt=Symbol("SignalKey");class Gt{_value;_target;_key;_equals;_disposed=!1;static create(t,e){return new Gt(t,e)}constructor(t,e=Object.is){this._value=t,this._target={[qt]:!0},this._key=Kt,this._equals=e}get value(){return this._disposed||gt(this._target,this._key),this._value}set value(t){this._disposed||this._equals(this._value,t)||(this._value=t,yt(this._target,this._key))}peek(){return this._value}update(t){this.value=t(this._value)}mutate(t){this._disposed||(t(this._value),yt(this._target,this._key))}notify(){this._disposed||yt(this._target,this._key)}asReadonly(){const t=this;return{get value(){return t.value},peek:()=>t.peek(),valueOf:()=>t.valueOf(),toString:()=>t.toString()}}dispose(){this._disposed=!0}valueOf(){return this.value}toString(){return String(this.value)}}class Yt{_value;_dirty=!0;_computing=!1;_target;_key;_getter;_cleanup;constructor(t){this._getter=t,this._target={[qt]:!0},this._key=Kt,this._cleanup=St(()=>{if(!this._computing){this._computing=!0;try{const t=this._getter(),e=this._dirty||!Object.is(this._value,t);this._value=t,this._dirty=!1,e&&yt(this._target,this._key)}finally{this._computing=!1}}})}get value(){if(gt(this._target,this._key),this._dirty){this._computing=!0,H();try{this._value=this._getter(),this._dirty=!1}finally{j(),this._computing=!1}}return this._value}peek(){if(this._dirty){H();try{this._value=this._getter(),this._dirty=!1}finally{j()}}return this._value}dispose(){this._cleanup&&(this._cleanup(),this._cleanup=void 0)}valueOf(){return this.value}toString(){return String(this.value)}}class Qt{_value;_dirty=!0;_disposed=!1;_target;_key;_getter;_runner;constructor(t){this._getter=t,this._target={[qt]:!0},this._key=Kt,this._runner=function(t,e){const i=new at(t);return i.scheduler=e,{run:()=>{vt(()=>i.run())},stop:()=>i.stop()}}(()=>{this._value=this._getter()},()=>{this._dirty||this._disposed||(this._dirty=!0,yt(this._target,this._key))})}get value(){return this._disposed||gt(this._target,this._key),this._refresh(),this._value}peek(){return this._refresh(),this._value}get isDirty(){return this._dirty}_refresh(){this._dirty&&(this._disposed?this._value=At(this._getter):this._runner.run(),this._dirty=!1)}dispose(){this._disposed||(this._disposed=!0,this._runner.stop())}valueOf(){return this.value}toString(){return String(this.value)}}let Zt=null,te=null,ee=null,ie=null,se=null;const ne=new WeakMap,oe=new WeakMap,re=new WeakMap,ae=new WeakMap,ce=new WeakMap;function le(t,e){const i=Zt;Zt=t;try{return e()}finally{Zt=i}}function he(t,e,i){const s=te,n=ee;te=t,ee=e;try{return i()}finally{te=s,ee=n}}function ue(t){let e=t;for(;e;){const t=re.get(e);if(t)return t.scope;const i=ae.get(e);if(i&&i._pending)return i;e=e.parent}return null}function de(t){if(!Zt)throw w("MJX409",function(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}(t));return Zt(t)}function pe(t){ie&&ie._pending&&ae.set(t,ie)}function fe(t){const e=se;if(!e)return;if(re.get(t)?.live)return;const i=ue(t)??e._currentScope();re.set(t,{scope:i,live:!0}),i._livePins++}function me(t){const e=re.get(t);e?e.live&&(e.live=!1,e.scope._releaseLivePin()):se&&ne.has(t)&&re.set(t,{scope:ue(t)??se._currentScope(),live:!1})}class _e{services;parent;root;scopeName;kind;singletonCache;scopedCache=new Map;transientSet=new Set;_autoDisposeTransients=!1;pendingSingleton;pendingScoped=new Map;_navigation;_ownerlessSlot={owner:null,ownerless:!0};_navigationDisposed=!1;_livePins=0;_pending=!1;constructor(t,e,i){this.services=t,this.parent=e,this.root=i??this,this.kind=this.root===this?"root":"user",this.singletonCache=this.root===this?new Map:this.root.singletonCache,this.pendingSingleton=this.root===this?new Map:this.root.pendingSingleton}createScope(t){const e=new _e(this.services,this,this.root);return e.scopeName=t??this.scopeName,e._autoDisposeTransients=this._autoDisposeTransients,e}enableAutoDisposeTransients(t=!0){return this._autoDisposeTransients=t,this}get(t){const e=this.services.getDescriptor(t);if(!e)throw w("MJX401",this.describeToken(t));return this.resolveDescriptorSync(e,[t])}async getAsync(t){const e=this.services.getDescriptor(t);if(!e)throw w("MJX401",this.describeToken(t));return await this.resolveDescriptorAsync(e,[t])}_getFor(t,e){let i=ne.get(t);return i||(i={owner:t},ne.set(t,i)),he(i,ee,()=>this.get(e))}getAllServices(){return this.services}_beginNavigation(){const t=this.root,e=t._navigation??={current:t,version:new Gt(0),scopes:new Set};se=t;const i=new _e(this.services,t,t);return i.kind="navigation",i.scopeName="navigation",i._pending=!0,i._autoDisposeTransients=t._autoDisposeTransients,e.scopes.add(i),i}_commitNavigation(t){const e=this.root._navigation;if(!e||e.current===t)return;t._pending=!1;const i=e.current;e.current=t,this._touch(),i!==this.root&&i._releaseIfUnused()}_abandonNavigation(t){t._pending=!1,t._releaseIfUnused()}_currentScope(){return this.root._navigation?.current??this.root}_touch(){const t=this.root._navigation;t&&(t.version.value=t.version.peek()+1)}_releaseLivePin(){this._livePins--,this._releaseIfUnused()}_releaseIfUnused(){const t=this.root._navigation;"navigation"!==this.kind||this._navigationDisposed||this._livePins>0||t&&t.current===this||(this._navigationDisposed=!0,t?.scopes.delete(this),this.dispose().catch(()=>{}))}_scopeFor(t){const e=this._navigation;if(e&&e.version.value,!t.ownerless){const e=ue(t.owner);if(e)return e;if(ie&&ie.root===this)return ie}return e?e.current:this}_handle(t,e){const i=te??this._ownerlessSlot;let s=oe.get(i);s||oe.set(i,s=new Map);let n=s.get(t.token);return n||(n=this._createHandle(t,i),s.set(t.token,n)),this._scopeFor(i)._scopedInstanceSync(t,e),n}async _handleAsync(t,e){const i=te??this._ownerlessSlot;return await this._scopeFor(i)._scopedInstanceAsync(t,e),he(i,null,()=>this._handle(t,e))}_createHandle(t,e){const i=this,s=()=>i._scopeFor(e)._scopedInstanceSync(t,[t.token]);return new Proxy(Object.create(null),{get(t,e){const i=s(),n=Reflect.get(i,e,i);return"function"==typeof n?function(t,e,i){let s=ce.get(t);s||ce.set(t,s=new Map);const n=s.get(e);if(n&&n.fn===i)return n.bound;const o=i.bind(t);return s.set(e,{fn:i,bound:o}),o}(i,e,n):n},set(t,e,i){const n=s();return Reflect.set(n,e,i,n)},has:(t,e)=>e in s(),getPrototypeOf:()=>Object.getPrototypeOf(s())})}_isSystemScope(){return"user"!==this.kind}_scopedInstanceSync(t,e){if(this.scopedCache.has(t.token))return this.scopedCache.get(t.token);const i=he(null,this,()=>this.instantiateSync(t,e));return this.scopedCache.set(t.token,i),i}async _scopedInstanceAsync(t,e){if(this.scopedCache.has(t.token))return this.scopedCache.get(t.token);if(this.pendingScoped.has(t.token))return await this.pendingScoped.get(t.token);const i=(async()=>{const i=await this.instantiateAsyncIn(null,this,t,e);return this.scopedCache.set(t.token,i),this.pendingScoped.delete(t.token),i})();return this.pendingScoped.set(t.token,i),await i}resolveDescriptorSync(t,e){switch(this.checkCycle(t.token,e),t.lifetime){case"singleton":{if(this.singletonCache.has(t.token))return this.singletonCache.get(t.token);const i=he(null,null,()=>this.instantiateSync(t,e));return this.singletonCache.set(t.token,i),i}case"scoped":return this._isSystemScope()&&ee!==this?this.root._handle(t,e):this._scopedInstanceSync(t,e);default:{const i=this.instantiateSync(t,e);return this._autoDisposeTransients&&this.parent&&this.transientSet.add(i),i}}}async resolveDescriptorAsync(t,e){switch(this.checkCycle(t.token,e),t.lifetime){case"singleton":{if(this.singletonCache.has(t.token))return this.singletonCache.get(t.token);if(this.pendingSingleton.has(t.token))return await this.pendingSingleton.get(t.token);const i=(async()=>{const i=await this.instantiateAsyncIn(null,null,t,e);return this.singletonCache.set(t.token,i),this.pendingSingleton.delete(t.token),i})();return this.pendingSingleton.set(t.token,i),await i}case"scoped":return this._isSystemScope()&&ee!==this?await this.root._handleAsync(t,e):await this._scopedInstanceAsync(t,e);default:{const i=await this.instantiateAsync(t,e);return this._autoDisposeTransients&&this.parent&&this.transientSet.add(i),i}}}construct(t){if(te)return t();const e={owner:null},i=he(e,ee,t);return!i||"object"!=typeof i&&"function"!=typeof i||"function"==typeof i.then||(pe(i),e.owner=i,ne.has(i)||ne.set(i,e)),i}instantiateSync(t,e){if(void 0!==t.useValue)return t.useValue;if(t.useFactory)return this.construct(()=>{const i=this.resolveDepsSync(t,e),s=le(this.injectionResolver(e),()=>t.useFactory(...i,this));if(s&&"function"==typeof s.then){throw w("MJX402",this.describeTokenWithSource(t.token))}return s});if(t.useClass)return this.construct(()=>{const i=this.resolveDepsSync(t,e);return le(this.injectionResolver(e),()=>new t.useClass(...i))});throw w("MJX403")}async instantiateAsyncIn(t,e,i,s){return await he(t,e,()=>this.instantiateAsync(i,s))}async instantiateAsync(t,e){if(void 0!==t.useValue)return t.useValue;const i=te,s=ee;if(t.useFactory){const n=await this.resolveDepsAsyncIn(i,s,t,e);return await he(i,s,()=>this.construct(()=>le(this.injectionResolver(e),()=>t.useFactory(...n,this))))}if(t.useClass){const n=await this.resolveDepsAsyncIn(i,s,t,e);return he(i,s,()=>this.construct(()=>le(this.injectionResolver(e),()=>new t.useClass(...n))))}throw w("MJX403")}async dispose(){const t=new Set,e=async e=>{if(e&&!t.has(e)){t.add(e);try{"function"==typeof e.dispose&&await e.dispose()}catch{}try{"function"==typeof e.close&&await e.close()}catch{}try{const t=e[Symbol.dispose];"function"==typeof t&&await t.call(e)}catch{}try{const t=e[Symbol.asyncDispose];"function"==typeof t&&await t.call(e)}catch{}}};if(this.root===this){const t=this._navigation;if(t){const e=[...t.scopes];t.scopes.clear(),t.current=this,se===this&&(se=null),this._navigation=void 0;for(const t of e)t._navigationDisposed=!0,await t.dispose()}for(const t of this.singletonCache.values())await e(t);this.singletonCache.clear(),this.pendingSingleton.clear()}for(const t of this.scopedCache.values())await e(t);"navigation"!==this.kind&&this.scopedCache.clear(),this.pendingScoped.clear();for(const t of this.transientSet.values())await e(t);this.transientSet.clear()}resolveDepsSync(t,e){const i=this.getDeps(t);return i&&0!==i.length?i.map(t=>this.resolveTokenSync(t,e)):[]}async resolveDepsAsyncIn(t,e,i,s){const n=this.getDeps(i);if(!n||0===n.length)return[];const o=[];for(const i of n)o.push(await he(t,e,()=>this.resolveTokenAsync(i,s)));return o}injectionResolver(t){return e=>this.resolveTokenSync(e,t)}getDeps(t){if(Array.isArray(t.deps))return t.deps;const e=t.useClass??t.useFactory;if(e){if(Array.isArray(e.inject))return e.inject;if(Array.isArray(e.dependencies))return e.dependencies}}resolveTokenSync(t,e){const i=this.services.getDescriptor(t);if(!i)throw w("MJX401",this.describeToken(t));const s=e.concat(t);return this.resolveDescriptorSync(i,s)}async resolveTokenAsync(t,e){const i=this.services.getDescriptor(t);if(!i)throw w("MJX401",this.describeToken(t));const s=e.concat(t);return await this.resolveDescriptorAsync(i,s)}checkCycle(t,e){const i=e.indexOf(t);if(-1!==i&&i!==e.length-1){throw w("MJX404",e.slice(i).concat([t]).map(t=>this.describeTokenWithSource(t)).join(" -> "))}}describeToken=t=>"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t);describeTokenWithSource(t){const e=this.describeToken(t),i=this.services.getDescriptor(t);if(!i)return e;return`${e}[${i.useClass?"useClass":i.useFactory?"useFactory":void 0!==i.useValue?"useValue":"unknown"}]`}}function ge(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function ye(t){const e=t?.motif?.options?.transition;if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function ve(t){const e=t?.motif.options?.transition;return!!(t?.motif.options?.transitionIn||e&&(e.classes||e.name&&e.name.length>0))}const we={callInitializeComponent(t){const e=t,i={cancel:!1};if(t&&!t.isDisposed){if("function"==typeof t.initializeComponent&&S(()=>t.initializeComponent(e,i),"MJX122","initializeComponent"),Array.isArray(t._base._initializeComponentHandlers)&&t._base._initializeComponentHandlers.length)for(const s of t._base._initializeComponentHandlers)S(()=>s(e,i),"MJX122","initializeComponent");if("function"==typeof t.oninitializeComponent&&S(()=>t.oninitializeComponent(e,i),"MJX122","oninitializeComponent"),Array.isArray(t._base._onInitializeComponentHandlers)&&t._base._onInitializeComponentHandlers.length)for(const s of t._base._onInitializeComponentHandlers)S(()=>s(e,i),"MJX122","oninitializeComponent")}},async callDisposing(t){we.backgroundCallback(()=>{if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onDisposing&&S(()=>t.onDisposing(e,i),"MJX122","onDisposing"),Array.isArray(t._base._onDisposingHandlers))for(const s of t._base._onDisposingHandlers)S(()=>s(e,i),"MJX122","onDisposing");t.ondisposing&&S(()=>t.ondisposing(e,i),"MJX122","ondisposing"),t._base.emiters.fire("ondisposing",i)})},callActivated(t){if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onActivated&&S(()=>t.onActivated(e,i),"MJX122","onActivated"),Array.isArray(t._base._onActivatedHandlers))for(const s of t._base._onActivatedHandlers)S(()=>s(e,i),"MJX122","onActivated");t._base.emiters.fire("onactivated",i)},callDeactivated(t){if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onDeactivated&&S(()=>t.onDeactivated(e,i),"MJX122","onDeactivated"),Array.isArray(t._base._onDeactivatedHandlers))for(const s of t._base._onDeactivatedHandlers)S(()=>s(e,i),"MJX122","onDeactivated");t._base.emiters.fire("ondeactivated",i)},deactivateTree(t,e=!0){if(t&&!t.isDisposed&&t.isBuilt&&t._base&&!t._base._inactive&&(t._base._inactive=!0,we.callDeactivated(t),e))for(const e of t.controls.items.slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&we.deactivateTree(e,!0)},activateTree(t,e=!0){if(t&&!t.isDisposed&&t._base&&t._base._inactive&&(t._base._inactive=!1,we.callActivated(t),e))for(const e of t.controls.items.slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&we.activateTree(e,!0)},async callDisposed(t){if(!t||!t._base||t._base._disposedFired)return;t._base._disposedFired=!0;const e=t,i={cancel:!1};if(t.onDisposed&&S(()=>t.onDisposed(e,i),"MJX122","onDisposed"),Array.isArray(t._base._onDisposedHandlers))for(const s of t._base._onDisposedHandlers)S(()=>s(e,i),"MJX122","onDisposed");t.ondisposed&&S(()=>t.ondisposed(e,i),"MJX122","ondisposed"),t._base.emiters.fire("ondisposed",i);try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:disposed",{id:t.id,type:t.constructor?.name})}catch{}},async callBuilt(t){we.backgroundCallback(()=>{if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onBuilt&&S(()=>t.onBuilt(e,i),"MJX122","onBuilt"),Array.isArray(t._base._onBuiltHandlers))for(const s of t._base._onBuiltHandlers)S(()=>s(e,i),"MJX122","onBuilt");t.onbuilt&&S(()=>t.onbuilt(e,i),"MJX122","onbuilt"),t._base.emiters.fire("onbuilt",i);try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:mounted",{id:t.id,type:t.constructor?.name})}catch{}})},scheduleMounted(t){if(!t||t.isDisposed||t._base._mountedScheduled)return;if(!("function"==typeof t.onMounted||Array.isArray(t._base._onMountedHandlers)&&t._base._onMountedHandlers.length>0||"function"==typeof t.onmounted))return;t._base._mountedScheduled=!0;const e=t.element;if(!e||"number"!=typeof e.nodeType)return;const i=Ge(e,()=>{t.isDisposed||we.callMounted(t)});i&&t._register(C.toDisposable(i))},callMounted(t){if(!t||t.isDisposed||t._base._mountedFired)return;t._base._mountedFired=!0;const e=t,i={cancel:!1};if(t.onMounted&&S(()=>t.onMounted(e,i),"MJX122","onMounted"),Array.isArray(t._base._onMountedHandlers))for(const s of t._base._onMountedHandlers)S(()=>s(e,i),"MJX122","onMounted");t.onmounted&&S(()=>t.onmounted(e,i),"MJX122","onmounted"),t._base.emiters.fire("onmounted",i)},async callBuilding(t){we.backgroundCallback(()=>{if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onBuilding&&S(()=>t.onBuilding(e,i),"MJX122","onBuilding"),Array.isArray(t._base._onBuildingHandlers))for(const s of t._base._onBuildingHandlers)S(()=>s(e,i),"MJX122","onBuilding");t._base.emiters.fire("onbuilding",i)})},async callConfig(t){we.backgroundCallback(()=>{if(!t||t.isDisposed||t.isConfigured)return;t.isConfigured=!0,t.motif.options._preconfig&&o(()=>t.motif.options._preconfig(t),"Component._preconfig");const e=t,i={cancel:!1};if(t.onConfig&&S(()=>t.onConfig(e,i),"MJX122","onConfig"),Array.isArray(t._base._onConfigHandlers))for(const s of t._base._onConfigHandlers)S(()=>s(e,i),"MJX122","onConfig");t._base.emiters.fire("onconfig",i)})},async callConfigured(t){t.motif.options&&t.motif.options._postconfigdone||(t?._base?._configDeferred&&!t.isConfigured&&we.callConfig(t),t.motif.options._postconfigdone=!0,we.backgroundCallback(()=>{if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onConfigured&&S(()=>t.onConfigured(e,i),"MJX122","onConfigured"),Array.isArray(t._base._onConfiguredHandlers))for(const s of t._base._onConfiguredHandlers)S(()=>s(e,i),"MJX122","onConfigured");t._base.emiters.fire("onconfigured",i)}))},async callOnInitialized(t){we.backgroundCallback(()=>{if(!t||t.isDisposed)return;t.isInitialized=!0;const e=t,i={cancel:!1};if(t.onInitialized&&S(()=>t.onInitialized(e,i),"MJX122","onInitialized"),Array.isArray(t._base._onInitializedHandlers))for(const s of t._base._onInitializedHandlers)S(()=>s(e,i),"MJX122","onInitialized");t._base.emiters.fire("oninitialized",i)})},async callOnInitializing(t){we.backgroundCallback(()=>{if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onInitializing&&S(()=>t.onInitializing(e,i),"MJX122","onInitializing"),Array.isArray(t._base._onInitializingHandlers))for(const s of t._base._onInitializingHandlers)S(()=>s(e,i),"MJX122","onInitializing");t._base.emiters.fire("oninitializing",i)})},async callVisibilityChanged(t){we.backgroundCallback(()=>{if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onVisibilityChanged&&S(()=>t.onVisibilityChanged(e,i),"MJX122","onVisibilityChanged"),Array.isArray(t._base._onVisibilityChangedHandlers))for(const s of t._base._onVisibilityChangedHandlers)S(()=>s(e,i),"MJX122","onVisibilityChanged");t._base.emiters.fire("onvisibilitychanged",i)})},findFragmentContent(t){const e=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;t.element.nodeType==Node.COMMENT_NODE&&0==e?.childNodes.length&&t.controls.length>0&&(t.motif.options.cache?.appendChild(t.element),t.controls.forEach(e=>{t.motif.options.cache?.appendChild(e.element)}),t.motif.options.cache?.appendChild(t.motif.options.closeFragment))},backgroundCallback(t){t()},internalBuild(t){if(this.isDisposed||t?.isDisposed)return;if(we.callConfigured(t),t._base._activatePreBindings(),t.isWait)return;const e=t.isBuilt;if(!this.isBuilt)return;if(t.isWait)return;const i=t._base._enterSeq;if(t.isBuilt){if(t.parent!=this){t.parent?.controls.detach(t),t.parent=this;const e=t.__pendingLeave;if(e)return void e.promise.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||we.internalBuild.call(this,t)})}}else t.build();t.parent=this;const s=this.controls.items.indexOf(t),n=Ke(this);var o=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;e&&t.element.nodeType==Node.COMMENT_NODE&&0==o?.childNodes.length&&t.controls.length>0&&(o=we.getContent.call(t));let r=null;const a=n?.element,c=t=>{if(!t||!t.isBuilt)return null;const e=t.isVisible?t.element:t.motif.options?.placeholder??null;return e&&a&&e.parentNode===a?e:null},l=this.controls.items;for(let t=s+1;t<l.length;t++){const e=c(l[t]);if(e){r=e;break}}if(!r)if(this.element.nodeType===Node.COMMENT_NODE){const t=this.motif.options.closeFragment;r=t&&a&&t.parentNode===a?t:null}else r=null;if(!t.isVisible){const e=t.motif.options?.hideStrategy??"auto",i=!(!t.motif.options?.__fromList&&void 0===t.motif.options?.indexkey&&void 0===t.motif.options?.__key);if("placeholder"!==("placeholder"===e?"placeholder":"detach"===e||i?"detach":"placeholder"))return;t.motif.options.placeholder||(t.motif.options.placeholder=fi.createComment("h")),o=t.motif.options.placeholder}const h=n?.element;if(o&&h&&(o===h||o.contains(h)))M("MJX104",[]);else if(r)try{n?.element.insertBefore(o,r)}catch{n?.element.appendChild(o)}else n?.element.appendChild(o);if(t.isVisible){!(!e&&t._base._enterSeq!==i)&&ve(t)&&t.motif.options.transition.enterTransition(()=>{}),e&&we.activateTree(t)}},getContent(){return this.isDisposed||!this.element?null:this.element.nodeType==Node.COMMENT_NODE?(this.motif.options.cache?.appendChild(this.element),this.controls.forEach(t=>{this.motif.options.cache?.appendChild(we.getContent.call(t))}),this.motif.options.cache?.appendChild(this.motif.options.closeFragment),this.motif.options.cache):this.element},routerClassing(t){try{const e=t.to,i=t.path;if(this.isDisposed)return;const s=this.context?.router;if(!s)return;const n=s.uri.startsWith("/")?s.uri:"/"+s.uri,o=i??"",r=function(t,e){try{const i=t=>t.trim().split(/[?#]/)[0].replace(/\\/g,"/").replace(/\/{2,}/g,"/");return i(t)===i(e)}catch(t){return b("MJX610",t),!1}}(n,o),a=r||function(t,e){const i=U(t),s=U(e);return i===s||i.startsWith(s+"/")}(n,o);if(t.activeClass&&("all"===e||"active"===e)){t.activeClass.split(" ").filter(t=>t.trim().length).forEach(t=>this.element.classList.toggle(t,a))}if(!a||"all"!==e&&"active"!==e?"all"!==e&&"active"!==e||t.offActive?.():t.onActive?.(),t.exactClass&&("all"===e||"exact"===e)){t.exactClass.split(" ").filter(t=>t.trim().length).forEach(t=>this.element.classList.toggle(t,r))}!r||"all"!==e&&"exact"!==e?"all"!==e&&"exact"!==e||t.offExact?.():t.onExact?.()}catch(t){}}},be=new WeakMap,Se=new Set(["building","built","initializing","initialized","disposing","disposed","config","configured","visibilitychanged","activated","deactivated"]),Me=Symbol("motif.rawApplication"),Ce=new Set(["on","onRouterChanged"]);class ke extends A{motif=new Ut(this,{transition:{transitionInfo:()=>({in:Wt(this.element,`${this.motif.options.transition.name}-enter ${this.motif.options.transition.name}-enter-start`),out:Wt(this.element,`${this.motif.options.transition.name}-leave ${this.motif.options.transition.name}-leave-start`)}),name:"",classes:void 0,activeCssCancel:null,activeCssPhase:null,cssProps:()=>{const t=this.motif.options.transition;return t.classes?{name:t.classes.name||t.name||"",...t.classes}:t.name&&t.name.length>0?{name:t.name}:null},skipNextLeave:!1,_suppressEnter:!1,_markedDirection:!1,in:t=>{this.motif.options.transitionIn=t},out:t=>{this.motif.options.transitionOut=t},enterTransition:t=>{const e=this.motif.options.transition,i=!this._base._enterPlayed;if(this._base._enterPlayed=!0,this._base._enterSeq=(this._base._enterSeq??0)+1,e._suppressEnter)return t&&t(),Ht;const s={};this._base._enterRun=s;const n=()=>{this._base?._enterRun===s&&(this._base._enterRun=null,ye(this)),t&&t()};return this.motif.options.transitionIn?e.run(this.motif.options.transitionIn.keyframes,this.motif.options.transitionIn.options,n):e._runCss("enter",n,i)},leaveTransition:t=>this.motif.options.transitionOut?this.motif.options.transition.run(this.motif.options.transitionOut.keyframes,this.motif.options.transitionOut.options,t):this.motif.options.transition._runCss("leave",t),_runCss:(t,e,i=!1)=>{const s=this.motif.options.transition;if("enter"===t&&"leave"===s.activeCssPhase)return e&&e(),Ht;const n=s.cssProps(),o=this.element;if(n&&o&&1===o.nodeType&&o.classList){try{s.activeCssCancel?.()}catch{}const r=$t(o,n,t,()=>{this.motif.options?.transition&&(this.motif.options.transition.activeCssCancel=null,this.motif.options.transition.activeCssPhase=null),e&&e()},i);return s.activeCssCancel=r,s.activeCssPhase=t,Ht}return e&&e(),Ht},activeAnimations:[],run:(t,e,i)=>{this.motif.stopAnimations();const s=this.element;if(s.animate){var n=s.animate(t,e);this.motif.options.transition.activeAnimations.push(n);let o=!1;const r=()=>{if(!o){o=!0;try{this?.motif.options?.transition?.activeAnimations&&(this.motif.options.transition.activeAnimations=this.motif.options.transition.activeAnimations.filter(t=>t!==n))}catch{}}};return n.addEventListener("finish",()=>{i&&i(),r()}),n.oncancel=()=>{r()},n}{i&&i();const t=globalThis;if("function"==typeof t.Animation)try{return new t.Animation}catch{}return Ht}}},set enableRouterClassing(t){try{var e=this.getInstance();const i=e.context.onRouterChanged(()=>{we.routerClassing.call(e,t)});e.motif.register(C.toDisposable(()=>{i()})),we.routerClassing.call(e,t)}catch(t){b("MJX105",t)}},getInstance:()=>this,get display(){return this.getInstance().isVisible},set display(t){t?this.getInstance().motif.show():this.getInstance().motif.hide()},hasEvent:t=>{const e=this._eventHandlers?.has(t);return!!e}});element;props;isBuilt=!1;isInitialized=!1;isDisposed=!1;isConfigured=!1;isPainting=!1;isPainted=!1;isVisible=!0;controls=new yi(this);_eventHandlers;_isWait=!1;class=new Ft(this);attr=new Jt(this);bindings=new Tt(this);_styleFx;useModel(t){return Zi(t)}_computeHideStrategy(){const t=this.motif.options?.hideStrategy??"auto";return"placeholder"===t?"placeholder":"detach"===t||this.motif.options?.__fromList||void 0!==this.motif.options?.indexkey||void 0!==this.motif.options?.__key?"detach":"placeholder"}_isInDom(){try{if(!this.element)return!1;const t=this.element;return t.nodeType,Node.COMMENT_NODE,!!t.parentNode}catch{return!1}}set isWait(t){this._isWait=t,this.isBuilt?t?this.motif.hide():this.motif.show():!1===t&&this.parent&&this.parent.isBuilt&&we.internalBuild.call(this.parent,this)}get isWait(){return this._isWait}constructor(t,e={}){if(super(),pe(this),this.onElementCreating?this.element=this.onElementCreating.call(this):this.element=e?.onElementCreating?e.onElementCreating.call(this):t,e)for(const t of Ee(this,Te(e,this)))S(()=>t(this),"MJX122","ref");if(e&&Pe(e,this),He(e?.options,this),this.props=e,e){const t=new.target;t===ke||Object.getPrototypeOf(t)===ke?Be(e,this):Ue(e,this)}we.callOnInitializing(this),this.controls.onAdd=t=>{this.motif.trigger("controladded",{control:t}),this.isWait||this.parent?.isWait||we.internalBuild.call(this,t)},this.controls.onAddBeforeBuild=t=>{this.motif.trigger("controladded",{control:t})},this.controls.onRemove=t=>{this.motif.trigger("controlremoved",{control:t})},we.callOnInitialized(this);const i=new.target;i===ke||Object.getPrototypeOf(i)===ke?we.callConfig(this):this._base._configDeferred=!0}childs;_base={prebinding_Activated:!1,_offAll:()=>{if(this._eventHandlers){for(const[t,e]of this._eventHandlers){const i=t.split(":")[0],s=i.startsWith("on")?i.slice(2).toLowerCase():i.toLowerCase();for(const t of e){if(!t||!t.wrapped)continue;if(!1===t.domEvent)continue;const e=!0===t.capture;try{this.element.removeEventListener(s,t.wrapped,e)}catch{}try{void 0===t.capture&&this.element.removeEventListener(s,t.wrapped,!e)}catch{}}}this._eventHandlers.clear(),this._eventHandlers=void 0}},_deactivateBindings:()=>{try{this.bindings?.deactivateAll()}catch{}},_activateBindings:()=>{try{this.bindings?.activateAll()}catch{}},_reactivateBindings:()=>{try{this.bindings?.reActivateAll()}catch{}},_activatePreBindings:()=>{this._base.prebinding_Activated||(this.bindings.items.filter(t=>"isWait"==t.propertyName||"display"==t.propertyName).forEach(t=>{t.activate()}),this._base.prebinding_Activated=!0)},_detachDomWithAnimation:()=>{const t=this.element;if(!t)return;try{if(!0===this.motif.options.transition.skipNextLeave||!0===this?._forceInstantDetach){this?.motif.options?.transition&&(this.motif.options.transition.skipNextLeave=!1),this._forceInstantDetach=!1;return void(()=>{const e=t.parentNode;if(t.nodeType===Node.COMMENT_NODE){const i=t,s=this.motif.options?.closeFragment||null;if(!e)return;if(s){let t=i;for(;t;){const i=t.nextSibling;try{e.removeChild(t)}catch{}if(t===s)break;t=i}}else try{e.removeChild(i)}catch{}}else if(e)try{e.removeChild(t)}catch{}const i=this.motif.options?.placeholder;if(i&&i.parentNode)try{i.parentNode.removeChild(i)}catch{}})()}}catch{}const e=()=>{if(t.nodeType===Node.COMMENT_NODE){const e=t,i=this.motif.options?.closeFragment||null,s=e.parentNode;if(!s)return;if(i){let t=e;for(;t;){const e=t.nextSibling;try{s.removeChild(t)}catch{}if(t===i)break;t=e}}else try{s.removeChild(e)}catch{}return}const e=t.parentNode;if(e){try{e.removeChild(t)}catch{}return}const i=this.motif.options?.placeholder;if(i&&i.parentNode)try{i.parentNode.removeChild(i)}catch{}};try{this.motif.options.transition.leaveTransition(()=>{e()})}catch{e()}},_detachDomWithAnimationAsync:async()=>{const t=this.element;if(!t)return Promise.resolve();try{if(!0===this.motif.options.transition.skipNextLeave||!0===this?._forceInstantDetach){this.motif.options.transition&&(this.motif.options.transition.skipNextLeave=!1),this._forceInstantDetach=!1;return(()=>{if(t.nodeType===Node.COMMENT_NODE){const e=t,i=this.motif.options?.closeFragment||null,s=e.parentNode;if(!s)return;if(i){let t=e;for(;t;){const e=t.nextSibling;try{s.removeChild(t)}catch{}if(t===i)break;t=e}}else try{s.removeChild(e)}catch{}}else{const e=t.parentNode;if(e)try{e.removeChild(t)}catch{}}const e=this.motif.options?.placeholder;if(e&&e.parentNode)try{e.parentNode.removeChild(e)}catch{}})(),Promise.resolve()}}catch{}const e=()=>{if(t.nodeType===Node.COMMENT_NODE){const e=t,i=this.motif.options?.closeFragment||null,s=e.parentNode;if(!s)return;if(i){let t=e;for(;t;){const e=t.nextSibling;try{s.removeChild(t)}catch{}if(t===i)break;t=e}}else try{s.removeChild(e)}catch{}return}const e=t.parentNode;if(e){try{e.removeChild(t)}catch{}return}const i=this.motif.options?.placeholder;if(i&&i.parentNode)try{i.parentNode.removeChild(i)}catch{}};return new Promise(t=>{try{this.motif.options.transition.leaveTransition(()=>{e(),t()})}catch{e(),t()}})},_disposeShallow:()=>{if(!this.isDisposed){we.callDisposing.call(this,this);try{this._base._offAll()}catch{}if(this.motif.stopAnimations(),this._base._deactivateBindings(),this.controls?.items?.length)for(const t of this.controls.items)try{t._base._disposeShallow()}catch{}we.callDisposed.call(this,this),s(()=>{this._base.emiters.clear()},"disposeShallow.emiters"),this.isDisposed=!0,super.dispose()}},_deepCleanup:()=>{try{this.parent=null}catch{}try{this._eventHandlers?.clear()}catch{}this._eventHandlers=void 0;try{this.class?._counts?.clear()}catch{}try{this.class?._watchers?.clear()}catch{}try{this.attr?._attrMap?.clear()}catch{}try{this.attr?._watchers?.clear()}catch{}try{this.motif.options&&(this.motif.options.cache=void 0,this.motif.options.closeFragment=void 0,this.motif.options.placeholder=void 0)}catch{}try{this.element=null}catch{}try{this.props=void 0}catch{}try{this.childs=void 0}catch{}try{this.class=void 0}catch{}try{this.attr=void 0}catch{}try{this.parent=null}catch{}try{this.motif.options=void 0}catch{}Object.entries(this).forEach(([t,e])=>{if("motif"!==t)try{this[t]=null,delete this[t]}catch{}}),this.isDisposed=!0},emiters:new Nt(this)};parent=null;_scopedContext;get context(){const t=this.parent?.context,e=t?.[Me]??t??Gs.main;return e?(this._scopedContext?.[Me]!==e&&(this._scopedContext=function(t,e){const i=new Map;return new Proxy(t,{get(t,s){if(s===Me)return t;const n=Reflect.get(t,s,t);if("function"!=typeof n)return n;const o=i.get(s);if(o&&o.fn===n)return o.bound;const r=Ce.has(s)?(...i)=>e._trackContextSubscription(n.apply(t,i)):n.bind(t);return i.set(s,{fn:n,bound:r}),r},set:(t,e,i)=>Reflect.set(t,e,i,t)})}(e,this)),this._scopedContext):e}_trackContextSubscription(t){if("function"!=typeof t)return t;if(this.isDisposed)return t(),t;const e=this._register(C.toDisposable(t));return()=>{this._disposables.detach(e),t()}}build(t=!0){if(we.callConfigured(this),this._base._activatePreBindings(),this.isDisposed||!this.element||this.isWait)return;if(this.isBuilt||this.isWait)return;we.callBuilding(this);var e=this.element;t&&(e=fi.createDocumentFragment());const i="string"!=typeof this.element&&this.element.nodeType===Node.COMMENT_NODE;if(i&&(this.motif.options.cache=fi.createDocumentFragment(),this.element.textContent="[",this.motif.options.cache.appendChild(this.element)),this.isBuilt)return;if(we.callInitializeComponent(this),this.view){const t=this.view();this.controls.add(t)}const s="SELECT"===this.element?.nodeName?this.bindings.items.filter(t=>"value"===t.propertyName):[];if(s.length)try{this.bindings.items.filter(t=>!s.includes(t)).forEach(t=>t.activate())}catch{}else this._base._activateBindings();for(const s of this.controls.items.filter(t=>!t.isWait))if(s.parent=this,s.build(!1),!s.isWait){var n=i?this.motif.options.cache:this.element;t?s.motif.options.cache?e.appendChild(s.motif.options.cache):e.appendChild(s.element):s.motif.options.cache?n.appendChild(s.motif.options.cache):n.appendChild(s.element),s._base?._inactive&&s.isVisible&&we.activateTree(s)}if(ve(this)){const t=this.element;if(t&&t.isConnected)this.motif.options.transition.enterTransition(()=>{});else{const t=this._base._enterSeq;queueMicrotask(()=>{!this.isDisposed&&this.isVisible&&this.motif.options?.transition&&this._base._enterSeq===t&&this.motif.options.transition.enterTransition(()=>{})})}}else ye(this);if(t)try{(n=i?this.motif.options.cache:this.element).nodeType===Node.TEXT_NODE?n.appendData(e.textContent):n.appendChild?n.appendChild(e):n.append(e)}catch(t){}if(s.length)try{s.forEach(t=>t.activate())}catch{}i&&(this.motif.options.closeFragment=fi.createComment("]"),this.motif.options.cache.appendChild(this.motif.options.closeFragment),this.element.nodeType===Node.COMMENT_NODE&&this.motif.options.closeFragment&&be.set(this.element,this.motif.options.closeFragment)),this.isBuilt=!0,we.callBuilt(this),we.scheduleMounted(this)}setState(){this.controls.forEach(t=>{t.setState()}),this._base._reactivateBindings()}reState(){this._base._reactivateBindings(),this.controls.forEach(t=>{t.reState()})}setText(t){!this.isDisposed&&this.element&&(Re(t)?function(t,e){if(Je.has(t))return;Je.add(t),M("MJX204",[],{value:Array.isArray(e)?`ComponentBase[${e.length}]`:"ComponentBase"})}(this,t):this.element&&(this.element.textContent=t))}style(t){if(this.isDisposed)return this;const e=this.element?.style;if(!e)return this;if("function"==typeof t){this._stopStyleEffect();let e=[],i=!1;const s=()=>St(()=>{const s=t();if(this.isDisposed)return;const n=this.element?.style;if(n)if("string"==typeof s)n.cssText=s,e=[],i=!0;else if(s&&"object"==typeof s){i&&(n.cssText="",i=!1);for(const t of e)if(!(t in s))try{n[t]=""}catch{}Object.assign(n,s),e=Object.keys(s)}else{i&&(n.cssText="",i=!1);for(const t of e)try{n[t]=""}catch{}e=[]}});let n=s();const o=()=>{try{n()}catch{}},r={propertyName:"__style",dataSource:null,activate(){},reActivate(){o(),n=s()},deactivate(){o()}};try{this.bindings.add(r)}catch{}return this._styleFx={stop:o,binding:r},this}return"string"==typeof t?e.cssText=t:t&&"object"==typeof t&&Object.assign(e,t),this}_stopStyleEffect(){const t=this._styleFx;if(t){this._styleFx=void 0;try{t.stop()}catch{}try{this.bindings.remove(t.binding)}catch{}}}_addHandler(t,e){this.motif.on(t,e)}async _show(){if(this.isDisposed||!this.element)return;if(this.isVisible)return;this.motif.options?.transition?.activeAnimations?.length&&s(async()=>{await Promise.all(this.motif.options.transition.activeAnimations.map(t=>t.finished?.catch(()=>{})))},"show.waitForLeaveAnimations");if("detach"===this._computeHideStrategy()){we.callVisibilityChanged(this);const t=!this._isInDom()&&this.parent&&this.parent.isBuilt&&!this.isWait;return this.isVisible=!0,void(t&&we.internalBuild.call(this.parent,this))}{const e=this.motif.options.placeholder?.parentElement,i=Ke(this.parent)?.element;if(this.motif.options.placeholder&&e&&e!==i)return M("MJX106",[]),this.isVisible=!0,void(this.parent?.isBuilt&&we.internalBuild.call(this.parent,this));if(ve(this)&&this.motif.options.transition.enterTransition(()=>{}),we.callVisibilityChanged(this),this.element.nodeType===Node.COMMENT_NODE)return this.controls.forEach(t=>{t.motif.show()}),this.isVisible=!0,void we.activateTree(this,!1);var t=this.motif.options.placeholder?.parentElement;t&&(t.replaceChild(this.element,this.motif.options.placeholder),this.isVisible=!0,we.activateTree(this))}}async _hide(){if(this.isDisposed||!this.element)return;if(!this.isVisible)return;if("detach"===this._computeHideStrategy())return we.callVisibilityChanged(this),await this._base._detachDomWithAnimationAsync(),this.isVisible=!1,void we.deactivateTree(this);{const t=this.motif.options.transition,e=!0===t.skipNextLeave;e&&(t.skipNextLeave=!1);const i=()=>{if(we.callVisibilityChanged(this),this.element.nodeType===Node.COMMENT_NODE)return this.controls.forEach(t=>{e&&t.isVisible&&t.element&&!t.isDisposed&&t.motif.options?.transition&&(t.motif.options.transition.skipNextLeave=!0),t.motif.hide()}),this.isVisible=!1,void we.deactivateTree(this,!1);var t=this.element.parentElement;t&&(this.motif.options.placeholder||(this.motif.options.placeholder=fi.createComment("h")),t.replaceChild(this.motif.options.placeholder,this.element)),this.isVisible=!1,we.deactivateTree(this)};return e?void i():t.leaveTransition(i).finished}}_toggle(){!this.isDisposed&&this.element&&(this.isVisible?this.motif.hide():this.motif.show())}async _on(t,e,i=!0){if(this.isDisposed||!this.element)return this;const s=String(t);if(s.startsWith("x:")){const t=s.slice(2).toLowerCase();if("mounted"===t){let t;const i=Ge(this.element,()=>{if(t&&(this._base._mountedSubs?.get(e)?.delete(t),this._disposables.detach(t)),this.isDisposed)return;const i={cancel:!1};S(()=>e.length<=1?e(i):e(this,i),"MJX122","x:mounted")});if(i){t=this._register(C.toDisposable(i));const s=this._base._mountedSubs??=new Map;let n=s.get(e);n||(n=new Set,s.set(e,n)),n.add(t)}return this}if(Se.has(t))return this._base.emiters.on("on"+t,e),this}const[n,...o]=s.split(":"),r=n.startsWith("on")?n.slice(2).toLowerCase():n.toLowerCase(),a={};o.includes("once")&&(a.once=!0),o.includes("passive")&&(a.passive=!0),o.includes("capture")&&(a.capture=!0);const c=t=>{if(o.includes("self")&&t.target!==this.element)return;if(o.includes("trusted")&&!t.isTrusted)return;let i;try{e&&e.length<=1?i=e(t):e&&(i=e(this,t))}catch(t){b("MJX123",t,r)}i&&"function"==typeof i.then&&i.then(void 0,t=>b("MJX123",t,r));const s=()=>{"function"==typeof t?.preventDefault&&t.preventDefault()},n=()=>{"function"==typeof t?.stopPropagation&&t.stopPropagation()};o.includes("prevent")&&s(),o.includes("stop")&&n(),(!1===i||i&&!0===i.cancel)&&(s(),n())};i&&this.element.addEventListener(r,c,a),this._eventHandlers??=new Map;const l=s.toLowerCase(),h=this._eventHandlers.get(l)??new Set;return h.add({original:e,wrapped:c,capture:!!a.capture,domEvent:!!i,type:r}),this._eventHandlers.set(l,h),this._register(C.toDisposable(()=>{this.motif.off(t,e)})),this}async _trigger(t,e){if(this.isDisposed||!this.element)return this;const i=String(t).toLowerCase();return s(()=>{var t=this._eventHandlers?.get(i);t&&t.forEach(t=>{try{t.wrapped(e)}catch{}})},"trigger"),this}async _off(t,e){if(this.isDisposed||!this.element)return this;const i=String(t).toLowerCase();if(i.startsWith("x:")){const t=i.slice(2);if("mounted"===t){const t=this._base._mountedSubs?.get(e);if(t){this._base._mountedSubs.delete(e);for(const e of t)this._disposables.delete(e)}return this}return Se.has(t)&&this._base.emiters.off("on"+t,e),this}const n=i.split(":")[0],o=n.startsWith("on")?n.slice(2).toLowerCase():n.toLowerCase();if(!this._eventHandlers)return this;const r=this._eventHandlers.get(i);if(!r)return this;for(const t of Array.from(r))if(t.original===e){if(!1!==t.domEvent){const e=!0===t.capture;s(()=>{this.element.removeEventListener(o,t.wrapped,e)},"off.removeEventListener"),s(()=>{void 0===t.capture&&this.element.removeEventListener(o,t.wrapped,!e)},"off.removeEventListener.fallback")}r.delete(t);break}return 0===r.size&&this._eventHandlers.delete(i),this}_disposing;dispose(t={deep:!0}){return this.isDisposed?Promise.resolve():(this._disposing||me(this),this._disposing??=this._disposeCore(t))}async _disposeCore(t){t?.skipLeaveTransition&&(this.motif.options.transition.skipNextLeave=!0),s(()=>{we.callDisposing.call(this,this)},"dispose.callDisposing"),this._base._offAll(),this._base._deactivateBindings(),s(()=>{this.parent?.controls?.silentDetach?.(this,!0)},"dispose.silentDetach"),this.motif.options.transition.skipNextLeave&&await this.motif.stopAnimations(),await this._base._detachDomWithAnimationAsync(),"TransportTo"!==this.constructor.name&&await async function(t){const e=Ae(t);return await Promise.all(e.map(async e=>{e.motif.options.transition.skipNextLeave=t.motif.options.transition.skipNextLeave;for(const t of e.controls.items)t.motif.options.transition.skipNextLeave=e.motif.options.transition.skipNextLeave,t.dispose({skipLeaveTransition:!0}),t.isDisposed=!0;await e.dispose()}))}(this),await n(async()=>{if(this.isDisposed)return;const e=Array.from(this.controls.items);e.length&&await Promise.all(e.map(async e=>{try{await e.disposeAsync({deep:t?.deep})}catch(t){b("MJX107",t)}}))},"dispose.disposeAsync"),this.isDisposed||(this.isDisposed=!0,super.dispose(),this.element=null,s(()=>{we.callDisposed.call(this,this)},"dispose.callDisposed"),s(()=>{this._base.emiters.clear()},"dispose.emiters"),this._base._offAll(),this._base._deepCleanup())}disposeAsync(t={deep:!0}){return this.isDisposed?Promise.resolve():(this._disposing||me(this),this._disposing??=this._disposeAsyncCore(t))}async _disposeAsyncCore(t){s(()=>{we.callDisposing.call(this,this)},"disposeAsync.callDisposing"),this._base._offAll(),this._base._deactivateBindings(),s(()=>{this.parent?.controls?.silentDetach?.(this,!0)},"disposeAsync.silentDetach"),await this.motif.stopAnimations(),await this._base._detachDomWithAnimationAsync(),await n(async()=>{if(this.isDisposed)return;const e=Array.from(this.controls.items);e.length&&await Promise.all(e.map(e=>n(async()=>{await e.disposeAsync({deep:t?.deep})},"disposeAsync.disposeAsyncChildren.handler")))},"disposeAsync.disposeAsyncChildren"),this.isDisposed=!0,super.dispose(),this.controls.items=[],s(()=>{we.callDisposed.call(this,this)},"disposeAsync.callDisposed"),s(()=>{this._base.emiters.clear()},"disposeAsync.emiters"),t?.deep&&this._base._deepCleanup()}async _clear(){1!=this.isDisposed&&(this.motif.options&&this.motif.options.disableDisposal||await this.controls.clearAsync())}using(t,e,i){t.then(t=>{this&&!this.isDisposed&&e&&e(t)},t=>{this&&!this.isDisposed&&i&&i(t)})}doWork(t){return Promise.resolve(t).then(t=>this&&!this.isDisposed?t:w("MJX108"))}siblings={all:()=>this.parent?.controls.items,next:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items[t+1]},prev:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items[t-1]},nextAll:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items.slice(t+1)},prevAll:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items.slice(0,t)}};get serviceProvider(){let t=this;for(;t;){const e=t.provider;if(e)return e;t=t.parent}try{return Gs.main?.provider??null}catch{return null}}getService(t){try{const e=this.serviceProvider;if(e)return e._getFor(this,t);M("MJX407",[ge(t)],{token:t})}catch(e){M("MJX408",[ge(t),String(e?.message??e)],{token:t,error:e})}return null}$(t){return this.isDisposed||!this.element?{fromDom:()=>null,fromComponent:()=>[]}:{fromDom:()=>{var e,i=Ke(this)?.element;return(e=i||document)?e.querySelectorAll(t):null},fromComponent:()=>{const e=Ke(this),i=[],s=e=>{const n=e.element;if(n&&n.nodeType===Node.ELEMENT_NODE){const s=n.matches||n.msMatchesSelector||n.webkitMatchesSelector;if("function"==typeof s)try{s.call(n,t)&&i.push(e)}catch{}}if(e.controls&&e.controls.items&&e.controls.items.length)for(const t of e.controls.items)s(t)};return s(e??this),i}}}async _stopAnimations(){try{this.motif.options?.transition?.activeCssCancel?.()}catch{}try{if(this.motif.options?.transition?.activeAnimations?.length)try{await Promise.all(this.motif.options.transition.activeAnimations.map(t=>t.finished?.catch(()=>{})))}catch{}}catch(t){}this.isDisposed||(this.motif.options.transition.activeAnimations=[])}}function Ae(t,e=[]){return!t||t.isDisposed||("TransportTo"===t.constructor.name&&e.push(t),t.controls&&t.controls.items&&t.controls.items.forEach(t=>Ae(t,e))),e}const De=new WeakMap;function Ee(t,e){const i=(Array.isArray(e)?e:[e]).filter(t=>"function"==typeof t);if(0===i.length)return i;let s=De.get(t);s||(s=new Set,De.set(t,s));const n=[];for(const t of i)s.has(t)||(s.add(t),n.push(t));return n}const xe=t=>"function"==typeof t||Array.isArray(t);function Te(t,e){const i=[];if(!t||"object"!=typeof t)return i;Object.prototype.hasOwnProperty.call(t,"ref")&&(xe(t.ref)?(i.push(t.ref),delete t.ref):e&&t.ref&&"object"==typeof t.ref&&(t.ref=e));const s=t.runover;if(s&&"object"==typeof s&&Object.prototype.hasOwnProperty.call(s,"ref"))if(xe(s.ref)){i.push(s.ref);const e={...s};delete e.ref,t.runover=e}else e&&s.ref&&"object"==typeof s.ref&&(s.ref=e);return[].concat(...i)}const Oe={initializecomponent:"_initializeComponentHandlers",oninitializecomponent:"_onInitializeComponentHandlers",onbuilding:"_onBuildingHandlers",onbuilt:"_onBuiltHandlers",onmounted:"_onMountedHandlers",oninitializing:"_onInitializingHandlers",oninitialized:"_onInitializedHandlers",onconfig:"_onConfigHandlers",onconfigured:"_onConfiguredHandlers",onvisibilitychanged:"_onVisibilityChangedHandlers",onactivated:"_onActivatedHandlers",ondeactivated:"_onDeactivatedHandlers",ondisposing:"_onDisposingHandlers",ondisposed:"_onDisposedHandlers"};function Ne(t,e,i){const s=Object.prototype.hasOwnProperty.call(Oe,e)?Oe[e]:void 0;if(!s)return!1;const n=Array.isArray(i)?i:[i];if(0===n.length||!n.every(t=>"function"==typeof t))return!1;t._base[s]??=[];const o=t._base[s];for(const t of n)o.includes(t)||o.push(t);return!0}function Pe(t,e){t&&(e.motif.options.props||(e.motif.options.props={}),Object.assign(e.motif.options.props,t),Object.keys(t).forEach(i=>{if("initializeComponent"==i||"oninitializeComponent"==i||i.startsWith("on")){if(Ne(e,i.toLowerCase(),t[i]))return void delete t[i]}else if("childs"==i){const s=[].concat(...t[i]);e.childs=s,delete t[i]}else if("transition"===i)Ie(t[i],e),delete t[i];else if(qe.hasOwnProperty(i.toLowerCase())||qe.hasOwnProperty("on"+i.toLowerCase())){var s;s=i.toLowerCase().startsWith("on")||"initializecomponent"===i.toLowerCase()?i:"on"+i,e[s]=t[i],delete t[i]}else if(i.startsWith("on"))e.motif.on(i,t[i]);else if(i.startsWith("x-")){var n=i.replace("x-","on");if("x-wait"==i.toLowerCase())e.bindings.wait(t[i]);else if("x-display"==i.toLowerCase())e.bindings.display(t[i]);else if(Ne(e,n.toLowerCase(),t[i]))return void delete t[i];delete t[i]}else i.startsWith("runover")?(Pe(t[i],e),delete t[i]):i.startsWith("preconfig")&&(e.motif.options._preconfig=t[i],delete t[i])}))}const Le=new WeakMap;function Xe(t,e,i){const s=t.motif.options.transition;"string"==typeof e&&e.length>0?(s.name=e,i&&(s.classes=void 0)):e&&"object"==typeof e?("string"==typeof e.name&&e.name.length>0&&(s.name=e.name),s.classes=e):i&&(s.name="",s.classes=void 0)}function Ie(t,e){e&&!e.isDisposed&&null!=t&&Le.get(e)!==t&&(Le.set(e,t),"function"!=typeof t?Xe(e,t,!1):e.bindings.watch(()=>{const i=t();e.isDisposed||Xe(e,i,!0)}))}function Re(t){return t instanceof ke||Array.isArray(t)&&t.length>0&&t.every(t=>t instanceof ke)}const Je=new WeakSet;const Fe=["hideStrategy","disableDisposal"];function He(t,e){if(t&&"object"==typeof t&&e&&!e.isDisposed)for(const i of Fe)void 0!==t[i]&&(e.motif.options[i]=t[i])}const je=new Set(["ref","key","indexkey","inject","options","props","settings","isSvg","childs","initializeComponent","runover","transition","preconfig","nodes","onElementCreating"]);function Be(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const i={},s=Ve(e);for(const n of Object.keys(t)){if(je.has(n))continue;if(n.startsWith("x-")||n.startsWith("x:")||n.startsWith("__"))continue;const o=t[n];void 0!==o&&(/^on/i.test(n)?"function"==typeof o&&e.motif.on(n,o):"function"==typeof o&&o.length>0||(s.set(n,o),"class"===n||"className"===n?e.class.add(o&&"object"==typeof o&&!Array.isArray(o)?[o]:o):"style"===n?e.style(o):"value"===n||"checked"===n||"selected"===n?e.bindings.add(n,o):i[n]=o))}Object.keys(i).length>0&&e.attr.add(i)}const ze=new WeakMap;function Ve(t){let e=ze.get(t);return e||(e=new Map,ze.set(t,e)),e}const We=new Set(["class","className","style","id","tabindex","role"]);function $e(t){return We.has(t)||t.startsWith("aria-")||t.startsWith("data-")}function Ue(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const i=Ve(e),s={};for(const e of Object.keys(t)){if(!$e(e))continue;const n=t[e];null!=n&&("function"==typeof n&&n.length>0||i.has(e)&&Object.is(i.get(e),n)||(s[e]=n))}Object.keys(s).length>0&&Be(s,e)}const qe={oninitializecomponent:(t,e)=>{},initializecomponent:(t,e)=>{},onconfigured:(t,e)=>{},onconfig:(t,e)=>{},onbuilding:(t,e)=>{},onbuilt:(t,e)=>{},onmounted:(t,e)=>{},oninitializing:(t,e)=>{},oninitialized:(t,e)=>{},ondisposing:(t,e)=>{},ondisposed:(t,e)=>{},onvisibilitychanged:(t,e)=>{},ondeactivated:(t,e)=>{},onactivated:(t,e)=>{}};function Ke(t){return s(()=>!t||t.isDisposed?null:t.element.nodeType!==Node.COMMENT_NODE&&t.element.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.element.nodeType!==Node.TEXT_NODE?t:t.parent?Ke(t.parent):null,"findAppendableComponent",null)}function Ge(t,e){if(document.contains(t))return e(),null;let i=!1;const s=new MutationObserver(()=>{i||document.contains(t)&&(i=!0,s.disconnect(),e())});return s.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{if(!i){i=!0;try{s.disconnect()}catch{}}}}function Ye(t){!function(t){const e=re.get(t);e&&(re.delete(t),e.live&&e.scope._releaseLivePin(),se?._touch())}(t),we.activateTree(t)}function Qe(t){fe(t),we.deactivateTree(t)}const Ze=100;function ti(t,e){let i=t,s=0;for(;"function"==typeof i;){if(i.prototype instanceof ke)return new i(e);if(++s>Ze)return b("MJX112",void 0,Ze),i;i=i(e)}return i}const ei="http://www.w3.org/2000/svg";class ii extends ke{static elementTag;static elementNamespace;constructor(){const t=new.target;var e,i,s=arguments;if(1===s.length?e=s[0]:2===s.length&&(e=s[0],i=s[1]),e instanceof Function&&(e=ti(e,i)),Array.isArray(e)){super(hi(),{});var n=Object.create(i||{});for(const t in e){const i=e[t];this.controls.add(new ii(i,n))}}else if("string"==typeof e&&e.trim().length>0)if(i||(i={}),i?.options&&i.options.isSvg||i?.__isSvgElement){const t=fi.createElementNS("http://www.w3.org/2000/svg",e,i);i.isSvg=!0,super(t,i)}else{super(fi.createElement(e,i),i)}else if(e instanceof Node)super(e,i);else{if(e instanceof ke)return e;{const s=e&&"object"==typeof e?e:i,n=function(t){try{const e=t?.elementTag;if("string"==typeof e){const t=e.trim();if(t)return t}}catch{}}(t);if(n){super(function(t,e,i){const s="string"==typeof e?.elementNamespace&&e.elementNamespace?e.elementNamespace:void 0;return s===ei||!0===i?.options?.isSvg||!0===i?.__isSvgElement?(i&&"object"==typeof i&&(i.isSvg=!0),fi.createElementNS(s||ei,t,i)):fi.createElement(t,i)}(n,t,s),s??{})}else super(hi(),s??{});const o=this.childs;if(Array.isArray(o)&&o.length)for(const t of o)t&&this.controls.add(t)}}}}function si(t){return e=>{var i=li({...e});return i.controls.add(t(e)),i}}function ni(t,e){if(t instanceof ke)for(const i of Ee(t,e))S(()=>i(t),"MJX122","ref");return t}function oi(t,e){const i=t._base?.[e];return Array.isArray(i)?i.length:0}function ri(t,e,i,s){const n=t._base?.[e];if(Array.isArray(n))for(let e=i;e<n.length;e++){if(t.isDisposed)return;const i=n[e];S(()=>i(t,{cancel:!1}),"MJX122",s)}}function ai(t,e){if("string"==typeof t){if("text"===t&&e&&e.__childExpr){const t=function(t){if("function"!=typeof t)return;let e;try{e=At(t)}catch{return}return e instanceof ke||Array.isArray(e)&&e.length>0&&e.every(t=>t instanceof ke)?e:void 0}(e.__childExpr);if(void 0!==t)return t}return new ii(t,e)}if(t instanceof ke||t instanceof ii)return t;if("function"==typeof t){const i=t.prototype instanceof ke?[]:Te(e),s=ti(t,e);return"object"==typeof s&&null!==s&&"el"in s?ni(ci(s,e),i):function(t,e,i){if(!e||"object"!=typeof e)return t;if(!(t instanceof ke))return t;ni(t,i.concat(Te(e))),Ue(e,t),He(e.options,t),Object.prototype.hasOwnProperty.call(e,"transition")&&Ie(e.transition,t);const s=e.runover;if(!s||"object"!=typeof s)return t;const n=t._base?._onConfigHandlers,r=Array.isArray(n)?n.length:0,a=oi(t,"_onInitializingHandlers"),c=oi(t,"_onInitializedHandlers");if(Pe(s,t),ri(t,"_onInitializingHandlers",a,"onInitializing"),ri(t,"_onInitializedHandlers",c,"onInitialized"),t.isConfigured){const e=t.motif.options?._preconfig;"function"==typeof e&&o(()=>e(t),"motifComponent.preconfig");const i=t._base?._onConfigHandlers;if(Array.isArray(i))for(let e=r;e<i.length;e++){const s=i[e];S(()=>s(t,{cancel:!1}),"MJX122","onConfig")}}return t}(s,e,i)}return"object"==typeof t&&null!==t&&"el"in t?ci(t,e):new ii(t,e)}function ci(t,e){const i=ai(t.el,e);return Object.getOwnPropertyNames(t).forEach(e=>{"el"!==e&&"ctor"!==e&&(i[e]=t[e])}),"function"==typeof t.ctor&&S(()=>t.ctor.call(i,e),"MJX122","ctor"),i}function li(t){return new ui(t)}function hi(){return fi.createComment("")}class ui extends ii{constructor(t,e){super(hi(),arguments.length<=1?t:e)}initializeComponent(t){const e=this.childs;if(Array.isArray(e)&&e.length)for(const t of e)t&&this.controls.add(t);o(()=>{const t=this.motif.options?.props?.nodes;if(Array.isArray(t)&&t.length)for(const e of t)e&&this.controls.add(e)},"Fragment.initializeComponent.props.nodes")}}const di=globalThis;function pi(){return di&&di.motifDom?di.motifDom.window.document:di.document}const fi={get window(){return di&&di.window?di.window:di&&di?di.motifDom.window:di},_created:new Map,document:pi(),createElement(t,e){const i=pi();if(!i)throw w("MJX101",t);if("text"===t)return i.createTextNode("");if(!this._created.has(t)){const s=i.createElement(t,e);this._created.set(t,s)}return this._created.get(t).cloneNode(!1)},createDocumentFragment(){try{var t=pi();if(t)return t.createDocumentFragment()}catch(t){i.reportSuppressed("dom.createDocumentFragment",t)}},createComment(t){try{return pi()?.createComment(t)}catch(t){i.reportSuppressed("dom.createComment",t)}},createTextNode(t){try{return pi()?.createTextNode(t)}catch(t){i.reportSuppressed("dom.createTextNode",t)}},querySelectorAll(t){try{return pi()?.querySelectorAll(t)}catch(t){i.reportSuppressed("dom.querySelectorAll",t)}},createElementNS(t,e,i){try{return pi()?.createElementNS(t,e,i)}catch(t){b("MJX103",t,e)}},convertToSvgElement(t){const e=t.tagName.toLowerCase(),i=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of t.attributes)i.setAttribute(e.name,e.value);for(;t.firstChild;)i.appendChild(t.firstChild);const s=t.parentNode;return s&&s.replaceChild(i,t),i},get body(){return pi()?.body}},mi=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;var _i;function gi(t,e,...i){return function(t,e,i,...s){const n=mi.exec(e);if(!n)throw w("MJX102",e);const o=n[1]||"div";let r;return r=t!==_i.HTML?fi.createElementNS(t,o):fi.createElement(o),n[3]&&(r.id=n[3]),n[4]&&(r.className=n[4].replace(/\./g," ").trim()),i&&Object.entries(i).forEach(([t,e])=>{void 0!==e&&(/^on\w+$/.test(t)?r[t]=e:"selected"===t?e&&r.setAttribute(t,"true"):r.setAttribute(t,e))}),r.append(...s),r}(_i.HTML,t,e,...i)}!function(t){t.HTML="http://www.w3.org/1999/xhtml",t.SVG="http://www.w3.org/2000/svg"}(_i||(_i={}));class yi{owner;constructor(t){this.owner=t}items=[];add(){const t=Array.from(arguments);if(0===t.length)return[];if("number"==typeof t[0]&&t.length>1){const e=t[0],i=[].concat(...t.slice(1));return this.insert(e,...i)}{const e=[].concat(...t);return this.insert(void 0,...e)}}insert(t,...e){return[].concat(...e).filter(t=>null!=t&&!t.isDisposed).map(e=>{"string"!=typeof(e=ti(e))&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e||(e=new ii(fi.createTextNode(e),null)),e.parent&&e.parent.controls.detach(e),null!=t&&t>=0?this.items.splice(t,0,e):this.items.push(e),e.parent=this.owner;const i=e.__pendingLeave;return i?(this.onAddBeforeBuild&&!this.owner.isBuilt&&this.onAddBeforeBuild(e),i.promise.then(()=>{e.isDisposed||this.owner.isDisposed||e.parent!==this.owner||this.onAdd&&this.owner.isBuilt&&this.onAdd(e)}),e):(this.onAdd&&this.owner.isBuilt&&this.onAdd(e),this.onAddBeforeBuild&&!this.owner.isBuilt&&this.onAddBeforeBuild(e),e)})}remove(t){var e=this.items.indexOf(t);if(e>-1){this.items.splice(e,1);try{t.dispose()}catch{}}}detach(t){const e=this.items.indexOf(t);return-1===e?Promise.resolve():(this.items.splice(e,1),t.isDisposed?Promise.resolve():(t.parent=null,function(t,e){let i=()=>{};const s=new Promise(t=>{i=t});let n=1,o=!1;const r=()=>{if(!o){if(o=!0,t.__pendingLeave?.promise===s&&delete t.__pendingLeave,!t.isDisposed){try{vi(t)}catch(t){b("MJX117",t)}Qe(t)}try{e()}catch(t){b("MJX118",t)}i()}},a=()=>{n--,0===n&&r()},c=t=>{if(!t||t.isDisposed||!t.element||!t.isVisible||t.isWait)return;const e=t.element;if(e.nodeType===Node.COMMENT_NODE)return void t.controls.items.forEach(c);if(e.nodeType!==Node.ELEMENT_NODE)return;n++;let i=!1;const s=()=>{i||(i=!0,a())};try{t.motif.options.transition.leaveTransition(s)}catch{s()}};return t.__pendingLeave={promise:s,finish:r},c(t),a(),s}(t,()=>{this.onRemove&&this.onRemove(t)})))}silentDetach(t,e=!1){if(e)return void this.silentUnlink(t);const i=this.items.indexOf(t);if(-1!==i&&(this.items.splice(i,1),!t.isDisposed)){t.parent=null;try{vi(t)}catch(t){b("MJX117",t)}Qe(t)}}silentUnlink(t){const e=this.items.indexOf(t);-1!==e&&(this.items.splice(e,1),t.parent=null)}async clearAsync(){const t=this.items.splice(0,this.items.length);await Promise.all(t.map(t=>t.dispose()))}clear(){this.items.splice(0,this.items.length).forEach(t=>{try{t.dispose()}catch{}})}get length(){return this.items.length}forEach(t){this.items.forEach(t)}map(t){return this.items.map(t)}onAdd;onRemove;onAddBeforeBuild;move(t,e){if(!t||t.isDisposed)return;if(e===t)return;if(t.parent!==this.owner)return;if(e&&e.parent!==this.owner)return;const i=this.items.indexOf(t);if(-1===i)return;const s=e?this.items.indexOf(e):-1;if(e&&-1===s)return;if(e?s===i+1:i===this.items.length-1)return;if(this.items.splice(i,1),e){const i=this.items.indexOf(e),s=i>=0?i:this.items.length;this.items.splice(s,0,t)}else this.items.push(t);if(t.isWait)return;const n=function(t){let e=t;for(;e;){const t=e.element;if(t&&t.nodeType!==Node.COMMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.nodeType!==Node.TEXT_NODE)return t;e=e.parent}return null}(this.owner);if(!n)return;!function(t,e,i){const s=t.element;if(!s)return;if(s.nodeType!==Node.COMMENT_NODE){try{e.insertBefore(s,i)}catch{}return}const n=s,o=t.motif.options?.closeFragment||null;if(!o){try{e.insertBefore(n,i)}catch{}return}i&&function(t,e,i){let s=t,n=1e4;for(;s&&n-- >0;){if(s===i)return!0;if(s===e)break;s=s.nextSibling}n<=0&&b("MJX120",void 0);return!1}(n,o,i)&&(i=o.nextSibling);const r=fi.createDocumentFragment&&fi.createDocumentFragment()||e.ownerDocument?.createDocumentFragment?.()||function(){try{return document.createDocumentFragment()}catch{return null}}();if(!r){let t=n,s=1e4;for(;t&&s-- >0;){const s=t.nextSibling;try{e.insertBefore(t,i)}catch{}if(t===o)break;t=s}return void(s<=0&&b("MJX119",void 0))}let a=n,c=1e4;for(;a&&c-- >0;){const t=a.nextSibling;try{r.appendChild(a)}catch{}if(a===o)break;a=t}c<=0&&b("MJX119",void 0);try{e.insertBefore(r,i)}catch{}}(t,n,e?e.element:function(t){const e=t.element;if(e&&e.nodeType===Node.COMMENT_NODE)return t.motif.options?.closeFragment||null;return null}(this.owner))}moveToIndex(t,e){if(!t||t.isDisposed)return;if(!Number.isFinite(e))return;if(e<0&&(e=0),e>this.items.length&&(e=this.items.length),-1===this.items.indexOf(t))return;const i=e>=this.items.length?null:this.items[e];this.move(t,i)}}function vi(t){const e=t.element;if(!e)return;const i=t.motif.options;if(e.nodeType===Node.COMMENT_NODE){if(!e.parentNode)return;const t=i?.closeFragment||null,s=i.cache??(i.cache=fi.createDocumentFragment());let n=e,o=1e4;for(;n&&o-- >0;){const e=n.nextSibling;if(s.appendChild(n),!t||n===t)break;n=e}return}if(e.parentNode)return void e.parentNode.removeChild(e);const s=i?.placeholder;s&&s.parentNode&&s.parentNode.removeChild(s)}function wi(t){return t&&"object"==typeof t&&"function"==typeof t.default?t.default:t}function bi(t){const e=t&&t.options||{},s=new ki,n=new Set,o=t=>{try{n.add(t)}catch{}return t},r=()=>{try{n.forEach(t=>{try{clearTimeout(t)}catch{}})}catch{}try{n.clear()}catch{}};try{s.motif.register(C.toDisposable(()=>r()))}catch{}const a=e.Placeholderview??e.Loaderview;null!=a&&s.navigate(ti(a));const c=()=>{if(!e.timeoutMs&&!e.signal)return t.caller();const i=[t.caller()];return e.timeoutMs&&e.timeoutMs>0&&i.push(new Promise((t,s)=>{const r=o(setTimeout(()=>s(w("MJX110",e.timeoutMs)),e.timeoutMs));if(i[0].finally(()=>{try{clearTimeout(r),n.delete(r)}catch{}}).catch(()=>{}),e.signal){const t=()=>{try{clearTimeout(r),n.delete(r)}catch{}};try{e.signal.addEventListener("abort",t,{once:!0})}catch{}}})),e.signal&&i.push(new Promise((t,i)=>{if(e.signal.aborted)return void i(w("MJX111"));const s=()=>{e.signal.removeEventListener("abort",s),r(),i(w("MJX111"))};e.signal.addEventListener("abort",s,{once:!0})})),Promise.race(i)},l=function(t){return"number"==typeof t?{count:Math.max(0,Math.floor(t)),delayMs:500,whenOnline:!0}:t&&"object"==typeof t?{count:Math.max(0,Math.floor(t.count||0)),delayMs:Math.max(0,t.delayMs??500),whenOnline:!1!==t.whenOnline}:{count:0,delayMs:0,whenOnline:!1}}(e.retry),h=new Set;try{s.motif.register(C.toDisposable(()=>{h.forEach(t=>{try{t()}catch{}}),h.clear()}))}catch{}const u=t=>new Promise(i=>{let s=!1;const r=t=>{if(!s){s=!0,h.delete(a);try{d&&window.removeEventListener("online",d)}catch{}try{void 0!==u&&(clearTimeout(u),n.delete(u))}catch{}try{e.signal?.removeEventListener("abort",c)}catch{}i(t)}},a=()=>r(!1),c=()=>r(!1);let u,d=null;h.add(a);try{e.signal?.addEventListener("abort",c,{once:!0})}catch{}const p=()=>{u=o(setTimeout(()=>r(!0),l.delayMs*t))};l.whenOnline&&"undefined"!=typeof navigator&&!1===navigator.onLine&&"undefined"!=typeof window?(d=()=>{try{window.removeEventListener("online",d)}catch{}d=null,p()},window.addEventListener("online",d)):p()}),d=l.count>0?(async()=>{let t=0;for(;;)try{return await c()}catch(i){if(e.signal?.aborted||s.isDisposed||t>=l.count)throw i;t++;try{e.onRetry?.(t,i)}catch{}if(!await u(t)||e.signal?.aborted||s.isDisposed)throw i}})():c(),p=Date.now();return d.then(t=>{if(e.signal?.aborted)return;const i=(e.mapResult??wi)(t),r=Date.now()-p,a=Math.max(0,e.minDelayMs??0),c=Math.max(0,a-r);if(c>0){const t=o(setTimeout(()=>{e.signal?.aborted||s.navigate(ti(i))},c));if(e.signal){const i=()=>{try{clearTimeout(t),n.delete(t)}catch{}};try{e.signal.addEventListener("abort",i,{once:!0})}catch{}}}else s.navigate(ti(i))}).catch(t=>{try{e.onError?.(t)}catch{}if(!e.signal?.aborted)if(null!=e.Fallbackview)s.navigate(ti(e.Fallbackview));else{i.reportSuppressed("Lazy.load (no Fallbackview)",t);try{s.motif.clear().catch(()=>{})}catch{}}}),s}function Si(t){if(t&&!t.isDisposed)if(Array.isArray(t))t.forEach(Si);else{try{t.motif.options?.transition?.activeCssCancel?.()}catch{}try{const e=t.motif.options?.transition?.activeAnimations;Array.isArray(e)&&(e.forEach(t=>{try{t&&"function"==typeof t.cancel&&t.cancel()}catch{}}),e.length=0)}catch{}try{if(t.controls&&t.controls.items)for(const e of t.controls.items)Si(e)}catch{}}}async function Mi(t){if(t)if(Array.isArray(t))for(const e of t)try{e&&!e.isDisposed&&await e.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){b("MJX115",t)}else t.isDisposed||await t.dispose({deep:!0,skipLeaveTransition:!0})}async function Ci(t,e,i=!1){if(t.isDisposed||null==e)return;if(null!==t.current&&t.current===e)return;const s=++t._latestNavigateId;t.isBusy=!0;const n=e=>{if(t.isDisposed)return;if(s!==t._latestNavigateId)return;const i=ti(e);t.current=i;try{Array.isArray(i)?t.controls.add(...i):t.controls.add(i)}catch(t){b("MJX114",t)}t.isBusy=!1,t.previouspage=i};if(!(t._navPending||null!==t.current||e instanceof Promise)){try{n(e)}catch(e){b("MJX114",e),t.isBusy=!1}return}t._navPending=(t._navPending??0)+1;const o=t._navLock??Promise.resolve();t._navLock=(async()=>{try{await o;try{t._navAbort?.abort()}catch{}t._navAbort=new AbortController;const s=t.current;if(s&&!i){Si(s),Si(t);try{await Mi(s)}catch{}}try{if(e instanceof Promise){const i=bi({caller:()=>e,options:{signal:t._navAbort?.signal}});n(i)}else n(e)}catch(e){b("MJX114",e),t.isBusy=!1}}finally{t._navPending=Math.max(0,(t._navPending??1)-1)}})(),await t._navLock}class ki extends ii{current=null;_latestNavigateId=0;_navLock=Promise.resolve();_navAbort;isBusy=!1;constructor(t){super(fi.createComment(""),t),t&&t.childs&&Array.isArray(t.childs)&&t.childs.length>0&&this.controls.add(t.childs)}async dispose(){await Mi(this.current),await super.dispose()}async flush(){await Mi(this.current)}async _clear(){await Mi(this.current)}previouspage;async navigate(t,e=!1){await Ci(this,t,e)}async navigateLazy(t,e,i=!1){const s=bi({caller:t,options:e});await this.navigate(s,i)}}const Ai=new Set;function Di(t){Ai.add(t),Ai.forEach(t=>{t()})}const Ei=new Map,xi=Symbol("changeBodyCollectionHandler");class Ti extends ii{constructor(t){super(t),this.controls.onAdd=t=>{var e=Ei.get(this.props.target);e&&(t.motif.options.ownerContentBlock=this,e.controls.add(t))},this.controls.onAddBeforeBuild=t=>{var e=Ei.get(this.props.target);e&&(t.motif.options.ownerContentBlock=this,e.controls.add(t))},this.childs&&this.controls.add(...this.childs)}onConfigured(t,e){var i=Ei.get(this.props.target);i?(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),i.controls.add(...this.controls.items)):this.context.on(xi,()=>{var t=Ei.get(this.props.target);t&&(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),t.controls.add(...this.controls.items))})}onDisposing(t,e){var i=Ei.get(this.props.target);if(i)for(const t of[...i.controls.items])t.motif.options.ownerContentBlock===this&&(i.controls.remove(t),M("MJX109",[],t))}ondisposing(t){}}class Oi extends ii{constructor(t){super(t),Ei.set(this.props.name,this),this.context.fire(xi)}ondisposing(t){Ei.delete(this.props.name)}}const Ni=Symbol("slotRegistered"),Pi=Symbol("slotUnregistered");class Li{static slots=new Map;static registerSlot(t,e){this.slots.set(t,e),Gs.main.fire(Ni,{name:t,slot:e})}static unregisterSlot(t,e){this.slots.get(t)===e&&(this.slots.delete(t),Gs.main.fire(Pi,{name:t,slot:e}))}static getSlot(t){return this.slots.get(t)}}class Xi extends ii{mode;constructor(t){super(t),this.mode=t.mode||"replace"}initializeComponent(t){Li.registerSlot(this.props.name,this),this.onDisposing=()=>{(this.controls.items||[]).forEach(t=>{this.controls.remove(t),t.dispose?.()}),Li.unregisterSlot(this.props.name,this)}}clearSlot(){(this.controls.items||[]).forEach(t=>{this.controls.remove(t),t.dispose?.()})}}class Ii{static transport(t,e,i={}){t&&e&&(t.parent===e&&e.controls.items.includes(t)||(t.parent&&t.parent!==e&&t.parent.controls.remove(t),i.owner&&(t.motif.options.ownerTransporter=i.owner),"number"==typeof i.index?e.controls.items.includes(t)||e.controls.items.splice(i.index,0,t):e.controls.items.includes(t)||e.controls.add(t),t.parent=e,i.keepState||t.reState()))}static transportMany(t,e,i={}){Array.isArray(t)&&t.forEach(t=>this.transport(t,e,i))}static createSlot(t,e){return{name:t,children:[],parent:e,mount(t,e={}){if(!this.parent)throw w("MJX113");this.children.includes(t)||(Ii.transport(t,this.parent,e),this.children.push(t))},unmount(t){if(!this.parent)throw w("MJX113");this.children=this.children.filter(e=>e!==t),this.parent.controls.remove(t)},detachAll(){this.parent&&(this.children.forEach(t=>{this.parent.controls.remove(t)}),this.children=[])}}}}class Ri extends ii{_onAddRef;_onRemoveRef;_slotRegisteredListener;_slotUnregisteredListener;_transported=[];constructor(t){super("div",t)}_handleSlotChange=t=>{if(t.name===this.props.name){const e=t.slot;"merge"!==e.mode&&e.clearSlot?.();const i=[...this.childs||[],...this.controls.items];Ii.transportMany(i,e),this._transported=i}};_clearChildrenFromSlot=t=>{(this.childs||[]).forEach(e=>{t.controls.remove(e),e.dispose()}),(this.controls.items||[]).forEach(e=>{t.controls.remove(e),e.dispose()})};initializeComponent(t){let e=Li.getSlot(this.props.name);if(e){"merge"!==e.mode&&e.clearSlot?.();const t=[...this.childs||[],...this.controls.items];Ii.transportMany(t,e),this._transported=t}this._slotRegisteredListener=Gs.main.on(Ni,this._handleSlotChange),this._slotUnregisteredListener=Gs.main.on(Pi,t=>{t.name===this.props.name&&this._clearChildrenFromSlot(t.slot)}),this._onAddRef=t=>{const e=Li.getSlot(this.props.name);e&&Ii.transport(t,e)},this._onRemoveRef=t=>{const e=Li.getSlot(this.props.name);e&&e.controls.remove(t)},this.controls.onAdd=this._onAddRef,this.controls.onRemove=this._onRemoveRef}onDisposing(t,e){const i=Li.getSlot(this.props.name);i&&(this._transported||[]).forEach(t=>{i.controls.remove(t),t.dispose()}),this._slotRegisteredListener&&(Gs.main.off(Ni,this._handleSlotChange),this._slotRegisteredListener=void 0),this._slotUnregisteredListener&&(Gs.main.off(Pi,this._slotUnregisteredListener),this._slotUnregisteredListener=void 0),this.controls.onAdd===this._onAddRef&&(this.controls.onAdd=void 0),this.controls.onRemove===this._onRemoveRef&&(this.controls.onRemove=void 0),this._onAddRef=void 0,this._onRemoveRef=void 0,this._transported=[]}}const Ji=new Set(["push","pop","shift","unshift","splice","reverse","sort"]),Fi=Symbol(""),Hi=new Map([["[__isReactive__]",()=>!0],["[__isReadonly__]",t=>t.isReadonly],["[__issuperficial__]",t=>t.superficial],["[__get_setup__]",(t,e)=>e],["[__raw__]",(t,e,i)=>t.ReactiveMap().get(e)===i?e:Fi]]);function ji(t){return function(e,i,s){const n=function(t,e,i,s){if("string"!=typeof i||91!==i.charCodeAt(0))return Fi;const n=Hi.get(i);return void 0===n?Fi:n(t,e,s)}(t,e,i,s);if(n!==Fi)return n;if(Array.isArray(e)&&!t.isReadonly){const s=t.arrayMethods.get;if(O(s,i)){const t=s[i];return Ji.has(i)?(o=i,B.push(x),x.enabled=!0,x.key=o):gt(e,i),t}}var o;const r=Reflect.get(e,i,s);return"__proto__"===i||L(i)?r:(t.isReadonly||gt(e,i),t.superficial||!N(r)?r:t.reactive(r))}}function Bi(t){return function(e,i,s,n){if(null!=(o=e)&&Boolean(o["[__isReadonly__]"]))return!1;var o;const r=Array.isArray(e),a=e[i],c=r?e.length:0,l=r&&("string"==typeof(h=i)&&I.test(h)&&String(Number(h))===h);var h;const u=l?Number(i)<c:O(e,i),d=Reflect.set(e,i,s,n);if(t.onValueChanged)try{t.onValueChanged({raw:e,proxy:n},i)}catch{}if(T(e)!==T(n))return d;if(!r&&u&&Object.is(s,a))return d;if(yt(e,i),r||u||yt(e,D),l&&!u&&yt(e,"length"),r&&"length"===i){for(let t=Number(s);t<c;t++)yt(e,String(t))}return function(){const t=B.pop();x=B.length>0?void 0===t?{enabled:!1,key:""}:t:{enabled:!1,key:""}}(),d}}function zi(t){return function(t){return gt(t,Array.isArray(t)?"length":D),Reflect.ownKeys(t)}}function Vi(t){return function(t,e){const i=Reflect.has(t,e);return L(e)||gt(t,e),i}}function Wi(t){return function(t,e){H();try{const i=O(t,e),s=Reflect.deleteProperty(t,e);return i&&(Array.isArray(t)?yt(t,"length"):(yt(t,e),yt(t,D))),s}finally{j()}}}const $i=[["includes","lookup"],["indexOf","lookup"],["lastIndexOf","lookup"],["sort","order"],["concat","join"],["push","structural"],["pop","structural"],["shift","structural"],["unshift","structural"],["splice","structural"],["reverse","structural"]];class Ui{engine;constructor(t){this.engine=t}get=this.createArrayMethods();createArrayMethods(){const t={};for(const[e,i]of $i)t[e]=this.patch(e,i);return t}patch(t,e){const i=this;switch(e){case"lookup":return function(...e){const s=T(this);i.engine.track(s,"length");const n=s[t](...e);return!1!==(o=n)&&-1!==o?n:s[t](...e.map(t=>T(t)));var o};case"order":return function(...e){const s=T(this),n=this.length;for(let t=0;t<n;t++)i.engine.track(s,String(t));const o=s[t].apply(this,e);return i.engine.track(s,t),o};case"join":return function(...t){return Array.prototype.concat.apply(this,t)};default:return function(...e){H();const i=T(this);try{return i[t].apply(this,e)}finally{j()}}}}}const qi=new WeakSet,Ki=new WeakMap;const Gi=new class{_gci;startGc(t=1e4){}stopGc(){if(this._gci){try{clearInterval(this._gci)}catch{}this._gci=void 0}}constructor(){qi.add(this),this.startGc()}DisposeMapper=new Q;arrayTriggerCache=new Map;ReactiveMap=()=>Ki;activeCallback;isReadonly=!1;superficial=!1;arrayMethods=new Ui(this);arrayHandler={get:ji(this),set:Bi(this),has:Vi(),deleteProperty:Wi(),ownKeys:zi()};deepHandler={get:ji(this),set:Bi(this),has:Vi(),deleteProperty:Wi(),ownKeys:zi()};reactive(t){N(t)||(t={value:t});const e=(i=t,s=Object.getPrototypeOf(i),n="",s&&s.constructor&&(n=s.constructor.name),"Control"===n||"RouteManager"==n||"ServiceManager"==n?0:Object.isExtensible(i)?X.get(Object.prototype.toString.call(i))??0:0);var i,s,n;if(0===e||2===e)return t;let o=Ki.get(t);if(o)return o;if(o=Ki.get(T(t)),o)return o;if(Array.isArray(t)){var r=new Proxy(t,this.arrayHandler);return Ki.set(t,r),r}r=new Proxy(t,this.deepHandler);return Ki.set(t,r),r}clearModel(t){null!=t&&null!=t&&(Object.keys(t).forEach(e=>{"object"==typeof t[e]&&(Ki.has(t[e])||Ki.has(T(t[e])))&&this.clearModel(t[e]),Ki.delete(T(t[e])),Ki.delete(t[e])}),Ki.delete(T(t)),Ki.delete(t))}track(t,e){gt(t,e)}trigger(t,e,i){yt(t,e)}ArrayTrigger(t,e,...i){this.trigger(t,e,i)}onValueChanged;toRaw(t){return JSON.parse(JSON.stringify(this.deepClone(t)))}deepClone(t){var e,i=this;if(!t)return t;if([Number,String,Boolean].forEach(function(i){t instanceof i&&(e=i(t))}),void 0===e)if("[object Array]"===Object.prototype.toString.call(t))e=[],t.forEach(function(t,s,n){e[s]=i.deepClone(t)});else if("object"==typeof t)if(t.nodeType&&"function"==typeof t.cloneNode)e=t.cloneNode(!0);else if(t.prototype)e=t;else if(t instanceof Date)e=new Date(t);else for(var s in e={},t)e[s]=i.deepClone(t[s]);else e=t;return e}pauseTracking(){H()}enableTracking(){F(!0)}resetTracking(){j()}dispose(){var t=!0;for(this.stopGc();1==t;)if(this.DisposeMapper.size>0){const t=this.DisposeMapper.pop();Ki.delete(t)}else t=!1;this.DisposeMapper.clear(),qi.delete(this)}},Yi=[],Qi=()=>{try{const t=globalThis;return!!t.__MOTIF_DEV__&&(t.__MOTIF_STORE_REGISTRY__!==Yi&&(t.__MOTIF_STORE_REGISTRY__=Yi),!0)}catch{return!1}};function Zi(t){const e=Gi.reactive(t);try{if(Qi()){const i=t?.constructor?.name||"reactive";Yi.push({name:i,value:e,type:"reactive"}),Yi.length>200&&Yi.shift()}}catch{}return e}function ts(t){const e=Gi.reactive(t);try{if(Qi()){const i=t?.constructor?.name||"useModel";Yi.push({name:i,value:e,type:"reactive"}),Yi.length>200&&Yi.shift()}}catch{}return e}function es(t){return Gi.clearModel(t)}function is(t){return Gi.deepClone(t)}function ss(t){const e=new Gt(t);try{if(Qi()){const t=`signal_${Yi.length}`;Yi.push({name:t,value:e.value,type:"signal"}),Yi.length>200&&Yi.shift()}}catch{}return e}function ns(t){const e=new Yt(t);try{if(Qi()){const t=`computed_${Yi.length}`;Yi.push({name:t,value:e.value,type:"computed"}),Yi.length>200&&Yi.shift()}}catch{}return e}function os(t){const e=new Qt(t);try{if(Qi()){const t=`lazyComputed_${Yi.length}`;Yi.push({name:t,value:void 0,type:"computed"}),Yi.length>200&&Yi.shift()}}catch{}return e}class rs extends ii{_state;_virtualContent;_topSpacer;_bottomSpacer;_cache=new Map;_view=[];_occurrence=[];_occurrenceKeys=new WeakMap;_isLoadingMore=!1;_emptyRendered=!1;_renderPending=!1;constructor(t){super("div",t),t.className&&this.class.add(t.className),t.style&&Object.assign(this.element.style,t.style),this._state=this.useModel({isLoading:!1,isInitialized:!1,currentPage:0,totalCount:0,hasMore:!0,error:void 0,data:[]}),this._loadMore=this._loadMore.bind(this),this._renderLoadingState=this._renderLoadingState.bind(this),this._renderErrorState=this._renderErrorState.bind(this),this._renderEmptyState=this._renderEmptyState.bind(this),this._loadInitial=this._loadInitial.bind(this),this.renderViewport=this.renderViewport.bind(this),this._makeView()}contentWrapper=new ii;wrapper;_makeView(){this._topSpacer=new ii("div"),this._topSpacer.element.style.cssText="height: 0px;",this._topSpacer.class.add("motif-virtualization-top-spacer"),this._bottomSpacer=new ii("div"),this._bottomSpacer.element.style.cssText="height: 0px;",this._bottomSpacer.class.add("motif-virtualization-bottom-spacer"),this._virtualContent=new ii(document.createComment("")),this.props.mainTemplate?(this.contentWrapper.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.contentWrapper.onBuilding=t=>{var e=q(t.parent);e&&(this.wrapper=e,this._loadInitial(),e.style({overflowY:"auto",position:"relative"}),e.motif.on("scroll",this._handleScroll))},this.controls.add(this.props.mainTemplate(this.contentWrapper,this._state))):(this.wrapper=this,this.element.style.cssText="overflow-y: auto; height: 100%; position: relative;",this.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.motif.on("scroll",this._handleScroll))}_initialLoadStarted=!1;onBuilding(){this.props.mainTemplate||this._initialLoadStarted||(this._initialLoadStarted=!0,this._loadInitial())}onMounted(){this._observeResize(),this._renderPending&&this.renderViewport()}onDisposing(){this._stopResizeObserver(),this._stopDataWatch(),this._clearContent()}_offsets=null;_resizeObserver;_observed;_observedHeight=-1;_fixedHeight(){const t=this.props.itemHeight;return"function"==typeof t?null:t}_computeOffsets(){const t=this.props.itemHeight;if("function"!=typeof t)return void(this._offsets=null);const e=this._view,i=new Array(e.length+1);i[0]=0;for(let s=0;s<e.length;s++){let n=0;try{n=Number(t(e[s],s))}catch{n=0}i[s+1]=i[s]+(n>0&&Number.isFinite(n)?n:0)}this._offsets=i}_layoutOffsets(){return this._offsets&&this._offsets.length===this._view.length+1||this._computeOffsets(),this._offsets}_offsetOf(t){const e=this._fixedHeight();if(null!==e)return t*e;const i=this._layoutOffsets();return i[Math.min(Math.max(0,t),i.length-1)]}_indexAt(t,e){const i=e.length-1;if(i<=0)return 0;let s=0,n=i-1;for(;s<n;){const i=s+n+1>>1;e[i]<=t?s=i:n=i-1}return s}_observeResize(){const t=this.wrapper?.element;if(!t||this._observed===t||this.isDisposed)return;const e=globalThis.ResizeObserver;if("function"!=typeof e)return;this._stopResizeObserver(),this._observedHeight=t.clientHeight;const i=new e(()=>{if(this.isDisposed)return;const e=t.clientHeight;e!==this._observedHeight&&(this._observedHeight=e,this.renderViewport())});i.observe(t),this._resizeObserver=i,this._observed=t}_stopResizeObserver(){try{this._resizeObserver?.disconnect()}catch{}this._resizeObserver=void 0,this._observed=void 0}_loadSeq=0;_dataWatchStop;_reloadScheduled=!1;_reloadTimes=[];_stopDataWatch(){this._dataWatchStop?.(),this._dataWatchStop=void 0}_request(t,e){const i=()=>{try{return Promise.resolve(this.props.dataRequest(t))}catch(t){return Promise.reject(t)}};if(!e||!1===this.props.autoRefresh)return At(i);let s;this._stopDataWatch();let n=!0;return this._dataWatchStop=St(()=>{if(n){n=!1;try{this.props.watch?.()}catch(t){b("MJX205",t)}s=i()}else this._scheduleReload()}),s}_scheduleReload(){this._reloadScheduled||this.isDisposed||(this._reloadScheduled=!0,queueMicrotask(()=>{if(this._reloadScheduled=!1,this.isDisposed)return;const t=Date.now();if(this._reloadTimes=this._reloadTimes.filter(e=>t-e<1e3),this._reloadTimes.push(t),this._reloadTimes.length>30)return this._stopDataWatch(),void M("MJX206",[]);this._state.isInitialized?this._reloadLoaded():this._loadInitial()}))}async _reloadLoaded(){const t=++this._loadSeq,e=this.props.pageSize||50,i=this._state.currentPage+1;try{const s=await this._request({page:0,pageSize:e*i,scrollTop:this.wrapper?.element?.scrollTop??0},!0);if(this.isDisposed||t!==this._loadSeq)return;const n=this.wrapper?.element,o=n?.scrollTop??0;this._state.currentPage=i-1,this._state.totalCount=s.totalCount,this._state.hasMore=s.hasMore,this._state.error=void 0,this._state.data=s.items,this._rebuildView(),this._topSpacer.style({height:"0px"}),this._bottomSpacer.style({height:this._offsetOf(this._view.length)+"px"}),this._clearContent(),n&&n.scrollTop!==o&&(n.scrollTop=o),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.error=e,this._renderErrorState(e)}}_handleScroll=(t,e)=>{if(this.renderViewport(),!1===this.props.autoLoad)return;if(!this._state.hasMore||this._isLoadingMore||!this._state.isInitialized)return;const i=this.wrapper.element,s=this._fixedHeight();(null!==s?this._state.data.length*s:this._offsetOf(this._view.length))-(i.scrollTop+i.clientHeight)<(this.props.autoLoadThreshold??100)&&this._loadMore()};async _loadInitial(){const t=++this._loadSeq;this._state.isLoading=!0,this._renderLoadingState();try{const e=this.props.pageSize||50,i=await this._request({page:0,pageSize:e,scrollTop:0},!0);if(this.isDisposed||t!==this._loadSeq)return;this._state.currentPage=0,this._state.totalCount=i.totalCount,this._state.hasMore=i.hasMore,this._state.isInitialized=!0,this._state.isLoading=!1,this._state.error=void 0,this._state.data=i.items,this._clearContent(),this._rebuildView(),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.isLoading=!1,this._state.error=e,this._renderErrorState(e)}}async _loadMore(){if(this._isLoadingMore||!this._state.hasMore||!this._state.isInitialized)return;const t=this._loadSeq;try{this._isLoadingMore=!0;const e=this._state.currentPage+1,i=this.props.pageSize||50,s=await this._request({page:e,pageSize:i,scrollTop:this.wrapper?.element?.scrollTop??0},!1);if(this.isDisposed||t!==this._loadSeq)return;this._state.totalCount=s.totalCount,this._state.currentPage=e,this._state.hasMore=s.hasMore,this._state.error=void 0,this._state.data.push(...s.items),this._rebuildView(),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.error=e,b("MJX207",e)}finally{this._isLoadingMore=!1}}_rebuildView(){this._view=this.props.filter?this.props.filter(this._state.data):this._state.data;const t=new Map;this._occurrence=this._view.map(e=>{if("object"!=typeof e||null===e)return 0;const i=t.get(e)??0;return t.set(e,i+1),i}),"function"==typeof this.props.itemHeight?this._computeOffsets():this._offsets=null}_clearContent(){if(!this._virtualContent)return;const t=this._virtualContent.controls;for(const e of this._cache.values())t.silentUnlink(e),e.isDisposed||e.dispose();this._cache.clear(),t.clear(),this._emptyRendered=!1}renderViewport(){if(this.isDisposed||!this.wrapper||!this._state.isInitialized)return;const t=this.wrapper.element;this._observeResize();const e=this._view,i=e.length;if(0===i)return this._emptyRendered||(this._clearContent(),this._renderEmptyState()),this._topSpacer.style({height:"0px"}),void this._bottomSpacer.style({height:"0px"});this._emptyRendered&&this._clearContent();const s=this._fixedHeight();let n,o,r,a,c;if(null!==s){const e=Math.floor(t.clientHeight/s);if(e<=0)return void(this._renderPending=!t.isConnected);this._renderPending=!1,n=Math.max(0,this.props.overscan??e);const l=Math.min(Math.max(0,Math.floor(t.scrollTop/s)),i-1);o=Math.max(0,l-n),r=Math.min(i,l+e+n),a=o*s,c=Math.max(0,i-r)*s}else{if(t.clientHeight<=0)return void(this._renderPending=!t.isConnected);this._renderPending=!1;const e=this._layoutOffsets(),s=Math.max(0,t.scrollTop),l=s+t.clientHeight,h=this._indexAt(s,e);let u=h;for(;u<i&&e[u]<l;)u++;const d=Math.max(1,u-h);n=Math.max(0,this.props.overscan??d),o=Math.max(0,h-n),r=Math.min(i,Math.max(u,h+1)+n),a=e[o],c=Math.max(0,e[i]-e[r])}const l=new Array(r-o),h=new Set;for(let t=o;t<r;t++){const i=this._rowFor(e[t],t);l[t-o]=i,h.add(i)}const u=this._virtualContent.controls.items;for(const t of u.slice())h.has(t)||this._detachRow(t);for(let t=0;t<l.length;t++){const e=l[t];u[t]!==e&&(e.parent===this._virtualContent&&this._detachRow(e),this._virtualContent.controls.insert(t,e))}this._topSpacer.style({height:a+"px"}),this._bottomSpacer.style({height:c+"px"}),this._evictCache(Math.max(200,3*(r-o))),!1!==this.props.autoLoad&&this._state.hasMore&&!this._isLoadingMore&&i<r+n&&this._loadMore()}_occurrenceKey(t,e){let i=this._occurrenceKeys.get(t);return i||(i=[],this._occurrenceKeys.set(t,i)),i[e]??={}}_rowFor(t,e){const i=this._occurrence[e]??0,s="object"==typeof t&&null!==t?0===i?t:this._occurrenceKey(t,i):e;let n=this._cache.get(s);if(n&&n.isDisposed&&(this._cache.delete(s),n=void 0),n)return this._cache.delete(s),this._cache.set(s,n),n;const o=this.props.itemTemplate(t,e);return n=o instanceof ke?o:new ii(o),n.__listItemRef=t,this._cache.set(s,n),n}_detachRow(t){const e=this._virtualContent.controls;if(t.isDisposed)return void e.silentUnlink(t);const i=t.element;if(i.nodeType===Node.COMMENT_NODE){e.silentUnlink(t);const s=t.motif.options.closeFragment,n=t.motif.options.cache??(t.motif.options.cache=document.createDocumentFragment());let o=i;for(;o;){const t=o.nextSibling;if(n.appendChild(o),o===s)break;o=t}Qe(t)}else e.silentDetach(t)}_evictCache(t){const e=this.props.cacheSize??t;if(!(this._cache.size<=e))for(const[t,i]of this._cache){if(this._cache.size<=e)break;i.parent!==this._virtualContent&&(this._cache.delete(t),i.isDisposed||i.dispose())}}_renderLoadingState(){if(!this._virtualContent||!this.props.loadingTemplate)return;this._clearContent();const t=this.props.loadingTemplate(this._state);this._virtualContent.controls.add(t)}_renderEmptyState(){if(!this._virtualContent||!this.props.emptyTemplate)return;this._clearContent();const t=this.props.emptyTemplate();this._virtualContent.controls.add(t),this._emptyRendered=!0}_renderErrorState(t){if(this._virtualContent)if(this._clearContent(),this.props.errorTemplate){const e=this.props.errorTemplate(t);this._virtualContent.controls.add(e)}else b("MJX207",t);else b("MJX207",t)}refresh(){return this._state.data=[],this._state.currentPage=0,this._state.isInitialized=!1,this._state.hasMore=!0,this._rebuildView(),this._loadInitial()}setData(t){this._loadSeq++,this._stopDataWatch(),this._state.data=t,this._state.currentPage=0,this._state.totalCount=t.length,this._state.hasMore=!1,this._state.isInitialized=!0,this._state.isLoading=!1,this._state.error=void 0,this._clearContent(),this._rebuildView(),this.renderViewport()}scrollToIndex(t){if(!this.wrapper)return;const e=this._view.length,i=Math.min(Math.max(0,t),Math.max(0,e-1));this.wrapper.element.scrollTop=this._offsetOf(i),this.renderViewport()}getState(){return{...this._state}}}const as=new Map;class cs{descriptors=new Map;reset(){this.descriptors.clear()}addTransient(t,e){this._add(t,e,"transient")}addSingleton(t,e){this._add(t,e,"singleton")}addScoped(t,e){this._add(t,e,"scoped")}_add(t,e,i){const s={token:t,lifetime:i};if(e&&"object"==typeof e&&(e.useClass||e.useFactory||Object.prototype.hasOwnProperty.call(e,"useValue")||Array.isArray(e.deps))){s.useClass=e.useClass,s.useFactory=e.useFactory,s.useValue=e.useValue,s.deps=Array.isArray(e.deps)?e.deps:void 0;try{const i=[s.useClass?"useClass":null,s.useFactory?"useFactory":null,void 0!==s.useValue?"useValue":null].filter(Boolean);i.length>1&&M("MJX410",[this._tokenName(t),i.join(", ")],{token:t}),e.deps&&!Array.isArray(e.deps)&&M("MJX411",[this._tokenName(t)],{token:t})}catch{}if(s.useValue&&"function"==typeof s.useValue.then){const t=s.useValue;s.useFactory=async()=>await t,s.useValue=void 0}}else if("function"==typeof e){if(!function(t){try{return Reflect.construct(String,[],t),!0}catch{return!1}}(e))throw w("MJX413",this._tokenName(t));s.useClass=e}else if(e&&"function"==typeof e.then){const t=e;s.useFactory=async()=>await t}else s.useValue=e;this.descriptors.set(t,s)}_tokenName(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}getDescriptor(t){const e=this.descriptors.get(t);if(e)return e;const i=as.get(t);return i?(this._add(t,{useClass:t,deps:i.deps,useValue:void 0,useFactory:void 0},i.lifetime||"transient"),this.descriptors.get(t)||null):null}canAutoRegister(t){return!this.descriptors.has(t)&&as.has(t)}getService(t){return this.getDescriptor(t)}buildServiceProvider(){return new _e(this)}has(t){return this.descriptors.has(t)}remove(t){return this.descriptors.delete(t)}replace(t,e,i){const s=this.descriptors.get(t),n=i??s?.lifetime??"transient";this._add(t,e,n)}tryAddTransient(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"transient"),!0)}tryAddSingleton(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"singleton"),!0)}tryAddScoped(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"scoped"),!0)}autoRegisterInjectables(){for(const[t,e]of as.entries())this.descriptors.has(t)||this._add(t,{useClass:t,deps:e.deps,useValue:void 0,useFactory:void 0},e.lifetime||"transient")}}function ls(t,e){const i=(t||"").trim(),s=(e||"").trim(),n=i&&"/"!==i&&i.endsWith("/")?i.slice(0,-1):i;if("/"===s)return n||"/";const o=s?s.startsWith("/")?s:"/"+s:"";return n&&"/"!==n?n+o:o||"/"}let hs=null,us=!1;function ds(t){hs&&(us="boolean"==typeof t?t:!us,hs.style.display=us?"block":"none")}class ps{static outlets=new Map;static register(t,e,i){this.outlets.has(t)||this.outlets.set(t,new Map),this.outlets.get(t).set(e,i)}static unregister(t,e){this.outlets.get(t)?.delete(e),0===this.outlets.get(t)?.size&&this.outlets.delete(t)}static find(t,e){if(e&&this.outlets.get(t)?.has(e))return this.outlets.get(t).get(e);const i=this.outlets.get(t);return i&&i.size>0?Array.from(i.values())[0]:null}static findAll(t){return Array.from(this.outlets.get(t)?.values()??[])}}const fs=Symbol.for("RouterView.built");class ms extends ii{constructor(t){super(t)}_navLock=Promise.resolve();_navAbort;get __isRouterView(){return!0}get scopeId(){let t=this.parent,e=[];for(;t;)e.push(t.constructor?.name??""),t=t.parent;return e.join(">")}disposingChilds=!1;previouspage;current=null;_latestNavigateId=0;isBusy=!1;async navigate(t,e=!1){await Ci(this,t,e)}async disposeTarget(t){await Mi(t)}onBuilt(){try{ps.register(this.props.name??"default",this.scopeId,this);let t=this.parent;for(;t;)t.motif.trigger(fs,this),t=t.parent}catch{}}onDisposed(){try{ps.unregister(this.props.name??"default",this.scopeId)}catch{}}}const _s="motifjs:scroll",gs=["wheel","touchstart","keydown","mousedown"];class ys{options;viewport;positions=new Map;currentKey="";visited=!1;restoring=!1;cancelFrame=null;disarmAbort=null;offs=[];locationAnchor=!0;constructor(t={},e){this.options=t,this.viewport=e??(t.container?function(t){const e=vs(),i=()=>{try{return"string"==typeof t?document.querySelector(t):"function"==typeof t?t()??null:t}catch{return null}};return{scrollTop:()=>{const t=i();return t?t.scrollTop||0:e.scrollTop()},scrollTo:t=>{const s=i();if(s)try{s.scrollTop=t}catch{}else e.scrollTo(t)},scrollToAnchor:t=>e.scrollToAnchor(t)}}(t.container):vs()),this.load();try{"undefined"!=typeof history&&"scrollRestoration"in history&&(history.scrollRestoration="manual")}catch{}"undefined"!=typeof window&&(this.offs.push(Ss(window,"pagehide",()=>this.persistNow())),this.offs.push(Ss(document,"visibilitychange",()=>{"hidden"===document.visibilityState&&this.persistNow()})))}leaving(){this.cancelRestore(),this.visited&&(this.remember(this.currentKey,this.viewport.scrollTop()),this.persist())}arrived(t){this.visited=!0;const{path:e,hash:i}=ws(t);this.currentKey=this.keyOf(e),this.restore(this.currentKey,!1===this.options.anchor?"":i||(this.locationAnchor?function(){try{const t=location?.hash??"";return t.length>1?bs(t.slice(1)):""}catch{return""}}():""))}saved(t){return this.positions.get(this.keyOf(ws(t).path))??0}dispose(){this.cancelRestore(),this.persistNow();for(const t of this.offs.splice(0))t();this.positions.clear()}keyOf(t){return(this.options.key?this.options.key(t):t)||"/"}remember(t,e){const i=this.options.limit??60;for(this.positions.delete(t),this.positions.set(t,Math.max(0,Math.round(e)));this.positions.size>i;){const t=this.positions.keys().next();if(t.done)break;this.positions.delete(t.value)}}restore(t,e){this.cancelRestore();const i=this.positions.get(t)??0;if(!e&&i<=0)return void(!1!==this.options.top&&this.viewport.scrollTo(0));this.restoring=!0;const s=this.options.settleMs??1200,n=Date.now(),o=()=>{this.cancelFrame=null;if((e?this.viewport.scrollToAnchor(e):this.reached(i))||Date.now()-n>=s)return this.cancelRestore(),void this.remember(t,this.viewport.scrollTop());this.armAbort(),this.cancelFrame=function(t){if("function"!=typeof requestAnimationFrame){const e=setTimeout(t,16);return()=>clearTimeout(e)}const e=requestAnimationFrame(t);return()=>cancelAnimationFrame(e)}(o)};o()}reached(t){return this.viewport.scrollTo(t),this.viewport.scrollTop()>=t-1}armAbort(){if(this.disarmAbort||"undefined"==typeof window)return;const t=()=>this.cancelRestore(),e=gs.map(e=>Ss(window,e,t,{passive:!0}));this.disarmAbort=()=>{for(const t of e)t()}}cancelRestore(){this.cancelFrame?.(),this.cancelFrame=null,this.disarmAbort?.(),this.disarmAbort=null,this.restoring=!1}persistNow(){this.visited&&!this.restoring&&this.remember(this.currentKey,this.viewport.scrollTop()),this.persist()}get storage(){if(!1===this.options.persist)return null;try{return"undefined"==typeof sessionStorage?null:sessionStorage}catch{return null}}persist(){const t=this.storage;if(t)try{t.setItem(_s,JSON.stringify([...this.positions]))}catch{}}load(){const t=this.storage;if(t)try{const e=t.getItem(_s);if(!e)return;const i=JSON.parse(e);if(!Array.isArray(i))return;for(const t of i){if(!Array.isArray(t)||"string"!=typeof t[0])continue;const e=Number(t[1]);Number.isFinite(e)&&e>0&&this.positions.set(t[0],e)}}catch{}}}function vs(){return{scrollTop:()=>{try{return window.scrollY||document.documentElement?.scrollTop||0}catch{return 0}},scrollTo:t=>{try{window.scrollTo(0,t)}catch{}},scrollToAnchor:t=>{try{const e=document.getElementById(t);return!!e&&(e.scrollIntoView(),!0)}catch{return!1}}}}function ws(t){const e=t.indexOf("#");return e<0?{path:t,hash:""}:{path:t.slice(0,e)||"/",hash:bs(t.slice(e+1))}}function bs(t){try{return decodeURIComponent(t)}catch{return t}}function Ss(t,e,i,s){try{return t.addEventListener(e,i,s),()=>{try{t.removeEventListener(e,i,s)}catch{}}}catch{return()=>{}}}const Ms="motifjs:stack",Cs=30,ks=t=>!!t&&1===t.nodeType&&!!t.style;function As(t,e){const i=t?.motif?.options;if(!i)return!1;const s=i.transition;return!!(("enter"===e?i.transitionIn:i.transitionOut)||s&&(s.classes||s.name&&s.name.length>0))}function Ds(t,e){const i=t?.element;if(t&&!t.isDisposed&&ks(i)){try{i.setAttribute("data-nav-direction",e)}catch{}t.motif.options.transition._markedDirection=!0}}function Es(t){const e=t?.motif?.options?.transition;if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function xs(t){return t.getAttribute("style")}function Ts(t,e){try{t.setAttribute("style",e??""),null===e&&t.removeAttribute("style")}catch{}}function Os(t){const e=[];try{const i=t=>{const i=t.scrollTop||0,s=t.scrollLeft||0;(i||s)&&e.push([t,i,s])};i(t),t.querySelectorAll("*").forEach(i)}catch{}return e}function Ns(t){for(const[e,i,s]of t)try{e.scrollTop=i,e.scrollLeft=s}catch{}}function Ps(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function Ls(t,e,i,s){if("function"!=typeof t.animate||i<=0)return Promise.resolve();try{const n=t.animate(e,{duration:i,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)",fill:"forwards"});return s.push(n),n.finished.then(()=>{},()=>{})}catch{return Promise.resolve()}}function Xs(t,e,i){t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.margin="0px",t.style.boxSizing="border-box";const s=e.getBoundingClientRect(),n=t.getBoundingClientRect();if(t.style.top=s.top-n.top+"px",t.style.left=s.left-n.left+"px",t.style.width=s.width+"px",t.style.height=s.height+"px",t.style.pointerEvents="none",t.style.zIndex=i?"2":"0",!i){let t="";try{t=getComputedStyle(e).position}catch{}t&&"static"!==t||(e.style.position="relative"),e.style.zIndex="1"}}class Is{retainAttached;depth;persist;animation;duration;swipe;session=null;entries=new Map;uris=new Map;loaded=null;current=null;currentTop=null;offs=[];gesture=null;gestureCommitted=!1;awaitingGestureResult=!1;disposed=!1;constructor(t){const e=!0===t?{}:t;this.retainAttached=!0===e.retain,this.depth=Math.max(0,Math.floor(e.depth??5)),this.persist=!0===e.persist,this.animation=e.animation??"none",this.duration=Math.max(0,e.duration??300);const i=e.swipeBack;this.swipe=i?{edge:"object"==typeof i&&"number"==typeof i.edge&&i.edge>0?i.edge:24,threshold:"object"==typeof i&&"number"==typeof i.threshold&&i.threshold>0?i.threshold:.35}:null,this.persist&&this.load(),this.swipe&&this.installSwipe()}get retainedCount(){return this.entries.size}isRetaining(t){return!!t.from&&!!t.to&&t.from.session===t.to.session&&t.to.index>t.from.index}begin(t){const e=t.to;if(e){if(this.session!==e.session){if(this.disposeAllEntries(),this.uris.clear(),this.session=e.session,this.loaded&&this.loaded.session===e.session)for(const[t,e]of this.loaded.uris)this.uris.set(t,e);this.loaded=null}if("push"===t.direction)this.truncate(e.index);else if("replace"===t.direction){const t=this.entries.get(e.index);t&&(this.entries.delete(e.index),this.disposeEntry(t))}}}take(t){if(!t||t.session!==this.session)return null;const e=this.entries.get(t.index);return e?(this.entries.delete(t.index),e.pendingDetach=!1,e):null}retain(t,e,i,s,n,o,r){const a=s[n],c=a.element,l={point:t,uri:e,chain:i.slice(),instances:s.slice(),top:a,topIndex:n,outlet:o,attached:!1,hidden:!1,pendingDetach:!1,saved:null,scroll:ks(c)?Os(c):[]};if(this.retainAttached&&ks(c))l.attached=!0,r||this.hide(l);else if(r)l.pendingDetach=!0;else try{a.parent?.controls.silentDetach(a)}catch{}const h=this.entries.get(t.index);return h&&h!==l&&this.disposeEntry(h),this.entries.set(t.index,l),this.evict(),l}settle(t){if(!t.top.isDisposed&&this.entries.get(t.point.index)===t)if(t.attached)this.hide(t);else if(t.pendingDetach){t.pendingDetach=!1;try{t.top.parent?.controls.silentDetach(t.top)}catch{}}}hide(t){if(!t.attached||t.hidden)return;const e=t.top.element;if(ks(e)){t.saved={style:xs(e),inert:e.hasAttribute("inert"),ariaHidden:e.getAttribute("aria-hidden")};try{e.style.setProperty("display","none","important"),e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")}catch{}t.hidden=!0;try{Qe(t.top)}catch{}}}reveal(t){const e=t.top.element;if(t.hidden&&t.saved&&ks(e)){Ts(e,t.saved.style);try{t.saved.inert||e.removeAttribute("inert"),null===t.saved.ariaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",t.saved.ariaHidden)}catch{}}t.hidden=!1,t.saved=null}restoreScroll(t){Ns(t.scroll)}record(t,e){if(t.to&&t.to.session===this.session){if(this.uris.set(t.to.index,t.uri),"push"===t.direction)for(const e of Array.from(this.uris.keys()))e>t.to.index&&this.uris.delete(e);this.current=t.to}this.currentTop=e,this.save()}describe(){const t=this.current?.index;return Array.from(this.uris.entries()).sort((t,e)=>t[0]-e[0]).map(([e,i])=>({index:e,uri:i,current:e===t,retained:this.entries.has(e)}))}get gestureCommitPending(){return this.gestureCommitted}consumeGestureCommit(){const t=this.gestureCommitted;return this.gestureCommitted=!1,t}traversalSettled(t){if(!this.awaitingGestureResult)return;this.awaitingGestureResult=!1;const e=this.gesture;if(!t)return this.gesture=null,void(this.gestureCommitted=!1);this.gestureCommitted=!1,e&&this.settleGesture(e,!1)}async transition(t,e,i){if(this.consumeGestureCommit())return;if("none"===this.animation||!this.animation)return;if("push"!==t&&"back"!==t&&"forward"!==t)return;const s=e?.element,n=i?.element;if(!(ks(s)&&ks(n)&&s.isConnected&&n.isConnected))return;if(Ps())return;const o="back"===t,r=xs(s),a=xs(n),c=[];try{if(Xs(n,s,o),"function"==typeof this.animation){const e={direction:t,entering:s,leaving:n};await this.animation(e)}else{const t=this.duration;o?await Promise.all([Ls(n,[{transform:"translateX(0)"},{transform:"translateX(100%)"}],t,c),Ls(s,[{transform:"translateX(-30%)"},{transform:"translateX(0)"}],t,c)]):await Promise.all([Ls(s,[{transform:"translateX(100%)"},{transform:"translateX(0)"}],t,c),Ls(n,[{transform:"translateX(0)"},{transform:"translateX(-30%)"}],t,c)])}}catch(t){b("MJX308",t)}finally{for(const t of c)try{t.cancel()}catch{}Ts(s,r),Ts(n,a)}}async disposeEntry(t){const e=t.top;if(e&&!e.isDisposed)try{await Mi(e)}catch(t){b("MJX307",t)}}async dispose(){if(!this.disposed){this.disposed=!0;for(const t of this.offs.splice(0))try{t()}catch{}this.gesture&&(this.endGestureListeners(this.gesture),this.gesture=null),await this.disposeAllEntries(),this.uris.clear(),this.current=null,this.currentTop=null}}async disposeAllEntries(){const t=Array.from(this.entries.values());this.entries.clear();for(const e of t)await this.disposeEntry(e)}truncate(t){for(const[e,i]of Array.from(this.entries))e>=t&&(this.entries.delete(e),this.disposeEntry(i))}evict(){for(;this.entries.size>this.depth;){let t=1/0;for(const e of this.entries.keys())e<t&&(t=e);const e=this.entries.get(t);this.entries.delete(t),e&&this.disposeEntry(e)}}load(){try{if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(Ms);if(!t)return;const e=JSON.parse(t);if(!e||"string"!=typeof e.session||!Array.isArray(e.uris))return;const i=[];for(const t of e.uris)Array.isArray(t)&&"number"==typeof t[0]&&"string"==typeof t[1]&&i.push([t[0],t[1]]);this.loaded={session:e.session,uris:i}}catch{}}save(){if(this.persist&&this.session)try{if("undefined"==typeof sessionStorage)return;sessionStorage.setItem(Ms,JSON.stringify({session:this.session,uris:Array.from(this.uris.entries())}))}catch{}}installSwipe(){if("undefined"==typeof document)return;const t=t=>this.onTouchStart(t);try{document.addEventListener("touchstart",t,{passive:!0}),this.offs.push(()=>{try{document.removeEventListener("touchstart",t)}catch{}})}catch{}}onTouchStart(t){if(this.disposed||this.gesture||this.awaitingGestureResult||!this.swipe)return;if(!t.touches||1!==t.touches.length)return;const e=t.touches[0];if(!e||e.clientX>this.swipe.edge)return;if(!this.current||this.current.index<=0)return;const i=this.currentTop?.element;if(!ks(i)||!i.isConnected)return;const s={startX:e.clientX,startY:e.clientY,lastX:e.clientX,samples:[[e.clientX,Date.now()]],dragging:!1,width:0,top:i,topSaved:null,under:null,underSaved:null,offs:[]},n=t=>this.onTouchMove(s,t),o=()=>this.onTouchEnd(s);try{document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",o),document.addEventListener("touchcancel",o),s.offs.push(()=>{try{document.removeEventListener("touchmove",n)}catch{}try{document.removeEventListener("touchend",o)}catch{}try{document.removeEventListener("touchcancel",o)}catch{}})}catch{}this.gesture=s}endGestureListeners(t){for(const e of t.offs.splice(0))try{e()}catch{}}beginDrag(t){t.dragging=!0,t.width=t.top.getBoundingClientRect().width||("undefined"!=typeof window?window.innerWidth:0)||1,t.topSaved=xs(t.top);const e=this.current,i=e?this.entries.get(e.index-1)??null:null;if(i&&i.attached&&ks(i.top.element)&&i.top.element.isConnected){const e=i.top.element;t.under=i,t.underSaved=xs(e),i.saved&&Ts(e,i.saved.style),Xs(e,t.top,!1),e.style.transform="translateX(-30%)",Ns(i.scroll)}t.top.style.willChange="transform"}applyDrag(t,e){const i=Math.min(1,Math.max(0,e/t.width));t.top.style.transform=`translateX(${Math.max(0,e)}px)`,t.under&&(t.under.top.element.style.transform=`translateX(-${Cs*(1-i)}%)`)}onTouchMove(t,e){const i=e.touches&&e.touches[0];if(!i)return;const s=i.clientX-t.startX,n=i.clientY-t.startY;if(!t.dragging){if(Math.abs(s)<8&&Math.abs(n)<8)return;if(s<=0||Math.abs(n)>Math.abs(s))return this.endGestureListeners(t),void(this.gesture=null);this.beginDrag(t)}if(e.cancelable)try{e.preventDefault()}catch{}const o=Date.now();for(t.lastX=i.clientX,t.samples.push([i.clientX,o]);t.samples.length>2&&o-t.samples[0][1]>100;)t.samples.shift();this.applyDrag(t,s)}onTouchEnd(t){if(this.endGestureListeners(t),!t.dragging)return void(this.gesture=null);const e=t.lastX-t.startX,i=e/t.width,s=t.samples[0],n=t.samples[t.samples.length-1],o=n&&s?n[1]-s[1]:0,r=n?Date.now()-n[1]:1/0,a=o>=16&&r<=50?(n[0]-s[0])/o:0,c=i>this.swipe.threshold||a>.5&&e>0;this.settleGesture(t,c)}async settleGesture(t,e){const i=[],s=t.top,n=t.under?t.under.top.element:null,o=Ps()?0:Math.max(0,Math.round(.6*this.duration)),r=s.style.transform||"translateX(0px)",a=n?.style.transform||"translateX(-30%)";if(e){await Promise.all([Ls(s,[{transform:r},{transform:"translateX(100%)"}],o,i),n?Ls(n,[{transform:a},{transform:"translateX(0)"}],o,i):Promise.resolve()]),s.style.transform="translateX(100%)",n&&(n.style.transform="translateX(0px)");for(const t of i)try{t.cancel()}catch{}this.gestureCommitted=!0,this.awaitingGestureResult=!0;try{window.history.back()}catch{this.traversalSettled(!0)}}else{await Promise.all([Ls(s,[{transform:r},{transform:"translateX(0)"}],o,i),n?Ls(n,[{transform:a},{transform:"translateX(-30%)"}],o,i):Promise.resolve()]);for(const t of i)try{t.cancel()}catch{}Ts(s,t.topSaved),n&&t.under&&Ts(n,t.underSaved),this.gesture===t&&(this.gesture=null)}}}class Rs{source;constructor(t){this.source=t,this.tokens=[]}currentColumn=0;tokens=[];addToken(t){this.tokens.push(t)}parse(){for(this.source.startsWith("/")||(this.source="/"+this.source);this.source.length>1&&this.source.endsWith("/");)this.source=this.source.slice(0,-1);var t="static",e=-1,i=0,s=-1;for(this.tokens=[],this.currentColumn=0;this.currentColumn<this.source.length;){var n=this.codePointAt(this.source,this.currentColumn),o=this.tokens[e];switch(n){case 47:s++,(void 0===o||o.input.length>1)&&(this.tokens.push({default:"",input:"/",isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:i,sectionIndex:s}),e=this.tokens.length-1);break;case 123:i++;let n,r,a=!1,c=!1;if(this.tokens.length>0){const t=this.tokens[this.tokens.length-1];t&&"static"===t.type&&"/"===t.input&&!t.consumed?(a=!0,n=this.tokens.length-1):t&&"static"===t.type&&"/"!==t.input&&t.sectionIndex===s&&!t.consumed&&(c=!0,r=this.tokens.length-1)}this.tokens.push({default:void 0,input:"",isOptinal:!1,regexs:[],type:"parameter",parameterName:"",parameterIndex:i,sectionIndex:s,hasLeadingSlash:a,leadingSlashTokenIndex:n,hasLeadingStatic:c,leadingStaticTokenIndex:r}),e=this.tokens.length-1,t="parameter";break;case 125:t="static",e=-1;break;case 58:t="defaultValue";break;case 63:o&&(o.isOptinal=!0);break;default:const l=this.source[this.currentColumn];o?"parameter"===t?o.parameterName=`${o.parameterName+l}`:"defaultValue"===t?o.default=`${(o.default??"")+l}`:"static"===o.type?o.input=`${o.input+l}`:(this.tokens.push({default:void 0,input:l,isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:i,sectionIndex:s}),e=this.tokens.length-1):(this.tokens.push({default:void 0,input:l,isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:i,sectionIndex:s}),e=this.tokens.length-1)}this.currentColumn++}const r=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(const t of this.tokens){if("parameter"===t.type&&t.isOptinal&&t.hasLeadingSlash&&"number"==typeof t.leadingSlashTokenIndex){const e=this.tokens[t.leadingSlashTokenIndex];e&&"static"===e.type&&"/"===e.input&&(e.consumed=!0)}if("parameter"===t.type&&t.isOptinal&&t.hasLeadingStatic&&"number"==typeof t.leadingStaticTokenIndex){const e=this.tokens[t.leadingStaticTokenIndex];e&&"static"===e.type&&e.input&&e.sectionIndex===t.sectionIndex&&(e.consumed=!0)}}const a=t=>{const e=this.tokens[t];for(let i=t+1;i<this.tokens.length;i++){const t=this.tokens[i];if("static"===t.type&&t.sectionIndex===e.sectionIndex&&t.input&&"/"!==t.input)return t.input[0];if("static"===t.type&&"/"===t.input)break}},c=(t,e)=>{const i=a(t);var s;return`(${i?`[^${s=r(i),s.replace(/[\\\]\^\-]/g,"\\$&")}]`:"[\\w\\d\\_\\-\\%\\&\\$\\+\\#\\,\\.\\{\\}\\(\\)\\[\\]\\?\\:\\=\\;\\'\\\"\\~\\\\]"}${e?"{0,255}":"{1,255}"})`};let l="^";for(let t=0;t<this.tokens.length;){const e=this.tokens[t];if("static"===e.type&&"/"===e.input){e.consumed||(l+="/"),t++;continue}const i=t;let s=t;for(;s<this.tokens.length;){const t=this.tokens[s];if("static"===t.type&&"/"===t.input&&s!==i)break;if("static"===t.type&&"/"===t.input&&s===i){s++;break}s++}const n={};let o=i;for(;o<s;){if(n[o]){o++;continue}const t=this.tokens[o];if("static"!==t.type){if(t.isOptinal&&!t.hasLeadingStatic){const e=o;let i=!1;for(let t=e+1;t<s;t++){const e=this.tokens[t],s=this.tokens[t+1];if(e&&"static"===e.type&&s&&"parameter"===s.type&&s.isOptinal&&s.hasLeadingStatic&&"number"==typeof s.leadingStaticTokenIndex&&s.leadingStaticTokenIndex===t){i=!0;break}if(e&&"static"===e.type&&"/"===e.input)break}let a="";t.hasLeadingSlash&&(a+="/"),a+=c(e,!i),n[e]=!0;let h=e+1;for(;h<s;){const t=this.tokens[h];if("static"===t.type&&this.tokens[h+1]&&"parameter"===this.tokens[h+1].type){const e=this.tokens[h+1];if(e.isOptinal&&e.hasLeadingStatic&&"number"==typeof e.leadingStaticTokenIndex&&e.leadingStaticTokenIndex===h){a+=`(?:${r(t.input)}${c(h+1,!0)})?`,n[h]=!0,n[h+1]=!0,h+=2;continue}}break}l+=`(?:${a})?`,o=h;continue}{const e=c(o,t.isOptinal);if(t.isOptinal)if(t.hasLeadingSlash)l+=`(?:/${e})?`;else if(t.hasLeadingStatic&&"number"==typeof t.leadingStaticTokenIndex){const i=this.tokens[t.leadingStaticTokenIndex];l+=`(?:${i&&"static"===i.type?r(i.input):""}${e})?`}else l+=`(?:${e})?`;else l+=e;n[o]=!0,o++}}else t.consumed||(l+=r(t.input)),n[o]=!0,o++}t=s}return l+="$",new RegExp(l,"i")}parameters={};exist(t,e){const i=t.indexOf("#"),s=i>=0?t.substring(0,i):t;let n=s,o="";const r=s.indexOf("?");for(r>=0&&(n=s.substring(0,r),o=s.substring(r+1));n.length>1&&n.endsWith("/");)n=n.slice(0,-1);var a=this.parse().exec(n);if(a){a&&a.length;var c=[];if(this.parameters={},a?.forEach((t,e)=>{c.push(t)}),o&&o.length){const t=new URLSearchParams(o),e=new Map;t.forEach((t,i)=>{const s=e.get(i)||[];s.push(t),e.set(i,s)}),e.forEach((t,e)=>{1===t.length?this.parameters[e]=t[0]:this.parameters[e]=t})}else if(e){const t=new URLSearchParams(e),i=new Map;t.forEach((t,e)=>{const s=i.get(e)||[];s.push(t),i.set(e,s)}),i.forEach((t,e)=>{1===t.length?this.parameters[e]=t[0]:this.parameters[e]=t})}if(a.input===c[0])return a?.forEach((t,e)=>{if(0!==e){var i=this.tokens.find(t=>t.parameterIndex==e);if(i){let e=t;if((void 0===e||""===e)&&i.isOptinal){e=void 0===i.default||""===i.default?void 0:i.default}this.parameters[i.parameterName]=void 0===e?void 0:e}}}),!0}return!1}codePointAt=String.prototype.codePointAt?(t,e)=>t.codePointAt(e):function(t,e){const i=t.length;if(e<0||e>=i)return;const s=t.charCodeAt(e);if(s>=55296&&s<=56319&&i>e+1){const i=t.charCodeAt(e+1);if(i>=56320&&i<=57343)return 1024*(s-55296)+i-56320+65536}return s}}function Js(t){let e=0,i=0;for(const s of(t||"").split("/"))s&&(s.startsWith("{")&&s.endsWith("}")?i++:e++);return{statics:e,params:i}}function Fs(t,e){const i=t.chain.length-e.chain.length;if(0!==i)return i;const s=Js(t.fullPath),n=Js(e.fullPath);return s.statics!==n.statics?n.statics-s.statics:s.params!==n.params?s.params-n.params:e.fullPath.length-t.fullPath.length}class Hs{routes;records=[];routesMap=new Map;constructor(t){this.routes=t,this.build()}build(){this.records=[],this.routesMap.clear();for(const t of this.routes)this.walk([],"",t);this.records.sort(Fs)}walk=(t,e,i,s=!1)=>{const n=this.joinPaths(e,i.path);if(!s){const t=i.fullPath;(null==t||"string"==typeof t&&""===t.trim())&&(i.fullPath=n),null!=i.name&&this.routesMap.set(i.name,i)}const o=[...t,i],r=[{path:n,isAlias:s},...(null==i.alias?[]:Array.isArray(i.alias)?i.alias:[i.alias]).map(t=>({path:this.joinPaths(e,t),isAlias:!0}))];for(const t of r)if(this.records.push({fullPath:t.path,chain:o,leaf:i,scanner:new Rs(t.path),aliasOf:t.isAlias?i.fullPath??null:null}),i.childs&&i.childs.length)for(const e of i.childs)this.walk(o,t.path,e,t.isAlias)};joinPaths(t,e){e=e||"";const i=(t=t||"")&&"/"!==t&&t.endsWith("/")?t.slice(0,-1):t;if("/"===e)return i||"/";const s=e?e.startsWith("/")?e:"/"+e:"";return i&&"/"!==i?i+s:s||"/"}}class js{stack=null;_revealed=new Set;root;application;routingModule;_previousPath=null;_previousInstances=[];register(t,e,i){this.root=t,this.application=e,this.routingModule=i}controlCache=new Map;async evict(t){const e=t?[t]:Array.from(this.controlCache.keys());for(const t of e){const e=this.controlCache.get(t);if(e&&!e.isDisposed){if(!this._previousInstances.includes(e)){this.controlCache.delete(t);try{await e.dispose()}catch(t){b("MJX307",t)}}}else this.controlCache.delete(t)}}async dispose(){this._navVersion++,this._previousPath=null,this._previousInstances=[],this._revealed.clear();const t=this.stack;if(this.stack=null,t)try{await t.dispose()}catch{}await this.evict()}generatePathString(t,e){const i=t.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}")){const i=t.slice(1,-1);let[s,n]=i.split(":");s.endsWith("?")&&(s=s.slice(0,-1));const o=e[s];return null!=o&&""!==o?String(o):n??""}return t}).filter(t=>""!==t).join("/");return t.startsWith("/")?"/"+(i||""):i}_navVersion=0;_pendingActivate=new Set;async execute(t,e,i){i??={target:t,chain:t.chain.map(e=>this.generatePathString(e.path,t.params)||""),direction:void 0,state:void 0};const s=this._rootProvider(),n={provider:s,scope:s?._beginNavigation(),route:i,committed:!1,suppressed:[]};try{await this._execute(t,e,n)}finally{!n.committed&&n.scope&&s._abandonNavigation(n.scope);for(const t of n.suppressed)t.isDisposed||(t.motif.options.transition._suppressEnter=!1)}}_commitNavigation(t){t.committed||(t.committed=!0,t.scope&&t.provider._commitNavigation(t.scope),this.application?._routerState.commit(t.route))}async _execute(t,e,i){const s=++this._navVersion,n=this.stack&&e&&e.to?this.stack:null;n&&n.begin(e);const o=n?n.take(e.to):null,r=new Array(t.chain.length),a=!(!this._previousPath||this._previousPath.route!==t.route||null==this._previousPath.route&&this._previousPath.fullPath!==t.fullPath);var c=!(!this._previousPath||this._previousPath.uri!==t.uri);let l=!1;if(a&&t.route){const e=this._previousPath.params||{},i=t.params||{};let s=!1;const o=new Set([...Object.keys(e),...Object.keys(i)]);for(const t of o)if(e[t]!==i[t]){s=!0;break}if(s){l=!0;const s=t.route;if(s&&!s.keepAlive&&this.controlCache.has(s))if(n)this.controlCache.delete(s);else{const t=this.controlCache.get(s);if(t&&"function"==typeof t.dispose&&!t.isDisposed)try{await t.dispose()}catch{}this.controlCache.delete(s)}try{const s=this.routingModule.getHooks?.()||void 0,n=t.route.onUpdate||s?.onUpdate;if(n){const s={from:{path:this._previousPath.uri||this._previousPath.fullPath||"",params:e},to:{path:t.uri||t.fullPath||"",params:i},meta:t.meta??t.extend};await n(s)}}catch(t){b("MJX306",t,"onUpdate")}}}if((!a||l)&&t.route)try{const e=t.meta??t.extend,i={path:t.uri||t.fullPath||"",params:t.params,meta:e,to:{path:t.uri||t.fullPath||"",params:t.params,meta:e}},s=this.routingModule.getHooks?.()||void 0,n=t.route.onEntering||s?.onEntering;n&&await n(i)}catch(t){b("MJX306",t,"onEntering")}const h=[];for(let e=0;e<t.chain.length;e++){const s=t.chain[e],n=o&&o.chain[e]===s?o.instances[e]:void 0;if(!n||n.isDisposed||s.keepAlive)if(this.controlCache.has(s)){let t=this.controlCache.get(s);if(!t||t.isDisposed){this.controlCache.delete(s);const t=this.createInstance(s.control,i.scope,i.route).then(t=>{this.controlCache.set(s,t),r[e]=t});h.push(t)}else r[e]=t,s.keepAlive&&!this._previousInstances.includes(t)&&this._pendingActivate.add(t)}else{const t=this.createInstance(s.control,i.scope,i.route).then(t=>{this.controlCache.set(s,t),r[e]=t});h.push(t)}else r[e]=n,this.controlCache.set(s,n)}h.length&&await Promise.all(h);let u=null,d=null;const p=this._previousInstances;if(n){const i=!!n.animation&&"none"!==n.animation&&("push"===e.direction||"back"===e.direction||"forward"===e.direction);if(d={animate:i,pages:!i&&!n.gestureCommitPending,direction:e.direction},u=await this._stackLeave(t.chain,r,e,n,d),o){const t=o.top;!t.isDisposed&&o.outlet&&t.parent===o.outlet&&(n.reveal(o),o.outlet.current=t,o.outlet.previouspage=t,this._revealed.add(t)),t.isDisposed||this._pendingActivate.add(t)}}else await this.disposeFromDivergencePoint(t.chain,r);const f=d?r.filter(t=>t&&!p.includes(t)):[];if(d){for(const t of p)Es(t);for(const t of f)d.pages?Ds(t,d.direction):(t.motif.options.transition._suppressEnter=!0,i.suppressed.push(t))}if(s===this._navVersion&&this._commitNavigation(i),await this.mountChain(r,t.chain,this.root,s),d?.pages){o?.attached&&!o.top.isDisposed&&As(o.top,"enter")&&o.top.motif.options.transition.enterTransition(()=>{});for(const t of f)t.isBuilt&&!As(t,"enter")&&Es(t)}let m=null;if(n){o&&n.restoreScroll(o);for(let t=0;t<r.length;t++)if(r[t]&&r[t]!==p[t]){m=r[t];break}m||(m=r.length?r[r.length-1]:null),n.record(e,m)}if(!c&&t.route)try{const e=t.meta??t.extend,i={path:t.uri||t.fullPath||"",params:t.params,meta:e,to:{path:t.uri||t.fullPath||"",params:t.params,meta:e}},s=this.routingModule.getHooks?.()||void 0,n=t.route?.onEnter||s?.onEnter;n&&await n(i)}catch(t){b("MJX306",t,"onEnter")}if(this._previousPath=t,this._previousInstances=r.slice(),n&&u){u.top&&s===this._navVersion&&(u.retained||u.disposeAfter.length)&&await n.transition(e.direction,m,u.top),u.retained&&n.settle(u.retained);for(const t of u.disposeAfter)try{t.isDisposed||await t.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){b("MJX307",t)}}}async _stackLeave(t,e,i,s,n){const o={top:null,retained:null,disposeAfter:[]},r=this._previousPath?.chain??[],a=this._previousInstances;if(!a.length)return o;let c=-1;for(let t=0;t<a.length;t++){const i=a[t];if(i&&!e.includes(i)){c=t;break}}if(c<0)return o;a[c].isDisposed||fe(a[c]);const l=t=>{const e=t-1>=0?a[t-1]:this.root,i=r[t]?.extend?.targetOutlet||"default";try{return e&&!e.isDisposed?this.findRouterView(e,i):null}catch{return null}},h=a[c],u=r[c];if(s.isRetaining(i)&&h&&!h.isDisposed&&!u?.keepAlive){const t=l(c);t&&t.current===h&&(t.current=null,t.previouspage=null),Si(h),n.pages&&As(h,"leave")&&(Ds(h,n.direction),await(d=h,new Promise(t=>{let e=!1;const i=()=>{e||(e=!0,t())};try{const t=d.motif.options.transition.leaveTransition(i);t&&"function"==typeof t.addEventListener&&t.addEventListener("cancel",i)}catch{i()}})),Es(h));for(let t=c;t<a.length;t++){const e=r[t];e&&!e.keepAlive&&this.controlCache.get(e)===a[t]&&this.controlCache.delete(e)}return o.top=h,o.retained=s.retain(i.from,this._previousPath?.uri??"",r,a,c,t,n.animate),o}var d;const p=n.animate&&!!h&&!h.isDisposed&&!u?.keepAlive;for(let t=a.length-1;t>=c;t--){const i=a[t],s=r[t];if(i&&!e.includes(i))if(i.isDisposed)s&&this.controlCache.get(s)===i&&this.controlCache.delete(s);else if(p&&t>c&&!s?.keepAlive)s&&this.controlCache.get(s)===i&&this.controlCache.delete(s);else try{const e=l(t);if(e&&e.current===i&&(e.current=null,e.previouspage=null),s?.keepAlive){Si(i);try{i.parent?.controls.silentDetach(i)}catch{}this.controlCache.has(s)||this.controlCache.set(s,i),Qe(i)}else s&&this.controlCache.get(s)===i&&this.controlCache.delete(s),p&&t===c?(o.top=i,o.disposeAfter.push(i)):n.pages?(Ds(i,n.direction),await i.dispose()):await i.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){b("MJX307",t)}}return o}async disposeFromDivergencePoint(t,e){if(!this._previousPath||!this._previousInstances.length)return;const i=this._previousPath.chain,s=this._previousInstances;let n=0;const o=Math.min(i.length,t.length);for(let e=0;e<o&&i[e]===t[e];e++)n=e+1;for(let t=s.length-1;t>=n;t--){const e=s[t],n=i[t];if(e&&!e.isDisposed)try{const i=t-1,o=i>=0?s[i]:this.root,r=n?.extend?.targetOutlet||"default",a=this.findRouterView(o,r);if(a&&a.current===e&&(a.current=null,a.previouspage=null),n?.keepAlive){Si(e);try{e.parent?.controls.silentDetach(e)}catch{}this.controlCache.has(n)||this.controlCache.set(n,e),Qe(e)}else this.controlCache.get(n)===e&&this.controlCache.delete(n),await e.dispose()}catch(t){b("MJX307",t)}else n&&this.controlCache.get(n)===e&&this.controlCache.delete(n)}}_construct(t,e,i){const s=this.application?._routerState;return function(t,e){const i=ie;ie=t??null;try{return e()}finally{ie=i}}(t,()=>s?s.constructWith(e,i):i())}async parseControl(t,e,i){var s=this._construct(e,i,()=>this._resolveFrom(e,t));if(s)return s;let n=t;return n instanceof Promise&&(n=await n.then(t=>t.default?t.default:t)),(s=this._construct(e,i,()=>this._resolveFrom(e,n)))||("function"==typeof n?this.parseControl(this._construct(e,i,()=>ti(n,this.application)),e,i):n)}_resolveFrom(t,e){const i=t??this._rootProvider();return i&&i.getAllServices().getDescriptor(e)?i.get(e):null}_rootProvider(){try{return this.application?.provider??Gs.main?.provider}catch{return}}async createInstance(t,e,i){return await this._instanceCreator(t,e,i)}async _instanceCreator(t,e,i){return await this.parseControl(t,e,i)}async activator(t){}pendingMount=new WeakMap;pendingListeners=new WeakMap;static OUTLET_WARN_MS=3e3;async mountChain(t,e,i,s){for(let n=0;n<t.length;){if(s!==this._navVersion)return;let o=t[n];o?.isDisposed&&(o=await this.createInstance(e[n].control,this._rootProvider()?._currentScope()),t[n]=o);const r=e[n]&&e[n].extend&&e[n].extend.targetOutlet||"default",a=this.findRouterView(i,r);if(!a||!i.isBuilt)return void this._waitForOutlet(i,t.slice(n),e.slice(n),s,r);const c=this._revealed.delete(o),l=a.current===o&&!c;await a.navigate(o),this._pendingActivate.delete(o)&&Ye(o);const h=e[n]?.onShow;h&&!l&&a.current===o&&s===this._navVersion&&S(()=>h(o),"MJX306","onShow"),i=o,n++}}_waitForOutlet(t,e,s,n,o){const r=this.pendingListeners.get(t);if(r){try{r()}catch{}this.pendingListeners.delete(t)}let a,c=!1;const l=async(i,o)=>{c||(h(),n===this._navVersion&&await this.mountChain(e,s,t,n))},h=()=>{if(!c){c=!0,this.pendingListeners.delete(t);try{t.motif?.off?.(fs,l)}catch{}if(void 0!==a){try{clearTimeout(a)}catch{}a=void 0}}};t.motif.on(fs,l),this.pendingListeners.set(t,h),i.isDevelopment()&&(a=setTimeout(()=>{c||n!==this._navVersion||M("MJX301",[o,js.OUTLET_WARN_MS])},js.OUTLET_WARN_MS))}findRouterView(t,e="default"){const i=(t.controls?.items||[]).slice();for(;i.length;){const t=i.shift();if(t&&!t.isDisposed){if(t.__isRouterView){const i=t;if((i.props.name||"default")===e)return i}if(t.controls&&t.controls.items&&t.controls.items.length)for(const e of t.controls.items)i.push(e)}}if(!e||"default"===e)return null;const s="function"==typeof t.scopeId?t.scopeId():t.scopeId??"";var n=ps.find(e,s);if(n)return n;let o=t,r=o?.parent;for(;r;){const t=(r.controls?.items||[]).filter(t=>t!==o).slice();for(;t.length;){const i=t.shift();if(i&&!i.isDisposed){if(i.__isRouterView){const t=i;if((t.props.name||"default")===e)return t}if(i.controls&&i.controls.items&&i.controls.items.length)for(const e of i.controls.items)t.push(e)}}o=r,r=r.parent}return null}}class Bs extends ii{constructor(t){super(t.el??"a",t),!1!==t.showHref&&this.attr.add({href:t.to}),t.target&&this.attr.add({target:t.target}),this.motif.on("click",(e,i)=>{if(t.bypass)return;if(t.target&&"_self"!==t.target)return;if(i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;i.preventDefault();const s=Gs.main.router;s&&s.navigate(t.to)}),this.childs&&this.childs.length?this.controls.add(...this.childs):null!=t.text&&this.attr.add({textContent:t.text})}onBuilt(t,e){this.motif.options.enableRouterClassing={to:"all",path:this.props.to,activeClass:this.props.activeClass,exactClass:this.props.exactClass,onActive:this.props.onActive,offActive:this.props.offActive,onExact:this.props.onExact,offExact:this.props.offExact}}}const zs=t=>t.split("#")[0].split("?")[0],Vs=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36);class Ws{static MAX_REDIRECTS=10;_routerOptions;routingEngine;routeCollection;routesMap=new Map;mainApp;application;_suppressBeforeEachOnce=!1;_suppressMiddlewaresOnce=!1;_scroll=null;constructor(t,e){this._routerOptions=t,this.routeCollection=new Hs(t.RouteItems),this.routingEngine=new js,this.application=e,this._installLinkInterceptor();const i=t.scrollMemory;i&&(this._scroll=new ys(!0===i?{}:i),this._scroll.locationAnchor="history"===this._addressMode()),t.stack&&"shell"!==t.mode&&(this._stack=new Is(t.stack),this.routingEngine.stack=this._stack)}_stack=null;getHooks(){return this._routerOptions.hooks}_windowNavListener=null;start(t,e){this.mainApp=t,this.routingEngine.register(this.mainApp,this.application,this);const i="shell"===this._routerOptions.mode?e??"/":this._getCurrentUri();this._seedHistoryIndex(),this._suppressMiddlewaresOnce=!0,this.navigate(i),"shell"!==this._routerOptions.mode&&(this._windowNavListener=()=>{this._onHistoryTraversal()},window.addEventListener("hash"===this._routerOptions.mode||"file"===this._routerOptions.mode?"hashchange":"popstate",this._windowNavListener))}get shownUri(){return this._previousRoute?this._currentUri:void 0}_getCurrentUri(){try{const t=window,e=this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history");if("hash"===e||"file"===e){const e=t?.location?.hash||"";return e&&e.startsWith("#")&&e.slice(1)||"/"}return(t?.location?.pathname||"/")+(t?.location?.search||"")}catch{return"/"}}static HISTORY_STAMP_KEY="__motifHistory";_historyStamp=null;_addressMode(){const t=window;return this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history")}_readHistoryStamp(){try{const t=window?.history?.state,e=t&&"object"==typeof t?t[Ws.HISTORY_STAMP_KEY]:null;if(e&&"object"==typeof e&&"number"==typeof e.index&&Number.isFinite(e.index)&&"string"==typeof e.session)return{index:e.index,session:e.session}}catch{}return null}static _isPlainObject(t){if(!t||"object"!=typeof t)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}_withHistoryStamp(t,e){return null==t?{[Ws.HISTORY_STAMP_KEY]:e}:Ws._isPlainObject(t)?{...t,[Ws.HISTORY_STAMP_KEY]:e}:t}_routerState(t,e){return t?this._withHistoryStamp(t,{...e,hasState:!0}):this._withHistoryStamp(null,e)}_userStateOf(t){if(null==t)return;if(!Ws._isPlainObject(t))return t;const e=Ws.HISTORY_STAMP_KEY;if(!(e in t))return t;const i=t[e];if(!i||!0!==i.hasState)return;const{[e]:s,...n}=t;return n}_currentHistoryUserState(){if("shell"!==this._addressMode())try{return this._userStateOf(window?.history?.state)}catch{return}}_nextHistoryStamp(t){const e=this._historyStamp;return e?{index:t?e.index+1:e.index,session:e.session}:{index:0,session:Vs()}}_stampCurrentEntry(t,e){try{const i=window;if(!i?.history||"function"!=typeof i.history.replaceState)return;const s=i.history.state;let n;if(e)n=this._routerState(e,t);else{const e=Ws._isPlainObject(s)&&Object.keys(s).length>0;n=this._withHistoryStamp(s,e?{...t,hasState:!0}:t)}n!==s&&i.history.replaceState(n,"")}catch{}}_seedHistoryIndex(){if("shell"===this._addressMode())return;const t=this._readHistoryStamp();if(t)return void(this._historyStamp=t);const e={index:0,session:Vs()};this._stampCurrentEntry(e),this._historyStamp=e}_pendingTraversal=null;async _onHistoryTraversal(){const t=this._historyStamp,e=this._readHistoryStamp();this._historyStamp=e;let i,s="traverse";t&&e&&t.session===e.session&&t.index!==e.index&&(s=e.index<t.index?"back":"forward"),this._pendingTraversal={direction:s,state:this._currentHistoryUserState(),from:t};try{i=await this.navigate(this._getCurrentUri())}finally{this._pendingTraversal=null}const n=!!i&&!0===i.cancelled;try{this._stack?.traversalSettled(n)}catch{}if(!n)return;const o=this._readHistoryStamp();if(this._historyStamp=o,!t||!o||o.session!==t.session)return;const r=t.index-o.index;if(0!==r)try{window.history.go(r)}catch{}}_currentUri="___startup___";_previousRoute=null;get currentUri(){return this._currentUri}async navigate(t,e){const s=this._pendingTraversal;return this._pendingTraversal=null,await(n=async()=>{try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-start",{uri:t})}catch{}const i=this._suppressBeforeEachOnce;i&&(this._suppressBeforeEachOnce=!1);const n=this._suppressMiddlewaresOnce;n&&(this._suppressMiddlewaresOnce=!1);const o=e||{},r=o.force||!1;if(t===this._currentUri&&!r)return{ok:!0,skipped:!0,uri:t};let a;if(a=n?{proceed:!0,uri:t}:await this._runMiddlewares(t),!a.proceed)return{ok:!1,uri:a.uri,cancelled:!0,reason:"middleware"};t=a.uri;let c,l,h=this.resolve(t),u="";if(h.ok&&h.route?.redirect){const e=t,i=[e];for(;h.ok&&h.route?.redirect;){const e=this._resolveRedirect(h,t);if(!e)break;if(i.length>Ws.MAX_REDIRECTS||i.some(t=>zs(t)===zs(e))){u=[...i,e].join(" → "),l=w("MJX303",u);break}i.push(e),t=e,h=this.resolve(t)}if(l)M("MJX303",[u]),t=e,h=this._buildFallbackResult(t,"error",{path:t,error:l});else if(t!==e&&(c=e,t===this._currentUri&&!r))return{ok:!0,skipped:!0,uri:t}}const d=!this._previousRoute,p=d?"initial":s?s.direction:o.replace?"replace":"push",f=s?s.state:d&&void 0===o.state?this._currentHistoryUserState():o.state||void 0,m={path:h.uri||t,params:h.params,meta:h.meta??h.extend,options:e,redirectedFrom:c,direction:p,state:f},_=this._previousRoute?{path:this._previousRoute.path,params:this._previousRoute.params,meta:this._previousRoute.meta,options:this._previousRoute.options}:null;if(this._previousRoute&&this._previousRoute.routeItem){const t=this._previousRoute.routeItem.onLeave||this._routerOptions.hooks?.onLeave;if(t)try{const e={from:{path:this._previousRoute.path,params:this._previousRoute.params,meta:this._previousRoute.meta},to:m},i=await t(e);if(!1===i)return{ok:!1,cancelled:!0,reason:"onLeave"};if(i&&"object"==typeof i&&!0===i.cancel)return{ok:!1,cancelled:!0,reason:i.reason||"onLeave"}}catch(t){b("MJX306",t,"onLeave")}}let g=!0;if(i||(g=await this.application._runBeforeEachGuards(m,_)),!1===g)return{ok:!1,cancelled:!0,reason:"guard"};if("string"==typeof g){const i=this._addressShows(t,c);return await this.navigate(g,i?{...o,replace:!0}:e)}const y=t=>({target:t,chain:t.chain.map(e=>this.routingEngine.generatePathString(e.path,t.params)||""),direction:p,state:f});h.ok||l||(h=this._buildFallbackResult(t,"notFound",{path:t})),this._currentUri=t,this._previousRoute={path:h.uri,params:h.params,meta:h.meta??h.extend,routeItem:h.route};let v=h.uri;this._scroll?.leaving();const S=s?s.from:this._historyStamp;try{const t=!!c&&this._addressShows(c);this._applyUrl(v,t?{...o,replace:!0}:o)}catch{}const C=this._stack?{direction:p,from:S,to:this._historyStamp,uri:v}:void 0;try{await this.routingEngine.execute(h,C,y(h))}catch(e){b("MJX304",e),h=this._buildFallbackResult(t,"error",{path:t,error:e});try{await this.routingEngine.execute(h,C,y(h))}catch(t){b("MJX305",t)}}this._stack&&this.application._routerState.touch(),o.scroll?this._handleScrollBehavior(o.scroll):this._scroll?.arrived(this._uriWithHash(v,t)),this.application.fire?.("motifjs-router-navigated",{uri:v,params:h.params,meta:h.meta??h.extend,route:h.ok?h.route:null,ok:h.ok,initial:d,redirectedFrom:c,direction:p,state:f});try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-end",{uri:v,params:h.params})}catch{}return h},o="UrlRoutingModule.navigate",i.safeCallSilentAsync(n,o));var n,o}describeStack(){return this._stack?this._stack.describe():void 0}routeInfos(){const t=[],e=(i,s)=>{const n=[...s,i];t.push({fullPath:i.fullPath||i.path,name:i.name??null,meta:i.meta??i.extend??{},route:i,chain:n});for(const t of i.childs||[])e(t,n)};for(const t of this.routeCollection?.routes||[])e(t,[]);return t}href(t,e){const i=this.routeCollection.routesMap?.get(t);if(!i)throw w("MJX302",t);const s=i.fullPath||i.path;return this.routingEngine.generatePathString(s,e||{})||s}async evict(t){let e=null;if("string"==typeof t){if(e=this.routeCollection.routesMap?.get(t),!e)throw w("MJX302",String(t))}else e=t;await this.routingEngine.evict(e)}_fallbackRoutes={};_getFallbackRoute(t){const e=this._fallbackRoutes[t];if(e)return e;const i=this._routerOptions.fallbacks?.[t],s={path:"",fullPath:null,control:i??("notFound"===t?Ws._builtinNotFound:Ws._builtinError),name:"notFound"===t?"not-found":"error",childs:[],extend:{},meta:{},validate:void 0,keepAlive:!1};return this._fallbackRoutes[t]=s,s}_buildFallbackResult(t,e,i){const s=this._getFallbackRoute(e),n=this._findLayoutPrefix(t),o=[...n?.chain??[],s],r={},a={};for(const t of o)t?.extend&&"object"==typeof t.extend&&Object.assign(r,t.extend),t?.meta&&"object"==typeof t.meta&&Object.assign(a,t.meta);return{ok:!1,uri:t,fullPath:null,route:s,chain:o,params:{...n?.params??{},...i},extend:r,meta:a}}_findLayoutPrefix(t){const e=t.split("?")[0].split("#")[0].split("/").filter(Boolean);let i=null;for(const t of this.routeCollection?.records||[]){if(!t.leaf.childs||!t.leaf.childs.length)continue;const s=t.fullPath.split("/").filter(Boolean).length;if(s>e.length)continue;const n="/"+e.slice(0,s).join("/");let o=!1;try{o=t.scanner.exist(n,this._pageSearch())}catch{o=!1}if(!o)continue;const r={...t.scanner.parameters};this.validateChain(n,t,r)&&((!i||t.chain.length>i.rec.chain.length||t.chain.length===i.rec.chain.length&&s>i.depth)&&(i={rec:t,params:r,depth:s}))}return i?{chain:i.rec.chain,params:i.params}:null}static _builtinNotFound=()=>new ii("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(gi("h2",{},"404 - Not Found")),t.element.appendChild(gi("p",{},"The requested page was not found."))}});static _builtinError=()=>new ii("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(gi("h2",{},"Error")),t.element.appendChild(gi("p",{},"The requested page could not be loaded."))}});async navigateByName(t,e,i){return await this.navigate(this.href(t,e),i)}async _runMiddlewares(t){let e=t;const i={uri:e,rewritePath:t=>{e=t,i.uri=t},context:this.application};let s=!1;const n=this._routerOptions.middlewareCollections&&this._routerOptions.middlewareCollections()||[],o=async t=>{if(t===n.length)return void(s=!0);const e=n[t];await e(i,async()=>{await o(t+1)})};return 0===n.length?s=!0:await o(0),{proceed:s,uri:e}}resolve(t){const e=[],i=this._pageSearch();for(const s of this.routeCollection?.records||[]){if(!s.scanner.exist(t,i))continue;const n={...s.scanner.parameters};this.validateChain(t,s,n)&&e.push({rec:s,params:n})}if(0===e.length){const e=(this.routeCollection?.records||[]).find(t=>t.scanner.exist("/*"));if(e){const i={};try{for(const t of e.chain)t&&t.extend&&"object"==typeof t.extend&&Object.assign(i,t.extend)}catch{}return{ok:!0,uri:t,fullPath:e.fullPath,route:e.leaf,chain:e.chain,params:{},extend:i||{},meta:e.meta||{}}}return{ok:!1,uri:t,fullPath:null,route:null,chain:[],params:{},extend:{}}}let s=e[0];const n=new Map;for(const t of e){const e=t.rec.fullPath,i=n.get(e)||[];i.push(t),n.set(e,i)}let o=!1;for(const[t,e]of n)if(e.length>1){s=(e.some(t=>!t.rec.aliasOf)?e.filter(t=>!t.rec.aliasOf):e).reduce((t,e)=>t.rec.chain.length>=e.rec.chain.length?t:e),o=!0;break}o||(s=e.reduce((t,e)=>Fs(t.rec,e.rec)<=0?t:e,e[0]));const r=s.rec,a=s.params,c={};try{for(const t of r.chain)t&&t.extend&&"object"==typeof t.extend&&Object.assign(c,t.extend)}catch{}return{ok:!0,uri:t,fullPath:r.fullPath,aliasOf:r.aliasOf??null,route:r.leaf,chain:r.chain,params:a,extend:c,meta:(()=>{const t={};try{for(const e of r.chain)e&&e.meta&&"object"==typeof e.meta&&Object.assign(t,e.meta)}catch{}return t})()}}validateChain(t,e,i){for(const s of e.chain)if("function"==typeof s.validate){const n={uri:t,key:s.name??e.fullPath,routes:this.routesMap,params:i};if(!s.validate(n))return!1}return!0}_navHandler=null;_installLinkInterceptor(){try{if(this._navHandler)return;this._navHandler=t=>{const e=window,i=this._routerOptions.mode||("file:"===e?.location?.protocol?"hash":"history");let s=t.target;for(;s&&s!==document.body&&!(s instanceof HTMLAnchorElement);)s=s.parentElement;if(!(s&&s instanceof HTMLAnchorElement))return;const n=s.getAttribute("rel")||"";if(!("router"==s.getAttribute("x-command")||s.hasAttribute("data-router-link")||"router"===n.toLowerCase()))return;const o=s;if(o.target&&"_self"!==o.target)return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let r=o.getAttribute("href")||"";if(r||(r=o.getAttribute("x-to")||""),!r)return;if("history"===i){const i=new URL(r,e.location.href);if(i.origin!==e.location.origin)return;t.preventDefault();const s=i.pathname+i.search+i.hash;return void this.navigate(s)}t.preventDefault();const a=r.startsWith("#")?r.slice(1):r;this.navigate(a)},document.addEventListener("click",this._navHandler)}catch{}}_applyUrl(t,e={}){try{const i=window,s=this._routerOptions.mode||("file:"===i?.location?.protocol?"hash":"history");if("shell"===s)return;if("hash"===s||"file"===s){const s=t.startsWith("#")?t:"#"+t;if(i?.location?.hash!==s)if(e.replace&&i?.history&&"function"==typeof i.history.replaceState){const t=this._nextHistoryStamp(!1);i.history.replaceState(this._routerState(e.state,t),"",s),this._historyStamp=t}else{i.location.hash=s;const t=this._nextHistoryStamp(!0);this._stampCurrentEntry(t,e.state),this._historyStamp=t}return}if(i?.history&&"function"==typeof i.history.pushState){if((i.location.pathname||"/")+(i.location.search||"")!==t)if(e.replace){const s=this._nextHistoryStamp(!1);i.history.replaceState(this._routerState(e.state,s),"",t),this._historyStamp=s}else{const s=this._nextHistoryStamp(!0);i.history.pushState(this._routerState(e.state,s),"",t),this._historyStamp=s}}}catch{}}_resolveRedirect(t,e){const i=t.route?.redirect;if(!i)return null;if("function"==typeof i){const e=i({path:t.uri,params:t.params,meta:t.meta??t.extend});return"string"==typeof e&&e.length>0?e:null}const s=this.routingEngine.generatePathString(i,t.params||{}),n=e.indexOf("#"),o=n>=0?e.slice(n):"",r=n>=0?e.slice(0,n):e,a=r.indexOf("?"),c=a>=0?r.slice(a):"",l=s.indexOf("#"),h=l>=0?s.slice(l):"";let u=l>=0?s.slice(0,l):s;return c&&!u.includes("?")&&(u+=c),u+(h||o)}_pageSearch(){try{const t=window,e=this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history");if("history"===e||"shell"===e)return;return t?.location?.search||void 0}catch{return}}_addressShows(...t){const e=this._getCurrentUri().split("#")[0];return t.some(t=>!!t&&t.split("#")[0]===e)}_uriWithHash(t,e){const i=e.indexOf("#");return i<0||t.indexOf("#")>=0?t:t+e.slice(i)}_handleScrollBehavior(t){if(t)try{"top"===t?window.scrollTo({top:0,behavior:"auto"}):"smooth"===t?window.scrollTo({top:0,behavior:"smooth"}):"instant"===t?window.scrollTo({top:0,behavior:"instant"}):"object"==typeof t&&window.scrollTo({top:t.top||0,left:t.left||0,behavior:t.behavior||"auto"})}catch{}}dispose(){try{this._scroll?.dispose()}catch{}this._scroll=null,this._historyStamp=null;try{try{this.routingEngine.dispose()}catch{}if(this._navHandler){try{document.removeEventListener("click",this._navHandler)}catch{}this._navHandler=null}if(this._windowNavListener){const t="hash"===this._routerOptions.mode||"file"===this._routerOptions.mode?"hashchange":"popstate";try{window.removeEventListener(t,this._windowNavListener)}catch{}this._windowNavListener=null}}catch{}}}class $s{version=new Gt(0);_current=null;_constructing=null;read(){return this.version.value,this._constructing??this._current}commit(t){this._current=t,this.touch()}reset(){this._current=null,this.touch()}touch(){this.version.value=this.version.peek()+1}constructWith(t,e){if(!t)return e();const i=this._constructing;this._constructing=t;try{return e()}finally{this._constructing=i}}}let Us=null,qs=!1;class Ks{services=new cs;constructor(){if(Us||qs)throw new y("MJX405",v("MJX405"),{cause:Us});qs=!0}build(){this.services.autoRegisterInjectables();const t=this.services.buildServiceProvider();this.services.addSingleton(_e,t);var e=new Gs(t);return this.services.addSingleton(Gs,e),Us=e,e}rebuild(){return Us?(Us.provider.dispose(),Us.provider=this.services.buildServiceProvider(),Us):this.build()}}class Gs{provider;static get main(){return Us}constructor(t){this.provider=t}_middlewares=[];_beforeEachGuards=[];_routerState=new $s;router=function(t,e){const i=()=>{const t=e();if(!t)throw w("MJX309");return t},s=()=>t.read()?.target;return{get params(){return s()?.params??{}},get route(){return s()?.route??null},get ok(){return s()?.ok??!1},get uri(){return s()?.uri??""},get fullPath(){return s()?.fullPath??null},get aliasOf(){return s()?.aliasOf??null},get extend(){return s()?.extend??{}},get meta(){const t=s();return t?t.meta??t.extend:{}},get chain(){return t.read()?.chain??[]},get direction(){return t.read()?.direction},get state(){return t.read()?.state},get stack(){return t.version.value,e()?.describeStack()},get routes(){return t.version.value,e()?.routeInfos()??[]},navigate:async(t,e)=>{await i().navigate(t,e)},navigateByName:async(t,e,s)=>{await i().navigateByName(t,e,s)},evict:async t=>{await i().evict(t)},resolve:t=>i().resolve(t),href:(t,e)=>i().href(t,e)}}(this._routerState,()=>this.urlRoutingModule);events=new Map;static CreateBuilder(){return new Ks}appShell;getAppShell(){return this.appShell}run(t,e){let i;if(o(()=>{Gi.startGc()},"Application.run.engine.startGc"),"string"==typeof t){if(i=document.querySelector(t),!i)throw w("MJX406",t)}else i=t;let s=e;const n=new ii(i);this.appShell=n,o(()=>{n.application=this,n.provider=this.provider},"Application.run.setupAppShell"),s?(s.parent=n,n.controls.add(s)):(s=n,s.controls.add(new ms({name:"default"}))),n.build(),this._routerRoot=s,this.urlRoutingModule&&(this.urlRoutingModule.start(s),this._startedRouter=this.urlRoutingModule)}insert(t){this.appShell.controls.add(t)}remove(t){this.appShell.controls.remove(t)}attach(t){this.appShell.controls.add(t)}detach(t){this.appShell.controls.detach(t)}appendToMainHost(t){this.appShell.element?.appendChild(t)}dispose(){qs=!1,o(()=>{this._removeLifecycleListeners()},"Application.dispose.lifecycle"),o(()=>{this.urlRoutingModule?.dispose?.()},"Application.dispose.router"),o(()=>{this.provider.dispose()},"Application.dispose.preDispose"),o(()=>{Gi.stopGc()},"Application.dispose.gcStop"),o(()=>{try{const t=window;t&&t.history&&"function"==typeof t.history.replaceState&&t.history.replaceState({},"","/")}catch{}},"Application.dispose.resetUrl"),Us=null}use(t){return this._middlewares.push(t),this}useGuard(t){return this._beforeEachGuards.push(t),this}async _runBeforeEachGuards(t,e){const i={to:t,from:e};for(const t of this._beforeEachGuards){let e,s=!1;const n=t=>{s=!0,e=t};try{await t(i,n)}catch(t){return b("MJX306",t,"guard"),!1}if(!s)return!1;if(!1===e)return!1;if("string"==typeof e)return e}return!0}urlRoutingModule;_routerConfig=null;_routerRoot=null;_startedRouter=null;useRouter(t){let e,i,s,n,r,a;return Array.isArray(t)?e=t:(e=t.routes,i=t.mode,s=t.fallbacks,n=t.hooks,r=t.scrollMemory,a=t.stack),this.urlRoutingModule&&this.urlRoutingModule.dispose(),this._routerConfig={mode:i,fallbacks:s,middlewareCollections:()=>this._middlewares,RouteItems:e,hooks:n,scrollMemory:r,stack:a},this.urlRoutingModule=new Ws(this._routerConfig,this),this._routerState.reset(),o(()=>{l(),function(){if(l(),h())try{hs||(hs=document.createElement("div"),hs.style.cssText="position:fixed; left:12px; bottom:12px; right:12px; z-index:2147483647; background:#111; color:#fff; border:1px solid #333; border-radius:8px; box-shadow:0 4px 14px rgba(0,0,0,0.4); display:none;",document.body.appendChild(hs),window.addEventListener("keydown",t=>{try{(t.ctrlKey||t.metaKey)&&"`"===t.key&&(t.preventDefault(),ds())}catch{}}),u(t=>{t.type}),location.search,Gs.main.isDevelopmentModeEnabled&&ds(!0))}catch{}}(),m(e),(this._isDevelopment||!0===globalThis.__MOTIF_DEV__||h())&&function(t){const e=new Map,i=new Map;function s(t,n,o){const r=t.path??"",a=String(r),c=""===n?a:ls(n,a),l=o>0&&"/"===a.trim(),h=""===a.trim();h&&M("MJX310",[n||"/"],{parentPath:n,path:a}),o>0&&a.length>0&&"/"!==a&&!a.startsWith("/")&&!a.startsWith("*")&&M("MJX311",[a,n||"/"],{parentPath:n,path:a}),n&&c===n&&(l||h||M("MJX312",[c],{parentPath:n,childPath:a}));const u=(e.get(c)||0)+1;e.set(c,u),u>1&&(l||h||M("MJX313",[c],{full:c}));const d=null==t.alias?[]:Array.isArray(t.alias)?t.alias:[t.alias];for(const t of d){const e=String(t??"");o>0&&e.length>0&&"/"!==e&&!e.startsWith("/")&&!e.startsWith("*")&&M("MJX314",[e,n||"/"],{parentPath:n,alias:e});const s=""===n?e:ls(n,e);s===c&&M("MJX315",[s],{full:c,alias:e});const r=(i.get(s)||0)+1;i.set(s,r),r>1&&M("MJX316",[s],{aliasFull:s})}const p=t.childs;if(Array.isArray(p))for(const t of p)s(t,c,o+1)}for(const e of t)s(e,"",0)}(e)},"Application.useRouter.devtools"),this}restartRouter(){const t=this._routerRoot;if(!t||!this._routerConfig)return this;const e=this._startedRouter,i=e?.shownUri;let s=this.urlRoutingModule;return s&&s!==e||(e?.dispose(),s=new Ws(this._routerConfig,this),this.urlRoutingModule=s),this._routerState.reset(),this._startedRouter=s,s.start(t,i),this}async navigate(t,e){if(this.urlRoutingModule)return await this.urlRoutingModule.navigate(t,e);throw w("MJX309")}async navigateByName(t,e,i){if(this.urlRoutingModule)return await this.urlRoutingModule.navigateByName(t,e,i);throw w("MJX309")}on(t,e){var i=this.events.get(t);return i||(this.events.set(t,new Set),i=this.events.get(t)),i&&i.add(e),()=>this.off(t,e)}off(t,e){var i=this.events.get(t);i&&i.delete(e)}fire(t,e){var i=this.events.get(t);i&&i.forEach(i=>{S(()=>i(e),"MJX123",String(t))})}onRouterChanged(t){return this.on("motifjs-router-navigated",t)}get isVisible(){try{return"undefined"==typeof document||"hidden"!==document.visibilityState}catch{return!0}}get isOnline(){try{return"undefined"==typeof navigator||!1!==navigator.onLine}catch{return!0}}_lifecycleOff=null;onLifecycle(t){return this._installLifecycleListeners(),this.on("motifjs-app-lifecycle",t)}_emitLifecycle(t){this.fire("motifjs-app-lifecycle",{state:t,visible:this.isVisible,online:this.isOnline})}_installLifecycleListeners(){if(this._lifecycleOff)return;const t=[],e=(e,i,s)=>{if(e)try{e.addEventListener(i,s),t.push(()=>{try{e.removeEventListener(i,s)}catch{}})}catch{}},i="undefined"!=typeof document?document:void 0,s="undefined"!=typeof window?window:void 0;e(i,"visibilitychange",()=>this._emitLifecycle(this.isVisible?"visible":"hidden")),e(i,"freeze",()=>this._emitLifecycle("frozen")),e(i,"resume",()=>this._emitLifecycle("resumed")),e(s,"pageshow",t=>{t&&t.persisted&&this._emitLifecycle("restored")}),e(s,"online",()=>this._emitLifecycle("online")),e(s,"offline",()=>this._emitLifecycle("offline")),this._lifecycleOff=t}_removeLifecycleListeners(){const t=this._lifecycleOff;if(this._lifecycleOff=null,t)for(const e of t)e()}_isDevelopment=!1;_enableErrorLogging=!0;get isDevelopmentModeEnabled(){return this._isDevelopment}useReactiveMonitor(t={}){return o(()=>{_t(t)},"Application.useReactiveMonitor.core"),this}useDevelopment(t=!0){return this._isDevelopment=t,i.setDevelopmentMode(t),o(()=>{globalThis.__MOTIF_DEV__=t},"Application.useDevelopment.flag"),t&&function(){for(const t of Array.from(nt))ot(t)}(),this}useLogging(t=!0){return this._enableErrorLogging=t,function(t){i.setConsoleLogging(t)}(t),this}}function Ys(){return Gs.main.router}function Qs(){return{application:Gs.main,services:Gs.main.provider,router:Gs.main.router,attach(...t){Gs.main&&Gs.main.getAppShell().controls.add(...t)}}}function Zs(t){return e=>{as.set(e,{lifetime:t?.lifetime??"transient",deps:t?.deps})}}function tn(t){try{return Gs.main.provider.get(t)}catch(e){return M("MJX414",[en(t),String(e?.message??e)],{token:t,error:e}),null}}function en(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function sn(t){return t&&"TimeoutError"===t.name}class nn extends y{constructor(){super("MJX605",v("MJX605")),this.name="TimeoutError"}}function on(t){return new Promise(e=>setTimeout(e,t))}function rn(t,e=.1){const i=(2*Math.random()-1)*e*t;return Math.max(0,Math.floor(t+i))}class an{}class cn extends an{retries;backoff;delayMs;jitter;shouldHandle;onRetry;constructor(t={}){super(),this.retries=t.retries??3,this.backoff=t.backoff??"exponential",this.delayMs=t.delay??100,this.jitter=Math.min(Math.max(t.jitter??.1,0),1),this.shouldHandle=t.shouldHandle??(t=>!!t&&!sn(t)),this.onRetry=t.onRetry}calcDelay(t){if("none"===this.backoff)return 0;if("fixed"===this.backoff)return rn(this.delayMs,this.jitter);return rn(this.delayMs*Math.pow(2,t-1),this.jitter)}async execute(t,e){let i;for(let s=1;s<=this.retries+1;s++)try{return await Promise.resolve(t(e))}catch(t){if(i=t,!this.shouldHandle(t)||s>this.retries)break;const n=this.calcDelay(s);this.onRetry&&await this.onRetry(s,t,n,e),n>0&&await on(n)}throw i}}class ln extends an{timeoutMs;constructor(t){super(),this.timeoutMs=t.timeoutMs}async execute(t,e){let i;const s=Promise.resolve(t(e)),n=new Promise((t,e)=>{i=setTimeout(()=>e(new nn),this.timeoutMs)});try{return await Promise.race([s,n])}finally{clearTimeout(i)}}}class hn extends an{failureThreshold;successThreshold;durationOfBreakMs;shouldHandle;onStateChange;state="CLOSED";failureCount=0;successCount=0;nextAttemptTime=0;constructor(t={}){super(),this.failureThreshold=t.failureThreshold??5,this.successThreshold=t.successThreshold??2,this.durationOfBreakMs=t.durationOfBreakMs??6e4,this.shouldHandle=t.shouldHandle??(t=>!!t&&!sn(t)),this.onStateChange=t.onStateChange}async changeState(t){const e=this.state;this.state=t,this.failureCount=0,this.successCount=0,"OPEN"===t&&(this.nextAttemptTime=Date.now()+this.durationOfBreakMs),this.onStateChange&&await this.onStateChange(e,t)}async execute(t,e){if("OPEN"===this.state){if(!(Date.now()>=this.nextAttemptTime))throw w("MJX602");await this.changeState("HALF_OPEN")}try{const i=await Promise.resolve(t(e));return"HALF_OPEN"===this.state?(this.successCount++,this.successCount>=this.successThreshold&&await this.changeState("CLOSED")):"CLOSED"===this.state&&(this.failureCount=0),i}catch(t){throw this.shouldHandle(t)&&(this.failureCount++,("HALF_OPEN"===this.state||"CLOSED"===this.state&&this.failureCount>=this.failureThreshold)&&await this.changeState("OPEN")),t}}getState(){return this.state}}class un extends an{maxConcurrent;maxQueue;active=0;queue=[];constructor(t={}){super(),this.maxConcurrent=t.maxConcurrent??10,this.maxQueue=t.maxQueue??50}dequeue(){if(0===this.queue.length)return;if(this.active>=this.maxConcurrent)return;this.queue.shift()()}async execute(t,e){if(this.active>=this.maxConcurrent){if(this.queue.length>=this.maxQueue)throw w("MJX603");await new Promise(t=>{this.queue.push(t)})}this.active++;try{return await Promise.resolve(t(e))}finally{this.active--,this.dequeue()}}}class dn extends an{tokensPerInterval;intervalMs;capacity;tokens;lastRefill;constructor(t={}){super(),this.tokensPerInterval=t.tokensPerInterval??1,this.intervalMs=t.intervalMs??1e3,this.capacity=t.capacity??1e3,this.tokens=this.capacity,this.lastRefill=Date.now()}refill(){const t=Date.now(),e=t-this.lastRefill;if(e<=0)return;const i=Math.floor(e/this.intervalMs)*this.tokensPerInterval;i>0&&(this.tokens=Math.min(this.capacity,this.tokens+i),this.lastRefill=t)}async execute(t,e){if(this.refill(),this.tokens<=0)throw w("MJX604");return this.tokens-=1,Promise.resolve(t(e))}}class pn extends an{fallback;shouldHandle;constructor(t){super(),this.fallback=t.fallback,this.shouldHandle=t.shouldHandle??(()=>!0)}async execute(t,e){try{return await Promise.resolve(t(e))}catch(t){if(!this.shouldHandle(t))throw t;return await Promise.resolve(this.fallback(t,e))}}}class fn extends an{policies;constructor(...t){super(),this.policies=t}async execute(t,e){return this.policies.reduceRight((t,e)=>i=>e.execute(()=>t(i),i),t)(e)}}const mn=t=>new cn(t),_n=t=>new ln(t),gn=t=>new hn(t),yn=t=>new un(t),vn=t=>new dn(t),wn=t=>new pn(t),bn=(...t)=>new fn(...t);function Sn(t,e){return i=>t.execute(e,i)}class Mn{static get create(){return new Mn}resiliences=[];retry=t=>(this.resiliences.push(mn(t)),this);timeout=t=>(this.resiliences.push(_n(t)),this);circuitBreaker=t=>(this.resiliences.push(gn(t)),this);bulkhead=t=>(this.resiliences.push(yn(t)),this);rateLimiter=t=>(this.resiliences.push(vn(t)),this);fallback=t=>(this.resiliences.push(wn(t)),this);async execute(t,e){return bn(...this.resiliences).execute(t,e)}}export{Gs as Application,Ks as ApplicationBuilder,ii as Component,ke as ComponentBase,Ut as ComponentMotif,Yt as Computed,Ti as ContentBlock,Oi as ContentBody,yi as ControlCollection,G as Dictionary,A as Disposable,k as DisposableStore,Ot as Emitter,e as ErrorHandler,si as FNComponent,ui as FragmentNode,ki as Frame,tn as FromService,Zs as Injectable,bi as Lazy,Qt as LazyComputed,Q as LinkedList,W as List,y as MotifError,V as NameValuePair,rt as NodeTypes,it as Query,Mn as Resilience,Bs as RouterLink,ms as RouterView,cs as ServiceCollection,_e as ServiceProvider,Gt as Signal,Xi as Transport,Ri as TransportTo,Ii as Transporter,rs as Virtualization,Ct as asyncTracking,es as clearModel,_t as configureReactivityLeakMonitor,ns as createComputed,os as createLazyComputed,ss as createSignal,Sn as decorate,is as deepClone,C as disposableCore,fi as dom,St as effect,i as errorHandler,de as inject,ot as motifCompiled,ai as motifComponent,li as motifFragment,Di as preProcessing,Zi as reactive,tt as read,s as safeCall,n as safeCallAsync,o as safeCallSilent,r as setUnexpectedErrorHandler,$ as toDisposable,Z as toGetter,At as untracked,Qs as useApplication,ts as useModel,Ys as useNavigation};
2
+ //# sourceMappingURL=index.esm.min.js.map