native-document 1.0.48 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var NativeDocumentDevTools=function(){"use strict";let e={};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()};const i=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)}}}}}(),s=function(e,t){this.$target=t,this.$observer=e};function l(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,i.emit("CreateObservable",this)}s.prototype.__$isObservableWhen=!0,s.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},s.prototype.val=function(){return this.$observer.$currentValue===this.$target},s.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},s.prototype.isActive=function(){return this.$observer.$currentValue===this.$target},Object.defineProperty(l.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),l.prototype.__$isObservable=!0;const a={},u=function(){};l.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},l.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||a;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const c=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};l.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);c(t,!0)}if(e.has(t)){const n=e.get(t);c(n,!1)}},l.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=u},l.prototype.trigger=u,l.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,i.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,i.emit("ObservableAfterChange",this))},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)A.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=u},l.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},l.prototype.subscribe=function(e,n=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return t.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new r("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),i.emit("ObservableSubscribe",this,n),()=>{this.unsubscribe(e),this.assocTrigger(),i.emit("ObservableUnsubscribe",this)}},l.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!A.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},l.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},l.prototype.check=function(e){return new o(this,e)},l.prototype.get=function(e){const t=this.$currentValue[e];return A.isObservable(t)?t.val():t},l.prototype.when=function(e){return new s(this,e)},l.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"},l.prototype.equals=function(e){return A.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},l.prototype.toBool=function(){return!!this.$currentValue},l.prototype.toggle=function(){this.set(!this.$currentValue)};const p={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(p.mountedSupposedSize>0)for(const e of t.addedNodes){const t=p.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(p.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=p.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{p.mounted.delete(e),p.unmounted.delete(e),p.mountedSupposedSize--,p.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,p.mounted.set(e,n),p.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,p.unmounted.set(e,n),p.unmountedSupposedSize++}}}};p.observer=new MutationObserver(p.checkMutation),p.observer.observe(document.body,{childList:!0,subtree:!0});const d=["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"];function h(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}h.prototype.__$isNDElement=!0,h.prototype.valueOf=function(){return this.$element},h.prototype.ref=function(e,t){return e[t]=this.$element,this},h.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},h.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},h.prototype.lifecycle=function(e){return this.$observer=this.$observer||p.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},h.prototype.mounted=function(e){return this.lifecycle({mounted:e})},h.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},h.prototype.htmlElement=function(){return this.$element},h.prototype.node=h.prototype.htmlElement,h.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},h.prototype.openShadow=function(e=null){return this.shadow("open",e)},h.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},h.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const f={},b=function(e,t,n){if(!e)return;if(!f[t]){const r=new WeakMap;return f[t]=r,void r.set(e,n)}const r=f[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);A.isArray(o)?o.push(n):r.set(e,[store[t],n])},g=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},m=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},v=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},y=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=f[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(A.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of d){const t=e.toLowerCase();h.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},h.prototype["onPrevent"+e]=function(e){return g(this.$element,t,e),this},h.prototype["onStop"+e]=function(e){return m(this.$element,t,e),this},h.prototype["onPreventStop"+e]=function(e){return v(this.$element,t,e),this},h.prototype["when"+e]=function(e){return b(this.$element,t,e),this},h.prototype["capture"+e]=function(e){return y(this.$element,t,e),this}}const $=1,O=3,w=8,C=11,A={isObservable:e=>e?.__$isObservable||e instanceof l||e instanceof o,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,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,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===$||e.nodeType===O||e.nodeType===C||e.nodeType===w),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 h,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&&(A.isObject(e)&&Object.values(e).some(e=>A.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")}},x=["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 S(e){return new l(e)}function E(e,t,n){e.classes.toggle(t,n)}function V(e,t,n){e.style[t]=n}function P(e,t,n){A.isBoolean(n)?e[t]=n:e[t]=n===e.value}function N(e,t,n,r){A.isBoolean(n)?r.set(e[t]):r.set(e.value)}function k(e,t){for(let n in t){const r=t[n];A.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(E.bind(null,e,n))):A.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(E.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function _(e,t){for(let n in t){const r=t[n];A.isObservable(r)?(e.style[n]=r.val(),r.subscribe(V.bind(null,e,n))):e.style[n]=r}}function T(e,t,n){const r=A.isObservable(n)?n.val():n;A.isBoolean(r)?e[t]=r:e[t]=r===e.value,A.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",N.bind(null,e,t,r,n)),n.subscribe(P.bind(null,e,t)))}function D(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}S.useValueProperty=function(e="value"){Object.defineProperty(l.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},S.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},S.cleanup=function(e){e.cleanup()},S.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)};const j=new Map;let M=null;const L={createTextNode:()=>(M||(M=document.createTextNode("")),M.cloneNode()),createObservableNode(e,t){const n=L.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=L.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=L.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(j.has(e))return j.get(e).cloneNode();const t=document.createElement(e);return j.set(e,t),t.cloneNode()}return new B("Fragment")},processChildren(e,t){if(null!==e){if(i.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}i.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(A.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,A.isString(e)))return L.createStaticTextNode(null,e);if(A.isElement(e))return e;if(A.isObservable(e))return L.createObservableNode(null,e);if(A.isNDElement(e))return e.$element??e.$build?.()??null;if(A.$element)return A.$element;if(A.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return A.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?L.createHydratableNode(null,e):L.createStaticTextNode(null,e)},processAttributes(e,t){A.isFragment(e)||t&&function(e,t){if(!A.isObject(t))throw new r("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(A.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,A.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>A.isObservable(e));o=S.computed(()=>o.map(e=>A.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&A.isObject(o)?k(e,o):"style"===r&&A.isObject(o)?_(e,o):x.includes(r)?T(e,r,o):A.isObservable(o)?D(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(i.emit("Setup",e,t,n),e)};function B(e,n=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),i=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(i),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild;const s=e=>n||e.firstChild===o&&e.lastChild===i;return r.appendElement=function(e,t=null){const n=o.parentNode,s=t||i;n!==r?n?.insertBefore(e,s):n.nativeInsertBefore(e,s)},r.appendChild=function(e,n=null){const o=i.parentNode;o?function(e,t,n){const o=A.isElement(t)?t:L.getChild(t);e!==r?s(e)&&n===i?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,n=n??i):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;const l=document.createDocumentFragment();for(;n&&n!==i;)t=n.nextSibling,l.append(n),n=t;l.replaceChildren()},r.remove=function(){if(i.parentNode===r)return;let e,t=o.nextSibling;for(;t&&t!==i;)e=t.nextSibling,r.nativeAppendChild(t),t=e},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),i.remove()},r.replaceContent=function(e){const t=i.parentNode;t&&(s(t)?t.replaceChildren(o,e,i):(r.removeChildren(),t.insertBefore(e,i)))},r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return i},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}Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new h(this)}});const I={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,...I}}});function F(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!A.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=L.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&L.processAttributes(l,o),i&&L.processChildren(i,l),L.setup(l,o,t)}function z(e,t){return F.bind(null,e.toLowerCase(),t)}const W=z("div");z("span"),z("label"),z("p"),z("strong"),z("h1"),z("h2"),z("h3"),z("h4"),z("h5"),z("h6"),z("br"),z("a"),z("pre"),z("code"),z("blockquote"),z("hr"),z("em"),z("small"),z("mark"),z("del"),z("ins"),z("sub"),z("sup"),z("abbr"),z("cite"),z("q"),z("dl"),z("dt"),z("dd"),z("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}),z("input"),z("textarea"),z("select"),z("fieldset"),z("option"),z("legend"),z("datalist"),z("output"),z("progress"),z("meter");const R=z("button");z("main"),z("section"),z("article"),z("aside"),z("nav"),z("figure"),z("figcaption"),z("header"),z("footer"),z("img"),z("details"),z("summary"),z("dialog"),z("menu"),z("ol"),z("ul"),z("li"),z("audio"),z("video"),z("source"),z("track"),z("canvas"),z("svg"),z("time"),z("data"),z("address"),z("kbd"),z("samp"),z("var"),z("wbr"),z("caption"),z("table"),z("thead"),z("tfoot"),z("tbody"),z("tr"),z("th"),z("td"),z(""),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 h(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return S.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return A.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return A.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!A.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return S.getById(n)}):this.valueOf()};const U=function(e,{propagation:t=!1,deep:n=!1}={}){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");l.apply(this,[e]),i.emit("CreateObservableArray",this)};U.prototype.__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{U.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{U.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),U.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},U.prototype.at=function(e){return this.$currentValue[e]},U.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},U.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},U.prototype.length=function(){return this.$currentValue.length},U.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],i=n[t];return n[e]=i,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,i]}),!0},U.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)},U.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},U.prototype.isEmpty=function(){return 0===this.$currentValue.length},U.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},S.array=function(e){return new U(e)},S.batch=function(e){const t=S(0),n=function(){if(A.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};S.init=function(e,{propagation:t=!1,deep:n=!0}={}){const r={};for(const o in e){const i=e[o];if(Array.isArray(i)){if(n){const e=i.map(e=>A.isJson(e)?S.json(e,{propagation:t,deep:n}):A.isArray(e)?S.array(e,{propagation:t,deep:n}):S(e));r[o]=S.array(e,{propagation:t});continue}r[o]=S.array(i,{propagation:t})}else A.isObservable(i)||A.isProxy(i)?r[o]=i:r[o]=S(i)}const o=()=>function(e){const t={};for(const n in e){const r=e[n];if(A.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>A.isObservable(e)?e.val():A.isProxy(e)?e.$value:e)),t[n]=e}else A.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(r),i=()=>S.init(o(),{propagation:t,deep:n}),s=e=>{S.update(a,e)},l=e=>function(e,t){const n=e[t];return A.isObservable(n)?n.val():A.isProxy(n)?n.$value:n}(r,e),a=new Proxy(r,{get:(t,n)=>"__isProxy__"===n||("$value"===n?o():"$clone"===n?i:"$keys"===n?Object.keys(e):"$observables"===n?Object.values(t):"$set"===n||"$updateWith"===n?s:"$get"===n?l:"$val"===n?o:void 0!==t[n]?t[n]:void 0),set:(e,t,n)=>void 0===e[t]||(A.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return a},S.arrayOfObject=function(e){return e.map(e=>S.object(e))},S.value=function(e){if(A.isObservable(e))return e.val();if(A.isProxy(e))return e.$value;if(A.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(S.value(r))}return t}return e},S.update=function(e,t){const n=A.isProxy(t)?t.$value:t;for(const r in n){const o=e[r],i=t[r],s=n[r];if(A.isObservable(o)){if(A.isArray(s)){const e=i.at(0);if(A.isObservable(e)||A.isProxy(e)){const t=s.map(t=>A.isProxy(e)?S.init(t):S(t));o.set(t);continue}o.set([...s]);continue}o.set(s)}else A.isProxy(o)?S.update(o,s):e[r]=s}},S.object=S.init,S.json=S.init,S.computed=function(e,t=[]){const n=new l(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),A.isFunction(t)){if(!A.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{A.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const H={createdObservable:S(0)},q={name:"DevTools",onCreateObservable(e){H.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function J(){let e=!1;const t=W({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[W({class:"widget-label"},H.createdObservable),R({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=W(W({class:"devtools-app-panel-wrapper pin-to-right"},[J,W({class:"devtools-app-panel"}),W("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:q}}();
1
+ var NativeDocumentDevTools=function(){"use strict";let e={};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()};const i=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)}}}}}(),s=function(e,t){this.$target=t,this.$observer=e};function l(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,i.emit("CreateObservable",this)}s.prototype.__$isObservableWhen=!0,s.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},s.prototype.val=function(){return this.$observer.$currentValue===this.$target},s.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},s.prototype.isActive=function(){return this.$observer.$currentValue===this.$target},Object.defineProperty(l.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),l.prototype.__$isObservable=!0;const a={},u=function(){};l.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},l.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||a;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const c=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};l.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);c(t,!0)}if(e.has(t)){const n=e.get(t);c(n,!1)}},l.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=u},l.prototype.trigger=u,l.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,i.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,i.emit("ObservableAfterChange",this))},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)A.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=u},l.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},l.prototype.subscribe=function(e,n=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return t.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new r("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),i.emit("ObservableSubscribe",this,n),()=>{this.unsubscribe(e),this.assocTrigger(),i.emit("ObservableUnsubscribe",this)}},l.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!A.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},l.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},l.prototype.check=function(e){return new o(this,e)},l.prototype.get=function(e){const t=this.$currentValue[e];return A.isObservable(t)?t.val():t},l.prototype.when=function(e){return new s(this,e)},l.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"},l.prototype.equals=function(e){return A.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},l.prototype.toBool=function(){return!!this.$currentValue},l.prototype.toggle=function(){this.set(!this.$currentValue)};const p={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(p.mountedSupposedSize>0)for(const e of t.addedNodes){const t=p.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(p.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=p.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{p.mounted.delete(e),p.unmounted.delete(e),p.mountedSupposedSize--,p.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,p.mounted.set(e,n),p.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,p.unmounted.set(e,n),p.unmountedSupposedSize++}}}};p.observer=new MutationObserver(p.checkMutation),p.observer.observe(document.body,{childList:!0,subtree:!0});const d=["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"];function h(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}h.prototype.__$isNDElement=!0,h.prototype.valueOf=function(){return this.$element},h.prototype.ref=function(e,t){return e[t]=this.$element,this},h.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},h.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},h.prototype.lifecycle=function(e){return this.$observer=this.$observer||p.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},h.prototype.mounted=function(e){return this.lifecycle({mounted:e})},h.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},h.prototype.htmlElement=function(){return this.$element},h.prototype.node=h.prototype.htmlElement,h.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},h.prototype.openShadow=function(e=null){return this.shadow("open",e)},h.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},h.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const f={},b=function(e,t,n){if(!e)return;if(!f[t]){const r=new WeakMap;return f[t]=r,void r.set(e,n)}const r=f[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);A.isArray(o)?o.push(n):r.set(e,[store[t],n])},g=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},m=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},v=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},y=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=f[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(A.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of d){const t=e.toLowerCase();h.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},h.prototype["onPrevent"+e]=function(e){return g(this.$element,t,e),this},h.prototype["onStop"+e]=function(e){return m(this.$element,t,e),this},h.prototype["onPreventStop"+e]=function(e){return v(this.$element,t,e),this},h.prototype["when"+e]=function(e){return b(this.$element,t,e),this},h.prototype["capture"+e]=function(e){return y(this.$element,t,e),this}}const $=1,O=3,w=8,C=11,A={isObservable:e=>e?.__$isObservable||e instanceof l||e instanceof o,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,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,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===$||e.nodeType===O||e.nodeType===C||e.nodeType===w),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 h,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&&(A.isObject(e)&&Object.values(e).some(e=>A.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")}},x=["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 S(e){return new l(e)}function E(e,t,n){e.classes.toggle(t,n)}function V(e,t,n){e.style[t]=n}function P(e,t,n){A.isBoolean(n)?e[t]=n:e[t]=n===e.value}function N(e,t,n,r){A.isBoolean(n)?r.set(e[t]):r.set(e.value)}function k(e,t){for(let n in t){const r=t[n];A.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(E.bind(null,e,n))):A.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(E.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function _(e,t){for(let n in t){const r=t[n];A.isObservable(r)?(e.style[n]=r.val(),r.subscribe(V.bind(null,e,n))):e.style[n]=r}}function T(e,t,n){const r=A.isObservable(n)?n.val():n;A.isBoolean(r)?e[t]=r:e[t]=r===e.value,A.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",N.bind(null,e,t,r,n)),n.subscribe(P.bind(null,e,t)))}function j(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}S.useValueProperty=function(e="value"){Object.defineProperty(l.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},S.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},S.cleanup=function(e){e.cleanup()},S.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)};const D=new Map;let M=null;const L={createTextNode:()=>(M||(M=document.createTextNode("")),M.cloneNode()),createObservableNode(e,t){const n=L.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=L.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=L.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(D.has(e))return D.get(e).cloneNode();const t=document.createElement(e);return D.set(e,t),t.cloneNode()}return new B("Fragment")},processChildren(e,t){if(null!==e){if(i.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}i.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(A.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,A.isString(e)))return L.createStaticTextNode(null,e);if(A.isElement(e))return e;if(A.isObservable(e))return L.createObservableNode(null,e);if(A.isNDElement(e))return e.$element??e.$build?.()??null;if(A.$element)return A.$element;if(A.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return A.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?L.createHydratableNode(null,e):L.createStaticTextNode(null,e)},processAttributes(e,t){A.isFragment(e)||t&&function(e,t){if(!A.isObject(t))throw new r("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(A.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,A.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>A.isObservable(e));o=S.computed(()=>o.map(e=>A.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&A.isObject(o)?k(e,o):"style"===r&&A.isObject(o)?_(e,o):x.includes(r)?T(e,r,o):A.isObservable(o)?j(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(i.emit("Setup",e,t,n),e)};function B(e,n=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),i=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(i),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild;const s=e=>n||e.firstChild===o&&e.lastChild===i;return r.appendElement=function(e,t=null){const n=o.parentNode,s=t||i;n!==r?n?.insertBefore(e,s):n.nativeInsertBefore(e,s)},r.appendChild=function(e,n=null){const o=i.parentNode;o?function(e,t,n){const o=A.isElement(t)?t:L.getChild(t);e!==r?s(e)&&n===i?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,n=n??i):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;const l=document.createDocumentFragment();for(;n&&n!==i;)t=n.nextSibling,l.append(n),n=t;l.replaceChildren()},r.remove=function(){if(i.parentNode===r)return;let e,t=o.nextSibling;for(;t&&t!==i;)e=t.nextSibling,r.nativeAppendChild(t),t=e},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),i.remove()},r.replaceContent=function(e){const t=i.parentNode;t&&(s(t)?t.replaceChildren(o,e,i):(r.removeChildren(),t.insertBefore(e,i)))},r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return i},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}Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new h(this)}});const I={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,...I}}});function F(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!A.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=L.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&L.processAttributes(l,o),i&&L.processChildren(i,l),L.setup(l,o,t)}function z(e,t){return F.bind(null,e.toLowerCase(),t)}const W=z("div");z("span"),z("label"),z("p"),z("strong"),z("h1"),z("h2"),z("h3"),z("h4"),z("h5"),z("h6"),z("br"),z("a"),z("pre"),z("code"),z("blockquote"),z("hr"),z("em"),z("small"),z("mark"),z("del"),z("ins"),z("sub"),z("sup"),z("abbr"),z("cite"),z("q"),z("dl"),z("dt"),z("dd"),z("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}),z("input"),z("textarea"),z("select"),z("fieldset"),z("option"),z("legend"),z("datalist"),z("output"),z("progress"),z("meter");const R=z("button");z("main"),z("section"),z("article"),z("aside"),z("nav"),z("figure"),z("figcaption"),z("header"),z("footer"),z("img"),z("details"),z("summary"),z("dialog"),z("menu"),z("ol"),z("ul"),z("li"),z("audio"),z("video"),z("source"),z("track"),z("canvas"),z("svg"),z("time"),z("data"),z("address"),z("kbd"),z("samp"),z("var"),z("wbr"),z("caption"),z("table"),z("thead"),z("tfoot"),z("tbody"),z("tr"),z("th"),z("td"),z(""),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 h(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return S.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return A.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return A.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!A.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return S.getById(n)}):this.valueOf()};const U=function(e,{propagation:t=!1,deep:n=!1}={}){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");l.call(this,e),i.emit("CreateObservableArray",this)};(U.prototype=Object.create(l.prototype)).__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{U.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{U.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),U.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},U.prototype.at=function(e){return this.$currentValue[e]},U.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},U.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},U.prototype.length=function(){return this.$currentValue.length},U.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],i=n[t];return n[e]=i,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,i]}),!0},U.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)},U.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},U.prototype.isEmpty=function(){return 0===this.$currentValue.length},U.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},S.array=function(e){return new U(e)},S.batch=function(e){const t=S(0),n=function(){if(A.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};S.init=function(e,{propagation:t=!1,deep:n=!0}={}){const r={};for(const o in e){const i=e[o];if(Array.isArray(i)){if(n){const e=i.map(e=>A.isJson(e)?S.json(e,{propagation:t,deep:n}):A.isArray(e)?S.array(e,{propagation:t,deep:n}):S(e));r[o]=S.array(e,{propagation:t});continue}r[o]=S.array(i,{propagation:t})}else A.isObservable(i)||A.isProxy(i)?r[o]=i:r[o]=S(i)}const o=()=>function(e){const t={};for(const n in e){const r=e[n];if(A.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>A.isObservable(e)?e.val():A.isProxy(e)?e.$value:e)),t[n]=e}else A.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(r),i=()=>S.init(o(),{propagation:t,deep:n}),s=e=>{S.update(a,e)},l=e=>function(e,t){const n=e[t];return A.isObservable(n)?n.val():A.isProxy(n)?n.$value:n}(r,e),a=new Proxy(r,{get:(t,n)=>"__isProxy__"===n||("$value"===n?o():"$clone"===n?i:"$keys"===n?Object.keys(e):"$observables"===n?Object.values(t):"$set"===n||"$updateWith"===n?s:"$get"===n?l:"$val"===n?o:void 0!==t[n]?t[n]:void 0),set:(e,t,n)=>void 0===e[t]||(A.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return a},S.arrayOfObject=function(e){return e.map(e=>S.object(e))},S.value=function(e){if(A.isObservable(e))return e.val();if(A.isProxy(e))return e.$value;if(A.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(S.value(r))}return t}return e},S.update=function(e,t){const n=A.isProxy(t)?t.$value:t;for(const r in n){const o=e[r],i=t[r],s=n[r];if(A.isObservable(o)){if(A.isArray(s)){const e=i.at(0);if(A.isObservable(e)||A.isProxy(e)){const t=s.map(t=>A.isProxy(e)?S.init(t):S(t));o.set(t);continue}o.set([...s]);continue}o.set(s)}else A.isProxy(o)?S.update(o,s):e[r]=s}},S.object=S.init,S.json=S.init,S.computed=function(e,t=[]){const n=new l(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),A.isFunction(t)){if(!A.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{A.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const H={createdObservable:S(0)},q={name:"DevTools",onCreateObservable(e){H.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function J(){let e=!1;const t=W({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[W({class:"widget-label"},H.createdObservable),R({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=W(W({class:"devtools-app-panel-wrapper pin-to-right"},[J,W({class:"devtools-app-panel"}),W("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:q}}();
@@ -1 +1 @@
1
- var NativeDocument=function(t){"use strict";let n={};n={log(){},warn(){},error(){},disable(){}};var r=n;const o=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 n=0;for(const[e,r]of t)r.deref()||(t.delete(e),n++);n>0&&r.log("Memory Auto Clean",`🧹 Cleaned ${n} orphaned observables`)}}}();class s extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function i(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}i.prototype.__$isObservableChecker=!0,i.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},i.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},i.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},i.prototype.set=function(e){return this.observable.set(e)},i.prototype.trigger=function(){return this.observable.trigger()},i.prototype.cleanup=function(){return this.observable.cleanup()};const a=function(){const e=new Map,t=new Map;return{list:()=>t,add(n,r){if(!n||"object"!=typeof n)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||n.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){n.$name=r,e.set(r,n),"function"==typeof n?.init&&n.init();for(const e in n)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");t.has(r)||t.set(r,new Set),t.get(r).add(n)}}},remove(n){if(!e.has(n))return;const r=e.get(n);"function"==typeof r.cleanup&&r.cleanup();for(const[e,n]of t.entries())n.has(r)&&n.delete(r),0===n.size&&t.delete(e);e.delete(n)},emit(e,...n){if(!t.has(e))return;const o=t.get(e);for(const t of o){const o=t["on"+e];if("function"==typeof o)try{o.call(t,...n)}catch(n){r.error("Plugin Manager",`Error in plugin ${t.$name} for event ${e}`,n)}}}}}(),u=function(e,t){this.$target=t,this.$observer=e};function l(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,a.emit("CreateObservable",this)}u.prototype.__$isObservableWhen=!0,u.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},u.prototype.val=function(){return this.$observer.$currentValue===this.$target},u.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},u.prototype.isActive=function(){return this.$observer.$currentValue===this.$target},Object.defineProperty(l.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),l.prototype.__$isObservable=!0;const c={},h=function(){};l.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},l.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||c;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)};const p=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};l.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);p(t,!0)}if(e.has(t)){const n=e.get(t);p(n,!1)}},l.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=h},l.prototype.trigger=h,l.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,a.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,a.emit("ObservableAfterChange",this))},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)I.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=h},l.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},l.prototype.subscribe=function(e,t=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return r.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new s("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),a.emit("ObservableSubscribe",this,t),()=>{this.unsubscribe(e),this.assocTrigger(),a.emit("ObservableUnsubscribe",this)}},l.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!I.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},l.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},l.prototype.check=function(e){return new i(this,e)},l.prototype.get=function(e){const t=this.$currentValue[e];return I.isObservable(t)?t.val():t},l.prototype.when=function(e){return new u(this,e)},l.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"},l.prototype.equals=function(e){return I.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},l.prototype.toBool=function(){return!!this.$currentValue},l.prototype.toggle=function(){this.set(!this.$currentValue)};const d=(e,t,n)=>{if(I.isFunction(n))return n(e,t);if(I.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return I.isObject(e)?e[n]?.val?.()??e[n]??t:e},f=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},b={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(b.mountedSupposedSize>0)for(const e of t.addedNodes){const t=b.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(b.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=b.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{b.mounted.delete(e),b.unmounted.delete(e),b.mountedSupposedSize--,b.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,b.mounted.set(e,n),b.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,b.unmounted.set(e,n),b.unmountedSupposedSize++}}}};b.observer=new MutationObserver(b.checkMutation),b.observer.observe(document.body,{childList:!0,subtree:!0});const m=["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"];function g(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}g.prototype.__$isNDElement=!0,g.prototype.valueOf=function(){return this.$element},g.prototype.ref=function(e,t){return e[t]=this.$element,this},g.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},g.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},g.prototype.lifecycle=function(e){return this.$observer=this.$observer||b.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},g.prototype.mounted=function(e){return this.lifecycle({mounted:e})},g.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},g.prototype.htmlElement=function(){return this.$element},g.prototype.node=g.prototype.htmlElement,g.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},g.prototype.openShadow=function(e=null){return this.shadow("open",e)},g.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},g.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const y={},v=function(e,t,n){if(!e)return;if(!y[t]){const r=new WeakMap;return y[t]=r,void r.set(e,n)}const r=y[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);I.isArray(o)?o.push(n):r.set(e,[store[t],n])},w=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},$=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},C=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},O=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=y[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(I.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of m){const t=e.toLowerCase();g.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},g.prototype["onPrevent"+e]=function(e){return w(this.$element,t,e),this},g.prototype["onStop"+e]=function(e){return $(this.$element,t,e),this},g.prototype["onPreventStop"+e]=function(e){return C(this.$element,t,e),this},g.prototype["when"+e]=function(e){return v(this.$element,t,e),this},g.prototype["capture"+e]=function(e){return O(this.$element,t,e),this}}const S=1,A=3,E=8,x=11,I={isObservable:e=>e?.__$isObservable||e instanceof l||e instanceof i,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof i,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,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===S||e.nodeType===A||e.nodeType===x||e.nodeType===E),isFragment:e=>e?.nodeType===x,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 g,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 s(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(I.isObject(e)&&Object.values(e).some(e=>I.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new s("Event callback must be a function")}};function k(e,t=!1){const n=document.createDocumentFragment();n.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);n.appendChild(o),n.appendChild(s),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild;const i=e=>t||e.firstChild===o&&e.lastChild===s;return n.appendElement=function(e,t=null){const r=o.parentNode,i=t||s;r!==n?r?.insertBefore(e,i):r.nativeInsertBefore(e,i)},n.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,r){const o=I.isElement(t)?t:W.getChild(t);e!==n?i(e)&&r===s?e.append(o,r):e.insertBefore(o,r):e.nativeInsertBefore(o,r)}(o,e,t=t??s):r.error("Anchor","Anchor : parent not found",e)},n.append=function(...e){return n.appendChild(e)},n.removeChildren=function(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;const a=document.createDocumentFragment();for(;r&&r!==s;)t=r.nextSibling,a.append(r),r=t;a.replaceChildren()},n.remove=function(){if(s.parentNode===n)return;let e,t=o.nextSibling;for(;t&&t!==s;)e=t.nextSibling,n.nativeAppendChild(t),t=e},n.removeWithAnchors=function(){n.removeChildren(),o.remove(),s.remove()},n.replaceContent=function(e){const t=s.parentNode;t&&(i(t)?t.replaceChildren(o,e,s):(n.removeChildren(),t.insertBefore(e,s)))},n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return s},n.startElement=function(){return o},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.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},n}const N=["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 P(e){return new l(e)}function F(e,t,n){e.classes.toggle(t,n)}function T(e,t,n){e.style[t]=n}function V(e,t,n){I.isBoolean(n)?e[t]=n:e[t]=n===e.value}function D(e,t,n,r){I.isBoolean(n)?r.set(e[t]):r.set(e.value)}function R(e,t){for(let n in t){const r=t[n];I.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(F.bind(null,e,n))):I.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(F.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function M(e,t){for(let n in t){const r=t[n];I.isObservable(r)?(e.style[n]=r.val(),r.subscribe(T.bind(null,e,n))):e.style[n]=r}}function L(e,t,n){const r=I.isObservable(n)?n.val():n;I.isBoolean(r)?e[t]=r:e[t]=r===e.value,I.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",D.bind(null,e,t,r,n)),n.subscribe(V.bind(null,e,t)))}function _(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}P.useValueProperty=function(e="value"){Object.defineProperty(l.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},P.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},P.cleanup=function(e){e.cleanup()},P.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{o.cleanup()}),setInterval(()=>o.cleanObservables(r),n)};const B=new Map;let j=null;const W={createTextNode:()=>(j||(j=document.createTextNode("")),j.cloneNode()),createObservableNode(e,t){const n=W.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=W.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=W.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(B.has(e))return B.get(e).cloneNode();const t=document.createElement(e);return B.set(e,t),t.cloneNode()}return new k("Fragment")},processChildren(e,t){if(null!==e){if(a.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}a.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(I.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,I.isString(e)))return W.createStaticTextNode(null,e);if(I.isElement(e))return e;if(I.isObservable(e))return W.createObservableNode(null,e);if(I.isNDElement(e))return e.$element??e.$build?.()??null;if(I.$element)return I.$element;if(I.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return I.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?W.createHydratableNode(null,e):W.createStaticTextNode(null,e)},processAttributes(e,t){I.isFragment(e)||t&&function(e,t){if(I.validateAttributes(t),!I.isObject(t))throw new s("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(I.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,I.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>I.isObservable(e));o=P.computed(()=>o.map(e=>I.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&I.isObject(o)?R(e,o):"style"===r&&I.isObject(o)?M(e,o):N.includes(r)?L(e,r,o):I.isObservable(o)?_(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(a.emit("Setup",e,t,n),e)};Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new g(this)}});const q={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,...q}}});let z=e=>e;t.ArgTypes={},t.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 H=function(e,t=null){if(!I.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},U=function(e){return I.isObservable(e)?W.createObservableNode(null,e):W.createStaticTextNode(null,e)};function K(e,t,n,r=null){let{props:o,children:s=null}=H(n,r),i=W.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&W.processAttributes(a,o),s&&W.processChildren(s,a),W.setup(a,o,t)}function J(e,t){return K.bind(null,e.toLowerCase(),t)}const Q=new WeakMap;function Z(e){let t=null,n=!1;const r=(e,t)=>{const n=Q.get(e);if(3===e.nodeType)return n&&n.value?n.value(t):e.cloneNode(!0);const o=e.cloneNode(e.fullCloneNode);if(n&&(((e,t,n)=>{let r=null;if(t.attributes){r=r||{};for(const e in t.attributes)r[e]=t.attributes[e](...n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e](...n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e](...n)}r&&W.processAttributes(e,r)})(o,n,t),function(e,t,n){if(!t.attach)return null;t.attach(e,...n)}(o,n,t)),e.fullCloneNode)return o;const s=e.childNodes;for(let e=0,n=s.length;e<n;e++){const n=s[e],i=r(n,t);o.appendChild(i)}return o};this.clone=o=>{if(!t&&(t=e(this),!n)){const e=t.cloneNode(!0);return e.fullCloneNode=!0,e}return n?r(t,o):t.cloneNode(!0)};const o=(e,t)=>({$hydrate:(r,o)=>{n=!0,function(e,t,n,r){Q.has(n)||Q.set(n,{});const o=Q.get(n);"value"!==t?"attach"!==t?(o[t]=o[t]||{},o[t][r]=e):o.attach=e:o.value=e}(e,t,r,o)}});this.style=e=>o(e,"styles"),this.class=e=>o(e,"classes"),this.property=e=>this.value(e),this.value=e=>o("function"!=typeof e?function(t){const n=t[0];return U(n[e])}:function(t){return U(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}function G(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=new k("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}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 g(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return P.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return I.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return I.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!I.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return P.getById(n)}):this.valueOf()};const X=e=>{let t=null;return new Proxy({},{get:(n,r)=>(null===t&&(t=e()),t[r])})},Y=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{if(!t.has(r)){if(e.length>0)return(...n)=>{const o=e(...n);return t.set(r,o),o};t.set(r,e())}return t.get(r)}})},ee={once:e=>X(e),memoize:e=>Y(e)},te=function(e,{propagation:t=!1,deep:n=!1}={}){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");l.apply(this,[e]),a.emit("CreateObservableArray",this)};te.prototype.__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{te.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{te.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),te.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},te.prototype.at=function(e){return this.$currentValue[e]},te.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},te.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},te.prototype.length=function(){return this.$currentValue.length},te.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},te.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},te.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},te.prototype.isEmpty=function(){return 0===this.$currentValue.length},te.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},P.array=function(e){return new te(e)},P.batch=function(e){const t=P(0),n=function(){if(I.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};P.init=function(e,{propagation:t=!1,deep:n=!0}={}){const r={};for(const o in e){const s=e[o];if(Array.isArray(s)){if(n){const e=s.map(e=>I.isJson(e)?P.json(e,{propagation:t,deep:n}):I.isArray(e)?P.array(e,{propagation:t,deep:n}):P(e));r[o]=P.array(e,{propagation:t});continue}r[o]=P.array(s,{propagation:t})}else I.isObservable(s)||I.isProxy(s)?r[o]=s:r[o]=P(s)}const o=()=>function(e){const t={};for(const n in e){const r=e[n];if(I.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>I.isObservable(e)?e.val():I.isProxy(e)?e.$value:e)),t[n]=e}else I.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(r),s=()=>P.init(o(),{propagation:t,deep:n}),i=e=>{P.update(u,e)},a=e=>function(e,t){const n=e[t];return I.isObservable(n)?n.val():I.isProxy(n)?n.$value:n}(r,e),u=new Proxy(r,{get:(t,n)=>"__isProxy__"===n||("$value"===n?o():"$clone"===n?s:"$keys"===n?Object.keys(e):"$observables"===n?Object.values(t):"$set"===n||"$updateWith"===n?i:"$get"===n?a:"$val"===n?o:void 0!==t[n]?t[n]:void 0),set:(e,t,n)=>void 0===e[t]||(I.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return u},P.arrayOfObject=function(e){return e.map(e=>P.object(e))},P.value=function(e){if(I.isObservable(e))return e.val();if(I.isProxy(e))return e.$value;if(I.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(P.value(r))}return t}return e},P.update=function(e,t){const n=I.isProxy(t)?t.$value:t;for(const r in n){const o=e[r],s=t[r],i=n[r];if(I.isObservable(o)){if(I.isArray(i)){const e=s.at(0);if(I.isObservable(e)||I.isProxy(e)){const t=i.map(t=>I.isProxy(e)?P.init(t):P(t));o.set(t);continue}o.set([...i]);continue}o.set(i)}else I.isProxy(o)?P.update(o,i):e[r]=i}},P.object=P.init,P.json=P.init,P.computed=function(e,t=[]){const n=new l(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),I.isFunction(t)){if(!I.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{I.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const ne=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=P(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=P(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 re=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!I.isObservable(e)&&!I.isObservableWhenResult(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=new k("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=W.getChild(t),I.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},oe=function(e,t,n=!0){if(!I.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=new k("Match"),o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=W.getChild(r),I.isFragment(r)&&(r=Array.from(r.children)),n&&o.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},se=function(e,t,n){if(!I.isObservable(e))throw new s("Toggle : condition must be an Observable");return oe(e,{true:t,false:n})},ie=J("div"),ae=J("span"),ue=J("label"),le=J("p"),ce=le,he=J("strong"),pe=J("h1"),de=J("h2"),fe=J("h3"),be=J("h4"),me=J("h5"),ge=J("h6"),ye=J("br"),ve=J("a"),we=J("pre"),$e=J("code"),Ce=J("blockquote"),Oe=J("hr"),Se=J("em"),Ae=J("small"),Ee=J("mark"),xe=J("del"),Ie=J("ins"),ke=J("sub"),Ne=J("sup"),Pe=J("abbr"),Fe=J("cite"),Te=J("q"),Ve=J("dl"),De=J("dt"),Re=J("dd"),Me=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}),Le=J("input"),_e=J("textarea"),Be=_e,je=J("select"),We=J("fieldset"),qe=J("option"),ze=J("legend"),He=J("datalist"),Ue=J("output"),Ke=J("progress"),Je=J("meter"),Qe=J("button"),Ze=J("main"),Ge=J("section"),Xe=J("article"),Ye=J("aside"),et=J("nav"),tt=J("figure"),nt=J("figcaption"),rt=J("header"),ot=J("footer"),st=J("img"),it=function(e,t){return st({src:e,...t})},at=J("details"),ut=J("summary"),lt=J("dialog"),ct=J("menu"),ht=J("ol"),pt=J("ul"),dt=J("li"),ft=dt,bt=ht,mt=pt,gt=J("audio"),yt=J("video"),vt=J("source"),wt=J("track"),$t=J("canvas"),Ct=J("svg"),Ot=J("time"),St=J("data"),At=J("address"),Et=J("kbd"),xt=J("samp"),It=J("var"),kt=J("wbr"),Nt=J("caption"),Pt=J("table"),Ft=J("thead"),Tt=J("tfoot"),Vt=J("tbody"),Dt=J("tr"),Rt=Dt,Mt=J("th"),Lt=Mt,_t=Mt,Bt=J("td"),jt=Bt,Wt=J("");var qt=Object.freeze({__proto__:null,Abbr:Pe,Address:At,Anchor:k,Article:Xe,Aside:Ye,AsyncImg:function(e,t,n,r){const o=I.isObservable(e)?e.val():e,i=it(t||o,n),a=new Image;return a.onload=()=>{I.isFunction(r)&&r(null,i),i.src=I.isObservable(e)?e.val():e},a.onerror=()=>{I.isFunction(r)&&r(new s("Image not found"))},I.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=o,i},Audio:gt,BaseImage:st,Blockquote:Ce,Br:ye,Button:Qe,Canvas:$t,Caption:Nt,Checkbox:e=>Le({type:"checkbox",...e}),Cite:Fe,Code:$e,ColorInput:e=>Le({type:"color",...e}),Data:St,Datalist:He,DateInput:e=>Le({type:"date",...e}),DateTimeInput:e=>Le({type:"datetime-local",...e}),Dd:Re,Del:xe,Details:at,Dialog:lt,Div:ie,Dl:Ve,Dt:De,Em:Se,EmailInput:e=>Le({type:"email",...e}),FieldSet:We,FigCaption:nt,Figure:tt,FileInput:e=>Le({type:"file",...e}),Footer:ot,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=new k("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=e=>{if(!o)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&e.removeChild(r),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},p=(e,o)=>{const i=d(e,o,n);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(o),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?P(o):null;let r=W.getChild(t(e,n));if(!r||I.isFragment(r))throw new s("ForEachArray child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(r),indexObserver:n})}catch(e){throw r.error("ForEach",`Error creating element for key ${i}`,e),e}return i},f=()=>{const t=a.parentNode;if(!t)return;const n=I.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 f(),I.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=new k("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,l=0;const c=t.length>=2,h=new WeakMap,p=()=>{o.removeChildren(),g(),l=0},f=(e,t)=>h.has(e)?h.get(e):d(e,t,n),b=e=>v(f(e)),m=(e,t=!0)=>{if(e){if(t){const t=e.child;t?.remove(),u.delete(e.keyId)}e.indexObserver?.deref()?.cleanup()}},g=()=>{if(!r.shouldKeepItemsInCache)if(c){for(const[e,t]of u.entries())m(t,!1);u.clear()}else u.clear()},y=(e,n)=>{const r=f(e,n);if(u.has(r)){const e=u.get(r);e.indexObserver?.deref()?.set(n);const t=e.child;if(t)return t;u.delete(r)}const o=c?P(n):null;let i=W.getChild(t(e,o));if(!i||I.isFragment(i))throw new s("ForEachArray child can't be null or undefined!");return u.set(r,{keyId:r,child:i,indexObserver:o?new WeakRef(o):null}),h.set(e,r),i},v=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(m(t,!1),null)},w=function(e,t){const n=u.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},$={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(y(e[t],l)),l++;return n},add(e,t=2){const n=$.toFragment(e);setTimeout(()=>{o.appendElement(n)},t)},replace(e){p(),$.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=b(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{m(u.get(e),t)})(f(e,t),!0)},clear:p,merge(e){$.add(e)},push(e){let t=0;r.pushDelay&&(t=r.pushDelay(e)??0),$.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(y(t,o)),l++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore($.toFragment(e),a.nextSibling)},splice(e,t){const[n,r,...s]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=f(t[0],n);if(1===t.length)w(e,u);else if(t.length>1){const r=v(e);a=r?.previousSibling;for(let e=0;e<t.length;e++){const r=f(t[e],n+e);w(r,u)}}}else a=i;u.replaceChildren(),s&&s.length&&a&&o.insertBefore($.toFragment(s),a.nextSibling)},reverse(e,t){$.reOrder(t)},sort(e,t){$.reOrder(t)},remove(e,t){$.removeOne(t)},pop(e,t){$.removeOne(t)},shift(e,t){$.removeOne(t)},swap(e,t){const n=i.parentNode;let r=b(t[0]),o=b(t[1]);if(!r||!o)return;const s=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,s),r=null,o=null}},C=(e,t,n)=>{if("clear"!==n.action&&e.length){if(n?.action)$[n.action]&&$[n.action](n.args,n.result);else{if(0===l)return void $.add(e);$.replace(e)}((e,t=0)=>{if(!c)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=u.get(f(e[r],r));t&&(t.indexObserver?.deref()?.set(n),n++)}})(e,0)}else{if(0===l)return;p()}};return e.val().length&&C(e.val(),0,{action:null}),I.isObservable(e)&&e.subscribe(C),o},Form:Me,Fragment:Wt,H1:pe,H2:de,H3:fe,H4:be,H5:me,H6:ge,Header:rt,HiddenInput:e=>Le({type:"hidden",...e}),HideIf:function(e,t,n){const r=P(!e.val());return e.subscribe(e=>r.set(!e)),re(r,t,n)},HideIfNot:function(e,t,n){return re(e,t,n)},Hr:Oe,Img:it,Input:Le,Ins:Ie,Kbd:Et,Label:ue,LazyImg:function(e,t){return it(e,{...t,loading:"lazy"})},Legend:ze,Li:ft,Link:ve,ListItem:dt,Main:Ze,Mark:Ee,Match:oe,Menu:ct,Meter:Je,MonthInput:e=>Le({type:"month",...e}),NativeDocumentFragment:k,Nav:et,NumberInput:e=>Le({type:"number",...e}),Ol:bt,Option:qe,OrderedList:ht,Output:Ue,P:le,Paragraph:ce,PasswordInput:e=>Le({type:"password",...e}),Pre:we,Progress:Ke,Quote:Te,Radio:e=>Le({type:"radio",...e}),RangeInput:e=>Le({type:"range",...e}),ReadonlyInput:e=>Le({readonly:!0,...e}),Samp:xt,SearchInput:e=>Le({type:"search",...e}),Section:Ge,Select:je,ShowIf:re,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!I.isObservableWhenResult(e))throw new s("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return re(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!I.isObservable(e))throw new s("showWhen observer must be an Observable",{data:e});return re(e.when(t),n)}throw new s("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Qe(e,{type:"button",...t}),Small:Ae,Source:vt,Span:ae,Strong:he,Sub:ke,SubmitButton:(e,t)=>Qe(e,{type:"submit",...t}),Summary:ut,Sup:Ne,Svg:Ct,Switch:se,TBody:Vt,TBodyCell:jt,TFoot:Tt,TFootCell:_t,THead:Ft,THeadCell:Lt,TRow:Rt,Table:Pt,Td:Bt,TelInput:e=>Le({type:"tel",...e}),TextArea:_e,TextInput:Be,Th:Mt,Time:Ot,TimeInput:e=>Le({type:"time",...e}),Tr:Dt,Track:wt,Ul:mt,UnorderedList:pt,UrlInput:e=>Le({type:"url",...e}),Var:It,Video:yt,Wbr:kt,WeekInput:e=>Le({type:"week",...e}),When:function(e){if(!I.isObservable(e))throw new s("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))}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=k("Portal "+n);return r.appendChild(W.getChild(e)),(t||document.body).appendChild(r),r}});const zt={};function Ht(e,t,n={}){e="/"+f(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=zt[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="/"+f(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 Ut extends Error{constructor(e,t){super(e),this.context=t}}const Kt=(e,t)=>{const n=[];return e.forEach(e=>{n.push(f(e.suffix,"/"))}),n.push(f(t,"/")),n.join("/")},Jt=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Qt=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Zt=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Gt(){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 Xt(){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){r.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:n,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:n},t.name()||n,n),this.handleRouteChange(t,o,{},n)}catch(e){r.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){r.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:n,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,n,o,s)}}function Yt(){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)}}const en="default";function tn(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Gt.apply(this,[]);else if("history"===e.mode)Xt.apply(this,[]);else{if("memory"!==e.mode)throw new Ut("Invalid router mode "+e.mode);Yt.apply(this,[])}const a=function(e,t){for(const n of s)try{n(e),t&&t(e)}catch(e){r.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,r,s){const i=new Ht(Kt(o,e),r,{...s,middlewares:Jt(o,s?.middlewares||[]),name:s?.name?Qt(o,s.name):null,layout:s?.layout||Zt(o)});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!I.isFunction(n))throw new Ut("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},r={}){const o=n[e];if(!o)throw new Ut(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(I.isJson(e)){const t=n[e.name];if(!t)throw new Ut(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[r,o]=e.split("?"),s="/"+f(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Ut(`Route not found for url: ${r}`);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(!I.isFunction(e))throw new Ut("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 nn(e,t){const{to:n,href:r,...o}=e,s=n||r;if(I.isString(s)){const e=tn.get();return ve({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||en,a=tn.get(i);if(!a)throw new Ut('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return ve({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}tn.routers={},tn.create=function(t,n){if(!I.isFunction(n))throw r.error("Router","Callback must be a function",e),new Ut("Callback must be a function");const o=new tn(t);return tn.routers[t.name||en]=o,n(o),o.init(t.entry),o.mount=function(e){if(I.isString(e)){const t=document.querySelector(e);if(!t)throw new Ut(`Container not found for selector: ${e}`);e=t}else if(!I.isElement(e))throw new Ut("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e,n){t.innerHTML="";const r=n.layout();r?t.appendChild(r(e)):t.appendChild(e)},o=function(e){if(!e.route)return;const{route:t,params:o,query:s,path:i}=e;if(n.has(i)){const e=n.get(i);return void r(e,t)}const a=t.component()({params:o,query:s});n.set(i,a),r(a,t)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},tn.get=function(e){const t=tn.routers[e||en];if(!t)throw new Ut(`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()},nn.blank=function(e,t){return ve({...e,target:"_blank"},t)};var rn=Object.freeze({__proto__:null,Link:nn,RouteParamPatterns:zt,Router:tn});return t.ElementCreator=W,t.HtmlElementWrapper=J,t.NDElement=g,t.Observable=P,t.PluginsManager=a,t.Service=ee,t.SingletonView=G,t.Store=ne,t.TemplateCloner=Z,t.Validator=I,t.autoMemoize=Y,t.autoOnce=X,t.classPropertyAccumulator=function(e=[]){let t=I.isString(e)?e.split(" ").filter(Boolean):e;const n=I.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=U,t.cssPropertyAccumulator=function(e={}){let t=I.isString(e)?e.split(";").filter(Boolean):e;const n=I.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=qt,t.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n;return t.has(r)||t.set(r,e(...o)),t.get(r)}},t.normalizeComponentArgs=H,t.once=e=>{let t=null;return(...n)=>(null===t&&(t=e(...n)),t)},t.router=rn,t.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])}},t.useSingleton=function(e){let t=null;return function(...n){return t||(t=new G(e)),t.render(n)}},t.withValidation=z,t}({});
1
+ var NativeDocument=function(t){"use strict";let n={};n={log(){},warn(){},error(){},disable(){}};var r=n;const o=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 n=0;for(const[e,r]of t)r.deref()||(t.delete(e),n++);n>0&&r.log("Memory Auto Clean",`🧹 Cleaned ${n} orphaned observables`)}}}();class s extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function i(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}i.prototype.__$isObservableChecker=!0,i.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},i.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},i.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},i.prototype.set=function(e){return this.observable.set(e)},i.prototype.trigger=function(){return this.observable.trigger()},i.prototype.cleanup=function(){return this.observable.cleanup()};const a=function(){const e=new Map,t=new Map;return{list:()=>t,add(n,r){if(!n||"object"!=typeof n)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||n.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){n.$name=r,e.set(r,n),"function"==typeof n?.init&&n.init();for(const e in n)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");t.has(r)||t.set(r,new Set),t.get(r).add(n)}}},remove(n){if(!e.has(n))return;const r=e.get(n);"function"==typeof r.cleanup&&r.cleanup();for(const[e,n]of t.entries())n.has(r)&&n.delete(r),0===n.size&&t.delete(e);e.delete(n)},emit(e,...n){if(!t.has(e))return;const o=t.get(e);for(const t of o){const o=t["on"+e];if("function"==typeof o)try{o.call(t,...n)}catch(n){r.error("Plugin Manager",`Error in plugin ${t.$name} for event ${e}`,n)}}}}}(),u=function(e,t){this.$target=t,this.$observer=e};function l(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,a.emit("CreateObservable",this)}u.prototype.__$isObservableWhen=!0,u.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},u.prototype.val=function(){return this.$observer.$currentValue===this.$target},u.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},u.prototype.isActive=function(){return this.$observer.$currentValue===this.$target},Object.defineProperty(l.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),l.prototype.__$isObservable=!0;const c={},h=function(){};l.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},l.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||c;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)};const p=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};l.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);p(t,!0)}if(e.has(t)){const n=e.get(t);p(n,!1)}},l.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},l.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=h},l.prototype.trigger=h,l.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,a.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,a.emit("ObservableAfterChange",this))},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)I.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=h},l.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},l.prototype.subscribe=function(e,t=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return r.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new s("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),a.emit("ObservableSubscribe",this,t),()=>{this.unsubscribe(e),this.assocTrigger(),a.emit("ObservableUnsubscribe",this)}},l.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!I.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},l.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},l.prototype.check=function(e){return new i(this,e)},l.prototype.get=function(e){const t=this.$currentValue[e];return I.isObservable(t)?t.val():t},l.prototype.when=function(e){return new u(this,e)},l.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"},l.prototype.equals=function(e){return I.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},l.prototype.toBool=function(){return!!this.$currentValue},l.prototype.toggle=function(){this.set(!this.$currentValue)};const d=(e,t,n)=>{if(I.isFunction(n))return n(e,t);if(I.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return I.isObject(e)?e[n]?.val?.()??e[n]??t:e},f=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},b={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(b.mountedSupposedSize>0)for(const e of t.addedNodes){const t=b.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(b.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=b.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{b.mounted.delete(e),b.unmounted.delete(e),b.mountedSupposedSize--,b.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,b.mounted.set(e,n),b.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,b.unmounted.set(e,n),b.unmountedSupposedSize++}}}};b.observer=new MutationObserver(b.checkMutation),b.observer.observe(document.body,{childList:!0,subtree:!0});const m=["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"];function g(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}g.prototype.__$isNDElement=!0,g.prototype.valueOf=function(){return this.$element},g.prototype.ref=function(e,t){return e[t]=this.$element,this},g.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},g.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},g.prototype.lifecycle=function(e){return this.$observer=this.$observer||b.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},g.prototype.mounted=function(e){return this.lifecycle({mounted:e})},g.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},g.prototype.htmlElement=function(){return this.$element},g.prototype.node=g.prototype.htmlElement,g.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},g.prototype.openShadow=function(e=null){return this.shadow("open",e)},g.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},g.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const y={},v=function(e,t,n){if(!e)return;if(!y[t]){const r=new WeakMap;return y[t]=r,void r.set(e,n)}const r=y[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);I.isArray(o)?o.push(n):r.set(e,[store[t],n])},w=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},$=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},C=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},O=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=y[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(I.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of m){const t=e.toLowerCase();g.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},g.prototype["onPrevent"+e]=function(e){return w(this.$element,t,e),this},g.prototype["onStop"+e]=function(e){return $(this.$element,t,e),this},g.prototype["onPreventStop"+e]=function(e){return C(this.$element,t,e),this},g.prototype["when"+e]=function(e){return v(this.$element,t,e),this},g.prototype["capture"+e]=function(e){return O(this.$element,t,e),this}}const S=1,A=3,E=8,x=11,I={isObservable:e=>e?.__$isObservable||e instanceof l||e instanceof i,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof i,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,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===S||e.nodeType===A||e.nodeType===x||e.nodeType===E),isFragment:e=>e?.nodeType===x,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 g,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 s(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(I.isObject(e)&&Object.values(e).some(e=>I.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new s("Event callback must be a function")}};function k(e,t=!1){const n=document.createDocumentFragment();n.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);n.appendChild(o),n.appendChild(s),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild;const i=e=>t||e.firstChild===o&&e.lastChild===s;return n.appendElement=function(e,t=null){const r=o.parentNode,i=t||s;r!==n?r?.insertBefore(e,i):r.nativeInsertBefore(e,i)},n.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,r){const o=I.isElement(t)?t:W.getChild(t);e!==n?i(e)&&r===s?e.append(o,r):e.insertBefore(o,r):e.nativeInsertBefore(o,r)}(o,e,t=t??s):r.error("Anchor","Anchor : parent not found",e)},n.append=function(...e){return n.appendChild(e)},n.removeChildren=function(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;const a=document.createDocumentFragment();for(;r&&r!==s;)t=r.nextSibling,a.append(r),r=t;a.replaceChildren()},n.remove=function(){if(s.parentNode===n)return;let e,t=o.nextSibling;for(;t&&t!==s;)e=t.nextSibling,n.nativeAppendChild(t),t=e},n.removeWithAnchors=function(){n.removeChildren(),o.remove(),s.remove()},n.replaceContent=function(e){const t=s.parentNode;t&&(i(t)?t.replaceChildren(o,e,s):(n.removeChildren(),t.insertBefore(e,s)))},n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return s},n.startElement=function(){return o},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.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},n}const N=["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 P(e){return new l(e)}function F(e,t,n){e.classes.toggle(t,n)}function T(e,t,n){e.style[t]=n}function V(e,t,n){I.isBoolean(n)?e[t]=n:e[t]=n===e.value}function D(e,t,n,r){I.isBoolean(n)?r.set(e[t]):r.set(e.value)}function R(e,t){for(let n in t){const r=t[n];I.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(F.bind(null,e,n))):I.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(F.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function M(e,t){for(let n in t){const r=t[n];I.isObservable(r)?(e.style[n]=r.val(),r.subscribe(T.bind(null,e,n))):e.style[n]=r}}function L(e,t,n){const r=I.isObservable(n)?n.val():n;I.isBoolean(r)?e[t]=r:e[t]=r===e.value,I.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",D.bind(null,e,t,r,n)),n.subscribe(V.bind(null,e,t)))}function _(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}P.useValueProperty=function(e="value"){Object.defineProperty(l.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},P.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},P.cleanup=function(e){e.cleanup()},P.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{o.cleanup()}),setInterval(()=>o.cleanObservables(r),n)};const B=new Map;let j=null;const W={createTextNode:()=>(j||(j=document.createTextNode("")),j.cloneNode()),createObservableNode(e,t){const n=W.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=W.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=W.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(B.has(e))return B.get(e).cloneNode();const t=document.createElement(e);return B.set(e,t),t.cloneNode()}return new k("Fragment")},processChildren(e,t){if(null!==e){if(a.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}a.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(I.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,I.isString(e)))return W.createStaticTextNode(null,e);if(I.isElement(e))return e;if(I.isObservable(e))return W.createObservableNode(null,e);if(I.isNDElement(e))return e.$element??e.$build?.()??null;if(I.$element)return I.$element;if(I.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return I.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?W.createHydratableNode(null,e):W.createStaticTextNode(null,e)},processAttributes(e,t){I.isFragment(e)||t&&function(e,t){if(I.validateAttributes(t),!I.isObject(t))throw new s("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(I.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,I.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>I.isObservable(e));o=P.computed(()=>o.map(e=>I.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&I.isObject(o)?R(e,o):"style"===r&&I.isObject(o)?M(e,o):N.includes(r)?L(e,r,o):I.isObservable(o)?_(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(a.emit("Setup",e,t,n),e)};Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new g(this)}});const q={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,...q}}});let z=e=>e;t.ArgTypes={},t.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 H=function(e,t=null){if(!I.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},U=function(e){return I.isObservable(e)?W.createObservableNode(null,e):W.createStaticTextNode(null,e)};function K(e,t,n,r=null){let{props:o,children:s=null}=H(n,r),i=W.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&W.processAttributes(a,o),s&&W.processChildren(s,a),W.setup(a,o,t)}function J(e,t){return K.bind(null,e.toLowerCase(),t)}const Q=new WeakMap;function Z(e){let t=null,n=!1;const r=(e,t)=>{const n=Q.get(e);if(3===e.nodeType)return n&&n.value?n.value(t):e.cloneNode(!0);const o=e.cloneNode(e.fullCloneNode);if(n&&(((e,t,n)=>{let r=null;if(t.attributes){r=r||{};for(const e in t.attributes)r[e]=t.attributes[e](...n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e](...n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e](...n)}r&&W.processAttributes(e,r)})(o,n,t),function(e,t,n){if(!t.attach)return null;t.attach(e,...n)}(o,n,t)),e.fullCloneNode)return o;const s=e.childNodes;for(let e=0,n=s.length;e<n;e++){const n=s[e],i=r(n,t);o.appendChild(i)}return o};this.clone=o=>{if(!t&&(t=e(this),!n)){const e=t.cloneNode(!0);return e.fullCloneNode=!0,e}return n?r(t,o):t.cloneNode(!0)};const o=(e,t)=>({$hydrate:(r,o)=>{n=!0,function(e,t,n,r){Q.has(n)||Q.set(n,{});const o=Q.get(n);"value"!==t?"attach"!==t?(o[t]=o[t]||{},o[t][r]=e):o.attach=e:o.value=e}(e,t,r,o)}});this.style=e=>o(e,"styles"),this.class=e=>o(e,"classes"),this.property=e=>this.value(e),this.value=e=>o("function"!=typeof e?function(t){const n=t[0];return U(n[e])}:function(t){return U(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}function G(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=new k("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}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 g(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return P.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return I.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return I.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!I.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return P.getById(n)}):this.valueOf()};const X=e=>{let t=null;return new Proxy({},{get:(n,r)=>(null===t&&(t=e()),t[r])})},Y=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{if(!t.has(r)){if(e.length>0)return(...n)=>{const o=e(...n);return t.set(r,o),o};t.set(r,e())}return t.get(r)}})},ee={once:e=>X(e),memoize:e=>Y(e)},te=function(e,{propagation:t=!1,deep:n=!1}={}){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");l.call(this,e),a.emit("CreateObservableArray",this)};(te.prototype=Object.create(l.prototype)).__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{te.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{te.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),te.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},te.prototype.at=function(e){return this.$currentValue[e]},te.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},te.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},te.prototype.length=function(){return this.$currentValue.length},te.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},te.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},te.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},te.prototype.isEmpty=function(){return 0===this.$currentValue.length},te.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},P.array=function(e){return new te(e)},P.batch=function(e){const t=P(0),n=function(){if(I.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};P.init=function(e,{propagation:t=!1,deep:n=!0}={}){const r={};for(const o in e){const s=e[o];if(Array.isArray(s)){if(n){const e=s.map(e=>I.isJson(e)?P.json(e,{propagation:t,deep:n}):I.isArray(e)?P.array(e,{propagation:t,deep:n}):P(e));r[o]=P.array(e,{propagation:t});continue}r[o]=P.array(s,{propagation:t})}else I.isObservable(s)||I.isProxy(s)?r[o]=s:r[o]=P(s)}const o=()=>function(e){const t={};for(const n in e){const r=e[n];if(I.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>I.isObservable(e)?e.val():I.isProxy(e)?e.$value:e)),t[n]=e}else I.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(r),s=()=>P.init(o(),{propagation:t,deep:n}),i=e=>{P.update(u,e)},a=e=>function(e,t){const n=e[t];return I.isObservable(n)?n.val():I.isProxy(n)?n.$value:n}(r,e),u=new Proxy(r,{get:(t,n)=>"__isProxy__"===n||("$value"===n?o():"$clone"===n?s:"$keys"===n?Object.keys(e):"$observables"===n?Object.values(t):"$set"===n||"$updateWith"===n?i:"$get"===n?a:"$val"===n?o:void 0!==t[n]?t[n]:void 0),set:(e,t,n)=>void 0===e[t]||(I.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return u},P.arrayOfObject=function(e){return e.map(e=>P.object(e))},P.value=function(e){if(I.isObservable(e))return e.val();if(I.isProxy(e))return e.$value;if(I.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(P.value(r))}return t}return e},P.update=function(e,t){const n=I.isProxy(t)?t.$value:t;for(const r in n){const o=e[r],s=t[r],i=n[r];if(I.isObservable(o)){if(I.isArray(i)){const e=s.at(0);if(I.isObservable(e)||I.isProxy(e)){const t=i.map(t=>I.isProxy(e)?P.init(t):P(t));o.set(t);continue}o.set([...i]);continue}o.set(i)}else I.isProxy(o)?P.update(o,i):e[r]=i}},P.object=P.init,P.json=P.init,P.computed=function(e,t=[]){const n=new l(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),I.isFunction(t)){if(!I.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{I.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const ne=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=P(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=P(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 re=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!I.isObservable(e)&&!I.isObservableWhenResult(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=new k("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=W.getChild(t),I.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},oe=function(e,t,n=!0){if(!I.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=new k("Match"),o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=W.getChild(r),I.isFragment(r)&&(r=Array.from(r.children)),n&&o.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},se=function(e,t,n){if(!I.isObservable(e))throw new s("Toggle : condition must be an Observable");return oe(e,{true:t,false:n})},ie=J("div"),ae=J("span"),ue=J("label"),le=J("p"),ce=le,he=J("strong"),pe=J("h1"),de=J("h2"),fe=J("h3"),be=J("h4"),me=J("h5"),ge=J("h6"),ye=J("br"),ve=J("a"),we=J("pre"),$e=J("code"),Ce=J("blockquote"),Oe=J("hr"),Se=J("em"),Ae=J("small"),Ee=J("mark"),xe=J("del"),Ie=J("ins"),ke=J("sub"),Ne=J("sup"),Pe=J("abbr"),Fe=J("cite"),Te=J("q"),Ve=J("dl"),De=J("dt"),Re=J("dd"),Me=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}),Le=J("input"),_e=J("textarea"),Be=_e,je=J("select"),We=J("fieldset"),qe=J("option"),ze=J("legend"),He=J("datalist"),Ue=J("output"),Ke=J("progress"),Je=J("meter"),Qe=J("button"),Ze=J("main"),Ge=J("section"),Xe=J("article"),Ye=J("aside"),et=J("nav"),tt=J("figure"),nt=J("figcaption"),rt=J("header"),ot=J("footer"),st=J("img"),it=function(e,t){return st({src:e,...t})},at=J("details"),ut=J("summary"),lt=J("dialog"),ct=J("menu"),ht=J("ol"),pt=J("ul"),dt=J("li"),ft=dt,bt=ht,mt=pt,gt=J("audio"),yt=J("video"),vt=J("source"),wt=J("track"),$t=J("canvas"),Ct=J("svg"),Ot=J("time"),St=J("data"),At=J("address"),Et=J("kbd"),xt=J("samp"),It=J("var"),kt=J("wbr"),Nt=J("caption"),Pt=J("table"),Ft=J("thead"),Tt=J("tfoot"),Vt=J("tbody"),Dt=J("tr"),Rt=Dt,Mt=J("th"),Lt=Mt,_t=Mt,Bt=J("td"),jt=Bt,Wt=J("");var qt=Object.freeze({__proto__:null,Abbr:Pe,Address:At,Anchor:k,Article:Xe,Aside:Ye,AsyncImg:function(e,t,n,r){const o=I.isObservable(e)?e.val():e,i=it(t||o,n),a=new Image;return a.onload=()=>{I.isFunction(r)&&r(null,i),i.src=I.isObservable(e)?e.val():e},a.onerror=()=>{I.isFunction(r)&&r(new s("Image not found"))},I.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=o,i},Audio:gt,BaseImage:st,Blockquote:Ce,Br:ye,Button:Qe,Canvas:$t,Caption:Nt,Checkbox:e=>Le({type:"checkbox",...e}),Cite:Fe,Code:$e,ColorInput:e=>Le({type:"color",...e}),Data:St,Datalist:He,DateInput:e=>Le({type:"date",...e}),DateTimeInput:e=>Le({type:"datetime-local",...e}),Dd:Re,Del:xe,Details:at,Dialog:lt,Div:ie,Dl:Ve,Dt:De,Em:Se,EmailInput:e=>Le({type:"email",...e}),FieldSet:We,FigCaption:nt,Figure:tt,FileInput:e=>Le({type:"file",...e}),Footer:ot,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=new k("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=e=>{if(!o)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&e.removeChild(r),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},p=(e,o)=>{const i=d(e,o,n);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(o),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?P(o):null;let r=W.getChild(t(e,n));if(!r||I.isFragment(r))throw new s("ForEachArray child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(r),indexObserver:n})}catch(e){throw r.error("ForEach",`Error creating element for key ${i}`,e),e}return i},f=()=>{const t=a.parentNode;if(!t)return;const n=I.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 f(),I.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=new k("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,l=0;const c=t.length>=2,h=new WeakMap,p=()=>{o.removeChildren(),g(),l=0},f=(e,t)=>h.has(e)?h.get(e):d(e,t,n),b=e=>v(f(e)),m=(e,t=!0)=>{if(e){if(t){const t=e.child;t?.remove(),u.delete(e.keyId)}e.indexObserver?.deref()?.cleanup()}},g=()=>{if(!r.shouldKeepItemsInCache)if(c){for(const[e,t]of u.entries())m(t,!1);u.clear()}else u.clear()},y=(e,n)=>{const r=f(e,n);if(u.has(r)){const e=u.get(r);e.indexObserver?.deref()?.set(n);const t=e.child;if(t)return t;u.delete(r)}const o=c?P(n):null;let i=W.getChild(t(e,o));if(!i||I.isFragment(i))throw new s("ForEachArray child can't be null or undefined!");return u.set(r,{keyId:r,child:i,indexObserver:o?new WeakRef(o):null}),h.set(e,r),i},v=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(m(t,!1),null)},w=function(e,t){const n=u.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},$={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(y(e[t],l)),l++;return n},add(e,t=2){const n=$.toFragment(e);setTimeout(()=>{o.appendElement(n)},t)},replace(e){p(),$.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=b(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{m(u.get(e),t)})(f(e,t),!0)},clear:p,merge(e){$.add(e)},push(e){let t=0;r.pushDelay&&(t=r.pushDelay(e)??0),$.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(y(t,o)),l++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore($.toFragment(e),a.nextSibling)},splice(e,t){const[n,r,...s]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=f(t[0],n);if(1===t.length)w(e,u);else if(t.length>1){const r=v(e);a=r?.previousSibling;for(let e=0;e<t.length;e++){const r=f(t[e],n+e);w(r,u)}}}else a=i;u.replaceChildren(),s&&s.length&&a&&o.insertBefore($.toFragment(s),a.nextSibling)},reverse(e,t){$.reOrder(t)},sort(e,t){$.reOrder(t)},remove(e,t){$.removeOne(t)},pop(e,t){$.removeOne(t)},shift(e,t){$.removeOne(t)},swap(e,t){const n=i.parentNode;let r=b(t[0]),o=b(t[1]);if(!r||!o)return;const s=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,s),r=null,o=null}},C=(e,t,n)=>{if("clear"!==n.action&&e.length){if(n?.action)$[n.action]&&$[n.action](n.args,n.result);else{if(0===l)return void $.add(e);$.replace(e)}((e,t=0)=>{if(!c)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=u.get(f(e[r],r));t&&(t.indexObserver?.deref()?.set(n),n++)}})(e,0)}else{if(0===l)return;p()}};return e.val().length&&C(e.val(),0,{action:null}),I.isObservable(e)&&e.subscribe(C),o},Form:Me,Fragment:Wt,H1:pe,H2:de,H3:fe,H4:be,H5:me,H6:ge,Header:rt,HiddenInput:e=>Le({type:"hidden",...e}),HideIf:function(e,t,n){const r=P(!e.val());return e.subscribe(e=>r.set(!e)),re(r,t,n)},HideIfNot:function(e,t,n){return re(e,t,n)},Hr:Oe,Img:it,Input:Le,Ins:Ie,Kbd:Et,Label:ue,LazyImg:function(e,t){return it(e,{...t,loading:"lazy"})},Legend:ze,Li:ft,Link:ve,ListItem:dt,Main:Ze,Mark:Ee,Match:oe,Menu:ct,Meter:Je,MonthInput:e=>Le({type:"month",...e}),NativeDocumentFragment:k,Nav:et,NumberInput:e=>Le({type:"number",...e}),Ol:bt,Option:qe,OrderedList:ht,Output:Ue,P:le,Paragraph:ce,PasswordInput:e=>Le({type:"password",...e}),Pre:we,Progress:Ke,Quote:Te,Radio:e=>Le({type:"radio",...e}),RangeInput:e=>Le({type:"range",...e}),ReadonlyInput:e=>Le({readonly:!0,...e}),Samp:xt,SearchInput:e=>Le({type:"search",...e}),Section:Ge,Select:je,ShowIf:re,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!I.isObservableWhenResult(e))throw new s("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return re(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!I.isObservable(e))throw new s("showWhen observer must be an Observable",{data:e});return re(e.when(t),n)}throw new s("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Qe(e,{type:"button",...t}),Small:Ae,Source:vt,Span:ae,Strong:he,Sub:ke,SubmitButton:(e,t)=>Qe(e,{type:"submit",...t}),Summary:ut,Sup:Ne,Svg:Ct,Switch:se,TBody:Vt,TBodyCell:jt,TFoot:Tt,TFootCell:_t,THead:Ft,THeadCell:Lt,TRow:Rt,Table:Pt,Td:Bt,TelInput:e=>Le({type:"tel",...e}),TextArea:_e,TextInput:Be,Th:Mt,Time:Ot,TimeInput:e=>Le({type:"time",...e}),Tr:Dt,Track:wt,Ul:mt,UnorderedList:pt,UrlInput:e=>Le({type:"url",...e}),Var:It,Video:yt,Wbr:kt,WeekInput:e=>Le({type:"week",...e}),When:function(e){if(!I.isObservable(e))throw new s("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))}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=k("Portal "+n);return r.appendChild(W.getChild(e)),(t||document.body).appendChild(r),r}});const zt={};function Ht(e,t,n={}){e="/"+f(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=zt[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="/"+f(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 Ut extends Error{constructor(e,t){super(e),this.context=t}}const Kt=(e,t)=>{const n=[];return e.forEach(e=>{n.push(f(e.suffix,"/"))}),n.push(f(t,"/")),n.join("/")},Jt=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Qt=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Zt=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Gt(){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 Xt(){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){r.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:n,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:n},t.name()||n,n),this.handleRouteChange(t,o,{},n)}catch(e){r.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){r.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:n,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,n,o,s)}}function Yt(){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)}}const en="default";function tn(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Gt.apply(this,[]);else if("history"===e.mode)Xt.apply(this,[]);else{if("memory"!==e.mode)throw new Ut("Invalid router mode "+e.mode);Yt.apply(this,[])}const a=function(e,t){for(const n of s)try{n(e),t&&t(e)}catch(e){r.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,r,s){const i=new Ht(Kt(o,e),r,{...s,middlewares:Jt(o,s?.middlewares||[]),name:s?.name?Qt(o,s.name):null,layout:s?.layout||Zt(o)});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!I.isFunction(n))throw new Ut("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},r={}){const o=n[e];if(!o)throw new Ut(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(I.isJson(e)){const t=n[e.name];if(!t)throw new Ut(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[r,o]=e.split("?"),s="/"+f(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Ut(`Route not found for url: ${r}`);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(!I.isFunction(e))throw new Ut("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 nn(e,t){const{to:n,href:r,...o}=e,s=n||r;if(I.isString(s)){const e=tn.get();return ve({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||en,a=tn.get(i);if(!a)throw new Ut('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return ve({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}tn.routers={},tn.create=function(t,n){if(!I.isFunction(n))throw r.error("Router","Callback must be a function",e),new Ut("Callback must be a function");const o=new tn(t);return tn.routers[t.name||en]=o,n(o),o.init(t.entry),o.mount=function(e){if(I.isString(e)){const t=document.querySelector(e);if(!t)throw new Ut(`Container not found for selector: ${e}`);e=t}else if(!I.isElement(e))throw new Ut("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e,n){t.innerHTML="";const r=n.layout();r?t.appendChild(r(e)):t.appendChild(e)},o=function(e){if(!e.route)return;const{route:t,params:o,query:s,path:i}=e;if(n.has(i)){const e=n.get(i);return void r(e,t)}const a=t.component()({params:o,query:s});n.set(i,a),r(a,t)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},tn.get=function(e){const t=tn.routers[e||en];if(!t)throw new Ut(`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()},nn.blank=function(e,t){return ve({...e,target:"_blank"},t)};var rn=Object.freeze({__proto__:null,Link:nn,RouteParamPatterns:zt,Router:tn});return t.ElementCreator=W,t.HtmlElementWrapper=J,t.NDElement=g,t.Observable=P,t.PluginsManager=a,t.Service=ee,t.SingletonView=G,t.Store=ne,t.TemplateCloner=Z,t.Validator=I,t.autoMemoize=Y,t.autoOnce=X,t.classPropertyAccumulator=function(e=[]){let t=I.isString(e)?e.split(" ").filter(Boolean):e;const n=I.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=U,t.cssPropertyAccumulator=function(e={}){let t=I.isString(e)?e.split(";").filter(Boolean):e;const n=I.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=qt,t.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n;return t.has(r)||t.set(r,e(...o)),t.get(r)}},t.normalizeComponentArgs=H,t.once=e=>{let t=null;return(...n)=>(null===t&&(t=e(...n)),t)},t.router=rn,t.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])}},t.useSingleton=function(e){let t=null;return function(...n){return t||(t=new G(e)),t.render(n)}},t.withValidation=z,t}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -11,10 +11,11 @@ const ObservableArray = function (target, { propagation = false, deep = false }
11
11
  throw new NativeDocumentError('Observable.array : target must be an array');
12
12
  }
13
13
 
14
- ObservableItem.apply(this, [target]);
14
+ ObservableItem.call(this, target);
15
15
  PluginsManager.emit('CreateObservableArray', this);
16
16
  };
17
17
 
18
+ ObservableArray.prototype = Object.create(ObservableItem.prototype);
18
19
  ObservableArray.prototype.__$isObservableArray = true;
19
20
 
20
21
  mutationMethods.forEach((method) => {