@base-framework/base
Version:
This is a javascript framework.
1 lines • 71.5 kB
JavaScript
var ze=Object.defineProperty;var Je=(s,t,e)=>t in s?ze(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var L=(s,t,e)=>(Je(s,typeof t!="symbol"?t+"":t,e),e);var B=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 d={create(s){return Object.create(s||null)},extendObject(s,t){return!h.isObject(s)||!h.isObject(t)?!1:(Object.keys(s).forEach(e=>{this.hasOwnProp(t,e)||(t[e]=s[e])}),t)},clone(s){return!s||!h.isObject(s)?{}: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 n=Object.create(e);for(var i in r)n[i]=r[i];return n},hasOwnProp(s,t){return Object.prototype.hasOwnProperty.call(s,t)},isPlainObject(s){return!!s&&Object.prototype.toString.call(s)==="[object Object]"},isEmpty(s){return h.isObject(s)?Object.keys(s).length===0:!0}};var Z={types:{},add(s,t){this.types[s]=t},get(s){return this.types[s]||!1},remove(s){delete this.types[s]}};var ct=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}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,n=Z.get(t);if(!!n){for(var i=0,o=e.length;i<o;i++)r=e[i],r&&(e[i]=null,this.removeByCallBack(n,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 l=class{static addType(t,e){Z.add(t,e)}static removeType(t){Z.remove(t)}static getTrackingId(t){return t?t.trackingId||(t.trackingId=`dt${this.trackingCount++}`):""}static add(t,e,r){let n=this.getTrackingId(t);this.find(n).add(e,r)}static get(t,e){let r=t.trackingId,n=this.trackers.get(r);return n?e?n.get(e):n:!1}static find(t){return this.trackers.has(t)||this.trackers.set(t,new ct),this.trackers.get(t)}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let r=t.trackingId;if(!r||!this.trackers.has(r))return;let n=this.trackers.get(r);if(!e){n.remove(),this.trackers.delete(r);return}n.remove(e),this.isEmpty(n.types)&&this.trackers.delete(r)}};L(l,"trackers",new Map),L(l,"trackingCount",0);var _t=s=>{let t=0;for(let[e,r]of Object.entries(s))t++,typeof s[e]=="object"&&(t+=_t(s[e]));return t},Qt=(s,t)=>{let e=!1;if(typeof s!="object"||typeof t!="object")return e;for(let[r,n]of Object.entries(s)){if(!d.hasOwnProp(t,r))break;let i=t[r];if(typeof n!=typeof i)break;if(typeof n=="object"){if(e=Qt(n,i),e!==!0)break}else if(n===i)e=!0;else break}return e},qe=(s,t)=>{let e=_t(s),r=_t(t);return e!==r?!1:Qt(s,t)},Zt=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?qe(s,t):s===t};var f={getEvents(s){return h.isObject(s)===!1?[]:l.get(s,"events")},create(s,t,e,r=!1,n=!1,i=null){return n=n===!0,{event:s,obj:t,fn:e,capture:r,swapped:n,originalFn:i}},on(s,t,e,r){return Array.isArray(s)?s.forEach(n=>this.add(n,t,e,r)):this.add(s,t,e,r),this},off(s,t,e,r){if(Array.isArray(s)){var n;s.forEach(i=>this.remove(i,t,e,r))}else this.remove(s,t,e,r);return this},add(s,t,e,r=!1,n=!1,i=null){if(h.isObject(t)===!1)return this;let o=this.create(s,t,e,r,n,i);return l.add(t,"events",o),t.addEventListener(s,e,r),this},remove(s,t,e,r=!1){let n=this.getEvent(s,t,e,r);return n===!1?this:(typeof n=="object"&&this.removeEvent(n),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 n=this.getEvents(t);if(!n||n.length<1)return!1;let i=this.create(s,t,e,r);return this.search(i,n)},search(s,t){let e,r=this.isSwappable(s.event);for(var n=0,i=t.length;n<i;n++)if(e=t[n],!(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:(l.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return this.swap.includes(s)}};l.addType("events",s=>{f.removeEvent(s)});var Ut={events:f,addListener(s,t,e,r){return this.events.add(s,t,e,r),this},on(s,t,e,r){let n=this.events;return Array.isArray(s)?s.forEach(i=>{n.add(i,t,e,r)}):n.add(s,t,e,r),this},off(s,t,e,r){let n=this.events;return Array.isArray(s)?s.forEach(i=>{n.remove(i,t,e,r)}):n.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 n;switch(t){case"HTMLEvents":n=new Event(s);break;case"MouseEvents":n=new MouseEvent(s,e);break;default:n=new CustomEvent(s,r);break}return n},createEvent(s,t,e,r){if(h.isObject(t)===!1)return!1;let n={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)&&(n=Object.assign(n,e));let i=this._getEventType(s);return this._createEvent(s,i,n,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,n]of Object.entries(t))if(s.match(n)){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 n=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()},i=this.getWheelEventType();return this.events.add(i,t,n,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 tt=class{constructor(){this.errors=[],this.dataTracker=l}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,n){return(t[e]=r).apply(t,B.toArray(n))}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 n=t[e];return typeof n<"u"?n:typeof r<"u"?r:""}createCallBack(t,e,r=[],n=!1){return typeof e!="function"?!1:(...i)=>(n===!0&&(r=r.concat(i)),e.apply(t,r))}bind(t,e){return e.bind(t)}};tt.prototype.extend=function(){return tt.prototype}();var A=new tt;A.augment({...d,...Ut,...h,equals:Zt});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 n={},i=/([^?=&]+)(=([^&]*))?/g;return t.replace(i,function(o,a,c,u){n[a]=e!==!1?decodeURIComponent(u):u}),n}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,n=>e+n.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 te={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};A.augment({xhrSettings:te,addFixedParams(s){this.xhrSettings.fixedParams=s},beforeSend(s){this.xhrSettings.beforeSend.push(s)},ajaxSettings(s){typeof s=="object"&&(this.xhrSettings=d.extendClass(A.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=te}});var ut=(...s)=>new jt(s).xhr,jt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR();if(e===!1)return!1;let{method:r,url:n,async:i}=this.settings;e.open(r,n,i),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=A.xhrSettings.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var n=0,i=t.length;n<i;n++){var o=t[n];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){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let n=typeof e;if(r==="string")return n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(n==="string"&&(e=v.parseQueryString(e,!1)),t instanceof FormData)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.append(i,e[i]);else r==="object"&&(t=d.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,n=t.length;r<n;r++){var i=t[r];switch(r){case 0:e.url=i;break;case 1:e.params=i;break;case 2:e.completed=i,e.failed=i;break;case 3:e.responseType=i||"json";break;case 4:e.method=i?i.toUpperCase():"POST";break;case 5:e.async=typeof i<"u"?i:!0;break}}else e=this.settings=d.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,n=()=>{f.removeEvents(r.upload),f.removeEvents(r)},i=this.settings;if(!i)return!1;switch(e||t.type){case"load":if(typeof i.completed=="function"){let a=this.getResponseData();i.completed(a,this.xhr)}n();break;case"error":typeof i.failed=="function"&&i.failed(!1,this.xhr),n();break;case"progress":typeof i.progress=="function"&&i.progress(t);break;case"abort":typeof i.aborted=="function"&&i.aborted(!1,this.xhr),n();break}}getResponseData(){let t=this.xhr,e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=this.update.bind(this);f.on(["load","error","abort"],e,r),f.on("progress",e.upload,r)}};var Ye=s=>typeof s!="string"?s:ee(s),ee=s=>[{tag:"text",textContent:s}],ht=()=>({props:{},children:[]}),ft=s=>({props:{},children:ee(s)}),lt=s=>({props:{},children:s}),pt=s=>({props:s[0]||{},children:Ye(s[1])});var dt=class{constructor(){this.connections=new Map}add(t,e,r){return this.find(t).set(e,r),r}get(t,e){let r=this.connections.get(t);return r&&r.get(e)||!1}find(t){let e=this.connections.get(t);if(e)return e;let r=new Map;return this.connections.set(t,r),r}remove(t,e){let r=this.connections.get(t);if(!r)return;let n;if(e)n=r.get(e),n&&(n.unsubscribe(),r.delete(e)),r.size===0&&this.connections.delete(t);else{let i=r.values();for(let o of i)o&&o.unsubscribe();this.connections.delete(t)}}};var j=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var mt=class extends j{constructor(t){super(),this.data=t}subscribe(t,e){this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data.off(this.msg,this.token)}};var W=class{unsubscribe(){}};var gt=class extends W{constructor(){super(),this.source=null}addSource(t){return this.source=new mt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var $=class extends j{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.off(this.msg,this.token)}callBack(){}};var yt=class extends ${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)}};var m=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?B.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]:B.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 n=null,i=t.currentStyle;if(i&&(n=i[e]))return n;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,n=e.getElementsByTagName("body")[0],i=t.innerWidth||r.clientWidth||n.clientWidth,o=t.innerHeight||r.clientHeight||n.clientHeight;return{width:i,height:o}}static getDocumentSize(){let t=document,e=t.body,r=t.documentElement,n=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:n}}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 n=0;for(;t&&(e===0||n<e);)n++,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 i=e.split(" ");for(var r=0,n=i.length;r<n;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 Ge=(s,t,e)=>{m.setAttr(s,t,e)},Xe=(s,t,e)=>{s.checked=s.value==e},Ke=(s,t,e)=>{e=e==1,re(s,t,e)},re=(s,t,e)=>{s[t]=e},Qe=(s,t)=>m.getAttr(s,t),Ze=(s,t)=>s[t],bt=class extends ${constructor(t,e,r,n){super(n),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.substring(4,1)==="-")return this.setValue=Ge,this.getValue=Qe,this;this.getValue=Ze;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=Ke;return;case"radio":this.setValue=Xe;return}return this.setValue=re,this}getAttrBind(t){if(t)return t;let e="textContent",r=this.element;if(!r||typeof r!="object")return e;let n=r.tagName.toLowerCase();if(n==="input"||n==="textarea"||n==="select"){let i=r.type;if(!i)return e="value",e;switch(i){case"checkbox":e="checked";break;case"file":e="files";break;default:e="value"}}return e}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}};var vt=class extends W{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new bt(t,e,r,this.pubSub)}addData(t,e){return this.data=new yt(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 se=-1,F=class{constructor(){this.callBacks=new Map}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),se=-1}on(t,e){let r=(++se).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){let r=this.callBacks.get(t);if(!!r)for(let n of r.values())n&&n.apply(this,e)}};var Wt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new dt,this.pubSub=new F,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,n){let i=r,o=null;if(r.indexOf(":")!==-1){let g=r.split(":");g.length>1&&(i=g[1],o=g[0])}let a=this.setupConnection(t,e,i,o,n),c=a.element,u=e.get(i);return typeof u<"u"?c.set(u):(u=c.get(),u!==""&&a.data.set(u)),this}setupConnection(t,e,r,n,i){let o=this.getBindId(t),a=new vt(this.pubSub);a.addData(e,r).subscribe(o);let g=`${e.getDataId()}:${r}`;return a.addElement(t,n,i).subscribe(g),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.dataset&&(t.dataset[this.attr]=e),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,n){if(h.isObject(t)===!1)return this;let i=new gt;i.addSource(e).subscribe(r,n);let a=this.getBindId(t),c=e.getDataId()+":"+r;this.addConnection(a,c,i);let u=e.get(r);return typeof u<"u"&&n(u),this}unwatch(t,e,r){if(h.isObject(t)===!1)return this;let n=t[this.attr];if(n){let i=e.getDataId()+":"+r;this.connections.remove(n,i)}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.indexOf(t.keyCode)!==-1}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r!==null){let n=this.connections.get(r,"bind");if(n){let i=n.element.get();this.pubSub.publish(r,i,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)}},y=new Wt;var T=s=>s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null;var tr={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"},et=s=>tr[s]||s,rt=s=>typeof s=="string"&&s.substring(0,2)==="on"?s.substring(2):s,k=class{static create(t,e,r,n){let i=document.createElement(t);return this.addAttributes(i,e),n===!0?this.prepend(r,i):this.append(r,i),i}static addAttributes(t,e){if(!e||typeof e!="object")return;let r=e.type;typeof r<"u"&&m.setAttr(t,"type",r);for(let[n,i]of Object.entries(e))n==="innerHTML"?t.innerHTML=i:n.indexOf("-")!==-1?m.setAttr(t,n,i):this.addAttr(t,n,i)}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=rt(e),f.add(e,t,r);else{let i=et(e);t[i]=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(n=>{let i=new Option(n.label,n.value);t.options.add(i),r!==null&&i.value==r&&(i.selected=!0)})}static removeElementData(t){let e=t.childNodes;if(e){let o=e.length-1;for(var r=o;r>=0;r--){var n=e[r];!n||this.removeElementData(n)}}l.remove(t),t.bindId&&y.unbind(t)}static removeElement(t){return t?(this.removeElementData(t),t.remove(),this):this}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(!h.isObject(t))return this;let e=t.childNodes;for(var r in e)Object.prototype.hasOwnProperty.call(e,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 n=r||t.firstChild;return t.insertBefore(e,n),this}static clone(t,e=!1){return h.isObject(t)?t.cloneNode(e):!1}};var x=class extends k{static create(t,e,r,n){let i=document.createElement(t);return this.addAttributes(i,e,n),r.appendChild(i),i}static addAttributes(t,e,r){!e||e.length<1||e.forEach(n=>{let{key:i,value:o}=n;this.addAttr(t,i,o,r)})}static addAttr(t,e,r,n){if(r===""||!e)return;if(e==="innerHTML"){t.innerHTML=r;return}if(typeof r==="function"){e=rt(e),f.add(e,t,function(a){r.call(this,a,n)});return}if(e.substr(4,1)==="-"){m.setAttr(t,e,r);return}let o=et(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 $t=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,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=s.match($t);return t?t.map(e=>e.slice(2,-2)):null},updateAttr(s,t,e){switch(t){case"text":case"textContent":s.textContent=e;break;default:x.addAttr(s,t,e);break}},replaceParams(s,t,e=!1){let r=0;return s.replace($t,function(){let n=e?t[r]:t;r++;let i=n.get(arguments[2]);return typeof i<"u"?i:""})},_getWatcherCallBack(s,t,e,r,n){return()=>{let i=this.replaceParams(e,t,n);this.updateAttr(s,r,i)}},getValue(s,t){let e=s.value;return Array.isArray(e)===!1?[e,T(t)]:(e.length<2&&e.push(T(t)),e)},getPropValues(s,t,e){let r=[];for(var n=0,i=t.length;n<i;n++){var o=e?s[n]:s,a=o.get(t[n]);a=typeof a<"u"?a:"",r.push(a)}return r},getCallBack(s,t,e,r,n){let i=s.attr||"textContent",o=s.callBack;if(typeof o=="function"){let a=r.match($t)||[],c=a&&a.length>1;return(u,g)=>{u=c!==!0?u:this.getPropValues(e,a,n);let b=o(u,t,g);typeof b<"u"&&this.updateAttr(t,i,b)}}return this._getWatcherCallBack(t,e,r,i,n)},addDataWatcher(s,t,e){let r=this.getValue(t,e),n=r[1]??e?.data??e?.context?.data??e?.state??null;if(!n)return;let i=r[0],o=Array.isArray(n),a=this.getCallBack(t,s,n,i,o),c=this._getWatcherProps(i);for(var u=0,g=c.length;u<g;u++){var b=o?n[u]:n;this.addWatcher(s,b,c[u],a)}},setup(s,t,e){if(!!t){if(typeof t=="string"){this.addDataWatcher(s,{value:t},e);return}if(Array.isArray(t)){let r=t[t.length-1],n=t[1]&&typeof t[1]=="object"?[t[0],t[1]]:[t[0]];this.addDataWatcher(s,typeof r=="function"?{value:n,callBack:r}:{attr:r||"textContent",value:n},e);return}this.addDataWatcher(s,t,e)}},addWatcher(s,t,e,r){y.watch(s,t,e,r)}};var er=s=>({props:{watch:s},children:[]}),rr=s=>{if(!s)return ht();let t=s[0];return typeof t=="string"?ft(t):Array.isArray(t)?w.isWatching(t)===!1?lt(t):er(t):pt(s)},sr=s=>(...t)=>{let{props:e,children:r}=rr(t);return s(e,r)};function ne(s,t){let e=isNaN(Number(t)),r=e?t:`[${t}]`;return s===""?r:e?`${s}.${r}`:`${s}${r}`}function ie(s,t="",e=""){return{get(r,n,i){let o=r[n];if(t===""&&n in r)return typeof o=="function"?o.bind(r):o;let a=r[e]||r;if(o=Reflect.get(a,n,i),d.isPlainObject(o)||Array.isArray(o)){let c=ne(t,n);return new Proxy(o,ie(s,c,e))}return o},set(r,n,i,o){if(t===""&&n in r)return r[n]=i,!0;let a=ne(t,n);return s.set(a,i),!0}}}var xt=(s,t="stage")=>new Proxy(s,ie(s,"",t));var st=class{static resume(t,e){if(!t)return null;let r,n=localStorage.getItem(t);return n===null?e&&(r=e):r=JSON.parse(n),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 St=(s={})=>{let t={};if(!h.isObject(s))return t;let e=d.clone(s);return Object.keys(e).forEach(r=>{let n=e[r];typeof n!="function"&&(t[r]=n)}),t};var nr=0,H={CHANGE:"change",DELETE:"delete"},Ft=(s,t)=>`${s}:${t}`,P=class{constructor(t={}){this.dirty=!1,this.links={},this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new F;let e=St(t);return this.set(e),xt(this)}setup(){this.stage={}}_init(){let t=++nr;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}getDataId(){return this._id}remove(){}on(t,e){let r=Ft(t,H.CHANGE);return this.eventSub.on(r,e)}off(t,e){let r=Ft(t,H.CHANGE);this.eventSub.off(r,e)}_setAttr(t,e,r=this,n=!1){let i=this.stage[t];e!==i&&(this.stage[t]=e,this._publish(t,e,r,H.CHANGE))}publishLocalEvent(t,e,r,n){let i=Ft(t,n);this.eventSub.publish(i,e,r)}_publish(t,e,r,n){this.publishLocalEvent(t,e,r,n),r=r||this,y.publish(this._dataId+t,e,r)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,n]=t;return Object.entries(e).forEach(([i,o])=>{typeof o!="function"&&this._setAttr(i,o,r,n)}),this}getModelData(){return this.stage}_deleteAttr(t,e,r=this){delete t[e],this.publishLocalEvent(e,null,r,H.DELETE)}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t){if(typeof t>"u")return;let e=this.get(t);return this.set(t,++e),this}decrement(t){if(typeof t>"u")return;let e=this.get(t);return this.set(t,--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=st.resume(this.key,t);return e?(this.set(e),this):this}store(){let t=this.get();return st.store(this.key,t)}delete(t){if(typeof t=="string"){this._deleteAttr(this.stage,t);return}this.setup()}_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 n=[];return Object.entries(e).forEach(([i])=>{n.push(this.remoteLink(t,i))}),n}remoteLink(t,e,r){let n=r||e,i=t.get(e);typeof i<"u"&&this.get(e)!==i&&this.set(e,i);let o=t.on(e,(c,u)=>{if(u===this)return!1;this.set(n,c,t)});this.addLink(o,t);let a=this.on(n,(c,u)=>{if(u===t)return!1;t.set(e,c,this)});return t.addLink(a,this),o}addLink(t,e){this.links[t]=e}unlink(t){if(t){this.removeLink(t);return}let e=this.links;d.isEmpty(e)||(Object.entries(e).forEach(([r,n])=>{this.removeLink(n,!1)}),this.links={})}removeLink(t,e=!0){let r=this.links[t];r&&r.off(t),e!==!1&&delete this.links[t]}};P.prototype.isData=!0;var E={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(s){return s.indexOf(".")!==-1||s.indexOf("[")!==-1},getSegments(s){let t=this.deepDataPattern;return s.match(t)}};var R=class{static set(t,e,r){if(!E.hasDeepData(e)){t[e]=r;return}let n,i=E.getSegments(e),o=i.length,a=o-1;for(var c=0;c<o;c++){if(n=i[c],c===a){t[n]=r;break}t[n]===void 0&&(t[n]=isNaN(n)?{}:[]),t=t[n]}}static delete(t,e){if(!E.hasDeepData(e)){delete t[e];return}let r=E.getSegments(e),n=r.length,i=n-1;for(var o=0;o<n;o++){var a=r[o],c=t[a];if(c===void 0)break;if(o===i){if(Array.isArray(t)){t.splice(Number(a),1);break}delete t[a];break}t=c}}static get(t,e){if(!E.hasDeepData(e))return t[e];let r=E.getSegments(e),n=r.length,i=n-1;for(var o=0;o<n;o++){var a=r[o],c=t[a];if(c===void 0)break;if(t=c,o===i)return t}}};var nt=class{static publishDeep(t,e,r,n){if(!E.hasDeepData(e)){this.publish(e,r,n);return}let i,o=E.getSegments(e),a=o.length,c=a-1,u="";for(var g=0;g<a;g++){i=o[g],t=t[i],g>0?isNaN(i)&&(u+="."+i):u=i;var b;if(g===c)b=r;else{var M=o[g+1];if(isNaN(M)===!1){u+="["+M+"]";continue}var Q={};Q[M]=t[M],b=Q}this.publish(u,b,n)}}static publish(t,e,r){if(t=t||"",r(t,e),!(!e||typeof e!="object")){if(Array.isArray(e)){this.publishArray(t,e,r);return}this.publishObject(t,e,r)}}static publishArray(t,e,r){let n,i,o=e.length;for(var a=0;a<o;a++)i=e[a],n=t+"["+a+"]",this._checkPublish(n,i,r)}static publishObject(t,e,r){let n,i;for(var o in e)!Object.prototype.hasOwnProperty.call(e,o)||(i=e[o],n=t+"."+o,this._checkPublish(n,i,r))}static _checkPublish(t,e,r){if(!e||typeof e!="object"){r(t,e);return}this.publish(t,e,r)}};var O=class extends P{setup(){this.attributes={},this.stage={}}_setAttr(t,e,r,n){typeof e!="object"&&e===this.get(t)||(!r&&n!==!0?R.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),R.set(this.stage,t,e),r=r||this,this._publish(t,e,r,H.CHANGE))}linkAttr(t,e){let r=t.get(e);if(!!r)for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&this.link(t,e+"."+n,n)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let n=new e(r);return n.linkAttr(this,t),n}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}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 n=this.get(t);return Array.isArray(n)===!1?-1:typeof n[0]!="object"?n.indexOf(e):n.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,n){let i=(o,a)=>this._publishAttr(o,a,r,n);nt.publish(t,e,i)}_publishAttr(t,e,r,n){let i=this._dataId+t;y.publish(i,e,r),this.publishLocalEvent(t,e,r,n)}mergeStage(){this.attributes=d.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){R.delete(t,e);let n=(i,o)=>this.publishLocalEvent(i,o,r,H.DELETE);nt.publish(e,e,n)}_getAttr(t,e){return R.get(t,e)}};var ir={"\n":"\\n","\r":"\\n"," ":"\\t"},or=(s,t)=>{typeof s!="string"&&(s=String(s));let e=t?/[\n\r\t]/g:/\t/g;return s.replace(e,r=>ir[r])},oe=(s,t)=>{if(typeof s!="string")return s;s=or(s,t),s=encodeURIComponent(s);let e=/%22/g;return s.replace(e,'"')},Vt=(s,t)=>{let e=typeof s;return e==="undefined"?s:e!=="object"?(s=oe(s),s):(Object.entries(s).forEach(([r,n])=>{n!==null&&(s[r]=typeof n=="string"?Vt(n,t):oe(n,t))}),s)};function ae(s){return typeof s<"u"&&s.length>0?JSON.parse(s):!1}function zt(s){return typeof s<"u"?JSON.stringify(s):null}var it=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?d.clone(t):t,n=Vt(r,e);return zt(n)}static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};L(it,"json",{encode:zt,decode:ae});var kt=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"),n="id="+r,i=this.model;return this._get("",n,t,e,o=>{if(o){let a=this.getObject(o);a&&i.set(a)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+it.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return!1;let r=this.setupObjectData();return this._put("",r,t,e)}add(t,e){if(!this.isValid())return!1;let r=this.setupObjectData();return this._post("",r,t,e)}update(t,e){if(!this.isValid())return!1;let r=this.setupObjectData();return this._patch("",r,t,e)}delete(t,e){let r=this.model.get("id"),n=typeof r<"u"?"id="+r:this.setupObjectData();return this._delete("",n,t,e)}all(t,e,r,n,i){i=this.model.get("filter")||i||"",r=isNaN(r)?0:r,n=isNaN(n)?50:n,typeof i=="object"&&(i=JSON.stringify(i));let o="&filter="+i+"&start="+r+"&stop="+n;return this._get("",o,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);let r=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(r)}setupRequest(t,e,r,n,i){let o={url:this.getUrl(t),method:e,params:r,completed:(c,u)=>{typeof i=="function"&&i(c),this.getResponse(c,n,u)}};return this._isFormData(r)&&(o.headers={}),ut(o)}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,n){return this._request("","POST",t,e,r,n)}_get(t,e,r,n,i){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",n,i)}_post(t,e,r,n,i){return this._request(t,"POST",e,r,n,i)}_put(t,e,r,n,i){return this._request(t,"PUT",e,r,n,i)}_patch(t,e,r,n,i){return this._request(t,"PATCH",e,r,n,i)}_delete(t,e,r,n,i){return this._request(t,"DELETE",e,r,n,i)}_request(t,e,r,n,i,o){return r=this.setupParams(r),r=this.addParams(r,n),this.setupRequest(t,e,r,i,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(i){super(i)}}return Object.assign(r.prototype,t),r}};var ar=s=>{let t={};if(!h.isObject(s)||!s.defaults)return t;let{defaults:e}=s;return Object.keys(e).forEach(r=>{let n=e[r];typeof n!="function"&&(t[r]=n)}),delete s.defaults,t},cr=s=>{if(!s||typeof s.xhr!="object")return{};let t={...s.xhr};return delete s.xhr,t},ur=0,V=class extends O{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=cr(t),n=e.prototype.service.extend(r),i=ar(t);class o extends e{constructor(c){let u={...i,...St(c)};super(u),this.xhr=new n(this)}dataTypeId=`bm${ur++}`}return Object.assign(o.prototype,t),o.prototype.service=n,o}};V.prototype.service=kt;var I=class extends P{};var wt=class extends I{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=null}addAction(t,e){typeof e<"u"&&this.set(t,e)}getState(t){return this.get(t)}removeAction(t,e){if(e){this.off(t,e);return}let r=this.stage;typeof r[t]<"u"&&delete r[t]}};var D=class{static restore(t,e){this.targets.set(t,e)}static getTarget(t){return this.targets.has(t)||this.targets.set(t,new wt(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let n=this.getTarget(t);return e&&n.addAction(e,r),n}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){this.off(t,e,r)}static on(t,e,r){let n=this.getTarget(t);return e?n.on(e,r):null}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let n=this.targets,i=n.get(t);if(!!i){if(e){i.off(e,r);return}this.targets.delete(t)}}static set(t,e,r){this.getTarget(t).set(e,r)}};L(D,"targets",new Map);var Dt=class{constructor(){this.events=[]}addEvents(t){t.length<1||t.forEach(r=>{this.on(...r)})}on(t,e,r,n){f.on(t,e,r,n),this.events.push({event:t,obj:e,callBack:r,capture:n})}off(t,e,r,n){f.off(t,e,r,n);let i,o=this.events;for(var a=0,c=o.length;a<c;a++)if(i=o[a],i.event===t&&i.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 At=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,n){return{action:t,state:e,callBack:r,targetId:n,token:null}}convertStates(t){let e=[];for(var r in t)if(!!Object.prototype.hasOwnProperty.call(t,r)){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var n=null,i=null,o=t[r];o&&typeof o=="object"&&(i=o.callBack,n=o.id||o.targetId,o=o.state),e.push(this.createState(r,o,i,n))}return e}setupRemoteStates(t,e){let r;for(var n=0,i=t.length;n<i;n++)if(r=t[n],!!r){for(var o in r)if(!(!Object.prototype.hasOwnProperty.call(r,o)||o==="id")){var a=null,c=r[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,r.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(var r=0,n=e.length;r<n;r++){var i=e[r];i.token&&this.unbindRemoteState(t,i.token),D.remove(i.targetId,i.action,i.token)}}restore(t){D.restore(t.id,t);let e=this.remoteStates;if(!!e)for(var r=0,n=e.length;r<n;r++){var i=e[r];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,r){let n=D.getTarget(r);return t.link(n,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var n=0,i=e.length;n<i;n++){var o=e[n],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}r.length<1&&(this.remoteStates=[])}addAction(t,e){let r,n=e.action,i=e.targetId;i&&(r=this.bindRemoteState(t,n,i)),typeof e.state<"u"&&t.addAction(n,e.state);let o=e.callBack;return typeof o=="function"&&t.on(n,o),r}};var ce=s=>{if(!s)return ht();let t=s[0];return typeof t=="string"?ft(t):Array.isArray(t)?lt(t):pt(s)};l.addType("components",s=>{if(!s)return;let t=s.component;t&&t.rendered===!0&&t.prepareDestroy()});var hr=0,ot=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.init();let{props:e,children:r}=ce(t);this.setupProps(e),this.children=r||[],this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+hr++}declareProps(){}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.persist?this._layout||(this._layout=this.render()):this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}afterBuild(){l.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 n=0,i=t.length;n<i;n++){let o=e(t[n],n);r.push(o)}return r}removeAll(t){return k.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),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||this.id;k.removeElement(t)}prepareDestroy(){this.rendered=!1,this.beforeDestroy()}beforeDestroy(){}destroy(){this._remove()}};var S=class extends ot{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)}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=D.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();d.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new At(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)}setEventHelper(){this.events||(this.events=new Dt)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events.addEvents(t))}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&this.persist===!1&&this.data.unlink()}};var Tt={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var fr=s=>typeof s=="function"?s:()=>s,lr=s=>{let t={};return s&&Object.entries(s).forEach(([e,r])=>{let n=Tt[e]||e;t[n]=fr(r)}),t},ue=(s,t)=>{class e extends s{}return Object.assign(e.prototype,t),e},_=(s,t=S)=>{if(!s)return null;let e,r=typeof s;return r==="object"&&s.render?(e=lr(s),ue(t,e)):(e={render:r==="function"?s:()=>s},ue(t,e))};var pr=(s,t)=>(Object.entries(s).forEach(([e,r])=>{let n=Tt[e]||e;t.prototype[n]=r}),t),dr=s=>class extends s{},mr=(s,t=S)=>{if(!s)return null;let e=dr(t),r={},n=s(r);return pr(r,e),e.prototype.render=n,e};var gr={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){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),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 this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),s)},formatTime(s,t){let e=this.createDate(s),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 n=this.getMeridian(s);return s=this.convert24To12(s),`${s}:${this.padNumber(t)} ${n}`},leapYear(s){return s%400===0||s%100!==0&&s%4===0},getMonthName(s=new Date().getMonth(),t=!1){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 i=/[- :]/,o=s.split(i);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}))),n=e.getTime()-r.getTime();return new Date(e.getTime()+n)},getLocalTime(s,t=!1,e=!1,r="America/Denver"){if(!s)return"";let n=this.getLocalDate(s,r),i=n.getMonth()+1,o=t===!0?"sql":"standard",a="";return e===!1&&(a+=this.renderDate(n.getFullYear(),i,n.getDate(),o)+" "),a+this.renderTime(n.getHours(),n.getMinutes(),n.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 n=Math.floor(r/7);e=n+" weeks";break;case t<5184e6:e="1 month";break;case t<31104e6:var i=this.toMonths(t);e=i+" 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,n,i,o,a,c;if(s<=0)switch(!0){case s<-63072e6:n=this.toYears(Math.abs(s)),t="in "+n+" years";break;case s<-31536e6:t="in a year";break;case s<-5184e6:i=this.toMonths(Math.abs(s)),t="in "+i+" months";break;case s<-2592e6:t="in a month";break;case s<-12096e5:e=this.toDays(Math.abs(s)),r=Math.floor(e/7),t="in "+r+" weeks";break;case s<-6048e5:t="in a week";break;case s<-1728e5:e=this.toDays(Math.abs(s)),t="in "+e+" days";break;case s<-864e5:t="tomorrow";break;case s<-72e5:o=this.toHours(Math.abs(s)),t="in "+o+" hours";break;case s<=-36e5:t="in an hour";break;case s<-12e4:a=this.toMinutes(Math.abs(s)),t="in "+a+" minutes";break;case s<-6e4:t="in a minute";break;case s<-2e3:c=this.toSeconds(Math.abs(s)),t="in "+c+" seconds";break;case s<-1:t="in 1 second";break;default:t="now"}else switch(!0){case s<1e3:t="1 second ago";break;case s<6e4:c=this.toSeconds(s),t=c+" seconds ago";break;case s<12e4:t="1 minute ago";break;case s<36e5:a=this.toMinutes(s),t=a+" minutes ago";break;case s<72e5:t="1 hour ago";break;case s<864e5:o=this.toHours(s),t=o+" hours ago";break;case s<1728e5:t="yesterday";break;case s<6048e5:e=this.toDays(s),t=e+" days ago";break;case s<12096e5:t="a week ago";break;case s<2592e6:e=this.toDays(s),r=Math.floor(e/7),t=r+" weeks ago";break;case s<5184e6:t="a month ago";break;case s<31536e6:i=this.toMonths(s),t=i+" months ago";break;case s<63072e6:t="a year ago";break;default:n=this.toYears(s),t=n+" years 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),n=r.getTime()-e.getTime();return{years:this.toYears(n),days:this.toDays(n),hours:this.toHours(n),minutes:this.toMinutes(n),seconds:this.toSeconds(n)}}};var he=(s,t)=>({name:s,callBack:t});var z={keys:[],items:{},add(s,t){return this.keys.push(s),this.items[s]=he(s,t),this},get(s){return this.items[s]||null},all(){return this.keys}};var Jt=(s,t)=>({attr:s,directive:t});var J=(s,t)=>({key:s,value:t});var fe=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var N=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,n){return t==="text"?(n.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(r.push(J("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){let n={attr:et(e),value:r};t.push(Jt(J(e,n),z.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let n=e.type||"button