@mmlogic/components 0.5.10 → 0.5.11

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.
@@ -6641,6 +6641,8 @@ const MrdTable = class {
6641
6641
  this.keydownHandler = null;
6642
6642
  this.createPickerClickHandler = null;
6643
6643
  this.viewPopoverClickHandler = null;
6644
+ /** Watches the host for gaining a box (e.g. its tab pane being shown) — see componentDidLoad. */
6645
+ this.resizeObserver = null;
6644
6646
  /** Guards against scheduling more than one column-width measurement per freeze. */
6645
6647
  this.colWidthMeasureScheduled = false;
6646
6648
  /** Drag origin of the running column resize (null = no drag in progress). */
@@ -6745,6 +6747,14 @@ const MrdTable = class {
6745
6747
  }
6746
6748
  componentDidLoad() {
6747
6749
  this.staleCheckTimer = setInterval(() => this.checkStalePages(), STALE_CHECK_INTERVAL_MS);
6750
+ // A table inside a hidden tab pane renders and loads page 0 without ever having a box, so
6751
+ // the width freeze cannot measure anything. ResizeObserver fires the moment the pane is
6752
+ // shown (the host gains a box) — that is when the freeze gets its chance. componentDidRender
6753
+ // is no help there: showing a sibling tab does not re-render this component.
6754
+ if (typeof ResizeObserver !== 'undefined') {
6755
+ this.resizeObserver = new ResizeObserver(() => this.freezeColWidths());
6756
+ this.resizeObserver.observe(this.el);
6757
+ }
6748
6758
  }
6749
6759
  // ── Helpers ────────────────────────────────────────────────────────────────
6750
6760
  applyDefaultSort(defaultSort) {
@@ -6848,6 +6858,10 @@ const MrdTable = class {
6848
6858
  }
6849
6859
  // ── Lifecycle ──────────────────────────────────────────────────────────────
6850
6860
  disconnectedCallback() {
6861
+ if (this.resizeObserver) {
6862
+ this.resizeObserver.disconnect();
6863
+ this.resizeObserver = null;
6864
+ }
6851
6865
  if (this.staleCheckTimer !== null) {
6852
6866
  clearInterval(this.staleCheckTimer);
6853
6867
  this.staleCheckTimer = null;
@@ -6870,29 +6884,35 @@ const MrdTable = class {
6870
6884
  }
6871
6885
  }
6872
6886
  componentDidRender() {
6873
- // Freeze header widths once the first data page has rendered. The measurement
6874
- // reads offsetWidth and writes the colWidths @State, which would trigger a
6875
- // re-render *during* the render cycle if done synchronously here. Defer it to a
6876
- // writeTask so the state mutation happens outside the render pass (avoids the
6877
- // Stencil "state/prop changed during rendering" warning and potential loops).
6878
- // NB: the freeze must not depend on the totalElements prop — hosts may omit it
6879
- // and rely on minKnownTotal, in which case the widths would never be locked and
6880
- // every incoming page would re-flow all columns.
6881
- if (this.colWidths.length === 0 &&
6882
- !this.colWidthMeasureScheduled &&
6883
- this.loadedPages.size > 0) {
6884
- this.colWidthMeasureScheduled = true;
6885
- index.writeTask(() => {
6886
- var _a;
6887
- this.colWidthMeasureScheduled = false;
6888
- // Re-check: state may have changed (e.g. a reset) between scheduling and running.
6889
- if (this.colWidths.length !== 0)
6890
- return;
6891
- const measured = (_a = this.measureContentWidths()) !== null && _a !== void 0 ? _a : this.measureColWidths();
6892
- if (measured)
6893
- this.colWidths = measured;
6894
- });
6895
- }
6887
+ this.freezeColWidths();
6888
+ }
6889
+ /** Freeze the column widths once the first data page has rendered.
6890
+ *
6891
+ * The measurement reads layout and writes the colWidths @State, which would trigger a
6892
+ * re-render *during* the render cycle if done synchronously from componentDidRender. It is
6893
+ * deferred to a writeTask so the state mutation happens outside the render pass (avoids the
6894
+ * Stencil "state/prop changed during rendering" warning and potential loops).
6895
+ *
6896
+ * NB: the freeze must not depend on the totalElements prop — hosts may omit it and rely on
6897
+ * minKnownTotal, in which case the widths would never be locked and every incoming page
6898
+ * would re-flow all columns. */
6899
+ freezeColWidths() {
6900
+ if (this.colWidths.length !== 0 || this.colWidthMeasureScheduled || this.loadedPages.size === 0)
6901
+ return;
6902
+ this.colWidthMeasureScheduled = true;
6903
+ index.writeTask(() => {
6904
+ var _a;
6905
+ this.colWidthMeasureScheduled = false;
6906
+ // Re-check: state may have changed (e.g. a reset) between scheduling and running.
6907
+ if (this.colWidths.length !== 0)
6908
+ return;
6909
+ const measured = (_a = this.measureContentWidths()) !== null && _a !== void 0 ? _a : this.measureColWidths();
6910
+ // A table inside a hidden tab pane (a tab page that is loaded but not shown) has no
6911
+ // layout at all, so every measurement comes back 0. Locking those would pin every
6912
+ // column at MIN_COL_WIDTH for good; wait for the ResizeObserver to report a real box.
6913
+ if (measured && measured.some(w => w > 0))
6914
+ this.colWidths = measured;
6915
+ });
6896
6916
  }
6897
6917
  // ── Column resizing (drag the header border, Excel-style) ──────────────────
6898
6918
  /** Current rendered header widths, or null when they can't be trusted (header not laid out yet). */
@@ -6930,15 +6950,20 @@ const MrdTable = class {
6930
6950
  const ths = this.el.querySelectorAll('.mrd-table__header');
6931
6951
  if (ths.length === 0 || ths.length !== this.columns.length)
6932
6952
  return null;
6933
- return Array.from(ths).map((th, idx) => {
6953
+ const needed = Array.from(ths).map((th, idx) => {
6934
6954
  let widest = this.neededWidth(th);
6935
6955
  // .mrd-table__cell only matches real data cells — the shimmer/retry rows render a single
6936
6956
  // colSpan cell (without that class) which would measure as the full table width.
6937
6957
  this.el
6938
6958
  .querySelectorAll(`.mrd-table__cell:nth-child(${idx + 1})`)
6939
6959
  .forEach(cell => { widest = Math.max(widest, this.neededWidth(cell)); });
6940
- return Math.min(Math.max(widest, MIN_COL_WIDTH), MAX_AUTOFIT_WIDTH);
6960
+ return widest;
6941
6961
  });
6962
+ // Nothing has a box: the table is in a hidden tab pane. Report "cannot measure" rather
6963
+ // than clamping a row of zeroes up to MIN_COL_WIDTH, which would look like a real result.
6964
+ if (needed.every(w => w <= 0))
6965
+ return null;
6966
+ return needed.map(w => Math.min(Math.max(w, MIN_COL_WIDTH), MAX_AUTOFIT_WIDTH));
6942
6967
  }
6943
6968
  /** Re-reads the rendered header widths into colWidths so a drag starts from what is
6944
6969
  * actually on screen — and locks the columns if they weren't locked yet.
@@ -27,6 +27,8 @@ export class MrdTable {
27
27
  this.keydownHandler = null;
28
28
  this.createPickerClickHandler = null;
29
29
  this.viewPopoverClickHandler = null;
30
+ /** Watches the host for gaining a box (e.g. its tab pane being shown) — see componentDidLoad. */
31
+ this.resizeObserver = null;
30
32
  /** Guards against scheduling more than one column-width measurement per freeze. */
31
33
  this.colWidthMeasureScheduled = false;
32
34
  /** Drag origin of the running column resize (null = no drag in progress). */
@@ -131,6 +133,14 @@ export class MrdTable {
131
133
  }
132
134
  componentDidLoad() {
133
135
  this.staleCheckTimer = setInterval(() => this.checkStalePages(), STALE_CHECK_INTERVAL_MS);
136
+ // A table inside a hidden tab pane renders and loads page 0 without ever having a box, so
137
+ // the width freeze cannot measure anything. ResizeObserver fires the moment the pane is
138
+ // shown (the host gains a box) — that is when the freeze gets its chance. componentDidRender
139
+ // is no help there: showing a sibling tab does not re-render this component.
140
+ if (typeof ResizeObserver !== 'undefined') {
141
+ this.resizeObserver = new ResizeObserver(() => this.freezeColWidths());
142
+ this.resizeObserver.observe(this.el);
143
+ }
134
144
  }
135
145
  // ── Helpers ────────────────────────────────────────────────────────────────
136
146
  applyDefaultSort(defaultSort) {
@@ -234,6 +244,10 @@ export class MrdTable {
234
244
  }
235
245
  // ── Lifecycle ──────────────────────────────────────────────────────────────
236
246
  disconnectedCallback() {
247
+ if (this.resizeObserver) {
248
+ this.resizeObserver.disconnect();
249
+ this.resizeObserver = null;
250
+ }
237
251
  if (this.staleCheckTimer !== null) {
238
252
  clearInterval(this.staleCheckTimer);
239
253
  this.staleCheckTimer = null;
@@ -256,29 +270,35 @@ export class MrdTable {
256
270
  }
257
271
  }
258
272
  componentDidRender() {
259
- // Freeze header widths once the first data page has rendered. The measurement
260
- // reads offsetWidth and writes the colWidths @State, which would trigger a
261
- // re-render *during* the render cycle if done synchronously here. Defer it to a
262
- // writeTask so the state mutation happens outside the render pass (avoids the
263
- // Stencil "state/prop changed during rendering" warning and potential loops).
264
- // NB: the freeze must not depend on the totalElements prop — hosts may omit it
265
- // and rely on minKnownTotal, in which case the widths would never be locked and
266
- // every incoming page would re-flow all columns.
267
- if (this.colWidths.length === 0 &&
268
- !this.colWidthMeasureScheduled &&
269
- this.loadedPages.size > 0) {
270
- this.colWidthMeasureScheduled = true;
271
- writeTask(() => {
272
- var _a;
273
- this.colWidthMeasureScheduled = false;
274
- // Re-check: state may have changed (e.g. a reset) between scheduling and running.
275
- if (this.colWidths.length !== 0)
276
- return;
277
- const measured = (_a = this.measureContentWidths()) !== null && _a !== void 0 ? _a : this.measureColWidths();
278
- if (measured)
279
- this.colWidths = measured;
280
- });
281
- }
273
+ this.freezeColWidths();
274
+ }
275
+ /** Freeze the column widths once the first data page has rendered.
276
+ *
277
+ * The measurement reads layout and writes the colWidths @State, which would trigger a
278
+ * re-render *during* the render cycle if done synchronously from componentDidRender. It is
279
+ * deferred to a writeTask so the state mutation happens outside the render pass (avoids the
280
+ * Stencil "state/prop changed during rendering" warning and potential loops).
281
+ *
282
+ * NB: the freeze must not depend on the totalElements prop — hosts may omit it and rely on
283
+ * minKnownTotal, in which case the widths would never be locked and every incoming page
284
+ * would re-flow all columns. */
285
+ freezeColWidths() {
286
+ if (this.colWidths.length !== 0 || this.colWidthMeasureScheduled || this.loadedPages.size === 0)
287
+ return;
288
+ this.colWidthMeasureScheduled = true;
289
+ writeTask(() => {
290
+ var _a;
291
+ this.colWidthMeasureScheduled = false;
292
+ // Re-check: state may have changed (e.g. a reset) between scheduling and running.
293
+ if (this.colWidths.length !== 0)
294
+ return;
295
+ const measured = (_a = this.measureContentWidths()) !== null && _a !== void 0 ? _a : this.measureColWidths();
296
+ // A table inside a hidden tab pane (a tab page that is loaded but not shown) has no
297
+ // layout at all, so every measurement comes back 0. Locking those would pin every
298
+ // column at MIN_COL_WIDTH for good; wait for the ResizeObserver to report a real box.
299
+ if (measured && measured.some(w => w > 0))
300
+ this.colWidths = measured;
301
+ });
282
302
  }
283
303
  // ── Column resizing (drag the header border, Excel-style) ──────────────────
284
304
  /** Current rendered header widths, or null when they can't be trusted (header not laid out yet). */
@@ -316,15 +336,20 @@ export class MrdTable {
316
336
  const ths = this.el.querySelectorAll('.mrd-table__header');
317
337
  if (ths.length === 0 || ths.length !== this.columns.length)
318
338
  return null;
319
- return Array.from(ths).map((th, idx) => {
339
+ const needed = Array.from(ths).map((th, idx) => {
320
340
  let widest = this.neededWidth(th);
321
341
  // .mrd-table__cell only matches real data cells — the shimmer/retry rows render a single
322
342
  // colSpan cell (without that class) which would measure as the full table width.
323
343
  this.el
324
344
  .querySelectorAll(`.mrd-table__cell:nth-child(${idx + 1})`)
325
345
  .forEach(cell => { widest = Math.max(widest, this.neededWidth(cell)); });
326
- return Math.min(Math.max(widest, MIN_COL_WIDTH), MAX_AUTOFIT_WIDTH);
346
+ return widest;
327
347
  });
348
+ // Nothing has a box: the table is in a hidden tab pane. Report "cannot measure" rather
349
+ // than clamping a row of zeroes up to MIN_COL_WIDTH, which would look like a real result.
350
+ if (needed.every(w => w <= 0))
351
+ return null;
352
+ return needed.map(w => Math.min(Math.max(w, MIN_COL_WIDTH), MAX_AUTOFIT_WIDTH));
328
353
  }
329
354
  /** Re-reads the rendered header widths into colWidths so a drag starts from what is
330
355
  * actually on screen — and locks the columns if they weren't locked yet.
@@ -1 +1 @@
1
- import{h as t,proxyCustomElement as r,HTMLElement as e,createEvent as l,writeTask as i,Host as a,transformTag as o}from"@stencil/core/internal/client";import{t as s}from"./i18n.js";import{a as d,b as n}from"./query-params.js";import{C as c}from"./cell-renderer.js";import{f as m,d as h,c as b}from"./format.js";const u=new Set(["TEXT","TEXTBLOCK","EMAIL","HYPERLINK"]),p=new Set(["INTEGER","DECIMAL","PERCENTAGE","CURRENCY"]),_=new Set(["DATE","DATETIME","TIME"]),v=new Set(["FILE","IMAGE"]),f=new Set(["LONGTEXT","JSON","FILE","IMAGE"]);function g(t,r){var e,l,i;const a=new URLSearchParams(t);a.delete("page"),a.delete("sort");const o=function(t){var r;const e={sum:[],avg:[],count:[]};for(const l of t){if("FIELD"!==l.type||!l.aggregate)continue;const t=l.aggregate.toLowerCase();t in e&&e[t].push(null!==(r=l.name)&&void 0!==r?r:"")}const l={};return e.sum.length&&(l.sum=e.sum),e.avg.length&&(l.avg=e.avg),e.count.length&&(l.count=e.count),Object.keys(l).length>0?l:null}(r);return(null===(e=null==o?void 0:o.sum)||void 0===e?void 0:e.length)&&a.set("sum",o.sum.join(",")),(null===(l=null==o?void 0:o.avg)||void 0===l?void 0:l.length)&&a.set("avg",o.avg.join(",")),(null===(i=null==o?void 0:o.count)||void 0===i?void 0:i.length)&&a.set("count",o.count.join(",")),a.toString()}function w(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l).toISOString().replace(/\.\d{3}Z$/,"Z")}function y(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l+1).toISOString().replace(/\.\d{3}Z$/,"Z")}const x=()=>t("span",{class:"mrd-table__filter-icon","aria-hidden":"true"},t("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},t("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}))),k=({col:r,row:e,locale:l,onDownload:i,onOpenTextblock:a,onOpenJson:o})=>{var d,n,m;const h=null!==(d=r.dataType)&&void 0!==d?d:"",b="FIELD"===r.type&&p.has(h);if("FIELD"===r.type&&("FILE"===h||"IMAGE"===h)){const a=null!==(n=r.name)&&void 0!==n?n:"",o=null==e?void 0:e[a],d=null==o?void 0:o.href,c=null==o?void 0:o.fileName;return t("td",{class:"mrd-table__cell"},d&&c?t("button",{class:"mrd-table__file-btn",title:c,onClick:t=>{t.stopPropagation(),i({href:d,fileName:c})}},t("svg",{class:"mrd-table__file-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z"})),s("download",l)):"")}if("JSON"===h){const i=null!==(m=r.name)&&void 0!==m?m:"",a=i?null==e?void 0:e[i]:void 0;if(null==a||""===a)return t("td",{class:"mrd-table__cell"});const d=c.formatJson(a,!0),n=c.formatJson(a,!1);return t("td",{class:"mrd-table__cell"},t("span",{class:"mrd-table__json-preview",innerHTML:d}),t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),o(n)},"aria-label":s("textblock_show_more",l)},"⋯"))}if("TEXTBLOCK"===h){const i=c.render(r,e,l);if(i.length<=200)return t("td",{class:"mrd-table__cell"},i);const o=i.slice(0,200)+"…";return t("td",{class:"mrd-table__cell"},o,t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),a(i)},"aria-label":s("textblock_show_more",l)},"⋯"))}const u=c.render(r,e,l);return t("td",{class:"mrd-table__cell"+(b?" mrd-table__cell--numeric":""),title:u||void 0},u)},E=({columns:r,aggregations:e,locale:l})=>e&&r.some((t=>"FIELD"===t.type&&t.aggregate))?t("tfoot",null,t("tr",{class:"mrd-table__totals-row"},r.map((r=>{var i;const a=function(t,r,e){var l,i;if("FIELD"!==t.type||!t.aggregate||!r)return"";const a=null===(l=r[t.aggregate.toLowerCase()])||void 0===l?void 0:l[null!==(i=t.name)&&void 0!==i?i:""];if(null==a)return"";const o=t.dataType;return"INTEGER"===o?m(a,e,{maximumFractionDigits:0}):"PERCENTAGE"===o?h(a,e):"CURRENCY"===o&&t.currencyCode?b(a,t.currencyCode,e):m(a,e)}(r,e,l),o="FIELD"===r.type&&p.has(null!==(i=r.dataType)&&void 0!==i?i:"");return t("td",{class:"mrd-table__totals-cell"+(o?" mrd-table__totals-cell--numeric":"")},a)})))):null,C=({text:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("p",{class:"mrd-table__modal-text"},r))),z=({html:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("pre",{class:"mrd-table__modal-json",innerHTML:r}))),M=({locale:r,filterCount:e,actions:l,views:i,activeViewIdx:a,viewPopoverOpen:o,createPickerOpen:d,createTypes:n,cb:c})=>{var m;const h=l.length>0,b=i.length>1;return t("div",{class:"mrd-table__toolbar"},t("div",{class:"mrd-table__toolbar-left"},e>0&&t("button",{class:"mrd-table__action mrd-table__action--secondary mrd-table__filter-clear",onClick:c.onClearAllFilters},t("svg",{class:"mrd-table__action-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),t("span",{class:"mrd-table__filter-clear-label"},s("table_filter_clear_all",r)," (",e,")"))),b&&t("div",{class:"mrd-table__toolbar-center"},t("div",{class:"mrd-table__view-switcher"},t("button",{class:"mrd-table__view-arrow","aria-label":"Previous view",onClick:()=>c.onViewSwitch((a-1+i.length)%i.length)},"◀"),t("div",{class:"mrd-table__view-title-wrap"},t("button",{class:"mrd-table__view-title",onClick:t=>c.onToggleViewPopover(t)},null===(m=i[a])||void 0===m?void 0:m.label),o&&t("div",{class:"mrd-table__view-popover",onClick:t=>t.stopPropagation()},i.map(((r,e)=>t("button",{key:String(e),class:"mrd-table__view-popover-item"+(e===a?" mrd-table__view-popover-item--active":""),onClick:()=>{e!==a&&c.onViewSwitch(e),c.onCloseViewPopover()}},r.label))))),t("button",{class:"mrd-table__view-arrow","aria-label":"Next view",onClick:()=>c.onViewSwitch((a+1)%i.length)},"▶"))),h&&t("div",{class:"mrd-table__toolbar-right"},l.map((r=>{var e,l;const i="create"===r.action?n:null;return(null==i?void 0:i.length)?t("div",{class:"mrd-table__create-picker-wrap",key:`action-${r.action}`},t("button",{class:`mrd-table__action mrd-table__action--${null!==(e=r.variant)&&void 0!==e?e:"secondary"}`,onClick:c.onToggleCreatePicker},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label)),d&&t("div",{class:"mrd-table__create-picker"},i.map((r=>t("button",{key:r.type,class:"mrd-table__create-picker-item",onClick:()=>c.onCreate(r.type)},r.label))))):t("button",{key:`action-${r.action}`,class:`mrd-table__action mrd-table__action--${null!==(l=r.variant)&&void 0!==l?l:"secondary"}`,disabled:r.disabled,onClick:()=>c.onAction(r.action)},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label))}))))},O=({col:r,dataType:e,openFilterCol:l,pendingFilter:i,locale:a,cb:o})=>{var d,n,c,m,h,b;const f=i;if(v.has(e))return t("p",{class:"mrd-table__filter-no-support"},s("filter_no_support",a));if("BOOLEAN"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-radio-group"},[{labelKey:"filter_all",value:null},{labelKey:"yes",value:!0},{labelKey:"no",value:!1}].map((r=>t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:!e&&f.value===r.value,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:void 0,value:r.value}))}),s(r.labelKey,a)))),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isEmpty",value:void 0}))}),s("filter_is_empty",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isNotEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isNotEmpty",value:void 0}))}),s("filter_is_not_empty",a)))}if("LIST"===e){const e=null!==(d=r.listItems)&&void 0!==d?d:[],l=null!==(n=f.values)&&void 0!==n?n:[];return t("div",{class:"mrd-table__filter-list"},t("div",{class:"mrd-table__filter-list-controls"},t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:e.map((t=>t.key))}))},s("filter_select_all",a)),t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:[]}))},s("filter_select_none",a))),e.map((r=>t("label",{class:"mrd-table__filter-checkbox-label"},t("input",{type:"checkbox",checked:l.includes(r.key),onChange:t=>o.onToggleValue(r.key,t.target.checked)}),r.label))))}if(u.has(e)||"RELATION"===e){const r=null!==(c=f.operator)&&void 0!==c?c:"startsWith",e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>o.onSetPending("operator",t.target.value)},[{val:"startsWith",labelKey:"filter_starts_with"},{val:"equals",labelKey:"filter_equals"},{val:"isEmpty",labelKey:"filter_is_empty"},{val:"isNotEmpty",labelKey:"filter_is_not_empty"}].map((e=>t("option",{value:e.val,selected:r===e.val},s(e.labelKey,a))))),!e&&t("input",{type:"text",class:"mrd-table__filter-input",value:String(null!==(m=f.value)&&void 0!==m?m:""),placeholder:s("filter_search_value",a),onInput:t=>o.onSetPending("value",t.target.value)}))}if(p.has(e)){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range"},t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("span",{class:"mrd-table__filter-range-sep"},"–"),t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"number",class:"mrd-table__filter-input",value:null!=f.value?String(f.value):"",onInput:t=>o.onSetPending("value",t.target.value)})))}if("DATETIME"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range mrd-table__filter-range--stacked"},t("label",{class:"mrd-table__filter-range-label"},s("filter_from",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("label",{class:"mrd-table__filter-range-label"},s("filter_to",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"date",class:"mrd-table__filter-input",value:String(null!==(h=f.value)&&void 0!==h?h:""),onInput:t=>o.onSetPending("value",t.target.value)})))}if(_.has(e)){const r="DATE"===e?"date":"time",i=f.operator,d="isEmpty"===i||"isNotEmpty"===i,n=!d&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!d},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===i},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===i},s("filter_is_not_empty",a))),!d&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),n?t("div",{class:"mrd-table__filter-range"},t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:r,class:"mrd-table__filter-input",value:String(null!==(b=f.value)&&void 0!==b?b:""),onInput:t=>o.onSetPending("value",t.target.value)})))}return null},S=r=>{var e;const{col:l,openFilterCol:i,popupPos:a,sortField:o,sortDir:d,locale:n,cb:c}=r,m=null!==(e=l.label)&&void 0!==e?e:i,h=o===i;return t("div",{class:"mrd-table__filter-popup",style:{top:`${a.top}px`,left:`${a.left}px`},onClick:t=>t.stopPropagation()},t("div",{class:"mrd-table__filter-popup-header"},t("span",{class:"mrd-table__filter-popup-title"},m),t("button",{class:"mrd-table__filter-close",onClick:c.onClose},"✕")),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_sorting",n)),t("div",{class:"mrd-table__filter-sort-buttons"},t("button",{class:"mrd-table__filter-sort-btn"+(h&&"asc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("asc")},"▲ ",s("filter_ascending",n)),t("button",{class:"mrd-table__filter-sort-btn"+(h&&"desc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("desc")},"▼ ",s("filter_descending",n)))),t("div",{class:"mrd-table__filter-divider"}),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_section",n)),t(O,Object.assign({},r))),t("div",{class:"mrd-table__filter-popup-footer"},t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--clear",onClick:c.onClear},s("filter_clear",n)),t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--apply",onClick:c.onApply},s("filter_apply",n))))};function T(t,r){return Math.ceil(t/r)}function j(t,r,e){return{firstPage:Math.floor(t/e),lastPage:Math.floor(r/e)}}const P=r(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdLoadPage=l(this,"mrdLoadPage",7),this.mrdPageError=l(this,"mrdPageError",7),this.mrdRowClick=l(this,"mrdRowClick",7),this.mrdAction=l(this,"mrdAction",7),this.mrdDownload=l(this,"mrdDownload",7),this.mrdLoadAggregations=l(this,"mrdLoadAggregations",7),this.pendingPages=new Set,this.debounceTimer=null,this.requestedAt=new Map,this.retryAttempts=new Map,this.staleCheckTimer=null,this.outsideClickHandler=null,this.keydownHandler=null,this.createPickerClickHandler=null,this.viewPopoverClickHandler=null,this.colWidthMeasureScheduled=!1,this.resizeOrigin=null,this.colWidthsUserSet=!1,this.paginationActivated=!1,this.item=null,this.parentId="",this.rows=[],this.locale=navigator.language,this.totalElements=0,this.pageSize=20,this.rowHeight=36,this.tableHeight=500,this.requestTimeoutMs=15e3,this.activeViewIdx=0,this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.renderStart=0,this.renderEnd=0,this.colWidths=[],this.resizingCol=null,this.sortField="",this.sortDir="asc",this.activeFilters=new Map,this.openFilterCol=null,this.pendingFilter=null,this.popupPos={top:0,left:0},this.createPickerOpen=!1,this.viewPopoverOpen=!1,this.scrollTop=0,this.textblockModal=null,this.jsonModal=null,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!1,this.minKnownTotal=0,this.handleScroll=t=>{const r=t.currentTarget,{renderStart:e,renderEnd:l}=function(t,r,e,l){const i=Math.floor(t/r),a=i+T(e,r)+10;return{renderStart:Math.max(0,i-10),renderEnd:l>0?Math.min(l-1,a):a}}(r.scrollTop,this.rowHeight,this.tableHeight,this.baseTotal);this.scrollTop=r.scrollTop,this.renderStart=e,this.renderEnd=l,this.requestPagesForWindow(this.renderStart,this.renderEnd)}}totalElementsChanged(t){t>0&&(this.renderEnd=Math.min(this.renderEnd,t-1))}itemChanged(t){var r,e;this.activeViewIdx=0,this.applyDefaultSort(null!==(e=null===(r=null==t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1}componentWillLoad(){var t,r,e;this.applyDefaultSort(null!==(e=null===(r=null===(t=this.item)||void 0===t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:"")}componentDidLoad(){this.staleCheckTimer=setInterval((()=>this.checkStalePages()),2e3)}applyDefaultSort(t){const{field:r,dir:e}=function(t){var r;if(!t)return{field:"",dir:"asc"};const e=t.split(",");return{field:e[0].trim(),dir:"desc"===(null===(r=e[1])||void 0===r?void 0:r.trim())?"desc":"asc"}}(t);this.sortField=r,this.sortDir=e}async init(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1,this.scrollTop=0,this.renderStart=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.minKnownTotal=0,this.paginationActivated=!0,this.emitLoadPage(0),this.requestedPages=new Set([0])}async setPage(t,r,e){this.paginationActivated=!0;const l=void 0!==e?!e:r.length<this.pageSize;l?(this.renderEnd=Math.min(this.renderEnd,t*this.pageSize+r.length-1),this.minKnownTotal=t*this.pageSize+r.length):this.minKnownTotal=Math.max(this.minKnownTotal,(t+1)*this.pageSize+1);const i=new Map(this.loadedPages);if(i.set(t,r),this.loadedPages=i,this.renderEnd<this.renderStart&&(this.renderEnd=Math.min(this.renderStart+this.visibleCount()-1,this.minKnownTotal-1)),this.requestedAt.delete(t),this.retryAttempts.delete(t),this.failedPages.has(t)){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r}if(0===t&&this.aggregationsPending){this.aggregationsPending=!1;const t=this.columns.some((t=>"FIELD"===t.type&&t.aggregate));l&&!t||this.emitLoadAggregations()}}async setAggregations(t){null!=t.total&&(this.aggregationsTotal=t.total),this.aggregations=t}disconnectedCallback(){null!==this.staleCheckTimer&&(clearInterval(this.staleCheckTimer),this.staleCheckTimer=null),this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null),this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null),this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}componentDidRender(){0===this.colWidths.length&&!this.colWidthMeasureScheduled&&this.loadedPages.size>0&&(this.colWidthMeasureScheduled=!0,i((()=>{var t;if(this.colWidthMeasureScheduled=!1,0!==this.colWidths.length)return;const r=null!==(t=this.measureContentWidths())&&void 0!==t?t:this.measureColWidths();r&&(this.colWidths=r)})))}measureColWidths(){const t=this.el.querySelectorAll(".mrd-table__header");return 0===t.length||t.length!==this.columns.length?null:Array.from(t).map((t=>Math.round(t.getBoundingClientRect().width)))}neededWidth(t){const r=t=>"number"==typeof t&&Number.isFinite(t)?t:0,e=r(t.clientWidth),l=r(t.scrollWidth),i=r(parseFloat(getComputedStyle(t).paddingRight||"0")),a=Math.max(0,r(t.offsetWidth)-e);return Math.ceil((l>e?l+i:e)+a)}measureContentWidths(){const t=this.el.querySelectorAll(".mrd-table__header");return 0===t.length||t.length!==this.columns.length?null:Array.from(t).map(((t,r)=>{let e=this.neededWidth(t);return this.el.querySelectorAll(`.mrd-table__cell:nth-child(${r+1})`).forEach((t=>{e=Math.max(e,this.neededWidth(t))})),Math.min(Math.max(e,48),600)}))}syncColWidths(){const t=this.measureColWidths();return t?(this.colWidths=t,!0):this.colWidths.length===this.columns.length}setColWidth(t,r){const e=[...this.colWidths];e[t]=Math.max(48,Math.round(r)),this.colWidths=e,this.colWidthsUserSet=!0}handleResizeStart(t,r){var e,l;t.preventDefault(),t.stopPropagation(),this.syncColWidths()&&(this.resizeOrigin={idx:r,startX:t.clientX,startWidth:this.colWidths[r]},this.resizingCol=r,null===(l=(e=t.currentTarget).setPointerCapture)||void 0===l||l.call(e,t.pointerId))}handleResizeMove(t){if(!this.resizeOrigin)return;const{idx:r,startX:e,startWidth:l}=this.resizeOrigin;this.setColWidth(r,l+(t.clientX-e))}handleResizeEnd(t){var r,e;this.resizeOrigin&&(this.resizeOrigin=null,this.resizingCol=null,null===(e=(r=t.currentTarget).releasePointerCapture)||void 0===e||e.call(r,t.pointerId))}handleResizeAutoFit(t,r){if(t.preventDefault(),t.stopPropagation(),!this.syncColWidths())return;const e=this.el.querySelectorAll(`.mrd-table__header:nth-child(${r+1}), .mrd-table__cell:nth-child(${r+1})`);let l=0;e.forEach((t=>{l=Math.max(l,this.neededWidth(t))})),l>0&&this.setColWidth(r,Math.min(l,600))}lockedTableStyle(){if(0===this.colWidths.length)return;const t=this.colWidths.reduce(((t,r)=>t+(r||0)),0);return Object.assign({tableLayout:"fixed",width:`${t}px`},this.colWidthsUserSet?{}:{minWidth:"100%"})}renderColResizer(r){return t("span",{class:"mrd-table__col-resizer"+(this.resizingCol===r?" mrd-table__col-resizer--active":""),role:"separator","aria-orientation":"vertical",title:s("column_resize",this.locale),"on-pointerdown":t=>this.handleResizeStart(t,r),"on-pointermove":t=>this.handleResizeMove(t),"on-pointerup":t=>this.handleResizeEnd(t),"on-pointercancel":t=>this.handleResizeEnd(t),"on-dblclick":t=>this.handleResizeAutoFit(t,r),onClick:t=>t.stopPropagation()})}visibleCount(){return T(this.tableHeight,this.rowHeight)}sortParam(){return(t=this.sortField)?"desc"===this.sortDir?`${t},desc`:t:"";var t}get allViews(){var t,r,e,l,i,a,o;if(!this.item)return[];const s=this.item;return[{label:null!==(i=null!==(l=null!==(e=null!==(t=s.label)&&void 0!==t?t:null===(r=s.view)||void 0===r?void 0:r.pluralLabel)&&void 0!==e?e:s.dataClass)&&void 0!==l?l:s.relatedClass)&&void 0!==i?i:"",dataClass:null!==(a=s.dataClass)&&void 0!==a?a:s.relatedClass,fromClass:s.fromClass,filterClass:s.filterClass,view:s.view},...(null!==(o=s.alternativeViews)&&void 0!==o?o:[]).map((t=>{var r,e,l,i;return{label:null!==(i=null!==(l=null!==(r=t.label)&&void 0!==r?r:null===(e=t.view)||void 0===e?void 0:e.pluralLabel)&&void 0!==l?l:t.dataClass)&&void 0!==i?i:"",dataClass:t.dataClass,fromClass:t.fromClass,filterClass:t.filterClass,view:t.view}}))]}buildExcelPath(){var t;const r=this.allViews[this.activeViewIdx];return r?"/excel"+n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildActionDetail(t,r){var e,l,i;if("export"===t)return{action:t,path:this.buildExcelPath(),qs:this.buildQueryParams(0)};if("create"===t){const a=this.allViews[this.activeViewIdx],o="RELATED_VIEW"===(null===(e=this.item)||void 0===e?void 0:e.type)?`/${null!==(l=null==a?void 0:a.fromClass)&&void 0!==l?l:""}/${this.parentId}`:null;return Object.assign({action:t,dataClass:null!==(i=null==a?void 0:a.dataClass)&&void 0!==i?i:"",parentPath:o},r?{basicType:r}:{})}return{action:t}}buildDataPath(){var t;const r=this.allViews[this.activeViewIdx];return r?n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildQueryParams(t){var r;const e=this.allViews[this.activeViewIdx];return function(t){var r,e;const l=new URLSearchParams;t.page>0&&l.set("page",String(t.page)),t.sort&&l.set("sort",t.sort),t.filterClass&&l.set("type",t.filterClass),d(l,t.viewFilters);for(const i of t.activeFilters)"isEmpty"!==i.operator?"isNotEmpty"!==i.operator?"startsWith"!==i.operator?(null===(e=i.values)||void 0===e?void 0:e.length)?l.set(i.field,i.values.join(",")):(null!=i.value&&l.set(i.field,String(i.value)),null!=i.from&&l.set(i.field+"_from",String(i.from)),null!=i.to&&l.set(i.field+"_to",String(i.to))):l.set(i.field+"_startswith",String(null!==(r=i.value)&&void 0!==r?r:"")):l.set(i.field+"_notempty","true"):l.set(i.field,"");return l.toString()}({page:t,sort:this.sortParam(),filterClass:null==e?void 0:e.filterClass,viewFilters:null===(r=null==e?void 0:e.view)||void 0===r?void 0:r.filter,activeFilters:this.activeFilters.values()})}get isPaginated(){return this.totalElements>0||this.paginationActivated}get columns(){var t,r,e;return null!==(e=null===(r=null===(t=this.allViews[this.activeViewIdx])||void 0===t?void 0:t.view)||void 0===r?void 0:r.values)&&void 0!==e?e:[]}get tableActions(){var t,r;const e=null!==(r=null===(t=this.item)||void 0===t?void 0:t.actions)&&void 0!==r?r:[];return(null!=e?e:[]).reduce(((t,r)=>("NEW"===r&&t.push({action:"create",label:s("table_new_record",this.locale),icon:"assets/sprites.svg#icon-plus",variant:"primary"}),"EXPORT"===r&&t.push({action:"export",label:s("table_export_excel",this.locale),icon:"assets/sprites.svg#icon-file-excel"}),t)),[])}toggleCreatePicker(){this.createPickerOpen?this.closeCreatePicker():(this.createPickerOpen=!0,this.createPickerClickHandler&&document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=t=>{const r=this.el.querySelector(".mrd-table__create-picker-wrap");r&&!r.contains(t.target)&&this.closeCreatePicker()},document.addEventListener("click",this.createPickerClickHandler))}closeCreatePicker(){this.createPickerOpen=!1,this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null)}colName(t){var r;return null!==(r=t.name)&&void 0!==r?r:""}colDataType(t){var r;return"RELATION"===t.type?"RELATION":null!==(r=t.dataType)&&void 0!==r?r:"TEXT"}isTotalKnown(){return null!=this.aggregationsTotal||function(t,r){for(const e of t.values())if(e.length<r)return!0;return!1}(this.loadedPages,this.pageSize)}get baseTotal(){return null!=this.aggregationsTotal?this.aggregationsTotal:this.totalElements>0?this.totalElements:this.minKnownTotal}emitLoadAggregations(){const t=this.buildQueryParams(0);this.mrdLoadAggregations.emit({path:this.buildDataPath(),qs:t,aggQs:g(t,this.columns)})}resetPages(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidthsUserSet||(this.colWidths=[],this.colWidthMeasureScheduled=!1),this.scrollTop=0,this.renderStart=0,this.minKnownTotal=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0)}applySort(t,r){this.sortField=this.colName(t),this.sortDir=r,this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd)}emitLoadPage(t){this.mrdLoadPage.emit({page:t,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(t)}),this.requestedAt.set(t,Date.now())}emitPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize),i=new Set(this.requestedPages);let a=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||i.has(t)||(i.add(t),this.emitLoadPage(t),a=!0);a&&(this.requestedPages=i)}getRow(t){return function(t,r,e){var l;const i=t.get(Math.floor(r/e));return null!==(l=null==i?void 0:i[r%e])&&void 0!==l?l:null}(this.loadedPages,t,this.pageSize)}requestPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize);let i=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||this.requestedPages.has(t)||this.pendingPages.has(t)||(this.pendingPages.add(t),i=!0);i&&(null!==this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>this.flushPendingPages()),150))}flushPendingPages(){if(this.debounceTimer=null,0===this.pendingPages.size)return;const t=new Set(this.requestedPages);let r=!1;for(const e of this.pendingPages){if(this.loadedPages.has(e)||t.has(e))continue;const l=e*this.pageSize;l+this.pageSize-1<this.renderStart||l>this.renderEnd||(t.add(e),this.emitLoadPage(e),r=!0)}this.pendingPages.clear(),r&&(this.requestedPages=t)}checkStalePages(){var t;if(0===this.requestedAt.size)return;const r=function(t,r,e){const l=[];for(const[i,a]of t)r-a>=e&&l.push(i);return l}(this.requestedAt,Date.now(),this.requestTimeoutMs).filter((t=>!this.loadedPages.has(t)));if(0===r.length)return;let e=null;for(const l of r){const r=null!==(t=this.retryAttempts.get(l))&&void 0!==t?t:0;r<3?(this.retryAttempts.set(l,r+1),this.emitLoadPage(l)):(this.requestedAt.delete(l),this.retryAttempts.delete(l),e||(e=new Set(this.failedPages)),e.add(l),this.mrdPageError.emit({page:l}))}e&&(this.failedPages=e)}retryPage(t){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r,this.retryAttempts.delete(t),this.emitLoadPage(t);const e=new Set(this.requestedPages);e.add(t),this.requestedPages=e}handleFilterOpen(t,r){r.stopPropagation();const e=r.currentTarget.getBoundingClientRect();let l=e.left;l+280>window.innerWidth-8&&(l=e.right-280),this.popupPos={top:e.bottom+4,left:Math.max(8,l)};const i=this.colName(t),a=this.colDataType(t),o=this.activeFilters.get(i),s=u.has(a)||"RELATION"===a?"startsWith":void 0;this.pendingFilter="DATETIME"===a&&o&&"isEmpty"!==o.operator&&"isNotEmpty"!==o.operator?function(t){const r=Object.assign({},t);return"string"==typeof r.from&&r.from&&(r.from=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}(r.from)),"string"==typeof r.to&&r.to&&(r.to=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:(r.setDate(r.getDate()-1),`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`)}(r.to)),r.from&&r.to&&r.from===r.to?Object.assign(Object.assign({},r),{value:r.from,from:void 0,to:void 0}):r}(o):o?Object.assign({},o):{field:i,dataType:a,operator:s},this.openFilterCol=i,this.outsideClickHandler&&document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=t=>{const r=this.el.querySelector(".mrd-table__filter-popup");r&&!r.contains(t.target)&&this.closeFilterPopup()},document.addEventListener("click",this.outsideClickHandler)}closeFilterPopup(){this.openFilterCol=null,this.pendingFilter=null,this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}openTextblockModal(t){this.textblockModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeTextblockModal()},document.addEventListener("keydown",this.keydownHandler)}closeTextblockModal(){this.textblockModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}openJsonModal(t){this.jsonModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeJsonModal()},document.addEventListener("keydown",this.keydownHandler)}closeJsonModal(){this.jsonModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}setPending(t,r){this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{[t]:r})}togglePendingValue(t,r){var e,l;const i=null!==(l=null===(e=this.pendingFilter)||void 0===e?void 0:e.values)&&void 0!==l?l:[];this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{values:r?[...i,t]:i.filter((r=>r!==t))})}applyFilter(){const t=this.pendingFilter;if(!(null==t?void 0:t.field))return void this.closeFilterPopup();const r=function(t){const r=Object.assign({},t);return"DATETIME"===t.dataType&&"isEmpty"!==t.operator&&"isNotEmpty"!==t.operator&&("string"==typeof r.value&&r.value?(r.from=w(r.value),r.to=y(r.value),r.value=void 0):("string"==typeof r.from&&r.from&&(r.from=w(r.from)),"string"==typeof r.to&&r.to&&(r.to=y(r.to)))),r}(t),e=new Map(this.activeFilters);!function(t){return"isEmpty"===t.operator||"isNotEmpty"===t.operator||void 0!==t.values&&t.values.length>0||null!=t.value&&""!==t.value||"boolean"==typeof t.value||null!=t.from&&""!==t.from||null!=t.to&&""!==t.to}(r)?e.delete(r.field):e.set(r.field,r),this.activeFilters=e,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearFilter(){const t=this.openFilterCol,r=new Map(this.activeFilters);t&&r.delete(t),this.activeFilters=r,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearAllFilters(){this.activeFilters=new Map,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}handleViewSwitch(t){var r,e;const l=this.allViews[t];(null==l?void 0:l.view)&&(this.activeViewIdx=t,this.applyDefaultSort(null!==(e=null===(r=l.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.activeFilters=new Map,this.init())}toggleViewPopover(t){t.stopPropagation(),this.viewPopoverOpen?this.closeViewPopover():(this.viewPopoverOpen=!0,this.viewPopoverClickHandler=()=>this.closeViewPopover(),document.addEventListener("click",this.viewPopoverClickHandler))}closeViewPopover(){this.viewPopoverOpen=!1,this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}renderToolbar(){var r;return t(M,{locale:this.locale,filterCount:this.activeFilters.size,actions:this.tableActions,views:this.allViews,activeViewIdx:this.activeViewIdx,viewPopoverOpen:this.viewPopoverOpen,createPickerOpen:this.createPickerOpen,createTypes:null===(r=this.item)||void 0===r?void 0:r.createTypes,cb:{onClearAllFilters:()=>this.clearAllFilters(),onViewSwitch:t=>this.handleViewSwitch(t),onToggleViewPopover:t=>this.toggleViewPopover(t),onCloseViewPopover:()=>this.closeViewPopover(),onToggleCreatePicker:()=>this.toggleCreatePicker(),onCreate:t=>{this.mrdAction.emit(this.buildActionDetail("create",t)),this.closeCreatePicker()},onAction:t=>this.mrdAction.emit(this.buildActionDetail(t))}})}renderFilterPopup(){if(!this.openFilterCol||!this.pendingFilter)return null;const r=this.columns.find((t=>this.colName(t)===this.openFilterCol));return r?t(S,{col:r,dataType:this.colDataType(r),openFilterCol:this.openFilterCol,pendingFilter:this.pendingFilter,popupPos:this.popupPos,sortField:this.sortField,sortDir:this.sortDir,locale:this.locale,cb:{onSetPending:(t,r)=>this.setPending(t,r),onReplacePending:t=>this.pendingFilter=t,onToggleValue:(t,r)=>this.togglePendingValue(t,r),onApplySort:t=>this.applySort(r,t),onApply:()=>this.applyFilter(),onClear:()=>this.clearFilter(),onClose:()=>this.closeFilterPopup()}}):null}renderFooter(r,e,l=!0){if(!this.isPaginated){const e=null!=r?r:0;return 0===e?null:t("div",{class:"mrd-table__footer"},e," ",s("table_of",this.locale)," ",e)}if(!this.loadedPages.has(0))return null;const i=null!=e?e:this.baseTotal,a=Math.min(Math.floor(this.scrollTop/this.rowHeight)+1,i),o=Math.min(Math.ceil((this.scrollTop+this.tableHeight)/this.rowHeight),i),d=l?String(i):"…";return t("div",{class:"mrd-table__footer"},a,"–",o," ",s("table_of",this.locale)," ",d)}renderCell(r,e){return t(k,{col:r,row:e,locale:this.locale,onDownload:t=>this.mrdDownload.emit(t),onOpenTextblock:t=>this.openTextblockModal(t),onOpenJson:t=>this.openJsonModal(t)})}renderTotalsRow(){return t(E,{columns:this.columns,aggregations:this.aggregations,locale:this.locale})}render(){var r,e,l;if(!(null===(r=this.columns)||void 0===r?void 0:r.length))return null;if(!this.isPaginated)return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table"},t("table",{class:"mrd-table__table",style:this.lockedTableStyle()},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.activeFilters.has(i),o=!f.has(this.colDataType(r)),s=["mrd-table__header",a?"mrd-table__header--filtered":"",o?"mrd-table__header--sortable":""].filter(Boolean).join(" ");return t("th",{class:s,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:o?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),a&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,null===(e=this.rows)||void 0===e?void 0:e.map(((r,e)=>t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:e%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:r})},this.columns.map((t=>this.renderCell(t,r))))))),this.renderTotalsRow()),(!this.rows||0===this.rows.length)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale))),this.renderFooter(null===(l=this.rows)||void 0===l?void 0:l.length),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal());const i=function(t,r,e){let l=e;for(const[e,i]of t)i.length<r&&(l=Math.min(l,e*r+i.length));return l}(this.loadedPages,this.pageSize,this.baseTotal),o=Math.min(this.renderEnd,i-1),d=this.columns.length,n=this.renderStart*this.rowHeight,c=Math.max(0,(i-1-o)*this.rowHeight),m=this.lockedTableStyle(),h=[];for(let r=this.renderStart;r<=o;r++){const e=this.getRow(r);if(null===e){const e=Math.floor(r/this.pageSize);this.failedPages.has(e)?h.push(t("tr",{class:"mrd-table__row mrd-table__row--failed"},t("td",{class:"mrd-table__cell--failed",colSpan:d},t("button",{type:"button",class:"mrd-table__retry-button",onClick:()=>this.retryPage(e)},s("load_failed_retry",this.locale))))):h.push(t("tr",{class:"mrd-table__row mrd-table__row--loading"},t("td",{class:"mrd-table__cell--placeholder",colSpan:d},t("span",{class:"mrd-table__placeholder-bar"}))))}else h.push(t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:r%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:e,listContext:{index:r,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(0)}})},this.columns.map((t=>this.renderCell(t,e)))))}return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table__scroll",style:{height:`${this.tableHeight}px`},onScroll:this.handleScroll},t("table",{class:"mrd-table__table",style:m},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.sortField===i,o=this.activeFilters.has(i),s=!f.has(this.colDataType(r)),d=["mrd-table__header",s?"mrd-table__header--sortable":"",a?`mrd-table__header--sorted-${this.sortDir}`:"",o?"mrd-table__header--filtered":""].filter(Boolean).join(" ");return t("th",{class:d,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:s?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),s&&a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"asc"===this.sortDir?"▲":"▼"),s&&!a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"⇅"),s&&o&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,n>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${n}px`}},t("td",{colSpan:d})),h,c>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${c}px`}},t("td",{colSpan:d}))),this.renderTotalsRow())),0===i&&this.loadedPages.has(0)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale)),i>0&&this.renderFooter(void 0,i,this.isTotalKnown()),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal())}renderTextblockModal(){return t(C,{text:this.textblockModal,locale:this.locale,onClose:()=>this.closeTextblockModal()})}renderJsonModal(){return t(z,{html:this.jsonModal,locale:this.locale,onClose:()=>this.closeJsonModal()})}get el(){return this}static get watchers(){return{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}}static get style(){return'.sc-mrd-table-h{display:block;width:100%}.mrd-table.sc-mrd-table{overflow-x:auto}.mrd-table__scroll.sc-mrd-table{overflow-y:auto;overflow-x:auto;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow-anchor:none}.mrd-table__table.sc-mrd-table{width:auto;min-width:100%;border-collapse:collapse;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900)}.mrd-table__scroll.sc-mrd-table .mrd-table__table.sc-mrd-table{min-width:max-content}.mrd-table__header.sc-mrd-table{position:sticky;top:0;z-index:1;background:var(--mrd-color-white);text-align:left;padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:2px solid var(--mrd-border-color);color:var(--mrd-color-neutral-600);font-weight:var(--mrd-font-weight-medium);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:var(--mrd-font-size-xs);text-transform:uppercase;letter-spacing:0.04em}.mrd-table__header--sortable.sc-mrd-table{cursor:pointer;user-select:none}.mrd-table__header--sortable.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-800)}.mrd-table__header--sorted-asc.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header--filtered.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header-label.sc-mrd-table{margin-right:var(--mrd-space-1)}.mrd-table__col-resizer.sc-mrd-table{position:absolute;top:0;right:0;width:9px;height:100%;cursor:col-resize;touch-action:none;user-select:none}.mrd-table__col-resizer.sc-mrd-table::after{content:"";position:absolute;top:25%;right:4px;width:1px;height:50%;background:var(--mrd-border-color)}.mrd-table__col-resizer.sc-mrd-table:hover::after{width:2px;right:3px;background:var(--mrd-color-primary)}.mrd-table__col-resizer--active.sc-mrd-table::after{width:2px;right:3px;height:100%;top:0;background:var(--mrd-color-primary)}.mrd-table--resizing.sc-mrd-table{cursor:col-resize;user-select:none}.mrd-table__sort-icon.sc-mrd-table{font-size:0.85rem;opacity:0.4;vertical-align:middle}.mrd-table__header--sorted-asc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table{opacity:1;color:var(--mrd-color-primary)}.mrd-table__filter-icon.sc-mrd-table{display:inline-flex;align-items:center;vertical-align:middle;margin-left:var(--mrd-space-1);color:var(--mrd-color-primary)}.mrd-table__row.sc-mrd-table{border-bottom:1px solid var(--mrd-border-color)}.mrd-table__row.sc-mrd-table:hover{background:var(--mrd-color-neutral-200) !important}.mrd-table__row--clickable.sc-mrd-table{cursor:pointer}.mrd-table__row--loading.sc-mrd-table{background:transparent}.mrd-table__row--failed.sc-mrd-table{background:transparent}.mrd-table__spacer.sc-mrd-table{border:none}.mrd-table__spacer.sc-mrd-table td.sc-mrd-table{padding:0;border:none}.mrd-table__cell.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);vertical-align:top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__cell--numeric.sc-mrd-table{text-align:right;font-variant-numeric:tabular-nums}.mrd-table__cell--placeholder.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__cell--failed.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__placeholder-bar.sc-mrd-table{display:block;height:0.75rem;width:55%;border-radius:var(--mrd-border-radius-sm);background:linear-gradient(90deg, var(--mrd-color-neutral-200) 25%, var(--mrd-color-neutral-100) 50%, var(--mrd-color-neutral-200) 75%);background-size:200% 100%;animation:mrd-shimmer 1.4s ease infinite}.mrd-table__retry-button.sc-mrd-table{border:none;background:none;padding:0;color:var(--mrd-color-danger);font-size:inherit;cursor:pointer;text-decoration:underline}.mrd-table__toolbar.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--mrd-space-2)}.mrd-table__toolbar-left.sc-mrd-table,.mrd-table__toolbar-right.sc-mrd-table{display:flex;gap:var(--mrd-space-2);align-items:center}.mrd-table__toolbar-center.sc-mrd-table{flex:1;display:flex;justify-content:center;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-switcher.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-arrow.sc-mrd-table{background:none;border:none;cursor:pointer;padding:0 var(--mrd-space-1);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-xs);line-height:1}.mrd-table__view-arrow.sc-mrd-table:hover{color:var(--mrd-color-neutral-800)}.mrd-table__view-title-wrap.sc-mrd-table{position:relative}.mrd-table__view-title.sc-mrd-table{font-size:var(--mrd-font-size-sm);font-weight:600;color:var(--mrd-color-neutral-800);font-family:var(--mrd-font-family);background:none;border:none;outline:none;cursor:pointer;padding:0 var(--mrd-space-1);max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__view-title.sc-mrd-table:hover{color:var(--mrd-color-primary)}.mrd-table__view-popover.sc-mrd-table{position:absolute;top:calc(100% + var(--mrd-space-1));left:50%;transform:translateX(-50%);background:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-radius-md);box-shadow:var(--mrd-shadow-md);z-index:100;min-width:160px;padding:var(--mrd-space-1) 0}.mrd-table__view-popover-item.sc-mrd-table{display:block;width:100%;text-align:left;background:none;border:none;cursor:pointer;padding:var(--mrd-space-2) var(--mrd-space-3);font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-700);white-space:nowrap}.mrd-table__view-popover-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50)}.mrd-table__view-popover-item--active.sc-mrd-table{font-weight:600;color:var(--mrd-color-primary)}.mrd-table__action.sc-mrd-table{position:relative;display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;background:transparent;border:1px solid transparent;border-radius:var(--mrd-border-radius);cursor:pointer;color:var(--mrd-color-neutral-400);transition:background-color 0.15s, border-color 0.15s, color 0.15s}.mrd-table__action.sc-mrd-table:hover{background-color:var(--mrd-color-neutral-100);border-color:var(--mrd-color-neutral-300);color:var(--mrd-color-neutral-700)}.mrd-table__action.sc-mrd-table:hover .mrd-table__action-tooltip.sc-mrd-table{display:block}.mrd-table__action.sc-mrd-table:disabled{opacity:0.4;cursor:not-allowed}.mrd-table__action--primary.sc-mrd-table{color:var(--mrd-color-neutral-500)}.mrd-table__action--primary.sc-mrd-table:hover{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__action--danger.sc-mrd-table{color:var(--mrd-color-error)}.mrd-table__action--danger.sc-mrd-table:hover{background-color:var(--mrd-color-error-light, #fef2f2);border-color:var(--mrd-color-error)}.mrd-table__action-icon.sc-mrd-table{width:1.25rem;height:1.25rem;pointer-events:none;fill:currentColor}.mrd-table__action-tooltip.sc-mrd-table{display:none;position:absolute;bottom:calc(100% + 6px);right:0;padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);white-space:nowrap;background:var(--mrd-color-tooltip, #fffce1);color:var(--mrd-color-neutral-900);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-sm, var(--mrd-border-radius));pointer-events:none;z-index:10}.mrd-table__create-picker-wrap.sc-mrd-table{position:relative}.mrd-table__create-picker.sc-mrd-table{position:absolute;right:0;top:calc(100% + 4px);background:var(--mrd-color-white, #fff);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:10;min-width:10rem;padding:var(--mrd-space-1) 0}.mrd-table__create-picker-item.sc-mrd-table{display:block;width:100%;text-align:left;padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-800)}.mrd-table__create-picker-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-900)}.mrd-table__filter-clear.sc-mrd-table{width:auto;gap:var(--mrd-space-1);padding:0 var(--mrd-space-2);color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear.sc-mrd-table:hover{color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear-label.sc-mrd-table{font-size:var(--mrd-font-size-sm);white-space:nowrap}.mrd-table__filter-popup.sc-mrd-table{position:fixed;width:280px;background:var(--mrd-color-white);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:var(--mrd-z-dropdown, 200);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-popup-header.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__filter-popup-title.sc-mrd-table{font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-close.sc-mrd-table{background:transparent;border:none;cursor:pointer;color:var(--mrd-color-neutral-500);font-size:0.9rem;padding:2px 4px;border-radius:3px;line-height:1}.mrd-table__filter-close.sc-mrd-table:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-800)}.mrd-table__filter-section.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-3)}.mrd-table__filter-section-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);text-transform:uppercase;letter-spacing:0.04em;color:var(--mrd-color-neutral-500);margin-bottom:var(--mrd-space-2)}.mrd-table__filter-sort-buttons.sc-mrd-table{display:flex;gap:var(--mrd-space-2)}.mrd-table__filter-sort-btn.sc-mrd-table{flex:1;padding:var(--mrd-space-1) var(--mrd-space-2);background:transparent;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);cursor:pointer;font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-700)}.mrd-table__filter-sort-btn.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-sort-btn--active.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-divider.sc-mrd-table{height:1px;background:var(--mrd-border-color);margin:0}.mrd-table__filter-editor.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-2)}.mrd-table__filter-select.sc-mrd-table,.mrd-table__filter-input.sc-mrd-table{width:100%;padding:var(--mrd-space-1) var(--mrd-space-2);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900);background:var(--mrd-color-white);box-sizing:border-box}.mrd-table__filter-select.sc-mrd-table:focus,.mrd-table__filter-input.sc-mrd-table:focus{outline:none;border-color:var(--mrd-color-primary);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.06)}.mrd-table__filter-range.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__filter-range.sc-mrd-table .mrd-table__filter-input.sc-mrd-table{flex:1;min-width:0}.mrd-table__filter-range--stacked.sc-mrd-table{flex-direction:column;align-items:stretch;gap:var(--mrd-space-2)}.mrd-table__filter-range-sep.sc-mrd-table{color:var(--mrd-color-neutral-400);flex-shrink:0}.mrd-table__filter-range-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);margin-bottom:2px}.mrd-table__filter-radio-group.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-table__filter-radio-group--inline.sc-mrd-table{flex-direction:row;gap:var(--mrd-space-3)}.mrd-table__filter-radio-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-list.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1);max-height:180px;overflow-y:auto}.mrd-table__filter-list-controls.sc-mrd-table{display:flex;gap:var(--mrd-space-2);margin-bottom:var(--mrd-space-1)}.mrd-table__filter-list-btn.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-primary);background:transparent;border:none;cursor:pointer;padding:0;text-decoration:underline}.mrd-table__filter-checkbox-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-no-support.sc-mrd-table{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-500);margin:0;font-style:italic}.mrd-table__filter-popup-footer.sc-mrd-table{display:flex;justify-content:flex-end;gap:var(--mrd-space-2);padding:var(--mrd-space-2) var(--mrd-space-3);border-top:1px solid var(--mrd-border-color)}.mrd-table__filter-btn.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-3);border-radius:var(--mrd-border-radius);border:1px solid var(--mrd-border-color);font-size:var(--mrd-font-size-sm);cursor:pointer}.mrd-table__filter-btn--clear.sc-mrd-table{background:transparent;color:var(--mrd-color-neutral-600)}.mrd-table__filter-btn--clear.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-btn--apply.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-btn--apply.sc-mrd-table:hover{background:var(--mrd-color-primary-dark, var(--mrd-color-primary));border-color:var(--mrd-color-primary-dark, var(--mrd-color-primary))}.mrd-table__totals-row.sc-mrd-table{border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell.sc-mrd-table{position:sticky;bottom:0;z-index:2;padding:var(--mrd-space-2) var(--mrd-space-4);background:var(--mrd-color-white);font-weight:var(--mrd-font-weight-medium);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell--numeric.sc-mrd-table{text-align:right}.mrd-table__footer.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);text-align:right}.mrd-table__empty.sc-mrd-table{padding:var(--mrd-space-4) var(--mrd-space-3);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-sm);text-align:center;margin:0}.mrd-table__file-btn.sc-mrd-table{display:inline-flex;align-items:center;gap:var(--mrd-space-1);background:none;border:none;padding:0;cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;max-width:100%;overflow:hidden}.mrd-table__file-btn.sc-mrd-table:hover{text-decoration:underline;color:var(--mrd-color-primary-dark)}.mrd-table__file-icon.sc-mrd-table{flex-shrink:0;width:1rem;height:1rem}.mrd-table__textblock-btn.sc-mrd-table{display:inline;background:none;border:none;padding:0 0 0 var(--mrd-space-1);cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;line-height:inherit;vertical-align:middle}.mrd-table__textblock-btn.sc-mrd-table:hover{color:var(--mrd-color-primary-dark)}.mrd-table__modal-backdrop.sc-mrd-table{position:fixed;inset:0;background:rgba(0, 0, 0, 0.4);z-index:var(--mrd-z-modal, 300);display:flex;align-items:center;justify-content:center}.mrd-table__modal.sc-mrd-table{background:#fff;border-radius:var(--mrd-radius-md, 0.5rem);padding:var(--mrd-space-6);max-width:min(600px, 90vw);max-height:70vh;overflow-y:auto;position:relative;box-shadow:var(--mrd-shadow-lg)}.mrd-table__modal-close.sc-mrd-table{position:absolute;top:var(--mrd-space-3);right:var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1;color:var(--mrd-color-text-muted, #6b7280);padding:0}.mrd-table__modal-close.sc-mrd-table:hover{color:var(--mrd-color-text, #111827)}.mrd-table__modal-text.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);white-space:pre-wrap;word-break:break-word;font-size:var(--mrd-font-size-sm);line-height:1.6}.mrd-table__json-preview.sc-mrd-table{font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:inline-block;max-width:calc(100% - 1.5rem);vertical-align:middle}.mrd-table__modal-json.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);white-space:pre-wrap;word-break:break-word;line-height:1.6;background:none;border:none}@keyframes mrd-shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}'}},[2,"mrd-table",{item:[16],parentId:[1,"parent-id"],rows:[16],locale:[1],totalElements:[2,"total-elements"],pageSize:[2,"page-size"],rowHeight:[2,"row-height"],tableHeight:[2,"table-height"],requestTimeoutMs:[2,"request-timeout-ms"],activeViewIdx:[32],loadedPages:[32],requestedPages:[32],failedPages:[32],renderStart:[32],renderEnd:[32],colWidths:[32],resizingCol:[32],sortField:[32],sortDir:[32],activeFilters:[32],openFilterCol:[32],pendingFilter:[32],popupPos:[32],createPickerOpen:[32],viewPopoverOpen:[32],scrollTop:[32],textblockModal:[32],jsonModal:[32],aggregations:[32],aggregationsTotal:[32],minKnownTotal:[32],init:[64],setPage:[64],setAggregations:[64]},void 0,{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}]);function I(){"undefined"!=typeof customElements&&["mrd-table"].forEach((t=>{"mrd-table"===t&&(customElements.get(o(t))||customElements.define(o(t),P))}))}export{P as M,I as d}
1
+ import{h as t,proxyCustomElement as r,HTMLElement as e,createEvent as l,writeTask as i,Host as a,transformTag as o}from"@stencil/core/internal/client";import{t as s}from"./i18n.js";import{a as d,b as n}from"./query-params.js";import{C as c}from"./cell-renderer.js";import{f as m,d as h,c as b}from"./format.js";const u=new Set(["TEXT","TEXTBLOCK","EMAIL","HYPERLINK"]),p=new Set(["INTEGER","DECIMAL","PERCENTAGE","CURRENCY"]),_=new Set(["DATE","DATETIME","TIME"]),v=new Set(["FILE","IMAGE"]),f=new Set(["LONGTEXT","JSON","FILE","IMAGE"]);function g(t,r){var e,l,i;const a=new URLSearchParams(t);a.delete("page"),a.delete("sort");const o=function(t){var r;const e={sum:[],avg:[],count:[]};for(const l of t){if("FIELD"!==l.type||!l.aggregate)continue;const t=l.aggregate.toLowerCase();t in e&&e[t].push(null!==(r=l.name)&&void 0!==r?r:"")}const l={};return e.sum.length&&(l.sum=e.sum),e.avg.length&&(l.avg=e.avg),e.count.length&&(l.count=e.count),Object.keys(l).length>0?l:null}(r);return(null===(e=null==o?void 0:o.sum)||void 0===e?void 0:e.length)&&a.set("sum",o.sum.join(",")),(null===(l=null==o?void 0:o.avg)||void 0===l?void 0:l.length)&&a.set("avg",o.avg.join(",")),(null===(i=null==o?void 0:o.count)||void 0===i?void 0:i.length)&&a.set("count",o.count.join(",")),a.toString()}function w(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l).toISOString().replace(/\.\d{3}Z$/,"Z")}function y(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l+1).toISOString().replace(/\.\d{3}Z$/,"Z")}const x=()=>t("span",{class:"mrd-table__filter-icon","aria-hidden":"true"},t("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},t("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}))),k=({col:r,row:e,locale:l,onDownload:i,onOpenTextblock:a,onOpenJson:o})=>{var d,n,m;const h=null!==(d=r.dataType)&&void 0!==d?d:"",b="FIELD"===r.type&&p.has(h);if("FIELD"===r.type&&("FILE"===h||"IMAGE"===h)){const a=null!==(n=r.name)&&void 0!==n?n:"",o=null==e?void 0:e[a],d=null==o?void 0:o.href,c=null==o?void 0:o.fileName;return t("td",{class:"mrd-table__cell"},d&&c?t("button",{class:"mrd-table__file-btn",title:c,onClick:t=>{t.stopPropagation(),i({href:d,fileName:c})}},t("svg",{class:"mrd-table__file-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z"})),s("download",l)):"")}if("JSON"===h){const i=null!==(m=r.name)&&void 0!==m?m:"",a=i?null==e?void 0:e[i]:void 0;if(null==a||""===a)return t("td",{class:"mrd-table__cell"});const d=c.formatJson(a,!0),n=c.formatJson(a,!1);return t("td",{class:"mrd-table__cell"},t("span",{class:"mrd-table__json-preview",innerHTML:d}),t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),o(n)},"aria-label":s("textblock_show_more",l)},"⋯"))}if("TEXTBLOCK"===h){const i=c.render(r,e,l);if(i.length<=200)return t("td",{class:"mrd-table__cell"},i);const o=i.slice(0,200)+"…";return t("td",{class:"mrd-table__cell"},o,t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),a(i)},"aria-label":s("textblock_show_more",l)},"⋯"))}const u=c.render(r,e,l);return t("td",{class:"mrd-table__cell"+(b?" mrd-table__cell--numeric":""),title:u||void 0},u)},E=({columns:r,aggregations:e,locale:l})=>e&&r.some((t=>"FIELD"===t.type&&t.aggregate))?t("tfoot",null,t("tr",{class:"mrd-table__totals-row"},r.map((r=>{var i;const a=function(t,r,e){var l,i;if("FIELD"!==t.type||!t.aggregate||!r)return"";const a=null===(l=r[t.aggregate.toLowerCase()])||void 0===l?void 0:l[null!==(i=t.name)&&void 0!==i?i:""];if(null==a)return"";const o=t.dataType;return"INTEGER"===o?m(a,e,{maximumFractionDigits:0}):"PERCENTAGE"===o?h(a,e):"CURRENCY"===o&&t.currencyCode?b(a,t.currencyCode,e):m(a,e)}(r,e,l),o="FIELD"===r.type&&p.has(null!==(i=r.dataType)&&void 0!==i?i:"");return t("td",{class:"mrd-table__totals-cell"+(o?" mrd-table__totals-cell--numeric":"")},a)})))):null,C=({text:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("p",{class:"mrd-table__modal-text"},r))),z=({html:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("pre",{class:"mrd-table__modal-json",innerHTML:r}))),M=({locale:r,filterCount:e,actions:l,views:i,activeViewIdx:a,viewPopoverOpen:o,createPickerOpen:d,createTypes:n,cb:c})=>{var m;const h=l.length>0,b=i.length>1;return t("div",{class:"mrd-table__toolbar"},t("div",{class:"mrd-table__toolbar-left"},e>0&&t("button",{class:"mrd-table__action mrd-table__action--secondary mrd-table__filter-clear",onClick:c.onClearAllFilters},t("svg",{class:"mrd-table__action-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),t("span",{class:"mrd-table__filter-clear-label"},s("table_filter_clear_all",r)," (",e,")"))),b&&t("div",{class:"mrd-table__toolbar-center"},t("div",{class:"mrd-table__view-switcher"},t("button",{class:"mrd-table__view-arrow","aria-label":"Previous view",onClick:()=>c.onViewSwitch((a-1+i.length)%i.length)},"◀"),t("div",{class:"mrd-table__view-title-wrap"},t("button",{class:"mrd-table__view-title",onClick:t=>c.onToggleViewPopover(t)},null===(m=i[a])||void 0===m?void 0:m.label),o&&t("div",{class:"mrd-table__view-popover",onClick:t=>t.stopPropagation()},i.map(((r,e)=>t("button",{key:String(e),class:"mrd-table__view-popover-item"+(e===a?" mrd-table__view-popover-item--active":""),onClick:()=>{e!==a&&c.onViewSwitch(e),c.onCloseViewPopover()}},r.label))))),t("button",{class:"mrd-table__view-arrow","aria-label":"Next view",onClick:()=>c.onViewSwitch((a+1)%i.length)},"▶"))),h&&t("div",{class:"mrd-table__toolbar-right"},l.map((r=>{var e,l;const i="create"===r.action?n:null;return(null==i?void 0:i.length)?t("div",{class:"mrd-table__create-picker-wrap",key:`action-${r.action}`},t("button",{class:`mrd-table__action mrd-table__action--${null!==(e=r.variant)&&void 0!==e?e:"secondary"}`,onClick:c.onToggleCreatePicker},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label)),d&&t("div",{class:"mrd-table__create-picker"},i.map((r=>t("button",{key:r.type,class:"mrd-table__create-picker-item",onClick:()=>c.onCreate(r.type)},r.label))))):t("button",{key:`action-${r.action}`,class:`mrd-table__action mrd-table__action--${null!==(l=r.variant)&&void 0!==l?l:"secondary"}`,disabled:r.disabled,onClick:()=>c.onAction(r.action)},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label))}))))},O=({col:r,dataType:e,openFilterCol:l,pendingFilter:i,locale:a,cb:o})=>{var d,n,c,m,h,b;const f=i;if(v.has(e))return t("p",{class:"mrd-table__filter-no-support"},s("filter_no_support",a));if("BOOLEAN"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-radio-group"},[{labelKey:"filter_all",value:null},{labelKey:"yes",value:!0},{labelKey:"no",value:!1}].map((r=>t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:!e&&f.value===r.value,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:void 0,value:r.value}))}),s(r.labelKey,a)))),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isEmpty",value:void 0}))}),s("filter_is_empty",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isNotEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isNotEmpty",value:void 0}))}),s("filter_is_not_empty",a)))}if("LIST"===e){const e=null!==(d=r.listItems)&&void 0!==d?d:[],l=null!==(n=f.values)&&void 0!==n?n:[];return t("div",{class:"mrd-table__filter-list"},t("div",{class:"mrd-table__filter-list-controls"},t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:e.map((t=>t.key))}))},s("filter_select_all",a)),t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:[]}))},s("filter_select_none",a))),e.map((r=>t("label",{class:"mrd-table__filter-checkbox-label"},t("input",{type:"checkbox",checked:l.includes(r.key),onChange:t=>o.onToggleValue(r.key,t.target.checked)}),r.label))))}if(u.has(e)||"RELATION"===e){const r=null!==(c=f.operator)&&void 0!==c?c:"startsWith",e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>o.onSetPending("operator",t.target.value)},[{val:"startsWith",labelKey:"filter_starts_with"},{val:"equals",labelKey:"filter_equals"},{val:"isEmpty",labelKey:"filter_is_empty"},{val:"isNotEmpty",labelKey:"filter_is_not_empty"}].map((e=>t("option",{value:e.val,selected:r===e.val},s(e.labelKey,a))))),!e&&t("input",{type:"text",class:"mrd-table__filter-input",value:String(null!==(m=f.value)&&void 0!==m?m:""),placeholder:s("filter_search_value",a),onInput:t=>o.onSetPending("value",t.target.value)}))}if(p.has(e)){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range"},t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("span",{class:"mrd-table__filter-range-sep"},"–"),t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"number",class:"mrd-table__filter-input",value:null!=f.value?String(f.value):"",onInput:t=>o.onSetPending("value",t.target.value)})))}if("DATETIME"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range mrd-table__filter-range--stacked"},t("label",{class:"mrd-table__filter-range-label"},s("filter_from",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("label",{class:"mrd-table__filter-range-label"},s("filter_to",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"date",class:"mrd-table__filter-input",value:String(null!==(h=f.value)&&void 0!==h?h:""),onInput:t=>o.onSetPending("value",t.target.value)})))}if(_.has(e)){const r="DATE"===e?"date":"time",i=f.operator,d="isEmpty"===i||"isNotEmpty"===i,n=!d&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!d},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===i},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===i},s("filter_is_not_empty",a))),!d&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),n?t("div",{class:"mrd-table__filter-range"},t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:r,class:"mrd-table__filter-input",value:String(null!==(b=f.value)&&void 0!==b?b:""),onInput:t=>o.onSetPending("value",t.target.value)})))}return null},S=r=>{var e;const{col:l,openFilterCol:i,popupPos:a,sortField:o,sortDir:d,locale:n,cb:c}=r,m=null!==(e=l.label)&&void 0!==e?e:i,h=o===i;return t("div",{class:"mrd-table__filter-popup",style:{top:`${a.top}px`,left:`${a.left}px`},onClick:t=>t.stopPropagation()},t("div",{class:"mrd-table__filter-popup-header"},t("span",{class:"mrd-table__filter-popup-title"},m),t("button",{class:"mrd-table__filter-close",onClick:c.onClose},"✕")),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_sorting",n)),t("div",{class:"mrd-table__filter-sort-buttons"},t("button",{class:"mrd-table__filter-sort-btn"+(h&&"asc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("asc")},"▲ ",s("filter_ascending",n)),t("button",{class:"mrd-table__filter-sort-btn"+(h&&"desc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("desc")},"▼ ",s("filter_descending",n)))),t("div",{class:"mrd-table__filter-divider"}),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_section",n)),t(O,Object.assign({},r))),t("div",{class:"mrd-table__filter-popup-footer"},t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--clear",onClick:c.onClear},s("filter_clear",n)),t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--apply",onClick:c.onApply},s("filter_apply",n))))};function T(t,r){return Math.ceil(t/r)}function j(t,r,e){return{firstPage:Math.floor(t/e),lastPage:Math.floor(r/e)}}const P=r(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdLoadPage=l(this,"mrdLoadPage",7),this.mrdPageError=l(this,"mrdPageError",7),this.mrdRowClick=l(this,"mrdRowClick",7),this.mrdAction=l(this,"mrdAction",7),this.mrdDownload=l(this,"mrdDownload",7),this.mrdLoadAggregations=l(this,"mrdLoadAggregations",7),this.pendingPages=new Set,this.debounceTimer=null,this.requestedAt=new Map,this.retryAttempts=new Map,this.staleCheckTimer=null,this.outsideClickHandler=null,this.keydownHandler=null,this.createPickerClickHandler=null,this.viewPopoverClickHandler=null,this.resizeObserver=null,this.colWidthMeasureScheduled=!1,this.resizeOrigin=null,this.colWidthsUserSet=!1,this.paginationActivated=!1,this.item=null,this.parentId="",this.rows=[],this.locale=navigator.language,this.totalElements=0,this.pageSize=20,this.rowHeight=36,this.tableHeight=500,this.requestTimeoutMs=15e3,this.activeViewIdx=0,this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.renderStart=0,this.renderEnd=0,this.colWidths=[],this.resizingCol=null,this.sortField="",this.sortDir="asc",this.activeFilters=new Map,this.openFilterCol=null,this.pendingFilter=null,this.popupPos={top:0,left:0},this.createPickerOpen=!1,this.viewPopoverOpen=!1,this.scrollTop=0,this.textblockModal=null,this.jsonModal=null,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!1,this.minKnownTotal=0,this.handleScroll=t=>{const r=t.currentTarget,{renderStart:e,renderEnd:l}=function(t,r,e,l){const i=Math.floor(t/r),a=i+T(e,r)+10;return{renderStart:Math.max(0,i-10),renderEnd:l>0?Math.min(l-1,a):a}}(r.scrollTop,this.rowHeight,this.tableHeight,this.baseTotal);this.scrollTop=r.scrollTop,this.renderStart=e,this.renderEnd=l,this.requestPagesForWindow(this.renderStart,this.renderEnd)}}totalElementsChanged(t){t>0&&(this.renderEnd=Math.min(this.renderEnd,t-1))}itemChanged(t){var r,e;this.activeViewIdx=0,this.applyDefaultSort(null!==(e=null===(r=null==t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1}componentWillLoad(){var t,r,e;this.applyDefaultSort(null!==(e=null===(r=null===(t=this.item)||void 0===t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:"")}componentDidLoad(){this.staleCheckTimer=setInterval((()=>this.checkStalePages()),2e3),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver((()=>this.freezeColWidths())),this.resizeObserver.observe(this.el))}applyDefaultSort(t){const{field:r,dir:e}=function(t){var r;if(!t)return{field:"",dir:"asc"};const e=t.split(",");return{field:e[0].trim(),dir:"desc"===(null===(r=e[1])||void 0===r?void 0:r.trim())?"desc":"asc"}}(t);this.sortField=r,this.sortDir=e}async init(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1,this.scrollTop=0,this.renderStart=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.minKnownTotal=0,this.paginationActivated=!0,this.emitLoadPage(0),this.requestedPages=new Set([0])}async setPage(t,r,e){this.paginationActivated=!0;const l=void 0!==e?!e:r.length<this.pageSize;l?(this.renderEnd=Math.min(this.renderEnd,t*this.pageSize+r.length-1),this.minKnownTotal=t*this.pageSize+r.length):this.minKnownTotal=Math.max(this.minKnownTotal,(t+1)*this.pageSize+1);const i=new Map(this.loadedPages);if(i.set(t,r),this.loadedPages=i,this.renderEnd<this.renderStart&&(this.renderEnd=Math.min(this.renderStart+this.visibleCount()-1,this.minKnownTotal-1)),this.requestedAt.delete(t),this.retryAttempts.delete(t),this.failedPages.has(t)){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r}if(0===t&&this.aggregationsPending){this.aggregationsPending=!1;const t=this.columns.some((t=>"FIELD"===t.type&&t.aggregate));l&&!t||this.emitLoadAggregations()}}async setAggregations(t){null!=t.total&&(this.aggregationsTotal=t.total),this.aggregations=t}disconnectedCallback(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),null!==this.staleCheckTimer&&(clearInterval(this.staleCheckTimer),this.staleCheckTimer=null),this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null),this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null),this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}componentDidRender(){this.freezeColWidths()}freezeColWidths(){0!==this.colWidths.length||this.colWidthMeasureScheduled||0===this.loadedPages.size||(this.colWidthMeasureScheduled=!0,i((()=>{var t;if(this.colWidthMeasureScheduled=!1,0!==this.colWidths.length)return;const r=null!==(t=this.measureContentWidths())&&void 0!==t?t:this.measureColWidths();r&&r.some((t=>t>0))&&(this.colWidths=r)})))}measureColWidths(){const t=this.el.querySelectorAll(".mrd-table__header");return 0===t.length||t.length!==this.columns.length?null:Array.from(t).map((t=>Math.round(t.getBoundingClientRect().width)))}neededWidth(t){const r=t=>"number"==typeof t&&Number.isFinite(t)?t:0,e=r(t.clientWidth),l=r(t.scrollWidth),i=r(parseFloat(getComputedStyle(t).paddingRight||"0")),a=Math.max(0,r(t.offsetWidth)-e);return Math.ceil((l>e?l+i:e)+a)}measureContentWidths(){const t=this.el.querySelectorAll(".mrd-table__header");if(0===t.length||t.length!==this.columns.length)return null;const r=Array.from(t).map(((t,r)=>{let e=this.neededWidth(t);return this.el.querySelectorAll(`.mrd-table__cell:nth-child(${r+1})`).forEach((t=>{e=Math.max(e,this.neededWidth(t))})),e}));return r.every((t=>t<=0))?null:r.map((t=>Math.min(Math.max(t,48),600)))}syncColWidths(){const t=this.measureColWidths();return t?(this.colWidths=t,!0):this.colWidths.length===this.columns.length}setColWidth(t,r){const e=[...this.colWidths];e[t]=Math.max(48,Math.round(r)),this.colWidths=e,this.colWidthsUserSet=!0}handleResizeStart(t,r){var e,l;t.preventDefault(),t.stopPropagation(),this.syncColWidths()&&(this.resizeOrigin={idx:r,startX:t.clientX,startWidth:this.colWidths[r]},this.resizingCol=r,null===(l=(e=t.currentTarget).setPointerCapture)||void 0===l||l.call(e,t.pointerId))}handleResizeMove(t){if(!this.resizeOrigin)return;const{idx:r,startX:e,startWidth:l}=this.resizeOrigin;this.setColWidth(r,l+(t.clientX-e))}handleResizeEnd(t){var r,e;this.resizeOrigin&&(this.resizeOrigin=null,this.resizingCol=null,null===(e=(r=t.currentTarget).releasePointerCapture)||void 0===e||e.call(r,t.pointerId))}handleResizeAutoFit(t,r){if(t.preventDefault(),t.stopPropagation(),!this.syncColWidths())return;const e=this.el.querySelectorAll(`.mrd-table__header:nth-child(${r+1}), .mrd-table__cell:nth-child(${r+1})`);let l=0;e.forEach((t=>{l=Math.max(l,this.neededWidth(t))})),l>0&&this.setColWidth(r,Math.min(l,600))}lockedTableStyle(){if(0===this.colWidths.length)return;const t=this.colWidths.reduce(((t,r)=>t+(r||0)),0);return Object.assign({tableLayout:"fixed",width:`${t}px`},this.colWidthsUserSet?{}:{minWidth:"100%"})}renderColResizer(r){return t("span",{class:"mrd-table__col-resizer"+(this.resizingCol===r?" mrd-table__col-resizer--active":""),role:"separator","aria-orientation":"vertical",title:s("column_resize",this.locale),"on-pointerdown":t=>this.handleResizeStart(t,r),"on-pointermove":t=>this.handleResizeMove(t),"on-pointerup":t=>this.handleResizeEnd(t),"on-pointercancel":t=>this.handleResizeEnd(t),"on-dblclick":t=>this.handleResizeAutoFit(t,r),onClick:t=>t.stopPropagation()})}visibleCount(){return T(this.tableHeight,this.rowHeight)}sortParam(){return(t=this.sortField)?"desc"===this.sortDir?`${t},desc`:t:"";var t}get allViews(){var t,r,e,l,i,a,o;if(!this.item)return[];const s=this.item;return[{label:null!==(i=null!==(l=null!==(e=null!==(t=s.label)&&void 0!==t?t:null===(r=s.view)||void 0===r?void 0:r.pluralLabel)&&void 0!==e?e:s.dataClass)&&void 0!==l?l:s.relatedClass)&&void 0!==i?i:"",dataClass:null!==(a=s.dataClass)&&void 0!==a?a:s.relatedClass,fromClass:s.fromClass,filterClass:s.filterClass,view:s.view},...(null!==(o=s.alternativeViews)&&void 0!==o?o:[]).map((t=>{var r,e,l,i;return{label:null!==(i=null!==(l=null!==(r=t.label)&&void 0!==r?r:null===(e=t.view)||void 0===e?void 0:e.pluralLabel)&&void 0!==l?l:t.dataClass)&&void 0!==i?i:"",dataClass:t.dataClass,fromClass:t.fromClass,filterClass:t.filterClass,view:t.view}}))]}buildExcelPath(){var t;const r=this.allViews[this.activeViewIdx];return r?"/excel"+n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildActionDetail(t,r){var e,l,i;if("export"===t)return{action:t,path:this.buildExcelPath(),qs:this.buildQueryParams(0)};if("create"===t){const a=this.allViews[this.activeViewIdx],o="RELATED_VIEW"===(null===(e=this.item)||void 0===e?void 0:e.type)?`/${null!==(l=null==a?void 0:a.fromClass)&&void 0!==l?l:""}/${this.parentId}`:null;return Object.assign({action:t,dataClass:null!==(i=null==a?void 0:a.dataClass)&&void 0!==i?i:"",parentPath:o},r?{basicType:r}:{})}return{action:t}}buildDataPath(){var t;const r=this.allViews[this.activeViewIdx];return r?n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildQueryParams(t){var r;const e=this.allViews[this.activeViewIdx];return function(t){var r,e;const l=new URLSearchParams;t.page>0&&l.set("page",String(t.page)),t.sort&&l.set("sort",t.sort),t.filterClass&&l.set("type",t.filterClass),d(l,t.viewFilters);for(const i of t.activeFilters)"isEmpty"!==i.operator?"isNotEmpty"!==i.operator?"startsWith"!==i.operator?(null===(e=i.values)||void 0===e?void 0:e.length)?l.set(i.field,i.values.join(",")):(null!=i.value&&l.set(i.field,String(i.value)),null!=i.from&&l.set(i.field+"_from",String(i.from)),null!=i.to&&l.set(i.field+"_to",String(i.to))):l.set(i.field+"_startswith",String(null!==(r=i.value)&&void 0!==r?r:"")):l.set(i.field+"_notempty","true"):l.set(i.field,"");return l.toString()}({page:t,sort:this.sortParam(),filterClass:null==e?void 0:e.filterClass,viewFilters:null===(r=null==e?void 0:e.view)||void 0===r?void 0:r.filter,activeFilters:this.activeFilters.values()})}get isPaginated(){return this.totalElements>0||this.paginationActivated}get columns(){var t,r,e;return null!==(e=null===(r=null===(t=this.allViews[this.activeViewIdx])||void 0===t?void 0:t.view)||void 0===r?void 0:r.values)&&void 0!==e?e:[]}get tableActions(){var t,r;const e=null!==(r=null===(t=this.item)||void 0===t?void 0:t.actions)&&void 0!==r?r:[];return(null!=e?e:[]).reduce(((t,r)=>("NEW"===r&&t.push({action:"create",label:s("table_new_record",this.locale),icon:"assets/sprites.svg#icon-plus",variant:"primary"}),"EXPORT"===r&&t.push({action:"export",label:s("table_export_excel",this.locale),icon:"assets/sprites.svg#icon-file-excel"}),t)),[])}toggleCreatePicker(){this.createPickerOpen?this.closeCreatePicker():(this.createPickerOpen=!0,this.createPickerClickHandler&&document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=t=>{const r=this.el.querySelector(".mrd-table__create-picker-wrap");r&&!r.contains(t.target)&&this.closeCreatePicker()},document.addEventListener("click",this.createPickerClickHandler))}closeCreatePicker(){this.createPickerOpen=!1,this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null)}colName(t){var r;return null!==(r=t.name)&&void 0!==r?r:""}colDataType(t){var r;return"RELATION"===t.type?"RELATION":null!==(r=t.dataType)&&void 0!==r?r:"TEXT"}isTotalKnown(){return null!=this.aggregationsTotal||function(t,r){for(const e of t.values())if(e.length<r)return!0;return!1}(this.loadedPages,this.pageSize)}get baseTotal(){return null!=this.aggregationsTotal?this.aggregationsTotal:this.totalElements>0?this.totalElements:this.minKnownTotal}emitLoadAggregations(){const t=this.buildQueryParams(0);this.mrdLoadAggregations.emit({path:this.buildDataPath(),qs:t,aggQs:g(t,this.columns)})}resetPages(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidthsUserSet||(this.colWidths=[],this.colWidthMeasureScheduled=!1),this.scrollTop=0,this.renderStart=0,this.minKnownTotal=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0)}applySort(t,r){this.sortField=this.colName(t),this.sortDir=r,this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd)}emitLoadPage(t){this.mrdLoadPage.emit({page:t,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(t)}),this.requestedAt.set(t,Date.now())}emitPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize),i=new Set(this.requestedPages);let a=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||i.has(t)||(i.add(t),this.emitLoadPage(t),a=!0);a&&(this.requestedPages=i)}getRow(t){return function(t,r,e){var l;const i=t.get(Math.floor(r/e));return null!==(l=null==i?void 0:i[r%e])&&void 0!==l?l:null}(this.loadedPages,t,this.pageSize)}requestPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize);let i=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||this.requestedPages.has(t)||this.pendingPages.has(t)||(this.pendingPages.add(t),i=!0);i&&(null!==this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>this.flushPendingPages()),150))}flushPendingPages(){if(this.debounceTimer=null,0===this.pendingPages.size)return;const t=new Set(this.requestedPages);let r=!1;for(const e of this.pendingPages){if(this.loadedPages.has(e)||t.has(e))continue;const l=e*this.pageSize;l+this.pageSize-1<this.renderStart||l>this.renderEnd||(t.add(e),this.emitLoadPage(e),r=!0)}this.pendingPages.clear(),r&&(this.requestedPages=t)}checkStalePages(){var t;if(0===this.requestedAt.size)return;const r=function(t,r,e){const l=[];for(const[i,a]of t)r-a>=e&&l.push(i);return l}(this.requestedAt,Date.now(),this.requestTimeoutMs).filter((t=>!this.loadedPages.has(t)));if(0===r.length)return;let e=null;for(const l of r){const r=null!==(t=this.retryAttempts.get(l))&&void 0!==t?t:0;r<3?(this.retryAttempts.set(l,r+1),this.emitLoadPage(l)):(this.requestedAt.delete(l),this.retryAttempts.delete(l),e||(e=new Set(this.failedPages)),e.add(l),this.mrdPageError.emit({page:l}))}e&&(this.failedPages=e)}retryPage(t){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r,this.retryAttempts.delete(t),this.emitLoadPage(t);const e=new Set(this.requestedPages);e.add(t),this.requestedPages=e}handleFilterOpen(t,r){r.stopPropagation();const e=r.currentTarget.getBoundingClientRect();let l=e.left;l+280>window.innerWidth-8&&(l=e.right-280),this.popupPos={top:e.bottom+4,left:Math.max(8,l)};const i=this.colName(t),a=this.colDataType(t),o=this.activeFilters.get(i),s=u.has(a)||"RELATION"===a?"startsWith":void 0;this.pendingFilter="DATETIME"===a&&o&&"isEmpty"!==o.operator&&"isNotEmpty"!==o.operator?function(t){const r=Object.assign({},t);return"string"==typeof r.from&&r.from&&(r.from=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}(r.from)),"string"==typeof r.to&&r.to&&(r.to=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:(r.setDate(r.getDate()-1),`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`)}(r.to)),r.from&&r.to&&r.from===r.to?Object.assign(Object.assign({},r),{value:r.from,from:void 0,to:void 0}):r}(o):o?Object.assign({},o):{field:i,dataType:a,operator:s},this.openFilterCol=i,this.outsideClickHandler&&document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=t=>{const r=this.el.querySelector(".mrd-table__filter-popup");r&&!r.contains(t.target)&&this.closeFilterPopup()},document.addEventListener("click",this.outsideClickHandler)}closeFilterPopup(){this.openFilterCol=null,this.pendingFilter=null,this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}openTextblockModal(t){this.textblockModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeTextblockModal()},document.addEventListener("keydown",this.keydownHandler)}closeTextblockModal(){this.textblockModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}openJsonModal(t){this.jsonModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeJsonModal()},document.addEventListener("keydown",this.keydownHandler)}closeJsonModal(){this.jsonModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}setPending(t,r){this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{[t]:r})}togglePendingValue(t,r){var e,l;const i=null!==(l=null===(e=this.pendingFilter)||void 0===e?void 0:e.values)&&void 0!==l?l:[];this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{values:r?[...i,t]:i.filter((r=>r!==t))})}applyFilter(){const t=this.pendingFilter;if(!(null==t?void 0:t.field))return void this.closeFilterPopup();const r=function(t){const r=Object.assign({},t);return"DATETIME"===t.dataType&&"isEmpty"!==t.operator&&"isNotEmpty"!==t.operator&&("string"==typeof r.value&&r.value?(r.from=w(r.value),r.to=y(r.value),r.value=void 0):("string"==typeof r.from&&r.from&&(r.from=w(r.from)),"string"==typeof r.to&&r.to&&(r.to=y(r.to)))),r}(t),e=new Map(this.activeFilters);!function(t){return"isEmpty"===t.operator||"isNotEmpty"===t.operator||void 0!==t.values&&t.values.length>0||null!=t.value&&""!==t.value||"boolean"==typeof t.value||null!=t.from&&""!==t.from||null!=t.to&&""!==t.to}(r)?e.delete(r.field):e.set(r.field,r),this.activeFilters=e,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearFilter(){const t=this.openFilterCol,r=new Map(this.activeFilters);t&&r.delete(t),this.activeFilters=r,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearAllFilters(){this.activeFilters=new Map,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}handleViewSwitch(t){var r,e;const l=this.allViews[t];(null==l?void 0:l.view)&&(this.activeViewIdx=t,this.applyDefaultSort(null!==(e=null===(r=l.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.activeFilters=new Map,this.init())}toggleViewPopover(t){t.stopPropagation(),this.viewPopoverOpen?this.closeViewPopover():(this.viewPopoverOpen=!0,this.viewPopoverClickHandler=()=>this.closeViewPopover(),document.addEventListener("click",this.viewPopoverClickHandler))}closeViewPopover(){this.viewPopoverOpen=!1,this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}renderToolbar(){var r;return t(M,{locale:this.locale,filterCount:this.activeFilters.size,actions:this.tableActions,views:this.allViews,activeViewIdx:this.activeViewIdx,viewPopoverOpen:this.viewPopoverOpen,createPickerOpen:this.createPickerOpen,createTypes:null===(r=this.item)||void 0===r?void 0:r.createTypes,cb:{onClearAllFilters:()=>this.clearAllFilters(),onViewSwitch:t=>this.handleViewSwitch(t),onToggleViewPopover:t=>this.toggleViewPopover(t),onCloseViewPopover:()=>this.closeViewPopover(),onToggleCreatePicker:()=>this.toggleCreatePicker(),onCreate:t=>{this.mrdAction.emit(this.buildActionDetail("create",t)),this.closeCreatePicker()},onAction:t=>this.mrdAction.emit(this.buildActionDetail(t))}})}renderFilterPopup(){if(!this.openFilterCol||!this.pendingFilter)return null;const r=this.columns.find((t=>this.colName(t)===this.openFilterCol));return r?t(S,{col:r,dataType:this.colDataType(r),openFilterCol:this.openFilterCol,pendingFilter:this.pendingFilter,popupPos:this.popupPos,sortField:this.sortField,sortDir:this.sortDir,locale:this.locale,cb:{onSetPending:(t,r)=>this.setPending(t,r),onReplacePending:t=>this.pendingFilter=t,onToggleValue:(t,r)=>this.togglePendingValue(t,r),onApplySort:t=>this.applySort(r,t),onApply:()=>this.applyFilter(),onClear:()=>this.clearFilter(),onClose:()=>this.closeFilterPopup()}}):null}renderFooter(r,e,l=!0){if(!this.isPaginated){const e=null!=r?r:0;return 0===e?null:t("div",{class:"mrd-table__footer"},e," ",s("table_of",this.locale)," ",e)}if(!this.loadedPages.has(0))return null;const i=null!=e?e:this.baseTotal,a=Math.min(Math.floor(this.scrollTop/this.rowHeight)+1,i),o=Math.min(Math.ceil((this.scrollTop+this.tableHeight)/this.rowHeight),i),d=l?String(i):"…";return t("div",{class:"mrd-table__footer"},a,"–",o," ",s("table_of",this.locale)," ",d)}renderCell(r,e){return t(k,{col:r,row:e,locale:this.locale,onDownload:t=>this.mrdDownload.emit(t),onOpenTextblock:t=>this.openTextblockModal(t),onOpenJson:t=>this.openJsonModal(t)})}renderTotalsRow(){return t(E,{columns:this.columns,aggregations:this.aggregations,locale:this.locale})}render(){var r,e,l;if(!(null===(r=this.columns)||void 0===r?void 0:r.length))return null;if(!this.isPaginated)return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table"},t("table",{class:"mrd-table__table",style:this.lockedTableStyle()},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.activeFilters.has(i),o=!f.has(this.colDataType(r)),s=["mrd-table__header",a?"mrd-table__header--filtered":"",o?"mrd-table__header--sortable":""].filter(Boolean).join(" ");return t("th",{class:s,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:o?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),a&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,null===(e=this.rows)||void 0===e?void 0:e.map(((r,e)=>t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:e%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:r})},this.columns.map((t=>this.renderCell(t,r))))))),this.renderTotalsRow()),(!this.rows||0===this.rows.length)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale))),this.renderFooter(null===(l=this.rows)||void 0===l?void 0:l.length),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal());const i=function(t,r,e){let l=e;for(const[e,i]of t)i.length<r&&(l=Math.min(l,e*r+i.length));return l}(this.loadedPages,this.pageSize,this.baseTotal),o=Math.min(this.renderEnd,i-1),d=this.columns.length,n=this.renderStart*this.rowHeight,c=Math.max(0,(i-1-o)*this.rowHeight),m=this.lockedTableStyle(),h=[];for(let r=this.renderStart;r<=o;r++){const e=this.getRow(r);if(null===e){const e=Math.floor(r/this.pageSize);this.failedPages.has(e)?h.push(t("tr",{class:"mrd-table__row mrd-table__row--failed"},t("td",{class:"mrd-table__cell--failed",colSpan:d},t("button",{type:"button",class:"mrd-table__retry-button",onClick:()=>this.retryPage(e)},s("load_failed_retry",this.locale))))):h.push(t("tr",{class:"mrd-table__row mrd-table__row--loading"},t("td",{class:"mrd-table__cell--placeholder",colSpan:d},t("span",{class:"mrd-table__placeholder-bar"}))))}else h.push(t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:r%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:e,listContext:{index:r,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(0)}})},this.columns.map((t=>this.renderCell(t,e)))))}return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table__scroll",style:{height:`${this.tableHeight}px`},onScroll:this.handleScroll},t("table",{class:"mrd-table__table",style:m},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.sortField===i,o=this.activeFilters.has(i),s=!f.has(this.colDataType(r)),d=["mrd-table__header",s?"mrd-table__header--sortable":"",a?`mrd-table__header--sorted-${this.sortDir}`:"",o?"mrd-table__header--filtered":""].filter(Boolean).join(" ");return t("th",{class:d,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:s?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),s&&a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"asc"===this.sortDir?"▲":"▼"),s&&!a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"⇅"),s&&o&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,n>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${n}px`}},t("td",{colSpan:d})),h,c>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${c}px`}},t("td",{colSpan:d}))),this.renderTotalsRow())),0===i&&this.loadedPages.has(0)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale)),i>0&&this.renderFooter(void 0,i,this.isTotalKnown()),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal())}renderTextblockModal(){return t(C,{text:this.textblockModal,locale:this.locale,onClose:()=>this.closeTextblockModal()})}renderJsonModal(){return t(z,{html:this.jsonModal,locale:this.locale,onClose:()=>this.closeJsonModal()})}get el(){return this}static get watchers(){return{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}}static get style(){return'.sc-mrd-table-h{display:block;width:100%}.mrd-table.sc-mrd-table{overflow-x:auto}.mrd-table__scroll.sc-mrd-table{overflow-y:auto;overflow-x:auto;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow-anchor:none}.mrd-table__table.sc-mrd-table{width:auto;min-width:100%;border-collapse:collapse;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900)}.mrd-table__scroll.sc-mrd-table .mrd-table__table.sc-mrd-table{min-width:max-content}.mrd-table__header.sc-mrd-table{position:sticky;top:0;z-index:1;background:var(--mrd-color-white);text-align:left;padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:2px solid var(--mrd-border-color);color:var(--mrd-color-neutral-600);font-weight:var(--mrd-font-weight-medium);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:var(--mrd-font-size-xs);text-transform:uppercase;letter-spacing:0.04em}.mrd-table__header--sortable.sc-mrd-table{cursor:pointer;user-select:none}.mrd-table__header--sortable.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-800)}.mrd-table__header--sorted-asc.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header--filtered.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header-label.sc-mrd-table{margin-right:var(--mrd-space-1)}.mrd-table__col-resizer.sc-mrd-table{position:absolute;top:0;right:0;width:9px;height:100%;cursor:col-resize;touch-action:none;user-select:none}.mrd-table__col-resizer.sc-mrd-table::after{content:"";position:absolute;top:25%;right:4px;width:1px;height:50%;background:var(--mrd-border-color)}.mrd-table__col-resizer.sc-mrd-table:hover::after{width:2px;right:3px;background:var(--mrd-color-primary)}.mrd-table__col-resizer--active.sc-mrd-table::after{width:2px;right:3px;height:100%;top:0;background:var(--mrd-color-primary)}.mrd-table--resizing.sc-mrd-table{cursor:col-resize;user-select:none}.mrd-table__sort-icon.sc-mrd-table{font-size:0.85rem;opacity:0.4;vertical-align:middle}.mrd-table__header--sorted-asc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table{opacity:1;color:var(--mrd-color-primary)}.mrd-table__filter-icon.sc-mrd-table{display:inline-flex;align-items:center;vertical-align:middle;margin-left:var(--mrd-space-1);color:var(--mrd-color-primary)}.mrd-table__row.sc-mrd-table{border-bottom:1px solid var(--mrd-border-color)}.mrd-table__row.sc-mrd-table:hover{background:var(--mrd-color-neutral-200) !important}.mrd-table__row--clickable.sc-mrd-table{cursor:pointer}.mrd-table__row--loading.sc-mrd-table{background:transparent}.mrd-table__row--failed.sc-mrd-table{background:transparent}.mrd-table__spacer.sc-mrd-table{border:none}.mrd-table__spacer.sc-mrd-table td.sc-mrd-table{padding:0;border:none}.mrd-table__cell.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);vertical-align:top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__cell--numeric.sc-mrd-table{text-align:right;font-variant-numeric:tabular-nums}.mrd-table__cell--placeholder.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__cell--failed.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__placeholder-bar.sc-mrd-table{display:block;height:0.75rem;width:55%;border-radius:var(--mrd-border-radius-sm);background:linear-gradient(90deg, var(--mrd-color-neutral-200) 25%, var(--mrd-color-neutral-100) 50%, var(--mrd-color-neutral-200) 75%);background-size:200% 100%;animation:mrd-shimmer 1.4s ease infinite}.mrd-table__retry-button.sc-mrd-table{border:none;background:none;padding:0;color:var(--mrd-color-danger);font-size:inherit;cursor:pointer;text-decoration:underline}.mrd-table__toolbar.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--mrd-space-2)}.mrd-table__toolbar-left.sc-mrd-table,.mrd-table__toolbar-right.sc-mrd-table{display:flex;gap:var(--mrd-space-2);align-items:center}.mrd-table__toolbar-center.sc-mrd-table{flex:1;display:flex;justify-content:center;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-switcher.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-arrow.sc-mrd-table{background:none;border:none;cursor:pointer;padding:0 var(--mrd-space-1);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-xs);line-height:1}.mrd-table__view-arrow.sc-mrd-table:hover{color:var(--mrd-color-neutral-800)}.mrd-table__view-title-wrap.sc-mrd-table{position:relative}.mrd-table__view-title.sc-mrd-table{font-size:var(--mrd-font-size-sm);font-weight:600;color:var(--mrd-color-neutral-800);font-family:var(--mrd-font-family);background:none;border:none;outline:none;cursor:pointer;padding:0 var(--mrd-space-1);max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__view-title.sc-mrd-table:hover{color:var(--mrd-color-primary)}.mrd-table__view-popover.sc-mrd-table{position:absolute;top:calc(100% + var(--mrd-space-1));left:50%;transform:translateX(-50%);background:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-radius-md);box-shadow:var(--mrd-shadow-md);z-index:100;min-width:160px;padding:var(--mrd-space-1) 0}.mrd-table__view-popover-item.sc-mrd-table{display:block;width:100%;text-align:left;background:none;border:none;cursor:pointer;padding:var(--mrd-space-2) var(--mrd-space-3);font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-700);white-space:nowrap}.mrd-table__view-popover-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50)}.mrd-table__view-popover-item--active.sc-mrd-table{font-weight:600;color:var(--mrd-color-primary)}.mrd-table__action.sc-mrd-table{position:relative;display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;background:transparent;border:1px solid transparent;border-radius:var(--mrd-border-radius);cursor:pointer;color:var(--mrd-color-neutral-400);transition:background-color 0.15s, border-color 0.15s, color 0.15s}.mrd-table__action.sc-mrd-table:hover{background-color:var(--mrd-color-neutral-100);border-color:var(--mrd-color-neutral-300);color:var(--mrd-color-neutral-700)}.mrd-table__action.sc-mrd-table:hover .mrd-table__action-tooltip.sc-mrd-table{display:block}.mrd-table__action.sc-mrd-table:disabled{opacity:0.4;cursor:not-allowed}.mrd-table__action--primary.sc-mrd-table{color:var(--mrd-color-neutral-500)}.mrd-table__action--primary.sc-mrd-table:hover{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__action--danger.sc-mrd-table{color:var(--mrd-color-error)}.mrd-table__action--danger.sc-mrd-table:hover{background-color:var(--mrd-color-error-light, #fef2f2);border-color:var(--mrd-color-error)}.mrd-table__action-icon.sc-mrd-table{width:1.25rem;height:1.25rem;pointer-events:none;fill:currentColor}.mrd-table__action-tooltip.sc-mrd-table{display:none;position:absolute;bottom:calc(100% + 6px);right:0;padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);white-space:nowrap;background:var(--mrd-color-tooltip, #fffce1);color:var(--mrd-color-neutral-900);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-sm, var(--mrd-border-radius));pointer-events:none;z-index:10}.mrd-table__create-picker-wrap.sc-mrd-table{position:relative}.mrd-table__create-picker.sc-mrd-table{position:absolute;right:0;top:calc(100% + 4px);background:var(--mrd-color-white, #fff);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:10;min-width:10rem;padding:var(--mrd-space-1) 0}.mrd-table__create-picker-item.sc-mrd-table{display:block;width:100%;text-align:left;padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-800)}.mrd-table__create-picker-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-900)}.mrd-table__filter-clear.sc-mrd-table{width:auto;gap:var(--mrd-space-1);padding:0 var(--mrd-space-2);color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear.sc-mrd-table:hover{color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear-label.sc-mrd-table{font-size:var(--mrd-font-size-sm);white-space:nowrap}.mrd-table__filter-popup.sc-mrd-table{position:fixed;width:280px;background:var(--mrd-color-white);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:var(--mrd-z-dropdown, 200);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-popup-header.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__filter-popup-title.sc-mrd-table{font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-close.sc-mrd-table{background:transparent;border:none;cursor:pointer;color:var(--mrd-color-neutral-500);font-size:0.9rem;padding:2px 4px;border-radius:3px;line-height:1}.mrd-table__filter-close.sc-mrd-table:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-800)}.mrd-table__filter-section.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-3)}.mrd-table__filter-section-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);text-transform:uppercase;letter-spacing:0.04em;color:var(--mrd-color-neutral-500);margin-bottom:var(--mrd-space-2)}.mrd-table__filter-sort-buttons.sc-mrd-table{display:flex;gap:var(--mrd-space-2)}.mrd-table__filter-sort-btn.sc-mrd-table{flex:1;padding:var(--mrd-space-1) var(--mrd-space-2);background:transparent;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);cursor:pointer;font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-700)}.mrd-table__filter-sort-btn.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-sort-btn--active.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-divider.sc-mrd-table{height:1px;background:var(--mrd-border-color);margin:0}.mrd-table__filter-editor.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-2)}.mrd-table__filter-select.sc-mrd-table,.mrd-table__filter-input.sc-mrd-table{width:100%;padding:var(--mrd-space-1) var(--mrd-space-2);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900);background:var(--mrd-color-white);box-sizing:border-box}.mrd-table__filter-select.sc-mrd-table:focus,.mrd-table__filter-input.sc-mrd-table:focus{outline:none;border-color:var(--mrd-color-primary);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.06)}.mrd-table__filter-range.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__filter-range.sc-mrd-table .mrd-table__filter-input.sc-mrd-table{flex:1;min-width:0}.mrd-table__filter-range--stacked.sc-mrd-table{flex-direction:column;align-items:stretch;gap:var(--mrd-space-2)}.mrd-table__filter-range-sep.sc-mrd-table{color:var(--mrd-color-neutral-400);flex-shrink:0}.mrd-table__filter-range-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);margin-bottom:2px}.mrd-table__filter-radio-group.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-table__filter-radio-group--inline.sc-mrd-table{flex-direction:row;gap:var(--mrd-space-3)}.mrd-table__filter-radio-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-list.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1);max-height:180px;overflow-y:auto}.mrd-table__filter-list-controls.sc-mrd-table{display:flex;gap:var(--mrd-space-2);margin-bottom:var(--mrd-space-1)}.mrd-table__filter-list-btn.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-primary);background:transparent;border:none;cursor:pointer;padding:0;text-decoration:underline}.mrd-table__filter-checkbox-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-no-support.sc-mrd-table{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-500);margin:0;font-style:italic}.mrd-table__filter-popup-footer.sc-mrd-table{display:flex;justify-content:flex-end;gap:var(--mrd-space-2);padding:var(--mrd-space-2) var(--mrd-space-3);border-top:1px solid var(--mrd-border-color)}.mrd-table__filter-btn.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-3);border-radius:var(--mrd-border-radius);border:1px solid var(--mrd-border-color);font-size:var(--mrd-font-size-sm);cursor:pointer}.mrd-table__filter-btn--clear.sc-mrd-table{background:transparent;color:var(--mrd-color-neutral-600)}.mrd-table__filter-btn--clear.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-btn--apply.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-btn--apply.sc-mrd-table:hover{background:var(--mrd-color-primary-dark, var(--mrd-color-primary));border-color:var(--mrd-color-primary-dark, var(--mrd-color-primary))}.mrd-table__totals-row.sc-mrd-table{border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell.sc-mrd-table{position:sticky;bottom:0;z-index:2;padding:var(--mrd-space-2) var(--mrd-space-4);background:var(--mrd-color-white);font-weight:var(--mrd-font-weight-medium);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell--numeric.sc-mrd-table{text-align:right}.mrd-table__footer.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);text-align:right}.mrd-table__empty.sc-mrd-table{padding:var(--mrd-space-4) var(--mrd-space-3);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-sm);text-align:center;margin:0}.mrd-table__file-btn.sc-mrd-table{display:inline-flex;align-items:center;gap:var(--mrd-space-1);background:none;border:none;padding:0;cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;max-width:100%;overflow:hidden}.mrd-table__file-btn.sc-mrd-table:hover{text-decoration:underline;color:var(--mrd-color-primary-dark)}.mrd-table__file-icon.sc-mrd-table{flex-shrink:0;width:1rem;height:1rem}.mrd-table__textblock-btn.sc-mrd-table{display:inline;background:none;border:none;padding:0 0 0 var(--mrd-space-1);cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;line-height:inherit;vertical-align:middle}.mrd-table__textblock-btn.sc-mrd-table:hover{color:var(--mrd-color-primary-dark)}.mrd-table__modal-backdrop.sc-mrd-table{position:fixed;inset:0;background:rgba(0, 0, 0, 0.4);z-index:var(--mrd-z-modal, 300);display:flex;align-items:center;justify-content:center}.mrd-table__modal.sc-mrd-table{background:#fff;border-radius:var(--mrd-radius-md, 0.5rem);padding:var(--mrd-space-6);max-width:min(600px, 90vw);max-height:70vh;overflow-y:auto;position:relative;box-shadow:var(--mrd-shadow-lg)}.mrd-table__modal-close.sc-mrd-table{position:absolute;top:var(--mrd-space-3);right:var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1;color:var(--mrd-color-text-muted, #6b7280);padding:0}.mrd-table__modal-close.sc-mrd-table:hover{color:var(--mrd-color-text, #111827)}.mrd-table__modal-text.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);white-space:pre-wrap;word-break:break-word;font-size:var(--mrd-font-size-sm);line-height:1.6}.mrd-table__json-preview.sc-mrd-table{font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:inline-block;max-width:calc(100% - 1.5rem);vertical-align:middle}.mrd-table__modal-json.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);white-space:pre-wrap;word-break:break-word;line-height:1.6;background:none;border:none}@keyframes mrd-shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}'}},[2,"mrd-table",{item:[16],parentId:[1,"parent-id"],rows:[16],locale:[1],totalElements:[2,"total-elements"],pageSize:[2,"page-size"],rowHeight:[2,"row-height"],tableHeight:[2,"table-height"],requestTimeoutMs:[2,"request-timeout-ms"],activeViewIdx:[32],loadedPages:[32],requestedPages:[32],failedPages:[32],renderStart:[32],renderEnd:[32],colWidths:[32],resizingCol:[32],sortField:[32],sortDir:[32],activeFilters:[32],openFilterCol:[32],pendingFilter:[32],popupPos:[32],createPickerOpen:[32],viewPopoverOpen:[32],scrollTop:[32],textblockModal:[32],jsonModal:[32],aggregations:[32],aggregationsTotal:[32],minKnownTotal:[32],init:[64],setPage:[64],setAggregations:[64]},void 0,{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}]);function I(){"undefined"!=typeof customElements&&["mrd-table"].forEach((t=>{"mrd-table"===t&&(customElements.get(o(t))||customElements.define(o(t),P))}))}export{P as M,I as d}