You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2 lines
17 KiB

/* Riot v4.5.0, @license MIT */
var e,t;e=this,t=function(e){"use strict";const t=new Map,n=Symbol("riot-component"),r=new Set,o="is",s="value",i=Symbol("attributes"),u=Symbol("template");var a=Object.freeze({COMPONENTS_IMPLEMENTATION_MAP:t,DOM_COMPONENT_INSTANCE_PROPERTY:n,PLUGINS_SET:r,IS_DIRECTIVE:o,VALUE_ATTRIBUTE:s,ATTRIBUTES_KEY_SYMBOL:i,TEMPLATE_KEY_SYMBOL:u});function l(e){Array.from(e).forEach(e=>e.parentNode&&e.parentNode.removeChild(e))}const c=2;var h={EACH:0,IF:1,SIMPLE:c,TAG:3,SLOT:4};const{indexOf:d}=[],p=(e,t,n,r,o,s)=>{const i="selectedIndex"in t;let u=i;for(;r<o;){const o=e(n[r],1);if(t.insertBefore(o,s),i&&u&&o.selected){u=!u;let{selectedIndex:e}=t;t.selectedIndex=e<0?r:d.call(t.querySelectorAll("option"),o)}r++}},m=(e,t)=>e==t,f=e=>e,b=(e,t,n,r,o,s,i)=>{const u=s-o;if(u<1)return-1;for(;n-t>=u;){let u=t,a=o;for(;u<n&&a<s&&i(e[u],r[a]);)u++,a++;if(a===s)return t;t=u+1}return-1},g=(e,t,n,r,o)=>n<r?e(t[n],0):0<n?e(t[n-1],-0).nextSibling:o,v=(e,t,n,r,o)=>{if(o-r<2)t.removeChild(e(n[r],-1));else{const s=t.ownerDocument.createRange();s.setStartBefore(e(n[r],-1)),s.setEndAfter(e(n[o-1],-1)),s.deleteContents()}},O=(e,t,n)=>{let r=1,o=t;for(;r<o;){const t=(r+o)/2>>>0;n<e[t]?o=t:r=t+1}return r},N=(e,t,n,r,o,s,i,u,a,l,c,h,d)=>{((e,t,n,r,o,s,i,u,a)=>{const l=new Map,c=e.length;let h=i,d=0;for(;d<c;)switch(e[d++]){case 0:o++,h++;break;case 1:l.set(r[o],1),p(t,n,r,o++,o,h<u?t(s[h],0):a);break;case-1:h++}for(d=0;d<c;)switch(e[d++]){case 0:i++;break;case-1:l.has(s[i])?i++:v(t,n,s,i++,i)}})(((e,t,n,r,o,s,i)=>{const u=n+s,a=[];let l,c,h,d,p,m,f;e:for(l=0;l<=u;l++){if(l>50)return null;for(f=l-1,p=l?a[l-1]:[0,0],m=a[l]=[],c=-l;c<=l;c+=2){for(h=(d=c===-l||c!==l&&p[f+c-1]<p[f+c+1]?p[f+c+1]:p[f+c-1]+1)-c;d<s&&h<n&&i(r[o+d],e[t+h]);)d++,h++;if(d===s&&h===n)break e;m[l+c]=d}}const b=Array(l/2+u/2);let g=b.length-1;for(l=a.length-1;l>=0;l--){for(;d>0&&h>0&&i(r[o+d-1],e[t+h-1]);)b[g--]=0,d--,h--;if(!l)break;f=l-1,p=l?a[l-1]:[0,0],(c=d-h)==-l||c!==l&&p[f+c-1]<p[f+c+1]?(h--,b[g--]=1):(d--,b[g--]=-1)}return b})(n,r,s,i,u,l,h)||((e,t,n,r,o,s,i,u)=>{let a=0,l=r<u?r:u;const c=Array(l++),h=Array(l);h[0]=-1;for(let e=1;e<l;e++)h[e]=i;const d=new Map;for(let e=s;e<i;e++)d.set(o[e],e);for(let r=t;r<n;r++){const t=d.get(e[r]);null!=t&&-1<(a=O(h,l,t))&&(h[a]=t,c[a]={newi:r,oldi:t,prev:c[a-1]})}for(a=--l,--i;h[a]>i;)--a;l=u+r-a;const p=Array(l);let m=c[a];for(--n;m;){const{newi:e,oldi:t}=m;for(;n>e;)p[--l]=1,--n;for(;i>t;)p[--l]=-1,--i;p[--l]=0,--n,--i,m=m.prev}for(;n>=t;)p[--l]=1,--n;for(;i>=s;)p[--l]=-1,--i;return p})(n,r,o,s,i,u,a,l),e,t,n,r,i,u,c,d)};function T(e){return null==e}function y(e){return!T(e.content)}const E=Object.seal({childrenMap:null,node:null,root:null,condition:null,evaluate:null,template:null,isTemplateTag:!1,nodes:[],getKey:null,indexName:null,itemName:null,afterPlaceholder:null,placeholder:null,mount(e,t){return this.update(e,t)},update(e,t){const{placeholder:n}=this,r=this.evaluate(e),o=r?Array.from(r):[],s=n.parentNode,{newChildrenMap:i,batches:u,futureNodes:a}=function(e,t,n,r){const{condition:o,template:s,childrenMap:i,itemName:u,getKey:a,indexName:l,root:c,isTemplateTag:h}=r,d=new Map,p=[],m=[];return e.forEach((e,r)=>{const f=function(e,t){let{itemName:n,indexName:r,index:o,item:s}=t;return e[n]=s,r&&(e[r]=o),e}(Object.create(t),{itemName:u,indexName:l,index:r,item:e}),b=a?a(f):r,g=i.get(b);if(function(e,t){return!!e&&!1===Boolean(e(t))}(o,f))return;const v=g?g.template:s.clone(),O=g?v.el:c.cloneNode(),N=!g,T=h&&N?function(e){const t=e.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:t,children:Array.from(t.childNodes)}}(v):{};N?p.push(()=>v.mount(O,f,n,T)):v.update(f,n),h?m.push(...T.children||v.children):m.push(O),i.delete(b),d.set(b,{template:v,context:f,index:r})}),{newChildrenMap:d,batches:p,futureNodes:m}}(o,e,t,this);return a.length?((e,t,n,r)=>{r||(r={});const o=r.compare||m,s=r.node||f,i=null==r.before?null:s(r.before,0),u=t.length;let a=u,l=0,c=n.length,h=0;for(;l<a&&h<c&&o(t[l],n[h]);)l++,h++;for(;l<a&&h<c&&o(t[a-1],n[c-1]);)a--,c--;const d=l===a,O=h===c;if(d&&O)return n;if(d&&h<c)return p(s,e,n,h,c,g(s,t,l,u,i)),n;if(O&&l<a)return v(s,e,t,l,a),n;const T=a-l,y=c-h;let E=-1;if(T<y){if(-1<(E=b(n,h,c,t,l,a,o)))return p(s,e,n,h,E,s(t[l],0)),p(s,e,n,E+T,c,g(s,t,a,u,i)),n}else if(y<T&&-1<(E=b(t,l,a,n,h,c,o)))return v(s,e,t,l,E),v(s,e,t,E+y,a),n;T<2||y<2?(p(s,e,n,h,c,s(t[l],0)),v(s,e,t,l,a)):T===y&&((e,t,n,r,o,s)=>{for(;r<o&&s(n[r],e[t-1]);)r++,t--;return 0===t})(n,c,t,l,a,o)?p(s,e,n,h,c,g(s,t,a,u,i)):N(s,e,n,h,c,y,t,l,a,T,u,o,i)})(s,this.nodes,a,{before:n,node:M(Array.from(this.childrenMap.values()),t)}):j(this.childrenMap),u.forEach(e=>e()),this.childrenMap=i,this.nodes=a,this},unmount(e,t){return j(this.childrenMap,t),this.childrenMap=new Map,this.nodes=[],this}});function M(e,t){return(n,r)=>{if(r<0){const{template:n,context:r}=e.pop();n.unmount(r,t,null)}return n}}function j(e,t){return Array.from(e.values()).map(e=>{let{template:n,context:r}=e;return n.unmount(r,t,!0)})}const A=Object.seal({node:null,evaluate:null,parent:null,isTemplateTag:!1,placeholder:null,template:null,mount(e,t){return this.parent.insertBefore(this.placeholder,this.node),this.parent.removeChild(this.node),this.update(e,t)},update(e,t){const n=!!this.evaluate(e),r=!this.value&&n,o=this.value&&!n,s=()=>{const n=this.node.cloneNode();this.parent.insertBefore(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,e,t)};switch(!0){case r:s();break;case o:this.unmount(e);break;default:n&&this.template.update(e,t)}return this.value=n,this},unmount(e,t){return this.template.unmount(e,t,!0),this}}),w=0;var x={ATTRIBUTE:w,EVENT:1,TEXT:2,VALUE:3};function C(e){return"object"==typeof e}const S="removeAttribute",I="setAttribute";function P(e,t,n,r){let{name:o}=t;o?((function(e){return"boolean"==typeof e}(n)||C(n))&&(e[o]=n),e[function(e){return T(e)||!1===e||""===e||C(e)?S:I}(n)](o,function(e,t){return!0===t?e:t}(o,n))):n?function(e,t){Object.entries(t).forEach(t=>{let[n,r]=t;return P(e,{name:n},r)})}(e,n):r&&function(e,t){Object.keys(t).forEach(t=>e.removeAttribute(t))}(e,r)}const _=/^on/;function B(e){return T(e)?"":e}var D={[w]:P,1:function(e,t,n,r){let{name:o}=t;const s=o.replace(_,"");return r&&e.removeEventListener(s,r),n&&e.addEventListener(s,n,!1),n},2:function(e,t,n){let{childNodeIndex:r}=t;const o=e.childNodes[r],s=B(n);if(o.nodeType===Node.COMMENT_NODE){const t=document.createTextNode(s);e.replaceChild(t,o)}else o.data=B(s)},3:function(e,t,n){e.value=n}};const L=Object.seal({node:null,value:null,mount(e){return this.value=this.evaluate(e),U(this,this.value),this},update(e){const t=this.evaluate(e);return this.value!==t&&(U(this,t),this.value=t),this},unmount(){return 1===this.type&&U(this,null),this}});function U(e,t){return D[e.type](e.node,e,t,e.value)}function k(e,t){return Object.assign({},L,{},t,{node:e})}const R=Object.seal({node:null,name:null,template:null,mount(e,t){const n=!!e.slots&&e.slots.find(e=>{let{id:t}=e;return t===this.name}),{parentNode:r}=this.node;return this.template=n&&q(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,t),function e(t){t.firstChild&&(t.parentNode.insertBefore(t.firstChild,t),e(t))}(this.node)),r.removeChild(this.node),this},update(e,t){return this.template&&t&&this.template.update(t),this},unmount(e,t,n){return this.template&&this.template.unmount(t,null,n),this}});function $(e){return e.reduce((e,t)=>{let{bindings:n}=t;return e.concat(n)},[])}const z=Object.seal({node:null,evaluate:null,name:null,slots:null,tag:null,attributes:null,getComponent:null,mount(e){return this.update(e)},update(e,t){const n=this.evaluate(e);return n===this.name?this.tag.update(e):(this.unmount(e,t,!0),this.name=n,this.tag=function(e,t,n){return void 0===t&&(t=[]),void 0===n&&(n=[]),e?e({slots:t,attributes:n}):q(function(e){return e.reduce((e,t)=>e+t.html,"")}(t),[...$(t),{expressions:n.map(e=>Object.assign({type:w},e))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,e)),this},unmount(e,t,n){return this.tag&&this.tag.unmount(n),this}});var Y={1:function(e,t){let{evaluate:n,template:r}=t;return Object.assign({},A,{node:e,evaluate:n,parent:e.parentNode,placeholder:document.createTextNode(""),template:r.createDOM(e)})},[c]:function(e,t){let{expressions:n}=t;return Object.assign({},(r=n.map(t=>k(e,t)),["mount","update","unmount"].reduce((e,t)=>Object.assign({},e,{[t]:e=>r.map(n=>n[t](e))&&o}),{})));var r,o},0:function(e,t){let{evaluate:n,condition:r,itemName:o,indexName:s,getKey:i,template:u}=t;const a=document.createTextNode(""),l=e.parentNode,c=e.cloneNode();return l.insertBefore(a,e),l.removeChild(e),Object.assign({},E,{childrenMap:new Map,node:e,root:c,condition:r,evaluate:n,isTemplateTag:y(c),template:u.createDOM(e),getKey:i,indexName:s,itemName:o,placeholder:a})},3:function(e,t){let{evaluate:n,getComponent:r,slots:o,attributes:s}=t;return Object.assign({},z,{node:e,evaluate:n,slots:o,attributes:s,getComponent:r})},4:function(e,t){let{name:n}=t;return Object.assign({},R,{node:e,name:n})}};function K(e){const t=e.ownerSVGElement;return!!t||null===t}function V(e,t){return K(e)?function(e,t){return t.ownerDocument.importNode((new window.DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${e}</svg>`,"application/xml").documentElement,!0)}(t,e):function(e,t){const n=y(t)?t:document.createElement("template");return n.innerHTML=e,n.content}(t,e)}function G(e,t){switch(!0){case K(e):!function e(t,n){t.firstChild&&(n.appendChild(t.firstChild),e(t,n))}(t,e);break;case y(e):e.parentNode.replaceChild(t,e);break;default:e.appendChild(t)}}const H=Object.freeze({bindings:null,bindingsData:null,html:null,isTemplateTag:!1,fragment:null,children:null,dom:null,el:null,createDOM(e){return this.dom=this.dom||function(e,t){return t&&("string"==typeof t?V(e,t):t)}(e,this.html),this},mount(e,t,n,r){if(void 0===r&&(r={}),!e)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(t);const{fragment:o,children:s,avoidDOMInjection:i}=r,{parentNode:u}=s?s[0]:e;return this.isTemplateTag=y(e),this.createDOM(e),this.dom&&(this.fragment=o||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?u:e,this.children=this.isTemplateTag?s||Array.from(this.fragment.childNodes):null,!i&&this.fragment&&G(e,this.fragment),this.bindings=this.bindingsData.map(e=>(function(e,t){const{selector:n,type:r,redundantAttribute:o,expressions:s}=t,i=n?e.querySelector(n):e;return o&&i.removeAttribute(o),(Y[r]||Y[c])(i,Object.assign({},t,{expressions:s||[]}))})(this.el,e)),this.bindings.forEach(e=>e.mount(t,n)),this},update(e,t){return this.bindings.forEach(n=>n.update(e,t)),this},unmount(e,t,n){if(this.el){switch(this.bindings.forEach(r=>r.unmount(e,t,n)),!0){case!0===this.isTemplateTag&&null!==n:l(this.children);break;case!0===n&&null!==this.el.parentNode:this.el.parentNode.removeChild(this.el);break;case null!==n:l(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function q(e,t){return void 0===t&&(t=[]),Object.assign({},H,{html:e,bindingsData:t})}function F(e){return"function"==typeof e}function W(e){throw new Error(e)}function X(e){return F(e)?e.prototype&&e.prototype.constructor?new e:e():e}function Z(e){return e.replace(/-(\w)/g,(e,t)=>t.toUpperCase())}function J(){return this}function Q(e,t,n,r){return void 0===r&&(r={}),Object.defineProperty(e,t,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),e}function ee(e,t,n){return Object.entries(t).forEach(t=>{let[r,o]=t;Q(e,r,o,n)}),e}function te(e){return Array.isArray(e)?e:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(e))&&"number"==typeof e.length?Array.from(e):[e]}const ne=e=>1===e.length?e[0]:e;function re(e,t,n){const r="object"==typeof t?t:{[t]:n},o=Object.keys(r);return te(e).forEach(e=>{o.forEach(t=>e.setAttribute(t,r[t]))}),e}function oe(e,t){return function(e,t,n){const r="string"==typeof t?[t]:t;return ne(te(e).map(e=>ne(r.map(t=>e[n](t)))))}(e,t,"getAttribute")}function se(e){return oe(e,o)||e.tagName.toLowerCase()}function ie(e,t){return te("string"==typeof e?(t||document).querySelectorAll(e):e)}const ue=new Map,ae=(e=>()=>e||(re(e=ie("style[riot]")[0]||document.createElement("style"),"type","text/css"),e.parentNode||document.head.appendChild(e),e))();var le={CSS_BY_NAME:ue,add(e,t){return ue.has(e)||(ue.set(e,t),this.inject()),this},inject(){return ae().innerHTML=[...ue.values()].join("\n"),this},remove(e){return ue.has(e)&&(ue.delete(e),this.inject()),this}};const ce=Object.freeze({$(e){return ie(e,this.root)[0]},$$(e){return ie(e,this.root)}}),he=Object.freeze({shouldUpdate:J,onBeforeMount:J,onMounted:J,onBeforeUpdate:J,onUpdated:J,onBeforeUnmount:J,onUnmounted:J}),de={update:J,mount:J,unmount:J,clone:J,createDOM:J};function pe(e){let{css:n,template:r,exports:o,name:s}=e;const i=r?function(e,n){return e(q,x,h,e=>n[e]||t.get(e))}(r,o?(void 0===(u=o.components)&&(u={}),Object.entries(X(u)).reduce((e,t)=>{let[n,r]=t;return e[function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}(n)]=pe(r),e},{})):{}):de;var u;return e=>{let{slots:t,attributes:r,props:u}=e;const a=X(o)||{},l=me({css:n,template:i,componentAPI:a,name:s})({slots:t,attributes:r,props:u});return{mount:(e,t,n)=>l.mount(e,n,t),update:(e,t)=>l.update(t,e),unmount:e=>l.unmount(e)}}}function me(e){let{css:t,template:n,componentAPI:r,name:o}=e;return t&&o&&le.add(o,t),function e(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(o=[...r,...o]).length<t.length?e(t,...o):t(...o)}}(ge)(ee((s=r,i=Object.assign({},he,{state:{}}),Object.entries(i).forEach(e=>{let[t,n]=e;s[t]||(s[t]=n)}),s),Object.assign({slots:null,root:null},ce,{name:o,css:t,template:n})));var s,i}function fe(e,t){return void 0===t&&(t=[]),Object.assign({},function(e){return Array.from(e.attributes).reduce((e,t)=>(e[Z(t.name)]=t.value,e),{})}(e),{},t.reduce((e,t)=>{const{value:n,type:r}=t;switch(!0){case!t.name&&r===x.ATTRIBUTE:return Object.assign({},e,{},n);case r===x.VALUE:e[s]=t.value;break;default:e[Z(t.name)]=t.value}return e},{}))}function be(e,t){return Object.assign({},e,{},X(t))}function ge(e,t){let{slots:o,attributes:s,props:a}=t;const l=X(a);return c=function(e){return[...r].reduce((e,t)=>t(e)||e,e)}(ee(Object.create(e),{mount(t,r,a){return void 0===r&&(r={}),this[i]=function(e,t){void 0===t&&(t=[]);const n=t.map(t=>k(e,t)),r={},o=e=>t=>(n.forEach(n=>n[e](t)),r);return Object.assign(r,{expressions:n,mount:o("mount"),update:o("update"),unmount:o("unmount")})}(t,s).mount(a),this.props=Object.freeze(Object.assign({},l,{},fe(t,this[i].expressions))),this.state=be(this.state,r),this[u]=this.template.createDOM(t).clone(),t[n]=this,e.name&&function(e,t){se(e)!==t&&re(e,"is",t)}(t,e.name),Q(this,"root",t),Q(this,"slots",o),this.onBeforeMount(this.props,this.state),this[u].mount(t,this,a),this.onMounted(this.props,this.state),this},update(e,t){void 0===e&&(e={}),t&&this[i].update(t);const n=fe(this.root,this[i].expressions);if(!1!==this.shouldUpdate(n,this.props))return this.props=Object.freeze(Object.assign({},l,{},n)),this.state=be(this.state,e),this.onBeforeUpdate(this.props,this.state),this[u].update(this,t),this.onUpdated(this.props,this.state),this},unmount(e){return this.onBeforeUnmount(this.props,this.state),this[i].unmount(),this[u].unmount(this,{},null===e?null:!e),this.onUnmounted(this.props,this.state),this}})),Object.keys(e).filter(t=>F(e[t])).forEach(e=>{c[e]=c[e].bind(c)}),c;var c}const{DOM_COMPONENT_INSTANCE_PROPERTY:ve,COMPONENTS_IMPLEMENTATION_MAP:Oe,PLUGINS_SET:Ne}=a,Te={cssManager:le,defineComponent:me,globals:a};e.__=Te,e.component=function(e){return(t,n)=>(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce((e,t)=>(function(){return e(t(...arguments))}))})(e=>e.mount(t),e=>e({props:n}),pe)(e)},e.install=function(e){return F(e)||W("Plugins must be of type function"),Ne.has(e)&&W("This plugin was already install"),Ne.add(e),Ne},e.mount=function(e,n,r){return ie(e).map(e=>(function(e,n,r){const o=r||se(e);return t.has(o)||W(`The component named "${o}" was never registered`),t.get(o)({props:n}).mount(e)})(e,n,r))},e.register=function(e,t){let{css:n,template:r,exports:o}=t;return Oe.has(e)&&W(`The component "${e}" was already registered`),Oe.set(e,pe({name:e,css:n,template:r,exports:o})),Oe},e.uninstall=function(e){return Ne.has(e)||W("This plugin was never installed"),Ne.delete(e),Ne},e.unmount=function(e,t){return ie(e).map(e=>(e[ve]&&e[ve].unmount(t),e))},e.unregister=function(e){return Oe.has(e)||W(`The component "${e}" was never registered`),Oe.delete(e),le.remove(e),Oe},e.version="v4.5.0",Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).riot={});