monobill-mintui 0.6.706 → 0.6.708

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/components/alert/browser.js +4 -4
  2. package/dist/components/alert/index.cjs +1 -1
  3. package/dist/components/alert/index.js +4 -4
  4. package/dist/components/back-button/browser.js +1 -1
  5. package/dist/components/back-button/index.cjs +1 -1
  6. package/dist/components/back-button/index.js +1 -1
  7. package/dist/components/bottom-navigation/browser.js +2 -2
  8. package/dist/components/bottom-navigation/index.cjs +1 -1
  9. package/dist/components/bottom-navigation/index.js +2 -2
  10. package/dist/components/button/browser.js +1 -1
  11. package/dist/components/button/index.cjs +1 -1
  12. package/dist/components/button/index.js +1 -1
  13. package/dist/components/checkbox/browser.js +2 -2
  14. package/dist/components/checkbox/index.cjs +1 -1
  15. package/dist/components/checkbox/index.js +2 -2
  16. package/dist/components/chip/browser.js +1 -1
  17. package/dist/components/chip/index.cjs +1 -1
  18. package/dist/components/chip/index.js +1 -1
  19. package/dist/components/chunks/{back-button-lIFHlWjY.js → back-button-BGzrOtpx.js} +1 -1
  20. package/dist/components/chunks/{back-button-B7uDpX7F.js → back-button-By8eO_KR.js} +2 -2
  21. package/dist/components/chunks/{button-imX8FM_Q.js → button-B_yN18B-.js} +1 -1
  22. package/dist/components/chunks/{button-CUWUQAt8.js → button-JPTyQfRs.js} +2 -2
  23. package/dist/components/chunks/caret-down-BFHFcMyL.js +1 -0
  24. package/dist/components/chunks/{caret-down-oeRBseTW.js → caret-down-ZjQN2yKq.js} +1 -1
  25. package/dist/components/chunks/caret-right--YnEL-Ny.js +1 -0
  26. package/dist/components/chunks/{caret-right-DMCejGQ6.js → caret-right-BlRbsLlh.js} +1 -1
  27. package/dist/components/chunks/{chip-BeGxDLpQ.js → chip-BUaS7ks-.js} +1 -1
  28. package/dist/components/chunks/{chip-CbfqkmGQ.js → chip-XuYPtZ3Z.js} +3 -3
  29. package/dist/components/chunks/{close-C5b9RhcK.js → close-Cn8XLO1c.js} +1 -1
  30. package/dist/components/chunks/close-DSrpkGHJ.js +1 -0
  31. package/dist/components/chunks/{confirm-action-ChDVVaGR.js → confirm-action-86hDdUKT.js} +1 -1
  32. package/dist/components/chunks/{confirm-action-FF25UbZj.js → confirm-action-CX_FEzCR.js} +2 -2
  33. package/dist/components/chunks/{date-picker-DGXeCDmc.js → date-picker-Bqre6M4g.js} +4 -4
  34. package/dist/components/chunks/{date-picker-C5srl0J1.js → date-picker-CBucQNne.js} +1 -1
  35. package/dist/components/chunks/{icon-B8hR_TFn.js → icon-CWOP4Com.js} +6 -6
  36. package/dist/components/chunks/icon-D6C1XGp2.js +1 -0
  37. package/dist/components/chunks/{icon-D7kATeRr.js → icon-hyFz3uhh.js} +181 -171
  38. package/dist/components/chunks/icon-l34kRIZg.js +1 -0
  39. package/dist/components/chunks/{input-C1O8znJn.js → input-Br2qLesW.js} +1 -1
  40. package/dist/components/chunks/{input-B3XZ9L6B.js → input-j6FCwb-x.js} +3 -3
  41. package/dist/components/chunks/{modal-DEl06xn_.js → modal-BEv3P1P0.js} +2 -2
  42. package/dist/components/chunks/{modal-CEH_XEC0.js → modal-ux6cqTde.js} +1 -1
  43. package/dist/components/chunks/{search-EHzNkMA7.js → search-BwjKBnv9.js} +1 -1
  44. package/dist/components/chunks/search-q3dkl4-X.js +1 -0
  45. package/dist/components/chunks/{time-picker-DJ_Z6L5m.js → time-picker-CxdBZbER.js} +1 -1
  46. package/dist/components/chunks/{time-picker-NlZ9LSyD.js → time-picker-DY5emLWw.js} +2 -2
  47. package/dist/components/chunks/{warning-D4JUMfwk.js → warning-DAYbxh3S.js} +1 -1
  48. package/dist/components/chunks/{warning-fwqtKFLY.js → warning-DKCaTYO6.js} +1 -1
  49. package/dist/components/confirm-action/browser.js +1 -1
  50. package/dist/components/confirm-action/index.cjs +1 -1
  51. package/dist/components/confirm-action/index.js +1 -1
  52. package/dist/components/date-picker/browser.js +1 -1
  53. package/dist/components/date-picker/index.cjs +1 -1
  54. package/dist/components/date-picker/index.js +1 -1
  55. package/dist/components/datetime-picker/browser.js +3 -3
  56. package/dist/components/datetime-picker/index.cjs +1 -1
  57. package/dist/components/datetime-picker/index.js +3 -3
  58. package/dist/components/dropzone/browser.js +4 -4
  59. package/dist/components/dropzone/index.cjs +1 -1
  60. package/dist/components/dropzone/index.js +4 -4
  61. package/dist/components/icon/browser.js +1 -1
  62. package/dist/components/icon/icons/funnel.d.ts +3 -0
  63. package/dist/components/icon/icons/funnel.d.ts.map +1 -0
  64. package/dist/components/icon/icons/index.d.ts +1 -0
  65. package/dist/components/icon/icons/index.d.ts.map +1 -1
  66. package/dist/components/icon/index.cjs +1 -1
  67. package/dist/components/icon/index.js +1 -1
  68. package/dist/components/input/browser.js +1 -1
  69. package/dist/components/input/index.cjs +1 -1
  70. package/dist/components/input/index.js +1 -1
  71. package/dist/components/modal/browser.js +1 -1
  72. package/dist/components/modal/index.cjs +1 -1
  73. package/dist/components/modal/index.js +1 -1
  74. package/dist/components/navigation/browser.js +2 -2
  75. package/dist/components/navigation/index.cjs +1 -1
  76. package/dist/components/navigation/index.js +2 -2
  77. package/dist/components/off-canvas/browser.js +2 -2
  78. package/dist/components/off-canvas/index.cjs +1 -1
  79. package/dist/components/off-canvas/index.js +2 -2
  80. package/dist/components/page/browser.js +3 -3
  81. package/dist/components/page/index.cjs +1 -1
  82. package/dist/components/page/index.js +3 -3
  83. package/dist/components/resource-table/ResourceTable.d.ts +2 -0
  84. package/dist/components/resource-table/ResourceTable.d.ts.map +1 -1
  85. package/dist/components/resource-table/browser.js +56 -49
  86. package/dist/components/resource-table/index.cjs +2 -2
  87. package/dist/components/resource-table/index.js +56 -49
  88. package/dist/components/search/browser.js +7 -7
  89. package/dist/components/search/index.cjs +1 -1
  90. package/dist/components/search/index.js +7 -7
  91. package/dist/components/select/browser.js +2 -2
  92. package/dist/components/select/index.cjs +1 -1
  93. package/dist/components/select/index.js +2 -2
  94. package/dist/components/side-navigation/browser.js +4 -4
  95. package/dist/components/side-navigation/index.cjs +1 -1
  96. package/dist/components/side-navigation/index.js +4 -4
  97. package/dist/components/switch/browser.js +2 -2
  98. package/dist/components/switch/index.cjs +1 -1
  99. package/dist/components/switch/index.js +2 -2
  100. package/dist/components/tabs/browser.js +1 -1
  101. package/dist/components/tabs/index.cjs +1 -1
  102. package/dist/components/tabs/index.js +1 -1
  103. package/dist/components/tags/browser.js +3 -3
  104. package/dist/components/tags/index.cjs +1 -1
  105. package/dist/components/tags/index.js +3 -3
  106. package/dist/components/time-picker/browser.js +1 -1
  107. package/dist/components/time-picker/index.cjs +1 -1
  108. package/dist/components/time-picker/index.js +1 -1
  109. package/dist/components/tree/browser.js +3 -3
  110. package/dist/components/tree/index.cjs +1 -1
  111. package/dist/components/tree/index.js +3 -3
  112. package/dist/icons/funnel.svg +3 -0
  113. package/dist/index.cjs +11 -11
  114. package/dist/index.js +386 -369
  115. package/dist/navigation-search.json +7 -0
  116. package/package.json +1 -1
  117. package/dist/components/chunks/caret-down-BC4shv_d.js +0 -1
  118. package/dist/components/chunks/caret-right-jB9sLJG2.js +0 -1
  119. package/dist/components/chunks/close-BNbAeJPY.js +0 -1
  120. package/dist/components/chunks/icon-BQqwHk-o.js +0 -1
  121. package/dist/components/chunks/icon-CzgI_MCf.js +0 -1
  122. package/dist/components/chunks/search-TahAPcYA.js +0 -1
@@ -7,16 +7,16 @@ import '../../spinner.css'
7
7
  import '../../popover.css'
8
8
  import '../../stack.css'
9
9
  import '../../resource-table.css'
10
- import "../chunks/icon-D7kATeRr.js";
10
+ import "../chunks/icon-hyFz3uhh.js";
11
11
  import { t as e } from "../chunks/register-element-BFYmIynH.js";
12
- import "../chunks/icon-BQqwHk-o.js";
12
+ import "../chunks/icon-l34kRIZg.js";
13
13
  import "../chunks/spinner-B2sml0AG.js";
14
- import "../chunks/button-CUWUQAt8.js";
15
- import "../chunks/input-B3XZ9L6B.js";
16
- import "../chunks/caret-down-oeRBseTW.js";
14
+ import "../chunks/button-JPTyQfRs.js";
15
+ import "../chunks/input-j6FCwb-x.js";
16
+ import "../chunks/caret-down-ZjQN2yKq.js";
17
17
  import "../chunks/popover-C1qiTAvR.js";
18
18
  import { n as t } from "../chunks/ScrollFade-DvzPIk2A.js";
19
- import "../chunks/search-EHzNkMA7.js";
19
+ import "../chunks/search-BwjKBnv9.js";
20
20
  import "../chunks/table-B_g7lNzN.js";
21
21
  //#region src/components/resource-table/utility-aliases.js
22
22
  var n = {
@@ -198,7 +198,7 @@ var n = {
198
198
  return e !== null && e !== "false";
199
199
  }
200
200
  constructor() {
201
- super(), this._configuration = null, this._rows = [], this._search = "", this._currentPage = 1, this._perPage = 15, this._totalRows = 0, this._lastPage = 0, this._offset = 0, this._loaded = !1, this._fetching = !1, this._loading = !1, this._loadingPage = null, this._fetchError = null, this._searching = !1, this._sorting = !1, this._sortingColumnData = null, this._type = "provided", this._searchTimeoutId = null, this._sortTimeoutId = null, this._searchColumns = [], this._exportColumns = {}, this._columns = [], this._tableId = "", this._searchInput = null, this._tableContainer = null, this._paginationContainer = null, this._skeletonContainer = null, this._inMintCard = !1, this._virtualBodyScrollEl = null, this._disposeVirtualBodyFade = null, this._virtualScrollHandler = null, this._virtualWindowRaf = null, this._virtualLastRangeStart = -1, this._virtualLastRangeEnd = -1, this._virtualLastRangeCacheSig = "", this._virtualResizeObserver = null, this._virtualWindowResizeHandler = null, this._virtualRowCache = /* @__PURE__ */ new Map(), this._virtualRangeFetching = !1, this._mobileListMql = null, this._boundMobileListMqlListener = null, this._virtualFetchGeneration = 0, this._virtualAjaxPrefetchTimer = null, this._fixedChromeResizeObserver = null, this._utilityClassObserver = null;
201
+ super(), this._configuration = null, this._rows = [], this._search = "", this._currentPage = 1, this._perPage = 15, this._totalRows = 0, this._lastPage = 0, this._offset = 0, this._loaded = !1, this._fetching = !1, this._loading = !1, this._loadingPage = null, this._fetchError = null, this._searching = !1, this._sorting = !1, this._sortingColumnData = null, this._type = "provided", this._searchTimeoutId = null, this._sortTimeoutId = null, this._searchColumns = [], this._exportColumns = {}, this._columns = [], this._tableId = "", this._searchInput = null, this._tableContainer = null, this._paginationContainer = null, this._skeletonContainer = null, this._inMintCard = !1, this._virtualBodyScrollEl = null, this._disposeVirtualBodyFade = null, this._virtualScrollHandler = null, this._virtualWindowRaf = null, this._virtualLastRangeStart = -1, this._virtualLastRangeEnd = -1, this._virtualLastRangeCacheSig = "", this._virtualResizeObserver = null, this._virtualWindowResizeHandler = null, this._virtualRowCache = /* @__PURE__ */ new Map(), this._virtualRangeFetching = !1, this._mobileListMql = null, this._boundMobileListMqlListener = null, this._initialMobileLayoutRaf = null, this._virtualFetchGeneration = 0, this._virtualAjaxPrefetchTimer = null, this._fixedChromeResizeObserver = null, this._utilityClassObserver = null;
202
202
  }
203
203
  get inMintCard() {
204
204
  return this._inMintCard;
@@ -218,7 +218,7 @@ var n = {
218
218
  }), this._inMintCard = this.closest("mint-card") !== null, this._configuration || this._parseConfiguration(), this._initializeColumns(), this._loadPageFromUrl(), this._attachRowClickHandler(), this.render();
219
219
  }
220
220
  disconnectedCallback() {
221
- this._searchTimeoutId && clearTimeout(this._searchTimeoutId), this._detachVirtualScroll(), this._detachFixedChromeResize(), this._detachMobileListMql(), this._utilityClassObserver?.disconnect(), this._utilityClassObserver = null, this._rowClickHandler &&= (this.removeEventListener("click", this._rowClickHandler, !0), null), this._scrollHandler &&= (window.removeEventListener("scroll", this._scrollHandler), null);
221
+ this._searchTimeoutId && clearTimeout(this._searchTimeoutId), this._detachVirtualScroll(), this._detachFixedChromeResize(), this._detachMobileListMql(), this._initialMobileLayoutRaf !== null && (window.cancelAnimationFrame(this._initialMobileLayoutRaf), this._initialMobileLayoutRaf = null), this._utilityClassObserver?.disconnect(), this._utilityClassObserver = null, this._rowClickHandler &&= (this.removeEventListener("click", this._rowClickHandler, !0), null), this._scrollHandler &&= (window.removeEventListener("scroll", this._scrollHandler), null);
222
222
  }
