snice 7.7.0 → 7.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/adapters/react/SniceProvider.js +1 -1
  2. package/adapters/react/SniceRouter.js +1 -1
  3. package/adapters/react/calendar.d.ts +1 -0
  4. package/adapters/react/calendar.d.ts.map +1 -1
  5. package/adapters/react/calendar.js +1 -1
  6. package/adapters/react/calendar.js.map +1 -1
  7. package/adapters/react/calendar.tsx +2 -1
  8. package/adapters/react/matchRoute.js +1 -1
  9. package/adapters/react/useRequestHandler.js +1 -1
  10. package/bin/analyzer-contracts.js +8 -2
  11. package/custom-elements.json +5 -1
  12. package/dist/cdn/accordion/snice-accordion.js +1 -1
  13. package/dist/cdn/action-bar/snice-action-bar.js +1 -1
  14. package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
  15. package/dist/cdn/alert/snice-alert.js +1 -1
  16. package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
  17. package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
  18. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  19. package/dist/cdn/availability/snice-availability.js +1 -1
  20. package/dist/cdn/avatar/snice-avatar.js +1 -1
  21. package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
  22. package/dist/cdn/badge/snice-badge.js +1 -1
  23. package/dist/cdn/banner/snice-banner.js +1 -1
  24. package/dist/cdn/binpack/snice-binpack.js +1 -1
  25. package/dist/cdn/book/snice-book.js +1 -1
  26. package/dist/cdn/booking/snice-booking.js +1 -1
  27. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  28. package/dist/cdn/button/snice-button.js +1 -1
  29. package/dist/cdn/calendar/README.md +2 -2
  30. package/dist/cdn/calendar/snice-calendar.js +26 -2
  31. package/dist/cdn/calendar/snice-calendar.js.map +1 -1
  32. package/dist/cdn/calendar/snice-calendar.min.js +2 -2
  33. package/dist/cdn/calendar/snice-calendar.min.js.map +1 -1
  34. package/dist/cdn/camera/snice-camera.js +1 -1
  35. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  36. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  37. package/dist/cdn/card/snice-card.js +1 -1
  38. package/dist/cdn/carousel/snice-carousel.js +1 -1
  39. package/dist/cdn/cart/snice-cart.js +1 -1
  40. package/dist/cdn/chart/snice-chart.js +1 -1
  41. package/dist/cdn/chat/snice-chat.js +1 -1
  42. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  43. package/dist/cdn/chip/snice-chip.js +1 -1
  44. package/dist/cdn/code-block/snice-code-block.js +1 -1
  45. package/dist/cdn/color-display/snice-color-display.js +1 -1
  46. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  47. package/dist/cdn/command-palette/snice-command-palette.js +1 -1
  48. package/dist/cdn/comments/snice-comments.js +1 -1
  49. package/dist/cdn/countdown/snice-countdown.js +1 -1
  50. package/dist/cdn/cropper/snice-cropper.js +1 -1
  51. package/dist/cdn/data-card/snice-data-card.js +1 -1
  52. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  53. package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
  54. package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
  55. package/dist/cdn/diff/snice-diff.js +1 -1
  56. package/dist/cdn/divider/snice-divider.js +1 -1
  57. package/dist/cdn/doc/snice-doc.js +1 -1
  58. package/dist/cdn/draw/snice-draw.js +1 -1
  59. package/dist/cdn/drawer/snice-drawer.js +1 -1
  60. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  61. package/dist/cdn/estimate/snice-estimate.js +1 -1
  62. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  63. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  64. package/dist/cdn/flip-card/snice-flip-card.js +1 -1
  65. package/dist/cdn/flow/snice-flow.js +1 -1
  66. package/dist/cdn/form-layout/snice-form-layout.js +1 -1
  67. package/dist/cdn/funnel/snice-funnel.js +1 -1
  68. package/dist/cdn/gantt/snice-gantt.js +1 -1
  69. package/dist/cdn/gauge/snice-gauge.js +1 -1
  70. package/dist/cdn/grid/snice-grid.js +1 -1
  71. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  72. package/dist/cdn/image/snice-image.js +1 -1
  73. package/dist/cdn/input/snice-input.js +1 -1
  74. package/dist/cdn/invoice/snice-invoice.js +1 -1
  75. package/dist/cdn/kanban/snice-kanban.js +1 -1
  76. package/dist/cdn/key-value/snice-key-value.js +1 -1
  77. package/dist/cdn/kpi/snice-kpi.js +1 -1
  78. package/dist/cdn/layout/snice-layout.js +1 -1
  79. package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
  80. package/dist/cdn/link/snice-link.js +1 -1
  81. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  82. package/dist/cdn/list/snice-list.js +1 -1
  83. package/dist/cdn/location/snice-location.js +1 -1
  84. package/dist/cdn/login/snice-login.js +1 -1
  85. package/dist/cdn/map/snice-map.js +1 -1
  86. package/dist/cdn/markdown/snice-markdown.js +1 -1
  87. package/dist/cdn/masonry/snice-masonry.js +1 -1
  88. package/dist/cdn/menu/snice-menu.js +1 -1
  89. package/dist/cdn/message-strip/snice-message-strip.js +1 -1
  90. package/dist/cdn/modal/snice-modal.js +1 -1
  91. package/dist/cdn/music-player/snice-music-player.js +1 -1
  92. package/dist/cdn/nav/snice-nav.js +1 -1
  93. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  94. package/dist/cdn/notification-center/snice-notification-center.js +1 -1
  95. package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
  96. package/dist/cdn/org-chart/snice-org-chart.js +1 -1
  97. package/dist/cdn/pagination/snice-pagination.js +1 -1
  98. package/dist/cdn/paint/snice-paint.js +1 -1
  99. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
  100. package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
  101. package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
  102. package/dist/cdn/popover/snice-popover.js +1 -1
  103. package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
  104. package/dist/cdn/product-card/snice-product-card.js +1 -1
  105. package/dist/cdn/progress/snice-progress.js +1 -1
  106. package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
  107. package/dist/cdn/qr-code/snice-qr-code.js +1 -1
  108. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  109. package/dist/cdn/radio/snice-radio.js +1 -1
  110. package/dist/cdn/range-slider/snice-range-slider.js +1 -1
  111. package/dist/cdn/rating/snice-rating.js +1 -1
  112. package/dist/cdn/receipt/snice-receipt.js +1 -1
  113. package/dist/cdn/recipe/snice-recipe.js +1 -1
  114. package/dist/cdn/runtime/README.md +2 -2
  115. package/dist/cdn/runtime/snice-runtime.esm.js +130 -31
  116. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  117. package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
  118. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  119. package/dist/cdn/runtime/snice-runtime.js +130 -31
  120. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  121. package/dist/cdn/runtime/snice-runtime.min.js +1 -1
  122. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  123. package/dist/cdn/sankey/snice-sankey.js +1 -1
  124. package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
  125. package/dist/cdn/select/snice-select.js +1 -1
  126. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  127. package/dist/cdn/slider/snice-slider.js +1 -1
  128. package/dist/cdn/sortable/snice-sortable.js +1 -1
  129. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  130. package/dist/cdn/spinner/snice-spinner.js +1 -1
  131. package/dist/cdn/split-button/snice-split-button.js +1 -1
  132. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  133. package/dist/cdn/spotlight/snice-spotlight.js +1 -1
  134. package/dist/cdn/stat-group/snice-stat-group.js +1 -1
  135. package/dist/cdn/step-input/snice-step-input.js +1 -1
  136. package/dist/cdn/stepper/snice-stepper.js +1 -1
  137. package/dist/cdn/switch/snice-switch.js +1 -1
  138. package/dist/cdn/table/README.md +2 -2
  139. package/dist/cdn/table/snice-table.esm.js +157 -33
  140. package/dist/cdn/table/snice-table.esm.js.map +1 -1
  141. package/dist/cdn/table/snice-table.esm.min.js +4 -4
  142. package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
  143. package/dist/cdn/table/snice-table.js +157 -33
  144. package/dist/cdn/table/snice-table.js.map +1 -1
  145. package/dist/cdn/table/snice-table.min.js +33 -33
  146. package/dist/cdn/table/snice-table.min.js.map +1 -1
  147. package/dist/cdn/tabs/snice-tabs.js +1 -1
  148. package/dist/cdn/tag/snice-tag.js +1 -1
  149. package/dist/cdn/tag-input/README.md +2 -2
  150. package/dist/cdn/tag-input/snice-tag-input.js +10 -16
  151. package/dist/cdn/tag-input/snice-tag-input.js.map +1 -1
  152. package/dist/cdn/tag-input/snice-tag-input.min.js +2 -2
  153. package/dist/cdn/tag-input/snice-tag-input.min.js.map +1 -1
  154. package/dist/cdn/terminal/snice-terminal.js +1 -1
  155. package/dist/cdn/testimonial/snice-testimonial.js +1 -1
  156. package/dist/cdn/textarea/snice-textarea.js +1 -1
  157. package/dist/cdn/time-picker/snice-time-picker.js +1 -1
  158. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  159. package/dist/cdn/timeline/snice-timeline.js +1 -1
  160. package/dist/cdn/timer/snice-timer.js +1 -1
  161. package/dist/cdn/toast/snice-toast.js +1 -1
  162. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  163. package/dist/cdn/tree/snice-tree.js +1 -1
  164. package/dist/cdn/treemap/snice-treemap.js +1 -1
  165. package/dist/cdn/user-card/snice-user-card.js +1 -1
  166. package/dist/cdn/video-player/snice-video-player.js +1 -1
  167. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  168. package/dist/cdn/waterfall/snice-waterfall.js +1 -1
  169. package/dist/cdn/weather/snice-weather.js +1 -1
  170. package/dist/cdn/work-order/snice-work-order.js +1 -1
  171. package/dist/components/calendar/snice-calendar.d.ts +2 -0
  172. package/dist/components/calendar/snice-calendar.js +25 -1
  173. package/dist/components/calendar/snice-calendar.js.map +1 -1
  174. package/dist/components/table/snice-row.d.ts +6 -0
  175. package/dist/components/table/snice-row.js +11 -3
  176. package/dist/components/table/snice-row.js.map +1 -1
  177. package/dist/components/table/snice-table.d.ts +31 -3
  178. package/dist/components/table/snice-table.js +89 -16
  179. package/dist/components/table/snice-table.js.map +1 -1
  180. package/dist/components/table/table-cell-presentation.d.ts +11 -0
  181. package/dist/components/table/table-cell-presentation.js +25 -8
  182. package/dist/components/table/table-cell-presentation.js.map +1 -1
  183. package/dist/components/table/table-export.d.ts +6 -0
  184. package/dist/components/table/table-export.js +11 -2
  185. package/dist/components/table/table-export.js.map +1 -1
  186. package/dist/components/table/table-master-detail.d.ts +11 -2
  187. package/dist/components/table/table-master-detail.js +20 -3
  188. package/dist/components/table/table-master-detail.js.map +1 -1
  189. package/dist/components/tag-input/snice-tag-input.d.ts +2 -2
  190. package/dist/components/tag-input/snice-tag-input.js +9 -15
  191. package/dist/components/tag-input/snice-tag-input.js.map +1 -1
  192. package/dist/index.cjs +127 -28
  193. package/dist/index.cjs.map +1 -1
  194. package/dist/index.esm.js +127 -28
  195. package/dist/index.esm.js.map +1 -1
  196. package/dist/index.iife.js +127 -28
  197. package/dist/index.iife.js.map +1 -1
  198. package/dist/react/SniceProvider.js +1 -1
  199. package/dist/react/SniceRouter.js +1 -1
  200. package/dist/react/index.js +1 -1
  201. package/dist/react/matchRoute.js +1 -1
  202. package/dist/react/useRequestHandler.js +1 -1
  203. package/dist/request-response.d.ts +24 -1
  204. package/dist/symbols.cjs +1 -1
  205. package/dist/symbols.esm.js +1 -1
  206. package/dist/testing-dom.cjs +1 -1
  207. package/dist/testing-dom.esm.js +1 -1
  208. package/dist/transitions.cjs +1 -1
  209. package/dist/transitions.esm.js +1 -1
  210. package/docs/ai/components/calendar.md +8 -0
  211. package/docs/ai/components/tag-input.md +4 -0
  212. package/docs/ai/controllers.md +22 -6
  213. package/docs/components/calendar.md +24 -0
  214. package/docs/components/tag-input.md +6 -1
  215. package/docs/controllers.md +57 -6
  216. package/package.json +1 -1
@@ -340,7 +340,7 @@ import{html as e,unsafeHTML as t,element as i,state as a,property as s,query as
340
340
  </if>
341
341
  <div class="empty-state__extra"><slot></slot></div>
342
342
  </div>
343
- `}styles(){return m`${":host([hidden]){display:none}:host{display:block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif)}.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:var(--snice-spacing-2xl,3rem) var(--snice-spacing-xl,2rem);color:var(--snice-color-text-secondary,rgb(82 82 82));animation:snice-empty-in 360ms var(--snice-ease-out,ease) backwards}@keyframes snice-empty-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.empty-state--small{padding:var(--snice-spacing-xl,2rem) var(--snice-spacing-lg,1.5rem)}.empty-state--medium{padding:var(--snice-spacing-2xl,3rem) var(--snice-spacing-xl,2rem)}.empty-state--large{padding:var(--snice-spacing-3xl,4rem) var(--snice-spacing-2xl,2.5rem)}.empty-state__icon-wrapper{display:flex;align-items:center;justify-content:center;margin-bottom:var(--snice-spacing-lg,1.5rem);position:relative;width:calc(var(--snice-font-size-4xl,4rem) * 1.8);height:calc(var(--snice-font-size-4xl,4rem) * 1.8)}.empty-state__icon-wrapper::before{content:'';position:absolute;inset:0;border-radius:50%;border:1px dashed color-mix(in srgb,var(--snice-color-border,#ddd) 70%,transparent);animation:18s linear infinite snice-empty-halo}@keyframes snice-empty-halo{to{transform:rotate(360deg)}}.empty-state__icon{font-size:var(--snice-font-size-4xl, 4rem);opacity:.5;line-height:1}.empty-state__icon svg{width:1em;height:1em;display:block}.empty-state__icon-wrapper ::slotted(*){display:flex;align-items:center;justify-content:center;font-size:var(--snice-font-size-4xl, 4rem);opacity:.5;line-height:1}.empty-state__icon-wrapper ::slotted(svg){width:var(--snice-font-size-4xl,4rem);height:var(--snice-font-size-4xl,4rem)}.empty-state__icon-wrapper ::slotted(img){width:var(--snice-font-size-4xl,4rem);height:var(--snice-font-size-4xl,4rem);object-fit:contain}.empty-state--small .empty-state__icon-wrapper{margin-bottom:var(--snice-spacing-md,1rem);width:calc(var(--snice-font-size-3xl,3rem) * 1.8);height:calc(var(--snice-font-size-3xl,3rem) * 1.8)}.empty-state--small .empty-state__icon{font-size:var(--snice-font-size-3xl, 3rem)}.empty-state--small .empty-state__icon-wrapper ::slotted(*){font-size:var(--snice-font-size-3xl, 3rem)}.empty-state--small .empty-state__icon-wrapper ::slotted(img),.empty-state--small .empty-state__icon-wrapper ::slotted(svg){width:var(--snice-font-size-3xl,3rem);height:var(--snice-font-size-3xl,3rem)}.empty-state--large .empty-state__icon-wrapper{margin-bottom:var(--snice-spacing-xl,2rem);width:calc(var(--snice-font-size-3xl,5rem) * 1.8);height:calc(var(--snice-font-size-3xl,5rem) * 1.8)}.empty-state--large .empty-state__icon{font-size:var(--snice-font-size-3xl, 5rem)}.empty-state--large .empty-state__icon-wrapper ::slotted(*){font-size:var(--snice-font-size-3xl, 5rem)}.empty-state--large .empty-state__icon-wrapper ::slotted(img),.empty-state--large .empty-state__icon-wrapper ::slotted(svg){width:var(--snice-font-size-3xl,5rem);height:var(--snice-font-size-3xl,5rem)}.empty-state__title{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);font-size:var(--snice-heading-lg, 1.25rem);font-weight:var(--snice-font-weight-semibold,600);color:var(--snice-color-text,rgb(23 23 23));margin:0 0 var(--snice-spacing-xs,.5rem) 0}.empty-state--small .empty-state__title{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);font-size:var(--snice-heading-md, 1.125rem);margin-bottom:var(--snice-spacing-2xs,.375rem)}.empty-state--large .empty-state__title{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);font-size:var(--snice-heading-xl, 1.5rem);margin-bottom:var(--snice-spacing-sm,.75rem)}.empty-state__description{font-size:var(--snice-font-size-sm, .875rem);color:var(--snice-color-text-secondary,rgb(82 82 82));margin:0 0 var(--snice-spacing-lg,1.5rem) 0;max-width:32rem;line-height:var(--snice-line-height-normal, 1.5)}.empty-state--small .empty-state__description{font-size:var(--snice-font-size-xs, .8125rem);margin-bottom:var(--snice-spacing-md,1rem)}.empty-state--large .empty-state__description{font-size:var(--snice-font-size-md, 1rem);margin-bottom:var(--snice-spacing-xl,2rem)}.empty-state__action{display:inline-flex;align-items:center;justify-content:center;padding:var(--snice-spacing-xs,.5rem) var(--snice-spacing-md,1rem);font-size:var(--snice-font-size-sm, .875rem);font-weight:var(--snice-font-weight-medium,500);color:var(--snice-color-text-inverse,rgb(250 250 250));background:var(--snice-color-primary,rgb(37 99 235));border:none;border-radius:var(--snice-border-radius-md,.375rem);text-decoration:none;cursor:pointer;transition:background var(--snice-transition-fast, 150ms)}.empty-state__action:hover{background:var(--snice-color-primary-hover,rgb(29 78 216))}.empty-state--small .empty-state__action{padding:var(--snice-spacing-2xs,.375rem) var(--snice-spacing-sm,.75rem);font-size:var(--snice-font-size-xs, .8125rem)}.empty-state--large .empty-state__action{padding:var(--snice-spacing-sm,.625rem) var(--snice-spacing-lg,1.25rem);font-size:var(--snice-font-size-md, 1rem)}.empty-state__extra ::slotted(*){margin-top:var(--snice-spacing-md,1rem)}@media (prefers-reduced-motion:reduce){*{transition-duration:0s!important;animation-duration:0s!important}}"}`}handleActionClick(e){this.actionHref||e.preventDefault(),this.dispatchActionEvent()}dispatchActionEvent(){return{emptyState:this}}constructor(){super(...arguments),this.size=(k(this,C),k(this,S,"medium")),this.icon=(k(this,E),k(this,D,"📭")),this.title=(k(this,A),k(this,R,"No data")),this.description=(k(this,M),k(this,z,"")),this.actionText=(k(this,$),k(this,F,"")),this.actionHref=(k(this,I),k(this,T,"")),k(this,L)}})})();var ie=":host([hidden]){display:none}:host{display:block;width:100%;font-size:.875rem;line-height:1.25rem;color:var(--snice-color-text,rgb(23 23 23))}.cell-content{width:100%;min-height:1.25rem;word-wrap:break-word}:host([align=left]){text-align:left}:host([align=center]){text-align:center}:host([align=right]){text-align:right}:host([type=accounting]),:host([type=currency]),:host([type=fraction]),:host([type=number]),:host([type=percent]),:host([type=scientific]){font-variant-numeric:tabular-nums;text-align:right}:host([type=date]){font-variant-numeric:tabular-nums}:host([type=boolean]){text-align:center;font-size:1rem}.boolean--true{color:var(--snice-color-success,rgb(22 163 74))}.boolean--false{color:var(--snice-color-danger,rgb(220 38 38))}:host([type=rating]){text-align:center}:host([type=sparkline]){text-align:center}.cell-content--text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cell-content--text[data-multiline=true]{white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word}.cell-content--date,.cell-content--number{font-feature-settings:'tnum'}:host([type=boolean]) .cell-content{display:flex;align-items:center;justify-content:center}:host([type=rating]) .cell-content{display:flex;align-items:center;justify-content:center;gap:.125rem;container-type:inline-size}:host([type=rating]) snice-rating{--rating-size:clamp(0.55rem, 16cqi, 1rem)}.cell-content--progress{width:100%;min-width:4rem}.cell-content--sparkline{display:flex;align-items:center;justify-content:center;min-width:3rem}:host(.positive){color:var(--snice-color-success,rgb(22 163 74))}:host(.negative){color:var(--snice-color-danger,rgb(220 38 38))}:host(.warning){color:var(--snice-color-warning,rgb(234 179 8));background-color:rgb(254 249 195 / .3)}:host(.danger){color:var(--snice-color-danger,rgb(220 38 38));background-color:rgb(254 226 226 / .3)}:host(.success){color:var(--snice-color-success,rgb(22 163 74));background-color:rgb(220 252 231 / .3)}:host(.info){color:var(--snice-color-primary,rgb(37 99 235));background-color:rgb(219 234 254 / .3)}:host(.date--today){font-weight:var(--snice-font-weight-semibold,600);color:var(--snice-color-primary,rgb(37 99 235))}:host(.date--past){color:var(--snice-color-text-secondary,rgb(82 82 82))}:host(.date--future){color:var(--snice-color-success,rgb(22 163 74))}:host(.number--negative.number--negative-red){color:var(--snice-color-danger,rgb(220 38 38))}:host(.number--positive.number--highlighted){color:var(--snice-color-success,rgb(22 163 74));font-weight:var(--snice-font-weight-semibold,600)}:host(.number--zero){color:var(--snice-color-text-secondary,rgb(82 82 82))}:host([truncate]) .cell-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host([wrap]) .cell-content{white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word}:host(:not([value])) .cell-content,:host([value=\"\"]) .cell-content{color:var(--snice-color-text-secondary,rgb(82 82 82))}:host(.loading){position:relative;overflow:hidden}:host(.loading) .cell-content{opacity:.6}:host(.loading)::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent,var(--snice-color-surface,rgb(255 255 255 / .6)),transparent);animation:1.5s infinite cell-shimmer}@keyframes cell-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}:host(:focus-within){outline:var(--snice-focus-ring-width,2px) solid var(--snice-focus-ring-color,rgb(37 99 235 / .5));outline-offset:-2px}.cell-content button,.cell-content input,.cell-content select{font-size:inherit;line-height:inherit}.cell-content a{color:var(--snice-color-primary,rgb(37 99 235));text-decoration:none}.cell-content a:hover{text-decoration:underline}@media (max-width:768px){:host{font-size:.75rem;line-height:1rem}:host([type=boolean]){font-size:.875rem}}@media (prefers-reduced-motion:reduce){:host(.loading)::after{animation:none}}@media (prefers-contrast:high){:host(.positive){background-color:rgb(220 252 231 / .3)}:host(.negative){background-color:rgb(254 226 226 / .3)}.cell-content a{text-decoration:underline}}@media print{:host{font-size:.75rem}:host(.loading)::after{display:none}.cell-content a{text-decoration:underline}}";const ae=["backgroundColor","color","fontWeight","fontStyle","fontSize","textDecoration"],se=new WeakMap,ne=new WeakMap;function le(e,t=!1){if(se.has(e))return;let i=null,a=!1;const s=()=>{if(!a){a=!0,i?.disconnect();try{const i=e.column;for(const t of ne.get(e)||[])e.classList.remove(t);ne.set(e,[]);for(const t of ae)e.style[t]="";if(e.removeAttribute("title"),!i)return;const a=t=>{if(t)for(const i of ae){const a=t[i];a&&(e.style[i]=a)}};a(i.style);for(const t of i.conditionalFormats||[])if(t.condition(e.value,e.rowData)){a(t.style),t.className&&(e.classList.add(t.className),ne.set(e,[t.className]));break}if(i.tooltip&&(e.title="function"==typeof i.tooltip?i.tooltip(e.value,e.rowData):null==e.value?"":String(e.value)),t||i.valueFormatter){const a=t&&i.formatter||i.valueFormatter,s=e.shadowRoot?.querySelector('[part~="content"]');if(a&&s){const t=String(a(e.value,e.rowData)??"");(s.textContent!==t||s.childElementCount>0)&&(s.textContent=t)}}}finally{a=!1,i&&e.shadowRoot&&i.observe(e.shadowRoot,{childList:!0,subtree:!0,characterData:!0})}}};i=new MutationObserver(s),e.shadowRoot&&i.observe(e.shadowRoot,{childList:!0,subtree:!0,characterData:!0}),se.set(e,i),queueMicrotask(s)}function re(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}(()=>{let t,a,c,h,u,p,g,b,f,v,y,x,C,S=[i("snice-cell")],E=[],D=HTMLElement,A=[],R=[],M=[],z=[],$=[],F=[],I=[],T=[],L=[],V=[],B=[],O=[],j=[];(class extends D{static{a=this}static{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(D[Symbol.metadata]??null):void 0;c=[s({})],h=[s({})],u=[s()],p=[s({type:Object,attribute:!1})],g=[s({type:Object,attribute:!1})],b=[n(".cell-content")],f=[l()],v=[r()],y=[o()],x=[d("align")],C=[d("value","column")],w(this,null,f,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:e},null,A),w(this,null,v,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:e},null,A),w(this,null,y,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:e},null,A),w(this,null,x,{kind:"method",name:"updateAlignment",static:!1,private:!1,access:{has:e=>"updateAlignment"in e,get:e=>e.updateAlignment},metadata:e},null,A),w(this,null,C,{kind:"method",name:"updateContent",static:!1,private:!1,access:{has:e=>"updateContent"in e,get:e=>e.updateContent},metadata:e},null,A),w(null,null,c,{kind:"field",name:"align",static:!1,private:!1,access:{has:e=>"align"in e,get:e=>e.align,set:(e,t)=>{e.align=t}},metadata:e},R,M),w(null,null,h,{kind:"field",name:"type",static:!1,private:!1,access:{has:e=>"type"in e,get:e=>e.type,set:(e,t)=>{e.type=t}},metadata:e},z,$),w(null,null,u,{kind:"field",name:"value",static:!1,private:!1,access:{has:e=>"value"in e,get:e=>e.value,set:(e,t)=>{e.value=t}},metadata:e},F,I),w(null,null,p,{kind:"field",name:"column",static:!1,private:!1,access:{has:e=>"column"in e,get:e=>e.column,set:(e,t)=>{e.column=t}},metadata:e},T,L),w(null,null,g,{kind:"field",name:"rowData",static:!1,private:!1,access:{has:e=>"rowData"in e,get:e=>e.rowData,set:(e,t)=>{e.rowData=t}},metadata:e},V,B),w(null,null,b,{kind:"field",name:"contentElement",static:!1,private:!1,access:{has:e=>"contentElement"in e,get:e=>e.contentElement,set:(e,t)=>{e.contentElement=t}},metadata:e},O,j),w(null,t={value:a},S,{kind:"class",name:a.name,metadata:e},null,E),a=t.value,e&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e}),k(a,E)}render(){return e`
343
+ `}styles(){return m`${":host([hidden]){display:none}:host{display:block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif)}.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:var(--snice-spacing-2xl,3rem) var(--snice-spacing-xl,2rem);color:var(--snice-color-text-secondary,rgb(82 82 82));animation:snice-empty-in 360ms var(--snice-ease-out,ease) backwards}@keyframes snice-empty-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.empty-state--small{padding:var(--snice-spacing-xl,2rem) var(--snice-spacing-lg,1.5rem)}.empty-state--medium{padding:var(--snice-spacing-2xl,3rem) var(--snice-spacing-xl,2rem)}.empty-state--large{padding:var(--snice-spacing-3xl,4rem) var(--snice-spacing-2xl,2.5rem)}.empty-state__icon-wrapper{display:flex;align-items:center;justify-content:center;margin-bottom:var(--snice-spacing-lg,1.5rem);position:relative;width:calc(var(--snice-font-size-4xl,4rem) * 1.8);height:calc(var(--snice-font-size-4xl,4rem) * 1.8)}.empty-state__icon-wrapper::before{content:'';position:absolute;inset:0;border-radius:50%;border:1px dashed color-mix(in srgb,var(--snice-color-border,#ddd) 70%,transparent);animation:18s linear infinite snice-empty-halo}@keyframes snice-empty-halo{to{transform:rotate(360deg)}}.empty-state__icon{font-size:var(--snice-font-size-4xl, 4rem);opacity:.5;line-height:1}.empty-state__icon svg{width:1em;height:1em;display:block}.empty-state__icon-wrapper ::slotted(*){display:flex;align-items:center;justify-content:center;font-size:var(--snice-font-size-4xl, 4rem);opacity:.5;line-height:1}.empty-state__icon-wrapper ::slotted(svg){width:var(--snice-font-size-4xl,4rem);height:var(--snice-font-size-4xl,4rem)}.empty-state__icon-wrapper ::slotted(img){width:var(--snice-font-size-4xl,4rem);height:var(--snice-font-size-4xl,4rem);object-fit:contain}.empty-state--small .empty-state__icon-wrapper{margin-bottom:var(--snice-spacing-md,1rem);width:calc(var(--snice-font-size-3xl,3rem) * 1.8);height:calc(var(--snice-font-size-3xl,3rem) * 1.8)}.empty-state--small .empty-state__icon{font-size:var(--snice-font-size-3xl, 3rem)}.empty-state--small .empty-state__icon-wrapper ::slotted(*){font-size:var(--snice-font-size-3xl, 3rem)}.empty-state--small .empty-state__icon-wrapper ::slotted(img),.empty-state--small .empty-state__icon-wrapper ::slotted(svg){width:var(--snice-font-size-3xl,3rem);height:var(--snice-font-size-3xl,3rem)}.empty-state--large .empty-state__icon-wrapper{margin-bottom:var(--snice-spacing-xl,2rem);width:calc(var(--snice-font-size-3xl,5rem) * 1.8);height:calc(var(--snice-font-size-3xl,5rem) * 1.8)}.empty-state--large .empty-state__icon{font-size:var(--snice-font-size-3xl, 5rem)}.empty-state--large .empty-state__icon-wrapper ::slotted(*){font-size:var(--snice-font-size-3xl, 5rem)}.empty-state--large .empty-state__icon-wrapper ::slotted(img),.empty-state--large .empty-state__icon-wrapper ::slotted(svg){width:var(--snice-font-size-3xl,5rem);height:var(--snice-font-size-3xl,5rem)}.empty-state__title{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);font-size:var(--snice-heading-lg, 1.25rem);font-weight:var(--snice-font-weight-semibold,600);color:var(--snice-color-text,rgb(23 23 23));margin:0 0 var(--snice-spacing-xs,.5rem) 0}.empty-state--small .empty-state__title{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);font-size:var(--snice-heading-md, 1.125rem);margin-bottom:var(--snice-spacing-2xs,.375rem)}.empty-state--large .empty-state__title{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);font-size:var(--snice-heading-xl, 1.5rem);margin-bottom:var(--snice-spacing-sm,.75rem)}.empty-state__description{font-size:var(--snice-font-size-sm, .875rem);color:var(--snice-color-text-secondary,rgb(82 82 82));margin:0 0 var(--snice-spacing-lg,1.5rem) 0;max-width:32rem;line-height:var(--snice-line-height-normal, 1.5)}.empty-state--small .empty-state__description{font-size:var(--snice-font-size-xs, .8125rem);margin-bottom:var(--snice-spacing-md,1rem)}.empty-state--large .empty-state__description{font-size:var(--snice-font-size-md, 1rem);margin-bottom:var(--snice-spacing-xl,2rem)}.empty-state__action{display:inline-flex;align-items:center;justify-content:center;padding:var(--snice-spacing-xs,.5rem) var(--snice-spacing-md,1rem);font-size:var(--snice-font-size-sm, .875rem);font-weight:var(--snice-font-weight-medium,500);color:var(--snice-color-text-inverse,rgb(250 250 250));background:var(--snice-color-primary,rgb(37 99 235));border:none;border-radius:var(--snice-border-radius-md,.375rem);text-decoration:none;cursor:pointer;transition:background var(--snice-transition-fast, 150ms)}.empty-state__action:hover{background:var(--snice-color-primary-hover,rgb(29 78 216))}.empty-state--small .empty-state__action{padding:var(--snice-spacing-2xs,.375rem) var(--snice-spacing-sm,.75rem);font-size:var(--snice-font-size-xs, .8125rem)}.empty-state--large .empty-state__action{padding:var(--snice-spacing-sm,.625rem) var(--snice-spacing-lg,1.25rem);font-size:var(--snice-font-size-md, 1rem)}.empty-state__extra ::slotted(*){margin-top:var(--snice-spacing-md,1rem)}@media (prefers-reduced-motion:reduce){*{transition-duration:0s!important;animation-duration:0s!important}}"}`}handleActionClick(e){this.actionHref||e.preventDefault(),this.dispatchActionEvent()}dispatchActionEvent(){return{emptyState:this}}constructor(){super(...arguments),this.size=(k(this,C),k(this,S,"medium")),this.icon=(k(this,E),k(this,D,"📭")),this.title=(k(this,A),k(this,R,"No data")),this.description=(k(this,M),k(this,z,"")),this.actionText=(k(this,$),k(this,F,"")),this.actionHref=(k(this,I),k(this,T,"")),k(this,L)}})})();var ie=":host([hidden]){display:none}:host{display:block;width:100%;font-size:.875rem;line-height:1.25rem;color:var(--snice-color-text,rgb(23 23 23))}.cell-content{width:100%;min-height:1.25rem;word-wrap:break-word}:host([align=left]){text-align:left}:host([align=center]){text-align:center}:host([align=right]){text-align:right}:host([type=accounting]),:host([type=currency]),:host([type=fraction]),:host([type=number]),:host([type=percent]),:host([type=scientific]){font-variant-numeric:tabular-nums;text-align:right}:host([type=date]){font-variant-numeric:tabular-nums}:host([type=boolean]){text-align:center;font-size:1rem}.boolean--true{color:var(--snice-color-success,rgb(22 163 74))}.boolean--false{color:var(--snice-color-danger,rgb(220 38 38))}:host([type=rating]){text-align:center}:host([type=sparkline]){text-align:center}.cell-content--text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cell-content--text[data-multiline=true]{white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word}.cell-content--date,.cell-content--number{font-feature-settings:'tnum'}:host([type=boolean]) .cell-content{display:flex;align-items:center;justify-content:center}:host([type=rating]) .cell-content{display:flex;align-items:center;justify-content:center;gap:.125rem;container-type:inline-size}:host([type=rating]) snice-rating{--rating-size:clamp(0.55rem, 16cqi, 1rem)}.cell-content--progress{width:100%;min-width:4rem}.cell-content--sparkline{display:flex;align-items:center;justify-content:center;min-width:3rem}:host(.positive){color:var(--snice-color-success,rgb(22 163 74))}:host(.negative){color:var(--snice-color-danger,rgb(220 38 38))}:host(.warning){color:var(--snice-color-warning,rgb(234 179 8));background-color:rgb(254 249 195 / .3)}:host(.danger){color:var(--snice-color-danger,rgb(220 38 38));background-color:rgb(254 226 226 / .3)}:host(.success){color:var(--snice-color-success,rgb(22 163 74));background-color:rgb(220 252 231 / .3)}:host(.info){color:var(--snice-color-primary,rgb(37 99 235));background-color:rgb(219 234 254 / .3)}:host(.date--today){font-weight:var(--snice-font-weight-semibold,600);color:var(--snice-color-primary,rgb(37 99 235))}:host(.date--past){color:var(--snice-color-text-secondary,rgb(82 82 82))}:host(.date--future){color:var(--snice-color-success,rgb(22 163 74))}:host(.number--negative.number--negative-red){color:var(--snice-color-danger,rgb(220 38 38))}:host(.number--positive.number--highlighted){color:var(--snice-color-success,rgb(22 163 74));font-weight:var(--snice-font-weight-semibold,600)}:host(.number--zero){color:var(--snice-color-text-secondary,rgb(82 82 82))}:host([truncate]) .cell-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host([wrap]) .cell-content{white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word}:host(:not([value])) .cell-content,:host([value=\"\"]) .cell-content{color:var(--snice-color-text-secondary,rgb(82 82 82))}:host(.loading){position:relative;overflow:hidden}:host(.loading) .cell-content{opacity:.6}:host(.loading)::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent,var(--snice-color-surface,rgb(255 255 255 / .6)),transparent);animation:1.5s infinite cell-shimmer}@keyframes cell-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}:host(:focus-within){outline:var(--snice-focus-ring-width,2px) solid var(--snice-focus-ring-color,rgb(37 99 235 / .5));outline-offset:-2px}.cell-content button,.cell-content input,.cell-content select{font-size:inherit;line-height:inherit}.cell-content a{color:var(--snice-color-primary,rgb(37 99 235));text-decoration:none}.cell-content a:hover{text-decoration:underline}@media (max-width:768px){:host{font-size:.75rem;line-height:1rem}:host([type=boolean]){font-size:.875rem}}@media (prefers-reduced-motion:reduce){:host(.loading)::after{animation:none}}@media (prefers-contrast:high){:host(.positive){background-color:rgb(220 252 231 / .3)}:host(.negative){background-color:rgb(254 226 226 / .3)}.cell-content a{text-decoration:underline}}@media print{:host{font-size:.75rem}:host(.loading)::after{display:none}.cell-content a{text-decoration:underline}}";const ae=["backgroundColor","color","fontWeight","fontStyle","fontSize","textDecoration"],se=new WeakMap,ne=new WeakMap;function le(e,t=!1){if(se.has(e))return;let i=null,a=!1;const s=()=>{if(!a){a=!0,i?.disconnect();try{const i=e.column;for(const t of ne.get(e)||[])e.classList.remove(t);ne.set(e,[]);for(const t of ae)e.style[t]="";if(e.removeAttribute("title"),!i)return;const a=t=>{if(t)for(const i of ae){const a=t[i];a&&(e.style[i]=a)}};a(i.style);for(const t of i.conditionalFormats||[])if(t.condition(e.value,e.rowData)){a(t.style),t.className&&(e.classList.add(t.className),ne.set(e,[t.className]));break}i.tooltip&&(e.title="function"==typeof i.tooltip?i.tooltip(e.value,e.rowData):null==e.value?"":String(e.value));const s=i.formatter?t?i.formatter:null:i.valueFormatter,n=e.hasAttribute("formatted")?e.getAttribute("value")??"":s?String(s(e.value,e.rowData)??""):null;if(null!==n){const t=e.shadowRoot?.querySelector('[part~="content"]');t&&(t.textContent!==n||t.childElementCount>0)&&(t.textContent=n)}}finally{a=!1,i&&e.shadowRoot&&i.observe(e.shadowRoot,{childList:!0,subtree:!0,characterData:!0})}}};i=new MutationObserver(s),e.shadowRoot&&i.observe(e.shadowRoot,{childList:!0,subtree:!0,characterData:!0}),se.set(e,i),queueMicrotask(s)}function re(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}(()=>{let t,a,c,h,u,p,g,b,f,v,y,x,C,S=[i("snice-cell")],E=[],D=HTMLElement,A=[],R=[],M=[],z=[],$=[],F=[],I=[],T=[],L=[],V=[],B=[],O=[],j=[];(class extends D{static{a=this}static{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(D[Symbol.metadata]??null):void 0;c=[s({})],h=[s({})],u=[s()],p=[s({type:Object,attribute:!1})],g=[s({type:Object,attribute:!1})],b=[n(".cell-content")],f=[l()],v=[r()],y=[o()],x=[d("align")],C=[d("value","column")],w(this,null,f,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:e},null,A),w(this,null,v,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:e},null,A),w(this,null,y,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:e},null,A),w(this,null,x,{kind:"method",name:"updateAlignment",static:!1,private:!1,access:{has:e=>"updateAlignment"in e,get:e=>e.updateAlignment},metadata:e},null,A),w(this,null,C,{kind:"method",name:"updateContent",static:!1,private:!1,access:{has:e=>"updateContent"in e,get:e=>e.updateContent},metadata:e},null,A),w(null,null,c,{kind:"field",name:"align",static:!1,private:!1,access:{has:e=>"align"in e,get:e=>e.align,set:(e,t)=>{e.align=t}},metadata:e},R,M),w(null,null,h,{kind:"field",name:"type",static:!1,private:!1,access:{has:e=>"type"in e,get:e=>e.type,set:(e,t)=>{e.type=t}},metadata:e},z,$),w(null,null,u,{kind:"field",name:"value",static:!1,private:!1,access:{has:e=>"value"in e,get:e=>e.value,set:(e,t)=>{e.value=t}},metadata:e},F,I),w(null,null,p,{kind:"field",name:"column",static:!1,private:!1,access:{has:e=>"column"in e,get:e=>e.column,set:(e,t)=>{e.column=t}},metadata:e},T,L),w(null,null,g,{kind:"field",name:"rowData",static:!1,private:!1,access:{has:e=>"rowData"in e,get:e=>e.rowData,set:(e,t)=>{e.rowData=t}},metadata:e},V,B),w(null,null,b,{kind:"field",name:"contentElement",static:!1,private:!1,access:{has:e=>"contentElement"in e,get:e=>e.contentElement,set:(e,t)=>{e.contentElement=t}},metadata:e},O,j),w(null,t={value:a},S,{kind:"class",name:a.name,metadata:e},null,E),a=t.value,e&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e}),k(a,E)}render(){return e`
344
344
  <div class="cell-content" part="content">
345
345
  ${this.formatValue()}
346
346
  </div>
@@ -571,7 +571,7 @@ import{html as e,unsafeHTML as t,element as i,state as a,property as s,query as
571
571
  </if>
572
572
  </div>
573
573
  </div>
574
- `}styles(){return m`${":host([hidden]){display:none}:host{display:block;width:100%;min-height:2.5rem}.row-container{display:flex;align-items:stretch;width:100%;min-height:2.5rem;background:0 0;color:var(--snice-color-text,rgb(23 23 23));border-bottom:1px solid var(--snice-color-border,rgb(226 226 226));transition:background-color .15s}.cell{display:flex;align-items:center;border-right:1px solid var(--snice-color-border,rgb(226 226 226));min-height:2.5rem;min-width:6.25rem;flex:1;word-wrap:break-word;overflow:hidden;color:var(--snice-color-text,rgb(23 23 23))}.cell:last-child{border-right:none}.cell--checkbox{width:3rem;min-width:3rem;max-width:3rem;padding:.75rem;justify-content:center}.row-checkbox{width:1rem;height:1rem;cursor:pointer;margin:0;display:block;accent-color:var(--snice-color-primary,rgb(37 99 235))}.cells-container{display:flex;flex:1;align-items:stretch}.cell--text{text-align:left}.cell--accounting,.cell--currency,.cell--fraction,.cell--number,.cell--percent,.cell--scientific{text-align:right;font-variant-numeric:tabular-nums}.cell--date{min-width:8rem;font-variant-numeric:tabular-nums}.cell--boolean{text-align:center;font-size:1rem}.cell--rating{text-align:center;min-width:6rem}.cell--progress{min-width:8rem}.cell--sparkline{text-align:center;min-width:6rem}.cell--duration,.cell--filesize{text-align:right;font-variant-numeric:tabular-nums}:host(.row--hoverable) .row-container:hover{background-color:var(--snice-color-surface-hover,rgb(243 244 246))}:host(.row--clickable) .row-container{cursor:pointer}:host(.row--clickable) .row-container:hover{background-color:var(--snice-color-surface-hover,rgb(243 244 246))}:host(.row--selected) .row-container{background-color:var(--snice-color-primary-subtle,rgb(239 246 255));box-shadow:inset 2px 0 0 0 var(--snice-color-primary,rgb(37 99 235))}:host(.row--selected.row--hoverable) .row-container:hover{background-color:var(--snice-color-primary-subtle-hover,var(--snice-color-primary-subtle,rgb(219 234 254)))}:host(.row--highlighted) .row-container{background-color:var(--snice-color-warning-subtle,rgb(254 249 195))!important;animation:2s ease-out row-highlight-fade}@keyframes row-highlight-fade{0%{background-color:var(--snice-color-warning-subtle-hover,rgb(254 252 232))}100%{background-color:var(--snice-color-warning-subtle,rgb(254 249 195))}}:host(:focus) .row-container{outline:var(--snice-focus-ring-width,2px) solid var(--snice-focus-ring-color,rgb(37 99 235 / .5));outline-offset:-2px}:host(.row--selectable){tabindex:0}:host(.row--striped) .row-container{background-color:var(--snice-color-surface-container-low,rgb(245 245 245))}:host(.row--bordered) .row-container{border-bottom:1px solid var(--snice-color-border,rgb(226 226 226))}:host(.row--small) .cell{padding:.5rem .75rem;min-height:2rem;font-size:.75rem}:host(.row--small) .row-container{min-height:2rem}:host(.row--large) .cell{padding:1rem 1.25rem;min-height:3.5rem;font-size:1rem}:host(.row--large) .row-container{min-height:3.5rem}@media (max-width:768px){.cell{padding:.5rem .75rem;font-size:.875rem}.cell--checkbox{width:2.5rem;min-width:2.5rem;max-width:2.5rem;padding:.5rem}.row-checkbox{width:.875rem;height:.875rem}}:host(.row--loading) .row-container{opacity:.6;pointer-events:none}:host(.row--loading) .row-container::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent,var(--snice-color-surface,rgb(255 255 255 / .6)),transparent);animation:1.5s infinite loading-shimmer}@keyframes loading-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}@media (prefers-reduced-motion:reduce){.row-container{transition:none}:host(.row--highlighted) .row-container{animation:none;background-color:var(--snice-color-warning-subtle,rgb(254 249 195))!important}:host(.row--loading) .row-container::after{animation:none}}@media (prefers-contrast:high){.cell{border-right:1px solid}.row-container{border-bottom:1px solid}:host(.row--selected) .row-container{border:2px solid}}"}`}init(){this.data&&0!==Object.keys(this.data).length||(this.data=this.extractDataFromAttributes()),this.updateRowAttributes(),this.configureCells()}configureCells(){this.columns&&this.columns.forEach((e,t)=>{const i=this.shadowRoot?.querySelector(`[data-column-index="${t}"]`);if(i){const a=this.data[e.key];if("function"==typeof e.renderCell){const s=e.renderCell(a,this.data,e),n=s instanceof HTMLElement?s:document.createElement("span");return s instanceof HTMLElement||(n.textContent=null==s?"":String(s)),n.setAttribute("data-column-index",String(t)),i.replaceWith(n),void this.applyCellPresentation(n.parentElement,e,a)}const s=e.formatter||e.valueFormatter;i.value=s?s(a,this.data):a,i.column=s?{...e,type:"text",formatter:void 0,valueFormatter:void 0}:e,i.rowData=this.data,this.applyCellPresentation(i.parentElement,e,a),"sparkline"===e.type&&Array.isArray(a)&&(i.data=a)}})}updateSelection(){this.updateRowAttributes();const e=this.shadowRoot?.querySelector(".row-checkbox");e&&(e.checked=this.selected)}updateRowAttributes(){this.classList.toggle("row--hoverable",this.hoverable),this.classList.toggle("row--clickable",this.clickable),this.classList.toggle("row--selectable",this.selectable),this.classList.toggle("row--selection-disabled",this.selectionDisabled),this.classList.toggle("row--selected",this.selected)}updateCells(){setTimeout(()=>this.configureCells(),0)}handleRowClick(e){const t=e.target;t.matches(".row-checkbox")||t.matches("button, a, .interactive")||(this.clickable&&this.dispatchRowClick(),this.selectable&&!this.selectionDisabled&&this.toggleSelection())}handleChange(e){const t=e.target;if(!t.matches(".row-checkbox"))return;const i=t;this.selectionDisabled?i.checked=this.selected:(this.selected=i.checked,this.dispatchRowSelect())}handleKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.selectable&&!this.selectionDisabled?this.toggleSelection():this.clickable&&this.dispatchRowClick())}handleRowHover(){this.dispatchRowHover()}renderCheckbox(){return e`
574
+ `}styles(){return m`${":host([hidden]){display:none}:host{display:block;width:100%;min-height:2.5rem}.row-container{display:flex;align-items:stretch;width:100%;min-height:2.5rem;background:0 0;color:var(--snice-color-text,rgb(23 23 23));border-bottom:1px solid var(--snice-color-border,rgb(226 226 226));transition:background-color .15s}.cell{display:flex;align-items:center;border-right:1px solid var(--snice-color-border,rgb(226 226 226));min-height:2.5rem;min-width:6.25rem;flex:1;word-wrap:break-word;overflow:hidden;color:var(--snice-color-text,rgb(23 23 23))}.cell:last-child{border-right:none}.cell--checkbox{width:3rem;min-width:3rem;max-width:3rem;padding:.75rem;justify-content:center}.row-checkbox{width:1rem;height:1rem;cursor:pointer;margin:0;display:block;accent-color:var(--snice-color-primary,rgb(37 99 235))}.cells-container{display:flex;flex:1;align-items:stretch}.cell--text{text-align:left}.cell--accounting,.cell--currency,.cell--fraction,.cell--number,.cell--percent,.cell--scientific{text-align:right;font-variant-numeric:tabular-nums}.cell--date{min-width:8rem;font-variant-numeric:tabular-nums}.cell--boolean{text-align:center;font-size:1rem}.cell--rating{text-align:center;min-width:6rem}.cell--progress{min-width:8rem}.cell--sparkline{text-align:center;min-width:6rem}.cell--duration,.cell--filesize{text-align:right;font-variant-numeric:tabular-nums}:host(.row--hoverable) .row-container:hover{background-color:var(--snice-color-surface-hover,rgb(243 244 246))}:host(.row--clickable) .row-container{cursor:pointer}:host(.row--clickable) .row-container:hover{background-color:var(--snice-color-surface-hover,rgb(243 244 246))}:host(.row--selected) .row-container{background-color:var(--snice-color-primary-subtle,rgb(239 246 255));box-shadow:inset 2px 0 0 0 var(--snice-color-primary,rgb(37 99 235))}:host(.row--selected.row--hoverable) .row-container:hover{background-color:var(--snice-color-primary-subtle-hover,var(--snice-color-primary-subtle,rgb(219 234 254)))}:host(.row--highlighted) .row-container{background-color:var(--snice-color-warning-subtle,rgb(254 249 195))!important;animation:2s ease-out row-highlight-fade}@keyframes row-highlight-fade{0%{background-color:var(--snice-color-warning-subtle-hover,rgb(254 252 232))}100%{background-color:var(--snice-color-warning-subtle,rgb(254 249 195))}}:host(:focus) .row-container{outline:var(--snice-focus-ring-width,2px) solid var(--snice-focus-ring-color,rgb(37 99 235 / .5));outline-offset:-2px}:host(.row--selectable){tabindex:0}:host(.row--striped) .row-container{background-color:var(--snice-color-surface-container-low,rgb(245 245 245))}:host(.row--bordered) .row-container{border-bottom:1px solid var(--snice-color-border,rgb(226 226 226))}:host(.row--small) .cell{padding:.5rem .75rem;min-height:2rem;font-size:.75rem}:host(.row--small) .row-container{min-height:2rem}:host(.row--large) .cell{padding:1rem 1.25rem;min-height:3.5rem;font-size:1rem}:host(.row--large) .row-container{min-height:3.5rem}@media (max-width:768px){.cell{padding:.5rem .75rem;font-size:.875rem}.cell--checkbox{width:2.5rem;min-width:2.5rem;max-width:2.5rem;padding:.5rem}.row-checkbox{width:.875rem;height:.875rem}}:host(.row--loading) .row-container{opacity:.6;pointer-events:none}:host(.row--loading) .row-container::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent,var(--snice-color-surface,rgb(255 255 255 / .6)),transparent);animation:1.5s infinite loading-shimmer}@keyframes loading-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}@media (prefers-reduced-motion:reduce){.row-container{transition:none}:host(.row--highlighted) .row-container{animation:none;background-color:var(--snice-color-warning-subtle,rgb(254 249 195))!important}:host(.row--loading) .row-container::after{animation:none}}@media (prefers-contrast:high){.cell{border-right:1px solid}.row-container{border-bottom:1px solid}:host(.row--selected) .row-container{border:2px solid}}"}`}init(){this.data&&0!==Object.keys(this.data).length||(this.data=this.extractDataFromAttributes()),this.updateRowAttributes(),this.configureCells()}cellValue(e){const t=this.data?.[e.key];return e.valueGetter?e.valueGetter(t,this.data):t}configureCells(){this.columns&&this.columns.forEach((e,t)=>{const i=this.shadowRoot?.querySelector(`[data-column-index="${t}"]`);if(i){const a=this.cellValue(e);if("function"==typeof e.renderCell){const s=e.renderCell(a,this.data,e),n=s instanceof HTMLElement?s:document.createElement("span");return s instanceof HTMLElement||(n.textContent=null==s?"":String(s)),n.setAttribute("data-column-index",String(t)),i.replaceWith(n),void this.applyCellPresentation(n.parentElement,e,a)}const s=e.formatter||e.valueFormatter;i.value=s?String(s(a,this.data)??""):a,i.column=s?{...e,type:"text",formatter:void 0,valueFormatter:void 0}:e,i.rowData=this.data,this.applyCellPresentation(i.parentElement,e,a),"sparkline"===e.type&&Array.isArray(a)&&(i.data=a)}})}updateSelection(){this.updateRowAttributes();const e=this.shadowRoot?.querySelector(".row-checkbox");e&&(e.checked=this.selected)}updateRowAttributes(){this.classList.toggle("row--hoverable",this.hoverable),this.classList.toggle("row--clickable",this.clickable),this.classList.toggle("row--selectable",this.selectable),this.classList.toggle("row--selection-disabled",this.selectionDisabled),this.classList.toggle("row--selected",this.selected)}updateCells(){setTimeout(()=>this.configureCells(),0)}handleRowClick(e){const t=e.target;t.matches(".row-checkbox")||t.matches("button, a, .interactive")||(this.clickable&&this.dispatchRowClick(),this.selectable&&!this.selectionDisabled&&this.toggleSelection())}handleChange(e){const t=e.target;if(!t.matches(".row-checkbox"))return;const i=t;this.selectionDisabled?i.checked=this.selected:(this.selected=i.checked,this.dispatchRowSelect())}handleKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.selectable&&!this.selectionDisabled?this.toggleSelection():this.clickable&&this.dispatchRowClick())}handleRowHover(){this.dispatchRowHover()}renderCheckbox(){return e`
575
575
  <div class="cell cell--checkbox" part="checkbox-cell">
576
576
  <input
577
577
  type="checkbox"
@@ -586,7 +586,7 @@ import{html as e,unsafeHTML as t,element as i,state as a,property as s,query as
586
586
  <div class="cell cell--${i.type}" part="cell" style="${this.getCellStyles(i)}">
587
587
  ${t(`<${s}\n type="${i.type}"\n align="${i.align||this.getDefaultAlign(i.type)}"\n data-column-index="${a}"\n ></${s}>`)}
588
588
  </div>
589
- `}getDefaultAlign(e){return["number","currency","percent","percentage","duration","filesize","accounting","scientific","fraction"].includes(e||"")?"right":["boolean","rating","image"].includes(e||"")?"center":"left"}applyCellPresentation(e,t,i){if(!e)return;const a=t=>{t&&Object.assign(e.style,t)};a(t.style);for(const s of t.conditionalFormats||[])if(s.condition(i,this.data)){a(s.style),s.className&&e.classList.add(s.className);break}t.tooltip&&(e.title="function"==typeof t.tooltip?t.tooltip(i,this.data):null==i?"":String(i))}getCellComponent(e){switch(e){case"text":return"snice-cell-text";case"number":case"accounting":case"scientific":case"fraction":return"snice-cell-number";case"date":return"snice-cell-date";case"boolean":return"snice-cell-boolean";case"sparkline":return"snice-cell-sparkline";case"rating":return"snice-cell-rating";case"progress":return"snice-cell-progress";case"duration":return"snice-cell-duration";case"filesize":return"snice-cell-filesize";case"link":case"url":return"snice-cell-link";case"actions":return"snice-cell-actions";case"tag":case"tags":case"badge":case"badges":return"snice-cell-tag";case"image":case"avatar":case"thumbnail":return"snice-cell-image";case"email":return"snice-cell-email";case"phone":case"tel":case"telephone":return"snice-cell-phone";case"status":return"snice-cell-status";case"color":return"snice-cell-color";case"json":case"object":return"snice-cell-json";case"currency":case"money":return"snice-cell-currency";case"percent":case"percentage":return"snice-cell-percentage";case"location":case"address":case"coordinates":return"snice-cell-location";default:return"snice-cell"}}getCellStyles(e){let t=[];return e.width&&(t.push(`width: ${e.width}`),t.push(`min-width: ${e.width}`),t.push(`max-width: ${e.width}`)),e.align&&t.push(`text-align: ${e.align}`),t.join("; ")}escapeHtml(e){if(null==e)return"";const t=String(e),i=document.createElement("div");return i.textContent=t,i.innerHTML}toggleSelection(){this.selected=!this.selected,this.dispatchRowSelect()}dispatchRowClick(){return{data:this.data,index:this.index,element:this}}dispatchRowSelect(){return{selected:this.selected,data:this.data,index:this.index,element:this}}dispatchRowHover(){return{data:this.data,index:this.index,element:this}}select(){!this.selectionDisabled&&this.selectable&&(this.selected=!0,this.dispatchRowSelect())}deselect(){this.selected=!1,this.dispatchRowSelect()}focusRow(){super.focus(),this.scrollIntoView({behavior:"smooth",block:"nearest"})}getCellValue(e){return this.data[e]}setCellValue(e,t){this.data={...this.data,[e]:t},this.updateCells()}getCellElement(e){const t=this.columns.find(t=>t.key===e);if(!t)return null;const i=this.columns.indexOf(t);return this.shadowRoot?.querySelector(`[data-column-index="${i}"]`)||null}highlight(e=2e3){this.classList.add("row--highlighted"),setTimeout(()=>{this.classList.remove("row--highlighted")},e)}constructor(){super(...arguments),this.selected=(k(this,V),k(this,B,!1)),this.hoverable=(k(this,O),k(this,j,!0)),this.clickable=(k(this,N),k(this,P,!1)),this.selectable=(k(this,H),k(this,q,!1)),this.selectionDisabled=(k(this,_),k(this,G,!1)),this.data=(k(this,K),k(this,W,{})),this.index=(k(this,U),k(this,Z,0)),this.columns=(k(this,Y),k(this,J,[])),k(this,Q)}})})();class oe{constructor(){this.rafId=0,this.lastStartIndex=-1,this.lastEndIndex=-1,this.enabled=!1,this.offsets=[],this.offsetsTotalRows=-1,this.topSpacer=document.createElement("tr"),this.topSpacer.className="virtual-spacer virtual-spacer--top",this.topSpacer.style.display="table-row",this.bottomSpacer=document.createElement("tr"),this.bottomSpacer.className="virtual-spacer virtual-spacer--bottom",this.bottomSpacer.style.display="table-row",this.contentContainer=document.createElement("tbody"),this.options={},this.scrollHandler=()=>{this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>this.update())}}attach(e){this.options=e,this.enabled=!0,this.lastStartIndex=-1,this.lastEndIndex=-1,this.invalidateOffsets(),this.options.scrollContainer.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),this.update()}detach(){this.enabled=!1,this.options.scrollContainer?.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("resize",this.scrollHandler),cancelAnimationFrame(this.rafId)}setTotalRows(e){this.options.totalRows=e,this.invalidateOffsets(),this.lastStartIndex=-1,this.update()}refresh(){this.invalidateOffsets(),this.lastStartIndex=-1,this.lastEndIndex=-1,this.update()}update(){if(!this.enabled||!this.options.scrollContainer)return;const{bufferPx:e,totalRows:t,scrollContainer:i,renderRange:a}=this.options,s=i.scrollTop,n=this.buildOffsets(t),l=t>0?Math.max(1,n[1]-n[0]):1,r=Math.max(l,i.clientHeight),o=n[t]||0,c=Math.max(0,o-r),d=Math.min(Math.max(0,s),c);s!==d&&(i.scrollTop=d);const h=Math.max(0,d-e),u=Math.min(o,d+r+e),m=this.findRowAtOffset(n,h),p=Math.min(t,this.findFirstOffsetAtOrAfter(n,u));if(m===this.lastStartIndex&&p===this.lastEndIndex)return;this.lastStartIndex=m,this.lastEndIndex=p;const g=n[m]||0,b=Math.max(0,o-(n[p]||o));this.topSpacer.style.height=`${g}px`,this.bottomSpacer.style.height=`${b}px`;const f=a(m,p),v=this.options.scrollContainer.querySelector("tbody");if(v){v.innerHTML="";const e=this.options.renderPinnedTop?.();if(e&&v.appendChild(e),g>0){const e=document.createElement("td");e.colSpan=999,e.style.height=`${g}px`,e.style.padding="0",e.style.border="none",this.topSpacer.innerHTML="",this.topSpacer.appendChild(e),v.appendChild(this.topSpacer)}if(v.appendChild(f),b>0){const e=document.createElement("td");e.colSpan=999,e.style.height=`${b}px`,e.style.padding="0",e.style.border="none",this.bottomSpacer.innerHTML="",this.bottomSpacer.appendChild(e),v.appendChild(this.bottomSpacer)}const t=this.options.renderPinnedBottom?.();t&&v.appendChild(t),this.options.afterRender?.()}}getVisibleRange(){return{start:this.lastStartIndex,end:this.lastEndIndex}}scrollToRow(e){if(!this.options.scrollContainer)return;const t=this.offsetForIndex(e);this.options.scrollContainer.scrollTop=t}scrollToIndex(e){this.options.scrollContainer&&(this.options.scrollContainer.scrollTop=this.offsetForIndex(e),this.refresh())}getScrollPosition(){const e=this.options.scrollContainer;return{top:e?.scrollTop??0,left:e?.scrollLeft??0}}isEnabled(){return this.enabled}heightForIndex(e){const t="function"==typeof this.options.rowHeight?this.options.rowHeight(e):this.options.rowHeight;return Number.isFinite(t)&&t>0?t:1}buildOffsets(e){if(this.offsetsTotalRows===e&&this.offsets.length===e+1)return this.offsets;this.offsets=new Array(e+1),this.offsets[0]=0;for(let t=0;t<e;t++)this.offsets[t+1]=this.offsets[t]+this.heightForIndex(t);return this.offsetsTotalRows=e,this.offsets}invalidateOffsets(){this.offsets=[],this.offsetsTotalRows=-1}offsetForIndex(e){const t=Math.max(0,Math.min(e,this.options.totalRows));return this.buildOffsets(this.options.totalRows)[t]||0}findRowAtOffset(e,t){const i=e.length-1;if(i<=0)return 0;let a=0,s=i;for(;a<s;){const i=Math.floor((a+s)/2);e[i+1]<=t?a=i+1:s=i}return Math.min(i,a)}findFirstOffsetAtOrAfter(e,t){let i=0,a=e.length-1;for(;i<a;){const s=Math.floor((i+a)/2);e[s]<t?i=s+1:a=s}return i}}class ce{constructor(){this.states=new Map,this.groups=[],this.resizeStartX=0,this.resizeStartWidth=0,this.resizingKey=null,this.resizeOverlay=null,this.tableElement=null}initialize(e,t){this.tableElement=t,e.forEach((e,t)=>{const i=this.states.get(e.key);this.states.set(e.key,{key:e.key,width:i?.width??this.parseWidth(e.width)??150,flex:e.flex,minWidth:e.minWidth??50,maxWidth:e.maxWidth??1/0,visible:i?.visible??!0,pinned:i?.pinned??(e.pinned||!1),order:i?.order??t,resizable:!1!==e.resizable,reorderable:!1!==e.reorderable,hideable:!1!==e.hideable,pinnable:!1!==e.pinnable})})}parseWidth(e){if(!e)return;const t=parseInt(e,10);return isNaN(t)?void 0:t}getVisibleColumns(){return Array.from(this.states.values()).filter(e=>e.visible).sort((e,t)=>e.order-t.order)}getAllStates(){return Array.from(this.states.values()).sort((e,t)=>e.order-t.order)}getPinnedLeft(){return this.getVisibleColumns().filter(e=>"left"===e.pinned)}getPinnedRight(){return this.getVisibleColumns().filter(e=>"right"===e.pinned)}getUnpinned(){return this.getVisibleColumns().filter(e=>!e.pinned)}computeFlexWidths(e){const t=this.getVisibleColumns(),i=new Map;let a=0;const s=[];for(const e of t)e.flex&&e.flex>0?s.push(e):(a+=e.width,i.set(e.key,e.width));const n=Math.max(0,e-a),l=s.reduce((e,t)=>e+(t.flex||1),0);for(const e of s){const t=Math.max(e.minWidth,Math.min(e.maxWidth,(e.flex||1)/l*n));i.set(e.key,t)}return i}applyWidths(e,t){e.querySelectorAll("th[data-key]").forEach(e=>{const i=e.getAttribute("data-key");i&&t.has(i)&&(e.style.width=`${t.get(i)}px`)})}startResize(e,t){const i=this.states.get(e);if(!i||!i.resizable)return;this.resizingKey=e,this.resizeStartX=t,this.resizeStartWidth=i.width,this.resizeOverlay=document.createElement("div"),this.resizeOverlay.style.cssText="position:fixed;inset:0;z-index:99999;cursor:col-resize;",document.body.appendChild(this.resizeOverlay);const a=t=>{t.preventDefault();const a=Math.max(i.minWidth,Math.min(i.maxWidth,this.resizeStartWidth+(t.clientX-this.resizeStartX)));i.width=a,i.flex=void 0;const s=this.tableElement?.shadowRoot;if(s){const t=s.querySelector(`th[data-key="${e}"]`);t&&(t.style.width=`${a}px`),s.querySelectorAll(`td[data-key="${e}"]`).forEach(e=>e.style.width=`${a}px`)}this.tableElement?.dispatchEvent(new CustomEvent("column-resize",{detail:{key:e,width:a},bubbles:!0,composed:!0}))},s=()=>{this.resizingKey=null,this.resizeOverlay?.remove(),this.resizeOverlay=null,document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",s),this.tableElement?.dispatchEvent(new CustomEvent("column-resize-end",{detail:{key:e,width:i.width},bubbles:!0,composed:!0}))};document.addEventListener("mousemove",a),document.addEventListener("mouseup",s)}autoSizeColumn(e,t){const i=this.states.get(e);if(!i)return;const a=this.tableElement?.shadowRoot?.querySelector(`th[data-key="${e}"]`);let s=a?a.scrollWidth:0;t.querySelectorAll(`td[data-key="${e}"]`).forEach(e=>{s=Math.max(s,e.scrollWidth)}),i.width=Math.max(i.minWidth,Math.min(i.maxWidth,s+16)),i.flex=void 0}autoSizeAll(e){for(const t of this.states.keys())this.autoSizeColumn(t,e)}setColumnVisible(e,t){const i=this.states.get(e);i&&i.hideable&&(i.visible=t)}showAllColumns(){for(const e of this.states.values())e.visible=!0}hideAllColumns(){for(const e of this.states.values())e.hideable&&(e.visible=!1)}getVisibilityModel(){const e={};for(const[t,i]of this.states)e[t]=i.visible;return e}moveColumn(e,t){const i=this.states.get(e);if(!i||!i.reorderable||i.pinned)return;const a=this.getVisibleColumns(),s=a.findIndex(t=>t.key===e);-1!==s&&s!==t&&(a.splice(s,1),a.splice(t,0,i),a.forEach((e,t)=>{e.order=t}))}pinColumn(e,t){const i=this.states.get(e);i&&i.pinnable&&(i.pinned=t)}unpinColumn(e){const t=this.states.get(e);t&&(t.pinned=!1)}setColumnGroups(e){this.groups=e}getColumnGroups(){return this.groups}renderGroupHeaders(e=this.getVisibleColumns().map(e=>e.key)){if(0===this.groups.length)return"";const t=new Map;for(const e of this.groups)for(const i of e.children)t.set(i,e);const i=[];for(const a of e){if(!this.states.get(a)?.visible)continue;const e=t.get(a)??null,s=i[i.length-1];s&&s.group===e?s.span++:i.push({group:e,span:1})}return i.map(({group:e,span:t})=>e?`<th colspan="${t}" class="column-group-header ${e.headerClass||""}">${e.label}</th>`:`<th colspan="${t}" class="column-group-header column-group-header--ungrouped" aria-hidden="true"></th>`).join("")}isResizing(){return null!==this.resizingKey}getState(e){return this.states.get(e)}getPinnedLeftOffsets(){const e=new Map;let t=0;for(const i of this.getPinnedLeft())e.set(i.key,t),t+=i.width;return e}getPinnedRightOffsets(){const e=new Map,t=this.getPinnedRight();let i=0;for(let a=t.length-1;a>=0;a--)e.set(t[a].key,i),i+=t[a].width;return e}}const de=[{value:"contains",label:"contains",requiresValue:!0},{value:"notContains",label:"does not contain",requiresValue:!0},{value:"equals",label:"equals",requiresValue:!0},{value:"notEquals",label:"does not equal",requiresValue:!0},{value:"startsWith",label:"starts with",requiresValue:!0},{value:"endsWith",label:"ends with",requiresValue:!0},{value:"isEmpty",label:"is empty",requiresValue:!1},{value:"isNotEmpty",label:"is not empty",requiresValue:!1}],he=[{value:"eq",label:"=",requiresValue:!0},{value:"neq",label:"≠",requiresValue:!0},{value:"gt",label:">",requiresValue:!0},{value:"gte",label:"≥",requiresValue:!0},{value:"lt",label:"<",requiresValue:!0},{value:"lte",label:"≤",requiresValue:!0},{value:"isEmpty",label:"is empty",requiresValue:!1},{value:"isNotEmpty",label:"is not empty",requiresValue:!1}],ue=[{value:"is",label:"is",requiresValue:!0},{value:"isNot",label:"is not",requiresValue:!0},{value:"before",label:"before",requiresValue:!0},{value:"onOrBefore",label:"on or before",requiresValue:!0},{value:"after",label:"after",requiresValue:!0},{value:"onOrAfter",label:"on or after",requiresValue:!0},{value:"isEmpty",label:"is empty",requiresValue:!1},{value:"isNotEmpty",label:"is not empty",requiresValue:!1}],me=[{value:"isTrue",label:"is true",requiresValue:!1},{value:"isFalse",label:"is false",requiresValue:!1}];class pe{constructor(){this.model={filters:[],logic:"and"},this.headerFilters=new Map}getOperatorsForType(e){switch(e){case"number":case"currency":case"rating":case"progress":case"filesize":case"duration":case"percent":case"percentage":return he;case"date":return ue;case"boolean":return me;default:return de}}setFilterModel(e){this.model=e}getFilterModel(){return{...this.model}}setColumnFilter(e,t,i){const a=this.model.filters.findIndex(t=>t.column===e);a>=0?this.model.filters[a]={column:e,operator:t,value:i}:this.model.filters.push({column:e,operator:t,value:i})}removeColumnFilter(e){this.model.filters=this.model.filters.filter(t=>t.column!==e)}clearAllFilters(){this.model.filters=[],this.model.quickFilter=void 0,this.model.logic="and",this.headerFilters.clear()}setQuickFilter(e){this.model.quickFilter=e||void 0}setHeaderFilter(e,t){t?this.headerFilters.set(e,t):this.headerFilters.delete(e)}getHeaderFilter(e){return this.headerFilters.get(e)||""}setFilterLogic(e){this.model.logic=e}hasActiveFilters(){return this.model.filters.length>0||!!this.model.quickFilter||this.headerFilters.size>0}hasColumnFilter(e){return this.model.filters.some(t=>t.column===e)||this.headerFilters.has(e)}getActiveFilterCount(){return this.model.filters.length+this.headerFilters.size+(this.model.quickFilter?1:0)}applyFilters(e,t){let i=e;this.model.filters.length>0&&(i=i.filter(e=>{const t=this.model.filters.map(t=>this.evaluateFilter(t,e));return"and"===this.model.logic?t.every(Boolean):t.some(Boolean)}));for(const[e,t]of this.headerFilters){const a=t.toLowerCase();i=i.filter(t=>{const i=t[e];return null!=i&&String(i).toLowerCase().includes(a)})}if(this.model.quickFilter){const e=this.model.quickFilter.toLowerCase().split(/\s+/).filter(Boolean),a=t.map(e=>e.key),s=this.model.quickFilterLogic||"and";i=i.filter(t=>{const i=e=>a.some(i=>{const a=t[i];return null!=a&&String(a).toLowerCase().includes(e)});return"and"===s?e.every(i):e.some(i)})}return i}evaluateFilter(e,t){const i=t[e.column],a=e.value;switch(e.operator){case"contains":return null!=i&&String(i).toLowerCase().includes(String(a).toLowerCase());case"notContains":return null==i||!String(i).toLowerCase().includes(String(a).toLowerCase());case"equals":return String(i??"").toLowerCase()===String(a).toLowerCase();case"notEquals":return String(i??"").toLowerCase()!==String(a).toLowerCase();case"startsWith":return null!=i&&String(i).toLowerCase().startsWith(String(a).toLowerCase());case"endsWith":return null!=i&&String(i).toLowerCase().endsWith(String(a).toLowerCase());case"isEmpty":return null==i||""===i;case"isNotEmpty":return null!=i&&""!==i;case"eq":return Number(i)===Number(a);case"neq":return Number(i)!==Number(a);case"gt":return Number(i)>Number(a);case"gte":return Number(i)>=Number(a);case"lt":return Number(i)<Number(a);case"lte":return Number(i)<=Number(a);case"is":return new Date(i).toDateString()===new Date(a).toDateString();case"isNot":return new Date(i).toDateString()!==new Date(a).toDateString();case"before":return new Date(i)<new Date(a);case"onOrBefore":return new Date(i)<=new Date(a);case"after":return new Date(i)>new Date(a);case"onOrAfter":return new Date(i)>=new Date(a);case"isTrue":return!0===i||"true"===i||1===i;case"isFalse":return!1===i||"false"===i||0===i||null==i;default:return!0}}toServerParams(){return{filters:this.model.filters,filterLogic:this.model.logic,quickFilter:this.model.quickFilter,headerFilters:Object.fromEntries(this.headerFilters)}}}class ge{constructor(){this.cellState=null,this.rowState=null,this.pipelines=new Map,this.validators=new Map,this.editableColumns=new Set,this.editabilityCheck=null,this.tableElement=null,this.mode="cell"}attach(e){this.tableElement=e}setEditableColumns(e){this.editableColumns=new Set(e)}setEditabilityCheck(e){this.editabilityCheck=e}setEditMode(e){this.mode=e}setPipeline(e,t){this.pipelines.set(e,t)}setValidation(e,t){this.validators.set(e,t)}isCellEditable(e,t){return!!this.editableColumns.has(t)&&(!this.editabilityCheck||this.editabilityCheck(e,t))}getDisplayValue(e,t,i){const a=this.pipelines.get(e);let s=t;return a?.valueGetter&&(s=a.valueGetter(s,i)),a?.valueFormatter?a.valueFormatter(s,i):null==s?"":String(s)}getSortValue(e,t,i){const a=this.pipelines.get(e);return a?.valueGetter?a.valueGetter(t,i):t}getEditorType(e){switch(e){case"number":case"currency":case"rating":case"progress":return"number";case"date":return"date";case"boolean":return"boolean";case"select":return"select";default:return"text"}}startCellEdit(e,t,i,a,s){return this.isCellEditable(a,t)?(this.cellState?.isEditing&&this.cancelCellEdit(),this.cellState={rowIndex:e,columnKey:t,rowData:a,originalValue:i,currentValue:i,editorType:this.getEditorType(s||""),error:null,isEditing:!0},this.cellState):null}updateCellValue(e){this.cellState&&(this.cellState.currentValue=e,this.cellState.error=null)}async commitCellEdit(){if(!this.cellState?.isEditing)return null;const{columnKey:e,currentValue:t,rowIndex:i,rowData:a}=this.cellState,s=this.pipelines.get(e);let n=t;s?.valueParser&&(n=s.valueParser(String(t),a));const l=this.validators.get(e);if(l){const e=await l.validate(n,a);if(e)return this.cellState.error=e,e}if(s?.valueSetter){const t=s.valueSetter(n,a);t&&"object"==typeof t&&!Array.isArray(t)?(Object.assign(a,t),n=a[e]):void 0!==t&&(n=t)}return this.tableElement?.dispatchEvent(new CustomEvent("cell-edit-commit",{detail:{rowIndex:i,columnKey:e,oldValue:this.cellState.originalValue,newValue:n},bubbles:!0,composed:!0})),this.cellState.isEditing=!1,this.cellState=null,null}cancelCellEdit(){this.cellState?.isEditing&&(this.tableElement?.dispatchEvent(new CustomEvent("cell-edit-cancel",{detail:{rowIndex:this.cellState.rowIndex,columnKey:this.cellState.columnKey},bubbles:!0,composed:!0})),this.cellState.isEditing=!1,this.cellState=null)}getCellEditState(){return this.cellState}startRowEdit(e,t){return this.rowState?.isEditing&&this.cancelRowEdit(),this.rowState={rowIndex:e,originalRow:{...t},editedRow:{...t},errors:new Map,isEditing:!0},this.rowState}updateRowField(e,t){this.rowState&&(this.rowState.editedRow[e]=t,this.rowState.errors.delete(e))}async commitRowEdit(){if(!this.rowState?.isEditing)return null;const e=new Map,t={...this.rowState.editedRow};for(const[e,i]of this.pipelines)i.valueParser&&e in t&&(t[e]=i.valueParser(String(t[e]),t));for(const i of this.editableColumns){const a=this.validators.get(i);if(a){const s=t[i],n=await a.validate(s,t);n&&e.set(i,n)}}if(e.size>0)return this.rowState.errors=e,e;let i={...t};for(const[e,t]of this.pipelines)if(t.valueSetter&&e in i){const a=t.valueSetter(i[e],i);a&&"object"==typeof a&&!Array.isArray(a)?i={...i,...a}:void 0!==a&&(i[e]=a)}return this.tableElement?.dispatchEvent(new CustomEvent("row-edit-commit",{detail:{rowIndex:this.rowState.rowIndex,oldRow:this.rowState.originalRow,newRow:i},bubbles:!0,composed:!0})),this.rowState.isEditing=!1,this.rowState=null,null}cancelRowEdit(){this.rowState?.isEditing&&(this.tableElement?.dispatchEvent(new CustomEvent("row-edit-cancel",{detail:{rowIndex:this.rowState.rowIndex},bubbles:!0,composed:!0})),this.rowState.isEditing=!1,this.rowState=null)}getRowEditState(){return this.rowState}isEditing(){return(this.cellState?.isEditing||this.rowState?.isEditing)??!1}createEditor(e,t,i){switch(e){case"number":{const e=document.createElement("input");return e.type="number",e.value=null==t?"":String(t),e.className="table-editor-input",e}case"date":{const e=document.createElement("input");return e.type="date",e.value=t||"",e.className="table-editor-input",e}case"boolean":{const e=document.createElement("input");return e.type="checkbox",e.checked=!!t,e.className="table-editor-checkbox",e}case"select":{const e=document.createElement("select");return e.className="table-editor-select",(i?.selectOptions||[]).forEach(i=>{const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.value===String(t)&&(a.selected=!0),e.appendChild(a)}),e}default:{const e=document.createElement("input");return e.type="text",e.value=null==t?"":String(t),e.className="table-editor-input",e}}}}class be{constructor(){this.focusedRow=-1,this.hasUserInteracted=!1,this.focusedCol=0,this.attached=!1,this.options={},this.keyHandler=e=>this.handleKeyDown(e)}attach(e){this.options=e;const t=e.shadowRoot;t&&(t.addEventListener("keydown",this.keyHandler),this.attached=!0,this.syncGridRole(),this.applyARIA())}detach(){this.options.shadowRoot?.removeEventListener("keydown",this.keyHandler),this.attached=!1}syncGridRole(){const e=this.getTable();e&&(e.setAttribute("role","grid"),e.setAttribute("tabindex","0"),e.setAttribute("aria-rowcount",String(this.ariaRowCount+1)),e.setAttribute("aria-colcount",String(this.totalColCount)))}refresh(){this.attached&&(this.syncGridRole(),this.applyARIA())}getTable(){return this.options.shadowRoot?.querySelector("table")??null}resolveBound(e){return"function"==typeof e?e():e??0}get totalRowCount(){return this.resolveBound(this.options.totalRows)}get totalColCount(){return this.resolveBound(this.options.totalColumns)}get ariaRowCount(){return this.resolveBound(this.options.ariaRows??this.options.totalRows)}get ariaRowOffset(){return Math.max(0,this.resolveBound(this.options.ariaRowOffset))}getBodyRow(e){if(this.options.getRowElement)return this.options.getRowElement(e);const t=this.getTable();return t?t.querySelector(`tbody tr[data-index="${e}"]`):null}applyARIA(){const e=this.getTable();if(!e)return;e.setAttribute("aria-rowcount",String(this.ariaRowCount+1)),e.setAttribute("aria-colcount",String(this.totalColCount));const t=e.querySelector("thead tr.column-header-row")??e.querySelector("thead tr:not(.column-group-row):not(.header-filter-row)");t&&(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1"),t.querySelectorAll("th").forEach((e,t)=>{if(e.setAttribute("role","columnheader"),e.setAttribute("aria-colindex",String(t+1)),e.classList.contains("sortable")){const t=e.querySelector(".sort-indicator.active");if(t){const i=t.textContent?.trim()||"";i.includes("▲")?e.setAttribute("aria-sort","ascending"):i.includes("▼")&&e.setAttribute("aria-sort","descending")}else e.setAttribute("aria-sort","none")}})),e.querySelectorAll("tbody tr:not(.virtual-spacer):not(.table-fill-row)").forEach((e,t)=>{e.setAttribute("role","row"),e.setAttribute("aria-rowindex",String(this.ariaRowOffset+t+2)),"true"===e.getAttribute("data-selected")?e.setAttribute("aria-selected","true"):e.removeAttribute("aria-selected"),e.querySelectorAll("td").forEach((e,t)=>{e.setAttribute("role","gridcell"),e.setAttribute("aria-colindex",String(t+1))})}),this.updateFocusIndicator()}setFocus(e,t){this.focusedRow=e,this.focusedCol=t,this.updateFocusIndicator()}getFocus(){return{row:this.focusedRow,col:this.focusedCol}}updateFocusIndicator(){if(!this.hasUserInteracted)return;const e=this.getTable();if(!e)return;e.querySelectorAll("[data-grid-focus]").forEach(e=>{e.removeAttribute("data-grid-focus"),e.removeAttribute("tabindex")});let t=null;if(-1===this.focusedRow)t=e.querySelectorAll("thead th")[this.focusedCol];else{let e=this.getBodyRow(this.focusedRow);e||(this.options.ensureRowVisible?.(this.focusedRow),e=this.getBodyRow(this.focusedRow)),e&&(t=e.querySelectorAll("td")[this.focusedCol])}t&&(t.setAttribute("data-grid-focus","true"),t.setAttribute("tabindex","0"))}handleKeyDown(e){if(this.options.isEditing())return;if(e.composedPath().some(e=>e instanceof Element&&e.matches('button, a, input, select, textarea, [contenteditable="true"], snice-button, snice-checkbox, snice-input, snice-select')))return;this.hasUserInteracted=!0;const t=this.totalRowCount,i=this.totalColCount;switch(e.key){case"ArrowDown":e.preventDefault(),this.focusedRow=Math.min(t-1,this.focusedRow+1),this.updateFocusIndicator(),this.scrollIntoView();break;case"ArrowUp":e.preventDefault(),this.focusedRow=Math.max(-1,this.focusedRow-1),this.updateFocusIndicator(),this.scrollIntoView();break;case"ArrowRight":e.preventDefault(),this.focusedCol=Math.min(i-1,this.focusedCol+1),this.updateFocusIndicator();break;case"ArrowLeft":e.preventDefault(),this.focusedCol=Math.max(0,this.focusedCol-1),this.updateFocusIndicator();break;case"Home":e.preventDefault(),e.ctrlKey?(this.focusedRow=-1,this.focusedCol=0):this.focusedCol=0,this.updateFocusIndicator(),this.scrollIntoView();break;case"End":e.preventDefault(),e.ctrlKey?(this.focusedRow=t-1,this.focusedCol=i-1):this.focusedCol=i-1,this.updateFocusIndicator(),this.scrollIntoView();break;case"PageDown":e.preventDefault(),this.focusedRow=Math.min(t-1,this.focusedRow+10),this.updateFocusIndicator(),this.scrollIntoView();break;case"PageUp":e.preventDefault(),this.focusedRow=Math.max(0,this.focusedRow-10),this.updateFocusIndicator(),this.scrollIntoView();break;case" ":this.focusedRow>=0&&(e.preventDefault(),this.options.onSelectionToggle?.(this.focusedRow));break;case"Enter":if(this.focusedRow>=0&&this.focusedCol>=0){e.preventDefault();const t=this.getBodyRow(this.focusedRow),i=t?.querySelectorAll("td"),a=i?.[this.focusedCol],s=a?.getAttribute("data-key")||"";this.options.onCellActivate?.(this.focusedRow,s)}break;case"a":(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.options.onSelectAll?.())}}scrollIntoView(){const e=this.getTable();if(!e)return;const t=e.querySelector("[data-grid-focus]");t&&("function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"nearest"}),"function"==typeof t.focus&&t.focus({preventScroll:!0}))}isAttached(){return this.attached}}class fe{exportCSV(e,t,i={}){const{delimiter:a=",",filename:s="export.csv",includeHeaders:n=!0,columns:l,utf8BOM:r=!0}=i;let o=t.filter(e=>!1!==e.exportable);l&&(o=o.filter(e=>l.includes(e.key)));const c=[];n&&c.push(o.map(e=>this.escapeCSV(e.label,a)).join(a));for(const t of e){const e=o.map(e=>{const i=t[e.key];return this.escapeCSV(null==i?"":String(i),a)});c.push(e.join(a))}const d=c.join("\n"),h=new Blob([(r?"\ufeff":"")+d],{type:"text/csv;charset=utf-8;"}),u=URL.createObjectURL(h),m=document.createElement("a");m.href=u,m.download=s,m.style.display="none",document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}print(e,t={}){const{hideFooter:i=!1,hideToolbar:a=!1,includeCheckboxes:s=!1,pageStyles:n=""}=t,l=e.shadowRoot;if(!l)return;const r=l.querySelector("table");if(!r)return;const o=r.cloneNode(!0),c=Array.from(r.querySelectorAll("snice-cell, [in-table], snice-checkbox")),d=Array.from(o.querySelectorAll("snice-cell, [in-table], snice-checkbox"));c.forEach((e,t)=>{const i=d[t];if(!i)return;if("snice-checkbox"===e.localName)return void i.replaceWith(document.createTextNode(e.checked?"☑":"☐"));const a=e.shadowRoot?.querySelector('[part~="content"]');i.replaceWith(document.createTextNode((a?.textContent||e.textContent||"").trim()))}),s||o.querySelectorAll(".select-column").forEach(e=>e.remove());const h=(e,t)=>{const i=l.querySelector(e);if(!i)return"";const a=i.cloneNode(!0);a.querySelectorAll("style").forEach(e=>e.remove()),a.querySelectorAll("button").forEach(e=>{e.textContent?.trim()||(e.textContent=e.getAttribute("aria-label")||"")});const s=a.textContent?.replace(/\s+/g," ").trim();return s?`<div class="${t}">${this.escapeHTML(s)}</div>`:""},u=a?"":h(".table-controls-container","print-toolbar"),m=i?"":h(".table-pagination-container","print-footer"),p=window.open("","_blank");p&&(p.document.write(`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Print</title>\n <style>\n body { font-family: system-ui, -apple-system, sans-serif; margin: 1rem; }\n table { width: 100%; border-collapse: collapse; }\n th, td { padding: 8px 12px; border: 1px solid #ddd; text-align: left; }\n th { background: #f5f5f5; font-weight: 600; }\n .print-toolbar, .print-footer { margin: 0 0 0.75rem; color: #444; }\n .print-footer { margin: 0.75rem 0 0; }\n @media print {\n body { margin: 0; }\n table { page-break-inside: auto; }\n tr { page-break-inside: avoid; }\n }\n ${n}\n </style>\n </head>\n <body>\n ${u}\n ${o.outerHTML}\n ${m}\n </body>\n </html>\n `),p.document.close(),p.onload=()=>{p.print(),p.close()})}async copyToClipboard(e,t,i={}){const{delimiter:a="\t",useFormatted:s=!0}=i;if(0===e.length)return!1;const n=e.map(e=>t.map(t=>{const i=e[t.key];return s?this.formatValue(i,e,t):this.rawValue(i)}).join(a)).join("\n");try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.createElement("textarea");e.value=n,e.style.cssText="position:fixed;left:-9999px;",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}escapeCSV(e,t){return e.includes(t)||e.includes('"')||e.includes("\n")||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}rawValue(e){if(null==e)return"";if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}formatValue(e,t,i){const a=i.formatter||i.valueFormatter;if(a)return String(a(e,t)??"");if(null==e)return"";const s=Number(e);switch(i.type){case"number":case"accounting":{if(!Number.isFinite(s))return this.rawValue(e);const t=i.numberFormat||{},a=t.decimals??("accounting"===i.type?2:0),n=new Intl.NumberFormat("en-US",{minimumFractionDigits:a,maximumFractionDigits:a,useGrouping:t.thousandsSeparator??!1}).format(Math.abs(s));let l=s<0&&("parentheses"===t.negativeStyle||"accounting"===i.type)?`(${n})`:`${s<0?"-":""}${n}`;return t.prefix&&(l=t.prefix+l),t.suffix&&(l+=t.suffix),l}case"currency":{if(!Number.isFinite(s))return this.rawValue(e);const t=i.currencyFormat||{},a=t.decimals??2,n=new Intl.NumberFormat(t.locale||"en-US",{style:"currency",currency:t.currency||"USD",currencyDisplay:t.currencyDisplay||t.display||"symbol",useGrouping:t.thousandsSeparator??!0,minimumFractionDigits:a,maximumFractionDigits:a}).format(Math.abs(s));return s>=0?n:"parentheses"===t.negativeStyle?`(${n})`:`-${n}`}case"percent":case"percentage":return Number.isFinite(s)?`${s.toFixed(i.percentageFormat?.decimals??2)}%`:this.rawValue(e);case"date":{const t=new Date(e);if(Number.isNaN(t.getTime()))return this.rawValue(e);const a=i.dateFormat||{},s="custom"===a.format?void 0:a.format||"short";return new Intl.DateTimeFormat(a.locale||"en-US",s?{dateStyle:s}:{}).format(t)}case"boolean":{const t=i.booleanFormat||{};return!0===e||String(e)===String(t.trueValue??"true")?t.trueSymbol||t.trueValue||"true":t.falseSymbol||t.falseValue||"false"}case"scientific":return Number.isFinite(s)?s.toExponential(i.numberFormat?.decimals??2):this.rawValue(e);default:return this.rawValue(e)}}escapeHTML(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}}class ve{constructor(){this.expandedRows=new Set,this.options=null,this.tableElement=null,this.contentCache=new Map,this.rowByIndex=new Map,this.measuredHeights=new Map,this.onHeightChange=null}attach(e,t){this.tableElement=e,this.options=t,this.contentCache.clear(),this.rowByIndex.clear(),this.measuredHeights.clear()}prepare(e){if(!this.options)return;this.rowByIndex=new Map(e.map((e,t)=>[t,e]));const t=new Set(e);for(const e of this.contentCache.keys())t.has(e)||this.contentCache.delete(e);for(const e of this.measuredHeights.keys())t.has(e)||this.measuredHeights.delete(e);!1===this.options.lazy&&e.forEach((e,t)=>this.getContent(e,t))}isExpanded(e){return this.expandedRows.has(e)}toggle(e){this.expandedRows.has(e)?this.collapse(e):this.expand(e)}expand(e){this.expandedRows.add(e),this.tableElement?.dispatchEvent(new CustomEvent("row-expand",{detail:{rowIndex:e},bubbles:!0,composed:!0}))}collapse(e){if(this.expandedRows.delete(e),!1!==this.options?.lazy){const t=this.rowByIndex.get(e);void 0!==t&&(this.contentCache.delete(t),this.measuredHeights.delete(t))}this.tableElement?.dispatchEvent(new CustomEvent("row-collapse",{detail:{rowIndex:e},bubbles:!0,composed:!0}))}expandAll(e){for(let t=0;t<e;t++)this.expandedRows.add(t)}collapseAll(){this.expandedRows.clear(),!1!==this.options?.lazy&&(this.contentCache.clear(),this.measuredHeights.clear())}getExpandedRows(){return new Set(this.expandedRows)}setExpandedRows(e){const t=new Set(e);if(!1!==this.options?.lazy)for(const e of this.expandedRows){if(t.has(e))continue;const i=this.rowByIndex.get(e);void 0!==i&&(this.contentCache.delete(i),this.measuredHeights.delete(i))}this.expandedRows=t}createToggleButton(e){const t=this.isExpanded(e),i=document.createElement("button");i.type="button",i.className="detail-toggle"+(t?" detail-toggle--expanded":""),i.setAttribute("aria-expanded",String(t)),i.setAttribute("aria-label",t?"Collapse row":"Expand row");const a=t?this.options?.collapseIcon:this.options?.expandIcon;return a?a.trim().startsWith("<")?i.innerHTML=a:i.textContent=a:i.innerHTML='<svg class="detail-toggle-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',i.addEventListener("click",t=>{t.stopPropagation(),this.toggle(e),this.tableElement?.dispatchEvent(new CustomEvent("detail-toggle",{detail:{rowIndex:e,expanded:this.isExpanded(e)},bubbles:!0,composed:!0}))}),i}createDetailRow(e,t,i){if(!this.options||!this.isExpanded(t))return null;const a=document.createElement("tr");a.className="detail-row",a.setAttribute("data-detail-for",String(t));const s=document.createElement("td");s.colSpan=i,s.className="detail-cell",s.style.padding="0",s.style.border="none";const n=document.createElement("div");n.className="detail-content";const l=document.createElement("div");l.className="detail-content-inner";const r=this.getContent(e,t);return"string"==typeof r?l.innerHTML=r:r instanceof HTMLElement&&l.appendChild(r),n.appendChild(l),s.appendChild(n),requestAnimationFrame(()=>{const t=this.options?.detailHeight,i=void 0===t||"auto"===t?`${l.scrollHeight}px`:"number"==typeof t?`${t}px`:t;void 0!==t&&"auto"!==t&&(l.style.height=i,l.style.overflow="auto"),n.style.setProperty("--detail-max-height",i),n.classList.add("detail-content--open");const a=l.getBoundingClientRect().height||l.scrollHeight,s=this.measuredHeights.get(e);a>0&&a!==s&&(this.measuredHeights.set(e,a),this.onHeightChange?.())}),a.appendChild(s),a}isEnabled(){return null!==this.options}getFixedAdditionalHeight(e){if(!this.isExpanded(e))return 0;const t=this.options?.detailHeight;if("number"==typeof t)return Math.max(0,t);if("string"==typeof t&&/^\d+(?:\.\d+)?px$/.test(t.trim()))return Math.max(0,Number.parseFloat(t));const i=this.rowByIndex.get(e);return void 0===i?0:this.measuredHeights.get(i)||0}getContent(e,t){return this.options?(this.rowByIndex.set(t,e),this.contentCache.has(e)||this.contentCache.set(e,this.options.getDetailContent(e,t)),this.contentCache.get(e)):""}}class ye{constructor(){this.container=null,this.options={},this.tableElement=null,this.filterEngine=null,this.filterPanel=null,this.filterPanelOpen=!1,this.filters=[],this.logic="and",this.pendingDebounces=[],this.sortPanel=null,this.sortPanelOpen=!1,this.onSearch=null,this.onSortColumn=null,this.onSetSortModel=null,this.onFilterColumn=null,this.onRemoveFilter=null,this.onClearFilters=null,this.onSetFilterModel=null,this.onExportCSV=null,this.onFullscreen=null}attach(e,t,i={}){this.tableElement=e,this.container=t,this.options=i,this.render()}setFilterEngine(e){this.filterEngine=e}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="tt-wrap",e.appendChild(this.styleTag());const t=document.createElement("div");if(t.className="table-toolbar",t.setAttribute("part","toolbar"),!1!==this.options.showSearch){const e=document.createElement("snice-input");let i;e.type="search",e.placeholder=this.options.searchPlaceholder||"Search...",e.size="small",e.prefixIcon="search",e.clearable=!0,e.className="toolbar-search",e.addEventListener("input",()=>{clearTimeout(i),i=window.setTimeout(()=>this.onSearch?.(e.value),300)}),t.appendChild(e)}const i=document.createElement("div");if(i.className="toolbar-actions",this.options.showSort){const e=this.mkBtn("Sort",N);e.classList.add("toolbar-sort"),e.addEventListener("click",()=>this.toggleSortPanel()),i.appendChild(e)}if(this.options.showFilter){const e=this.mkBtn("Filter",T);e.classList.add("toolbar-filter"),e.addEventListener("click",()=>{this.filterPanelOpen?this.closeFilterPanel():this.openFilterModal()}),i.appendChild(e)}if(this.options.showExport){const e=this.mkBtn("Export CSV",L);e.addEventListener("click",()=>this.onExportCSV?.()),i.appendChild(e)}const a=this.mkBtn("Fullscreen",B);a.addEventListener("click",()=>this.onFullscreen?.()),i.appendChild(a),t.appendChild(i),e.appendChild(t),this.filterPanel=document.createElement("div"),this.filterPanel.className="tt-filter-panel",this.filterPanel.hidden=!this.filterPanelOpen,e.appendChild(this.filterPanel),this.sortPanel=document.createElement("div"),this.sortPanel.className="tt-sort-panel",this.sortPanel.hidden=!this.sortPanelOpen,e.appendChild(this.sortPanel),this.container.appendChild(e),this.filterPanelOpen&&this.renderFilterPanel(),this.sortPanelOpen&&this.renderSortPanel()}openFilterModal(e){this.closeSortPanel();const t=this.ensureEngine();if(!this.filterPanelOpen){const e=t.getFilterModel();this.filters=e.filters.map(e=>({...e})),this.logic=e.logic||"and"}if(e){const i=(this.tableElement?.columns||[]).find(t=>t.key===e),a=t.getOperatorsForType(i?.type||"text");i&&a[0]&&!this.filters.some(t=>t.column===e)&&this.filters.push({column:e,operator:a[0].value,value:""})}this.filterPanelOpen||(this.filterPanelOpen=!0,this.filterPanel&&(this.filterPanel.hidden=!1)),this.renderFilterPanel()}closeFilterPanel(){this.cancelPendingDebounces(),this.filterPanelOpen=!1,this.filterPanel&&(this.filterPanel.hidden=!0)}toggleSortPanel(){this.sortPanelOpen?this.closeSortPanel():(this.closeFilterPanel(),this.sortPanelOpen=!0,this.sortPanel&&(this.sortPanel.hidden=!1),this.renderSortPanel())}closeSortPanel(){this.sortPanelOpen=!1,this.sortPanel&&(this.sortPanel.hidden=!0)}renderSortPanel(){if(!this.sortPanel)return;const e=(this.tableElement?.columns||[]).filter(e=>!1!==e.sortable);let t=(this.tableElement?.currentSort||[]).map(e=>({...e}));this.sortPanel.innerHTML="",this.sortPanel.appendChild(this.styleTag());const i=document.createElement("div");i.className="tt-filter-inner";const a=document.createElement("button");a.type="button",a.className="tt-filter-corner-close",a.setAttribute("aria-label","Close sort panel"),a.innerHTML=x,a.addEventListener("click",()=>this.closeSortPanel()),i.appendChild(a);const s=document.createElement("div");s.className="tt-filter-rows",i.appendChild(s);const n=()=>this.onSetSortModel?.(t.map(e=>({...e}))),l=()=>this.renderSortPanel();if(0===t.length){const e=document.createElement("div");e.className="tt-filter-empty",e.textContent="No sorting applied",s.appendChild(e)}else t.forEach((i,a)=>{const r=document.createElement("div");r.className="tt-filter-row tt-sort-row";const o=document.createElement("button");o.type="button",o.className="tt-filter-x",o.setAttribute("aria-label","Remove sort"),o.innerHTML=x,o.addEventListener("click",()=>{t.splice(a,1),n(),l()}),r.appendChild(o);const c=document.createElement("snice-select");c.size="small";const d=new Set(t.filter((e,t)=>t!==a).map(e=>e.column));c.options=e.filter(e=>e.key===i.column||!d.has(e.key)).map(e=>({value:e.key,label:e.label||e.key})),c.value=i.column,c.style.width="12rem",c.addEventListener("change",()=>{i.column=c.value,n()}),r.appendChild(c);const h=document.createElement("snice-select");h.size="small",h.options=[{value:"asc",label:"Ascending"},{value:"desc",label:"Descending"}],h.value=i.direction,h.style.width="9rem",h.addEventListener("change",()=>{i.direction=h.value,n()}),r.appendChild(h),s.appendChild(r)});const r=document.createElement("div");r.className="tt-filter-footer";const o=document.createElement("button");if(o.type="button",o.className="tt-filter-add",o.innerHTML=`${R}<span>Add sort</span>`,o.addEventListener("click",()=>{const i=new Set(t.map(e=>e.column)),a=e.find(e=>!i.has(e.key));a&&(t.push({column:a.key,direction:"asc"}),n(),l())}),o.disabled=t.length>=e.length,r.appendChild(o),t.length>0){const e=document.createElement("button");e.type="button",e.className="tt-filter-clear",e.textContent="Clear all",e.addEventListener("click",()=>{t=[],n(),l()}),r.appendChild(e)}i.appendChild(r),this.sortPanel.appendChild(i)}ensureEngine(){return this.filterEngine||(this.filterEngine=new pe),this.filterEngine}cancelPendingDebounces(){for(const e of this.pendingDebounces)clearTimeout(e);this.pendingDebounces=[]}renderFilterPanel(){if(!this.filterPanel)return;this.cancelPendingDebounces();const e=this.ensureEngine(),t=this.tableElement?.columns||[];if(0===this.filters.length){const t=e.getFilterModel();this.filters=[...t.filters],this.logic=t.logic||"and"}this.filterPanel.innerHTML="",this.filterPanel.appendChild(this.styleTag());const i=document.createElement("div");i.className="tt-filter-inner";const a=document.createElement("button");a.type="button",a.className="tt-filter-corner-close",a.setAttribute("aria-label","Close filter panel"),a.setAttribute("title","Close"),a.innerHTML=x,a.addEventListener("click",()=>this.closeFilterPanel()),i.appendChild(a);const s=document.createElement("div");s.className="tt-filter-rows",i.appendChild(s);const n=()=>{const i=this.filters.filter(i=>{const a=t.find(e=>e.key===i.column),s=e.getOperatorsForType(a?.type||"text").find(e=>e.value===i.operator);return!!s&&(!1===s.requiresValue||null!==i.value&&""!==i.value)});this.onSetFilterModel?.(i,this.logic)},l=(i,a)=>{const s=document.createElement("div");s.className="tt-filter-row";const l=document.createElement("button");l.type="button",l.className="tt-filter-x",l.setAttribute("aria-label","Remove filter"),l.innerHTML=x,l.addEventListener("click",()=>{this.filters.splice(a,1),0===this.filters.length?this.onClearFilters?.():n(),this.renderFilterPanel()}),s.appendChild(l);const r=document.createElement("snice-select");r.size="small",r.searchable=t.length>8,r.maxHeight="200px",r.options=t.map(e=>({value:e.key,label:e.label||e.key})),r.value=i.column,r.style.width="11rem",s.appendChild(r);const o=document.createElement("snice-select");o.size="small",o.maxHeight="200px",o.style.width="8rem",s.appendChild(o);const c=document.createElement("span");c.className="tt-filter-val-wrap";const d=document.createElement("snice-input");d.size="small",d.placeholder="Value",d.style.width="11rem",null!=i.value&&(d.value=String(i.value)),c.appendChild(d),s.appendChild(c);const h=()=>{const a=t.find(e=>e.key===r.value),s=a?.type||"text",n=e.getOperatorsForType(s);o.options=n.map(e=>({value:e.value,label:e.label})),o.value=n.some(e=>e.value===i.operator)?i.operator:"",d.type=(e=>{switch(e){case"number":case"currency":case"rating":case"progress":case"filesize":case"duration":case"percent":case"percentage":return"number";case"date":return"date";default:return"text"}})(s),u()},u=()=>{const i=t.find(e=>e.key===r.value),a=e.getOperatorsForType(i?.type||"text").find(e=>e.value===o.value);c.style.display=!1===a?.requiresValue?"none":""};let m;return r.addEventListener("change",()=>{i.column=r.value,h(),n()}),o.addEventListener("change",()=>{i.operator=o.value,u(),n()}),d.addEventListener("input",()=>{clearTimeout(m),m=window.setTimeout(()=>{this.pendingDebounces=this.pendingDebounces.filter(e=>e!==m),i.value=d.value,n()},250),this.pendingDebounces.push(m)}),d.addEventListener("keydown",e=>{"Enter"===e.key&&(i.value=d.value,n())}),h(),s};if(this.filters.length>1){const e=document.createElement("div");e.className="tt-filter-logicbar";const t=document.createElement("span");t.className="tt-filter-logicbar-label",t.textContent="Match";const a=document.createElement("snice-select");a.size="small",a.options=[{value:"and",label:"All filters (AND)"},{value:"or",label:"Any filter (OR)"}],a.value=this.logic,a.style.width="11rem",a.addEventListener("change",()=>{this.logic=a.value,n()}),e.appendChild(t),e.appendChild(a),i.insertBefore(e,s)}if(0===this.filters.length){const e=document.createElement("div");e.className="tt-filter-empty",e.textContent="No filters applied",s.appendChild(e)}else this.filters.forEach((e,t)=>s.appendChild(l(e,t)));const r=document.createElement("div");r.className="tt-filter-footer";const o=document.createElement("button");if(o.type="button",o.className="tt-filter-add",o.innerHTML=`${R}<span>Add filter</span>`,o.addEventListener("click",()=>{const i=t[0];if(!i)return;const a=e.getOperatorsForType(i.type||"text");a[0]&&(this.filters.push({column:i.key,operator:a[0].value,value:""}),this.renderFilterPanel())}),r.appendChild(o),this.filters.length>0){const e=document.createElement("button");e.type="button",e.className="tt-filter-clear",e.textContent="Clear all",e.addEventListener("click",()=>{this.cancelPendingDebounces(),this.filters=[],this.logic="and",this.onClearFilters?.(),this.renderFilterPanel()}),r.appendChild(e)}i.appendChild(r),this.filterPanel.appendChild(i)}mkBtn(e,t){const i=document.createElement("button");return i.className="toolbar-btn",i.setAttribute("aria-label",e),i.setAttribute("title",e),i.innerHTML=t,i}styleTag(){const e=document.createElement("style");return e.textContent=we,e}setActiveFilterCount(e){}isAttached(){return null!==this.container}}const we="\n .tt-wrap { display: flex; flex-direction: column; }\n\n .tt-filter-panel {\n border-bottom: 1px solid var(--snice-color-border, rgb(226 226 226));\n background: var(--snice-color-surface-container-low, rgb(250 250 250));\n }\n .tt-sort-panel {\n border-bottom: 1px solid var(--snice-color-border, rgb(226 226 226));\n background: var(--snice-color-surface-container-low, rgb(250 250 250));\n }\n .tt-filter-inner {\n padding: 0.75rem 0.875rem;\n padding-right: 2.5rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n position: relative;\n }\n .tt-filter-corner-close {\n position: absolute;\n top: 0.5rem;\n right: 0.5rem;\n width: 1.75rem;\n height: 1.75rem;\n border: none;\n background: none;\n cursor: pointer;\n color: var(--snice-color-text-tertiary, rgb(115 115 115));\n border-radius: var(--snice-border-radius-md, 0.25rem);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n line-height: 0;\n z-index: 1;\n }\n .tt-filter-corner-close:hover {\n background: var(--snice-color-surface-hover, rgb(245 245 245));\n color: var(--snice-color-text, rgb(23 23 23));\n }\n .tt-filter-corner-close svg {\n width: 1rem;\n height: 1rem;\n }\n .tt-filter-logicbar {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n }\n .tt-filter-logicbar-label {\n font-size: 0.75rem;\n font-weight: 500;\n color: var(--snice-color-text-secondary, rgb(82 82 82));\n flex: 0 0 auto;\n }\n .tt-filter-rows {\n display: flex;\n flex-direction: column;\n gap: 0.375rem;\n }\n .tt-filter-empty {\n padding: 0.625rem 0.5rem;\n font-size: 0.8125rem;\n color: var(--snice-color-text-tertiary, rgb(115 115 115));\n font-style: italic;\n }\n .tt-filter-row {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n flex-wrap: nowrap;\n }\n .tt-filter-x {\n border: none;\n background: none;\n color: var(--snice-color-text-tertiary, rgb(115 115 115));\n cursor: pointer;\n border-radius: var(--snice-border-radius-md, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n padding: 0;\n line-height: 0;\n }\n .tt-filter-x svg {\n width: 1rem;\n height: 1rem;\n }\n .tt-filter-x:hover {\n color: var(--snice-color-danger, rgb(220 38 38));\n background: var(--snice-color-surface-hover, rgb(245 245 245));\n }\n .tt-filter-val-wrap { display: inline-flex; flex: 1 1 auto; min-width: 0; }\n .tt-filter-val-wrap snice-input { width: 100%; }\n .tt-filter-footer {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n margin-top: 0.125rem;\n }\n .tt-filter-add,\n .tt-filter-clear {\n border: none;\n background: none;\n font-family: inherit;\n font-size: 0.8125rem;\n cursor: pointer;\n padding: 0.375rem 0.625rem;\n border-radius: var(--snice-border-radius-md, 0.25rem);\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n line-height: 1;\n }\n .tt-filter-add svg,\n .tt-filter-clear svg {\n width: 0.875rem;\n height: 0.875rem;\n }\n .tt-filter-add { color: var(--snice-color-primary, rgb(37 99 235)); font-weight: 500; }\n .tt-filter-add:hover { background: var(--snice-color-primary-subtle, rgb(219 234 254 / 0.4)); }\n .tt-filter-clear { color: var(--snice-color-text-tertiary, rgb(115 115 115)); margin-left: auto; }\n .tt-filter-clear:hover {\n color: var(--snice-color-danger, rgb(220 38 38));\n background: var(--snice-color-surface-hover, rgb(245 245 245));\n }\n";class ke{constructor(){this.options=null,this.expandedKeys=new Set,this.flatRows=[],this.enabled=!1,this.defaultDepth=0}attach(e){this.options=e,this.enabled=!0,void 0!==e.defaultExpansionDepth&&e.defaultExpansionDepth>=0&&(this.defaultDepth=e.defaultExpansionDepth)}isEnabled(){return this.enabled}processData(e){if(!this.options)return[];const t=new Map;for(const i of e){const e=this.options.getPath(i),a=e.join("/");t.set(a,{data:i,children:new Set,depth:e.length-1,isGap:!1});for(let i=1;i<e.length;i++){const a=e.slice(0,i),s=a.join("/");t.has(s)||t.set(s,{data:{[this.options.groupColumn||"name"]:a[a.length-1]},children:new Set,depth:i-1,isGap:!0})}if(e.length>1){const i=e.slice(0,-1).join("/"),s=t.get(i);s&&s.children.add(a)}}const i=[];for(const[e,a]of t)0===a.depth&&i.push(e);if(i.sort(),0===this.expandedKeys.size&&this.defaultDepth>0)for(const[e,i]of t)i.depth<this.defaultDepth&&i.children.size>0&&this.expandedKeys.add(e);this.flatRows=[];const a=e=>{const i=t.get(e);if(!i)return;const s=i.children.size>0,n=this.expandedKeys.has(e);if(this.flatRows.push({path:e.split("/"),data:i.data,depth:i.depth,hasChildren:s,expanded:n,key:e,isGap:i.isGap}),n){const e=Array.from(i.children).sort();for(const t of e)a(t)}};for(const e of i)a(e);return this.flatRows}getFlatRows(){return this.flatRows}toggle(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):this.expandedKeys.add(e)}expand(e){this.expandedKeys.add(e)}collapse(e){this.expandedKeys.delete(e)}expandAll(e){if(this.options)for(const t of e){const e=this.options.getPath(t);for(let t=1;t<=e.length;t++)this.expandedKeys.add(e.slice(0,t).join("/"))}}collapseAll(){this.expandedKeys.clear()}isExpanded(e){return this.expandedKeys.has(e)}createToggle(e){const t=document.createElement("span");if(t.className="tree-indent",t.style.paddingLeft=1.5*e.depth+"rem",e.hasChildren){const i=document.createElement("button");i.type="button",i.className="tree-toggle"+(e.expanded?" tree-toggle--expanded":""),i.innerHTML='<svg class="tree-toggle-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',i.setAttribute("aria-expanded",String(e.expanded)),i.setAttribute("aria-label",(e.expanded?"Collapse":"Expand")+" row"),i.addEventListener("click",t=>{t.stopPropagation(),this.toggle(e.key),i.dispatchEvent(new CustomEvent("tree-toggle",{detail:{key:e.key,expanded:this.isExpanded(e.key)},bubbles:!0,composed:!0}))}),t.appendChild(i)}else{const e=document.createElement("span");e.className="tree-spacer",t.appendChild(e)}return t}getGroupColumn(){return this.options?.groupColumn||""}}function xe(e,t,i){if("function"==typeof e)return e(t,i);if("count"===e)return i.length;const a=[];for(const e of t)if(null!=e&&"boolean"!=typeof e&&("string"!=typeof e||""!==e.trim()))try{const t=Number(e);Number.isFinite(t)&&a.push(t)}catch{}switch(e){case"sum":return a.reduce((e,t)=>e+t,0);case"avg":return a.length?a.reduce((e,t)=>e+t,0)/a.length:0;case"min":return a.length?a.reduce((e,t)=>t<e?t:e,a[0]):null;case"max":return a.length?a.reduce((e,t)=>t>e?t:e,a[0]):null;default:return null}}class Ce{constructor(){this.groupByKeys=[],this.defaultExpanded=!0,this.aggregators=[],this.collapsedOverrides=new Set,this.expandedOverrides=new Set,this.flatItems=[],this.objectValueIds=new WeakMap,this.symbolValueIds=new Map,this.nextValueId=1}configure(e){this.groupByKeys=(e.groupBy??[]).filter(Boolean),this.defaultExpanded=!1!==e.defaultExpanded}setColumns(e){const t=e.filter(e=>null!=e.aggregate).map(e=>({key:e.key,aggregate:e.aggregate,valueGetter:e.valueGetter})),i=t.length!==this.aggregators.length||t.some((e,t)=>{const i=this.aggregators[t];return i?.key!==e.key||i.aggregate!==e.aggregate||i.valueGetter!==e.valueGetter});return this.aggregators=t,i}hasGrouping(){return this.groupByKeys.length>0}hasAggregation(){return this.aggregators.length>0}isEnabled(){return this.hasGrouping()||this.hasAggregation()}getGroupByKeys(){return this.groupByKeys}computeAggregates(e){const t={};for(const i of this.aggregators){const a=e.map(e=>{const t=e?.[i.key];return i.valueGetter?i.valueGetter(t,e):t});t[i.key]=xe(i.aggregate,a,e)}return t}valueKey(e){if(null===e)return"null";switch(typeof e){case"undefined":return"undefined";case"string":return`string:${encodeURIComponent(e)}`;case"number":return Number.isNaN(e)?"number:NaN":`number:${Object.is(e,-0)?"0":String(e)}`;case"boolean":return"boolean:"+(e?"1":"0");case"bigint":return`bigint:${String(e)}`;case"symbol":{let t=this.symbolValueIds.get(e);return void 0===t&&(t=this.nextValueId++,this.symbolValueIds.set(e,t)),`symbol:${t}`}case"object":case"function":{const t=e;let i=this.objectValueIds.get(t);return void 0===i&&(i=this.nextValueId++,this.objectValueIds.set(t,i)),`object:${i}`}default:return`${typeof e}:${encodeURIComponent(String(e))}`}}processData(e){if(!this.isEnabled()||0===e.length)return this.flatItems=[],this.flatItems;const t=[];if(this.hasGrouping())this.buildGroups(e,0,"",t);else for(const i of e)t.push({type:"row",key:i,depth:0,data:i});return this.hasAggregation()&&t.push({type:"aggregate",key:"agg:table",depth:0,scope:"table",aggregates:this.computeAggregates(e),rows:e}),this.flatItems=t,t}buildGroups(e,t,i,a){const s=this.groupByKeys[t],n=new Map;for(const t of e){const e=t[s],i=n.get(e);i?i.push(t):n.set(e,[t])}const l=Array.from(n.keys()).sort((e,t)=>String(e??"").localeCompare(String(t??""),void 0,{numeric:!0})||this.valueKey(e).localeCompare(this.valueKey(t))),r=t===this.groupByKeys.length-1;for(const e of l){const l=n.get(e),o=`${encodeURIComponent(s)}=${this.valueKey(e)}`,c=i?`${i}|${o}`:o,d=`group:${c}`,h=this.isExpanded(d);if(a.push({type:"group",key:d,depth:t,groupKey:s,value:e,count:l.length,expanded:h,hasChildren:!0,rows:l}),h){if(r)for(const e of l)a.push({type:"row",key:e,depth:t+1,data:e});else this.buildGroups(l,t+1,c,a);this.hasAggregation()&&a.push({type:"aggregate",key:`agg:${d}`,depth:t+1,scope:"group",aggregates:this.computeAggregates(l),rows:l,groupKey:d,groupValue:e,groupColumn:s})}}}getFlatItems(){return this.flatItems}isExpanded(e){return this.defaultExpanded?!this.collapsedOverrides.has(e):this.expandedOverrides.has(e)}toggle(e){this.isExpanded(e)?this.collapse(e):this.expand(e)}expand(e){this.collapsedOverrides.delete(e),this.defaultExpanded||this.expandedOverrides.add(e)}collapse(e){this.expandedOverrides.delete(e),this.defaultExpanded&&this.collapsedOverrides.add(e)}expandAll(){if(this.collapsedOverrides.clear(),!this.defaultExpanded)for(const e of this.flatItems)"group"===e.type&&this.expandedOverrides.add(e.key)}collapseAll(){if(this.expandedOverrides.clear(),this.defaultExpanded)for(const e of this.flatItems)"group"===e.type&&this.collapsedOverrides.add(e.key)}createToggle(e){const t=document.createElement("span");t.className="tree-indent",t.style.paddingLeft=1.5*e.depth+"rem";const i=document.createElement("button");i.type="button",i.className="tree-toggle"+(e.expanded?" tree-toggle--expanded":""),i.setAttribute("data-group-key",e.key),i.innerHTML='<svg class="tree-toggle-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',i.setAttribute("aria-expanded",String(e.expanded));const a=null==e.value||""===e.value?"blank":String(e.value);return i.setAttribute("aria-label",`${e.expanded?"Collapse":"Expand"} ${a} group, ${e.count} rows`),t.appendChild(i),t}}class Se{constructor(){this.menuEl=null,this.activeColumn=null,this.tableElement=null,this.outsideClickHandler=null,this.onSortAsc=null,this.onSortDesc=null,this.onFilter=null,this.onHide=null,this.onPinLeft=null,this.onPinRight=null,this.onUnpin=null,this.onAutoSize=null}attach(e){this.tableElement=e}show(e,t,i,a){this.hide(),this.activeColumn=e;const s=document.createElement("div");s.className="table-column-menu",s.style.left=`${t}px`,s.style.top=`${i}px`;const n=[];!1!==a?.sortable&&(n.push({label:"Sort Ascending",icon:M,action:"sort-asc"}),n.push({label:"Sort Descending",icon:z,action:"sort-desc"}),n.push({label:"",action:"",separator:!0})),!1!==a?.filterable&&n.push({label:"Filter...",icon:T,action:"filter"}),!1!==a?.hideable&&n.push({label:"Hide Column",icon:O,action:"hide"}),!1!==a?.pinnable&&(a?.pinned?n.push({label:"Unpin",icon:x,action:"unpin"}):(n.push({label:"Pin Left",icon:j,action:"pin-left"}),n.push({label:"Pin Right",icon:j,action:"pin-right"}))),n.push({label:"",action:"",separator:!0}),n.push({label:"Auto-size",icon:N,action:"autosize"});for(const e of n){if(e.separator){const e=document.createElement("div");e.className="column-menu-separator",s.appendChild(e);continue}const t=document.createElement("button");t.type="button",t.className="column-menu-item",t.innerHTML=`${e.icon?`<span class="column-menu-icon">${e.icon}</span>`:""}<span>${e.label}</span>`,t.addEventListener("click",()=>{this.handleAction(e.action),this.hide()}),e.disabled&&(t.disabled=!0),s.appendChild(t)}const l=this.tableElement?.shadowRoot;l?l.appendChild(s):document.body.appendChild(s),this.menuEl=s,setTimeout(()=>{this.outsideClickHandler=e=>{e.composedPath().includes(s)||this.hide()},document.addEventListener("click",this.outsideClickHandler,{capture:!0})},0);const r=e=>{"Escape"===e.key&&(this.hide(),document.removeEventListener("keydown",r))};document.addEventListener("keydown",r)}handleAction(e){if(this.activeColumn)switch(e){case"sort-asc":this.onSortAsc?.(this.activeColumn);break;case"sort-desc":this.onSortDesc?.(this.activeColumn);break;case"filter":this.onFilter?.(this.activeColumn);break;case"hide":this.onHide?.(this.activeColumn);break;case"pin-left":this.onPinLeft?.(this.activeColumn);break;case"pin-right":this.onPinRight?.(this.activeColumn);break;case"unpin":this.onUnpin?.(this.activeColumn);break;case"autosize":this.onAutoSize?.(this.activeColumn)}}hide(){this.menuEl&&(this.menuEl.remove(),this.menuEl=null),this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler,{capture:!0}),this.outsideClickHandler=null),this.activeColumn=null}isOpen(){return null!==this.menuEl}}class Ee{constructor(){this.enabled=!1,this.tableElement=null,this.dragSourceIndex=-1,this.dropTargetIndex=-1,this.dropIndicator=null}attach(e){this.tableElement=e,this.enabled=!0}detach(){this.removeDropIndicator(),this.tableElement=null,this.dragSourceIndex=-1,this.dropTargetIndex=-1,this.enabled=!1}isEnabled(){return this.enabled}makeRowDraggable(e,t,i=!0){i&&(e.draggable=!0,e.addEventListener("dragstart",i=>{this.dragSourceIndex=t,e.style.opacity="0.5",i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",String(t))}),e.addEventListener("dragend",()=>{e.style.opacity="1",this.removeDropIndicator(),this.dragSourceIndex=-1}),e.addEventListener("dragover",i=>{i.preventDefault(),i.dataTransfer.dropEffect="move",this.dropTargetIndex=t,this.showDropIndicator(e)}),e.addEventListener("dragleave",()=>{this.removeDropIndicator()}),e.addEventListener("drop",e=>{e.preventDefault(),this.removeDropIndicator(),-1!==this.dragSourceIndex&&this.dragSourceIndex!==t&&this.tableElement?.dispatchEvent(new CustomEvent("row-reorder",{detail:{fromIndex:this.dragSourceIndex,toIndex:t},bubbles:!0,composed:!0})),this.dragSourceIndex=-1}))}createDragHandle(){const e=document.createElement("td");return e.className="drag-handle-cell",e.textContent="⠗",e.setAttribute("aria-label","Drag to reorder"),e}showDropIndicator(e){this.removeDropIndicator(),this.dropIndicator=document.createElement("div"),this.dropIndicator.className="drop-indicator";const t=e.getBoundingClientRect(),i=e.parentElement?.getBoundingClientRect();i&&(this.dropIndicator.style.top=(this.dropTargetIndex>this.dragSourceIndex?t.bottom-i.top:t.top-i.top)+"px",e.parentElement.style.position="relative",e.parentElement.appendChild(this.dropIndicator))}removeDropIndicator(){this.dropIndicator?.remove(),this.dropIndicator=null}}class De{constructor(){this.enabled=!1,this.tableElement=null,this.dragSourceKey=null}attach(e){this.tableElement=e,this.enabled=!0}detach(){this.tableElement=null,this.dragSourceKey=null,this.enabled=!1}isEnabled(){return this.enabled}makeHeaderDraggable(e,t,i=!0){i&&(e.draggable=!0,e.addEventListener("dragstart",i=>{this.dragSourceKey=t,e.style.opacity="0.5",i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",t)}),e.addEventListener("dragend",()=>{e.style.opacity="1",this.dragSourceKey=null}),e.addEventListener("dragover",i=>{this.dragSourceKey&&this.dragSourceKey!==t&&(i.preventDefault(),i.dataTransfer.dropEffect="move",e.style.borderLeft="2px solid var(--snice-color-primary, rgb(37 99 235))")}),e.addEventListener("dragleave",()=>{e.style.borderLeft=""}),e.addEventListener("drop",i=>{i.preventDefault(),e.style.borderLeft="",this.dragSourceKey&&this.dragSourceKey!==t&&this.tableElement?.dispatchEvent(new CustomEvent("column-reorder",{detail:{fromKey:this.dragSourceKey,toKey:t},bubbles:!0,composed:!0})),this.dragSourceKey=null}))}}(()=>{let t,a,c,p,b,v,x,C,S,E,D,A,R,M,z,$,F,I,T,L,V,B,O,j,N,P,H,q,_,G,K,W,U,Z,Y,J,Q,X,ee,te,ie,ae,se,ne,le,re,de,he,ue,me,we,xe,Ae,Re,Me,ze,$e,Fe,Ie,Te,Le,Ve,Be,Oe,je,Ne,Pe,He,qe,_e,Ge,Ke,We,Ue,Ze,Ye,Je,Qe,Xe,et,tt,it,at,st,nt,lt,rt,ot,ct,dt,ht,ut,mt,pt,gt=[i("snice-table")],bt=[],ft=HTMLElement,vt=[],yt=[],wt=[],kt=[],xt=[],Ct=[],St=[],Et=[],Dt=[],At=[],Rt=[],Mt=[],zt=[],$t=[],Ft=[],It=[],Tt=[],Lt=[],Vt=[],Bt=[],Ot=[],jt=[],Nt=[],Pt=[],Ht=[],qt=[],_t=[],Gt=[],Kt=[],Wt=[],Ut=[],Zt=[],Yt=[],Jt=[],Qt=[],Xt=[],ei=[],ti=[],ii=[],ai=[],si=[],ni=[],li=[],ri=[],oi=[],ci=[],di=[],hi=[],ui=[],mi=[],pi=[],gi=[],bi=[],fi=[],vi=[],yi=[],wi=[],ki=[],xi=[],Ci=[],Si=[],Ei=[],Di=[],Ai=[],Ri=[],Mi=[],zi=[],$i=[],Fi=[],Ii=[],Ti=[],Li=[],Vi=[],Bi=[],Oi=[],ji=[],Ni=[],Pi=[],Hi=[],qi=[],_i=[],Gi=[],Ki=[],Wi=[],Ui=[],Zi=[],Yi=[],Ji=[],Qi=[];var Xi=class extends ft{static{a=this}static{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(ft[Symbol.metadata]??null):void 0;c=[s({type:Boolean,attribute:"striped"})],p=[s({type:Boolean,attribute:"searchable"})],b=[s({type:Boolean,attribute:"filterable"})],v=[s({type:Boolean,attribute:"sortable"})],x=[s({type:Boolean,attribute:"selectable"})],C=[s({type:Boolean,attribute:"hoverable"})],S=[s({type:Boolean,attribute:"clickable"})],E=[s({type:Boolean,attribute:"list"})],D=[s({type:Boolean,attribute:"pagination"})],A=[s({attribute:"pagination-mode"})],R=[s({type:Number,attribute:"page-size"})],M=[s({type:Number,attribute:"current-page"})],z=[s({type:Number,attribute:"total-items"})],$=[s({type:Array,attribute:!1})],F=[s({type:Number,attribute:"search-debounce"})],I=[s({attribute:!1})],T=[s({attribute:!1})],L=[s()],V=[s({type:Array,attribute:!1})],B=[s({type:String,attribute:"selector"})],O=[s({type:Array,attribute:!1})],j=[s({type:Boolean,attribute:"loading"})],N=[s({type:Boolean,attribute:"virtualize"})],P=[s({type:Number,attribute:"row-height"})],H=[s({type:Number,attribute:"virtual-buffer"})],q=[s({type:Boolean,attribute:"column-resize"})],_=[s({type:Boolean,attribute:"editable"})],G=[s({attribute:"edit-mode"})],K=[s({attribute:"density"})],W=[s({type:Boolean,attribute:"header-filters"})],U=[s({type:Boolean,attribute:"quick-filter"})],Z=[s({type:Boolean,attribute:"row-reorder"})],Y=[s({type:Boolean,attribute:"column-reorder"})],J=[s({type:Boolean,attribute:"column-menu"})],Q=[s({type:Boolean,attribute:"lazy-load"})],X=[s({type:Number,attribute:"lazy-load-threshold"})],ee=[s({type:Array,attribute:!1})],te=[s({attribute:"selection-mode"})],ie=[s({attribute:!1})],ae=[s({attribute:!1})],se=[n("table")],ne=[n("thead")],le=[n("tbody")],re=[g("table/config")],de=[g("table/data")],he=[r()],ue=[l()],me=[y("resize",".table-frame")],we=[o()],xe=[f("column-changed")],Ae=[d("selectorOptions")],Re=[d("sortable")],Me=[d("selectable")],ze=[d("columns",{immediate:!1})],$e=[d("groupBy","groupDefaults",{immediate:!1})],Fe=[d("data",{immediate:!1})],Ie=[d("loading")],Te=[d("selectedRows")],Le=[d("selectionMode",{immediate:!1})],Ve=[d("currentSort")],Be=[d("searchable","filterable","quickFilter")],Oe=[d("currentSort",{immediate:!1})],je=[d("currentPage",{immediate:!1})],Ne=[d("pageSize",{immediate:!1})],Pe=[d("density",{immediate:!1})],He=[d("list",{immediate:!1})],qe=[d("editable",{immediate:!1})],_e=[d("editMode",{immediate:!1})],Ge=[d("virtualize",{immediate:!1})],Ke=[d("rowHeight",{immediate:!1})],We=[d("columnResize",{immediate:!1})],Ue=[d("headerFilters",{immediate:!1})],Ze=[d("rowReorder",{immediate:!1})],Ye=[d("columnReorder",{immediate:!1})],Je=[d("lazyLoad","lazyLoadThreshold",{immediate:!1})],Qe=[d("columnMenu",{immediate:!1})],Xe=[h("page-change",{bubbles:!0,composed:!0})],et=[h("table-row-selection-changed",{bubbles:!0,composed:!0})],tt=[h("row-clicked",{bubbles:!0,composed:!0})],it=[h("table-load-error",{bubbles:!0,composed:!0})],at=[h("table-select-all-changed",{bubbles:!0,composed:!0})],st=[h("selection-changed",{bubbles:!0,composed:!0})],nt=[h("sort-change",{bubbles:!0,composed:!0})],lt=[h("filter-change",{bubbles:!0,composed:!0})],rt=[h("column-visibility-change",{bubbles:!0,composed:!0})],ot=[h("column-pin-change",{bubbles:!0,composed:!0})],ct=[h("column-order-change",{bubbles:!0,composed:!0})],dt=[h("density-change",{bubbles:!0,composed:!0})],ht=[u()],ut=[s({attribute:!1})],mt=[d("listRenderer",{immediate:!1})],pt=[h("group-toggle",{bubbles:!0,composed:!0})],w(this,null,re,{kind:"method",name:"getTableConfig",static:!1,private:!1,access:{has:e=>"getTableConfig"in e,get:e=>e.getTableConfig},metadata:e},null,vt),w(this,null,de,{kind:"method",name:"getTableData",static:!1,private:!1,access:{has:e=>"getTableData"in e,get:e=>e.getTableData},metadata:e},null,vt),w(this,null,he,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:e},null,vt),w(this,null,ue,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:e},null,vt),w(this,null,me,{kind:"method",name:"handleFrameResize",static:!1,private:!1,access:{has:e=>"handleFrameResize"in e,get:e=>e.handleFrameResize},metadata:e},null,vt),w(this,null,we,{kind:"method",name:"initialize",static:!1,private:!1,access:{has:e=>"initialize"in e,get:e=>e.initialize},metadata:e},null,vt),w(this,null,xe,{kind:"method",name:"handleDeclarativeColumnChange",static:!1,private:!1,access:{has:e=>"handleDeclarativeColumnChange"in e,get:e=>e.handleDeclarativeColumnChange},metadata:e},null,vt),w(this,null,Ae,{kind:"method",name:"handleSelectorOptionsChange",static:!1,private:!1,access:{has:e=>"handleSelectorOptionsChange"in e,get:e=>e.handleSelectorOptionsChange},metadata:e},null,vt),w(this,null,Re,{kind:"method",name:"handleSortableChange",static:!1,private:!1,access:{has:e=>"handleSortableChange"in e,get:e=>e.handleSortableChange},metadata:e},null,vt),w(this,null,Me,{kind:"method",name:"handleSelectableChange",static:!1,private:!1,access:{has:e=>"handleSelectableChange"in e,get:e=>e.handleSelectableChange},metadata:e},null,vt),w(this,null,ze,{kind:"method",name:"handleColumnsAssignment",static:!1,private:!1,access:{has:e=>"handleColumnsAssignment"in e,get:e=>e.handleColumnsAssignment},metadata:e},null,vt),w(this,null,$e,{kind:"method",name:"handleGroupByChange",static:!1,private:!1,access:{has:e=>"handleGroupByChange"in e,get:e=>e.handleGroupByChange},metadata:e},null,vt),w(this,null,Fe,{kind:"method",name:"handleDataAssignment",static:!1,private:!1,access:{has:e=>"handleDataAssignment"in e,get:e=>e.handleDataAssignment},metadata:e},null,vt),w(this,null,Ie,{kind:"method",name:"handleDataChange",static:!1,private:!1,access:{has:e=>"handleDataChange"in e,get:e=>e.handleDataChange},metadata:e},null,vt),w(this,null,Te,{kind:"method",name:"handleSelectedRowsChange",static:!1,private:!1,access:{has:e=>"handleSelectedRowsChange"in e,get:e=>e.handleSelectedRowsChange},metadata:e},null,vt),w(this,null,Le,{kind:"method",name:"handleSelectionModeChange",static:!1,private:!1,access:{has:e=>"handleSelectionModeChange"in e,get:e=>e.handleSelectionModeChange},metadata:e},null,vt),w(this,null,Ve,{kind:"method",name:"handleSortChange",static:!1,private:!1,access:{has:e=>"handleSortChange"in e,get:e=>e.handleSortChange},metadata:e},null,vt),w(this,null,Be,{kind:"method",name:"handleControlsChange",static:!1,private:!1,access:{has:e=>"handleControlsChange"in e,get:e=>e.handleControlsChange},metadata:e},null,vt),w(this,null,Oe,{kind:"method",name:"handleControlledSort",static:!1,private:!1,access:{has:e=>"handleControlledSort"in e,get:e=>e.handleControlledSort},metadata:e},null,vt),w(this,null,je,{kind:"method",name:"handleCurrentPageChange",static:!1,private:!1,access:{has:e=>"handleCurrentPageChange"in e,get:e=>e.handleCurrentPageChange},metadata:e},null,vt),w(this,null,Ne,{kind:"method",name:"handlePageSizeChange",static:!1,private:!1,access:{has:e=>"handlePageSizeChange"in e,get:e=>e.handlePageSizeChange},metadata:e},null,vt),w(this,null,Pe,{kind:"method",name:"handleDensityChange",static:!1,private:!1,access:{has:e=>"handleDensityChange"in e,get:e=>e.handleDensityChange},metadata:e},null,vt),w(this,null,He,{kind:"method",name:"handleListChange",static:!1,private:!1,access:{has:e=>"handleListChange"in e,get:e=>e.handleListChange},metadata:e},null,vt),w(this,null,qe,{kind:"method",name:"handleEditableChange",static:!1,private:!1,access:{has:e=>"handleEditableChange"in e,get:e=>e.handleEditableChange},metadata:e},null,vt),w(this,null,_e,{kind:"method",name:"handleEditModeChange",static:!1,private:!1,access:{has:e=>"handleEditModeChange"in e,get:e=>e.handleEditModeChange},metadata:e},null,vt),w(this,null,Ge,{kind:"method",name:"handleVirtualizeChange",static:!1,private:!1,access:{has:e=>"handleVirtualizeChange"in e,get:e=>e.handleVirtualizeChange},metadata:e},null,vt),w(this,null,Ke,{kind:"method",name:"handleRowHeightChange",static:!1,private:!1,access:{has:e=>"handleRowHeightChange"in e,get:e=>e.handleRowHeightChange},metadata:e},null,vt),w(this,null,We,{kind:"method",name:"handleColumnResizeChange",static:!1,private:!1,access:{has:e=>"handleColumnResizeChange"in e,get:e=>e.handleColumnResizeChange},metadata:e},null,vt),w(this,null,Ue,{kind:"method",name:"handleHeaderFiltersChange",static:!1,private:!1,access:{has:e=>"handleHeaderFiltersChange"in e,get:e=>e.handleHeaderFiltersChange},metadata:e},null,vt),w(this,null,Ze,{kind:"method",name:"handleRowReorderChange",static:!1,private:!1,access:{has:e=>"handleRowReorderChange"in e,get:e=>e.handleRowReorderChange},metadata:e},null,vt),w(this,null,Ye,{kind:"method",name:"handleColumnReorderChange",static:!1,private:!1,access:{has:e=>"handleColumnReorderChange"in e,get:e=>e.handleColumnReorderChange},metadata:e},null,vt),w(this,null,Je,{kind:"method",name:"handleLazyLoadChange",static:!1,private:!1,access:{has:e=>"handleLazyLoadChange"in e,get:e=>e.handleLazyLoadChange},metadata:e},null,vt),w(this,null,Qe,{kind:"method",name:"handleColumnMenuChange",static:!1,private:!1,access:{has:e=>"handleColumnMenuChange"in e,get:e=>e.handleColumnMenuChange},metadata:e},null,vt),w(this,null,Xe,{kind:"method",name:"dispatchPageChange",static:!1,private:!1,access:{has:e=>"dispatchPageChange"in e,get:e=>e.dispatchPageChange},metadata:e},null,vt),w(this,null,et,{kind:"method",name:"dispatchRowSelectionChanged",static:!1,private:!1,access:{has:e=>"dispatchRowSelectionChanged"in e,get:e=>e.dispatchRowSelectionChanged},metadata:e},null,vt),w(this,null,tt,{kind:"method",name:"dispatchRowClicked",static:!1,private:!1,access:{has:e=>"dispatchRowClicked"in e,get:e=>e.dispatchRowClicked},metadata:e},null,vt),w(this,null,it,{kind:"method",name:"dispatchLoadError",static:!1,private:!1,access:{has:e=>"dispatchLoadError"in e,get:e=>e.dispatchLoadError},metadata:e},null,vt),w(this,null,at,{kind:"method",name:"dispatchSelectAllChanged",static:!1,private:!1,access:{has:e=>"dispatchSelectAllChanged"in e,get:e=>e.dispatchSelectAllChanged},metadata:e},null,vt),w(this,null,st,{kind:"method",name:"dispatchSelectionChanged",static:!1,private:!1,access:{has:e=>"dispatchSelectionChanged"in e,get:e=>e.dispatchSelectionChanged},metadata:e},null,vt),w(this,null,nt,{kind:"method",name:"dispatchSortChange",static:!1,private:!1,access:{has:e=>"dispatchSortChange"in e,get:e=>e.dispatchSortChange},metadata:e},null,vt),w(this,null,lt,{kind:"method",name:"dispatchFilterChange",static:!1,private:!1,access:{has:e=>"dispatchFilterChange"in e,get:e=>e.dispatchFilterChange},metadata:e},null,vt),w(this,null,rt,{kind:"method",name:"dispatchColumnVisibilityChange",static:!1,private:!1,access:{has:e=>"dispatchColumnVisibilityChange"in e,get:e=>e.dispatchColumnVisibilityChange},metadata:e},null,vt),w(this,null,ot,{kind:"method",name:"dispatchColumnPinChange",static:!1,private:!1,access:{has:e=>"dispatchColumnPinChange"in e,get:e=>e.dispatchColumnPinChange},metadata:e},null,vt),w(this,null,ct,{kind:"method",name:"dispatchColumnOrderChange",static:!1,private:!1,access:{has:e=>"dispatchColumnOrderChange"in e,get:e=>e.dispatchColumnOrderChange},metadata:e},null,vt),w(this,null,dt,{kind:"method",name:"dispatchDensityChange",static:!1,private:!1,access:{has:e=>"dispatchDensityChange"in e,get:e=>e.dispatchDensityChange},metadata:e},null,vt),w(this,null,ht,{kind:"method",name:"cleanup",static:!1,private:!1,access:{has:e=>"cleanup"in e,get:e=>e.cleanup},metadata:e},null,vt),w(this,null,mt,{kind:"method",name:"handleListRendererChange",static:!1,private:!1,access:{has:e=>"handleListRendererChange"in e,get:e=>e.handleListRendererChange},metadata:e},null,vt),w(this,null,pt,{kind:"method",name:"dispatchGroupToggle",static:!1,private:!1,access:{has:e=>"dispatchGroupToggle"in e,get:e=>e.dispatchGroupToggle},metadata:e},null,vt),w(null,null,c,{kind:"field",name:"striped",static:!1,private:!1,access:{has:e=>"striped"in e,get:e=>e.striped,set:(e,t)=>{e.striped=t}},metadata:e},yt,wt),w(null,null,p,{kind:"field",name:"searchable",static:!1,private:!1,access:{has:e=>"searchable"in e,get:e=>e.searchable,set:(e,t)=>{e.searchable=t}},metadata:e},kt,xt),w(null,null,b,{kind:"field",name:"filterable",static:!1,private:!1,access:{has:e=>"filterable"in e,get:e=>e.filterable,set:(e,t)=>{e.filterable=t}},metadata:e},Ct,St),w(null,null,v,{kind:"field",name:"sortable",static:!1,private:!1,access:{has:e=>"sortable"in e,get:e=>e.sortable,set:(e,t)=>{e.sortable=t}},metadata:e},Et,Dt),w(null,null,x,{kind:"field",name:"selectable",static:!1,private:!1,access:{has:e=>"selectable"in e,get:e=>e.selectable,set:(e,t)=>{e.selectable=t}},metadata:e},At,Rt),w(null,null,C,{kind:"field",name:"hoverable",static:!1,private:!1,access:{has:e=>"hoverable"in e,get:e=>e.hoverable,set:(e,t)=>{e.hoverable=t}},metadata:e},Mt,zt),w(null,null,S,{kind:"field",name:"clickable",static:!1,private:!1,access:{has:e=>"clickable"in e,get:e=>e.clickable,set:(e,t)=>{e.clickable=t}},metadata:e},$t,Ft),w(null,null,E,{kind:"field",name:"list",static:!1,private:!1,access:{has:e=>"list"in e,get:e=>e.list,set:(e,t)=>{e.list=t}},metadata:e},It,Tt),w(null,null,D,{kind:"field",name:"pagination",static:!1,private:!1,access:{has:e=>"pagination"in e,get:e=>e.pagination,set:(e,t)=>{e.pagination=t}},metadata:e},Lt,Vt),w(null,null,A,{kind:"field",name:"paginationMode",static:!1,private:!1,access:{has:e=>"paginationMode"in e,get:e=>e.paginationMode,set:(e,t)=>{e.paginationMode=t}},metadata:e},Bt,Ot),w(null,null,R,{kind:"field",name:"pageSize",static:!1,private:!1,access:{has:e=>"pageSize"in e,get:e=>e.pageSize,set:(e,t)=>{e.pageSize=t}},metadata:e},jt,Nt),w(null,null,M,{kind:"field",name:"currentPage",static:!1,private:!1,access:{has:e=>"currentPage"in e,get:e=>e.currentPage,set:(e,t)=>{e.currentPage=t}},metadata:e},Pt,Ht),w(null,null,z,{kind:"field",name:"totalItems",static:!1,private:!1,access:{has:e=>"totalItems"in e,get:e=>e.totalItems,set:(e,t)=>{e.totalItems=t}},metadata:e},qt,_t),w(null,null,$,{kind:"field",name:"pageSizes",static:!1,private:!1,access:{has:e=>"pageSizes"in e,get:e=>e.pageSizes,set:(e,t)=>{e.pageSizes=t}},metadata:e},Gt,Kt),w(null,null,F,{kind:"field",name:"searchDebounce",static:!1,private:!1,access:{has:e=>"searchDebounce"in e,get:e=>e.searchDebounce,set:(e,t)=>{e.searchDebounce=t}},metadata:e},Wt,Ut),w(null,null,I,{kind:"field",name:"columns",static:!1,private:!1,access:{has:e=>"columns"in e,get:e=>e.columns,set:(e,t)=>{e.columns=t}},metadata:e},Zt,Yt),w(null,null,T,{kind:"field",name:"data",static:!1,private:!1,access:{has:e=>"data"in e,get:e=>e.data,set:(e,t)=>{e.data=t}},metadata:e},Jt,Qt),w(null,null,L,{kind:"field",name:"mode",static:!1,private:!1,access:{has:e=>"mode"in e,get:e=>e.mode,set:(e,t)=>{e.mode=t}},metadata:e},Xt,ei),w(null,null,V,{kind:"field",name:"currentSort",static:!1,private:!1,access:{has:e=>"currentSort"in e,get:e=>e.currentSort,set:(e,t)=>{e.currentSort=t}},metadata:e},ti,ii),w(null,null,B,{kind:"field",name:"selector",static:!1,private:!1,access:{has:e=>"selector"in e,get:e=>e.selector,set:(e,t)=>{e.selector=t}},metadata:e},ai,si),w(null,null,O,{kind:"field",name:"selectorOptions",static:!1,private:!1,access:{has:e=>"selectorOptions"in e,get:e=>e.selectorOptions,set:(e,t)=>{e.selectorOptions=t}},metadata:e},ni,li),w(null,null,j,{kind:"field",name:"loading",static:!1,private:!1,access:{has:e=>"loading"in e,get:e=>e.loading,set:(e,t)=>{e.loading=t}},metadata:e},ri,oi),w(null,null,N,{kind:"field",name:"virtualize",static:!1,private:!1,access:{has:e=>"virtualize"in e,get:e=>e.virtualize,set:(e,t)=>{e.virtualize=t}},metadata:e},ci,di),w(null,null,P,{kind:"field",name:"rowHeight",static:!1,private:!1,access:{has:e=>"rowHeight"in e,get:e=>e.rowHeight,set:(e,t)=>{e.rowHeight=t}},metadata:e},hi,ui),w(null,null,H,{kind:"field",name:"virtualBuffer",static:!1,private:!1,access:{has:e=>"virtualBuffer"in e,get:e=>e.virtualBuffer,set:(e,t)=>{e.virtualBuffer=t}},metadata:e},mi,pi),w(null,null,q,{kind:"field",name:"columnResize",static:!1,private:!1,access:{has:e=>"columnResize"in e,get:e=>e.columnResize,set:(e,t)=>{e.columnResize=t}},metadata:e},gi,bi),w(null,null,_,{kind:"field",name:"editable",static:!1,private:!1,access:{has:e=>"editable"in e,get:e=>e.editable,set:(e,t)=>{e.editable=t}},metadata:e},fi,vi),w(null,null,G,{kind:"field",name:"editMode",static:!1,private:!1,access:{has:e=>"editMode"in e,get:e=>e.editMode,set:(e,t)=>{e.editMode=t}},metadata:e},yi,wi),w(null,null,K,{kind:"field",name:"density",static:!1,private:!1,access:{has:e=>"density"in e,get:e=>e.density,set:(e,t)=>{e.density=t}},metadata:e},ki,xi),w(null,null,W,{kind:"field",name:"headerFilters",static:!1,private:!1,access:{has:e=>"headerFilters"in e,get:e=>e.headerFilters,set:(e,t)=>{e.headerFilters=t}},metadata:e},Ci,Si),w(null,null,U,{kind:"field",name:"quickFilter",static:!1,private:!1,access:{has:e=>"quickFilter"in e,get:e=>e.quickFilter,set:(e,t)=>{e.quickFilter=t}},metadata:e},Ei,Di),w(null,null,Z,{kind:"field",name:"rowReorder",static:!1,private:!1,access:{has:e=>"rowReorder"in e,get:e=>e.rowReorder,set:(e,t)=>{e.rowReorder=t}},metadata:e},Ai,Ri),w(null,null,Y,{kind:"field",name:"columnReorder",static:!1,private:!1,access:{has:e=>"columnReorder"in e,get:e=>e.columnReorder,set:(e,t)=>{e.columnReorder=t}},metadata:e},Mi,zi),w(null,null,J,{kind:"field",name:"columnMenu",static:!1,private:!1,access:{has:e=>"columnMenu"in e,get:e=>e.columnMenu,set:(e,t)=>{e.columnMenu=t}},metadata:e},$i,Fi),w(null,null,Q,{kind:"field",name:"lazyLoad",static:!1,private:!1,access:{has:e=>"lazyLoad"in e,get:e=>e.lazyLoad,set:(e,t)=>{e.lazyLoad=t}},metadata:e},Ii,Ti),w(null,null,X,{kind:"field",name:"lazyLoadThreshold",static:!1,private:!1,access:{has:e=>"lazyLoadThreshold"in e,get:e=>e.lazyLoadThreshold,set:(e,t)=>{e.lazyLoadThreshold=t}},metadata:e},Li,Vi),w(null,null,ee,{kind:"field",name:"selectedRows",static:!1,private:!1,access:{has:e=>"selectedRows"in e,get:e=>e.selectedRows,set:(e,t)=>{e.selectedRows=t}},metadata:e},Bi,Oi),w(null,null,te,{kind:"field",name:"selectionMode",static:!1,private:!1,access:{has:e=>"selectionMode"in e,get:e=>e.selectionMode,set:(e,t)=>{e.selectionMode=t}},metadata:e},ji,Ni),w(null,null,ie,{kind:"field",name:"groupBy",static:!1,private:!1,access:{has:e=>"groupBy"in e,get:e=>e.groupBy,set:(e,t)=>{e.groupBy=t}},metadata:e},Pi,Hi),w(null,null,ae,{kind:"field",name:"groupDefaults",static:!1,private:!1,access:{has:e=>"groupDefaults"in e,get:e=>e.groupDefaults,set:(e,t)=>{e.groupDefaults=t}},metadata:e},qi,_i),w(null,null,se,{kind:"field",name:"table",static:!1,private:!1,access:{has:e=>"table"in e,get:e=>e.table,set:(e,t)=>{e.table=t}},metadata:e},Gi,Ki),w(null,null,ne,{kind:"field",name:"thead",static:!1,private:!1,access:{has:e=>"thead"in e,get:e=>e.thead,set:(e,t)=>{e.thead=t}},metadata:e},Wi,Ui),w(null,null,le,{kind:"field",name:"tbody",static:!1,private:!1,access:{has:e=>"tbody"in e,get:e=>e.tbody,set:(e,t)=>{e.tbody=t}},metadata:e},Zi,Yi),w(null,null,ut,{kind:"field",name:"listRenderer",static:!1,private:!1,access:{has:e=>"listRenderer"in e,get:e=>e.listRenderer,set:(e,t)=>{e.listRenderer=t}},metadata:e},Ji,Qi),w(null,t={value:a},gt,{kind:"class",name:a.name,metadata:e},null,bt),Xi=a=t.value,e&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}setColumns(e){this.columns=e}setData(e){this.settingDataImperative=!0,this.data=e,this.settingDataImperative=!1}async*getTableConfig(){const e=await(yield{});return this.columns=e.columns||[],this.selectorOptions=e.selectorOptions||[],await new Promise(e=>requestAnimationFrame(e)),this.renderHeader(),this.renderControls(),e}async*getTableData(){const e=++this.dataRequestSeq;this.loading=!0,this.selectedRows=[];try{const t={search:this.searchText,sort:this.currentSort,filter:this.filterEngine.getFilterModel(),selector:this.selector};this.pagination&&(t.page=this.currentPage,t.pageSize=this.pageSize);const i=await(yield t);if(e!==this.dataRequestSeq)return;if(this.data=i.data||[],this.rebuildRowIndex(),void 0!==i.totalItems&&(this.totalItems=i.totalItems),this.loadError=null,this.classList.remove("table--error"),this.loading=!1,await new Promise(e=>requestAnimationFrame(e)),e!==this.dataRequestSeq)return;return this.renderBody(),i}catch(t){if(e!==this.dataRequestSeq)return;console.error("Error loading table data:",t),this.loadError=t instanceof Error?t.message:String(t),this.classList.add("table--error"),this.dispatchLoadError(t),this.loading=!1,await new Promise(e=>requestAnimationFrame(e)),this.renderBody()}}scheduleRender(e){"header"!==e&&"both"!==e||(this.pendingHeaderRender=!0),"body"!==e&&"both"!==e||(this.pendingBodyRender=!0),this.renderQueued||(this.renderQueued=!0,queueMicrotask(()=>{queueMicrotask(()=>{this.renderQueued=!1;const e=this.pendingHeaderRender,t=this.pendingBodyRender;this.pendingHeaderRender=!1,this.pendingBodyRender=!1,e&&this.renderHeader(),t&&this.renderBody()})}))}debouncedDataRequest(){this.loading||(this.loading=!0),this.dataRequestTimeout&&clearTimeout(this.dataRequestTimeout),this.dataRequestTimeout=setTimeout(()=>{this.getTableData(),this.dataRequestTimeout=null},150)}styles(){return m`
589
+ `}getDefaultAlign(e){return["number","currency","percent","percentage","duration","filesize","accounting","scientific","fraction"].includes(e||"")?"right":["boolean","rating","image"].includes(e||"")?"center":"left"}applyCellPresentation(e,t,i){if(!e)return;const a=t=>{t&&Object.assign(e.style,t)};a(t.style);for(const s of t.conditionalFormats||[])if(s.condition(i,this.data)){a(s.style),s.className&&e.classList.add(s.className);break}t.tooltip&&(e.title="function"==typeof t.tooltip?t.tooltip(i,this.data):null==i?"":String(i))}getCellComponent(e){switch(e){case"text":return"snice-cell-text";case"number":case"accounting":case"scientific":case"fraction":return"snice-cell-number";case"date":return"snice-cell-date";case"boolean":return"snice-cell-boolean";case"sparkline":return"snice-cell-sparkline";case"rating":return"snice-cell-rating";case"progress":return"snice-cell-progress";case"duration":return"snice-cell-duration";case"filesize":return"snice-cell-filesize";case"link":case"url":return"snice-cell-link";case"actions":return"snice-cell-actions";case"tag":case"tags":case"badge":case"badges":return"snice-cell-tag";case"image":case"avatar":case"thumbnail":return"snice-cell-image";case"email":return"snice-cell-email";case"phone":case"tel":case"telephone":return"snice-cell-phone";case"status":return"snice-cell-status";case"color":return"snice-cell-color";case"json":case"object":return"snice-cell-json";case"currency":case"money":return"snice-cell-currency";case"percent":case"percentage":return"snice-cell-percentage";case"location":case"address":case"coordinates":return"snice-cell-location";default:return"snice-cell"}}getCellStyles(e){let t=[];return e.width&&(t.push(`width: ${e.width}`),t.push(`min-width: ${e.width}`),t.push(`max-width: ${e.width}`)),e.align&&t.push(`text-align: ${e.align}`),t.join("; ")}escapeHtml(e){if(null==e)return"";const t=String(e),i=document.createElement("div");return i.textContent=t,i.innerHTML}toggleSelection(){this.selected=!this.selected,this.dispatchRowSelect()}dispatchRowClick(){return{data:this.data,index:this.index,element:this}}dispatchRowSelect(){return{selected:this.selected,data:this.data,index:this.index,element:this}}dispatchRowHover(){return{data:this.data,index:this.index,element:this}}select(){!this.selectionDisabled&&this.selectable&&(this.selected=!0,this.dispatchRowSelect())}deselect(){this.selected=!1,this.dispatchRowSelect()}focusRow(){super.focus(),this.scrollIntoView({behavior:"smooth",block:"nearest"})}getCellValue(e){return this.data[e]}setCellValue(e,t){this.data={...this.data,[e]:t},this.updateCells()}getCellElement(e){const t=this.columns.find(t=>t.key===e);if(!t)return null;const i=this.columns.indexOf(t);return this.shadowRoot?.querySelector(`[data-column-index="${i}"]`)||null}highlight(e=2e3){this.classList.add("row--highlighted"),setTimeout(()=>{this.classList.remove("row--highlighted")},e)}constructor(){super(...arguments),this.selected=(k(this,V),k(this,B,!1)),this.hoverable=(k(this,O),k(this,j,!0)),this.clickable=(k(this,N),k(this,P,!1)),this.selectable=(k(this,H),k(this,q,!1)),this.selectionDisabled=(k(this,_),k(this,G,!1)),this.data=(k(this,K),k(this,W,{})),this.index=(k(this,U),k(this,Z,0)),this.columns=(k(this,Y),k(this,J,[])),k(this,Q)}})})();class oe{constructor(){this.rafId=0,this.lastStartIndex=-1,this.lastEndIndex=-1,this.enabled=!1,this.offsets=[],this.offsetsTotalRows=-1,this.topSpacer=document.createElement("tr"),this.topSpacer.className="virtual-spacer virtual-spacer--top",this.topSpacer.style.display="table-row",this.bottomSpacer=document.createElement("tr"),this.bottomSpacer.className="virtual-spacer virtual-spacer--bottom",this.bottomSpacer.style.display="table-row",this.contentContainer=document.createElement("tbody"),this.options={},this.scrollHandler=()=>{this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(()=>this.update())}}attach(e){this.options=e,this.enabled=!0,this.lastStartIndex=-1,this.lastEndIndex=-1,this.invalidateOffsets(),this.options.scrollContainer.addEventListener("scroll",this.scrollHandler,{passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),this.update()}detach(){this.enabled=!1,this.options.scrollContainer?.removeEventListener("scroll",this.scrollHandler),window.removeEventListener("resize",this.scrollHandler),cancelAnimationFrame(this.rafId)}setTotalRows(e){this.options.totalRows=e,this.invalidateOffsets(),this.lastStartIndex=-1,this.update()}refresh(){this.invalidateOffsets(),this.lastStartIndex=-1,this.lastEndIndex=-1,this.update()}update(){if(!this.enabled||!this.options.scrollContainer)return;const{bufferPx:e,totalRows:t,scrollContainer:i,renderRange:a}=this.options,s=i.scrollTop,n=this.buildOffsets(t),l=t>0?Math.max(1,n[1]-n[0]):1,r=Math.max(l,i.clientHeight),o=n[t]||0,c=Math.max(0,o-r),d=Math.min(Math.max(0,s),c);s!==d&&(i.scrollTop=d);const h=Math.max(0,d-e),u=Math.min(o,d+r+e),m=this.findRowAtOffset(n,h),p=Math.min(t,this.findFirstOffsetAtOrAfter(n,u));if(m===this.lastStartIndex&&p===this.lastEndIndex)return;this.lastStartIndex=m,this.lastEndIndex=p;const g=n[m]||0,b=Math.max(0,o-(n[p]||o));this.topSpacer.style.height=`${g}px`,this.bottomSpacer.style.height=`${b}px`;const f=a(m,p),v=this.options.scrollContainer.querySelector("tbody");if(v){v.innerHTML="";const e=this.options.renderPinnedTop?.();if(e&&v.appendChild(e),g>0){const e=document.createElement("td");e.colSpan=999,e.style.height=`${g}px`,e.style.padding="0",e.style.border="none",this.topSpacer.innerHTML="",this.topSpacer.appendChild(e),v.appendChild(this.topSpacer)}if(v.appendChild(f),b>0){const e=document.createElement("td");e.colSpan=999,e.style.height=`${b}px`,e.style.padding="0",e.style.border="none",this.bottomSpacer.innerHTML="",this.bottomSpacer.appendChild(e),v.appendChild(this.bottomSpacer)}const t=this.options.renderPinnedBottom?.();t&&v.appendChild(t),this.options.afterRender?.()}}getVisibleRange(){return{start:this.lastStartIndex,end:this.lastEndIndex}}scrollToRow(e){if(!this.options.scrollContainer)return;const t=this.offsetForIndex(e);this.options.scrollContainer.scrollTop=t}scrollToIndex(e){this.options.scrollContainer&&(this.options.scrollContainer.scrollTop=this.offsetForIndex(e),this.refresh())}getScrollPosition(){const e=this.options.scrollContainer;return{top:e?.scrollTop??0,left:e?.scrollLeft??0}}isEnabled(){return this.enabled}heightForIndex(e){const t="function"==typeof this.options.rowHeight?this.options.rowHeight(e):this.options.rowHeight;return Number.isFinite(t)&&t>0?t:1}buildOffsets(e){if(this.offsetsTotalRows===e&&this.offsets.length===e+1)return this.offsets;this.offsets=new Array(e+1),this.offsets[0]=0;for(let t=0;t<e;t++)this.offsets[t+1]=this.offsets[t]+this.heightForIndex(t);return this.offsetsTotalRows=e,this.offsets}invalidateOffsets(){this.offsets=[],this.offsetsTotalRows=-1}offsetForIndex(e){const t=Math.max(0,Math.min(e,this.options.totalRows));return this.buildOffsets(this.options.totalRows)[t]||0}findRowAtOffset(e,t){const i=e.length-1;if(i<=0)return 0;let a=0,s=i;for(;a<s;){const i=Math.floor((a+s)/2);e[i+1]<=t?a=i+1:s=i}return Math.min(i,a)}findFirstOffsetAtOrAfter(e,t){let i=0,a=e.length-1;for(;i<a;){const s=Math.floor((i+a)/2);e[s]<t?i=s+1:a=s}return i}}class ce{constructor(){this.states=new Map,this.groups=[],this.resizeStartX=0,this.resizeStartWidth=0,this.resizingKey=null,this.resizeOverlay=null,this.tableElement=null}initialize(e,t){this.tableElement=t,e.forEach((e,t)=>{const i=this.states.get(e.key);this.states.set(e.key,{key:e.key,width:i?.width??this.parseWidth(e.width)??150,flex:e.flex,minWidth:e.minWidth??50,maxWidth:e.maxWidth??1/0,visible:i?.visible??!0,pinned:i?.pinned??(e.pinned||!1),order:i?.order??t,resizable:!1!==e.resizable,reorderable:!1!==e.reorderable,hideable:!1!==e.hideable,pinnable:!1!==e.pinnable})})}parseWidth(e){if(!e)return;const t=parseInt(e,10);return isNaN(t)?void 0:t}getVisibleColumns(){return Array.from(this.states.values()).filter(e=>e.visible).sort((e,t)=>e.order-t.order)}getAllStates(){return Array.from(this.states.values()).sort((e,t)=>e.order-t.order)}getPinnedLeft(){return this.getVisibleColumns().filter(e=>"left"===e.pinned)}getPinnedRight(){return this.getVisibleColumns().filter(e=>"right"===e.pinned)}getUnpinned(){return this.getVisibleColumns().filter(e=>!e.pinned)}computeFlexWidths(e){const t=this.getVisibleColumns(),i=new Map;let a=0;const s=[];for(const e of t)e.flex&&e.flex>0?s.push(e):(a+=e.width,i.set(e.key,e.width));const n=Math.max(0,e-a),l=s.reduce((e,t)=>e+(t.flex||1),0);for(const e of s){const t=Math.max(e.minWidth,Math.min(e.maxWidth,(e.flex||1)/l*n));i.set(e.key,t)}return i}applyWidths(e,t){e.querySelectorAll("th[data-key]").forEach(e=>{const i=e.getAttribute("data-key");i&&t.has(i)&&(e.style.width=`${t.get(i)}px`)})}startResize(e,t){const i=this.states.get(e);if(!i||!i.resizable)return;this.resizingKey=e,this.resizeStartX=t,this.resizeStartWidth=i.width,this.resizeOverlay=document.createElement("div"),this.resizeOverlay.style.cssText="position:fixed;inset:0;z-index:99999;cursor:col-resize;",document.body.appendChild(this.resizeOverlay);const a=t=>{t.preventDefault();const a=Math.max(i.minWidth,Math.min(i.maxWidth,this.resizeStartWidth+(t.clientX-this.resizeStartX)));i.width=a,i.flex=void 0;const s=this.tableElement?.shadowRoot;if(s){const t=s.querySelector(`th[data-key="${e}"]`);t&&(t.style.width=`${a}px`),s.querySelectorAll(`td[data-key="${e}"]`).forEach(e=>e.style.width=`${a}px`)}this.tableElement?.dispatchEvent(new CustomEvent("column-resize",{detail:{key:e,width:a},bubbles:!0,composed:!0}))},s=()=>{this.resizingKey=null,this.resizeOverlay?.remove(),this.resizeOverlay=null,document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",s),this.tableElement?.dispatchEvent(new CustomEvent("column-resize-end",{detail:{key:e,width:i.width},bubbles:!0,composed:!0}))};document.addEventListener("mousemove",a),document.addEventListener("mouseup",s)}autoSizeColumn(e,t){const i=this.states.get(e);if(!i)return;const a=this.tableElement?.shadowRoot?.querySelector(`th[data-key="${e}"]`);let s=a?a.scrollWidth:0;t.querySelectorAll(`td[data-key="${e}"]`).forEach(e=>{s=Math.max(s,e.scrollWidth)}),i.width=Math.max(i.minWidth,Math.min(i.maxWidth,s+16)),i.flex=void 0}autoSizeAll(e){for(const t of this.states.keys())this.autoSizeColumn(t,e)}setColumnVisible(e,t){const i=this.states.get(e);i&&i.hideable&&(i.visible=t)}showAllColumns(){for(const e of this.states.values())e.visible=!0}hideAllColumns(){for(const e of this.states.values())e.hideable&&(e.visible=!1)}getVisibilityModel(){const e={};for(const[t,i]of this.states)e[t]=i.visible;return e}moveColumn(e,t){const i=this.states.get(e);if(!i||!i.reorderable||i.pinned)return;const a=this.getVisibleColumns(),s=a.findIndex(t=>t.key===e);-1!==s&&s!==t&&(a.splice(s,1),a.splice(t,0,i),a.forEach((e,t)=>{e.order=t}))}pinColumn(e,t){const i=this.states.get(e);i&&i.pinnable&&(i.pinned=t)}unpinColumn(e){const t=this.states.get(e);t&&(t.pinned=!1)}setColumnGroups(e){this.groups=e}getColumnGroups(){return this.groups}renderGroupHeaders(e=this.getVisibleColumns().map(e=>e.key)){if(0===this.groups.length)return"";const t=new Map;for(const e of this.groups)for(const i of e.children)t.set(i,e);const i=[];for(const a of e){if(!this.states.get(a)?.visible)continue;const e=t.get(a)??null,s=i[i.length-1];s&&s.group===e?s.span++:i.push({group:e,span:1})}return i.map(({group:e,span:t})=>e?`<th colspan="${t}" class="column-group-header ${e.headerClass||""}">${e.label}</th>`:`<th colspan="${t}" class="column-group-header column-group-header--ungrouped" aria-hidden="true"></th>`).join("")}isResizing(){return null!==this.resizingKey}getState(e){return this.states.get(e)}getPinnedLeftOffsets(){const e=new Map;let t=0;for(const i of this.getPinnedLeft())e.set(i.key,t),t+=i.width;return e}getPinnedRightOffsets(){const e=new Map,t=this.getPinnedRight();let i=0;for(let a=t.length-1;a>=0;a--)e.set(t[a].key,i),i+=t[a].width;return e}}const de=[{value:"contains",label:"contains",requiresValue:!0},{value:"notContains",label:"does not contain",requiresValue:!0},{value:"equals",label:"equals",requiresValue:!0},{value:"notEquals",label:"does not equal",requiresValue:!0},{value:"startsWith",label:"starts with",requiresValue:!0},{value:"endsWith",label:"ends with",requiresValue:!0},{value:"isEmpty",label:"is empty",requiresValue:!1},{value:"isNotEmpty",label:"is not empty",requiresValue:!1}],he=[{value:"eq",label:"=",requiresValue:!0},{value:"neq",label:"≠",requiresValue:!0},{value:"gt",label:">",requiresValue:!0},{value:"gte",label:"≥",requiresValue:!0},{value:"lt",label:"<",requiresValue:!0},{value:"lte",label:"≤",requiresValue:!0},{value:"isEmpty",label:"is empty",requiresValue:!1},{value:"isNotEmpty",label:"is not empty",requiresValue:!1}],ue=[{value:"is",label:"is",requiresValue:!0},{value:"isNot",label:"is not",requiresValue:!0},{value:"before",label:"before",requiresValue:!0},{value:"onOrBefore",label:"on or before",requiresValue:!0},{value:"after",label:"after",requiresValue:!0},{value:"onOrAfter",label:"on or after",requiresValue:!0},{value:"isEmpty",label:"is empty",requiresValue:!1},{value:"isNotEmpty",label:"is not empty",requiresValue:!1}],me=[{value:"isTrue",label:"is true",requiresValue:!1},{value:"isFalse",label:"is false",requiresValue:!1}];class pe{constructor(){this.model={filters:[],logic:"and"},this.headerFilters=new Map}getOperatorsForType(e){switch(e){case"number":case"currency":case"rating":case"progress":case"filesize":case"duration":case"percent":case"percentage":return he;case"date":return ue;case"boolean":return me;default:return de}}setFilterModel(e){this.model=e}getFilterModel(){return{...this.model}}setColumnFilter(e,t,i){const a=this.model.filters.findIndex(t=>t.column===e);a>=0?this.model.filters[a]={column:e,operator:t,value:i}:this.model.filters.push({column:e,operator:t,value:i})}removeColumnFilter(e){this.model.filters=this.model.filters.filter(t=>t.column!==e)}clearAllFilters(){this.model.filters=[],this.model.quickFilter=void 0,this.model.logic="and",this.headerFilters.clear()}setQuickFilter(e){this.model.quickFilter=e||void 0}setHeaderFilter(e,t){t?this.headerFilters.set(e,t):this.headerFilters.delete(e)}getHeaderFilter(e){return this.headerFilters.get(e)||""}setFilterLogic(e){this.model.logic=e}hasActiveFilters(){return this.model.filters.length>0||!!this.model.quickFilter||this.headerFilters.size>0}hasColumnFilter(e){return this.model.filters.some(t=>t.column===e)||this.headerFilters.has(e)}getActiveFilterCount(){return this.model.filters.length+this.headerFilters.size+(this.model.quickFilter?1:0)}applyFilters(e,t){let i=e;this.model.filters.length>0&&(i=i.filter(e=>{const t=this.model.filters.map(t=>this.evaluateFilter(t,e));return"and"===this.model.logic?t.every(Boolean):t.some(Boolean)}));for(const[e,t]of this.headerFilters){const a=t.toLowerCase();i=i.filter(t=>{const i=t[e];return null!=i&&String(i).toLowerCase().includes(a)})}if(this.model.quickFilter){const e=this.model.quickFilter.toLowerCase().split(/\s+/).filter(Boolean),a=t.map(e=>e.key),s=this.model.quickFilterLogic||"and";i=i.filter(t=>{const i=e=>a.some(i=>{const a=t[i];return null!=a&&String(a).toLowerCase().includes(e)});return"and"===s?e.every(i):e.some(i)})}return i}evaluateFilter(e,t){const i=t[e.column],a=e.value;switch(e.operator){case"contains":return null!=i&&String(i).toLowerCase().includes(String(a).toLowerCase());case"notContains":return null==i||!String(i).toLowerCase().includes(String(a).toLowerCase());case"equals":return String(i??"").toLowerCase()===String(a).toLowerCase();case"notEquals":return String(i??"").toLowerCase()!==String(a).toLowerCase();case"startsWith":return null!=i&&String(i).toLowerCase().startsWith(String(a).toLowerCase());case"endsWith":return null!=i&&String(i).toLowerCase().endsWith(String(a).toLowerCase());case"isEmpty":return null==i||""===i;case"isNotEmpty":return null!=i&&""!==i;case"eq":return Number(i)===Number(a);case"neq":return Number(i)!==Number(a);case"gt":return Number(i)>Number(a);case"gte":return Number(i)>=Number(a);case"lt":return Number(i)<Number(a);case"lte":return Number(i)<=Number(a);case"is":return new Date(i).toDateString()===new Date(a).toDateString();case"isNot":return new Date(i).toDateString()!==new Date(a).toDateString();case"before":return new Date(i)<new Date(a);case"onOrBefore":return new Date(i)<=new Date(a);case"after":return new Date(i)>new Date(a);case"onOrAfter":return new Date(i)>=new Date(a);case"isTrue":return!0===i||"true"===i||1===i;case"isFalse":return!1===i||"false"===i||0===i||null==i;default:return!0}}toServerParams(){return{filters:this.model.filters,filterLogic:this.model.logic,quickFilter:this.model.quickFilter,headerFilters:Object.fromEntries(this.headerFilters)}}}class ge{constructor(){this.cellState=null,this.rowState=null,this.pipelines=new Map,this.validators=new Map,this.editableColumns=new Set,this.editabilityCheck=null,this.tableElement=null,this.mode="cell"}attach(e){this.tableElement=e}setEditableColumns(e){this.editableColumns=new Set(e)}setEditabilityCheck(e){this.editabilityCheck=e}setEditMode(e){this.mode=e}setPipeline(e,t){this.pipelines.set(e,t)}setValidation(e,t){this.validators.set(e,t)}isCellEditable(e,t){return!!this.editableColumns.has(t)&&(!this.editabilityCheck||this.editabilityCheck(e,t))}getDisplayValue(e,t,i){const a=this.pipelines.get(e);let s=t;return a?.valueGetter&&(s=a.valueGetter(s,i)),a?.valueFormatter?a.valueFormatter(s,i):null==s?"":String(s)}getSortValue(e,t,i){const a=this.pipelines.get(e);return a?.valueGetter?a.valueGetter(t,i):t}getEditorType(e){switch(e){case"number":case"currency":case"rating":case"progress":return"number";case"date":return"date";case"boolean":return"boolean";case"select":return"select";default:return"text"}}startCellEdit(e,t,i,a,s){return this.isCellEditable(a,t)?(this.cellState?.isEditing&&this.cancelCellEdit(),this.cellState={rowIndex:e,columnKey:t,rowData:a,originalValue:i,currentValue:i,editorType:this.getEditorType(s||""),error:null,isEditing:!0},this.cellState):null}updateCellValue(e){this.cellState&&(this.cellState.currentValue=e,this.cellState.error=null)}async commitCellEdit(){if(!this.cellState?.isEditing)return null;const{columnKey:e,currentValue:t,rowIndex:i,rowData:a}=this.cellState,s=this.pipelines.get(e);let n=t;s?.valueParser&&(n=s.valueParser(String(t),a));const l=this.validators.get(e);if(l){const e=await l.validate(n,a);if(e)return this.cellState.error=e,e}if(s?.valueSetter){const t=s.valueSetter(n,a);t&&"object"==typeof t&&!Array.isArray(t)?(Object.assign(a,t),n=a[e]):void 0!==t&&(n=t)}return this.tableElement?.dispatchEvent(new CustomEvent("cell-edit-commit",{detail:{rowIndex:i,columnKey:e,oldValue:this.cellState.originalValue,newValue:n},bubbles:!0,composed:!0})),this.cellState.isEditing=!1,this.cellState=null,null}cancelCellEdit(){this.cellState?.isEditing&&(this.tableElement?.dispatchEvent(new CustomEvent("cell-edit-cancel",{detail:{rowIndex:this.cellState.rowIndex,columnKey:this.cellState.columnKey},bubbles:!0,composed:!0})),this.cellState.isEditing=!1,this.cellState=null)}getCellEditState(){return this.cellState}startRowEdit(e,t){return this.rowState?.isEditing&&this.cancelRowEdit(),this.rowState={rowIndex:e,originalRow:{...t},editedRow:{...t},errors:new Map,isEditing:!0},this.rowState}updateRowField(e,t){this.rowState&&(this.rowState.editedRow[e]=t,this.rowState.errors.delete(e))}async commitRowEdit(){if(!this.rowState?.isEditing)return null;const e=new Map,t={...this.rowState.editedRow};for(const[e,i]of this.pipelines)i.valueParser&&e in t&&(t[e]=i.valueParser(String(t[e]),t));for(const i of this.editableColumns){const a=this.validators.get(i);if(a){const s=t[i],n=await a.validate(s,t);n&&e.set(i,n)}}if(e.size>0)return this.rowState.errors=e,e;let i={...t};for(const[e,t]of this.pipelines)if(t.valueSetter&&e in i){const a=t.valueSetter(i[e],i);a&&"object"==typeof a&&!Array.isArray(a)?i={...i,...a}:void 0!==a&&(i[e]=a)}return this.tableElement?.dispatchEvent(new CustomEvent("row-edit-commit",{detail:{rowIndex:this.rowState.rowIndex,oldRow:this.rowState.originalRow,newRow:i},bubbles:!0,composed:!0})),this.rowState.isEditing=!1,this.rowState=null,null}cancelRowEdit(){this.rowState?.isEditing&&(this.tableElement?.dispatchEvent(new CustomEvent("row-edit-cancel",{detail:{rowIndex:this.rowState.rowIndex},bubbles:!0,composed:!0})),this.rowState.isEditing=!1,this.rowState=null)}getRowEditState(){return this.rowState}isEditing(){return(this.cellState?.isEditing||this.rowState?.isEditing)??!1}createEditor(e,t,i){switch(e){case"number":{const e=document.createElement("input");return e.type="number",e.value=null==t?"":String(t),e.className="table-editor-input",e}case"date":{const e=document.createElement("input");return e.type="date",e.value=t||"",e.className="table-editor-input",e}case"boolean":{const e=document.createElement("input");return e.type="checkbox",e.checked=!!t,e.className="table-editor-checkbox",e}case"select":{const e=document.createElement("select");return e.className="table-editor-select",(i?.selectOptions||[]).forEach(i=>{const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.value===String(t)&&(a.selected=!0),e.appendChild(a)}),e}default:{const e=document.createElement("input");return e.type="text",e.value=null==t?"":String(t),e.className="table-editor-input",e}}}}class be{constructor(){this.focusedRow=-1,this.hasUserInteracted=!1,this.focusedCol=0,this.attached=!1,this.options={},this.keyHandler=e=>this.handleKeyDown(e)}attach(e){this.options=e;const t=e.shadowRoot;t&&(t.addEventListener("keydown",this.keyHandler),this.attached=!0,this.syncGridRole(),this.applyARIA())}detach(){this.options.shadowRoot?.removeEventListener("keydown",this.keyHandler),this.attached=!1}syncGridRole(){const e=this.getTable();e&&(e.setAttribute("role","grid"),e.setAttribute("tabindex","0"),e.setAttribute("aria-rowcount",String(this.ariaRowCount+1)),e.setAttribute("aria-colcount",String(this.totalColCount)))}refresh(){this.attached&&(this.syncGridRole(),this.applyARIA())}getTable(){return this.options.shadowRoot?.querySelector("table")??null}resolveBound(e){return"function"==typeof e?e():e??0}get totalRowCount(){return this.resolveBound(this.options.totalRows)}get totalColCount(){return this.resolveBound(this.options.totalColumns)}get ariaRowCount(){return this.resolveBound(this.options.ariaRows??this.options.totalRows)}get ariaRowOffset(){return Math.max(0,this.resolveBound(this.options.ariaRowOffset))}getBodyRow(e){if(this.options.getRowElement)return this.options.getRowElement(e);const t=this.getTable();return t?t.querySelector(`tbody tr[data-index="${e}"]`):null}applyARIA(){const e=this.getTable();if(!e)return;e.setAttribute("aria-rowcount",String(this.ariaRowCount+1)),e.setAttribute("aria-colcount",String(this.totalColCount));const t=e.querySelector("thead tr.column-header-row")??e.querySelector("thead tr:not(.column-group-row):not(.header-filter-row)");t&&(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1"),t.querySelectorAll("th").forEach((e,t)=>{if(e.setAttribute("role","columnheader"),e.setAttribute("aria-colindex",String(t+1)),e.classList.contains("sortable")){const t=e.querySelector(".sort-indicator.active");if(t){const i=t.textContent?.trim()||"";i.includes("▲")?e.setAttribute("aria-sort","ascending"):i.includes("▼")&&e.setAttribute("aria-sort","descending")}else e.setAttribute("aria-sort","none")}})),e.querySelectorAll("tbody tr:not(.virtual-spacer):not(.table-fill-row)").forEach((e,t)=>{e.setAttribute("role","row"),e.setAttribute("aria-rowindex",String(this.ariaRowOffset+t+2)),"true"===e.getAttribute("data-selected")?e.setAttribute("aria-selected","true"):e.removeAttribute("aria-selected"),e.querySelectorAll("td").forEach((e,t)=>{e.setAttribute("role","gridcell"),e.setAttribute("aria-colindex",String(t+1))})}),this.updateFocusIndicator()}setFocus(e,t){this.focusedRow=e,this.focusedCol=t,this.updateFocusIndicator()}getFocus(){return{row:this.focusedRow,col:this.focusedCol}}updateFocusIndicator(){if(!this.hasUserInteracted)return;const e=this.getTable();if(!e)return;e.querySelectorAll("[data-grid-focus]").forEach(e=>{e.removeAttribute("data-grid-focus"),e.removeAttribute("tabindex")});let t=null;if(-1===this.focusedRow)t=e.querySelectorAll("thead th")[this.focusedCol];else{let e=this.getBodyRow(this.focusedRow);e||(this.options.ensureRowVisible?.(this.focusedRow),e=this.getBodyRow(this.focusedRow)),e&&(t=e.querySelectorAll("td")[this.focusedCol])}t&&(t.setAttribute("data-grid-focus","true"),t.setAttribute("tabindex","0"))}handleKeyDown(e){if(this.options.isEditing())return;if(e.composedPath().some(e=>e instanceof Element&&e.matches('button, a, input, select, textarea, [contenteditable="true"], snice-button, snice-checkbox, snice-input, snice-select')))return;this.hasUserInteracted=!0;const t=this.totalRowCount,i=this.totalColCount;switch(e.key){case"ArrowDown":e.preventDefault(),this.focusedRow=Math.min(t-1,this.focusedRow+1),this.updateFocusIndicator(),this.scrollIntoView();break;case"ArrowUp":e.preventDefault(),this.focusedRow=Math.max(-1,this.focusedRow-1),this.updateFocusIndicator(),this.scrollIntoView();break;case"ArrowRight":e.preventDefault(),this.focusedCol=Math.min(i-1,this.focusedCol+1),this.updateFocusIndicator();break;case"ArrowLeft":e.preventDefault(),this.focusedCol=Math.max(0,this.focusedCol-1),this.updateFocusIndicator();break;case"Home":e.preventDefault(),e.ctrlKey?(this.focusedRow=-1,this.focusedCol=0):this.focusedCol=0,this.updateFocusIndicator(),this.scrollIntoView();break;case"End":e.preventDefault(),e.ctrlKey?(this.focusedRow=t-1,this.focusedCol=i-1):this.focusedCol=i-1,this.updateFocusIndicator(),this.scrollIntoView();break;case"PageDown":e.preventDefault(),this.focusedRow=Math.min(t-1,this.focusedRow+10),this.updateFocusIndicator(),this.scrollIntoView();break;case"PageUp":e.preventDefault(),this.focusedRow=Math.max(0,this.focusedRow-10),this.updateFocusIndicator(),this.scrollIntoView();break;case" ":this.focusedRow>=0&&(e.preventDefault(),this.options.onSelectionToggle?.(this.focusedRow));break;case"Enter":if(this.focusedRow>=0&&this.focusedCol>=0){e.preventDefault();const t=this.getBodyRow(this.focusedRow),i=t?.querySelectorAll("td"),a=i?.[this.focusedCol],s=a?.getAttribute("data-key")||"";this.options.onCellActivate?.(this.focusedRow,s)}break;case"a":(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.options.onSelectAll?.())}}scrollIntoView(){const e=this.getTable();if(!e)return;const t=e.querySelector("[data-grid-focus]");t&&("function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"nearest"}),"function"==typeof t.focus&&t.focus({preventScroll:!0}))}isAttached(){return this.attached}}class fe{exportCSV(e,t,i={}){const{delimiter:a=",",filename:s="export.csv",includeHeaders:n=!0,columns:l,utf8BOM:r=!0}=i;let o=t.filter(e=>!1!==e.exportable);l&&(o=o.filter(e=>l.includes(e.key)));const c=[];n&&c.push(o.map(e=>this.escapeCSV(e.label,a)).join(a));for(const t of e){const e=o.map(e=>{const i=this.cellValue(t,e);return this.escapeCSV(null==i?"":String(i),a)});c.push(e.join(a))}const d=c.join("\n"),h=new Blob([(r?"\ufeff":"")+d],{type:"text/csv;charset=utf-8;"}),u=URL.createObjectURL(h),m=document.createElement("a");m.href=u,m.download=s,m.style.display="none",document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)}print(e,t={}){const{hideFooter:i=!1,hideToolbar:a=!1,includeCheckboxes:s=!1,pageStyles:n=""}=t,l=e.shadowRoot;if(!l)return;const r=l.querySelector("table");if(!r)return;const o=r.cloneNode(!0),c=Array.from(r.querySelectorAll("snice-cell, [in-table], snice-checkbox")),d=Array.from(o.querySelectorAll("snice-cell, [in-table], snice-checkbox"));c.forEach((e,t)=>{const i=d[t];if(!i)return;if("snice-checkbox"===e.localName)return void i.replaceWith(document.createTextNode(e.checked?"☑":"☐"));const a=e.shadowRoot?.querySelector('[part~="content"]');i.replaceWith(document.createTextNode((a?.textContent||e.textContent||"").trim()))}),s||o.querySelectorAll(".select-column").forEach(e=>e.remove());const h=(e,t)=>{const i=l.querySelector(e);if(!i)return"";const a=i.cloneNode(!0);a.querySelectorAll("style").forEach(e=>e.remove()),a.querySelectorAll("button").forEach(e=>{e.textContent?.trim()||(e.textContent=e.getAttribute("aria-label")||"")});const s=a.textContent?.replace(/\s+/g," ").trim();return s?`<div class="${t}">${this.escapeHTML(s)}</div>`:""},u=a?"":h(".table-controls-container","print-toolbar"),m=i?"":h(".table-pagination-container","print-footer"),p=window.open("","_blank");p&&(p.document.write(`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Print</title>\n <style>\n body { font-family: system-ui, -apple-system, sans-serif; margin: 1rem; }\n table { width: 100%; border-collapse: collapse; }\n th, td { padding: 8px 12px; border: 1px solid #ddd; text-align: left; }\n th { background: #f5f5f5; font-weight: 600; }\n .print-toolbar, .print-footer { margin: 0 0 0.75rem; color: #444; }\n .print-footer { margin: 0.75rem 0 0; }\n @media print {\n body { margin: 0; }\n table { page-break-inside: auto; }\n tr { page-break-inside: avoid; }\n }\n ${n}\n </style>\n </head>\n <body>\n ${u}\n ${o.outerHTML}\n ${m}\n </body>\n </html>\n `),p.document.close(),p.onload=()=>{p.print(),p.close()})}async copyToClipboard(e,t,i={}){const{delimiter:a="\t",useFormatted:s=!0}=i;if(0===e.length)return!1;const n=e.map(e=>t.map(t=>{const i=this.cellValue(e,t);return s?this.formatValue(i,e,t):this.rawValue(i)}).join(a)).join("\n");try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.createElement("textarea");e.value=n,e.style.cssText="position:fixed;left:-9999px;",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}escapeCSV(e,t){return e.includes(t)||e.includes('"')||e.includes("\n")||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}cellValue(e,t){const i=e?.[t.key];return t.valueGetter?t.valueGetter(i,e):i}rawValue(e){if(null==e)return"";if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}formatValue(e,t,i){const a=i.formatter||i.valueFormatter;if(a)return String(a(e,t)??"");if(null==e)return"";const s=Number(e);switch(i.type){case"number":case"accounting":{if(!Number.isFinite(s))return this.rawValue(e);const t=i.numberFormat||{},a=t.decimals??("accounting"===i.type?2:0),n=new Intl.NumberFormat("en-US",{minimumFractionDigits:a,maximumFractionDigits:a,useGrouping:t.thousandsSeparator??!1}).format(Math.abs(s));let l=s<0&&("parentheses"===t.negativeStyle||"accounting"===i.type)?`(${n})`:`${s<0?"-":""}${n}`;return t.prefix&&(l=t.prefix+l),t.suffix&&(l+=t.suffix),l}case"currency":{if(!Number.isFinite(s))return this.rawValue(e);const t=i.currencyFormat||{},a=t.decimals??2,n=new Intl.NumberFormat(t.locale||"en-US",{style:"currency",currency:t.currency||"USD",currencyDisplay:t.currencyDisplay||t.display||"symbol",useGrouping:t.thousandsSeparator??!0,minimumFractionDigits:a,maximumFractionDigits:a}).format(Math.abs(s));return s>=0?n:"parentheses"===t.negativeStyle?`(${n})`:`-${n}`}case"percent":case"percentage":return Number.isFinite(s)?`${s.toFixed(i.percentageFormat?.decimals??2)}%`:this.rawValue(e);case"date":{const t=new Date(e);if(Number.isNaN(t.getTime()))return this.rawValue(e);const a=i.dateFormat||{},s="custom"===a.format?void 0:a.format||"short";return new Intl.DateTimeFormat(a.locale||"en-US",s?{dateStyle:s}:{}).format(t)}case"boolean":{const t=i.booleanFormat||{};return!0===e||String(e)===String(t.trueValue??"true")?t.trueSymbol||t.trueValue||"true":t.falseSymbol||t.falseValue||"false"}case"scientific":return Number.isFinite(s)?s.toExponential(i.numberFormat?.decimals??2):this.rawValue(e);default:return this.rawValue(e)}}escapeHTML(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}}class ve{constructor(){this.expandedRows=new Set,this.options=null,this.tableElement=null,this.contentCache=new Map,this.fingerprints=new Map,this.rowByIndex=new Map,this.measuredHeights=new Map,this.onHeightChange=null}attach(e,t){this.tableElement=e,this.options=t,this.contentCache.clear(),this.fingerprints.clear(),this.rowByIndex.clear(),this.measuredHeights.clear()}prepare(e,t){if(!this.options)return;this.rowByIndex=new Map(e.map((e,t)=>[t,e]));const i=new Set(e);for(const e of[...this.contentCache.keys()])i.has(e)?t&&this.fingerprints.get(e)!==t(e)&&(this.contentCache.delete(e),this.measuredHeights.delete(e)):this.contentCache.delete(e);t&&(this.fingerprints=new Map(e.map(e=>[e,t(e)])));for(const e of this.measuredHeights.keys())i.has(e)||this.measuredHeights.delete(e);!1===this.options.lazy&&e.forEach((e,t)=>this.getContent(e,t))}isExpanded(e){return this.expandedRows.has(e)}toggle(e){this.expandedRows.has(e)?this.collapse(e):this.expand(e)}expand(e){this.expandedRows.add(e),this.tableElement?.dispatchEvent(new CustomEvent("row-expand",{detail:{rowIndex:e},bubbles:!0,composed:!0}))}collapse(e){if(this.expandedRows.delete(e),!1!==this.options?.lazy){const t=this.rowByIndex.get(e);void 0!==t&&(this.contentCache.delete(t),this.measuredHeights.delete(t))}this.tableElement?.dispatchEvent(new CustomEvent("row-collapse",{detail:{rowIndex:e},bubbles:!0,composed:!0}))}expandAll(e){for(let t=0;t<e;t++)this.expandedRows.add(t)}collapseAll(){this.expandedRows.clear(),!1!==this.options?.lazy&&(this.contentCache.clear(),this.measuredHeights.clear())}getExpandedRows(){return new Set(this.expandedRows)}setExpandedRows(e){const t=new Set(e);if(!1!==this.options?.lazy)for(const e of this.expandedRows){if(t.has(e))continue;const i=this.rowByIndex.get(e);void 0!==i&&(this.contentCache.delete(i),this.measuredHeights.delete(i))}this.expandedRows=t}createToggleButton(e){const t=this.isExpanded(e),i=document.createElement("button");i.type="button",i.className="detail-toggle"+(t?" detail-toggle--expanded":""),i.setAttribute("aria-expanded",String(t)),i.setAttribute("aria-label",t?"Collapse row":"Expand row");const a=t?this.options?.collapseIcon:this.options?.expandIcon;return a?a.trim().startsWith("<")?i.innerHTML=a:i.textContent=a:i.innerHTML='<svg class="detail-toggle-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',i.addEventListener("click",t=>{t.stopPropagation(),this.toggle(e),this.tableElement?.dispatchEvent(new CustomEvent("detail-toggle",{detail:{rowIndex:e,expanded:this.isExpanded(e)},bubbles:!0,composed:!0}))}),i}createDetailRow(e,t,i){if(!this.options||!this.isExpanded(t))return null;const a=document.createElement("tr");a.className="detail-row",a.setAttribute("data-detail-for",String(t));const s=document.createElement("td");s.colSpan=i,s.className="detail-cell",s.style.padding="0",s.style.border="none";const n=document.createElement("div");n.className="detail-content";const l=document.createElement("div");l.className="detail-content-inner";const r=this.getContent(e,t);return"string"==typeof r?l.innerHTML=r:r instanceof HTMLElement&&l.appendChild(r),n.appendChild(l),s.appendChild(n),requestAnimationFrame(()=>{const t=this.options?.detailHeight,i=void 0===t||"auto"===t?`${l.scrollHeight}px`:"number"==typeof t?`${t}px`:t;void 0!==t&&"auto"!==t&&(l.style.height=i,l.style.overflow="auto"),n.style.setProperty("--detail-max-height",i),n.classList.add("detail-content--open");const a=l.getBoundingClientRect().height||l.scrollHeight,s=this.measuredHeights.get(e);a>0&&a!==s&&(this.measuredHeights.set(e,a),this.onHeightChange?.())}),a.appendChild(s),a}isEnabled(){return null!==this.options}getFixedAdditionalHeight(e){if(!this.isExpanded(e))return 0;const t=this.options?.detailHeight;if("number"==typeof t)return Math.max(0,t);if("string"==typeof t&&/^\d+(?:\.\d+)?px$/.test(t.trim()))return Math.max(0,Number.parseFloat(t));const i=this.rowByIndex.get(e);return void 0===i?0:this.measuredHeights.get(i)||0}getContent(e,t){return this.options?(this.rowByIndex.set(t,e),this.contentCache.has(e)||this.contentCache.set(e,this.options.getDetailContent(e,t)),this.contentCache.get(e)):""}}class ye{constructor(){this.container=null,this.options={},this.tableElement=null,this.filterEngine=null,this.filterPanel=null,this.filterPanelOpen=!1,this.filters=[],this.logic="and",this.pendingDebounces=[],this.sortPanel=null,this.sortPanelOpen=!1,this.onSearch=null,this.onSortColumn=null,this.onSetSortModel=null,this.onFilterColumn=null,this.onRemoveFilter=null,this.onClearFilters=null,this.onSetFilterModel=null,this.onExportCSV=null,this.onFullscreen=null}attach(e,t,i={}){this.tableElement=e,this.container=t,this.options=i,this.render()}setFilterEngine(e){this.filterEngine=e}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="tt-wrap",e.appendChild(this.styleTag());const t=document.createElement("div");if(t.className="table-toolbar",t.setAttribute("part","toolbar"),!1!==this.options.showSearch){const e=document.createElement("snice-input");let i;e.type="search",e.placeholder=this.options.searchPlaceholder||"Search...",e.size="small",e.prefixIcon="search",e.clearable=!0,e.className="toolbar-search",e.addEventListener("input",()=>{clearTimeout(i),i=window.setTimeout(()=>this.onSearch?.(e.value),300)}),t.appendChild(e)}const i=document.createElement("div");if(i.className="toolbar-actions",this.options.showSort){const e=this.mkBtn("Sort",N);e.classList.add("toolbar-sort"),e.addEventListener("click",()=>this.toggleSortPanel()),i.appendChild(e)}if(this.options.showFilter){const e=this.mkBtn("Filter",T);e.classList.add("toolbar-filter"),e.addEventListener("click",()=>{this.filterPanelOpen?this.closeFilterPanel():this.openFilterModal()}),i.appendChild(e)}if(this.options.showExport){const e=this.mkBtn("Export CSV",L);e.addEventListener("click",()=>this.onExportCSV?.()),i.appendChild(e)}const a=this.mkBtn("Fullscreen",B);a.addEventListener("click",()=>this.onFullscreen?.()),i.appendChild(a),t.appendChild(i),e.appendChild(t),this.filterPanel=document.createElement("div"),this.filterPanel.className="tt-filter-panel",this.filterPanel.hidden=!this.filterPanelOpen,e.appendChild(this.filterPanel),this.sortPanel=document.createElement("div"),this.sortPanel.className="tt-sort-panel",this.sortPanel.hidden=!this.sortPanelOpen,e.appendChild(this.sortPanel),this.container.appendChild(e),this.filterPanelOpen&&this.renderFilterPanel(),this.sortPanelOpen&&this.renderSortPanel()}openFilterModal(e){this.closeSortPanel();const t=this.ensureEngine();if(!this.filterPanelOpen){const e=t.getFilterModel();this.filters=e.filters.map(e=>({...e})),this.logic=e.logic||"and"}if(e){const i=(this.tableElement?.columns||[]).find(t=>t.key===e),a=t.getOperatorsForType(i?.type||"text");i&&a[0]&&!this.filters.some(t=>t.column===e)&&this.filters.push({column:e,operator:a[0].value,value:""})}this.filterPanelOpen||(this.filterPanelOpen=!0,this.filterPanel&&(this.filterPanel.hidden=!1)),this.renderFilterPanel()}closeFilterPanel(){this.cancelPendingDebounces(),this.filterPanelOpen=!1,this.filterPanel&&(this.filterPanel.hidden=!0)}toggleSortPanel(){this.sortPanelOpen?this.closeSortPanel():(this.closeFilterPanel(),this.sortPanelOpen=!0,this.sortPanel&&(this.sortPanel.hidden=!1),this.renderSortPanel())}closeSortPanel(){this.sortPanelOpen=!1,this.sortPanel&&(this.sortPanel.hidden=!0)}renderSortPanel(){if(!this.sortPanel)return;const e=(this.tableElement?.columns||[]).filter(e=>!1!==e.sortable);let t=(this.tableElement?.currentSort||[]).map(e=>({...e}));this.sortPanel.innerHTML="",this.sortPanel.appendChild(this.styleTag());const i=document.createElement("div");i.className="tt-filter-inner";const a=document.createElement("button");a.type="button",a.className="tt-filter-corner-close",a.setAttribute("aria-label","Close sort panel"),a.innerHTML=x,a.addEventListener("click",()=>this.closeSortPanel()),i.appendChild(a);const s=document.createElement("div");s.className="tt-filter-rows",i.appendChild(s);const n=()=>this.onSetSortModel?.(t.map(e=>({...e}))),l=()=>this.renderSortPanel();if(0===t.length){const e=document.createElement("div");e.className="tt-filter-empty",e.textContent="No sorting applied",s.appendChild(e)}else t.forEach((i,a)=>{const r=document.createElement("div");r.className="tt-filter-row tt-sort-row";const o=document.createElement("button");o.type="button",o.className="tt-filter-x",o.setAttribute("aria-label","Remove sort"),o.innerHTML=x,o.addEventListener("click",()=>{t.splice(a,1),n(),l()}),r.appendChild(o);const c=document.createElement("snice-select");c.size="small";const d=new Set(t.filter((e,t)=>t!==a).map(e=>e.column));c.options=e.filter(e=>e.key===i.column||!d.has(e.key)).map(e=>({value:e.key,label:e.label||e.key})),c.value=i.column,c.style.width="12rem",c.addEventListener("change",()=>{i.column=c.value,n()}),r.appendChild(c);const h=document.createElement("snice-select");h.size="small",h.options=[{value:"asc",label:"Ascending"},{value:"desc",label:"Descending"}],h.value=i.direction,h.style.width="9rem",h.addEventListener("change",()=>{i.direction=h.value,n()}),r.appendChild(h),s.appendChild(r)});const r=document.createElement("div");r.className="tt-filter-footer";const o=document.createElement("button");if(o.type="button",o.className="tt-filter-add",o.innerHTML=`${R}<span>Add sort</span>`,o.addEventListener("click",()=>{const i=new Set(t.map(e=>e.column)),a=e.find(e=>!i.has(e.key));a&&(t.push({column:a.key,direction:"asc"}),n(),l())}),o.disabled=t.length>=e.length,r.appendChild(o),t.length>0){const e=document.createElement("button");e.type="button",e.className="tt-filter-clear",e.textContent="Clear all",e.addEventListener("click",()=>{t=[],n(),l()}),r.appendChild(e)}i.appendChild(r),this.sortPanel.appendChild(i)}ensureEngine(){return this.filterEngine||(this.filterEngine=new pe),this.filterEngine}cancelPendingDebounces(){for(const e of this.pendingDebounces)clearTimeout(e);this.pendingDebounces=[]}renderFilterPanel(){if(!this.filterPanel)return;this.cancelPendingDebounces();const e=this.ensureEngine(),t=this.tableElement?.columns||[];if(0===this.filters.length){const t=e.getFilterModel();this.filters=[...t.filters],this.logic=t.logic||"and"}this.filterPanel.innerHTML="",this.filterPanel.appendChild(this.styleTag());const i=document.createElement("div");i.className="tt-filter-inner";const a=document.createElement("button");a.type="button",a.className="tt-filter-corner-close",a.setAttribute("aria-label","Close filter panel"),a.setAttribute("title","Close"),a.innerHTML=x,a.addEventListener("click",()=>this.closeFilterPanel()),i.appendChild(a);const s=document.createElement("div");s.className="tt-filter-rows",i.appendChild(s);const n=()=>{const i=this.filters.filter(i=>{const a=t.find(e=>e.key===i.column),s=e.getOperatorsForType(a?.type||"text").find(e=>e.value===i.operator);return!!s&&(!1===s.requiresValue||null!==i.value&&""!==i.value)});this.onSetFilterModel?.(i,this.logic)},l=(i,a)=>{const s=document.createElement("div");s.className="tt-filter-row";const l=document.createElement("button");l.type="button",l.className="tt-filter-x",l.setAttribute("aria-label","Remove filter"),l.innerHTML=x,l.addEventListener("click",()=>{this.filters.splice(a,1),0===this.filters.length?this.onClearFilters?.():n(),this.renderFilterPanel()}),s.appendChild(l);const r=document.createElement("snice-select");r.size="small",r.searchable=t.length>8,r.maxHeight="200px",r.options=t.map(e=>({value:e.key,label:e.label||e.key})),r.value=i.column,r.style.width="11rem",s.appendChild(r);const o=document.createElement("snice-select");o.size="small",o.maxHeight="200px",o.style.width="8rem",s.appendChild(o);const c=document.createElement("span");c.className="tt-filter-val-wrap";const d=document.createElement("snice-input");d.size="small",d.placeholder="Value",d.style.width="11rem",null!=i.value&&(d.value=String(i.value)),c.appendChild(d),s.appendChild(c);const h=()=>{const a=t.find(e=>e.key===r.value),s=a?.type||"text",n=e.getOperatorsForType(s);o.options=n.map(e=>({value:e.value,label:e.label})),o.value=n.some(e=>e.value===i.operator)?i.operator:"",d.type=(e=>{switch(e){case"number":case"currency":case"rating":case"progress":case"filesize":case"duration":case"percent":case"percentage":return"number";case"date":return"date";default:return"text"}})(s),u()},u=()=>{const i=t.find(e=>e.key===r.value),a=e.getOperatorsForType(i?.type||"text").find(e=>e.value===o.value);c.style.display=!1===a?.requiresValue?"none":""};let m;return r.addEventListener("change",()=>{i.column=r.value,h(),n()}),o.addEventListener("change",()=>{i.operator=o.value,u(),n()}),d.addEventListener("input",()=>{clearTimeout(m),m=window.setTimeout(()=>{this.pendingDebounces=this.pendingDebounces.filter(e=>e!==m),i.value=d.value,n()},250),this.pendingDebounces.push(m)}),d.addEventListener("keydown",e=>{"Enter"===e.key&&(i.value=d.value,n())}),h(),s};if(this.filters.length>1){const e=document.createElement("div");e.className="tt-filter-logicbar";const t=document.createElement("span");t.className="tt-filter-logicbar-label",t.textContent="Match";const a=document.createElement("snice-select");a.size="small",a.options=[{value:"and",label:"All filters (AND)"},{value:"or",label:"Any filter (OR)"}],a.value=this.logic,a.style.width="11rem",a.addEventListener("change",()=>{this.logic=a.value,n()}),e.appendChild(t),e.appendChild(a),i.insertBefore(e,s)}if(0===this.filters.length){const e=document.createElement("div");e.className="tt-filter-empty",e.textContent="No filters applied",s.appendChild(e)}else this.filters.forEach((e,t)=>s.appendChild(l(e,t)));const r=document.createElement("div");r.className="tt-filter-footer";const o=document.createElement("button");if(o.type="button",o.className="tt-filter-add",o.innerHTML=`${R}<span>Add filter</span>`,o.addEventListener("click",()=>{const i=t[0];if(!i)return;const a=e.getOperatorsForType(i.type||"text");a[0]&&(this.filters.push({column:i.key,operator:a[0].value,value:""}),this.renderFilterPanel())}),r.appendChild(o),this.filters.length>0){const e=document.createElement("button");e.type="button",e.className="tt-filter-clear",e.textContent="Clear all",e.addEventListener("click",()=>{this.cancelPendingDebounces(),this.filters=[],this.logic="and",this.onClearFilters?.(),this.renderFilterPanel()}),r.appendChild(e)}i.appendChild(r),this.filterPanel.appendChild(i)}mkBtn(e,t){const i=document.createElement("button");return i.className="toolbar-btn",i.setAttribute("aria-label",e),i.setAttribute("title",e),i.innerHTML=t,i}styleTag(){const e=document.createElement("style");return e.textContent=we,e}setActiveFilterCount(e){}isAttached(){return null!==this.container}}const we="\n .tt-wrap { display: flex; flex-direction: column; }\n\n .tt-filter-panel {\n border-bottom: 1px solid var(--snice-color-border, rgb(226 226 226));\n background: var(--snice-color-surface-container-low, rgb(250 250 250));\n }\n .tt-sort-panel {\n border-bottom: 1px solid var(--snice-color-border, rgb(226 226 226));\n background: var(--snice-color-surface-container-low, rgb(250 250 250));\n }\n .tt-filter-inner {\n padding: 0.75rem 0.875rem;\n padding-right: 2.5rem;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n position: relative;\n }\n .tt-filter-corner-close {\n position: absolute;\n top: 0.5rem;\n right: 0.5rem;\n width: 1.75rem;\n height: 1.75rem;\n border: none;\n background: none;\n cursor: pointer;\n color: var(--snice-color-text-tertiary, rgb(115 115 115));\n border-radius: var(--snice-border-radius-md, 0.25rem);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n line-height: 0;\n z-index: 1;\n }\n .tt-filter-corner-close:hover {\n background: var(--snice-color-surface-hover, rgb(245 245 245));\n color: var(--snice-color-text, rgb(23 23 23));\n }\n .tt-filter-corner-close svg {\n width: 1rem;\n height: 1rem;\n }\n .tt-filter-logicbar {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n }\n .tt-filter-logicbar-label {\n font-size: 0.75rem;\n font-weight: 500;\n color: var(--snice-color-text-secondary, rgb(82 82 82));\n flex: 0 0 auto;\n }\n .tt-filter-rows {\n display: flex;\n flex-direction: column;\n gap: 0.375rem;\n }\n .tt-filter-empty {\n padding: 0.625rem 0.5rem;\n font-size: 0.8125rem;\n color: var(--snice-color-text-tertiary, rgb(115 115 115));\n font-style: italic;\n }\n .tt-filter-row {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n flex-wrap: nowrap;\n }\n .tt-filter-x {\n border: none;\n background: none;\n color: var(--snice-color-text-tertiary, rgb(115 115 115));\n cursor: pointer;\n border-radius: var(--snice-border-radius-md, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n padding: 0;\n line-height: 0;\n }\n .tt-filter-x svg {\n width: 1rem;\n height: 1rem;\n }\n .tt-filter-x:hover {\n color: var(--snice-color-danger, rgb(220 38 38));\n background: var(--snice-color-surface-hover, rgb(245 245 245));\n }\n .tt-filter-val-wrap { display: inline-flex; flex: 1 1 auto; min-width: 0; }\n .tt-filter-val-wrap snice-input { width: 100%; }\n .tt-filter-footer {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n margin-top: 0.125rem;\n }\n .tt-filter-add,\n .tt-filter-clear {\n border: none;\n background: none;\n font-family: inherit;\n font-size: 0.8125rem;\n cursor: pointer;\n padding: 0.375rem 0.625rem;\n border-radius: var(--snice-border-radius-md, 0.25rem);\n display: inline-flex;\n align-items: center;\n gap: 0.375rem;\n line-height: 1;\n }\n .tt-filter-add svg,\n .tt-filter-clear svg {\n width: 0.875rem;\n height: 0.875rem;\n }\n .tt-filter-add { color: var(--snice-color-primary, rgb(37 99 235)); font-weight: 500; }\n .tt-filter-add:hover { background: var(--snice-color-primary-subtle, rgb(219 234 254 / 0.4)); }\n .tt-filter-clear { color: var(--snice-color-text-tertiary, rgb(115 115 115)); margin-left: auto; }\n .tt-filter-clear:hover {\n color: var(--snice-color-danger, rgb(220 38 38));\n background: var(--snice-color-surface-hover, rgb(245 245 245));\n }\n";class ke{constructor(){this.options=null,this.expandedKeys=new Set,this.flatRows=[],this.enabled=!1,this.defaultDepth=0}attach(e){this.options=e,this.enabled=!0,void 0!==e.defaultExpansionDepth&&e.defaultExpansionDepth>=0&&(this.defaultDepth=e.defaultExpansionDepth)}isEnabled(){return this.enabled}processData(e){if(!this.options)return[];const t=new Map;for(const i of e){const e=this.options.getPath(i),a=e.join("/");t.set(a,{data:i,children:new Set,depth:e.length-1,isGap:!1});for(let i=1;i<e.length;i++){const a=e.slice(0,i),s=a.join("/");t.has(s)||t.set(s,{data:{[this.options.groupColumn||"name"]:a[a.length-1]},children:new Set,depth:i-1,isGap:!0})}if(e.length>1){const i=e.slice(0,-1).join("/"),s=t.get(i);s&&s.children.add(a)}}const i=[];for(const[e,a]of t)0===a.depth&&i.push(e);if(i.sort(),0===this.expandedKeys.size&&this.defaultDepth>0)for(const[e,i]of t)i.depth<this.defaultDepth&&i.children.size>0&&this.expandedKeys.add(e);this.flatRows=[];const a=e=>{const i=t.get(e);if(!i)return;const s=i.children.size>0,n=this.expandedKeys.has(e);if(this.flatRows.push({path:e.split("/"),data:i.data,depth:i.depth,hasChildren:s,expanded:n,key:e,isGap:i.isGap}),n){const e=Array.from(i.children).sort();for(const t of e)a(t)}};for(const e of i)a(e);return this.flatRows}getFlatRows(){return this.flatRows}toggle(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):this.expandedKeys.add(e)}expand(e){this.expandedKeys.add(e)}collapse(e){this.expandedKeys.delete(e)}expandAll(e){if(this.options)for(const t of e){const e=this.options.getPath(t);for(let t=1;t<=e.length;t++)this.expandedKeys.add(e.slice(0,t).join("/"))}}collapseAll(){this.expandedKeys.clear()}isExpanded(e){return this.expandedKeys.has(e)}createToggle(e){const t=document.createElement("span");if(t.className="tree-indent",t.style.paddingLeft=1.5*e.depth+"rem",e.hasChildren){const i=document.createElement("button");i.type="button",i.className="tree-toggle"+(e.expanded?" tree-toggle--expanded":""),i.innerHTML='<svg class="tree-toggle-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',i.setAttribute("aria-expanded",String(e.expanded)),i.setAttribute("aria-label",(e.expanded?"Collapse":"Expand")+" row"),i.addEventListener("click",t=>{t.stopPropagation(),this.toggle(e.key),i.dispatchEvent(new CustomEvent("tree-toggle",{detail:{key:e.key,expanded:this.isExpanded(e.key)},bubbles:!0,composed:!0}))}),t.appendChild(i)}else{const e=document.createElement("span");e.className="tree-spacer",t.appendChild(e)}return t}getGroupColumn(){return this.options?.groupColumn||""}}function xe(e,t,i){if("function"==typeof e)return e(t,i);if("count"===e)return i.length;const a=[];for(const e of t)if(null!=e&&"boolean"!=typeof e&&("string"!=typeof e||""!==e.trim()))try{const t=Number(e);Number.isFinite(t)&&a.push(t)}catch{}switch(e){case"sum":return a.reduce((e,t)=>e+t,0);case"avg":return a.length?a.reduce((e,t)=>e+t,0)/a.length:0;case"min":return a.length?a.reduce((e,t)=>t<e?t:e,a[0]):null;case"max":return a.length?a.reduce((e,t)=>t>e?t:e,a[0]):null;default:return null}}class Ce{constructor(){this.groupByKeys=[],this.defaultExpanded=!0,this.aggregators=[],this.collapsedOverrides=new Set,this.expandedOverrides=new Set,this.flatItems=[],this.objectValueIds=new WeakMap,this.symbolValueIds=new Map,this.nextValueId=1}configure(e){this.groupByKeys=(e.groupBy??[]).filter(Boolean),this.defaultExpanded=!1!==e.defaultExpanded}setColumns(e){const t=e.filter(e=>null!=e.aggregate).map(e=>({key:e.key,aggregate:e.aggregate,valueGetter:e.valueGetter})),i=t.length!==this.aggregators.length||t.some((e,t)=>{const i=this.aggregators[t];return i?.key!==e.key||i.aggregate!==e.aggregate||i.valueGetter!==e.valueGetter});return this.aggregators=t,i}hasGrouping(){return this.groupByKeys.length>0}hasAggregation(){return this.aggregators.length>0}isEnabled(){return this.hasGrouping()||this.hasAggregation()}getGroupByKeys(){return this.groupByKeys}computeAggregates(e){const t={};for(const i of this.aggregators){const a=e.map(e=>{const t=e?.[i.key];return i.valueGetter?i.valueGetter(t,e):t});t[i.key]=xe(i.aggregate,a,e)}return t}valueKey(e){if(null===e)return"null";switch(typeof e){case"undefined":return"undefined";case"string":return`string:${encodeURIComponent(e)}`;case"number":return Number.isNaN(e)?"number:NaN":`number:${Object.is(e,-0)?"0":String(e)}`;case"boolean":return"boolean:"+(e?"1":"0");case"bigint":return`bigint:${String(e)}`;case"symbol":{let t=this.symbolValueIds.get(e);return void 0===t&&(t=this.nextValueId++,this.symbolValueIds.set(e,t)),`symbol:${t}`}case"object":case"function":{const t=e;let i=this.objectValueIds.get(t);return void 0===i&&(i=this.nextValueId++,this.objectValueIds.set(t,i)),`object:${i}`}default:return`${typeof e}:${encodeURIComponent(String(e))}`}}processData(e){if(!this.isEnabled()||0===e.length)return this.flatItems=[],this.flatItems;const t=[];if(this.hasGrouping())this.buildGroups(e,0,"",t);else for(const i of e)t.push({type:"row",key:i,depth:0,data:i});return this.hasAggregation()&&t.push({type:"aggregate",key:"agg:table",depth:0,scope:"table",aggregates:this.computeAggregates(e),rows:e}),this.flatItems=t,t}buildGroups(e,t,i,a){const s=this.groupByKeys[t],n=new Map;for(const t of e){const e=t[s],i=n.get(e);i?i.push(t):n.set(e,[t])}const l=Array.from(n.keys()).sort((e,t)=>String(e??"").localeCompare(String(t??""),void 0,{numeric:!0})||this.valueKey(e).localeCompare(this.valueKey(t))),r=t===this.groupByKeys.length-1;for(const e of l){const l=n.get(e),o=`${encodeURIComponent(s)}=${this.valueKey(e)}`,c=i?`${i}|${o}`:o,d=`group:${c}`,h=this.isExpanded(d);if(a.push({type:"group",key:d,depth:t,groupKey:s,value:e,count:l.length,expanded:h,hasChildren:!0,rows:l}),h){if(r)for(const e of l)a.push({type:"row",key:e,depth:t+1,data:e});else this.buildGroups(l,t+1,c,a);this.hasAggregation()&&a.push({type:"aggregate",key:`agg:${d}`,depth:t+1,scope:"group",aggregates:this.computeAggregates(l),rows:l,groupKey:d,groupValue:e,groupColumn:s})}}}getFlatItems(){return this.flatItems}isExpanded(e){return this.defaultExpanded?!this.collapsedOverrides.has(e):this.expandedOverrides.has(e)}toggle(e){this.isExpanded(e)?this.collapse(e):this.expand(e)}expand(e){this.collapsedOverrides.delete(e),this.defaultExpanded||this.expandedOverrides.add(e)}collapse(e){this.expandedOverrides.delete(e),this.defaultExpanded&&this.collapsedOverrides.add(e)}expandAll(){if(this.collapsedOverrides.clear(),!this.defaultExpanded)for(const e of this.flatItems)"group"===e.type&&this.expandedOverrides.add(e.key)}collapseAll(){if(this.expandedOverrides.clear(),this.defaultExpanded)for(const e of this.flatItems)"group"===e.type&&this.collapsedOverrides.add(e.key)}createToggle(e){const t=document.createElement("span");t.className="tree-indent",t.style.paddingLeft=1.5*e.depth+"rem";const i=document.createElement("button");i.type="button",i.className="tree-toggle"+(e.expanded?" tree-toggle--expanded":""),i.setAttribute("data-group-key",e.key),i.innerHTML='<svg class="tree-toggle-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',i.setAttribute("aria-expanded",String(e.expanded));const a=null==e.value||""===e.value?"blank":String(e.value);return i.setAttribute("aria-label",`${e.expanded?"Collapse":"Expand"} ${a} group, ${e.count} rows`),t.appendChild(i),t}}class Se{constructor(){this.menuEl=null,this.activeColumn=null,this.tableElement=null,this.outsideClickHandler=null,this.onSortAsc=null,this.onSortDesc=null,this.onFilter=null,this.onHide=null,this.onPinLeft=null,this.onPinRight=null,this.onUnpin=null,this.onAutoSize=null}attach(e){this.tableElement=e}show(e,t,i,a){this.hide(),this.activeColumn=e;const s=document.createElement("div");s.className="table-column-menu",s.style.left=`${t}px`,s.style.top=`${i}px`;const n=[];!1!==a?.sortable&&(n.push({label:"Sort Ascending",icon:M,action:"sort-asc"}),n.push({label:"Sort Descending",icon:z,action:"sort-desc"}),n.push({label:"",action:"",separator:!0})),!1!==a?.filterable&&n.push({label:"Filter...",icon:T,action:"filter"}),!1!==a?.hideable&&n.push({label:"Hide Column",icon:O,action:"hide"}),!1!==a?.pinnable&&(a?.pinned?n.push({label:"Unpin",icon:x,action:"unpin"}):(n.push({label:"Pin Left",icon:j,action:"pin-left"}),n.push({label:"Pin Right",icon:j,action:"pin-right"}))),n.push({label:"",action:"",separator:!0}),n.push({label:"Auto-size",icon:N,action:"autosize"});for(const e of n){if(e.separator){const e=document.createElement("div");e.className="column-menu-separator",s.appendChild(e);continue}const t=document.createElement("button");t.type="button",t.className="column-menu-item",t.innerHTML=`${e.icon?`<span class="column-menu-icon">${e.icon}</span>`:""}<span>${e.label}</span>`,t.addEventListener("click",()=>{this.handleAction(e.action),this.hide()}),e.disabled&&(t.disabled=!0),s.appendChild(t)}const l=this.tableElement?.shadowRoot;l?l.appendChild(s):document.body.appendChild(s),this.menuEl=s,setTimeout(()=>{this.outsideClickHandler=e=>{e.composedPath().includes(s)||this.hide()},document.addEventListener("click",this.outsideClickHandler,{capture:!0})},0);const r=e=>{"Escape"===e.key&&(this.hide(),document.removeEventListener("keydown",r))};document.addEventListener("keydown",r)}handleAction(e){if(this.activeColumn)switch(e){case"sort-asc":this.onSortAsc?.(this.activeColumn);break;case"sort-desc":this.onSortDesc?.(this.activeColumn);break;case"filter":this.onFilter?.(this.activeColumn);break;case"hide":this.onHide?.(this.activeColumn);break;case"pin-left":this.onPinLeft?.(this.activeColumn);break;case"pin-right":this.onPinRight?.(this.activeColumn);break;case"unpin":this.onUnpin?.(this.activeColumn);break;case"autosize":this.onAutoSize?.(this.activeColumn)}}hide(){this.menuEl&&(this.menuEl.remove(),this.menuEl=null),this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler,{capture:!0}),this.outsideClickHandler=null),this.activeColumn=null}isOpen(){return null!==this.menuEl}}class Ee{constructor(){this.enabled=!1,this.tableElement=null,this.dragSourceIndex=-1,this.dropTargetIndex=-1,this.dropIndicator=null}attach(e){this.tableElement=e,this.enabled=!0}detach(){this.removeDropIndicator(),this.tableElement=null,this.dragSourceIndex=-1,this.dropTargetIndex=-1,this.enabled=!1}isEnabled(){return this.enabled}makeRowDraggable(e,t,i=!0){i&&(e.draggable=!0,e.addEventListener("dragstart",i=>{this.dragSourceIndex=t,e.style.opacity="0.5",i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",String(t))}),e.addEventListener("dragend",()=>{e.style.opacity="1",this.removeDropIndicator(),this.dragSourceIndex=-1}),e.addEventListener("dragover",i=>{i.preventDefault(),i.dataTransfer.dropEffect="move",this.dropTargetIndex=t,this.showDropIndicator(e)}),e.addEventListener("dragleave",()=>{this.removeDropIndicator()}),e.addEventListener("drop",e=>{e.preventDefault(),this.removeDropIndicator(),-1!==this.dragSourceIndex&&this.dragSourceIndex!==t&&this.tableElement?.dispatchEvent(new CustomEvent("row-reorder",{detail:{fromIndex:this.dragSourceIndex,toIndex:t},bubbles:!0,composed:!0})),this.dragSourceIndex=-1}))}createDragHandle(){const e=document.createElement("td");return e.className="drag-handle-cell",e.textContent="⠗",e.setAttribute("aria-label","Drag to reorder"),e}showDropIndicator(e){this.removeDropIndicator(),this.dropIndicator=document.createElement("div"),this.dropIndicator.className="drop-indicator";const t=e.getBoundingClientRect(),i=e.parentElement?.getBoundingClientRect();i&&(this.dropIndicator.style.top=(this.dropTargetIndex>this.dragSourceIndex?t.bottom-i.top:t.top-i.top)+"px",e.parentElement.style.position="relative",e.parentElement.appendChild(this.dropIndicator))}removeDropIndicator(){this.dropIndicator?.remove(),this.dropIndicator=null}}class De{constructor(){this.enabled=!1,this.tableElement=null,this.dragSourceKey=null}attach(e){this.tableElement=e,this.enabled=!0}detach(){this.tableElement=null,this.dragSourceKey=null,this.enabled=!1}isEnabled(){return this.enabled}makeHeaderDraggable(e,t,i=!0){i&&(e.draggable=!0,e.addEventListener("dragstart",i=>{this.dragSourceKey=t,e.style.opacity="0.5",i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",t)}),e.addEventListener("dragend",()=>{e.style.opacity="1",this.dragSourceKey=null}),e.addEventListener("dragover",i=>{this.dragSourceKey&&this.dragSourceKey!==t&&(i.preventDefault(),i.dataTransfer.dropEffect="move",e.style.borderLeft="2px solid var(--snice-color-primary, rgb(37 99 235))")}),e.addEventListener("dragleave",()=>{e.style.borderLeft=""}),e.addEventListener("drop",i=>{i.preventDefault(),e.style.borderLeft="",this.dragSourceKey&&this.dragSourceKey!==t&&this.tableElement?.dispatchEvent(new CustomEvent("column-reorder",{detail:{fromKey:this.dragSourceKey,toKey:t},bubbles:!0,composed:!0})),this.dragSourceKey=null}))}}(()=>{let t,a,c,p,b,v,x,C,S,E,D,A,R,M,z,$,F,I,T,L,V,B,O,j,N,P,H,q,_,G,K,W,U,Z,Y,J,Q,X,ee,te,ie,ae,se,ne,le,re,de,he,ue,me,we,xe,Ae,Re,Me,ze,$e,Fe,Ie,Te,Le,Ve,Be,Oe,je,Ne,Pe,He,qe,_e,Ge,Ke,We,Ue,Ze,Ye,Je,Qe,Xe,et,tt,it,at,st,nt,lt,rt,ot,ct,dt,ht,ut,mt,pt,gt=[i("snice-table")],bt=[],ft=HTMLElement,vt=[],yt=[],wt=[],kt=[],xt=[],Ct=[],St=[],Et=[],Dt=[],At=[],Rt=[],Mt=[],zt=[],$t=[],Ft=[],It=[],Tt=[],Lt=[],Vt=[],Bt=[],Ot=[],jt=[],Nt=[],Pt=[],Ht=[],qt=[],_t=[],Gt=[],Kt=[],Wt=[],Ut=[],Zt=[],Yt=[],Jt=[],Qt=[],Xt=[],ei=[],ti=[],ii=[],ai=[],si=[],ni=[],li=[],ri=[],oi=[],ci=[],di=[],hi=[],ui=[],mi=[],pi=[],gi=[],bi=[],fi=[],vi=[],yi=[],wi=[],ki=[],xi=[],Ci=[],Si=[],Ei=[],Di=[],Ai=[],Ri=[],Mi=[],zi=[],$i=[],Fi=[],Ii=[],Ti=[],Li=[],Vi=[],Bi=[],Oi=[],ji=[],Ni=[],Pi=[],Hi=[],qi=[],_i=[],Gi=[],Ki=[],Wi=[],Ui=[],Zi=[],Yi=[],Ji=[],Qi=[];var Xi=class extends ft{static{a=this}static{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(ft[Symbol.metadata]??null):void 0;c=[s({type:Boolean,attribute:"striped"})],p=[s({type:Boolean,attribute:"searchable"})],b=[s({type:Boolean,attribute:"filterable"})],v=[s({type:Boolean,attribute:"sortable"})],x=[s({type:Boolean,attribute:"selectable"})],C=[s({type:Boolean,attribute:"hoverable"})],S=[s({type:Boolean,attribute:"clickable"})],E=[s({type:Boolean,attribute:"list"})],D=[s({type:Boolean,attribute:"pagination"})],A=[s({attribute:"pagination-mode"})],R=[s({type:Number,attribute:"page-size"})],M=[s({type:Number,attribute:"current-page"})],z=[s({type:Number,attribute:"total-items"})],$=[s({type:Array,attribute:!1})],F=[s({type:Number,attribute:"search-debounce"})],I=[s({attribute:!1})],T=[s({attribute:!1})],L=[s()],V=[s({type:Array,attribute:!1})],B=[s({type:String,attribute:"selector"})],O=[s({type:Array,attribute:!1})],j=[s({type:Boolean,attribute:"loading"})],N=[s({type:Boolean,attribute:"virtualize"})],P=[s({type:Number,attribute:"row-height"})],H=[s({type:Number,attribute:"virtual-buffer"})],q=[s({type:Boolean,attribute:"column-resize"})],_=[s({type:Boolean,attribute:"editable"})],G=[s({attribute:"edit-mode"})],K=[s({attribute:"density"})],W=[s({type:Boolean,attribute:"header-filters"})],U=[s({type:Boolean,attribute:"quick-filter"})],Z=[s({type:Boolean,attribute:"row-reorder"})],Y=[s({type:Boolean,attribute:"column-reorder"})],J=[s({type:Boolean,attribute:"column-menu"})],Q=[s({type:Boolean,attribute:"lazy-load"})],X=[s({type:Number,attribute:"lazy-load-threshold"})],ee=[s({type:Array,attribute:!1})],te=[s({attribute:"selection-mode"})],ie=[s({attribute:!1})],ae=[s({attribute:!1})],se=[n("table")],ne=[n("thead")],le=[n("tbody")],re=[g("table/config")],de=[g("table/data")],he=[r()],ue=[l()],me=[y("resize",".table-frame")],we=[o()],xe=[f("column-changed")],Ae=[d("selectorOptions")],Re=[d("sortable")],Me=[d("selectable")],ze=[d("columns",{immediate:!1})],$e=[d("groupBy","groupDefaults",{immediate:!1})],Fe=[d("data",{immediate:!1})],Ie=[d("loading")],Te=[d("selectedRows")],Le=[d("selectionMode",{immediate:!1})],Ve=[d("currentSort")],Be=[d("searchable","filterable","quickFilter")],Oe=[d("currentSort",{immediate:!1})],je=[d("currentPage",{immediate:!1})],Ne=[d("pageSize",{immediate:!1})],Pe=[d("density",{immediate:!1})],He=[d("list",{immediate:!1})],qe=[d("editable",{immediate:!1})],_e=[d("editMode",{immediate:!1})],Ge=[d("virtualize",{immediate:!1})],Ke=[d("rowHeight",{immediate:!1})],We=[d("columnResize",{immediate:!1})],Ue=[d("headerFilters",{immediate:!1})],Ze=[d("rowReorder",{immediate:!1})],Ye=[d("columnReorder",{immediate:!1})],Je=[d("lazyLoad","lazyLoadThreshold",{immediate:!1})],Qe=[d("columnMenu",{immediate:!1})],Xe=[h("page-change",{bubbles:!0,composed:!0})],et=[h("table-row-selection-changed",{bubbles:!0,composed:!0})],tt=[h("row-clicked",{bubbles:!0,composed:!0})],it=[h("table-load-error",{bubbles:!0,composed:!0})],at=[h("table-select-all-changed",{bubbles:!0,composed:!0})],st=[h("selection-changed",{bubbles:!0,composed:!0})],nt=[h("sort-change",{bubbles:!0,composed:!0})],lt=[h("filter-change",{bubbles:!0,composed:!0})],rt=[h("column-visibility-change",{bubbles:!0,composed:!0})],ot=[h("column-pin-change",{bubbles:!0,composed:!0})],ct=[h("column-order-change",{bubbles:!0,composed:!0})],dt=[h("density-change",{bubbles:!0,composed:!0})],ht=[u()],ut=[s({attribute:!1})],mt=[d("listRenderer",{immediate:!1})],pt=[h("group-toggle",{bubbles:!0,composed:!0})],w(this,null,re,{kind:"method",name:"getTableConfig",static:!1,private:!1,access:{has:e=>"getTableConfig"in e,get:e=>e.getTableConfig},metadata:e},null,vt),w(this,null,de,{kind:"method",name:"getTableData",static:!1,private:!1,access:{has:e=>"getTableData"in e,get:e=>e.getTableData},metadata:e},null,vt),w(this,null,he,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:e},null,vt),w(this,null,ue,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:e},null,vt),w(this,null,me,{kind:"method",name:"handleFrameResize",static:!1,private:!1,access:{has:e=>"handleFrameResize"in e,get:e=>e.handleFrameResize},metadata:e},null,vt),w(this,null,we,{kind:"method",name:"initialize",static:!1,private:!1,access:{has:e=>"initialize"in e,get:e=>e.initialize},metadata:e},null,vt),w(this,null,xe,{kind:"method",name:"handleDeclarativeColumnChange",static:!1,private:!1,access:{has:e=>"handleDeclarativeColumnChange"in e,get:e=>e.handleDeclarativeColumnChange},metadata:e},null,vt),w(this,null,Ae,{kind:"method",name:"handleSelectorOptionsChange",static:!1,private:!1,access:{has:e=>"handleSelectorOptionsChange"in e,get:e=>e.handleSelectorOptionsChange},metadata:e},null,vt),w(this,null,Re,{kind:"method",name:"handleSortableChange",static:!1,private:!1,access:{has:e=>"handleSortableChange"in e,get:e=>e.handleSortableChange},metadata:e},null,vt),w(this,null,Me,{kind:"method",name:"handleSelectableChange",static:!1,private:!1,access:{has:e=>"handleSelectableChange"in e,get:e=>e.handleSelectableChange},metadata:e},null,vt),w(this,null,ze,{kind:"method",name:"handleColumnsAssignment",static:!1,private:!1,access:{has:e=>"handleColumnsAssignment"in e,get:e=>e.handleColumnsAssignment},metadata:e},null,vt),w(this,null,$e,{kind:"method",name:"handleGroupByChange",static:!1,private:!1,access:{has:e=>"handleGroupByChange"in e,get:e=>e.handleGroupByChange},metadata:e},null,vt),w(this,null,Fe,{kind:"method",name:"handleDataAssignment",static:!1,private:!1,access:{has:e=>"handleDataAssignment"in e,get:e=>e.handleDataAssignment},metadata:e},null,vt),w(this,null,Ie,{kind:"method",name:"handleDataChange",static:!1,private:!1,access:{has:e=>"handleDataChange"in e,get:e=>e.handleDataChange},metadata:e},null,vt),w(this,null,Te,{kind:"method",name:"handleSelectedRowsChange",static:!1,private:!1,access:{has:e=>"handleSelectedRowsChange"in e,get:e=>e.handleSelectedRowsChange},metadata:e},null,vt),w(this,null,Le,{kind:"method",name:"handleSelectionModeChange",static:!1,private:!1,access:{has:e=>"handleSelectionModeChange"in e,get:e=>e.handleSelectionModeChange},metadata:e},null,vt),w(this,null,Ve,{kind:"method",name:"handleSortChange",static:!1,private:!1,access:{has:e=>"handleSortChange"in e,get:e=>e.handleSortChange},metadata:e},null,vt),w(this,null,Be,{kind:"method",name:"handleControlsChange",static:!1,private:!1,access:{has:e=>"handleControlsChange"in e,get:e=>e.handleControlsChange},metadata:e},null,vt),w(this,null,Oe,{kind:"method",name:"handleControlledSort",static:!1,private:!1,access:{has:e=>"handleControlledSort"in e,get:e=>e.handleControlledSort},metadata:e},null,vt),w(this,null,je,{kind:"method",name:"handleCurrentPageChange",static:!1,private:!1,access:{has:e=>"handleCurrentPageChange"in e,get:e=>e.handleCurrentPageChange},metadata:e},null,vt),w(this,null,Ne,{kind:"method",name:"handlePageSizeChange",static:!1,private:!1,access:{has:e=>"handlePageSizeChange"in e,get:e=>e.handlePageSizeChange},metadata:e},null,vt),w(this,null,Pe,{kind:"method",name:"handleDensityChange",static:!1,private:!1,access:{has:e=>"handleDensityChange"in e,get:e=>e.handleDensityChange},metadata:e},null,vt),w(this,null,He,{kind:"method",name:"handleListChange",static:!1,private:!1,access:{has:e=>"handleListChange"in e,get:e=>e.handleListChange},metadata:e},null,vt),w(this,null,qe,{kind:"method",name:"handleEditableChange",static:!1,private:!1,access:{has:e=>"handleEditableChange"in e,get:e=>e.handleEditableChange},metadata:e},null,vt),w(this,null,_e,{kind:"method",name:"handleEditModeChange",static:!1,private:!1,access:{has:e=>"handleEditModeChange"in e,get:e=>e.handleEditModeChange},metadata:e},null,vt),w(this,null,Ge,{kind:"method",name:"handleVirtualizeChange",static:!1,private:!1,access:{has:e=>"handleVirtualizeChange"in e,get:e=>e.handleVirtualizeChange},metadata:e},null,vt),w(this,null,Ke,{kind:"method",name:"handleRowHeightChange",static:!1,private:!1,access:{has:e=>"handleRowHeightChange"in e,get:e=>e.handleRowHeightChange},metadata:e},null,vt),w(this,null,We,{kind:"method",name:"handleColumnResizeChange",static:!1,private:!1,access:{has:e=>"handleColumnResizeChange"in e,get:e=>e.handleColumnResizeChange},metadata:e},null,vt),w(this,null,Ue,{kind:"method",name:"handleHeaderFiltersChange",static:!1,private:!1,access:{has:e=>"handleHeaderFiltersChange"in e,get:e=>e.handleHeaderFiltersChange},metadata:e},null,vt),w(this,null,Ze,{kind:"method",name:"handleRowReorderChange",static:!1,private:!1,access:{has:e=>"handleRowReorderChange"in e,get:e=>e.handleRowReorderChange},metadata:e},null,vt),w(this,null,Ye,{kind:"method",name:"handleColumnReorderChange",static:!1,private:!1,access:{has:e=>"handleColumnReorderChange"in e,get:e=>e.handleColumnReorderChange},metadata:e},null,vt),w(this,null,Je,{kind:"method",name:"handleLazyLoadChange",static:!1,private:!1,access:{has:e=>"handleLazyLoadChange"in e,get:e=>e.handleLazyLoadChange},metadata:e},null,vt),w(this,null,Qe,{kind:"method",name:"handleColumnMenuChange",static:!1,private:!1,access:{has:e=>"handleColumnMenuChange"in e,get:e=>e.handleColumnMenuChange},metadata:e},null,vt),w(this,null,Xe,{kind:"method",name:"dispatchPageChange",static:!1,private:!1,access:{has:e=>"dispatchPageChange"in e,get:e=>e.dispatchPageChange},metadata:e},null,vt),w(this,null,et,{kind:"method",name:"dispatchRowSelectionChanged",static:!1,private:!1,access:{has:e=>"dispatchRowSelectionChanged"in e,get:e=>e.dispatchRowSelectionChanged},metadata:e},null,vt),w(this,null,tt,{kind:"method",name:"dispatchRowClicked",static:!1,private:!1,access:{has:e=>"dispatchRowClicked"in e,get:e=>e.dispatchRowClicked},metadata:e},null,vt),w(this,null,it,{kind:"method",name:"dispatchLoadError",static:!1,private:!1,access:{has:e=>"dispatchLoadError"in e,get:e=>e.dispatchLoadError},metadata:e},null,vt),w(this,null,at,{kind:"method",name:"dispatchSelectAllChanged",static:!1,private:!1,access:{has:e=>"dispatchSelectAllChanged"in e,get:e=>e.dispatchSelectAllChanged},metadata:e},null,vt),w(this,null,st,{kind:"method",name:"dispatchSelectionChanged",static:!1,private:!1,access:{has:e=>"dispatchSelectionChanged"in e,get:e=>e.dispatchSelectionChanged},metadata:e},null,vt),w(this,null,nt,{kind:"method",name:"dispatchSortChange",static:!1,private:!1,access:{has:e=>"dispatchSortChange"in e,get:e=>e.dispatchSortChange},metadata:e},null,vt),w(this,null,lt,{kind:"method",name:"dispatchFilterChange",static:!1,private:!1,access:{has:e=>"dispatchFilterChange"in e,get:e=>e.dispatchFilterChange},metadata:e},null,vt),w(this,null,rt,{kind:"method",name:"dispatchColumnVisibilityChange",static:!1,private:!1,access:{has:e=>"dispatchColumnVisibilityChange"in e,get:e=>e.dispatchColumnVisibilityChange},metadata:e},null,vt),w(this,null,ot,{kind:"method",name:"dispatchColumnPinChange",static:!1,private:!1,access:{has:e=>"dispatchColumnPinChange"in e,get:e=>e.dispatchColumnPinChange},metadata:e},null,vt),w(this,null,ct,{kind:"method",name:"dispatchColumnOrderChange",static:!1,private:!1,access:{has:e=>"dispatchColumnOrderChange"in e,get:e=>e.dispatchColumnOrderChange},metadata:e},null,vt),w(this,null,dt,{kind:"method",name:"dispatchDensityChange",static:!1,private:!1,access:{has:e=>"dispatchDensityChange"in e,get:e=>e.dispatchDensityChange},metadata:e},null,vt),w(this,null,ht,{kind:"method",name:"cleanup",static:!1,private:!1,access:{has:e=>"cleanup"in e,get:e=>e.cleanup},metadata:e},null,vt),w(this,null,mt,{kind:"method",name:"handleListRendererChange",static:!1,private:!1,access:{has:e=>"handleListRendererChange"in e,get:e=>e.handleListRendererChange},metadata:e},null,vt),w(this,null,pt,{kind:"method",name:"dispatchGroupToggle",static:!1,private:!1,access:{has:e=>"dispatchGroupToggle"in e,get:e=>e.dispatchGroupToggle},metadata:e},null,vt),w(null,null,c,{kind:"field",name:"striped",static:!1,private:!1,access:{has:e=>"striped"in e,get:e=>e.striped,set:(e,t)=>{e.striped=t}},metadata:e},yt,wt),w(null,null,p,{kind:"field",name:"searchable",static:!1,private:!1,access:{has:e=>"searchable"in e,get:e=>e.searchable,set:(e,t)=>{e.searchable=t}},metadata:e},kt,xt),w(null,null,b,{kind:"field",name:"filterable",static:!1,private:!1,access:{has:e=>"filterable"in e,get:e=>e.filterable,set:(e,t)=>{e.filterable=t}},metadata:e},Ct,St),w(null,null,v,{kind:"field",name:"sortable",static:!1,private:!1,access:{has:e=>"sortable"in e,get:e=>e.sortable,set:(e,t)=>{e.sortable=t}},metadata:e},Et,Dt),w(null,null,x,{kind:"field",name:"selectable",static:!1,private:!1,access:{has:e=>"selectable"in e,get:e=>e.selectable,set:(e,t)=>{e.selectable=t}},metadata:e},At,Rt),w(null,null,C,{kind:"field",name:"hoverable",static:!1,private:!1,access:{has:e=>"hoverable"in e,get:e=>e.hoverable,set:(e,t)=>{e.hoverable=t}},metadata:e},Mt,zt),w(null,null,S,{kind:"field",name:"clickable",static:!1,private:!1,access:{has:e=>"clickable"in e,get:e=>e.clickable,set:(e,t)=>{e.clickable=t}},metadata:e},$t,Ft),w(null,null,E,{kind:"field",name:"list",static:!1,private:!1,access:{has:e=>"list"in e,get:e=>e.list,set:(e,t)=>{e.list=t}},metadata:e},It,Tt),w(null,null,D,{kind:"field",name:"pagination",static:!1,private:!1,access:{has:e=>"pagination"in e,get:e=>e.pagination,set:(e,t)=>{e.pagination=t}},metadata:e},Lt,Vt),w(null,null,A,{kind:"field",name:"paginationMode",static:!1,private:!1,access:{has:e=>"paginationMode"in e,get:e=>e.paginationMode,set:(e,t)=>{e.paginationMode=t}},metadata:e},Bt,Ot),w(null,null,R,{kind:"field",name:"pageSize",static:!1,private:!1,access:{has:e=>"pageSize"in e,get:e=>e.pageSize,set:(e,t)=>{e.pageSize=t}},metadata:e},jt,Nt),w(null,null,M,{kind:"field",name:"currentPage",static:!1,private:!1,access:{has:e=>"currentPage"in e,get:e=>e.currentPage,set:(e,t)=>{e.currentPage=t}},metadata:e},Pt,Ht),w(null,null,z,{kind:"field",name:"totalItems",static:!1,private:!1,access:{has:e=>"totalItems"in e,get:e=>e.totalItems,set:(e,t)=>{e.totalItems=t}},metadata:e},qt,_t),w(null,null,$,{kind:"field",name:"pageSizes",static:!1,private:!1,access:{has:e=>"pageSizes"in e,get:e=>e.pageSizes,set:(e,t)=>{e.pageSizes=t}},metadata:e},Gt,Kt),w(null,null,F,{kind:"field",name:"searchDebounce",static:!1,private:!1,access:{has:e=>"searchDebounce"in e,get:e=>e.searchDebounce,set:(e,t)=>{e.searchDebounce=t}},metadata:e},Wt,Ut),w(null,null,I,{kind:"field",name:"columns",static:!1,private:!1,access:{has:e=>"columns"in e,get:e=>e.columns,set:(e,t)=>{e.columns=t}},metadata:e},Zt,Yt),w(null,null,T,{kind:"field",name:"data",static:!1,private:!1,access:{has:e=>"data"in e,get:e=>e.data,set:(e,t)=>{e.data=t}},metadata:e},Jt,Qt),w(null,null,L,{kind:"field",name:"mode",static:!1,private:!1,access:{has:e=>"mode"in e,get:e=>e.mode,set:(e,t)=>{e.mode=t}},metadata:e},Xt,ei),w(null,null,V,{kind:"field",name:"currentSort",static:!1,private:!1,access:{has:e=>"currentSort"in e,get:e=>e.currentSort,set:(e,t)=>{e.currentSort=t}},metadata:e},ti,ii),w(null,null,B,{kind:"field",name:"selector",static:!1,private:!1,access:{has:e=>"selector"in e,get:e=>e.selector,set:(e,t)=>{e.selector=t}},metadata:e},ai,si),w(null,null,O,{kind:"field",name:"selectorOptions",static:!1,private:!1,access:{has:e=>"selectorOptions"in e,get:e=>e.selectorOptions,set:(e,t)=>{e.selectorOptions=t}},metadata:e},ni,li),w(null,null,j,{kind:"field",name:"loading",static:!1,private:!1,access:{has:e=>"loading"in e,get:e=>e.loading,set:(e,t)=>{e.loading=t}},metadata:e},ri,oi),w(null,null,N,{kind:"field",name:"virtualize",static:!1,private:!1,access:{has:e=>"virtualize"in e,get:e=>e.virtualize,set:(e,t)=>{e.virtualize=t}},metadata:e},ci,di),w(null,null,P,{kind:"field",name:"rowHeight",static:!1,private:!1,access:{has:e=>"rowHeight"in e,get:e=>e.rowHeight,set:(e,t)=>{e.rowHeight=t}},metadata:e},hi,ui),w(null,null,H,{kind:"field",name:"virtualBuffer",static:!1,private:!1,access:{has:e=>"virtualBuffer"in e,get:e=>e.virtualBuffer,set:(e,t)=>{e.virtualBuffer=t}},metadata:e},mi,pi),w(null,null,q,{kind:"field",name:"columnResize",static:!1,private:!1,access:{has:e=>"columnResize"in e,get:e=>e.columnResize,set:(e,t)=>{e.columnResize=t}},metadata:e},gi,bi),w(null,null,_,{kind:"field",name:"editable",static:!1,private:!1,access:{has:e=>"editable"in e,get:e=>e.editable,set:(e,t)=>{e.editable=t}},metadata:e},fi,vi),w(null,null,G,{kind:"field",name:"editMode",static:!1,private:!1,access:{has:e=>"editMode"in e,get:e=>e.editMode,set:(e,t)=>{e.editMode=t}},metadata:e},yi,wi),w(null,null,K,{kind:"field",name:"density",static:!1,private:!1,access:{has:e=>"density"in e,get:e=>e.density,set:(e,t)=>{e.density=t}},metadata:e},ki,xi),w(null,null,W,{kind:"field",name:"headerFilters",static:!1,private:!1,access:{has:e=>"headerFilters"in e,get:e=>e.headerFilters,set:(e,t)=>{e.headerFilters=t}},metadata:e},Ci,Si),w(null,null,U,{kind:"field",name:"quickFilter",static:!1,private:!1,access:{has:e=>"quickFilter"in e,get:e=>e.quickFilter,set:(e,t)=>{e.quickFilter=t}},metadata:e},Ei,Di),w(null,null,Z,{kind:"field",name:"rowReorder",static:!1,private:!1,access:{has:e=>"rowReorder"in e,get:e=>e.rowReorder,set:(e,t)=>{e.rowReorder=t}},metadata:e},Ai,Ri),w(null,null,Y,{kind:"field",name:"columnReorder",static:!1,private:!1,access:{has:e=>"columnReorder"in e,get:e=>e.columnReorder,set:(e,t)=>{e.columnReorder=t}},metadata:e},Mi,zi),w(null,null,J,{kind:"field",name:"columnMenu",static:!1,private:!1,access:{has:e=>"columnMenu"in e,get:e=>e.columnMenu,set:(e,t)=>{e.columnMenu=t}},metadata:e},$i,Fi),w(null,null,Q,{kind:"field",name:"lazyLoad",static:!1,private:!1,access:{has:e=>"lazyLoad"in e,get:e=>e.lazyLoad,set:(e,t)=>{e.lazyLoad=t}},metadata:e},Ii,Ti),w(null,null,X,{kind:"field",name:"lazyLoadThreshold",static:!1,private:!1,access:{has:e=>"lazyLoadThreshold"in e,get:e=>e.lazyLoadThreshold,set:(e,t)=>{e.lazyLoadThreshold=t}},metadata:e},Li,Vi),w(null,null,ee,{kind:"field",name:"selectedRows",static:!1,private:!1,access:{has:e=>"selectedRows"in e,get:e=>e.selectedRows,set:(e,t)=>{e.selectedRows=t}},metadata:e},Bi,Oi),w(null,null,te,{kind:"field",name:"selectionMode",static:!1,private:!1,access:{has:e=>"selectionMode"in e,get:e=>e.selectionMode,set:(e,t)=>{e.selectionMode=t}},metadata:e},ji,Ni),w(null,null,ie,{kind:"field",name:"groupBy",static:!1,private:!1,access:{has:e=>"groupBy"in e,get:e=>e.groupBy,set:(e,t)=>{e.groupBy=t}},metadata:e},Pi,Hi),w(null,null,ae,{kind:"field",name:"groupDefaults",static:!1,private:!1,access:{has:e=>"groupDefaults"in e,get:e=>e.groupDefaults,set:(e,t)=>{e.groupDefaults=t}},metadata:e},qi,_i),w(null,null,se,{kind:"field",name:"table",static:!1,private:!1,access:{has:e=>"table"in e,get:e=>e.table,set:(e,t)=>{e.table=t}},metadata:e},Gi,Ki),w(null,null,ne,{kind:"field",name:"thead",static:!1,private:!1,access:{has:e=>"thead"in e,get:e=>e.thead,set:(e,t)=>{e.thead=t}},metadata:e},Wi,Ui),w(null,null,le,{kind:"field",name:"tbody",static:!1,private:!1,access:{has:e=>"tbody"in e,get:e=>e.tbody,set:(e,t)=>{e.tbody=t}},metadata:e},Zi,Yi),w(null,null,ut,{kind:"field",name:"listRenderer",static:!1,private:!1,access:{has:e=>"listRenderer"in e,get:e=>e.listRenderer,set:(e,t)=>{e.listRenderer=t}},metadata:e},Ji,Qi),w(null,t={value:a},gt,{kind:"class",name:a.name,metadata:e},null,bt),Xi=a=t.value,e&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})}setColumns(e){this.columns=e}setData(e){this.settingDataImperative=!0,this.data=e,this.settingDataImperative=!1}async*getTableConfig(){const e=await(yield{});return this.columns=e.columns||[],this.selectorOptions=e.selectorOptions||[],await new Promise(e=>requestAnimationFrame(e)),this.renderHeader(),this.renderControls(),e}async*getTableData(){const e=++this.dataRequestSeq;this.loading=!0,this.selectedRows=[];try{const t={search:this.searchText,sort:this.currentSort,filter:this.filterEngine.getFilterModel(),selector:this.selector};this.pagination&&(t.page=this.currentPage,t.pageSize=this.pageSize);const i=await(yield t);if(e!==this.dataRequestSeq)return;if(this.data=i.data||[],this.rebuildRowIndex(),void 0!==i.totalItems&&(this.totalItems=i.totalItems),this.loadError=null,this.classList.remove("table--error"),this.loading=!1,await new Promise(e=>requestAnimationFrame(e)),e!==this.dataRequestSeq)return;return this.renderBody(),i}catch(t){if(e!==this.dataRequestSeq)return;console.error("Error loading table data:",t),this.loadError=t instanceof Error?t.message:String(t),this.classList.add("table--error"),this.dispatchLoadError(t),this.loading=!1,await new Promise(e=>requestAnimationFrame(e)),this.renderBody()}}scheduleRender(e){"header"!==e&&"both"!==e||(this.pendingHeaderRender=!0),"body"!==e&&"both"!==e||(this.pendingBodyRender=!0),this.renderQueued||(this.renderQueued=!0,queueMicrotask(()=>{queueMicrotask(()=>{this.renderQueued=!1;const e=this.pendingHeaderRender,t=this.pendingBodyRender;this.pendingHeaderRender=!1,this.pendingBodyRender=!1,e&&this.renderHeader(),t&&this.renderBody()})}))}debouncedDataRequest(){this.loading||(this.loading=!0),this.dataRequestTimeout&&clearTimeout(this.dataRequestTimeout),this.dataRequestTimeout=setTimeout(()=>{this.getTableData(),this.dataRequestTimeout=null},150)}styles(){return m`
590
590
  :host([hidden]) {
591
591
  display: none;
592
592
  }
@@ -1664,7 +1664,7 @@ import{html as e,unsafeHTML as t,element as i,state as a,property as s,query as
1664
1664
  </div>
1665
1665
  <div class="table-pagination-container"></div>
1666
1666
  </div>
1667
- `}renderControls(){const e=this.shadowRoot?.querySelector(".table-controls-container");if(!e)return;if(this.toolbarOptions)return void this.setToolbar(this.toolbarOptions);if(!(this.searchable||this.filterable||this.quickFilter))return void(e.innerHTML="");e.innerHTML="";const t=document.createElement("div");if(t.className="table-controls",t.setAttribute("part","controls"),this.quickFilter){const e=document.createElement("snice-input");e.className="quick-filter-input",e.type="search",e.placeholder="Quick filter...",e.size="small",e.clearable=!0,e.style.width="16rem",e.style.maxWidth="16rem",e.value=this.filterEngine.getFilterModel().quickFilter||"",e.addEventListener("input",this.handleQuickFilterInput),t.appendChild(e)}else if(this.searchable){const e=document.createElement("snice-input");e.className="search-input",e.setAttribute("type","search"),e.setAttribute("placeholder","Search..."),e.setAttribute("size","small"),e.style.width="16rem",e.style.maxWidth="16rem",e.style.flex="0 0 auto",e.addEventListener("input",this.handleSearchInput),t.appendChild(e)}if(this.filterable){const e=document.createElement("snice-select");e.className="selector-input",e.setAttribute("multiple",""),e.setAttribute("searchable",""),e.setAttribute("clearable",""),e.setAttribute("placeholder","Filter..."),e.setAttribute("size","medium"),this.selectorOptions.forEach(t=>{const i=document.createElement("snice-option");i.setAttribute("value",t.value),i.textContent=t.label,e.appendChild(i)}),t.appendChild(e)}e.appendChild(t)}handleFrameResize(){this.updateFillRow()}async initialize(){this.addEventListener("controller-attached",this.onAttached),this.addEventListener("select-change",this.handleSelectorChange),this.addEventListener("row-select",this.handleSlottedRowSelect),this.addEventListener("detail-toggle",()=>this.renderBody()),this.addEventListener("cell-edit-commit",e=>{const{rowIndex:t,columnKey:i,newValue:a}=e.detail,s=this.data[t];s&&(s[i]=a),this.invalidateFilteredCache(),s&&this.invalidateRenderedRow(s)}),this.addEventListener("row-edit-commit",e=>{const{rowIndex:t,newRow:i}=e.detail;this.data[t]&&(this.data[t]=i),this.rebuildRowIndex()}),await customElements.whenDefined("snice-column"),await customElements.whenDefined("snice-row"),await this.processSlottedContent(),await this.rendered,this.syncGrouping(),this.renderControls(),this.initializeModules(),this.initColumnMenu(),this.rowReorder&&this.rowDnD.attach(this),this.columnReorder&&this.columnDnD.attach(this),this.renderHeader(),this.renderBody(),this.virtualize&&requestAnimationFrame(()=>{this.virtualizer.isEnabled()||this.setupVirtualization()}),this.lazyLoad&&requestAnimationFrame(()=>this.setupLazyLoading()),this.addEventListener("row-reorder",e=>{const{fromIndex:t,toIndex:i}=e.detail;if(!Number.isInteger(t)||!Number.isInteger(i)||t<0||i<0||t>=this.data.length||i>=this.data.length)return;if(t===i)return;const a=this.selectedRows.map(e=>this.data[e]).filter(e=>void 0!==e),s=Array.from(this.masterDetail.getExpandedRows()).map(e=>this.data[e]).filter(e=>void 0!==e),n=this.data.splice(t,1)[0],l=this.data[i>t?i-1:i];if(n&&l&&this.grouping.hasGrouping())for(const e of this.grouping.getGroupByKeys())n[e]=l[e];this.data.splice(i,0,n),this.data=[...this.data],this.selectedRows=a.map(e=>this.indexOfRow(e)).filter(e=>e>=0),this.masterDetail.setExpandedRows(s.map(e=>this.indexOfRow(e)).filter(e=>e>=0))}),this.addEventListener("column-reorder",e=>{const{fromKey:t,toKey:i}=e.detail,a=this.columns.findIndex(e=>e.key===t),s=this.columnManager.getVisibleColumns().findIndex(e=>e.key===i);a>=0&&s>=0&&(this.columnManager.moveColumn(t,s),this.renderHeader(),this.renderBody())}),this.addEventListener("tree-toggle",()=>this.renderBody())}async processSlottedContent(){const e=Array.from(this.querySelectorAll('snice-column[slot="columns"]')),t=Array.from(this.querySelectorAll('snice-row[slot="rows"]'));await Promise.all(t.map(e=>e.ready)),e.length>0&&(this.columns=e.map(e=>e.getColumnDefinition())),t.forEach((e,t)=>{e.columns=this.columns,e.index=t,e.hoverable=this.hoverable,e.clickable=this.clickable}),this.syncSlottedSelectionState(),this.shouldModelSlottedRows()&&this.syncSlottedRowsIntoData(),e.length>0&&!this.shouldModelSlottedRows()&&requestAnimationFrame(()=>this.renderSlottedHeader())}shouldModelSlottedRows(){return(Array.isArray(this.groupBy)?this.groupBy:this.groupBy?[this.groupBy]:[]).some(Boolean)||this.columns.some(e=>null!=e.aggregate)}syncSlottedRowsIntoData(){const e=Array.from(this.querySelectorAll('snice-row[slot="rows"]'));if(0===e.length)return;const t=e.map(e=>{if(e.data&&Object.keys(e.data).length>0)return e.data;const t=e.getAttribute("data");if(t)try{return JSON.parse(t)}catch{}return e.data??{}});this.data=t}renderSlottedHeader(){const e=this.shadowRoot?.querySelector("#slotted-header");if(e&&0!==this.columns.length){e.replaceChildren();for(const t of this.columns){const i=document.createElement("div");i.className="header-cell",i.textContent=t.label??t.key,e.appendChild(i)}}}handleDeclarativeColumnChange(){const e=Array.from(this.querySelectorAll('snice-column[slot="columns"]'));0!==e.length&&(this.columns=e.map(e=>e.getColumnDefinition()),Array.from(this.querySelectorAll('snice-row[slot="rows"]')).forEach(e=>{e.columns=this.columns}),requestAnimationFrame(()=>{this.shouldModelSlottedRows()||this.renderSlottedHeader(),this.renderControls()}))}handleSelectorOptionsChange(){0===this.selectorOptions.length?this.classList.add("selector-options-empty"):this.classList.remove("selector-options-empty")}handleSortableChange(){this.renderHeader()}handleSelectableChange(){this.render(),queueMicrotask(()=>this.syncSlottedSelectionState())}handleColumnsAssignment(){this.renderedRows=new Map,this.columns.length>0&&this.columnManager.initialize(this.columns,this),this.grouping.setColumns(this.columns),this.invalidateGroupingCache();const e=!!this.querySelector('snice-row[slot="rows"]'),t=this.shouldModelSlottedRows();e&&this.virtualizer.isEnabled()&&!!this.shadowRoot?.querySelector("table")!==t&&this.virtualizer.detach(),t&&this.syncSlottedRowsIntoData(),e&&requestAnimationFrame(()=>{t||this.renderSlottedHeader(),this.renderControls(),this.toolbarOptions&&this.setToolbar(this.toolbarOptions),this.lazyLoad&&this.setupLazyLoading()}),this.scheduleRender("both")}handleGroupByChange(){this.syncGrouping();const e=!!this.querySelector('snice-row[slot="rows"]'),t=this.shouldModelSlottedRows();e&&this.virtualizer.isEnabled()&&!!this.shadowRoot?.querySelector("table")!==t&&this.virtualizer.detach(),t&&this.syncSlottedRowsIntoData(),e&&requestAnimationFrame(()=>{t||this.renderSlottedHeader(),this.renderControls(),this.toolbarOptions&&this.setToolbar(this.toolbarOptions),this.lazyLoad&&this.setupLazyLoading()}),this.scheduleRender(e?"both":"body")}syncGrouping(){const e=Array.isArray(this.groupBy)?this.groupBy.filter(Boolean):this.groupBy?[this.groupBy]:[];this.grouping.configure({groupBy:e,defaultExpanded:!1!==this.groupDefaults?.expanded}),this.grouping.setColumns(this.columns),this.invalidateGroupingCache()}handleDataAssignment(){this.settingSortedData||(this.unsortedData=[...this.data],this.rebuildRowIndex(),this.masterDetail.prepare(this.data),this.settingDataImperative||this.scheduleRender("body"))}handleDataChange(){this.renderBody(),this.updateLoadingOverlay()}updateLoadingOverlay(){const e=this.shadowRoot?.querySelector(".table-frame");if(!e)return;let t=e.querySelector(".table-loading-overlay");const i=this.loading&&this.data.length>0;if(i&&!t){t=document.createElement("div"),t.className="table-loading-overlay",t.setAttribute("part","loading-overlay");const i=document.createElement("snice-progress");i.setAttribute("variant","circular"),i.setAttribute("indeterminate",""),i.setAttribute("size","small"),t.appendChild(i),e.appendChild(t)}else!i&&t&&t.remove()}handleSelectedRowsChange(e,t){const i=new Set(e??[]),a=new Set(t??this.selectedRows??[]),s=new Set;for(const e of i)a.has(e)||s.add(e);for(const e of a)i.has(e)||s.add(e);for(const e of s)this.updateRowSelectionStateFor(e,a.has(e));this.updateSelectAllState(),this.updateGroupSelectionStates()}handleSelectionModeChange(){"none"===this.selectionMode?(this.selectedRows=[],this.selectionAnchor=null):"single"===this.selectionMode&&this.selectedRows.length>1&&(this.selectedRows=this.selectedRows.slice(0,1),this.selectionAnchor=this.data[this.selectedRows[0]]??null),this.syncSlottedSelectionState(),this.scheduleRender("both")}handleSortChange(){this.renderHeader()}handleControlsChange(){this.renderControls(),this.quickFilter&&this.scheduleRender("body")}handleControlledSort(){"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()}handleCurrentPageChange(){"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.scheduleRender("body")}handlePageSizeChange(){this.currentPage=1,"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.scheduleRender("body")}handleDensityChange(){this.scheduleRender("body"),this.dispatchDensityChange()}handleListChange(){this.renderedRows=new Map,this.scheduleRender("body")}handleEditableChange(){this.editable&&this.setupEditor(),this.scheduleRender("body")}handleEditModeChange(){this.editable&&this.editor.setEditMode(this.editMode),this.scheduleRender("body")}handleVirtualizeChange(){this.virtualize||this.virtualizer.detach(),this.scheduleRender("body")}handleRowHeightChange(){this.scheduleRender("body")}handleColumnResizeChange(){this.scheduleRender("header")}handleHeaderFiltersChange(){this.scheduleRender("header")}handleRowReorderChange(){this.rowReorder?this.rowDnD.attach(this):this.rowDnD.detach(),this.scheduleRender("both")}handleColumnReorderChange(){this.columnReorder?this.columnDnD.attach(this):this.columnDnD.detach(),this.scheduleRender("header")}handleLazyLoadChange(){this.lazyLoad?queueMicrotask(()=>this.setupLazyLoading()):(this.lazyLoadHandler&&this.lazyLoadContainer?.removeEventListener("scroll",this.lazyLoadHandler),this.lazyLoadHandler=null,this.lazyLoadContainer=null)}handleColumnMenuChange(){this.columnMenu&&this.initColumnMenu(),this.scheduleRender("header")}getVisibleColumnDefinitions(){if(0===this.columnManager.getAllStates().length)return this.columns;const e=[...this.columnManager.getPinnedLeft(),...this.columnManager.getUnpinned(),...this.columnManager.getPinnedRight()],t=new Map(this.columns.map(e=>[e.key,e]));return e.map(e=>t.get(e.key)).filter(e=>!!e)}renderHeader(){if(!this.thead)return;const e=document.createElement("tr");if(e.className="column-header-row",this.rowReorder&&this.rowDnD.isEnabled()){const t=document.createElement("th");t.setAttribute("scope","col"),t.className="drag-handle-cell",e.appendChild(t)}if(this.masterDetail.isEnabled()){const t=document.createElement("th");t.setAttribute("scope","col"),t.className="detail-toggle-cell",e.appendChild(t)}if(this.hasSelectionColumn()){const t=document.createElement("th");if(t.setAttribute("scope","col"),t.className="select-column","multiple"===this.selectionMode){const e=this.getSelectableIndices(this.getFilteredData()),i=e.filter(e=>this.selectedRows.includes(e)),a=i.length>0&&i.length<e.length;t.innerHTML=`<snice-checkbox class="select-all" size="small" compact ${i.length===e.length&&e.length>0?"checked":""}></snice-checkbox>`,setTimeout(()=>{const e=t.querySelector(".select-all");e&&(e.indeterminate=a)},0)}else t.setAttribute("aria-label","Select one row");e.appendChild(t)}const t=this.getVisibleColumnDefinitions();if(t.forEach(t=>{const i=document.createElement("th");if(i.setAttribute("data-key",t.key),i.setAttribute("scope","col"),this.sortable&&!1!==t.sortable){const e=this.currentSort.find(e=>e.column===t.key);i.setAttribute("aria-sort","asc"===e?.direction?"ascending":"desc"===e?.direction?"descending":"none")}const a=this.columnManager.getState(t.key);if(a)if(i.style.width=`${a.width}px`,"left"===a.pinned){const e=this.columnManager.getPinnedLeftOffsets();i.classList.add("pinned-cell"),i.style.position="sticky",i.style.left=`${e.get(t.key)??0}px`,i.style.zIndex="2"}else if("right"===a.pinned){const e=this.columnManager.getPinnedRightOffsets();i.classList.add("pinned-cell"),i.style.position="sticky",i.style.right=`${e.get(t.key)??0}px`,i.style.zIndex="2"}if(this.sortable&&!1!==t.sortable?(i.classList.add("sortable"),i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i.setAttribute("aria-label",`Sort by ${t.label}`),i.innerHTML=this.renderSortableHeader(t)):i.textContent=t.label,this.filterEngine.hasColumnFilter(t.key)&&i.classList.add("filtered"),this.columnResize&&!1!==t.resizable){const e=document.createElement("span");e.className="resize-handle",e.addEventListener("mousedown",e=>{e.stopPropagation(),this.columnManager.startResize(t.key,e.clientX)}),e.addEventListener("dblclick",e=>{e.stopPropagation(),this.tbody&&(this.columnManager.autoSizeColumn(t.key,this.tbody),this.renderHeader(),this.renderBody())}),i.appendChild(e)}this.columnMenu&&i.addEventListener("contextmenu",e=>{e.preventDefault();const i=this.columnManager.getState(t.key);this.columnMenuManager.show(t.key,e.clientX,e.clientY,{sortable:this.sortable&&!1!==t.sortable,filterable:!1!==t.filterable,hideable:i?.hideable,pinnable:i?.pinnable,pinned:i?.pinned})}),this.columnReorder&&this.columnDnD.isEnabled()&&this.columnDnD.makeHeaderDraggable(i,t.key,!1!==t.reorderable&&!a?.pinned),e.appendChild(i)}),this.thead.innerHTML="",this.columnManager.getColumnGroups().length>0){const e=document.createElement("tr");e.className="column-group-row";const i=[this.rowReorder&&this.rowDnD.isEnabled()?"drag-handle-cell":"",this.masterDetail.isEnabled()?"detail-toggle-cell":"",this.hasSelectionColumn()?"select-column":""].filter(Boolean);for(const t of i){const i=document.createElement("th");i.className=t,i.setAttribute("aria-hidden","true"),e.appendChild(i)}const a=document.createElement("template");a.innerHTML=this.columnManager.renderGroupHeaders(t.map(e=>e.key)),e.appendChild(a.content),this.thead.appendChild(e)}if(this.thead.appendChild(e),this.headerFilters){const e=document.createElement("tr");if(e.className="header-filter-row",this.rowReorder&&this.rowDnD.isEnabled()){const t=document.createElement("td");t.className="drag-handle-cell",e.appendChild(t)}if(this.masterDetail.isEnabled()){const t=document.createElement("td");t.className="detail-toggle-cell",e.appendChild(t)}if(this.hasSelectionColumn()){const t=document.createElement("td");t.className="select-column",e.appendChild(t)}t.forEach(t=>{const i=document.createElement("td"),a=document.createElement("snice-input");a.size="small",a.placeholder=`Filter ${t.label}...`,a.setAttribute("data-column",t.key),a.value=this.filterEngine.getHeaderFilter(t.key),a.style.cssText="width:100%;--snice-color-border:transparent;--snice-border-radius-md:0;",a.addEventListener("input",()=>{this.filterEngine.setHeaderFilter(t.key,a.value),this.debouncedApplyClientFilters()}),i.appendChild(a),e.appendChild(i)}),this.thead.appendChild(e)}}renderSortableHeader(e){const t=this.currentSort.find(t=>t.column===e.key),i=this.currentSort.findIndex(t=>t.column===e.key),a='<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 5l4-4 4 4"/></svg>',s='<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 1l4 4 4-4"/></svg>';let n=`<span style="display:flex;flex-direction:column;gap:0;opacity:0.3">${a}${s}</span>`,l="";t&&("asc"===t.direction?n=a:"desc"===t.direction&&(n=s),this.currentSort.length>1&&(l=`<span class="sort-order">${i+1}</span>`));const r=["sort-indicator",t?"active":""].filter(Boolean).join(" ");return`\n <div class="sort-header">\n <span>${e.label}</span>\n <div class="${r}">\n ${n}\n ${l}\n </div>\n </div>\n `}renderBody(){if(!this.tbody)return;if(this.columns.length>0&&this.columnManager.initialize(this.columns,this),this.grouping.setColumns(this.columns)&&this.invalidateGroupingCache(),this.pagination&&"client"===this.paginationMode&&(this.usesGroupingDisplayModel()?this.totalItems=this.getGroupingItems().length:this.treeData.isEnabled()&&(this.totalItems=this.getTreeDisplayRows(!1).length)),this.virtualize&&!this.virtualizer.isEnabled()&&this.setupVirtualization(),this.virtualize&&this.virtualizer.isEnabled())return this.virtualRowsSnapshot=this.getVirtualRows(),this.virtualizer.setTotalRows(this.virtualRowsSnapshot.length),void(this.pagination&&this.renderPagination());if(0===this.data.length&&this.columns.length>0){this.tbody.innerHTML="",this.renderedRows=new Map;const e=(this.hasSelectionColumn()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),t=this.columns.length+e;if(this.loading){const e=document.createElement("tr"),i=document.createElement("td");return i.colSpan=t,i.className="no-data",i.innerHTML='<snice-progress variant="circular" indeterminate size="small"></snice-progress>',e.appendChild(i),void this.tbody.appendChild(e)}if(this.loadError){const e=document.createElement("tr"),i=document.createElement("td");i.colSpan=t,i.className="no-data";const a=document.createElement("div");return a.className="table-error-message",a.textContent=`⚠️ ${this.loadError}`,i.appendChild(a),e.appendChild(i),void this.tbody.appendChild(e)}{const e=document.createElement("tr"),i=document.createElement("td");i.colSpan=t,i.className="no-data";const a=this.querySelector('[slot="empty-state"]');if(a)i.appendChild(a.cloneNode(!0));else{const e=document.createElement("snice-empty-state");e.setAttribute("size","small"),e.setAttribute("icon","📭"),e.setAttribute("title","No data"),e.setAttribute("description","No records to display."),i.appendChild(e)}return e.appendChild(i),void this.tbody.appendChild(e)}}const e=this.getFilteredData();let t=e;if(this.pagination&&"client"===this.paginationMode&&!this.usesGroupingDisplayModel()&&!this.treeData.isEnabled()){this.totalItems=e.length;const i=(this.currentPage-1)*this.pageSize;t=e.slice(i,i+this.pageSize)}const i=(this.hasSelectionColumn()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),a=(this.columnManager.getAllStates().length>0?this.columnManager.getVisibleColumns().length:this.columns.length)+i,s=this.computeStructuralSig(),n=[];if(this.pinnedTopRows.forEach((e,t)=>{n.push({key:`__pinned_top_${t}`,sig:"pinned",alwaysRebuild:!0,create:()=>{const t=this.createRow(e,-1);return t.classList.add("pinned-row","pinned-row--top"),t}})}),this.usesGroupingDisplayModel()){const e=this.getDisplayedGroupingItems();for(const t of e)if("group"===t.type)n.push({key:t.key,sig:`${s}|grp:${t.key}:${t.expanded?1:0}:${t.count}`,alwaysRebuild:!0,create:()=>this.createGroupRow(t,a)});else if("aggregate"===t.type)n.push({key:t.key,sig:`${s}|agg:${t.key}`,alwaysRebuild:!0,create:()=>this.createAggregateRow(t,a)});else{const e=this.indexOfRow(t.data),i=this.isRowEditing(e);n.push({key:t.data,sig:this.rowSignature(t.data,e,s)+(i?"|edit":""),alwaysRebuild:i,restampIndex:e,create:()=>this.createRow(t.data,e)}),this.masterDetail.isEnabled()&&this.masterDetail.isExpanded(e)&&n.push({key:`__detail_${e}`,sig:"detail",alwaysRebuild:!0,create:()=>this.masterDetail.createDetailRow(t.data,e,a)??document.createElement("tr")})}}else this.treeData.isEnabled()?this.getTreeDisplayRows(!0).forEach(({data:e,index:t,treeRow:i,groupItem:l})=>{if("aggregate"===l?.type)return void n.push({key:l.key,sig:`${s}|agg:${l.key}`,alwaysRebuild:!0,create:()=>this.createAggregateRow(l,a)});if(!i)return;const r=this.isRowEditing(t);n.push({key:e,sig:this.rowSignature(e,t,s,i)+(r?"|edit":""),alwaysRebuild:r,restampIndex:t,create:()=>this.createRow(e,t,i)})}):t.forEach(e=>{const t=this.indexOfRow(e),i=this.isRowEditing(t);n.push({key:e,sig:this.rowSignature(e,t,s)+(i?"|edit":""),alwaysRebuild:i,restampIndex:t,create:()=>this.createRow(e,t)}),this.masterDetail.isEnabled()&&this.masterDetail.isExpanded(t)&&n.push({key:`__detail_${t}`,sig:"detail",alwaysRebuild:!0,create:()=>this.masterDetail.createDetailRow(e,t,a)??document.createElement("tr")})});this.pinnedBottomRows.forEach((e,t)=>{n.push({key:`__pinned_bottom_${t}`,sig:"pinned",alwaysRebuild:!0,create:()=>{const t=this.createRow(e,-1);return t.classList.add("pinned-row","pinned-row--bottom"),t}})}),this.reconcileRows(n),this.keyboard.refresh(),this.pagination&&this.renderPagination(),this.updateFillRow()}updateFillRow(){const e=this.shadowRoot?.querySelector(".table-frame"),t=e?.querySelector("table"),i=t?.querySelector("tbody");if(!e||!t||!i)return;if(i.querySelector("tr.table-fill-row")?.remove(),this.list&&this.listRenderer)return;const a=i.querySelectorAll("tr[data-index]"),s=a[a.length-1];if(!s)return;const n=Math.floor(e.clientHeight-t.offsetHeight);if(n<=1)return;const l=s.cloneNode(!0);l.className="table-fill-row";for(const e of["data-index","data-selected","role","aria-rowindex","aria-selected","tabindex","id"])l.removeAttribute(e);l.setAttribute("aria-hidden","true"),l.querySelectorAll("td").forEach(e=>{e.replaceChildren();for(const t of["role","aria-colindex","tabindex","aria-selected"])e.removeAttribute(t)}),l.style.height=`${n}px`,i.appendChild(l)}reconcileRows(e){const t=this.tbody;if(!t)return;const i=new Map,a=[],s=new Set;for(const t of e){const e=this.renderedRows.get(t.key);let n;!e||s.has(e.el)||t.alwaysRebuild||e.sig!==t.sig?n=t.create():(n=e.el,void 0!==t.restampIndex&&this.restampRowIndex(n,t.restampIndex)),s.add(n),a.push(n),i.has(t.key)||i.set(t.key,{el:n,sig:t.sig})}const n=new Set(a);for(const e of Array.from(t.children))n.has(e)||e.remove();let l=t.firstChild;for(const e of a)if(e===l)l=e.nextSibling;else{const i=document.createDocumentFragment();i.appendChild(e),t.insertBefore(i,l)}this.renderedRows=i}rendererIdFor(e){if("function"!=typeof e)return"";let t=this.rendererIds.get(e);return void 0===t&&(t=++this.rendererIdSeq,this.rendererIds.set(e,t)),String(t)}computeStructuralSig(){const e=this.getVisibleColumnDefinitions().map(e=>{const t=this.columnManager.getState(e.key),i=this.rendererIdFor(e.renderCell);return`${e.key}:${t?.width??""}:${t?.pinned??""}:rc${i}`});return[e.join(","),`pl=${Array.from(this.columnManager.getPinnedLeftOffsets().values()).join("/")}`,`pr=${Array.from(this.columnManager.getPinnedRightOffsets().values()).join("/")}`,`sel=${this.selectable?this.selectionMode:"off"}`,`selectable=${this.rendererIdFor(this.selectabilityCheck)}`,"md="+(this.masterDetail.isEnabled()?1:0),"rr="+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),`rh=${this.rowHeight}`,`d=${this.density}`,`tree=${this.treeData.isEnabled()?this.treeData.getGroupColumn():""}`].join("|")}rowSignature(e,t,i,a){const s=[i];return a&&s.push(`t:${a.depth}:${a.expanded?1:0}:${a.hasChildren?1:0}`),this.rowHeightCallback&&s.push(`h:${this.rowHeightCallback(e,t)}`),this.masterDetail.isEnabled()&&s.push("detail:"+(this.masterDetail.isExpanded(t)?1:0)),(this.rowReorder&&this.rowDnD.isEnabled()||this.masterDetail.isEnabled())&&s.push(`i:${t}`),s.join("|")}isRowEditing(e){if(!this.editable)return!1;if("row"===this.editMode){const t=this.editor.getRowEditState();return!(!t?.isEditing||t.rowIndex!==e)}const t=this.editor.getCellEditState();return!(!t?.isEditing||t.rowIndex!==e)}restampRowIndex(e,t){e.setAttribute("data-index",String(t));const i=this.selectedRows.includes(t);e.setAttribute("data-selected",String(i));const a=e.querySelector("snice-checkbox.row-select");if(a){a.setAttribute("data-row-index",String(t)),a.checked=i;const e=!(!this.selectabilityCheck||this.selectabilityCheck(this.data[t],t));a.disabled=e,a.toggleAttribute("disabled",e)}}invalidateRenderedRow(e){this.renderedRows.delete(e)}paginationTotal(){return"client"!==this.paginationMode?this.totalItems:this.usesGroupingDisplayModel()?this.getGroupingItems().length:this.treeData.isEnabled()?this.getTreeDisplayRows(!1).length:this.data.length}get totalPages(){const e=this.paginationTotal();return Math.max(1,Math.ceil(e/this.pageSize))}goToPage(e){const t=Math.max(1,Math.min(e,this.totalPages));t!==this.currentPage&&(this.currentPage=t,"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.renderBody(),this.dispatchPageChange())}setPageSize(e){this.pageSize=e,this.currentPage=1,"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.renderBody(),this.dispatchPageChange()}dispatchPageChange(){return{page:this.currentPage,pageSize:this.pageSize,totalPages:this.totalPages,totalItems:this.paginationTotal()}}renderPagination(){const e=this.shadowRoot?.querySelector(".table-pagination-container");if(!e)return;if(!this.pagination)return void(e.innerHTML="");const t=this.paginationTotal(),i=this.totalPages,a=Math.min((this.currentPage-1)*this.pageSize+1,t),s=Math.min(this.currentPage*this.pageSize,t),n=[];if(i<=7)for(let e=1;e<=i;e++)n.push(this.pageButton(e));else{n.push(this.pageButton(1)),this.currentPage>3&&n.push('<span class="pagination__ellipsis">…</span>');const e=Math.max(2,this.currentPage-1),t=Math.min(i-1,this.currentPage+1);for(let i=e;i<=t;i++)n.push(this.pageButton(i));this.currentPage<i-2&&n.push('<span class="pagination__ellipsis">…</span>'),n.push(this.pageButton(i))}e.innerHTML="";const l=document.createElement("div");l.className="pagination",l.setAttribute("part","pagination");const r=document.createElement("div");r.className="pagination__info",r.textContent=`Showing ${a}–${s} of ${t}`,l.appendChild(r);const o=document.createElement("div");o.className="pagination__controls",o.innerHTML=`\n <button class="pagination__btn pagination__first" ${this.currentPage<=1?"disabled":""} data-page="1" aria-label="First page">⟨⟨</button>\n <button class="pagination__btn pagination__prev" ${this.currentPage<=1?"disabled":""} data-page="${this.currentPage-1}" aria-label="Previous page">⟨</button>\n ${n.join("")}\n <button class="pagination__btn pagination__next" ${this.currentPage>=i?"disabled":""} data-page="${this.currentPage+1}" aria-label="Next page">⟩</button>\n <button class="pagination__btn pagination__last" ${this.currentPage>=i?"disabled":""} data-page="${i}" aria-label="Last page">⟩⟩</button>\n `,l.appendChild(o);const c=document.createElement("div");c.className="pagination__size";const d=document.createElement("label");d.textContent="Rows per page:",c.appendChild(d);const h=document.createElement("snice-select");h.size="small",h.className="pagination__size-select";const u=this.pageSizes.includes(this.pageSize)?this.pageSizes:[...this.pageSizes,this.pageSize].sort((e,t)=>e-t);for(const e of u){const t=document.createElement("snice-option");t.setAttribute("value",String(e)),t.textContent=String(e),e===this.pageSize&&t.setAttribute("selected",""),h.appendChild(t)}h.value=String(this.pageSize),c.appendChild(h),l.appendChild(c),e.appendChild(l),o.querySelectorAll("[data-page]").forEach(e=>{e.addEventListener("click",()=>{const t=parseInt(e.getAttribute("data-page"));this.goToPage(t)})}),h.addEventListener("select-change",e=>{this.setPageSize(parseInt(e.detail.value))})}pageButton(e){return`<button class="pagination__btn pagination__page${e===this.currentPage?" pagination__btn--active":""}" data-page="${e}">${e}</button>`}createCellElement(e,t,i){if("function"==typeof e.renderCell){const a=e.renderCell(t,i,e);if(a instanceof HTMLElement)return a;const s=document.createElement("span");return s.className="custom-cell",s.textContent=null==a?"":String(a),s}const a=this.getCellTagName(e.type),s=document.createElement(a);switch(s.setAttribute("type",e.type||"text"),e.align&&s.setAttribute("align",e.align),s.setAttribute("in-table","true"),"sparkline"===e.type&&null!==t&&"object"==typeof t?(s.setAttribute("value",JSON.stringify(t)),Array.isArray(t)&&(s.data=t)):s.value=t??"",null!==t&&"object"==typeof t||s.setAttribute("value",String(t??"")),s.column=e,s.rowData=i??null,e.type){case"number":case"currency":if(void 0!==e.decimals&&s.setAttribute("decimals",String(e.decimals)),e.thousandsSeparator&&s.setAttribute("thousands-separator","true"),e.prefix&&s.setAttribute("prefix",e.prefix),e.suffix&&s.setAttribute("suffix",e.suffix),"currency"===e.type){const t=e.currencyFormat;t&&(t.currency&&s.setAttribute("currency",t.currency),t.locale&&s.setAttribute("locale",t.locale),(t.display||t.currencyDisplay)&&s.setAttribute("currencydisplay",t.currencyDisplay||t.display),void 0!==t.decimals&&s.setAttribute("decimals",String(t.decimals)),!1===t.thousandsSeparator&&(s.thousandsSeparator=!1))}break;case"date":e.dateFormat&&s.setAttribute("date-format",e.dateFormat);break;case"boolean":e.useSymbols&&s.setAttribute("use-symbols","true"),e.trueSymbol&&s.setAttribute("true-symbol",e.trueSymbol),e.falseSymbol&&s.setAttribute("false-symbol",e.falseSymbol),e.trueValue&&s.setAttribute("true-value",e.trueValue),e.falseValue&&s.setAttribute("false-value",e.falseValue);break;case"sparkline":{const t=e.sparklineFormat;t&&(t.color&&s.setAttribute("color",t.color),t.type&&s.setAttribute("chart-type",t.type),t.width&&s.setAttribute("width",String(t.width)),t.height&&s.setAttribute("height",String(t.height)));break}case"rating":{const t=e.ratingFormat;t&&(t.max&&s.setAttribute("max",String(t.max)),t.color&&s.setAttribute("color",t.color));break}case"progress":{const t=e.progressFormat;t&&(t.max&&s.setAttribute("max",String(t.max)),t.color&&s.setAttribute("color",t.color),t.showPercentage&&s.setAttribute("show-percentage","true"));break}case"percentage":case"percent":{const t=e.percentageFormat;t&&(void 0!==t.decimals&&s.setAttribute("decimals",String(t.decimals)),t.colorize&&s.setAttribute("colorize","true"));break}case"status":{const t=e.statusFormat;t&&(t.variant&&s.setAttribute("variant",t.variant),t.showDot&&s.setAttribute("show-dot","true"));break}case"link":{const t=e.linkFormat;t&&(t.target&&s.setAttribute("target",t.target),t.external&&s.setAttribute("external","true"));break}case"image":{const t=e.imageFormat;t&&(t.shape&&s.setAttribute("shape",t.shape),t.size&&s.setAttribute("size",t.size));break}case"color":{const t=e.colorFormat;t&&(!1!==t.showSwatch&&s.setAttribute("show-swatch","true"),t.displayFormat&&s.setAttribute("display-format",t.displayFormat));break}case"email":{const t=e.emailFormat;t&&t.showIcon&&s.setAttribute("show-icon","true");break}case"phone":{const t=e.phoneFormat;t&&(t.showIcon&&s.setAttribute("show-icon","true"),t.format&&s.setAttribute("format","true"));break}}return s}getCellTagName(e){switch(e){case"text":return"snice-cell-text";case"number":return"snice-cell-number";case"currency":return"snice-cell-currency";case"date":return"snice-cell-date";case"boolean":return"snice-cell-boolean";case"rating":return"snice-cell-rating";case"progress":return"snice-cell-progress";case"duration":return"snice-cell-duration";case"filesize":return"snice-cell-filesize";case"sparkline":return"snice-cell-sparkline";case"image":return"snice-cell-image";case"percentage":case"percent":return"snice-cell-percentage";case"tag":return"snice-cell-tag";case"status":return"snice-cell-status";case"actions":return"snice-cell-actions";case"link":return"snice-cell-link";case"email":return"snice-cell-email";case"phone":return"snice-cell-phone";case"color":return"snice-cell-color";case"location":return"snice-cell-location";case"json":return"snice-cell-json";default:return"snice-cell"}}updateRowSelectionState(){this.tbody&&this.tbody.querySelectorAll("tr").forEach((e,t)=>{const i=this.selectedRows.includes(t);e.setAttribute("data-selected",String(i));const a=e.querySelector("snice-checkbox.row-select");a&&(a.checked=i)})}updateRowSelectionStateFor(e,t){if(!this.tbody)return;const i=this.tbody.querySelector(`tr[data-index="${e}"]`);if(!i)return;i.setAttribute("data-selected",String(t));const a=i.querySelector("snice-checkbox.row-select");a&&(a.checked=t)}updateSelectAllState(){const e=this.thead?.querySelector("snice-checkbox.select-all");if(!e)return;const t=this.getSelectableIndices(this.getFilteredData()),i=t.filter(e=>this.selectedRows.includes(e)),a=i.length>0&&i.length<t.length;e.checked=i.length===t.length&&t.length>0,e.indeterminate=a}toggleSort(e,t=!1){if(t){const t=this.currentSort.findIndex(t=>t.column===e);this.currentSort=-1===t?[...this.currentSort,{column:e,direction:"asc"}]:"asc"===this.currentSort[t].direction?this.currentSort.map((e,i)=>i===t?{...e,direction:"desc"}:e):this.currentSort.filter(t=>t.column!==e)}else{const t=this.currentSort.find(t=>t.column===e);this.currentSort=t?"asc"===t.direction?[{column:e,direction:"desc"}]:[]:[{column:e,direction:"asc"}]}this.renderHeader(),this.dispatchSortChange(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()}sortLocalData(){this.unsortedData.length||(this.unsortedData=[...this.data]),this.settingSortedData=!0,this.data=0===this.currentSort.length?[...this.unsortedData]:[...this.unsortedData].sort((e,t)=>{for(const{column:i,direction:a}of this.currentSort){const s=this.columns.find(e=>e.key===i),n=s?.sortComparator;if(n){const s=n(e[i],t[i],a);if(0!==s)return s}else{const n=s?.valueGetter?s.valueGetter(e[i],e):e[i]??"",l=s?.valueGetter?s.valueGetter(t[i],t):t[i]??"",r=String(n).localeCompare(String(l),void 0,{numeric:!0});if(0!==r)return"asc"===a?r:-r}}return 0}),this.settingSortedData=!1,this.rebuildRowIndex(),this.scheduleRender("body")}dispatchRowSelectionChanged(e,t){return{selectedRows:this.selectedRows,rowIndex:e,selected:t}}dispatchRowClicked(e,t){return{rowData:e,rowIndex:t}}dispatchLoadError(e){return{error:e}}dispatchSelectAllChanged(e){return{selectedRows:this.selectedRows,allSelected:e}}dispatchSelectionChanged(){return{selectedRows:this.selectedRows,rows:this.getSelectedData()}}dispatchSortChange(){return{sort:this.currentSort}}dispatchFilterChange(){return{filters:this.filterEngine.getFilterModel()}}dispatchColumnVisibilityChange(e,t){return{key:e,visible:t,visibility:this.columnManager.getVisibilityModel()}}dispatchColumnPinChange(e,t){return{key:e,pinned:t}}dispatchColumnOrderChange(e,t){return{key:e,toIndex:t}}dispatchDensityChange(){return{density:this.density}}initializeModules(){this.columnManager.initialize(this.columns,this),this.setupEditor(),this.shadowRoot&&this.keyboard.attach({shadowRoot:this.shadowRoot,totalRows:()=>this.getKeyboardRows().length,ariaRows:()=>this.usesGroupingDisplayModel()?this.getDisplayedGroupingItems().length:this.treeData.isEnabled()?this.getTreeDisplayRows(!0).length:this.getKeyboardRows().length,ariaRowOffset:()=>this.virtualize&&this.virtualizer.isEnabled()?Math.max(0,this.virtualizer.getVisibleRange().start):0,totalColumns:()=>this.getKeyboardColumnCount(),tabMode:"all",isEditing:()=>this.editor.isEditing(),getRowElement:e=>this.getKeyboardRowElement(e),ensureRowVisible:e=>this.ensureKeyboardRowRendered(e),onCellActivate:(e,t)=>{const i=this.getKeyboardDataIndex(e);this.editable&&i>=0&&t&&this.startEdit(i,t)},onSelectionToggle:e=>{const t=this.getKeyboardDataIndex(e);this.selectable&&t>=0&&this.toggleRowSelection(t)},onSelectAll:()=>{this.selectable&&this.selectAllRows()}})}cleanup(){this.virtualizer.detach(),this.keyboard.detach(),this.lazyLoadHandler&&this.lazyLoadContainer?.removeEventListener("scroll",this.lazyLoadHandler),this.lazyLoadHandler=null,this.lazyLoadContainer=null,this.rowDnD.detach(),this.columnDnD.detach()}getScrollContainer(){return this.shadowRoot?.querySelector(".table-frame")??this.shadowRoot?.querySelector(".snice-table")}setupVirtualization(){if(!this.virtualize||!this.shadowRoot||!this.tbody)return;const e=this.getScrollContainer();e&&(this.virtualRowsSnapshot=this.getVirtualRows(),this.virtualizer.attach({rowHeight:e=>this.getVirtualRowHeight(e),bufferPx:this.virtualBuffer,totalRows:this.virtualRowsSnapshot.length,scrollContainer:e,renderRange:(e,t)=>this.renderRowRange(e,t),renderPinnedTop:()=>this.renderPinnedRows(this.pinnedTopRows,"top"),renderPinnedBottom:()=>this.renderPinnedRows(this.pinnedBottomRows,"bottom"),afterRender:()=>this.keyboard.refresh()}))}getVirtualRowHeight(e){const t=this.virtualRowsSnapshot[e];if(!t||t.groupItem&&"row"!==t.groupItem.type)return this.rowHeight;const i=t.groupItem?this.indexOfRow(t.data):t.index;return(this.rowHeightCallback?this.rowHeightCallback(t.data,i):this.rowHeight)+this.masterDetail.getFixedAdditionalHeight(i)}getVirtualRows(){const e=this.getFilteredData();return this.usesGroupingDisplayModel()?this.getDisplayedGroupingItems().map((e,t)=>({data:"row"===e.type?e.data:void 0,index:t,groupItem:e})):this.treeData.isEnabled()?this.getTreeDisplayRows(!0):e.map(e=>({data:e,index:this.indexOfRow(e)}))}renderRowRange(e,t){const i=document.createDocumentFragment(),a=this.virtualRowsSnapshot.length>0?this.virtualRowsSnapshot:this.getVirtualRows(),s=(this.hasSelectionColumn()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),n=(this.columnManager.getAllStates().length>0?this.columnManager.getVisibleColumns().length:this.columns.length)+s,l=this.computeStructuralSig(),r=new Map,o=new Set;for(let s=e;s<t&&s<a.length;s++){const{data:e,index:t,treeRow:c,groupItem:d}=a[s];if(d&&"row"!==d.type){const e="group"===d.type?this.createGroupRow(d,n):this.createAggregateRow(d,n);o.add(e),r.has(d.key)||r.set(d.key,{el:e,sig:"grouprow"}),i.appendChild(e);continue}const h=d?this.indexOfRow(e):t,u=this.isRowEditing(h),m=this.rowSignature(e,h,l,c)+(u?"|edit":""),p=this.renderedRows.get(e);let g;if(!p||o.has(p.el)||u||p.sig!==m?g=this.createRow(e,h,c):(g=p.el,this.restampRowIndex(g,h)),o.add(g),r.has(e)||r.set(e,{el:g,sig:m}),i.appendChild(g),!c&&this.masterDetail.isEnabled()&&this.masterDetail.isExpanded(h)){const t=this.masterDetail.createDetailRow(e,h,n);t&&i.appendChild(t)}}return this.renderedRows=r,i}renderPinnedRows(e,t){const i=document.createDocumentFragment();for(const a of e){const e=this.createRow(a,-1);e.classList.add("pinned-row","top"===t?"pinned-row--top":"pinned-row--bottom"),i.appendChild(e)}return i}scrollToRow(e){if(this.usesGroupingDisplayModel()||this.treeData.isEnabled()){const t=this.data[e],i=this.getVirtualRows().findIndex(e=>e.data===t);return void(i>=0&&this.virtualizer.scrollToIndex(i))}this.virtualizer.scrollToRow(e)}getKeyboardColumnCount(){const e=this.shadowRoot?.querySelectorAll("thead tr.column-header-row > th").length??0;return e>0?e:(this.columnManager.getAllStates().length>0?this.columnManager.getVisibleColumns().length:this.columns.length)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.hasSelectionColumn()?1:0)}getKeyboardRows(){if(this.usesGroupingDisplayModel())return this.getDisplayedGroupingItems().filter(e=>"row"===e.type).map(e=>e.data);if(this.treeData.isEnabled())return this.getTreeDisplayRows(!0).filter(e=>!!e.treeRow).map(e=>e.data);let e=this.getFilteredData();if(this.pagination&&"client"===this.paginationMode){const t=(this.currentPage-1)*this.pageSize;e=e.slice(t,t+this.pageSize)}return e}getKeyboardDataIndex(e){const t=this.getKeyboardRows()[e];return void 0===t?-1:this.indexOfRow(t)}getKeyboardRowElement(e){const t=this.getKeyboardDataIndex(e);return t<0?null:this.tbody?.querySelector(`tr[data-index="${t}"]`)}ensureKeyboardRowRendered(e){if(!this.virtualize||!this.virtualizer.isEnabled())return;if(this.getKeyboardRowElement(e))return;const t=this.getKeyboardRows()[e];if(void 0===t)return;const i=this.getVirtualRows().findIndex(e=>e.data===t);i>=0&&this.virtualizer.scrollToIndex(i)}getScrollPosition(){return this.virtualizer.getScrollPosition()}setColumnFilter(e,t,i){this.filterEngine.setColumnFilter(e,t,i),this.applyClientFilters()}removeColumnFilter(e){this.filterEngine.removeColumnFilter(e),this.applyClientFilters()}setQuickFilter(e){this.filterEngine.setQuickFilter(e),this.applyClientFilters()}setFilterModel(e){this.filterEngine.setFilterModel(e),this.applyClientFilters()}getFilterModel(){return this.filterEngine.getFilterModel()}clearAllFilters(){this.filterEngine.clearAllFilters(),this.applyClientFilters()}getFilteredData(){if(this.ensureRowIndex(),this.filteredCache)return this.filteredCache;const e=this.filterEngine.hasActiveFilters()?this.filterEngine.applyFilters(this.data,this.columns):this.data;return this.filteredCache=e,e}rebuildRowIndex(){this.rowIndexMap.clear();const e=this.data;for(let t=0;t<e.length;t++)this.rowIndexMap.has(e[t])||this.rowIndexMap.set(e[t],t);this.rowIndexDataRef=e,this.filteredCache=null,this.groupingCache=null}ensureRowIndex(){this.rowIndexDataRef!==this.data&&this.rebuildRowIndex()}indexOfRow(e){this.ensureRowIndex();const t=this.rowIndexMap.get(e);return void 0===t?-1:t}invalidateFilteredCache(){this.filteredCache=null,this.groupingCache=null}invalidateGroupingCache(){this.groupingCache=null}getGroupingItems(){return this.grouping.setColumns(this.columns)&&this.invalidateGroupingCache(),this.groupingCache||(this.groupingCache=this.grouping.processData(this.getFilteredData())),this.groupingCache}usesGroupingDisplayModel(){return this.grouping.hasGrouping()||this.grouping.hasAggregation()&&!this.treeData.isEnabled()}getDisplayedGroupingItems(){const e=this.getGroupingItems();if(!this.pagination||"client"!==this.paginationMode)return e;const t=Math.max(1,Math.ceil(e.length/this.pageSize)),i=Math.max(1,Math.min(this.currentPage,t));i!==this.currentPage&&(this.currentPage=i);const a=(i-1)*this.pageSize;return e.slice(a,a+this.pageSize)}getTreeDisplayRows(e){const t=this.treeData.processData(this.getFilteredData()).map(e=>({data:e.data,index:this.indexOfRow(e.data),treeRow:e}));if(this.grouping.hasAggregation()){const e=this.getGroupingItems().find(e=>"aggregate"===e.type&&"table"===e.scope);e&&t.push({data:void 0,index:-1,groupItem:e})}if(!e||!this.pagination||"client"!==this.paginationMode)return t;const i=Math.max(1,Math.ceil(t.length/this.pageSize)),a=Math.max(1,Math.min(this.currentPage,i));a!==this.currentPage&&(this.currentPage=a);const s=(a-1)*this.pageSize;return t.slice(s,s+this.pageSize)}applyClientFilters(){this.invalidateFilteredCache(),this.dispatchFilterChange(),"remote"===this.mode?this.debouncedDataRequest():this.renderBody()}static{this.FILTER_INPUT_DEBOUNCE_MS=150}debouncedApplyClientFilters(){this.filterInputDebounceTimeout&&clearTimeout(this.filterInputDebounceTimeout),this.filterInputDebounceTimeout=setTimeout(()=>{this.filterInputDebounceTimeout=null,this.applyClientFilters()},Xi.FILTER_INPUT_DEBOUNCE_MS)}setColumnVisible(e,t){this.columnManager.setColumnVisible(e,t),this.renderHeader(),this.renderBody(),this.dispatchColumnVisibilityChange(e,t)}showAllColumns(){this.columnManager.showAllColumns(),this.renderHeader(),this.renderBody()}hideAllColumns(){this.columnManager.hideAllColumns(),this.renderHeader(),this.renderBody()}getColumnVisibility(){return this.columnManager.getVisibilityModel()}pinColumn(e,t){this.columnManager.pinColumn(e,t),this.renderHeader(),this.renderBody(),this.dispatchColumnPinChange(e,t)}unpinColumn(e){this.columnManager.unpinColumn(e),this.renderHeader(),this.renderBody(),this.dispatchColumnPinChange(e,!1)}autoSizeColumn(e){this.tbody&&(this.columnManager.autoSizeColumn(e,this.tbody),this.renderHeader())}autoSizeAllColumns(){this.tbody&&(this.columnManager.autoSizeAll(this.tbody),this.renderHeader())}moveColumn(e,t){this.columnManager.moveColumn(e,t),this.renderHeader(),this.renderBody(),this.dispatchColumnOrderChange(e,t)}setupEditor(){if(!this.editable)return;this.editor.attach(this),this.editor.setEditMode(this.editMode);const e=this.columns.filter(e=>!1!==e.editable).map(e=>e.key);this.editor.setEditableColumns(e);for(const e of this.columns)(e.valueGetter||e.valueFormatter||e.valueParser||e.valueSetter)&&this.editor.setPipeline(e.key,{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter,valueParser:e.valueParser,valueSetter:e.valueSetter})}startEdit(e,t){if(!this.editable)return;const i=this.data[e];if(i){if(this.setupEditor(),"row"===this.editMode)this.editor.startRowEdit(e,i);else{const a=this.columns.find(e=>e.key===t);this.editor.startCellEdit(e,t,i[t],i,a?.editorType??a?.type)}this.renderBody(),this.focusActiveEditor()}}focusActiveEditor(){const e=this.tbody?.querySelector(".table-editor-input, .table-editor-checkbox, .table-editor-select");if(e&&(e.focus(),e instanceof HTMLInputElement&&("text"===e.type||"number"===e.type)))try{e.select()}catch{}}async commitEdit(){if("row"===this.editMode){const e=await this.editor.commitRowEdit();return this.renderBody(),e?"Validation errors":null}{const e=await this.editor.commitCellEdit();return this.renderBody(),e}}cancelEdit(){"row"===this.editMode?this.editor.cancelRowEdit():this.editor.cancelCellEdit(),this.renderBody()}exportCSV(e){const t=this.getFilteredData(),i=e?.selectedOnly?this.getSelectedRowsIn(t):t;this.exporter.exportCSV(i,this.columns,e)}printTable(e){this.exporter.print(this,e)}async copyToClipboard(e){const t=this.getFilteredData(),i=this.selectedRows.length>0?this.getSelectedRowsIn(t):t;return this.exporter.copyToClipboard(i,this.columns,e)}getSelectedRowsIn(e){const t=new Set(this.getSelectedData());return e.filter(e=>t.has(e))}hasSelectionColumn(){return this.selectable&&"none"!==this.selectionMode}getSlottedSelectionRows(){return this.shouldModelSlottedRows()?[]:Array.from(this.querySelectorAll('snice-row[slot="rows"]'))}getSelectionSourceRows(){const e=this.getSlottedSelectionRows();return e.length>0?e.map(e=>e.data):this.data}syncSlottedSelectionState(){const e=this.getSlottedSelectionRows();if(0===e.length)return;const t=this.hasSelectionColumn();let i=!1;e.forEach((e,a)=>{const s=!(!t||!this.selectabilityCheck||this.selectabilityCheck(e.data,a));e.index=a,e.selectable=t,e.selectionDisabled=s,!t||s?e.selected=!1:"single"===this.selectionMode&&e.selected&&(i?e.selected=!1:i=!0)}),this.selectedRows=e.map((e,t)=>e.selected&&!e.selectionDisabled?t:-1).filter(e=>e>=0)}getSelectableIndices(e){const t=[];for(const i of e){const e=this.indexOfRow(i);e<0||this.selectabilityCheck&&!this.selectabilityCheck(i,e)||t.push(e)}return t}applyRowSelection(e,t){if("none"===this.selectionMode)return;if(this.selectabilityCheck&&!this.selectabilityCheck(this.data[e],e))return;const i=this.data[e];if("single"===this.selectionMode)return this.selectedRows=[e],this.selectionAnchor=i,this.dispatchRowSelectionChanged(e,!0),void this.dispatchSelectionChanged();if(t.range&&null!=this.selectionAnchor)return this.selectRange(this.selectionAnchor,i),this.dispatchRowSelectionChanged(e,this.selectedRows.includes(e)),void this.dispatchSelectionChanged();const a=this.selectedRows.includes(e);this.selectedRows=a?this.selectedRows.filter(t=>t!==e):[...this.selectedRows,e],this.selectionAnchor=i,this.dispatchRowSelectionChanged(e,!a),this.dispatchSelectionChanged()}selectRange(e,t){const i=this.getFilteredData();let a=i.indexOf(e);const s=i.indexOf(t);if(-1===s)return;-1===a&&(a=s);const n=Math.min(a,s),l=Math.max(a,s),r=[];for(let e=n;e<=l;e++){const t=this.indexOfRow(i[e]);t<0||this.selectabilityCheck&&!this.selectabilityCheck(i[e],t)||r.push(t)}this.selectedRows=r}toggleRowSelection(e){this.applyRowSelection(e,{additive:!0,range:!1})}selectAllRows(){if("multiple"!==this.selectionMode)return;const e=this.getSelectableIndices(this.getFilteredData()),t=e.every(e=>this.selectedRows.includes(e));if(t)this.selectedRows=this.selectedRows.filter(t=>!e.includes(t));else{const t=new Set([...this.selectedRows,...e]);this.selectedRows=Array.from(t)}this.dispatchSelectAllChanged(t),this.dispatchSelectionChanged()}setDetailPanel(e){this.masterDetail.attach(this,e),this.masterDetail.onHeightChange=()=>{this.virtualize&&this.virtualizer.isEnabled()&&(this.virtualRowsSnapshot=this.getVirtualRows(),this.virtualizer.setTotalRows(this.virtualRowsSnapshot.length))},this.masterDetail.prepare(this.data),this.renderHeader(),this.renderBody()}expandRow(e){this.masterDetail.expand(e),this.renderBody()}collapseRow(e){this.masterDetail.collapse(e),this.renderBody()}toggleRowExpansion(e){this.masterDetail.toggle(e),this.renderBody()}expandAllRows(){this.masterDetail.expandAll(this.data.length),this.renderBody()}collapseAllRows(){this.masterDetail.collapseAll(),this.renderBody()}setToolbar(e){this.toolbarOptions=e;const t=this.shadowRoot?.querySelector(".table-controls-container");t&&(this.toolbar.attach(this,t,e),this.toolbar.setFilterEngine(this.filterEngine),this.toolbar.onSearch=e=>this.setQuickFilter(e),this.toolbar.onSortColumn=(e,t)=>{this.currentSort=[{column:e,direction:t}],this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.toolbar.onSetSortModel=e=>{this.currentSort=e,this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.toolbar.onFilterColumn=(e,t,i)=>{this.setColumnFilter(e,t,i)},this.toolbar.onRemoveFilter=e=>{this.removeColumnFilter(e)},this.toolbar.onSetFilterModel=(e,t)=>{this.filterEngine.clearAllFilters(),this.filterEngine.setFilterLogic(t);for(const t of e)this.filterEngine.setColumnFilter(t.column,t.operator,t.value);this.applyClientFilters()},this.toolbar.onClearFilters=()=>{this.clearAllFilters()},this.toolbar.onExportCSV=()=>this.exportCSV(),this.toolbar.onFullscreen=()=>this.toggleFullscreen())}setTreeData(e){this.treeData.attach(e),this.renderBody()}expandTreeNode(e){this.treeData.expand(e),this.renderBody()}collapseTreeNode(e){this.treeData.collapse(e),this.renderBody()}toggleTreeNode(e){this.treeData.toggle(e),this.renderBody()}expandAllTreeNodes(){this.treeData.expandAll(this.data),this.renderBody()}collapseAllTreeNodes(){this.treeData.collapseAll(),this.renderBody()}setColumnGroups(e){this.columnManager.setColumnGroups(e),this.renderHeader()}initColumnMenu(){this.columnMenu&&(this.columnMenuManager.attach(this),this.columnMenuManager.onSortAsc=e=>{this.currentSort=[{column:e,direction:"asc"}],this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.columnMenuManager.onSortDesc=e=>{this.currentSort=[{column:e,direction:"desc"}],this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.columnMenuManager.onFilter=e=>{this.toolbar.openFilterModal(e)},this.columnMenuManager.onHide=e=>this.setColumnVisible(e,!1),this.columnMenuManager.onPinLeft=e=>this.pinColumn(e,"left"),this.columnMenuManager.onPinRight=e=>this.pinColumn(e,"right"),this.columnMenuManager.onUnpin=e=>this.unpinColumn(e),this.columnMenuManager.onAutoSize=e=>this.autoSizeColumn(e))}pinRowTop(e){this.pinnedTopRows.push(e),this.renderBody()}pinRowBottom(e){this.pinnedBottomRows.push(e),this.renderBody()}unpinRow(e){this.pinnedTopRows=this.pinnedTopRows.filter(t=>t!==e),this.pinnedBottomRows=this.pinnedBottomRows.filter(t=>t!==e),this.renderBody()}clearPinnedRows(){this.pinnedTopRows=[],this.pinnedBottomRows=[],this.renderBody()}setRowHeight(e){this.rowHeight=e,this.renderBody()}setRowHeightCallback(e){this.rowHeightCallback=e,this.renderBody()}setSortComparator(e,t){const i=this.columns.find(t=>t.key===e);i&&(i.sortComparator=t)}setSelectabilityCheck(e){this.selectabilityCheck=e;const t=this.getSelectionSourceRows();this.selectedRows=this.selectedRows.filter(i=>{const a=t[i];return!!a&&e(a,i)}),this.syncSlottedSelectionState(),this.scheduleRender("both")}setCellEditableCheck(e){this.editor.setEditabilityCheck(e)}getSelectedData(){const e=this.getSelectionSourceRows();return this.selectedRows.map(t=>e[t]).filter(Boolean)}setupLazyLoading(){if(!this.lazyLoad)return;const e=this.getScrollContainer();e&&(this.lazyLoadHandler&&this.lazyLoadContainer?.removeEventListener("scroll",this.lazyLoadHandler),this.lazyLoadHandler=()=>{const{scrollTop:t,scrollHeight:i,clientHeight:a}=e;i-t-a<this.lazyLoadThreshold&&this.dispatchEvent(new CustomEvent("lazy-load",{detail:{currentCount:this.data.length},bubbles:!0,composed:!0}))},e.addEventListener("scroll",this.lazyLoadHandler,{passive:!0}),this.lazyLoadContainer=e)}scrollToColumn(e){const t=this.shadowRoot?.querySelector(`th[data-key="${e}"]`);t?.scrollIntoView({inline:"nearest",block:"nearest"})}handleListRendererChange(){this.list&&(this.renderedRows=new Map,this.renderBody())}setListViewRenderer(e){this.listRenderer=e}createRow(e,t,i){const a=document.createElement("tr");a.setAttribute("data-index",String(t)),a.setAttribute("part","row"),this.rowHeightCallback?a.style.height=`${this.rowHeightCallback(e,t)}px`:48!==this.rowHeight&&(a.style.height=`${this.rowHeight}px`);const s=this.selectedRows.includes(t);if(a.setAttribute("data-selected",String(s)),this.rowReorder&&this.rowDnD.isEnabled()&&(a.appendChild(this.rowDnD.createDragHandle()),this.rowDnD.makeRowDraggable(a,t)),this.masterDetail.isEnabled()){const e=document.createElement("td");e.className="detail-toggle-cell",e.appendChild(this.masterDetail.createToggleButton(t)),a.appendChild(e)}if(this.hasSelectionColumn()){const i=document.createElement("td");i.className="select-column";const n=!(!this.selectabilityCheck||this.selectabilityCheck(e,t));i.innerHTML=`<snice-checkbox class="row-select" size="small" compact ${s?"checked":""} ${n?"disabled":""} data-row-index="${t}"></snice-checkbox>`,i.querySelector("snice-checkbox").disabled=n,a.appendChild(i)}const n=this.getVisibleColumnDefinitions();if(this.list&&this.listRenderer){const i=document.createElement("td");i.className="list-view-cell",i.colSpan=Math.max(1,n.length);const s=this.listRenderer(e,t);return s instanceof HTMLElement?i.appendChild(s):i.textContent=null==s?"":String(s),a.appendChild(i),a}let l=0;return n.forEach((s,n)=>{if(l>0)return void l--;const r=document.createElement("td");r.setAttribute("data-key",s.key),r.setAttribute("part","cell");const o=e[s.key],c=s.valueGetter?s.valueGetter(o,e):o;this.applyCellPresentation(r,s,c,e);const d=s.colSpan;if(d){const t="function"==typeof d?d(c,e):d;t>1&&(r.colSpan=t,l=t-1)}const h=this.maybeCreateCellEditor(s,e,c,t);if(h)r.classList.add("editing"),r.appendChild(h);else if(i&&s.key===this.treeData.getGroupColumn()){const e=this.treeData.createToggle(i);r.appendChild(e);const t=document.createElement("span");t.textContent=null==c?"":String(c),i.hasChildren&&(t.style.cursor="pointer",t.addEventListener("click",e=>{e.stopPropagation(),this.treeData.toggle(i.key),this.renderBody()})),r.appendChild(t)}else r.appendChild(this.createCellElement(s,c,e));const u=this.columnManager.getState(s.key);if(u)if(r.style.width=`${u.width}px`,"left"===u.pinned){const e=this.columnManager.getPinnedLeftOffsets();r.classList.add("pinned-cell"),r.style.position="sticky",r.style.left=`${e.get(s.key)??0}px`,r.style.zIndex="1"}else if("right"===u.pinned){const e=this.columnManager.getPinnedRightOffsets();r.classList.add("pinned-cell"),r.style.position="sticky",r.style.right=`${e.get(s.key)??0}px`,r.style.zIndex="1"}a.appendChild(r)}),a}applyCellPresentation(e,t,i,a){const s=t=>{t&&(t.backgroundColor&&(e.style.backgroundColor=t.backgroundColor),t.color&&(e.style.color=t.color),t.fontWeight&&(e.style.fontWeight=t.fontWeight),t.fontStyle&&(e.style.fontStyle=t.fontStyle),t.fontSize&&(e.style.fontSize=t.fontSize),t.textDecoration&&(e.style.textDecoration=t.textDecoration))};s(t.style);for(const n of t.conditionalFormats||[])if(n.condition(i,a)){s(n.style),n.className&&e.classList.add(n.className);break}t.tooltip&&(e.title="function"==typeof t.tooltip?t.tooltip(i,a):null==i?"":String(i))}createGroupRow(e,t){const i=document.createElement("tr");i.className="group-header-row",i.setAttribute("data-group-key",e.key),i.setAttribute("data-depth",String(e.depth)),i.setAttribute("aria-label",`${null==e.value||""===e.value?"Blank":String(e.value)} group, ${e.count} rows`);const a=document.createElement("td");if(a.colSpan=t,a.className="group-header-cell",this.selectable&&"multiple"===this.selectionMode){const t=this.groupSelectionState(e),i=document.createElement("span");i.className="group-select-wrap";const s=document.createElement("snice-checkbox");s.className="group-select",s.setAttribute("size","small"),s.setAttribute("compact",""),s.setAttribute("data-group-key",e.key),s.setAttribute("aria-label",`Select all rows in ${null==e.value||""===e.value?"blank":String(e.value)} group`),s.checked="all"===t,s.indeterminate="some"===t,s.disabled=0===this.getSelectableGroupIndices(e).length,i.appendChild(s),a.appendChild(i)}const s=this.grouping.createToggle(e);a.appendChild(s);const n=document.createElement("span");n.className="group-header-label",n.textContent=null==e.value?"":String(e.value),a.appendChild(n);const l=document.createElement("span");return l.className="group-header-count",l.textContent=String(e.count),a.appendChild(l),i.appendChild(a),i}createAggregateRow(e,t){const i=document.createElement("tr");i.className="group-aggregate-row",i.setAttribute("data-agg-scope",e.scope),i.setAttribute("data-depth",String(e.depth)),e.groupKey&&i.setAttribute("data-group-key",e.groupKey);const a=null==e.groupValue||""===e.groupValue?"Blank":String(e.groupValue),s="table"===e.scope?"Total":`${e.groupColumn?`${e.groupColumn}: `:""}${a} subtotal`;if(i.setAttribute("aria-label",s),this.rowReorder&&this.rowDnD.isEnabled()){const e=document.createElement("td");e.className="drag-handle-cell",i.appendChild(e)}if(this.masterDetail.isEnabled()){const e=document.createElement("td");e.className="detail-toggle-cell",i.appendChild(e)}if(this.hasSelectionColumn()){const e=document.createElement("td");e.className="select-column",i.appendChild(e)}const n=this.getVisibleColumnDefinitions(),l=n.find(t=>!Object.prototype.hasOwnProperty.call(e.aggregates,t.key))?null:n[0]?.key;let r=!1;return n.forEach(t=>{const a=document.createElement("td");a.setAttribute("data-key",t.key),a.className="aggregate-cell";const n=Object.prototype.hasOwnProperty.call(e.aggregates,t.key);if(!n&&!r||n&&t.key===l){r=!0;const t=document.createElement("span");t.className="aggregate-label"+(n?" aggregate-label--inline":""),t.textContent=s,"group"===e.scope&&e.depth>0&&(t.style.paddingLeft=1.5*e.depth+"rem"),a.appendChild(t)}if(n){const i=e.aggregates[t.key];a.setAttribute("data-agg-value",String(i));const s=t.renderCell||!t.formatter&&t.valueFormatter?{...t,renderCell:void 0,formatter:t.formatter??t.valueFormatter}:t;a.appendChild(this.createCellElement(s,i))}const o=this.columnManager.getState(t.key);if(o)if(a.style.width=`${o.width}px`,"left"===o.pinned){const e=this.columnManager.getPinnedLeftOffsets();a.classList.add("pinned-cell"),a.style.position="sticky",a.style.left=`${e.get(t.key)??0}px`,a.style.zIndex="1"}else if("right"===o.pinned){const e=this.columnManager.getPinnedRightOffsets();a.classList.add("pinned-cell"),a.style.position="sticky",a.style.right=`${e.get(t.key)??0}px`,a.style.zIndex="1"}i.appendChild(a)}),i}groupSelectionState(e){const t=this.getSelectableGroupIndices(e);if(0===t.length)return"none";const i=t.filter(e=>this.selectedRows.includes(e)).length;return 0===i?"none":i===t.length?"all":"some"}getSelectableGroupIndices(e){const t=[];for(const i of e.rows){const e=this.indexOfRow(i);e<0||this.selectabilityCheck&&!this.selectabilityCheck(i,e)||t.push(e)}return t}toggleGroup(e){this.grouping.toggle(e.key),this.invalidateGroupingCache(),this.dispatchGroupToggle(e.key,e.value,this.grouping.isExpanded(e.key)),this.renderBody()}updateGroupSelectionStates(){if(!this.tbody||!this.grouping.hasGrouping()||!this.selectable)return;const e=this.getGroupingItems().filter(e=>"group"===e.type);if(0===e.length)return;const t=new Map(e.map(e=>[e.key,e]));this.tbody.querySelectorAll("tr.group-header-row").forEach(e=>{const i=e.getAttribute("data-group-key"),a=i?t.get(i):void 0;if(!a)return;const s=e.querySelector("snice-checkbox.group-select");if(!s)return;const n=this.groupSelectionState(a);s.checked="all"===n,s.indeterminate="some"===n})}dispatchGroupToggle(e,t,i){return{key:e,value:t,expanded:i}}maybeCreateCellEditor(e,t,i,a){if(!this.editable)return null;let s,n=!1,l=i;if("row"===this.editMode){const i=this.editor.getRowEditState();i?.isEditing&&i.rowIndex===a&&this.editor.isCellEditable(t,e.key)&&(n=!0,l=i.editedRow[e.key]),s=this.resolveEditorType(e)}else{const t=this.editor.getCellEditState();t?.isEditing&&t.rowIndex===a&&t.columnKey===e.key&&(n=!0,l=t.currentValue),s=t?.editorType??this.resolveEditorType(e)}if(!n)return null;if("function"==typeof e.renderEditor)return e.renderEditor(l,t,e,t=>{"row"===this.editMode?this.editor.updateRowField(e.key,t):this.editor.updateCellValue(t),this.commitEdit()},()=>this.cancelEdit());const r=this.editor.createEditor(s,l,e.selectOptions?{selectOptions:e.selectOptions}:void 0);return this.wireEditorElement(r,e),r}resolveEditorType(e){return e.editorType?e.editorType:this.editor.getEditorType(e.type||"text")}wireEditorElement(e,t){const i=e instanceof HTMLInputElement&&"checkbox"===e.type,a=()=>{const a=i?e.checked:e.value;"row"===this.editMode?this.editor.updateRowField(t.key,a):this.editor.updateCellValue(a)};e.addEventListener("input",a),e.addEventListener("change",a),e.addEventListener("keydown",e=>{"Enter"===e.key?(e.preventDefault(),a(),this.commitEdit()):"Escape"===e.key&&(e.preventDefault(),this.cancelEdit())}),e.addEventListener("blur",()=>{"row"!==this.editMode&&this.editor.isEditing()&&(a(),this.commitEdit())})}constructor(){super(...arguments),this.striped=(k(this,vt),k(this,yt,!1)),this.searchable=(k(this,wt),k(this,kt,!1)),this.filterable=(k(this,xt),k(this,Ct,!1)),this.sortable=(k(this,St),k(this,Et,!1)),this.selectable=(k(this,Dt),k(this,At,!1)),this.hoverable=(k(this,Rt),k(this,Mt,!0)),this.clickable=(k(this,zt),k(this,$t,!1)),this.list=(k(this,Ft),k(this,It,!1)),this.pagination=(k(this,Tt),k(this,Lt,!1)),this.paginationMode=(k(this,Vt),k(this,Bt,"client")),this.pageSize=(k(this,Ot),k(this,jt,10)),this.currentPage=(k(this,Nt),k(this,Pt,1)),this.totalItems=(k(this,Ht),k(this,qt,0)),this.pageSizes=(k(this,_t),k(this,Gt,[10,25,50,100])),this.searchDebounce=(k(this,Kt),k(this,Wt,500)),this.columns=(k(this,Ut),k(this,Zt,[])),this.data=(k(this,Yt),k(this,Jt,[])),this.mode=(k(this,Qt),k(this,Xt,"local")),this.currentSort=(k(this,ei),k(this,ti,[])),this.searchText=(k(this,ii),""),this.selector=k(this,ai,""),this.selectorOptions=(k(this,si),k(this,ni,[])),this.loading=(k(this,li),k(this,ri,!1)),this.loadError=(k(this,oi),null),this.virtualize=k(this,ci,!1),this.rowHeight=(k(this,di),k(this,hi,48)),this.virtualBuffer=(k(this,ui),k(this,mi,200)),this.columnResize=(k(this,pi),k(this,gi,!1)),this.editable=(k(this,bi),k(this,fi,!1)),this.editMode=(k(this,vi),k(this,yi,"cell")),this.density=(k(this,wi),k(this,ki,"standard")),this.headerFilters=(k(this,xi),k(this,Ci,!1)),this.quickFilter=(k(this,Si),k(this,Ei,!1)),this.rowReorder=(k(this,Di),k(this,Ai,!1)),this.columnReorder=(k(this,Ri),k(this,Mi,!1)),this.columnMenu=(k(this,zi),k(this,$i,!1)),this.lazyLoad=(k(this,Fi),k(this,Ii,!1)),this.lazyLoadThreshold=(k(this,Ti),k(this,Li,200)),this.selectedRows=(k(this,Vi),k(this,Bi,[])),this.selectionMode=(k(this,Oi),k(this,ji,"multiple")),this.selectionAnchor=(k(this,Ni),null),this.groupBy=k(this,Pi,""),this.groupDefaults=(k(this,Hi),k(this,qi,{})),this.groupingCache=(k(this,_i),null),this.virtualizer=new oe,this.columnManager=new ce,this.filterEngine=new pe,this.editor=new ge,this.keyboard=new be,this.exporter=new fe,this.masterDetail=new ve,this.toolbar=new ye,this.treeData=new ke,this.grouping=new Ce,this.columnMenuManager=new Se,this.rowDnD=new Ee,this.columnDnD=new De,this.pinnedTopRows=[],this.pinnedBottomRows=[],this.toolbarOptions=null,this.lazyLoadHandler=null,this.lazyLoadContainer=null,this.rowHeightCallback=null,this.virtualRowsSnapshot=[],this.table=k(this,Gi,void 0),this.thead=(k(this,Ki),k(this,Wi,void 0)),this.tbody=(k(this,Ui),k(this,Zi,void 0)),this.unsortedData=(k(this,Yi),[]),this.dataRequestTimeout=null,this.rowIndexMap=new Map,this.rowIndexDataRef=null,this.filteredCache=null,this.dataRequestSeq=0,this.renderedRows=new Map,this.settingSortedData=!1,this.settingDataImperative=!1,this.renderQueued=!1,this.pendingHeaderRender=!1,this.pendingBodyRender=!1,this.rendererIds=new WeakMap,this.rendererIdSeq=0,this.fsExitHandler=null,this.toggleFullscreen=async()=>{if(this.classList.contains("table-fullscreen")){if(this.classList.remove("table-fullscreen"),document.fullscreenElement===this)try{await document.exitFullscreen()}catch{}this.fsExitHandler&&(document.removeEventListener("fullscreenchange",this.fsExitHandler),this.fsExitHandler=null)}else{this.classList.add("table-fullscreen");try{"function"==typeof this.requestFullscreen&&await this.requestFullscreen()}catch{}this.fsExitHandler=()=>{document.fullscreenElement!==this&&(this.classList.remove("table-fullscreen"),this.fsExitHandler&&(document.removeEventListener("fullscreenchange",this.fsExitHandler),this.fsExitHandler=null))},document.addEventListener("fullscreenchange",this.fsExitHandler)}},this.handleKeydown=e=>{if("Enter"!==e.key&&" "!==e.key)return;const t=e.target.closest("th.sortable");if(!t)return;const i=t.getAttribute("data-key");i&&(e.preventDefault(),this.toggleSort(i,!0))},this.handleClick=e=>{const t=e.target,i=t.closest("th.sortable");if(i){const e=i.getAttribute("data-key");return void(e&&this.toggleSort(e,!0))}const a=t.closest("tbody tr");if(a){if(a.classList.contains("group-header-row")){if(t.closest("snice-checkbox.group-select"))return;const e=a.getAttribute("data-group-key"),i=e?this.getGroupingItems().find(t=>"group"===t.type&&t.key===e):void 0;return void(i&&this.toggleGroup(i))}if(!a.hasAttribute("data-index"))return;if(t.matches('input[type="checkbox"], button, a, .interactive, snice-checkbox, snice-button, snice-input, snice-select'))return;const i=parseInt(a.getAttribute("data-index")||"0"),s=this.data[i];this.selectable&&this.applyRowSelection(i,{additive:e.ctrlKey||e.metaKey,range:e.shiftKey}),this.clickable&&this.dispatchRowClicked(s,i)}},this.handleChange=e=>{const t=e.target;if(t.matches("snice-checkbox.row-select")){const e=t,i=parseInt(e.getAttribute("data-row-index")||"0");if("none"===this.selectionMode)return;return this.selectabilityCheck&&!this.selectabilityCheck(this.data[i],i)?void(e.checked=this.selectedRows.includes(i)):("single"===this.selectionMode?this.selectedRows=e.checked?[i]:[]:e.checked?this.selectedRows.includes(i)||(this.selectedRows=[...this.selectedRows,i]):this.selectedRows=this.selectedRows.filter(e=>e!==i),this.selectionAnchor=this.data[i],this.dispatchRowSelectionChanged(i,e.checked),void this.dispatchSelectionChanged())}if(t.matches("snice-checkbox.group-select")){const e=t;if("multiple"!==this.selectionMode)return;const i=e.getAttribute("data-group-key"),a=this.getGroupingItems().find(e=>"group"===e.type&&e.key===i);if(!a)return;const s=this.getSelectableGroupIndices(a);if(e.checked)this.selectedRows=Array.from(new Set([...this.selectedRows,...s]));else{const e=new Set(s);this.selectedRows=this.selectedRows.filter(t=>!e.has(t))}return void this.dispatchSelectionChanged()}if(t.matches("snice-checkbox.select-all")){const e=t;if("multiple"!==this.selectionMode)return;this.selectedRows=e.checked?this.getSelectableIndices(this.getFilteredData()):[],this.dispatchSelectAllChanged(e.checked),this.dispatchSelectionChanged()}},this.onAttached=()=>{"remote"===this.mode&&(this.getTableConfig(),this.getTableData())},this.searchDebounceTimeout=null,this.handleSearchInput=e=>{this.searchText=e.target.value,this.searchDebounceTimeout&&clearTimeout(this.searchDebounceTimeout),this.searchDebounceTimeout=setTimeout(()=>{"remote"===this.mode?this.getTableData():this.setQuickFilter(this.searchText)},this.searchDebounce)},this.handleQuickFilterInput=e=>{const t=e.target;this.filterInputDebounceTimeout&&clearTimeout(this.filterInputDebounceTimeout),this.filterInputDebounceTimeout=setTimeout(()=>{this.filterInputDebounceTimeout=null,this.setQuickFilter(t.value||"")},Xi.FILTER_INPUT_DEBOUNCE_MS)},this.selectorDebounceTimeout=null,this.handleSelectorChange=e=>{this.selector=Array.isArray(e.detail.value)?e.detail.value.join(","):e.detail.value,this.selectorDebounceTimeout&&clearTimeout(this.selectorDebounceTimeout),this.selectorDebounceTimeout=setTimeout(()=>{this.debouncedDataRequest()},150)},this.filterInputDebounceTimeout=null,this.handleSlottedRowSelect=e=>{const t=e.detail?.element,i=this.getSlottedSelectionRows(),a=i.indexOf(t);if(!(a<0))return!this.hasSelectionColumn()||this.selectabilityCheck&&!this.selectabilityCheck(t.data,a)?(t.selected=!1,void this.syncSlottedSelectionState()):("single"===this.selectionMode&&t.selected&&i.forEach((e,t)=>{t!==a&&(e.selected=!1)}),this.selectedRows=i.map((e,t)=>e.selected?t:-1).filter(e=>e>=0),this.selectionAnchor=t.data,this.dispatchRowSelectionChanged(a,t.selected),void this.dispatchSelectionChanged())},this.selectabilityCheck=null,this.listRenderer=k(this,Ji,null),k(this,Qi)}static{k(a,bt)}};Xi=a})(),(()=>{let a,n,c,u,p,g,b,f,v,y,x,E,D,A,R,M,z,$=[i("snice-header")],F=[],I=HTMLElement,T=[],L=[],V=[],B=[],O=[],j=[],N=[],P=[],H=[],q=[],_=[],G=[],K=[],W=[],U=[];(class extends I{static{n=this}static{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(I[Symbol.metadata]??null):void 0;c=[s({type:Boolean})],u=[s({type:Array,attribute:!1})],p=[s({type:Boolean})],g=[s({type:Boolean})],b=[s({type:Object,attribute:!1})],f=[s({type:Boolean,attribute:"all-selected"})],v=[s({type:Boolean,attribute:"some-selected"})],y=[l()],x=[r()],E=[o()],D=[d("sticky","selectable","sortable")],A=[d("allSelected","someSelected")],R=[h("header-sort",{bubbles:!0,composed:!0})],M=[h("header-select-all",{bubbles:!0,composed:!0})],z=[h("header-filter",{bubbles:!0,composed:!0})],w(this,null,y,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:e},null,T),w(this,null,x,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:e},null,T),w(this,null,E,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:e},null,T),w(this,null,D,{kind:"method",name:"updateHeaderAttributes",static:!1,private:!1,access:{has:e=>"updateHeaderAttributes"in e,get:e=>e.updateHeaderAttributes},metadata:e},null,T),w(this,null,A,{kind:"method",name:"updateSelectAllCheckbox",static:!1,private:!1,access:{has:e=>"updateSelectAllCheckbox"in e,get:e=>e.updateSelectAllCheckbox},metadata:e},null,T),w(this,null,R,{kind:"method",name:"dispatchSort",static:!1,private:!1,access:{has:e=>"dispatchSort"in e,get:e=>e.dispatchSort},metadata:e},null,T),w(this,null,M,{kind:"method",name:"dispatchSelectAll",static:!1,private:!1,access:{has:e=>"dispatchSelectAll"in e,get:e=>e.dispatchSelectAll},metadata:e},null,T),w(this,null,z,{kind:"method",name:"dispatchFilter",static:!1,private:!1,access:{has:e=>"dispatchFilter"in e,get:e=>e.dispatchFilter},metadata:e},null,T),w(null,null,c,{kind:"field",name:"sticky",static:!1,private:!1,access:{has:e=>"sticky"in e,get:e=>e.sticky,set:(e,t)=>{e.sticky=t}},metadata:e},L,V),w(null,null,u,{kind:"field",name:"columns",static:!1,private:!1,access:{has:e=>"columns"in e,get:e=>e.columns,set:(e,t)=>{e.columns=t}},metadata:e},B,O),w(null,null,p,{kind:"field",name:"selectable",static:!1,private:!1,access:{has:e=>"selectable"in e,get:e=>e.selectable,set:(e,t)=>{e.selectable=t}},metadata:e},j,N),w(null,null,g,{kind:"field",name:"sortable",static:!1,private:!1,access:{has:e=>"sortable"in e,get:e=>e.sortable,set:(e,t)=>{e.sortable=t}},metadata:e},P,H),w(null,null,b,{kind:"field",name:"currentSort",static:!1,private:!1,access:{has:e=>"currentSort"in e,get:e=>e.currentSort,set:(e,t)=>{e.currentSort=t}},metadata:e},q,_),w(null,null,f,{kind:"field",name:"allSelected",static:!1,private:!1,access:{has:e=>"allSelected"in e,get:e=>e.allSelected,set:(e,t)=>{e.allSelected=t}},metadata:e},G,K),w(null,null,v,{kind:"field",name:"someSelected",static:!1,private:!1,access:{has:e=>"someSelected"in e,get:e=>e.someSelected,set:(e,t)=>{e.someSelected=t}},metadata:e},W,U),w(null,a={value:n},$,{kind:"class",name:n.name,metadata:e},null,F),n=a.value,e&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e}),k(n,F)}render(){return e`
1667
+ `}renderControls(){const e=this.shadowRoot?.querySelector(".table-controls-container");if(!e)return;if(this.toolbarOptions)return void this.setToolbar(this.toolbarOptions);if(!(this.searchable||this.filterable||this.quickFilter))return void(e.innerHTML="");e.innerHTML="";const t=document.createElement("div");if(t.className="table-controls",t.setAttribute("part","controls"),this.quickFilter){const e=document.createElement("snice-input");e.className="quick-filter-input",e.type="search",e.placeholder="Quick filter...",e.size="small",e.clearable=!0,e.style.width="16rem",e.style.maxWidth="16rem",e.value=this.filterEngine.getFilterModel().quickFilter||"",e.addEventListener("input",this.handleQuickFilterInput),t.appendChild(e)}else if(this.searchable){const e=document.createElement("snice-input");e.className="search-input",e.setAttribute("type","search"),e.setAttribute("placeholder","Search..."),e.setAttribute("size","small"),e.style.width="16rem",e.style.maxWidth="16rem",e.style.flex="0 0 auto",e.addEventListener("input",this.handleSearchInput),t.appendChild(e)}if(this.filterable){const e=document.createElement("snice-select");e.className="selector-input",e.setAttribute("multiple",""),e.setAttribute("searchable",""),e.setAttribute("clearable",""),e.setAttribute("placeholder","Filter..."),e.setAttribute("size","medium"),this.selectorOptions.forEach(t=>{const i=document.createElement("snice-option");i.setAttribute("value",t.value),i.textContent=t.label,e.appendChild(i)}),t.appendChild(e)}e.appendChild(t)}handleFrameResize(){this.updateFillRow()}async initialize(){this.addEventListener("controller-attached",this.onAttached),this.addEventListener("select-change",this.handleSelectorChange),this.addEventListener("row-select",this.handleSlottedRowSelect),this.addEventListener("detail-toggle",()=>this.renderBody()),this.addEventListener("cell-edit-commit",e=>{const{rowIndex:t,columnKey:i,newValue:a}=e.detail,s=this.data[t];s&&(s[i]=a),this.invalidateFilteredCache(),s&&this.invalidateRenderedRow(s)}),this.addEventListener("row-edit-commit",e=>{const{rowIndex:t,newRow:i}=e.detail;this.data[t]&&(this.data[t]=i),this.rebuildRowIndex()}),await customElements.whenDefined("snice-column"),await customElements.whenDefined("snice-row"),await this.processSlottedContent(),await this.rendered,this.syncGrouping(),this.renderControls(),this.initializeModules(),this.initColumnMenu(),this.rowReorder&&this.rowDnD.attach(this),this.columnReorder&&this.columnDnD.attach(this),this.renderHeader(),this.renderBody(),this.virtualize&&requestAnimationFrame(()=>{this.virtualizer.isEnabled()||this.setupVirtualization()}),this.lazyLoad&&requestAnimationFrame(()=>this.setupLazyLoading()),this.addEventListener("row-reorder",e=>{const{fromIndex:t,toIndex:i}=e.detail;if(!Number.isInteger(t)||!Number.isInteger(i)||t<0||i<0||t>=this.data.length||i>=this.data.length)return;if(t===i)return;const a=this.selectedRows.map(e=>this.data[e]).filter(e=>void 0!==e),s=Array.from(this.masterDetail.getExpandedRows()).map(e=>this.data[e]).filter(e=>void 0!==e),n=this.data.splice(t,1)[0],l=this.data[i>t?i-1:i];if(n&&l&&this.grouping.hasGrouping())for(const e of this.grouping.getGroupByKeys())n[e]=l[e];this.data.splice(i,0,n),this.data=[...this.data],this.selectedRows=a.map(e=>this.indexOfRow(e)).filter(e=>e>=0),this.masterDetail.setExpandedRows(s.map(e=>this.indexOfRow(e)).filter(e=>e>=0))}),this.addEventListener("column-reorder",e=>{const{fromKey:t,toKey:i}=e.detail,a=this.columns.findIndex(e=>e.key===t),s=this.columnManager.getVisibleColumns().findIndex(e=>e.key===i);a>=0&&s>=0&&(this.columnManager.moveColumn(t,s),this.renderHeader(),this.renderBody())}),this.addEventListener("tree-toggle",()=>this.renderBody())}async processSlottedContent(){const e=Array.from(this.querySelectorAll('snice-column[slot="columns"]')),t=Array.from(this.querySelectorAll('snice-row[slot="rows"]'));await Promise.all(t.map(e=>e.ready)),e.length>0&&(this.columns=e.map(e=>e.getColumnDefinition())),t.forEach((e,t)=>{e.columns=this.columns,e.index=t,e.hoverable=this.hoverable,e.clickable=this.clickable}),this.syncSlottedSelectionState(),this.shouldModelSlottedRows()&&this.syncSlottedRowsIntoData(),e.length>0&&!this.shouldModelSlottedRows()&&requestAnimationFrame(()=>this.renderSlottedHeader())}shouldModelSlottedRows(){return(Array.isArray(this.groupBy)?this.groupBy:this.groupBy?[this.groupBy]:[]).some(Boolean)||this.columns.some(e=>null!=e.aggregate)}syncSlottedRowsIntoData(){const e=Array.from(this.querySelectorAll('snice-row[slot="rows"]'));if(0===e.length)return;const t=e.map(e=>{if(e.data&&Object.keys(e.data).length>0)return e.data;const t=e.getAttribute("data");if(t)try{return JSON.parse(t)}catch{}return e.data??{}});this.data=t}renderSlottedHeader(){const e=this.shadowRoot?.querySelector("#slotted-header");if(e&&0!==this.columns.length){e.replaceChildren();for(const t of this.columns){const i=document.createElement("div");i.className="header-cell",i.textContent=t.label??t.key,e.appendChild(i)}}}handleDeclarativeColumnChange(){const e=Array.from(this.querySelectorAll('snice-column[slot="columns"]'));0!==e.length&&(this.columns=e.map(e=>e.getColumnDefinition()),Array.from(this.querySelectorAll('snice-row[slot="rows"]')).forEach(e=>{e.columns=this.columns}),requestAnimationFrame(()=>{this.shouldModelSlottedRows()||this.renderSlottedHeader(),this.renderControls()}))}handleSelectorOptionsChange(){0===this.selectorOptions.length?this.classList.add("selector-options-empty"):this.classList.remove("selector-options-empty")}handleSortableChange(){this.renderHeader()}handleSelectableChange(){this.render(),queueMicrotask(()=>this.syncSlottedSelectionState())}handleColumnsAssignment(){this.renderedRows=new Map,this.columns.length>0&&this.columnManager.initialize(this.columns,this),this.grouping.setColumns(this.columns),this.invalidateGroupingCache();const e=!!this.querySelector('snice-row[slot="rows"]'),t=this.shouldModelSlottedRows();e&&this.virtualizer.isEnabled()&&!!this.shadowRoot?.querySelector("table")!==t&&this.virtualizer.detach(),t&&this.syncSlottedRowsIntoData(),e&&requestAnimationFrame(()=>{t||this.renderSlottedHeader(),this.renderControls(),this.toolbarOptions&&this.setToolbar(this.toolbarOptions),this.lazyLoad&&this.setupLazyLoading()}),this.scheduleRender("both")}handleGroupByChange(){this.syncGrouping();const e=!!this.querySelector('snice-row[slot="rows"]'),t=this.shouldModelSlottedRows();e&&this.virtualizer.isEnabled()&&!!this.shadowRoot?.querySelector("table")!==t&&this.virtualizer.detach(),t&&this.syncSlottedRowsIntoData(),e&&requestAnimationFrame(()=>{t||this.renderSlottedHeader(),this.renderControls(),this.toolbarOptions&&this.setToolbar(this.toolbarOptions),this.lazyLoad&&this.setupLazyLoading()}),this.scheduleRender(e?"both":"body")}syncGrouping(){const e=Array.isArray(this.groupBy)?this.groupBy.filter(Boolean):this.groupBy?[this.groupBy]:[];this.grouping.configure({groupBy:e,defaultExpanded:!1!==this.groupDefaults?.expanded}),this.grouping.setColumns(this.columns),this.invalidateGroupingCache()}handleDataAssignment(){this.settingSortedData||(this.unsortedData=[...this.data],"remote"!==this.mode&&this.currentSort.length>0&&this.applyLocalSortOrder(),this.rebuildRowIndex(),this.masterDetail.prepare(this.data,e=>this.rowValueSignature(e)),this.settingDataImperative||this.scheduleRender("body"))}handleDataChange(){this.renderBody(),this.updateLoadingOverlay()}updateLoadingOverlay(){const e=this.shadowRoot?.querySelector(".table-frame");if(!e)return;let t=e.querySelector(".table-loading-overlay");const i=this.loading&&this.data.length>0;if(i&&!t){t=document.createElement("div"),t.className="table-loading-overlay",t.setAttribute("part","loading-overlay");const i=document.createElement("snice-progress");i.setAttribute("variant","circular"),i.setAttribute("indeterminate",""),i.setAttribute("size","small"),t.appendChild(i),e.appendChild(t)}else!i&&t&&t.remove()}handleSelectedRowsChange(e,t){const i=new Set(e??[]),a=new Set(t??this.selectedRows??[]),s=new Set;for(const e of i)a.has(e)||s.add(e);for(const e of a)i.has(e)||s.add(e);for(const e of s)this.updateRowSelectionStateFor(e,a.has(e));this.updateSelectAllState(),this.updateGroupSelectionStates()}handleSelectionModeChange(){"none"===this.selectionMode?(this.selectedRows=[],this.selectionAnchor=null):"single"===this.selectionMode&&this.selectedRows.length>1&&(this.selectedRows=this.selectedRows.slice(0,1),this.selectionAnchor=this.data[this.selectedRows[0]]??null),this.syncSlottedSelectionState(),this.scheduleRender("both")}handleSortChange(){this.renderHeader()}handleControlsChange(){this.renderControls(),this.quickFilter&&this.scheduleRender("body")}handleControlledSort(){"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()}handleCurrentPageChange(){"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.scheduleRender("body")}handlePageSizeChange(){this.currentPage=1,"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.scheduleRender("body")}handleDensityChange(){this.scheduleRender("body"),this.dispatchDensityChange()}handleListChange(){this.renderedRows=new Map,this.scheduleRender("body")}handleEditableChange(){this.editable&&this.setupEditor(),this.scheduleRender("body")}handleEditModeChange(){this.editable&&this.editor.setEditMode(this.editMode),this.scheduleRender("body")}handleVirtualizeChange(){this.virtualize||this.virtualizer.detach(),this.scheduleRender("body")}handleRowHeightChange(){this.scheduleRender("body")}handleColumnResizeChange(){this.scheduleRender("header")}handleHeaderFiltersChange(){this.scheduleRender("header")}handleRowReorderChange(){this.rowReorder?this.rowDnD.attach(this):this.rowDnD.detach(),this.scheduleRender("both")}handleColumnReorderChange(){this.columnReorder?this.columnDnD.attach(this):this.columnDnD.detach(),this.scheduleRender("header")}handleLazyLoadChange(){this.lazyLoad?queueMicrotask(()=>this.setupLazyLoading()):(this.lazyLoadHandler&&this.lazyLoadContainer?.removeEventListener("scroll",this.lazyLoadHandler),this.lazyLoadHandler=null,this.lazyLoadContainer=null)}handleColumnMenuChange(){this.columnMenu&&this.initColumnMenu(),this.scheduleRender("header")}getVisibleColumnDefinitions(){if(0===this.columnManager.getAllStates().length)return this.columns;const e=[...this.columnManager.getPinnedLeft(),...this.columnManager.getUnpinned(),...this.columnManager.getPinnedRight()],t=new Map(this.columns.map(e=>[e.key,e]));return e.map(e=>t.get(e.key)).filter(e=>!!e)}renderHeader(){if(!this.thead)return;const e=document.createElement("tr");if(e.className="column-header-row",this.rowReorder&&this.rowDnD.isEnabled()){const t=document.createElement("th");t.setAttribute("scope","col"),t.className="drag-handle-cell",e.appendChild(t)}if(this.masterDetail.isEnabled()){const t=document.createElement("th");t.setAttribute("scope","col"),t.className="detail-toggle-cell",e.appendChild(t)}if(this.hasSelectionColumn()){const t=document.createElement("th");if(t.setAttribute("scope","col"),t.className="select-column","multiple"===this.selectionMode){const e=this.getSelectableIndices(this.getFilteredData()),i=e.filter(e=>this.selectedRows.includes(e)),a=i.length>0&&i.length<e.length;t.innerHTML=`<snice-checkbox class="select-all" size="small" compact ${i.length===e.length&&e.length>0?"checked":""}></snice-checkbox>`,setTimeout(()=>{const e=t.querySelector(".select-all");e&&(e.indeterminate=a)},0)}else t.setAttribute("aria-label","Select one row");e.appendChild(t)}const t=this.getVisibleColumnDefinitions();if(t.forEach(t=>{const i=document.createElement("th");if(i.setAttribute("data-key",t.key),i.setAttribute("scope","col"),this.sortable&&!1!==t.sortable){const e=this.currentSort.find(e=>e.column===t.key);i.setAttribute("aria-sort","asc"===e?.direction?"ascending":"desc"===e?.direction?"descending":"none")}const a=this.columnManager.getState(t.key);if(a)if(i.style.width=`${a.width}px`,"left"===a.pinned){const e=this.columnManager.getPinnedLeftOffsets();i.classList.add("pinned-cell"),i.style.position="sticky",i.style.left=`${e.get(t.key)??0}px`,i.style.zIndex="2"}else if("right"===a.pinned){const e=this.columnManager.getPinnedRightOffsets();i.classList.add("pinned-cell"),i.style.position="sticky",i.style.right=`${e.get(t.key)??0}px`,i.style.zIndex="2"}if(this.sortable&&!1!==t.sortable?(i.classList.add("sortable"),i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i.setAttribute("aria-label",`Sort by ${t.label}`),i.innerHTML=this.renderSortableHeader(t)):i.textContent=t.label,this.filterEngine.hasColumnFilter(t.key)&&i.classList.add("filtered"),this.columnResize&&!1!==t.resizable){const e=document.createElement("span");e.className="resize-handle",e.addEventListener("mousedown",e=>{e.stopPropagation(),this.columnManager.startResize(t.key,e.clientX)}),e.addEventListener("dblclick",e=>{e.stopPropagation(),this.tbody&&(this.columnManager.autoSizeColumn(t.key,this.tbody),this.renderHeader(),this.renderBody())}),i.appendChild(e)}this.columnMenu&&i.addEventListener("contextmenu",e=>{e.preventDefault();const i=this.columnManager.getState(t.key);this.columnMenuManager.show(t.key,e.clientX,e.clientY,{sortable:this.sortable&&!1!==t.sortable,filterable:!1!==t.filterable,hideable:i?.hideable,pinnable:i?.pinnable,pinned:i?.pinned})}),this.columnReorder&&this.columnDnD.isEnabled()&&this.columnDnD.makeHeaderDraggable(i,t.key,!1!==t.reorderable&&!a?.pinned),e.appendChild(i)}),this.thead.innerHTML="",this.columnManager.getColumnGroups().length>0){const e=document.createElement("tr");e.className="column-group-row";const i=[this.rowReorder&&this.rowDnD.isEnabled()?"drag-handle-cell":"",this.masterDetail.isEnabled()?"detail-toggle-cell":"",this.hasSelectionColumn()?"select-column":""].filter(Boolean);for(const t of i){const i=document.createElement("th");i.className=t,i.setAttribute("aria-hidden","true"),e.appendChild(i)}const a=document.createElement("template");a.innerHTML=this.columnManager.renderGroupHeaders(t.map(e=>e.key)),e.appendChild(a.content),this.thead.appendChild(e)}if(this.thead.appendChild(e),this.headerFilters){const e=document.createElement("tr");if(e.className="header-filter-row",this.rowReorder&&this.rowDnD.isEnabled()){const t=document.createElement("td");t.className="drag-handle-cell",e.appendChild(t)}if(this.masterDetail.isEnabled()){const t=document.createElement("td");t.className="detail-toggle-cell",e.appendChild(t)}if(this.hasSelectionColumn()){const t=document.createElement("td");t.className="select-column",e.appendChild(t)}t.forEach(t=>{const i=document.createElement("td"),a=document.createElement("snice-input");a.size="small",a.placeholder=`Filter ${t.label}...`,a.setAttribute("data-column",t.key),a.value=this.filterEngine.getHeaderFilter(t.key),a.style.cssText="width:100%;--snice-color-border:transparent;--snice-border-radius-md:0;",a.addEventListener("input",()=>{this.filterEngine.setHeaderFilter(t.key,a.value),this.debouncedApplyClientFilters()}),i.appendChild(a),e.appendChild(i)}),this.thead.appendChild(e)}}renderSortableHeader(e){const t=this.currentSort.find(t=>t.column===e.key),i=this.currentSort.findIndex(t=>t.column===e.key),a='<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 5l4-4 4 4"/></svg>',s='<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 1l4 4 4-4"/></svg>';let n=`<span style="display:flex;flex-direction:column;gap:0;opacity:0.3">${a}${s}</span>`,l="";t&&("asc"===t.direction?n=a:"desc"===t.direction&&(n=s),this.currentSort.length>1&&(l=`<span class="sort-order">${i+1}</span>`));const r=["sort-indicator",t?"active":""].filter(Boolean).join(" ");return`\n <div class="sort-header">\n <span>${e.label}</span>\n <div class="${r}">\n ${n}\n ${l}\n </div>\n </div>\n `}renderBody(){if(!this.tbody)return;if(this.columns.length>0&&this.columnManager.initialize(this.columns,this),this.grouping.setColumns(this.columns)&&this.invalidateGroupingCache(),this.pagination&&"client"===this.paginationMode&&(this.usesGroupingDisplayModel()?this.totalItems=this.getGroupingItems().length:this.treeData.isEnabled()&&(this.totalItems=this.getTreeDisplayRows(!1).length)),this.virtualize&&!this.virtualizer.isEnabled()&&this.setupVirtualization(),this.virtualize&&this.virtualizer.isEnabled())return this.virtualRowsSnapshot=this.getVirtualRows(),this.virtualizer.setTotalRows(this.virtualRowsSnapshot.length),this.pagination&&this.renderPagination(),void this.updateSelectAllState();if(0===this.data.length&&this.columns.length>0){this.tbody.innerHTML="",this.renderedRows=new Map;const e=(this.hasSelectionColumn()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),t=this.columns.length+e;if(this.loading){const e=document.createElement("tr"),i=document.createElement("td");return i.colSpan=t,i.className="no-data",i.innerHTML='<snice-progress variant="circular" indeterminate size="small"></snice-progress>',e.appendChild(i),void this.tbody.appendChild(e)}if(this.loadError){const e=document.createElement("tr"),i=document.createElement("td");i.colSpan=t,i.className="no-data";const a=document.createElement("div");return a.className="table-error-message",a.textContent=`⚠️ ${this.loadError}`,i.appendChild(a),e.appendChild(i),void this.tbody.appendChild(e)}{const e=document.createElement("tr"),i=document.createElement("td");i.colSpan=t,i.className="no-data";const a=this.querySelector('[slot="empty-state"]');if(a)i.appendChild(a.cloneNode(!0));else{const e=document.createElement("snice-empty-state");e.setAttribute("size","small"),e.setAttribute("icon","📭"),e.setAttribute("title","No data"),e.setAttribute("description","No records to display."),i.appendChild(e)}return e.appendChild(i),void this.tbody.appendChild(e)}}const e=this.getFilteredData();let t=e;if(this.pagination&&"client"===this.paginationMode&&!this.usesGroupingDisplayModel()&&!this.treeData.isEnabled()){this.totalItems=e.length;const i=(this.currentPage-1)*this.pageSize;t=e.slice(i,i+this.pageSize)}const i=(this.hasSelectionColumn()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),a=(this.columnManager.getAllStates().length>0?this.columnManager.getVisibleColumns().length:this.columns.length)+i,s=this.computeStructuralSig(),n=[];if(this.pinnedTopRows.forEach((e,t)=>{n.push({key:`__pinned_top_${t}`,sig:"pinned",alwaysRebuild:!0,create:()=>{const t=this.createRow(e,-1);return t.classList.add("pinned-row","pinned-row--top"),t}})}),this.usesGroupingDisplayModel()){const e=this.getDisplayedGroupingItems();for(const t of e)if("group"===t.type)n.push({key:t.key,sig:`${s}|grp:${t.key}:${t.expanded?1:0}:${t.count}`,alwaysRebuild:!0,create:()=>this.createGroupRow(t,a)});else if("aggregate"===t.type)n.push({key:t.key,sig:`${s}|agg:${t.key}`,alwaysRebuild:!0,create:()=>this.createAggregateRow(t,a)});else{const e=this.indexOfRow(t.data),i=this.isRowEditing(e);n.push({key:t.data,sig:this.rowSignature(t.data,e,s)+(i?"|edit":""),alwaysRebuild:i,restampIndex:e,create:()=>this.createRow(t.data,e)}),this.masterDetail.isEnabled()&&this.masterDetail.isExpanded(e)&&n.push({key:`__detail_${e}`,sig:"detail",alwaysRebuild:!0,create:()=>this.masterDetail.createDetailRow(t.data,e,a)??document.createElement("tr")})}}else this.treeData.isEnabled()?this.getTreeDisplayRows(!0).forEach(({data:e,index:t,treeRow:i,groupItem:l})=>{if("aggregate"===l?.type)return void n.push({key:l.key,sig:`${s}|agg:${l.key}`,alwaysRebuild:!0,create:()=>this.createAggregateRow(l,a)});if(!i)return;const r=this.isRowEditing(t);n.push({key:e,sig:this.rowSignature(e,t,s,i)+(r?"|edit":""),alwaysRebuild:r,restampIndex:t,create:()=>this.createRow(e,t,i)})}):t.forEach(e=>{const t=this.indexOfRow(e),i=this.isRowEditing(t);n.push({key:e,sig:this.rowSignature(e,t,s)+(i?"|edit":""),alwaysRebuild:i,restampIndex:t,create:()=>this.createRow(e,t)}),this.masterDetail.isEnabled()&&this.masterDetail.isExpanded(t)&&n.push({key:`__detail_${t}`,sig:"detail",alwaysRebuild:!0,create:()=>this.masterDetail.createDetailRow(e,t,a)??document.createElement("tr")})});this.pinnedBottomRows.forEach((e,t)=>{n.push({key:`__pinned_bottom_${t}`,sig:"pinned",alwaysRebuild:!0,create:()=>{const t=this.createRow(e,-1);return t.classList.add("pinned-row","pinned-row--bottom"),t}})}),this.reconcileRows(n),this.keyboard.refresh(),this.updateSelectAllState(),this.pagination&&this.renderPagination(),this.updateFillRow()}updateFillRow(){const e=this.shadowRoot?.querySelector(".table-frame"),t=e?.querySelector("table"),i=t?.querySelector("tbody");if(!e||!t||!i)return;if(i.querySelector("tr.table-fill-row")?.remove(),this.list&&this.listRenderer)return;const a=i.querySelectorAll("tr[data-index]"),s=a[a.length-1];if(!s)return;const n=Math.floor(e.clientHeight-t.offsetHeight);if(n<=1)return;const l=s.cloneNode(!0);l.className="table-fill-row";for(const e of["data-index","data-selected","role","aria-rowindex","aria-selected","tabindex","id"])l.removeAttribute(e);l.setAttribute("aria-hidden","true"),l.querySelectorAll("td").forEach(e=>{e.replaceChildren();for(const t of["role","aria-colindex","tabindex","aria-selected"])e.removeAttribute(t)}),l.style.height=`${n}px`,i.appendChild(l)}reconcileRows(e){const t=this.tbody;if(!t)return;const i=new Map,a=[],s=new Set;for(const t of e){const e=this.renderedRows.get(t.key);let n;!e||s.has(e.el)||t.alwaysRebuild||e.sig!==t.sig?n=t.create():(n=e.el,void 0!==t.restampIndex&&this.restampRowIndex(n,t.restampIndex)),s.add(n),a.push(n),i.has(t.key)||i.set(t.key,{el:n,sig:t.sig})}const n=new Set(a);for(const e of Array.from(t.children))n.has(e)||e.remove();let l=t.firstChild;for(const e of a)if(e===l)l=e.nextSibling;else{const i=document.createDocumentFragment();i.appendChild(e),t.insertBefore(i,l)}this.renderedRows=i}rendererIdFor(e){if("function"!=typeof e)return"";let t=this.rendererIds.get(e);return void 0===t&&(t=++this.rendererIdSeq,this.rendererIds.set(e,t)),String(t)}computeStructuralSig(){const e=this.getVisibleColumnDefinitions().map(e=>{const t=this.columnManager.getState(e.key),i=this.rendererIdFor(e.renderCell);return`${e.key}:${t?.width??""}:${t?.pinned??""}:rc${i}`});return[e.join(","),`pl=${Array.from(this.columnManager.getPinnedLeftOffsets().values()).join("/")}`,`pr=${Array.from(this.columnManager.getPinnedRightOffsets().values()).join("/")}`,`sel=${this.selectable?this.selectionMode:"off"}`,`selectable=${this.rendererIdFor(this.selectabilityCheck)}`,"md="+(this.masterDetail.isEnabled()?1:0),"rr="+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),`rh=${this.rowHeight}`,`d=${this.density}`,`tree=${this.treeData.isEnabled()?this.treeData.getGroupColumn():""}`].join("|")}rowValueSignature(e){if(null===e||"object"!=typeof e)return String(e);const t=[];for(const i of Object.keys(e)){const a=e[i];t.push(`${i}=${null==a?"":String(a)}`)}return t.join("|")}rowSignature(e,t,i,a){const s=[i,`v:${this.rowValueSignature(e)}`];return a&&s.push(`t:${a.depth}:${a.expanded?1:0}:${a.hasChildren?1:0}`),this.rowHeightCallback&&s.push(`h:${this.rowHeightCallback(e,t)}`),this.masterDetail.isEnabled()&&s.push("detail:"+(this.masterDetail.isExpanded(t)?1:0)),(this.rowReorder&&this.rowDnD.isEnabled()||this.masterDetail.isEnabled())&&s.push(`i:${t}`),s.join("|")}isRowEditing(e){if(!this.editable)return!1;if("row"===this.editMode){const t=this.editor.getRowEditState();return!(!t?.isEditing||t.rowIndex!==e)}const t=this.editor.getCellEditState();return!(!t?.isEditing||t.rowIndex!==e)}restampRowIndex(e,t){e.setAttribute("data-index",String(t));const i=this.selectedRows.includes(t);e.setAttribute("data-selected",String(i));const a=e.querySelector("snice-checkbox.row-select");if(a){a.setAttribute("data-row-index",String(t)),a.checked=i;const e=!(!this.selectabilityCheck||this.selectabilityCheck(this.data[t],t));a.disabled=e,a.toggleAttribute("disabled",e)}}invalidateRenderedRow(e){this.renderedRows.delete(e)}paginationTotal(){return"client"!==this.paginationMode?this.totalItems:this.usesGroupingDisplayModel()?this.getGroupingItems().length:this.treeData.isEnabled()?this.getTreeDisplayRows(!1).length:this.data.length}get totalPages(){const e=this.paginationTotal();return Math.max(1,Math.ceil(e/this.pageSize))}goToPage(e){const t=Math.max(1,Math.min(e,this.totalPages));t!==this.currentPage&&(this.currentPage=t,"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.renderBody(),this.dispatchPageChange())}setPageSize(e){this.pageSize=e,this.currentPage=1,"server"===this.paginationMode&&"remote"===this.mode?this.debouncedDataRequest():this.renderBody(),this.dispatchPageChange()}dispatchPageChange(){return{page:this.currentPage,pageSize:this.pageSize,totalPages:this.totalPages,totalItems:this.paginationTotal()}}renderPagination(){const e=this.shadowRoot?.querySelector(".table-pagination-container");if(!e)return;if(!this.pagination)return void(e.innerHTML="");const t=this.paginationTotal(),i=this.totalPages,a=Math.min((this.currentPage-1)*this.pageSize+1,t),s=Math.min(this.currentPage*this.pageSize,t),n=[];if(i<=7)for(let e=1;e<=i;e++)n.push(this.pageButton(e));else{n.push(this.pageButton(1)),this.currentPage>3&&n.push('<span class="pagination__ellipsis">…</span>');const e=Math.max(2,this.currentPage-1),t=Math.min(i-1,this.currentPage+1);for(let i=e;i<=t;i++)n.push(this.pageButton(i));this.currentPage<i-2&&n.push('<span class="pagination__ellipsis">…</span>'),n.push(this.pageButton(i))}e.innerHTML="";const l=document.createElement("div");l.className="pagination",l.setAttribute("part","pagination");const r=document.createElement("div");r.className="pagination__info",r.textContent=`Showing ${a}–${s} of ${t}`,l.appendChild(r);const o=document.createElement("div");o.className="pagination__controls",o.innerHTML=`\n <button class="pagination__btn pagination__first" ${this.currentPage<=1?"disabled":""} data-page="1" aria-label="First page">⟨⟨</button>\n <button class="pagination__btn pagination__prev" ${this.currentPage<=1?"disabled":""} data-page="${this.currentPage-1}" aria-label="Previous page">⟨</button>\n ${n.join("")}\n <button class="pagination__btn pagination__next" ${this.currentPage>=i?"disabled":""} data-page="${this.currentPage+1}" aria-label="Next page">⟩</button>\n <button class="pagination__btn pagination__last" ${this.currentPage>=i?"disabled":""} data-page="${i}" aria-label="Last page">⟩⟩</button>\n `,l.appendChild(o);const c=document.createElement("div");c.className="pagination__size";const d=document.createElement("label");d.textContent="Rows per page:",c.appendChild(d);const h=document.createElement("snice-select");h.size="small",h.className="pagination__size-select";const u=this.pageSizes.includes(this.pageSize)?this.pageSizes:[...this.pageSizes,this.pageSize].sort((e,t)=>e-t);for(const e of u){const t=document.createElement("snice-option");t.setAttribute("value",String(e)),t.textContent=String(e),e===this.pageSize&&t.setAttribute("selected",""),h.appendChild(t)}h.value=String(this.pageSize),c.appendChild(h),l.appendChild(c),e.appendChild(l),o.querySelectorAll("[data-page]").forEach(e=>{e.addEventListener("click",()=>{const t=parseInt(e.getAttribute("data-page"));this.goToPage(t)})}),h.addEventListener("select-change",e=>{this.setPageSize(parseInt(e.detail.value))})}pageButton(e){return`<button class="pagination__btn pagination__page${e===this.currentPage?" pagination__btn--active":""}" data-page="${e}">${e}</button>`}cellDisplayText(e,t,i){const a=e.formatter||e.valueFormatter;return a?String(a(t,i)??""):null}createCellElement(e,t,i){if("function"==typeof e.renderCell){const a=e.renderCell(t,i,e);if(a instanceof HTMLElement)return a;const s=document.createElement("span");return s.className="custom-cell",s.textContent=null==a?"":String(a),s}const a=this.getCellTagName(e.type),s=document.createElement(a);s.setAttribute("type",e.type||"text"),e.align&&s.setAttribute("align",e.align),s.setAttribute("in-table","true");const n=this.cellDisplayText(e,t,i),l=null===n?e:{...e,formatter:void 0,valueFormatter:void 0};switch(null!==n?(s.setAttribute("formatted",""),s.value=n,s.setAttribute("value",n)):"sparkline"===e.type&&null!==t&&"object"==typeof t?(s.setAttribute("value",JSON.stringify(t)),Array.isArray(t)&&(s.data=t)):(s.value=t??"",null!==t&&"object"==typeof t||s.setAttribute("value",String(t??""))),s.column=l,s.rowData=i??null,e.type){case"number":case"currency":if(void 0!==e.decimals&&s.setAttribute("decimals",String(e.decimals)),e.thousandsSeparator&&s.setAttribute("thousands-separator","true"),e.prefix&&s.setAttribute("prefix",e.prefix),e.suffix&&s.setAttribute("suffix",e.suffix),"currency"===e.type){const t=e.currencyFormat;t&&(t.currency&&s.setAttribute("currency",t.currency),t.locale&&s.setAttribute("locale",t.locale),(t.display||t.currencyDisplay)&&s.setAttribute("currencydisplay",t.currencyDisplay||t.display),void 0!==t.decimals&&s.setAttribute("decimals",String(t.decimals)),!1===t.thousandsSeparator&&(s.thousandsSeparator=!1))}break;case"date":e.dateFormat&&s.setAttribute("date-format",e.dateFormat);break;case"boolean":e.useSymbols&&s.setAttribute("use-symbols","true"),e.trueSymbol&&s.setAttribute("true-symbol",e.trueSymbol),e.falseSymbol&&s.setAttribute("false-symbol",e.falseSymbol),e.trueValue&&s.setAttribute("true-value",e.trueValue),e.falseValue&&s.setAttribute("false-value",e.falseValue);break;case"sparkline":{const t=e.sparklineFormat;t&&(t.color&&s.setAttribute("color",t.color),t.type&&s.setAttribute("chart-type",t.type),t.width&&s.setAttribute("width",String(t.width)),t.height&&s.setAttribute("height",String(t.height)));break}case"rating":{const t=e.ratingFormat;t&&(t.max&&s.setAttribute("max",String(t.max)),t.color&&s.setAttribute("color",t.color));break}case"progress":{const t=e.progressFormat;t&&(t.max&&s.setAttribute("max",String(t.max)),t.color&&s.setAttribute("color",t.color),t.showPercentage&&s.setAttribute("show-percentage","true"));break}case"percentage":case"percent":{const t=e.percentageFormat;t&&(void 0!==t.decimals&&s.setAttribute("decimals",String(t.decimals)),t.colorize&&s.setAttribute("colorize","true"));break}case"status":{const t=e.statusFormat;t&&(t.variant&&s.setAttribute("variant",t.variant),t.showDot&&s.setAttribute("show-dot","true"));break}case"link":{const t=e.linkFormat;t&&(t.target&&s.setAttribute("target",t.target),t.external&&s.setAttribute("external","true"));break}case"image":{const t=e.imageFormat;t&&(t.shape&&s.setAttribute("shape",t.shape),t.size&&s.setAttribute("size",t.size));break}case"color":{const t=e.colorFormat;t&&(!1!==t.showSwatch&&s.setAttribute("show-swatch","true"),t.displayFormat&&s.setAttribute("display-format",t.displayFormat));break}case"email":{const t=e.emailFormat;t&&t.showIcon&&s.setAttribute("show-icon","true");break}case"phone":{const t=e.phoneFormat;t&&(t.showIcon&&s.setAttribute("show-icon","true"),t.format&&s.setAttribute("format","true"));break}}return s}getCellTagName(e){switch(e){case"text":return"snice-cell-text";case"number":return"snice-cell-number";case"currency":return"snice-cell-currency";case"date":return"snice-cell-date";case"boolean":return"snice-cell-boolean";case"rating":return"snice-cell-rating";case"progress":return"snice-cell-progress";case"duration":return"snice-cell-duration";case"filesize":return"snice-cell-filesize";case"sparkline":return"snice-cell-sparkline";case"image":return"snice-cell-image";case"percentage":case"percent":return"snice-cell-percentage";case"tag":return"snice-cell-tag";case"status":return"snice-cell-status";case"actions":return"snice-cell-actions";case"link":return"snice-cell-link";case"email":return"snice-cell-email";case"phone":return"snice-cell-phone";case"color":return"snice-cell-color";case"location":return"snice-cell-location";case"json":return"snice-cell-json";default:return"snice-cell"}}updateRowSelectionState(){this.tbody&&this.tbody.querySelectorAll("tr").forEach((e,t)=>{const i=this.selectedRows.includes(t);e.setAttribute("data-selected",String(i));const a=e.querySelector("snice-checkbox.row-select");a&&(a.checked=i)})}updateRowSelectionStateFor(e,t){if(!this.tbody)return;const i=this.tbody.querySelector(`tr[data-index="${e}"]`);if(!i)return;i.setAttribute("data-selected",String(t));const a=i.querySelector("snice-checkbox.row-select");a&&(a.checked=t)}updateSelectAllState(){const e=this.thead?.querySelector("snice-checkbox.select-all");if(!e)return;const t=this.getSelectableIndices(this.getFilteredData()),i=t.filter(e=>this.selectedRows.includes(e)),a=i.length>0&&i.length<t.length;e.checked=i.length===t.length&&t.length>0,e.indeterminate=a}toggleSort(e,t=!1){if(t){const t=this.currentSort.findIndex(t=>t.column===e);this.currentSort=-1===t?[...this.currentSort,{column:e,direction:"asc"}]:"asc"===this.currentSort[t].direction?this.currentSort.map((e,i)=>i===t?{...e,direction:"desc"}:e):this.currentSort.filter(t=>t.column!==e)}else{const t=this.currentSort.find(t=>t.column===e);this.currentSort=t?"asc"===t.direction?[{column:e,direction:"desc"}]:[]:[{column:e,direction:"asc"}]}this.renderHeader(),this.dispatchSortChange(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()}applyLocalSortOrder(){this.unsortedData.length||(this.unsortedData=[...this.data]),this.settingSortedData=!0,this.data=0===this.currentSort.length?[...this.unsortedData]:[...this.unsortedData].sort((e,t)=>{for(const{column:i,direction:a}of this.currentSort){const s=this.columns.find(e=>e.key===i),n=s?.sortComparator,l=s?.valueGetter?s.valueGetter(e[i],e):e[i],r=s?.valueGetter?s.valueGetter(t[i],t):t[i];if(n){const e=n(l,r,a);if(0!==e)return e}else{const e=String(l??"").localeCompare(String(r??""),void 0,{numeric:!0});if(0!==e)return"asc"===a?e:-e}}return 0}),this.settingSortedData=!1}sortLocalData(){this.applyLocalSortOrder(),this.rebuildRowIndex(),this.scheduleRender("body")}dispatchRowSelectionChanged(e,t){return{selectedRows:this.selectedRows,rowIndex:e,selected:t}}dispatchRowClicked(e,t){return{rowData:e,rowIndex:t}}dispatchLoadError(e){return{error:e}}dispatchSelectAllChanged(e){return{selectedRows:this.selectedRows,allSelected:e}}dispatchSelectionChanged(){return{selectedRows:this.selectedRows,rows:this.getSelectedData()}}dispatchSortChange(){return{sort:this.currentSort}}dispatchFilterChange(){return{filters:this.filterEngine.getFilterModel()}}dispatchColumnVisibilityChange(e,t){return{key:e,visible:t,visibility:this.columnManager.getVisibilityModel()}}dispatchColumnPinChange(e,t){return{key:e,pinned:t}}dispatchColumnOrderChange(e,t){return{key:e,toIndex:t}}dispatchDensityChange(){return{density:this.density}}initializeModules(){this.columnManager.initialize(this.columns,this),this.setupEditor(),this.shadowRoot&&this.keyboard.attach({shadowRoot:this.shadowRoot,totalRows:()=>this.getKeyboardRows().length,ariaRows:()=>this.usesGroupingDisplayModel()?this.getDisplayedGroupingItems().length:this.treeData.isEnabled()?this.getTreeDisplayRows(!0).length:this.getKeyboardRows().length,ariaRowOffset:()=>this.virtualize&&this.virtualizer.isEnabled()?Math.max(0,this.virtualizer.getVisibleRange().start):0,totalColumns:()=>this.getKeyboardColumnCount(),tabMode:"all",isEditing:()=>this.editor.isEditing(),getRowElement:e=>this.getKeyboardRowElement(e),ensureRowVisible:e=>this.ensureKeyboardRowRendered(e),onCellActivate:(e,t)=>{const i=this.getKeyboardDataIndex(e);this.editable&&i>=0&&t&&this.startEdit(i,t)},onSelectionToggle:e=>{const t=this.getKeyboardDataIndex(e);this.selectable&&t>=0&&this.toggleRowSelection(t)},onSelectAll:()=>{this.selectable&&this.selectAllRows()}})}cleanup(){this.virtualizer.detach(),this.keyboard.detach(),this.lazyLoadHandler&&this.lazyLoadContainer?.removeEventListener("scroll",this.lazyLoadHandler),this.lazyLoadHandler=null,this.lazyLoadContainer=null,this.rowDnD.detach(),this.columnDnD.detach()}getScrollContainer(){return this.shadowRoot?.querySelector(".table-frame")??this.shadowRoot?.querySelector(".snice-table")}setupVirtualization(){if(!this.virtualize||!this.shadowRoot||!this.tbody)return;const e=this.getScrollContainer();e&&(this.virtualRowsSnapshot=this.getVirtualRows(),this.virtualizer.attach({rowHeight:e=>this.getVirtualRowHeight(e),bufferPx:this.virtualBuffer,totalRows:this.virtualRowsSnapshot.length,scrollContainer:e,renderRange:(e,t)=>this.renderRowRange(e,t),renderPinnedTop:()=>this.renderPinnedRows(this.pinnedTopRows,"top"),renderPinnedBottom:()=>this.renderPinnedRows(this.pinnedBottomRows,"bottom"),afterRender:()=>this.keyboard.refresh()}))}getVirtualRowHeight(e){const t=this.virtualRowsSnapshot[e];if(!t||t.groupItem&&"row"!==t.groupItem.type)return this.rowHeight;const i=t.groupItem?this.indexOfRow(t.data):t.index;return(this.rowHeightCallback?this.rowHeightCallback(t.data,i):this.rowHeight)+this.masterDetail.getFixedAdditionalHeight(i)}getVirtualRows(){const e=this.getFilteredData();return this.usesGroupingDisplayModel()?this.getDisplayedGroupingItems().map((e,t)=>({data:"row"===e.type?e.data:void 0,index:t,groupItem:e})):this.treeData.isEnabled()?this.getTreeDisplayRows(!0):e.map(e=>({data:e,index:this.indexOfRow(e)}))}renderRowRange(e,t){const i=document.createDocumentFragment(),a=this.virtualRowsSnapshot.length>0?this.virtualRowsSnapshot:this.getVirtualRows(),s=(this.hasSelectionColumn()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0),n=(this.columnManager.getAllStates().length>0?this.columnManager.getVisibleColumns().length:this.columns.length)+s,l=this.computeStructuralSig(),r=new Map,o=new Set;for(let s=e;s<t&&s<a.length;s++){const{data:e,index:t,treeRow:c,groupItem:d}=a[s];if(d&&"row"!==d.type){const e="group"===d.type?this.createGroupRow(d,n):this.createAggregateRow(d,n);o.add(e),r.has(d.key)||r.set(d.key,{el:e,sig:"grouprow"}),i.appendChild(e);continue}const h=d?this.indexOfRow(e):t,u=this.isRowEditing(h),m=this.rowSignature(e,h,l,c)+(u?"|edit":""),p=this.renderedRows.get(e);let g;if(!p||o.has(p.el)||u||p.sig!==m?g=this.createRow(e,h,c):(g=p.el,this.restampRowIndex(g,h)),o.add(g),r.has(e)||r.set(e,{el:g,sig:m}),i.appendChild(g),!c&&this.masterDetail.isEnabled()&&this.masterDetail.isExpanded(h)){const t=this.masterDetail.createDetailRow(e,h,n);t&&i.appendChild(t)}}return this.renderedRows=r,i}renderPinnedRows(e,t){const i=document.createDocumentFragment();for(const a of e){const e=this.createRow(a,-1);e.classList.add("pinned-row","top"===t?"pinned-row--top":"pinned-row--bottom"),i.appendChild(e)}return i}scrollToRow(e){if(this.usesGroupingDisplayModel()||this.treeData.isEnabled()){const t=this.data[e],i=this.getVirtualRows().findIndex(e=>e.data===t);return void(i>=0&&this.virtualizer.scrollToIndex(i))}this.virtualizer.scrollToRow(e)}getKeyboardColumnCount(){const e=this.shadowRoot?.querySelectorAll("thead tr.column-header-row > th").length??0;return e>0?e:(this.columnManager.getAllStates().length>0?this.columnManager.getVisibleColumns().length:this.columns.length)+(this.rowReorder&&this.rowDnD.isEnabled()?1:0)+(this.masterDetail.isEnabled()?1:0)+(this.hasSelectionColumn()?1:0)}getKeyboardRows(){if(this.usesGroupingDisplayModel())return this.getDisplayedGroupingItems().filter(e=>"row"===e.type).map(e=>e.data);if(this.treeData.isEnabled())return this.getTreeDisplayRows(!0).filter(e=>!!e.treeRow).map(e=>e.data);let e=this.getFilteredData();if(this.pagination&&"client"===this.paginationMode){const t=(this.currentPage-1)*this.pageSize;e=e.slice(t,t+this.pageSize)}return e}getKeyboardDataIndex(e){const t=this.getKeyboardRows()[e];return void 0===t?-1:this.indexOfRow(t)}getKeyboardRowElement(e){const t=this.getKeyboardDataIndex(e);return t<0?null:this.tbody?.querySelector(`tr[data-index="${t}"]`)}ensureKeyboardRowRendered(e){if(!this.virtualize||!this.virtualizer.isEnabled())return;if(this.getKeyboardRowElement(e))return;const t=this.getKeyboardRows()[e];if(void 0===t)return;const i=this.getVirtualRows().findIndex(e=>e.data===t);i>=0&&this.virtualizer.scrollToIndex(i)}getScrollPosition(){return this.virtualizer.getScrollPosition()}setColumnFilter(e,t,i){this.filterEngine.setColumnFilter(e,t,i),this.applyClientFilters()}removeColumnFilter(e){this.filterEngine.removeColumnFilter(e),this.applyClientFilters()}setQuickFilter(e){this.filterEngine.setQuickFilter(e),this.applyClientFilters()}setFilterModel(e){this.filterEngine.setFilterModel(e),this.applyClientFilters()}getFilterModel(){return this.filterEngine.getFilterModel()}clearAllFilters(){this.filterEngine.clearAllFilters(),this.applyClientFilters()}getFilteredData(){if(this.ensureRowIndex(),this.filteredCache)return this.filteredCache;const e=this.filterEngine.hasActiveFilters()?this.filterEngine.applyFilters(this.data,this.columns):this.data;return this.filteredCache=e,e}rebuildRowIndex(){this.rowIndexMap.clear();const e=this.data;for(let t=0;t<e.length;t++)this.rowIndexMap.has(e[t])||this.rowIndexMap.set(e[t],t);this.rowIndexDataRef=e,this.filteredCache=null,this.groupingCache=null}ensureRowIndex(){this.rowIndexDataRef!==this.data&&this.rebuildRowIndex()}indexOfRow(e){this.ensureRowIndex();const t=this.rowIndexMap.get(e);return void 0===t?-1:t}invalidateFilteredCache(){this.filteredCache=null,this.groupingCache=null}invalidateGroupingCache(){this.groupingCache=null}getGroupingItems(){return this.grouping.setColumns(this.columns)&&this.invalidateGroupingCache(),this.groupingCache||(this.groupingCache=this.grouping.processData(this.getFilteredData())),this.groupingCache}usesGroupingDisplayModel(){return this.grouping.hasGrouping()||this.grouping.hasAggregation()&&!this.treeData.isEnabled()}getDisplayedGroupingItems(){const e=this.getGroupingItems();if(!this.pagination||"client"!==this.paginationMode)return e;const t=Math.max(1,Math.ceil(e.length/this.pageSize)),i=Math.max(1,Math.min(this.currentPage,t));i!==this.currentPage&&(this.currentPage=i);const a=(i-1)*this.pageSize;return e.slice(a,a+this.pageSize)}getTreeDisplayRows(e){const t=this.treeData.processData(this.getFilteredData()).map(e=>({data:e.data,index:this.indexOfRow(e.data),treeRow:e}));if(this.grouping.hasAggregation()){const e=this.getGroupingItems().find(e=>"aggregate"===e.type&&"table"===e.scope);e&&t.push({data:void 0,index:-1,groupItem:e})}if(!e||!this.pagination||"client"!==this.paginationMode)return t;const i=Math.max(1,Math.ceil(t.length/this.pageSize)),a=Math.max(1,Math.min(this.currentPage,i));a!==this.currentPage&&(this.currentPage=a);const s=(a-1)*this.pageSize;return t.slice(s,s+this.pageSize)}applyClientFilters(){this.invalidateFilteredCache(),this.dispatchFilterChange(),"remote"===this.mode?this.debouncedDataRequest():this.renderBody()}static{this.FILTER_INPUT_DEBOUNCE_MS=150}debouncedApplyClientFilters(){this.filterInputDebounceTimeout&&clearTimeout(this.filterInputDebounceTimeout),this.filterInputDebounceTimeout=setTimeout(()=>{this.filterInputDebounceTimeout=null,this.applyClientFilters()},Xi.FILTER_INPUT_DEBOUNCE_MS)}setColumnVisible(e,t){this.columnManager.setColumnVisible(e,t),this.renderHeader(),this.renderBody(),this.dispatchColumnVisibilityChange(e,t)}showAllColumns(){this.columnManager.showAllColumns(),this.renderHeader(),this.renderBody()}hideAllColumns(){this.columnManager.hideAllColumns(),this.renderHeader(),this.renderBody()}getColumnVisibility(){return this.columnManager.getVisibilityModel()}pinColumn(e,t){this.columnManager.pinColumn(e,t),this.renderHeader(),this.renderBody(),this.dispatchColumnPinChange(e,t)}unpinColumn(e){this.columnManager.unpinColumn(e),this.renderHeader(),this.renderBody(),this.dispatchColumnPinChange(e,!1)}autoSizeColumn(e){this.tbody&&(this.columnManager.autoSizeColumn(e,this.tbody),this.renderHeader())}autoSizeAllColumns(){this.tbody&&(this.columnManager.autoSizeAll(this.tbody),this.renderHeader())}moveColumn(e,t){this.columnManager.moveColumn(e,t),this.renderHeader(),this.renderBody(),this.dispatchColumnOrderChange(e,t)}setupEditor(){if(!this.editable)return;this.editor.attach(this),this.editor.setEditMode(this.editMode);const e=this.columns.filter(e=>!1!==e.editable).map(e=>e.key);this.editor.setEditableColumns(e);for(const e of this.columns)(e.valueGetter||e.valueFormatter||e.valueParser||e.valueSetter)&&this.editor.setPipeline(e.key,{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter,valueParser:e.valueParser,valueSetter:e.valueSetter})}startEdit(e,t){if(!this.editable)return;const i=this.data[e];if(i){if(this.setupEditor(),"row"===this.editMode)this.editor.startRowEdit(e,i);else{const a=this.columns.find(e=>e.key===t);this.editor.startCellEdit(e,t,i[t],i,a?.editorType??a?.type)}this.renderBody(),this.focusActiveEditor()}}focusActiveEditor(){const e=this.tbody?.querySelector(".table-editor-input, .table-editor-checkbox, .table-editor-select");if(e&&(e.focus(),e instanceof HTMLInputElement&&("text"===e.type||"number"===e.type)))try{e.select()}catch{}}async commitEdit(){if("row"===this.editMode){const e=await this.editor.commitRowEdit();return this.renderBody(),e?"Validation errors":null}{const e=await this.editor.commitCellEdit();return this.renderBody(),e}}cancelEdit(){"row"===this.editMode?this.editor.cancelRowEdit():this.editor.cancelCellEdit(),this.renderBody()}exportCSV(e){const t=this.getFilteredData(),i=e?.selectedOnly?this.getSelectedRowsIn(t):t;this.exporter.exportCSV(i,this.columns,e)}printTable(e){this.exporter.print(this,e)}async copyToClipboard(e){const t=this.getFilteredData(),i=this.selectedRows.length>0?this.getSelectedRowsIn(t):t;return this.exporter.copyToClipboard(i,this.columns,e)}getSelectedRowsIn(e){const t=new Set(this.getSelectedData());return e.filter(e=>t.has(e))}hasSelectionColumn(){return this.selectable&&"none"!==this.selectionMode}getSlottedSelectionRows(){return this.shouldModelSlottedRows()?[]:Array.from(this.querySelectorAll('snice-row[slot="rows"]'))}getSelectionSourceRows(){const e=this.getSlottedSelectionRows();return e.length>0?e.map(e=>e.data):this.data}syncSlottedSelectionState(){const e=this.getSlottedSelectionRows();if(0===e.length)return;const t=this.hasSelectionColumn();let i=!1;e.forEach((e,a)=>{const s=!(!t||!this.selectabilityCheck||this.selectabilityCheck(e.data,a));e.index=a,e.selectable=t,e.selectionDisabled=s,!t||s?e.selected=!1:"single"===this.selectionMode&&e.selected&&(i?e.selected=!1:i=!0)}),this.selectedRows=e.map((e,t)=>e.selected&&!e.selectionDisabled?t:-1).filter(e=>e>=0)}getSelectableIndices(e){const t=[];for(const i of e){const e=this.indexOfRow(i);e<0||this.selectabilityCheck&&!this.selectabilityCheck(i,e)||t.push(e)}return t}applyRowSelection(e,t){if("none"===this.selectionMode)return;if(this.selectabilityCheck&&!this.selectabilityCheck(this.data[e],e))return;const i=this.data[e];if("single"===this.selectionMode)return this.selectedRows=[e],this.selectionAnchor=i,this.dispatchRowSelectionChanged(e,!0),void this.dispatchSelectionChanged();if(t.range&&null!=this.selectionAnchor)return this.selectRange(this.selectionAnchor,i),this.dispatchRowSelectionChanged(e,this.selectedRows.includes(e)),void this.dispatchSelectionChanged();const a=this.selectedRows.includes(e);this.selectedRows=a?this.selectedRows.filter(t=>t!==e):[...this.selectedRows,e],this.selectionAnchor=i,this.dispatchRowSelectionChanged(e,!a),this.dispatchSelectionChanged()}selectRange(e,t){const i=this.getFilteredData();let a=i.indexOf(e);const s=i.indexOf(t);if(-1===s)return;-1===a&&(a=s);const n=Math.min(a,s),l=Math.max(a,s),r=[];for(let e=n;e<=l;e++){const t=this.indexOfRow(i[e]);t<0||this.selectabilityCheck&&!this.selectabilityCheck(i[e],t)||r.push(t)}this.selectedRows=r}toggleRowSelection(e){this.applyRowSelection(e,{additive:!0,range:!1})}selectAllRows(){if("multiple"!==this.selectionMode)return;const e=this.getSelectableIndices(this.getFilteredData()),t=e.every(e=>this.selectedRows.includes(e));if(t)this.selectedRows=this.selectedRows.filter(t=>!e.includes(t));else{const t=new Set([...this.selectedRows,...e]);this.selectedRows=Array.from(t)}this.dispatchSelectAllChanged(t),this.dispatchSelectionChanged()}setDetailPanel(e){this.masterDetail.attach(this,e),this.masterDetail.onHeightChange=()=>{this.virtualize&&this.virtualizer.isEnabled()&&(this.virtualRowsSnapshot=this.getVirtualRows(),this.virtualizer.setTotalRows(this.virtualRowsSnapshot.length))},this.masterDetail.prepare(this.data),this.renderHeader(),this.renderBody()}expandRow(e){this.masterDetail.expand(e),this.renderBody()}collapseRow(e){this.masterDetail.collapse(e),this.renderBody()}toggleRowExpansion(e){this.masterDetail.toggle(e),this.renderBody()}expandAllRows(){this.masterDetail.expandAll(this.data.length),this.renderBody()}collapseAllRows(){this.masterDetail.collapseAll(),this.renderBody()}setToolbar(e){this.toolbarOptions=e;const t=this.shadowRoot?.querySelector(".table-controls-container");t&&(this.toolbar.attach(this,t,e),this.toolbar.setFilterEngine(this.filterEngine),this.toolbar.onSearch=e=>this.setQuickFilter(e),this.toolbar.onSortColumn=(e,t)=>{this.currentSort=[{column:e,direction:t}],this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.toolbar.onSetSortModel=e=>{this.currentSort=e,this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.toolbar.onFilterColumn=(e,t,i)=>{this.setColumnFilter(e,t,i)},this.toolbar.onRemoveFilter=e=>{this.removeColumnFilter(e)},this.toolbar.onSetFilterModel=(e,t)=>{this.filterEngine.clearAllFilters(),this.filterEngine.setFilterLogic(t);for(const t of e)this.filterEngine.setColumnFilter(t.column,t.operator,t.value);this.applyClientFilters()},this.toolbar.onClearFilters=()=>{this.clearAllFilters()},this.toolbar.onExportCSV=()=>this.exportCSV(),this.toolbar.onFullscreen=()=>this.toggleFullscreen())}setTreeData(e){this.treeData.attach(e),this.renderBody()}expandTreeNode(e){this.treeData.expand(e),this.renderBody()}collapseTreeNode(e){this.treeData.collapse(e),this.renderBody()}toggleTreeNode(e){this.treeData.toggle(e),this.renderBody()}expandAllTreeNodes(){this.treeData.expandAll(this.data),this.renderBody()}collapseAllTreeNodes(){this.treeData.collapseAll(),this.renderBody()}setColumnGroups(e){this.columnManager.setColumnGroups(e),this.renderHeader()}initColumnMenu(){this.columnMenu&&(this.columnMenuManager.attach(this),this.columnMenuManager.onSortAsc=e=>{this.currentSort=[{column:e,direction:"asc"}],this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.columnMenuManager.onSortDesc=e=>{this.currentSort=[{column:e,direction:"desc"}],this.dispatchSortChange(),this.renderHeader(),"remote"===this.mode?this.debouncedDataRequest():this.sortLocalData()},this.columnMenuManager.onFilter=e=>{this.toolbar.openFilterModal(e)},this.columnMenuManager.onHide=e=>this.setColumnVisible(e,!1),this.columnMenuManager.onPinLeft=e=>this.pinColumn(e,"left"),this.columnMenuManager.onPinRight=e=>this.pinColumn(e,"right"),this.columnMenuManager.onUnpin=e=>this.unpinColumn(e),this.columnMenuManager.onAutoSize=e=>this.autoSizeColumn(e))}pinRowTop(e){this.pinnedTopRows.push(e),this.renderBody()}pinRowBottom(e){this.pinnedBottomRows.push(e),this.renderBody()}unpinRow(e){this.pinnedTopRows=this.pinnedTopRows.filter(t=>t!==e),this.pinnedBottomRows=this.pinnedBottomRows.filter(t=>t!==e),this.renderBody()}clearPinnedRows(){this.pinnedTopRows=[],this.pinnedBottomRows=[],this.renderBody()}setRowHeight(e){this.rowHeight=e,this.renderBody()}setRowHeightCallback(e){this.rowHeightCallback=e,this.renderBody()}setSortComparator(e,t){const i=this.columns.find(t=>t.key===e);i&&(i.sortComparator=t)}setSelectabilityCheck(e){this.selectabilityCheck=e;const t=this.getSelectionSourceRows();this.selectedRows=this.selectedRows.filter(i=>{const a=t[i];return!!a&&e(a,i)}),this.syncSlottedSelectionState(),this.scheduleRender("both")}setCellEditableCheck(e){this.editor.setEditabilityCheck(e)}getSelectedData(){const e=this.getSelectionSourceRows();return this.selectedRows.map(t=>e[t]).filter(Boolean)}setupLazyLoading(){if(!this.lazyLoad)return;const e=this.getScrollContainer();e&&(this.lazyLoadHandler&&this.lazyLoadContainer?.removeEventListener("scroll",this.lazyLoadHandler),this.lazyLoadHandler=()=>{const{scrollTop:t,scrollHeight:i,clientHeight:a}=e;i-t-a<this.lazyLoadThreshold&&this.dispatchEvent(new CustomEvent("lazy-load",{detail:{currentCount:this.data.length},bubbles:!0,composed:!0}))},e.addEventListener("scroll",this.lazyLoadHandler,{passive:!0}),this.lazyLoadContainer=e)}scrollToColumn(e){const t=this.shadowRoot?.querySelector(`th[data-key="${e}"]`);t?.scrollIntoView({inline:"nearest",block:"nearest"})}handleListRendererChange(){this.list&&(this.renderedRows=new Map,this.renderBody())}setListViewRenderer(e){this.listRenderer=e}createRow(e,t,i){const a=document.createElement("tr");a.setAttribute("data-index",String(t)),a.setAttribute("part","row"),this.rowHeightCallback?a.style.height=`${this.rowHeightCallback(e,t)}px`:48!==this.rowHeight&&(a.style.height=`${this.rowHeight}px`);const s=this.selectedRows.includes(t);if(a.setAttribute("data-selected",String(s)),this.rowReorder&&this.rowDnD.isEnabled()&&(a.appendChild(this.rowDnD.createDragHandle()),this.rowDnD.makeRowDraggable(a,t)),this.masterDetail.isEnabled()){const e=document.createElement("td");e.className="detail-toggle-cell",e.appendChild(this.masterDetail.createToggleButton(t)),a.appendChild(e)}if(this.hasSelectionColumn()){const i=document.createElement("td");i.className="select-column";const n=!(!this.selectabilityCheck||this.selectabilityCheck(e,t));i.innerHTML=`<snice-checkbox class="row-select" size="small" compact ${s?"checked":""} ${n?"disabled":""} data-row-index="${t}"></snice-checkbox>`,i.querySelector("snice-checkbox").disabled=n,a.appendChild(i)}const n=this.getVisibleColumnDefinitions();if(this.list&&this.listRenderer){const i=document.createElement("td");i.className="list-view-cell",i.colSpan=Math.max(1,n.length);const s=this.listRenderer(e,t);return s instanceof HTMLElement?i.appendChild(s):i.textContent=null==s?"":String(s),a.appendChild(i),a}let l=0;return n.forEach((s,n)=>{if(l>0)return void l--;const r=document.createElement("td");r.setAttribute("data-key",s.key),r.setAttribute("part","cell");const o=e[s.key],c=s.valueGetter?s.valueGetter(o,e):o;this.applyCellPresentation(r,s,c,e);const d=s.colSpan;if(d){const t="function"==typeof d?d(c,e):d;t>1&&(r.colSpan=t,l=t-1)}const h=this.maybeCreateCellEditor(s,e,c,t);if(h)r.classList.add("editing"),r.appendChild(h);else if(i&&s.key===this.treeData.getGroupColumn()){const e=this.treeData.createToggle(i);r.appendChild(e);const t=document.createElement("span");t.textContent=null==c?"":String(c),i.hasChildren&&(t.style.cursor="pointer",t.addEventListener("click",e=>{e.stopPropagation(),this.treeData.toggle(i.key),this.renderBody()})),r.appendChild(t)}else r.appendChild(this.createCellElement(s,c,e));const u=this.columnManager.getState(s.key);if(u)if(r.style.width=`${u.width}px`,"left"===u.pinned){const e=this.columnManager.getPinnedLeftOffsets();r.classList.add("pinned-cell"),r.style.position="sticky",r.style.left=`${e.get(s.key)??0}px`,r.style.zIndex="1"}else if("right"===u.pinned){const e=this.columnManager.getPinnedRightOffsets();r.classList.add("pinned-cell"),r.style.position="sticky",r.style.right=`${e.get(s.key)??0}px`,r.style.zIndex="1"}a.appendChild(r)}),a}applyCellPresentation(e,t,i,a){const s=t=>{t&&(t.backgroundColor&&(e.style.backgroundColor=t.backgroundColor),t.color&&(e.style.color=t.color),t.fontWeight&&(e.style.fontWeight=t.fontWeight),t.fontStyle&&(e.style.fontStyle=t.fontStyle),t.fontSize&&(e.style.fontSize=t.fontSize),t.textDecoration&&(e.style.textDecoration=t.textDecoration))};s(t.style);for(const n of t.conditionalFormats||[])if(n.condition(i,a)){s(n.style),n.className&&e.classList.add(n.className);break}t.tooltip&&(e.title="function"==typeof t.tooltip?t.tooltip(i,a):null==i?"":String(i))}createGroupRow(e,t){const i=document.createElement("tr");i.className="group-header-row",i.setAttribute("data-group-key",e.key),i.setAttribute("data-depth",String(e.depth)),i.setAttribute("aria-label",`${null==e.value||""===e.value?"Blank":String(e.value)} group, ${e.count} rows`);const a=document.createElement("td");if(a.colSpan=t,a.className="group-header-cell",this.selectable&&"multiple"===this.selectionMode){const t=this.groupSelectionState(e),i=document.createElement("span");i.className="group-select-wrap";const s=document.createElement("snice-checkbox");s.className="group-select",s.setAttribute("size","small"),s.setAttribute("compact",""),s.setAttribute("data-group-key",e.key),s.setAttribute("aria-label",`Select all rows in ${null==e.value||""===e.value?"blank":String(e.value)} group`),s.checked="all"===t,s.indeterminate="some"===t,s.disabled=0===this.getSelectableGroupIndices(e).length,i.appendChild(s),a.appendChild(i)}const s=this.grouping.createToggle(e);a.appendChild(s);const n=document.createElement("span");n.className="group-header-label",n.textContent=null==e.value?"":String(e.value),a.appendChild(n);const l=document.createElement("span");return l.className="group-header-count",l.textContent=String(e.count),a.appendChild(l),i.appendChild(a),i}createAggregateRow(e,t){const i=document.createElement("tr");i.className="group-aggregate-row",i.setAttribute("data-agg-scope",e.scope),i.setAttribute("data-depth",String(e.depth)),e.groupKey&&i.setAttribute("data-group-key",e.groupKey);const a=null==e.groupValue||""===e.groupValue?"Blank":String(e.groupValue),s="table"===e.scope?"Total":`${e.groupColumn?`${e.groupColumn}: `:""}${a} subtotal`;if(i.setAttribute("aria-label",s),this.rowReorder&&this.rowDnD.isEnabled()){const e=document.createElement("td");e.className="drag-handle-cell",i.appendChild(e)}if(this.masterDetail.isEnabled()){const e=document.createElement("td");e.className="detail-toggle-cell",i.appendChild(e)}if(this.hasSelectionColumn()){const e=document.createElement("td");e.className="select-column",i.appendChild(e)}const n=this.getVisibleColumnDefinitions(),l=n.find(t=>!Object.prototype.hasOwnProperty.call(e.aggregates,t.key))?null:n[0]?.key;let r=!1;return n.forEach(t=>{const a=document.createElement("td");a.setAttribute("data-key",t.key),a.className="aggregate-cell";const n=Object.prototype.hasOwnProperty.call(e.aggregates,t.key);if(!n&&!r||n&&t.key===l){r=!0;const t=document.createElement("span");t.className="aggregate-label"+(n?" aggregate-label--inline":""),t.textContent=s,"group"===e.scope&&e.depth>0&&(t.style.paddingLeft=1.5*e.depth+"rem"),a.appendChild(t)}if(n){const i=e.aggregates[t.key];a.setAttribute("data-agg-value",String(i));const s=t.renderCell||!t.formatter&&t.valueFormatter?{...t,renderCell:void 0,formatter:t.formatter??t.valueFormatter}:t;a.appendChild(this.createCellElement(s,i))}const o=this.columnManager.getState(t.key);if(o)if(a.style.width=`${o.width}px`,"left"===o.pinned){const e=this.columnManager.getPinnedLeftOffsets();a.classList.add("pinned-cell"),a.style.position="sticky",a.style.left=`${e.get(t.key)??0}px`,a.style.zIndex="1"}else if("right"===o.pinned){const e=this.columnManager.getPinnedRightOffsets();a.classList.add("pinned-cell"),a.style.position="sticky",a.style.right=`${e.get(t.key)??0}px`,a.style.zIndex="1"}i.appendChild(a)}),i}groupSelectionState(e){const t=this.getSelectableGroupIndices(e);if(0===t.length)return"none";const i=t.filter(e=>this.selectedRows.includes(e)).length;return 0===i?"none":i===t.length?"all":"some"}getSelectableGroupIndices(e){const t=[];for(const i of e.rows){const e=this.indexOfRow(i);e<0||this.selectabilityCheck&&!this.selectabilityCheck(i,e)||t.push(e)}return t}toggleGroup(e){this.grouping.toggle(e.key),this.invalidateGroupingCache(),this.dispatchGroupToggle(e.key,e.value,this.grouping.isExpanded(e.key)),this.renderBody()}updateGroupSelectionStates(){if(!this.tbody||!this.grouping.hasGrouping()||!this.selectable)return;const e=this.getGroupingItems().filter(e=>"group"===e.type);if(0===e.length)return;const t=new Map(e.map(e=>[e.key,e]));this.tbody.querySelectorAll("tr.group-header-row").forEach(e=>{const i=e.getAttribute("data-group-key"),a=i?t.get(i):void 0;if(!a)return;const s=e.querySelector("snice-checkbox.group-select");if(!s)return;const n=this.groupSelectionState(a);s.checked="all"===n,s.indeterminate="some"===n})}dispatchGroupToggle(e,t,i){return{key:e,value:t,expanded:i}}maybeCreateCellEditor(e,t,i,a){if(!this.editable)return null;let s,n=!1,l=i;if("row"===this.editMode){const i=this.editor.getRowEditState();i?.isEditing&&i.rowIndex===a&&this.editor.isCellEditable(t,e.key)&&(n=!0,l=i.editedRow[e.key]),s=this.resolveEditorType(e)}else{const t=this.editor.getCellEditState();t?.isEditing&&t.rowIndex===a&&t.columnKey===e.key&&(n=!0,l=t.currentValue),s=t?.editorType??this.resolveEditorType(e)}if(!n)return null;if("function"==typeof e.renderEditor)return e.renderEditor(l,t,e,t=>{"row"===this.editMode?this.editor.updateRowField(e.key,t):this.editor.updateCellValue(t),this.commitEdit()},()=>this.cancelEdit());const r=this.editor.createEditor(s,l,e.selectOptions?{selectOptions:e.selectOptions}:void 0);return this.wireEditorElement(r,e),r}resolveEditorType(e){return e.editorType?e.editorType:this.editor.getEditorType(e.type||"text")}wireEditorElement(e,t){const i=e instanceof HTMLInputElement&&"checkbox"===e.type,a=()=>{const a=i?e.checked:e.value;"row"===this.editMode?this.editor.updateRowField(t.key,a):this.editor.updateCellValue(a)};e.addEventListener("input",a),e.addEventListener("change",a),e.addEventListener("keydown",e=>{"Enter"===e.key?(e.preventDefault(),a(),this.commitEdit()):"Escape"===e.key&&(e.preventDefault(),this.cancelEdit())}),e.addEventListener("blur",()=>{"row"!==this.editMode&&this.editor.isEditing()&&(a(),this.commitEdit())})}constructor(){super(...arguments),this.striped=(k(this,vt),k(this,yt,!1)),this.searchable=(k(this,wt),k(this,kt,!1)),this.filterable=(k(this,xt),k(this,Ct,!1)),this.sortable=(k(this,St),k(this,Et,!1)),this.selectable=(k(this,Dt),k(this,At,!1)),this.hoverable=(k(this,Rt),k(this,Mt,!0)),this.clickable=(k(this,zt),k(this,$t,!1)),this.list=(k(this,Ft),k(this,It,!1)),this.pagination=(k(this,Tt),k(this,Lt,!1)),this.paginationMode=(k(this,Vt),k(this,Bt,"client")),this.pageSize=(k(this,Ot),k(this,jt,10)),this.currentPage=(k(this,Nt),k(this,Pt,1)),this.totalItems=(k(this,Ht),k(this,qt,0)),this.pageSizes=(k(this,_t),k(this,Gt,[10,25,50,100])),this.searchDebounce=(k(this,Kt),k(this,Wt,500)),this.columns=(k(this,Ut),k(this,Zt,[])),this.data=(k(this,Yt),k(this,Jt,[])),this.mode=(k(this,Qt),k(this,Xt,"local")),this.currentSort=(k(this,ei),k(this,ti,[])),this.searchText=(k(this,ii),""),this.selector=k(this,ai,""),this.selectorOptions=(k(this,si),k(this,ni,[])),this.loading=(k(this,li),k(this,ri,!1)),this.loadError=(k(this,oi),null),this.virtualize=k(this,ci,!1),this.rowHeight=(k(this,di),k(this,hi,48)),this.virtualBuffer=(k(this,ui),k(this,mi,200)),this.columnResize=(k(this,pi),k(this,gi,!1)),this.editable=(k(this,bi),k(this,fi,!1)),this.editMode=(k(this,vi),k(this,yi,"cell")),this.density=(k(this,wi),k(this,ki,"standard")),this.headerFilters=(k(this,xi),k(this,Ci,!1)),this.quickFilter=(k(this,Si),k(this,Ei,!1)),this.rowReorder=(k(this,Di),k(this,Ai,!1)),this.columnReorder=(k(this,Ri),k(this,Mi,!1)),this.columnMenu=(k(this,zi),k(this,$i,!1)),this.lazyLoad=(k(this,Fi),k(this,Ii,!1)),this.lazyLoadThreshold=(k(this,Ti),k(this,Li,200)),this.selectedRows=(k(this,Vi),k(this,Bi,[])),this.selectionMode=(k(this,Oi),k(this,ji,"multiple")),this.selectionAnchor=(k(this,Ni),null),this.groupBy=k(this,Pi,""),this.groupDefaults=(k(this,Hi),k(this,qi,{})),this.groupingCache=(k(this,_i),null),this.virtualizer=new oe,this.columnManager=new ce,this.filterEngine=new pe,this.editor=new ge,this.keyboard=new be,this.exporter=new fe,this.masterDetail=new ve,this.toolbar=new ye,this.treeData=new ke,this.grouping=new Ce,this.columnMenuManager=new Se,this.rowDnD=new Ee,this.columnDnD=new De,this.pinnedTopRows=[],this.pinnedBottomRows=[],this.toolbarOptions=null,this.lazyLoadHandler=null,this.lazyLoadContainer=null,this.rowHeightCallback=null,this.virtualRowsSnapshot=[],this.table=k(this,Gi,void 0),this.thead=(k(this,Ki),k(this,Wi,void 0)),this.tbody=(k(this,Ui),k(this,Zi,void 0)),this.unsortedData=(k(this,Yi),[]),this.dataRequestTimeout=null,this.rowIndexMap=new Map,this.rowIndexDataRef=null,this.filteredCache=null,this.dataRequestSeq=0,this.renderedRows=new Map,this.settingSortedData=!1,this.settingDataImperative=!1,this.renderQueued=!1,this.pendingHeaderRender=!1,this.pendingBodyRender=!1,this.rendererIds=new WeakMap,this.rendererIdSeq=0,this.fsExitHandler=null,this.toggleFullscreen=async()=>{if(this.classList.contains("table-fullscreen")){if(this.classList.remove("table-fullscreen"),document.fullscreenElement===this)try{await document.exitFullscreen()}catch{}this.fsExitHandler&&(document.removeEventListener("fullscreenchange",this.fsExitHandler),this.fsExitHandler=null)}else{this.classList.add("table-fullscreen");try{"function"==typeof this.requestFullscreen&&await this.requestFullscreen()}catch{}this.fsExitHandler=()=>{document.fullscreenElement!==this&&(this.classList.remove("table-fullscreen"),this.fsExitHandler&&(document.removeEventListener("fullscreenchange",this.fsExitHandler),this.fsExitHandler=null))},document.addEventListener("fullscreenchange",this.fsExitHandler)}},this.handleKeydown=e=>{if("Enter"!==e.key&&" "!==e.key)return;const t=e.target.closest("th.sortable");if(!t)return;const i=t.getAttribute("data-key");i&&(e.preventDefault(),this.toggleSort(i,!0))},this.handleClick=e=>{const t=e.target,i=t.closest("th.sortable");if(i){const e=i.getAttribute("data-key");return void(e&&this.toggleSort(e,!0))}const a=t.closest("tbody tr");if(a){if(a.classList.contains("group-header-row")){if(t.closest("snice-checkbox.group-select"))return;const e=a.getAttribute("data-group-key"),i=e?this.getGroupingItems().find(t=>"group"===t.type&&t.key===e):void 0;return void(i&&this.toggleGroup(i))}if(!a.hasAttribute("data-index"))return;if(t.matches('input[type="checkbox"], button, a, .interactive, snice-checkbox, snice-button, snice-input, snice-select'))return;const i=parseInt(a.getAttribute("data-index")||"0"),s=this.data[i];this.selectable&&this.applyRowSelection(i,{additive:e.ctrlKey||e.metaKey,range:e.shiftKey}),this.clickable&&this.dispatchRowClicked(s,i)}},this.handleChange=e=>{const t=e.target;if(t.matches("snice-checkbox.row-select")){const e=t,i=parseInt(e.getAttribute("data-row-index")||"0");if("none"===this.selectionMode)return;return this.selectabilityCheck&&!this.selectabilityCheck(this.data[i],i)?void(e.checked=this.selectedRows.includes(i)):("single"===this.selectionMode?this.selectedRows=e.checked?[i]:[]:e.checked?this.selectedRows.includes(i)||(this.selectedRows=[...this.selectedRows,i]):this.selectedRows=this.selectedRows.filter(e=>e!==i),this.selectionAnchor=this.data[i],this.dispatchRowSelectionChanged(i,e.checked),void this.dispatchSelectionChanged())}if(t.matches("snice-checkbox.group-select")){const e=t;if("multiple"!==this.selectionMode)return;const i=e.getAttribute("data-group-key"),a=this.getGroupingItems().find(e=>"group"===e.type&&e.key===i);if(!a)return;const s=this.getSelectableGroupIndices(a);if(e.checked)this.selectedRows=Array.from(new Set([...this.selectedRows,...s]));else{const e=new Set(s);this.selectedRows=this.selectedRows.filter(t=>!e.has(t))}return void this.dispatchSelectionChanged()}if(t.matches("snice-checkbox.select-all")){const e=t;if("multiple"!==this.selectionMode)return;this.selectedRows=e.checked?this.getSelectableIndices(this.getFilteredData()):[],this.dispatchSelectAllChanged(e.checked),this.dispatchSelectionChanged()}},this.onAttached=()=>{"remote"===this.mode&&(this.getTableConfig(),this.getTableData())},this.searchDebounceTimeout=null,this.handleSearchInput=e=>{this.searchText=e.target.value,this.searchDebounceTimeout&&clearTimeout(this.searchDebounceTimeout),this.searchDebounceTimeout=setTimeout(()=>{"remote"===this.mode?this.getTableData():this.setQuickFilter(this.searchText)},this.searchDebounce)},this.handleQuickFilterInput=e=>{const t=e.target;this.filterInputDebounceTimeout&&clearTimeout(this.filterInputDebounceTimeout),this.filterInputDebounceTimeout=setTimeout(()=>{this.filterInputDebounceTimeout=null,this.setQuickFilter(t.value||"")},Xi.FILTER_INPUT_DEBOUNCE_MS)},this.selectorDebounceTimeout=null,this.handleSelectorChange=e=>{this.selector=Array.isArray(e.detail.value)?e.detail.value.join(","):e.detail.value,this.selectorDebounceTimeout&&clearTimeout(this.selectorDebounceTimeout),this.selectorDebounceTimeout=setTimeout(()=>{this.debouncedDataRequest()},150)},this.filterInputDebounceTimeout=null,this.handleSlottedRowSelect=e=>{const t=e.detail?.element,i=this.getSlottedSelectionRows(),a=i.indexOf(t);if(!(a<0))return!this.hasSelectionColumn()||this.selectabilityCheck&&!this.selectabilityCheck(t.data,a)?(t.selected=!1,void this.syncSlottedSelectionState()):("single"===this.selectionMode&&t.selected&&i.forEach((e,t)=>{t!==a&&(e.selected=!1)}),this.selectedRows=i.map((e,t)=>e.selected?t:-1).filter(e=>e>=0),this.selectionAnchor=t.data,this.dispatchRowSelectionChanged(a,t.selected),void this.dispatchSelectionChanged())},this.selectabilityCheck=null,this.listRenderer=k(this,Ji,null),k(this,Qi)}static{k(a,bt)}};Xi=a})(),(()=>{let a,n,c,u,p,g,b,f,v,y,x,E,D,A,R,M,z,$=[i("snice-header")],F=[],I=HTMLElement,T=[],L=[],V=[],B=[],O=[],j=[],N=[],P=[],H=[],q=[],_=[],G=[],K=[],W=[],U=[];(class extends I{static{n=this}static{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(I[Symbol.metadata]??null):void 0;c=[s({type:Boolean})],u=[s({type:Array,attribute:!1})],p=[s({type:Boolean})],g=[s({type:Boolean})],b=[s({type:Object,attribute:!1})],f=[s({type:Boolean,attribute:"all-selected"})],v=[s({type:Boolean,attribute:"some-selected"})],y=[l()],x=[r()],E=[o()],D=[d("sticky","selectable","sortable")],A=[d("allSelected","someSelected")],R=[h("header-sort",{bubbles:!0,composed:!0})],M=[h("header-select-all",{bubbles:!0,composed:!0})],z=[h("header-filter",{bubbles:!0,composed:!0})],w(this,null,y,{kind:"method",name:"render",static:!1,private:!1,access:{has:e=>"render"in e,get:e=>e.render},metadata:e},null,T),w(this,null,x,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:e},null,T),w(this,null,E,{kind:"method",name:"init",static:!1,private:!1,access:{has:e=>"init"in e,get:e=>e.init},metadata:e},null,T),w(this,null,D,{kind:"method",name:"updateHeaderAttributes",static:!1,private:!1,access:{has:e=>"updateHeaderAttributes"in e,get:e=>e.updateHeaderAttributes},metadata:e},null,T),w(this,null,A,{kind:"method",name:"updateSelectAllCheckbox",static:!1,private:!1,access:{has:e=>"updateSelectAllCheckbox"in e,get:e=>e.updateSelectAllCheckbox},metadata:e},null,T),w(this,null,R,{kind:"method",name:"dispatchSort",static:!1,private:!1,access:{has:e=>"dispatchSort"in e,get:e=>e.dispatchSort},metadata:e},null,T),w(this,null,M,{kind:"method",name:"dispatchSelectAll",static:!1,private:!1,access:{has:e=>"dispatchSelectAll"in e,get:e=>e.dispatchSelectAll},metadata:e},null,T),w(this,null,z,{kind:"method",name:"dispatchFilter",static:!1,private:!1,access:{has:e=>"dispatchFilter"in e,get:e=>e.dispatchFilter},metadata:e},null,T),w(null,null,c,{kind:"field",name:"sticky",static:!1,private:!1,access:{has:e=>"sticky"in e,get:e=>e.sticky,set:(e,t)=>{e.sticky=t}},metadata:e},L,V),w(null,null,u,{kind:"field",name:"columns",static:!1,private:!1,access:{has:e=>"columns"in e,get:e=>e.columns,set:(e,t)=>{e.columns=t}},metadata:e},B,O),w(null,null,p,{kind:"field",name:"selectable",static:!1,private:!1,access:{has:e=>"selectable"in e,get:e=>e.selectable,set:(e,t)=>{e.selectable=t}},metadata:e},j,N),w(null,null,g,{kind:"field",name:"sortable",static:!1,private:!1,access:{has:e=>"sortable"in e,get:e=>e.sortable,set:(e,t)=>{e.sortable=t}},metadata:e},P,H),w(null,null,b,{kind:"field",name:"currentSort",static:!1,private:!1,access:{has:e=>"currentSort"in e,get:e=>e.currentSort,set:(e,t)=>{e.currentSort=t}},metadata:e},q,_),w(null,null,f,{kind:"field",name:"allSelected",static:!1,private:!1,access:{has:e=>"allSelected"in e,get:e=>e.allSelected,set:(e,t)=>{e.allSelected=t}},metadata:e},G,K),w(null,null,v,{kind:"field",name:"someSelected",static:!1,private:!1,access:{has:e=>"someSelected"in e,get:e=>e.someSelected,set:(e,t)=>{e.someSelected=t}},metadata:e},W,U),w(null,a={value:n},$,{kind:"class",name:n.name,metadata:e},null,F),n=a.value,e&&Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e}),k(n,F)}render(){return e`
1668
1668
  <div class="header-container" part="container">
1669
1669
  <if ${this.selectable}>
1670
1670
  ${this.renderSelectAllCheckbox()}