import { jsxs as y, Fragment as Te, jsx as c } from "react/jsx-runtime";
import { $ as ve, l as pt, k as Ce, g as ft, _ as wt } from "./core-Dpfb_THi.js";
import _t, { useRef as K, useState as D, useCallback as k, useEffect as W, useReducer as gt, useMemo as ge, useContext as $e, createContext as Pe, forwardRef as Ie } from "react";
const $t = ({
  visible: e,
  onClose: t,
  title: o,
  items: s,
  showCancelButton: u = !0,
  cancelText: d,
  className: h,
  style: g
}) => {
  const { t: p } = ve();
  return e ? /* @__PURE__ */ y(Te, { children: [
    /* @__PURE__ */ c("div", { className: "nice-actionsheet__overlay", onClick: t }),
    /* @__PURE__ */ y("div", { className: `nice-actionsheet ${h || ""}`, style: g, children: [
      o && /* @__PURE__ */ c("div", { className: "nice-actionsheet__title", children: o }),
      /* @__PURE__ */ c("div", { className: "nice-actionsheet__items", children: s.map((E, r) => /* @__PURE__ */ y(
        "button",
        {
          className: `nice-actionsheet__item ${E.type === "danger" ? "nice-actionsheet__item--danger" : ""}`,
          disabled: E.disabled,
          onClick: () => {
            E.onClick?.(), t();
          },
          children: [
            E.icon && /* @__PURE__ */ c("span", { className: "nice-actionsheet__icon", children: E.icon }),
            E.text
          ]
        },
        r
      )) }),
      u && /* @__PURE__ */ c("button", { className: "nice-actionsheet__cancel", onClick: t, children: d || p("cancel", "Cancel") })
    ] })
  ] }) : null;
}, Pt = ({
  visible: e,
  onClose: t,
  targetRef: o,
  position: s = "bottom",
  title: u,
  showArrow: d = !0,
  width: h,
  children: g,
  className: p,
  style: E,
  displayStyle: r
}) => {
  pt("tooltip", r);
  const b = K(null), [Y, f] = D({ top: 0, left: 0 }), L = k(() => {
    const w = o.current, X = b.current;
    if (!w || !X)
      return;
    const n = w.getBoundingClientRect(), v = X.getBoundingClientRect();
    let a = 0, z = 0;
    const T = 8;
    switch (s) {
      case "top":
        a = n.top - v.height - T, z = n.left + (n.width - v.width) / 2;
        break;
      case "bottom":
        a = n.bottom + T, z = n.left + (n.width - v.width) / 2;
        break;
      case "left":
        a = n.top + (n.height - v.height) / 2, z = n.left - v.width - T;
        break;
      case "right":
        a = n.top + (n.height - v.height) / 2, z = n.right + T;
        break;
    }
    f({ top: a + window.scrollY, left: z + window.scrollX });
  }, [o, s]);
  return W(() => {
    if (e) {
      requestAnimationFrame(L);
      const w = (X) => {
        b.current && !b.current.contains(X.target) && o.current && !o.current.contains(X.target) && t();
      };
      return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
    }
  }, [e, L, t, o]), e ? /* @__PURE__ */ y(
    "div",
    {
      ref: b,
      className: `nice-popover nice-popover--${s} ${p || ""}`,
      style: { ...E, position: "absolute", top: Y.top, left: Y.left, width: h },
      children: [
        d && /* @__PURE__ */ c("div", { className: `nice-popover__arrow nice-popover__arrow--${s}` }),
        u && /* @__PURE__ */ c("div", { className: "nice-popover__title", children: u }),
        /* @__PURE__ */ c("div", { className: "nice-popover__content", children: g })
      ]
    }
  ) : null;
}, Dt = ({
  visible: e,
  message: t,
  container: o,
  showIndicator: s = !0,
  shading: u = !0,
  className: d,
  style: h
}) => {
  const { t: g } = ve();
  if (!e)
    return null;
  const p = !!o?.current, E = /* @__PURE__ */ y("div", { className: `nice-loadpanel ${d || ""}`, style: h, children: [
    u && /* @__PURE__ */ c("div", { className: "nice-loadpanel__shade" }),
    /* @__PURE__ */ y("div", { className: "nice-loadpanel__box", children: [
      s && /* @__PURE__ */ c("div", { className: "nice-spinner nice-spinner--md" }),
      /* @__PURE__ */ c("span", { className: "nice-loadpanel__text", children: t || g("loading", "Loading...") })
    ] })
  ] });
  if (p && o.current) {
    const r = o.current;
    return r.style.position = r.style.position || "relative", E;
  }
  return E;
}, Yt = ({
  direction: e = "row",
  align: t,
  justify: o,
  wrap: s,
  gap: u,
  flex: d,
  children: h,
  className: g,
  style: p
}) => /* @__PURE__ */ c(
  "div",
  {
    className: `nice-box ${g || ""}`,
    style: {
      display: "flex",
      flexDirection: e,
      alignItems: t,
      justifyContent: o,
      flexWrap: s ? "wrap" : void 0,
      gap: u,
      flex: d,
      ...p
    },
    children: h
  }
), Xt = ({
  direction: e = "row",
  items: t,
  gap: o,
  className: s,
  style: u
}) => /* @__PURE__ */ c(
  "div",
  {
    className: `nice-responsivebox ${s || ""}`,
    style: { display: "flex", flexDirection: e, gap: o, ...u },
    children: t.map((d, h) => /* @__PURE__ */ c(
      "div",
      {
        style: { flex: d.ratio ?? 1, flexBasis: d.baseSize, flexShrink: d.shrink ?? 1 },
        children: d.children
      },
      h
    ))
  }
), Ot = ({
  width: e = 200,
  height: t = 200,
  minWidth: o = 50,
  minHeight: s = 50,
  maxWidth: u = 1 / 0,
  maxHeight: d = 1 / 0,
  handles: h = ["right", "bottom", "bottomRight"],
  onResize: g,
  children: p,
  className: E,
  style: r
}) => {
  const [b, Y] = D({ width: e, height: t }), f = K(null), L = (n, v) => {
    v.preventDefault();
    const a = v.clientX, z = v.clientY, T = b.width, B = b.height, _ = (i) => {
      const x = i.clientX - a, S = i.clientY - z;
      let I = T, l = B;
      (n.includes("right") || n === "right") && (I = T + x), (n.includes("bottom") || n === "bottom") && (l = B + S), (n.includes("left") || n === "left") && (I = T - x), (n.includes("top") || n === "top") && (l = B - S), I = Math.max(o, Math.min(u, I)), l = Math.max(s, Math.min(d, l)), Y({ width: I, height: l }), g?.({ width: I, height: l });
    }, P = () => {
      document.removeEventListener("pointermove", _), document.removeEventListener("pointerup", P);
    };
    document.addEventListener("pointermove", _), document.addEventListener("pointerup", P);
  }, w = (n) => {
    switch (n) {
      case "top":
      case "bottom":
        return "ns-resize";
      case "left":
      case "right":
        return "ew-resize";
      case "topLeft":
      case "bottomRight":
        return "nwse-resize";
      case "topRight":
      case "bottomLeft":
        return "nesw-resize";
      default:
        return "default";
    }
  }, X = (n) => {
    const v = { position: "absolute", zIndex: 1 }, a = 8;
    return n === "right" ? {
      ...v,
      top: 0,
      right: -a / 2,
      width: a,
      height: "100%",
      cursor: w(n)
    } : n === "bottom" ? {
      ...v,
      left: 0,
      bottom: -a / 2,
      width: "100%",
      height: a,
      cursor: w(n)
    } : n === "left" ? { ...v, top: 0, left: -a / 2, width: a, height: "100%", cursor: w(n) } : n === "top" ? { ...v, top: -a / 2, left: 0, width: "100%", height: a, cursor: w(n) } : n === "bottomRight" ? {
      ...v,
      bottom: -a / 2,
      right: -a / 2,
      width: a * 2,
      height: a * 2,
      cursor: w(n)
    } : n === "bottomLeft" ? {
      ...v,
      bottom: -a / 2,
      left: -a / 2,
      width: a * 2,
      height: a * 2,
      cursor: w(n)
    } : n === "topRight" ? {
      ...v,
      top: -a / 2,
      right: -a / 2,
      width: a * 2,
      height: a * 2,
      cursor: w(n)
    } : n === "topLeft" ? {
      ...v,
      top: -a / 2,
      left: -a / 2,
      width: a * 2,
      height: a * 2,
      cursor: w(n)
    } : v;
  };
  return /* @__PURE__ */ y(
    "div",
    {
      ref: f,
      className: `nice-resizable ${E || ""}`,
      style: {
        ...r,
        width: b.width,
        height: b.height,
        position: "relative",
        overflow: "hidden"
      },
      children: [
        p,
        h.map((n) => /* @__PURE__ */ c("div", { style: X(n), onPointerDown: (v) => L(n, v) }, n))
      ]
    }
  );
}, qt = ({
  direction: e = "vertical",
  showScrollbar: t = "onInteraction",
  width: o,
  height: s,
  onScroll: u,
  children: d,
  className: h,
  style: g
}) => {
  const p = e === "horizontal" || e === "both" ? "auto" : "hidden", E = e === "vertical" || e === "both" ? "auto" : "hidden";
  return /* @__PURE__ */ c(
    "div",
    {
      className: `nice-scrollview ${t === "never" ? "nice-scrollview--hide-sb" : t === "always" ? "nice-scrollview--show-sb" : ""} ${h || ""}`,
      style: { ...g, width: o, height: s, overflowX: p, overflowY: E },
      onScroll: u,
      children: d
    }
  );
};
function ze(e, t) {
  if (!e)
    return { score: 1, indices: [] };
  const o = e.toLowerCase(), s = t.toLowerCase();
  let u = 0;
  const d = [];
  let h = 0, g = -1;
  for (let p = 0; p < s.length && u < o.length; p++)
    s[p] === o[u] && (d.push(p), g === p - 1 && (h += 3), (p === 0 || /[\s\-_/.]/.test(t[p - 1])) && (h += 5), t[p] === e[u] && (h += 1), h += 1, g = p, u++);
  return u < o.length ? null : (h -= d[0] * 0.1, { score: h, indices: d });
}
function vt(e, t) {
  if (t.length === 0)
    return [e];
  const o = [];
  let s = 0;
  const u = new Set(t);
  for (let d = 0; d < e.length; d++)
    u.has(d) && (s < d && o.push(e.slice(s, d)), o.push(
      _t.createElement(
        "mark",
        { key: `m-${d}`, className: "nice-command-palette__match" },
        e[d]
      )
    ), s = d + 1);
  return s < e.length && o.push(e.slice(s)), o;
}
function yt(e, t) {
  switch (t.type) {
    case "REGISTER": {
      const o = new Map(e.commands);
      return o.set(t.command.id, t.command), { ...e, commands: o };
    }
    case "REGISTER_BATCH": {
      const o = new Map(e.commands);
      for (const s of t.commands)
        o.set(s.id, s);
      return { ...e, commands: o };
    }
    case "UNREGISTER": {
      const o = new Map(e.commands);
      return o.delete(t.id), { ...e, commands: o };
    }
    case "OPEN":
      return { ...e, isOpen: !0, query: "", selectedIndex: 0 };
    case "CLOSE":
      return { ...e, isOpen: !1, query: "", selectedIndex: 0 };
    case "SET_QUERY":
      return { ...e, query: t.query, selectedIndex: 0 };
    case "SET_SELECTED":
      return { ...e, selectedIndex: t.index };
    case "ADD_RECENT": {
      const o = e.recentIds.filter((s) => s !== t.id);
      return {
        ...e,
        recentIds: [t.id, ...o].slice(0, t.maxRecent)
      };
    }
    default:
      return e;
  }
}
const De = Pe(null);
function bt() {
  const e = $e(De);
  if (!e)
    throw new Error("useCommandPalette must be used within NiceCommandPaletteProvider");
  return e;
}
const xt = ({
  children: e,
  commands: t,
  placeholder: o = "Type a command...",
  maxVisible: s = 10,
  maxRecent: u = 5,
  className: d,
  emptyText: h = "No commands found",
  closeOnAction: g = !0,
  onOpen: p,
  onClose: E
}) => {
  const [r, b] = gt(yt, {
    commands: new Map(t?.map((l) => [l.id, l]) ?? []),
    isOpen: !1,
    query: "",
    selectedIndex: 0,
    recentIds: []
  }), Y = K(null), f = K(null), [L, w] = D(!1), X = k((l) => {
    b({ type: "REGISTER", command: l });
  }, []), n = k((l) => {
    b({ type: "UNREGISTER", id: l });
  }, []), v = k((l) => {
    b({ type: "REGISTER_BATCH", commands: l });
  }, []), a = k(() => {
    b({ type: "OPEN" }), p?.();
  }, [p]), z = k(() => {
    b({ type: "CLOSE" }), E?.();
  }, [E]), T = k(() => {
    r.isOpen ? z() : a();
  }, [r.isOpen, z, a]), _ = ge(() => {
    const l = Array.from(r.commands.values()).filter((m) => !m.hidden);
    if (!r.query.trim()) {
      const m = r.recentIds.map((R) => r.commands.get(R)).filter((R) => !!R && !R.hidden), O = l.filter((R) => !r.recentIds.includes(R.id));
      return O.sort((R, Q) => R.label.localeCompare(Q.label)), [...m, ...O].map((R) => ({
        command: R,
        match: null,
        isRecent: r.recentIds.includes(R.id)
      }));
    }
    return l.map((m) => {
      const O = ze(r.query, m.label), R = m.description ? ze(r.query, m.description) : null, Q = m.keywords?.map((M) => ze(r.query, M)).filter(Boolean)[0] ?? null, le = [O, R, Q].filter(Boolean).sort((M, q) => (q?.score ?? 0) - (M?.score ?? 0))[0];
      return { command: m, match: le, isRecent: !1 };
    }).filter((m) => m.match !== null).sort((m, O) => (O.match?.score ?? 0) - (m.match?.score ?? 0));
  }, [r.commands, r.query, r.recentIds]).slice(0, s), P = k(
    async (l) => {
      const C = r.commands.get(l);
      if (!(!C || C.disabled)) {
        w(!0);
        try {
          await C.action(), b({ type: "ADD_RECENT", id: l, maxRecent: u });
        } finally {
          w(!1), g && z();
        }
      }
    },
    [r.commands, u, g, z]
  );
  W(() => {
    const l = (C) => {
      (C.metaKey || C.ctrlKey) && C.key === "k" && (C.preventDefault(), T()), C.key === "Escape" && r.isOpen && (C.preventDefault(), z());
    };
    return document.addEventListener("keydown", l), () => document.removeEventListener("keydown", l);
  }, [T, r.isOpen, z]), W(() => {
    r.isOpen && requestAnimationFrame(() => Y.current?.focus());
  }, [r.isOpen]);
  const i = k(
    (l) => {
      const C = _.length;
      if (C) {
        if (l.key === "ArrowDown")
          l.preventDefault(), b({ type: "SET_SELECTED", index: (r.selectedIndex + 1) % C });
        else if (l.key === "ArrowUp")
          l.preventDefault(), b({ type: "SET_SELECTED", index: (r.selectedIndex - 1 + C) % C });
        else if (l.key === "Enter") {
          l.preventDefault();
          const m = _[r.selectedIndex];
          m && P(m.command.id);
        }
      }
    },
    [_, r.selectedIndex, P]
  );
  W(() => {
    if (!f.current)
      return;
    f.current.children[r.selectedIndex]?.scrollIntoView({ block: "nearest" });
  }, [r.selectedIndex]);
  const x = ge(
    () => ({
      registerCommand: X,
      unregisterCommand: n,
      registerCommands: v,
      open: a,
      close: z,
      toggle: T,
      isOpen: r.isOpen,
      executeCommand: P
    }),
    [
      X,
      n,
      v,
      a,
      z,
      T,
      r.isOpen,
      P
    ]
  ), S = ge(() => {
    const l = /* @__PURE__ */ new Map();
    for (const C of _) {
      const m = C.command.category ?? "General";
      l.has(m) || l.set(m, []), l.get(m).push(C);
    }
    return l;
  }, [_]);
  let I = 0;
  return /* @__PURE__ */ y(De.Provider, { value: x, children: [
    e,
    r.isOpen && /* @__PURE__ */ c("div", { className: `nice-command-palette__overlay ${d ?? ""}`, onClick: z, children: /* @__PURE__ */ y(
      "div",
      {
        className: "nice-command-palette",
        role: "dialog",
        "aria-label": "Command Palette",
        "aria-modal": "true",
        onClick: (l) => l.stopPropagation(),
        children: [
          /* @__PURE__ */ c("div", { className: "nice-command-palette__input-wrapper", children: /* @__PURE__ */ c(
            "input",
            {
              ref: Y,
              className: "nice-command-palette__input",
              type: "text",
              placeholder: o,
              value: r.query,
              onChange: (l) => b({ type: "SET_QUERY", query: l.target.value }),
              onKeyDown: i,
              "aria-label": "Search commands",
              "aria-autocomplete": "list",
              "aria-controls": "nice-command-palette-list",
              "aria-activedescendant": _[r.selectedIndex] ? `nice-cmd-${_[r.selectedIndex].command.id}` : void 0
            }
          ) }),
          /* @__PURE__ */ y(
            "div",
            {
              ref: f,
              id: "nice-command-palette-list",
              className: "nice-command-palette__list",
              role: "listbox",
              children: [
                _.length === 0 && /* @__PURE__ */ c("div", { className: "nice-command-palette__empty", children: h }),
                Array.from(S.entries()).map(([l, C]) => /* @__PURE__ */ y("div", { className: "nice-command-palette__group", children: [
                  /* @__PURE__ */ c("div", { className: "nice-command-palette__category", children: l }),
                  C.map((m) => {
                    const O = I++, R = O === r.selectedIndex;
                    return /* @__PURE__ */ y(
                      "div",
                      {
                        id: `nice-cmd-${m.command.id}`,
                        className: `nice-command-palette__item ${R ? "nice-command-palette__item--selected" : ""} ${m.command.disabled ? "nice-command-palette__item--disabled" : ""}`,
                        role: "option",
                        "aria-selected": R,
                        "aria-disabled": m.command.disabled,
                        onClick: () => !m.command.disabled && P(m.command.id),
                        onMouseEnter: () => b({ type: "SET_SELECTED", index: O }),
                        children: [
                          m.command.icon && /* @__PURE__ */ c("span", { className: "nice-command-palette__icon", children: m.command.icon }),
                          /* @__PURE__ */ y("div", { className: "nice-command-palette__label-group", children: [
                            /* @__PURE__ */ c("span", { className: "nice-command-palette__label", children: m.match && r.query ? vt(m.command.label, m.match.indices) : m.command.label }),
                            m.command.description && /* @__PURE__ */ c("span", { className: "nice-command-palette__description", children: m.command.description })
                          ] }),
                          m.command.shortcut && /* @__PURE__ */ c("kbd", { className: "nice-command-palette__shortcut", children: m.command.shortcut }),
                          m.isRecent && /* @__PURE__ */ c("span", { className: "nice-command-palette__recent-badge", children: "Recent" })
                        ]
                      },
                      m.command.id
                    );
                  })
                ] }, l))
              ]
            }
          ),
          L && /* @__PURE__ */ c("div", { className: "nice-command-palette__executing", children: "Executing..." })
        ]
      }
    ) })
  ] });
};
xt.displayName = "NiceCommandPaletteProvider";
function At(e) {
  const { registerCommands: t, unregisterCommand: o } = bt();
  W(() => (t(e), () => {
    for (const s of e)
      o(s.id);
  }), []);
}
const Nt = Ie(
  ({ blocked: e, message: t, children: o, className: s, style: u, id: d }, h) => {
    const g = Ce(d);
    return /* @__PURE__ */ y(
      "div",
      {
        ref: h,
        id: g,
        className: `nice-block-ui ${s || ""}`,
        style: { position: "relative", ...u },
        children: [
          o,
          e && /* @__PURE__ */ c("div", { className: "nice-block-ui__overlay", "aria-busy": "true", role: "alert", children: t && /* @__PURE__ */ c("div", { className: "nice-block-ui__message", children: t }) })
        ]
      }
    );
  }
);
Nt.displayName = "NiceBlockUI";
const kt = Ie(
  ({
    windows: e,
    children: t,
    onChange: o,
    onClose: s,
    onFocus: u,
    showTaskbar: d = !0,
    size: h = "md",
    className: g,
    style: p,
    id: E,
    ...r
  }, b) => {
    const Y = Ce(E), { t: f } = ve(), [L, w] = D(null), X = K(null), n = e ?? [], v = Math.max(1, ...n.map((i) => i.zIndex ?? 1)), a = k(
      (i, x) => {
        const S = n.map((I) => I.key === i ? { ...I, ...x } : I);
        o?.(S);
      },
      [n, o]
    ), z = k(
      (i) => {
        a(i, { zIndex: v + 1 }), u?.(i);
      },
      [a, v, u]
    ), T = k(
      (i) => {
        s?.(i), o?.(n.filter((x) => x.key !== i));
      },
      [n, o, s]
    ), B = k(
      (i) => {
        const x = n.find((S) => S.key === i);
        x && a(i, { minimized: !x.minimized, maximized: !1 });
      },
      [n, a]
    ), _ = k(
      (i) => {
        const x = n.find((S) => S.key === i);
        x && a(i, { maximized: !x.maximized, minimized: !1 });
      },
      [n, a]
    );
    W(() => {
      if (!L)
        return;
      const i = (S) => {
        const I = n.find((l) => l.key === L.key);
        if (I)
          if (L.mode === "move")
            a(L.key, {
              x: S.clientX - L.offsetX,
              y: S.clientY - L.offsetY
            });
          else {
            const C = X.current?.getBoundingClientRect(), m = C?.left ?? 0, O = C?.top ?? 0;
            a(L.key, {
              width: Math.max(200, S.clientX - m - I.x),
              height: Math.max(100, S.clientY - O - I.y)
            });
          }
      }, x = () => w(null);
      return document.addEventListener("mousemove", i), document.addEventListener("mouseup", x), () => {
        document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", x);
      };
    }, [L, n, a]);
    const P = k(
      (i, x, S) => {
        x.preventDefault();
        const I = n.find((l) => l.key === i);
        I && (z(i), w({
          key: i,
          offsetX: S === "move" ? x.clientX - I.x : 0,
          offsetY: S === "move" ? x.clientY - I.y : 0,
          mode: S
        }));
      },
      [n, z]
    );
    return /* @__PURE__ */ y(
      "div",
      {
        ref: (i) => {
          X.current = i, typeof b == "function" ? b(i) : b && (b.current = i);
        },
        id: Y,
        className: `nice-wm nice-wm--${h} ${g ?? ""}`,
        style: { ...p, position: "relative", overflow: "hidden" },
        ...r,
        children: [
          n.map((i) => {
            if (i.minimized)
              return null;
            const x = i.maximized, S = x ? {
              position: "absolute",
              top: 0,
              left: 0,
              width: "100%",
              height: "100%",
              zIndex: i.zIndex ?? 1
            } : {
              position: "absolute",
              top: i.y,
              left: i.x,
              width: i.width,
              height: i.height,
              zIndex: i.zIndex ?? 1
            };
            return /* @__PURE__ */ y(
              "div",
              {
                className: `nice-wm__window ${x ? "nice-wm__window--maximized" : ""}`,
                style: S,
                onMouseDown: () => z(i.key),
                role: "dialog",
                "aria-label": i.title,
                children: [
                  /* @__PURE__ */ y(
                    "div",
                    {
                      className: "nice-wm__titlebar",
                      onMouseDown: (I) => !x && P(i.key, I, "move"),
                      children: [
                        i.icon && /* @__PURE__ */ c("span", { className: "nice-wm__icon", children: i.icon }),
                        /* @__PURE__ */ c("span", { className: "nice-wm__title", children: i.title }),
                        /* @__PURE__ */ y("div", { className: "nice-wm__controls", children: [
                          (i.minimizable ?? !0) && /* @__PURE__ */ c(
                            "button",
                            {
                              type: "button",
                              className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--min",
                              onClick: () => B(i.key),
                              title: f("wm.minimize", "Minimize"),
                              children: "─"
                            }
                          ),
                          (i.maximizable ?? !0) && /* @__PURE__ */ c(
                            "button",
                            {
                              type: "button",
                              className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--max",
                              onClick: () => _(i.key),
                              title: f("wm.maximize", "Maximize"),
                              children: x ? "❐" : "☐"
                            }
                          ),
                          (i.closable ?? !0) && /* @__PURE__ */ c(
                            "button",
                            {
                              type: "button",
                              className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--close",
                              onClick: () => T(i.key),
                              title: f("wm.close", "Close"),
                              children: "✕"
                            }
                          )
                        ] })
                      ]
                    }
                  ),
                  /* @__PURE__ */ c("div", { className: "nice-wm__body", children: i.content }),
                  (i.resizable ?? !0) && !x && /* @__PURE__ */ c(
                    "div",
                    {
                      className: "nice-wm__resize-handle",
                      onMouseDown: (I) => P(i.key, I, "resize")
                    }
                  )
                ]
              },
              i.key
            );
          }),
          e === void 0 && t,
          d && /* @__PURE__ */ c("div", { className: "nice-wm__taskbar", role: "toolbar", "aria-label": f("wm.taskbar", "Taskbar"), children: n.map((i) => /* @__PURE__ */ y(
            "button",
            {
              type: "button",
              className: `nice-wm__taskbar-btn ${i.minimized ? "nice-wm__taskbar-btn--minimized" : ""}`,
              onClick: () => {
                i.minimized && B(i.key), z(i.key);
              },
              children: [
                i.icon && /* @__PURE__ */ c("span", { className: "nice-wm__taskbar-icon", children: i.icon }),
                /* @__PURE__ */ c("span", { className: "nice-wm__taskbar-label", children: i.title })
              ]
            },
            i.key
          )) })
        ]
      }
    );
  }
);
kt.displayName = "NiceWindowManager";
function Et(e, t) {
  const o = document.querySelector(e);
  if (!o)
    return null;
  const s = o.getBoundingClientRect();
  return {
    top: s.top - t + window.scrollY,
    left: s.left - t + window.scrollX,
    width: s.width + t * 2,
    height: s.height + t * 2
  };
}
function zt(e, t, o, s) {
  const d = { w: window.innerWidth, h: window.innerHeight + window.scrollY }, h = {
    top: {
      top: e.top - o - 12,
      left: e.left + e.width / 2 - t / 2
    },
    bottom: {
      top: e.top + e.height + 12,
      left: e.left + e.width / 2 - t / 2
    },
    left: {
      top: e.top + e.height / 2 - o / 2,
      left: e.left - t - 12
    },
    right: {
      top: e.top + e.height / 2 - o / 2,
      left: e.left + e.width + 12
    }
  };
  if (s && s !== "auto")
    return { ...h[s], actualPlacement: s };
  for (const g of ["bottom", "top", "right", "left"]) {
    const p = h[g];
    if (p.top >= 0 && p.left >= 0 && p.top + o <= d.h && p.left + t <= d.w)
      return { ...p, actualPlacement: g };
  }
  return { ...h.bottom, actualPlacement: "bottom" };
}
const Ye = ({
  steps: e,
  active: t,
  onFinish: o,
  onSkip: s,
  onStepChange: u,
  closeOnEscape: d = !0,
  closeOnOverlayClick: h = !1,
  showProgress: g = !0,
  showSkipButton: p = !0,
  labels: E,
  animationDuration: r = 300,
  overlayOpacity: b = 0.6,
  zIndex: Y = 1e4
}) => {
  const [f, L] = D(0), [w, X] = D(null), [n, v] = D({ w: 340, h: 200 }), [a, z] = D(!0), T = K(null), B = K(-1), _ = e[f], P = f === e.length - 1, i = f === 0, x = E?.next ?? "Next", S = E?.back ?? "Back", I = E?.finish ?? "Finish", l = E?.skip ?? "Skip", C = E?.stepOf ?? "of";
  W(() => {
    if (T.current) {
      const M = T.current.getBoundingClientRect();
      v({ w: M.width, h: M.height });
    }
  }, [f, t]), W(() => {
    if (!t || !_)
      return;
    const M = () => {
      const q = Et(_.target, _.highlightPadding ?? 8);
      X(q);
    };
    if (M(), _.scrollIntoView !== !1) {
      document.querySelector(_.target)?.scrollIntoView({ behavior: "smooth", block: "center" });
      const ae = setTimeout(M, 350);
      return () => clearTimeout(ae);
    }
  }, [t, _, f]), W(() => {
    !t || !_ || B.current !== f && (B.current >= 0 && B.current < e.length && e[B.current]?.onLeave?.(), _.onEnter?.(), B.current = f);
  }, [t, _, f, e]), W(() => {
    if (!t || !_?.advanceOn)
      return;
    const M = document.querySelector(_.target);
    if (!M)
      return;
    const q = () => m();
    return M.addEventListener(_.advanceOn.event, q), () => M.removeEventListener(_.advanceOn.event, q);
  }, [t, _, f]), W(() => {
    if (!t)
      return;
    const M = (q) => {
      q.key === "Escape" && d ? s?.() : q.key === "ArrowRight" ? m() : q.key === "ArrowLeft" && O();
    };
    return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
  }, [t, f, d]), W(() => {
    z(!0);
    const M = setTimeout(() => z(!1), r);
    return () => clearTimeout(M);
  }, [f, r]);
  const m = k(() => {
    if (P)
      _?.onLeave?.(), o?.();
    else {
      const M = f + 1;
      L(M), u?.(M);
    }
  }, [f, P, o, u, _]), O = k(() => {
    if (!i) {
      const M = f - 1;
      L(M), u?.(M);
    }
  }, [f, i, u]), R = ge(() => w ? zt(w, n.w, n.h, _?.placement) : {
    top: window.innerHeight / 2,
    left: window.innerWidth / 2,
    actualPlacement: "bottom"
  }, [w, n, _?.placement]);
  if (!t || !_)
    return null;
  const Q = Math.max(document.documentElement.scrollWidth, window.innerWidth), le = Math.max(document.documentElement.scrollHeight, window.innerHeight);
  return /* @__PURE__ */ y(
    "div",
    {
      className: "nice-tutorial",
      style: { zIndex: Y },
      "aria-modal": "true",
      role: "dialog",
      "aria-label": "Tutorial",
      children: [
        /* @__PURE__ */ y(
          "svg",
          {
            className: "nice-tutorial__overlay",
            style: {
              position: "absolute",
              top: 0,
              left: 0,
              width: Q,
              height: le,
              pointerEvents: "auto"
            },
            onClick: h ? s : void 0,
            children: [
              /* @__PURE__ */ c("defs", { children: /* @__PURE__ */ y("mask", { id: "nice-tutorial-mask", children: [
                /* @__PURE__ */ c("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: "white" }),
                w && /* @__PURE__ */ c(
                  "rect",
                  {
                    x: w.left,
                    y: w.top,
                    width: w.width,
                    height: w.height,
                    rx: "8",
                    fill: "black",
                    className: a ? "nice-tutorial__spotlight--entering" : ""
                  }
                )
              ] }) }),
              /* @__PURE__ */ c(
                "rect",
                {
                  x: "0",
                  y: "0",
                  width: "100%",
                  height: "100%",
                  fill: `rgba(0,0,0,${b})`,
                  mask: "url(#nice-tutorial-mask)"
                }
              )
            ]
          }
        ),
        w && /* @__PURE__ */ c(
          "div",
          {
            className: `nice-tutorial__highlight ${a ? "nice-tutorial__highlight--entering" : ""}`,
            style: {
              position: "absolute",
              top: w.top,
              left: w.left,
              width: w.width,
              height: w.height,
              transition: `all ${r}ms ease`
            }
          }
        ),
        _.disableInteraction && w && /* @__PURE__ */ c(
          "div",
          {
            className: "nice-tutorial__blocker",
            style: {
              position: "absolute",
              top: w.top,
              left: w.left,
              width: w.width,
              height: w.height
            }
          }
        ),
        /* @__PURE__ */ y(
          "div",
          {
            ref: T,
            className: `nice-tutorial__tooltip nice-tutorial__tooltip--${R.actualPlacement} ${a ? "nice-tutorial__tooltip--entering" : ""}`,
            style: {
              position: "absolute",
              top: R.top,
              left: R.left,
              transition: `all ${r}ms ease`,
              maxWidth: 380,
              zIndex: Y + 1
            },
            children: [
              _.showArrow !== !1 && /* @__PURE__ */ c(
                "div",
                {
                  className: `nice-tutorial__arrow nice-tutorial__arrow--${R.actualPlacement}`
                }
              ),
              /* @__PURE__ */ y("div", { className: "nice-tutorial__header", children: [
                /* @__PURE__ */ c("h4", { className: "nice-tutorial__title", children: _.title }),
                p && /* @__PURE__ */ c(
                  "button",
                  {
                    type: "button",
                    className: "nice-tutorial__close",
                    onClick: s,
                    "aria-label": l,
                    children: "✕"
                  }
                )
              ] }),
              /* @__PURE__ */ c(
                "div",
                {
                  className: "nice-tutorial__content",
                  dangerouslySetInnerHTML: { __html: ft(_.content) }
                }
              ),
              /* @__PURE__ */ y("div", { className: "nice-tutorial__footer", children: [
                g && /* @__PURE__ */ y("div", { className: "nice-tutorial__progress", children: [
                  e.map((M, q) => /* @__PURE__ */ c(
                    "span",
                    {
                      className: `nice-tutorial__dot ${q === f ? "nice-tutorial__dot--active" : ""} ${q < f ? "nice-tutorial__dot--done" : ""}`
                    },
                    q
                  )),
                  /* @__PURE__ */ y("span", { className: "nice-tutorial__step-label", children: [
                    f + 1,
                    " ",
                    C,
                    " ",
                    e.length
                  ] })
                ] }),
                /* @__PURE__ */ y("div", { className: "nice-tutorial__actions", children: [
                  p && !P && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-tutorial__btn nice-tutorial__btn--skip",
                      onClick: s,
                      children: l
                    }
                  ),
                  !i && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-tutorial__btn nice-tutorial__btn--back",
                      onClick: O,
                      children: S
                    }
                  ),
                  !_.waitForAction && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-tutorial__btn nice-tutorial__btn--next",
                      onClick: m,
                      children: P ? I : x
                    }
                  )
                ] })
              ] })
            ]
          }
        )
      ]
    }
  );
};
Ye.displayName = "NiceTutorial";
const Xe = Pe({
  startTutorial: () => {
  },
  stopTutorial: () => {
  },
  isActive: !1,
  currentStep: 0,
  nextStep: () => {
  },
  prevStep: () => {
  },
  goToStep: () => {
  }
});
function Bt() {
  return $e(Xe);
}
const Ct = ({ children: e }) => {
  const [t, o] = D([]), [s, u] = D(!1), [d, h] = D(0), g = k((f) => {
    o(f), h(0), u(!0);
  }, []), p = k(() => {
    u(!1), h(0), o([]);
  }, []), E = k(() => {
    h((f) => Math.min(f + 1, t.length - 1));
  }, [t.length]), r = k(() => {
    h((f) => Math.max(f - 1, 0));
  }, []), b = k(
    (f) => {
      h(Math.max(0, Math.min(f, t.length - 1)));
    },
    [t.length]
  ), Y = {
    startTutorial: g,
    stopTutorial: p,
    isActive: s,
    currentStep: d,
    nextStep: E,
    prevStep: r,
    goToStep: b
  };
  return /* @__PURE__ */ y(Xe.Provider, { value: Y, children: [
    e,
    s && t.length > 0 && /* @__PURE__ */ c(
      Ye,
      {
        steps: t,
        active: s,
        onFinish: p,
        onSkip: p,
        onStepChange: h
      }
    )
  ] });
};
Ct.displayName = "NiceTutorialProvider";
function It(e, t, o, s, u) {
  const d = e <= u, h = e + u >= o, g = t <= u, p = t + u >= s;
  return g && d ? "top-left" : g && h ? "top-right" : p && d ? "bottom-left" : p && h ? "bottom-right" : d ? "left" : h ? "right" : g ? "top" : p ? "bottom" : "none";
}
function Mt(e) {
  switch (e) {
    case "left":
      return { left: 0, top: 0, width: "50%", height: "100%" };
    case "right":
      return { left: "50%", top: 0, width: "50%", height: "100%" };
    case "top":
      return { left: 0, top: 0, width: "100%", height: "50%" };
    case "bottom":
      return { left: 0, top: "50%", width: "100%", height: "50%" };
    case "top-left":
      return { left: 0, top: 0, width: "50%", height: "50%" };
    case "top-right":
      return { left: "50%", top: 0, width: "50%", height: "50%" };
    case "bottom-left":
      return { left: 0, top: "50%", width: "50%", height: "50%" };
    case "bottom-right":
      return { left: "50%", top: "50%", width: "50%", height: "50%" };
    default:
      return null;
  }
}
const St = Ie(
  ({
    windowKey: e,
    title: t,
    icon: o,
    children: s,
    footer: u,
    x: d,
    y: h,
    defaultPosition: g,
    width: p = 480,
    height: E = 360,
    minWidth: r = 200,
    minHeight: b = 120,
    maxWidth: Y,
    maxHeight: f,
    zIndex: L = 1,
    closable: w = !0,
    minimizable: X = !0,
    maximizable: n = !0,
    fullscreenable: v = !1,
    pinnable: a = !1,
    resizable: z = !0,
    draggable: T = !0,
    snappable: B = !0,
    snapThreshold: _ = 20,
    minimized: P,
    maximized: i,
    fullscreen: x,
    pinned: S,
    focused: I,
    onClose: l,
    onMinimize: C,
    onMaximize: m,
    onFullscreen: O,
    onPin: R,
    onFocus: Q,
    onMove: le,
    onResize: M,
    onSnap: q,
    onTitleBarDoubleClick: ae,
    size: Oe = "md",
    statusBar: Me,
    titleBarActions: qe,
    className: Ae,
    style: Be,
    id: Se,
    accessMode: We,
    ...Fe
  }, He) => {
    const Ue = Ce(Se), Ke = wt(We, Se), { t: de } = ve(), ye = K(null);
    ye.current == null && (ye.current = `nice-window-${Math.random().toString(36).slice(2, 10)}`);
    const A = e ?? ye.current, Ge = d ?? g?.x ?? 100, Ve = h ?? g?.y ?? 100;
    if (Ke === "hidden")
      return null;
    const [fe, se] = D({ x: Ge, y: Ve }), [we, _e] = D({ width: p, height: E }), [je, Qe] = D(!1), [Ze, Je] = D(!1), [et, tt] = D(!1), [nt, it] = D(!1), [V, be] = D("none"), ot = P ?? je, G = i ?? Ze, H = x ?? et, ue = S ?? nt, xe = I ?? !0, oe = fe.x, ce = fe.y, Z = we.width, J = we.height, ee = K(
      null
    ), U = K(null), $ = K(null), ct = k(() => {
      l?.(A);
    }, [A, l]), st = k(() => {
      Qe(!0), C?.(A);
    }, [A, C]), Ne = k(() => {
      const N = !G;
      Je(N), !N && $.current ? (se({ x: $.current.x, y: $.current.y }), _e({ width: $.current.w, height: $.current.h }), $.current = null) : N && ($.current = { x: oe, y: ce, w: Z, h: J }), be("none"), m?.(A, N);
    }, [A, G, oe, ce, Z, J, m]), ke = k(() => {
      const N = !H;
      tt(N), N ? $.current = { x: oe, y: ce, w: Z, h: J } : $.current && (se({ x: $.current.x, y: $.current.y }), _e({ width: $.current.w, height: $.current.h }), $.current = null), O?.(A, N);
    }, [A, H, oe, ce, Z, J, O]), rt = k(() => {
      const N = !ue;
      it(N), R?.(A, N);
    }, [A, ue, R]), me = k(() => {
      Q?.(A);
    }, [A, Q]), lt = k(() => {
      ae ? ae(A) : n && Ne();
    }, [A, n, Ne, ae]);
    W(() => {
      const N = (te) => {
        if (!ee.current)
          return;
        const j = te.clientX - ee.current.startX + ee.current.origX, he = te.clientY - ee.current.startY + ee.current.origY;
        se({ x: j, y: he }), le?.(A, { x: j, y: he });
      }, F = (te) => {
        if (ee.current) {
          if (B) {
            const j = It(
              te.clientX,
              te.clientY,
              window.innerWidth,
              window.innerHeight,
              _
            );
            j !== "none" && ($.current = { x: fe.x, y: fe.y, w: Z, h: J }, be(j), q?.(A, j));
          }
          ee.current = null;
        }
      };
      return document.addEventListener("mousemove", N), document.addEventListener("mouseup", F), () => {
        document.removeEventListener("mousemove", N), document.removeEventListener("mouseup", F);
      };
    });
    const at = k(
      (N) => {
        !T || G || H || (N.preventDefault(), V !== "none" && ($.current && (se({ x: $.current.x, y: $.current.y }), _e({ width: $.current.w, height: $.current.h })), be("none")), me(), ee.current = { startX: N.clientX, startY: N.clientY, origX: oe, origY: ce });
      },
      [T, G, H, V, oe, ce, me]
    );
    W(() => {
      const N = (te) => {
        if (!U.current)
          return;
        const j = te.clientX - U.current.startX, he = te.clientY - U.current.startY, re = U.current.handle;
        let ne = U.current.origW, ie = U.current.origH;
        if (re.includes("e") && (ne = U.current.origW + j), re.includes("w") && (ne = U.current.origW - j), re.includes("s") && (ie = U.current.origH + he), re.includes("n") && (ie = U.current.origH - he), ne = Math.max(r, Y ? Math.min(Y, ne) : ne), ie = Math.max(b, f ? Math.min(f, ie) : ie), re.includes("w")) {
          const Ee = we.width - ne;
          se((pe) => ({ ...pe, x: pe.x + Ee }));
        }
        if (re.includes("n")) {
          const Ee = we.height - ie;
          se((pe) => ({ ...pe, y: pe.y + Ee }));
        }
        _e({ width: ne, height: ie }), M?.(A, { width: ne, height: ie });
      }, F = () => {
        U.current = null;
      };
      return document.addEventListener("mousemove", N), document.addEventListener("mouseup", F), () => {
        document.removeEventListener("mousemove", N), document.removeEventListener("mouseup", F);
      };
    });
    const dt = k(
      (N, F) => {
        !z || G || H || V !== "none" || (F.preventDefault(), F.stopPropagation(), me(), U.current = { startX: F.clientX, startY: F.clientY, origW: Z, origH: J, handle: N });
      },
      [z, G, H, V, Z, J, me]
    );
    if (W(() => {
      if (!xe)
        return;
      const N = (F) => {
        F.key === "Escape" && H && ke();
      };
      return document.addEventListener("keydown", N), () => document.removeEventListener("keydown", N);
    }, [xe, H, ke]), ot)
      return null;
    const Re = V !== "none" ? Mt(V) : null, Le = G || H, ut = H ? { position: "fixed", top: 0, left: 0, width: "100vw", height: "100vh", zIndex: 999999 } : G ? { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", zIndex: L } : Re ? { position: "absolute", ...Re, zIndex: L } : { position: "absolute", top: ce, left: oe, width: Z, height: J, zIndex: L }, mt = ["n", "e", "s", "w", "ne", "se", "sw", "nw"], ht = {
      n: "ns-resize",
      s: "ns-resize",
      e: "ew-resize",
      w: "ew-resize",
      ne: "nesw-resize",
      sw: "nesw-resize",
      nw: "nwse-resize",
      se: "nwse-resize"
    };
    return /* @__PURE__ */ y(
      "div",
      {
        ref: He,
        id: Ue,
        className: `nice-window nice-window--${Oe} ${xe ? "nice-window--focused" : ""} ${ue ? "nice-window--pinned" : ""} ${Le ? "nice-window--maximized" : ""} ${V !== "none" ? `nice-window--snapped-${V}` : ""} ${Ae ?? ""}`,
        style: { ...ut, ...Be },
        onMouseDown: me,
        role: "dialog",
        "aria-label": t,
        ...Fe,
        children: [
          /* @__PURE__ */ y(
            "div",
            {
              className: "nice-window__titlebar",
              onMouseDown: at,
              onDoubleClick: lt,
              children: [
                o && /* @__PURE__ */ c("span", { className: "nice-window__icon", children: o }),
                /* @__PURE__ */ c("span", { className: "nice-window__title", children: t }),
                /* @__PURE__ */ y("div", { className: "nice-window__actions", children: [
                  qe,
                  a && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: `nice-window__action nice-window__action--pin ${ue ? "nice-window__action--active" : ""}`,
                      onClick: rt,
                      title: de("window.pin", ue ? "Unpin" : "Pin"),
                      children: "📌"
                    }
                  ),
                  X && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-window__action nice-window__action--minimize",
                      onClick: st,
                      title: de("window.minimize", "Minimize"),
                      children: "─"
                    }
                  ),
                  n && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-window__action nice-window__action--maximize",
                      onClick: Ne,
                      title: de("window.maximize", G ? "Restore" : "Maximize"),
                      children: G ? "❐" : "☐"
                    }
                  ),
                  v && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-window__action nice-window__action--fullscreen",
                      onClick: ke,
                      title: de("window.fullscreen", H ? "Exit Full Screen" : "Full Screen"),
                      children: H ? "⇲" : "⇱"
                    }
                  ),
                  w && /* @__PURE__ */ c(
                    "button",
                    {
                      type: "button",
                      className: "nice-window__action nice-window__action--close",
                      onClick: ct,
                      title: de("window.close", "Close"),
                      children: "✕"
                    }
                  )
                ] })
              ]
            }
          ),
          /* @__PURE__ */ c("div", { className: "nice-window__body", children: s }),
          u && /* @__PURE__ */ c("div", { className: "nice-window__footer", children: u }),
          Me && /* @__PURE__ */ c("div", { className: "nice-window__statusbar", children: Me }),
          z && !Le && V === "none" && /* @__PURE__ */ c(Te, { children: mt.map((N) => /* @__PURE__ */ c(
            "div",
            {
              className: `nice-window__resize nice-window__resize--${N}`,
              style: { cursor: ht[N] },
              onMouseDown: (F) => dt(N, F)
            },
            N
          )) })
        ]
      }
    );
  }
);
St.displayName = "NiceWindow";
export {
  $t as N,
  Nt as a,
  Yt as b,
  xt as c,
  Dt as d,
  Pt as e,
  Ot as f,
  Xt as g,
  qt as h,
  Ye as i,
  Ct as j,
  St as k,
  kt as l,
  At as m,
  ze as n,
  vt as o,
  Bt as p,
  bt as u
};
