import { n as e } from "./popover-IztNF45J.js";
import { t } from "./ui.module-DHVTOqZ0.js";
import { i as n, r, t as i } from "./uiClasses-UkaejTdf.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 { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
import { XIcon as p } from "lucide-react";
var m = {
	button: "wLOHwj",
	iconOnly: "lFsM-Y",
	buttonInner: "LPob63",
	buttonIcon: "tsaGtv"
}, h = o(function({ children: o, disabled: s, className: c, icon: p, iconEnd: h, title: g, variant: _, tone: v, appearance: y, type: b = "button", "aria-label": x, ...S }, C) {
	let w = a.count(o) > 0, T = !!p && !w, E = n({
		variant: _,
		tone: v,
		appearance: y,
		fallbackAppearance: v && v !== "neutral" ? "solid" : "outline"
	}), D = T ? x ?? g : x, O = /* @__PURE__ */ d("button", {
		...S,
		ref: C,
		type: b,
		disabled: s,
		"aria-label": D,
		className: l(t.uiElement, t.uiInputControl, m.button, r(E.tone), i(E.appearance), T ? m.iconOnly : "", "textNoWrap", c ?? ""),
		children: /* @__PURE__ */ f("span", {
			className: m.buttonInner,
			children: [
				p && !h && /* @__PURE__ */ d("span", {
					"aria-hidden": "true",
					className: m.buttonIcon,
					children: p
				}),
				w && /* @__PURE__ */ d("span", {
					className: "flexEllipsis",
					children: o
				}),
				p && h && /* @__PURE__ */ d("span", {
					"aria-hidden": "true",
					className: m.buttonIcon,
					children: p
				})
			]
		})
	});
	return g ? /* @__PURE__ */ d(e, {
		placement: "bottom",
		tooltip: !0,
		content: /* @__PURE__ */ d(u, { 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__ */ d(h, {
		icon: /* @__PURE__ */ d(p, {}),
		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-BsvHGWPc.js.map