native-document 1.0.95 → 1.0.99

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.
Files changed (44) hide show
  1. package/{src/devtools/hrm → devtools}/ComponentRegistry.js +2 -2
  2. package/devtools/index.js +8 -0
  3. package/{src/devtools/plugin.js → devtools/plugin/dev-tools-plugin.js} +2 -2
  4. package/{src/devtools/hrm/nd-vite-hot-reload.js → devtools/transformers/nd-vite-devtools.js} +16 -6
  5. package/devtools/transformers/src/transformComponentForHrm.js +74 -0
  6. package/devtools/transformers/src/transformJsFile.js +9 -0
  7. package/devtools/transformers/src/utils.js +79 -0
  8. package/{src/devtools/hrm → devtools/transformers/templates}/hrm.orbservable.hook.template.js +8 -0
  9. package/devtools/widget/Widget.js +48 -0
  10. package/devtools/widget/widget.css +81 -0
  11. package/devtools/widget.js +23 -0
  12. package/dist/native-document.components.min.js +1953 -1245
  13. package/dist/native-document.dev.js +2022 -1375
  14. package/dist/native-document.dev.js.map +1 -1
  15. package/dist/native-document.devtools.min.js +1 -1
  16. package/dist/native-document.min.js +1 -1
  17. package/docs/cache.md +1 -1
  18. package/docs/core-concepts.md +1 -1
  19. package/docs/native-document-element.md +51 -15
  20. package/docs/observables.md +333 -315
  21. package/docs/state-management.md +198 -193
  22. package/package.json +1 -1
  23. package/readme.md +1 -1
  24. package/rollup.config.js +1 -1
  25. package/src/core/data/ObservableArray.js +67 -0
  26. package/src/core/data/ObservableChecker.js +2 -0
  27. package/src/core/data/ObservableItem.js +97 -0
  28. package/src/core/data/ObservableObject.js +183 -0
  29. package/src/core/data/Store.js +364 -34
  30. package/src/core/data/observable-helpers/object.js +2 -166
  31. package/src/core/utils/formatters.js +91 -0
  32. package/src/core/utils/localstorage.js +57 -0
  33. package/src/core/utils/validator.js +0 -2
  34. package/src/fetch/NativeFetch.js +5 -2
  35. package/types/observable.d.ts +73 -15
  36. package/types/plugins-manager.d.ts +1 -1
  37. package/types/store.d.ts +33 -6
  38. package/hrm.js +0 -7
  39. package/src/devtools/app/App.js +0 -66
  40. package/src/devtools/app/app.css +0 -0
  41. package/src/devtools/hrm/transformComponent.js +0 -129
  42. package/src/devtools/index.js +0 -18
  43. package/src/devtools/widget/DevToolsWidget.js +0 -26
  44. /package/{src/devtools/hrm → devtools/transformers/templates}/hrm.hook.template.js +0 -0
