import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger
} from "/build/_shared/chunk-B7SHUSBW.js";
import {
  require_lodash
} from "/build/_shared/chunk-O67VWZBP.js";
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow
} from "/build/_shared/chunk-P3C75TI5.js";
import {
  Clipboard,
  ClipboardCheck,
  Eye,
  RefreshCcw
} from "/build/_shared/chunk-EJE2TVVM.js";
import {
  useCopyToClipboard,
  useFetcherWithReset
} from "/build/_shared/chunk-B7TG3BDD.js";
import {
  require_jsx_dev_runtime
} from "/build/_shared/chunk-ED7KKCRB.js";
import {
  Routes
} from "/build/_shared/chunk-N27UEDHN.js";
import {
  createHotContext,
  init_remix_hmr
} from "/build/_shared/chunk-G7KTOMTD.js";
import {
  __toESM
} from "/build/_shared/chunk-PNG5AS42.js";

// app/utils/sorters.ts
init_remix_hmr();
var import_lodash = __toESM(require_lodash(), 1);
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/utils/sorters.ts"
  );
  import.meta.hot.lastModified = "1710795853621.6653";
}
var priority = ["Development", "Production"];
var sortApiKeys = (apiKeys) => {
  return import_lodash.default.sortBy(apiKeys, [
    (apiKey) => {
      const index = priority.indexOf(apiKey.environment.name);
      return index === -1 ? priority.length : index;
    },
    "name"
  ]);
};

// app/components/dialogs/ApiKeys/ApiKeysTable.tsx
init_remix_hmr();

// app/components/dialogs/ApiKeys/ApiKeyRow.tsx
init_remix_hmr();

// app/components/dialogs/ApiKeys/CopyApiKey.tsx
init_remix_hmr();
var import_jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/components/dialogs/ApiKeys/CopyApiKey.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/components/dialogs/ApiKeys/CopyApiKey.tsx"
  );
  import.meta.hot.lastModified = "1711548645603.631";
}
var CopyApiKey = ({
  apiKey
}) => {
  _s();
  const [copied, copyToClipboard] = useCopyToClipboard();
  const handleClick = () => copyToClipboard(apiKey);
  const isCopied = copied.value === apiKey;
  const Icon = isCopied ? ClipboardCheck : Clipboard;
  return /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Tooltip, { children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(Icon, { size: 20, className: "cursor-pointer hover:scale-110", onClick: handleClick }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/CopyApiKey.tsx",
      lineNumber: 36,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/CopyApiKey.tsx",
      lineNumber: 35,
      columnNumber: 9
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)(TooltipContent, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("p", { children: isCopied ? "Copied!" : "Copy API Key" }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/CopyApiKey.tsx",
      lineNumber: 39,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/CopyApiKey.tsx",
      lineNumber: 38,
      columnNumber: 9
    }, this)
  ] }, void 0, true, {
    fileName: "app/components/dialogs/ApiKeys/CopyApiKey.tsx",
    lineNumber: 34,
    columnNumber: 7
  }, this) }, void 0, false, {
    fileName: "app/components/dialogs/ApiKeys/CopyApiKey.tsx",
    lineNumber: 33,
    columnNumber: 10
  }, this);
};
_s(CopyApiKey, "xe37LXpC6NbqLMDO4XOsBHzFJ3s=", false, function() {
  return [useCopyToClipboard];
});
_c = CopyApiKey;
var _c;
$RefreshReg$(_c, "CopyApiKey");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/components/dialogs/ApiKeys/RevealApiKey.tsx
init_remix_hmr();
var import_jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/components/dialogs/ApiKeys/RevealApiKey.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/components/dialogs/ApiKeys/RevealApiKey.tsx"
  );
  import.meta.hot.lastModified = "1711234838348.2644";
}
var RevealApiKey = ({
  onClick
}) => {
  return /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(Tooltip, { children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(Eye, { size: 20, className: "cursor-pointer hover:scale-110", onClick }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RevealApiKey.tsx",
      lineNumber: 29,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RevealApiKey.tsx",
      lineNumber: 28,
      columnNumber: 9
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)(TooltipContent, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime2.jsxDEV)("p", { children: "You can only reveal once." }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RevealApiKey.tsx",
      lineNumber: 32,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RevealApiKey.tsx",
      lineNumber: 31,
      columnNumber: 9
    }, this)
  ] }, void 0, true, {
    fileName: "app/components/dialogs/ApiKeys/RevealApiKey.tsx",
    lineNumber: 27,
    columnNumber: 7
  }, this) }, void 0, false, {
    fileName: "app/components/dialogs/ApiKeys/RevealApiKey.tsx",
    lineNumber: 26,
    columnNumber: 10
  }, this);
};
_c2 = RevealApiKey;
var _c2;
$RefreshReg$(_c2, "RevealApiKey");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/components/dialogs/ApiKeys/RotateApiKey.tsx
init_remix_hmr();
var import_jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/components/dialogs/ApiKeys/RotateApiKey.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/components/dialogs/ApiKeys/RotateApiKey.tsx"
  );
  import.meta.hot.lastModified = "1711234838348.5342";
}
var RotateApiKey = ({
  handleRotate
}) => {
  return /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(Tooltip, { children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(RefreshCcw, { size: 20, className: "cursor-pointer hover:scale-110", onClick: handleRotate }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RotateApiKey.tsx",
      lineNumber: 29,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RotateApiKey.tsx",
      lineNumber: 28,
      columnNumber: 9
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)(TooltipContent, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime3.jsxDEV)("p", { children: "Rotate" }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RotateApiKey.tsx",
      lineNumber: 32,
      columnNumber: 11
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/RotateApiKey.tsx",
      lineNumber: 31,
      columnNumber: 9
    }, this)
  ] }, void 0, true, {
    fileName: "app/components/dialogs/ApiKeys/RotateApiKey.tsx",
    lineNumber: 27,
    columnNumber: 7
  }, this) }, void 0, false, {
    fileName: "app/components/dialogs/ApiKeys/RotateApiKey.tsx",
    lineNumber: 26,
    columnNumber: 10
  }, this);
};
_c3 = RotateApiKey;
var _c3;
$RefreshReg$(_c3, "RotateApiKey");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/components/dialogs/ApiKeys/ApiKeyRow.tsx
var import_jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/components/dialogs/ApiKeys/ApiKeyRow.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
var _s2 = $RefreshSig$();
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/components/dialogs/ApiKeys/ApiKeyRow.tsx"
  );
  import.meta.hot.lastModified = "1711549148798.228";
}
var ApiKeyRow = ({
  apiKey,
  projectId
}) => {
  _s2();
  const revealFetcher = useFetcherWithReset();
  const rotateFetcher = useFetcherWithReset();
  const apiKeyToShow = rotateFetcher.data?.key ? void 0 : revealFetcher.data?.key;
  const handleReveal = () => {
    revealFetcher.submit(null, {
      method: "POST",
      action: Routes.actions.apiKeys.reveal({
        projectId,
        apiKeyId: apiKey.id
      })
    });
    rotateFetcher.reset();
  };
  const handleRotate = () => {
    rotateFetcher.submit(null, {
      method: "POST",
      action: Routes.actions.apiKeys.rotate({
        projectId,
        apiKeyId: apiKey.id
      })
    });
    revealFetcher.reset();
  };
  return /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(TableRow, { children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(TableCell, { className: "font-medium", children: apiKey.environment.name }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
      lineNumber: 57,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("div", { className: "min-w-80", children: apiKeyToShow || apiKey.key }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
      lineNumber: 59,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
      lineNumber: 58,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("div", { className: "flex w-14 justify-between gap-1", children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)("div", { children: apiKeyToShow ? /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(CopyApiKey, { apiKey: apiKeyToShow }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
        lineNumber: 64,
        columnNumber: 29
      }, this) : !apiKey.viewed && /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(RevealApiKey, { onClick: handleReveal }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
        lineNumber: 64,
        columnNumber: 86
      }, this) }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
        lineNumber: 63,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime4.jsxDEV)(RotateApiKey, { handleRotate }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
        lineNumber: 66,
        columnNumber: 11
      }, this)
    ] }, void 0, true, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
      lineNumber: 62,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
      lineNumber: 61,
      columnNumber: 7
    }, this)
  ] }, apiKey.envId, true, {
    fileName: "app/components/dialogs/ApiKeys/ApiKeyRow.tsx",
    lineNumber: 56,
    columnNumber: 10
  }, this);
};
_s2(ApiKeyRow, "WqOge+LmqRZz8ETSVhsWqp0vKsU=", false, function() {
  return [useFetcherWithReset, useFetcherWithReset];
});
_c4 = ApiKeyRow;
var _c4;
$RefreshReg$(_c4, "ApiKeyRow");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

