UNPKG

@base-framework/base

Version:

This is a javascript framework.

1 lines 81.7 kB
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 ur=Object.prototype.toString,qt=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)qt.call(s,e)&&!qt.call(t,e)&&(t[e]=s[e]);return 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 i=Object.create(e);for(var n in r)i[n]=r[n];return i},hasOwnProp(s,t){return qt.call(s,t)},isPlainObject(s){return!!s&&ur.call(s)==="[object Object]"},isEmpty(s){return h.isObject(s)?Object.keys(s).length===0:!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 dt=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 d=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){return!t||typeof t!="object"?"":t.trackingId||(t.trackingId=`dt${this.trackingCount++}`)}static add(t,e,r){let i=this.getTrackingId(t);this.find(i).add(e,r)}static get(t,e){let r=t.trackingId,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 dt),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 i=this.trackers.get(r);if(!e){i.remove(),this.trackers.delete(r),delete t.trackingId;return}i.remove(e),this.isEmpty(i.types)&&(this.trackers.delete(r),delete t.trackingId)}};var Jt=s=>{let t=0;for(let[e,r]of Object.entries(s))t++,typeof s[e]=="object"&&(t+=Jt(s[e]));return t},ae=(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=ae(i,n),e!==!0)break}else if(i===n)e=!0;else break}return e},hr=(s,t)=>{let e=Jt(s),r=Jt(t);return e!==r?!1:ae(s,t)},ce=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?hr(s,t):s===t};var f={getEvents(s){return h.isObject(s)===!1?[]:d.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 d.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:(d.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return this.swap.includes(s)}};d.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=d}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 D=new st;D.augment({...b,...Yt,...h,equals:ce});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 ue=()=>{D.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(D.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=it}})};var S=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 pt=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=S.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={...D.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)}};ue();var mt=(...s)=>new pt(s).xhr;var lr=s=>typeof s!="string"?s:he(s),he=s=>[{tag:"text",textContent:s}],gt=()=>({props:{},children:[]}),yt=s=>({props:{},children:he(s)}),bt=s=>({props:{},children:s}),xt=s=>({props:s[0]||{},children:lr(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 F=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var St=class extends F{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 $=class{unsubscribe(){}};var kt=class extends ${constructor(){super(),this.source=null}addSource(t){return this.source=new St(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var V=class extends F{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 Ct=class extends V{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 g=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=S.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=S.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=S.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=S.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=S.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 wt=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 fr=(s,t,e)=>{g.setAttr(s,t,e)},dr=(s,t,e)=>{s.checked=s.value==e},pr=(s,t,e)=>{e=e==1,le(s,t,e)},le=(s,t,e)=>{s[t]=e},mr=(s,t)=>g.getAttr(s,t),gr=(s,t)=>s[t],Tt=class extends V{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=fr,this.getValue=mr,this;this.getValue=gr;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=pr;return;case"radio":this.setValue=dr;return}return this.setValue=le,this}getAttrBind(t){return t||wt(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 ${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 Ct(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 fe=-1,z=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,fe=-1}on(t,e){let r=(++fe).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=!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=new Map(this.updateQueue);this.updateQueue.clear();for(let[e,r]of t)this.publishImmediate(e,...r);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._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())i&&i.apply(this,e)}};var Qt=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 z,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,p=e.get(n);return typeof p<"u"?l.set(p):(p=l.get(),p!==""&&u.data.set(p)),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 kt;n.addSource(e).subscribe(r,i);let a=this.getBindId(t),c=e.getDataId()+":"+r;this.addConnection(a,c,n);let u=e.get(r);return i(u),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)}},v=new Qt;var E=s=>s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null;var yr={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=>yr[s]||s,ot=s=>typeof s=="string"&&s.substring(0,2)==="on"?s.substring(2):s,A=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"&&g.setAttr(t,"type",r);for(let[i,n]of Object.entries(e))i==="innerHTML"?t.innerHTML=n:i.indexOf("-")!==-1?g.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){d.remove(t);let e=t.childNodes;if(e){let o=e.length-1;for(var r=o;r>=0;r--){var i=e[r];i&&this.removeElementData(i)}}t.bindId&&v.unbind(t)}static removeElement(t){if(!t)return this;let e=d.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=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 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 A{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){!e||e.length<1||e.forEach(i=>{let{key:n,value:o}=i;this.addAttr(t,n,o,r)})}static addAttr(t,e,r,i){if(r===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=r;return}if(typeof r==="function"){e=ot(e);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)==="-"){g.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 Xt=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,de=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=de.get(s);if(t!==void 0)return t;let e=s.match(Xt),r=e?e.map(i=>i.slice(2,-2)):null;return de.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.toLowerCase()==="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(Xt,function(){let i=e?t[r]:t;r++;let n=i.get(arguments[2]);return typeof n<"u"&&n!==null?n:""})},_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(Xt)||[],u=c.length>1;return(l,p)=>{l=u!==!0?l:this.getPropValues(e,c,i);let m=a(l,t,p);typeof m<"u"&&this.updateAttr(t,o,m)}}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){v.watch(s,t,e,r)}};var br=s=>({props:{watch:s},children:[]}),xr=s=>{if(!s)return gt();let t=s[0],e=typeof t;if(e==="string"||e==="number")return yt(t);if(Array.isArray(t))return w.isWatching(t)===!1?bt(t):br(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]=[]),xt(s)},vr=s=>(...t)=>{let{props:e,children:r}=xr(t);return s(e,r)};var pe=new WeakMap;function Sr(s,t,e,r){let i=pe.get(s);i||(i=new Map,pe.set(s,i));let n=i.get(e);if(n)return n;let o=new Proxy(s,ge(t,e,r));return i.set(e,o),o}var kr=/^\d+$/;function me(s,t){let e=kr.test(t);return s===""?e?`[${t}]`:t:e?`${s}[${t}]`:`${s}.${t}`}function ge(s,t="",e=""){return{get(r,i,n){let o=r[i];if(t===""&&i in r)return typeof o=="function"?o.bind(r):o;let a=r[e]||r;if(o=Reflect.get(a,i,n),o!==null&&typeof o=="object"){let c=me(t,i);return Sr(o,s,c,e)}return o},set(r,i,n,o){if(t===""&&i in r)return r[i]=n,!0;let a=me(t,i);return s.set(a,n),!0}}}var Dt=(s,t="stage")=>new Proxy(s,ge(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 Et=(s={})=>{let t={};if(!h.isObject(s))return t;let e=b.clone(s);return Object.keys(e).forEach(r=>{let i=e[r];typeof i!="function"&&(t[r]=i)}),t};var Cr=0,ye=new Map,H={CHANGE:"change",DELETE:"delete"},Gt=(s,t)=>{let e=ye.get(s);return e||(e={change:`${s}:change`,delete:`${s}:delete`},ye.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 z;let e=Et(t);return this.set(e),Dt(this)}setup(){this.stage={}}_init(){let t=++Cr;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}onFlush(t){this.eventSub.onFlush(t)}getDataId(){return String(this._id)}remove(){}on(t,e){let r=Gt(t,H.CHANGE);return this.eventSub.on(r,e)}off(t,e){let r=Gt(t,H.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,H.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,v.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,H.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 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 L=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 q=null,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 p=o[l];t=t[p],l>0?isNaN(p)&&(u+="."+p):u=p;let m;if(l===c)m=r;else{let x=o[l+1];if(isNaN(x)===!1){u+="["+x+"]";continue}let T={};T[x]=t[x],m=T}this.publish(u,m,i)}}static publish(t,e,r,i=null,n=0){if(t=t||"",r(t,e),!e||typeof e!="object")return;let o=i===null;if(o&&(q||(q=new WeakSet),i=q),!!i){if(i.has(e)){console.warn("[Publisher] Circular reference detected at path:",t),o&&(q=null);return}if(n>=this.MAX_DEPTH){console.warn("[Publisher] Max depth exceeded at path:",t,"- stopping recursion"),o&&(q=null);return}i.add(e),Array.isArray(e)?this.publishArray(t,e,r,i,n):this.publishObject(t,e,r,i,n),o&&(q=null)}}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){for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;let a=e[o],c=`${t}.${o}`;this._checkPublish(c,a,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 B=class extends M{setup(){this.attributes={},this.stage={}}_setAttr(t,e,r,i){typeof e!="object"&&e===this.get(t)||(!r&&i!==!0?L.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),L.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)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;v.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){L.delete(t,e);let i=(n,o)=>this.publishLocalEvent(n,o,r,H.DELETE);ct.publish(e,e,i)}_getAttr(t,e){return L.get(t,e)}};var wr={"\n":"\\n","\r":"\\n"," ":"\\t"},Tr=(s,t)=>{typeof s!="string"&&(s=String(s));let e=t?/[\n\r\t]/g:/\t/g;return s.replace(e,r=>wr[r])},be=(s,t)=>{if(typeof s!="string")return s;s=Tr(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=be(s),s):(Object.entries(s).forEach(([r,i])=>{i!==null&&(s[r]=typeof i=="string"?Zt(i,t):be(i,t))}),s)};function xe(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:xe};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var Pt=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=S.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=S.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 p=a.orderBy||"";typeof p=="object"&&(p=JSON.stringify(p));let m=a.groupBy||"";Array.isArray(m)&&(m=JSON.stringify(m));let x="&filter="+u+"&offset="+r+"&limit="+i+"&dates="+l+"&orderBy="+p+"&groupBy="+m+"&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={}),mt(o)}setupEventSource(t,e,r,i,n=!0){let o=null,a=null,c=!1,u=!1,l=()=>{a&&(clearTimeout(a),a=null)},p=()=>{if(c||!n||u)return;l(),a=setTimeout(()=>{a=null,m()},3e3)},m=()=>{if(c||u)return;if(o){try{o.close()}catch{}o=null}u=!0;let x=this.getUrl(t),T=e?"?"+e:"";o=new EventSource(x+T,{withCredentials:!0}),o.onopen=()=>{u=!1,l(),i&&i()},o.onerror=()=>{u=!1,o&&o.readyState===EventSource.CLOSED&&(o=null,p())},o.onmessage=et=>{try{let ft=JSON.parse(et.data);r&&r(ft)}catch{}}};return m(),{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 Ar=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},Dr=s=>{if(!s||typeof s.xhr!="object")return{};let t={...s.xhr};return delete s.xhr,t},Er=0,J=class extends B{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=Dr(t),i=e.prototype.service.extend(r),n=Ar(t);class o extends e{constructor(c){let u={...n,...Et(c)};super(u),this.xhr=new i(this)}dataTypeId=`bm${Er++}`}return Object.assign(o.prototype,t),o.prototype.service=i,o}};J.prototype.service=Pt;var _=class extends M{};var Y=class extends _{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 Y{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=""}};var I=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 Mt=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(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var 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){let r;for(var i=0,n=t.length;i<n;i++)if(r=t[i],!!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,i=e.length;r<i;r++){var n=e[r];n.token&&this.unbindRemoteState(t,n.token),I.remove(n.targetId,n.action,n.token)}}restore(t){I.restore(t.id,t);let e=this.remoteStates;if(e)for(var r=0,i=e.length;r<i;r++){var n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let i=I.getTarget(r);return t.link(i,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var i=0,n=e.length;i<n;i++){var o=e[i],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}r.length<1&&(this.remoteStates=[])}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 ve=s=>{if(!s)return gt();let t=s[0],e=typeof t;return e==="string"||e==="number"?yt(t):Array.isArray(t)?bt(t):xt(s)};d.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 Pr=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.cached=[],this.init();let{props:e,children:r}=ve(t);this.setupProps(e),this.children=r||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Pr++,this.unitType=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(){d.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 A.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&&A.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,this.id=t.id}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this