parcoursup/node_modules/riot/riot.min.js
lalBi94 7bc56c09b5 $
2023-03-05 13:23:23 +01:00

1 line
15 KiB
JavaScript

var t,e;t=this,e=function(t){"use strict";const e={EACH:0,IF:1,SIMPLE:2,TAG:3,SLOT:4};function n(t,e){return typeof t===e}function r(t){const e=t.ownerSVGElement;return!!e||null===e}function s(t){return"template"===t.tagName.toLowerCase()}function o(t){return n(t,"function")}function i(t){return!u(t)&&t.constructor===Object}function u(t){return null==t}const a=new Map,c=Symbol(),l=new Set,h="mount",d="update",p="unmount",m="props",f="slots",b="root",g=Symbol(),v=Symbol(),y=Symbol(),O=Symbol(),j=Symbol();function N(t){return t.replace(/-(\w)/g,((t,e)=>e.toUpperCase()))}function x(t,e){t.firstChild&&(e.appendChild(t.firstChild),x(t,e))}function M(t){Array.from(t).forEach(E)}const E=t=>t&&t.parentNode&&t.parentNode.removeChild(t),A=(t,e)=>e&&e.parentNode&&e.parentNode.insertBefore(t,e),T={ATTRIBUTE:0,EVENT:1,TEXT:2,VALUE:3};function w(){return this}function S(t){return o(t)?t.prototype&&t.prototype.constructor?new t:t():t}function C(t){const e=new Map,n=n=>(e.has(n)||e.set(n,t.call(this,n)))&&e.get(n);return n.cache=e,n}function D(t){return t.reduce(((t,e)=>{const{value:n,type:r}=e;switch(!0){case!e.name&&0===r:return Object.assign({},t,n);case 3===r:t.value=e.value;break;default:t[N(e.name)]=e.value}return t}),{})}function L(t,e,n,r){return void 0===r&&(r={}),Object.defineProperty(t,e,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function k(t,e,n){return Object.entries(e).forEach((e=>{let[r,s]=e;L(t,r,s,n)})),t}function U(t,e){return Object.entries(e).forEach((e=>{let[n,r]=e;t[n]||(t[n]=r)})),t}const B=Object.freeze({[h]:w,[d]:w,[p]:w}),I=Object.assign({},B,{clone:w,createDOM:w}),P=Symbol(),_=Symbol(),$=Symbol(),z={nodes:[],mount(t,e){return this.update(t,e)},update(t,e){const{placeholder:n,nodes:r,childrenMap:s}=this,o=t===$?null:this.evaluate(t),i=o?Array.from(o):[],{newChildrenMap:u,batches:a,futureNodes:c}=function(t,e,n,r){const{condition:s,template:o,childrenMap:i,itemName:u,getKey:a,indexName:c,root:l,isTemplateTag:h}=r,d=new Map,p=[],m=[];return t.forEach(((t,r)=>{const f=function(t,e){let{itemName:n,indexName:r,index:s,item:o}=e;return L(t,n,o),r&&L(t,r,s),t}(Object.create(e),{itemName:u,indexName:c,index:r,item:t}),b=a?a(f):r,g=i.get(b),v=[];if(function(t,e){return!!t&&!t(e)}(s,f))return;const y=!g,O=g?g.template:o.clone(),j=O.el||l.cloneNode(),N=h&&y?function(t){const e=t.dom.cloneNode(!0),{head:n,tail:r}=function(){const t=document.createTextNode(""),e=document.createTextNode("");return t[P]=!0,e[_]=!0,{head:t,tail:e}}();return{avoidDOMInjection:!0,fragment:e,head:n,tail:r,children:[n,...Array.from(e.childNodes),r]}}(O):O.meta;y?p.push((()=>O.mount(j,f,n,N))):p.push((()=>O.update(f,n))),h?v.push(...N.children):v.push(j),i.delete(b),m.push(...v),d.set(b,{nodes:v,template:O,context:f,index:r})})),{newChildrenMap:d,batches:p,futureNodes:m}}(i,t,e,this);return((t,e,n,r)=>{const s=e.length;let o=t.length,i=s,u=0,a=0,c=null;for(;u<o||a<i;)if(o===u){const t=i<s?a?n(e[a-1],-0).nextSibling:n(e[i-a],0):r;for(;a<i;)A(n(e[a++],1),t)}else if(i===a)for(;u<o;)c&&c.has(t[u])||E(n(t[u],-1)),u++;else if(t[u]===e[a])u++,a++;else if(t[o-1]===e[i-1])o--,i--;else if(t[u]===e[i-1]&&e[a]===t[o-1]){const r=n(t[--o],-1).nextSibling;A(n(e[a++],1),n(t[u++],-1).nextSibling),A(n(e[--i],1),r),t[o]=e[i]}else{if(!c){c=new Map;let t=a;for(;t<i;)c.set(e[t],t++)}if(c.has(t[u])){const r=c.get(t[u]);if(a<r&&r<i){let s=u,d=1;for(;++s<o&&s<i&&c.get(t[s])===r+d;)d++;if(d>r-a){const s=n(t[u],0);for(;a<r;)A(n(e[a++],1),s)}else l=n(e[a++],1),(h=n(t[u++],-1))&&h.parentNode&&h.parentNode.replaceChild(l,h)}else u++}else E(n(t[u++],-1))}var l,h})(r,c,function(t,e){return(n,r)=>{if(r<0){const n=t[t.length-1];if(n){const{template:r,nodes:s,context:o}=n;s.pop(),s.length||(t.pop(),r.unmount(o,e,null))}}return n}}(Array.from(s.values()),e),n),a.forEach((t=>t())),this.childrenMap=u,this.nodes=c,this},unmount(t,e){return this.update($,e),this}},H={mount(t,e){return this.update(t,e)},update(t,e){const n=!!this.evaluate(t),r=!this.value&&n,s=this.value&&!n,o=()=>{const n=this.node.cloneNode();A(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,t,e)};switch(!0){case r:o();break;case s:this.unmount(t);break;default:n&&this.template.update(t,e)}return this.value=n,this},unmount(t,e){return this.template.unmount(t,e,!0),this}},K="undefined"==typeof Element?{}:Element.prototype,R=C((t=>K.hasOwnProperty(t))),Y=/^on/,F={handleEvent(t){this[t.type](t)}},V=new WeakMap;function q(t){return u(t)?"":t}const G=(t,e)=>{const n=t.childNodes[e];if(n.nodeType===Node.COMMENT_NODE){const e=document.createTextNode("");return t.replaceChild(e,n),e}return n},W={0:function t(e,r,s,u){let{name:a}=r;if(!a)return u&&function(t,e,n){const r=e?Object.keys(e):[];Object.keys(n).filter((t=>!r.includes(t))).forEach((e=>t.removeAttribute(e)))}(e,s,u),void(s&&function(e,n){Object.entries(n).forEach((n=>{let[r,s]=n;return t(e,{name:r},s)}))}(e,s));!R(a)&&(function(t){return n(t,"boolean")}(s)||i(s)||o(s))&&(e[a]=s),function(t){return!t&&0!==t}(s)?e.removeAttribute(a):function(t){return!0===t||["string","number"].includes(typeof t)}(s)&&e.setAttribute(a,function(t,e){return!0===e?t:e}(a,s))},1:function(t,e,n){let{name:r}=e;const s=r.replace(Y,""),o=V.get(t)||(t=>{const e=Object.create(F);return V.set(t,e),e})(t),[i,u]=(t=>Array.isArray(t)?t:[t,!1])(n),a=o[s],c=i&&!a;a&&!i&&t.removeEventListener(s,o),c&&t.addEventListener(s,o,u),o[s]=i},2:function(t,e,n){t.data=q(n)},3:function(t,e,n){t.value=q(n)}},X={mount(t){return this.value=this.evaluate(t),Z(this,this.value),this},update(t){const e=this.evaluate(t);return this.value!==e&&(Z(this,e),this.value=e),this},unmount(){return 1===this.type&&Z(this,null),this}};function Z(t,e){return W[t.type](t.node,t,e,t.value)}function J(t,e){return Object.assign({},X,e,{node:2===e.type?G(t,e.childNodeIndex):t})}const Q=(t,e)=>t[y]||e,tt={attributes:[],getTemplateScope(t,e){return function(t,e,n){if(!t||!t.length)return n;const r=t.map((t=>Object.assign({},t,{value:t.evaluate(e)})));return Object.assign(Object.create(n||null),D(r))}(this.attributes,t,e)},mount(t,e){const n=!!t.slots&&t.slots.find((t=>{let{id:e}=t;return e===this.name})),{parentNode:r}=this.node,s=Q(t,e);return this.template=n&&ct(n.html,n.bindings).createDOM(r),this.template&&(M(this.node.childNodes),this.template.mount(this.node,this.getTemplateScope(t,s),s),this.template.children=Array.from(this.node.childNodes)),et(this.node),E(this.node),this},update(t,e){if(this.template){const n=Q(t,e);this.template.update(this.getTemplateScope(t,n),n)}return this},unmount(t,e,n){return this.template&&this.template.unmount(this.getTemplateScope(t,e),null,n),this}};function et(t){const e=t&&t.firstChild;e&&(A(e,t),et(t))}function nt(t){return t.reduce(((t,e)=>{let{bindings:n}=e;return t.concat(n)}),[])}const rt={mount(t){return this.update(t)},update(t,e){const n=this.evaluate(t);return n&&n===this.name?this.tag.update(t):(this.unmount(t,e,!0),this.name=n,this.tag=(r=this.getComponent(n),void 0===(s=this.slots)&&(s=[]),void 0===(o=this.attributes)&&(o=[]),r?r({slots:s,attributes:o}):ct(function(t){return t.reduce(((t,e)=>t+e.html),"")}(s),[...nt(s),{expressions:o.map((t=>Object.assign({type:0},t)))}])),this.tag.mount(this.node,t)),this;var r,s,o},unmount(t,e,n){return this.tag&&this.tag.unmount(n),this}},st={1:function(t,e){let{evaluate:n,template:r}=e;const s=document.createTextNode("");return A(s,t),E(t),Object.assign({},H,{node:t,evaluate:n,placeholder:s,template:r.createDOM(t)})},2:function(t,e){let{expressions:n}=e;return Object.assign({},(r=n.map((e=>J(t,e))),["mount","update","unmount"].reduce(((t,e)=>Object.assign({},t,{[e]:t=>r.map((n=>n[e](t)))&&void 0})),{})));var r},0:function(t,e){let{evaluate:n,condition:r,itemName:o,indexName:i,getKey:u,template:a}=e;const c=document.createTextNode(""),l=t.cloneNode();return A(c,t),E(t),Object.assign({},z,{childrenMap:new Map,node:t,root:l,condition:r,evaluate:n,isTemplateTag:s(l),template:a.createDOM(t),getKey:u,indexName:i,itemName:o,placeholder:c})},3:function(t,e){let{evaluate:n,getComponent:r,slots:s,attributes:o}=e;return Object.assign({},rt,{node:t,evaluate:n,slots:s,attributes:o,getComponent:r})},4:function(t,e){let{name:n,attributes:r}=e;return Object.assign({},tt,{attributes:r,node:t,name:n})}};function ot(t,e){return t.map((t=>2===t.type?Object.assign({},t,{childNodeIndex:t.childNodeIndex+e}):t))}function it(t,e,n){const{selector:r,type:s,redundantAttribute:o,expressions:i}=e,u=r?t.querySelector(r):t;o&&u.removeAttribute(o);const a=i||[];return(st[s]||st[2])(u,Object.assign({},e,{expressions:n&&!r?ot(a,n):a}))}function ut(t,e){switch(!0){case r(t):x(e,t);break;case s(t):t.parentNode.replaceChild(e,t);break;default:t.appendChild(e)}}const at={createDOM(t){return this.dom=this.dom||function(t,e){return e&&("string"==typeof e?function(t,e){return r(t)?function(t,e){return e.ownerDocument.importNode((new window.DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,"application/xml").documentElement,!0)}(e,t):function(t,e){const n=s(e)?e:document.createElement("template");return n.innerHTML=t,n.content}(e,t)}(t,e):e)}(t,this.html)||document.createDocumentFragment(),this},mount(t,e,n,r){void 0===r&&(r={}),this.el&&this.unmount(e);const{fragment:o,children:i,avoidDOMInjection:u}=r,{parentNode:a}=i?i[0]:t,c=s(t),l=c?function(t,e,n){const r=Array.from(t.childNodes);return Math.max(r.indexOf(e),r.indexOf(n.head)+1,0)}(a,t,r):null;this.createDOM(t);const h=o||this.dom.cloneNode(!0);return this.el=c?a:t,this.children=c?i||Array.from(h.childNodes):null,!u&&h&&ut(t,h),this.bindings=this.bindingsData.map((t=>it(this.el,t,l))),this.bindings.forEach((t=>t.mount(e,n))),this.meta=r,this},update(t,e){return this.bindings.forEach((n=>n.update(t,e))),this},unmount(t,e,n){void 0===n&&(n=!1);const r=this.el;if(!r)return this;switch(this.bindings.forEach((r=>r.unmount(t,e,n))),!0){case r[g]||null===n:break;case Array.isArray(this.children):M(this.children);break;case!n:r.innerHTML="";break;case!!n:E(r)}return this.el=null,this},clone(){return Object.assign({},this,{meta:{},el:null})}};function ct(t,e){return void 0===e&&(e=[]),Object.assign({},at,{html:t,bindingsData:e})}const lt=(t,e)=>t[c]=e;function ht(t){return[h,d,p].reduce(((e,n)=>(e[n]=t(n),e)),{})}function dt(t){return Array.isArray(t)?t:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(t))&&"number"==typeof t.length?Array.from(t):[t]}function pt(t,e){return dt("string"==typeof t?(e||document).querySelectorAll(t):t)}const mt=Object.freeze({$(t){return pt(t,this.root)[0]},$$(t){return pt(t,this.root)}}),ft=Object.freeze({shouldUpdate:w,onBeforeMount:w,onMounted:w,onBeforeUpdate:w,onUpdated:w,onBeforeUnmount:w,onUnmounted:w}),bt=t=>1===t.length?t[0]:t;function gt(t,e,n){const r="object"==typeof e?e:{[e]:n},s=Object.keys(r);return dt(t).forEach((t=>{s.forEach((e=>t.setAttribute(e,r[e])))})),t}const vt=new Map;var yt;const Ot={CSS_BY_NAME:vt,add(t,e){return vt.has(t)||(vt.set(t,e),this.inject()),this},inject(){return(yt||(gt(yt=pt("style[riot]")[0]||document.createElement("style"),"type","text/css"),yt.parentNode||document.head.appendChild(yt),yt)).innerHTML=[...vt.values()].join("\n"),this},remove(t){return vt.has(t)&&(vt.delete(t),this.inject()),this}};function jt(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(r=[...n,...r]).length<t.length?jt(t,...r):t(...r)}}function Nt(t){return function(t,e,n){const r=["is"];return bt(dt(t).map((t=>bt(r.map((e=>t.getAttribute(e)))))))}(t)||t.tagName.toLowerCase()}function xt(t,e){return Object.assign({},t,S(e))}function Mt(t,e){let{slots:n,attributes:r,props:s}=e;return u=function(t){return[...l].reduce(((t,e)=>e(t)||t),t)}(k(i(t)?Object.create(t):t,{mount(e,o,i){return void 0===o&&(o={}),L(e,g,!1),this[y]=i,this[O]=function(t,e){void 0===e&&(e=[]);const n=e.map((e=>J(t,e))),r={};return Object.assign(r,Object.assign({expressions:n},ht((t=>e=>(n.forEach((n=>n[t](e))),r)))))}(e,r).mount(i),L(this,m,Object.freeze(Object.assign({},function(t,e){return void 0===e&&(e={}),Object.assign({},function(t){return Array.from(t.attributes).reduce(((t,e)=>(t[N(e.name)]=e.value,t)),{})}(t),S(e))}(e,s),D(this[O].expressions)))),this.state=xt(this.state,o),this[j]=this.template.createDOM(e).clone(),lt(e,this),t.name&&function(t,e){Nt(t)!==e&&gt(t,"is",e)}(e,t.name),L(this,b,e),L(this,f,n),this.onBeforeMount(this.props,this.state),this[j].mount(e,this,i),this.onMounted(this.props,this.state),this},update(t,e){void 0===t&&(t={}),e&&(this[y]=e,this[O].update(e));const n=D(this[O].expressions);if(!1!==this.shouldUpdate(n,this.props))return L(this,m,Object.freeze(Object.assign({},this.props,n))),this.state=xt(this.state,t),this.onBeforeUpdate(this.props,this.state),this[v]||(this[v]=!0,this[j].update(this,this[y])),this.onUpdated(this.props,this.state),this[v]=!1,this},unmount(t){return this.onBeforeUnmount(this.props,this.state),this[O].unmount(),this[j].unmount(this,this[y],null===t?null:!t),this.onUnmounted(this.props,this.state),this}})),Object.keys(t).filter((e=>o(t[e]))).forEach((t=>{u[t]=u[t].bind(u)})),u;var u}function Et(t){let{css:e,template:n,componentAPI:r,name:s}=t;return e&&s&&Ot.add(s,e),jt(Mt)(k(U(r,Object.assign({},ft,{[m]:{},state:{}})),Object.assign({[f]:null,[b]:null},mt,{name:s,css:e,template:n})))}function At(t){const{css:n,template:r,exports:s,name:o}=t,i=r?function(t,n){const r=function(t){return void 0===t&&(t={}),Object.entries(S(t)).reduce(((t,e)=>{let[n,r]=e;var s;return t[(s=n,s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=At(r),t}),{})}(n.exports?n.exports.components:{});return t(ct,T,e,(t=>t===n.name?Tt(n):r[t]||a.get(t)))}(r,t):I;return t=>{let{slots:e,attributes:u,props:a}=t;if(s&&s[g])return function(t,e){let{slots:n,attributes:r,props:s,css:o,template:i}=e;const u=U(t({slots:n,attributes:r,props:s}),B);return ht((t=>function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(t===h){const[t]=n;L(t,g,!0),lt(t,u)}return u[t](...n),u}))}(s,{slots:e,attributes:u,props:a,css:n,template:r});const c=S(s)||{},l=Et({css:n,template:i,componentAPI:c,name:o})({slots:e,attributes:u,props:a});return{mount:(t,e,n)=>l.mount(t,n,e),update:(t,e)=>l.update(e,t),unmount:t=>l.unmount(t)}}}const Tt=C(At),wt={cssManager:Ot,DOMBindings:{template:ct,createBinding:it,createExpression:J,bindingTypes:e,expressionTypes:T},globals:{DOM_COMPONENT_INSTANCE_PROPERTY:c,PARENT_KEY_SYMBOL:y}};t.__=wt,t.component=function(t){return function(e,n,r){let{slots:s,attributes:o,parentScope:i}=void 0===r?{}:r;return function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce(((t,e)=>function(){return t(e(...arguments))}))}((t=>t.mount(e,i)),(t=>t({props:n,slots:s,attributes:o})),At)(t)}},t.install=function(t){return o(t),l.has(t),l.add(t),l},t.mount=function(t,e,n){return pt(t).map((t=>function(t,e,n,r){const s=n||Nt(t);return a.has(s),a.get(s)({props:e,slots:void 0}).mount(t)}(t,e,n)))},t.pure=function(t){return o(t),t[g]=!0,t},t.register=function(t,e){let{css:n,template:r,exports:s}=e;return a.has(t),a.set(t,At({name:t,css:n,template:r,exports:s})),a},t.uninstall=function(t){return l.has(t),l.delete(t),l},t.unmount=function(t,e){return pt(t).map((t=>(t[c]&&t[c].unmount(e),t)))},t.unregister=function(t){return a.has(t),a.delete(t),Ot.remove(t),a},t.version="v7.0.3",t.withTypes=t=>t,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).riot={});