/*!
 * Nutrient Web SDK 1.12.0 (https://www.nutrient.io/sdk/web)
 *
 * Copyright (c) 2016-2026 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/
 */
"use strict";(globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[]).push([[860],{5629:(e,t,n)=>{n.r(t),n.d(t,{Conformance:()=>r,GdPicture:()=>h,GdPictureWorker:()=>k,getBrowserSpawner:()=>M});var o=n(66080),s=n(57683);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}({});var a=n(39340);const i="/create.pdf",l="/save.pdf",d="/create.docx",u="/save.docx",c="/templateData.json",p="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let f=null,m=null;function w(e){let t;(0,o.V1)(m,"GdPicture WebAssembly is not loaded.");for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];for(const e of s)t=Object.assign(s[0],e);const a=JSON.stringify({type:e,...t}),i=JSON.parse(m.CommandHandler(a));if(!i.success)throw new Error(i.errorReason+": "+i.errorMessage+"\n"+i.error);return i}class h{_mountCustomFonts(e,t){(0,o.V1)(f,"WebAssembly module not loaded."),f.FS.mkdir(t);{const n=p?f.FS.filesystems.WORKERFS:f.FS.filesystems.MEMFS;f.FS.mount(n,{blobs:e},t)}}async loadModule(e,t,n,o,r,a,i){const{Assemblies:l,Module:d}=await async function(e,t){if("string"==typeof e){const n="nutrient-viewer-lib/",o=`${n}gdpicture-935f5ee6/jit`,s=`${n}gdpicture-935f5ee6/aot`;let r,a;t?(r=`${e}${s}/initDotnet.js`,a=`${e}${s}`):(r=`${e}${o}/initDotnet.js`,a=`${e}${o}`);const{initDotnet:i}=await import(r);return i(a,(e,t,n,o,s)=>"blazor.boot.json"===t?fetch(n,{credentials:"same-origin"}):null)}throw new Error("GdPicture WASM loader not implemented")}(e,t);m=l.GdPictureWasm.API,f=d,w("gdpicture/setLicense",{origin:n},{licenseKey:o||"DEMO_PSPDFKIT_WEB"});const u=r?"/fonts":"";if(r&&!f.FS.analyzePath(u).exists&&(this._mountCustomFonts(r,u),w("gdpicture/setFonts",{fontPaths:[u]})),a){const e=await(0,s.sw)(a);w("gdpicture/setDynamicFontLoading",{baseUrl:a.split("/").slice(0,-1).join("/"),allowedFonts:e.availableFonts,v:1})}i&&w("gdpicture/setFontSubstitutions",{fontSubstitutions:i})}toPdf(e,t,n,o,s){let d=i;if(s&&"pdf"!==s&&Object.values(S).includes(s)){const e=Object.keys(S).find(e=>S[e].toLowerCase()===s.toLowerCase());(0,a.AR)(e.toLowerCase()),d+=`.${s}`}else if(o&&"application/pdf"!==o){const e=o.toLowerCase();(0,a.AR)(e);const t=S.hasOwnProperty(e)&&S[e];t&&(d+=`.${t}`)}f.FS.writeFile(d,new Uint8Array(e));const u={file:l,format:"pdf",conformance:t&&t in r?t:void 0,officeConversionSettings:F(n)};try{return w("gdpicture/process",{input:{file:d},output:u}),f.FS.readFile(l).buffer}finally{try{f.FS.unlink(l),f.FS.unlink(d)}catch(e){}}}toOffice(e,t){f.FS.writeFile(i,new Uint8Array(e));const n=`/save.${t}`;try{return w("gdpicture/process",{input:{file:i},output:{file:n,format:t}}),f.FS.readFile(n).buffer}finally{try{f.FS.unlink(n),f.FS.unlink(i)}catch(e){console.log(e.message)}}}async populateDocumentTemplate(e,t){let n;f.FS.writeFile(d,new Uint8Array(e));try{n=JSON.stringify(t,null,2)}catch(e){throw new Error("Invalid config data")}f.FS.writeFile(c,n);try{return w("gdpicture/process-office-template",{inputFile:d,modelAndConfigFile:c,outputFile:u}),f.FS.readFile(u).buffer}finally{try{f.FS.unlink(u),f.FS.unlink(c),f.FS.unlink(d)}catch(e){console.log(e.message)}}}}const _={allMarkup:0,simpleMarkup:1,noMarkup:2,original:3},g=_.noMarkup,y={documentMarkupMode:g};function F(e){if(!e)return y;if(!e.documentMarkupMode)return{...e,documentMarkupMode:g};if(!(e.documentMarkupMode in _))throw new Error(`Invalid documentMarkupMode value: ${e.documentMarkupMode}. Allowed values are: ${Object.keys(_).join(", ")}`);return{...e,documentMarkupMode:_[e.documentMarkupMode]}}const S={"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"};var b=n(34724);const k=class{getModuleLoadPromise(){return this.moduleLoadPromise}constructor(e){let{baseUrl:t,aot:n,mainThreadOrigin:s,licenseKey:r,customFonts:a,dynamicFonts:i,fontSubstitutions:l,workerSpawner:d,wasmLoaderPath:u}=e;(0,b.A)(this,"requests",new Map),(0,b.A)(this,"nextRequestId",1),(0,b.A)(this,"handleMessage",e=>{const t=e.data,n=this.requests.get(t.id);(0,o.V1)(n,`No request was made for id ${t.id}.`);const{resolve:s,reject:r}=n;if(this.requests.delete(t.id),t.error){const e=new o.uE(t.error);e.callArgs=t.callArgs,r(e)}else s(t.result)}),this.workerSpawner=d,this.workerSpawner.setMessageHandler(this.handleMessage),this.moduleLoadPromise=this.sendRequest("loadModule",[u?{baseUrl:t,wasmLoaderPath:u}:t,n,s,r,a,i,l])}toOffice(e,t){return this.sendRequest("toOffice",[e,t])}toPdf(e){let t,{document:n,conformance:o,officeConversionSettings:s,contentType:r,extension:a}=e;return o&&(t=o.replace("pdf","pdf_").replaceAll("-","_")),this.sendRequest("toPdf",[n,t,s,r,a])}async populateDocumentTemplate(e,t){return this.sendRequest("populateDocumentTemplate",[e,t])}destroy(){this.workerSpawner?.terminate(),this.workerSpawner=null}async sendRequest(e,t){(0,o.V1)(this.workerSpawner,"GdPictureClient has been destroyed"),this.moduleLoadPromise&&await this.moduleLoadPromise;const n=this.workerSpawner;return new Promise((o,s)=>{const r=this.assignId(),a=[...t].filter(e=>e instanceof ArrayBuffer);n.postMessage({id:r,action:e,args:t},a),this.requests=this.requests.set(r,{resolve:o,reject:s})})}assignId(){const e=this.nextRequestId;return this.nextRequestId=this.nextRequestId+1,e}};const M=async function(){let e;if(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]){const{default:t}=await n.e(11).then(n.bind(n,7222));e=new t}else e=new Worker(n.tu(new URL(n.p+n.u(374),n.b)));return{setMessageHandler(t){(0,o.V1)(e,"Worker is null"),e.onmessage=t},postMessage(t,n){e?.postMessage(t,n)},terminate(){e?.terminate(),e=null}}}}}]);