{
  "version": 3,
  "sources": ["../src/error-messages.ts"],
  "sourcesContent": ["/**\n * User-friendly error messages for upload failures.\n *\n * Provides localized, human-readable messages for all error codes\n * with actionable guidance for users.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { ErrorCode } from './upload-error';\n\n/**\n * Configuration for an error message.\n */\nexport interface ErrorMessageConfig {\n\t/** Short title describing the error type. */\n\ttitle: string;\n\t/** Detailed description of what happened. */\n\tdescription: string;\n\t/** Optional actionable guidance for the user. */\n\taction?: string;\n}\n\n/**\n * Gets a user-friendly error message configuration for an error code.\n *\n * @param code     The error code from UploadError.\n * @param fileName The name of the file that failed to upload.\n * @return Error message configuration with title, description, and action.\n */\nexport function getErrorMessage(\n\tcode: ErrorCode | string,\n\tfileName: string\n): ErrorMessageConfig {\n\tconst messages: Record< string, ErrorMessageConfig > = {\n\t\t[ ErrorCode.EMPTY_FILE ]: {\n\t\t\ttitle: __( 'Empty file' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( '\"%s\" is empty.' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Please choose a different file.' ),\n\t\t},\n\t\t[ ErrorCode.SIZE_ABOVE_LIMIT ]: {\n\t\t\ttitle: __( 'File too large' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( '\"%s\" exceeds the maximum upload size.' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Please reduce the file size and try again.' ),\n\t\t},\n\t\t[ ErrorCode.MIME_TYPE_NOT_SUPPORTED ]: {\n\t\t\ttitle: __( 'Unsupported file type' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( '\"%s\" is not a supported file type.' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Please upload a different file format.' ),\n\t\t},\n\t\t[ ErrorCode.MIME_TYPE_NOT_ALLOWED_FOR_USER ]: {\n\t\t\ttitle: __( 'File type not allowed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'You are not allowed to upload \"%s\".' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Please contact your site administrator.' ),\n\t\t},\n\t\t[ ErrorCode.HEIC_DECODE_ERROR ]: {\n\t\t\ttitle: __( 'HEIC decode failed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'Failed to decode HEIC file \"%s\".' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Try converting the image to JPEG or PNG first.' ),\n\t\t},\n\t\t[ ErrorCode.IMAGE_TRANSCODING_ERROR ]: {\n\t\t\ttitle: __( 'Image processing failed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'Failed to process \"%s\".' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'The image may be corrupted. Try a different file.' ),\n\t\t},\n\t\t[ ErrorCode.IMAGE_ROTATION_ERROR ]: {\n\t\t\ttitle: __( 'Image rotation failed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'Failed to rotate \"%s\".' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'The image may be corrupted. Try a different file.' ),\n\t\t},\n\t\t[ ErrorCode.MEDIA_TRANSCODING_ERROR ]: {\n\t\t\ttitle: __( 'Media processing failed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'Failed to convert \"%s\" to the target format.' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'The file may be corrupted. Try a different file.' ),\n\t\t},\n\t\t[ ErrorCode.GENERAL ]: {\n\t\t\ttitle: __( 'Upload failed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'Failed to upload \"%s\".' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Please try again.' ),\n\t\t},\n\t};\n\n\treturn (\n\t\tmessages[ code ] || {\n\t\t\ttitle: __( 'Upload failed' ),\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %s: file name */\n\t\t\t\t__( 'Failed to upload \"%s\".' ),\n\t\t\t\tfileName\n\t\t\t),\n\t\t\taction: __( 'Please try again.' ),\n\t\t}\n\t);\n}\n"],
  "mappings": ";AAUA,SAAS,IAAI,eAAe;AAK5B,SAAS,iBAAiB;AAqBnB,SAAS,gBACf,MACA,UACqB;AACrB,QAAM,WAAiD;AAAA,IACtD,CAAE,UAAU,UAAW,GAAG;AAAA,MACzB,OAAO,GAAI,YAAa;AAAA,MACxB,aAAa;AAAA;AAAA,QAEZ,GAAI,gBAAiB;AAAA,QACrB;AAAA,MACD;AAAA,MACA,QAAQ,GAAI,iCAAkC;AAAA,IAC/C;AAAA,IACA,CAAE,UAAU,gBAAiB,GAAG;AAAA,MAC/B,OAAO,GAAI,gBAAiB;AAAA,MAC5B,aAAa;AAAA;AAAA,QAEZ,GAAI,uCAAwC;AAAA,QAC5C;AAAA,MACD;AAAA,MACA,QAAQ,GAAI,4CAA6C;AAAA,IAC1D;AAAA,IACA,CAAE,UAAU,uBAAwB,GAAG;AAAA,MACtC,OAAO,GAAI,uBAAwB;AAAA,MACnC,aAAa;AAAA;AAAA,QAEZ,GAAI,oCAAqC;AAAA,QACzC;AAAA,MACD;AAAA,MACA,QAAQ,GAAI,wCAAyC;AAAA,IACtD;AAAA,IACA,CAAE,UAAU,8BAA+B,GAAG;AAAA,MAC7C,OAAO,GAAI,uBAAwB;AAAA,MACnC,aAAa;AAAA;AAAA,QAEZ,GAAI,qCAAsC;AAAA,QAC1C;AAAA,MACD;AAAA,MACA,QAAQ,GAAI,yCAA0C;AAAA,IACvD;AAAA,IACA,CAAE,UAAU,i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