@@ -1 +1 @@
1
- var NativeDocumentDevTools=function(){"use strict";let e={};"development"===process.env.NODE_ENV&&(e={enabled:!1,enable(){this.enabled=!0,console.log("🔍 NativeDocument Debug Mode enabled")},disable(){this.enabled=!1},log(e,t,n){this.enabled&&(console.group(`🔍 [${e}] ${t}`),n&&console.log(n),console.trace(),console.groupEnd())},warn(e,t,n){this.enabled&&console.warn(`⚠️ [${e}] ${t}`,n)},error(e,t,n){console.error(`❌ [${e}] ${t}`,n)}}),"production"===process.env.NODE_ENV&&(e={log(){},warn(){},error(){},disable(){}});var t=e;const n=function(){let e=0;const n=new Map;return{register(t){const r=++e;return n.set(r,new WeakRef(t)),r},unregister(e){n.delete(e)},getObservableById:e=>n.get(e)?.deref(),cleanup(){for(const[e,t]of n){const e=t.deref();e&&e.cleanup()}n.clear()},cleanObservables(e){if(n.size<e)return;let r=0;for(const[e,t]of n)t.deref()||(n.delete(e),r++);r>0&&t.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}();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()};let s=null;"development"===process.env.NODE_ENV&&(s=function(){const e=new Map,n=new Map;return{list:()=>n,add(t,r){if(!t||"object"!=typeof t)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||t.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){t.$name=r,e.set(r,t),"function"==typeof t?.init&&t.init();for(const e in t)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");n.has(r)||n.set(r,new Set),n.get(r).add(t)}}},remove(t){if(!e.has(t))return;const r=e.get(t);"function"==typeof r.cleanup&&r.cleanup();for(const[e,t]of n.entries())t.has(r)&&t.delete(r),0===t.size&&n.delete(e);e.delete(t)},emit(e,...r){if(!n.has(e))return;const o=n.get(e);for(const n of o){const o=n["on"+e];if("function"==typeof o)try{o.call(n,...r)}catch(r){t.error("Plugin Manager",`Error in plugin ${n.$name} for event ${e}`,r)}}}}}());var i=s;const l=function(e,t){this.$target=t,this.$observer=e};l.prototype.__$isObservableWhen=!0,l.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},l.prototype.val=function(){return this.$observer.$currentValue===this.$target},l.prototype.isMatch=l.prototype.val,l.prototype.isActive=l.prototype.val;const a=(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=>a(e));if(v.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=a(e[t]));return n};function u(e,t=null){e=v.isObservable(e)?e.val():e,this.$previousValue=null,this.$currentValue=e,"development"===process.env.NODE_ENV&&(this.$isCleanedUp=!1),this.$firstListener=null,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=v.isObject(e)?a(e):e)),"development"===process.env.NODE_ENV&&i.emit("CreateObservable",this)}Object.defineProperty(u.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),u.prototype.__$isObservable=!0;const c=function(){};u.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},u.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},u.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)},u.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)},u.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},u.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},u.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=c},u.prototype.trigger=c,u.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,"development"===process.env.NODE_ENV&&i.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,"development"===process.env.NODE_ENV&&i.emit("ObservableAfterChange",this))},u.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)},u.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},u.prototype.set=u.prototype.$basicSet,u.prototype.val=function(){return this.$currentValue},u.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)v.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},u.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},u.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}n.unregister(this.$memoryId),this.disconnectAll(),"development"===process.env.NODE_ENV&&(this.$isCleanedUp=!0),delete this.$value},u.prototype.subscribe=function(e){if("development"===process.env.NODE_ENV){if(this.$isCleanedUp)return void t.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable.");if("function"!=typeof e)throw new r("Callback must be a function")}this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger(),"development"===process.env.NODE_ENV&&i.emit("ObservableSubscribe",this)},u.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?v.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()},u.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()},u.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)},u.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger(),"development"===process.env.NODE_ENV&&i.emit("ObservableUnsubscribe",this)},u.prototype.check=function(e){return new o(this,e)},u.prototype.get=function(e){const t=this.$currentValue[e];return v.isObservable(t)?t.val():t},u.prototype.when=function(e){return new l(this,e)},u.prototype.equals=function(e){return v.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},u.prototype.toBool=function(){return!!this.$currentValue},u.prototype.toggle=function(){this.set(!this.$currentValue)},u.prototype.reset=function(){if(!this.configs?.reset)return;const e=v.isObject(this.$initialValue)?a(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},u.prototype.toString=function(){return String(this.$currentValue)},u.prototype.valueOf=function(){return this.$currentValue};const p={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=p.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=p.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(p.mountedSupposedSize>0)for(const e of t.addedNodes){if(p.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)p.executeMountedCallback(e)}if(p.unmountedSupposedSize>0)for(const e of t.removedNodes){if(p.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)p.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(p.mounted.delete(e),p.mountedSupposedSize--),r&&(p.unmounted.delete(e),p.unmountedSupposedSize--),o=null}};const s=(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=>{s("mounted",t),p.mounted.set(e,o),n||(p.mountedSupposedSize++,n=!0)},unmounted:t=>{s("unmounted",t),p.unmounted.set(e,o),r||(p.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)}}}};function d(e){this.$element=e,this.$observer=null,"development"===process.env.NODE_ENV&&i.emit("NDElementCreated",e,this)}p.observer=new MutationObserver(p.checkMutation),p.observer.observe(document.body,{childList:!0,subtree:!0}),d.prototype.__$isNDElement=!0,d.prototype.valueOf=function(){return this.$element},d.prototype.ref=function(e,t){return e[t]=this.$element,this},d.prototype.refSelf=function(e,t){return e[t]=this,this},d.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},d.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},d.prototype.lifecycle=function(e){return this.$observer=this.$observer||p.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},d.prototype.mounted=function(e){return this.lifecycle({mounted:e})},d.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},d.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!p.beforeUnmount.has(n)){p.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=p.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return p.beforeUnmount.get(n).set(e,t),this},d.prototype.htmlElement=function(){return this.$element},d.prototype.node=d.prototype.htmlElement,d.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},d.prototype.openShadow=function(e=null){return this.shadow("open",e)},d.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},d.prototype.attach=function(e,t){return t.$hydrate(this.$element,e),this.$element},d.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");"development"===process.env.NODE_ENV&&(this.$localExtensions||(this.$localExtensions=new Map));for(const n in e){const r=e[n];"function"==typeof r?("development"===process.env.NODE_ENV&&(this[n]&&!this.$localExtensions.has(n)&&t.warn("NDElement.extend",`Method "${n}" already exists and will be overwritten`),this.$localExtensions.set(n,r)),this[n]=r.bind(this)):console.warn(`⚠️ extends(): "${n}" is not a function, skipping`)}return this},d.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 n=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(n.has(o))throw t.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);d.prototype[o]&&t.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),d.prototype[o]=s}else t.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return"development"===process.env.NODE_ENV&&i.emit("NDElementExtended",e),d};const h=1,f=3,b=8,m=11,v={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=>v.isObservable(e)||v.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&(e.nodeType===h||e.nodeType===f||e.nodeType===m||e.nodeType===b),isFragment:e=>e?.nodeType===m,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 d,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&&(v.isObject(e)&&Object.values(e).some(e=>v.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")}};"development"===process.env.NODE_ENV&&(v.validateAttributes=function(e){if(!e||"object"!=typeof e)return e;const n=[],r=Object.keys(e).filter(e=>n.includes(e));return r.length>0&&t.warn("Validator",`Reserved attributes found: ${r.join(", ")}`),e});const y=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"]);function g(e,t=null){return new u(e,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 w(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 O(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(v.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)}}g.useValueProperty=function(e="value"){Object.defineProperty(u.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},g.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},g.cleanup=function(e){e.cleanup()},g.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:r=6e4,threshold:o=100}=t;window.addEventListener("beforeunload",()=>{n.cleanup()}),setInterval(()=>n.cleanObservables(o),r)},String.prototype.toNdElement=function(){const e=this.resolveObservableTemplate?this.resolveObservableTemplate():this;return v.isString(e)?A.createStaticTextNode(null,e):A.getChild(null,e)},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},u.prototype.toNdElement=function(){return A.createObservableNode(null,this)},o.prototype.toNdElement=u.prototype.toNdElement,d.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=A.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){const e=this;return"development"===process.env.NODE_ENV&&i.emit("BeforeProcessComponent",e),A.getChild(e())};const E=(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),l="0s"!==i.transitionDuration,a="0s"!==i.animationDuration;l||a||o()});d.prototype.transitionOut=function(e){const t=e+"-exit";return this.beforeUnmount("transition-exit",async function(){this.$element.classes.add(t),await E(this.$element),this.$element.classes.remove(t)}),this},d.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to";return this.$element.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.$element.classes.remove(t),this.$element.classes.add(n),E(this.$element).then(()=>{this.$element.classes.remove(n)})})})}),this},d.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},d.prototype.animate=function(e){return this.$element.classes.add(e),E(this.$element).then(()=>{this.$element.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},u.prototype.handleNdAttribute=function(e,t){y.has(t)?O(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)};const C=new Map;let N=null;const A={createTextNode:()=>(N||(N=document.createTextNode("")),N.cloneNode()),createObservableNode(e,t){const n=A.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=A.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=A.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=C.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return C.set(e,n),n.cloneNode()}return function(e,n=!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=e=>n||e.firstChild===o&&e.lastChild===s,l=function(e,t,n){const o=v.isElement(t)?t:A.getChild(t);e!==r?i(e)&&n===s?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)};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,n=null){const r=s.parentNode;r?l(r,e,n=n??s):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t.remove()),t=e;await Promise.all(n)},r.remove=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[],i=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t),i.push(t.remove()),t=e;await Promise.all(i),r.nativeAppend(...n)},r.removeWithAnchors=async function(){await r.removeChildren(),o.remove(),s.remove()},r.replaceContent=async function(e){const t=v.isElement(e)?e:A.getChild(e),n=s.parentNode;n&&(await r.removeChildren(),n.insertBefore(t,s))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return s},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}("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;"development"===process.env.NODE_ENV&&i.emit("BeforeProcessChildren",t);let n=this.getChild(e);n&&t.appendChild(n),"development"===process.env.NODE_ENV&&i.emit("AfterProcessChildren",t)},async safeRemove(e){await e.remove()},getChild(e){if(null==e)return null;if(e.toNdElement)do{if(e=e.toNdElement(),v.isElement(e))return e}while(e.toNdElement);return A.createStaticTextNode(null,e)},processAttributes(e,t){t&&function(e,t){v.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){w(e,o);continue}}y.has(r)?O(e,r,o):e.setAttribute(r,o)}}}(e,t)}};DocumentFragment.prototype.setAttribute=()=>{};const x={configurable:!0,get(){return new d(this)}};Object.defineProperty(HTMLElement.prototype,"nd",x),Object.defineProperty(DocumentFragment.prototype,"nd",x),Object.defineProperty(d.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();d.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();d.prototype["onStop"+e]=function(e=null){return S(this.$element,t,e),this},d.prototype["onPreventStop"+e]=function(e=null){return D(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();d.prototype["onPrevent"+e]=function(e=null){return V(this.$element,t,e),this}}),d.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const V=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},S=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},D=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},_={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,..._}}});class k extends Error{constructor(e,t){super(`${e}\n\n${t.join("\n")}\n\n`)}}let P=e=>e;if("development"===process.env.NODE_ENV){const e=(e,t,n="Function")=>{if(!t)return;const r=[],o=t.filter(e=>!e.optional).length;if(e.length<o&&r.push(`${n}: Expected at least ${o} arguments, got ${e.length}`),t.forEach((t,o)=>{const s=o+1,i=e[o];if(void 0!==i){if(!t.validate(i)){const e=i?.constructor?.name||typeof i;r.push(`${n}: Invalid argument '${t.name}' at position ${s}, expected ${t.type}, got ${e}`)}}else t.optional||r.push(`${n}: Missing required argument '${t.name}' at position ${s}`)}),r.length>0)throw new k("Argument validation failed",r)};P=(t,n,o="Function")=>{if(!v.isArray(n))throw new r("withValidation : argSchema must be an array");return function(...r){return e(r,n,t.name||o),t.apply(this,r)}}}process.env.NODE_ENV;function j(e,t,n,r=null){let{props:o,children:s=null}=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}}(n,r),i=A.createElement(e),l=t&&"function"==typeof t?t(i):i;return A.processAttributes(l,o),A.processChildren(s,l),l}function M(e,t=null){return j.bind(null,e,t)}const L=M("div");M("span"),M("label"),M("p"),M("strong"),M("h1"),M("h2"),M("h3"),M("h4"),M("h5"),M("h6"),M("br"),M("a"),M("pre"),M("code"),M("blockquote"),M("hr"),M("em"),M("small"),M("mark"),M("del"),M("ins"),M("sub"),M("sup"),M("abbr"),M("cite"),M("q"),M("dl"),M("dt"),M("dd"),M("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}),M("input"),M("textarea"),M("select"),M("fieldset"),M("option"),M("legend"),M("datalist"),M("output"),M("progress"),M("meter");const T=M("button");function I(e,t){const n=e.filter(v.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>v.isObservable(e)?e.val():e))}}function F(e,t=!0,n=""){return I([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())})}M("main"),M("section"),M("article"),M("aside"),M("nav"),M("figure"),M("figcaption"),M("header"),M("footer"),M("img"),M("details"),M("summary"),M("dialog"),M("menu"),M("ol"),M("ul"),M("li"),M("audio"),M("video"),M("source"),M("track"),M("canvas"),M("svg"),M("time"),M("data"),M("address"),M("kbd"),M("samp"),M("var"),M("wbr"),M("caption"),M("table"),M("thead"),M("tfoot"),M("tbody"),M("tr"),M("th"),M("td"),M(""),DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return P(this,e)},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 d(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 g.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return v.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return v.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!v.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return g.getById(n)}):this.valueOf()};const B=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");u.call(this,e,t),"development"===process.env.NODE_ENV&&i.emit("CreateObservableArray",this)};(B.prototype=Object.create(u.prototype)).constructor=B,B.prototype.__$isObservableArray=!0,Object.defineProperty(B.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{B.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=>{B.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),B.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},B.prototype.at=function(e){return this.$currentValue[e]},B.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},B.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},B.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},B.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)},B.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},B.prototype.isEmpty=function(){return 0===this.$currentValue.length},B.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},B.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=v.isObservable(o)?F(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=g.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},B.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},B.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},g.array=function(e=[],t=null){return new B(e,t)},g.batch=function(e){const t=g(0),n=function(){if(v.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};g.init=function(e,t=null){const n={};for(const r in e){const o=e[r];if(Array.isArray(o)){if(!1!==t?.deep){const e=o.map(e=>v.isJson(e)?g.json(e,t):v.isArray(e)?g.array(e,t):g(e,t));n[r]=g.array(e,t);continue}n[r]=g.array(o,t)}else v.isObservable(o)||v.isProxy(o)?n[r]=o:n[r]=g(o,t)}const r=()=>{for(const e in n){n[e].reset()}},o=()=>function(e){const t={};for(const n in e){const r=e[n];if(v.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>v.isObservable(e)?e.val():v.isProxy(e)?e.$value:e)),t[n]=e}else v.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(n),s=()=>g.init(o(),t),i=e=>{g.update(a,e)},l=e=>function(e,t){const n=e[t];return v.isObservable(n)?n.val():v.isProxy(n)?n.$value:n}(n,e),a=new Proxy(n,{get:(n,a)=>"__isProxy__"===a||("$value"===a?o():"get"===a||"$get"===a?l:"val"===a||"$val"===a?o:"set"===a||"$set"===a||"$updateWith"===a?i:"observables"===a||"$observables"===a?Object.values(n):"keys"===a||"$keys"===a?Object.keys(e):"clone"===a||"$clone"===a?s:"reset"===a?r:"configs"===a?t:n[a]),set:(e,t,n)=>void 0===e[t]||(v.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return a},g.arrayOfObject=function(e){return e.map(e=>g.object(e))},g.value=function(e){if(v.isObservable(e))return e.val();if(v.isProxy(e))return e.$value;if(v.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(g.value(r))}return t}return e},g.update=function(e,t){const n=v.isProxy(t)?t.$value:t,r=e.configs;for(const o in n){const s=e[o],i=t[o],l=n[o];if(v.isObservable(s)){if(v.isArray(l)){const e=i.at(0);if(v.isObservable(e)||v.isProxy(e)){const t=l.map(t=>v.isProxy(e)?g.init(t,r):g(t,r));s.set(t);continue}s.set([...l]);continue}s.set(l)}else v.isProxy(s)?g.update(s,l):e[o]=l}},g.object=g.init,g.json=g.init,g.computed=function(e,t=[]){const n=new u(e()),o=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}}(()=>n.set(e()));if("development"===process.env.NODE_ENV&&i.emit("CreateObservableComputed",n,t),v.isFunction(t)){if(!v.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{v.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const U={createdObservable:g(0)},W={name:"DevTools",onCreateObservable(e){U.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function z(){let e=!1;const t=L({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[L({class:"widget-label"},U.createdObservable),T({class:"widget-button"},"Full").nd.onClick(()=>{alert("Move to full-screen")})]);return t.nd.onStopMouseDown(()=>e=!0).onMouseUp(t=>e=!1),document.addEventListener("mousemove",n=>{e&&(t.style="left: "+n.clientX+"px; top: "+n.clientY+"px")}),t}return{config(){console.log("devtool init configuratzion")},init(){const e=L(L({class:"devtools-app-panel-wrapper pin-to-right"},[z,L({class:"devtools-app-panel"}),L("Gogo Panel")])).nd.closedShadow("\n .devtools-app-panel-wrapper {\n position: fixed;\n width: 0px;\n background: red;\n animate: .25s linear;\n }\n .devtools-app-panel-wrapper.pin-to-right {\n right: 0;\n top: 0;\n bottom: 0;\n }\n .devtools-app-panel-widget {\n position: fixed;\n background: rgba(0, 0, 0, 0.8);\n backdrop-filter: blur(5px);\n padding: 2px;\n width: 150px;\n height: 30px;\n border-radius: 5px;\n border: 1px solid black;\n z-index: 10000009;\n color: white;\n cursor: pointer;\n transform: translate(-50%, -50%);\n display: flex;\n justify-content: space-between;\n align-items: stretch;\n align-content: center;\n }\n .widget-button {\n width: 30px;\n padding: 2px;\n background: rgba(0, 0, 0, 0.8);\n border: 1px solid black;\n display: flex;\n justify-content: center;\n align-items: center;\n align-content: center;\n color: white;\n border-radius: 5px;\n cursor: pointer;\n font-size: .9rem;\n }\n .widget-label {\n font-weight: bold;\n font-size: 1.5rem;\n flex: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n ");document.body.parentNode.appendChild(e.$element)},plugin:W}}();
1
+ var NativeDocumentDevTools=function(e,t,n,r,o,s,a){"use strict";var i="undefined"!=typeof document?document.currentScript:null;const l=o.fileURLToPath(i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("native-document.devtools.min.js",document.baseURI).href),u=n.dirname(l);function c(e,t){let n=e;for(const e in t)n=n.replace(new RegExp("\\${"+e+"}","ig"),t[e]);return n}function d(e,t){let n=!1,r=!1;const o=t.split(",").map(e=>{let t=e.trim();return"Observable"===t?(n=!0,"Observable as __OriginalObservable__"):"$"===t?(r=!0,"$ as __$__"):` ${t}`});!n&&r&&o.push("Observable as __OriginalObservable__");return`import {${o.join(", ")} } from 'native-document'`}function p(e,n){const o=e.replace(/import\s+\{([^}]+?)\}\s+from\s+['"]native-document['"]/g,d),s=o!==e,a=new r(o);if(s){const e=t.readFileSync(u+"/../templates/hrm.orbservable.hook.template.js","utf8");a.append(c(e,n??{}))}return a.toString()}function m(e){return e.replace(/(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json))?\s*\(/g,(e,t,n,r,o)=>`${t} ${n} = ${o?`${r}${o}`:"Observable"}('${n}', arguments[arguments.length - 1], `)}function f(e){if(!/labs\/live\/src/.test(e))return!1;const n=t.readFileSync(e,"utf-8");return!!/import\s+\{([^}]+?)\}\s+from\s+['"]native-document['"]/g.test(n)||/(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json))?\s*\(/g.test(n)}const v=o.fileURLToPath(i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("native-document.devtools.min.js",document.baseURI).href),g=n.dirname(v);function $(e,n,o){let i=!1,l=null,u=0,d=0;const f=t.readFileSync(g+"/../templates/hrm.hook.template.js","utf8"),v=m(p(n,{id:e,...o})),$=new r(v),b=s.parse(v,{sourceType:"module",plugins:[]});if(a.default(b,{ExportDefaultDeclaration(e){i=!0;const t=e.node.declaration;l=t.id?t.id.name:"Identifier"===t.type?t.name:"AnonymousComponent",u=e.node.start,d=e.node.end}}),!i)return null;const _=v.slice(u,d),h=`__HRM_${l}__`,y=_.replace("export default",`const ${h} =`);$.overwrite(u,d,y);const R=c(f,{id:e});return $.prepend('import ComponentRegistry from "native-document/devtools/ComponentRegistry";'),$.append(`export default ComponentRegistry.register('${e}', ${h}, { preserveState: ${o.preserveState} });`),$.append(R),{code:$.toString(),map:$.generateMap({source:e,hires:!0})}}return e.NdViteDevtools=function(e){const{include:t=/\.nd\.js$/,preserveState:n=!0}=e;return{name:"nd-devtools",apply:"serve",enforce:"post",handleHotUpdate:({file:e,server:n,modules:r})=>t.test(e)?(n.ws.send({type:"nd-hmr-file",event:"nd:update",data:{file:e,msg:"The content has changed"}}),r.filter(Boolean)):f(e)?r.filter(Boolean):void 0,transform(e,r){if(!t.test(r))return f(r)?function(e,t,n){return m(p(t,{id:e,...n}))}(r,e,{preserveState:n}):null;if(r.includes("node_modules"))return null;try{return $(r,e,{preserveState:n})}catch(e){return console.error(`[NativeDocument] Transform error in ${r}:`,e),null}},configResolved(){console.log("[NativeDocument] HMR Plugin loaded ✓")}}},e.transformComponentForHrm=$,e}({},fs,path,MagicString,node_url,parser,traverse);
@@ -1 +1 @@
1
- var NativeDocument=function(e){"use strict";let t={};t={log(){},warn(){},error(){},disable(){}};var n=t;const r=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`)}}}();class o extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function s(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}s.prototype.__$isObservableChecker=!0,s.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},s.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},s.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},s.prototype.set=function(e){return this.observable.set(e)},s.prototype.trigger=function(){return this.observable.trigger()},s.prototype.cleanup=function(){return this.observable.cleanup()};const i=function(e,t){this.$target=t,this.$observer=e};i.prototype.__$isObservableWhen=!0,i.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},i.prototype.val=function(){return this.$observer.$currentValue===this.$target},i.prototype.isMatch=i.prototype.val,i.prototype.isActive=i.prototype.val;const a=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},u=(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=>u(e));if(g.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=u(e[t]));return n};function l(e,t=null){e=g.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=g.isObject(e)?u(e):e))}Object.defineProperty(l.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),l.prototype.__$isObservable=!0;const c=function(){};l.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},l.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},l.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)},l.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)},l.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},l.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},l.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=c},l.prototype.trigger=c,l.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)},l.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)},l.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},l.prototype.set=l.prototype.$basicSet,l.prototype.val=function(){return this.$currentValue},l.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)g.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},l.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},l.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}r.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},l.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},l.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?g.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()},l.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()},l.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)},l.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},l.prototype.check=function(e){return new s(this,e)},l.prototype.get=function(e){const t=this.$currentValue[e];return g.isObservable(t)?t.val():t},l.prototype.when=function(e){return new i(this,e)},l.prototype.equals=function(e){return g.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},l.prototype.toBool=function(){return!!this.$currentValue},l.prototype.toggle=function(){this.set(!this.$currentValue)},l.prototype.reset=function(){if(!this.configs?.reset)return;const e=g.isObject(this.$initialValue)?u(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},l.prototype.toString=function(){return String(this.$currentValue)},l.prototype.valueOf=function(){return this.$currentValue};const h={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=h.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=h.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(h.mountedSupposedSize>0)for(const e of t.addedNodes){if(h.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)h.executeMountedCallback(e)}if(h.unmountedSupposedSize>0)for(const e of t.removedNodes){if(h.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)h.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(h.mounted.delete(e),h.mountedSupposedSize--),r&&(h.unmounted.delete(e),h.unmountedSupposedSize--),o=null}};const s=(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=>{s("mounted",t),h.mounted.set(e,o),n||(h.mountedSupposedSize++,n=!0)},unmounted:t=>{s("unmounted",t),h.unmounted.set(e,o),r||(h.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)}}}};function p(e){this.$element=e,this.$observer=null}function d(e){this.$hydrate=e}h.observer=new MutationObserver(h.checkMutation),h.observer.observe(document.body,{childList:!0,subtree:!0}),p.prototype.__$isNDElement=!0,p.prototype.valueOf=function(){return this.$element},p.prototype.ref=function(e,t){return e[t]=this.$element,this},p.prototype.refSelf=function(e,t){return e[t]=this,this},p.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},p.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},p.prototype.lifecycle=function(e){return this.$observer=this.$observer||h.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},p.prototype.mounted=function(e){return this.lifecycle({mounted:e})},p.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},p.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!h.beforeUnmount.has(n)){h.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=h.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return h.beforeUnmount.get(n).set(e,t),this},p.prototype.htmlElement=function(){return this.$element},p.prototype.node=p.prototype.htmlElement,p.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},p.prototype.openShadow=function(e=null){return this.shadow("open",e)},p.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},p.prototype.attach=function(e,t){return t.$hydrate(this.$element,e),this.$element},p.prototype.with=function(e){if(!e||"object"!=typeof e)throw new o("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},p.extend=function(e){if(!e||"object"!=typeof e)throw new o("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new o("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 r in e){if(!Object.hasOwn(e,r))continue;const s=e[r];if("function"==typeof s){if(t.has(r))throw n.error("NDElement.extend",`Cannot override protected method "${r}"`),new o(`Cannot override protected method "${r}"`);p.prototype[r]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${r}"`),p.prototype[r]=s}else n.warn("NDElement.extend",`"${r}" is not a function, skipping`)}return p},d.prototype.__$isTemplateBinding=!0;const f=1,m=3,b=8,y=11,g={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=>g.isObservable(e)||g.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof s,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&(e.nodeType===f||e.nodeType===m||e.nodeType===y||e.nodeType===b),isFragment:e=>e?.nodeType===y,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 p,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 o(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(g.isObject(e)&&Object.values(e).some(e=>g.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new o("Event callback must be a function")}};function v(e,t=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(s),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild,r.nativeAppend=r.append;const i=function(e,n,i){const a=g.isElement(n)?n:k.getChild(n);e!==r?(e=>t||e.firstChild===o&&e.lastChild===s)(e)&&i===s?e.append(a,i):e.insertBefore(a,i):e.nativeInsertBefore(a,i)};return r.appendElement=function(e,t=null){const n=o.parentNode,i=t||s;n!==r?n?.insertBefore(e,i):n.nativeInsertBefore(e,i)},r.appendChild=function(e,t=null){const r=s.parentNode;r?i(r,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t.remove()),t=e;await Promise.all(n)},r.remove=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[],i=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t),i.push(t.remove()),t=e;await Promise.all(i),r.nativeAppend(...n)},r.removeWithAnchors=async function(){await r.removeChildren(),o.remove(),s.remove()},r.replaceContent=async function(e){const t=g.isElement(e)?e:k.getChild(e),n=s.parentNode;n&&(await r.removeChildren(),n.insertBefore(t,s))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return s},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}DocumentFragment.prototype.setAttribute=()=>{};const w=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"]);function $(e,t=null){return new l(e,t)}const O=$,C=$;function S(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 A(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.style[n]=r.val(),r.subscribe(t=>e.style[n]=t)):e.style[n]=r}}function E(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(g.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)}}$.useValueProperty=function(e="value"){Object.defineProperty(l.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},$.getById=function(e){const t=r.getObservableById(parseInt(e));if(!t)throw new o("Observable.getById : No observable found with id "+e);return t},$.cleanup=function(e){e.cleanup()},$.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:o=100}=t;window.addEventListener("beforeunload",()=>{r.cleanup()}),setInterval(()=>r.cleanObservables(o),n)},String.prototype.toNdElement=function(){const e=this.resolveObservableTemplate?this.resolveObservableTemplate():this;return g.isString(e)?k.createStaticTextNode(null,e):k.getChild(null,e)},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},l.prototype.toNdElement=function(){return k.createObservableNode(null,this)},s.prototype.toNdElement=l.prototype.toNdElement,p.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=k.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return k.getChild(this())},d.prototype.toNdElement=function(){return k.createHydratableNode(null,this)};const x=(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()});p.prototype.transitionOut=function(e){const t=e+"-exit";return this.beforeUnmount("transition-exit",async function(){this.$element.classes.add(t),await x(this.$element),this.$element.classes.remove(t)}),this},p.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to";return this.$element.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.$element.classes.remove(t),this.$element.classes.add(n),x(this.$element).then(()=>{this.$element.classes.remove(n)})})})}),this},p.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},p.prototype.animate=function(e){return this.$element.classes.add(e),x(this.$element).then(()=>{this.$element.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},l.prototype.handleNdAttribute=function(e,t){w.has(t)?E(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)},d.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const N=new Map;let T=null;const k={createTextNode:()=>(T||(T=document.createTextNode("")),T.cloneNode()),createObservableNode(e,t){const n=k.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=k.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=k.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=N.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return N.set(e,n),n.cloneNode()}return v("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(),g.isElement(e))return e}while(e.toNdElement);return k.createStaticTextNode(null,e)},processAttributes(e,t){t&&function(e,t){g.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){S(e,o);continue}if("style"===r){A(e,o);continue}}w.has(r)?E(e,r,o):e.setAttribute(r,o)}}}(e,t)}},D={configurable:!0,get(){return new p(this)}};Object.defineProperty(HTMLElement.prototype,"nd",D),Object.defineProperty(DocumentFragment.prototype,"nd",D),Object.defineProperty(p.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();p.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();p.prototype["onStop"+e]=function(e=null){return I(this.$element,t,e),this},p.prototype["onPreventStop"+e]=function(e=null){return F(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();p.prototype["onPrevent"+e]=function(e=null){return _(this.$element,t,e),this}}),p.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const _=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},I=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},F=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},P={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,...P}}});let L=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 V=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 M(e,t,n,r=null){let{props:o,children:s=null}=V(n,r),i=k.createElement(e),a=t&&"function"==typeof t?t(i):i;return k.processAttributes(a,o),k.processChildren(s,a),a}function q(e,t=null){return M.bind(null,e,t)}const j=new WeakMap,W=(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?(k.processAttributes(e,r),!0):null},R=(e,t,n)=>{if(!t.attach)return null;for(const r in t.attach)e.nd[r](function(...e){t.attach[r].apply(this,[...e,...n])})},B=(e,t,n,r)=>{if(r.fn&&("string"==typeof r.fn?k.bindTextNode(t,n[0][r.fn]):r.fn(n,t,e)),r.children)for(let o=0,s=r.children.length;o<s;o++){const s=r.children[o],i=t.childNodes[s.index];B(e,i,n,s)}};function U(e){let t=null,n=!1;const r={fn:null,children:[]},o=(e,t,n)=>{const r=j.get(e);if(3===e.nodeType){if(r&&r.value){n.fn=r.value;const o=e.cloneNode();return"string"==typeof r.value?(k.bindTextNode(o,t[0][r.value]),o):(r.value(t,o),o)}return e.cloneNode(!0)}const s=e.cloneNode();r&&(W(s,r,t),R(s,r,t),n.fn=(e,t)=>{W(t,r,e),R(t,r,e)});const i=e.childNodes,a=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r={index:e,fn:null},u=o(n,t,r);(r.children||r.fn)&&a.push(r),s.appendChild(u)}return a.length&&(n.children=n.children||[],n.children=a),s},s=e=>{let n=t.cloneNode(!0);return B(n,n,e,r),n};this.clone=i=>{if(t=e(this),!n)return this.clone=()=>t.cloneNode(!0),t.cloneNode(!0);const a=o(t,i,r);return this.clone=s,a};const i=(e,t)=>new d((r,o)=>{n=!0,function(e,t,n,r){j.has(n)||j.set(n,{});const o=j.get(n);"value"!==t?(o[t]=o[t]||{},o[t][r]=e):o.value=e}(e,t,r,o)});this.style=e=>i(e,"styles"),this.class=e=>i(e,"classes"),this.property=e=>this.value(e),this.value=e=>i("function"!=typeof e?e:(t,n)=>{k.bindTextNode(n,e(...t))},"value"),this.attr=e=>i(e,"attributes"),this.attach=e=>i(e,"attach")}function H(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=v("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 p(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 $.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return g.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return g.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!g.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return $.getById(n)}):this.valueOf()};const z=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},K=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},J=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 G(e){return e instanceof Date?e:new Date(e)}function Y(e,t){const n=G(e),r=G(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function Q(e){const t=G(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function X(e,t){const n=g.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function Z(e,t){const n=e.filter(g.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>g.isObservable(e)?e.val():e))}}function ee(e){return X(e,(e,t)=>e===t)}function te(e){return X(e,(e,t)=>e!==t)}function ne(e){return X(e,(e,t)=>e>t)}function re(e){return X(e,(e,t)=>e>=t)}function oe(e){return X(e,(e,t)=>e<t)}function se(e){return X(e,(e,t)=>e<=t)}function ie(e,t=!0,n=""){return Z([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 ae(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(g.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ue(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(g.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const le=ne,ce=re,he=oe,pe=se,de=ee,fe=te,me=ae,be=ue;function ye(e,t=!1){return X(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const ge=ye;var ve=Object.freeze({__proto__:null,all:me,and:ae,any:be,between:function(e,t){return Z([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:ge,createFilter:X,createMultiSourceFilter:Z,custom:function(e,...t){const n=t.filter(g.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>g.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>X(e,(e,t)=>!(!e||!t)&&G(e)>G(t)),dateBefore:e=>X(e,(e,t)=>!(!e||!t)&&G(e)<G(t)),dateBetween:(e,t)=>Z([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=G(e);return r>=G(t)&&r<=G(n)}),dateEquals:e=>X(e,(e,t)=>!(!e||!t)&&Y(e,t)),dateTimeAfter:e=>X(e,(e,t)=>!(!e||!t)&&G(e)>G(t)),dateTimeBefore:e=>X(e,(e,t)=>!(!e||!t)&&G(e)<G(t)),dateTimeBetween:(e,t)=>Z([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=G(e);return r>=G(t)&&r<=G(n)}),dateTimeEquals:e=>X(e,(e,t)=>!(!e||!t)&&G(e).getTime()===G(t).getTime()),endsWith:function(e,t=!1){return X(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:de,equals:ee,getSecondsOfDay:Q,greaterThan:ne,greaterThanOrEqual:re,gt:le,gte:ce,inArray:function(e){return X(e,(e,t)=>t.includes(e))},includes:ye,isEmpty:function(e=!0){return X(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return X(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:Y,lessThan:oe,lessThanOrEqual:se,lt:he,lte:pe,match:ie,neq:fe,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:te,notIn:function(e){return X(e,(e,t)=>!t.includes(e))},or:ue,startsWith:function(e,t=!1){return X(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>X(e,(e,t)=>!(!e||!t)&&Q(e)>Q(t)),timeBefore:e=>X(e,(e,t)=>!(!e||!t)&&Q(e)<Q(t)),timeBetween:(e,t)=>Z([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=Q(e);return r>=Q(t)&&r<=Q(n)}),timeEquals:e=>X(e,(e,t)=>{if(!e||!t)return!1;const n=G(e),r=G(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:G});const we=function(e,t=null){if(!Array.isArray(e))throw new o("Observable.array : target must be an array");l.call(this,e,t)};(we.prototype=Object.create(l.prototype)).constructor=we,we.prototype.__$isObservableArray=!0,Object.defineProperty(we.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{we.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=>{we.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),we.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},we.prototype.at=function(e){return this.$currentValue[e]},we.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},we.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},we.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},we.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)},we.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},we.prototype.isEmpty=function(){return 0===this.$currentValue.length},we.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},we.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=g.isObservable(o)?ie(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=$.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},we.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},we.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},$.array=function(e=[],t=null){return new we(e,t)},$.batch=function(e){const t=$(0),n=function(){if(g.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};$.init=function(e,t=null){const n={};for(const r in e){const o=e[r];if(Array.isArray(o)){if(!1!==t?.deep){const e=o.map(e=>g.isJson(e)?$.json(e,t):g.isArray(e)?$.array(e,t):$(e,t));n[r]=$.array(e,t);continue}n[r]=$.array(o,t)}else g.isObservable(o)||g.isProxy(o)?n[r]=o:n[r]=$(o,t)}const r=()=>{for(const e in n){n[e].reset()}},o=()=>function(e){const t={};for(const n in e){const r=e[n];if(g.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>g.isObservable(e)?e.val():g.isProxy(e)?e.$value:e)),t[n]=e}else g.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(n),s=()=>$.init(o(),t),i=e=>{$.update(u,e)},a=e=>function(e,t){const n=e[t];return g.isObservable(n)?n.val():g.isProxy(n)?n.$value:n}(n,e),u=new Proxy(n,{get:(n,u)=>"__isProxy__"===u||("$value"===u?o():"get"===u||"$get"===u?a:"val"===u||"$val"===u?o:"set"===u||"$set"===u||"$updateWith"===u?i:"observables"===u||"$observables"===u?Object.values(n):"keys"===u||"$keys"===u?Object.keys(e):"clone"===u||"$clone"===u?s:"reset"===u?r:"configs"===u?t:n[u]),set:(e,t,n)=>void 0===e[t]||(g.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return u},$.arrayOfObject=function(e){return e.map(e=>$.object(e))},$.value=function(e){if(g.isObservable(e))return e.val();if(g.isProxy(e))return e.$value;if(g.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push($.value(r))}return t}return e},$.update=function(e,t){const n=g.isProxy(t)?t.$value:t,r=e.configs;for(const o in n){const s=e[o],i=t[o],a=n[o];if(g.isObservable(s)){if(g.isArray(a)){const e=i.at(0);if(g.isObservable(e)||g.isProxy(e)){const t=a.map(t=>g.isProxy(e)?$.init(t,r):$(t,r));s.set(t);continue}s.set([...a]);continue}s.set(a)}else g.isProxy(s)?$.update(s,a):e[o]=a}},$.object=$.init,$.json=$.init,$.computed=function(e,t=[]){const n=new l(e()),r=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}}(()=>n.set(e()));if(g.isFunction(t)){if(!g.isObservable(t.$observer))throw new o("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{g.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const $e=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=$(n.val()),s=n.subscribe(e=>o.set(e)),i=o.subscribe(e=>n.set(e));return o.destroy=()=>{s(),i(),o.cleanup()},r.add(o),o},follow(e){return this.use(e)},create(t,n){const r=$(n);return e.set(t,{observer:r,subscribers:new Set}),r},get(t){const n=e.get(t);return n?n.observer:null},getWithSubscribers:t=>e.get(t),delete(t){const n=e.get(t);n&&(n.observer.cleanup(),n.subscribers.forEach(e=>e.destroy()),n.observer.clear())}}}();const Oe=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!g.isObservable(e)&&!g.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=v("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=k.getChild(t),g.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Ce=function(e,t,n=!0){if(!g.isObservable(e))throw new o("Toggle : condition must be an Observable");const r=v("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=k.getChild(r),g.isFragment(r)&&(r=Array.from(r.children)),n&&s.set(e,r),r):null},a=e.val(),u=i(a);return u&&r.appendChild(u),e.subscribe(e=>{const t=i(e);r.remove(),t&&r.appendChild(t)}),r.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&s.delete(e),delete t[e]}})},Se=function(e,t,n){if(!g.isObservable(e))throw new o("Toggle : condition must be an Observable");return Ce(e,{true:t,false:n})},Ae=q("div"),Ee=q("span"),xe=q("label"),Ne=q("p"),Te=Ne,ke=q("strong"),De=q("h1"),_e=q("h2"),Ie=q("h3"),Fe=q("h4"),Pe=q("h5"),Le=q("h6"),Ve=q("br"),Me=q("a"),qe=q("pre"),je=q("code"),We=q("blockquote"),Re=q("hr"),Be=q("em"),Ue=q("small"),He=q("mark"),ze=q("del"),Ke=q("ins"),Je=q("sub"),Ge=q("sup"),Ye=q("abbr"),Qe=q("cite"),Xe=q("q"),Ze=q("dl"),et=q("dt"),tt=q("dd"),nt=q("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}),rt=q("input"),ot=q("textarea"),st=ot,it=q("select"),at=q("fieldset"),ut=q("option"),lt=q("legend"),ct=q("datalist"),ht=q("output"),pt=q("progress"),dt=q("meter"),ft=q("button"),mt=q("main"),bt=q("section"),yt=q("article"),gt=q("aside"),vt=q("nav"),wt=q("figure"),$t=q("figcaption"),Ot=q("header"),Ct=q("footer"),St=q("img"),At=function(e,t){return St({src:e,...t})},Et=q("details"),xt=q("summary"),Nt=q("dialog"),Tt=q("menu"),kt=q("ol"),Dt=q("ul"),_t=q("li"),It=_t,Ft=kt,Pt=Dt,Lt=q("audio"),Vt=q("video"),Mt=q("source"),qt=q("track"),jt=q("canvas"),Wt=q("svg"),Rt=q("time"),Bt=q("data"),Ut=q("address"),Ht=q("kbd"),zt=q("samp"),Kt=q("var"),Jt=q("wbr"),Gt=q("caption"),Yt=q("table"),Qt=q("thead"),Xt=q("tfoot"),Zt=q("tbody"),en=q("tr"),tn=en,nn=q("th"),rn=nn,on=nn,sn=q("td"),an=sn,un=q("");var ln=Object.freeze({__proto__:null,Abbr:Ye,Address:Ut,Anchor:v,Article:yt,Aside:gt,AsyncImg:function(e,t,n,r){const s=g.isObservable(e)?e.val():e,i=At(t||s,n),a=new Image;return a.onload=()=>{g.isFunction(r)&&r(null,i),i.src=g.isObservable(e)?e.val():e},a.onerror=()=>{g.isFunction(r)&&r(new o("Image not found"))},g.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Lt,BaseImage:St,Blockquote:We,Br:Ve,Button:ft,Canvas:jt,Caption:Gt,Checkbox:e=>rt({type:"checkbox",...e}),Cite:Qe,Code:je,ColorInput:e=>rt({type:"color",...e}),Data:Bt,Datalist:ct,DateInput:e=>rt({type:"date",...e}),DateTimeInput:e=>rt({type:"datetime-local",...e}),Dd:tt,Del:ze,Details:Et,Dialog:Nt,Div:Ae,Dl:Ze,Dt:et,Em:Be,EmailInput:e=>rt({type:"email",...e}),FieldSet:at,FigCaption:$t,Figure:wt,FileInput:e=>rt({type:"file",...e}),Footer:Ct,ForEach:function(e,t,r,{shouldKeepItemsInCache:s=!1}={}){const i=v("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(g.isString(n)){const r=g.isObservable(e)?e.val():e,o=r?.[n];return g.isObservable(o)?o.val():o??t}return g.isFunction(n)?n(e,t):(g.isObservable(e)?e.val():e)??t})(e,s,r);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?$(s):null;let r=k.getChild(t(e,n));if(!r)throw new o("ForEach child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(r),indexObserver:n})}catch(e){throw n.error("ForEach",`Error creating element for key ${i}`,e),e}return i},d=()=>{const t=a.parentNode;if(!t)return;const n=g.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 d(),g.isObservable(e)&&e.subscribe(d),i},ForEachArray:function(e,t,n={}){const r=v("ForEach Array",n.isParentUniqueChild),s=r.endElement(),i=r.startElement();let a=new Map,u=0;const l=t.length>=2,c=e=>{r.removeChildren(),d(e),u=0},h=e=>a.get(e)?.child,p=(e,t=!0)=>{const n=a.get(e);if(n){if(t){const e=n.child;e?.remove(),a.delete(n.keyId)}n.indexObserver?.cleanup()}},d=e=>{if(!n.shouldKeepItemsInCache)if(l){for(const[t,n]of a.entries())e&&e.contains(t)||p(t,!1);a.clear()}else a.clear()},f=(e,n)=>{const r=a.get(e);if(r){r.indexObserver?.set(n);const t=r.child;if(t)return t;a.delete(e)}const s=l?$(n):null;let i=k.getChild(t(e,s));if(i)return a.set(e,{child:i,indexObserver:s}),i;throw new o("ForEachArray child can't be null or undefined!")},m=function(e,t){const n=a.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},b={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(f(e[t],u)),u++;return n},add(e,t=2){r.appendElement(b.toFragment(e))},replace(e){c(e),b.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=h(r),t&&n.appendChild(t);t=null,r.appendElement(n,s)},removeOne(e,t){p(e,!0)},clear:c,merge(e){b.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),b.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(f(t,r)),u++}r.appendChild(o),o.replaceChildren()},unshift(e){r.insertBefore(b.toFragment(e),i.nextSibling)},splice(e,t){const[n,o,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)m(e,u);else if(t.length>1){const e=h(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)m(t[e],u)}}else a=s;u.replaceChildren(),i&&i.length&&a&&r.insertBefore(b.toFragment(i),a.nextSibling)},reverse(e,t){b.reOrder(t)},sort(e,t){b.reOrder(t)},remove(e,t){b.removeOne(t)},pop(e,t){b.removeOne(t)},shift(e,t){b.removeOne(t)},swap(e,t){const n=s.parentNode;let r=h(t[0]),o=h(t[1]);if(!r||!o)return;const i=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,i),r=null,o=null}},y=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(n?.action)b[n.action]&&b[n.action](n.args,n.result);else{if(0===u)return void b.add(e);b.replace(e)}((e,t=0)=>{if(!l)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=a.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===u)return;c()}};return e.val().length&&y(e.val(),0,{action:null}),g.isObservable(e)&&e.subscribe(y),r},Form:nt,Fragment:un,H1:De,H2:_e,H3:Ie,H4:Fe,H5:Pe,H6:Le,Header:Ot,HiddenInput:e=>rt({type:"hidden",...e}),HideIf:function(e,t,n){const r=$(!e.val());return e.subscribe(e=>r.set(!e)),Oe(r,t,n)},HideIfNot:function(e,t,n){return Oe(e,t,n)},Hr:Re,Img:At,Input:rt,Ins:Ke,Kbd:Ht,Label:xe,LazyImg:function(e,t){return At(e,{...t,loading:"lazy"})},Legend:lt,Li:It,Link:Me,ListItem:_t,Main:mt,Mark:He,Match:Ce,Menu:Tt,Meter:dt,MonthInput:e=>rt({type:"month",...e}),NativeDocumentFragment:v,Nav:vt,NumberInput:e=>rt({type:"number",...e}),Ol:Ft,Option:ut,OrderedList:kt,Output:ht,P:Ne,Paragraph:Te,PasswordInput:e=>rt({type:"password",...e}),Pre:qe,Progress:pt,Quote:Xe,Radio:e=>rt({type:"radio",...e}),RangeInput:e=>rt({type:"range",...e}),ReadonlyInput:e=>rt({readonly:!0,...e}),Samp:zt,SearchInput:e=>rt({type:"search",...e}),Section:bt,Select:it,ShowIf:Oe,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!g.isObservableWhenResult(e))throw new o("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Oe(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!g.isObservable(e))throw new o("showWhen observer must be an Observable",{data:e});return Oe(e.when(t),n)}throw new o("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>ft(e,{type:"button",...t}),Small:Ue,Source:Mt,Span:Ee,Strong:ke,Sub:Je,SubmitButton:(e,t)=>ft(e,{type:"submit",...t}),Summary:xt,Sup:Ge,Svg:Wt,Switch:Se,TBody:Zt,TBodyCell:an,TFoot:Xt,TFootCell:on,THead:Qt,THeadCell:rn,TRow:tn,Table:Yt,Td:sn,TelInput:e=>rt({type:"tel",...e}),TextArea:ot,TextInput:st,Th:nn,Time:Rt,TimeInput:e=>rt({type:"time",...e}),Tr:en,Track:qt,Ul:Pt,UnorderedList:Dt,UrlInput:e=>rt({type:"url",...e}),Var:Kt,Video:Vt,Wbr:Jt,WeekInput:e=>rt({type:"week",...e}),When:function(e){if(!g.isObservable(e))throw new o("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,Se(e,t,n)),toNdElement:()=>Se(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=v("Portal "+n);return r.appendChild(k.getChild(e)),(t||document.body).appendChild(r),r}});const cn={};function hn(e,t,n={}){e="/"+a(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,u=n.with||{},l=n.layout||null,c={},h=[],p=e=>{if(!e)return null;const[t,n]=e.split(":");let r=u[t];return!r&&n&&(r=cn[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},d=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=p(t);return n&&n.pattern?(c[n.name]=n.pattern,h.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=()=>l,this.match=function(e){e="/"+a(e,"/");if(!d().exec(e))return!1;const t={};return d().exec(e).forEach((e,n)=>{if(n<1)return;const r=h[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=p(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 pn extends Error{constructor(e,t){super(e),this.context=t}}const dn=(e,t)=>{const n=[];return e.forEach(e=>{n.push(a(e.suffix,"/"))}),n.push(a(t,"/")),n.join("/")},fn=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},mn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},bn=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function yn(){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 gn(){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 vn(){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 wn(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 g.isAnchor(e)||(r=v(t),r.appendChild(e)),o.set(e,r),r},u=()=>{g.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return g.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=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 $n="default";function On(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)yn.apply(this,[]);else if("history"===e.mode)gn.apply(this,[]);else{if("memory"!==e.mode)throw new pn("Invalid router mode "+e.mode);vn.apply(this,[])}const u=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 hn(dn(o,e),n,{...s,middlewares:fn(o,s?.middlewares||[]),name:s?.name?mn(o,s.name):null,layout:s?.layout||bn(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!g.isFunction(n))throw new pn("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 pn(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(g.isJson(e)){const t=r[e.name];if(!t)throw new pn(`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="/"+a(n,"/");let i,u=null;for(const e of t)if(i=e.match(s),i){u=e;break}if(!u)throw new pn(`Route not found for url: ${n}`);const l={};if(o){const e=new URLSearchParams(o).entries();for(const[t,n]of e)l[t]=n}return{route:u,params:i,query:l,path:e}},this.subscribe=function(e){if(!g.isFunction(e))throw new pn("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(),u];let s=0;const a={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||a,l)};return o[s](a,l)}}function Cn(e,t){const{to:n,href:r,...o}=e;if(r){const e=On.get();return Me({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||$n,a=On.get(i);if(!a)throw new pn('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Me({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}On.routers={},On.create=function(e,t){if(!g.isFunction(t))throw n.error("Router","Callback must be a function"),new pn("Callback must be a function");const r=new On(e);return On.routers[e.name||$n]=r,t(r),r.init(e.entry),r.mount=function(e){if(g.isString(e)){const t=document.querySelector(e);if(!t)throw new pn(`Container not found for selector: ${e}`);e=t}else if(!g.isElement(e))throw new pn("Container must be a string or an Element");return wn(r,e)},r},On.get=function(e){const t=On.routers[e||$n];if(!t)throw new pn(`Router not found for name: ${e}`);return t},On.push=function(e,t=null){return On.get(t).push(e)},On.replace=function(e,t=null){return On.get(t).replace(e)},On.forward=function(e=null){return On.get(e).forward()},On.back=function(e=null){return On.get(e).back()},Cn.blank=function(e,t){return Me({...e,target:"_blank"},t)};var Sn=Object.freeze({__proto__:null,Link:Cn,RouteParamPatterns:cn,Router:On});var An=Object.freeze({__proto__:null,memoize:e=>J(e),once:e=>K(e),singleton:e=>z(e)}),En=Object.freeze({__proto__:null,Cache:An,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||{}}};o&&(o instanceof FormData?i.body=o:(i.headers["Content-Type"]="application/json","GET"!==n?i.body=JSON.stringify(o):i.params=o));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:ve});return e.$=O,e.ElementCreator=k,e.HtmlElementWrapper=q,e.NDElement=p,e.Observable=$,e.PluginsManager=null,e.SingletonView=H,e.Store=$e,e.TemplateCloner=U,e.Validator=g,e.autoMemoize=J,e.autoOnce=K,e.classPropertyAccumulator=function(e=[]){let t=g.isString(e)?e.split(" ").filter(Boolean):e;const n=g.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=function(e){return g.isObservable(e)?k.createObservableNode(null,e):k.createStaticTextNode(null,e)},e.cssPropertyAccumulator=function(e={}){let t=g.isString(e)?e.split(";").filter(Boolean):e;const n=g.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=ln,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=V,e.obs=C,e.once=z,e.router=Sn,e.useCache=function(e){let t=null;const n=function(n){return t||(t=new U(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new H(e)),t.render(n)}},e.utils=En,e.withValidation=L,e}({});
1
+ var NativeDocument=function(e){"use strict";let t={};t={log(){},warn(){},error(){},disable(){}};var n=t;class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const s={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=s.mounted.get(e);if(t&&(t.inDom=!0,t.mounted))if(Array.isArray(t.mounted))for(const n of t.mounted)n(e);else t.mounted(e)},executeUnmountedCallback(e){const t=s.unmounted.get(e);if(!t)return;if(t.inDom=!1,!t.unmounted)return;let n=!1;if(Array.isArray(t.unmounted))for(const r of t.unmounted)!0===r(e)&&(n=!0);else n=!0===t.unmounted(e);n&&(t.disconnect(),e.nd?.remove())},checkMutation:function(e){for(const t of e){if(s.mountedSupposedSize>0)for(const e of t.addedNodes){if(s.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)s.executeMountedCallback(e)}if(s.unmountedSupposedSize>0)for(const e of t.removedNodes){if(s.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)s.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(s.mounted.delete(e),s.mountedSupposedSize--),r&&(s.unmounted.delete(e),s.unmountedSupposedSize--),o=null}};const i=(e,t)=>{o[e]?Array.isArray(o[e])?o[e].push(t):o[e]=[o[e],t]:o[e]=t};return{disconnect:()=>o?.disconnect(),mounted:t=>{i("mounted",t),s.mounted.set(e,o),n||(s.mountedSupposedSize++,n=!0)},unmounted:t=>{i("unmounted",t),s.unmounted.set(e,o),r||(s.unmountedSupposedSize++,r=!0)},off:(e,t)=>{((e,t)=>{if(o?.[e]){if(Array.isArray(o[e])){const n=o[e].indexOf(t);return n>-1&&o[e].splice(n,1),1===o[e].length&&(o[e]=o[e][0]),void(0===o[e].length&&(o[e]=null))}o[e]=null}})(e,t)}}}};s.observer=new MutationObserver(s.checkMutation),s.observer.observe(document.body,{childList:!0,subtree:!0});function i(e){this.$element=e,this.$observer=null}i.prototype.__$isNDElement=!0,i.prototype.valueOf=function(){return this.$element},i.prototype.ref=function(e,t){return e[t]=this.$element,this},i.prototype.refSelf=function(e,t){return e[t]=this,this},i.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},i.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},i.prototype.lifecycle=function(e){return this.$observer=this.$observer||s.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},i.prototype.mounted=function(e){return this.lifecycle({mounted:e})},i.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},i.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!s.beforeUnmount.has(n)){s.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=s.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return s.beforeUnmount.get(n).set(e,t),this},i.prototype.htmlElement=function(){return this.$element},i.prototype.node=i.prototype.htmlElement,i.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},i.prototype.openShadow=function(e=null){return this.shadow("open",e)},i.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},i.prototype.attach=function(e,t){return t.$hydrate(this.$element,e),this.$element},i.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},i.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!Object.hasOwn(e,o))continue;const s=e[o];if("function"==typeof s){if(t.has(o))throw n.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);i.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),i.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i};const a=1,u=3,l=8,c=11,h={isObservable:e=>e?.__$isObservable,isTemplateBinding:e=>e?.__$isTemplateBinding,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isObservableOrProxy:e=>h.isObservable(e)||h.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&(e.nodeType===a||e.nodeType===u||e.nodeType===c||e.nodeType===l),isFragment:e=>e?.nodeType===c,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof i,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(h.isObject(e)&&Object.values(e).some(e=>h.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new r("Event callback must be a function")}};function p(e,t=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(s),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild,r.nativeAppend=r.append;const i=function(e,n,i){const a=h.isElement(n)?n:j.getChild(n);e!==r?(e=>t||e.firstChild===o&&e.lastChild===s)(e)&&i===s?e.append(a,i):e.insertBefore(a,i):e.nativeInsertBefore(a,i)};return r.appendElement=function(e,t=null){const n=o.parentNode,i=t||s;n!==r?n?.insertBefore(e,i):n.nativeInsertBefore(e,i)},r.appendChild=function(e,t=null){const r=s.parentNode;r?i(r,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t.remove()),t=e;await Promise.all(n)},r.remove=async function(){if(s.parentNode===r)return;let e,t=o.nextSibling;const n=[],i=[];for(;t&&t!==s;)e=t.nextSibling,n.push(t),i.push(t.remove()),t=e;await Promise.all(i),r.nativeAppend(...n)},r.removeWithAnchors=async function(){await r.removeChildren(),o.remove(),s.remove()},r.replaceContent=async function(e){const t=h.isElement(e)?e:j.getChild(e),n=s.parentNode;n&&(await r.removeChildren(),n.insertBefore(t,s))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return s},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}DocumentFragment.prototype.setAttribute=()=>{};const d=new Set(["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"]),f=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let r=0;for(const[e,n]of t)n.deref()||(t.delete(e),r++);r>0&&n.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}(),m=function(e,t){this.$target=t,this.$observer=e};m.prototype.__$isObservableWhen=!0,m.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},m.prototype.val=function(){return this.$observer.$currentValue===this.$target},m.prototype.isMatch=m.prototype.val,m.prototype.isActive=m.prototype.val;const b=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},y=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},g=(e,t)=>{try{if(void 0!==window.structuredClone)return window.structuredClone(e)}catch(e){}if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>g(e));if(h.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=g(e[t]));return n},v={getJson(e){let t=localStorage.getItem(e);try{return JSON.parse(t)}catch(t){throw new r("invalid_json:"+e)}},getNumber(e){return Number(this.get(e))},getBool(e){const t=this.get(e);return"true"===t||"1"===t},setJson(e,t){localStorage.setItem(e,JSON.stringify(t))},setBool(e,t){localStorage.setItem(e,t?"true":"false")},get:(e,t=null)=>localStorage.getItem(e)||t,set:(e,t)=>localStorage.setItem(e,t),remove(e){localStorage.removeItem(e)},has:e=>null!=localStorage.getItem(e)},w=(e,t)=>{if(!v.has(e))return t;switch(typeof t){case"object":return v.getJson(e)??t;case"boolean":return v.getBool(e)??t;case"number":return v.getNumber(e)??t;default:return v.get(e,t)??t}},$=e=>{switch(typeof e){case"object":return v.setJson;case"boolean":return v.setBool;default:return v.set}},S=function(){const e=new Map,t=new Map,o=(t,o)=>{const s=e.get(o);if(!s)throw n.error("Store",`Store.${t}('${o}') : store not found. Did you call Store.create('${o}') first?`),new r(`Store.${t}('${o}') : store not found.`);return s},s=(e,t={})=>Array.isArray(e)?N.array(e,t):"object"==typeof e?N.object(e,t):N(e,t);return new Proxy({create(t,o){if(e.has(t))throw n.warn("Store",`Store.create('${t}') : a store with this name already exists. Use Store.get('${t}') to retrieve it.`),new r(`Store.create('${t}') : a store with this name already exists.`);const i=s(o);return e.set(t,{observer:i,subscribers:new Set,resettable:!1,composed:!1}),i},createResettable(t,o){if(e.has(t))throw n.warn("Store",`Store.createResettable('${t}') : a store with this name already exists.`),new r(`Store.createResettable('${t}') : a store with this name already exists.`);const i=s(o,{reset:!0});return e.set(t,{observer:i,subscribers:new Set,resettable:!0,composed:!1}),i},createComposed(t,o,s){if(e.has(t))throw n.warn("Store",`Store.createComposed('${t}') : a store with this name already exists.`),new r(`Store.createComposed('${t}') : a store with this name already exists.`);if("function"!=typeof o)throw new r(`Store.createComposed('${t}') : computation must be a function.`);if(!Array.isArray(s)||0===s.length)throw new r(`Store.createComposed('${t}') : dependencies must be a non-empty array of store names.`);const i=s.map(o=>{if("string"!=typeof o)return o;const s=e.get(o);if(!s)throw n.error("Store",`Store.createComposed('${t}') : dependency '${o}' not found. Create it first.`),new r(`Store.createComposed('${t}') : dependency store '${o}' not found.`);return s.observer}),a=N.computed(o,i);return e.set(t,{observer:a,subscribers:new Set,resettable:!1,composed:!0}),a},has:t=>e.has(t),reset(e){const t=o("reset",e);if(t.composed)throw n.error("Store",`Store.reset('${e}') : composed stores cannot be reset. Their value is derived from dependencies.`),new r(`Store.reset('${e}') : composed stores cannot be reset.`);if(!t.resettable)throw n.error("Store",`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`),new r(`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`);t.observer.reset()},use(e){const t=o("use",e);if(t.composed)throw n.error("Store",`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`),new r(`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`);const{observer:i,subscribers:a}=t,u=s(i.val()),l=e=>u.set(e),c=e=>i.set(e);return i.subscribe(l),u.subscribe(c),u.destroy=()=>{i.unsubscribe(l),u.unsubscribe(c),a.delete(u),u.cleanup()},u.dispose=u.destroy,a.add(u),u},follow(e){const{observer:t,subscribers:i}=o("follow",e),a=s(t.val()),u=e=>a.set(e);return t.subscribe(u),((e,t,o)=>{const s=e=>()=>{throw n.error("Store",`Store.${o}('${t}') is read-only. '${e}()' is not allowed.`),new r(`Store.${o}('${t}') is read-only.`)};e.set=s("set"),e.toggle=s("toggle"),e.reset=s("reset")})(a,e,"follow"),a.destroy=()=>{t.unsubscribe(u),i.delete(a),a.cleanup()},a.dispose=a.destroy,i.add(a),a},get(t){const r=e.get(t);return r?r.observer:(n.warn("Store",`Store.get('${t}') : store not found.`),null)},getWithSubscribers:t=>e.get(t)??null,delete(t){const r=e.get(t);r?(r.subscribers.forEach(e=>e.destroy()),r.subscribers.clear(),r.observer.cleanup(),e.delete(t)):n.warn("Store",`Store.delete('${t}') : store not found, nothing to delete.`)},group(e,t){"function"==typeof e&&(t=e,e="anonymous");const n=S();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,w(n,t)),o=$(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,w(n,t)),o=$(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{v.remove(n),s()},r}},{get(e,n){if("symbol"==typeof n||n.startsWith("$")||n in e)return e[n];if(e.has(n)){if(t.has(n))return t.get(n);const r=e.follow(n);return t.set(n,r),r}},set(e,t,o){throw n.error("Store",`Forbidden: You cannot overwrite the store key '${String(t)}'. Use .use('${String(t)}').set(value) instead.`),new r("Store structure is immutable. Use .set() on the observable.")},deleteProperty(e,t){throw new r("Store keys cannot be deleted.")}})},O=S();O.create("locale","fr");const C=(e,t)=>{const n=new Date(e);return{d:n,parts:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(n).reduce((e,{type:t,value:n})=>(e[t]=n,e),{})}},A=(e,t,n)=>{const r=e=>String(e).padStart(2,"0");return e.replace("YYYY",n.year).replace("YY",n.year.slice(-2)).replace("MMMM",n.month).replace("MMM",n.month.slice(0,3)).replace("MM",r(t.getMonth()+1)).replace("DD",r(t.getDate())).replace("D",t.getDate()).replace("HH",n.hour).replace("mm",n.minute).replace("ss",n.second)},E={currency:(e,t,{currency:n="XOF",notation:r,minimumFractionDigits:o,maximumFractionDigits:s}={})=>new Intl.NumberFormat(t,{style:"currency",currency:n,notation:r,minimumFractionDigits:o,maximumFractionDigits:s}).format(e),number:(e,t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}={})=>new Intl.NumberFormat(t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}).format(e),percent:(e,t,{decimals:n=1}={})=>new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:n}).format(e),date:(e,t,{format:n,dateStyle:r="long"}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r}).format(new Date(e))},time:(e,t,{format:n,hour:r="2-digit",minute:o="2-digit",second:s}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{hour:r,minute:o,second:s}).format(new Date(e))},datetime:(e,t,{format:n,dateStyle:r="long",hour:o="2-digit",minute:s="2-digit",second:i}={})=>{if(n){const{d:r,parts:o}=C(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r,hour:o,minute:s,second:i}).format(new Date(e))},relative:(e,t,{unit:n="day",numeric:r="auto"}={})=>{const o=Math.round((e-Date.now())/864e5);return new Intl.RelativeTimeFormat(t,{numeric:r}).format(o,n)},plural:(e,t,{singular:n,plural:r}={})=>`${e} ${"one"===new Intl.PluralRules(t).select(e)?n:r}`};function x(e,t=null){e=h.isObservable(e)?e.val():e,this.$previousValue=null,this.$currentValue=e,this.$firstListener=null,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=h.isObject(e)?g(e):e))}Object.defineProperty(x.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),x.prototype.__$isObservable=!0;const D=function(){};function N(e,t=null){return new x(e,t)}x.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},x.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},x.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)},x.prototype.triggerWatchers=function(e){const t=this.$watchers,n=this.$previousValue,r=this.$currentValue,o=t.get(r),s=t.get(n);o&&o(!0,n,e),s&&s(!1,r,e)},x.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},x.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},x.prototype.assocTrigger=function(){this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?1===this.$listeners.length?(this.$firstListener=this.$listeners[0],this.trigger=this.triggerFirstListener):this.trigger=this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=D},x.prototype.trigger=D,x.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(),this.$previousValue=null)},x.prototype.$setWithInterceptor=function(e){let t="function"==typeof e?e(this.$currentValue):e;const n=this.$interceptor(t,this.$currentValue);void 0!==n&&(t=n),this.$updateWithNewValue(t)},x.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},x.prototype.set=x.prototype.$basicSet,x.prototype.val=function(){return this.$currentValue},x.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)h.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=D},x.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},x.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}f.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},x.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},x.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);t.__$isObservable&&(t=t.set.bind(t)),n?h.isArray(n.list)?n.list.push(t):(n=[n,t],t=e=>{for(let t=0,r=n.length;t<r;t++)n[t](e)},t.list=n,this.$watchers.set(e,t)):(n=t,this.$watchers.set(e,t)),this.assocTrigger()},x.prototype.off=function(e,t){if(!this.$watchers)return;const n=this.$watchers.get(e);if(!n)return;if(!t||!Array.isArray(n.list))return this.$watchers?.delete(e),void this.assocTrigger();const r=n.indexOf(t);n?.splice(r,1),1===n.length?this.$watchers.set(e,n[0]):0===n.length&&this.$watchers?.delete(e),this.assocTrigger()},x.prototype.once=function(e,t){const n="function"==typeof e?e:t=>t===e,r=e=>{n(e)&&(this.unsubscribe(r),t(e))};this.subscribe(r)},x.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},x.prototype.check=function(e){return new o(this,e)},x.prototype.transform=x.prototype.check,x.prototype.pluck=x.prototype.check,x.prototype.is=x.prototype.check,x.prototype.select=x.prototype.check,x.prototype.get=function(e){const t=this.$currentValue[e];return h.isObservable(t)?t.val():t},x.prototype.when=function(e){return new m(this,e)},x.prototype.equals=function(e){return h.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},x.prototype.toBool=function(){return!!this.$currentValue},x.prototype.toggle=function(){this.set(!this.$currentValue)},x.prototype.reset=function(){if(!this.configs?.reset)return;const e=h.isObject(this.$initialValue)?g(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},x.prototype.toString=function(){return String(this.$currentValue)},x.prototype.valueOf=function(){return this.$currentValue},x.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=E[e],s=O.follow("locale");return N.computed(()=>r(n.val(),s.val(),t),[n,s])},x.prototype.persist=function(e,t={}){let n=w(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=$(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const k=N,T=N;function F(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))):r.__$isObservableWhen?(e.classes.toggle(n,r.isActive()),r.subscribe(t=>e.classes.toggle(n,t))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function I(e,t){for(const n in t){const r=t[n];r.__$isObservable?(e.style[n]=r.val(),r.subscribe(t=>e.style[n]=t)):e.style[n]=r}}function _(e,t,n){const r=n.__$isObservable,o=r?n.val():n;if(h.isBoolean(o)?e[t]=o:e[t]=o===e.value,r){if("checked"===t)return"boolean"==typeof o?e.addEventListener("input",()=>n.set(e[t])):e.addEventListener("input",()=>n.set(e.value)),void n.subscribe(n=>e[t]=n);n.subscribe(n=>e[t]=n===e.value)}}function M(e){this.$hydrate=e}N.useValueProperty=function(e="value"){Object.defineProperty(x.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},N.getById=function(e){const t=f.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},N.cleanup=function(e){e.cleanup()},N.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{f.cleanup()}),setInterval(()=>f.cleanObservables(r),n)},M.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){const e=this.resolveObservableTemplate?this.resolveObservableTemplate():this;return h.isString(e)?j.createStaticTextNode(null,e):j.getChild(null,e)},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},x.prototype.toNdElement=function(){return j.createObservableNode(null,this)},o.prototype.toNdElement=x.prototype.toNdElement,i.prototype.toNdElement=function(){return this.$element??this.$build?.()??this.build?.()??null},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=j.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return j.getChild(this())},M.prototype.toNdElement=function(){return j.createHydratableNode(null,this)};const P=(e,t=1e3)=>new Promise(n=>{let r=!1;const o=t=>{t&&t.target!==e||r||(r=!0,e.removeEventListener("transitionend",o),e.removeEventListener("animationend",o),clearTimeout(s),n())};e.addEventListener("transitionend",o),e.addEventListener("animationend",o);const s=setTimeout(o,t),i=window.getComputedStyle(e),a="0s"!==i.transitionDuration,u="0s"!==i.animationDuration;a||u||o()});i.prototype.transitionOut=function(e){const t=e+"-exit";return this.beforeUnmount("transition-exit",async function(){this.$element.classes.add(t),await P(this.$element),this.$element.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to";return this.$element.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.$element.classes.remove(t),this.$element.classes.add(n),P(this.$element).then(()=>{this.$element.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){return this.$element.classes.add(e),P(this.$element).then(()=>{this.$element.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},x.prototype.handleNdAttribute=function(e,t){d.has(t)?_(e,t,this):function(e,t,n){const r="value"===t?t=>e.value=t:n=>e.setAttribute(t,n);if(n.subscribe(r),"value"===t)return e.value=n.val(),void e.addEventListener("input",()=>n.set(e.value));e.setAttribute(t,n.val())}(e,t,this)},M.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const V=new Map;let L=null;const j={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=j.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=j.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=j.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){const t=V.get(e);if(t)return t.cloneNode();const n=document.createElement(e);return V.set(e,n),n.cloneNode()}return p("Fragment")},bindTextNode(e,t){if(t?.__$isObservable)return t.subscribe(t=>e.nodeValue=t),void(e.nodeValue=t.val());e.nodeValue=t},processChildren(e,t){if(null===e)return;let n=this.getChild(e);n&&t.appendChild(n)},async safeRemove(e){await e.remove()},getChild(e){if(null==e)return null;if(e.toNdElement)do{if(e=e.toNdElement(),h.isElement(e))return e}while(e.toNdElement);return j.createStaticTextNode(null,e)},processAttributes(e,t){t&&function(e,t){h.validateAttributes(t);for(const n in t){const r=n.toLowerCase();let o=t[n];if(null!=o)if(o.handleNdAttribute)o.handleNdAttribute(e,r,o);else{if("object"==typeof o){if("class"===r){F(e,o);continue}if("style"===r){I(e,o);continue}}d.has(r)?_(e,r,o):e.setAttribute(r,o)}}}(e,t)}},R={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",R),Object.defineProperty(DocumentFragment.prototype,"nd",R),Object.defineProperty(i.prototype,"nd",{configurable:!0,get:function(){return this}}),["Click","DblClick","MouseDown","MouseEnter","MouseLeave","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Blur","Change","Focus","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","AfterPrint","BeforePrint","BeforeUnload","Error","HashChange","Load","Offline","Online","PageHide","PageShow","Resize","Scroll","Unload","Abort","CanPlay","CanPlayThrough","DurationChange","Emptied","Ended","LoadedData","LoadedMetadata","LoadStart","Pause","Play","Playing","Progress","RateChange","Seeked","Seeking","Stalled","Suspend","TimeUpdate","VolumeChange","Waiting","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["on"+e]=function(e=null){return this.$element.addEventListener(t,e),this}}),["Click","DblClick","MouseDown","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Change","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","BeforeUnload","HashChange","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onStop"+e]=function(e=null){return W(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return B(this.$element,t,e),this}}),["Click","DblClick","MouseDown","MouseUp","Wheel","KeyDown","KeyPress","Invalid","Reset","Submit","DragOver","Drop","BeforeUnload","TouchCancel","TouchEnd","TouchMove","TouchStart","Copy","Cut","Paste","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onPrevent"+e]=function(e=null){return q(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const q=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},W=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},B=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},U={getClasses(){return this.$element.className?.split(" ").filter(Boolean)},add(e){const t=this.getClasses();t.indexOf(e)>=0||(t.push(e),this.$element.className=t.join(" "))},remove(e){const t=this.getClasses(),n=t.indexOf(e);n<0||(t.splice(n,1),this.$element.className=t.join(" "))},toggle(e,t=void 0){const n=this.getClasses(),r=n.indexOf(e);if(r>=0){if(!0===t)return;n.splice(r,1)}else{if(!1===t)return;n.push(e)}this.$element.className=n.join(" ")},contains(e){return this.getClasses().indexOf(e)>=0}};Object.defineProperty(HTMLElement.prototype,"classes",{configurable:!0,get(){return{$element:this,...U}}});let H=e=>e;e.ArgTypes={},e.ArgTypes={string:()=>!0,number:()=>!0,boolean:()=>!0,observable:()=>!0,element:()=>!0,function:()=>!0,object:()=>!0,objectNotNull:()=>!0,children:()=>!0,attributes:()=>!0,optional:()=>!0,oneOf:()=>!0};const z=function(e,t=null){return Array.isArray(e)||"object"!=typeof e||null===e||"Object"!==e.constructor.name||e.$hydrate?{props:t,children:e}:{props:e,children:t}};function K(e,t,n,r=null){let{props:o,children:s=null}=z(n,r),i=j.createElement(e),a=t&&"function"==typeof t?t(i):i;return j.processAttributes(a,o),j.processChildren(s,a),a}function J(e,t=null){return K.bind(null,e,t)}const Y=new WeakMap,G=(e,t,n)=>{let r=null;if(t.attributes){r={};for(const e in t.attributes)r[e]=t.attributes[e].apply(null,n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e].apply(null,n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e].apply(null,n)}return r?(j.processAttributes(e,r),!0):null},Q=(e,t,n)=>{if(!t.attach)return null;for(const r in t.attach)e.nd[r](function(...e){t.attach[r].apply(this,[...e,...n])})},X=(e,t,n,r)=>{if(r.fn&&("string"==typeof r.fn?j.bindTextNode(t,n[0][r.fn]):r.fn(n,t,e)),r.children)for(let o=0,s=r.children.length;o<s;o++){const s=r.children[o],i=t.childNodes[s.index];X(e,i,n,s)}};function Z(e){let t=null,n=!1;const r={fn:null,children:[]},o=(e,t,n)=>{const r=Y.get(e);if(3===e.nodeType){if(r&&r.value){n.fn=r.value;const o=e.cloneNode();return"string"==typeof r.value?(j.bindTextNode(o,t[0][r.value]),o):(r.value(t,o),o)}return e.cloneNode(!0)}const s=e.cloneNode();r&&(G(s,r,t),Q(s,r,t),n.fn=(e,t)=>{G(t,r,e),Q(t,r,e)});const i=e.childNodes,a=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r={index:e,fn:null},u=o(n,t,r);(r.children||r.fn)&&a.push(r),s.appendChild(u)}return a.length&&(n.children=n.children||[],n.children=a),s},s=e=>{let n=t.cloneNode(!0);return X(n,n,e,r),n};this.clone=i=>{if(t=e(this),!n)return this.clone=()=>t.cloneNode(!0),t.cloneNode(!0);const a=o(t,i,r);return this.clone=s,a};const i=(e,t)=>new M((r,o)=>{n=!0,function(e,t,n,r){Y.has(n)||Y.set(n,{});const o=Y.get(n);"value"!==t?(o[t]=o[t]||{},o[t][r]=e):o.value=e}(e,t,r,o)});this.style=e=>i(e,"styles"),this.class=e=>i(e,"classes"),this.property=e=>this.value(e),this.value=e=>i("function"!=typeof e?e:(t,n)=>{j.bindTextNode(n,e(...t))},"value"),this.attr=e=>i(e,"attributes"),this.attach=e=>i(e,"attach")}function ee(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=p("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new i(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){const t=(...n)=>{try{return this.apply(this,n)}catch(r){return e(r,{caller:t,args:n})}};return t},String.prototype.use=function(e){const t=this;return N.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return h.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return h.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!h.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return N.getById(n)}):this.valueOf()};const te=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},ne=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},re=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{const o=t.get(r);if(o)return o;if(e.length>0)return(...n)=>{const o=e(...n,r);return t.set(r,o),o};const s=e(r);return t.set(r,s),s}})};function oe(e){return e instanceof Date?e:new Date(e)}function se(e,t){const n=oe(e),r=oe(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ie(e){const t=oe(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function ae(e,t){const n=h.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function ue(e,t){const n=e.filter(h.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>h.isObservable(e)?e.val():e))}}function le(e){return ae(e,(e,t)=>e===t)}function ce(e){return ae(e,(e,t)=>e!==t)}function he(e){return ae(e,(e,t)=>e>t)}function pe(e){return ae(e,(e,t)=>e>=t)}function de(e){return ae(e,(e,t)=>e<t)}function fe(e){return ae(e,(e,t)=>e<=t)}function me(e,t=!0,n=""){return ue([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function be(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(h.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ye(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(h.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ge=he,ve=pe,we=de,$e=fe,Se=le,Oe=ce,Ce=be,Ae=ye;function Ee(e,t=!1){return ae(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const xe=Ee;var De=Object.freeze({__proto__:null,all:Ce,and:be,any:Ae,between:function(e,t){return ue([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:xe,createFilter:ae,createMultiSourceFilter:ue,custom:function(e,...t){const n=t.filter(h.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>h.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateEquals:e=>ae(e,(e,t)=>!(!e||!t)&&se(e,t)),dateTimeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateTimeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateTimeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateTimeEquals:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e).getTime()===oe(t).getTime()),endsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Se,equals:le,getSecondsOfDay:ie,greaterThan:he,greaterThanOrEqual:pe,gt:ge,gte:ve,inArray:function(e){return ae(e,(e,t)=>t.includes(e))},includes:Ee,isEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:se,lessThan:de,lessThanOrEqual:fe,lt:we,lte:$e,match:me,neq:Oe,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:ce,notIn:function(e){return ae(e,(e,t)=>!t.includes(e))},or:ye,startsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)>ie(t)),timeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)<ie(t)),timeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),timeEquals:e=>ae(e,(e,t)=>{if(!e||!t)return!1;const n=oe(e),r=oe(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:oe});const Ne=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");x.call(this,e,t)};(Ne.prototype=Object.create(x.prototype)).constructor=Ne,Ne.prototype.__$isObservableArray=!0,Object.defineProperty(Ne.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{Ne.prototype[e]=function(...t){const n=this.$currentValue[e].apply(this.$currentValue,t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{Ne.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),Ne.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},Ne.prototype.at=function(e){return this.$currentValue[e]},Ne.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},Ne.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},Ne.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},Ne.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},Ne.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},Ne.prototype.isEmpty=function(){return 0===this.$currentValue.length},Ne.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},Ne.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=h.isObservable(o)?me(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push.apply(n,t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=N.array(),s=Object.entries(r),i=()=>{const e=t.val().filter(e=>{for(const[t,n]of s)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(i)),i(),o},Ne.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},Ne.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},Ne.prototype.deepSubscribe=function(e){const t=b(()=>e(this.val())),n=new WeakMap,r=e=>{n.has(e)||(e?.__$isObservableArray?n.set(e,e.deepSubscribe(t)):e?.__$isObservable&&(e.subscribe(t),n.set(e,()=>e.unsubscribe(t))))},o=e=>{const t=n.get(e);t&&(t(),n.delete(e))};return this.$currentValue.forEach(r),this.subscribe(t),this.subscribe((e,t,n)=>{switch(n?.action){case"push":case"unshift":case"merge":n.args.forEach(r);break;case"splice":{const[e,t,...s]=n.args;n.result?.forEach(o),s.forEach(r);break}case"remove":o(n.result);break;case"clear":this.$currentValue.forEach(o)}}),()=>{this.$currentValue.forEach(o)}},N.array=function(e=[],t=null){return new Ne(e,t)},N.batch=function(e){const t=N(0),n=function(){if(h.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const ke=function(e,t){x.call(this,e),this.$observables={},this.configs=t,this.$load(e);for(const t in e)Object.hasOwn(this,t)||Object.defineProperty(this,t,{get:()=>this.$observables[t],set:e=>this.$observables[t].set(e)})};ke.prototype=Object.create(x.prototype),Object.defineProperty(ke,"$value",{get(){return this.val()},set(e){this.set(e)}}),ke.prototype.__$isObservableObject=!0,ke.prototype.__isProxy__=!0,ke.prototype.$load=function(e){const t=this.configs;for(const n in e){const r=e[n];if(Array.isArray(r)){if(!1!==t?.deep){const e=r.map(e=>h.isJson(e)?N.json(e,t):h.isArray(e)?N.array(e,t):N(e,t));this.$observables[n]=N.array(e,t);continue}this.$observables[n]=N.array(r,t)}else h.isObservable(r)||h.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?N.object(r,t):N(r,t)}},ke.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(h.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>h.isObservable(e)?e.val():h.isProxy(e)?e.$value:e)),e[t]=r}else h.isProxy(n)?e[t]=n.$value:e[t]=n}return e},ke.prototype.$val=ke.prototype.val,ke.prototype.get=function(e){const t=this.$observables[e];return h.isObservable(t)?t.val():h.isProxy(t)?t.$value:t},ke.prototype.$get=ke.prototype.get,ke.prototype.set=function(e){const t=h.isProxy(e)?e.$value:e,n=this.configs;for(const r in t){const o=this.$observables[r],s=e[r],i=t[r];if(h.isObservable(o)){if(!h.isArray(i)){o.set(i);continue}const e=s.at(0);if(h.isObservable(e)||h.isProxy(e)){const t=i.map(t=>h.isProxy(e)?N.init(t,n):N(t,n));o.set(t);continue}o.set([...i]);continue}h.isProxy(o)?o.update(i):this[r]=i}},ke.prototype.$set=ke.prototype.set,ke.prototype.$updateWith=ke.prototype.set,ke.prototype.observables=function(){return Object.values(this.$observables)},ke.prototype.$observables=ke.prototype.observables,ke.prototype.keys=function(){return Object.keys(this.$observables)},ke.prototype.$keys=ke.prototype.keys,ke.prototype.clone=function(){return N.init(this.val(),this.configs)},ke.prototype.$clone=ke.prototype.clone,ke.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},ke.prototype.originalSubscribe=ke.prototype.subscribe,ke.prototype.subscribe=function(e){const t=this.observables(),n=b(()=>this.trigger());this.originalSubscribe(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];r.__$isObservableArray?r.deepSubscribe(n):r.subscribe(n)}},ke.prototype.configs=function(){return this.configs},ke.prototype.update=ke.prototype.set,N.init=function(e,t=null){return new ke(e,t)},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.value=function(e){if(h.isObservable(e))return e.val();if(h.isProxy(e))return e.$value;if(h.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(N.value(r))}return t}return e},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new x(e()),o=b(()=>n.set(e()));if(h.isFunction(t)){if(!h.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{h.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Te=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!h.isObservable(e)&&!h.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=p("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=j.getChild(t),h.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Fe=function(e,t,n=!0){if(!h.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=p("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=j.getChild(r),h.isFragment(r)&&(r=Array.from(r.children)),n&&s.set(e,r),r):null},a=e.val(),u=i(a);return u&&o.appendChild(u),e.subscribe(e=>{const t=i(e);o.remove(),t&&o.appendChild(t)}),o.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&s.delete(e),delete t[e]}})},Ie=function(e,t,n){if(!h.isObservable(e))throw new r("Toggle : condition must be an Observable");return Fe(e,{true:t,false:n})},_e=J("div"),Me=J("span"),Pe=J("label"),Ve=J("p"),Le=Ve,je=J("strong"),Re=J("h1"),qe=J("h2"),We=J("h3"),Be=J("h4"),Ue=J("h5"),He=J("h6"),ze=J("br"),Ke=J("a"),Je=J("pre"),Ye=J("code"),Ge=J("blockquote"),Qe=J("hr"),Xe=J("em"),Ze=J("small"),et=J("mark"),tt=J("del"),nt=J("ins"),rt=J("sub"),ot=J("sup"),st=J("abbr"),it=J("cite"),at=J("q"),ut=J("dl"),lt=J("dt"),ct=J("dd"),ht=J("form",function(e){return e.submit=function(t){return"function"==typeof t?(e.onSubmit(e=>{e.preventDefault(),t(e)}),e):(this.setAttribute("action",t),e)},e.multipartFormData=function(){return this.setAttribute("enctype","multipart/form-data"),e},e.post=function(t){return this.setAttribute("method","post"),this.setAttribute("action",t),e},e.get=function(e){this.setAttribute("method","get"),this.setAttribute("action",e)},e}),pt=J("input"),dt=J("textarea"),ft=dt,mt=J("select"),bt=J("fieldset"),yt=J("option"),gt=J("legend"),vt=J("datalist"),wt=J("output"),$t=J("progress"),St=J("meter"),Ot=J("button"),Ct=J("main"),At=J("section"),Et=J("article"),xt=J("aside"),Dt=J("nav"),Nt=J("figure"),kt=J("figcaption"),Tt=J("header"),Ft=J("footer"),It=J("img"),_t=function(e,t){return It({src:e,...t})},Mt=J("details"),Pt=J("summary"),Vt=J("dialog"),Lt=J("menu"),jt=J("ol"),Rt=J("ul"),qt=J("li"),Wt=qt,Bt=jt,Ut=Rt,Ht=J("audio"),zt=J("video"),Kt=J("source"),Jt=J("track"),Yt=J("canvas"),Gt=J("svg"),Qt=J("time"),Xt=J("data"),Zt=J("address"),en=J("kbd"),tn=J("samp"),nn=J("var"),rn=J("wbr"),on=J("caption"),sn=J("table"),an=J("thead"),un=J("tfoot"),ln=J("tbody"),cn=J("tr"),hn=cn,pn=J("th"),dn=pn,fn=pn,mn=J("td"),bn=mn,yn=J("");var gn=Object.freeze({__proto__:null,Abbr:st,Address:Zt,Anchor:p,Article:Et,Aside:xt,AsyncImg:function(e,t,n,o){const s=h.isObservable(e)?e.val():e,i=_t(t||s,n),a=new Image;return a.onload=()=>{h.isFunction(o)&&o(null,i),i.src=h.isObservable(e)?e.val():e},a.onerror=()=>{h.isFunction(o)&&o(new r("Image not found"))},h.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Ht,BaseImage:It,Blockquote:Ge,Br:ze,Button:Ot,Canvas:Yt,Caption:on,Checkbox:e=>pt({type:"checkbox",...e}),Cite:it,Code:Ye,ColorInput:e=>pt({type:"color",...e}),Data:Xt,Datalist:vt,DateInput:e=>pt({type:"date",...e}),DateTimeInput:e=>pt({type:"datetime-local",...e}),Dd:ct,Del:tt,Details:Mt,Dialog:Vt,Div:_e,Dl:ut,Dt:lt,Em:Xe,EmailInput:e=>pt({type:"email",...e}),FieldSet:bt,FigCaption:kt,Figure:Nt,FileInput:e=>pt({type:"file",...e}),Footer:Ft,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=p("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,d=e=>{if(!s)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&r.remove(),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},f=(e,s)=>{const i=((e,t,n)=>{if(h.isString(n)){const r=h.isObservable(e)?e.val():e,o=r?.[n];return h.isObservable(o)?o.val():o??t}return h.isFunction(n)?n(e,t):(h.isObservable(e)?e.val():e)??t})(e,s,o);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(s),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?N(s):null;let o=j.getChild(t(e,n));if(!o)throw new r("ForEach child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(o),indexObserver:n})}catch(e){throw n.error("ForEach",`Error creating element for key ${i}`,e),e}return i},m=()=>{const t=a.parentNode;if(!t)return;const n=h.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=f(n[e],e);c.add(t)}else for(const e in n){const t=f(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),d(),void l?.clear();d(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return m(),h.isObservable(e)&&e.subscribe(m),i},ForEachArray:function(e,t,n={}){const o=p("ForEach Array",n.isParentUniqueChild),s=o.endElement(),i=o.startElement();let a=new Map,u=0;const l=t.length>=2,c=e=>{o.removeChildren(),m(e),u=0},d=e=>a.get(e)?.child,f=(e,t=!0)=>{const n=a.get(e);if(n){if(t){const e=n.child;e?.remove(),a.delete(n.keyId)}n.indexObserver?.cleanup()}},m=e=>{if(!n.shouldKeepItemsInCache)if(l){for(const[t,n]of a.entries())e&&e.contains(t)||f(t,!1);a.clear()}else a.clear()},b=(e,n)=>{const o=a.get(e);if(o){o.indexObserver?.set(n);const t=o.child;if(t)return t;a.delete(e)}const s=l?N(n):null;let i=j.getChild(t(e,s));if(i)return a.set(e,{child:i,indexObserver:s}),i;throw new r("ForEachArray child can't be null or undefined!")},y=function(e,t){const n=a.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},g={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(b(e[t],u)),u++;return n},add(e,t=2){o.appendElement(g.toFragment(e))},replace(e){c(e),g.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=d(r),t&&n.appendChild(t);t=null,o.appendElement(n,s)},removeOne(e,t){f(e,!0)},clear:c,merge(e){g.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),g.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(b(t,o)),u++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore(g.toFragment(e),i.nextSibling)},splice(e,t){const[n,r,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)y(e,u);else if(t.length>1){const e=d(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)y(t[e],u)}}else a=s;u.replaceChildren(),i&&i.length&&a&&o.insertBefore(g.toFragment(i),a.nextSibling)},reverse(e,t){g.reOrder(t)},sort(e,t){g.reOrder(t)},remove(e,t){g.removeOne(t)},pop(e,t){g.removeOne(t)},shift(e,t){g.removeOne(t)},swap(e,t){const n=s.parentNode;let r=d(t[0]),o=d(t[1]);if(!r||!o)return;const i=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,i),r=null,o=null}},v=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(n?.action)g[n.action]&&g[n.action](n.args,n.result);else{if(0===u)return void g.add(e);g.replace(e)}((e,t=0)=>{if(!l)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=a.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===u)return;c()}};return e.val().length&&v(e.val(),0,{action:null}),h.isObservable(e)&&e.subscribe(v),o},Form:ht,Fragment:yn,H1:Re,H2:qe,H3:We,H4:Be,H5:Ue,H6:He,Header:Tt,HiddenInput:e=>pt({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),Te(r,t,n)},HideIfNot:function(e,t,n){return Te(e,t,n)},Hr:Qe,Img:_t,Input:pt,Ins:nt,Kbd:en,Label:Pe,LazyImg:function(e,t){return _t(e,{...t,loading:"lazy"})},Legend:gt,Li:Wt,Link:Ke,ListItem:qt,Main:Ct,Mark:et,Match:Fe,Menu:Lt,Meter:St,MonthInput:e=>pt({type:"month",...e}),NativeDocumentFragment:p,Nav:Dt,NumberInput:e=>pt({type:"number",...e}),Ol:Bt,Option:yt,OrderedList:jt,Output:wt,P:Ve,Paragraph:Le,PasswordInput:e=>pt({type:"password",...e}),Pre:Je,Progress:$t,Quote:at,Radio:e=>pt({type:"radio",...e}),RangeInput:e=>pt({type:"range",...e}),ReadonlyInput:e=>pt({readonly:!0,...e}),Samp:tn,SearchInput:e=>pt({type:"search",...e}),Section:At,Select:mt,ShowIf:Te,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!h.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Te(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!h.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return Te(e.when(t),n)}throw new r("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Ot(e,{type:"button",...t}),Small:Ze,Source:Kt,Span:Me,Strong:je,Sub:rt,SubmitButton:(e,t)=>Ot(e,{type:"submit",...t}),Summary:Pt,Sup:ot,Svg:Gt,Switch:Ie,TBody:ln,TBodyCell:bn,TFoot:un,TFootCell:fn,THead:an,THeadCell:dn,TRow:hn,Table:sn,Td:mn,TelInput:e=>pt({type:"tel",...e}),TextArea:dt,TextInput:ft,Th:pn,Time:Qt,TimeInput:e=>pt({type:"time",...e}),Tr:cn,Track:Jt,Ul:Ut,UnorderedList:Rt,UrlInput:e=>pt({type:"url",...e}),Var:nn,Video:zt,Wbr:rn,WeekInput:e=>pt({type:"week",...e}),When:function(e){if(!h.isObservable(e))throw new r("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,Ie(e,t,n)),toNdElement:()=>Ie(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=p("Portal "+n);return r.appendChild(j.getChild(e)),(t||document.body).appendChild(r),r}});const vn={};function wn(e,t,n={}){e="/"+y(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u=n.layout||null,l={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=vn[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},p=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=h(t);return n&&n.pattern?(l[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+y(e,"/");if(!p().exec(e))return!1;const t={};return p().exec(e).forEach((e,n)=>{if(n<1)return;const r=c[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=h(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class $n extends Error{constructor(e,t){super(e),this.context=t}}const Sn=(e,t)=>{const n=[];return e.forEach(e=>{n.push(y(e.suffix,"/"))}),n.push(y(t,"/")),n.join("/")},On=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Cn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},An=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function En(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function xn(){this.push=function(e){try{const{route:t,path:n,params:r,query:o}=this.resolve(e);if(window.history.state&&window.history.state.path===n)return;window.history.pushState({name:t.name(),params:r,path:n},t.name()||n,n),this.handleRouteChange(t,r,o,n)}catch(e){n.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:r,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:r},t.name()||r,r),this.handleRouteChange(t,o,{},r)}catch(e){n.error("HistoryRouter","Error in replaceState",e)}},this.forward=function(){window.history.forward()},this.back=function(){window.history.back()},this.init=function(e){window.addEventListener("popstate",e=>{try{if(!e.state||!e.state.path)return;const t=e.state.path,{route:n,params:r,query:o,path:s}=this.resolve(t);if(!n)return;this.handleRouteChange(n,r,o,s)}catch(e){n.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:r,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,r,o,s)}}function Dn(){const e=[];let t=0;const n=n=>{const r=t+n;if(!e[r])return;t=r;const{route:o,params:s,query:i,path:a}=e[r];this.handleRouteChange(o,s,i,a)};this.push=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]&&e[t].path===i||(e.splice(t+1),e.push({route:r,params:o,query:s,path:i}),t++,this.handleRouteChange(r,o,s,i))},this.replace=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]={route:r,params:o,query:s,path:i},this.handleRouteChange(r,o,s,i)},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){const r=n||window.location.pathname+window.location.search,{route:o,params:s,query:i,path:a}=this.resolve(r);e.push({route:o,params:s,query:i,path:a}),t=0,this.handleRouteChange(o,s,i,a)}}function Nn(e,t){const n=new Map,r=new WeakMap,o=new WeakMap;let s=null,i=null;const a=(e,t)=>{const n=o.get(e);if(n)return n;let r=e;return h.isAnchor(e)||(r=p(t),r.appendChild(e)),o.set(e,r),r},u=()=>{h.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return h.isNDElement(e)&&(t=e.node()),t},d=function(e,n,o){const h=n.layout();if(h)return void((e,n,o,i)=>{let h=c(n);const p=r.get(h);if(p){if(p===s){const e=a(h,i);return u(),void e.replaceContent(h)}return l(),s=p,a(h,i).replaceContent(h),void t.appendChild(s)}l();const d=a(h,i);s=e(d),r.set(h,s),t.appendChild(s)})(h,e,0,o);let p=c(e);l(),t.appendChild(p),i=e},f=function(e){if(!e.route)return;const{route:t,params:r,query:o,path:s}=e;if(n.has(s)){const e=n.get(s);return void d(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),d(i,t,s)};return e.subscribe(f),f(e.currentState()),t}const kn="default";function Tn(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)En.apply(this,[]);else if("history"===e.mode)xn.apply(this,[]);else{if("memory"!==e.mode)throw new $n("Invalid router mode "+e.mode);Dn.apply(this,[])}const a=function(e,t){for(const r of s)try{r(e),t&&t(e)}catch(e){n.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,n,s){const i=new wn(Sn(o,e),n,{...s,middlewares:On(o,s?.middlewares||[]),name:s?.name?Cn(o,s.name):null,layout:s?.layout||An(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!h.isFunction(n))throw new $n("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},n={}){const o=r[e];if(!o)throw new $n(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(h.isJson(e)){const t=r[e.name];if(!t)throw new $n(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[n,o]=e.split("?"),s="/"+y(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new $n(`Route not found for url: ${n}`);const u={};if(o){const e=new URLSearchParams(o).entries();for(const[t,n]of e)u[t]=n}return{route:a,params:i,query:u,path:e}},this.subscribe=function(e){if(!h.isFunction(e))throw new $n("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function Fn(e,t){const{to:n,href:r,...o}=e;if(r){const e=Tn.get();return Ke({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||kn,a=Tn.get(i);if(!a)throw new $n('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ke({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Tn.routers={},Tn.create=function(e,t){if(!h.isFunction(t))throw n.error("Router","Callback must be a function"),new $n("Callback must be a function");const r=new Tn(e);return Tn.routers[e.name||kn]=r,t(r),r.init(e.entry),r.mount=function(e){if(h.isString(e)){const t=document.querySelector(e);if(!t)throw new $n(`Container not found for selector: ${e}`);e=t}else if(!h.isElement(e))throw new $n("Container must be a string or an Element");return Nn(r,e)},r},Tn.get=function(e){const t=Tn.routers[e||kn];if(!t)throw new $n(`Router not found for name: ${e}`);return t},Tn.push=function(e,t=null){return Tn.get(t).push(e)},Tn.replace=function(e,t=null){return Tn.get(t).replace(e)},Tn.forward=function(e=null){return Tn.get(e).forward()},Tn.back=function(e=null){return Tn.get(e).back()},Fn.blank=function(e,t){return Ke({...e,target:"_blank"},t)};var In=Object.freeze({__proto__:null,Link:Fn,RouteParamPatterns:vn,Router:Tn});var _n=Object.freeze({__proto__:null,memoize:e=>re(e),once:e=>ne(e),singleton:e=>te(e)}),Mn=Object.freeze({__proto__:null,Cache:_n,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};if(o)if(o instanceof FormData)i.body=o;else if("GET"!==n)i.headers["Content-Type"]="application/json",i.body=JSON.stringify(o);else{const e=new URLSearchParams(o).toString();e&&(r=r+(r.includes("?")?"&":"?")+e)}for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const u=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(u?.message||a.statusText);throw e.status=a.status,e.data=u,e}return u},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},filters:De});return e.$=k,e.ElementCreator=j,e.HtmlElementWrapper=J,e.NDElement=i,e.Observable=N,e.PluginsManager=null,e.SingletonView=ee,e.Store=O,e.StoreFactory=S,e.TemplateCloner=Z,e.Validator=h,e.autoMemoize=re,e.autoOnce=ne,e.classPropertyAccumulator=function(e=[]){let t=h.isString(e)?e.split(" ").filter(Boolean):e;const n=h.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=function(e){return h.isObservable(e)?j.createObservableNode(null,e):j.createStaticTextNode(null,e)},e.cssPropertyAccumulator=function(e={}){let t=h.isString(e)?e.split(";").filter(Boolean):e;const n=h.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=gn,e.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n,s=t.get(r);if(s)return s;const i=e(...o);return t.set(r,i),i}},e.normalizeComponentArgs=z,e.obs=T,e.once=te,e.router=In,e.useCache=function(e){let t=null;const n=function(n){return t||(t=new Z(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new ee(e)),t.render(n)}},e.utils=Mn,e.withValidation=H,e}({});
package/docs/cache.md CHANGED
@@ -259,7 +259,7 @@ await API.posts.get('456');
259
259
 
260
260
  ### Key Concepts
261
261
 
262
- 1. **Property name becomes the key**: `API.users` `key = 'users'`
262
+ 1. **Property name becomes the key**: `API.users` -> `key = 'users'`
263
263
  2. **Function executed per unique key**: First access creates instance
264
264
  3. **Results cached by key**: Subsequent accesses return same instance
265
265
  4. **Each key has its own instance**: `API.users` ≠ `API.posts`
@@ -211,7 +211,7 @@ const list = ForEach(items, (item) =>
211
211
  Div([
212
212
  item,
213
213
  Button('Remove').nd.onClick(() => {
214
- // User action → State change UI update
214
+ // User action → State change -> UI update
215
215
  const index = items.val().indexOf(item);
216
216
  items.splice(index, 1);
217
217
  })
@@ -172,6 +172,53 @@ Div("Content").nd.mounted(element => {
172
172
  });
173
173
  ```
174
174
 
175
+ ### `unmounted(callback)`
176
+ Shortcut to define only the unmount callback.
177
+ ```javascript
178
+ Div("Content").nd.unmounted(element => {
179
+ console.log("Element removed from DOM!");
180
+ });
181
+ ```
182
+
183
+ ### `beforeUnmount(id, callback)`
184
+ Registers a callback executed before the element is removed from the DOM.
185
+ Useful for exit animations or cleanup before removal.
186
+ ```javascript
187
+ Div("Content").nd.beforeUnmount('my-cleanup', async () => {
188
+ await saveData();
189
+ });
190
+ ```
191
+
192
+ ## Transitions
193
+
194
+ ### `transition(name)`
195
+ Applies both enter and exit transitions using CSS classes.
196
+ ```javascript
197
+ Div("Content").nd.transition('fade');
198
+ // On mount : adds 'fade-enter-from', then 'fade-enter-to'
199
+ // On unmount: adds 'fade-exit'
200
+ ```
201
+
202
+ ### `transitionIn(name)`
203
+ Applies only the enter transition.
204
+ ```javascript
205
+ Div("Content").nd.transitionIn('slide');
206
+ ```
207
+
208
+ ### `transitionOut(name)`
209
+ Applies only the exit transition.
210
+ ```javascript
211
+ Div("Content").nd.transitionOut('slide');
212
+ ```
213
+
214
+ ### `animate(name)`
215
+ Triggers a one-shot CSS animation by adding then automatically removing a class.
216
+ ```javascript
217
+ Button("Click").nd.onClick(function() {
218
+ this.nd.animate('bounce');
219
+ });
220
+ ```
221
+
175
222
  ## Practical Examples
176
223
 
177
224
  ### Custom Event Handler
@@ -210,7 +257,7 @@ const todoForm = Form([
210
257
  Input({ type: 'text', value: newTodo })
211
258
  .nd.onEnter(addTodo),
212
259
 
213
- Button('Add', { type: 'submit' })
260
+ Button({ type: 'submit' }, 'Add')
214
261
  ]).nd.onPreventSubmit(addTodo);
215
262
  ```
216
263
 
@@ -224,19 +271,6 @@ element.nd.on('customEvent', callback, options)
224
271
  element.nd.on('scroll', callback, { passive: true })
225
272
  ```
226
273
 
227
- ### Batch Event Registration
228
-
229
- Register multiple events at once:
230
- ```javascript
231
- // Register multiple events in one call
232
- Input()
233
- .nd.on({
234
- focus: e => console.log('Focused'),
235
- blur: e => console.log('Blurred'),
236
- input: e => console.log('Value:', e.target.value)
237
- });
238
- ```
239
-
240
274
  ### Reference Management
241
275
 
242
276
  ```javascript
@@ -278,7 +312,9 @@ Div([
278
312
 
279
313
  ## Limitations
280
314
 
281
- - Event handlers are not automatically removed (manual management required if needed)
315
+ - Event handlers added via .nd.onXxx() are not automatically removed.
316
+ Use the native removeEventListener() on .$element if needed,
317
+ or rely on .nd.remove() which cleans up the element entirely.
282
318
  - Access to native HTML element is still necessary for advanced APIs
283
319
 
284
320
  NDElement thus provides a practical abstraction layer while preserving the power and performance of native DOM.