/* Riot v4.0.5, @license MIT */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.riot={}))})(this,function(a){'use strict';function b(a){return Array.isArray(a)?a:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(a))&&"number"==typeof a.length?Array.from(a):[a]}function c(a,c,d){const e="string"==typeof c?[c]:c;return qa(b(a).map(a=>qa(e.map(b=>a[d](b)))))}function d(a,c,d){const e="object"==typeof c?c:{[c]:d},f=Object.keys(e);return b(a).forEach(a=>{f.forEach(b=>a.setAttribute(b,e[b]))}),a}function e(a,b){return c(a,b,"getAttribute")}function f(a,b){return typeof a===b}function g(a){return f(a,"function")}function h(a){throw new Error(a)}function i(a){return g(a)?a.prototype&&a.prototype.constructor?new a:a():a}function j(a){return a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function k(a){return a.replace(/-(\w)/g,(a,b)=>b.toUpperCase())}function l(a,b){return Object.entries(b).forEach(b=>{let[c,d]=b;a[c]||(a[c]=d)}),a}function m(){return this}function n(a,b){return b.forEach(b=>{a[b]=a[b].bind(a)}),a}function o(a,b,c,d){return void 0===d&&(d={}),Object.defineProperty(a,b,Object.assign({value:c,enumerable:!1,writable:!1,configurable:!0},d)),a}function p(a){let{name:b,value:c}=a;return{name:k(b),value:c}}function q(a,b,c){return Object.entries(b).forEach(b=>{let[d,e]=b;o(a,d,e,c)}),a}function r(a){return a.reduce((a,b)=>{const{value:c}=b;if(!b.name)return Object.assign({},a,c);const d=p({value:c,name:b.name});return a[d.name]=d.value,a},{})}function s(a){return Array.from(a.attributes).reduce((a,b)=>{const c=p(b);return a[c.name]=c.value,a},{})}function t(a){return e(a,ma)||a.tagName.toLowerCase()}function u(a){const b=a.childNodes;Array.from(b).forEach(b=>a.removeChild(b))}function v(a,b){return(c,d)=>{if(0>d){const{template:c,context:d}=a.pop();c.unmount(d,b,null)}return c}}function w(a,b){return Array.from(a.values()).map(a=>{let{template:c,context:d}=a;return c.unmount(d,b,!0)})}function x(a,b){return!!a&&!1===!!a(b)}function y(a,b){let{itemName:c,indexName:d,index:e,item:f}=b;return a[c]=f,d&&(a[d]=e),a}function z(a,b,c,d){const{condition:e,template:f,childrenMap:g,itemName:h,getKey:i,indexName:j,root:k}=d,l=new Map,m=[],n=[];return a.forEach((a,d)=>{const o=y(Object.create(b),{itemName:h,indexName:j,index:d,item:a}),p=i?i(o):d,q=g.get(p);if(x(e,o))return;const r=q?q.template:f.clone(),s=q?r.el:k.cloneNode();q?m.push(()=>r.update(o,c)):m.push(()=>r.mount(s,o,c)),n.push(s),g.delete(p),l.set(p,{template:r,context:o,index:d})}),{newChildrenMap:l,batches:m,futureNodes:n}}function A(a,b){const c=b.parentNode;c.insertBefore(a,b),c.removeChild(b)}function B(a,b){Object.entries(b).forEach(b=>{let[c,d]=b;return D(a,{name:c},d)})}function C(a,b){Object.keys(b).forEach(b=>a.removeAttribute(b))}function D(a,b,c,d){let{name:e}=b;return e?void("boolean"==typeof c&&(a[e]=c),a[E(c)](e,F(e,c))):void(c?B(a,c):d&&C(a,d))}function E(a){return a&&"object"!=typeof a?Va:Ua}function F(a,b){return!0===b?a:b}function G(a){return null==a?"":a}function H(a,b){return Wa[a.type](a.node,a,b,a.value)}function I(a,b){return Object.assign({},Xa,b,{node:a})}function J(a,b,c){return b.reduce((b,d)=>Object.assign({},b,{[d]:b=>a.map(a=>a[d](b))&&c}),{})}function K(a){a.firstChild&&(a.parentNode.insertBefore(a.firstChild,a),K(a))}function L(a,b,c){return void 0===b&&(b=[]),void 0===c&&(c=[]),a?a({slots:b,attributes:c}):W(N(b),[...M(b),{expressions:c.map(a=>Object.assign({type:Pa},a))}])}function M(a){return a.reduce((a,b)=>{let{bindings:c}=b;return a.concat(c)},[])}function N(a){return a.reduce((a,b)=>a+b.html,"")}function O(a,b){const{selector:c,type:d,redundantAttribute:e,expressions:f}=b,g=c?a.querySelector(c):a;return e&&g.removeAttribute(e),($a[d]||$a[ta])(g,Object.assign({},b,{expressions:f||[]}))}function P(a){const b=a.ownerSVGElement;return!!b||null===b}function Q(a){const b=document.createElement("template");return b.innerHTML=a,b.content}function R(a,b){const c=b.ownerDocument.importNode(new window.DOMParser().parseFromString(``,"application/xml").documentElement,!0);return c}function S(a,b){return P(a)?R(b,a):Q(b)}function T(a,b){a.firstChild&&(b.appendChild(a.firstChild),T(a,b))}function U(a,b){_a.test(a.tagName)?T(b,a):a.appendChild(b)}function V(a,b){return b&&("string"==typeof b?S(a,b):b)}function W(a,b){return void 0===b&&(b=[]),Object.assign({},ab,{html:a,bindingsData:b})}function X(a,c){return b("string"==typeof a?(c||document).querySelectorAll(a):a)}function Y(a){for(var b=arguments.length,c=Array(1b[a]||ja.get(a))}function $(a){let{css:b,template:c,exports:d,name:e}=a;const f=c?Z(c,d?ca(d.components):{}):gb;return a=>{let{slots:c,attributes:g,props:h}=a;const j=i(d)||{},k=_({css:b,template:f,componentAPI:j,name:e})({slots:c,attributes:g,props:h});return{mount(a,b,c){return k.mount(a,c,b)},update(a,b){return k.update(b,a)},unmount(a){return k.unmount(a)}}}}function _(a){let{css:b,template:c,componentAPI:d,name:e}=a;return b&&e&&db.add(e,b),Y(ga)(q(l(d,Object.assign({},fb,{state:{}})),Object.assign({slots:null,root:null},eb,{name:e,css:b,template:c})))}function aa(a,b){return void 0===b&&(b=[]),Object.assign({},s(a),r(b))}function ba(b,c){void 0===c&&(c=[]);const d=c.map(c=>I(b,c)),e={},f=a=>b=>(d.forEach(c=>c[a](b)),e);return Object.assign(e,{expressions:d,mount:f("mount"),update:f("update"),unmount:f("unmount")})}function ca(a){return void 0===a&&(a={}),Object.entries(i(a)).reduce((a,b)=>{let[c,d]=b;return a[j(c)]=$(d),a},{})}function da(a){return[...la].reduce((a,b)=>b(a)||a,a)}function ea(a,b){return Object.assign({},a,i(b))}function fa(a,b){t(a)!==b&&d(a,"is",b)}function ga(a,b){let{slots:c,attributes:d,props:e}=b;const f=i(e);return n(da(q(Object.create(a),{mount(b,e,g){return void 0===e&&(e={}),this[na]=ba(b,d).mount(g),this.props=Object.freeze(Object.assign({},f,aa(b,this[na].expressions))),this.state=ea(this.state,e),this[oa]=this.template.createDOM(b).clone(),b[ka]=this,a.name&&fa(b,a.name),o(this,"root",b),o(this,"slots",c),this.onBeforeMount(this.props,this.state),this[oa].mount(b,this,g),this.onMounted(this.props,this.state),this},update(a,b){void 0===a&&(a={}),b&&this[na].update(b);const c=aa(this.root,this[na].expressions);if(!1!==this.shouldUpdate(c,this.props))return this.props=Object.freeze(Object.assign({},f,c)),this.state=ea(this.state,a),this.onBeforeUpdate(this.props,this.state),this[oa].update(this,b),this.onUpdated(this.props,this.state),this},unmount(a){return this.onBeforeUnmount(this.props,this.state),this[na].unmount(),this[oa].unmount(this,{},!a),this.onUnmounted(this.props,this.state),this}})),Object.keys(a).filter(b=>g(a[b])))}function ha(a,b,c){const d=c||t(a);ja.has(d)||h(`The component named "${d}" was never registered`);const e=ja.get(d)({props:b});return e.mount(a)}function ia(){for(var a=arguments.length,b=Array(a),c=0;cfunction(){return a(b(...arguments))})}const ja=new Map,ka=Symbol("riot-component"),la=new Set,ma="is",na=Symbol("attributes"),oa=Symbol("template");var pa=Object.freeze({COMPONENTS_IMPLEMENTATION_MAP:ja,DOM_COMPONENT_INSTANCE_PROPERTY:ka,PLUGINS_SET:la,IS_DIRECTIVE:"is",ATTRIBUTES_KEY_SYMBOL:na,TEMPLATE_KEY_SYMBOL:oa});const qa=a=>1===a.length?a[0]:a,ra=0,sa=1,ta=2,ua=3,va=4;var wa={EACH:ra,IF:sa,SIMPLE:ta,TAG:ua,SLOT:va};const xa=(a,b,c,d,e,f)=>{if(2>e-d)b.insertBefore(a(c[d],1),f);else{const g=b.ownerDocument.createDocumentFragment();for(;dc==a,za=a=>a,Aa=(a,b,c,d,e,f,g)=>{const h=f-e;if(1>h)return-1;for(;c-b>=h;){let h=b,i=e;for(;h{for(;dc{if(2>e-d)b.removeChild(a(c[d],-1));else{const f=b.ownerDocument.createRange();f.setStartBefore(a(c[d],-1)),f.setEndAfter(a(c[e-1],-1)),f.deleteContents()}},Ea=-1,Fa=1,Ga=0,Ha=(a,b,c,d,e,f,g,h)=>{let j=0,l=dg;)--j;l=h+d-j;const p=Array(l);let q=m[j];for(--c;q;){const{newi:a,oldi:b}=q;for(;c>a;)p[--l]=Fa,--c;for(;g>b;)p[--l]=Ea,--g;p[--l]=Ga,--c,--g,q=q.prev}for(;c>=b;)p[--l]=Fa,--c;for(;g>=f;)p[--l]=Ea,--g;return p},Ia=(a,b,e,f,g,h,i)=>{const j=e+h,l=[];let m,n,o,p,q,s,t;outer:for(m=0;m<=j;m++){if(m>50)return null;for(t=m-1,q=m?l[m-1]:[0,0],s=l[m]=[],n=-m;n<=m;n+=2){for(p=n===-m||n!==m&&q[t+n-1]{const k=new Map,l=a.length;let m=g,n=0;for(;n{let d=1,e=b;for(;d>>0;c{Ja(Ia(c,d,f,g,h,j,l)||Ha(c,d,e,f,g,h,i,j),a,b,c,d,g,h,k,m)},Ma=(a,b,c,d)=>{d||(d={});const e=d.compare||ya,f=d.node||za,g=null==d.before?null:f(d.before,0),h=b.length;let j=h,k=0,l=c.length,m=0;for(;kp||2>q?(xa(f,a,c,m,l,f(b[k],0)),Da(f,a,b,k,j),c):p===q&&Ba(c,l,b,k,j,e)?(xa(f,a,c,m,l,Ca(f,b,j,h,g)),c):(La(f,a,c,m,l,q,b,k,j,p,h,e,g),c)},Na=Object.seal({childrenMap:null,node:null,root:null,condition:null,evaluate:null,template:null,nodes:[],getKey:null,indexName:null,itemName:null,afterPlaceholder:null,placeholder:null,mount(a,b){return this.update(a,b)},update(a,b){const{placeholder:c}=this,d=this.evaluate(a),e=d?Array.from(d):[],f=c.parentNode,{newChildrenMap:g,batches:h,futureNodes:i}=z(e,a,b,this);return i.length?Ma(f,this.nodes,i,{before:c,node:v(Array.from(this.childrenMap.values()),b)}):w(this.childrenMap),h.forEach(a=>a()),this.childrenMap=g,this.nodes=i,this},unmount(a,b){return w(this.childrenMap,b),this.childrenMap=new Map,this.nodes=[],this}}),Oa=Object.seal({node:null,evaluate:null,placeholder:null,template:"",mount(a,b){return A(this.placeholder,this.node),this.update(a,b)},update(a,b){const c=!!this.evaluate(a),d=!this.value&&c,e=this.value&&!c;switch(!0){case d:A(this.node,this.placeholder),this.template&&(this.template=this.template.clone(),this.template.mount(this.node,a,b));break;case e:this.unmount(a),A(this.placeholder,this.node);break;default:c&&this.template.update(a,b);}return this.value=c,this},unmount(a,b){const{template:c}=this;return c&&c.unmount(a,b),this}}),Pa=0,Qa=1,Ra=2,Sa=3;var Ta={ATTRIBUTE:Pa,EVENT:Qa,TEXT:Ra,VALUE:Sa};const Ua="removeAttribute",Va="setAttribute";var Wa={[Pa]:D,[Qa]:function(a,b,c){let{name:d}=b;a[d]=c},[Ra]:function(a,b,c){let{childNodeIndex:d}=b;const e=a.childNodes[d],f=G(c);if(e.nodeType===Node.COMMENT_NODE){const b=document.createTextNode(f);a.replaceChild(b,e)}else e.data=G(f)},[Sa]:function(a,b,c){a.value=c}};const Xa=Object.seal({node:null,value:null,mount(a){return this.value=this.evaluate(a),H(this,this.value),this},update(a){const b=this.evaluate(a);return this.value!==b&&(H(this,b),this.value=b),this},unmount(){return this}}),Ya=Object.seal({node:null,name:null,template:null,mount(a,b){const c=!!a.slots&&a.slots.find(a=>{let{id:b}=a;return b===this.name}),{parentNode:d}=this.node;return this.template=c&&W(c.html,c.bindings).createDOM(d),this.template&&(this.template.mount(this.node,b),K(this.node)),d.removeChild(this.node),this},update(a,b){return this.template&&b&&this.template.update(b),this},unmount(a,b){return this.template&&this.template.unmount(b),this}}),Za=Object.seal({node:null,evaluate:null,name:null,slots:null,tag:null,attributes:null,getComponent:null,mount(a){return this.update(a)},update(a){const b=this.evaluate(a);return b===this.name?this.tag.update(a):(this.unmount(),this.name=b,this.tag=L(this.getComponent(b),this.slots,this.attributes),this.tag.mount(this.node,a)),this},unmount(){return this.tag&&this.tag.unmount(!0),this}});var $a={[sa]:function(a,b){let{evaluate:c,template:d}=b;return Object.assign({},Oa,{node:a,evaluate:c,placeholder:document.createTextNode(""),template:d.createDOM(a)})},[ta]:function(a,b){let{expressions:c}=b;return Object.assign({},J(c.map(b=>I(a,b)),["mount","update","unmount"]))},[ra]:function(a,b){let{evaluate:c,condition:d,itemName:e,indexName:f,getKey:g,template:h}=b;const i=document.createTextNode(""),j=a.parentNode,k=a.cloneNode(),l=Array.from(j.childNodes).indexOf(a);return j.insertBefore(i,a),j.removeChild(a),Object.assign({},Na,{childrenMap:new Map,node:a,root:k,offset:l,condition:d,evaluate:c,template:h.createDOM(a),getKey:g,indexName:f,itemName:e,placeholder:i})},[ua]:function(a,b){let{evaluate:c,getComponent:d,slots:e,attributes:f}=b;return Object.assign({},Za,{node:a,evaluate:c,slots:e,attributes:f,getComponent:d})},[va]:function(a,b){let{name:c}=b;return Object.assign({},Ya,{node:a,name:c})}};const _a=/svg/i,ab=Object.freeze({bindings:null,bindingsData:null,html:null,dom:null,el:null,createDOM(a){return this.dom=this.dom||V(a,this.html),this},mount(a,c,d){if(!a)throw new Error("Please provide DOM node to mount properly your template");return this.el&&this.unmount(c),this.el=a,this.createDOM(a),this.dom&&U(a,this.dom.cloneNode(!0)),this.bindings=this.bindingsData.map(a=>O(this.el,a)),this.bindings.forEach(a=>a.mount(c,d)),this},update(a,c){return this.bindings.forEach(d=>d.update(a,c)),this},unmount(a,c,d){return this.el&&(this.bindings.forEach(d=>d.unmount(a,c)),d&&this.el.parentNode?this.el.parentNode.removeChild(this.el):null!==d&&u(this.el),this.el=null),this},clone(){return Object.assign({},this,{el:null})}}),bb=new Map,cb=(a=>()=>a?a:(a=X("style[riot]")[0]||document.createElement("style"),d(a,"type","text/css"),a.parentNode||document.head.appendChild(a),a))();var db={CSS_BY_NAME:bb,add(a,b){return bb.has(a)||(bb.set(a,b),this.inject()),this},inject(){return cb().innerHTML=[...bb.values()].join("\n"),this},remove(a){return bb.has(a)&&(bb.delete(a),this.inject()),this}};const eb=Object.freeze({$(a){return X(a,this.root)[0]},$$(a){return X(a,this.root)}}),fb=Object.freeze({shouldUpdate:m,onBeforeMount:m,onMounted:m,onBeforeUpdate:m,onUpdated:m,onBeforeUnmount:m,onUnmounted:m}),gb={update:m,mount:m,unmount:m,clone:m,createDOM:m},{DOM_COMPONENT_INSTANCE_PROPERTY:hb,COMPONENTS_IMPLEMENTATION_MAP:ib,PLUGINS_SET:jb}=pa;a.__={cssManager:db,defineComponent:_,globals:pa},a.component=function(a){return(b,d)=>ia(a=>a.mount(b),a=>a({props:d}),$)(a)},a.install=function(a){return g(a)||h("Plugins must be of type function"),jb.has(a)&&h("This plugin was already install"),jb.add(a),jb},a.mount=function(a,b,c){return X(a).map(a=>ha(a,b,c))},a.register=function(a,b){let{css:c,template:d,exports:e}=b;return ib.has(a)&&h(`The component "${a}" was already registered`),ib.set(a,$({name:a,css:c,template:d,exports:e})),ib},a.uninstall=function(a){return jb.has(a)||h("This plugin was never installed"),jb.delete(a),jb},a.unmount=function(a){return X(a).map(a=>(a[hb]&&a[hb].unmount(),a))},a.unregister=function(a){return ib.has(a)||h(`The component "${a}" was never registered`),ib.delete(a),db.remove(a),ib},a.version="v4.0.5",Object.defineProperty(a,"__esModule",{value:!0})});