{"version":3,"file":"normalizeStringifyValue.js","sources":["../../../../src/normalizeStringifyValue.ts"],"sourcesContent":["import { htmlTreeAsString, isElement } from '@sentry-internal/browser-utils';\n\ntype Prototype = { constructor?: (...args: unknown[]) => unknown };\n\nconst HTML_ELEMENT_CONSTRUCTOR_NAME_REGEX = /^HTML(\\w*)Element$/;\n\n/**\n * Browser-specific contributions to `normalize()`'s `stringifyValue`. Plug into\n * `setNormalizeStringifier` from the browser SDK so DOM values get a useful string\n * representation without forcing core to carry the DOM-specific code.\n *\n * Handles:\n * - `window` → `[Window]`\n * - `document` → `[Document]`\n * - `HTMLElement` subclasses → `[HTMLElement: ]` (via `htmlTreeAsString`)\n *\n * Vue ViewModels and React SyntheticEvents are not handled here — the Vue and React\n * SDKs wrap this function in their `init` and add their own checks on top.\n */\nexport function normalizeStringifyValue(value: Exclude): string | undefined {\n // oxlint-disable-next-line no-restricted-globals\n if (typeof window !== 'undefined' && value === window) {\n return '[Window]';\n }\n // oxlint-disable-next-line no-restricted-globals\n if (typeof document !== 'undefined' && value === document) {\n return '[Document]';\n }\n\n if (isElement(value)) {\n const objName = getConstructorName(value);\n if (HTML_ELEMENT_CONSTRUCTOR_NAME_REGEX.test(objName)) {\n return `[HTMLElement: ${htmlTreeAsString(value)}]`;\n }\n }\n\n return undefined;\n}\n\nfunction getConstructorName(value: unknown): string {\n const prototype: Prototype | null = Object.getPrototypeOf(value);\n\n return prototype?.constructor ? prototype.constructor.name : 'null prototype';\n}\n"],"names":[],"mappings":";;AAIA,MAAM,mCAAA,GAAsC,oBAAA;AAerC,SAAS,wBAAwB,KAAA,EAA+E;AAErH,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,KAAA,KAAU,MAAA,EAAQ;AACrD,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,IAAe,KAAA,KAAU,QAAA,EAAU;AACzD,IAAA,OAAO,YAAA;AAAA,EACT;AAEA,EAAA,IAAI,SAAA,CAAU,KAAK,CAAA,EAAG;AACpB,IAAA,MAAM,OAAA,GAAU,mBAAmB,KAAK,CAAA;AACxC,IAAA,IAAI,mCAAA,CAAoC,IAAA,CAAK,OAAO,CAAA,EAAG;AACrD,MAAA,OAAO,CAAA,cAAA,EAAiB,gBAAA,CAAiB,KAAK,CAAC,CAAA,CAAA,CAAA;AAAA,IACjD;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,mBAAmB,KAAA,EAAwB;AAClD,EAAA,MAAM,SAAA,GAA8B,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA;AAE/D,EAAA,OAAO,SAAA,EAAW,WAAA,GAAc,SAAA,CAAU,WAAA,CAAY,IAAA,GAAO,gBAAA;AAC/D;;;;"}