native-document 1.0.110 → 1.0.112

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}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]=new i(this.$element),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,a.delete(e),e=null,this};const a=new WeakMap;i.prototype.lifecycle=function(e){const t=this.$element;a.has(t)||a.set(t,s.watch(t));const n=a.get(t);return e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),n.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),n.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 u=1,l=3,c=8,h=11,p={[u]:!0,[l]:!0,[h]:!0,[c]:!0},d={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=>d.isObservable(e)||d.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&&p[e.nodeType],isDOMNode:e=>p[e.nodeType],isFragment:e=>e?.nodeType===h,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&&(d.isObject(e)&&Object.values(e).some(e=>d.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 f(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=t?()=>!0:e=>e.firstChild===o&&e.lastChild===s;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 o=s.parentNode;o?function(e,t,n){const o=d.isElement(t)?t:q.getChild(t);e!==r?i(e)&&n===s?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=s.parentNode;if(e===r)return;if(i(e))return void e.replaceChildren(o,s);let t,n=o.nextSibling;for(;n&&n!==s;)t=n.nextSibling,n.remove(),n=t},r.remove=function(){const e=s.parentNode;if(e===r)return;if(i(e))return void e.replaceChildren(o,s);let t,n=o.nextSibling;for(;n&&n!==s;)t=n.nextSibling,r.nativeAppend(n),n=t},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),s.remove()},r.replaceContent=function(e){const t=d.isElement(e)?e:q.getChild(e),n=s.parentNode;n&&(i(n)?n.replaceChildren(o,t,s):(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 m=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"]),b=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`)}}}(),y=function(e,t){this.$target=t,this.$observer=e};y.prototype.__$isObservableWhen=!0,y.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},y.prototype.val=function(){return this.$observer.$currentValue===this.$target},y.prototype.isMatch=y.prototype.val,y.prototype.isActive=y.prototype.val;const g=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},v=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},w=(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=>w(e));if(d.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=w(e[t]));return n},$={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)},S=(e,t)=>{if(!$.has(e))return t;switch(typeof t){case"object":return $.getJson(e)??t;case"boolean":return $.getBool(e)??t;case"number":return $.getNumber(e)??t;default:return $.get(e,t)??t}},O=e=>{switch(typeof e){case"object":return $.setJson;case"boolean":return $.setBool;default:return $.set}},C=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)?T.array(e,t):"object"==typeof e?T.object(e,t):T(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=T.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=C();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,S(n,t)),o=O(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,S(n,t)),o=O(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{$.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.")}})},A=C();A.create("locale",navigator.language.split("-")[0]||"en");const E=(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),{})}},x=(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)},D={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}=E(e,t);return x(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}=E(e,t);return x(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}=E(e,t);return x(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 N(e,t=null){e=d.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=d.isObject(e)?w(e):e))}Object.defineProperty(N.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),N.prototype.__$isObservable=!0;const k=function(){};function T(e,t=null){return new N(e,t)}N.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},N.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},N.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)},N.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)},N.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},N.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},N.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=k},N.prototype.trigger=k,N.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)},N.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)},N.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},N.prototype.set=N.prototype.$basicSet,N.prototype.val=function(){return this.$currentValue},N.prototype.disconnectAll=function(){this.$previousValue=null,this.$currentValue=null,this.$listeners=null,this.$watchers=null,this.trigger=k},N.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},N.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}b.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},N.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},N.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?d.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()},N.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()},N.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)},N.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},N.prototype.check=function(e){return new o(this,e)},N.prototype.transform=N.prototype.check,N.prototype.pluck=N.prototype.check,N.prototype.is=N.prototype.check,N.prototype.select=N.prototype.check,N.prototype.get=function(e){const t=this.$currentValue[e];return d.isObservable(t)?t.val():t},N.prototype.when=function(e){return new y(this,e)},N.prototype.equals=function(e){return d.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},N.prototype.toBool=function(){return!!this.$currentValue},N.prototype.toggle=function(){this.set(!this.$currentValue)},N.prototype.reset=function(){if(!this.configs?.reset)return;const e=d.isObject(this.$initialValue)?w(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},N.prototype.toString=function(){return String(this.$currentValue)},N.prototype.valueOf=function(){return this.$currentValue},N.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=D[e],s=D.locale;return T.computed(()=>r(n.val(),s.val(),t),[n,s])},N.prototype.persist=function(e,t={}){let n=S(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=O(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const I=T,F=T;function _(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 M(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 P(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(d.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 V(e){this.$hydrate=e}T.useValueProperty=function(e="value"){Object.defineProperty(N.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},T.getById=function(e){const t=b.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},T.cleanup=function(e){e.cleanup()},T.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{b.cleanup()}),setInterval(()=>b.cleanObservables(r),n)},V.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){return q.createStaticTextNode(null,this)},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},N.prototype.toNdElement=function(){return q.createObservableNode(null,this)},o.prototype.toNdElement=N.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=q.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return q.getChild(this())},V.prototype.toNdElement=function(){return q.createHydratableNode(null,this)};const L=(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",n=this.$element;return this.beforeUnmount("transition-exit",async function(){n.classes.add(t),await L(n),n.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to",r=this.$element;return r.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classes.remove(t),r.classes.add(n),L(r).then(()=>{r.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){const t=this.$element;return t.classes.add(e),L(t).then(()=>{t.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},N.prototype.handleNdAttribute=function(e,t){m.has(t)?P(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)},V.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const j=new Map;let R=null;const q={createTextNode:()=>(R||(R=document.createTextNode("")),R.cloneNode()),createObservableNode(e,t){const n=q.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=q.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=q.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=j.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return j.set(e,n),n.cloneNode()}return f("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(),d.isElement(e))return e}while(e.toNdElement);return q.createStaticTextNode(null,e)},processAttributes(e,t){t&&function(e,t){d.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){_(e,o);continue}if("style"===r){M(e,o);continue}}m.has(r)?P(e,r,o):e.setAttribute(r,o)}}}(e,t)}},W={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",W),Object.defineProperty(DocumentFragment.prototype,"nd",W),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 U(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return H(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 B(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const B=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},U=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},H=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},z={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,...z}}});let K=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 J=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 Y(e,t,n,r=null){let{props:o,children:s=null}=J(n,r),i=q.createElement(e),a=t&&"function"==typeof t?t(i):i;return q.processAttributes(a,o),q.processChildren(s,a),a}function G(e,t=null){return Y.bind(null,e,t)}const Q=new WeakMap,X=(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?(q.processAttributes(e,r),!0):null},Z=(e,t,n)=>{for(let r=0,o=t.attach.length;r<o;r++){const{methodName:o,fn:s}=t.attach[r];e.nd[o](function(...e){s.apply(this,[...e,...n])})}},ee=()=>{};function te(e){let t=null,n=!1;const r=[{id:0,parentId:null,fn:ee}];let o=0;const s=(e,t,n)=>{const i=Q.get(e);if(3===e.nodeType){if(i&&i.value){n.fn=i.value;const r=e.cloneNode();return"string"==typeof i.value?(q.bindTextNode(r,t[0][i.value]),r):(i.value(t,r),r)}return e.cloneNode(!0)}const a=e.cloneNode();if(i){X(a,i,t),Z(a,i,t);const e=i.classes||i.styles||i.attributes,r=i.attach.length;e&&r?n.fn=(e,t)=>{X(t,i,e),Z(t,i,e)}:e?n.fn=(e,t)=>{X(t,i,e)}:r&&(n.fn=(e,t)=>{Z(t,i,e)})}const u=e.childNodes,l=n.id;for(let e=0,i=u.length;e<i;e++){const i=u[e],c={parentId:l,id:++o,index:e,fn:ee},h=s(i,t,c);(c.hasChildren||c.fn)&&(r.unshift(c),n.hasChildren=!0),a.appendChild(h)}return a},i=e=>{let n=t.cloneNode(!0);return((e,t,n)=>{const r=n.at(-1),o=[];o[r.id]=e,t[0],(0,r.fn)(t,e,e);for(let r=0,s=n.length-1;r<s;r++){const s=n[r],i=o[s.parentId].childNodes[s.index];o[s.id]=i,(0,s.fn)(t,i,e)}o.length=0})(n,e,r),n};this.clone=o=>{if(t=e(this),!n)return this.clone=()=>t.cloneNode(!0),t.cloneNode(!0);const a=s(t,o,r[0]);return this.clone=i,a};const a=(e,t)=>new V((r,o)=>{n=!0,function(e,t,n,r){Q.has(n)||Q.set(n,{attach:[]});const o=Q.get(n);if("value"!==t){if("attach"===t)return o.attach=o.attach||[],void o.attach.push({methodName:r,fn:e});o[t]=o[t]||{},o[t][r]=e}else o.value=e}(e,t,r,o)});this.style=e=>a(e,"styles"),this.class=e=>a(e,"classes"),this.property=e=>this.value(e),this.value=e=>a("function"!=typeof e?(t,n)=>{q.bindTextNode(n,t[0][e])}:(t,n)=>{q.bindTextNode(n,e(...t))},"value"),this.text=this.value,this.attr=e=>a(e,"attributes"),this.attach=e=>a(e,"attach")}function ne(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=f("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 T.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return d.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return d.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!d.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return T.getById(n)}):this.valueOf()};const re=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},oe=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},se=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 ie(e){return e instanceof Date?e:new Date(e)}function ae(e,t){const n=ie(e),r=ie(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ue(e){const t=ie(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function le(e,t){const n=d.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function ce(e,t){const n=e.filter(d.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>d.isObservable(e)?e.val():e))}}function he(e){return le(e,(e,t)=>e===t)}function pe(e){return le(e,(e,t)=>e!==t)}function de(e){return le(e,(e,t)=>e>t)}function fe(e){return le(e,(e,t)=>e>=t)}function me(e){return le(e,(e,t)=>e<t)}function be(e){return le(e,(e,t)=>e<=t)}function ye(e,t=!0,n=""){return ce([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 ge(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(d.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ve(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(d.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const we=de,$e=fe,Se=me,Oe=be,Ce=he,Ae=pe,Ee=ge,xe=ve;function De(e,t=!1){return le(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const Ne=De;var ke=Object.freeze({__proto__:null,all:Ee,and:ge,any:xe,between:function(e,t){return ce([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:Ne,createFilter:le,createMultiSourceFilter:ce,custom:function(e,...t){const n=t.filter(d.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>d.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>le(e,(e,t)=>!(!e||!t)&&ie(e)>ie(t)),dateBefore:e=>le(e,(e,t)=>!(!e||!t)&&ie(e)<ie(t)),dateBetween:(e,t)=>ce([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),dateEquals:e=>le(e,(e,t)=>!(!e||!t)&&ae(e,t)),dateTimeAfter:e=>le(e,(e,t)=>!(!e||!t)&&ie(e)>ie(t)),dateTimeBefore:e=>le(e,(e,t)=>!(!e||!t)&&ie(e)<ie(t)),dateTimeBetween:(e,t)=>ce([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),dateTimeEquals:e=>le(e,(e,t)=>!(!e||!t)&&ie(e).getTime()===ie(t).getTime()),endsWith:function(e,t=!1){return le(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Ce,equals:he,getSecondsOfDay:ue,greaterThan:de,greaterThanOrEqual:fe,gt:we,gte:$e,inArray:function(e){return le(e,(e,t)=>t.includes(e))},includes:De,isEmpty:function(e=!0){return le(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return le(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:ae,lessThan:me,lessThanOrEqual:be,lt:Se,lte:Oe,match:ye,neq:Ae,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:pe,notIn:function(e){return le(e,(e,t)=>!t.includes(e))},or:ve,startsWith:function(e,t=!1){return le(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>le(e,(e,t)=>!(!e||!t)&&ue(e)>ue(t)),timeBefore:e=>le(e,(e,t)=>!(!e||!t)&&ue(e)<ue(t)),timeBetween:(e,t)=>ce([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ue(e);return r>=ue(t)&&r<=ue(n)}),timeEquals:e=>le(e,(e,t)=>{if(!e||!t)return!1;const n=ie(e),r=ie(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:ie});const Te=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");N.call(this,e,t)};(Te.prototype=Object.create(N.prototype)).constructor=Te,Te.prototype.__$isObservableArray=!0,Object.defineProperty(Te.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{Te.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=>{Te.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),Te.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},Te.prototype.at=function(e){return this.$currentValue[e]},Te.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},Te.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},Te.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},Te.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)},Te.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},Te.prototype.isEmpty=function(){return 0===this.$currentValue.length},Te.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},Te.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=d.isObservable(o)?ye(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=T.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},Te.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},Te.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},Te.prototype.deepSubscribe=function(e){const t=g(()=>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)}},T.array=function(e=[],t=null){return new Te(e,t)},T.batch=function(e){const t=T(0),n=function(){if(d.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const Ie=function(e,t){N.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)})};Ie.prototype=Object.create(N.prototype),Object.defineProperty(Ie,"$value",{get(){return this.val()},set(e){this.set(e)}}),Ie.prototype.__$isObservableObject=!0,Ie.prototype.__isProxy__=!0,Ie.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=>d.isJson(e)?T.json(e,t):d.isArray(e)?T.array(e,t):T(e,t));this.$observables[n]=T.array(e,t);continue}this.$observables[n]=T.array(r,t)}else d.isObservable(r)||d.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?T.object(r,t):T(r,t)}},Ie.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(d.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>d.isObservable(e)?e.val():d.isProxy(e)?e.$value:e)),e[t]=r}else d.isProxy(n)?e[t]=n.$value:e[t]=n}return e},Ie.prototype.$val=Ie.prototype.val,Ie.prototype.get=function(e){const t=this.$observables[e];return d.isObservable(t)?t.val():d.isProxy(t)?t.$value:t},Ie.prototype.$get=Ie.prototype.get,Ie.prototype.set=function(e){const t=d.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(d.isObservable(o)){if(!d.isArray(i)){o.set(i);continue}const e=s.at(0);if(d.isObservable(e)||d.isProxy(e)){const t=i.map(t=>d.isProxy(e)?T.init(t,n):T(t,n));o.set(t);continue}o.set([...i]);continue}d.isProxy(o)?o.update(i):this[r]=i}},Ie.prototype.$set=Ie.prototype.set,Ie.prototype.$updateWith=Ie.prototype.set,Ie.prototype.observables=function(){return Object.values(this.$observables)},Ie.prototype.$observables=Ie.prototype.observables,Ie.prototype.keys=function(){return Object.keys(this.$observables)},Ie.prototype.$keys=Ie.prototype.keys,Ie.prototype.clone=function(){return T.init(this.val(),this.configs)},Ie.prototype.$clone=Ie.prototype.clone,Ie.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},Ie.prototype.originalSubscribe=Ie.prototype.subscribe,Ie.prototype.subscribe=function(e){const t=this.observables(),n=g(()=>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)}},Ie.prototype.configs=function(){return this.configs},Ie.prototype.update=Ie.prototype.set,T.init=function(e,t=null){return new Ie(e,t)},T.arrayOfObject=function(e){return e.map(e=>T.object(e))},T.value=function(e){if(d.isObservable(e))return e.val();if(d.isProxy(e))return e.$value;if(d.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(T.value(r))}return t}return e},T.object=T.init,T.json=T.init,T.computed=function(e,t=[]){const n=new N(e()),o=g(()=>n.set(e()));if(d.isFunction(t)){if(!d.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{d.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Fe=new Set(["clear","push","unshift","replace"]);const _e=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!d.isObservable(e)&&!d.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=f("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=q.getChild(t),d.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Me=function(e,t,n=!0){if(!d.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=f("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=q.getChild(r),d.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]}})},Pe=function(e,t,n){if(!d.isObservable(e))throw new r("Toggle : condition must be an Observable");return Me(e,{true:t,false:n})},Ve=G("div"),Le=G("span"),je=G("label"),Re=G("p"),qe=Re,We=G("strong"),Be=G("h1"),Ue=G("h2"),He=G("h3"),ze=G("h4"),Ke=G("h5"),Je=G("h6"),Ye=G("br"),Ge=G("a"),Qe=G("pre"),Xe=G("code"),Ze=G("blockquote"),et=G("hr"),tt=G("em"),nt=G("small"),rt=G("mark"),ot=G("del"),st=G("ins"),it=G("sub"),at=G("sup"),ut=G("abbr"),lt=G("cite"),ct=G("q"),ht=G("dl"),pt=G("dt"),dt=G("dd"),ft=G("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}),mt=G("input"),bt=G("textarea"),yt=bt,gt=G("select"),vt=G("fieldset"),wt=G("option"),$t=G("legend"),St=G("datalist"),Ot=G("output"),Ct=G("progress"),At=G("meter"),Et=G("button"),xt=G("main"),Dt=G("section"),Nt=G("article"),kt=G("aside"),Tt=G("nav"),It=G("figure"),Ft=G("figcaption"),_t=G("header"),Mt=G("footer"),Pt=G("img"),Vt=function(e,t){return Pt({src:e,...t})},Lt=G("details"),jt=G("summary"),Rt=G("dialog"),qt=G("menu"),Wt=G("ol"),Bt=G("ul"),Ut=G("li"),Ht=Ut,zt=Wt,Kt=Bt,Jt=G("audio"),Yt=G("video"),Gt=G("source"),Qt=G("track"),Xt=G("canvas"),Zt=G("svg"),en=G("time"),tn=G("data"),nn=G("address"),rn=G("kbd"),on=G("samp"),sn=G("var"),an=G("wbr"),un=G("caption"),ln=G("table"),cn=G("thead"),hn=G("tfoot"),pn=G("tbody"),dn=G("tr"),fn=dn,mn=G("th"),bn=mn,yn=mn,gn=G("td"),vn=gn,wn=G("");var $n=Object.freeze({__proto__:null,Abbr:ut,Address:nn,Anchor:f,Article:Nt,Aside:kt,AsyncImg:function(e,t,n,o){const s=d.isObservable(e)?e.val():e,i=Vt(t||s,n),a=new Image;return a.onload=()=>{d.isFunction(o)&&o(null,i),i.src=d.isObservable(e)?e.val():e},a.onerror=()=>{d.isFunction(o)&&o(new r("Image not found"))},d.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Jt,BaseImage:Pt,Blockquote:Ze,Br:Ye,Button:Et,Canvas:Xt,Caption:un,Checkbox:e=>mt({type:"checkbox",...e}),Cite:lt,Code:Xe,ColorInput:e=>mt({type:"color",...e}),Data:tn,Datalist:St,DateInput:e=>mt({type:"date",...e}),DateTimeInput:e=>mt({type:"datetime-local",...e}),Dd:dt,Del:ot,Details:Lt,Dialog:Rt,Div:Ve,Dl:ht,Dt:pt,Em:tt,EmailInput:e=>mt({type:"email",...e}),FieldSet:vt,FigCaption:Ft,Figure:It,FileInput:e=>mt({type:"file",...e}),Footer:Mt,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=f("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=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)}},p=(e,s)=>{const i=((e,t,n)=>{if(d.isString(n)){const r=d.isObservable(e)?e.val():e,o=r?.[n];return d.isObservable(o)?o.val():o??t}return d.isFunction(n)?n(e,t):(d.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?T(s):null;let o=q.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=d.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=p(n[e],e);c.add(t)}else for(const e in n){const t=p(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),h(),void l?.clear();h(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(),d.isObservable(e)&&e.subscribe(m),i},ForEachArray:function(e,t,n={}){const r=f("ForEach Array",n.isParentUniqueChild),o=r.endElement(),s=r.startElement();let i=new Map,a=0;const u=t.length>=2,l=e=>{r.removeChildren(),g(e),a=0},c=e=>i.get(e)?.child,h=(e,t=!0)=>{const n=i.get(e);if(n){if(t){const t=n.child;t?.remove(),i.delete(e)}n.indexObserver?.cleanup()}},p=e=>{const n=q.getChild(t(e,null));return i.set(e,{child:n,indexObserver:null}),n},m=(e,n)=>{const r=T(n),o=q.getChild(t(e,r));return i.set(e,{child:o,indexObserver:r}),o},b=(e,t)=>{const n=i.get(e);return n?(n.indexObserver?.set(t),n.child):p(e)};let y=p;const g=e=>{if(u){if(!n.shouldKeepItemsInCache)for(const[t,n]of i.entries())e&&e.includes(t)||h(t,!1)}else i.clear()},v=function(e,t){const n=i.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},w={toFragment(e){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(y(e[n],a)),a++;return t},add(e){r.appendElement(w.toFragment(e))},replace(e){l(e),w.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=c(r),t&&n.appendChild(t);t=null,r.appendElement(n,o)},removeOne(e,t){h(e,!0)},clear:l,merge(e){w.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),w.add(e,t)},populate([e,t,n]){const o=document.createDocumentFragment();for(let r=0;r<t;r++){const t=n(r);e.push(t),o.append(y(t,r)),a++}r.appendChild(o),o.replaceChildren()},unshift(e){r.insertBefore(w.toFragment(e),s.nextSibling)},splice(e,t){const[n,s,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)v(e,u);else if(t.length>1){const e=c(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)v(t[e],u)}}else a=o;u.replaceChildren(),i&&i.length&&a&&r.insertBefore(w.toFragment(i),a.nextSibling)},reverse(e,t){w.reOrder(t)},sort(e,t){w.reOrder(t)},remove(e,t){w.removeOne(t)},pop(e,t){w.removeOne(t)},shift(e,t){w.removeOne(t)},swap(e,t){const n=o.parentNode;let r=c(t[0]),s=c(t[1]);if(!r||!s)return;const i=s.nextSibling;n.insertBefore(s,r),n.insertBefore(r,i),r=null,s=null}},$=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(((e=null)=>{y=Fe.has(e)?u?m:p:i.size?b:u?m:p})(n?.action),n?.action)w[n.action]&&w[n.action](n.args,n.result);else{if(0===a)return void w.add(e);w.replace(e)}((e,t=0)=>{if(!u)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=i.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===a)return;l()}};return e.val().length&&$(e.val(),0,{action:null}),d.isObservable(e)&&e.subscribe($),r},Form:ft,Fragment:wn,H1:Be,H2:Ue,H3:He,H4:ze,H5:Ke,H6:Je,Header:_t,HiddenInput:e=>mt({type:"hidden",...e}),HideIf:function(e,t,n){const r=T(!e.val());return e.subscribe(e=>r.set(!e)),_e(r,t,n)},HideIfNot:function(e,t,n){return _e(e,t,n)},Hr:et,Img:Vt,Input:mt,Ins:st,Kbd:rn,Label:je,LazyImg:function(e,t){return Vt(e,{...t,loading:"lazy"})},Legend:$t,Li:Ht,Link:Ge,ListItem:Ut,Main:xt,Mark:rt,Match:Me,Menu:qt,Meter:At,MonthInput:e=>mt({type:"month",...e}),NativeDocumentFragment:f,Nav:Tt,NumberInput:e=>mt({type:"number",...e}),Ol:zt,Option:wt,OrderedList:Wt,Output:Ot,P:Re,Paragraph:qe,PasswordInput:e=>mt({type:"password",...e}),Pre:Qe,Progress:Ct,Quote:ct,Radio:e=>mt({type:"radio",...e}),RangeInput:e=>mt({type:"range",...e}),ReadonlyInput:e=>mt({readonly:!0,...e}),Samp:on,SearchInput:e=>mt({type:"search",...e}),Section:Dt,Select:gt,ShowIf:_e,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!d.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return _e(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!d.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return _e(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)=>Et(e,{type:"button",...t}),Small:nt,Source:Gt,Span:Le,Strong:We,Sub:it,SubmitButton:(e,t)=>Et(e,{type:"submit",...t}),Summary:jt,Sup:at,Svg:Zt,Switch:Pe,TBody:pn,TBodyCell:vn,TFoot:hn,TFootCell:yn,THead:cn,THeadCell:bn,TRow:fn,Table:ln,Td:gn,TelInput:e=>mt({type:"tel",...e}),TextArea:bt,TextInput:yt,Th:mn,Time:en,TimeInput:e=>mt({type:"time",...e}),Tr:dn,Track:Qt,Ul:Kt,UnorderedList:Bt,UrlInput:e=>mt({type:"url",...e}),Var:sn,Video:Yt,Wbr:an,WeekInput:e=>mt({type:"week",...e}),When:function(e){if(!d.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,Pe(e,t,n)),toNdElement:()=>Pe(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=f("Portal "+n);return r.appendChild(q.getChild(e)),(t||document.body).appendChild(r),r}});const Sn={};function On(e,t,n={}){e="/"+v(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=Sn[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="/"+v(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 Cn extends Error{constructor(e,t){super(e),this.context=t}}const An=(e,t)=>{const n=[];return e.forEach(e=>{n.push(v(e.suffix,"/"))}),n.push(v(t,"/")),n.join("/")},En=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},xn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Dn=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Nn(){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 kn(){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 Tn(){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 In(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 d.isAnchor(e)||(r=f(t),r.appendChild(e)),o.set(e,r),r},u=()=>{d.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return d.isNDElement(e)&&(t=e.node()),t},h=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=q.getChild(e(d)),r.set(h,s),t.appendChild(s)})(h,e,0,o);let p=c(e);l(),t.appendChild(p),i=e},p=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 h(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),h(i,t,s)};return e.subscribe(p),p(e.currentState()),t}const Fn="default";function _n(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Nn.apply(this,[]);else if("history"===e.mode)kn.apply(this,[]);else{if("memory"!==e.mode)throw new Cn("Invalid router mode "+e.mode);Tn.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 On(An(o,e),n,{...s,middlewares:En(o,s?.middlewares||[]),name:s?.name?xn(o,s.name):null,layout:s?.layout||Dn(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!d.isFunction(n))throw new Cn("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 Cn(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(d.isJson(e)){const t=r[e.name];if(!t)throw new Cn(`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="/"+v(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Cn(`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(!d.isFunction(e))throw new Cn("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 Mn(e,t){const{to:n,href:r,...o}=e;if(r){const e=_n.get();return Ge({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||Fn,a=_n.get(i);if(!a)throw new Cn('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ge({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}_n.routers={},_n.create=function(e,t){if(!d.isFunction(t))throw n.error("Router","Callback must be a function"),new Cn("Callback must be a function");const r=new _n(e);return _n.routers[e.name||Fn]=r,t(r),r.init(e.entry),r.mount=function(e){if(d.isString(e)){const t=document.querySelector(e);if(!t)throw new Cn(`Container not found for selector: ${e}`);e=t}else if(!d.isElement(e))throw new Cn("Container must be a string or an Element");return In(r,e)},r},_n.get=function(e){const t=_n.routers[e||Fn];if(!t)throw new Cn(`Router not found for name: ${e}`);return t},_n.push=function(e,t=null){return _n.get(t).push(e)},_n.replace=function(e,t=null){return _n.get(t).replace(e)},_n.forward=function(e=null){return _n.get(e).forward()},_n.back=function(e=null){return _n.get(e).back()},_n.redirectTo=function(e,t=null,n=null){let r=e;const o=_n.get(n);return o.resolve({name:e,params:t})&&(r={name:e,params:t}),console.log(r),o.push(r)},Mn.blank=function(e,t){return Ge({...e,target:"_blank"},t)};var Pn=Object.freeze({__proto__:null,Link:Mn,RouteParamPatterns:Sn,Router:_n});var Vn=Object.freeze({__proto__:null,memoize:e=>se(e),once:e=>oe(e),singleton:e=>re(e)}),Ln=Object.freeze({__proto__:null,Cache:Vn,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:ke});return e.$=I,e.ElementCreator=q,e.HtmlElementWrapper=G,e.NDElement=i,e.Observable=T,e.PluginsManager=null,e.SingletonView=ne,e.Store=A,e.StoreFactory=C,e.TemplateCloner=te,e.Validator=d,e.autoMemoize=se,e.autoOnce=oe,e.classPropertyAccumulator=function(e=[]){let t=d.isString(e)?e.split(" ").filter(Boolean):e;const n=d.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=function(e){return d.isObservable(e)?q.createObservableNode(null,e):q.createStaticTextNode(null,e)},e.cssPropertyAccumulator=function(e={}){let t=d.isString(e)?e.split(";").filter(Boolean):e;const n=d.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=$n,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=J,e.obs=F,e.once=re,e.router=Pn,e.useCache=function(e){let t=null,n=function(r){return t=new te(e),n=function(e){return t.clone(e)},t.clone(r)};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 ne(e)),t.render(n)}},e.utils=Ln,e.withValidation=K,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}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]=new i(this.$element),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,a.delete(e),e=null,this};const a=new WeakMap;i.prototype.lifecycle=function(e){const t=this.$element;a.has(t)||a.set(t,s.watch(t));const n=a.get(t);return e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),n.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),n.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 u=3,l=8,c=11,h=[];h[1]=!0,h[u]=!0,h[c]=!0,h[l]=!0;const p={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=>p.isObservable(e)||p.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&&h[e.nodeType],isDOMNode:e=>h[e.nodeType],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&&(p.isObject(e)&&Object.values(e).some(e=>p.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 d(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=t?()=>!0:e=>e.firstChild===o&&e.lastChild===s;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 o=s.parentNode;o?function(e,t,n){const o=p.isElement(t)?t:q.getChild(t);e!==r?i(e)&&n===s?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=s.parentNode;if(e===r)return;if(i(e))return void e.replaceChildren(o,s);let t,n=o.nextSibling;for(;n&&n!==s;)t=n.nextSibling,n.remove(),n=t},r.remove=function(){const e=s.parentNode;if(e===r)return;if(i(e))return void e.replaceChildren(o,s);let t,n=o.nextSibling;for(;n&&n!==s;)t=n.nextSibling,r.nativeAppend(n),n=t},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),s.remove()},r.replaceContent=function(e){const t=p.isElement(e)?e:q.getChild(e),n=s.parentNode;n&&(i(n)?n.replaceChildren(o,t,s):(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 f=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"]),m=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`)}}}(),b=function(e,t){this.$target=t,this.$observer=e};b.prototype.__$isObservableWhen=!0,b.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},b.prototype.val=function(){return this.$observer.$currentValue===this.$target},b.prototype.isMatch=b.prototype.val,b.prototype.isActive=b.prototype.val;const y=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},g=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},v=(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=>v(e));if(p.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=v(e[t]));return n},w={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)},$=(e,t)=>{if(!w.has(e))return t;switch(typeof t){case"object":return w.getJson(e)??t;case"boolean":return w.getBool(e)??t;case"number":return w.getNumber(e)??t;default:return w.get(e,t)??t}},S=e=>{switch(typeof e){case"object":return w.setJson;case"boolean":return w.setBool;default:return w.set}},C=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)?x.array(e,t):"object"==typeof e?x.object(e,t):x(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=x.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=C();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,$(n,t)),o=S(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,$(n,t)),o=S(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{w.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=C();O.create("locale",navigator.language.split("-")[0]||"en");const A=(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),{})}},E=(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)},D={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}=A(e,t);return E(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}=A(e,t);return E(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}=A(e,t);return E(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 _(e,t=null){e=p.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=p.isObject(e)?v(e):e))}Object.defineProperty(_.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),_.prototype.__$isObservable=!0;const T=function(){};function x(e,t=null){return new _(e,t)}_.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},_.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},_.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)},_.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)},_.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},_.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},_.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=T},_.prototype.trigger=T,_.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)},_.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)},_.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},_.prototype.set=_.prototype.$basicSet,_.prototype.val=function(){return this.$currentValue},_.prototype.disconnectAll=function(){this.$previousValue=null,this.$currentValue=null,this.$listeners=null,this.$watchers=null,this.trigger=T},_.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},_.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}m.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},_.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},_.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?p.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()},_.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()},_.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)},_.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},_.prototype.check=function(e){return new o(this,e)},_.prototype.transform=_.prototype.check,_.prototype.pluck=_.prototype.check,_.prototype.is=_.prototype.check,_.prototype.select=_.prototype.check,_.prototype.get=function(e){const t=this.$currentValue[e];return p.isObservable(t)?t.val():t},_.prototype.when=function(e){return new b(this,e)},_.prototype.equals=function(e){return p.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},_.prototype.toBool=function(){return!!this.$currentValue},_.prototype.toggle=function(){this.set(!this.$currentValue)},_.prototype.reset=function(){if(!this.configs?.reset)return;const e=p.isObject(this.$initialValue)?v(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},_.prototype.toString=function(){return String(this.$currentValue)},_.prototype.valueOf=function(){return this.$currentValue},_.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=D[e],s=D.locale;return x.computed(()=>r(n.val(),s.val(),t),[n,s])},_.prototype.persist=function(e,t={}){let n=$(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=S(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const N=x,k=x;function I(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 F(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 L(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(p.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,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){I(e,o);continue}if("style"===r){F(e,o);continue}}f.has(r)?L(e,r,o):e.setAttribute(r,o)}}return e}function P(e){this.$hydrate=e}x.useValueProperty=function(e="value"){Object.defineProperty(_.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},x.getById=function(e){const t=m.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},x.cleanup=function(e){e.cleanup()},x.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{m.cleanup()}),setInterval(()=>m.cleanObservables(r),n)},P.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){return q.createStaticTextNode(null,this)},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},_.prototype.toNdElement=function(){return q.createObservableNode(null,this)},o.prototype.toNdElement=_.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=q.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return q.getChild(this())},P.prototype.toNdElement=function(){return q.createHydratableNode(null,this)};const V=(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",n=this.$element;return this.beforeUnmount("transition-exit",async function(){n.classes.add(t),await V(n),n.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to",r=this.$element;return r.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classes.remove(t),r.classes.add(n),V(r).then(()=>{r.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){const t=this.$element;return t.classes.add(e),V(t).then(()=>{t.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},_.prototype.handleNdAttribute=function(e,t){f.has(t)?L(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)},P.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const R=new Map;let j=null;const q={createTextNode:()=>(j||(j=document.createTextNode("")),j.cloneNode()),createObservableNode(e,t){const n=q.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=q.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=q.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=R.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return R.set(e,n),n.cloneNode()}return d("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(),p.isElement(e))return e}while(e.toNdElement);return q.createStaticTextNode(null,e)},processAttributes(e,t){t&&M(e,t)},processAttributesDirect:M,processClassAttribute:I,processStyleAttribute:F},W={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",W),Object.defineProperty(DocumentFragment.prototype,"nd",W),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 U(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return H(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 B(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const B=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},U=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},H=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},z={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,...z}}});let Y=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 K=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 J(e,t,n,r=null){let{props:o,children:s=null}=K(n,r),i=q.createElement(e),a=t&&"function"==typeof t?t(i):i;return q.processAttributes(a,o),q.processChildren(s,a),a}function X(e,t=null){return J.bind(null,e,t)}const G=new WeakMap,Q=(e,t,n)=>{if(t.HYDRATE_TEXT){const r=t.value;return void q.bindTextNode(e,t.isString?n[0][r]:r.apply(null,n))}if(t.ATTACH_METHOD){const r=t.bindingData;for(let t=0,o=r._attachLength;t<o;t++){const o=r.attach[t];e.nd[o.methodName](function(){o.fn.call(this,...n,...arguments)})}}t.HYDRATE_ATTRIBUTES&&t.hydrator(e,t.bindingData,n)},Z=(e,t,n)=>{for(let r=0,o=t._attachLength;r<o;r++){const o=t.attach[r];e.nd[o.methodName](function(){o.fn.call(this,...n,...arguments)})}},ee=[],te=(e,t,n,r)=>{const o=n[r];ee[o.id]=e,Q(e,o,t);let s=null,i=null;for(let e=0;e<r;e++){if(i=n[e],s=ee[i.parentId].childNodes[i.index],ee[i.id]=s,i.HYDRATE_TEXT){const e=i.value;q.bindTextNode(s,i.isString?t[0][e]:e.apply(null,t));continue}if(i.ATTACH_METHOD){const e=i.bindingData;for(let n=0,r=e._attachLength;n<r;n++){const r=e.attach[n];s.nd[r.methodName](function(){r.fn.call(this,...t,...arguments)})}}i.HYDRATE_ATTRIBUTES&&i.hydrator(s,i.bindingData,t)}for(let e=0;e<=r;e++)ee[e]=null},ne=(e,t,n)=>{const r=t._cache;for(let e=0,o=t._flatAttributesLength;e<o;e++){const o=t._flatAttributes[e];r[o.name]=o.value.apply(null,n)}for(let e=0,o=t._flatDynamiqueLength;e<o;e++){const o=t._flatDynamique[e];r[o.name][o.key]=o.value.apply(null,n)}return q.processAttributesDirect(e,r),!0},re=(e,t,n)=>{const r=t._cache;for(let e=0,o=t._flatDynamiqueLength;e<o;e++){const o=t._flatDynamique[e];r[o.name][o.key]=o.value.apply(null,n)}return q.processClassAttribute(e,r.class),q.processStyleAttribute(e,r.style),!0},oe=(e,t,n)=>{const r=t._cache.class;for(let e=0,o=t._flatDynamiqueLength;e<o;e++){const o=t._flatDynamique[e];r[o.key]=o.value.apply(null,n)}return q.processClassAttribute(e,r),!0},se=(e,t,n)=>{const r=t._cache;for(let e=0,o=t._flatDynamiqueLength;e<o;e++){const o=t._flatDynamique[e];r[o.key]=o.value.apply(null,n)}return q.processStyleAttribute(e,r),!0},ie=(e,t,n)=>{const r=t._cache;for(let e=0,o=t._flatAttributesLength;e<o;e++){const o=t._flatAttributes[e];r[o.name]=o.value.apply(null,n)}return q.processAttributesDirect(e,r),!0};function ae(e){let t=null,n=!1,r=0;const o=[{id:0,parentId:null}];let s=0;const i=(e,t,n)=>{const r=G.get(e);if(r&&(e=>{(e=>{const t={};e.attributes&&(t.attributes={}),e.classes&&(t.class={}),e.styles&&(t.style={}),e._cache=t})(e),(e=>{const t=[],n=[];if(e.attributes)for(const n in e.attributes)t.push({name:n,value:e.attributes[n]});if(e.classes)for(const t in e.classes)e._hasClassAttribute=!0,n.push({name:"class",key:t,value:e.classes[t]});if(e.styles)for(const t in e.styles)e._hasStyleAttribute=!0,n.push({name:"style",key:t,value:e.styles[t]});e._flatAttributes=t,e._flatAttributesLength=t.length,e._flatDynamique=n,e._flatDynamiqueLength=n.length,e._attachLength=e.attach.length})(e)})(r),3===e.nodeType){if(r&&r.value){const o=r.value,s=e.cloneNode();return n.value=o,n.HYDRATE_TEXT=!0,n.operation=!0,n.isString="string"==typeof o,q.bindTextNode(s,n.isString?t[0][o]:o.apply(null,t)),s}return e.cloneNode(!0)}const a=e.cloneNode();if(r){const e=(e=>e._cache?e._flatAttributesLength&&e._flatDynamiqueLength?ne:e._flatAttributesLength?ie:e._hasClassAttribute&&e._hasStyleAttribute?re:e._hasClassAttribute?oe:se:noUpdate)(r);e(a,r,t),Z(a,r,t);const o=r.classes||r.styles||r.attributes,s=r.attach.length;n.bindingData=r,n.hydrator=e,o&&(n.HYDRATE_ATTRIBUTES=!0,n.operation=!0),s&&(n.ATTACH_METHOD=!0,n.operation=!0)}const u=e.childNodes,l=n.id;for(let e=0,r=u.length;e<r;e++){const r=u[e],c={parentId:l,id:++s,index:e},h=i(r,t,c);(c.hasChildren||c.operation)&&(o.push(c),n.hasChildren=!0),a.appendChild(h)}return a},a=e=>{let n=t.cloneNode(!0);return te(n,e,o,r),n};this.clone=s=>{const u=new Proxy(this,{get:(e,t)=>t in e||"symbol"==typeof t?e[t]:e.value(t)});if(t=e(u),!n)return this.clone=()=>t.cloneNode(!0),t.cloneNode(!0);const l=i(t,s,o[0]);return o.reverse(),r=o.length-1,this.clone=a,l};const u=(e,t)=>new P((r,o)=>{n=!0,function(e,t,n,r){G.has(n)||G.set(n,{attach:[]});const o=G.get(n);if("value"!==t){if("attach"===t)return o.attach=o.attach||[],void o.attach.push({methodName:r,fn:e});o[t]=o[t]||{},o[t][r]=e}else o.value=e}(e,t,r,o)});this.style=e=>u(e,"styles"),this.class=e=>u(e,"classes"),this.property=e=>this.value(e),this.value=e=>u(e,"value"),this.text=this.value,this.attr=e=>u(e,"attributes"),this.attach=e=>u(e,"attach"),this.callback=this.attach}function ue(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=d("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 x.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return p.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return p.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!p.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return x.getById(n)}):this.valueOf()};const le=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},ce=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},he=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 pe(e){return e instanceof Date?e:new Date(e)}function de(e,t){const n=pe(e),r=pe(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function fe(e){const t=pe(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function me(e,t){const n=p.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function be(e,t){const n=e.filter(p.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>p.isObservable(e)?e.val():e))}}function ye(e){return me(e,(e,t)=>e===t)}function ge(e){return me(e,(e,t)=>e!==t)}function ve(e){return me(e,(e,t)=>e>t)}function we(e){return me(e,(e,t)=>e>=t)}function $e(e){return me(e,(e,t)=>e<t)}function Se(e){return me(e,(e,t)=>e<=t)}function Ce(e,t=!0,n=""){return be([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 Oe(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(p.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function Ae(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(p.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const Ee=ve,De=we,_e=$e,Te=Se,xe=ye,Ne=ge,ke=Oe,Ie=Ae;function Fe(e,t=!1){return me(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const Le=Fe;var Me=Object.freeze({__proto__:null,all:ke,and:Oe,any:Ie,between:function(e,t){return be([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:Le,createFilter:me,createMultiSourceFilter:be,custom:function(e,...t){const n=t.filter(p.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>p.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>me(e,(e,t)=>!(!e||!t)&&pe(e)>pe(t)),dateBefore:e=>me(e,(e,t)=>!(!e||!t)&&pe(e)<pe(t)),dateBetween:(e,t)=>be([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=pe(e);return r>=pe(t)&&r<=pe(n)}),dateEquals:e=>me(e,(e,t)=>!(!e||!t)&&de(e,t)),dateTimeAfter:e=>me(e,(e,t)=>!(!e||!t)&&pe(e)>pe(t)),dateTimeBefore:e=>me(e,(e,t)=>!(!e||!t)&&pe(e)<pe(t)),dateTimeBetween:(e,t)=>be([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=pe(e);return r>=pe(t)&&r<=pe(n)}),dateTimeEquals:e=>me(e,(e,t)=>!(!e||!t)&&pe(e).getTime()===pe(t).getTime()),endsWith:function(e,t=!1){return me(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:xe,equals:ye,getSecondsOfDay:fe,greaterThan:ve,greaterThanOrEqual:we,gt:Ee,gte:De,inArray:function(e){return me(e,(e,t)=>t.includes(e))},includes:Fe,isEmpty:function(e=!0){return me(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return me(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:de,lessThan:$e,lessThanOrEqual:Se,lt:_e,lte:Te,match:Ce,neq:Ne,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:ge,notIn:function(e){return me(e,(e,t)=>!t.includes(e))},or:Ae,startsWith:function(e,t=!1){return me(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>me(e,(e,t)=>!(!e||!t)&&fe(e)>fe(t)),timeBefore:e=>me(e,(e,t)=>!(!e||!t)&&fe(e)<fe(t)),timeBetween:(e,t)=>be([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=fe(e);return r>=fe(t)&&r<=fe(n)}),timeEquals:e=>me(e,(e,t)=>{if(!e||!t)return!1;const n=pe(e),r=pe(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:pe});const Pe=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");_.call(this,e,t)};(Pe.prototype=Object.create(_.prototype)).constructor=Pe,Pe.prototype.__$isObservableArray=!0,Object.defineProperty(Pe.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{Pe.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=>{Pe.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),Pe.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},Pe.prototype.at=function(e){return this.$currentValue[e]},Pe.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},Pe.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},Pe.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},Pe.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)},Pe.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},Pe.prototype.isEmpty=function(){return 0===this.$currentValue.length},Pe.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},Pe.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=p.isObservable(o)?Ce(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=x.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},Pe.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},Pe.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},Pe.prototype.deepSubscribe=function(e){const t=y(()=>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)}},x.array=function(e=[],t=null){return new Pe(e,t)},x.batch=function(e){const t=x(0),n=function(){if(p.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const Ve=function(e,t){_.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)})};Ve.prototype=Object.create(_.prototype),Object.defineProperty(Ve,"$value",{get(){return this.val()},set(e){this.set(e)}}),Ve.prototype.__$isObservableObject=!0,Ve.prototype.__isProxy__=!0,Ve.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=>p.isJson(e)?x.json(e,t):p.isArray(e)?x.array(e,t):x(e,t));this.$observables[n]=x.array(e,t);continue}this.$observables[n]=x.array(r,t)}else p.isObservable(r)||p.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?x.object(r,t):x(r,t)}},Ve.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(p.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>p.isObservable(e)?e.val():p.isProxy(e)?e.$value:e)),e[t]=r}else p.isProxy(n)?e[t]=n.$value:e[t]=n}return e},Ve.prototype.$val=Ve.prototype.val,Ve.prototype.get=function(e){const t=this.$observables[e];return p.isObservable(t)?t.val():p.isProxy(t)?t.$value:t},Ve.prototype.$get=Ve.prototype.get,Ve.prototype.set=function(e){const t=p.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(p.isObservable(o)){if(!p.isArray(i)){o.set(i);continue}const e=s.at(0);if(p.isObservable(e)||p.isProxy(e)){const t=i.map(t=>p.isProxy(e)?x.init(t,n):x(t,n));o.set(t);continue}o.set([...i]);continue}p.isProxy(o)?o.update(i):this[r]=i}},Ve.prototype.$set=Ve.prototype.set,Ve.prototype.$updateWith=Ve.prototype.set,Ve.prototype.observables=function(){return Object.values(this.$observables)},Ve.prototype.$observables=Ve.prototype.observables,Ve.prototype.keys=function(){return Object.keys(this.$observables)},Ve.prototype.$keys=Ve.prototype.keys,Ve.prototype.clone=function(){return x.init(this.val(),this.configs)},Ve.prototype.$clone=Ve.prototype.clone,Ve.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},Ve.prototype.originalSubscribe=Ve.prototype.subscribe,Ve.prototype.subscribe=function(e){const t=this.observables(),n=y(()=>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)}},Ve.prototype.configs=function(){return this.configs},Ve.prototype.update=Ve.prototype.set,x.init=function(e,t=null){return new Ve(e,t)},x.arrayOfObject=function(e){return e.map(e=>x.object(e))},x.value=function(e){if(p.isObservable(e))return e.val();if(p.isProxy(e))return e.$value;if(p.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(x.value(r))}return t}return e},x.object=x.init,x.json=x.init,x.computed=function(e,t=[]){const n=new _(e()),o=y(()=>n.set(e()));if(p.isFunction(t)){if(!p.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{p.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Re=new Set(["clear","push","unshift","replace"]);const je=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!p.isObservable(e)&&!p.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=d("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=q.getChild(t),p.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},qe=function(e,t,n=!0){if(!p.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=d("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=q.getChild(r),p.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]}})},We=function(e,t,n){if(!p.isObservable(e))throw new r("Toggle : condition must be an Observable");return qe(e,{true:t,false:n})},Be=X("div"),Ue=X("span"),He=X("label"),ze=X("p"),Ye=ze,Ke=X("strong"),Je=X("h1"),Xe=X("h2"),Ge=X("h3"),Qe=X("h4"),Ze=X("h5"),et=X("h6"),tt=X("br"),nt=X("a"),rt=X("pre"),ot=X("code"),st=X("blockquote"),it=X("hr"),at=X("em"),ut=X("small"),lt=X("mark"),ct=X("del"),ht=X("ins"),pt=X("sub"),dt=X("sup"),ft=X("abbr"),mt=X("cite"),bt=X("q"),yt=X("dl"),gt=X("dt"),vt=X("dd"),wt=X("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}),$t=X("input"),St=X("textarea"),Ct=St,Ot=X("select"),At=X("fieldset"),Et=X("option"),Dt=X("legend"),_t=X("datalist"),Tt=X("output"),xt=X("progress"),Nt=X("meter"),kt=X("button"),It=X("main"),Ft=X("section"),Lt=X("article"),Mt=X("aside"),Pt=X("nav"),Vt=X("figure"),Rt=X("figcaption"),jt=X("header"),qt=X("footer"),Wt=X("img"),Bt=function(e,t){return Wt({src:e,...t})},Ut=X("details"),Ht=X("summary"),zt=X("dialog"),Yt=X("menu"),Kt=X("ol"),Jt=X("ul"),Xt=X("li"),Gt=Xt,Qt=Kt,Zt=Jt,en=X("audio"),tn=X("video"),nn=X("source"),rn=X("track"),on=X("canvas"),sn=X("svg"),an=X("time"),un=X("data"),ln=X("address"),cn=X("kbd"),hn=X("samp"),pn=X("var"),dn=X("wbr"),fn=X("caption"),mn=X("table"),bn=X("thead"),yn=X("tfoot"),gn=X("tbody"),vn=X("tr"),wn=vn,$n=X("th"),Sn=$n,Cn=$n,On=X("td"),An=On,En=X("");var Dn=Object.freeze({__proto__:null,Abbr:ft,Address:ln,Anchor:d,Article:Lt,Aside:Mt,AsyncImg:function(e,t,n,o){const s=p.isObservable(e)?e.val():e,i=Bt(t||s,n),a=new Image;return a.onload=()=>{p.isFunction(o)&&o(null,i),i.src=p.isObservable(e)?e.val():e},a.onerror=()=>{p.isFunction(o)&&o(new r("Image not found"))},p.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:en,BaseImage:Wt,Blockquote:st,Br:tt,Button:kt,Canvas:on,Caption:fn,Checkbox:e=>$t({type:"checkbox",...e}),Cite:mt,Code:ot,ColorInput:e=>$t({type:"color",...e}),Data:un,Datalist:_t,DateInput:e=>$t({type:"date",...e}),DateTimeInput:e=>$t({type:"datetime-local",...e}),Dd:vt,Del:ct,Details:Ut,Dialog:zt,Div:Be,Dl:yt,Dt:gt,Em:at,EmailInput:e=>$t({type:"email",...e}),FieldSet:At,FigCaption:Rt,Figure:Vt,FileInput:e=>$t({type:"file",...e}),Footer:qt,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=d("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=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(p.isString(n)){const r=p.isObservable(e)?e.val():e,o=r?.[n];return p.isObservable(o)?o.val():o??t}return p.isFunction(n)?n(e,t):(p.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?x(s):null;let o=q.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=p.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(),h(),void l?.clear();h(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(),p.isObservable(e)&&e.subscribe(m),i},ForEachArray:function(e,t,n={}){const r=d("ForEach Array",n.isParentUniqueChild),o=r.endElement(),s=r.startElement();let i=new Map,a=0;const u=t.length>=2,l=e=>{r.removeChildren(),g(e),a=0},c=e=>i.get(e)?.child,h=(e,t=!0)=>{const n=i.get(e);if(n){if(t){const t=n.child;t?.remove(),i.delete(e)}n.indexObserver?.cleanup()}},f=e=>{const n=q.getChild(t(e,null));return i.set(e,{child:n,indexObserver:null}),n},m=(e,n)=>{const r=x(n),o=q.getChild(t(e,r));return i.set(e,{child:o,indexObserver:r}),o},b=(e,t)=>{const n=i.get(e);return n?(n.indexObserver?.set(t),n.child):f(e)};let y=f;const g=e=>{if(u){if(!n.shouldKeepItemsInCache)for(const[t,n]of i.entries())e&&e.includes(t)||h(t,!1)}else i.clear()},v=function(e,t){const n=i.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},w={toFragment(e){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(y(e[n],a)),a++;return t},add(e){r.appendElement(w.toFragment(e))},replace(e){l(e),w.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=c(r),t&&n.appendChild(t);t=null,r.appendElement(n,o)},removeOne(e,t){h(e,!0)},clear:l,merge(e){w.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),w.add(e,t)},populate([e,t,n]){const o=document.createDocumentFragment();for(let r=0;r<t;r++){const t=n(r);e.push(t),o.append(y(t,r)),a++}r.appendChild(o),o.replaceChildren()},unshift(e){r.insertBefore(w.toFragment(e),s.nextSibling)},splice(e,t){const[n,s,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)v(e,u);else if(t.length>1){const e=c(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)v(t[e],u)}}else a=o;u.replaceChildren(),i&&i.length&&a&&r.insertBefore(w.toFragment(i),a.nextSibling)},reverse(e,t){w.reOrder(t)},sort(e,t){w.reOrder(t)},remove(e,t){w.removeOne(t)},pop(e,t){w.removeOne(t)},shift(e,t){w.removeOne(t)},swap(e,t){const n=o.parentNode;let r=c(t[0]),s=c(t[1]);if(!r||!s)return;const i=s.nextSibling;n.insertBefore(s,r),n.insertBefore(r,i),r=null,s=null}},$=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(((e=null)=>{y=Re.has(e)?u?m:f:i.size?b:u?m:f})(n?.action),n?.action)w[n.action]&&w[n.action](n.args,n.result);else{if(0===a)return void w.add(e);w.replace(e)}((e,t=0)=>{if(!u)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=i.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===a)return;l()}};return e.val().length&&$(e.val(),0,{action:null}),p.isObservable(e)&&e.subscribe($),r},Form:wt,Fragment:En,H1:Je,H2:Xe,H3:Ge,H4:Qe,H5:Ze,H6:et,Header:jt,HiddenInput:e=>$t({type:"hidden",...e}),HideIf:function(e,t,n){const r=x(!e.val());return e.subscribe(e=>r.set(!e)),je(r,t,n)},HideIfNot:function(e,t,n){return je(e,t,n)},Hr:it,Img:Bt,Input:$t,Ins:ht,Kbd:cn,Label:He,LazyImg:function(e,t){return Bt(e,{...t,loading:"lazy"})},Legend:Dt,Li:Gt,Link:nt,ListItem:Xt,Main:It,Mark:lt,Match:qe,Menu:Yt,Meter:Nt,MonthInput:e=>$t({type:"month",...e}),NativeDocumentFragment:d,Nav:Pt,NumberInput:e=>$t({type:"number",...e}),Ol:Qt,Option:Et,OrderedList:Kt,Output:Tt,P:ze,Paragraph:Ye,PasswordInput:e=>$t({type:"password",...e}),Pre:rt,Progress:xt,Quote:bt,Radio:e=>$t({type:"radio",...e}),RangeInput:e=>$t({type:"range",...e}),ReadonlyInput:e=>$t({readonly:!0,...e}),Samp:hn,SearchInput:e=>$t({type:"search",...e}),Section:Ft,Select:Ot,ShowIf:je,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!p.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return je(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!p.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return je(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)=>kt(e,{type:"button",...t}),Small:ut,Source:nn,Span:Ue,Strong:Ke,Sub:pt,SubmitButton:(e,t)=>kt(e,{type:"submit",...t}),Summary:Ht,Sup:dt,Svg:sn,Switch:We,TBody:gn,TBodyCell:An,TFoot:yn,TFootCell:Cn,THead:bn,THeadCell:Sn,TRow:wn,Table:mn,Td:On,TelInput:e=>$t({type:"tel",...e}),TextArea:St,TextInput:Ct,Th:$n,Time:an,TimeInput:e=>$t({type:"time",...e}),Tr:vn,Track:rn,Ul:Zt,UnorderedList:Jt,UrlInput:e=>$t({type:"url",...e}),Var:pn,Video:tn,Wbr:dn,WeekInput:e=>$t({type:"week",...e}),When:function(e){if(!p.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,We(e,t,n)),toNdElement:()=>We(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=d("Portal "+n);return r.appendChild(q.getChild(e)),(t||document.body).appendChild(r),r}});const _n={};function Tn(e,t,n={}){e="/"+g(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=_n[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="/"+g(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 xn extends Error{constructor(e,t){super(e),this.context=t}}const Nn=(e,t)=>{const n=[];return e.forEach(e=>{n.push(g(e.suffix,"/"))}),n.push(g(t,"/")),n.join("/")},kn=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},In=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Fn=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Ln(){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 Mn(){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 Pn(){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 Vn(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 p.isAnchor(e)||(r=d(t),r.appendChild(e)),o.set(e,r),r},u=()=>{p.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return p.isNDElement(e)&&(t=e.node()),t},h=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=q.getChild(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 h(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),h(i,t,s)};return e.subscribe(f),f(e.currentState()),t}const Rn="default";function jn(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Ln.apply(this,[]);else if("history"===e.mode)Mn.apply(this,[]);else{if("memory"!==e.mode)throw new xn("Invalid router mode "+e.mode);Pn.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 Tn(Nn(o,e),n,{...s,middlewares:kn(o,s?.middlewares||[]),name:s?.name?In(o,s.name):null,layout:s?.layout||Fn(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!p.isFunction(n))throw new xn("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 xn(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(p.isJson(e)){const t=r[e.name];if(!t)throw new xn(`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="/"+g(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new xn(`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(!p.isFunction(e))throw new xn("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 qn(e,t){const{to:n,href:r,...o}=e;if(r){const e=jn.get();return nt({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||Rn,a=jn.get(i);if(!a)throw new xn('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return nt({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}jn.routers={},jn.create=function(e,t){if(!p.isFunction(t))throw n.error("Router","Callback must be a function"),new xn("Callback must be a function");const r=new jn(e);return jn.routers[e.name||Rn]=r,t(r),r.init(e.entry),r.mount=function(e){if(p.isString(e)){const t=document.querySelector(e);if(!t)throw new xn(`Container not found for selector: ${e}`);e=t}else if(!p.isElement(e))throw new xn("Container must be a string or an Element");return Vn(r,e)},r},jn.get=function(e){const t=jn.routers[e||Rn];if(!t)throw new xn(`Router not found for name: ${e}`);return t},jn.push=function(e,t=null){return jn.get(t).push(e)},jn.replace=function(e,t=null){return jn.get(t).replace(e)},jn.forward=function(e=null){return jn.get(e).forward()},jn.back=function(e=null){return jn.get(e).back()},jn.redirectTo=function(e,t=null,n=null){let r=e;const o=jn.get(n);return o.resolve({name:e,params:t})&&(r={name:e,params:t}),console.log(r),o.push(r)},qn.blank=function(e,t){return nt({...e,target:"_blank"},t)};var Wn=Object.freeze({__proto__:null,Link:qn,RouteParamPatterns:_n,Router:jn});var Bn=Object.freeze({__proto__:null,memoize:e=>he(e),once:e=>ce(e),singleton:e=>le(e)}),Un=Object.freeze({__proto__:null,Cache:Bn,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:Me});return e.$=N,e.ElementCreator=q,e.HtmlElementWrapper=X,e.NDElement=i,e.Observable=x,e.PluginsManager=null,e.SingletonView=ue,e.Store=O,e.StoreFactory=C,e.TemplateCloner=ae,e.Validator=p,e.autoMemoize=he,e.autoOnce=ce,e.classPropertyAccumulator=function(e=[]){let t=p.isString(e)?e.split(" ").filter(Boolean):e;const n=p.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=function(e){return p.isObservable(e)?q.createObservableNode(null,e):q.createStaticTextNode(null,e)},e.cssPropertyAccumulator=function(e={}){let t=p.isString(e)?e.split(";").filter(Boolean):e;const n=p.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=Dn,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=K,e.obs=k,e.once=le,e.router=Wn,e.useCache=function(e){let t=null,n=r=>(t=new ae(e),n=e=>t.clone(e),t.clone(r));return e.length<2?(...e)=>n(e):(e,t,...r)=>n([e,t,...r])},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new ue(e)),t.render(n)}},e.utils=Un,e.withValidation=Y,e}({});
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as HtmlElementWrapper, createTextNode } from './src/core/wrappers/HtmlElementWrapper'
2
2
  export { ElementCreator } from './src/core/wrappers/ElementCreator';
3
3
  export { NDElement } from './src/core/wrappers/NDElement';
4
- export { TemplateCloner, useCache } from './src/core/wrappers/TemplateCloner';
4
+ export { TemplateCloner, useCache } from './src/core/wrappers/template-cloner/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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.110",
3
+ "version": "1.0.112",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -0,0 +1,160 @@
1
+ import {ElementCreator} from "../ElementCreator";
2
+ import TemplateBinding from "../TemplateBinding";
3
+ import { OPERATIONS, hydrateClonedNode, optimizeBindingData, $hydrateFn, bindAttachMethods, cloneBindingsDataCache } from './utils';
4
+ import { getHydrator } from './attributes-hydrator';
5
+
6
+ export function TemplateCloner($fn) {
7
+ let $node = null;
8
+ let $hasBindingData = false;
9
+
10
+ let $bindingTreePathSize = 0;
11
+ const $bindingTreePath = [
12
+ {
13
+ id: 0,
14
+ parentId: null
15
+ }
16
+ ];
17
+
18
+ let pathCounter = 0;
19
+ const clone = (node, data, currentPath) => {
20
+ const bindDingData = cloneBindingsDataCache.get(node);
21
+ if(bindDingData) {
22
+ optimizeBindingData(bindDingData);
23
+ }
24
+ if(node.nodeType === 3) {
25
+ if(bindDingData && bindDingData.value) {
26
+ const value = bindDingData.value;
27
+ const textNode = node.cloneNode();
28
+ currentPath.value = value;
29
+ currentPath.HYDRATE_TEXT = true;
30
+ currentPath.operation = true;
31
+ currentPath.isString = (typeof value === 'string');
32
+ ElementCreator.bindTextNode(textNode, (currentPath.isString ? data[0][value] : value.apply(null, data)));
33
+ return textNode;
34
+ }
35
+ return node.cloneNode(true);
36
+ }
37
+ const nodeCloned = node.cloneNode();
38
+ if(bindDingData) {
39
+ const hydrator = getHydrator(bindDingData);
40
+ hydrator(nodeCloned, bindDingData, data);
41
+ bindAttachMethods(nodeCloned, bindDingData, data);
42
+
43
+ const hasAttributes = bindDingData.classes || bindDingData.styles || bindDingData.attributes;
44
+ const hasAttachMethods = bindDingData.attach.length;
45
+
46
+ currentPath.bindingData = bindDingData;
47
+ currentPath.hydrator = hydrator;
48
+
49
+ if(hasAttributes) {
50
+ currentPath.HYDRATE_ATTRIBUTES = true;
51
+ currentPath.operation = true;
52
+ }
53
+ if(hasAttachMethods) {
54
+ currentPath.ATTACH_METHOD = true;
55
+ currentPath.operation = true;
56
+ }
57
+ }
58
+ const childNodes = node.childNodes;
59
+ const parentId = currentPath.id;
60
+
61
+ for(let i = 0, length = childNodes.length; i < length; i++) {
62
+ const childNode = childNodes[i];
63
+ const path = { parentId, id: ++pathCounter, index: i };
64
+ const childNodeCloned = clone(childNode, data, path);
65
+ if(path.hasChildren || path.operation) {
66
+ $bindingTreePath.push(path);
67
+ currentPath.hasChildren = true;
68
+ }
69
+ nodeCloned.appendChild(childNodeCloned);
70
+ }
71
+ return nodeCloned;
72
+ };
73
+
74
+ const cloneWithBindingPaths = (data) => {
75
+ let root = $node.cloneNode(true);
76
+
77
+ hydrateClonedNode(root, data, $bindingTreePath, $bindingTreePathSize);
78
+ return root;
79
+ };
80
+
81
+ this.clone = (data) => {
82
+ const binder = createTemplateCloner(this);
83
+ $node = $fn(binder);
84
+ if(!$hasBindingData) {
85
+ this.clone = () => $node.cloneNode(true);
86
+ return $node.cloneNode(true);
87
+ }
88
+
89
+ const firstClone = clone($node, data, $bindingTreePath[0]);
90
+ $bindingTreePath.reverse();
91
+ $bindingTreePathSize = $bindingTreePath.length - 1;
92
+
93
+ this.clone = cloneWithBindingPaths;
94
+ return firstClone;
95
+ };
96
+
97
+
98
+ const createBinding = (hydrateFunction, targetType) => {
99
+ return new TemplateBinding((element, property) => {
100
+ $hasBindingData = true;
101
+ $hydrateFn(hydrateFunction, targetType, element, property)
102
+ });
103
+ };
104
+
105
+ this.style = (fn) => {
106
+ return createBinding(fn, 'styles');
107
+ };
108
+ this.class = (fn) => {
109
+ return createBinding(fn, 'classes');
110
+ };
111
+ this.property = (propertyName) => {
112
+ return this.value(propertyName);
113
+ }
114
+ this.value = (callbackOrProperty) => {
115
+ return createBinding(callbackOrProperty, 'value');
116
+ };
117
+ this.text = this.value;
118
+ this.attr = (fn) => {
119
+ return createBinding(fn, 'attributes');
120
+ };
121
+ this.attach = (fn) => {
122
+ return createBinding(fn, 'attach');
123
+ };
124
+ this.callback = this.attach;
125
+ }
126
+
127
+
128
+ function createTemplateCloner($binder) {
129
+ return new Proxy($binder, {
130
+ get(target, prop) {
131
+ if(prop in target) {
132
+ return target[prop];
133
+ }
134
+ if (typeof prop === 'symbol') return target[prop];
135
+ return target.value(prop);
136
+ }
137
+ });
138
+ }
139
+
140
+ export function useCache(fn) {
141
+ let $cache = null;
142
+
143
+ let wrapper = (args) => {
144
+ $cache = new TemplateCloner(fn);
145
+
146
+ wrapper = (args) => {
147
+ return $cache.clone(args);
148
+ };
149
+ return $cache.clone(args);
150
+ };
151
+
152
+ if(fn.length < 2) {
153
+ return (...args) => {
154
+ return wrapper(args);
155
+ };
156
+ }
157
+ return (_, __, ...args) => {
158
+ return wrapper([_, __, ...args]);
159
+ };
160
+ }
@@ -0,0 +1,86 @@
1
+ import {ElementCreator} from "../ElementCreator";
2
+
3
+ export const hydrateFull = (node, bindDingData, data) => {
4
+ const cacheAttributes = bindDingData._cache;
5
+
6
+ for(let i = 0, length = bindDingData._flatAttributesLength; i < length; i++) {
7
+ const attr = bindDingData._flatAttributes[i];
8
+ cacheAttributes[attr.name] = attr.value.apply(null, data);
9
+ }
10
+
11
+ for(let i = 0, length = bindDingData._flatDynamiqueLength; i < length; i++) {
12
+ const dyn = bindDingData._flatDynamique[i];
13
+ cacheAttributes[dyn.name][dyn.key] = dyn.value.apply(null, data);
14
+ }
15
+
16
+ ElementCreator.processAttributesDirect(node, cacheAttributes);
17
+ return true;
18
+ };
19
+
20
+ export const hydrateDynamic = (node, bindDingData, data) => {
21
+ const cacheAttributes = bindDingData._cache;
22
+
23
+ for(let i = 0, length = bindDingData._flatDynamiqueLength; i < length; i++) {
24
+ const dyn = bindDingData._flatDynamique[i];
25
+ cacheAttributes[dyn.name][dyn.key] = dyn.value.apply(null, data);
26
+ }
27
+
28
+ ElementCreator.processClassAttribute(node, cacheAttributes.class);
29
+ ElementCreator.processStyleAttribute(node, cacheAttributes.style);
30
+ return true;
31
+ };
32
+
33
+ export const hydrateClassAttribute = (node, bindDingData, data) => {
34
+ const classAttributes = bindDingData._cache.class;
35
+
36
+ for(let i = 0, length = bindDingData._flatDynamiqueLength; i < length; i++) {
37
+ const dyn = bindDingData._flatDynamique[i];
38
+ classAttributes[dyn.key] = dyn.value.apply(null, data);
39
+ }
40
+
41
+ ElementCreator.processClassAttribute(node, classAttributes);
42
+ return true;
43
+ };
44
+
45
+ export const hydrateStyleAttribute = (node, bindDingData, data) => {
46
+ const styleAttributes = bindDingData._cache;
47
+
48
+ for(let i = 0, length = bindDingData._flatDynamiqueLength; i < length; i++) {
49
+ const dyn = bindDingData._flatDynamique[i];
50
+ styleAttributes[dyn.key] = dyn.value.apply(null, data);
51
+ }
52
+
53
+ ElementCreator.processStyleAttribute(node, styleAttributes);
54
+ return true;
55
+ };
56
+
57
+ export const hydrateAttributes = (node, bindDingData, data) => {
58
+ const cacheAttributes = bindDingData._cache;
59
+
60
+ for(let i = 0, length = bindDingData._flatAttributesLength; i < length; i++) {
61
+ const attr = bindDingData._flatAttributes[i];
62
+ cacheAttributes[attr.name] = attr.value.apply(null, data);
63
+ }
64
+
65
+ ElementCreator.processAttributesDirect(node, cacheAttributes);
66
+ return true;
67
+ };
68
+
69
+ export const getHydrator = (bindDingData) => {
70
+ if(!bindDingData._cache) {
71
+ return noUpdate;
72
+ }
73
+ if(bindDingData._flatAttributesLength && bindDingData._flatDynamiqueLength) {
74
+ return hydrateFull;
75
+ }
76
+ if(bindDingData._flatAttributesLength) {
77
+ return hydrateAttributes;
78
+ }
79
+ if(bindDingData._hasClassAttribute && bindDingData._hasStyleAttribute) {
80
+ return hydrateDynamic;
81
+ }
82
+ if(bindDingData._hasClassAttribute) {
83
+ return hydrateClassAttribute;
84
+ }
85
+ return hydrateStyleAttribute;
86
+ };