{"version":3,"file":"dom.mjs","names":[],"sources":["../../src/polyfills/dom.ts"],"sourcesContent":["/**\n * Polyfill: DOMException, Headers\n *\n * DOMException is used by CopilotKit's isAbortError check.\n * Headers is used by CopilotKit's request construction.\n * Skipped if the globals are already defined.\n *\n * Usage:\n *   import \"@copilotkit/react-native/polyfills/dom\";\n */\n\nexport {};\n\nconst g = globalThis as Record<string, unknown>;\n\n// DOMException\nif (typeof g.DOMException === \"undefined\") {\n  class DOMExceptionPolyfill extends Error {\n    code: number;\n    constructor(message?: string, name?: string) {\n      super(message);\n      this.name = name || \"DOMException\";\n      this.code = 0;\n    }\n  }\n  g.DOMException = DOMExceptionPolyfill;\n}\n\n// Headers\nif (typeof g.Headers === \"undefined\") {\n  class HeadersPolyfill {\n    private _map: Record<string, string> = {};\n    constructor(init?: Record<string, string> | HeadersPolyfill) {\n      if (init) {\n        if (init instanceof HeadersPolyfill) {\n          this._map = { ...init._map };\n        } else {\n          for (const [key, value] of Object.entries(init)) {\n            this._map[key.toLowerCase()] = value;\n          }\n        }\n      }\n    }\n    get(name: string): string | null {\n      return this._map[name.toLowerCase()] ?? null;\n    }\n    set(name: string, value: string): void {\n      this._map[name.toLowerCase()] = value;\n    }\n    has(name: string): boolean {\n      return name.toLowerCase() in this._map;\n    }\n    delete(name: string): void {\n      delete this._map[name.toLowerCase()];\n    }\n    append(name: string, value: string): void {\n      const key = name.toLowerCase();\n      if (key in this._map) {\n        this._map[key] += \", \" + value;\n      } else {\n        this._map[key] = value;\n      }\n    }\n    entries(): IterableIterator<[string, string]> {\n      return Object.entries(this._map)[Symbol.iterator]();\n    }\n    keys(): IterableIterator<string> {\n      return Object.keys(this._map)[Symbol.iterator]();\n    }\n    values(): IterableIterator<string> {\n      return Object.values(this._map)[Symbol.iterator]();\n    }\n    forEach(\n      callback: (value: string, key: string, parent: HeadersPolyfill) => void,\n    ): void {\n      for (const [key, value] of Object.entries(this._map)) {\n        callback(value, key, this);\n      }\n    }\n    [Symbol.iterator](): Iter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