{"version":3,"file":"instanceOf.js","sourceRoot":"","sources":["../../src/jsutils/instanceOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,sBAAqB;AAWvC,SAAS,aAAa,CACpB,KAAc,EACd,MAAc,EACd,WAAwB;IAExB,IAAK,KAAa,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAEhD,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5D,MAAM,cAAc,GAElB,MAAM,CAAC,WAAW,IAAI,KAAK;YACzB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;YAC3B,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;QAC9B,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;YACjC,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,cAAc,SAAS,KAAK,gBAAgB;;;;;;;;;;;kBAWlC,CACX,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,MAAc;IACpD,OAAQ,KAAa,EAAE,MAAM,KAAK,MAAM,CAAC;AAC3C,CAAC;AAkBD,MAAM,CAAC,IAAI,UAAU,GAIN,cAAc,CAAC;AAG9B,MAAM,UAAU,mBAAmB;IACjC,UAAU,GAAG,aAAa,CAAC;AAC7B,CAAC","sourcesContent":["import { inspect } from './inspect.ts';\n\n/**\n * A replacement for instanceof relying on a symbol-driven type brand which in\n * development mode includes an error warning when multi-realm constructors are\n * detected.\n * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production\n * See: https://webpack.js.org/guides/production/\n *\n * @internal\n */\nfunction devInstanceOf(\n  value: unknown,\n  symbol: symbol,\n  constructor: Constructor,\n): boolean {\n  if ((value as any)?.__kind === symbol) {\n    return true;\n  }\n  if (typeof value === 'object' && value !== null) {\n    // Prefer Symbol.toStringTag since it is immune to minification.\n    const className = constructor.prototype[Symbol.toStringTag];\n    const valueClassName =\n      // We still need to support constructor's name to detect conflicts with older versions of this library.\n      Symbol.toStringTag in value\n        ? value[Symbol.toStringTag]\n        : value.constructor?.name;\n    if (className === valueClassName) {\n      const stringifiedValue = inspect(value);\n      throw new Error(\n        `Cannot use ${className} \"${stringifiedValue}\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`,\n      );\n    }\n  }\n  return false;\n}\n\nfunction prodInstanceOf(value: unknown, symbol: symbol): boolean {\n  return (value as any)?.__kind === symbol;\n}\n\ninterface Constructor {\n  prototype: {\n    [Symbol.toStringTag]: string;\n  };\n  new (...args: Array<any>): any;\n}\n\ninterface Constructor {\n  prototype: {\n    [Symbol.toStringTag]: string;\n  };\n  new (...args: Array<any>): any;\n}\n\n/** @internal */\n/* eslint-disable-next-line import/no-mutable-exports */\nexport let instanceOf: (\n  value: unknown,\n  symbol: symbol,\n  constructor: Constructor,\n) => boolean = prodInstanceOf;\n\n/** @internal */\nexport function enableDevInstanceOf(): void {\n  instanceOf = devInstanceOf;\n}\n"]}