{"version":3,"file":"message_serialization-B5pQmmM8.cjs","names":[],"sources":["../lib/errors.js","../lib/message_serialization.js"],"sourcesContent":["// Copyright (c) 2025 Mahmoud Alghalayini. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Base error class for all rclnodejs errors.\n * Provides structured error information with context.\n * @class\n */\nclass RclNodeError extends Error {\n  /**\n   * @param {string} message - Human-readable error message\n   * @param {object} [options] - Additional error context\n   * @param {string} [options.code] - Machine-readable error code (e.g., 'TIMEOUT', 'INVALID_ARGUMENT')\n   * @param {string} [options.nodeName] - Name of the node where error occurred\n   * @param {string} [options.entityType] - Type of entity (publisher, subscription, client, etc.)\n   * @param {string} [options.entityName] - Name of the entity (topic name, service name, etc.)\n   * @param {Error} [options.cause] - Original error that caused this error\n   * @param {any} [options.details] - Additional error-specific details\n   */\n  constructor(message, options = {}) {\n    super(message);\n\n    // Maintains proper stack trace for where our error was thrown\n    Error.captureStackTrace(this, this.constructor);\n\n    this.name = this.constructor.name;\n    this.code = options.code || 'UNKNOWN_ERROR';\n    this.nodeName = options.nodeName;\n    this.entityType = options.entityType;\n    this.entityName = options.entityName;\n    this.details = options.details;\n\n    // Error chaining (ES2022 feature, Node.js 16.9+)\n    if (options.cause) {\n      this.cause = options.cause;\n    }\n\n    // Timestamp for logging/debugging\n    this.timestamp = new Date();\n  }\n\n  /**\n   * Returns a detailed error object for logging/serialization\n   * @return {object} Structured error information\n   */\n  toJSON() {\n    return {\n      name: this.name,\n      message: this.message,\n      code: this.code,\n      nodeName: this.nodeName,\n      entityType: this.entityType,\n      entityName: this.entityName,\n      details: this.details,\n      timestamp: this.timestamp.toISOString(),\n      stack: this.stack,\n      cause: this.cause\n        ? this.cause.toJSON?.() || this.cause.message\n        : undefined,\n    };\n  }\n\n  /**\n   * Returns a user-friendly error description\n   * @return {string} Formatted error string\n   */\n  toString() {\n    let str = `${this.name}: ${this.message}`;\n    if (this.code) str += ` [${this.code}]`;\n    if (this.nodeName) str += ` (node: ${this.nodeName})`;\n    if (this.entityName)\n      str += ` (${this.entityType || 'entity'}: ${this.entityName})`;\n    return str;\n  }\n}\n\n/**\n * Error thrown when validation fails\n * @class\n * @extends RclNodeError\n */\nclass ValidationError extends RclNodeError {\n  /**\n   * @param {string} message - Error message\n   * @param {object} [options] - Additional options\n   * @param {string} [options.argumentName] - Name of the argument that failed validation\n   * @param {any} [options.providedValue] - The value that was provided\n   * @param {string} [options.expectedType] - The expected type or format\n   * @param {string} [options.validationRule] - The validation rule that failed\n   */\n  constructor(message, options = {}) {\n    super(message, { code: 'VALIDATION_ERROR', ...options });\n    this.argumentName = options.argumentName;\n    this.providedValue = options.providedValue;\n    this.expectedType = options.expectedType;\n    this.validationRule = options.validationRule;\n  }\n}\n\n/**\n * Type validation error\n * @class\n * @extends ValidationError\n */\nclass TypeValidationError extends ValidationError {\n  /**\n   * @param {string} argumentName - Name of the argument\n   * @param {any} providedValue - The value that was provided\n   * @param {string} expectedType - The expected type\n   * @param {object} [options] - Additional options\n   */\n  constructor(argumentName, providedValue, expectedType, options = {}) {\n    super(\n      `Invalid type for '${argumentName}': expected ${expectedType}, got ${typeof providedValue}`,\n      {\n        code: 'INVALID_TYPE',\n        argumentName,\n        providedValue,\n        expectedType,\n        ...options,\n      }\n    );\n  }\n}\n\n/**\n * Range/value validation error\n * @class\n * @extends ValidationError\n */\nclass RangeValidationError extends ValidationError {\n  /**\n   * @param {string} argumentName - Name of the argument\n   * @param {any} providedValue - The value that was provided\n   * @param {string} constraint - The constraint that was violated\n   * @param {object} [options] - Additional options\n   */\n  constructor(argumentName, providedValue, constraint, options = {}) {\n    super(\n      `Value '${providedValue}' for '${argumentName}' is out of range: ${constraint}`,\n      {\n        code: 'OUT_OF_RANGE',\n        argumentName,\n        providedValue,\n        validationRule: constraint,\n        ...options,\n      }\n    );\n  }\n}\n\n/**\n * Message validation error for ROS message structure/type issues\n * @class\n * @extends ValidationError\n */\nclass MessageValidationError extends ValidationError {\n  /**\n   * @param {string} messageType - The ROS message type (e.g., 'std_msgs/msg/String')\n   * @param {Array<object>} issues - Array of validation issues\n   * @param {string} issues[].field - Field path where issue occurred\n   * @param {string} issues[].problem - Problem type (UNKNOWN_FIELD, TYPE_MISMATCH, etc.)\n   * @param {string} [issues[].expected] - Expected type or value\n   * @param {any} [issues[].received] - Actual value received\n   * @param {object} [options] - Additional options\n   */\n  constructor(messageType, issues, options = {}) {\n    const issuesSummary = issues\n      .map((i) => `${i.field}: ${i.problem}`)\n      .join(', ');\n    super(`Invalid message for '${messageType}': ${issuesSummary}`, {\n      code: 'MESSAGE_VALIDATION_ERROR',\n      entityType: 'message',\n      entityName: messageType,\n      details: { issues },\n      ...options,\n    });\n    this.messageType = messageType;\n    this.issues = issues;\n  }\n\n  /**\n   * Get issues filtered by problem type\n   * @param {string} problemType - Problem type to filter by\n   * @returns {Array<object>} Filtered issues\n   */\n  getIssuesByType(problemType) {\n    return this.issues.filter((i) => i.problem === problemType);\n  }\n\n  /**\n   * Check if a specific field has validation issues\n   * @param {string} fieldPath - Field path to check\n   * @returns {boolean} True if field has issues\n   */\n  hasFieldIssue(fieldPath) {\n    return this.issues.some((i) => i.field === fieldPath);\n  }\n}\n\n/**\n * ROS name validation error (topics, nodes, services)\n * @class\n * @extends ValidationError\n */\nclass NameValidationError extends ValidationError {\n  /**\n   * @param {string} name - The invalid name\n   * @param {string} nameType - Type of name (node, topic, service, etc.)\n   * @param {string} validationResult - The validation error message\n   * @param {number} invalidIndex - Index where validation failed\n   * @param {object} [options] - Additional options\n   */\n  constructor(name, nameType, validationResult, invalidIndex, options = {}) {\n    super(\n      `Invalid ${nameType} name '${name}': ${validationResult}` +\n        (invalidIndex >= 0 ? ` at index ${invalidIndex}` : ''),\n      {\n        code: 'INVALID_NAME',\n        argumentName: nameType,\n        providedValue: name,\n        details: { validationResult, invalidIndex },\n        ...options,\n      }\n    );\n    this.invalidIndex = invalidIndex;\n    this.validationResult = validationResult;\n  }\n}\n\n/**\n * Base class for operation/runtime errors\n * @class\n * @extends RclNodeError\n */\nclass OperationError extends RclNodeError {\n  /**\n   * @param {string} message - Error message\n   * @param {object} [options] - Additional options\n   */\n  constructor(message, options = {}) {\n    super(message, { code: 'OPERATION_ERROR', ...options });\n  }\n}\n\n/**\n * Request timeout error\n * @class\n * @extends OperationError\n */\nclass TimeoutError extends OperationError {\n  /**\n   * @param {string} operationType - Type of operation that timed out\n   * @param {number} timeoutMs - Timeout duration in milliseconds\n   * @param {object} [options] - Additional options\n   */\n  constructor(operationType, timeoutMs, options = {}) {\n    super(`${operationType} timeout after ${timeoutMs}ms`, {\n      code: 'TIMEOUT',\n      details: { timeoutMs, operationType },\n      ...options,\n    });\n    this.timeout = timeoutMs;\n    this.operationType = operationType;\n  }\n}\n\n/**\n * Request abortion error\n * @class\n * @extends OperationError\n */\nclass AbortError extends OperationError {\n  /**\n   * @param {string} operationType - Type of operation that was aborted\n   * @param {string} [reason] - Reason for abortion\n   * @param {object} [options] - Additional options\n   */\n  constructor(operationType, reason, options = {}) {\n    super(`${operationType} was aborted` + (reason ? `: ${reason}` : ''), {\n      code: 'ABORTED',\n      details: { operationType, reason },\n      ...options,\n    });\n    this.operationType = operationType;\n    this.abortReason = reason;\n  }\n}\n\n/**\n * Service not available error\n * @class\n * @extends OperationError\n */\nclass ServiceNotFoundError extends OperationError {\n  /**\n   * @param {string} serviceName - Name of the service\n   * @param {object} [options] - Additional options\n   */\n  constructor(serviceName, options = {}) {\n    super(`Service '${serviceName}' is not available`, {\n      code: 'SERVICE_NOT_FOUND',\n      entityType: 'service',\n      entityName: serviceName,\n      ...options,\n    });\n    this.serviceName = serviceName;\n  }\n}\n\n/**\n * Remote node not found error\n * @class\n * @extends OperationError\n */\nclass NodeNotFoundError extends OperationError {\n  /**\n   * @param {string} nodeName - Name of the node\n   * @param {object} [options] - Additional options\n   */\n  constructor(nodeName, options = {}) {\n    super(`Node '${nodeName}' not found or not available`, {\n      code: 'NODE_NOT_FOUND',\n      entityType: 'node',\n      entityName: nodeName,\n      ...options,\n    });\n    this.targetNodeName = nodeName;\n  }\n}\n\n/**\n * Base error for parameter operations\n * @class\n * @extends RclNodeError\n */\nclass ParameterError extends RclNodeError {\n  /**\n   * @param {string} message - Error message\n   * @param {string} parameterName - Name of the parameter\n   * @param {object} [options] - Additional options\n   */\n  constructor(message, parameterName, options = {}) {\n    super(message, {\n      code: 'PARAMETER_ERROR',\n      entityType: 'parameter',\n      entityName: parameterName,\n      ...options,\n    });\n    this.parameterName = parameterName;\n  }\n}\n\n/**\n * Parameter not found error\n * @class\n * @extends ParameterError\n */\nclass ParameterNotFoundError extends ParameterError {\n  /**\n   * @param {string} parameterName - Name of the parameter\n   * @param {string} nodeName - Name of the node\n   * @param {object} [options] - Additional options\n   */\n  constructor(parameterName, nodeName, options = {}) {\n    super(\n      `Parameter '${parameterName}' not found on node '${nodeName}'`,\n      parameterName,\n      {\n        code: 'PARAMETER_NOT_FOUND',\n        nodeName,\n        ...options,\n      }\n    );\n  }\n}\n\n/**\n * Parameter type mismatch error\n * @class\n * @extends ParameterError\n */\nclass ParameterTypeError extends ParameterError {\n  /**\n   * @param {string} parameterName - Name of the parameter\n   * @param {string} expectedType - Expected parameter type\n   * @param {string} actualType - Actual parameter type\n   * @param {object} [options] - Additional options\n   */\n  constructor(parameterName, expectedType, actualType, options = {}) {\n    super(\n      `Type mismatch for parameter '${parameterName}': expected ${expectedType}, got ${actualType}`,\n      parameterName,\n      {\n        code: 'PARAMETER_TYPE_MISMATCH',\n        details: { expectedType, actualType },\n        ...options,\n      }\n    );\n    this.expectedType = expectedType;\n    this.actualType = actualType;\n  }\n}\n\n/**\n * Read-only parameter modification error\n * @class\n * @extends ParameterError\n */\nclass ReadOnlyParameterError extends ParameterError {\n  /**\n   * @param {string} parameterName - Name of the parameter\n   * @param {object} [options] - Additional options\n   */\n  constructor(parameterName, options = {}) {\n    super(\n      `Cannot modify read-only parameter '${parameterName}'`,\n      parameterName,\n      {\n        code: 'PARAMETER_READ_ONLY',\n        ...options,\n      }\n    );\n  }\n}\n\n/**\n * Base error for topic operations\n * @class\n * @extends RclNodeError\n */\nclass TopicError extends RclNodeError {\n  /**\n   * @param {string} message - Error message\n   * @param {string} topicName - Name of the topic\n   * @param {object} [options] - Additional options\n   */\n  constructor(message, topicName, options = {}) {\n    super(message, {\n      code: 'TOPIC_ERROR',\n      entityType: 'topic',\n      entityName: topicName,\n      ...options,\n    });\n    this.topicName = topicName;\n  }\n}\n\n/**\n * Publisher-specific error\n * @class\n * @extends TopicError\n */\nclass PublisherError extends TopicError {\n  /**\n   * @param {string} message - Error message\n   * @param {string} topicName - Name of the topic\n   * @param {object} [options] - Additional options\n   */\n  constructor(message, topicName, options = {}) {\n    super(message, topicName, {\n      code: 'PUBLISHER_ERROR',\n      entityType: 'publisher',\n      ...options,\n    });\n  }\n}\n\n/**\n * Subscription-specific error\n * @class\n * @extends TopicError\n */\nclass SubscriptionError extends TopicError {\n  /**\n   * @param {string} message - Error message\n   * @param {string} topicName - Name of the topic\n   * @param {object} [options] - Additional options\n   */\n  constructor(message, topicName, options = {}) {\n    super(message, topicName, {\n      code: 'SUBSCRIPTION_ERROR',\n      entityType: 'subscription',\n      ...options,\n    });\n  }\n}\n\n/**\n * Base error for action operations\n * @class\n * @extends RclNodeError\n */\nclass ActionError extends RclNodeError {\n  /**\n   * @param {string} message - Error message\n   * @param {string} actionName - Name of the action\n   * @param {object} [options] - Additional options\n   */\n  constructor(message, actionName, options = {}) {\n    super(message, {\n      code: 'ACTION_ERROR',\n      entityType: 'action',\n      entityName: actionName,\n      ...options,\n    });\n    this.actionName = actionName;\n  }\n}\n\n/**\n * Goal rejected by action server\n * @class\n * @extends ActionError\n */\nclass GoalRejectedError extends ActionError {\n  /**\n   * @param {string} actionName - Name of the action\n   * @param {string} goalId - ID of the rejected goal\n   * @param {object} [options] - Additional options\n   */\n  constructor(actionName, goalId, options = {}) {\n    super(`Goal rejected by action server '${actionName}'`, actionName, {\n      code: 'GOAL_REJECTED',\n      details: { goalId },\n      ...options,\n    });\n    this.goalId = goalId;\n  }\n}\n\n/**\n * Action server not found\n * @class\n * @extends ActionError\n */\nclass ActionServerNotFoundError extends ActionError {\n  /**\n   * @param {string} actionName - Name of the action\n   * @param {object} [options] - Additional options\n   */\n  constructor(actionName, options = {}) {\n    super(`Action server '${actionName}' is not available`, actionName, {\n      code: 'ACTION_SERVER_NOT_FOUND',\n      ...options,\n    });\n  }\n}\n\n/**\n * Wraps errors from native C++ layer with additional context\n * @class\n * @extends RclNodeError\n */\nclass NativeError extends RclNodeError {\n  /**\n   * @param {string} nativeMessage - Error message from C++ layer\n   * @param {string} operation - Operation that failed\n   * @param {object} [options] - Additional options\n   */\n  constructor(nativeMessage, operation, options = {}) {\n    super(`Native operation failed: ${operation} - ${nativeMessage}`, {\n      code: 'NATIVE_ERROR',\n      details: { nativeMessage, operation },\n      ...options,\n    });\n    this.nativeMessage = nativeMessage;\n    this.operation = operation;\n  }\n}\n\nexport {\n  // Base error\n  RclNodeError,\n\n  // Validation errors\n  ValidationError,\n  TypeValidationError,\n  RangeValidationError,\n  MessageValidationError,\n  NameValidationError,\n\n  // Operation errors\n  OperationError,\n  TimeoutError,\n  AbortError,\n  ServiceNotFoundError,\n  NodeNotFoundError,\n\n  // Parameter errors\n  ParameterError,\n  ParameterNotFoundError,\n  ParameterTypeError,\n  ReadOnlyParameterError,\n\n  // Topic errors\n  TopicError,\n  PublisherError,\n  SubscriptionError,\n\n  // Action errors\n  ActionError,\n  GoalRejectedError,\n  ActionServerNotFoundError,\n\n  // Native error\n  NativeError,\n};\n","// Copyright (c) 2025 Mahmoud Alghalayini. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ValidationError } from './errors.js';\n\n/**\n * Check if a value is a TypedArray\n * @param {*} value - The value to check\n * @returns {boolean} True if the value is a TypedArray\n */\nfunction isTypedArray(value) {\n  return ArrayBuffer.isView(value) && !(value instanceof DataView);\n}\n\n/**\n * Check if a value needs JSON conversion (BigInt, functions, etc.)\n * @param {*} value - The value to check\n * @returns {boolean} True if the value needs special JSON handling\n */\nfunction needsJSONConversion(value) {\n  return (\n    typeof value === 'bigint' ||\n    typeof value === 'function' ||\n    typeof value === 'undefined' ||\n    value === Infinity ||\n    value === -Infinity ||\n    (typeof value === 'number' && isNaN(value))\n  );\n}\n\n/**\n * Convert a message to plain arrays (TypedArray -> regular Array)\n * @param {*} obj - The object to convert\n * @returns {*} The converted object with plain arrays\n */\nfunction toPlainArrays(obj) {\n  if (obj === null || obj === undefined) {\n    return obj;\n  }\n\n  if (isTypedArray(obj)) {\n    return Array.from(obj);\n  }\n\n  if (Array.isArray(obj)) {\n    return obj.map((item) => toPlainArrays(item));\n  }\n\n  if (typeof obj === 'object' && obj !== null) {\n    const result = {};\n    for (const key in obj) {\n      if (Object.hasOwn(obj, key)) {\n        result[key] = toPlainArrays(obj[key]);\n      }\n    }\n    return result;\n  }\n\n  return obj;\n}\n\n/**\n * Convert a message to be fully JSON-safe\n * @param {*} obj - The object to convert\n * @returns {*} The JSON-safe converted object\n */\nfunction toJSONSafe(obj) {\n  if (obj === null || obj === undefined) {\n    return obj;\n  }\n\n  if (isTypedArray(obj)) {\n    return Array.from(obj).map((item) => toJSONSafe(item));\n  }\n\n  if (needsJSONConversion(obj)) {\n    if (typeof obj === 'bigint') {\n      // Convert BigInt to string with 'n' suffix to indicate it was a BigInt\n      return obj.toString() + 'n';\n    }\n    if (obj === Infinity) return 'Infinity';\n    if (obj === -Infinity) return '-Infinity';\n    if (typeof obj === 'number' && isNaN(obj)) return 'NaN';\n    if (typeof obj === 'undefined') return null;\n    if (typeof obj === 'function') return '[Function]';\n  }\n\n  if (Array.isArray(obj)) {\n    return obj.map((item) => toJSONSafe(item));\n  }\n\n  if (typeof obj === 'object' && obj !== null) {\n    const result = {};\n    for (const key in obj) {\n      if (Object.hasOwn(obj, key)) {\n        result[key] = toJSONSafe(obj[key]);\n      }\n    }\n    return result;\n  }\n\n  return obj;\n}\n\n/**\n * Convert a message to a JSON string\n * @param {*} obj - The object to convert\n * @param {number} [space] - Space parameter for JSON.stringify formatting\n * @returns {string} The JSON string representation\n */\nfunction toJSONString(obj, space) {\n  const jsonSafeObj = toJSONSafe(obj);\n  return JSON.stringify(jsonSafeObj, null, space);\n}\n\n/**\n * Apply serialization mode conversion to a message object\n * @param {*} message - The message object to convert\n * @param {string} serializationMode - The serialization mode ('default', 'plain', 'json')\n * @returns {*} The converted message\n */\nfunction applySerializationMode(message, serializationMode) {\n  switch (serializationMode) {\n    case 'default':\n      // No conversion needed - use native rclnodejs behavior\n      return message;\n\n    case 'plain':\n      // Convert TypedArrays to regular arrays\n      return toPlainArrays(message);\n\n    case 'json':\n      // Convert to fully JSON-safe format\n      return toJSONSafe(message);\n\n    default:\n      throw new ValidationError(\n        `Invalid serializationMode: ${serializationMode}. Valid modes are: 'default', 'plain', 'json'`,\n        {\n          code: 'INVALID_SERIALIZATION_MODE',\n          argumentName: 'serializationMode',\n          providedValue: serializationMode,\n          expectedType: \"'default' | 'plain' | 'json'\",\n        }\n      );\n  }\n}\n\n/**\n * Validate serialization mode\n * @param {string} mode - The serialization mode to validate\n * @returns {boolean} True if valid\n */\nfunction isValidSerializationMode(mode) {\n  return ['default', 'plain', 'json'].includes(mode);\n}\n\n/**\n * Inverse of {@link toJSONSafe} for 64-bit integer fields.\n *\n * `toJSONSafe` encodes `bigint` as the string `\"<n>n\"` so values survive\n * `JSON.stringify`. `reviveBigInts` walks an arbitrary JSON value and\n * converts any such string back into a real `bigint`. Everything else\n * passes through unchanged. Used by the rosocket gateway and the Web\n * Runtime dispatcher to rehydrate inbound JSON before handing it to\n * rclnodejs.\n *\n * Returned objects use a null prototype and skip the well-known\n * prototype-pollution keys (`__proto__`, `constructor`, `prototype`)\n * because the input is attacker-controllable JSON arriving from a\n * remote peer.\n *\n * @param {*} value\n * @returns {*}\n */\nfunction reviveBigInts(value) {\n  if (value === null || typeof value !== 'object') {\n    if (typeof value === 'string' && /^-?\\d+n$/.test(value)) {\n      return BigInt(value.slice(0, -1));\n    }\n    return value;\n  }\n  if (Array.isArray(value)) return value.map(reviveBigInts);\n  const out = Object.create(null);\n  for (const k of Object.keys(value)) {\n    if (k === '__proto__' || k === 'constructor' || k === 'prototype') continue;\n    out[k] = reviveBigInts(value[k]);\n  }\n  return out;\n}\n\nexport {\n  isTypedArray,\n  needsJSONConversion,\n  toPlainArrays,\n  toJSONSafe,\n  toJSONString,\n  applySerializationMode,\n  isValidSerializationMode,\n  reviveBigInts,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAM,eAAN,cAA2B,MAAM;;;;;;;;;;;CAW/B,YAAY,SAAS,UAAU,CAAC,GAAG;EACjC,MAAM,OAAO;EAGb,MAAM,kBAAkB,MAAM,KAAK,WAAW;EAE9C,KAAK,OAAO,KAAK,YAAY;EAC7B,KAAK,OAAO,QAAQ,QAAQ;EAC5B,KAAK,WAAW,QAAQ;EACxB,KAAK,aAAa,QAAQ;EAC1B,KAAK,aAAa,QAAQ;EAC1B,KAAK,UAAU,QAAQ;EAGvB,IAAI,QAAQ,OACV,KAAK,QAAQ,QAAQ;EAIvB,KAAK,4BAAY,IAAI,KAAK;CAC5B;;;;;CAMA,SAAS;EACP,OAAO;GACL,MAAM,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