import { p as t, H as i, c as e, h as s, F as n, t as o } from './p-BfLQgzDX.js';
import { c as r } from './p-D7YaJBkB.js';
import { g as l, d as a } from './p-CE6EHX9u.js';
import { f as h, a as d } from './p-BiHzhysf.js';
import { C as u } from './p-C0U9wSBw.js';
import { d as c } from './p-5F1gBr3j.js';
import { d as p } from './p-f9tCETeY.js';
import { d as f } from './p-dR-hNm6x.js';
import { d as v } from './p-BpML1w-i.js';
import { d as m } from './p-C6qt54JA.js';
import { v as b } from './p-CK3_k8jD.js';
import { b as k, k as w, a as y, i as g } from './p-DzS7aqZe.js';
import { f as x, h as j, l as C, q as O, p as A, S as I, i as E, s as L, b as S, m as _, a as z } from './p-BmF3Oegw.js';
import { i as D, b as M } from './p-BvYuaZU5.js';
function T(t) {
  return 'symbol' == typeof t || (x(t) && '[object Symbol]' == j(t));
}
var F = O ? O.prototype : void 0,
  B = F ? F.toString : void 0;
function K(t) {
  if ('string' == typeof t) return t;
  if (C(t))
    return (
      (function (t, i) {
        for (var e = -1, s = null == t ? 0 : t.length, n = Array(s); ++e < s; ) n[e] = i(t[e], e, t);
        return n;
      })(t, K) + ''
    );
  if (T(t)) return B ? B.call(t) : '';
  var i = t + '';
  return '0' == i && 1 / t == -1 / 0 ? '-0' : i;
}
var R = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  H = /^\w*$/;
function N(t, i) {
  if (C(t)) return !1;
  var e = typeof t;
  return !('number' != e && 'symbol' != e && 'boolean' != e && null != t && !T(t)) || H.test(t) || !R.test(t) || (null != i && t in Object(i));
}
function U(t, i) {
  if ('function' != typeof t || (null != i && 'function' != typeof i)) throw new TypeError('Expected a function');
  var e = function () {
    var s = arguments,
      n = i ? i.apply(this, s) : s[0],
      o = e.cache;
    if (o.has(n)) return o.get(n);
    var r = t.apply(this, s);
    return ((e.cache = o.set(n, r) || o), r);
  };
  return ((e.cache = new (U.Cache || A)()), e);
}
U.Cache = A;
var $,
  V,
  q,
  P = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,
  Y = /\\(\\)?/g,
  J =
    (($ = function (t) {
      var i = [];
      return (
        46 === t.charCodeAt(0) && i.push(''),
        t.replace(P, function (t, e, s, n) {
          i.push(s ? n.replace(Y, '$1') : e || t);
        }),
        i
      );
    }),
    (V = U($, function (t) {
      return (500 === q.size && q.clear(), t);
    })),
    (q = V.cache),
    V);
function W(t, i) {
  return C(t)
    ? t
    : N(t, i)
      ? [t]
      : J(
          (function (t) {
            return null == t ? '' : K(t);
          })(t),
        );
}
function X(t) {
  if ('string' == typeof t || T(t)) return t;
  var i = t + '';
  return '0' == i && 1 / t == -1 / 0 ? '-0' : i;
}
function Z(t, i) {
  for (var e = 0, s = (i = W(i, t)).length; null != t && e < s; ) t = t[X(i[e++])];
  return e && e == s ? t : void 0;
}
function G(t) {
  return t == t && !E(t);
}
function Q(t, i) {
  return function (e) {
    return null != e && e[t] === i && (void 0 !== i || t in Object(e));
  };
}
function tt(t, i) {
  return null != t && i in Object(t);
}
function it(t, i) {
  return N(t) && G(i)
    ? Q(X(t), i)
    : function (e) {
        var s = (function (t, i) {
          var e = null == t ? void 0 : Z(t, i);
          return void 0 === e ? void 0 : e;
        })(e, t);
        return void 0 === s && s === i
          ? (function (t, i) {
              return (
                null != t &&
                (function (t, i, e) {
                  for (var s = -1, n = (i = W(i, t)).length, o = !1; ++s < n; ) {
                    var r = X(i[s]);
                    if (!(o = null != t && e(t, r))) break;
                    t = t[r];
                  }
                  return o || ++s != n ? o : !!(n = null == t ? 0 : t.length) && L(n) && S(r, n) && (C(t) || _(t));
                })(t, i, tt)
              );
            })(e, t)
          : k(i, s, 3);
      };
}
function et(t) {
  return 'function' == typeof t
    ? t
    : null == t
      ? D
      : 'object' == typeof t
        ? C(t)
          ? it(t[0], t[1])
          : ((n = (function (t) {
              for (var i = w(t), e = i.length; e--; ) {
                var s = i[e],
                  n = t[s];
                i[e] = [s, n, G(n)];
              }
              return i;
            })((s = t))),
            1 == n.length && n[0][2]
              ? Q(n[0][0], n[0][1])
              : function (t) {
                  return (
                    t === s ||
                    (function (t, i, e) {
                      var s = e.length,
                        n = s;
                      if (null == t) return !n;
                      for (t = Object(t); s--; ) {
                        var o = e[s];
                        if (o[2] ? o[1] !== t[o[0]] : !(o[0] in t)) return !1;
                      }
                      for (; ++s < n; ) {
                        var r = (o = e[s])[0],
                          l = t[r],
                          a = o[1];
                        if (o[2]) {
                          if (void 0 === l && !(r in t)) return !1;
                        } else {
                          var h = new I();
                          if (!k(a, l, 3, void 0, h)) return !1;
                        }
                      }
                      return !0;
                    })(t, 0, n)
                  );
                })
        : N((i = t))
          ? ((e = X(i)),
            function (t) {
              return null == t ? void 0 : t[e];
            })
          : (function (t) {
              return function (i) {
                return Z(i, t);
              };
            })(i);
  var i, e, s, n;
}
var st,
  nt =
    ((st = function (t, i) {
      return t && M(t, i, w);
    }),
    function (t, i) {
      if (null == t) return t;
      if (!z(t)) return st(t, i);
      for (var e = t.length, s = -1, n = Object(t); ++s < e && !1 !== i(n[s], s, n); );
      return t;
    });
