{"version":3,"file":"errors-C1XqxNmZ.cjs","names":["code: string","message: string","type: MessageType","options: {\n      readonly path?: string;\n      readonly contentType?: ContentType;\n      readonly messages?: readonly UCPMessage[];\n    }","continue_url: string","statusCode: number"],"sources":["../src/errors.ts"],"sourcesContent":["export type MessageType = 'error' | 'warning' | 'info';\nexport type MessageSeverity =\n  | 'recoverable'\n  | 'requires_buyer_input'\n  | 'requires_buyer_review'\n  | 'unrecoverable';\nexport type ContentType = 'plain' | 'markdown';\n\n/** A single message from the gateway's `messages[]` array. */\nexport interface UCPMessage {\n  readonly type: MessageType;\n  readonly code?: string;\n  readonly content: string;\n  readonly severity?: MessageSeverity;\n  /** JSONPath to the field that caused the error (e.g., `$.buyer.email`). */\n  readonly path?: string;\n  readonly content_type?: ContentType;\n}\n\n/** Thrown when the gateway returns an error response with `messages[]`. */\nexport class UCPError extends Error {\n  readonly code: string;\n  readonly type: MessageType;\n  readonly statusCode: number;\n  /** JSONPath to the field that caused the error, from the first message. */\n  readonly path: string | undefined;\n  readonly contentType: ContentType | undefined;\n  /** All messages from the gateway response. */\n  readonly messages: readonly UCPMessage[];\n\n  constructor(\n    code: string,\n    message: string,\n    type: MessageType = 'error',\n    statusCode = 400,\n    options: {\n      readonly path?: string;\n      readonly contentType?: ContentType;\n      readonly messages?: readonly UCPMessage[];\n    } = {},\n  ) {\n    super(message);\n    this.name = 'UCPError';\n    this.code = code;\n    this.type = type;\n    this.statusCode = statusCode;\n    this.path = options.path;\n    this.contentType = options.contentType;\n    this.messages = options.messages ?? [];\n  }\n}\n\n/** Thrown on HTTP 409 when no `messages[]` body is present (idempotency key collision). */\nexport class UCPIdempotencyConflictError extends UCPError {\n  constructor(message = 'Idempotency key reused with different request body') {\n    super('IDEMPOTENCY_CONFLICT', message, 'error', 409);\n    this.name = 'UCPIdempotencyConflictError';\n  }\n}\n\n/** Thrown when a checkout response has `status: 'requires_escalation'` with a `continue_url`. */\nexport class UCPEscalationError extends Error {\n  /** The URL to redirect the buyer to for merchant-hosted checkout UI. */\n  readonly continue_url: string;\n\n  constructor(continue_url: string, message = 'Payment requires escalation') {\n    super(message);\n    this.name = 'UCPEscalationError';\n    this.continue_url = continue_url;\n  }\n}\n\n/** Thrown when an OAuth token exchange, refresh, or revocation fails. */\nexport class UCPOAuthError extends Error {\n  readonly statusCode: number;\n\n  constructor(message: string, statusCode: number) {\n    super(message);\n    this.name = 'UCPOAuthError';\n    this.statusCode = statusCode;\n  }\n}\n"],"mappings":";;;;AAoBA,IAAa,WAAb,cAA8B,MAAM;CAClC,AAAS;CACT,AAAS;CACT,AAAS;;CAET,AAAS;CACT,AAAS;;CAET,AAAS;CAET,YACEA,MACAC,SACAC,OAAoB,SACpB,aAAa,KACbC,UAII,CAAE,GACN;AACA,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,aAAa;AAClB,OAAK,OAAO,QAAQ;AACpB,OAAK,cAAc,QAAQ;AAC3B,OAAK,WAAW,QAAQ,YAAY,CAAE;CACvC;AACF;;AAGD,IAAa,8BAAb,cAAiD,SAAS;CACxD,YAAY,UAAU,sDAAsD;AAC1E,QAAM,wBAAwB,SAAS,SAAS,IAAI;AACpD,OAAK,OAAO;CACb;AACF;;AAGD,IAAa,qBAAb,cAAwC,MAAM;;CAE5C,AAAS;CAET,YAAYC,cAAsB,UAAU,+BAA+B;AACzE,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,eAAe;CACrB;AACF;;AAGD,IAAa,gBAAb,cAAmC,MAAM;CACvC,AAAS;CAET,YAAYH,SAAiBI,YAAoB;AAC/C,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,aAAa;CACnB;AACF"}