@base-framework/base 2.6.6 → 2.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.js +1 -1
- package/dist/base.js.map +2 -2
- package/package.json +1 -1
package/dist/base.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var R={createObject(i){return Object.create(i)},extendObject(i,t){if(typeof i>"u"||typeof t>"u")return!1;for(var e in i)i.hasOwnProperty(e)&&typeof t[e]>"u"&&(t[e]=i[e]);return t},cloneObject(i){return i?JSON.parse(JSON.stringify(i)):{}},_getClassObject(i){return typeof i=="function"?i.prototype:i},extendClass(i,t){let e=this._getClassObject(i),r=this._getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let s=Object.create(e);for(var n in r)s[n]=r[n];return s}};var et={types:{},add(i,t){this.types[i]=t},get(i){return this.types[i]||!1},remove(i){delete this.types[i]}},rt=class{constructor(){this.types={}}add(t,e){(this.types[t]||(this.types[t]=[])).push(e)}get(t){return this.types[t]||!1}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){let e=this.types;if(e){let n=e[t];if(n.length){let a,o=et.get(t);for(var r=0,s=n.length;r<s;r++)a=n[r],a&&(n[r]=null,this.removeByCallBack(o,a));delete e[n]}}}remove(t){if(t)this.removeType(t);else{let r=this.types;for(var e in r)if(r.hasOwnProperty(e)){if(t=r[e],!t)continue;this.removeType(e)}delete this.types}}},I=class{constructor(){this.trackers={},this.trackingCount=0}addType(t,e){et.add(t,e)}removeType(t){et.remove(t)}getTrackingId(t){return t.trackingId||(t.trackingId="dt"+this.trackingCount++)}add(t,e,r){let s=this.getTrackingId(t);this.find(s).add(e,r)}get(t,e){let r=t.trackingId,s=this.trackers[r];return s?e?s.get(e):s:!1}find(t){let e=this.trackers;return e[t]||(e[t]=new rt)}isEmpty(t){if(!t||typeof t!="object")return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}remove(t,e){let r=t.trackingId;if(!r)return!0;let s=this.trackers[r];if(!s)return!1;e?(s.remove(e),this.isEmpty(s.types)&&delete this.trackers[r]):(s.remove(),delete this.trackers[r])}};var Dt=window,L=class{constructor(){this.version="2.6.0",this.errors=[],this.dataTracker=new I}augment(t){if(!t||typeof t!="object")return this;let e=this.constructor.prototype;for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return this}listToArray(t){return Array.prototype.slice.call(t)}override(t,e,r,s){return(t[e]=r).apply(t,this.listToArray(s))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}parseQueryString(t,e){typeof t!="string"&&(t=Dt.location.search);let r={},s=/([^?=&]+)(=([^&]*))?/g;return t.replace(s,function(n,a,o,l){r[a]=e!==!1?decodeURIComponent(l):l}),r}isEmpty(t){if(this.isObject(t)===!1)return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?this.listToArray(e):!1}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]:this.listToArray(r):!1}html(t,e){return this.isObject(t)===!1?!1:this.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}setCss(t,e,r){return this.isObject(t)===!1||this.isUndefined(e)?this:(e=this.uncamelCase(e),t.style[e]=r,this)}getCss(t,e){if(!t||typeof e>"u")return!1;e=this.uncamelCase(e);var r=t.style[e];if(r!=="")return r;var s=null,n=t.currentStyle;if(n&&(s=n[e]))r=s;else{var a=window.getComputedStyle(t,null);a&&(r=a[e])}return r}css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}removeAttr(t,e){return this.isObject(t)&&t.removeAttribute(e),this}setAttr(t,e,r){t.setAttribute(e,r)}getAttr(t,e){return t.getAttribute(e)}attr(t,e,r){return this.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}_checkDataPrefix(t){return typeof t!="string"||(t=h.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}_removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}setData(t,e,r){e=this._removeDataPrefix(e),e=h.camelCase(e),t.dataset[e]=r}getData(t,e){return e=h.camelCase(this._removeDataPrefix(e)),t.dataset[e]}data(t,e,r){return this.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}find(t,e){return!t||typeof e!="string"?!1:t.querySelectorAll(e)}show(t){if(this.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}hide(t){if(this.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}toggle(t){return this.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}camelCase(t){if(typeof t!="string")return!1;let e=/(-|\s|\_)+\w{1}/g;return t.replace(e,function(r){return r[1].toUpperCase()})}uncamelCase(t,e){if(typeof t!="string")return!1;e=e||"-";let r=/([A-Z]{1,})/g;return t.replace(r,function(s){return e+s.toLowerCase()}).toLowerCase()}getSize(t){return this.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}getWidth(t){return this.isObject(t)?t.offsetWidth:!1}getHeight(t){return this.isObject(t)?t.offsetHeight:!1}getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=window.pageXOffset||t.scrollLeft,r=window.pageYOffset||t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return this.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}getScrollTop(t){return this.getScrollPosition(t).top}getScrollLeft(t){return this.getScrollPosition(t).left}getWindowSize(){let t=window,e=document,r=e.documentElement,s=e.getElementsByTagName("body")[0],n=t.innerWidth||r.clientWidth||s.clientWidth,a=t.innerHeight||r.clientHeight||s.clientHeight;return{width:n,height:a}}getDocumentSize(){let t=document,e=t.body,r=t.documentElement,s=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:s}}getDocumentHeight(){return this.getDocumentSize().height}getProperty(t,e,r){if(this.isObject(t)===!1)return"";let s=t[e];return typeof s<"u"?s:typeof r<"u"?r:""}position(t,e=1){let r={x:0,y:0};if(this.isObject(t)===!1)return r;let s=0;for(;t&&(e===0||s<e);)s++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}addClass(t,e){if(this.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let n=e.split(" ");for(var r=0,s=n.length;r<s;r++)t.classList.add(e)}return this}removeClass(t,e){return this.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}hasClass(t,e){return this.isObject(t)===!1||e===""?!1:t.classList.contains(e)}toggleClass(t,e){return this.isObject(t)===!1?this:(t.classList.toggle(e),this)}getType(t){let e=typeof t;return e!=="object"?e:this.isArray(t)?"array":e}isUndefined(t){return typeof t>"u"}isObject(t){return!(!t||typeof t!="object")}isArray(t){return Array.isArray(t)}inArray(t,e,r){return!t||typeof t!="object"?-1:t.indexOf(e,r)}createCallBack(t,e,r,s){return typeof e!="function"?!1:(r=r||[],function(...n){return s===!0&&(r=r.concat(n)),e.apply(t,r)})}bind(t,e){return e.bind(t)}prepareJsonUrl(t,e=!1){var r=l=>{if(typeof l!="string"&&(l=String(l)),e){let u=/\n/g;l=l.replace(u,"\\n")}let f=/\t/g;return l.replace(f,"\\t")},s=l=>{if(typeof l!="string")return l;l=r(l),l=encodeURIComponent(l);let f=/\%22/g;return l.replace(f,'"')},n=l=>{let f=typeof l;if(f==="undefined")return l;if(f!=="object")return l=s(l),l;let u;for(var c in l)if(l.hasOwnProperty(c)){if(u=l[c],u===null)continue;l[c]=n(u)}return l};let a=typeof t=="object"?this.cloneObject(t):t,o=n(a);return this.jsonEncode(o)}jsonDecode(t){return typeof t<"u"&&t.length>0?JSON.parse(t):!1}jsonEncode(t){return typeof t<"u"?JSON.stringify(t):!1}xmlParse(t){if(typeof t>"u")return!1;var e=new DOMParser;return e.parseFromString(t,"text/xml")}};L.prototype.extend=function(){return L.prototype}();var h=new L;h.augment(R);var st=i=>{let t=0;for(var e in i)i.hasOwnProperty(e)&&(t++,typeof i[e]=="object"&&(t+=st(i[e])));return t},vt=(i,t)=>{let e=!1;if(typeof i!="object"||typeof t!="object")return e;for(var r in i){if(!i.hasOwnProperty(r)||!t.hasOwnProperty(r))break;let s=i[r],n=t[r];if(typeof s!=typeof n)break;if(typeof s=="object"){if(e=vt(s,n),e!==!0)break}else if(s===n)e=!0;else break}return e},Ot=(i,t)=>{let e=st(i),r=st(t);return e!==r?!1:vt(i,t)};h.augment({equals(i,t){let e=typeof i;return e!==typeof t?!1:e==="object"?Ot(i,t):i===t}});var U=h.dataTracker,xt={getEvents(i){return h.isObject(i)===!1?!1:U.get(i,"events")},create(i,t,e,r=!1,s=!1,n=null){return s=s===!0,{event:i,obj:t,fn:e,capture:r,swapped:s,originalFn:n}},add(i,t,e,r=!1,s=!1,n=null){if(h.isObject(t)===!1)return this;let a=this.create(i,t,e,r,s,n);return U.add(t,"events",a),t.addEventListener(i,e,r),this},remove(i,t,e,r=!1){let s=this.getEvent(i,t,e,r);return s===!1?this:(typeof s=="object"&&this.removeEvent(s),this)},removeEvent(i){return typeof i=="object"&&i.obj.removeEventListener(i.event,i.fn,i.capture),this},getEvent(i,t,e,r){if(typeof t!="object")return!1;let s=this.getEvents(t);if(!s||s.length<1)return!1;let n=this.create(i,t,e,r);return this.search(n,s)},search(i,t){let e,r=this.isSwappable(i.event);for(var s=0,n=t.length;s<n;s++)if(e=t[s],!(e.event!==i.event||e.obj!==i.obj)&&(e.fn===i.fn||r===!0&&e.originalFn===i.fn))return e;return!1},removeEvents(i){return h.isObject(i)===!1?this:(U.remove(i,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(i){this.swap.push(i)},isSwappable(i){return h.inArray(this.swap,i)>-1}};U.addType("events",i=>{xt.removeEvent(i)});h.augment({events:xt,addListener(i,t,e,r){return this.events.add(i,t,e,r),this},on(i,t,e,r){let s=this.events;if(this.isArray(i)){let o;for(var n=0,a=i.length;n<a;n++)o=i[n],s.add(o,t,e,r)}else s.add(i,t,e,r);return this},off(i,t,e,r){let s=this.events;if(this.isArray(i))for(var n,a=0,o=i.length;a<o;a++)n=i[a],s.remove(n,t,e,r);else s.remove(i,t,e,r);return this},removeListener(i,t,e,r){return this.events.remove(i,t,e,r),this},_createEvent(i,t,e,r){let s;return t==="HTMLEvents"?s=new Event(i):t==="MouseEvents"?s=new MouseEvent(i,e):s=new CustomEvent(i,r),s},createEvent(i,t,e,r){if(this.isObject(t)===!1)return!1;let s={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)&&(s=Object.assign(s,e));let n=this._getEventType(i);return this._createEvent(i,n,s,r)},_getEventType(i){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,r="CustomEvent";for(var s in t)if(t.hasOwnProperty(s)&&(e=t[s],i.match(e))){r=s;break}return r},trigger(i,t,e){if(this.isObject(t)===!1)return this;let r=typeof i=="string"?this.createEvent(i,t,null,e):i;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let i=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=i())},onMouseWheel(i,t,e,r){typeof t>"u"&&(t=window);let s=a=>{a=a||window.event;let o=Math.max(-1,Math.min(1,-a.deltaY||a.wheelDelta||-a.detail));typeof i=="function"&&i(o,a),e===!0&&a.preventDefault()},n=this.getWheelEventType();return this.events.add(n,t,s,r,!0,i),this},offMouseWheel(i,t,e){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,i,e),this},preventDefault(i){return i=i||window.event,typeof i.preventDefault=="function"?i.preventDefault():i.returnValue=!1,this},stopPropagation(i){return i=i||window.event,typeof i.stopPropagation=="function"?i.stopPropagation():i.cancelBubble=!0,this}});var bt={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};h.augment({xhrSettings:bt,addFixedParams(i){this.xhrSettings.fixedParams=i},beforeSend(i){this.xhrSettings.beforeSend.push(i)},ajaxSettings(i){typeof i=="object"&&(this.xhrSettings=this.extendClass(h.xhrSettings,i))},resetAjaxSettings(){this.xhrSettings=bt}});var N=(...i)=>new it(i).xhr,it=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:s,async:n}=this.settings;e.open(r,s,n),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=h.xhrSettings.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var s=0,n=t.length;s<n;s++){var a=t[s];a&&a(e,r)}}objectToString(t){let e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r+"="+t[r]);return e.join("&")}setupParams(t,e){let r=typeof t;if(e){let n=typeof e;if(r==="string")n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e;else if(n==="string"&&(e=h.parseQueryString(e,!1)),t instanceof FormData)for(var s in e)e.hasOwnProperty(s)&&t.append(s,e[s]);else r==="object"&&(t=h.cloneObject(t),t=Object.assign(e,t),t=this.objectToString(t))}else!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.params,r=t.fixedParams;return e?e=this.setupParams(e,r):r&&(e=this.setupParams(r)),e}getXhrSettings(t){let e=this.settings=Object.create(h.xhrSettings);if(t.length>=2&&typeof t[0]!="object")for(var r=0,s=t.length;r<s;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=h.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"){let r=t.headers;for(var e in r)r.hasOwnProperty(e)&&this.xhr.setRequestHeader(e,r[e])}}update(t,e){let r=this.xhr,s=()=>{let o=h.events;o.removeEvents(r.upload),o.removeEvents(r)},n=this.settings;if(!n)return!1;switch(e||t.type){case"load":if(typeof n.completed=="function"){let o=this.getResponseData();n.completed(o,this.xhr)}s();break;case"error":typeof n.failed=="function"&&n.failed(!1,this.xhr),s();break;case"progress":typeof n.progress=="function"&&n.progress(t);break;case"abort":typeof n.aborted=="function"&&n.aborted(!1,this.xhr),s();break}}getResponseData(){let t=this.xhr,e=t.response,r=t.responseType;return!r||r==="text"?t.responseText:e}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=h.bind(this,this.update);h.on(["load","error","abort"],e,r),h.on("progress",e.upload,r)}};var wt=-1,k=class{constructor(){this.callBacks={},this.lastToken=-1}get(t){let e=this.callBacks;return e[t]||(e[t]=[])}reset(){this.callBacks={},this.lastToken=-1,wt=-1}on(t,e){let r=++wt;return this.get(t).push({token:r,callBack:e}),r}off(t,e){let r=this.callBacks[t]||!1;if(r===!1)return!1;let s=r.length;for(var n=0;n<s;n++){var a=r[n];if(a.token===e){r.splice(n,1);break}}}remove(t){let e=this.callBacks;e[t]&&delete e[t]}publish(t){let e,r,s=this.callBacks[t]||!1;if(s===!1)return!1;let n=Array.prototype.slice.call(arguments,1);for(r=s.length,e=0;e<r;e++){var a=s[e];!a||a.callBack.apply(this,n)}}},C=new k;var T=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var H=class extends T{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 A=class{unsubscribe(){}};var M=class extends A{constructor(){super(),this.source=null}addSource(t){return this.source=new H(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var E=class extends T{subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=C.on(t,e)}unsubscribe(){C.off(this.msg,this.token)}callBack(){}};var W=class extends E{constructor(t,e){super(),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 _t=(i,t,e)=>{h.setAttr(i,t,e)},Bt=(i,t,e)=>{i.checked=i.value===e},Rt=(i,t,e)=>{e=e==1,St(i,t,e)},St=(i,t,e)=>{i[t]=e},Lt=(i,t)=>h.getAttr(i,t),It=(i,t)=>i[t],J=class extends E{constructor(t,e,r){super(),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)==="-")this.setValue=_t,this.getValue=Lt;else{this.getValue=It;var r=t.type;if(r)switch(r){case"checkbox":this.setValue=Rt;return;case"radio":this.setValue=Bt;return}this.setValue=St}}getAttrBind(t){if(t)return t;let e="textContent",r=this.element;if(!(r&&typeof r=="object"))return e;let s=r.tagName.toLowerCase();if(s==="input"||s==="textarea"||s==="select"){let n=r.type;if(n)switch(n){case"checkbox":e="checked";break;case"file":e="files";break;default:e="value"}else e="value"}return e}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;if(!e||typeof e!="object")return!1;this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){e!==this.element&&this.set(t)}};var F=class extends A{constructor(){super(),this.element=null,this.data=null}addElement(t,e,r){return this.element=new J(t,e,r)}addData(t,e){return this.data=new W(t,e)}unsubscribeSource(t){t&&t.unsubscribe()}unsubscribe(){this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null}};var V=class{constructor(){this.connections={}}add(t,e,r){let s=this.find(t);return s[e]=r}get(t,e){let r=this.connections[t];return r&&r[e]||!1}find(t){let e=this.connections;return e[t]||(e[t]={})}remove(t,e){let r=this.connections[t];if(!r)return!1;let s;if(e)s=r[e],s&&(s.unsubscribe(),delete r[e]),h.isEmpty(r)&&delete this.connections[t];else{for(var n in r)r.hasOwnProperty(n)&&(s=r[n],s&&s.unsubscribe());delete this.connections[t]}}};var nt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new V,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,s){let n=r,a=null;if(r.indexOf(":")!==-1){let u=r.split(":");u.length>1&&(n=u[1],a=u[0])}let o=this.setupConnection(t,e,n,a,s),l=o.element,f=e.get(n);return typeof f<"u"?l.set(f):(f=l.get(),f!==""&&o.data.set(f)),this}setupConnection(t,e,r,s,n){let a=this.getBindId(t),o=new F;o.addData(e,r).subscribe(a);let f=e.getDataId(),u=f+":"+r;return o.addElement(t,s,n).subscribe(u),this.addConnection(a,"bind",o),o}addConnection(t,e,r){this.connections.add(t,e,r)}setBindId(t){let e="db-"+this.idCount++;return 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,s){if(!t||typeof t!="object")return!1;let n=new M;n.addSource(e).subscribe(r,s);let o=this.getBindId(t),l=e.getDataId()+":"+r;this.addConnection(o,l,n);let f=e.get(r);typeof f<"u"&&s(f)}unwatch(t,e,r){if(!t||typeof t!="object")return!1;let s=t[this.attr];if(s){let n=e.getDataId()+":"+r;this.connections.remove(s,n)}}publish(t,e,r){return C.publish(t,e,r),this}isDataBound(t){if(t){let e=t[this.attr];if(e)return e}return!1}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){let s=this.connections.get(r,"bind");if(s){let n=s.element.get();C.publish(r,n,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){h.on(["change","keyup"],document,this.changeHandler,!1)}removeEvents(){h.off(["change","keyup"],document,this.changeHandler,!1)}},d=new nt;var at=i=>JSON.parse(JSON.stringify(i)),z=i=>{let t={};if(!i&&typeof i!="object")return t;i=at(i);for(var e in i)if(i.hasOwnProperty(e)){var r=i[e];typeof r!="function"&&(t[e]=r,delete i[e])}return t};var S=class{constructor(t){this.dirty=!1,this.links={},this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new k;let e=z(t);this.set(e)}setup(){this.stage={}}_init(){let t=this.constructor;this._dataNumber=typeof t._dataNumber>"u"?t._dataNumber=0:++t._dataNumber,this._id="dt-"+this._dataNumber,this._dataId=this._id+":"}getDataId(){return this._id}remove(){}on(t,e){let r=t+":change";return this.eventSub.on(r,e)}off(t,e){let r=t+":change";this.eventSub.off(r,e)}_setAttr(t,e,r){let s=this.stage[t];if(e===s)return!1;this.stage[t]=e,r=r||this,this._publish(t,e,r,s)}set(...t){if(typeof t[0]=="object"){let[s,n,a]=t;for(var e in s)if(s.hasOwnProperty(e)){var r=s[e];if(typeof r=="function")continue;this._setAttr(e,r,n,a)}}else this._setAttr(...t);return this}getModelData(){return this.stage}_deleteAttr(t,e){delete t[e]}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}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){this.key=t}resume(t){let e=this.key;if(!e)return!1;let r,s=localStorage.getItem(e);s===null?t&&(r=t):r=JSON.parse(s),this.set(r)}store(){let t=this.key;if(!t)return!1;let e=this.get();if(!e)return!1;let r=JSON.stringify(e);localStorage.setItem(t,r)}delete(t){if(typeof t<"u"){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 s=[];for(var n in e)e.hasOwnProperty(n)!==!1&&s.push(this.remoteLink(t,n));return s}remoteLink(t,e,r){let s=r||e,n=t.get(e);typeof n<"u"&&this.get(e)!==n&&this.set(e,n);let a=t.on(e,(l,f)=>{if(f===this)return!1;this.set(s,l,t)});this.addLink(a,t);let o=this.on(s,(l,f)=>{if(f===t)return!1;t.set(e,l,this)});return t.addLink(o,this),a}addLink(t,e){this.links[t]=e}unlink(t){if(t){this.removeLink(t);return}let e=this.links;if(e.length){for(var r=0,s=e.length;r<s;r++)this.removeLink(e[r],!1);this.links=[]}}removeLink(t,e){let r=this.links[t];r&&r.off(t),e!==!1&&delete this.links[t]}};S.prototype.isData=!0;var y={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(i){return i.indexOf(".")!==-1||i.indexOf("[")!==-1},getSegments(i){var t=this.deepDataPattern;return i.match(t)}};var v=class extends S{setup(){this.attributes={},this.stage={}}_updateAttr(t,e,r){if(y.hasDeepData(e)){let n,a=y.getSegments(e),o=a.length,l=o-1;for(var s=0;s<o;s++){if(n=a[s],s===l){t[n]=r;break}t[n]===void 0&&(t[n]=isNaN(n)?{}:[]),t=t[n]}}else t[e]=r}_setAttr(t,e,r,s){typeof e!="object"&&e===this.get(t)||(!r&&s!==!0?this._updateAttr(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),this._updateAttr(this.stage,t,e),r=r||this,this._publish(t,e,r))}linkAttr(t,e){let r=t.get(e);if(r)for(var s in r)r.hasOwnProperty(s)&&this.link(t,e+"."+s,s)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let s=new e(r);return s.linkAttr(this,t),s}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}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){this.publish(t,e,r)}publishDeep(t,e,r){if(y.hasDeepData(t)){let l,f=y.getSegments(t),u=f.length,c=u-1,m="",B=this.stage;for(var s=0;s<u;s++){l=f[s],B=B[l],s>0?isNaN(l)&&(m+="."+l):m=l;var n;if(s===c)n=e;else{var a=f[s+1];if(isNaN(a)===!1){m+="["+a+"]";continue}var o={};o[a]=B[a],n=o}this.publish(m,n,r)}}else this.publish(t,e,r)}publish(t,e,r){if(t=t||"",this._publishAttr(t,e,r),e&&typeof e=="object"){let a,o;if(Array.isArray(e)){let l=e.length;for(var s=0;s<l;s++)o=e[s],a=t+"["+s+"]",this._checkPublish(a,o,r)}else for(var n in e)e.hasOwnProperty(n)&&(o=e[n],a=t+"."+n,this._checkPublish(a,o,r))}}_checkPublish(t,e,r){!e||typeof e!="object"?this._publishAttr(t,e,r):this.publish(t,e,r)}_publishAttr(t,e,r){d.publish(this._dataId+t,e,r);let s=t+":change";this.eventSub.publish(s,e,r)}mergeStage(){this.attributes=at(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e){if(y.hasDeepData(e)){let a=y.getSegments(e),o=a.length,l=o-1;for(var r=0;r<o;r++){var s=a[r],n=t[s];if(n!==void 0){if(r===l){if(Array.isArray(t)){t.splice(s,1);break}delete t[s];break}t=n}else break}}else delete t[e]}_getAttr(t,e){if(y.hasDeepData(e)){let a=y.getSegments(e),o=a.length,l=o-1;for(var r=0;r<o;r++){var s=a[r],n=t[s];if(n!==void 0){if(t=n,r===l)return t}else break}return}else return t[e]}};var x=class extends S{_publish(t,e,r,s){let n=t+":change";this.eventSub.publish(n,e,r),r=r||this,d.publish(this._dataId+t,e,r)}};var q=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)t.hasOwnProperty(r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=h.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=h.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)e.hasOwnProperty(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"),s="op=get&id="+r,n=this.model;return this._get("",s,t,e,a=>{if(a){let o=this.getObject(a);o&&n.set(o)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+h.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return!1;let r="op=setup&"+this.setupObjectData();return r=this.addParams(r,t,t),this._put("",r,e)}add(t,e){if(!this.isValid())return!1;let r="op=add&"+this.setupObjectData();return this._post("",r,t,e)}update(t,e){if(!this.isValid())return!1;let r="op=update&"+this.setupObjectData();return this._patch("",r,t,e)}delete(t,e){let r=this.model.get("id"),s="op=delete&id="+r;return this._delete("",s,t,e)}all(t,e,r,s,n){n=n||"",r=isNaN(r)?0:r,s=isNaN(s)?50:s;let a="op=all&option="+n+"&start="+r+"&stop="+s;return this._get("",a,t,e)}getUrl(t){let e=this.url;return t?t[0]==="?"?e+t:e+="/"+t:e}setupRequest(t,e,r,s,n){let a={url:this.getUrl(t),method:e,params:r,completed:(l,f)=>{typeof n=="function"&&n(l),this.getResponse(l,s,f)}};return this._isFormData(r)&&(a.headers={}),N(a)}_isFormData(t){return t instanceof FormData}request(t,e,r,s){return this._request("","POST",t,e,r,s)}_get(t,e,r,s,n){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",s,n)}_post(t,e,r,s,n){return this._request(t,"POST",e,r,s,n)}_put(t,e,r,s,n){return this._request(t,"PUT",e,r,s,n)}_patch(t,e,r,s,n){return this._request(t,"PATCH",e,r,s,n)}_delete(t,e,r,s,n){return this._request(t,"DELETE",e,r,s,n)}_request(t,e,r,s,n,a){return r=this.setupParams(r),r=this.addParams(r,s),this.setupRequest(t,e,r,n,a)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;var e=this;class r extends e{constructor(n){super(n)}}return Object.assign(r.prototype,t),r}};var Ut=i=>{let t={};if(!i||typeof i!="object")return t;let e=i.defaults;if(!e)return t;for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];typeof s!="function"&&(t[r]=s)}return delete i.defaults,t},Nt=i=>{if(!i||typeof i.xhr!="object")return{};let t=i.xhr,e=Object.assign({},t);return delete i.xhr,e},Ht=0,P=class extends v{constructor(t){super(t),this.initialize()}initialize(){}static extend(t={}){let e=this,r=Nt(t),s=this.prototype.service.extend(r),n=Ut(t);class a extends e{constructor(l){let f=z(l);f=Object.assign({},n,f),super(f),this.xhr=new s(this)}dataTypeId="bm"+Ht++}return Object.assign(a.prototype,t),a.prototype.service=s,a}};P.prototype.service=q;var X=class extends x{constructor(t){super(),this.id=t}restore(){g.restore(this.id,this)}remove(){g.remove(this.id)}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);else{let r=this.stage;typeof r[t]<"u"&&delete r[t]}}};var ot=class{constructor(){this.targets={}}restore(t,e){this.targets[t]=e}getTarget(t){let e=this.targets;return e[t]||(e[t]=new X(t))}getActionState(t,e){return this.getTarget(t).get(e)}add(t,e,r){let s=this.getTarget(t);return e&&s.addAction(e,r),s}addAction(t,e,r){return this.add(t,e,r)}removeAction(t,e,r){this.off(t,e,r)}on(t,e,r){let s=this.getTarget(t);return e?s.on(e,r):!1}off(t,e,r){this.remove(t,e,r)}remove(t,e,r){let s=this.targets,n=s[t];if(!n)return!1;e?n.off(e,r):delete s[t]}set(t,e,r){var s=this.getTarget(t);s.set(e,r)}},g=new ot;var K=class{constructor(){this._reserved=["tag","bind","onCreated","route","switch","useParent","useState","useData","addState","map","for","html","onSet","onState","watch","context","useContext","addContext","role","aria","cache"]}getElementTag(t){let e="div",r=t.tag||t.t;return typeof r<"u"&&(e=t.tag=r),e}setupChildren(t){t.nest&&(t.children=t.nest,t.nest=null)}parseElement(t){let e={},r=[],s=this.getElementTag(t);s==="button"&&(e.type=e.type||"button"),this.setupChildren(t);let n=this._reserved;for(var a in t)if(t.hasOwnProperty(a)){var o=t[a];if(o==null||n.indexOf(a)!==-1)continue;typeof o!="object"?e[a]=o:a==="children"?r=r.concat(o):r.push(o)}return{tag:s,attr:e,children:r}}};var Mt=h.dataTracker,Wt={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"},lt=i=>Wt[i]||i,ht=i=>typeof i=="string"&&i.substring(0,2)==="on"?i.substring(2):i,G=class{create(t,e,r,s){let n=document.createElement(t);return this._addElementAttrs(n,e),s===!0?this.prepend(r,n):this.append(r,n),n}_addElementAttrs(t,e){if(!e||typeof e!="object")return!1;let r=e.type;typeof r<"u"&&h.setAttr(t,"type",r);for(var s in e)if(!(e.hasOwnProperty(s)===!1||s==="type")){var n=e[s];s==="innerHTML"?t.innerHTML=n:s.substring(4,1)==="-"?h.setAttr(t,s,n):this.addAttr(t,s,n)}}addHtml(t,e){typeof e<"u"&&e!==""&&(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e)}addAttr(t,e,r){if(r===""||!e)return!1;if(typeof r==="function")e=ht(e),h.addListener(e,t,r);else{let n=lt(e);t[n]=r}}createDocFragment(){return document.createDocumentFragment()}createTextNode(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}createCommentNode(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}setupSelectOptions(t,e,r){if(!t||typeof t!="object"||!e||!e.length)return!1;for(var s=0,n=e.length;s<n;s++){var a=e[s],o=t.options[s]=new Option(a.label,a.value);r!==null&&o.value==r&&(o.selected=!0)}}removeElementData(t){let e=t.childNodes;if(e){let a=e.length-1;for(var r=a;r>=0;r--){var s=e[r];s&&this.removeElementData(s)}}Mt.remove(t),t.bindId&&d.unbind(t)}removeElement(t){let e;return!t||!(e=t.parentNode)?this:(this.removeElementData(t),e.removeChild(t),this)}removeChild(t){this.removeElement(t)}removeAll(t){if(typeof t=="object"){let r=t.childNodes;for(var e in r)r.hasOwnProperty(e)&&this.removeElementData(r[e]);t.innerHTML=""}}changeParent(t,e){e.appendChild(t)}append(t,e){switch(typeof t){case"object":break;case"undefined":t=document.body;break}t.appendChild(e)}prepend(t,e,r){switch(typeof t){case"object":break;case"undefined":t=document.body;break}var s=r||t.firstChild;t.insertBefore(e,s)}clone(t,e){return!t||typeof t!="object"?!1:(e=e||!1,t.cloneNode(e))}};var kt=/(\[\[(.*?)\]\])/g,ft={_getWatcherProps(i){let t=/\[\[(.*?)\]\]/g,e=i.match(t);if(e){t=/(\[\[|\]\])/g;for(var r=0,s=e.length;r<s;r++)e[r]=e[r].replace(t,"")}return e},updateAttr(i,t,e){t==="text"||t==="textContent"?i.textContent=e:t==="innerHTML"?i.innerHTML=e:t.substring(4,1)==="-"?h.setAttr(i,t,e):i[t]=e},_getWatcherCallBack(i,t,e,r,s){return()=>{let n=0,a=e.replace(kt,function(){let o=s?t[n]:t;n++;let l=o.get(arguments[2]);return typeof l<"u"?l:""});this.updateAttr(i,r,a)}},getParentData(i){return i.data?i.data:i.context&&i.context.data?i.context.data:i.state?i.state:null},getValue(i,t){typeof i=="string"&&(i={value:i});let e=i.value;return Array.isArray(e)===!1?e=[e,this.getParentData(t)]:e.length<2&&e.push(this.getParentData(t)),e},getPropValues(i,t,e){let r=[];for(var s=0,n=t.length;s<n;s++){var a=e?i[s]:i,o=a.get(t[s]);o=typeof o<"u"?o:"",r.push(o)}return r},getCallBack(i,t,e,r,s){let n,a=i.callBack;if(typeof a=="function"){let o=r.match(kt),l=o&&o.length>1;n=(f,u)=>{f=l!==!0?f:this.getPropValues(e,o,s),a(t,f,u)}}else{let o=i.attr||"textContent";n=this._getWatcherCallBack(t,e,r,o,s)}return n},addDataWatcher(i,t,e){let r=this.getValue(t,e),s=r[1];if(!s)return;let n=r[0],a=Array.isArray(s),o=this.getCallBack(t,i,s,n,a),l=this._getWatcherProps(n);for(var f=0,u=l.length;f<u;f++){var c=a?s[f]:s;this.addWatcher(i,c,l[f],o)}},setup(i,t,e){!t||(Array.isArray(t)&&(t={attr:t[2],value:[t[0],t[1]]}),this.addDataWatcher(i,t,e))},addWatcher(i,t,e,r){d.watch(i,t,e,r)}};var Jt={created:"onCreated",state:"setupStates",events:"setupEevents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"},Ft=i=>typeof i==="function"?i:function(){return i},Vt=i=>{let t={};if(!i)return t;for(var e in i){if(i.hasOwnProperty(e)===!1)continue;let r=i[e],s=Jt[e];if(s){t[s]=Ft(r);continue}t[e]=r}return t},zt=i=>{class t extends w{}return Object.assign(t.prototype,i),t},Ct=i=>{class t extends b{}return Object.assign(t.prototype,i),t},D=function(i){if(!i)return null;let t;switch(typeof i){case"object":return i.render?(t=Vt(i),zt(t)):(t={render:function(){return i}},Ct(t));case"function":return t={render:i},Ct(t)}};var Tt=function(i,t){return function(e){return{onSet:[i,t,(r,s)=>e(s)]}}};h.dataTracker.addType("context",function(i){if(!i)return!1;i.parent.removeContextBranch(i.branch)});var qt=new K,ut=class extends G{create(t,e,r,s){let n=document.createElement(t);return this._addElementAttrs(n,e,s),this.append(r,n),n}_addElementAttrs(t,e,r){if(!e||typeof e!="object")return!1;let s=e.type;typeof s<"u"&&h.setAttr(t,"type",s);for(var n in e)if(!(e.hasOwnProperty(n)===!1||n==="type")){var a=e[n];n==="innerHTML"?t.innerHTML=a:n.indexOf("-")!==-1?h.setAttr(t,n,a):this.addAttr(t,n,a,r)}}addAttr(t,e,r,s){if(r===""||!e)return!1;if(typeof r==="function")e=ht(e),h.addListener(e,t,function(a){r.call(this,a,s)});else{let a=lt(e);t[a]=r}}render(t,e,r){if(!!t)switch(typeof t){case"object":if(t.isUnit===!0)return this.createComponent(t,e,r),t;default:let s=D(t),n=new s;return this.createComponent(n,e,r),n}}build(t,e,r){let s=this.createDocFragment();if(Array.isArray(t)){let o;for(var n=0,a=t.length;n<a;n++)o=t[n],this.buildElement(o,s,r)}else this.buildElement(t,s,r);return e&&typeof e=="object"&&e.appendChild(s),s}buildElement(t,e,r){!t||(t.component||t.isUnit===!0?this.createComponent(t,e,r):this.createElement(t,e,r))}append(t,e){t.appendChild(e)}createElement(t,e,r){let s=qt.parseElement(t),n=this.createNode(s,e,r),a=t.cache;r&&a&&(r[a]=n);let o=s.children;if(o.length>0){let u;for(var l=0,f=o.length;l<f;l++)u=o[l],u!==null&&this.buildElement(u,n,r)}this.addElementDirectives(n,t,r)}addElementDirectives(t,e,r){typeof e.onCreated=="function"&&e.onCreated(t,r);let s=e.bind;if(s&&this.bindElement(t,s,r),e.route&&this.addRoute(t,e.route,r),e.switch&&this.addSwitch(t,e.switch,r),e.html&&this.addHtml(t,e.html),e.useContext&&this.useContext(t,e.useContext,r),e.addContext&&this.addContext(t,e.addContext,r),e.context&&this.context(t,e.context,r),e.role&&this.addRole(t,e.role,r),e.aria&&this.addAria(t,e.aria,r),r){let n=e.onState;n&&n.length&&this.onState(t,n,r);let a=e.onSet;a&&a.length&&this.onSet(t,a,r);let o=e.map;o&&o.length&&this.map(t,o,r);let l=e.for;l&&l.length&&this.for(t,l,r);let f=e.useParent;f&&this.useParent(t,f,r);let u=e.useData;u&&this.useData(t,u,r);let c=e.useState;c&&this.useState(t,c,r);let m=e.addState;m&&this.addState(t,m,r)}e.watch&&this.watch(t,e.watch,r)}_getDataSource(t){return t?t.data?t.data:t.context&&t.context.data?t.context.data:t.state?t.state:!1:!1}bindElement(t,e,r){let s,n,a;if(typeof e=="string"){if(s=this._getDataSource(r),!s)return!1;n=e}else if(Array.isArray(e)){if(typeof e[0]!="object"){let o=this._getDataSource(r);if(o)e.unshift(o);else return!1}[s,n,a]=e}d.bind(t,s,n,a)}addRoute(t,e,r){if(!e)return!1;if(h.isArray(e))for(var s=0,n=e.length;s<n;s++)this.setupRoute(t,e[s],r);else this.setupRoute(t,e,r)}setupRoute(t,e,r){e.container=t,e.parent=r;let s=h.router.add(e);this.trackRoute(t,s)}checkResume(t){return t&&t.component&&t.component.route}resumeRoute(t,e){h.router.resume(e,t),this.trackRoute(t,e)}trackRoute(t,e){h.dataTracker.add(t,"routes",{route:e})}addSwitch(t,e,r){let s=e[0];for(var n=0,a=e.length;n<a;n++)s=e[n],s.container=t,s.parent=r;let o=h.router.addSwitch(e);this.trackSwitch(t,o)}resumeSwitch(t,e){let r=h.router.resumeSwitch(e,t);this.trackSwitch(t,r)}trackSwitch(t,e){h.dataTracker.add(t,"switch",{id:e})}addRole(t,e,r){!e||e&&h.setAttr(t,"role",e)}addAria(t,e,r){if(!e)return;let s=e.role;s&&(h.setAttr(t,"role",s),e.role=null);let n=f=>(u,c)=>{var m=c?"true":"false";h.setAttr(u,f,m)};for(var a in e)if(!(e.hasOwnProperty(a)===!1||e[a]===null)){var o=e[a],l="aria-"+a;Array.isArray(o)?(o.push(n(l)),this.onSet(t,o,r)):h.setAttr(t,l,o)}}getParentContext(t){return t?t.getContext():null}context(t,e,r){if(typeof e!="function")return;let s=this.getParentContext(r),n=e(s);!n||(this._addElementAttrs(t,n,r),this.addElementDirectives(t,n,r))}useContext(t,e,r){if(typeof e!="function")return;let s=this.getParentContext(r);e(s)}addContext(t,e,r){if(typeof e!="function"||!r)return;let s=this.getParentContext(r),n=e(s);!n||r.addContextBranch(n[0],n[1])}trackContext(t,e,r){h.dataTracker.add(t,"context",{branch:e,parent:r})}watch(t,e,r){if(!e)return!1;if(Array.isArray(e)&&typeof e[0]!="string")for(var s=0,n=e.length;s<n;s++)ft.setup(t,e[s],r);else ft.setup(t,e,r)}useParent(t,e,r){if(!e||!r)return!1;e(r,t)}useData(t,e,r){if(!e||!r)return!1;e(r.data,t)}useState(t,e,r){if(!e||!r)return!1;e(r.state,t)}addState(t,e,r){if(!e||!r)return!1;if(r.stateHelper){let s=r.state,n=e(s);r.stateHelper.addStates(n)}}map(t,e,r){let s=e[0];if(!s||s.length<1)return;let n=e[1],a=[];for(var o=0,l=s.length;o<l;o++){var f=s[o];if(!!f){var u=n(f,o);u!==null&&a.push(u)}}return this.build(a,t,r)}for(t,e,r){let s,n,a,o;if(e.length<3){let f=this.getParentSetData(r);if(!f)return;s=f,n=e[0],a=e[1],o=e[2]}else s=e[0],n=e[1],a=e[2],o=e[3];let l=o!==!1;d.watch(t,s,n,f=>{if(this.removeAll(t),!f||f.length<1)return;let u=[];for(var c=0,m=f.length;c<m;c++){var B=l?s.scope(n+"["+c+"]"):null,yt=a(f[c],c,B);yt!==null&&u.push(yt)}return this.build(u,t,r)})}onState(t,e,r){this.onUpdate(t,r.state,e,r)}getParentSetData(t){return t.data?t.data:t.context&&t.context.data?t.context.data:null}onSet(t,e,r){let s=this.getParentSetData(r);this.onUpdate(t,s,e,r)}onUpdate(t,e,r,s){let n,a,o;if(h.isArray(r[0])){for(var l=0,f=r.length;l<f;l++){var u=r[l];!u||this.onUpdate(t,e,u,s)}return}if(r.length<3?[n,a]=r:[e,n,a]=r,!e||!n)return!1;switch(typeof a){case"object":o=c=>{this.addClass(t,a,c)};break;case"function":o=c=>{this.updateElement(t,a,n,c,s)};break}d.watch(t,e,n,o)}updateElement(t,e,r,s,n){let a=e(t,s,n);switch(typeof a){case"object":if(n&&a&&a.isUnit===!0&&n.persist===!0&&n.state){let o=r+":"+s,l=n.state,f=l.get(o);typeof f<"u"&&(a=f),l.set(o,a)}this.rebuild(t,a,n);break;case"string":this.addHtml(t,a);break}}addClass(t,e,r){for(var s in e)!e.hasOwnProperty(s)||!s||(e[s]===r?h.addClass(t,s):h.removeClass(t,s))}rebuild(t,e,r){this.removeAll(t),this.build(e,t,r)}createComponent(t,e,r){let s=t.component||t;s.parent=r,r&&r.persist===!0&&s.persist!==!1&&(s.persist=!0),s.cacheable&&r&&(r[s.cacheable]=s),s.setup(e),t.component&&typeof t.onCreated=="function"&&t.onCreated(s)}createNode(t,e,r){let s=t.tag;if(s==="text"){let n=t.attr,a=n.textContent||n.text;return this.createTextNode(a,e)}else if(s==="comment"){let a=t.attr.text;return this.createCommentNode(a,e)}return this.create(s,t.attr,e,r)}},p=new ut;h.augment({buildLayout(i,t,e){p.build(i,t,e)}});h.dataTracker.addType("components",i=>{if(!i)return;let t=i.component;t&&t.rendered===!0&&t.prepareDestroy()});var Xt=0,b=class{constructor(t){this.isUnit=!0,this.init(),this.setupProps(t),this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Xt++}setupProps(t){if(!t||typeof t!="object")return!1;for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])}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||{},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)}buildLayout(){let t=this.prepareLayout();this.build(t,this.container),h.dataTracker.add(this.panel,"components",{component:this}),this.rendered=!0}build(t,e){return p.build(t,e,this)}prepend(t,e,r){var s=this.build(t,null);p.prepend(e,s,r)}rebuild(t,e){return p.rebuild(e,t,this)}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var s=0,n=t.length;s<n;s++){var a=e(t[s],s);r.push(a)}return r}removeAll(t){return p.removeAll(t)}cache(t,e,r){return!e||typeof e!="object"?!1:(e.isUnit===!0&&(e={component:e}),e.onCreated=s=>{this[t]=s,typeof r=="function"&&r(s)},e)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup(),this.buildLayout(),this.afterSetup()}beforeSetup(){}afterSetup(){}setup(t){this.container=t,this.initialize()}remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;p.removeElement(t)}prepareDestroy(){this.rendered=!1,this.beforeDestroy()}beforeDestroy(){}destroy(){this.remove()}bindElement(t,e,r,s){t&&d.bind(t,e,r,s)}};var Q=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(e<1)return!1;let r;for(var s=0;s<e;s++)r=t[s],this.on(...r)}on(t,e,r,s){h.on(t,e,r,s),this.events.push({event:t,obj:e,callBack:r,capture:s})}off(t,e,r,s){h.off(t,e,r,s);let n,a=this.events;for(var o=0,l=a.length;o<l;o++)if(n=a[o],n.event===t&&n.obj===e){a.splice(o,1);break}}set(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],h.on(t.event,t.obj,t.callBack,t.capture)}unset(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],h.off(t.event,t.obj,t.callBack,t.capture)}reset(){this.unset(),this.events=[]}};var $=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,s){return{action:t,state:e,callBack:r,targetId:s,token:null}}convertStates(t){let e=[];for(var r in t)if(t.hasOwnProperty(r)!==!1){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var s=null,n=null,a=t[r];a&&typeof a=="object"&&(n=a.callBack,s=a.id||a.targetId,a=a.state),e.push(this.createState(r,a,n,s))}return e}setupRemoteStates(t,e){let r;for(var s=0,n=t.length;s<n;s++)if(r=t[s],!!r){for(var a in r)if(!(r.hasOwnProperty(a)===!1||a==="id")){var o=null,l=r[a],f=l!==null?l:void 0;f&&typeof f=="object"&&(o=f.callBack,f=f.state),e.push(this.createState(a,f,o,r.id))}}}removeRemoteStates(){let t=this.remoteStates;t&&this.removeActions(t)}removeActions(t){if(!(t.length<1))for(var e=0,r=t.length;e<r;e++){var s=t[e];g.remove(s.targetId,s.action,s.token)}}restore(t){t.restore();let e=this.remoteStates;if(!!e)for(var r=0,s=e.length;r<s;r++){var n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let s=g.getTarget(r);return t.link(s,e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var s=0,n=e.length;s<n;s++){var a=e[s],o=this.addAction(t,a);a.targetId&&(a.token=o,r.push(a))}r.length<1&&(this.remoteStates=null)}addAction(t,e){let r,s=e.action,n=e.targetId;n&&(r=this.bindRemoteState(t,s,n)),typeof e.state<"u"&&t.addAction(s,e.state);let a=e.callBack;return typeof a=="function"&&t.on(s,a),r}};var w=class extends b{constructor(t){super(t),this.isComponent=!0,this.stateTargetId=null}initialize(){this.setupContext(),this.beforeSetup(),this.addStates(),this.buildLayout(),this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=g.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateHelper.restore(t);return}let e=this.setupStates();h.isEmpty(e)||(this.setupStateTarget(),this.stateHelper=new $(this.state,e))}removeStates(){let t=this.state;if(!t)return!1;this.stateHelper.removeRemoteStates(),t.remove()}setupEventHelper(){this.events||(this.events=new Q)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();if(t.length<1)return!1;this.setupEventHelper(),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 Y=class extends w{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",className:this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),children:this.children,watch:r}}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact!==!1,s=O.data,n=[];return t&&typeof t=="object"&&n.push({attr:"href",value:t}),e&&typeof e=="object"&&n.push({attr:"text",value:e}),n.push({value:["[[path]]",s],callBack:(a,o)=>{let l=a.pathname+a.hash,f=r?o===l:new RegExp("^"+a.pathname+"($|#|/|\\.).*").test(o);this.update(a,f)}}),n}setupStates(){return{selected:!1}}update(t,e){this.state.set("selected",e)}};var At={removeSlashes(i){return typeof i=="string"&&(i.substring(0,1)==="/"&&(i=i.substring(1)),i.substring(-1)==="/"&&(i=i.substring(0,i.length-1))),i}};var Z=class{constructor(t,e){this.route=t,this.template=e.component,this.component=null,this.hasTemplate=!1,this.setup=!1,this.container=e.container,this.persist=e.persist,this.parent=e.parent,this.setupTemplate()}focus(t){this.setup===!1&&this.create(),this.update(t)}setupTemplate(){let t=this.template;if(typeof t=="string"&&(t=this.template=window[t],!t))return;let e=typeof t;if(e==="function")this.component=new this.template({route:this.route,persist:this.persist,parent:this.parent});else if(e==="object"){this.template.isUnit||(this.template=Jot(this.template));let r=this.component=this.template,s=r.persist!==!1;r.route=this.route,r.persist=s,r.parent=this.parent,this.persist=s}this.hasTemplate=!0}create(){if(!this.hasTemplate)return!1;this.setup=!0;let t=this.component;(!this.persist||!t)&&(t=this.component=this.template),p.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return!1;this.setup=!1;let t=this.component;if(!t)return!1;typeof t.destroy=="function"&&t.destroy(),this.persist===!1&&(this.component=null)}update(t){let e=this.component;if(!e)return!1;typeof e.update=="function"&&e.update(t)}};var dt=[],Kt=i=>dt.indexOf(i)!==-1,Gt=i=>({tag:"script",src:i.src,async:!1,load(t){dt.push(i.src);let e=i.load;e&&e()}}),Qt=i=>({tag:"link",rel:"stylesheet",type:"text/css",href:i.src,load(t){dt.push(i.src);let e=i.load;e&&e()}}),ct=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,r=this.update.bind(this);t.indexOf(".css")!==-1?e=Qt({load:r,src:t}):e=Gt({load:r,src:t}),p.build(e,document.head)}addFiles(t){if(!!t)for(var e=0,r=t.length;e<r;e++){var s=t[e];Kt(s)||this.add(s)}}update(){if(this.updateProgress()>=100){var e=this.callBack;e&&e()}}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}},$t=(i,t)=>{import(i).then(e=>{t&&t(e)})},Yt=i=>i?typeof i?.prototype?.constructor=="function":!1,Zt=(i,t,e)=>{let r=p.build(i,null,e),s=r.firstChild;return t.after(r),s},jt=i=>({tag:"comment",text:"import placeholder",onCreated:i.onCreated}),te=D({render(){return jt({onCreated:i=>{if(!!this.src){if(this.depends){new ct(()=>{this.loadAndRender(i)}).addFiles(this.depends);return}this.loadAndRender(i)}}})},getLayout(i){let t=i.default;if(!t)return null;let e=this.callBack;return e?t=e(t):Yt(t)?(t=new t,t.route=this.route,this.persist&&(t.persist=!0)):t=t(),this.layout=t},loadAndRender(i){$t(this.src,t=>{this.loaded=!0;let e=this.layout||this.getLayout(t);this.layoutRoot=Zt(e,i,this.parent)})},shouldUpdate(i){return this.updateLayout===!0?!0:this.updateLayout=i&&i.isUnit&&typeof i.update=="function"},updateModuleLayout(i){let t=this.layout;this.shouldUpdate(t)&&t.update(i)},update(i){this.loaded===!0&&this.updateModuleLayout(i)},beforeDestroy(){!this.layoutRoot||p.removeElement(this.layoutRoot)}}),Et=i=>new te(i);var ee=i=>{let t="";if(i){let e=/\//g;t=i.replace(e,"/");let r=/(\/):[^\/(]*?\?/g;t=t.replace(r,o=>{let l=/\//g;return o.replace(l,"(?:$|/)")});let s=/(:[^\/?&($]+)/g,n=/(\?\/+\*?)/g;t=t.replace(n,"?/*"),t=t.replace(s,o=>o.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)");let a=/(\*)/g;t=t.replace(a,".*")}return t+=i[i.length-1]==="*"?"":"$",t},re=i=>{if(i.length){let r={};for(var t=0,e=i.length;t<e;t++)r[i[t]]=null;return r}return null},se=i=>{let t=[];if(!i)return t;let e=/[\*?]/g;i=i.replace(e,"");let r=/:(.[^.\/?&($]+)\?*/g,s=i.match(r);if(s===null)return t;for(var n=0,a=s.length;n<a;n++){var o=s[n];o&&(o=o.replace(":",""),t.push(o))}return t},ie=0,j=class extends x{constructor(t){let e=t.baseUri,r=se(e),s=re(r);super(s),this.uri=e,this.paramKeys=r,this.setupRoute(t),this.set("active",!1)}setupRoute(t){this.id=t.id||"bs-rte-"+ie++,this.path=null,this.referralPath=null;let e=ee(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title}setTitle(t){base.router.updateTitle({title:t,stage:this.stage})}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?(typeof e=="string"&&(e={src:e}),Et(e)):null}setupComponentHelper(t){let e=this.getLayout(t);if(e){let{container:r,persist:s=!1,parent:n}=t,a={component:e,container:r,persist:s,parent:n};this.controller=new Z(this,a)}}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let s=this.path;if(!s)return;let n=s.split("#")[1];!n||this.scrollToId(n)}scrollToId(t){if(!t)return;let e=document.getElementById(t);!e||e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(r&&typeof r=="object"&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(t&&typeof t=="object"){let n=this.paramKeys;if(n){let a={};for(var e=0,r=n.length;e<r;e++){var s=n[e];typeof s<"u"&&(a[s]=t[e])}this.set(a)}}}getParams(){return this.stage}};var _=class{static browserIsSupported(){return"history"in window&&"pushState"in window.history}static setup(t){return _.browserIsSupported()?new pt(t).setup():new mt(t).setup()}},ne=0,tt=class{constructor(t){this.router=t,this.locationId="base-app-router-"+ne++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}},pt=class extends tt{addEvent(){return h.on("popstate",window,this.callBack),this}removeEvent(){return h.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri)}createState(t,e){let r={location:this.locationId,uri:t};return e&&typeof e=="object"&&(r=Object.assign(r,e)),r}addState(t,e,r){let s=window.history,n=s.state;if(n&&n.uri===t)return this;let a=this.createState(t,e);return r=r===!0,s[r===!1?"pushState":"replaceState"](a,null,t),this}},mt=class extends tt{addEvent(){return h.on("hashchange",window,this.callBack),this}removeEvent(){return h.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};h.dataTracker.addType("routes",i=>{if(!i)return!1;let t=i.route;t&&O.removeRoute(t)});h.dataTracker.addType("switch",i=>{if(!i)return!1;let t=i.id;O.removeSwitch(t)});var gt=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.history=null,this.callBackLink=null,this.location=window.location,this.routes=[],this.switches={},this.switchCount=0,this.data=new v({path:""})}setupHistory(){this.history=_.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new j(t)}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+At.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var n=e[s];if(n.uri===t)return n}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var n=e[s];if(n.id===t)return n}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);for(var s=0,n=t.length;s<n;s++){var a=this.createRoute(t[s]);r.push(a)}return this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,s=this.getSwitchGroup(r);for(var n=0,a=t.length;n<a;n++){var o=t[n].component.route;o.resume(e),s.push(o)}return this.checkGroup(s,this.getPath()),r}getSwitchGroup(t){return this.switches[t]=[]}removeSwitch(t){let e=this.switches;e[t]&&delete e[t]}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e!==!1&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.set("path",this.getPath()),this.callBackLink=this.checkLink.bind(this),h.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){let e=t.parentNode;for(;e!==null;){if(e.nodeName.toLowerCase()==="a")return e;e=e.parentNode}return!1}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target||t.srcElement;if(e.nodeName.toLowerCase()!=="a"&&(e=this.getParentLink(e),e===!1)||e.target==="_blank"||h.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let s=this.baseURI,n=s!=="/"?r.replace(s,""):r;return this.navigate(n),t.preventDefault(),t.stopPropagation(),!1}}reset(){return this.routes=[],this.switches=[],this.switchCount=0,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.set("path",t)}updateTitle(t){if(!t||!t.title)return this;let e=s=>{let n=o=>{let l=/\w\S*/;return o.replace(l,f=>f.charAt(0).toUpperCase()+f.substring(1).toLowerCase())},a=o=>{if(o.indexOf(":")>-1){let c=t.stage;for(var l in c)if(c.hasOwnProperty(l)){var f=c[l],u=new RegExp(":"+l,"gi");o=o.replace(u,f)}}return o};return s&&(typeof s=="function"&&(s=s(t.stage)),s=a(s),s=n(s),this.title!==""&&(s+=" - "+this.title)),s},r=t.title;document.title=e(r)}checkActiveRoutes(t){this.lastPath=t,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,s;for(var n=0;n<r;n++)s=e[n],!(typeof s>"u")&&this.checkRoute(s,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(var r in e)if(e.hasOwnProperty(r)!==!1){var s=e[r];this.checkGroup(s,t)}}checkGroup(t,e){let r=!1,s,n,a,o,l=!1;for(var f=0,u=t.length;f<u;f++)if(s=t[f],!(typeof s>"u")){if(f===0&&(n=s),!a&&s.get("active")&&(a=s),r!==!1){l&&s.deactivate();continue}r=s.match(e),r!==!1&&(o=s,s.controller&&(this.select(s),l=!0))}o===void 0?(this.select(n),a&&n!==a&&a.deactivate()):a?l&&o!==a&&a.deactivate():n&&l===!1&&this.select(n)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?this.select(t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){if(!t)return!1;t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t)}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){h.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},O=new gt;var Pt=function(){};Pt.extend=function i(t){let e=this;if(typeof t=="object"){let s=t;t=n=>R.cloneObject(s)}let r=(s={})=>{s=s||{};let n=t(s),a=e(s);return typeof a=="object"&&(n=R.extendObject(a,n)),n};return r.extend=i,r};h.augment({ajax:N,dataBinder:d,Data:v,SimpleData:x,Model:P,state:g,builder:p,router:O,Component:w});export{Pt as Atom,w as Component,v as Data,D as Jot,P as Model,Y as NavLink,x as SimpleData,b as Unit,Tt as Watch,N as ajax,h as base,p as builder,d as dataBinder,O as router,g as state};
|
|
1
|
+
var R={createObject(i){return Object.create(i)},extendObject(i,t){if(typeof i>"u"||typeof t>"u")return!1;for(var e in i)i.hasOwnProperty(e)&&typeof t[e]>"u"&&(t[e]=i[e]);return t},cloneObject(i){return i?JSON.parse(JSON.stringify(i)):{}},_getClassObject(i){return typeof i=="function"?i.prototype:i},extendClass(i,t){let e=this._getClassObject(i),r=this._getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let s=Object.create(e);for(var n in r)s[n]=r[n];return s}};var et={types:{},add(i,t){this.types[i]=t},get(i){return this.types[i]||!1},remove(i){delete this.types[i]}},rt=class{constructor(){this.types={}}add(t,e){(this.types[t]||(this.types[t]=[])).push(e)}get(t){return this.types[t]||!1}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){let e=this.types;if(e){let n=e[t];if(n.length){let a,o=et.get(t);for(var r=0,s=n.length;r<s;r++)a=n[r],a&&(n[r]=null,this.removeByCallBack(o,a));delete e[n]}}}remove(t){if(t)this.removeType(t);else{let r=this.types;for(var e in r)if(r.hasOwnProperty(e)){if(t=r[e],!t)continue;this.removeType(e)}delete this.types}}},I=class{constructor(){this.trackers={},this.trackingCount=0}addType(t,e){et.add(t,e)}removeType(t){et.remove(t)}getTrackingId(t){return t.trackingId||(t.trackingId="dt"+this.trackingCount++)}add(t,e,r){let s=this.getTrackingId(t);this.find(s).add(e,r)}get(t,e){let r=t.trackingId,s=this.trackers[r];return s?e?s.get(e):s:!1}find(t){let e=this.trackers;return e[t]||(e[t]=new rt)}isEmpty(t){if(!t||typeof t!="object")return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}remove(t,e){let r=t.trackingId;if(!r)return!0;let s=this.trackers[r];if(!s)return!1;e?(s.remove(e),this.isEmpty(s.types)&&delete this.trackers[r]):(s.remove(),delete this.trackers[r])}};var Dt=window,L=class{constructor(){this.version="2.6.0",this.errors=[],this.dataTracker=new I}augment(t){if(!t||typeof t!="object")return this;let e=this.constructor.prototype;for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return this}listToArray(t){return Array.prototype.slice.call(t)}override(t,e,r,s){return(t[e]=r).apply(t,this.listToArray(s))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}parseQueryString(t,e){typeof t!="string"&&(t=Dt.location.search);let r={},s=/([^?=&]+)(=([^&]*))?/g;return t.replace(s,function(n,a,o,l){r[a]=e!==!1?decodeURIComponent(l):l}),r}isEmpty(t){if(this.isObject(t)===!1)return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?this.listToArray(e):!1}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]:this.listToArray(r):!1}html(t,e){return this.isObject(t)===!1?!1:this.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}setCss(t,e,r){return this.isObject(t)===!1||this.isUndefined(e)?this:(e=this.uncamelCase(e),t.style[e]=r,this)}getCss(t,e){if(!t||typeof e>"u")return!1;e=this.uncamelCase(e);var r=t.style[e];if(r!=="")return r;var s=null,n=t.currentStyle;if(n&&(s=n[e]))r=s;else{var a=window.getComputedStyle(t,null);a&&(r=a[e])}return r}css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}removeAttr(t,e){return this.isObject(t)&&t.removeAttribute(e),this}setAttr(t,e,r){t.setAttribute(e,r)}getAttr(t,e){return t.getAttribute(e)}attr(t,e,r){return this.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}_checkDataPrefix(t){return typeof t!="string"||(t=h.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}_removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}setData(t,e,r){e=this._removeDataPrefix(e),e=h.camelCase(e),t.dataset[e]=r}getData(t,e){return e=h.camelCase(this._removeDataPrefix(e)),t.dataset[e]}data(t,e,r){return this.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}find(t,e){return!t||typeof e!="string"?!1:t.querySelectorAll(e)}show(t){if(this.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}hide(t){if(this.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}toggle(t){return this.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}camelCase(t){if(typeof t!="string")return!1;let e=/(-|\s|\_)+\w{1}/g;return t.replace(e,function(r){return r[1].toUpperCase()})}uncamelCase(t,e){if(typeof t!="string")return!1;e=e||"-";let r=/([A-Z]{1,})/g;return t.replace(r,function(s){return e+s.toLowerCase()}).toLowerCase()}getSize(t){return this.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}getWidth(t){return this.isObject(t)?t.offsetWidth:!1}getHeight(t){return this.isObject(t)?t.offsetHeight:!1}getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=window.pageXOffset||t.scrollLeft,r=window.pageYOffset||t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return this.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}getScrollTop(t){return this.getScrollPosition(t).top}getScrollLeft(t){return this.getScrollPosition(t).left}getWindowSize(){let t=window,e=document,r=e.documentElement,s=e.getElementsByTagName("body")[0],n=t.innerWidth||r.clientWidth||s.clientWidth,a=t.innerHeight||r.clientHeight||s.clientHeight;return{width:n,height:a}}getDocumentSize(){let t=document,e=t.body,r=t.documentElement,s=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:s}}getDocumentHeight(){return this.getDocumentSize().height}getProperty(t,e,r){if(this.isObject(t)===!1)return"";let s=t[e];return typeof s<"u"?s:typeof r<"u"?r:""}position(t,e=1){let r={x:0,y:0};if(this.isObject(t)===!1)return r;let s=0;for(;t&&(e===0||s<e);)s++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}addClass(t,e){if(this.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let n=e.split(" ");for(var r=0,s=n.length;r<s;r++)t.classList.add(e)}return this}removeClass(t,e){return this.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}hasClass(t,e){return this.isObject(t)===!1||e===""?!1:t.classList.contains(e)}toggleClass(t,e){return this.isObject(t)===!1?this:(t.classList.toggle(e),this)}getType(t){let e=typeof t;return e!=="object"?e:this.isArray(t)?"array":e}isUndefined(t){return typeof t>"u"}isObject(t){return!(!t||typeof t!="object")}isArray(t){return Array.isArray(t)}inArray(t,e,r){return!t||typeof t!="object"?-1:t.indexOf(e,r)}createCallBack(t,e,r,s){return typeof e!="function"?!1:(r=r||[],function(...n){return s===!0&&(r=r.concat(n)),e.apply(t,r)})}bind(t,e){return e.bind(t)}prepareJsonUrl(t,e=!1){var r=l=>{if(typeof l!="string"&&(l=String(l)),e){let u=/\n/g;l=l.replace(u,"\\n")}let f=/\t/g;return l.replace(f,"\\t")},s=l=>{if(typeof l!="string")return l;l=r(l),l=encodeURIComponent(l);let f=/\%22/g;return l.replace(f,'"')},n=l=>{let f=typeof l;if(f==="undefined")return l;if(f!=="object")return l=s(l),l;let u;for(var c in l)if(l.hasOwnProperty(c)){if(u=l[c],u===null)continue;l[c]=n(u)}return l};let a=typeof t=="object"?this.cloneObject(t):t,o=n(a);return this.jsonEncode(o)}jsonDecode(t){return typeof t<"u"&&t.length>0?JSON.parse(t):!1}jsonEncode(t){return typeof t<"u"?JSON.stringify(t):!1}xmlParse(t){if(typeof t>"u")return!1;var e=new DOMParser;return e.parseFromString(t,"text/xml")}};L.prototype.extend=function(){return L.prototype}();var h=new L;h.augment(R);var st=i=>{let t=0;for(var e in i)i.hasOwnProperty(e)&&(t++,typeof i[e]=="object"&&(t+=st(i[e])));return t},vt=(i,t)=>{let e=!1;if(typeof i!="object"||typeof t!="object")return e;for(var r in i){if(!i.hasOwnProperty(r)||!t.hasOwnProperty(r))break;let s=i[r],n=t[r];if(typeof s!=typeof n)break;if(typeof s=="object"){if(e=vt(s,n),e!==!0)break}else if(s===n)e=!0;else break}return e},Ot=(i,t)=>{let e=st(i),r=st(t);return e!==r?!1:vt(i,t)};h.augment({equals(i,t){let e=typeof i;return e!==typeof t?!1:e==="object"?Ot(i,t):i===t}});var U=h.dataTracker,xt={getEvents(i){return h.isObject(i)===!1?!1:U.get(i,"events")},create(i,t,e,r=!1,s=!1,n=null){return s=s===!0,{event:i,obj:t,fn:e,capture:r,swapped:s,originalFn:n}},add(i,t,e,r=!1,s=!1,n=null){if(h.isObject(t)===!1)return this;let a=this.create(i,t,e,r,s,n);return U.add(t,"events",a),t.addEventListener(i,e,r),this},remove(i,t,e,r=!1){let s=this.getEvent(i,t,e,r);return s===!1?this:(typeof s=="object"&&this.removeEvent(s),this)},removeEvent(i){return typeof i=="object"&&i.obj.removeEventListener(i.event,i.fn,i.capture),this},getEvent(i,t,e,r){if(typeof t!="object")return!1;let s=this.getEvents(t);if(!s||s.length<1)return!1;let n=this.create(i,t,e,r);return this.search(n,s)},search(i,t){let e,r=this.isSwappable(i.event);for(var s=0,n=t.length;s<n;s++)if(e=t[s],!(e.event!==i.event||e.obj!==i.obj)&&(e.fn===i.fn||r===!0&&e.originalFn===i.fn))return e;return!1},removeEvents(i){return h.isObject(i)===!1?this:(U.remove(i,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(i){this.swap.push(i)},isSwappable(i){return h.inArray(this.swap,i)>-1}};U.addType("events",i=>{xt.removeEvent(i)});h.augment({events:xt,addListener(i,t,e,r){return this.events.add(i,t,e,r),this},on(i,t,e,r){let s=this.events;if(this.isArray(i)){let o;for(var n=0,a=i.length;n<a;n++)o=i[n],s.add(o,t,e,r)}else s.add(i,t,e,r);return this},off(i,t,e,r){let s=this.events;if(this.isArray(i))for(var n,a=0,o=i.length;a<o;a++)n=i[a],s.remove(n,t,e,r);else s.remove(i,t,e,r);return this},removeListener(i,t,e,r){return this.events.remove(i,t,e,r),this},_createEvent(i,t,e,r){let s;return t==="HTMLEvents"?s=new Event(i):t==="MouseEvents"?s=new MouseEvent(i,e):s=new CustomEvent(i,r),s},createEvent(i,t,e,r){if(this.isObject(t)===!1)return!1;let s={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)&&(s=Object.assign(s,e));let n=this._getEventType(i);return this._createEvent(i,n,s,r)},_getEventType(i){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,r="CustomEvent";for(var s in t)if(t.hasOwnProperty(s)&&(e=t[s],i.match(e))){r=s;break}return r},trigger(i,t,e){if(this.isObject(t)===!1)return this;let r=typeof i=="string"?this.createEvent(i,t,null,e):i;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let i=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=i())},onMouseWheel(i,t,e,r){typeof t>"u"&&(t=window);let s=a=>{a=a||window.event;let o=Math.max(-1,Math.min(1,-a.deltaY||a.wheelDelta||-a.detail));typeof i=="function"&&i(o,a),e===!0&&a.preventDefault()},n=this.getWheelEventType();return this.events.add(n,t,s,r,!0,i),this},offMouseWheel(i,t,e){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,i,e),this},preventDefault(i){return i=i||window.event,typeof i.preventDefault=="function"?i.preventDefault():i.returnValue=!1,this},stopPropagation(i){return i=i||window.event,typeof i.stopPropagation=="function"?i.stopPropagation():i.cancelBubble=!0,this}});var bt={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};h.augment({xhrSettings:bt,addFixedParams(i){this.xhrSettings.fixedParams=i},beforeSend(i){this.xhrSettings.beforeSend.push(i)},ajaxSettings(i){typeof i=="object"&&(this.xhrSettings=this.extendClass(h.xhrSettings,i))},resetAjaxSettings(){this.xhrSettings=bt}});var N=(...i)=>new it(i).xhr,it=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:s,async:n}=this.settings;e.open(r,s,n),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=h.xhrSettings.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var s=0,n=t.length;s<n;s++){var a=t[s];a&&a(e,r)}}objectToString(t){let e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r+"="+t[r]);return e.join("&")}setupParams(t,e){let r=typeof t;if(e){let n=typeof e;if(r==="string")n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e;else if(n==="string"&&(e=h.parseQueryString(e,!1)),t instanceof FormData)for(var s in e)e.hasOwnProperty(s)&&t.append(s,e[s]);else r==="object"&&(t=h.cloneObject(t),t=Object.assign(e,t),t=this.objectToString(t))}else!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.params,r=t.fixedParams;return e?e=this.setupParams(e,r):r&&(e=this.setupParams(r)),e}getXhrSettings(t){let e=this.settings=Object.create(h.xhrSettings);if(t.length>=2&&typeof t[0]!="object")for(var r=0,s=t.length;r<s;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=h.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"){let r=t.headers;for(var e in r)r.hasOwnProperty(e)&&this.xhr.setRequestHeader(e,r[e])}}update(t,e){let r=this.xhr,s=()=>{let o=h.events;o.removeEvents(r.upload),o.removeEvents(r)},n=this.settings;if(!n)return!1;switch(e||t.type){case"load":if(typeof n.completed=="function"){let o=this.getResponseData();n.completed(o,this.xhr)}s();break;case"error":typeof n.failed=="function"&&n.failed(!1,this.xhr),s();break;case"progress":typeof n.progress=="function"&&n.progress(t);break;case"abort":typeof n.aborted=="function"&&n.aborted(!1,this.xhr),s();break}}getResponseData(){let t=this.xhr,e=t.response,r=t.responseType;return!r||r==="text"?t.responseText:e}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=h.bind(this,this.update);h.on(["load","error","abort"],e,r),h.on("progress",e.upload,r)}};var wt=-1,k=class{constructor(){this.callBacks={},this.lastToken=-1}get(t){let e=this.callBacks;return e[t]||(e[t]=[])}reset(){this.callBacks={},this.lastToken=-1,wt=-1}on(t,e){let r=++wt;return this.get(t).push({token:r,callBack:e}),r}off(t,e){let r=this.callBacks[t]||!1;if(r===!1)return!1;let s=r.length;for(var n=0;n<s;n++){var a=r[n];if(a.token===e){r.splice(n,1);break}}}remove(t){let e=this.callBacks;e[t]&&delete e[t]}publish(t){let e,r,s=this.callBacks[t]||!1;if(s===!1)return!1;let n=Array.prototype.slice.call(arguments,1);for(r=s.length,e=0;e<r;e++){var a=s[e];!a||a.callBack.apply(this,n)}}},C=new k;var T=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var H=class extends T{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 A=class{unsubscribe(){}};var M=class extends A{constructor(){super(),this.source=null}addSource(t){return this.source=new H(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var E=class extends T{subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=C.on(t,e)}unsubscribe(){C.off(this.msg,this.token)}callBack(){}};var W=class extends E{constructor(t,e){super(),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 _t=(i,t,e)=>{h.setAttr(i,t,e)},Bt=(i,t,e)=>{i.checked=i.value===e},Rt=(i,t,e)=>{e=e==1,St(i,t,e)},St=(i,t,e)=>{i[t]=e},Lt=(i,t)=>h.getAttr(i,t),It=(i,t)=>i[t],J=class extends E{constructor(t,e,r){super(),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)==="-")this.setValue=_t,this.getValue=Lt;else{this.getValue=It;var r=t.type;if(r)switch(r){case"checkbox":this.setValue=Rt;return;case"radio":this.setValue=Bt;return}this.setValue=St}}getAttrBind(t){if(t)return t;let e="textContent",r=this.element;if(!(r&&typeof r=="object"))return e;let s=r.tagName.toLowerCase();if(s==="input"||s==="textarea"||s==="select"){let n=r.type;if(n)switch(n){case"checkbox":e="checked";break;case"file":e="files";break;default:e="value"}else e="value"}return e}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;if(!e||typeof e!="object")return!1;this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){e!==this.element&&this.set(t)}};var F=class extends A{constructor(){super(),this.element=null,this.data=null}addElement(t,e,r){return this.element=new J(t,e,r)}addData(t,e){return this.data=new W(t,e)}unsubscribeSource(t){t&&t.unsubscribe()}unsubscribe(){this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null}};var V=class{constructor(){this.connections={}}add(t,e,r){let s=this.find(t);return s[e]=r}get(t,e){let r=this.connections[t];return r&&r[e]||!1}find(t){let e=this.connections;return e[t]||(e[t]={})}remove(t,e){let r=this.connections[t];if(!r)return!1;let s;if(e)s=r[e],s&&(s.unsubscribe(),delete r[e]),h.isEmpty(r)&&delete this.connections[t];else{for(var n in r)r.hasOwnProperty(n)&&(s=r[n],s&&s.unsubscribe());delete this.connections[t]}}};var nt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new V,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,s){let n=r,a=null;if(r.indexOf(":")!==-1){let u=r.split(":");u.length>1&&(n=u[1],a=u[0])}let o=this.setupConnection(t,e,n,a,s),l=o.element,f=e.get(n);return typeof f<"u"?l.set(f):(f=l.get(),f!==""&&o.data.set(f)),this}setupConnection(t,e,r,s,n){let a=this.getBindId(t),o=new F;o.addData(e,r).subscribe(a);let f=e.getDataId(),u=f+":"+r;return o.addElement(t,s,n).subscribe(u),this.addConnection(a,"bind",o),o}addConnection(t,e,r){this.connections.add(t,e,r)}setBindId(t){let e="db-"+this.idCount++;return 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,s){if(!t||typeof t!="object")return!1;let n=new M;n.addSource(e).subscribe(r,s);let o=this.getBindId(t),l=e.getDataId()+":"+r;this.addConnection(o,l,n);let f=e.get(r);typeof f<"u"&&s(f)}unwatch(t,e,r){if(!t||typeof t!="object")return!1;let s=t[this.attr];if(s){let n=e.getDataId()+":"+r;this.connections.remove(s,n)}}publish(t,e,r){return C.publish(t,e,r),this}isDataBound(t){if(t){let e=t[this.attr];if(e)return e}return!1}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){let s=this.connections.get(r,"bind");if(s){let n=s.element.get();C.publish(r,n,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){h.on(["change","keyup"],document,this.changeHandler,!1)}removeEvents(){h.off(["change","keyup"],document,this.changeHandler,!1)}},d=new nt;var at=i=>JSON.parse(JSON.stringify(i)),z=i=>{let t={};if(!i&&typeof i!="object")return t;i=at(i);for(var e in i)if(i.hasOwnProperty(e)){var r=i[e];typeof r!="function"&&(t[e]=r,delete i[e])}return t};var S=class{constructor(t){this.dirty=!1,this.links={},this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new k;let e=z(t);this.set(e)}setup(){this.stage={}}_init(){let t=this.constructor;this._dataNumber=typeof t._dataNumber>"u"?t._dataNumber=0:++t._dataNumber,this._id="dt-"+this._dataNumber,this._dataId=this._id+":"}getDataId(){return this._id}remove(){}on(t,e){let r=t+":change";return this.eventSub.on(r,e)}off(t,e){let r=t+":change";this.eventSub.off(r,e)}_setAttr(t,e,r){let s=this.stage[t];if(e===s)return!1;this.stage[t]=e,r=r||this,this._publish(t,e,r,s)}set(...t){if(typeof t[0]=="object"){let[s,n,a]=t;for(var e in s)if(s.hasOwnProperty(e)){var r=s[e];if(typeof r=="function")continue;this._setAttr(e,r,n,a)}}else this._setAttr(...t);return this}getModelData(){return this.stage}_deleteAttr(t,e){delete t[e]}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}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){this.key=t}resume(t){let e=this.key;if(!e)return!1;let r,s=localStorage.getItem(e);s===null?t&&(r=t):r=JSON.parse(s),this.set(r)}store(){let t=this.key;if(!t)return!1;let e=this.get();if(!e)return!1;let r=JSON.stringify(e);localStorage.setItem(t,r)}delete(t){if(typeof t<"u"){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 s=[];for(var n in e)e.hasOwnProperty(n)!==!1&&s.push(this.remoteLink(t,n));return s}remoteLink(t,e,r){let s=r||e,n=t.get(e);typeof n<"u"&&this.get(e)!==n&&this.set(e,n);let a=t.on(e,(l,f)=>{if(f===this)return!1;this.set(s,l,t)});this.addLink(a,t);let o=this.on(s,(l,f)=>{if(f===t)return!1;t.set(e,l,this)});return t.addLink(o,this),a}addLink(t,e){this.links[t]=e}unlink(t){if(t){this.removeLink(t);return}let e=this.links;if(e.length){for(var r=0,s=e.length;r<s;r++)this.removeLink(e[r],!1);this.links=[]}}removeLink(t,e){let r=this.links[t];r&&r.off(t),e!==!1&&delete this.links[t]}};S.prototype.isData=!0;var y={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(i){return i.indexOf(".")!==-1||i.indexOf("[")!==-1},getSegments(i){var t=this.deepDataPattern;return i.match(t)}};var v=class extends S{setup(){this.attributes={},this.stage={}}_updateAttr(t,e,r){if(y.hasDeepData(e)){let n,a=y.getSegments(e),o=a.length,l=o-1;for(var s=0;s<o;s++){if(n=a[s],s===l){t[n]=r;break}t[n]===void 0&&(t[n]=isNaN(n)?{}:[]),t=t[n]}}else t[e]=r}_setAttr(t,e,r,s){typeof e!="object"&&e===this.get(t)||(!r&&s!==!0?this._updateAttr(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),this._updateAttr(this.stage,t,e),r=r||this,this._publish(t,e,r))}linkAttr(t,e){let r=t.get(e);if(r)for(var s in r)r.hasOwnProperty(s)&&this.link(t,e+"."+s,s)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let s=new e(r);return s.linkAttr(this,t),s}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}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){this.publish(t,e,r)}publishDeep(t,e,r){if(y.hasDeepData(t)){let l,f=y.getSegments(t),u=f.length,c=u-1,m="",B=this.stage;for(var s=0;s<u;s++){l=f[s],B=B[l],s>0?isNaN(l)&&(m+="."+l):m=l;var n;if(s===c)n=e;else{var a=f[s+1];if(isNaN(a)===!1){m+="["+a+"]";continue}var o={};o[a]=B[a],n=o}this.publish(m,n,r)}}else this.publish(t,e,r)}publish(t,e,r){if(t=t||"",this._publishAttr(t,e,r),e&&typeof e=="object"){let a,o;if(Array.isArray(e)){let l=e.length;for(var s=0;s<l;s++)o=e[s],a=t+"["+s+"]",this._checkPublish(a,o,r)}else for(var n in e)e.hasOwnProperty(n)&&(o=e[n],a=t+"."+n,this._checkPublish(a,o,r))}}_checkPublish(t,e,r){!e||typeof e!="object"?this._publishAttr(t,e,r):this.publish(t,e,r)}_publishAttr(t,e,r){d.publish(this._dataId+t,e,r);let s=t+":change";this.eventSub.publish(s,e,r)}mergeStage(){this.attributes=at(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e){if(y.hasDeepData(e)){let a=y.getSegments(e),o=a.length,l=o-1;for(var r=0;r<o;r++){var s=a[r],n=t[s];if(n!==void 0){if(r===l){if(Array.isArray(t)){t.splice(s,1);break}delete t[s];break}t=n}else break}}else delete t[e]}_getAttr(t,e){if(y.hasDeepData(e)){let a=y.getSegments(e),o=a.length,l=o-1;for(var r=0;r<o;r++){var s=a[r],n=t[s];if(n!==void 0){if(t=n,r===l)return t}else break}return}else return t[e]}};var x=class extends S{_publish(t,e,r,s){let n=t+":change";this.eventSub.publish(n,e,r),r=r||this,d.publish(this._dataId+t,e,r)}};var q=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)t.hasOwnProperty(r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=h.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=h.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)e.hasOwnProperty(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"),s="op=get&id="+r,n=this.model;return this._get("",s,t,e,a=>{if(a){let o=this.getObject(a);o&&n.set(o)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+h.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return!1;let r="op=setup&"+this.setupObjectData();return this._put("",r,t,e)}add(t,e){if(!this.isValid())return!1;let r="op=add&"+this.setupObjectData();return this._post("",r,t,e)}update(t,e){if(!this.isValid())return!1;let r="op=update&"+this.setupObjectData();return this._patch("",r,t,e)}delete(t,e){let r=this.model.get("id"),s="op=delete&id="+r;return this._delete("",s,t,e)}all(t,e,r,s,n){n=n||"",r=isNaN(r)?0:r,s=isNaN(s)?50:s;let a="op=all&option="+n+"&start="+r+"&stop="+s;return this._get("",a,t,e)}getUrl(t){let e=this.url;return t?t[0]==="?"?e+t:e+="/"+t:e}setupRequest(t,e,r,s,n){let a={url:this.getUrl(t),method:e,params:r,completed:(l,f)=>{typeof n=="function"&&n(l),this.getResponse(l,s,f)}};return this._isFormData(r)&&(a.headers={}),N(a)}_isFormData(t){return t instanceof FormData}request(t,e,r,s){return this._request("","POST",t,e,r,s)}_get(t,e,r,s,n){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",s,n)}_post(t,e,r,s,n){return this._request(t,"POST",e,r,s,n)}_put(t,e,r,s,n){return this._request(t,"PUT",e,r,s,n)}_patch(t,e,r,s,n){return this._request(t,"PATCH",e,r,s,n)}_delete(t,e,r,s,n){return this._request(t,"DELETE",e,r,s,n)}_request(t,e,r,s,n,a){return r=this.setupParams(r),r=this.addParams(r,s),this.setupRequest(t,e,r,n,a)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;var e=this;class r extends e{constructor(n){super(n)}}return Object.assign(r.prototype,t),r}};var Ut=i=>{let t={};if(!i||typeof i!="object")return t;let e=i.defaults;if(!e)return t;for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];typeof s!="function"&&(t[r]=s)}return delete i.defaults,t},Nt=i=>{if(!i||typeof i.xhr!="object")return{};let t=i.xhr,e=Object.assign({},t);return delete i.xhr,e},Ht=0,P=class extends v{constructor(t){super(t),this.initialize()}initialize(){}static extend(t={}){let e=this,r=Nt(t),s=this.prototype.service.extend(r),n=Ut(t);class a extends e{constructor(l){let f=z(l);f=Object.assign({},n,f),super(f),this.xhr=new s(this)}dataTypeId="bm"+Ht++}return Object.assign(a.prototype,t),a.prototype.service=s,a}};P.prototype.service=q;var X=class extends x{constructor(t){super(),this.id=t}restore(){g.restore(this.id,this)}remove(){g.remove(this.id)}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);else{let r=this.stage;typeof r[t]<"u"&&delete r[t]}}};var ot=class{constructor(){this.targets={}}restore(t,e){this.targets[t]=e}getTarget(t){let e=this.targets;return e[t]||(e[t]=new X(t))}getActionState(t,e){return this.getTarget(t).get(e)}add(t,e,r){let s=this.getTarget(t);return e&&s.addAction(e,r),s}addAction(t,e,r){return this.add(t,e,r)}removeAction(t,e,r){this.off(t,e,r)}on(t,e,r){let s=this.getTarget(t);return e?s.on(e,r):!1}off(t,e,r){this.remove(t,e,r)}remove(t,e,r){let s=this.targets,n=s[t];if(!n)return!1;e?n.off(e,r):delete s[t]}set(t,e,r){var s=this.getTarget(t);s.set(e,r)}},g=new ot;var K=class{constructor(){this._reserved=["tag","bind","onCreated","route","switch","useParent","useState","useData","addState","map","for","html","onSet","onState","watch","context","useContext","addContext","role","aria","cache"]}getElementTag(t){let e="div",r=t.tag||t.t;return typeof r<"u"&&(e=t.tag=r),e}setupChildren(t){t.nest&&(t.children=t.nest,t.nest=null)}parseElement(t){let e={},r=[],s=this.getElementTag(t);s==="button"&&(e.type=e.type||"button"),this.setupChildren(t);let n=this._reserved;for(var a in t)if(t.hasOwnProperty(a)){var o=t[a];if(o==null||n.indexOf(a)!==-1)continue;typeof o!="object"?e[a]=o:a==="children"?r=r.concat(o):r.push(o)}return{tag:s,attr:e,children:r}}};var Mt=h.dataTracker,Wt={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"},lt=i=>Wt[i]||i,ht=i=>typeof i=="string"&&i.substring(0,2)==="on"?i.substring(2):i,G=class{create(t,e,r,s){let n=document.createElement(t);return this._addElementAttrs(n,e),s===!0?this.prepend(r,n):this.append(r,n),n}_addElementAttrs(t,e){if(!e||typeof e!="object")return!1;let r=e.type;typeof r<"u"&&h.setAttr(t,"type",r);for(var s in e)if(!(e.hasOwnProperty(s)===!1||s==="type")){var n=e[s];s==="innerHTML"?t.innerHTML=n:s.substring(4,1)==="-"?h.setAttr(t,s,n):this.addAttr(t,s,n)}}addHtml(t,e){typeof e<"u"&&e!==""&&(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e)}addAttr(t,e,r){if(r===""||!e)return!1;if(typeof r==="function")e=ht(e),h.addListener(e,t,r);else{let n=lt(e);t[n]=r}}createDocFragment(){return document.createDocumentFragment()}createTextNode(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}createCommentNode(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}setupSelectOptions(t,e,r){if(!t||typeof t!="object"||!e||!e.length)return!1;for(var s=0,n=e.length;s<n;s++){var a=e[s],o=t.options[s]=new Option(a.label,a.value);r!==null&&o.value==r&&(o.selected=!0)}}removeElementData(t){let e=t.childNodes;if(e){let a=e.length-1;for(var r=a;r>=0;r--){var s=e[r];s&&this.removeElementData(s)}}Mt.remove(t),t.bindId&&d.unbind(t)}removeElement(t){let e;return!t||!(e=t.parentNode)?this:(this.removeElementData(t),e.removeChild(t),this)}removeChild(t){this.removeElement(t)}removeAll(t){if(typeof t=="object"){let r=t.childNodes;for(var e in r)r.hasOwnProperty(e)&&this.removeElementData(r[e]);t.innerHTML=""}}changeParent(t,e){e.appendChild(t)}append(t,e){switch(typeof t){case"object":break;case"undefined":t=document.body;break}t.appendChild(e)}prepend(t,e,r){switch(typeof t){case"object":break;case"undefined":t=document.body;break}var s=r||t.firstChild;t.insertBefore(e,s)}clone(t,e){return!t||typeof t!="object"?!1:(e=e||!1,t.cloneNode(e))}};var kt=/(\[\[(.*?)\]\])/g,ft={_getWatcherProps(i){let t=/\[\[(.*?)\]\]/g,e=i.match(t);if(e){t=/(\[\[|\]\])/g;for(var r=0,s=e.length;r<s;r++)e[r]=e[r].replace(t,"")}return e},updateAttr(i,t,e){t==="text"||t==="textContent"?i.textContent=e:t==="innerHTML"?i.innerHTML=e:t.substring(4,1)==="-"?h.setAttr(i,t,e):i[t]=e},_getWatcherCallBack(i,t,e,r,s){return()=>{let n=0,a=e.replace(kt,function(){let o=s?t[n]:t;n++;let l=o.get(arguments[2]);return typeof l<"u"?l:""});this.updateAttr(i,r,a)}},getParentData(i){return i.data?i.data:i.context&&i.context.data?i.context.data:i.state?i.state:null},getValue(i,t){typeof i=="string"&&(i={value:i});let e=i.value;return Array.isArray(e)===!1?e=[e,this.getParentData(t)]:e.length<2&&e.push(this.getParentData(t)),e},getPropValues(i,t,e){let r=[];for(var s=0,n=t.length;s<n;s++){var a=e?i[s]:i,o=a.get(t[s]);o=typeof o<"u"?o:"",r.push(o)}return r},getCallBack(i,t,e,r,s){let n,a=i.callBack;if(typeof a=="function"){let o=r.match(kt),l=o&&o.length>1;n=(f,u)=>{f=l!==!0?f:this.getPropValues(e,o,s),a(t,f,u)}}else{let o=i.attr||"textContent";n=this._getWatcherCallBack(t,e,r,o,s)}return n},addDataWatcher(i,t,e){let r=this.getValue(t,e),s=r[1];if(!s)return;let n=r[0],a=Array.isArray(s),o=this.getCallBack(t,i,s,n,a),l=this._getWatcherProps(n);for(var f=0,u=l.length;f<u;f++){var c=a?s[f]:s;this.addWatcher(i,c,l[f],o)}},setup(i,t,e){!t||(Array.isArray(t)&&(t={attr:t[2],value:[t[0],t[1]]}),this.addDataWatcher(i,t,e))},addWatcher(i,t,e,r){d.watch(i,t,e,r)}};var Jt={created:"onCreated",state:"setupStates",events:"setupEevents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"},Ft=i=>typeof i==="function"?i:function(){return i},Vt=i=>{let t={};if(!i)return t;for(var e in i){if(i.hasOwnProperty(e)===!1)continue;let r=i[e],s=Jt[e];if(s){t[s]=Ft(r);continue}t[e]=r}return t},zt=i=>{class t extends w{}return Object.assign(t.prototype,i),t},Ct=i=>{class t extends b{}return Object.assign(t.prototype,i),t},D=function(i){if(!i)return null;let t;switch(typeof i){case"object":return i.render?(t=Vt(i),zt(t)):(t={render:function(){return i}},Ct(t));case"function":return t={render:i},Ct(t)}};var Tt=function(i,t){return function(e){return{onSet:[i,t,(r,s)=>e(s)]}}};h.dataTracker.addType("context",function(i){if(!i)return!1;i.parent.removeContextBranch(i.branch)});var qt=new K,ut=class extends G{create(t,e,r,s){let n=document.createElement(t);return this._addElementAttrs(n,e,s),this.append(r,n),n}_addElementAttrs(t,e,r){if(!e||typeof e!="object")return!1;let s=e.type;typeof s<"u"&&h.setAttr(t,"type",s);for(var n in e)if(!(e.hasOwnProperty(n)===!1||n==="type")){var a=e[n];n==="innerHTML"?t.innerHTML=a:n.indexOf("-")!==-1?h.setAttr(t,n,a):this.addAttr(t,n,a,r)}}addAttr(t,e,r,s){if(r===""||!e)return!1;if(typeof r==="function")e=ht(e),h.addListener(e,t,function(a){r.call(this,a,s)});else{let a=lt(e);t[a]=r}}render(t,e,r){if(!!t)switch(typeof t){case"object":if(t.isUnit===!0)return this.createComponent(t,e,r),t;default:let s=D(t),n=new s;return this.createComponent(n,e,r),n}}build(t,e,r){let s=this.createDocFragment();if(Array.isArray(t)){let o;for(var n=0,a=t.length;n<a;n++)o=t[n],this.buildElement(o,s,r)}else this.buildElement(t,s,r);return e&&typeof e=="object"&&e.appendChild(s),s}buildElement(t,e,r){!t||(t.component||t.isUnit===!0?this.createComponent(t,e,r):this.createElement(t,e,r))}append(t,e){t.appendChild(e)}createElement(t,e,r){let s=qt.parseElement(t),n=this.createNode(s,e,r),a=t.cache;r&&a&&(r[a]=n);let o=s.children;if(o.length>0){let u;for(var l=0,f=o.length;l<f;l++)u=o[l],u!==null&&this.buildElement(u,n,r)}this.addElementDirectives(n,t,r)}addElementDirectives(t,e,r){typeof e.onCreated=="function"&&e.onCreated(t,r);let s=e.bind;if(s&&this.bindElement(t,s,r),e.route&&this.addRoute(t,e.route,r),e.switch&&this.addSwitch(t,e.switch,r),e.html&&this.addHtml(t,e.html),e.useContext&&this.useContext(t,e.useContext,r),e.addContext&&this.addContext(t,e.addContext,r),e.context&&this.context(t,e.context,r),e.role&&this.addRole(t,e.role,r),e.aria&&this.addAria(t,e.aria,r),r){let n=e.onState;n&&n.length&&this.onState(t,n,r);let a=e.onSet;a&&a.length&&this.onSet(t,a,r);let o=e.map;o&&o.length&&this.map(t,o,r);let l=e.for;l&&l.length&&this.for(t,l,r);let f=e.useParent;f&&this.useParent(t,f,r);let u=e.useData;u&&this.useData(t,u,r);let c=e.useState;c&&this.useState(t,c,r);let m=e.addState;m&&this.addState(t,m,r)}e.watch&&this.watch(t,e.watch,r)}_getDataSource(t){return t?t.data?t.data:t.context&&t.context.data?t.context.data:t.state?t.state:!1:!1}bindElement(t,e,r){let s,n,a;if(typeof e=="string"){if(s=this._getDataSource(r),!s)return!1;n=e}else if(Array.isArray(e)){if(typeof e[0]!="object"){let o=this._getDataSource(r);if(o)e.unshift(o);else return!1}[s,n,a]=e}d.bind(t,s,n,a)}addRoute(t,e,r){if(!e)return!1;if(h.isArray(e))for(var s=0,n=e.length;s<n;s++)this.setupRoute(t,e[s],r);else this.setupRoute(t,e,r)}setupRoute(t,e,r){e.container=t,e.parent=r;let s=h.router.add(e);this.trackRoute(t,s)}checkResume(t){return t&&t.component&&t.component.route}resumeRoute(t,e){h.router.resume(e,t),this.trackRoute(t,e)}trackRoute(t,e){h.dataTracker.add(t,"routes",{route:e})}addSwitch(t,e,r){let s=e[0];for(var n=0,a=e.length;n<a;n++)s=e[n],s.container=t,s.parent=r;let o=h.router.addSwitch(e);this.trackSwitch(t,o)}resumeSwitch(t,e){let r=h.router.resumeSwitch(e,t);this.trackSwitch(t,r)}trackSwitch(t,e){h.dataTracker.add(t,"switch",{id:e})}addRole(t,e,r){!e||e&&h.setAttr(t,"role",e)}addAria(t,e,r){if(!e)return;let s=e.role;s&&(h.setAttr(t,"role",s),e.role=null);let n=f=>(u,c)=>{var m=c?"true":"false";h.setAttr(u,f,m)};for(var a in e)if(!(e.hasOwnProperty(a)===!1||e[a]===null)){var o=e[a],l="aria-"+a;Array.isArray(o)?(o.push(n(l)),this.onSet(t,o,r)):h.setAttr(t,l,o)}}getParentContext(t){return t?t.getContext():null}context(t,e,r){if(typeof e!="function")return;let s=this.getParentContext(r),n=e(s);!n||(this._addElementAttrs(t,n,r),this.addElementDirectives(t,n,r))}useContext(t,e,r){if(typeof e!="function")return;let s=this.getParentContext(r);e(s)}addContext(t,e,r){if(typeof e!="function"||!r)return;let s=this.getParentContext(r),n=e(s);!n||r.addContextBranch(n[0],n[1])}trackContext(t,e,r){h.dataTracker.add(t,"context",{branch:e,parent:r})}watch(t,e,r){if(!e)return!1;if(Array.isArray(e)&&typeof e[0]!="string")for(var s=0,n=e.length;s<n;s++)ft.setup(t,e[s],r);else ft.setup(t,e,r)}useParent(t,e,r){if(!e||!r)return!1;e(r,t)}useData(t,e,r){if(!e||!r)return!1;e(r.data,t)}useState(t,e,r){if(!e||!r)return!1;e(r.state,t)}addState(t,e,r){if(!e||!r)return!1;if(r.stateHelper){let s=r.state,n=e(s);r.stateHelper.addStates(n)}}map(t,e,r){let s=e[0];if(!s||s.length<1)return;let n=e[1],a=[];for(var o=0,l=s.length;o<l;o++){var f=s[o];if(!!f){var u=n(f,o);u!==null&&a.push(u)}}return this.build(a,t,r)}for(t,e,r){let s,n,a,o;if(e.length<3){let f=this.getParentSetData(r);if(!f)return;s=f,n=e[0],a=e[1],o=e[2]}else s=e[0],n=e[1],a=e[2],o=e[3];let l=o!==!1;d.watch(t,s,n,f=>{if(this.removeAll(t),!f||f.length<1)return;let u=[];for(var c=0,m=f.length;c<m;c++){var B=l?s.scope(n+"["+c+"]"):null,yt=a(f[c],c,B);yt!==null&&u.push(yt)}return this.build(u,t,r)})}onState(t,e,r){this.onUpdate(t,r.state,e,r)}getParentSetData(t){return t.data?t.data:t.context&&t.context.data?t.context.data:null}onSet(t,e,r){let s=this.getParentSetData(r);this.onUpdate(t,s,e,r)}onUpdate(t,e,r,s){let n,a,o;if(h.isArray(r[0])){for(var l=0,f=r.length;l<f;l++){var u=r[l];!u||this.onUpdate(t,e,u,s)}return}if(r.length<3?[n,a]=r:[e,n,a]=r,!e||!n)return!1;switch(typeof a){case"object":o=c=>{this.addClass(t,a,c)};break;case"function":o=c=>{this.updateElement(t,a,n,c,s)};break}d.watch(t,e,n,o)}updateElement(t,e,r,s,n){let a=e(t,s,n);switch(typeof a){case"object":if(n&&a&&a.isUnit===!0&&n.persist===!0&&n.state){let o=r+":"+s,l=n.state,f=l.get(o);typeof f<"u"&&(a=f),l.set(o,a)}this.rebuild(t,a,n);break;case"string":this.addHtml(t,a);break}}addClass(t,e,r){for(var s in e)!e.hasOwnProperty(s)||!s||(e[s]===r?h.addClass(t,s):h.removeClass(t,s))}rebuild(t,e,r){this.removeAll(t),this.build(e,t,r)}createComponent(t,e,r){let s=t.component||t;s.parent=r,r&&r.persist===!0&&s.persist!==!1&&(s.persist=!0),s.cacheable&&r&&(r[s.cacheable]=s),s.setup(e),t.component&&typeof t.onCreated=="function"&&t.onCreated(s)}createNode(t,e,r){let s=t.tag;if(s==="text"){let n=t.attr,a=n.textContent||n.text;return this.createTextNode(a,e)}else if(s==="comment"){let a=t.attr.text;return this.createCommentNode(a,e)}return this.create(s,t.attr,e,r)}},p=new ut;h.augment({buildLayout(i,t,e){p.build(i,t,e)}});h.dataTracker.addType("components",i=>{if(!i)return;let t=i.component;t&&t.rendered===!0&&t.prepareDestroy()});var Xt=0,b=class{constructor(t){this.isUnit=!0,this.init(),this.setupProps(t),this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Xt++}setupProps(t){if(!t||typeof t!="object")return!1;for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])}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||{},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)}buildLayout(){let t=this.prepareLayout();this.build(t,this.container),h.dataTracker.add(this.panel,"components",{component:this}),this.rendered=!0}build(t,e){return p.build(t,e,this)}prepend(t,e,r){var s=this.build(t,null);p.prepend(e,s,r)}rebuild(t,e){return p.rebuild(e,t,this)}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var s=0,n=t.length;s<n;s++){var a=e(t[s],s);r.push(a)}return r}removeAll(t){return p.removeAll(t)}cache(t,e,r){return!e||typeof e!="object"?!1:(e.isUnit===!0&&(e={component:e}),e.onCreated=s=>{this[t]=s,typeof r=="function"&&r(s)},e)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup(),this.buildLayout(),this.afterSetup()}beforeSetup(){}afterSetup(){}setup(t){this.container=t,this.initialize()}remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;p.removeElement(t)}prepareDestroy(){this.rendered=!1,this.beforeDestroy()}beforeDestroy(){}destroy(){this.remove()}bindElement(t,e,r,s){t&&d.bind(t,e,r,s)}};var Q=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(e<1)return!1;let r;for(var s=0;s<e;s++)r=t[s],this.on(...r)}on(t,e,r,s){h.on(t,e,r,s),this.events.push({event:t,obj:e,callBack:r,capture:s})}off(t,e,r,s){h.off(t,e,r,s);let n,a=this.events;for(var o=0,l=a.length;o<l;o++)if(n=a[o],n.event===t&&n.obj===e){a.splice(o,1);break}}set(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],h.on(t.event,t.obj,t.callBack,t.capture)}unset(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],h.off(t.event,t.obj,t.callBack,t.capture)}reset(){this.unset(),this.events=[]}};var $=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,s){return{action:t,state:e,callBack:r,targetId:s,token:null}}convertStates(t){let e=[];for(var r in t)if(t.hasOwnProperty(r)!==!1){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var s=null,n=null,a=t[r];a&&typeof a=="object"&&(n=a.callBack,s=a.id||a.targetId,a=a.state),e.push(this.createState(r,a,n,s))}return e}setupRemoteStates(t,e){let r;for(var s=0,n=t.length;s<n;s++)if(r=t[s],!!r){for(var a in r)if(!(r.hasOwnProperty(a)===!1||a==="id")){var o=null,l=r[a],f=l!==null?l:void 0;f&&typeof f=="object"&&(o=f.callBack,f=f.state),e.push(this.createState(a,f,o,r.id))}}}removeRemoteStates(){let t=this.remoteStates;t&&this.removeActions(t)}removeActions(t){if(!(t.length<1))for(var e=0,r=t.length;e<r;e++){var s=t[e];g.remove(s.targetId,s.action,s.token)}}restore(t){t.restore();let e=this.remoteStates;if(!!e)for(var r=0,s=e.length;r<s;r++){var n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let s=g.getTarget(r);return t.link(s,e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var s=0,n=e.length;s<n;s++){var a=e[s],o=this.addAction(t,a);a.targetId&&(a.token=o,r.push(a))}r.length<1&&(this.remoteStates=null)}addAction(t,e){let r,s=e.action,n=e.targetId;n&&(r=this.bindRemoteState(t,s,n)),typeof e.state<"u"&&t.addAction(s,e.state);let a=e.callBack;return typeof a=="function"&&t.on(s,a),r}};var w=class extends b{constructor(t){super(t),this.isComponent=!0,this.stateTargetId=null}initialize(){this.setupContext(),this.beforeSetup(),this.addStates(),this.buildLayout(),this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=g.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateHelper.restore(t);return}let e=this.setupStates();h.isEmpty(e)||(this.setupStateTarget(),this.stateHelper=new $(this.state,e))}removeStates(){let t=this.state;if(!t)return!1;this.stateHelper.removeRemoteStates(),t.remove()}setupEventHelper(){this.events||(this.events=new Q)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();if(t.length<1)return!1;this.setupEventHelper(),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 Y=class extends w{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",className:this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),children:this.children,watch:r}}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact!==!1,s=O.data,n=[];return t&&typeof t=="object"&&n.push({attr:"href",value:t}),e&&typeof e=="object"&&n.push({attr:"text",value:e}),n.push({value:["[[path]]",s],callBack:(a,o)=>{let l=a.pathname+a.hash,f=r?o===l:new RegExp("^"+a.pathname+"($|#|/|\\.).*").test(o);this.update(a,f)}}),n}setupStates(){return{selected:!1}}update(t,e){this.state.set("selected",e)}};var At={removeSlashes(i){return typeof i=="string"&&(i.substring(0,1)==="/"&&(i=i.substring(1)),i.substring(-1)==="/"&&(i=i.substring(0,i.length-1))),i}};var Z=class{constructor(t,e){this.route=t,this.template=e.component,this.component=null,this.hasTemplate=!1,this.setup=!1,this.container=e.container,this.persist=e.persist,this.parent=e.parent,this.setupTemplate()}focus(t){this.setup===!1&&this.create(),this.update(t)}setupTemplate(){let t=this.template;if(typeof t=="string"&&(t=this.template=window[t],!t))return;let e=typeof t;if(e==="function")this.component=new this.template({route:this.route,persist:this.persist,parent:this.parent});else if(e==="object"){this.template.isUnit||(this.template=Jot(this.template));let r=this.component=this.template,s=r.persist!==!1;r.route=this.route,r.persist=s,r.parent=this.parent,this.persist=s}this.hasTemplate=!0}create(){if(!this.hasTemplate)return!1;this.setup=!0;let t=this.component;(!this.persist||!t)&&(t=this.component=this.template),p.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return!1;this.setup=!1;let t=this.component;if(!t)return!1;typeof t.destroy=="function"&&t.destroy(),this.persist===!1&&(this.component=null)}update(t){let e=this.component;if(!e)return!1;typeof e.update=="function"&&e.update(t)}};var dt=[],Kt=i=>dt.indexOf(i)!==-1,Gt=i=>({tag:"script",src:i.src,async:!1,load(t){dt.push(i.src);let e=i.load;e&&e()}}),Qt=i=>({tag:"link",rel:"stylesheet",type:"text/css",href:i.src,load(t){dt.push(i.src);let e=i.load;e&&e()}}),ct=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,r=this.update.bind(this);t.indexOf(".css")!==-1?e=Qt({load:r,src:t}):e=Gt({load:r,src:t}),p.build(e,document.head)}addFiles(t){if(!!t)for(var e=0,r=t.length;e<r;e++){var s=t[e];Kt(s)||this.add(s)}}update(){if(this.updateProgress()>=100){var e=this.callBack;e&&e()}}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}},$t=(i,t)=>{import(i).then(e=>{t&&t(e)})},Yt=i=>i?typeof i?.prototype?.constructor=="function":!1,Zt=(i,t,e)=>{let r=p.build(i,null,e),s=r.firstChild;return t.after(r),s},jt=i=>({tag:"comment",text:"import placeholder",onCreated:i.onCreated}),te=D({render(){return jt({onCreated:i=>{if(!!this.src){if(this.depends){new ct(()=>{this.loadAndRender(i)}).addFiles(this.depends);return}this.loadAndRender(i)}}})},getLayout(i){let t=i.default;if(!t)return null;let e=this.callBack;return e?t=e(t):Yt(t)?(t=new t,t.route=this.route,this.persist&&(t.persist=!0)):t=t(),this.layout=t},loadAndRender(i){$t(this.src,t=>{this.loaded=!0;let e=this.layout||this.getLayout(t);this.layoutRoot=Zt(e,i,this.parent)})},shouldUpdate(i){return this.updateLayout===!0?!0:this.updateLayout=i&&i.isUnit&&typeof i.update=="function"},updateModuleLayout(i){let t=this.layout;this.shouldUpdate(t)&&t.update(i)},update(i){this.loaded===!0&&this.updateModuleLayout(i)},beforeDestroy(){!this.layoutRoot||p.removeElement(this.layoutRoot)}}),Et=i=>new te(i);var ee=i=>{let t="";if(i){let e=/\//g;t=i.replace(e,"/");let r=/(\/):[^\/(]*?\?/g;t=t.replace(r,o=>{let l=/\//g;return o.replace(l,"(?:$|/)")});let s=/(:[^\/?&($]+)/g,n=/(\?\/+\*?)/g;t=t.replace(n,"?/*"),t=t.replace(s,o=>o.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)");let a=/(\*)/g;t=t.replace(a,".*")}return t+=i[i.length-1]==="*"?"":"$",t},re=i=>{if(i.length){let r={};for(var t=0,e=i.length;t<e;t++)r[i[t]]=null;return r}return null},se=i=>{let t=[];if(!i)return t;let e=/[\*?]/g;i=i.replace(e,"");let r=/:(.[^.\/?&($]+)\?*/g,s=i.match(r);if(s===null)return t;for(var n=0,a=s.length;n<a;n++){var o=s[n];o&&(o=o.replace(":",""),t.push(o))}return t},ie=0,j=class extends x{constructor(t){let e=t.baseUri,r=se(e),s=re(r);super(s),this.uri=e,this.paramKeys=r,this.setupRoute(t),this.set("active",!1)}setupRoute(t){this.id=t.id||"bs-rte-"+ie++,this.path=null,this.referralPath=null;let e=ee(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title}setTitle(t){base.router.updateTitle({title:t,stage:this.stage})}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?(typeof e=="string"&&(e={src:e}),Et(e)):null}setupComponentHelper(t){let e=this.getLayout(t);if(e){let{container:r,persist:s=!1,parent:n}=t,a={component:e,container:r,persist:s,parent:n};this.controller=new Z(this,a)}}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let s=this.path;if(!s)return;let n=s.split("#")[1];!n||this.scrollToId(n)}scrollToId(t){if(!t)return;let e=document.getElementById(t);!e||e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(r&&typeof r=="object"&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(t&&typeof t=="object"){let n=this.paramKeys;if(n){let a={};for(var e=0,r=n.length;e<r;e++){var s=n[e];typeof s<"u"&&(a[s]=t[e])}this.set(a)}}}getParams(){return this.stage}};var _=class{static browserIsSupported(){return"history"in window&&"pushState"in window.history}static setup(t){return _.browserIsSupported()?new pt(t).setup():new mt(t).setup()}},ne=0,tt=class{constructor(t){this.router=t,this.locationId="base-app-router-"+ne++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}},pt=class extends tt{addEvent(){return h.on("popstate",window,this.callBack),this}removeEvent(){return h.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri)}createState(t,e){let r={location:this.locationId,uri:t};return e&&typeof e=="object"&&(r=Object.assign(r,e)),r}addState(t,e,r){let s=window.history,n=s.state;if(n&&n.uri===t)return this;let a=this.createState(t,e);return r=r===!0,s[r===!1?"pushState":"replaceState"](a,null,t),this}},mt=class extends tt{addEvent(){return h.on("hashchange",window,this.callBack),this}removeEvent(){return h.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};h.dataTracker.addType("routes",i=>{if(!i)return!1;let t=i.route;t&&O.removeRoute(t)});h.dataTracker.addType("switch",i=>{if(!i)return!1;let t=i.id;O.removeSwitch(t)});var gt=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.history=null,this.callBackLink=null,this.location=window.location,this.routes=[],this.switches={},this.switchCount=0,this.data=new v({path:""})}setupHistory(){this.history=_.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new j(t)}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+At.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var n=e[s];if(n.uri===t)return n}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var n=e[s];if(n.id===t)return n}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);for(var s=0,n=t.length;s<n;s++){var a=this.createRoute(t[s]);r.push(a)}return this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,s=this.getSwitchGroup(r);for(var n=0,a=t.length;n<a;n++){var o=t[n].component.route;o.resume(e),s.push(o)}return this.checkGroup(s,this.getPath()),r}getSwitchGroup(t){return this.switches[t]=[]}removeSwitch(t){let e=this.switches;e[t]&&delete e[t]}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e!==!1&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.set("path",this.getPath()),this.callBackLink=this.checkLink.bind(this),h.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){let e=t.parentNode;for(;e!==null;){if(e.nodeName.toLowerCase()==="a")return e;e=e.parentNode}return!1}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target||t.srcElement;if(e.nodeName.toLowerCase()!=="a"&&(e=this.getParentLink(e),e===!1)||e.target==="_blank"||h.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let s=this.baseURI,n=s!=="/"?r.replace(s,""):r;return this.navigate(n),t.preventDefault(),t.stopPropagation(),!1}}reset(){return this.routes=[],this.switches=[],this.switchCount=0,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.set("path",t)}updateTitle(t){if(!t||!t.title)return this;let e=s=>{let n=o=>{let l=/\w\S*/;return o.replace(l,f=>f.charAt(0).toUpperCase()+f.substring(1).toLowerCase())},a=o=>{if(o.indexOf(":")>-1){let c=t.stage;for(var l in c)if(c.hasOwnProperty(l)){var f=c[l],u=new RegExp(":"+l,"gi");o=o.replace(u,f)}}return o};return s&&(typeof s=="function"&&(s=s(t.stage)),s=a(s),s=n(s),this.title!==""&&(s+=" - "+this.title)),s},r=t.title;document.title=e(r)}checkActiveRoutes(t){this.lastPath=t,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,s;for(var n=0;n<r;n++)s=e[n],!(typeof s>"u")&&this.checkRoute(s,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(var r in e)if(e.hasOwnProperty(r)!==!1){var s=e[r];this.checkGroup(s,t)}}checkGroup(t,e){let r=!1,s,n,a,o,l=!1;for(var f=0,u=t.length;f<u;f++)if(s=t[f],!(typeof s>"u")){if(f===0&&(n=s),!a&&s.get("active")&&(a=s),r!==!1){l&&s.deactivate();continue}r=s.match(e),r!==!1&&(o=s,s.controller&&(this.select(s),l=!0))}o===void 0?(this.select(n),a&&n!==a&&a.deactivate()):a?l&&o!==a&&a.deactivate():n&&l===!1&&this.select(n)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?this.select(t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){if(!t)return!1;t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t)}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){h.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},O=new gt;var Pt=function(){};Pt.extend=function i(t){let e=this;if(typeof t=="object"){let s=t;t=n=>R.cloneObject(s)}let r=(s={})=>{s=s||{};let n=t(s),a=e(s);return typeof a=="object"&&(n=R.extendObject(a,n)),n};return r.extend=i,r};h.augment({ajax:N,dataBinder:d,Data:v,SimpleData:x,Model:P,state:g,builder:p,router:O,Component:w});export{Pt as Atom,w as Component,v as Data,D as Jot,P as Model,Y as NavLink,x as SimpleData,b as Unit,Tt as Watch,N as ajax,h as base,p as builder,d as dataBinder,O as router,g as state};
|
|
2
2
|
//# sourceMappingURL=base.js.map
|