// ../src/helpers/formatClassString.ts
var formatClassString = (classesArray) => {
  return classesArray.filter((x) => !!x).join(" ");
};

// ../src/components/switch/switch.tsx
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
var Switch = ({
  name = "ds-switch",
  checked,
  showMeta = false,
  metaOn = "P\xE5",
  metaOff = "Av",
  disabled,
  stripLabel,
  forcePx,
  classNames,
  attributes
}) => {
  const componentClassName = "ds-switch";
  const classes = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
  return /* @__PURE__ */ jsxs("div", { className: classes, children: [
    /* @__PURE__ */ jsx(
      "input",
      {
        type: "checkbox",
        id: name,
        name,
        defaultChecked: checked,
        disabled,
        "aria-label": name,
        ...attributes
      }
    ),
    stripLabel ? /* @__PURE__ */ jsx("div", { className: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx(
      SwitchInner,
      {
        ...{
          showMeta,
          metaOn,
          metaOff,
          componentClassName
        }
      }
    ) }) : /* @__PURE__ */ jsx("label", { className: `${componentClassName}__inner`, tabIndex: 0, htmlFor: name, children: /* @__PURE__ */ jsx(
      SwitchInner,
      {
        ...{
          showMeta,
          metaOn,
          metaOff,
          componentClassName
        }
      }
    ) })
  ] });
};
var SwitchInner = ({ showMeta, metaOn, metaOff, componentClassName }) => {
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    showMeta && /* @__PURE__ */ jsxs("div", { className: `${componentClassName}__meta`, children: [
      /* @__PURE__ */ jsx("span", { className: `${componentClassName}__meta-on`, children: metaOn }),
      /* @__PURE__ */ jsx("span", { className: `${componentClassName}__meta-off`, children: metaOff })
    ] }),
    /* @__PURE__ */ jsx("span", { className: `${componentClassName}__box`, children: /* @__PURE__ */ jsx("span", { className: `${componentClassName}__knob` }) })
  ] });
};
export {
  Switch
};
//# sourceMappingURL=switch.js.map
