import{a as e}from"./assets/vendor.e3aed3a9.js";const i=n=>Math.round(Math.random()*1e3)%n,h=["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"],p=["red","yellow","blue","green","pink","brown","purple","brown","white","black","orange"],m=["table","chair","house","bbq","desk","car","pony","cookie","sandwich","burger","pizza","mouse","keyboard"];let u=1;const o=n=>{const a=new Array(n);for(let s=0;s<n;s++)a[s]={id:u++,label:`${h[i(h.length)]} ${p[i(p.length)]} ${m[i(m.length)]}`};return a},b={data:[],selected:0};class y extends e.Component{shouldComponentUpdate(a){const{item:s,selected:t}=this.props;return a.item!==s||a.selected!==t}constructor(a){super(a);this.onSelect=()=>{const{item:s,dispatch:t}=this.props;t({type:"SELECT",id:s.id})},this.onRemove=()=>{const{item:s,dispatch:t}=this.props;t({type:"REMOVE",id:s.id})}}render(){const{selected:a,item:s}=this.props;return e.h("tr",{className:a?"danger":""},e.h("td",{className:"col-md-1"},s.id),e.h("td",{className:"col-md-4"},e.h("a",{onClick:this.onSelect},s.label)),e.h("td",{className:"col-md-1"},e.h("a",{onClick:this.onRemove},e.h("span",{className:"glyphicon glyphicon-remove","aria-hidden":"true"}))),e.h("td",{className:"col-md-6"}))}}class r extends e.Component{render(){const{id:a,cb:s,title:t}=this.props;return e.h("div",{className:"col-sm-6 smallpad"},e.h("button",{type:"button",className:"btn btn-primary btn-block",id:a,onClick:s},t))}}class N extends e.Component{shouldComponentUpdate(){return!1}render(){const{dispatch:a}=this.props;return e.h("div",{className:"jumbotron"},e.h("div",{className:"row"},e.h("div",{className:"col-md-6"},e.h("h1",null,"Art keyed")),e.h("div",{className:"col-md-6"},e.h("div",{className:"row"},e.h(r,{id:"run",title:"Create 1,000 rows",cb:()=>a({type:"RUN"})}),e.h(r,{id:"runlots",title:"Create 10,000 rows",cb:()=>a({type:"RUN_LOTS"})}),e.h(r,{id:"add",title:"Append 1,000 rows",cb:()=>a({type:"ADD"})}),e.h(r,{id:"update",title:"Update every 10th row",cb:()=>a({type:"UPDATE"})}),e.h(r,{id:"clear",title:"Clear",cb:()=>a({type:"CLEAR"})}),e.h(r,{id:"swaprows",title:"Swap Rows",cb:()=>a({type:"SWAP_ROWS"})})))))}}class g extends e.Component{constructor(a){super(a);this.data=b,this.dispatch=s=>{const{data:t}=this.data;switch(s.type){case"RUN":return this.setData({data:o(1e3),selected:0});case"RUN_LOTS":return this.setData({data:o(1e4),selected:0});case"ADD":return this.setData({data:t.concat(o(1e3))});case"UPDATE":{const d=t.slice(0);for(let l=0;l<d.length;l+=10){const c=d[l];d[l]={id:c.id,label:c.label+" !!!"}}return this.setData({data:d})}case"CLEAR":return this.setData({data:[],selected:0});case"SWAP_ROWS":return t.length>998?this.setData({data:[t[0],t[998],...t.slice(2,998),t[1],t[999]]}):void 0;case"REMOVE":{const d=t.findIndex(l=>l.id===s.id);return this.setData({data:[...t.slice(0,d),...t.slice(d+1)]})}case"SELECT":return this.setData({selected:s.id})}}}render(){const{data:a,selected:s}=this.data;return e.h("div",{className:"container"},e.h(N,{dispatch:this.dispatch}),e.h("table",{className:"table table-hover table-striped test-data"},e.h("tbody",null,a.map(t=>e.h(y,{key:t.id,item:t,selected:s===t.id,dispatch:this.dispatch})))),e.h("span",{className:"preloadicon glyphicon glyphicon-remove","aria-hidden":"true"}))}}e.render(e.h(g,null),document.getElementById("root"));
