{"version":3,"sources":["../../src/constants.ts","../../src/connection.ts","../../src/platform/browser.ts","../../src/platform/env.ts","../../src/logger.ts","../../package.json","../../src/version.ts","../../src/clientHeader.ts","../../src/schemas.ts","../../src/api-utils.ts"],"sourcesContent":["export enum Region {\n  // Americas\n  AWS_US_EAST_1 = \"aws-us-east-1\",\n  AWS_US_EAST_2 = \"aws-us-east-2\",\n  AWS_US_WEST_2 = \"aws-us-west-2\",\n\n  // EMEA\n  AWS_EU_WEST_1 = \"aws-eu-west-1\",\n\n  // APAC\n  AWS_AP_SOUTH_1 = \"aws-ap-south-1\",\n}\n\nexport enum Runtime {\n  TINY = \"tiny\",\n  SMALL = \"small\",\n  MEDIUM = \"medium\",\n  LARGE = \"large\",\n  X_LARGE = \"x-large\",\n  XX_LARGE = \"2x-large\",\n  XXXX_LARGE = \"4x-large\",\n\n  MEDIUM_HIMEM = \"medium-himem\",\n  LARGE_HIMEM = \"large-himem\",\n  X_LARGE_HIMEM = \"x-large-himem\",\n  XX_LARGE_HIMEM = \"2x-large-himem\",\n  XXXX_LARGE_HIMEM = \"4x-large-himem\",\n\n  TINY_A10_GPU = \"tiny-a10-gpu\",\n  SMALL_A10_GPU = \"small-a10-gpu\",\n  MEDIUM_A10_GPU = \"medium-a10-gpu\",\n}\n\nexport enum ResultsFormat {\n  JSON = \"json\",\n  ARROW = \"arrow\",\n}\n\nexport enum DataCompression {\n  NONE = \"none\",\n  GZIP = \"gzip\",\n  BROTLI = \"brotli\",\n}\n\nexport enum GeometryRepresentation {\n  WKT = \"wkt\",\n  WKB = \"wkb\",\n  EWKT = \"ewkt\",\n  EWKB = \"ewkb\",\n  GEOJSON = \"geojson\",\n}\n\nexport enum SessionType {\n  SINGLE = \"single\",\n  MULTI = \"multi\",\n}\n\nexport enum SessionStatus {\n  PENDING = \"PENDING\",\n  PREPARING = \"PREPARING\",\n  PREPARE_FAILED = \"PREPARE_FAILED\",\n  REQUESTED = \"REQUESTED\",\n  DEPLOYING = \"DEPLOYING\",\n  DEPLOY_FAILED = \"DEPLOY_FAILED\",\n  DEPLOYED = \"DEPLOYED\",\n  INITIALIZING = \"INITIALIZING\",\n  INIT_FAILED = \"INIT_FAILED\",\n  READY = \"READY\",\n  DESTROY_REQUESTED = \"DESTROY_REQUESTED\",\n  DESTROYING = \"DESTROYING\",\n  DESTROY_FAILED = \"DESTROY_FAILED\",\n  DESTROYED = \"DESTROYED\",\n}\n","import * as uuid from \"uuid\";\nimport { decode as decodeCbor } from \"cbor-x\";\nimport { Table, TypeMap } from \"apache-arrow\";\nimport z from \"zod\";\nimport { platform } from \"@platform\";\nimport logger, { sessionContextLogger } from \"./logger\";\nimport { getEnv } from \"./platform/env\";\nimport { OpenSocket, SocketApiSubset } from \"./platform/types\";\nimport { CLIENT_HEADER_NAME, clientHeaderValue } from \"./clientHeader\";\nimport { DataCompression } from \"./constants\";\nimport {\n  CancelExecutionEvent,\n  ConnectionOptions,\n  ConnectionOptionsNormalized,\n  ConnectionOptionsSchemaNormalized,\n  ErrorEventSchema,\n  EventWithExecutionIdSchema,\n  ExecuteSQLEvent,\n  ExecutionResultEventSchema,\n  ReadySessionResponseSchema,\n  RetrieveResultsEvent,\n  SessionResponseSchema,\n  StateUpdatedEventSchema,\n} from \"./schemas\";\nimport {\n  asyncOperationWithRetry,\n  backoffRetry,\n  combineAbortSignals,\n  decodeResults,\n  isSessionInFinalState,\n  NUM_RESLIENCY_RETRIES,\n  parseResponse,\n  shouldRetryForResiliency,\n  toWsUrl,\n} from \"./api-utils\";\n\ntype ConnectionTestHarness = {\n  fetch: typeof fetch;\n  openSocket?: OpenSocket;\n  protocolVersion?: string | undefined;\n};\n\nconst DEFAULT_API_URL = \"https://api.cloud.wherobots.com\";\nconst PROTOCOL_VERSION = \"1.0.0\";\nconst API_REQUEST_TIMEOUT = 10e3;\n\ntype ExecuteOptions = {\n  signal?: AbortSignal;\n};\n\n// Normalize a WebSocket message payload to a Uint8Array across platforms:\n// Node `ws` delivers a Buffer or Buffer[]; a browser native socket with\n// binaryType=\"arraybuffer\" delivers an ArrayBuffer (Blob is handled defensively).\nconst toBytes = async (data: unknown): Promise<Uint8Array> => {\n  if (data instanceof Uint8Array) {\n    return data;\n  }\n  if (data instanceof ArrayBuffer) {\n    return new Uint8Array(data);\n  }\n  if (Array.isArray(data)) {\n    const total = data.reduce((sum, chunk) => sum + chunk.length, 0);\n    const merged = new Uint8Array(total);\n    let offset = 0;\n    for (const chunk of data) {\n      merged.set(chunk, offset);\n      offset += chunk.length;\n    }\n    return merged;\n  }\n  if (typeof Blob !== \"undefined\" && data instanceof Blob) {\n    return new Uint8Array(await data.arrayBuffer());\n  }\n  throw new Error(\"Unsupported WebSocket message payload\");\n};\n\nexport class Connection {\n  public static async connect(\n    options: ConnectionOptions,\n    testHarness?: ConnectionTestHarness,\n  ) {\n    const connection = new Connection(options, testHarness);\n    logger.info(\n      \"Initializing SQL session. Please wait, this process may take a few moments...\",\n    );\n    await connection.establishSession();\n    return connection;\n  }\n\n  public static async connectDirect(wsUrl: string, options: ConnectionOptions) {\n    const connection = new Connection(options);\n    await connection.connectToWebSocket(wsUrl);\n    return connection;\n  }\n\n  private options: ConnectionOptionsNormalized;\n  private fetch: typeof fetch;\n  private fetchOptions: RequestInit;\n  private apiUrl: string;\n  private compression: DataCompression;\n  private openSocket: OpenSocket;\n  private ws: SocketApiSubset | null = null;\n  private protocolVersion: string;\n  private wsListeners: {\n    name: keyof WebSocketEventMap;\n    // for purposes of tracking and automatically cleaning up listeners,\n    // we don't care about the event type argument to the listener\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    listener: (e: any) => void | never;\n  }[] = [];\n  private sessionAbortController = new AbortController();\n\n  constructor(options: ConnectionOptions, testHarness?: ConnectionTestHarness) {\n    // Apply the WHEROBOTS_API_KEY env fallback (Node only) only when the caller\n    // supplied neither an explicit apiKey nor a token, so passing a token never\n    // collides with an ambient API key.\n    const merged: ConnectionOptions = { ...options };\n    if (!merged.apiKey && !merged.token) {\n      const envApiKey = getEnv(\"WHEROBOTS_API_KEY\");\n      if (envApiKey) {\n        merged.apiKey = envApiKey;\n      }\n    }\n    this.options = ConnectionOptionsSchemaNormalized.parse(merged);\n\n    this.apiUrl =\n      this.options.apiUrl || getEnv(\"WHEROBOTS_API_URL\") || DEFAULT_API_URL;\n    this.compression =\n      this.options.dataCompression ?? platform.defaultCompression;\n\n    const headers: Record<string, string> = {\n      \"Content-Type\": \"application/json\",\n      \"Cache-Control\": \"no-store\",\n      // Identifies the SDK on both platforms; a custom header is used because\n      // browsers drop a JS-set User-Agent. The richer User-Agent below is\n      // added only where the runtime allows it (Node).\n      [CLIENT_HEADER_NAME]: clientHeaderValue(this.options.clientChain),\n    };\n    if (this.options.token) {\n      headers[\"Authorization\"] = `Bearer ${this.options.token}`;\n    } else if (this.options.apiKey) {\n      headers[\"X-API-Key\"] = this.options.apiKey;\n    }\n    const userAgent = platform.userAgent();\n    if (userAgent) {\n      headers[\"User-Agent\"] = userAgent;\n    }\n    this.fetchOptions = {\n      headers,\n      signal: this.sessionAbortController.signal,\n      // the types we're using don't recognize the `cache` option\n      // even though it is a valid option for the fetch API\n      // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n      // @ts-ignore\n      cache: \"no-store\",\n    };\n    // The global fetch must be invoked with `this` bound to the global object\n    // (the browser throws \"Illegal invocation\" otherwise); a harness-supplied\n    // fetch is used as-is.\n    this.fetch = testHarness?.fetch ?? fetch.bind(globalThis);\n    this.openSocket = testHarness?.openSocket || platform.openSocket;\n    this.protocolVersion = testHarness?.protocolVersion || PROTOCOL_VERSION;\n    const { apiKey, token, ...optionsToLog } = this.options;\n    logger.child(optionsToLog).debug(\"Creating connection\");\n  }\n\n  private async establishSession() {\n    // Only send `region` when set; an omitted region lets the API apply the\n    // organization's configured default. `runtimeId` is likewise dropped from\n    // the body below when undefined (JSON.stringify omits undefined values).\n    const sessionParams = new URLSearchParams();\n    if (this.options.region) {\n      sessionParams.set(\"region\", this.options.region);\n    }\n    sessionParams.set(\"force_new\", String(this.options.forceNew));\n    const createdSession = await asyncOperationWithRetry(\n      (signal) =>\n        this.fetch(`${this.apiUrl}/sql/session?${sessionParams.toString()}`, {\n          method: \"POST\",\n          body: JSON.stringify({\n            runtimeId: this.options.runtime,\n            version: this.options.version,\n            sessionType: this.options.sessionType,\n            shutdownAfterInactiveSeconds:\n              this.options.shutdownAfterInactiveSeconds,\n          }),\n          ...this.fetchOptions,\n          signal: combineAbortSignals(signal, this.fetchOptions.signal),\n        }),\n      {\n        retryOn: shouldRetryForResiliency,\n        retryDelay: backoffRetry,\n        timeout: API_REQUEST_TIMEOUT,\n      },\n    ).then((res) => parseResponse(res, SessionResponseSchema));\n    sessionContextLogger(createdSession).debug(\"Session created\");\n\n    // a custom counter that is only incremented when a request is retried\n    // due to an error, as opposed to a successful request that is retried\n    // because the session is not ready yet\n    let numFailedAttempts = 0;\n    const establishedSession = await asyncOperationWithRetry(\n      (signal) =>\n        this.fetch(`${this.apiUrl}/sql/session/${createdSession.id}`, {\n          ...this.fetchOptions,\n          signal: combineAbortSignals(signal, this.fetchOptions.signal),\n        }),\n      {\n        retryDelay: backoffRetry,\n        retryOn: async (_, error, res) => {\n          if (shouldRetryForResiliency(numFailedAttempts, error, res)) {\n            numFailedAttempts++;\n            return true;\n          }\n          if (!error && res) {\n            const session = await parseResponse(res, SessionResponseSchema);\n            sessionContextLogger(session).debug(\"Checked session state\");\n            return !isSessionInFinalState(session);\n          }\n          return false;\n        },\n        timeout: API_REQUEST_TIMEOUT,\n      },\n    ).then((res) => parseResponse(res, ReadySessionResponseSchema));\n\n    logger\n      .child({ url: establishedSession.appMeta?.url })\n      .debug(\"Session established\");\n\n    const wsUrl = `${toWsUrl(establishedSession.appMeta.url)}`;\n    await this.connectToWebSocket(wsUrl);\n  }\n\n  private async connectToWebSocket(wsUrl: string) {\n    const urlWithProtocol = `${wsUrl}/${this.protocolVersion}`;\n    logger\n      .child({ wsUrl: urlWithProtocol })\n      .debug(\"Opening WebSocket connection\");\n\n    this.ws = await asyncOperationWithRetry(\n      (signal) =>\n        this.openWebSocket(\n          urlWithProtocol,\n          combineAbortSignals(signal, this.sessionAbortController.signal),\n        ),\n      {\n        retryOn: (attempt, error) => {\n          if (error && attempt < NUM_RESLIENCY_RETRIES) {\n            logger\n              .child({ attempt, error: error.message })\n              .warn(\"Retrying WebSocket connection\");\n            return true;\n          }\n          return false;\n        },\n        retryDelay: backoffRetry,\n        timeout: API_REQUEST_TIMEOUT,\n      },\n    );\n    this.addWsListener(\"error\", this.onWsError);\n    this.addWsListener(\"close\", this.onWsClose);\n\n    logger\n      .child({ wsUrl: urlWithProtocol })\n      .debug(\"WebSocket connection is open\");\n  }\n\n  // helper method to attempt to open a WebSocket connection,\n  // returning a Promise that either resolves to a socket instance\n  // if the connection is opened succesfully, or rejects if the connection\n  // fails, is closed remotely, or is aborted due to a timeout\n  private openWebSocket(\n    url: string,\n    signal: AbortSignal,\n  ): Promise<SocketApiSubset> {\n    return new Promise((resolve, reject) => {\n      const onAbort = (e: Event) => {\n        reject(new Error(e.type));\n        cleanup(true);\n      };\n      signal.addEventListener(\"abort\", onAbort);\n      signal.throwIfAborted();\n      const onSocketOpen = () => {\n        cleanup();\n        resolve(ws);\n      };\n      const onSocketFail = (e: Event) => {\n        cleanup(true);\n        reject(new Error(e.type));\n      };\n      const cleanup = (close?: boolean) => {\n        signal.removeEventListener(\"abort\", onAbort);\n        ws.removeEventListener(\"open\", onSocketOpen);\n        ws.removeEventListener(\"error\", onSocketFail);\n        ws.removeEventListener(\"close\", onSocketFail);\n        if (close) {\n          ws.close();\n        }\n      };\n      const ws = this.openSocket(url, {\n        token: this.options.token,\n        apiKey: this.options.apiKey,\n      });\n      ws.addEventListener(\"open\", onSocketOpen, { once: true });\n      ws.addEventListener(\"error\", onSocketFail, { once: true });\n      ws.addEventListener(\"close\", onSocketFail, { once: true });\n    });\n  }\n\n  public async execute<Schema extends TypeMap = TypeMap>(\n    statement: string,\n    options: ExecuteOptions = {},\n  ): Promise<Table<Schema>> {\n    if (!this.ws) {\n      throw new Error(\"WebSocket is not open\");\n    }\n    const executionId = uuid.v4();\n    const executionAbortSignal = combineAbortSignals(\n      this.sessionAbortController.signal,\n      options.signal,\n    );\n    const executionSuccessPromise = this.waitForMessage(\n      executionId,\n      StateUpdatedEventSchema,\n      executionAbortSignal,\n    );\n    const executeEvent: ExecuteSQLEvent = {\n      kind: \"execute_sql\",\n      execution_id: executionId,\n      statement,\n    };\n    this.ws.send(JSON.stringify(executeEvent));\n    logger\n      .child({ executionId })\n      .debug(\"Waiting for execution to be successful\");\n    await executionSuccessPromise;\n\n    const resultsPromise = this.waitForMessage(\n      executionId,\n      ExecutionResultEventSchema,\n      executionAbortSignal,\n    );\n    const retrieveEvent: RetrieveResultsEvent = {\n      kind: \"retrieve_results\",\n      execution_id: executionId,\n      geometry: this.options.geometryRepresentation,\n      compression: this.compression,\n    };\n    this.ws.send(JSON.stringify(retrieveEvent));\n    logger\n      .child({ executionId })\n      .debug(\"Waiting for execution result to succeed\");\n    const results = await resultsPromise;\n\n    const decompressed = await platform.decompress(\n      results.results.result_bytes,\n      results.results.compression,\n    );\n    const decoded = decodeResults<Schema>(decompressed, results.results.format);\n    return Promise.resolve(decoded);\n  }\n\n  private async waitForMessage<T extends typeof EventWithExecutionIdSchema>(\n    executionId: string,\n    schema: T,\n    abortSignal: AbortSignal,\n  ): Promise<z.infer<T>> {\n    return new Promise<z.infer<T>>((resolve, reject) => {\n      const sendCancellation = () => {\n        logger.child({ executionId }).debug(\"Sending cancel event\");\n        const cancelEvent: CancelExecutionEvent = {\n          kind: \"cancel\",\n          execution_id: executionId,\n        };\n        this.ws?.send(JSON.stringify(cancelEvent));\n      };\n      const handleSignalAborted = () => {\n        sendCancellation();\n        cleanup();\n        reject(new Error(\"Execution aborted\"));\n      };\n      abortSignal.addEventListener(\"abort\", handleSignalAborted);\n      if (abortSignal.aborted) {\n        sendCancellation();\n        reject(new Error(\"Execution aborted\"));\n        return;\n      }\n\n      const handleMessage = async (e: MessageEvent) => {\n        try {\n          let toParse: unknown;\n          if (typeof e.data === \"string\") {\n            toParse = JSON.parse(e.data);\n          } else {\n            toParse = decodeCbor(await toBytes(e.data));\n          }\n\n          // Early check: only process messages that belong to this execution\n          const { success: hasExecutionId, data: eventWithId } =\n            EventWithExecutionIdSchema.safeParse(toParse);\n          if (!hasExecutionId || eventWithId.execution_id !== executionId) {\n            return; // Ignore messages for other executions\n          }\n\n          // Check if this is an error event\n          const { success: isError, data: errorEvent } =\n            ErrorEventSchema.safeParse(toParse);\n          if (isError) {\n            logger.child(errorEvent).error(\"Error event received\");\n            cleanup();\n            abortSignal.removeEventListener(\"abort\", handleSignalAborted);\n            reject(new Error(\"Error event received\"));\n            return;\n          }\n\n          // Try to parse as the expected schema\n          const data = schema.parse(toParse);\n          cleanup();\n          abortSignal.removeEventListener(\"abort\", handleSignalAborted);\n          resolve(data);\n        } catch (err) {\n          // A schema mismatch is expected and ignored: the message may be for a\n          // different schema, or \"status\" may be \"failed\" (a dedicated error\n          // event is also sent in that case). Anything else (e.g. a binary\n          // decode failure in toBytes/decodeCbor) is unexpected, so surface it\n          // at debug level rather than swallowing it entirely.\n          if (!(err instanceof z.ZodError)) {\n            logger\n              .child({ executionId, error: (err as Error)?.message })\n              .debug(\"Failed to handle WebSocket message\");\n          }\n        }\n      };\n      const cleanup = this.addWsListener(\"message\", handleMessage);\n    });\n  }\n\n  private addWsListener<E extends keyof WebSocketEventMap>(\n    name: E,\n    listener: (e: WebSocketEventMap[E]) => void,\n    options?: AddEventListenerOptions,\n  ) {\n    if (!this.ws) {\n      throw new Error(\"WebSocket is not open\");\n    }\n    const boundListener = listener.bind(this);\n    this.wsListeners.push({ name, listener: boundListener });\n    this.ws.addEventListener(name, boundListener, options);\n    return () => this.ws?.removeEventListener(name, boundListener);\n  }\n\n  private onWsError(e: Event) {\n    logger\n      .child({ message: (e as ErrorEvent).message })\n      .error(\"Web Socket error\");\n    this.close();\n  }\n\n  private onWsClose(e: CloseEvent) {\n    logger\n      .child({ code: e.code, reason: e.reason })\n      .error(\"Web Socket closed unexpectedly\");\n    this.close();\n  }\n\n  public close(): void {\n    logger.debug(\"Closing connection\");\n    this.sessionAbortController.abort();\n    if (this.ws) {\n      this.wsListeners.forEach((l) =>\n        this.ws?.removeEventListener(l.name, l.listener),\n      );\n      this.ws.close();\n    }\n    this.ws = null;\n    this.wsListeners = [];\n  }\n\n  public [Symbol.dispose](): void {\n    this.close();\n  }\n}\n","import { DataCompression } from \"../constants\";\nimport {\n  AuthCredentials,\n  Logger,\n  LoggerOptions,\n  Platform,\n  SocketApiSubset,\n} from \"./types\";\n\n// In the browser the native WebSocket cannot set request headers, so auth on\n// the upgrade uses one of the two header-free channels the edge (goproxy)\n// accepts:\n//   - a bearer/session token via the ambient `wherobotsToken` cookie (sent\n//     automatically because the page origin and the session host share the\n//     registrable domain), or\n//   - an API key via the `?token=` query param, which goproxy validates as an\n//     X-API-Key. This requires the EnableTokenQueryParamGoproxy flag, and the\n//     key is visible in the URL (and thus proxy/access logs), so prefer a\n//     short-lived token + cookie when possible.\nconst openSocket = (url: string, auth: AuthCredentials): SocketApiSubset => {\n  let socketUrl = url;\n  if (auth.apiKey) {\n    const separator = socketUrl.includes(\"?\") ? \"&\" : \"?\";\n    socketUrl += `${separator}token=${encodeURIComponent(auth.apiKey)}`;\n  }\n  const ws = new WebSocket(socketUrl);\n  ws.binaryType = \"arraybuffer\";\n  return ws;\n};\n\nconst gunzipStream = async (payload: Uint8Array): Promise<Uint8Array> => {\n  // The cast is required: TS's BlobPart wants Uint8Array<ArrayBuffer>, but our\n  // payloads are the wider Uint8Array<ArrayBufferLike>. Safe at runtime.\n  const stream = new Blob([payload as unknown as BlobPart])\n    .stream()\n    .pipeThrough(new DecompressionStream(\"gzip\"));\n  return new Uint8Array(await new Response(stream).arrayBuffer());\n};\n\nconst decompress = async (\n  payload: Uint8Array,\n  compression: DataCompression,\n): Promise<Uint8Array> => {\n  switch (compression) {\n    case DataCompression.GZIP:\n      return gunzipStream(payload);\n    case DataCompression.NONE:\n      return payload;\n    case DataCompression.BROTLI:\n      throw new Error(\n        \"Brotli decompression is not supported in the browser. Request `gzip` or `none` compression instead.\",\n      );\n    default:\n      throw new Error(`Unsupported compression: ${compression}`);\n  }\n};\n\n// A minimal console-backed logger so the browser bundle pulls in neither pino\n// nor pino-pretty. Context objects accumulate across `child` calls.\nconst consoleLogger = (\n  options: LoggerOptions,\n  context: object = {},\n): Logger => {\n  const enabled = options.enabled;\n  const log =\n    (level: \"info\" | \"debug\" | \"warn\" | \"error\") => (msg: string | object) => {\n      if (!enabled) return;\n      if (level === \"debug\" && !options.debug) return;\n      const prefix = `[${options.name}]`;\n      if (typeof msg === \"string\") {\n        console[level](prefix, msg, context);\n      } else {\n        console[level](prefix, { ...context, ...msg });\n      }\n    };\n  return {\n    info: log(\"info\"),\n    debug: log(\"debug\"),\n    warn: log(\"warn\"),\n    error: log(\"error\"),\n    child: (childContext) =>\n      consoleLogger(options, { ...context, ...childContext }),\n  };\n};\n\nexport const platform: Platform = {\n  openSocket,\n  decompress,\n  // Browsers drop a JS-set User-Agent; the SDK identifies itself via the\n  // X-Wherobots-Client header instead (set by the connection on both platforms).\n  userAgent: () => undefined,\n  clientPlatform: \"browser\",\n  defaultCompression: DataCompression.GZIP,\n  createLogger: (options) => consoleLogger(options),\n};\n","// Cross-platform environment access. A single guarded implementation works in\n// both Node (reads process.env) and the browser (no process → undefined), so no\n// platform-specific build is needed for this.\nexport const getEnv = (name: string): string | undefined => {\n  if (typeof process === \"undefined\" || !process.env) {\n    return undefined;\n  }\n  // eslint-disable-next-line security/detect-object-injection\n  return process.env[name];\n};\n\nexport const isNode = (): boolean =>\n  typeof process !== \"undefined\" && Boolean(process.versions?.node);\n","import { platform } from \"@platform\";\nimport { getEnv } from \"./platform/env\";\nimport { Logger } from \"./platform/types\";\nimport { SessionReponse } from \"./schemas\";\n\nconst shouldUseDebugLogging = (getEnv(\"NODE_DEBUG\") || \"\")\n  .split(\",\")\n  .includes(\"wherobots-sql-driver\");\n\nconst logger: Logger = platform.createLogger({\n  name: \"wherobots-sql-driver\",\n  debug: shouldUseDebugLogging,\n  enabled: getEnv(\"NODE_ENV\") !== \"test\",\n});\n\nexport default logger;\n\nexport const sessionContextLogger = (session: SessionReponse): Logger => {\n  const { id, status, traces, message, appMeta } = session;\n  const context = Object.fromEntries(\n    Object.entries({\n      id,\n      status,\n      traces,\n      message,\n      appMeta,\n    }).filter(([, val]) => Boolean(val)),\n  );\n  return logger.child(context);\n};\n","{\n  \"name\": \"wherobots-sql-driver\",\n  \"version\": \"0.12.0\",\n  \"description\": \"TypeScript SDK for Wherobots DB\",\n  \"license\": \"Apache-2.0\",\n  \"main\": \"./dist/node/index.js\",\n  \"module\": \"./dist/node/index.mjs\",\n  \"browser\": \"./dist/browser/index.js\",\n  \"types\": \"./dist/node/index.d.ts\",\n  \"exports\": {\n    \".\": {\n      \"browser\": {\n        \"types\": \"./dist/browser/index.d.ts\",\n        \"import\": \"./dist/browser/index.mjs\",\n        \"require\": \"./dist/browser/index.js\"\n      },\n      \"node\": {\n        \"types\": \"./dist/node/index.d.ts\",\n        \"import\": \"./dist/node/index.mjs\",\n        \"require\": \"./dist/node/index.js\"\n      },\n      \"default\": {\n        \"types\": \"./dist/node/index.d.ts\",\n        \"import\": \"./dist/node/index.mjs\",\n        \"require\": \"./dist/node/index.js\"\n      }\n    }\n  },\n  \"files\": [\n    \"dist\"\n  ],\n  \"keywords\": [\n    \"wherobots\",\n    \"sedona\",\n    \"geospatial\",\n    \"spatial sql\"\n  ],\n  \"homepage\": \"https://github.com/wherobots/wherobots-typescript-sdk\",\n  \"bugs\": \"https://github.com/wherobots/wherobots-typescript-sdk/issues\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/wherobots/wherobots-typescript-sdk\"\n  },\n  \"engines\": {\n    \"node\": \">=18.0.0\"\n  },\n  \"scripts\": {\n    \"build\": \"tsup\",\n    \"build:check\": \"tsc --noEmit\",\n    \"lint\": \"eslint .\",\n    \"lint:fix\": \"eslint . --fix\",\n    \"format\": \"prettier --check .\",\n    \"format:fix\": \"prettier --write .\",\n    \"prepare\": \"husky\",\n    \"prepublish\": \"npm run build\",\n    \"test\": \"vitest run\",\n    \"test:watch\": \"vitest\",\n    \"test:browser\": \"playwright test\"\n  },\n  \"devDependencies\": {\n    \"@commitlint/cli\": \"^19.4.0\",\n    \"@commitlint/config-conventional\": \"^19.2.2\",\n    \"@playwright/test\": \"^1.49.0\",\n    \"@swc-node/register\": \"^1.10.9\",\n    \"@tsconfig/node-lts\": \"^20.1.3\",\n    \"@tsconfig/strictest\": \"^2.0.5\",\n    \"@types/ws\": \"^8.5.12\",\n    \"@typescript-eslint/eslint-plugin\": \"^7.18.0\",\n    \"@typescript-eslint/parser\": \"^7.18.0\",\n    \"eslint\": \"^8.57.0\",\n    \"eslint-config-airbnb\": \"^19.0.4\",\n    \"eslint-config-airbnb-typescript\": \"^18.0.0\",\n    \"eslint-config-prettier\": \"^9.1.0\",\n    \"eslint-plugin-node\": \"^11.1.0\",\n    \"eslint-plugin-prettier\": \"^5.2.1\",\n    \"eslint-plugin-security\": \"^3.0.1\",\n    \"esbuild\": \"^0.28.1\",\n    \"husky\": \"^9.1.4\",\n    \"lint-staged\": \"^15.2.9\",\n    \"prettier\": \"^3.3.3\",\n    \"tsup\": \"^8.3.5\",\n    \"typescript\": \"^5.5.4\",\n    \"vitest\": \"^3.0.5\",\n    \"vitest-fetch-mock\": \"^0.3.0\"\n  },\n  \"dependencies\": {\n    \"apache-arrow\": \"^17.0.0\",\n    \"cbor-x\": \"^1.6.0\",\n    \"pino\": \"^9.3.2\",\n    \"pino-pretty\": \"^11.2.2\",\n    \"uuid\": \"^11.1.1\",\n    \"ws\": \"^8.18.0\",\n    \"zod\": \"^3.23.8\"\n  },\n  \"overrides\": {\n    \"tsup\": {\n      \"esbuild\": \"^0.28.1\"\n    }\n  }\n}\n","// Named imports (rather than a default import of the whole file) let the\n// bundler tree-shake package.json down to just these two fields, instead of\n// inlining the entire manifest (deps and all) into both builds.\nimport { name, version } from \"../package.json\";\n\nexport const PACKAGE_NAME: string = name;\nexport const PACKAGE_VERSION: string = version;\n","// Build the advisory `X-Wherobots-Client` request header.\n//\n// `X-Wherobots-Client` is the shared, cross-client attribution header. It\n// carries an ordered, comma-separated chain of hops modelled on\n// `X-Forwarded-For`: the *leftmost* hop is the origin client and every\n// component that forwards the request *appends its own hop on the right*:\n//\n//     client=studio-frontend, client=typescript-sdk;ver=0.11.1;plat=browser\n//\n// Each hop is `client=<token>` plus optional `;key=value` parameters. The\n// convention defines `ver`, `plat` and `cmd`; this SDK emits `ver` and `plat` —\n// there is no subcommand for it to name. Commas and semicolons are the\n// delimiters, so they never appear inside a value, and neither do control\n// characters, which an HTTP header field-value cannot carry at all.\n//\n// The header is *advisory only*: it is client-asserted, used for attribution\n// and analytics, and must never influence authentication or authorization.\n//\n// See studio-backend `docs/client-attribution.md` — that document is the\n// contract this module implements.\n\nimport { platform } from \"@platform\";\nimport { PACKAGE_VERSION } from \"./version\";\n\n// Canonical name of the shared, cross-service client-chain header.\nexport const CLIENT_HEADER_NAME = \"X-Wherobots-Client\";\n\n// This SDK's stable token in the shared client vocabulary. Renaming it splits\n// its analytics history, so it never changes.\nexport const CLIENT_TOKEN = \"typescript-sdk\";\n\n// The server treats a header value longer than this (in bytes) as malformed and\n// records `unknown` for the whole chain, so we never emit more: oversized\n// upstream chains are trimmed from the left instead. Every value is scrubbed to\n// ASCII, so bytes and characters count the same here.\nexport const MAX_HEADER_BYTES = 512;\n\n// Bounds a single parameter value (`ver`, `plat`). The server's 64-character\n// limit applies to a hop's `client` token, not to its parameters, so an\n// over-length value here costs nothing on its own; the bound exists so one\n// pathological version string cannot eat the header budget and starve upstream\n// hops. `CLIENT_TOKEN` is a short fixed literal and never passes through\n// `sanitizeValue`.\nconst MAX_VALUE_CHARS = 63;\n\nconst HOP_SEPARATOR = \", \";\nconst REPLACEMENT = \"_\";\n\n// Everything outside this ASCII allowlist collapses to `_`: the `,` and `;`\n// grammar delimiters, every C0 control character and DEL (a CR or LF here is\n// the classic header-injection primitive, and `fetch` rejects the request\n// outright rather than sending it), and every non-ASCII character.\nconst UNSAFE_VALUE_CHARS = /[^A-Za-z0-9._+-]/g;\n\n// An upstream chain carries its own `,` / `;` / `=` grammar, so those survive;\n// everything else outside the allowlist does not.\nconst UNSAFE_CHAIN_CHARS = /[^A-Za-z0-9._+:/@=;, -]/g;\n\n// Render a value safe to embed in a hop we build ourselves.\nconst sanitizeValue = (value: string): string =>\n  value\n    .trim()\n    .replace(UNSAFE_VALUE_CHARS, REPLACEMENT)\n    .slice(0, MAX_VALUE_CHARS)\n    // Trailing separators carry no information and read as noise. Stripped\n    // after truncation as well as before it: the cut can land immediately\n    // after a replaced character and expose a separator that was in the\n    // middle of the value a moment ago.\n    .replace(/^[_.-]+|[_.-]+$/g, \"\");\n\n// The `plat` parameter for this hop. Node reports its OS (`darwin`, `linux`,\n// `win32`) to match what the Python SDK and JDBC driver emit; the browser has\n// no equivalent it can report honestly, and a UA-string parse would be a guess,\n// so it reports the runtime instead. Resolved through the platform layer so\n// that `process.platform` stays out of the browser bundle entirely.\nexport const resolvePlatform = (): string => platform.clientPlatform;\n\n// Render this SDK's single hop. A parameter whose value is missing or empty is\n// omitted rather than emitted as a placeholder, so an unresolvable version\n// simply means the hop carries no `ver` — the `client=` token, which is the\n// part attribution actually depends on, is always present.\nexport const buildHop = (\n  version: string = PACKAGE_VERSION,\n  platformName: string = resolvePlatform(),\n): string => {\n  const segments = [`client=${CLIENT_TOKEN}`];\n  const sanitizedVersion = sanitizeValue(version);\n  if (sanitizedVersion) {\n    segments.push(`ver=${sanitizedVersion}`);\n  }\n  const sanitizedPlatform = sanitizeValue(platformName);\n  if (sanitizedPlatform) {\n    segments.push(`plat=${sanitizedPlatform}`);\n  }\n  return segments.join(\";\");\n};\n\n// Split an inbound chain into its individual hops. Hop *parameters* are\n// preserved as-is — the chain is a record of what upstream asserted, not\n// something to re-render — but the text is scrubbed, because an upstream chain\n// is arbitrary caller-supplied input and this is the only sanitization it ever\n// gets before landing in a request header.\nconst splitChain = (chain: string | undefined): string[] => {\n  if (!chain) {\n    return [];\n  }\n  return chain\n    .replace(UNSAFE_CHAIN_CHARS, REPLACEMENT)\n    .split(\",\")\n    .map((hop) => hop.replace(/\\s+/g, \" \").trim())\n    .filter((hop) => hop.length > 0);\n};\n\nconst byteLength = (value: string): number =>\n  new TextEncoder().encode(value).length;\n\n// Build the full header value for a request this SDK is sending.\n//\n// Any `upstreamChain` the caller supplies is preserved — scrubbed, but\n// otherwise untouched — and this SDK's hop is appended on its right, so the\n// origin stays leftmost. When the result would exceed `MAX_HEADER_BYTES` the\n// oldest (leftmost) upstream hops are dropped until it fits: losing early\n// provenance beats the server discarding the whole chain as malformed.\n//\n// Never returns an empty string. With no upstream chain it is this SDK's\n// single hop.\nexport const clientHeaderValue = (\n  upstreamChain?: string,\n  hop: string = buildHop(),\n): string => {\n  const hops = splitChain(upstreamChain);\n  while (hops.length > 0) {\n    const value = [...hops, hop].join(HOP_SEPARATOR);\n    if (byteLength(value) <= MAX_HEADER_BYTES) {\n      return value;\n    }\n    hops.shift();\n  }\n  return hop;\n};\n","import z from \"zod\";\nimport { MAX_HEADER_BYTES } from \"./clientHeader\";\nimport {\n  DataCompression,\n  GeometryRepresentation,\n  ResultsFormat,\n  SessionStatus,\n  SessionType,\n} from \"./constants\";\n\n//////////////////////////////////////////////////////////////////////////\n// Schema-definitions for connection options from the consumer\n\n// A schema for the options that are passed to the Connection contstructor,\n// used to generate the typescript type for that constructor\n\nconst apiKeySchema = z.string().min(1).max(255);\n\nconst ConnectionOptionsSchema = z.object({\n  apiKey: apiKeySchema.optional(),\n  // A bearer token (e.g. a WorkOS access token) used instead of an API key.\n  // Exactly one of `token` / `apiKey` must be provided. In the browser, prefer\n  // `token`: it authenticates the REST calls, while the session WebSocket relies\n  // on the ambient `wherobotsToken` cookie.\n  token: z.string().min(1).max(8192).optional(),\n  // Override the API origin. Defaults to the WHEROBOTS_API_URL env var (Node)\n  // or https://api.cloud.wherobots.com. Must be set explicitly in the browser\n  // only when targeting a non-default environment.\n  apiUrl: z.string().url().optional(),\n  // Accepts any non-empty string; `Runtime` enum values are passed through as-is.\n  // When omitted, the org's default runtime is used.\n  runtime: z\n    .string()\n    .min(1)\n    .describe(\n      \"Override the default runtime set for your organization. Only set this if you need a specific runtime instead of the one your administrator has configured. When omitted, your organization's default runtime is used.\",\n    )\n    .optional(),\n  // Accepts any non-empty string; `Region` enum values and BYOC region\n  // identifiers (e.g. \"byoc-acme-us-east-1\") are passed through as-is.\n  // When omitted, the org's default region is used.\n  region: z\n    .string()\n    .min(1)\n    .describe(\n      \"Override the default region set for your organization. Only set this if you intend to use a specific region instead of the one your administrator has configured. When omitted, your organization's default region is used.\",\n    )\n    .optional(),\n  version: z.string().nullable().optional(),\n  resultsFormat: z.literal(ResultsFormat.ARROW).optional(),\n  // Result compression to request from the server. When omitted, the platform\n  // default is used (brotli in Node, gzip in the browser).\n  dataCompression: z.nativeEnum(DataCompression).optional(),\n  geometryRepresentation: z.nativeEnum(GeometryRepresentation).optional(),\n  sessionType: z.nativeEnum(SessionType).optional(),\n  forceNew: z.boolean().optional(),\n  shutdownAfterInactiveSeconds: z.number().int().positive().optional(),\n  // An inbound `X-Wherobots-Client` chain to forward. Set this only when the\n  // caller is itself acting on behalf of an upstream Wherobots client (an app\n  // embedding this SDK, a BI integration); the value is sanitized and kept to\n  // the left of this SDK's own hop, so the origin stays leftmost. Attribution\n  // is advisory and never affects auth, so a malformed value costs provenance,\n  // not the request. The bound here is a coarse guard measured in UTF-16 code\n  // units, not bytes; `clientHeaderValue` enforces the real UTF-8 byte budget.\n  clientChain: z.string().min(1).max(MAX_HEADER_BYTES).optional(),\n});\n\nexport type ConnectionOptions = z.infer<typeof ConnectionOptionsSchema>;\n\n// A normalized extension to the ConnectionOptionsSchema that fills in defaults\n// for all optional fields. `apiKey`/`token` stay optional here; exactly one is\n// required, enforced by the refinement below. `dataCompression` stays optional\n// so the connection can fall back to the platform default.\nexport const ConnectionOptionsSchemaNormalized = ConnectionOptionsSchema.extend(\n  {\n    // No region/runtime default: when the consumer omits them they stay\n    // undefined and are dropped from the request so the API applies the\n    // organization's configured defaults.\n    resultsFormat: ConnectionOptionsSchema.shape.resultsFormat.default(\n      ResultsFormat.ARROW,\n    ),\n    geometryRepresentation:\n      ConnectionOptionsSchema.shape.geometryRepresentation.default(\n        GeometryRepresentation.EWKT,\n      ),\n    sessionType: ConnectionOptionsSchema.shape.sessionType.default(\n      SessionType.SINGLE,\n    ),\n    forceNew: ConnectionOptionsSchema.shape.forceNew.default(false),\n  },\n).superRefine((options, ctx) => {\n  if (Boolean(options.token) === Boolean(options.apiKey)) {\n    ctx.addIssue({\n      code: z.ZodIssueCode.custom,\n      message: \"Exactly one of `token` or `apiKey` is required\",\n    });\n  }\n});\n\nexport type ConnectionOptionsNormalized = z.infer<\n  typeof ConnectionOptionsSchemaNormalized\n>;\n\n//////////////////////////////////////////////////////////////////////////\n// Schema-definitions for creating the session via REST\n\nconst AppMetaSchema = z.object({\n  url: z.string().url(),\n});\n\nexport const SessionResponseSchema = z.object({\n  id: z.string(),\n  status: z.nativeEnum(SessionStatus),\n  appMeta: AppMetaSchema.nullable().optional(),\n  traces: z.object({}).passthrough().nullable().optional(),\n  message: z.string().nullable().optional(),\n});\n\nexport type SessionReponse = z.infer<typeof SessionResponseSchema>;\n\nexport const ReadySessionResponseSchema = SessionResponseSchema.extend({\n  status: z.literal(SessionStatus.READY),\n  appMeta: AppMetaSchema,\n});\n\n//////////////////////////////////////////////////////////////////////////\n// Schema-definitions for executing SQL over web socket\n\nconst ExecutionIdSchema = z.string().min(1).max(255);\n\nexport const ExecuteSQLEventSchema = z.object({\n  kind: z.literal(\"execute_sql\"),\n  execution_id: ExecutionIdSchema,\n  statement: z.string().min(1),\n});\n\nexport type ExecuteSQLEvent = z.infer<typeof ExecuteSQLEventSchema>;\n\nexport const RetrieveResultsEventSchema = z.object({\n  kind: z.literal(\"retrieve_results\"),\n  execution_id: ExecutionIdSchema,\n  geometry: z.nativeEnum(GeometryRepresentation),\n  compression: z.nativeEnum(DataCompression),\n});\n\nexport type RetrieveResultsEvent = z.infer<typeof RetrieveResultsEventSchema>;\n\nexport const CancelExecutionEventSchema = z.object({\n  kind: z.literal(\"cancel\"),\n  execution_id: ExecutionIdSchema,\n});\n\nexport type CancelExecutionEvent = z.infer<typeof CancelExecutionEventSchema>;\n\nexport const EventWithExecutionIdSchema = z.object({\n  execution_id: ExecutionIdSchema,\n});\n\nexport const StateUpdatedEventSchema = EventWithExecutionIdSchema.extend({\n  kind: z.literal(\"state_updated\"),\n  state: z.literal(\"succeeded\"),\n});\n\nexport type StateUpdatedEvent = z.infer<typeof StateUpdatedEventSchema>;\n\nexport const ExecutionResultEventSchema = EventWithExecutionIdSchema.extend({\n  kind: z.literal(\"execution_result\"),\n  state: z.literal(\"succeeded\"),\n  results: z.object({\n    // Binary frames decode to a Uint8Array. Using z.custom (rather than\n    // z.instanceof) keeps the inferred type the permissive `Uint8Array` so a\n    // Node Buffer (Uint8Array<ArrayBufferLike>) is accepted as well.\n    result_bytes: z.custom<Uint8Array>((val) => val instanceof Uint8Array, {\n      message: \"Expected binary result bytes\",\n    }),\n    compression: z.nativeEnum(DataCompression),\n    format: z.nativeEnum(ResultsFormat),\n    geometry: z.nativeEnum(GeometryRepresentation),\n    geo_columns: z.array(z.string()),\n  }),\n});\n\nexport type ExecutionResultEvent = z.infer<typeof ExecutionResultEventSchema>;\n\nexport const ErrorEventSchema = EventWithExecutionIdSchema.extend({\n  kind: z.literal(\"error\"),\n  message: z.string(),\n});\n\nexport type ErrorEvent = z.infer<typeof ErrorEventSchema>;\n","import z, { ZodRawShape } from \"zod\";\nimport { SessionReponse } from \"./schemas\";\nimport { ResultsFormat, SessionStatus } from \"./constants\";\nimport logger from \"./logger\";\nimport { tableFromIPC, TypeMap } from \"apache-arrow\";\n\nexport const parseResponse = async <T extends z.ZodObject<ZodRawShape>>(\n  res: Response,\n  schema: T,\n): Promise<z.infer<T>> => {\n  if (!res.ok) {\n    logger\n      .child({ status: res.status, url: res.url })\n      .error(`Request failed: ${res.statusText}`);\n    throw new Error(`Request failed: ${res.statusText}`);\n  }\n  const parseResult = schema.safeParse(await res.clone().json());\n  if (!parseResult.success) {\n    logger\n      .child({ url: res.url, message: parseResult.error.message })\n      .error(\"Invalid API response\");\n    logger.debug(parseResult.error);\n    throw new Error(\"Invalid API response\");\n  }\n  return parseResult.data;\n};\n\nexport const isSessionInFinalState = (session: SessionReponse): boolean =>\n  ![\n    SessionStatus.PENDING,\n    SessionStatus.PREPARING,\n    SessionStatus.REQUESTED,\n    SessionStatus.DEPLOYING,\n    SessionStatus.DEPLOYED,\n    SessionStatus.INITIALIZING,\n  ].includes(session.status);\n\n// choose a random number between 50% and 100% of the target delay\nconst jitter = (delay: number) => delay / 2 + (delay / 2) * Math.random();\n\n// helper function to define the retry delay (in milliseconds)\n// as a function of how many attempts have been made\nexport const backoffRetry = (attempts: number) => {\n  if (attempts <= 1) {\n    return jitter(1000);\n  }\n  if (attempts === 2) {\n    return jitter(2000);\n  }\n  return jitter(5000);\n};\n\ntype RetryOptions<T> = {\n  timeout: number;\n  retryOn: (\n    attempts: number,\n    error: Error | null,\n    result: T | null,\n  ) => boolean | Promise<boolean>;\n  retryDelay: (attempts: number) => number;\n};\n\n/*\n * helper function to perform an async operation where the caller can\n * specify the retry and timeout semantics via an options API.\n *\n * in order for timeouts to be handled correctly, the contract with the caller is\n * that the operation function must take an abort signal as an argument and\n * must respect the signal by aborting the operation when the signal is aborted.\n *\n * in the case of a timeout, the `retryOn` function will be called with an error\n * with the name \"TimeoutError\", which can be used to define how timeouts are retried.\n */\nexport const asyncOperationWithRetry = async <T>(\n  operation: (signal: AbortSignal) => Promise<T>,\n  options: RetryOptions<T>,\n): Promise<T> => {\n  const performAttempt = async (): Promise<[Error | null, T | null]> => {\n    try {\n      const timeoutSignal = AbortSignal.timeout(options.timeout);\n      const r = await operation(timeoutSignal);\n      return [null, r];\n    } catch (e) {\n      return [e as Error, null];\n    }\n  };\n  let attempts = 0;\n  let [error, result] = await performAttempt();\n  while (await options.retryOn(attempts, error, result)) {\n    const delay = options.retryDelay(attempts);\n    await new Promise((resolve) => setTimeout(resolve, delay));\n    attempts += 1;\n    [error, result] = await performAttempt();\n  }\n  if (error) {\n    return Promise.reject(error);\n  }\n  return Promise.resolve(result as T);\n};\n\nexport const RETRYABLE_HTTP_STATUS_CODES = [502, 503];\nexport const NUM_RESLIENCY_RETRIES = 3;\nexport const shouldRetryForResiliency = (\n  attempt: number,\n  error: Error | null,\n  result: { status: number } | null,\n) => {\n  if (attempt >= NUM_RESLIENCY_RETRIES) {\n    return false;\n  }\n  if (result && RETRYABLE_HTTP_STATUS_CODES.includes(result.status)) {\n    logger\n      .child({ status: result.status, attempt })\n      .debug(\"Retrying due to HTTP status\");\n    return true;\n  }\n  if (error && error.name === \"TimeoutError\") {\n    logger.child({ attempt }).debug(\"Retrying due to timeout\");\n    return true;\n  }\n  return false;\n};\n\nexport const toWsUrl = (url: string) => {\n  if (url.startsWith(\"https:\")) {\n    return url.replace(\"https:\", \"wss:\");\n  }\n  if (url.startsWith(\"http:\")) {\n    return url.replace(\"http:\", \"ws:\");\n  }\n  return `wss:${url}`;\n};\n\nexport const decodeResults = <Schema extends TypeMap>(\n  results: Uint8Array,\n  encoding: ResultsFormat,\n) => {\n  switch (encoding) {\n    case ResultsFormat.ARROW:\n      return tableFromIPC<Schema>(results);\n    default:\n      throw new Error(`Unsupported encoding: ${encoding}`);\n  }\n};\n\n// we can use AbortSignal.any() once we don't support Node 18\nexport const combineAbortSignals = (\n  ...signals: (AbortSignal | null | undefined)[]\n): AbortSignal => {\n  const controller = new AbortController();\n  signals.forEach((signal) => {\n    if (signal) {\n      if (signal.aborted) {\n        controller.abort(signal.reason);\n        return;\n      }\n      const onSignalAbort = () => controller.abort(signal.reason);\n      signal.addEventListener(\"abort\", onSignalAbort);\n      controller.signal.addEventListener(\"abort\", () =>\n        signal.removeEventListener(\"abort\", onSignalAbort),\n      );\n    }\n  });\n  return controller.signal;\n};\n"],"mappings":";AAAO,IAAK,SAAL,kBAAKA,YAAL;AAEL,EAAAA,QAAA,mBAAgB;AAChB,EAAAA,QAAA,mBAAgB;AAChB,EAAAA,QAAA,mBAAgB;AAGhB,EAAAA,QAAA,mBAAgB;AAGhB,EAAAA,QAAA,oBAAiB;AAVP,SAAAA;AAAA,GAAA;AAaL,IAAK,UAAL,kBAAKC,aAAL;AACL,EAAAA,SAAA,UAAO;AACP,EAAAA,SAAA,WAAQ;AACR,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,WAAQ;AACR,EAAAA,SAAA,aAAU;AACV,EAAAA,SAAA,cAAW;AACX,EAAAA,SAAA,gBAAa;AAEb,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,iBAAc;AACd,EAAAA,SAAA,mBAAgB;AAChB,EAAAA,SAAA,oBAAiB;AACjB,EAAAA,SAAA,sBAAmB;AAEnB,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,mBAAgB;AAChB,EAAAA,SAAA,oBAAiB;AAjBP,SAAAA;AAAA,GAAA;AAoBL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;AAKL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,yBAAL,kBAAKC,4BAAL;AACL,EAAAA,wBAAA,SAAM;AACN,EAAAA,wBAAA,SAAM;AACN,EAAAA,wBAAA,UAAO;AACP,EAAAA,wBAAA,UAAO;AACP,EAAAA,wBAAA,aAAU;AALA,SAAAA;AAAA,GAAA;AAQL,I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B,mBACG,MAAM,EAAE,SAAU,EAAiB,QAAQ,CAAC,EAC5C,MAAM,kBAAkB;AAC3B,SAAK,MAAM;AAAA,EACb;AAAA,EAEQ,UAAU,GAAe;AAC/B,mBACG,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,EAAE,OAAO,CAAC,EACxC,MAAM,gCAAgC;AACzC,SAAK,MAAM;AAAA,EACb;AAAA,EAEO,QAAc;AACnB,mBAAO,MAAM,oBAAoB;AACjC,SAAK,uBAAuB,MAAM;AAClC,QAAI,KAAK,IAAI;AACX,WAAK,YAAY;AAAA,QAAQ,CAAC,MACxB,KAAK,IAAI,oBAAoB,EAAE,MAAM,EAAE,QAAQ;AAAA,MACjD;AACA,WAAK,GAAG,MAAM;AAAA,IAChB;AACA,SAAK,KAAK;AACV,SAAK,cAAc,CAAC;AAAA,EACtB;AAAA,EAEA,CAAQ,OAAO,OAAO,IAAU;AAC9B,SAAK,MAAM;AAAA,EACb;AACF;","names":["Region","Runtime","ResultsFormat","DataCompression","GeometryRepresentation","SessionType","SessionStatus","z","name","version","z","name"]}