import { Use as P, Value as p, prop as tt, html as y, attr as l, on as I, WithElement as ut, Empty as F, aria as R, bind as ft, computedOf as B, style as ht, OnDispose as X, When as L, NotEmpty as Jt, Fragment as z, ForEach as ot, svg as At, svgAttr as bt, emitValue as j, coalesce as Kt, Ensure as te, OneOfType as ee, Repeat as jt, signal as Vt, input as Q, emitValueAsNullableDate as ne, emitValueAsNullableDateTime as se, emitValueAsNumber as Y, emit as re, Task as Bt } from "@tempots/dom";
import { f as ae } from "./colors-pQZlNrwM.js";
import { g as le } from "./timer-DzWb416P.js";
import { ElementRect as Ht, AutoSelect as oe } from "@tempots/ui";
import { a as W, b as O, f as Lt, I as U, C as H, c as ce, d as It, T as ie, g as ue, L as pe, e as zt, h as de, B as vt } from "./translations-g3qGTkzw.js";
import { C as mt, m as fe, d as me, I as Wt, E as he, P as ge, S as ct, s as be, e as xt, O as rt, f as Et } from "./notice-Cpso9PgQ.js";
function Zt(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 Zt(t) || ve(t) || xe(t) || we(t);
}
function _e(t) {
  if (!Zt(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, b) => {
    const [g, f, w] = [u, d, b].map((_) => (_ = _ / 255, _ <= 0.03928 ? _ / 12.92 : Math.pow((_ + 0.055) / 1.055, 2.4)));
    return 0.2126 * g + 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), b = parseInt(u.slice(2, 4), 16), g = parseInt(u.slice(4, 6), 16), f = parseInt(u.slice(6, 8), 16) / 255;
      return [d, b, g, 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), b = parseInt(u[1] + u[1], 16), g = parseInt(u[2] + u[2], 16), f = parseInt(u[3] + u[3], 16) / 255;
      return [d, b, g, f];
    }
    if (u.length === 3) {
      const d = parseInt(u[0] + u[0], 16), b = parseInt(u[1] + u[1], 16), g = parseInt(u[2] + u[2], 16);
      return [d, b, g, 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]), b = parseFloat(c[3]), g = c[4] != null ? parseFloat(c[4]) : 1, [f, w, _] = Yt(u, d / 100, b / 100);
    return [f, w, _, g];
  }
  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, b = parseFloat(a[3]) / 100, g = a[4] != null ? parseFloat(a[4]) : 1, [f, w, _] = Ie(u, d, b);
    return [f, w, _, g];
  }
  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]), b = parseFloat(i[3]), g = 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, b);
    return [w, _, $, g];
  }
  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 ke(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 Yt(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 Ie(t, e, s) {
  t = (t % 360 + 360) % 360;
  const n = e + s;
  n > 1 && (e /= n, s /= n);
  const [r, c, a] = Yt(t, 1, 0.5).map((b) => b / 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, b = o * o * o, g = 4.0767416621 * u - 3.3077115913 * d + 0.2309699292 * b, f = -1.2684380046 * u + 2.6097574011 * d - 0.3413193965 * b, w = -0.0041960863 * u - 0.7034186147 * d + 1.707614701 * b;
  return [_t(g), _t(f), _t(w)];
}
function De(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), b = Math.cbrt(o), g = 0.2104542553 * u + 0.793617785 * d - 0.0040720468 * b, f = 1.9779984951 * u - 2.428592205 * d + 0.4505937099 * b, w = 0.0259040371 * u + 0.7827717662 * d - 0.808675766 * b, _ = Math.sqrt(f * f + w * w);
  let $ = Math.atan2(w, f) * 180 / Math.PI;
  return $ < 0 && ($ += 360), [g, _, $];
}
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] = De(t, e, s), u = (Math.round(a * 1e3) / 1e3).toFixed(3), d = (Math.round(i * 1e3) / 1e3).toFixed(3), b = (Math.round(o * 10) / 10).toFixed(1), g = Math.round(n * 100) / 100;
      return c || n < 1 ? `oklch(${u} ${d} ${b} / ${g})` : `oklch(${u} ${d} ${b})`;
    }
  }
}
function lt(t, e) {
  return e ? t === "rgb" ? "rgba" : t === "hsl" ? "hsla" : t : t === "rgba" ? "rgb" : t === "hsla" ? "hsl" : t;
}
class Se 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 Se(
    "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 = (x) => {
      x.preventDefault(), x.stopPropagation(), u.value = !0;
    }, b = (x) => {
      x.preventDefault(), x.stopPropagation(), (!x.currentTarget || !x.currentTarget.contains(x.relatedTarget)) && (u.value = !1);
    }, g = (x) => {
      x.preventDefault(), x.stopPropagation(), u.value = !1;
      const m = Array.from(x.dataTransfer?.files || []);
      m.length > 0 && (o.value = m, t(m, "dragdrop"));
    }, f = (x) => {
      p.get(n) && x.currentTarget.querySelector(
        'input[type="file"]'
      )?.click();
    };
    let w = null;
    const _ = () => {
      if (w == null) return;
      const x = Array.from(w.files ?? []);
      x.length > 0 && (o.value = x, t(x, "click")), w.value = "";
    }, $ = (x) => {
      p.get(n) && (x.key === "Enter" || x.key === " ") && (x.preventDefault(), f(x));
    };
    return y.div(
      l.role("button"),
      l.tabindex(
        p.map(n, (x) => x ? 0 : -1)
      ),
      l.style("position: relative;"),
      I.dragover(d),
      I.dragleave(b),
      I.drop(g),
      I.click(f),
      I.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;"
        ),
        I.change(_),
        ut((x) => (w = x, o.on((m) => {
          const M = globalThis.DataTransfer;
          if (M != null) {
            const D = new M();
            m.forEach((S) => D.items.add(S)), x.files = D.files;
          }
        }), F))
      ),
      // 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: b } = d[i[u] ?? 0];
              return `${b}px`;
            })
          ),
          ht.left(
            B(
              e,
              o
            )((u, d) => {
              const { left: b } = d[i[u] ?? 0];
              return `${b}px`;
            })
          )
        ),
        // clickable buttons
        a.map(({ label: u, key: d }, b) => y.button(
          l.type("button"),
          I.click((g) => {
            g.preventDefault(), p.get(r) || s?.(d);
          }),
          l.disabled(r),
          l.class("bc-segmented-input__segment"),
          l.class(
            p.map(e, (g) => g === d ? "bc-segmented-input__segment--active" : "bc-segmented-input__segment--inactive")
          ),
          Ht((g) => {
            function f() {
              o.update((_) => {
                const $ = [..._];
                return $[b] = {
                  width: g.value.width,
                  left: g.value.localLeft
                }, $;
              });
            }
            const w = le(f);
            return X(w, g.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(
        X(() => {
          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: b = !0,
    ...g
  } = t, f = s, w = p.map(d, (v) => v === "input"), _ = p.map(d, (v) => v === "compact"), $ = (v) => {
    let h = v;
    if (r != null) {
      const k = p.get(r);
      h = h.slice(0, k);
    }
    if (c) {
      const k = p.get(c);
      h = h.filter((T) => T.size <= k);
    }
    a?.(h);
  }, x = (v) => {
    const k = f.value.filter((T, A) => A !== v);
    a?.(k);
  }, m = () => {
    a?.([]);
  }, M = ({
    files: v,
    clear: h,
    change: k
  }) => P(
    W,
    (T) => 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(T.$.filesInputInstructions)(
            r,
            c,
            T.$.fileSizeUnits.value
          )
        )
      )
    )
  ), D = ({
    files: v
  }) => P(
    W,
    (h) => y.div(
      l.class("bc-file-input__compact-drop-zone"),
      L(
        v.map((k) => k.length > 0),
        () => y.div(
          l.class("bc-file-input__compact-file-list"),
          ot(v, (k, T) => {
            const A = T.index;
            return y.div(
              l.class("bc-file-input__compact-file-item"),
              y.div(
                l.class("bc-file-input__compact-file-icon"),
                yt(k)
              ),
              y.div(
                l.class("bc-file-input__compact-file-info"),
                y.div(
                  l.class("bc-file-input__compact-file-name"),
                  l.title(k.$.name),
                  k.$.name
                ),
                y.div(
                  l.class("bc-file-input__compact-file-meta"),
                  B(
                    k.$.size,
                    h.$.fileSizeUnits
                  )((C, V) => Lt(C, { units: V })),
                  " • ",
                  B(
                    k.$.type,
                    h.$.unknownType
                  )((C, V) => C || V)
                )
              ),
              mt(
                {
                  size: "sm",
                  label: h.$.removeFile,
                  disabled: o,
                  onClick: () => x(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(h.$.filesInputInstructions)(
              r,
              c,
              h.$.fileSizeUnits.value
            )
          )
        )
      )
    )
  ), S = ({
    files: v
  }) => P(
    W,
    (h) => y.div(
      l.class("bc-file-input__compact-input"),
      L(
        v.map((k) => k.length > 0),
        () => y.span(
          l.class("bc-file-input__compact-value"),
          ot(
            v,
            (k) => y.span(
              l.class("bc-file-input__compact-value-item"),
              yt(k),
              y.span(
                l.class("bc-file-input__compact-value-item-name"),
                k.$.name
              )
            )
          )
        ),
        () => y.span(
          l.class("bc-file-input__compact-placeholder"),
          U({ icon: "mdi:cloud-upload-outline", size: "md" }),
          " ",
          ft(h.$.filesInputInstructions)(
            r,
            c,
            h.$.fileSizeUnits.value
          )
        )
      )
    )
  );
  return P(
    W,
    (v) => O(
      {
        baseContainer: p.map(w, (h) => !h),
        disabled: o,
        hasError: u,
        after: L(
          w,
          () => L(
            f.map(({ length: h }) => h > 0),
            () => mt(
              {
                size: "sm",
                label: v.$.clearAllFiles,
                disabled: o,
                onClick: m
              },
              l.class("bc-file-input__compact-clear")
            )
          )
        ),
        ...g,
        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, (h) => h > 1),
              disabled: o,
              onChange: $,
              content: S
            })
          ),
          () => 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, (h) => h > 1),
                disabled: o,
                onChange: $,
                content: D
              })
            ),
            () => y.div(
              l.class("bc-file-input"),
              $t({
                value: f,
                accept: n,
                enableClick: !0,
                allowMultiple: p.map(r ?? 1 / 0, (h) => h > 1),
                disabled: o,
                onChange: $,
                content: M
              }),
              L(
                b,
                () => Jt(
                  f,
                  () => z(
                    y.div(
                      l.class("bc-file-input__file-list"),
                      ot(f, (h, k) => {
                        const T = k.index;
                        return y.div(
                          l.class("bc-file-input__file-item"),
                          y.div(
                            l.class("bc-file-input__file-icon"),
                            yt(h)
                          ),
                          y.div(
                            l.class("bc-file-input__file-info"),
                            y.div(
                              l.class("bc-file-input__file-name"),
                              l.title(h.$.name),
                              h.$.name
                            ),
                            y.div(
                              l.class("bc-file-input__file-meta"),
                              B(
                                h.$.size,
                                v.$.fileSizeUnits
                              )(
                                (A, C) => Lt(A, { units: C })
                              ),
                              " • ",
                              B(
                                h.$.type,
                                v.$.unknownType
                              )((A, C) => A || C)
                            )
                          ),
                          mt(
                            {
                              size: "sm",
                              label: v.$.removeFile,
                              disabled: o,
                              onClick: () => x(T)
                            },
                            l.class("bc-file-input__remove-button")
                          )
                        );
                      })
                    ),
                    L(
                      f.map(({ length: h }) => h > 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),
                          v.$.clearAllFiles,
                          I.click((h) => {
                            h.preventDefault(), h.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((b, g) => {
    const f = c.get(b), w = Ne(b ?? ""), _ = f?.type || Ue(w), $ = f?.name ?? `file-${g}`, x = w.buffer.slice(
      w.byteOffset,
      w.byteOffset + w.byteLength
    ), m = new Blob([x], { type: _ });
    return new File([m], $, { type: _ });
  })), i = (d) => (b) => {
    d && Re(b).then((g) => {
      for (const [f, w] of g.entries())
        c.set(w, { name: b[f].name, type: b[f].type });
      d(g);
    });
  }, 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 = ke(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) * _, x = Math.sin(w) * _;
    u.push({ x: $, y: x });
  }
  const d = (u[0].x + u[i - 1].x) / 2, b = (u[0].y + u[i - 1].y) / 2;
  let g = `M ${d.toFixed(3)} ${b.toFixed(3)}`;
  for (let f = 0; f < i; f++) {
    const w = u[f], _ = u[(f + 1) % i], $ = (w.x + _.x) / 2, x = (w.y + _.y) / 2;
    g += ` Q ${w.x.toFixed(3)} ${w.y.toFixed(3)} ${$.toFixed(3)} ${x.toFixed(3)}`;
  }
  return g += " Z", g;
}
const kn = (t) => {
  const { value: e, onBlur: s, onChange: n, onInput: r, displayValue: c, size: a, withAlpha: i } = t, o = p.map(a ?? 32, (v) => v), u = p.map(e, (v) => $e(v ?? "#000000")), d = p.map(
    u,
    ([v, h, k]) => [v, h, k]
  ), b = p.map(u, ([, , , v]) => v), g = tt(p.get(b) ?? 1), f = p.map(i ?? !1, (v) => v), w = p.map(
    t.colorTextFormat ?? "rgb",
    (v) => v
  ), _ = B(
    d,
    g,
    w,
    f
  )(
    ([v, h, k], T, A, C) => at(v, h, k, T ?? 1, lt(A, C), C)
  ), $ = p.map(
    t.colorTextFormat ?? "hex",
    (v) => v
  ), x = p.map(o, (v) => `${-v / 2} ${-v / 2} ${v} ${v}`), m = B(
    d,
    o
  )((v, h) => Pe(v, h / 2)), M = B(
    d,
    g,
    f
  )(
    ([v, h, k], T, A) => A || T < 1 ? ye(v, h, k, T) : Ct(v, h, k)
  ), D = y.div(
    l.class("bc-color-swatch-input__control"),
    l.class(
      p.map(
        f,
        (v) => v ? "bc-color-swatch-input__control--alpha" : ""
      )
    ),
    l.style(
      B(o)((v) => `min-width:${v + 2}px;height:${v + 2}px`)
    ),
    // The SVG blob preview
    At.svg(
      l.class("bc-color-swatch-input__svg"),
      bt.viewBox(x),
      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, ([v, h, k]) => Ct(v, h, k))),
      l.class(
        "bc-input bc-color-swatch-input bc-color-swatch-input__native"
      ),
      s != null ? I.blur(s) : F,
      n != null ? I.change((v) => {
        const h = v.target.value;
        if (!n) return;
        const { r: k, g: T, b: A } = it(h) ?? { r: 0, g: 0, b: 0 }, C = p.get(g) ?? 1, V = lt(
          p.get($),
          p.get(f)
        ), N = at(k, T, A, C, V, p.get(f));
        n(N);
      }) : F,
      r != null ? I.input((v) => {
        const h = v.target.value;
        if (!r) return;
        const { r: k, g: T, b: A } = it(h) ?? { r: 0, g: 0, b: 0 }, C = p.get(g) ?? 1, V = lt(
          p.get($),
          p.get(f)
        ), N = at(k, T, A, C, V, p.get(f));
        r(N);
      }) : F
    )
  ), S = 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(g, (v) => String(v ?? 1))),
      l.disabled(t.disabled),
      I.input((v) => {
        const h = parseFloat(v.target.value);
        g.set(h);
        const [k, T, A] = p.get(d), C = lt(
          p.get($),
          p.get(f)
        ), V = at(k, T, A, h, C, p.get(f));
        r?.(V);
      }),
      I.change((v) => {
        const h = parseFloat(v.target.value);
        g.set(h);
        const [k, T, A] = p.get(d), C = lt(
          p.get($),
          p.get(f)
        ), V = at(k, T, A, h, C, p.get(f));
        n?.(V);
      })
    )
  );
  return O({
    baseContainer: !0,
    ...t,
    // ensure our control does not try to grow
    growInput: !1,
    input: D,
    // If caller provided an `after`, append RGB before it
    after: z(
      L(
        c ?? !1,
        () => y.span(l.class("bc-color-swatch-input__rgb"), _)
      ),
      S,
      t.after
    )
  });
}, St = "$$tts-exp-", je = (t, e) => ut((s) => {
  const n = `${St}${t}`;
  return X(p.on(e, (r) => Reflect.set(s, n, r)));
}), In = (t, e) => {
  const s = `${St}${t}`;
  return (n) => {
    e(Reflect.get(n.target, s));
  };
}, He = (t, e) => {
  const s = `${St}${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(),
        I.keydown((o) => {
          o.key === "Enter" ? c.set(!1) : o.key === "Escape" && (a.set(!0), c.set(!1));
        }),
        I.blur(
          j((o) => {
            if (c.set(!1), a.value) {
              a.set(!1);
              return;
            }
            s(o);
          })
        )
      ),
      () => y.span(
        I.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)),
            I.click(() => c.set(!0)),
            U({ icon: "line-md/pencil", color: "neutral" })
          )
        )
      )
    )
  );
}, Xt = (t, e, s) => te(
  t,
  (n) => ee(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) => Xt(
          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((b) => {
            const { removedNodes: g } = b[0];
            g.length > 0 && (o.selectedIndex = 0);
          });
          return d.observe(u, { childList: !0 }), X(() => d.disconnect());
        }),
        H(t),
        l.class("bc-native-select bc-input"),
        P(
          W,
          (u) => y.option(
            l.hidden("hidden"),
            Kt(c, u.$.selectOne)
          )
        ),
        ot(r, (u) => Xt(u, a, e)),
        s != null ? I.blur(s) : F,
        n != null ? I.change(He("value", (u) => n(u))) : F
      )
    },
    I.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 Dn(t) {
  return Wt({
    ...t,
    content: Ye(t)
  });
}
function Xe(t, e, s) {
  const n = t.length.map((r) => r);
  return z(
    jt(
      n,
      (r) => {
        const c = t.item(r.index), a = [];
        return z(
          X(() => {
            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 Rt = {
  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 ? { ...Rt, ...e } : e ?? Rt, 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 Ut(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), b = /* @__PURE__ */ new Set();
  for (const C of u) C.type === "literal" && b.add(C.char);
  if (n.prefix) for (const C of n.prefix) b.add(C);
  if (n.suffix) for (const C of n.suffix) b.add(C);
  const g = Array.from(t).filter((C) => d(C) && !b.has(C));
  if (g.length === 0) return { value: "", cursor: 0, completed: !1 };
  const f = [], w = [];
  let _ = 0, $ = 0, x = 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 = g[_];
    if (V == null)
      break;
    if (C.type === "any") {
      x++, 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)) {
        x++;
        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(""), D = (n.prefix ?? "") + M + (n.suffix ?? "");
  let v = (n.prefix ?? "").length;
  if (m >= 0) {
    let C = m + 1;
    if ((c?.policy ?? "smart") !== "sticky")
      for (; C < w.length && w[C].kind === "literal"; ) C++;
    v += C;
  }
  const h = n.completion?.mode === "min" ? (n.completion.minChars ?? 0) <= x : n.completion?.mode === "custom" ? !!n.completion.isComplete?.(D) : $ > 0 && x >= $, k = n.pipe?.(D, { ...a, completed: h });
  let T, A = v;
  return k === !1 ? (T = e, A = e.length) : typeof k == "string" ? (T = k, A = k.length) : typeof k == "object" && k ? (T = k.value, A = k.cursor ?? k.value.length) : T = D, { value: T, cursor: A, completed: h };
}
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 Gt = (t) => {
  const {
    value: e,
    onBlur: s,
    onChange: n,
    onInput: r,
    onAccept: c,
    onComplete: a,
    mask: i,
    definitions: o,
    useDefaultDefinitions: u,
    extraLiterals: d,
    prefix: b,
    suffix: g,
    autofix: f,
    pipe: w,
    completion: _,
    unmask: $,
    allowMode: x,
    allow: m,
    placeholder: M,
    placeholderOptions: D
  } = t, S = B(
    e,
    i,
    o,
    u,
    d,
    b,
    g,
    f,
    _,
    $,
    x,
    M,
    D
  )((h, k, T, A, C, V, N, nt, st, K, q, pt, Z) => k ? Ut(h ?? "", "", k, {
    definitions: T ?? {},
    useDefaultDefinitions: A ?? !0,
    extraLiterals: C ?? [],
    autofix: nt ?? "none",
    completion: st ?? { mode: "mask" },
    pipe: w ?? ((E) => E),
    unmask: K ?? { strategy: "none" },
    allowMode: q ?? "all",
    allow: m,
    prefix: V,
    suffix: N
  }).value : h ?? ""), v = (h, k) => {
    const T = h.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, q = $ != null ? p.get($) : void 0, pt = x != null ? p.get(x) : void 0, Z = b != null ? p.get(b) : void 0, E = g != null ? p.get(g) : void 0, {
      value: G,
      cursor: gt,
      completed: Tt
    } = C ? Ut(
      T,
      A,
      C,
      {
        definitions: V ?? {},
        useDefaultDefinitions: N ?? !0,
        extraLiterals: nt ?? [],
        autofix: st ?? "none",
        completion: K ?? { mode: "mask" },
        pipe: w ?? ((Qt) => Qt),
        unmask: q ?? { strategy: "none" },
        allowMode: pt ?? "all",
        allow: m,
        prefix: Z,
        suffix: E
      },
      h.selectionStart ?? T.length,
      t.cursor ? p.get(t.cursor) : void 0
    ) : { value: T, cursor: T.length, completed: !0 };
    if (G !== T) {
      h.value = G;
      try {
        h.setSelectionRange(gt, gt);
      } catch {
      }
    }
    const Ft = Qe(G, q);
    c?.({
      raw: Ft,
      conformed: G,
      completed: Tt,
      cursor: gt
    }), k === "input" ? r?.(G) : (n?.(G), Tt && a?.({ raw: Ft, conformed: G }));
  };
  return z(
    O({
      ...t,
      input: Q.text(
        H(t),
        l.value(S),
        l.class("bc-input"),
        s != null ? I.blur(s) : F,
        ut(
          (h) => h instanceof HTMLInputElement ? z(
            I.input(() => v(h, "input")),
            I.change(() => v(h, "change")),
            I.keydown((k) => {
              if (k.key !== "Backspace" || !(t.cursor ? p.get(t.cursor)?.backspaceRubberBand ?? !0 : !0)) return;
              const A = h.selectionStart ?? 0, C = h.selectionEnd ?? A;
              if (A !== C || A <= 0) return;
              const V = h.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 = b != null ? p.get(b) : void 0, q = g != null ? p.get(g) : 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 (q) for (const E of q) Z.add(E);
              if (Z.has(V[A - 1])) {
                let E = A - 1;
                for (; E >= 0 && Z.has(V[E]); ) E--;
                E >= 0 && (k.preventDefault(), k.stopPropagation(), h.value = V.slice(0, E) + V.slice(E + 1), v(h, "input"));
              }
            })
          ) : F
        )
      )
    })
  );
};
function J(t, e, s) {
  const n = p.map(t, (c) => c != null), r = It.clearValue;
  return z(
    X(() => p.dispose(n)),
    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" }),
        I.click((c) => {
          c.preventDefault(), c.stopPropagation(), s?.(null);
        })
      )
    )
  );
}
const Sn = (t) => {
  const { value: e, onBlur: s, onChange: n, after: r, disabled: c } = t, a = J(e, c, n);
  return O({
    ...t,
    input: Q.date(
      H(t),
      l.valueAsDate(e),
      l.class("bc-input"),
      s != null ? I.blur(j(s)) : F,
      n != null ? I.change(ne(n)) : F
    ),
    after: r != null ? z(a, r) : a
  });
}, 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, after: r, disabled: c } = t, a = p.map(e, (o) => o != null ? Je(o) : null), i = J(e, c, n);
  return O({
    ...t,
    input: Q["datetime-local"](
      H(t),
      l.value(p.map(a, (o) => o ?? null)),
      l.class("bc-input"),
      s != null ? I.blur(j(s)) : F,
      n != null ? I.change(se(n)) : F
    ),
    after: r != null ? z(i, r) : i
  });
}, Nt = (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);
    return t({
      ...o,
      disabled: i,
      value: p.map(s, Ke),
      onChange: r != null ? (d) => r(Nt(d)) : void 0,
      onInput: c != null ? (d) => c(Nt(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 ? I.blur(j(s)) : F,
      n != null ? I.change(j(n)) : F,
      r != null ? I.input(j(r)) : F
    )
  });
}, Bn = et(
  tn
), Ln = (t) => {
  const { value: e, step: s, min: n, max: r, onBlur: c, onChange: a, onInput: i, after: o } = t, u = (g) => {
    const f = n != null ? p.get(n) : void 0, w = r != null ? p.get(r) : void 0;
    return f != null && g < f ? f : w != null && g > w ? w : g;
  }, d = s != null ? P(W, (g) => {
    const f = B(
      e,
      n
    )((x, m) => m == null ? !0 : (x ?? 0) > m), w = B(
      e,
      r
    )((x, m) => m == null ? !0 : (x ?? 0) < m), _ = (x) => {
      const m = p.get(e) ?? 0, M = p.get(s), D = x?.shiftKey ? 10 : 1, S = m - M * D, v = n != null ? p.get(n) : void 0;
      if (v != null && S < v)
        return;
      const h = u(S);
      h !== m && a && a(h);
    }, $ = (x) => {
      const m = p.get(e) ?? 0, M = p.get(s), D = x?.shiftKey ? 10 : 1, S = m + M * D, v = r != null ? p.get(r) : void 0;
      if (v != null && S > v)
        return;
      const h = u(S);
      h !== m && a && a(h);
    };
    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
          )((x, m) => !x || m)
        ),
        I.click((x) => $(x)),
        R.label(g.$.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
          )((x, m) => !x || m)
        ),
        I.click((x) => _(x)),
        R.label(g.$.decrementValue),
        U({ icon: "line-md:minus", size: "xs" })
      )
    );
  }) : null, b = o != null && d != null ? z(d, o) : o ?? d;
  return O({
    ...t,
    input: Q.number(
      n != null ? z(
        l.min(n),
        X(
          p.on(n, (g) => {
            g < p.get(e);
          })
        )
      ) : F,
      r != null ? z(
        l.max(r),
        X(
          p.on(r, (g) => {
            g > p.get(e);
          })
        )
      ) : F,
      H(t),
      l.valueAsNumber(e),
      l.step(s),
      l.class("bc-input bc-number-input"),
      c != null ? I.blur(j(c)) : F,
      a != null ? I.change(Y(a)) : F,
      i != null ? I.input(Y(i)) : F,
      // Add wheel event support when step is defined
      s != null ? I.wheel((g) => {
        g.preventDefault();
        const f = p.get(e) ?? 0, w = p.get(s), _ = g.shiftKey ? 10 : 1, $ = g.deltaY < 0 ? w * _ : -w * _, x = u(f + $);
        x !== f && a && a(x);
      }) : F
    ),
    after: b
  });
}, Ot = (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 D = m ?? 0;
      return M == null ? !0 : D > M;
    }), w = B(
      e,
      r
    )((m, M) => {
      const D = m ?? 0;
      return M == null ? !0 : D < M;
    }), _ = (m) => {
      const M = p.get(e) ?? 0, D = p.get(s), S = m?.shiftKey ? 10 : 1, v = M - D * S, h = n != null ? p.get(n) : void 0;
      if (h != null && v < h) return;
      const k = u(v);
      k !== M && a && a(k);
    }, $ = (m) => {
      const M = p.get(e) ?? 0, D = p.get(s), S = m?.shiftKey ? 10 : 1, v = M + D * S, h = r != null ? p.get(r) : void 0;
      if (h != null && v > h) return;
      const k = u(v);
      k !== M && a && a(k);
    };
    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
          )((D, S) => !D || S)
        ),
        I.click((D) => $(D)),
        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
          )((D, S) => !D || S)
        ),
        I.click((D) => _(D)),
        R.label(M),
        U({ icon: "line-md:minus", size: "xs" })
      )
    ))(
      It.incrementValue,
      It.decrementValue
    );
  })(), b = J(e, t.disabled, a), g = o != null && d != null ? z(d, b, o) : o != null ? z(b, o) : d != null ? z(d, b) : b;
  return O({
    ...t,
    input: Q.number(
      // min/max attributes and reactive watchers (no forced correction)
      n != null ? l.min(n) : F,
      r != null ? l.max(r) : F,
      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 ? I.blur(j(c)) : F,
      a != null ? I.change(
        j((f) => {
          const w = Ot(f);
          a(w);
        })
      ) : F,
      i != null ? I.input(
        j((f) => {
          const w = Ot(f);
          i(w);
        })
      ) : F,
      // Wheel support when step is defined
      s != null ? I.wheel((f) => {
        f.preventDefault();
        const w = p.get(e) ?? 0, _ = p.get(s), $ = f.shiftKey ? 10 : 1, x = f.deltaY < 0 ? _ * $ : -_ * $, m = u(w + x);
        m !== w && a && a(m);
      }) : F
    ),
    after: g
  });
}, 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 b = o ?? be("switch");
  function g($, x) {
    const m = [
      "bc-switch",
      `bc-switch--size-${x}`,
      `bc-switch--${x}`
    ];
    return $ && m.push("bc-switch--disabled"), m.join(" ");
  }
  function f($) {
    const x = $ ?? "primary", m = /* @__PURE__ */ new Map(), M = zt(x, "solid", "light"), D = zt(x, "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", D.backgroundColor), m.set("--switch-track-on-label-dark", D.textColor), m.set(
      "--switch-track-on-border-dark",
      de(x, "dark")
    ), Array.from(m.entries()).map(([S, v]) => `${S}: ${v}`).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
      )(
        ($, x) => g($ ?? !1, x ?? "md")
      )
    ),
    l.style(
      B(u)(
        ($) => f($)
      )
    ),
    l.id(b),
    l.role("switch"),
    l.tabindex(
      B(
        a ?? !1,
        d
      )(($, x) => $ ? -1 : x ?? 0)
    ),
    R.checked(t),
    R.disabled(a),
    I.click(w),
    I.keydown(_),
    n != null ? I.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,
      Ht(
        ($) => P(
          pe,
          ({ direction: x }) => 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,
                x
              )((m, { width: M }, D, S) => {
                const v = (() => {
                  switch (D) {
                    case "xs":
                      return 5;
                    case "sm":
                      return 5.5;
                    case "md":
                      return 6;
                    case "lg":
                      return 7;
                    case "xl":
                      return 8;
                  }
                })(), h = S === "rtl" ? `calc((var(--spacing-base) * ${v}) - ${M}px)` : `calc(${M}px - (var(--spacing-base) * ${v}))`;
                return m ? `translateX(${h})` : "translateX(0)";
              })
            )
          )
        )
      )
    )
  );
}, en = (t) => {
  const e = {
    type: "pattern",
    pattern: /[0-9A-Fa-f]/,
    transform: (n) => n.toLowerCase()
  };
  return Gt({
    ...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: b = 1
  } = t, g = () => {
    const m = p.get(b);
    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 S = m.currentTarget.getBoundingClientRect(), v = (m.clientX - S.left) / S.width, h = M - 1 + v, k = g(), T = Math.ceil(h / k) * k, A = f(T);
    s?.(A);
  }, _ = (m) => {
    if (p.get(n ?? !1)) return;
    const M = g(), D = p.get(e) ?? 0;
    let S;
    switch (m.key) {
      case "ArrowRight":
      case "ArrowUp":
        S = f(D + M);
        break;
      case "ArrowLeft":
      case "ArrowDown":
        S = f(D - M);
        break;
      case "Home":
        S = 0;
        break;
      case "End":
        S = p.get(r);
        break;
      default:
        return;
    }
    m.preventDefault(), s?.(S);
  }, $ = p.map(u, (m) => `bc-icon--${m}`), x = ({ 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, (D) => {
          const S = Math.floor(D);
          return S > m ? "100%" : S < m ? "0%" : `${(D - m) * 100}%`;
        })
      ),
      U(
        {
          icon: i,
          size: u,
          color: c,
          tone: "soft"
        },
        l.class("bc-rating-input__icon-full")
      )
    ),
    I.click(
      re((D) => w(D, 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 D = m ?? 0, S = M ?? 0;
          return `${String(D)} / ${String(S)}`;
        })
      ),
      // Keyboard & focus handlers
      I.keydown(_),
      d != null ? I.blur(d) : null,
      jt(r, x)
    )
  });
}, Un = (t) => {
  const { value: e, onChange: s, onBlur: n, after: r, disabled: c, ...a } = t, i = J(e, c, s);
  return rn({
    ...a,
    // Map null -> 0 for display so the control shows as empty when null
    value: p.map(e, (o) => o ?? 0),
    // Pass through numeric changes; clear button will call onChange(null)
    onChange: s,
    onBlur: n,
    after: r != null ? z(i, r) : i
  });
}, 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 ? I.blur(Y(c)) : F,
      a != null ? I.change(Y(a)) : F,
      i != null ? I.input(Y(i)) : F
    )
  });
}, 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 b = n != null ? p.get(n) : void 0;
    return typeof b == "number" ? b : 0;
  }), u = J(e, t.disabled, (d) => {
    a?.(d);
  });
  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 ? I.blur(Y(c)) : F,
        a != null ? I.change(
          Y((d) => {
            a(d);
          })
        ) : F,
        i != null ? I.input(
          Y((d) => {
            i(d);
          })
        ) : F
      )
    },
    // Ensure container grows input naturally
    z()
  );
};
let kt = null;
async function Dt() {
  const t = globalThis;
  return t.Temporal ? t.Temporal : (kt || (kt = import("./index.esm-DPNh6inz.js").then((e) => {
    const s = e.Temporal;
    return t.Temporal || (t.Temporal = s), s;
  })), kt);
}
const an = (t, e) => e ? Bt(Dt, {
  then: t,
  pending: e.pending,
  error: e.error
}) : Bt(Dt, 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 Pt = (t, e) => {
  if (t == null) return null;
  try {
    return t.Duration.from(e);
  } catch {
    return null;
  }
}, Pn = (t) => {
  const { value: e, onChange: s, after: n, disabled: r, onBlur: c } = t, a = () => {
    const u = J(e, r, s);
    return n != null ? z(u, n) : u;
  }, i = t.placeholder != null ? F : l.placeholder("P0DT0H0M0S");
  return an(
    (u) => Gt({
      ...t,
      value: p.map(e, (d) => d?.toString() ?? ""),
      onChange: s ? (d) => s(d === "" ? null : u.Duration.from(d)) : void 0,
      onInput: void 0,
      ...cn(u.Duration.from),
      placeholder: "P0DT0H0M0S",
      after: a()
    }),
    { pending: () => O({
      ...t,
      input: Q.text(
        H(t),
        l.value(p.map(e, (u) => u?.toString() ?? "")),
        l.class("bc-input"),
        i,
        c != null ? I.blur(() => c()) : F,
        s != null ? I.change((u) => {
          const b = u.currentTarget?.value ?? "";
          if (b === "") {
            s(null);
            return;
          }
          const g = globalThis.Temporal, f = Pt(g, b);
          if (f != null) {
            s(f);
            return;
          }
          Dt().then((w) => {
            const _ = Pt(w, b);
            _ != null && s(_);
          }).catch(() => {
          });
        }) : F
      ),
      after: a()
    }) }
  );
}, 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 ? I.blur(j(s)) : F,
      n != null ? I.change(j(n)) : F,
      r != null ? I.input(j(r)) : F
    )
  });
}, 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: b
  } = t, g = p.toSignal(u).map((_) => _ === "aside"), f = (_) => {
    const $ = L(
      r ?? !1,
      () => y.div(
        l.class("bc-group--align-center"),
        l.class(
          g.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
            })
          )
        )
      )
    ), x = 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(
      g,
      () => 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),
            () => $
          ),
          x
        )
      ),
      () => 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()
          ),
          x
        )
      )
    );
  }, 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,
            b ?? !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: b,
    addDisabled: g,
    ...f
  } = t;
  return Wt(
    {
      ...f,
      content: pn({
        controller: s,
        element: n,
        separator: r,
        showMove: c,
        showRemove: a,
        showAdd: i,
        createItem: o,
        addLabel: u,
        controlsLayout: d,
        removeDisabled: b,
        addDisabled: g
      })
    },
    ...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 b of a)
        if (b.detect(d))
          return b.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 b = a.find((f) => f.key === d);
      if (!b)
        throw new Error(`Unknown branch: ${d}`);
      const g = new xt(
        [...e, d],
        (f) => {
          this.change(f);
        },
        this.signal.map(
          (f) => b.detect(f) ? f : b.defaultValue(),
          i
        ),
        r.map(Et([d])),
        {
          disabled: this.disabled,
          validationMode: this.parent.validationMode
        },
        i
      );
      return this.#t.set(d, g), g;
    };
    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(Et([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,
  kn 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,
  Gt 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,
  In 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,
  ke as a5,
  Yt as a6,
  Ie as a7,
  Mt as a8,
  Ce as a9,
  wt as aa,
  _t as ab,
  Me as ac,
  De as ad,
  at as ae,
  lt as af,
  Dt as ag,
  _n as ah,
  wn as ai,
  Zt as b,
  _e as c,
  cn as d,
  Nt 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,
  Dn as q,
  Sn 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
};
