UNPKG

@trimble-oss/moduswebcomponents

Version:

Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust

12 lines 73.4 kB
import{r as t,c as e,h as o,H as l,g as n}from"./p-D_4hbGjA.js";import{i as r}from"./p-BLBSdonk.js";
/**
   * table-core
   *
   * Copyright (c) TanStack
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE.md file in the root directory of this source tree.
   *
   * @license MIT
   */
function a(t,e){return"function"==typeof t?t(e):t}function u(t,e){return o=>{e.setState((e=>({...e,[t]:a(o,e[t])})))}}function i(t){return t instanceof Function}function s(t,e,o){let l,n=[];return r=>{let a;o.key&&o.debug&&(a=Date.now());const u=t(r);if(u.length===n.length&&!u.some(((t,e)=>n[e]!==t)))return l;let i;if(n=u,o.key&&o.debug&&(i=Date.now()),l=e(...u),null==o||null==o.onChange||o.onChange(l),o.key&&o.debug&&null!=o&&o.debug()){const t=Math.round(100*(Date.now()-a))/100,e=Math.round(100*(Date.now()-i))/100,l=e/16,n=(t,e)=>{for(t=String(t);t.length<e;)t=" "+t;return t};console.info(`%c⏱ ${n(e,5)} /${n(t,5)} ms`,`\n            font-size: .6rem;\n            font-weight: bold;\n            color: hsl(${Math.max(0,Math.min(120-120*l,120))}deg 100% 31%);`,null==o?void 0:o.key)}return l}}function c(t,e,o,l){return{debug:()=>{var o;return null!=(o=null==t?void 0:t.debugAll)?o:t[e]},key:!1,onChange:l}}const d="debugHeaders";function h(t,e,o){var l;let n={id:null!=(l=o.id)?l:e.id,column:e,index:o.index,isPlaceholder:!!o.isPlaceholder,placeholderId:o.placeholderId,depth:o.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const t=[],e=o=>{o.subHeaders&&o.subHeaders.length&&o.subHeaders.map(e),t.push(o)};return e(n),t},getContext:()=>({table:t,header:n,column:e})};return t._features.forEach((e=>{null==e.createHeader||e.createHeader(n,t)})),n}const m={createTable:t=>{t.getHeaderGroups=s((()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right]),((e,o,l,n)=>{var r,a;const u=null!=(r=null==l?void 0:l.map((t=>o.find((e=>e.id===t)))).filter(Boolean))?r:[],i=null!=(a=null==n?void 0:n.map((t=>o.find((e=>e.id===t)))).filter(Boolean))?a:[];return b(e,[...u,...o.filter((t=>!(null!=l&&l.includes(t.id)||null!=n&&n.includes(t.id)))),...i],t)}),c(t.options,d)),t.getCenterHeaderGroups=s((()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right]),((e,o,l,n)=>b(e,o=o.filter((t=>!(null!=l&&l.includes(t.id)||null!=n&&n.includes(t.id)))),t,"center")),c(t.options,d)),t.getLeftHeaderGroups=s((()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left]),((e,o,l)=>{var n;return b(e,null!=(n=null==l?void 0:l.map((t=>o.find((e=>e.id===t)))).filter(Boolean))?n:[],t,"left")}),c(t.options,d)),t.getRightHeaderGroups=s((()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.right]),((e,o,l)=>{var n;return b(e,null!=(n=null==l?void 0:l.map((t=>o.find((e=>e.id===t)))).filter(Boolean))?n:[],t,"right")}),c(t.options,d)),t.getFooterGroups=s((()=>[t.getHeaderGroups()]),(t=>[...t].reverse()),c(t.options,d)),t.getLeftFooterGroups=s((()=>[t.getLeftHeaderGroups()]),(t=>[...t].reverse()),c(t.options,d)),t.getCenterFooterGroups=s((()=>[t.getCenterHeaderGroups()]),(t=>[...t].reverse()),c(t.options,d)),t.getRightFooterGroups=s((()=>[t.getRightHeaderGroups()]),(t=>[...t].reverse()),c(t.options,d)),t.getFlatHeaders=s((()=>[t.getHeaderGroups()]),(t=>t.map((t=>t.headers)).flat()),c(t.options,d)),t.getLeftFlatHeaders=s((()=>[t.getLeftHeaderGroups()]),(t=>t.map((t=>t.headers)).flat()),c(t.options,d)),t.getCenterFlatHeaders=s((()=>[t.getCenterHeaderGroups()]),(t=>t.map((t=>t.headers)).flat()),c(t.options,d)),t.getRightFlatHeaders=s((()=>[t.getRightHeaderGroups()]),(t=>t.map((t=>t.headers)).flat()),c(t.options,d)),t.getCenterLeafHeaders=s((()=>[t.getCenterFlatHeaders()]),(t=>t.filter((t=>{var e;return!(null!=(e=t.subHeaders)&&e.length)}))),c(t.options,d)),t.getLeftLeafHeaders=s((()=>[t.getLeftFlatHeaders()]),(t=>t.filter((t=>{var e;return!(null!=(e=t.subHeaders)&&e.length)}))),c(t.options,d)),t.getRightLeafHeaders=s((()=>[t.getRightFlatHeaders()]),(t=>t.filter((t=>{var e;return!(null!=(e=t.subHeaders)&&e.length)}))),c(t.options,d)),t.getLeafHeaders=s((()=>[t.getLeftHeaderGroups(),t.getCenterHeaderGroups(),t.getRightHeaderGroups()]),((t,e,o)=>{var l,n,r,a,u,i;return[...null!=(l=null==(n=t[0])?void 0:n.headers)?l:[],...null!=(r=null==(a=e[0])?void 0:a.headers)?r:[],...null!=(u=null==(i=o[0])?void 0:i.headers)?u:[]].map((t=>t.getLeafHeaders())).flat()}),c(t.options,d))}};function b(t,e,o,l){var n,r;let a=0;const u=function(t,e){void 0===e&&(e=1),a=Math.max(a,e),t.filter((t=>t.getIsVisible())).forEach((t=>{var o;null!=(o=t.columns)&&o.length&&u(t.columns,e+1)}),0)};u(t);let i=[];const s=(t,e)=>{const n={depth:e,id:[l,`${e}`].filter(Boolean).join("_"),headers:[]},r=[];t.forEach((t=>{const a=[...r].reverse()[0];let u,i=!1;if(t.column.depth===n.depth&&t.column.parent?u=t.column.parent:(u=t.column,i=!0),a&&(null==a?void 0:a.column)===u)a.subHeaders.push(t);else{const n=h(o,u,{id:[l,e,u.id,null==t?void 0:t.id].filter(Boolean).join("_"),isPlaceholder:i,placeholderId:i?`${r.filter((t=>t.column===u)).length}`:void 0,depth:e,index:r.length});n.subHeaders.push(t),r.push(n)}n.headers.push(t),t.headerGroup=n})),i.push(n),e>0&&s(r,e-1)},c=e.map(((t,e)=>h(o,t,{depth:a,index:e})));s(c,a-1),i.reverse();const d=t=>t.filter((t=>t.column.getIsVisible())).map((t=>{let e=0,o=0,l=[0];return t.subHeaders&&t.subHeaders.length?(l=[],d(t.subHeaders).forEach((t=>{let{colSpan:o,rowSpan:n}=t;e+=o,l.push(n)}))):e=1,o+=Math.min(...l),t.colSpan=e,t.rowSpan=o,{colSpan:e,rowSpan:o}}));return d(null!=(n=null==(r=i[0])?void 0:r.headers)?n:[]),i}const v=(t,e,o,l,n,r,a)=>{let u={id:e,index:l,original:o,depth:n,parentId:a,_valuesCache:{},_uniqueValuesCache:{},getValue:e=>{if(u._valuesCache.hasOwnProperty(e))return u._valuesCache[e];const o=t.getColumn(e);return null!=o&&o.accessorFn?(u._valuesCache[e]=o.accessorFn(u.original,l),u._valuesCache[e]):void 0},getUniqueValues:e=>{if(u._uniqueValuesCache.hasOwnProperty(e))return u._uniqueValuesCache[e];const o=t.getColumn(e);return null!=o&&o.accessorFn?o.columnDef.getUniqueValues?(u._uniqueValuesCache[e]=o.columnDef.getUniqueValues(u.original,l),u._uniqueValuesCache[e]):(u._uniqueValuesCache[e]=[u.getValue(e)],u._uniqueValuesCache[e]):void 0},renderValue:e=>{var o;return null!=(o=u.getValue(e))?o:t.options.renderFallbackValue},subRows:[],getLeafRows:()=>function(t){const e=[],o=t=>{t.forEach((t=>{e.push(t);const l=t.subRows;null!=l&&l.length&&o(l)}))};return o(t),e}(u.subRows),getParentRow:()=>u.parentId?t.getRow(u.parentId,!0):void 0,getParentRows:()=>{let t=[],e=u;for(;;){const o=e.getParentRow();if(!o)break;t.push(o),e=o}return t.reverse()},getAllCells:s((()=>[t.getAllLeafColumns()]),(e=>e.map((e=>function(t,e,o,l){const n={id:`${e.id}_${o.id}`,row:e,column:o,getValue:()=>e.getValue(l),renderValue:()=>{var e;return null!=(e=n.getValue())?e:t.options.renderFallbackValue},getContext:s((()=>[t,o,e,n]),((t,e,o,l)=>({table:t,column:e,row:o,cell:l,getValue:l.getValue,renderValue:l.renderValue})),c(t.options,"debugCells"))};return t._features.forEach((l=>{null==l.createCell||l.createCell(n,o,e,t)}),{}),n}(t,u,e,e.id)))),c(t.options,"debugRows")),_getAllCellsByColumnId:s((()=>[u.getAllCells()]),(t=>t.reduce(((t,e)=>(t[e.column.id]=e,t)),{})),c(t.options,"debugRows"))};for(let e=0;e<t._features.length;e++){const o=t._features[e];null==o||null==o.createRow||o.createRow(u,t)}return u},g={createColumn:(t,e)=>{t._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,t.id),t.getFacetedRowModel=()=>t._getFacetedRowModel?t._getFacetedRowModel():e.getPreFilteredRowModel(),t._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,t.id),t.getFacetedUniqueValues=()=>t._getFacetedUniqueValues?t._getFacetedUniqueValues():new Map,t._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,t.id),t.getFacetedMinMaxValues=()=>{if(t._getFacetedMinMaxValues)return t._getFacetedMinMaxValues()}}},w=(t,e,o)=>{var l,n;const r=null==o||null==(l=o.toString())?void 0:l.toLowerCase();return Boolean(null==(n=t.getValue(e))||null==(n=n.toString())||null==(n=n.toLowerCase())?void 0:n.includes(r))};w.autoRemove=t=>I(t);const f=(t,e,o)=>{var l;return Boolean(null==(l=t.getValue(e))||null==(l=l.toString())?void 0:l.includes(o))};f.autoRemove=t=>I(t);const p=(t,e,o)=>{var l;return(null==(l=t.getValue(e))||null==(l=l.toString())?void 0:l.toLowerCase())===(null==o?void 0:o.toLowerCase())};p.autoRemove=t=>I(t);const y=(t,e,o)=>{var l;return null==(l=t.getValue(e))?void 0:l.includes(o)};y.autoRemove=t=>I(t);const S=(t,e,o)=>!o.some((o=>{var l;return!(null!=(l=t.getValue(e))&&l.includes(o))}));S.autoRemove=t=>I(t)||!(null!=t&&t.length);const C=(t,e,o)=>o.some((o=>{var l;return null==(l=t.getValue(e))?void 0:l.includes(o)}));C.autoRemove=t=>I(t)||!(null!=t&&t.length);const k=(t,e,o)=>t.getValue(e)===o;k.autoRemove=t=>I(t);const O=(t,e,o)=>t.getValue(e)==o;O.autoRemove=t=>I(t);const R=(t,e,o)=>{let[l,n]=o;const r=t.getValue(e);return r>=l&&r<=n};R.resolveFilterValue=t=>{let[e,o]=t,l="number"!=typeof e?parseFloat(e):e,n="number"!=typeof o?parseFloat(o):o,r=null===e||Number.isNaN(l)?-1/0:l,a=null===o||Number.isNaN(n)?1/0:n;if(r>a){const t=r;r=a,a=t}return[r,a]},R.autoRemove=t=>I(t)||I(t[0])&&I(t[1]);const x={includesString:w,includesStringSensitive:f,equalsString:p,arrIncludes:y,arrIncludesAll:S,arrIncludesSome:C,equals:k,weakEquals:O,inNumberRange:R};function I(t){return null==t||""===t}function z(t,e,o){return!(!t||!t.autoRemove)&&t.autoRemove(e,o)||void 0===e||"string"==typeof e&&!e}const j={sum:(t,e,o)=>o.reduce(((e,o)=>{const l=o.getValue(t);return e+("number"==typeof l?l:0)}),0),min:(t,e,o)=>{let l;return o.forEach((e=>{const o=e.getValue(t);null!=o&&(l>o||void 0===l&&o>=o)&&(l=o)})),l},max:(t,e,o)=>{let l;return o.forEach((e=>{const o=e.getValue(t);null!=o&&(l<o||void 0===l&&o>=o)&&(l=o)})),l},extent:(t,e,o)=>{let l,n;return o.forEach((e=>{const o=e.getValue(t);null!=o&&(void 0===l?o>=o&&(l=n=o):(l>o&&(l=o),n<o&&(n=o)))})),[l,n]},mean:(t,e)=>{let o=0,l=0;if(e.forEach((e=>{let n=e.getValue(t);null!=n&&(n=+n)>=n&&(++o,l+=n)})),o)return l/o},median:(t,e)=>{if(!e.length)return;const o=e.map((e=>e.getValue(t)));if(l=o,!Array.isArray(l)||!l.every((t=>"number"==typeof t)))return;var l;if(1===o.length)return o[0];const n=Math.floor(o.length/2),r=o.sort(((t,e)=>t-e));return o.length%2!=0?r[n]:(r[n-1]+r[n])/2},unique:(t,e)=>Array.from(new Set(e.map((e=>e.getValue(t)))).values()),uniqueCount:(t,e)=>new Set(e.map((e=>e.getValue(t)))).size,count:(t,e)=>e.length},P={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},B={getDefaultColumnDef:()=>P,getInitialState:t=>({columnSizing:{},columnSizingInfo:{startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]},...t}),getDefaultOptions:t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:u("columnSizing",t),onColumnSizingInfoChange:u("columnSizingInfo",t)}),createColumn:(t,e)=>{t.getSize=()=>{var o,l,n;const r=e.getState().columnSizing[t.id];return Math.min(Math.max(null!=(o=t.columnDef.minSize)?o:P.minSize,null!=(l=null!=r?r:t.columnDef.size)?l:P.size),null!=(n=t.columnDef.maxSize)?n:P.maxSize)},t.getStart=s((t=>[t,M(e,t),e.getState().columnSizing]),((e,o)=>o.slice(0,t.getIndex(e)).reduce(((t,e)=>t+e.getSize()),0)),c(e.options,"debugColumns")),t.getAfter=s((t=>[t,M(e,t),e.getState().columnSizing]),((e,o)=>o.slice(t.getIndex(e)+1).reduce(((t,e)=>t+e.getSize()),0)),c(e.options,"debugColumns")),t.resetSize=()=>{e.setColumnSizing((e=>{let{[t.id]:o,...l}=e;return l}))},t.getCanResize=()=>{var o,l;return(null==(o=t.columnDef.enableResizing)||o)&&(null==(l=e.options.enableColumnResizing)||l)},t.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===t.id},createHeader:(t,e)=>{t.getSize=()=>{let e=0;const o=t=>{var l;t.subHeaders.length?t.subHeaders.forEach(o):e+=null!=(l=t.column.getSize())?l:0};return o(t),e},t.getStart=()=>{if(t.index>0){const e=t.headerGroup.headers[t.index-1];return e.getStart()+e.getSize()}return 0},t.getResizeHandler=o=>{const l=e.getColumn(t.column.id),n=null==l?void 0:l.getCanResize();return r=>{if(!l||!n)return;if(null==r.persist||r.persist(),_(r)&&r.touches&&r.touches.length>1)return;const a=t.getSize(),u=t?t.getLeafHeaders().map((t=>[t.column.id,t.column.getSize()])):[[l.id,l.getSize()]],i=_(r)?Math.round(r.touches[0].clientX):r.clientX,s={},c=(t,o)=>{"number"==typeof o&&(e.setColumnSizingInfo((t=>{var l,n;const r=(o-(null!=(l=null==t?void 0:t.startOffset)?l:0))*("rtl"===e.options.columnResizeDirection?-1:1),a=Math.max(r/(null!=(n=null==t?void 0:t.startSize)?n:0),-.999999);return t.columnSizingStart.forEach((t=>{let[e,o]=t;s[e]=Math.round(100*Math.max(o+o*a,0))/100})),{...t,deltaOffset:r,deltaPercentage:a}})),"onChange"!==e.options.columnResizeMode&&"end"!==t||e.setColumnSizing((t=>({...t,...s}))))},d=t=>c("move",t),h=t=>{c("end",t),e.setColumnSizingInfo((t=>({...t,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]})))},m=o||("undefined"!=typeof document?document:null),b={moveHandler:t=>d(t.clientX),upHandler:t=>{null==m||m.removeEventListener("mousemove",b.moveHandler),null==m||m.removeEventListener("mouseup",b.upHandler),h(t.clientX)}},v={moveHandler:t=>(t.cancelable&&(t.preventDefault(),t.stopPropagation()),d(t.touches[0].clientX),!1),upHandler:t=>{var e;null==m||m.removeEventListener("touchmove",v.moveHandler),null==m||m.removeEventListener("touchend",v.upHandler),t.cancelable&&(t.preventDefault(),t.stopPropagation()),h(null==(e=t.touches[0])?void 0:e.clientX)}},g=!!function(){if("boolean"==typeof D)return D;let t=!1;try{const e=()=>{};window.addEventListener("test",e,{get passive(){return t=!0,!1}}),window.removeEventListener("test",e)}catch(e){t=!1}return D=t,D}()&&{passive:!1};_(r)?(null==m||m.addEventListener("touchmove",v.moveHandler,g),null==m||m.addEventListener("touchend",v.upHandler,g)):(null==m||m.addEventListener("mousemove",b.moveHandler,g),null==m||m.addEventListener("mouseup",b.upHandler,g)),e.setColumnSizingInfo((t=>({...t,startOffset:i,startSize:a,deltaOffset:0,deltaPercentage:0,columnSizingStart:u,isResizingColumn:l.id})))}}},createTable:t=>{t.setColumnSizing=e=>null==t.options.onColumnSizingChange?void 0:t.options.onColumnSizingChange(e),t.setColumnSizingInfo=e=>null==t.options.onColumnSizingInfoChange?void 0:t.options.onColumnSizingInfoChange(e),t.resetColumnSizing=e=>{var o;t.setColumnSizing(e?{}:null!=(o=t.initialState.columnSizing)?o:{})},t.resetHeaderSizeInfo=e=>{var o;t.setColumnSizingInfo(e?{startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}:null!=(o=t.initialState.columnSizingInfo)?o:{startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]})},t.getTotalSize=()=>{var e,o;return null!=(e=null==(o=t.getHeaderGroups()[0])?void 0:o.headers.reduce(((t,e)=>t+e.getSize()),0))?e:0},t.getLeftTotalSize=()=>{var e,o;return null!=(e=null==(o=t.getLeftHeaderGroups()[0])?void 0:o.headers.reduce(((t,e)=>t+e.getSize()),0))?e:0},t.getCenterTotalSize=()=>{var e,o;return null!=(e=null==(o=t.getCenterHeaderGroups()[0])?void 0:o.headers.reduce(((t,e)=>t+e.getSize()),0))?e:0},t.getRightTotalSize=()=>{var e,o;return null!=(e=null==(o=t.getRightHeaderGroups()[0])?void 0:o.headers.reduce(((t,e)=>t+e.getSize()),0))?e:0}}};let D=null;function _(t){return"touchstart"===t.type}function M(t,e){return e?"center"===e?t.getCenterVisibleLeafColumns():"left"===e?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns()}const F={getInitialState:t=>({rowSelection:{},...t}),getDefaultOptions:t=>({onRowSelectionChange:u("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:t=>{t.setRowSelection=e=>null==t.options.onRowSelectionChange?void 0:t.options.onRowSelectionChange(e),t.resetRowSelection=e=>{var o;return t.setRowSelection(e?{}:null!=(o=t.initialState.rowSelection)?o:{})},t.toggleAllRowsSelected=e=>{t.setRowSelection((o=>{e=void 0!==e?e:!t.getIsAllRowsSelected();const l={...o};return t.getPreGroupedRowModel().flatRows.forEach(e?t=>{t.getCanSelect()&&(l[t.id]=!0)}:t=>{delete l[t.id]}),l}))},t.toggleAllPageRowsSelected=e=>t.setRowSelection((o=>{const l=void 0!==e?e:!t.getIsAllPageRowsSelected(),n={...o};return t.getRowModel().rows.forEach((e=>{T(n,e.id,l,!0,t)})),n})),t.getPreSelectedRowModel=()=>t.getCoreRowModel(),t.getSelectedRowModel=s((()=>[t.getState().rowSelection,t.getCoreRowModel()]),((e,o)=>Object.keys(e).length?N(t,o):{rows:[],flatRows:[],rowsById:{}}),c(t.options,"debugTable")),t.getFilteredSelectedRowModel=s((()=>[t.getState().rowSelection,t.getFilteredRowModel()]),((e,o)=>Object.keys(e).length?N(t,o):{rows:[],flatRows:[],rowsById:{}}),c(t.options,"debugTable")),t.getGroupedSelectedRowModel=s((()=>[t.getState().rowSelection,t.getSortedRowModel()]),((e,o)=>Object.keys(e).length?N(t,o):{rows:[],flatRows:[],rowsById:{}}),c(t.options,"debugTable")),t.getIsAllRowsSelected=()=>{const e=t.getFilteredRowModel().flatRows,{rowSelection:o}=t.getState();let l=Boolean(e.length&&Object.keys(o).length);return l&&e.some((t=>t.getCanSelect()&&!o[t.id]))&&(l=!1),l},t.getIsAllPageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows.filter((t=>t.getCanSelect())),{rowSelection:o}=t.getState();let l=!!e.length;return l&&e.some((t=>!o[t.id]))&&(l=!1),l},t.getIsSomeRowsSelected=()=>{var e;const o=Object.keys(null!=(e=t.getState().rowSelection)?e:{}).length;return o>0&&o<t.getFilteredRowModel().flatRows.length},t.getIsSomePageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows;return!t.getIsAllPageRowsSelected()&&e.filter((t=>t.getCanSelect())).some((t=>t.getIsSelected()||t.getIsSomeSelected()))},t.getToggleAllRowsSelectedHandler=()=>e=>{t.toggleAllRowsSelected(e.target.checked)},t.getToggleAllPageRowsSelectedHandler=()=>e=>{t.toggleAllPageRowsSelected(e.target.checked)}},createRow:(t,e)=>{t.toggleSelected=(o,l)=>{const n=t.getIsSelected();e.setRowSelection((r=>{var a;if(o=void 0!==o?o:!n,t.getCanSelect()&&n===o)return r;const u={...r};return T(u,t.id,o,null==(a=null==l?void 0:l.selectChildren)||a,e),u}))},t.getIsSelected=()=>{const{rowSelection:o}=e.getState();return A(t,o)},t.getIsSomeSelected=()=>{const{rowSelection:o}=e.getState();return"some"===E(t,o)},t.getIsAllSubRowsSelected=()=>{const{rowSelection:o}=e.getState();return"all"===E(t,o)},t.getCanSelect=()=>{var o;return"function"==typeof e.options.enableRowSelection?e.options.enableRowSelection(t):null==(o=e.options.enableRowSelection)||o},t.getCanSelectSubRows=()=>{var o;return"function"==typeof e.options.enableSubRowSelection?e.options.enableSubRowSelection(t):null==(o=e.options.enableSubRowSelection)||o},t.getCanMultiSelect=()=>{var o;return"function"==typeof e.options.enableMultiRowSelection?e.options.enableMultiRowSelection(t):null==(o=e.options.enableMultiRowSelection)||o},t.getToggleSelectedHandler=()=>{const e=t.getCanSelect();return o=>{var l;e&&t.toggleSelected(null==(l=o.target)?void 0:l.checked)}}}},T=(t,e,o,l,n)=>{var r;const a=n.getRow(e,!0);o?(a.getCanMultiSelect()||Object.keys(t).forEach((e=>delete t[e])),a.getCanSelect()&&(t[e]=!0)):delete t[e],l&&null!=(r=a.subRows)&&r.length&&a.getCanSelectSubRows()&&a.subRows.forEach((e=>T(t,e.id,o,l,n)))};function N(t,e){const o=t.getState().rowSelection,l=[],n={},r=function(t){return t.map((t=>{var e;const a=A(t,o);if(a&&(l.push(t),n[t.id]=t),null!=(e=t.subRows)&&e.length&&(t={...t,subRows:r(t.subRows)}),a)return t})).filter(Boolean)};return{rows:r(e.rows),flatRows:l,rowsById:n}}function A(t,e){var o;return null!=(o=e[t.id])&&o}function E(t,e){var o;if(null==(o=t.subRows)||!o.length)return!1;let l=!0,n=!1;return t.subRows.forEach((t=>{if((!n||l)&&(t.getCanSelect()&&(A(t,e)?n=!0:l=!1),t.subRows&&t.subRows.length)){const o=E(t,e);"all"===o?n=!0:"some"===o?(n=!0,l=!1):l=!1}})),l?"all":!!n&&"some"}const V=/([0-9]+)/gm;function $(t,e){return t===e?0:t>e?1:-1}function q(t){return"number"==typeof t?isNaN(t)||t===1/0||t===-1/0?"":String(t):"string"==typeof t?t:""}function H(t,e){const o=t.split(V).filter(Boolean),l=e.split(V).filter(Boolean);for(;o.length&&l.length;){const t=o.shift(),e=l.shift(),n=parseInt(t,10),r=parseInt(e,10),a=[n,r].sort();if(isNaN(a[0])){if(t>e)return 1;if(e>t)return-1}else{if(isNaN(a[1]))return isNaN(n)?-1:1;if(n>r)return 1;if(r>n)return-1}}return o.length-l.length}const L={alphanumeric:(t,e,o)=>H(q(t.getValue(o)).toLowerCase(),q(e.getValue(o)).toLowerCase()),alphanumericCaseSensitive:(t,e,o)=>H(q(t.getValue(o)),q(e.getValue(o))),text:(t,e,o)=>$(q(t.getValue(o)).toLowerCase(),q(e.getValue(o)).toLowerCase()),textCaseSensitive:(t,e,o)=>$(q(t.getValue(o)),q(e.getValue(o))),datetime:(t,e,o)=>{const l=t.getValue(o),n=e.getValue(o);return l>n?1:l<n?-1:0},basic:(t,e,o)=>$(t.getValue(o),e.getValue(o))},G=[m,{getInitialState:t=>({columnVisibility:{},...t}),getDefaultOptions:t=>({onColumnVisibilityChange:u("columnVisibility",t)}),createColumn:(t,e)=>{t.toggleVisibility=o=>{t.getCanHide()&&e.setColumnVisibility((e=>({...e,[t.id]:null!=o?o:!t.getIsVisible()})))},t.getIsVisible=()=>{var o,l;const n=t.columns;return null==(o=n.length?n.some((t=>t.getIsVisible())):null==(l=e.getState().columnVisibility)?void 0:l[t.id])||o},t.getCanHide=()=>{var o,l;return(null==(o=t.columnDef.enableHiding)||o)&&(null==(l=e.options.enableHiding)||l)},t.getToggleVisibilityHandler=()=>e=>{null==t.toggleVisibility||t.toggleVisibility(e.target.checked)}},createRow:(t,e)=>{t._getAllVisibleCells=s((()=>[t.getAllCells(),e.getState().columnVisibility]),(t=>t.filter((t=>t.column.getIsVisible()))),c(e.options,"debugRows")),t.getVisibleCells=s((()=>[t.getLeftVisibleCells(),t.getCenterVisibleCells(),t.getRightVisibleCells()]),((t,e,o)=>[...t,...e,...o]),c(e.options,"debugRows"))},createTable:t=>{const e=(e,o)=>s((()=>[o(),o().filter((t=>t.getIsVisible())).map((t=>t.id)).join("_")]),(t=>t.filter((t=>null==t.getIsVisible?void 0:t.getIsVisible()))),c(t.options,"debugColumns"));t.getVisibleFlatColumns=e(0,(()=>t.getAllFlatColumns())),t.getVisibleLeafColumns=e(0,(()=>t.getAllLeafColumns())),t.getLeftVisibleLeafColumns=e(0,(()=>t.getLeftLeafColumns())),t.getRightVisibleLeafColumns=e(0,(()=>t.getRightLeafColumns())),t.getCenterVisibleLeafColumns=e(0,(()=>t.getCenterLeafColumns())),t.setColumnVisibility=e=>null==t.options.onColumnVisibilityChange?void 0:t.options.onColumnVisibilityChange(e),t.resetColumnVisibility=e=>{var o;t.setColumnVisibility(e?{}:null!=(o=t.initialState.columnVisibility)?o:{})},t.toggleAllColumnsVisible=e=>{var o;e=null!=(o=e)?o:!t.getIsAllColumnsVisible(),t.setColumnVisibility(t.getAllLeafColumns().reduce(((t,o)=>({...t,[o.id]:e||!(null!=o.getCanHide&&o.getCanHide())})),{}))},t.getIsAllColumnsVisible=()=>!t.getAllLeafColumns().some((t=>!(null!=t.getIsVisible&&t.getIsVisible()))),t.getIsSomeColumnsVisible=()=>t.getAllLeafColumns().some((t=>null==t.getIsVisible?void 0:t.getIsVisible())),t.getToggleAllColumnsVisibilityHandler=()=>e=>{var o;t.toggleAllColumnsVisible(null==(o=e.target)?void 0:o.checked)}}},{getInitialState:t=>({columnOrder:[],...t}),getDefaultOptions:t=>({onColumnOrderChange:u("columnOrder",t)}),createColumn:(t,e)=>{t.getIndex=s((t=>[M(e,t)]),(e=>e.findIndex((e=>e.id===t.id))),c(e.options,"debugColumns")),t.getIsFirstColumn=o=>{var l;return(null==(l=M(e,o)[0])?void 0:l.id)===t.id},t.getIsLastColumn=o=>{var l;const n=M(e,o);return(null==(l=n[n.length-1])?void 0:l.id)===t.id}},createTable:t=>{t.setColumnOrder=e=>null==t.options.onColumnOrderChange?void 0:t.options.onColumnOrderChange(e),t.resetColumnOrder=e=>{var o;t.setColumnOrder(e?[]:null!=(o=t.initialState.columnOrder)?o:[])},t._getOrderColumnsFn=s((()=>[t.getState().columnOrder,t.getState().grouping,t.options.groupedColumnMode]),((t,e,o)=>l=>{let n=[];if(null!=t&&t.length){const e=[...t],o=[...l];for(;o.length&&e.length;){const t=e.shift(),l=o.findIndex((e=>e.id===t));l>-1&&n.push(o.splice(l,1)[0])}n=[...n,...o]}else n=l;return function(t,e,o){if(null==e||!e.length||!o)return t;const l=t.filter((t=>!e.includes(t.id)));return"remove"===o?l:[...e.map((e=>t.find((t=>t.id===e)))).filter(Boolean),...l]}(n,e,o)}),c(t.options,"debugTable"))}},{getInitialState:t=>({columnPinning:{left:[],right:[]},...t}),getDefaultOptions:t=>({onColumnPinningChange:u("columnPinning",t)}),createColumn:(t,e)=>{t.pin=o=>{const l=t.getLeafColumns().map((t=>t.id)).filter(Boolean);e.setColumnPinning((t=>{var e,n,r,a,u,i;return"right"===o?{left:(null!=(r=null==t?void 0:t.left)?r:[]).filter((t=>!(null!=l&&l.includes(t)))),right:[...(null!=(a=null==t?void 0:t.right)?a:[]).filter((t=>!(null!=l&&l.includes(t)))),...l]}:"left"===o?{left:[...(null!=(u=null==t?void 0:t.left)?u:[]).filter((t=>!(null!=l&&l.includes(t)))),...l],right:(null!=(i=null==t?void 0:t.right)?i:[]).filter((t=>!(null!=l&&l.includes(t))))}:{left:(null!=(e=null==t?void 0:t.left)?e:[]).filter((t=>!(null!=l&&l.includes(t)))),right:(null!=(n=null==t?void 0:t.right)?n:[]).filter((t=>!(null!=l&&l.includes(t))))}}))},t.getCanPin=()=>t.getLeafColumns().some((t=>{var o,l,n;return(null==(o=t.columnDef.enablePinning)||o)&&(null==(l=null!=(n=e.options.enableColumnPinning)?n:e.options.enablePinning)||l)})),t.getIsPinned=()=>{const o=t.getLeafColumns().map((t=>t.id)),{left:l,right:n}=e.getState().columnPinning,r=o.some((t=>null==l?void 0:l.includes(t))),a=o.some((t=>null==n?void 0:n.includes(t)));return r?"left":!!a&&"right"},t.getPinnedIndex=()=>{var o,l;const n=t.getIsPinned();return n?null!=(o=null==(l=e.getState().columnPinning)||null==(l=l[n])?void 0:l.indexOf(t.id))?o:-1:0}},createRow:(t,e)=>{t.getCenterVisibleCells=s((()=>[t._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right]),((t,e,o)=>{const l=[...null!=e?e:[],...null!=o?o:[]];return t.filter((t=>!l.includes(t.column.id)))}),c(e.options,"debugRows")),t.getLeftVisibleCells=s((()=>[t._getAllVisibleCells(),e.getState().columnPinning.left]),((t,e)=>(null!=e?e:[]).map((e=>t.find((t=>t.column.id===e)))).filter(Boolean).map((t=>({...t,position:"left"})))),c(e.options,"debugRows")),t.getRightVisibleCells=s((()=>[t._getAllVisibleCells(),e.getState().columnPinning.right]),((t,e)=>(null!=e?e:[]).map((e=>t.find((t=>t.column.id===e)))).filter(Boolean).map((t=>({...t,position:"right"})))),c(e.options,"debugRows"))},createTable:t=>{t.setColumnPinning=e=>null==t.options.onColumnPinningChange?void 0:t.options.onColumnPinningChange(e),t.resetColumnPinning=e=>{var o,l;return t.setColumnPinning(e?{left:[],right:[]}:null!=(o=null==(l=t.initialState)?void 0:l.columnPinning)?o:{left:[],right:[]})},t.getIsSomeColumnsPinned=e=>{var o;const l=t.getState().columnPinning;var n,r;return e?Boolean(null==(o=l[e])?void 0:o.length):Boolean((null==(n=l.left)?void 0:n.length)||(null==(r=l.right)?void 0:r.length))},t.getLeftLeafColumns=s((()=>[t.getAllLeafColumns(),t.getState().columnPinning.left]),((t,e)=>(null!=e?e:[]).map((e=>t.find((t=>t.id===e)))).filter(Boolean)),c(t.options,"debugColumns")),t.getRightLeafColumns=s((()=>[t.getAllLeafColumns(),t.getState().columnPinning.right]),((t,e)=>(null!=e?e:[]).map((e=>t.find((t=>t.id===e)))).filter(Boolean)),c(t.options,"debugColumns")),t.getCenterLeafColumns=s((()=>[t.getAllLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right]),((t,e,o)=>{const l=[...null!=e?e:[],...null!=o?o:[]];return t.filter((t=>!l.includes(t.id)))}),c(t.options,"debugColumns"))}},g,{getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:t=>({columnFilters:[],...t}),getDefaultOptions:t=>({onColumnFiltersChange:u("columnFilters",t),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(t,e)=>{t.getAutoFilterFn=()=>{const o=e.getCoreRowModel().flatRows[0],l=null==o?void 0:o.getValue(t.id);return"string"==typeof l?x.includesString:"number"==typeof l?x.inNumberRange:"boolean"==typeof l||null!==l&&"object"==typeof l?x.equals:Array.isArray(l)?x.arrIncludes:x.weakEquals},t.getFilterFn=()=>{var o,l;return i(t.columnDef.filterFn)?t.columnDef.filterFn:"auto"===t.columnDef.filterFn?t.getAutoFilterFn():null!=(o=null==(l=e.options.filterFns)?void 0:l[t.columnDef.filterFn])?o:x[t.columnDef.filterFn]},t.getCanFilter=()=>{var o,l,n;return(null==(o=t.columnDef.enableColumnFilter)||o)&&(null==(l=e.options.enableColumnFilters)||l)&&(null==(n=e.options.enableFilters)||n)&&!!t.accessorFn},t.getIsFiltered=()=>t.getFilterIndex()>-1,t.getFilterValue=()=>{var o;return null==(o=e.getState().columnFilters)||null==(o=o.find((e=>e.id===t.id)))?void 0:o.value},t.getFilterIndex=()=>{var o,l;return null!=(o=null==(l=e.getState().columnFilters)?void 0:l.findIndex((e=>e.id===t.id)))?o:-1},t.setFilterValue=o=>{e.setColumnFilters((e=>{const l=t.getFilterFn(),n=null==e?void 0:e.find((e=>e.id===t.id)),r=a(o,n?n.value:void 0);var u;if(z(l,r,t))return null!=(u=null==e?void 0:e.filter((e=>e.id!==t.id)))?u:[];const i={id:t.id,value:r};var s;return n?null!=(s=null==e?void 0:e.map((e=>e.id===t.id?i:e)))?s:[]:null!=e&&e.length?[...e,i]:[i]}))}},createRow:t=>{t.columnFilters={},t.columnFiltersMeta={}},createTable:t=>{t.setColumnFilters=e=>{const o=t.getAllLeafColumns();null==t.options.onColumnFiltersChange||t.options.onColumnFiltersChange((t=>{var l;return null==(l=a(e,t))?void 0:l.filter((t=>{const e=o.find((e=>e.id===t.id));return!e||!z(e.getFilterFn(),t.value,e)}))}))},t.resetColumnFilters=e=>{var o,l;t.setColumnFilters(e?[]:null!=(o=null==(l=t.initialState)?void 0:l.columnFilters)?o:[])},t.getPreFilteredRowModel=()=>t.getCoreRowModel(),t.getFilteredRowModel=()=>(!t._getFilteredRowModel&&t.options.getFilteredRowModel&&(t._getFilteredRowModel=t.options.getFilteredRowModel(t)),t.options.manualFiltering||!t._getFilteredRowModel?t.getPreFilteredRowModel():t._getFilteredRowModel())}},{createTable:t=>{t._getGlobalFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,"__global__"),t.getGlobalFacetedRowModel=()=>t.options.manualFiltering||!t._getGlobalFacetedRowModel?t.getPreFilteredRowModel():t._getGlobalFacetedRowModel(),t._getGlobalFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,"__global__"),t.getGlobalFacetedUniqueValues=()=>t._getGlobalFacetedUniqueValues?t._getGlobalFacetedUniqueValues():new Map,t._getGlobalFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,"__global__"),t.getGlobalFacetedMinMaxValues=()=>{if(t._getGlobalFacetedMinMaxValues)return t._getGlobalFacetedMinMaxValues()}}},{getInitialState:t=>({globalFilter:void 0,...t}),getDefaultOptions:t=>({onGlobalFilterChange:u("globalFilter",t),globalFilterFn:"auto",getColumnCanGlobalFilter:e=>{var o;const l=null==(o=t.getCoreRowModel().flatRows[0])||null==(o=o._getAllCellsByColumnId()[e.id])?void 0:o.getValue();return"string"==typeof l||"number"==typeof l}}),createColumn:(t,e)=>{t.getCanGlobalFilter=()=>{var o,l,n,r;return(null==(o=t.columnDef.enableGlobalFilter)||o)&&(null==(l=e.options.enableGlobalFilter)||l)&&(null==(n=e.options.enableFilters)||n)&&(null==(r=null==e.options.getColumnCanGlobalFilter?void 0:e.options.getColumnCanGlobalFilter(t))||r)&&!!t.accessorFn}},createTable:t=>{t.getGlobalAutoFilterFn=()=>x.includesString,t.getGlobalFilterFn=()=>{var e,o;const{globalFilterFn:l}=t.options;return i(l)?l:"auto"===l?t.getGlobalAutoFilterFn():null!=(e=null==(o=t.options.filterFns)?void 0:o[l])?e:x[l]},t.setGlobalFilter=e=>{null==t.options.onGlobalFilterChange||t.options.onGlobalFilterChange(e)},t.resetGlobalFilter=e=>{t.setGlobalFilter(e?void 0:t.initialState.globalFilter)}}},{getInitialState:t=>({sorting:[],...t}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:t=>({onSortingChange:u("sorting",t),isMultiSortEvent:t=>t.shiftKey}),createColumn:(t,e)=>{t.getAutoSortingFn=()=>{const o=e.getFilteredRowModel().flatRows.slice(10);let l=!1;for(const e of o){const o=null==e?void 0:e.getValue(t.id);if("[object Date]"===Object.prototype.toString.call(o))return L.datetime;if("string"==typeof o&&(l=!0,o.split(V).length>1))return L.alphanumeric}return l?L.text:L.basic},t.getAutoSortDir=()=>{const o=e.getFilteredRowModel().flatRows[0];return"string"==typeof(null==o?void 0:o.getValue(t.id))?"asc":"desc"},t.getSortingFn=()=>{var o,l;if(!t)throw new Error;return i(t.columnDef.sortingFn)?t.columnDef.sortingFn:"auto"===t.columnDef.sortingFn?t.getAutoSortingFn():null!=(o=null==(l=e.options.sortingFns)?void 0:l[t.columnDef.sortingFn])?o:L[t.columnDef.sortingFn]},t.toggleSorting=(o,l)=>{const n=t.getNextSortingOrder(),r=null!=o;e.setSorting((a=>{const u=null==a?void 0:a.find((e=>e.id===t.id)),i=null==a?void 0:a.findIndex((e=>e.id===t.id));let s,c=[],d=r?o:"desc"===n;var h;return s=null!=a&&a.length&&t.getCanMultiSort()&&l?u?"toggle":"add":null!=a&&a.length&&i!==a.length-1?"replace":u?"toggle":"replace","toggle"===s&&(r||n||(s="remove")),"add"===s?(c=[...a,{id:t.id,desc:d}],c.splice(0,c.length-(null!=(h=e.options.maxMultiSortColCount)?h:Number.MAX_SAFE_INTEGER))):c="toggle"===s?a.map((e=>e.id===t.id?{...e,desc:d}:e)):"remove"===s?a.filter((e=>e.id!==t.id)):[{id:t.id,desc:d}],c}))},t.getFirstSortDir=()=>{var o,l;return(null!=(o=null!=(l=t.columnDef.sortDescFirst)?l:e.options.sortDescFirst)?o:"desc"===t.getAutoSortDir())?"desc":"asc"},t.getNextSortingOrder=o=>{var l,n;const r=t.getFirstSortDir(),a=t.getIsSorted();return a?!!(a===r||null!=(l=e.options.enableSortingRemoval)&&!l||o&&null!=(n=e.options.enableMultiRemove)&&!n)&&("desc"===a?"asc":"desc"):r},t.getCanSort=()=>{var o,l;return(null==(o=t.columnDef.enableSorting)||o)&&(null==(l=e.options.enableSorting)||l)&&!!t.accessorFn},t.getCanMultiSort=()=>{var o,l;return null!=(o=null!=(l=t.columnDef.enableMultiSort)?l:e.options.enableMultiSort)?o:!!t.accessorFn},t.getIsSorted=()=>{var o;const l=null==(o=e.getState().sorting)?void 0:o.find((e=>e.id===t.id));return!!l&&(l.desc?"desc":"asc")},t.getSortIndex=()=>{var o,l;return null!=(o=null==(l=e.getState().sorting)?void 0:l.findIndex((e=>e.id===t.id)))?o:-1},t.clearSorting=()=>{e.setSorting((e=>null!=e&&e.length?e.filter((e=>e.id!==t.id)):[]))},t.getToggleSortingHandler=()=>{const o=t.getCanSort();return l=>{o&&(null==l.persist||l.persist(),null==t.toggleSorting||t.toggleSorting(void 0,!!t.getCanMultiSort()&&(null==e.options.isMultiSortEvent?void 0:e.options.isMultiSortEvent(l))))}}},createTable:t=>{t.setSorting=e=>null==t.options.onSortingChange?void 0:t.options.onSortingChange(e),t.resetSorting=e=>{var o,l;t.setSorting(e?[]:null!=(o=null==(l=t.initialState)?void 0:l.sorting)?o:[])},t.getPreSortedRowModel=()=>t.getGroupedRowModel(),t.getSortedRowModel=()=>(!t._getSortedRowModel&&t.options.getSortedRowModel&&(t._getSortedRowModel=t.options.getSortedRowModel(t)),t.options.manualSorting||!t._getSortedRowModel?t.getPreSortedRowModel():t._getSortedRowModel())}},{getDefaultColumnDef:()=>({aggregatedCell:t=>{var e,o;return null!=(e=null==(o=t.getValue())||null==o.toString?void 0:o.toString())?e:null},aggregationFn:"auto"}),getInitialState:t=>({grouping:[],...t}),getDefaultOptions:t=>({onGroupingChange:u("grouping",t),groupedColumnMode:"reorder"}),createColumn:(t,e)=>{t.toggleGrouping=()=>{e.setGrouping((e=>null!=e&&e.includes(t.id)?e.filter((e=>e!==t.id)):[...null!=e?e:[],t.id]))},t.getCanGroup=()=>{var o,l;return(null==(o=t.columnDef.enableGrouping)||o)&&(null==(l=e.options.enableGrouping)||l)&&(!!t.accessorFn||!!t.columnDef.getGroupingValue)},t.getIsGrouped=()=>{var o;return null==(o=e.getState().grouping)?void 0:o.includes(t.id)},t.getGroupedIndex=()=>{var o;return null==(o=e.getState().grouping)?void 0:o.indexOf(t.id)},t.getToggleGroupingHandler=()=>{const e=t.getCanGroup();return()=>{e&&t.toggleGrouping()}},t.getAutoAggregationFn=()=>{const o=e.getCoreRowModel().flatRows[0],l=null==o?void 0:o.getValue(t.id);return"number"==typeof l?j.sum:"[object Date]"===Object.prototype.toString.call(l)?j.extent:void 0},t.getAggregationFn=()=>{var o,l;if(!t)throw new Error;return i(t.columnDef.aggregationFn)?t.columnDef.aggregationFn:"auto"===t.columnDef.aggregationFn?t.getAutoAggregationFn():null!=(o=null==(l=e.options.aggregationFns)?void 0:l[t.columnDef.aggregationFn])?o:j[t.columnDef.aggregationFn]}},createTable:t=>{t.setGrouping=e=>null==t.options.onGroupingChange?void 0:t.options.onGroupingChange(e),t.resetGrouping=e=>{var o,l;t.setGrouping(e?[]:null!=(o=null==(l=t.initialState)?void 0:l.grouping)?o:[])},t.getPreGroupedRowModel=()=>t.getFilteredRowModel(),t.getGroupedRowModel=()=>(!t._getGroupedRowModel&&t.options.getGroupedRowModel&&(t._getGroupedRowModel=t.options.getGroupedRowModel(t)),t.options.manualGrouping||!t._getGroupedRowModel?t.getPreGroupedRowModel():t._getGroupedRowModel())},createRow:(t,e)=>{t.getIsGrouped=()=>!!t.groupingColumnId,t.getGroupingValue=o=>{if(t._groupingValuesCache.hasOwnProperty(o))return t._groupingValuesCache[o];const l=e.getColumn(o);return null!=l&&l.columnDef.getGroupingValue?(t._groupingValuesCache[o]=l.columnDef.getGroupingValue(t.original),t._groupingValuesCache[o]):t.getValue(o)},t._groupingValuesCache={}},createCell:(t,e,o)=>{t.getIsGrouped=()=>e.getIsGrouped()&&e.id===o.groupingColumnId,t.getIsPlaceholder=()=>!t.getIsGrouped()&&e.getIsGrouped(),t.getIsAggregated=()=>{var e;return!t.getIsGrouped()&&!t.getIsPlaceholder()&&!(null==(e=o.subRows)||!e.length)}}},{getInitialState:t=>({expanded:{},...t}),getDefaultOptions:t=>({onExpandedChange:u("expanded",t),paginateExpandedRows:!0}),createTable:t=>{let e=!1,o=!1;t._autoResetExpanded=()=>{var l,n;if(e){if(null!=(l=null!=(n=t.options.autoResetAll)?n:t.options.autoResetExpanded)?l:!t.options.manualExpanding){if(o)return;o=!0,t._queue((()=>{t.resetExpanded(),o=!1}))}}else t._queue((()=>{e=!0}))},t.setExpanded=e=>null==t.options.onExpandedChange?void 0:t.options.onExpandedChange(e),t.toggleAllRowsExpanded=e=>{(null!=e?e:!t.getIsAllRowsExpanded())?t.setExpanded(!0):t.setExpanded({})},t.resetExpanded=e=>{var o,l;t.setExpanded(e?{}:null!=(o=null==(l=t.initialState)?void 0:l.expanded)?o:{})},t.getCanSomeRowsExpand=()=>t.getPrePaginationRowModel().flatRows.some((t=>t.getCanExpand())),t.getToggleAllRowsExpandedHandler=()=>e=>{null==e.persist||e.persist(),t.toggleAllRowsExpanded()},t.getIsSomeRowsExpanded=()=>{const e=t.getState().expanded;return!0===e||Object.values(e).some(Boolean)},t.getIsAllRowsExpanded=()=>{const e=t.getState().expanded;return"boolean"==typeof e?!0===e:!!Object.keys(e).length&&!t.getRowModel().flatRows.some((t=>!t.getIsExpanded()))},t.getExpandedDepth=()=>{let e=0;return(!0===t.getState().expanded?Object.keys(t.getRowModel().rowsById):Object.keys(t.getState().expanded)).forEach((t=>{const o=t.split(".");e=Math.max(e,o.length)})),e},t.getPreExpandedRowModel=()=>t.getSortedRowModel(),t.getExpandedRowModel=()=>(!t._getExpandedRowModel&&t.options.getExpandedRowModel&&(t._getExpandedRowModel=t.options.getExpandedRowModel(t)),t.options.manualExpanding||!t._getExpandedRowModel?t.getPreExpandedRowModel():t._getExpandedRowModel())},createRow:(t,e)=>{t.toggleExpanded=o=>{e.setExpanded((l=>{var n;const r=!0===l||!(null==l||!l[t.id]);let a={};if(!0===l?Object.keys(e.getRowModel().rowsById).forEach((t=>{a[t]=!0})):a=l,o=null!=(n=o)?n:!r,!r&&o)return{...a,[t.id]:!0};if(r&&!o){const{[t.id]:e,...o}=a;return o}return l}))},t.getIsExpanded=()=>{var o;const l=e.getState().expanded;return!!(null!=(o=null==e.options.getIsRowExpanded?void 0:e.options.getIsRowExpanded(t))?o:!0===l||(null==l?void 0:l[t.id]))},t.getCanExpand=()=>{var o,l,n;return null!=(o=null==e.options.getRowCanExpand?void 0:e.options.getRowCanExpand(t))?o:(null==(l=e.options.enableExpanding)||l)&&!(null==(n=t.subRows)||!n.length)},t.getIsAllParentsExpanded=()=>{let o=!0,l=t;for(;o&&l.parentId;)l=e.getRow(l.parentId,!0),o=l.getIsExpanded();return o},t.getToggleExpandedHandler=()=>{const e=t.getCanExpand();return()=>{e&&t.toggleExpanded()}}}},{getInitialState:t=>({...t,pagination:{pageIndex:0,pageSize:10,...null==t?void 0:t.pagination}}),getDefaultOptions:t=>({onPaginationChange:u("pagination",t)}),createTable:t=>{let e=!1,o=!1;t._autoResetPageIndex=()=>{var l,n;if(e){if(null!=(l=null!=(n=t.options.autoResetAll)?n:t.options.autoResetPageIndex)?l:!t.options.manualPagination){if(o)return;o=!0,t._queue((()=>{t.resetPageIndex(),o=!1}))}}else t._queue((()=>{e=!0}))},t.setPagination=e=>null==t.options.onPaginationChange?void 0:t.options.onPaginationChange((t=>a(e,t))),t.resetPagination=e=>{var o;t.setPagination(e?{pageIndex:0,pageSize:10}:null!=(o=t.initialState.pagination)?o:{pageIndex:0,pageSize:10})},t.setPageIndex=e=>{t.setPagination((o=>{let l=a(e,o.pageIndex);return l=Math.max(0,Math.min(l,void 0===t.options.pageCount||-1===t.options.pageCount?Number.MAX_SAFE_INTEGER:t.options.pageCount-1)),{...o,pageIndex:l}}))},t.resetPageIndex=e=>{var o,l;t.setPageIndex(e?0:null!=(o=null==(l=t.initialState)||null==(l=l.pagination)?void 0:l.pageIndex)?o:0)},t.resetPageSize=e=>{var o,l;t.setPageSize(e?10:null!=(o=null==(l=t.initialState)||null==(l=l.pagination)?void 0:l.pageSize)?o:10)},t.setPageSize=e=>{t.setPagination((t=>{const o=Math.max(1,a(e,t.pageSize)),l=Math.floor(t.pageSize*t.pageIndex/o);return{...t,pageIndex:l,pageSize:o}}))},t.setPageCount=e=>t.setPagination((o=>{var l;let n=a(e,null!=(l=t.options.pageCount)?l:-1);return"number"==typeof n&&(n=Math.max(-1,n)),{...o,pageCount:n}})),t.getPageOptions=s((()=>[t.getPageCount()]),(t=>{let e=[];return t&&t>0&&(e=[...new Array(t)].fill(null).map(((t,e)=>e))),e}),c(t.options,"debugTable")),t.getCanPreviousPage=()=>t.getState().pagination.pageIndex>0,t.getCanNextPage=()=>{const{pageIndex:e}=t.getState().pagination,o=t.getPageCount();return-1===o||0!==o&&e<o-1},t.previousPage=()=>t.setPageIndex((t=>t-1)),t.nextPage=()=>t.setPageIndex((t=>t+1)),t.firstPage=()=>t.setPageIndex(0),t.lastPage=()=>t.setPageIndex(t.getPageCount()-1),t.getPrePaginationRowModel=()=>t.getExpandedRowModel(),t.getPaginationRowModel=()=>(!t._getPaginationRowModel&&t.options.getPaginationRowModel&&(t._getPaginationRowModel=t.options.getPaginationRowModel(t)),t.options.manualPagination||!t._getPaginationRowModel?t.getPrePaginationRowModel():t._getPaginationRowModel()),t.getPageCount=()=>{var e;return null!=(e=t.options.pageCount)?e:Math.ceil(t.getRowCount()/t.getState().pagination.pageSize)},t.getRowCount=()=>{var e;return null!=(e=t.options.rowCount)?e:t.getPrePaginationRowModel().rows.length}}},{getInitialState:t=>({rowPinning:{top:[],bottom:[]},...t}),getDefaultOptions:t=>({onRowPinningChange:u("rowPinning",t)}),createRow:(t,e)=>{t.pin=(o,l,n)=>{const r=l?t.getLeafRows().map((t=>{let{id:e}=t;return e})):[],a=n?t.getParentRows().map((t=>{let{id:e}=t;return e})):[],u=new Set([...a,t.id,...r]);e.setRowPinning((t=>{var e,l,n,r,a,i;return"bottom"===o?{top:(null!=(n=null==t?void 0:t.top)?n:[]).filter((t=>!(null!=u&&u.has(t)))),bottom:[...(null!=(r=null==t?void 0:t.bottom)?r:[]).filter((t=>!(null!=u&&u.has(t)))),...Array.from(u)]}:"top"===o?{top:[...(null!=(a=null==t?void 0:t.top)?a:[]).filter((t=>!(null!=u&&u.has(t)))),...Array.from(u)],bottom:(null!=(i=null==t?void 0:t.bottom)?i:[]).filter((t=>!(null!=u&&u.has(t))))}:{top:(null!=(e=null==t?void 0:t.top)?e:[]).filter((t=>!(null!=u&&u.has(t)))),bottom:(null!=(l=null==t?void 0:t.bottom)?l:[]).filter((t=>!(null!=u&&u.has(t))))}}))},t.getCanPin=()=>{var o;const{enableRowPinning:l,enablePinning:n}=e.options;return"function"==typeof l?l(t):null==(o=null!=l?l:n)||o},t.getIsPinned=()=>{const o=[t.id],{top:l,bottom:n}=e.getState().rowPinning,r=o.some((t=>null==l?void 0:l.includes(t))),a=o.some((t=>null==n?void 0:n.includes(t)));return r?"top":!!a&&"bottom"},t.getPinnedIndex=()=>{var o,l;const n=t.getIsPinned();if(!n)return-1;const r=null==(o="top"===n?e.getTopRows():e.getBottomRows())?void 0:o.map((t=>{let{id:e}=t;return e}));return null!=(l=null==r?void 0:r.indexOf(t.id))?l:-1}},createTable:t=>{t.setRowPinning=e=>null==t.options.onRowPinningChange?void 0:t.options.onRowPinningChange(e),t.resetRowPinning=e=>{var o,l;return t.setRowPinning(e?{top:[],bottom:[]}:null!=(o=null==(l=t.initialState)?void 0:l.rowPinning)?o:{top:[],bottom:[]})},t.getIsSomeRowsPinned=e=>{var o;const l=t.getState().rowPinning;var n,r;return e?Boolean(null==(o=l[e])?void 0:o.length):Boolean((null==(n=l.top)?void 0:n.length)||(null==(r=l.bottom)?void 0:r.length))},t._getPinnedRows=(e,o,l)=>{var n;return(null==(n=t.options.keepPinnedRows)||n?(null!=o?o:[]).map((e=>{const o=t.getRow(e,!0);return o.getIsAllParentsExpanded()?o:null})):(null!=o?o:[]).map((t=>e.find((e=>e.id===t))))).filter(Boolean).map((t=>({...t,position:l})))},t.getTopRows=s((()=>[t.getRowModel().rows,t.getState().rowPinning.top]),((e,o)=>t._getPinnedRows(e,o,"top")),c(t.options,"debugRows")),t.getBottomRows=s((()=>[t.getRowModel().rows,t.getState().rowPinning.bottom]),((e,o)=>t._getPinnedRows(e,o,"bottom")),c(t.options,"debugRows")),t.getCenterRows=s((()=>[t.getRowModel().rows,t.getState().rowPinning.top,t.getState().rowPinning.bottom]),((t,e,o)=>{const l=new Set([...null!=e?e:[],...null!=o?o:[]]);return t.filter((t=>!l.has(t.id)))}),c(t.options,"debugRows"))}},F,B];function U(t,e=!0){return t.map((t=>({id:t.id,accessorFn:e=>e[t.accessor],sortingFn:(t,e,o)=>{const l=t.getValue(o),n=e.getValue(o);if(null==l)return 1;if(null==n)return-1;if(!isNaN(Number(l))&&!isNaN(Number(n)))return Number(l)-Number(n);if(l instanceof Date&&n instanceof Date)return l.getTime()-n.getTime();const r=String(l).toLowerCase(),a=String(n).toLowerCase();return r.localeCompare(a)},header:"string"==typeof t.header?t.header:()=>t.header,enableSorting:!1!==t.sortable&&e,meta:{className:t.className,width:t.width,cellRenderer:t.cellRenderer}})))}const W=class{constructor(o){t(this,o),this.cellEditStart=e(this,"cellEditStart"),this.cellEditCommit=e(this,"cellEditCommit"),this.rowClick=e(this,"rowClick"),this.sortChange=e(this,"sortChange"),this.paginationChange=e(this,"paginationChange"),this.rowSelectionChange=e(this,"rowSelectionChange"),this.inheritedAttributes={},this.table=null,this.tanStackColumns=[],this.editable=!1,this.customClass="",this.density="comfortable",this.hover=!0,this.currentPage=1,this.paginated=!1,this.pageSizeOptions=[5,10,15],this.showPageSizeSelector=!0,this.sortable=!0,this.selectable="none",this.zebra=!1,this.activeEditor=null,this.sorting=[],this.internalPagination={pageIndex:0,pageSize:5},this.internalRowSelection={},this.handleSortingChange=t=>{const e="function"==typeof t?t(this.sorting):t;this.sorting=[...e],this.table&&(this.table.setOptions((t=>Object.assign(Object.assign({},t),{state:Object.assign(Object.assign({},t.state),{sorting:e})}))),this.table.getSortedRowModel()),this.sortChange.emit(e),this.sorting=[...e]},this.handlePaginationChange=t=>{const e="function"==typeof t?t(this.internalPagination):t;this.internalPagination=e,this.table&&this.table.setOptions((t=>Object.assign(Object.assign({},t),{state:Object.assign(Object.assign({},t.state),{pagination:e})}))),this.paginationChange.emit({currentPage:e.pageIndex+1,pageSize:e.pageSize}),this.internalPagination=e},this.handleRowSelectionChange=t=>{const e="function"==typeof t?t(this.internalRowSelection):t;this.selectedRowIds||(this.internalRowSelection=Object.assign({},e));const o=Object.keys(e).filter((t=>e[t])),l=[];this.table&&o.forEach((t=>{const e=this.table.getRow(t);e&&l.push(e.original)})),this.table&&this.table.setOptions((t=>Object.assign(Object.assign({},t),{state:Object.assign(Object.assign({},t.state),{rowSelection:e})}))),this.rowSelectionChange.emit({selectedRows:l,selectedRowIds:o})},this.handleRowClick=(t,e)=>{"none"!==this.selectable&&this.table&&this.toggleRowSelection(t),this.rowClick.emit({row:t.original,index:e})},this.handleHeaderClick=t=>{const e=this.columns.find((e=>e.id===t));if(!(null==e?void 0:e.sortable)||!this.sortable||!this.table)return;const o=this.sorting.find((e=>e.id===t));let l=[];o?o.desc||(l=[{id:t,desc:!0}]):l=[{id:t,desc:!1}];try{this.table.setSorting(l),this.table.getSortedRowModel(),this.sorting=[...l],this.sortChange.emit(l)}catch(t){console.error("Error applying sorting:",t)}}}handleCurrentPageChange(t){this.table&&this.internalPagination.pageIndex!==t-1&&(this.internalPagination=Object.assign(Object.assign({},this.internalPagination),{pageIndex:t-1}),this.table.setPagination(this.internalPagination))}handleDataChange(t){this.table?this.table.setOptions((e=>Object.assign(Object.assign({},e),{data:[...t]}))):t&&this.columns&&this.initializeTable()}handleColumnsChange(t){this.table?(this.tanStackColumns=U(t,this.sortable),this.table.setOptions((t=>Object.assign(Object.assign({},t),{columns:this.tanStackColumns})))):t&&this.data&&this.initializeTable()}handleSortableChange(t){this.table&&this.table.setOptions((e=>Object.assign(Object.assign({},e),{enableSorting:t,columns:U(this.columns,t),state:Object.assign(Object.assign({},e.state),{sorting:[]})})))}handlePaginatedChange(t){this.table&&this.table.setOptions((e=>Object.assign(Object.assign({},e),{manualPagination:!t})))}handleSelectedRowIdsChange(t){if(this.table&&Array.isArray(t)){const e={};t.forEach((t=>e[t]=!0)),this.internalRowSelection=e,this.table.setRowSelection(e)}}componentWillLoad(){var t,e;this.columns||console.error("ModusWcTable: columns is required."),this.data||console.error("ModusWcTable: data is required."),this.internalPagination={pageIndex:this.currentPage-1,pageSize:this.pageSizeOptions[0]};const o=Object.fromEntries(null!==(e=null===(t=this.selectedRowIds)||void 0===t?void 0:t.map((t=>[t,!0])))&&void 0!==e?e:[]);o&&Object.keys(o).length>0&&(this.internalRowSelection=o),this.inheritedAttributes=r(this.el),this.initializeTable()}disconnectedCallback(){this.globalClickHandler&&(document.removeEventListener("click",this.globalClickHandler,!0),this.globalClickHandler=void 0),this.activeEditorElement=void 0}initializeTable(){if(!this.columns||!this.data)return;const t=[...this.data];this.tanStackColumns=U(this.columns,this.sortable),this.table=function(t){const{data:e,columns:o,pageCount:l,sorting:n,pagination:r={pageIndex:0,pageSize:10},enableSorting:u=!0,manualSorting:i=!1,manualPagination:d=!1,enableRowSelection:h=!1,rowSelection:m,onRowSelectionChange:b,getRowId:g,onSortingChange:w,onPaginationChange:f}=t,p={pagination:r};void 0!==n&&(p.sorting=n),void 0!==m&&(p.rowSelection=m);const y=function(t){var e,o;const l=[...G,...null!=(e=t._features)?e:[]];let n={_features:l};const r=n._features.reduce(((t,e)=>Object.assign(t,null==e.getDefaultOptions?void 0:e.getDefaultOptions(n))),{});let u={...null!=(o=t.initialState)?o:{}};n._features.forEach((t=>{var e;u=null!=(e=null==t.getInitialState?void 0:t.getInitialState(u))?e:u}));const i=[];let d=!1;const h={_features:l,options:{...r,...t},initialState:u,_queue:t=>{i.push(t),d||(d=!0,Promise.resolve().then((()=>{for(;i.length;)i.shift()();d=!1})).catch((t=>setTimeout((()=>{throw t})))))},reset:()=>{n.setState(n.initialState)},setOptions:t=>{const e=a(t,n.options);n.options=(t=>n.options.mergeOptions?n.options.mergeOptions(r,t):{...r,...t})(e)},getState:()=>n.options.state,setState:t=>{null==n.options.onStateChange||n.options.onStateChange(t)},_getRowId:(t,e,o)=>{var l;return null!=(l=null==n.options.getRowId?void 0:n.options.getRowId(t,e,o))?l:`${o?[o.id,e].join("."):e}`},getCoreRowModel:()=>(n._getCoreRowModel||(n._getCoreRowModel=n.options.getCoreRowModel(n)),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(t,e)=>{let o=(e?n.getPrePaginationRowModel():n.getRowModel()).rowsById[t];if(!o&&(o=n.getCoreRowModel().rowsById[t],!o))throw new Error;return o},_getDefaultColumnDef:s((()=>[n.options.defaultColumn]),(t=>{var e;return t=null!=(e=t)?e:{},{header:t=>{const e=t.header.column.columnDef;return e.accessorKey?e.accessorKey:e.accessorFn?e.id:null},cell:t=>{var e,o;return null!=(e=null==(o=t.renderValue())||null==o.toString?void 0:o.toString())?e:null},...n._features.reduce(((t,e)=>Object.assign(t,null==e.getDefaultColumnDef?void 0:e.getDefaultColumnDef())),{}),...t}}),c(t,"debugColumns")),_getColumnDefs:()=>n.options.columns,getAllColumns:s((()=>[n._getColumnDefs()]),(t=>{const e=function(t,o,l){return void 0===l&&(l=0),t.map((t=>{const r=function(t,e,o,l){var n,r;const a={...t._getDefaultColumnDef(),...e},u=a.accessorKey;let i,d=null!=(n=null!=(r=a.id)?r:u?"function"==typeof String.prototype.replaceAll?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)?n:"string"==typeof a.header?a.header:void 0;if(a.accessorFn?i=a.accessorFn:u&&(i=u.includes(".")?t=>{let e=t;for(const t of u.split(".")){var o;e=null==(o=e)?void 0:o[t]}return e}:t=>t[a.accessorKey]),!d)throw new Error;let h={id:`${String(d)}`,accessorFn:i,parent:l,depth:o,columnDef:a,columns:[],getFlatColumns:s((()=>[!0]),(()=>{var t;return[h,...null==(t=h.columns)?void 0:t.flatMap((t=>t.getFlatColumns()))]}),c(t.options,"debugColumns")),getLeafColumns:s((()=>[t._getOrderColumnsFn()]),(t=>{var e;if(null!=(e=h.columns)&&e.length){let e=h.columns.flatMap((t=>t.getLeafColumns()));return t(e)}return[h]}),c(t.options,"debugColumns"))};for(const e of t._features)null==e.createColumn||e.createColumn(h,t);return h}(n,t,l,o);return r.columns=t.columns?e(t.columns,r,l+1):[],r}))};return e(t)}),c(t,"debugColumns")),getAllFlatColumns:s((()=>[n.getAllColumns()]),(t=>t.flatMap((t=>t.getFlatColumns()))),c(t,"debugColumns")),_getAllFlatColumnsById:s((()=>[n.getAllFlatColumns()]),(t=>t.reduce(((t,e)=>(t[e.id]=e,t)),{})),c(t,"debugColumns")),getAllLeafColumns:s((()=>[n.getAllColumns(),n._getOrderColumnsFn()]),((t,e)=>e(t.flatMap((t=>t.getLeafColumns())))),c(t,"debugColumns")),getColumn:t=>n._getAllFlatColumnsById()[t]};Object.assign(n,h);for(let t=0;t<n._features.length;t++){const e=n._features[t];null==e||null==e.createTable||e.createTable(n)}return n}({data:e,columns:o,pageCount:l,enableSorting:u,manualSorting:i,manualPagination:d,enableRowSelection:h,state:p,onSortingChange:w,onPaginationChange:f,onRowSelectionChange:b,getRowId:g,getCoreRowModel:t=>s((()=>[t.options.data]),(e=>{const o={rows:[],flatRows:[],rowsById:{}},l=function(e,n,r){void 0===n&&(n=0);const a=[];for(let i=0;i<e.length;i++){const s=v(t,t._getRowId(e[i],i,r),e[i],i,n,0,null==r?void 0:r.id);var u;o.flatRows.push(s),o.rowsById[s.id]=s,a.push(s),t.options.getSubRows&&(s.originalSubRows=t.options.getSubRows(e[i],i),null!=(u=s.originalSubRows)&&u.length&&(s.subRows=l(s.originalSubRows,n+1,s)))}return a};return o.rows=l(e),o}),c(t.options,"debugTable",0,(()=>t._autoResetPageIndex()))),getSortedRowModel:t=>s((()=>[t.getState().sorting,t.getPreSortedRowModel()]),((e,o)=>{if(!o.rows.length||null==e||!e.length)return o;const l=t.getState().sorting,n=[],r=l.filter((e=>{var o;return null==(o=t.getColumn(e.id))?void 0:o.getCanSort()})),a={};r.forEach((e=>{const o=t.getColumn(e.id);o&&(a[e.id]={sortUndefined:o.columnDef.sortUndefined,invertSorting:o.columnDef.invertSorting,sortingFn:o.getSortingFn()})}));const u=t=>{const e=t.map((t=>({...t})));return e.sort(((t,e)=>{for(let l=0;l<r.length;l+=1){var o;const n=r[l],u=a[n.id],i=u.sortUndefined,s=null!=(o=null==n?void 0:n.desc)&&o;let c=0;if(i){const o=void 0===t.getValue(n.id),l=void 0===e.getValue(n.id);if(o||l){if("first"===i)return o?-1:1;if("last"===i)return o?1:-1;c=o&&l?0:o?i:-i}}if(0===c&&(c=u.sortingFn(t,e,n.id)),0!==c)return s&&(c*=-1),u.invertSorting&&(c*=-1),c}return t.index-e.index})),e.forEach((t=>{var e;n.push(t),null!=(e=t.subRows)&&e.length&&(t.subRows=u(t.subRows))})),e};return{rows:u(o.rows),flatRows:n,rowsById:o.rowsById}}),c(t.options,"debugTable",0,(()=>t._autoResetPageIndex()))),getPaginationRowModel:d?void 0:t=>s((()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded]),((e,o)=>{if(!o.rows.length)return o;const{pageSize:l,pageIndex:n}=e;let{rows:r,flatRows:a,rowsById:u}=o;const i=l*n;let s;r=r.slice(i,i+l),s=t.options.paginateExpandedRows?{rows:r,flatRows:a,rowsById:u}:function(t){const e=[],o=t=>{var l;e.push(t),null!=(l=t.subRows)&&l.length&&t.getIsExpanded()&&t.subRows.forEach(o)};return t.rows.forEach(o),{rows:e,flatRows:t.flatRows,rowsById:t.rowsById}}({rows:r,flatRows:a,rowsById:u}),s.flatRows=[];const c=t=>{s.flatRows.push(t),t.subRows.length&&t.subRows.forEach(c)};return s.rows.forEach(c),s}),c(t.options,"debugTable")),onStateChange:()=>{},renderFallbackValue:null}),S=y;return S.setData=t=>{y.setOptions((e=>Object.assign(Object.assign({},e),{data:t}))),y.getRowModel()},S.setColumns=t=>{y.setOptions((e=>Object.assign(Object.assign({},e),{columns:t}))),y.getRowModel()},S}({data:t,columns:this.tanStackColumns,rowSelection:this.internalRowSelection,enableRowSelection:"none"!==this.selectable,pagination:this.internalPagination,enableSorting:this.sortable,manualPagination:!this.paginated,manualSorting:!1,onSortingChange:this.handleSortingChange,onPaginationChange:this.handlePaginationChange,onRowSelectionChange:this.handleRowSelectionChange,getRowId:(t,e)=>String(t&&null!=t.id?t.id:e)}),this.sorting.length>0&&this.table&&this.table.setSorting([...this.sorting])}getClasses(){const t=["modus-wc-table"],e=function(t){const e=[];return t.density&&e.push(`modus-wc-table-density-${t.density}`),t.zebra&&e.push("modus-wc-table-zebra"),t.hover&&e.push("modus-wc-table-hover"),e.join(" ")}({density:this.density,zebra:this.zebra,hover:this.hover});return e&&t.push(e),this.customClass&&t.push(this.customClass),t.join(" ")}toggleRowSelection(t){var e,o;const l=String(t.id),n=!!this.internalRowSelection[l];"single"===this.selectable?null===(e=this.table)||void 0===e||e.setRowSelection({[l]:!n}):null===(o=t.toggleSelected)||void 0===o||o.call(t)}getTotalPages(){return this.data&&this.data.length?this.internalPagination.pageSize<=0?1:Math.ceil(this.data.length/this.internalPagination.pageSize):1}handlePageChange(t){const e=this.getTotalPages();if(t<1||t>e||!this.table)return;const o=t-1;this.table.setPagination(Object.assign(Object.assign({},this.internalPagination),{pageIndex:o}))}handlePageSizeOptionChange(t){if(!this.table)return;const e=parseInt(t.detail.srcElement.value,10);this.table.setPagination({pageSize:e,pageIndex:0})}renderCell(t,e){var o;const l=e[t.accessor];return t.cellRenderer?t.cellRenderer(l,e):null!==(o=null==l?void 0:l.toString())&&void 0!==o?o:""}getPaginationSize(){switch(this.density){case"compact":return"sm";case"relaxed":return"lg";default:return"md"}}renderPageSizeSelector(){var t;if(!this.showPageSizeSelector)return null;const e=this.getPaginationSize(),l=null===(t=this.pageSizeOptions)||void 0===t?void 0:t.map((t=>({value:t.toString(),label:t.toString()})));return o("div",{class:"page-size-selector"},o("span",null,"Show"),o("modus-wc-select",{"aria-label":"Select page size",bordered:!0,size:e,onInputChange:t=>this.handlePageSizeOptionChange(t),options:l}))}renderPaginationInfo(){if(!this.data||!this.data.length)return null;const t=Math.min(this.internalPagination.pageIndex*this.internalPagination.pageSize+1,this.data.length),e=Math.min((this.internalPagination.pageIndex+1)*this.internalPagination.pageSize,this.data.length);return o("div",{class:"pagination-info"},"Showing ",t," to ",e," of ",this.data.length," entries")}isRowEditable(t){return"function"==typeof this.editable?this.editable(t):Boolean(this.editable)}validateRowAndColumn(t,e){var o,l;return!(t<0||t>=((null===(o=this.data)||void 0===o?void 0:o.length)||0))&&((null===(l=this.columns)||void 0===l?void 0:l.some((t=>t.id===e)))||!1)}enterEdit(t,e){this.validateRowAndColumn(t,e)&&this.isRowEditable(this.data[t])&&(this.activeEditor={rowIndex:t,colId:e},this.cellEditStart.emit({rowIndex:t,colId:e}))}commitEdit(t,e,o){var l;if(!this.validateRowAndColumn(t,e))return;const n=[...this.data],r=Object.assign(Object.assign({},n[t]),{[e]:o});n[t]=r,this.data=n,null===(l=this.table)||void 0===l||l.setOptions((t=>Object.assign(Object.assign({},t),{data:n}))),this.cellEditCommit.emit({rowIndex:t,colId:e,newValue:o,updatedRow:r}),this.activeEditor=null}setupEditorCell(t,e,o,l,n){t.innerHTML="","string"!=typeof e&&"tagName"in e?(t.appendChild(e),o.editorTemplate&&o.editorSetup&&o.editorSetup(e,l,n),this.activeEditorElement=t,this.globalClickHandler||(this.globalClickHandler=t=>{this.activeEditor&&this.activeEditorElement&&!this.el.contains(t.target)&&(this.activeEditor=null,this.activeEditorElement=void 0)},document.addEventListener("click",this.globalClickHandler,!0))):t.textContent=String(e)}render(){var t,e,n;const r=this.table?this.paginated?this.table.getPaginationRowModel().rows:this.table.getRowModel().rows:[],a=r.map((t=>t.original)),u=this.getTotalPages();return o(l,{key:"1cf7f9c0b22b23d76fe433dc69b7c12e3c36263c"},o("div",{key:"896c63170c7ef798d3b2d5cf9978cceadb40529a",class:"table-container"},o("div",Object.assign({key:"d551fb0d5e4ca7de9d01381e4ff80606b2dc4580",class:"modus-wc-overflow-x-auto"},this.inheritedAttributes),o("table",{key:"504170d756594e6dc8da783d5414a96310382ce3",class:this.getClasses()},this.caption&&o("caption",{key:"43703be78071edfa608ae23c8b71724486eb82c3",class:"modus-wc-sr-only"},this.caption),o("thead",{key:"733bce82284aba8b72df8131e01279649995ccf7"},o("tr",{key:"aeaa9d8214f7022d324ac16c5aaa88666fc6c0a8"},"none"!==this.selectable&&o("th",{key:"2178d4040efaef874635add286fa1a9219c648e8",class:"selection-column",style:{width:"48px"}},"multi"===this.selectable&&this.table&&o("modus-wc-checkbox",{key:"8ae882271283a269561e369bab88586230dcd707","aria-label":"Select all rows",size:"sm",value:this.table.getIsAllRowsSelected(),indeterminate:this.table.getIsSomeRowsSelected()&&!this.table.getIsAllRowsSelected(),onInputChange:()=>{var t;return null===(t=this.table)||void 0===t?void 0:t.toggleAllRowsSelected()}})),null===(t=this.columns)||void 0===t?void 0:t.map((t=>{var e;const l=null===(e=this.table)||void 0===e?void 0:e.getColumn(t.id),n=null==l?void 0:l.getIsSorted(),r="asc"===n,a="desc"===n;return o("th",{class:{[t.className||""]:!!t.className,sortable:Boolean(t.sortable&&this.sortable),sorted:!!n,asc:!!r,desc:!!a},style:{width:t.width},onClick:()=>this.handleHeaderClick(t.id),role:t.sortable&&this.sortable?"button":void 0,tabIndex:t.sortable&&this.sortable?0:void 0,"aria-sort":r?"ascending":a?"descending":void 0},t.header,t.sortable&&this.sortable&&o("span",{class:"sort-icon","aria-hidden":"true"},o("modus-wc-icon",r?{name:"sort_alpha_down",size:"xs"}:a?{name:"sort_alpha_up",size:"xs"}:{name:"sort_alpha_down",size:"xs",style:{opacity:"0.5"}})))})))),o("tbody",{key:"92c266aeeecb4e742f2e600d61c249f83f63bad0"},a.length>0?r.map(((t,e)=>{var l,n,r,a,u;const i=t.original;return o("tr",{key:null!==(l=t.id)&&void 0!==l?l:`row-${e}`,class:{selected:!!this.internalRowSelection[String(t.id)]||(null===(n=t.getIsSelected)||void 0===n?void 0:n.call(t))},onClick:()=>this.handleRowClick(t,e)},"none"!==this.selectable&&o("td",{class:"selection-column",style:{width:"48px"}},o("modus-wc-checkbox",{"aria-label":"Select row",size:"sm",value:null!==(a=null===(r=t.getIsSelected)||void 0===r?void 0:r.call(t))&&void 0!==a&&a})),null===(u=this.columns)||void 0===u?void 0:u.map((t=>{var l,n,r;const a=(null===(l=this.activeEditor)||void 0===l?void 0:l.rowIndex)===e&&this.activeEditor.colId===t.id,u=this.renderCell(t,i),s=o=>this.commitEdit(e,t.id,o);let c;if(a)if(t.editorTemplate){const e=t.editorTemplate.replace(/\$\{value\}/g,String(null!==(n=i[t.accessor])&&void 0!==n?n:"")),o=document.createElement("div");o.innerHTML=e,c=o.firstElementChild,null===(r=t.editorSetup)||void 0===r||r.call(t,c,i,s)}else c=t.customEditorRenderer?t.customEditorRenderer(i[t.accessor],s,i):u;else c=u;return o("td",{class:{[t.className||""]:!!t.className,editing:a},"data-col":t.id,onDblClick:o=>{var l,n,r;(null===(l=this.activeEditor)||void 0===l?void 0:l.rowIndex)===e&&(null===(n=this.activeEditor)||void 0===n?void 0:n.colId)===t.id||(null===(r=this.activeEditorElement)||void 0===r?void 0:r.contains(o.target))||this.enterEdit(e,t.id)},ref:e=>{e&&this.setupEditorCell(e,c,t,i,s)}})})))})):o("tr",null,o("td",{colSpan:((null===(e=this.columns)||void 0===e?void 0:e.length)||1)+("none"!==this.selectable?1:0),class:"no-data-message"},"No data available"))))),this.paginated&&(null===(n=this.data)||void 0===n?void 0:n.length)>0&&o("div",{key:"aaa5bfe16cb2433f3adec73e2740625aa7afa678",class:"pagination-container"},this.renderPageSizeSelector(),this.renderPaginationInfo(),o("div",{key:"2f12609eebdc7e3bcd5ea9f24fe99eae6d51ab0f",class:"pagination-controls"},o("modus-wc-pagination",{key:"5d4782ec737bc3ec3547f0f40280c91e03bc1614",count:u,page:this.internalPagination.pageIndex+1,size:this.getPaginationSize(),onPageChange:t=>this.handlePageChange(Number(t.detail.newPage))})))))}get el(){return n(this)}static get watchers(){return{currentPage:["handleCurrentPageChange"],data:["handleDataChange"],columns:["handleColumnsChange"],sortable:["handleSortableChange"],paginated:["handlePaginatedChange"],selectedRowIds:["handleSelectedRowIdsChange"]}}};W.style=":host{display:block;}:host p,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6{margin:0}.table-container{display:flex;flex-direction:column;width:100%}modus-wc-table .modus-wc-table.modus-wc-table-zebra tbody tr:nth-child(2n){background-color:var(--modus-wc-color-base-page)}modus-wc-table .modus-wc-table:where(thead,tfoot){background-color:var(--modus-wc-color-base-100)}modus-wc-table .modus-wc-table:where(thead tr,tbody tr:not(:last-child),tbody tr:first-child:last-child){border-bottom-color:var(--modus-wc-color-base-100)}modus-wc-table .modus-wc-overflow-x-auto{border:var(--modus-wc-border-width-sm) solid var(--modus-wc-color-base-100);border-radius:var(--modus-wc-border-radius-table);overflow-x:auto}[data-theme=modus-classic-light] modus-wc-table .modus-wc-overflow-x-auto,[data-theme=modus-classic-dark] modus-wc-table .modus-wc-overflow-x-auto{border-radius:0}[data-theme=modus-classic-light] modus-wc-table .modus-wc-table,[data-theme=modus-classic-dark] modus-wc-table .modus-wc-table{border-collapse:collapse;border-radius:0}[data-theme=modus-classic-light] modus-wc-table .modus-wc-table th,[data-theme=modus-classic-light] modus-wc-table .modus-wc-table td,[data-theme=modus-classic-dark] modus-wc-table .modus-wc-table th,[data-theme=modus-classic-dark] modus-wc-table .modus-wc-table td{border-right:1px solid #b7b9c3}[data-theme=modus-classic-light] modus-wc-table .modus-wc-table th:last-child,[data-theme=modus-classic-light] modus-wc-table .modus-wc-table td:last-child,[data-theme=modus-classic-dark] modus-wc-table .modus-wc-table th:last-child,[data-theme=modus-classic-dark] modus-wc-table .modus-wc-table td:last-child{border-right:none}[data-theme=modus-classic-light] th{background-color:#f1f1f6 !important;color:#464b52 !important}[data-theme=modus-classic-light] .modus-wc-table.modus-wc-table-hover tbody tr:hover{background-color:#dcedf9 !important}[data-theme=modus-classic-dark] th{background-color:#464b52 !important;color:#e0e1e9 !important}[data-theme=modus-classic-dark] .modus-wc-table.modus-wc-table-hover tbody tr:hover{background-color:#464b52 !important}[data-theme=connect-light] modus-wc-table,[data-theme=connect-dark] modus-wc-table{border:none;box-shadow:none}[data-theme=connect-light] modus-wc-table .modus-wc-overflow-x-auto,[data-theme=connect-dark] modus-wc-table .modus-wc-overflow-x-auto{border:none;border-radius:0}[data-theme=connect-light] modus-wc-table .modus-wc-table,[data-theme=connect-dark] modus-wc-table .modus-wc-table{border:none;border-collapse:collapse;border-radius:0}[data-theme=connect-light] modus-wc-table .modus-wc-table th,[data-theme=connect-light] modus-wc-table .modus-wc-table td,[data-theme=connect-dark] modus-wc-table .modus-wc-table th,[data-theme=connect-dark] modus-wc-table .modus-wc-table td{border-right:1px solid transparent}[data-theme=connect-light] modus-wc-table th,[data-theme=connect-dark] modus-wc-table th{background-color:var(--modus-wc-color-base-100) !important;border:none !important;color:var(--modus-wc-color-base-content-low-contrast) !important}[data-theme=connect-light] modus-wc-table td,[data-theme=connect-dark] modus-wc-table td{border:none !important;border-bottom:1px solid var(--modus-wc-color-base-100)}[data-theme=connect-light] modus-wc-table .modus-wc-table.modus-wc-table-hover tbody tr:hover,[data-theme=connect-dark] modus-wc-table .modus-wc-table.modus-wc-table-hover tbody tr:hover{background-color:var(--modus-wc-color-base-100) !important}.modus-wc-table{overflow:hidden;width:100%;}.modus-wc-table th{background-color:var(--modus-wc-color-alt-white);color:var(--modus-wc-color-gray-dark);font-size:0.875rem;font-weight:600;padding:0.75rem;text-align:left;vertical-align:middle}.modus-wc-table th.sortable{cursor:pointer;padding-right:1.5rem;position:relative}.modus-wc-table th.sortable .sort-icon{color:var(--modus-wc-color-blue);position:absolute;right:0.5rem;top:50%;transform:translateY(-50%)}.modus-wc-table th.sortable:hover{background-color:var(--modus-wc-color-alt-silver-light)}.modus-wc-table td{border-bottom:1px solid var(--modus-wc-color-alt-silver);padding:0.75rem;vertical-align:middle}.modus-wc-table tr:last-child td{border-bottom:none}.modus-wc-table.modus-wc-table-density-compact td,.modus-wc-table.modus-wc-table-density-compact th{padding:0.5rem}.modus-wc-table.modus-wc-table-density-relaxed td,.modus-wc-table.modus-wc-table-density-relaxed th{padding:1.25rem 1rem}.modus-wc-table.modus-wc-table-density-comfortable td,.modus-wc-table.modus-wc-table-density-comfortable th{padding:1rem}.modus-wc-table.modus-wc-table-zebra tbody tr:nth-child(odd){background-color:var(--modus-wc-color-base-100)}.modus-wc-table.modus-wc-table-hover tbody tr{transition:background-color 0.15s ease-in-out}.modus-wc-table.modus-wc-table-hover tbody tr:hover{background-color:var(--modus-wc-color-base-100);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr:focus{background-color:var(--modus-wc-color-base-200);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr:active{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr-selected{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr-active{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr-open{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr.selected{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr.active{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr-disabled:hover{background-color:inherit}.modus-wc-table.modus-wc-table-hover tbody tr--active{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr--selected{background-color:var(--modus-wc-color-primary-pale);color:var(--modus-wc-color-primary)}.modus-wc-table.modus-wc-table-hover tbody tr:checked{background-color:var(--modus-wc-color-primary);color:var(--modus-wc-color-primary-content)}.modus-wc-table.modus-wc-table-hover tbody tr.checked{background-color:var(--modus-wc-color-primary);color:var(--modus-wc-color-primary-content)}.modus-wc-table.modus-wc-table-hover tbody tr-checked{background-color:var(--modus-wc-color-primary);color:var(--modus-wc-color-primary-content)}.modus-wc-table.modus-wc-table-hover tbody tr.pressed{background-color:var(--modus-wc-color-primary);color:var(--modus-wc-color-primary-content)}.modus-wc-table.modus-wc-table-hover tbody tr-pressed{background-color:var(--modus-wc-color-primary);color:var(--modus-wc-color-primary-content)}.modus-wc-table.modus-wc-table-hover tbody tr[aria-pressed=true]{background-color:var(--modus-wc-color-primary);color:var(--modus-wc-color-primary-content)}.modus-wc-table tbody tr{cursor:pointer}.modus-wc-table .no-data-message{color:var(--modus-wc-color-gray);font-style:italic;padding:1.5rem;text-align:center}.pagination-container{align-items:center;display:flex;flex-wrap:wrap;gap:0.75rem;justify-content:space-between;margin-top:1rem;padding:0.5rem 0}@media (width <= 768px){.pagination-container{align-items:flex-start;flex-direction:column;gap:1rem}}.pagination-info{color:var(--modus-wc-color-gray-dark);font-size:0.875rem}.pagination-controls{align-items:center;display:flex}.page-size-selector,.modus-wc-table-page-size-selector{align-items:center;color:var(--modus-wc-color-gray-dark);display:flex;font-size:0.875rem;gap:0.5rem}.page-size-selector select,.modus-wc-table-page-size-selector select{background-color:var(--modus-wc-color-alt-white);border:1px solid var(--modus-wc-color-alt-silver);border-radius:0.25rem;color:var(--modus-wc-color-gray-dark);font-size:0.875rem;height:2rem;min-width:4rem;padding:0 0.5rem}.page-size-selector select:focus,.modus-wc-table-page-size-selector select:focus{border-color:var(--modus-wc-color-blue);box-shadow:0 0 0 2px var(--modus-wc-color-blue-light);outline:none}tr.selected{background-color:var(--modus-wc-color-primary-pale)}.modus-wc-table td.editing{padding-bottom:0.25rem;padding-top:0.25rem}.modus-wc-table td.editing>*{margin:0;width:100%}";export{W as modus_wc_table}