native-document 1.0.38 → 1.0.40

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)}}}}}();function s(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,i.emit("CreateObservable",this)}Object.defineProperty(s.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),s.prototype.__$isObservable=!0;const l=function(){};s.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},s.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||DEFAULT_OPERATIONS;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const a=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};s.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);a(t,!0)}if(e.has(t)){const n=e.get(t);a(n,!1)}},s.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},s.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},s.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=l},s.prototype.trigger=l,s.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))},s.prototype.val=function(){return this.$currentValue},s.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)w.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=l},s.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},s.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)}},s.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!w.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()}},s.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},s.prototype.check=function(e){return new o(this,e)},s.prototype.get=s.prototype.check,s.prototype.when=function(e){return{$target:e,$observer:this}},s.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"};const u={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(u.mountedSupposedSize>0)for(const e of t.addedNodes){const t=u.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(u.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=u.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:()=>{u.mounted.delete(e),u.unmounted.delete(e),u.mountedSupposedSize--,u.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,u.mounted.set(e,n),u.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,u.unmounted.set(e,n),u.unmountedSupposedSize++}}}};u.observer=new MutationObserver(u.checkMutation),u.observer.observe(document.body,{childList:!0,subtree:!0});const c=["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 d(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}d.prototype.__$isNDElement=!0,d.prototype.valueOf=function(){return this.$element},d.prototype.ref=function(e,t){return e[t]=this.$element,this},d.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},d.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},d.prototype.lifecycle=function(e){return this.$observer=this.$observer||u.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},d.prototype.mounted=function(e){return this.lifecycle({mounted:e})},d.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},d.prototype.htmlElement=function(){return this.$element},d.prototype.node=d.prototype.htmlElement,d.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},d.prototype.openShadow=function(e=null){return this.shadow("open",e)},d.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},d.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const p={},h=function(e,t,n){if(!e)return;if(!p[t]){const r=new WeakMap;return p[t]=r,void r.set(e,n)}const r=p[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);w.isArray(o)?o.push(n):r.set(e,[store[t],n])},f=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},b=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},g=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},m=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=p[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(w.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 c){const t=e.toLowerCase();d.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},d.prototype["onPrevent"+e]=function(e){return f(this.$element,t,e),this},d.prototype["onStop"+e]=function(e){return b(this.$element,t,e),this},d.prototype["onPreventStop"+e]=function(e){return g(this.$element,t,e),this},d.prototype["when"+e]=function(e){return h(this.$element,t,e),this},d.prototype["capture"+e]=function(e){return m(this.$element,t,e),this}}const v=1,y=3,$=11,w={isObservable:e=>e?.__$isObservable||e instanceof s||e instanceof o,isProxy:e=>e?.__isProxy__,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===v||e.nodeType===y||e.nodeType===$),isFragment:e=>e?.nodeType===$,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof d,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(w.isObject(e)&&Object.values(e).some(e=>w.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")}},O=["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 C(e){return new s(e)}function S(e,t,n){e.classes.toggle(t,n)}function A(e,t,n){e.style[t]=n}function x(e,t,n){w.isBoolean(n)?e[t]=n:e[t]=n===e.value}function E(e,t,n,r){w.isBoolean(n)?r.set(e[t]):r.set(e.value)}function N(e,t){for(let n in t){const r=t[n];w.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(S.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,S.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function k(e,t){for(let n in t){const r=t[n];w.isObservable(r)?(e.style[n]=r.val(),r.subscribe(A.bind(null,e,n))):e.style[n]=r}}function P(e,t,n){const r=w.isObservable(n)?n.val():n;w.isBoolean(r)?e[t]=r:e[t]=r===e.value,w.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",E.bind(null,e,t,r)),n.subscribe(x.bind(null,e,t)))}function T(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))}C.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},C.cleanup=function(e){e.cleanup()},C.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 L=null;const j={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=j.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=j.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=j.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(D.has(e))return D.get(e).cloneNode();const t=document.createElement(e);return D.set(e,t),t.cloneNode()}return new M("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(w.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,w.isString(e)))return j.createStaticTextNode(null,e);if(w.isElement(e))return e;if(w.isObservable(e))return j.createObservableNode(null,e);if(w.isNDElement(e))return e.$element??e.$build?.()??null;if(w.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 w.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?j.createHydratableNode(null,e):j.createStaticTextNode(null,e)},processAttributes(e,t){w.isFragment(e)||t&&function(e,t){if(!w.isObject(t))throw new r("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(w.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,w.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>w.isObservable(e));o=C.computed(()=>o.map(e=>w.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&w.isObject(o)?N(e,o):"style"===r&&w.isObject(o)?k(e,o):O.includes(r)?P(e,r,o):w.isObservable(o)?T(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 M(e,n=!1){const r=document.createDocumentFragment(),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 r=i.parentNode;r?function(e,t,n){const r=w.isElement(t)?t:j.getChild(t);e!==r?s(e)||n===i?e.append(r,n):e.insertBefore(r,n):e.nativeInsertBefore(r,n)}(r,e,n=n??i):t.error("Anchor","Anchor : parent not found",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(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(i,i);let t,n=o.nextSibling;for(;n!==i;)t=n.nextSibling,r.nativeAppendChild(n),n=t},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.clear=function(){r.remove()},r.endElement=function(){return i},r.startElement=function(){return o},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 d(this)}});const B={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,...B}}});function I(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!w.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=j.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&j.processAttributes(l,o),i&&j.processChildren(i,l),j.setup(l,o,t)}function F(e,t){return I.bind(null,e.toLowerCase(),t)}const V=F("div");F("span"),F("label"),F("p"),F("strong"),F("h1"),F("h2"),F("h3"),F("h4"),F("h5"),F("h6"),F("br"),F("a"),F("pre"),F("code"),F("blockquote"),F("hr"),F("em"),F("small"),F("mark"),F("del"),F("ins"),F("sub"),F("sup"),F("abbr"),F("cite"),F("q"),F("dl"),F("dt"),F("dd"),F("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}),F("input"),F("textarea"),F("select"),F("fieldset"),F("option"),F("legend"),F("datalist"),F("output"),F("progress"),F("meter");const _=F("button");F("main"),F("section"),F("article"),F("aside"),F("nav"),F("figure"),F("figcaption"),F("header"),F("footer"),F("img"),F("details"),F("summary"),F("dialog"),F("menu"),F("ol"),F("ul"),F("li"),F("audio"),F("video"),F("source"),F("track"),F("canvas"),F("svg"),F("time"),F("data"),F("address"),F("kbd"),F("samp"),F("var"),F("wbr"),F("caption"),F("table"),F("thead"),F("tfoot"),F("tbody"),F("tr"),F("th"),F("td"),F(""),Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new d(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 C.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return w.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return w.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!w.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return C.getById(n)}):this.valueOf()};const z=["push","pop","shift","unshift","reverse","sort","splice"];C.array=function(e){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");const t=C(e);i.emit("CreateObservableArray",t),z.forEach(e=>{t[e]=function(...n){const r=t.val()[e](...n);return t.trigger({action:e,args:n,result:r}),r}}),t.clear=function(){return t.val().length=0,t.trigger({action:"clear"}),!0},t.merge=function(e){t.$value.push(...e),t.trigger({action:"merge",args:e})},t.populateAndRender=function(e,n){t.trigger({action:"populate",args:[t.val(),e,n]})},t.remove=function(e){const n=t.val().splice(e,1);return 0===n.length?[]:(t.trigger({action:"remove",args:[e],result:n[0]}),n)},t.swap=function(e,n){const r=t.val(),o=r.length;if(o<e||o<n)return!1;if(n<e){const t=e;e=n,n=t}const i=r[e],s=r[n];return r[e]=s,r[n]=i,t.trigger({action:"swap",args:[e,n],result:[i,s]}),!0},t.length=function(){return t.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{t[e]=(...n)=>t.val()[e](...n)}),t},C.batch=function(e){const t=C(0),n=function(){if(w.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n},C.init=function(e){const t={};for(const n in e){const r=e[n];w.isJson(r)?t[n]=C.init(r):w.isArray(r)?t[n]=C.array(r):t[n]=C(r)}const n=function(){},r=function(e){C.update(o,e)},o=new Proxy(t,{get:(e,o)=>"__isProxy__"===o||("$value"===o?function(){const e={};for(const n in t){const r=t[n];w.isObservable(r)?e[n]=r.val():w.isProxy(r)?e[n]=r.$value:e[n]=r}return e}():"$clone"===o?n:"$observables"===o?Object.values(e):"$updateWith"===o?r:void 0!==e[o]?e[o]:void 0),set:(e,t,n)=>void 0===e[t]||(w.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return o},C.arrayOfObject=function(e){return e.map(e=>C.object(e))},C.value=function(e){if(w.isObservable(e))return e.val();if(w.isProxy(e))return e.$value;if(w.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(C.value(r))}return t}return e},C.update=function(e,t){w.isProxy(t)&&(t=t.$value);for(const n in t){const r=e[n],o=t[n];if(w.isObservable(r)){if(w.isArray(o)){r.set([...o]);continue}r.set(o)}else w.isProxy(r)?C.update(r,o):e[n]=o}},C.object=C.init,C.json=C.init,C.computed=function(e,t=[]){const n=new s(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),w.isFunction(t)){if(!w.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{w.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const W={createdObservable:C(0)},U={name:"DevTools",onCreateObservable(e){W.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function R(){let e=!1;const t=V({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[V({class:"widget-label"},W.createdObservable),_({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=V(V({class:"devtools-app-panel-wrapper pin-to-right"},[R,V({class:"devtools-app-panel"}),V("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:U}}();
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)}}}}}();function s(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,i.emit("CreateObservable",this)}Object.defineProperty(s.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),s.prototype.__$isObservable=!0;const l={},a=function(){};s.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},s.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||l;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const u=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};s.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);u(t,!0)}if(e.has(t)){const n=e.get(t);u(n,!1)}},s.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},s.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},s.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=a},s.prototype.trigger=a,s.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))},s.prototype.val=function(){return this.$currentValue},s.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)C.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=a},s.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},s.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)}},s.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!C.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()}},s.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},s.prototype.check=function(e){return new o(this,e)},s.prototype.get=s.prototype.check,s.prototype.when=function(e){return{$target:e,$observer:this}},s.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"};const c={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(c.mountedSupposedSize>0)for(const e of t.addedNodes){const t=c.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(c.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=c.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:()=>{c.mounted.delete(e),c.unmounted.delete(e),c.mountedSupposedSize--,c.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,c.mounted.set(e,n),c.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,c.unmounted.set(e,n),c.unmountedSupposedSize++}}}};c.observer=new MutationObserver(c.checkMutation),c.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 p(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}p.prototype.__$isNDElement=!0,p.prototype.valueOf=function(){return this.$element},p.prototype.ref=function(e,t){return e[t]=this.$element,this},p.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},p.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},p.prototype.lifecycle=function(e){return this.$observer=this.$observer||c.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},p.prototype.mounted=function(e){return this.lifecycle({mounted:e})},p.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},p.prototype.htmlElement=function(){return this.$element},p.prototype.node=p.prototype.htmlElement,p.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},p.prototype.openShadow=function(e=null){return this.shadow("open",e)},p.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},p.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const h={},f=function(e,t,n){if(!e)return;if(!h[t]){const r=new WeakMap;return h[t]=r,void r.set(e,n)}const r=h[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);C.isArray(o)?o.push(n):r.set(e,[store[t],n])},b=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},g=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},m=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},v=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=h[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(C.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();p.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},p.prototype["onPrevent"+e]=function(e){return b(this.$element,t,e),this},p.prototype["onStop"+e]=function(e){return g(this.$element,t,e),this},p.prototype["onPreventStop"+e]=function(e){return m(this.$element,t,e),this},p.prototype["when"+e]=function(e){return f(this.$element,t,e),this},p.prototype["capture"+e]=function(e){return v(this.$element,t,e),this}}const y=1,$=3,w=11,C={isObservable:e=>e?.__$isObservable||e instanceof s||e instanceof o,isProxy:e=>e?.__isProxy__,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===y||e.nodeType===$||e.nodeType===w),isFragment:e=>e?.nodeType===w,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof p,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(C.isObject(e)&&Object.values(e).some(e=>C.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")}},O=["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 s(e)}function A(e,t,n){e.classes.toggle(t,n)}function x(e,t,n){e.style[t]=n}function E(e,t,n){C.isBoolean(n)?e[t]=n:e[t]=n===e.value}function N(e,t,n,r){C.isBoolean(n)?r.set(e[t]):r.set(e.value)}function k(e,t){for(let n in t){const r=t[n];C.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(A.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,A.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function P(e,t){for(let n in t){const r=t[n];C.isObservable(r)?(e.style[n]=r.val(),r.subscribe(x.bind(null,e,n))):e.style[n]=r}}function D(e,t,n){const r=C.isObservable(n)?n.val():n;C.isBoolean(r)?e[t]=r:e[t]=r===e.value,C.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",N.bind(null,e,t,r)),n.subscribe(E.bind(null,e,t)))}function T(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.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 L=new Map;let j=null;const M={createTextNode:()=>(j||(j=document.createTextNode("")),j.cloneNode()),createObservableNode(e,t){const n=M.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=M.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=M.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(L.has(e))return L.get(e).cloneNode();const t=document.createElement(e);return L.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(C.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,C.isString(e)))return M.createStaticTextNode(null,e);if(C.isElement(e))return e;if(C.isObservable(e))return M.createObservableNode(null,e);if(C.isNDElement(e))return e.$element??e.$build?.()??null;if(C.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 C.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?M.createHydratableNode(null,e):M.createStaticTextNode(null,e)},processAttributes(e,t){C.isFragment(e)||t&&function(e,t){if(!C.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(C.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,C.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>C.isObservable(e));o=S.computed(()=>o.map(e=>C.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&C.isObject(o)?k(e,o):"style"===r&&C.isObject(o)?P(e,o):O.includes(r)?D(e,r,o):C.isObservable(o)?T(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(),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 r=i.parentNode;r?function(e,t,n){const r=C.isElement(t)?t:M.getChild(t);e!==r?s(e)&&n===i?e.append(r,n):e.insertBefore(r,n):e.nativeInsertBefore(r,n)}(r,e,n=n??i):t.error("Anchor","Anchor : parent not found",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(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;for(;n&&n!==i;)t=n.nextSibling,r.nativeAppendChild(n),n=t},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.clear=function(){r.remove()},r.endElement=function(){return i},r.startElement=function(){return o},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 p(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 V(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!C.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=M.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&M.processAttributes(l,o),i&&M.processChildren(i,l),M.setup(l,o,t)}function F(e,t){return V.bind(null,e.toLowerCase(),t)}const _=F("div");F("span"),F("label"),F("p"),F("strong"),F("h1"),F("h2"),F("h3"),F("h4"),F("h5"),F("h6"),F("br"),F("a"),F("pre"),F("code"),F("blockquote"),F("hr"),F("em"),F("small"),F("mark"),F("del"),F("ins"),F("sub"),F("sup"),F("abbr"),F("cite"),F("q"),F("dl"),F("dt"),F("dd"),F("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}),F("input"),F("textarea"),F("select"),F("fieldset"),F("option"),F("legend"),F("datalist"),F("output"),F("progress"),F("meter");const z=F("button");F("main"),F("section"),F("article"),F("aside"),F("nav"),F("figure"),F("figcaption"),F("header"),F("footer"),F("img"),F("details"),F("summary"),F("dialog"),F("menu"),F("ol"),F("ul"),F("li"),F("audio"),F("video"),F("source"),F("track"),F("canvas"),F("svg"),F("time"),F("data"),F("address"),F("kbd"),F("samp"),F("var"),F("wbr"),F("caption"),F("table"),F("thead"),F("tfoot"),F("tbody"),F("tr"),F("th"),F("td"),F(""),Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new p(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 C.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return C.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!C.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return S.getById(n)}):this.valueOf()};const W=["push","pop","shift","unshift","reverse","sort","splice"];S.array=function(e){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");const t=S(e);i.emit("CreateObservableArray",t),W.forEach(e=>{t[e]=function(...n){const r=t.val()[e](...n);return t.trigger({action:e,args:n,result:r}),r}}),t.clear=function(){return t.val().length=0,t.trigger({action:"clear"}),!0},t.merge=function(e){t.$value.push(...e),t.trigger({action:"merge",args:e})},t.populateAndRender=function(e,n){t.trigger({action:"populate",args:[t.val(),e,n]})},t.remove=function(e){const n=t.val().splice(e,1);return 0===n.length?[]:(t.trigger({action:"remove",args:[e],result:n[0]}),n)},t.swap=function(e,n){const r=t.val(),o=r.length;if(o<e||o<n)return!1;if(n<e){const t=e;e=n,n=t}const i=r[e],s=r[n];return r[e]=s,r[n]=i,t.trigger({action:"swap",args:[e,n],result:[i,s]}),!0},t.length=function(){return t.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{t[e]=(...n)=>t.val()[e](...n)}),t},S.batch=function(e){const t=S(0),n=function(){if(C.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){const t={};for(const n in e){const r=e[n];t[n]=S(r)}const n=function(){const e={};for(const n in t){const r=t[n];C.isObservable(r)?e[n]=r.val():C.isProxy(r)?e[n]=r.$value:e[n]=r}return e},r=function(){return S.init(n())},o=function(e){S.update(i,e)},i=new Proxy(t,{get:(e,t)=>"__isProxy__"===t||("$value"===t?n():"$clone"===t?r:"$observables"===t?Object.values(e):"$updateWith"===t?o:void 0!==e[t]?e[t]:void 0),set:(e,t,n)=>void 0===e[t]||(C.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return i},S.arrayOfObject=function(e){return e.map(e=>S.object(e))},S.value=function(e){if(C.isObservable(e))return e.val();if(C.isProxy(e))return e.$value;if(C.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){C.isProxy(t)&&(t=t.$value);for(const n in t){const r=e[n],o=t[n];if(C.isObservable(r)){if(C.isArray(o)){r.set([...o]);continue}r.set(o)}else C.isProxy(r)?S.update(r,o):e[n]=o}},S.object=S.init,S.json=S.init,S.computed=function(e,t=[]){const n=new s(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),C.isFunction(t)){if(!C.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{C.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const U={createdObservable:S(0)},R={name:"DevTools",onCreateObservable(e){U.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function H(){let e=!1;const t=_({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[_({class:"widget-label"},U.createdObservable),z({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=_(_({class:"devtools-app-panel-wrapper pin-to-right"},[H,_({class:"devtools-app-panel"}),_("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:R}}();
@@ -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)}}}}}();function u(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,a.emit("CreateObservable",this)}Object.defineProperty(u.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),u.prototype.__$isObservable=!0;const l=function(){};u.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},u.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||DEFAULT_OPERATIONS;for(let o=0,s=t.length;o<s;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)};u.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)}},u.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},u.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},u.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=l},u.prototype.trigger=l,u.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))},u.prototype.val=function(){return this.$currentValue},u.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)E.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=l},u.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},u.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)}},u.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!E.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()}},u.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},u.prototype.check=function(e){return new i(this,e)},u.prototype.get=u.prototype.check,u.prototype.when=function(e){return{$target:e,$observer:this}},u.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"};const h=(e,t,n)=>{if(E.isFunction(n))return n(e,t);if(E.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return E.isObject(e)?e[n]?.val?.()??e[n]??t:e},d=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},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 f=["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 m(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}m.prototype.__$isNDElement=!0,m.prototype.valueOf=function(){return this.$element},m.prototype.ref=function(e,t){return e[t]=this.$element,this},m.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},m.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},m.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},m.prototype.mounted=function(e){return this.lifecycle({mounted:e})},m.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},m.prototype.htmlElement=function(){return this.$element},m.prototype.node=m.prototype.htmlElement,m.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},m.prototype.openShadow=function(e=null){return this.shadow("open",e)},m.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},m.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const b={},g=function(e,t,n){if(!e)return;if(!b[t]){const r=new WeakMap;return b[t]=r,void r.set(e,n)}const r=b[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);E.isArray(o)?o.push(n):r.set(e,[store[t],n])},v=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},y=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},w=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},$=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=b[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(E.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 f){const t=e.toLowerCase();m.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},m.prototype["onPrevent"+e]=function(e){return v(this.$element,t,e),this},m.prototype["onStop"+e]=function(e){return y(this.$element,t,e),this},m.prototype["onPreventStop"+e]=function(e){return w(this.$element,t,e),this},m.prototype["when"+e]=function(e){return g(this.$element,t,e),this},m.prototype["capture"+e]=function(e){return $(this.$element,t,e),this}}const C=1,O=3,S=11,E={isObservable:e=>e?.__$isObservable||e instanceof u||e instanceof i,isProxy:e=>e?.__isProxy__,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===C||e.nodeType===O||e.nodeType===S),isFragment:e=>e?.nodeType===S,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 m,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&&(E.isObject(e)&&Object.values(e).some(e=>E.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 A(e,t=!1){const n=document.createDocumentFragment(),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 n=s.parentNode;n?function(e,t,n){const r=E.isElement(t)?t:j.getChild(t);e!==r?i(e)||n===s?e.append(r,n):e.insertBefore(r,n):e.nativeInsertBefore(r,n)}(n,e,t=t??s):r.error("Anchor","Anchor : parent not found",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(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(s,s);let t,r=o.nextSibling;for(;r!==s;)t=r.nextSibling,n.nativeAppendChild(r),r=t},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.clear=function(){n.remove()},n.endElement=function(){return s},n.startElement=function(){return o},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 I=["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 k(e){return new u(e)}function x(e,t,n){e.classes.toggle(t,n)}function N(e,t,n){e.style[t]=n}function F(e,t,n){E.isBoolean(n)?e[t]=n:e[t]=n===e.value}function T(e,t,n,r){E.isBoolean(n)?r.set(e[t]):r.set(e.value)}function D(e,t){for(let n in t){const r=t[n];E.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(x.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,x.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function P(e,t){for(let n in t){const r=t[n];E.isObservable(r)?(e.style[n]=r.val(),r.subscribe(N.bind(null,e,n))):e.style[n]=r}}function L(e,t,n){const r=E.isObservable(n)?n.val():n;E.isBoolean(r)?e[t]=r:e[t]=r===e.value,E.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",T.bind(null,e,t,r)),n.subscribe(F.bind(null,e,t)))}function R(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))}k.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},k.cleanup=function(e){e.cleanup()},k.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 M=null;const j={createTextNode:()=>(M||(M=document.createTextNode("")),M.cloneNode()),createObservableNode(e,t){const n=j.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=j.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=j.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(B.has(e))return B.get(e).cloneNode();const t=document.createElement(e);return B.set(e,t),t.cloneNode()}return new A("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(E.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,E.isString(e)))return j.createStaticTextNode(null,e);if(E.isElement(e))return e;if(E.isObservable(e))return j.createObservableNode(null,e);if(E.isNDElement(e))return e.$element??e.$build?.()??null;if(E.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 E.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?j.createHydratableNode(null,e):j.createStaticTextNode(null,e)},processAttributes(e,t){E.isFragment(e)||t&&function(e,t){if(!E.isObject(t))throw new s("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(E.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,E.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>E.isObservable(e));o=k.computed(()=>o.map(e=>E.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&E.isObject(o)?D(e,o):"style"===r&&E.isObject(o)?P(e,o):I.includes(r)?L(e,r,o):E.isObservable(o)?R(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 m(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 _=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 V=function(e,t=null){if(!E.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},H=function(e){return E.isObservable(e)?j.createObservableNode(null,e):j.createStaticTextNode(null,e)};function W(e,t,n,r=null){let{props:o,children:s=null}=V(n,r),i=j.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&j.processAttributes(a,o),s&&j.processChildren(s,a),j.setup(a,o,t)}function z(e,t){return W.bind(null,e.toLowerCase(),t)}const U=new WeakMap;function K(e){let t=null,n=!1;const r=(e,t)=>{const n=U.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&&j.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){U.has(n)||U.set(n,{});const o=U.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 H(n[e])}:function(t){return H(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new m(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 k.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return E.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return E.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!E.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return k.getById(n)}):this.valueOf()};const J=["push","pop","shift","unshift","reverse","sort","splice"];k.array=function(e){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");const t=k(e);a.emit("CreateObservableArray",t),J.forEach(e=>{t[e]=function(...n){const r=t.val()[e](...n);return t.trigger({action:e,args:n,result:r}),r}}),t.clear=function(){return t.val().length=0,t.trigger({action:"clear"}),!0},t.merge=function(e){t.$value.push(...e),t.trigger({action:"merge",args:e})},t.populateAndRender=function(e,n){t.trigger({action:"populate",args:[t.val(),e,n]})},t.remove=function(e){const n=t.val().splice(e,1);return 0===n.length?[]:(t.trigger({action:"remove",args:[e],result:n[0]}),n)},t.swap=function(e,n){const r=t.val(),o=r.length;if(o<e||o<n)return!1;if(n<e){const t=e;e=n,n=t}const s=r[e],i=r[n];return r[e]=i,r[n]=s,t.trigger({action:"swap",args:[e,n],result:[s,i]}),!0},t.length=function(){return t.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{t[e]=(...n)=>t.val()[e](...n)}),t},k.batch=function(e){const t=k(0),n=function(){if(E.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n},k.init=function(e){const t={};for(const n in e){const r=e[n];E.isJson(r)?t[n]=k.init(r):E.isArray(r)?t[n]=k.array(r):t[n]=k(r)}const n=function(){},r=function(e){k.update(o,e)},o=new Proxy(t,{get:(e,o)=>"__isProxy__"===o||("$value"===o?function(){const e={};for(const n in t){const r=t[n];E.isObservable(r)?e[n]=r.val():E.isProxy(r)?e[n]=r.$value:e[n]=r}return e}():"$clone"===o?n:"$observables"===o?Object.values(e):"$updateWith"===o?r:void 0!==e[o]?e[o]:void 0),set:(e,t,n)=>void 0===e[t]||(E.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return o},k.arrayOfObject=function(e){return e.map(e=>k.object(e))},k.value=function(e){if(E.isObservable(e))return e.val();if(E.isProxy(e))return e.$value;if(E.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(k.value(r))}return t}return e},k.update=function(e,t){E.isProxy(t)&&(t=t.$value);for(const n in t){const r=e[n],o=t[n];if(E.isObservable(r)){if(E.isArray(o)){r.set([...o]);continue}r.set(o)}else E.isProxy(r)?k.update(r,o):e[n]=o}},k.object=k.init,k.json=k.init,k.computed=function(e,t=[]){const n=new u(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),E.isFunction(t)){if(!E.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{E.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const Q=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=k(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=k(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 Z=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!E.isObservable(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=new A("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=j.getChild(t),E.isFragment(i)&&(i=Array.from(i.children))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},G=function(e,t,n=!0){if(!E.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=new A,o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=j.getChild(r),E.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},X=function(e,t,n){if(!E.isObservable(e))throw new s("Toggle : condition must be an Observable");return G(e,{true:t,false:n})},Y=z("div"),ee=z("span"),te=z("label"),ne=z("p"),re=ne,oe=z("strong"),se=z("h1"),ie=z("h2"),ae=z("h3"),ue=z("h4"),le=z("h5"),ce=z("h6"),he=z("br"),de=z("a"),pe=z("pre"),fe=z("code"),me=z("blockquote"),be=z("hr"),ge=z("em"),ve=z("small"),ye=z("mark"),we=z("del"),$e=z("ins"),Ce=z("sub"),Oe=z("sup"),Se=z("abbr"),Ee=z("cite"),Ae=z("q"),Ie=z("dl"),ke=z("dt"),xe=z("dd"),Ne=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}),Fe=z("input"),Te=z("textarea"),De=Te,Pe=z("select"),Le=z("fieldset"),Re=z("option"),Be=z("legend"),Me=z("datalist"),je=z("output"),qe=z("progress"),_e=z("meter"),Ve=z("button"),He=z("main"),We=z("section"),ze=z("article"),Ue=z("aside"),Ke=z("nav"),Je=z("figure"),Qe=z("figcaption"),Ze=z("header"),Ge=z("footer"),Xe=z("img"),Ye=function(e,t){return Xe({src:e,...t})},et=z("details"),tt=z("summary"),nt=z("dialog"),rt=z("menu"),ot=z("ol"),st=z("ul"),it=z("li"),at=it,ut=ot,lt=st,ct=z("audio"),ht=z("video"),dt=z("source"),pt=z("track"),ft=z("canvas"),mt=z("svg"),bt=z("time"),gt=z("data"),vt=z("address"),yt=z("kbd"),wt=z("samp"),$t=z("var"),Ct=z("wbr"),Ot=z("caption"),St=z("table"),Et=z("thead"),At=z("tfoot"),It=z("tbody"),kt=z("tr"),xt=kt,Nt=z("th"),Ft=Nt,Tt=Nt,Dt=z("td"),Pt=Dt,Lt=z("");var Rt=Object.freeze({__proto__:null,Abbr:Se,Address:vt,Anchor:A,Article:ze,Aside:Ue,AsyncImg:function(e,t,n,r){const o=Ye(t||e,n),i=new Image;return i.onload=()=>{E.isFunction(r)&&r(null,o),o.src=e},i.onerror=()=>{E.isFunction(r)&&r(new s("Image not found"))},E.isObservable(e)&&e.subscribe(e=>{i.src=e}),i.src=e,o},Audio:ct,BaseImage:Xe,Blockquote:me,Br:he,Button:Ve,Canvas:ft,Caption:Ot,Checkbox:e=>Fe({type:"checkbox",...e}),Cite:Ee,Code:fe,ColorInput:e=>Fe({type:"color",...e}),Data:gt,Datalist:Me,DateInput:e=>Fe({type:"date",...e}),DateTimeInput:e=>Fe({type:"datetime-local",...e}),Dd:xe,Del:we,Details:et,Dialog:nt,Div:Y,Dl:Ie,Dt:ke,Em:ge,EmailInput:e=>Fe({type:"email",...e}),FieldSet:Le,FigCaption:Qe,Figure:Je,FileInput:e=>Fe({type:"file",...e}),Footer:Ge,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=new A("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,d=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=h(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?k(o):null;let r=j.getChild(t(e,n));if(!r||E.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=E.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(),d(),void l?.clear();d(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return f(),E.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=new A("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,l=0;const c=t.length>=2,d=new WeakMap,p=()=>{o.removeChildren(),g(),l=0},f=(e,t)=>d.has(e)?d.get(e):h(e,t,n),m=e=>y(f(e)),b=(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())b(t,!1);u.clear()}else u.clear()},v=(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?k(n):null;let i=j.getChild(t(e,o));if(!i||E.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}),d.set(e,r),i},y=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(b(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(v(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=m(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{b(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(v(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=y(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=m(t[0]),o=m(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}),E.isObservable(e)&&e.subscribe(C),o},Form:Ne,Fragment:Lt,H1:se,H2:ie,H3:ae,H4:ue,H5:le,H6:ce,Header:Ze,HiddenInput:e=>Fe({type:"hidden",...e}),HideIf:function(e,t,n){const r=k(!e.val());return e.subscribe(e=>r.set(!e)),Z(r,t,n)},HideIfNot:function(e,t,n){return Z(e,t,n)},Hr:be,Img:Ye,Input:Fe,Ins:$e,Kbd:yt,Label:te,LazyImg:function(e,t){return Ye(e,{...t,loading:"lazy"})},Legend:Be,Li:at,Link:de,ListItem:it,Main:He,Mark:ye,Match:G,Menu:rt,Meter:_e,MonthInput:e=>Fe({type:"month",...e}),NativeDocumentFragment:A,Nav:Ke,NumberInput:e=>Fe({type:"number",...e}),Ol:ut,Option:Re,OrderedList:ot,Output:je,P:ne,Paragraph:re,PasswordInput:e=>Fe({type:"password",...e}),Pre:pe,Progress:qe,Quote:Ae,Radio:e=>Fe({type:"radio",...e}),RangeInput:e=>Fe({type:"range",...e}),ReadonlyInput:e=>Fe({readonly:!0,...e}),Samp:wt,SearchInput:e=>Fe({type:"search",...e}),Section:We,Select:Pe,ShowIf:Z,SimpleButton:(e,t)=>Ve(e,{type:"button",...t}),Small:ve,Source:dt,Span:ee,Strong:oe,Sub:Ce,SubmitButton:(e,t)=>Ve(e,{type:"submit",...t}),Summary:tt,Sup:Oe,Svg:mt,Switch:X,TBody:It,TBodyCell:Pt,TFoot:At,TFootCell:Tt,THead:Et,THeadCell:Ft,TRow:xt,Table:St,Td:Dt,TelInput:e=>Fe({type:"tel",...e}),TextArea:Te,TextInput:De,Th:Nt,Time:bt,TimeInput:e=>Fe({type:"time",...e}),Tr:kt,Track:pt,Ul:lt,UnorderedList:st,UrlInput:e=>Fe({type:"url",...e}),Var:$t,Video:ht,Wbr:Ct,WeekInput:e=>Fe({type:"week",...e}),When:function(e){if(!E.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,X(e,t,n))}}});const Bt={};function Mt(e,t,n={}){e="/"+d(e,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u={},l=[],c=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=Bt[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},h=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=c(t);return n&&n.pattern?(u[n.name]=n.pattern,l.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.match=function(e){e="/"+d(e,"/");if(!h().exec(e))return!1;const t={};return h().exec(e).forEach((e,n)=>{if(n<1)return;const r=l[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=c(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 jt extends Error{constructor(e,t){super(e),this.context=t}}const qt=(e,t)=>{const n=[];return e.forEach(e=>{n.push(d(e.suffix,"/"))}),n.push(d(t,"/")),n.join("/")},_t=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Vt=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")};function Ht(){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 Wt(){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 zt(){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 Ut="default";function Kt(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Ht.apply(this,[]);else if("history"===e.mode)Wt.apply(this,[]);else{if("memory"!==e.mode)throw new jt("Invalid router mode "+e.mode);zt.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 Mt(qt(o,e),r,{...s,middlewares:_t(o,s?.middlewares||[]),name:s?.name?Vt(o,s.name):null});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!E.isFunction(n))throw new jt("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 jt(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(E.isJson(e)){const t=n[e.name];if(!t)throw new jt(`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="/"+d(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new jt(`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(!E.isFunction(e))throw new jt("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 Jt(e,t){const{to:n,href:r,...o}=e,s=n||r;if(E.isString(s)){const e=Kt.get();return de({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||Ut,a=Kt.get(i);if(!a)throw new jt('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return de({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Kt.routers={},Kt.create=function(t,n){if(!E.isFunction(n))throw r.error("Router","Callback must be a function",e),new jt("Callback must be a function");const o=new Kt(t);return Kt.routers[t.name||Ut]=o,n(o),o.init(t.entry),o.mount=function(e){if(E.isString(e)){const t=document.querySelector(e);if(!t)throw new jt(`Container not found for selector: ${e}`);e=t}else if(!E.isElement(e))throw new jt("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e){t.innerHTML="",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)}const a=t.component()({params:o,query:s});n.set(i,a),r(a)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},Kt.get=function(e){const t=Kt.routers[e||Ut];if(!t)throw new jt(`Router not found for name: ${e}`);return t},Kt.push=function(e,t=null){return Kt.get(t).push(e)},Kt.replace=function(e,t=null){return Kt.get(t).replace(e)},Kt.forward=function(e=null){return Kt.get(e).forward()},Kt.back=function(e=null){return Kt.get(e).back()},Jt.blank=function(e,t){return de({...e,target:"_blank"},t)};var Qt=Object.freeze({__proto__:null,Link:Jt,RouteParamPatterns:Bt,Router:Kt});return t.ElementCreator=j,t.HtmlElementWrapper=z,t.NDElement=m,t.Observable=k,t.PluginsManager=a,t.Store=Q,t.TemplateCloner=K,t.classPropertyAccumulator=function(e=[]){let t=E.isString(e)?e.split(" ").filter(Boolean):e;const n=E.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=H,t.cssPropertyAccumulator=function(e={}){let t=E.isString(e)?e.split(";").filter(Boolean):e;const n=E.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=Rt,t.normalizeComponentArgs=V,t.router=Qt,t.useCache=function(e){let t=null;const n=function(n){return t||(t=new K(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},t.withValidation=_,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)}}}}}();function u(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,a.emit("CreateObservable",this)}Object.defineProperty(u.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),u.prototype.__$isObservable=!0;const l={},c=function(){};u.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},u.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||l;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)};const h=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};u.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);h(t,!0)}if(e.has(t)){const n=e.get(t);h(n,!1)}},u.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},u.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},u.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=c},u.prototype.trigger=c,u.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))},u.prototype.val=function(){return this.$currentValue},u.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)A.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},u.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},u.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)}},u.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()}},u.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},u.prototype.check=function(e){return new i(this,e)},u.prototype.get=u.prototype.check,u.prototype.when=function(e){return{$target:e,$observer:this}},u.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"};const d=(e,t,n)=>{if(A.isFunction(n))return n(e,t);if(A.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return A.isObject(e)?e[n]?.val?.()??e[n]??t:e},p=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},f={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(f.mountedSupposedSize>0)for(const e of t.addedNodes){const t=f.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(f.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=f.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:()=>{f.mounted.delete(e),f.unmounted.delete(e),f.mountedSupposedSize--,f.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,f.mounted.set(e,n),f.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,f.unmounted.set(e,n),f.unmountedSupposedSize++}}}};f.observer=new MutationObserver(f.checkMutation),f.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 b(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}b.prototype.__$isNDElement=!0,b.prototype.valueOf=function(){return this.$element},b.prototype.ref=function(e,t){return e[t]=this.$element,this},b.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},b.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},b.prototype.lifecycle=function(e){return this.$observer=this.$observer||f.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},b.prototype.mounted=function(e){return this.lifecycle({mounted:e})},b.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},b.prototype.htmlElement=function(){return this.$element},b.prototype.node=b.prototype.htmlElement,b.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},b.prototype.openShadow=function(e=null){return this.shadow("open",e)},b.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},b.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const g={},v=function(e,t,n){if(!e)return;if(!g[t]){const r=new WeakMap;return g[t]=r,void r.set(e,n)}const r=g[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])},y=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},w=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},$=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},C=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=g[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 m){const t=e.toLowerCase();b.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},b.prototype["onPrevent"+e]=function(e){return y(this.$element,t,e),this},b.prototype["onStop"+e]=function(e){return w(this.$element,t,e),this},b.prototype["onPreventStop"+e]=function(e){return $(this.$element,t,e),this},b.prototype["when"+e]=function(e){return v(this.$element,t,e),this},b.prototype["capture"+e]=function(e){return C(this.$element,t,e),this}}const O=1,S=3,E=11,A={isObservable:e=>e?.__$isObservable||e instanceof u||e instanceof i,isProxy:e=>e?.__isProxy__,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===O||e.nodeType===S||e.nodeType===E),isFragment:e=>e?.nodeType===E,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 b,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&&(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 s("Event callback must be a function")}};var I=Object.freeze({__proto__:null,default:A});function k(e,t=!1){const n=document.createDocumentFragment(),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 n=s.parentNode;n?function(e,t,n){const r=A.isElement(t)?t:_.getChild(t);e!==r?i(e)&&n===s?e.append(r,n):e.insertBefore(r,n):e.nativeInsertBefore(r,n)}(n,e,t=t??s):r.error("Anchor","Anchor : parent not found",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(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;for(;r&&r!==s;)t=r.nextSibling,n.nativeAppendChild(r),r=t},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.clear=function(){n.remove()},n.endElement=function(){return s},n.startElement=function(){return o},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 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 N(e){return new u(e)}function F(e,t,n){e.classes.toggle(t,n)}function T(e,t,n){e.style[t]=n}function D(e,t,n){A.isBoolean(n)?e[t]=n:e[t]=n===e.value}function P(e,t,n,r){A.isBoolean(n)?r.set(e[t]):r.set(e.value)}function L(e,t){for(let n in t){const r=t[n];A.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(F.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,F.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function R(e,t){for(let n in t){const r=t[n];A.isObservable(r)?(e.style[n]=r.val(),r.subscribe(T.bind(null,e,n))):e.style[n]=r}}function B(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",P.bind(null,e,t,r)),n.subscribe(D.bind(null,e,t)))}function M(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))}N.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},N.cleanup=function(e){e.cleanup()},N.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{o.cleanup()}),setInterval(()=>o.cleanObservables(r),n)};const j=new Map;let q=null;const _={createTextNode:()=>(q||(q=document.createTextNode("")),q.cloneNode()),createObservableNode(e,t){const n=_.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=_.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=_.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 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(A.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,A.isString(e)))return _.createStaticTextNode(null,e);if(A.isElement(e))return e;if(A.isObservable(e))return _.createObservableNode(null,e);if(A.isNDElement(e))return e.$element??e.$build?.()??null;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)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?_.createHydratableNode(null,e):_.createStaticTextNode(null,e)},processAttributes(e,t){A.isFragment(e)||t&&function(e,t){if(A.validateAttributes(t),!A.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(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=N.computed(()=>o.map(e=>A.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&A.isObject(o)?L(e,o):"style"===r&&A.isObject(o)?R(e,o):x.includes(r)?B(e,r,o):A.isObservable(o)?M(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 b(this)}});const V={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,...V}}});let H=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 W=function(e,t=null){if(!A.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},z=function(e){return A.isObservable(e)?_.createObservableNode(null,e):_.createStaticTextNode(null,e)};function U(e,t,n,r=null){let{props:o,children:s=null}=W(n,r),i=_.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&_.processAttributes(a,o),s&&_.processChildren(s,a),_.setup(a,o,t)}function K(e,t){return U.bind(null,e.toLowerCase(),t)}const J=new WeakMap;function Q(e){let t=null,n=!1;const r=(e,t)=>{const n=J.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&&_.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){J.has(n)||J.set(n,{});const o=J.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 z(n[e])}:function(t){return z(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new b(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 N.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 N.getById(n)}):this.valueOf()};const Z=["push","pop","shift","unshift","reverse","sort","splice"];N.array=function(e){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");const t=N(e);a.emit("CreateObservableArray",t),Z.forEach(e=>{t[e]=function(...n){const r=t.val()[e](...n);return t.trigger({action:e,args:n,result:r}),r}}),t.clear=function(){return t.val().length=0,t.trigger({action:"clear"}),!0},t.merge=function(e){t.$value.push(...e),t.trigger({action:"merge",args:e})},t.populateAndRender=function(e,n){t.trigger({action:"populate",args:[t.val(),e,n]})},t.remove=function(e){const n=t.val().splice(e,1);return 0===n.length?[]:(t.trigger({action:"remove",args:[e],result:n[0]}),n)},t.swap=function(e,n){const r=t.val(),o=r.length;if(o<e||o<n)return!1;if(n<e){const t=e;e=n,n=t}const s=r[e],i=r[n];return r[e]=i,r[n]=s,t.trigger({action:"swap",args:[e,n],result:[s,i]}),!0},t.length=function(){return t.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{t[e]=(...n)=>t.val()[e](...n)}),t},N.batch=function(e){const t=N(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},N.init=function(e){const t={};for(const n in e){const r=e[n];t[n]=N(r)}const n=function(){const e={};for(const n in t){const r=t[n];A.isObservable(r)?e[n]=r.val():A.isProxy(r)?e[n]=r.$value:e[n]=r}return e},r=function(){return N.init(n())},o=function(e){N.update(s,e)},s=new Proxy(t,{get:(e,t)=>"__isProxy__"===t||("$value"===t?n():"$clone"===t?r:"$observables"===t?Object.values(e):"$updateWith"===t?o:void 0!==e[t]?e[t]:void 0),set:(e,t,n)=>void 0===e[t]||(A.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return s},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.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(N.value(r))}return t}return e},N.update=function(e,t){A.isProxy(t)&&(t=t.$value);for(const n in t){const r=e[n],o=t[n];if(A.isObservable(r)){if(A.isArray(o)){r.set([...o]);continue}r.set(o)}else A.isProxy(r)?N.update(r,o):e[n]=o}},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new u(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),A.isFunction(t)){if(!A.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{A.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const G=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=N(n.val()),s=n.subscribe(e=>o.set(e)),i=o.subscribe(e=>n.set(e));return o.destroy=()=>{s(),i(),o.cleanup()},r.add(o),o},follow(e){return this.use(e)},create(t,n){const r=N(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 X=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!A.isObservable(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=_.getChild(t),A.isFragment(i)&&(i=Array.from(i.children))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Y=function(e,t,n=!0){if(!A.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=new k,o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=_.getChild(r),A.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},ee=function(e,t,n){if(!A.isObservable(e))throw new s("Toggle : condition must be an Observable");return Y(e,{true:t,false:n})},te=K("div"),ne=K("span"),re=K("label"),oe=K("p"),se=oe,ie=K("strong"),ae=K("h1"),ue=K("h2"),le=K("h3"),ce=K("h4"),he=K("h5"),de=K("h6"),pe=K("br"),fe=K("a"),me=K("pre"),be=K("code"),ge=K("blockquote"),ve=K("hr"),ye=K("em"),we=K("small"),$e=K("mark"),Ce=K("del"),Oe=K("ins"),Se=K("sub"),Ee=K("sup"),Ae=K("abbr"),Ie=K("cite"),ke=K("q"),xe=K("dl"),Ne=K("dt"),Fe=K("dd"),Te=K("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}),De=K("input"),Pe=K("textarea"),Le=Pe,Re=K("select"),Be=K("fieldset"),Me=K("option"),je=K("legend"),qe=K("datalist"),_e=K("output"),Ve=K("progress"),He=K("meter"),We=K("button"),ze=K("main"),Ue=K("section"),Ke=K("article"),Je=K("aside"),Qe=K("nav"),Ze=K("figure"),Ge=K("figcaption"),Xe=K("header"),Ye=K("footer"),et=K("img"),tt=function(e,t){return et({src:e,...t})},nt=K("details"),rt=K("summary"),ot=K("dialog"),st=K("menu"),it=K("ol"),at=K("ul"),ut=K("li"),lt=ut,ct=it,ht=at,dt=K("audio"),pt=K("video"),ft=K("source"),mt=K("track"),bt=K("canvas"),gt=K("svg"),vt=K("time"),yt=K("data"),wt=K("address"),$t=K("kbd"),Ct=K("samp"),Ot=K("var"),St=K("wbr"),Et=K("caption"),At=K("table"),It=K("thead"),kt=K("tfoot"),xt=K("tbody"),Nt=K("tr"),Ft=Nt,Tt=K("th"),Dt=Tt,Pt=Tt,Lt=K("td"),Rt=Lt,Bt=K("");var Mt=Object.freeze({__proto__:null,Abbr:Ae,Address:wt,Anchor:k,Article:Ke,Aside:Je,AsyncImg:function(e,t,n,r){const o=tt(t||e,n),i=new Image;return i.onload=()=>{A.isFunction(r)&&r(null,o),o.src=e},i.onerror=()=>{A.isFunction(r)&&r(new s("Image not found"))},A.isObservable(e)&&e.subscribe(e=>{i.src=e}),i.src=e,o},Audio:dt,BaseImage:et,Blockquote:ge,Br:pe,Button:We,Canvas:bt,Caption:Et,Checkbox:e=>De({type:"checkbox",...e}),Cite:Ie,Code:be,ColorInput:e=>De({type:"color",...e}),Data:yt,Datalist:qe,DateInput:e=>De({type:"date",...e}),DateTimeInput:e=>De({type:"datetime-local",...e}),Dd:Fe,Del:Ce,Details:nt,Dialog:ot,Div:te,Dl:xe,Dt:Ne,Em:ye,EmailInput:e=>De({type:"email",...e}),FieldSet:Be,FigCaption:Ge,Figure:Ze,FileInput:e=>De({type:"file",...e}),Footer:Ye,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?N(o):null;let r=_.getChild(t(e,n));if(!r||A.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=A.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(),A.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),m=e=>y(f(e)),b=(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())b(t,!1);u.clear()}else u.clear()},v=(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?N(n):null;let i=_.getChild(t(e,o));if(!i||A.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},y=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(b(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(v(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=m(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{b(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(v(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=y(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=m(t[0]),o=m(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}),A.isObservable(e)&&e.subscribe(C),o},Form:Te,Fragment:Bt,H1:ae,H2:ue,H3:le,H4:ce,H5:he,H6:de,Header:Xe,HiddenInput:e=>De({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),X(r,t,n)},HideIfNot:function(e,t,n){return X(e,t,n)},Hr:ve,Img:tt,Input:De,Ins:Oe,Kbd:$t,Label:re,LazyImg:function(e,t){return tt(e,{...t,loading:"lazy"})},Legend:je,Li:lt,Link:fe,ListItem:ut,Main:ze,Mark:$e,Match:Y,Menu:st,Meter:He,MonthInput:e=>De({type:"month",...e}),NativeDocumentFragment:k,Nav:Qe,NumberInput:e=>De({type:"number",...e}),Ol:ct,Option:Me,OrderedList:it,Output:_e,P:oe,Paragraph:se,PasswordInput:e=>De({type:"password",...e}),Pre:me,Progress:Ve,Quote:ke,Radio:e=>De({type:"radio",...e}),RangeInput:e=>De({type:"range",...e}),ReadonlyInput:e=>De({readonly:!0,...e}),Samp:Ct,SearchInput:e=>De({type:"search",...e}),Section:Ue,Select:Re,ShowIf:X,SimpleButton:(e,t)=>We(e,{type:"button",...t}),Small:we,Source:ft,Span:ne,Strong:ie,Sub:Se,SubmitButton:(e,t)=>We(e,{type:"submit",...t}),Summary:rt,Sup:Ee,Svg:gt,Switch:ee,TBody:xt,TBodyCell:Rt,TFoot:kt,TFootCell:Pt,THead:It,THeadCell:Dt,TRow:Ft,Table:At,Td:Lt,TelInput:e=>De({type:"tel",...e}),TextArea:Pe,TextInput:Le,Th:Tt,Time:vt,TimeInput:e=>De({type:"time",...e}),Tr:Nt,Track:mt,Ul:ht,UnorderedList:at,UrlInput:e=>De({type:"url",...e}),Var:Ot,Video:pt,Wbr:St,WeekInput:e=>De({type:"week",...e}),When:function(e){if(!A.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,ee(e,t,n))}}});const jt={};function qt(e,t,n={}){e="/"+p(e,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u={},l=[],c=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=jt[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},h=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=c(t);return n&&n.pattern?(u[n.name]=n.pattern,l.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.match=function(e){e="/"+p(e,"/");if(!h().exec(e))return!1;const t={};return h().exec(e).forEach((e,n)=>{if(n<1)return;const r=l[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=c(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 _t extends Error{constructor(e,t){super(e),this.context=t}}const Vt=(e,t)=>{const n=[];return e.forEach(e=>{n.push(p(e.suffix,"/"))}),n.push(p(t,"/")),n.join("/")},Ht=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Wt=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")};function zt(){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 Ut(){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 Kt(){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 Jt="default";function Qt(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)zt.apply(this,[]);else if("history"===e.mode)Ut.apply(this,[]);else{if("memory"!==e.mode)throw new _t("Invalid router mode "+e.mode);Kt.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 qt(Vt(o,e),r,{...s,middlewares:Ht(o,s?.middlewares||[]),name:s?.name?Wt(o,s.name):null});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!A.isFunction(n))throw new _t("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 _t(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(A.isJson(e)){const t=n[e.name];if(!t)throw new _t(`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="/"+p(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new _t(`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(!A.isFunction(e))throw new _t("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 Zt(e,t){const{to:n,href:r,...o}=e,s=n||r;if(A.isString(s)){const e=Qt.get();return fe({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||Jt,a=Qt.get(i);if(!a)throw new _t('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return fe({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Qt.routers={},Qt.create=function(t,n){if(!A.isFunction(n))throw r.error("Router","Callback must be a function",e),new _t("Callback must be a function");const o=new Qt(t);return Qt.routers[t.name||Jt]=o,n(o),o.init(t.entry),o.mount=function(e){if(A.isString(e)){const t=document.querySelector(e);if(!t)throw new _t(`Container not found for selector: ${e}`);e=t}else if(!A.isElement(e))throw new _t("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e){t.innerHTML="",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)}const a=t.component()({params:o,query:s});n.set(i,a),r(a)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},Qt.get=function(e){const t=Qt.routers[e||Jt];if(!t)throw new _t(`Router not found for name: ${e}`);return t},Qt.push=function(e,t=null){return Qt.get(t).push(e)},Qt.replace=function(e,t=null){return Qt.get(t).replace(e)},Qt.forward=function(e=null){return Qt.get(e).forward()},Qt.back=function(e=null){return Qt.get(e).back()},Zt.blank=function(e,t){return fe({...e,target:"_blank"},t)};var Gt=Object.freeze({__proto__:null,Link:Zt,RouteParamPatterns:jt,Router:Qt});return t.ElementCreator=_,t.HtmlElementWrapper=K,t.NDElement=b,t.Observable=N,t.PluginsManager=a,t.Store=G,t.TemplateCloner=Q,t.Validator=I,t.classPropertyAccumulator=function(e=[]){let t=A.isString(e)?e.split(" ").filter(Boolean):e;const n=A.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=z,t.cssPropertyAccumulator=function(e={}){let t=A.isString(e)?e.split(";").filter(Boolean):e;const n=A.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=Mt,t.normalizeComponentArgs=W,t.router=Gt,t.useCache=function(e){let t=null;const n=function(n){return t||(t=new Q(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},t.withValidation=H,t}({});
package/index.js CHANGED
@@ -8,7 +8,7 @@ import './src/utils/prototypes.js';
8
8
 
9
9
  export * from './src/utils/property-accumulator';
10
10
  export * from './src/utils/args-types';
11
- export * from './src/utils/validator'
11
+ export * as Validator from './src/utils/validator'
12
12
  export * from './src/data/Observable';
13
13
  export * from './src/data/observable-helpers/array';
14
14
  export * from './src/data/observable-helpers/batch';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -33,7 +33,7 @@ Object.defineProperty(ObservableItem.prototype, '$value', {
33
33
  });
34
34
 
35
35
  ObservableItem.prototype.__$isObservable = true;
36
-
36
+ const DEFAULT_OPERATIONS = {};
37
37
  const noneTrigger = function() {};
38
38
  ObservableItem.prototype.triggerFirstListener = function(operations) {
39
39
  this.$listeners[0](this.$currentValue, this.$previousValue, operations || {});
@@ -1,5 +1,6 @@
1
1
  import Validator from "../../utils/validator";
2
2
  import {Observable} from "../Observable";
3
+ import ObservableItem from "../ObservableItem";
3
4
 
4
5
  /**
5
6
  *
@@ -10,14 +11,6 @@ Observable.init = function(initialValue) {
10
11
  const data = {};
11
12
  for(const key in initialValue) {
12
13
  const itemValue = initialValue[key];
13
- if(Validator.isJson(itemValue)) {
14
- data[key] = Observable.init(itemValue);
15
- continue;
16
- }
17
- else if(Validator.isArray(itemValue)) {
18
- data[key] = Observable.array(itemValue);
19
- continue;
20
- }
21
14
  data[key] = Observable(itemValue);
22
15
  }
23
16
 
@@ -36,7 +29,7 @@ Observable.init = function(initialValue) {
36
29
  return result;
37
30
  };
38
31
  const $clone = function() {
39
-
32
+ return Observable.init($val());
40
33
  };
41
34
  const $updateWith = function(values) {
42
35
  Observable.update(proxy, values);
@@ -23,7 +23,7 @@ export default function Anchor(name, isUniqueChild = false) {
23
23
  parent.nativeInsertBefore(element, target);
24
24
  return;
25
25
  }
26
- if(isParentUniqueChild(parent) || target === anchorEnd) {
26
+ if(isParentUniqueChild(parent) && target === anchorEnd) {
27
27
  parent.append(element, target);
28
28
  return;
29
29
  }
@@ -75,11 +75,11 @@ export default function Anchor(name, isUniqueChild = false) {
75
75
  return;
76
76
  }
77
77
  if(isParentUniqueChild(parent)) {
78
- parent.replaceChildren(anchorEnd, anchorEnd);
78
+ parent.replaceChildren(anchorStart, anchorEnd);
79
79
  return;
80
80
  }
81
81
  let itemToRemove = anchorStart.nextSibling, tempItem;
82
- while(itemToRemove !== anchorEnd) {
82
+ while(itemToRemove && itemToRemove !== anchorEnd) {
83
83
  tempItem = itemToRemove.nextSibling;
84
84
  element.nativeAppendChild(itemToRemove);
85
85
  itemToRemove = tempItem;
@@ -129,6 +129,9 @@ export default function AttributesWrapper(element, attributes) {
129
129
  for(let key in attributes) {
130
130
  const attributeName = key.toLowerCase();
131
131
  let value = attributes[attributeName];
132
+ if(value === null || value === undefined) {
133
+ continue;
134
+ }
132
135
  if(Validator.isString(value)) {
133
136
  value = value.resolveObservableTemplate ? value.resolveObservableTemplate() : value;
134
137
  if(Validator.isString(value)) {