/*! * PSPDFKit for Web 2024.3.2 (https://pspdfkit.com/web) * * Copyright (c) 2016-2024 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://pspdfkit.com/acknowledgements/web/ */ (self.webpackChunkPSPDFKit=self.webpackChunkPSPDFKit||[]).push([[6377],{22425:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>J});var r=n(17375),s=n(96156),i=n(35369),o=n(15359),a=n(51679),l=n(34997),h=n(81249),c=n(87463),u=n(71856),p=n(84254),d=n(98492),m=n(11765),f=n(2427),g=n(96723),E=n(20063);class v extends(i.WV({authPayload:null,serverUrl:null,hostedBaseUrl:null,documentId:null,backendPermissions:null,documentURL:null,imageToken:null,instantSettings:null,token:null,features:(0,i.aV)(),signatureFeatureAvailability:E.H.NONE,isFormsEnabled:!0,minSearchQueryLength:1,documentHandle:null,isDocumentHandleOutdated:!1,digitalSignatures:null,defaultGroup:void 0,hasCollaborationPermissions:!1,forceLegacySignaturesFeature:!1})){}var w=n(94809),y=n(87856),$=n(60209),R=n(68944),S=n(98179);const P="The image can not be rendered because of an unknown error.";class I{constructor(e){let{identifier:t,url:n,token:r,payload:s,doNotRequestWebP:i=!1}=e;this.identifier=t,this.url=n,this.token=r,this.payload=s,this.doNotRequestWebP=i}abort(){var e;null===(e=this.httpRequest)||void 0===e||e.abort()}request(){return new Promise(((e,t)=>{const n=new XMLHttpRequest;this.httpRequest=n,n.open(this.payload?"POST":"GET",this.url,!0),n.setRequestHeader("X-PSPDFKit-Image-Token",this.token),n.setRequestHeader("PSPDFKit-Platform","web"),n.setRequestHeader("PSPDFKit-Version",(0,R.oM)()),y.Zy&&!this.doNotRequestWebP&&n.setRequestHeader("Accept","image/webp,*/*"),n.responseType="blob",n.onreadystatechange=(async()=>{if(4!==n.readyState)return;if(n.response&&n.response.type.startsWith("application/json")){const r=new FileReader;return r.onload=n=>{var r;const s=JSON.parse(null===(r=n.target)||void 0===r?void 0:r.result);s.attachments_not_found?e({attachmentsNotFound:s.attachments_not_found}):s.error?"initialization_error"===s.error?e(null):t(new o.p2(`The server could not render the requested image (${s.error})`)):t(new o.p2(P))},r.onerror=()=>t(new o.p2(P)),void r.readAsText(n.response)}if(!(0,w.vu)(n.status))return void t(new o.p2(P));const r=n.response,s=URL.createObjectURL(r),i=new Image;i.onerror=()=>t(new o.p2(P)),i.src=s;const a=i.decode();try{await a}catch(e){if(!S.i7)throw new o.p2(`The image could not be decoded: ${e.message}`);await new Promise((e=>setTimeout(e,200)))}e(new $.Z(i,(()=>URL.revokeObjectURL(s))))}).bind(this),n.send(this.payload)}))}}var A=n(10983),b=n(65160),_=n(33427),O=n(7407),N=n(4715),L=n(78025);var T=n(88265),x=n(91038),F=n(32751),D=n(96650),C=n(87460),j=n(67055),k=n(21853),U=n(43069),G=n(44550),M=n(12705),H=n(74311),V=n(67009),q=n(86528),X=n(30006);const B=["color","fillColor","outlineColor"];function z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function K(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:window;if(super(),t=this,(0,s.Z)(this,"_password",null),(0,s.Z)(this,"type","SERVER"),(0,s.Z)(this,"_cachedRenderedAnnotation",{index:"",width:0,height:0,APStreamPromise:Promise.resolve(null)}),(0,s.Z)(this,"_requestRenderAnnotation",((e,n,r,s,i,a)=>{const h=`${this._state.documentURL}/render_annotation`,c=`render-annotation-${a?(0,l.SK)():e.id}`,u=JSON.stringify({data:(0,m.Hs)(e),width:s,height:i,detached:a||void 0,formFieldValue:n?(0,m.kr)(n):void 0});let p,d,f=!1,g=[];const E=new Promise(((e,t)=>{p=e,d=t}));if(e instanceof N.GI){const t=(0,_.et)(e);if((0,X.Gx)({annotation:e,annotationVisualPropertiesString:t,width:s,height:i,secondAnnotationVisualPropertiesString:this._cachedRenderedAnnotation.index,secondAnnotationWidth:this._cachedRenderedAnnotation.width,secondAnnotationHeight:this._cachedRenderedAnnotation.height}))return this._cachedRenderedAnnotation.APStreamPromise.then((e=>{p(e&&new $.Z(e.element.cloneNode(!0),(()=>{})))})).catch(d),{promise:E,cancel:()=>{f=!0,g.forEach((e=>{e.cancel()}))}};(0,X.oE)(e)&&(this._cachedRenderedAnnotation={index:t,width:s,height:i,APStreamPromise:E})}return function n(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const l=new FormData;l.append("render",u),a.length>0&&"imageAttachmentId"in e&&e.imageAttachmentId&&r&&l.append(e.imageAttachmentId,r);const m=new I({identifier:c,url:h,token:t._state.imageToken,payload:l,doNotRequestWebP:s>A.pt||i>A.pt}),E=t._requestQueue.enqueue(m,!1);E.promise.then((e=>{f||(null!=e&&e.attachmentsNotFound?n(e.attachmentsNotFound):null!=e&&e.attachmentsNotFound?d(new o.p2("Attachment could not be found.")):p(e))})).catch((e=>{f||d(e)})),g.push(E)}(),{promise:E,cancel:()=>{f=!0,g.forEach((e=>{e.cancel()}))}}})),(0,s.Z)(this,"_requestRenderAnnotations",((e,t,n,r,s)=>{const i=`${this._state.documentURL}/render_annotations`,o=JSON.stringify({annotations:t.map(((t,s)=>({pageIndex:e,pdfObjectId:t,width:n[s],height:r[s]}))),formFieldValues:s});let a,l,h=!1;const c=new Promise(((e,t)=>{a=e,l=t}));return this._fetch(i,{method:"post",body:o,credentials:"include",headers:{"X-PSPDFKit-Image-Token":this._state.imageToken,"Content-Type":"application/json",Accept:"multipart/form-data"}}).then((e=>e.formData())).then((e=>{h||a(Array.from(e.values()))})).catch((e=>{h||l(e)})),{promise:c,cancel:()=>{h=!0}}})),(0,s.Z)(this,"handleDocumentHandleConflict",(()=>{this._state=this._state.set("isDocumentHandleOutdated",!0),this.cancelRequests(),this._destroyProvider()})),"object"!=typeof e.authPayload)throw new o.p2("authPayload must be an object that contains the `jwt`. For example: `authPayload: { jwt: 'xxx.xxx.xxx'}`");const i=null===(n=e.authPayload)||void 0===n?void 0:n.accessToken;let h=null,c=null,u=null;if(i)u=e.hostedBaseUrl||"https://api.pspdfkit.com/",(0,w.sf)(u),(0,f.eU)(i);else{if(h=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window;const n=e.serverUrl||(0,R.SV)(t.document);if("/"!==n.substr(-1))throw new o.p2("`serverUrl` must have a slash at the end (e.g. `https://pspdfkit.example.com/`).");if(!e.serverUrl){if(n===`${t.location.protocol}//${t.location.host}/`)throw new o.p2('PSPDFKit automatically infers the URL of PSPDFKit Document Engine from the current `