import { D as e, E as t, Lt as n, Nt as r, On as i, Pt as a, Tn as o, Zn as s, _ as c, b as l, et as u, g as d, k as f, mt as p, o as m, qt as h, tr as g, v as _, xt as v, y } from "./runtime-core.esm-bundler-C_RgxGrN.js";
import { c as b, l as x } from "./vue.runtime.esm-bundler-CFaGDlW9.js";
import { T as S, b as C, p as w, q as T, v as E, x as D, y as O } from "./Button-C1y42oVo.js";
import { A as k, b as A } from "./dist-BVQ2eZ4j.js";
import { v as j, y as M } from "./Tooltip-C9kG7ywk.js";
import { r as N, t as P } from "./VisuallyHiddenInput-BGsNpXMC.js";
import { t as F } from "./Label-BLc-IXe0.js";
var [I, L] = S(`SwitchRoot`), R = f({ __name: `SwitchRoot`, props: { defaultValue: { type: null, required: false }, modelValue: { type: null, required: false, default: void 0 }, disabled: { type: Boolean, required: false }, id: { type: String, required: false }, value: { type: String, required: false, default: `on` }, trueValue: { type: null, required: false, default: () => true }, falseValue: { type: null, required: false, default: () => false }, asChild: { type: Boolean, required: false }, as: { type: null, required: false, default: `button` }, name: { type: String, required: false }, required: { type: Boolean, required: false } }, emits: [`update:modelValue`], setup(e2, { emit: t2 }) {
  let n2 = e2, r2 = t2, { disabled: a2 } = o(n2), s2 = A(n2, `modelValue`, r2, { defaultValue: n2.defaultValue ?? n2.falseValue, passive: n2.modelValue === void 0 }), c2 = d(() => s2.value === n2.trueValue);
  function l2() {
    a2.value || (s2.value = c2.value ? n2.falseValue : n2.trueValue);
  }
  let { forwardRef: f2, currentElement: m2 } = M(), g2 = N(m2), S2 = d(() => n2.id && m2.value ? document.querySelector(`[for="${n2.id}"]`)?.innerText : void 0);
  return L({ checked: c2, toggleCheck: l2, disabled: a2 }), (e3, t3) => (p(), _(i(D), u(e3.$attrs, { id: e3.id, ref: i(f2), role: `switch`, type: e3.as === `button` ? `button` : void 0, value: e3.value, "aria-label": e3.$attrs[`aria-label`] || S2.value, "aria-checked": c2.value, "aria-required": e3.required, "data-state": c2.value ? `checked` : `unchecked`, "data-disabled": i(a2) ? `` : void 0, "as-child": e3.asChild, as: e3.as, disabled: i(a2), onClick: l2, onKeydown: b(x(l2, [`prevent`]), [`enter`]) }), { default: h(() => [v(e3.$slots, `default`, { modelValue: i(s2), checked: c2.value }), i(g2) && e3.name ? (p(), _(i(P), { key: 0, type: `checkbox`, name: e3.name, disabled: i(a2), required: e3.required, value: e3.value, checked: c2.value }, null, 8, [`name`, `disabled`, `required`, `value`, `checked`])) : y(`v-if`, true)]), _: 3 }, 16, [`id`, `type`, `value`, `aria-label`, `aria-checked`, `aria-required`, `data-state`, `data-disabled`, `as-child`, `as`, `disabled`, `onKeydown`]));
} }), z = f({ __name: `SwitchThumb`, props: { asChild: { type: Boolean, required: false }, as: { type: null, required: false, default: `span` } }, setup(e2) {
  let t2 = I();
  return M(), (e3, n2) => (p(), _(i(D), { "data-state": i(t2).checked.value ? `checked` : `unchecked`, "data-disabled": i(t2).disabled.value ? `` : void 0, "as-child": e3.asChild, as: e3.as }, { default: h(() => [v(e3.$slots, `default`)]), _: 3 }, 8, [`data-state`, `data-disabled`, `as-child`, `as`]));
} }), B = { slots: { root: `relative flex items-start`, base: [`inline-flex items-center shrink-0 rounded-full border-2 border-transparent focus-visible:outline-2 focus-visible:outline-offset-2 data-[state=unchecked]:bg-accented`, `transition-[background] duration-200`], container: `flex items-center`, thumb: `group pointer-events-none rounded-full bg-default shadow-lg ring-0 transition-transform duration-200 data-[state=unchecked]:translate-x-0 data-[state=unchecked]:rtl:-translate-x-0 flex items-center justify-center`, icon: [`absolute shrink-0 group-data-[state=unchecked]:text-dimmed opacity-0 size-10/12`, `transition-[color,opacity] duration-200`], wrapper: `ms-2`, label: `block font-medium text-default`, description: `text-muted` }, variants: { color: { primary: { base: `data-[state=checked]:bg-primary focus-visible:outline-primary`, icon: `group-data-[state=checked]:text-primary` }, secondary: { base: `data-[state=checked]:bg-secondary focus-visible:outline-secondary`, icon: `group-data-[state=checked]:text-secondary` }, success: { base: `data-[state=checked]:bg-success focus-visible:outline-success`, icon: `group-data-[state=checked]:text-success` }, info: { base: `data-[state=checked]:bg-info focus-visible:outline-info`, icon: `group-data-[state=checked]:text-info` }, warning: { base: `data-[state=checked]:bg-warning focus-visible:outline-warning`, icon: `group-data-[state=checked]:text-warning` }, error: { base: `data-[state=checked]:bg-error focus-visible:outline-error`, icon: `group-data-[state=checked]:text-error` }, neutral: { base: `data-[state=checked]:bg-inverted focus-visible:outline-inverted`, icon: `group-data-[state=checked]:text-highlighted` } }, size: { xs: { base: `w-7`, container: `h-4`, thumb: `size-3 data-[state=checked]:translate-x-3 data-[state=checked]:rtl:-translate-x-3`, wrapper: `text-xs` }, sm: { base: `w-8`, container: `h-4`, thumb: `size-3.5 data-[state=checked]:translate-x-3.5 data-[state=checked]:rtl:-translate-x-3.5`, wrapper: `text-xs` }, md: { base: `w-9`, container: `h-5`, thumb: `size-4 data-[state=checked]:translate-x-4 data-[state=checked]:rtl:-translate-x-4`, wrapper: `text-sm` }, lg: { base: `w-10`, container: `h-5`, thumb: `size-4.5 data-[state=checked]:translate-x-4.5 data-[state=checked]:rtl:-translate-x-4.5`, wrapper: `text-sm` }, xl: { base: `w-11`, container: `h-6`, thumb: `size-5 data-[state=checked]:translate-x-5 data-[state=checked]:rtl:-translate-x-5`, wrapper: `text-base` } }, checked: { true: { icon: `group-data-[state=checked]:opacity-100` } }, unchecked: { true: { icon: `group-data-[state=unchecked]:opacity-100` } }, loading: { true: { icon: `animate-spin` } }, required: { true: { label: `after:content-['*'] after:ms-0.5 after:text-error` } }, disabled: { true: { root: `opacity-75`, base: `cursor-not-allowed`, label: `cursor-not-allowed`, description: `cursor-not-allowed` } } }, defaultVariants: { color: `primary`, size: `md` } }, V = Object.assign({ inheritAttrs: false }, { __name: `Switch`, props: { as: { type: null, required: false }, color: { type: null, required: false }, size: { type: null, required: false }, loading: { type: Boolean, required: false }, loadingIcon: { type: null, required: false }, checkedIcon: { type: null, required: false }, uncheckedIcon: { type: null, required: false }, label: { type: String, required: false }, description: { type: String, required: false }, class: { type: null, required: false }, ui: { type: Object, required: false }, disabled: { type: Boolean, required: false }, id: { type: String, required: false }, name: { type: String, required: false }, required: { type: Boolean, required: false }, value: { type: String, required: false }, defaultValue: { type: null, required: false }, modelValue: { type: null, required: false }, trueValue: { type: null, required: false }, falseValue: { type: null, required: false } }, emits: [`change`, `update:modelValue`], setup(o2, { emit: f2 }) {
  let b2 = o2, x2 = n(), S2 = f2, A2 = T(), M2 = C(`switch`, b2), N2 = j(k(b2, `required`, `value`, `defaultValue`, `modelValue`, `trueValue`, `falseValue`), S2), { id: P2, emitFormChange: I2, emitFormInput: L2, size: V2, color: H, name: U, disabled: W, ariaAttrs: G } = w(b2), K = P2.value ?? a(), q = r(), J = d(() => {
    let { "data-state": e2, ...t2 } = q;
    return t2;
  }), Y = d(() => O({ extend: O(B), ...A2.ui?.switch || {} })({ size: V2.value, color: H.value, required: b2.required, loading: b2.loading, disabled: W.value || b2.loading }));
  function X(e2) {
    S2(`change`, new Event(`change`, { target: { value: e2 } })), I2(), L2();
  }
  return (n2, r2) => (p(), _(i(D), { as: o2.as, "data-slot": `root`, class: s(Y.value.root({ class: [i(M2)?.root, b2.class] })) }, { default: h(() => [c(`div`, { "data-slot": `container`, class: s(Y.value.container({ class: i(M2)?.container })) }, [e(i(R), u({ id: i(K) }, { ...i(N2), ...J.value, ...i(G) }, { name: i(U), disabled: i(W) || o2.loading, "data-slot": `base`, class: Y.value.base({ class: i(M2)?.base }), "onUpdate:modelValue": X }), { default: h(() => [e(i(z), { "data-slot": `thumb`, class: s(Y.value.thumb({ class: i(M2)?.thumb })) }, { default: h(() => [o2.loading ? (p(), _(E, { key: 0, name: o2.loadingIcon || i(A2).ui.icons.loading, "data-slot": `icon`, class: s(Y.value.icon({ class: i(M2)?.icon, checked: true, unchecked: true })) }, null, 8, [`name`, `class`])) : (p(), l(m, { key: 1 }, [o2.checkedIcon ? (p(), _(E, { key: 0, name: o2.checkedIcon, "data-slot": `icon`, class: s(Y.value.icon({ class: i(M2)?.icon, checked: true })) }, null, 8, [`name`, `class`])) : y(``, true), o2.uncheckedIcon ? (p(), _(E, { key: 1, name: o2.uncheckedIcon, "data-slot": `icon`, class: s(Y.value.icon({ class: i(M2)?.icon, unchecked: true })) }, null, 8, [`name`, `class`])) : y(``, true)], 64))]), _: 1 }, 8, [`class`])]), _: 1 }, 16, [`id`, `name`, `disabled`, `class`])], 2), o2.label || x2.label || o2.description || x2.description ? (p(), l(`div`, { key: 0, "data-slot": `wrapper`, class: s(Y.value.wrapper({ class: i(M2)?.wrapper })) }, [o2.label || x2.label ? (p(), _(i(F), { key: 0, for: i(K), "data-slot": `label`, class: s(Y.value.label({ class: i(M2)?.label })) }, { default: h(() => [v(n2.$slots, `label`, { label: o2.label }, () => [t(g(o2.label), 1)])]), _: 3 }, 8, [`for`, `class`])) : y(``, true), o2.description || x2.description ? (p(), l(`p`, { key: 1, "data-slot": `description`, class: s(Y.value.description({ class: i(M2)?.description })) }, [v(n2.$slots, `description`, { description: o2.description }, () => [t(g(o2.description), 1)])], 2)) : y(``, true)], 2)) : y(``, true)]), _: 3 }, 8, [`as`, `class`]));
} });
export {
  V as t
};