223
223
  attributeChangedCallback(e, t, n) {
224
224
  e === "configuration" && t !== n ? (!this._configuration || typeof n == "string") && (this._parseConfiguration(), this.render()) : t !== n && (e === "loading" || e === "virtual-scroll" || e === "virtual-scroll-root" || e === "virtual-row-height" || e === "virtual-max-height" || e === "fixed-header" || e === "fixed-controls") && this._configuration && this.isConnected && this.render();
@@ -465,7 +465,12 @@ var n = {
465
465
  this._mobileListMql && this._boundMobileListMqlListener && this._mobileListMql.removeEventListener("change", this._boundMobileListMqlListener), this._mobileListMql = null, this._boundMobileListMqlListener = null;
466
466
  }
467
467
  _useMobileListLayout() {
468
- return !!this._mobileListMql?.matches;
468
+ return this._mobileListMql ? this._mobileListMql.matches : typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(max-width: 767px)").matches : !1;
469
+ }
470
+ _scheduleInitialMobileLayoutSync(e) {
471
+ this._initialMobileLayoutRaf !== null || typeof window.requestAnimationFrame != "function" || (this._initialMobileLayoutRaf = window.requestAnimationFrame(() => {
472
+ this._initialMobileLayoutRaf = null, this.isConnected && this._configuration && this._useMobileListLayout() !== e && this.render();
473
+ }));
469
474
  }
470
475
  _paginationHostPlaceholderHtml() {
471
476
  if (!this._configuration?.perPage || this._virtualScrollActive()) return "";
@@ -618,7 +623,7 @@ var n = {
618
623
  }
619
624
  _buildTableCellInnerHtml(e, t, n, r = "table") {
620
625
  if (!this._configuration) return "";
621
- let i = n, a = "";
626
+ let i = n, a = "", o = r === "mobile" ? "mobile" : "desktop";
622
627
  if (!(!e.show || e.show(this, t))) return "";
623
628
  if (e.raw) if (e.action) {
624
629
  if (!e.action.show || e.action.show(this, t)) {
@@ -626,7 +631,7 @@ var n = {
626
631
  a += `<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(n))}</mint-button>`;
627
632
  }
628
633
  } else if (e.actions) if (e.actionStyle !== "buttons") {
629
- let n = `actions-popover-${this._tableId}-${i}`, r = `actions-button-${this._tableId}-${i}`;
634
+ let n = `actions-popover-${this._tableId}-${o}-${i}`, r = `actions-button-${this._tableId}-${o}-${i}`;
630
635
  a += `<mint-button id="${r}" variant="ghost" icon="ellipsis">`, a += "</mint-button>", a += `<mint-popover id="${n}" trigger-id="${r}" direction="down">`, a += "<div class=\"mint-resource-action-menu\">", e.actions.forEach((n, r) => {
631
636
  if (!n.show || n.show(this, t)) {
632
637
  let o = typeof n.label == "function" ? n.label(this, t) : n.label, s = n.icon ? ` icon="${this._escapeHtml(n.icon)}"` : "", c = n.variant ? this._escapeHtml(n.variant) : "ghost", l = n.tone ? ` tone="${this._escapeHtml(n.tone)}"` : "", u = (typeof n.active == "function" ? n.active(this, t) : n.active) ? " active=\"true\"" : "";
@@ -642,7 +647,7 @@ var n = {
642
647
  else typeof e.format == "function" ? a += e.format(this, t) : e.data && (a += this._escapeHtml(String(t[e.data] || "")));
643
648
  else if (e.action) (!e.action.show || e.action.show(this, t)) && (a += `<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${e.action.label}</mint-button>`);
644
649
  else if (e.actions) if (e.actionStyle !== "buttons") {
645
- let n = `actions-popover-${this._tableId}-${i}`, r = `actions-button-${this._tableId}-${i}`;
650
+ let n = `actions-popover-${this._tableId}-${o}-${i}`, r = `actions-button-${this._tableId}-${o}-${i}`;
646
651
  a += `<mint-button id="${r}" variant="ghost" icon="ellipsis">`, a += "</mint-button>", a += `<mint-popover id="${n}" trigger-id="${r}" direction="down">`, a += "<div class=\"mint-resource-action-menu\">", e.actions.forEach((n, r) => {
647
652
  if (!n.show || n.show(this, t)) {
648
653
  let o = typeof n.label == "function" ? n.label(this, t) : n.label, s = n.icon ? ` icon="${this._escapeHtml(n.icon)}"` : "", c = n.variant ? this._escapeHtml(n.variant) : "ghost", l = n.tone ? ` tone="${this._escapeHtml(n.tone)}"` : "", u = (typeof n.active == "function" ? n.active(this, t) : n.active) ? " active=\"true\"" : "";
@@ -1145,12 +1150,14 @@ var n = {
1145
1150
  return;
1146
1151
  }
1147
1152
  this._ensureMobileListMql();
1148
- let e = String(this._configuration.id || "").trim();
1149
- e && (this.id = e), this._detachVirtualScroll(), this._detachFixedChromeResize(), this._virtualScrollActive() || this._virtualRowCache.clear();
1150
- let t = !this._loaded || this._rows.length > 0 || this._search.length > 0 || this._searching || this._configuration.showSearch !== !1 || !!this._configuration.buttons?.length, n = this._getRows();
1153
+ let e = this._useMobileListLayout();
1154
+ this._scheduleInitialMobileLayoutSync(e);
1155
+ let t = String(this._configuration.id || "").trim();
1156
+ t && (this.id = t), this._detachVirtualScroll(), this._detachFixedChromeResize(), this._virtualScrollActive() || this._virtualRowCache.clear();
1157
+ let n = !this._loaded || this._rows.length > 0 || this._search.length > 0 || this._searching || this._configuration.showSearch !== !1 || !!this._configuration.buttons?.length, r = this._getRows();
1151
1158
  this._lastPage || Math.ceil(this._rows.length / this._perPage);
1152
- let r = this._isExternalLoading(), i = "";
1153
- if (t) {
1159
+ let i = this._isExternalLoading(), a = "";
1160
+ if (n) {
1154
1161
  let e = this._fixedControls(), t = [
1155
1162
  "flex",
1156
1163
  "items-center",
@@ -1158,60 +1165,60 @@ var n = {
1158
1165
  this._inMintCard ? "p-3.5" : "mb-3",
1159
1166
  e ? "sticky top-0 z-20 bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider" : ""
1160
1167
  ].filter(Boolean).join(" ");
1161
- if (i += `<div id="mint-rt-fixed-controls-${this._tableId}" class="${t}">`, i += "<div class=\"flex min-w-0 flex-1 items-center gap-2\">", i += this._buildMobileSortToolbarHtml(), i += this._toolbarButtonsHtml("left"), this._configuration.showSearch !== !1) {
1168
+ if (a += `<div id="mint-rt-fixed-controls-${this._tableId}" class="${t}">`, a += "<div class=\"flex min-w-0 flex-1 items-center gap-2\">", a += this._buildMobileSortToolbarHtml(), a += this._toolbarButtonsHtml("left"), this._configuration.showSearch !== !1) {
1162
1169
  let e = `search-${this._tableId}`, t = this._escapeHtml(this._configuration.searchPlaceholder || "Search...");
1163
- i += `<mint-input id="${e}" type="search" label="" placeholder="${t}" class="min-w-0 flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`;
1170
+ a += `<mint-input id="${e}" type="search" label="" placeholder="${t}" class="min-w-0 flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`;
1164
1171
  }
1165
- i += this._toolbarButtonsHtml("right"), i += "</div>", i += "</div>";
1172
+ a += this._toolbarButtonsHtml("right"), a += "</div>", a += "</div>";
1166
1173
  }
1167
- if ((this._type === "ajax" && !this._loaded || this._type === "provided" && r) && !this._fetchError && !this._sorting) {
1174
+ if ((this._type === "ajax" && !this._loaded || this._type === "provided" && i) && !this._fetchError && !this._sorting) {
1168
1175
  let e = this._fixedHeader() ? " data-mint-rt-scroll-inner=\"\"" : "", t = this._fixedHeader() && this._fixedControls(), n = this._fixedHeader() ? t ? "sticky top-[var(--mint-rt-fixed-controls-h,0px)] z-30 " : "sticky top-0 z-30 " : "sticky top-0 z-10 ";
1169
- i += "<div class=\"min-w-0\">", i += "<mint-table class=\"table-section" + (this._inMintCard ? " rounded-t-none" : "") + "\"" + e + ">", i += `<table id="${this._tableId}">`, i += "<thead class=\"" + n + "bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider\"><tr>", this._configuration.columns.forEach((e, t) => {
1176
+ a += "<div class=\"min-w-0\">", a += "<mint-table class=\"table-section" + (this._inMintCard ? " rounded-t-none" : "") + "\"" + e + ">", a += `<table id="${this._tableId}">`, a += "<thead class=\"" + n + "bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider\"><tr>", this._configuration.columns.forEach((e, t) => {
1170
1177
  if (e.hidden) return;
1171
1178
  let n = e.sortable ? " data-mint-rt-sortable=\"\"" : "";
1172
- if (i += `<th width="${e.width || ""}" style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${n}>`, e.showLabel !== !1) {
1173
- if (i += "<div class=\"flex items-center\" data-mint-rt-sort-label>", i += `<div class="flex-1">${e.raw ? e.label : this._escapeHtml(e.label)}</div>`, e.sortable) {
1179
+ if (a += `<th width="${e.width || ""}" style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${n}>`, e.showLabel !== !1) {
1180
+ if (a += "<div class=\"flex items-center\" data-mint-rt-sort-label>", a += `<div class="flex-1">${e.raw ? e.label : this._escapeHtml(e.label)}</div>`, e.sortable) {
1174
1181
  let t = this._getSortClass(e);
1175
- t === "spinner" ? i += "<div class=\"ml-2 flex items-center\" data-mint-rt-sort-icon><mint-spinner class=\"w-4 h-4\"></mint-spinner></div>" : (t === "caret-up" || t === "caret-down") && (i += `<div class="ml-2 flex items-center" data-mint-rt-sort-icon><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`);
1182
+ t === "spinner" ? a += "<div class=\"ml-2 flex items-center\" data-mint-rt-sort-icon><mint-spinner class=\"w-4 h-4\"></mint-spinner></div>" : (t === "caret-up" || t === "caret-down") && (a += `<div class="ml-2 flex items-center" data-mint-rt-sort-icon><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`);
1176
1183
  }
1177
- i += "</div>";
1184
+ a += "</div>";
1178
1185
  }
1179
- i += "</th>";
1180
- }), i += "</tr></thead>", i += "<tbody>";
1181
- for (let e = 0; e < 4; e++) i += "<tr>", this._configuration.columns.forEach((e) => {
1186
+ a += "</th>";
1187
+ }), a += "</tr></thead>", a += "<tbody>";
1188
+ for (let e = 0; e < 4; e++) a += "<tr>", this._configuration.columns.forEach((e) => {
1182
1189
  if (!e.hidden) {
1183
- if (i += `<td style="${this._getStyle(e)}" class="${this._getClasses(e, !0)}">`, e.thumbnail) {
1190
+ if (a += `<td style="${this._getStyle(e)}" class="${this._getClasses(e, !0)}">`, e.thumbnail) {
1184
1191
  let t = this._thumbnailDesktopPx(e);
1185
- i += `<div class="rounded-md bg-gray-200 dark:bg-white/15 animate-pulse" style="width:${t}px;height:${t}px;box-sizing:border-box"></div>`;
1186
- } else i += "<div class=\"h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15 animate-pulse\"></div>";
1187
- i += "</td>";
1192
+ a += `<div class="rounded-md bg-gray-200 dark:bg-white/15 animate-pulse" style="width:${t}px;height:${t}px;box-sizing:border-box"></div>`;
1193
+ } else a += "<div class=\"h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15 animate-pulse\"></div>";
1194
+ a += "</td>";
1188
1195
  }
1189
- }), i += "</tr>";
1190
- i += "</tbody>", i += "</table>", i += "</mint-table>", i += "</div>", i += this._paginationHostPlaceholderHtml();
1196
+ }), a += "</tr>";
1197
+ a += "</tbody>", a += "</table>", a += "</mint-table>", a += "</div>", a += this._paginationHostPlaceholderHtml();
1191
1198
  } else {
1192
- let e = this._virtualScrollActive() && (this._type === "provided" || this._type === "ajax" && this._loaded && !this._fetchError), t = e && this._virtualScrollRoot() === "table-body", a = this._escapeHtml(this._virtualMaxHeightCss()), o = t || this._fixedHeader(), s = this._fixedHeader() && this._fixedControls(), c = o ? " data-mint-rt-scroll-inner=\"\"" : "", l = "table-section" + (this._inMintCard ? " rounded-t-none" : ""), u = `mint-resource-table-mobile-list m-0 min-h-0 w-full list-none border-collapse overflow-x-hidden ${this._inMintCard ? "px-3.5 py-3.5" : "py-3"} md:hidden`, d = "";
1199
+ let e = this._virtualScrollActive() && (this._type === "provided" || this._type === "ajax" && this._loaded && !this._fetchError), t = e && this._virtualScrollRoot() === "table-body", n = this._escapeHtml(this._virtualMaxHeightCss()), o = t || this._fixedHeader(), s = this._fixedHeader() && this._fixedControls(), c = o ? " data-mint-rt-scroll-inner=\"\"" : "", l = "table-section" + (this._inMintCard ? " rounded-t-none" : ""), u = `mint-resource-table-mobile-list m-0 min-h-0 w-full list-none border-collapse overflow-x-hidden ${this._inMintCard ? "px-3.5 py-3.5" : "py-3"} md:hidden`, d = "";
1193
1200
  if (t) {
1194
1201
  let e = this._renderColgroupHtml();
1195
- i += `<div id="mint-rt-vscroll-${this._tableId}" class="overflow-y-auto overflow-x-auto min-h-0 w-full" style="max-height: ${a}; scrollbar-gutter: stable; overscroll-behavior-x: contain; overscroll-behavior-y: none; overflow-anchor: none;">`, i += "<div class=\"hidden min-h-0 min-w-0 md:block\">", i += `<mint-table class="${l}"${c}>`, i += `<table id="${this._tableId}" class="w-full min-w-0 table-fixed">`, i += e, i += this._renderTheadHtml(!0, !0, !0, s);
1196
- } else i += "<div class=\"hidden min-h-0 min-w-0 md:block\">", i += `<mint-table class="${l}"${c}>`, i += `<table id="${this._tableId}">`, e && (i += this._renderColgroupHtml()), i += this._renderTheadHtml(!0, !0, !!e, s);
1197
- if (i += "<tbody" + (e ? ` data-mint-rt-tbody="${this._tableId}"` : "") + ">", !this._fetching && !this._loading && !r && !e && n.forEach((e, t) => {
1198
- d += this._buildMobileListItemHtml(e, t, t === n.length - 1);
1199
- let r = typeof this._configuration.onRowClick == "function", a = r ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated" : "";
1200
- i += `<tr data-row-index="${t}" ${r ? "data-row-clickable=\"true\"" : ""}${a ? ` class="${a}"` : ""}>`, this._configuration.columns.forEach((n) => {
1202
+ a += `<div id="mint-rt-vscroll-${this._tableId}" class="overflow-y-auto overflow-x-auto min-h-0 w-full" style="max-height: ${n}; scrollbar-gutter: stable; overscroll-behavior-x: contain; overscroll-behavior-y: none; overflow-anchor: none;">`, a += "<div class=\"hidden min-h-0 min-w-0 md:block\">", a += `<mint-table class="${l}"${c}>`, a += `<table id="${this._tableId}" class="w-full min-w-0 table-fixed">`, a += e, a += this._renderTheadHtml(!0, !0, !0, s);
1203
+ } else a += "<div class=\"hidden min-h-0 min-w-0 md:block\">", a += `<mint-table class="${l}"${c}>`, a += `<table id="${this._tableId}">`, e && (a += this._renderColgroupHtml()), a += this._renderTheadHtml(!0, !0, !!e, s);
1204
+ if (a += "<tbody" + (e ? ` data-mint-rt-tbody="${this._tableId}"` : "") + ">", !this._fetching && !this._loading && !i && !e && r.forEach((e, t) => {
1205
+ d += this._buildMobileListItemHtml(e, t, t === r.length - 1);
1206
+ let n = typeof this._configuration.onRowClick == "function", i = n ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated" : "";
1207
+ a += `<tr data-row-index="${t}" ${n ? "data-row-clickable=\"true\"" : ""}${i ? ` class="${i}"` : ""}>`, this._configuration.columns.forEach((n) => {
1201
1208
  if (n.hidden) return;
1202
1209
  let r = !n.show || n.show(this, e);
1203
- i += `<td style="${this._getStyle(n)}" class="${this._getClasses(n, !0)}">`, r && (i += this._buildTableCellInnerHtml(n, e, t, "table")), i += "</td>";
1204
- }), i += "</tr>";
1205
- }), !this._fetching && !this._loading && !r && n.length === 0) if (this._fetchError) {
1210
+ a += `<td style="${this._getStyle(n)}" class="${this._getClasses(n, !0)}">`, r && (a += this._buildTableCellInnerHtml(n, e, t, "table")), a += "</td>";
1211
+ }), a += "</tr>";
1212
+ }), !this._fetching && !this._loading && !i && r.length === 0) if (this._fetchError) {
1206
1213
  let e = this._configuration.columns.filter((e) => !e.hidden).length;
1207
- i += `<tr><td colspan="${e}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`, d += `<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`;
1214
+ a += `<tr><td colspan="${e}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`, d += `<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`;
1208
1215
  } else {
1209
1216
  let e = this._configuration.columns.filter((e) => !e.hidden).length;
1210
- i += `<tr><td colspan="${e}" class="text-center py-8">No data available.</td></tr>`, d += "<li class=\"list-none px-4 py-8 text-center text-sm\">No data available.</li>";
1217
+ a += `<tr><td colspan="${e}" class="text-center py-8">No data available.</td></tr>`, d += "<li class=\"list-none px-4 py-8 text-center text-sm\">No data available.</li>";
1211
1218
  }
1212
- i += "</tbody>", i += "</table>", i += "</mint-table>", i += "</div>", i += `<ul class="${u}" data-mint-rt-mobile-list="${this._tableId}">${e && n.length > 0 ? "" : d}</ul>`, e || (i += this._paginationHostPlaceholderHtml()), t && (i += "</div>");
1219
+ a += "</tbody>", a += "</table>", a += "</mint-table>", a += "</div>", a += `<ul class="${u}" data-mint-rt-mobile-list="${this._tableId}">${e && r.length > 0 ? "" : d}</ul>`, e || (a += this._paginationHostPlaceholderHtml()), t && (a += "</div>");
1213
1220
  }
1214
- this._fixedHeader() ? this.setAttribute("data-mint-rt-fixed-header", "") : this.removeAttribute("data-mint-rt-fixed-header"), this._fixedControls() ? this.setAttribute("data-mint-rt-fixed-controls", "") : this.removeAttribute("data-mint-rt-fixed-controls"), this.innerHTML = i, this._replaceUtilityClasses(), this._updatePagination(), this.querySelectorAll("mint-button[data-action]").forEach((e) => {
1221
+ this._fixedHeader() ? this.setAttribute("data-mint-rt-fixed-header", "") : this.removeAttribute("data-mint-rt-fixed-header"), this._fixedControls() ? this.setAttribute("data-mint-rt-fixed-controls", "") : this.removeAttribute("data-mint-rt-fixed-controls"), this.innerHTML = a, this._replaceUtilityClasses(), this._updatePagination(), this.querySelectorAll("mint-button[data-action]").forEach((e) => {
1215
1222
  e.render && e.render();
1216
1223
  }), this.querySelectorAll("mint-button[data-mint-rt-toolbar]").forEach((e) => {
1217
1224
  e.render && e.render();
@@ -17,14 +17,14 @@ __mintLoadStyle('input', '../../input.css')
17
17
  __mintLoadStyle('button', '../../button.css')
18
18
  __mintLoadStyle('spinner', '../../spinner.css')
19
19
  __mintLoadStyle('search', '../../search.css')
20
- import "../chunks/icon-D7kATeRr.js";
20
+ import "../chunks/icon-hyFz3uhh.js";
21
21
  import { t as e } from "../chunks/register-element-BFYmIynH.js";
22
- import "../chunks/icon-BQqwHk-o.js";
23
- import "../chunks/close-C5b9RhcK.js";
24
- import "../chunks/button-CUWUQAt8.js";
25
- import "../chunks/chip-CbfqkmGQ.js";
26
- import "../chunks/input-B3XZ9L6B.js";
27
- import "../chunks/search-EHzNkMA7.js";
22
+ import "../chunks/icon-l34kRIZg.js";
23
+ import "../chunks/close-Cn8XLO1c.js";
24
+ import "../chunks/button-JPTyQfRs.js";
25
+ import "../chunks/chip-XuYPtZ3Z.js";
26
+ import "../chunks/input-j6FCwb-x.js";
27
+ import "../chunks/search-BwjKBnv9.js";
28
28
  //#region src/components/search/Search.ts
29
29
  var t = class e extends HTMLElement {
30
30
  constructor(...e) {
@@ -1 +1 @@
1
- require(`../chunks/icon-B8hR_TFn.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-CzgI_MCf.js`),require(`../chunks/close-BNbAeJPY.js`),require(`../chunks/button-imX8FM_Q.js`),require(`../chunks/chip-BeGxDLpQ.js`),require(`../chunks/input-C1O8znJn.js`),require(`../chunks/search-TahAPcYA.js`);var t=class e extends HTMLElement{constructor(...e){super(...e),this._shell=null,this._desktopInput=null,this._panel=null,this._panelInner=null,this._resultsId=``,this._panelInput=null,this._panelFiltersWrap=null,this._panelFiltersMainRow=null,this._panelFiltersChips=null,this._panelFiltersShowAllWrap=null,this._panelFiltersShowAllBtn=null,this._panelFiltersMorePanel=null,this._filtersMoreOpen=!1,this._filterOverflowObserver=null,this._filterOverflowZeroWidthRetries=0,this._desktopFilterWrap=null,this._mobileFilterWrap=null,this._resultsWrap=null,this._stateWrap=null,this._customResultsWrap=null,this._query=``,this._searchOpen=!1,this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._debounceId=null,this._abortController=null,this._docPointerDownHandler=null,this._globalKeydownHandler=null,this._focusOutHandler=null,this._resizeHandler=null,this._scrollHandler=null,this._desktopShortcutHint=null,this._panelSearchBar=null,this._contentObserver=null,this._renderFrame=null}static{this._filterMorePanelSeq=0}static{this._filterChipsOverflowMask=`linear-gradient(to right, #000 0%, #000 max(0%, calc(100% - 3.5rem)), transparent 100%)`}static get observedAttributes(){return[`endpoint`,`search-param`,`placeholder`,`filters`,`filter-param`,`open-shortcut`,`open-shortcut-hint`,`collapse-on-mobile`,`results-limit`]}connectedCallback(){this.classList.add(`mint-search-host`),this._attachGlobalHandlers(),this._attachFocusOutHandler(),this._attachResizeHandler(),this.render(),this._observeContentMutations()}disconnectedCallback(){this._panel?.remove(),this._docPointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._docPointerDownHandler,!0),null),this._globalKeydownHandler&&=(document.removeEventListener(`keydown`,this._globalKeydownHandler),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null),this._scrollHandler&&=(document.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._focusOutHandler&&=(this.removeEventListener(`focusout`,this._focusOutHandler,!0),null),this._cancelDebounce(),this._abortSearch(),this._filterOverflowObserver&&=(this._filterOverflowObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getEndpoint(){return(this.getAttribute(`endpoint`)||``).trim()}_getSearchParam(){return(this.getAttribute(`search-param`)||`q`).trim()||`q`}_getPlaceholder(){return this.getAttribute(`placeholder`)||`Search`}_getFilterParam(){return(this.getAttribute(`filter-param`)||``).trim()}_getFilterOptions(){return(this.getAttribute(`filters`)||``).split(`,`).map(e=>e.trim()).filter(Boolean)}_hasSelectedFilters(){return this._selectedFilters.length>0}_getFilterChipOverflowReservePx(){let e=Math.max(1,this._getFilterOptions().length),t=this._hasSelectedFilters()?28:56;return Math.min(200,t+e*34)}_getFilterParamValue(){return this._selectedFilters.join(`,`)}_getFilterChipLabelText(){return this._selectedFilters.join(`, `)}_getCondensedFilterChipLabel(e=22){if(!this._hasSelectedFilters())return``;let[t=``]=this._selectedFilters,n=this._selectedFilters.length-1,r=Math.max(8,e-2),i=t;if(n<=0)return i.length<=r?i:`${i.slice(0,Math.max(1,r-3))}...`;let a=`${t}, and ${n} more`;return a.length<=r?a:`${a.slice(0,Math.max(1,r-3))}...`}_isMobileViewport(){return window.matchMedia(`(max-width: 1099.98px)`).matches}_collapseOnMobile(){let e=this.getAttribute(`collapse-on-mobile`);if(e===null)return!1;let t=e.trim().toLowerCase();return!(t===`false`||t===`0`||t===`off`||t===`none`)}_primarySearchInput(){return this._isMobileViewport()&&this._collapseOnMobile()?this._panelInput:this._desktopInput}_isApplePlatform(){return typeof navigator>`u`?!1:/Mac|iPhone|iPad|iPod/i.test(navigator.platform)||/Mac OS/i.test(navigator.userAgent)}_parseOpenShortcut(){let e=(this.getAttribute(`open-shortcut`)??`mod+k`).trim().toLowerCase();if(!e||e===`none`||e===`false`||e===`off`)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let t=e.split(`+`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let n=t[t.length-1],r=new Set(t.slice(0,-1).map(e=>e.toLowerCase()));return{disabled:!1,wantMod:r.has(`mod`),wantMeta:r.has(`meta`)||r.has(`cmd`)||r.has(`super`),wantCtrl:r.has(`ctrl`)||r.has(`control`),wantAlt:r.has(`alt`),wantShift:r.has(`shift`),key:n.toLowerCase()}}_eventKeyMatchesShortcutKey(e,t){let n=t.toLowerCase();return(e.key.length,e.key.toLowerCase())===n}_openShortcutMatches(e){let t=this._parseOpenShortcut();return t.disabled||!t.key||e.repeat||!this._eventKeyMatchesShortcutKey(e,t.key)||t.wantShift!==e.shiftKey||t.wantAlt!==e.altKey?!1:t.wantMod||t.wantMeta||t.wantCtrl?!(t.wantMod&&!(e.metaKey||e.ctrlKey)||t.wantMeta&&!e.metaKey||t.wantCtrl&&!e.ctrlKey):!!t.wantAlt}_getOpenShortcutHintText(){let e=this.getAttribute(`open-shortcut-hint`);if(e===`none`||e===`false`)return``;if(e!==null&&e.trim()!==``)return e.trim();let t=this._parseOpenShortcut();if(t.disabled)return``;let n=this._isApplePlatform(),r=[];t.wantMod&&r.push(n?`⌘`:`Ctrl`),t.wantMeta&&!t.wantMod&&r.push(n?`⌘`:`Meta`),t.wantCtrl&&!t.wantMod&&r.push(`Ctrl`),t.wantAlt&&r.push(`Alt`),t.wantShift&&r.push(`Shift`);let i=t.key.length===1?t.key.toUpperCase():t.key;return i?t.wantMod&&!t.wantMeta&&!t.wantCtrl&&!t.wantAlt&&!t.wantShift&&t.key.length===1?`${n?`⌘`:`Ctrl+`}${i}`:[...r,i].join(`+`):``}_attachGlobalHandlers(){this._globalKeydownHandler||(this._globalKeydownHandler=e=>{if(this._openShortcutMatches(e)){e.preventDefault(),this._openSearch(!0);return}if(e.key===`Tab`&&this._searchOpen){let t=e.composedPath();if(this._shell&&t.includes(this._shell)||this._panelInner&&t.includes(this._panelInner)){let t=this._getSearchFocusableElements();if(t.length){let n=document.activeElement,r=n?t.indexOf(n):-1,i=e.shiftKey?-1:1,a=r<0?e.shiftKey?t.length-1:0:(r+i+t.length)%t.length;e.preventDefault(),t[a]?.focus()}}return}if(e.key.toLowerCase()===`escape`&&this._searchOpen){if(this._filtersMoreOpen){this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput());return}this._closeSearch()}},document.addEventListener(`keydown`,this._globalKeydownHandler)),this._docPointerDownHandler||(this._docPointerDownHandler=e=>{if(!this._searchOpen)return;let t=e.composedPath();this._filtersMoreOpen&&this._panelFiltersWrap&&!t.includes(this._panelFiltersWrap)&&(this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput())),!(this._shell&&t.includes(this._shell)||this._panelInner&&t.includes(this._panelInner))&&this._closeSearch()},document.addEventListener(`pointerdown`,this._docPointerDownHandler,!0))}_attachResizeHandler(){this._resizeHandler||(this._resizeHandler=()=>{this._syncPanelVisibility(),this._syncFilterOverflow()},window.addEventListener(`resize`,this._resizeHandler,{passive:!0})),this._scrollHandler||(this._scrollHandler=()=>{this._searchOpen&&this._positionPanel()},document.addEventListener(`scroll`,this._scrollHandler,!0))}_attachFocusOutHandler(){this._focusOutHandler||(this._focusOutHandler=e=>{if(!this._searchOpen)return;let t=e.relatedTarget;t&&(this._shell&&this._shell.contains(t)||this._panelInner&&this._panelInner.contains(t)||this._closeSearch())},this.addEventListener(`focusout`,this._focusOutHandler,!0))}_emitSearchOpenChange(){this.dispatchEvent(new CustomEvent(`search-open-change`,{detail:{open:this._searchOpen},bubbles:!0,composed:!0}))}_openSearch(e=!1){this._getEndpoint()&&(this._searchOpen||(this._searchOpen=!0,this._syncPanelVisibility(),this._emitSearchOpenChange(),e&&this._primarySearchInput()?.focus()))}_closeSearch(){this._searchOpen&&(this._searchOpen=!1,this._filtersMoreOpen=!1,this._syncPanelVisibility(),this._emitSearchOpenChange())}_syncPanelVisibility(){if(this._panel){this._syncPanelLayoutClass(),this._panel.classList.toggle(`is-hidden`,!this._searchOpen),this._panel.classList.toggle(`is-open`,this._searchOpen),this._shell&&this._shell.classList.toggle(`is-open`,this._searchOpen);for(let e of[this._desktopInput,this._panelInput]){let t=e?.querySelector(`input`);t&&(t.setAttribute(`aria-expanded`,String(this._searchOpen)),this._resultsId&&t.setAttribute(`aria-controls`,this._resultsId))}this._positionPanel(),this._searchOpen&&this._scheduleFilterOverflowSync()}}_syncPanelLayoutClass(){if(!this._panel)return;let e=!this._isMobileViewport()||!this._collapseOnMobile();this._panel.classList.toggle(`mint-search-panel-anchored`,e),this._panel.classList.toggle(`mint-search-panel-mobile`,!e),this._panel.classList.toggle(`mint-search-panel-global`,this.classList.contains(`global-search-control`))}_positionPanel(){if(!this._panel)return;if(!(!this._isMobileViewport()||!this._collapseOnMobile())){this._panel.style.left=``,this._panel.style.right=``,this._panel.style.top=``,this._panel.style.bottom=``,this._panel.style.width=``,this._panel.classList.remove(`is-open-above`),this._panelInner&&(this._panelInner.style.maxHeight=``);return}let e=this._shell?.getBoundingClientRect();if(!e)return;let t=window.innerHeight,n=Math.max(0,Math.min(416,t-16)),r=Math.max(0,t-e.bottom-4),i=Math.max(0,e.top-4),a=r<n&&i>r,o=Math.min(n,a?i:r);this._panel.classList.toggle(`is-open-above`,a),this._panelInner&&(this._panelInner.style.maxHeight=`${o}px`),this._panel.style.left=`${e.left}px`,this._panel.style.width=`${e.width}px`,this._panel.style.right=`auto`,a?(this._panel.style.top=`auto`,this._panel.style.bottom=`${Math.max(0,t-e.top-4)}px`):(this._panel.style.top=`${e.bottom-4}px`,this._panel.style.bottom=`auto`)}_setQuery(e){let t=this._query;this._query=e,e!==t&&(this._selectedFilterBackspaceArmed=!1),this._desktopInput&&(this._desktopInput.value=e),this._panelInput&&(this._panelInput.value=e)}_cancelDebounce(){this._debounceId!==null&&(window.clearTimeout(this._debounceId),this._debounceId=null)}_abortSearch(){this._abortController&&=(this._abortController.abort(),null)}_normalizeResults(e){let t=Number.parseInt(this.getAttribute(`results-limit`)||``,10),n=Number.isFinite(t)&&t>0?Math.min(t,1e3):8;return(e=>{if(Array.isArray(e))return e;if(!e||typeof e!=`object`)return[];let t=e;for(let e of[`results`,`items`,`data`,`products`]){let n=t[e];if(Array.isArray(n))return n}return[]})(e).map(e=>{let t=e||{};return{title:String(t.title||t.name||t.label||t.email||t.id||``).trim()||`Untitled`,subtitle:String(t.description||t.category||t.username||``).trim(),parent:String(t.parent||t.type||t.entity||t.kind||t.category||``).trim()||void 0}}).slice(0,n)}_emitResultsChange(e,t){let n=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-results-change`,{detail:{query:this._query,filter:n,filters:[...this._selectedFilters],results:e,raw:t??null},bubbles:!0,composed:!0}))}_emitFilterChange(){let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-filter-change`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters]},bubbles:!0,composed:!0}))}_renderState(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`is-hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`is-hidden`);return}this._stateWrap&&(this._stateWrap.textContent=e,this._stateWrap.classList.remove(`is-hidden`),this._resultsWrap&&(this._resultsWrap.classList.remove(`is-hidden`),this._resultsWrap.innerHTML=``))}_renderResults(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`is-hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`is-hidden`);return}if(!(!this._resultsWrap||!this._stateWrap)){if(this._resultsWrap.innerHTML=``,e.length===0){this._renderState(`No results found`);return}this._stateWrap.classList.add(`is-hidden`);for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`mint-search-result`,e.setAttribute(`role`,`option`),e.setAttribute(`aria-selected`,`false`);let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`mint-search-result-icon`;let r=document.createElement(`div`);r.className=`mint-search-result-copy`;let i=document.createElement(`div`);if(i.className=`mint-search-result-title`,i.textContent=t.title,r.appendChild(i),t.subtitle){let e=document.createElement(`div`);e.className=`mint-search-result-subtitle`,e.textContent=t.subtitle,r.appendChild(e)}e.appendChild(n),e.appendChild(r),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){t.preventDefault(),this._moveFocusInResults(e,1);return}if(t.key===`ArrowUp`){t.preventDefault(),this._moveFocusInResults(e,-1);return}}),e.addEventListener(`click`,()=>{let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-select`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters],result:t},bubbles:!0,composed:!0})),this._closeSearch()}),this._resultsWrap.appendChild(e)}}}_fetchSearchResults(e){let t=this._getEndpoint();if(!t)return;let n=e.trim();if(!n){this._emitResultsChange([]),this._renderState(`Start typing to search`);return}this._abortSearch(),this._abortController=new AbortController,this._renderState(`Searching...`);let r=new URLSearchParams;r.set(this._getSearchParam(),n);let i=this._getFilterParam();i&&this._hasSelectedFilters()&&r.set(i,this._getFilterParamValue());let a=t.includes(`{query}`)?t.replace(`{query}`,encodeURIComponent(n)):`${t}${t.includes(`?`)?`&`:`?`}${r.toString()}`;fetch(a,{signal:this._abortController.signal}).then(e=>{if(!e.ok)throw Error(`Request failed: ${e.status}`);return e.json()}).then(e=>{let t=this._normalizeResults(e);this._emitResultsChange(t,e),this._renderResults(t)}).catch(e=>{e?.name!==`AbortError`&&(this._emitResultsChange([]),this._renderState(`Unable to load results`))})}_scheduleSearch(e){this._setQuery(e),this._cancelDebounce(),this._debounceId=window.setTimeout(()=>this._fetchSearchResults(e),220)}_getNativeInputValue(e){if(!e)return``;let t=e.querySelector(`input, textarea`);return t?t.value||``:e.value||``}_getCurrentInputValue(){let e=document.activeElement;return e&&this._desktopInput&&this._desktopInput.contains(e)?this._getNativeInputValue(this._desktopInput):e&&this._panelInput&&this._panelInput.contains(e)?this._getNativeInputValue(this._panelInput):this._getNativeInputValue(this._primarySearchInput())}_applyFilterSelectionChange(){let e=this._getCurrentInputValue();if(this._setQuery(e),this._emitFilterChange(),this.render(),e.trim()){this._scheduleSearch(e);return}this._cancelDebounce(),this._abortSearch(),this._emitResultsChange([]),this._renderState(`Start typing to search`)}_clearAllSelectedFilters(){this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange()}_popLastSelectedFilter(){this._selectedFilters.length!==0&&(this._selectedFilters.pop(),this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange())}_focusActiveInput(){let e=this._primarySearchInput();e&&requestAnimationFrame(()=>{e.focus()})}_focusHideFiltersControl(){let e=this._panelFiltersShowAllBtn;e&&(e.querySelector(`button`)??e).focus()}_getFilterChipElements(){return this._panelFiltersWrap?Array.from(this._panelFiltersWrap.querySelectorAll(`mint-chip`)):[]}_ensurePanelFiltersShell(){!this._panelFiltersWrap||this._panelFiltersMainRow||(this._panelFiltersWrap.replaceChildren(),this._panelFiltersWrap.className=`mint-search-filters`,this._panelFiltersMainRow=document.createElement(`div`),this._panelFiltersMainRow.className=`mint-search-filter-row`,this._panelFiltersChips=document.createElement(`div`),this._panelFiltersChips.className=`mint-search-filter-chips`,this._panelFiltersMorePanel=document.createElement(`div`),this._panelFiltersMorePanel.id=`mint-search-filter-more-${e._filterMorePanelSeq++}`,this._panelFiltersMorePanel.className=`mint-search-filter-more is-hidden`,this._panelFiltersShowAllWrap=document.createElement(`div`),this._panelFiltersShowAllWrap.className=`mint-search-filter-more-trigger is-hidden`,this._panelFiltersShowAllBtn=document.createElement(`mint-button`),this._panelFiltersShowAllBtn.setAttribute(`type`,`button`),this._panelFiltersShowAllBtn.setAttribute(`variant`,`ghost`),this._panelFiltersShowAllBtn.setAttribute(`tone`,`neutral`),this._panelFiltersShowAllBtn.setAttribute(`size`,`small`),this._panelFiltersShowAllBtn.classList.add(`mint-search-filter-more-button`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,`false`),this._panelFiltersShowAllBtn.setAttribute(`aria-controls`,this._panelFiltersMorePanel.id),this._panelFiltersShowAllBtn.addEventListener(`click`,e=>{e.stopPropagation();let t=this._filtersMoreOpen;this._filtersMoreOpen=!this._filtersMoreOpen,this.render(),t&&requestAnimationFrame(()=>this._focusActiveInput())}),this._panelFiltersShowAllWrap.append(this._panelFiltersShowAllBtn),this._panelFiltersMainRow.append(this._panelFiltersChips,this._panelFiltersShowAllWrap),this._setPanelFiltersShowAllLabel(`Show all`),this._panelFiltersWrap.append(this._panelFiltersMainRow,this._panelFiltersMorePanel),typeof ResizeObserver<`u`&&!this._filterOverflowObserver&&(this._filterOverflowObserver=new ResizeObserver(()=>this._syncFilterOverflow()),this._filterOverflowObserver.observe(this._panelFiltersChips),this._filterOverflowObserver.observe(this._panelFiltersMainRow)))}_setPanelFiltersShowAllLabel(e){let t=this._panelFiltersShowAllBtn;if(!t)return;for(let e of Array.from(t.childNodes))e.nodeType===Node.TEXT_NODE&&e.remove();let n=t.querySelector(`button .mint-button-content`)||t.querySelector(`.mint-button-content`);if(n){n.textContent=e;return}let r=t.querySelector(`:scope > button`);if(r){r.replaceChildren(document.createTextNode(e)),t.render?.();return}t.firstElementChild||t.appendChild(document.createTextNode(e))}_scheduleFilterOverflowSync(){requestAnimationFrame(()=>{requestAnimationFrame(()=>this._syncFilterOverflow())})}_setFilterChipsEdgeFade(t){let n=this._panelFiltersChips;n&&(t?(n.style.maskImage=e._filterChipsOverflowMask,n.style.webkitMaskImage=e._filterChipsOverflowMask):(n.style.maskImage=``,n.style.webkitMaskImage=``))}_syncFilterOverflow(){if(!this._panelFiltersChips||!this._panelFiltersShowAllWrap||!this._panelFiltersShowAllBtn)return;if(this._filtersMoreOpen){this._panelFiltersShowAllWrap.classList.remove(`is-hidden`),this._filterOverflowZeroWidthRetries=0,this._setFilterChipsEdgeFade(!1);return}let e=this._panelFiltersChips.clientWidth;if(e===0&&this._searchOpen){this._filterOverflowZeroWidthRetries<10&&(this._filterOverflowZeroWidthRetries+=1,this._scheduleFilterOverflowSync()),this._setFilterChipsEdgeFade(!1);return}this._filterOverflowZeroWidthRetries=0;let t=this._panelFiltersChips.scrollWidth+this._getFilterChipOverflowReservePx()>e;this._panelFiltersShowAllWrap.classList.toggle(`is-hidden`,!t),this._setFilterChipsEdgeFade(t)}_getResultFocusableElements(){let e=this._customResultsWrap&&!this._customResultsWrap.classList.contains(`is-hidden`)?this._customResultsWrap:this._resultsWrap;return e?Array.from(e.querySelectorAll(`button:not([disabled]), [href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`)):[]}_getSearchFocusableElements(){return[this._shell,this._panelInner].filter(e=>!!e).flatMap(e=>Array.from(e.querySelectorAll(`button:not([disabled]), [href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`))).filter(e=>{if(e.closest(`.is-hidden`)||e.closest(`[aria-hidden="true"]`))return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_focusFirstChipOrResult(e=!1){let t=this._getFilterChipElements(),n=this._getResultFocusableElements();if(!e){(t[0]||n[0])?.focus();return}(n[n.length-1]||t[t.length-1])?.focus()}_moveFocusInResults(e,t){let n=this._getResultFocusableElements();if(n.length===0)return;let r=n.indexOf(e);if(r===-1)return;let i=n[r+t];if(i){i.focus();return}if(t===-1){let e=this._getFilterChipElements(),t=e[e.length-1];t?t.focus():this._focusActiveInput()}}_renderSelectedFilter(){let e=e=>{if(!e||(e.innerHTML=``,!this._hasSelectedFilters()))return;let t=document.createElement(`mint-chip`);t.setAttribute(`dismissable`,``),t.title=this._getFilterChipLabelText();let n=this._getCondensedFilterChipLabel();t.classList.add(`mint-search-selected-filter`),this._selectedFilterBackspaceArmed&&t.classList.add(`is-backspace-armed`),t.textContent=n,t.addEventListener(`dismiss`,e=>{e.stopPropagation(),this._clearAllSelectedFilters()}),e.appendChild(t)};e(this._desktopFilterWrap),e(this._mobileFilterWrap);let t=this._hasSelectedFilters();this._desktopInput?.classList.toggle(`has-selected-filter`,t),this._panelInput?.classList.toggle(`has-selected-filter`,t),this._syncSelectedFilterInputOffset(this._desktopInput,this._desktopFilterWrap),this._syncSelectedFilterInputOffset(this._panelInput,this._mobileFilterWrap)}_syncSelectedFilterInputOffset(e,t){if(!e||!t)return;let n=t.querySelector(`mint-chip`);if(!n){e.style.removeProperty(`--mint-search-filter-chip-width`);return}let r=()=>{n.isConnected&&e.style.setProperty(`--mint-search-filter-chip-width`,`${n.getBoundingClientRect().width}px`)};r(),requestAnimationFrame(r)}_bindInputHandlers(e){let t=()=>{this._scheduleSearch(this._getNativeInputValue(e))};e.addEventListener(`focusin`,()=>this._openSearch(!1)),e.addEventListener(`input`,t),e.addEventListener(`search`,t),e.addEventListener(`change`,t),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!1);return}if(t.key===`ArrowUp`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!0);return}if(t.key!==`Backspace`)return;let n=this._getNativeInputValue(e);if(n!==this._query&&this._setQuery(n),!(n.length>0)&&this._hasSelectedFilters()){if(!this._selectedFilterBackspaceArmed){t.preventDefault(),this._selectedFilterBackspaceArmed=!0,this._renderSelectedFilter();return}t.preventDefault(),this._popLastSelectedFilter()}})}openSearch(e=!0){this._openSearch(e)}closeSearch(){this._closeSearch()}toggleSearch(e=!0){if(this._searchOpen){this._closeSearch();return}this._openSearch(e)}isSearchOpen(){return this._searchOpen}render(){let e=this._getEndpoint();if(this.classList.toggle(`is-hidden`,!e),!e){this._searchOpen=!1,this._panel?.classList.add(`is-hidden`);return}if(!this._shell){this._shell=document.createElement(`div`),this._shell.className=`mint-search-shell`,this._desktopFilterWrap=document.createElement(`div`),this._desktopFilterWrap.className=`mint-search-filter-slot`,this._desktopFilterWrap.setAttribute(`slot`,`prepend`),this._desktopInput=document.createElement(`mint-input`),this._desktopInput.setAttribute(`type`,`search`),this._desktopInput.setAttribute(`icon`,`search`),this._desktopInput.setAttribute(`aria-label`,this.getAttribute(`placeholder`)||`Search`),this._desktopInput.className=`mint-search-input`;let e=document.createElement(`span`);e.className=`mint-search-shortcut-hint`,e.setAttribute(`slot`,`append`),this._desktopShortcutHint=e,this._bindInputHandlers(this._desktopInput),this._desktopInput.appendChild(this._desktopFilterWrap),this._desktopInput.appendChild(e),this._shell.appendChild(this._desktopInput),this.appendChild(this._shell)}if(!this._panel){this._panel=document.createElement(`div`),this._panel.className=`mint-search-panel is-hidden`;let e=document.createElement(`div`);e.className=`mint-search-panel-inner`,this._panelInner=e;let t=document.createElement(`div`);this._panelSearchBar=t,t.className=`mint-search-panel-searchbar is-hidden`,this._mobileFilterWrap=document.createElement(`div`),this._mobileFilterWrap.className=`mint-search-filter-slot`,this._mobileFilterWrap.setAttribute(`slot`,`prepend`),this._panelInput=document.createElement(`mint-input`),this._panelInput.setAttribute(`type`,`search`),this._panelInput.setAttribute(`icon`,`search`),this._panelInput.setAttribute(`aria-label`,this.getAttribute(`placeholder`)||`Search`),this._panelInput.className=`mint-search-input`,this._bindInputHandlers(this._panelInput),this._panelInput.appendChild(this._mobileFilterWrap),t.appendChild(this._panelInput),this._customResultsWrap=document.createElement(`div`),this._customResultsWrap.className=`mint-search-custom-results is-hidden`,this._stateWrap=document.createElement(`div`),this._stateWrap.className=`mint-search-state`,this._stateWrap.textContent=`Start typing to search`,this._stateWrap.setAttribute(`role`,`status`),this._stateWrap.setAttribute(`aria-live`,`polite`),this._resultsWrap=document.createElement(`div`),this._resultsWrap.className=`mint-search-results`,this._resultsId=`mint-search-results-${Math.random().toString(36).slice(2,10)}`,this._resultsWrap.id=this._resultsId,this._resultsWrap.setAttribute(`role`,`listbox`),this._resultsWrap.setAttribute(`aria-label`,`Search results`),this._customResultsWrap.setAttribute(`role`,`region`),this._customResultsWrap.setAttribute(`aria-label`,`Search results`),e.appendChild(t),this._panelFiltersWrap=document.createElement(`div`),e.appendChild(this._panelFiltersWrap),this._ensurePanelFiltersShell(),e.appendChild(this._customResultsWrap),e.appendChild(this._stateWrap),e.appendChild(this._resultsWrap),this._panel.appendChild(e)}this._panel.parentElement!==document.body&&document.body.appendChild(this._panel);let t=this._hasSelectedFilters()?``:this._getPlaceholder();if(this._desktopInput&&this._desktopInput.setAttribute(`placeholder`,t),this._panelInput&&this._panelInput.setAttribute(`placeholder`,t),this._desktopInput&&this._desktopInput.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||this._getPlaceholder()),this._panelInput&&this._panelInput.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||this._getPlaceholder()),this._desktopShortcutHint){let e=this._getOpenShortcutHintText();this._desktopShortcutHint.textContent=e,this._desktopShortcutHint.classList.toggle(`is-hidden`,!e)}if(this._panelFiltersWrap){this._ensurePanelFiltersShell();let e=this._getFilterOptions();this._selectedFilters=this._selectedFilters.filter(t=>e.includes(t));let t=e.length>0;t||(this._filtersMoreOpen=!1),this._panelFiltersWrap.classList.toggle(`is-hidden`,!t),this._panelInner?.classList.toggle(`has-no-filters`,!t),this._panelFiltersChips&&this._panelFiltersChips.replaceChildren(),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.replaceChildren();let n=this._filtersMoreOpen&&this._panelFiltersMorePanel?this._panelFiltersMorePanel:this._panelFiltersChips;for(let t of e){if(!n)break;let r=document.createElement(`mint-chip`),i=this._selectedFilters.includes(t);if(i&&r.classList.add(`is-selected`),r.classList.add(`mint-search-filter-chip`),i){let e=document.createElement(`span`);e.textContent=t;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`close`),n.className=`mint-search-filter-chip-close`,n.setAttribute(`aria-hidden`,`true`),r.append(e,n)}else r.textContent=t;r.tabIndex=0,r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,i?`Remove filter ${t}`:`Filter by ${t}`),r.dataset.mintSearchFilter=t,r.addEventListener(`pointerdown`,e=>{e.preventDefault()});let a=n=>{n&&n.stopPropagation();let r=this._filtersMoreOpen,i=this._selectedFilters.indexOf(t);i>=0?this._selectedFilters.splice(i,1):this._selectedFilters.push(t),this._selectedFilterBackspaceArmed=!1;let a=e.length>0&&this._selectedFilters.length===e.length,o=this._selectedFilters.length===0;r&&(a||o)&&(this._filtersMoreOpen=!1),this._emitFilterChange(),this._renderSelectedFilter(),this.render(),this._query.trim()&&this._scheduleSearch(this._query),r?a||o?this._focusActiveInput():requestAnimationFrame(()=>{this._getFilterChipElements().find(e=>e.dataset.mintSearchFilter===t)?.focus()}):this._focusActiveInput()};r.addEventListener(`click`,e=>a(e)),r.addEventListener(`keydown`,e=>{let t=this._getFilterChipElements(),n=t.indexOf(r);if(e.key===`Enter`||e.key===` `){e.preventDefault(),a(e);return}if(e.key===`ArrowRight`){e.preventDefault();let r=t[n+1];r&&r.focus();return}if(e.key===`ArrowLeft`){e.preventDefault();let r=t[n-1];r?r.focus():this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}if(e.key===`ArrowDown`){e.preventDefault(),this._getResultFocusableElements()[0]?.focus();return}if(e.key===`ArrowUp`){e.preventDefault(),this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}}),n.appendChild(r)}this._panelFiltersChips&&this._panelFiltersChips.classList.toggle(`is-hidden`,this._filtersMoreOpen),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.classList.toggle(`is-hidden`,!this._filtersMoreOpen),this._panelFiltersShowAllBtn&&(this._setPanelFiltersShowAllLabel(this._filtersMoreOpen?`Hide filters`:`Show all`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,this._filtersMoreOpen?`true`:`false`)),this._panelInner&&(this._filtersMoreOpen&&t?this._panelInner.classList.add(`is-overflow-visible`):this._panelInner.classList.remove(`is-overflow-visible`)),this._scheduleFilterOverflowSync()}if(this._customResultsWrap){Array.from(this.children).filter(e=>e===this._shell||e===this._panel?!1:e.getAttribute(`slot`)===`results`).forEach(e=>this._customResultsWrap.appendChild(e));let e=this._customResultsWrap.childElementCount>0;this._customResultsWrap.classList.toggle(`is-hidden`,!e),e?(this._stateWrap?.classList.add(`is-hidden`),this._resultsWrap?.classList.add(`is-hidden`)):this._resultsWrap?.classList.remove(`is-hidden`)}this._renderSelectedFilter(),this._syncResponsiveChrome(),this._syncPanelVisibility()}_syncResponsiveChrome(){let e=this._collapseOnMobile();this._shell&&this._shell.classList.toggle(`is-collapsed`,e),this._panelSearchBar&&(this._panelSearchBar.classList.toggle(`is-hidden`,!e),this._panelSearchBar.classList.toggle(`is-collapsed`,e))}};customElements.get(`mint-search`)||e.t(`mint-search`,t),module.exports=t;
1
+ require(`../chunks/icon-CWOP4Com.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-D6C1XGp2.js`),require(`../chunks/close-DSrpkGHJ.js`),require(`../chunks/button-B_yN18B-.js`),require(`../chunks/chip-BUaS7ks-.js`),require(`../chunks/input-Br2qLesW.js`),require(`../chunks/search-q3dkl4-X.js`);var t=class e extends HTMLElement{constructor(...e){super(...e),this._shell=null,this._desktopInput=null,this._panel=null,this._panelInner=null,this._resultsId=``,this._panelInput=null,this._panelFiltersWrap=null,this._panelFiltersMainRow=null,this._panelFiltersChips=null,this._panelFiltersShowAllWrap=null,this._panelFiltersShowAllBtn=null,this._panelFiltersMorePanel=null,this._filtersMoreOpen=!1,this._filterOverflowObserver=null,this._filterOverflowZeroWidthRetries=0,this._desktopFilterWrap=null,this._mobileFilterWrap=null,this._resultsWrap=null,this._stateWrap=null,this._customResultsWrap=null,this._query=``,this._searchOpen=!1,this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._debounceId=null,this._abortController=null,this._docPointerDownHandler=null,this._globalKeydownHandler=null,this._focusOutHandler=null,this._resizeHandler=null,this._scrollHandler=null,this._desktopShortcutHint=null,this._panelSearchBar=null,this._contentObserver=null,this._renderFrame=null}static{this._filterMorePanelSeq=0}static{this._filterChipsOverflowMask=`linear-gradient(to right, #000 0%, #000 max(0%, calc(100% - 3.5rem)), transparent 100%)`}static get observedAttributes(){return[`endpoint`,`search-param`,`placeholder`,`filters`,`filter-param`,`open-shortcut`,`open-shortcut-hint`,`collapse-on-mobile`,`results-limit`]}connectedCallback(){this.classList.add(`mint-search-host`),this._attachGlobalHandlers(),this._attachFocusOutHandler(),this._attachResizeHandler(),this.render(),this._observeContentMutations()}disconnectedCallback(){this._panel?.remove(),this._docPointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._docPointerDownHandler,!0),null),this._globalKeydownHandler&&=(document.removeEventListener(`keydown`,this._globalKeydownHandler),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null),this._scrollHandler&&=(document.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._focusOutHandler&&=(this.removeEventListener(`focusout`,this._focusOutHandler,!0),null),this._cancelDebounce(),this._abortSearch(),this._filterOverflowObserver&&=(this._filterOverflowObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getEndpoint(){return(this.getAttribute(`endpoint`)||``).trim()}_getSearchParam(){return(this.getAttribute(`search-param`)||`q`).trim()||`q`}_getPlaceholder(){return this.getAttribute(`placeholder`)||`Search`}_getFilterParam(){return(this.getAttribute(`filter-param`)||``).trim()}_getFilterOptions(){return(this.getAttribute(`filters`)||``).split(`,`).map(e=>e.trim()).filter(Boolean)}_hasSelectedFilters(){return this._selectedFilters.length>0}_getFilterChipOverflowReservePx(){let e=Math.max(1,this._getFilterOptions().length),t=this._hasSelectedFilters()?28:56;return Math.min(200,t+e*34)}_getFilterParamValue(){return this._selectedFilters.join(`,`)}_getFilterChipLabelText(){return this._selectedFilters.join(`, `)}_getCondensedFilterChipLabel(e=22){if(!this._hasSelectedFilters())return``;let[t=``]=this._selectedFilters,n=this._selectedFilters.length-1,r=Math.max(8,e-2),i=t;if(n<=0)return i.length<=r?i:`${i.slice(0,Math.max(1,r-3))}...`;let a=`${t}, and ${n} more`;return a.length<=r?a:`${a.slice(0,Math.max(1,r-3))}...`}_isMobileViewport(){return window.matchMedia(`(max-width: 1099.98px)`).matches}_collapseOnMobile(){let e=this.getAttribute(`collapse-on-mobile`);if(e===null)return!1;let t=e.trim().toLowerCase();return!(t===`false`||t===`0`||t===`off`||t===`none`)}_primarySearchInput(){return this._isMobileViewport()&&this._collapseOnMobile()?this._panelInput:this._desktopInput}_isApplePlatform(){return typeof navigator>`u`?!1:/Mac|iPhone|iPad|iPod/i.test(navigator.platform)||/Mac OS/i.test(navigator.userAgent)}_parseOpenShortcut(){let e=(this.getAttribute(`open-shortcut`)??`mod+k`).trim().toLowerCase();if(!e||e===`none`||e===`false`||e===`off`)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let t=e.split(`+`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let n=t[t.length-1],r=new Set(t.slice(0,-1).map(e=>e.toLowerCase()));return{disabled:!1,wantMod:r.has(`mod`),wantMeta:r.has(`meta`)||r.has(`cmd`)||r.has(`super`),wantCtrl:r.has(`ctrl`)||r.has(`control`),wantAlt:r.has(`alt`),wantShift:r.has(`shift`),key:n.toLowerCase()}}_eventKeyMatchesShortcutKey(e,t){let n=t.toLowerCase();return(e.key.length,e.key.toLowerCase())===n}_openShortcutMatches(e){let t=this._parseOpenShortcut();return t.disabled||!t.key||e.repeat||!this._eventKeyMatchesShortcutKey(e,t.key)||t.wantShift!==e.shiftKey||t.wantAlt!==e.altKey?!1:t.wantMod||t.wantMeta||t.wantCtrl?!(t.wantMod&&!(e.metaKey||e.ctrlKey)||t.wantMeta&&!e.metaKey||t.wantCtrl&&!e.ctrlKey):!!t.wantAlt}_getOpenShortcutHintText(){let e=this.getAttribute(`open-shortcut-hint`);if(e===`none`||e===`false`)return``;if(e!==null&&e.trim()!==``)return e.trim();let t=this._parseOpenShortcut();if(t.disabled)return``;let n=this._isApplePlatform(),r=[];t.wantMod&&r.push(n?`⌘`:`Ctrl`),t.wantMeta&&!t.wantMod&&r.push(n?`⌘`:`Meta`),t.wantCtrl&&!t.wantMod&&r.push(`Ctrl`),t.wantAlt&&r.push(`Alt`),t.wantShift&&r.push(`Shift`);let i=t.key.length===1?t.key.toUpperCase():t.key;return i?t.wantMod&&!t.wantMeta&&!t.wantCtrl&&!t.wantAlt&&!t.wantShift&&t.key.length===1?`${n?`⌘`:`Ctrl+`}${i}`:[...r,i].join(`+`):``}_attachGlobalHandlers(){this._globalKeydownHandler||(this._globalKeydownHandler=e=>{if(this._openShortcutMatches(e)){e.preventDefault(),this._openSearch(!0);return}if(e.key===`Tab`&&this._searchOpen){let t=e.composedPath();if(this._shell&&t.includes(this._shell)||this._panelInner&&t.includes(this._panelInner)){let t=this._getSearchFocusableElements();if(t.length){let n=document.activeElement,r=n?t.indexOf(n):-1,i=e.shiftKey?-1:1,a=r<0?e.shiftKey?t.length-1:0:(r+i+t.length)%t.length;e.preventDefault(),t[a]?.focus()}}return}if(e.key.toLowerCase()===`escape`&&this._searchOpen){if(this._filtersMoreOpen){this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput());return}this._closeSearch()}},document.addEventListener(`keydown`,this._globalKeydownHandler)),this._docPointerDownHandler||(this._docPointerDownHandler=e=>{if(!this._searchOpen)return;let t=e.composedPath();this._filtersMoreOpen&&this._panelFiltersWrap&&!t.includes(this._panelFiltersWrap)&&(this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput())),!(this._shell&&t.includes(this._shell)||this._panelInner&&t.includes(this._panelInner))&&this._closeSearch()},document.addEventListener(`pointerdown`,this._docPointerDownHandler,!0))}_attachResizeHandler(){this._resizeHandler||(this._resizeHandler=()=>{this._syncPanelVisibility(),this._syncFilterOverflow()},window.addEventListener(`resize`,this._resizeHandler,{passive:!0})),this._scrollHandler||(this._scrollHandler=()=>{this._searchOpen&&this._positionPanel()},document.addEventListener(`scroll`,this._scrollHandler,!0))}_attachFocusOutHandler(){this._focusOutHandler||(this._focusOutHandler=e=>{if(!this._searchOpen)return;let t=e.relatedTarget;t&&(this._shell&&this._shell.contains(t)||this._panelInner&&this._panelInner.contains(t)||this._closeSearch())},this.addEventListener(`focusout`,this._focusOutHandler,!0))}_emitSearchOpenChange(){this.dispatchEvent(new CustomEvent(`search-open-change`,{detail:{open:this._searchOpen},bubbles:!0,composed:!0}))}_openSearch(e=!1){this._getEndpoint()&&(this._searchOpen||(this._searchOpen=!0,this._syncPanelVisibility(),this._emitSearchOpenChange(),e&&this._primarySearchInput()?.focus()))}_closeSearch(){this._searchOpen&&(this._searchOpen=!1,this._filtersMoreOpen=!1,this._syncPanelVisibility(),this._emitSearchOpenChange())}_syncPanelVisibility(){if(this._panel){this._syncPanelLayoutClass(),this._panel.classList.toggle(`is-hidden`,!this._searchOpen),this._panel.classList.toggle(`is-open`,this._searchOpen),this._shell&&this._shell.classList.toggle(`is-open`,this._searchOpen);for(let e of[this._desktopInput,this._panelInput]){let t=e?.querySelector(`input`);t&&(t.setAttribute(`aria-expanded`,String(this._searchOpen)),this._resultsId&&t.setAttribute(`aria-controls`,this._resultsId))}this._positionPanel(),this._searchOpen&&this._scheduleFilterOverflowSync()}}_syncPanelLayoutClass(){if(!this._panel)return;let e=!this._isMobileViewport()||!this._collapseOnMobile();this._panel.classList.toggle(`mint-search-panel-anchored`,e),this._panel.classList.toggle(`mint-search-panel-mobile`,!e),this._panel.classList.toggle(`mint-search-panel-global`,this.classList.contains(`global-search-control`))}_positionPanel(){if(!this._panel)return;if(!(!this._isMobileViewport()||!this._collapseOnMobile())){this._panel.style.left=``,this._panel.style.right=``,this._panel.style.top=``,this._panel.style.bottom=``,this._panel.style.width=``,this._panel.classList.remove(`is-open-above`),this._panelInner&&(this._panelInner.style.maxHeight=``);return}let e=this._shell?.getBoundingClientRect();if(!e)return;let t=window.innerHeight,n=Math.max(0,Math.min(416,t-16)),r=Math.max(0,t-e.bottom-4),i=Math.max(0,e.top-4),a=r<n&&i>r,o=Math.min(n,a?i:r);this._panel.classList.toggle(`is-open-above`,a),this._panelInner&&(this._panelInner.style.maxHeight=`${o}px`),this._panel.style.left=`${e.left}px`,this._panel.style.width=`${e.width}px`,this._panel.style.right=`auto`,a?(this._panel.style.top=`auto`,this._panel.style.bottom=`${Math.max(0,t-e.top-4)}px`):(this._panel.style.top=`${e.bottom-4}px`,this._panel.style.bottom=`auto`)}_setQuery(e){let t=this._query;this._query=e,e!==t&&(this._selectedFilterBackspaceArmed=!1),this._desktopInput&&(this._desktopInput.value=e),this._panelInput&&(this._panelInput.value=e)}_cancelDebounce(){this._debounceId!==null&&(window.clearTimeout(this._debounceId),this._debounceId=null)}_abortSearch(){this._abortController&&=(this._abortController.abort(),null)}_normalizeResults(e){let t=Number.parseInt(this.getAttribute(`results-limit`)||``,10),n=Number.isFinite(t)&&t>0?Math.min(t,1e3):8;return(e=>{if(Array.isArray(e))return e;if(!e||typeof e!=`object`)return[];let t=e;for(let e of[`results`,`items`,`data`,`products`]){let n=t[e];if(Array.isArray(n))return n}return[]})(e).map(e=>{let t=e||{};return{title:String(t.title||t.name||t.label||t.email||t.id||``).trim()||`Untitled`,subtitle:String(t.description||t.category||t.username||``).trim(),parent:String(t.parent||t.type||t.entity||t.kind||t.category||``).trim()||void 0}}).slice(0,n)}_emitResultsChange(e,t){let n=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-results-change`,{detail:{query:this._query,filter:n,filters:[...this._selectedFilters],results:e,raw:t??null},bubbles:!0,composed:!0}))}_emitFilterChange(){let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-filter-change`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters]},bubbles:!0,composed:!0}))}_renderState(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`is-hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`is-hidden`);return}this._stateWrap&&(this._stateWrap.textContent=e,this._stateWrap.classList.remove(`is-hidden`),this._resultsWrap&&(this._resultsWrap.classList.remove(`is-hidden`),this._resultsWrap.innerHTML=``))}_renderResults(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`is-hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`is-hidden`);return}if(!(!this._resultsWrap||!this._stateWrap)){if(this._resultsWrap.innerHTML=``,e.length===0){this._renderState(`No results found`);return}this._stateWrap.classList.add(`is-hidden`);for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`mint-search-result`,e.setAttribute(`role`,`option`),e.setAttribute(`aria-selected`,`false`);let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`mint-search-result-icon`;let r=document.createElement(`div`);r.className=`mint-search-result-copy`;let i=document.createElement(`div`);if(i.className=`mint-search-result-title`,i.textContent=t.title,r.appendChild(i),t.subtitle){let e=document.createElement(`div`);e.className=`mint-search-result-subtitle`,e.textContent=t.subtitle,r.appendChild(e)}e.appendChild(n),e.appendChild(r),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){t.preventDefault(),this._moveFocusInResults(e,1);return}if(t.key===`ArrowUp`){t.preventDefault(),this._moveFocusInResults(e,-1);return}}),e.addEventListener(`click`,()=>{let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-select`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters],result:t},bubbles:!0,composed:!0})),this._closeSearch()}),this._resultsWrap.appendChild(e)}}}_fetchSearchResults(e){let t=this._getEndpoint();if(!t)return;let n=e.trim();if(!n){this._emitResultsChange([]),this._renderState(`Start typing to search`);return}this._abortSearch(),this._abortController=new AbortController,this._renderState(`Searching...`);let r=new URLSearchParams;r.set(this._getSearchParam(),n);let i=this._getFilterParam();i&&this._hasSelectedFilters()&&r.set(i,this._getFilterParamValue());let a=t.includes(`{query}`)?t.replace(`{query}`,encodeURIComponent(n)):`${t}${t.includes(`?`)?`&`:`?`}${r.toString()}`;fetch(a,{signal:this._abortController.signal}).then(e=>{if(!e.ok)throw Error(`Request failed: ${e.status}`);return e.json()}).then(e=>{let t=this._normalizeResults(e);this._emitResultsChange(t,e),this._renderResults(t)}).catch(e=>{e?.name!==`AbortError`&&(this._emitResultsChange([]),this._renderState(`Unable to load results`))})}_scheduleSearch(e){this._setQuery(e),this._cancelDebounce(),this._debounceId=window.setTimeout(()=>this._fetchSearchResults(e),220)}_getNativeInputValue(e){if(!e)return``;let t=e.querySelector(`input, textarea`);return t?t.value||``:e.value||``}_getCurrentInputValue(){let e=document.activeElement;return e&&this._desktopInput&&this._desktopInput.contains(e)?this._getNativeInputValue(this._desktopInput):e&&this._panelInput&&this._panelInput.contains(e)?this._getNativeInputValue(this._panelInput):this._getNativeInputValue(this._primarySearchInput())}_applyFilterSelectionChange(){let e=this._getCurrentInputValue();if(this._setQuery(e),this._emitFilterChange(),this.render(),e.trim()){this._scheduleSearch(e);return}this._cancelDebounce(),this._abortSearch(),this._emitResultsChange([]),this._renderState(`Start typing to search`)}_clearAllSelectedFilters(){this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange()}_popLastSelectedFilter(){this._selectedFilters.length!==0&&(this._selectedFilters.pop(),this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange())}_focusActiveInput(){let e=this._primarySearchInput();e&&requestAnimationFrame(()=>{e.focus()})}_focusHideFiltersControl(){let e=this._panelFiltersShowAllBtn;e&&(e.querySelector(`button`)??e).focus()}_getFilterChipElements(){return this._panelFiltersWrap?Array.from(this._panelFiltersWrap.querySelectorAll(`mint-chip`)):[]}_ensurePanelFiltersShell(){!this._panelFiltersWrap||this._panelFiltersMainRow||(this._panelFiltersWrap.replaceChildren(),this._panelFiltersWrap.className=`mint-search-filters`,this._panelFiltersMainRow=document.createElement(`div`),this._panelFiltersMainRow.className=`mint-search-filter-row`,this._panelFiltersChips=document.createElement(`div`),this._panelFiltersChips.className=`mint-search-filter-chips`,this._panelFiltersMorePanel=document.createElement(`div`),this._panelFiltersMorePanel.id=`mint-search-filter-more-${e._filterMorePanelSeq++}`,this._panelFiltersMorePanel.className=`mint-search-filter-more is-hidden`,this._panelFiltersShowAllWrap=document.createElement(`div`),this._panelFiltersShowAllWrap.className=`mint-search-filter-more-trigger is-hidden`,this._panelFiltersShowAllBtn=document.createElement(`mint-button`),this._panelFiltersShowAllBtn.setAttribute(`type`,`button`),this._panelFiltersShowAllBtn.setAttribute(`variant`,`ghost`),this._panelFiltersShowAllBtn.setAttribute(`tone`,`neutral`),this._panelFiltersShowAllBtn.setAttribute(`size`,`small`),this._panelFiltersShowAllBtn.classList.add(`mint-search-filter-more-button`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,`false`),this._panelFiltersShowAllBtn.setAttribute(`aria-controls`,this._panelFiltersMorePanel.id),this._panelFiltersShowAllBtn.addEventListener(`click`,e=>{e.stopPropagation();let t=this._filtersMoreOpen;this._filtersMoreOpen=!this._filtersMoreOpen,this.render(),t&&requestAnimationFrame(()=>this._focusActiveInput())}),this._panelFiltersShowAllWrap.append(this._panelFiltersShowAllBtn),this._panelFiltersMainRow.append(this._panelFiltersChips,this._panelFiltersShowAllWrap),this._setPanelFiltersShowAllLabel(`Show all`),this._panelFiltersWrap.append(this._panelFiltersMainRow,this._panelFiltersMorePanel),typeof ResizeObserver<`u`&&!this._filterOverflowObserver&&(this._filterOverflowObserver=new ResizeObserver(()=>this._syncFilterOverflow()),this._filterOverflowObserver.observe(this._panelFiltersChips),this._filterOverflowObserver.observe(this._panelFiltersMainRow)))}_setPanelFiltersShowAllLabel(e){let t=this._panelFiltersShowAllBtn;if(!t)return;for(let e of Array.from(t.childNodes))e.nodeType===Node.TEXT_NODE&&e.remove();let n=t.querySelector(`button .mint-button-content`)||t.querySelector(`.mint-button-content`);if(n){n.textContent=e;return}let r=t.querySelector(`:scope > button`);if(r){r.replaceChildren(document.createTextNode(e)),t.render?.();return}t.firstElementChild||t.appendChild(document.createTextNode(e))}_scheduleFilterOverflowSync(){requestAnimationFrame(()=>{requestAnimationFrame(()=>this._syncFilterOverflow())})}_setFilterChipsEdgeFade(t){let n=this._panelFiltersChips;n&&(t?(n.style.maskImage=e._filterChipsOverflowMask,n.style.webkitMaskImage=e._filterChipsOverflowMask):(n.style.maskImage=``,n.style.webkitMaskImage=``))}_syncFilterOverflow(){if(!this._panelFiltersChips||!this._panelFiltersShowAllWrap||!this._panelFiltersShowAllBtn)return;if(this._filtersMoreOpen){this._panelFiltersShowAllWrap.classList.remove(`is-hidden`),this._filterOverflowZeroWidthRetries=0,this._setFilterChipsEdgeFade(!1);return}let e=this._panelFiltersChips.clientWidth;if(e===0&&this._searchOpen){this._filterOverflowZeroWidthRetries<10&&(this._filterOverflowZeroWidthRetries+=1,this._scheduleFilterOverflowSync()),this._setFilterChipsEdgeFade(!1);return}this._filterOverflowZeroWidthRetries=0;let t=this._panelFiltersChips.scrollWidth+this._getFilterChipOverflowReservePx()>e;this._panelFiltersShowAllWrap.classList.toggle(`is-hidden`,!t),this._setFilterChipsEdgeFade(t)}_getResultFocusableElements(){let e=this._customResultsWrap&&!this._customResultsWrap.classList.contains(`is-hidden`)?this._customResultsWrap:this._resultsWrap;return e?Array.from(e.querySelectorAll(`button:not([disabled]), [href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`)):[]}_getSearchFocusableElements(){return[this._shell,this._panelInner].filter(e=>!!e).flatMap(e=>Array.from(e.querySelectorAll(`button:not([disabled]), [href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`))).filter(e=>{if(e.closest(`.is-hidden`)||e.closest(`[aria-hidden="true"]`))return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_focusFirstChipOrResult(e=!1){let t=this._getFilterChipElements(),n=this._getResultFocusableElements();if(!e){(t[0]||n[0])?.focus();return}(n[n.length-1]||t[t.length-1])?.focus()}_moveFocusInResults(e,t){let n=this._getResultFocusableElements();if(n.length===0)return;let r=n.indexOf(e);if(r===-1)return;let i=n[r+t];if(i){i.focus();return}if(t===-1){let e=this._getFilterChipElements(),t=e[e.length-1];t?t.focus():this._focusActiveInput()}}_renderSelectedFilter(){let e=e=>{if(!e||(e.innerHTML=``,!this._hasSelectedFilters()))return;let t=document.createElement(`mint-chip`);t.setAttribute(`dismissable`,``),t.title=this._getFilterChipLabelText();let n=this._getCondensedFilterChipLabel();t.classList.add(`mint-search-selected-filter`),this._selectedFilterBackspaceArmed&&t.classList.add(`is-backspace-armed`),t.textContent=n,t.addEventListener(`dismiss`,e=>{e.stopPropagation(),this._clearAllSelectedFilters()}),e.appendChild(t)};e(this._desktopFilterWrap),e(this._mobileFilterWrap);let t=this._hasSelectedFilters();this._desktopInput?.classList.toggle(`has-selected-filter`,t),this._panelInput?.classList.toggle(`has-selected-filter`,t),this._syncSelectedFilterInputOffset(this._desktopInput,this._desktopFilterWrap),this._syncSelectedFilterInputOffset(this._panelInput,this._mobileFilterWrap)}_syncSelectedFilterInputOffset(e,t){if(!e||!t)return;let n=t.querySelector(`mint-chip`);if(!n){e.style.removeProperty(`--mint-search-filter-chip-width`);return}let r=()=>{n.isConnected&&e.style.setProperty(`--mint-search-filter-chip-width`,`${n.getBoundingClientRect().width}px`)};r(),requestAnimationFrame(r)}_bindInputHandlers(e){let t=()=>{this._scheduleSearch(this._getNativeInputValue(e))};e.addEventListener(`focusin`,()=>this._openSearch(!1)),e.addEventListener(`input`,t),e.addEventListener(`search`,t),e.addEventListener(`change`,t),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!1);return}if(t.key===`ArrowUp`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!0);return}if(t.key!==`Backspace`)return;let n=this._getNativeInputValue(e);if(n!==this._query&&this._setQuery(n),!(n.length>0)&&this._hasSelectedFilters()){if(!this._selectedFilterBackspaceArmed){t.preventDefault(),this._selectedFilterBackspaceArmed=!0,this._renderSelectedFilter();return}t.preventDefault(),this._popLastSelectedFilter()}})}openSearch(e=!0){this._openSearch(e)}closeSearch(){this._closeSearch()}toggleSearch(e=!0){if(this._searchOpen){this._closeSearch();return}this._openSearch(e)}isSearchOpen(){return this._searchOpen}render(){let e=this._getEndpoint();if(this.classList.toggle(`is-hidden`,!e),!e){this._searchOpen=!1,this._panel?.classList.add(`is-hidden`);return}if(!this._shell){this._shell=document.createElement(`div`),this._shell.className=`mint-search-shell`,this._desktopFilterWrap=document.createElement(`div`),this._desktopFilterWrap.className=`mint-search-filter-slot`,this._desktopFilterWrap.setAttribute(`slot`,`prepend`),this._desktopInput=document.createElement(`mint-input`),this._desktopInput.setAttribute(`type`,`search`),this._desktopInput.setAttribute(`icon`,`search`),this._desktopInput.setAttribute(`aria-label`,this.getAttribute(`placeholder`)||`Search`),this._desktopInput.className=`mint-search-input`;let e=document.createElement(`span`);e.className=`mint-search-shortcut-hint`,e.setAttribute(`slot`,`append`),this._desktopShortcutHint=e,this._bindInputHandlers(this._desktopInput),this._desktopInput.appendChild(this._desktopFilterWrap),this._desktopInput.appendChild(e),this._shell.appendChild(this._desktopInput),this.appendChild(this._shell)}if(!this._panel){this._panel=document.createElement(`div`),this._panel.className=`mint-search-panel is-hidden`;let e=document.createElement(`div`);e.className=`mint-search-panel-inner`,this._panelInner=e;let t=document.createElement(`div`);this._panelSearchBar=t,t.className=`mint-search-panel-searchbar is-hidden`,this._mobileFilterWrap=document.createElement(`div`),this._mobileFilterWrap.className=`mint-search-filter-slot`,this._mobileFilterWrap.setAttribute(`slot`,`prepend`),this._panelInput=document.createElement(`mint-input`),this._panelInput.setAttribute(`type`,`search`),this._panelInput.setAttribute(`icon`,`search`),this._panelInput.setAttribute(`aria-label`,this.getAttribute(`placeholder`)||`Search`),this._panelInput.className=`mint-search-input`,this._bindInputHandlers(this._panelInput),this._panelInput.appendChild(this._mobileFilterWrap),t.appendChild(this._panelInput),this._customResultsWrap=document.createElement(`div`),this._customResultsWrap.className=`mint-search-custom-results is-hidden`,this._stateWrap=document.createElement(`div`),this._stateWrap.className=`mint-search-state`,this._stateWrap.textContent=`Start typing to search`,this._stateWrap.setAttribute(`role`,`status`),this._stateWrap.setAttribute(`aria-live`,`polite`),this._resultsWrap=document.createElement(`div`),this._resultsWrap.className=`mint-search-results`,this._resultsId=`mint-search-results-${Math.random().toString(36).slice(2,10)}`,this._resultsWrap.id=this._resultsId,this._resultsWrap.setAttribute(`role`,`listbox`),this._resultsWrap.setAttribute(`aria-label`,`Search results`),this._customResultsWrap.setAttribute(`role`,`region`),this._customResultsWrap.setAttribute(`aria-label`,`Search results`),e.appendChild(t),this._panelFiltersWrap=document.createElement(`div`),e.appendChild(this._panelFiltersWrap),this._ensurePanelFiltersShell(),e.appendChild(this._customResultsWrap),e.appendChild(this._stateWrap),e.appendChild(this._resultsWrap),this._panel.appendChild(e)}this._panel.parentElement!==document.body&&document.body.appendChild(this._panel);let t=this._hasSelectedFilters()?``:this._getPlaceholder();if(this._desktopInput&&this._desktopInput.setAttribute(`placeholder`,t),this._panelInput&&this._panelInput.setAttribute(`placeholder`,t),this._desktopInput&&this._desktopInput.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||this._getPlaceholder()),this._panelInput&&this._panelInput.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||this._getPlaceholder()),this._desktopShortcutHint){let e=this._getOpenShortcutHintText();this._desktopShortcutHint.textContent=e,this._desktopShortcutHint.classList.toggle(`is-hidden`,!e)}if(this._panelFiltersWrap){this._ensurePanelFiltersShell();let e=this._getFilterOptions();this._selectedFilters=this._selectedFilters.filter(t=>e.includes(t));let t=e.length>0;t||(this._filtersMoreOpen=!1),this._panelFiltersWrap.classList.toggle(`is-hidden`,!t),this._panelInner?.classList.toggle(`has-no-filters`,!t),this._panelFiltersChips&&this._panelFiltersChips.replaceChildren(),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.replaceChildren();let n=this._filtersMoreOpen&&this._panelFiltersMorePanel?this._panelFiltersMorePanel:this._panelFiltersChips;for(let t of e){if(!n)break;let r=document.createElement(`mint-chip`),i=this._selectedFilters.includes(t);if(i&&r.classList.add(`is-selected`),r.classList.add(`mint-search-filter-chip`),i){let e=document.createElement(`span`);e.textContent=t;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`close`),n.className=`mint-search-filter-chip-close`,n.setAttribute(`aria-hidden`,`true`),r.append(e,n)}else r.textContent=t;r.tabIndex=0,r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,i?`Remove filter ${t}`:`Filter by ${t}`),r.dataset.mintSearchFilter=t,r.addEventListener(`pointerdown`,e=>{e.preventDefault()});let a=n=>{n&&n.stopPropagation();let r=this._filtersMoreOpen,i=this._selectedFilters.indexOf(t);i>=0?this._selectedFilters.splice(i,1):this._selectedFilters.push(t),this._selectedFilterBackspaceArmed=!1;let a=e.length>0&&this._selectedFilters.length===e.length,o=this._selectedFilters.length===0;r&&(a||o)&&(this._filtersMoreOpen=!1),this._emitFilterChange(),this._renderSelectedFilter(),this.render(),this._query.trim()&&this._scheduleSearch(this._query),r?a||o?this._focusActiveInput():requestAnimationFrame(()=>{this._getFilterChipElements().find(e=>e.dataset.mintSearchFilter===t)?.focus()}):this._focusActiveInput()};r.addEventListener(`click`,e=>a(e)),r.addEventListener(`keydown`,e=>{let t=this._getFilterChipElements(),n=t.indexOf(r);if(e.key===`Enter`||e.key===` `){e.preventDefault(),a(e);return}if(e.key===`ArrowRight`){e.preventDefault();let r=t[n+1];r&&r.focus();return}if(e.key===`ArrowLeft`){e.preventDefault();let r=t[n-1];r?r.focus():this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}if(e.key===`ArrowDown`){e.preventDefault(),this._getResultFocusableElements()[0]?.focus();return}if(e.key===`ArrowUp`){e.preventDefault(),this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}}),n.appendChild(r)}this._panelFiltersChips&&this._panelFiltersChips.classList.toggle(`is-hidden`,this._filtersMoreOpen),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.classList.toggle(`is-hidden`,!this._filtersMoreOpen),this._panelFiltersShowAllBtn&&(this._setPanelFiltersShowAllLabel(this._filtersMoreOpen?`Hide filters`:`Show all`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,this._filtersMoreOpen?`true`:`false`)),this._panelInner&&(this._filtersMoreOpen&&t?this._panelInner.classList.add(`is-overflow-visible`):this._panelInner.classList.remove(`is-overflow-visible`)),this._scheduleFilterOverflowSync()}if(this._customResultsWrap){Array.from(this.children).filter(e=>e===this._shell||e===this._panel?!1:e.getAttribute(`slot`)===`results`).forEach(e=>this._customResultsWrap.appendChild(e));let e=this._customResultsWrap.childElementCount>0;this._customResultsWrap.classList.toggle(`is-hidden`,!e),e?(this._stateWrap?.classList.add(`is-hidden`),this._resultsWrap?.classList.add(`is-hidden`)):this._resultsWrap?.classList.remove(`is-hidden`)}this._renderSelectedFilter(),this._syncResponsiveChrome(),this._syncPanelVisibility()}_syncResponsiveChrome(){let e=this._collapseOnMobile();this._shell&&this._shell.classList.toggle(`is-collapsed`,e),this._panelSearchBar&&(this._panelSearchBar.classList.toggle(`is-hidden`,!e),this._panelSearchBar.classList.toggle(`is-collapsed`,e))}};customElements.get(`mint-search`)||e.t(`mint-search`,t),module.exports=t;
@@ -5,14 +5,14 @@ import '../../input.css'
5
5
  import '../../button.css'
6
6
  import '../../spinner.css'
7
7
  import '../../search.css'
8
- import "../chunks/icon-D7kATeRr.js";
8
+ import "../chunks/icon-hyFz3uhh.js";
9
9
  import { t as e } from "../chunks/register-element-BFYmIynH.js";
10
- import "../chunks/icon-BQqwHk-o.js";
11
- import "../chunks/close-C5b9RhcK.js";
12
- import "../chunks/button-CUWUQAt8.js";
13
- import "../chunks/chip-CbfqkmGQ.js";
14
- import "../chunks/input-B3XZ9L6B.js";
15
- import "../chunks/search-EHzNkMA7.js";
10
+ import "../chunks/icon-l34kRIZg.js";
11
+ import "../chunks/close-Cn8XLO1c.js";
12
+ import "../chunks/button-JPTyQfRs.js";
13
+ import "../chunks/chip-XuYPtZ3Z.js";
14
+ import "../chunks/input-j6FCwb-x.js";
15
+ import "../chunks/search-BwjKBnv9.js";
16
16
  //#region src/components/search/Search.ts
17
17
  var t = class e extends HTMLElement {
18
18
  constructor(...e) {
@@ -15,9 +15,9 @@ __mintLoadStyle('icon', '../../icon.css')
15
15
  __mintLoadStyle('popover', '../../popover.css')
16
16
  __mintLoadStyle('stack', '../../stack.css')
17
17
  __mintLoadStyle('select', '../../select.css')
18
- import "../chunks/icon-D7kATeRr.js";
18
+ import "../chunks/icon-hyFz3uhh.js";
19
19
  import { t as e } from "../chunks/register-element-BFYmIynH.js";
20
- import "../chunks/icon-BQqwHk-o.js";
20
+ import "../chunks/icon-l34kRIZg.js";
21
21
  import "../chunks/popover-C1qiTAvR.js";
22
22
  //#region src/components/select/NativeSelect.ts
23
23
  var t = "data-mint-native-select-part", n = class extends HTMLElement {
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-B8hR_TFn.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-CzgI_MCf.js`),require(`../chunks/popover-6cborap6.js`);var t=`data-mint-native-select-part`,n=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null,this._hostOptionsObserverRaf=null,this._generatedControlId=`mint-native-select-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-native-select-host`),this.getLabel()||console.error(`mint-native-select: The "label" attribute is required. Please provide a label for the select.`),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{if(e.some(e=>{let t=e.target;if(this._select&&(t===this._select||this._select.contains(t)))return!1;let n=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),r=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return n||r})){if(this._hostOptionsObserverRaf!==null)return;this._hostOptionsObserverRaf=requestAnimationFrame(()=>{this._hostOptionsObserverRaf=null,this.isConnected&&this.render()})}}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null),this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null)}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._syncSelectAccessibility());return}if(e===`loading`){this.render();return}if(e===`value`){if(this._select)if(this.isMultiple()){let e=[];try{let t=n?JSON.parse(n):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=n?[String(n)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=n||``;return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){if(this.isMultiple()&&this._select){let e=Array.from(this._select.selectedOptions).map(e=>e.value);return JSON.stringify(e)}return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(e=>String(e)):e==null||e===``?[]:[String(e)];this.setAttribute(`value`,JSON.stringify(t)),this._select&&Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)});return}let t=e==null?``:String(e);this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{if(this.isMultiple()){this.setValue(e);return}let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){let e=this.getAttribute(`disabled`);return e!==null&&e!==`false`}isMultiple(){let e=this.getAttribute(`multiple`);return e!==null&&e!==`false`}isRequired(){let e=this.getAttribute(`required`);return e!==null&&e!==`false`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){return[`mint-native-select-control`,this.isMultiple()?`is-multiple`:``,this.hasError()?`has-error`:``].filter(Boolean).join(` `)}render(){this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null);let e=this.isLoading(),n=this.isMultiple(),r=this.getValue(),i=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&i.push(e.cloneNode(!0))}),Array.from(this.children).forEach(e=>{e instanceof HTMLElement&&e.hasAttribute(t)&&e.remove()}),this._wrapper=null,this._select=null;let a=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0)),o=this.getLabel(),s=this.getInfo(),c=this.getId()||this._generatedControlId,l=this.getName(),u=this.isDisabled(),d=this.hasError();if(o){let e=document.createElement(`label`);e.setAttribute(t,`label`),e.className=`mint-native-select-label`,c&&e.setAttribute(`for`,c);let n=document.createTextNode(o);e.appendChild(n),this.appendChild(e)}this._wrapper=document.createElement(`div`),this._wrapper.setAttribute(t,`wrapper`),this._wrapper.className=`mint-native-select-control-wrap`,this.appendChild(this._wrapper),this._select=document.createElement(`select`),this._select.className=this.getSelectClasses(),c&&(this._select.id=c),l&&(this._select.name=l),u&&(this._select.disabled=!0),this._select.required=this.isRequired(),n&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,d?`true`:`false`);let f=this.getAttribute(`aria-label`)?.trim(),p=this.getAttribute(`aria-labelledby`)?.trim();p?this._select.setAttribute(`aria-labelledby`,p):o?this._select.removeAttribute(`aria-label`):this._select.setAttribute(`aria-label`,f||`Select an option`);let m=a.length>0?a:i;if(m.length>0&&m.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(n){let e=[];try{let t=r?JSON.parse(r):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=r?[String(r)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=r||``;if(this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target,r=n?Array.from(t.selectedOptions).map(e=>e.value):t.value,i=n?JSON.stringify(r):String(r||``);(this.getAttribute(`value`)||``)!==i&&(i?this.setAttribute(`value`,i):this.removeAttribute(`value`));let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{if(this._select)if(n){let t=[];try{let n=JSON.parse(e);t=Array.isArray(n)?n.map(e=>String(e)):[]}catch{t=[String(e)]}Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)})}else Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),n)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.className=`mint-native-select-caret`,this._caretUpIcon=document.createElement(`mint-icon`),this._caretUpIcon.setAttribute(`name`,`caret-up`),this._caretUpIcon.className=`mint-native-select-caret-up`,this._caretUpIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement(`mint-icon`),this._caretDownIcon.setAttribute(`name`,`caret-down`),this._caretDownIcon.className=`mint-native-select-caret-down`,this._caretDownIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(s){let e=document.createElement(`div`);e.setAttribute(t,`info`),e.className=`mint-native-select-info`,e.textContent=s,this.appendChild(e)}this._renderErrorState(),this._syncSelectAccessibility(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-native-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-native-select-skeleton-container`,t.setAttribute(`aria-hidden`,`true`),n?n.appendChild(t):this.appendChild(t));let e=t.querySelector(`.mint-native-select-skeleton`);e||(e=document.createElement(`div`),t.appendChild(e));let r=this.isMultiple();e.classList.toggle(`is-multiple`,r),e.style.height=r?`5rem`:`2rem`,t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`,this._select.setAttribute(`aria-busy`,`true`))}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`,this._select.removeAttribute(`aria-busy`))}_renderErrorState(){let e=this.hasError(),n=this.getErrorMessage(),r=this.querySelector(`.mint-native-select-error`);e&&n?(r?r.hasAttribute(t)||r.setAttribute(t,`error`):(r=document.createElement(`div`),r.setAttribute(t,`error`),r.className=`mint-native-select-error`,this.appendChild(r)),r.textContent=n):r&&r.remove()}_syncSelectAccessibility(){if(!this._select)return;let e=this._select.id||this._generatedControlId,n=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),r=this.querySelector(`[${t}="info"]`),i=this.querySelector(`.mint-native-select-error`);r&&(r.id=`${e}-info`,n.push(r.id)),i&&(i.id=`${e}-error`,n.push(i.id)),n.length?this._select.setAttribute(`aria-describedby`,Array.from(new Set(n)).join(` `)):this._select.removeAttribute(`aria-describedby`)}};customElements.get(`mint-native-select`)||e.t(`mint-native-select`,n);var r=`data-mint-select-part`,i=class extends HTMLElement{constructor(...e){super(...e),this._native=null,this._trigger=null,this._popover=null,this._list=null,this._observer=null,this._syncing=!1,this._typeahead=``,this._typeaheadTimer=null,this._pointerSelectedOption=null,this._id=`mint-select-${Math.random().toString(36).slice(2,10)}`}static get observedAttributes(){return[`name`,`value`,`values`,`multiple`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`loading`,`placeholder`,`aria-label`,`aria-labelledby`,`aria-describedby`,`form`]}connectedCallback(){this.classList.add(`mint-select-host`),this.render(),this._observer?.disconnect(),this._observer=new MutationObserver(e=>{this._syncing||e.some(e=>{let t=e.target instanceof Element?e.target:e.target.parentElement;return t===this||t?.closest(`[${r}]`)?!1:e.type===`attributes`?[`value`,`label`,`disabled`,`selected`].includes(e.attributeName):t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement||[...e.addedNodes,...e.removedNodes].some(e=>e instanceof HTMLOptionElement||e instanceof HTMLOptGroupElement)})&&this.render()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`label`,`disabled`,`selected`]})}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer)}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`values`&&this._native&&this.isMultiple()){this._applyValues(this.parseValues(n)),this.updateDisplay();return}if(e===`multiple`&&this._native){this.render();return}if(e===`value`&&this._native){this.isMultiple()?this._applyValues(n?[n]:[]):this._native.value=n||``,this.updateDisplay();return}this.render()}}get value(){return this.isMultiple()?this.values:this._native?.value||this.getAttribute(`value`)||``}set value(e){this.setValue(e)}get values(){return this._native&&this.isMultiple()?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`))}set values(e){this.setValue(e)}getValue(){return this.value}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)];this.setAttribute(`values`,JSON.stringify(t)),this._applyValues(t)}else{let t=e==null?``:String(e);this.setAttribute(`value`,t),this._native&&(this._native.value=t)}this.updateDisplay()}isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}isRequired(){return this.hasAttribute(`required`)&&this.getAttribute(`required`)!==`false`}isMultiple(){return this.hasAttribute(`multiple`)&&this.getAttribute(`multiple`)!==`false`}hasError(){return this.getAttribute(`error`)===`true`}parseValues(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){if(t.length===1&&typeof t[0]==`string`&&t[0].trim().startsWith(`[`))try{let e=JSON.parse(t[0]);if(Array.isArray(e))return e.map(String)}catch{}return t.map(String)}}catch{}return[e]}_applyValues(e){if(!this._native)return;let t=new Set(e);Array.from(this._native.options).forEach(e=>{e.selected=t.has(e.value)})}options(){return Array.from(this.querySelectorAll(`:scope > option, :scope > optgroup > option`))}selectedOption(){return this._native?.selectedOptions[0]||this.options().find(e=>e.value===this.value)}render(){let e=this._native?.value||this.getAttribute(`value`)||``,t=this._native?.multiple?Array.from(this._native.selectedOptions,e=>e.value):[],n=t.length?t:this.parseValues(this.getAttribute(`values`));this._syncing=!0,Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let i=this.getAttribute(`label`)?.trim()||``,a=this.getAttribute(`id`)||this._id;if(i){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${a}-trigger`,e.textContent=i,this.append(e)}let o=document.createElement(`div`);o.setAttribute(r,`wrap`),o.className=`mint-select-control-wrap`,o.style.position=`relative`,this.append(o);let s=document.createElement(`button`);s.type=`button`,s.id=`${a}-trigger`,s.className=`mint-select-trigger`,s.disabled=this.isDisabled()||this.isLoading(),s.setAttribute(`role`,`combobox`),s.setAttribute(`aria-busy`,String(this.isLoading())),s.setAttribute(`aria-haspopup`,`listbox`),s.setAttribute(`aria-expanded`,`false`),s.setAttribute(`aria-required`,String(this.isRequired())),s.setAttribute(`aria-invalid`,String(this.hasError()));let c=this.getAttribute(`aria-labelledby`),l=this.getAttribute(`aria-label`)?.trim();if(c?s.setAttribute(`aria-labelledby`,c):!i&&l?s.setAttribute(`aria-label`,l):i&&s.setAttribute(`aria-labelledby`,`${a}-label`),i){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${a}-label`)}let u=document.createElement(`span`);u.className=`mint-select-value`,s.append(u);let d=document.createElement(`span`);d.className=`mint-select-caret`,d.setAttribute(`aria-hidden`,`true`),d.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,s.append(d),o.append(s);let f=null;this.isLoading()?(f=document.createElement(`div`),f.className=`mint-select-skeleton`,f.setAttribute(`aria-hidden`,`true`),f.style.cssText=`position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;`,o.append(f),s.style.visibility=`hidden`,this.setAttribute(`aria-busy`,`true`)):this.removeAttribute(`aria-busy`);let p=document.createElement(`select`);p.setAttribute(r,`native`),p.className=`mint-select-native-control`,p.id=`${a}-native`,p.name=this.getAttribute(`name`)||``,p.multiple=this.isMultiple(),this.hasAttribute(`form`)&&p.setAttribute(`form`,this.getAttribute(`form`)||``),p.required=this.isRequired(),p.disabled=this.isDisabled(),p.tabIndex=-1,p.setAttribute(`aria-hidden`,`true`),p.setAttribute(`aria-invalid`,String(this.hasError()));let m=[this.getAttribute(`aria-describedby`),i?`${a}-label`:``,this.getAttribute(`info`)?`${a}-info`:``,this.getAttribute(`error-message`)?`${a}-error`:``].filter(Boolean).join(` `);if(m&&p.setAttribute(`aria-describedby`,m),this.options().forEach(e=>p.append(e.cloneNode(!0))),!p.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,p.append(e)}if(p.multiple){let t=n.length?n:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];t.length&&Array.from(p.options).forEach(e=>{e.selected=t.includes(e.value)})}else p.value=e;o.append(p),this._native=p,this._trigger=s;let h=document.createElement(`mint-popover`);h.className=`mint-select-popover`,h.setAttribute(r,`popover`),h.setAttribute(`trigger-id`,s.id),h.setAttribute(`trigger-toggle`,`false`),h.setAttribute(`direction`,`down`),h.setAttribute(`trigger-align`,`start`),h.setAttribute(`align-selected`,`true`),h.setAttribute(`distance`,`4`),h.setAttribute(`padding`,`0`),h.setAttribute(`aria-label`,i?`${i} options`:`Select options`);let g=document.createElement(`div`);g.className=`mint-select-options`,g.id=`${a}-listbox`,g.setAttribute(`role`,`listbox`),g.setAttribute(`aria-multiselectable`,String(this.isMultiple())),s.setAttribute(`aria-controls`,g.id),h.append(g),this.append(h),this._popover=h,this._list=g,this.renderOptions(),this.updateDisplay(),this.bindEvents();let _=this.getAttribute(`info`);if(_){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${a}-info`,e.textContent=_,this.append(e)}let v=this.getAttribute(`error-message`);if(this.hasError()&&v){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${a}-error`,e.textContent=v,this.append(e)}this._syncing=!1}renderOptions(){this._list&&(this._list.replaceChildren(),Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).forEach(e=>{if(e instanceof HTMLOptGroupElement){let t=document.createElement(`div`);t.className=`mint-select-group-label`,t.setAttribute(`role`,`presentation`),t.textContent=e.label,this._list.append(t),Array.from(e.children).forEach(t=>this.addOption(t,e.disabled))}else this.addOption(e,!1)}))}addOption(e,t){if(!this._list)return;let n=document.createElement(`button`);n.type=`button`,n.className=`mint-select-option`,n.dataset.value=e.value,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(this.isMultiple()?this.values.includes(e.value):e.value===this.value)),n.disabled=e.disabled||t||this.isDisabled(),n.tabIndex=-1;let r=document.createElement(`span`);r.textContent=e.label||e.textContent||``,n.append(r);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`check`),i.setAttribute(`aria-hidden`,`true`),i.className=`mint-select-option-check`,n.append(i),this._list.append(n)}updateDisplay(){if(!this._native||!this._trigger)return;let e=this.selectedOption(),t=this.values,n=this.isMultiple()?t.map(e=>this.options().find(t=>t.value===e)?.label||e):[],r=this._trigger.querySelector(`.mint-select-value`);r&&(r.textContent=this.isMultiple()?n.join(`, `)||this.getAttribute(`placeholder`)||`Select an option`:e?.label||e?.textContent?.trim()||this.getAttribute(`placeholder`)||`Select an option`,r.classList.toggle(`is-placeholder`,this.isMultiple()?t.length===0:!e||e.value===``)),this._trigger.setAttribute(`aria-invalid`,String(this.hasError())),this._trigger.setAttribute(`aria-haspopup`,`listbox`),this._list?.setAttribute(`aria-multiselectable`,String(this.isMultiple())),this._list?.querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,String(this.isMultiple()?t.includes(e.dataset.value||``):e.dataset.value===this._native.value)))}bindEvents(){!this._trigger||!this._popover||!this._native||!this._list||(this._trigger.onclick=()=>{this._popover.style.setProperty(`--mint-select-popover-width`,`${this._trigger.getBoundingClientRect().width}px`),this._popover.hasAttribute(`open`)?this._popover.close():this.openPopover()},this._trigger.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),this._popover.hasAttribute(`open`)||this.openPopover();let n=t.findIndex(e=>e.dataset.value===(this.isMultiple()?this.values[0]:this._native.value));t[e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n<=0?0:n-1)]?.focus()}else if(e.key===`Enter`||e.key===` `)if(this._popover.hasAttribute(`open`)){e.preventDefault();let t=this._list.querySelector(`[role="option"]:focus`);t?this.selectOption(t.dataset.value||``):this.openPopover()}else e.key===` `&&(e.preventDefault(),this.openPopover());else e.key===`Escape`&&this._popover.hasAttribute(`open`)?(e.preventDefault(),this._popover.close(),this._trigger.focus()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.typeahead(e.key)},this._list.onpointerdown=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;e.preventDefault();let n=t.dataset.value||``;this._pointerSelectedOption={value:n,time:Date.now()},this.selectOption(n)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;let n=t.dataset.value||``,r=this._pointerSelectedOption?.value===n&&Date.now()-this._pointerSelectedOption.time<1e3;this._pointerSelectedOption=null,r||this.selectOption(n)},this._list.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`)),n=t.indexOf(e.target),r=n;if(e.key===`ArrowDown`)r=Math.min(t.length-1,n+1);else if(e.key===`ArrowUp`)r=Math.max(0,n-1);else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),this._popover.close(),this._trigger.focus();return}else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.selectOption(e.target.dataset.value||``);return}else if(e.key.length===1){this.typeahead(e.key);return}else return;e.preventDefault(),t[r]?.focus()},this._native.onchange=()=>{this.isMultiple()?this.setAttribute(`values`,JSON.stringify(this.values)):this.setAttribute(`value`,this._native.value),this.updateDisplay(),this.dispatchSelectionEvents()})}openPopover(){this._popover&&this._popover.open()}selectOption(e){if(this._native){if(this.isMultiple()){let t=new Set(this.values);t.has(e)?t.delete(e):t.add(e);let n=[...t];this._applyValues(n),this.setAttribute(`values`,JSON.stringify(n)),this.updateDisplay(),this.dispatchSelectionEvents();return}this._native.value=e,this.setAttribute(`value`,e),this.updateDisplay(),this._popover?.close(),this._trigger?.focus(),this.dispatchSelectionEvents()}}dispatchSelectionEvents(){let e=this.isMultiple()?this.values:this._native?.value||``,t=this.isMultiple()?{value:e,values:e}:{value:e};this.dispatchEvent(new CustomEvent(`input`,{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,composed:!0,detail:t}))}typeahead(e){this._typeahead+=e.toLocaleLowerCase(),this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``},700);let t=Array.from(this._list?.querySelectorAll(`[role="option"]:not(:disabled)`)||[]).find(e=>e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));t&&(this._popover?.hasAttribute(`open`)||this.openPopover(),t.focus())}};customElements.get(`mint-select`)||e.t(`mint-select`,i),exports.NativeSelect=n,exports.default=i;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-CWOP4Com.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-D6C1XGp2.js`),require(`../chunks/popover-6cborap6.js`);var t=`data-mint-native-select-part`,n=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`,`aria-label`,`aria-labelledby`,`aria-describedby`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null,this._hostOptionsObserverRaf=null,this._generatedControlId=`mint-native-select-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-native-select-host`),this.getLabel()||console.error(`mint-native-select: The "label" attribute is required. Please provide a label for the select.`),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{if(e.some(e=>{let t=e.target;if(this._select&&(t===this._select||this._select.contains(t)))return!1;let n=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),r=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return n||r})){if(this._hostOptionsObserverRaf!==null)return;this._hostOptionsObserverRaf=requestAnimationFrame(()=>{this._hostOptionsObserverRaf=null,this.isConnected&&this.render()})}}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null),this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null)}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._syncSelectAccessibility());return}if(e===`loading`){this.render();return}if(e===`value`){if(this._select)if(this.isMultiple()){let e=[];try{let t=n?JSON.parse(n):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=n?[String(n)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=n||``;return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){if(this.isMultiple()&&this._select){let e=Array.from(this._select.selectedOptions).map(e=>e.value);return JSON.stringify(e)}return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(e=>String(e)):e==null||e===``?[]:[String(e)];this.setAttribute(`value`,JSON.stringify(t)),this._select&&Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)});return}let t=e==null?``:String(e);this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{if(this.isMultiple()){this.setValue(e);return}let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){let e=this.getAttribute(`disabled`);return e!==null&&e!==`false`}isMultiple(){let e=this.getAttribute(`multiple`);return e!==null&&e!==`false`}isRequired(){let e=this.getAttribute(`required`);return e!==null&&e!==`false`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){return[`mint-native-select-control`,this.isMultiple()?`is-multiple`:``,this.hasError()?`has-error`:``].filter(Boolean).join(` `)}render(){this._hostOptionsObserverRaf!==null&&(cancelAnimationFrame(this._hostOptionsObserverRaf),this._hostOptionsObserverRaf=null);let e=this.isLoading(),n=this.isMultiple(),r=this.getValue(),i=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&i.push(e.cloneNode(!0))}),Array.from(this.children).forEach(e=>{e instanceof HTMLElement&&e.hasAttribute(t)&&e.remove()}),this._wrapper=null,this._select=null;let a=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0)),o=this.getLabel(),s=this.getInfo(),c=this.getId()||this._generatedControlId,l=this.getName(),u=this.isDisabled(),d=this.hasError();if(o){let e=document.createElement(`label`);e.setAttribute(t,`label`),e.className=`mint-native-select-label`,c&&e.setAttribute(`for`,c);let n=document.createTextNode(o);e.appendChild(n),this.appendChild(e)}this._wrapper=document.createElement(`div`),this._wrapper.setAttribute(t,`wrapper`),this._wrapper.className=`mint-native-select-control-wrap`,this.appendChild(this._wrapper),this._select=document.createElement(`select`),this._select.className=this.getSelectClasses(),c&&(this._select.id=c),l&&(this._select.name=l),u&&(this._select.disabled=!0),this._select.required=this.isRequired(),n&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,d?`true`:`false`);let f=this.getAttribute(`aria-label`)?.trim(),p=this.getAttribute(`aria-labelledby`)?.trim();p?this._select.setAttribute(`aria-labelledby`,p):o?this._select.removeAttribute(`aria-label`):this._select.setAttribute(`aria-label`,f||`Select an option`);let m=a.length>0?a:i;if(m.length>0&&m.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(n){let e=[];try{let t=r?JSON.parse(r):[];e=Array.isArray(t)?t.map(e=>String(e)):[]}catch{e=r?[String(r)]:[]}Array.from(this._select.options).forEach(t=>{t.selected=e.includes(t.value)})}else this._select.value=r||``;if(this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target,r=n?Array.from(t.selectedOptions).map(e=>e.value):t.value,i=n?JSON.stringify(r):String(r||``);(this.getAttribute(`value`)||``)!==i&&(i?this.setAttribute(`value`,i):this.removeAttribute(`value`));let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{if(this._select)if(n){let t=[];try{let n=JSON.parse(e);t=Array.isArray(n)?n.map(e=>String(e)):[]}catch{t=[String(e)]}Array.from(this._select.options).forEach(e=>{e.selected=t.includes(e.value)})}else Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),n)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.className=`mint-native-select-caret`,this._caretUpIcon=document.createElement(`mint-icon`),this._caretUpIcon.setAttribute(`name`,`caret-up`),this._caretUpIcon.className=`mint-native-select-caret-up`,this._caretUpIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement(`mint-icon`),this._caretDownIcon.setAttribute(`name`,`caret-down`),this._caretDownIcon.className=`mint-native-select-caret-down`,this._caretDownIcon.setAttribute(`aria-hidden`,`true`),e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(s){let e=document.createElement(`div`);e.setAttribute(t,`info`),e.className=`mint-native-select-info`,e.textContent=s,this.appendChild(e)}this._renderErrorState(),this._syncSelectAccessibility(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-native-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-native-select-skeleton-container`,t.setAttribute(`aria-hidden`,`true`),n?n.appendChild(t):this.appendChild(t));let e=t.querySelector(`.mint-native-select-skeleton`);e||(e=document.createElement(`div`),t.appendChild(e));let r=this.isMultiple();e.classList.toggle(`is-multiple`,r),e.style.height=r?`5rem`:`2rem`,t.style.display=`block`,this._select&&(this._select.style.opacity=`0`,this._select.style.pointerEvents=`none`,this._select.setAttribute(`aria-busy`,`true`))}else t&&(t.style.display=`none`),this._select&&(this._select.style.opacity=`1`,this._select.style.pointerEvents=`auto`,this._select.removeAttribute(`aria-busy`))}_renderErrorState(){let e=this.hasError(),n=this.getErrorMessage(),r=this.querySelector(`.mint-native-select-error`);e&&n?(r?r.hasAttribute(t)||r.setAttribute(t,`error`):(r=document.createElement(`div`),r.setAttribute(t,`error`),r.className=`mint-native-select-error`,this.appendChild(r)),r.textContent=n):r&&r.remove()}_syncSelectAccessibility(){if(!this._select)return;let e=this._select.id||this._generatedControlId,n=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),r=this.querySelector(`[${t}="info"]`),i=this.querySelector(`.mint-native-select-error`);r&&(r.id=`${e}-info`,n.push(r.id)),i&&(i.id=`${e}-error`,n.push(i.id)),n.length?this._select.setAttribute(`aria-describedby`,Array.from(new Set(n)).join(` `)):this._select.removeAttribute(`aria-describedby`)}};customElements.get(`mint-native-select`)||e.t(`mint-native-select`,n);var r=`data-mint-select-part`,i=class extends HTMLElement{constructor(...e){super(...e),this._native=null,this._trigger=null,this._popover=null,this._list=null,this._observer=null,this._syncing=!1,this._typeahead=``,this._typeaheadTimer=null,this._pointerSelectedOption=null,this._id=`mint-select-${Math.random().toString(36).slice(2,10)}`}static get observedAttributes(){return[`name`,`value`,`values`,`multiple`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`loading`,`placeholder`,`aria-label`,`aria-labelledby`,`aria-describedby`,`form`]}connectedCallback(){this.classList.add(`mint-select-host`),this.render(),this._observer?.disconnect(),this._observer=new MutationObserver(e=>{this._syncing||e.some(e=>{let t=e.target instanceof Element?e.target:e.target.parentElement;return t===this||t?.closest(`[${r}]`)?!1:e.type===`attributes`?[`value`,`label`,`disabled`,`selected`].includes(e.attributeName):t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement||[...e.addedNodes,...e.removedNodes].some(e=>e instanceof HTMLOptionElement||e instanceof HTMLOptGroupElement)})&&this.render()}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`label`,`disabled`,`selected`]})}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer)}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`values`&&this._native&&this.isMultiple()){this._applyValues(this.parseValues(n)),this.updateDisplay();return}if(e===`multiple`&&this._native){this.render();return}if(e===`value`&&this._native){this.isMultiple()?this._applyValues(n?[n]:[]):this._native.value=n||``,this.updateDisplay();return}this.render()}}get value(){return this.isMultiple()?this.values:this._native?.value||this.getAttribute(`value`)||``}set value(e){this.setValue(e)}get values(){return this._native&&this.isMultiple()?Array.from(this._native.selectedOptions,e=>e.value):this.parseValues(this.getAttribute(`values`))}set values(e){this.setValue(e)}getValue(){return this.value}setValue(e){if(this.isMultiple()){let t=Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)];this.setAttribute(`values`,JSON.stringify(t)),this._applyValues(t)}else{let t=e==null?``:String(e);this.setAttribute(`value`,t),this._native&&(this._native.value=t)}this.updateDisplay()}isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}isLoading(){let e=this.getAttribute(`loading`);return e!==null&&e!==`false`}isRequired(){return this.hasAttribute(`required`)&&this.getAttribute(`required`)!==`false`}isMultiple(){return this.hasAttribute(`multiple`)&&this.getAttribute(`multiple`)!==`false`}hasError(){return this.getAttribute(`error`)===`true`}parseValues(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t)){if(t.length===1&&typeof t[0]==`string`&&t[0].trim().startsWith(`[`))try{let e=JSON.parse(t[0]);if(Array.isArray(e))return e.map(String)}catch{}return t.map(String)}}catch{}return[e]}_applyValues(e){if(!this._native)return;let t=new Set(e);Array.from(this._native.options).forEach(e=>{e.selected=t.has(e.value)})}options(){return Array.from(this.querySelectorAll(`:scope > option, :scope > optgroup > option`))}selectedOption(){return this._native?.selectedOptions[0]||this.options().find(e=>e.value===this.value)}render(){let e=this._native?.value||this.getAttribute(`value`)||``,t=this._native?.multiple?Array.from(this._native.selectedOptions,e=>e.value):[],n=t.length?t:this.parseValues(this.getAttribute(`values`));this._syncing=!0,Array.from(this.children).forEach(e=>{e.hasAttribute(r)&&e.remove()});let i=this.getAttribute(`label`)?.trim()||``,a=this.getAttribute(`id`)||this._id;if(i){let e=document.createElement(`label`);e.setAttribute(r,`label`),e.className=`mint-select-label`,e.htmlFor=`${a}-trigger`,e.textContent=i,this.append(e)}let o=document.createElement(`div`);o.setAttribute(r,`wrap`),o.className=`mint-select-control-wrap`,o.style.position=`relative`,this.append(o);let s=document.createElement(`button`);s.type=`button`,s.id=`${a}-trigger`,s.className=`mint-select-trigger`,s.disabled=this.isDisabled()||this.isLoading(),s.setAttribute(`role`,`combobox`),s.setAttribute(`aria-busy`,String(this.isLoading())),s.setAttribute(`aria-haspopup`,`listbox`),s.setAttribute(`aria-expanded`,`false`),s.setAttribute(`aria-required`,String(this.isRequired())),s.setAttribute(`aria-invalid`,String(this.hasError()));let c=this.getAttribute(`aria-labelledby`),l=this.getAttribute(`aria-label`)?.trim();if(c?s.setAttribute(`aria-labelledby`,c):!i&&l?s.setAttribute(`aria-label`,l):i&&s.setAttribute(`aria-labelledby`,`${a}-label`),i){let e=this.querySelector(`[${r}="label"]`);e&&(e.id=`${a}-label`)}let u=document.createElement(`span`);u.className=`mint-select-value`,s.append(u);let d=document.createElement(`span`);d.className=`mint-select-caret`,d.setAttribute(`aria-hidden`,`true`),d.innerHTML=`<mint-icon name="caret-up"></mint-icon><mint-icon name="caret-down"></mint-icon>`,s.append(d),o.append(s);let f=null;this.isLoading()?(f=document.createElement(`div`),f.className=`mint-select-skeleton`,f.setAttribute(`aria-hidden`,`true`),f.style.cssText=`position:absolute;inset:0;z-index:1;border:1px solid var(--mint-color-border,#dfe6e0);border-radius:.5rem;background:var(--mint-color-surface-muted,#e8eee9);animation:mint-select-pulse 1.4s ease-in-out infinite;`,o.append(f),s.style.visibility=`hidden`,this.setAttribute(`aria-busy`,`true`)):this.removeAttribute(`aria-busy`);let p=document.createElement(`select`);p.setAttribute(r,`native`),p.className=`mint-select-native-control`,p.id=`${a}-native`,p.name=this.getAttribute(`name`)||``,p.multiple=this.isMultiple(),this.hasAttribute(`form`)&&p.setAttribute(`form`,this.getAttribute(`form`)||``),p.required=this.isRequired(),p.disabled=this.isDisabled(),p.tabIndex=-1,p.setAttribute(`aria-hidden`,`true`),p.setAttribute(`aria-invalid`,String(this.hasError()));let m=[this.getAttribute(`aria-describedby`),i?`${a}-label`:``,this.getAttribute(`info`)?`${a}-info`:``,this.getAttribute(`error-message`)?`${a}-error`:``].filter(Boolean).join(` `);if(m&&p.setAttribute(`aria-describedby`,m),this.options().forEach(e=>p.append(e.cloneNode(!0))),!p.options.length){let e=document.createElement(`option`);e.value=``,e.textContent=this.getAttribute(`placeholder`)||`Select an option`,e.disabled=!0,p.append(e)}if(p.multiple){let t=n.length?n:this.parseValues(this.getAttribute(`values`)).length?this.parseValues(this.getAttribute(`values`)):e?[e]:[];t.length&&Array.from(p.options).forEach(e=>{e.selected=t.includes(e.value)})}else p.value=e;o.append(p),this._native=p,this._trigger=s;let h=document.createElement(`mint-popover`);h.className=`mint-select-popover`,h.setAttribute(r,`popover`),h.setAttribute(`trigger-id`,s.id),h.setAttribute(`trigger-toggle`,`false`),h.setAttribute(`direction`,`down`),h.setAttribute(`trigger-align`,`start`),h.setAttribute(`align-selected`,`true`),h.setAttribute(`distance`,`4`),h.setAttribute(`padding`,`0`),h.setAttribute(`aria-label`,i?`${i} options`:`Select options`);let g=document.createElement(`div`);g.className=`mint-select-options`,g.id=`${a}-listbox`,g.setAttribute(`role`,`listbox`),g.setAttribute(`aria-multiselectable`,String(this.isMultiple())),s.setAttribute(`aria-controls`,g.id),h.append(g),this.append(h),this._popover=h,this._list=g,this.renderOptions(),this.updateDisplay(),this.bindEvents();let _=this.getAttribute(`info`);if(_){let e=document.createElement(`div`);e.setAttribute(r,`info`),e.className=`mint-select-info`,e.id=`${a}-info`,e.textContent=_,this.append(e)}let v=this.getAttribute(`error-message`);if(this.hasError()&&v){let e=document.createElement(`div`);e.setAttribute(r,`error`),e.className=`mint-select-error`,e.id=`${a}-error`,e.textContent=v,this.append(e)}this._syncing=!1}renderOptions(){this._list&&(this._list.replaceChildren(),Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).forEach(e=>{if(e instanceof HTMLOptGroupElement){let t=document.createElement(`div`);t.className=`mint-select-group-label`,t.setAttribute(`role`,`presentation`),t.textContent=e.label,this._list.append(t),Array.from(e.children).forEach(t=>this.addOption(t,e.disabled))}else this.addOption(e,!1)}))}addOption(e,t){if(!this._list)return;let n=document.createElement(`button`);n.type=`button`,n.className=`mint-select-option`,n.dataset.value=e.value,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(this.isMultiple()?this.values.includes(e.value):e.value===this.value)),n.disabled=e.disabled||t||this.isDisabled(),n.tabIndex=-1;let r=document.createElement(`span`);r.textContent=e.label||e.textContent||``,n.append(r);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`check`),i.setAttribute(`aria-hidden`,`true`),i.className=`mint-select-option-check`,n.append(i),this._list.append(n)}updateDisplay(){if(!this._native||!this._trigger)return;let e=this.selectedOption(),t=this.values,n=this.isMultiple()?t.map(e=>this.options().find(t=>t.value===e)?.label||e):[],r=this._trigger.querySelector(`.mint-select-value`);r&&(r.textContent=this.isMultiple()?n.join(`, `)||this.getAttribute(`placeholder`)||`Select an option`:e?.label||e?.textContent?.trim()||this.getAttribute(`placeholder`)||`Select an option`,r.classList.toggle(`is-placeholder`,this.isMultiple()?t.length===0:!e||e.value===``)),this._trigger.setAttribute(`aria-invalid`,String(this.hasError())),this._trigger.setAttribute(`aria-haspopup`,`listbox`),this._list?.setAttribute(`aria-multiselectable`,String(this.isMultiple())),this._list?.querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,String(this.isMultiple()?t.includes(e.dataset.value||``):e.dataset.value===this._native.value)))}bindEvents(){!this._trigger||!this._popover||!this._native||!this._list||(this._trigger.onclick=()=>{this._popover.style.setProperty(`--mint-select-popover-width`,`${this._trigger.getBoundingClientRect().width}px`),this._popover.hasAttribute(`open`)?this._popover.close():this.openPopover()},this._trigger.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`));if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),this._popover.hasAttribute(`open`)||this.openPopover();let n=t.findIndex(e=>e.dataset.value===(this.isMultiple()?this.values[0]:this._native.value));t[e.key===`ArrowDown`?Math.min(t.length-1,n+1):Math.max(0,n<=0?0:n-1)]?.focus()}else if(e.key===`Enter`||e.key===` `)if(this._popover.hasAttribute(`open`)){e.preventDefault();let t=this._list.querySelector(`[role="option"]:focus`);t?this.selectOption(t.dataset.value||``):this.openPopover()}else e.key===` `&&(e.preventDefault(),this.openPopover());else e.key===`Escape`&&this._popover.hasAttribute(`open`)?(e.preventDefault(),this._popover.close(),this._trigger.focus()):e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.typeahead(e.key)},this._list.onpointerdown=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;e.preventDefault();let n=t.dataset.value||``;this._pointerSelectedOption={value:n,time:Date.now()},this.selectOption(n)},this._list.onclick=e=>{let t=e.target.closest(`[role="option"]`);if(!t||t.disabled)return;let n=t.dataset.value||``,r=this._pointerSelectedOption?.value===n&&Date.now()-this._pointerSelectedOption.time<1e3;this._pointerSelectedOption=null,r||this.selectOption(n)},this._list.onkeydown=e=>{let t=Array.from(this._list.querySelectorAll(`[role="option"]:not(:disabled)`)),n=t.indexOf(e.target),r=n;if(e.key===`ArrowDown`)r=Math.min(t.length-1,n+1);else if(e.key===`ArrowUp`)r=Math.max(0,n-1);else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else if(e.key===`Escape`){e.preventDefault(),this._popover.close(),this._trigger.focus();return}else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.selectOption(e.target.dataset.value||``);return}else if(e.key.length===1){this.typeahead(e.key);return}else return;e.preventDefault(),t[r]?.focus()},this._native.onchange=()=>{this.isMultiple()?this.setAttribute(`values`,JSON.stringify(this.values)):this.setAttribute(`value`,this._native.value),this.updateDisplay(),this.dispatchSelectionEvents()})}openPopover(){this._popover&&this._popover.open()}selectOption(e){if(this._native){if(this.isMultiple()){let t=new Set(this.values);t.has(e)?t.delete(e):t.add(e);let n=[...t];this._applyValues(n),this.setAttribute(`values`,JSON.stringify(n)),this.updateDisplay(),this.dispatchSelectionEvents();return}this._native.value=e,this.setAttribute(`value`,e),this.updateDisplay(),this._popover?.close(),this._trigger?.focus(),this.dispatchSelectionEvents()}}dispatchSelectionEvents(){let e=this.isMultiple()?this.values:this._native?.value||``,t=this.isMultiple()?{value:e,values:e}:{value:e};this.dispatchEvent(new CustomEvent(`input`,{bubbles:!0,composed:!0,detail:t})),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,composed:!0,detail:t}))}typeahead(e){this._typeahead+=e.toLocaleLowerCase(),this._typeaheadTimer!==null&&window.clearTimeout(this._typeaheadTimer),this._typeaheadTimer=window.setTimeout(()=>{this._typeahead=``},700);let t=Array.from(this._list?.querySelectorAll(`[role="option"]:not(:disabled)`)||[]).find(e=>e.textContent?.trim().toLocaleLowerCase().startsWith(this._typeahead));t&&(this._popover?.hasAttribute(`open`)||this.openPopover(),t.focus())}};customElements.get(`mint-select`)||e.t(`mint-select`,i),exports.NativeSelect=n,exports.default=i;
@@ -3,9 +3,9 @@ import '../../icon.css'
3
3
  import '../../popover.css'
4
4
  import '../../stack.css'
5
5
  import '../../select.css'
6
- import "../chunks/icon-D7kATeRr.js";
6
+ import "../chunks/icon-hyFz3uhh.js";
7
7
  import { t as e } from "../chunks/register-element-BFYmIynH.js";
8
- import "../chunks/icon-BQqwHk-o.js";
8
+ import "../chunks/icon-l34kRIZg.js";
9
9
  import "../chunks/popover-C1qiTAvR.js";
10
10
  //#region src/components/select/NativeSelect.ts
11
11
  var t = "data-mint-native-select-part", n = class extends HTMLElement {
@@ -16,12 +16,12 @@ __mintLoadStyle('text', '../../text.css')
16
16
  __mintLoadStyle('popover', '../../popover.css')
17
17
  __mintLoadStyle('stack', '../../stack.css')
18
18
  __mintLoadStyle('side-navigation', '../../side-navigation.css')
19
- import "../chunks/icon-D7kATeRr.js";
19
+ import "../chunks/icon-hyFz3uhh.js";
20
20
  import { t as e } from "../chunks/register-element-BFYmIynH.js";
21
- import "../chunks/icon-BQqwHk-o.js";
21
+ import "../chunks/icon-l34kRIZg.js";
22
22
  import "../chunks/text-C-6UCBp-.js";
23
- import "../chunks/caret-right-DMCejGQ6.js";
24
- import "../chunks/caret-down-oeRBseTW.js";
23
+ import "../chunks/caret-right-BlRbsLlh.js";
24
+ import "../chunks/caret-down-ZjQN2yKq.js";
25
25
  import "../chunks/popover-C1qiTAvR.js";
26
26
  import { n as t } from "../chunks/ScrollFade-DvzPIk2A.js";
27
27
  //#region src/components/side-navigation/SideNavigationLink.ts