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