import{r as t,h as e}from"./p-D0dWnGvB.js";var s=function(t,e){var s={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(s[o[i]]=t[o[i]])}return s};const o=class{constructor(e){t(this,e),this.data=[{selected:!0},{selected:!0}],this.rowDivider=!0,this.showSelectCheckBox=!0,this.alternate=!0,this.cells=[{propertyName:"test",isFilter:!1,isSort:!1,title:"Test",type:"propertyName",colSpan:1},{propertyName:"test",isFilter:!1,isSort:!1,title:"Test",type:"propertyName",colSpan:1}],this.contained=!0,this.sortedData=[],this.direction=!1,this.sortData=(t="up",e,s)=>{if("up"===t){const t=[...this.data.sort(((t,s)=>s[e]>t[e]?1:t[e]>s[e]?-1:0))];this.sortedData=t}else if("down"===t){const t=[...this.data.sort(((t,s)=>t[e]>s[e]?1:s[e]>t[e]?-1:0))];this.sortedData=t}this.cells[s].sort="down"==t?"up":"down"},this.handleSelectedRowChanges=(t,e)=>{const s=[...this.data];s[e].selected=t,this.sortedData=s,this.getSelectedRows&&this.getSelectedRows({selectedRows:s.filter((t=>t.selected)),currentSelectedRow:s[e],currentSelectedRowIndex:e})},this.selectAll=t=>{const e=[...this.data];e.forEach((e=>e.selected=t)),this.sortedData=e,this.getSelectedRows&&this.getSelectedRows({selectedRows:e})}}initializeData(t){if(t&&t.length>0){const e=[...t];this.sortedData=e}}componentWillLoad(){this.direction=document.dir?"rtl"===document.dir:!!document.documentElement.lang&&"ar"===document.documentElement.lang,this.initializeData(this.data)}render(){return console.log(this.sortedData,"this.sortedData"),e("div",{key:"1f9543a605c90fb731b87690b789befcb2fe1ff3",class:"table-wrapper "+(this.contained?"table-contained":"")},e("table",{key:"6fb15399504af87ab22a29e6dfdc06c3e0cb414d",class:" azm-table "+(this.contained?"table-contained":""),style:{direction:this.direction?"rtl":"ltr"}},e("thead",{key:"fc4bb6483281c5a35b7a84050a1b8e1120bbfb37"},e("tr",{key:"8d1c9aa85b88e9f5e4f8e89745d843cf0850acc2",class:this.rowDivider?"row-divider":""},this.showSelectCheckBox&&e("th",{key:"4b03683271eae037be53414cc1c59ff6c357f097",style:{width:"20px"}},e("dga-checkbox",{key:"ed30d783b71fb9b2b6c6e78eb971cbdf8b81dfe4",showBorderOnFocusAndFocusOute:!1,value:"true",onChange:t=>this.selectAll(t.target.checked)})),this.cells.map(((t,o)=>{var{sort:i,isSort:c,propertyName:n,type:a}=t,r=s(t,["sort","isSort","propertyName","type"]);return e("th",{key:o},e("span",null,e("span",{class:"text"},r.title),e("span",{class:"icon-wrapper"},c&&"up"==i&&"propertyName"==a&&e("button",{class:"dga-btn dga-btn--sort dga-btn--icon dga-btn--md",onClick:()=>this.sortData("up",n,o)},e("dga-icon",{icon:"SortByUp02Icon",variant:"stroke",type:"rounded",size:16})),c&&(!i||"down"==i)&&"propertyName"==a&&e("button",{class:"dga-btn dga-btn--sort dga-btn--icon dga-btn--md",onClick:()=>this.sortData("down",n,o)},e("dga-icon",{icon:"SortByDown02Icon",variant:"stroke",type:"rounded",size:16})),r.isFilter&&e("button",{class:"dga-btn dga-btn--sort dga-btn--icon dga-btn--md ",onClick:()=>this.pressOnFilter&&this.pressOnFilter(n)},e("dga-icon",{icon:"FilterIcon",variant:"stroke",type:"rounded",size:16})))))})))),e("tbody",{key:"33f8d0cc7ddf274c42700795d93fc36e959f3609"},this.sortedData.map(((t,o)=>e("tr",{class:`${this.rowDivider?"row-divider":""} ${this.alternate?"alternate":""} ${t.selected?"row-selected":""} `,key:o},this.showSelectCheckBox&&e("td",null,e("dga-checkbox",{name:o+"checkboxSelection",value:t.selected,id:o+"checkboxSelection",showBorderOnFocusAndFocusOute:!1,onChange:t=>this.handleSelectedRowChanges(t.target.checked,o),checked:t.selected})),this.cells.map(((o,i)=>{var{El:c}=o,n=s(o,["El"]);return e("td",{key:i,colSpan:n.colSpan?n.colSpan:1},"element"===n.type&&c?e(c,Object.assign({},t)):t[n.propertyName])}))))))))}};export{o as dga_data_table}