import { n as e } from "./popover-xJJqy1v6.js";
import { t } from "./ui.module-BisoTevy.js";
import { n, r, t as i } from "./uiClasses-BNjBunnY.js";
import { Children as a, forwardRef as o, useRef as s, useState as c } from "react";
import { cn as l } from "@ryuzaki13/react-foundation-lib/utils";
import { XIcon as u } from "lucide-react";
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
var m = {
	button: "wLOHwj",
	iconOnly: "lFsM-Y",
	buttonInner: "LPob63",
	buttonIcon: "tsaGtv"
}, h = o(function({ children: o, disabled: s, className: c, icon: u, iconEnd: h, title: g, variant: _, tone: v, appearance: y, type: b = "button", "aria-label": x, ...S }, C) {
	let w = a.count(o) > 0, T = !!u && !w, E = r({
		variant: _,
		tone: v,
		appearance: y,
		fallbackAppearance: v && v !== "neutral" ? "solid" : "outline"
	}), D = T ? x ?? g : x, O = /* @__PURE__ */ f("button", {
		...S,
		ref: C,
		type: b,
		disabled: s,
		"aria-label": D,
		className: l(t.uiElement, t.uiInputControl, m.button, n(E.tone), i(E.appearance), T ? m.iconOnly : "", "textNoWrap", c ?? ""),
		children: /* @__PURE__ */ p("span", {
			className: m.buttonInner,
			children: [
				u && !h && /* @__PURE__ */ f("span", {
					"aria-hidden": "true",
					className: m.buttonIcon,
					children: u
				}),
				w && /* @__PURE__ */ f("span", {
					className: "flexEllipsis",
					children: o
				}),
				u && h && /* @__PURE__ */ f("span", {
					"aria-hidden": "true",
					className: m.buttonIcon,
					children: u
				})
			]
		})
	});
	return g ? /* @__PURE__ */ f(e, {
		placement: "bottom",
		tooltip: !0,
		content: /* @__PURE__ */ f(d, { children: g }),
		children: O
	}) : O;
});
//#endregion
//#region src/button/ButtonRemove.tsx
function g({ onPreRemove: e, onRemove: t, className: n }) {
	let [r, i] = c(!1), a = s(null);
	return /* @__PURE__ */ f(h, {
		icon: /* @__PURE__ */ f(u, {}),
		onClick: (n) => {
			n.preventDefault(), a.current &&= (window.clearTimeout(a.current), null), r ? (t(), i(!1)) : (e?.(), i(!0), a.current = window.setTimeout(() => {
				i(!1);
			}, 1500));
		},
		tone: "error",
		appearance: r ? "solid" : "outline",
		className: n
	});
}
//#endregion
export { h as n, g as t };

//# sourceMappingURL=button-CC0Jdx1j.js.map