"use client";
import { jsxs as n, jsx as r } from "react/jsx-runtime";
import { Input as u } from "../shared/input.js";
import { createId as N, classNames as s } from "../../utils/index.js";
import { useState as C } from "react";
import { CiSettings as v } from "../../../../../node_modules/.pnpm/react-icons@5.5.0_react@19.0.0/node_modules/react-icons/ci/index.js";
import { Checkbox as i } from "../shared/checkbox.js";
import { Label as a } from "../shared/label.js";
import { useSettings as x } from "../../hooks/use-settings.js";
const W = ({
  type: m,
  fieldName: c = "link",
  label: d = "Link",
  className: h
}) => {
  const [l, f] = C(!1), [e, g] = x(c, m), t = (o, w) => {
    g({
      ...e,
      [w]: o
    });
  }, p = N();
  return /* @__PURE__ */ n("div", { className: s("mt-4 grid gap-1.5", h), children: [
    d && /* @__PURE__ */ r(a, { children: d }),
    /* @__PURE__ */ n("div", { className: "flex", children: [
      /* @__PURE__ */ r(
        u,
        {
          id: p,
          value: (e == null ? void 0 : e.url) ?? "",
          onChange: (o) => t(o.target.value, "url"),
          type: "url",
          placeholder: "Paste URL or type",
          className: "rounded-r-none "
        }
      ),
      /* @__PURE__ */ r(
        "button",
        {
          onClick: () => f((o) => !o),
          className: "rounded-r-md border border-l-0 border-slate-300 bg-slate-100 px-2 hover:bg-slate-300",
          children: /* @__PURE__ */ r(v, {})
        }
      )
    ] }),
    /* @__PURE__ */ r(
      "div",
      {
        className: s(
          "grid grid-rows-[0fr] overflow-hidden transition-[grid-template-rows] duration-200",
          {
            "grid-rows-[1fr]": l
          }
        ),
        children: /* @__PURE__ */ n("div", { className: s("min-h-0", { "h-auto": l }), children: [
          /* @__PURE__ */ n(a, { className: "mt-3 flex", children: [
            /* @__PURE__ */ r(
              i,
              {
                checked: !!(e != null && e.newWindow),
                onCheckedChange: (o) => t(o, "newWindow"),
                className: "me-1.5"
              }
            ),
            "Open in new window"
          ] }),
          /* @__PURE__ */ n(a, { className: "mt-2 flex", children: [
            /* @__PURE__ */ r(
              i,
              {
                checked: !!(e != null && e.nofollow),
                onCheckedChange: (o) => t(o, "nofollow"),
                className: "me-1.5"
              }
            ),
            "Add nofollow"
          ] })
        ] })
      }
    )
  ] });
};
export {
  W as LinkControl
};
//# sourceMappingURL=link.control.js.map