var ot = Object.prototype.hasOwnProperty;
function rt(t, i) {
  var e = -1,
    s = (i = W(i, t)).length;
  if (!s) return !0;
  for (; ++e < s; ) {
    var n = X(i[e]);
    if ('__proto__' === n && !ot.call(t, '__proto__')) return !1;
    if (('constructor' === n || 'prototype' === n) && e < s - 1) return !1;
  }
  var o = (function (t, i) {
    return i.length < 2
      ? t
      : Z(
          t,
          (function (t, i, e) {
            var s = -1,
              n = t.length;
            (i < 0 && (i = -i > n ? 0 : n + i), (e = e > n ? n : e) < 0 && (e += n), (n = i > e ? 0 : (e - i) >>> 0), (i >>>= 0));
            for (var o = Array(n); ++s < n; ) o[s] = t[s + i];
            return o;
          })(i, 0, -1),
        );
  })(t, i);
  return (
    null == o ||
    delete o[
      X(
        (function (t) {
          var i = null == t ? 0 : t.length;
          return i ? t[i - 1] : void 0;
        })(i),
      )
    ]
  );
}
var lt = Array.prototype.splice;
function at(t, i) {
  var e;
  return (
    nt(t, function (t, s, n) {
      return !(e = i(t, s, n));
    }),
    !!e
  );
}
function ht(t, i) {
  return (C(t) ? y : at)(t, et(i));
}
const dt = t(
  class extends i {
    constructor(t) {
      (super(),
        !1 !== t && this.__registerHost(),
        (this.tkChange = e(this, 'tk-change', 7)),
        (this.tkSelectAll = e(this, 'tk-select-all', 7)),
        (this.tkOpen = e(this, 'tk-open', 3)),
        (this.tkClose = e(this, 'tk-close', 3)),
        (this.internals = this.attachInternals()),
        (this.hasEmptyDataSlot = !1),
        (this.uniqueId = b()),
        (this.isItemClickFlag = !1),
        (this.flatOptions = []),
        (this.isOpen = !1),
        (this.groupNameKey = 'label'),
        (this.groupOptionsKey = 'options'),
        (this.loading = !1),
        (this.allowCustomValue = !1),
        (this.clearable = !1),
        (this.disabled = !1),
        (this.dropdownWidthMode = 'match-parent'),
        (this.editable = !1),
        (this.emptyMessage = 'No options available'),
        (this.filter = this.defaultFilter),
        (this.filterDebounceDelay = 0),
        (this.invalid = !1),
        (this.readonly = !1),
        (this.size = 'base'),
        (this.showAsterisk = !1),
        (this.optionLabelKey = 'label'),
        (this.selectAll = !1),
        (this.selectAllLabel = 'All'),
        (this.closeHandler = () => {
          this.isOpen = !1;
        }),
        (this.boundRunFilterForMultiple = this.runFilterForMultiple.bind(this)));
    }
    isOpenChanged(t) {
      t ? this.tkOpen.emit() : this.tkClose.emit();
    }
    disabledChanged(t) {
      t && (this.isOpen = !1);
    }
    optionsChanged(t, i) {
      var e;
      g(t, i) || ((this.renderOptions = (null === (e = this.options) || void 0 === e ? void 0 : e.length) > 0 ? [...this.options] : []), this.setValue());
    }
    valueChanged(t, i) {
      if (!g(t, i) && (this.setValue(), this.multiple && this.selectAll)) {
        const i = Array.isArray(t) ? t : [];
        this.tkSelectAll.emit(this.isAllSelected(i));
      }
    }
    componentWillLoad() {
      var t;
      ((this.hasEmptyDataSlot = !!this.el.querySelector('[slot="empty-data"]')),
        this.setFlatOptions(),
        (this.renderOptions = (null === (t = this.options) || void 0 === t ? void 0 : t.length) > 0 ? [...this.options] : []));
    }
    componentDidLoad() {
      var t, i;
      (null === (i = null === (t = this.internals) || void 0 === t ? void 0 : t.form) ||
        void 0 === i ||
        i.addEventListener('reset', () => {
          this.handleFormReset();
        }),
        (this.nativeInputRef = this.inputRef.querySelector('input')));
      const e = this.inputRef.querySelector('.tk-input');
      ((this.clickOutsideMixin = new u({ referenceElement: null != e ? e : this.el, handler: this.closeHandler, disabled: this.disabled || this.readonly || !this.isOpen })),
        this.allowCustomValue && (this.editable = !0),
        null != this.value && this.setValue());
    }
    componentDidRender() {
      var t, i, e;
      if (this.readonly) {
        const i = null === (t = this.inputRef) || void 0 === t ? void 0 : t.querySelector('input');
        i && i.setAttribute('readonly', 'true');
      }
      this.multiple &&
        this.editable &&
        (null === (i = this.nativeInputRef) || void 0 === i || i.removeEventListener('input', this.boundRunFilterForMultiple),
        null === (e = this.nativeInputRef) || void 0 === e || e.addEventListener('input', this.boundRunFilterForMultiple));
    }
    componentDidUpdate() {
      var t, i, e, s;
      if (
        ((this.nativeInputRef = this.inputRef.querySelector('input')),
        null === (t = this.clickOutsideMixin) ||
          void 0 === t ||
          t.updateConfig({ disabled: this.disabled || this.readonly || !this.isOpen, ignoredElements: this.panelRef ? [this.panelRef] : [] }),
        this.isOpen)
      ) {
        if (
          this.inputRef &&
          this.panelRef &&
          (null === (i = this.cleanup) || void 0 === i || i.call(this),
          this.updatePosition(),
          this.setFlatOptions(),
          !this.el.querySelector('.dropdown-item[data-active]') && !this.allowCustomValue)
        ) {
          const t = this.getNextEnabledItemIndex(-1, 'down');
          if (null !== t) {
            const i = this.el.querySelector(`.dropdown-item[data-option-index="${t}"]`);
            null == i || i.setAttribute('data-active', 'true');
          }
        }
      } else (null === (e = this.cleanup) || void 0 === e || e.call(this), (this.cleanup = null), null === (s = this.panelRef) || void 0 === s || s.remove());
    }
    disconnectedCallback() {
      var t, i, e, s;
      (null === (t = this.cleanup) || void 0 === t || t.call(this),
        (this.cleanup = null),
        null === (e = null === (i = this.internals) || void 0 === i ? void 0 : i.form) || void 0 === e || e.removeEventListener('reset', this.handleFormReset.bind(this)),
        null === (s = this.clickOutsideMixin) || void 0 === s || s.disconnectedCallback());
    }
    formResetCallback() {
      this.handleFormReset();
    }
    async close() {
      this.isOpen = !1;
    }
    updatePosition() {
      const t = this.dropdownWidthMode,
        i = this.inputRef.querySelector('.tk-input');
      this.cleanup = h(i, this.panelRef, void 0, {
        placement: 'bottom-start',
        size: {
          apply({ rects: i, elements: e }) {
            'match-parent' === t ? d(e.floating, { width: `${i.reference.width}px` }) : 'auto' !== t && t.length > 0 && d(e.floating, { width: t });
          },
        },
      });
    }
    isGrouped() {
      var t, i;
      return (null === (t = this.options) || void 0 === t ? void 0 : t.length) > 0 && (null === (i = this.options[0]) || void 0 === i ? void 0 : i[this.groupOptionsKey]);
    }
    setFlatOptions() {
      this.flatOptions = this.isGrouped() ? this.options.flatMap(t => t[this.groupOptionsKey]) : this.options;
    }
    async runFilterForMultiple() {
      this.renderOptions = await this.filter(this.nativeInputRef.value, this.options);
    }
    async defaultFilter(t, i) {
      return t
        ? this.isGrouped()
          ? i
              .map(i =>
                Object.assign(Object.assign({}, i), {
                  [this.groupOptionsKey]: i[this.groupOptionsKey].filter(i => this.getOptionLabel(i).toLowerCase().includes(t.toLowerCase())),
                }),
              )
              .filter(t => t[this.groupOptionsKey].length > 0)
          : i.filter(i => this.getOptionLabel(i).toLowerCase().indexOf(t.toLowerCase()) > -1)
        : [...this.options];
    }
    isOptionSelected(t, i) {
      return 'object' != typeof i || Array.isArray(i) || null === i ? t.includes(i) : t.some(t => g(t, i));
    }
    isAllSelected(t) {
      var i, e;
      let s;
      s = Array.isArray(t)
        ? t
        : Array.isArray(
              null === (e = null === (i = this.value) || void 0 === i ? void 0 : i.filter) || void 0 === e
                ? void 0
                : e.call(i, t => {
                    var i;
                    return !(null === (i = this.optionDisabled) || void 0 === i ? void 0 : i.call(this, t));
                  }),
            )
          ? this.value
          : [];
      const n = this.flatOptions
        .filter(t => {
          var i;
          return !(null === (i = this.optionDisabled) || void 0 === i ? void 0 : i.call(this, t));
        })
        .map(t => this.getOptionValue(t));
      return n.length > 0 && n.every(t => this.isOptionSelected(s, t));
    }
    getOptionLabel(t) {
      if ('object' == typeof t && null !== t) {
        const i = l(t, this.optionLabelKey);
        return null != i ? String(i) : '';
      }
      return null != t ? String(t) : '';
    }
    getOptionValue(t) {
      var i;
      return 'object' == typeof t && null !== t && (null === (i = this.optionValueKey) || void 0 === i ? void 0 : i.length) > 0 ? l(t, this.optionValueKey) : t;
    }
    getDisplayValueForMultiple(t) {
      if (!this.visibleItemCount || t.length <= this.visibleItemCount) return t;
      if (this.allowCustomValue) {
        const i = t.filter(t => this.flatOptions.some(i => (this.optionValueKey ? this.getOptionValue(i) === this.getOptionValue(t) : g(i, t)))),
          e = t.filter(t => !this.flatOptions.some(i => (this.optionValueKey ? this.getOptionValue(i) === this.getOptionValue(t) : g(i, t)))),
          s = [...i.slice(0, this.visibleItemCount), ...e.slice(0, Math.max(0, this.visibleItemCount - i.length))];
        if (t.length > this.visibleItemCount) {
          const i = { __isOthersIndicator: !0, label: '+' + (t.length - this.visibleItemCount), removable: !1 };
          return [...s, i];
        }
        return s;
      }
      return [...t.slice(0, this.visibleItemCount), { __isOthersIndicator: !0, label: '+' + (t.length - this.visibleItemCount), removable: !1 }];
    }
    async setRenderOptions(t) {
      this.renderOptions = await this.filter(t, this.options);
    }
    getSelectedItem() {
      var t, i;
      if ((null === (t = this.renderOptions) || void 0 === t ? void 0 : t.length) > 0) {
        let t = this.renderOptions;
        return (
          this.isGrouped() && (t = this.renderOptions.flatMap(t => t[this.groupOptionsKey] || [])),
          'object' != typeof this.value && (null == t ? void 0 : t.every(t => 'object' != typeof t))
            ? t.find(t => t == this.value)
            : (null == t ? void 0 : t.every(t => 'object' == typeof t))
              ? (null === (i = this.optionValueKey) || void 0 === i ? void 0 : i.length) > 0
                ? t.find(t => this.getOptionValue(t) == this.value)
                : t.find(t => g(t, this.value))
              : null
        );
      }
      return null;
    }
    setValue() {
      var t, i, e, s, n;
      if (this.inputRef)
        if ((this.setFlatOptions(), this.multiple)) {
          const t = Array.isArray(this.value) ? this.value : [];
          this.selectedItem = t
            .map(t => {
              let i;
              return ((i = this.flatOptions.find(this.optionValueKey ? i => this.getOptionValue(i) === t : i => g(i, t))), void 0 !== i ? i : this.allowCustomValue ? t : null);
            })
            .filter(t => null != t);
          const i = this.getDisplayValueForMultiple(this.selectedItem);
          this.inputRef.value = i;
        } else if (this.editable && this.allowCustomValue) this.inputRef.value = null != this.value ? this.getOptionLabel(this.value) : null;
        else if (
          ((this.selectedItem =
            'object' != typeof this.value && (null === (t = this.flatOptions) || void 0 === t ? void 0 : t.every(t => 'object' != typeof t))
              ? null === (i = this.flatOptions) || void 0 === i
                ? void 0
                : i.find(t => t === this.value)
              : (null === (e = this.optionValueKey) || void 0 === e ? void 0 : e.length) > 0
                ? null === (s = this.flatOptions) || void 0 === s
                  ? void 0
                  : s.find(t => this.getOptionValue(t) === this.value)
                : null === (n = this.flatOptions) || void 0 === n
                  ? void 0
                  : n.find(t => g(t, this.value))),
          null != this.selectedItem)
        )
          if (this.multiple) this.inputRef.value = this.selectedItem;
          else {
            const t = this.getOptionLabel(this.selectedItem);
            this.inputRef.value = t;
          }
        else
          this.filter
            ? ((this.selectedItem = this.getSelectedItem()),
              (this.inputRef.value = this.selectedItem ? (this.multiple ? this.selectedItem : this.getOptionLabel(this.selectedItem)) : null))
            : (this.inputRef.value = null);
    }
    scrollItem(t) {
      t.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
    }
    getNextEnabledItemIndex(t, i, e = 0) {
      const s = this.flatOptions.length;
      if (e >= (this.selectAll && this.multiple ? s + 1 : s)) return null;
      const n = this.selectAll && this.multiple ? -1 : 0,
        o = s - 1;
      let r = 'down' === i ? t + 1 : t - 1;
      return (
        r > o ? (r = n) : r < n && (r = o),
        -1 === r && this.selectAll && this.multiple ? -1 : this.optionDisabled && this.optionDisabled(this.flatOptions[r]) ? this.getNextEnabledItemIndex(r, i, e + 1) : r
      );
    }
    navigateToItem(t) {
      const i = this.el.querySelector('.dropdown-item[data-active="true"]'),
        e = i ? Number(i.getAttribute('data-option-index')) : null,
        s = null !== e ? this.getNextEnabledItemIndex(e, t) : this.getNextEnabledItemIndex(-1, 'down');
      if (null !== s) {
        const t = this.el.querySelector(`.dropdown-item[data-option-index='${s}']`);
        t && (null == i || i.setAttribute('data-active', 'false'), t.setAttribute('data-active', 'true'), this.scrollItem(t));
      }
    }
    handleFormReset() {
      ((this.value = this.multiple && this.optionDisabled && Array.isArray(this.value) ? this.value.filter(t => this.optionDisabled(t)) : null), this.tkChange.emit(this.value));
    }
    async handleSelectAllClick() {
      var t;
      if (!this.readonly) {
        if (this.multiple) {
          let i;
          if (this.isAllSelected())
            ((i = this.value.filter(t => {
              var i;
              return null === (i = this.optionDisabled) || void 0 === i ? void 0 : i.call(this, t);
            })),
              this.tkSelectAll.emit(!1));
          else {
            const e = this.flatOptions
                .filter(t => {
                  var i;
                  return !(null === (i = this.optionDisabled) || void 0 === i ? void 0 : i.call(this, t));
                })
                .map(t => this.getOptionValue(t)),
              s = Array.isArray(this.value) ? (null === (t = this.value) || void 0 === t ? void 0 : t.filter(t => !this.isOptionSelected(e, t))) : [];
            ((i = [...e, ...s]), this.tkSelectAll.emit(!0));
          }
          (this.multiple && this.editable && ((this.nativeInputRef.value = null), (this.renderOptions = await this.filter(null, this.options))),
            (this.inputRef.value = [...i]),
            (this.value = [...i]),
            this.tkChange.emit([...i]));
        }
        this.isItemClickFlag = !1;
      }
    }
    async handleItemClick(t) {
      var i;
      if (!this.readonly && !(null === (i = this.optionDisabled) || void 0 === i ? void 0 : i.call(this, t))) {
        if (this.multiple) {
          const i = Array.isArray(this.value) ? [...this.value] : [],
            e = this.getOptionValue(t);
          (ht(i, t => g(t, this.getOptionValue(e)))
            ? (function (t, i) {
                var e = [];
                if (!t || !t.length) return e;
                var s = -1,
                  n = [],
                  o = t.length;
                for (i = et(i); ++s < o; ) {
                  var r = t[s];
                  i(r, s, t) && (e.push(r), n.push(s));
                }
                (function (t, i) {
                  for (var e = t ? i.length : 0, s = e - 1; e--; ) {
                    var n = i[e];
                    if (e == s || n !== o) {
                      var o = n;
                      S(n) ? lt.call(t, n, 1) : rt(t, n);
                    }
                  }
                })(t, n);
              })(i, t => g(t, e))
            : i.push(e),
            this.multiple && this.editable && (this.nativeInputRef.value = null),
            (this.inputRef.value = [...i]),
            (this.value = [...i]),
            this.tkChange.emit([...i]));
        } else ((this.value = this.getOptionValue(t)), this.tkChange.emit(this.getOptionValue(t)), (this.isOpen = !1));
        ((this.renderOptions = await this.filter(null, this.options)), (this.isItemClickFlag = !1));
      }
    }
    async handleInputChange(t) {
      if (this.multiple) {
        if (null == t) this.value = [];
        else {
          const i = (Array.isArray(t) ? t : [t]).filter(t => !('object' == typeof t && null !== t && t.__isOthersIndicator));
          if (this.visibleItemCount && this.selectedItem && this.selectedItem.length > this.visibleItemCount) {
            const t = this.getDisplayValueForMultiple(this.selectedItem)
              .filter(t => !('object' == typeof t && null !== t && t.__isOthersIndicator))
              .find(t => !i.some(i => (this.optionValueKey && 'object' == typeof t && 'object' == typeof i ? this.getOptionValue(t) === this.getOptionValue(i) : g(t, i))));
            if (t) {
              const i = Array.isArray(this.value) ? [...this.value] : [],
                e = this.optionValueKey && 'object' == typeof t ? this.getOptionValue(t) : t,
                s = i.filter(i => (this.optionValueKey && 'object' == typeof t ? i !== e : !g(i, e)));
              return ((this.value = s), void this.tkChange.emit(this.value));
            }
          }
          const e = i.map(t => ('object' == typeof t && null !== t && this.optionValueKey ? this.getOptionValue(t) : t));
          this.value = e;
        }
        this.tkChange.emit(this.value);
      } else
        (this.editable && this.allowCustomValue && ((this.value = t), this.tkChange.emit(t)),
          this.filterDebounceDelay > 0
            ? (clearTimeout(this.filterDebounceTimeout),
              (this.filterDebounceTimeout = setTimeout(async () => {
                await this.setRenderOptions(t);
              }, this.filterDebounceDelay)))
            : await this.setRenderOptions(t),
          '' === t && ((this.value = null), this.tkChange.emit(null)));
    }
    handleInputClick(t) {
      if (this.disabled || this.readonly) return;
      const i = t.composedPath(),
        e = i.some(t => {
          var i;
          return null === (i = t.classList) || void 0 === i ? void 0 : i.contains('tk-input-clear-button');
        }),
        s = i.some(t => 'TK-ICON' === t.tagName && ('keyboard_arrow_up' === t.icon || 'keyboard_arrow_down' === t.icon)),
        n = i.some(t => {
          var i;
          return null === (i = t.classList) || void 0 === i ? void 0 : i.contains('tk-chips-clear-button');
        }),
        o = i.some(t => {
          var i;
          return null === (i = t.classList) || void 0 === i ? void 0 : i.contains('tk-input');
        });
      e || n || (s ? (this.isOpen = !this.isOpen) : o && !this.isOpen && (this.isOpen = !0));
    }
    async handleInputBlur() {
      if (this.isItemClickFlag) this.isItemClickFlag = !1;
      else if (this.editable) {
        if ((this.multiple && (this.nativeInputRef.value = null), !this.multiple && !this.allowCustomValue)) {
          const t = this.getSelectedItem(),
            i = this.nativeInputRef.value;
          if (!i) return;
          ((!t && i) || (t && this.getOptionLabel(t) != i)) && ((this.value = null), (this.inputRef.value = null), this.tkChange.emit(null));
        }
        this.renderOptions = await this.filter(null, this.options);
      }
    }
    async handleInputKeydown(t) {
      if ((['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(t.key) && t.preventDefault(), this.isOpen || ('Enter' !== t.key && 'ArrowDown' !== t.key && 'ArrowUp' !== t.key))) {
        if (this.isOpen) {
          if ('Escape' === t.key) return void (this.isOpen = !1);
          if ('ArrowDown' === t.key) return void this.navigateToItem('down');
          if ('ArrowUp' === t.key) return void this.navigateToItem('up');
          if ('Enter' === t.key) {
            const t = this.el.querySelector('.dropdown-item[data-active="true"]');
            return (this.multiple && this.editable && this.allowCustomValue && this.nativeInputRef.dispatchEvent(new InputEvent('input', { bubbles: !0 })), void (t && t.click()));
          }
        }
        'Tab' === t.key && (this.isOpen = !1);
      } else this.disabled || this.readonly || (this.isOpen = !0);
    }
    handleInputClearClick() {
      ((this.value = this.multiple && this.optionDisabled && Array.isArray(this.value) ? this.value.filter(t => this.optionDisabled(t)) : null),
        this.tkChange.emit(this.value),
        this.selectAll && this.multiple && this.isAllSelected() && this.tkSelectAll.emit(!1));
    }
    createOptionItem(t, i = 0) {
      return null == t
        ? void 0
        : t.map((t, e) => {
            var o;
            const l = !!this.optionDisabled && (null === (o = this.optionDisabled) || void 0 === o ? void 0 : o.call(this, t));
            let a,
              h = {};
            const d = ht(this.value, i => g(i, this.getOptionValue(t)));
            return (
              this.multiple
                ? (a = s(
                    n,
                    null,
                    s('tk-checkbox', { 'value': d, 'disabled': l, 'onTk-change': t => t.stopPropagation(), 'onClick': t => t.preventDefault() }),
                    null != this.optionHtml ? s('div', { class: 'multiple-option-content', innerHTML: this.optionHtml(t) }) : s('div', null, this.getOptionLabel(t)),
                  ))
                : (h = null != this.optionHtml ? { innerHTML: this.optionHtml(t) } : { innerHTML: this.getOptionLabel(t) }),
              s(
                'div',
                Object.assign(
                  {
                    'class': r('dropdown-item', { multiple: this.multiple }, { disabled: l }),
                    'data-option-index': i + e,
                    'data-selected': (this.multiple && d) || this.value === this.getOptionValue(t) ? 'true' : 'false',
                    'onPointerDown': () => (this.isItemClickFlag = !0),
                    'onClick': () => this.handleItemClick(t),
                  },
                  h,
                ),
                a,
              )
            );
          });
    }
    createSelectAllOption() {
      var t;
      if (this.selectAll && this.multiple) {
        const i = !this.isAllSelected() && (null === (t = this.value) || void 0 === t ? void 0 : t.length) > 0,
          e = this.isAllSelected();
        return s(
          'div',
          null,
          s(
            'div',
            {
              'class': r('dropdown-item', { multiple: this.multiple }),
              'data-selected': this.multiple && e ? 'true' : 'false',
              'onPointerDown': () => (this.isItemClickFlag = !0),
              'onClick': () => this.handleSelectAllClick(),
              'data-option-index': '-1',
            },
            s('tk-checkbox', { 'indeterminate': i, 'value': i ? null : e, 'onTk-change': t => t.stopPropagation(), 'onClick': t => t.preventDefault() }),
            s('div', null, this.selectAllLabel),
          ),
          s('tk-divider', { my: 1, style: { margin: '6px 4px 0px' } }),
        );
      }
    }
    createOptions() {
      if (this.isGrouped()) {
        let t = 0;
        return this.renderOptions.map(i => {
          var e;
          const n = this.createOptionItem(i[this.groupOptionsKey], t);
          return (
            (t += (null === (e = i[this.groupOptionsKey]) || void 0 === e ? void 0 : e.length) || 0),
            s('div', { class: 'dropdown-group' }, s('div', { class: 'dropdown-group-label' }, s('label', null, i[this.groupNameKey]), s('div', { class: 'line' })), n)
          );
        });
      }
      return this.createOptionItem(this.renderOptions);
    }
    renderInput() {
      var t;
      return s('tk-input', {
        'ref': t => (this.inputRef = t),
        'class': r('tk-select-input', {
          'editable-select': this.editable,
          'readonly-select': this.readonly,
          'tk-table-input': this.el.classList.contains('tk-table-select'),
          'multiple-select': this.multiple,
          'allow-custom-value-select': this.allowCustomValue,
        }),
        'label': this.label,
        'size': this.size,
        'showAsterisk': this.showAsterisk,
        'hint': this.hint,
        'placeholder': (null === (t = this.value) || void 0 === t ? void 0 : t.length) > 0 ? '' : this.placeholder,
        'invalid': this.invalid,
        'error': this.error,
        'icon': { left: this.icon, right: this.isOpen ? 'keyboard_arrow_up' : 'keyboard_arrow_down' },
        'mode': this.multiple ? 'chips' : 'text',
        'chipLabelKey': this.optionLabelKey,
        'readonly': this.readonly,
        'disabled': this.disabled,
        'loading': this.loading,
        'clearable': this.clearable,
        'chipOptions': this.chipOptions,
        'chipDisabled': this.optionDisabled,
        'aria-describedby': 'dropdown',
        'aria-expanded': !!this.isOpen,
        'onClick': t => this.handleInputClick(t),
        'onTk-change': t => {
          (t.stopPropagation(), this.handleInputChange(t.detail));
        },
        'onTk-blur': () => this.handleInputBlur(),
        'onTk-clear-click': () => this.handleInputClearClick(),
        'onKeyDown': t => this.handleInputKeydown(t),
      });
    }
    renderDropdown() {
      var t;
      return this.isOpen
        ? s(
            'div',
            { 'class': 'tk-select-panel', 'ref': t => (this.panelRef = t), 'data-tk-select-id': this.uniqueId },
            s(
              'div',
              { class: 'dropdown-item-holder' },
              this.loading
                ? s('tk-spinner', { size: this.size })
                : s(
                    n,
                    null,
                    this.panelTopHtml &&
                      s('div', {
                        class: 'dropdown-item-top',
                        ref: t => {
                          if (t) {
                            const e = this.panelTopHtml();
                            e instanceof i ? ((t.innerHTML = ''), t.appendChild(e)) : (t.innerHTML = e);
                          }
                        },
                      }),
                    (null === (t = this.renderOptions) || void 0 === t ? void 0 : t.length) > 0
                      ? s(n, null, this.createSelectAllOption(), this.createOptions())
                      : this.hasEmptyDataSlot
                        ? s('slot', { name: 'empty-data' })
                        : this.emptyMessage,
                  ),
            ),
          )
        : null;
    }
    render() {
      const t = r('tk-select-container', this.size);
      return s(
        'div',
        { 'key': '64f931ec47171d320e918857784947bb496f8016', 'aria-readonly': this.readonly, 'aria-disabled': this.disabled, 'aria-invalid': this.invalid, 'class': t },
        this.renderInput(),
        this.renderDropdown(),
      );
    }
    static get formAssociated() {
      return !0;
    }
    get el() {
      return this;
    }
    static get watchers() {
      return { isOpen: [{ isOpenChanged: 0 }], disabled: [{ disabledChanged: 0 }], options: [{ optionsChanged: 0 }], value: [{ valueChanged: 0 }] };
    }
    static get style() {
      return '@font-face{font-family:"Material Symbols Outlined";src:url("./assets/fonts/material-symbols/Material-Symbols-Outlined.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}.material-symbols-outlined{font-family:"Material Symbols Outlined";font-weight:normal;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}.material-symbols-outlined{font-variation-settings:"FILL" 0}.material-symbols-outlined.fill{font-variation-settings:"FILL" 1}@font-face{font-family:"Material Symbols Rounded";src:url("./assets/fonts/material-symbols/Material-Symbols-Rounded.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}.material-symbols-rounded{font-family:"Material Symbols Rounded";font-weight:normal;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}.material-symbols-rounded{font-variation-settings:"FILL" 0}.material-symbols-rounded.fill{font-variation-settings:"FILL" 1}@font-face{font-family:"Material Symbols Sharp";src:url("./assets/fonts/material-symbols/Material-Symbols-Sharp.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}.material-symbols-sharp{font-family:"Material Symbols Sharp";font-weight:normal;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}.material-symbols-sharp{font-variation-settings:"FILL" 0}.material-symbols-sharp.fill{font-variation-settings:"FILL" 1}tk-select{display:block}.tk-select-container .tk-select-panel{position:fixed;max-height:320px;overflow:hidden;border-radius:16px;border:1px solid var(--border-light);background:var(--static-light);z-index:800;box-shadow:var(--effect-1-default-sm);font-family:var(--family-body)}.tk-select-container .tk-select-panel .dropdown-item-holder{margin:8px;padding:1px;overflow-y:auto;display:flex;flex-direction:column;gap:6px}.tk-select-container .tk-select-panel .dropdown-item-holder::-webkit-scrollbar{width:4px;height:4px}.tk-select-container .tk-select-panel .dropdown-item-holder::-webkit-scrollbar-track{background:var(--background-lightest);border-radius:2px}.tk-select-container .tk-select-panel .dropdown-item-holder::-webkit-scrollbar-thumb{border-radius:3px;background:var(--secondary-sub-base)}.tk-select-container .tk-select-panel .dropdown-item-holder::-webkit-scrollbar-thumb:hover{background:var(--secondary-dark)}.tk-select-container .tk-select-panel .dropdown-item-holder::-webkit-scrollbar-corner{background:var(--background-lightest)}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item-top{position:sticky;top:0;z-index:1}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-group{display:flex;flex-direction:column;gap:6px}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-group .dropdown-group-label{display:flex;align-items:center;gap:16px;color:var(--text-dark);font-size:var(--desktop-body-xs-size);padding:0px 8px}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-group .dropdown-group-label label{white-space:nowrap}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-group .dropdown-group-label .line{width:100%;height:1px;background-color:var(--background-light)}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item{color:var(--text-darkest);border-radius:8px;padding:var(--dropdown-items-basic-base-v-padding) var(--dropdown-items-basic-base-h-padding, 8px)}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item.multiple{display:flex;align-items:center;gap:8px}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item .multiple-option-content{flex:1}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item[data-selected=true]{cursor:pointer;background:var(--states-info-lightest);outline:1px solid var(--states-info-light)}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item.disabled{pointer-events:none;cursor:not-allowed;background:var(--background-lightest);color:var(--text-sub-base);outline:none}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item:hover{cursor:pointer;background:var(--background-lightest)}.tk-select-container .tk-select-panel .dropdown-item-holder .dropdown-item[data-active=true]{cursor:pointer;outline:1px solid var(--background-light)}.tk-select-container.large .dropdown-item-holder{max-height:272px}.tk-select-container.large .dropdown-item-holder .dropdown-item{font-size:var(--desktop-body-m-base-size)}.tk-select-container.large .dropdown-item-holder tk-spinner{min-height:48px}.tk-select-container.base .dropdown-item-holder{max-height:254px}.tk-select-container.base .dropdown-item-holder .dropdown-item{font-size:var(--desktop-body-s-size)}.tk-select-container.base .dropdown-item-holder tk-spinner{min-height:38px}.tk-select-container.small .dropdown-item-holder{max-height:236px}.tk-select-container.small .dropdown-item-holder .dropdown-item{font-size:var(--desktop-body-xs-size)}.tk-select-container.small .dropdown-item-holder tk-spinner{min-height:28px}';
    }
  },
  [
    324,
    'tk-select',
    {
      groupNameKey: [1, 'group-name-key'],
      groupOptionsKey: [1, 'group-options-key'],
      loading: [4],
      allowCustomValue: [4, 'allow-custom-value'],
      clearable: [4],
      icon: [1],
      disabled: [4],
      dropdownWidthMode: [1, 'dropdown-width-mode'],
      editable: [4],
      error: [1],
      emptyMessage: [1, 'empty-message'],
      filter: [16],
      filterDebounceDelay: [2, 'filter-debounce-delay'],
      hint: [1],
      invalid: [4],
      label: [1],
      multiple: [4],
      visibleItemCount: [2, 'visible-item-count'],
      name: [1],
      placeholder: [1],
      readonly: [4],
      size: [1],
      showAsterisk: [4, 'show-asterisk'],
      chipOptions: [16],
      panelTopHtml: [16],
      options: [16],
      optionHtml: [16],
      optionLabelKey: [1, 'option-label-key'],
      optionValueKey: [1, 'option-value-key'],
      selectAll: [4, 'select-all'],
      selectAllLabel: [1, 'select-all-label'],
      optionDisabled: [16],
      value: [1032],
      renderOptions: [32],
      isOpen: [32],
      close: [64],
    },
    void 0,
    { isOpen: [{ isOpenChanged: 0 }], disabled: [{ disabledChanged: 0 }], options: [{ optionsChanged: 0 }], value: [{ valueChanged: 0 }] },
  ],
);
function ut() {
  'undefined' != typeof customElements &&
    ['tk-select', 'tk-checkbox', 'tk-chips', 'tk-divider', 'tk-icon', 'tk-input', 'tk-spinner'].forEach(t => {
      switch (t) {
        case 'tk-select':
          customElements.get(o(t)) || customElements.define(o(t), dt);
          break;
        case 'tk-checkbox':
          customElements.get(o(t)) || c();
          break;
        case 'tk-chips':
          customElements.get(o(t)) || p();
          break;
        case 'tk-divider':
          customElements.get(o(t)) || f();
          break;
        case 'tk-icon':
          customElements.get(o(t)) || v();
          break;
        case 'tk-input':
          customElements.get(o(t)) || a();
          break;
        case 'tk-spinner':
          customElements.get(o(t)) || m();
      }
    });
}
export { dt as T, ut as d, ht as s };
