import { Use as P, Value as p, prop as tt, html as y, attr as l, on as k, WithElement as ut, Empty as D, aria as R, bind as ft, computedOf as B, style as ht, OnDispose as G, When as L, NotEmpty as te, Fragment as z, ForEach as ot, svg as At, svgAttr as bt, emitValue as j, coalesce as ee, Ensure as ne, OneOfType as se, Repeat as Wt, signal as Vt, input as Q, emitValueAsNullableDate as Bt, emitValueAsNullableDateTime as Lt, emitValueAsNumber as Y, emit as re, Task as zt } from "@tempots/dom";
import { f as ae } from "./colors-pQZlNrwM.js";
import { g as le } from "./timer-DzWb416P.js";
import { ElementRect as Zt, AutoSelect as oe } from "@tempots/ui";
import { a as W, b as O, f as Et, I as U, C as H, c as ce, d as kt, T as ie, g as ue, L as pe, e as Rt, h as de, B as vt } from "./translations-BUTBIDsS.js";
import { C as mt, m as fe, d as me, I as Yt, E as he, P as ge, S as ct, s as be, e as xt, O as rt, f as Ut } from "./notice-CTONCH2t.js";
function Xt(t) {
  if (typeof t != "string") return !1;
  const e = t.startsWith("#") ? t.slice(1) : t;
  return /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e);
}
function ve(t) {
  if (typeof t != "string") return !1;
  const e = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i, s = t.match(e);
  if (!s) return !1;
  const [, n, r, c] = s, a = parseInt(n, 10), i = parseInt(r, 10), o = parseInt(c, 10);
  return a >= 0 && a <= 255 && i >= 0 && i <= 255 && o >= 0 && o <= 255;
}
function xe(t) {
  if (typeof t != "string") return !1;
  const e = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i, s = t.match(e);
  if (!s) return !1;
  const [, n, r, c, a] = s, i = parseInt(n, 10), o = parseInt(r, 10), u = parseInt(c, 10), d = parseFloat(a);
  return i >= 0 && i <= 255 && o >= 0 && o <= 255 && u >= 0 && u <= 255 && d >= 0 && d <= 1;
}
function we(t) {
  if (typeof t != "string") return !1;
  const e = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i, s = t.match(e);
  if (!s) return !1;
  const [, n, r, c] = s, a = parseInt(n, 10), i = parseInt(r, 10), o = parseInt(c, 10);
  return a >= 0 && a <= 360 && i >= 0 && i <= 100 && o >= 0 && o <= 100;
}
function vn(t) {
  return Xt(t) || ve(t) || xe(t) || we(t);
}
function _e(t) {
  if (!Xt(t)) return null;
  let e = t.startsWith("#") ? t.slice(1) : t;
  return e.length === 3 && (e = e.split("").map((s) => s + s).join("")), `#${e.toLowerCase()}`;
}
function Ct(t, e, s) {
  const n = (r) => {
    const c = Math.round(Math.max(0, Math.min(255, r))).toString(16);
    return c.length === 1 ? "0" + c : c;
  };
  return `#${n(t)}${n(e)}${n(s)}`;
}
function it(t) {
  const e = _e(t);
  if (!e) return null;
  const s = /^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
  return s ? {
    r: parseInt(s[1], 16),
    g: parseInt(s[2], 16),
    b: parseInt(s[3], 16)
  } : null;
}
function xn(t, e) {
  const s = it(t), n = it(e);
  if (!s || !n) return null;
  const r = (u, d, h) => {
    const [b, f, w] = [u, d, h].map(($) => ($ = $ / 255, $ <= 0.03928 ? $ / 12.92 : Math.pow(($ + 0.055) / 1.055, 2.4)));
    return 0.2126 * b + 0.7152 * f + 0.0722 * w;
  }, c = r(s.r, s.g, s.b), a = r(n.r, n.g, n.b), i = Math.max(c, a), o = Math.min(c, a);
  return (i + 0.05) / (o + 0.05);
}
function $e(t) {
  if (!t) return [0, 0, 0, 1];
  const s = t.trim().match(
    /^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/
  );
  if (s) {
    const u = s[1];
    if (u.length === 8) {
      const d = parseInt(u.slice(0, 2), 16), h = parseInt(u.slice(2, 4), 16), b = parseInt(u.slice(4, 6), 16), f = parseInt(u.slice(6, 8), 16) / 255;
      return [d, h, b, f];
    }
    if (u.length === 6)
      return [
        parseInt(u.slice(0, 2), 16),
        parseInt(u.slice(2, 4), 16),
        parseInt(u.slice(4, 6), 16),
        1
      ];
    if (u.length === 4) {
      const d = parseInt(u[0] + u[0], 16), h = parseInt(u[1] + u[1], 16), b = parseInt(u[2] + u[2], 16), f = parseInt(u[3] + u[3], 16) / 255;
      return [d, h, b, f];
    }
    if (u.length === 3) {
      const d = parseInt(u[0] + u[0], 16), h = parseInt(u[1] + u[1], 16), b = parseInt(u[2] + u[2], 16);
      return [d, h, b, 1];
    }
  }
  const n = t.match(
    /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i
  );
  if (n)
    return [
      parseInt(n[1], 10),
      parseInt(n[2], 10),
      parseInt(n[3], 10),
      parseFloat(n[4])
    ];
  const r = t.match(
    /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i
  );
  if (r)
    return [parseInt(r[1], 10), parseInt(r[2], 10), parseInt(r[3], 10), 1];
  const c = t.match(
    /^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i
  );
  if (c) {
    const u = parseFloat(c[1]), d = parseFloat(c[2]), h = parseFloat(c[3]), b = c[4] != null ? parseFloat(c[4]) : 1, [f, w, $] = qt(u, d / 100, h / 100);
    return [f, w, $, b];
  }
  const a = t.match(
    /^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i
  );
  if (a) {
    const u = parseFloat(a[1]), d = parseFloat(a[2]) / 100, h = parseFloat(a[3]) / 100, b = a[4] != null ? parseFloat(a[4]) : 1, [f, w, $] = ke(u, d, h);
    return [f, w, $, b];
  }
  const i = t.match(
    /^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i
  );
  if (i) {
    const u = i[1], d = parseFloat(i[2]), h = parseFloat(i[3]), b = i[4] != null ? parseFloat(i[4]) : 1, f = u.endsWith("%") ? Math.max(0, Math.min(1, parseFloat(u) / 100)) : Math.max(0, Math.min(1, parseFloat(u))), [w, $, _] = Me(f, d, h);
    return [w, $, _, b];
  }
  const o = it(t);
  return o ? [o.r, o.g, o.b, 1] : [0, 0, 0, 1];
}
function ye(t, e, s, n) {
  return `rgba(${Math.round(t)}, ${Math.round(e)}, ${Math.round(s)}, ${Math.max(
    0,
    Math.min(1, Math.round(n * 100) / 100)
  )})`;
}
function Ie(t) {
  let e = t + 1831565813;
  return function() {
    return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
  };
}
function qt(t, e, s) {
  t = (t % 360 + 360) % 360;
  const n = (1 - Math.abs(2 * s - 1)) * e, r = n * (1 - Math.abs(t / 60 % 2 - 1)), c = s - n / 2;
  let a = 0, i = 0, o = 0;
  return 0 <= t && t < 60 ? [a, i, o] = [n, r, 0] : 60 <= t && t < 120 ? [a, i, o] = [r, n, 0] : 120 <= t && t < 180 ? [a, i, o] = [0, n, r] : 180 <= t && t < 240 ? [a, i, o] = [0, r, n] : 240 <= t && t < 300 ? [a, i, o] = [r, 0, n] : [a, i, o] = [n, 0, r], [
    Math.round((a + c) * 255),
    Math.round((i + c) * 255),
    Math.round((o + c) * 255)
  ];
}
function ke(t, e, s) {
  t = (t % 360 + 360) % 360;
  const n = e + s;
  n > 1 && (e /= n, s /= n);
  const [r, c, a] = qt(t, 1, 0.5).map((h) => h / 255), i = 1 - e - s, o = r * i + e, u = c * i + e, d = a * i + e;
  return [Math.round(o * 255), Math.round(u * 255), Math.round(d * 255)];
}
function Mt(t, e, s) {
  t /= 255, e /= 255, s /= 255;
  const n = Math.max(t, e, s), r = Math.min(t, e, s);
  let c = 0, a = 0;
  const i = (n + r) / 2, o = n - r;
  if (o !== 0) {
    switch (a = i > 0.5 ? o / (2 - n - r) : o / (n + r), n) {
      case t:
        c = (e - s) / o + (e < s ? 6 : 0);
        break;
      case e:
        c = (s - t) / o + 2;
        break;
      default:
        c = (t - e) / o + 4;
    }
    c *= 60;
  }
  return [Math.round(c), Math.round(a * 100), Math.round(i * 100)];
}
function Ce(t, e, s) {
  const [n] = Mt(t, e, s), r = t / 255, c = e / 255, a = s / 255, i = Math.min(r, c, a), o = 1 - Math.max(r, c, a);
  return [n, Math.round(i * 100), Math.round(o * 100)];
}
function wt(t) {
  const e = t / 255;
  return e <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function _t(t) {
  const e = t <= 31308e-7 ? 12.92 * t : 1.055 * Math.pow(t, 0.4166666666666667) - 0.055;
  return Math.round(Math.max(0, Math.min(1, e)) * 255);
}
function Me(t, e, s) {
  const n = s * Math.PI / 180, r = Math.cos(n) * e, c = Math.sin(n) * e, a = t + 0.3963377774 * r + 0.2158037573 * c, i = t - 0.1055613458 * r - 0.0638541728 * c, o = t - 0.0894841775 * r - 1.291485548 * c, u = a * a * a, d = i * i * i, h = o * o * o, b = 4.0767416621 * u - 3.3077115913 * d + 0.2309699292 * h, f = -1.2684380046 * u + 2.6097574011 * d - 0.3413193965 * h, w = -0.0041960863 * u - 0.7034186147 * d + 1.707614701 * h;
  return [_t(b), _t(f), _t(w)];
}
function Se(t, e, s) {
  const n = wt(t), r = wt(e), c = wt(s), a = 0.4122214708 * n + 0.5363325363 * r + 0.0514459929 * c, i = 0.2119034982 * n + 0.6806995451 * r + 0.1073969566 * c, o = 0.0883024619 * n + 0.2817188376 * r + 0.6299787005 * c, u = Math.cbrt(a), d = Math.cbrt(i), h = Math.cbrt(o), b = 0.2104542553 * u + 0.793617785 * d - 0.0040720468 * h, f = 1.9779984951 * u - 2.428592205 * d + 0.4505937099 * h, w = 0.0259040371 * u + 0.7827717662 * d - 0.808675766 * h, $ = Math.sqrt(f * f + w * w);
  let _ = Math.atan2(w, f) * 180 / Math.PI;
  return _ < 0 && (_ += 360), [b, $, _];
}
function at(t, e, s, n, r, c) {
  switch (r) {
    case "hex":
      if (c) {
        const a = (o) => o.toString(16).padStart(2, "0"), i = Math.max(0, Math.min(255, Math.round(n * 255)));
        return `#${a(t)}${a(e)}${a(s)}${a(i)}`;
      }
      return Ct(t, e, s);
    case "rgb":
      return `rgb(${t}, ${e}, ${s})`;
    case "rgba":
      return `rgba(${t}, ${e}, ${s}, ${Math.round(n * 100) / 100})`;
    case "hsl": {
      const [a, i, o] = Mt(t, e, s);
      return `hsl(${a}, ${i}%, ${o}%)`;
    }
    case "hsla": {
      const [a, i, o] = Mt(t, e, s);
      return `hsla(${a}, ${i}%, ${o}%, ${Math.round(n * 100) / 100})`;
    }
    case "hwb": {
      const [a, i, o] = Ce(t, e, s);
      return n < 1 ? `hwb(${a} ${i}% ${o}% / ${Math.round(n * 100) / 100})` : `hwb(${a} ${i}% ${o}%)`;
    }
    case "oklch": {
      const [a, i, o] = Se(t, e, s), u = (Math.round(a * 1e3) / 1e3).toFixed(3), d = (Math.round(i * 1e3) / 1e3).toFixed(3), h = (Math.round(o * 10) / 10).toFixed(1), b = Math.round(n * 100) / 100;
      return c || n < 1 ? `oklch(${u} ${d} ${h} / ${b})` : `oklch(${u} ${d} ${h})`;
    }
  }
}
function lt(t, e) {
  return e ? t === "rgb" ? "rgba" : t === "hsl" ? "hsla" : t : t === "rgba" ? "rgb" : t === "hsla" ? "hsl" : t;
}
class De extends Error {
  constructor(e = "Missing implementation") {
    super(e), this.name = "MissingImplementationError";
  }
}
const wn = (t) => Te(t).split("_").join(" "), Te = (t) => (t = t.replace(/::/g, "/"), t = t.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2"), t = t.replace(/([a-z\d])([A-Z])/g, "$1_$2"), t = t.replace(/-/g, "_"), t.toLowerCase()), _n = (t) => t.substring(0, 1).toUpperCase() + t.substring(1), Fe = (t) => {
  if (typeof Buffer < "u")
    return Buffer.from(t, "base64").toString("utf8");
  if (typeof atob < "u")
    return atob(t);
  throw new De(
    "No implementation found for base64 decoding"
  );
};
function $t({
  onChange: t,
  value: e,
  accept: s = "*/*",
  enableClick: n = !0,
  content: r,
  disabled: c = !1,
  allowMultiple: a
}) {
  return P(W, (i) => {
    const o = p.deriveProp(e ?? []), u = tt(!1), d = (v) => {
      v.preventDefault(), v.stopPropagation(), u.value = !0;
    }, h = (v) => {
      v.preventDefault(), v.stopPropagation(), (!v.currentTarget || !v.currentTarget.contains(v.relatedTarget)) && (u.value = !1);
    }, b = (v) => {
      v.preventDefault(), v.stopPropagation(), u.value = !1;
      const m = Array.from(v.dataTransfer?.files || []);
      m.length > 0 && (o.value = m, t(m, "dragdrop"));
    }, f = (v) => {
      p.get(n) && v.currentTarget.querySelector(
        'input[type="file"]'
      )?.click();
    };
    let w = null;
    const $ = () => {
      if (w == null) return;
      const v = Array.from(w.files ?? []);
      v.length > 0 && (o.value = v, t(v, "click")), w.value = "";
    }, _ = (v) => {
      p.get(n) && (v.key === "Enter" || v.key === " ") && (v.preventDefault(), f(v));
    };
    return y.div(
      l.role("button"),
      l.tabindex(
        p.map(n, (v) => v ? 0 : -1)
      ),
      l.style("position: relative;"),
      k.dragover(d),
      k.dragleave(h),
      k.drop(b),
      k.click(f),
      k.keydown(_),
      // Hidden file input
      y.input(
        l.type("file"),
        l.disabled(c),
        l.accept(s),
        l.multiple(a),
        l.style(
          "position: absolute; left: -9999px; opacity: 0; pointer-events: none;"
        ),
        k.change($),
        ut((v) => (w = v, o.on((m) => {
          const M = globalThis.DataTransfer;
          if (M != null) {
            const S = new M();
            m.forEach((T) => S.items.add(T)), v.files = S.files;
          }
        }), D))
      ),
      // Screen reader instructions
      R.label(ft(i.$.dropZoneInstructions)(n)),
      // Content
      r({ files: o, clear: () => o.value = [], change: o.set })
    );
  });
}
function Ae(t, e) {
  return t.length === e.length && t.every((s, n) => s === e[n]);
}
function Ve(t, e) {
  const s = ["bc-segmented-input", `bc-segmented-input--size-${t}`];
  return e && s.push("bc-segmented-input--disabled"), s.join(" ");
}
function $n({
  options: t,
  value: e,
  onChange: s,
  size: n = "md",
  disabled: r = !1
}, ...c) {
  const a = ae(t).map(([i, o]) => ({
    key: i,
    label: o
  }));
  return ut(() => {
    const i = Object.fromEntries(
      a.map((u, d) => [u.key, d])
    ), o = tt(
      a.map(() => ({ left: 0, width: 0 })),
      Ae
    );
    return y.div(
      l.class(
        B(
          n,
          r
        )(
          (u, d) => Ve(u ?? "md", d ?? !1)
        )
      ),
      y.div(
        l.class("bc-segmented-input__container"),
        y.div(
          l.class("bc-segmented-input__indicator"),
          ht.width(
            B(
              e,
              o
            )((u, d) => {
              const { width: h } = d[i[u] ?? 0];
              return `${h}px`;
            })
          ),
          ht.left(
            B(
              e,
              o
            )((u, d) => {
              const { left: h } = d[i[u] ?? 0];
              return `${h}px`;
            })
          )
        ),
        // clickable buttons
        a.map(({ label: u, key: d }, h) => y.button(
          l.type("button"),
          k.click((b) => {
            b.preventDefault(), p.get(r) || s?.(d);
          }),
          l.disabled(r),
          l.class("bc-segmented-input__segment"),
          l.class(
            p.map(e, (b) => b === d ? "bc-segmented-input__segment--active" : "bc-segmented-input__segment--inactive")
          ),
          Zt((b) => {
            function f() {
              o.update(($) => {
                const _ = [...$];
                return _[h] = {
                  width: b.value.width,
                  left: b.value.localLeft
                }, _;
              });
            }
            const w = le(f);
            return G(w, b.on(f));
          }),
          u
        ))
      ),
      ...c
    );
  });
}
function Be(t) {
  const e = t.type.toLowerCase();
  return e.startsWith("image/") && (e.includes("jpeg") || e.includes("jpg") || e.includes("png") || e.includes("gif") || e.includes("webp") || e.includes("svg"));
}
function Le(t) {
  const e = t.type.toLowerCase();
  return e.startsWith("image/") ? "vscode-icons:file-type-image" : e.startsWith("video/") ? "vscode-icons:file-type-video" : e.startsWith("audio/") ? "vscode-icons:file-type-audio" : e.includes("pdf") ? "vscode-icons:file-type-pdf2" : e.includes("word") || e.includes("document") ? "vscode-icons:file-type-word" : e.includes("excel") || e.includes("spreadsheet") ? "vscode-icons:file-type-excel" : e.includes("powerpoint") || e.includes("presentation") ? "vscode-icons:file-type-powerpoint" : e.includes("zip") || e.includes("archive") ? "vscode-icons:file-type-zip" : e.includes("text") ? "vscode-icons:file-type-text" : e.includes("json") ? "vscode-icons:file-type-json-official" : e.includes("csv") ? "vscode-icons:file-type-csv" : e.includes("xml") ? "vscode-icons:file-type-xml" : e.includes("yaml") ? "vscode-icons:file-type-yaml-official" : "vscode-icons:file-type-binary";
}
function yt(t) {
  return L(
    t.map(Be),
    () => {
      const e = tt(null);
      return t.on((s) => {
        e.value && URL.revokeObjectURL(e.value);
        const n = URL.createObjectURL(s);
        e.value = n;
      }), y.div(
        G(() => {
          e.value && URL.revokeObjectURL(e.value);
        }),
        l.class("bc-file-input__thumbnail-container"),
        y.img(
          l.src(e),
          l.alt(t.map((s) => s.name)),
          l.class("bc-file-input__thumbnail")
        )
      );
    },
    () => U({ icon: t.map(Le) })
  );
}
const ze = (t, ...e) => {
  const {
    value: s = tt([]),
    accept: n = "*/*",
    maxFiles: r,
    maxFileSize: c,
    onChange: a,
    onBlur: i,
    disabled: o,
    hasError: u,
    mode: d = "default",
    showFileList: h = !0,
    ...b
  } = t, f = s, w = p.map(d, (x) => x === "input"), $ = p.map(d, (x) => x === "compact"), _ = (x) => {
    let g = x;
    if (r != null) {
      const I = p.get(r);
      g = g.slice(0, I);
    }
    if (c) {
      const I = p.get(c);
      g = g.filter((F) => F.size <= I);
    }
    a?.(g);
  }, v = (x) => {
    const I = f.value.filter((F, A) => A !== x);
    a?.(I);
  }, m = () => {
    a?.([]);
  }, M = ({
    files: x,
    clear: g,
    change: I
  }) => P(
    W,
    (F) => y.div(
      l.class("bc-file-input__drop-zone"),
      y.div(
        l.class(
          "bc-file-input__drop-zone-content bc-file-input__drop-zone-content--empty"
        ),
        U({ icon: "mdi:cloud-upload-outline", size: "xl" }),
        y.div(
          l.class("bc-file-input__drop-zone-text"),
          ft(F.$.filesInputInstructions)(
            r,
            c,
            F.$.fileSizeUnits.value
          )
        )
      )
    )
  ), S = ({
    files: x
  }) => P(
    W,
    (g) => y.div(
      l.class("bc-file-input__compact-drop-zone"),
      L(
        x.map((I) => I.length > 0),
        () => y.div(
          l.class("bc-file-input__compact-file-list"),
          ot(x, (I, F) => {
            const A = F.index;
            return y.div(
              l.class("bc-file-input__compact-file-item"),
              y.div(
                l.class("bc-file-input__compact-file-icon"),
                yt(I)
              ),
              y.div(
                l.class("bc-file-input__compact-file-info"),
                y.div(
                  l.class("bc-file-input__compact-file-name"),
                  l.title(I.$.name),
                  I.$.name
                ),
                y.div(
                  l.class("bc-file-input__compact-file-meta"),
                  B(
                    I.$.size,
                    g.$.fileSizeUnits
                  )((C, V) => Et(C, { units: V })),
                  " • ",
                  B(
                    I.$.type,
                    g.$.unknownType
                  )((C, V) => C || V)
                )
              ),
              mt(
                {
                  size: "sm",
                  label: g.$.removeFile,
                  disabled: o,
                  onClick: () => v(A)
                },
                l.class("bc-file-input__compact-remove-button")
              )
            );
          })
        ),
        () => y.div(
          l.class("bc-file-input__compact-placeholder"),
          U({ icon: "mdi:cloud-upload-outline", size: "lg" }),
          y.div(
            l.class("bc-file-input__compact-placeholder-text"),
            ft(g.$.filesInputInstructions)(
              r,
              c,
              g.$.fileSizeUnits.value
            )
          )
        )
      )
    )
  ), T = ({
    files: x
  }) => P(
    W,
    (g) => y.div(
      l.class("bc-file-input__compact-input"),
      L(
        x.map((I) => I.length > 0),
        () => y.span(
          l.class("bc-file-input__compact-value"),
          ot(
            x,
            (I) => y.span(
              l.class("bc-file-input__compact-value-item"),
              yt(I),
              y.span(
                l.class("bc-file-input__compact-value-item-name"),
                I.$.name
              )
            )
          )
        ),
        () => y.span(
          l.class("bc-file-input__compact-placeholder"),
          U({ icon: "mdi:cloud-upload-outline", size: "md" }),
          " ",
          ft(g.$.filesInputInstructions)(
            r,
            c,
            g.$.fileSizeUnits.value
          )
        )
      )
    )
  );
  return P(
    W,
    (x) => O(
      {
        baseContainer: p.map(w, (g) => !g),
        disabled: o,
        hasError: u,
        after: L(
          w,
          () => L(
            f.map(({ length: g }) => g > 0),
            () => mt(
              {
                size: "sm",
                label: x.$.clearAllFiles,
                disabled: o,
                onClick: m
              },
              l.class("bc-file-input__compact-clear")
            )
          )
        ),
        ...b,
        input: L(
          w,
          () => y.div(
            l.class("bc-file-input bc-file-input--input"),
            $t({
              value: f,
              accept: n,
              enableClick: !0,
              allowMultiple: p.map(r ?? 1 / 0, (g) => g > 1),
              disabled: o,
              onChange: _,
              content: T
            })
          ),
          () => L(
            $,
            () => y.div(
              l.class("bc-file-input bc-file-input--compact"),
              $t({
                value: f,
                accept: n,
                enableClick: !0,
                allowMultiple: p.map(r ?? 1 / 0, (g) => g > 1),
                disabled: o,
                onChange: _,
                content: S
              })
            ),
            () => y.div(
              l.class("bc-file-input"),
              $t({
                value: f,
                accept: n,
                enableClick: !0,
                allowMultiple: p.map(r ?? 1 / 0, (g) => g > 1),
                disabled: o,
                onChange: _,
                content: M
              }),
              L(
                h,
                () => te(
                  f,
                  () => z(
                    y.div(
                      l.class("bc-file-input__file-list"),
                      ot(f, (g, I) => {
                        const F = I.index;
                        return y.div(
                          l.class("bc-file-input__file-item"),
                          y.div(
                            l.class("bc-file-input__file-icon"),
                            yt(g)
                          ),
                          y.div(
                            l.class("bc-file-input__file-info"),
                            y.div(
                              l.class("bc-file-input__file-name"),
                              l.title(g.$.name),
                              g.$.name
                            ),
                            y.div(
                              l.class("bc-file-input__file-meta"),
                              B(
                                g.$.size,
                                x.$.fileSizeUnits
                              )(
                                (A, C) => Et(A, { units: C })
                              ),
                              " • ",
                              B(
                                g.$.type,
                                x.$.unknownType
                              )((A, C) => A || C)
                            )
                          ),
                          mt(
                            {
                              size: "sm",
                              label: x.$.removeFile,
                              disabled: o,
                              onClick: () => v(F)
                            },
                            l.class("bc-file-input__remove-button")
                          )
                        );
                      })
                    ),
                    L(
                      f.map(({ length: g }) => g > 1),
                      () => y.div(
                        l.class(
                          "bc-file-input__clear-all-button-container"
                        ),
                        y.button(
                          l.type("button"),
                          l.class("bc-file-input__clear-all-button"),
                          l.disabled(o),
                          x.$.clearAllFiles,
                          k.click((g) => {
                            g.preventDefault(), g.stopPropagation(), m();
                          })
                        )
                      )
                    )
                  )
                )
              )
            )
          )
        )
      },
      ...e
    )
  );
};
async function Ee(t) {
  return new Promise((e, s) => {
    const n = new FileReader();
    n.readAsDataURL(t), n.onload = () => {
      const r = n.result;
      e(r.split(",")[1]);
    }, n.onerror = (r) => s(r);
  });
}
function Re(t) {
  return Promise.all(t.map(Ee));
}
function Ue(t) {
  if (t.length >= 4) {
    if (t[0] === 137 && t[1] === 80 && t[2] === 78 && t[3] === 71)
      return "image/png";
    if (t[0] === 255 && t[1] === 216) return "image/jpeg";
    if (t[0] === 71 && t[1] === 73 && t[2] === 70)
      return "image/gif";
    if (t[0] === 82 && t[1] === 73 && t[2] === 70 && t[3] === 70 && t.length >= 12 && t[8] === 87 && t[9] === 69 && t[10] === 66 && t[11] === 80)
      return "image/webp";
  }
  try {
    if (new TextDecoder("utf-8").decode(t.slice(0, 256)).includes("<svg")) return "image/svg+xml";
  } catch {
  }
  return "application/octet-stream";
}
function Ne(t) {
  const e = Fe(t ?? ""), s = e.length, n = new Uint8Array(s);
  for (let r = 0; r < s; r++) n[r] = e.charCodeAt(r);
  return n;
}
function Oe(t) {
  const {
    value: e,
    onChange: s,
    onInput: n,
    ...r
  } = t, c = /* @__PURE__ */ new Map(), a = p.toSignal(e).map((d) => d.map((h, b) => {
    const f = c.get(h), w = Ne(h ?? ""), $ = f?.type || Ue(w), _ = f?.name ?? `file-${b}`, v = w.buffer.slice(
      w.byteOffset,
      w.byteOffset + w.byteLength
    ), m = new Blob([v], { type: $ });
    return new File([m], _, { type: $ });
  })), i = (d) => (h) => {
    d && Re(h).then((b) => {
      for (const [f, w] of b.entries())
        c.set(w, { name: h[f].name, type: h[f].type });
      d(b);
    });
  }, o = i(s), u = i(n);
  return ze({
    ...r,
    value: a,
    onChange: o,
    onInput: u
  });
}
function yn(t) {
  const {
    value: e,
    onInput: s,
    onChange: n,
    ...r
  } = t;
  return Oe({
    ...r,
    maxFiles: 1,
    value: p.map(e, (c) => c == null ? [] : [c]),
    onChange: (c) => {
      n?.(c[0]);
    },
    onInput: (c) => {
      s?.(c[0]);
    }
  });
}
function Pe(t, e) {
  const [s, n, r] = t, c = s << 16 ^ n << 8 ^ r, a = Ie(c), i = 6 + Math.floor(a() * 5), o = 0.18 + a() * 0.06, u = [];
  for (let f = 0; f < i; f++) {
    const w = f / i * Math.PI * 2, $ = e * (1 + (a() * 2 - 1) * o), _ = Math.cos(w) * $, v = Math.sin(w) * $;
    u.push({ x: _, y: v });
  }
  const d = (u[0].x + u[i - 1].x) / 2, h = (u[0].y + u[i - 1].y) / 2;
  let b = `M ${d.toFixed(3)} ${h.toFixed(3)}`;
  for (let f = 0; f < i; f++) {
    const w = u[f], $ = u[(f + 1) % i], _ = (w.x + $.x) / 2, v = (w.y + $.y) / 2;
    b += ` Q ${w.x.toFixed(3)} ${w.y.toFixed(3)} ${_.toFixed(3)} ${v.toFixed(3)}`;
  }
  return b += " Z", b;
}
const In = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, displayValue: c, size: a, withAlpha: i } = t, o = p.map(a ?? 32, (x) => x), u = p.map(e, (x) => $e(x ?? "#000000")), d = p.map(
    u,
    ([x, g, I]) => [x, g, I]
  ), h = p.map(u, ([, , , x]) => x), b = tt(p.get(h) ?? 1), f = p.map(i ?? !1, (x) => x), w = p.map(
    t.colorTextFormat ?? "rgb",
    (x) => x
  ), $ = B(
    d,
    b,
    w,
    f
  )(
    ([x, g, I], F, A, C) => at(x, g, I, F ?? 1, lt(A, C), C)
  ), _ = p.map(
    t.colorTextFormat ?? "hex",
    (x) => x
  ), v = p.map(o, (x) => `${-x / 2} ${-x / 2} ${x} ${x}`), m = B(
    d,
    o
  )((x, g) => Pe(x, g / 2)), M = B(
    d,
    b,
    f
  )(
    ([x, g, I], F, A) => A || F < 1 ? ye(x, g, I, F) : Ct(x, g, I)
  ), S = y.div(
    l.class("bc-color-swatch-input__control"),
    l.class(
      p.map(
        f,
        (x) => x ? "bc-color-swatch-input__control--alpha" : ""
      )
    ),
    l.style(
      B(o)((x) => `min-width:${x + 2}px;height:${x + 2}px`)
    ),
    // The SVG blob preview
    At.svg(
      l.class("bc-color-swatch-input__svg"),
      bt.viewBox(v),
      At.path(bt.d(m), bt.fill(M))
    ),
    // Invisible native input overlays the blob for picker and accessibility
    y.input(
      l.type("color"),
      H(t),
      // Native color input needs hex without alpha
      l.value(p.map(d, ([x, g, I]) => Ct(x, g, I))),
      l.class(
        "bc-input bc-color-swatch-input bc-color-swatch-input__native"
      ),
      s != null ? k.blur(s) : D,
      n != null ? k.change((x) => {
        const g = x.target.value;
        if (!n) return;
        const { r: I, g: F, b: A } = it(g) ?? { r: 0, g: 0, b: 0 }, C = p.get(b) ?? 1, V = lt(
          p.get(_),
          p.get(f)
        ), N = at(I, F, A, C, V, p.get(f));
        n(N);
      }) : D,
      r != null ? k.input((x) => {
        const g = x.target.value;
        if (!r) return;
        const { r: I, g: F, b: A } = it(g) ?? { r: 0, g: 0, b: 0 }, C = p.get(b) ?? 1, V = lt(
          p.get(_),
          p.get(f)
        ), N = at(I, F, A, C, V, p.get(f));
        r(N);
      }) : D
    )
  ), T = L(
    f,
    () => y.input(
      l.type("range"),
      l.class("bc-color-swatch-input__alpha"),
      l.min(0),
      l.max(1),
      l.step(0.01),
      l.value(p.map(b, (x) => String(x ?? 1))),
      l.disabled(t.disabled),
      k.input((x) => {
        const g = parseFloat(x.target.value);
        b.set(g);
        const [I, F, A] = p.get(d), C = lt(
          p.get(_),
          p.get(f)
        ), V = at(I, F, A, g, C, p.get(f));
        r?.(V);
      }),
      k.change((x) => {
        const g = parseFloat(x.target.value);
        b.set(g);
        const [I, F, A] = p.get(d), C = lt(
          p.get(_),
          p.get(f)
        ), V = at(I, F, A, g, C, p.get(f));
        n?.(V);
      })
    )
  );
  return O({
    baseContainer: !0,
    ...t,
    // ensure our control does not try to grow
    growInput: !1,
    input: S,
    // If caller provided an `after`, append RGB before it
    after: z(
      L(
        c ?? !1,
        () => y.span(l.class("bc-color-swatch-input__rgb"), $)
      ),
      T,
      t.after
    )
  });
}, Dt = "$$tts-exp-", je = (t, e) => ut((s) => {
  const n = `${Dt}${t}`;
  return G(p.on(e, (r) => Reflect.set(s, n, r)));
}), kn = (t, e) => {
  const s = `${Dt}${t}`;
  return (n) => {
    e(Reflect.get(n.target, s));
  };
}, He = (t, e) => {
  const s = `${Dt}${t}`;
  return (n) => {
    const r = n.target, c = r.selectedIndex, a = r.options[c];
    e(Reflect.get(a, s));
  };
};
function We(t, e, s) {
  const n = ["bc-card"];
  return t !== "default" && n.push(`bc-card--${t}`), e !== "md" && n.push(`bc-card--padding-${e}`), s !== "lg" && n.push(`bc-card--rounded-${s}`), n.join(" ");
}
function Cn({ variant: t = "default", size: e = "md", roundedness: s = "lg" } = {}, ...n) {
  return y.div(
    l.class(
      B(
        t,
        e,
        s
      )(
        (r, c, a) => We(
          r ?? "default",
          c ?? "md",
          a ?? "lg"
        )
      )
    ),
    ...n
  );
}
function dt(...t) {
  return y.div(l.class("bc-group"), ...t);
}
const Mn = ({
  startEditing: t,
  value: e,
  onChange: s,
  placeholder: n,
  disabled: r
}) => {
  const c = p.deriveProp(t ?? !1), a = tt(!1), i = p.map(r ?? !1, (o) => o);
  return y.div(
    l.class("bc-editable-text"),
    l.class(
      p.map(
        i,
        (o) => o ? "bc-editable-text--disabled" : ""
      )
    ),
    R.disabled(i),
    L(
      c,
      () => y.input(
        l.placeholder(n),
        l.value(e),
        l.class("bc-editable-text__input"),
        oe(),
        k.keydown((o) => {
          o.key === "Enter" ? c.set(!1) : o.key === "Escape" && (a.set(!0), c.set(!1));
        }),
        k.blur(
          j((o) => {
            if (c.set(!1), a.value) {
              a.set(!1);
              return;
            }
            s(o);
          })
        )
      ),
      () => y.span(
        k.click(() => {
          p.get(i) || c.set(!0);
        }),
        l.class("bc-editable-text__display"),
        L(
          p.map(e, (o) => o != null && o.trim() !== ""),
          () => y.span(l.class("bc-editable-text__text"), e),
          () => y.span(
            l.class("bc-editable-text__placeholder"),
            n
          )
        ),
        L(
          p.map(i, (o) => !o),
          () => y.button(
            l.type("button"),
            l.class("bc-editable-text__edit-button"),
            P(W, (o) => R.label(o.$.editLabel)),
            k.click(() => c.set(!0)),
            U({ icon: "line-md/pencil", color: "neutral" })
          )
        )
      )
    )
  );
}, Gt = (t, e, s) => ne(
  t,
  (n) => se(n, {
    value: (r) => {
      const c = B(
        r,
        s
      )((a, i) => e(a.value, i));
      return y.option(
        l.selected(c),
        je("value", r.$.value),
        r.$.label
      );
    },
    group: (r) => y.optgroup(
      l.label(r.$.group),
      ot(
        r.$.options,
        (c) => Gt(
          c,
          e,
          s
        )
      )
    ),
    break: () => y.hr()
  })
), Ze = (t) => {
  const {
    value: e,
    onBlur: s,
    onChange: n,
    options: r,
    unselectedLabel: c,
    equality: a = (u, d) => u === d,
    after: i
  } = t;
  let o;
  return O(
    {
      ...t,
      after: z(
        ce({
          icon: "ph:caret-down-bold",
          color: "neutral",
          size: "sm"
        }),
        i
      ),
      input: y.select(
        ut((u) => {
          o = u;
          const d = new MutationObserver((h) => {
            const { removedNodes: b } = h[0];
            b.length > 0 && (o.selectedIndex = 0);
          });
          return d.observe(u, { childList: !0 }), G(() => d.disconnect());
        }),
        H(t),
        l.class("bc-native-select bc-input"),
        P(
          W,
          (u) => y.option(
            l.hidden("hidden"),
            ee(c, u.$.selectOne)
          )
        ),
        ot(r, (u) => Gt(u, a, e)),
        s != null ? k.blur(s) : D,
        n != null ? k.change(He("value", (u) => n(u))) : D
      )
    },
    k.click(() => {
      o?.focus(), typeof o?.showPicker == "function" && o.showPicker();
    })
  );
};
function Ye(t) {
  const { controller: e, onChange: s, onBlur: n, ...r } = t;
  return Ze({
    ...r,
    value: e.signal,
    onChange: me(e, s),
    onBlur: fe(e, n)
  });
}
function Sn(t) {
  return Yt({
    ...t,
    content: Ye(t)
  });
}
function Xe(t, e, s) {
  const n = t.length.map((r) => r);
  return z(
    Wt(
      n,
      (r) => {
        const c = t.item(r.index), a = [];
        return z(
          G(() => {
            a.forEach((i) => i());
          }),
          e({
            list: t,
            item: c,
            position: r,
            remove: () => t.removeAt(r.index),
            move: (i) => {
              switch (i) {
                case "up":
                  if (r.index === 0) return;
                  t.move(r.index, r.index - 1);
                  break;
                case "down":
                  if (r.index === t.length.value - 1) return;
                  t.move(r.index, r.index + 1);
                  break;
                case "first":
                  t.move(r.index, 0);
                  break;
                case "last":
                  t.move(r.index, t.length.value - 1);
              }
            },
            canMove: (i) => {
              const o = (() => {
                switch (i) {
                  case "up":
                    return Vt(r.index > 0);
                  case "down":
                    return t.length.map((u) => r.index < u - 1);
                }
              })();
              return a.push(() => o.dispose()), o;
            },
            cannotMove: (i) => {
              const o = (() => {
                switch (i) {
                  case "up":
                    return Vt(r.index === 0);
                  case "down":
                    return t.length.map((u) => r.index === u - 1);
                }
              })();
              return a.push(() => o.dispose()), o;
            }
          })
        );
      },
      s
    )
  );
}
const Nt = {
  9: { pattern: /^[0-9]$/ },
  A: { pattern: /^[A-Za-z]$/, transform: (t) => t.toUpperCase() },
  "*": { pattern: /^.$/ }
}, qe = (t) => t instanceof RegExp;
function Qt(t, e, s) {
  if (t == null) return [];
  const n = s ? { ...Nt, ...e } : e ?? Nt, r = (a, i) => {
    const o = n[i];
    o ? a.push({ type: "pattern", name: i, ...o }) : a.push({ type: "literal", char: i });
  }, c = [];
  if (typeof t == "string") {
    for (const a of t) r(c, a);
    return c;
  }
  for (const a of t)
    if (typeof a == "string")
      if (a.length <= 1) r(c, a);
      else for (const i of a) r(c, i);
    else qe(a) ? c.push({ type: "pattern", pattern: a }) : typeof a == "object" && a && c.push(a);
  return c;
}
function Ge(t, e) {
  return (s) => {
    switch (t) {
      case "digits":
        return /[0-9]/.test(s);
      case "letters":
        return /[A-Za-z]/.test(s);
      case "alphanumeric":
        return /[A-Za-z0-9]/.test(s);
      case "custom":
        return e?.(s) ?? !0;
      default:
        return !0;
    }
  };
}
function Ot(t, e, s, n, r, c) {
  const a = {
    raw: t,
    previousConformed: e,
    cursor: r ?? t.length,
    completed: !1
  }, i = n.definitions ?? {}, o = typeof s == "function" ? s(t, a) : s, u = Qt(
    o,
    i,
    n.useDefaultDefinitions ?? !0
  ), d = Ge(n.allowMode, n.allow), h = /* @__PURE__ */ new Set();
  for (const C of u) C.type === "literal" && h.add(C.char);
  if (n.prefix) for (const C of n.prefix) h.add(C);
  if (n.suffix) for (const C of n.suffix) h.add(C);
  const b = Array.from(t).filter((C) => d(C) && !h.has(C));
  if (b.length === 0) return { value: "", cursor: 0, completed: !1 };
  const f = [], w = [];
  let $ = 0, _ = 0, v = 0, m = -1;
  for (const C of u) {
    if (C.type === "literal") {
      f.push(C.char), w.push({ kind: "literal", filled: !0 });
      continue;
    }
    _ += C.optional ? 0 : 1;
    const V = b[$];
    if (V == null)
      break;
    if (C.type === "any") {
      v++, f.push(C.transform ? C.transform(V) : V), w.push({ kind: "slot", filled: !0 }), m = w.length - 1, $++;
      continue;
    }
    if (C.type === "pattern")
      if (C.pattern.test(V)) {
        v++;
        const N = C.transform ? C.transform(V) : V;
        f.push(N), w.push({ kind: "slot", filled: !0 }), m = w.length - 1, $++;
      } else {
        $++;
        continue;
      }
  }
  const M = f.join(""), S = (n.prefix ?? "") + M + (n.suffix ?? "");
  let x = (n.prefix ?? "").length;
  if (m >= 0) {
    let C = m + 1;
    if ((c?.policy ?? "smart") !== "sticky")
      for (; C < w.length && w[C].kind === "literal"; ) C++;
    x += C;
  }
  const g = n.completion?.mode === "min" ? (n.completion.minChars ?? 0) <= v : n.completion?.mode === "custom" ? !!n.completion.isComplete?.(S) : _ > 0 && v >= _, I = n.pipe?.(S, { ...a, completed: g });
  let F, A = x;
  return I === !1 ? (F = e, A = e.length) : typeof I == "string" ? (F = I, A = I.length) : typeof I == "object" && I ? (F = I.value, A = I.cursor ?? I.value.length) : F = S, { value: F, cursor: A, completed: g };
}
function Qe(t, e) {
  const s = e?.strategy ?? "none";
  return s === "custom" && e?.unmask ? e.unmask(t) : s === "strip" ? t.replace(/[^A-Za-z0-9]/g, "") : t;
}
const Jt = (t) => {
  const {
    value: e,
    onBlur: s,
    onChange: n,
    onInput: r,
    onAccept: c,
    onComplete: a,
    mask: i,
    definitions: o,
    useDefaultDefinitions: u,
    extraLiterals: d,
    prefix: h,
    suffix: b,
    autofix: f,
    pipe: w,
    completion: $,
    unmask: _,
    allowMode: v,
    allow: m,
    placeholder: M,
    placeholderOptions: S
  } = t, T = B(
    e,
    i,
    o,
    u,
    d,
    h,
    b,
    f,
    $,
    _,
    v,
    M,
    S
  )((g, I, F, A, C, V, N, nt, st, K, X, pt, Z) => I ? Ot(g ?? "", "", I, {
    definitions: F ?? {},
    useDefaultDefinitions: A ?? !0,
    extraLiterals: C ?? [],
    autofix: nt ?? "none",
    completion: st ?? { mode: "mask" },
    pipe: w ?? ((E) => E),
    unmask: K ?? { strategy: "none" },
    allowMode: X ?? "all",
    allow: m,
    prefix: V,
    suffix: N
  }).value : g ?? ""), x = (g, I) => {
    const F = g.value ?? "", A = p.get(e) ?? "", C = i != null ? p.get(i) : null, V = o != null ? p.get(o) : void 0, N = u != null ? p.get(u) : void 0, nt = d != null ? p.get(d) : void 0, st = f != null ? p.get(f) : void 0, K = $ != null ? p.get($) : void 0, X = _ != null ? p.get(_) : void 0, pt = v != null ? p.get(v) : void 0, Z = h != null ? p.get(h) : void 0, E = b != null ? p.get(b) : void 0, {
      value: q,
      cursor: gt,
      completed: Tt
    } = C ? Ot(
      F,
      A,
      C,
      {
        definitions: V ?? {},
        useDefaultDefinitions: N ?? !0,
        extraLiterals: nt ?? [],
        autofix: st ?? "none",
        completion: K ?? { mode: "mask" },
        pipe: w ?? ((Kt) => Kt),
        unmask: X ?? { strategy: "none" },
        allowMode: pt ?? "all",
        allow: m,
        prefix: Z,
        suffix: E
      },
      g.selectionStart ?? F.length,
      t.cursor ? p.get(t.cursor) : void 0
    ) : { value: F, cursor: F.length, completed: !0 };
    if (q !== F) {
      g.value = q;
      try {
        g.setSelectionRange(gt, gt);
      } catch {
      }
    }
    const Ft = Qe(q, X);
    c?.({
      raw: Ft,
      conformed: q,
      completed: Tt,
      cursor: gt
    }), I === "input" ? r?.(q) : (n?.(q), Tt && a?.({ raw: Ft, conformed: q }));
  };
  return z(
    O({
      ...t,
      input: Q.text(
        H(t),
        l.value(T),
        l.class("bc-input"),
        s != null ? k.blur(s) : D,
        ut(
          (g) => g instanceof HTMLInputElement ? z(
            k.input(() => x(g, "input")),
            k.change(() => x(g, "change")),
            k.keydown((I) => {
              if (I.key !== "Backspace" || !(t.cursor ? p.get(t.cursor)?.backspaceRubberBand ?? !0 : !0)) return;
              const A = g.selectionStart ?? 0, C = g.selectionEnd ?? A;
              if (A !== C || A <= 0) return;
              const V = g.value ?? "", N = i != null ? p.get(i) : null;
              if (!N) return;
              const nt = o != null ? p.get(o) : void 0, st = u != null ? p.get(u) : !0, K = h != null ? p.get(h) : void 0, X = b != null ? p.get(b) : void 0, pt = Qt(
                typeof N == "function" ? N(V, {
                  raw: V,
                  previousConformed: V,
                  cursor: A,
                  completed: !1
                }) : N,
                nt ?? {},
                st ?? !0
              ), Z = /* @__PURE__ */ new Set();
              for (const E of pt)
                E.type === "literal" && Z.add(E.char);
              if (K) for (const E of K) Z.add(E);
              if (X) for (const E of X) Z.add(E);
              if (Z.has(V[A - 1])) {
                let E = A - 1;
                for (; E >= 0 && Z.has(V[E]); ) E--;
                E >= 0 && (I.preventDefault(), I.stopPropagation(), g.value = V.slice(0, E) + V.slice(E + 1), x(g, "input"));
              }
            })
          ) : D
        )
      )
    })
  );
};
function J(t, e, s) {
  const n = p.map(t, (c) => c != null), r = kt.clearValue;
  return z(
    L(
      n,
      () => y.button(
        l.type("button"),
        l.class("bc-input-container__reset"),
        R.label(r),
        l.title(r),
        l.disabled(e ?? !1),
        U({ icon: "mdi:close", size: "sm" }),
        k.click((c) => {
          c.stopPropagation(), s?.(null);
        })
      )
    )
  );
}
const Dn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: c, disabled: a } = t, i = J(e, a, n ?? r);
  return O({
    ...t,
    input: Q.date(
      H(t),
      l.valueAsDate(e),
      l.class("bc-input"),
      s != null ? k.blur(j(s)) : D,
      n != null ? k.change(Bt(n)) : D,
      r != null ? k.input(Bt(r)) : D
    ),
    after: c != null ? z(i, c) : i
  });
}, Je = (t) => {
  const e = t.getFullYear(), s = t.getMonth() + 1, n = t.getDate(), r = t.getHours(), c = t.getMinutes(), a = t.getSeconds();
  return `${e}-${s.toString().padStart(2, "0")}-${n.toString().padStart(2, "0")}T${r.toString().padStart(2, "0")}:${c.toString().padStart(2, "0")}:${a.toString().padStart(2, "0")}`;
}, Tn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, after: c, disabled: a } = t, i = p.map(e, (u) => u != null ? Je(u) : null), o = J(e, a, n ?? r);
  return O({
    ...t,
    input: Q["datetime-local"](
      H(t),
      l.value(p.map(i, (u) => u ?? null)),
      l.class("bc-input"),
      s != null ? k.blur(j(s)) : D,
      n != null ? k.change(Lt(n)) : D,
      r != null ? k.input(Lt(r)) : D
    ),
    after: c != null ? z(o, c) : o
  });
}, Pt = (t) => typeof t == "string" && t.trim() === "" ? null : t, Ke = (t) => t ?? "";
function et(t) {
  return (e) => {
    const { value: s, onBlur: n, onChange: r, onInput: c, after: a, disabled: i, ...o } = e, u = J(s, i, r ?? c);
    return t({
      ...o,
      disabled: i,
      value: p.map(s, Ke),
      onChange: r != null ? (d) => r(Pt(d)) : void 0,
      onInput: c != null ? (d) => c(Pt(d)) : void 0,
      onBlur: n,
      after: a != null ? z(u, a) : u
    });
  };
}
const Fn = et(he), An = et(ie), Vn = et(ge), tn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, rows: c } = t;
  return O({
    baseContainer: !0,
    ...t,
    input: y.textarea(
      l.class(
        B(t.size ?? "md")(
          (a) => ue(
            !1,
            a ?? "md"
          )
        )
      ),
      H(t),
      l.rows(c ?? 3),
      l.value(e),
      l.class("bc-input"),
      s != null ? k.blur(j(s)) : D,
      n != null ? k.change(j(n)) : D,
      r != null ? k.input(j(r)) : D
    )
  });
}, Bn = et(
  tn
), Ln = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: c, onChange: a, onInput: i, after: o } = t, u = (b) => {
    const f = n != null ? p.get(n) : void 0, w = r != null ? p.get(r) : void 0;
    return f != null && b < f ? f : w != null && b > w ? w : b;
  }, d = s != null ? P(W, (b) => {
    const f = B(
      e,
      n
    )((v, m) => m == null ? !0 : (v ?? 0) > m), w = B(
      e,
      r
    )((v, m) => m == null ? !0 : (v ?? 0) < m), $ = (v) => {
      const m = p.get(e) ?? 0, M = p.get(s), S = v?.shiftKey ? 10 : 1, T = m - M * S, x = n != null ? p.get(n) : void 0;
      if (x != null && T < x)
        return;
      const g = u(T);
      g !== m && a && a(g);
    }, _ = (v) => {
      const m = p.get(e) ?? 0, M = p.get(s), S = v?.shiftKey ? 10 : 1, T = m + M * S, x = r != null ? p.get(r) : void 0;
      if (x != null && T > x)
        return;
      const g = u(T);
      g !== m && a && a(g);
    };
    return ct(
      l.class("bc-number-input-steppers"),
      // Increment second
      y.button(
        l.type("button"),
        l.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
        ),
        l.disabled(
          B(
            w,
            t.disabled ?? !1
          )((v, m) => !v || m)
        ),
        k.click((v) => _(v)),
        R.label(b.$.incrementValue),
        U({ icon: "line-md:plus", size: "xs" })
      ),
      // Decrement first (matches tests expecting first button to be decrement)
      y.button(
        l.type("button"),
        l.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
        ),
        l.disabled(
          B(
            f,
            t.disabled ?? !1
          )((v, m) => !v || m)
        ),
        k.click((v) => $(v)),
        R.label(b.$.decrementValue),
        U({ icon: "line-md:minus", size: "xs" })
      )
    );
  }) : null, h = o != null && d != null ? z(d, o) : o ?? d;
  return O({
    ...t,
    input: Q.number(
      n != null ? z(
        l.min(n),
        G(
          p.on(n, (b) => {
            b < p.get(e);
          })
        )
      ) : D,
      r != null ? z(
        l.max(r),
        G(
          p.on(r, (b) => {
            b > p.get(e);
          })
        )
      ) : D,
      H(t),
      l.valueAsNumber(e),
      l.step(s),
      l.class("bc-input bc-number-input"),
      c != null ? k.blur(j(c)) : D,
      a != null ? k.change(Y(a)) : D,
      i != null ? k.input(Y(i)) : D,
      // Add wheel event support when step is defined
      s != null ? k.wheel((b) => {
        b.preventDefault();
        const f = p.get(e) ?? 0, w = p.get(s), $ = b.shiftKey ? 10 : 1, _ = b.deltaY < 0 ? w * $ : -w * $, v = u(f + _);
        v !== f && a && a(v);
      }) : D
    ),
    after: h
  });
}, jt = (t) => {
  if (t == null || t === "") return null;
  const e = Number(t);
  return Number.isNaN(e) ? null : e;
}, zn = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: c, onChange: a, onInput: i, after: o } = t, u = (f) => {
    const w = n != null ? p.get(n) : void 0, $ = r != null ? p.get(r) : void 0;
    return w != null && f < w ? w : $ != null && f > $ ? $ : f;
  }, d = (() => {
    if (s == null) return null;
    const f = B(
      e,
      n
    )((m, M) => {
      const S = m ?? 0;
      return M == null ? !0 : S > M;
    }), w = B(
      e,
      r
    )((m, M) => {
      const S = m ?? 0;
      return M == null ? !0 : S < M;
    }), $ = (m) => {
      const M = p.get(e) ?? 0, S = p.get(s), T = m?.shiftKey ? 10 : 1, x = M - S * T, g = n != null ? p.get(n) : void 0;
      if (g != null && x < g) return;
      const I = u(x);
      I !== M && a && a(I);
    }, _ = (m) => {
      const M = p.get(e) ?? 0, S = p.get(s), T = m?.shiftKey ? 10 : 1, x = M + S * T, g = r != null ? p.get(r) : void 0;
      if (g != null && x > g) return;
      const I = u(x);
      I !== M && a && a(I);
    };
    return ((m, M) => ct(
      l.class("bc-number-input-steppers"),
      y.button(
        l.type("button"),
        l.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"
        ),
        l.disabled(
          B(
            w,
            t.disabled ?? !1
          )((S, T) => !S || T)
        ),
        k.click((S) => _(S)),
        R.label(m),
        U({ icon: "line-md:plus", size: "xs" })
      ),
      y.button(
        l.type("button"),
        l.class(
          "bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"
        ),
        l.disabled(
          B(
            f,
            t.disabled ?? !1
          )((S, T) => !S || T)
        ),
        k.click((S) => $(S)),
        R.label(M),
        U({ icon: "line-md:minus", size: "xs" })
      )
    ))(
      kt.incrementValue,
      kt.decrementValue
    );
  })(), h = J(
    e,
    t.disabled,
    a ?? i
  ), b = o != null && d != null ? z(d, h, o) : o != null ? z(h, o) : d != null ? z(d, h) : h;
  return O({
    ...t,
    input: Q.number(
      // min/max attributes and reactive watchers (no forced correction)
      n != null ? l.min(n) : D,
      r != null ? l.max(r) : D,
      H(t),
      // Represent null as empty string so the field can be cleared
      l.value(p.map(e, (f) => f == null ? "" : String(f))),
      l.step(s),
      l.class("bc-input bc-number-input"),
      c != null ? k.blur(j(c)) : D,
      a != null ? k.change(
        j((f) => {
          const w = jt(f);
          a(w);
        })
      ) : D,
      i != null ? k.input(
        j((f) => {
          const w = jt(f);
          i(w);
        })
      ) : D,
      // Wheel support when step is defined
      s != null ? k.wheel((f) => {
        f.preventDefault();
        const w = p.get(e) ?? 0, $ = p.get(s), _ = f.shiftKey ? 10 : 1, v = f.deltaY < 0 ? $ * _ : -$ * _, m = u(w + v);
        m !== w && a && a(m);
      }) : D
    ),
    after: b
  });
}, En = ({
  value: t,
  onChange: e,
  onInput: s,
  onBlur: n,
  offLabel: r,
  onLabel: c,
  disabled: a = !1,
  size: i = "md",
  id: o,
  color: u = "primary",
  tabIndex: d = 0
}) => {
  const h = o ?? be("switch");
  function b(_, v) {
    const m = [
      "bc-switch",
      `bc-switch--size-${v}`,
      `bc-switch--${v}`
    ];
    return _ && m.push("bc-switch--disabled"), m.join(" ");
  }
  function f(_) {
    const v = _ ?? "primary", m = /* @__PURE__ */ new Map(), M = Rt(v, "solid", "light"), S = Rt(v, "solid", "dark");
    return m.set("--switch-track-on-bg", M.backgroundColor), m.set("--switch-track-on-label", M.textColor), m.set("--switch-track-on-bg-dark", S.backgroundColor), m.set("--switch-track-on-label-dark", S.textColor), m.set(
      "--switch-track-on-border-dark",
      de(v, "dark")
    ), Array.from(m.entries()).map(([T, x]) => `${T}: ${x}`).join("; ");
  }
  const w = () => {
    p.get(a) || (e?.(!p.get(t)), s?.(!p.get(t)));
  }, $ = (_) => {
    p.get(a) || (_.key === " " || _.key === "Enter") && (_.preventDefault(), w());
  };
  return y.div(
    l.class(
      B(
        a ?? !1,
        i
      )(
        (_, v) => b(_ ?? !1, v ?? "md")
      )
    ),
    l.style(
      B(u)(
        (_) => f(_)
      )
    ),
    l.id(h),
    l.role("switch"),
    l.tabindex(
      B(
        a ?? !1,
        d
      )((_, v) => _ ? -1 : v ?? 0)
    ),
    R.checked(t),
    R.disabled(a),
    k.click(w),
    k.keydown($),
    n != null ? k.blur(n) : null,
    y.div(
      l.class("bc-switch__track"),
      l.class(
        p.map(
          t,
          (_) => _ ? "bc-switch__track--on" : "bc-switch__track--off"
        )
      ),
      r != null ? y.div(
        R.hidden(!0),
        l.class("bc-switch__track-label bc-switch__track-label--off"),
        l.class(
          p.map(
            t,
            (_) => _ ? "bc-switch__track-label--hidden" : "bc-switch__track-label--visible"
          )
        ),
        r
      ) : null,
      c != null ? y.div(
        l.class("bc-switch__track-label bc-switch__track-label--on"),
        l.class(
          p.map(
            t,
            (_) => _ ? "bc-switch__track-label--visible" : "bc-switch__track-label--hidden"
          )
        ),
        c
      ) : null,
      Zt(
        (_) => P(
          pe,
          ({ direction: v }) => y.div(
            l.class("bc-switch__thumb"),
            l.class(
              p.map(
                t,
                (m) => m ? "bc-switch__thumb--on" : "bc-switch__thumb--off"
              )
            ),
            ht.transform(
              B(
                t,
                _,
                i,
                v
              )((m, { width: M }, S, T) => {
                const x = (() => {
                  switch (S) {
                    case "xs":
                      return 5;
                    case "sm":
                      return 5.5;
                    case "md":
                      return 6;
                    case "lg":
                      return 7;
                    case "xl":
                      return 8;
                  }
                })(), g = T === "rtl" ? `calc((var(--spacing-base) * ${x}) - ${M}px)` : `calc(${M}px - (var(--spacing-base) * ${x}))`;
                return m ? `translateX(${g})` : "translateX(0)";
              })
            )
          )
        )
      )
    )
  );
}, en = (t) => {
  const e = {
    type: "pattern",
    pattern: /[0-9A-Fa-f]/,
    transform: (n) => n.toLowerCase()
  };
  return Jt({
    ...t,
    mask: [
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      "-",
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e,
      e
    ],
    // Sensible default placeholder; can be overridden via options.placeholder
    placeholder: t.placeholder ?? "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  });
}, Rn = et(en), nn = "line-md:star-alt-filled", sn = "line-md:star-alt", rn = (t) => {
  const {
    value: e,
    onChange: s,
    disabled: n,
    max: r = 5,
    fullColor: c = "yellow",
    emptyColor: a = "neutral",
    fullIcon: i = nn,
    emptyIcon: o = sn,
    size: u = "md",
    onBlur: d,
    rounding: h = 1
  } = t, b = () => {
    const m = p.get(h);
    return m > 0 ? m : 1;
  }, f = (m) => Math.min(Math.max(m, 0), p.get(r)), w = (m, M) => {
    if (p.get(n ?? !1)) return;
    const T = m.currentTarget.getBoundingClientRect(), x = (m.clientX - T.left) / T.width, g = M - 1 + x, I = b(), F = Math.ceil(g / I) * I, A = f(F);
    s?.(A);
  }, $ = (m) => {
    if (p.get(n ?? !1)) return;
    const M = b(), S = p.get(e) ?? 0;
    let T;
    switch (m.key) {
      case "ArrowRight":
      case "ArrowUp":
        T = f(S + M);
        break;
      case "ArrowLeft":
      case "ArrowDown":
        T = f(S - M);
        break;
      case "Home":
        T = 0;
        break;
      case "End":
        T = p.get(r);
        break;
      default:
        return;
    }
    m.preventDefault(), s?.(T);
  }, _ = p.map(u, (m) => `bc-icon--${m}`), v = ({ index: m, counter: M }) => y.span(
    l.class("bc-rating-input__icon-container"),
    l.class(_),
    U(
      {
        icon: o,
        size: u,
        color: a,
        tone: "soft"
      },
      l.class("bc-rating-input__icon-empty")
    ),
    y.span(
      l.class("bc-rating-input__icon-clipper"),
      l.class(_),
      ht.width(
        p.map(e, (S) => {
          const T = Math.floor(S);
          return T > m ? "100%" : T < m ? "0%" : `${(S - m) * 100}%`;
        })
      ),
      U(
        {
          icon: i,
          size: u,
          color: c,
          tone: "soft"
        },
        l.class("bc-rating-input__icon-full")
      )
    ),
    k.click(
      re((S) => w(S, M), {
        preventDefault: !0,
        stopPropagation: !0
      })
    )
  );
  return O({
    baseContainer: !0,
    growInput: !1,
    focusableSelector: '[role="slider"]',
    ...t,
    input: y.div(
      // Common input attributes (id, required, invalid, custom classes, etc.)
      H(t),
      l.class("bc-rating-input"),
      // ARIA slider semantics
      l.role("slider"),
      l.tabindex(p.map(n ?? !1, (m) => m ? -1 : 0)),
      R.disabled(n ?? !1),
      R.valuemin(0),
      R.valuemax(p.map(r, (m) => m ?? 0)),
      R.valuenow(p.map(e, (m) => m ?? 0)),
      R.valuetext(
        B(
          e,
          r
        )((m, M) => {
          const S = m ?? 0, T = M ?? 0;
          return `${String(S)} / ${String(T)}`;
        })
      ),
      // Keyboard & focus handlers
      k.keydown($),
      d != null ? k.blur(d) : null,
      Wt(r, v)
    )
  });
}, Un = (t) => {
  const { value: e, onChange: s, onInput: n, onBlur: r, after: c, disabled: a, ...i } = t, o = J(e, a, s ?? n);
  return rn({
    ...i,
    // Map null -> 0 for display so the control shows as empty when null
    value: p.map(e, (u) => u ?? 0),
    // Pass through numeric changes; clear button will call onChange(null)
    onChange: s,
    onInput: n,
    onBlur: r,
    after: c != null ? z(o, c) : o
  });
}, Nn = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: c, onChange: a, onInput: i } = t;
  return O({
    ...t,
    // Make sure clicks anywhere focus the range input
    focusableSelector: 'input[type="range"]',
    input: y.input(
      l.type("range"),
      H(t),
      l.min(n),
      l.max(r),
      l.step(s),
      // Using value as number to keep it in sync
      l.valueAsNumber(e),
      l.class("bc-input bc-slider-input"),
      c != null ? k.blur(Y(c)) : D,
      a != null ? k.change(Y(a)) : D,
      i != null ? k.input(Y(i)) : D
    )
  });
}, On = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: c, onChange: a, onInput: i } = t, o = p.map(e, (d) => {
    if (d != null) return d;
    const h = n != null ? p.get(n) : void 0;
    return typeof h == "number" ? h : 0;
  }), u = J(
    e,
    t.disabled,
    a ?? i
  );
  return O(
    {
      ...t,
      focusableSelector: 'input[type="range"]',
      after: u,
      input: y.input(
        l.type("range"),
        H(t),
        l.min(n),
        l.max(r),
        l.step(s),
        l.valueAsNumber(o),
        l.class("bc-input bc-slider-input"),
        c != null ? k.blur(Y(c)) : D,
        a != null ? k.change(
          Y((d) => {
            a(d);
          })
        ) : D,
        i != null ? k.input(
          Y((d) => {
            i(d);
          })
        ) : D
      )
    },
    // Ensure container grows input naturally
    z()
  );
};
let It = null;
async function St() {
  const t = globalThis;
  return t.Temporal ? t.Temporal : (It || (It = import("./index.esm-DPNh6inz.js").then((e) => {
    const s = e.Temporal;
    return t.Temporal || (t.Temporal = s), s;
  })), It);
}
const an = (t, e) => e ? zt(St, {
  then: t,
  pending: e.pending,
  error: e.error
}) : zt(St, t), ln = /^P(\d+([YMWD]|$)){0,4}(T(\d+([HMS]|$)){0,3})?$/i, on = /^P(?:(\d+Y)?(\d+M)?(\d+W)?(\d+D)?)(T(\d+H)?(\d+M)?(\d+S)?)?$/i;
function cn(t) {
  return {
    mask: null,
    allowMode: "custom",
    allow: (e) => /[0-9ptwdhms]/i.test(e),
    pipe: (e) => {
      const s = e.toUpperCase();
      return s.length === 0 ? s : !s.startsWith("P") || !ln.test(s) ? !1 : s;
    },
    completion: {
      mode: "custom",
      isComplete: (e) => {
        const s = e.toUpperCase();
        if (!on.test(s)) return !1;
        try {
          return t(s), !0;
        } catch {
          return !1;
        }
      }
    }
  };
}
const Ht = (t, e) => {
  if (t == null) return null;
  try {
    return t.Duration.from(e);
  } catch {
    return null;
  }
}, Pn = (t) => {
  const { value: e, onChange: s, onInput: n, after: r, disabled: c, onBlur: a } = t, i = () => {
    const d = J(e, c, s ?? n);
    return r != null ? z(d, r) : d;
  }, o = t.placeholder != null ? D : l.placeholder("P0DT0H0M0S");
  return an(
    (d) => Jt({
      ...t,
      value: p.map(e, (h) => h?.toString() ?? ""),
      onChange: s ? (h) => s(h === "" ? null : d.Duration.from(h)) : void 0,
      onInput: void 0,
      ...cn(d.Duration.from),
      placeholder: "P0DT0H0M0S",
      after: i()
    }),
    { pending: () => {
      const d = (h) => (b) => {
        const w = b.currentTarget?.value ?? "";
        if (w === "") {
          h(null);
          return;
        }
        const $ = globalThis.Temporal, _ = Ht($, w);
        if (_ != null) {
          h(_);
          return;
        }
        St().then((v) => {
          const m = Ht(v, w);
          m != null && h(m);
        }).catch(() => {
        });
      };
      return O({
        ...t,
        input: Q.text(
          H(t),
          l.value(p.map(e, (h) => h?.toString() ?? "")),
          l.class("bc-input"),
          o,
          a != null ? k.blur(() => a()) : D,
          s != null ? k.change(d(s)) : D,
          n != null ? k.input(d(n)) : D
        ),
        after: i()
      });
    } }
  );
}, un = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r } = t;
  return O({
    ...t,
    input: Q.url(
      H(t),
      l.value(e),
      l.class("bc-input"),
      s != null ? k.blur(j(s)) : D,
      n != null ? k.change(j(n)) : D,
      r != null ? k.input(j(r)) : D
    )
  });
}, jn = et(un), pn = (t) => {
  const {
    controller: e,
    element: s,
    separator: n,
    showMove: r = !0,
    showRemove: c = !0,
    showAdd: a = !0,
    createItem: i,
    addLabel: o,
    controlsLayout: u = "aside",
    removeDisabled: d,
    addDisabled: h
  } = t, b = p.toSignal(u).map(($) => $ === "aside"), f = ($) => {
    const _ = L(
      r ?? !1,
      () => y.div(
        l.class("bc-group--align-center"),
        l.class(
          b.map(
            (m) => m ? "bc-group--direction-column bc-group--gap-1" : "bc-group--direction-row bc-group--gap-1"
          )
        ),
        vt(
          {
            size: "xs",
            roundedness: "full",
            variant: "text",
            onClick: () => $.move("up"),
            disabled: $.cannotMove("up")
          },
          P(
            W,
            (m) => U({
              size: "xs",
              icon: "line-md:arrow-up",
              title: m.$.incrementValue
            })
          )
        ),
        vt(
          {
            size: "xs",
            roundedness: "full",
            variant: "text",
            onClick: () => $.move("down"),
            disabled: $.cannotMove("down")
          },
          P(
            W,
            (m) => U({
              size: "xs",
              icon: "line-md:arrow-down",
              title: m.$.decrementValue
            })
          )
        )
      )
    ), v = L(
      c,
      () => P(
        W,
        (m) => mt({
          size: "xs",
          // Use a lowercase label to satisfy tests that query with [aria-label*="remove"]
          label: p.map(m.$.removeItem, (M) => M.toLowerCase()),
          color: "danger",
          disabled: d,
          onClick: $.remove
        })
      )
    );
    return (m) => L(
      b,
      () => dt(
        l.class("bc-group--gap-1 bc-group--align-center"),
        ct(l.class("bc-stack--grow"), m),
        ct(
          l.class("bc-stack--align-center"),
          L(
            e.signal.map((M) => M.length > 1),
            () => _
          ),
          v
        )
      ),
      () => ct(
        l.class("bc-stack--gap-2"),
        m,
        dt(
          l.class("bc-group--gap-2 bc-group--justify-between"),
          L(
            e.signal.map((M) => M.length > 1),
            () => _,
            () => y.div()
          ),
          v
        )
      )
    );
  }, w = L(
    B(a, i)(($, _) => $ && _ != null),
    () => dt(
      l.class(
        "bc-group--gap-2 bc-group--align-center bc-group--justify-center"
      ),
      vt(
        {
          size: "sm",
          variant: "filled",
          onClick: () => e.push(i()),
          disabled: B(
            e.disabled,
            h ?? !1
          )(
            ($, _) => $ || _
          )
        },
        P(
          W,
          ($) => dt(
            l.class("bc-group--gap-2"),
            U({ icon: "line-md:plus" }),
            o ?? $.$.addLabel
          )
        )
      )
    )
  );
  return z(
    Xe(
      e,
      ($) => f($)(s($)),
      n
    ),
    w
  );
}, Hn = (t, ...e) => {
  const {
    controller: s,
    element: n,
    separator: r,
    showMove: c,
    showRemove: a,
    showAdd: i,
    createItem: o,
    addLabel: u,
    controlsLayout: d,
    removeDisabled: h,
    addDisabled: b,
    ...f
  } = t;
  return Yt(
    {
      ...f,
      content: pn({
        controller: s,
        element: n,
        separator: r,
        showMove: c,
        showRemove: a,
        showAdd: i,
        createItem: o,
        addLabel: u,
        controlsLayout: d,
        removeDisabled: h,
        addDisabled: b
      })
    },
    ...e
  );
};
class Wn extends xt {
  branches;
  activeBranch;
  #e;
  #t = /* @__PURE__ */ new Map();
  constructor(e, s, n, r, c, a, i = rt) {
    super(e, s, n, r, c, i), this.branches = a;
    const o = (d) => {
      for (const h of a)
        if (h.detect(d))
          return h.key;
      return a[0]?.key ?? "unknown";
    };
    this.activeBranch = n.map(o, rt);
    const u = (d) => {
      if (this.#t.has(d))
        return this.#t.get(d);
      const h = a.find((f) => f.key === d);
      if (!h)
        throw new Error(`Unknown branch: ${d}`);
      const b = new xt(
        [...e, d],
        (f) => {
          this.change(f);
        },
        this.signal.map(
          (f) => h.detect(f) ? f : h.defaultValue(),
          i
        ),
        r.map(Ut([d])),
        {
          disabled: this.disabled,
          validationMode: this.parent.validationMode
        },
        i
      );
      return this.#t.set(d, b), b;
    };
    this.#e = this.activeBranch.map(
      (d) => u(d),
      rt
    ), this.onDispose(() => {
      for (const d of this.#t.values())
        d.dispose();
      this.#t.clear(), this.activeBranch.dispose(), this.#e.dispose();
    });
  }
  /**
   * Get the controller for the currently active branch
   */
  get activeController() {
    return p.get(this.#e);
  }
  /**
   * Get a controller for a specific branch
   */
  getBranchController(e) {
    const s = this.branches.find((r) => r.key === e);
    if (!s)
      throw new Error(`Unknown branch: ${e}`);
    if (this.#t.has(e))
      return this.#t.get(e);
    const n = new xt(
      [...this.path, e],
      (r) => {
        this.change(r);
      },
      this.signal.map(
        (r) => s.detect(r) ? r : s.defaultValue(),
        rt
      ),
      this.status.map(Ut([e])),
      {
        disabled: this.disabled,
        validationMode: this.parent.validationMode
      },
      rt
    );
    return this.#t.set(e, n), n;
  }
  /**
   * Switch to a different branch
   */
  switchToBranch(e, s = !1) {
    const n = this.branches.find((a) => a.key === e);
    if (!n)
      throw new Error(`Unknown branch: ${e}`);
    const r = p.get(this.signal);
    if (n.detect(r))
      return !0;
    if (n.convert) {
      const a = n.convert(r);
      if (a.ok)
        return this.change(a.value), !0;
    }
    if (s && typeof window == "object" && typeof window.confirm == "function" && !window.confirm(
      "Changing type will clear the current value. Continue?"
    ))
      return !1;
    const c = n.defaultValue();
    return this.change(c), !0;
  }
  /**
   * Get the current active branch definition
   */
  get activeBranchDefinition() {
    const e = p.get(this.activeBranch);
    return this.branches.find((s) => s.key === e);
  }
}
function Zn(t) {
  return t.transform(
    (e) => e ?? null,
    (e) => e ?? void 0
  );
}
function Yn(t) {
  return t.transform(
    (e) => e ?? "",
    (e) => e === "" ? void 0 : e
  );
}
function Xn(t) {
  return t.transform(
    (e) => e ?? void 0,
    (e) => e ?? null
  );
}
export {
  we as $,
  En as A,
  pn as B,
  In as C,
  en as D,
  je as E,
  ze as F,
  dt as G,
  Rn as H,
  Un as I,
  Nn as J,
  On as K,
  Hn as L,
  Jt as M,
  Ze as N,
  Pn as O,
  un as P,
  jn as Q,
  rn as R,
  $n as S,
  tn as T,
  $t as U,
  Cn as V,
  an as W,
  kn as X,
  He as Y,
  ve as Z,
  xe as _,
  J as a,
  Ct as a0,
  it as a1,
  xn as a2,
  $e as a3,
  ye as a4,
  Ie as a5,
  qt as a6,
  ke as a7,
  Mt as a8,
  Ce as a9,
  wt as aa,
  _t as ab,
  Me as ac,
  Se as ad,
  at as ae,
  lt as af,
  St as ag,
  _n as ah,
  wn as ai,
  Xt as b,
  _e as c,
  cn as d,
  Pt as e,
  Wn as f,
  Yn as g,
  Xn as h,
  vn as i,
  yn as j,
  Ee as k,
  Oe as l,
  Mn as m,
  Ke as n,
  Xe as o,
  Ye as p,
  Sn as q,
  Dn as r,
  Tn as s,
  Zn as t,
  Fn as u,
  Vn as v,
  Bn as w,
  An as x,
  Ln as y,
  zn as z
};
