(function(){'use strict';var v;{const a={},b={},c={},d=document.documentElement||document.body.parentNode,e="ontouchstart"in window,f=!e&&window.PointerEvent&&navigator.maxTouchPoints;let g;function u(k,h){h||(h=k.type);const m=k.target;let p=m;var l=m["_event_"+h];if(l)p=m["_root_"+h];else{for(;p!==d;){"click"===h&&g&&(l=p.getAttribute("tap"));l||(l=p.getAttribute(h));if(l){var n=l.indexOf(":");if(-1!==n){const w=l.substring(0,n);n=l.substring(n+1);l=0;for(p=p.parentElement;p!==d;){if(p.hasAttribute(n)){l=w;break}p=p.parentElement}}break}p=
p.parentElement}if(!l)return;m["_event_"+h]=l;m["_root_"+h]=p}h=b[l];l=c[l];h&&(!1!==l.cancel&&k.preventDefault(),h(p,k,m));!1!==l.stop&&k.stopPropagation()}x.route=x.prototype.o=function(k,h,m){b[k]=h;c[k]=m||{};return this};x.dispatch=function(k,h,m,p){b[k].call(this,h,m,p);return this};let q,r,t;if(e||f){function k(l){m(l,l.touches)}function h(l){let n=q,w=r;m(l,l.changedTouches);50>Math.abs(q-n)&&50>Math.abs(r-w)&&u.call(this,l,"tap")}function m(l,n){n&&(l=n[0]);q=l.clientX;r=l.clientY}const p=
{passive:!1,capture:!0};t=function(l){y(l,f?"pointerdown":"touchstart",k,p);y(l,f?"pointerup":"touchend",h,p)}}x.listen=x.prototype.N=function(k,h){a[k]||(y(1,k,u,h),a[k]=1);return this};x.unlisten=function(k,h){a[k]&&(y(0,k,u,h),a[k]=0);return this};function y(k,h,m,p){if("tap"===h){if(e||f){t(k);return}g=!0;h="click"}window[(k?"add":"remove")+"EventListener"](h,m,p||!1)}};const z=Array.prototype,A=window.Proxy;let B=0;function C(a){if(!(this instanceof C))return new C(a);if(a instanceof C)return a;this.g=null;const b=a?a.length:0;if(A){if(b)for(let c=0;c<b;c++)this[c]=a[c];this.length=b;this.m={splice:z.splice.bind(this),pop:z.pop.bind(this),shift:z.shift.bind(this),unshift:z.unshift.bind(this),push:z.push.bind(this)};return new Proxy(this,D)}this.m=a||[];for(a=0;a<=b;a++)E(this,a);B=b;E(this,"length")}
function E(a,b){Object.defineProperty(a,b,{get:function(){return this.m[b]},set:function(c){"number"===typeof b&&(b===B&&E(this,++B),D.set(this,b,c))}})}let F=!1;
const D={set:function(a,b,c){if("number"===typeof b)var d=!0;else{var e=parseInt(b,10);b===""+e&&(b=e,d=!0)}if(!F){F=!0;if((e=a.g)&&!e.B){var f=a.length;if(d){d=e.length;f!==d&&(a.length=d);if(e.C&&a[b]===c)return F=!1,!0;f=e.view;b>=d?(e.add(c,f),a.length++):b<d&&(d=e.f[b],e.K?e.update(d,c,f,b):e.replace(d,c,f,b));if(e.proxy)return F=!1,!0}else"length"===b&&c<f&&e.remove(c,f-c)}F=!1}(A?a:a.m)[b]=c;return!0}};v=C.prototype;v.set=function(a){this.splice();return this.concat(a)};
v.splice=function(a,b,c){F=!0;a||(a=0);"undefined"===typeof b&&(b=this.length-a,0>b&&(b=0));b&&this.g.remove(a,b);b=c?this.m.splice(a,b,c):this.m.splice(a,b);c&&this.g.add(c,a,this.g.view);F=!1;return b};v.push=function(a){F=!0;this.g.add(a,this.g.view);this.g.proxy||(this[this.length]=a);A&&this.length++;F=!1};v.unshift=function(a){F=!0;this.g.add(a,0,this.g.view);this.m.unshift(a);F=!1};v.pop=function(){F=!0;this.g.remove(this.length-1);const a=this.m.pop();F=!1;return a};
v.shift=function(){F=!0;this.g.remove(0);const a=this.m.shift();F=!1;return a};v.concat=function(a){const b=a.length;for(let c=0;c<b;c++)this.push(a[c]);return this};v.sort=z.sort;v.reverse=z.reverse;v.slice=z.slice;v.map=function(a,b){b&&(a=a.bind(this));for(let c=0,d=this.length;c<d;c++)this[c]=a(this[c]);return this};v.filter=function(a,b){b&&(a=a.bind(this));let c,d;for(let e=0,f=this.length;e<f;e++)a(this[e])?d&&(this.splice(c,d),f-=d,e-=d,d=0):d?d++:(c=e,d=1);d&&this.splice(c,d);return this};
v.indexOf=function(a){for(let b=0,c=this.length;b<c;b++)if(this[b]===a)return b;return-1};v.lastIndexOf=function(a){for(let b=this.length-1;0<=b;b--)if(this[b]===a)return b;return-1};v.forEach=function(a){for(let b=0,c=this.length;b<c;b++)a(this[b])};const H=!window.Proxy&&function(){function a(b,c){this.path=c.path;this.F=c.F;c=Object.keys(b);for(let d=0,e=c.length;d<e;d++){const f=c[d];this.b(b,f,b[f])}return b}a.prototype._proxy=!0;a.prototype.b=function(b,c,d){const e=this;Object.defineProperty(b,c,{get:function(){return d},set:function(f){d!==f&&(G(e.F,e.path,c,f),d=f)}})};return a}(),I={_text:function(a,b){a.nodeValue=b},_html:function(a,b){a.innerHTML=b},_class:function(a,b){a.className=b},_css:function(a,b){(a._style||(a._style=a.style)).cssText=
b},_attr:function(a,b,c){a.setAttribute(c,b)}};function J(a,b,c){return new (H||Proxy)(a,{path:b,F:c,get:K,set:aa})}function K(a,b){return"_proxy"===b||a[b]}function aa(a,b,c){a[b]!==c&&(G(this.F,this.path,b,c),a[b]=c);return!0}function G(a,b,c,d){if(a=a["data."+c])for(let e=0,f=a.length,g;e<f;e++)g=a[e],I[g[0]](b[g[1]],d,g[2]||c)};let ba={};const L={};
function x(a,b,c){if(!(this instanceof x))return new x(a,b,c);a.nodeType||(c=b,b=a,a=null);a?this.mount(a):(this.b=this.f=null,this.length=0);a=b;"string"===typeof a?a=L[a]:(c||!a||a.n||(c=a,a=null),a?a.n&&ca(a):a=L[this.u]);c||(c=this.M||{});this.K=!1!==c.reuse;this.state=c.state||ba;b=c.store||!1!==c.store;(this.G="object"===typeof b)?c.store=!0:b&&(b=[]);if(this.observe=b instanceof C)b.g=this;this.B=0;this.D=!this.G&&!1!==c.loose;this.store=!this.D&&b;this.M=c;b=a.n;this.u!==b&&(this.u=b,this.H=
a.d,this.J=this.A=null,this.proxy=this.C=0,this.I=!1!==c.prefetch&&M(this,a),N(this),this.l=(this.key=a.k)&&{})}var ca=x.register=function(a,b){b||(b=a,a=b.n);L[a]=b;return x};x.prototype.mount=function(a){if(this.b!==a){this.key&&this.b&&(this.b._pool=this.l,this.l=a._pool||{});this.b=a;N(this);var b;if(!(b=a._dom)){{b=a.children;let c=b.length;const d=Array(c);for(let e=0,f;e<c;e++)f=b[e],d[e]=f;b=d}b=a._dom=b}this.f=b;this.length=this.f.length}return this};x.prototype.index=function(a){return this.f.indexOf(a)};
x.prototype.data=function(a){const b="object"===typeof a;return this.store?this.store[b?this.index(a):a]:(b?a:this.f[a])._data};var da=x.once=function(a,b,c,d,e){const f=new x(a,b);"function"===typeof d&&(e=d,d=null);if(e){const g=e;e=function(){O(f);g()}}f.render(c,d,e);e||O(f);return x};function N(a){if(a.b){const b=a.b._tpl;b!==a.u&&(a.b._tpl=a.u,b&&(a.l={},a.remove(0,a.length)))}}v=x.prototype;
v.create=function(a,b,c){let d=this.key;const e=d&&a[d];let f,g;f=g=this.I||(this.I=M(this,L[this.u]));this.apply(f,a,b,c);g&&(f=f.cloneNode(!0));d&&(f._key=e,this.l[e]=f);return f};v.apply=function(a,b,c,d){if(!this.H)return b||(b=this.store?this.store[d]:a._data),this.J(a._path||P(this,a),!1,b,d,c),this};
v.refresh=function(a,b){if(this.C)return this;var c;"number"===typeof a?c=this.f[a]:b=a;if(c)return this.apply(c,null,b,a);a=this.length;if((c=this.store)&&this.D)return this.store=null,this.render(c,b);c=c?c.length:a;a=a<c?a:c;for(c=0;c<a;c++)this.apply(this.f[c],null,b,c);return this};
v.render=function(a,b){var c=this.length;if(!a){if(this.H)return this.f[0]||this.add(),this;if(!(a=this.store))return this}var d=a.length;if("undefined"===typeof d)a=[a],d=1;else if(!d)return this.remove(0,c);var e=!this.K&&this.key;e||this.K||(this.remove(0,c,d),c=0);var f=c<d?c:d,g=0;if(g<f)for(;g<f;g++){var u=this.f[g],q=a[g];if(e&&u._key!==q[e]){{if(c=!this.G&&this.store)a||(a=c),this.store=0;d=this.f;e=this.l;f=a.length;u=d.length;q=u>f?u:f;let y=0;const k=this.key;for(g||(g=0);g<q;g++){var r=
void 0;if(g<f){const h=a[g];var t=g>=u;let m,p,l;if(!t&&(m=d[g],p=h[k],l=m._key,l===p)){this.update(m,h,b,g);continue}if(t||!e[p]){t||!this.O?(u++,q=u>f?u:f,this.add(h,b,g)):this.replace(m,h,b,g);continue}let n,w;for(t=g+1;t<q;t++)if(!n&&t<u&&d[t]._key===p&&(n=t+1),!w&&t<f&&a[t][k]===l&&(w=t+1),n&&w){n>=w?(r=d[n-1],this.b.insertBefore(r,m),this.update(r,h,b,g),n===w?(1<t-g&&this.b.insertBefore(m,d[n]),d[g]=d[t],d[t]=m):(Q(d,n-1,g),y++)):(r=w-1+y,this.b.insertBefore(m,d[r]||null),Q(d,g,(r>u?u:r)-1),
y--,g--);r=1;break}}r||(this.remove(g),u--,q=u>f?u:f,g--)}c&&(this.store=a)}return this}this.update(u,q,b,g)}if(g<d)for(;g<d;g++)this.add(a[g],b);else d<c&&this.remove(d,c-d);return this};function Q(a,b,c,d){const e=d||a[b];d&&b++;if(b<c)for(;b<c;b++)a[b]=a[b+1];else for(;b>c;b--)a[b]=a[b-1];a[c]=e}
v.add=function(a,b,c,d){let e;if(!d)if("number"===typeof b)c=b,b=null,e=1;else if(c||0===c)e=1;c=d||e?c:this.length;b=this.create(a,b,c);{let f;this.proxy&&(this.C&&this.D&&b._data===a?f=1:a._proxy||(a=J(a,b._path||P(this,b),this.proxy)));f||(this.store?e&&!this.G?Q(this.store,this.length-1,c,a):(this.B=1,this.store[c]=a,this.B=0):this.D&&(b._data=a))}e?(this.b.insertBefore(b,this.f[c]),Q(this.f,this.length-1,c,b),this.length++):(d?this.b.replaceChild(b,d):(this.b.appendChild(b),this.length++),this.f[c]=
b);return this};function O(a){a.L();a.length=0;a.f=a.b=a.u=a.A=a.J=a.I=null;a.l=null;a.store=null}
v.remove=function(a,b,c){let d=this.length;a&&("object"===typeof a?a=this.index(a):0>a&&(a=d+a-1));if(!d||a>=d)return this;b?0>b&&(a-=b+1,0>a&&(a=0),b*=-1):b=1;!a&&b>=d?(this.store&&!this.G&&(this.store=c?Array(c):[]),a=this.f,b=a.length,this.b.textContent="",this.b._dom=this.f=c?Array(c):[],d=0):(this.store&&!this.observe&&this.store.splice(a,b),a=this.f.splice(a,b),d-=b);this.length=d;for(let e=0,f;e<b;e++)f=a[e],d&&this.b.removeChild(f),this.key&&(this.l[f._key]=null);return this};
v.replace=function(a,b,c,d){"undefined"===typeof d&&("number"===typeof a?(d=a,a=this.f[d]):d=this.index(a));let e;if(this.key&&(e=this.l[b[this.key]])){this.C||b._proxy||this.apply(a,b,c,d);if(e!==a){c=this.index(e);if(this.store){this.B=1;let f=this.store[d];this.store[d]=b;this.store[c]=f;this.B=0}this.f[d]=e;this.f[c]=a;c<d&&(b=a,a=e,e=b);b=a.nextElementSibling;this.b.insertBefore(a,e);b!==e&&this.b.insertBefore(e,b)}return this}this.add(b,c,d,a);this.key&&(this.l[a._key]=null);return this};
v.update=function(a,b,c,d){"undefined"===typeof d&&("number"===typeof a?(d=a,a=this.f[a]):d=this.index(a));if(this.proxy){if(this.C&&this.store[d]===b)return this;b._proxy||(b=J(b,a._path||P(this,a),this.proxy))}this.store?(this.B=1,this.store[d]=b,this.B=0):this.D&&(a._data=b);if(this.key){const e=a._key,f=b[this.key];e!==f&&(this.l[e]=null,this.l[f]=a,a._key=f)}return this.apply(a,b,c,d)};
function P(a,b){const c=a.A.length,d={},e=Array(c);for(let r=0,t;r<c;r++){t=a.A[r];var f=r,g;if(!(g=d[t])){g=b;var u=t,q=d;for(let y=0,k=u.length,h="";y<k;y++){const m=u[y];h+=m;q[h]?g=q[h]:(">"===m?g=g.firstElementChild:"+"===m?g=g.nextElementSibling:"|"===m&&(g=g.firstChild),q[h]=g)}}e[f]=g}return b._path=e}let R;
function M(a,b,c,d,e){const f=document.createElement(b.t||"div");c||(c=0,d="&",R="",a.A=[],f._path=e=[]);var g=b.s;let u=b.i;var q=b.x,r=b.h,t=b.a;const y=b.e;var k=b.c,h=b.j;b=a.A.length;let m=0,p=0,l="";h&&(l+=";"+h,-1<l.indexOf("self")&&(m=2));k&&("object"===typeof k?(h=k[1],k=""+k[0],l+=k?";self.className="+k:"",h&&(S(a,k,["_class",b]),p++),m++):f.className=k);if(t||y){let n;t&&(n=Object.keys(t));y&&(k=Object.keys(y),n=n?n.concat(k):k);for(k=0;k<n.length;k++){h=n[k];let w;t&&"undefined"!==typeof(w=
t[h])||(w=y[h],a.N(h));if("object"===typeof w){let ea=w[1];w=""+w[0];l+=w?";v="+w+";self[v||v===0?'setAttribute':'removeAttribute']('"+h+"',v)":"";ea&&(S(a,w,["_attr",b,h]),p++);m++}else f.setAttribute(h,w)}}g&&("string"===typeof g?f.style.cssText=g:g.length&&(t=g[1],g=g[0],l+=g?";self.style.cssText="+g:"",t&&(S(a,g,["_css",b]),p++),m++));if(!u)if(q){let n;if(r="object"===typeof q)n=q[1],q=""+q[0];g=document.createTextNode(q);r&&(m&&b++,a.A[b]=d+"|",e[b]=g,T(m,q?";self.nodeValue="+q:"",b),n&&(S(a,
q,["_text",b]),p++),m&&b--);f.appendChild(g)}else r&&("object"===typeof r?(q=r[1],r=""+r[0],l+=r?";self.innerHTML="+r:"",q&&(S(a,r,["_html",b]),p++),m++):f.innerHTML=r);m?(a.A[b]=d,e[b]=f,a.H=0,m===p&&(a.C=1),T(m,l,b)):l&&(R+=l);if(u)if(u.length){q=">";for(let n=0,w;n<u.length;n++)n&&(q+="+"),w=u[n],f.appendChild(M(a,w,c+n+1,d+q,e))}else f.appendChild(M(a,u,c+1,d+">",e));c||a.H||!R||(a.J=Function("p","s","data","index","view",'"use strict";var self,v'+R));return f}
function S(a,b,c){a.proxy||(a.proxy={});(a.proxy[b]||(a.proxy[b]=[])).push(c)}function T(a,b,c){R=1<a?R+(";self=p["+c+"]"+b):R+b.replace(/self/g,"p["+c+"]")}x.prototype.L=function(a){a?"object"===typeof a&&(a=a.n):a=this.u;a&&(L[a]=null);return this};x.unregister=x.unload=x.prototype.L;const U="pretty large big small tall short long handsome plain quaint clean elegant easy angry crazy helpful mushy odd unsightly adorable important inexpensive cheap expensive fancy".split(" "),V="red yellow blue green pink brown purple brown white black orange".split(" "),W="table chair house bbq desk car pony cookie sandwich burger pizza mouse keyboard".split(" "),fa=U.length,ha=V.length,ia=W.length;let ja=1;
function X(a){const b=Array(a);for(let c=0;c<a;c++)b[c]={id:ja++,label:U[Math.random()*fa|0]+" "+V[Math.random()*ha|0]+" "+W[Math.random()*ia|0]};return b};da(document.getElementById("main"),{i:[{i:{i:[{i:{t:"h1",x:'Mikado-"keyed"'},c:"col-md-6"},{i:{i:[{i:{t:"button",a:{type:"button",id:"run"},c:"btn btn-primary btn-block",e:{click:"run"},x:"Create 1,000 rows"},c:"col-sm-6 smallpad"},{i:{t:"button",a:{type:"button",id:"runlots"},c:"btn btn-primary btn-block",e:{click:"runlots"},x:"Create 10,000 rows"},c:"col-sm-6 smallpad"},{i:{t:"button",a:{type:"button",id:"add"},c:"btn btn-primary btn-block",e:{click:"add"},x:"Append 1,000 rows"},c:"col-sm-6 smallpad"},
{i:{t:"button",a:{type:"button",id:"update"},c:"btn btn-primary btn-block",e:{click:"update"},x:"Update every 10th row"},c:"col-sm-6 smallpad"},{i:{t:"button",a:{type:"button",id:"clear"},c:"btn btn-primary btn-block",e:{click:"clear"},x:"Clear"},c:"col-sm-6 smallpad"},{i:{t:"button",a:{type:"button",id:"swaprows"},c:"btn btn-primary btn-block",e:{click:"swaprows"},x:"Swap Rows"},c:"col-sm-6 smallpad"}],c:"row"},c:"col-md-6"}],c:"row"},c:"jumbotron"},{t:"table",i:{t:"tbody",a:{id:"tbody"}},c:"table table-hover table-striped test-data"},
{t:"span",a:{"aria-hidden":"true"},c:"preloadicon glyphicon glyphicon-remove"}],c:"container",d:!0,n:"app",v:"0.7.58"});
const Y=new C,Z=(new x(document.getElementById("tbody"),{t:"tr",a:{root:""},i:[{t:"td",c:"col-md-1",x:["data.id",1]},{t:"td",i:{t:"a",c:"lbl",e:{click:"select:root"},x:["data.label",1]},c:"col-md-4"},{t:"td",i:{t:"a",i:{t:"span",a:{"aria-hidden":"true"},c:"remove glyphicon glyphicon-remove"},c:"remove",e:{click:"remove:root"}},c:"col-md-1"},{t:"td",c:"col-md-6"}],c:["(this.selected === index ? 'danger' : '')"],k:"id",d:!1,n:"item",v:"0.7.58"},{reuse:!1,store:Y})).o("run",()=>Y.set(X(1E3))).o("runlots",
()=>Y.set(X(1E4))).o("add",()=>Y.concat(X(1E3))).o("update",()=>{for(let a=0,b=Y.length;a<b;a+=10)Y[a].label+=" !!!"}).o("clear",()=>Y.splice()).o("swaprows",()=>{const a=Y[998];Y[998]=Y[1];Y[1]=a}).o("remove",a=>Y.splice(Z.index(a),1)).o("select",a=>Z.refresh(Z.selected=Z.index(a)));}).call(this);