// app/components/dialogs/ApiKeys/ApiKeysTable.tsx
var import_jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
} else {
  prevRefreshReg = window.$RefreshReg$;
  prevRefreshSig = window.$RefreshSig$;
  window.$RefreshReg$ = (type, id) => {
    window.$RefreshRuntime$.register(type, '"app/components/dialogs/ApiKeys/ApiKeysTable.tsx"' + id);
  };
  window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
}
var prevRefreshReg;
var prevRefreshSig;
if (import.meta) {
  import.meta.hot = createHotContext(
    //@ts-expect-error
    "app/components/dialogs/ApiKeys/ApiKeysTable.tsx"
  );
  import.meta.hot.lastModified = "1713199469911.7397";
}
var ApiKeysTable = ({
  sortedEnvironments,
  projectId
}) => {
  return /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(Table, { children: [
    /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(TableHeader, { children: /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(TableRow, { children: [
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(TableHead, { children: "Environment" }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
        lineNumber: 30,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(TableHead, { children: "API Key" }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
        lineNumber: 31,
        columnNumber: 11
      }, this),
      /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(TableHead, { children: "Actions" }, void 0, false, {
        fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
        lineNumber: 32,
        columnNumber: 11
      }, this)
    ] }, void 0, true, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
      lineNumber: 29,
      columnNumber: 9
    }, this) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
      lineNumber: 28,
      columnNumber: 7
    }, this),
    /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(TableBody, { children: sortedEnvironments.map((apiKey) => /* @__PURE__ */ (0, import_jsx_dev_runtime5.jsxDEV)(ApiKeyRow, { apiKey, projectId }, apiKey.id, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
      lineNumber: 36,
      columnNumber: 43
    }, this)) }, void 0, false, {
      fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
      lineNumber: 35,
      columnNumber: 7
    }, this)
  ] }, void 0, true, {
    fileName: "app/components/dialogs/ApiKeys/ApiKeysTable.tsx",
    lineNumber: 27,
    columnNumber: 10
  }, this);
};
_c5 = ApiKeysTable;
var _c5;
$RefreshReg$(_c5, "ApiKeysTable");
window.$RefreshReg$ = prevRefreshReg;
window.$RefreshSig$ = prevRefreshSig;

export {
  ApiKeysTable,
  sortApiKeys
};
//# sourceMappingURL=/build/_shared/chunk-FXDK75EI.js.map
