import { bZ as u, a0 as n, b9 as h, cU as m, bK as w, bL as y, bd as C, bA as f, bB as d, cV as g, bO as v, bf as p, U as S, V as a, cW as k, P as s, bh as b, bi as o, bj as l, bg as i, bk as V, bl as x, cG as E, bn as P, bo as M, bp as $, co as O } from "./684d2f28.js";
import { useContext as r } from "react";
import { formDataChildren as j, FormDataPropertyView as B } from "./00dac55d.js";
import { focusWithOptions as F, blurMethod as L, clickMethod as N } from "./d6402597.js";
import "react-dom";
const R = [u, {
  label: n("switchComp.open"),
  value: "true",
  description: n("switchComp.openDesc")
}, {
  label: n("switchComp.close"),
  value: "false",
  description: n("switchComp.closeDesc")
}], U = (t) => O`
    .ant-switch-handle::before {
      background-color: ${t.handle};
    }
    button {
      background-image: none;
      background-color: ${t.unchecked};
      &.ant-switch-checked {
        background-color: ${t.checked};
      }
    }
  `, W = h.div`
  min-height: 32px;
  display: flex;
  align-items: center;
  // Can respond to drag & select events when disabled
  ${(t) => t.disabled && `
    cursor: not-allowed;
    >button:disabled {
      pointer-events: none;
    }
  `};
  ${(t) => t.$style && U(t.$style)}
`;
function A(t) {
  return t && t.hasOwnProperty("unChecked") ? {
    label: t.label,
    handle: t.handle,
    unchecked: t.unChecked,
    checked: t.checked
  } : t;
}
let D = function() {
  const t = {
    value: m("value"),
    label: w,
    onEvent: y(R),
    disabled: C,
    style: f(d(g), A),
    labelStyle: d(v.filter((e) => ["accent", "validate"].includes(e.name) === !1)),
    viewRef: p,
    ...j
  };
  return new S(t, (e) => e.label({
    style: e.style,
    labelStyle: e.labelStyle,
    children: /* @__PURE__ */ a(W, {
      disabled: e.disabled,
      $style: e.style,
      children: /* @__PURE__ */ a(k, {
        checked: e.value.value,
        disabled: e.disabled,
        ref: e.viewRef,
        onChange: (c) => {
          e.value.onChange(c), e.onEvent("change"), e.onEvent(c ? "true" : "false");
        }
      })
    })
  })).setPropertyViewFn((e) => /* @__PURE__ */ s(b, {
    children: [/* @__PURE__ */ a(o, {
      name: l.basic,
      children: e.value.propertyView({
        label: n("switchComp.defaultValue")
      })
    }), /* @__PURE__ */ a(B, {
      ...e
    }), ["logic", "both"].includes(r(i).editorModeStatus) && /* @__PURE__ */ s(o, {
      name: l.interaction,
      children: [e.onEvent.getPropertyView(), V(e), x(e)]
    }), ["layout", "both"].includes(r(i).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(r(i).editorModeStatus) && /* @__PURE__ */ s(b, {
      children: [/* @__PURE__ */ a(o, {
        name: l.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ a(o, {
        name: l.labelStyle,
        children: e.labelStyle.getPropertyView()
      })]
    })]
  })).setExposeMethodConfigs(E([F, L, N])).build();
}();
const Z = P(D, [new M("value", n("switchComp.valueDesc")), ...$]);
export {
  Z as SwitchComp
};
