{"version":3,"sources":["../src/transformer.ts","../src/validate.ts","../src/event-format.schema.ts"],"sourcesContent":["import type { Transformer } from '@walkeros/core';\nimport { setByPath } from '@walkeros/core';\nimport { validateEventAgainstContract } from './validate';\nimport type { ValidateSettings } from './types';\n\n/**\n * Mutating dot-path setter for ingest writes.\n *\n * We can't use @walkeros/core setByPath here: it clones-and-returns (immutable),\n * but ingest is the pipeline's mutable scratch context. We need in-place writes\n * so subsequent transformers and observers in the chain see the values.\n */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction setNestedPath(\n  obj: Record<string, unknown>,\n  path: string,\n  value: unknown,\n): void {\n  const keys = path.split('.');\n  let cur: Record<string, unknown> = obj;\n  for (let i = 0; i < keys.length - 1; i++) {\n    const k = keys[i];\n    const next = cur[k];\n    if (isRecord(next)) {\n      cur = next;\n    } else {\n      const child: Record<string, unknown> = {};\n      cur[k] = child;\n      cur = child;\n    }\n  }\n  cur[keys[keys.length - 1]] = value;\n}\n\nexport const transformerValidate: Transformer.Init<\n  Transformer.Types<ValidateSettings>\n> = (context) => {\n  const { config } = context;\n  const settings: ValidateSettings = config.settings ?? {};\n\n  const mode = settings.mode ?? 'pass';\n  const isValidPath = settings.output?.isValid ?? 'source.valid';\n  const errorsPath = settings.output?.errors ?? 'validation';\n\n  return {\n    // Init's input config type is Partial<Settings>; the instance config type\n    // is Settings. Same cast pattern the bot/fingerprint transformers use.\n    type: 'validate',\n    config: config as Transformer.Config<Transformer.Types<ValidateSettings>>,\n\n    async push(event, ctx) {\n      const { ingest } = ctx;\n\n      const { isValid, errors } = validateEventAgainstContract(event, ingest, {\n        contracts: settings.contract,\n        format: settings.format,\n      });\n\n      // Issues go to the INGEST (observer-visible diagnostics), written in\n      // place so they survive even when a strict drop stops the chain.\n      if (errorsPath) setNestedPath(ingest, errorsPath, errors);\n\n      // Verdict goes to the EVENT (travels to destinations as analytics data).\n      // setByPath is immutable, so reassign.\n      let nextEvent = event;\n      if (isValidPath) nextEvent = setByPath(nextEvent, isValidPath, isValid);\n\n      // strict + invalid: chain-stop drop. Errors are already on the ingest,\n      // so the drop is still diagnosable.\n      if (mode === 'strict' && !isValid) return false;\n\n      return { event: nextEvent };\n    },\n  };\n};\n","import type { Flow, Ingest, ValidateEvents, WalkerOS } from '@walkeros/core';\nimport * as cfworker from '@cfworker/json-schema';\nimport type { ContractSource, ValidationIssue } from './types';\nimport { eventFormatSchema } from './event-format.schema';\n\n/**\n * Module-level Validator cache keyed by the compact JSON of the schema.\n *\n * A plain Map (not WeakMap): schemas are re-cloned per flow load, so identical\n * structures arrive as distinct object references. Keying on serialized content\n * lets repeated pushes within and across loads share one compiled interpreter.\n */\nconst validatorCache = new Map<string, cfworker.Validator>();\n\nexport function getValidator(\n  schema: Record<string, unknown>,\n): cfworker.Validator {\n  const key = JSON.stringify(schema);\n  const cached = validatorCache.get(key);\n  if (cached) return cached;\n  // cfworker dereferences $ref by annotating each subschema in place\n  // (e.g. __absolute_uri__). Parse a fresh mutable copy from the cache key so a\n  // frozen input (the generated eventFormatSchema) stays untouched.\n  const mutable = JSON.parse(key) as Record<string, unknown>;\n  // Pin draft 2020-12 (the contract authoring draft).\n  const validator = new cfworker.Validator(mutable, '2020-12');\n  validatorCache.set(key, validator);\n  return validator;\n}\n\nfunction isContractRule(source: ContractSource): source is Flow.ContractRule {\n  if (typeof source !== 'object' || source === null) return false;\n  const hasEvents =\n    'events' in source &&\n    typeof source.events === 'object' &&\n    source.events !== null;\n  return hasEvents || 'schema' in source;\n}\n\n/**\n * Selects the entity-action schema with the documented wildcard fallback:\n * entity.action → entity.* → *.action → *.*.\n */\nfunction selectEventSchema(\n  events: ValidateEvents,\n  entity: string,\n  action: string,\n): Record<string, unknown> | undefined {\n  return (\n    events[entity]?.[action] ??\n    events[entity]?.['*'] ??\n    events['*']?.[action] ??\n    events['*']?.['*']\n  );\n}\n\n/** Collects every JSON Schema that applies to this event. */\nfunction collectSchemas(\n  event: WalkerOS.DeepPartialEvent,\n  opts: { contracts?: ContractSource[]; format?: boolean },\n): Record<string, unknown>[] {\n  const schemas: Record<string, unknown>[] = [];\n\n  if (opts.format) schemas.push(eventFormatSchema);\n\n  for (const source of opts.contracts ?? []) {\n    if (isContractRule(source)) {\n      const entity = typeof event.entity === 'string' ? event.entity : '';\n      const action = typeof event.action === 'string' ? event.action : '';\n      const selected = selectEventSchema(source.events ?? {}, entity, action);\n      if (selected) schemas.push(selected);\n      if (source.schema) schemas.push(source.schema);\n    } else {\n      // Inline whole-event JSON Schema.\n      schemas.push(source);\n    }\n  }\n\n  return schemas;\n}\n\n/**\n * The validation verdict authority. Runs the event through every applicable\n * JSON Schema (AND semantics) and aggregates all @cfworker errors.\n *\n * No matching constraint (empty schema set) means no opinion: isValid is true.\n */\nexport function validateEventAgainstContract(\n  event: WalkerOS.DeepPartialEvent,\n  _ingest: Ingest | undefined,\n  opts: { contracts?: ContractSource[]; format?: boolean },\n): { isValid: boolean; errors: ValidationIssue[] } {\n  const schemas = collectSchemas(event, opts);\n\n  const errors: ValidationIssue[] = [];\n  for (const schema of schemas) {\n    const result = getValidator(schema).validate(event);\n    if (!result.valid) {\n      for (const unit of result.errors) {\n        errors.push({\n          path: unit.instanceLocation,\n          message: unit.error,\n          level: 'error',\n        });\n      }\n    }\n  }\n\n  return { isValid: errors.length === 0, errors };\n}\n","// GENERATED by scripts/generate-format-schema.mjs: DO NOT EDIT.\n// Source: @walkeros/core partialEventJsonSchema (canonical zod EventSchema).\n// `format: true` validates that the value is a valid WalkerOS.PartialEvent:\n// the canonical event structure with all fields optional, so it checks shape\n// and field types, not presence. Required-field enforcement is the contract\n// arm's job (events/schema with required).\n// Regenerate: npm run generate:format-schema\n\nexport const eventFormatSchema = Object.freeze({\n  $schema: 'http://json-schema.org/draft-07/schema#',\n  description: 'Partial event structure with all fields optional',\n  allOf: [\n    {\n      $ref: '#/definitions/WalkerOSPartialEvent',\n    },\n  ],\n  definitions: {\n    WalkerOSProperty: {\n      title: 'WalkerOS.Property',\n      description:\n        'PropertyType or an array of PropertyType. Recursive structure for nested objects and arrays.',\n      anyOf: [\n        {\n          $ref: '#/definitions/WalkerOSPropertyType',\n        },\n        {\n          type: 'array',\n          items: {\n            $ref: '#/definitions/WalkerOSPropertyType',\n          },\n        },\n      ],\n    },\n    WalkerOSPropertyType: {\n      title: 'WalkerOS.PropertyType',\n      description:\n        'Base property value types (boolean, string, number, or nested Property record).',\n      anyOf: [\n        {\n          type: 'boolean',\n        },\n        {\n          type: 'string',\n        },\n        {\n          type: 'number',\n        },\n        {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            $ref: '#/definitions/WalkerOSProperty',\n          },\n        },\n      ],\n    },\n    WalkerOSProperties: {\n      type: 'object',\n      propertyNames: {\n        type: 'string',\n      },\n      additionalProperties: {\n        allOf: [\n          {\n            $ref: '#/definitions/WalkerOSProperty',\n          },\n        ],\n      },\n      title: 'WalkerOS.Properties',\n      description: 'Flexible property collection with optional values.',\n    },\n    WalkerOSOrderedProperties: {\n      type: 'object',\n      propertyNames: {\n        type: 'string',\n      },\n      additionalProperties: {\n        type: 'array',\n        items: [\n          {\n            $ref: '#/definitions/WalkerOSProperty',\n          },\n          {\n            type: 'number',\n          },\n        ],\n      },\n      title: 'WalkerOS.OrderedProperties',\n      description:\n        'Ordered properties with [value, order] tuples for priority control.',\n    },\n    WalkerOSUser: {\n      allOf: [\n        {\n          description: 'Flexible property collection with optional values',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSProperties',\n            },\n          ],\n        },\n        {\n          type: 'object',\n          properties: {\n            id: {\n              description: 'User identifier',\n              type: 'string',\n            },\n            device: {\n              description: 'Device identifier',\n              type: 'string',\n            },\n            session: {\n              description: 'Session identifier',\n              type: 'string',\n            },\n            hash: {\n              description: 'Hashed identifier',\n              type: 'string',\n            },\n            address: {\n              description: 'User address',\n              type: 'string',\n            },\n            email: {\n              description: 'User email address',\n              type: 'string',\n              format: 'email',\n              pattern:\n                \"^(?!\\\\.)(?!.*\\\\.\\\\.)([A-Za-z0-9_'+\\\\-\\\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\\\-]*\\\\.)+[A-Za-z]{2,}$\",\n            },\n            phone: {\n              description: 'User phone number',\n              type: 'string',\n            },\n            userAgent: {\n              description: 'Browser user agent string',\n              type: 'string',\n            },\n            browser: {\n              description: 'Browser name',\n              type: 'string',\n            },\n            browserVersion: {\n              description: 'Browser version',\n              type: 'string',\n            },\n            deviceType: {\n              description: 'Device type (mobile, desktop, tablet)',\n              type: 'string',\n            },\n            os: {\n              description: 'Operating system',\n              type: 'string',\n            },\n            osVersion: {\n              description: 'Operating system version',\n              type: 'string',\n            },\n            screenSize: {\n              description: 'Screen dimensions',\n              type: 'string',\n            },\n            language: {\n              description: 'User language',\n              type: 'string',\n            },\n            country: {\n              description: 'User country',\n              type: 'string',\n            },\n            region: {\n              description: 'User region/state',\n              type: 'string',\n            },\n            city: {\n              description: 'User city',\n              type: 'string',\n            },\n            zip: {\n              description: 'User postal code',\n              type: 'string',\n            },\n            timezone: {\n              description: 'User timezone',\n              type: 'string',\n            },\n            ip: {\n              description: 'User IP address',\n              type: 'string',\n            },\n            internal: {\n              description: 'Internal user flag (employee, test user)',\n              type: 'boolean',\n            },\n          },\n          additionalProperties: false,\n        },\n      ],\n      title: 'WalkerOS.User',\n      description: 'User identification and attributes.',\n    },\n    __schema0: {\n      description: 'Nested entity structure with recursive nesting support',\n      $ref: '#/definitions/WalkerOSEntity',\n    },\n    WalkerOSEntity: {\n      title: 'WalkerOS.Entity',\n      description: 'Nested entity structure with recursive nesting support.',\n      type: 'object',\n      properties: {\n        entity: {\n          type: 'string',\n          description: 'Entity name',\n        },\n        data: {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            allOf: [\n              {\n                $ref: '#/definitions/WalkerOSProperty',\n              },\n            ],\n          },\n          title: 'WalkerOS.Properties',\n          description: 'Entity-specific properties',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSProperties',\n            },\n          ],\n        },\n        nested: {\n          description: 'Nested child entities',\n          type: 'array',\n          items: {\n            $ref: '#/definitions/__schema0',\n          },\n        },\n        context: {\n          description: 'Entity context data',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSOrderedProperties',\n            },\n          ],\n        },\n      },\n      required: ['entity', 'data'],\n      additionalProperties: false,\n    },\n    WalkerOSEntities: {\n      type: 'array',\n      items: {\n        $ref: '#/definitions/__schema0',\n      },\n      title: 'WalkerOS.Entities',\n      description: 'Array of nested entities.',\n    },\n    WalkerOSConsent: {\n      type: 'object',\n      propertyNames: {\n        type: 'string',\n      },\n      additionalProperties: {\n        type: 'boolean',\n      },\n      title: 'WalkerOS.Consent',\n      description:\n        'Consent state mapping. Keys are consent groups (e.g. marketing, functional), values are booleans for granted/denied.',\n    },\n    WalkerOSSource: {\n      allOf: [\n        {\n          description: 'Flexible property collection with optional values',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSProperties',\n            },\n          ],\n        },\n        {\n          type: 'object',\n          properties: {\n            type: {\n              type: 'string',\n              description: 'Source kind (browser, dataLayer, gtag, ...)',\n            },\n            platform: {\n              description:\n                'Runtime platform (web, server, app, ios, android, terminal, ...)',\n              type: 'string',\n            },\n            version: {\n              description: 'Deployment version of the source emitter',\n              type: 'string',\n            },\n            schema: {\n              description:\n                'Event model spec version (collector defaults to \"4\")',\n              type: 'string',\n            },\n            count: {\n              description: 'Emission sequence per run',\n              type: 'integer',\n              minimum: 0,\n              maximum: 9007199254740991,\n            },\n            trace: {\n              description:\n                'Trace id shared by every event of a run (W3C trace-id shape)',\n              type: 'string',\n            },\n            release: {\n              description:\n                'Per-flow config release map, keyed by flow name; accumulates across walkerOS crossings',\n              type: 'object',\n              propertyNames: {\n                type: 'string',\n              },\n              additionalProperties: {\n                type: 'string',\n              },\n            },\n            url: {\n              type: 'string',\n            },\n            referrer: {\n              type: 'string',\n            },\n            tool: {\n              type: 'string',\n            },\n            command: {\n              type: 'string',\n            },\n          },\n          required: ['type'],\n          additionalProperties: false,\n        },\n      ],\n      title: 'WalkerOS.Source',\n      description: 'Event source information (origin of the event).',\n    },\n    WalkerOSPartialEvent: {\n      type: 'object',\n      properties: {\n        name: {\n          type: 'string',\n          description:\n            'Event name in \"entity action\" format (e.g., \"page view\", \"product add\")',\n        },\n        data: {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            allOf: [\n              {\n                $ref: '#/definitions/WalkerOSProperty',\n              },\n            ],\n          },\n          title: 'WalkerOS.Properties',\n          description: 'Event-specific properties',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSProperties',\n            },\n          ],\n        },\n        context: {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            type: 'array',\n            items: [\n              {\n                $ref: '#/definitions/WalkerOSProperty',\n              },\n              {\n                type: 'number',\n              },\n            ],\n          },\n          title: 'WalkerOS.OrderedProperties',\n          description: 'Ordered context properties with priorities',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSOrderedProperties',\n            },\n          ],\n        },\n        globals: {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            allOf: [\n              {\n                $ref: '#/definitions/WalkerOSProperty',\n              },\n            ],\n          },\n          title: 'WalkerOS.Properties',\n          description: 'Global properties shared across events',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSProperties',\n            },\n          ],\n        },\n        custom: {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            allOf: [\n              {\n                $ref: '#/definitions/WalkerOSProperty',\n              },\n            ],\n          },\n          title: 'WalkerOS.Properties',\n          description: 'Custom implementation-specific properties',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSProperties',\n            },\n          ],\n        },\n        user: {\n          allOf: [\n            {\n              description: 'Flexible property collection with optional values',\n              allOf: [\n                {\n                  $ref: '#/definitions/WalkerOSProperties',\n                },\n              ],\n            },\n            {\n              type: 'object',\n              properties: {\n                id: {\n                  description: 'User identifier',\n                  type: 'string',\n                },\n                device: {\n                  description: 'Device identifier',\n                  type: 'string',\n                },\n                session: {\n                  description: 'Session identifier',\n                  type: 'string',\n                },\n                hash: {\n                  description: 'Hashed identifier',\n                  type: 'string',\n                },\n                address: {\n                  description: 'User address',\n                  type: 'string',\n                },\n                email: {\n                  description: 'User email address',\n                  type: 'string',\n                  format: 'email',\n                  pattern:\n                    \"^(?!\\\\.)(?!.*\\\\.\\\\.)([A-Za-z0-9_'+\\\\-\\\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\\\-]*\\\\.)+[A-Za-z]{2,}$\",\n                },\n                phone: {\n                  description: 'User phone number',\n                  type: 'string',\n                },\n                userAgent: {\n                  description: 'Browser user agent string',\n                  type: 'string',\n                },\n                browser: {\n                  description: 'Browser name',\n                  type: 'string',\n                },\n                browserVersion: {\n                  description: 'Browser version',\n                  type: 'string',\n                },\n                deviceType: {\n                  description: 'Device type (mobile, desktop, tablet)',\n                  type: 'string',\n                },\n                os: {\n                  description: 'Operating system',\n                  type: 'string',\n                },\n                osVersion: {\n                  description: 'Operating system version',\n                  type: 'string',\n                },\n                screenSize: {\n                  description: 'Screen dimensions',\n                  type: 'string',\n                },\n                language: {\n                  description: 'User language',\n                  type: 'string',\n                },\n                country: {\n                  description: 'User country',\n                  type: 'string',\n                },\n                region: {\n                  description: 'User region/state',\n                  type: 'string',\n                },\n                city: {\n                  description: 'User city',\n                  type: 'string',\n                },\n                zip: {\n                  description: 'User postal code',\n                  type: 'string',\n                },\n                timezone: {\n                  description: 'User timezone',\n                  type: 'string',\n                },\n                ip: {\n                  description: 'User IP address',\n                  type: 'string',\n                },\n                internal: {\n                  description: 'Internal user flag (employee, test user)',\n                  type: 'boolean',\n                },\n              },\n              additionalProperties: false,\n            },\n          ],\n          title: 'WalkerOS.User',\n          description: 'User identification and attributes',\n        },\n        nested: {\n          type: 'array',\n          items: {\n            $ref: '#/definitions/__schema0',\n          },\n          title: 'WalkerOS.Entities',\n          description: 'Related nested entities',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSEntities',\n            },\n          ],\n        },\n        consent: {\n          type: 'object',\n          propertyNames: {\n            type: 'string',\n          },\n          additionalProperties: {\n            type: 'boolean',\n          },\n          title: 'WalkerOS.Consent',\n          description: 'Consent states at event time',\n          allOf: [\n            {\n              $ref: '#/definitions/WalkerOSConsent',\n            },\n          ],\n        },\n        id: {\n          type: 'string',\n          minLength: 1,\n          description: 'W3C span_id, 16 lowercase hex characters',\n        },\n        trigger: {\n          type: 'string',\n          description: 'Event trigger identifier',\n        },\n        entity: {\n          type: 'string',\n          description: 'Parsed entity from event name',\n        },\n        action: {\n          type: 'string',\n          description: 'Parsed action from event name',\n        },\n        timestamp: {\n          type: 'integer',\n          exclusiveMinimum: 0,\n          maximum: 9007199254740991,\n          description: 'Unix timestamp in milliseconds since epoch',\n        },\n        timing: {\n          type: 'number',\n          description: 'Event processing timing information',\n        },\n        source: {\n          allOf: [\n            {\n              description: 'Flexible property collection with optional values',\n              allOf: [\n                {\n                  $ref: '#/definitions/WalkerOSProperties',\n                },\n              ],\n            },\n            {\n              type: 'object',\n              properties: {\n                type: {\n                  type: 'string',\n                  description: 'Source kind (browser, dataLayer, gtag, ...)',\n                },\n                platform: {\n                  description:\n                    'Runtime platform (web, server, app, ios, android, terminal, ...)',\n                  type: 'string',\n                },\n                version: {\n                  description: 'Deployment version of the source emitter',\n                  type: 'string',\n                },\n                schema: {\n                  description:\n                    'Event model spec version (collector defaults to \"4\")',\n                  type: 'string',\n                },\n                count: {\n                  description: 'Emission sequence per run',\n                  type: 'integer',\n                  minimum: 0,\n                  maximum: 9007199254740991,\n                },\n                trace: {\n                  description:\n                    'Trace id shared by every event of a run (W3C trace-id shape)',\n                  type: 'string',\n                },\n                release: {\n                  description:\n                    'Per-flow config release map, keyed by flow name; accumulates across walkerOS crossings',\n                  type: 'object',\n                  propertyNames: {\n                    type: 'string',\n                  },\n                  additionalProperties: {\n                    type: 'string',\n                  },\n                },\n                url: {\n                  type: 'string',\n                },\n                referrer: {\n                  type: 'string',\n                },\n                tool: {\n                  type: 'string',\n                },\n                command: {\n                  type: 'string',\n                },\n              },\n              required: ['type'],\n              additionalProperties: false,\n            },\n          ],\n          title: 'WalkerOS.Source',\n          description: 'Event source information',\n        },\n      },\n      additionalProperties: false,\n      title: 'WalkerOS.PartialEvent',\n      description: 'Partial event structure with all fields optional.',\n    },\n  },\n} as const);\n"],"mappings":";AACA,SAAS,iBAAiB;;;ACA1B,YAAY,cAAc;;;ACOnB,IAAM,oBAAoB,OAAO,OAAO;AAAA,EAC7C,SAAS;AAAA,EACT,aAAa;AAAA,EACb,OAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,aAAa;AAAA,IACX,kBAAkB;AAAA,MAChB,OAAO;AAAA,MACP,aACE;AAAA,MACF,OAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,QACR;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,YACL,MAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,sBAAsB;AAAA,MACpB,OAAO;AAAA,MACP,aACE;AAAA,MACF,OAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,QACR;AAAA,QACA;AAAA,UACE,MAAM;AAAA,QACR;AAAA,QACA;AAAA,UACE,MAAM;AAAA,QACR;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,eAAe;AAAA,YACb,MAAM;AAAA,UACR;AAAA,UACA,sBAAsB;AAAA,YACpB,MAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,eAAe;AAAA,QACb,MAAM;AAAA,MACR;AAAA,MACA,sBAAsB;AAAA,QACp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