@motifx/core 1.2.0-rc.2 → 1.2.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).motif={})}(this,function(t){"use strict";function e(t){setTimeout(()=>{throw t},0)}class i{unexpectedErrorHandler=e;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 s=new i;function n(t,e,i){return s.safeCall(t,e,i)}function o(t,e,i){return s.safeCallAsync(t,e,i)}function r(t,e){s.safeCallSilent(t,e)}const a={enabled:!1,listeners:new Set,warnings:[],routes:null};function c(){return a.enabled||!0===globalThis.__MOTIF_DEV__}function l(){try{if("undefined"==typeof window)return!1;return!0===window.__motif_DEVTOOLS||(!0===globalThis.__MOTIF_DEVTOOLS__||!0===globalThis.__MOTIF_DEVTOOLS_FLAG)}catch{return!1}}function h(t){try{t?window.__motifDevBus={on:p,emit:f,warn:m,getWarnings:_,isEnabled:d,setRoutes:g,getRoutes:y}:delete window.__motifDevBus}catch{}}function u(){a.enabled||(a.enabled=l(),a.enabled&&h(!0))}function d(){return a.enabled}function p(t){return a.listeners.add(t),()=>{a.listeners.delete(t)}}function f(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 m(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{}f("warning",s)}function _(){return a.warnings.slice()}function g(t){a.routes=t}function y(){return a.routes}const v={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.`,MJX124:t=>`A spread object on a DOM tag cannot set ${t}; the key was ignored. Write it on the tag, or use x-html, for HTML you trust.`,MJX125:t=>`A spread object on a DOM tag cannot set a javascript: URL on '${t}'; the value was ignored. Write the attribute on the tag if it is intended.`,MJX126:()=>"Lazy: loading the component failed and no Fallbackview is set; the host was cleared.",MJX127:t=>"module"===t?"The loaded module has no default export. Export the component as default, or map it: () => import('./X').then(m => m.X).":`The loaded value is not a component (got ${t}). Return a component class, a function component, an Options API factory or a component instance.`,MJX128:(t,e,i)=>"method"===i?`${t} overrides ${e} without calling super.${e}; MotifJS relies on this ComponentBase member. Rename your member, or call super.${e} in the override.`:"field"===i?`${t} defines '${e}' as an instance field, which hides the ComponentBase member MotifJS relies on. Rename your field.`:`${t} replaces '${e}', which MotifJS created for the component (a class field or an assignment with that name). Rename your member.`,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 w extends Error{code;constructor(t,e,i){super(e,i),this.name="MotifError",this.code=t}}function b(t,...e){return`[motifjs] ${t}: ${v[t](...e)}`}function S(t,...e){return new w(t,b(t,...e))}function M(t,e,...i){s.report(new w(t,b(t,...i),{cause:e}))}function C(t,e,...i){try{const s=t();s&&"function"==typeof s.then&&s.then(void 0,t=>M(e,t,...i))}catch(t){M(e,t,...i)}}function A(t,e,i){m(t,v[t](...e),i)}const k=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 D{_items=new Set;_closed=!1;constructor(){k.notifyCreated(this)}get isDisposed(){return this._closed}add(t){if(!t)return t;if(t===this)throw S("MJX502");return k.notifyOwner(t,this),this._closed?A("MJX504",[],(new Error).stack):this._items.add(t),t}delete(t){if(t){if(t===this)throw S("MJX505");this._items.delete(t),t.dispose()}}detach(t){t&&this._items.delete(t)&&k.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 w("MJX503",b("MJX503"),{cause:new AggregateError(t)})}dispose(){this._closed||(k.notifyDisposed(this),this._closed=!0,this.clear())}}class E{_disposables=new D;constructor(){k.notifyCreated(this),k.notifyOwner(this._disposables,this)}dispose(){k.notifyDisposed(this);const t=this._disposables;t&&"function"==typeof t.dispose?t.dispose():A("MJX501",[],{disposable:this})}_register(t){if(t===this)throw S("MJX502");return this._disposables.add(t)}}const T={IS_REACTIVE:Symbol.for("motif.isReactive"),IS_READONLY:Symbol.for("motif.isReadonly"),IS_SUPERFICIAL:Symbol.for("motif.isSuperficial"),RAW:Symbol.for("motif.raw"),GET_SETUP:Symbol.for("motif.getSetup")},x=Symbol("");let O=!0,N={enabled:!1,key:""};function P(t){let e=t;for(;e&&e[T.RAW];)e=e[T.RAW];return e}function L(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function X(t){return"object"==typeof t&&null!==t}const R=new Set(Object.values(Object.getOwnPropertyDescriptors(Symbol)).map(t=>t.value).filter(t=>"symbol"==typeof t));function I(t){return"symbol"==typeof t&&R.has(t)}const J=new Map([["[object Object]",1],["[object Array]",1],["[object Map]",2],["[object Set]",2],["[object WeakMap]",2],["[object WeakSet]",2]]);const H=/^(?:0|[1-9]\d*)$/,j=[];let F=0;function B(t){j[F++]=O,O=t}function z(){B(!1)}function V(){O=!(F>0)||j[--F]}const W=[];class ${component;itemsFn;renderFn;options;propertyName="__list__";dataSource;dataMember;formatString;converter;converterBack;updateMode;_isActive=!1;_effectCleanup;_rendered=[];_identityMap=new WeakMap;container=Zi("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 kt(()=>{const i=this.renderFn(t,e);return this.processRendered(i,t)})}processRendered(t,e){const i=Fi(t);if(!(i instanceof ai))throw S("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=P(t),i=t.length;let s;if(e===t)s=t;else{s=new Array(i);for(let n=0;n<i;n++)n in e?s[n]=t[n]:t[n]}const n=this.olditems,o=this._rendered;if(this.olditems.length>0){const t=new Set;for(let e=0;e<i;e++)t.add(P(s[e]));for(const e of this.olditems){const i=P(e);if(!t.has(i)){const t=this._identityMap.get(i);if(t){this._identityMap.delete(i);for(const e of t)try{e.dispose()}catch{}}}}}const r=[],a=new Set,c=new Map,l=new Set,h=new Map,u=t=>!(!t||t.isDisposed||l.has(t)||t.__listAdopted),d=Math.min(s.length,n.length);for(let t=0;t<d;t++){const e=s[t];if(!$._isPrimitive(e))continue;if(!Object.is(n[t],e))continue;const i=o[t];u(i)&&(h.set(t,i),l.add(i))}let p=null;if(!this._indexSensitive){p=new Map;for(let t=0;t<n.length;t++){const e=n[t];if(!$._isPrimitive(e))continue;const i=o[t];if(!u(i))continue;const s=p.get(e);s?s.push(i):p.set(e,[i])}}const f=new Map;return s.forEach((t,e)=>{let i;if("object"==typeof t&&null!==t){const s=P(t),n=f.get(s)??0;f.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=h.get(e);if(!s&&p){const e=p.get(t);e&&e.length&&(s=e.shift(),l.add(s))}i=s||this._render(t,e)}const s=this._getComponentKey(i);null!=s&&(c.has(s)?A("MJX202",[s,e]):c.set(s,e)),r.push(i),a.add(i)}),f.forEach((t,e)=>{const i=this._identityMap.get(e);i&&i.length>t&&(i.length=t)}),this._rendered.forEach(t=>{if(!a.has(t)&&!t.__listAdopted)try{t.dispose()}catch{}}),this._syncContainer(r),this._rendered=r,this.olditems=s===t?t.slice():s,i};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}if(t.length>=i.length){let s=!0;for(let e=0;e<i.length;e++)if(t[e]!==i[e]){s=!1;break}if(s&&t.length>i.length){const e=new Set(i);for(let n=i.length;n<t.length;n++){if(e.has(t[n])){s=!1;break}e.add(t[n])}}if(s){for(let s=i.length;s<t.length;s++)try{e.add(t[s])}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 U{Key;value}class q{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){const e=this.__list.indexOf(t);return-1===e?[]:(this._map.delete(t),this.__list.splice(e,1))}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.slice().reverse()}filter(t){return this.__list.filter(t)}}function G(t){let e=!0;return{dispose(){e&&(e=!1,t())}}}function K(t){return"/"+t.replace(/^\/+|\/+$/g,"")}function Y(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 Y(t.parent)}catch(t){throw t}return null}class Q{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();A("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}}function Z(){const t={value:void 0,linked:!1};return t.before=t,t.after=t,t}class tt{_ring=Z();_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=Z(),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 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 S("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),A("MJX121",[t,1])):nt.add(t))}var rt;t.NodeTypes=void 0,(rt=t.NodeTypes||(t.NodeTypes={}))[rt.ELEMENT_NODE=1]="ELEMENT_NODE",rt[rt.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",rt[rt.TEXT_NODE=3]="TEXT_NODE",rt[rt.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",rt[rt.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",rt[rt.ENTITY_NODE=6]="ENTITY_NODE",rt[rt.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",rt[rt.COMMENT_NODE=8]="COMMENT_NODE",rt[rt.DOCUMENT_NODE=9]="DOCUMENT_NODE",rt[rt.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",rt[rt.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE",rt[rt.NOTATION_NODE=12]="NOTATION_NODE";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 Q(ft,t.name??"reactivity-core"):void 0}function gt(t,e){if(!O)return;const i=P(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=P(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&&A("MJX203",[wt],{fn:String(i.fn).slice(0,200)}):vt(()=>i.run())}}}finally{ht.clear(),dt=!1}})}()}function vt(t){try{t()}catch(t){M("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)}},At=new at(()=>{});function kt(t){lt.push(At);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}}At.active=!1;class Tt{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()||""}}const xt=T.RAW;function Ot(t,e,i){let s=Object.getPrototypeOf(t);for(;s&&s!==e;){if(Object.prototype.hasOwnProperty.call(s,i))return!0;s=Object.getPrototypeOf(s)}return!1}function Nt(t,e){for(const i of e){let e=t[i];"function"==typeof e&&Object.defineProperty(t,i,{configurable:!0,enumerable:!1,get(){if(this===t||(s=this,Object.prototype.hasOwnProperty.call(s,"constructor")&&"function"==typeof s.constructor&&s.constructor.prototype===s))return e;var s;const n=this[xt]??this,o=e.bind(n);if(!Ot(n,t,i))try{Object.defineProperty(n,i,{value:o,writable:!0,configurable:!0,enumerable:!0})}catch{}return o},set(s){this!==t||"function"!=typeof s?Object.defineProperty(this,i,{value:s,writable:!0,configurable:!0,enumerable:!0}):e=s}})}}function Pt(t){return"function"==typeof t?Pt(t()):t}function Lt(t,e){return"__proto__"!==e&&("constructor"!==e&&"prototype"!==e||Object.prototype.hasOwnProperty.call(t,e))}class Xt{_items=[];_component;_branchScope=null;constructor(t){this._component=t}_own(t){this._branchScope?this._branchScope.push(t):this._component.motif.register(G(()=>{try{t()}catch{}}))}when(t,e){var i=new _s;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,kt(()=>{t?i.navigate(e(t)):i.navigate(Zi())}))});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 Tt(this._component,i,s,n,o,r)}return this._items.push(e),this._component.isBuilt&&e.activate(),e}wait(t){const e=new Tt(this._component,"isWait",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}display(t){const e=new Tt(this._component,"isWait",()=>!Pt(t()));return this._items.push(e),this._component.isBuilt&&e.activate(),e}html(t){const e=new Tt(this._component,"innerHTML",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}list(t,e,i){const s=new $(this._component,t,e,i);return this._items.push(s),this._component.isBuilt&&s.activate(),s}loop(t,e,i){const s=new $(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 zi(ns.createTextNode(t)),n(i,s),void(s=null));s||(s=new _s,n(s,i),i=null),s.navigate(null==t?Zi():t)});e.motif.register(G(()=>{try{o()}catch{}}))}ternary(t,e,i){const s=new _s;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 kt(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(G(()=>{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 Tt(this._component,i,t[0]),s.setter=t[1];else{const[e,n,o,r]=t;s=new Tt(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 s=0;s<t.length&&null!=i;s++){const n=t[s];if(!Lt(i,n))return;s===t.length-1?i[n]=e:i=i[n]}}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){M("MJX208",t)}}switchCase(t,e,i){const s=new _s;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(Zi())}});return this._component.motif.register(G(()=>{try{r()}catch{}})),null}}Nt(Xt.prototype,["add","remove","clear","activateAll","deactivateAll","reActivateAll","when","text","value","list","loop","method","watch","display","wait","ternaryCall","_ternaryCallTop"]);class Rt{_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 D?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){s.onUnexpectedError(t)}}this._delivery===t&&(this._delivery=void 0)}}}class It{component;_emitters;_sourceDisposables;_listenerDisposables;constructor(t){this.component=t}hasListeners(t){return void 0!==this._emitters&&this._emitters.has(t)}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){const e=this._emitters??=new Map;let i=e.get(t);return i||(i=new Rt,e.set(t,i)),i}createEvent(t,e){const i=String(t).toLowerCase(),s=i.startsWith("on")?"x:"+i.slice(2):i,n=t=>{let i;return C(()=>(i=e.length<=1?e(t):e(this.component,t),i),"MJX122",s),i},o=this.getOrCreateEmitter(i).event(t=>n(t)),r=this._listenerDisposables??=new Map;let a=r.get(i);a||(a=new Map,r.set(i,a));const c=a.get(e);return c?c.push(o):a.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 Rt?e.event:e)}catch{}if(o){const t=this._sourceDisposables??=new Map;let e=t.get(i);e||(e=new Set,t.set(i,e)),e.add(o),this.component.motif.register(k.toDisposable(()=>{try{o?.dispose()}catch{}try{e?.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 if(this._emitters)for(const t of Array.from(this._emitters.keys()))this.clear(t);return this}}Nt(It.prototype,["fire","on","off","createEvent","getOrCreateEmitter","addSource","clear"]);const Jt=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"]),Ht={show:"close",showModal:"close",showPopover:"hidePopover"},jt=new Set(["close","hidePopover","requestSubmit","checkValidity","reportValidity","showPicker","load"]),Ft=new Set(["setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Bt=new Set(["checked","selected","muted","indeterminate","srcObject"]);class zt{_parent;_attrMapStore;_watchersStore;constructor(t){this._parent=t}get _attrMap(){return this._attrMapStore??=new Map}get _watchers(){return this._watchersStore??=new Map}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&&Jt.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 Ht){return r(()=>{if(!1===e){const t=i[Ht[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(jt.has(s)){return r(()=>{!0===e?o(n):e&&o(n,e)}),void a()}if(Ft.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&&Bt.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(vi(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 Vt{_parent;constructor(t){this._parent=t}_countsStore;_staticSetStore;_watchersStore;_watcherSeq=0;get _counts(){return this._countsStore??=new Map}get _staticSet(){return this._staticSetStore??=new Set}get _watchers(){return this._watchersStore??=new Map}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 Wt={cancel(){},addEventListener(){},removeEventListener(){},oncancel:null,playState:"finished"};function $t(t){const e=t.substring(0,Math.max(0,t.length-1)).replace(",",".");return 1e3*Number(e)}function Ut(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=$t(n[t])+$t(s[t%s.length]);o=Math.max(o,e)}return{kind:e,longest:o,tracks:n.length}}const qt=/(?:^|\W)(?:transform|all)(?:,|$)/;function Gt(t,e){if(!t)return{type:"animation",timeout:0,propCount:0,hasTransform:!1};const i={transition:Ut(t,"transition"),animation:Ut(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&&qt.test(t.transitionProperty)}}function Kt(t,e,i){if(t.isConnected&&8!==t.nodeType)return Gt(ns.window.getComputedStyle(t),i);const s=ns.createElement("div");s.setAttribute("style","width:0!important;height:0!important;display:none"),ns.body.appendChild(s),s.setAttribute("class",e);try{return Gt(ns.window.getComputedStyle(s),i)}finally{s.remove()}}function Yt(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 Gt(ns.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 Qt{_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(k.toDisposable(t))}stopAnimations(){return this._component._stopAnimations()}}const Zt=Symbol("SignalTarget"),te=Symbol("SignalKey");class ee{_value;_target;_key;_equals;_disposed=!1;static create(t,e){return new ee(t,e)}constructor(t,e=Object.is){this._value=t,this._target={[Zt]:!0},this._key=te,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 ie{_value;_dirty=!0;_computing=!1;_target;_key;_getter;_cleanup;constructor(t){this._getter=t,this._target={[Zt]:!0},this._key=te,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,z();try{this._value=this._getter(),this._dirty=!1}finally{V(),this._computing=!1}}return this._value}peek(){if(this._dirty){z();try{this._value=this._getter(),this._dirty=!1}finally{V()}}return this._value}dispose(){this._cleanup&&(this._cleanup(),this._cleanup=void 0)}valueOf(){return this.value}toString(){return String(this.value)}}class se{_value;_dirty=!0;_disposed=!1;_target;_key;_getter;_runner;constructor(t){this._getter=t,this._target={[Zt]:!0},this._key=te,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=kt(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 ne=null,oe=null,re=null,ae=null,ce=null;const le=new WeakMap,he=new WeakMap,ue=new WeakMap,de=new WeakMap,pe=new WeakMap;function fe(t,e){const i=ne;ne=t;try{return e()}finally{ne=i}}function me(t,e,i){const s=oe,n=re;oe=t,re=e;try{return i()}finally{oe=s,re=n}}function _e(t){let e=t;for(;e;){const t=ue.get(e);if(t)return t.scope;const i=de.get(e);if(i&&i._pending)return i;e=e.parent}return null}function ge(t){ae&&ae._pending&&de.set(t,ae)}function ye(t){const e=ce;if(!e)return;if(ue.get(t)?.live)return;const i=_e(t)??e._currentScope();ue.set(t,{scope:i,live:!0}),i._livePins++}function ve(t){const e=ue.get(t);e?e.live&&(e.live=!1,e.scope._releaseLivePin()):ce&&le.has(t)&&ue.set(t,{scope:_e(t)??ce._currentScope(),live:!1})}class we{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 we(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 S("MJX401",this.describeToken(t));return this.resolveDescriptorSync(e,[t])}async getAsync(t){const e=this.services.getDescriptor(t);if(!e)throw S("MJX401",this.describeToken(t));return await this.resolveDescriptorAsync(e,[t])}_getFor(t,e){let i=le.get(t);return i||(i={owner:t},le.set(t,i)),me(i,re,()=>this.get(e))}getAllServices(){return this.services}_beginNavigation(){const t=this.root,e=t._navigation??={current:t,version:new ee(0),scopes:new Set};ce=t;const i=new we(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=_e(t.owner);if(e)return e;if(ae&&ae.root===this)return ae}return e?e.current:this}_handle(t,e){const i=oe??this._ownerlessSlot;let s=he.get(i);s||he.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=oe??this._ownerlessSlot;return await this._scopeFor(i)._scopedInstanceAsync(t,e),me(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=pe.get(t);s||pe.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=me(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=me(null,null,()=>this.instantiateSync(t,e));return this.singletonCache.set(t.token,i),i}case"scoped":return this._isSystemScope()&&re!==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()&&re!==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(oe)return t();const e={owner:null},i=me(e,re,t);return!i||"object"!=typeof i&&"function"!=typeof i||"function"==typeof i.then||(ge(i),e.owner=i,le.has(i)||le.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=fe(this.injectionResolver(e),()=>t.useFactory(...i,this));if(s&&"function"==typeof s.then){throw S("MJX402",this.describeTokenWithSource(t.token))}return s});if(t.useClass)return this.construct(()=>{const i=this.resolveDepsSync(t,e);return fe(this.injectionResolver(e),()=>new t.useClass(...i))});throw S("MJX403")}async instantiateAsyncIn(t,e,i,s){return await me(t,e,()=>this.instantiateAsync(i,s))}async instantiateAsync(t,e){if(void 0!==t.useValue)return t.useValue;const i=oe,s=re;if(t.useFactory){const n=await this.resolveDepsAsyncIn(i,s,t,e);return await me(i,s,()=>this.construct(()=>fe(this.injectionResolver(e),()=>t.useFactory(...n,this))))}if(t.useClass){const n=await this.resolveDepsAsyncIn(i,s,t,e);return me(i,s,()=>this.construct(()=>fe(this.injectionResolver(e),()=>new t.useClass(...n))))}throw S("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,ce===this&&(ce=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 me(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 S("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 S("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 S("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"}]`}}const be={live:0},Se=Symbol("motif.optionsOwner"),Me=Symbol("motif.transition"),Ce={mode:"concurrent"},Ae=()=>{};function ke(){const t=new WeakMap;return{track:function(e,i,s){const n=e?.parentNode??s?.parentNode;if(!n)return{done:i,release:Ae};let o=t.get(n);o||t.set(n,o=new Set);let r=Ae;const a={node:e,via:s??null,done:new Promise(t=>{r=t})};o.add(a);let c=!1;const l=()=>{c||(c=!0,o.delete(a),r())};return{done:()=>{const t=!c;l(),t&&i&&i()},release:l,finished:a.done}},pending:function(e,i){if(!e)return null;const s=t.get(e);if(!s||0===s.size)return null;let n=null;for(const t of s)t.node!==i&&(t.node.parentNode===e||t.via?.parentNode===e?(n??=[]).push(t.done):s.delete(t));return n?Promise.all(n).then(Ae):null}}}const De=ke(),Ee=ke(),Te=De.track,xe=De.pending,Oe=Ee.track,Ne=Ee.pending;function Pe(t){return"concurrent"===t||"out-in"===t||"in-out"===t}function Le(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function Xe(t){return t?.motif?.options?.[Me]}function Re(t){const e=Xe(t);if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function Ie(t){let e=t;for(;e;){const t=Xe(e)?.mode;if(t)return t;const i=e.element;if(!i||i.nodeType!==Node.COMMENT_NODE)break;e=e.parent??e._base?._leaveContainer}return Ce.mode}function Je(t){const e=t?.motif?.options,i=e?.[Me];return!!(e?.transitionIn||i&&(i.classes||i.name&&i.name.length>0))}function He(t){const e=()=>t.motif.options?.[Me]??i,i={transitionInfo:()=>{const i=e();return{in:Kt(t.element,`${i.name}-enter ${i.name}-enter-start`),out:Kt(t.element,`${i.name}-leave ${i.name}-leave-start`)}},name:"",mode:void 0,classes:void 0,activeCssCancel:null,activeCssPhase:null,cssProps:()=>{const t=e();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:e=>{t.motif.options.transitionIn=e},out:e=>{t.motif.options.transitionOut=e},enterTransition:i=>{const s=e(),n=t._base,o=!n._enterPlayed;if(n._enterPlayed=!0,n._enterSeq=(n._enterSeq??0)+1,s._suppressEnter)return i&&i(),Wt;const r={};n._enterRun=r;const a=Oe(t.element,()=>{t._base?._enterRun===r&&(t._base._enterRun=null,Re(t)),i&&i()},t.motif.options.placeholder),c=t.motif.options.transitionIn,l=c?s.run(c.keyframes,c.options,a.done):s._runCss("enter",a.done,o);return l&&l!==Wt&&"function"==typeof l.addEventListener&&l.addEventListener("cancel",a.release),l},leaveTransition:i=>{const s=e(),n=t.element,o=Te(n,i),r=()=>{const e=t.motif.options?.transitionOut,i=e?s.run(e.keyframes,e.options,o.done):s._runCss("leave",o.done);return i&&i!==Wt&&"function"==typeof i.addEventListener&&i.addEventListener("cancel",o.release),i};return o.finished&&"in-out"===Ie((a=t).parent??a._base?._leaveContainer)?function(t,e,i){const s=t.parentNode,n={finished:e.finished??Promise.resolve(),playState:"pending",addEventListener:Ae,removeEventListener:Ae,cancel:Ae};return queueMicrotask(()=>{const e=Ne(s,t);e?e.then(()=>{i()}):i()}),n}(n,o,r):r();var a},_runCss:(i,s,n=!1)=>{const o=e();if("enter"===i&&"leave"===o.activeCssPhase)return s&&s(),Wt;const r=o.cssProps(),a=t.element;if(r&&a&&1===a.nodeType&&a.classList){try{o.activeCssCancel?.()}catch{}const t=Yt(a,r,i,()=>{o.activeCssCancel=null,o.activeCssPhase=null,s&&s()},n);return o.activeCssCancel=t,o.activeCssPhase=i,Wt}return s&&s(),Wt},activeAnimations:[],run:(i,s,n)=>{const o=e();t.motif.stopAnimations();const r=t.element;if(r.animate){var a=r.animate(i,s);o.activeAnimations.push(a);let t=!1;const e=()=>{if(!t){t=!0;try{o.activeAnimations&&(o.activeAnimations=o.activeAnimations.filter(t=>t!==a))}catch{}}};return a.addEventListener("finish",()=>{n&&n(),e()}),a.oncancel=()=>{e()},a}{n&&n();const t=globalThis;if("function"==typeof t.Animation)try{return new t.Animation}catch{}return Wt}}};return i}class je{[Se];[Me];constructor(t){this[Se]=t}get transition(){return this[Me]??=He(this[Se])}set transition(t){this[Me]=t}set enableRouterClassing(t){try{const e=this[Se],i=e.context.onRouterChanged(()=>{Ue.routerClassing.call(e,t)});e.motif.register(k.toDisposable(()=>{i()})),Ue.routerClassing.call(e,t)}catch(t){M("MJX105",t)}}getInstance(){return this[Se]}get display(){return this[Se].isVisible}set display(t){t?this[Se].motif.show():this[Se].motif.hide()}hasEvent(t){return!!this[Se]._eventHandlers?.has(t)}}function Fe(t,e,i){const s=t._base;s&&s.emiters.fire(e,i)}function Be(t,e,i,s,n){if(t[e])return!0;const o=t._base[i];return!!(Array.isArray(o)&&o.length>0)||(!(!n||!t[n])||t._base.emiters.hasListeners(s))}Nt(je.prototype,["getInstance","hasEvent"]);const ze=["build","setState","reState","setText","style","dispose","disposeAsync","using","doWork","getService","$","useModel","context","siblings","serviceProvider","isWait"],Ve=new WeakSet;function We(t,e){if("function"!=typeof t)return!1;const i=e.replace(/\$/g,"\\$");return new RegExp(`\\bsuper\\s*(\\.\\s*${i}(?![\\w$])|\\[)`).test(Function.prototype.toString.call(t))}function $e(t){if(!c())return;const e=t?.constructor;if("function"!=typeof e||Ve.has(e))return;Ve.add(e);const i=e.name||"An anonymous component class";for(const[e,s]of function(t){const e=[],i=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);for(const s of ze)if(i(t,s))e.push([s,"field"]);else for(let i=Object.getPrototypeOf(t);i&&i!==ai.prototype;i=Object.getPrototypeOf(i)){const t=Object.getOwnPropertyDescriptor(i,s);if(t){("value"in t?[t.value]:[t.get,t.set].filter(Boolean)).some(t=>We(t,s))||e.push([s,"method"]);break}}const s=t;return s.motif instanceof Qt||e.push(["motif","replaced"]),s.controls instanceof cs||e.push(["controls","replaced"]),s.class instanceof Vt||e.push(["class","replaced"]),s.attr instanceof zt||e.push(["attr","replaced"]),s.bindings instanceof Xt||e.push(["bindings","replaced"]),null==s.element||"undefined"==typeof Node||s.element instanceof Node||e.push(["element","replaced"]),null==s.parent||s.parent instanceof ai||e.push(["parent","replaced"]),e}(t))A("MJX128",[i,e,s])}const Ue={callInitializeComponent(t){const e=t,i={cancel:!1};if(t&&!t.isDisposed){if("function"==typeof t.initializeComponent&&C(()=>t.initializeComponent(e,i),"MJX122","initializeComponent"),Array.isArray(t._base._initializeComponentHandlers)&&t._base._initializeComponentHandlers.length)for(const s of t._base._initializeComponentHandlers)C(()=>s(e,i),"MJX122","initializeComponent");if("function"==typeof t.oninitializeComponent&&C(()=>t.oninitializeComponent(e,i),"MJX122","oninitializeComponent"),Array.isArray(t._base._onInitializeComponentHandlers)&&t._base._onInitializeComponentHandlers.length)for(const s of t._base._onInitializeComponentHandlers)C(()=>s(e,i),"MJX122","oninitializeComponent")}},callDisposing(t){if(!t||t.isDisposed)return;if(!Be(t,"onDisposing","_onDisposingHandlers","ondisposing","ondisposing"))return;const e=t,i={cancel:!1};if(t.onDisposing&&C(()=>t.onDisposing(e,i),"MJX122","onDisposing"),Array.isArray(t._base._onDisposingHandlers))for(const s of t._base._onDisposingHandlers)C(()=>s(e,i),"MJX122","onDisposing");t.ondisposing&&C(()=>t.ondisposing(e,i),"MJX122","ondisposing"),Fe(t,"ondisposing",i)},callActivated(t){if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onActivated&&C(()=>t.onActivated(e,i),"MJX122","onActivated"),Array.isArray(t._base._onActivatedHandlers))for(const s of t._base._onActivatedHandlers)C(()=>s(e,i),"MJX122","onActivated");Fe(t,"onactivated",i)},callDeactivated(t){if(!t||t.isDisposed)return;const e=t,i={cancel:!1};if(t.onDeactivated&&C(()=>t.onDeactivated(e,i),"MJX122","onDeactivated"),Array.isArray(t._base._onDeactivatedHandlers))for(const s of t._base._onDeactivatedHandlers)C(()=>s(e,i),"MJX122","onDeactivated");Fe(t,"ondeactivated",i)},deactivateTree(t,e=!0){if(t&&!t.isDisposed&&t.isBuilt&&t._base&&!t._base._inactive&&(t._base._inactive=!0,Ue.callDeactivated(t),e&&!t.isDisposed))for(const e of t.controls.items.slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&Ue.deactivateTree(e,!0)},activateTree(t,e=!0){if(t&&!t.isDisposed&&t._base&&t._base._inactive&&(t._base._inactive=!1,Ue.callActivated(t),e&&!t.isDisposed))for(const e of t.controls.items.slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&Ue.activateTree(e,!0)},callDisposed(t){if(t&&t._base&&!t._base._disposedFired){if(t._base._disposedFired=!0,Be(t,"onDisposed","_onDisposedHandlers","ondisposed","ondisposed")){const e=t,i={cancel:!1};if(t.onDisposed&&C(()=>t.onDisposed(e,i),"MJX122","onDisposed"),Array.isArray(t._base._onDisposedHandlers))for(const s of t._base._onDisposedHandlers)C(()=>s(e,i),"MJX122","onDisposed");t.ondisposed&&C(()=>t.ondisposed(e,i),"MJX122","ondisposed"),Fe(t,"ondisposed",i)}try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:disposed",{id:t.id,type:t.constructor?.name})}catch{}}},callBuilt(t){if(t&&!t.isDisposed){if(Be(t,"onBuilt","_onBuiltHandlers","onbuilt","onbuilt")){const e=t,i={cancel:!1};if(t.onBuilt&&C(()=>t.onBuilt(e,i),"MJX122","onBuilt"),Array.isArray(t._base._onBuiltHandlers))for(const s of t._base._onBuiltHandlers)C(()=>s(e,i),"MJX122","onBuilt");t.onbuilt&&C(()=>t.onbuilt(e,i),"MJX122","onbuilt"),Fe(t,"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=Ii(e,()=>{t.isDisposed||Ue.callMounted(t)});i&&t._register(k.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&&C(()=>t.onMounted(e,i),"MJX122","onMounted"),Array.isArray(t._base._onMountedHandlers))for(const s of t._base._onMountedHandlers)C(()=>s(e,i),"MJX122","onMounted");t.onmounted&&C(()=>t.onmounted(e,i),"MJX122","onmounted"),Fe(t,"onmounted",i)},callBuilding(t){if(!t||t.isDisposed)return;if(!Be(t,"onBuilding","_onBuildingHandlers","onbuilding"))return;const e=t,i={cancel:!1};if(t.onBuilding&&C(()=>t.onBuilding(e,i),"MJX122","onBuilding"),Array.isArray(t._base._onBuildingHandlers))for(const s of t._base._onBuildingHandlers)C(()=>s(e,i),"MJX122","onBuilding");Fe(t,"onbuilding",i)},callConfig(t){if(!t||t.isDisposed||t.isConfigured)return;if(t.isConfigured=!0,t.motif.options._preconfig&&r(()=>t.motif.options._preconfig(t),"Component._preconfig"),!Be(t,"onConfig","_onConfigHandlers","onconfig"))return;const e=t,i={cancel:!1};if(t.onConfig&&C(()=>t.onConfig(e,i),"MJX122","onConfig"),Array.isArray(t._base._onConfigHandlers))for(const s of t._base._onConfigHandlers)C(()=>s(e,i),"MJX122","onConfig");Fe(t,"onconfig",i)},callConfigured(t){if(t.motif.options&&t.motif.options._postconfigdone)return;if(t?._base?._configDeferred&&!t.isConfigured&&Ue.callConfig(t),t.motif.options._postconfigdone=!0,!t||t.isDisposed)return;if(!Be(t,"onConfigured","_onConfiguredHandlers","onconfigured"))return;const e=t,i={cancel:!1};if(t.onConfigured&&C(()=>t.onConfigured(e,i),"MJX122","onConfigured"),Array.isArray(t._base._onConfiguredHandlers))for(const s of t._base._onConfiguredHandlers)C(()=>s(e,i),"MJX122","onConfigured");Fe(t,"onconfigured",i)},callOnInitialized(t){if(!t||t.isDisposed)return;if(t.isInitialized=!0,!Be(t,"onInitialized","_onInitializedHandlers","oninitialized"))return;const e=t,i={cancel:!1};if(t.onInitialized&&C(()=>t.onInitialized(e,i),"MJX122","onInitialized"),Array.isArray(t._base._onInitializedHandlers))for(const s of t._base._onInitializedHandlers)C(()=>s(e,i),"MJX122","onInitialized");Fe(t,"oninitialized",i)},callOnInitializing(t){if(!t||t.isDisposed)return;if(!Be(t,"onInitializing","_onInitializingHandlers","oninitializing"))return;const e=t,i={cancel:!1};if(t.onInitializing&&C(()=>t.onInitializing(e,i),"MJX122","onInitializing"),Array.isArray(t._base._onInitializingHandlers))for(const s of t._base._onInitializingHandlers)C(()=>s(e,i),"MJX122","onInitializing");Fe(t,"oninitializing",i)},callVisibilityChanged(t){if(!t||t.isDisposed)return;if(!Be(t,"onVisibilityChanged","_onVisibilityChangedHandlers","onvisibilitychanged"))return;const e=t,i={cancel:!1};if(t.onVisibilityChanged&&C(()=>t.onVisibilityChanged(e,i),"MJX122","onVisibilityChanged"),Array.isArray(t._base._onVisibilityChangedHandlers))for(const s of t._base._onVisibilityChangedHandlers)C(()=>s(e,i),"MJX122","onVisibilityChanged");Fe(t,"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(Ue.callConfigured(t),t.isDisposed)return;if(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||Ue.internalBuild.call(this,t)})}}else t.build();if(t.isDisposed||this.isDisposed)return;t.parent=this;const s=this.controls.items,n=s.length>0&&s[s.length-1]===t?s.length-1:s.indexOf(t),o=Ri(this);var r=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;e&&t.element.nodeType==Node.COMMENT_NODE&&0==r?.childNodes.length&&t.controls.length>0&&(r=Ue.getContent.call(t));let a=null;const c=o?.element,l=t=>{if(!t||!t.isBuilt)return null;const e=t.isVisible?t.element:t.motif.options?.placeholder??null;return e&&c&&e.parentNode===c?e:null},h=this.controls.items;for(let t=n+1;t<h.length;t++){const e=l(h[t]);if(e){a=e;break}}if(!a)if(this.element.nodeType===Node.COMMENT_NODE){const t=this.motif.options.closeFragment;a=t&&c&&t.parentNode===c?t:null}else a=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=ns.createComment("h")),r=t.motif.options.placeholder}if(c&&"out-in"===Ie(this)){const e=xe(c,r);if(e)return t._base._enterSeq=(t._base._enterSeq??0)+1,void e.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||Ue.internalBuild.call(this,t)})}const u=o?.element;if(r&&u&&(r===u||r.contains(u)))A("MJX104",[]);else if(a)try{o?.element.insertBefore(r,a)}catch{o?.element.appendChild(r)}else o?.element.appendChild(r);if(t.isVisible){!(!e&&t._base._enterSeq!==i)&&Je(t)&&t.motif.options.transition.enterTransition(()=>{}),e&&Ue.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(Ue.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 M("MJX610",t),!1}}(n,o),a=r||function(t,e){const i=K(t),s=K(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){}}};function qe(t,e,i){const s=t.motif?.options,n=e.parentNode;if(e.nodeType===Node.COMMENT_NODE){if(!n)return;const t=s?.closeFragment||null;if(t){let i=e;for(;i;){const e=i.nextSibling;try{n.removeChild(i)}catch{}if(i===t)break;i=e}}else try{n.removeChild(e)}catch{}if(!i)return}else if(n){try{n.removeChild(e)}catch{}if(!i)return}const o=s?.placeholder;if(o&&o.parentNode)try{o.parentNode.removeChild(o)}catch{}}function Ge(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const i=t.motif.options,s=i?.[Me];try{if(!0===s?.skipNextLeave||!0===t._forceInstantDetach)return s&&(s.skipNextLeave=!1),t._forceInstantDetach=!1,void qe(t,e,!0)}catch{}if(s||i?.transitionOut)try{i.transition.leaveTransition(()=>{qe(t,e,!1)})}catch{qe(t,e,!1)}else qe(t,e,!1)}const Ke=Promise.resolve();function Ye(t,e){if(!e&&t._disposing&&!t.isDisposed)return!1;if(t.disposeAsync!==ai.prototype.disposeAsync)return!1;const i=t.motif?.options;if(i){if(i.transitionOut)return!1;const t=i[Me];if(t){if(t.activeAnimations&&t.activeAnimations.length>0)return!1;if(t.activeCssCancel)return!1;if(t.classes||t.name&&t.name.length>0)return!1}}const s=t.controls?.items;if(s)for(let t=0;t<s.length;t++){const e=s[t];if(e&&!e.isDisposed&&!Ye(e,!1))return!1}return!0}const Qe=new WeakMap;function Ze(t,e,i){const s=i?"disposeAsync":"dispose";if(Ln._disposingCount>0){const e=function(t){for(let e=t;e;e=e.parent){if(e.application)return e.application;const t=Qe.get(e);if(t)return t}return Ln.main??null}(t);e&&"disposing"===e.state&&Qe.set(t,e)}!i&&e?.skipLeaveTransition&&(t.motif.options.transition.skipNextLeave=!0),n(()=>{Ue.callDisposing.call(t,t)},s+".callDisposing"),t._base._offAll(),t._base._deactivateBindings(),n(()=>{t.parent?.controls?.silentDetach?.(t,!0)},s+".silentDetach")}function ti(t,e,i){if(t.isDisposed=!0,E.prototype.dispose.call(t),i)return t.controls.items=[],n(()=>{Ue.callDisposed.call(t,t)},"disposeAsync.callDisposed"),n(()=>{t._base.emiters.clear()},"disposeAsync.emiters"),void(e?.deep&&t._base._deepCleanup());t.element=null,n(()=>{Ue.callDisposed.call(t,t)},"dispose.callDisposed"),n(()=>{t._base.emiters.clear()},"dispose.emiters"),t._base._offAll(),t._base._deepCleanup()}async function ei(t,e,i,s){s?await s:((i||Xe(t)?.skipNextLeave)&&await t.motif.stopAnimations(),await t._base._detachDomWithAnimationAsync()),i||"TransportTo"===t.constructor.name||await async function(t){if(0===be.live)return;const e=ci(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()}))}(t);const n={deep:e?.deep};await o(async()=>{if(t.isDisposed)return;const e=Array.from(t.controls.items);e.length&&await Promise.all(e.map(t=>i?o(async()=>{await t.disposeAsync(n)},"disposeAsync.disposeAsyncChildren.handler"):(async()=>{try{await t.disposeAsync(n)}catch(t){M("MJX107",t)}})()))},i?"disposeAsync.disposeAsyncChildren":"dispose.disposeAsync"),!i&&t.isDisposed||ti(t,e,i)}const ii={_offAll(){const t=this.owner;if(t._eventHandlers){for(const[e,i]of t._eventHandlers){const s=e.split(":")[0],n=s.startsWith("on")?s.slice(2).toLowerCase():s.toLowerCase();for(const e of i){if(!e||!e.wrapped)continue;if(!1===e.domEvent)continue;const i=!0===e.capture;try{t.element.removeEventListener(n,e.wrapped,i)}catch{}try{void 0===e.capture&&t.element.removeEventListener(n,e.wrapped,!i)}catch{}}}t._eventHandlers.clear(),t._eventHandlers=void 0}},_deactivateBindings(){const t=this.owner;try{t.bindings?.deactivateAll()}catch{}},_activateBindings(){const t=this.owner;try{t.bindings?.activateAll()}catch{}},_reactivateBindings(){const t=this.owner;try{t.bindings?.reActivateAll()}catch{}},_activatePreBindings(){if(this.prebinding_Activated)return;const t=this.owner,e=t.bindings?._items;e&&e.length>0&&t.bindings.items.filter(t=>"isWait"==t.propertyName||"display"==t.propertyName).forEach(t=>{t.activate()}),this.prebinding_Activated=!0},_detachDomWithAnimation(){Ge(this.owner)},_detachDomWithAnimationAsync(){return async function(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const i=t.motif.options,s=i?.[Me];try{if(!0===s?.skipNextLeave||!0===t._forceInstantDetach)return s&&(s.skipNextLeave=!1),t._forceInstantDetach=!1,void qe(t,e,!0)}catch{}if(s||i?.transitionOut)return new Promise(s=>{try{i.transition.leaveTransition(()=>{qe(t,e,!1),s()})}catch{qe(t,e,!1),s()}});qe(t,e,!1)}(this.owner)},_disposeShallow(){!function(t){if(!t.isDisposed){Ue.callDisposing.call(t,t);try{t._base._offAll()}catch{}if(t.motif.stopAnimations(),t._base._deactivateBindings(),t.controls?.items?.length)for(const e of t.controls.items)try{e._base._disposeShallow()}catch{}Ue.callDisposed.call(t,t),n(()=>{t._base.emiters.clear()},"disposeShallow.emiters"),t.isDisposed=!0,E.prototype.dispose.call(t)}}(this.owner)},_deepCleanup(){!function(t){try{t.parent=null}catch{}try{t._eventHandlers?.clear()}catch{}t._eventHandlers=void 0;try{t.class?._countsStore?.clear()}catch{}try{t.class?._watchersStore?.clear()}catch{}try{t.attr?._attrMapStore?.clear()}catch{}try{t.attr?._watchersStore?.clear()}catch{}try{t.motif.options&&(t.motif.options.cache=void 0,t.motif.options.closeFragment=void 0,t.motif.options.placeholder=void 0)}catch{}try{t.element=null}catch{}try{t.props=void 0}catch{}try{t.childs=void 0}catch{}try{t.class=void 0}catch{}try{t.attr=void 0}catch{}try{t.parent=null}catch{}try{t.motif.options=void 0}catch{}const e=Object.keys(t);for(let i=0;i<e.length;i++){const s=e[i];if("motif"!==s)try{t[s]=void 0}catch{}}t.isDisposed=!0}(this.owner)}};const si=new WeakMap,ni=new Set(["building","built","initializing","initialized","disposing","disposed","config","configured","visibilitychanged","activated","deactivated"]),oi=Symbol("motif.rawApplication"),ri=new Set(["on","onRouterChanged"]);class ai extends E{motif=new Qt(this,new je(this));element;props;isBuilt=!1;isInitialized=!1;isDisposed=!1;isConfigured=!1;isPainting=!1;isPainted=!1;isVisible=!0;controls=new cs(this);_eventHandlers;_isWait=!1;class=new Vt(this);attr=new zt(this);bindings=new Xt(this);_styleFx;useModel(t){return Ws(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&&Ue.internalBuild.call(this.parent,this)}get isWait(){return this._isWait}constructor(t,e={}){if(super(),ge(this),this.onElementCreating?this.element=this.onElementCreating.call(this):this.element=e?.onElementCreating?e.onElementCreating.call(this):t,e){const t=di(e,this);if(t.length>0)for(const e of hi(this,t))C(()=>e(this),"MJX122","ref")}if(e&&mi(e,this),Si(e?.options,this),this.props=e,e){const t=new.target;t===ai||Object.getPrototypeOf(t)===ai?Ti(e,this):Li(e,this)}if(Ue.callOnInitializing(this),this.isDisposed)return;this.controls.onAdd=t=>{this._eventHandlers?.has("controladded")&&this.motif.trigger("controladded",{control:t}),this.isWait||this.parent?.isWait||Ue.internalBuild.call(this,t)},this.controls.onAddBeforeBuild=t=>{this._eventHandlers?.has("controladded")&&this.motif.trigger("controladded",{control:t})},this.controls.onRemove=t=>{this._eventHandlers?.has("controlremoved")&&this.motif.trigger("controlremoved",{control:t})},Ue.callOnInitialized(this);const i=new.target;i===ai||Object.getPrototypeOf(i)===ai?Ue.callConfig(this):this._base._configDeferred=!0}childs;_base=function(t){const e=Object.create(ii);return e.owner=t,e.prebinding_Activated=!1,e.emiters=new It(t),e}(this);parent=null;_scopedContext;get context(){const t=this.parent?.context,e=t?.[oi]??t??Qe.get(this)??Ln.main;return e?(this._scopedContext?.[oi]!==e&&(this._scopedContext=function(t,e){const i=new Map;return new Proxy(t,{get(t,s){if(s===oi)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=ri.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(k.toDisposable(t));return()=>{this._disposables.detach(e),t()}}build(t=!0){if($e(this),Ue.callConfigured(this),this._base._activatePreBindings(),this.isDisposed||!this.element||this.isWait)return;if(this.isBuilt||this.isWait)return;if(Ue.callBuilding(this),this.isDisposed)return;var e=this.element;t&&(e=ns.createDocumentFragment());const i="string"!=typeof this.element&&this.element.nodeType===Node.COMMENT_NODE;if(i&&(this.motif.options.cache=ns.createDocumentFragment(),this.element.textContent="[",this.motif.options.cache.appendChild(this.element)),this.isBuilt)return;if(Ue.callInitializeComponent(this),this.isDisposed)return;if(this.view){const t=this.view();if(this.controls.add(t),this.isDisposed)return}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&&Ue.activateTree(s)}if(!this.isDisposed){if(Je(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 Re(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=ns.createComment("]"),this.motif.options.cache.appendChild(this.motif.options.closeFragment),this.element.nodeType===Node.COMMENT_NODE&&this.motif.options.closeFragment&&si.set(this.element,this.motif.options.closeFragment)),this.isBuilt=!0,Ue.callBuilt(this),Ue.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&&(vi(t)?function(t,e){if(wi.has(t))return;wi.add(t),A("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;if(this.parent&&"out-in"===Ie(this.parent)){const t=this.motif.options.placeholder?.parentNode??Ri(this.parent)?.element,e=xe(t,this.element);if(e){const t=this._base._showSeq=(this._base._showSeq??0)+1;return e.then(()=>{if(!this.isDisposed&&this._base._showSeq===t)return this._show()})}}Xe(this)?.activeAnimations?.length&&n(async()=>{await Promise.all(this.motif.options.transition.activeAnimations.map(t=>t.finished?.catch(()=>{})))},"show.waitForLeaveAnimations");if("detach"===this._computeHideStrategy()){if(Ue.callVisibilityChanged(this),this.isDisposed)return;const t=!this._isInDom()&&this.parent&&this.parent.isBuilt&&!this.isWait;return this.isVisible=!0,void(t&&Ue.internalBuild.call(this.parent,this))}{const e=this.motif.options.placeholder?.parentElement,i=Ri(this.parent)?.element;if(this.motif.options.placeholder&&e&&e!==i)return A("MJX106",[]),this.isVisible=!0,void(this.parent?.isBuilt&&Ue.internalBuild.call(this.parent,this));if(Je(this)&&this.motif.options.transition.enterTransition(()=>{}),Ue.callVisibilityChanged(this),this.isDisposed)return;if(this.element.nodeType===Node.COMMENT_NODE)return this.controls.forEach(t=>{t.motif.show()}),this.isVisible=!0,void Ue.activateTree(this,!1);var t=this.motif.options.placeholder?.parentElement;t&&(t.replaceChild(this.element,this.motif.options.placeholder),this.isVisible=!0,Ue.activateTree(this))}}async _hide(){if(this.isDisposed||!this.element)return;if(this._base._showSeq=(this._base._showSeq??0)+1,!this.isVisible)return;if("detach"===this._computeHideStrategy()){if(Ue.callVisibilityChanged(this),this.isDisposed)return;return await this._base._detachDomWithAnimationAsync(),this.isVisible=!1,void Ue.deactivateTree(this)}{const t=this.motif.options.transition,e=!0===t.skipNextLeave;e&&(t.skipNextLeave=!1);const i=()=>{if(Ue.callVisibilityChanged(this),!this.isDisposed){if(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 Ue.deactivateTree(this,!1);var t=this.element.parentElement;t&&(this.motif.options.placeholder||(this.motif.options.placeholder=ns.createComment("h")),t.replaceChild(this.motif.options.placeholder,this.element)),this.isVisible=!1,Ue.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=Ii(this.element,()=>{if(t&&(this._base._mountedSubs?.get(e)?.delete(t),this._disposables.detach(t)),this.isDisposed)return;const i={cancel:!1};C(()=>e.length<=1?e(i):e(this,i),"MJX122","x:mounted")});if(i){t=this._register(k.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(ni.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){M("MJX123",t,r)}i&&"function"==typeof i.then&&i.then(void 0,t=>M("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(),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(k.toDisposable(()=>{this.motif.off(t,e)})),this}async _trigger(t,e){if(this.isDisposed||!this.element)return this;const i=String(t).toLowerCase();return n(()=>{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 ni.has(t)&&this._base.emiters.off("on"+t,e),this}const s=i.split(":")[0],o=s.startsWith("on")?s.slice(2).toLowerCase():s.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;n(()=>{this.element.removeEventListener(o,t.wrapped,e)},"off.removeEventListener"),n(()=>{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?this._disposing:(ve(this),this._disposing=Ke,this._disposing=this._disposeCore(t,!1))}async _disposeCore(t,e){let i;if(Ze(this,t,e),e||Xe(this)?.skipNextLeave||(i=this._base._detachDomWithAnimationAsync()),await void 0,0===be.live&&Ye(this,!0)){const s=function(t,e,i,s){const n={deep:e?.deep},o=[t],r=[-1];let a=null;s||Ge(t);for(let e=0;e<o.length;e++){const i=o[e];if(i.isDisposed)continue;const s=i.controls?.items;if(!s||0===s.length)continue;const c=Array.from(s);for(let i=0;i<c.length;i++){const s=c[i];if(!s.isDisposed)if(s._disposing)(a??=[]).push(s._disposing);else try{ve(s),s._disposing=t._disposing,Ze(s,n,!0),Ge(s),o.push(s),r.push(e)}catch(t){M("MJX107",t)}}}const c=o.length;if(c>1){const t=new Array(c).fill(0);for(let e=c-1;e>=1;e--){const i=r[e];t[e]+1>t[i]&&(t[i]=t[e]+1)}const e=[];for(let t=1;t<c;t++)e.push(t);e.sort((e,i)=>t[e]-t[i]||e-i);for(let t=0;t<e.length;t++)try{ti(o[e[t]],n,!0)}catch(t){M("MJX107",t)}}return a||(!i&&t.isDisposed||ti(t,e,i),null)}(this,t,e,void 0!==i);if(s){if(await Promise.all(s),!e&&this.isDisposed)return;ti(this,t,e)}return}await ei(this,t,e,i)}disposeAsync(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(ve(this),this._disposing=Ke,this._disposing=this._disposeCore(t,!0))}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:S("MJX108"))}_siblingsApi;_siblingsSet;get siblings(){return this._siblingsSet||this.isDisposed&&!this.motif?.options?this._siblingsApi:this._siblingsApi??=this._createSiblingsApi()}set siblings(t){this._siblingsApi=t,this._siblingsSet=!0}_createSiblingsApi(){return{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;const i=Qe.get(t);if(i)return"disposed"===i.state?null:i.provider;t=t.parent}try{return Ln.main?.provider??null}catch{return null}}getService(t){try{const e=this.serviceProvider;if(e)return e._getFor(this,t);A("MJX407",[Le(t)],{token:t})}catch(e){A("MJX408",[Le(t),String(e?.message??e)],{token:t,error:e})}return null}$(t){return this.isDisposed||!this.element?{fromDom:()=>null,fromComponent:()=>[]}:{fromDom:()=>{var e,i=Ri(this)?.element;return(e=i||document)?e.querySelectorAll(t):null},fromComponent:()=>{const e=Ri(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(){const t=Xe(this);try{t?.activeCssCancel?.()}catch{}try{if(t?.activeAnimations?.length)try{await Promise.all(t.activeAnimations.map(t=>t.finished?.catch(()=>{})))}catch{}}catch(t){}this.isDisposed||t&&(t.activeAnimations=[])}}function ci(t,e=[]){return!t||t.isDisposed||("TransportTo"===t.constructor.name&&e.push(t),t.controls&&t.controls.items&&t.controls.items.forEach(t=>ci(t,e))),e}const li=new WeakMap;function hi(t,e){const i=(Array.isArray(e)?e:[e]).filter(t=>"function"==typeof t);if(0===i.length)return i;let s=li.get(t);s||(s=new Set,li.set(t,s));const n=[];for(const t of i)s.has(t)||(s.add(t),n.push(t));return n}const ui=t=>"function"==typeof t||Array.isArray(t);function di(t,e){const i=[];if(!t||"object"!=typeof t)return i;Object.prototype.hasOwnProperty.call(t,"ref")&&(ui(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(ui(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 0===i.length?i:[].concat(...i)}const pi={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 fi(t,e,i){const s=Object.prototype.hasOwnProperty.call(pi,e)?pi[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 mi(t,e){if(t){e.motif.options.props||(e.motif.options.props={}),Object.assign(e.motif.options.props,t);var i=Object.keys(t);if(0===i.length)return;i.forEach(i=>{if("initializeComponent"==i||"oninitializeComponent"==i||i.startsWith("on")){if(fi(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)yi(t[i],e),delete t[i];else if(Xi.hasOwnProperty(i.toLowerCase())||Xi.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(fi(e,n.toLowerCase(),t[i]))return void delete t[i];delete t[i]}else i.startsWith("runover")?(mi(t[i],e),delete t[i]):i.startsWith("preconfig")&&(e.motif.options._preconfig=t[i],delete t[i])})}}const _i=new WeakMap;function gi(t,e,i){const s=t.motif.options.transition;if("string"==typeof e&&e.length>0)s.name=e,i&&(s.classes=void 0);else if(e&&"object"==typeof e)if("string"==typeof e.name&&e.name.length>0&&(s.name=e.name),"mode"in e){const{mode:t,...i}=e;Pe(t)&&(s.mode=t),Object.keys(i).length>0&&(s.classes=i)}else s.classes=e;else i&&(s.name="",s.classes=void 0)}function yi(t,e){e&&!e.isDisposed&&null!=t&&_i.get(e)!==t&&(_i.set(e,t),"function"!=typeof t?gi(e,t,!1):e.bindings.watch(()=>{const i=t();e.isDisposed||gi(e,i,!0)}))}function vi(t){return t instanceof ai||Array.isArray(t)&&t.length>0&&t.every(t=>t instanceof ai)}const wi=new WeakSet;const bi=["hideStrategy","disableDisposal"];function Si(t,e){if(t&&"object"==typeof t&&e&&!e.isDisposed)for(const i of bi)void 0!==t[i]&&(e.motif.options[i]=t[i])}const Mi=new Set(["ref","key","indexkey","inject","options","props","settings","isSvg","childs","initializeComponent","runover","transition","preconfig","nodes","onElementCreating"]),Ci=new Set(["innerhtml","srcdoc"]),Ai=new Set(["href","src","action","formaction","xlink:href"]),ki=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Di(t){if(null==t||"boolean"==typeof t)return!1;try{return ki.test(String(t))}catch{return!1}}function Ei(t,e){return()=>{let i=e();return"function"==typeof i&&(i=i()),"function"==typeof i&&(i=i()),Di(i)?(A("MJX125",[t]),null):i}}function Ti(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const i=Object.keys(t);if(0===i.length)return;let s=null,n=null;for(const o of i){if(Mi.has(o))continue;if(o.startsWith("x-")||o.startsWith("x:")||o.startsWith("__"))continue;let i=t[o];if(void 0===i)continue;if(/^on/i.test(o)){"function"==typeof i&&e.motif.on(o,i);continue}if("function"==typeof i&&i.length>0)continue;const r=o.toLowerCase();if(Ci.has(r))A("MJX124",[o]);else{if(Ai.has(r))if("function"==typeof i)i=Ei(o,i);else if(Di(i)){A("MJX125",[o]);continue}(n??=Oi(e)).set(o,i),"class"===o||"className"===o?e.class.add(i&&"object"==typeof i&&!Array.isArray(i)?[i]:i):"style"===o?e.style(i):"value"===o||"checked"===o||"selected"===o?e.bindings.add(o,i):(s??={})[o]=i}}s&&e.attr.add(s)}const xi=new WeakMap;function Oi(t){let e=xi.get(t);return e||(e=new Map,xi.set(t,e)),e}const Ni=new Set(["class","className","style","id","tabindex","role"]);function Pi(t){return Ni.has(t)||t.startsWith("aria-")||t.startsWith("data-")}function Li(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const i=xi.get(e);let s=null;for(const e of Object.keys(t)){if(!Pi(e))continue;const n=t[e];null!=n&&("function"==typeof n&&n.length>0||i&&i.has(e)&&Object.is(i.get(e),n)||((s??={})[e]=n))}s&&Ti(s,e)}const Xi={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 Ri(t){return n(()=>!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?Ri(t.parent):null,"findAppendableComponent",null)}function Ii(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 Ji(t){!function(t){const e=ue.get(t);e&&(ue.delete(t),e.live&&e.scope._releaseLivePin(),ce?._touch())}(t),Ue.activateTree(t)}function Hi(t){ye(t),Ue.deactivateTree(t)}const ji=100;function Fi(t,e){let i=t,s=0;for(;"function"==typeof i;){if(i.prototype instanceof ai)return new i(e);if(++s>ji)return M("MJX112",void 0,ji),i;i=i(e)}return i}const Bi="http://www.w3.org/2000/svg";class zi extends ai{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&&qi(e=Fi(e,i)))return Qi(e,i);if(Array.isArray(e)){super(ts(),{});var n=Object.create(i||{});for(const t in e){const i=e[t];this.controls.add(new zi(i,n))}}else if("string"==typeof e&&e.trim().length>0)if(i||(i={}),i?.options&&i.options.isSvg||i?.__isSvgElement){const t=ns.createElementNS("http://www.w3.org/2000/svg",e,i);i.isSvg=!0,super(t,i)}else{super(ns.createElement(e,i),i)}else if(e instanceof Node)super(e,i);else{if(e instanceof ai)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===Bi||!0===i?.options?.isSvg||!0===i?.__isSvgElement?(i&&"object"==typeof i&&(i.isSvg=!0),ns.createElementNS(s||Bi,t,i)):ns.createElement(t,i)}(n,t,s),s??{})}else super(ts(),s??{});const o=this.childs;if(Array.isArray(o)&&o.length)for(const t of o)t&&this.controls.add(t)}}}}function Vi(t,e){if(t instanceof ai)for(const i of hi(t,e))C(()=>i(t),"MJX122","ref");return t}function Wi(t,e){const i=t._base?.[e];return Array.isArray(i)?i.length:0}function $i(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];C(()=>i(t,{cancel:!1}),"MJX122",s)}}function Ui(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=kt(t)}catch{return}return e instanceof ai||Array.isArray(e)&&e.length>0&&e.every(t=>t instanceof ai)?e:void 0}(e.__childExpr);if(void 0!==t)return t}return new zi(t,e)}if(t instanceof ai||t instanceof zi)return t;if("function"==typeof t){const i=t.prototype instanceof ai?[]:di(e),s=Fi(t,e);return"object"==typeof s&&null!==s&&"el"in s?Vi(Qi(s,e),i):function(t,e,i){if(!e||"object"!=typeof e)return t;if(!(t instanceof ai))return t;Vi(t,i.concat(di(e))),Li(e,t),Si(e.options,t),Object.prototype.hasOwnProperty.call(e,"transition")&&yi(e.transition,t);const s=e.runover;if(!s||"object"!=typeof s)return t;const n=t._base?._onConfigHandlers,o=Array.isArray(n)?n.length:0,a=Wi(t,"_onInitializingHandlers"),c=Wi(t,"_onInitializedHandlers");if(mi(s,t),$i(t,"_onInitializingHandlers",a,"onInitializing"),$i(t,"_onInitializedHandlers",c,"onInitialized"),t.isConfigured){const e=t.motif.options?._preconfig;"function"==typeof e&&r(()=>e(t),"motifComponent.preconfig");const i=t._base?._onConfigHandlers;if(Array.isArray(i))for(let e=o;e<i.length;e++){const s=i[e];C(()=>s(t,{cancel:!1}),"MJX122","onConfig")}}return t}(s,e,i)}return"object"==typeof t&&null!==t&&"el"in t?Qi(t,e):new zi(t,e)}function qi(t){return"object"==typeof t&&null!==t&&!(t instanceof ai)&&"el"in t}function Gi(t){return!t||"object"!=typeof t||t instanceof ai||null==t.default?t:t.default}function Ki(t){if(null!==t&&"object"==typeof t&&!(t instanceof ai||Array.isArray(t)||t instanceof Node)&&"function"!=typeof t.then)throw S("MJX127",function(t){return null===t?"null":Array.isArray(t)?"array":"object"!=typeof t||"[object Module]"!==Object.prototype.toString.call(t)&&!t.__esModule?typeof t:"module"}(t))}function Yi(t,e){const i=Fi(t,e);return qi(i)?Qi(i,void 0):i}function Qi(t,e){const i=Ui(t.el,e);return Object.getOwnPropertyNames(t).forEach(e=>{"el"!==e&&"ctor"!==e&&(i[e]=t[e])}),"function"==typeof t.ctor&&C(()=>t.ctor.call(i,e),"MJX122","ctor"),i}function Zi(t){return new es(t)}function ts(){return ns.createComment("")}class es extends zi{constructor(t,e){super(ts(),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);r(()=>{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 is=globalThis;function ss(){return is&&is.motifDom?is.motifDom.window.document:is.document}const ns={get window(){return is&&is.window?is.window:is&&is?is.motifDom.window:is},_created:new Map,document:ss(),createElement(t,e){const i=ss();if(!i)throw S("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=ss();if(t)return t.createDocumentFragment()}catch(t){s.reportSuppressed("dom.createDocumentFragment",t)}},createComment(t){try{return ss()?.createComment(t)}catch(t){s.reportSuppressed("dom.createComment",t)}},createTextNode(t){try{return ss()?.createTextNode(t)}catch(t){s.reportSuppressed("dom.createTextNode",t)}},querySelectorAll(t){try{return ss()?.querySelectorAll(t)}catch(t){s.reportSuppressed("dom.querySelectorAll",t)}},createElementNS(t,e,i){try{return ss()?.createElementNS(t,e,i)}catch(t){M("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 ss()?.body}},os=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;var rs;function as(t,e,...i){return function(t,e,i,...s){const n=os.exec(e);if(!n)throw S("MJX102",e);const o=n[1]||"div";let r;return r=t!==rs.HTML?ns.createElementNS(t,o):ns.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}(rs.HTML,t,e,...i)}!function(t){t.HTML="http://www.w3.org/1999/xhtml",t.SVG="http://www.w3.org/2000/svg"}(rs||(rs={}));class cs{owner;constructor(t){this.owner=t}items=[];add(){const t=arguments.length;if(0===t)return[];const e=arguments[0];if(1===t&&e instanceof ai)return e.isDisposed?[]:[this._insertOne(void 0,e)];const i=Array.from(arguments);if("number"==typeof i[0]&&i.length>1){const t=i[0],e=[].concat(...i.slice(1));return this.insert(t,...e)}{const t=[].concat(...i);return this.insert(void 0,...t)}}insert(t,...e){return[].concat(...e).filter(t=>null!=t&&!t.isDisposed).map(e=>this._insertOne(t,e))}_insertOne(t,e){"string"!=typeof(e=Fi(e))&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e||(e=new zi(ns.createTextNode(e),null)),$e(e),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._base&&(t._base._leaveContainer=this.owner),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{ls(t)}catch(t){M("MJX117",t)}Hi(t)}try{e()}catch(t){M("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{const e=t.motif.options;if(!e[Me]&&!e.transitionOut)return void s();e.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{ls(t)}catch(t){M("MJX117",t)}Hi(t)}}silentUnlink(t){const e=this.items.indexOf(t);-1!==e&&(this.items.splice(e,1),t._base&&(t._base._leaveContainer=this.owner),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&&M("MJX120",void 0);return!1}(n,o,i)&&(i=o.nextSibling);const r=ns.createDocumentFragment&&ns.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&&M("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&&M("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 ls(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=ns.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 hs(t){return Gi(t)}function us(t){const e=t&&t.options||{},i=new _s,s=new Set,n=t=>{try{s.add(t)}catch{}return t},o=()=>{try{s.forEach(t=>{try{clearTimeout(t)}catch{}})}catch{}try{s.clear()}catch{}};try{i.motif.register(k.toDisposable(()=>o()))}catch{}const r=e.Placeholderview??e.Loaderview;null!=r&&i.navigate(Yi(r));const a=()=>{if(!e.timeoutMs&&!e.signal)return t.caller();const i=[t.caller()];return e.timeoutMs&&e.timeoutMs>0&&i.push(new Promise((t,o)=>{const r=n(setTimeout(()=>o(S("MJX110",e.timeoutMs)),e.timeoutMs));if(i[0].finally(()=>{try{clearTimeout(r),s.delete(r)}catch{}}).catch(()=>{}),e.signal){const t=()=>{try{clearTimeout(r),s.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(S("MJX111"));const s=()=>{e.signal.removeEventListener("abort",s),o(),i(S("MJX111"))};e.signal.addEventListener("abort",s,{once:!0})})),Promise.race(i)},c=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),l=new Set;try{i.motif.register(k.toDisposable(()=>{l.forEach(t=>{try{t()}catch{}}),l.clear()}))}catch{}const h=t=>new Promise(i=>{let o=!1;const r=t=>{if(!o){o=!0,l.delete(a);try{d&&window.removeEventListener("online",d)}catch{}try{void 0!==u&&(clearTimeout(u),s.delete(u))}catch{}try{e.signal?.removeEventListener("abort",h)}catch{}i(t)}},a=()=>r(!1),h=()=>r(!1);let u,d=null;l.add(a);try{e.signal?.addEventListener("abort",h,{once:!0})}catch{}const p=()=>{u=n(setTimeout(()=>r(!0),c.delayMs*t))};c.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()}),u=c.count>0?(async()=>{let t=0;for(;;)try{return await a()}catch(s){if(e.signal?.aborted||i.isDisposed||t>=c.count)throw s;t++;try{e.onRetry?.(t,s)}catch{}if(!await h(t)||e.signal?.aborted||i.isDisposed)throw s}})():a(),d=Date.now(),p=t=>{try{e.onError?.(t)}catch{}if(!e.signal?.aborted)if(null!=e.Fallbackview)i.navigate(Yi(e.Fallbackview));else{M("MJX126",t);try{i.motif.clear().catch(()=>{})}catch{}}},f=t=>{let e;try{e=Yi(t),Ki(e)}catch(t){return void p(t)}i.navigate(e)};return u.then(t=>{if(e.signal?.aborted)return;const i=(e.mapResult??hs)(t),o=Date.now()-d,r=Math.max(0,e.minDelayMs??0),a=Math.max(0,r-o);if(a>0){const t=n(setTimeout(()=>{e.signal?.aborted||f(i)},a));if(e.signal){const i=()=>{try{clearTimeout(t),s.delete(t)}catch{}};try{e.signal.addEventListener("abort",i,{once:!0})}catch{}}}else f(i)}).catch(p),i}function ds(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 ps(t){if(t&&!t.isDisposed)if(Array.isArray(t))t.forEach(ps);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)ps(e)}catch{}}}async function fs(t,e={deep:!0}){if(!t)return;const i=Array.isArray(t)?t:[t];await Promise.all(i.map(async t=>{if(t&&!t.isDisposed)try{await t.dispose(e)}catch(t){M("MJX115",t)}}))}async function ms(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=Fi(e);t.current=i;try{Array.isArray(i)?t.controls.add(...i):t.controls.add(i)}catch(t){M("MJX114",t)}t.isBusy=!1,t.previouspage=i};if(!(t._navPending||null!==t.current||e instanceof Promise)){try{n(e)}catch(e){M("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 r=t.current;if(r&&!i){ps(r),ps(t);const e=!!(s=r)&&(Array.isArray(s)?s.some(t=>!!t&&!t.isDisposed&&ds(t,"leave")):!s.isDisposed&&ds(s,"leave")),i=fs(r);e?i.catch(()=>{}):await i}try{if(e instanceof Promise){const i=us({caller:()=>e,options:{signal:t._navAbort?.signal}});n(i)}else n(e)}catch(e){M("MJX114",e),t.isBusy=!1}}finally{t._navPending=Math.max(0,(t._navPending??1)-1)}var s})(),await t._navLock}class _s extends zi{current=null;_latestNavigateId=0;_navLock=Promise.resolve();_navAbort;isBusy=!1;constructor(t){super(ns.createComment(""),t),t&&t.childs&&Array.isArray(t.childs)&&t.childs.length>0&&this.controls.add(t.childs)}async dispose(t={deep:!0}){await fs(this.current,t),await super.dispose(t)}async flush(){await fs(this.current)}async _clear(){await fs(this.current)}previouspage;async navigate(t,e=!1){await ms(this,t,e)}async navigateLazy(t,e,i=!1){const s=us({caller:t,options:e});await this.navigate(s,i)}}const gs=new Set;const ys=new Map,vs=Symbol("changeBodyCollectionHandler");const ws=Symbol("slotRegistered"),bs=Symbol("slotUnregistered");class Ss{static slots=new Map;static registerSlot(t,e){this.slots.set(t,e),Ln.main.fire(ws,{name:t,slot:e})}static unregisterSlot(t,e){this.slots.get(t)===e&&(this.slots.delete(t),Ln.main.fire(bs,{name:t,slot:e}))}static getSlot(t){return this.slots.get(t)}}class Ms{static transport(t,e,i={}){t&&e&&(t.parent===e&&e.controls.items.includes(t)||(t.parent&&t.parent!==e&&t.parent.controls.silentDetach(t,!0),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 S("MJX113");this.children.includes(t)||(Ms.transport(t,this.parent,e),this.children.push(t))},unmount(t){if(!this.parent)throw S("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=[])}}}}const Cs=new Set(["push","pop","shift","unshift","splice","reverse","sort"]),As=Symbol(""),ks=new Map([[T.IS_REACTIVE,()=>!0],[T.IS_READONLY,t=>t.isReadonly],[T.IS_SUPERFICIAL,t=>t.superficial],[T.GET_SETUP,(t,e)=>e],[T.RAW,(t,e,i)=>t.ReactiveMap().get(e)===i?e:As]]);function Ds(t,e,i,s){if("symbol"!=typeof i)return As;const n=ks.get(i);return void 0===n?As:n(t,e,s)}function Es(t){return function(e,i,s){const n=Ds(t,e,i,s);if(n!==As)return n;if(Array.isArray(e)&&!t.isReadonly){const s=t.arrayMethods.get;if(L(s,i)){const t=s[i];return Cs.has(i)?(o=i,W.push(N),N.enabled=!0,N.key=o):gt(e,i),t}}var o;const r=Reflect.get(e,i,s);return"__proto__"===i||I(i)?r:(t.isReadonly||gt(e,i),t.superficial||!X(r)?r:t.reactive(r))}}function Ts(t){return function(e,i,s,n){if(null!=(o=e)&&Boolean(o[T.IS_READONLY]))return!1;var o;const r=Array.isArray(e),a=e[i],c=r?e.length:0,l=r&&("string"==typeof(h=i)&&H.test(h)&&String(Number(h))===h);var h;const u=l?Number(i)<c:L(e,i),d=Reflect.set(e,i,s,n);if(t.onValueChanged)try{t.onValueChanged({raw:e,proxy:n},i)}catch{}if(P(e)!==P(n))return d;if(!r&&u&&Object.is(s,a))return d;if(yt(e,i),r||u||yt(e,x),l&&!u&&yt(e,"length"),r&&"length"===i){for(let t=Number(s);t<c;t++)yt(e,String(t))}return function(){const t=W.pop();N=W.length>0?void 0===t?{enabled:!1,key:""}:t:{enabled:!1,key:""}}(),d}}function xs(t){return function(t){return gt(t,Array.isArray(t)?"length":x),Reflect.ownKeys(t)}}function Os(t){return function(t,e){const i=Reflect.has(t,e);return I(e)||gt(t,e),i}}function Ns(t){return function(t,e){z();try{const i=L(t,e),s=Reflect.deleteProperty(t,e);return i&&(Array.isArray(t)?yt(t,"length"):(yt(t,e),yt(t,x))),s}finally{V()}}}const Ps=[["includes","lookup"],["indexOf","lookup"],["lastIndexOf","lookup"],["sort","order"],["concat","join"],["push","structural"],["pop","structural"],["shift","structural"],["unshift","structural"],["splice","structural"],["reverse","structural"]];class Ls{engine;constructor(t){this.engine=t}get=this.createArrayMethods();createArrayMethods(){const t={};for(const[e,i]of Ps)t[e]=this.patch(e,i);return t}patch(t,e){const i=this;switch(e){case"lookup":return function(...e){const s=P(this);i.engine.track(s,"length");const n=s[t](...e);return!1!==(o=n)&&-1!==o?n:s[t](...e.map(t=>P(t)));var o};case"order":return function(...e){const s=P(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){z();const i=P(this);try{return i[t].apply(this,e)}finally{V()}}}}}const Xs=Symbol("");function Rs(t,e,i){yt(t,e),yt(t,x),i&&yt(t,Xs)}function Is(t,e){return t.has(e)?e:P(e)}function Js(t,e){return{next(){const i=t.next();return i.done?i:{value:e(i.value),done:!1}},[Symbol.iterator](){return this}}}function Hs(t){const e=function(t){const e=e=>X(e)?t.reactive(e):e,i=t=>t instanceof Map?([t,i])=>[t,e(i)]:([t])=>{const i=e(t);return[i,i]};return{get(t){const i=P(this),s=Is(i,t);return gt(i,s),e(i.get(s))},has(t){const e=P(this),i=Is(e,t);return gt(e,i),e.has(i)},set(t,e){const i=P(this),s=Is(i,t),n=P(e),o=i.has(s),r=i.get(s);return i.set(s,n),o?Object.is(r,n)||Rs(i,s,!1):Rs(i,s,!0),this},add(t){const e=P(this),i=Is(e,t);return e.has(i)||(e.add(i),Rs(e,i,!0)),this},delete(t){const e=P(this),i=Is(e,t),s=e.delete(i);return s&&Rs(e,i,!0),s},clear(){const t=P(this);if(0===t.size)return;const e=Array.from(t.keys());t.clear();for(const i of e)yt(t,i);yt(t,x),yt(t,Xs)},forEach(t,i){const s=P(this);gt(s,x);const n=this,o=s instanceof Map;s.forEach((s,r)=>{const a=e(s);t.call(i,a,o?r:a,n)})},keys(){const t=P(this);return t instanceof Map?(gt(t,Xs),t.keys()):(gt(t,x),Js(t.keys(),e))},values(){const t=P(this);return gt(t,x),Js(t.values(),e)},entries(){const t=P(this);return gt(t,x),Js(t.entries(),i(t))},[Symbol.iterator](){const t=P(this);return gt(t,x),t instanceof Map?Js(t.entries(),i(t)):Js(t.values(),e)}}}(t);return{get(i,s,n){const o=Ds(t,i,s,n);if(o!==As)return o;if("size"===s)return gt(i,x),i.size;if(("string"==typeof s||s===Symbol.iterator)&&L(e,s)&&s in i)return e[s];const r=Reflect.get(i,s,i);return"function"==typeof r?r.bind(i):r}}}const js=new WeakSet,Fs=new WeakMap;const Bs=new class{_gci;startGc(t=1e4){}stopGc(){if(this._gci){try{clearInterval(this._gci)}catch{}this._gci=void 0}}constructor(){js.add(this),this.startGc()}DisposeMapper=new tt;arrayTriggerCache=new Map;ReactiveMap=()=>Fs;activeCallback;isReadonly=!1;superficial=!1;arrayMethods=new Ls(this);arrayHandler={get:Es(this),set:Ts(this),has:Os(),deleteProperty:Ns(),ownKeys:xs()};deepHandler={get:Es(this),set:Ts(this),has:Os(),deleteProperty:Ns(),ownKeys:xs()};collectionHandler=Hs(this);reactive(t){X(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)?J.get(Object.prototype.toString.call(i))??0:0);var i,s,n;if(0===e)return t;let o=Fs.get(t);if(o)return o;if(o=Fs.get(P(t)),o)return o;if(2===e){var r=new Proxy(t,this.collectionHandler);return Fs.set(t,r),r}if(Array.isArray(t)){r=new Proxy(t,this.arrayHandler);return Fs.set(t,r),r}r=new Proxy(t,this.deepHandler);return Fs.set(t,r),r}clearModel(t){null!=t&&null!=t&&(Object.keys(t).forEach(e=>{"object"==typeof t[e]&&(Fs.has(t[e])||Fs.has(P(t[e])))&&this.clearModel(t[e]),Fs.delete(P(t[e])),Fs.delete(t[e])}),Fs.delete(P(t)),Fs.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(){z()}enableTracking(){B(!0)}resetTracking(){V()}dispose(){var t=!0;for(this.stopGc();1==t;)if(this.DisposeMapper.size>0){const t=this.DisposeMapper.pop();Fs.delete(t)}else t=!1;this.DisposeMapper.clear(),js.delete(this)}},zs=[],Vs=()=>{try{const t=globalThis;return!!t.__MOTIF_DEV__&&(t.__MOTIF_STORE_REGISTRY__!==zs&&(t.__MOTIF_STORE_REGISTRY__=zs),!0)}catch{return!1}};function Ws(t){const e=Bs.reactive(t);try{if(Vs()){const i=t?.constructor?.name||"reactive";zs.push({name:i,value:e,type:"reactive"}),zs.length>200&&zs.shift()}}catch{}return e}const $s=new Map;class Us{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&&A("MJX410",[this._tokenName(t),i.join(", ")],{token:t}),e.deps&&!Array.isArray(e.deps)&&A("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 S("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=$s.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)&&$s.has(t)}getService(t){return this.getDescriptor(t)}buildServiceProvider(){return new we(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 $s.entries())this.descriptors.has(t)||this._add(t,{useClass:t,deps:e.deps,useValue:void 0,useFactory:void 0},e.lifetime||"transient")}}function qs(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 Gs=null,Ks=!1;function Ys(){if(u(),l())try{Gs||(Gs=document.createElement("div"),Gs.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(Gs),window.addEventListener("keydown",t=>{try{(t.ctrlKey||t.metaKey)&&"`"===t.key&&(t.preventDefault(),Gs&&(Ks=!Ks,Gs.style.display=Ks?"block":"none"))}catch{}}),p(t=>{t.type}))}catch{}}class Qs{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 Zs=Symbol.for("RouterView.built");class tn extends zi{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 ms(this,t,e)}async disposeTarget(t){await fs(t)}onBuilt(){try{Qs.register(this.props.name??"default",this.scopeId,this);let t=this.parent;for(;t;)t.motif.trigger(Zs,this),t=t.parent}catch{}}onDisposed(){try{Qs.unregister(this.props.name??"default",this.scopeId)}catch{}}}const en="motifjs:scroll",sn=["wheel","touchstart","keydown","mousedown"];class nn{options;viewport;positions=new Map;currentKey="";currentPath=null;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=on(),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.scrollTo({top:t,behavior:"instant"})}catch{try{s.scrollTop=t}catch{}}else e.scrollTo(t)},scrollToAnchor:(t,i)=>e.scrollToAnchor(t,i)}}(t.container):on()),this.load();try{"undefined"!=typeof history&&"scrollRestoration"in history&&(history.scrollRestoration="manual")}catch{}"undefined"!=typeof window&&(this.offs.push(cn(window,"pagehide",()=>this.persistNow())),this.offs.push(cn(document,"visibilitychange",()=>{"hidden"===document.visibilityState&&this.persistNow()})))}leaving(){this.cancelRestore(),this.visited&&(this.remember(this.currentKey,this.viewport.scrollTop()),this.persist())}arrived(t,e){this.visited=!0;const{path:i,hash:s}=rn(t),n=!!s&&i===this.currentPath&&("push"===e||"replace"===e||"traverse"===e);this.currentPath=i,this.currentKey=this.keyOf(i),this.restore(this.currentKey,!1===this.options.anchor?"":s||(this.locationAnchor?function(){try{const t=location?.hash??"";return t.length>1?an(t.slice(1)):""}catch{return""}}():""),n)}saved(t){return this.positions.get(this.keyOf(rn(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,i){this.cancelRestore();const s=this.positions.get(t)??0;if(!e&&s<=0)return void(!1!==this.options.top&&this.viewport.scrollTo(0));this.restoring=!0;const n=this.options.settleMs??1200,o=Date.now(),r=()=>{this.cancelFrame=null;if((e?this.viewport.scrollToAnchor(e,i):this.reached(s))||Date.now()-o>=n)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)}(r)};r()}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=sn.map(e=>cn(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(en,JSON.stringify([...this.positions]))}catch{}}load(){const t=this.storage;if(t)try{const e=t.getItem(en);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 on(){return{scrollTop:()=>{try{return window.scrollY||document.documentElement?.scrollTop||0}catch{return 0}},scrollTo:t=>{try{window.scrollTo({top:t,behavior:"instant"})}catch{try{window.scrollTo(0,t)}catch{}}},scrollToAnchor:(t,e)=>{try{const i=document.getElementById(t);if(!i)return!1;if(e)i.scrollIntoView();else try{i.scrollIntoView({behavior:"instant"})}catch{i.scrollIntoView()}return!0}catch{return!1}}}}function rn(t){const e=t.indexOf("#");return e<0?{path:t,hash:""}:{path:t.slice(0,e)||"/",hash:an(t.slice(e+1))}}function an(t){try{return decodeURIComponent(t)}catch{return t}}function cn(t,e,i,s){try{return t.addEventListener(e,i,s),()=>{try{t.removeEventListener(e,i,s)}catch{}}}catch{return()=>{}}}const ln="motifjs:stack",hn=30,un=t=>!!t&&1===t.nodeType&&!!t.style;function dn(t,e){const i=t?.element;if(t&&!t.isDisposed&&un(i)){try{i.setAttribute("data-nav-direction",e)}catch{}t.motif.options.transition._markedDirection=!0}}function pn(t){const e=t?.motif?.options?.transition;if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function fn(t){return t.getAttribute("style")}function mn(t,e){try{t.setAttribute("style",e??""),null===e&&t.removeAttribute("style")}catch{}}function _n(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 gn(t){for(const[e,i,s]of t)try{e.scrollTop=i,e.scrollLeft=s}catch{}}function yn(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function vn(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 wn(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 bn{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:un(c)?_n(c):[]};if(this.retainAttached&&un(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(un(e)){t.saved={style:fn(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{Hi(t.top)}catch{}}}reveal(t){const e=t.top.element;if(t.hidden&&t.saved&&un(e)){mn(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){gn(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(!(un(s)&&un(n)&&s.isConnected&&n.isConnected))return;if(yn())return;const o="back"===t,r=fn(s),a=fn(n),c=[];try{if(wn(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([vn(n,[{transform:"translateX(0)"},{transform:"translateX(100%)"}],t,c),vn(s,[{transform:"translateX(-30%)"},{transform:"translateX(0)"}],t,c)]):await Promise.all([vn(s,[{transform:"translateX(100%)"},{transform:"translateX(0)"}],t,c),vn(n,[{transform:"translateX(0)"},{transform:"translateX(-30%)"}],t,c)])}}catch(t){M("MJX308",t)}finally{for(const t of c)try{t.cancel()}catch{}mn(s,r),mn(n,a)}}async disposeEntry(t){const e=t.top;if(e&&!e.isDisposed)try{await fs(e,{deep:!0,skipLeaveTransition:!0})}catch(t){M("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(ln);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(ln,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(!un(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=fn(t.top);const e=this.current,i=e?this.entries.get(e.index-1)??null:null;if(i&&i.attached&&un(i.top.element)&&i.top.element.isConnected){const e=i.top.element;t.under=i,t.underSaved=fn(e),i.saved&&mn(e,i.saved.style),wn(e,t.top,!1),e.style.transform="translateX(-30%)",gn(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(-${hn*(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=yn()?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([vn(s,[{transform:r},{transform:"translateX(100%)"}],o,i),n?vn(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([vn(s,[{transform:r},{transform:"translateX(0)"}],o,i),n?vn(n,[{transform:a},{transform:"translateX(-30%)"}],o,i):Promise.resolve()]);for(const t of i)try{t.cancel()}catch{}mn(s,t.topSaved),n&&t.under&&mn(n,t.underSaved),this.gesture===t&&(this.gesture=null)}}}class Sn{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 Mn(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 Cn(t,e){const i=t.chain.length-e.chain.length;if(0!==i)return i;const s=Mn(t.fullPath),n=Mn(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 An{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(Cn)}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 Sn(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 kn{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){M("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){M("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){M("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)pn(t);for(const t of f)d.pages?dn(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&&ds(o.top,"enter")&&o.top.motif.options.transition.enterTransition(()=>{});for(const t of f)t.isBuilt&&!ds(t,"enter")&&pn(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){M("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){M("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||ye(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),ps(h),n.pages&&ds(h,"leave")&&(dn(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()}})),pn(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){ps(i);try{i.parent?.controls.silentDetach(i)}catch{}this.controlCache.has(s)||this.controlCache.set(s,i),Hi(i)}else s&&this.controlCache.get(s)===i&&this.controlCache.delete(s),p&&t===c?(o.top=i,o.disposeAfter.push(i)):n.pages?(dn(i,n.direction),await i.dispose()):await i.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){M("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){ps(e);try{e.parent?.controls.silentDetach(e)}catch{}this.controlCache.has(n)||this.controlCache.set(n,e),Hi(e)}else this.controlCache.get(n)===e&&this.controlCache.delete(n),await e.dispose()}catch(t){M("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=ae;ae=t??null;try{return e()}finally{ae=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=Gi(await n)),(s=this._construct(e,i,()=>this._resolveFrom(e,n)))||("function"==typeof n?this.parseControl(this._construct(e,i,()=>Yi(n,this.application)),e,i):Yi(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??Ln.main?.provider}catch{return}}async createInstance(t,e,i){return await this._instanceCreator(t,e,i)}async _instanceCreator(t,e,i){let s=await this.parseControl(t,e,i);return Ki(s),s}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)&&Ji(o);const h=e[n]?.onShow;h&&!l&&a.current===o&&s===this._navVersion&&C(()=>h(o),"MJX306","onShow"),i=o,n++}}_waitForOutlet(t,e,i,n,o){const r=this.pendingListeners.get(t);if(r){try{r()}catch{}this.pendingListeners.delete(t)}let a,c=!1;const l=async(s,o)=>{c||(h(),n===this._navVersion&&await this.mountChain(e,i,t,n))},h=()=>{if(!c){c=!0,this.pendingListeners.delete(t);try{t.motif?.off?.(Zs,l)}catch{}if(void 0!==a){try{clearTimeout(a)}catch{}a=void 0}}};t.motif.on(Zs,l),this.pendingListeners.set(t,h),s.isDevelopment()&&(a=setTimeout(()=>{c||n!==this._navVersion||A("MJX301",[o,kn.OUTLET_WARN_MS])},kn.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=Qs.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}}const Dn=t=>t.split("#")[0].split("?")[0],En=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36);class Tn{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 An(t.RouteItems),this.routingEngine=new kn,this.application=e,this._installLinkInterceptor();const i=t.scrollMemory;i&&(this._scroll=new nn(!0===i?{}:i),this._scroll.locationAnchor="history"===this._addressMode()),t.stack&&"shell"!==t.mode&&(this._stack=new bn(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||"")+(t?.location?.hash||"")}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[Tn.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?{[Tn.HISTORY_STAMP_KEY]:e}:Tn._isPlainObject(t)?{...t,[Tn.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(!Tn._isPlainObject(t))return t;const e=Tn.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:En()}}_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=Tn._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:En()};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 i=this._pendingTraversal;return this._pendingTraversal=null,await(n=async()=>{try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-start",{uri:t})}catch{}const s=this._suppressBeforeEachOnce;s&&(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>Tn.MAX_REDIRECTS||i.some(t=>Dn(t)===Dn(e))){u=[...i,e].join(" → "),l=S("MJX303",u);break}i.push(e),t=e,h=this.resolve(t)}if(l)A("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":i?i.direction:o.replace?"replace":"push",f=i?i.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){M("MJX306",t,"onLeave")}}let g=!0;if(s||(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:this.chainOf(t),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 w=i?i.from:this._historyStamp;try{const t=!!c&&this._addressShows(c);this._applyUrl(v,t?{...o,replace:!0}:o)}catch{}const b=this._stack?{direction:p,from:w,to:this._historyStamp,uri:v}:void 0;try{await this.routingEngine.execute(h,b,y(h))}catch(e){M("MJX304",e),h=this._buildFallbackResult(t,"error",{path:t,error:e});try{await this.routingEngine.execute(h,b,y(h))}catch(t){M("MJX305",t)}}this._stack&&this.application._routerState.touch(),o.scroll?this._handleScrollBehavior(o.scroll):this._scroll?.arrived(this._uriWithHash(v,t),p),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",s.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 S("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 S("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?Tn._builtinNotFound:Tn._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 zi("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(as("h2",{},"404 - Not Found")),t.element.appendChild(as("p",{},"The requested page was not found."))}});static _builtinError=()=>new zi("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(as("h2",{},"Error")),t.element.appendChild(as("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}}chainOf(t){return t.chain.map(e=>this.routingEngine.generatePathString(e.path,t.params)||"")}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)=>Cn(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){const s=(i.location.pathname||"/")+(i.location.search||"")+(i.location.hash||"");let n=t;try{const e=new URL(t,i.location.href);n=e.pathname+e.search+e.hash}catch{}if(s!==n)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;let t=Promise.resolve();try{try{t=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{}return t}}class xn{version=new ee(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 On=null,Nn=!1;class Pn{services=new Us;constructor(){if(On&&"disposing"!==On.state||Nn)throw new w("MJX405",b("MJX405"),{cause:On});Nn=!0}build(){this.services.autoRegisterInjectables();const t=this.services.buildServiceProvider();this.services.addSingleton(we,t);var e=new Ln(t);return this.services.addSingleton(Ln,e),On=e,e}rebuild(){return On?(On.provider.dispose(),On.provider=this.services.buildServiceProvider(),On):this.build()}}class Ln{provider;static get main(){return On}constructor(t){this.provider=t}static _disposingCount=0;_state="initializing";_disposing;get state(){return this._state}_middlewares=[];_beforeEachGuards=[];_routerState=new xn;router=function(t,e){const i=()=>{const t=e();if(!t)throw S("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=>{const e=i(),s=e.resolve(t);return{chain:e.chainOf(s),result:s}},href:(t,e)=>i().href(t,e)}}(this._routerState,()=>this.urlRoutingModule);events=new Map;static CreateBuilder(){return new Pn}appShell;getAppShell(){return this.appShell}run(t,e){let i;if(r(()=>{Bs.startGc()},"Application.run.engine.startGc"),"string"==typeof t){if(i=document.querySelector(t),!i)throw S("MJX406",t)}else i=t;let s=e;this._state="running";const n=new zi(i);this.appShell=n,r(()=>{n._keepElementOnDispose=!0,n.application=this,n.provider=this.provider},"Application.run.setupAppShell"),s?(s.parent=n,n.controls.add(s)):(s=n,s.controls.add(new tn({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(){if(this._disposing)return this._disposing;let t;this._state="disposing",Ln._disposingCount++,Nn=!1,r(()=>{this._removeLifecycleListeners()},"Application.dispose.lifecycle"),r(()=>{t=this.urlRoutingModule?.dispose?.()},"Application.dispose.router"),r(()=>{Bs.stopGc()},"Application.dispose.gcStop"),r(()=>{try{const t=window;t&&t.history&&"function"==typeof t.history.replaceState&&t.history.replaceState({},"","/")}catch{}},"Application.dispose.resetUrl"),Ce.mode="concurrent";const e=this.appShell;return this._disposing=(async()=>{try{await t}catch(t){M("MJX307",t)}if(e&&!e.isDisposed)try{await e.dispose()}catch(t){M("MJX307",t)}try{await this.provider.dispose()}catch{}On===this&&(On=null),this._state="disposed",Ln._disposingCount--})()}useTransitions(t){return Pe(t?.mode)&&(Ce.mode=t.mode),this}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 M("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,o,a;return Array.isArray(t)?e=t:(e=t.routes,i=t.mode,s=t.fallbacks,n=t.hooks,o=t.scrollMemory,a=t.stack),this.urlRoutingModule&&this.urlRoutingModule.dispose(),this._routerConfig={mode:i,fallbacks:s,middlewareCollections:()=>this._middlewares,RouteItems:e,hooks:n,scrollMemory:o,stack:a},this.urlRoutingModule=new Tn(this._routerConfig,this),this._routerState.reset(),r(()=>{u(),Ys(),g(e),(this._isDevelopment||!0===globalThis.__MOTIF_DEV__||d())&&function(t){const e=new Map,i=new Map;function s(t,n,o){const r=t.path??"",a=String(r),c=""===n?a:qs(n,a),l=o>0&&"/"===a.trim(),h=""===a.trim();h&&A("MJX310",[n||"/"],{parentPath:n,path:a}),o>0&&a.length>0&&"/"!==a&&!a.startsWith("/")&&!a.startsWith("*")&&A("MJX311",[a,n||"/"],{parentPath:n,path:a}),n&&c===n&&(l||h||A("MJX312",[c],{parentPath:n,childPath:a}));const u=(e.get(c)||0)+1;e.set(c,u),u>1&&(l||h||A("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("*")&&A("MJX314",[e,n||"/"],{parentPath:n,alias:e});const s=""===n?e:qs(n,e);s===c&&A("MJX315",[s],{full:c,alias:e});const r=(i.get(s)||0)+1;i.set(s,r),r>1&&A("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 Tn(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 S("MJX309")}async navigateByName(t,e,i){if(this.urlRoutingModule)return await this.urlRoutingModule.navigateByName(t,e,i);throw S("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=>{C(()=>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 r(()=>{_t(t)},"Application.useReactiveMonitor.core"),this}useDevelopment(t=!0){return this._isDevelopment=t,s.setDevelopmentMode(t),r(()=>{globalThis.__MOTIF_DEV__=t},"Application.useDevelopment.flag"),r(()=>{var e;e=t,a.enabled=e||l(),h(a.enabled)},"Application.useDevelopment.devtools"),t&&function(){for(const t of Array.from(nt))ot(t)}(),this}useLogging(t=!0){return this._enableErrorLogging=t,function(t){s.setConsoleLogging(t)}(t),this}}function Xn(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function Rn(t){return t&&"TimeoutError"===t.name}class In extends w{constructor(){super("MJX605",b("MJX605")),this.name="TimeoutError"}}function Jn(t){return new Promise(e=>setTimeout(e,t))}function Hn(t,e=.1){const i=(2*Math.random()-1)*e*t;return Math.max(0,Math.floor(t+i))}class jn{}class Fn extends jn{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&&!Rn(t)),this.onRetry=t.onRetry}calcDelay(t){if("none"===this.backoff)return 0;if("fixed"===this.backoff)return Hn(this.delayMs,this.jitter);return Hn(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 Jn(n)}throw i}}class Bn extends jn{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 In),this.timeoutMs)});try{return await Promise.race([s,n])}finally{clearTimeout(i)}}}class zn extends jn{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&&!Rn(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 S("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 Vn extends jn{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 S("MJX603");await new Promise(t=>{this.queue.push(t)})}this.active++;try{return await Promise.resolve(t(e))}finally{this.active--,this.dequeue()}}}class Wn extends jn{tokensPerInterval;intervalMs;capacity;tokens;lastRefill;constructor(t={}){super(),this.tokensPerInterval=t.tokensPerInterval??1,this.intervalMs=t.intervalMs??1e3,this.capacity=t.capacity??this.tokensPerInterval,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 S("MJX604");return this.tokens-=1,Promise.resolve(t(e))}}class $n extends jn{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 Un extends jn{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 qn=t=>new Fn(t),Gn=t=>new Bn(t),Kn=t=>new zn(t),Yn=t=>new Vn(t),Qn=t=>new Wn(t),Zn=t=>new $n(t),to=(...t)=>new Un(...t);class eo{static get create(){return new eo}resiliences=[];retry=t=>(this.resiliences.push(qn(t)),this);timeout=t=>(this.resiliences.push(Gn(t)),this);circuitBreaker=t=>(this.resiliences.push(Kn(t)),this);bulkhead=t=>(this.resiliences.push(Yn(t)),this);rateLimiter=t=>(this.resiliences.push(Qn(t)),this);fallback=t=>(this.resiliences.push(Zn(t)),this);async execute(t,e){return to(...this.resiliences).execute(t,e)}}t.Application=Ln,t.ApplicationBuilder=Pn,t.Component=zi,t.ComponentBase=ai,t.ComponentMotif=Qt,t.Computed=ie,t.ContentBlock=class extends zi{constructor(t){super(t);const e=t=>{this.motif.trigger("controladded",{control:t});var e=ys.get(this.props.target);e&&(t.motif.options.ownerContentBlock=this,e.controls.add(t))};this.controls.onAdd=e,this.controls.onAddBeforeBuild=e,this.childs&&this.controls.add(...this.childs)}onConfigured(t,e){var i=ys.get(this.props.target);i?(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),i.controls.add(...this.controls.items)):this.context.on(vs,()=>{var t=ys.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=ys.get(this.props.target);if(i)for(const t of[...i.controls.items])t.motif.options.ownerContentBlock===this&&(i.controls.remove(t),A("MJX109",[],t))}ondisposing(t){}},t.ContentBody=class extends zi{constructor(t){super(t),ys.set(this.props.name,this),this.context.fire(vs)}ondisposing(t){ys.get(this.props.name)===this&&ys.delete(this.props.name)}},t.ControlCollection=cs,t.Dictionary=class{__values=new q;Add(t,e){var i=new U;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)}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)}},t.Disposable=E,t.DisposableStore=D,t.Emitter=Rt,t.ErrorHandler=i,t.FNComponent=function(t){return e=>{var i=Zi({...e});return i.controls.add(t(e)),i}},t.FragmentNode=es,t.Frame=_s,t.FromService=function(t){try{return Ln.main.provider.get(t)}catch(e){return A("MJX414",[Xn(t),String(e?.message??e)],{token:t,error:e}),null}},t.Injectable=function(t){return e=>{$s.set(e,{lifetime:t?.lifetime??"transient",deps:t?.deps})}},t.Lazy=us,t.LazyComputed=se,t.LinkedList=tt,t.List=q,t.MotifError=w,t.NameValuePair=U,t.Query=it,t.Resilience=eo,t.RouterLink=class extends zi{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=Ln.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}}},t.RouterView=tn,t.ServiceCollection=Us,t.ServiceProvider=we,t.Signal=ee,t.Transport=class extends zi{mode;constructor(t){super(t),this.mode=t.mode||"replace"}initializeComponent(t){Ss.registerSlot(this.props.name,this),this.onDisposing=()=>{[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()}),Ss.unregisterSlot(this.props.name,this)}}clearSlot(){[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()})}},t.TransportTo=class extends zi{_onAddRef;_onRemoveRef;_slotRegisteredListener;_slotUnregisteredListener;_transported=[];_countedLive=!1;constructor(t){super("div",t),be.live++,this._countedLive=!0}_handleSlotChange=t=>{if(t.name===this.props.name){const e=t.slot;"merge"!==e.mode&&e.clearSlot?.();const i=[...this.childs||[],...this.controls.items];Ms.transportMany(i,e),this._rememberTransported(i)}};_rememberTransported(t){const e=this._transported.filter(t=>!t.isDisposed);for(const i of t)e.includes(i)||e.push(i);this._transported=e}_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=Ss.getSlot(this.props.name);if(e){"merge"!==e.mode&&e.clearSlot?.();const t=[...this.childs||[],...this.controls.items];Ms.transportMany(t,e),this._rememberTransported(t)}this._slotRegisteredListener=Ln.main.on(ws,this._handleSlotChange),this._slotUnregisteredListener=Ln.main.on(bs,t=>{t.name===this.props.name&&this._clearChildrenFromSlot(t.slot)}),this._onAddRef=t=>{this.motif.trigger("controladded",{control:t});const e=Ss.getSlot(this.props.name);e&&(Ms.transport(t,e),this._rememberTransported([t]))},this._onRemoveRef=t=>{const e=Ss.getSlot(this.props.name);e&&e.controls.remove(t),this._transported=this._transported.filter(e=>e!==t)},this.controls.onAdd=this._onAddRef,this.controls.onRemove=this._onRemoveRef}onDisposing(t,e){this._countedLive&&(this._countedLive=!1,be.live--);const i=Ss.getSlot(this.props.name);for(const t of this._transported||[])i?.controls.remove(t),t.dispose();this._slotRegisteredListener&&(Ln.main.off(ws,this._handleSlotChange),this._slotRegisteredListener=void 0),this._slotUnregisteredListener&&(Ln.main.off(bs,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=[]}},t.Transporter=Ms,t.Virtualization=class extends zi{_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 zi;wrapper;_makeView(){this._topSpacer=new zi("div"),this._topSpacer.element.style.cssText="height: 0px;",this._topSpacer.class.add("motif-virtualization-top-spacer"),this._bottomSpacer=new zi("div"),this._bottomSpacer.element.style.cssText="height: 0px;",this._bottomSpacer.class.add("motif-virtualization-bottom-spacer"),this._virtualContent=new zi(document.createComment("")),this.props.mainTemplate?(this.contentWrapper.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.contentWrapper.onBuilding=t=>{var e=Y(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 kt(i);let s;this._stopDataWatch();let n=!0;return this._dataWatchStop=St(()=>{if(n){n=!1;try{this.props.watch?.()}catch(t){M("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 A("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,M("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 ai?o:new zi(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}Hi(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 M("MJX207",t);else M("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}}},t.asyncTracking=Ct,t.clearModel=function(t){return Bs.clearModel(t)},t.configureReactivityLeakMonitor=_t,t.createComputed=function(t){const e=new ie(t);try{if(Vs()){const t=`computed_${zs.length}`;zs.push({name:t,value:e.value,type:"computed"}),zs.length>200&&zs.shift()}}catch{}return e},t.createLazyComputed=function(t){const e=new se(t);try{if(Vs()){const t=`lazyComputed_${zs.length}`;zs.push({name:t,value:void 0,type:"computed"}),zs.length>200&&zs.shift()}}catch{}return e},t.createSignal=function(t){const e=new ee(t);try{if(Vs()){const t=`signal_${zs.length}`;zs.push({name:t,value:e.value,type:"signal"}),zs.length>200&&zs.shift()}}catch{}return e},t.decorate=function(t,e){return i=>t.execute(e,i)},t.deepClone=function(t){return Bs.deepClone(t)},t.disposableCore=k,t.dom=ns,t.effect=St,t.errorHandler=s,t.inject=function(t){if(!ne)throw S("MJX409",function(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}(t));return ne(t)},t.motifCompiled=ot,t.motifComponent=Ui,t.motifFragment=Zi,t.preProcessing=function(t){gs.add(t),gs.forEach(t=>{t()})},t.reactive=Ws,t.read=function(t){return"function"==typeof t?t():t},t.safeCall=n,t.safeCallAsync=o,t.safeCallSilent=r,t.setUnexpectedErrorHandler=function(t){s.setUnexpectedErrorHandler(t)},t.toDisposable=G,t.toGetter=function(t){return"function"==typeof t?t:()=>t},t.untracked=kt,t.useApplication=function(){return{application:Ln.main,services:Ln.main.provider,router:Ln.main.router,attach(...t){Ln.main&&Ln.main.getAppShell().controls.add(...t)}}},t.useModel=function(t){const e=Bs.reactive(t);try{if(Vs()){const i=t?.constructor?.name||"useModel";zs.push({name:i,value:e,type:"reactive"}),zs.length>200&&zs.shift()}}catch{}return e},t.useNavigation=function(){return Ln.main.router}});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).motif={})}(this,function(t){"use strict";function e(t){setTimeout(()=>{throw t},0)}class i{constructor(){this.unexpectedErrorHandler=e,this.listeners=[],this._isDevelopment=!1,this._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 s=new i;function n(t,e,i){return s.safeCall(t,e,i)}function o(t,e,i){return s.safeCallAsync(t,e,i)}function r(t,e){s.safeCallSilent(t,e)}const a={enabled:!1,listeners:new Set,warnings:[],routes:null};function c(){return a.enabled||!0===globalThis.__MOTIF_DEV__}function l(){try{if("undefined"==typeof window)return!1;return!0===window.__motif_DEVTOOLS||(!0===globalThis.__MOTIF_DEVTOOLS__||!0===globalThis.__MOTIF_DEVTOOLS_FLAG)}catch{return!1}}function h(t){try{t?window.__motifDevBus={on:p,emit:f,warn:m,getWarnings:_,isEnabled:d,setRoutes:g,getRoutes:y}:delete window.__motifDevBus}catch{}}function u(){a.enabled||(a.enabled=l(),a.enabled&&h(!0))}function d(){return a.enabled}function p(t){return a.listeners.add(t),()=>{a.listeners.delete(t)}}function f(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 m(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{}f("warning",s)}function _(){return a.warnings.slice()}function g(t){a.routes=t}function y(){return a.routes}const v={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.`,MJX124:t=>`A spread object on a DOM tag cannot set ${t}; the key was ignored. Write it on the tag, or use x-html, for HTML you trust.`,MJX125:t=>`A spread object on a DOM tag cannot set a javascript: URL on '${t}'; the value was ignored. Write the attribute on the tag if it is intended.`,MJX126:()=>"Lazy: loading the component failed and no Fallbackview is set; the host was cleared.",MJX127:t=>"module"===t?"The loaded module has no default export. Export the component as default, or map it: () => import('./X').then(m => m.X).":`The loaded value is not a component (got ${t}). Return a component class, a function component, an Options API factory or a component instance.`,MJX128:(t,e,i)=>"method"===i?`${t} overrides ${e} without calling super.${e}; MotifJS relies on this ComponentBase member. Rename your member, or call super.${e} in the override.`:"field"===i?`${t} defines '${e}' as an instance field, which hides the ComponentBase member MotifJS relies on. Rename your field.`:`${t} replaces '${e}', which MotifJS created for the component (a class field or an assignment with that name). Rename your member.`,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 w extends Error{constructor(t,e,i){super(e,i),this.name="MotifError",this.code=t}}function b(t,...e){return`[motifjs] ${t}: ${v[t](...e)}`}function S(t,...e){return new w(t,b(t,...e))}function C(t,e,...i){s.report(new w(t,b(t,...i),{cause:e}))}function M(t,e,...i){try{const s=t();s&&"function"==typeof s.then&&s.then(void 0,t=>C(e,t,...i))}catch(t){C(e,t,...i)}}function k(t,e,i){m(t,v[t](...e),i)}const D=new class{constructor(){this.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 A{constructor(){this._closed=!1,D.notifyCreated(this)}get isDisposed(){return this._closed}add(t){if(!t)return t;if(t===this)throw S("MJX502");return D.notifyOwner(t,this),this._closed?k("MJX504",[],(new Error).stack):(this._items??=new Set).add(t),t}delete(t){if(t){if(t===this)throw S("MJX505");this._items?.delete(t),t.dispose()}}detach(t){t&&this._items?.delete(t)&&D.notifyOwner(t,null)}clear(){const t=this._items;if(!t||0===t.size)return;const e=[];for(const i of t)try{i?.dispose()}catch(t){e.push(t)}if(t.clear(),1===e.length)throw e[0];if(e.length>1)throw new w("MJX503",b("MJX503"),{cause:new AggregateError(e)})}dispose(){this._closed||(D.notifyDisposed(this),this._closed=!0,this.clear())}}let x;class E{get _disposables(){let t=this._store;return void 0===t&&(t=this._store=new A,D.notifyOwner(t,this)),t}constructor(){this._store=void 0,D.notifyCreated(this)}dispose(){D.notifyDisposed(this);const t=this._store;void 0===t?this._store=(void 0===x&&(x=new A,x.dispose()),x):t&&"function"==typeof t.dispose?t.dispose():k("MJX501",[],{disposable:this})}_register(t){if(t===this)throw S("MJX502");return this._disposables.add(t)}}const T={IS_REACTIVE:Symbol.for("motif.isReactive"),IS_READONLY:Symbol.for("motif.isReadonly"),IS_SUPERFICIAL:Symbol.for("motif.isSuperficial"),RAW:Symbol.for("motif.raw"),GET_SETUP:Symbol.for("motif.getSetup")},O=Symbol("");let N=!0,P={enabled:!1,key:""};function L(t){let e=t;for(;e&&e[T.RAW];)e=e[T.RAW];return e}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function X(t){return"object"==typeof t&&null!==t}const I=new Set(Object.values(Object.getOwnPropertyDescriptors(Symbol)).map(t=>t.value).filter(t=>"symbol"==typeof t));function J(t){return"symbol"==typeof t&&I.has(t)}const j=new Map([["[object Object]",1],["[object Array]",1],["[object Map]",2],["[object Set]",2],["[object WeakMap]",2],["[object WeakSet]",2]]);const F=/^(?:0|[1-9]\d*)$/,H=[];let B=0;function z(t){H[B++]=N,N=t}function V(){z(!1)}function W(){N=!(B>0)||H[--B]}const $=[];class U{constructor(t,e,i,s){this.component=t,this.itemsFn=e,this.renderFn=i,this.options=s,this.propertyName="__list__",this._isActive=!1,this._rendered=[],this._identityMap=new WeakMap,this.container=Js("list-container"),this.olditems=[],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 xt(()=>{const i=this.renderFn(t,e);return this.processRendered(i,t)})}processRendered(t,e){const i=ks(t);if(!(i instanceof ji))throw S("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}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=L(t),i=t.length;let s;if(e===t)s=t;else{s=new Array(i);for(let n=0;n<i;n++)n in e?s[n]=t[n]:t[n]}const n=this.olditems,o=this._rendered;if(this.olditems.length>0){const t=new Set;for(let e=0;e<i;e++)t.add(L(s[e]));for(const e of this.olditems){const i=L(e);if(!t.has(i)){const t=this._identityMap.get(i);if(t){this._identityMap.delete(i);for(const e of t)try{e.dispose()}catch{}}}}}const r=[],a=new Set,c=new Map,l=new Set,h=new Map,u=t=>!(!t||t.isDisposed||l.has(t)||t.__listAdopted),d=Math.min(s.length,n.length);for(let t=0;t<d;t++){const e=s[t];if(!U._isPrimitive(e))continue;if(!Object.is(n[t],e))continue;const i=o[t];u(i)&&(h.set(t,i),l.add(i))}let p=null;if(!this._indexSensitive){p=new Map;for(let t=0;t<n.length;t++){const e=n[t];if(!U._isPrimitive(e))continue;const i=o[t];if(!u(i))continue;const s=p.get(e);s?s.push(i):p.set(e,[i])}}const f=new Map;return s.forEach((t,e)=>{let i;if("object"==typeof t&&null!==t){const s=L(t),n=f.get(s)??0;f.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=h.get(e);if(!s&&p){const e=p.get(t);e&&e.length&&(s=e.shift(),l.add(s))}i=s||this._render(t,e)}const s=this._getComponentKey(i);null!=s&&(c.has(s)?k("MJX202",[s,e]):c.set(s,e)),r.push(i),a.add(i)}),f.forEach((t,e)=>{const i=this._identityMap.get(e);i&&i.length>t&&(i.length=t)}),this._rendered.forEach(t=>{if(!a.has(t)&&!t.__listAdopted)try{t.dispose()}catch{}}),this._syncContainer(r),this._rendered=r,this.olditems=s===t?t.slice():s,i};this._effectCleanup=Mt(()=>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}if(t.length>=i.length){let s=!0;for(let e=0;e<i.length;e++)if(t[e]!==i[e]){s=!1;break}if(s&&t.length>i.length){const e=new Set(i);for(let n=i.length;n<t.length;n++){if(e.has(t[n])){s=!1;break}e.add(t[n])}}if(s){for(let s=i.length;s<t.length;s++)try{e.add(t[s])}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));if(t.length===i.length&&function(t,e,i){const s=new Uint8Array(t.length);for(let n=0;n<t.length;n++){const o=t[n];if(-1===o||s[o])return!1;s[o]=1;const r=e[n];if(r.isDisposed||r.parent!==i)return!1}return!0}(n,t,this.container))return void e._reorder(t,o);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 q{}class G{constructor(){this.__list=[],this._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){const e=this.__list.indexOf(t);return-1===e?[]:(this._map.delete(t),this.__list.splice(e,1))}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.slice().reverse()}filter(t){return this.__list.filter(t)}}function K(t){let e=!0;return{dispose(){e&&(e=!1,t())}}}function Y(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 Z{constructor(t,e){this.threshold=t,this.name=e,this._origins=new Map,this._quietChecks=0}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();k("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}}function tt(){const t={value:void 0,linked:!1};return t.before=t,t.after=t,t}class et{constructor(){this._ring=tt(),this._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=tt(),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 it(t,e){return t>e?1:t<e?-1:0}class st{constructor(t){this.source=Array.isArray(t)?t:Array.from(t)}static from(t){return new st(t)}where(t){return new st(this.source.filter(t))}select(t){return new st(this.source.map(t))}orderBy(t){return new st([...this.source].sort((e,i)=>it(t(e),t(i))))}orderByDescending(t){return new st([...this.source].sort((e,i)=>it(t(i),t(e))))}distinctBy(t){const e=new Set;return new st(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 st(Array.from(e,([t,e])=>({key:t,items:e})))}first(){if(0===this.source.length)throw S("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 nt=[1,2],ot=new Set,rt=new Set;function at(t){nt.includes(t)||ot.has(t)||(c()?(rt.delete(t),ot.add(t),k("MJX121",[t,2])):rt.add(t))}var ct;t.NodeTypes=void 0,(ct=t.NodeTypes||(t.NodeTypes={}))[ct.ELEMENT_NODE=1]="ELEMENT_NODE",ct[ct.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",ct[ct.TEXT_NODE=3]="TEXT_NODE",ct[ct.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",ct[ct.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",ct[ct.ENTITY_NODE=6]="ENTITY_NODE",ct[ct.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",ct[ct.COMMENT_NODE=8]="COMMENT_NODE",ct[ct.DOCUMENT_NODE=9]="DOCUMENT_NODE",ct[ct.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",ct[ct.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE",ct[ct.NOTATION_NODE=12]="NOTATION_NODE";class lt{constructor(t,e){this.fn=t,this.callback=e,this.deps=[],this.active=!0,this.running=!1}run(){let t;if(this.active&&!this.running){Ct(this),ut.push(this),this.running=!0;try{t=this.fn()}finally{ut.pop(),this.running=!1,this.callback&&this.callback(t)}}}stop(){this.active=!1,Ct(this)}}const ht=new WeakMap,ut=[],dt=new Set;let pt,ft=!1,mt=!1,_t=-1;const gt=new WeakMap;function yt(t={}){mt=!!t.enabled,_t="number"==typeof t.threshold?t.threshold:mt?200:-1,pt=mt&&_t>0?new Z(_t,t.name??"reactivity-core"):void 0}function vt(t,e){if(!N)return;const i=L(t),s=ut[ut.length-1];if(!s||!s.active)return;let n=ht.get(i);n||ht.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]),mt&&pt&&_t>0))try{const t=pt.check(o.size);if(t){let e=gt.get(o);e||(e=new Map,gt.set(o,e)),e.set(s,t)}}catch{}}function wt(t,e){const i=L(t),s=ht.get(i);if(!s)return;const n=s.get(e);if(!n)return;let o=!1;n.forEach(t=>{t.active&&(t.scheduler?bt(t.scheduler):(dt.add(t),o=!0))}),o&&function(){if(ft)return;ft=!0,Promise.resolve().then(()=>{const t=new Map;try{for(;dt.size>0;){const e=Array.from(dt);dt.clear();for(const i of e){const e=(t.get(i)??0)+1;t.set(i,e),e>St?e===St+1&&k("MJX203",[St],{fn:String(i.fn).slice(0,200)}):bt(()=>i.run())}}}finally{dt.clear(),ft=!1}})}()}function bt(t){try{t()}catch(t){C("MJX208",t)}}const St=50;function Ct(t){for(const[e,i]of t.deps){const s=ht.get(e);if(!s)continue;const n=s.get(i);if(n){n.delete(t);try{const e=gt.get(n),i=e?.get(t);if(i){try{i()}catch{}e.delete(t)}}catch{}0===n.size&&s.delete(i),0===s.size&&ht.delete(e)}}t.deps=[]}function Mt(t,e){const i=new lt(t,e);return bt(()=>i.run()),()=>i.stop()}function kt(t){if(!t.pushed)return;t.pushed=!1;const e=ut.lastIndexOf(t.effect);e>=0&&ut.splice(e,1)}const Dt={capture:()=>({effect:ut[ut.length-1],pushed:!1}),suspend:(t,e)=>(kt(t),e),resume:(t,e)=>(t.effect&&t.effect.active&&!t.pushed&&(ut.push(t.effect),t.pushed=!0),e),end(t){kt(t)}},At=new lt(()=>{});function xt(t){ut.push(At);try{return t()}finally{ut.pop()}}function Et(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"checkbox"===e||"radio"===e}function Tt(t){if(t){if(Et(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}}At.active=!1;class Ot{constructor(t,e,i,s,n,o){this.updateMode="onPropertyChanged",this._isActive=!1,this._memberPath=null,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=Mt(()=>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;Et(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()||""}}const Nt=T.RAW;function Pt(t,e,i){let s=Object.getPrototypeOf(t);for(;s&&s!==e;){if(Object.prototype.hasOwnProperty.call(s,i))return!0;s=Object.getPrototypeOf(s)}return!1}function Lt(t,e){for(const i of e){let e=t[i];"function"==typeof e&&Object.defineProperty(t,i,{configurable:!0,enumerable:!1,get(){if(this===t||(s=this,Object.prototype.hasOwnProperty.call(s,"constructor")&&"function"==typeof s.constructor&&s.constructor.prototype===s))return e;var s;const n=this[Nt]??this,o=e.bind(n);if(!Pt(n,t,i))try{Object.defineProperty(n,i,{value:o,writable:!0,configurable:!0,enumerable:!0})}catch{}return o},set(s){this!==t||"function"!=typeof s?Object.defineProperty(this,i,{value:s,writable:!0,configurable:!0,enumerable:!0}):e=s}})}}function Rt(t){return"function"==typeof t?Rt(t()):t}function Xt(t,e){return"__proto__"!==e&&("constructor"!==e&&"prototype"!==e||Object.prototype.hasOwnProperty.call(t,e))}class It{constructor(t){this._items=[],this._branchScope=null,this._component=t}_own(t){this._branchScope?this._branchScope.push(t):this._component.motif.register(K(()=>{try{t()}catch{}}))}when(t,e){var i=new on;this._component.controls.add(i);let s,n=!1;const o=Mt(t,t=>{n&&(Object.is(s,t)||!s&&!t)||(n=!0,s=t,xt(()=>{t?i.navigate(e(t)):i.navigate(Js())}))});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 Ot(this._component,i,s,n,o,r)}return this._items.push(e),this._component.isBuilt&&e.activate(),e}wait(t){const e=new Ot(this._component,"isWait",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}display(t){const e=new Ot(this._component,"isWait",()=>!Rt(t()));return this._items.push(e),this._component.isBuilt&&e.activate(),e}html(t){const e=new Ot(this._component,"innerHTML",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}list(t,e,i){const s=new U(this._component,t,e,i);return this._items.push(s),this._component.isBuilt&&s.activate(),s}loop(t,e,i){const s=new U(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=Mt(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 As(zs.createTextNode(t)),n(i,s),void(s=null));s||(s=new on,n(s,i),i=null),s.navigate(null==t?Js():t)});e.motif.register(K(()=>{try{o()}catch{}}))}ternary(t,e,i){const s=new on;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=Mt(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 xt(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=Mt(()=>{t()});this._component.motif.register(K(()=>{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 Ot(this._component,i,t[0]),s.setter=t[1];else{const[e,n,o,r]=t;s=new Ot(this._component,i,e,n,o,r)}const n=t=>{let e=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 s=0;s<t.length&&null!=i;s++){const n=t[s];if(!Xt(i,n))return;s===t.length-1?i[n]=e:i=i[n]}}else null!=o&&"object"==typeof o&&"value"in o&&(o.value=e)};(this._modelWriters??=new WeakMap).set(s,n);const o=e.toLowerCase();if("input"===o||"select"===o||"textarea"===o){const t=()=>{try{const t=this._component.element;if(!t)return;n(Tt(t))}catch{}};this._component.motif.on("input",t),this._component.motif.on("change",t)}return this._items.push(s),this._component.isBuilt&&s.activate(),s}writeModel(t){const e=this._modelWriters;if(!e)return!1;let i=!1;for(const s of this._items){const n=e.get(s);if(n)try{n(t),i=!0}catch{}}return i}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){C("MJX208",t)}}switchCase(t,e,i){const s=new on;var n;this._component.controls.add(s);var o=!1;const r=Mt(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(Js())}});return this._component.motif.register(K(()=>{try{r()}catch{}})),null}}Lt(It.prototype,["add","remove","clear","activateAll","deactivateAll","reActivateAll","when","text","value","list","loop","method","watch","display","wait","ternaryCall","_ternaryCallTop"]);class Jt{constructor(){this._subscriptions=[],this._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 A?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){s.onUnexpectedError(t)}}this._delivery===t&&(this._delivery=void 0)}}}class jt{constructor(t){this.component=t}hasListeners(t){return void 0!==this._emitters&&this._emitters.has(t)}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){const e=this._emitters??=new Map;let i=e.get(t);return i||(i=new Jt,e.set(t,i)),i}createEvent(t,e){const i=String(t).toLowerCase(),s=i.startsWith("on")?"x:"+i.slice(2):i,n=t=>{let i;return M(()=>(i=e.length<=1?e(t):e(this.component,t),i),"MJX122",s),i},o=this.getOrCreateEmitter(i).event(t=>n(t)),r=this._listenerDisposables??=new Map;let a=r.get(i);a||(a=new Map,r.set(i,a));const c=a.get(e);return c?c.push(o):a.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 Jt?e.event:e)}catch{}if(o){const t=this._sourceDisposables??=new Map;let e=t.get(i);e||(e=new Set,t.set(i,e)),e.add(o),this.component.motif.register(D.toDisposable(()=>{try{o?.dispose()}catch{}try{e?.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 if(this._emitters)for(const t of Array.from(this._emitters.keys()))this.clear(t);return this}}Lt(jt.prototype,["fire","on","off","createEvent","getOrCreateEmitter","addSource","clear"]);const Ft=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"]),Ht={show:"close",showModal:"close",showPopover:"hidePopover"},Bt=new Set(["close","hidePopover","requestSubmit","checkValidity","reportValidity","showPicker","load"]),zt=new Set(["setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Vt=new Set(["checked","selected","muted","indeterminate","srcObject"]);class Wt{constructor(t){this._parent=t}get _attrMap(){return this._attrMapStore??=new Map}get _watchers(){return this._watchersStore??=new Map}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=()=>Mt(()=>{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&&Ft.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 Ht){return r(()=>{if(!1===e){const t=i[Ht[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(Bt.has(s)){return r(()=>{!0===e?o(n):e&&o(n,e)}),void a()}if(zt.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&&Vt.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(Qi(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 $t{constructor(t){this._watcherSeq=0,this._parent=t}get _counts(){return this._countsStore??=new Map}get _staticSet(){return this._staticSetStore??=new Set}get _watchers(){return this._watchersStore??=new Map}add(...t){for(const e of t)"function"==typeof e?this._addReactive(e):Array.isArray(e)?this._addStaticFromArray(e):e&&"object"==typeof e?this._addStaticFromObject(e):this._addStaticNames(this._splitClasses(String(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?/\s/.test(t)?t.split(/\s+/).filter(t=>t.length>0):[t]:[]}_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{}}}_addStaticNames(t){if(0===t.length)return;const e=this._getElement(),i=this._staticSet,s=e&&!e.hasAttribute("class")?[]:null;for(const n of t){if(i.has(n))continue;i.add(n);const t=this._counts.get(n)||0;if(this._counts.set(n,t+1),0===t&&e)if(s)s.push(n);else try{e.classList.add(n)}catch{}}s&&s.length>0&&e.setAttribute("class",s.join(" "))}_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=()=>Mt(()=>{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 Ut={cancel(){},addEventListener(){},removeEventListener(){},oncancel:null,playState:"finished"};function qt(t){const e=t.substring(0,Math.max(0,t.length-1)).replace(",",".");return 1e3*Number(e)}function Gt(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=qt(n[t])+qt(s[t%s.length]);o=Math.max(o,e)}return{kind:e,longest:o,tracks:n.length}}const Kt=/(?:^|\W)(?:transform|all)(?:,|$)/;function Yt(t,e){if(!t)return{type:"animation",timeout:0,propCount:0,hasTransform:!1};const i={transition:Gt(t,"transition"),animation:Gt(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&&Kt.test(t.transitionProperty)}}function Qt(t,e,i){if(t.isConnected&&8!==t.nodeType)return Yt(zs.window.getComputedStyle(t),i);const s=zs.createElement("div");s.setAttribute("style","width:0!important;height:0!important;display:none"),zs.body.appendChild(s),s.setAttribute("class",e);try{return Yt(zs.window.getComputedStyle(s),i)}finally{s.remove()}}function Zt(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 Yt(zs.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 te{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(D.toDisposable(t))}stopAnimations(){return this._component._stopAnimations()}}const ee=Symbol("SignalTarget"),ie=Symbol("SignalKey");class se{static create(t,e){return new se(t,e)}constructor(t,e=Object.is){this._disposed=!1,this._value=t,this._target={[ee]:!0},this._key=ie,this._equals=e}get value(){return this._disposed||vt(this._target,this._key),this._value}set value(t){this._disposed||this._equals(this._value,t)||(this._value=t,wt(this._target,this._key))}peek(){return this._value}update(t){this.value=t(this._value)}mutate(t){this._disposed||(t(this._value),wt(this._target,this._key))}notify(){this._disposed||wt(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 ne{constructor(t){this._dirty=!0,this._computing=!1,this._getter=t,this._target={[ee]:!0},this._key=ie,this._cleanup=Mt(()=>{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&&wt(this._target,this._key)}finally{this._computing=!1}}})}get value(){if(vt(this._target,this._key),this._dirty){this._computing=!0,V();try{this._value=this._getter(),this._dirty=!1}finally{W(),this._computing=!1}}return this._value}peek(){if(this._dirty){V();try{this._value=this._getter(),this._dirty=!1}finally{W()}}return this._value}dispose(){this._cleanup&&(this._cleanup(),this._cleanup=void 0)}valueOf(){return this.value}toString(){return String(this.value)}}class oe{constructor(t){this._dirty=!0,this._disposed=!1,this._getter=t,this._target={[ee]:!0},this._key=ie,this._runner=function(t,e){const i=new lt(t);return i.scheduler=e,{run:()=>{bt(()=>i.run())},stop:()=>i.stop()}}(()=>{this._value=this._getter()},()=>{this._dirty||this._disposed||(this._dirty=!0,wt(this._target,this._key))})}get value(){return this._disposed||vt(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=xt(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 re=null,ae=null,ce=null,le=null,he=null;const ue=new WeakMap,de=new WeakMap,pe=new WeakMap,fe=new WeakMap,me=new WeakMap;function _e(t,e){const i=re;re=t;try{return e()}finally{re=i}}function ge(t,e,i){const s=ae,n=ce;ae=t,ce=e;try{return i()}finally{ae=s,ce=n}}function ye(t){let e=t;for(;e;){const t=pe.get(e);if(t)return t.scope;const i=fe.get(e);if(i&&i._pending)return i;e=e.parent}return null}function ve(t){le&&le._pending&&fe.set(t,le)}function we(t){const e=he;if(!e)return;if(pe.get(t)?.live)return;const i=ye(t)??e._currentScope();pe.set(t,{scope:i,live:!0}),i._livePins++}function be(t){const e=pe.get(t);e?e.live&&(e.live=!1,e.scope._releaseLivePin()):he&&ue.has(t)&&pe.set(t,{scope:ye(t)??he._currentScope(),live:!1})}class Se{constructor(t,e,i){this.services=t,this.scopedCache=new Map,this.transientSet=new Set,this._autoDisposeTransients=!1,this.pendingScoped=new Map,this._ownerlessSlot={owner:null,ownerless:!0},this._navigationDisposed=!1,this._livePins=0,this._pending=!1,this.describeToken=t=>"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(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 Se(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 S("MJX401",this.describeToken(t));return this.resolveDescriptorSync(e,[t])}async getAsync(t){const e=this.services.getDescriptor(t);if(!e)throw S("MJX401",this.describeToken(t));return await this.resolveDescriptorAsync(e,[t])}_getFor(t,e){let i=ue.get(t);return i||(i={owner:t},ue.set(t,i)),ge(i,ce,()=>this.get(e))}getAllServices(){return this.services}_beginNavigation(){const t=this.root,e=t._navigation??={current:t,version:new se(0),scopes:new Set};he=t;const i=new Se(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=ye(t.owner);if(e)return e;if(le&&le.root===this)return le}return e?e.current:this}_handle(t,e){const i=ae??this._ownerlessSlot;let s=de.get(i);s||de.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=ae??this._ownerlessSlot;return await this._scopeFor(i)._scopedInstanceAsync(t,e),ge(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=me.get(t);s||me.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=ge(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=ge(null,null,()=>this.instantiateSync(t,e));return this.singletonCache.set(t.token,i),i}case"scoped":return this._isSystemScope()&&ce!==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()&&ce!==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(ae)return t();const e={owner:null},i=ge(e,ce,t);return!i||"object"!=typeof i&&"function"!=typeof i||"function"==typeof i.then||(ve(i),e.owner=i,ue.has(i)||ue.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=_e(this.injectionResolver(e),()=>t.useFactory(...i,this));if(s&&"function"==typeof s.then){throw S("MJX402",this.describeTokenWithSource(t.token))}return s});if(t.useClass)return this.construct(()=>{const i=this.resolveDepsSync(t,e);return _e(this.injectionResolver(e),()=>new t.useClass(...i))});throw S("MJX403")}async instantiateAsyncIn(t,e,i,s){return await ge(t,e,()=>this.instantiateAsync(i,s))}async instantiateAsync(t,e){if(void 0!==t.useValue)return t.useValue;const i=ae,s=ce;if(t.useFactory){const n=await this.resolveDepsAsyncIn(i,s,t,e);return await ge(i,s,()=>this.construct(()=>_e(this.injectionResolver(e),()=>t.useFactory(...n,this))))}if(t.useClass){const n=await this.resolveDepsAsyncIn(i,s,t,e);return ge(i,s,()=>this.construct(()=>_e(this.injectionResolver(e),()=>new t.useClass(...n))))}throw S("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,he===this&&(he=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 ge(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 S("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 S("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 S("MJX404",e.slice(i).concat([t]).map(t=>this.describeTokenWithSource(t)).join(" -> "))}}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"}]`}}const Ce={live:0},Me=Symbol("motif.optionsOwner"),ke=Symbol("motif.transition"),De={mode:"concurrent"},Ae=()=>{};function xe(){const t=new WeakMap;return{track:function(e,i,s){const n=e?.parentNode??s?.parentNode;if(!n)return{done:i,release:Ae};let o=t.get(n);o||t.set(n,o=new Set);let r=Ae;const a={node:e,via:s??null,done:new Promise(t=>{r=t})};o.add(a);let c=!1;const l=()=>{c||(c=!0,o.delete(a),r())};return{done:()=>{const t=!c;l(),t&&i&&i()},release:l,finished:a.done}},pending:function(e,i){if(!e)return null;const s=t.get(e);if(!s||0===s.size)return null;let n=null;for(const t of s)t.node!==i&&(t.node.parentNode===e||t.via?.parentNode===e?(n??=[]).push(t.done):s.delete(t));return n?Promise.all(n).then(Ae):null}}}const Ee=xe(),Te=xe(),Oe=Ee.track,Ne=Ee.pending,Pe=Te.track,Le=Te.pending;function Re(t){return"concurrent"===t||"out-in"===t||"in-out"===t}function Xe(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}const Ie=1024;function Je(t){return t?._motif?.options}function je(t){return t?._motif?.options?.[ke]}function Fe(t){const e=je(t);if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function He(t){let e=t;for(;e;){const t=je(e)?.mode;if(t)return t;const i=e.element;if(!i||i.nodeType!==Node.COMMENT_NODE)break;e=e.parent??e._leaveContainer}return De.mode}function Be(t){const e=t?._motif?.options,i=e?.[ke];return!!(e?.transitionIn||i&&(i.classes||i.name&&i.name.length>0))}function ze(t){const e=()=>t.motif.options?.[ke]??i,i={transitionInfo:()=>{const i=e();return{in:Qt(t.element,`${i.name}-enter ${i.name}-enter-start`),out:Qt(t.element,`${i.name}-leave ${i.name}-leave-start`)}},name:"",mode:void 0,classes:void 0,activeCssCancel:null,activeCssPhase:null,cssProps:()=>{const t=e();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:e=>{t.motif.options.transitionIn=e},out:e=>{t.motif.options.transitionOut=e},enterTransition:i=>{const s=e(),n=t._base,o=!n._enterPlayed;if(n._enterPlayed=!0,n._enterSeq=(n._enterSeq??0)+1,s._suppressEnter)return i&&i(),Ut;const r={};n._enterRun=r;const a=Pe(t.element,()=>{t._base?._enterRun===r&&(t._base._enterRun=null,Fe(t)),i&&i()},t.motif.options.placeholder),c=t.motif.options.transitionIn,l=c?s.run(c.keyframes,c.options,a.done):s._runCss("enter",a.done,o);return l&&l!==Ut&&"function"==typeof l.addEventListener&&l.addEventListener("cancel",a.release),l},leaveTransition:i=>{const s=e(),n=t.element,o=Oe(n,i),r=()=>{const e=t.motif.options?.transitionOut,i=e?s.run(e.keyframes,e.options,o.done):s._runCss("leave",o.done);return i&&i!==Ut&&"function"==typeof i.addEventListener&&i.addEventListener("cancel",o.release),i};return o.finished&&"in-out"===He((a=t).parent??a._leaveContainer)?function(t,e,i){const s=t.parentNode,n={finished:e.finished??Promise.resolve(),playState:"pending",addEventListener:Ae,removeEventListener:Ae,cancel:Ae};return queueMicrotask(()=>{const e=Le(s,t);e?e.then(()=>{i()}):i()}),n}(n,o,r):r();var a},_runCss:(i,s,n=!1)=>{const o=e();if("enter"===i&&"leave"===o.activeCssPhase)return s&&s(),Ut;const r=o.cssProps(),a=t.element;if(r&&a&&1===a.nodeType&&a.classList){try{o.activeCssCancel?.()}catch{}const t=Zt(a,r,i,()=>{o.activeCssCancel=null,o.activeCssPhase=null,s&&s()},n);return o.activeCssCancel=t,o.activeCssPhase=i,Ut}return s&&s(),Ut},activeAnimations:[],run:(i,s,n)=>{const o=e();t.motif.stopAnimations();const r=t.element;if(r.animate){var a=r.animate(i,s);o.activeAnimations.push(a);let t=!1;const e=()=>{if(!t){t=!0;try{o.activeAnimations&&(o.activeAnimations=o.activeAnimations.filter(t=>t!==a))}catch{}}};return a.addEventListener("finish",()=>{n&&n(),e()}),a.oncancel=()=>{e()},a}{n&&n();const t=globalThis;if("function"==typeof t.Animation)try{return new t.Animation}catch{}return Ut}}};return i}class Ve{constructor(t){this[Me]=t}get transition(){return this[ke]??=ze(this[Me])}set transition(t){this[ke]=t}set enableRouterClassing(t){try{const e=this[Me],i=e.context.onRouterChanged(()=>{Qe.routerClassing.call(e,t)});e.motif.register(D.toDisposable(()=>{i()})),Qe.routerClassing.call(e,t)}catch(t){C("MJX105",t)}}getInstance(){return this[Me]}get display(){return this[Me].isVisible}set display(t){t?this[Me].motif.show():this[Me].motif.hide()}hasEvent(t){return Si(this[Me],t)}}function We(t,e,i){const s=t._baseCtx;s&&s._emiters?.fire(e,i)}function $e(t,e,i,s,n){if(!t)return;let o=t[e];if(!o)return;let r=0;if("function"==typeof o){const a=o;if(M(()=>a(i,s),"MJX122",n),o=t[e],!Array.isArray(o))return;r=1}for(let t=r;t<o.length;t++){const e=o[t];M(()=>e(i,s),"MJX122",n)}}function Ue(t,e,i,s,n){if(t[e])return!0;const o=t._baseCtx;return!!o?.[i]||(!(!n||!t[n])||!!o?._emiters?.hasListeners(s))}Lt(Ve.prototype,["getInstance","hasEvent"]);const qe=["build","setState","reState","setText","style","dispose","disposeAsync","using","doWork","getService","$","useModel","context","siblings","serviceProvider","isWait"],Ge=new WeakSet;function Ke(t,e){if("function"!=typeof t)return!1;const i=e.replace(/\$/g,"\\$");return new RegExp(`\\bsuper\\s*(\\.\\s*${i}(?![\\w$])|\\[)`).test(Function.prototype.toString.call(t))}function Ye(t){if(!c())return;const e=t?.constructor;if("function"!=typeof e||Ge.has(e))return;Ge.add(e);const i=e.name||"An anonymous component class";for(const[e,s]of function(t){const e=[],i=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);for(const s of qe)if(i(t,s))e.push([s,"field"]);else for(let i=Object.getPrototypeOf(t);i&&i!==ji.prototype;i=Object.getPrototypeOf(i)){const t=Object.getOwnPropertyDescriptor(i,s);if(t){("value"in t?[t.value]:[t.get,t.set].filter(Boolean)).some(t=>Ke(t,s))||e.push([s,"method"]);break}}const s=t;return s.motif instanceof te||e.push(["motif","replaced"]),s.controls instanceof Us||e.push(["controls","replaced"]),s.class instanceof $t||e.push(["class","replaced"]),s.attr instanceof Wt||e.push(["attr","replaced"]),s.bindings instanceof It||e.push(["bindings","replaced"]),null==s.element||"undefined"==typeof Node||s.element instanceof Node||e.push(["element","replaced"]),null==s.parent||s.parent instanceof ji||e.push(["parent","replaced"]),e}(t))k("MJX128",[i,e,s])}const Qe={callInitializeComponent(t){const e=t,i={cancel:!1};if(!t||t.isDisposed)return;"function"==typeof t.initializeComponent&&M(()=>t.initializeComponent(e,i),"MJX122","initializeComponent");const s=t._init;s&&M(()=>s(e,i),"MJX122","initializeComponent"),$e(t._baseCtx,"_initializeComponentHandlers",e,i,"initializeComponent"),"function"==typeof t.oninitializeComponent&&M(()=>t.oninitializeComponent(e,i),"MJX122","oninitializeComponent"),$e(t._baseCtx,"_onInitializeComponentHandlers",e,i,"oninitializeComponent")},callDisposing(t){if(!t||t.isDisposed)return;if(!Ue(t,"onDisposing","_onDisposingHandlers","ondisposing","ondisposing"))return;const e=t,i={cancel:!1};t.onDisposing&&M(()=>t.onDisposing(e,i),"MJX122","onDisposing"),$e(t._baseCtx,"_onDisposingHandlers",e,i,"onDisposing"),t.ondisposing&&M(()=>t.ondisposing(e,i),"MJX122","ondisposing"),We(t,"ondisposing",i)},callActivated(t){if(!t||t.isDisposed)return;const e=t,i={cancel:!1};t.onActivated&&M(()=>t.onActivated(e,i),"MJX122","onActivated"),$e(t._baseCtx,"_onActivatedHandlers",e,i,"onActivated"),We(t,"onactivated",i)},callDeactivated(t){if(!t||t.isDisposed)return;const e=t,i={cancel:!1};t.onDeactivated&&M(()=>t.onDeactivated(e,i),"MJX122","onDeactivated"),$e(t._baseCtx,"_onDeactivatedHandlers",e,i,"onDeactivated"),We(t,"ondeactivated",i)},deactivateTree(t,e=!0){if(t&&!t.isDisposed&&t.isBuilt&&t._base&&!t._base._inactive&&(t._base._inactive=!0,Qe.callDeactivated(t),e&&!t.isDisposed))for(const e of Oi(t).slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&Qe.deactivateTree(e,!0)},activateTree(t,e=!0){if(t&&!t.isDisposed&&t._base&&t._base._inactive&&(t._base._inactive=!1,Qe.callActivated(t),e&&!t.isDisposed))for(const e of Oi(t).slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&Qe.activateTree(e,!0)},callDisposed(t){if(t&&0===(t._flags&Ie)&&(!t.isDisposed||t.element||void 0!==t._baseCtx)){if(t._flags|=Ie,Ue(t,"onDisposed","_onDisposedHandlers","ondisposed","ondisposed")){const e=t,i={cancel:!1};t.onDisposed&&M(()=>t.onDisposed(e,i),"MJX122","onDisposed"),$e(t._baseCtx,"_onDisposedHandlers",e,i,"onDisposed"),t.ondisposed&&M(()=>t.ondisposed(e,i),"MJX122","ondisposed"),We(t,"ondisposed",i)}try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:disposed",{id:t.id,type:t.constructor?.name})}catch{}}},callBuilt(t){if(t&&!t.isDisposed){if(Ue(t,"onBuilt","_onBuiltHandlers","onbuilt","onbuilt")){const e=t,i={cancel:!1};t.onBuilt&&M(()=>t.onBuilt(e,i),"MJX122","onBuilt"),$e(t._baseCtx,"_onBuiltHandlers",e,i,"onBuilt"),t.onbuilt&&M(()=>t.onbuilt(e,i),"MJX122","onbuilt"),We(t,"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._baseCtx?._mountedScheduled)return;if(!("function"==typeof t.onMounted||!!t._baseCtx?._onMountedHandlers||"function"==typeof t.onmounted))return;t._base._mountedScheduled=!0;const e=t.element;if(!e||"number"!=typeof e.nodeType)return;const i=bs(e,()=>{t.isDisposed||Qe.callMounted(t)});i&&t._register(D.toDisposable(i))},callMounted(t){if(!t||t.isDisposed||t._base._mountedFired)return;t._base._mountedFired=!0;const e=t,i={cancel:!1};t.onMounted&&M(()=>t.onMounted(e,i),"MJX122","onMounted"),$e(t._baseCtx,"_onMountedHandlers",e,i,"onMounted"),t.onmounted&&M(()=>t.onmounted(e,i),"MJX122","onmounted"),We(t,"onmounted",i)},callBuilding(t){if(!t||t.isDisposed)return;if(!Ue(t,"onBuilding","_onBuildingHandlers","onbuilding"))return;const e=t,i={cancel:!1};t.onBuilding&&M(()=>t.onBuilding(e,i),"MJX122","onBuilding"),$e(t._baseCtx,"_onBuildingHandlers",e,i,"onBuilding"),We(t,"onbuilding",i)},callConfig(t){if(!t||t.isDisposed||t.isConfigured)return;t.isConfigured=!0;const e=t._motif?.options?._preconfig;if(e&&r(()=>e(t),"Component._preconfig"),!Ue(t,"onConfig","_onConfigHandlers","onconfig"))return;const i=t,s={cancel:!1};t.onConfig&&M(()=>t.onConfig(i,s),"MJX122","onConfig"),$e(t._baseCtx,"_onConfigHandlers",i,s,"onConfig"),We(t,"onconfig",s)},callConfigured(t){if(256&t._flags)return;if(t?._baseCtx?._configDeferred&&!t.isConfigured&&Qe.callConfig(t),t._flags|=256,!t||t.isDisposed)return;if(!Ue(t,"onConfigured","_onConfiguredHandlers","onconfigured"))return;const e=t,i={cancel:!1};t.onConfigured&&M(()=>t.onConfigured(e,i),"MJX122","onConfigured"),$e(t._baseCtx,"_onConfiguredHandlers",e,i,"onConfigured"),We(t,"onconfigured",i)},callOnInitialized(t){if(!t||t.isDisposed)return;if(t.isInitialized=!0,!Ue(t,"onInitialized","_onInitializedHandlers","oninitialized"))return;const e=t,i={cancel:!1};t.onInitialized&&M(()=>t.onInitialized(e,i),"MJX122","onInitialized"),$e(t._baseCtx,"_onInitializedHandlers",e,i,"onInitialized"),We(t,"oninitialized",i)},callOnInitializing(t){if(!t||t.isDisposed)return;if(!Ue(t,"onInitializing","_onInitializingHandlers","oninitializing"))return;const e=t,i={cancel:!1};t.onInitializing&&M(()=>t.onInitializing(e,i),"MJX122","onInitializing"),$e(t._baseCtx,"_onInitializingHandlers",e,i,"onInitializing"),We(t,"oninitializing",i)},callVisibilityChanged(t,e){if(!t||t.isDisposed)return;if(!Ue(t,"onVisibilityChanged","_onVisibilityChangedHandlers","onvisibilitychanged"))return;const i=t,s={cancel:!1,visible:e};t.onVisibilityChanged&&M(()=>t.onVisibilityChanged(i,s),"MJX122","onVisibilityChanged"),$e(t._baseCtx,"_onVisibilityChangedHandlers",i,s,"onVisibilityChanged"),We(t,"onvisibilitychanged",s)},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(Qe.callConfigured(t),t.isDisposed)return;if(Ai(t),t.isWait)return void(this.isBuilt&&function(t,e){if(!Ze(e))return;const i=_s(t)?.element;if(!i)return;const s=e.element;if(s&&s.parentNode===i)return;const n=e.motif.options,o=n.placeholder??(n.placeholder=zs.createComment("h"));if(o.parentNode===i)return;i.insertBefore(o,ei(t,t.controls.items.indexOf(e)+1,i))}(this,t));const e=t.isBuilt;if(!this.isBuilt)return;if(t.isWait)return;const i=t._baseCtx?._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||Qe.internalBuild.call(this,t)})}}else t.build();if(t.isDisposed||this.isDisposed)return;t.parent=this;const s=this.controls.items,n=s.length>0&&s[s.length-1]===t?s.length-1:s.indexOf(t),o=_s(this);var r=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;e&&t.element.nodeType==Node.COMMENT_NODE&&0==r?.childNodes.length&&t.controls.length>0&&(r=Qe.getContent.call(t));const a=o?.element,c=t.motif.options.placeholder,l=t.isVisible&&c&&a&&c.parentNode===a?c:null,h=l??(a?ei(this,n+1,a):null);if(!t.isVisible){if(!Ze(t))return;t.motif.options.placeholder||(t.motif.options.placeholder=zs.createComment("h")),r=t.motif.options.placeholder}if(a&&"out-in"===He(this)){const e=Ne(a,r);if(e)return t._base._enterSeq=(t._base._enterSeq??0)+1,void e.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||Qe.internalBuild.call(this,t)})}const u=o?.element;if(r&&u&&(r===u||r.contains(u)))k("MJX104",[]);else{if(h)try{o?.element.insertBefore(r,h)}catch{o?.element.appendChild(r)}else o?.element.appendChild(r);l&&l.parentNode&&l.parentNode.removeChild(l)}if(t.isVisible){!(!e&&t._baseCtx?._enterSeq!==i)&&Be(t)&&t.motif.options.transition.enterTransition(()=>{}),e&&Qe.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=>{const e=t.isWait||!t.isVisible?Ze(t)?t.motif.options.placeholder??=zs.createComment("h"):void 0:Qe.getContent.call(t);e&&this.motif.options.cache?.appendChild(e)}),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 C("MJX610",t),!1}}(n,o),a=r||function(t,e){const i=Y(t),s=Y(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){}}};function Ze(t){return"detach"!==Je(t)?.hideStrategy}function ti(t,e){const i=Je(t)?.placeholder;if(i&&i.parentNode===e)return i;const s=t.element;return s&&s.parentNode===e?s:null}function ei(t,e,i){const s=t.controls.items;for(let t=e;t<s.length;t++){const e=s[t]?ti(s[t],i):null;if(e)return e}if(t.element.nodeType===Node.COMMENT_NODE){const e=Je(t)?.closeFragment;return e&&e.parentNode===i?e:null}return null}function ii(t,e,i){const s=Je(t),n=e.parentNode;if(e.nodeType===Node.COMMENT_NODE){if(n){const t=s?.closeFragment||null;if(t){let i=e;for(;i;){const e=i.nextSibling;try{n.removeChild(i)}catch{}if(i===t)break;i=e}}else try{n.removeChild(e)}catch{}if(!i)return}}else if(n){try{n.removeChild(e)}catch{}if(!i)return}const o=s?.placeholder;if(o&&o.parentNode)try{o.parentNode.removeChild(o)}catch{}}function si(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const i=t.motif.options,s=i?.[ke];try{if(!0===s?.skipNextLeave||!0===t._forceInstantDetach)return s&&(s.skipNextLeave=!1),t._forceInstantDetach=!1,void ii(t,e,!0)}catch{}if(s||i?.transitionOut)try{i.transition.leaveTransition(()=>{ii(t,e,!1)})}catch{ii(t,e,!1)}else ii(t,e,!1)}async function ni(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const i=t.motif.options,s=i?.[ke];try{if(!0===s?.skipNextLeave||!0===t._forceInstantDetach)return s&&(s.skipNextLeave=!1),t._forceInstantDetach=!1,void ii(t,e,!0)}catch{}if(s||i?.transitionOut)return new Promise(s=>{try{i.transition.leaveTransition(()=>{ii(t,e,!1),s()})}catch{ii(t,e,!1),s()}});ii(t,e,!1)}function oi(t){if(!t.isDisposed){Qe.callDisposing.call(t,t);try{Ci(t)}catch{}if(t.motif.stopAnimations(),Mi(t),Oi(t).length)for(const e of t._controls.items)try{oi(e)}catch{}Qe.callDisposed.call(t,t),n(()=>{t._baseCtx?._emiters?.clear()},"disposeShallow.emiters"),t.isDisposed=!0,E.prototype.dispose.call(t)}}function ri(t){try{t.parent=null}catch{}t._eventHandlers=void 0;try{t._class?._countsStore?.clear()}catch{}try{t._class?._watchersStore?.clear()}catch{}try{t._attr?._attrMapStore?.clear()}catch{}try{t._attr?._watchersStore?.clear()}catch{}try{const e=t._motif?.options;e&&(e.cache=void 0,e.closeFragment=void 0,e.placeholder=void 0)}catch{}try{t.element=null}catch{}try{t.props=void 0}catch{}try{t.childs=void 0}catch{}try{t.class=void 0}catch{}try{t.attr=void 0}catch{}try{t.parent=null}catch{}try{t._motif&&(t._motif.options=void 0)}catch{}const e=Object.keys(t);for(let i=0;i<e.length;i++){const s=e[i];if("_motif"!==s&&"_flags"!==s)try{t[s]=void 0}catch{}}t._store=null,t._flags=1860}const ai=Promise.resolve();function ci(t,e){if(!e&&t._disposing&&!t.isDisposed)return!1;if(t.disposeAsync!==ji.prototype.disposeAsync)return!1;const i=Je(t);if(i){if(i.transitionOut)return!1;const t=i[ke];if(t){if(t.activeAnimations&&t.activeAnimations.length>0)return!1;if(t.activeCssCancel)return!1;if(t.classes||t.name&&t.name.length>0)return!1}}const s=Oi(t);if(s.length)for(let t=0;t<s.length;t++){const e=s[t];if(e&&!e.isDisposed&&!ci(e,!1))return!1}return!0}const li=new WeakMap;function hi(t,e,i){const s=i?"disposeAsync":"dispose";if(Co._disposingCount>0){const e=function(t){for(let e=t;e;e=e.parent){if(e.application)return e.application;const t=li.get(e);if(t)return t}return Co.main??null}(t);e&&"disposing"===e.state&&li.set(t,e)}!i&&e?.skipLeaveTransition&&(t.motif.options.transition.skipNextLeave=!0),n(()=>{Qe.callDisposing.call(t,t)},s+".callDisposing"),Ci(t),Mi(t),n(()=>{t.parent?.controls?.silentDetach?.(t,!0)},s+".silentDetach")}function ui(t,e,i){if(t.isDisposed=!0,E.prototype.dispose.call(t),i)return t._controls&&(t._controls.items=[]),n(()=>{Qe.callDisposed.call(t,t)},"disposeAsync.callDisposed"),n(()=>{t._baseCtx?._emiters?.clear()},"disposeAsync.emiters"),void(e?.deep&&ri(t));t.element=null,n(()=>{Qe.callDisposed.call(t,t)},"dispose.callDisposed"),n(()=>{t._baseCtx?._emiters?.clear()},"dispose.emiters"),Ci(t),ri(t)}async function di(t,e,i,s){s?await s:((i||je(t)?.skipNextLeave)&&await t.motif.stopAnimations(),await ni(t)),i||"TransportTo"===t.constructor.name||await async function(t){if(0===Ce.live)return;const e=Fi(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()}))}(t);const n={deep:e?.deep};await o(async()=>{if(t.isDisposed)return;const e=Array.from(Oi(t));e.length&&await Promise.all(e.map(t=>i?o(async()=>{await t.disposeAsync(n)},"disposeAsync.disposeAsyncChildren.handler"):(async()=>{try{await t.disposeAsync(n)}catch(t){C("MJX107",t)}})()))},i?"disposeAsync.disposeAsyncChildren":"dispose.disposeAsync"),!i&&t.isDisposed||ui(t,e,i)}const pi={get emiters(){return this._emiters??=new jt(this.owner)},_offAll(){Ci(this.owner)},_deactivateBindings(){Mi(this.owner)},_activateBindings(){ki(this.owner)},_reactivateBindings(){Di(this.owner)},_activatePreBindings(){Ai(this.owner)},_detachDomWithAnimation(){si(this.owner)},_detachDomWithAnimationAsync(){return ni(this.owner)},_disposeShallow(){oi(this.owner)},_deepCleanup(){ri(this.owner)}},fi=16,mi=32,_i=64,gi=[];let yi=0;class vi{constructor(t,e,i,s,n){this.owner=t,this.key=e,this.original=i,this.type=s,this.flags=n,this.next=void 0}handleEvent(t){const e=this.flags,i=this.owner;if(1&e&&t.target!==i.element)return;if(2&e&&!t.isTrusted)return;const s=this.original;let n;try{s&&s.length<=1?n=s(t):s&&(n=s(i,t))}catch(t){C("MJX123",t,this.type)}if(n&&"function"==typeof n.then){const t=this.type;n.then(void 0,e=>C("MJX123",e,t))}4&e&&wi(t),8&e&&bi(t),n&&!0===n.cancel&&(wi(t),bi(t))}}function wi(t){"function"==typeof t?.preventDefault&&t.preventDefault()}function bi(t){"function"==typeof t?.stopPropagation&&t.stopPropagation()}function Si(t,e){for(let i=t._eventHandlers;void 0!==i;i=i.next)if(0===(i.flags&_i)&&i.key===e)return!0;return!1}function Ci(t){const e=t._eventHandlers;if(void 0!==e){for(let i=e;void 0!==i;i=i.next)if((i.flags&(mi|_i))===mi)try{t.element.removeEventListener(i.type,i,0!==(i.flags&fi))}catch{}t._eventHandlers=void 0}}function Mi(t){try{t._bindings?._items?.length&&t._bindings.deactivateAll()}catch{}}function ki(t){try{t._bindings?.activateAll()}catch{}}function Di(t){try{t._bindings?.reActivateAll()}catch{}}function Ai(t){if(512&t._flags)return;const e=t._bindings?._items;e&&e.length>0&&t._bindings.items.filter(t=>"isWait"==t.propertyName||"display"==t.propertyName).forEach(t=>{t.activate()}),t._flags|=512}function xi(t){return t.owner}const Ei=Object.freeze([]),Ti=Object.freeze([]);function Oi(t){return t._controls?.items??Ei}function Ni(t){const e=xi(this);Si(e,"controladded")&&e.motif.trigger("controladded",{control:t}),(e.isVisible||e.element?.nodeType!==Node.COMMENT_NODE)&&Qe.internalBuild.call(e,t)}function Pi(t){const e=xi(this);Si(e,"controladded")&&e.motif.trigger("controladded",{control:t})}function Li(t){const e=xi(this);Si(e,"controlremoved")&&e.motif.trigger("controlremoved",{control:t})}const Ri=new WeakMap,Xi=new Set(["building","built","initializing","initialized","disposing","disposed","config","configured","visibilitychanged","activated","deactivated"]),Ii=Symbol("motif.rawApplication"),Ji=new Set(["on","onRouterChanged"]);class ji extends E{get motif(){return void 0!==this._motif?this._motif:this._motif=new te(this,this.isDisposed&&!this.element?void 0:new Ve(this))}set motif(t){this._motif=t}get isBuilt(){return!!(1&this._flags)}set isBuilt(t){this._flags=t?1|this._flags:-2&this._flags}get isInitialized(){return!!(2&this._flags)}set isInitialized(t){this._flags=t?2|this._flags:-3&this._flags}get isDisposed(){return!!(4&this._flags)}set isDisposed(t){this._flags=t?4|this._flags:-5&this._flags}get isConfigured(){return!!(8&this._flags)}set isConfigured(t){this._flags=t?8|this._flags:-9&this._flags}get isPainting(){return!!(16&this._flags)}set isPainting(t){this._flags=t?16|this._flags:-17&this._flags}get isPainted(){return!!(32&this._flags)}set isPainted(t){this._flags=t?32|this._flags:-33&this._flags}get isVisible(){return!(64&this._flags)}set isVisible(t){this._flags=t?-65&this._flags:64|this._flags}get controls(){return void 0!==this._controls||this.isDisposed&&!this.element?this._controls:this._controls=function(t){const e=new Us(t);return e.onAdd=Ni,e.onAddBeforeBuild=Pi,e.onRemove=Li,e}(this)}set controls(t){this._controls=t}get class(){return void 0!==this._class||this.isDisposed&&!this.element?this._class:this._class=new $t(this)}set class(t){this._class=t}get attr(){return void 0!==this._attr||this.isDisposed&&!this.element?this._attr:this._attr=new Wt(this)}set attr(t){this._attr=t}get bindings(){return void 0!==this._bindings||this.isDisposed&&!this.element?this._bindings:this._bindings=new It(this)}set bindings(t){this._bindings=t}useModel(t){return Ln(t)}_computeHideStrategy(){return Ze(this)?"placeholder":"detach"}_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._flags=t?128|this._flags:-129&this._flags,this.isBuilt?t?this.motif.hide():this.motif.show():!1===t&&this.parent&&this.parent.isBuilt&&Qe.internalBuild.call(this.parent,this)}get isWait(){return!!(128&this._flags)}constructor(t,e={}){super(),this._motif=void 0,this._flags=0,this._controls=void 0,this._class=void 0,this._attr=void 0,this._bindings=void 0,this._baseCtx=void 0,this._init=void 0,this._leaveContainer=void 0,this.parent=null;const i=ps;ps=!1,ve(this),this.onElementCreating?this.element=this.onElementCreating.call(this):this.element=e?.onElementCreating?e.onElementCreating.call(this):t,3!==this.element?.nodeType&&void 0===this._controls&&(this._controls=new Us(this));const s=e?Wi(e,this):[];if(e&&qi(e,this)&&(e={}),es(e?.options,this),this.props=e,e){const t=new.target;!i&&(t===ji||Object.getPrototypeOf(t)===ji)?cs(e,this):fs(e,this)}if(s.length>0)for(const t of Bi(this,s))M(()=>t(this),"MJX122","ref");if(Qe.callOnInitializing(this),this.isDisposed)return;const n=this._controls;n&&(n.onAdd=Ni,n.onAddBeforeBuild=Pi,n.onRemove=Li),Qe.callOnInitialized(this);const o=new.target;o===ji||Object.getPrototypeOf(o)===ji?Qe.callConfig(this):this._base._configDeferred=!0}get _base(){return void 0!==this._baseCtx||this.isDisposed&&!this.element?this._baseCtx:this._baseCtx=function(t){const e=Object.create(pi);return e.owner=t,e}(this)}get context(){const t=this.parent?.context,e=t?.[Ii]??t??li.get(this)??Co.main;return e?(this._scopedContext?.[Ii]!==e&&(this._scopedContext=function(t,e){const i=new Map;return new Proxy(t,{get(t,s){if(s===Ii)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=Ji.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(D.toDisposable(t));return()=>{this._disposables.detach(e),t()}}build(t=!0){if(Ye(this),Qe.callConfigured(this),Ai(this),this.isDisposed||!this.element||this.isWait)return;if(this.isBuilt||this.isWait)return;if(Qe.callBuilding(this),this.isDisposed)return;var e=this.element;t&&(e=zs.createDocumentFragment());const i="string"!=typeof this.element&&this.element.nodeType===Node.COMMENT_NODE;if(i&&(this.motif.options.cache=zs.createDocumentFragment(),this.element.textContent="[",this.motif.options.cache.appendChild(this.element)),this.isBuilt)return;if(Qe.callInitializeComponent(this),this.isDisposed)return;if(this.view){const t=this.view();if(this.controls.add(t),this.isDisposed)return}const s="SELECT"===this.element?.nodeName?this.bindings.items.filter(t=>"value"===t.propertyName):Ti;if(s.length)try{this.bindings.items.filter(t=>!s.includes(t)).forEach(t=>t.activate())}catch{}else ki(this);const n=Oi(this);for(const s of n.length?n.slice():n){var o=i?this.motif.options.cache:this.element;if(s.isWait||(s.parent=this,s.build(!1)),s.isWait){if(Ze(s)){const i=s.motif.options;(t?e:o).appendChild(i.placeholder??(i.placeholder=zs.createComment("h")))}}else{if(t){const t=Je(s)?.cache;t?e.appendChild(t):e.appendChild(s.element)}else{const t=Je(s)?.cache;t?o.appendChild(t):o.appendChild(s.element)}s._baseCtx?._inactive&&s.isVisible&&Qe.activateTree(s)}}if(!this.isDisposed){if(Be(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 Fe(this);if(t)try{(o=i?this.motif.options.cache:this.element).nodeType===Node.TEXT_NODE?o.appendData(e.textContent):o.appendChild?o.appendChild(e):o.append(e)}catch(t){}if(s.length)try{s.forEach(t=>t.activate())}catch{}i&&(this.motif.options.closeFragment=zs.createComment("]"),this.motif.options.cache.appendChild(this.motif.options.closeFragment),this.element.nodeType===Node.COMMENT_NODE&&this.motif.options.closeFragment&&Ri.set(this.element,this.motif.options.closeFragment)),this.isBuilt=!0,Qe.callBuilt(this),Qe.scheduleMounted(this)}}setState(){this.controls.forEach(t=>{t.setState()}),Di(this)}reState(){Di(this),this.controls.forEach(t=>{t.reState()})}setText(t){!this.isDisposed&&this.element&&(Qi(t)?function(t,e){if(Zi.has(t))return;Zi.add(t),k("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=()=>Mt(()=>{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;if(this.isWait)return;if(this.parent&&"out-in"===He(this.parent)){const t=this.motif.options.placeholder?.parentNode??_s(this.parent)?.element,e=Ne(t,this.element);if(e){const t=this._base._showSeq=(this._base._showSeq??0)+1;return e.then(()=>{if(!this.isDisposed&&this._base._showSeq===t)return this._show()})}}je(this)?.activeAnimations?.length&&n(async()=>{await Promise.all(this.motif.options.transition.activeAnimations.map(t=>t.finished?.catch(()=>{})))},"show.waitForLeaveAnimations");if("detach"===this._computeHideStrategy()){if(Qe.callVisibilityChanged(this,!0),this.isDisposed)return;const t=!this._isInDom()&&this.parent&&this.parent.isBuilt&&!this.isWait;return this.isVisible=!0,void(t&&Qe.internalBuild.call(this.parent,this))}{const e=this.motif.options.placeholder?.parentElement,i=_s(this.parent)?.element;if(this.motif.options.placeholder&&e&&e!==i){if(k("MJX106",[]),Qe.callVisibilityChanged(this,!0),this.isDisposed)return;return this.isVisible=!0,void(this.parent?.isBuilt&&Qe.internalBuild.call(this.parent,this))}if(Be(this)&&this.motif.options.transition.enterTransition(()=>{}),Qe.callVisibilityChanged(this,!0),this.isDisposed)return;if(this.element.nodeType===Node.COMMENT_NODE)return this.controls.items.filter(t=>!t.isBuilt).forEach(t=>Qe.internalBuild.call(this,t)),this.controls.forEach(t=>{t.motif.show()}),this.isVisible=!0,void Qe.activateTree(this,!1);if(!this.isBuilt)return void(this.isVisible=!0);var t=this.motif.options.placeholder?.parentElement;t&&(t.replaceChild(this.element,this.motif.options.placeholder),this.isVisible=!0,Qe.activateTree(this))}}async _hide(){if(this.isDisposed||!this.element)return;if(this._base._showSeq=(this._base._showSeq??0)+1,!this.isVisible)return;if("detach"===this._computeHideStrategy()){if(Qe.callVisibilityChanged(this,!1),this.isDisposed)return;return await this._base._detachDomWithAnimationAsync(),this.isVisible=!1,void Qe.deactivateTree(this)}{const t=this.motif.options.transition,e=!0===t.skipNextLeave;e&&(t.skipNextLeave=!1);const i=()=>{if(Qe.callVisibilityChanged(this,!1),!this.isDisposed){if(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 Qe.deactivateTree(this,!1);var t=this.element.parentElement;t&&(this.motif.options.placeholder||(this.motif.options.placeholder=zs.createComment("h")),t.replaceChild(this.motif.options.placeholder,this.element)),this.isVisible=!1,Qe.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=bs(this.element,()=>{if(t&&(this._base._mountedSubs?.get(e)?.delete(t),this._disposables.detach(t)),this.isDisposed)return;const i={cancel:!1};M(()=>e.length<=1?e(i):e(this,i),"MJX122","x:mounted")});if(i){t=this._register(D.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(Xi.has(t))return this._base.emiters.on("on"+t,e),this}const n=s.indexOf(":"),o=n<0?s:s.slice(0,n),r=n<0?gi:s.slice(n+1).split(":"),a=o.startsWith("on")?o.slice(2).toLowerCase():o.toLowerCase();let c,l=i?mi:0;r.length&&(c={},r.includes("once")&&(c.once=!0),r.includes("passive")&&(c.passive=!0),r.includes("capture")&&(c.capture=!0,l|=fi),r.includes("self")&&(l|=1),r.includes("trusted")&&(l|=2),r.includes("prevent")&&(l|=4),r.includes("stop")&&(l|=8));const h=new vi(this,s.toLowerCase(),e,a,l);return i&&this.element.addEventListener(a,h,c),function(t,e){let i=t._eventHandlers;if(void 0!==i){for(;void 0!==i.next;)i=i.next;i.next=e}else t._eventHandlers=e}(this,h),this}async _trigger(t,e){if(this.isDisposed||!this.element)return this;const i=String(t).toLowerCase();return n(()=>{yi++;try{for(let t=this._eventHandlers;void 0!==t;t=t.next)if(0===(t.flags&_i)&&t.key===i)try{t.handleEvent(e)}catch{}}finally{yi--}},"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 Xi.has(t)&&this._base._emiters?.off("on"+t,e),this}for(let t=this._eventHandlers;void 0!==t;t=t.next)if(0===(t.flags&_i)&&t.key===i&&t.original===e){if(0!==(t.flags&mi)){const e=t;n(()=>{this.element.removeEventListener(e.type,e,0!==(e.flags&fi))},"off.removeEventListener")}t.flags|=_i;break}return 0===yi&&function(t){let e,i;for(let s=t._eventHandlers;void 0!==s;s=s.next)0===(s.flags&_i)&&(void 0===i?e=s:i.next=s,i=s);void 0!==i&&(i.next=void 0),t._eventHandlers=e}(this),this}dispose(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(be(this),this._disposing=ai,this._disposing=this._disposeCore(t,!1))}async _disposeCore(t,e){let i;if(hi(this,t,e),e||je(this)?.skipNextLeave||(i=this._base._detachDomWithAnimationAsync()),await void 0,0===Ce.live&&ci(this,!0)){const s=function(t,e,i,s){const n={deep:e?.deep},o=[t],r=[-1];let a=null;s||si(t);for(let e=0;e<o.length;e++){const i=o[e];if(i.isDisposed)continue;const s=Oi(i);if(0===s.length)continue;const c=Array.from(s);for(let i=0;i<c.length;i++){const s=c[i];if(!s.isDisposed)if(s._disposing)(a??=[]).push(s._disposing);else try{be(s),s._disposing=t._disposing,hi(s,n,!0),!1!==s.element?.isConnected&&si(s),o.push(s),r.push(e)}catch(t){C("MJX107",t)}}}const c=o.length;if(c>1){const t=new Array(c).fill(0);for(let e=c-1;e>=1;e--){const i=r[e];t[e]+1>t[i]&&(t[i]=t[e]+1)}const e=[];for(let t=1;t<c;t++)e.push(t);e.sort((e,i)=>t[e]-t[i]||e-i);for(let t=0;t<e.length;t++)try{ui(o[e[t]],n,!0)}catch(t){C("MJX107",t)}}return a||(!i&&t.isDisposed||ui(t,e,i),null)}(this,t,e,void 0!==i);if(s){if(await Promise.all(s),!e&&this.isDisposed)return;ui(this,t,e)}return}await di(this,t,e,i)}disposeAsync(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(be(this),this._disposing=ai,this._disposing=this._disposeCore(t,!0))}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:S("MJX108"))}get siblings(){return this._siblingsSet||this.isDisposed&&!this.motif?.options?this._siblingsApi:this._siblingsApi??=this._createSiblingsApi()}set siblings(t){this._siblingsApi=t,this._siblingsSet=!0}_createSiblingsApi(){return{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;const i=li.get(t);if(i)return"disposed"===i.state?null:i.provider;t=t.parent}try{return Co.main?.provider??null}catch{return null}}getService(t){try{const e=this.serviceProvider;if(e)return e._getFor(this,t);k("MJX407",[Xe(t)],{token:t})}catch(e){k("MJX408",[Xe(t),String(e?.message??e)],{token:t,error:e})}return null}$(t){return this.isDisposed||!this.element?{fromDom:()=>null,fromComponent:()=>[]}:{fromDom:()=>{var e,i=_s(this)?.element;return(e=i||document)?e.querySelectorAll(t):null},fromComponent:()=>{const e=_s(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(){const t=je(this);try{t?.activeCssCancel?.()}catch{}try{if(t?.activeAnimations?.length)try{await Promise.all(t.activeAnimations.map(t=>t.finished?.catch(()=>{})))}catch{}}catch(t){}this.isDisposed||t&&(t.activeAnimations=[])}}function Fi(t,e=[]){return!t||t.isDisposed||("TransportTo"===t.constructor.name&&e.push(t),t.controls&&t.controls.items&&t.controls.items.forEach(t=>Fi(t,e))),e}const Hi=new WeakMap;function Bi(t,e){const i=(Array.isArray(e)?e:[e]).filter(t=>"function"==typeof t);if(0===i.length)return i;let s=Hi.get(t);s||(s=new Set,Hi.set(t,s));const n=[];for(const t of i)s.has(t)||(s.add(t),n.push(t));return n}function zi(t,e){Array.isArray(e)&&e.some(t=>t instanceof ji)&&t.motif.setDisposable(()=>{for(const t of e)t instanceof ji&&!t.isDisposed&&!t.parent&&t.dispose()})}const Vi=t=>"function"==typeof t||Array.isArray(t);function Wi(t,e){const i=[];if(!t||"object"!=typeof t)return i;Object.prototype.hasOwnProperty.call(t,"ref")&&(Vi(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(Vi(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 0===i.length?i:[].concat(...i)}const $i={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 Ui(t,e,i){const s=Object.prototype.hasOwnProperty.call($i,e)?$i[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;const o=t;let r=0;if("_initializeComponentHandlers"===s&&(void 0!==o._init||o._baseCtx?._initializeComponentHandlers||(o._init=n[0],r=1)),r>=n.length)return!0;const a=o._base;for(let t=r;t<n.length;t++){const e=n[t];if("_initializeComponentHandlers"===s&&e===o._init)continue;const i=a[s];void 0===i?a[s]=e:"function"==typeof i?i!==e&&(a[s]=[i,e]):i.includes(e)||i.push(e)}return!0}function qi(t,e){if(t){var i=Object.keys(t);return 0!==i.length&&(i.forEach(i=>{if("initializeComponent"==i||"oninitializeComponent"==i||i.startsWith("on")){if(Ui(e,i.toLowerCase(),t[i]))return void delete t[i]}else if("childs"==i){const s=[].concat(...t[i]);e.childs=s,zi(e,s),delete t[i]}else if("transition"===i)Yi(t[i],e),delete t[i];else if(ms.hasOwnProperty(i.toLowerCase())||ms.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(Ui(e,n.toLowerCase(),t[i]))return void delete t[i];delete t[i]}else i.startsWith("runover")?(qi(t[i],e),delete t[i]):i.startsWith("preconfig")?(e.motif.options._preconfig=t[i],delete t[i]):"__childExpr"===i&&delete t[i]}),"object"==typeof t&&0===Reflect.ownKeys(t).length)}return!1}const Gi=new WeakMap;function Ki(t,e,i){const s=t.motif.options.transition;if("string"==typeof e&&e.length>0)s.name=e,i&&(s.classes=void 0);else if(e&&"object"==typeof e)if("string"==typeof e.name&&e.name.length>0&&(s.name=e.name),"mode"in e){const{mode:t,...i}=e;Re(t)&&(s.mode=t),Object.keys(i).length>0&&(s.classes=i)}else s.classes=e;else i&&(s.name="",s.classes=void 0)}function Yi(t,e){e&&!e.isDisposed&&null!=t&&Gi.get(e)!==t&&(Gi.set(e,t),"function"!=typeof t?Ki(e,t,!1):e.bindings.watch(()=>{const i=t();e.isDisposed||Ki(e,i,!0)}))}function Qi(t){return t instanceof ji||Array.isArray(t)&&t.length>0&&t.every(t=>t instanceof ji)}const Zi=new WeakSet;const ts=["hideStrategy","disableDisposal"];function es(t,e){if(t&&"object"==typeof t&&e&&!e.isDisposed)for(const i of ts)void 0!==t[i]&&(e.motif.options[i]=t[i])}const is=new Set(["ref","key","indexkey","inject","options","props","settings","isSvg","childs","initializeComponent","runover","transition","preconfig","nodes","onElementCreating"]),ss=new Set(["innerhtml","srcdoc"]),ns=new Set(["href","src","action","formaction","xlink:href"]),os=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function rs(t){if(null==t||"boolean"==typeof t)return!1;try{return os.test(String(t))}catch{return!1}}function as(t,e){return()=>{let i=e();return"function"==typeof i&&(i=i()),"function"==typeof i&&(i=i()),rs(i)?(k("MJX125",[t]),null):i}}function cs(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const i=Object.keys(t);if(0===i.length)return;let s=null,n=null;for(const o of i){if(is.has(o))continue;if(o.startsWith("x-")||o.startsWith("x:")||o.startsWith("__"))continue;let i=t[o];if(void 0===i)continue;if(/^on/i.test(o)){"function"==typeof i&&e.motif.on(o,i);continue}if("function"==typeof i&&i.length>0)continue;const r=o.toLowerCase();if(ss.has(r))k("MJX124",[o]);else{if(ns.has(r))if("function"==typeof i)i=as(o,i);else if(rs(i)){k("MJX125",[o]);continue}(n??=hs(e)).set(o,i),"class"===o||"className"===o?e.class.add(i&&"object"==typeof i&&!Array.isArray(i)?[i]:i):"style"===o?e.style(i):"value"===o||"checked"===o||"selected"===o?e.bindings.add(o,i):(s??={})[o]=i}}s&&e.attr.add(s)}const ls=new WeakMap;function hs(t){let e=ls.get(t);return e||(e=new Map,ls.set(t,e)),e}const us=new Set(["class","className","style","id","tabindex","role"]);function ds(t){return us.has(t)||t.startsWith("aria-")||t.startsWith("data-")}let ps=!1;function fs(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const i=ls.get(e);let s=null;for(const e of Object.keys(t)){if(!ds(e))continue;const n=t[e];null!=n&&("function"==typeof n&&n.length>0||i&&i.has(e)&&Object.is(i.get(e),n)||((s??={})[e]=n))}s&&cs(s,e)}const ms={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 _s(t){return n(()=>!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?_s(t.parent):null,"findAppendableComponent",null)}const gs=new Set;let ys=null;function vs(){if(!gs.size&&ys){try{ys.disconnect()}catch{}ys=null}}function ws(){for(const t of[...gs])if(gs.has(t)&&document.contains(t.element)){gs.delete(t);try{t.callback()}catch(t){queueMicrotask(()=>{throw t})}}vs()}function bs(t,e){if(document.contains(t))return e(),null;const i={element:t,callback:e};return gs.add(i),ys||(ys=new MutationObserver(ws),ys.observe(document.documentElement,{childList:!0,subtree:!0})),()=>{gs.delete(i)&&vs()}}function Ss(t){!function(t){const e=pe.get(t);e&&(pe.delete(t),e.live&&e.scope._releaseLivePin(),he?._touch())}(t),Qe.activateTree(t)}function Cs(t){we(t),Qe.deactivateTree(t)}const Ms=100;function ks(t,e){let i=t,s=0;for(;"function"==typeof i;){if(i.prototype instanceof ji)return new i(e);if(++s>Ms)return C("MJX112",void 0,Ms),i;i=i(e)}return i}const Ds="http://www.w3.org/2000/svg";class As extends ji{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&&Ps(e=ks(e,i)))return Is(e,i);if(Array.isArray(e)){super(js(),{});var n=Object.create(i||{});for(const t in e){const i=e[t];this.controls.add(new As(i,n))}}else if("string"==typeof e&&e.trim().length>0)if(i||(i={}),i?.options&&i.options.isSvg||i?.__isSvgElement){const t=zs.createElementNS("http://www.w3.org/2000/svg",e,i);i.isSvg=!0,super(t,i)}else{super(zs.createElement(e,i),i)}else if(e instanceof Node)super(e,i);else{if(e instanceof ji)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===Ds||!0===i?.options?.isSvg||!0===i?.__isSvgElement?(i&&"object"==typeof i&&(i.isSvg=!0),zs.createElementNS(s||Ds,t,i)):zs.createElement(t,i)}(n,t,s),s??{})}else super(js(),s??{});const o=this.childs;if(Array.isArray(o)&&o.length&&!0!==t?._placesChilds)for(const t of o)t&&this.controls.add(t)}}}}function xs(t,e){if(t instanceof ji)for(const i of Bi(t,e))M(()=>i(t),"MJX122","ref");return t}function Es(t,e){const i=t._base?.[e];return i?"function"==typeof i?[i]:i:[]}function Ts(t,e){return Es(t,e).length}function Os(t,e,i,s){for(let n=i;n<Ts(t,e);n++){if(t.isDisposed)return;const i=Es(t,e)[n];M(()=>i(t,{cancel:!1}),"MJX122",s)}}function Ns(t,e){if("string"==typeof t){if("function"==typeof e){const i=new As(t);return i._init=e,i}if("text"===t&&e&&e.__childExpr){const t=function(t){if("function"!=typeof t)return;let e;try{e=xt(t)}catch{return}return e instanceof ji||Array.isArray(e)&&e.length>0&&e.every(t=>t instanceof ji)?e:void 0}(e.__childExpr);if(void 0!==t)return t}return new As(t,e)}if(t instanceof ji||t instanceof As)return t;if("function"==typeof t){const i=t.prototype instanceof ji?[]:Wi(e),s=ks(t,e);return"object"==typeof s&&null!==s&&"el"in s?xs(Is(s,e),i):function(t,e,i){if(!e||"object"!=typeof e)return t;if(!(t instanceof ji))return t;xs(t,i.concat(Wi(e))),zi(t,e.childs),fs(e,t),es(e.options,t),Object.prototype.hasOwnProperty.call(e,"transition")&&Yi(e.transition,t);const s=e.runover;if(!s||"object"!=typeof s)return t;const n=Ts(t,"_onConfigHandlers"),o=Ts(t,"_onInitializingHandlers"),a=Ts(t,"_onInitializedHandlers");if(qi(s,t),Os(t,"_onInitializingHandlers",o,"onInitializing"),Os(t,"_onInitializedHandlers",a,"onInitialized"),t.isConfigured){const e=t.motif.options?._preconfig;"function"==typeof e&&r(()=>e(t),"motifComponent.preconfig");for(let e=n;e<Ts(t,"_onConfigHandlers");e++){const i=Es(t,"_onConfigHandlers")[e];M(()=>i(t,{cancel:!1}),"MJX122","onConfig")}}return t}(s,e,i)}return"object"==typeof t&&null!==t&&"el"in t?Is(t,e):new As(t,e)}function Ps(t){return"object"==typeof t&&null!==t&&!(t instanceof ji)&&"el"in t}function Ls(t){return!t||"object"!=typeof t||t instanceof ji||null==t.default?t:t.default}function Rs(t){if(null!==t&&"object"==typeof t&&!(t instanceof ji||Array.isArray(t)||t instanceof Node)&&"function"!=typeof t.then)throw S("MJX127",function(t){return null===t?"null":Array.isArray(t)?"array":"object"!=typeof t||"[object Module]"!==Object.prototype.toString.call(t)&&!t.__esModule?typeof t:"module"}(t))}function Xs(t,e){const i=ks(t,e);return Ps(i)?Is(i,void 0):i}function Is(t,e){const i="string"==typeof t.el?function(t){ps=!0;try{return t()}finally{ps=!1}}(()=>Ns(t.el,e)):Ns(t.el,e);return Object.getOwnPropertyNames(t).forEach(e=>{"el"!==e&&"ctor"!==e&&(i[e]=t[e])}),"function"==typeof t.ctor&&M(()=>t.ctor.call(i,e),"MJX122","ctor"),i}function Js(t){return new Fs(t)}function js(){return zs.createComment("")}class Fs extends As{constructor(t,e){super(js(),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);r(()=>{const t=this.props?.nodes;if(Array.isArray(t)&&t.length)for(const e of t)e&&this.controls.add(e)},"Fragment.initializeComponent.props.nodes")}}const Hs=globalThis;function Bs(){return Hs&&Hs.motifDom?Hs.motifDom.window.document:Hs.document}const zs={get window(){return Hs&&Hs.window?Hs.window:Hs&&Hs?Hs.motifDom.window:Hs},_created:new Map,document:Bs(),createElement(t,e){const i=Bs();if(!i)throw S("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=Bs();if(t)return t.createDocumentFragment()}catch(t){s.reportSuppressed("dom.createDocumentFragment",t)}},createComment(t){try{return Bs()?.createComment(t)}catch(t){s.reportSuppressed("dom.createComment",t)}},createTextNode(t){try{return Bs()?.createTextNode(t)}catch(t){s.reportSuppressed("dom.createTextNode",t)}},querySelectorAll(t){try{return Bs()?.querySelectorAll(t)}catch(t){s.reportSuppressed("dom.querySelectorAll",t)}},createElementNS(t,e,i){try{return Bs()?.createElementNS(t,e,i)}catch(t){C("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 Bs()?.body}},Vs=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;var Ws;function $s(t,e,...i){return function(t,e,i,...s){const n=Vs.exec(e);if(!n)throw S("MJX102",e);const o=n[1]||"div";let r;return r=t!==Ws.HTML?zs.createElementNS(t,o):zs.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}(Ws.HTML,t,e,...i)}!function(t){t.HTML="http://www.w3.org/1999/xhtml",t.SVG="http://www.w3.org/2000/svg"}(Ws||(Ws={}));class Us{constructor(t){this.owner=t,this.items=[]}add(){const t=arguments.length;if(0===t)return[];const e=arguments[0];if(1===t&&e instanceof ji)return e.isDisposed?[]:[this._insertOne(void 0,e)];const i=Array.from(arguments);if("number"==typeof i[0]&&i.length>1){const t=i[0],e=[].concat(...i.slice(1));return this.insert(t,...e)}{const t=[].concat(...i);return this.insert(void 0,...t)}}insert(t,...e){return[].concat(...e).filter(t=>null!=t&&!t.isDisposed).map(e=>this._insertOne(t,e))}_insertOne(t,e){"string"!=typeof(e=ks(e))&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e||(e=new As(zs.createTextNode(e),null)),Ye(e),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._leaveContainer=this.owner,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{Ys(t)}catch(t){C("MJX117",t)}Cs(t)}try{e()}catch(t){C("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{const e=t.motif.options;if(!e[ke]&&!e.transitionOut)return void s();e.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{Ys(t)}catch(t){C("MJX117",t)}Cs(t)}}silentUnlink(t){const e=this.items.indexOf(t);-1!==e&&(this.items.splice(e,1),t._leaveContainer=this.owner,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)}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);const n=qs(this.owner);if(!n||!ti(t,n))return;const o=e?this.items.indexOf(e):-1;Ks(t,n,o>=0?function(t,e,i,s){for(let t=i;t<e.length;t++){const i=ti(e[t],s);if(i)return i}return Gs(t)}(this.owner,this.items,o,n):Gs(this.owner))}_reorder(t,e){const i=qs(this.owner);if(i){let s=Gs(this.owner);for(let n=t.length-1;n>=0;n--){const o=t[n],r=ti(o,i);r&&(e.has(n)||Ks(o,i,s),s=r)}}const s=this.items;for(let e=0;e<t.length;e++)s[e]=t[e]}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 qs(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}function Gs(t){const e=t.element;return e&&e.nodeType===Node.COMMENT_NODE&&t.motif.options?.closeFragment||null}function Ks(t,e,i){const s=ti(t,e);if(!s)return;if(s.nodeType!==Node.COMMENT_NODE||s!==t.element){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&&C("MJX120",void 0);return!1}(n,o,i)&&(i=o.nextSibling);const r=zs.createDocumentFragment&&zs.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&&C("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&&C("MJX119",void 0);try{e.insertBefore(r,i)}catch{}}function Ys(t){const e=t.element;if(!e)return;const i=t.motif.options;if(e.nodeType===Node.COMMENT_NODE&&e.parentNode){const t=i?.closeFragment||null,s=i.cache??(i.cache=zs.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 Qs(t){return Ls(t)}function Zs(t){const e=t&&t.options||{},i=new on,s=new Set,n=t=>{try{s.add(t)}catch{}return t},o=()=>{try{s.forEach(t=>{try{clearTimeout(t)}catch{}})}catch{}try{s.clear()}catch{}};try{i.motif.register(D.toDisposable(()=>o()))}catch{}const r=e.Placeholderview??e.Loaderview;null!=r&&i.navigate(Xs(r));const a=()=>{if(!e.timeoutMs&&!e.signal)return t.caller();const i=[t.caller()];return e.timeoutMs&&e.timeoutMs>0&&i.push(new Promise((t,o)=>{const r=n(setTimeout(()=>o(S("MJX110",e.timeoutMs)),e.timeoutMs));if(i[0].finally(()=>{try{clearTimeout(r),s.delete(r)}catch{}}).catch(()=>{}),e.signal){const t=()=>{try{clearTimeout(r),s.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(S("MJX111"));const s=()=>{e.signal.removeEventListener("abort",s),o(),i(S("MJX111"))};e.signal.addEventListener("abort",s,{once:!0})})),Promise.race(i)},c=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),l=new Set;try{i.motif.register(D.toDisposable(()=>{l.forEach(t=>{try{t()}catch{}}),l.clear()}))}catch{}const h=t=>new Promise(i=>{let o=!1;const r=t=>{if(!o){o=!0,l.delete(a);try{d&&window.removeEventListener("online",d)}catch{}try{void 0!==u&&(clearTimeout(u),s.delete(u))}catch{}try{e.signal?.removeEventListener("abort",h)}catch{}i(t)}},a=()=>r(!1),h=()=>r(!1);let u,d=null;l.add(a);try{e.signal?.addEventListener("abort",h,{once:!0})}catch{}const p=()=>{u=n(setTimeout(()=>r(!0),c.delayMs*t))};c.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()}),u=c.count>0?(async()=>{let t=0;for(;;)try{return await a()}catch(s){if(e.signal?.aborted||i.isDisposed||t>=c.count)throw s;t++;try{e.onRetry?.(t,s)}catch{}if(!await h(t)||e.signal?.aborted||i.isDisposed)throw s}})():a(),d=Date.now(),p=t=>{try{e.onError?.(t)}catch{}if(!e.signal?.aborted)if(null!=e.Fallbackview)i.navigate(Xs(e.Fallbackview));else{C("MJX126",t);try{i.motif.clear().catch(()=>{})}catch{}}},f=t=>{let e;try{e=Xs(t),Rs(e)}catch(t){return void p(t)}i.navigate(e)};return u.then(t=>{if(e.signal?.aborted)return;const i=(e.mapResult??Qs)(t),o=Date.now()-d,r=Math.max(0,e.minDelayMs??0),a=Math.max(0,r-o);if(a>0){const t=n(setTimeout(()=>{e.signal?.aborted||f(i)},a));if(e.signal){const i=()=>{try{clearTimeout(t),s.delete(t)}catch{}};try{e.signal.addEventListener("abort",i,{once:!0})}catch{}}}else f(i)}).catch(p),i}function tn(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 en(t){if(t&&!t.isDisposed)if(Array.isArray(t))t.forEach(en);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)en(e)}catch{}}}async function sn(t,e={deep:!0}){if(!t)return;const i=Array.isArray(t)?t:[t];await Promise.all(i.map(async t=>{if(t&&!t.isDisposed)try{await t.dispose(e)}catch(t){C("MJX115",t)}}))}async function nn(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=ks(e);t.current=i;try{Array.isArray(i)?t.controls.add(...i):t.controls.add(i)}catch(t){C("MJX114",t)}t.isBusy=!1,t.previouspage=i};if(!(t._navPending||null!==t.current||e instanceof Promise)){try{n(e)}catch(e){C("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 r=t.current;if(r&&!i){en(r),en(t);const e=!!(s=r)&&(Array.isArray(s)?s.some(t=>!!t&&!t.isDisposed&&tn(t,"leave")):!s.isDisposed&&tn(s,"leave")),i=sn(r);e?i.catch(()=>{}):await i}try{if(e instanceof Promise){const i=Zs({caller:()=>e,options:{signal:t._navAbort?.signal}});n(i)}else n(e)}catch(e){C("MJX114",e),t.isBusy=!1}}finally{t._navPending=Math.max(0,(t._navPending??1)-1)}var s})(),await t._navLock}class on extends As{constructor(t){super(zs.createComment(""),t),this.current=null,this._latestNavigateId=0,this._navLock=Promise.resolve(),this.isBusy=!1,t&&t.childs&&Array.isArray(t.childs)&&t.childs.length>0&&this.controls.add(t.childs)}async dispose(t={deep:!0}){await sn(this.current,t),await super.dispose(t)}async flush(){await sn(this.current)}async _clear(){await sn(this.current)}async navigate(t,e=!1){await nn(this,t,e)}async navigateLazy(t,e,i=!1){const s=Zs({caller:t,options:e});await this.navigate(s,i)}}const rn=new Set;const an=new Map,cn=Symbol("changeBodyCollectionHandler");const ln=Symbol("slotRegistered"),hn=Symbol("slotUnregistered");class un{static{this.slots=new Map}static registerSlot(t,e){this.slots.set(t,e),Co.main.fire(ln,{name:t,slot:e})}static unregisterSlot(t,e){this.slots.get(t)===e&&(this.slots.delete(t),Co.main.fire(hn,{name:t,slot:e}))}static getSlot(t){return this.slots.get(t)}}class dn{static transport(t,e,i={}){t&&e&&(t.parent===e&&e.controls.items.includes(t)||(t.parent&&t.parent!==e&&t.parent.controls.silentDetach(t,!0),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 S("MJX113");this.children.includes(t)||(dn.transport(t,this.parent,e),this.children.push(t))},unmount(t){if(!this.parent)throw S("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=[])}}}}const pn=new Set(["push","pop","shift","unshift","splice","reverse","sort"]),fn=Symbol(""),mn=new Map([[T.IS_REACTIVE,()=>!0],[T.IS_READONLY,t=>t.isReadonly],[T.IS_SUPERFICIAL,t=>t.superficial],[T.GET_SETUP,(t,e)=>e],[T.RAW,(t,e,i)=>t.ReactiveMap().get(e)===i?e:fn]]);function _n(t,e,i,s){if("symbol"!=typeof i)return fn;const n=mn.get(i);return void 0===n?fn:n(t,e,s)}function gn(t){return function(e,i,s){const n=_n(t,e,i,s);if(n!==fn)return n;if(Array.isArray(e)&&!t.isReadonly){const s=t.arrayMethods.get;if(R(s,i)){const t=s[i];return pn.has(i)?(o=i,$.push(P),P.enabled=!0,P.key=o):vt(e,i),t}}var o;const r=Reflect.get(e,i,s);return"__proto__"===i||J(i)?r:(t.isReadonly||vt(e,i),t.superficial||!X(r)?r:t.reactive(r))}}function yn(t){return function(e,i,s,n){if(null!=(o=e)&&Boolean(o[T.IS_READONLY]))return!1;var o;const r=Array.isArray(e),a=e[i],c=r?e.length:0,l=r&&("string"==typeof(h=i)&&F.test(h)&&String(Number(h))===h);var h;const u=l?Number(i)<c:R(e,i),d=Reflect.set(e,i,s,n);if(t.onValueChanged)try{t.onValueChanged({raw:e,proxy:n},i)}catch{}if(L(e)!==L(n))return d;if(!r&&u&&Object.is(s,a))return d;if(wt(e,i),r||u||wt(e,O),l&&!u&&wt(e,"length"),r&&"length"===i){for(let t=Number(s);t<c;t++)wt(e,String(t))}return function(){const t=$.pop();P=$.length>0?void 0===t?{enabled:!1,key:""}:t:{enabled:!1,key:""}}(),d}}function vn(t){return function(t){return vt(t,Array.isArray(t)?"length":O),Reflect.ownKeys(t)}}function wn(t){return function(t,e){const i=Reflect.has(t,e);return J(e)||vt(t,e),i}}function bn(t){return function(t,e){V();try{const i=R(t,e),s=Reflect.deleteProperty(t,e);return i&&(Array.isArray(t)?wt(t,"length"):(wt(t,e),wt(t,O))),s}finally{W()}}}const Sn=[["includes","lookup"],["indexOf","lookup"],["lastIndexOf","lookup"],["sort","order"],["concat","join"],["push","structural"],["pop","structural"],["shift","structural"],["unshift","structural"],["splice","structural"],["reverse","structural"]];class Cn{constructor(t){this.engine=t,this.get=this.createArrayMethods()}createArrayMethods(){const t={};for(const[e,i]of Sn)t[e]=this.patch(e,i);return t}patch(t,e){const i=this;switch(e){case"lookup":return function(...e){const s=L(this);i.engine.track(s,"length");const n=s[t](...e);return!1!==(o=n)&&-1!==o?n:s[t](...e.map(t=>L(t)));var o};case"order":return function(...e){const s=L(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){V();const i=L(this);try{return i[t].apply(this,e)}finally{W()}}}}}const Mn=Symbol("");function kn(t,e,i){wt(t,e),wt(t,O),i&&wt(t,Mn)}function Dn(t,e){return t.has(e)?e:L(e)}function An(t,e){return{next(){const i=t.next();return i.done?i:{value:e(i.value),done:!1}},[Symbol.iterator](){return this}}}function xn(t){const e=function(t){const e=e=>X(e)?t.reactive(e):e,i=t=>t instanceof Map?([t,i])=>[t,e(i)]:([t])=>{const i=e(t);return[i,i]};return{get(t){const i=L(this),s=Dn(i,t);return vt(i,s),e(i.get(s))},has(t){const e=L(this),i=Dn(e,t);return vt(e,i),e.has(i)},set(t,e){const i=L(this),s=Dn(i,t),n=L(e),o=i.has(s),r=i.get(s);return i.set(s,n),o?Object.is(r,n)||kn(i,s,!1):kn(i,s,!0),this},add(t){const e=L(this),i=Dn(e,t);return e.has(i)||(e.add(i),kn(e,i,!0)),this},delete(t){const e=L(this),i=Dn(e,t),s=e.delete(i);return s&&kn(e,i,!0),s},clear(){const t=L(this);if(0===t.size)return;const e=Array.from(t.keys());t.clear();for(const i of e)wt(t,i);wt(t,O),wt(t,Mn)},forEach(t,i){const s=L(this);vt(s,O);const n=this,o=s instanceof Map;s.forEach((s,r)=>{const a=e(s);t.call(i,a,o?r:a,n)})},keys(){const t=L(this);return t instanceof Map?(vt(t,Mn),t.keys()):(vt(t,O),An(t.keys(),e))},values(){const t=L(this);return vt(t,O),An(t.values(),e)},entries(){const t=L(this);return vt(t,O),An(t.entries(),i(t))},[Symbol.iterator](){const t=L(this);return vt(t,O),t instanceof Map?An(t.entries(),i(t)):An(t.values(),e)}}}(t);return{get(i,s,n){const o=_n(t,i,s,n);if(o!==fn)return o;if("size"===s)return vt(i,O),i.size;if(("string"==typeof s||s===Symbol.iterator)&&R(e,s)&&s in i)return e[s];const r=Reflect.get(i,s,i);return"function"==typeof r?r.bind(i):r}}}const En=new WeakSet,Tn=new WeakMap;const On=new class{startGc(t=1e4){}stopGc(){if(this._gci){try{clearInterval(this._gci)}catch{}this._gci=void 0}}constructor(){this.DisposeMapper=new et,this.arrayTriggerCache=new Map,this.ReactiveMap=()=>Tn,this.isReadonly=!1,this.superficial=!1,this.arrayMethods=new Cn(this),this.arrayHandler={get:gn(this),set:yn(this),has:wn(),deleteProperty:bn(),ownKeys:vn()},this.deepHandler={get:gn(this),set:yn(this),has:wn(),deleteProperty:bn(),ownKeys:vn()},this.collectionHandler=xn(this),En.add(this),this.startGc()}reactive(t){X(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)?j.get(Object.prototype.toString.call(i))??0:0);var i,s,n;if(0===e)return t;let o=Tn.get(t);if(o)return o;if(o=Tn.get(L(t)),o)return o;if(2===e){var r=new Proxy(t,this.collectionHandler);return Tn.set(t,r),r}if(Array.isArray(t)){r=new Proxy(t,this.arrayHandler);return Tn.set(t,r),r}r=new Proxy(t,this.deepHandler);return Tn.set(t,r),r}clearModel(t){null!=t&&null!=t&&(Object.keys(t).forEach(e=>{"object"==typeof t[e]&&(Tn.has(t[e])||Tn.has(L(t[e])))&&this.clearModel(t[e]),Tn.delete(L(t[e])),Tn.delete(t[e])}),Tn.delete(L(t)),Tn.delete(t))}track(t,e){vt(t,e)}trigger(t,e,i){wt(t,e)}ArrayTrigger(t,e,...i){this.trigger(t,e,i)}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(){V()}enableTracking(){z(!0)}resetTracking(){W()}dispose(){var t=!0;for(this.stopGc();1==t;)if(this.DisposeMapper.size>0){const t=this.DisposeMapper.pop();Tn.delete(t)}else t=!1;this.DisposeMapper.clear(),En.delete(this)}},Nn=[],Pn=()=>{try{const t=globalThis;return!!t.__MOTIF_DEV__&&(t.__MOTIF_STORE_REGISTRY__!==Nn&&(t.__MOTIF_STORE_REGISTRY__=Nn),!0)}catch{return!1}};function Ln(t){const e=On.reactive(t);try{if(Pn()){const i=t?.constructor?.name||"reactive";Nn.push({name:i,value:e,type:"reactive"}),Nn.length>200&&Nn.shift()}}catch{}return e}const Rn=new Map;class Xn{constructor(){this.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&&k("MJX410",[this._tokenName(t),i.join(", ")],{token:t}),e.deps&&!Array.isArray(e.deps)&&k("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 S("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=Rn.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)&&Rn.has(t)}getService(t){return this.getDescriptor(t)}buildServiceProvider(){return new Se(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 Rn.entries())this.descriptors.has(t)||this._add(t,{useClass:t,deps:e.deps,useValue:void 0,useFactory:void 0},e.lifetime||"transient")}}function In(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 Jn=null,jn=!1;function Fn(){if(u(),l())try{Jn||(Jn=document.createElement("div"),Jn.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(Jn),window.addEventListener("keydown",t=>{try{(t.ctrlKey||t.metaKey)&&"`"===t.key&&(t.preventDefault(),Jn&&(jn=!jn,Jn.style.display=jn?"block":"none"))}catch{}}),p(t=>{t.type}))}catch{}}class Hn{static{this.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 Bn=Symbol.for("RouterView.built");class zn extends As{constructor(t){super(t),this._navLock=Promise.resolve(),this.disposingChilds=!1,this.current=null,this._latestNavigateId=0,this.isBusy=!1}get __isRouterView(){return!0}get scopeId(){let t=this.parent,e=[];for(;t;)e.push(t.constructor?.name??""),t=t.parent;return e.join(">")}async navigate(t,e=!1){await nn(this,t,e)}async disposeTarget(t){await sn(t)}onBuilt(){try{Hn.register(this.props.name??"default",this.scopeId,this);let t=this.parent;for(;t;)t.motif.trigger(Bn,this),t=t.parent}catch{}}onDisposed(){try{Hn.unregister(this.props.name??"default",this.scopeId)}catch{}}}const Vn="motifjs:scroll",Wn=["wheel","touchstart","keydown","mousedown"];class $n{constructor(t={},e){this.positions=new Map,this.currentKey="",this.currentPath=null,this.visited=!1,this.restoring=!1,this.cancelFrame=null,this.disarmAbort=null,this.offs=[],this.locationAnchor=!0,this.options=t,this.viewport=e??(t.container?function(t){const e=Un(),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.scrollTo({top:t,behavior:"instant"})}catch{try{s.scrollTop=t}catch{}}else e.scrollTo(t)},scrollToAnchor:(t,i)=>e.scrollToAnchor(t,i)}}(t.container):Un()),this.load();try{"undefined"!=typeof history&&"scrollRestoration"in history&&(history.scrollRestoration="manual")}catch{}"undefined"!=typeof window&&(this.offs.push(Kn(window,"pagehide",()=>this.persistNow())),this.offs.push(Kn(document,"visibilitychange",()=>{"hidden"===document.visibilityState&&this.persistNow()})))}leaving(){this.cancelRestore(),this.visited&&(this.remember(this.currentKey,this.viewport.scrollTop()),this.persist())}arrived(t,e){this.visited=!0;const{path:i,hash:s}=qn(t),n=!!s&&i===this.currentPath&&("push"===e||"replace"===e||"traverse"===e);this.currentPath=i,this.currentKey=this.keyOf(i),this.restore(this.currentKey,!1===this.options.anchor?"":s||(this.locationAnchor?function(){try{const t=location?.hash??"";return t.length>1?Gn(t.slice(1)):""}catch{return""}}():""),n)}saved(t){return this.positions.get(this.keyOf(qn(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,i){this.cancelRestore();const s=this.positions.get(t)??0;if(!e&&s<=0)return void(!1!==this.options.top&&this.viewport.scrollTo(0));this.restoring=!0;const n=this.options.settleMs??1200,o=Date.now(),r=()=>{this.cancelFrame=null;if((e?this.viewport.scrollToAnchor(e,i):this.reached(s))||Date.now()-o>=n)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)}(r)};r()}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=Wn.map(e=>Kn(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(Vn,JSON.stringify([...this.positions]))}catch{}}load(){const t=this.storage;if(t)try{const e=t.getItem(Vn);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 Un(){return{scrollTop:()=>{try{return window.scrollY||document.documentElement?.scrollTop||0}catch{return 0}},scrollTo:t=>{try{window.scrollTo({top:t,behavior:"instant"})}catch{try{window.scrollTo(0,t)}catch{}}},scrollToAnchor:(t,e)=>{try{const i=document.getElementById(t);if(!i)return!1;if(e)i.scrollIntoView();else try{i.scrollIntoView({behavior:"instant"})}catch{i.scrollIntoView()}return!0}catch{return!1}}}}function qn(t){const e=t.indexOf("#");return e<0?{path:t,hash:""}:{path:t.slice(0,e)||"/",hash:Gn(t.slice(e+1))}}function Gn(t){try{return decodeURIComponent(t)}catch{return t}}function Kn(t,e,i,s){try{return t.addEventListener(e,i,s),()=>{try{t.removeEventListener(e,i,s)}catch{}}}catch{return()=>{}}}const Yn="motifjs:stack",Qn=30,Zn=t=>!!t&&1===t.nodeType&&!!t.style;function to(t,e){const i=t?.element;if(t&&!t.isDisposed&&Zn(i)){try{i.setAttribute("data-nav-direction",e)}catch{}t.motif.options.transition._markedDirection=!0}}function eo(t){const e=t?.motif?.options?.transition;if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function io(t){return t.getAttribute("style")}function so(t,e){try{t.setAttribute("style",e??""),null===e&&t.removeAttribute("style")}catch{}}function no(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 oo(t){for(const[e,i,s]of t)try{e.scrollTop=i,e.scrollLeft=s}catch{}}function ro(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function ao(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 co(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 lo{constructor(t){this.session=null,this.entries=new Map,this.uris=new Map,this.loaded=null,this.current=null,this.currentTop=null,this.offs=[],this.gesture=null,this.gestureCommitted=!1,this.awaitingGestureResult=!1,this.disposed=!1;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:Zn(c)?no(c):[]};if(this.retainAttached&&Zn(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(Zn(e)){t.saved={style:io(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{Cs(t.top)}catch{}}}reveal(t){const e=t.top.element;if(t.hidden&&t.saved&&Zn(e)){so(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){oo(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(!(Zn(s)&&Zn(n)&&s.isConnected&&n.isConnected))return;if(ro())return;const o="back"===t,r=io(s),a=io(n),c=[];try{if(co(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([ao(n,[{transform:"translateX(0)"},{transform:"translateX(100%)"}],t,c),ao(s,[{transform:"translateX(-30%)"},{transform:"translateX(0)"}],t,c)]):await Promise.all([ao(s,[{transform:"translateX(100%)"},{transform:"translateX(0)"}],t,c),ao(n,[{transform:"translateX(0)"},{transform:"translateX(-30%)"}],t,c)])}}catch(t){C("MJX308",t)}finally{for(const t of c)try{t.cancel()}catch{}so(s,r),so(n,a)}}async disposeEntry(t){const e=t.top;if(e&&!e.isDisposed)try{await sn(e,{deep:!0,skipLeaveTransition:!0})}catch(t){C("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(Yn);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(Yn,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(!Zn(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=io(t.top);const e=this.current,i=e?this.entries.get(e.index-1)??null:null;if(i&&i.attached&&Zn(i.top.element)&&i.top.element.isConnected){const e=i.top.element;t.under=i,t.underSaved=io(e),i.saved&&so(e,i.saved.style),co(e,t.top,!1),e.style.transform="translateX(-30%)",oo(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(-${Qn*(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=ro()?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([ao(s,[{transform:r},{transform:"translateX(100%)"}],o,i),n?ao(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([ao(s,[{transform:r},{transform:"translateX(0)"}],o,i),n?ao(n,[{transform:a},{transform:"translateX(-30%)"}],o,i):Promise.resolve()]);for(const t of i)try{t.cancel()}catch{}so(s,t.topSaved),n&&t.under&&so(n,t.underSaved),this.gesture===t&&(this.gesture=null)}}}class ho{constructor(t){this.source=t,this.currentColumn=0,this.tokens=[],this.parameters={},this.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},this.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")}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}}function uo(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 po(t,e){const i=t.chain.length-e.chain.length;if(0!==i)return i;const s=uo(t.fullPath),n=uo(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 fo{constructor(t){this.routes=t,this.records=[],this.routesMap=new Map,this.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 ho(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)},this.build()}build(){this.records=[],this.routesMap.clear();for(const t of this.routes)this.walk([],"",t);this.records.sort(po)}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 mo{constructor(){this.stack=null,this._revealed=new Set,this._previousPath=null,this._previousInstances=[],this.controlCache=new Map,this._navVersion=0,this._pendingActivate=new Set,this.pendingMount=new WeakMap,this.pendingListeners=new WeakMap}register(t,e,i){this.root=t,this.application=e,this.routingModule=i}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){C("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}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){C("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){C("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)eo(t);for(const t of f)d.pages?to(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&&tn(o.top,"enter")&&o.top.motif.options.transition.enterTransition(()=>{});for(const t of f)t.isBuilt&&!tn(t,"enter")&&eo(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){C("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){C("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||we(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),en(h),n.pages&&tn(h,"leave")&&(to(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()}})),eo(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){en(i);try{i.parent?.controls.silentDetach(i)}catch{}this.controlCache.has(s)||this.controlCache.set(s,i),Cs(i)}else s&&this.controlCache.get(s)===i&&this.controlCache.delete(s),p&&t===c?(o.top=i,o.disposeAfter.push(i)):n.pages?(to(i,n.direction),await i.dispose()):await i.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){C("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){en(e);try{e.parent?.controls.silentDetach(e)}catch{}this.controlCache.has(n)||this.controlCache.set(n,e),Cs(e)}else this.controlCache.get(n)===e&&this.controlCache.delete(n),await e.dispose()}catch(t){C("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=le;le=t??null;try{return e()}finally{le=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=Ls(await n)),(s=this._construct(e,i,()=>this._resolveFrom(e,n)))||("function"==typeof n?this.parseControl(this._construct(e,i,()=>Xs(n,this.application)),e,i):Xs(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??Co.main?.provider}catch{return}}async createInstance(t,e,i){return await this._instanceCreator(t,e,i)}async _instanceCreator(t,e,i){let s=await this.parseControl(t,e,i);return Rs(s),s}async activator(t){}static{this.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)&&Ss(o);const h=e[n]?.onShow;h&&!l&&a.current===o&&s===this._navVersion&&M(()=>h(o),"MJX306","onShow"),i=o,n++}}_waitForOutlet(t,e,i,n,o){const r=this.pendingListeners.get(t);if(r){try{r()}catch{}this.pendingListeners.delete(t)}let a,c=!1;const l=async(s,o)=>{c||(h(),n===this._navVersion&&await this.mountChain(e,i,t,n))},h=()=>{if(!c){c=!0,this.pendingListeners.delete(t);try{t.motif?.off?.(Bn,l)}catch{}if(void 0!==a){try{clearTimeout(a)}catch{}a=void 0}}};t.motif.on(Bn,l),this.pendingListeners.set(t,h),s.isDevelopment()&&(a=setTimeout(()=>{c||n!==this._navVersion||k("MJX301",[o,mo.OUTLET_WARN_MS])},mo.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=Hn.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}}const _o=t=>t.split("#")[0].split("?")[0],go=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36);class yo{static{this.MAX_REDIRECTS=10}constructor(t,e){this.routesMap=new Map,this._suppressBeforeEachOnce=!1,this._suppressMiddlewaresOnce=!1,this._scroll=null,this._stack=null,this._windowNavListener=null,this._historyStamp=null,this._pendingTraversal=null,this._currentUri="___startup___",this._previousRoute=null,this._fallbackRoutes={},this._navHandler=null,this._routerOptions=t,this.routeCollection=new fo(t.RouteItems),this.routingEngine=new mo,this.application=e,this._installLinkInterceptor();const i=t.scrollMemory;i&&(this._scroll=new $n(!0===i?{}:i),this._scroll.locationAnchor="history"===this._addressMode()),t.stack&&"shell"!==t.mode&&(this._stack=new lo(t.stack),this.routingEngine.stack=this._stack)}getHooks(){return this._routerOptions.hooks}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||"")+(t?.location?.hash||"")}catch{return"/"}}static{this.HISTORY_STAMP_KEY="__motifHistory"}_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[yo.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?{[yo.HISTORY_STAMP_KEY]:e}:yo._isPlainObject(t)?{...t,[yo.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(!yo._isPlainObject(t))return t;const e=yo.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:go()}}_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=yo._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:go()};this._stampCurrentEntry(e),this._historyStamp=e}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{}}get currentUri(){return this._currentUri}async navigate(t,e){const i=this._pendingTraversal;return this._pendingTraversal=null,await(n=async()=>{try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-start",{uri:t})}catch{}const s=this._suppressBeforeEachOnce;s&&(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>yo.MAX_REDIRECTS||i.some(t=>_o(t)===_o(e))){u=[...i,e].join(" → "),l=S("MJX303",u);break}i.push(e),t=e,h=this.resolve(t)}if(l)k("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":i?i.direction:o.replace?"replace":"push",f=i?i.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){C("MJX306",t,"onLeave")}}let g=!0;if(s||(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:this.chainOf(t),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 w=i?i.from:this._historyStamp;try{const t=!!c&&this._addressShows(c);this._applyUrl(v,t?{...o,replace:!0}:o)}catch{}const b=this._stack?{direction:p,from:w,to:this._historyStamp,uri:v}:void 0;try{await this.routingEngine.execute(h,b,y(h))}catch(e){C("MJX304",e),h=this._buildFallbackResult(t,"error",{path:t,error:e});try{await this.routingEngine.execute(h,b,y(h))}catch(t){C("MJX305",t)}}this._stack&&this.application._routerState.touch(),o.scroll?this._handleScrollBehavior(o.scroll):this._scroll?.arrived(this._uriWithHash(v,t),p),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",s.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 S("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 S("MJX302",String(t))}else e=t;await this.routingEngine.evict(e)}_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?yo._builtinNotFound:yo._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{this._builtinNotFound=()=>new As("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild($s("h2",{},"404 - Not Found")),t.element.appendChild($s("p",{},"The requested page was not found."))}})}static{this._builtinError=()=>new As("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild($s("h2",{},"Error")),t.element.appendChild($s("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}}chainOf(t){return t.chain.map(e=>this.routingEngine.generatePathString(e.path,t.params)||"")}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)=>po(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}_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){const s=(i.location.pathname||"/")+(i.location.search||"")+(i.location.hash||"");let n=t;try{const e=new URL(t,i.location.href);n=e.pathname+e.search+e.hash}catch{}if(s!==n)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;let t=Promise.resolve();try{try{t=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{}return t}}class vo{constructor(){this.version=new se(0),this._current=null,this._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 wo=null,bo=!1;class So{constructor(){if(this.services=new Xn,wo&&"disposing"!==wo.state||bo)throw new w("MJX405",b("MJX405"),{cause:wo});bo=!0}build(){this.services.autoRegisterInjectables();const t=this.services.buildServiceProvider();this.services.addSingleton(Se,t);var e=new Co(t);return this.services.addSingleton(Co,e),wo=e,e}rebuild(){return wo?(wo.provider.dispose(),wo.provider=this.services.buildServiceProvider(),wo):this.build()}}class Co{static get main(){return wo}constructor(t){this.provider=t,this._state="initializing",this._middlewares=[],this._beforeEachGuards=[],this._routerState=new vo,this.router=function(t,e){const i=()=>{const t=e();if(!t)throw S("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=>{const e=i(),s=e.resolve(t);return{chain:e.chainOf(s),result:s}},href:(t,e)=>i().href(t,e)}}(this._routerState,()=>this.urlRoutingModule),this.events=new Map,this._routerConfig=null,this._routerRoot=null,this._startedRouter=null,this._lifecycleOff=null,this._isDevelopment=!1,this._enableErrorLogging=!0}static{this._disposingCount=0}get state(){return this._state}static CreateBuilder(){return new So}getAppShell(){return this.appShell}run(t,e){let i;if(r(()=>{On.startGc()},"Application.run.engine.startGc"),"string"==typeof t){if(i=document.querySelector(t),!i)throw S("MJX406",t)}else i=t;let s=e;this._state="running";const n=new As(i);this.appShell=n,r(()=>{n._keepElementOnDispose=!0,n.application=this,n.provider=this.provider},"Application.run.setupAppShell"),s?(s.parent=n,n.controls.add(s)):(s=n,s.controls.add(new zn({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(){if(this._disposing)return this._disposing;let t;this._state="disposing",Co._disposingCount++,bo=!1,r(()=>{this._removeLifecycleListeners()},"Application.dispose.lifecycle"),r(()=>{t=this.urlRoutingModule?.dispose?.()},"Application.dispose.router"),r(()=>{On.stopGc()},"Application.dispose.gcStop"),r(()=>{try{const t=window;t&&t.history&&"function"==typeof t.history.replaceState&&t.history.replaceState({},"","/")}catch{}},"Application.dispose.resetUrl"),De.mode="concurrent";const e=this.appShell;return this._disposing=(async()=>{try{await t}catch(t){C("MJX307",t)}if(e&&!e.isDisposed)try{await e.dispose()}catch(t){C("MJX307",t)}try{await this.provider.dispose()}catch{}wo===this&&(wo=null),this._state="disposed",Co._disposingCount--})()}useTransitions(t){return Re(t?.mode)&&(De.mode=t.mode),this}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 C("MJX306",t,"guard"),!1}if(!s)return!1;if(!1===e)return!1;if("string"==typeof e)return e}return!0}useRouter(t){let e,i,s,n,o,a;return Array.isArray(t)?e=t:(e=t.routes,i=t.mode,s=t.fallbacks,n=t.hooks,o=t.scrollMemory,a=t.stack),this.urlRoutingModule&&this.urlRoutingModule.dispose(),this._routerConfig={mode:i,fallbacks:s,middlewareCollections:()=>this._middlewares,RouteItems:e,hooks:n,scrollMemory:o,stack:a},this.urlRoutingModule=new yo(this._routerConfig,this),this._routerState.reset(),r(()=>{u(),Fn(),g(e),(this._isDevelopment||!0===globalThis.__MOTIF_DEV__||d())&&function(t){const e=new Map,i=new Map;function s(t,n,o){const r=t.path??"",a=String(r),c=""===n?a:In(n,a),l=o>0&&"/"===a.trim(),h=""===a.trim();h&&k("MJX310",[n||"/"],{parentPath:n,path:a}),o>0&&a.length>0&&"/"!==a&&!a.startsWith("/")&&!a.startsWith("*")&&k("MJX311",[a,n||"/"],{parentPath:n,path:a}),n&&c===n&&(l||h||k("MJX312",[c],{parentPath:n,childPath:a}));const u=(e.get(c)||0)+1;e.set(c,u),u>1&&(l||h||k("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("*")&&k("MJX314",[e,n||"/"],{parentPath:n,alias:e});const s=""===n?e:In(n,e);s===c&&k("MJX315",[s],{full:c,alias:e});const r=(i.get(s)||0)+1;i.set(s,r),r>1&&k("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 yo(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 S("MJX309")}async navigateByName(t,e,i){if(this.urlRoutingModule)return await this.urlRoutingModule.navigateByName(t,e,i);throw S("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=>{M(()=>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}}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()}get isDevelopmentModeEnabled(){return this._isDevelopment}useReactiveMonitor(t={}){return r(()=>{yt(t)},"Application.useReactiveMonitor.core"),this}useDevelopment(t=!0){return this._isDevelopment=t,s.setDevelopmentMode(t),r(()=>{globalThis.__MOTIF_DEV__=t},"Application.useDevelopment.flag"),r(()=>{var e;e=t,a.enabled=e||l(),h(a.enabled)},"Application.useDevelopment.devtools"),t&&function(){for(const t of Array.from(rt))at(t)}(),this}useLogging(t=!0){return this._enableErrorLogging=t,function(t){s.setConsoleLogging(t)}(t),this}}function Mo(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function ko(t){return t&&"TimeoutError"===t.name}class Do extends w{constructor(){super("MJX605",b("MJX605")),this.name="TimeoutError"}}function Ao(t){return new Promise(e=>setTimeout(e,t))}function xo(t,e=.1){const i=(2*Math.random()-1)*e*t;return Math.max(0,Math.floor(t+i))}class Eo{}class To extends Eo{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&&!ko(t)),this.onRetry=t.onRetry}calcDelay(t){if("none"===this.backoff)return 0;if("fixed"===this.backoff)return xo(this.delayMs,this.jitter);return xo(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 Ao(n)}throw i}}class Oo extends Eo{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 Do),this.timeoutMs)});try{return await Promise.race([s,n])}finally{clearTimeout(i)}}}class No extends Eo{constructor(t={}){super(),this.state="CLOSED",this.failureCount=0,this.successCount=0,this.nextAttemptTime=0,this.failureThreshold=t.failureThreshold??5,this.successThreshold=t.successThreshold??2,this.durationOfBreakMs=t.durationOfBreakMs??6e4,this.shouldHandle=t.shouldHandle??(t=>!!t&&!ko(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 S("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 Po extends Eo{constructor(t={}){super(),this.active=0,this.queue=[],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 S("MJX603");await new Promise(t=>{this.queue.push(t)})}this.active++;try{return await Promise.resolve(t(e))}finally{this.active--,this.dequeue()}}}class Lo extends Eo{constructor(t={}){super(),this.tokensPerInterval=t.tokensPerInterval??1,this.intervalMs=t.intervalMs??1e3,this.capacity=t.capacity??this.tokensPerInterval,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 S("MJX604");return this.tokens-=1,Promise.resolve(t(e))}}class Ro extends Eo{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 Xo extends Eo{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 Io=t=>new To(t),Jo=t=>new Oo(t),jo=t=>new No(t),Fo=t=>new Po(t),Ho=t=>new Lo(t),Bo=t=>new Ro(t),zo=(...t)=>new Xo(...t);class Vo{constructor(){this.resiliences=[],this.retry=t=>(this.resiliences.push(Io(t)),this),this.timeout=t=>(this.resiliences.push(Jo(t)),this),this.circuitBreaker=t=>(this.resiliences.push(jo(t)),this),this.bulkhead=t=>(this.resiliences.push(Fo(t)),this),this.rateLimiter=t=>(this.resiliences.push(Ho(t)),this),this.fallback=t=>(this.resiliences.push(Bo(t)),this)}static get create(){return new Vo}async execute(t,e){return zo(...this.resiliences).execute(t,e)}}t.Application=Co,t.ApplicationBuilder=So,t.Component=As,t.ComponentBase=ji,t.ComponentMotif=te,t.Computed=ne,t.ContentBlock=class extends As{constructor(t){super(t);const e=t=>{this.motif.trigger("controladded",{control:t});var e=an.get(this.props.target);e&&(t.motif.options.ownerContentBlock=this,e.controls.add(t))};this.controls.onAdd=e,this.controls.onAddBeforeBuild=e,this.childs&&this.controls.add(...this.childs)}onConfigured(t,e){var i=an.get(this.props.target);i?(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),i.controls.add(...this.controls.items)):this.context.on(cn,()=>{var t=an.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=an.get(this.props.target);if(i)for(const t of[...i.controls.items])t.motif.options.ownerContentBlock===this&&(i.controls.remove(t),k("MJX109",[],t))}ondisposing(t){}},t.ContentBody=class extends As{constructor(t){super(t),an.set(this.props.name,this),this.context.fire(cn)}ondisposing(t){an.get(this.props.name)===this&&an.delete(this.props.name)}},t.ControlCollection=Us,t.Dictionary=class{constructor(){this.__values=new G}Add(t,e){var i=new q;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]}removeIndex(t){return this.__values.removeIndex(t)}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)}},t.Disposable=E,t.DisposableStore=A,t.Emitter=Jt,t.ErrorHandler=i,t.FNComponent=function(t){return e=>{var i=Js({...e});return i.controls.add(t(e)),i}},t.FragmentNode=Fs,t.Frame=on,t.FromService=function(t){try{return Co.main.provider.get(t)}catch(e){return k("MJX414",[Mo(t),String(e?.message??e)],{token:t,error:e}),null}},t.Injectable=function(t){return e=>{Rn.set(e,{lifetime:t?.lifetime??"transient",deps:t?.deps})}},t.Lazy=Zs,t.LazyComputed=oe,t.LinkedList=et,t.List=G,t.MotifError=w,t.NameValuePair=q,t.Query=st,t.Resilience=Vo,t.RouterLink=class extends As{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=Co.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}}},t.RouterView=zn,t.ServiceCollection=Xn,t.ServiceProvider=Se,t.Signal=se,t.Transport=class extends As{constructor(t){super(t),this.mode=t.mode||"replace"}initializeComponent(t){un.registerSlot(this.props.name,this),this.onDisposing=()=>{[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()}),un.unregisterSlot(this.props.name,this)}}clearSlot(){[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()})}},t.TransportTo=class extends As{constructor(t){super("div",t),this._transported=[],this._countedLive=!1,this._handleSlotChange=t=>{if(t.name===this.props.name){const e=t.slot;"merge"!==e.mode&&e.clearSlot?.();const i=[...this.childs||[],...this.controls.items];dn.transportMany(i,e),this._rememberTransported(i)}},this._clearChildrenFromSlot=t=>{(this.childs||[]).forEach(e=>{t.controls.remove(e),e.dispose()}),(this.controls.items||[]).forEach(e=>{t.controls.remove(e),e.dispose()})},Ce.live++,this._countedLive=!0}_rememberTransported(t){const e=this._transported.filter(t=>!t.isDisposed);for(const i of t)e.includes(i)||e.push(i);this._transported=e}initializeComponent(t){let e=un.getSlot(this.props.name);if(e){"merge"!==e.mode&&e.clearSlot?.();const t=[...this.childs||[],...this.controls.items];dn.transportMany(t,e),this._rememberTransported(t)}this._slotRegisteredListener=Co.main.on(ln,this._handleSlotChange),this._slotUnregisteredListener=Co.main.on(hn,t=>{t.name===this.props.name&&this._clearChildrenFromSlot(t.slot)}),this._onAddRef=t=>{this.motif.trigger("controladded",{control:t});const e=un.getSlot(this.props.name);e&&(dn.transport(t,e),this._rememberTransported([t]))},this._onRemoveRef=t=>{const e=un.getSlot(this.props.name);e&&e.controls.remove(t),this._transported=this._transported.filter(e=>e!==t)},this.controls.onAdd=this._onAddRef,this.controls.onRemove=this._onRemoveRef}onDisposing(t,e){this._countedLive&&(this._countedLive=!1,Ce.live--);const i=un.getSlot(this.props.name);for(const t of this._transported||[])i?.controls.remove(t),t.dispose();this._slotRegisteredListener&&(Co.main.off(ln,this._handleSlotChange),this._slotRegisteredListener=void 0),this._slotUnregisteredListener&&(Co.main.off(hn,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=[]}},t.Transporter=dn,t.Virtualization=class extends As{constructor(t){super("div",t),this._cache=new Map,this._view=[],this._occurrence=[],this._occurrenceKeys=new WeakMap,this._isLoadingMore=!1,this._emptyRendered=!1,this._renderPending=!1,this.contentWrapper=new As,this._initialLoadStarted=!1,this._offsets=null,this._observedHeight=-1,this._loadSeq=0,this._reloadScheduled=!1,this._reloadTimes=[],this._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()},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()}_makeView(){this._topSpacer=new As("div"),this._topSpacer.element.style.cssText="height: 0px;",this._topSpacer.class.add("motif-virtualization-top-spacer"),this._bottomSpacer=new As("div"),this._bottomSpacer.element.style.cssText="height: 0px;",this._bottomSpacer.class.add("motif-virtualization-bottom-spacer"),this._virtualContent=new As(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))}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()}_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}_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 xt(i);let s;this._stopDataWatch();let n=!0;return this._dataWatchStop=Mt(()=>{if(n){n=!1;try{this.props.watch?.()}catch(t){C("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 k("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)}}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,C("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 ji?o:new As(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}Cs(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 C("MJX207",t);else C("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}}},t.asyncTracking=Dt,t.clearModel=function(t){return On.clearModel(t)},t.configureReactivityLeakMonitor=yt,t.createComputed=function(t){const e=new ne(t);try{if(Pn()){const t=`computed_${Nn.length}`;Nn.push({name:t,value:e.value,type:"computed"}),Nn.length>200&&Nn.shift()}}catch{}return e},t.createLazyComputed=function(t){const e=new oe(t);try{if(Pn()){const t=`lazyComputed_${Nn.length}`;Nn.push({name:t,value:void 0,type:"computed"}),Nn.length>200&&Nn.shift()}}catch{}return e},t.createSignal=function(t){const e=new se(t);try{if(Pn()){const t=`signal_${Nn.length}`;Nn.push({name:t,value:e.value,type:"signal"}),Nn.length>200&&Nn.shift()}}catch{}return e},t.decorate=function(t,e){return i=>t.execute(e,i)},t.deepClone=function(t){return On.deepClone(t)},t.disposableCore=D,t.dom=zs,t.effect=Mt,t.errorHandler=s,t.inject=function(t){if(!re)throw S("MJX409",function(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}(t));return re(t)},t.motifCompiled=at,t.motifComponent=Ns,t.motifFragment=Js,t.preProcessing=function(t){rn.add(t),rn.forEach(t=>{t()})},t.reactive=Ln,t.read=function(t){return"function"==typeof t?t():t},t.safeCall=n,t.safeCallAsync=o,t.safeCallSilent=r,t.setUnexpectedErrorHandler=function(t){s.setUnexpectedErrorHandler(t)},t.toDisposable=K,t.toGetter=function(t){return"function"==typeof t?t:()=>t},t.untracked=xt,t.useApplication=function(){return{application:Co.main,services:Co.main.provider,router:Co.main.router,attach(...t){Co.main&&Co.main.getAppShell().controls.add(...t)}}},t.useModel=function(t){const e=On.reactive(t);try{if(Pn()){const i=t?.constructor?.name||"useModel";Nn.push({name:i,value:e,type:"reactive"}),Nn.length>200&&Nn.shift()}}catch{}return e},t.useNavigation=function(){return Co.main.router}});
2
2
  //# sourceMappingURL=index.umd.min.js.map