/*!
 * Nutrient Web SDK 1.1.0 (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/
 */
"use strict";(globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[]).push([[362],{63993:(t,e,a)=>{a.r(e),a.d(e,{corePool:()=>l.mG,customFontsPromiseRef:()=>_,default:()=>b,loadModule:()=>F,normalizeCoreOptions:()=>l.DO,validateStandaloneConfiguration:()=>l.mn});var s=a(49568),i=a(85409),n=a(55994),r=a(41204),o=a(85410),l=a(20873),u=a(37506),c=a(85553),d=a(89055),h=a(68322),m=a(82079),f=a(84318);async function p(t,e){const a=await fetch(t,{credentials:"same-origin"}).finally((()=>{e?.()}));return{isFullyAvailable:!0,fullDocument:await a.arrayBuffer()}}async function g(t,e,a,s){if(t instanceof ArrayBuffer)return{isFullyAvailable:!0,fullDocument:t};(0,i.V1)("string"==typeof t,"Document is not a string");let n=!1;const{linearizedInstance:r,serverSupportsRangeRequests:o}=await(async()=>{if(a&&function(t){try{const e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol}catch(t){return!1}}(t)){const a=e.initializeLinearizedInstance();return{linearizedInstance:a,serverSupportsRangeRequests:await a.initialize(t)}}return{linearizedInstance:null,serverSupportsRangeRequests:!1}})();try{if(!o)return n=!0,p(t,s);(0,i.V1)(r,"Loader is not available"),r.kickStartDownload();if(!await r.waitUntilIsLinearizedIsKnown())return r.destroy(),n=!0,p(t,s);s?.();const e=await r.waitUntilDocumentInfoAvailable();return e?(s?.(),{isFullyAvailable:!1,documentResponse:e}):(r.destroy(),n=!0,p(t,s))}catch(e){if(r?.destroy(),n)throw e;return p(t,s)}}var y=a(33075);let w;class b extends l.Ay{constructor(t){const e=t.baseUrl||(0,o.$_)(window.document),a=t.baseCoreUrl||e,s=t.baseProcessorEngineUrl||e,n={...t,baseUrl:e,baseCoreUrl:a,baseProcessorEngineUrl:s};if("string"!=typeof n.baseUrl)throw new i.uE("`baseUrl` is mandatory and must be a valid URL, e.g. `https://example.com/`");if("string"!=typeof n.document&&!(n.document instanceof ArrayBuffer))throw new i.uE("document must be either an URL to a supported document type (PDF and images), e.g. `https://example.com/document.pdf`, or an `ArrayBuffer`");if(w&&w!==n.licenseKey)throw new i.uE("Trying to re-use instance with a different licenseKey.\nUnfortunately we only allow one licenseKey per instance.\nPlease contact support for further assistance.");if("string"==typeof n.licenseKey&&n.licenseKey.startsWith("TRIAL-"))throw new i.uE("You're using the npm key instead of the license key. This key is used to download the PSPDFKit for Web package via the node package manager.\n\nLeave out the license key to activate as a trial.");super(n),this.destroyed=!1,this.activeConfiguration=t}async load(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=.2;t.progressCallback&&t.progressCallback("loading",e),this._isPDFJavaScriptEnabled=t.isPDFJavaScriptEnabled,"string"==typeof this._state.document&&(0,y.XC)(this._state.baseUrl,this._state.document,this._state.productId);const a=await F(this.client,this._state).finally((()=>{e+=.3,t.progressCallback&&t.progressCallback("loading",e)})),n=g(this._state.document,this.corePDFBridge,this._state.allowLinearizedLoading,(()=>{e+=.3,t.progressCallback&&t.progressCallback("loading",e)}));(0,i.V1)(a);const{features:o,signatureFeatureAvailability:l,capabilities:u}=a;if(this._state.productId===h.v.SharePoint&&"string"==typeof this._state.document&&Array.isArray(a.afu)){const t=new URL(this._state.document,this._state.baseUrl);if(!a.afu.some((e=>t.hostname.match(e))))throw new i.uE(`The document origin ${t.hostname} is not authorized.`)}const f=l===c.g.ELECTRONIC_SIGNATURES&&(0,d.UX)(o)&&this._state.forceLegacySignaturesFeature?c.g.LEGACY_SIGNATURES:l;this._state=this._state.set("features",(0,s.B8)(o)).set("signatureFeatureAvailability",f),w=this._state.licenseKey;const p=await n;let b=null;if(p.isFullyAvailable){let e=p.fullDocument.slice(0);try{this.destroyed?(e=null,b=await new Promise((()=>{}))):(b=await this.client.openDocument(p.fullDocument,{password:t.password,initialPageIndex:"number"==typeof t.initialPageIndex?t.initialPageIndex:0,formsConfiguration:this._formsConfiguration}),e=null)}catch(a){if("INVALID_PASSWORD"===a.message&&this._state.document instanceof ArrayBuffer&&(this._state=this._state.set("document",a.callArgs[0])),"IMAGE_DOCUMENTS_NOT_LICENSED"===a.message&&(a.message="The image documents feature is not enabled for your license key. Please contact support or sales to purchase the UI module for your product."),!(u?.includes("GdPictureWASM")&&a instanceof i.uE&&a.message.includes("File not in PDF format or corrupted.")))throw a;{(0,i.V1)(e);let s,n=(0,m.jU)();try{n||(n=(0,m.NY)({baseUrl:this._state.baseProcessorEngineUrl,mainThreadOrigin:this._state.appName||(0,r.D5)()||window.location.origin,licenseKey:this._state.licenseKey||void 0,customFonts:this._state.customFonts||void 0,dynamicFonts:this._state.dynamicFonts||void 0,fontSubstitutions:this._state.fontSubstitutions,processorEngine:this._state.processorEngine}),(0,m.Pm)(n)),s=await n,(0,i.V1)(s);const a=await s.toPdf(e);b=await this.client.openDocument(a,{password:t.password,initialPageIndex:"number"==typeof t.initialPageIndex?t.initialPageIndex:0,formsConfiguration:this._formsConfiguration})}catch(t){throw"INVALID_PASSWORD"===t.message&&this._state.document instanceof ArrayBuffer&&(this._state=this._state.set("document",a.callArgs[0])),"IMAGE_DOCUMENTS_NOT_LICENSED"===t.message&&(t.message="The image documents feature is not enabled for your license key. Please contact support or sales to purchase the UI module for your product."),t}finally{e=null,s?.destroy(),(0,m.Pm)(null)}}}(0,i.V1)(b),await this.afterDocumentLoaded(b)}else b=p.documentResponse;return this._state=this._state.set("documentResponse",b),{features:this._state.features,signatureFeatureAvailability:this._state.signatureFeatureAvailability,hasPassword:!!t.password,password:t.password,allowedTileScales:"all",evaluation:a.evaluation,linearizedLoading:!p.isFullyAvailable,documentResponse:b}}destroy(){this.destroyed=!0,super.destroy()}getCustomFontsPromise(){return _}async afterDocumentLoaded(t){if(this._isPDFJavaScriptEnabled&&(this._initialChanges=await this.client.enablePDFJavaScriptSupport()),this._XFDF&&await this.client.importXFDF(this._XFDF.source,this._XFDF.keepCurrentAnnotations,this._XFDF.ignorePageRotation),this._instantJSON&&this._instantJSON.pdfId&&t.ID.permanent){const e=this._instantJSON.pdfId,a=t.ID;if(e.permanent!==a.permanent)throw new i.uE("Could not instantiate from Instant JSON: Permanent PDF ID mismatch.\nPlease use the same PDF document that was used to create this Instant JSON.\nFor more information, please visit: https://www.nutrient.io/guides/web/importing-exporting/instant-json/");if(e.changing!==a.changing)throw new i.uE("Could not instantiate from Instant JSON: Changing PDF ID mismatch.\nPlease use the same revision of this PDF document that was used to create this Instant JSON.\nFor more information, please visit: https://www.nutrient.io/guides/web/importing-exporting/instant-json/")}if(this._trustedCAsCallback)try{const t=await this._trustedCAsCallback();if(!Array.isArray(t))throw new i.uE("Certificates response must be an array");if(t.some((t=>!(t instanceof ArrayBuffer)&&"string"!=typeof t)))throw new i.uE("All certificates must be passed as ArrayBuffer (DER) or string (PEM)");await this.client.loadCertificates(t.map(u.PI))}catch(t){throw new i.uE(`Could not retrieve certificates for digital signatures validation: ${t.message}.`)}}async waitUntilFullyLoaded(t){(0,i.V1)(this.corePDFBridge.linearizedInstance,"Linearized loader is not available");return this.corePDFBridge.linearizedInstance.waitUntilDownloaded().then((async()=>{await this.corePDFBridge.normallyOpenLinearizedDocument(this,{password:t,initialPageIndex:0,formsConfiguration:this._formsConfiguration}),await this.afterDocumentLoaded(this._state.documentResponse)}))}async getDocumentBytes(){if(this._state.document instanceof ArrayBuffer)return this._state.document;if("string"==typeof this._state.document){const t=await fetch(this._state.document);if(!t.ok)throw new i.uE(`Failed to fetch document: ${t.statusText}`);return t.arrayBuffer()}throw new i.uE("Document bytes are not available")}}const _={current:void 0};async function F(t,e){_.current=_.current||(e.customFonts?(0,f.eY)(e.customFonts):void 0);const a=(0,o.f)(e.appName);return t.loadNativeModule(e.baseCoreUrl,{mainThreadOrigin:a,disableWebAssemblyStreaming:e.disableWebAssemblyStreaming,enableAutomaticLinkExtraction:e.enableAutomaticLinkExtraction,overrideMemoryLimit:e.overrideMemoryLimit,workerSpawnerFn:()=>(0,n.pj)(e.inlineWorkers)}).then((async()=>t.load(e.baseCoreUrl,e.licenseKey,{mainThreadOrigin:a,..._.current?{customFonts:await _.current}:null,dynamicFonts:e.dynamicFonts,productId:e.productId})))}}}]);