diff --git a/dist/akili.js b/dist/akili.js index 77a7411..4e8f6b7 100644 --- a/dist/akili.js +++ b/dist/akili.js @@ -3,9 +3,9 @@ * * const Akili = makeItEasy(js + html); * - * @version 1.2.33 + * @version 1.2.34 * @author Alexandr Balasyan * {@link http://akilijs.com} * {@link https://github.com/ortexx/akili} */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Akili=e():t.Akili=e()}(self,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function r(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}function i(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function a(t,e,n){return a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&o(i,n.prototype),i},a.apply(null,arguments)}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);nFt});var p=function(){function t(e,n,r,i){u(this,t),this.name=e,this.node=n,this.el=r,this.component=i}return h(t,[{key:"trigger",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.__removed||!n&&this.inEvaluating()||(t=m.copy(t,{plain:!0}),this.el.dispatchEvent(new CustomEvent(this.name,this.prepareOptions(f({detail:t},e)))))}},{key:"dispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.__removed||!n&&this.inEvaluating()||this.el.dispatchEvent(new t(this.name,this.prepareOptions(e)))}},{key:"prepareOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=f({bubbles:!0},t),this.node.__component.__prepareAttributeOut(this.node,t.detail),t}},{key:"inEvaluating",value:function(){var t=this.component.__evaluatingEvent;return!!t&&(t.el===this.el&&t.event.type===this.name&&t.component===this.component)}},{key:"bind",value:function(t){this.el.addEventListener(this.name,this.fn=t)}},{key:"unbind",value:function(){this.fn&&this.el.removeEventListener(this.name,this.fn)}},{key:"remove",value:function(){this.unbind(),delete this.name,delete this.node,delete this.component,delete this.el,this.__removed=!0}}]),t}();function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function d(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=[],i="";if(!e)return t.split("");if(e instanceof RegExp)return t.split(e);if(-1==t.indexOf(e))i=t;else for(var o=t.split(""),a="",s=0,l=o.length;s-1&&(!a||a==u)&&(a=a?"":n[c]),u!=e||a?i+=u:(r.push(i),i="")}return i&&r.push(i),r},filter:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[];if(r&&!Array.isArray(r)&&(r=[r]),"function"!=typeof e){var o=e?(e+"").toLowerCase():"";e=function(t){return(t?(t+"").toLowerCase():"").match(n.escapeForRegExp(o))}}for(var a=0,s=t.length;a1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];t=t.slice(),!0===n?(n=[],r=[!0]):!1===n&&(n=[],r=[!1]),Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);var i=n.length;return t.sort((function(t,o){var a=0,s=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t instanceof Date&&(t=t.getTime()),e instanceof Date&&(e=e.getTime()),t>e?n?-1:1:t=i)return 0;var u=n[a];Array.isArray(u)||(u=[u]);var c=e.getPropertyByKeys(u,t),h=e.getPropertyByKeys(u,o),_=s(c,h,!1===r[a]);return 0!==_?_:(a++,l())}():s(t,o,!1===r[a])})),t},includeKeys:function(t,e){for(var n={},r=Object.keys(t),i=0,o=r.length;i1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=n(t)||!t)return t;r=d({nested:!0,enumerable:!0,plain:!1},r);return function t(i){if(i=e.isScopeProxy(i)||e.isStoreProxy(i)?i.__target:i,r.plain&&!e.isPlainObject(i))return i;for(var o=r.enumerable?Object.keys(i):Object.getOwnPropertyNames(i),a=Array.isArray(i)?[]:{},s=0,l=o.length;s2&&void 0!==arguments[2]?arguments[2]:{};if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if("function"==typeof t&&"function"==typeof e)return t.toString()===e.toString();if("object"==n(t)&&"object"==n(e)){if(null===t||null===e)return t===e;var i=function(t){for(var e=Array.isArray(t)?[]:{},n=r.enumerable?Object.keys(t):Object.getOwnPropertyNames(),i=0,o=n.length;i1&&void 0!==arguments[1]?arguments[1]:{}).ignoreScopeHash&&this.isScopeProxy(t)&&t.__hash)return t.__hash;t=function r(i){if(!i||"object"!=n(i))return String(i);if(e.isScopeProxy(i)){if(i!==t&&i.__hash)return i.__hash;i=i.__target}if(i instanceof K)return"".concat(i.constructor.name,":;").concat(i.scope.__name);for(var o=Object.keys(i),a=o.length,s="",l=0;l2&&void 0!==arguments[2]?arguments[2]:{},o="ERR_ARRAY_REDUCE_BREAK",a=t.length,s=0,l=Array.isArray(i.closest)?i.closest:[],u=function(){var t=new Error("Break the reducer");throw t.code=o,t};try{t.reduce((function(t,e){return s++,t&&"object"==n(t)||u(),void 0===t[e]&&i.closest&&(r=l.length?t:void 0,u()),l.push(e),void 0===t[e]?{}:(s==a&&(r=t[e]),t[e])}),e)}catch(t){if(t.code!=o)throw t}return r},hasPropertyByKeys:function(t,e){var r=!1,i=t.length,o=0;return t.reduce((function(t,e){return o++,t&&"object"==n(t)?Object.prototype.hasOwnProperty.call(t,e)?(o==i&&(r=Object.prototype.hasOwnProperty.call(t,e)),t[e]):{}:!!t}),e),r},hasEnumerablePropertyByKeys:function(t,e){var r=!1,i=t.length,o=0;return t.reduce((function(t,e){return o++,t&&"object"==n(t)?Object.prototype.propertyIsEnumerable.call(t,e)?(o==i&&(r=Object.prototype.hasOwnProperty.call(t,e)),t[e]):{}:!!t}),e),r},setPropertyByKeys:function(t,e,r){var i=void 0,o=t.length,a=0;return t.reduce((function(t,e){if(a++,t&&"object"==n(t))return Object.prototype.hasOwnProperty.call(t,e)||(t[e]=void 0),t[e]=r(a==o,t[e]),i=t,t[e]}),e),i},deletePropertyByKeys:function(t,e,r){var i,o=t.length,a=0;return t.reduce((function(t,e){if(a++,t&&"object"==n(t))return Object.prototype.hasOwnProperty.call(t,e)?a==o?(i=t[e],(!r||r(i))&&delete t[e],i):t[e]:{}}),e),i},getEnumerablePropertyTarget:function(t,e){var n=this;return function t(r){if(n.hasEnumerablePropertyByKeys(e,r))return r;var i=Object.getPrototypeOf(r);return i?t(i):null}(t)},getOwnPropertyTarget:function(t,e){var n=this;return function t(r){if(n.hasPropertyByKeys(e,r))return r;var i=Object.getPrototypeOf(r);return i?t(i):null}(t)},createRandomString:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=Math.random().toString(36).substring(2,t+2),r=Date.now(),i="",o=0,a=n.length;o1&&void 0!==arguments[1]?arguments[1]:0,n=function n(){clearTimeout(t.__debounceTimeout),t.__debounceTimeout=setTimeout((function(){t(),n.removeDebounce()}),e)};return n.removeDebounce=function(){clearTimeout(t.__debounceTimeout),delete t.__debounceTimeout},n}};const m=y;var g=function(){function t(e,n,r){u(this,t),this.__name=e,this.__el=n,this.__component=r,n.setAttribute("scope",e)}return h(t,[{key:"__set",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Array.isArray(t)||(t=[t]),Ft.unisolate((function(){r.saveProxy&&(n.__component.__disableProxyRedefining=!0),r.silent&&n.__component.__disableKeys(),m.setPropertyByKeys(t,r.target?n.__target:n,(function(t,n){return t?e:n||{}})),r.silent&&n.__component.__enableKeys(),r.saveProxy&&(n.__component.__disableProxyRedefining=!1)}))}},{key:"__remove",value:function(){for(var t in Ft.removeScope(this.__name),this)Object.prototype.hasOwnProperty.call(this,t)&&delete this[t]}}]),t}();function b(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function k(t){for(var e=1;e0){var s=o.substring(0,a),l=o.substring(a+2);e[s]=l}}return e})),this.baseUrl=e?e.replace(/\/$/,"")+"/":"",this.defaults=k({statusErrorPattern:/^[^23]/,cache:!1},n||{})}return h(t,[{key:"query",value:function(t){var e=this;return new Promise((function(n,r){(t=k(k({},e.defaults),t||{})).url=e.baseUrl?"".concat(e.baseUrl).concat(t.url.replace(/^\//,"")):t.url,t.method=t.method||"GET";var i=new XMLHttpRequest,o=e.transformBefore(i,t);if(i=o.xhr,"function"==typeof(t=o.options).onStart&&t.onStart(i),t.headers=t.headers||{},t.json?(!0!==t.json&&(t.body=JSON.stringify(t.json)),t.headers["content-type"]="application/json",t.responseType=t.responseType||"json"):t.form&&(t.body=e.createFormData(t.form),t.headers["content-type"]="multipart/form-data"),t.params){var a=e.paramsToQuery(t.params);a&&(t.url+="?"+a)}var s=null,l="function"==typeof t.cache?t.cache(t):t.cache;if(!window.AKILI_SSR&&null===Ft.__init&&(l=!0),"GET"!=t.method.toUpperCase()||t.body&&"string"!=typeof t.body||(s=e.createCacheHash({url:t.url,method:t.method,user:t.user,password:t.password,body:t.body})),l&&s){var u=e.getCache(s),c=(new Date).getTime();if(u&&(!0===l||c-u.createdAt<=l))return n(e.transformAfter(u.result))}i.open(t.method,t.url,!0,t.user,t.password),Object.prototype.hasOwnProperty.call(t,"timeout")&&(i.timeout=t.timeout),t.responseType&&(i.responseType=t.responseType),t.withCredentials&&(i.withCredentials=t.withCredentials);for(var h=Object.keys(t.headers),_=0,f=h.length;_2&&void 0!==arguments[2]?arguments[2]:"",n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new FormData;for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&t[r]){var i=e?e+"["+r+"]":r;t[r]instanceof Date?n.append(i,t[r].toISOString()):m.isPlainObject(t[r])?this.createFormData(t[r],n,i):n.append(i,t[r])}return n}},{key:"transformBefore",value:function(t,e){return{xhr:t,options:e}}},{key:"transformAfter",value:function(t){return k(k({},t),{},{data:t.response})}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="GET",this.query(e)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="DELETE",this.query(e)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="POST",this.query(e)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="PUT",this.query(e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="PATCH",this.query(e)}},{key:"head",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="HEAD",this.query(e)}}]),t}(),O=new w;O.__instances={},O.__cache={},O.addInstance=function(t,e){this.__instances[t]=e},O.removeInstance=function(t){delete this.__instances[t]},Object.defineProperty(O,"use",{get:function(){return O.__instances}}),O.Request=w;const P=O;var A=j({},[]);function S(t,e){var n=t.length?[t[0]]:[e],r=n[0],i=[].concat(l(t),[e]),o="store.".concat(r);Ft.__isolation[o]={updatedAt:Date.now(),rootKey:r,rootKeys:n,keys:i}}function j(t,e){if("object"!=n(t)||null===t)return t;if(!m.isPlainObject(t)&&!m.isStoreProxy(t)&&t!==A)return t;var r=t;t.__isProxy&&(r=t.__target,m.isStoreProxy(t)&&Ft.joinBindingKeys(e)==Ft.joinBindingKeys(t.__keys)||(t=r=m.copy(r,{nested:!1})));for(var i=Object.keys(t),o=0,a=i.length;o1&&void 0!==arguments[1]?arguments[1]:{};if(u(this,t),!(e instanceof Element))throw new Error("You must pass an html element to the component constructor");this.__isCreated=!1,this.__isMounted=!1,this.__isCompiled=!1,this.__isResolved=!1,this.__isRemoved=!1,this.__cancelled=!1,this.__prevent=!1,this.__bindings={},this.__evaluatingEvent=null,this.__recompiling=null,this.__compiling=null,this.__disableProxy={},this.__disableStoreKeys={},this.__disableAttrKeys={},this.__children=[],this.__parent=null,this.__parents=[],this.__content="",this.__attrs={},this.__attrLinks={},this.__storeLinks={},this.__attributeOf=null,this.__evaluationComponent=this,this.scope=n,this.el=e,!this.constructor.ssr&&window.AKILI_SSR&&this.cancel()}return h(t,[{key:"__createCompilationOptions",value:function(){return x({checkChanges:!1,setEvents:!0,setParents:!0,setBooleanAttributes:!0,defineAttributes:!0},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"__createRecompilationOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return x(x({},this.__createCompilationOptions()),{},{setEvents:!1,setParents:!1,defineAttributes:!1},t)}},{key:"__recompile",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.__isMounted=!1,this.__recompiling=!0,this.__evaluationComponent.__disableProxy={},this.__compiling=this.__createRecompilationOptions(t),this.__compiling.setEvents&&this.__setEvents(),this.__compiling.setParents&&this.__setParents(),this.__compiling.setBooleanAttributes&&this.__setBooleanAttributes(),this.__compiling.defineAttributes&&this.__defineAttributes()}},{key:"__create",value:function(){var t=this;this.__compiling=this.__createCompilationOptions(),this.__initialize(),this.__setEvents(),this.__setParents(),this.__setBooleanAttributes(),this.__defineAttributes(),Ft.isolate((function(){return t.created(t.attrs)})),this.__isCreated=!0}},{key:"__compile",value:function(){var t=this,e=this.__controlAttributes||!this.__evaluationParent,n=Promise.resolve();this.__attributeOf=e?this:this.__evaluationParent.__akili,(!this.__recompiling||this.__compiling.newParent||this.__controlAttributes)&&this.__interpolateAttributes(this.el,this.__attributeOf);var r;return function e(n,r){for(var i=0,o=n.length;i2&&void 0!==arguments[2]?arguments[2]:{};return m.compare(m.createHash(e),t.hash,n)}},{key:"__createExceptionMessage",value:function(t,e){var n=t.__component.el.tagName,r=(t.__component.el.getAttribute("component")||n).toLowerCase(),i=t.__element.tagName.toLowerCase(),o=t instanceof window.Attr?t.name.toLowerCase():"",a=[e.message,t.__expression.trim()];return o&&a.push("[attribute ".concat(o,"]")),"Expression error: "+(a=a.concat(["[element ".concat(i,"]"),"[component ".concat(r,"]")])).join("\n\tat ")}},{key:"__evaluate",value:function(t){var e,r,i=this,o=0,a=t.__attributeOf||t.__component;return t.__component.parents((function(t){return t.__prevent})).length?{res:t.__expression}:t instanceof window.Attr||!t.__component.__prevent?{res:t.__expression.replace(T,(function(s,l){var u;o++;var c=t.__component.__getParsedExpression(l);i.__finishEvaluationCycle(),Ft.__evaluation={node:t,list:[],component:a};try{u=i.constructor.parse(a.__evaluationComponent.scope,c,x({},C))}catch(e){throw i.__createExceptionMessage(t,e)}if(i.__finishEvaluationCycle(),t instanceof window.Attr)return r=s,e=u,m.makeAttributeValue(u);if("object"==n(u))try{return JSON.stringify(u)}catch(t){return u}return u})),counter:o,expression:r,attributeValue:e}:{res:t.__expression}}},{key:"__finishEvaluationCycle",value:function(){var t,e,n=[],r={};Ft.__evaluation&&(t=Ft.__evaluation.node,e=Ft.__evaluation.component,n=Ft.__evaluation.list,Ft.__evaluation.list=null,Ft.__evaluation=null);for(var i=n.length-1;i>=0;i--){var o=n[i];if(!o.component.__isRemoved){var a=o.component.__createKeysHash(o.keys);if(!o.notBinding&&!r[a]){var s=m.getPropertyByKeys(o.parents,o.component.__scope);m.isScopeProxy(s)&&o.component!==e.__evaluationComponent&&o.component===o.bindComponent||(o.bindComponent.__bindAndSetProperty(t,o.keys,o.evaluated),r[a]=!0)}}}}},{key:"__bindAndSetProperty",value:function(t,e,n){var r=this.__getBoundNode(e,t),i=m.getPropertyByKeys(e,this.__scope);r||this.__bind(e,{node:t,keys:e}),this.__setNodeProperty(t,e,i,n)}},{key:"__getEvaluationComponents",value:function(t){var e=[];return function n(r){r.__getBind(t)&&e.push(r);for(var i=0;i1&&void 0!==arguments[1])||arguments[1],n=t instanceof window.Attr?"value":"nodeValue";if(!e||this.__checkEvaluation(t)){var r=this.__evaluate(t),i=r.res,o=r.attributeValue,a=r.expression,s=r.counter;if(t[n]!=i&&(t[n]=i),t instanceof window.Attr){var l=i,u=!1;1==s&&a&&t.__expression==a&&(l=o);var c=t.nodeName.replace(/^boolean-(.+)/i,"$1"),h=m.toCamelCase(c);if(c!=t.nodeName&&(u=!0,l=!!l),t.__attributeOn){var _=t.__attributeOn;l=_.__prepareAttributeIn(t,l),_.__disableAttributeSetter=!0,_.attrs[h]=l,_.__disableAttributeSetter=!1,_.__isMounted&&_.__attrTriggerByName(h,l)}else if(u){var f=t.__element;l?f.setAttribute(h,"true"):f.removeAttribute(h)}}}return t[n]}},{key:"__prepareAttributeIn",value:function(t,e){return m.copy(e,{plain:!0})}},{key:"__prepareAttributeOut",value:function(t,e){return m.copy(e,{plain:!0})}},{key:"__initializeAttribute",value:function(t,e,n){if(t&&-1==N.indexOf(t.nodeName)&&this.__initializeNode(t,e)){var r=t.nodeName.replace(/^on-(.+)/i,"$1"),i=n||this;if(t.__isEvent){if(t.__event)return;var o=new Ft.EventEmitter(r,t,e,i);return t.__hasBindings&&o.bind((function(n){return i.__evaluateEvent(t,e,n)})),t.__event=o,e.setAttribute(t.nodeName,m.makeAttributeValue(o)),void(n&&(this.__disableAttributeSetter=!0,this.attrs[m.toCamelCase(t.nodeName)]=o,this.__disableAttributeSetter=!1))}n&&(t.__attributeOn=this,t.__attributeOf=i);var a=!!this.__compiling&&this.__compiling.checkChanges;i.__evaluateNode(t,a)}}},{key:"__initializeNode",value:function(t,e){if(t.__initialized)return!0;var n=t instanceof window.Attr,r=t[n?"value":"nodeValue"],i=B.test(r.trim()),o=!!n&&/^boolean-/i.test(t.nodeName),a=!!n&&/^on-(.+)/i.test(t.nodeName);return!!(e.__akili||i||o||a)&&(t.__name=this.__scope.__name+m.createRandomString(16),t.__isEvent=a,t.__hasBindings=i,t.__isBoolean=o,t.__expression=r,t.__properties={},t.__attributeOf=null,t.__attributeOn=null,t.__event=null,t.__initialized=!0,t.__component=this,t.__element=e,!0)}},{key:"__deinitializeNode",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.__initialized&&(t.__event&&t.__event.remove(),t.__hasBindings&&!e.saveBindings&&(this.__unbindByNodes(t),this.__unbindParentsByNodes(t)),Ft.removeTag(t),delete t.__name,delete t.__hasBindings,delete t.__isBoolean,delete t.__isEvent,delete t.__expression,delete t.__properties,delete t.__attributeOf,delete t.__attributeOn,delete t.__event,delete t.__initialized,delete t.__component,delete t.__element)}},{key:"__interpolateAttributes",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=0,r=t.attributes,i=r.length;n2&&void 0!==arguments[2]&&arguments[2];if(!t.__disableAttributeSetter){var i=t.el.getAttributeNode(e);if(r)return i&&t.__deinitializeNode(i),void t.el.removeAttribute(e);i?(i.value=n,t.__deinitializeNode(i)):(t.el.setAttribute(e,n),i=t.el.getAttributeNode(e)),t.__initializeAttribute(i,t.el,t.__attributeOf)}};this.attrs=new Proxy(this.__attrs,{get:function(t,e){return"__isProxy"==e||t[e]},set:function(n,r,i){var o=m.toDashCase(r);return-1!=t.booleanAttributes.indexOf(o)&&(i?t.el.setAttribute(o,i):t.el.removeAttribute(o),o="boolean-".concat(o)),n[r]=i,e(o,m.makeAttributeValue(i)),!0},deleteProperty:function(t,n,r){var i=m.toDashCase(n);return e(i,m.makeAttributeValue(r),!0),delete t[n],!0}})}},{key:"__observe",value:function(t,e){var n=this;return new Proxy(t,{get:function(r,i){if("__isProxy"==i)return!0;if("__target"==i)return t;if("__component"==i)return n;if("__keys"==i)return e;if(n.__isSystemKey(i))return r[i];if(Ft.__evaluation&&!n.__isRemoved){var o=[].concat(e,[i]),a=!1,s=!m.getOwnPropertyTarget(n.__scope,o),l=n;if(r instanceof g){var u=m.getOwnPropertyTarget(r,[i]);u&&u instanceof g&&(l=u.__component)}return Ft.__wrapping&&o.length>1||(i in r&&!m.getEnumerablePropertyTarget(r,[i])&&(a=!0),n.__bindNode(Ft.__evaluation.list,l,o,e,r[i],a,s)),r[i]}return r[i]},set:function(t,r,i){var o=[].concat(l(e),[r]);return n.__isRemoved||n.__isSystemKey(r)||n.__checkDisablement(o)?(t[r]=i,n.__setScopeObjectHash(t,o),!0):n.__isCreated&&void 0!==i&&!Object.prototype.hasOwnProperty.call(t,r)&&r in t?(m.getEnumerablePropertyTarget(t,[r]).__component.scope[r]=i,!1):("function"==typeof i&&(i=Ft.wrapFunction(i)),t[r]=n.__nestedObserve(i,o),n.__isResolved||n.__triggerStoreAndAttr(o),Ft.__isolation?(n.__createIsolationObject(e,r),!0):(n.__setScopeObjectHash(t,o),n.__isResolved&&n.__triggerStoreAndAttr(o),n.__isMounted&&n.__evaluateByKeys(o),!0))},deleteProperty:function(t,r){var i=[].concat(e,[r]);return n.__isRemoved||n.__isSystemKey(r)||n.__checkDisablement(i)?(delete t[r],n.__setScopeObjectHash(t,i),!0):(delete t[r],n.__isResolved||n.__triggerStoreAndAttr(i),Ft.__isolation?(n.__createIsolationObject(e,r),!0):(n.__isResolved&&n.__triggerStoreAndAttr(i),n.__setScopeObjectHash(t,i),n.__evaluateByKeys(i),!0))}})}},{key:"__triggerStoreAndAttr",value:function(t){for(var e=0,n=t.length;e1&&void 0!==arguments[1]?arguments[1]:"proxy";this[this.__getDisablementTypeStore(e)][t?this.__createKeysHash(t):"__all"]=!0}},{key:"__enableKeys",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"proxy";delete this[this.__getDisablementTypeStore(e)][t?this.__createKeysHash(t):"__all"]}},{key:"__checkDisablement",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"proxy",n=this.__getDisablementTypeStore(e);return!!this[n].__all||this[n][this.__createKeysHash(t)]}},{key:"__storeTriggerByKeys",value:function(t,e){if(!this.__checkDisablement(t,"store")){var n=this.__storeLinks[Ft.joinBindingKeys(t)];if(n&&n.length){e=m.copy(e,{plain:!0});for(var r=[],i=0,o=n.length;i2&&void 0!==arguments[2]?arguments[2]:{};if(n=x({get:!0,set:!0},n),!e)throw new Error('Store link "'.concat(t,'" must have the scope property name'));if(!n.get&&!n.set)throw new Error('Store link "'.concat(t,'" must have at least "get" or "set" option as true'));Array.isArray(e)||(e=[e]),this.__disableKeys(e,"store"),(Object.prototype.hasOwnProperty.call(R,t)||!m.hasPropertyByKeys(e,this.__scope))&&this.scope.__set(e,R[t]),this.__enableKeys(e,"store");var r,i=Ft.joinBindingKeys(e);this.__storeLinks[i]||(this.__storeLinks[i]=[]);for(var o=this.__storeLinks[i],a=o.length-1;a>=0;a--){var s=o[a];if(s.component===this&&s.name==t&&s.keyString==i)return void(o[a]=x(x(x({},s),n),{},{date:Date.now()}))}Ft.__storeLinks[t]||(Ft.__storeLinks[t]=[]),r=x(x({},n),{},{component:this,name:t,keys:e,keyString:i,date:Date.now()}),this.__storeLinks[i].push(r),Ft.__storeLinks[t].push(r)}},{key:"__storeByFunction",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=void 0===n.callOnStart?Object.prototype.hasOwnProperty.call(R.__target,t):n.callOnStart;Ft.__storeLinks[t]||(Ft.__storeLinks[t]=[]);for(var i=Ft.__storeLinks[t],o=i.length-1;o>=0;o--){var a=i[o];if(a.component===this&&a.name==t&&a.fn===e)return void(i[o]=x(x(x({},a),n),{},{date:Date.now()}))}if(Ft.__storeLinks[t].push(x(x({},n),{},{component:this,name:t,fn:e,date:Date.now()})),"*"==t&&!1!==n.callOnStart){for(var s=Object.keys(R.__target),l=[],u=0,c=s.length;u=0;i--){var o=r[i],a=Ft.__storeLinks[o.name];if(o.component===this&&o.name==t&&o.keyString==n&&(r.splice(i,1),a&&a.length)){for(var s=a.length-1;s>=0;s--){var l=a[s];l.component===this&&l.keyString==n&&a.splice(s,1)}a.length||delete Ft.__storeLinks[t]}}r.length||delete this.__storeLinks[n]}}},{key:"__unstoreByFunction",value:function(t,e){if(Ft.__storeLinks[t]){for(var n=Ft.__storeLinks[t],r=n.length-1;r>=0;r--){var i=n[r];if(i.component===this&&i.name==t&&i.fn===e){n.splice(r,1);break}}n.length||delete Ft.__storeLinks[t]}}},{key:"__attrTriggerByKeys",value:function(t,e){var n=this;if(!this.__checkDisablement(t,"attr")){var r=this.__attrLinks[Ft.joinBindingKeys(t)];if(r&&r.length)return Ft.isolate((function(){for(var t=0,i=r.length;t2&&void 0!==arguments[2]?arguments[2]:{};if(n=x({get:!0,set:!0},n),t=m.toCamelCase(t),!e)throw new Error('Attribute link "'.concat(t,'" must have the scope property name'));Array.isArray(e)||(e=[e]),this.__disableKeys(e,"attr"),(Object.prototype.hasOwnProperty.call(this.attrs,t)||!m.hasPropertyByKeys(e,this.__scope))&&this.scope.__set(e,this.attrs[t]),this.__enableKeys(e,"attr");var r=Ft.joinBindingKeys(e);this.__attrLinks[r]||(this.__attrLinks[r]=[]);for(var i=this.__attrLinks[r],o=i.length-1;o>=0;o--){var a=i[o];if(a.name==t&&a.keyString==r)return void(i[o]=x(x(x({},a),n),{},{date:Date.now()}))}this.__attrLinks[r].push(x(x({},n),{},{name:t,keys:e,keyString:r,date:Date.now(),component:this}))}},{key:"__attrByFunction",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=m.toCamelCase(t);var i=void 0===r.callOnStart?Object.prototype.hasOwnProperty.call(this.attrs,t):r.callOnStart;this.__attrLinks[t]||(this.__attrLinks[t]=[]);for(var o=this.__attrLinks[t],a=o.length-1;a>=0;a--){var s=o[a];if(s.name==t&&s.fn===e)return void(o[a]=x(x(x({},s),r),{},{date:Date.now()}))}if(this.__attrLinks[t].push(x(x({},r),{},{name:t,fn:e,date:Date.now(),component:this})),"*"==t&&!1!==r.callOnStart){for(var l=Object.keys(this.__attrs).filter((function(t){return!(n.__attrs[t]instanceof Ft.EventEmitter)})),u=[],c=0,h=l.length;c=0;i--){var o=r[i];o.name==t&&o.keyString==n&&r.splice(i,1)}r.length||delete this.__attrLinks[n]}}},{key:"__unattrByFunction",value:function(t,e){if(this.__attrLinks[t]){for(var n=this.__attrLinks[t],r=n.length-1;r>=0;r--){var i=n[r];if(i.name==t&&i.fn===e){n.splice(r,1);break}}n.length||delete this.__attrLinks[t]}}},{key:"__isSystemKey",value:function(t){return t.match&&t.match("^_|#")||"constructor"==t}},{key:"__setScopeObjectHash",value:function(t,e){!t||"object"!=n(t)||t instanceof g||(Object.defineProperty(t,"__hash",{configurable:!0,enumerable:!1,value:m.createHash(t,{ignoreScopeHash:!0})}),e&&(e=e.slice(0,-1),this.__setScopeObjectHash(m.getPropertyByKeys(e,this.__scope),e)))}},{key:"__nestedObserve",value:function(t,e){var r=this;return function t(e,i){if("object"!=n(e)||null===e)return e;if(!(m.isPlainObject(e)||m.isScopeProxy(e)||e instanceof g))return e;var o=e;t:if(e.__isProxy){if(o=e.__target,r.__disableProxyRedefining)break t;e.__component===r&&Ft.joinBindingKeys(i)==Ft.joinBindingKeys(e.__keys)||(e=o=m.copy(o,{nested:!1}))}else r.__disableProxyRedefining||e instanceof g||(e=o=m.copy(o,{nested:!1}));for(var a=Object.keys(o),s=0,u=a.length;s5&&void 0!==arguments[5]&&arguments[5],a=arguments.length>6&&void 0!==arguments[6]&&arguments[6],s=Ft.joinBindingKeys(r),l=this;if(t.length&&!o){var u=t.length-1,c=t[u];c.bindComponent===this&&c.keysString==s&&(l=c.component),c.keysString==s&&c.component===l&&t.splice(u,1)}t.push({component:l,bindComponent:e,keysString:Ft.joinBindingKeys(n),parents:r,keys:n,value:i,evaluated:a,notBinding:o})}},{key:"__isSystemBindingKey",value:function(t){return"__data"==t}},{key:"__getBind",value:function(t){return m.getPropertyByKeys(t,this.__bindings)||null}},{key:"__getAllBinds",value:function(t){var e=this.__getBind(t);if(!e)return[];var n=[];return function t(e){for(var r in n=n.concat(e.__data||[]),e)Object.prototype.hasOwnProperty.call(e,r)&&"__data"!=r&&t(e[r])}(e),n}},{key:"__getBoundNode",value:function(t,e){var n=m.getPropertyByKeys(t,this.__bindings);if(!n||!n.__data||!n.__data.length)return null;for(var r=0,i=n.__data.length;r3&&void 0!==arguments[3]&&arguments[3],i=this.__getNodeProperty(t,e),o=m.createHash(n);if(i){var a=t.__component.__compareNodePropertyValue(i,n);return i.value=n,i.hash=o,!a}return t.__properties[this.__createKeysHash(e)]={component:this,value:n,hash:o,node:t,keys:e,evaluated:r},!0}},{key:"__getNodeProperty",value:function(t,e){return t.__properties[this.__createKeysHash(e)]||null}},{key:"__deleteNodeProperty",value:function(t,e){var n="scope.".concat(this.__scope.__name,".").concat(Ft.joinBindingKeys(e));delete t.__properties[n]}},{key:"__mapNodes",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n=x({rootAttrs:!0,attrs:!0,node:!0,el:!0},n);!function r(i){if(i){if(n.attrs&&(i!==e.el||n.rootAttrs))for(var o=0,a=i.attributes,s=a.length;o=0;l--){var u=i.childNodes[l];3==u.nodeType?n.node&&t(u):1!=u.nodeType||u.__akili||(r(u),n.el&&t(u))}}}(this.el)}},{key:"__getAllNodes",value:function(){var t=[];return this.__mapNodes((function(e){return t.push(e)})),t}},{key:"__bind",value:function(t,e){m.setPropertyByKeys(t,this.__bindings,(function(t,r){var i={__data:[]};return t?("object"==n(r)&&(i=r),i.__data||(i.__data=[]),i.__data.push(e),i):r||i}))}},{key:"__unbindByNodes",value:function(t){var e=this;t instanceof Node&&(t=[t]);!function n(r,i,o){for(var a=Object.keys(r),s=0,l=a.length;s=0;r--){n[r].component===this&&n.splice(r,1)}n.length||delete t[e]}}},{key:"__remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attrs.onRemoved&&this.attrs.onRemoved.trigger(void 0,{bubbles:!1}),this.removed();var e=this.__detach({saveBindings:!0,deinitializeNodes:!0}),n=[].concat(e,this.__empty({saveBindings:!0}));return this.__unbindByNodes(e),!t.saveBindings&&this.__unbindParentsByNodes(n),this.__clearStoreLinks(),this.__scope.__remove(),delete this.__scope,delete this.scope,this.el.remove(),delete this.el.__akili,delete this.el,delete this.__parent,delete this.__attributeOf,delete this.__evaluationComponent,delete this.__evaluationParent,delete this.__parents,delete this.__bindings,delete this.__attrLinks,delete this.__storeLinks,delete this.__attrs,delete this.attrs,this.__isRemoved=!0,n}},{key:"__removeChildren",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[],n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.__parent&&this.__parent.__akili.__spliceChild(this.el);for(var e=[],n=0,r=this.el.attributes.length;n0&&void 0!==arguments[0]?arguments[0]:{},n=this.__removeChildren({saveBindings:!0});return this.__mapNodes((function(e){1!=e.nodeType?e.__initialized&&(t.__deinitializeNode(e,{saveBindings:!0}),n.push(e)):e.remove()}),{rootAttrs:!1}),this.__unbindByNodes(n),!e.saveBindings&&this.__unbindParentsByNodes(n),this.el.innerHTML="",n}},{key:"__getParent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[],o=0;"object"!=n(r)&&(r=[r]);return function n(a){if(a){if((!r||-1!=r.indexOf(o))&&(!t||a.__akili.matches(t))){if(!e)return void i.push(a.__akili);i.push(a.__akili)}o++,n(a.__akili.__parent)}}(this.__parent),e?i:i[0]||null}},{key:"__getChildren",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[],o=0;"object"!=n(r)&&(r=[r]);return function n(a){for(var s=0,l=a.length;s0&&void 0!==arguments[0]?arguments[0]:"",e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.__parent)return null;var r=this.__parent.__akili.__children.slice(),i=[];n&&r.reverse();for(var o=0,a=r.length;o0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getParent(t,!1,e)}},{key:"parents",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getParent(t,!0,e)}},{key:"child",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getChildren(t,!1,e)}},{key:"children",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getChildren(t,!0,e)}},{key:"before",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!0,!1)}},{key:"after",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!0,!0)}},{key:"prev",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!1,!1)}},{key:"next",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!1,!0)}},{key:"appendTo",value:function(t){return t.appendChild(this.el),Ft.compile(this.el,{recompile:{setParents:!0,checkChanges:!1}})}},{key:"cancel",value:function(){this.__cancelled=!0}},{key:"prevent",value:function(){this.__prevent=!0}},{key:"empty",value:function(){return this.__empty.apply(this,arguments)}},{key:"remove",value:function(){return this.__remove.apply(this,arguments)}},{key:"created",value:function(){}},{key:"compiled",value:function(){}},{key:"recompiled",value:function(){}},{key:"resolved",value:function(){}},{key:"removed",value:function(){}},{key:"transition",get:function(){return this.__scope&&this.__scope.__transition||null}},{key:"isCreated",get:function(){return this.__isCreated}},{key:"isCompiled",get:function(){return this.__isCompiled}},{key:"isResolved",get:function(){return this.__isResolved}},{key:"isRemoved",get:function(){return this.__isRemoved}}],[{key:"define",value:function(){Ft.component("component",t)}},{key:"parse",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=[],i=[],o=m.split(e,";",['"',"'","`"]);for(var s in o[o.length-1]="return ".concat(o[o.length-1]),n)r.push(s),i.push(n[s]);return a(Function,r.concat(["".concat(o.join("; "))])).apply(t,i)}}]),t}();function H(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function I(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},U(t)}function D(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}i(K,"matches",""),i(K,"booleanAttributes",[]),i(K,"events",[]),i(K,"controlAttributes",!1),i(K,"transparent",!1),i(K,"template",""),i(K,"templateUrl",""),i(K,"scope",null),i(K,"ssr",!0);var M=function(t){H(n,t);var e=D(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;on){var i=this.iterators[n];return i.setIndex(this.__index===i.index),i.setKey(this.__key===i.key),i.setValue(m.compare(this.__hash,i.hash)),{promise:r,iterator:i}}var o=this.iteratorEl.cloneNode();return o.innerHTML=this.html,this.el.insertBefore(o,this.el.children[this.iteratorIndex+this.iterators.length]),r=Ft.compile(o),this.iterators.push(o.__akili),{promise:r,iterator:o.__akili}}},{key:"drawChunk",value:function(t){var e=this;if(this.__isRemoved)return Promise.resolve();var r=Object.keys(this.data),i=r.length;if(t==i)return this.__removeExcessIterators(),Promise.resolve(this.__completeDrawing());var o=[],a=t+ +(this.attrs.chunks||i);a>i&&(a=i);for(var s=this.__stepIterationChunk.bind(this),l=function(){var t=r[u],n=u+1,l=e.loop(t,e.data[t],u);return l.iterator.iterate(u),o.push(l.promise),n!=a?"continue":(n==i&&(e.__removeExcessIterators(),s=e.__completeDrawing.bind(e)),{v:Promise.all(o).then((function(){return s(n)}))})},u=t;u=0;r--){var i=this.el.options[r],o=!!i.getAttribute("selected");!e||e.includes(i.value)?e?(i.selected=!0,n.push(i.value)):(i.selected=o,o&&n.push(i.value)):i.selected=!1}this.changeValue(this.formatValue(n))}},{key:"setMultiple",value:function(){this.changeValue(this.formatValue(m.copy(this.el.content)))}},{key:"setValue",value:function(t){if(void 0!==t||this.__isCompiled){var e=this.formatValue(t);this.changeValue(e,!m.compare(e,t))}}},{key:"createIteratorElement",value:function(){var t=F(U(n.prototype),"createIteratorElement",this).apply(this,arguments);return t.hasAttribute("value")||t.setAttribute("value",this.html.trim()),t}},{key:"getContent",value:function(){if(!this.attrs.multiple)return this.el.value;for(var t=[],e=0,n=this.el.options.length;e=0;i--)e[t[i]]||t.splice(i,1);return t}},{key:"redefine",value:function(){this.el.querySelector("[selected]")||(this.el.value=this.getDefaultValue()),this.changeValue(this.getContent())}},{key:"getDefaultValue",value:function(){var t=this.el.options[0];return this.attrs.multiple?[]:t?t.value:void 0}},{key:"changeValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(m.compare(this.el.content,t)){if(!e)return}else{if(Array.isArray(t)){this.el.value=t[t.length-1];for(var n=0,r=this.el.options.length;n${this.__content}'),nt.RadioButton=rt;var ot=function(t){H(n,t);var e=it(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("textarea",this)}}]),n}(J);function at(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var st=function(t){H(n,t);var e=at(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;or&&(t=r),t<=0)return this.el.focus();this.walkTextNodes(this.el,(function(t){return n.push(t)}));for(var i=0;in[i].nodeValue.length&&n[i+1])){e=n[i];break}t-=n[i].nodeValue.length}var o=document.createRange(),a=window.getSelection();o.setStart(e,t),o.setEnd(e,t),a.removeAllRanges(),a.addRange(o),this.el.focus()}}],[{key:"define",value:function(){Ft.component("content",this),Ft.alias("[contenteditable]","content")}}]),n}(J);function lt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var ut=function(t){H(n,t);var e=lt(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;o=0;e--)this.constructor.__activeUrlLoading[e].component===this&&(this.constructor.__activeUrlLoading.splice(e,1),t=!0);t&&window.dispatchEvent(new CustomEvent("akili-url-loading",{detail:{name:this.chunkName,component:this}}))}}},{key:"addChunk",value:function(){var t=this;this.chunk||(this.chunk=!0,this.chunkListener=function(e){e.detail.name==t.chunkName&&e.detail.component!==t&&t.checkChunk()},window.addEventListener("akili-url-loading",this.chunkListener))}},{key:"checkChunk",value:function(){var t=this;if(this.chunk&&!this.finished){var e=this.constructor.__activeUrlLoading.filter((function(e){return e.name==t.chunkName}));this.constructor.__activeUrlLoading.find((function(e){return e.component===t}))||e.length>=this.chunkSize||(this.constructor.__activeUrlLoading.push({name:this.chunkName,component:this}),this.setUrlAttribute(this.attrs[this.handlerAttribute]))}}},{key:"setLoading",value:function(t){"viewport"==t?this.addViewport():this.removeViewport(),"chunk"==t?this.addChunk():this.removeChunk()}},{key:"setUrl",value:function(t){return this.abort(),this.removeChunkFromQueue(),this.finished=!1,this.viewport&&!this.isIntersecting?this.setUrlAttribute():this.chunk?(this.checkChunk(),this.setUrlAttribute()):void this.setUrlAttribute(t)}},{key:"setUrlAttribute",value:function(t){this.el.style.opacity=0,void 0!==t&&(!1===t?this.cancelling=!0:(this.cancelling=!1,this.timeout&&(this.loadingTimeout=setTimeout(this.onTimeout.bind(this),this.timeout))),this.isLoading=!0,this.attrs[this.urlAttribute]=t)}},{key:"setChunkName",value:function(t){if(!this.isCompiled||!this.chunk)return this.chunkName=t;this.abort(),this.removeChunkFromQueue(),this.chunkName=t,this.checkChunk()}},{key:"setChunkSize",value:function(t){if(!this.isCompiled||!this.chunk)return this.chunkSize=+t;this.abort(),this.removeChunkFromQueue(),this.chunkSize=+t,this.checkChunk()}},{key:"setTimeout",value:function(t){this.timeout=+t}},{key:"abort",value:function(){this.isLoading&&(this.setUrlAttribute(!1),this.attrs.onAbort.trigger())}}]),n}(K);function _t(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}i(ht,"matches","[url],[urlset]"),i(ht,"events",["timeout","abort"]),i(ht,"booleanAttributes",["hidden-error"]),i(ht,"__activeUrlLoading",[]);var ft=function(t){H(n,t);var e=_t(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("iframe",this)}}]),n}(ht);function pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var vt=function(t){H(n,t);var e=pt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("img",this)}}]),n}(ht);function dt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var yt=function(t){H(n,t);var e=dt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("embed",this)}}]),n}(ht);function mt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var gt=function(t){H(n,t);var e=mt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("audio",this)}}]),n}(ht);function bt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var kt=function(t){H(n,t);var e=bt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("video",this)}}]),n}(ht);function wt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var Ot=function(t){H(n,t);var e=wt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("track",this)}}]),n}(ht);function Pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var At=function(t){H(n,t);var e=Pt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("source",this)}}]),n}(ht);function St(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var jt=function(t){H(n,t);var e=St(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;o1&&void 0!==arguments[1])||arguments[1],r=t.path.state;return this.__scope.__transition={parent:function t(e){return e.parent?e.parent.component?e.parent.component.__scope.__transition.path:t(e.parent):null}(t.path),state:t.path.state,data:t.path.data,url:t.path.url,params:t.path.params,query:t.path.query,hash:t.path.hash},n?Promise.resolve().then((function(){return r.template?r.template:r.templateUrl?P.get(r.templateUrl).then((function(t){return t.data})):void 0})).then((function(t){return function(t){e.empty();var n="component";if(r.component){var i=!1;for(var o in Ft.__components)if(Ft.__components[o]===r.component){n=o,i=!0;break}if(!i)throw new Error('Router state "'.concat(r.name,'" has no defined component'))}return e.el.innerHTML="<".concat(n,">").concat(t,""),Ft.compile(e.el,{recompile:!0})}(t)})):Ft.compile(this.el,{recompile:{checkChanges:!0,route:this}})}}],[{key:"define",value:function(){Ft.component("route",this)}}]),n}(K);function Ct(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Lt(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:null;u(this,t),this.url=e,this.previous=n,this.path=null,this.routes=[],this.states={},this.__cancelled=!1,this.__finished=!1}return h(t,[{key:"redirect",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return i=Lt(Lt({},this.path.options),i),this.cancel(),Bt.state.call(Bt,t,e,n,r,i)}},{key:"reload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r=Lt(Lt({},this.path.options),r),t=Lt(Lt({},this.path.params),t),e=Lt(Lt({},this.path.query),e),n=void 0===n?this.path.hash:n,this.redirect(this.path.state.name,t,e,n,r)}},{key:"setPath",value:function(t){t.parent=this.path||null,this.path=Lt({params:{},query:{}},t),this.routes.push(this.path),this.states[this.path.state.name]=this.path}},{key:"getRoute",value:function(t){for(var e=0,n=this.routes.length;e=0&&Bt.__queue.splice(t,1)}}]),t}(),Bt={baseUrl:"/",states:[],hashMode:!0,transition:null,__info:{},__queue:[],__redirects:0,__init:!1,__paramRegex:/(\/?:([\w\d-]+))/g,__routeSelector:function(t){return t instanceof Et},add:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"==n(t)&&(e=(r=t).pattern,t=r.state,delete r.pattern,delete r.state),!t)throw new Error("Router state must have a name");if(Ft.options.debug&&r.component&&(r.template||r.templateUrl)&&console.warn('Router state "'.concat(t,'" must only have a component or template option')),r.template||r.templateUrl||r.component||(r.abstract=!0),this.has(t))throw new Error('Router state "'.concat(t,'" is already exists'));return this.setState(t,e,Lt(Lt({},{template:"",templateUrl:"",abstract:!1,component:null,params:{},query:{},handler:function(){},options:{}}),r)),this},remove:function(t){for(var e=0,n=this.states.length;e1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if("object"!==n(t)&&(t=this.getState(t)),!t)throw new Error("Not found route state with name ".concat(t));(a=Lt({},a)).manual=!0;var s=this.prepareStateArgs(t,r,i,o,a,!1);r=s.params,i=s.query,o=s.hash,a=s.options;var l=this.createStateUrl(t,r,i,o,a);return this.isolate((function(){return e.setUrl(l)})),this.changeState(a)},back:function(){return window.history.back.apply(window.history,arguments)},go:function(){return window.history.go.apply(window.history,arguments)},forward:function(){return window.history.forward.apply(window.history,arguments)},location:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(n=Lt({},n)).manual=!0,this.isolate((function(){return e.setUrl(t)})),this.changeState(n)},init:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=window.history.pushState;window.history.pushState=function(){var t=r.apply(this,arguments);return Bt.changeState().catch((function(t){return console.error(t)})),t},this.__onStateChangeHandler=function(){t.changeState().catch((function(t){return console.error(t)}))},this.defaultUrl=e,this.hashMode=n,this.states.sort((function(t,e){return(t=t.name.split(".").length)-(e=e.name.split(".").length)}));for(var i=0,o=this.states.length;i2&&void 0!==arguments[2]?arguments[2]:{}),{},{name:t,pattern:e});return this.states.push(n),this.__init&&this.initState(n),n},removeState:function(t){for(var e=0,n=this.states.length;e1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];if("object"!==n(t)&&(t=this.getState(t)),o=Lt({},o),a){var s=this.prepareStateArgs(t,e,r,i,o);e=s.params,r=s.query,i=s.hash,o=s.options}var l=t.fullPattern.replace(this.__paramRegex,(function(t,n,r){return"/"+(e[r]||"")}));return l=l.replace(/^\^/,""),l=this.splitSlashes(l),Object.keys(r).length&&(l+="?"+P.paramsToQuery(r)),!this.hashMode&&i&&(l+="#"+i.replace("#","")),l},prepareStateArgs:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o={params:e,query:n,hash:r,options:i},a=0;a<4^4;a++){var s=this.prepareStateParams(t,e,o),l=this.prepareStateQuery(t,n,o),u=this.prepareStateHash(t,r,o),c=this.prepareStateOptions(t,i,o);null===u?c.emptyHash=null:""===u&&(c.emptyHash="");var h={params:s,query:l,hash:u,options:c};if(m.compare(h,o))break;o=h}return o},prepareStateParams:function(t,e,r){"object"!==n(t)&&(t=this.getState(t));var i=t.name.split(".");e=Object.assign({},e);for(var o=i.length-1;o>=0;o--){var a=i.slice(0,i.length-o).join(".");e=this.createStateObjectArgs(e,this.getState(a).params,r)}return e},prepareStateQuery:function(t,e,r){"object"!==n(t)&&(t=this.getState(t));var i=t.name.split(".");e=Object.assign({},e);for(var o=i.length-1;o>=0;o--){var a=i.slice(0,i.length-o).join(".");e=this.createStateObjectArgs(e,this.getState(a).query,r)}return e},prepareStateOptions:function(t,e,r){"object"!==n(t)&&(t=this.getState(t));var i=t.name.split(".");e=Object.assign({},e);for(var o=i.length-1;o>=0;o--){var a=i.slice(0,i.length-o).join(".");e=this.createStateObjectArgs(e,this.getState(a).options,r)}return e},createStateObjectArgs:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{params:{},query:{},options:{}},r=Object.assign({},t);for(var i in e){var o=e[i];null!==r[i]&&("function"==typeof o&&(r[i]=o(n)),void 0===r[i]&&(r[i]=o))}for(var a in r)null===r[a]&&delete r[a];return r},prepareStateHash:function(t,e,r){if(null===e)return e;"object"!==n(t)&&(t=this.getState(t));for(var i=t.name.split("."),o=i.length-1;o>=0;o--){var a=i.slice(0,i.length-o).join(".");e=this.createStateHashArgs(e,this.getState(a).hash,r)}return e},createStateHashArgs:function(t,e){return null===t?t:"function"==typeof e?e(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{params:{},query:{}}):void 0===t?e:t},splitSlashes:function(t){return t.replace(/[/]+/g,"/")},getPatternContent:function(t,e){"object"!==n(t)&&(t=this.getState(t));var r=[],i={};e=(e=e.split("?")[0]).split("#")[0];var o=t.fullPattern.replace(this.__paramRegex,(function(t,e,n){return r.push(n),"/?([^/]*)"}));o=o.replace(/([^^/]+)[/]+$/,"$1");var a=new RegExp(o,"g");return e.match(a)?(e.replace(a,(function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o1&&void 0!==arguments[1]&&arguments[1];"object"!==n(t)&&(t=this.getState(t));var r=Bt.transition&&!Bt.transition.__finished?Bt.transition.url:this.getUrl();r=this.splitSlashes("/"+r.split("?")[0]+"/");var i=t.fullPattern.replace(this.__paramRegex,"/?([^/]*)");i=i.replace(/^\^/,"").replace(/\$$/,"");var o=e?i:this.splitSlashes("^/"+i+"/$");return new RegExp(o).test(r)},inActiveState:function(t){return Bt.isActiveState(t,!0)},getRoute:function(t){var e=this,n=0;return function r(i){var o=i.child(e.__routeSelector);return o?n==t?o:(n++,r(o)):null}(Ft.root)},getArrayPatternContent:function(t,e){for(var n=0,r=t.length;nt)break;e.push(i)}}return e},reload:function(){var t;if(!this.transition)throw new Error("Not found an active transition to reload the state");return(t=this.transition).reload.apply(t,arguments)},isolate:function(t){var e;this.__isolated=!0;try{e=t()}catch(t){throw this.__isolated=!1,t}return this.__isolated=!1,e},changeState:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.__isolated)return Promise.resolve();var n=this.getUrl(),r=new xt(n);return this.__queue.push(r),new Promise((function(e){var n=setInterval((function(){t.__queue[0]===r&&(clearInterval(n),e())}))})).then((function(){r.previous=Bt.transition||null,Bt.transition=r,window.dispatchEvent(new CustomEvent("state-change",{detail:r}));var i=e.emptyHash;if(!t.__redirects){var o=getComputedStyle(document.documentElement);t.__info.scrollPos={left:window.scrollX,top:window.scrollY},t.__info.docMinHeight=o.minHeight,t.__info.docMinWidth=o.minWidth,document.documentElement.style.minHeight=document.documentElement.offsetHeight+"px",document.documentElement.style.minWidth=document.documentElement.offsetWidth+"px"}var a={},s=t.getUrlQuery(),l=t.hashMode?"":window.location.hash.replace("#",""),u=0;return function o(c){if(!c.length)return Promise.resolve();var h=t.getArrayPatternContent(c,n);if(!h)return Promise.resolve();var _=h.state;r.setPath({state:_,component:v}),a=Lt(Lt({},a),h.params),l=l||i;var f=t.prepareStateArgs(_,a,s,l,e);a=f.params,s=f.query,l=f.hash,(e=f.options).init=null===Ft.__init,l=l||"";var p=t.createStateUrl(_,a,s,l,e,!1);t.isolate((function(){return t.replaceUrl(p)}));var v=_.abstract?null:t.getRoute(u);if(!v&&!_.abstract)throw new Error('Not found route component for state "'.concat(_.name,'"'));r.path.params=a,r.path.query=s,r.path.hash=l,r.path.url=p,r.path.options=e,!_.abstract&&u++;var d=!0;p!=n&&(d=r.isRouteChanged(r.path));var y=d&&!1!==e.reload,m=r.previous&&r.previous.path?r.previous.path.data:void 0;return Promise.resolve(y?_.handler(r):m).then((function(t){if(r.path.data=t,!r.__cancelled&&(void 0!==_.title&&(document.title="function"==typeof _.title?_.title(r):_.title),!_.abstract)){var n=r.previous&&r.previous.getRoute(_);return(n&&!n.loaded||!0===e.reload)&&(y=!0),v.setTransition(r,y).then((function(){return r.path.loaded=!0}))}})).then((function(){return o(_.children)}))}(t.getStatesByLevel(0)).then((function(){if(!r.routes.length){if(t.__redirects)throw new Error('Wrong router default url "'.concat(t.defaultUrl,'"'));if(t.defaultUrl){if(t.defaultUrl==t.getUrl())throw new Error("Not found any routes");return t.isolate((function(){return t.replaceUrl(t.defaultUrl)})),t.__redirects++,r.finish(),t.changeState(e)}Ft.options.debug&&console.warn('Not found a default route. You can pass it in "router.init(defaultUrl)" function')}return!t.hashMode&&r.path&&r.path.hash||!1===e.reload&&void 0===e.saveScrollPosition||null===e.saveScrollPosition||window.scrollTo(Lt({},e.saveScrollPosition?t.__info.scrollPos:{top:0,left:0})),document.documentElement.style.minHeight=t.__info.docMinHeight,document.documentElement.style.minWidth=t.__info.docMinWidth,t.__redirects=0,t.__info={},window.dispatchEvent(new CustomEvent("state-changed",{detail:r})),r.finish(),r}))})).catch((function(t){throw r&&r.finish(),t}))},deinit:function(){window.removeEventListener("popstate",this.__onStateChangeHandler),this.__init=!1}};Bt.Transition=xt;const Tt=Bt;function Nt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var Kt=function(t){H(r,t);var e=Nt(r);function r(){var t;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o1&&void 0!==arguments[1])||arguments[1],n=[];return function t(r){r.parentNode&&(r.parentNode.__akili&&(n.push(r.parentNode),!e)||t(r.parentNode))}(t),e?n:n[0]},qt.setTemplate=function(t,e){return e=e.replace(/\${(((?!\${)\s*this\.__content\s*)*)}/,t.innerHTML),t.innerHTML=e,t.innerHTML},qt.createScopeName=function(){var t=this;return m.createRandomString(16,(function(e){return!!t.__scopes[e]}))},qt.isolate=function(t){var e,n=this.__isolation;!n&&(this.__isolation={});try{if(e=t(),n)return e}catch(t){throw this.__isolation=null,t}var r=[];for(var i in this.__isolation)r.push(this.__isolation[i]);this.__isolation=null;for(var o=0,a=r.length;o2&&void 0!==arguments[2]?arguments[2]:{}).recompile,r=t.__akili;if(r){if(n){var i=!0===n?{}:n;return i.root=e,i.initiator=e.__akili,r.__recompile(i),r}}else{var o=t===this.__root,a=m.toDashCase(t.getAttribute("component")||t.tagName.toLowerCase()),s=this.__components[a];t:if(!s){var l=Object.keys(this.__aliases);if(!l.length)break t;var u=l.join(",");if(!t.matches(u))break t;for(var c=0,h=l.length;c1&&void 0!==arguments[1]?arguments[1]:{recompile:!1},r=[];if(window.AKILI_SSR)for(var i=t.querySelectorAll("[no-ssr]"),o=0,a=i.length;o=0;e--){var n=r[e];t.push(n.__resolve())}return Promise.all(t)}))},qt.component=function(t,e){if(t=t.toLowerCase(),!e)return this.__components[t]||null;this.__components[t]&&qt.options.debug&&console.warn("Component ".concat(t," already was added")),this.__components[t]=e},qt.removeComponent=function(t){delete this.__components[t]},qt.alias=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!(e=e.toLowerCase()))return this.__aliases[t]||null;this.__aliases[t]&&qt.options.debug&&console.warn("Alias with selector ".concat(t," already was added")),this.__aliases[t]=e},qt.removeAlias=function(t){delete this.__aliases[t]},qt.isolateArrayPrototype=function(){var t=this;this.__window.Array={prototype:{}};for(var e=Object.getOwnPropertyNames(Array.prototype),n=function(){var n=e[r],i=Array.prototype[n];if("function"!=typeof i||"constructor"==n)return"continue";t.__window.Array.prototype[n]=i,Array.prototype[n]=function(){var t=arguments,e=this;return qt.unevaluate((function(){return e.__isProxy?qt.isolate((function(){return i.apply(e,t)})):i.apply(e,t)}))}},r=0,i=e.length;r1&&void 0!==arguments[1]?arguments[1]:"last";return function(){var n=[].slice.call(arguments);!Array.isArray(e)&&(e=[e]);for(var r=function(){var t=e[i],r=t,o=n[t];if("last"==t&&(r=n.length-1,o=n[r]),"function"!=typeof o)return"continue";o.__isolated||(n[r]=function(){var t=arguments;return qt.isolate((function(){return o.apply(o,t)}))},Object.defineProperty(n[r],"__isolated",{enumerable:!1,value:o}))},i=0,o=e.length;i1&&void 0!==arguments[1]?arguments[1]:{},r=t;if("function"==typeof t){if((t=this.wrapFunction(t,e))===r)return t}else if(!t||"object"!=n(t)||Array.isArray(t))return t;for(var i=Object.getOwnPropertyNames(t),o=0,a=i.length;o1&&void 0!==arguments[1]?arguments[1]:{};if(t.__akili)return t;var n=function(){var n=arguments,r=this;return e.tag&&qt.__evaluation&&qt.addTag(e.tag,qt.__evaluation.node),qt.wrapping((function(){return t.apply(r,n)}))},r=Object.keys(t);n.prototype=t.prototype;for(var i=0,o=r.length;i=0;e--)this.__root.removeAttribute(this.__root.attributes[e].name);var n=(new DOMParser).parseFromString(t,"text/html").querySelector(this.__root===document.body?"body":"body > *");this.__root.innerHTML=n.innerHTML;for(var r=n.attributes.length-1;r>=0;r--){var i=n.attributes[r];this.__root.setAttribute(i.name,i.value)}},qt.initServerSideRequestCache=function(t){var e=function(t,e){for(var n in e)t.__cache[n]=e[n]};for(var n in t){e("__main"===n?P:P.__instances[n],t[n])}},qt.prepareServerSideHtml=function(){return this.__root.outerHTML},qt.prepareServerSideRequestCache=function(){var t={__main:P.__cache};for(var e in P.__instances)t[e]=P.__instances[e].__cache;return t};const Ft=qt;return window.Akili=qt,qt.define(),qt.handleErrors(),qt.isolateGlobals(),e=e.default})())); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Akili=e():t.Akili=e()}(self,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function r(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}function i(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function s(t,e,n){return s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&o(i,n.prototype),i},s.apply(null,arguments)}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);nFt});var p=function(){function t(e,n,r,i){u(this,t),this.name=e,this.node=n,this.el=r,this.component=i}return h(t,[{key:"trigger",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.__removed||!n&&this.inEvaluating()||(t=m.copy(t,{plain:!0}),this.el.dispatchEvent(new CustomEvent(this.name,this.prepareOptions(f({detail:t},e)))))}},{key:"dispatch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.__removed||!n&&this.inEvaluating()||this.el.dispatchEvent(new t(this.name,this.prepareOptions(e)))}},{key:"prepareOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=f({bubbles:!0},t),this.node.__component.__prepareAttributeOut(this.node,t.detail),t}},{key:"inEvaluating",value:function(){var t=this.component.__evaluatingEvent;return!!t&&(t.el===this.el&&t.event.type===this.name&&t.component===this.component)}},{key:"bind",value:function(t){this.el.addEventListener(this.name,this.fn=t)}},{key:"unbind",value:function(){this.fn&&this.el.removeEventListener(this.name,this.fn)}},{key:"remove",value:function(){this.unbind(),delete this.name,delete this.node,delete this.component,delete this.el,this.__removed=!0}}]),t}();function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function d(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=[],i="";if(!e)return t.split("");if(e instanceof RegExp)return t.split(e);if(-1==t.indexOf(e))i=t;else for(var o=t.split(""),s="",a=0,l=o.length;a-1&&(!s||s==u)&&(s=s?"":n[c]),u!=e||s?i+=u:(r.push(i),i="")}return i&&r.push(i),r},filter:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[];if(r&&!Array.isArray(r)&&(r=[r]),"function"!=typeof e){var o=e?(e+"").toLowerCase():"";e=function(t){return(t?(t+"").toLowerCase():"").match(n.escapeForRegExp(o))}}for(var s=0,a=t.length;s1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];t=t.slice(),!0===n?(n=[],r=[!0]):!1===n&&(n=[],r=[!1]),Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);var i=n.length;return t.sort((function(t,o){var s=0,a=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t instanceof Date&&(t=t.getTime()),e instanceof Date&&(e=e.getTime()),t>e?n?-1:1:t=i)return 0;var u=n[s];Array.isArray(u)||(u=[u]);var c=e.getPropertyByKeys(u,t),h=e.getPropertyByKeys(u,o),_=a(c,h,!1===r[s]);return 0!==_?_:(s++,l())}():a(t,o,!1===r[s])})),t},includeKeys:function(t,e){for(var n={},r=Object.keys(t),i=0,o=r.length;i1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=n(t)||!t)return t;r=d({nested:!0,enumerable:!0,plain:!1},r);return function t(i){if(i=e.isScopeProxy(i)||e.isStoreProxy(i)?i.__target:i,r.plain&&!e.isPlainObject(i))return i;for(var o=r.enumerable?Object.keys(i):Object.getOwnPropertyNames(i),s=Array.isArray(i)?[]:{},a=0,l=o.length;a2&&void 0!==arguments[2]?arguments[2]:{};if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if("function"==typeof t&&"function"==typeof e)return t.toString()===e.toString();if("object"==n(t)&&"object"==n(e)){if(null===t||null===e)return t===e;var i=function(t){for(var e=Array.isArray(t)?[]:{},n=r.enumerable?Object.keys(t):Object.getOwnPropertyNames(),i=0,o=n.length;i1&&void 0!==arguments[1]?arguments[1]:{}).ignoreScopeHash&&this.isScopeProxy(t)&&t.__hash)return t.__hash;t=function r(i){if(!i||"object"!=n(i))return String(i);if(e.isScopeProxy(i)){if(i!==t&&i.__hash)return i.__hash;i=i.__target}if(i instanceof K)return"".concat(i.constructor.name,":;").concat(i.scope.__name);for(var o=Object.keys(i),s=o.length,a="",l=0;l2&&void 0!==arguments[2]?arguments[2]:{},o="ERR_ARRAY_REDUCE_BREAK",s=t.length,a=0,l=Array.isArray(i.closest)?i.closest:[],u=function(){var t=new Error("Break the reducer");throw t.code=o,t};try{t.reduce((function(t,e){return a++,t&&"object"==n(t)||u(),void 0===t[e]&&i.closest&&(r=l.length?t:void 0,u()),l.push(e),void 0===t[e]?{}:(a==s&&(r=t[e]),t[e])}),e)}catch(t){if(t.code!=o)throw t}return r},hasPropertyByKeys:function(t,e){var r=!1,i=t.length,o=0;return t.reduce((function(t,e){return o++,t&&"object"==n(t)?Object.prototype.hasOwnProperty.call(t,e)?(o==i&&(r=Object.prototype.hasOwnProperty.call(t,e)),t[e]):{}:!!t}),e),r},hasEnumerablePropertyByKeys:function(t,e){var r=!1,i=t.length,o=0;return t.reduce((function(t,e){return o++,t&&"object"==n(t)?Object.prototype.propertyIsEnumerable.call(t,e)?(o==i&&(r=Object.prototype.hasOwnProperty.call(t,e)),t[e]):{}:!!t}),e),r},setPropertyByKeys:function(t,e,r){var i=void 0,o=t.length,s=0;return t.reduce((function(t,e){if(s++,t&&"object"==n(t))return Object.prototype.hasOwnProperty.call(t,e)||(t[e]=void 0),t[e]=r(s==o,t[e]),i=t,t[e]}),e),i},deletePropertyByKeys:function(t,e,r){var i,o=t.length,s=0;return t.reduce((function(t,e){if(s++,t&&"object"==n(t))return Object.prototype.hasOwnProperty.call(t,e)?s==o?(i=t[e],(!r||r(i))&&delete t[e],i):t[e]:{}}),e),i},getEnumerablePropertyTarget:function(t,e){var n=this;return function t(r){if(n.hasEnumerablePropertyByKeys(e,r))return r;var i=Object.getPrototypeOf(r);return i?t(i):null}(t)},getOwnPropertyTarget:function(t,e){var n=this;return function t(r){if(n.hasPropertyByKeys(e,r))return r;var i=Object.getPrototypeOf(r);return i?t(i):null}(t)},createRandomString:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=Math.random().toString(36).substring(2,t+2),r=Date.now(),i="",o=0,s=n.length;o1&&void 0!==arguments[1]?arguments[1]:0,n=function n(){clearTimeout(t.__debounceTimeout),t.__debounceTimeout=setTimeout((function(){t(),n.removeDebounce()}),e)};return n.removeDebounce=function(){clearTimeout(t.__debounceTimeout),delete t.__debounceTimeout},n}};const m=y;var g=function(){function t(e,n,r){u(this,t),this.__name=e,this.__el=n,this.__component=r,n.setAttribute("scope",e)}return h(t,[{key:"__set",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Array.isArray(t)||(t=[t]),Ft.unisolate((function(){r.saveProxy&&(n.__component.__disableProxyRedefining=!0),r.silent&&n.__component.__disableKeys(),m.setPropertyByKeys(t,r.target?n.__target:n,(function(t,n){return t?e:n||{}})),r.silent&&n.__component.__enableKeys(),r.saveProxy&&(n.__component.__disableProxyRedefining=!1)}))}},{key:"__remove",value:function(){for(var t in Ft.removeScope(this.__name),this)Object.prototype.hasOwnProperty.call(this,t)&&delete this[t]}}]),t}();function b(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function k(t){for(var e=1;e0){var a=o.substring(0,s),l=o.substring(s+2);e[a]=l}}return e})),this.baseUrl=e?e.replace(/\/$/,"")+"/":"",this.defaults=k({statusErrorPattern:/^[^23]/,cache:!1},n||{})}return h(t,[{key:"query",value:function(t){var e=this;return new Promise((function(n,r){(t=k(k({},e.defaults),t||{})).url=e.baseUrl?"".concat(e.baseUrl).concat(t.url.replace(/^\//,"")):t.url,t.method=t.method||"GET";var i=new XMLHttpRequest,o=e.transformBefore(i,t);if(i=o.xhr,"function"==typeof(t=o.options).onStart&&t.onStart(i),t.headers=t.headers||{},t.json?(!0!==t.json&&(t.body=JSON.stringify(t.json)),t.headers["content-type"]="application/json",t.responseType=t.responseType||"json"):t.form&&(t.body=e.createFormData(t.form),t.headers["content-type"]="multipart/form-data"),t.params){var s=e.paramsToQuery(t.params);s&&(t.url+="?"+s)}var a=null,l="function"==typeof t.cache?t.cache(t):t.cache;if(!window.AKILI_SSR&&null===Ft.__init&&(l=!0),"GET"!=t.method.toUpperCase()||t.body&&"string"!=typeof t.body||(a=e.createCacheHash({url:t.url,method:t.method,user:t.user,password:t.password,body:t.body})),l&&a){var u=e.getCache(a),c=(new Date).getTime();if(u&&(!0===l||c-u.createdAt<=l))return n(e.transformAfter(u.result))}i.open(t.method,t.url,!0,t.user,t.password),Object.prototype.hasOwnProperty.call(t,"timeout")&&(i.timeout=t.timeout),t.responseType&&(i.responseType=t.responseType),t.withCredentials&&(i.withCredentials=t.withCredentials);for(var h=Object.keys(t.headers),_=0,f=h.length;_2&&void 0!==arguments[2]?arguments[2]:"",n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:null)||new FormData;for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&t[r]){var i=e?e+"["+r+"]":r;t[r]instanceof Date?n.append(i,t[r].toISOString()):m.isPlainObject(t[r])?this.createFormData(t[r],n,i):n.append(i,t[r])}return n}},{key:"transformBefore",value:function(t,e){return{xhr:t,options:e}}},{key:"transformAfter",value:function(t){return k(k({},t),{},{data:t.response})}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="GET",this.query(e)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="DELETE",this.query(e)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="POST",this.query(e)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="PUT",this.query(e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="PATCH",this.query(e)}},{key:"head",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.url=t,e.method="HEAD",this.query(e)}}]),t}(),O=new w;O.__instances={},O.__cache={},O.addInstance=function(t,e){this.__instances[t]=e},O.removeInstance=function(t){delete this.__instances[t]},Object.defineProperty(O,"use",{get:function(){return O.__instances}}),O.Request=w;const P=O;var A=j({},[]);function S(t,e){var n=t.length?[t[0]]:[e],r=n[0],i=[].concat(l(t),[e]),o="store.".concat(r);Ft.__isolation[o]={updatedAt:Date.now(),rootKey:r,rootKeys:n,keys:i}}function j(t,e){if("object"!=n(t)||null===t)return t;if(!m.isPlainObject(t)&&!m.isStoreProxy(t)&&t!==A)return t;var r=t;t.__isProxy&&(r=t.__target,m.isStoreProxy(t)&&Ft.joinBindingKeys(e)==Ft.joinBindingKeys(t.__keys)||(t=r=m.copy(r,{nested:!1})));for(var i=Object.keys(t),o=0,s=i.length;o1&&void 0!==arguments[1]?arguments[1]:{};if(u(this,t),!(e instanceof Element))throw new Error("You must pass an html element to the component constructor");this.__isCreated=!1,this.__isMounted=!1,this.__isCompiled=!1,this.__isResolved=!1,this.__isRemoved=!1,this.__cancelled=!1,this.__prevent=!1,this.__bindings={},this.__evaluatingEvent=null,this.__recompiling=null,this.__compiling=null,this.__disableProxy={},this.__disableStoreKeys={},this.__disableAttrKeys={},this.__children=[],this.__parent=null,this.__parents=[],this.__content="",this.__attrs={},this.__attrLinks={},this.__storeLinks={},this.__attributeOf=null,this.__evaluationComponent=this,this.scope=n,this.el=e,!this.constructor.ssr&&window.AKILI_SSR&&this.cancel()}return h(t,[{key:"__createCompilationOptions",value:function(){return x({checkChanges:!1,setEvents:!0,setParents:!0,setBooleanAttributes:!0,defineAttributes:!0},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"__createRecompilationOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return x(x({},this.__createCompilationOptions()),{},{setEvents:!1,setParents:!1,defineAttributes:!1},t)}},{key:"__recompile",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.__isMounted=!1,this.__recompiling=!0,this.__evaluationComponent.__disableProxy={},this.__compiling=this.__createRecompilationOptions(t),this.__compiling.setEvents&&this.__setEvents(),this.__compiling.setParents&&this.__setParents(),this.__compiling.setBooleanAttributes&&this.__setBooleanAttributes(),this.__compiling.defineAttributes&&this.__defineAttributes()}},{key:"__create",value:function(){var t=this;this.__compiling=this.__createCompilationOptions(),this.__initialize(),this.__setEvents(),this.__setParents(),this.__setBooleanAttributes(),this.__defineAttributes(),Ft.isolate((function(){return t.created(t.attrs)})),this.__isCreated=!0}},{key:"__compile",value:function(){var t=this,e=this.__controlAttributes||!this.__evaluationParent,n=Promise.resolve();this.__attributeOf=e?this:this.__evaluationParent.__akili,(!this.__recompiling||this.__compiling.newParent||this.__controlAttributes)&&this.__interpolateAttributes(this.el,this.__attributeOf);var r;return function e(n,r){for(var i=0,o=n.length;i2&&void 0!==arguments[2]?arguments[2]:{};return m.compare(m.createHash(e),t.hash,n)}},{key:"__createExceptionMessage",value:function(t,e){var n=t.__component.el.tagName,r=(t.__component.el.getAttribute("component")||n).toLowerCase(),i=t.__element.tagName.toLowerCase(),o=t instanceof window.Attr?t.name.toLowerCase():"",s=[e.message,t.__expression.trim()];return o&&s.push("[attribute ".concat(o,"]")),"Expression error: "+(s=s.concat(["[element ".concat(i,"]"),"[component ".concat(r,"]")])).join("\n\tat ")}},{key:"__evaluate",value:function(t){var e,r,i=this,o=0,s=t.__attributeOf||t.__component;return t.__component.parents((function(t){return t.__prevent})).length?{res:t.__expression}:t instanceof window.Attr||!t.__component.__prevent?{res:t.__expression.replace(T,(function(a,l){var u;o++;var c=t.__component.__getParsedExpression(l);i.__finishEvaluationCycle(),Ft.__evaluation={node:t,list:[],component:s};try{u=i.constructor.parse(s.__evaluationComponent.scope,c,x({},L))}catch(e){throw i.__createExceptionMessage(t,e)}if(i.__finishEvaluationCycle(),t instanceof window.Attr)return r=a,e=u,m.makeAttributeValue(u);if("object"==n(u))try{return JSON.stringify(u)}catch(t){return u}return u})),counter:o,expression:r,attributeValue:e}:{res:t.__expression}}},{key:"__finishEvaluationCycle",value:function(){var t,e,n=[],r={};Ft.__evaluation&&(t=Ft.__evaluation.node,e=Ft.__evaluation.component,n=Ft.__evaluation.list,Ft.__evaluation.list=null,Ft.__evaluation=null);for(var i=n.length-1;i>=0;i--){var o=n[i];if(!o.component.__isRemoved){var s=o.component.__createKeysHash(o.keys);if(!o.notBinding&&!r[s]){var a=m.getPropertyByKeys(o.parents,o.component.__scope);m.isScopeProxy(a)&&o.component!==e.__evaluationComponent&&o.component===o.bindComponent||(o.bindComponent.__bindAndSetProperty(t,o.keys,o.evaluated),r[s]=!0)}}}}},{key:"__bindAndSetProperty",value:function(t,e,n){var r=this.__getBoundNode(e,t),i=m.getPropertyByKeys(e,this.__scope);r||this.__bind(e,{node:t,keys:e}),this.__setNodeProperty(t,e,i,n)}},{key:"__getEvaluationComponents",value:function(t){var e=[];return function n(r){r.__getBind(t)&&e.push(r);for(var i=0;i1&&void 0!==arguments[1])||arguments[1],n=t instanceof window.Attr?"value":"nodeValue";if(!e||this.__checkEvaluation(t)){var r=this.__evaluate(t),i=r.res,o=r.attributeValue,s=r.expression,a=r.counter;if(t[n]!=i&&(t[n]=i),t instanceof window.Attr){var l=i,u=!1;1==a&&s&&t.__expression==s&&(l=o);var c=t.nodeName.replace(/^boolean-(.+)/i,"$1"),h=m.toCamelCase(c);if(c!=t.nodeName&&(u=!0,l=!!l),t.__attributeOn){var _=t.__attributeOn;l=_.__prepareAttributeIn(t,l),_.__disableAttributeSetter=!0,_.attrs[h]=l,_.__disableAttributeSetter=!1,_.__isMounted&&_.__attrTriggerByName(h,l)}else if(u){var f=t.__element;l?f.setAttribute(h,"true"):f.removeAttribute(h)}}}return t[n]}},{key:"__prepareAttributeIn",value:function(t,e){return m.copy(e,{plain:!0})}},{key:"__prepareAttributeOut",value:function(t,e){return m.copy(e,{plain:!0})}},{key:"__initializeAttribute",value:function(t,e,n){if(t&&-1==N.indexOf(t.nodeName)&&this.__initializeNode(t,e)){var r=t.nodeName.replace(/^on-(.+)/i,"$1"),i=n||this;if(t.__isEvent){if(t.__event)return;var o=new Ft.EventEmitter(r,t,e,i);return t.__hasBindings&&o.bind((function(n){return i.__evaluateEvent(t,e,n)})),t.__event=o,e.setAttribute(t.nodeName,m.makeAttributeValue(o)),void(n&&(this.__disableAttributeSetter=!0,this.attrs[m.toCamelCase(t.nodeName)]=o,this.__disableAttributeSetter=!1))}n&&(t.__attributeOn=this,t.__attributeOf=i);var s=!!this.__compiling&&this.__compiling.checkChanges;i.__evaluateNode(t,s)}}},{key:"__initializeNode",value:function(t,e){if(t.__initialized)return!0;var n=t instanceof window.Attr,r=t[n?"value":"nodeValue"],i=B.test(r.trim()),o=!!n&&/^boolean-/i.test(t.nodeName),s=!!n&&/^on-(.+)/i.test(t.nodeName);return!!(e.__akili||i||o||s)&&(t.__name=this.__scope.__name+m.createRandomString(16),t.__isEvent=s,t.__hasBindings=i,t.__isBoolean=o,t.__expression=r,t.__properties={},t.__attributeOf=null,t.__attributeOn=null,t.__event=null,t.__initialized=!0,t.__component=this,t.__element=e,!0)}},{key:"__deinitializeNode",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.__initialized&&(t.__event&&t.__event.remove(),t.__hasBindings&&!e.saveBindings&&(this.__unbindByNodes(t),this.__unbindParentsByNodes(t)),Ft.removeTag(t),delete t.__name,delete t.__hasBindings,delete t.__isBoolean,delete t.__isEvent,delete t.__expression,delete t.__properties,delete t.__attributeOf,delete t.__attributeOn,delete t.__event,delete t.__initialized,delete t.__component,delete t.__element)}},{key:"__interpolateAttributes",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=0,r=t.attributes,i=r.length;n2&&void 0!==arguments[2]&&arguments[2];if(!t.__disableAttributeSetter){var i=t.el.getAttributeNode(e);if(r)return i&&t.__deinitializeNode(i),void t.el.removeAttribute(e);i?(i.value=n,t.__deinitializeNode(i)):(t.el.setAttribute(e,n),i=t.el.getAttributeNode(e)),t.__initializeAttribute(i,t.el,t.__attributeOf)}};this.attrs=new Proxy(this.__attrs,{get:function(t,e){return"__isProxy"==e||t[e]},set:function(n,r,i){var o=m.toDashCase(r);return-1!=t.booleanAttributes.indexOf(o)&&(i?t.el.setAttribute(o,i):t.el.removeAttribute(o),o="boolean-".concat(o)),n[r]=i,e(o,m.makeAttributeValue(i)),!0},deleteProperty:function(t,n,r){var i=m.toDashCase(n);return e(i,m.makeAttributeValue(r),!0),delete t[n],!0}})}},{key:"__observe",value:function(t,e){var n=this;return new Proxy(t,{get:function(r,i){if("__isProxy"==i)return!0;if("__target"==i)return t;if("__component"==i)return n;if("__keys"==i)return e;if(n.__isSystemKey(i))return r[i];if(Ft.__evaluation&&!n.__isRemoved){var o=[].concat(e,[i]),s=!1,a=!m.getOwnPropertyTarget(n.__scope,o),l=n;if(r instanceof g){var u=m.getOwnPropertyTarget(r,[i]);u&&u instanceof g&&(l=u.__component)}return Ft.__wrapping&&o.length>1||(i in r&&!m.getEnumerablePropertyTarget(r,[i])&&(s=!0),n.__bindNode(Ft.__evaluation.list,l,o,e,r[i],s,a)),r[i]}return r[i]},set:function(t,r,i){var o=[].concat(l(e),[r]);return n.__isRemoved||n.__isSystemKey(r)||n.__checkDisablement(o)?(t[r]=i,n.__setScopeObjectHash(t,o),!0):n.__isCreated&&void 0!==i&&!Object.prototype.hasOwnProperty.call(t,r)&&r in t?(m.getEnumerablePropertyTarget(t,[r]).__component.scope[r]=i,!1):("function"==typeof i&&(i=Ft.wrapFunction(i)),t[r]=n.__nestedObserve(i,o),n.__isResolved||n.__triggerStoreAndAttr(o),Ft.__isolation?(n.__createIsolationObject(e,r),!0):(n.__setScopeObjectHash(t,o),n.__isResolved&&n.__triggerStoreAndAttr(o),n.__isMounted&&n.__evaluateByKeys(o),!0))},deleteProperty:function(t,r){var i=[].concat(e,[r]);return n.__isRemoved||n.__isSystemKey(r)||n.__checkDisablement(i)?(delete t[r],n.__setScopeObjectHash(t,i),!0):(delete t[r],n.__isResolved||n.__triggerStoreAndAttr(i),Ft.__isolation?(n.__createIsolationObject(e,r),!0):(n.__isResolved&&n.__triggerStoreAndAttr(i),n.__setScopeObjectHash(t,i),n.__evaluateByKeys(i),!0))}})}},{key:"__triggerStoreAndAttr",value:function(t){for(var e=0,n=t.length;e1&&void 0!==arguments[1]?arguments[1]:"proxy";this[this.__getDisablementTypeStore(e)][t?this.__createKeysHash(t):"__all"]=!0}},{key:"__enableKeys",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"proxy";delete this[this.__getDisablementTypeStore(e)][t?this.__createKeysHash(t):"__all"]}},{key:"__checkDisablement",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"proxy",n=this.__getDisablementTypeStore(e);return!!this[n].__all||this[n][this.__createKeysHash(t)]}},{key:"__storeTriggerByKeys",value:function(t,e){if(!this.__checkDisablement(t,"store")){var n=this.__storeLinks[Ft.joinBindingKeys(t)];if(n&&n.length){e=m.copy(e,{plain:!0});for(var r=[],i=0,o=n.length;i2&&void 0!==arguments[2]?arguments[2]:{};if(n=x({get:!0,set:!0},n),!e)throw new Error('Store link "'.concat(t,'" must have the scope property name'));if(!n.get&&!n.set)throw new Error('Store link "'.concat(t,'" must have at least "get" or "set" option as true'));Array.isArray(e)||(e=[e]),this.__disableKeys(e,"store"),(Object.prototype.hasOwnProperty.call(R,t)||!m.hasPropertyByKeys(e,this.__scope))&&this.scope.__set(e,R[t]),this.__enableKeys(e,"store");var r,i=Ft.joinBindingKeys(e);this.__storeLinks[i]||(this.__storeLinks[i]=[]);for(var o=this.__storeLinks[i],s=o.length-1;s>=0;s--){var a=o[s];if(a.component===this&&a.name==t&&a.keyString==i)return void(o[s]=x(x(x({},a),n),{},{date:Date.now()}))}Ft.__storeLinks[t]||(Ft.__storeLinks[t]=[]),r=x(x({},n),{},{component:this,name:t,keys:e,keyString:i,date:Date.now()}),this.__storeLinks[i].push(r),Ft.__storeLinks[t].push(r)}},{key:"__storeByFunction",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=void 0===n.callOnStart?Object.prototype.hasOwnProperty.call(R.__target,t):n.callOnStart;Ft.__storeLinks[t]||(Ft.__storeLinks[t]=[]);for(var i=Ft.__storeLinks[t],o=i.length-1;o>=0;o--){var s=i[o];if(s.component===this&&s.name==t&&s.fn===e)return void(i[o]=x(x(x({},s),n),{},{date:Date.now()}))}if(Ft.__storeLinks[t].push(x(x({},n),{},{component:this,name:t,fn:e,date:Date.now()})),"*"==t&&!1!==n.callOnStart){for(var a=Object.keys(R.__target),l=[],u=0,c=a.length;u=0;i--){var o=r[i],s=Ft.__storeLinks[o.name];if(o.component===this&&o.name==t&&o.keyString==n&&(r.splice(i,1),s&&s.length)){for(var a=s.length-1;a>=0;a--){var l=s[a];l.component===this&&l.keyString==n&&s.splice(a,1)}s.length||delete Ft.__storeLinks[t]}}r.length||delete this.__storeLinks[n]}}},{key:"__unstoreByFunction",value:function(t,e){if(Ft.__storeLinks[t]){for(var n=Ft.__storeLinks[t],r=n.length-1;r>=0;r--){var i=n[r];if(i.component===this&&i.name==t&&i.fn===e){n.splice(r,1);break}}n.length||delete Ft.__storeLinks[t]}}},{key:"__attrTriggerByKeys",value:function(t,e){var n=this;if(!this.__checkDisablement(t,"attr")){var r=this.__attrLinks[Ft.joinBindingKeys(t)];if(r&&r.length)return Ft.isolate((function(){for(var t=0,i=r.length;t2&&void 0!==arguments[2]?arguments[2]:{};if(n=x({get:!0,set:!0},n),t=m.toCamelCase(t),!e)throw new Error('Attribute link "'.concat(t,'" must have the scope property name'));Array.isArray(e)||(e=[e]),this.__disableKeys(e,"attr"),(Object.prototype.hasOwnProperty.call(this.attrs,t)||!m.hasPropertyByKeys(e,this.__scope))&&this.scope.__set(e,this.attrs[t]),this.__enableKeys(e,"attr");var r=Ft.joinBindingKeys(e);this.__attrLinks[r]||(this.__attrLinks[r]=[]);for(var i=this.__attrLinks[r],o=i.length-1;o>=0;o--){var s=i[o];if(s.name==t&&s.keyString==r)return void(i[o]=x(x(x({},s),n),{},{date:Date.now()}))}this.__attrLinks[r].push(x(x({},n),{},{name:t,keys:e,keyString:r,date:Date.now(),component:this}))}},{key:"__attrByFunction",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=m.toCamelCase(t);var i=void 0===r.callOnStart?Object.prototype.hasOwnProperty.call(this.attrs,t):r.callOnStart;this.__attrLinks[t]||(this.__attrLinks[t]=[]);for(var o=this.__attrLinks[t],s=o.length-1;s>=0;s--){var a=o[s];if(a.name==t&&a.fn===e)return void(o[s]=x(x(x({},a),r),{},{date:Date.now()}))}if(this.__attrLinks[t].push(x(x({},r),{},{name:t,fn:e,date:Date.now(),component:this})),"*"==t&&!1!==r.callOnStart){for(var l=Object.keys(this.__attrs).filter((function(t){return!(n.__attrs[t]instanceof Ft.EventEmitter)})),u=[],c=0,h=l.length;c=0;i--){var o=r[i];o.name==t&&o.keyString==n&&r.splice(i,1)}r.length||delete this.__attrLinks[n]}}},{key:"__unattrByFunction",value:function(t,e){if(this.__attrLinks[t]){for(var n=this.__attrLinks[t],r=n.length-1;r>=0;r--){var i=n[r];if(i.name==t&&i.fn===e){n.splice(r,1);break}}n.length||delete this.__attrLinks[t]}}},{key:"__isSystemKey",value:function(t){return t.match&&t.match("^_|#")||"constructor"==t}},{key:"__setScopeObjectHash",value:function(t,e){!t||"object"!=n(t)||t instanceof g||(Object.defineProperty(t,"__hash",{configurable:!0,enumerable:!1,value:m.createHash(t,{ignoreScopeHash:!0})}),e&&(e=e.slice(0,-1),this.__setScopeObjectHash(m.getPropertyByKeys(e,this.__scope),e)))}},{key:"__nestedObserve",value:function(t,e){var r=this;return function t(e,i){if("object"!=n(e)||null===e)return e;if(!(m.isPlainObject(e)||m.isScopeProxy(e)||e instanceof g))return e;var o=e;t:if(e.__isProxy){if(o=e.__target,r.__disableProxyRedefining)break t;e.__component===r&&Ft.joinBindingKeys(i)==Ft.joinBindingKeys(e.__keys)||(e=o=m.copy(o,{nested:!1}))}else r.__disableProxyRedefining||e instanceof g||(e=o=m.copy(o,{nested:!1}));for(var s=Object.keys(o),a=0,u=s.length;a5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]&&arguments[6],a=Ft.joinBindingKeys(r),l=this;if(t.length&&!o){var u=t.length-1,c=t[u];c.bindComponent===this&&c.keysString==a&&(l=c.component),c.keysString==a&&c.component===l&&t.splice(u,1)}t.push({component:l,bindComponent:e,keysString:Ft.joinBindingKeys(n),parents:r,keys:n,value:i,evaluated:s,notBinding:o})}},{key:"__isSystemBindingKey",value:function(t){return"__data"==t}},{key:"__getBind",value:function(t){return m.getPropertyByKeys(t,this.__bindings)||null}},{key:"__getAllBinds",value:function(t){var e=this.__getBind(t);if(!e)return[];var n=[];return function t(e){for(var r in n=n.concat(e.__data||[]),e)Object.prototype.hasOwnProperty.call(e,r)&&"__data"!=r&&t(e[r])}(e),n}},{key:"__getBoundNode",value:function(t,e){var n=m.getPropertyByKeys(t,this.__bindings);if(!n||!n.__data||!n.__data.length)return null;for(var r=0,i=n.__data.length;r3&&void 0!==arguments[3]&&arguments[3],i=this.__getNodeProperty(t,e),o=m.createHash(n);if(i){var s=t.__component.__compareNodePropertyValue(i,n);return i.value=n,i.hash=o,!s}return t.__properties[this.__createKeysHash(e)]={component:this,value:n,hash:o,node:t,keys:e,evaluated:r},!0}},{key:"__getNodeProperty",value:function(t,e){return t.__properties[this.__createKeysHash(e)]||null}},{key:"__deleteNodeProperty",value:function(t,e){var n="scope.".concat(this.__scope.__name,".").concat(Ft.joinBindingKeys(e));delete t.__properties[n]}},{key:"__mapNodes",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n=x({rootAttrs:!0,attrs:!0,node:!0,el:!0},n);!function r(i){if(i){if(n.attrs&&(i!==e.el||n.rootAttrs))for(var o=0,s=i.attributes,a=s.length;o=0;l--){var u=i.childNodes[l];3==u.nodeType?n.node&&t(u):1!=u.nodeType||u.__akili||(r(u),n.el&&t(u))}}}(this.el)}},{key:"__getAllNodes",value:function(){var t=[];return this.__mapNodes((function(e){return t.push(e)})),t}},{key:"__bind",value:function(t,e){m.setPropertyByKeys(t,this.__bindings,(function(t,r){var i={__data:[]};return t?("object"==n(r)&&(i=r),i.__data||(i.__data=[]),i.__data.push(e),i):r||i}))}},{key:"__unbindByNodes",value:function(t){var e=this;t instanceof Node&&(t=[t]);!function n(r,i,o){for(var s=Object.keys(r),a=0,l=s.length;a=0;r--){n[r].component===this&&n.splice(r,1)}n.length||delete t[e]}}},{key:"__remove",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attrs.onRemoved&&this.attrs.onRemoved.trigger(void 0,{bubbles:!1}),this.removed();var e=this.__detach({saveBindings:!0,deinitializeNodes:!0}),n=[].concat(e,this.__empty({saveBindings:!0}));return this.__unbindByNodes(e),!t.saveBindings&&this.__unbindParentsByNodes(n),this.__clearStoreLinks(),this.__scope.__remove(),delete this.__scope,delete this.scope,this.el.remove(),delete this.el.__akili,delete this.el,delete this.__parent,delete this.__attributeOf,delete this.__evaluationComponent,delete this.__evaluationParent,delete this.__parents,delete this.__bindings,delete this.__attrLinks,delete this.__storeLinks,delete this.__attrs,delete this.attrs,this.__isRemoved=!0,n}},{key:"__removeChildren",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[],n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.__parent&&this.__parent.__akili.__spliceChild(this.el);for(var e=[],n=0,r=this.el.attributes.length;n0&&void 0!==arguments[0]?arguments[0]:{},n=this.__removeChildren({saveBindings:!0});return this.__mapNodes((function(e){1!=e.nodeType?e.__initialized&&(t.__deinitializeNode(e,{saveBindings:!0}),n.push(e)):e.remove()}),{rootAttrs:!1}),this.__unbindByNodes(n),!e.saveBindings&&this.__unbindParentsByNodes(n),this.el.innerHTML="",n}},{key:"__getParent",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[],o=0;"object"!=n(r)&&(r=[r]);return function n(s){if(s){if((!r||-1!=r.indexOf(o))&&(!t||s.__akili.matches(t))){if(!e)return void i.push(s.__akili);i.push(s.__akili)}o++,n(s.__akili.__parent)}}(this.__parent),e?i:i[0]||null}},{key:"__getChildren",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=[],o=0;"object"!=n(r)&&(r=[r]);return function n(s){for(var a=0,l=s.length;a0&&void 0!==arguments[0]?arguments[0]:"",e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.__parent)return null;var r=this.__parent.__akili.__children.slice(),i=[];n&&r.reverse();for(var o=0,s=r.length;o0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getParent(t,!1,e)}},{key:"parents",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getParent(t,!0,e)}},{key:"child",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getChildren(t,!1,e)}},{key:"children",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.__getChildren(t,!0,e)}},{key:"before",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!0,!1)}},{key:"after",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!0,!0)}},{key:"prev",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!1,!1)}},{key:"next",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.__getNear(t,!1,!0)}},{key:"appendTo",value:function(t){return t.appendChild(this.el),Ft.compile(this.el,{recompile:{setParents:!0,checkChanges:!1}})}},{key:"cancel",value:function(){this.__cancelled=!0}},{key:"prevent",value:function(){this.__prevent=!0}},{key:"empty",value:function(){return this.__empty.apply(this,arguments)}},{key:"remove",value:function(){return this.__remove.apply(this,arguments)}},{key:"created",value:function(){}},{key:"compiled",value:function(){}},{key:"recompiled",value:function(){}},{key:"resolved",value:function(){}},{key:"removed",value:function(){}},{key:"transition",get:function(){return this.__scope&&this.__scope.__transition||null}},{key:"isCreated",get:function(){return this.__isCreated}},{key:"isCompiled",get:function(){return this.__isCompiled}},{key:"isResolved",get:function(){return this.__isResolved}},{key:"isRemoved",get:function(){return this.__isRemoved}}],[{key:"define",value:function(){Ft.component("component",t)}},{key:"parse",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=[],i=[],o=m.split(e,";",['"',"'","`"]);for(var a in o[o.length-1]="return ".concat(o[o.length-1]),n)r.push(a),i.push(n[a]);return s(Function,r.concat(["".concat(o.join("; "))])).apply(t,i)}}]),t}();function H(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function I(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},U(t)}function D(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}i(K,"matches",""),i(K,"booleanAttributes",[]),i(K,"events",[]),i(K,"controlAttributes",!1),i(K,"transparent",!1),i(K,"template",""),i(K,"templateUrl",""),i(K,"scope",null),i(K,"ssr",!0);var M=function(t){H(n,t);var e=D(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;on){var i=this.iterators[n];return i.setIndex(this.__index===i.index),i.setKey(this.__key===i.key),i.setValue(m.compare(this.__hash,i.hash)),{promise:r,iterator:i}}var o=this.iteratorEl.cloneNode();return o.innerHTML=this.html,this.el.insertBefore(o,this.el.children[this.iteratorIndex+this.iterators.length]),r=Ft.compile(o),this.iterators.push(o.__akili),{promise:r,iterator:o.__akili}}},{key:"drawChunk",value:function(t){var e=this;if(this.__isRemoved)return Promise.resolve();var r=Object.keys(this.data),i=r.length;if(t==i)return this.__removeExcessIterators(),Promise.resolve(this.__completeDrawing());var o=[],s=t+ +(this.attrs.chunks||i);s>i&&(s=i);for(var a=this.__stepIterationChunk.bind(this),l=function(){var t=r[u],n=u+1,l=e.loop(t,e.data[t],u);return l.iterator.iterate(u),o.push(l.promise),n!=s?"continue":(n==i&&(e.__removeExcessIterators(),a=e.__completeDrawing.bind(e)),{v:Promise.all(o).then((function(){return a(n)}))})},u=t;u=0;r--){var i=this.el.options[r],o=!!i.getAttribute("selected");!e||e.includes(i.value)?e?(i.selected=!0,n.push(i.value)):(i.selected=o,o&&n.push(i.value)):i.selected=!1}this.changeValue(this.formatValue(n))}},{key:"setMultiple",value:function(){this.changeValue(this.formatValue(m.copy(this.el.content)))}},{key:"setValue",value:function(t){if(void 0!==t||this.__isCompiled){var e=this.formatValue(t);this.changeValue(e,!m.compare(e,t))}}},{key:"createIteratorElement",value:function(){var t=F(U(n.prototype),"createIteratorElement",this).apply(this,arguments);return t.hasAttribute("value")||t.setAttribute("value",this.html.trim()),t}},{key:"getContent",value:function(){if(!this.attrs.multiple)return this.el.value;for(var t=[],e=0,n=this.el.options.length;e=0;i--)e[t[i]]||t.splice(i,1);return t}},{key:"redefine",value:function(){this.el.querySelector("[selected]")||(this.el.value=this.getDefaultValue()),this.changeValue(this.getContent())}},{key:"getDefaultValue",value:function(){var t=this.el.options[0];return this.attrs.multiple?[]:t?t.value:void 0}},{key:"changeValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(m.compare(this.el.content,t)){if(!e)return}else{if(Array.isArray(t)){this.el.value=t[t.length-1];for(var n=0,r=this.el.options.length;n${this.__content}'),nt.RadioButton=rt;var ot=function(t){H(n,t);var e=it(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("textarea",this)}}]),n}(J);function st(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var at=function(t){H(n,t);var e=st(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;or&&(t=r),t<=0)return this.el.focus();this.walkTextNodes(this.el,(function(t){return n.push(t)}));for(var i=0;in[i].nodeValue.length&&n[i+1])){e=n[i];break}t-=n[i].nodeValue.length}var o=document.createRange(),s=window.getSelection();o.setStart(e,t),o.setEnd(e,t),s.removeAllRanges(),s.addRange(o),this.el.focus()}}],[{key:"define",value:function(){Ft.component("content",this),Ft.alias("[contenteditable]","content")}}]),n}(J);function lt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var ut=function(t){H(n,t);var e=lt(n);function n(){u(this,n);for(var t=arguments.length,r=new Array(t),i=0;i=0;e--)this.constructor.__activeUrlLoading[e].component===this&&(this.constructor.__activeUrlLoading.splice(e,1),t=!0);t&&window.dispatchEvent(new CustomEvent("akili-url-loading",{detail:{name:this.chunkName,component:this}}))}}},{key:"addChunk",value:function(){var t=this;this.chunk||(this.chunk=!0,this.chunkListener=function(e){e.detail.name==t.chunkName&&e.detail.component!==t&&t.checkChunk()},window.addEventListener("akili-url-loading",this.chunkListener))}},{key:"checkChunk",value:function(){var t=this;if(this.chunk&&!this.finished){var e=this.constructor.__activeUrlLoading.filter((function(e){return e.name==t.chunkName}));this.constructor.__activeUrlLoading.find((function(e){return e.component===t}))||e.length>=this.chunkSize||(this.constructor.__activeUrlLoading.push({name:this.chunkName,component:this}),this.setUrlAttribute(this.attrs[this.handlerAttribute]))}}},{key:"setLoading",value:function(t){"viewport"==t?this.addViewport():this.removeViewport(),"chunk"==t?this.addChunk():this.removeChunk()}},{key:"setUrl",value:function(t){return this.abort(),this.removeChunkFromQueue(),this.finished=!1,this.viewport&&!this.isIntersecting?this.setUrlAttribute():this.chunk?(this.checkChunk(),this.setUrlAttribute()):void this.setUrlAttribute(t)}},{key:"setUrlAttribute",value:function(t){this.el.style.opacity=0,void 0!==t&&(!1===t?this.cancelling=!0:(this.cancelling=!1,this.timeout&&(this.loadingTimeout=setTimeout(this.onTimeout.bind(this),this.timeout))),this.isLoading=!0,this.attrs[this.urlAttribute]=t)}},{key:"setChunkName",value:function(t){if(!this.isCompiled||!this.chunk)return this.chunkName=t;this.abort(),this.removeChunkFromQueue(),this.chunkName=t,this.checkChunk()}},{key:"setChunkSize",value:function(t){if(!this.isCompiled||!this.chunk)return this.chunkSize=+t;this.abort(),this.removeChunkFromQueue(),this.chunkSize=+t,this.checkChunk()}},{key:"setTimeout",value:function(t){this.timeout=+t}},{key:"abort",value:function(){this.isLoading&&(this.setUrlAttribute(!1),this.attrs.onAbort.trigger())}}]),n}(K);function _t(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}i(ht,"matches","[url],[urlset]"),i(ht,"events",["timeout","abort"]),i(ht,"booleanAttributes",["hidden-error"]),i(ht,"__activeUrlLoading",[]);var ft=function(t){H(n,t);var e=_t(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("iframe",this)}}]),n}(ht);function pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var vt=function(t){H(n,t);var e=pt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("img",this)}}]),n}(ht);function dt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var yt=function(t){H(n,t);var e=dt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("embed",this)}}]),n}(ht);function mt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var gt=function(t){H(n,t);var e=mt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("audio",this)}}]),n}(ht);function bt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var kt=function(t){H(n,t);var e=bt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("video",this)}}]),n}(ht);function wt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var Ot=function(t){H(n,t);var e=wt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("track",this)}}]),n}(ht);function Pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var At=function(t){H(n,t);var e=Pt(n);function n(){return u(this,n),e.apply(this,arguments)}return h(n,null,[{key:"define",value:function(){Ft.component("source",this)}}]),n}(ht);function St(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var jt=function(t){H(n,t);var e=St(n);function n(){var t;u(this,n);for(var r=arguments.length,i=new Array(r),o=0;o1&&void 0!==arguments[1])||arguments[1],r=t.path.state;return this.__scope.__transition={parent:function t(e){return e.parent?e.parent.component?e.parent.component.__scope.__transition.path:t(e.parent):null}(t.path),state:t.path.state,data:t.path.data,url:t.path.url,params:t.path.params,query:t.path.query,hash:t.path.hash},n?Promise.resolve().then((function(){return r.template?r.template:r.templateUrl?P.get(r.templateUrl).then((function(t){return t.data})):void 0})).then((function(t){return function(t){e.empty();var n="component";if(r.component){var i=!1;for(var o in Ft.__components)if(Ft.__components[o]===r.component){n=o,i=!0;break}if(!i)throw new Error('Router state "'.concat(r.name,'" has no defined component'))}return e.el.innerHTML="<".concat(n,">").concat(t,""),Ft.compile(e.el,{recompile:!0})}(t)})):Ft.compile(this.el,{recompile:{checkChanges:!0,route:this}})}}],[{key:"define",value:function(){Ft.component("route",this)}}]),n}(K);function Lt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ct(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:null;u(this,t),this.url=e,this.previous=n,this.path=null,this.routes=[],this.states={},this.__cancelled=!1,this.__finished=!1}return h(t,[{key:"redirect",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return i=Ct(Ct({},this.path.options),i),this.cancel(),Bt.state.call(Bt,t,e,n,r,i)}},{key:"reload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return r=Ct(Ct({},this.path.options),r),t=Ct(Ct({},this.path.params),t),e=Ct(Ct({},this.path.query),e),n=void 0===n?this.path.hash:n,this.redirect(this.path.state.name,t,e,n,r)}},{key:"setPath",value:function(t){t.parent=this.path||null,this.path=Ct({params:{},query:{}},t),this.routes.push(this.path),this.states[this.path.state.name]=this.path}},{key:"getRoute",value:function(t){for(var e=0,n=this.routes.length;e=0&&Bt.__queue.splice(t,1)}}]),t}(),Bt={baseUrl:"/",states:[],hashMode:!0,transition:null,__info:{},__queue:[],__redirects:0,__init:!1,__paramRegex:/(\/?:([\w\d-]+))/g,__routeSelector:function(t){return t instanceof Et},add:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"==n(t)&&(e=(r=t).pattern,t=r.state,delete r.pattern,delete r.state),!t)throw new Error("Router state must have a name");if(Ft.options.debug&&r.component&&(r.template||r.templateUrl)&&console.warn('Router state "'.concat(t,'" must only have a component or template option')),r.template||r.templateUrl||r.component||(r.abstract=!0),this.has(t))throw new Error('Router state "'.concat(t,'" is already exists'));return this.setState(t,e,Ct(Ct({},{template:"",templateUrl:"",abstract:!1,component:null,params:{},query:{},handler:function(){},options:{}}),r)),this},remove:function(t){for(var e=0,n=this.states.length;e1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if("object"!==n(t)&&(t=this.getState(t)),!t)throw new Error("Not found route state with name ".concat(t));(s=Ct({},s)).manual=!0;var a=this.prepareStateArgs(t,r,i,o,s,!1);r=a.params,i=a.query,o=a.hash,s=a.options;var l=this.createStateUrl(t,r,i,o,s);return this.isolate((function(){return e.setUrl(l)})),this.changeState(s)},back:function(){return window.history.back.apply(window.history,arguments)},go:function(){return window.history.go.apply(window.history,arguments)},forward:function(){return window.history.forward.apply(window.history,arguments)},location:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(n=Ct({},n)).manual=!0,this.isolate((function(){return e.setUrl(t)})),this.changeState(n)},init:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=window.history.pushState;window.history.pushState=function(){var t=r.apply(this,arguments);return Bt.changeState().catch((function(t){return console.error(t)})),t},this.__onStateChangeHandler=function(){t.changeState().catch((function(t){return console.error(t)}))},this.defaultUrl=e,this.hashMode=n,this.states.sort((function(t,e){return(t=t.name.split(".").length)-(e=e.name.split(".").length)}));for(var i=0,o=this.states.length;i2&&void 0!==arguments[2]?arguments[2]:{}),{},{name:t,pattern:e});return this.states.push(n),this.__init&&this.initState(n),n},removeState:function(t){for(var e=0,n=this.states.length;e1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];if("object"!==n(t)&&(t=this.getState(t)),o=Ct({},o),s){var a=this.prepareStateArgs(t,e,r,i,o);e=a.params,r=a.query,i=a.hash,o=a.options}var l=t.fullPattern.replace(this.__paramRegex,(function(t,n,r){return"/"+(e[r]||"")}));return l=l.replace(/^\^/,""),l=this.splitSlashes(l),Object.keys(r).length&&(l+="?"+P.paramsToQuery(r)),!this.hashMode&&i&&(l+="#"+i.replace("#","")),l},prepareStateArgs:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o={params:e,query:n,hash:r,options:i},s=0;s<4^4;s++){var a=this.prepareStateParams(t,e,o),l=this.prepareStateQuery(t,n,o),u=this.prepareStateHash(t,r,o),c=this.prepareStateOptions(t,i,o);null===u?c.emptyHash=null:""===u&&(c.emptyHash="");var h={params:a,query:l,hash:u,options:c};if(m.compare(h,o))break;o=h}return o},prepareStateParams:function(t,e,r){"object"!==n(t)&&(t=this.getState(t));var i=t.name.split(".");e=Object.assign({},e);for(var o=i.length-1;o>=0;o--){var s=i.slice(0,i.length-o).join(".");e=this.createStateObjectArgs(e,this.getState(s).params,r)}return e},prepareStateQuery:function(t,e,r){"object"!==n(t)&&(t=this.getState(t));var i=t.name.split(".");e=Object.assign({},e);for(var o=i.length-1;o>=0;o--){var s=i.slice(0,i.length-o).join(".");e=this.createStateObjectArgs(e,this.getState(s).query,r)}return e},prepareStateOptions:function(t,e,r){"object"!==n(t)&&(t=this.getState(t));var i=t.name.split(".");e=Object.assign({},e);for(var o=i.length-1;o>=0;o--){var s=i.slice(0,i.length-o).join(".");e=this.createStateObjectArgs(e,this.getState(s).options,r)}return e},createStateObjectArgs:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{params:{},query:{},options:{}},r=Object.assign({},t);for(var i in e){var o=e[i];null!==r[i]&&("function"==typeof o&&(r[i]=o(n)),void 0===r[i]&&(r[i]=o))}for(var s in r)null===r[s]&&delete r[s];return r},prepareStateHash:function(t,e,r){if(null===e)return e;"object"!==n(t)&&(t=this.getState(t));for(var i=t.name.split("."),o=i.length-1;o>=0;o--){var s=i.slice(0,i.length-o).join(".");e=this.createStateHashArgs(e,this.getState(s).hash,r)}return e},createStateHashArgs:function(t,e){return null===t?t:"function"==typeof e?e(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{params:{},query:{}}):void 0===t?e:t},splitSlashes:function(t){return t.replace(/[/]+/g,"/")},getPatternContent:function(t,e){"object"!==n(t)&&(t=this.getState(t));var r=[],i={};e=(e=e.split("?")[0]).split("#")[0];var o=t.fullPattern.replace(this.__paramRegex,(function(t,e,n){return r.push(n),"/?([^/]*)"}));o=o.replace(/([^^/]+)[/]+$/,"$1");var s=new RegExp(o,"g");return e.match(s)?(e.replace(s,(function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o1&&void 0!==arguments[1]&&arguments[1];"object"!==n(t)&&(t=this.getState(t));var r=Bt.transition&&!Bt.transition.__finished?Bt.transition.url:this.getUrl();r=this.splitSlashes("/"+r.split("?")[0]+"/");var i=t.fullPattern.replace(this.__paramRegex,"/?([^/]*)");i=i.replace(/^\^/,"").replace(/\$$/,"");var o=e?i:this.splitSlashes("^/"+i+"/$");return new RegExp(o).test(r)},inActiveState:function(t){return Bt.isActiveState(t,!0)},getRoute:function(t){var e=this,n=0;return function r(i){var o=i.child(e.__routeSelector);return o?n==t?o:(n++,r(o)):null}(Ft.root)},getArrayPatternContent:function(t,e){for(var n=0,r=t.length;nt)break;e.push(i)}}return e},reload:function(){var t;if(!this.transition)throw new Error("Not found an active transition to reload the state");return(t=this.transition).reload.apply(t,arguments)},isolate:function(t){var e;this.__isolated=!0;try{e=t()}catch(t){throw this.__isolated=!1,t}return this.__isolated=!1,e},changeState:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.__isolated)return Promise.resolve();var n=this.getUrl(),r=new xt(n);return this.__queue.push(r),new Promise((function(e){var n=setInterval((function(){t.__queue[0]===r&&(clearInterval(n),e())}))})).then((function(){r.previous=Bt.transition||null,Bt.transition=r,window.dispatchEvent(new CustomEvent("state-change",{detail:r}));var i=e.emptyHash;if(!t.__redirects){var o=getComputedStyle(document.documentElement);t.__info.scrollPos={left:window.scrollX,top:window.scrollY},t.__info.docMinHeight=o.minHeight,t.__info.docMinWidth=o.minWidth,document.documentElement.style.minHeight=document.documentElement.offsetHeight+"px",document.documentElement.style.minWidth=document.documentElement.offsetWidth+"px"}var s={},a=t.getUrlQuery(),l=t.hashMode?"":window.location.hash.replace("#",""),u=0;return function o(c){if(!c.length)return Promise.resolve();var h=t.getArrayPatternContent(c,n);if(!h)return Promise.resolve();var _=h.state;r.setPath({state:_,component:v}),s=Ct(Ct({},s),h.params),l=l||i;var f=t.prepareStateArgs(_,s,a,l,e);s=f.params,a=f.query,l=f.hash,(e=f.options).init=null===Ft.__init,l=l||"";var p=t.createStateUrl(_,s,a,l,e,!1);t.isolate((function(){return t.replaceUrl(p)}));var v=_.abstract?null:t.getRoute(u);if(!v&&!_.abstract)throw new Error('Not found route component for state "'.concat(_.name,'"'));r.path.params=s,r.path.query=a,r.path.hash=l,r.path.url=p,r.path.options=e,!_.abstract&&u++;var d=!0;p!=n&&(d=r.isRouteChanged(r.path));var y=d&&!1!==e.reload,m=r.previous&&r.previous.path?r.previous.path.data:void 0;return Promise.resolve(y?_.handler(r):m).then((function(t){if(r.path.data=t,!r.__cancelled&&(void 0!==_.title&&(document.title="function"==typeof _.title?_.title(r):_.title),!_.abstract)){var n=r.previous&&r.previous.getRoute(_);return(n&&!n.loaded||!0===e.reload)&&(y=!0),v.setTransition(r,y).then((function(){return r.path.loaded=!0}))}})).then((function(){return o(_.children)}))}(t.getStatesByLevel(0)).then((function(){if(!r.routes.length){if(t.__redirects)throw new Error('Wrong router default url "'.concat(t.defaultUrl,'"'));if(t.defaultUrl){if(t.defaultUrl==t.getUrl())throw new Error("Not found any routes");return t.isolate((function(){return t.replaceUrl(t.defaultUrl)})),t.__redirects++,r.finish(),t.changeState(e)}Ft.options.debug&&console.warn('Not found a default route. You can pass it in "router.init(defaultUrl)" function')}return!t.hashMode&&r.path&&r.path.hash||!1===e.reload&&void 0===e.saveScrollPosition||null===e.saveScrollPosition||window.scrollTo(Ct({},e.saveScrollPosition?t.__info.scrollPos:{top:0,left:0})),document.documentElement.style.minHeight=t.__info.docMinHeight,document.documentElement.style.minWidth=t.__info.docMinWidth,t.__redirects=0,t.__info={},window.dispatchEvent(new CustomEvent("state-changed",{detail:r})),r.finish(),r}))})).catch((function(t){throw r&&r.finish(),t}))},deinit:function(){window.removeEventListener("popstate",this.__onStateChangeHandler),this.__init=!1}};Bt.Transition=xt;const Tt=Bt;function Nt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=U(t);if(e){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I(this,n)}}var Kt=function(t){H(r,t);var e=Nt(r);function r(){var t;u(this,r);for(var n=arguments.length,i=new Array(n),o=0;o1&&void 0!==arguments[1])||arguments[1],n=[];return function t(r){r.parentNode&&(r.parentNode.__akili&&(n.push(r.parentNode),!e)||t(r.parentNode))}(t),e?n:n[0]},qt.setTemplate=function(t,e){return e=e.replace(/\${(((?!\${)\s*this\.__content\s*)*)}/,t.innerHTML),t.innerHTML=e,t.innerHTML},qt.createScopeName=function(){var t=this;return m.createRandomString(16,(function(e){return!!t.__scopes[e]}))},qt.isolate=function(t){var e,n=this.__isolation;!n&&(this.__isolation={});try{if(e=t(),n)return e}catch(t){throw this.__isolation=null,t}var r=[];for(var i in this.__isolation)r.push(this.__isolation[i]);this.__isolation=null;for(var o=0,s=r.length;o2&&void 0!==arguments[2]?arguments[2]:{}).recompile,r=t.__akili;if(r){if(n){var i=!0===n?{}:n;return i.root=e,i.initiator=e.__akili,r.__recompile(i),r}}else{var o=t===this.__root,s=m.toDashCase(t.getAttribute("component")||t.tagName.toLowerCase()),a=this.__components[s];t:if(!a){var l=Object.keys(this.__aliases);if(!l.length)break t;var u=l.join(",");if(!t.matches(u))break t;for(var c=0,h=l.length;c1&&void 0!==arguments[1]?arguments[1]:{recompile:!1},r=[];if(window.AKILI_SSR)for(var i=t.querySelectorAll("[no-ssr]"),o=0,s=i.length;o=0;e--){var n=r[e];t.push(n.__resolve())}return Promise.all(t)}))},qt.component=function(t,e){if(t=t.toLowerCase(),!e)return this.__components[t]||null;this.__components[t]&&qt.options.debug&&console.warn("Component ".concat(t," already was added")),this.__components[t]=e},qt.removeComponent=function(t){delete this.__components[t]},qt.alias=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!(e=e.toLowerCase()))return this.__aliases[t]||null;this.__aliases[t]&&qt.options.debug&&console.warn("Alias with selector ".concat(t," already was added")),this.__aliases[t]=e},qt.removeAlias=function(t){delete this.__aliases[t]},qt.isolateArrayPrototype=function(){var t=this;this.__window.Array={prototype:{}};for(var e=Object.getOwnPropertyNames(Array.prototype),n=function(){var n=e[r],i=Array.prototype[n];if("function"!=typeof i||"constructor"==n)return"continue";t.__window.Array.prototype[n]=i,Array.prototype[n]=function(){var t=arguments,e=this;return qt.unevaluate((function(){return e.__isProxy?qt.isolate((function(){return i.apply(e,t)})):i.apply(e,t)}))}},r=0,i=e.length;r1&&void 0!==arguments[1]?arguments[1]:"last";return function(){var n=[].slice.call(arguments);!Array.isArray(e)&&(e=[e]);for(var r=function(){var t=e[i],r=t,o=n[t];if("last"==t&&(r=n.length-1,o=n[r]),"function"!=typeof o)return"continue";o.__isolated||(n[r]=function(){var t=arguments;return qt.isolate((function(){return o.apply(o,t)}))},Object.defineProperty(n[r],"__isolated",{enumerable:!1,value:o}))},i=0,o=e.length;i1&&void 0!==arguments[1]?arguments[1]:{},r=t;if("function"==typeof t){if((t=this.wrapFunction(t,e))===r)return t}else if(!t||"object"!=n(t)||Array.isArray(t))return t;for(var i=Object.getOwnPropertyNames(t),o=0,s=i.length;o1&&void 0!==arguments[1]?arguments[1]:{};if(t.__akili)return t;var n=function(){var n=arguments,r=this;return e.tag&&qt.__evaluation&&qt.addTag(e.tag,qt.__evaluation.node),qt.wrapping((function(){return t.apply(r,n)}))},r=Object.keys(t);n.prototype=t.prototype;for(var i=0,o=r.length;i=0;e--)this.__root.removeAttribute(this.__root.attributes[e].name);var n=(new DOMParser).parseFromString(t,"text/html").querySelector(this.__root===document.body?"body":"body > *");this.__root.innerHTML=n.innerHTML;for(var r=n.attributes.length-1;r>=0;r--){var i=n.attributes[r];this.__root.setAttribute(i.name,i.value)}},qt.initServerSideRequestCache=function(t){var e=function(t,e){for(var n in e)t.__cache[n]=e[n]};for(var n in t){e("__main"===n?P:P.__instances[n],t[n])}},qt.prepareServerSideHtml=function(){return this.__root.outerHTML},qt.prepareServerSideRequestCache=function(){var t={__main:P.__cache};for(var e in P.__instances)t[e]=P.__instances[e].__cache;return t};const Ft=qt;return window.Akili=qt,qt.define(),qt.handleErrors(),qt.isolateGlobals(),e=e.default})())); \ No newline at end of file diff --git a/package.json b/package.json index 6e39351..ee21c75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "akili", - "version": "1.2.33", + "version": "1.2.34", "description": "Akili - javascript framework", "main": "./src/akili.js", "author": { diff --git a/src/components/a.js b/src/components/a.js index 99f3bf2..917ec52 100644 --- a/src/components/a.js +++ b/src/components/a.js @@ -38,23 +38,9 @@ export default class A extends Component { } compiled() { - this.el.addEventListener('click', e => { - e.preventDefault(); - - if (this.isUrl) { - router.location(this.attrs.url, this.options); - return; - } - - if(this.attrs.state) { - router.state(this.state.name, this.params, this.query, this.hash, this.options); - return; - } - - router.reload(this.params, this.query, this.hash, this.options); - }); - - this.onStateChanged = () => this.state && this.setActivity(); + this.onClickListener = this.onClick.bind(this); + this.onStateChanged = () => this.state && this.setActivity(); + this.el.addEventListener('click', this.onClickListener); window.addEventListener('state-changed', this.onStateChanged); this.attr('state', this.setState); @@ -73,6 +59,23 @@ export default class A extends Component { removed() { window.removeEventListener('state-changed', this.onStateChanged); + this.el.removeEventListener('click', this.onClickListener); + } + + onClick(e) { + e.preventDefault(); + + if (this.isUrl) { + router.location(this.attrs.url, this.options); + return; + } + + if(this.attrs.state) { + router.state(this.state.name, this.params, this.query, this.hash, this.options); + return; + } + + router.reload(this.params, this.query, this.hash, this.options); } setUrl(url) { diff --git a/src/components/include.js b/src/components/include.js index c60590f..e00e287 100644 --- a/src/components/include.js +++ b/src/components/include.js @@ -8,16 +8,17 @@ import request from '../services/request.js'; * {@link https://akilijs.com/docs/components#docs_html_templates} * * @tag include - * @selector include[url]:not([html]),[html]:not([url]) + * @selector [url],[html],[inject] * @attr {string} [url] - template path * @attr {string} [html] - html to append + * @attr {string} [inject] - inject component by name * @attr {number|function|boolean} [cache] - request cache {@link https://akilijs.com/docs/requests#docs_cache} * @message {void} load - sent on the template load * @message {Error} error - sent on error */ export default class Include extends Component { static transparent = true; - static matches = '[url]:not([html]),[html]:not([url])'; + static matches = '[url],[html],[inject]'; static events = ['load', 'error']; static define() { @@ -26,17 +27,33 @@ export default class Include extends Component { constructor(...args) { super(...args); + } + + created() { this.html = this.el.innerHTML; + + if(this.el.getAttribute('inject')) { + this.injected = this.el.querySelector('*'); + } + this.el.innerHTML = ''; this.connection = null; } compiled() { this.attr('cache', this.setCache); + this.attr('inject', this.setInject); this.attr('html', this.setHtml); return this.attr('url', this.setTemplate); } + setInject(name) { + this.injected.setAttribute('component', name); + this.empty(); + this.el.innerHTML = this.injected.outerHTML; + return Akili.compile(this.el, { recompile: true }); + } + setCache(cache) { this.cache = cache; } diff --git a/src/components/radio.js b/src/components/radio.js index 56b61da..c993304 100644 --- a/src/components/radio.js +++ b/src/components/radio.js @@ -30,23 +30,8 @@ export default class Radio extends For { } created() { - this.el.addEventListener('change', () => { - if(this._disableInternalEvents) { - return; - } - - let value = this.getRadioValue(); - - if (value === this.prevValue) { - return; - } - - this.prevValue = value; - - if(this.attrs.value === undefined || this.__isResolved) { - this.attrs.onRadio.trigger(value, { bubbles: true }); - } - }); + this.onChangeListener = this.onChange.bind(this); + this.el.addEventListener('change', this.onChangeListener); if(this.iterable) { return super.created.apply(this, arguments); @@ -68,6 +53,29 @@ export default class Radio extends For { return this.attr('in', this.setIn, { callOnStart: false }); } + removed() { + this.el.removeEventListener('change', this.onChangeListener); + return super.removed.apply(this, arguments); + } + + onChange() { + if(this._disableInternalEvents) { + return; + } + + let value = this.getRadioValue(); + + if (value === this.prevValue) { + return; + } + + this.prevValue = value; + + if(this.attrs.value === undefined || this.__isResolved) { + this.attrs.onRadio.trigger(value, { bubbles: true }); + } + } + setIn(data) { return this.draw(data).then(this.redrawRadio.bind(this)); } diff --git a/src/components/select.js b/src/components/select.js index e66f69d..16ef1f5 100644 --- a/src/components/select.js +++ b/src/components/select.js @@ -28,7 +28,8 @@ export default class Select extends For { } created() { - this.el.addEventListener('change', () => this.el.content = this.getContent()); + this.onChangeListener = this.onChange.bind(this); + this.el.addEventListener('change', this.onChangeListener); if(this.iterable) { return super.created.apply(this, arguments); @@ -43,6 +44,15 @@ export default class Select extends For { return this.attr('in', this.setIn); } + removed() { + this.el.removeEventListener('change', this.onChangeListener); + return super.removed.apply(this, arguments); + } + + onChange() { + this.el.content = this.getContent() + } + setIn(data) { return this.draw(data).then(this.redrawSelect.bind(this)); } diff --git a/src/components/text.js b/src/components/text.js index 5461d0a..53fe588 100644 --- a/src/components/text.js +++ b/src/components/text.js @@ -23,9 +23,10 @@ export default class Text extends Component { created() { if(this.el.hasAttribute('on-debounce')) { - this.el.addEventListener('input', utils.debounce(() => { - this.attrs.onDebounce.trigger(undefined, { bubbles: true }); - }, this.debounceInterval)); + this.onInputListener = utils.debounce(() => { + !this.isRemoved && this.attrs.onDebounce.trigger(undefined, { bubbles: true }); + }, this.debounceInterval).bind(this); + this.el.addEventListener('input', this.onInputListener); } } @@ -35,6 +36,10 @@ export default class Text extends Component { this.attr('debounce', this.setDebounce); } + removed() { + this.el.removeEventListener('input', this.onInputListener); + } + setDebounce(interval) { this.debounceInterval = +interval; } diff --git a/test/app/all.js b/test/app/all.js index f68f64d..a8b7f8f 100644 --- a/test/app/all.js +++ b/test/app/all.js @@ -38,6 +38,12 @@ export default class All extends Component { `; + this.el.innerHTML += ` + +
+
+ `; + this.el.innerHTML += `
diff --git a/test/components.js b/test/components.js index 99a2a1c..20f44b7 100644 --- a/test/components.js +++ b/test/components.js @@ -107,7 +107,11 @@ describe('components/', () => { }); it('should load an html', () => { - assert.equal(component.child('include').el.querySelector('test').textContent, '1'); + assert.equal(component.child('include[html]').el.querySelector('test').textContent, '1'); + }); + + it('should inject a component', () => { + assert.equal(component.child('include[inject]').child().data[0], '1'); }); });