/*!
 * Nutrient Web SDK 1.10.0-18868f6 (https://www.nutrient.io/sdk/web)
 *
 * Copyright (c) 2016-2025 PSPDFKit GmbH. All rights reserved.
 *
 * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
 * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
 * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
 * This notice may not be removed from this file.
 *
 * PSPDFKit uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/web-acknowledgements/
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.NutrientViewer=t():e.NutrientViewer=t()}(globalThis,(()=>(()=>{"use strict";const e=function e(t){let n;return n=t instanceof Error?t:new Error(t),Object.setPrototypeOf(n,e.prototype),n};e.prototype=Object.create(Error.prototype,{name:{value:"PSPDFKitError",enumerable:!1}});const t=e;function n(e,n){if(!e)throw new t(`Assertion failed: ${n||"Condition not met"}\n\nFor further assistance, please go to: https://www.nutrient.io/support/request`)}["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'].join(",");new WeakMap;async function o(e){const n=(await async function(e){try{const n=await fetch(e).catch((n=>{throw new t(`Error fetching dynamic fonts file ${e}. ${n}`)}));if(200!==n.status)throw new t(`Error fetching dynamic fonts file ${e}. Status code: ${n.status}`);return n}catch(e){throw e}}(e)).json().catch((n=>{throw new t(`Error parsing dynamic fonts file ${e}. ${n}`)}));return n}let r=function(e){return e[e.pdf_a_1a=0]="pdf_a_1a",e[e.pdf_a_1b=1]="pdf_a_1b",e[e.pdf_a_2a=2]="pdf_a_2a",e[e.pdf_a_2u=3]="pdf_a_2u",e[e.pdf_a_2b=4]="pdf_a_2b",e[e.pdf_a_3a=5]="pdf_a_3a",e[e.pdf_a_3u=6]="pdf_a_3u",e[e.pdf_a_3b=7]="pdf_a_3b",e[e.pdf_a_4=8]="pdf_a_4",e[e.pdf_a_4e=9]="pdf_a_4e",e[e.pdf_a_4f=10]="pdf_a_4f",e}({});const a="/create.pdf",i="/save.pdf",s="/create.docx",c="/save.docx",l="/templateData.json",f="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let d=null,u=null;function p(e){let t;n(u,"GdPicture WebAssembly is not loaded.");for(var o=arguments.length,r=new Array(o>1?o-1:0),a=1;a<o;a++)r[a-1]=arguments[a];for(const e of r)t=Object.assign(r[0],e);const i=JSON.stringify({type:e,...t}),s=JSON.parse(u.CommandHandler(i));if(!s.success)throw new Error(s.errorReason+": "+s.errorMessage+"\n"+s.error);return s}const m={allMarkup:0,simpleMarkup:1,noMarkup:2,original:3},y=m.noMarkup,_={documentMarkupMode:y};function w(e){if(!e)return _;if(!e.documentMarkupMode)return{...e,documentMarkupMode:y};if(!(e.documentMarkupMode in m))throw new Error(`Invalid documentMarkupMode value: ${e.documentMarkupMode}. Allowed values are: ${Object.keys(m).join(", ")}`);return{...e,documentMarkupMode:m[e.documentMarkupMode]}}const b={"application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt"},g=new class{_mountCustomFonts(e,t){n(d,"WebAssembly module not loaded."),d.FS.mkdir(t);{const n=f?d.FS.filesystems.WORKERFS:d.FS.filesystems.MEMFS;d.FS.mount(n,{blobs:e},t)}}async loadModule(e,t,n,r,a,i,s){const{Assemblies:c,Module:l}=await async function(e,t){if("string"==typeof e){const n="nutrient-viewer-lib/",o=`${n}gdpicture-174da64a/jit`,r=`${n}gdpicture-174da64a/aot`;let a,i;t?(a=`${e}${r}/initDotnet.js`,i=`${e}${r}`):(a=`${e}${o}/initDotnet.js`,i=`${e}${o}`);const{initDotnet:s}=await import(a);return s(i,((e,t,n,o,r)=>"blazor.boot.json"===t?fetch(n,{credentials:"same-origin"}):null))}throw new Error("GdPicture WASM loader not implemented")}(e,t);u=c.GdPictureWasm.API,d=l,p("gdpicture/setLicense",{origin:n},{licenseKey:r||"DEMO_PSPDFKIT_WEB"});const f=a?"/fonts":"";if(a&&!d.FS.analyzePath(f).exists&&(this._mountCustomFonts(a,f),p("gdpicture/setFonts",{fontPaths:[f]})),i){const e=await o(i);p("gdpicture/setDynamicFontLoading",{baseUrl:i.split("/").slice(0,-1).join("/"),allowedFonts:e.availableFonts,v:1})}s&&p("gdpicture/setFontSubstitutions",{fontSubstitutions:s})}toPdf(e,t,n,o,s){let c=a;if(s&&"pdf"!==s&&Object.values(b).includes(s))c+=`.${s}`;else if(o&&"application/pdf"!==o){const e=o.toLowerCase(),t=b.hasOwnProperty(e)&&b[e];t&&(c+=`.${t}`)}d.FS.writeFile(c,new Uint8Array(e));const l={file:i,format:"pdf",conformance:t&&t in r?t:void 0,officeConversionSettings:w(n)};try{return p("gdpicture/process",{input:{file:c},output:l}),d.FS.readFile(i).buffer}finally{try{d.FS.unlink(i),d.FS.unlink(c)}catch(e){}}}toOffice(e,t){d.FS.writeFile(a,new Uint8Array(e));const n=`/save.${t}`;try{return p("gdpicture/process",{input:{file:a},output:{file:n,format:t}}),d.FS.readFile(n).buffer}finally{try{d.FS.unlink(n),d.FS.unlink(a)}catch(e){console.log(e.message)}}}async populateDocumentTemplate(e,t){let n;d.FS.writeFile(s,new Uint8Array(e));try{n=JSON.stringify(t,null,2)}catch(e){throw new Error("Invalid config data")}d.FS.writeFile(l,n);try{return p("gdpicture/process-office-template",{inputFile:s,modelAndConfigFile:l,outputFile:c}),d.FS.readFile(c).buffer}finally{try{d.FS.unlink(c),d.FS.unlink(l),d.FS.unlink(s)}catch(e){console.log(e.message)}}}},F=self;return F.global=F,F.module={},F.onmessage=async e=>{let t,n,{data:o}=e;try{const e=await g[o.action](...o.args);if(t={id:o.id,result:e},Array.isArray(e)){const t=e.filter((e=>e instanceof ArrayBuffer));t.length>0&&(n=t)}e instanceof ArrayBuffer&&(n=[e])}catch(e){const r=[...o.args].filter((e=>e instanceof ArrayBuffer));r.length>0&&(n=r),t={id:o.id,error:e.message||e.toString(),callArgs:o.args}}F.postMessage(t,n)},{}})()));