@base-framework/base 3.7.21 → 3.7.22

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/base.js CHANGED
@@ -1,2 +1,2 @@
1
- var R=class{static toArray(t){return Array.from(t)}static inArray(t,e,r){return Array.isArray(t)?t.indexOf(e,r):-1}};var h=class{static getType(t){let e=typeof t;return e!=="object"?e:Array.isArray(t)?"array":"object"}static isUndefined(t){return typeof t>"u"}static isObject(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}static isFunction(t){return typeof t=="function"}static isString(t){return typeof t=="string"}static isArray(t){return Array.isArray(t)}};var dr=Object.prototype.toString,dt=Object.prototype.hasOwnProperty,b={create(s){return Object.create(s||null)},extendObject(s,t){if(!h.isObject(s)||!h.isObject(t))return!1;for(let e in s)dt.call(s,e)&&!dt.call(t,e)&&(t[e]=s[e]);return t},clone(s){if(!s||!h.isObject(s))return{};try{return structuredClone(s)}catch{return JSON.parse(JSON.stringify(s))}},getClassObject(s){return typeof s=="function"?s.prototype:s},extendClass(s,t){let e=this.getClassObject(s),r=this.getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let i=Object.create(e);for(var n in r)i[n]=r[n];return i},hasOwnProp(s,t){return dt.call(s,t)},isPlainObject(s){return!!s&&dr.call(s)==="[object Object]"},isEmpty(s){if(!h.isObject(s))return!0;for(let t in s)if(dt.call(s,t))return!1;return!0}};var rt={types:{},add(s,t){this.types[s]=t},get(s){return this.types[s]||!1},remove(s){delete this.types[s]}};var pt=class{constructor(){this.types=new Map}add(t,e){this.types.has(t)||this.types.set(t,[]),this.types.get(t).push(e)}get(t){return this.types.get(t)||!1}has(t){return this.types.has(t)}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){if(!this.types.has(t))return;let e=this.types.get(t);if(!e.length)return;let r,i=rt.get(t);if(i){for(var n=0,o=e.length;n<o;n++)r=e[n],r&&(e[n]=null,this.removeByCallBack(i,r));this.types.delete(t)}}remove(t){if(t){this.removeType(t);return}this.types.forEach((e,r)=>{r&&this.removeType(r)}),this.types.clear()}};var j=new WeakMap,m=class{static trackers=new Map;static trackingCount=0;static addType(t,e){rt.add(t,e)}static removeType(t){rt.remove(t)}static getTrackingId(t){if(!t||typeof t!="object")return"";let e=j.get(t);return e||(e=`dt${this.trackingCount++}`,j.set(t,e)),e}static add(t,e,r){let i=this.getTrackingId(t);this.find(i).add(e,r)}static get(t,e){let r=j.get(t),i=this.trackers.get(r);return i?e?i.get(e):i:!1}static has(t,e){let r=this.getTrackingId(t);if(!r)return!1;let i=this.trackers.get(r);return i&&e?i.has(e):!1}static find(t){return this.trackers.has(t)||this.trackers.set(t,new pt),this.trackers.get(t)}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let r=j.get(t);if(!r||!this.trackers.has(r))return;let i=this.trackers.get(r);if(!e){i.remove(),this.trackers.delete(r),j.delete(t);return}i.remove(e),this.isEmpty(i.types)&&(this.trackers.delete(r),j.delete(t))}};var Qt=s=>{let t=0;for(let[e,r]of Object.entries(s))t++,typeof s[e]=="object"&&(t+=Qt(s[e]));return t},ue=(s,t)=>{let e=!1;if(typeof s!="object"||typeof t!="object")return e;for(let[r,i]of Object.entries(s)){if(!b.hasOwnProp(t,r))break;let n=t[r];if(typeof i!=typeof n)break;if(typeof i=="object"){if(e=ue(i,n),e!==!0)break}else if(i===n)e=!0;else break}return e},pr=(s,t)=>{let e=Qt(s),r=Qt(t);return e!==r?!1:ue(s,t)},he=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?pr(s,t):s===t};var f={getEvents(s){return h.isObject(s)===!1?[]:m.get(s,"events")},create(s,t,e,r=!1,i=!1,n=null){return i=i===!0,{event:s,obj:t,fn:e,capture:r,swapped:i,originalFn:n}},on(s,t,e,r){return Array.isArray(s)?s.forEach(i=>this.add(i,t,e,r)):this.add(s,t,e,r),this},off(s,t,e,r){if(Array.isArray(s)){var i;s.forEach(n=>this.remove(n,t,e,r))}else this.remove(s,t,e,r);return this},add(s,t,e,r=!1,i=!1,n=null){if(h.isObject(t)===!1)return this;let o=this.create(s,t,e,r,i,n);return m.add(t,"events",o),t.addEventListener(s,e,r),this},remove(s,t,e,r=!1){let i=this.getEvent(s,t,e,r);return i===!1?this:(typeof i=="object"&&this.removeEvent(i),this)},removeEvent(s){return typeof s=="object"&&s.obj.removeEventListener(s.event,s.fn,s.capture),this},getEvent(s,t,e,r){if(typeof t!="object")return!1;let i=this.getEvents(t);if(!i||i.length<1)return!1;let n=this.create(s,t,e,r);return this.search(n,i)},search(s,t){let e,r=this.isSwappable(s.event);for(var i=0,n=t.length;i<n;i++)if(e=t[i],!(e.event!==s.event||e.obj!==s.obj)&&(e.fn===s.fn||r===!0&&e.originalFn===s.fn))return e;return!1},removeEvents(s){return h.isObject(s)===!1?this:(m.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return this.swap.includes(s)}};m.addType("events",s=>{f.removeEvent(s)});var Yt={events:f,addListener(s,t,e,r){return this.events.add(s,t,e,r),this},on(s,t,e,r){let i=this.events;return Array.isArray(s)?s.forEach(n=>{i.add(n,t,e,r)}):i.add(s,t,e,r),this},off(s,t,e,r){let i=this.events;return Array.isArray(s)?s.forEach(n=>{i.remove(n,t,e,r)}):i.remove(s,t,e,r),this},removeListener(s,t,e,r){return this.events.remove(s,t,e,r),this},_createEvent(s,t,e,r){let i;switch(t){case"HTMLEvents":i=new Event(s,e);break;case"MouseEvents":i=new MouseEvent(s,e);break;default:i=new CustomEvent(s,r);break}return i},createEvent(s,t,e,r){if(h.isObject(t)===!1)return!1;let i={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};h.isObject(e)&&(i=Object.assign(i,e));let n=this._getEventType(s);return this._createEvent(s,n,i,r)},_getEventType(s){let t={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},e="CustomEvent";for(let[r,i]of Object.entries(t))if(s.match(i)){e=r;break}return e},trigger(s,t,e){if(h.isObject(t)===!1)return this;let r=typeof s=="string"?this.createEvent(s,t,null,e):s;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let s=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=s())},onMouseWheel(s,t,e,r=!1){typeof t>"u"&&(t=window);let i=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof s=="function"&&s(a,o),e===!0&&o.preventDefault()},n=this.getWheelEventType();return this.events.add(n,t,i,r,!0,s),this},offMouseWheel(s,t,e=!1){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,s,e),this},preventDefault(s){return typeof s.preventDefault=="function"?s.preventDefault():s.returnValue=!1,this},stopPropagation(s){return typeof s.stopPropagation=="function"?s.stopPropagation():s.cancelBubble=!0,this}};var st=class{constructor(){this.errors=[],this.dataTracker=m}augment(t){if(!h.isObject(t))return this;let e=this.constructor.prototype;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return this}override(t,e,r,i){return(t[e]=r).apply(t,R.toArray(i))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,r){if(h.isObject(t)===!1)return"";let i=t[e];return typeof i<"u"?i:typeof r<"u"?r:""}createCallBack(t,e,r=[],i=!1){return typeof e!="function"?!1:(...n)=>(i===!0&&(r=r.concat(n)),e.apply(t,r))}bind(t,e){return e.bind(t)}};st.prototype.extend=(function(){return st.prototype})();var A=new st;A.augment({...b,...Yt,...h,equals:he});var it={url:"",responseType:"json",method:"POST",fixedParams:"",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},beforeSend:[],async:!0,crossDomain:!1,withCredentials:!1,completed:null,failed:null,aborted:null,progress:null};var le=()=>{A.augment({xhrSettings:it,addFixedParams(s){this.xhrSettings.fixedParams=s},beforeSend(s){this.xhrSettings.beforeSend.push(s)},ajaxSettings(s){typeof s=="object"&&(this.xhrSettings=b.extendClass(A.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=it}})};var v=class{static limit(t,e=1e6){return typeof t!="string"?"":t.substring(0,e)}static parseQueryString(t,e,r=!0){typeof t!="string"&&(t=window.location.search),t=this.limit(t);let i={},n=/([^?=&]+)(=([^&]*))?/g;return t.replace(n,function(o,a,c,u){i[a]=e!==!1?decodeURIComponent(u):u}),i}static camelCase(t){t=this.limit(t);let e=/(-|\s|_)+\w{1}/g;return t.replace(e,r=>r[1].toUpperCase())}static uncamelCase(t,e="-"){t=this.limit(t);let r=/([A-Z]{1,})/g;return t.replace(r,i=>e+i.toLowerCase()).toLowerCase()}static titleCase(t){if(!t)return"";t=this.limit(t);let e=/\w\S*/;return t.replace(e,r=>r.charAt(0).toUpperCase()+r.substring(1).toLowerCase())}};var mt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR(),{method:r,url:i,async:n}=this.settings;e.open(r,i,n),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=it.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var i=0,n=t.length;i<n;i++){var o=t[i];o&&o(e,r)}}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}setupParams(t,e=null){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let i=typeof e;if(r==="string")return i!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(i==="string"&&(e=v.parseQueryString(e,!1)),t instanceof FormData)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.append(n,e[n]);else r==="object"&&(t=b.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,r=t.params;return r?r=this.setupParams(r,e):e&&(r=this.setupParams(e)),r}getXhrSettings(t){let e=this.settings={...A.xhrSettings};if(t.length>=2&&typeof t[0]!="object")for(var r=0,i=t.length;r<i;r++){var n=t[r];switch(r){case 0:e.url=n;break;case 1:e.params=n;break;case 2:e.completed=n,e.failed=n;break;case 3:e.responseType=n||"json";break;case 4:e.method=n?n.toUpperCase():"POST";break;case 5:e.async=typeof n<"u"?n:!0;break}}else e=this.settings=b.extendClass(this.settings,t[0]),typeof e.completed=="function"&&(typeof e.failed!="function"&&(e.failed=e.completed),typeof e.aborted!="function"&&(e.aborted=e.failed))}createXHR(){let t=this.settings,e=new XMLHttpRequest;return e.responseType=t.responseType,t.withCredentials===!0&&(e.withCredentials=!0),e}setupHeaders(){let t=this.settings;if(!t||typeof t.headers!="object")return;let e=t.headers;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.xhr?.setRequestHeader(r,e[r])}update(t,e){let r=this.xhr,i=()=>{f.removeEvents(r?.upload),f.removeEvents(r)},n=this.settings;if(!n)return!1;switch(e||t.type){case"load":if(typeof n.completed=="function"){let a=this.getResponseData();n.completed(a,this.xhr)}i();break;case"error":typeof n.failed=="function"&&n.failed(!1,this.xhr),i();break;case"progress":typeof n.progress=="function"&&n.progress(t);break;case"abort":typeof n.aborted=="function"&&n.aborted(!1,this.xhr),i();break}}getResponseData(){let t=this.xhr;if(!t)return null;let e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr;if(!e)return;let r=this.update.bind(this);f.on(["load","error","abort"],e,r),f.on("progress",e.upload,r)}};le();var gt=(...s)=>new mt(s).xhr;var mr=s=>typeof s!="string"?s:fe(s),fe=s=>[{tag:"text",textContent:s}],yt=()=>({props:{},children:[]}),bt=s=>({props:{},children:fe(s)}),xt=s=>({props:{},children:s}),St=s=>({props:s[0]||{},children:mr(s[1])});var vt=class{constructor(){this.connections=new Map}add(t,e,r){let i=this.getOrCreate(t),n=i.get(e);return n?Array.isArray(n)?n.push(r):i.set(e,[n,r]):i.set(e,r),r}get(t,e){let r=this.connections.get(t)?.get(e);return r?Array.isArray(r)?r[r.length-1]||!1:r:!1}getOrCreate(t){let e=this.connections.get(t);return e||(e=new Map,this.connections.set(t,e)),e}remove(t,e){let r=this.connections.get(t);if(r)if(e)this.unsubscribe(r.get(e)),r.delete(e),r.size===0&&this.connections.delete(t);else{for(let i of r.values())this.unsubscribe(i);this.connections.delete(t)}}unsubscribe(t){if(t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)t[e]?.unsubscribe();else t.unsubscribe()}};var $=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var kt=class extends ${constructor(t){super(),this.data=t}subscribe(t,e){if(!this.data||typeof this.data.on!="function"){console.warn('OneWaySource: Cannot subscribe - data source is null or does not have an "on" method. Make sure your component has data, state, or context.data initialized.',t,this.data);return}this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data&&this.msg&&this.token&&this.data.off(this.msg,this.token),this.data=null,this.msg=null,this.token=null}};var V=class{unsubscribe(){}};var Ct=class extends V{constructor(){super(),this.source=null}addSource(t){return this.source=new kt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var z=class extends ${constructor(t){super(),this.pubSub=t}subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=this.pubSub.on(t,e)}unsubscribe(){this.pubSub&&this.msg&&this.token&&this.pubSub.off(this.msg,this.token),this.pubSub=null,this.msg=null,this.token=null}callBack(){}};var wt=class extends z{constructor(t,e,r){super(r),this.data=t,this.prop=e}set(t){this.data.set(this.prop,t)}get(){return this.data.get(this.prop)}callBack(t,e){this.data!==e&&this.data.set(this.prop,t,e)}unsubscribe(){super.unsubscribe(),this.data=null,this.prop=null}};var y=class{static getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}static getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?R.toArray(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:R.toArray(r):!1}static html(t,e){return h.isObject(t)===!1?!1:h.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,r){return h.isObject(t)===!1||h.isUndefined(e)?this:(e=v.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=v.uncamelCase(e);let r=t.style[e];if(r!=="")return r;let i=null,n=t.currentStyle;if(n&&(i=n[e]))return i;let o=window.getComputedStyle(t,null);return o?o[e]:r}static css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}static removeAttr(t,e){return h.isObject(t)&&t.removeAttribute(e),this}static setAttr(t,e,r){t.setAttribute(e,r)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,r){return h.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=v.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}static removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}static setData(t,e,r){e=this.removeDataPrefix(e),e=v.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=v.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,r){return h.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?[]:t.querySelectorAll(e)}static show(t){if(h.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}static hide(t){if(h.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}static toggle(t){return h.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return h.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return h.isObject(t)?t.offsetWidth:!1}static getHeight(t){return h.isObject(t)?t.offsetHeight:!1}static getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,r=t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return h.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}static getScrollTop(t){return this.getScrollPosition(t).top}static getScrollLeft(t){return this.getScrollPosition(t).left}static getWindowSize(){let t=window,e=document,r=e.documentElement,i=e.getElementsByTagName("body")[0],n=t.innerWidth||r.clientWidth||i.clientWidth,o=t.innerHeight||r.clientHeight||i.clientHeight;return{width:n,height:o}}static getDocumentSize(){let t=document,e=t.body,r=t.documentElement,i=Math.max(e.scrollHeight,e.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,r.clientWidth,r.scrollWidth,r.offsetWidth),height:i}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let r={x:0,y:0};if(h.isObject(t)===!1)return r;let i=0;for(;t&&(e===0||i<e);)i++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}static addClass(t,e){if(h.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let n=e.split(" ");for(var r=0,i=n.length;r<i;r++)t.classList.add(e)}return this}static removeClass(t,e){return h.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return h.isObject(t)===!1||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return h.isObject(t)===!1?this:(t.classList.toggle(e),this)}};var Dt=s=>{let t="textContent";if(!s||typeof s!="object")return t;let e=s.tagName.toLowerCase();if(e==="input"||e==="textarea"||e==="select"){let r=s.type;if(!r)return t="value",t;switch(r){case"checkbox":t="checked";break;case"file":t="files";break;default:t="value"}}return t};var gr=(s,t,e)=>{y.setAttr(s,t,e)},yr=(s,t,e)=>{s.checked=s.value==e},br=(s,t,e)=>{e=e==1,de(s,t,e)},de=(s,t,e)=>{s[t]=e},xr=(s,t)=>y.getAttr(s,t),Sr=(s,t)=>s[t],Tt=class extends z{constructor(t,e,r,i){super(i),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof r=="string"?this.setupFilter(r):r}addSetMethod(t,e){if(e.charAt(4)==="-")return this.setValue=gr,this.getValue=xr,this;this.getValue=Sr;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=br;return;case"radio":this.setValue=yr;return}return this.setValue=de,this}getAttrBind(t){return t||Dt(this.element)}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;return!e||typeof e!="object"?this:(this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t),this)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){return e!==this.element&&this.set(t),this}unsubscribe(){super.unsubscribe(),this.element={},this.attr="",this.filter=null,this.setValue=null,this.getValue=null}};var At=class extends V{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new Tt(t,e,r,this.pubSub)}addData(t,e){return this.data=new wt(t,e,this.pubSub)}unsubscribeSource(t){return t&&t.unsubscribe(),this}unsubscribe(){return this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null,this}};var pe=-1,q=class{constructor(){this.callBacks=new Map,this.updateQueue=new Map,this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this.maxFlushIterations=2e3,this.batchingEnabled=!0,this.debugMode=!1,this.flushCompleteResolvers=[],this.flushCallbacks=[]}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,pe=-1}on(t,e){let r=(++pe).toString();return this.get(t).set(r,e),r}off(t,e){let r=this.callBacks.get(t);r&&(e=String(e),r.delete(e),r.size===0&&this.callBacks.delete(t))}remove(t){this.callBacks.delete(t)}publish(t,...e){if(!this.batchingEnabled){this.publishImmediate(t,...e);return}this.updateQueue.set(t,e),this.debugMode&&console.log("[DataPubSub] Queued update:",t,e),this.scheduleFlush()}scheduleFlush(){this.isFlushing||this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){if(this.updateQueue.size===0){this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete();return}if(this.isFlushing||(this.flushIterations=0),this.isFlushing=!0,this.flushScheduled=!1,this.flushIterations++,this.flushIterations>this.maxFlushIterations){console.error("[DataPubSub] Infinite loop detected! Flush iterations exceeded",this.maxFlushIterations,"- Breaking to prevent memory exhaustion."),console.error("[DataPubSub] Queue size:",this.updateQueue.size),console.error("[DataPubSub] Queued messages:",Array.from(this.updateQueue.keys())),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this._resolveFlushComplete(),this.flushIterations=0;return}this.debugMode&&console.log("[DataPubSub] Flushing",this.updateQueue.size,"updates (iteration",this.flushIterations+")");let t=this.updateQueue;this.updateQueue=new Map;try{for(let[e,r]of t)this.publishImmediate(e,...r)}finally{this.debugMode&&console.log("[DataPubSub] Flush complete (iteration",this.flushIterations+")"),this.updateQueue.size>0?(this.debugMode&&console.log("[DataPubSub] New updates queued during flush, re-flushing..."),this.flush()):(this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete())}}_resolveFlushComplete(){if(this.flushCompleteResolvers.length>0){let t=this.flushCompleteResolvers;this.flushCompleteResolvers=[];let e=t.length;for(let r=0;r<e;r++)t[r]()}if(this.flushCallbacks.length>0){let t=this.flushCallbacks;this.flushCallbacks=[];let e=t.length;for(let r=0;r<e;r++)t[r]()}}nextFlush(){return new Promise(t=>{this.flushCompleteResolvers.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>t())})}onFlush(t){if(typeof t!="function"){console.warn("[DataPubSub] onFlush requires a function callback");return}this.flushCallbacks.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>{if(this.flushCallbacks.length>0){let e=this.flushCallbacks;this.flushCallbacks=[];let r=e.length;for(let i=0;i<r;i++)e[i]()}})}flushSync(){this.flush()}publishImmediate(t,...e){let r=this.callBacks.get(t);if(r){for(let i of r.values())if(i)try{i.apply(this,e)}catch(n){console.error('[DataPubSub] Subscriber error for "'+t+'":',n)}}}};var Xt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=new Set([20,37,38,39,40]),this.connections=new vt,this.pubSub=new q,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,i){let n=r,o=null,a=r.indexOf(":");a!==-1&&(o=r.substring(0,a),n=r.substring(a+1));let c=o??"",u=this.setupConnection(t,e,n,c,i),l=u.element,d=e.get(n);return typeof d<"u"?l.set(d):(d=l.get(),d!==""&&u.data.set(d)),this}setupConnection(t,e,r,i,n){let o=this.getBindId(t),a=new At(this.pubSub);a.addData(e,r).subscribe(o);let l=`${e.getDataId()}:${r}`;return a.addElement(t,i,n).subscribe(l),this.addConnection(o,"bind",a),a}addConnection(t,e,r){return this.connections.add(t,e,r),this}setBindId(t){let e="db-"+this.idCount++;return t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,i){if(h.isObject(t)===!1)return this;let n=new Ct,o=e.get(r),a=!0,c=p=>{a&&(a=!1,p===o)||i(p)};n.addSource(e).subscribe(r,c);let l=this.getBindId(t),d=e.getDataId()+":"+r;return this.addConnection(l,d,n),i(o),this}unwatch(t,e,r){if(h.isObject(t)===!1)return this;let i=t[this.attr];if(i){let n=e.getDataId()+":"+r;this.connections.remove(i,n)}return this}publish(t,e,r){return this.pubSub.publish(t,e,r),this}isDataBound(t){if(!t)return null;let e=t[this.attr];return e||null}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.has(t.keyCode)}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r!==null){let i=this.connections.get(r,"bind");if(i){let n=i.element.get();this.pubSub.publish(r,n,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){typeof document<"u"&&f.on(["change","paste","input"],document,this.changeHandler,!1)}removeEvents(){typeof document<"u"&&f.off(["change","paste","input"],document,this.changeHandler,!1)}},S=new Xt;var E=s=>s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null;var vr={class:"className",text:"textContent",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",celpadding:"cellPadding",useMap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},nt=s=>vr[s]||s,ot=s=>typeof s=="string"&&s.substring(0,2)==="on"?s.substring(2):s,T=class{static create(t,e,r,i){let n=document.createElement(t);return this.addAttributes(n,e),i===!0?this.prepend(r,n):this.append(r,n),n}static addAttributes(t,e){if(!e||typeof e!="object")return;let r=e.type;typeof r<"u"&&y.setAttr(t,"type",r);for(let[i,n]of Object.entries(e))i==="innerHTML"?t.innerHTML=n:i.indexOf("-")!==-1?y.setAttr(t,i,n):this.addAttr(t,i,n)}static addHtml(t,e){return typeof e>"u"||e===""?this:(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,r){if(r===""||!e)return;if(typeof r==="function")e=ot(e),r.originalCallback?f.add(e,t,r,!1,!0,r.originalCallback):f.add(e,t,r);else{let n=nt(e);t[n]=r}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}static createComment(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}static setupSelectOptions(t,e,r){if(!h.isObject(t)||!h.isArray(e))return!1;e.forEach(i=>{let n=new Option(i.label,i.value);t.options.add(n),r!==null&&n.value==r&&(n.selected=!0)})}static removeElementData(t){m.remove(t);let e=t.childNodes;if(e&&e.length>0){let i=Array.from(e);for(let n=i.length-1;n>=0;n--)this.removeElementData(i[n])}t.bindId&&S.unbind(t)}static removeElement(t){if(!t)return this;let e=m.has(t,"manual-destroy");return this.removeElementData(t),e===!1&&t.remove(),this}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(!h.isObject(t))return this;let e=Array.from(t.childNodes);for(let r=0,i=e.length;r<i;r++)this.removeElementData(e[r]);return t.innerHTML="",this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,r){let i=r||t.firstChild;return t.insertBefore(e,i),this}static clone(t,e=!1){return h.isObject(t)?t.cloneNode(e):!1}};var C=class extends T{static create(t,e,r,i){let n=document.createElement(t);return this.addAttributes(n,e,i),r.appendChild(n),n}static addAttributes(t,e,r){if(!(!e||e.length<1))for(let i=0,n=e.length;i<n;i++){let o=e[i];this.addAttr(t,o.key,o.value,r)}}static addAttr(t,e,r,i){if(r===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=r;return}if(typeof r==="function"){if(e=ot(e),r.originalCallback)f.add(e,t,r,!1,!0,r.originalCallback);else{let a=r,c=function(u){a.call(this,u,i)};f.add(e,t,c,!1,!0,a)}return}if(e.substring(4,5)==="-"){y.setAttr(t,e,r);return}let o=nt(e);t[o]=r}static addContent(t,e){e&&(e.textContent!==null?t.textContent=e.textContent:e.innerHTML&&(t.innerHTML=e.innerHTML))}static append(t,e){t.appendChild(e)}};var Gt=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,me=new Map,w={isWatching(s){return Array.isArray(s)?typeof s[0]=="string"&&this.hasParams(s[0]):this.hasParams(s)},hasParams(s){return h.isString(s)&&s.includes("[[")},_getWatcherProps(s){let t=me.get(s);if(t!==void 0)return t;let e=s.match(Gt),r=e?e.map(i=>i.slice(2,-2)):null;return me.set(s,r),r},updateAttr(s,t,e){switch(t){case"text":case"textContent":s.textContent=e;break;case"disabled":s.disabled=!e;break;case"checked":s.checked=!!e;break;case"required":s.required=!!e;break;case"src":if(s.tagName==="IMG"){s.src=e&&(e.indexOf(".")!==-1||e.indexOf("blob:")!==-1)?e:"";break}s.src=e;break;default:C.addAttr(s,t,e);break}},replaceParams(s,t,e=!1){let r=0;return s.replace(Gt,function(i,n,o){let a=e?t[r]:t;r++;let c=a.get(o);return typeof c<"u"&&c!==null?c:""})},_getWatcherCallBack(s,t,e,r,i){return()=>{let n=this.replaceParams(e,t,i);this.updateAttr(s,r,n)}},getValue(s,t){let e=s.value;return Array.isArray(e)===!1?[e,E(t)]:(e.length<2&&e.push(E(t)),e)},getPropValues(s,t,e){let r=[];for(let i=0,n=t.length;i<n;i++){let a=(e?s[i]:s).get(t[i])??"";r.push(a)}return r},getCallBack(s,t,e,r,i,n){let o=s.attr||"textContent",a=s.callBack;if(typeof a=="function"){let c=n||r.match(Gt)||[],u=c.length>1;return(l,d)=>{l=u!==!0?l:this.getPropValues(e,c,i);let p=a(l,t,d);typeof p<"u"&&this.updateAttr(t,o,p)}}return this._getWatcherCallBack(t,e,r,o,i)},addDataWatcher(s,t,e){let r=this.getValue(t,e),i=r[1]??e?.data??e?.context?.data??e?.state??null;if(!i)return;let n=r[0],o=Array.isArray(i),a=this._getWatcherProps(n),c=this.getCallBack(t,s,i,n,o,a);if(o)for(let u=0,l=a.length;u<l;u++)this.addWatcher(s,i[u],a[u],c);else for(let u=0,l=a.length;u<l;u++)this.addWatcher(s,i,a[u],c)},getWatcherSettings(s,t=null){if(typeof s=="string")return{attr:t,value:s};if(Array.isArray(s)){let e=s[s.length-1];e&&typeof e=="object"&&(e=t!==null?t:null);let r=s[1]&&typeof s[1]=="object"?[s[0],s[1]]:[s[0]];return typeof e=="function"?{attr:t,value:r,callBack:e}:{attr:e||"textContent",value:r}}return s},setup(s,t,e){t&&this.addDataWatcher(s,this.getWatcherSettings(t),e)},addWatcher(s,t,e,r){S.watch(s,t,e,r)}};var kr=s=>({props:{watch:s},children:[]}),Cr=s=>{if(!s)return yt();let t=s[0],e=typeof t;if(e==="string"||e==="number")return bt(t);if(Array.isArray(t))return w.isWatching(t)===!1?xt(t):kr(t);let r=s[1]??s[0]??[];return r&&Array.isArray(r)&&w.isWatching(r)===!0&&(s[0]=Array.isArray(s[0])?{}:s[0],s[0].watch=r,s[1]=[]),St(s)},wr=s=>(...t)=>{let{props:e,children:r}=Cr(t);return s(e,r)};var ge=new WeakMap,ye=new WeakMap;function Dr(s,t,e,r){let i=ge.get(s);i||(i=new Map,ge.set(s,i));let n=i.get(e);if(n)return n;let o=new Proxy(s,xe(t,e,r));return i.set(e,o),o}function be(s,t){let e=isNaN(Number(t)),r=e?t:`[${t}]`;return s===""?r:e?`${s}.${r}`:`${s}${r}`}function xe(s,t="",e=""){return{get(r,i,n){let o=r[i];if(t===""&&i in r){if(typeof o=="function"){let c=ye.get(r);c||(c=new Map,ye.set(r,c));let u=c.get(i);if(u)return u;let l=o.bind(r);return c.set(i,l),l}return o}if(o=(r[e]||r)[i],o!==null&&typeof o=="object"){let c=be(t,i);return Dr(o,s,c,e)}return o},set(r,i,n,o){if(t===""&&i in r)return r[i]=n,!0;let a=be(t,i);return s.set(a,n),!0}}}var Et=(s,t="stage")=>new Proxy(s,xe(s,"",t));var at=class{static resume(t,e){if(!t)return null;let r,i=localStorage.getItem(t);return i===null?e&&(r=e):r=JSON.parse(i),r}static store(t,e){if(!t||!e)return!1;let r=JSON.stringify(e);return localStorage.setItem(t,r),!0}static remove(t){return t?(localStorage.removeItem(t),!0):!1}};var Pt=(s={})=>{let t={};if(!h.isObject(s))return t;let e=Object.keys(s);for(let r=0,i=e.length;r<i;r++){let n=e[r],o=s[n];typeof o!="function"&&(t[n]=o)}return t};var Tr=0,Se=new Map,N={CHANGE:"change",DELETE:"delete"},Kt=(s,t)=>{let e=Se.get(s);return e||(e={change:`${s}:change`,delete:`${s}:delete`},Se.set(s,e)),t==="change"?e.change:e.delete},M=class{constructor(t={}){this.dirty=!1,this.links=new Map,this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new q;let e=Pt(t);return this.set(e),Et(this)}setup(){this.stage={}}_init(){let t=++Tr;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}onFlush(t){this.eventSub.onFlush(t)}flushPending(){this.eventSub.flush()}getDataId(){return String(this._id)}remove(){}on(t,e){let r=Kt(t,N.CHANGE);return this.eventSub.on(r,e)}off(t,e){let r=Kt(t,N.CHANGE);this.eventSub.off(r,e)}_setAttr(t,e,r=this,i=!1){let n=this.stage[t];e!==n&&(this.stage[t]=e,this._publish(t,e,r,N.CHANGE))}publishLocalEvent(t,e,r,i){let n=Kt(t,i);this.eventSub.publish(n,e,r)}_publish(t,e,r,i){this.publishLocalEvent(t,e,r,i),r=r||this,S.publish(this._dataId+t,e,r)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,i]=t,n=Object.keys(e);for(let o=0;o<n.length;o++){let a=n[o],c=e[a];typeof c!="function"&&this._setAttr(a,c,r,i)}return this}getModelData(){return this.stage}_deleteAttr(t,e,r=this){delete t[e],this.publishLocalEvent(e,null,r,N.DELETE)}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r+e),this}decrement(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r-e),this}concat(t,e){if(typeof t>"u")return;let r=this.get(t);return this.set(t,r+e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){return this.key=t,this}resume(t){let e=at.resume(String(this.key),t);return e?(this.set(e),this):this}store(){let t=this.get();return at.store(String(this.key),t)}delete(t){return typeof t=="string"?(this._deleteAttr(this.stage,t),this):(this.setup(),this)}_getAttr(t,e){return t[e]}get(t){return typeof t<"u"?this._getAttr(this.stage,t):this.getModelData()}link(t,e,r){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,r);let i=[];return Object.entries(e).forEach(([n])=>{i.push(this.remoteLink(t,n))}),i}remoteLink(t,e,r){let i=r||e,n=t.get(e);typeof n<"u"&&this.get(e)!==n&&this.set(e,n);let o=t.on(e,(c,u)=>{if(u===this)return!1;this.set(i,c,t)});this.addLink(o,t);let a=this.on(i,(c,u)=>{if(u===t)return!1;t.set(e,c,this)});return t.addLink(a,this),o}addLink(t,e){this.links.set(t,e)}unlink(t){if(t){this.removeLink(t);return}let e=this.links;b.isEmpty(e)||(e.forEach((r,i)=>{this.removeLink(i,!1)}),this.links=new Map)}removeLink(t,e=!0){let r=this.links.get(t);r&&r.off(t),e!==!1&&this.links.delete(t)}};M.prototype.isData=!0;var Zt=class{constructor(t=1e3){this.cache=new Map,this.maxSize=t}get(t){return this.cache.get(t)}set(t,e){if(this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.maxSize){let r=this.cache.keys().next().value;this.cache.delete(r)}}clear(){this.cache.clear()}},P={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,segmentCache:new Zt(1e3),hasDeepData(s){return s.indexOf(".")!==-1||s.indexOf("[")!==-1},getSegments(s){let t=this.segmentCache.get(s);if(t!==void 0)return t;let e=this.deepDataPattern;return t=s.match(e),this.segmentCache.set(s,t),t}};var _=class{static set(t,e,r){if(!P.hasDeepData(e)){t[e]=r;return}let i,n=P.getSegments(e);if(!n)return;let o=n.length,a=o-1;for(let c=0;c<o;c++){let u=n[c];if(c===a){t[u]=r;break}t[u]===void 0&&(t[u]=isNaN(u)?{}:[]),t=t[u]}}static delete(t,e){if(!P.hasDeepData(e)){delete t[e];return}let r=P.getSegments(e);if(!r)return;let i=r.length,n=i-1;for(let o=0;o<i;o++){let a=r[o],c=t[a];if(c===void 0)break;if(o===n){if(Array.isArray(t)){t.splice(Number(a),1);break}delete t[a];break}t=c}}static get(t,e){if(!P.hasDeepData(e))return t[e]??void 0;let r=P.getSegments(e);if(!r)return;let i=r.length,n=i-1;for(let o=0;o<i;o++){let a=r[o],c=t[a]??void 0;if(c===void 0)break;if(t=c,o===n)return t}}};var ve=new Set,ct=class{static MAX_DEPTH=50;static publishDeep(t,e,r,i){if(!P.hasDeepData(e)){this.publish(e,r,i);return}let n,o=P.getSegments(e);if(!o)return;let a=o.length,c=a-1,u="";for(let l=0;l<a;l++){let d=o[l];t=t[d],l>0?isNaN(d)&&(u+="."+d):u=d;let p;if(l===c)p=r;else{let x=o[l+1];if(isNaN(x)===!1){u+="["+x+"]";continue}let D={};D[x]=t[x],p=D}this.publish(u,p,i)}}static publish(t,e,r,i=null,n=0){if(t=t||"",r(t,e),!(!e||typeof e!="object"||(i===null&&(ve.clear(),i=ve),!i))){if(i.has(e)){console.warn("[Publisher] Circular reference detected at path:",t);return}if(n>=this.MAX_DEPTH){console.warn("[Publisher] Max depth exceeded at path:",t,"- stopping recursion");return}i.add(e),Array.isArray(e)?this.publishArray(t,e,r,i,n):this.publishObject(t,e,r,i,n)}}static publishArray(t,e,r,i,n){let o=e.length;for(let a=0;a<o;a++){let c=e[a],u=t+"["+a+"]";this._checkPublish(u,c,r,i,n)}}static publishObject(t,e,r,i,n){let o=Object.keys(e);for(let a=0,c=o.length;a<c;a++){let u=o[a],l=e[u],d=t+"."+u;this._checkPublish(d,l,r,i,n)}}static _checkPublish(t,e,r,i,n){if(!e||typeof e!="object"){r(t,e);return}this.publish(t,e,r,i,n+1)}};var I=class extends M{setup(){this.attributes={},this.stage={}}_setAttr(t,e,r,i){typeof e!="object"&&e===this.get(t)||(!r&&i!==!0?_.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),_.set(this.stage,t,e),r=r||this,this._publish(t,e,r,N.CHANGE))}linkAttr(t,e){let r=t.get(e);if(!r)return;let i=Object.keys(r);for(let n=0,o=i.length;n<o;n++){let a=i[n];this.link(t,e+"."+a,a)}}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let i=new e(r);return i.linkAttr(this,t),i}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.push(e),this.set(t,r),this}concat(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r=r.concat(e),this.set(t,r),this}unshift(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.unshift(e),this.set(t,r),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.shift();return this.set(t,e),r}getIndex(t,e,r){let i=this.get(t);return Array.isArray(i)===!1?-1:typeof i[0]!="object"?i.indexOf(e):i.findIndex(o=>o[e]===r)}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.pop();return this.set(t,e),r}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,r,i){let n=(o,a)=>this._publishAttr(o,a,r,i);ct.publish(t,e,n)}_publishAttr(t,e,r,i){let n=this._dataId+t;S.publish(n,e,r),this.publishLocalEvent(t,e,r,i)}mergeStage(){this.attributes=b.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e,r=this){_.delete(t,e);let i=(n,o)=>this.publishLocalEvent(n,o,r,N.DELETE);ct.publish(e,e,i)}_getAttr(t,e){return _.get(t,e)}};var Ar={"\n":"\\n","\r":"\\n"," ":"\\t"},Er=(s,t)=>{typeof s!="string"&&(s=String(s));let e=t?/[\n\r\t]/g:/\t/g;return s.replace(e,r=>Ar[r])},ke=(s,t)=>{if(typeof s!="string")return s;s=Er(s,t),s=encodeURIComponent(s);let e=/%22/g;return s.replace(e,'"')},te=(s,t)=>{let e=typeof s;return e==="undefined"?s:e!=="object"?(s=ke(s),s):(Object.entries(s).forEach(([r,i])=>{i!==null&&(s[r]=typeof i=="string"?te(i,t):ke(i,t))}),s)};function Ce(s){return typeof s<"u"&&s.length>0?JSON.parse(s):!1}function ee(s){return typeof s<"u"?JSON.stringify(s):null}var ut=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?b.clone(t):t,i=te(r,e);return ee(i)}static json={encode:ee,decode:Ce};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var Ot=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=v.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=v.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),i="id="+r,n=r?`/${r}`:"",o=this.model;return this._get(n,i,t,e,a=>{if(a){let c=this.getObject(a);c&&o.set(c)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+ut.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=i!=null?`/${i}`:"";return this._put(n,r,t,e)}add(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=i!=null?`/${i}`:"";return this._post(n,r,t,e)}update(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=i!=null?`/${i}`:"";return this._patch(n,r,t,e)}delete(t,e){let r=this.model.get("id"),i=typeof r<"u"?"id="+r:this.setupObjectData(),n=r!=null?`/${r}`:"";return this._delete(n,i,t,e)}all(t,e,r,i,n=null,o=null){let a=this.model.get();r=isNaN(r)?0:r,i=isNaN(i)?50:i;let c=a.search||"",u=a.filter||"";typeof u=="object"&&(u=JSON.stringify(u));let l=a.dates||"";typeof l=="object"&&(l=JSON.stringify(l));let d=a.orderBy||"";typeof d=="object"&&(d=JSON.stringify(d));let p=a.groupBy||"";Array.isArray(p)&&(p=JSON.stringify(p));let x="&filter="+u+"&offset="+r+"&limit="+i+"&dates="+l+"&orderBy="+d+"&groupBy="+p+"&search="+c+"&lastCursor="+(typeof n<"u"&&n!==null?n:"")+"&since="+(typeof o<"u"&&o!==null?o:"");return this._get("",x,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);t[0]==="/"&&(t=t.substring(1));let r=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(r)}setupRequest(t,e,r,i,n){let o={url:this.getUrl(t),method:e,params:r,completed:(c,u)=>{typeof n=="function"&&n(c),this.getResponse(c,i,u)}};return this._isFormData(r)&&(o.headers={}),gt(o)}setupEventSource(t,e,r,i,n=!0){let o=null,a=null,c=!1,u=!1,l=()=>{a&&(clearTimeout(a),a=null)},d=()=>{if(c||!n||u)return;l(),a=setTimeout(()=>{a=null,p()},3e3)},p=()=>{if(c||u)return;if(o){try{o.close()}catch{}o=null}u=!0;let x=this.getUrl(t),D=e?"?"+e:"";o=new EventSource(x+D,{withCredentials:!0}),o.onopen=()=>{u=!1,l(),i&&i()},o.onerror=()=>{u=!1,o&&o.readyState===EventSource.CLOSED&&(o=null,d())},o.onmessage=et=>{try{let ft=JSON.parse(et.data);r&&r(ft)}catch{}}};return p(),{get source(){return o},close:()=>{if(c=!0,u=!1,l(),o){try{o.close()}catch{}o=null}}}}replaceUrl(t){return w.isWatching(t)&&(t=w.replaceParams(t,this.model)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t}_isFormData(t){return t instanceof FormData}request(t,e,r,i){return this._request("","POST",t,e,r,i)}_get(t,e,r,i,n){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",i,n)}_post(t,e,r,i,n){return this._request(t,"POST",e,r,i,n)}_put(t,e,r,i,n){return this._request(t,"PUT",e,r,i,n)}_patch(t,e,r,i,n){return this._request(t,"PATCH",e,r,i,n)}_delete(t,e,r,i,n){return this._request(t,"DELETE",e,r,i,n)}_request(t,e,r,i,n,o){return r=this.setupParams(r),r=this.addParams(r,i),this.setupRequest(t,e,r,n,o)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;let e=this;class r extends e{constructor(n){super(n)}}return Object.assign(r.prototype,t),r}};var Pr=s=>{let t={};if(!h.isObject(s)||!s.defaults)return t;let{defaults:e}=s;return Object.keys(e).forEach(r=>{let i=e[r];typeof i!="function"&&(t[r]=i)}),delete s.defaults,t},Or=s=>{if(!s||typeof s.xhr!="object")return{};let t={...s.xhr};return delete s.xhr,t},Mr=0,J=class extends I{constructor(t){let e=super(t);return this.initialize(),e}setup(){this.attributes={},this.stage={},this.url=this.url||"",this.xhr=this.xhr||{}}initialize(){}static extend(t={}){let e=this,r=Or(t),i=e.prototype.service.extend(r),n=Pr(t);class o extends e{constructor(c){let u={...n,...Pt(c)};super(u),this.xhr=new i(this)}dataTypeId=`bm${Mr++}`}return Object.assign(o.prototype,t),o.prototype.service=i,o}};J.prototype.service=Ot;var L=class extends M{};var Q=class extends L{setup(){this.stage={}}addAction(t,e){return typeof e<"u"&&this.set(t,e),this}getState(t){return this.get(t)}removeAction(t,e){if(e)return this.off(t,e),this;let r=this.stage;return typeof r[t]<"u"&&delete r[t],this}};var Mt=class extends Q{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=""}};var B=class{static targets=new Map;static restore(t,e){this.targets.set(t,e)}static getTarget(t){return this.targets.has(t)||this.targets.set(t,new Mt(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let i=this.getTarget(t);return e&&i.addAction(e,r),i}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){r&&this.off(t,e,r)}static on(t,e,r){let i=this.getTarget(t);return e?i.on(e,r):null}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let i=this.targets,n=i.get(t);if(n){if(e){n.off(e,r);return}this.targets.delete(t)}}static set(t,e,r){this.getTarget(t).set(e,r)}};var It=class{constructor(){this.events=[]}addEvents(t){t.length<1||t.forEach(r=>{this.on(...r)})}on(t,e,r,i){f.on(t,e,r,i),this.events.push({event:t,obj:e,callBack:r,capture:i})}off(t,e,r,i){f.off(t,e,r,i);let n,o=this.events;for(var a=0,c=o.length;a<c;a++)if(n=o[a],n.event===t&&n.obj===e){o.splice(a,1);break}}set(){this.events.forEach(t=>{f.on(t.event,t.obj,t.callBack,t.capture)})}unset(){this.events.forEach(t=>{f.off(t.event,t.obj,t.callBack,t.capture)})}reset(){this.unset(),this.events=[]}};var Bt=class{constructor(t,e){this.remoteStates=[];let r=this.convertStates(e);this.addStatesToTarget(t,r)}addStates(t,e){let r=this.convertStates(e);this.addStatesToTarget(t,r)}createState(t,e,r,i){return{action:t,state:e,callBack:r,targetId:i,token:null}}convertStates(t){let e=[];for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}let i=null,n=null,o=t[r];o&&typeof o=="object"&&(n=o.callBack,i=o.id||o.targetId,o=o.state),e.push(this.createState(r,o,n,i))}return e}setupRemoteStates(t,e){for(let r=0,i=t.length;r<i;r++){let n=t[r];if(n)for(let o in n){if(!Object.prototype.hasOwnProperty.call(n,o)||o==="id")continue;let a=null,c=n[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,n.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(let r=0,i=e.length;r<i;r++){let n=e[r];n.token&&this.unbindRemoteState(t,n.token),n.targetId&&B.remove(n.targetId,n.action,n.token)}}restore(t){B.restore(t.id,t);let e=this.remoteStates;if(e)for(let r=0,i=e.length;r<i;r++){let n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let i=B.getTarget(r);return t.link(i,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(let i=0,n=e.length;i<n;i++){let o=e[i],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}}addAction(t,e){let r,i=e.action,n=e.targetId;n&&(r=this.bindRemoteState(t,i,n)),typeof e.state<"u"&&t.addAction(i,e.state);let o=e.callBack;return typeof o=="function"&&t.on(i,o),r||null}};var we=s=>{if(!s)return yt();let t=s[0],e=typeof t;return e==="string"||e==="number"?bt(t):Array.isArray(t)?xt(t):St(s)};m.addType("components",s=>{if(!s)return;let t=s.component;!t||!t.isUnit||(t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken),t.rendered===!0&&(t.prepareDestroy(),t.cleanUpAfterDestroy()))});var Ir=0,ht=class{constructor(...t){this.isUnit=!0,this.data=null,this.persist=null,this.nest=null,this.state=null,this.panel=null,this.parent=null,this.unitType=null,this._classId,this.cached=[],this.init();let{props:e,children:r}=we(t);this.setupProps(e),this.children=r||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Ir++,this.unitType=this._classId||this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=this.persistedCount++,r="pc"+e,n=Object.keys(this.persistedChildren)[e],o=this.persistedChildren[n];return o&&t.unitType===o.unitType&&(r=n,t.resumeScope(o)),t.persistToken=r,this.persistedChildren[r]=t,r}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){let t=this.getParentContext(),e=this.setContext(t);if(e){this.context=e;return}this.context=t,this.setupAddingContext()}setupAddingContext(){let t=this.context,e=this.addContext(t);if(!e)return;let r=e[0];r&&(this.addingContext=!0,this.contextBranchName=r,this.addContextBranch(r,e[1]))}addContextBranch(t,e){this.context??={},this.context[t]=e}setContext(t){return null}addContext(t){return null}removeContext(){this.addingContext&&this.removeContextBranch(this.contextBranchName)}removeContextBranch(t){t&&delete this.context[t]}getContext(){return this.context}onCreated(){}render(){return{}}_cacheRoot(t){return t&&(t.id||(t.id=this.getId()),t.cache="panel",t)}_createLayout(){return this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}afterBuild(){m.add(this.panel,"components",{component:this}),this.rendered=!0,this.afterLayout()}afterLayout(){this.afterSetup()}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var i=0,n=t.length;i<n;i++){let o=e(t[i],i);r.push(o)}return r}removeAll(t){return T.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),String(e)}cacheEle(t,e){e&&(this[e]=t,this.cached.push(e))}initialize(){this.setupContext(),this.beforeSetup()}beforeSetup(){}afterSetup(){}setup(t){this.setContainer(t),this.initialize()}setContainer(t){this.container=t}_remove(){this.prepareDestroy(),this.removeContext();let t=this.panel;t&&T.removeElement(t),this.cleanUpAfterDestroy()}cleanUpAfterDestroy(){this.panel=null,this.container=null,this.cached.forEach(t=>{this[t]=null}),this.cached=[],this.persist!==!0&&(this.persistedChildren={},this.persistToken=null)}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&typeof this.data.unlink=="function"&&this.data.unlink()}beforeDestroy(){}destroy(){this._remove()}};var k=class extends ht{constructor(...t){super(...t),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this.data=t.data,this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,t.context&&(this.context=t.context),this.id=t.id,this._refreshData()}_refreshData(){let t=this.setData();t&&this.data&&this.data.set(t.stage),this._refreshContextData()}_refreshContextData(){let t=this.context;if(!t||!t.data)return;let e=this.getParentContext();!e||!e.data||t.data.set(e.data.stage)}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=B.getTarget(String(e))}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();b.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new Bt(this.state,t))}addState(t){!this.stateHelper||this.stateResumed==!0||this.stateHelper.addStates(this.state,t)}removeStates(){let t=this.state;t&&(this.stateHelper.removeRemoteStates(t),t.remove(),this.stateResumed=!1)}onFlush(t){let e=this.data??this?.context?.data??null;e&&e.onFlush(t)}setEventHelper(){this.events||(this.events=new It)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events&&this.events.addEvents(t))}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&this.persist!==!0&&this.data.unlink()}};var Rt={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var Br=(s,t)=>typeof s!="function"&&t==="setupStates"?()=>s:s,re=(s,t)=>(s&&Object.entries(s).forEach(([e,r])=>{let i=Rt[e]||e;t[i]=Br(r,i)}),t),Rr=s=>re(s,{}),Hr=0,De=(s,t)=>{class e extends s{}return Object.assign(e.prototype,t),e.prototype._classId="jot"+Hr++,e},F=(s,t=k)=>{s||(s={});let e,r=typeof s;return r==="object"&&s.render?(e=Rr(s),De(t,e)):(e={render:r==="function"?s:()=>s},De(t,e))};var Nr=(s,t)=>(Object.entries(s).forEach(([e,r])=>{let i=Rt[e]||e;t.prototype[i]=r}),t),_r=0,Lr=s=>{let t=class extends s{};return t.prototype._classId="pod"+_r++,t},Fr=(s,t=k)=>{if(!s)return null;let e=Lr(t),r={},i=s(r);return Nr(r,e),e.prototype.render=i,e};var Ur={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],getDayName(s=new Date().getDay(),t=!1){if(typeof Intl<"u"){let i=new Date(2004,0,4+s);return new Intl.DateTimeFormat(void 0,{weekday:t?"short":"long"}).format(i)}let e=this.dayNames;if(s>e.length)return null;let r=e[s];return t?r.substring(0,3):r},convertJsMonth(s){return this.padNumber(s+1)},convertDate(s,t=!1){s=s?s.replace(/\s/,"T"):"";let e=new Date(s);if(typeof Intl<"u"){let i={weekday:"long",month:"short",day:"2-digit"};return t&&(i.year="numeric"),new Intl.DateTimeFormat(void 0,i).format(e)}let r=t===!0?" "+e.getFullYear():"";return this.getDayName(e.getDay())+", "+this.getMonthName(e.getMonth(),!0)+" "+this.padNumber(e.getDate())+r},padNumber(s){return s<=9?"0"+s:String(s)},createDate(s){return s?(typeof s=="string"&&s.indexOf("-")>-1&&(s=s.replace(/\s/,"T"),s=s.indexOf(":")>-1?s:s+"T00:00:00"),new Date(s)):new Date},format(s,t){let e=this.createDate(t);return s!=="sql"&&typeof Intl<"u"?new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}).format(e):this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),s)},formatTime(s,t){let e=this.createDate(s);if(t!==24&&typeof Intl<"u")return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!0}).format(e);let r=t===24?"sql":"standard";return this.renderTime(e.getHours(),e.getMinutes(),e.getSeconds(),r)},getMeridian(s){return s=Number(s),s>=12?"PM":"AM"},convert24To12(s){return s=Number(s),s>12&&(s=s-12),s},convert12To24(s,t){return s=Number(s),t.toLowerCase()==="pm"&&(s=s+12),s},renderDate(s,t,e,r="sql"){return t=Number(t),e=Number(e),r==="sql"?`${s}-${this.padNumber(t)}-${this.padNumber(e)}`:`${this.padNumber(t)}/${this.padNumber(e)}/${s}`},renderTime(s,t,e=0,r="sql"){if(r==="sql")return`${this.padNumber(s)}:${this.padNumber(t)}:${this.padNumber(e)}`;let i=this.getMeridian(s);return s=this.convert24To12(s),`${s}:${this.padNumber(t)} ${i}`},leapYear(s){return s%400===0||s%100!==0&&s%4===0},getMonthName(s=new Date().getMonth(),t=!1){if(typeof Intl<"u"){let i=new Date(2e3,s,1);return new Intl.DateTimeFormat(void 0,{month:t?"short":"long"}).format(i)}let e=this.monthNames;if(s>e.length)return"";let r=e[s];return r?t?r.substring(0,3):r:""},getMonthLength(s,t){let e=new Date;return s=typeof s<"u"?s:e.getMonth(),t=typeof t<"u"?t:e.getFullYear(),this.getMonthsLength(t)[s]},getMonthsLength(s=new Date().getFullYear()){return this.leapYear(s)===!0?[31,29,31,30,31,30,31,31,30,31,30,31]:[31,28,31,30,31,30,31,31,30,31,30,31]},getLocalDate(s,t="America/Denver"){let e=new Date(s);if(Number.isNaN(e.getMonth())===!0){let n=/[- :]/,o=s.split(n);e=new Date(o[0],o[1]-1,o[2],o[3],o[4],o[5])}let r=new Date(Date.parse(e.toLocaleString("en-US",{timeZone:t}))),i=e.getTime()-r.getTime();return new Date(e.getTime()+i)},getLocalTime(s,t=!1,e=!1,r="America/Denver"){if(!s)return"";let i=this.getLocalDate(s,r);if(!t&&typeof Intl<"u"){let c={hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0};return e===!1&&(c.year="numeric",c.month="2-digit",c.day="2-digit"),new Intl.DateTimeFormat(void 0,c).format(i)}let n=i.getMonth()+1,o=t===!0?"sql":"standard",a="";return e===!1&&(a+=this.renderDate(i.getFullYear(),n,i.getDate(),o)+" "),a+this.renderTime(i.getHours(),i.getMinutes(),i.getSeconds(),o)},getDiffFromNow(s,t=!1){s=s.replace(/\s/,"T");let e=new Date(s),r=new Date;return t===!0&&r.setHours(0,0,0,0),r.getTime()-e.getTime()},getAge(s){let t=this.getDiffFromNow(s),e,r;switch(!0){case t<864e5:e="1 day";break;case t<6048e5:r=this.toDays(t),e=r+" days";break;case t<12096e5:e="1 week";break;case t<2592e6:r=this.toDays(t);var i=Math.floor(r/7);e=i+" weeks";break;case t<5184e6:e="1 month";break;case t<31104e6:var n=this.toMonths(t);e=n+" months";break;default:var o=this.toYears(t);e=o}return String(e)},getTimeFrame(s){let t=this.getDiffFromNow(s);return this.convertToEstimate(t)},convertToEstimate(s){let t="",e,r,i,n,o,a,c;if(s<=0)switch(!0){case s<-63072e6:i=this.toYears(Math.abs(s)),t="in "+i+" y";break;case s<-31536e6:t="in 1y";break;case s<-5184e6:n=this.toMonths(Math.abs(s)),t="in "+n+"mo";break;case s<-2592e6:t="in 1mo";break;case s<-12096e5:e=this.toDays(Math.abs(s)),r=Math.floor(e/7),t="in "+r+"w";break;case s<-6048e5:t="in 1w";break;case s<-1728e5:e=this.toDays(Math.abs(s)),t="in "+e+"d";break;case s<-864e5:t="tomorrow";break;case s<-72e5:o=this.toHours(Math.abs(s)),t="in "+o+" h";break;case s<=-36e5:t="in 1h";break;case s<-12e4:a=this.toMinutes(Math.abs(s)),t="in "+a+"m";break;case s<-6e4:t="in 1m";break;case s<-2e3:c=this.toSeconds(Math.abs(s)),t="in "+c+"s";break;case s<-1:t="in 1s";break;default:t="now"}else switch(!0){case s<1e3:t="1s ago";break;case s<6e4:c=this.toSeconds(s),t=c+"s ago";break;case s<12e4:t="1m ago";break;case s<36e5:a=this.toMinutes(s),t=a+"m ago";break;case s<72e5:t="1h ago";break;case s<864e5:o=this.toHours(s),t=o+"h ago";break;case s<1728e5:t="yesterday";break;case s<6048e5:e=this.toDays(s),t=e+"d ago";break;case s<12096e5:t="1w ago";break;case s<2592e6:e=this.toDays(s),r=Math.floor(e/7),t=r+"w ago";break;case s<5184e6:t="1mo ago";break;case s<31536e6:n=this.toMonths(s),t=n+"mo ago";break;case s<63072e6:t="1y ago";break;default:i=this.toYears(s),t=i+"y ago"}return t},toYears(s){return typeof s!="number"?0:Math.floor(s/31558464e3)},toMonths(s){return typeof s=="number"?Math.floor(s/2592e6):0},toDays(s){return typeof s!="number"?0:Math.floor(s/864e5*1)},toHours(s){return typeof s!="number"?0:Math.floor(s%864e5/36e5*1)},toMinutes(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5/6e4*1)},toSeconds(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5%6e4/1e3*1)},getDifference(s,t){let e=new Date(s),r=new Date(t),i=r.getTime()-e.getTime();return{years:this.toYears(i),days:this.toDays(i),hours:this.toHours(i),minutes:this.toMinutes(i),seconds:this.toSeconds(i)}}};var Te=(s,t)=>({name:s,callBack:t});var Y={keys:[],items:{},add(s,t){return this.keys.push(s),this.items[s]=Te(s,t),this},get(s){return this.items[s]||null},all(){return this.keys}};var se=(s,t)=>({attr:s,directive:t});var U=(s,t)=>({key:s,value:t});var Ae=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var H=class{static getTag(t){return t.tag||"div"}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,r,i){return t==="text"?(i.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(r.push(U("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){t.push(se(U(e,w.getWatcherSettings(r,nt(e))),Y.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let i=e.type||"button";r.push(U("type",i))}}static parse(t,e){let r=[],i=[],n=this.getTag(t);this.setButtonType(n,t,r),this.setupChildren(t);let o=[],a,c,u=Object.keys(t);for(let l=0,d=u.length;l<d;l++){let p=u[l];if(p==="tag"||(a=t[p],a==null))continue;if(p==="children"){if(Array.isArray(a))for(let D=0;D<a.length;D++)o.push(a[D]);else o.push(a);continue}if((c=Y.get(p))!==null){i.push(se(U(p,a),c));continue}let x=typeof a;if(x==="object"){if(w.isWatching(a)){this.setTextAsWatcher(i,p,a);continue}o.push(a);continue}if(x==="function"){let D=a,et=function(ft){D.call(this,ft,e)};et.originalCallback=D,r.push(U(p,et));continue}if(w.isWatching(a)){this.setTextAsWatcher(i,p,a);continue}this.setElementContent(p,a,r,o)||r.push(U(p,a))}return Ae(n,r,i,o)}};var X=class{build(t,e,r){}setupComponent(t,e,r){let i=r?.getChildScope();t.parent=i,i&&i.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&i&&(i[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),r=this.build(e,t.container,t);return t.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(t),r}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t),t}setDirectives(t,e,r){}removeNode(t){}removeAll(t){}};var Ht=class extends X{build(t,e,r){let i=C.createDocFragment();if(Array.isArray(t))for(let n=0,o=t.length;n<o;n++)this.buildElement(t[n],i,r);else this.buildElement(t,i,r);return e&&typeof e=="object"&&e.appendChild(i),i}buildElement(t,e,r){if(t){if(t.isUnit===!0){this.createComponent(t,e,r);return}this.createElement(t,e,r)}}createElement(t,e,r){let i=r?.getChildScope();if(t.data||t.state){this.createTempComponent(t,e,i);return}let n=H.parse(t,i),o=this.createNode(n,e,i);this.cache(o,t.cache,r);let a=n.children;for(let u=0,l=a.length;u<l;u++){let d=a[u];d!==null&&this.buildElement(d,o,r)}let c=n.directives;c&&c.length&&this.setDirectives(o,c,i)}createTempComponent(t,e,r){let i={cache:t.cache,setData:()=>t.data,...re(t.methods||{},{}),render(){return{...t,data:null,state:null}}};t.state&&(i.setupStateTarget=function(o){this.state=t.state});let n=new k(i);this.createComponent(n,e,r)}setDirectives(t,e,r){for(let i=0,n=e.length;i<n;i++)this.handleDirective(t,e[i],r)}handleDirective(t,e,r){e.directive.callBack(t,e.attr.value,r)}cache(t,e,r){r&&e&&r.cacheEle(t,e)}createNode(t,e,r){let i=t.tag;if(i==="text"){let n=t.attr[0],o=n?n.value:"";return C.createText(o,e)}else if(i==="comment"){let n=t.attr[0],o=n?n.value:"";return C.createComment(o,e)}return C.create(i,t.attr,e,r)}removeNode(t){C.removeElement(t)}removeAll(t){C.removeAll(t)}};var Wr=["area","base","br","col","embed","hr","img","input","link","meta","source"],G=class{static create(t,e=[],r=""){let i=this.getInnerContent(e);i+=this.getInnerHtml(e);let n=this.createAttributes(e);return Wr.includes(t)?`<${t} ${n} />`:`<${t} ${n}>`+i+r+`</${t}>`}static getInnerContent(t){let e="";return t.forEach(({key:r,value:i},n)=>{if(r!=="text"&&r!=="textContent")return"";t.splice(n,1),e+=i}),e}static getInnerHtml(t){let e="";return t.forEach(({key:r,value:i},n)=>{if(r!=="html"&&r!=="innerHTML")return"";t.splice(n,1),e+=i}),e}static createAttributes(t=[]){return!t||t.length<1?"":t.map(e=>{let{key:r,value:i}=e;return typeof i=="function"&&(r="on"+ot(r)),`${r}="${i}"`}).join(" ")}static createText(t){return t}static createComment(t){return`<!-- ${t} -->`}};var Nt=class extends X{build(t,e,r){return(Array.isArray(t)?t:[t]).map(n=>this.buildElement(n,r)).join("")}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t)}buildElement(t,e){return t?t.isUnit===!0?this.createComponent(t,{},e):this.createElement(t,e):""}createElement(t,e){let r=H.parse(t,e),i=r.children.map(n=>n!==null?this.buildElement(n,e):"").join("");return this.createNode(r,i)}createNode(t,e){let r=t.tag;if(r==="text"){let i=t.attr[0],n=i?i.value:"";return G.createText(n)}else if(r==="comment"){let i=t.attr[0],n=i?i.value:"";return G.createComment(n)}return G.create(r,t.attr,e)}removeAll(t){}};var _t=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new Ht:new Nt}};var W=_t.setup(),jr=s=>typeof s=="object"&&s.isUnit===!0,$r=s=>{let t=F(s);return t?new t:null},g=class{static render(t,e,r){return!t||(jr(t)||(t=$r(t)),!t)?null:W.createComponent(t,e,r)}static build(t,e,r){return W.build(t,e,r)}static rebuild(t,e,r){return W.removeAll(e),this.build(t,e,r)}static setDirectives(t,e,r){W.setDirectives(t,e,r)}static createNode(t,e,r){return W.createNode(t,e,r)}static removeNode(t){W.removeNode(t)}static removeAll(t){W.removeAll(t)}};A.augment({buildLayout(s,t,e){g.build(s,t,e)}});var ie=[],Vr=s=>ie.indexOf(s)!==-1,zr=s=>({tag:"script",src:s.src,async:!1,load(t){ie.push(s.src);let e=s.load;e&&e()}}),qr=s=>({tag:"link",rel:"stylesheet",type:"text/css",href:s.src,load(t){ie.push(s.src);let e=s.load;e&&e()}}),Lt=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,r=this.update.bind(this);t.indexOf(".css")!==-1?e=qr({load:r,src:t}):e=zr({load:r,src:t}),g.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{Vr(e)||this.add(e)})}update(){if(this.updateProgress()<100)return;let e=this.callBack;e&&e()}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}};var Jr=s=>s?typeof s?.prototype?.constructor=="function":!1,K=class{static process(t,e){let r=t.default;return r?e.callback?e.callback(r):(Jr(r)?r=new r:r=r(),r.isUnit===!0&&(r.route=e.route,e.persist&&(r.persist=!0)),r):null}static render(t,e,r){let i=g.build(t,null,r),n=i.firstChild||t?.panel;return e.after(i),n}};var Ft=class{static load(t,e,r){return t.then(i=>(e&&e(i),i)).catch(i=>{console.error("Error loading module:",i),r&&r(i)})}};var Qr=s=>({tag:"comment",textContent:"import placeholder",onCreated:s.onCreated}),Ut=new Map,Yr=s=>{if(Ut.has(s)){let r=Ut.get(s);return r&&typeof r.then!="function"?Promise.resolve(r):r}let t=typeof s,e;if(t==="string")e=import(s);else if(t==="function")e=s();else return s;return e.then(r=>{Ut.set(s,r)}),Ut.set(s,e),e},Ee=F({declareProps(){this.loaded=!1,this.generation=0},render(){return Qr({onCreated:s=>{if(this.src){if(this.layout){this.layoutRoot=K.render(this.layout,this.panel,this.parent);return}if(this.depends){new Lt(()=>{this.loadAndRender(s)}).addFiles(this.depends);return}this.loadAndRender(s)}}})},loadAndRender(s){let t=this.generation;Ft.load(Yr(this.src),e=>{if(t!==this.generation)return;this.loaded=!0;let r=this.layout||K.process(e,{callback:this.callback,route:this.route,persist:this.persist});this.layout=r,this.layoutRoot=K.render(r,s,this.parent)},e=>{t===this.generation&&(this.loaded=!1)})},shouldUpdate(s){return this.updateLayout===!0?!0:this.updateLayout=s&&s.isUnit&&typeof s.update=="function"},updateModuleLayout(s){let t=this.layout;this.shouldUpdate(t)&&t&&t.update(s)},update(s){this.loaded===!0&&this.updateModuleLayout(s)},destroy(){this.generation++,this.layoutRoot&&(g.removeNode(this.layoutRoot),this.persist!==!0&&(this.layoutRoot=null,this.layout=null,this.loaded=!1,this.updateLayout=!1))}});var ne=s=>{let t=typeof s;return(t==="string"||t==="function"||s instanceof Promise)&&(s={src:s}),new Ee(s)};var Pe=(s,t,e=null)=>{if(!s)return;let r=null,i=!1,n=()=>{i||(i=!0,r&&(clearTimeout(r),r=null),f.off("animationend",s,o),s&&y.removeClass(s,t),e&&e())},o=a=>{a.target===s&&n()};f.on("animationend",s,o),requestAnimationFrame(()=>{if(!s){n();return}y.addClass(s,t);try{let a=window.getComputedStyle(s),c=parseFloat(a.animationDuration)*1e3||1e3,u=parseFloat(a.animationDelay)*1e3||0;r=setTimeout(n,c+u+100)}catch{r=setTimeout(n,1e3)}})},Oe=(s,t,e)=>{Pe(s,t)},Me=(s,t,e)=>{let r=()=>{s&&s.remove&&s.remove()};Xr(s,()=>Pe(s,t,r),e)};m.addType("manual-destroy",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var Xr=(s,t,e)=>{m.add(s,"manual-destroy",{ele:s,callBack:t,parent:e})};var lt=(s,t,e,r)=>{if(Array.isArray(e[0])){e.forEach(i=>{i&&lt(s,t,i,r)});return}Gr(s,t,e,r)},Gr=(s,t,e,r)=>{let i,n;if(e.length<3?[i,n]=e:[t,i,n]=e,!t||!i)return;if(typeof t.on!="function"){console.warn('Watcher directive: Data source does not have an "on" method. Make sure your component has data, state, or context.data initialized before using watchers like onSet, watch, or [[prop]] syntax.',s,t);return}let o=Kr(s,i,n,r);S.watch(s,t,i,o)},Kr=(s,t,e,r)=>typeof e=="object"?i=>{es(s,e,i)}:i=>{Zr(s,e,t,i,r)},Zr=(s,t,e,r,i)=>{let n=t(r,s,i);switch(typeof n){case"object":ts(n,s,i);break;case"string":let o=Dt(s);if(o!=="textContent"){y.setAttr(s,o,n);break}T.addHtml(s,n);break}},ts=(s,t,e)=>{g.rebuild(s,t,e)},es=(s,t,e)=>{for(let[r,i]of Object.entries(t))r&&(i===e?y.addClass(s,r):y.removeClass(s,r))};var Z=(s,t,e)=>{let r=E(e);lt(s,r,t,e)};var Ie=(s,t,e)=>{t&&t&&y.setAttr(s,"role",t)},rs=s=>(t,e)=>{let r=t?"true":"false";y.setAttr(e,s,r)},Be=(s,t,e)=>{if(!t)return;let r=t.role;r&&(y.setAttr(s,"role",r),t.role=null),Object.entries(t).forEach(([i,n])=>{if(n===null)return;let o=`aria-${i}`;if(Array.isArray(n)){let a=[...n];a.push(rs(o)),Z(s,a,e)}else y.setAttr(s,o,n)})};var Re=(s,t,e)=>{if(!t)return;let r=H.parse(t,e);C.addAttributes(s,r.attr,e),g.setDirectives(s,r.directives,e)};m.addType("context",s=>{if(!s)return!1;s.parent.removeContextBranch(s.branch)});var oe=s=>s?s.getContext():null,He=(s,t,e)=>{if(typeof t!="function")return;let r=oe(e),i=t(r);Re(s,i,e)},Ne=(s,t,e)=>{if(typeof t!="function")return;let r=oe(e);t(r)},_e=(s,t,e)=>{if(typeof t!="function"||!e)return;let r=oe(e),i=t(r);i&&e.addContextBranch(i[0],i[1])};var Le=(s,t,e)=>{};var Fe=(s,t,e)=>{if(!e)return;let r=e._layout?e._layout:e.render();console.log("Debug: ","ele: ",s),console.log("Data: ",t),console.log("Layout: ",r),console.log("parent: ",e)};var Ue=(s,t,e)=>{},We=(s,t,e)=>{if(!t||!e)return;let r=t(e,s);r&&g.build(r,s,e)},je=(s,t,e)=>{if(!t||!e)return;let r=e.getId(t);s.id=r},$e=(s,t,e)=>{if(!t||!e)return;let r=t(e.data,s);r&&g.build(r,s,e)},Ve=(s,t,e)=>{if(!t||!e)return;let r=t(e.state,s);r&&g.build(r,s,e)},ze=(s,t,e)=>{if(!t||!e)return;let r=e.state,i=t(r);if(!e.state){e.setStateHelper(i);return}e.addState(i)},qe=(s,t,e)=>{if(!(!t||!e)){if(e.events||e.setEventHelper(),t[2]){let r=t[2];t[2]=i=>{r(i,e)}}e.events.on(...t)}};var Je=(s,t,e)=>{let r,i,n;if(typeof t=="string"){if(r=E(e),!r)return;i=t}else if(Array.isArray(t)){if(typeof t[0]!="object"){let o=E(e);if(!o)return;t.unshift(o)}[r,i,n]=t}S.bind(s,r,i,n)};var Wt=(s,t,e)=>{lt(s,e.state,t,e)};var Qe=s=>(t,e)=>{let[r,i,n="active"]=s,o=t===i?n:"";y.setData(e,r,o)},Ye=(s,t,e)=>{if(!t)return;let r=[...t],i=r.pop();r.push(Qe(i)),Z(s,r,e)},Xe=(s,t,e)=>{if(!t)return;let r=[...t],i=r.pop();r.push(Qe(i)),Wt(s,r,e)};var Ge=(s,t,e)=>{let r,i,n,o;if(t.length<3){let c=E(e);if(!c)return;r=c,[i,n,o]=t}else[r,i,n,o]=t;let a=o!==!1;S.watch(s,r,i,c=>{if(g.removeAll(s),!c||c.length<1)return;let u=[];for(let l=0,d=c.length;l<d;l++){let p=a?r.scope(`${i}[${l}]`):null,x=n(c[l],l,p,u);x!==null&&u.push(x)}return g.build(u,s,e)})};var Ke=(s,t,e)=>{let r=t[0];if(!r||r.length<1)return;let i=t[1],n=[];for(let o=0,a=r.length;o<a;o++){let c=r[o];if(!c)continue;let u=i(c,o);u!==null&&n.push(u)}g.build(n,s,e)};var Ze=(s,t,e)=>{t(s,e)};m.addType("destroyed",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var tr=(s,t,e)=>{ss(s,t,e)},ss=(s,t,e)=>{m.add(s,"destroyed",{ele:s,callBack:t,parent:e})};var er=(s,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(var r=0,i=t.length;r<i;r++)w.setup(s,t[r],e);else w.setup(s,t,e)};var is=0,tt=class{constructor(t){this.router=t,this.locationId="base-app-router-"+is++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}check(t){}getScrollPosition(){return{x:window.scrollX,y:window.scrollY}}scrollTo(t){window.scrollTo(t.x,t.y)}addEvent(){return this}};var jt=class extends tt{addEvent(){return f.on("popstate",window,this.callBack),this}removeEvent(){return f.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri);let r=e.scrollPosition;r&&this.scrollTo(r)}createState(t,e={}){let r=this.getScrollPosition();return e=e===null?{}:e,{location:this.locationId,...e,scrollPosition:r,uri:t}}addState(t,e,r=!1){let i=window.history,n=i.state;if(n&&n.uri===t)return this;let o=this.createState(t,e);return i[r===!1?"pushState":"replaceState"](o,null,t),this}};var $t=class extends tt{addEvent(){return f.on("hashchange",window,this.callBack),this}removeEvent(){return f.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};var Vt=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new jt(t).setup():new $t(t).setup()}};var ae=class extends k{getChildScope(){return this.parent}},rr=s=>F(s,ae);var zt=class{constructor(t,e){this.route=t,this.template=e.component,this.component=null,this.hasTemplate=!1,this.setup=!1,this.container=e.container,this.persist=e.persist,this.parent=e.parent}focus(t){this.setup===!1&&(this.route&&typeof this.route.flushPending=="function"&&this.route.flushPending(),this.create()),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){this.template=this.template(),this.initializeTemplateObject()}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){let t=this.template;if(!t)return;t.isUnit||(this.template=new(rr(t)));let e=this.template;this.transferSettings(e)}create(){if(this.setupTemplate(),!this.hasTemplate)return;this.setup=!0;let t=this.component;g.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return;this.setup=!1;let t=this.component;t&&(typeof t.destroy=="function"&&t.destroy(),this.component=null)}update(t){let e=this.component;e&&typeof e.update=="function"&&e.update(t)}};var sr=s=>{if(!s.length)return null;let t={};return s.forEach(e=>{t[e]=null}),t},ir=s=>{let t=[];if(!s)return t;let e=/[*?]/g;s=s.replace(e,"");let r=/:(.[^./?&($]+)\?*/g,i=s.match(r);return i===null||i.forEach(n=>{n&&(n=n.replace(":",""),t.push(n))}),t};var ns=s=>s.replace(/\//g,"/"),os=s=>s.replace(/(\/):[^/(]*?\?/g,t=>t.replace(/\//g,"(?:$|/)")),as=s=>(s=s.replace(/(\?\/+\*?)/g,"?/*"),s.replace(/(:[^/?&($]+)/g,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),cs=s=>s.replace(/(\*)/g,".*"),us=(s,t)=>s+=t[t.length-1]==="*"?"":"$",nr=s=>{if(!s)return"";let t=ns(s);return t=os(t),t=as(t),t=cs(t),t=us(t,s),t};var hs=0,qt=class extends M{constructor(t,e){let r=t.baseUri,i=ir(r),n=sr(i),o=super(n);return this.uri=r,this.paramKeys=i,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),o}setup(){this.stage={},this.routeId=null,this.uri=null,this.uriQuery=null,this.controller=null,this.paramKeys=[],this.titleCallBack=()=>{},this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1}setupRoute(t){this.routeId=t.id||"bs-rte-"+hs++,this.path=null,this.referralPath=null;let e=nr(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1}setTitle(t){this.title=t,this.titleCallBack(this,t)}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?ne(e):null}setupComponentHelper(t){let e=this.getLayout(t);if(!e)return;let{container:r,persist:i,parent:n}=t,o={component:e,container:r,persist:i,parent:n},a=Et(this);this.controller=new zt(a,o)}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let i=this.path;if(!i)return;let n=i.split("#")[1];n&&this.scrollToId(n)}scrollToId(t){if(!t)return;let e=document.getElementById(t);e&&e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(Array.isArray(r)&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(!Array.isArray(t))return;let e=this.paramKeys;if(!e)return;let r={};e.forEach((i,n)=>{typeof i<"u"&&(r[i]=t[n])}),this.set(r)}getParams(){return this.stage}};var ls=s=>{let t=/\w\S*/;return s.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},fs=(s,t)=>{if(s.indexOf(":")===-1)return s;let e=t.stage;for(let[r,i]of Object.entries(e)){let n=new RegExp(":"+r,"gi");s=s.replace(n,i)}return s},ds=(s,t)=>t&&(typeof t=="function"&&(t=t(s.stage)),t=fs(t,s),ls(t)),ps=(s,t)=>(t!==""&&(s+=" - "+t),s),or=(s,t,e)=>t&&(t=ds(s,t),ps(t,e));var ar={removeSlashes(s){return typeof s!="string"?"":(s.substring(0,1)==="/"&&(s=s.substring(1)),s.substring(-1)==="/"&&(s=s.substring(0,s.length-1)),s)}};var cr=(s,t)=>({attr:s,value:t}),ms=(s,t)=>new RegExp("^"+s+"($|#|/|\\.).*").test(t),Jt=class extends k{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",class:this.class||this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),nest:this.nest||this.children,dataStateSet:this.dataSet,watch:r}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact===!0,i=O.data,n=[];return t&&typeof t=="object"&&n.push(cr("href",t)),e&&typeof e=="object"&&n.push(cr("text",e)),n.push({value:["[[path]]",i],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.hash,u=r?o===c:ms(a.pathname,o);this.update(u)}}),n}setupStates(){return{selected:!1}}update(t){this.state&&(this.state.selected=t)}};var gs=()=>typeof window<"u"?window.location:{},ce=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.lastMatchedRoute=null,this.history=null,this.callBackLink=null,this.location=gs(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new I({path:""})}setupHistory(){this.history=Vt.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new qt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+ar.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(let i=0;i<r;i++){let n=e[i];if(n.uri===t)return n}return null}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(let i=0;i<r;i++){let n=e[i];if(n.routeId===t)return n}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1),this.lastMatchedRoute===t&&(this.lastMatchedRoute=null)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);return t.forEach(i=>{if(!i)return;let n=this.createRoute(i);r.push(n)}),this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,i=this.getSwitchGroup(r);return t.forEach(n=>{let o=n.component.route;o.resume(e),i.push(o)}),this.checkGroup(i,this.getPath()),r}getSwitchGroup(t){let e=this.switches.get(t);if(e)return e;let r=[];return this.switches.set(t,r),r}removeSwitch(t){this.switches.delete(t)}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.path=this.getPath(),this.callBackLink=this.checkLink.bind(this),f.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){return t.closest("a")}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target.closest("a");if(!e||e.target==="_blank"||e.dataset.cancelRoute)return!0;let r=e.getAttribute("href");if(r!==null){let i=this.baseURI,n=i!=="/"?r.replace(i,""):r;return this.navigate(n),t.preventDefault(),t.stopPropagation(),!1}}reset(){let t=this.routes;for(let e=0,r=t.length;e<r;e++){let i=t[e];i&&typeof i.deactivate=="function"&&i.deactivate()}return this.routes=[],this.switches=new Map,this.switchCount=0,this.lastMatchedRoute=null,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.path=t}updateTitle(t){if(!t||!t.title)return this;let e=t.title;document.title=or(t,e,this.title)}checkActiveRoutes(t){if(this.lastPath=this.path,t=t||this.getPath(),this.path=t,this.lastMatchedRoute&&this.check(this.lastMatchedRoute,t))this.select(this.lastMatchedRoute);else{let e=this.routes,r=e.length;for(let i=0;i<r;i++){let n=e[i];typeof n>"u"||this.checkRoute(n,t)}}this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(let r of e.values())this.checkGroup(r,t)}checkGroup(t,e){if(!t.length)return;let r=t.find(o=>o.get("active"));r&&r.match(e)===!1&&r.deactivate();let i;for(let o of t){if(typeof o>"u")continue;if(i){o.deactivate();continue}o.match(e)!==!1&&i===void 0&&o.controller&&(i=o,this.select(o))}let n=t[0];i||this.select(n)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?(this.select(t),this.lastMatchedRoute=t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),t.preventScroll!==!0&&this.checkToScroll())}checkToScroll(){this.shouldScrollToTop()&&window.scrollTo(0,0)}cleanPath(t){return t?t.split("?")[0].split("#")[0]:"/"}shouldScrollToTop(){let t=this.cleanPath(this.getPath()),r=this.cleanPath(this.lastPath).split("/"),i=t.split("/");if(r.length!==i.length)return!0;let n=r[r.length-1],o=i[i.length-1];return n!==o}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){typeof this.callBackLink=="function"&&f.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},O=new ce;m.addType("routes",s=>{if(!s)return!1;let t=s.route;t&&O.removeRoute(t)});var hr=(s,t,e)=>{t&&(Array.isArray(t)?t.forEach(r=>{r&&ur(s,r,e)}):ur(s,t,e))},ur=(s,t,e)=>{t.container=s,t.parent=e;let r=O.add(t);ys(s,r)},ys=(s,t)=>{m.add(s,"routes",{route:t})};var lr=(s,t,e)=>{};m.addType("switch",s=>{if(!s)return!1;let t=s.id;O.removeSwitch(t)});var fr=(s,t,e)=>{let r=t[0];t.forEach(n=>{n&&(n.container=s,n.parent=e)});let i=O.addSwitch(t);bs(s,i)},bs=(s,t)=>{m.add(s,"switch",{id:t})};Y.add("cache",Ue).add("onCreated",Ze).add("onDestroyed",tr).add("bind",Je).add("data",Le).add("state",lr).add("onSet",Z).add("onState",Wt).add("animateIn",Oe).add("animateOut",Me).add("watch",er).add("useParent",We).add("useData",$e).add("useState",Ve).add("getId",je).add("addState",ze).add("addEvent",qe).add("map",Ke).add("for",Ge).add("useContext",Ne).add("addContext",_e).add("context",He).add("role",Ie).add("aria",Be).add("route",hr).add("debug",Fe).add("dataSet",Ye).add("dataStateSet",Xe).add("switch",fr);A.augment({Ajax:gt,Html:T,dataBinder:S,Data:I,SimpleData:L,Model:J,State:Q,Builder:g,router:O,Component:k});export{gt as Ajax,R as Arrays,wr as Atom,g as Builder,k as Component,I as Data,m as DataTracker,Ur as DateTime,Y as Directives,y as Dom,ut as Encode,Yt as Events,T as Html,ne as Import,F as Jot,J as Model,Jt as NavLink,b as Objects,Fr as Pod,L as SimpleData,Q as State,B as Store,v as Strings,h as Types,ht as Unit,A as base,S as dataBinder,O as router};
1
+ var R=class{static toArray(t){return Array.from(t)}static inArray(t,e,r){return Array.isArray(t)?t.indexOf(e,r):-1}};var l=class{static getType(t){let e=typeof t;return e!=="object"?e:Array.isArray(t)?"array":"object"}static isUndefined(t){return typeof t>"u"}static isObject(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}static isFunction(t){return typeof t=="function"}static isString(t){return typeof t=="string"}static isArray(t){return Array.isArray(t)}};var dr=Object.prototype.toString,dt=Object.prototype.hasOwnProperty,b={create(s){return Object.create(s||null)},extendObject(s,t){if(!l.isObject(s)||!l.isObject(t))return!1;for(let e in s)dt.call(s,e)&&!dt.call(t,e)&&(t[e]=s[e]);return t},clone(s){if(!s||!l.isObject(s))return{};try{return structuredClone(s)}catch{return JSON.parse(JSON.stringify(s))}},getClassObject(s){return typeof s=="function"?s.prototype:s},extendClass(s,t){let e=this.getClassObject(s),r=this.getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let i=Object.create(e);for(var n in r)i[n]=r[n];return i},hasOwnProp(s,t){return dt.call(s,t)},isPlainObject(s){return!!s&&dr.call(s)==="[object Object]"},isEmpty(s){if(!l.isObject(s))return!0;for(let t in s)if(dt.call(s,t))return!1;return!0}};var rt={types:{},add(s,t){this.types[s]=t},get(s){return this.types[s]||!1},remove(s){delete this.types[s]}};var pt=class{constructor(){this.types=new Map}add(t,e){this.types.has(t)||this.types.set(t,[]),this.types.get(t).push(e)}get(t){return this.types.get(t)||!1}has(t){return this.types.has(t)}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){if(!this.types.has(t))return;let e=this.types.get(t);if(!e.length)return;let r,i=rt.get(t);if(i){for(var n=0,o=e.length;n<o;n++)r=e[n],r&&(e[n]=null,this.removeByCallBack(i,r));this.types.delete(t)}}remove(t){if(t){this.removeType(t);return}this.types.forEach((e,r)=>{r&&this.removeType(r)}),this.types.clear()}};var j=new WeakMap,m=class{static trackers=new Map;static trackingCount=0;static addType(t,e){rt.add(t,e)}static removeType(t){rt.remove(t)}static getTrackingId(t){if(!t||typeof t!="object")return"";let e=j.get(t);return e||(e=`dt${this.trackingCount++}`,j.set(t,e)),e}static add(t,e,r){let i=this.getTrackingId(t);this.find(i).add(e,r)}static get(t,e){let r=j.get(t),i=this.trackers.get(r);return i?e?i.get(e):i:!1}static has(t,e){let r=this.getTrackingId(t);if(!r)return!1;let i=this.trackers.get(r);return i&&e?i.has(e):!1}static find(t){return this.trackers.has(t)||this.trackers.set(t,new pt),this.trackers.get(t)}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let r=j.get(t);if(!r||!this.trackers.has(r))return;let i=this.trackers.get(r);if(!e){i.remove(),this.trackers.delete(r),j.delete(t);return}i.remove(e),this.isEmpty(i.types)&&(this.trackers.delete(r),j.delete(t))}};var Qt=s=>{let t=0;for(let[e,r]of Object.entries(s))t++,typeof s[e]=="object"&&(t+=Qt(s[e]));return t},ce=(s,t)=>{let e=!1;if(typeof s!="object"||typeof t!="object")return e;for(let[r,i]of Object.entries(s)){if(!b.hasOwnProp(t,r))break;let n=t[r];if(typeof i!=typeof n)break;if(typeof i=="object"){if(e=ce(i,n),e!==!0)break}else if(i===n)e=!0;else break}return e},pr=(s,t)=>{let e=Qt(s),r=Qt(t);return e!==r?!1:ce(s,t)},ue=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?pr(s,t):s===t};var f={getEvents(s){return l.isObject(s)===!1?[]:m.get(s,"events")},create(s,t,e,r=!1,i=!1,n=null){return i=i===!0,{event:s,obj:t,fn:e,capture:r,swapped:i,originalFn:n}},on(s,t,e,r){return Array.isArray(s)?s.forEach(i=>this.add(i,t,e,r)):this.add(s,t,e,r),this},off(s,t,e,r){if(Array.isArray(s)){var i;s.forEach(n=>this.remove(n,t,e,r))}else this.remove(s,t,e,r);return this},add(s,t,e,r=!1,i=!1,n=null){if(l.isObject(t)===!1)return this;let o=this.create(s,t,e,r,i,n);return m.add(t,"events",o),t.addEventListener(s,e,r),this},remove(s,t,e,r=!1){let i=this.getEvent(s,t,e,r);return i===!1?this:(typeof i=="object"&&this.removeEvent(i),this)},removeEvent(s){return typeof s=="object"&&s.obj.removeEventListener(s.event,s.fn,s.capture),this},getEvent(s,t,e,r){if(typeof t!="object")return!1;let i=this.getEvents(t);if(!i||i.length<1)return!1;let n=this.create(s,t,e,r);return this.search(n,i)},search(s,t){let e,r=this.isSwappable(s.event);for(var i=0,n=t.length;i<n;i++)if(e=t[i],!(e.event!==s.event||e.obj!==s.obj)&&(e.fn===s.fn||r===!0&&e.originalFn===s.fn))return e;return!1},removeEvents(s){return l.isObject(s)===!1?this:(m.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return this.swap.includes(s)}};m.addType("events",s=>{f.removeEvent(s)});var Yt={events:f,addListener(s,t,e,r){return this.events.add(s,t,e,r),this},on(s,t,e,r){let i=this.events;return Array.isArray(s)?s.forEach(n=>{i.add(n,t,e,r)}):i.add(s,t,e,r),this},off(s,t,e,r){let i=this.events;return Array.isArray(s)?s.forEach(n=>{i.remove(n,t,e,r)}):i.remove(s,t,e,r),this},removeListener(s,t,e,r){return this.events.remove(s,t,e,r),this},_createEvent(s,t,e,r){let i;switch(t){case"HTMLEvents":i=new Event(s,e);break;case"MouseEvents":i=new MouseEvent(s,e);break;default:i=new CustomEvent(s,r);break}return i},createEvent(s,t,e,r){if(l.isObject(t)===!1)return!1;let i={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};l.isObject(e)&&(i=Object.assign(i,e));let n=this._getEventType(s);return this._createEvent(s,n,i,r)},_getEventType(s){let t={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},e="CustomEvent";for(let[r,i]of Object.entries(t))if(s.match(i)){e=r;break}return e},trigger(s,t,e){if(l.isObject(t)===!1)return this;let r=typeof s=="string"?this.createEvent(s,t,null,e):s;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let s=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=s())},onMouseWheel(s,t,e,r=!1){typeof t>"u"&&(t=window);let i=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof s=="function"&&s(a,o),e===!0&&o.preventDefault()},n=this.getWheelEventType();return this.events.add(n,t,i,r,!0,s),this},offMouseWheel(s,t,e=!1){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,s,e),this},preventDefault(s){return typeof s.preventDefault=="function"?s.preventDefault():s.returnValue=!1,this},stopPropagation(s){return typeof s.stopPropagation=="function"?s.stopPropagation():s.cancelBubble=!0,this}};var st=class{constructor(){this.errors=[],this.dataTracker=m}augment(t){if(!l.isObject(t))return this;let e=this.constructor.prototype;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return this}override(t,e,r,i){return(t[e]=r).apply(t,R.toArray(i))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,r){if(l.isObject(t)===!1)return"";let i=t[e];return typeof i<"u"?i:typeof r<"u"?r:""}createCallBack(t,e,r=[],i=!1){return typeof e!="function"?!1:(...n)=>(i===!0&&(r=r.concat(n)),e.apply(t,r))}bind(t,e){return e.bind(t)}};st.prototype.extend=(function(){return st.prototype})();var A=new st;A.augment({...b,...Yt,...l,equals:ue});var it={url:"",responseType:"json",method:"POST",fixedParams:"",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},beforeSend:[],async:!0,crossDomain:!1,withCredentials:!1,completed:null,failed:null,aborted:null,progress:null};var he=()=>{A.augment({xhrSettings:it,addFixedParams(s){this.xhrSettings.fixedParams=s},beforeSend(s){this.xhrSettings.beforeSend.push(s)},ajaxSettings(s){typeof s=="object"&&(this.xhrSettings=b.extendClass(A.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=it}})};var v=class{static limit(t,e=1e6){return typeof t!="string"?"":t.substring(0,e)}static parseQueryString(t,e,r=!0){typeof t!="string"&&(t=window.location.search),t=this.limit(t);let i={},n=/([^?=&]+)(=([^&]*))?/g;return t.replace(n,function(o,a,c,u){i[a]=e!==!1?decodeURIComponent(u):u}),i}static camelCase(t){t=this.limit(t);let e=/(-|\s|_)+\w{1}/g;return t.replace(e,r=>r[1].toUpperCase())}static uncamelCase(t,e="-"){t=this.limit(t);let r=/([A-Z]{1,})/g;return t.replace(r,i=>e+i.toLowerCase()).toLowerCase()}static titleCase(t){if(!t)return"";t=this.limit(t);let e=/\w\S*/;return t.replace(e,r=>r.charAt(0).toUpperCase()+r.substring(1).toLowerCase())}};var mt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR(),{method:r,url:i,async:n}=this.settings;e.open(r,i,n),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=it.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var i=0,n=t.length;i<n;i++){var o=t[i];o&&o(e,r)}}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}setupParams(t,e=null){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let i=typeof e;if(r==="string")return i!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(i==="string"&&(e=v.parseQueryString(e,!1)),t instanceof FormData)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.append(n,e[n]);else r==="object"&&(t=b.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,r=t.params;return r?r=this.setupParams(r,e):e&&(r=this.setupParams(e)),r}getXhrSettings(t){let e=this.settings={...A.xhrSettings};if(t.length>=2&&typeof t[0]!="object")for(var r=0,i=t.length;r<i;r++){var n=t[r];switch(r){case 0:e.url=n;break;case 1:e.params=n;break;case 2:e.completed=n,e.failed=n;break;case 3:e.responseType=n||"json";break;case 4:e.method=n?n.toUpperCase():"POST";break;case 5:e.async=typeof n<"u"?n:!0;break}}else e=this.settings=b.extendClass(this.settings,t[0]),typeof e.completed=="function"&&(typeof e.failed!="function"&&(e.failed=e.completed),typeof e.aborted!="function"&&(e.aborted=e.failed))}createXHR(){let t=this.settings,e=new XMLHttpRequest;return e.responseType=t.responseType,t.withCredentials===!0&&(e.withCredentials=!0),e}setupHeaders(){let t=this.settings;if(!t||typeof t.headers!="object")return;let e=t.headers;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.xhr?.setRequestHeader(r,e[r])}update(t,e){let r=this.xhr,i=()=>{f.removeEvents(r?.upload),f.removeEvents(r)},n=this.settings;if(!n)return!1;switch(e||t.type){case"load":if(typeof n.completed=="function"){let a=this.getResponseData();n.completed(a,this.xhr)}i();break;case"error":typeof n.failed=="function"&&n.failed(!1,this.xhr),i();break;case"progress":typeof n.progress=="function"&&n.progress(t);break;case"abort":typeof n.aborted=="function"&&n.aborted(!1,this.xhr),i();break}}getResponseData(){let t=this.xhr;if(!t)return null;let e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr;if(!e)return;let r=this.update.bind(this);f.on(["load","error","abort"],e,r),f.on("progress",e.upload,r)}};he();var gt=(...s)=>new mt(s).xhr;var mr=s=>typeof s!="string"?s:le(s),le=s=>[{tag:"text",textContent:s}],yt=()=>({props:{},children:[]}),bt=s=>({props:{},children:le(s)}),xt=s=>({props:{},children:s}),St=s=>({props:s[0]||{},children:mr(s[1])});var vt=class{constructor(){this.connections=new Map}add(t,e,r){let i=this.getOrCreate(t),n=i.get(e);return n?Array.isArray(n)?n.push(r):i.set(e,[n,r]):i.set(e,r),r}get(t,e){let r=this.connections.get(t)?.get(e);return r?Array.isArray(r)?r[r.length-1]||!1:r:!1}getOrCreate(t){let e=this.connections.get(t);return e||(e=new Map,this.connections.set(t,e)),e}remove(t,e){let r=this.connections.get(t);if(r)if(e)this.unsubscribe(r.get(e)),r.delete(e),r.size===0&&this.connections.delete(t);else{for(let i of r.values())this.unsubscribe(i);this.connections.delete(t)}}unsubscribe(t){if(t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)t[e]?.unsubscribe();else t.unsubscribe()}};var $=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var kt=class extends ${constructor(t){super(),this.data=t}subscribe(t,e){if(!this.data||typeof this.data.on!="function"){console.warn('OneWaySource: Cannot subscribe - data source is null or does not have an "on" method. Make sure your component has data, state, or context.data initialized.',t,this.data);return}this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data&&this.msg&&this.token&&this.data.off(this.msg,this.token),this.data=null,this.msg=null,this.token=null}};var V=class{unsubscribe(){}};var Ct=class extends V{constructor(){super(),this.source=null}addSource(t){return this.source=new kt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var z=class extends ${constructor(t){super(),this.pubSub=t}subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=this.pubSub.on(t,e)}unsubscribe(){this.pubSub&&this.msg&&this.token&&this.pubSub.off(this.msg,this.token),this.pubSub=null,this.msg=null,this.token=null}callBack(){}};var wt=class extends z{constructor(t,e,r){super(r),this.data=t,this.prop=e}set(t){this.data.set(this.prop,t)}get(){return this.data.get(this.prop)}callBack(t,e){this.data!==e&&this.data.set(this.prop,t,e)}unsubscribe(){super.unsubscribe(),this.data=null,this.prop=null}};var y=class{static getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}static getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?R.toArray(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:R.toArray(r):!1}static html(t,e){return l.isObject(t)===!1?!1:l.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,r){return l.isObject(t)===!1||l.isUndefined(e)?this:(e=v.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=v.uncamelCase(e);let r=t.style[e];if(r!=="")return r;let i=null,n=t.currentStyle;if(n&&(i=n[e]))return i;let o=window.getComputedStyle(t,null);return o?o[e]:r}static css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}static removeAttr(t,e){return l.isObject(t)&&t.removeAttribute(e),this}static setAttr(t,e,r){t.setAttribute(e,r)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,r){return l.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=v.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}static removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}static setData(t,e,r){e=this.removeDataPrefix(e),e=v.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=v.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,r){return l.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?[]:t.querySelectorAll(e)}static show(t){if(l.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}static hide(t){if(l.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}static toggle(t){return l.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return l.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return l.isObject(t)?t.offsetWidth:!1}static getHeight(t){return l.isObject(t)?t.offsetHeight:!1}static getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,r=t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return l.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}static getScrollTop(t){return this.getScrollPosition(t).top}static getScrollLeft(t){return this.getScrollPosition(t).left}static getWindowSize(){let t=window,e=document,r=e.documentElement,i=e.getElementsByTagName("body")[0],n=t.innerWidth||r.clientWidth||i.clientWidth,o=t.innerHeight||r.clientHeight||i.clientHeight;return{width:n,height:o}}static getDocumentSize(){let t=document,e=t.body,r=t.documentElement,i=Math.max(e.scrollHeight,e.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,r.clientWidth,r.scrollWidth,r.offsetWidth),height:i}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let r={x:0,y:0};if(l.isObject(t)===!1)return r;let i=0;for(;t&&(e===0||i<e);)i++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}static addClass(t,e){if(l.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let n=e.split(" ");for(var r=0,i=n.length;r<i;r++)t.classList.add(e)}return this}static removeClass(t,e){return l.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return l.isObject(t)===!1||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return l.isObject(t)===!1?this:(t.classList.toggle(e),this)}};var Dt=s=>{let t="textContent";if(!s||typeof s!="object")return t;let e=s.tagName.toLowerCase();if(e==="input"||e==="textarea"||e==="select"){let r=s.type;if(!r)return t="value",t;switch(r){case"checkbox":t="checked";break;case"file":t="files";break;default:t="value"}}return t};var gr=(s,t,e)=>{y.setAttr(s,t,e)},yr=(s,t,e)=>{s.checked=s.value==e},br=(s,t,e)=>{e=e==1,fe(s,t,e)},fe=(s,t,e)=>{s[t]=e},xr=(s,t)=>y.getAttr(s,t),Sr=(s,t)=>s[t],Tt=class extends z{constructor(t,e,r,i){super(i),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof r=="string"?this.setupFilter(r):r}addSetMethod(t,e){if(e.charAt(4)==="-")return this.setValue=gr,this.getValue=xr,this;this.getValue=Sr;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=br;return;case"radio":this.setValue=yr;return}return this.setValue=fe,this}getAttrBind(t){return t||Dt(this.element)}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;return!e||typeof e!="object"?this:(this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t),this)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){return e!==this.element&&this.set(t),this}unsubscribe(){super.unsubscribe(),this.element={},this.attr="",this.filter=null,this.setValue=null,this.getValue=null}};var At=class extends V{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new Tt(t,e,r,this.pubSub)}addData(t,e){return this.data=new wt(t,e,this.pubSub)}unsubscribeSource(t){return t&&t.unsubscribe(),this}unsubscribe(){return this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null,this}};var de=-1,q=class{constructor(){this.callBacks=new Map,this.updateQueue=new Map,this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this.maxFlushIterations=2e3,this.batchingEnabled=!0,this.debugMode=!1,this.flushCompleteResolvers=[],this.flushCallbacks=[]}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,de=-1}on(t,e){let r=(++de).toString();return this.get(t).set(r,e),r}off(t,e){let r=this.callBacks.get(t);r&&(e=String(e),r.delete(e),r.size===0&&this.callBacks.delete(t))}remove(t){this.callBacks.delete(t)}publish(t,...e){if(!this.batchingEnabled){this.publishImmediate(t,...e);return}this.updateQueue.set(t,e),this.debugMode&&console.log("[DataPubSub] Queued update:",t,e),this.scheduleFlush()}scheduleFlush(){this.isFlushing||this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){if(this.updateQueue.size===0){this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete();return}if(this.isFlushing||(this.flushIterations=0),this.isFlushing=!0,this.flushScheduled=!1,this.flushIterations++,this.flushIterations>this.maxFlushIterations){console.error("[DataPubSub] Infinite loop detected! Flush iterations exceeded",this.maxFlushIterations,"- Breaking to prevent memory exhaustion."),console.error("[DataPubSub] Queue size:",this.updateQueue.size),console.error("[DataPubSub] Queued messages:",Array.from(this.updateQueue.keys())),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this._resolveFlushComplete(),this.flushIterations=0;return}this.debugMode&&console.log("[DataPubSub] Flushing",this.updateQueue.size,"updates (iteration",this.flushIterations+")");let t=this.updateQueue;this.updateQueue=new Map;try{for(let[e,r]of t)this.publishImmediate(e,...r)}finally{this.debugMode&&console.log("[DataPubSub] Flush complete (iteration",this.flushIterations+")"),this.updateQueue.size>0?(this.debugMode&&console.log("[DataPubSub] New updates queued during flush, re-flushing..."),this.flush()):(this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete())}}_resolveFlushComplete(){if(this.flushCompleteResolvers.length>0){let t=this.flushCompleteResolvers;this.flushCompleteResolvers=[];let e=t.length;for(let r=0;r<e;r++)t[r]()}if(this.flushCallbacks.length>0){let t=this.flushCallbacks;this.flushCallbacks=[];let e=t.length;for(let r=0;r<e;r++)t[r]()}}nextFlush(){return new Promise(t=>{this.flushCompleteResolvers.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>t())})}onFlush(t){if(typeof t!="function"){console.warn("[DataPubSub] onFlush requires a function callback");return}this.flushCallbacks.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>{if(this.flushCallbacks.length>0){let e=this.flushCallbacks;this.flushCallbacks=[];let r=e.length;for(let i=0;i<r;i++)e[i]()}})}flushSync(){this.flush()}publishImmediate(t,...e){let r=this.callBacks.get(t);if(r){for(let i of r.values())if(i)try{i.apply(this,e)}catch(n){console.error('[DataPubSub] Subscriber error for "'+t+'":',n)}}}};var Xt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=new Set([20,37,38,39,40]),this.connections=new vt,this.pubSub=new q,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,i){let n=r,o=null,a=r.indexOf(":");a!==-1&&(o=r.substring(0,a),n=r.substring(a+1));let c=o??"",u=this.setupConnection(t,e,n,c,i),h=u.element,d=e.get(n);return typeof d<"u"?h.set(d):(d=h.get(),d!==""&&u.data.set(d)),this}setupConnection(t,e,r,i,n){let o=this.getBindId(t),a=new At(this.pubSub);a.addData(e,r).subscribe(o);let h=`${e.getDataId()}:${r}`;return a.addElement(t,i,n).subscribe(h),this.addConnection(o,"bind",a),a}addConnection(t,e,r){return this.connections.add(t,e,r),this}setBindId(t){let e="db-"+this.idCount++;return t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,i){if(l.isObject(t)===!1)return this;let n=new Ct,o=e.get(r),a=!0,c=p=>{a&&(a=!1,p===o)||i(p)};n.addSource(e).subscribe(r,c);let h=this.getBindId(t),d=e.getDataId()+":"+r;return this.addConnection(h,d,n),i(o),this}unwatch(t,e,r){if(l.isObject(t)===!1)return this;let i=t[this.attr];if(i){let n=e.getDataId()+":"+r;this.connections.remove(i,n)}return this}publish(t,e,r){return this.pubSub.publish(t,e,r),this}isDataBound(t){if(!t)return null;let e=t[this.attr];return e||null}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.has(t.keyCode)}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r!==null){let i=this.connections.get(r,"bind");if(i){let n=i.element.get();this.pubSub.publish(r,n,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){typeof document<"u"&&f.on(["change","paste","input"],document,this.changeHandler,!1)}removeEvents(){typeof document<"u"&&f.off(["change","paste","input"],document,this.changeHandler,!1)}},S=new Xt;var E=s=>s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null;var vr=new Map([["class","className"],["text","textContent"],["for","htmlFor"],["readonly","readOnly"],["maxlength","maxLength"],["cellspacing","cellSpacing"],["rowspan","rowSpan"],["colspan","colSpan"],["tabindex","tabIndex"],["celpadding","cellPadding"],["useMap","useMap"],["frameborder","frameBorder"],["contenteditable","contentEditable"]]),nt=s=>vr.get(s)||s,ot=s=>typeof s=="string"&&s.charCodeAt(0)===111&&s.charCodeAt(1)===110?s.substring(2):s,kr=/(?:<[a-z][\s\S]*>)/i,T=class{static create(t,e,r,i){let n=document.createElement(t);return this.addAttributes(n,e),i===!0?this.prepend(r,n):this.append(r,n),n}static addAttributes(t,e){if(!e||typeof e!="object")return;let r=e.type;r!==void 0&&t.setAttribute("type",r);let i=Object.keys(e);for(let n=0,o=i.length;n<o;n++){let a=i[n],c=e[a];a==="innerHTML"?t.innerHTML=c:a.indexOf("-")!==-1?t.setAttribute(a,c):this.addAttr(t,a,c)}}static addHtml(t,e){return typeof e>"u"||e===""?this:(kr.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,r){if(r===""||!e)return;if(typeof r==="function")e=ot(e),r.originalCallback?f.add(e,t,r,!1,!0,r.originalCallback):f.add(e,t,r);else{let n=nt(e);t[n]=r}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}static createComment(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}static setupSelectOptions(t,e,r){if(!t||typeof t!="object"||!Array.isArray(e))return!1;e.forEach(i=>{let n=new Option(i.label,i.value);t.options.add(n),r!==null&&n.value==r&&(n.selected=!0)})}static removeElementData(t){let e=[t];for(;e.length>0;){let r=e.pop(),i=r.childNodes;if(i&&i.length>0)for(let n=i.length-1;n>=0;n--)e.push(i[n]);m.remove(r),r.bindId&&S.unbind(r)}}static removeElement(t){if(!t)return this;let e=m.has(t,"manual-destroy");return this.removeElementData(t),e===!1&&t.remove(),this}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(!t||typeof t!="object")return this;let e;for(;e=t.firstChild;)this.removeElementData(e),t.removeChild(e);return this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,r){let i=r||t.firstChild;return t.insertBefore(e,i),this}static clone(t,e=!1){return!t||typeof t!="object"?!1:t.cloneNode(e)}};var C=class extends T{static create(t,e,r,i){let n=document.createElement(t);return this.addAttributes(n,e,i),r.appendChild(n),n}static addAttributes(t,e,r){if(!(!e||e.length<1))for(let i=0,n=e.length;i<n;i++){let o=e[i];this.addAttr(t,o.key,o.value,r)}}static addAttr(t,e,r,i){if(r===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=r;return}if(typeof r==="function"){if(e=ot(e),r.originalCallback)f.add(e,t,r,!1,!0,r.originalCallback);else{let a=r,c=function(u){a.call(this,u,i)};f.add(e,t,c,!1,!0,a)}return}if(e.charCodeAt(4)===45){t.setAttribute(e,r);return}let o=nt(e);t[o]=r}static addContent(t,e){e&&(e.textContent!==null?t.textContent=e.textContent:e.innerHTML&&(t.innerHTML=e.innerHTML))}static append(t,e){t.appendChild(e)}};var pe=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,me=new Map,w={isWatching(s){if(Array.isArray(s)){let t=s[0];return typeof t=="string"&&t.includes("[[")}return this.hasParams(s)},hasParams(s){return typeof s=="string"&&s.includes("[[")},_getWatcherProps(s){let t=me.get(s);if(t!==void 0)return t;let e=s.match(pe),r=e?e.map(i=>i.slice(2,-2)):null;return me.set(s,r),r},updateAttr(s,t,e){switch(t){case"text":case"textContent":s.textContent=e;break;case"disabled":s.disabled=!e;break;case"checked":s.checked=!!e;break;case"required":s.required=!!e;break;case"src":if(s.tagName==="IMG"){s.src=e&&(e.indexOf(".")!==-1||e.indexOf("blob:")!==-1)?e:"";break}s.src=e;break;default:C.addAttr(s,t,e);break}},replaceParams(s,t,e=!1){let r=0;return s.replace(pe,function(i,n,o){let a=e?t[r]:t;r++;let c=a.get(o);return c??""})},_getWatcherCallBack(s,t,e,r,i){return()=>{let n=this.replaceParams(e,t,i);this.updateAttr(s,r,n)}},getValue(s,t){let e=s.value;return Array.isArray(e)===!1?[e,E(t)]:(e.length<2&&e.push(E(t)),e)},getPropValues(s,t,e){let r=[];for(let i=0,n=t.length;i<n;i++){let a=(e?s[i]:s).get(t[i])??"";r.push(a)}return r},getCallBack(s,t,e,r,i,n){let o=s.attr||"textContent",a=s.callBack;if(typeof a=="function"){let c=n||this._getWatcherProps(r)||[],u=c.length>1;return(h,d)=>{h=u!==!0?h:this.getPropValues(e,c,i);let p=a(h,t,d);typeof p<"u"&&this.updateAttr(t,o,p)}}return this._getWatcherCallBack(t,e,r,o,i)},addDataWatcher(s,t,e){let r=this.getValue(t,e),i=r[1]??e?.data??e?.context?.data??e?.state??null;if(!i)return;let n=r[0],o=Array.isArray(i),a=this._getWatcherProps(n),c=this.getCallBack(t,s,i,n,o,a);if(o)for(let u=0,h=a.length;u<h;u++)this.addWatcher(s,i[u],a[u],c);else for(let u=0,h=a.length;u<h;u++)this.addWatcher(s,i,a[u],c)},getWatcherSettings(s,t=null){if(typeof s=="string")return{attr:t,value:s};if(Array.isArray(s)){let e=s[s.length-1];e&&typeof e=="object"&&(e=t!==null?t:null);let r=s[1]&&typeof s[1]=="object"?[s[0],s[1]]:[s[0]];return typeof e=="function"?{attr:t,value:r,callBack:e}:{attr:e||"textContent",value:r}}return s},setup(s,t,e){t&&this.addDataWatcher(s,this.getWatcherSettings(t),e)},addWatcher(s,t,e,r){S.watch(s,t,e,r)}};var Cr=s=>({props:{watch:s},children:[]}),wr=s=>{if(s.length===0)return yt();let t=s[0],e=typeof t;if(e==="string"||e==="number")return bt(t);if(Array.isArray(t))return w.isWatching(t)?Cr(t):xt(t);let r=s[1]??s[0]??[];return r&&Array.isArray(r)&&w.isWatching(r)&&(s[0]=Array.isArray(s[0])?{}:s[0],s[0].watch=r,s[1]=[]),St(s)},Dr=s=>(...t)=>{let{props:e,children:r}=wr(t);return s(e,r)};var ge=new WeakMap,ye=new WeakMap;function Tr(s,t,e,r){let i=ge.get(s);i||(i=new Map,ge.set(s,i));let n=i.get(e);if(n)return n;let o=new Proxy(s,xe(t,e,r));return i.set(e,o),o}function be(s,t){let e=isNaN(Number(t)),r=e?t:`[${t}]`;return s===""?r:e?`${s}.${r}`:`${s}${r}`}function xe(s,t="",e=""){return{get(r,i,n){let o=r[i];if(t===""&&i in r){if(typeof o=="function"){let c=ye.get(r);c||(c=new Map,ye.set(r,c));let u=c.get(i);if(u)return u;let h=o.bind(r);return c.set(i,h),h}return o}if(o=(r[e]||r)[i],o!==null&&typeof o=="object"){let c=be(t,i);return Tr(o,s,c,e)}return o},set(r,i,n,o){if(t===""&&i in r)return r[i]=n,!0;let a=be(t,i);return s.set(a,n),!0}}}var Et=(s,t="stage")=>new Proxy(s,xe(s,"",t));var at=class{static resume(t,e){if(!t)return null;let r,i=localStorage.getItem(t);return i===null?e&&(r=e):r=JSON.parse(i),r}static store(t,e){if(!t||!e)return!1;let r=JSON.stringify(e);return localStorage.setItem(t,r),!0}static remove(t){return t?(localStorage.removeItem(t),!0):!1}};var Pt=(s={})=>{let t={};if(!l.isObject(s))return t;let e=Object.keys(s);for(let r=0,i=e.length;r<i;r++){let n=e[r],o=s[n];typeof o!="function"&&(t[n]=o)}return t};var Ar=0,Se=new Map,N={CHANGE:"change",DELETE:"delete"},Gt=(s,t)=>{let e=Se.get(s);return e||(e={change:`${s}:change`,delete:`${s}:delete`},Se.set(s,e)),t==="change"?e.change:e.delete},O=class{constructor(t={}){this.dirty=!1,this.links=new Map,this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new q;let e=Pt(t);return this.set(e),Et(this)}setup(){this.stage={}}_init(){let t=++Ar;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}onFlush(t){this.eventSub.onFlush(t)}flushPending(){this.eventSub.flush()}getDataId(){return String(this._id)}remove(){}on(t,e){let r=Gt(t,N.CHANGE);return this.eventSub.on(r,e)}off(t,e){let r=Gt(t,N.CHANGE);this.eventSub.off(r,e)}_setAttr(t,e,r=this,i=!1){let n=this.stage[t];e!==n&&(this.stage[t]=e,this._publish(t,e,r,N.CHANGE))}publishLocalEvent(t,e,r,i){let n=Gt(t,i);this.eventSub.publish(n,e,r)}_publish(t,e,r,i){this.publishLocalEvent(t,e,r,i),r=r||this,S.publish(this._dataId+t,e,r)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,i]=t,n=Object.keys(e);for(let o=0;o<n.length;o++){let a=n[o],c=e[a];typeof c!="function"&&this._setAttr(a,c,r,i)}return this}getModelData(){return this.stage}_deleteAttr(t,e,r=this){delete t[e],this.publishLocalEvent(e,null,r,N.DELETE)}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r+e),this}decrement(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r-e),this}concat(t,e){if(typeof t>"u")return;let r=this.get(t);return this.set(t,r+e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){return this.key=t,this}resume(t){let e=at.resume(String(this.key),t);return e?(this.set(e),this):this}store(){let t=this.get();return at.store(String(this.key),t)}delete(t){return typeof t=="string"?(this._deleteAttr(this.stage,t),this):(this.setup(),this)}_getAttr(t,e){return t[e]}get(t){return typeof t<"u"?this._getAttr(this.stage,t):this.getModelData()}link(t,e,r){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,r);let i=[];return Object.entries(e).forEach(([n])=>{i.push(this.remoteLink(t,n))}),i}remoteLink(t,e,r){let i=r||e,n=t.get(e);typeof n<"u"&&this.get(e)!==n&&this.set(e,n);let o=t.on(e,(c,u)=>{if(u===this)return!1;this.set(i,c,t)});this.addLink(o,t);let a=this.on(i,(c,u)=>{if(u===t)return!1;t.set(e,c,this)});return t.addLink(a,this),o}addLink(t,e){this.links.set(t,e)}unlink(t){if(t){this.removeLink(t);return}let e=this.links;b.isEmpty(e)||(e.forEach((r,i)=>{this.removeLink(i,!1)}),this.links=new Map)}removeLink(t,e=!0){let r=this.links.get(t);r&&r.off(t),e!==!1&&this.links.delete(t)}};O.prototype.isData=!0;var Kt=class{constructor(t=1e3){this.cache=new Map,this.maxSize=t}get(t){return this.cache.get(t)}set(t,e){if(this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.maxSize){let r=this.cache.keys().next().value;this.cache.delete(r)}}clear(){this.cache.clear()}},P={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,segmentCache:new Kt(1e3),hasDeepData(s){return s.indexOf(".")!==-1||s.indexOf("[")!==-1},getSegments(s){let t=this.segmentCache.get(s);if(t!==void 0)return t;let e=this.deepDataPattern;return t=s.match(e),this.segmentCache.set(s,t),t}};var _=class{static set(t,e,r){if(!P.hasDeepData(e)){t[e]=r;return}let i,n=P.getSegments(e);if(!n)return;let o=n.length,a=o-1;for(let c=0;c<o;c++){let u=n[c];if(c===a){t[u]=r;break}t[u]===void 0&&(t[u]=isNaN(u)?{}:[]),t=t[u]}}static delete(t,e){if(!P.hasDeepData(e)){delete t[e];return}let r=P.getSegments(e);if(!r)return;let i=r.length,n=i-1;for(let o=0;o<i;o++){let a=r[o],c=t[a];if(c===void 0)break;if(o===n){if(Array.isArray(t)){t.splice(Number(a),1);break}delete t[a];break}t=c}}static get(t,e){if(!P.hasDeepData(e))return t[e]??void 0;let r=P.getSegments(e);if(!r)return;let i=r.length,n=i-1;for(let o=0;o<i;o++){let a=r[o],c=t[a]??void 0;if(c===void 0)break;if(t=c,o===n)return t}}};var ve=new Set,ct=class{static MAX_DEPTH=50;static publishDeep(t,e,r,i){if(!P.hasDeepData(e)){this.publish(e,r,i);return}let n,o=P.getSegments(e);if(!o)return;let a=o.length,c=a-1,u="";for(let h=0;h<a;h++){let d=o[h];t=t[d],h>0?isNaN(d)&&(u+="."+d):u=d;let p;if(h===c)p=r;else{let x=o[h+1];if(isNaN(x)===!1){u+="["+x+"]";continue}let D={};D[x]=t[x],p=D}this.publish(u,p,i)}}static publish(t,e,r,i=null,n=0){if(t=t||"",r(t,e),!(!e||typeof e!="object"||(i===null&&(ve.clear(),i=ve),!i))){if(i.has(e)){console.warn("[Publisher] Circular reference detected at path:",t);return}if(n>=this.MAX_DEPTH){console.warn("[Publisher] Max depth exceeded at path:",t,"- stopping recursion");return}i.add(e),Array.isArray(e)?this.publishArray(t,e,r,i,n):this.publishObject(t,e,r,i,n)}}static publishArray(t,e,r,i,n){let o=e.length;for(let a=0;a<o;a++){let c=e[a],u=t+"["+a+"]";this._checkPublish(u,c,r,i,n)}}static publishObject(t,e,r,i,n){let o=Object.keys(e);for(let a=0,c=o.length;a<c;a++){let u=o[a],h=e[u],d=t+"."+u;this._checkPublish(d,h,r,i,n)}}static _checkPublish(t,e,r,i,n){if(!e||typeof e!="object"){r(t,e);return}this.publish(t,e,r,i,n+1)}};var I=class extends O{setup(){this.attributes={},this.stage={}}_setAttr(t,e,r,i){typeof e!="object"&&e===this.get(t)||(!r&&i!==!0?_.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),_.set(this.stage,t,e),r=r||this,this._publish(t,e,r,N.CHANGE))}linkAttr(t,e){let r=t.get(e);if(!r)return;let i=Object.keys(r);for(let n=0,o=i.length;n<o;n++){let a=i[n];this.link(t,e+"."+a,a)}}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let i=new e(r);return i.linkAttr(this,t),i}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.push(e),this.set(t,r),this}concat(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r=r.concat(e),this.set(t,r),this}unshift(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.unshift(e),this.set(t,r),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.shift();return this.set(t,e),r}getIndex(t,e,r){let i=this.get(t);return Array.isArray(i)===!1?-1:typeof i[0]!="object"?i.indexOf(e):i.findIndex(o=>o[e]===r)}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.pop();return this.set(t,e),r}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,r,i){let n=(o,a)=>this._publishAttr(o,a,r,i);ct.publish(t,e,n)}_publishAttr(t,e,r,i){let n=this._dataId+t;S.publish(n,e,r),this.publishLocalEvent(t,e,r,i)}mergeStage(){this.attributes=b.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e,r=this){_.delete(t,e);let i=(n,o)=>this.publishLocalEvent(n,o,r,N.DELETE);ct.publish(e,e,i)}_getAttr(t,e){return _.get(t,e)}};var Er={"\n":"\\n","\r":"\\n"," ":"\\t"},Pr=(s,t)=>{typeof s!="string"&&(s=String(s));let e=t?/[\n\r\t]/g:/\t/g;return s.replace(e,r=>Er[r])},ke=(s,t)=>{if(typeof s!="string")return s;s=Pr(s,t),s=encodeURIComponent(s);let e=/%22/g;return s.replace(e,'"')},Zt=(s,t)=>{let e=typeof s;return e==="undefined"?s:e!=="object"?(s=ke(s),s):(Object.entries(s).forEach(([r,i])=>{i!==null&&(s[r]=typeof i=="string"?Zt(i,t):ke(i,t))}),s)};function Ce(s){return typeof s<"u"&&s.length>0?JSON.parse(s):!1}function te(s){return typeof s<"u"?JSON.stringify(s):null}var ut=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?b.clone(t):t,i=Zt(r,e);return te(i)}static json={encode:te,decode:Ce};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var Mt=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=v.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=v.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),i="id="+r,n=r?`/${r}`:"",o=this.model;return this._get(n,i,t,e,a=>{if(a){let c=this.getObject(a);c&&o.set(c)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+ut.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=i!=null?`/${i}`:"";return this._put(n,r,t,e)}add(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=i!=null?`/${i}`:"";return this._post(n,r,t,e)}update(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=i!=null?`/${i}`:"";return this._patch(n,r,t,e)}delete(t,e){let r=this.model.get("id"),i=typeof r<"u"?"id="+r:this.setupObjectData(),n=r!=null?`/${r}`:"";return this._delete(n,i,t,e)}all(t,e,r,i,n=null,o=null){let a=this.model.get();r=isNaN(r)?0:r,i=isNaN(i)?50:i;let c=a.search||"",u=a.filter||"";typeof u=="object"&&(u=JSON.stringify(u));let h=a.dates||"";typeof h=="object"&&(h=JSON.stringify(h));let d=a.orderBy||"";typeof d=="object"&&(d=JSON.stringify(d));let p=a.groupBy||"";Array.isArray(p)&&(p=JSON.stringify(p));let x="&filter="+u+"&offset="+r+"&limit="+i+"&dates="+h+"&orderBy="+d+"&groupBy="+p+"&search="+c+"&lastCursor="+(typeof n<"u"&&n!==null?n:"")+"&since="+(typeof o<"u"&&o!==null?o:"");return this._get("",x,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);t[0]==="/"&&(t=t.substring(1));let r=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(r)}setupRequest(t,e,r,i,n){let o={url:this.getUrl(t),method:e,params:r,completed:(c,u)=>{typeof n=="function"&&n(c),this.getResponse(c,i,u)}};return this._isFormData(r)&&(o.headers={}),gt(o)}setupEventSource(t,e,r,i,n=!0){let o=null,a=null,c=!1,u=!1,h=()=>{a&&(clearTimeout(a),a=null)},d=()=>{if(c||!n||u)return;h(),a=setTimeout(()=>{a=null,p()},3e3)},p=()=>{if(c||u)return;if(o){try{o.close()}catch{}o=null}u=!0;let x=this.getUrl(t),D=e?"?"+e:"";o=new EventSource(x+D,{withCredentials:!0}),o.onopen=()=>{u=!1,h(),i&&i()},o.onerror=()=>{u=!1,o&&o.readyState===EventSource.CLOSED&&(o=null,d())},o.onmessage=et=>{try{let ft=JSON.parse(et.data);r&&r(ft)}catch{}}};return p(),{get source(){return o},close:()=>{if(c=!0,u=!1,h(),o){try{o.close()}catch{}o=null}}}}replaceUrl(t){return w.isWatching(t)&&(t=w.replaceParams(t,this.model)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t}_isFormData(t){return t instanceof FormData}request(t,e,r,i){return this._request("","POST",t,e,r,i)}_get(t,e,r,i,n){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",i,n)}_post(t,e,r,i,n){return this._request(t,"POST",e,r,i,n)}_put(t,e,r,i,n){return this._request(t,"PUT",e,r,i,n)}_patch(t,e,r,i,n){return this._request(t,"PATCH",e,r,i,n)}_delete(t,e,r,i,n){return this._request(t,"DELETE",e,r,i,n)}_request(t,e,r,i,n,o){return r=this.setupParams(r),r=this.addParams(r,i),this.setupRequest(t,e,r,n,o)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;let e=this;class r extends e{constructor(n){super(n)}}return Object.assign(r.prototype,t),r}};var Mr=s=>{let t={};if(!l.isObject(s)||!s.defaults)return t;let{defaults:e}=s;return Object.keys(e).forEach(r=>{let i=e[r];typeof i!="function"&&(t[r]=i)}),delete s.defaults,t},Or=s=>{if(!s||typeof s.xhr!="object")return{};let t={...s.xhr};return delete s.xhr,t},Ir=0,J=class extends I{constructor(t){let e=super(t);return this.initialize(),e}setup(){this.attributes={},this.stage={},this.url=this.url||"",this.xhr=this.xhr||{}}initialize(){}static extend(t={}){let e=this,r=Or(t),i=e.prototype.service.extend(r),n=Mr(t);class o extends e{constructor(c){let u={...n,...Pt(c)};super(u),this.xhr=new i(this)}dataTypeId=`bm${Ir++}`}return Object.assign(o.prototype,t),o.prototype.service=i,o}};J.prototype.service=Mt;var L=class extends O{};var Q=class extends L{setup(){this.stage={}}addAction(t,e){return typeof e<"u"&&this.set(t,e),this}getState(t){return this.get(t)}removeAction(t,e){if(e)return this.off(t,e),this;let r=this.stage;return typeof r[t]<"u"&&delete r[t],this}};var Ot=class extends Q{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=""}};var B=class{static targets=new Map;static restore(t,e){this.targets.set(t,e)}static getTarget(t){return this.targets.has(t)||this.targets.set(t,new Ot(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let i=this.getTarget(t);return e&&i.addAction(e,r),i}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){r&&this.off(t,e,r)}static on(t,e,r){let i=this.getTarget(t);return e?i.on(e,r):null}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let i=this.targets,n=i.get(t);if(n){if(e){n.off(e,r);return}this.targets.delete(t)}}static set(t,e,r){this.getTarget(t).set(e,r)}};var It=class{constructor(){this.events=[]}addEvents(t){t.length<1||t.forEach(r=>{this.on(...r)})}on(t,e,r,i){f.on(t,e,r,i),this.events.push({event:t,obj:e,callBack:r,capture:i})}off(t,e,r,i){f.off(t,e,r,i);let n,o=this.events;for(var a=0,c=o.length;a<c;a++)if(n=o[a],n.event===t&&n.obj===e){o.splice(a,1);break}}set(){this.events.forEach(t=>{f.on(t.event,t.obj,t.callBack,t.capture)})}unset(){this.events.forEach(t=>{f.off(t.event,t.obj,t.callBack,t.capture)})}reset(){this.unset(),this.events=[]}};var Bt=class{constructor(t,e){this.remoteStates=[];let r=this.convertStates(e);this.addStatesToTarget(t,r)}addStates(t,e){let r=this.convertStates(e);this.addStatesToTarget(t,r)}createState(t,e,r,i){return{action:t,state:e,callBack:r,targetId:i,token:null}}convertStates(t){let e=[];for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}let i=null,n=null,o=t[r];o&&typeof o=="object"&&(n=o.callBack,i=o.id||o.targetId,o=o.state),e.push(this.createState(r,o,n,i))}return e}setupRemoteStates(t,e){for(let r=0,i=t.length;r<i;r++){let n=t[r];if(n)for(let o in n){if(!Object.prototype.hasOwnProperty.call(n,o)||o==="id")continue;let a=null,c=n[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,n.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(let r=0,i=e.length;r<i;r++){let n=e[r];n.token&&this.unbindRemoteState(t,n.token),n.targetId&&B.remove(n.targetId,n.action,n.token)}}restore(t){B.restore(t.id,t);let e=this.remoteStates;if(e)for(let r=0,i=e.length;r<i;r++){let n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let i=B.getTarget(r);return t.link(i,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(let i=0,n=e.length;i<n;i++){let o=e[i],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}}addAction(t,e){let r,i=e.action,n=e.targetId;n&&(r=this.bindRemoteState(t,i,n)),typeof e.state<"u"&&t.addAction(i,e.state);let o=e.callBack;return typeof o=="function"&&t.on(i,o),r||null}};var we=s=>{if(!s)return yt();let t=s[0],e=typeof t;return e==="string"||e==="number"?bt(t):Array.isArray(t)?xt(t):St(s)};m.addType("components",s=>{if(!s)return;let t=s.component;!t||!t.isUnit||(t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken),t.rendered===!0&&(t.prepareDestroy(),t.cleanUpAfterDestroy()))});var Br=0,ht=class{constructor(...t){this.isUnit=!0,this.data=null,this.persist=null,this.nest=null,this.state=null,this.panel=null,this.parent=null,this.unitType=null,this._classId,this.cached=[],this.init();let{props:e,children:r}=we(t);this.setupProps(e),this.children=r||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Br++,this.unitType=this._classId||this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=this.persistedCount++,r="pc"+e,n=Object.keys(this.persistedChildren)[e],o=this.persistedChildren[n];return o&&t.unitType===o.unitType&&(r=n,t.resumeScope(o)),t.persistToken=r,this.persistedChildren[r]=t,r}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){let t=this.getParentContext(),e=this.setContext(t);if(e){this.context=e;return}this.context=t,this.setupAddingContext()}setupAddingContext(){let t=this.context,e=this.addContext(t);if(!e)return;let r=e[0];r&&(this.addingContext=!0,this.contextBranchName=r,this.addContextBranch(r,e[1]))}addContextBranch(t,e){this.context??={},this.context[t]=e}setContext(t){return null}addContext(t){return null}removeContext(){this.addingContext&&this.removeContextBranch(this.contextBranchName)}removeContextBranch(t){t&&delete this.context[t]}getContext(){return this.context}onCreated(){}render(){return{}}_cacheRoot(t){return t&&(t.id||(t.id=this.getId()),t.cache="panel",t)}_createLayout(){return this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}afterBuild(){m.add(this.panel,"components",{component:this}),this.rendered=!0,this.afterLayout()}afterLayout(){this.afterSetup()}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var i=0,n=t.length;i<n;i++){let o=e(t[i],i);r.push(o)}return r}removeAll(t){return T.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),String(e)}cacheEle(t,e){e&&(this[e]=t,this.cached.push(e))}initialize(){this.setupContext(),this.beforeSetup()}beforeSetup(){}afterSetup(){}setup(t){this.setContainer(t),this.initialize()}setContainer(t){this.container=t}_remove(){this.prepareDestroy(),this.removeContext();let t=this.panel;t&&T.removeElement(t),this.cleanUpAfterDestroy()}cleanUpAfterDestroy(){this.panel=null,this.container=null,this.cached.forEach(t=>{this[t]=null}),this.cached=[],this.persist!==!0&&(this.persistedChildren={},this.persistToken=null)}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&typeof this.data.unlink=="function"&&this.data.unlink()}beforeDestroy(){}destroy(){this._remove()}};var k=class extends ht{constructor(...t){super(...t),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this.data=t.data,this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,t.context&&(this.context=t.context),this.id=t.id,this._refreshData()}_refreshData(){let t=this.setData();t&&this.data&&this.data.set(t.stage),this._refreshContextData()}_refreshContextData(){let t=this.context;if(!t||!t.data)return;let e=this.getParentContext();!e||!e.data||t.data.set(e.data.stage)}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=B.getTarget(String(e))}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();b.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new Bt(this.state,t))}addState(t){!this.stateHelper||this.stateResumed==!0||this.stateHelper.addStates(this.state,t)}removeStates(){let t=this.state;t&&(this.stateHelper.removeRemoteStates(t),t.remove(),this.stateResumed=!1)}onFlush(t){let e=this.data??this?.context?.data??null;e&&e.onFlush(t)}setEventHelper(){this.events||(this.events=new It)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events&&this.events.addEvents(t))}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&this.persist!==!0&&this.data.unlink()}};var Rt={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var Rr=(s,t)=>typeof s!="function"&&t==="setupStates"?()=>s:s,ee=(s,t)=>(s&&Object.entries(s).forEach(([e,r])=>{let i=Rt[e]||e;t[i]=Rr(r,i)}),t),Hr=s=>ee(s,{}),Nr=0,De=(s,t)=>{class e extends s{}return Object.assign(e.prototype,t),e.prototype._classId="jot"+Nr++,e},F=(s,t=k)=>{s||(s={});let e,r=typeof s;return r==="object"&&s.render?(e=Hr(s),De(t,e)):(e={render:r==="function"?s:()=>s},De(t,e))};var _r=(s,t)=>(Object.entries(s).forEach(([e,r])=>{let i=Rt[e]||e;t.prototype[i]=r}),t),Lr=0,Fr=s=>{let t=class extends s{};return t.prototype._classId="pod"+Lr++,t},Ur=(s,t=k)=>{if(!s)return null;let e=Fr(t),r={},i=s(r);return _r(r,e),e.prototype.render=i,e};var Wr={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],getDayName(s=new Date().getDay(),t=!1){if(typeof Intl<"u"){let i=new Date(2004,0,4+s);return new Intl.DateTimeFormat(void 0,{weekday:t?"short":"long"}).format(i)}let e=this.dayNames;if(s>e.length)return null;let r=e[s];return t?r.substring(0,3):r},convertJsMonth(s){return this.padNumber(s+1)},convertDate(s,t=!1){s=s?s.replace(/\s/,"T"):"";let e=new Date(s);if(typeof Intl<"u"){let i={weekday:"long",month:"short",day:"2-digit"};return t&&(i.year="numeric"),new Intl.DateTimeFormat(void 0,i).format(e)}let r=t===!0?" "+e.getFullYear():"";return this.getDayName(e.getDay())+", "+this.getMonthName(e.getMonth(),!0)+" "+this.padNumber(e.getDate())+r},padNumber(s){return s<=9?"0"+s:String(s)},createDate(s){return s?(typeof s=="string"&&s.indexOf("-")>-1&&(s=s.replace(/\s/,"T"),s=s.indexOf(":")>-1?s:s+"T00:00:00"),new Date(s)):new Date},format(s,t){let e=this.createDate(t);return s!=="sql"&&typeof Intl<"u"?new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}).format(e):this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),s)},formatTime(s,t){let e=this.createDate(s);if(t!==24&&typeof Intl<"u")return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!0}).format(e);let r=t===24?"sql":"standard";return this.renderTime(e.getHours(),e.getMinutes(),e.getSeconds(),r)},getMeridian(s){return s=Number(s),s>=12?"PM":"AM"},convert24To12(s){return s=Number(s),s>12&&(s=s-12),s},convert12To24(s,t){return s=Number(s),t.toLowerCase()==="pm"&&(s=s+12),s},renderDate(s,t,e,r="sql"){return t=Number(t),e=Number(e),r==="sql"?`${s}-${this.padNumber(t)}-${this.padNumber(e)}`:`${this.padNumber(t)}/${this.padNumber(e)}/${s}`},renderTime(s,t,e=0,r="sql"){if(r==="sql")return`${this.padNumber(s)}:${this.padNumber(t)}:${this.padNumber(e)}`;let i=this.getMeridian(s);return s=this.convert24To12(s),`${s}:${this.padNumber(t)} ${i}`},leapYear(s){return s%400===0||s%100!==0&&s%4===0},getMonthName(s=new Date().getMonth(),t=!1){if(typeof Intl<"u"){let i=new Date(2e3,s,1);return new Intl.DateTimeFormat(void 0,{month:t?"short":"long"}).format(i)}let e=this.monthNames;if(s>e.length)return"";let r=e[s];return r?t?r.substring(0,3):r:""},getMonthLength(s,t){let e=new Date;return s=typeof s<"u"?s:e.getMonth(),t=typeof t<"u"?t:e.getFullYear(),this.getMonthsLength(t)[s]},getMonthsLength(s=new Date().getFullYear()){return this.leapYear(s)===!0?[31,29,31,30,31,30,31,31,30,31,30,31]:[31,28,31,30,31,30,31,31,30,31,30,31]},getLocalDate(s,t="America/Denver"){let e=new Date(s);if(Number.isNaN(e.getMonth())===!0){let n=/[- :]/,o=s.split(n);e=new Date(o[0],o[1]-1,o[2],o[3],o[4],o[5])}let r=new Date(Date.parse(e.toLocaleString("en-US",{timeZone:t}))),i=e.getTime()-r.getTime();return new Date(e.getTime()+i)},getLocalTime(s,t=!1,e=!1,r="America/Denver"){if(!s)return"";let i=this.getLocalDate(s,r);if(!t&&typeof Intl<"u"){let c={hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0};return e===!1&&(c.year="numeric",c.month="2-digit",c.day="2-digit"),new Intl.DateTimeFormat(void 0,c).format(i)}let n=i.getMonth()+1,o=t===!0?"sql":"standard",a="";return e===!1&&(a+=this.renderDate(i.getFullYear(),n,i.getDate(),o)+" "),a+this.renderTime(i.getHours(),i.getMinutes(),i.getSeconds(),o)},getDiffFromNow(s,t=!1){s=s.replace(/\s/,"T");let e=new Date(s),r=new Date;return t===!0&&r.setHours(0,0,0,0),r.getTime()-e.getTime()},getAge(s){let t=this.getDiffFromNow(s),e,r;switch(!0){case t<864e5:e="1 day";break;case t<6048e5:r=this.toDays(t),e=r+" days";break;case t<12096e5:e="1 week";break;case t<2592e6:r=this.toDays(t);var i=Math.floor(r/7);e=i+" weeks";break;case t<5184e6:e="1 month";break;case t<31104e6:var n=this.toMonths(t);e=n+" months";break;default:var o=this.toYears(t);e=o}return String(e)},getTimeFrame(s){let t=this.getDiffFromNow(s);return this.convertToEstimate(t)},convertToEstimate(s){let t="",e,r,i,n,o,a,c;if(s<=0)switch(!0){case s<-63072e6:i=this.toYears(Math.abs(s)),t="in "+i+" y";break;case s<-31536e6:t="in 1y";break;case s<-5184e6:n=this.toMonths(Math.abs(s)),t="in "+n+"mo";break;case s<-2592e6:t="in 1mo";break;case s<-12096e5:e=this.toDays(Math.abs(s)),r=Math.floor(e/7),t="in "+r+"w";break;case s<-6048e5:t="in 1w";break;case s<-1728e5:e=this.toDays(Math.abs(s)),t="in "+e+"d";break;case s<-864e5:t="tomorrow";break;case s<-72e5:o=this.toHours(Math.abs(s)),t="in "+o+" h";break;case s<=-36e5:t="in 1h";break;case s<-12e4:a=this.toMinutes(Math.abs(s)),t="in "+a+"m";break;case s<-6e4:t="in 1m";break;case s<-2e3:c=this.toSeconds(Math.abs(s)),t="in "+c+"s";break;case s<-1:t="in 1s";break;default:t="now"}else switch(!0){case s<1e3:t="1s ago";break;case s<6e4:c=this.toSeconds(s),t=c+"s ago";break;case s<12e4:t="1m ago";break;case s<36e5:a=this.toMinutes(s),t=a+"m ago";break;case s<72e5:t="1h ago";break;case s<864e5:o=this.toHours(s),t=o+"h ago";break;case s<1728e5:t="yesterday";break;case s<6048e5:e=this.toDays(s),t=e+"d ago";break;case s<12096e5:t="1w ago";break;case s<2592e6:e=this.toDays(s),r=Math.floor(e/7),t=r+"w ago";break;case s<5184e6:t="1mo ago";break;case s<31536e6:n=this.toMonths(s),t=n+"mo ago";break;case s<63072e6:t="1y ago";break;default:i=this.toYears(s),t=i+"y ago"}return t},toYears(s){return typeof s!="number"?0:Math.floor(s/31558464e3)},toMonths(s){return typeof s=="number"?Math.floor(s/2592e6):0},toDays(s){return typeof s!="number"?0:Math.floor(s/864e5*1)},toHours(s){return typeof s!="number"?0:Math.floor(s%864e5/36e5*1)},toMinutes(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5/6e4*1)},toSeconds(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5%6e4/1e3*1)},getDifference(s,t){let e=new Date(s),r=new Date(t),i=r.getTime()-e.getTime();return{years:this.toYears(i),days:this.toDays(i),hours:this.toHours(i),minutes:this.toMinutes(i),seconds:this.toSeconds(i)}}};var Te=(s,t)=>({name:s,callBack:t});var Y={keys:[],items:{},add(s,t){return this.keys.push(s),this.items[s]=Te(s,t),this},get(s){return this.items[s]||null},all(){return this.keys}};var re=(s,t)=>({attr:s,directive:t});var U=(s,t)=>({key:s,value:t});var Ae=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var H=class{static getTag(t){return t.tag||"div"}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,r,i){return t==="text"?(i.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(r.push(U("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){t.push(re(U(e,w.getWatcherSettings(r,nt(e))),Y.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let i=e.type||"button";r.push(U("type",i))}}static parse(t,e){let r=[],i=[],n=this.getTag(t);this.setButtonType(n,t,r),this.setupChildren(t);let o=[],a,c,u=Object.keys(t);for(let h=0,d=u.length;h<d;h++){let p=u[h];if(p==="tag"||(a=t[p],a==null))continue;if(p==="children"){if(Array.isArray(a))for(let D=0;D<a.length;D++)o.push(a[D]);else o.push(a);continue}if((c=Y.get(p))!==null){i.push(re(U(p,a),c));continue}let x=typeof a;if(x==="object"){if(w.isWatching(a)){this.setTextAsWatcher(i,p,a);continue}o.push(a);continue}if(x==="function"){let D=a,et=function(ft){D.call(this,ft,e)};et.originalCallback=D,r.push(U(p,et));continue}if(w.isWatching(a)){this.setTextAsWatcher(i,p,a);continue}this.setElementContent(p,a,r,o)||r.push(U(p,a))}return Ae(n,r,i,o)}};var X=class{build(t,e,r){}setupComponent(t,e,r){let i=r?.getChildScope();t.parent=i,i&&i.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&i&&(i[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),r=this.build(e,t.container,t);return t.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(t),r}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t),t}setDirectives(t,e,r){}removeNode(t){}removeAll(t){}};var Ht=class extends X{build(t,e,r){let i=C.createDocFragment();if(Array.isArray(t))for(let n=0,o=t.length;n<o;n++)this.buildElement(t[n],i,r);else this.buildElement(t,i,r);return e&&typeof e=="object"&&e.appendChild(i),i}buildElement(t,e,r){if(t){if(t.isUnit===!0){this.createComponent(t,e,r);return}this.createElement(t,e,r)}}createElement(t,e,r){let i=r?.getChildScope();if(t.data||t.state){this.createTempComponent(t,e,i);return}let n=H.parse(t,i),o=this.createNode(n,e,i);this.cache(o,t.cache,r);let a=n.children;for(let u=0,h=a.length;u<h;u++){let d=a[u];d!==null&&this.buildElement(d,o,r)}let c=n.directives;c&&c.length&&this.setDirectives(o,c,i)}createTempComponent(t,e,r){let i={cache:t.cache,setData:()=>t.data,...ee(t.methods||{},{}),render(){return{...t,data:null,state:null}}};t.state&&(i.setupStateTarget=function(o){this.state=t.state});let n=new k(i);this.createComponent(n,e,r)}setDirectives(t,e,r){for(let i=0,n=e.length;i<n;i++)this.handleDirective(t,e[i],r)}handleDirective(t,e,r){e.directive.callBack(t,e.attr.value,r)}cache(t,e,r){r&&e&&r.cacheEle(t,e)}createNode(t,e,r){let i=t.tag;if(i==="text"){let n=t.attr[0],o=n?n.value:"";return C.createText(o,e)}else if(i==="comment"){let n=t.attr[0],o=n?n.value:"";return C.createComment(o,e)}return C.create(i,t.attr,e,r)}removeNode(t){C.removeElement(t)}removeAll(t){C.removeAll(t)}};var jr=["area","base","br","col","embed","hr","img","input","link","meta","source"],G=class{static create(t,e=[],r=""){let i=this.getInnerContent(e);i+=this.getInnerHtml(e);let n=this.createAttributes(e);return jr.includes(t)?`<${t} ${n} />`:`<${t} ${n}>`+i+r+`</${t}>`}static getInnerContent(t){let e="";return t.forEach(({key:r,value:i},n)=>{if(r!=="text"&&r!=="textContent")return"";t.splice(n,1),e+=i}),e}static getInnerHtml(t){let e="";return t.forEach(({key:r,value:i},n)=>{if(r!=="html"&&r!=="innerHTML")return"";t.splice(n,1),e+=i}),e}static createAttributes(t=[]){return!t||t.length<1?"":t.map(e=>{let{key:r,value:i}=e;return typeof i=="function"&&(r="on"+ot(r)),`${r}="${i}"`}).join(" ")}static createText(t){return t}static createComment(t){return`<!-- ${t} -->`}};var Nt=class extends X{build(t,e,r){return(Array.isArray(t)?t:[t]).map(n=>this.buildElement(n,r)).join("")}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t)}buildElement(t,e){return t?t.isUnit===!0?this.createComponent(t,{},e):this.createElement(t,e):""}createElement(t,e){let r=H.parse(t,e),i=r.children.map(n=>n!==null?this.buildElement(n,e):"").join("");return this.createNode(r,i)}createNode(t,e){let r=t.tag;if(r==="text"){let i=t.attr[0],n=i?i.value:"";return G.createText(n)}else if(r==="comment"){let i=t.attr[0],n=i?i.value:"";return G.createComment(n)}return G.create(r,t.attr,e)}removeAll(t){}};var _t=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new Ht:new Nt}};var W=_t.setup(),$r=s=>typeof s=="object"&&s.isUnit===!0,Vr=s=>{let t=F(s);return t?new t:null},g=class{static render(t,e,r){return!t||($r(t)||(t=Vr(t)),!t)?null:W.createComponent(t,e,r)}static build(t,e,r){return W.build(t,e,r)}static rebuild(t,e,r){return W.removeAll(e),this.build(t,e,r)}static setDirectives(t,e,r){W.setDirectives(t,e,r)}static createNode(t,e,r){return W.createNode(t,e,r)}static removeNode(t){W.removeNode(t)}static removeAll(t){W.removeAll(t)}};A.augment({buildLayout(s,t,e){g.build(s,t,e)}});var se=[],zr=s=>se.indexOf(s)!==-1,qr=s=>({tag:"script",src:s.src,async:!1,load(t){se.push(s.src);let e=s.load;e&&e()}}),Jr=s=>({tag:"link",rel:"stylesheet",type:"text/css",href:s.src,load(t){se.push(s.src);let e=s.load;e&&e()}}),Lt=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,r=this.update.bind(this);t.indexOf(".css")!==-1?e=Jr({load:r,src:t}):e=qr({load:r,src:t}),g.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{zr(e)||this.add(e)})}update(){if(this.updateProgress()<100)return;let e=this.callBack;e&&e()}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}};var Qr=s=>s?typeof s?.prototype?.constructor=="function":!1,K=class{static process(t,e){let r=t.default;return r?e.callback?e.callback(r):(Qr(r)?r=new r:r=r(),r.isUnit===!0&&(r.route=e.route,e.persist&&(r.persist=!0)),r):null}static render(t,e,r){let i=g.build(t,null,r),n=i.firstChild||t?.panel;return e.after(i),n}};var Ft=class{static load(t,e,r){return t.then(i=>(e&&e(i),i)).catch(i=>{console.error("Error loading module:",i),r&&r(i)})}};var Yr=s=>({tag:"comment",textContent:"import placeholder",onCreated:s.onCreated}),Ut=new Map,Xr=s=>{if(Ut.has(s)){let r=Ut.get(s);return r&&typeof r.then!="function"?Promise.resolve(r):r}let t=typeof s,e;if(t==="string")e=import(s);else if(t==="function")e=s();else return s;return e.then(r=>{Ut.set(s,r)}),Ut.set(s,e),e},Ee=F({declareProps(){this.loaded=!1,this.generation=0},render(){return Yr({onCreated:s=>{if(this.src){if(this.layout){this.layoutRoot=K.render(this.layout,this.panel,this.parent);return}if(this.depends){new Lt(()=>{this.loadAndRender(s)}).addFiles(this.depends);return}this.loadAndRender(s)}}})},loadAndRender(s){let t=this.generation;Ft.load(Xr(this.src),e=>{if(t!==this.generation)return;this.loaded=!0;let r=this.layout||K.process(e,{callback:this.callback,route:this.route,persist:this.persist});this.layout=r,this.layoutRoot=K.render(r,s,this.parent)},e=>{t===this.generation&&(this.loaded=!1)})},shouldUpdate(s){return this.updateLayout===!0?!0:this.updateLayout=s&&s.isUnit&&typeof s.update=="function"},updateModuleLayout(s){let t=this.layout;this.shouldUpdate(t)&&t&&t.update(s)},update(s){this.loaded===!0&&this.updateModuleLayout(s)},destroy(){this.generation++,this.layoutRoot&&(g.removeNode(this.layoutRoot),this.persist!==!0&&(this.layoutRoot=null,this.layout=null,this.loaded=!1,this.updateLayout=!1))}});var ie=s=>{let t=typeof s;return(t==="string"||t==="function"||s instanceof Promise)&&(s={src:s}),new Ee(s)};var Pe=(s,t,e=null)=>{if(!s)return;let r=null,i=!1,n=()=>{i||(i=!0,r&&(clearTimeout(r),r=null),f.off("animationend",s,o),s&&y.removeClass(s,t),e&&e())},o=a=>{a.target===s&&n()};f.on("animationend",s,o),requestAnimationFrame(()=>{if(!s){n();return}y.addClass(s,t);try{let a=window.getComputedStyle(s),c=parseFloat(a.animationDuration)*1e3||1e3,u=parseFloat(a.animationDelay)*1e3||0;r=setTimeout(n,c+u+100)}catch{r=setTimeout(n,1e3)}})},Me=(s,t,e)=>{Pe(s,t)},Oe=(s,t,e)=>{let r=()=>{s&&s.remove&&s.remove()};Gr(s,()=>Pe(s,t,r),e)};m.addType("manual-destroy",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var Gr=(s,t,e)=>{m.add(s,"manual-destroy",{ele:s,callBack:t,parent:e})};var lt=(s,t,e,r)=>{if(Array.isArray(e[0])){e.forEach(i=>{i&&lt(s,t,i,r)});return}Kr(s,t,e,r)},Kr=(s,t,e,r)=>{let i,n;if(e.length<3?[i,n]=e:[t,i,n]=e,!t||!i)return;if(typeof t.on!="function"){console.warn('Watcher directive: Data source does not have an "on" method. Make sure your component has data, state, or context.data initialized before using watchers like onSet, watch, or [[prop]] syntax.',s,t);return}let o=Zr(s,i,n,r);S.watch(s,t,i,o)},Zr=(s,t,e,r)=>typeof e=="object"?i=>{rs(s,e,i)}:i=>{ts(s,e,t,i,r)},ts=(s,t,e,r,i)=>{let n=t(r,s,i);switch(typeof n){case"object":es(n,s,i);break;case"string":let o=Dt(s);if(o!=="textContent"){y.setAttr(s,o,n);break}T.addHtml(s,n);break}},es=(s,t,e)=>{g.rebuild(s,t,e)},rs=(s,t,e)=>{for(let[r,i]of Object.entries(t))r&&(i===e?y.addClass(s,r):y.removeClass(s,r))};var Z=(s,t,e)=>{let r=E(e);lt(s,r,t,e)};var Ie=(s,t,e)=>{t&&t&&y.setAttr(s,"role",t)},ss=s=>(t,e)=>{let r=t?"true":"false";y.setAttr(e,s,r)},Be=(s,t,e)=>{if(!t)return;let r=t.role;r&&(y.setAttr(s,"role",r),t.role=null),Object.entries(t).forEach(([i,n])=>{if(n===null)return;let o=`aria-${i}`;if(Array.isArray(n)){let a=[...n];a.push(ss(o)),Z(s,a,e)}else y.setAttr(s,o,n)})};var Re=(s,t,e)=>{if(!t)return;let r=H.parse(t,e);C.addAttributes(s,r.attr,e),g.setDirectives(s,r.directives,e)};m.addType("context",s=>{if(!s)return!1;s.parent.removeContextBranch(s.branch)});var ne=s=>s?s.getContext():null,He=(s,t,e)=>{if(typeof t!="function")return;let r=ne(e),i=t(r);Re(s,i,e)},Ne=(s,t,e)=>{if(typeof t!="function")return;let r=ne(e);t(r)},_e=(s,t,e)=>{if(typeof t!="function"||!e)return;let r=ne(e),i=t(r);i&&e.addContextBranch(i[0],i[1])};var Le=(s,t,e)=>{};var Fe=(s,t,e)=>{if(!e)return;let r=e._layout?e._layout:e.render();console.log("Debug: ","ele: ",s),console.log("Data: ",t),console.log("Layout: ",r),console.log("parent: ",e)};var Ue=(s,t,e)=>{},We=(s,t,e)=>{if(!t||!e)return;let r=t(e,s);r&&g.build(r,s,e)},je=(s,t,e)=>{if(!t||!e)return;let r=e.getId(t);s.id=r},$e=(s,t,e)=>{if(!t||!e)return;let r=t(e.data,s);r&&g.build(r,s,e)},Ve=(s,t,e)=>{if(!t||!e)return;let r=t(e.state,s);r&&g.build(r,s,e)},ze=(s,t,e)=>{if(!t||!e)return;let r=e.state,i=t(r);if(!e.state){e.setStateHelper(i);return}e.addState(i)},qe=(s,t,e)=>{if(!(!t||!e)){if(e.events||e.setEventHelper(),t[2]){let r=t[2];t[2]=i=>{r(i,e)}}e.events.on(...t)}};var Je=(s,t,e)=>{let r,i,n;if(typeof t=="string"){if(r=E(e),!r)return;i=t}else if(Array.isArray(t)){if(typeof t[0]!="object"){let o=E(e);if(!o)return;t.unshift(o)}[r,i,n]=t}S.bind(s,r,i,n)};var Wt=(s,t,e)=>{lt(s,e.state,t,e)};var Qe=s=>(t,e)=>{let[r,i,n="active"]=s,o=t===i?n:"";y.setData(e,r,o)},Ye=(s,t,e)=>{if(!t)return;let r=[...t],i=r.pop();r.push(Qe(i)),Z(s,r,e)},Xe=(s,t,e)=>{if(!t)return;let r=[...t],i=r.pop();r.push(Qe(i)),Wt(s,r,e)};var Ge=(s,t,e)=>{let r,i,n,o;if(t.length<3){let c=E(e);if(!c)return;r=c,[i,n,o]=t}else[r,i,n,o]=t;let a=o!==!1;S.watch(s,r,i,c=>{if(g.removeAll(s),!c||c.length<1)return;let u=[];for(let h=0,d=c.length;h<d;h++){let p=a?r.scope(`${i}[${h}]`):null,x=n(c[h],h,p,u);x!==null&&u.push(x)}return g.build(u,s,e)})};var Ke=(s,t,e)=>{let r=t[0];if(!r||r.length<1)return;let i=t[1],n=[];for(let o=0,a=r.length;o<a;o++){let c=r[o];if(!c)continue;let u=i(c,o);u!==null&&n.push(u)}g.build(n,s,e)};var Ze=(s,t,e)=>{t(s,e)};m.addType("destroyed",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var tr=(s,t,e)=>{is(s,t,e)},is=(s,t,e)=>{m.add(s,"destroyed",{ele:s,callBack:t,parent:e})};var er=(s,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(var r=0,i=t.length;r<i;r++)w.setup(s,t[r],e);else w.setup(s,t,e)};var ns=0,tt=class{constructor(t){this.router=t,this.locationId="base-app-router-"+ns++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}check(t){}getScrollPosition(){return{x:window.scrollX,y:window.scrollY}}scrollTo(t){window.scrollTo(t.x,t.y)}addEvent(){return this}};var jt=class extends tt{addEvent(){return f.on("popstate",window,this.callBack),this}removeEvent(){return f.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri);let r=e.scrollPosition;r&&this.scrollTo(r)}createState(t,e={}){let r=this.getScrollPosition();return e=e===null?{}:e,{location:this.locationId,...e,scrollPosition:r,uri:t}}addState(t,e,r=!1){let i=window.history,n=i.state;if(n&&n.uri===t)return this;let o=this.createState(t,e);return i[r===!1?"pushState":"replaceState"](o,null,t),this}};var $t=class extends tt{addEvent(){return f.on("hashchange",window,this.callBack),this}removeEvent(){return f.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};var Vt=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new jt(t).setup():new $t(t).setup()}};var oe=class extends k{getChildScope(){return this.parent}},rr=s=>F(s,oe);var zt=class{constructor(t,e){this.route=t,this.template=e.component,this.component=null,this.hasTemplate=!1,this.setup=!1,this.container=e.container,this.persist=e.persist,this.parent=e.parent}focus(t){this.setup===!1&&(this.route&&typeof this.route.flushPending=="function"&&this.route.flushPending(),this.create()),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){this.template=this.template(),this.initializeTemplateObject()}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){let t=this.template;if(!t)return;t.isUnit||(this.template=new(rr(t)));let e=this.template;this.transferSettings(e)}create(){if(this.setupTemplate(),!this.hasTemplate)return;this.setup=!0;let t=this.component;g.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return;this.setup=!1;let t=this.component;t&&(typeof t.destroy=="function"&&t.destroy(),this.component=null)}update(t){let e=this.component;e&&typeof e.update=="function"&&e.update(t)}};var sr=s=>{if(!s.length)return null;let t={};return s.forEach(e=>{t[e]=null}),t},ir=s=>{let t=[];if(!s)return t;let e=/[*?]/g;s=s.replace(e,"");let r=/:(.[^./?&($]+)\?*/g,i=s.match(r);return i===null||i.forEach(n=>{n&&(n=n.replace(":",""),t.push(n))}),t};var os=s=>s.replace(/\//g,"/"),as=s=>s.replace(/(\/):[^/(]*?\?/g,t=>t.replace(/\//g,"(?:$|/)")),cs=s=>(s=s.replace(/(\?\/+\*?)/g,"?/*"),s.replace(/(:[^/?&($]+)/g,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),us=s=>s.replace(/(\*)/g,".*"),hs=(s,t)=>s+=t[t.length-1]==="*"?"":"$",nr=s=>{if(!s)return"";let t=os(s);return t=as(t),t=cs(t),t=us(t),t=hs(t,s),t};var ls=0,qt=class extends O{constructor(t,e){let r=t.baseUri,i=ir(r),n=sr(i),o=super(n);return this.uri=r,this.paramKeys=i,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),o}setup(){this.stage={},this.routeId=null,this.uri=null,this.uriQuery=null,this.controller=null,this.paramKeys=[],this.titleCallBack=()=>{},this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1}setupRoute(t){this.routeId=t.id||"bs-rte-"+ls++,this.path=null,this.referralPath=null;let e=nr(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1}setTitle(t){this.title=t,this.titleCallBack(this,t)}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?ie(e):null}setupComponentHelper(t){let e=this.getLayout(t);if(!e)return;let{container:r,persist:i,parent:n}=t,o={component:e,container:r,persist:i,parent:n},a=Et(this);this.controller=new zt(a,o)}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let i=this.path;if(!i)return;let n=i.split("#")[1];n&&this.scrollToId(n)}scrollToId(t){if(!t)return;let e=document.getElementById(t);e&&e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(Array.isArray(r)&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(!Array.isArray(t))return;let e=this.paramKeys;if(!e)return;let r={};e.forEach((i,n)=>{typeof i<"u"&&(r[i]=t[n])}),this.set(r)}getParams(){return this.stage}};var fs=s=>{let t=/\w\S*/;return s.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},ds=(s,t)=>{if(s.indexOf(":")===-1)return s;let e=t.stage;for(let[r,i]of Object.entries(e)){let n=new RegExp(":"+r,"gi");s=s.replace(n,i)}return s},ps=(s,t)=>t&&(typeof t=="function"&&(t=t(s.stage)),t=ds(t,s),fs(t)),ms=(s,t)=>(t!==""&&(s+=" - "+t),s),or=(s,t,e)=>t&&(t=ps(s,t),ms(t,e));var ar={removeSlashes(s){return typeof s!="string"?"":(s.substring(0,1)==="/"&&(s=s.substring(1)),s.substring(-1)==="/"&&(s=s.substring(0,s.length-1)),s)}};var cr=(s,t)=>({attr:s,value:t}),gs=(s,t)=>new RegExp("^"+s+"($|#|/|\\.).*").test(t),Jt=class extends k{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",class:this.class||this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),nest:this.nest||this.children,dataStateSet:this.dataSet,watch:r}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact===!0,i=M.data,n=[];return t&&typeof t=="object"&&n.push(cr("href",t)),e&&typeof e=="object"&&n.push(cr("text",e)),n.push({value:["[[path]]",i],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.hash,u=r?o===c:gs(a.pathname,o);this.update(u)}}),n}setupStates(){return{selected:!1}}update(t){this.state&&(this.state.selected=t)}};var ys=()=>typeof window<"u"?window.location:{},ae=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.lastMatchedRoute=null,this.history=null,this.callBackLink=null,this.location=ys(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new I({path:""})}setupHistory(){this.history=Vt.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new qt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+ar.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(let i=0;i<r;i++){let n=e[i];if(n.uri===t)return n}return null}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(let i=0;i<r;i++){let n=e[i];if(n.routeId===t)return n}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1),this.lastMatchedRoute===t&&(this.lastMatchedRoute=null)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);return t.forEach(i=>{if(!i)return;let n=this.createRoute(i);r.push(n)}),this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,i=this.getSwitchGroup(r);return t.forEach(n=>{let o=n.component.route;o.resume(e),i.push(o)}),this.checkGroup(i,this.getPath()),r}getSwitchGroup(t){let e=this.switches.get(t);if(e)return e;let r=[];return this.switches.set(t,r),r}removeSwitch(t){this.switches.delete(t)}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.path=this.getPath(),this.callBackLink=this.checkLink.bind(this),f.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){return t.closest("a")}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target.closest("a");if(!e||e.target==="_blank"||e.dataset.cancelRoute)return!0;let r=e.getAttribute("href");if(r!==null){let i=this.baseURI,n=i!=="/"?r.replace(i,""):r;return this.navigate(n),t.preventDefault(),t.stopPropagation(),!1}}reset(){let t=this.routes;for(let e=0,r=t.length;e<r;e++){let i=t[e];i&&typeof i.deactivate=="function"&&i.deactivate()}return this.routes=[],this.switches=new Map,this.switchCount=0,this.lastMatchedRoute=null,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.path=t}updateTitle(t){if(!t||!t.title)return this;let e=t.title;document.title=or(t,e,this.title)}checkActiveRoutes(t){if(this.lastPath=this.path,t=t||this.getPath(),this.path=t,this.lastMatchedRoute&&this.check(this.lastMatchedRoute,t))this.select(this.lastMatchedRoute);else{let e=this.routes,r=e.length;for(let i=0;i<r;i++){let n=e[i];typeof n>"u"||this.checkRoute(n,t)}}this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(let r of e.values())this.checkGroup(r,t)}checkGroup(t,e){if(!t.length)return;let r=t.find(o=>o.get("active"));r&&r.match(e)===!1&&r.deactivate();let i;for(let o of t){if(typeof o>"u")continue;if(i){o.deactivate();continue}o.match(e)!==!1&&i===void 0&&o.controller&&(i=o,this.select(o))}let n=t[0];i||this.select(n)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?(this.select(t),this.lastMatchedRoute=t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),t.preventScroll!==!0&&this.checkToScroll())}checkToScroll(){this.shouldScrollToTop()&&window.scrollTo(0,0)}cleanPath(t){return t?t.split("?")[0].split("#")[0]:"/"}shouldScrollToTop(){let t=this.cleanPath(this.getPath()),r=this.cleanPath(this.lastPath).split("/"),i=t.split("/");if(r.length!==i.length)return!0;let n=r[r.length-1],o=i[i.length-1];return n!==o}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){typeof this.callBackLink=="function"&&f.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},M=new ae;m.addType("routes",s=>{if(!s)return!1;let t=s.route;t&&M.removeRoute(t)});var hr=(s,t,e)=>{t&&(Array.isArray(t)?t.forEach(r=>{r&&ur(s,r,e)}):ur(s,t,e))},ur=(s,t,e)=>{t.container=s,t.parent=e;let r=M.add(t);bs(s,r)},bs=(s,t)=>{m.add(s,"routes",{route:t})};var lr=(s,t,e)=>{};m.addType("switch",s=>{if(!s)return!1;let t=s.id;M.removeSwitch(t)});var fr=(s,t,e)=>{let r=t[0];t.forEach(n=>{n&&(n.container=s,n.parent=e)});let i=M.addSwitch(t);xs(s,i)},xs=(s,t)=>{m.add(s,"switch",{id:t})};Y.add("cache",Ue).add("onCreated",Ze).add("onDestroyed",tr).add("bind",Je).add("data",Le).add("state",lr).add("onSet",Z).add("onState",Wt).add("animateIn",Me).add("animateOut",Oe).add("watch",er).add("useParent",We).add("useData",$e).add("useState",Ve).add("getId",je).add("addState",ze).add("addEvent",qe).add("map",Ke).add("for",Ge).add("useContext",Ne).add("addContext",_e).add("context",He).add("role",Ie).add("aria",Be).add("route",hr).add("debug",Fe).add("dataSet",Ye).add("dataStateSet",Xe).add("switch",fr);A.augment({Ajax:gt,Html:T,dataBinder:S,Data:I,SimpleData:L,Model:J,State:Q,Builder:g,router:M,Component:k});export{gt as Ajax,R as Arrays,Dr as Atom,g as Builder,k as Component,I as Data,m as DataTracker,Wr as DateTime,Y as Directives,y as Dom,ut as Encode,Yt as Events,T as Html,ie as Import,F as Jot,J as Model,Jt as NavLink,b as Objects,Ur as Pod,L as SimpleData,Q as State,B as Store,v as Strings,l as Types,ht as Unit,A as base,S as dataBinder,M as router};
2
2
  //# sourceMappingURL=base.js.map