{"version":3,"file":"region.mjs","names":[],"sources":["../src/region.ts"],"sourcesContent":["/**\n * OpenAI regional endpoints. `eu.api.openai.com` covers the same paths\n * as the default host (REST + Realtime WS) for projects with EU data\n * residency enabled. Keys are project-scoped, so an EU-project key must\n * be used against the EU host.\n *\n * Reference: https://developers.openai.com/api/docs/guides/your-data\n */\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type OpenAiRegion = \"default\" | \"eu\" | (string & {})\n\nconst DEFAULT_HOST = \"https://api.openai.com/v1\"\n\n/**\n * Resolve the HTTP base URL from a Config. `baseUrl` is the universal\n * escape hatch and wins when set. Otherwise the host is computed from\n * `region`; unknown region strings are passed through verbatim as a\n * `{region}.api.openai.com/v1` host, so newly-introduced regions work\n * without an SDK update.\n *\n * Realtime WS code derives its `wss://` URL by substituting `http→ws`\n * on the resolved host.\n */\nexport const resolveHost = (cfg: {\n  readonly baseUrl?: string\n  readonly region?: OpenAiRegion\n}): string => {\n  if (cfg.baseUrl !== undefined) return cfg.baseUrl\n  if (cfg.region === undefined || cfg.region === \"default\") return DEFAULT_HOST\n  return `https://${cfg.region}.api.openai.com/v1`\n}\n"],"mappings":";AAYA,MAAM,eAAe;;;;;;;;;;;AAYrB,MAAa,eAAe,QAGd;CACZ,IAAI,IAAI,YAAY,KAAA,GAAW,OAAO,IAAI;CAC1C,IAAI,IAAI,WAAW,KAAA,KAAa,IAAI,WAAW,WAAW,OAAO;CACjE,OAAO,WAAW,IAAI,OAAO;AAC/B"}