@base-framework/atoms 1.0.0

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/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # Base Atoms
2
+
3
+ **Version**: 1.0.0
4
+
5
+ ## Overview
6
+ This documentation aims to guide the enhancement of component scalability and reusability within your projects through the use of atoms. Atoms are designed to function as the fundamental building blocks in a component-based architecture.
7
+
8
+ This module will add default atoms to your project.
9
+
10
+ ## Atom Scope
11
+ Within our component model, each component autonomously generates its own scope. When components are nested, unique scopes are established at each level. Atoms inherit the scope of their parent component, gaining access to the component's state and data, and enabling directive manipulation and event handling.
12
+
13
+ ### Global Reusability
14
+ Atoms are globally defined and reusable entities, mirroring the nested capabilities characteristic of other layout constructs.
15
+
16
+ ## Atom Types
17
+ Atoms can be instantiated using various methodologies:
18
+
19
+ ### Function Atoms
20
+ These atoms are instantiated with either standard functions or arrow functions, equipped with a props object to transfer properties to the atoms.
21
+
22
+ ```typescript
23
+ const Div = (props, children) => ({
24
+ ...props,
25
+ children
26
+ });
27
+ ```
28
+
29
+ ### Atom Callbacks
30
+ Atoms may be created using the Atom function, which accepts a callback function as its sole parameter. The callback function is passed a props object and children array and returns an object containing the atom's layout.
31
+
32
+ ```typescript
33
+ const Button = Atom((props, children) => ({
34
+ tag: 'button',
35
+ ...props,
36
+ children
37
+ }));
38
+ ```
39
+
40
+ #### Atom Nesting
41
+ Atoms should use composition to nest other atoms. This is achieved by passing the children array to the atoms args.
42
+
43
+ ```typescript
44
+ const SecondaryButton = Atom((props, children) => (Button({
45
+ ...props,
46
+ class: 'secondary-btn',
47
+ children
48
+ }));
49
+ ```
50
+
51
+ ## Adding Event Listeners
52
+ Event listener callbacks within atoms accept two parameters: the originating event object and the "parent" component object in which the atom resides.
53
+
54
+ ### Accessing the Parent Component in an Atom
55
+ ```typescript
56
+ class Page extends Component
57
+ {
58
+ render()
59
+ {
60
+ return Div([
61
+ SecondaryButton({
62
+ /**
63
+ * This will add a click event listener to the button.
64
+ *
65
+ * @param {Event} event The event object
66
+ * @param {Component} parent The parent component object
67
+ * @returns {void}
68
+ */
69
+ click(event, parent) =>
70
+ {
71
+ // Code to access the parent component
72
+ }
73
+ })
74
+ ]);
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Utilization of Atoms
80
+ To leverage an atom, invoke its function and pass the requisite values via a props and children. The Atoms created with the Atom callback functions support passing optional props or children to the atom. The props object should always be first but if the atom does not require props, the children array or string can be passed as the first argument.
81
+
82
+ ```javascript
83
+ // props only
84
+ Div({class: 'text'});
85
+
86
+ // text child only
87
+ Div('test');
88
+
89
+ // array child only
90
+ Div([
91
+ Div('test')
92
+ ]);
93
+
94
+ // props and text child
95
+ Div({class: 'text'}, 'test');
96
+
97
+ // props and array children
98
+ Div({class: 'text'}, [
99
+ Div('test'),
100
+ Div('test')
101
+ ]);
102
+ ```
103
+
104
+ ### Example of Atom Utilization
105
+ ```typescript
106
+ SecondaryButton({
107
+ click(e) =>
108
+ {
109
+ // Handle the click event
110
+ }
111
+ })
112
+ ```
113
+
114
+ The implementation of atoms is aimed at enhancing the readability and modularity of extensive layouts.
115
+
116
+ ### Illustrative Example of a Complex Layout
117
+ ```typescript
118
+ Section([
119
+ Article({ class: 'post' }, [
120
+ Header([
121
+ H1('Title')
122
+ ])
123
+ ])
124
+ ])
125
+ ```
126
+
127
+ ## Contributing
128
+
129
+ Contributions to Base Framework are welcome. Follow these steps to contribute:
130
+
131
+ - Fork the repository.
132
+ - Create a new branch for your feature or bug fix.
133
+ - Commit your changes with clear, descriptive messages.
134
+ - Push your branch and submit a pull request.
135
+ - Before contributing, read our CONTRIBUTING.md for coding standards and community guidelines.
136
+
137
+ ## License
138
+
139
+ Base Atoms are licensed under the MIT License. See the LICENSE file for details.
package/dist/atoms.js ADDED
@@ -0,0 +1,2 @@
1
+ var wt=Object.defineProperty,St=(t,e,r)=>e in t?wt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,E=(t,e,r)=>(St(t,typeof e!="symbol"?e+"":e,r),r),B=class{static toArray(t){return Array.prototype.slice.call(t)}static inArray(t,e,r){return!t||typeof t!="object"?-1:t.indexOf(e,r)}},p=class{static getType(t){let e=typeof t;return e!=="object"?e:this.isArray(t)?"array":e}static isUndefined(t){return typeof t>"u"}static isObject(t){return t&&typeof t=="object"&&this.isArray(t)===!1}static isString(t){return typeof t=="string"}static isArray(t){return Array.isArray(t)}},v={create(t){return Object.create(t)},extendObject(t,e){if(typeof t>"u"||typeof e>"u")return!1;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&typeof e[r]>"u"&&(e[r]=t[r]);return e},clone(t){return t?JSON.parse(JSON.stringify(t)):{}},getClassObject(t){return typeof t=="function"?t.prototype:t},extendClass(t,e){let r=this.getClassObject(t),s=this.getClassObject(e);if(typeof r!="object"||typeof s!="object")return!1;let i=Object.create(r);for(var a in s)i[a]=s[a];return i},isEmpty(t){if(p.isObject(t)===!1)return!0;for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}},L={types:{},add(t,e){this.types[t]=e},get(t){return this.types[t]||!1},remove(t){delete this.types[t]}},jt=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)return;let r=e[t];if(!r.length)return;let s,i=L.get(t);for(var a=0,n=r.length;a<n;a++)s=r[a],s&&(r[a]=null,this.removeByCallBack(i,s));delete e[r]}remove(t){if(t)this.removeType(t);else{let r=this.types;for(var e in r)if(Object.prototype.hasOwnProperty.call(r,e)){if(t=r[e],!t)continue;this.removeType(e)}delete this.types}}},g=class{static addType(t,e){L.add(t,e)}static removeType(t){L.remove(t)}static getTrackingId(t){return t.trackingId||(t.trackingId="dt"+this.trackingCount++)}static add(t,e,r){let s=this.getTrackingId(t);this.find(s).add(e,r)}static get(t,e){let r=t.trackingId,s=this.trackers[r];return s?e?s.get(e):s:!1}static find(t){let e=this.trackers;return e[t]||(e[t]=new jt)}static isEmpty(t){if(!t||typeof t!="object")return!0;for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}static 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])}};E(g,"trackers",{}),E(g,"trackingCount",0);var _=t=>{let e=0;for(var r in t)!Object.prototype.hasOwnProperty.call(t,r)||(e++,typeof t[r]=="object"&&(e+=_(t[r])));return e},et=(t,e)=>{let r=!1;if(typeof t!="object"||typeof e!="object")return r;for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.prototype.hasOwnProperty.call(e,s))break;let i=t[s],a=e[s];if(typeof i!=typeof a)break;if(typeof i=="object"){if(r=et(i,a),r!==!0)break}else if(i===a)r=!0;else break}return r},At=(t,e)=>{let r=_(t),s=_(e);return r!==s?!1:et(t,e)},Ot=(t,e)=>{let r=typeof t;return r!==typeof e?!1:r==="object"?At(t,e):t===e},d={getEvents(t){return p.isObject(t)===!1?!1:g.get(t,"events")},create(t,e,r,s=!1,i=!1,a=null){return i=i===!0,{event:t,obj:e,fn:r,capture:s,swapped:i,originalFn:a}},on(t,e,r,s){if(Array.isArray(t)){let n;for(var i=0,a=t.length;i<a;i++)n=t[i],this.add(n,e,r,s)}else this.add(t,e,r,s);return this},off(t,e,r,s){if(Array.isArray(t))for(var i,a=0,n=t.length;a<n;a++)i=t[a],this.remove(i,e,r,s);else this.remove(t,e,r,s);return this},add(t,e,r,s=!1,i=!1,a=null){if(p.isObject(e)===!1)return this;let n=this.create(t,e,r,s,i,a);return g.add(e,"events",n),e.addEventListener(t,r,s),this},remove(t,e,r,s=!1){let i=this.getEvent(t,e,r,s);return i===!1?this:(typeof i=="object"&&this.removeEvent(i),this)},removeEvent(t){return typeof t=="object"&&t.obj.removeEventListener(t.event,t.fn,t.capture),this},getEvent(t,e,r,s){if(typeof e!="object")return!1;let i=this.getEvents(e);if(!i||i.length<1)return!1;let a=this.create(t,e,r,s);return this.search(a,i)},search(t,e){let r,s=this.isSwappable(t.event);for(var i=0,a=e.length;i<a;i++)if(r=e[i],!(r.event!==t.event||r.obj!==t.obj)&&(r.fn===t.fn||s===!0&&r.originalFn===t.fn))return r;return!1},removeEvents(t){return p.isObject(t)===!1?this:(g.remove(t,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(t){this.swap.push(t)},isSwappable(t){return B.inArray(this.swap,t)>-1}};g.addType("events",t=>{d.removeEvent(t)});var Ct={events:d,addListener(t,e,r,s){return this.events.add(t,e,r,s),this},on(t,e,r,s){let i=this.events;if(Array.isArray(t)){let o;for(var a=0,n=t.length;a<n;a++)o=t[a],i.add(o,e,r,s)}else i.add(t,e,r,s);return this},off(t,e,r,s){let i=this.events;if(Array.isArray(t))for(var a,n=0,o=t.length;n<o;n++)a=t[n],i.remove(a,e,r,s);else i.remove(t,e,r,s);return this},removeListener(t,e,r,s){return this.events.remove(t,e,r,s),this},_createEvent(t,e,r,s){let i;return e==="HTMLEvents"?i=new Event(t):e==="MouseEvents"?i=new MouseEvent(t,r):i=new CustomEvent(t,s),i},createEvent(t,e,r,s){if(p.isObject(e)===!1)return!1;let i={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};p.isObject(r)&&(i=Object.assign(i,r));let a=this._getEventType(t);return this._createEvent(t,a,i,s)},_getEventType(t){let e={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},r,s="CustomEvent";for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&(r=e[i],t.match(r))){s=i;break}return s},trigger(t,e,r){if(p.isObject(e)===!1)return this;let s=typeof t=="string"?this.createEvent(t,e,null,r):t;return e.dispatchEvent(s),this},mouseWheelEventType:null,getWheelEventType(){let t=()=>{let e="wheel";return"onmousewheel"in self?e="mousewheel":"DOMMouseScroll"in self&&(e="DOMMouseScroll"),e};return this.mouseWheelEventType||(this.mouseWheelEventType=t())},onMouseWheel(t,e,r,s){typeof e>"u"&&(e=window);let i=n=>{let o=Math.max(-1,Math.min(1,-n.deltaY||n.wheelDelta||-n.detail));typeof t=="function"&&t(o,n),r===!0&&n.preventDefault()},a=this.getWheelEventType();return this.events.add(a,e,i,s,!0,t),this},offMouseWheel(t,e,r){typeof e>"u"&&(e=window);let s=this.getWheelEventType();return this.off(s,e,t,r),this},preventDefault(t){return typeof t.preventDefault=="function"?t.preventDefault():t.returnValue=!1,this},stopPropagation(t){return typeof t.stopPropagation=="function"?t.stopPropagation():t.cancelBubble=!0,this}},H=class{constructor(){this.version="3.0.5",this.errors=[],this.dataTracker=g}augment(t){if(!t||typeof t!="object")return this;let e=this.constructor.prototype;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return this}override(t,e,r,s){return(t[e]=r).apply(t,B.toArray(s))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,r){if(p.isObject(t)===!1)return"";let s=t[e];return typeof s<"u"?s:typeof r<"u"?r:""}createCallBack(t,e,r,s){return typeof e!="function"?!1:(r=r||[],function(...i){return s===!0&&(r=r.concat(i)),e.apply(t,r)})}bind(t,e){return e.bind(t)}};H.prototype.extend=function(){return H.prototype}();var j=new H;j.augment({...v,...Ct,...p,equals:Ot});var x=class{static parseQueryString(t,e){typeof t!="string"&&(t=window.location.search);let r={},s=/([^?=&]+)(=([^&]*))?/g;return t.replace(s,function(i,a,n,o){r[a]=e!==!1?decodeURIComponent(o):o}),r}static camelCase(t){if(typeof t!="string")return!1;let e=/(-|\s|_)+\w{1}/g;return t.replace(e,r=>r[1].toUpperCase())}static uncamelCase(t,e){if(typeof t!="string")return!1;e=e||"-";let r=/([A-Z]{1,})/g;return t.replace(r,s=>e+s.toLowerCase()).toLowerCase()}},$={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};j.augment({xhrSettings:$,addFixedParams(t){this.xhrSettings.fixedParams=t},beforeSend(t){this.xhrSettings.beforeSend.push(t)},ajaxSettings(t){typeof t=="object"&&(this.xhrSettings=v.extendClass(j.xhrSettings,t))},resetAjaxSettings(){this.xhrSettings=$}});var rt=(...t)=>new Tt(t).xhr,Tt=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:i}=this.settings;e.open(r,s,i),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=j.xhrSettings.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var s=0,i=t.length;s<i;s++){var a=t[s];a&&a(e,r)}}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}setupParams(t,e){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let s=typeof e;if(r==="string")return s!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(s==="string"&&(e=x.parseQueryString(e,!1)),t instanceof FormData)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.append(i,e[i]);else r==="object"&&(t=v.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,r=t.params;return r?r=this.setupParams(r,e):e&&(r=this.setupParams(e)),r}getXhrSettings(t){let e=this.settings=Object.create(j.xhrSettings);if(t.length>=2&&typeof t[0]!="object")for(var r=0,s=t.length;r<s;r++){var i=t[r];switch(r){case 0:e.url=i;break;case 1:e.params=i;break;case 2:e.completed=i,e.failed=i;break;case 3:e.responseType=i||"json";break;case 4:e.method=i?i.toUpperCase():"POST";break;case 5:e.async=typeof i<"u"?i:!0;break}}else e=this.settings=v.extendClass(this.settings,t[0]),typeof e.completed=="function"&&(typeof e.failed!="function"&&(e.failed=e.completed),typeof e.aborted!="function"&&(e.aborted=e.failed))}createXHR(){let t=this.settings,e=new XMLHttpRequest;return e.responseType=t.responseType,t.withCredentials===!0&&(e.withCredentials=!0),e}setupHeaders(){let t=this.settings;if(!t&&typeof t.headers!="object")return;let e=t.headers;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.xhr.setRequestHeader(r,e[r])}update(t,e){let r=this.xhr,s=()=>{d.removeEvents(r.upload),d.removeEvents(r)},i=this.settings;if(!i)return!1;switch(e||t.type){case"load":if(typeof i.completed=="function"){let a=this.getResponseData();i.completed(a,this.xhr)}s();break;case"error":typeof i.failed=="function"&&i.failed(!1,this.xhr),s();break;case"progress":typeof i.progress=="function"&&i.progress(t);break;case"abort":typeof i.aborted=="function"&&i.aborted(!1,this.xhr),s();break}}getResponseData(){let t=this.xhr,e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let t=this.xhr,e=this.update.bind(this);d.on(["load","error","abort"],t,e),d.on("progress",t.upload,e)}},y=class{static getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}static getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?B.toArray(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:B.toArray(r):!1}static html(t,e){return p.isObject(t)===!1?!1:p.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,r){return p.isObject(t)===!1||p.isUndefined(e)?this:(e=x.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=x.uncamelCase(e);let r=t.style[e];if(r!=="")return r;let s=null,i=t.currentStyle;if(i&&(s=i[e]))r=s;else{let a=window.getComputedStyle(t,null);a&&(r=a[e])}return r}static css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}static removeAttr(t,e){return p.isObject(t)&&t.removeAttribute(e),this}static setAttr(t,e,r){t.setAttribute(e,r)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,r){return p.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=x.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}static removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}static setData(t,e,r){e=this.removeDataPrefix(e),e=x.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=x.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,r){return p.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?!1:t.querySelectorAll(e)}static show(t){if(p.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}static hide(t){if(p.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}static toggle(t){return p.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return p.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return p.isObject(t)?t.offsetWidth:!1}static getHeight(t){return p.isObject(t)?t.offsetHeight:!1}static getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,r=t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return p.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}static getScrollTop(t){return this.getScrollPosition(t).top}static getScrollLeft(t){return this.getScrollPosition(t).left}static getWindowSize(){let t=window,e=document,r=e.documentElement,s=e.getElementsByTagName("body")[0],i=t.innerWidth||r.clientWidth||s.clientWidth,a=t.innerHeight||r.clientHeight||s.clientHeight;return{width:i,height:a}}static 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}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let r={x:0,y:0};if(p.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}static addClass(t,e){if(p.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let i=e.split(" ");for(var r=0,s=i.length;r<s;r++)t.classList.add(e)}return this}static removeClass(t,e){return p.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return p.isObject(t)===!1||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return p.isObject(t)===!1?this:(t.classList.toggle(e),this)}},Dt=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]),v.isEmpty(r)&&delete this.connections[t];else{for(var i in r)!Object.prototype.hasOwnProperty.call(r,i)||(s=r[i],s&&s.unsubscribe());delete this.connections[t]}}},st=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}},Pt=class extends st{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)}},it=class{unsubscribe(){}},Et=class extends it{constructor(){super(),this.source=null}addSource(t){return this.source=new Pt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}},at=class extends st{constructor(t){super(),this.pubSub=t}subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=this.pubSub.on(t,e)}unsubscribe(){this.pubSub.off(this.msg,this.token)}callBack(){}},Bt=class extends at{constructor(t,e,r){super(r),this.data=t,this.prop=e}set(t){this.data.set(this.prop,t)}get(){return this.data.get(this.prop)}callBack(t,e){this.data!==e&&this.data.set(this.prop,t,e)}},Mt=(t,e,r)=>{y.setAttr(t,e,r)},Lt=(t,e,r)=>{t.checked=t.value==r},_t=(t,e,r)=>{r=r==1,nt(t,e,r)},nt=(t,e,r)=>{t[e]=r},Ht=(t,e)=>y.getAttr(t,e),Nt=(t,e)=>t[e],Rt=class extends at{constructor(t,e,r,s){super(s),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=Mt,this.getValue=Ht;return}this.getValue=Nt;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=_t;return;case"radio":this.setValue=Lt;return}this.setValue=nt}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 i=r.type;if(!i)return e="value",e;switch(i){case"checkbox":e="checked";break;case"file":e="files";break;default:e="value"}}return e}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;!e||typeof e!="object"||(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)}},It=class extends it{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new Rt(t,e,r,this.pubSub)}addData(t,e){return this.data=new Bt(t,e,this.pubSub)}unsubscribeSource(t){t&&t.unsubscribe()}unsubscribe(){this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null}},z=-1,ot=class{constructor(){this.callBacks={},this.lastToken=-1}get(t){let e=this.callBacks;return e[t]||(e[t]=[])}reset(){this.callBacks={},this.lastToken=-1,z=-1}on(t,e){let r=++z;return this.get(t).push({token:r,callBack:e}),r}off(t,e){let r=this.callBacks[t];if(!r)return;let s=r.length;for(var i=0;i<s;i++){var a=r[i];if(a.token===e){r.splice(i,1);break}}}remove(t){let e=this.callBacks;e[t]&&delete e[t]}publish(t){let e=this.callBacks[t]||!1;if(e===!1)return;let r=Array.prototype.slice.call(arguments,1),s=e.length;for(var i=0;i<s;i++){var a=e[i];!a||a.callBack.apply(this,r)}}},Ut=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new Dt,this.pubSub=new ot,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,s){let i=r,a=null;if(r.indexOf(":")!==-1){let u=r.split(":");u.length>1&&(i=u[1],a=u[0])}let n=this.setupConnection(t,e,i,a,s),o=n.element,c=e.get(i);return typeof c<"u"?o.set(c):(c=o.get(),c!==""&&n.data.set(c)),this}setupConnection(t,e,r,s,i){let a=this.getBindId(t),n=new It(this.pubSub);n.addData(e,r).subscribe(a);let o=e.getDataId(),c=o+":"+r;return n.addElement(t,s,i).subscribe(c),this.addConnection(a,"bind",n),n}addConnection(t,e,r){this.connections.add(t,e,r)}setBindId(t){let e="db-"+this.idCount++;return t.dataset&&(t.dataset[this.attr]=e),t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,s){if(p.isObject(t)===!1)return;let i=new Et;i.addSource(e).subscribe(r,s);let a=this.getBindId(t),n=e.getDataId()+":"+r;this.addConnection(a,n,i);let o=e.get(r);typeof o<"u"&&s(o)}unwatch(t,e,r){if(p.isObject(t)===!1)return;let s=t[this.attr];if(s){let i=e.getDataId()+":"+r;this.connections.remove(s,i)}}publish(t,e,r){return this.pubSub.publish(t,e,r),this}isDataBound(t){return t&&t[this.attr]||!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 i=s.element.get();this.pubSub.publish(r,i,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){d.on(["change","paste","input"],document,this.changeHandler,!1)}removeEvents(){d.off(["change","paste","input"],document,this.changeHandler,!1)}},k=new Ut,K=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,T={isWatching(t){return Array.isArray(t)?typeof t[0]!="string"?!1:!!this.hasParams(t[0]):this.hasParams(t)},hasParams(t){return!t||p.isString(t)===!1?!1:t.indexOf("[[")!==-1},_getWatcherProps(t){let e=/\[\[(.*?)(\[\d+\])?\]\]/g,r=t.match(e);if(r){e=/(\[\[|\]\])/g;for(var s=0,i=r.length;s<i;s++)r[s]=r[s].replace(e,"")}return r},updateAttr(t,e,r){e==="text"||e==="textContent"?t.textContent=r:e==="innerHTML"?t.innerHTML=r:e.substring(4,1)==="-"?y.setAttr(t,e,r):t[e]=r},_getWatcherCallBack(t,e,r,s,i){return()=>{let a=0,n=r.replace(K,function(){let o=i?e[a]:e;a++;let c=o.get(arguments[2]);return typeof c<"u"?c:""});this.updateAttr(t,s,n)}},getParentData(t){return t.data?t.data:t.context&&t.context.data?t.context.data:t.state?t.state:null},getValue(t,e){typeof t=="string"&&(t={value:t});let r=t.value;return Array.isArray(r)===!1?[r,this.getParentData(e)]:(r.length<2&&r.push(this.getParentData(e)),r)},getPropValues(t,e,r){let s=[];for(var i=0,a=e.length;i<a;i++){var n=r?t[i]:t,o=n.get(e[i]);o=typeof o<"u"?o:"",s.push(o)}return s},getCallBack(t,e,r,s,i){let a,n=t.callBack;if(typeof n=="function"){let o=s.match(K),c=o&&o.length>1;a=(u,f)=>{u=c!==!0?u:this.getPropValues(r,o,i),n(u,e,f)}}else{let o=t.attr||"textContent";a=this._getWatcherCallBack(e,r,s,o,i)}return a},addDataWatcher(t,e,r){let s=this.getValue(e,r),i=s[1];if(!i)return;let a=s[0],n=Array.isArray(i),o=this.getCallBack(e,t,i,a,n),c=this._getWatcherProps(a);for(var u=0,f=c.length;u<f;u++){var b=n?i[u]:i;this.addWatcher(t,b,c[u],o)}},setup(t,e,r){if(e){if(Array.isArray(e)){let s=[e[0],e[1]],i=e[2];typeof i=="function"?e={value:s,callBack:i}:e={attr:i,value:[e[0],e[1]]}}this.addDataWatcher(t,e,r)}},addWatcher(t,e,r,s){k.watch(t,e,r,s)}},Wt=t=>typeof t!="string"?t:lt(t),lt=t=>[{tag:"text",textContent:t}],Ft=t=>{if(!t)return{props:{},children:[]};let e=t[0];return typeof e=="string"?{props:{},children:lt(e)}:Array.isArray(e)?T.isWatching(e)===!1?{props:{},children:e}:{props:{watch:e},children:[]}:{props:e||{},children:Wt(t[1])}},l=t=>(...e)=>{let{props:r,children:s}=Ft(e);return t(r,s)},ht=t=>{let e={};if(!t||typeof t!="object")return e;t=v.clone(t);for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var s=t[r];typeof s!="function"&&(e[r]=s,delete t[r])}return e};function X(t,e){return t===""?(t=e,isNaN(t)?t:`[${e}]`):isNaN(e)?`${t}.${e}`:`${t}[${e}]`}function ct(t,e="",r=""){return{get(s,i,a){if(e===""&&i in s)return s[i];let n=s[r]||s,o=Reflect.get(n,i,a);if(!p.isObject(o))return o;let c=X(e,i);return new Proxy(o,ct(t,c,r))},set(s,i,a,n){if(e===""&&i in s)return s[i]=a,!0;let o=s[r]||s,c=X(e,i);return t.set(c,a),Reflect.set(o,i,a,n)}}}var qt=(t,e="stage")=>new Proxy(t,ct(t,"",e)),Vt=0,R=class{constructor(t){this.dirty=!1,this.links={},this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new ot;let e=ht(t);return this.set(e),qt(this)}setup(){this.stage={}}_init(){let t=++Vt;this._dataNumber=t,this._id="dt-"+t,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=this){let s=this.stage[t];if(e===s)return!1;this.stage[t]=e,this._publish(t,e,r,s)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,s]=t;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=e[i];typeof a!="function"&&this._setAttr(i,a,r,s)}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}concat(t,e){if(typeof t>"u")return;let r=this.get(t);return this.set(t,r+e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){return this.key=t,this}resume(t){let e=this.key;if(!e)return this;let r,s=localStorage.getItem(e);return s===null?t&&(r=t):r=JSON.parse(s),r?(this.set(r),this):this}store(){let t=this.key;if(!t)return!1;let e=this.get();if(!e)return!1;let r=JSON.stringify(e);return localStorage.setItem(t,r),!0}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 i in e)!Object.prototype.hasOwnProperty.call(e,i)||s.push(this.remoteLink(t,i));return s}remoteLink(t,e,r){let s=r||e,i=t.get(e);typeof i<"u"&&this.get(e)!==i&&this.set(e,i);let a=t.on(e,(o,c)=>{if(c===this)return!1;this.set(s,o,t)});this.addLink(a,t);let n=this.on(s,(o,c)=>{if(c===t)return!1;t.set(e,o,this)});return t.addLink(n,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]}};R.prototype.isData=!0;var m={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(t){return t.indexOf(".")!==-1||t.indexOf("[")!==-1},getSegments(t){let e=this.deepDataPattern;return t.match(e)}},I=class extends R{setup(){this.attributes={},this.stage={}}_updateAttr(t,e,r){if(!m.hasDeepData(e)){t[e]=r;return}let s,i=m.getSegments(e),a=i.length,n=a-1;for(var o=0;o<a;o++){if(s=i[o],o===n){t[s]=r;break}t[s]===void 0&&(t[s]=isNaN(s)?{}:[]),t=t[s]}}_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)Object.prototype.hasOwnProperty.call(r,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(!m.hasDeepData(t)){this.publish(t,e,r);return}let s,i=m.getSegments(t),a=i.length,n=a-1,o="",c=this.stage;for(var u=0;u<a;u++){s=i[u],c=c[s],u>0?isNaN(s)&&(o+="."+s):o=s;var f;if(u===n)f=e;else{var b=i[u+1];if(isNaN(b)===!1){o+="["+b+"]";continue}var P={};P[b]=c[b],f=P}this.publish(o,f,r)}}publish(t,e,r){if(t=t||"",this._publishAttr(t,e,r),!e||typeof e!="object")return;let s,i;if(Array.isArray(e)){let o=e.length;for(var a=0;a<o;a++)i=e[a],s=t+"["+a+"]",this._checkPublish(s,i,r)}else for(var n in e)!Object.prototype.hasOwnProperty.call(e,n)||(i=e[n],s=t+"."+n,this._checkPublish(s,i,r))}_checkPublish(t,e,r){!e||typeof e!="object"?this._publishAttr(t,e,r):this.publish(t,e,r)}_publishAttr(t,e,r){k.publish(this._dataId+t,e,r);let s=t+":change";this.eventSub.publish(s,e,r)}mergeStage(){this.attributes=v.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e){m.hasDeepData(e)||delete t[e];let r=m.getSegments(e),s=r.length,i=s-1;for(var a=0;a<s;a++){var n=r[a],o=t[n];if(o===void 0)break;if(a===i){if(Array.isArray(t)){t.splice(n,1);break}delete t[n];break}t=o}}_getAttr(t,e){if(!m.hasDeepData(e))return t[e];let r=m.getSegments(e),s=r.length,i=s-1;for(var a=0;a<s;a++){var n=r[a],o=t[n];if(o===void 0)break;if(t=o,a===i)return t}}},Yt=(t,e)=>{if(typeof t!="string"&&(t=String(t)),e){let s=/(\n|\r\n)/g;t=t.replace(s,"\\n")}let r=/\t/g;return t.replace(r,"\\t")},G=(t,e)=>{if(typeof t!="string")return t;t=Yt(t,e),t=encodeURIComponent(t);let r=/%22/g;return t.replace(r,'"')},ut=(t,e)=>{let r=typeof t;if(r==="undefined")return t;if(r!=="object")return t=G(t),t;let s;for(var i in t)!Object.prototype.hasOwnProperty.call(t,i)||(s=t[i],s!==null&&(t[i]=typeof s=="string"?ut(s,e):G(s,e)));return t};function Jt(t){return typeof t<"u"&&t.length>0?JSON.parse(t):!1}function pt(t){return typeof t<"u"?JSON.stringify(t):!1}var dt=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?v.clone(t):t,s=ut(r,e);return pt(s)}static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};E(dt,"json",{encode:pt,decode:Jt});var $t=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=x.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=x.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),s="op=get&id="+r,i=this.model;return this._get("",s,t,e,a=>{if(a){let n=this.getObject(a);n&&i.set(n)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+dt.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,i){i=i||"",r=isNaN(r)?0:r,s=isNaN(s)?50:s;let a="op=all&option="+i+"&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,i){let a={url:this.getUrl(t),method:e,params:r,completed:(n,o)=>{typeof i=="function"&&i(n),this.getResponse(n,s,o)}};return this._isFormData(r)&&(a.headers={}),rt(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,i){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",s,i)}_post(t,e,r,s,i){return this._request(t,"POST",e,r,s,i)}_put(t,e,r,s,i){return this._request(t,"PUT",e,r,s,i)}_patch(t,e,r,s,i){return this._request(t,"PATCH",e,r,s,i)}_delete(t,e,r,s,i){return this._request(t,"DELETE",e,r,s,i)}_request(t,e,r,s,i,a){return r=this.setupParams(r),r=this.addParams(r,s),this.setupRequest(t,e,r,i,a)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;let e=this;class r extends e{constructor(i){super(i)}}return Object.assign(r.prototype,t),r}},zt=t=>{let e={};if(!t||typeof t!="object")return e;let r=t.defaults;if(!r)return e;for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s)){var i=r[s];typeof i!="function"&&(e[s]=i)}return delete t.defaults,e},Kt=t=>{if(!t||typeof t.xhr!="object")return{};let e=t.xhr,r=Object.assign({},e);return delete t.xhr,r},Xt=0,ft=class extends I{xhr=null;constructor(t){let e=super(t);return this.initialize(),e}initialize(){}static extend(t={}){let e=this,r=Kt(t),s=this.prototype.service.extend(r),i=zt(t);class a extends e{constructor(o){let c=ht(o);c=Object.assign({},i,c),super(c),this.xhr=new s(this)}dataTypeId="bm"+Xt++}return Object.assign(a.prototype,t),a.prototype.service=s,a}};ft.prototype.service=$t;var U=class extends R{_publish(t,e,r,s){let i=t+":change";this.eventSub.publish(i,e,r),r=r||this,k.publish(this._dataId+t,e,r)}},Gt=class extends U{constructor(t){super(),this.id=t}addAction(t,e){typeof e<"u"&&this.set(t,e)}getState(t){return this.get(t)}removeAction(t,e){if(e){this.off(t,e);return}let r=this.stage;typeof r[t]<"u"&&delete r[t]}},S=class{static restore(t,e){this.targets[t]=e}static getTarget(t){let e=this.targets;return e[t]||(e[t]=new Gt(t))}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let s=this.getTarget(t);return e&&s.addAction(e,r),s}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){this.off(t,e,r)}static on(t,e,r){let s=this.getTarget(t);return e?s.on(e,r):!1}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let s=this.targets,i=s[t];if(i){if(e){i.off(e,r);return}delete s[t]}}static set(t,e,r){this.getTarget(t).set(e,r)}};E(S,"targets",{});var Qt=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){d.on(t,e,r,s),this.events.push({event:t,obj:e,callBack:r,capture:s})}off(t,e,r,s){d.off(t,e,r,s);let i,a=this.events;for(var n=0,o=a.length;n<o;n++)if(i=a[n],i.event===t&&i.obj===e){a.splice(n,1);break}}set(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],d.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],d.off(t.event,t.obj,t.callBack,t.capture)}reset(){this.unset(),this.events=[]}},Zt=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(Object.prototype.hasOwnProperty.call(t,r)){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var s=null,i=null,a=t[r];a&&typeof a=="object"&&(i=a.callBack,s=a.id||a.targetId,a=a.state),e.push(this.createState(r,a,i,s))}return e}setupRemoteStates(t,e){let r;for(var s=0,i=t.length;s<i;s++)if(r=t[s],!!r){for(var a in r)if(!(!Object.prototype.hasOwnProperty.call(r,a)||a==="id")){var n=null,o=r[a],c=o!==null?o:void 0;c&&typeof c=="object"&&(n=c.callBack,c=c.state),e.push(this.createState(a,c,n,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];S.remove(s.targetId,s.action,s.token)}}restore(t){S.restore();let e=this.remoteStates;if(e)for(var r=0,s=e.length;r<s;r++){var i=e[r];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,r){let s=S.getTarget(r);return t.link(s,e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var s=0,i=e.length;s<i;s++){var a=e[s],n=this.addAction(t,a);a.targetId&&(a.token=n,r.push(a))}r.length<1&&(this.remoteStates=null)}addAction(t,e){let r,s=e.action,i=e.targetId;i&&(r=this.bindRemoteState(t,s,i)),typeof e.state<"u"&&t.addAction(s,e.state);let a=e.callBack;return typeof a=="function"&&t.on(s,a),r}},te={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"},W=t=>te[t]||t,gt=t=>typeof t=="string"&&t.substring(0,2)==="on"?t.substring(2):t,A=class{static create(t,e,r,s){let i=document.createElement(t);return this.addAttributes(i,e),s===!0?this.prepend(r,i):this.append(r,i),i}static addAttributes(t,e){if(!e||typeof e!="object")return!1;let r=e.type;typeof r<"u"&&y.setAttr(t,"type",r);for(var s in e)if(!(!Object.prototype.hasOwnProperty.call(e,s)||s==="type")){var i=e[s];s==="innerHTML"?t.innerHTML=i:s.indexOf("-")!==-1?y.setAttr(t,s,i):this.addAttr(t,s,i)}}static addHtml(t,e){return typeof e>"u"||e===""?this:(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,r){if(!(r===""||!e))if(typeof r=="function")e=gt(e),d.add(e,t,r);else{let s=W(e);t[s]=r}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}static createComment(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}static setupSelectOptions(t,e,r){if(!t||typeof t!="object"||!e||!e.length)return!1;for(var s=0,i=e.length;s<i;s++){var a=e[s],n=t.options[s]=new Option(a.label,a.value);r!==null&&n.value==r&&(n.selected=!0)}}static removeElementData(t){let e=t.childNodes;if(e){let i=e.length-1;for(var r=i;r>=0;r--){var s=e[r];!s||this.removeElementData(s)}}g.remove(t),t.bindId&&k.unbind(t)}static removeElement(t){let e;return!t||!(e=t.parentNode)?this:(this.removeElementData(t),e.removeChild(t),this)}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(typeof t!="object")return this;let e=t.childNodes;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.removeElementData(e[r]);return t.innerHTML="",this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,r){let s=r||t.firstChild;return t.insertBefore(e,s),this}static clone(t,e=!1){return!t||typeof t!="object"?!1:t.cloneNode(e)}},ee=t=>typeof t!="string"?t:yt(t),yt=t=>[{tag:"text",textContent:t}],re=t=>{if(!t)return{props:{},children:[]};let e=t[0];return typeof e=="string"?{props:{},children:yt(e)}:Array.isArray(e)?{props:{},children:e}:{props:e||{},children:ee(t[1])}};g.addType("components",t=>{if(!t)return;let e=t.component;e&&e.rendered===!0&&e.prepareDestroy()});var se=0,bt=class{constructor(...t){this.isUnit=!0,this.init();let{props:e,children:r}=re(t);this.setupProps(e),this.children??=r,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+se++}setupProps(t){if(!(!t||typeof t!="object"))for(var e in t)Object.prototype.hasOwnProperty.call(t,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)}afterBuild(){g.add(this.panel,"components",{component:this}),this.rendered=!0,this.afterLayout()}afterLayout(){this.afterSetup()}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var s=0,i=t.length;s<i;s++){let a=e(t[s],s);r.push(a)}return r}removeAll(t){return A.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup()}beforeSetup(){}afterSetup(){}setup(t){this.container=t,this.initialize()}remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;A.removeElement(t)}prepareDestroy(){this.rendered=!1,this.beforeDestroy()}beforeDestroy(){}destroy(){this.remove()}},vt=class extends bt{constructor(...t){super(...t),this.isComponent=!0,this.stateTargetId=null}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=S.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateHelper.restore(t);return}let e=this.setupStates();v.isEmpty(e)||(this.setupStateTarget(),this.stateHelper=new Zt(this.state,e))}removeStates(){if(!this.state)return!1;this.stateHelper.removeRemoteStates(),S.remove()}setupEventHelper(){this.events||(this.events=new Qt)}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()}},ie={created:"onCreated",state:"setupStates",events:"setupEevents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"},ae=t=>typeof t=="function"?t:function(){return t},ne=t=>{let e={};if(!t)return e;for(var r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let s=t[r],i=ie[r];if(i){e[i]=ae(s);continue}e[r]=s}return e},oe=t=>{class e extends vt{}return Object.assign(e.prototype,t),e},Q=t=>{class e extends bt{}return Object.assign(e.prototype,t),e},F=function(t){if(!t)return null;let e;switch(typeof t){case"object":return t.render?(e=ne(t),oe(e)):(e={render(){return t}},Q(e));case"function":return e={render:t},Q(e)}};var le=(t,e)=>({name:t,callBack:e}),N={keys:[],items:{},add(t,e){return this.keys.push(t),this.items[t]=le(t,e),this},get(t){return this.items[t]||null},all(){return this.keys}},Z=(t,e)=>({attr:t,directive:e}),O=(t,e)=>({key:t,value:e}),he=(t,e,r,s)=>({tag:t,attr:e,directives:r,children:s}),ce=class{static getTag(t){let e="div",r=t.tag;return typeof r<"u"&&(e=r),e}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,r,s){return t==="text"?(s.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(r.push(O("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){r={attr:W(e),value:r},t.push(Z(O(e,r),N.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let s=e.type||"button";r.push(O("type",s))}}static parse(t,e){let r=[],s=[],i=this.getTag(t);this.setButtonType(i,t,r),this.setupChildren(t);let a=[];var n,o;for(var c in t){if(!Object.prototype.hasOwnProperty.call(t,c)||c==="tag"||(n=t[c],n==null))continue;if((o=N.get(c))!==null){s.push(Z(O(c,n),o));continue}let u=typeof n;if(u==="object"){if(c==="children"){a=a.concat(n);continue}if(T.isWatching(n)){this.setTextAsWatcher(s,c,n);continue}a.push(n);continue}if(u==="function"){let f=n;n=function(b){f.call(this,b,e)}}if(T.isWatching(n)){this.setTextAsWatcher(s,c,n);continue}this.setElementContent(c,n,r,a)||r.push(O(c,n))}return he(i,r,s,a)}},C=class extends A{static create(t,e,r,s){let i=document.createElement(t);return this.addAttributes(i,e,s),r.appendChild(i),i}static addAttributes(t,e,r){let s;if(!(!e||(s=e.length)<1))for(var i=0;i<s;i++){var a=e[i],n=a.key,o=a.value;if(n==="innerHTML"){t.innerHTML=o;continue}if(n.substr(4,1)==="-"){y.setAttr(t,n,o);continue}this.addAttr(t,n,o,r)}}static addAttr(t,e,r,s){if(r===""||!e)return!1;if(typeof r=="function")e=gt(e),d.add(e,t,function(i){r.call(this,i,s)});else{let i=W(e);t[i]=r}}static addContent(t,e){!e||(e.textContent!==null?t.textContent=e.textContent:e.innerHTML&&(t.innerHTML=e.innerHTML))}static append(t,e){t.appendChild(e)}},mt=class{createNode(t,e,r){}},ue=class extends mt{createNode(t,e,r){let s=t.tag;if(s==="text"){let i=t.attr[0],a=i?i.value:"";return C.createText(a,e)}else if(s==="comment"){let i=t.attr[0],a=i?i.value:"";return C.createComment(a,e)}return C.create(s,t.attr,e,r)}},pe=class extends mt{createNode(t,e,r){let s=t.tag;if(s==="text"){let i=t.attr[0],a=i?i.value:""}else if(s==="comment"){let i=t.attr[0],a=i?i.value:""}}},de=class{static browserIsSupported(){return window}static setup(){return this.browserIsSupported()?new ue:new pe}},fe=de.setup(),w=class{static render(t,e,r){if(!t)return;let s,i;switch(typeof t){case"object":if(t.isUnit===!0)return this.createComponent(t,e,r),t;default:return s=F(t),i=new s,this.createComponent(i,e,r),i}}static build(t,e,r){let s=C.createDocFragment();if(Array.isArray(t))for(var i=0,a=t.length;i<a;i++)this.buildElement(t[i],s,r);else this.buildElement(t,s,r);return e&&typeof e=="object"&&e.appendChild(s),s}static rebuild(t,e,r){return C.removeAll(e),this.build(t,e,r)}static buildElement(t,e,r){if(t){if(t.isUnit===!0){this.createComponent(t,e,r);return}this.createElement(t,e,r)}}static createElement(t,e,r){let s=ce.parse(t,r),i=this.createNode(s,e,r);this.cache(i,t.cache,r);let a=s.children;if(a.length>0){let u;for(var n=0,o=a.length;n<o;n++)u=a[n],u!==null&&this.buildElement(u,i,r)}let c=s.directives;c&&c.length&&this.setDirectives(i,c,r)}static setDirectives(t,e,r){for(var s=0,i=e.length;s<i;s++)this.handleDirective(t,e[s],r)}static handleDirective(t,e,r){e.directive.callBack(t,e.attr.value,r)}static cache(t,e,r){r&&e&&(r[e]=t)}static createComponent(t,e,r){let s=t;s.parent=r,r&&r.persist===!0&&s.persist!==!1&&(s.persist=!0),s.cache&&r&&(r[s.cache]=s),s.setup(e);let i=s.prepareLayout();this.build(i,s.container,s),s.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(s)}static createNode(t,e,r){return fe.createNode(t,e,r)}};j.augment({buildLayout(t,e,r){w.build(t,e,r)}});var q=[],ge=t=>q.indexOf(t)!==-1,ye=t=>({tag:"script",src:t.src,async:!1,load(e){q.push(t.src);let r=t.load;r&&r()}}),be=t=>({tag:"link",rel:"stylesheet",type:"text/css",href:t.src,load(e){q.push(t.src);let r=t.load;r&&r()}}),ve=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=be({load:r,src:t}):e=ye({load:r,src:t}),w.build(e,document.head)}addFiles(t){if(t)for(var e=0,r=t.length;e<r;e++){var s=t[e];ge(s)||this.add(s)}}update(){if(this.updateProgress()<100)return;let t=this.callBack;t&&t()}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}},me=(t,e)=>{import(t).then(r=>{e&&e(r)})},xe=t=>t?typeof t?.prototype?.constructor=="function":!1,ke=(t,e,r)=>{let s=w.build(t,null,r),i=s.firstChild;return e.after(s),i},we=t=>({tag:"comment",textContent:"import placeholder",onCreated:t.onCreated}),Se=F({render(){return we({onCreated:t=>{if(this.src){if(this.depends){new ve(()=>{this.loadAndRender(t)}).addFiles(this.depends);return}this.loadAndRender(t)}}})},getLayout(t){let e=t.default;if(!e)return null;let r=this.callBack;return r?e=r(e):xe(e)?(e=new e,e.route=this.route,this.persist&&(e.persist=!0)):e=e(),this.layout=e},loadAndRender(t){me(this.src,e=>{this.loaded=!0;let r=this.layout||this.getLayout(e);this.layoutRoot=ke(r,t,this.parent)})},shouldUpdate(t){return this.updateLayout===!0?!0:this.updateLayout=t&&t.isUnit&&typeof t.update=="function"},updateModuleLayout(t){let e=this.layout;this.shouldUpdate(e)&&e.update(t)},update(t){this.loaded===!0&&this.updateModuleLayout(t)},beforeDestroy(){!this.layoutRoot||A.removeElement(this.layoutRoot)}}),je=t=>new Se(t),Ae=(t,e,r)=>{!e||e&&y.setAttr(t,"role",e)},Oe=t=>(e,r)=>{let s=r?"true":"false";y.setAttr(e,t,s)},Ce=(t,e,r)=>{if(!e)return;let s=e.role;s&&(y.setAttr(t,"role",s),e.role=null);for(var i in e)if(!(!Object.prototype.hasOwnProperty.call(e,i)||e[i]===null)){var a=e[i],n="aria-"+i;Array.isArray(a)?(a.push(Oe(n)),(void 0).onSet(t,a,r)):y.setAttr(t,n,a)}};g.addType("context",t=>{if(!t)return!1;t.parent.removeContextBranch(t.branch)});var V=t=>t?t.getContext():null,Te=(t,e,r)=>{if(typeof e!="function")return;let s=V(r),i=e(s);!i||((void 0)._addElementAttrs(t,i,r),(void 0).addElementDirectives(t,i,r))},De=(t,e,r)=>{if(typeof e!="function")return;let s=V(r);e(s)},Pe=(t,e,r)=>{if(typeof e!="function"||!r)return;let s=V(r),i=e(s);!i||r.addContextBranch(i[0],i[1])},Ee=(t,e,r)=>{!e||!r||(r[e]=t)},Be=(t,e,r)=>{if(!e||!r)return!1;e(r,t)},Me=(t,e,r)=>{if(!e||!r)return!1;e(r.data,t)},Le=(t,e,r)=>{if(!e||!r)return!1;e(r.state,t)},_e=(t,e,r)=>{if(!e||!r)return!1;if(r.stateHelper){let s=r.state,i=e(s);r.stateHelper.addStates(i)}},M=t=>t.data?t.data:t.context&&t.context.data?t.context.data:null,He=(t,e,r)=>{let s,i,a;if(typeof e=="string"){if(s=M(r),!s)return!1;i=e}else if(Array.isArray(e)){if(typeof e[0]!="object"){let n=M(r);if(n)e.unshift(n);else return!1}[s,i,a]=e}k.bind(t,s,i,a)},Ne=(t,e,r)=>{let s,i,a,n;if(e.length<3){let c=M(r);if(!c)return;s=c,i=e[0],a=e[1],n=e[2]}else s=e[0],i=e[1],a=e[2],n=e[3];let o=n!==!1;k.watch(t,s,i,c=>{if(A.removeAll(t),!c||c.length<1)return;let u=[];for(var f=0,b=c.length;f<b;f++){var P=o?s.scope(i+"["+f+"]"):null,J=a(c[f],f,P);J!==null&&u.push(J)}return w.build(u,t,r)})},Re=(t,e,r)=>{let s=e[0];if(!s||s.length<1)return;let i=e[1],a=[];for(var n=0,o=s.length;n<o;n++){var c=s[n];if(c){var u=i(c,n);u!==null&&a.push(u)}}return w.build(a,t,r)},Ie=(t,e,r)=>{e(t)};g.addType("destroyed",t=>{if(!t)return!1;t.callBack(t.ele)});var Ue=(t,e,r)=>{We(t,e)},We=(t,e)=>{g.add(t,"destroyed",{ele:t,callBack:e})},Y=(t,e,r,s)=>{let i,a,n;if(Array.isArray(r[0])){for(var o=0,c=r.length;o<c;o++){var u=r[o];!u||Y(t,e,u,s)}return}if(r.length<3?[i,a]=r:[e,i,a]=r,!e||!i)return!1;switch(typeof a){case"object":n=f=>{Ve(t,a,f)};break;case"function":n=f=>{Fe(t,a,i,f,s)};break}k.watch(t,e,i,n)},Fe=(t,e,r,s,i)=>{let a=e(s,t,i);switch(typeof a){case"object":if(i&&a&&a.isUnit===!0&&i.persist===!0&&i.state){let n=r+":"+s,o=i.state,c=o.get(n);typeof c<"u"&&(a=c),o.set(n,a)}qe(a,t,i);break;case"string":A.addHtml(t,a);break}},qe=(t,e,r)=>{w.rebuild(t,e,r)},Ve=(t,e,r)=>{for(var s in e)!Object.prototype.hasOwnProperty.call(e,s)||!s||(e[s]===r?y.addClass(t,s):y.removeClass(t,s))},Ye=(t,e,r)=>{let s=M(r);Y(t,s,e,r)},Je=(t,e,r)=>{Y(t,r.state,e,r)},$e=(t,e,r)=>{if(!e)return!1;if(Array.isArray(e)&&typeof e[0]!="string")for(var s=0,i=e.length;s<i;s++)T.setup(t,e[s],r);else T.setup(t,e,r)},ze=0,xt=class{constructor(t){this.router=t,this.locationId="base-app-router-"+ze++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}},Ke=class extends xt{addEvent(){return d.on("popstate",window,this.callBack),this}removeEvent(){return d.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=!1){let s=window.history,i=s.state;if(i&&i.uri===t)return this;let a=this.createState(t,e);return s[r===!1?"pushState":"replaceState"](a,null,t),this}},Xe=class extends xt{addEvent(){return d.on("hashchange",window,this.callBack),this}removeEvent(){return d.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}},kt=class{static browserIsSupported(){return"history"in window&&"pushState"in window.history}static setup(t){return kt.browserIsSupported()?new Ke(t).setup():new Xe(t).setup()}},Ge=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=F(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),w.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)}},Qe=t=>{let e="";if(t){let r=/(\/):[^/(]*?\?/g;e=e.replace(r,n=>{let o=/\//g;return n.replace(o,"(?:$|/)")});let s=/(:[^/?&($]+)/g,i=/(\?\/+\*?)/g;e=e.replace(i,"?/*"),e=e.replace(s,n=>n.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)");let a=/(\*)/g;e=e.replace(a,".*")}return e+=t[t.length-1]==="*"?"":"$",e},Ze=t=>{if(!t.length)return null;let e={};for(var r=0,s=t.length;r<s;r++)e[t[r]]=null;return e},tr=t=>{let e=[];if(!t)return e;let r=/[*?]/g;t=t.replace(r,"");let s=/:(.[^./?&($]+)\?*/g,i=t.match(s);if(i===null)return e;for(var a=0,n=i.length;a<n;a++){var o=i[a];o&&(o=o.replace(":",""),e.push(o))}return e},er=0,rr=class extends U{constructor(t,e){let r=t.baseUri,s=tr(r),i=Ze(s),a=super(i);return this.uri=r,this.paramKeys=s,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),a}setupRoute(t){this.id=t.id||"bs-rte-"+er++,this.path=null,this.referralPath=null;let e=Qe(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title}setTitle(t){this.titleCallBack(this,t)}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?(typeof e=="string"&&(e={src:e}),je(e)):null}setupComponentHelper(t){let e=this.getLayout(t);if(e){let{container:r,persist:s=!1,parent:i}=t,a={component:e,container:r,persist:s,parent:i};this.controller=new Ge(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 i=s.split("#")[1];!i||this.scrollToId(i)}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")return;let e=this.paramKeys;if(!e)return;let r={};for(var s=0,i=e.length;s<i;s++){var a=e[s];typeof a<"u"&&(r[a]=t[s])}this.set(r)}getParams(){return this.stage}},sr=t=>{let e=/\w\S*/;return t.replace(e,r=>r.charAt(0).toUpperCase()+r.substring(1).toLowerCase())},ir=(t,e)=>{if(t.indexOf(":")===-1)return t;let r=e.stage;for(var s in r)if(Object.prototype.hasOwnProperty.call(r,s)){var i=r[s],a=new RegExp(":"+s,"gi");t=t.replace(a,i)}return t},ar=(t,e,r)=>e&&(typeof e=="function"&&(e=e(t.stage)),e=ir(e,t),e=sr(e),r!==""&&(e+=" - "+r),e),nr={removeSlashes(t){return typeof t=="string"&&(t.substring(0,1)==="/"&&(t=t.substring(1)),t.substring(-1)==="/"&&(t=t.substring(0,t.length-1))),t}};g.addType("routes",t=>{if(!t)return!1;let e=t.route;e&&D.removeRoute(e)});g.addType("switch",t=>{if(!t)return!1;let e=t.id;D.removeSwitch(e)});var or=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 I({path:""})}setupHistory(){this.history=kt.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new rr(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+nr.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var i=e[s];if(i.uri===t)return i}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var i=e[s];if(i.id===t)return i}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,i=t.length;s<i;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 i=0,a=t.length;i<a;i++){var n=t[i].component.route;n.resume(e),s.push(n)}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),d.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"||y.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let s=this.baseURI,i=s!=="/"?r.replace(s,""):r;return this.navigate(i),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=t.title;document.title=ar(t,e,this.title)}checkActiveRoutes(t){this.lastPath=this.path,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,s;for(var i=0;i<r;i++)s=e[i],!(typeof s>"u")&&this.checkRoute(s,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var s=e[r];this.checkGroup(s,t)}}checkGroup(t,e){let r=!1,s,i,a,n,o=!1;for(var c=0,u=t.length;c<u;c++)if(s=t[c],!(typeof s>"u")){if(c===0&&(i=s),!a&&s.get("active")&&(a=s),r!==!1){o&&s.deactivate();continue}r=s.match(e),r!==!1&&(n=s,s.controller&&(this.select(s),o=!0))}if(n===void 0){this.select(i),a&&i!==a&&a.deactivate();return}a?o&&n!==a&&a.deactivate():i&&o===!1&&this.select(i)}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(){d.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}},D=new or,lr=(t,e,r)=>{if(!e)return!1;if(Array.isArray(e))for(var s=0,i=e.length;s<i;s++)tt(t,e[s],r);else tt(t,e,r)},tt=(t,e,r)=>{e.container=t,e.parent=r;let s=D.add(e);hr(t,s)},hr=(t,e)=>{g.add(t,"routes",{route:e})},cr=(t,e,r)=>{let s=e[0];for(var i=0,a=e.length;i<a;i++)s=e[i],s.container=t,s.parent=r;let n=D.addSwitch(e);ur(t,n)},ur=(t,e)=>{g.add(t,"switch",{id:e})};N.add("cache",Ee).add("onCreated",Ie).add("onDestroyed",Ue).add("bind",He).add("onSet",Ye).add("onState",Je).add("watch",$e).add("useParent",Be).add("useData",Me).add("useState",Le).add("addState",_e).add("map",Re).add("for",Ne).add("useContext",De).add("addContext",Pe).add("context",Te).add("role",Ae).add("aria",Ce).add("route",lr).add("switch",cr);j.augment({Ajax:rt,Html:A,dataBinder:k,Data:I,SimpleData:U,Model:ft,State:S,Builder:w,router:D,Component:vt});var h=(t,e)=>({...t,children:e}),os=l((t,e)=>h(t,e)),ls=l((t,e)=>h({...t,tag:"span"},e)),hs=l((t,e)=>h({...t,tag:"p"},e)),cs=l((t,e)=>h({...t,tag:"a"},e)),us=l((t,e)=>h({...t,tag:"button"},e)),ps=l((t,e)=>h({...t,tag:"ul"},e)),ds=l((t,e)=>h({...t,tag:"li"},e)),fs=l(t=>h({...t,tag:"img"},null)),gs=l((t,e)=>h({...t,tag:"h1"},e)),ys=l((t,e)=>h({...t,tag:"h2"},e)),bs=l((t,e)=>h({...t,tag:"h3"},e)),vs=l((t,e)=>h({...t,tag:"h4"},e)),ms=l((t,e)=>h({...t,tag:"h5"},e)),xs=l((t,e)=>h({...t,tag:"h6"},e)),ks=l(t=>h({...t,tag:"input"},null)),ws=l((t,e)=>h({...t,tag:"label"},e)),Ss=l((t,e)=>h({...t,tag:"section"},e)),js=l((t,e)=>h({...t,tag:"article"},e)),As=l((t,e)=>h({...t,tag:"header"},e)),Os=l((t,e)=>h({...t,tag:"footer"},e)),Cs=l((t,e)=>h({...t,tag:"nav"},e)),Ts=l((t,e)=>h({...t,tag:"aside"},e)),Ds=l((t,e)=>h({...t,tag:"figure"},e)),Ps=l((t,e)=>h({...t,tag:"figcaption"},e)),Es=l((t,e)=>h({...t,tag:"main"},e)),Bs=l((t,e)=>h({...t,tag:"video"},e)),Ms=l((t,e)=>h({...t,tag:"audio"},e)),Ls=l((t,e)=>h({...t,tag:"table"},e)),_s=l((t,e)=>h({...t,tag:"tr"},e)),Hs=l((t,e)=>h({...t,tag:"th"},e)),Ns=l((t,e)=>h({...t,tag:"td"},e)),Rs=l((t,e)=>h({...t,tag:"thead"},e)),Is=l((t,e)=>h({...t,tag:"tbody"},e)),Us=l((t,e)=>h({...t,tag:"tfoot"},e)),Ws=l((t,e)=>h({...t,tag:"form"},e)),Fs=l((t,e)=>h({...t,tag:"select"},e)),qs=l((t,e)=>h({...t,tag:"option"},e)),Vs=l((t,e)=>h({...t,tag:"textarea"},e)),Ys=l((t,e)=>h({...t,tag:"canvas"},e)),Js=l((t,e)=>h({...t,tag:"progress"},e)),$s=l((t,e)=>h({...t,tag:"blockquote"},e)),zs=l((t,e)=>h({...t,tag:"pre"},e)),Ks=l((t,e)=>h({...t,tag:"code"},e)),Xs=l((t,e)=>h({...t,tag:"ol"},e)),Gs=l((t,e)=>h({...t,tag:"dl"},e)),Qs=l((t,e)=>h({...t,tag:"dt"},e)),Zs=l((t,e)=>h({...t,tag:"dd"},e)),ti=l((t,e)=>h({...t,tag:"fieldset"},e)),ei=l((t,e)=>h({...t,tag:"legend"},e)),ri=l((t,e)=>h({...t,tag:"meter"},e)),si=l((t,e)=>h({...t,tag:"iframe"},e)),ii=l((t,e)=>h({...t,tag:"details"},e)),ai=l((t,e)=>h({...t,tag:"summary"},e)),ni=l((t,e)=>h({...t,tag:"em"},e)),oi=l((t,e)=>h({...t,tag:"strong"},e)),li=l((t,e)=>h({...t,tag:"small"},e)),hi=l((t,e)=>h({...t,tag:"s"},e)),ci=l((t,e)=>h({...t,tag:"cite"},e)),ui=l((t,e)=>h({...t,tag:"q"},e)),pi=l((t,e)=>h({...t,tag:"dfn"},e)),di=l((t,e)=>h({...t,tag:"abbr"},e)),fi=l((t,e)=>h({...t,tag:"data"},e)),gi=l((t,e)=>h({...t,tag:"time"},e)),yi=l((t,e)=>h({...t,tag:"var"},e)),bi=l((t,e)=>h({...t,tag:"samp"},e)),vi=l((t,e)=>h({...t,tag:"kbd"},e)),mi=l((t,e)=>h({...t,tag:"sub"},e)),xi=l((t,e)=>h({...t,tag:"sup"},e)),ki=l((t,e)=>h({...t,tag:"i"},e)),wi=l((t,e)=>h({...t,tag:"b"},e)),Si=l((t,e)=>h({...t,tag:"u"},e)),ji=l((t,e)=>h({...t,tag:"mark"},e)),Ai=l((t,e)=>h({...t,tag:"ruby"},e)),Oi=l((t,e)=>h({...t,tag:"rt"},e)),Ci=l((t,e)=>h({...t,tag:"rp"},e)),Ti=l((t,e)=>h({...t,tag:"bdi"},e)),Di=l((t,e)=>h({...t,tag:"bdo"},e)),Pi=l(t=>h({...t,tag:"wbr"},null));export{cs as A,di as Abbr,js as Article,Ts as Aside,Ms as Audio,wi as B,Ti as Bdi,Di as Bdo,$s as Blockquote,us as Button,Ys as Canvas,ci as Cite,Ks as Code,fi as Data,Zs as Dd,ii as Details,pi as Dfn,os as Div,Gs as Dl,Qs as Dt,ni as Em,ti as Fieldset,Ps as Figcaption,Ds as Figure,Os as Footer,Ws as Form,gs as H1,ys as H2,bs as H3,vs as H4,ms as H5,xs as H6,As as Header,ki as I,si as Iframe,fs as Img,ks as Input,vi as Kbd,ws as Label,ei as Legend,ds as Li,Es as Main,ji as Mark,ri as Meter,Cs as Nav,Xs as Ol,qs as Option,hs as P,zs as Pre,Js as Progress,ui as Q,Ci as Rp,Oi as Rt,Ai as Ruby,hi as S,bi as Samp,Ss as Section,Fs as Select,li as Small,ls as Span,oi as Strong,mi as Sub,ai as Summary,xi as Sup,Ls as Table,Is as Tbody,Ns as Td,Vs as Textarea,Us as Tfoot,Hs as Th,Rs as Thead,gi as Time,_s as Tr,Si as U,ps as Ul,yi as Var,Bs as Video,Pi as Wbr};
2
+ //# sourceMappingURL=atoms.js.map