"use client";
import { B as J } from "./badge-Dc99vsfo.js";
import { B as h } from "./banner-BKDBfLHA.js";
import { a as Y } from "./banner-BKDBfLHA.js";
import { B as n } from "./button-Bh96oxRL.js";
import { L as aa, R as ea, b as oa } from "./button-Bh96oxRL.js";
import { D as ta } from "./date-range-picker-CbKEQ9pi.js";
import { C as ia } from "./checkbox-CfFoTNFI.js";
import { C as na } from "./clipboard-text-1d0rHIhb.js";
import { C as pa, a as fa } from "./code-T2wPDiM0.js";
import { C as ca } from "./combobox-vnvi22pn.js";
import { a as N, D as O, c as U, e as A } from "./dialog-C4BIM-74.js";
import { d as Ta, b as ua } from "./dialog-C4BIM-74.js";
import { D as _a } from "./dropdown-CfS4QcSR.js";
import { C as Ca } from "./collapsible-OBNkTO48.js";
import { F as La, a as Ra, K as Ea, f as Sa } from "./field-B8xISAuX.js";
import { b as Na, K as Oa, L as Ua, a as ga, l as Da } from "./label-Cd6nCDWj.js";
import { I as g } from "./input-DCzpefuq.js";
import { i as Ka } from "./input-DCzpefuq.js";
import { I as ka, T as va } from "./input-area-DCaAN9nG.js";
import { I as ya } from "./input-group-BbaVpJnA.js";
import { L as Ba } from "./layer-card-C8j5Hkkj.js";
import { L as za } from "./loader-DHGMYlC6.js";
import { S as ja } from "./skeleton-line-CtpS1u1J.js";
import { M as qa, u as Wa } from "./menubar-Chchzst0.js";
import { M as Ha } from "./meter-Wk7_EhaO.js";
import { P as Qa } from "./pagination-DFHoZwPJ.js";
import { S as Za } from "./select-DtcT1zGm.js";
import { S as ee } from "./surface-BIC6CXiz.js";
import { S as re } from "./switch-DrbaX2iC.js";
import { T as se } from "./tabs-B-Fxc6Zo.js";
import { T as le } from "./table-CH9KC36S.js";
import { T as me } from "./text-BEhqwMfe.js";
import { a as fe, T as de, u as ce } from "./toast-DUYp3EtH.js";
import { T as Te, a as ue } from "./tooltip-D-KwZQDV.js";
import { g as _e, K as Ie, P as Ce } from "./popover-D20xpmdk.js";
import { a as Le, K as Re, S as Ee } from "./sensitive-input-DHDRZRC7.js";
import { b as he, K as Ne, R as Oe, a as Ue } from "./radio-ibVa4Y8a.js";
import { C as De, a as Ve, K as Ke } from "./command-palette-B80cqB7K.js";
import { a as ke, K as ve, L as Pe, l as ye } from "./link-DJq9RWpK.js";
import { B as Be } from "./breadcrumbs-DyKi7BcP.js";
import { E as ze } from "./empty-D03cbzRS.js";
import { G as je, a as $e, c as qe, K as We, b as Xe, g as He } from "./grid-DKajRHh8.js";
import { C as Qe, a as Ye, K as Ze, P as ao, g as eo } from "./cloudflare-logo-Dqd1VD9z.js";
import { D as ro } from "./date-picker-M6uNX5Ca.js";
import { Flow as so } from "./components/flow.js";
import { c as D } from "./cn-Bhsu1vx2.js";
import { s as lo } from "./cn-Bhsu1vx2.js";
import { L as mo, u as po } from "./link-provider-DPBGo-0n.js";
import { jsx as a, jsxs as e } from "react/jsx-runtime";
import { useState as _, useEffect as V, useCallback as m } from "react";
import { XIcon as K, WarningCircleIcon as M, CheckIcon as k, CopyIcon as v } from "@phosphor-icons/react";
import { i as co } from "./vendor-base-ui-Bsg5ebHI.js";
const W = {
  size: {
    sm: {
      classes: "",
      description: "Small dialog for simple delete confirmations"
    },
    base: {
      classes: "",
      description: "Default delete confirmation dialog size"
    }
  }
}, P = {
  size: "base"
};
function y({
  open: s,
  onOpenChange: I,
  resourceType: p,
  resourceName: o,
  onDelete: f,
  isDeleting: t = !1,
  caseSensitive: d = !0,
  deleteButtonText: C,
  size: b = P.size,
  errorMessage: c,
  className: L
}) {
  const [x, T] = _(""), [R, i] = _(!1);
  V(() => {
    s || (T(""), i(!1));
  }, [s]);
  const u = m(
    (r) => d ? r : r.toLowerCase(),
    [d]
  ), l = u(x) === u(o), E = m(async () => {
    !l || t || await f();
  }, [l, t, f]), S = m(async () => {
    await navigator.clipboard.writeText(o), i(!0), setTimeout(() => i(!1), 1500);
  }, [o]);
  return /* @__PURE__ */ a(N, { open: s, onOpenChange: I, children: /* @__PURE__ */ e(O, { size: b, className: D("p-0", L), children: [
    /* @__PURE__ */ e("div", { className: "flex items-center justify-between border-b border-kumo-line px-6 py-4", children: [
      /* @__PURE__ */ e(U, { className: "text-lg font-semibold", children: [
        "Delete ",
        o
      ] }),
      /* @__PURE__ */ a(
        A,
        {
          render: (r) => /* @__PURE__ */ a(
            n,
            {
              ...r,
              variant: "ghost",
              shape: "square",
              size: "sm",
              "aria-label": "Close",
              disabled: t,
              children: /* @__PURE__ */ a(K, { size: 18 })
            }
          )
        }
      )
    ] }),
    /* @__PURE__ */ e("div", { className: "flex flex-col p-6 gap-4", children: [
      /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: [
        c && /* @__PURE__ */ a(h, { icon: /* @__PURE__ */ a(M, {}), variant: "error", children: c }),
        /* @__PURE__ */ e("p", { className: "text-base text-kumo-subtle max-w-prose text-pretty", children: [
          "This action cannot be undone. This will permanently delete the",
          " ",
          /* @__PURE__ */ a("span", { className: "font-medium text-kumo-default", children: o }),
          " ",
          p.toLowerCase(),
          "."
        ] })
      ] }),
      /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: [
        /* @__PURE__ */ a("div", { className: "flex items-center gap-1.5 text-base", children: /* @__PURE__ */ e("span", { children: [
          "Type",
          " ",
          /* @__PURE__ */ e(
            "button",
            {
              className: "font-mono text-sm inline font-semibold bg-kumo-tint hover:bg-kumo-fill rounded-md px-2 py-1 group hover:cursor-pointer",
              onClick: S,
              "aria-label": `Copy ${o} to clipboard`,
              children: [
                o,
                R ? /* @__PURE__ */ a(
                  k,
                  {
                    size: 12,
                    weight: "bold",
                    className: "inline ml-1.5"
                  }
                ) : /* @__PURE__ */ a(
                  v,
                  {
                    size: 12,
                    weight: "bold",
                    className: "inline text-kumo-subtle group-hover:text-kumo-default ml-1.5"
                  }
                )
              ]
            }
          ),
          " ",
          "to confirm:"
        ] }) }),
        /* @__PURE__ */ a(
          g,
          {
            placeholder: o,
            value: x,
            onChange: (r) => T(r.target.value),
            disabled: t,
            autoComplete: "off",
            autoCorrect: "off",
            autoCapitalize: "off",
            spellCheck: !1,
            "aria-label": `Type ${o} to confirm deletion`,
            className: "w-full"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ e("div", { className: "flex justify-end gap-3 border-t border-kumo-line px-6 py-4", children: [
      /* @__PURE__ */ a(
        A,
        {
          render: (r) => /* @__PURE__ */ a(n, { ...r, variant: "secondary", disabled: t, children: "Cancel" })
        }
      ),
      /* @__PURE__ */ a(
        n,
        {
          variant: "destructive",
          onClick: E,
          disabled: !l || t,
          loading: t,
          children: C || `Delete ${p}`
        }
      )
    ] })
  ] }) });
}
y.displayName = "DeleteResource";
export {
  J as Badge,
  h as Banner,
  Y as BannerVariant,
  Be as Breadcrumbs,
  n as Button,
  ia as Checkbox,
  na as ClipboardText,
  Qe as CloudflareLogo,
  pa as Code,
  fa as CodeBlock,
  Ca as Collapsible,
  ca as Combobox,
  De as CommandPalette,
  ro as DatePicker,
  ta as DateRangePicker,
  y as DeleteResource,
  O as Dialog,
  A as DialogClose,
  Ta as DialogDescription,
  N as DialogRoot,
  U as DialogTitle,
  ua as DialogTrigger,
  _a as DropdownMenu,
  ze as Empty,
  La as Field,
  so as Flow,
  je as Grid,
  $e as GridItem,
  g as Input,
  ka as InputArea,
  ya as InputGroup,
  Ye as KUMO_CLOUDFLARE_LOGO_DEFAULT_VARIANTS,
  Ze as KUMO_CLOUDFLARE_LOGO_VARIANTS,
  Ve as KUMO_COMMAND_PALETTE_DEFAULT_VARIANTS,
  Ke as KUMO_COMMAND_PALETTE_VARIANTS,
  P as KUMO_DELETE_RESOURCE_DEFAULT_VARIANTS,
  W as KUMO_DELETE_RESOURCE_VARIANTS,
  Ra as KUMO_FIELD_DEFAULT_VARIANTS,
  Ea as KUMO_FIELD_VARIANTS,
  qe as KUMO_GRID_DEFAULT_VARIANTS,
  We as KUMO_GRID_VARIANTS,
  Na as KUMO_LABEL_DEFAULT_VARIANTS,
  Oa as KUMO_LABEL_VARIANTS,
  ke as KUMO_LINK_DEFAULT_VARIANTS,
  ve as KUMO_LINK_VARIANTS,
  _e as KUMO_POPOVER_DEFAULT_VARIANTS,
  Ie as KUMO_POPOVER_VARIANTS,
  he as KUMO_RADIO_DEFAULT_VARIANTS,
  Ne as KUMO_RADIO_VARIANTS,
  Le as KUMO_SENSITIVE_INPUT_DEFAULT_VARIANTS,
  Re as KUMO_SENSITIVE_INPUT_VARIANTS,
  Ua as Label,
  Ba as LayerCard,
  Pe as Link,
  aa as LinkButton,
  mo as LinkProvider,
  za as Loader,
  qa as MenuBar,
  Ha as Meter,
  Qa as Pagination,
  Ce as Popover,
  ao as PoweredByCloudflare,
  Oe as Radio,
  Ue as RadioGroup,
  ea as RefreshButton,
  Za as Select,
  Ee as SensitiveInput,
  ja as SkeletonLine,
  ee as Surface,
  re as Switch,
  le as Table,
  se as Tabs,
  me as Text,
  va as Textarea,
  co as Toast,
  fe as ToastProvider,
  de as Toasty,
  Te as Tooltip,
  ue as TooltipProvider,
  oa as buttonVariants,
  D as cn,
  Sa as fieldVariants,
  eo as generateCloudflareLogoSvg,
  Xe as gridItemVariants,
  He as gridVariants,
  Ka as inputVariants,
  ga as labelContentVariants,
  Da as labelVariants,
  ye as linkVariants,
  lo as safeRandomId,
  ce as useKumoToastManager,
  po as useLinkComponent,
  Wa as useMenuNavigation
};
//# sourceMappingURL=index.js.map
