native-document 1.0.100 → 1.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var NativeDocument=function(e){"use strict";let t={};t={log(){},warn(){},error(){},disable(){}};var n=t;class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const s={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=s.mounted.get(e);if(t&&(t.inDom=!0,t.mounted))if(Array.isArray(t.mounted))for(const n of t.mounted)n(e);else t.mounted(e)},executeUnmountedCallback(e){const t=s.unmounted.get(e);if(!t)return;if(t.inDom=!1,!t.unmounted)return;let n=!1;if(Array.isArray(t.unmounted))for(const r of t.unmounted)!0===r(e)&&(n=!0);else n=!0===t.unmounted(e);n&&(t.disconnect(),e.nd?.remove())},checkMutation:function(e){for(const t of e){if(s.mountedSupposedSize>0)for(const e of t.addedNodes){if(s.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)s.executeMountedCallback(e)}if(s.unmountedSupposedSize>0)for(const e of t.removedNodes){if(s.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)s.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(s.mounted.delete(e),s.mountedSupposedSize--),r&&(s.unmounted.delete(e),s.unmountedSupposedSize--),o=null}};const i=(e,t)=>{o[e]?Array.isArray(o[e])?o[e].push(t):o[e]=[o[e],t]:o[e]=t};return{disconnect:()=>o?.disconnect(),mounted:t=>{i("mounted",t),s.mounted.set(e,o),n||(s.mountedSupposedSize++,n=!0)},unmounted:t=>{i("unmounted",t),s.unmounted.set(e,o),r||(s.unmountedSupposedSize++,r=!0)},off:(e,t)=>{((e,t)=>{if(o?.[e]){if(Array.isArray(o[e])){const n=o[e].indexOf(t);return n>-1&&o[e].splice(n,1),1===o[e].length&&(o[e]=o[e][0]),void(0===o[e].length&&(o[e]=null))}o[e]=null}})(e,t)}}}};s.observer=new MutationObserver(s.checkMutation),s.observer.observe(document.body,{childList:!0,subtree:!0});function i(e){this.$element=e,this.$observer=null}i.prototype.__$isNDElement=!0,i.prototype.valueOf=function(){return this.$element},i.prototype.ref=function(e,t){return e[t]=this.$element,this},i.prototype.refSelf=function(e,t){return e[t]=this,this},i.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},i.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},i.prototype.lifecycle=function(e){return this.$observer=this.$observer||s.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},i.prototype.mounted=function(e){return this.lifecycle({mounted:e})},i.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},i.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!s.beforeUnmount.has(n)){s.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=s.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return s.beforeUnmount.get(n).set(e,t),this},i.prototype.htmlElement=function(){return this.$element},i.prototype.node=i.prototype.htmlElement,i.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},i.prototype.openShadow=function(e=null){return this.shadow("open",e)},i.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},i.prototype.attach=function(e,t){return t.$hydrate(this.$element,e),this.$element},i.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},i.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!Object.hasOwn(e,o))continue;const s=e[o];if("function"==typeof s){if(t.has(o))throw n.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);i.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),i.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i};const a=1,u=3,l=8,c=11,h={isObservable:e=>e?.__$isObservable,isTemplateBinding:e=>e?.__$isTemplateBinding,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isObservableOrProxy:e=>h.isObservable(e)||h.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&(e.nodeType===a||e.nodeType===u||e.nodeType===c||e.nodeType===l),isFragment:e=>e?.nodeType===c,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof i,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(h.isObject(e)&&Object.values(e).some(e=>h.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new r("Event callback must be a function")}};function p(e,t=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(s),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild,r.nativeAppend=r.append;const i=function(e,n,i){const a=h.isElement(n)?n:j.getChild(n);e!==r?(e=>t||e.firstChild===o&&e.lastChild===s)(e)&&i===s?e.append(a,i):e.insertBefore(a,i):e.nativeInsertBefore(a,i)};return r.appendElement=function(e,t=null){const n=o.parentNode,i=t||s;n!==r?n?.insertBefore(e,i):n.nativeInsertBefore(e,i)},r.appendChild=function(e,t=null){const r=s.parentNode;r?i(r,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t.remove()),t=e;await Promise.all(n)},r.remove=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[],i=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t),i.push(t.remove()),t=e;await Promise.all(i),r.nativeAppend(...n)},r.removeWithAnchors=async function(){await r.removeChildren(),o.remove(),s.remove()},r.replaceContent=async function(e){const t=h.isElement(e)?e:j.getChild(e),n=s.parentNode;n&&(await r.removeChildren(),n.insertBefore(t,s))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return s},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}DocumentFragment.prototype.setAttribute=()=>{};const d=new Set(["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"]),f=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let r=0;for(const[e,n]of t)n.deref()||(t.delete(e),r++);r>0&&n.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}(),m=function(e,t){this.$target=t,this.$observer=e};m.prototype.__$isObservableWhen=!0,m.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},m.prototype.val=function(){return this.$observer.$currentValue===this.$target},m.prototype.isMatch=m.prototype.val,m.prototype.isActive=m.prototype.val;const b=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},y=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},g=(e,t)=>{try{if(void 0!==window.structuredClone)return window.structuredClone(e)}catch(e){}if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>g(e));if(h.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=g(e[t]));return n},v={getJson(e){let t=localStorage.getItem(e);try{return JSON.parse(t)}catch(t){throw new r("invalid_json:"+e)}},getNumber(e){return Number(this.get(e))},getBool(e){const t=this.get(e);return"true"===t||"1"===t},setJson(e,t){localStorage.setItem(e,JSON.stringify(t))},setBool(e,t){localStorage.setItem(e,t?"true":"false")},get:(e,t=null)=>localStorage.getItem(e)||t,set:(e,t)=>localStorage.setItem(e,t),remove(e){localStorage.removeItem(e)},has:e=>null!=localStorage.getItem(e)},w=(e,t)=>{if(!v.has(e))return t;switch(typeof t){case"object":return v.getJson(e)??t;case"boolean":return v.getBool(e)??t;case"number":return v.getNumber(e)??t;default:return v.get(e,t)??t}},$=e=>{switch(typeof e){case"object":return v.setJson;case"boolean":return v.setBool;default:return v.set}},S=function(){const e=new Map,t=new Map,o=(t,o)=>{const s=e.get(o);if(!s)throw n.error("Store",`Store.${t}('${o}') : store not found. Did you call Store.create('${o}') first?`),new r(`Store.${t}('${o}') : store not found.`);return s},s=(e,t={})=>Array.isArray(e)?N.array(e,t):"object"==typeof e?N.object(e,t):N(e,t);return new Proxy({create(t,o){if(e.has(t))throw n.warn("Store",`Store.create('${t}') : a store with this name already exists. Use Store.get('${t}') to retrieve it.`),new r(`Store.create('${t}') : a store with this name already exists.`);const i=s(o);return e.set(t,{observer:i,subscribers:new Set,resettable:!1,composed:!1}),i},createResettable(t,o){if(e.has(t))throw n.warn("Store",`Store.createResettable('${t}') : a store with this name already exists.`),new r(`Store.createResettable('${t}') : a store with this name already exists.`);const i=s(o,{reset:!0});return e.set(t,{observer:i,subscribers:new Set,resettable:!0,composed:!1}),i},createComposed(t,o,s){if(e.has(t))throw n.warn("Store",`Store.createComposed('${t}') : a store with this name already exists.`),new r(`Store.createComposed('${t}') : a store with this name already exists.`);if("function"!=typeof o)throw new r(`Store.createComposed('${t}') : computation must be a function.`);if(!Array.isArray(s)||0===s.length)throw new r(`Store.createComposed('${t}') : dependencies must be a non-empty array of store names.`);const i=s.map(o=>{if("string"!=typeof o)return o;const s=e.get(o);if(!s)throw n.error("Store",`Store.createComposed('${t}') : dependency '${o}' not found. Create it first.`),new r(`Store.createComposed('${t}') : dependency store '${o}' not found.`);return s.observer}),a=N.computed(o,i);return e.set(t,{observer:a,subscribers:new Set,resettable:!1,composed:!0}),a},has:t=>e.has(t),reset(e){const t=o("reset",e);if(t.composed)throw n.error("Store",`Store.reset('${e}') : composed stores cannot be reset. Their value is derived from dependencies.`),new r(`Store.reset('${e}') : composed stores cannot be reset.`);if(!t.resettable)throw n.error("Store",`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`),new r(`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`);t.observer.reset()},use(e){const t=o("use",e);if(t.composed)throw n.error("Store",`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`),new r(`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`);const{observer:i,subscribers:a}=t,u=s(i.val()),l=e=>u.set(e),c=e=>i.set(e);return i.subscribe(l),u.subscribe(c),u.destroy=()=>{i.unsubscribe(l),u.unsubscribe(c),a.delete(u),u.cleanup()},u.dispose=u.destroy,a.add(u),u},follow(e){const{observer:t,subscribers:i}=o("follow",e),a=s(t.val()),u=e=>a.set(e);return t.subscribe(u),((e,t,o)=>{const s=e=>()=>{throw n.error("Store",`Store.${o}('${t}') is read-only. '${e}()' is not allowed.`),new r(`Store.${o}('${t}') is read-only.`)};e.set=s("set"),e.toggle=s("toggle"),e.reset=s("reset")})(a,e,"follow"),a.destroy=()=>{t.unsubscribe(u),i.delete(a),a.cleanup()},a.dispose=a.destroy,i.add(a),a},get(t){const r=e.get(t);return r?r.observer:(n.warn("Store",`Store.get('${t}') : store not found.`),null)},getWithSubscribers:t=>e.get(t)??null,delete(t){const r=e.get(t);r?(r.subscribers.forEach(e=>e.destroy()),r.subscribers.clear(),r.observer.cleanup(),e.delete(t)):n.warn("Store",`Store.delete('${t}') : store not found, nothing to delete.`)},group(e,t){"function"==typeof e&&(t=e,e="anonymous");const n=S();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,w(n,t)),o=$(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,w(n,t)),o=$(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{v.remove(n),s()},r}},{get(e,n){if("symbol"==typeof n||n.startsWith("$")||n in e)return e[n];if(e.has(n)){if(t.has(n))return t.get(n);const r=e.follow(n);return t.set(n,r),r}},set(e,t,o){throw n.error("Store",`Forbidden: You cannot overwrite the store key '${String(t)}'. Use .use('${String(t)}').set(value) instead.`),new r("Store structure is immutable. Use .set() on the observable.")},deleteProperty(e,t){throw new r("Store keys cannot be deleted.")}})},O=S();O.create("locale",navigator.language.split("-")[0]||"en");const C=(e,t)=>{const n=new Date(e);return{d:n,parts:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(n).reduce((e,{type:t,value:n})=>(e[t]=n,e),{})}},A=(e,t,n)=>{const r=e=>String(e).padStart(2,"0");return e.replace("YYYY",n.year).replace("YY",n.year.slice(-2)).replace("MMMM",n.month).replace("MMM",n.month.slice(0,3)).replace("MM",r(t.getMonth()+1)).replace("DD",r(t.getDate())).replace("D",t.getDate()).replace("HH",n.hour).replace("mm",n.minute).replace("ss",n.second)},E={currency:(e,t,{currency:n="XOF",notation:r,minimumFractionDigits:o,maximumFractionDigits:s}={})=>new Intl.NumberFormat(t,{style:"currency",currency:n,notation:r,minimumFractionDigits:o,maximumFractionDigits:s}).format(e),number:(e,t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}={})=>new Intl.NumberFormat(t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}).format(e),percent:(e,t,{decimals:n=1}={})=>new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:n}).format(e),date:(e,t,{format:n,dateStyle:r="long"}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r}).format(new Date(e))},time:(e,t,{format:n,hour:r="2-digit",minute:o="2-digit",second:s}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{hour:r,minute:o,second:s}).format(new Date(e))},datetime:(e,t,{format:n,dateStyle:r="long",hour:o="2-digit",minute:s="2-digit",second:i}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r,hour:o,minute:s,second:i}).format(new Date(e))},relative:(e,t,{unit:n="day",numeric:r="auto"}={})=>{const o=Math.round((e-Date.now())/864e5);return new Intl.RelativeTimeFormat(t,{numeric:r}).format(o,n)},plural:(e,t,{singular:n,plural:r}={})=>`${e} ${"one"===new Intl.PluralRules(t).select(e)?n:r}`};function x(e,t=null){e=h.isObservable(e)?e.val():e,this.$previousValue=null,this.$currentValue=e,this.$firstListener=null,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=h.isObject(e)?g(e):e))}Object.defineProperty(x.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),x.prototype.__$isObservable=!0;const D=function(){};function N(e,t=null){return new x(e,t)}x.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},x.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},x.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)},x.prototype.triggerWatchers=function(e){const t=this.$watchers,n=this.$previousValue,r=this.$currentValue,o=t.get(r),s=t.get(n);o&&o(!0,n,e),s&&s(!1,r,e)},x.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},x.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},x.prototype.assocTrigger=function(){this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?1===this.$listeners.length?(this.$firstListener=this.$listeners[0],this.trigger=this.triggerFirstListener):this.trigger=this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=D},x.prototype.trigger=D,x.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(),this.$previousValue=null)},x.prototype.$setWithInterceptor=function(e){let t="function"==typeof e?e(this.$currentValue):e;const n=this.$interceptor(t,this.$currentValue);void 0!==n&&(t=n),this.$updateWithNewValue(t)},x.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},x.prototype.set=x.prototype.$basicSet,x.prototype.val=function(){return this.$currentValue},x.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)h.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=D},x.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},x.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}f.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},x.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},x.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);t.__$isObservable&&(t=t.set.bind(t)),n?h.isArray(n.list)?n.list.push(t):(n=[n,t],t=e=>{for(let t=0,r=n.length;t<r;t++)n[t](e)},t.list=n,this.$watchers.set(e,t)):(n=t,this.$watchers.set(e,t)),this.assocTrigger()},x.prototype.off=function(e,t){if(!this.$watchers)return;const n=this.$watchers.get(e);if(!n)return;if(!t||!Array.isArray(n.list))return this.$watchers?.delete(e),void this.assocTrigger();const r=n.indexOf(t);n?.splice(r,1),1===n.length?this.$watchers.set(e,n[0]):0===n.length&&this.$watchers?.delete(e),this.assocTrigger()},x.prototype.once=function(e,t){const n="function"==typeof e?e:t=>t===e,r=e=>{n(e)&&(this.unsubscribe(r),t(e))};this.subscribe(r)},x.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},x.prototype.check=function(e){return new o(this,e)},x.prototype.transform=x.prototype.check,x.prototype.pluck=x.prototype.check,x.prototype.is=x.prototype.check,x.prototype.select=x.prototype.check,x.prototype.get=function(e){const t=this.$currentValue[e];return h.isObservable(t)?t.val():t},x.prototype.when=function(e){return new m(this,e)},x.prototype.equals=function(e){return h.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},x.prototype.toBool=function(){return!!this.$currentValue},x.prototype.toggle=function(){this.set(!this.$currentValue)},x.prototype.reset=function(){if(!this.configs?.reset)return;const e=h.isObject(this.$initialValue)?g(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},x.prototype.toString=function(){return String(this.$currentValue)},x.prototype.valueOf=function(){return this.$currentValue},x.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=E[e],s=E.locale;return N.computed(()=>r(n.val(),s.val(),t),[n,s])},x.prototype.persist=function(e,t={}){let n=w(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=$(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const k=N,T=N;function F(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))):r.__$isObservableWhen?(e.classes.toggle(n,r.isActive()),r.subscribe(t=>e.classes.toggle(n,t))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function I(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.style[n]=r.val(),r.subscribe(t=>e.style[n]=t)):e.style[n]=r}}function _(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(h.isBoolean(o)?e[t]=o:e[t]=o===e.value,r){if("checked"===t)return"boolean"==typeof o?e.addEventListener("input",()=>n.set(e[t])):e.addEventListener("input",()=>n.set(e.value)),void n.subscribe(n=>e[t]=n);n.subscribe(n=>e[t]=n===e.value)}}function M(e){this.$hydrate=e}N.useValueProperty=function(e="value"){Object.defineProperty(x.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},N.getById=function(e){const t=f.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},N.cleanup=function(e){e.cleanup()},N.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{f.cleanup()}),setInterval(()=>f.cleanObservables(r),n)},M.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){const e=this.resolveObservableTemplate?this.resolveObservableTemplate():this;return h.isString(e)?j.createStaticTextNode(null,e):j.getChild(null,e)},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},x.prototype.toNdElement=function(){return j.createObservableNode(null,this)},o.prototype.toNdElement=x.prototype.toNdElement,i.prototype.toNdElement=function(){return this.$element??this.$build?.()??this.build?.()??null},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=j.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return j.getChild(this())},M.prototype.toNdElement=function(){return j.createHydratableNode(null,this)};const P=(e,t=1e3)=>new Promise(n=>{let r=!1;const o=t=>{t&&t.target!==e||r||(r=!0,e.removeEventListener("transitionend",o),e.removeEventListener("animationend",o),clearTimeout(s),n())};e.addEventListener("transitionend",o),e.addEventListener("animationend",o);const s=setTimeout(o,t),i=window.getComputedStyle(e),a="0s"!==i.transitionDuration,u="0s"!==i.animationDuration;a||u||o()});i.prototype.transitionOut=function(e){const t=e+"-exit";return this.beforeUnmount("transition-exit",async function(){this.$element.classes.add(t),await P(this.$element),this.$element.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to";return this.$element.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.$element.classes.remove(t),this.$element.classes.add(n),P(this.$element).then(()=>{this.$element.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){return this.$element.classes.add(e),P(this.$element).then(()=>{this.$element.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},x.prototype.handleNdAttribute=function(e,t){d.has(t)?_(e,t,this):function(e,t,n){const r="value"===t?t=>e.value=t:n=>e.setAttribute(t,n);if(n.subscribe(r),"value"===t)return e.value=n.val(),void e.addEventListener("input",()=>n.set(e.value));e.setAttribute(t,n.val())}(e,t,this)},M.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const V=new Map;let L=null;const j={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=j.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=j.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=j.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=V.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return V.set(e,n),n.cloneNode()}return p("Fragment")},bindTextNode(e,t){if(t?.__$isObservable)return t.subscribe(t=>e.nodeValue=t),void(e.nodeValue=t.val());e.nodeValue=t},processChildren(e,t){if(null===e)return;let n=this.getChild(e);n&&t.appendChild(n)},async safeRemove(e){await e.remove()},getChild(e){if(null==e)return null;if(e.toNdElement)do{if(e=e.toNdElement(),h.isElement(e))return e}while(e.toNdElement);return j.createStaticTextNode(null,e)},processAttributes(e,t){t&&function(e,t){h.validateAttributes(t);for(const n in t){const r=n.toLowerCase();let o=t[n];if(null!=o)if(o.handleNdAttribute)o.handleNdAttribute(e,r,o);else{if("object"==typeof o){if("class"===r){F(e,o);continue}if("style"===r){I(e,o);continue}}d.has(r)?_(e,r,o):e.setAttribute(r,o)}}}(e,t)}},R={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",R),Object.defineProperty(DocumentFragment.prototype,"nd",R),Object.defineProperty(i.prototype,"nd",{configurable:!0,get:function(){return this}}),["Click","DblClick","MouseDown","MouseEnter","MouseLeave","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Blur","Change","Focus","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","AfterPrint","BeforePrint","BeforeUnload","Error","HashChange","Load","Offline","Online","PageHide","PageShow","Resize","Scroll","Unload","Abort","CanPlay","CanPlayThrough","DurationChange","Emptied","Ended","LoadedData","LoadedMetadata","LoadStart","Pause","Play","Playing","Progress","RateChange","Seeked","Seeking","Stalled","Suspend","TimeUpdate","VolumeChange","Waiting","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["on"+e]=function(e=null){return this.$element.addEventListener(t,e),this}}),["Click","DblClick","MouseDown","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Change","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","BeforeUnload","HashChange","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onStop"+e]=function(e=null){return W(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return B(this.$element,t,e),this}}),["Click","DblClick","MouseDown","MouseUp","Wheel","KeyDown","KeyPress","Invalid","Reset","Submit","DragOver","Drop","BeforeUnload","TouchCancel","TouchEnd","TouchMove","TouchStart","Copy","Cut","Paste","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onPrevent"+e]=function(e=null){return q(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const q=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},W=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},B=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},U={getClasses(){return this.$element.className?.split(" ").filter(Boolean)},add(e){const t=this.getClasses();t.indexOf(e)>=0||(t.push(e),this.$element.className=t.join(" "))},remove(e){const t=this.getClasses(),n=t.indexOf(e);n<0||(t.splice(n,1),this.$element.className=t.join(" "))},toggle(e,t=void 0){const n=this.getClasses(),r=n.indexOf(e);if(r>=0){if(!0===t)return;n.splice(r,1)}else{if(!1===t)return;n.push(e)}this.$element.className=n.join(" ")},contains(e){return this.getClasses().indexOf(e)>=0}};Object.defineProperty(HTMLElement.prototype,"classes",{configurable:!0,get(){return{$element:this,...U}}});let H=e=>e;e.ArgTypes={},e.ArgTypes={string:()=>!0,number:()=>!0,boolean:()=>!0,observable:()=>!0,element:()=>!0,function:()=>!0,object:()=>!0,objectNotNull:()=>!0,children:()=>!0,attributes:()=>!0,optional:()=>!0,oneOf:()=>!0};const z=function(e,t=null){return Array.isArray(e)||"object"!=typeof e||null===e||"Object"!==e.constructor.name||e.$hydrate?{props:t,children:e}:{props:e,children:t}};function K(e,t,n,r=null){let{props:o,children:s=null}=z(n,r),i=j.createElement(e),a=t&&"function"==typeof t?t(i):i;return j.processAttributes(a,o),j.processChildren(s,a),a}function J(e,t=null){return K.bind(null,e,t)}const Y=new WeakMap,G=(e,t,n)=>{let r=null;if(t.attributes){r={};for(const e in t.attributes)r[e]=t.attributes[e].apply(null,n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e].apply(null,n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e].apply(null,n)}return r?(j.processAttributes(e,r),!0):null},Q=(e,t,n)=>{if(!t.attach)return null;for(const r in t.attach)e.nd[r](function(...e){t.attach[r].apply(this,[...e,...n])})},X=(e,t,n,r)=>{if(r.fn&&("string"==typeof r.fn?j.bindTextNode(t,n[0][r.fn]):r.fn(n,t,e)),r.children)for(let o=0,s=r.children.length;o<s;o++){const s=r.children[o],i=t.childNodes[s.index];X(e,i,n,s)}};function Z(e){let t=null,n=!1;const r={fn:null,children:[]},o=(e,t,n)=>{const r=Y.get(e);if(3===e.nodeType){if(r&&r.value){n.fn=r.value;const o=e.cloneNode();return"string"==typeof r.value?(j.bindTextNode(o,t[0][r.value]),o):(r.value(t,o),o)}return e.cloneNode(!0)}const s=e.cloneNode();r&&(G(s,r,t),Q(s,r,t),n.fn=(e,t)=>{G(t,r,e),Q(t,r,e)});const i=e.childNodes,a=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r={index:e,fn:null},u=o(n,t,r);(r.children||r.fn)&&a.push(r),s.appendChild(u)}return a.length&&(n.children=n.children||[],n.children=a),s},s=e=>{let n=t.cloneNode(!0);return X(n,n,e,r),n};this.clone=i=>{if(t=e(this),!n)return this.clone=()=>t.cloneNode(!0),t.cloneNode(!0);const a=o(t,i,r);return this.clone=s,a};const i=(e,t)=>new M((r,o)=>{n=!0,function(e,t,n,r){Y.has(n)||Y.set(n,{});const o=Y.get(n);"value"!==t?(o[t]=o[t]||{},o[t][r]=e):o.value=e}(e,t,r,o)});this.style=e=>i(e,"styles"),this.class=e=>i(e,"classes"),this.property=e=>this.value(e),this.value=e=>i("function"!=typeof e?e:(t,n)=>{j.bindTextNode(n,e(...t))},"value"),this.attr=e=>i(e,"attributes"),this.attach=e=>i(e,"attach")}function ee(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=p("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new i(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){const t=(...n)=>{try{return this.apply(this,n)}catch(r){return e(r,{caller:t,args:n})}};return t},String.prototype.use=function(e){const t=this;return N.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return h.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return h.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!h.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return N.getById(n)}):this.valueOf()};const te=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},ne=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},re=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{const o=t.get(r);if(o)return o;if(e.length>0)return(...n)=>{const o=e(...n,r);return t.set(r,o),o};const s=e(r);return t.set(r,s),s}})};function oe(e){return e instanceof Date?e:new Date(e)}function se(e,t){const n=oe(e),r=oe(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ie(e){const t=oe(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function ae(e,t){const n=h.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function ue(e,t){const n=e.filter(h.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>h.isObservable(e)?e.val():e))}}function le(e){return ae(e,(e,t)=>e===t)}function ce(e){return ae(e,(e,t)=>e!==t)}function he(e){return ae(e,(e,t)=>e>t)}function pe(e){return ae(e,(e,t)=>e>=t)}function de(e){return ae(e,(e,t)=>e<t)}function fe(e){return ae(e,(e,t)=>e<=t)}function me(e,t=!0,n=""){return ue([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function be(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(h.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ye(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(h.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ge=he,ve=pe,we=de,$e=fe,Se=le,Oe=ce,Ce=be,Ae=ye;function Ee(e,t=!1){return ae(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const xe=Ee;var De=Object.freeze({__proto__:null,all:Ce,and:be,any:Ae,between:function(e,t){return ue([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:xe,createFilter:ae,createMultiSourceFilter:ue,custom:function(e,...t){const n=t.filter(h.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>h.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateEquals:e=>ae(e,(e,t)=>!(!e||!t)&&se(e,t)),dateTimeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateTimeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateTimeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateTimeEquals:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e).getTime()===oe(t).getTime()),endsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Se,equals:le,getSecondsOfDay:ie,greaterThan:he,greaterThanOrEqual:pe,gt:ge,gte:ve,inArray:function(e){return ae(e,(e,t)=>t.includes(e))},includes:Ee,isEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:se,lessThan:de,lessThanOrEqual:fe,lt:we,lte:$e,match:me,neq:Oe,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:ce,notIn:function(e){return ae(e,(e,t)=>!t.includes(e))},or:ye,startsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)>ie(t)),timeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)<ie(t)),timeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),timeEquals:e=>ae(e,(e,t)=>{if(!e||!t)return!1;const n=oe(e),r=oe(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:oe});const Ne=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");x.call(this,e,t)};(Ne.prototype=Object.create(x.prototype)).constructor=Ne,Ne.prototype.__$isObservableArray=!0,Object.defineProperty(Ne.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{Ne.prototype[e]=function(...t){const n=this.$currentValue[e].apply(this.$currentValue,t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{Ne.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),Ne.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},Ne.prototype.at=function(e){return this.$currentValue[e]},Ne.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},Ne.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},Ne.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},Ne.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},Ne.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},Ne.prototype.isEmpty=function(){return 0===this.$currentValue.length},Ne.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},Ne.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=h.isObservable(o)?me(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push.apply(n,t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=N.array(),s=Object.entries(r),i=()=>{const e=t.val().filter(e=>{for(const[t,n]of s)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(i)),i(),o},Ne.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},Ne.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},Ne.prototype.deepSubscribe=function(e){const t=b(()=>e(this.val())),n=new WeakMap,r=e=>{n.has(e)||(e?.__$isObservableArray?n.set(e,e.deepSubscribe(t)):e?.__$isObservable&&(e.subscribe(t),n.set(e,()=>e.unsubscribe(t))))},o=e=>{const t=n.get(e);t&&(t(),n.delete(e))};return this.$currentValue.forEach(r),this.subscribe(t),this.subscribe((e,t,n)=>{switch(n?.action){case"push":case"unshift":case"merge":n.args.forEach(r);break;case"splice":{const[e,t,...s]=n.args;n.result?.forEach(o),s.forEach(r);break}case"remove":o(n.result);break;case"clear":this.$currentValue.forEach(o)}}),()=>{this.$currentValue.forEach(o)}},N.array=function(e=[],t=null){return new Ne(e,t)},N.batch=function(e){const t=N(0),n=function(){if(h.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const ke=function(e,t){x.call(this,e),this.$observables={},this.configs=t,this.$load(e);for(const t in e)Object.hasOwn(this,t)||Object.defineProperty(this,t,{get:()=>this.$observables[t],set:e=>this.$observables[t].set(e)})};ke.prototype=Object.create(x.prototype),Object.defineProperty(ke,"$value",{get(){return this.val()},set(e){this.set(e)}}),ke.prototype.__$isObservableObject=!0,ke.prototype.__isProxy__=!0,ke.prototype.$load=function(e){const t=this.configs;for(const n in e){const r=e[n];if(Array.isArray(r)){if(!1!==t?.deep){const e=r.map(e=>h.isJson(e)?N.json(e,t):h.isArray(e)?N.array(e,t):N(e,t));this.$observables[n]=N.array(e,t);continue}this.$observables[n]=N.array(r,t)}else h.isObservable(r)||h.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?N.object(r,t):N(r,t)}},ke.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(h.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>h.isObservable(e)?e.val():h.isProxy(e)?e.$value:e)),e[t]=r}else h.isProxy(n)?e[t]=n.$value:e[t]=n}return e},ke.prototype.$val=ke.prototype.val,ke.prototype.get=function(e){const t=this.$observables[e];return h.isObservable(t)?t.val():h.isProxy(t)?t.$value:t},ke.prototype.$get=ke.prototype.get,ke.prototype.set=function(e){const t=h.isProxy(e)?e.$value:e,n=this.configs;for(const r in t){const o=this.$observables[r],s=e[r],i=t[r];if(h.isObservable(o)){if(!h.isArray(i)){o.set(i);continue}const e=s.at(0);if(h.isObservable(e)||h.isProxy(e)){const t=i.map(t=>h.isProxy(e)?N.init(t,n):N(t,n));o.set(t);continue}o.set([...i]);continue}h.isProxy(o)?o.update(i):this[r]=i}},ke.prototype.$set=ke.prototype.set,ke.prototype.$updateWith=ke.prototype.set,ke.prototype.observables=function(){return Object.values(this.$observables)},ke.prototype.$observables=ke.prototype.observables,ke.prototype.keys=function(){return Object.keys(this.$observables)},ke.prototype.$keys=ke.prototype.keys,ke.prototype.clone=function(){return N.init(this.val(),this.configs)},ke.prototype.$clone=ke.prototype.clone,ke.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},ke.prototype.originalSubscribe=ke.prototype.subscribe,ke.prototype.subscribe=function(e){const t=this.observables(),n=b(()=>this.trigger());this.originalSubscribe(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];r.__$isObservableArray?r.deepSubscribe(n):r.subscribe(n)}},ke.prototype.configs=function(){return this.configs},ke.prototype.update=ke.prototype.set,N.init=function(e,t=null){return new ke(e,t)},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.value=function(e){if(h.isObservable(e))return e.val();if(h.isProxy(e))return e.$value;if(h.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(N.value(r))}return t}return e},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new x(e()),o=b(()=>n.set(e()));if(h.isFunction(t)){if(!h.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{h.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Te=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!h.isObservable(e)&&!h.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=p("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=j.getChild(t),h.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Fe=function(e,t,n=!0){if(!h.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=p("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=j.getChild(r),h.isFragment(r)&&(r=Array.from(r.children)),n&&s.set(e,r),r):null},a=e.val(),u=i(a);return u&&o.appendChild(u),e.subscribe(e=>{const t=i(e);o.remove(),t&&o.appendChild(t)}),o.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&s.delete(e),delete t[e]}})},Ie=function(e,t,n){if(!h.isObservable(e))throw new r("Toggle : condition must be an Observable");return Fe(e,{true:t,false:n})},_e=J("div"),Me=J("span"),Pe=J("label"),Ve=J("p"),Le=Ve,je=J("strong"),Re=J("h1"),qe=J("h2"),We=J("h3"),Be=J("h4"),Ue=J("h5"),He=J("h6"),ze=J("br"),Ke=J("a"),Je=J("pre"),Ye=J("code"),Ge=J("blockquote"),Qe=J("hr"),Xe=J("em"),Ze=J("small"),et=J("mark"),tt=J("del"),nt=J("ins"),rt=J("sub"),ot=J("sup"),st=J("abbr"),it=J("cite"),at=J("q"),ut=J("dl"),lt=J("dt"),ct=J("dd"),ht=J("form",function(e){return e.submit=function(t){return"function"==typeof t?(e.onSubmit(e=>{e.preventDefault(),t(e)}),e):(this.setAttribute("action",t),e)},e.multipartFormData=function(){return this.setAttribute("enctype","multipart/form-data"),e},e.post=function(t){return this.setAttribute("method","post"),this.setAttribute("action",t),e},e.get=function(e){this.setAttribute("method","get"),this.setAttribute("action",e)},e}),pt=J("input"),dt=J("textarea"),ft=dt,mt=J("select"),bt=J("fieldset"),yt=J("option"),gt=J("legend"),vt=J("datalist"),wt=J("output"),$t=J("progress"),St=J("meter"),Ot=J("button"),Ct=J("main"),At=J("section"),Et=J("article"),xt=J("aside"),Dt=J("nav"),Nt=J("figure"),kt=J("figcaption"),Tt=J("header"),Ft=J("footer"),It=J("img"),_t=function(e,t){return It({src:e,...t})},Mt=J("details"),Pt=J("summary"),Vt=J("dialog"),Lt=J("menu"),jt=J("ol"),Rt=J("ul"),qt=J("li"),Wt=qt,Bt=jt,Ut=Rt,Ht=J("audio"),zt=J("video"),Kt=J("source"),Jt=J("track"),Yt=J("canvas"),Gt=J("svg"),Qt=J("time"),Xt=J("data"),Zt=J("address"),en=J("kbd"),tn=J("samp"),nn=J("var"),rn=J("wbr"),on=J("caption"),sn=J("table"),an=J("thead"),un=J("tfoot"),ln=J("tbody"),cn=J("tr"),hn=cn,pn=J("th"),dn=pn,fn=pn,mn=J("td"),bn=mn,yn=J("");var gn=Object.freeze({__proto__:null,Abbr:st,Address:Zt,Anchor:p,Article:Et,Aside:xt,AsyncImg:function(e,t,n,o){const s=h.isObservable(e)?e.val():e,i=_t(t||s,n),a=new Image;return a.onload=()=>{h.isFunction(o)&&o(null,i),i.src=h.isObservable(e)?e.val():e},a.onerror=()=>{h.isFunction(o)&&o(new r("Image not found"))},h.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Ht,BaseImage:It,Blockquote:Ge,Br:ze,Button:Ot,Canvas:Yt,Caption:on,Checkbox:e=>pt({type:"checkbox",...e}),Cite:it,Code:Ye,ColorInput:e=>pt({type:"color",...e}),Data:Xt,Datalist:vt,DateInput:e=>pt({type:"date",...e}),DateTimeInput:e=>pt({type:"datetime-local",...e}),Dd:ct,Del:tt,Details:Mt,Dialog:Vt,Div:_e,Dl:ut,Dt:lt,Em:Xe,EmailInput:e=>pt({type:"email",...e}),FieldSet:bt,FigCaption:kt,Figure:Nt,FileInput:e=>pt({type:"file",...e}),Footer:Ft,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=p("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,d=e=>{if(!s)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&r.remove(),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},f=(e,s)=>{const i=((e,t,n)=>{if(h.isString(n)){const r=h.isObservable(e)?e.val():e,o=r?.[n];return h.isObservable(o)?o.val():o??t}return h.isFunction(n)?n(e,t):(h.isObservable(e)?e.val():e)??t})(e,s,o);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(s),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?N(s):null;let o=j.getChild(t(e,n));if(!o)throw new r("ForEach child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(o),indexObserver:n})}catch(e){throw n.error("ForEach",`Error creating element for key ${i}`,e),e}return i},m=()=>{const t=a.parentNode;if(!t)return;const n=h.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=f(n[e],e);c.add(t)}else for(const e in n){const t=f(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),d(),void l?.clear();d(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return m(),h.isObservable(e)&&e.subscribe(m),i},ForEachArray:function(e,t,n={}){const o=p("ForEach Array",n.isParentUniqueChild),s=o.endElement(),i=o.startElement();let a=new Map,u=0;const l=t.length>=2,c=e=>{o.removeChildren(),m(e),u=0},d=e=>a.get(e)?.child,f=(e,t=!0)=>{const n=a.get(e);if(n){if(t){const e=n.child;e?.remove(),a.delete(n.keyId)}n.indexObserver?.cleanup()}},m=e=>{if(!n.shouldKeepItemsInCache)if(l){for(const[t,n]of a.entries())e&&e.contains(t)||f(t,!1);a.clear()}else a.clear()},b=(e,n)=>{const o=a.get(e);if(o){o.indexObserver?.set(n);const t=o.child;if(t)return t;a.delete(e)}const s=l?N(n):null;let i=j.getChild(t(e,s));if(i)return a.set(e,{child:i,indexObserver:s}),i;throw new r("ForEachArray child can't be null or undefined!")},y=function(e,t){const n=a.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},g={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(b(e[t],u)),u++;return n},add(e,t=2){o.appendElement(g.toFragment(e))},replace(e){c(e),g.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=d(r),t&&n.appendChild(t);t=null,o.appendElement(n,s)},removeOne(e,t){f(e,!0)},clear:c,merge(e){g.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),g.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(b(t,o)),u++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore(g.toFragment(e),i.nextSibling)},splice(e,t){const[n,r,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)y(e,u);else if(t.length>1){const e=d(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)y(t[e],u)}}else a=s;u.replaceChildren(),i&&i.length&&a&&o.insertBefore(g.toFragment(i),a.nextSibling)},reverse(e,t){g.reOrder(t)},sort(e,t){g.reOrder(t)},remove(e,t){g.removeOne(t)},pop(e,t){g.removeOne(t)},shift(e,t){g.removeOne(t)},swap(e,t){const n=s.parentNode;let r=d(t[0]),o=d(t[1]);if(!r||!o)return;const i=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,i),r=null,o=null}},v=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(n?.action)g[n.action]&&g[n.action](n.args,n.result);else{if(0===u)return void g.add(e);g.replace(e)}((e,t=0)=>{if(!l)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=a.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===u)return;c()}};return e.val().length&&v(e.val(),0,{action:null}),h.isObservable(e)&&e.subscribe(v),o},Form:ht,Fragment:yn,H1:Re,H2:qe,H3:We,H4:Be,H5:Ue,H6:He,Header:Tt,HiddenInput:e=>pt({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),Te(r,t,n)},HideIfNot:function(e,t,n){return Te(e,t,n)},Hr:Qe,Img:_t,Input:pt,Ins:nt,Kbd:en,Label:Pe,LazyImg:function(e,t){return _t(e,{...t,loading:"lazy"})},Legend:gt,Li:Wt,Link:Ke,ListItem:qt,Main:Ct,Mark:et,Match:Fe,Menu:Lt,Meter:St,MonthInput:e=>pt({type:"month",...e}),NativeDocumentFragment:p,Nav:Dt,NumberInput:e=>pt({type:"number",...e}),Ol:Bt,Option:yt,OrderedList:jt,Output:wt,P:Ve,Paragraph:Le,PasswordInput:e=>pt({type:"password",...e}),Pre:Je,Progress:$t,Quote:at,Radio:e=>pt({type:"radio",...e}),RangeInput:e=>pt({type:"range",...e}),ReadonlyInput:e=>pt({readonly:!0,...e}),Samp:tn,SearchInput:e=>pt({type:"search",...e}),Section:At,Select:mt,ShowIf:Te,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!h.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Te(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!h.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return Te(e.when(t),n)}throw new r("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Ot(e,{type:"button",...t}),Small:Ze,Source:Kt,Span:Me,Strong:je,Sub:rt,SubmitButton:(e,t)=>Ot(e,{type:"submit",...t}),Summary:Pt,Sup:ot,Svg:Gt,Switch:Ie,TBody:ln,TBodyCell:bn,TFoot:un,TFootCell:fn,THead:an,THeadCell:dn,TRow:hn,Table:sn,Td:mn,TelInput:e=>pt({type:"tel",...e}),TextArea:dt,TextInput:ft,Th:pn,Time:Qt,TimeInput:e=>pt({type:"time",...e}),Tr:cn,Track:Jt,Ul:Ut,UnorderedList:Rt,UrlInput:e=>pt({type:"url",...e}),Var:nn,Video:zt,Wbr:rn,WeekInput:e=>pt({type:"week",...e}),When:function(e){if(!h.isObservable(e))throw new r("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,Ie(e,t,n)),toNdElement:()=>Ie(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=p("Portal "+n);return r.appendChild(j.getChild(e)),(t||document.body).appendChild(r),r}});const vn={};function wn(e,t,n={}){e="/"+y(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u=n.layout||null,l={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=vn[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},p=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=h(t);return n&&n.pattern?(l[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+y(e,"/");if(!p().exec(e))return!1;const t={};return p().exec(e).forEach((e,n)=>{if(n<1)return;const r=c[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=h(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class $n extends Error{constructor(e,t){super(e),this.context=t}}const Sn=(e,t)=>{const n=[];return e.forEach(e=>{n.push(y(e.suffix,"/"))}),n.push(y(t,"/")),n.join("/")},On=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Cn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},An=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function En(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function xn(){this.push=function(e){try{const{route:t,path:n,params:r,query:o}=this.resolve(e);if(window.history.state&&window.history.state.path===n)return;window.history.pushState({name:t.name(),params:r,path:n},t.name()||n,n),this.handleRouteChange(t,r,o,n)}catch(e){n.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:r,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:r},t.name()||r,r),this.handleRouteChange(t,o,{},r)}catch(e){n.error("HistoryRouter","Error in replaceState",e)}},this.forward=function(){window.history.forward()},this.back=function(){window.history.back()},this.init=function(e){window.addEventListener("popstate",e=>{try{if(!e.state||!e.state.path)return;const t=e.state.path,{route:n,params:r,query:o,path:s}=this.resolve(t);if(!n)return;this.handleRouteChange(n,r,o,s)}catch(e){n.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:r,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,r,o,s)}}function Dn(){const e=[];let t=0;const n=n=>{const r=t+n;if(!e[r])return;t=r;const{route:o,params:s,query:i,path:a}=e[r];this.handleRouteChange(o,s,i,a)};this.push=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]&&e[t].path===i||(e.splice(t+1),e.push({route:r,params:o,query:s,path:i}),t++,this.handleRouteChange(r,o,s,i))},this.replace=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]={route:r,params:o,query:s,path:i},this.handleRouteChange(r,o,s,i)},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){const r=n||window.location.pathname+window.location.search,{route:o,params:s,query:i,path:a}=this.resolve(r);e.push({route:o,params:s,query:i,path:a}),t=0,this.handleRouteChange(o,s,i,a)}}function Nn(e,t){const n=new Map,r=new WeakMap,o=new WeakMap;let s=null,i=null;const a=(e,t)=>{const n=o.get(e);if(n)return n;let r=e;return h.isAnchor(e)||(r=p(t),r.appendChild(e)),o.set(e,r),r},u=()=>{h.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return h.isNDElement(e)&&(t=e.node()),t},d=function(e,n,o){const h=n.layout();if(h)return void((e,n,o,i)=>{let h=c(n);const p=r.get(h);if(p){if(p===s){const e=a(h,i);return u(),void e.replaceContent(h)}return l(),s=p,a(h,i).replaceContent(h),void t.appendChild(s)}l();const d=a(h,i);s=e(d),r.set(h,s),t.appendChild(s)})(h,e,0,o);let p=c(e);l(),t.appendChild(p),i=e},f=function(e){if(!e.route)return;const{route:t,params:r,query:o,path:s}=e;if(n.has(s)){const e=n.get(s);return void d(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),d(i,t,s)};return e.subscribe(f),f(e.currentState()),t}const kn="default";function Tn(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)En.apply(this,[]);else if("history"===e.mode)xn.apply(this,[]);else{if("memory"!==e.mode)throw new $n("Invalid router mode "+e.mode);Dn.apply(this,[])}const a=function(e,t){for(const r of s)try{r(e),t&&t(e)}catch(e){n.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,n,s){const i=new wn(Sn(o,e),n,{...s,middlewares:On(o,s?.middlewares||[]),name:s?.name?Cn(o,s.name):null,layout:s?.layout||An(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!h.isFunction(n))throw new $n("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},n={}){const o=r[e];if(!o)throw new $n(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(h.isJson(e)){const t=r[e.name];if(!t)throw new $n(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[n,o]=e.split("?"),s="/"+y(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new $n(`Route not found for url: ${n}`);const u={};if(o){const e=new URLSearchParams(o).entries();for(const[t,n]of e)u[t]=n}return{route:a,params:i,query:u,path:e}},this.subscribe=function(e){if(!h.isFunction(e))throw new $n("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function Fn(e,t){const{to:n,href:r,...o}=e;if(r){const e=Tn.get();return Ke({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||kn,a=Tn.get(i);if(!a)throw new $n('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ke({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Tn.routers={},Tn.create=function(e,t){if(!h.isFunction(t))throw n.error("Router","Callback must be a function"),new $n("Callback must be a function");const r=new Tn(e);return Tn.routers[e.name||kn]=r,t(r),r.init(e.entry),r.mount=function(e){if(h.isString(e)){const t=document.querySelector(e);if(!t)throw new $n(`Container not found for selector: ${e}`);e=t}else if(!h.isElement(e))throw new $n("Container must be a string or an Element");return Nn(r,e)},r},Tn.get=function(e){const t=Tn.routers[e||kn];if(!t)throw new $n(`Router not found for name: ${e}`);return t},Tn.push=function(e,t=null){return Tn.get(t).push(e)},Tn.replace=function(e,t=null){return Tn.get(t).replace(e)},Tn.forward=function(e=null){return Tn.get(e).forward()},Tn.back=function(e=null){return Tn.get(e).back()},Fn.blank=function(e,t){return Ke({...e,target:"_blank"},t)};var In=Object.freeze({__proto__:null,Link:Fn,RouteParamPatterns:vn,Router:Tn});var _n=Object.freeze({__proto__:null,memoize:e=>re(e),once:e=>ne(e),singleton:e=>te(e)}),Mn=Object.freeze({__proto__:null,Cache:_n,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};if(o)if(o instanceof FormData)i.body=o;else if("GET"!==n)i.headers["Content-Type"]="application/json",i.body=JSON.stringify(o);else{const e=new URLSearchParams(o).toString();e&&(r=r+(r.includes("?")?"&":"?")+e)}for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const u=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(u?.message||a.statusText);throw e.status=a.status,e.data=u,e}return u},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},filters:De});return e.$=k,e.ElementCreator=j,e.HtmlElementWrapper=J,e.NDElement=i,e.Observable=N,e.PluginsManager=null,e.SingletonView=ee,e.Store=O,e.StoreFactory=S,e.TemplateCloner=Z,e.Validator=h,e.autoMemoize=re,e.autoOnce=ne,e.classPropertyAccumulator=function(e=[]){let t=h.isString(e)?e.split(" ").filter(Boolean):e;const n=h.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=function(e){return h.isObservable(e)?j.createObservableNode(null,e):j.createStaticTextNode(null,e)},e.cssPropertyAccumulator=function(e={}){let t=h.isString(e)?e.split(";").filter(Boolean):e;const n=h.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=gn,e.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n,s=t.get(r);if(s)return s;const i=e(...o);return t.set(r,i),i}},e.normalizeComponentArgs=z,e.obs=T,e.once=te,e.router=In,e.useCache=function(e){let t=null;const n=function(n){return t||(t=new Z(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new ee(e)),t.render(n)}},e.utils=Mn,e.withValidation=H,e}({});
1
+ var NativeDocument=function(e){"use strict";let t={};t={log(){},warn(){},error(){},disable(){}};var n=t;class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const s={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=s.mounted.get(e);if(t&&(t.inDom=!0,t.mounted))if(Array.isArray(t.mounted))for(const n of t.mounted)n(e);else t.mounted(e)},executeUnmountedCallback(e){const t=s.unmounted.get(e);if(!t)return;if(t.inDom=!1,!t.unmounted)return;let n=!1;if(Array.isArray(t.unmounted))for(const r of t.unmounted)!0===r(e)&&(n=!0);else n=!0===t.unmounted(e);n&&(t.disconnect(),e.nd?.remove())},checkMutation:function(e){for(const t of e){if(s.mountedSupposedSize>0)for(const e of t.addedNodes){if(s.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)s.executeMountedCallback(e)}if(s.unmountedSupposedSize>0)for(const e of t.removedNodes){if(s.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)s.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(s.mounted.delete(e),s.mountedSupposedSize--),r&&(s.unmounted.delete(e),s.unmountedSupposedSize--),o=null}};const i=(e,t)=>{o[e]?Array.isArray(o[e])?o[e].push(t):o[e]=[o[e],t]:o[e]=t};return{disconnect:()=>o?.disconnect(),mounted:t=>{i("mounted",t),s.mounted.set(e,o),n||(s.mountedSupposedSize++,n=!0)},unmounted:t=>{i("unmounted",t),s.unmounted.set(e,o),r||(s.unmountedSupposedSize++,r=!0)},off:(e,t)=>{((e,t)=>{if(o?.[e]){if(Array.isArray(o[e])){const n=o[e].indexOf(t);return n>-1&&o[e].splice(n,1),1===o[e].length&&(o[e]=o[e][0]),void(0===o[e].length&&(o[e]=null))}o[e]=null}})(e,t)}}}};s.observer=new MutationObserver(s.checkMutation),s.observer.observe(document.body,{childList:!0,subtree:!0});function i(e){this.$element=e,this.$observer=null}i.prototype.__$isNDElement=!0,i.prototype.valueOf=function(){return this.$element},i.prototype.ref=function(e,t){return e[t]=this.$element,this},i.prototype.refSelf=function(e,t){return e[t]=this,this},i.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},i.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},i.prototype.lifecycle=function(e){return this.$observer=this.$observer||s.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},i.prototype.mounted=function(e){return this.lifecycle({mounted:e})},i.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},i.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!s.beforeUnmount.has(n)){s.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=s.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return s.beforeUnmount.get(n).set(e,t),this},i.prototype.htmlElement=function(){return this.$element},i.prototype.node=i.prototype.htmlElement,i.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},i.prototype.openShadow=function(e=null){return this.shadow("open",e)},i.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},i.prototype.attach=function(e,t){return t.$hydrate(this.$element,e),this.$element},i.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},i.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!Object.hasOwn(e,o))continue;const s=e[o];if("function"==typeof s){if(t.has(o))throw n.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);i.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),i.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i};const a=1,u=3,l=8,c=11,h={isObservable:e=>e?.__$isObservable,isTemplateBinding:e=>e?.__$isTemplateBinding,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isObservableOrProxy:e=>h.isObservable(e)||h.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&(e.nodeType===a||e.nodeType===u||e.nodeType===c||e.nodeType===l),isFragment:e=>e?.nodeType===c,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof i,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(h.isObject(e)&&Object.values(e).some(e=>h.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new r("Event callback must be a function")}};function p(e,t=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(s),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild,r.nativeAppend=r.append;const i=function(e,n,i){const a=h.isElement(n)?n:j.getChild(n);e!==r?(e=>t||e.firstChild===o&&e.lastChild===s)(e)&&i===s?e.append(a,i):e.insertBefore(a,i):e.nativeInsertBefore(a,i)};return r.appendElement=function(e,t=null){const n=o.parentNode,i=t||s;n!==r?n?.insertBefore(e,i):n.nativeInsertBefore(e,i)},r.appendChild=function(e,t=null){const r=s.parentNode;r?i(r,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t.remove()),t=e;await Promise.all(n)},r.remove=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[],i=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t),i.push(t.remove()),t=e;await Promise.all(i),r.nativeAppend(...n)},r.removeWithAnchors=async function(){await r.removeChildren(),o.remove(),s.remove()},r.replaceContent=async function(e){const t=h.isElement(e)?e:j.getChild(e),n=s.parentNode;n&&(await r.removeChildren(),n.insertBefore(t,s))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return s},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}DocumentFragment.prototype.setAttribute=()=>{};const d=new Set(["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"]),f=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let r=0;for(const[e,n]of t)n.deref()||(t.delete(e),r++);r>0&&n.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}(),m=function(e,t){this.$target=t,this.$observer=e};m.prototype.__$isObservableWhen=!0,m.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},m.prototype.val=function(){return this.$observer.$currentValue===this.$target},m.prototype.isMatch=m.prototype.val,m.prototype.isActive=m.prototype.val;const b=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},y=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},g=(e,t)=>{try{if(void 0!==window.structuredClone)return window.structuredClone(e)}catch(e){}if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>g(e));if(h.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=g(e[t]));return n},v={getJson(e){let t=localStorage.getItem(e);try{return JSON.parse(t)}catch(t){throw new r("invalid_json:"+e)}},getNumber(e){return Number(this.get(e))},getBool(e){const t=this.get(e);return"true"===t||"1"===t},setJson(e,t){localStorage.setItem(e,JSON.stringify(t))},setBool(e,t){localStorage.setItem(e,t?"true":"false")},get:(e,t=null)=>localStorage.getItem(e)||t,set:(e,t)=>localStorage.setItem(e,t),remove(e){localStorage.removeItem(e)},has:e=>null!=localStorage.getItem(e)},w=(e,t)=>{if(!v.has(e))return t;switch(typeof t){case"object":return v.getJson(e)??t;case"boolean":return v.getBool(e)??t;case"number":return v.getNumber(e)??t;default:return v.get(e,t)??t}},$=e=>{switch(typeof e){case"object":return v.setJson;case"boolean":return v.setBool;default:return v.set}},S=function(){const e=new Map,t=new Map,o=(t,o)=>{const s=e.get(o);if(!s)throw n.error("Store",`Store.${t}('${o}') : store not found. Did you call Store.create('${o}') first?`),new r(`Store.${t}('${o}') : store not found.`);return s},s=(e,t={})=>Array.isArray(e)?N.array(e,t):"object"==typeof e?N.object(e,t):N(e,t);return new Proxy({create(t,o){if(e.has(t))throw n.warn("Store",`Store.create('${t}') : a store with this name already exists. Use Store.get('${t}') to retrieve it.`),new r(`Store.create('${t}') : a store with this name already exists.`);const i=s(o);return e.set(t,{observer:i,subscribers:new Set,resettable:!1,composed:!1}),i},createResettable(t,o){if(e.has(t))throw n.warn("Store",`Store.createResettable('${t}') : a store with this name already exists.`),new r(`Store.createResettable('${t}') : a store with this name already exists.`);const i=s(o,{reset:!0});return e.set(t,{observer:i,subscribers:new Set,resettable:!0,composed:!1}),i},createComposed(t,o,s){if(e.has(t))throw n.warn("Store",`Store.createComposed('${t}') : a store with this name already exists.`),new r(`Store.createComposed('${t}') : a store with this name already exists.`);if("function"!=typeof o)throw new r(`Store.createComposed('${t}') : computation must be a function.`);if(!Array.isArray(s)||0===s.length)throw new r(`Store.createComposed('${t}') : dependencies must be a non-empty array of store names.`);const i=s.map(o=>{if("string"!=typeof o)return o;const s=e.get(o);if(!s)throw n.error("Store",`Store.createComposed('${t}') : dependency '${o}' not found. Create it first.`),new r(`Store.createComposed('${t}') : dependency store '${o}' not found.`);return s.observer}),a=N.computed(o,i);return e.set(t,{observer:a,subscribers:new Set,resettable:!1,composed:!0}),a},has:t=>e.has(t),reset(e){const t=o("reset",e);if(t.composed)throw n.error("Store",`Store.reset('${e}') : composed stores cannot be reset. Their value is derived from dependencies.`),new r(`Store.reset('${e}') : composed stores cannot be reset.`);if(!t.resettable)throw n.error("Store",`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`),new r(`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`);t.observer.reset()},use(e){const t=o("use",e);if(t.composed)throw n.error("Store",`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`),new r(`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`);const{observer:i,subscribers:a}=t,u=s(i.val()),l=e=>u.set(e),c=e=>i.set(e);return i.subscribe(l),u.subscribe(c),u.destroy=()=>{i.unsubscribe(l),u.unsubscribe(c),a.delete(u),u.cleanup()},u.dispose=u.destroy,a.add(u),u},follow(e){const{observer:t,subscribers:i}=o("follow",e),a=s(t.val()),u=e=>a.set(e);return t.subscribe(u),((e,t,o)=>{const s=e=>()=>{throw n.error("Store",`Store.${o}('${t}') is read-only. '${e}()' is not allowed.`),new r(`Store.${o}('${t}') is read-only.`)};e.set=s("set"),e.toggle=s("toggle"),e.reset=s("reset")})(a,e,"follow"),a.destroy=()=>{t.unsubscribe(u),i.delete(a),a.cleanup()},a.dispose=a.destroy,i.add(a),a},get(t){const r=e.get(t);return r?r.observer:(n.warn("Store",`Store.get('${t}') : store not found.`),null)},getWithSubscribers:t=>e.get(t)??null,delete(t){const r=e.get(t);r?(r.subscribers.forEach(e=>e.destroy()),r.subscribers.clear(),r.observer.cleanup(),e.delete(t)):n.warn("Store",`Store.delete('${t}') : store not found, nothing to delete.`)},group(e,t){"function"==typeof e&&(t=e,e="anonymous");const n=S();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,w(n,t)),o=$(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,w(n,t)),o=$(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{v.remove(n),s()},r}},{get(e,n){if("symbol"==typeof n||n.startsWith("$")||n in e)return e[n];if(e.has(n)){if(t.has(n))return t.get(n);const r=e.follow(n);return t.set(n,r),r}},set(e,t,o){throw n.error("Store",`Forbidden: You cannot overwrite the store key '${String(t)}'. Use .use('${String(t)}').set(value) instead.`),new r("Store structure is immutable. Use .set() on the observable.")},deleteProperty(e,t){throw new r("Store keys cannot be deleted.")}})},O=S();O.create("locale",navigator.language.split("-")[0]||"en");const C=(e,t)=>{const n=new Date(e);return{d:n,parts:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(n).reduce((e,{type:t,value:n})=>(e[t]=n,e),{})}},A=(e,t,n)=>{const r=e=>String(e).padStart(2,"0");return e.replace("YYYY",n.year).replace("YY",n.year.slice(-2)).replace("MMMM",n.month).replace("MMM",n.month.slice(0,3)).replace("MM",r(t.getMonth()+1)).replace("DD",r(t.getDate())).replace("D",t.getDate()).replace("HH",n.hour).replace("mm",n.minute).replace("ss",n.second)},E={currency:(e,t,{currency:n="XOF",notation:r,minimumFractionDigits:o,maximumFractionDigits:s}={})=>new Intl.NumberFormat(t,{style:"currency",currency:n,notation:r,minimumFractionDigits:o,maximumFractionDigits:s}).format(e),number:(e,t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}={})=>new Intl.NumberFormat(t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}).format(e),percent:(e,t,{decimals:n=1}={})=>new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:n}).format(e),date:(e,t,{format:n,dateStyle:r="long"}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r}).format(new Date(e))},time:(e,t,{format:n,hour:r="2-digit",minute:o="2-digit",second:s}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{hour:r,minute:o,second:s}).format(new Date(e))},datetime:(e,t,{format:n,dateStyle:r="long",hour:o="2-digit",minute:s="2-digit",second:i}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r,hour:o,minute:s,second:i}).format(new Date(e))},relative:(e,t,{unit:n="day",numeric:r="auto"}={})=>{const o=Math.round((e-Date.now())/864e5);return new Intl.RelativeTimeFormat(t,{numeric:r}).format(o,n)},plural:(e,t,{singular:n,plural:r}={})=>`${e} ${"one"===new Intl.PluralRules(t).select(e)?n:r}`};function x(e,t=null){e=h.isObservable(e)?e.val():e,this.$previousValue=null,this.$currentValue=e,this.$firstListener=null,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=h.isObject(e)?g(e):e))}Object.defineProperty(x.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),x.prototype.__$isObservable=!0;const D=function(){};function N(e,t=null){return new x(e,t)}x.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},x.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},x.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)},x.prototype.triggerWatchers=function(e){const t=this.$watchers,n=this.$previousValue,r=this.$currentValue,o=t.get(r),s=t.get(n);o&&o(!0,n,e),s&&s(!1,r,e)},x.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},x.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},x.prototype.assocTrigger=function(){this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?1===this.$listeners.length?(this.$firstListener=this.$listeners[0],this.trigger=this.triggerFirstListener):this.trigger=this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=D},x.prototype.trigger=D,x.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(),this.$previousValue=null)},x.prototype.$setWithInterceptor=function(e){let t="function"==typeof e?e(this.$currentValue):e;const n=this.$interceptor(t,this.$currentValue);void 0!==n&&(t=n),this.$updateWithNewValue(t)},x.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},x.prototype.set=x.prototype.$basicSet,x.prototype.val=function(){return this.$currentValue},x.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)h.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=D},x.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},x.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}f.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},x.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},x.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);t.__$isObservable&&(t=t.set.bind(t)),n?h.isArray(n.list)?n.list.push(t):(n=[n,t],t=e=>{for(let t=0,r=n.length;t<r;t++)n[t](e)},t.list=n,this.$watchers.set(e,t)):(n=t,this.$watchers.set(e,t)),this.assocTrigger()},x.prototype.off=function(e,t){if(!this.$watchers)return;const n=this.$watchers.get(e);if(!n)return;if(!t||!Array.isArray(n.list))return this.$watchers?.delete(e),void this.assocTrigger();const r=n.indexOf(t);n?.splice(r,1),1===n.length?this.$watchers.set(e,n[0]):0===n.length&&this.$watchers?.delete(e),this.assocTrigger()},x.prototype.once=function(e,t){const n="function"==typeof e?e:t=>t===e,r=e=>{n(e)&&(this.unsubscribe(r),t(e))};this.subscribe(r)},x.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},x.prototype.check=function(e){return new o(this,e)},x.prototype.transform=x.prototype.check,x.prototype.pluck=x.prototype.check,x.prototype.is=x.prototype.check,x.prototype.select=x.prototype.check,x.prototype.get=function(e){const t=this.$currentValue[e];return h.isObservable(t)?t.val():t},x.prototype.when=function(e){return new m(this,e)},x.prototype.equals=function(e){return h.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},x.prototype.toBool=function(){return!!this.$currentValue},x.prototype.toggle=function(){this.set(!this.$currentValue)},x.prototype.reset=function(){if(!this.configs?.reset)return;const e=h.isObject(this.$initialValue)?g(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},x.prototype.toString=function(){return String(this.$currentValue)},x.prototype.valueOf=function(){return this.$currentValue},x.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=E[e],s=E.locale;return N.computed(()=>r(n.val(),s.val(),t),[n,s])},x.prototype.persist=function(e,t={}){let n=w(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=$(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const k=N,T=N;function F(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))):r.__$isObservableWhen?(e.classes.toggle(n,r.isActive()),r.subscribe(t=>e.classes.toggle(n,t))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function I(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.style[n]=r.val(),r.subscribe(t=>e.style[n]=t)):e.style[n]=r}}function _(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(h.isBoolean(o)?e[t]=o:e[t]=o===e.value,r){if("checked"===t)return"boolean"==typeof o?e.addEventListener("input",()=>n.set(e[t])):e.addEventListener("input",()=>n.set(e.value)),void n.subscribe(n=>e[t]=n);n.subscribe(n=>e[t]=n===e.value)}}function M(e){this.$hydrate=e}N.useValueProperty=function(e="value"){Object.defineProperty(x.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},N.getById=function(e){const t=f.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},N.cleanup=function(e){e.cleanup()},N.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{f.cleanup()}),setInterval(()=>f.cleanObservables(r),n)},M.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){const e=this.resolveObservableTemplate?this.resolveObservableTemplate():this;return h.isString(e)?j.createStaticTextNode(null,e):j.getChild(null,e)},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},x.prototype.toNdElement=function(){return j.createObservableNode(null,this)},o.prototype.toNdElement=x.prototype.toNdElement,i.prototype.toNdElement=function(){return this.$element??this.$build?.()??this.build?.()??null},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=j.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return j.getChild(this())},M.prototype.toNdElement=function(){return j.createHydratableNode(null,this)};const P=(e,t=1e3)=>new Promise(n=>{let r=!1;const o=t=>{t&&t.target!==e||r||(r=!0,e.removeEventListener("transitionend",o),e.removeEventListener("animationend",o),clearTimeout(s),n())};e.addEventListener("transitionend",o),e.addEventListener("animationend",o);const s=setTimeout(o,t),i=window.getComputedStyle(e),a="0s"!==i.transitionDuration,u="0s"!==i.animationDuration;a||u||o()});i.prototype.transitionOut=function(e){const t=e+"-exit";return this.beforeUnmount("transition-exit",async function(){this.$element.classes.add(t),await P(this.$element),this.$element.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to";return this.$element.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.$element.classes.remove(t),this.$element.classes.add(n),P(this.$element).then(()=>{this.$element.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){return this.$element.classes.add(e),P(this.$element).then(()=>{this.$element.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},x.prototype.handleNdAttribute=function(e,t){d.has(t)?_(e,t,this):function(e,t,n){const r="value"===t?t=>e.value=t:n=>e.setAttribute(t,n);if(n.subscribe(r),"value"===t)return e.value=n.val(),void e.addEventListener("input",()=>n.set(e.value));e.setAttribute(t,n.val())}(e,t,this)},M.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const V=new Map;let L=null;const j={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=j.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=j.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=j.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=V.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return V.set(e,n),n.cloneNode()}return p("Fragment")},bindTextNode(e,t){if(t?.__$isObservable)return t.subscribe(t=>e.nodeValue=t),void(e.nodeValue=t.val());e.nodeValue=t},processChildren(e,t){if(null===e)return;let n=this.getChild(e);n&&t.appendChild(n)},async safeRemove(e){await e.remove()},getChild(e){if(null==e)return null;if(e.toNdElement)do{if(e=e.toNdElement(),h.isElement(e))return e}while(e.toNdElement);return j.createStaticTextNode(null,e)},processAttributes(e,t){t&&function(e,t){h.validateAttributes(t);for(const n in t){const r=n.toLowerCase();let o=t[n];if(null!=o)if(o.handleNdAttribute)o.handleNdAttribute(e,r,o);else{if("object"==typeof o){if("class"===r){F(e,o);continue}if("style"===r){I(e,o);continue}}d.has(r)?_(e,r,o):e.setAttribute(r,o)}}}(e,t)}},R={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",R),Object.defineProperty(DocumentFragment.prototype,"nd",R),Object.defineProperty(i.prototype,"nd",{configurable:!0,get:function(){return this}}),["Click","DblClick","MouseDown","MouseEnter","MouseLeave","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Blur","Change","Focus","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","AfterPrint","BeforePrint","BeforeUnload","Error","HashChange","Load","Offline","Online","PageHide","PageShow","Resize","Scroll","Unload","Abort","CanPlay","CanPlayThrough","DurationChange","Emptied","Ended","LoadedData","LoadedMetadata","LoadStart","Pause","Play","Playing","Progress","RateChange","Seeked","Seeking","Stalled","Suspend","TimeUpdate","VolumeChange","Waiting","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["on"+e]=function(e=null){return this.$element.addEventListener(t,e),this}}),["Click","DblClick","MouseDown","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Change","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","BeforeUnload","HashChange","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onStop"+e]=function(e=null){return W(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return B(this.$element,t,e),this}}),["Click","DblClick","MouseDown","MouseUp","Wheel","KeyDown","KeyPress","Invalid","Reset","Submit","DragOver","Drop","BeforeUnload","TouchCancel","TouchEnd","TouchMove","TouchStart","Copy","Cut","Paste","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onPrevent"+e]=function(e=null){return q(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const q=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},W=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},B=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},U={getClasses(){return this.$element.className?.split(" ").filter(Boolean)},add(e){const t=this.getClasses();t.indexOf(e)>=0||(t.push(e),this.$element.className=t.join(" "))},remove(e){const t=this.getClasses(),n=t.indexOf(e);n<0||(t.splice(n,1),this.$element.className=t.join(" "))},toggle(e,t=void 0){const n=this.getClasses(),r=n.indexOf(e);if(r>=0){if(!0===t)return;n.splice(r,1)}else{if(!1===t)return;n.push(e)}this.$element.className=n.join(" ")},contains(e){return this.getClasses().indexOf(e)>=0}};Object.defineProperty(HTMLElement.prototype,"classes",{configurable:!0,get(){return{$element:this,...U}}});let H=e=>e;e.ArgTypes={},e.ArgTypes={string:()=>!0,number:()=>!0,boolean:()=>!0,observable:()=>!0,element:()=>!0,function:()=>!0,object:()=>!0,objectNotNull:()=>!0,children:()=>!0,attributes:()=>!0,optional:()=>!0,oneOf:()=>!0};const z=function(e,t=null){return Array.isArray(e)||"object"!=typeof e||null===e||"Object"!==e.constructor.name||e.$hydrate?{props:t,children:e}:{props:e,children:t}};function K(e,t,n,r=null){let{props:o,children:s=null}=z(n,r),i=j.createElement(e),a=t&&"function"==typeof t?t(i):i;return j.processAttributes(a,o),j.processChildren(s,a),a}function J(e,t=null){return K.bind(null,e,t)}const Y=new WeakMap,G=(e,t,n)=>{let r=null;if(t.attributes){r={};for(const e in t.attributes)r[e]=t.attributes[e].apply(null,n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e].apply(null,n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e].apply(null,n)}return r?(j.processAttributes(e,r),!0):null},Q=(e,t,n)=>{if(!t.attach)return null;for(const r in t.attach)e.nd[r](function(...e){t.attach[r].apply(this,[...e,...n])})},X=(e,t,n,r)=>{if(r.fn&&("string"==typeof r.fn?j.bindTextNode(t,n[0][r.fn]):r.fn(n,t,e)),r.children)for(let o=0,s=r.children.length;o<s;o++){const s=r.children[o],i=t.childNodes[s.index];X(e,i,n,s)}};function Z(e){let t=null,n=!1;const r={fn:null,children:[]},o=(e,t,n)=>{const r=Y.get(e);if(3===e.nodeType){if(r&&r.value){n.fn=r.value;const o=e.cloneNode();return"string"==typeof r.value?(j.bindTextNode(o,t[0][r.value]),o):(r.value(t,o),o)}return e.cloneNode(!0)}const s=e.cloneNode();r&&(G(s,r,t),Q(s,r,t),n.fn=(e,t)=>{G(t,r,e),Q(t,r,e)});const i=e.childNodes,a=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r={index:e,fn:null},u=o(n,t,r);(r.children||r.fn)&&a.push(r),s.appendChild(u)}return a.length&&(n.children=n.children||[],n.children=a),s},s=e=>{let n=t.cloneNode(!0);return X(n,n,e,r),n};this.clone=i=>{if(t=e(this),!n)return this.clone=()=>t.cloneNode(!0),t.cloneNode(!0);const a=o(t,i,r);return this.clone=s,a};const i=(e,t)=>new M((r,o)=>{n=!0,function(e,t,n,r){Y.has(n)||Y.set(n,{});const o=Y.get(n);"value"!==t?(o[t]=o[t]||{},o[t][r]=e):o.value=e}(e,t,r,o)});this.style=e=>i(e,"styles"),this.class=e=>i(e,"classes"),this.property=e=>this.value(e),this.value=e=>i("function"!=typeof e?e:(t,n)=>{j.bindTextNode(n,e(...t))},"value"),this.attr=e=>i(e,"attributes"),this.attach=e=>i(e,"attach")}function ee(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=p("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new i(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){const t=(...n)=>{try{return this.apply(this,n)}catch(r){return e(r,{caller:t,args:n})}};return t},String.prototype.use=function(e){const t=this;return N.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return h.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return h.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!h.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return N.getById(n)}):this.valueOf()};const te=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},ne=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},re=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{const o=t.get(r);if(o)return o;if(e.length>0)return(...n)=>{const o=e(...n,r);return t.set(r,o),o};const s=e(r);return t.set(r,s),s}})};function oe(e){return e instanceof Date?e:new Date(e)}function se(e,t){const n=oe(e),r=oe(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ie(e){const t=oe(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function ae(e,t){const n=h.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function ue(e,t){const n=e.filter(h.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>h.isObservable(e)?e.val():e))}}function le(e){return ae(e,(e,t)=>e===t)}function ce(e){return ae(e,(e,t)=>e!==t)}function he(e){return ae(e,(e,t)=>e>t)}function pe(e){return ae(e,(e,t)=>e>=t)}function de(e){return ae(e,(e,t)=>e<t)}function fe(e){return ae(e,(e,t)=>e<=t)}function me(e,t=!0,n=""){return ue([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function be(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(h.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ye(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(h.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ge=he,ve=pe,we=de,$e=fe,Se=le,Oe=ce,Ce=be,Ae=ye;function Ee(e,t=!1){return ae(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const xe=Ee;var De=Object.freeze({__proto__:null,all:Ce,and:be,any:Ae,between:function(e,t){return ue([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:xe,createFilter:ae,createMultiSourceFilter:ue,custom:function(e,...t){const n=t.filter(h.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>h.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateEquals:e=>ae(e,(e,t)=>!(!e||!t)&&se(e,t)),dateTimeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateTimeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateTimeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateTimeEquals:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e).getTime()===oe(t).getTime()),endsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Se,equals:le,getSecondsOfDay:ie,greaterThan:he,greaterThanOrEqual:pe,gt:ge,gte:ve,inArray:function(e){return ae(e,(e,t)=>t.includes(e))},includes:Ee,isEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:se,lessThan:de,lessThanOrEqual:fe,lt:we,lte:$e,match:me,neq:Oe,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:ce,notIn:function(e){return ae(e,(e,t)=>!t.includes(e))},or:ye,startsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)>ie(t)),timeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)<ie(t)),timeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),timeEquals:e=>ae(e,(e,t)=>{if(!e||!t)return!1;const n=oe(e),r=oe(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:oe});const Ne=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");x.call(this,e,t)};(Ne.prototype=Object.create(x.prototype)).constructor=Ne,Ne.prototype.__$isObservableArray=!0,Object.defineProperty(Ne.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{Ne.prototype[e]=function(...t){const n=this.$currentValue[e].apply(this.$currentValue,t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{Ne.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),Ne.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},Ne.prototype.at=function(e){return this.$currentValue[e]},Ne.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},Ne.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},Ne.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},Ne.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},Ne.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},Ne.prototype.isEmpty=function(){return 0===this.$currentValue.length},Ne.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},Ne.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=h.isObservable(o)?me(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push.apply(n,t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=N.array(),s=Object.entries(r),i=()=>{const e=t.val().filter(e=>{for(const[t,n]of s)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(i)),i(),o},Ne.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},Ne.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},Ne.prototype.deepSubscribe=function(e){const t=b(()=>e(this.val())),n=new WeakMap,r=e=>{n.has(e)||(e?.__$isObservableArray?n.set(e,e.deepSubscribe(t)):e?.__$isObservable&&(e.subscribe(t),n.set(e,()=>e.unsubscribe(t))))},o=e=>{const t=n.get(e);t&&(t(),n.delete(e))};return this.$currentValue.forEach(r),this.subscribe(t),this.subscribe((e,t,n)=>{switch(n?.action){case"push":case"unshift":case"merge":n.args.forEach(r);break;case"splice":{const[e,t,...s]=n.args;n.result?.forEach(o),s.forEach(r);break}case"remove":o(n.result);break;case"clear":this.$currentValue.forEach(o)}}),()=>{this.$currentValue.forEach(o)}},N.array=function(e=[],t=null){return new Ne(e,t)},N.batch=function(e){const t=N(0),n=function(){if(h.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const ke=function(e,t){x.call(this,e),this.$observables={},this.configs=t,this.$load(e);for(const t in e)Object.hasOwn(this,t)||Object.defineProperty(this,t,{get:()=>this.$observables[t],set:e=>this.$observables[t].set(e)})};ke.prototype=Object.create(x.prototype),Object.defineProperty(ke,"$value",{get(){return this.val()},set(e){this.set(e)}}),ke.prototype.__$isObservableObject=!0,ke.prototype.__isProxy__=!0,ke.prototype.$load=function(e){const t=this.configs;for(const n in e){const r=e[n];if(Array.isArray(r)){if(!1!==t?.deep){const e=r.map(e=>h.isJson(e)?N.json(e,t):h.isArray(e)?N.array(e,t):N(e,t));this.$observables[n]=N.array(e,t);continue}this.$observables[n]=N.array(r,t)}else h.isObservable(r)||h.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?N.object(r,t):N(r,t)}},ke.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(h.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>h.isObservable(e)?e.val():h.isProxy(e)?e.$value:e)),e[t]=r}else h.isProxy(n)?e[t]=n.$value:e[t]=n}return e},ke.prototype.$val=ke.prototype.val,ke.prototype.get=function(e){const t=this.$observables[e];return h.isObservable(t)?t.val():h.isProxy(t)?t.$value:t},ke.prototype.$get=ke.prototype.get,ke.prototype.set=function(e){const t=h.isProxy(e)?e.$value:e,n=this.configs;for(const r in t){const o=this.$observables[r],s=e[r],i=t[r];if(h.isObservable(o)){if(!h.isArray(i)){o.set(i);continue}const e=s.at(0);if(h.isObservable(e)||h.isProxy(e)){const t=i.map(t=>h.isProxy(e)?N.init(t,n):N(t,n));o.set(t);continue}o.set([...i]);continue}h.isProxy(o)?o.update(i):this[r]=i}},ke.prototype.$set=ke.prototype.set,ke.prototype.$updateWith=ke.prototype.set,ke.prototype.observables=function(){return Object.values(this.$observables)},ke.prototype.$observables=ke.prototype.observables,ke.prototype.keys=function(){return Object.keys(this.$observables)},ke.prototype.$keys=ke.prototype.keys,ke.prototype.clone=function(){return N.init(this.val(),this.configs)},ke.prototype.$clone=ke.prototype.clone,ke.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},ke.prototype.originalSubscribe=ke.prototype.subscribe,ke.prototype.subscribe=function(e){const t=this.observables(),n=b(()=>this.trigger());this.originalSubscribe(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];r.__$isObservableArray?r.deepSubscribe(n):r.subscribe(n)}},ke.prototype.configs=function(){return this.configs},ke.prototype.update=ke.prototype.set,N.init=function(e,t=null){return new ke(e,t)},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.value=function(e){if(h.isObservable(e))return e.val();if(h.isProxy(e))return e.$value;if(h.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(N.value(r))}return t}return e},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new x(e()),o=b(()=>n.set(e()));if(h.isFunction(t)){if(!h.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{h.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Te=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!h.isObservable(e)&&!h.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=p("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=j.getChild(t),h.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Fe=function(e,t,n=!0){if(!h.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=p("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=j.getChild(r),h.isFragment(r)&&(r=Array.from(r.children)),n&&s.set(e,r),r):null},a=e.val(),u=i(a);return u&&o.appendChild(u),e.subscribe(e=>{const t=i(e);o.remove(),t&&o.appendChild(t)}),o.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&s.delete(e),delete t[e]}})},Ie=function(e,t,n){if(!h.isObservable(e))throw new r("Toggle : condition must be an Observable");return Fe(e,{true:t,false:n})},_e=J("div"),Me=J("span"),Pe=J("label"),Ve=J("p"),Le=Ve,je=J("strong"),Re=J("h1"),qe=J("h2"),We=J("h3"),Be=J("h4"),Ue=J("h5"),He=J("h6"),ze=J("br"),Ke=J("a"),Je=J("pre"),Ye=J("code"),Ge=J("blockquote"),Qe=J("hr"),Xe=J("em"),Ze=J("small"),et=J("mark"),tt=J("del"),nt=J("ins"),rt=J("sub"),ot=J("sup"),st=J("abbr"),it=J("cite"),at=J("q"),ut=J("dl"),lt=J("dt"),ct=J("dd"),ht=J("form",function(e){return e.submit=function(t){return"function"==typeof t?(e.onSubmit(e=>{e.preventDefault(),t(e)}),e):(this.setAttribute("action",t),e)},e.multipartFormData=function(){return this.setAttribute("enctype","multipart/form-data"),e},e.post=function(t){return this.setAttribute("method","post"),this.setAttribute("action",t),e},e.get=function(e){this.setAttribute("method","get"),this.setAttribute("action",e)},e}),pt=J("input"),dt=J("textarea"),ft=dt,mt=J("select"),bt=J("fieldset"),yt=J("option"),gt=J("legend"),vt=J("datalist"),wt=J("output"),$t=J("progress"),St=J("meter"),Ot=J("button"),Ct=J("main"),At=J("section"),Et=J("article"),xt=J("aside"),Dt=J("nav"),Nt=J("figure"),kt=J("figcaption"),Tt=J("header"),Ft=J("footer"),It=J("img"),_t=function(e,t){return It({src:e,...t})},Mt=J("details"),Pt=J("summary"),Vt=J("dialog"),Lt=J("menu"),jt=J("ol"),Rt=J("ul"),qt=J("li"),Wt=qt,Bt=jt,Ut=Rt,Ht=J("audio"),zt=J("video"),Kt=J("source"),Jt=J("track"),Yt=J("canvas"),Gt=J("svg"),Qt=J("time"),Xt=J("data"),Zt=J("address"),en=J("kbd"),tn=J("samp"),nn=J("var"),rn=J("wbr"),on=J("caption"),sn=J("table"),an=J("thead"),un=J("tfoot"),ln=J("tbody"),cn=J("tr"),hn=cn,pn=J("th"),dn=pn,fn=pn,mn=J("td"),bn=mn,yn=J("");var gn=Object.freeze({__proto__:null,Abbr:st,Address:Zt,Anchor:p,Article:Et,Aside:xt,AsyncImg:function(e,t,n,o){const s=h.isObservable(e)?e.val():e,i=_t(t||s,n),a=new Image;return a.onload=()=>{h.isFunction(o)&&o(null,i),i.src=h.isObservable(e)?e.val():e},a.onerror=()=>{h.isFunction(o)&&o(new r("Image not found"))},h.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Ht,BaseImage:It,Blockquote:Ge,Br:ze,Button:Ot,Canvas:Yt,Caption:on,Checkbox:e=>pt({type:"checkbox",...e}),Cite:it,Code:Ye,ColorInput:e=>pt({type:"color",...e}),Data:Xt,Datalist:vt,DateInput:e=>pt({type:"date",...e}),DateTimeInput:e=>pt({type:"datetime-local",...e}),Dd:ct,Del:tt,Details:Mt,Dialog:Vt,Div:_e,Dl:ut,Dt:lt,Em:Xe,EmailInput:e=>pt({type:"email",...e}),FieldSet:bt,FigCaption:kt,Figure:Nt,FileInput:e=>pt({type:"file",...e}),Footer:Ft,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=p("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,d=e=>{if(!s)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&r.remove(),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},f=(e,s)=>{const i=((e,t,n)=>{if(h.isString(n)){const r=h.isObservable(e)?e.val():e,o=r?.[n];return h.isObservable(o)?o.val():o??t}return h.isFunction(n)?n(e,t):(h.isObservable(e)?e.val():e)??t})(e,s,o);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(s),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?N(s):null;let o=j.getChild(t(e,n));if(!o)throw new r("ForEach child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(o),indexObserver:n})}catch(e){throw n.error("ForEach",`Error creating element for key ${i}`,e),e}return i},m=()=>{const t=a.parentNode;if(!t)return;const n=h.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=f(n[e],e);c.add(t)}else for(const e in n){const t=f(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),d(),void l?.clear();d(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return m(),h.isObservable(e)&&e.subscribe(m),i},ForEachArray:function(e,t,n={}){const o=p("ForEach Array",n.isParentUniqueChild),s=o.endElement(),i=o.startElement();let a=new Map,u=0;const l=t.length>=2,c=e=>{o.removeChildren(),m(e),u=0},d=e=>a.get(e)?.child,f=(e,t=!0)=>{const n=a.get(e);if(n){if(t){const e=n.child;e?.remove(),a.delete(n.keyId)}n.indexObserver?.cleanup()}},m=e=>{if(!n.shouldKeepItemsInCache)if(l){for(const[t,n]of a.entries())e&&e.contains(t)||f(t,!1);a.clear()}else a.clear()},b=(e,n)=>{const o=a.get(e);if(o){o.indexObserver?.set(n);const t=o.child;if(t)return t;a.delete(e)}const s=l?N(n):null;let i=j.getChild(t(e,s));if(i)return a.set(e,{child:i,indexObserver:s}),i;throw new r("ForEachArray child can't be null or undefined!")},y=function(e,t){const n=a.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},g={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(b(e[t],u)),u++;return n},add(e,t=2){o.appendElement(g.toFragment(e))},replace(e){c(e),g.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=d(r),t&&n.appendChild(t);t=null,o.appendElement(n,s)},removeOne(e,t){f(e,!0)},clear:c,merge(e){g.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),g.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(b(t,o)),u++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore(g.toFragment(e),i.nextSibling)},splice(e,t){const[n,r,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)y(e,u);else if(t.length>1){const e=d(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)y(t[e],u)}}else a=s;u.replaceChildren(),i&&i.length&&a&&o.insertBefore(g.toFragment(i),a.nextSibling)},reverse(e,t){g.reOrder(t)},sort(e,t){g.reOrder(t)},remove(e,t){g.removeOne(t)},pop(e,t){g.removeOne(t)},shift(e,t){g.removeOne(t)},swap(e,t){const n=s.parentNode;let r=d(t[0]),o=d(t[1]);if(!r||!o)return;const i=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,i),r=null,o=null}},v=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(n?.action)g[n.action]&&g[n.action](n.args,n.result);else{if(0===u)return void g.add(e);g.replace(e)}((e,t=0)=>{if(!l)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=a.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===u)return;c()}};return e.val().length&&v(e.val(),0,{action:null}),h.isObservable(e)&&e.subscribe(v),o},Form:ht,Fragment:yn,H1:Re,H2:qe,H3:We,H4:Be,H5:Ue,H6:He,Header:Tt,HiddenInput:e=>pt({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),Te(r,t,n)},HideIfNot:function(e,t,n){return Te(e,t,n)},Hr:Qe,Img:_t,Input:pt,Ins:nt,Kbd:en,Label:Pe,LazyImg:function(e,t){return _t(e,{...t,loading:"lazy"})},Legend:gt,Li:Wt,Link:Ke,ListItem:qt,Main:Ct,Mark:et,Match:Fe,Menu:Lt,Meter:St,MonthInput:e=>pt({type:"month",...e}),NativeDocumentFragment:p,Nav:Dt,NumberInput:e=>pt({type:"number",...e}),Ol:Bt,Option:yt,OrderedList:jt,Output:wt,P:Ve,Paragraph:Le,PasswordInput:e=>pt({type:"password",...e}),Pre:Je,Progress:$t,Quote:at,Radio:e=>pt({type:"radio",...e}),RangeInput:e=>pt({type:"range",...e}),ReadonlyInput:e=>pt({readonly:!0,...e}),Samp:tn,SearchInput:e=>pt({type:"search",...e}),Section:At,Select:mt,ShowIf:Te,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!h.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Te(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!h.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return Te(e.when(t),n)}throw new r("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Ot(e,{type:"button",...t}),Small:Ze,Source:Kt,Span:Me,Strong:je,Sub:rt,SubmitButton:(e,t)=>Ot(e,{type:"submit",...t}),Summary:Pt,Sup:ot,Svg:Gt,Switch:Ie,TBody:ln,TBodyCell:bn,TFoot:un,TFootCell:fn,THead:an,THeadCell:dn,TRow:hn,Table:sn,Td:mn,TelInput:e=>pt({type:"tel",...e}),TextArea:dt,TextInput:ft,Th:pn,Time:Qt,TimeInput:e=>pt({type:"time",...e}),Tr:cn,Track:Jt,Ul:Ut,UnorderedList:Rt,UrlInput:e=>pt({type:"url",...e}),Var:nn,Video:zt,Wbr:rn,WeekInput:e=>pt({type:"week",...e}),When:function(e){if(!h.isObservable(e))throw new r("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,Ie(e,t,n)),toNdElement:()=>Ie(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=p("Portal "+n);return r.appendChild(j.getChild(e)),(t||document.body).appendChild(r),r}});const vn={};function wn(e,t,n={}){e="/"+y(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u=n.layout||null,l={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=vn[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(t){t="/"+y(t,"/");const n=(()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=h(t);return n&&n.pattern?(l[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r})().exec(t);if(!n)return!1;const o={};return n.forEach((e,t)=>{if(t<1)return;const n=c[t-1];o[n]=e}),o},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=h(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class $n extends Error{constructor(e,t){super(e),this.context=t}}const Sn=(e,t)=>{const n=[];return e.forEach(e=>{n.push(y(e.suffix,"/"))}),n.push(y(t,"/")),n.join("/")},On=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Cn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},An=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function En(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function xn(){this.push=function(e){try{const{route:t,path:n,params:r,query:o}=this.resolve(e);if(window.history.state&&window.history.state.path===n)return;window.history.pushState({name:t.name(),params:r,path:n},t.name()||n,n),this.handleRouteChange(t,r,o,n)}catch(e){n.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:r,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:r},t.name()||r,r),this.handleRouteChange(t,o,{},r)}catch(e){n.error("HistoryRouter","Error in replaceState",e)}},this.forward=function(){window.history.forward()},this.back=function(){window.history.back()},this.init=function(e){window.addEventListener("popstate",e=>{try{if(!e.state||!e.state.path)return;const t=e.state.path,{route:n,params:r,query:o,path:s}=this.resolve(t);if(!n)return;this.handleRouteChange(n,r,o,s)}catch(e){n.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:r,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,r,o,s)}}function Dn(){const e=[];let t=0;const n=n=>{const r=t+n;if(!e[r])return;t=r;const{route:o,params:s,query:i,path:a}=e[r];this.handleRouteChange(o,s,i,a)};this.push=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]&&e[t].path===i||(e.splice(t+1),e.push({route:r,params:o,query:s,path:i}),t++,this.handleRouteChange(r,o,s,i))},this.replace=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]={route:r,params:o,query:s,path:i},this.handleRouteChange(r,o,s,i)},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){const r=n||window.location.pathname+window.location.search,{route:o,params:s,query:i,path:a}=this.resolve(r);e.push({route:o,params:s,query:i,path:a}),t=0,this.handleRouteChange(o,s,i,a)}}function Nn(e,t){const n=new Map,r=new WeakMap,o=new WeakMap;let s=null,i=null;const a=(e,t)=>{const n=o.get(e);if(n)return n;let r=e;return h.isAnchor(e)||(r=p(t),r.appendChild(e)),o.set(e,r),r},u=()=>{h.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return h.isNDElement(e)&&(t=e.node()),t},d=function(e,n,o){const h=n.layout();if(h)return void((e,n,o,i)=>{let h=c(n);const p=r.get(h);if(p){if(p===s){const e=a(h,i);return u(),void e.replaceContent(h)}return l(),s=p,a(h,i).replaceContent(h),void t.appendChild(s)}l();const d=a(h,i);s=e(d),r.set(h,s),t.appendChild(s)})(h,e,0,o);let p=c(e);l(),t.appendChild(p),i=e},f=function(e){if(!e.route)return;const{route:t,params:r,query:o,path:s}=e;if(n.has(s)){const e=n.get(s);return void d(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),d(i,t,s)};return e.subscribe(f),f(e.currentState()),t}const kn="default";function Tn(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)En.apply(this,[]);else if("history"===e.mode)xn.apply(this,[]);else{if("memory"!==e.mode)throw new $n("Invalid router mode "+e.mode);Dn.apply(this,[])}const a=function(e,t){for(const r of s)try{r(e),t&&t(e)}catch(e){n.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,n,s){const i=new wn(Sn(o,e),n,{...s,middlewares:On(o,s?.middlewares||[]),name:s?.name?Cn(o,s.name):null,layout:s?.layout||An(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!h.isFunction(n))throw new $n("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},n={}){const o=r[e];if(!o)throw new $n(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(h.isJson(e)){const t=r[e.name];if(!t)throw new $n(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[n,o]=e.split("?"),s="/"+y(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new $n(`Route not found for url: ${n}`);const u={};if(o){const e=new URLSearchParams(o).entries();for(const[t,n]of e)u[t]=n}return{route:a,params:i,query:u,path:e}},this.subscribe=function(e){if(!h.isFunction(e))throw new $n("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function Fn(e,t){const{to:n,href:r,...o}=e;if(r){const e=Tn.get();return Ke({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||kn,a=Tn.get(i);if(!a)throw new $n('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ke({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Tn.routers={},Tn.create=function(e,t){if(!h.isFunction(t))throw n.error("Router","Callback must be a function"),new $n("Callback must be a function");const r=new Tn(e);return Tn.routers[e.name||kn]=r,t(r),r.init(e.entry),r.mount=function(e){if(h.isString(e)){const t=document.querySelector(e);if(!t)throw new $n(`Container not found for selector: ${e}`);e=t}else if(!h.isElement(e))throw new $n("Container must be a string or an Element");return Nn(r,e)},r},Tn.get=function(e){const t=Tn.routers[e||kn];if(!t)throw new $n(`Router not found for name: ${e}`);return t},Tn.push=function(e,t=null){return Tn.get(t).push(e)},Tn.replace=function(e,t=null){return Tn.get(t).replace(e)},Tn.forward=function(e=null){return Tn.get(e).forward()},Tn.back=function(e=null){return Tn.get(e).back()},Fn.blank=function(e,t){return Ke({...e,target:"_blank"},t)};var In=Object.freeze({__proto__:null,Link:Fn,RouteParamPatterns:vn,Router:Tn});var _n=Object.freeze({__proto__:null,memoize:e=>re(e),once:e=>ne(e),singleton:e=>te(e)}),Mn=Object.freeze({__proto__:null,Cache:_n,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};if(o)if(o instanceof FormData)i.body=o;else if("GET"!==n)i.headers["Content-Type"]="application/json",i.body=JSON.stringify(o);else{const e=new URLSearchParams(o).toString();e&&(r=r+(r.includes("?")?"&":"?")+e)}for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const u=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(u?.message||a.statusText);throw e.status=a.status,e.data=u,e}return u},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},filters:De});return e.$=k,e.ElementCreator=j,e.HtmlElementWrapper=J,e.LocalStorage=v,e.NDElement=i,e.Observable=N,e.PluginsManager=null,e.SingletonView=ee,e.Store=O,e.StoreFactory=S,e.TemplateCloner=Z,e.Validator=h,e.autoMemoize=re,e.autoOnce=ne,e.classPropertyAccumulator=function(e=[]){let t=h.isString(e)?e.split(" ").filter(Boolean):e;const n=h.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=function(e){return h.isObservable(e)?j.createObservableNode(null,e):j.createStaticTextNode(null,e)},e.cssPropertyAccumulator=function(e={}){let t=h.isString(e)?e.split(";").filter(Boolean):e;const n=h.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=gn,e.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n,s=t.get(r);if(s)return s;const i=e(...o);return t.set(r,i),i}},e.normalizeComponentArgs=z,e.obs=T,e.once=te,e.router=In,e.useCache=function(e){let t=null;const n=function(n){return t||(t=new Z(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new ee(e)),t.render(n)}},e.utils=Mn,e.withValidation=H,e}({});
package/index.js CHANGED
@@ -5,6 +5,7 @@ export { TemplateCloner, useCache } from './src/core/wrappers/TemplateCloner';
5
5
  export { SingletonView, useSingleton } from './src/core/wrappers/SingletonView';
6
6
  export { default as PluginsManager } from './src/core/utils/plugins-manager';
7
7
  export { default as Validator } from './src/core/utils/validator';
8
+ export { LocalStorage } from './src/core/utils/localstorage';
8
9
 
9
10
  import './src/core/utils/prototypes.js';
10
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.100",
3
+ "version": "1.0.101",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "eslint": "^9.33.0",
21
21
  "eslint-plugin-jsdoc": "^62.5.4",
22
22
  "magic-string": "^0.30.21",
23
- "rollup": "^4.53.3"
23
+ "rollup": "4.59.0"
24
24
  },
25
25
  "dependencies": {
26
26
  "i18next": "^25.8.0"
@@ -77,13 +77,13 @@ export function Route($path, $component, $options = {}) {
77
77
  *
78
78
  * @param {string} path
79
79
  */
80
- this.match = function(path) {
80
+ this.match = function(path) {
81
81
  path = '/'+trim(path, '/');
82
82
  const match = getPattern().exec(path);
83
83
  if(!match) return false;
84
84
  const params = {};
85
85
 
86
- getPattern().exec(path).forEach((value, index) => {
86
+ match.forEach((value, index) => {
87
87
  if(index < 1) return;
88
88
  const name = $paramsNames[index - 1];
89
89
  params[name] = value;
@@ -20,4 +20,4 @@ interface ServiceStatic {
20
20
  ): MemoizeProxy<(...args: Args) => T>;
21
21
  }
22
22
 
23
- export const Service: ServiceStatic;
23
+ export const Cache: ServiceStatic;