{"version":3,"sources":["jsdelivr-header.js","/npm/@wordpress/blob@4.34.0/src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,EAAgC,GAS/B,SAAS,EAAe,GAC9B,MAAM,EAAM,OAAO,IAAI,gBAAiB,GAIjC,OAFP,EAAO,GAAQ,EAER,CACR,CAWO,SAAS,EAAc,GAC7B,OAAO,EAAO,EACf,CAWO,SAAS,EAAkB,GACjC,OAAO,EAAc,IAAO,KAAK,MAAO,KAAO,EAChD,CAOO,SAAS,EAAe,GACzB,EAAO,IACJ,OAAA,IAAI,gBAAiB,UAGtB,EAAO,EACf,CASO,SAAS,EAAW,GAC1B,SAAO,IAAS,EAAI,UAGc,IAA3B,EAAI,QAAS,QACrB,CAyBO,SAAS,EACf,EACA,EACA,EAAsB,IAEjB,IAAE,IAAc,EACpB,OAGK,MAAA,EAAO,IAAI,OAAO,KAAM,CAAE,GAAW,CAAE,KAAM,IAC7C,EAAM,OAAO,IAAI,gBAAiB,GAClC,EAAgB,SAAS,cAAe,KAC9C,EAAc,KAAO,EACrB,EAAc,SAAW,EACzB,EAAc,MAAM,QAAU,OACrB,SAAA,KAAK,YAAa,GAC3B,EAAc,QACL,SAAA,KAAK,YAAa,GACpB,OAAA,IAAI,gBAAiB,EAC7B,Q","file":"/npm/@wordpress/blob@4.34.0/build-module/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/@wordpress/blob@4.34.0/build-module/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const cache: Record< string, File > = {};\n\n/**\n * Create a blob URL from a file.\n *\n * @param file The file to create a blob URL for.\n *\n * @return The blob URL.\n */\nexport function createBlobURL( file: File ): string {\n\tconst url = window.URL.createObjectURL( file );\n\n\tcache[ url ] = file;\n\n\treturn url;\n}\n\n/**\n * Retrieve a file based on a blob URL. The file must have been created by\n * `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return\n * `undefined`.\n *\n * @param url The blob URL.\n *\n * @return The file for the blob URL.\n */\nexport function getBlobByURL( url: string ): File | undefined {\n\treturn cache[ url ];\n}\n\n/**\n * Retrieve a blob type based on URL. The file must have been created by\n * `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return\n * `undefined`.\n *\n * @param url The blob URL.\n *\n * @return The blob type.\n */\nexport function getBlobTypeByURL( url: string ): string | undefined {\n\treturn getBlobByURL( url )?.type.split( '/' )[ 0 ]; // 0: media type , 1: file extension eg ( type: 'image/jpeg' ).\n}\n\n/**\n * Remove the resource and file cache from memory.\n *\n * @param url The blob URL.\n */\nexport function revokeBlobURL( url: string ): void {\n\tif ( cache[ url ] ) {\n\t\twindow.URL.revokeObjectURL( url );\n\t}\n\n\tdelete cache[ url ];\n}\n\n/**\n * Check whether a url is a blob url.\n *\n * @param url The URL.\n *\n * @return Is the url a blob url?\n */\nexport function isBlobURL( url: string | undefined ): boolean {\n\tif ( ! url || ! url.indexOf ) {\n\t\treturn false;\n\t}\n\treturn url.indexOf( 'blob:' ) === 0;\n}\n\n/**\n * Downloads a file, e.g., a text or readable stream, in the browser.\n * Appropriate for downloading smaller file sizes, e.g., < 5 MB.\n *\n * Example usage:\n *\n * ```js\n * \tconst fileContent = JSON.stringify(\n * \t\t{\n * \t\t\t\"title\": \"My Post\",\n * \t\t},\n * \t\tnull,\n * \t\t2\n * \t);\n * \tconst filename = 'file.json';\n *\n * \tdownloadBlob( filename, fileContent, 'application/json' );\n * ```\n *\n * @param filename    File name.\n * @param content     File content (BufferSource | Blob | string).\n * @param contentType (Optional) File mime type. Default is `''`.\n */\nexport function downloadBlob(\n\tfilename: string,\n\tcontent: BlobPart,\n\tcontentType: string = ''\n): void {\n\tif ( ! filename || ! content ) {\n\t\treturn;\n\t}\n\n\tconst file = new window.Blob( [ content ], { type: contentType } );\n\tconst url = window.URL.createObjectURL( file );\n\tconst anchorElement = document.createElement( 'a' );\n\tanchorElement.href = url;\n\tanchorElement.download = filename;\n\tanchorElement.style.display = 'none';\n\tdocument.body.appendChild( anchorElement );\n\tanchorElement.click();\n\tdocument.body.removeChild( anchorElement );\n\twindow.URL.revokeObjectURL( url );\n}\n"]}