-
-
Notifications
You must be signed in to change notification settings - Fork 925
/
mithril.min.js
1 lines (1 loc) · 24 KB
/
mithril.min.js
1
!function(){"use strict";function e(e,t,n,r,o,l){return{tag:e,key:t,attrs:n,children:r,text:o,dom:l,domSize:void 0,state:void 0,events:void 0,instance:void 0}}e.normalize=function(t){return Array.isArray(t)?e("[",void 0,void 0,e.normalizeChildren(t),void 0,void 0):null==t||"boolean"==typeof t?null:"object"==typeof t?t:e("#",void 0,void 0,String(t),void 0,void 0)},e.normalizeChildren=function(t){var n=[];if(t.length){for(var r=null!=t[0]&&null!=t[0].key,o=1;o<t.length;o++)if((null!=t[o]&&null!=t[o].key)!==r)throw new TypeError(!r||null==t[o]&&"boolean"!=typeof t[o]?"In fragments, vnodes must either all have keys or none have keys.":"In fragments, vnodes must either all have keys or none have keys. You may wish to consider using an explicit keyed empty fragment, m.fragment({key: ...}), instead of a hole.");for(o=0;o<t.length;o++)n[o]=e.normalize(t[o])}return n};var t=function(){var t,n=arguments[this],r=this+1;if(null==n?n={}:("object"!=typeof n||null!=n.tag||Array.isArray(n))&&(n={},r=this),arguments.length===r+1)t=arguments[r],Array.isArray(t)||(t=[t]);else for(t=[];r<arguments.length;)t.push(arguments[r++]);return e("",n.key,n,t)},n={}.hasOwnProperty,r=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,o=Object.create(null);function l(e){for(var t in e)if(n.call(e,t))return!1;return!0}function i(e){for(var t,n="div",i=[],a={};t=r.exec(e);){var s=t[1],u=t[2];if(""===s&&""!==u)n=u;else if("#"===s)a.id=u;else if("."===s)i.push(u);else if("["===t[3][0]){var f=t[6];f&&(f=f.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===t[4]?i.push(f):a[t[4]]=""===f?f:f||!0}}return i.length>0&&(a.className=i.join(" ")),l(a)&&(a=null),o[e]={tag:n,attrs:a}}function a(e,t){var r=t.attrs,o=n.call(r,"class"),l=o?r.class:r.className;return t.tag=e.tag,null!=e.attrs?(r=Object.assign({},e.attrs,r),null==l&&null==e.attrs.className||(r.className=null!=l?null!=e.attrs.className?String(e.attrs.className)+" "+String(l):l:null!=e.attrs.className?e.attrs.className:null)):null!=l&&(r.className=l),o&&(r.class=null),"input"===e.tag&&n.call(r,"type")&&(r=Object.assign({type:r.type},r)),t.attrs=r,t}function s(n){if(null==n||"string"!=typeof n&&"function"!=typeof n&&"function"!=typeof n.view)throw Error("The selector must be either a string or a component.");var r=t.apply(1,arguments);return"string"==typeof n&&(r.children=e.normalizeChildren(r.children),"["!==n)?a(o[n]||i(n),r):(r.tag=n,r)}s.trust=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)},s.fragment=function(){var n=t.apply(0,arguments);return n.tag="[",n.children=e.normalizeChildren(n.children),n};var u=new WeakMap;var f={delayedRemoval:u,domFor:function*(e,t={}){var n=e.dom,r=e.domSize,o=t.generation;if(null!=n)do{var l=n.nextSibling;u.get(n)===o&&(yield n,r--),n=l}while(r)}},c=f.delayedRemoval,d=f.domFor,m=function(){var t,n,r={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function o(e){return e.ownerDocument}function l(e){return e.attrs&&e.attrs.xmlns||r[e.tag]}function i(e,t){if(e.state!==t)throw new Error("'vnode.state' must not be modified.")}function a(e){var t=e.state;try{return this.apply(t,arguments)}finally{i(e,t)}}function s(e){try{return o(e).activeElement}catch(e){return null}}function u(e,t,n,r,o,l,i){for(var a=n;a<r;a++){var s=t[a];null!=s&&f(e,s,o,i,l)}}function f(e,t,n,r,o){var l=t.tag;if("string"==typeof l)switch(t.state={},null!=t.attrs&&W(t.attrs,t,n),l){case"#":m(e,t,o);break;case"<":v(e,t,r,o);break;case"[":h(e,t,n,r,o);break;default:y(e,t,n,r,o)}else w(e,t,n,r,o)}function m(e,t,n){t.dom=o(e).createTextNode(t.children),L(e,t.dom,n)}var p={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};function v(e,t,n,r){var l=t.children.match(/^\s*?<(\w+)/im)||[],i=o(e).createElement(p[l[1]]||"div");"http://www.w3.org/2000/svg"===n?(i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+t.children+"</svg>",i=i.firstChild):i.innerHTML=t.children,t.dom=i.firstChild,t.domSize=i.childNodes.length;for(var a,s=o(e).createDocumentFragment();a=i.firstChild;)s.appendChild(a);L(e,s,r)}function h(e,t,n,r,l){var i=o(e).createDocumentFragment();if(null!=t.children){var a=t.children;u(i,a,0,a.length,n,null,r)}t.dom=i.firstChild,t.domSize=i.childNodes.length,L(e,i,l)}function y(e,t,n,r,i){var a=t.tag,s=t.attrs,f=s&&s.is,c=(r=l(t)||r)?f?o(e).createElementNS(r,a,{is:f}):o(e).createElementNS(r,a):f?o(e).createElement(a,{is:f}):o(e).createElement(a);if(t.dom=c,null!=s&&F(t,s,r),L(e,c,i),!R(t)&&null!=t.children){var d=t.children;u(c,d,0,d.length,n,null,r),"select"===t.tag&&null!=s&&U(t,s)}}function g(t,n){var r;if("function"==typeof t.tag.view){if(t.state=Object.create(t.tag),null!=(r=t.state.view).$$reentrantLock$$)return;r.$$reentrantLock$$=!0}else{if(t.state=void 0,null!=(r=t.tag).$$reentrantLock$$)return;r.$$reentrantLock$$=!0,t.state=null!=t.tag.prototype&&"function"==typeof t.tag.prototype.view?new t.tag(t):t.tag(t)}if(W(t.state,t,n),null!=t.attrs&&W(t.attrs,t,n),t.instance=e.normalize(a.call(t.state.view,t)),t.instance===t)throw Error("A view cannot return the vnode it received as argument");r.$$reentrantLock$$=null}function w(e,t,n,r,o){g(t,n),null!=t.instance?(f(e,t.instance,n,r,o),t.dom=t.instance.dom,t.domSize=null!=t.dom?t.instance.domSize:0):t.domSize=0}function b(e,t,n,r,o,l){if(t!==n&&(null!=t||null!=n))if(null==t||0===t.length)u(e,n,0,n.length,r,o,l);else if(null==n||0===n.length)I(e,t,0,t.length);else{var i=null!=t[0]&&null!=t[0].key,a=null!=n[0]&&null!=n[0].key,s=0,c=0;if(!i)for(;c<t.length&&null==t[c];)c++;if(!a)for(;s<n.length&&null==n[s];)s++;if(i!==a)I(e,t,c,t.length),u(e,n,s,n.length,r,o,l);else if(a){for(var d,m,p,v,h,y=t.length-1,g=n.length-1;y>=c&&g>=s&&(p=t[y],v=n[g],p.key===v.key);)p!==v&&x(e,p,v,r,o,l),null!=v.dom&&(o=v.dom),y--,g--;for(;y>=c&&g>=s&&(d=t[c],m=n[s],d.key===m.key);)c++,s++,d!==m&&x(e,d,m,r,N(t,c,o),l);for(;y>=c&&g>=s&&s!==g&&d.key===v.key&&p.key===m.key;)$(e,p,h=N(t,c,o)),p!==m&&x(e,p,m,r,h,l),++s<=--g&&$(e,d,o),d!==v&&x(e,d,v,r,o,l),null!=v.dom&&(o=v.dom),c++,p=t[--y],v=n[g],d=t[c],m=n[s];for(;y>=c&&g>=s&&p.key===v.key;)p!==v&&x(e,p,v,r,o,l),null!=v.dom&&(o=v.dom),g--,p=t[--y],v=n[g];if(s>g)I(e,t,c,y+1);else if(c>y)u(e,n,s,g+1,r,o,l);else{var w,b,k=o,S=g-s+1,E=new Array(S),z=0,j=0,A=2147483647,C=0;for(j=0;j<S;j++)E[j]=-1;for(j=g;j>=s;j--){null==w&&(w=O(t,c,y+1));var L=w[(v=n[j]).key];null!=L&&(A=L<A?L:-1,E[j-s]=L,p=t[L],t[L]=null,p!==v&&x(e,p,v,r,o,l),null!=v.dom&&(o=v.dom),C++)}if(o=k,C!==y-c+1&&I(e,t,c,y+1),0===C)u(e,n,s,g+1,r,o,l);else if(-1===A)for(z=(b=T(E)).length-1,j=g;j>=s;j--)m=n[j],-1===E[j-s]?f(e,m,r,l,o):b[z]===j-s?z--:$(e,m,o),null!=m.dom&&(o=n[j].dom);else for(j=g;j>=s;j--)m=n[j],-1===E[j-s]&&f(e,m,r,l,o),null!=m.dom&&(o=n[j].dom)}}else{var R=t.length<n.length?t.length:n.length;for(s=s<c?s:c;s<R;s++)(d=t[s])===(m=n[s])||null==d&&null==m||(null==d?f(e,m,r,l,N(t,s+1,o)):null==m?P(e,d):x(e,d,m,r,N(t,s+1,o),l));t.length>R&&I(e,t,s,t.length),n.length>R&&u(e,n,s,n.length,r,o,l)}}}function x(e,t,n,r,o,l){var i=t.tag;if(i===n.tag){if(n.state=t.state,n.events=t.events,Y(n,t))return;if("string"==typeof i)switch(null!=n.attrs&&X(n.attrs,n,r),i){case"#":k(t,n);break;case"<":S(e,t,n,l,o);break;case"[":E(e,t,n,r,o,l);break;default:z(t,n,r,l)}else j(e,t,n,r,o,l)}else P(e,t),f(e,n,r,l,o)}function k(e,t){e.children.toString()!==t.children.toString()&&(e.dom.nodeValue=t.children),t.dom=e.dom}function S(e,t,n,r,o){t.children!==n.children?(D(e,t,void 0),v(e,n,r,o)):(n.dom=t.dom,n.domSize=t.domSize)}function E(e,t,n,r,o,l){b(e,t.children,n.children,r,o,l);var i=0,a=n.children;if(n.dom=null,null!=a){for(var s=0;s<a.length;s++){var u=a[s];null!=u&&null!=u.dom&&(null==n.dom&&(n.dom=u.dom),i+=u.domSize||1)}1!==i&&(n.domSize=i)}}function z(e,t,n,r){var o=t.dom=e.dom;r=l(t)||r,H(t,e.attrs,t.attrs,r),R(t)||b(o,e.children,t.children,n,null,r)}function j(t,n,r,o,l,i){if(r.instance=e.normalize(a.call(r.state.view,r)),r.instance===r)throw Error("A view cannot return the vnode it received as argument");X(r.state,r,o),null!=r.attrs&&X(r.attrs,r,o),null!=r.instance?(null==n.instance?f(t,r.instance,o,i,l):x(t,n.instance,r.instance,o,l,i),r.dom=r.instance.dom,r.domSize=r.instance.domSize):null!=n.instance?(P(t,n.instance),r.dom=void 0,r.domSize=0):(r.dom=n.dom,r.domSize=n.domSize)}function O(e,t,n){for(var r=Object.create(null);t<n;t++){var o=e[t];if(null!=o){var l=o.key;null!=l&&(r[l]=t)}}return r}var A,C=[];function T(e){var t=[0],n=0,r=0,o=0,l=C.length=e.length;for(o=0;o<l;o++)C[o]=e[o];for(o=0;o<l;++o)if(-1!==e[o]){var i=t[t.length-1];if(e[i]<e[o])C[o]=i,t.push(o);else{for(n=0,r=t.length-1;n<r;){var a=(n>>>1)+(r>>>1)+(n&r&1);e[t[a]]<e[o]?n=a+1:r=a}e[o]<e[t[n]]&&(n>0&&(C[o]=t[n-1]),t[n]=o)}}for(r=t[(n=t.length)-1];n-- >0;)t[n]=r,r=C[r];return C.length=0,t}function N(e,t,n){for(;t<e.length;t++)if(null!=e[t]&&null!=e[t].dom)return e[t].dom;return n}function $(e,t,n){if(null!=t.dom){var r;if(null==t.domSize)r=t.dom;else for(var l of(r=o(e).createDocumentFragment(),d(t)))r.appendChild(l);L(e,r,n)}}function L(e,t,n){null!=n?e.insertBefore(t,n):e.appendChild(t)}function R(e){if(null==e.attrs||null==e.attrs.contenteditable&&null==e.attrs.contentEditable)return!1;var t=e.children;if(null!=t&&1===t.length&&"<"===t[0].tag){var n=t[0].children;e.dom.innerHTML!==n&&(e.dom.innerHTML=n)}else if(null!=t&&0!==t.length)throw new Error("Child node of a contenteditable must be trusted.");return!0}function I(e,t,n,r){for(var o=n;o<r;o++){var l=t[o];null!=l&&P(e,l)}}function P(e,t){var r,o,l,s,u=0,f=t.state;"string"!=typeof t.tag&&"function"==typeof t.state.onbeforeremove&&(null!=(l=a.call(t.state.onbeforeremove,t))&&"function"==typeof l.then&&(u=1,r=l));t.attrs&&"function"==typeof t.attrs.onbeforeremove&&(null!=(l=a.call(t.attrs.onbeforeremove,t))&&"function"==typeof l.then&&(u|=2,o=l));if(i(t,f),u){for(var m of(s=n,d(t)))c.set(m,s);null!=r&&r.finally((function(){1&u&&((u&=2)||(i(t,f),_(t),D(e,t,s)))})),null!=o&&o.finally((function(){2&u&&((u&=1)||(i(t,f),_(t),D(e,t,s)))}))}else _(t),D(e,t,s)}function D(e,t,n){if(null!=t.dom)if(null==t.domSize)c.get(t.dom)===n&&e.removeChild(t.dom);else for(var r of d(t,{generation:n}))e.removeChild(r)}function _(e){if("string"!=typeof e.tag&&"function"==typeof e.state.onremove&&a.call(e.state.onremove,e),e.attrs&&"function"==typeof e.attrs.onremove&&a.call(e.attrs.onremove,e),"string"!=typeof e.tag)null!=e.instance&&_(e.instance);else{var t=e.children;if(Array.isArray(t))for(var n=0;n<t.length;n++){var r=t[n];null!=r&&_(r)}}}function F(e,t,n){for(var r in t)M(e,r,null,t[r],n)}function M(e,t,n,r,o){if("key"!==t&&"is"!==t&&null!=r&&!J(t)&&(n!==r||K(e,t)||"object"==typeof r)){if("o"===t[0]&&"n"===t[1])return V(e,t,r);if("xlink:"===t.slice(0,6))e.dom.setAttributeNS("http://www.w3.org/1999/xlink",t.slice(6),r);else if("style"===t)Q(e.dom,n,r);else if(B(e,t,o)){if("value"===t){var l="input"===e.tag&&"file"===e.attrs.type;if(("input"===e.tag||"textarea"===e.tag)&&e.dom.value===""+r&&(l||e.dom===s(e.dom)))return;if("select"===e.tag&&null!==n&&e.dom.value===""+r)return;if("option"===e.tag&&null!==n&&e.dom.value===""+r)return;if(l&&""+r!="")return void console.error("`value` is read-only on file inputs!")}"input"===e.tag&&"type"===t?e.dom.setAttribute(t,r):e.dom[t]=r}else"boolean"==typeof r?r?e.dom.setAttribute(t,""):e.dom.removeAttribute(t):e.dom.setAttribute("className"===t?"class":t,r)}}function q(e,t,n,r){if("key"!==t&&"is"!==t&&null!=n&&!J(t))if("o"===t[0]&&"n"===t[1])V(e,t,void 0);else if("style"===t)Q(e.dom,n,null);else if(!B(e,t,r)||"className"===t||"title"===t||"value"===t&&("option"===e.tag||"select"===e.tag&&-1===e.dom.selectedIndex&&e.dom===s(e.dom))||"input"===e.tag&&"type"===t){var o=t.indexOf(":");-1!==o&&(t=t.slice(o+1)),!1!==n&&e.dom.removeAttribute("className"===t?"class":t)}else e.dom[t]=null}function U(e,t){if("value"in t)if(null===t.value)-1!==e.dom.selectedIndex&&(e.dom.value=null);else{var n=""+t.value;e.dom.value===n&&-1!==e.dom.selectedIndex||(e.dom.value=n)}"selectedIndex"in t&&M(e,"selectedIndex",null,t.selectedIndex,void 0)}function H(e,t,n,r){if(t&&t===n&&console.warn("Don't reuse attrs object, use new object for every redraw, this will throw in next major"),null!=n)for(var o in n)M(e,o,t&&t[o],n[o],r);var l;if(null!=t)for(var o in t)null==(l=t[o])||null!=n&&null!=n[o]||q(e,o,l,r)}function K(e,t){return"value"===t||"checked"===t||"selectedIndex"===t||"selected"===t&&e.dom===s(e.dom)||"option"===e.tag&&e.dom.parentNode===s(e.dom)}function J(e){return"oninit"===e||"oncreate"===e||"onupdate"===e||"onremove"===e||"onbeforeremove"===e||"onbeforeupdate"===e}function B(e,t,n){return void 0===n&&(e.tag.indexOf("-")>-1||null!=e.attrs&&e.attrs.is||"href"!==t&&"list"!==t&&"form"!==t&&"width"!==t&&"height"!==t)&&t in e.dom}function Q(e,t,n){if(t===n);else if(null==n)e.style="";else if("object"!=typeof n)e.style=n;else if(null==t||"object"!=typeof t)for(var r in e.style.cssText="",n){null!=(o=n[r])&&(r.includes("-")?e.style.setProperty(r,String(o)):e.style[r]=String(o))}else{for(var r in n){var o;null!=(o=n[r])&&(o=String(o))!==String(t[r])&&(r.includes("-")?e.style.setProperty(r,o):e.style[r]=o)}for(var r in t)null!=t[r]&&null==n[r]&&(r.includes("-")?e.style.removeProperty(r):e.style[r]="")}}function G(){this._=t}function V(e,n,r){if(null!=e.events){if(e.events._=t,e.events[n]===r)return;null==r||"function"!=typeof r&&"object"!=typeof r?(null!=e.events[n]&&e.dom.removeEventListener(n.slice(2),e.events,!1),e.events[n]=void 0):(null==e.events[n]&&e.dom.addEventListener(n.slice(2),e.events,!1),e.events[n]=r)}else null==r||"function"!=typeof r&&"object"!=typeof r||(e.events=new G,e.dom.addEventListener(n.slice(2),e.events,!1),e.events[n]=r)}function W(e,t,n){"function"==typeof e.oninit&&a.call(e.oninit,t),"function"==typeof e.oncreate&&n.push(a.bind(e.oncreate,t))}function X(e,t,n){"function"==typeof e.onupdate&&n.push(a.bind(e.onupdate,t))}function Y(e,t){do{var n;if(null!=e.attrs&&"function"==typeof e.attrs.onbeforeupdate)if(void 0!==(n=a.call(e.attrs.onbeforeupdate,e,t))&&!n)break;if("string"!=typeof e.tag&&"function"==typeof e.state.onbeforeupdate)if(void 0!==(n=a.call(e.state.onbeforeupdate,e,t))&&!n)break;return!1}while(0);return e.dom=t.dom,e.domSize=t.domSize,e.instance=t.instance,e.attrs=t.attrs,e.children=t.children,e.text=t.text,!0}return G.prototype=Object.create(null),G.prototype.handleEvent=function(e){var t,n=this["on"+e.type];"function"==typeof n?t=n.call(e.currentTarget,e):"function"==typeof n.handleEvent&&n.handleEvent(e),this._&&!1!==e.redraw&&(0,this._)(),!1===t&&(e.preventDefault(),e.stopPropagation())},function(r,o,l){if(!r)throw new TypeError("DOM element being rendered to does not exist.");if(null!=A&&r.contains(A))throw new TypeError("Node is currently being rendered to and thus is locked.");var i=t,a=A,u=[],f=s(r),c=r.namespaceURI;A=r,t="function"==typeof l?l:void 0,n={};try{null==r.vnodes&&(r.textContent=""),o=e.normalizeChildren(Array.isArray(o)?o:[o]),b(r,r.vnodes,o,u,null,"http://www.w3.org/1999/xhtml"===c?void 0:c),r.vnodes=o,null!=f&&s(r)!==f&&"function"==typeof f.focus&&f.focus();for(var d=0;d<u.length;d++)u[d]()}finally{t=i,A=a}}}("undefined"!=typeof window&&window),p=function(t,n,r){var o=[],l=!1,i=-1;function a(){for(i=0;i<o.length;i+=2)try{t(o[i],e(o[i+1]),s)}catch(e){r.error(e)}i=-1}function s(){l||(l=!0,n((function(){l=!1,a()})))}return s.sync=a,{mount:function(n,r){if(null!=r&&null==r.view&&"function"!=typeof r)throw new TypeError("m.mount expects a component, not a vnode.");var l=o.indexOf(n);l>=0&&(o.splice(l,2),l<=i&&(i-=2),t(n,[])),null!=r&&(o.push(n,r),t(n,e(r),s))},redraw:s}}(m,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:null,"undefined"!=typeof console?console:null),v=function(e){if("[object Object]"!==Object.prototype.toString.call(e))return"";var t=[];for(var n in e)r(n,e[n]);return t.join("&");function r(e,n){if(Array.isArray(n))for(var o=0;o<n.length;o++)r(e+"["+o+"]",n[o]);else if("[object Object]"===Object.prototype.toString.call(n))for(var o in n)r(e+"["+o+"]",n[o]);else t.push(encodeURIComponent(e)+(null!=n&&""!==n?"="+encodeURIComponent(n):""))}},h=function(e,t){if(/:([^\/\.-]+)(\.{3})?:/.test(e))throw new SyntaxError("Template parameter names must be separated by either a '/', '-', or '.'.");if(null==t)return e;var n=e.indexOf("?"),r=e.indexOf("#"),o=r<0?e.length:r,l=n<0?o:n,i=e.slice(0,l),a={};Object.assign(a,t);var s=i.replace(/:([^\/\.-]+)(\.{3})?/g,(function(e,n,r){return delete a[n],null==t[n]?e:r?t[n]:encodeURIComponent(String(t[n]))})),u=s.indexOf("?"),f=s.indexOf("#"),c=f<0?s.length:f,d=u<0?c:u,m=s.slice(0,d);n>=0&&(m+=e.slice(n,o)),u>=0&&(m+=(n<0?"?":"&")+s.slice(u,c));var p=v(a);return p&&(m+=(n<0&&u<0?"?":"&")+p),r>=0&&(m+=e.slice(r)),f>=0&&(m+=(r<0?"":"&")+s.slice(f)),m},y=function(e,t){function r(e){return new Promise(e)}function o(t,r){return new Promise((function(o,i){t=h(t,r.params);var a,s=null!=r.method?r.method.toUpperCase():"GET",u=r.body,f=(null==r.serialize||r.serialize===JSON.serialize)&&!(u instanceof e.FormData||u instanceof e.URLSearchParams),c=r.responseType||("function"==typeof r.extract?"":"json"),d=new e.XMLHttpRequest,m=!1,p=!1,v=d,y=d.abort;for(var g in d.abort=function(){m=!0,y.call(this)},d.open(s,t,!1!==r.async,"string"==typeof r.user?r.user:void 0,"string"==typeof r.password?r.password:void 0),f&&null!=u&&!l(r,"content-type")&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof r.deserialize||l(r,"accept")||d.setRequestHeader("Accept","application/json, text/*"),r.withCredentials&&(d.withCredentials=r.withCredentials),r.timeout&&(d.timeout=r.timeout),d.responseType=c,r.headers)n.call(r.headers,g)&&d.setRequestHeader(g,r.headers[g]);d.onreadystatechange=function(e){if(!m&&4===e.target.readyState)try{var n,l=e.target.status>=200&&e.target.status<300||304===e.target.status||/^file:\/\//i.test(t),a=e.target.response;if("json"===c){if(!e.target.responseType&&"function"!=typeof r.extract)try{a=JSON.parse(e.target.responseText)}catch(e){a=null}}else c&&"text"!==c||null==a&&(a=e.target.responseText);if("function"==typeof r.extract?(a=r.extract(e.target,r),l=!0):"function"==typeof r.deserialize&&(a=r.deserialize(a)),l){if("function"==typeof r.type)if(Array.isArray(a))for(var s=0;s<a.length;s++)a[s]=new r.type(a[s]);else a=new r.type(a);o(a)}else{var u=function(){try{n=e.target.responseText}catch(e){n=a}var t=new Error(n);t.code=e.target.status,t.response=a,i(t)};0===d.status?setTimeout((function(){p||u()})):u()}}catch(e){i(e)}},d.ontimeout=function(e){p=!0;var t=new Error("Request timed out");t.code=e.target.status,i(t)},"function"==typeof r.config&&(d=r.config(d,r,t)||d)!==v&&(a=d.abort,d.abort=function(){m=!0,a.call(this)}),null==u?d.send():"function"==typeof r.serialize?d.send(r.serialize(u)):u instanceof e.FormData||u instanceof e.URLSearchParams?d.send(u):d.send(JSON.stringify(u))}))}function l(e,t){for(var r in e.headers)if(n.call(e.headers,r)&&r.toLowerCase()===t)return!0;return!1}return r.prototype=Promise.prototype,r.__proto__=Promise,{request:function(e,n){"string"!=typeof e?(n=e,e=e.url):null==n&&(n={});var l=o(e,n);if(!0===n.background)return l;var i=0;function a(){0==--i&&"function"==typeof t&&t()}return function e(t){var n=t.then;return t.constructor=r,t.then=function(){i++;var r=n.apply(t,arguments);return r.then(a,(function(e){if(a(),0===i)throw e})),e(r)},t}(l)}}}("undefined"!=typeof window?window:null,p.redraw),g=p,w=f,b=function(){return s.apply(this,arguments)};b.m=s,b.trust=s.trust,b.fragment=s.fragment,b.Fragment="[",b.mount=g.mount;var x=s;function k(e){try{return decodeURIComponent(e)}catch(t){return e}}var S=function(e){if(""===e||null==e)return{};"?"===e.charAt(0)&&(e=e.slice(1));for(var t=e.split("&"),n={},r={},o=0;o<t.length;o++){var l=t[o].split("="),i=k(l[0]),a=2===l.length?k(l[1]):"";"true"===a?a=!0:"false"===a&&(a=!1);var s=i.split(/\]\[?|\[/),u=r;i.indexOf("[")>-1&&s.pop();for(var f=0;f<s.length;f++){var c=s[f],d=s[f+1],m=""==d||!isNaN(parseInt(d,10));if(""===c)null==n[i=s.slice(0,f).join()]&&(n[i]=Array.isArray(u)?u.length:0),c=n[i]++;else if("__proto__"===c)break;if(f===s.length-1)u[c]=a;else{var p=Object.getOwnPropertyDescriptor(u,c);null!=p&&(p=p.value),null==p&&(u[c]=p=m?[]:{}),u=p}}}return r},E=function(e){var t=e.indexOf("?"),n=e.indexOf("#"),r=n<0?e.length:n,o=t<0?r:t,l=e.slice(0,o).replace(/\/{2,}/g,"/");return l?"/"!==l[0]&&(l="/"+l):l="/",{path:l,params:t<0?{}:S(e.slice(t+1,r))}},z=new RegExp("^(?:key|oninit|oncreate|onbeforeupdate|onupdate|onbeforeremove|onremove)$"),j=function(e,t){var r={};if(null!=t)for(var o in e)n.call(e,o)&&!z.test(o)&&t.indexOf(o)<0&&(r[o]=e[o]);else for(var o in e)n.call(e,o)&&!z.test(o)&&(r[o]=e[o]);return r},O={};function A(e){try{return decodeURIComponent(e)}catch(t){return e}}b.route=function(t,n){var r,o,l,i,a,s,u=null==t?null:"function"==typeof t.setImmediate?t.setImmediate:t.setTimeout,f=Promise.resolve(),c=!1,d=!1,m=0,p=O,v={onbeforeupdate:function(){return!(!(m=m?2:1)||O===p)},onremove:function(){t.removeEventListener("popstate",w,!1),t.removeEventListener("hashchange",g,!1)},view:function(){if(m&&O!==p){var t=[e(l,i.key,i)];return p&&(t=p.render(t[0])),t}}},y=k.SKIP={};function g(){c=!1;var e=t.location.hash;"#"!==k.prefix[0]&&(e=t.location.search+e,"?"!==k.prefix[0]&&"/"!==(e=t.location.pathname+e)[0]&&(e="/"+e));var u=e.concat().replace(/(?:%[a-f89][a-f0-9])+/gim,A).slice(k.prefix.length),d=E(u);function v(e){console.error(e),b(o,null,{replace:!0})}Object.assign(d.params,t.history.state),function e(t){for(;t<r.length;t++)if(r[t].check(d)){var c=r[t].component,h=r[t].route,g=c,w=s=function(r){if(w===s){if(r===y)return e(t+1);l=null==r||"function"!=typeof r.view&&"function"!=typeof r?"div":r,i=d.params,a=u,s=null,p=c.render?c:null,2===m?n.redraw():(m=2,n.redraw.sync())}};return void(c.view||"function"==typeof c?(c={},w(g)):c.onmatch?f.then((function(){return c.onmatch(d.params,u,h)})).then(w,u===o?null:v):w("div"))}if(u===o)throw new Error("Could not resolve default route "+o+".");b(o,null,{replace:!0})}(0)}function w(){c||(c=!0,u(g))}function b(e,n,r){if(e=h(e,n),d){w();var o=r?r.state:null,l=r?r.title:null;r&&r.replace?t.history.replaceState(o,l,k.prefix+e):t.history.pushState(o,l,k.prefix+e)}else t.location.href=k.prefix+e}function k(e,l,i){if(!e)throw new TypeError("DOM element being rendered to does not exist.");if(r=Object.keys(i).map((function(e){if("/"!==e[0])throw new SyntaxError("Routes must start with a '/'.");if(/:([^\/\.-]+)(\.{3})?:/.test(e))throw new SyntaxError("Route parameter names must be separated with either '/', '.', or '-'.");return{route:e,component:i[e],check:(t=e,n=E(t),r=Object.keys(n.params),o=[],l=new RegExp("^"+n.path.replace(/:([^\/.-]+)(\.{3}|\.(?!\.)|-)?|[\\^$*+.()|\[\]{}]/g,(function(e,t,n){return null==t?"\\"+e:(o.push({k:t,r:"..."===n}),"..."===n?"(.*)":"."===n?"([^/]+)\\.":"([^/]+)"+(n||""))}))+"$"),function(e){for(var t=0;t<r.length;t++)if(n.params[r[t]]!==e.params[r[t]])return!1;if(!o.length)return l.test(e.path);var i=l.exec(e.path);if(null==i)return!1;for(t=0;t<o.length;t++)e.params[o[t].k]=o[t].r?i[t+1]:decodeURIComponent(i[t+1]);return!0})};var t,n,r,o,l})),o=l,null!=l){var a=E(l);if(!r.some((function(e){return e.check(a)})))throw new ReferenceError("Default route doesn't match any known routes.")}"function"==typeof t.history.pushState?t.addEventListener("popstate",w,!1):"#"===k.prefix[0]&&t.addEventListener("hashchange",g,!1),d=!0,n.mount(e,v),g()}return k.set=function(e,t,n){null!=s&&((n=n||{}).replace=!0),s=null,b(e,t,n)},k.get=function(){return a},k.prefix="#!",k.Link={view:function(e){var t,n,r,o=x(e.attrs.selector||"a",j(e.attrs,["options","params","selector","onclick"]),e.children);return(o.attrs.disabled=Boolean(o.attrs.disabled))?(o.attrs.href=null,o.attrs["aria-disabled"]="true"):(t=e.attrs.options,n=e.attrs.onclick,r=h(o.attrs.href,e.attrs.params),o.attrs.href=k.prefix+r,o.attrs.onclick=function(e){var o;"function"==typeof n?o=n.call(e.currentTarget,e):null==n||"object"!=typeof n||"function"==typeof n.handleEvent&&n.handleEvent(e),!1===o||e.defaultPrevented||0!==e.button&&0!==e.which&&1!==e.which||e.currentTarget.target&&"_self"!==e.currentTarget.target||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),e.redraw=!1,k.set(r,null,t))}),o}},k.param=function(e){return i&&null!=e?i[e]:i},k}("undefined"!=typeof window?window:null,g),b.render=m,b.redraw=g.redraw,b.request=y.request,b.parseQueryString=S,b.buildQueryString=v,b.parsePathname=E,b.buildPathname=h,b.vnode=e,b.censor=j,b.domFor=w.domFor,"undefined"!=typeof module?module.exports=b:window.m=b}();