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,CACA,MAAM,EAAO,IAAI,WAAW,GAC5B,IAAI,EAAW,EACf,IAAK,MAAM,KAAS,EAChB,EAAK,IAAI,EAAO,GAChB,GAAY,EAAM,OAEtB,EAAM,EAAK,MACf,CACA,MAAO,GACH,QAAQ,IAAI,2CAA4C,GAExD,QAAY,EAAK,cACjB,GACI,EAAG,CACC,MACA,MAAO,EAAI,WACX,SAAU,EAAI,WACd,MAAO,EACP,MAAM,GAElB,CACA,OAAO,CACX,IACA,QAAQ,qBAAuB,qBAU/B,MAAM,UAAY,CAAC,EAAK,EAAU,GAAW,EAAO,IAAO,eAAU,OAAQ,OAAQ,GAAQ,YACzF,MAAM,EAAM,QACA,EAAI,QAAQ,sBAAsB,EAAK,eAChC,MAAM,IAAM,cACzB,EAAO,IAAI,KAAK,CAAC,GAAM,CAAE,KAAM,IACrC,OAAO,IAAI,gBAAgB,EAC/B,IACA,QAAQ,UAAY","file":"/npm/@ffmpeg/util@0.12.0/dist/cjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@ffmpeg/util@0.12.0/dist/cjs/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","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toBlobURL = exports.downloadWithProgress = exports.importScript = exports.fetchFile = void 0;\nconst errors_js_1 = require(\"./errors.js\");\nconst const_js_1 = require(\"./const.js\");\nconst readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {\n    const fileReader = new FileReader();\n    fileReader.onload = () => {\n        const { result } = fileReader;\n        if (result instanceof ArrayBuffer) {\n            resolve(new Uint8Array(result));\n        }\n        else {\n            resolve(new Uint8Array());\n        }\n    };\n    fileReader.onerror = (event) => {\n        var _a, _b;\n        reject(Error(`File could not be read! Code=${((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code) || -1}`));\n    };\n    fileReader.readAsArrayBuffer(blob);\n});\n/**\n * An util function to fetch data from url string, base64, URL, File or Blob format.\n *\n * Examples:\n * ```ts\n * // URL\n * await fetchFile(\"http://localhost:3000/video.mp4\");\n * // base64\n * await fetchFile(\"data:<type>;base64,wL2dvYWwgbW9yZ...\");\n * // URL\n * await fetchFile(new URL(\"video.mp4\", import.meta.url));\n * // File\n * fileInput.addEventListener('change', (e) => {\n *   await fetchFile(e.target.files[0]);\n * });\n * // Blob\n * const blob = new Blob(...);\n * await fetchFile(blob);\n * ```\n */\nconst fetchFile = (file) => __awaiter(void 0, void 0, void 0, function* () {\n    let data;\n    if (typeof file === \"string\") {\n        /* From base64 format */\n        if (/data:_data\\/([a-zA-Z]*);base64,([^\"]*)/.test(file)) {\n            data = atob(file.split(\",\")[1])\n                .split(\"\")\n                .map((c) => c.charCodeAt(0));\n            /* From remote server/URL */\n        }\n        else {\n            data = yield (yield fetch(file)).arrayBuffer();\n        }\n    }\n    else if (file instanceof URL) {\n        data = yield (yield fetch(file)).arrayBuffer();\n    }\n    else if (file instanceof File || file instanceof Blob) {\n        data = yield readFromBlobOrFile(file);\n    }\n    else {\n        return new Uint8Array();\n    }\n    return new Uint8Array(data);\n});\nexports.fetchFile = fetchFile;\n/**\n * importScript dynamically import a script, useful when you\n * want to use different versions of ffmpeg.wasm based on environment.\n *\n * Example:\n *\n * ```ts\n * await importScript(\"http://localhost:3000/ffmpeg.js\");\n * ```\n */\nconst importScript = (url) => __awaiter(void 0, void 0, void 0, function* () {\n    return new Promise((resolve) => {\n        const script = document.createElement(\"script\");\n        const eventHandler = () => {\n            script.removeEventListener(\"load\", eventHandler);\n            resolve();\n        };\n        script.src = url;\n        script.type = \"text/javascript\";\n        script.addEventListener(\"load\", eventHandler);\n        document.getElementsByTagName(\"head\")[0].appendChild(script);\n    });\n});\nexports.importScript = importScript;\n/**\n * Download content of a URL with progress.\n *\n * Progress only works when Content-Length is provided by the server.\n *\n */\nconst downloadWithProgress = (url, cb) => __awaiter(void 0, void 0, void 0, function* () {\n    var _a;\n    const resp = yield fetch(url);\n    let buf;\n    try {\n        // Set total to -1 to indicate that there is not Content-Type Header.\n        const total = parseInt(resp.headers.get(const_js_1.HeaderContentLength) || \"-1\");\n        const reader = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.getReader();\n        if (!reader)\n            throw errors_js_1.ERROR_RESPONSE_BODY_READER;\n        const chunks = [];\n        let received = 0;\n        for (;;) {\n            const { done, value } = yield reader.read();\n            const delta = value ? value.length : 0;\n            if (done) {\n                if (total != -1 && total !== received)\n                    throw errors_js_1.ERROR_INCOMPLETED_DOWNLOAD;\n                cb && cb({ url, total, received, delta, done });\n                break;\n            }\n            chunks.push(value);\n            received += delta;\n            cb && cb({ url, total, received, delta, done });\n        }\n        const data = new Uint8Array(received);\n        let position = 0;\n        for (const chunk of chunks) {\n            data.set(chunk, position);\n            position += chunk.length;\n        }\n        buf = data.buffer;\n    }\n    catch (e) {\n        console.log(`failed to send download progress event: `, e);\n        // Fetch arrayBuffer directly when it is not possible to get progress.\n        buf = yield resp.arrayBuffer();\n        cb &&\n            cb({\n                url,\n                total: buf.byteLength,\n                received: buf.byteLength,\n                delta: 0,\n                done: true,\n            });\n    }\n    return buf;\n});\nexports.downloadWithProgress = downloadWithProgress;\n/**\n * toBlobURL fetches data from an URL and return a blob URL.\n *\n * Example:\n *\n * ```ts\n * await toBlobURL(\"http://localhost:3000/ffmpeg.js\", \"text/javascript\");\n * ```\n */\nconst toBlobURL = (url, mimeType, progress = false, cb) => __awaiter(void 0, void 0, void 0, function* () {\n    const buf = progress\n        ? yield (0, exports.downloadWithProgress)(url, cb)\n        : yield (yield fetch(url)).arrayBuffer();\n    const blob = new Blob([buf], { type: mimeType });\n    return URL.createObjectURL(blob);\n});\nexports.toBlobURL = toBlobURL;\n"]}