{"version":3,"sources":["../src/cli/commands/virtual-keys/_shared.ts"],"sourcesContent":["import type { VirtualKeyScope, VirtualKeyScopeType } from \"@/client-sdk/services/virtual-keys/virtual-keys-api.service\";\nimport { resolveControlPlaneUrl } from \"@/cli/utils/governance/resolveEndpoint\";\n\n/**\n * Build the public-facing LangWatch UI URL for a VK detail page. After the\n * multi-scope refactor (PR #3524), VKs live at the org-scoped settings\n * surface (/settings/gateway/virtual-keys/:id) regardless of their scope\n * rows; the per-project gateway pages are gone. Honours\n * `LANGWATCH_UI_ENDPOINT` for split UI/API hosts.\n */\nexport function virtualKeyDetailUrl(vkId: string): string {\n  const uiOverride = process.env.LANGWATCH_UI_ENDPOINT;\n  const base = (uiOverride ?? resolveControlPlaneUrl()).replace(/\\/+$/, \"\");\n  if (!base) return \"\";\n  return `${base}/settings/gateway/virtual-keys/${encodeURIComponent(vkId)}`;\n}\n\nconst SCOPE_TYPES: VirtualKeyScopeType[] = [\"ORGANIZATION\", \"TEAM\", \"PROJECT\"];\n\n/**\n * Parse a single `--scope <TYPE>:<id>` CLI value into a `VirtualKeyScope`.\n * Accepts the canonical ORGANIZATION/TEAM/PROJECT spellings (case-insensitive)\n * plus the friendly ORG alias for `ORGANIZATION`. Throws an Error with a\n * single-sentence message the CLI can print directly so users see what they\n * mistyped without a stack trace.\n */\nexport function parseScopeArg(raw: string): VirtualKeyScope {\n  const trimmed = raw.trim();\n  const colon = trimmed.indexOf(\":\");\n  if (colon < 1 || colon === trimmed.length - 1) {\n    throw new Error(`--scope value \"${raw}\" must be in the form TYPE:id (e.g. ORG:acme, TEAM:platform, PROJECT:demo)`);\n  }\n  const typeRaw = trimmed.slice(0, colon).toUpperCase();\n  const scopeId = trimmed.slice(colon + 1).trim();\n  const scopeType: VirtualKeyScopeType | null =\n    typeRaw === \"ORG\" ? \"ORGANIZATION\" :\n    (SCOPE_TYPES as readonly string[]).includes(typeRaw) ? (typeRaw as VirtualKeyScopeType) :\n    null;\n  if (!scopeType) {\n    throw new Error(`--scope type \"${typeRaw}\" must be one of ORG | ORGANIZATION | TEAM | PROJECT`);\n  }\n  if (!scopeId) {\n    throw new Error(`--scope value \"${raw}\" is missing the id after the colon`);\n  }\n  return { scope_type: scopeType, scope_id: scopeId };\n}\n\n/**\n * Format a scope for display in CLI tables / get output: `ORG:acme`,\n * `TEAM:platform`, etc. Uses the short `ORG` form for brevity.\n */\nexport function formatScope(scope: VirtualKeyScope): string {\n  const prefix = scope.scope_type === \"ORGANIZATION\" ? \"ORG\" : scope.scope_type;\n  return `${prefix}:${scope.scope_id}`;\n}\n"],"mappings":";;;;;AAUO,SAAS,oBAAoB,MAAsB;AACxD,QAAM,aAAa,QAAQ,IAAI;AAC/B,QAAM,QAAQ,kCAAc,uBAAuB,GAAG,QAAQ,QAAQ,EAAE;AACxE,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,GAAG,IAAI,kCAAkC,mBAAmB,IAAI,CAAC;AAC1E;AAEA,IAAM,cAAqC,CAAC,gBAAgB,QAAQ,SAAS;AAStE,SAAS,cAAc,KAA8B;AAC1D,QAAM,UAAU,IAAI,KAAK;AACzB,QAAM,QAAQ,QAAQ,QAAQ,GAAG;AACjC,MAAI,QAAQ,KAAK,UAAU,QAAQ,SAAS,GAAG;AAC7C,UAAM,IAAI,MAAM,kBAAkB,GAAG,4EAA4E;AAAA,EACnH;AACA,QAAM,UAAU,QAAQ,MAAM,GAAG,KAAK,EAAE,YAAY;AACpD,QAAM,UAAU,QAAQ,MAAM,QAAQ,CAAC,EAAE,KAAK;AAC9C,QAAM,YACJ,YAAY,QAAQ,iBACnB,YAAkC,SAAS,OAAO,IAAK,UACxD;AACF,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,iBAAiB,OAAO,sDAAsD;AAAA,EAChG;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kBAAkB,GAAG,qCAAqC;AAAA,EAC5E;AACA,SAAO,EAAE,YAAY,WAAW,UAAU,QAAQ;AACpD;AAMO,SAAS,YAAY,OAAgC;AAC1D,QAAM,SAAS,MAAM,eAAe,iBAAiB,QAAQ,MAAM;AACnE,SAAO,GAAG,MAAM,IAAI,MAAM,QAAQ;AACpC;","names":[]}