native-document 1.0.68 → 1.0.69
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.
- package/dist/native-document.dev.js +478 -59
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.devtools.min.js +1 -1
- package/dist/native-document.min.js +1 -1
- package/package.json +1 -1
- package/src/data/ObservableArray.js +67 -1
- package/src/data/ObservableItem.js +3 -1
- package/src/data/observable-helpers/array.js +1 -1
- package/src/utils/filters/date.js +95 -0
- package/src/utils/filters/index.js +4 -0
- package/src/utils/filters/standard.js +137 -0
- package/src/utils/filters/strings.js +35 -0
- package/src/utils/filters/utils.js +41 -0
- package/types/observable.d.ts +1 -1
- package/utils.js +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var NativeDocumentDevTools=function(){"use strict";let e={};e={log(){},warn(){},error(){},disable(){}};var t=e;const n=function(){let e=0;const n=new Map;return{register(t){const r=++e;return n.set(r,new WeakRef(t)),r},unregister(e){n.delete(e)},getObservableById:e=>n.get(e)?.deref(),cleanup(){for(const[e,t]of n){const e=t.deref();e&&e.cleanup()}n.clear()},cleanObservables(e){if(n.size<e)return;let r=0;for(const[e,t]of n)t.deref()||(n.delete(e),r++);r>0&&t.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}();class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const i=function(){const e=new Map,n=new Map;return{list:()=>n,add(t,r){if(!t||"object"!=typeof t)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||t.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){t.$name=r,e.set(r,t),"function"==typeof t?.init&&t.init();for(const e in t)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");n.has(r)||n.set(r,new Set),n.get(r).add(t)}}},remove(t){if(!e.has(t))return;const r=e.get(t);"function"==typeof r.cleanup&&r.cleanup();for(const[e,t]of n.entries())t.has(r)&&t.delete(r),0===t.size&&n.delete(e);e.delete(t)},emit(e,...r){if(!n.has(e))return;const o=n.get(e);for(const n of o){const o=n["on"+e];if("function"==typeof o)try{o.call(n,...r)}catch(r){t.error("Plugin Manager",`Error in plugin ${n.$name} for event ${e}`,r)}}}}}(),s=function(e,t){this.$target=t,this.$observer=e};s.prototype.__$isObservableWhen=!0,s.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},s.prototype.val=function(){return this.$observer.$currentValue===this.$target},s.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},s.prototype.isActive=function(){return this.$observer.$currentValue===this.$target};const l=(e,t)=>{if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>l(e));if(x.isObservable(e))return t&&t(e),e;const n={};for(const t in e)e.hasOwnProperty(t)&&(n[t]=l(e[t]));return n};function a(e,t=null){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=x.isObject(e)?l(e):e)),i.emit("CreateObservable",this)}Object.defineProperty(a.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),a.prototype.__$isObservable=!0;const u={},c=function(){};a.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},a.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||u;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const p=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};a.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);p(t,!0)}if(e.has(t)){const n=e.get(t);p(n,!1)}},a.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},a.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},a.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},a.prototype.trigger=c,a.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))},a.prototype.val=function(){return this.$currentValue},a.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)x.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},a.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},a.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)}},a.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!x.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()}},a.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},a.prototype.check=function(e){return new o(this,e)},a.prototype.get=function(e){const t=this.$currentValue[e];return x.isObservable(t)?t.val():t},a.prototype.when=function(e){return new s(this,e)},a.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"},a.prototype.equals=function(e){return x.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},a.prototype.toBool=function(){return!!this.$currentValue},a.prototype.toggle=function(){this.set(!this.$currentValue)},a.prototype.reset=function(){if(!this.configs?.reset)return;const e=x.isObject(this.$initialValue)?l(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)};const d={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=d.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))},executeUnmountedCallback(e){const t=d.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))},checkMutation:function(e){for(const t of e){if(d.mountedSupposedSize>0)for(const e of t.addedNodes){if(d.executeMountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-mounted]");if(!t.length)return;for(const e of t)d.executeMountedCallback(e)}if(d.unmountedSupposedSize>0)for(const e of t.removedNodes){if(d.executeUnmountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-unmounted]");if(!t.length)return;for(const e of t)d.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{d.mounted.delete(e),d.unmounted.delete(e),d.mountedSupposedSize--,d.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,d.mounted.set(e,n),d.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,d.unmounted.set(e,n),d.unmountedSupposedSize++}}}};d.observer=new MutationObserver(d.checkMutation),d.observer.observe(document.body,{childList:!0,subtree:!0});const h=["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 f(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}f.prototype.__$isNDElement=!0,f.prototype.valueOf=function(){return this.$element},f.prototype.ref=function(e,t){return e[t]=this.$element,this},f.prototype.refSelf=function(e,t){return e[t]=this,this},f.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},f.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},f.prototype.lifecycle=function(e){return this.$observer=this.$observer||d.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},f.prototype.mounted=function(e){return this.lifecycle({mounted:e})},f.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},f.prototype.htmlElement=function(){return this.$element},f.prototype.node=f.prototype.htmlElement,f.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},f.prototype.openShadow=function(e=null){return this.shadow("open",e)},f.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},f.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const b={},m=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);x.isArray(o)?o.push(n):r.set(e,[store[t],n])},g=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},y=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},v=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},$=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(x.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 h){const t=e.toLowerCase();f.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},f.prototype["onPrevent"+e]=function(e){return g(this.$element,t,e),this},f.prototype["onStop"+e]=function(e){return y(this.$element,t,e),this},f.prototype["onPreventStop"+e]=function(e){return v(this.$element,t,e),this},f.prototype["when"+e]=function(e){return m(this.$element,t,e),this},f.prototype["capture"+e]=function(e){return $(this.$element,t,e),this}}f.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},f.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const n=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!e.hasOwnProperty(o))continue;const i=e[o];if("function"==typeof i){if(n.has(o))throw t.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);f.prototype[o]&&t.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),f.prototype[o]=i}else t.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i.emit("NDElementExtended",e),f};const w=1,O=3,C=8,A=11,x={isObservable:e=>e?.__$isObservable||e instanceof a||e instanceof o,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===w||e.nodeType===O||e.nodeType===A||e.nodeType===C),isFragment:e=>e?.nodeType===A,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 f,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&&(x.isObject(e)&&Object.values(e).some(e=>x.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")}},S=["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"];function E(e,t=null){return new a(e,t)}function V(e,t,n){e.classes.toggle(t,n)}function k(e,t,n){e.style[t]=n}function P(e,t,n){x.isBoolean(n)?e[t]=n:e[t]=n===e.value}function N(e,t,n,r){x.isBoolean(n)?r.set(e[t]):r.set(e.value)}function j(e,t){for(let n in t){const r=t[n];x.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(V.bind(null,e,n))):x.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(V.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function D(e,t){for(let n in t){const r=t[n];x.isObservable(r)?(e.style[n]=r.val(),r.subscribe(k.bind(null,e,n))):e.style[n]=r}}function T(e,t,n){const r=x.isObservable(n)?n.val():n;x.isBoolean(r)?e[t]=r:e[t]=r===e.value,x.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",N.bind(null,e,t,r,n)),n.subscribe(P.bind(null,e,t)))}function _(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}E.useValueProperty=function(e="value"){Object.defineProperty(a.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},E.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},E.cleanup=function(e){e.cleanup()},E.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 M=new Map;let L=null;const B={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=B.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=B.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=B.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(M.has(e))return M.get(e).cloneNode();const t=document.createElement(e);return M.set(e,t),t.cloneNode()}return function(e,n=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),i=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(i),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild;const s=e=>n||e.firstChild===o&&e.lastChild===i,l=function(e,t,n){const o=x.isElement(t)?t:B.getChild(t);e!==r?s(e)&&n===i?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)};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?l(r,e,n=n??i):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;const l=document.createDocumentFragment();for(;n&&n!==i;)t=n.nextSibling,l.append(n),n=t;l.replaceChildren()},r.remove=function(){if(i.parentNode===r)return;let e,t=o.nextSibling;for(;t&&t!==i;)e=t.nextSibling,r.nativeAppendChild(t),t=e},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),i.remove()},r.replaceContent=function(e){const t=x.isElement(e)?e:B.getChild(e),n=i.parentNode;n&&(s(n)?n.replaceChildren(o,t,i):(r.removeChildren(),n.insertBefore(t,i)))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return i},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}("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(x.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,x.isString(e)))return B.createStaticTextNode(null,e);if(x.isElement(e))return e;if(x.isObservable(e))return B.createObservableNode(null,e);if(x.isNDElement(e))return e.$element??e.$build?.()??null;if(x.$element)return x.$element;if(x.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 x.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?B.createHydratableNode(null,e):B.createStaticTextNode(null,e)},processAttributes(e,t){x.isFragment(e)||t&&function(e,t){if(!x.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(x.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,x.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>x.isObservable(e));o=E.computed(()=>o.map(e=>x.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&x.isObject(o)?j(e,o):"style"===r&&x.isObject(o)?D(e,o):S.includes(r)?T(e,r,o):x.isObservable(o)?_(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)};const I={configurable:!0,get(){return new f(this)}};Object.defineProperty(HTMLElement.prototype,"nd",I),Object.defineProperty(DocumentFragment.prototype,"nd",I),Object.defineProperty(f.prototype,"nd",{configurable:!0,get:function(){return this}});const F={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,...F}}});function z(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!x.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=B.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&B.processAttributes(l,o),i&&B.processChildren(i,l),B.setup(l,o,t)}function W(e,t){return z.bind(null,e.toLowerCase(),t)}const U=W("div");W("span"),W("label"),W("p"),W("strong"),W("h1"),W("h2"),W("h3"),W("h4"),W("h5"),W("h6"),W("br"),W("a"),W("pre"),W("code"),W("blockquote"),W("hr"),W("em"),W("small"),W("mark"),W("del"),W("ins"),W("sub"),W("sup"),W("abbr"),W("cite"),W("q"),W("dl"),W("dt"),W("dd"),W("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}),W("input"),W("textarea"),W("select"),W("fieldset"),W("option"),W("legend"),W("datalist"),W("output"),W("progress"),W("meter");const q=W("button");W("main"),W("section"),W("article"),W("aside"),W("nav"),W("figure"),W("figcaption"),W("header"),W("footer"),W("img"),W("details"),W("summary"),W("dialog"),W("menu"),W("ol"),W("ul"),W("li"),W("audio"),W("video"),W("source"),W("track"),W("canvas"),W("svg"),W("time"),W("data"),W("address"),W("kbd"),W("samp"),W("var"),W("wbr"),W("caption"),W("table"),W("thead"),W("tfoot"),W("tbody"),W("tr"),W("th"),W("td"),W(""),Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new f(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 E.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return x.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return x.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!x.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return E.getById(n)}):this.valueOf()};const R=function(e,t){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");a.call(this,e,t),i.emit("CreateObservableArray",this)};(R.prototype=Object.create(a.prototype)).__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{R.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{R.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),R.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},R.prototype.at=function(e){return this.$currentValue[e]},R.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},R.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},R.prototype.length=function(){return this.$currentValue.length},R.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],i=n[t];return n[e]=i,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,i]}),!0},R.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},R.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},R.prototype.isEmpty=function(){return 0===this.$currentValue.length},R.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},E.array=function(e,t=null){return new R(e,t)},E.batch=function(e){const t=E(0),n=function(){if(x.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};E.init=function(e,t=null){const n={};for(const r in e){const o=e[r];if(Array.isArray(o)){if(!1!==t?.deep){const e=o.map(e=>x.isJson(e)?E.json(e,t):x.isArray(e)?E.array(e,t):E(e,t));n[r]=E.array(e,t);continue}n[r]=E.array(o,t)}else x.isObservable(o)||x.isProxy(o)?n[r]=o:n[r]=E(o,t)}const r=()=>{for(const e in n){n[e].reset()}},o=()=>function(e){const t={};for(const n in e){const r=e[n];if(x.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>x.isObservable(e)?e.val():x.isProxy(e)?e.$value:e)),t[n]=e}else x.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(n),i=()=>E.init(o(),t),s=e=>{E.update(a,e)},l=e=>function(e,t){const n=e[t];return x.isObservable(n)?n.val():x.isProxy(n)?n.$value:n}(n,e),a=new Proxy(n,{get:(n,a)=>"__isProxy__"===a||("$value"===a?o():"get"===a||"$get"===a?l:"val"===a||"$val"===a?o:"set"===a||"$set"===a||"$updateWith"===a?s:"observables"===a||"$observables"===a?Object.values(n):"keys"===a||"$keys"===a?Object.keys(e):"clone"===a||"$clone"===a?i:"reset"===a?r:"configs"===a?t:n[a]),set:(e,t,n)=>void 0===e[t]||(x.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return a},E.arrayOfObject=function(e){return e.map(e=>E.object(e))},E.value=function(e){if(x.isObservable(e))return e.val();if(x.isProxy(e))return e.$value;if(x.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(E.value(r))}return t}return e},E.update=function(e,t){const n=x.isProxy(t)?t.$value:t,r=e.configs;for(const o in n){const i=e[o],s=t[o],l=n[o];if(x.isObservable(i)){if(x.isArray(l)){const e=s.at(0);if(x.isObservable(e)||x.isProxy(e)){const t=l.map(t=>x.isProxy(e)?E.init(t,r):E(t,r));i.set(t);continue}i.set([...l]);continue}i.set(l)}else x.isProxy(i)?E.update(i,l):e[o]=l}},E.object=E.init,E.json=E.init,E.computed=function(e,t=[]){const n=new a(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),x.isFunction(t)){if(!x.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{x.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const H={createdObservable:E(0)},J={name:"DevTools",onCreateObservable(e){H.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function K(){let e=!1;const t=U({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[U({class:"widget-label"},H.createdObservable),q({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=U(U({class:"devtools-app-panel-wrapper pin-to-right"},[K,U({class:"devtools-app-panel"}),U("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:J}}();
|
|
1
|
+
var NativeDocumentDevTools=function(){"use strict";let e={};e={log(){},warn(){},error(){},disable(){}};var t=e;const n=function(){let e=0;const n=new Map;return{register(t){const r=++e;return n.set(r,new WeakRef(t)),r},unregister(e){n.delete(e)},getObservableById:e=>n.get(e)?.deref(),cleanup(){for(const[e,t]of n){const e=t.deref();e&&e.cleanup()}n.clear()},cleanObservables(e){if(n.size<e)return;let r=0;for(const[e,t]of n)t.deref()||(n.delete(e),r++);r>0&&t.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}();class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const i=function(){const e=new Map,n=new Map;return{list:()=>n,add(t,r){if(!t||"object"!=typeof t)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||t.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){t.$name=r,e.set(r,t),"function"==typeof t?.init&&t.init();for(const e in t)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");n.has(r)||n.set(r,new Set),n.get(r).add(t)}}},remove(t){if(!e.has(t))return;const r=e.get(t);"function"==typeof r.cleanup&&r.cleanup();for(const[e,t]of n.entries())t.has(r)&&t.delete(r),0===t.size&&n.delete(e);e.delete(t)},emit(e,...r){if(!n.has(e))return;const o=n.get(e);for(const n of o){const o=n["on"+e];if("function"==typeof o)try{o.call(n,...r)}catch(r){t.error("Plugin Manager",`Error in plugin ${n.$name} for event ${e}`,r)}}}}}(),s=function(e,t){this.$target=t,this.$observer=e};s.prototype.__$isObservableWhen=!0,s.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},s.prototype.val=function(){return this.$observer.$currentValue===this.$target},s.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},s.prototype.isActive=function(){return this.$observer.$currentValue===this.$target};const l=(e,t)=>{if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>l(e));if(x.isObservable(e))return t&&t(e),e;const n={};for(const t in e)e.hasOwnProperty(t)&&(n[t]=l(e[t]));return n};function a(e,t=null){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=x.isObject(e)?l(e):e)),i.emit("CreateObservable",this)}Object.defineProperty(a.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),a.prototype.__$isObservable=!0;const u={},c=function(){};a.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},a.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||u;for(let o=0,i=t.length;o<i;o++)t[o],t[o](r,n,e)};const p=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};a.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);p(t,!0)}if(e.has(t)){const n=e.get(t);p(n,!1)}},a.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},a.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},a.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},a.prototype.trigger=c,a.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))},a.prototype.val=function(){return this.$currentValue},a.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)x.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},a.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},a.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)}},a.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!x.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()}},a.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},a.prototype.check=function(e){return new o(this,e)},a.prototype.get=function(e){const t=this.$currentValue[e];return x.isObservable(t)?t.val():t},a.prototype.when=function(e){return new s(this,e)},a.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"},a.prototype.equals=function(e){return x.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},a.prototype.toBool=function(){return!!this.$currentValue},a.prototype.toggle=function(){this.set(!this.$currentValue)},a.prototype.reset=function(){if(!this.configs?.reset)return;const e=x.isObject(this.$initialValue)?l(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)};const d={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=d.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))},executeUnmountedCallback(e){const t=d.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))},checkMutation:function(e){for(const t of e){if(d.mountedSupposedSize>0)for(const e of t.addedNodes){if(d.executeMountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-mounted]");if(!t.length)return;for(const e of t)d.executeMountedCallback(e)}if(d.unmountedSupposedSize>0)for(const e of t.removedNodes){if(d.executeUnmountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-unmounted]");if(!t.length)return;for(const e of t)d.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{d.mounted.delete(e),d.unmounted.delete(e),d.mountedSupposedSize--,d.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,d.mounted.set(e,n),d.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,d.unmounted.set(e,n),d.unmountedSupposedSize++}}}};d.observer=new MutationObserver(d.checkMutation),d.observer.observe(document.body,{childList:!0,subtree:!0});const h=["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 f(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}f.prototype.__$isNDElement=!0,f.prototype.valueOf=function(){return this.$element},f.prototype.ref=function(e,t){return e[t]=this.$element,this},f.prototype.refSelf=function(e,t){return e[t]=this,this},f.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},f.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},f.prototype.lifecycle=function(e){return this.$observer=this.$observer||d.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},f.prototype.mounted=function(e){return this.lifecycle({mounted:e})},f.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},f.prototype.htmlElement=function(){return this.$element},f.prototype.node=f.prototype.htmlElement,f.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},f.prototype.openShadow=function(e=null){return this.shadow("open",e)},f.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},f.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const b={},m=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);x.isArray(o)?o.push(n):r.set(e,[store[t],n])},g=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},y=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},v=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},$=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(x.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 h){const t=e.toLowerCase();f.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},f.prototype["onPrevent"+e]=function(e){return g(this.$element,t,e),this},f.prototype["onStop"+e]=function(e){return y(this.$element,t,e),this},f.prototype["onPreventStop"+e]=function(e){return v(this.$element,t,e),this},f.prototype["when"+e]=function(e){return m(this.$element,t,e),this},f.prototype["capture"+e]=function(e){return $(this.$element,t,e),this}}f.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},f.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const n=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!e.hasOwnProperty(o))continue;const i=e[o];if("function"==typeof i){if(n.has(o))throw t.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);f.prototype[o]&&t.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),f.prototype[o]=i}else t.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i.emit("NDElementExtended",e),f};const w=1,O=3,C=8,A=11,x={isObservable:e=>e?.__$isObservable||e instanceof a||e instanceof o,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===w||e.nodeType===O||e.nodeType===A||e.nodeType===C),isFragment:e=>e?.nodeType===A,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 f,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&&(x.isObject(e)&&Object.values(e).some(e=>x.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")}},S=["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"];function E(e,t=null){return new a(e,t)}function k(e,t,n){e.classes.toggle(t,n)}function V(e,t,n){e.style[t]=n}function P(e,t,n){x.isBoolean(n)?e[t]=n:e[t]=n===e.value}function j(e,t,n,r){x.isBoolean(n)?r.set(e[t]):r.set(e.value)}function N(e,t){for(let n in t){const r=t[n];x.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(k.bind(null,e,n))):x.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(k.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function D(e,t){for(let n in t){const r=t[n];x.isObservable(r)?(e.style[n]=r.val(),r.subscribe(V.bind(null,e,n))):e.style[n]=r}}function _(e,t,n){const r=x.isObservable(n)?n.val():n;x.isBoolean(r)?e[t]=r:e[t]=r===e.value,x.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",j.bind(null,e,t,r,n)),n.subscribe(P.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))}E.useValueProperty=function(e="value"){Object.defineProperty(a.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},E.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},E.cleanup=function(e){e.cleanup()},E.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 M=new Map;let L=null;const B={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=B.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=B.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=B.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(M.has(e))return M.get(e).cloneNode();const t=document.createElement(e);return M.set(e,t),t.cloneNode()}return function(e,n=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),i=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(i),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild;const s=e=>n||e.firstChild===o&&e.lastChild===i,l=function(e,t,n){const o=x.isElement(t)?t:B.getChild(t);e!==r?s(e)&&n===i?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)};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?l(r,e,n=n??i):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;const l=document.createDocumentFragment();for(;n&&n!==i;)t=n.nextSibling,l.append(n),n=t;l.replaceChildren()},r.remove=function(){if(i.parentNode===r)return;let e,t=o.nextSibling;for(;t&&t!==i;)e=t.nextSibling,r.nativeAppendChild(t),t=e},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),i.remove()},r.replaceContent=function(e){const t=x.isElement(e)?e:B.getChild(e),n=i.parentNode;n&&(s(n)?n.replaceChildren(o,t,i):(r.removeChildren(),n.insertBefore(t,i)))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return i},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}("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(x.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,x.isString(e)))return B.createStaticTextNode(null,e);if(x.isElement(e))return e;if(x.isObservable(e))return B.createObservableNode(null,e);if(x.isNDElement(e))return e.$element??e.$build?.()??null;if(x.$element)return x.$element;if(x.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 x.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?B.createHydratableNode(null,e):B.createStaticTextNode(null,e)},processAttributes(e,t){x.isFragment(e)||t&&function(e,t){if(!x.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(x.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,x.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>x.isObservable(e));o=E.computed(()=>o.map(e=>x.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&x.isObject(o)?N(e,o):"style"===r&&x.isObject(o)?D(e,o):S.includes(r)?_(e,r,o):x.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)};const I={configurable:!0,get(){return new f(this)}};Object.defineProperty(HTMLElement.prototype,"nd",I),Object.defineProperty(DocumentFragment.prototype,"nd",I),Object.defineProperty(f.prototype,"nd",{configurable:!0,get:function(){return this}});const F={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,...F}}});function z(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!x.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=B.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&B.processAttributes(l,o),i&&B.processChildren(i,l),B.setup(l,o,t)}function W(e,t){return z.bind(null,e.toLowerCase(),t)}const U=W("div");W("span"),W("label"),W("p"),W("strong"),W("h1"),W("h2"),W("h3"),W("h4"),W("h5"),W("h6"),W("br"),W("a"),W("pre"),W("code"),W("blockquote"),W("hr"),W("em"),W("small"),W("mark"),W("del"),W("ins"),W("sub"),W("sup"),W("abbr"),W("cite"),W("q"),W("dl"),W("dt"),W("dd"),W("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}),W("input"),W("textarea"),W("select"),W("fieldset"),W("option"),W("legend"),W("datalist"),W("output"),W("progress"),W("meter");const q=W("button");function R(e,t){const n=e.filter(x.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>x.isObservable(e)?e.val():e))}}function H(e,t=!0,n=""){return R([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}W("main"),W("section"),W("article"),W("aside"),W("nav"),W("figure"),W("figcaption"),W("header"),W("footer"),W("img"),W("details"),W("summary"),W("dialog"),W("menu"),W("ol"),W("ul"),W("li"),W("audio"),W("video"),W("source"),W("track"),W("canvas"),W("svg"),W("time"),W("data"),W("address"),W("kbd"),W("samp"),W("var"),W("wbr"),W("caption"),W("table"),W("thead"),W("tfoot"),W("tbody"),W("tr"),W("th"),W("td"),W(""),Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new f(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 E.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return x.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return x.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!x.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return E.getById(n)}):this.valueOf()};const J=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");a.call(this,e,t),i.emit("CreateObservableArray",this)};(J.prototype=Object.create(a.prototype)).__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{J.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{J.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),J.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},J.prototype.at=function(e){return this.$currentValue[e]},J.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},J.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},J.prototype.length=function(){return this.$currentValue.length},J.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],i=n[t];return n[e]=i,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,i]}),!0},J.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},J.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},J.prototype.isEmpty=function(){return 0===this.$currentValue.length},J.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},J.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=x.isObservable(o)?H(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push(...t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=Observable.array(),i=Object.entries(r),s=()=>{const e=t.val().filter(e=>{for(const[t,n]of i)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(s)),s(),o},J.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},J.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},E.array=function(e=[],t=null){return new J(e,t)},E.batch=function(e){const t=E(0),n=function(){if(x.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};E.init=function(e,t=null){const n={};for(const r in e){const o=e[r];if(Array.isArray(o)){if(!1!==t?.deep){const e=o.map(e=>x.isJson(e)?E.json(e,t):x.isArray(e)?E.array(e,t):E(e,t));n[r]=E.array(e,t);continue}n[r]=E.array(o,t)}else x.isObservable(o)||x.isProxy(o)?n[r]=o:n[r]=E(o,t)}const r=()=>{for(const e in n){n[e].reset()}},o=()=>function(e){const t={};for(const n in e){const r=e[n];if(x.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>x.isObservable(e)?e.val():x.isProxy(e)?e.$value:e)),t[n]=e}else x.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(n),i=()=>E.init(o(),t),s=e=>{E.update(a,e)},l=e=>function(e,t){const n=e[t];return x.isObservable(n)?n.val():x.isProxy(n)?n.$value:n}(n,e),a=new Proxy(n,{get:(n,a)=>"__isProxy__"===a||("$value"===a?o():"get"===a||"$get"===a?l:"val"===a||"$val"===a?o:"set"===a||"$set"===a||"$updateWith"===a?s:"observables"===a||"$observables"===a?Object.values(n):"keys"===a||"$keys"===a?Object.keys(e):"clone"===a||"$clone"===a?i:"reset"===a?r:"configs"===a?t:n[a]),set:(e,t,n)=>void 0===e[t]||(x.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return a},E.arrayOfObject=function(e){return e.map(e=>E.object(e))},E.value=function(e){if(x.isObservable(e))return e.val();if(x.isProxy(e))return e.$value;if(x.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(E.value(r))}return t}return e},E.update=function(e,t){const n=x.isProxy(t)?t.$value:t,r=e.configs;for(const o in n){const i=e[o],s=t[o],l=n[o];if(x.isObservable(i)){if(x.isArray(l)){const e=s.at(0);if(x.isObservable(e)||x.isProxy(e)){const t=l.map(t=>x.isProxy(e)?E.init(t,r):E(t,r));i.set(t);continue}i.set([...l]);continue}i.set(l)}else x.isProxy(i)?E.update(i,l):e[o]=l}},E.object=E.init,E.json=E.init,E.computed=function(e,t=[]){const n=new a(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),x.isFunction(t)){if(!x.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{x.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const K={createdObservable:E(0)},G={name:"DevTools",onCreateObservable(e){K.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function X(){let e=!1;const t=U({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[U({class:"widget-label"},K.createdObservable),q({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=U(U({class:"devtools-app-panel-wrapper pin-to-right"},[X,U({class:"devtools-app-panel"}),U("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:G}}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var NativeDocument=function(t){"use strict";let n={};n={log(){},warn(){},error(){},disable(){}};var r=n;const o=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let n=0;for(const[e,r]of t)r.deref()||(t.delete(e),n++);n>0&&r.log("Memory Auto Clean",`🧹 Cleaned ${n} orphaned observables`)}}}();class s extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function i(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}i.prototype.__$isObservableChecker=!0,i.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},i.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},i.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},i.prototype.set=function(e){return this.observable.set(e)},i.prototype.trigger=function(){return this.observable.trigger()},i.prototype.cleanup=function(){return this.observable.cleanup()};const a=function(){const e=new Map,t=new Map;return{list:()=>t,add(n,r){if(!n||"object"!=typeof n)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||n.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){n.$name=r,e.set(r,n),"function"==typeof n?.init&&n.init();for(const e in n)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");t.has(r)||t.set(r,new Set),t.get(r).add(n)}}},remove(n){if(!e.has(n))return;const r=e.get(n);"function"==typeof r.cleanup&&r.cleanup();for(const[e,n]of t.entries())n.has(r)&&n.delete(r),0===n.size&&t.delete(e);e.delete(n)},emit(e,...n){if(!t.has(e))return;const o=t.get(e);for(const t of o){const o=t["on"+e];if("function"==typeof o)try{o.call(t,...n)}catch(n){r.error("Plugin Manager",`Error in plugin ${t.$name} for event ${e}`,n)}}}}}(),u=function(e,t){this.$target=t,this.$observer=e};u.prototype.__$isObservableWhen=!0,u.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},u.prototype.val=function(){return this.$observer.$currentValue===this.$target},u.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},u.prototype.isActive=function(){return this.$observer.$currentValue===this.$target};const l=(e,t,n)=>{if(N.isFunction(n))return n(e,t);if(N.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return N.isObject(e)?e[n]?.val?.()??e[n]??t:e},c=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},h=(e,t)=>{if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>h(e));if(N.isObservable(e))return t&&t(e),e;const n={};for(const t in e)e.hasOwnProperty(t)&&(n[t]=h(e[t]));return n};function p(e,t=null){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=N.isObject(e)?h(e):e)),a.emit("CreateObservable",this)}Object.defineProperty(p.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),p.prototype.__$isObservable=!0;const d={},f=function(){};p.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},p.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||d;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)};const b=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};p.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);b(t,!0)}if(e.has(t)){const n=e.get(t);b(n,!1)}},p.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},p.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},p.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=f},p.prototype.trigger=f,p.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))},p.prototype.val=function(){return this.$currentValue},p.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)N.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=f},p.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},p.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)}},p.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!N.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()}},p.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},p.prototype.check=function(e){return new i(this,e)},p.prototype.get=function(e){const t=this.$currentValue[e];return N.isObservable(t)?t.val():t},p.prototype.when=function(e){return new u(this,e)},p.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"},p.prototype.equals=function(e){return N.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},p.prototype.toBool=function(){return!!this.$currentValue},p.prototype.toggle=function(){this.set(!this.$currentValue)},p.prototype.reset=function(){if(!this.configs?.reset)return;const e=N.isObject(this.$initialValue)?h(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)};const m={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=m.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))},executeUnmountedCallback(e){const t=m.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))},checkMutation:function(e){for(const t of e){if(m.mountedSupposedSize>0)for(const e of t.addedNodes){if(m.executeMountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-mounted]");if(!t.length)return;for(const e of t)m.executeMountedCallback(e)}if(m.unmountedSupposedSize>0)for(const e of t.removedNodes){if(m.executeUnmountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-unmounted]");if(!t.length)return;for(const e of t)m.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{m.mounted.delete(e),m.unmounted.delete(e),m.mountedSupposedSize--,m.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,m.mounted.set(e,n),m.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,m.unmounted.set(e,n),m.unmountedSupposedSize++}}}};m.observer=new MutationObserver(m.checkMutation),m.observer.observe(document.body,{childList:!0,subtree:!0});const g=["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 y(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}y.prototype.__$isNDElement=!0,y.prototype.valueOf=function(){return this.$element},y.prototype.ref=function(e,t){return e[t]=this.$element,this},y.prototype.refSelf=function(e,t){return e[t]=this,this},y.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},y.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},y.prototype.lifecycle=function(e){return this.$observer=this.$observer||m.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},y.prototype.mounted=function(e){return this.lifecycle({mounted:e})},y.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},y.prototype.htmlElement=function(){return this.$element},y.prototype.node=y.prototype.htmlElement,y.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},y.prototype.openShadow=function(e=null){return this.shadow("open",e)},y.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},y.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const v={},w=function(e,t,n){if(!e)return;if(!v[t]){const r=new WeakMap;return v[t]=r,void r.set(e,n)}const r=v[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);N.isArray(o)?o.push(n):r.set(e,[store[t],n])},$=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},C=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},O=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},S=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=v[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(N.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 g){const t=e.toLowerCase();y.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},y.prototype["onPrevent"+e]=function(e){return $(this.$element,t,e),this},y.prototype["onStop"+e]=function(e){return C(this.$element,t,e),this},y.prototype["onPreventStop"+e]=function(e){return O(this.$element,t,e),this},y.prototype["when"+e]=function(e){return w(this.$element,t,e),this},y.prototype["capture"+e]=function(e){return S(this.$element,t,e),this}}y.prototype.with=function(e){if(!e||"object"!=typeof e)throw new s("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},y.extend=function(e){if(!e||"object"!=typeof e)throw new s("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new s("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const n in e){if(!e.hasOwnProperty(n))continue;const o=e[n];if("function"==typeof o){if(t.has(n))throw r.error("NDElement.extend",`Cannot override protected method "${n}"`),new s(`Cannot override protected method "${n}"`);y.prototype[n]&&r.warn("NDElement.extend",`Overwriting existing prototype method "${n}"`),y.prototype[n]=o}else r.warn("NDElement.extend",`"${n}" is not a function, skipping`)}return a.emit("NDElementExtended",e),y};const A=1,E=3,x=8,k=11,N={isObservable:e=>e?.__$isObservable||e instanceof p||e instanceof i,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof i,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===A||e.nodeType===E||e.nodeType===k||e.nodeType===x),isFragment:e=>e?.nodeType===k,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 y,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&&(N.isObject(e)&&Object.values(e).some(e=>N.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 I(e,t=!1){const n=document.createDocumentFragment();n.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);n.appendChild(o),n.appendChild(s),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild;const i=e=>t||e.firstChild===o&&e.lastChild===s;return n.appendElement=function(e,t=null){const r=o.parentNode,i=t||s;r!==n?r?.insertBefore(e,i):r.nativeInsertBefore(e,i)},n.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,r){const o=N.isElement(t)?t:H.getChild(t);e!==n?i(e)&&r===s?e.append(o,r):e.insertBefore(o,r):e.nativeInsertBefore(o,r)}(o,e,t=t??s):r.error("Anchor","Anchor : parent not found",e)},n.append=function(...e){return n.appendChild(e)},n.removeChildren=function(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;const a=document.createDocumentFragment();for(;r&&r!==s;)t=r.nextSibling,a.append(r),r=t;a.replaceChildren()},n.remove=function(){if(s.parentNode===n)return;let e,t=o.nextSibling;for(;t&&t!==s;)e=t.nextSibling,n.nativeAppendChild(t),t=e},n.removeWithAnchors=function(){n.removeChildren(),o.remove(),s.remove()},n.replaceContent=function(e){const t=N.isElement(e)?e:H.getChild(e),r=s.parentNode;r&&(i(r)?r.replaceChildren(o,t,s):(n.removeChildren(),r.insertBefore(t,s)))},n.setContent=n.replaceContent,n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return s},n.startElement=function(){return o},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},n}const P=["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 T(e,t=null){return new p(e,t)}const D=T,F=T;function V(e,t,n){e.classes.toggle(t,n)}function j(e,t,n){e.style[t]=n}function M(e,t,n){N.isBoolean(n)?e[t]=n:e[t]=n===e.value}function R(e,t,n,r){N.isBoolean(n)?r.set(e[t]):r.set(e.value)}function _(e,t){for(let n in t){const r=t[n];N.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(V.bind(null,e,n))):N.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(V.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function q(e,t){for(let n in t){const r=t[n];N.isObservable(r)?(e.style[n]=r.val(),r.subscribe(j.bind(null,e,n))):e.style[n]=r}}function L(e,t,n){const r=N.isObservable(n)?n.val():n;N.isBoolean(r)?e[t]=r:e[t]=r===e.value,N.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",R.bind(null,e,t,r,n)),n.subscribe(M.bind(null,e,t)))}function B(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))}T.useValueProperty=function(e="value"){Object.defineProperty(p.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},T.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},T.cleanup=function(e){e.cleanup()},T.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{o.cleanup()}),setInterval(()=>o.cleanObservables(r),n)};const W=new Map;let z=null;const H={createTextNode:()=>(z||(z=document.createTextNode("")),z.cloneNode()),createObservableNode(e,t){const n=H.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=H.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=H.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(W.has(e))return W.get(e).cloneNode();const t=document.createElement(e);return W.set(e,t),t.cloneNode()}return I("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(N.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,N.isString(e)))return H.createStaticTextNode(null,e);if(N.isElement(e))return e;if(N.isObservable(e))return H.createObservableNode(null,e);if(N.isNDElement(e))return e.$element??e.$build?.()??null;if(N.$element)return N.$element;if(N.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 N.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?H.createHydratableNode(null,e):H.createStaticTextNode(null,e)},processAttributes(e,t){N.isFragment(e)||t&&function(e,t){if(N.validateAttributes(t),!N.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(N.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,N.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>N.isObservable(e));o=T.computed(()=>o.map(e=>N.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&N.isObject(o)?_(e,o):"style"===r&&N.isObject(o)?q(e,o):P.includes(r)?L(e,r,o):N.isObservable(o)?B(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)},U={configurable:!0,get(){return new y(this)}};Object.defineProperty(HTMLElement.prototype,"nd",U),Object.defineProperty(DocumentFragment.prototype,"nd",U),Object.defineProperty(y.prototype,"nd",{configurable:!0,get:function(){return this}});const K={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,...K}}});let J=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 G=function(e,t=null){if(!N.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},Q=function(e){return N.isObservable(e)?H.createObservableNode(null,e):H.createStaticTextNode(null,e)};function Z(e,t,n,r=null){let{props:o,children:s=null}=G(n,r),i=H.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&H.processAttributes(a,o),s&&H.processChildren(s,a),H.setup(a,o,t)}function X(e,t){return Z.bind(null,e.toLowerCase(),t)}const Y=new WeakMap;function ee(e){let t=null,n=!1;const r=(e,t)=>{const n=Y.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&&H.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){Y.has(n)||Y.set(n,{});const o=Y.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 Q(n[e])}:function(t){return Q(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}function te(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=I("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new y(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 T.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return N.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return N.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!N.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return T.getById(n)}):this.valueOf()};const ne=e=>{let t=null;return new Proxy({},{get:(n,r)=>(null===t&&(t=e()),t[r])})},re=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{if(!t.has(r)){if(e.length>0)return(...n)=>{const o=e(...n);return t.set(r,o),o};t.set(r,e())}return t.get(r)}})},oe=function(e,t){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");p.call(this,e,t),a.emit("CreateObservableArray",this)};(oe.prototype=Object.create(p.prototype)).__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{oe.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{oe.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),oe.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},oe.prototype.at=function(e){return this.$currentValue[e]},oe.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},oe.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},oe.prototype.length=function(){return this.$currentValue.length},oe.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},oe.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},oe.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},oe.prototype.isEmpty=function(){return 0===this.$currentValue.length},oe.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},T.array=function(e,t=null){return new oe(e,t)},T.batch=function(e){const t=T(0),n=function(){if(N.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};T.init=function(e,t=null){const n={};for(const r in e){const o=e[r];if(Array.isArray(o)){if(!1!==t?.deep){const e=o.map(e=>N.isJson(e)?T.json(e,t):N.isArray(e)?T.array(e,t):T(e,t));n[r]=T.array(e,t);continue}n[r]=T.array(o,t)}else N.isObservable(o)||N.isProxy(o)?n[r]=o:n[r]=T(o,t)}const r=()=>{for(const e in n){n[e].reset()}},o=()=>function(e){const t={};for(const n in e){const r=e[n];if(N.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>N.isObservable(e)?e.val():N.isProxy(e)?e.$value:e)),t[n]=e}else N.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(n),s=()=>T.init(o(),t),i=e=>{T.update(u,e)},a=e=>function(e,t){const n=e[t];return N.isObservable(n)?n.val():N.isProxy(n)?n.$value:n}(n,e),u=new Proxy(n,{get:(n,u)=>"__isProxy__"===u||("$value"===u?o():"get"===u||"$get"===u?a:"val"===u||"$val"===u?o:"set"===u||"$set"===u||"$updateWith"===u?i:"observables"===u||"$observables"===u?Object.values(n):"keys"===u||"$keys"===u?Object.keys(e):"clone"===u||"$clone"===u?s:"reset"===u?r:"configs"===u?t:n[u]),set:(e,t,n)=>void 0===e[t]||(N.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return u},T.arrayOfObject=function(e){return e.map(e=>T.object(e))},T.value=function(e){if(N.isObservable(e))return e.val();if(N.isProxy(e))return e.$value;if(N.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(T.value(r))}return t}return e},T.update=function(e,t){const n=N.isProxy(t)?t.$value:t,r=e.configs;for(const o in n){const s=e[o],i=t[o],a=n[o];if(N.isObservable(s)){if(N.isArray(a)){const e=i.at(0);if(N.isObservable(e)||N.isProxy(e)){const t=a.map(t=>N.isProxy(e)?T.init(t,r):T(t,r));s.set(t);continue}s.set([...a]);continue}s.set(a)}else N.isProxy(s)?T.update(s,a):e[o]=a}},T.object=T.init,T.json=T.init,T.computed=function(e,t=[]){const n=new p(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),N.isFunction(t)){if(!N.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{N.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const se=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=T(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=T(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 ie=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!N.isObservable(e)&&!N.isObservableWhenResult(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=I("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=H.getChild(t),N.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},ae=function(e,t,n=!0){if(!N.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=I("Match"),o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=H.getChild(r),N.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.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&o.delete(e),delete t[e]}})},ue=function(e,t,n){if(!N.isObservable(e))throw new s("Toggle : condition must be an Observable");return ae(e,{true:t,false:n})},le=X("div"),ce=X("span"),he=X("label"),pe=X("p"),de=pe,fe=X("strong"),be=X("h1"),me=X("h2"),ge=X("h3"),ye=X("h4"),ve=X("h5"),we=X("h6"),$e=X("br"),Ce=X("a"),Oe=X("pre"),Se=X("code"),Ae=X("blockquote"),Ee=X("hr"),xe=X("em"),ke=X("small"),Ne=X("mark"),Ie=X("del"),Pe=X("ins"),Te=X("sub"),De=X("sup"),Fe=X("abbr"),Ve=X("cite"),je=X("q"),Me=X("dl"),Re=X("dt"),_e=X("dd"),qe=X("form",function(e){return e.submit=function(t){return"function"==typeof t?(e.onSubmit(e=>{e.preventDefault(),t(e)}),e):(this.setAttribute("action",t),e)},e.multipartFormData=function(){return this.setAttribute("enctype","multipart/form-data"),e},e.post=function(t){return this.setAttribute("method","post"),this.setAttribute("action",t),e},e.get=function(e){this.setAttribute("method","get"),this.setAttribute("action",e)},e}),Le=X("input"),Be=X("textarea"),We=Be,ze=X("select"),He=X("fieldset"),Ue=X("option"),Ke=X("legend"),Je=X("datalist"),Ge=X("output"),Qe=X("progress"),Ze=X("meter"),Xe=X("button"),Ye=X("main"),et=X("section"),tt=X("article"),nt=X("aside"),rt=X("nav"),ot=X("figure"),st=X("figcaption"),it=X("header"),at=X("footer"),ut=X("img"),lt=function(e,t){return ut({src:e,...t})},ct=X("details"),ht=X("summary"),pt=X("dialog"),dt=X("menu"),ft=X("ol"),bt=X("ul"),mt=X("li"),gt=mt,yt=ft,vt=bt,wt=X("audio"),$t=X("video"),Ct=X("source"),Ot=X("track"),St=X("canvas"),At=X("svg"),Et=X("time"),xt=X("data"),kt=X("address"),Nt=X("kbd"),It=X("samp"),Pt=X("var"),Tt=X("wbr"),Dt=X("caption"),Ft=X("table"),Vt=X("thead"),jt=X("tfoot"),Mt=X("tbody"),Rt=X("tr"),_t=Rt,qt=X("th"),Lt=qt,Bt=qt,Wt=X("td"),zt=Wt,Ht=X("");var Ut=Object.freeze({__proto__:null,Abbr:Fe,Address:kt,Anchor:I,Article:tt,Aside:nt,AsyncImg:function(e,t,n,r){const o=N.isObservable(e)?e.val():e,i=lt(t||o,n),a=new Image;return a.onload=()=>{N.isFunction(r)&&r(null,i),i.src=N.isObservable(e)?e.val():e},a.onerror=()=>{N.isFunction(r)&&r(new s("Image not found"))},N.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=o,i},Audio:wt,BaseImage:ut,Blockquote:Ae,Br:$e,Button:Xe,Canvas:St,Caption:Dt,Checkbox:e=>Le({type:"checkbox",...e}),Cite:Ve,Code:Se,ColorInput:e=>Le({type:"color",...e}),Data:xt,Datalist:Je,DateInput:e=>Le({type:"date",...e}),DateTimeInput:e=>Le({type:"datetime-local",...e}),Dd:_e,Del:Ie,Details:ct,Dialog:pt,Div:le,Dl:Me,Dt:Re,Em:xe,EmailInput:e=>Le({type:"email",...e}),FieldSet:He,FigCaption:st,Figure:ot,FileInput:e=>Le({type:"file",...e}),Footer:at,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=I("ForEach"),a=i.endElement();i.startElement();let u=new Map,c=null;const h=new Set,p=e=>{if(!o)for(const[t,n]of u.entries()){if(h.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),c&&c.delete(n.keyId)}},d=(e,o)=>{const i=l(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?T(o):null;let r=H.getChild(t(e,n));if(!r)throw new s("ForEach 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=N.isObservable(e)?e.val():e;if(h.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=d(n[e],e);h.add(t)}else for(const e in n){const t=d(n[e],e);h.add(t)}if(0===h.size)return i.removeChildren(),p(),void c?.clear();p(t),c&&0!==c.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(h);Array.from(c);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 h){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),c?.clear(),c=new Set([...h])};return f(),N.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=I("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,c=0;const h=t.length>=2,p=new WeakMap,d=()=>{o.removeChildren(),g(),c=0},f=(e,t)=>p.has(e)?p.get(e):l(e,t,n),b=e=>v(f(e)),m=(e,t=!0)=>{if(e){if(t){const t=e.child;t?.remove(),u.delete(e.keyId)}e.indexObserver?.deref()?.cleanup()}},g=()=>{if(!r.shouldKeepItemsInCache)if(h){for(const[e,t]of u.entries())m(t,!1);u.clear()}else u.clear()},y=(e,n)=>{const r=f(e,n);if(u.has(r)){const e=u.get(r);e.indexObserver?.deref()?.set(n);const t=e.child;if(t)return t;u.delete(r)}const o=h?T(n):null;let i=H.getChild(t(e,o));if(!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}),p.set(e,r),i},v=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(m(t,!1),null)},w=function(e,t){const n=u.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},$={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(y(e[t],c)),c++;return n},add(e,t=2){const n=$.toFragment(e);setTimeout(()=>{o.appendElement(n)},t)},replace(e){d(),$.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=b(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{m(u.get(e),t)})(f(e,t),!0)},clear:d,merge(e){$.add(e)},push(e){let t=0;r.pushDelay&&(t=r.pushDelay(e)??0),$.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(y(t,o)),c++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore($.toFragment(e),a.nextSibling)},splice(e,t){const[n,r,...s]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=f(t[0],n);if(1===t.length)w(e,u);else if(t.length>1){const r=v(e);a=r?.previousSibling;for(let e=0;e<t.length;e++){const r=f(t[e],n+e);w(r,u)}}}else a=i;u.replaceChildren(),s&&s.length&&a&&o.insertBefore($.toFragment(s),a.nextSibling)},reverse(e,t){$.reOrder(t)},sort(e,t){$.reOrder(t)},remove(e,t){$.removeOne(t)},pop(e,t){$.removeOne(t)},shift(e,t){$.removeOne(t)},swap(e,t){const n=i.parentNode;let r=b(t[0]),o=b(t[1]);if(!r||!o)return;const s=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,s),r=null,o=null}},C=(e,t,n)=>{if("clear"!==n.action&&e.length){if(n?.action)$[n.action]&&$[n.action](n.args,n.result);else{if(0===c)return void $.add(e);$.replace(e)}((e,t=0)=>{if(!h)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===c)return;d()}};return e.val().length&&C(e.val(),0,{action:null}),N.isObservable(e)&&e.subscribe(C),o},Form:qe,Fragment:Ht,H1:be,H2:me,H3:ge,H4:ye,H5:ve,H6:we,Header:it,HiddenInput:e=>Le({type:"hidden",...e}),HideIf:function(e,t,n){const r=T(!e.val());return e.subscribe(e=>r.set(!e)),ie(r,t,n)},HideIfNot:function(e,t,n){return ie(e,t,n)},Hr:Ee,Img:lt,Input:Le,Ins:Pe,Kbd:Nt,Label:he,LazyImg:function(e,t){return lt(e,{...t,loading:"lazy"})},Legend:Ke,Li:gt,Link:Ce,ListItem:mt,Main:Ye,Mark:Ne,Match:ae,Menu:dt,Meter:Ze,MonthInput:e=>Le({type:"month",...e}),NativeDocumentFragment:I,Nav:rt,NumberInput:e=>Le({type:"number",...e}),Ol:yt,Option:Ue,OrderedList:ft,Output:Ge,P:pe,Paragraph:de,PasswordInput:e=>Le({type:"password",...e}),Pre:Oe,Progress:Qe,Quote:je,Radio:e=>Le({type:"radio",...e}),RangeInput:e=>Le({type:"range",...e}),ReadonlyInput:e=>Le({readonly:!0,...e}),Samp:It,SearchInput:e=>Le({type:"search",...e}),Section:et,Select:ze,ShowIf:ie,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!N.isObservableWhenResult(e))throw new s("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return ie(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!N.isObservable(e))throw new s("showWhen observer must be an Observable",{data:e});return ie(e.when(t),n)}throw new s("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Xe(e,{type:"button",...t}),Small:ke,Source:Ct,Span:ce,Strong:fe,Sub:Te,SubmitButton:(e,t)=>Xe(e,{type:"submit",...t}),Summary:ht,Sup:De,Svg:At,Switch:ue,TBody:Mt,TBodyCell:zt,TFoot:jt,TFootCell:Bt,THead:Vt,THeadCell:Lt,TRow:_t,Table:Ft,Td:Wt,TelInput:e=>Le({type:"tel",...e}),TextArea:Be,TextInput:We,Th:qt,Time:Et,TimeInput:e=>Le({type:"time",...e}),Tr:Rt,Track:Ot,Ul:vt,UnorderedList:bt,UrlInput:e=>Le({type:"url",...e}),Var:Pt,Video:$t,Wbr:Tt,WeekInput:e=>Le({type:"week",...e}),When:function(e){if(!N.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,ue(e,t,n))}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=I("Portal "+n);return r.appendChild(H.getChild(e)),(t||document.body).appendChild(r),r}});const Kt={};function Jt(e,t,n={}){e="/"+c(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u=n.layout||null,l={},h=[],p=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=Kt[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},d=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=p(t);return n&&n.pattern?(l[n.name]=n.pattern,h.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+c(e,"/");if(!d().exec(e))return!1;const t={};return d().exec(e).forEach((e,n)=>{if(n<1)return;const r=h[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=p(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class Gt extends Error{constructor(e,t){super(e),this.context=t}}const Qt=(e,t)=>{const n=[];return e.forEach(e=>{n.push(c(e.suffix,"/"))}),n.push(c(t,"/")),n.join("/")},Zt=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Xt=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Yt=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function en(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function tn(){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 nn(){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 rn="default";function on(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)en.apply(this,[]);else if("history"===e.mode)tn.apply(this,[]);else{if("memory"!==e.mode)throw new Gt("Invalid router mode "+e.mode);nn.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 Jt(Qt(o,e),r,{...s,middlewares:Zt(o,s?.middlewares||[]),name:s?.name?Xt(o,s.name):null,layout:s?.layout||Yt(o)});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!N.isFunction(n))throw new Gt("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 Gt(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(N.isJson(e)){const t=n[e.name];if(!t)throw new Gt(`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="/"+c(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Gt(`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(!N.isFunction(e))throw new Gt("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 sn(e,t){const{to:n,href:r,...o}=e,s=n||r;if(N.isString(s)){const e=on.get();return Ce({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||rn,a=on.get(i);if(!a)throw new Gt('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ce({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}on.routers={},on.create=function(t,n){if(!N.isFunction(n))throw r.error("Router","Callback must be a function",e),new Gt("Callback must be a function");const o=new on(t);return on.routers[t.name||rn]=o,n(o),o.init(t.entry),o.mount=function(e){if(N.isString(e)){const t=document.querySelector(e);if(!t)throw new Gt(`Container not found for selector: ${e}`);e=t}else if(!N.isElement(e))throw new Gt("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e,n){t.innerHTML="";const r=n.layout();r?t.appendChild(r(e)):t.appendChild(e)},o=function(e){if(!e.route)return;const{route:t,params:o,query:s,path:i}=e;if(n.has(i)){const e=n.get(i);return void r(e,t)}const a=t.component()({params:o,query:s});n.set(i,a),r(a,t)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},on.get=function(e){const t=on.routers[e||rn];if(!t)throw new Gt(`Router not found for name: ${e}`);return t},on.push=function(e,t=null){return on.get(t).push(e)},on.replace=function(e,t=null){return on.get(t).replace(e)},on.forward=function(e=null){return on.get(e).forward()},on.back=function(e=null){return on.get(e).back()},sn.blank=function(e,t){return Ce({...e,target:"_blank"},t)};var an=Object.freeze({__proto__:null,Link:sn,RouteParamPatterns:Kt,Router:on});const un={once:e=>ne(e),memoize:e=>re(e)};var ln=Object.freeze({__proto__:null,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};o&&(o instanceof FormData?i.body=o:(i.headers["Content-Type"]="application/json","GET"!==n?i.body=JSON.stringify(o):i.params=o));for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const u=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(u?.message||a.statusText);throw e.status=a.status,e.data=u,e}return u},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},Service:un});return t.$=D,t.ElementCreator=H,t.HtmlElementWrapper=X,t.NDElement=y,t.Observable=T,t.PluginsManager=a,t.SingletonView=te,t.Store=se,t.TemplateCloner=ee,t.Validator=N,t.autoMemoize=re,t.autoOnce=ne,t.classPropertyAccumulator=function(e=[]){let t=N.isString(e)?e.split(" ").filter(Boolean):e;const n=N.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=Q,t.cssPropertyAccumulator=function(e={}){let t=N.isString(e)?e.split(";").filter(Boolean):e;const n=N.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=Ut,t.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n;return t.has(r)||t.set(r,e(...o)),t.get(r)}},t.normalizeComponentArgs=G,t.obs=F,t.once=e=>{let t=null;return(...n)=>(null===t&&(t=e(...n)),t)},t.router=an,t.useCache=function(e){let t=null;const n=function(n){return t||(t=new ee(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},t.useSingleton=function(e){let t=null;return function(...n){return t||(t=new te(e)),t.render(n)}},t.utils=ln,t.withValidation=J,t}({});
|
|
1
|
+
var NativeDocument=function(t){"use strict";let n={};n={log(){},warn(){},error(){},disable(){}};var r=n;const o=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let n=0;for(const[e,r]of t)r.deref()||(t.delete(e),n++);n>0&&r.log("Memory Auto Clean",`🧹 Cleaned ${n} orphaned observables`)}}}();class s extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function i(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}i.prototype.__$isObservableChecker=!0,i.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},i.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},i.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},i.prototype.set=function(e){return this.observable.set(e)},i.prototype.trigger=function(){return this.observable.trigger()},i.prototype.cleanup=function(){return this.observable.cleanup()};const a=function(){const e=new Map,t=new Map;return{list:()=>t,add(n,r){if(!n||"object"!=typeof n)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||n.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){n.$name=r,e.set(r,n),"function"==typeof n?.init&&n.init();for(const e in n)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");t.has(r)||t.set(r,new Set),t.get(r).add(n)}}},remove(n){if(!e.has(n))return;const r=e.get(n);"function"==typeof r.cleanup&&r.cleanup();for(const[e,n]of t.entries())n.has(r)&&n.delete(r),0===n.size&&t.delete(e);e.delete(n)},emit(e,...n){if(!t.has(e))return;const o=t.get(e);for(const t of o){const o=t["on"+e];if("function"==typeof o)try{o.call(t,...n)}catch(n){r.error("Plugin Manager",`Error in plugin ${t.$name} for event ${e}`,n)}}}}}(),u=function(e,t){this.$target=t,this.$observer=e};u.prototype.__$isObservableWhen=!0,u.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},u.prototype.val=function(){return this.$observer.$currentValue===this.$target},u.prototype.isMath=function(){return this.$observer.$currentValue===this.$target},u.prototype.isActive=function(){return this.$observer.$currentValue===this.$target};const l=(e,t,n)=>{if(T.isFunction(n))return n(e,t);if(T.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return T.isObject(e)?e[n]?.val?.()??e[n]??t:e},c=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},h=(e,t)=>{if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>h(e));if(T.isObservable(e))return t&&t(e),e;const n={};for(const t in e)e.hasOwnProperty(t)&&(n[t]=h(e[t]));return n};function d(e,t=null){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=T.isObject(e)?h(e):e)),a.emit("CreateObservable",this)}Object.defineProperty(d.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),d.prototype.__$isObservable=!0;const p={},f=function(){};d.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},d.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||p;for(let o=0,s=t.length;o<s;o++)t[o],t[o](r,n,e)};const b=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};d.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);b(t,!0)}if(e.has(t)){const n=e.get(t);b(n,!1)}},d.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},d.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},d.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=f},d.prototype.trigger=f,d.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))},d.prototype.val=function(){return this.$currentValue},d.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)T.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=f},d.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},d.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)}},d.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!T.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()}},d.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},d.prototype.check=function(e){return new i(this,e)},d.prototype.get=function(e){const t=this.$currentValue[e];return T.isObservable(t)?t.val():t},d.prototype.when=function(e){return new u(this,e)},d.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"},d.prototype.equals=function(e){return T.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},d.prototype.toBool=function(){return!!this.$currentValue},d.prototype.toggle=function(){this.set(!this.$currentValue)},d.prototype.reset=function(){if(!this.configs?.reset)return;const e=T.isObject(this.$initialValue)?h(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)};const m={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=m.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))},executeUnmountedCallback(e){const t=m.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))},checkMutation:function(e){for(const t of e){if(m.mountedSupposedSize>0)for(const e of t.addedNodes){if(m.executeMountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-mounted]");if(!t.length)return;for(const e of t)m.executeMountedCallback(e)}if(m.unmountedSupposedSize>0)for(const e of t.removedNodes){if(m.executeUnmountedCallback(e),!e.querySelectorAll)return;const t=e.querySelectorAll("[data--nd-unmounted]");if(!t.length)return;for(const e of t)m.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{m.mounted.delete(e),m.unmounted.delete(e),m.mountedSupposedSize--,m.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,m.mounted.set(e,n),m.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,m.unmounted.set(e,n),m.unmountedSupposedSize++}}}};m.observer=new MutationObserver(m.checkMutation),m.observer.observe(document.body,{childList:!0,subtree:!0});const g=["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 y(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}y.prototype.__$isNDElement=!0,y.prototype.valueOf=function(){return this.$element},y.prototype.ref=function(e,t){return e[t]=this.$element,this},y.prototype.refSelf=function(e,t){return e[t]=this,this},y.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},y.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},y.prototype.lifecycle=function(e){return this.$observer=this.$observer||m.watch(this.$element),e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),this.$observer.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),this.$observer.unmounted(e.unmounted)),this},y.prototype.mounted=function(e){return this.lifecycle({mounted:e})},y.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},y.prototype.htmlElement=function(){return this.$element},y.prototype.node=y.prototype.htmlElement,y.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},y.prototype.openShadow=function(e=null){return this.shadow("open",e)},y.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},y.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const v={},w=function(e,t,n){if(!e)return;if(!v[t]){const r=new WeakMap;return v[t]=r,void r.set(e,n)}const r=v[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);T.isArray(o)?o.push(n):r.set(e,[store[t],n])},$=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},O=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},C=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},S=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=v[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(T.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 g){const t=e.toLowerCase();y.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},y.prototype["onPrevent"+e]=function(e){return $(this.$element,t,e),this},y.prototype["onStop"+e]=function(e){return O(this.$element,t,e),this},y.prototype["onPreventStop"+e]=function(e){return C(this.$element,t,e),this},y.prototype["when"+e]=function(e){return w(this.$element,t,e),this},y.prototype["capture"+e]=function(e){return S(this.$element,t,e),this}}y.prototype.with=function(e){if(!e||"object"!=typeof e)throw new s("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},y.extend=function(e){if(!e||"object"!=typeof e)throw new s("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new s("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const n in e){if(!e.hasOwnProperty(n))continue;const o=e[n];if("function"==typeof o){if(t.has(n))throw r.error("NDElement.extend",`Cannot override protected method "${n}"`),new s(`Cannot override protected method "${n}"`);y.prototype[n]&&r.warn("NDElement.extend",`Overwriting existing prototype method "${n}"`),y.prototype[n]=o}else r.warn("NDElement.extend",`"${n}" is not a function, skipping`)}return a.emit("NDElementExtended",e),y};const A=1,E=3,x=8,k=11,T={isObservable:e=>e?.__$isObservable||e instanceof d||e instanceof i,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof i,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===A||e.nodeType===E||e.nodeType===k||e.nodeType===x),isFragment:e=>e?.nodeType===k,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 y,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&&(T.isObject(e)&&Object.values(e).some(e=>T.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 D(e,t=!1){const n=document.createDocumentFragment();n.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);n.appendChild(o),n.appendChild(s),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild;const i=e=>t||e.firstChild===o&&e.lastChild===s;return n.appendElement=function(e,t=null){const r=o.parentNode,i=t||s;r!==n?r?.insertBefore(e,i):r.nativeInsertBefore(e,i)},n.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,r){const o=T.isElement(t)?t:H.getChild(t);e!==n?i(e)&&r===s?e.append(o,r):e.insertBefore(o,r):e.nativeInsertBefore(o,r)}(o,e,t=t??s):r.error("Anchor","Anchor : parent not found",e)},n.append=function(...e){return n.appendChild(e)},n.removeChildren=function(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;const a=document.createDocumentFragment();for(;r&&r!==s;)t=r.nextSibling,a.append(r),r=t;a.replaceChildren()},n.remove=function(){if(s.parentNode===n)return;let e,t=o.nextSibling;for(;t&&t!==s;)e=t.nextSibling,n.nativeAppendChild(t),t=e},n.removeWithAnchors=function(){n.removeChildren(),o.remove(),s.remove()},n.replaceContent=function(e){const t=T.isElement(e)?e:H.getChild(e),r=s.parentNode;r&&(i(r)?r.replaceChildren(o,t,s):(n.removeChildren(),r.insertBefore(t,s)))},n.setContent=n.replaceContent,n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return s},n.startElement=function(){return o},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},n}const 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 N(e,t=null){return new d(e,t)}const P=N,F=N;function j(e,t,n){e.classes.toggle(t,n)}function M(e,t,n){e.style[t]=n}function V(e,t,n){T.isBoolean(n)?e[t]=n:e[t]=n===e.value}function q(e,t,n,r){T.isBoolean(n)?r.set(e[t]):r.set(e.value)}function _(e,t){for(let n in t){const r=t[n];T.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(j.bind(null,e,n))):T.isObservableWhenResult(r)?(e.classes.toggle(n,r.isMath()),r.subscribe(j.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function L(e,t){for(let n in t){const r=t[n];T.isObservable(r)?(e.style[n]=r.val(),r.subscribe(M.bind(null,e,n))):e.style[n]=r}}function R(e,t,n){const r=T.isObservable(n)?n.val():n;T.isBoolean(r)?e[t]=r:e[t]=r===e.value,T.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",q.bind(null,e,t,r,n)),n.subscribe(V.bind(null,e,t)))}function B(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.useValueProperty=function(e="value"){Object.defineProperty(d.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},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 W=new Map;let z=null;const H={createTextNode:()=>(z||(z=document.createTextNode("")),z.cloneNode()),createObservableNode(e,t){const n=H.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=H.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=H.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(W.has(e))return W.get(e).cloneNode();const t=document.createElement(e);return W.set(e,t),t.cloneNode()}return D("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(T.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,T.isString(e)))return H.createStaticTextNode(null,e);if(T.isElement(e))return e;if(T.isObservable(e))return H.createObservableNode(null,e);if(T.isNDElement(e))return e.$element??e.$build?.()??null;if(T.$element)return T.$element;if(T.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 T.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?H.createHydratableNode(null,e):H.createStaticTextNode(null,e)},processAttributes(e,t){T.isFragment(e)||t&&function(e,t){if(T.validateAttributes(t),!T.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(T.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,T.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>T.isObservable(e));o=N.computed(()=>o.map(e=>T.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&T.isObject(o)?_(e,o):"style"===r&&T.isObject(o)?L(e,o):I.includes(r)?R(e,r,o):T.isObservable(o)?B(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)},U={configurable:!0,get(){return new y(this)}};Object.defineProperty(HTMLElement.prototype,"nd",U),Object.defineProperty(DocumentFragment.prototype,"nd",U),Object.defineProperty(y.prototype,"nd",{configurable:!0,get:function(){return this}});const K={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,...K}}});let J=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 G=function(e,t=null){if(!T.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},Y=function(e){return T.isObservable(e)?H.createObservableNode(null,e):H.createStaticTextNode(null,e)};function Q(e,t,n,r=null){let{props:o,children:s=null}=G(n,r),i=H.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&H.processAttributes(a,o),s&&H.processChildren(s,a),H.setup(a,o,t)}function Z(e,t){return Q.bind(null,e.toLowerCase(),t)}const X=new WeakMap;function ee(e){let t=null,n=!1;const r=(e,t)=>{const n=X.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&&H.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){X.has(n)||X.set(n,{});const o=X.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 Y(n[e])}:function(t){return Y(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}function te(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=D("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new y(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 T.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return T.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!T.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return N.getById(n)}):this.valueOf()};const ne=e=>{let t=null;return new Proxy({},{get:(n,r)=>(null===t&&(t=e()),t[r])})},re=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{if(!t.has(r)){if(e.length>0)return(...n)=>{const o=e(...n);return t.set(r,o),o};t.set(r,e())}return t.get(r)}})};function oe(e){return e instanceof Date?e:new Date(e)}function se(e,t){const n=oe(e),r=oe(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ie(e){const t=oe(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function ae(e,t){const n=T.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function ue(e,t){const n=e.filter(T.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>T.isObservable(e)?e.val():e))}}function le(e){return ae(e,(e,t)=>e===t)}function ce(e){return ae(e,(e,t)=>e!==t)}function he(e){return ae(e,(e,t)=>e>t)}function de(e){return ae(e,(e,t)=>e>=t)}function pe(e){return ae(e,(e,t)=>e<t)}function fe(e){return ae(e,(e,t)=>e<=t)}function be(e,t=!0,n=""){return ue([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function me(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(T.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ge(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(T.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ye=he,ve=de,we=pe,$e=fe,Oe=le,Ce=ce,Se=me,Ae=ge;function Ee(e,t=!1){return ae(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const xe=Ee;var ke=Object.freeze({__proto__:null,In:function(e){return ae(e,(e,t)=>t.includes(e))},all:Se,and:me,any:Ae,between:function(e,t){return ue([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:xe,createFilter:ae,createMultiSourceFilter:ue,custom:function(e,...t){const n=t.filter(T.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>T.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateEquals:e=>ae(e,(e,t)=>!(!e||!t)&&se(e,t)),dateTimeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateTimeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateTimeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateTimeEquals:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e).getTime()===oe(t).getTime()),endsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Oe,equals:le,getSecondsOfDay:ie,greaterThan:he,greaterThanOrEqual:de,gt:ye,gte:ve,includes:Ee,isEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:se,lessThan:pe,lessThanOrEqual:fe,lt:we,lte:$e,match:be,neq:Ce,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:ce,notIn:function(e){return ae(e,(e,t)=>!t.includes(e))},or:ge,startsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>ae(e,(e,t)=>ie(e)>ie(t)),timeBefore:e=>ae(e,(e,t)=>ie(e)<ie(t)),timeBetween:(e,t)=>ue([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),timeEquals:e=>ae(e,(e,t)=>{if(!e||!t)return!1;const n=oe(e),r=oe(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:oe});const Te=function(e,t=null){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");d.call(this,e,t),a.emit("CreateObservableArray",this)};(Te.prototype=Object.create(d.prototype)).__$isObservableArray=!0,["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{Te.prototype[e]=function(...t){const n=this.$currentValue[e](...t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{Te.prototype[e]=function(...t){return this.$currentValue[e](...t)}}),Te.prototype.clear=function(){return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},Te.prototype.at=function(e){return this.$currentValue[e]},Te.prototype.merge=function(e){this.$currentValue.push(...e),this.trigger({action:"merge",args:e})},Te.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},Te.prototype.length=function(){return this.$currentValue.length},Te.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},Te.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},Te.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return this.remove(t)},Te.prototype.isEmpty=function(){return 0===this.$currentValue.length},Te.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},Te.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=T.isObservable(o)?be(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push(...t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=Observable.array(),s=Object.entries(r),i=()=>{const e=t.val().filter(e=>{for(const[t,n]of s)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(i)),i(),o},Te.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},Te.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},N.array=function(e=[],t=null){return new Te(e,t)},N.batch=function(e){const t=N(0),n=function(){if(T.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,t=null){const n={};for(const r in e){const o=e[r];if(Array.isArray(o)){if(!1!==t?.deep){const e=o.map(e=>T.isJson(e)?N.json(e,t):T.isArray(e)?N.array(e,t):N(e,t));n[r]=N.array(e,t);continue}n[r]=N.array(o,t)}else T.isObservable(o)||T.isProxy(o)?n[r]=o:n[r]=N(o,t)}const r=()=>{for(const e in n){n[e].reset()}},o=()=>function(e){const t={};for(const n in e){const r=e[n];if(T.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>T.isObservable(e)?e.val():T.isProxy(e)?e.$value:e)),t[n]=e}else T.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(n),s=()=>N.init(o(),t),i=e=>{N.update(u,e)},a=e=>function(e,t){const n=e[t];return T.isObservable(n)?n.val():T.isProxy(n)?n.$value:n}(n,e),u=new Proxy(n,{get:(n,u)=>"__isProxy__"===u||("$value"===u?o():"get"===u||"$get"===u?a:"val"===u||"$val"===u?o:"set"===u||"$set"===u||"$updateWith"===u?i:"observables"===u||"$observables"===u?Object.values(n):"keys"===u||"$keys"===u?Object.keys(e):"clone"===u||"$clone"===u?s:"reset"===u?r:"configs"===u?t:n[u]),set:(e,t,n)=>void 0===e[t]||(T.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return u},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.value=function(e){if(T.isObservable(e))return e.val();if(T.isProxy(e))return e.$value;if(T.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){const n=T.isProxy(t)?t.$value:t,r=e.configs;for(const o in n){const s=e[o],i=t[o],a=n[o];if(T.isObservable(s)){if(T.isArray(a)){const e=i.at(0);if(T.isObservable(e)||T.isProxy(e)){const t=a.map(t=>T.isProxy(e)?N.init(t,r):N(t,r));s.set(t);continue}s.set([...a]);continue}s.set(a)}else T.isProxy(s)?N.update(s,a):e[o]=a}},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new d(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),T.isFunction(t)){if(!T.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{T.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const De=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 Ie=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!T.isObservable(e)&&!T.isObservableWhenResult(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=D("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=H.getChild(t),T.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Ne=function(e,t,n=!0){if(!T.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=D("Match"),o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=H.getChild(r),T.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.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&o.delete(e),delete t[e]}})},Pe=function(e,t,n){if(!T.isObservable(e))throw new s("Toggle : condition must be an Observable");return Ne(e,{true:t,false:n})},Fe=Z("div"),je=Z("span"),Me=Z("label"),Ve=Z("p"),qe=Ve,_e=Z("strong"),Le=Z("h1"),Re=Z("h2"),Be=Z("h3"),We=Z("h4"),ze=Z("h5"),He=Z("h6"),Ue=Z("br"),Ke=Z("a"),Je=Z("pre"),Ge=Z("code"),Ye=Z("blockquote"),Qe=Z("hr"),Ze=Z("em"),Xe=Z("small"),et=Z("mark"),tt=Z("del"),nt=Z("ins"),rt=Z("sub"),ot=Z("sup"),st=Z("abbr"),it=Z("cite"),at=Z("q"),ut=Z("dl"),lt=Z("dt"),ct=Z("dd"),ht=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}),dt=Z("input"),pt=Z("textarea"),ft=pt,bt=Z("select"),mt=Z("fieldset"),gt=Z("option"),yt=Z("legend"),vt=Z("datalist"),wt=Z("output"),$t=Z("progress"),Ot=Z("meter"),Ct=Z("button"),St=Z("main"),At=Z("section"),Et=Z("article"),xt=Z("aside"),kt=Z("nav"),Tt=Z("figure"),Dt=Z("figcaption"),It=Z("header"),Nt=Z("footer"),Pt=Z("img"),Ft=function(e,t){return Pt({src:e,...t})},jt=Z("details"),Mt=Z("summary"),Vt=Z("dialog"),qt=Z("menu"),_t=Z("ol"),Lt=Z("ul"),Rt=Z("li"),Bt=Rt,Wt=_t,zt=Lt,Ht=Z("audio"),Ut=Z("video"),Kt=Z("source"),Jt=Z("track"),Gt=Z("canvas"),Yt=Z("svg"),Qt=Z("time"),Zt=Z("data"),Xt=Z("address"),en=Z("kbd"),tn=Z("samp"),nn=Z("var"),rn=Z("wbr"),on=Z("caption"),sn=Z("table"),an=Z("thead"),un=Z("tfoot"),ln=Z("tbody"),cn=Z("tr"),hn=cn,dn=Z("th"),pn=dn,fn=dn,bn=Z("td"),mn=bn,gn=Z("");var yn=Object.freeze({__proto__:null,Abbr:st,Address:Xt,Anchor:D,Article:Et,Aside:xt,AsyncImg:function(e,t,n,r){const o=T.isObservable(e)?e.val():e,i=Ft(t||o,n),a=new Image;return a.onload=()=>{T.isFunction(r)&&r(null,i),i.src=T.isObservable(e)?e.val():e},a.onerror=()=>{T.isFunction(r)&&r(new s("Image not found"))},T.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=o,i},Audio:Ht,BaseImage:Pt,Blockquote:Ye,Br:Ue,Button:Ct,Canvas:Gt,Caption:on,Checkbox:e=>dt({type:"checkbox",...e}),Cite:it,Code:Ge,ColorInput:e=>dt({type:"color",...e}),Data:Zt,Datalist:vt,DateInput:e=>dt({type:"date",...e}),DateTimeInput:e=>dt({type:"datetime-local",...e}),Dd:ct,Del:tt,Details:jt,Dialog:Vt,Div:Fe,Dl:ut,Dt:lt,Em:Ze,EmailInput:e=>dt({type:"email",...e}),FieldSet:mt,FigCaption:Dt,Figure:Tt,FileInput:e=>dt({type:"file",...e}),Footer:Nt,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=D("ForEach"),a=i.endElement();i.startElement();let u=new Map,c=null;const h=new Set,d=e=>{if(!o)for(const[t,n]of u.entries()){if(h.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),c&&c.delete(n.keyId)}},p=(e,o)=>{const i=l(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=H.getChild(t(e,n));if(!r)throw new s("ForEach 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=T.isObservable(e)?e.val():e;if(h.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=p(n[e],e);h.add(t)}else for(const e in n){const t=p(n[e],e);h.add(t)}if(0===h.size)return i.removeChildren(),d(),void c?.clear();d(t),c&&0!==c.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(h);Array.from(c);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 h){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),c?.clear(),c=new Set([...h])};return f(),T.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=D("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,c=0;const h=t.length>=2,d=new WeakMap,p=()=>{o.removeChildren(),g(),c=0},f=(e,t)=>d.has(e)?d.get(e):l(e,t,n),b=e=>v(f(e)),m=(e,t=!0)=>{if(e){if(t){const t=e.child;t?.remove(),u.delete(e.keyId)}e.indexObserver?.deref()?.cleanup()}},g=()=>{if(!r.shouldKeepItemsInCache)if(h){for(const[e,t]of u.entries())m(t,!1);u.clear()}else u.clear()},y=(e,n)=>{const r=f(e,n);if(u.has(r)){const e=u.get(r);e.indexObserver?.deref()?.set(n);const t=e.child;if(t)return t;u.delete(r)}const o=h?N(n):null;let i=H.getChild(t(e,o));if(!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},v=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(m(t,!1),null)},w=function(e,t){const n=u.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},$={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(y(e[t],c)),c++;return n},add(e,t=2){const n=$.toFragment(e);setTimeout(()=>{o.appendElement(n)},t)},replace(e){p(),$.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=b(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{m(u.get(e),t)})(f(e,t),!0)},clear:p,merge(e){$.add(e)},push(e){let t=0;r.pushDelay&&(t=r.pushDelay(e)??0),$.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(y(t,o)),c++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore($.toFragment(e),a.nextSibling)},splice(e,t){const[n,r,...s]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=f(t[0],n);if(1===t.length)w(e,u);else if(t.length>1){const r=v(e);a=r?.previousSibling;for(let e=0;e<t.length;e++){const r=f(t[e],n+e);w(r,u)}}}else a=i;u.replaceChildren(),s&&s.length&&a&&o.insertBefore($.toFragment(s),a.nextSibling)},reverse(e,t){$.reOrder(t)},sort(e,t){$.reOrder(t)},remove(e,t){$.removeOne(t)},pop(e,t){$.removeOne(t)},shift(e,t){$.removeOne(t)},swap(e,t){const n=i.parentNode;let r=b(t[0]),o=b(t[1]);if(!r||!o)return;const s=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,s),r=null,o=null}},O=(e,t,n)=>{if("clear"!==n.action&&e.length){if(n?.action)$[n.action]&&$[n.action](n.args,n.result);else{if(0===c)return void $.add(e);$.replace(e)}((e,t=0)=>{if(!h)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===c)return;p()}};return e.val().length&&O(e.val(),0,{action:null}),T.isObservable(e)&&e.subscribe(O),o},Form:ht,Fragment:gn,H1:Le,H2:Re,H3:Be,H4:We,H5:ze,H6:He,Header:It,HiddenInput:e=>dt({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),Ie(r,t,n)},HideIfNot:function(e,t,n){return Ie(e,t,n)},Hr:Qe,Img:Ft,Input:dt,Ins:nt,Kbd:en,Label:Me,LazyImg:function(e,t){return Ft(e,{...t,loading:"lazy"})},Legend:yt,Li:Bt,Link:Ke,ListItem:Rt,Main:St,Mark:et,Match:Ne,Menu:qt,Meter:Ot,MonthInput:e=>dt({type:"month",...e}),NativeDocumentFragment:D,Nav:kt,NumberInput:e=>dt({type:"number",...e}),Ol:Wt,Option:gt,OrderedList:_t,Output:wt,P:Ve,Paragraph:qe,PasswordInput:e=>dt({type:"password",...e}),Pre:Je,Progress:$t,Quote:at,Radio:e=>dt({type:"radio",...e}),RangeInput:e=>dt({type:"range",...e}),ReadonlyInput:e=>dt({readonly:!0,...e}),Samp:tn,SearchInput:e=>dt({type:"search",...e}),Section:At,Select:bt,ShowIf:Ie,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!T.isObservableWhenResult(e))throw new s("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Ie(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!T.isObservable(e))throw new s("showWhen observer must be an Observable",{data:e});return Ie(e.when(t),n)}throw new s("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Ct(e,{type:"button",...t}),Small:Xe,Source:Kt,Span:je,Strong:_e,Sub:rt,SubmitButton:(e,t)=>Ct(e,{type:"submit",...t}),Summary:Mt,Sup:ot,Svg:Yt,Switch:Pe,TBody:ln,TBodyCell:mn,TFoot:un,TFootCell:fn,THead:an,THeadCell:pn,TRow:hn,Table:sn,Td:bn,TelInput:e=>dt({type:"tel",...e}),TextArea:pt,TextInput:ft,Th:dn,Time:Qt,TimeInput:e=>dt({type:"time",...e}),Tr:cn,Track:Jt,Ul:zt,UnorderedList:Lt,UrlInput:e=>dt({type:"url",...e}),Var:nn,Video:Ut,Wbr:rn,WeekInput:e=>dt({type:"week",...e}),When:function(e){if(!T.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,Pe(e,t,n))}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=D("Portal "+n);return r.appendChild(H.getChild(e)),(t||document.body).appendChild(r),r}});const vn={};function wn(e,t,n={}){e="/"+c(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u=n.layout||null,l={},h=[],d=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=vn[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},p=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=d(t);return n&&n.pattern?(l[n.name]=n.pattern,h.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+c(e,"/");if(!p().exec(e))return!1;const t={};return p().exec(e).forEach((e,n)=>{if(n<1)return;const r=h[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=d(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class $n extends Error{constructor(e,t){super(e),this.context=t}}const On=(e,t)=>{const n=[];return e.forEach(e=>{n.push(c(e.suffix,"/"))}),n.push(c(t,"/")),n.join("/")},Cn=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Sn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},An=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function En(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function xn(){this.push=function(e){try{const{route:t,path:n,params:r,query:o}=this.resolve(e);if(window.history.state&&window.history.state.path===n)return;window.history.pushState({name:t.name(),params:r,path:n},t.name()||n,n),this.handleRouteChange(t,r,o,n)}catch(e){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 kn(){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 Tn="default";function Dn(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)En.apply(this,[]);else if("history"===e.mode)xn.apply(this,[]);else{if("memory"!==e.mode)throw new $n("Invalid router mode "+e.mode);kn.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 wn(On(o,e),r,{...s,middlewares:Cn(o,s?.middlewares||[]),name:s?.name?Sn(o,s.name):null,layout:s?.layout||An(o)});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!T.isFunction(n))throw new $n("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},r={}){const o=n[e];if(!o)throw new $n(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(T.isJson(e)){const t=n[e.name];if(!t)throw new $n(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[r,o]=e.split("?"),s="/"+c(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new $n(`Route not found for url: ${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(!T.isFunction(e))throw new $n("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function In(e,t){const{to:n,href:r,...o}=e,s=n||r;if(T.isString(s)){const e=Dn.get();return Ke({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||Tn,a=Dn.get(i);if(!a)throw new $n('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ke({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Dn.routers={},Dn.create=function(t,n){if(!T.isFunction(n))throw r.error("Router","Callback must be a function",e),new $n("Callback must be a function");const o=new Dn(t);return Dn.routers[t.name||Tn]=o,n(o),o.init(t.entry),o.mount=function(e){if(T.isString(e)){const t=document.querySelector(e);if(!t)throw new $n(`Container not found for selector: ${e}`);e=t}else if(!T.isElement(e))throw new $n("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e,n){t.innerHTML="";const r=n.layout();r?t.appendChild(r(e)):t.appendChild(e)},o=function(e){if(!e.route)return;const{route:t,params:o,query:s,path:i}=e;if(n.has(i)){const e=n.get(i);return void r(e,t)}const a=t.component()({params:o,query:s});n.set(i,a),r(a,t)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},Dn.get=function(e){const t=Dn.routers[e||Tn];if(!t)throw new $n(`Router not found for name: ${e}`);return t},Dn.push=function(e,t=null){return Dn.get(t).push(e)},Dn.replace=function(e,t=null){return Dn.get(t).replace(e)},Dn.forward=function(e=null){return Dn.get(e).forward()},Dn.back=function(e=null){return Dn.get(e).back()},In.blank=function(e,t){return Ke({...e,target:"_blank"},t)};var Nn=Object.freeze({__proto__:null,Link:In,RouteParamPatterns:vn,Router:Dn});const Pn={once:e=>ne(e),memoize:e=>re(e)};var Fn=Object.freeze({__proto__:null,Filters:ke,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};o&&(o instanceof FormData?i.body=o:(i.headers["Content-Type"]="application/json","GET"!==n?i.body=JSON.stringify(o):i.params=o));for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const u=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(u?.message||a.statusText);throw e.status=a.status,e.data=u,e}return u},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},Service:Pn});return t.$=P,t.ElementCreator=H,t.HtmlElementWrapper=Z,t.NDElement=y,t.Observable=N,t.PluginsManager=a,t.SingletonView=te,t.Store=De,t.TemplateCloner=ee,t.Validator=T,t.autoMemoize=re,t.autoOnce=ne,t.classPropertyAccumulator=function(e=[]){let t=T.isString(e)?e.split(" ").filter(Boolean):e;const n=T.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=Y,t.cssPropertyAccumulator=function(e={}){let t=T.isString(e)?e.split(";").filter(Boolean):e;const n=T.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=yn,t.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n;return t.has(r)||t.set(r,e(...o)),t.get(r)}},t.normalizeComponentArgs=G,t.obs=F,t.once=e=>{let t=null;return(...n)=>(null===t&&(t=e(...n)),t)},t.router=Nn,t.useCache=function(e){let t=null;const n=function(n){return t||(t=new ee(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},t.useSingleton=function(e){let t=null;return function(...n){return t||(t=new te(e)),t.render(n)}},t.utils=Fn,t.withValidation=J,t}({});
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {match} from "../utils/filters/index";
|
|
2
|
+
import Validator from "../utils/validator";
|
|
1
3
|
import ObservableItem from "./ObservableItem.js";
|
|
2
4
|
import PluginsManager from "../utils/plugins-manager.js";
|
|
3
5
|
import NativeDocumentError from "../errors/NativeDocumentError.js";
|
|
@@ -12,7 +14,7 @@ const noMutationMethods = ['map', 'forEach', 'filter', 'reduce', 'some', 'every'
|
|
|
12
14
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
13
15
|
* @constructor
|
|
14
16
|
*/
|
|
15
|
-
const ObservableArray = function (target, configs) {
|
|
17
|
+
const ObservableArray = function (target, configs = null) {
|
|
16
18
|
if(!Array.isArray(target)) {
|
|
17
19
|
throw new NativeDocumentError('Observable.array : target must be an array');
|
|
18
20
|
}
|
|
@@ -115,6 +117,70 @@ ObservableArray.prototype.populateAndRender = function(iteration, callback) {
|
|
|
115
117
|
};
|
|
116
118
|
|
|
117
119
|
|
|
120
|
+
ObservableArray.prototype.where = function(predicates) {
|
|
121
|
+
const sourceArray = this;
|
|
122
|
+
const observableDependencies = [sourceArray];
|
|
123
|
+
const filterCallbacks = {};
|
|
124
|
+
|
|
125
|
+
for (const [key, rawPredicate] of Object.entries(predicates)) {
|
|
126
|
+
const predicate = Validator.isObservable(rawPredicate) ? match(rawPredicate, false) : rawPredicate;
|
|
127
|
+
if (predicate && typeof predicate === 'object' && 'callback' in predicate) {
|
|
128
|
+
filterCallbacks[key] = predicate.callback;
|
|
129
|
+
|
|
130
|
+
if (predicate.dependencies) {
|
|
131
|
+
const deps = Array.isArray(predicate.dependencies)
|
|
132
|
+
? predicate.dependencies
|
|
133
|
+
: [predicate.dependencies];
|
|
134
|
+
observableDependencies.push(...deps);
|
|
135
|
+
}
|
|
136
|
+
} else if(typeof predicate === 'function') {
|
|
137
|
+
filterCallbacks[key] = predicate;
|
|
138
|
+
} else {
|
|
139
|
+
filterCallbacks[key] = (value) => value === predicate;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const viewArray = Observable.array();
|
|
144
|
+
|
|
145
|
+
const filters = Object.entries(filterCallbacks);
|
|
146
|
+
const updateView = () => {
|
|
147
|
+
const filtered = sourceArray.val().filter(item => {
|
|
148
|
+
for (const [key, callback] of filters) {
|
|
149
|
+
if(key === '_') {
|
|
150
|
+
if (!callback(item)) return false;
|
|
151
|
+
} else {
|
|
152
|
+
if (!callback(item[key])) return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
viewArray.set(filtered);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
observableDependencies.forEach(dep => dep.subscribe(updateView));
|
|
162
|
+
|
|
163
|
+
updateView();
|
|
164
|
+
|
|
165
|
+
return viewArray;
|
|
166
|
+
};
|
|
118
167
|
|
|
168
|
+
ObservableArray.prototype.whereSome = function(fields, filter) {
|
|
169
|
+
return this.where({
|
|
170
|
+
_: {
|
|
171
|
+
dependencies: filter.dependencies,
|
|
172
|
+
callback: (item) => fields.some(field => filter.callback(item[field]))
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
ObservableArray.prototype.whereEvery = function(fields, filter) {
|
|
178
|
+
return this.where({
|
|
179
|
+
_: {
|
|
180
|
+
dependencies: filter.dependencies,
|
|
181
|
+
callback: (item) => fields.every(field => filter.callback(item[field]))
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
};
|
|
119
185
|
|
|
120
186
|
export default ObservableArray;
|
|
@@ -57,6 +57,7 @@ ObservableItem.prototype.triggerListeners = function(operations) {
|
|
|
57
57
|
|
|
58
58
|
operations = operations || DEFAULT_OPERATIONS;
|
|
59
59
|
for(let i = 0, length = $listeners.length; i < length; i++) {
|
|
60
|
+
const listener = $listeners[i];
|
|
60
61
|
$listeners[i]($currentValue, $previousValue, operations);
|
|
61
62
|
}
|
|
62
63
|
};
|
|
@@ -74,6 +75,7 @@ const handleWatcherCallback = function(callbacks, value) {
|
|
|
74
75
|
callback.set ? callback.set(value) : callback(value);
|
|
75
76
|
});
|
|
76
77
|
}
|
|
78
|
+
|
|
77
79
|
ObservableItem.prototype.triggerWatchers = function() {
|
|
78
80
|
if(!this.$watchers) {
|
|
79
81
|
return;
|
|
@@ -281,4 +283,4 @@ ObservableItem.prototype.reset = function() {
|
|
|
281
283
|
})
|
|
282
284
|
: this.$initialValue;
|
|
283
285
|
this.set(resetValue)
|
|
284
|
-
};
|
|
286
|
+
};
|
|
@@ -8,6 +8,6 @@ import ObservableArray from "../ObservableArray.js";
|
|
|
8
8
|
* @param {{propagation: boolean, deep: boolean, reset: boolean}|null} configs
|
|
9
9
|
* @returns {ObservableArray}
|
|
10
10
|
*/
|
|
11
|
-
Observable.array = function(target, configs = null) {
|
|
11
|
+
Observable.array = function(target = [], configs = null) {
|
|
12
12
|
return new ObservableArray(target, configs);
|
|
13
13
|
};
|