import*as t from"@momentum-ui/icons/data/momentumUiIconsNames.json";import*as e from"@momentum-ui/utils/lib/getColorValue";import*as r from"lit";import*as o from"lit/decorators.js";import*as s from"lit/directives/class-map.js";import*as a from"lit/directives/if-defined.js";import*as i from"lit/directives/style-map.js";import*as l from"mobx";import*as n from"papaparse";var d,p,m={3273(t,e,r){r.d(e,{X:()=>c,s:()=>m}),r(1821);var o=r(9609),s=r(4084),a=r(2927),i=r(8899),l=r(4955),n=r(6897),d=r(1928),p=function(t,e,r,o){var s,a=arguments.length,i=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,o);else for(var l=t.length-1;l>=0;l--)(s=t[l])&&(i=(a<3?s(i):a>3?s(e,r,i):s(e,r))||i);return a>3&&i&&Object.defineProperty(e,r,i),i};const m=["number","default"];var c;!function(t){let e=class extends a.LitElement{constructor(){super(...arguments),this.tabledata="",this.zebra=!1,this.clean=!1,this.sorting=!1,this.nodata="No data Loaded",this.stickheader=!1,this.label="Table",this.noBorders=!1,this.format="default",this.warning=[],this.errors=[],this.sort={columnName:"",sortting:!1},this.csvData=void 0,this.config={quoteChar:'"',escapeChar:'""',header:!1,preview:0,comments:!1,step:void 0,complete:void 0}}connectedCallback(){super.connectedCallback(),this.results=n.default.parse(this.tabledata,this.config),this.headerRow=this.results.data[0],this.csvData=this.results.data.slice(1,this.results.data.length)}get rowItem(){return this.rowTable}linkCellItems(){const t=this.rowTable;null==t||t.forEach((t,e)=>{this.warning.forEach(r=>{e+1===r.row&&t.querySelectorAll('td[role="cell"').forEach((t,e)=>{e+1===r.col&&(t.classList.add("warning"),t.insertAdjacentHTML("beforeend",'<md-icon name="warning-regular" size="24" iconSet="momentumDesign" color="var(--md-alert-warning-text-color)"></md-icon>'))})}),this.errors.forEach(r=>{e+1===r.row&&t.querySelectorAll('td[role="cell"').forEach((t,e)=>{e+1===r.col&&(t.classList.add("error"),t.insertAdjacentHTML("beforeend",'<md-icon name="clear-bold" size="24" iconSet="momentumDesign" color="var(--md-alert-error-text-color)"></md-icon>'))})})})}sortTab(t,e){const r=t.target,o=Array.from(this.csvData),s=this.headerRow.indexOf(e);e!==this.sort.columnName||!0!==this.sort.sortting?(o.sort(function(t,e){const r=t[s].toLowerCase(),o=e[s].toLowerCase();return r>o?1:r<o?-1:0}),this.sort.sortting=!0,r.classList.remove("sortedZyx"),r.classList.add("sortedAbc")):(o.reverse(),this.sort.sortting=!1,r.classList.remove("sortedAbc"),r.classList.add("sortedZyx")),this.sort.columnName=e,this.csvData=o,this.requestUpdate("csvData")}willUpdate(t){super.willUpdate(t),t.has("tabledata")&&(this.results=n.default.parse(this.tabledata,this.config),this.headerRow=this.results.data[0],this.csvData=this.results.data.slice(1,this.results.data.length))}updated(t){super.updated(t),t.has("tabledata")&&this.linkCellItems()}static get styles(){return[s.A,d.A]}get tableClassMap(){return{"md-table--clean":this.clean,"md-table--no-borders":this.noBorders,"md-table--stripped":this.zebra,"md-table--sorting":this.sorting}}getSortTemplate(t){return this.sort.columnName!==t?a.nothing:a.html`
        <md-icon
          name=${this.sort.sortting?"sort-descending-bold":"sort-ascending-bold"}
          iconSet="momentumDesign"
          size="16"
        ></md-icon>
      `}render(){return a.html`
        <div class=${"md-table-container "+(this.stickheader?"md-table-container_stickly":"")}>
          ${0!=this.csvData.length?a.html`
                <table
                  class="md-table ${(0,l.classMap)(this.tableClassMap)}"
                  tabindex="0"
                  role="table"
                  aria-label="${this.label}"
                >
                  <thead class="md-table__header" role="rowgroup" tabindex="0">
                    <tr role="row">
                      ${this.headerRow.map(t=>a.html`
                          <th role="columnheader">
                            ${this.sorting?a.html`
                                  <a @click=${e=>this.sortTab(e,t)}>
                                    ${t}${this.getSortTemplate(t)}
                                  </a>
                                `:a.html` ${t}`}
                          </th>
                        `)}
                    </tr>
                  </thead>
                  <tbody class="md-table__body" role="rowgroup">
                    ${this.csvData.map((t,e)=>a.html`
                        <tr tabindex="0" role="row" part=${0===e?"first-row":"row"}>
                          ${t.map((t,e)=>{const r="number"===this.format&&0!==e?Number(t).toLocaleString():t;return a.html`
                              <td part=${0===e?"left-cell":"cell"} role="cell">
                                <span>${r}</span>
                              </td>
                            `})}
                        </tr>
                      `)}
                  </tbody>
                </table>
              `:a.html` <p>${this.nodata}</p> `}
        </div>
      `}};p([(0,i.property)({type:String})],e.prototype,"tabledata",void 0),p([(0,i.property)({type:Boolean})],e.prototype,"zebra",void 0),p([(0,i.property)({type:Boolean})],e.prototype,"clean",void 0),p([(0,i.property)({type:Boolean})],e.prototype,"sorting",void 0),p([(0,i.property)({type:String})],e.prototype,"nodata",void 0),p([(0,i.property)({type:Boolean})],e.prototype,"stickheader",void 0),p([(0,i.property)({type:String})],e.prototype,"label",void 0),p([(0,i.property)({type:Boolean,attribute:"no-borders"})],e.prototype,"noBorders",void 0),p([(0,i.property)({type:String})],e.prototype,"format",void 0),p([(0,i.property)({type:Array})],e.prototype,"warning",void 0),p([(0,i.property)({type:Array})],e.prototype,"errors",void 0),p([(0,i.state)()],e.prototype,"sort",void 0),p([(0,i.state)()],e.prototype,"csvData",void 0),p([(0,i.queryAll)('.md-table__body tr[role="row"]')],e.prototype,"rowTable",void 0),e=p([(0,o.w)("md-table")],e),t.ELEMENT=e}(c||(c={}))},9500(e,r,o){var s,a;e.exports=(s={default:()=>t.default},a={},o.d(a,s),a)},3496(t,r,o){var s,a;t.exports=(s={default:()=>e.default},a={},o.d(a,s),a)},2927(t,e,o){var s,a;t.exports=(s={LitElement:()=>r.LitElement,css:()=>r.css,html:()=>r.html,nothing:()=>r.nothing},a={},o.d(a,s),a)},8899(t,e,r){var s,a;t.exports=(s={property:()=>o.property,query:()=>o.query,queryAll:()=>o.queryAll,state:()=>o.state},a={},r.d(a,s),a)},4955(t,e,r){var o,a;t.exports=(o={classMap:()=>s.classMap},a={},r.d(a,o),a)},3517(t,e,r){var o,s;t.exports=(o={ifDefined:()=>a.ifDefined},s={},r.d(s,o),s)},1156(t,e,r){var o,s;t.exports=(o={styleMap:()=>i.styleMap},s={},r.d(s,o),s)},4980(t,e,r){var o,s;t.exports=(o={action:()=>l.action,observable:()=>l.observable},s={},r.d(s,o),s)},6897(t,e,r){var o,s;t.exports=(o={default:()=>n.default},s={},r.d(s,o),s)}},c={};function h(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return m[t](r,r.exports,h),r.exports}h.m=m,d=[],h.O=(t,e,r,o)=>{if(!e){var s=1/0;for(n=0;n<d.length;n++){for(var[e,r,o]=d[n],a=!0,i=0;i<e.length;i++)(!1&o||s>=o)&&Object.keys(h.O).every(t=>h.O[t](e[i]))?e.splice(i--,1):(a=!1,o<s&&(s=o));if(a){d.splice(n--,1);var l=r();void 0!==l&&(t=l)}}return t}o=o||0;for(var n=d.length;n>0&&d[n-1][2]>o;n--)d[n]=d[n-1];d[n]=[e,r,o]},h.d=(t,e)=>{for(var r in e)h.o(e,r)&&!h.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{h as __webpack_require__};p={502:0,1745:0,4545:0,4928:0,5369:0,6060:0,6920:0,8111:0,8442:0,8510:0},h.C=t=>{var e,r,{__webpack_esm_ids__:o,__webpack_esm_modules__:s,__webpack_esm_runtime__:a}=t,i=0;for(e in s)h.o(s,e)&&(h.m[e]=s[e]);for(a&&a(h);i<o.length;i++)r=o[i],h.o(p,r)&&p[r]&&p[r][0](),p[o[i]]=0;h.O()},h.O.j=t=>0===p[t];import*as f from"../9609.js";h.C(f);import*as u from"../4084.js";h.C(u);import*as b from"../3305.js";h.C(b);import*as y from"../4739.js";h.C(y);import*as v from"../7154.js";h.C(v);import*as g from"../9773.js";h.C(g);import*as w from"../5983.js";h.C(w);import*as j from"../9488.js";h.C(j);import*as x from"../1821.js";h.C(x);import*as _ from"../519.js";h.C(_);import*as C from"../1928.js";h.C(C);var $=h.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9488,1821,519,1928],()=>h(3273));const L=($=h.O($)).X,D=$.s;export{L as Table,D as formatType};