@gientech/modual 1.5.4 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/GientechStreamReader-3-pyybZr.js +449 -0
- package/dist/chat.js +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json +1 -1
- package/dist/streamFilesReader.js +1 -1
- package/package.json +2 -2
- package/src/utils/testconfigs/index.ts +1 -1
- package/stats.html +1 -1
- package/dist/assets/GientechStreamReader-KtCNi1G3.js +0 -447
- package/src/main.tsx.backup +0 -5
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
var Vn=Object.defineProperty;var wn=p=>{throw TypeError(p)};var Yn=(p,a,y)=>a in p?Vn(p,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[a]=y;var se=(p,a,y)=>Yn(p,typeof a!="symbol"?a+"":a,y),ln=(p,a,y)=>a.has(p)||wn("Cannot "+y);var R=(p,a,y)=>(ln(p,a,"read from private field"),y?y.call(p):a.get(p)),Lt=(p,a,y)=>a.has(p)?wn("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(p):a.set(p,y),Bt=(p,a,y,f)=>(ln(p,a,"write to private field"),f?f.call(p,y):a.set(p,y),y),Mt=(p,a,y)=>(ln(p,a,"access private method"),y);var un=(p,a,y,f)=>({set _(_){Bt(p,a,_,y)},get _(){return R(p,a,f)}});import{jsxs,jsx,Fragment}from"react/jsx-runtime";import React__default,{forwardRef,createElement,useState,useRef,useEffect,useCallback,useMemo}from"react";import{c as createLucideIcon,L as getAugmentedNamespace,J as dt$1,M as ChevronRight,a as axios}from"./Input-CNqIA41v.js";import{W as Wv,o as oa}from"./index-Bof0D4vl.js";import{X}from"./x-DdRafKQU.js";/**
|
|
2
|
+
* @license lucide-react v0.456.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ChevronLeft=createLucideIcon("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
7
|
+
* @license lucide-react v0.456.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Download=createLucideIcon("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
12
|
+
* @license lucide-react v0.456.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Pencil=createLucideIcon("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
17
|
+
* @license lucide-react v0.456.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const RotateCcw=createLucideIcon("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
22
|
+
* @license lucide-react v0.456.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const RotateCw=createLucideIcon("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
|
|
27
|
+
* @license lucide-react v0.456.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ZoomIn=createLucideIcon("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
|
|
32
|
+
* @license lucide-react v0.456.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const ZoomOut=createLucideIcon("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function commonjsRequire(p){throw new Error('Could not dynamically require "'+p+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pdf={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$0=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredPdf;function requirePdf(){return hasRequiredPdf||(hasRequiredPdf=1,(function(module,exports){(function(a,y){module.exports=y()})(globalThis,()=>(()=>{var __webpack_modules__=[,((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.VerbosityLevel=a.Util=a.UnknownErrorException=a.UnexpectedResponseException=a.UNSUPPORTED_FEATURES=a.TextRenderingMode=a.StreamType=a.RenderingIntentFlag=a.PermissionFlag=a.PasswordResponses=a.PasswordException=a.PageActionEventType=a.OPS=a.MissingPDFException=a.LINE_FACTOR=a.LINE_DESCENT_FACTOR=a.InvalidPDFException=a.ImageKind=a.IDENTITY_MATRIX=a.FormatError=a.FontType=a.FeatureTest=a.FONT_IDENTITY_MATRIX=a.DocumentActionEventType=a.CMapCompressionType=a.BaseException=a.AnnotationType=a.AnnotationStateModelType=a.AnnotationReviewState=a.AnnotationReplyType=a.AnnotationMode=a.AnnotationMarkedState=a.AnnotationFlag=a.AnnotationFieldFlag=a.AnnotationEditorType=a.AnnotationEditorPrefix=a.AnnotationEditorParamsType=a.AnnotationBorderStyleType=a.AnnotationActionEventType=a.AbortException=void 0,a.arrayByteLength=L,a.arraysToBytes=At,a.assert=d,a.bytesToString=D,a.createPromiseCapability=he,a.createValidAbsoluteUrl=P,a.escapeString=Vt,a.getModificationDate=de,a.getVerbosityLevel=_t,a.info=wt,a.isArrayBuffer=Qt,a.isArrayEqual=le,a.isAscii=te,a.objectFromMap=Ct,a.objectSize=Q,a.setVerbosityLevel=G,a.shadow=j,a.string32=H,a.stringToBytes=g,a.stringToPDFString=Xt,a.stringToUTF16BEString=Gt,a.stringToUTF8String=Yt,a.unreachable=q,a.utf8StringToString=Kt,a.warn=Ot,y(2);const f=[1,0,0,1,0,0];a.IDENTITY_MATRIX=f;const _=[.001,0,0,.001,0,0];a.FONT_IDENTITY_MATRIX=_;const Y=1.35;a.LINE_FACTOR=Y;const W=.35;a.LINE_DESCENT_FACTOR=W;const K={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};a.RenderingIntentFlag=K;const M={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};a.AnnotationMode=M;const b="pdfjs_internal_editor_";a.AnnotationEditorPrefix=b;const w={DISABLE:-1,NONE:0,FREETEXT:3,INK:15};a.AnnotationEditorType=w;const T={FREETEXT_SIZE:1,FREETEXT_COLOR:2,FREETEXT_OPACITY:3,INK_COLOR:11,INK_THICKNESS:12,INK_OPACITY:13};a.AnnotationEditorParamsType=T;const S={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};a.PermissionFlag=S;const v={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};a.TextRenderingMode=v;const c={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};a.ImageKind=c;const t={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};a.AnnotationType=t;const r={MARKED:"Marked",REVIEW:"Review"};a.AnnotationStateModelType=r;const o={MARKED:"Marked",UNMARKED:"Unmarked"};a.AnnotationMarkedState=o;const F={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};a.AnnotationReviewState=F;const m={GROUP:"Group",REPLY:"R"};a.AnnotationReplyType=m;const l={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};a.AnnotationFlag=l;const n={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};a.AnnotationFieldFlag=n;const i={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};a.AnnotationBorderStyleType=i;const e={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};a.AnnotationActionEventType=e;const E={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};a.DocumentActionEventType=E;const x={O:"PageOpen",C:"PageClose"};a.PageActionEventType=x;const N={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};a.StreamType=N;const I={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};a.FontType=I;const St={ERRORS:0,WARNINGS:1,INFOS:5};a.VerbosityLevel=St;const Pt={NONE:0,BINARY:1,STREAM:2};a.CMapCompressionType=Pt;const bt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};a.OPS=bt;const V={unknown:"unknown",forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"};a.UNSUPPORTED_FEATURES=V;const O={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};a.PasswordResponses=O;let z=St.WARNINGS;function G(Dt){Number.isInteger(Dt)&&(z=Dt)}function _t(){return z}function wt(Dt){z>=St.INFOS&&console.log(`Info: ${Dt}`)}function Ot(Dt){z>=St.WARNINGS&&console.log(`Warning: ${Dt}`)}function q(Dt){throw new Error(Dt)}function d(Dt,J){Dt||q(J)}function u(Dt){if(!Dt)return!1;switch(Dt.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function P(Dt,J=null,Z=null){if(!Dt)return null;try{if(Z&&typeof Dt=="string"){if(Z.addDefaultProtocol&&Dt.startsWith("www.")){const zt=Dt.match(/\./g);zt&&zt.length>=2&&(Dt=`http://${Dt}`)}if(Z.tryConvertEncoding)try{Dt=Yt(Dt)}catch{}}const Nt=J?new URL(Dt,J):new URL(Dt);if(u(Nt))return Nt}catch{}return null}function j(Dt,J,Z){return Object.defineProperty(Dt,J,{value:Z,enumerable:!0,configurable:!0,writable:!1}),Z}const U=(function(){function J(Z,Nt){this.constructor===J&&q("Cannot initialize BaseException."),this.message=Z,this.name=Nt}return J.prototype=new Error,J.constructor=J,J})();a.BaseException=U;class $ extends U{constructor(J,Z){super(J,"PasswordException"),this.code=Z}}a.PasswordException=$;class s extends U{constructor(J,Z){super(J,"UnknownErrorException"),this.details=Z}}a.UnknownErrorException=s;class h extends U{constructor(J){super(J,"InvalidPDFException")}}a.InvalidPDFException=h;class C extends U{constructor(J){super(J,"MissingPDFException")}}a.MissingPDFException=C;class A extends U{constructor(J,Z){super(J,"UnexpectedResponseException"),this.status=Z}}a.UnexpectedResponseException=A;class k extends U{constructor(J){super(J,"FormatError")}}a.FormatError=k;class B extends U{constructor(J){super(J,"AbortException")}}a.AbortException=B;function D(Dt){(typeof Dt!="object"||Dt===null||Dt.length===void 0)&&q("Invalid argument for bytesToString");const J=Dt.length,Z=8192;if(J<Z)return String.fromCharCode.apply(null,Dt);const Nt=[];for(let zt=0;zt<J;zt+=Z){const xt=Math.min(zt+Z,J),Rt=Dt.subarray(zt,xt);Nt.push(String.fromCharCode.apply(null,Rt))}return Nt.join("")}function g(Dt){typeof Dt!="string"&&q("Invalid argument for stringToBytes");const J=Dt.length,Z=new Uint8Array(J);for(let Nt=0;Nt<J;++Nt)Z[Nt]=Dt.charCodeAt(Nt)&255;return Z}function L(Dt){if(Dt.length!==void 0)return Dt.length;if(Dt.byteLength!==void 0)return Dt.byteLength;q("Invalid argument for arrayByteLength")}function At(Dt){const J=Dt.length;if(J===1&&Dt[0]instanceof Uint8Array)return Dt[0];let Z=0;for(let xt=0;xt<J;xt++)Z+=L(Dt[xt]);let Nt=0;const zt=new Uint8Array(Z);for(let xt=0;xt<J;xt++){let Rt=Dt[xt];Rt instanceof Uint8Array||(typeof Rt=="string"?Rt=g(Rt):Rt=new Uint8Array(Rt));const Ut=Rt.byteLength;zt.set(Rt,Nt),Nt+=Ut}return zt}function H(Dt){return String.fromCharCode(Dt>>24&255,Dt>>16&255,Dt>>8&255,Dt&255)}function Q(Dt){return Object.keys(Dt).length}function Ct(Dt){const J=Object.create(null);for(const[Z,Nt]of Dt)J[Z]=Nt;return J}function Tt(){const Dt=new Uint8Array(4);return Dt[0]=1,new Uint32Array(Dt.buffer,0,1)[0]===1}function It(){try{return new Function(""),!0}catch{return!1}}class kt{static get isLittleEndian(){return j(this,"isLittleEndian",Tt())}static get isEvalSupported(){return j(this,"isEvalSupported",It())}static get isOffscreenCanvasSupported(){return j(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}}a.FeatureTest=kt;const Ht=[...Array(256).keys()].map(Dt=>Dt.toString(16).padStart(2,"0"));class Wt{static makeHexColor(J,Z,Nt){return`#${Ht[J]}${Ht[Z]}${Ht[Nt]}`}static scaleMinMax(J,Z){let Nt;J[0]?(J[0]<0&&(Nt=Z[0],Z[0]=Z[1],Z[1]=Nt),Z[0]*=J[0],Z[1]*=J[0],J[3]<0&&(Nt=Z[2],Z[2]=Z[3],Z[3]=Nt),Z[2]*=J[3],Z[3]*=J[3]):(Nt=Z[0],Z[0]=Z[2],Z[2]=Nt,Nt=Z[1],Z[1]=Z[3],Z[3]=Nt,J[1]<0&&(Nt=Z[2],Z[2]=Z[3],Z[3]=Nt),Z[2]*=J[1],Z[3]*=J[1],J[2]<0&&(Nt=Z[0],Z[0]=Z[1],Z[1]=Nt),Z[0]*=J[2],Z[1]*=J[2]),Z[0]+=J[4],Z[1]+=J[4],Z[2]+=J[5],Z[3]+=J[5]}static transform(J,Z){return[J[0]*Z[0]+J[2]*Z[1],J[1]*Z[0]+J[3]*Z[1],J[0]*Z[2]+J[2]*Z[3],J[1]*Z[2]+J[3]*Z[3],J[0]*Z[4]+J[2]*Z[5]+J[4],J[1]*Z[4]+J[3]*Z[5]+J[5]]}static applyTransform(J,Z){const Nt=J[0]*Z[0]+J[1]*Z[2]+Z[4],zt=J[0]*Z[1]+J[1]*Z[3]+Z[5];return[Nt,zt]}static applyInverseTransform(J,Z){const Nt=Z[0]*Z[3]-Z[1]*Z[2],zt=(J[0]*Z[3]-J[1]*Z[2]+Z[2]*Z[5]-Z[4]*Z[3])/Nt,xt=(-J[0]*Z[1]+J[1]*Z[0]+Z[4]*Z[1]-Z[5]*Z[0])/Nt;return[zt,xt]}static getAxialAlignedBoundingBox(J,Z){const Nt=Wt.applyTransform(J,Z),zt=Wt.applyTransform(J.slice(2,4),Z),xt=Wt.applyTransform([J[0],J[3]],Z),Rt=Wt.applyTransform([J[2],J[1]],Z);return[Math.min(Nt[0],zt[0],xt[0],Rt[0]),Math.min(Nt[1],zt[1],xt[1],Rt[1]),Math.max(Nt[0],zt[0],xt[0],Rt[0]),Math.max(Nt[1],zt[1],xt[1],Rt[1])]}static inverseTransform(J){const Z=J[0]*J[3]-J[1]*J[2];return[J[3]/Z,-J[1]/Z,-J[2]/Z,J[0]/Z,(J[2]*J[5]-J[4]*J[3])/Z,(J[4]*J[1]-J[5]*J[0])/Z]}static apply3dTransform(J,Z){return[J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2],J[3]*Z[0]+J[4]*Z[1]+J[5]*Z[2],J[6]*Z[0]+J[7]*Z[1]+J[8]*Z[2]]}static singularValueDecompose2dScale(J){const Z=[J[0],J[2],J[1],J[3]],Nt=J[0]*Z[0]+J[1]*Z[2],zt=J[0]*Z[1]+J[1]*Z[3],xt=J[2]*Z[0]+J[3]*Z[2],Rt=J[2]*Z[1]+J[3]*Z[3],Ut=(Nt+Rt)/2,$t=Math.sqrt((Nt+Rt)**2-4*(Nt*Rt-xt*zt))/2,qt=Ut+$t||1,Zt=Ut-$t||1;return[Math.sqrt(qt),Math.sqrt(Zt)]}static normalizeRect(J){const Z=J.slice(0);return J[0]>J[2]&&(Z[0]=J[2],Z[2]=J[0]),J[1]>J[3]&&(Z[1]=J[3],Z[3]=J[1]),Z}static intersect(J,Z){const Nt=Math.max(Math.min(J[0],J[2]),Math.min(Z[0],Z[2])),zt=Math.min(Math.max(J[0],J[2]),Math.max(Z[0],Z[2]));if(Nt>zt)return null;const xt=Math.max(Math.min(J[1],J[3]),Math.min(Z[1],Z[3])),Rt=Math.min(Math.max(J[1],J[3]),Math.max(Z[1],Z[3]));return xt>Rt?null:[Nt,xt,zt,Rt]}static bezierBoundingBox(J,Z,Nt,zt,xt,Rt,Ut,$t){const qt=[],Zt=[[],[]];let ie,Jt,oe,ee,me,fe,rn,an;for(let on=0;on<2;++on){if(on===0?(Jt=6*J-12*Nt+6*xt,ie=-3*J+9*Nt-9*xt+3*Ut,oe=3*Nt-3*J):(Jt=6*Z-12*zt+6*Rt,ie=-3*Z+9*zt-9*Rt+3*$t,oe=3*zt-3*Z),Math.abs(ie)<1e-12){if(Math.abs(Jt)<1e-12)continue;ee=-oe/Jt,0<ee&&ee<1&&qt.push(ee);continue}rn=Jt*Jt-4*oe*ie,an=Math.sqrt(rn),!(rn<0)&&(me=(-Jt+an)/(2*ie),0<me&&me<1&&qt.push(me),fe=(-Jt-an)/(2*ie),0<fe&&fe<1&&qt.push(fe))}let Ee=qt.length,re;const Ce=Ee;for(;Ee--;)ee=qt[Ee],re=1-ee,Zt[0][Ee]=re*re*re*J+3*re*re*ee*Nt+3*re*ee*ee*xt+ee*ee*ee*Ut,Zt[1][Ee]=re*re*re*Z+3*re*re*ee*zt+3*re*ee*ee*Rt+ee*ee*ee*$t;return Zt[0][Ce]=J,Zt[1][Ce]=Z,Zt[0][Ce+1]=Ut,Zt[1][Ce+1]=$t,Zt[0].length=Zt[1].length=Ce+2,[Math.min(...Zt[0]),Math.min(...Zt[1]),Math.max(...Zt[0]),Math.max(...Zt[1])]}}a.Util=Wt;const jt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function Xt(Dt){if(Dt[0]>="\xEF"){let Z;if(Dt[0]==="\xFE"&&Dt[1]==="\xFF"?Z="utf-16be":Dt[0]==="\xFF"&&Dt[1]==="\xFE"?Z="utf-16le":Dt[0]==="\xEF"&&Dt[1]==="\xBB"&&Dt[2]==="\xBF"&&(Z="utf-8"),Z)try{const Nt=new TextDecoder(Z,{fatal:!0}),zt=g(Dt);return Nt.decode(zt)}catch(Nt){Ot(`stringToPDFString: "${Nt}".`)}}const J=[];for(let Z=0,Nt=Dt.length;Z<Nt;Z++){const zt=jt[Dt.charCodeAt(Z)];J.push(zt?String.fromCharCode(zt):Dt.charAt(Z))}return J.join("")}function Vt(Dt){return Dt.replace(/([()\\\n\r])/g,J=>J===`
|
|
37
|
+
`?"\\n":J==="\r"?"\\r":`\\${J}`)}function te(Dt){return/^[\x00-\x7F]*$/.test(Dt)}function Gt(Dt){const J=["\xFE\xFF"];for(let Z=0,Nt=Dt.length;Z<Nt;Z++){const zt=Dt.charCodeAt(Z);J.push(String.fromCharCode(zt>>8&255),String.fromCharCode(zt&255))}return J.join("")}function Yt(Dt){return decodeURIComponent(escape(Dt))}function Kt(Dt){return unescape(encodeURIComponent(Dt))}function Qt(Dt){return typeof Dt=="object"&&Dt!==null&&Dt.byteLength!==void 0}function le(Dt,J){if(Dt.length!==J.length)return!1;for(let Z=0,Nt=Dt.length;Z<Nt;Z++)if(Dt[Z]!==J[Z])return!1;return!0}function de(Dt=new Date){return[Dt.getUTCFullYear().toString(),(Dt.getUTCMonth()+1).toString().padStart(2,"0"),Dt.getUTCDate().toString().padStart(2,"0"),Dt.getUTCHours().toString().padStart(2,"0"),Dt.getUTCMinutes().toString().padStart(2,"0"),Dt.getUTCSeconds().toString().padStart(2,"0")].join("")}function he(){const Dt=Object.create(null);let J=!1;return Object.defineProperty(Dt,"settled",{get(){return J}}),Dt.promise=new Promise(function(Z,Nt){Dt.resolve=function(zt){J=!0,Z(zt)},Dt.reject=function(zt){J=!0,Nt(zt)}}),Dt}}),((p,a,y)=>{y(3)}),((p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.isNodeJS=void 0;const y=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");a.isNodeJS=y}),((__unused_webpack_module,exports,__w_pdfjs_require__)=>{var p,y,f,_,Y,W,K,M,b,cn,T,S;Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.setPDFNetworkStreamFactory=setPDFNetworkStreamFactory,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(5),_display_utils=__w_pdfjs_require__(8),_font_loader=__w_pdfjs_require__(11),_canvas=__w_pdfjs_require__(12),_worker_options=__w_pdfjs_require__(15),_is_node=__w_pdfjs_require__(3),_message_handler=__w_pdfjs_require__(16),_metadata=__w_pdfjs_require__(17),_optional_content_config=__w_pdfjs_require__(18),_transport_stream=__w_pdfjs_require__(19),_xfa_text=__w_pdfjs_require__(20);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100;let DefaultCanvasFactory=_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;let DefaultCMapReaderFactory=_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;let DefaultStandardFontDataFactory=_display_utils.DOMStandardFontDataFactory;if(exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory,_is_node.isNodeJS){const{NodeCanvasFactory:c,NodeCMapReaderFactory:t,NodeStandardFontDataFactory:r}=__w_pdfjs_require__(21);exports.DefaultCanvasFactory=DefaultCanvasFactory=c,exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory=t,exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory=r}let createPDFNetworkStream;function setPDFNetworkStreamFactory(c){createPDFNetworkStream=c}function getDocument(c){const t=new PDFDocumentLoadingTask;let r;if(typeof c=="string"||c instanceof URL)r={url:c};else if((0,_util.isArrayBuffer)(c))r={data:c};else if(c instanceof PDFDataRangeTransport)r={range:c};else{if(typeof c!="object")throw new Error("Invalid parameter in getDocument, need either string, URL, TypedArray, or parameter object.");if(!c.url&&!c.data&&!c.range)throw new Error("Invalid parameter object: need either .data, .range or .url");r=c}const o=Object.create(null);let F=null,m=null;for(const n in r){const i=r[n];switch(n){case"url":if(typeof window<"u")try{o[n]=new URL(i,window.location).href;continue}catch(e){(0,_util.warn)(`Cannot create valid URL: "${e}".`)}else if(typeof i=="string"||i instanceof URL){o[n]=i.toString();continue}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");case"range":F=i;continue;case"worker":m=i;continue;case"data":if(_is_node.isNodeJS&&typeof Buffer<"u"&&i instanceof Buffer)o[n]=new Uint8Array(i);else{if(i instanceof Uint8Array)break;if(typeof i=="string")o[n]=(0,_util.stringToBytes)(i);else if(typeof i=="object"&&i!==null&&!isNaN(i.length))o[n]=new Uint8Array(i);else if((0,_util.isArrayBuffer)(i))o[n]=new Uint8Array(i);else throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}continue}o[n]=i}if(o.CMapReaderFactory=o.CMapReaderFactory||DefaultCMapReaderFactory,o.StandardFontDataFactory=o.StandardFontDataFactory||DefaultStandardFontDataFactory,o.ignoreErrors=o.stopAtErrors!==!0,o.fontExtraProperties=o.fontExtraProperties===!0,o.pdfBug=o.pdfBug===!0,o.enableXfa=o.enableXfa===!0,(!Number.isInteger(o.rangeChunkSize)||o.rangeChunkSize<1)&&(o.rangeChunkSize=DEFAULT_RANGE_CHUNK_SIZE),(typeof o.docBaseUrl!="string"||(0,_display_utils.isDataScheme)(o.docBaseUrl))&&(o.docBaseUrl=null),(!Number.isInteger(o.maxImageSize)||o.maxImageSize<-1)&&(o.maxImageSize=-1),typeof o.cMapUrl!="string"&&(o.cMapUrl=null),typeof o.standardFontDataUrl!="string"&&(o.standardFontDataUrl=null),typeof o.useWorkerFetch!="boolean"&&(o.useWorkerFetch=o.CMapReaderFactory===_display_utils.DOMCMapReaderFactory&&o.StandardFontDataFactory===_display_utils.DOMStandardFontDataFactory),typeof o.isEvalSupported!="boolean"&&(o.isEvalSupported=!0),typeof o.disableFontFace!="boolean"&&(o.disableFontFace=_is_node.isNodeJS),typeof o.useSystemFonts!="boolean"&&(o.useSystemFonts=!_is_node.isNodeJS&&!o.disableFontFace),(typeof o.ownerDocument!="object"||o.ownerDocument===null)&&(o.ownerDocument=globalThis.document),typeof o.disableRange!="boolean"&&(o.disableRange=!1),typeof o.disableStream!="boolean"&&(o.disableStream=!1),typeof o.disableAutoFetch!="boolean"&&(o.disableAutoFetch=!1),(0,_util.setVerbosityLevel)(o.verbosity),!m){const n={verbosity:o.verbosity,port:_worker_options.GlobalWorkerOptions.workerPort};m=n.port?PDFWorker.fromPort(n):new PDFWorker(n),t._worker=m}const l=t.docId;return m.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");const n=_fetchDocument(m,o,F,l),i=new Promise(function(e){let E;F?E=new _transport_stream.PDFDataTransportStream({length:o.length,initialData:o.initialData,progressiveDone:o.progressiveDone,contentDispositionFilename:o.contentDispositionFilename,disableRange:o.disableRange,disableStream:o.disableStream},F):o.data||(E=createPDFNetworkStream({url:o.url,length:o.length,httpHeaders:o.httpHeaders,withCredentials:o.withCredentials,rangeChunkSize:o.rangeChunkSize,disableRange:o.disableRange,disableStream:o.disableStream})),e(E)});return Promise.all([n,i]).then(function([e,E]){if(t.destroyed)throw new Error("Loading aborted");const x=new _message_handler.MessageHandler(l,e,m.port),N=new WorkerTransport(x,t,E,o);t._transport=N,x.send("Ready",null)})}).catch(t._capability.reject),t}async function _fetchDocument(c,t,r,o){if(c.destroyed)throw new Error("Worker was destroyed");r&&(t.length=r.length,t.initialData=r.initialData,t.progressiveDone=r.progressiveDone,t.contentDispositionFilename=r.contentDispositionFilename);const F=await c.messageHandler.sendWithPromise("GetDocRequest",{docId:o,apiVersion:"2.16.105",source:{data:t.data,url:t.url,password:t.password,disableAutoFetch:t.disableAutoFetch,rangeChunkSize:t.rangeChunkSize,length:t.length},maxImageSize:t.maxImageSize,disableFontFace:t.disableFontFace,docBaseUrl:t.docBaseUrl,ignoreErrors:t.ignoreErrors,isEvalSupported:t.isEvalSupported,fontExtraProperties:t.fontExtraProperties,enableXfa:t.enableXfa,useSystemFonts:t.useSystemFonts,cMapUrl:t.useWorkerFetch?t.cMapUrl:null,standardFontDataUrl:t.useWorkerFetch?t.standardFontDataUrl:null});if(t.data&&(t.data=null),c.destroyed)throw new Error("Worker was destroyed");return F}const a=class a{constructor(){this._capability=(0,_util.createPromiseCapability)(),this._transport=null,this._worker=null,this.docId=`d${un(a,p)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null,this.onUnsupportedFeature=null}get promise(){return this._capability.promise}async destroy(){var t;this.destroyed=!0,await((t=this._transport)==null?void 0:t.destroy()),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};p=new WeakMap,Lt(a,p,0);let PDFDocumentLoadingTask=a;exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(t,r,o=!1,F=null){this.length=t,this.initialData=r,this.progressiveDone=o,this.contentDispositionFilename=F,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,r){for(const o of this._rangeListeners)o(t,r)}onDataProgress(t,r){this._readyCapability.promise.then(()=>{for(const o of this._progressListeners)o(t,r)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const r of this._progressiveReadListeners)r(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,r){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(t,r){this._pdfInfo=t,this._transport=r,Object.defineProperty(this,"fingerprint",{get(){return(0,_display_utils.deprecated)("`PDFDocumentProxy.fingerprint`, please use `PDFDocumentProxy.fingerprints` instead."),this.fingerprints[0]}}),Object.defineProperty(this,"getStats",{value:async()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getStats`, please use the `PDFDocumentProxy.stats`-getter instead."),this.stats||{streamTypes:{},fontTypes:{}})})}get annotationStorage(){return this._transport.annotationStorage}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get stats(){return this._transport.stats}get isPureXfa(){return!!this._transport._htmlForXfa}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}saveDocument(){return this._transport.annotationStorage.size<=0&&(0,_display_utils.deprecated)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead."),this._transport.saveDocument()}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(t,r,o,F,m=!1){this._pageIndex=t,this._pageInfo=r,this._ownerDocument=F,this._transport=o,this._stats=m?new _display_utils.StatTimer:null,this._pdfBug=m,this.commonObjs=o.commonObjs,this.objs=new PDFObjects,this._bitmaps=new Set,this.cleanupAfterRender=!1,this.pendingCleanup=!1,this._intentStates=new Map,this._annotationPromises=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:r=this.rotate,offsetX:o=0,offsetY:F=0,dontFlip:m=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:t,rotation:r,offsetX:o,offsetY:F,dontFlip:m})}getAnnotations({intent:t="display"}={}){const r=this._transport.getRenderingIntent(t);let o=this._annotationPromises.get(r.cacheKey);return o||(o=this._transport.getAnnotations(this._pageIndex,r.renderingIntent),this._annotationPromises.set(r.cacheKey,o),o=o.then(F=>{for(const m of F)m.titleObj!==void 0&&Object.defineProperty(m,"title",{get(){return(0,_display_utils.deprecated)("`title`-property on annotation, please use `titleObj` instead."),m.titleObj.str}}),m.contentsObj!==void 0&&Object.defineProperty(m,"contents",{get(){return(0,_display_utils.deprecated)("`contents`-property on annotation, please use `contentsObj` instead."),m.contentsObj.str}});return F})),o}getJSActions(){return this._jsActionsPromise||(this._jsActionsPromise=this._transport.getPageJSActions(this._pageIndex))}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:r,intent:o="display",annotationMode:F=_util.AnnotationMode.ENABLE,transform:m=null,imageLayer:l=null,canvasFactory:n=null,background:i=null,optionalContentConfigPromise:e=null,annotationCanvasMap:E=null,pageColors:x=null,printAnnotationStorage:N=null}){var G,_t;((G=arguments[0])==null?void 0:G.renderInteractiveForms)!==void 0&&((0,_display_utils.deprecated)("render no longer accepts the `renderInteractiveForms`-option, please use the `annotationMode`-option instead."),arguments[0].renderInteractiveForms===!0&&F===_util.AnnotationMode.ENABLE&&(F=_util.AnnotationMode.ENABLE_FORMS)),((_t=arguments[0])==null?void 0:_t.includeAnnotationStorage)!==void 0&&((0,_display_utils.deprecated)("render no longer accepts the `includeAnnotationStorage`-option, please use the `annotationMode`-option instead."),arguments[0].includeAnnotationStorage===!0&&F===_util.AnnotationMode.ENABLE&&(F=_util.AnnotationMode.ENABLE_STORAGE)),this._stats&&this._stats.time("Overall");const I=this._transport.getRenderingIntent(o,F,N);this.pendingCleanup=!1,e||(e=this._transport.getOptionalContentConfig());let St=this._intentStates.get(I.cacheKey);St||(St=Object.create(null),this._intentStates.set(I.cacheKey,St)),St.streamReaderCancelTimeout&&(clearTimeout(St.streamReaderCancelTimeout),St.streamReaderCancelTimeout=null);const Pt=n||new DefaultCanvasFactory({ownerDocument:this._ownerDocument}),bt=!!(I.renderingIntent&_util.RenderingIntentFlag.PRINT);St.displayReadyCapability||(St.displayReadyCapability=(0,_util.createPromiseCapability)(),St.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(I));const V=wt=>{St.renderTasks.delete(O),(this.cleanupAfterRender||bt)&&(this.pendingCleanup=!0),this._tryCleanup(),wt?(O.capability.reject(wt),this._abortOperatorList({intentState:St,reason:wt instanceof Error?wt:new Error(wt)})):O.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"))},O=new InternalRenderTask({callback:V,params:{canvasContext:t,viewport:r,transform:m,imageLayer:l,background:i},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:E,operatorList:St.operatorList,pageIndex:this._pageIndex,canvasFactory:Pt,useRequestAnimationFrame:!bt,pdfBug:this._pdfBug,pageColors:x});(St.renderTasks||(St.renderTasks=new Set)).add(O);const z=O.task;return Promise.all([St.displayReadyCapability.promise,e]).then(([wt,Ot])=>{if(this.pendingCleanup){V();return}this._stats&&this._stats.time("Rendering"),O.initializeGraphics({transparency:wt,optionalContentConfig:Ot}),O.operatorListChanged()}).catch(V),z}getOperatorList({intent:t="display",annotationMode:r=_util.AnnotationMode.ENABLE,printAnnotationStorage:o=null}={}){function F(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(n))}const m=this._transport.getRenderingIntent(t,r,o,!0);let l=this._intentStates.get(m.cacheKey);l||(l=Object.create(null),this._intentStates.set(m.cacheKey,l));let n;return l.opListReadCapability||(n=Object.create(null),n.operatorListChanged=F,l.opListReadCapability=(0,_util.createPromiseCapability)(),(l.renderTasks||(l.renderTasks=new Set)).add(n),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(m)),l.opListReadCapability.promise}streamTextContent({disableCombineTextItems:t=!1,includeMarkedContent:r=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,combineTextItems:t!==!0,includeMarkedContent:r===!0},{highWaterMark:100,size(F){return F.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(o=>_xfa_text.XfaText.textContent(o));const r=this.streamTextContent(t);return new Promise(function(o,F){function m(){l.read().then(function({value:i,done:e}){if(e){o(n);return}Object.assign(n.styles,i.styles),n.items.push(...i.items),m()},F)}const l=r.getReader(),n={items:[],styles:Object.create(null)};m()})}getStructTree(){return this._structTreePromise||(this._structTreePromise=this._transport.getStructTree(this._pageIndex))}_destroy(){this.destroyed=!0;const t=[];for(const r of this._intentStates.values())if(this._abortOperatorList({intentState:r,reason:new Error("Page was destroyed."),force:!0}),!r.opListReadCapability)for(const o of r.renderTasks)t.push(o.completed),o.cancel();this.objs.clear();for(const r of this._bitmaps)r.close();return this._bitmaps.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,this.pendingCleanup=!1,Promise.all(t)}cleanup(t=!1){return this.pendingCleanup=!0,this._tryCleanup(t)}_tryCleanup(t=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:r,operatorList:o}of this._intentStates.values())if(r.size>0||!o.lastChunk)return!1;this._intentStates.clear(),this.objs.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,t&&this._stats&&(this._stats=new _display_utils.StatTimer);for(const r of this._bitmaps)r.close();return this._bitmaps.clear(),this.pendingCleanup=!1,!0}_startRenderPage(t,r){const o=this._intentStates.get(r);o&&(this._stats&&this._stats.timeEnd("Page Request"),o.displayReadyCapability&&o.displayReadyCapability.resolve(t))}_renderPageChunk(t,r){for(let o=0,F=t.length;o<F;o++)r.operatorList.fnArray.push(t.fnArray[o]),r.operatorList.argsArray.push(t.argsArray[o]);r.operatorList.lastChunk=t.lastChunk,r.operatorList.separateAnnots=t.separateAnnots;for(const o of r.renderTasks)o.operatorListChanged();t.lastChunk&&this._tryCleanup()}_pumpOperatorList({renderingIntent:t,cacheKey:r,annotationStorageMap:o}){const m=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:r,annotationStorage:o}).getReader(),l=this._intentStates.get(r);l.streamReader=m;const n=()=>{m.read().then(({value:i,done:e})=>{if(e){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(i,l),n())},i=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const e of l.renderTasks)e.operatorListChanged();this._tryCleanup()}if(l.displayReadyCapability)l.displayReadyCapability.reject(i);else if(l.opListReadCapability)l.opListReadCapability.reject(i);else throw i}})};n()}_abortOperatorList({intentState:t,reason:r,force:o=!1}){if(t.streamReader){if(!o){if(t.renderTasks.size>0)return;if(r instanceof _display_utils.RenderingCancelledException){t.streamReaderCancelTimeout=setTimeout(()=>{this._abortOperatorList({intentState:t,reason:r,force:!0}),t.streamReaderCancelTimeout=null},RENDERING_CANCELLED_TIMEOUT);return}}if(t.streamReader.cancel(new _util.AbortException(r.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[F,m]of this._intentStates)if(m===t){this._intentStates.delete(F);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){this._listeners=[],this._deferred=Promise.resolve()}postMessage(t,r){const o={data:structuredClone(t,r)};this._deferred.then(()=>{for(const F of this._listeners)F.call(this,o)})}addEventListener(t,r){this._listeners.push(r)}removeEventListener(t,r){const o=this._listeners.indexOf(r);this._listeners.splice(o,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;{if(_is_node.isNodeJS&&typeof commonjsRequire=="function")PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if(typeof document=="object"){const c=(y=document==null?void 0:document.currentScript)==null?void 0:y.src;c&&(PDFWorkerUtil.fallbackWorkerSrc=c.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(c,t){let r;try{if(r=new URL(c),!r.origin||r.origin==="null")return!1}catch{return!1}const o=new URL(t,r);return r.origin===o.origin},PDFWorkerUtil.createCDNWrapper=function(c){const t=`importScripts("${c}");`;return URL.createObjectURL(new Blob([t]))}}const _PDFWorker=class _PDFWorker{constructor({name:c=null,port:t=null,verbosity:r=(0,_util.getVerbosityLevel)()}={}){if(t&&R(_PDFWorker,f).has(t))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=c,this.destroyed=!1,this.verbosity=r,this._readyCapability=(0,_util.createPromiseCapability)(),this._port=null,this._webWorker=null,this._messageHandler=null,t){R(_PDFWorker,f).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(c){this._port=c,this._messageHandler=new _message_handler.MessageHandler("main","worker",c),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve()}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:c}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,c)||(c=PDFWorkerUtil.createCDNWrapper(new URL(c,window.location).href));const t=new Worker(c),r=new _message_handler.MessageHandler("main","worker",t),o=()=>{t.removeEventListener("error",F),r.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},F=()=>{this._webWorker||o()};t.addEventListener("error",F),r.on("test",l=>{if(t.removeEventListener("error",F),this.destroyed){o();return}l?(this._messageHandler=r,this._port=t,this._webWorker=t,this._readyCapability.resolve(),r.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),r.destroy(),t.terminate())}),r.on("ready",l=>{if(t.removeEventListener("error",F),this.destroyed){o();return}try{m()}catch{this._setupFakeWorker()}});const m=()=>{const l=new Uint8Array;r.send("test",l,[l.buffer])};m();return}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then(c=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new LoopbackPort;this._port=t;const r=`fake${PDFWorkerUtil.fakeWorkerId++}`,o=new _message_handler.MessageHandler(r+"_worker",r,t);c.setup(o,t);const F=new _message_handler.MessageHandler(r,r+"_worker",t);this._messageHandler=F,this._readyCapability.resolve(),F.send("configure",{verbosity:this.verbosity})}).catch(c=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${c.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),R(_PDFWorker,f).delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(c){if(!(c!=null&&c.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return R(this,f).has(c.port)?R(this,f).get(c.port):new _PDFWorker(c)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(PDFWorkerUtil.fallbackWorkerSrc!==null)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var c;try{return((c=globalThis.pdfjsWorker)==null?void 0:c.WorkerMessageHandler)||null}catch{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&typeof commonjsRequire=="function"){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}};f=new WeakMap,Lt(_PDFWorker,f,new WeakMap);let PDFWorker=_PDFWorker;exports.PDFWorker=PDFWorker,PDFWorker.getWorkerSrc=function(){return(0,_display_utils.deprecated)("`PDFWorker.getWorkerSrc()`, please use `PDFWorker.workerSrc` instead."),this.workerSrc};class WorkerTransport{constructor(t,r,o,F){Lt(this,_,null);Lt(this,Y,new Map);Lt(this,W,new Map);Lt(this,K,null);this.messageHandler=t,this.loadingTask=r,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({docId:r.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:F.ownerDocument,styleElement:F.styleElement}),this._params=F,F.useWorkerFetch||(this.CMapReaderFactory=new F.CMapReaderFactory({baseUrl:F.cMapUrl,isCompressed:F.cMapPacked}),this.StandardFontDataFactory=new F.StandardFontDataFactory({baseUrl:F.standardFontDataUrl})),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=o,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=(0,_util.createPromiseCapability)(),this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}get stats(){return R(this,_)}getRenderingIntent(t,r=_util.AnnotationMode.ENABLE,o=null,F=!1){let m=_util.RenderingIntentFlag.DISPLAY,l=null;switch(t){case"any":m=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":m=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${t}`)}switch(r){case _util.AnnotationMode.DISABLE:m+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:m+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:m+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,l=(m&_util.RenderingIntentFlag.PRINT&&o instanceof _annotation_storage.PrintAnnotationStorage?o:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${r}`)}return F&&(m+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:m,cacheKey:`${m}_${_annotation_storage.AnnotationStorage.getHash(l)}`,annotationStorageMap:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=(0,_util.createPromiseCapability)(),this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const o of R(this,Y).values())t.push(o._destroy());R(this,Y).clear(),R(this,W).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const r=this.messageHandler.sendWithPromise("Terminate",null);return t.push(r),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),Bt(this,K,null),this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null,this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:r}=this;t.on("GetReader",(o,F)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=m=>{this._lastProgress={loaded:m.loaded,total:m.total}},F.onPull=()=>{this._fullReader.read().then(function({value:m,done:l}){if(l){F.close();return}(0,_util.assert)((0,_util.isArrayBuffer)(m),"GetReader - expected an ArrayBuffer."),F.enqueue(new Uint8Array(m),1,[m])}).catch(m=>{F.error(m)})},F.onCancel=m=>{this._fullReader.cancel(m),F.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("ReaderHeadersReady",o=>{const F=(0,_util.createPromiseCapability)(),m=this._fullReader;return m.headersReady.then(()=>{var l;(!m.isStreamingSupported||!m.isRangeSupported)&&(this._lastProgress&&((l=r.onProgress)==null||l.call(r,this._lastProgress)),m.onProgress=n=>{var i;(i=r.onProgress)==null||i.call(r,{loaded:n.loaded,total:n.total})}),F.resolve({isStreamingSupported:m.isStreamingSupported,isRangeSupported:m.isRangeSupported,contentLength:m.contentLength})},F.reject),F.promise}),t.on("GetRangeReader",(o,F)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const m=this._networkStream.getRangeReader(o.begin,o.end);if(!m){F.close();return}F.onPull=()=>{m.read().then(function({value:l,done:n}){if(n){F.close();return}(0,_util.assert)((0,_util.isArrayBuffer)(l),"GetRangeReader - expected an ArrayBuffer."),F.enqueue(new Uint8Array(l),1,[l])}).catch(l=>{F.error(l)})},F.onCancel=l=>{m.cancel(l),F.ready.catch(n=>{if(!this.destroyed)throw n})}}),t.on("GetDoc",({pdfInfo:o})=>{this._numPages=o.numPages,this._htmlForXfa=o.htmlForXfa,delete o.htmlForXfa,r._capability.resolve(new PDFDocumentProxy(o,this))}),t.on("DocException",function(o){let F;switch(o.name){case"PasswordException":F=new _util.PasswordException(o.message,o.code);break;case"InvalidPDFException":F=new _util.InvalidPDFException(o.message);break;case"MissingPDFException":F=new _util.MissingPDFException(o.message);break;case"UnexpectedResponseException":F=new _util.UnexpectedResponseException(o.message,o.status);break;case"UnknownErrorException":F=new _util.UnknownErrorException(o.message,o.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}r._capability.reject(F)}),t.on("PasswordRequest",o=>{if(this._passwordCapability=(0,_util.createPromiseCapability)(),r.onPassword){const F=m=>{m instanceof Error?this._passwordCapability.reject(m):this._passwordCapability.resolve({password:m})};try{r.onPassword(F,o.code)}catch(m){this._passwordCapability.reject(m)}}else this._passwordCapability.reject(new _util.PasswordException(o.message,o.code));return this._passwordCapability.promise}),t.on("DataLoaded",o=>{var F;(F=r.onProgress)==null||F.call(r,{loaded:o.length,total:o.length}),this.downloadInfoCapability.resolve(o)}),t.on("StartRenderPage",o=>{if(this.destroyed)return;R(this,Y).get(o.pageIndex)._startRenderPage(o.transparency,o.cacheKey)}),t.on("commonobj",([o,F,m])=>{var l;if(!this.destroyed&&!this.commonObjs.has(o))switch(F){case"Font":const n=this._params;if("error"in m){const E=m.error;(0,_util.warn)(`Error during font loading: ${E}`),this.commonObjs.resolve(o,E);break}let i=null;n.pdfBug&&((l=globalThis.FontInspector)!=null&&l.enabled)&&(i={registerFont(E,x){globalThis.FontInspector.fontAdded(E,x)}});const e=new _font_loader.FontFaceObject(m,{isEvalSupported:n.isEvalSupported,disableFontFace:n.disableFontFace,ignoreErrors:n.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:i});this.fontLoader.bind(e).catch(E=>t.sendWithPromise("FontFallback",{id:o})).finally(()=>{!n.fontExtraProperties&&e.data&&(e.data=null),this.commonObjs.resolve(o,e)});break;case"FontPath":case"Image":this.commonObjs.resolve(o,m);break;default:throw new Error(`Got unknown common object type ${F}`)}}),t.on("obj",([o,F,m,l])=>{var i;if(this.destroyed)return;const n=R(this,Y).get(F);if(!n.objs.has(o))switch(m){case"Image":n.objs.resolve(o,l);const e=8e6;if(l){let E;if(l.bitmap){const{bitmap:x,width:N,height:I}=l;E=N*I*4,n._bitmaps.add(x)}else E=((i=l.data)==null?void 0:i.length)||0;E>e&&(n.cleanupAfterRender=!0)}break;case"Pattern":n.objs.resolve(o,l);break;default:throw new Error(`Got unknown object type ${m}`)}}),t.on("DocProgress",o=>{var F;this.destroyed||(F=r.onProgress)==null||F.call(r,{loaded:o.loaded,total:o.total})}),t.on("DocStats",o=>{this.destroyed||Bt(this,_,Object.freeze({streamTypes:Object.freeze(o.streamTypes),fontTypes:Object.freeze(o.fontTypes)}))}),t.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this)),t.on("FetchBuiltInCMap",o=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.CMapReaderFactory?this.CMapReaderFactory.fetch(o):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",o=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.StandardFontDataFactory?this.StandardFontDataFactory.fetch(o):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}_onUnsupportedFeature({featureId:t}){var r,o;this.destroyed||(o=(r=this.loadingTask).onUnsupportedFeature)==null||o.call(r,t)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const r=t-1,o=R(this,W).get(r);if(o)return o;const F=this.messageHandler.sendWithPromise("GetPage",{pageIndex:r}).then(m=>{if(this.destroyed)throw new Error("Transport destroyed");const l=new PDFPageProxy(r,m,this,this._params.ownerDocument,this._params.pdfBug);return R(this,Y).set(r,l),l});return R(this,W).set(r,F),F}getPageIndex(t){return typeof t!="object"||t===null||!Number.isInteger(t.num)||t.num<0||!Number.isInteger(t.gen)||t.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen})}getAnnotations(t,r){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:r})}saveDocument(){var t;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:this.annotationStorage.serializable,filename:((t=this._fullReader)==null?void 0:t.filename)??null}).finally(()=>{this.annotationStorage.resetModified()})}getFieldObjects(){return this._getFieldObjectsPromise||(this._getFieldObjectsPromise=this.messageHandler.sendWithPromise("GetFieldObjects",null))}hasJSActions(){return this._hasJSActionsPromise||(this._hasJSActionsPromise=this.messageHandler.sendWithPromise("HasJSActions",null))}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then(t=>new _optional_content_config.OptionalContentConfig(t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return R(this,K)||Bt(this,K,this.messageHandler.sendWithPromise("GetMetadata",null).then(t=>{var r,o;return{info:t[0],metadata:t[1]?new _metadata.Metadata(t[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(await this.messageHandler.sendWithPromise("Cleanup",null),!this.destroyed){for(const r of R(this,Y).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),Bt(this,K,null),this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null}}get loadingParams(){const t=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:t.disableAutoFetch,enableXfa:t.enableXfa})}}_=new WeakMap,Y=new WeakMap,W=new WeakMap,K=new WeakMap;class PDFObjects{constructor(){Lt(this,b);Lt(this,M,Object.create(null))}get(t,r=null){if(r){const F=Mt(this,b,cn).call(this,t);return F.capability.promise.then(()=>r(F.data)),null}const o=R(this,M)[t];if(!(o!=null&&o.capability.settled))throw new Error(`Requesting object that isn't resolved yet ${t}.`);return o.data}has(t){const r=R(this,M)[t];return(r==null?void 0:r.capability.settled)||!1}resolve(t,r=null){const o=Mt(this,b,cn).call(this,t);o.data=r,o.capability.resolve()}clear(){Bt(this,M,Object.create(null))}}M=new WeakMap,b=new WeakSet,cn=function(t){const r=R(this,M)[t];return r||(R(this,M)[t]={capability:(0,_util.createPromiseCapability)(),data:null})};class RenderTask{constructor(t){Lt(this,T,null);Bt(this,T,t),this.onContinue=null}get promise(){return R(this,T).capability.promise}cancel(){R(this,T).cancel()}get separateAnnots(){const{separateAnnots:t}=R(this,T).operatorList;if(!t)return!1;const{annotationCanvasMap:r}=R(this,T);return t.form||t.canvas&&(r==null?void 0:r.size)>0}}T=new WeakMap,exports.RenderTask=RenderTask;const v=class v{constructor({callback:t,params:r,objs:o,commonObjs:F,annotationCanvasMap:m,operatorList:l,pageIndex:n,canvasFactory:i,useRequestAnimationFrame:e=!1,pdfBug:E=!1,pageColors:x=null}){this.callback=t,this.params=r,this.objs=o,this.commonObjs=F,this.annotationCanvasMap=m,this.operatorListIdx=null,this.operatorList=l,this._pageIndex=n,this.canvasFactory=i,this._pdfBug=E,this.pageColors=x,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=e===!0&&typeof window<"u",this.cancelled=!1,this.capability=(0,_util.createPromiseCapability)(),this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=r.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:r}){var i;if(this.cancelled)return;if(this._canvas){if(R(v,S).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");R(v,S).add(this._canvas)}this._pdfBug&&((i=globalThis.StepperManager)!=null&&i.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:o,viewport:F,transform:m,imageLayer:l,background:n}=this.params;this.gfx=new _canvas.CanvasGraphics(o,this.commonObjs,this.objs,this.canvasFactory,l,r,this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:m,viewport:F,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback&&this.graphicsReadyCallback()}cancel(t=null){this.running=!1,this.cancelled=!0,this.gfx&&this.gfx.endDrawing(),this._canvas&&R(v,S).delete(this._canvas),this.callback(t||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,"canvas"))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}this.stepper&&this.stepper.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame(()=>{this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),this._canvas&&R(v,S).delete(this._canvas),this.callback())))}};S=new WeakMap,Lt(v,S,new WeakSet);let InternalRenderTask=v;const version="2.16.105";exports.version=version;const build="172ccdbe5";exports.build=build}),((p,a,y)=>{var M,kn,w;Object.defineProperty(a,"__esModule",{value:!0}),a.PrintAnnotationStorage=a.AnnotationStorage=void 0;var f=y(1),_=y(6),Y=y(10);class W{constructor(){Lt(this,M);this._storage=new Map,this._modified=!1,this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(S,v){const c=this._storage.get(S);return c===void 0?v:Object.assign(v,c)}getRawValue(S){return this._storage.get(S)}remove(S){if(this._storage.delete(S),this._storage.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const v of this._storage.values())if(v instanceof _.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(S,v){const c=this._storage.get(S);let t=!1;if(c!==void 0)for(const[r,o]of Object.entries(v))c[r]!==o&&(t=!0,c[r]=o);else t=!0,this._storage.set(S,v);t&&Mt(this,M,kn).call(this),v instanceof _.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(v.constructor._type)}has(S){return this._storage.has(S)}getAll(){return this._storage.size>0?(0,f.objectFromMap)(this._storage):null}get size(){return this._storage.size}resetModified(){this._modified&&(this._modified=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new K(this)}get serializable(){if(this._storage.size===0)return null;const S=new Map;for(const[v,c]of this._storage){const t=c instanceof _.AnnotationEditor?c.serialize():c;t&&S.set(v,t)}return S}static getHash(S){if(!S)return"";const v=new Y.MurmurHash3_64;for(const[c,t]of S)v.update(`${c}:${JSON.stringify(t)}`);return v.hexdigest()}}M=new WeakSet,kn=function(){this._modified||(this._modified=!0,typeof this.onSetModified=="function"&&this.onSetModified())},a.AnnotationStorage=W;class K extends W{constructor(v){super();Lt(this,w,null);Bt(this,w,structuredClone(v.serializable))}get print(){(0,f.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return R(this,w)}}w=new WeakMap,a.PrintAnnotationStorage=K}),((p,a,y)=>{var W,K,M,b,w,T;Object.defineProperty(a,"__esModule",{value:!0}),a.AnnotationEditor=void 0;var f=y(7),_=y(1);const S=class S{constructor(c){Lt(this,W,this.focusin.bind(this));Lt(this,K,this.focusout.bind(this));Lt(this,M,!1);Lt(this,b,!1);Lt(this,w,!1);Lt(this,T,S._zIndex++);this.constructor===S&&(0,_.unreachable)("Cannot initialize AnnotationEditor."),this.parent=c.parent,this.id=c.id,this.width=this.height=null,this.pageIndex=c.parent.pageIndex,this.name=c.name,this.div=null;const[t,r]=this.parent.viewportBaseDimensions;this.x=c.x/t,this.y=c.y/r,this.rotation=this.parent.viewport.rotation,this.isAttachedToDOM=!1}static get _defaultLineColor(){return(0,_.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=R(this,T)}focusin(c){R(this,M)?Bt(this,M,!1):this.parent.setSelected(this)}focusout(c){if(!this.isAttachedToDOM)return;const t=c.relatedTarget;t!=null&&t.closest(`#${this.id}`)||(c.preventDefault(),this.parent.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.parent.addToAnnotationStorage(this)}dragstart(c){const t=this.parent.div.getBoundingClientRect();this.startX=c.clientX-t.x,this.startY=c.clientY-t.y,c.dataTransfer.setData("text/plain",this.id),c.dataTransfer.effectAllowed="move"}setAt(c,t,r,o){const[F,m]=this.parent.viewportBaseDimensions;[r,o]=this.screenToPageTranslation(r,o),this.x=(c+r)/F,this.y=(t+o)/m,this.div.style.left=`${100*this.x}%`,this.div.style.top=`${100*this.y}%`}translate(c,t){const[r,o]=this.parent.viewportBaseDimensions;[c,t]=this.screenToPageTranslation(c,t),this.x+=c/r,this.y+=t/o,this.div.style.left=`${100*this.x}%`,this.div.style.top=`${100*this.y}%`}screenToPageTranslation(c,t){const{rotation:r}=this.parent.viewport;switch(r){case 90:return[t,-c];case 180:return[-c,-t];case 270:return[-t,c];default:return[c,t]}}setDims(c,t){const[r,o]=this.parent.viewportBaseDimensions;this.div.style.width=`${100*c/r}%`,this.div.style.height=`${100*t/o}%`}getInitialTranslation(){return[0,0]}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",R(this,W)),this.div.addEventListener("focusout",R(this,K));const[c,t]=this.getInitialTranslation();return this.translate(c,t),(0,f.bindEvents)(this,this.div,["dragstart","pointerdown"]),this.div}pointerdown(c){const t=f.KeyboardManager.platform.isMac;if(c.button!==0||c.ctrlKey&&t){c.preventDefault();return}c.ctrlKey&&!t||c.shiftKey||c.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this),Bt(this,M,!0)}getRect(c,t){const[r,o]=this.parent.viewportBaseDimensions,[F,m]=this.parent.pageDimensions,l=F*c/r,n=m*t/o,i=this.x*F,e=this.y*m,E=this.width*F,x=this.height*m;switch(this.rotation){case 0:return[i+l,m-e-n-x,i+l+E,m-e-n];case 90:return[i+n,m-e+l,i+n+x,m-e+l+E];case 180:return[i-l-E,m-e+n,i-l,m-e+n+x];case 270:return[i-n-x,m-e-l-E,i-n,m-e-l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(c,t){const[r,o,F,m]=c,l=F-r,n=m-o;switch(this.rotation){case 0:return[r,t-m,l,n];case 90:return[r,t-o,n,l];case 180:return[F,t-o,l,n];case 270:return[F,t-m,n,l];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){Bt(this,w,!0)}disableEditMode(){Bt(this,w,!1)}isInEditMode(){return R(this,w)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var c;(c=this.div)==null||c.addEventListener("focusin",R(this,W))}serialize(){(0,_.unreachable)("An editor must be serializable")}static deserialize(c,t){const r=new this.prototype.constructor({parent:t,id:t.getNextId()});r.rotation=c.rotation;const[o,F]=t.pageDimensions,[m,l,n,i]=r.getRectInCurrentCoords(c.rect,F);return r.x=m/o,r.y=l/F,r.width=n/o,r.height=i/F,r}remove(){this.div.removeEventListener("focusin",R(this,W)),this.div.removeEventListener("focusout",R(this,K)),this.isEmpty()||this.commit(),this.parent.remove(this)}select(){var c;(c=this.div)==null||c.classList.add("selectedEditor")}unselect(){var c;(c=this.div)==null||c.classList.remove("selectedEditor")}updateParams(c,t){}disableEditing(){}enableEditing(){}get propertiesToUpdate(){return{}}get contentDiv(){return this.div}get isEditing(){return R(this,b)}set isEditing(c){Bt(this,b,c),c?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}};W=new WeakMap,K=new WeakMap,M=new WeakMap,b=new WeakMap,w=new WeakMap,T=new WeakMap,se(S,"_colorManager",new f.ColorManager),se(S,"_zIndex",1);let Y=S;a.AnnotationEditor=Y}),((p,a,y)=>{var v,c,t,r,o,F,Pn,n,e,E,x,N,I,St,Pt,bt,V,O,z,G,_t,wt,Ot,q,d,u,Tn,dn,ae,ve,Dn,Rn,hn,Fe,we;Object.defineProperty(a,"__esModule",{value:!0}),a.KeyboardManager=a.CommandManager=a.ColorManager=a.AnnotationEditorUIManager=void 0,a.bindEvents=Y,a.opacityToHex=W;var f=y(1),_=y(8);function Y(D,g,L){for(const At of L)g.addEventListener(At,D[At].bind(D))}function W(D){return Math.round(Math.min(255,Math.max(1,255*D))).toString(16).padStart(2,"0")}class K{constructor(){Lt(this,v,0)}getId(){return`${f.AnnotationEditorPrefix}${un(this,v)._++}`}}v=new WeakMap;class M{constructor(g=128){Lt(this,c,[]);Lt(this,t,!1);Lt(this,r);Lt(this,o,-1);Bt(this,r,g)}add({cmd:g,undo:L,mustExec:At,type:H=NaN,overwriteIfSameType:Q=!1,keepUndo:Ct=!1}){if(At&&g(),R(this,t))return;const Tt={cmd:g,undo:L,type:H};if(R(this,o)===-1){R(this,c).length>0&&(R(this,c).length=0),Bt(this,o,0),R(this,c).push(Tt);return}if(Q&&R(this,c)[R(this,o)].type===H){Ct&&(Tt.undo=R(this,c)[R(this,o)].undo),R(this,c)[R(this,o)]=Tt;return}const It=R(this,o)+1;It===R(this,r)?R(this,c).splice(0,1):(Bt(this,o,It),It<R(this,c).length&&R(this,c).splice(It)),R(this,c).push(Tt)}undo(){R(this,o)!==-1&&(Bt(this,t,!0),R(this,c)[R(this,o)].undo(),Bt(this,t,!1),Bt(this,o,R(this,o)-1))}redo(){R(this,o)<R(this,c).length-1&&(Bt(this,o,R(this,o)+1),Bt(this,t,!0),R(this,c)[R(this,o)].cmd(),Bt(this,t,!1))}hasSomethingToUndo(){return R(this,o)!==-1}hasSomethingToRedo(){return R(this,o)<R(this,c).length-1}destroy(){Bt(this,c,null)}}c=new WeakMap,t=new WeakMap,r=new WeakMap,o=new WeakMap,a.CommandManager=M;const l=class l{constructor(g){Lt(this,F);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const L=l.platform.isMac;for(const[At,H]of g)for(const Q of At){const Ct=Q.startsWith("mac+");L&&Ct?(this.callbacks.set(Q.slice(4),H),this.allKeys.add(Q.split("+").at(-1))):!L&&!Ct&&(this.callbacks.set(Q,H),this.allKeys.add(Q.split("+").at(-1)))}}static get platform(){const g=typeof navigator<"u"?navigator.platform:"";return(0,f.shadow)(this,"platform",{isWin:g.includes("Win"),isMac:g.includes("Mac")})}exec(g,L){if(!this.allKeys.has(L.key))return;const At=this.callbacks.get(Mt(this,F,Pn).call(this,L));At&&(At.bind(g)(),L.stopPropagation(),L.preventDefault())}};F=new WeakSet,Pn=function(g){g.altKey&&this.buffer.push("alt"),g.ctrlKey&&this.buffer.push("ctrl"),g.metaKey&&this.buffer.push("meta"),g.shiftKey&&this.buffer.push("shift"),this.buffer.push(g.key);const L=this.buffer.join("+");return this.buffer.length=0,L};let b=l;a.KeyboardManager=b;class w{constructor(){Lt(this,n,null)}copy(g){g&&(Array.isArray(g)?Bt(this,n,g.map(L=>L.serialize())):Bt(this,n,[g.serialize()]),Bt(this,n,R(this,n).filter(L=>!!L)),R(this,n).length===0&&Bt(this,n,null))}paste(){return R(this,n)}isEmpty(){return R(this,n)===null}destroy(){Bt(this,n,null)}}n=new WeakMap;const i=class i{get _colors(){const g=new Map([["CanvasText",null],["Canvas",null]]);return(0,_.getColorValues)(g),(0,f.shadow)(this,"_colors",g)}convert(g){const L=(0,_.getRGB)(g);if(!window.matchMedia("(forced-colors: active)").matches)return L;for(const[At,H]of this._colors)if(H.every((Q,Ct)=>Q===L[Ct]))return i._colorsMapping.get(At);return L}getHexCode(g){const L=this._colors.get(g);return L?f.Util.makeHexColor(...L):g}};se(i,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let T=i;a.ColorManager=T;const B=class B{constructor(g,L){Lt(this,u);Lt(this,e,null);Lt(this,E,new Map);Lt(this,x,new Map);Lt(this,N,new w);Lt(this,I,new M);Lt(this,St,0);Lt(this,Pt,null);Lt(this,bt,null);Lt(this,V,new K);Lt(this,O,!1);Lt(this,z,f.AnnotationEditorType.NONE);Lt(this,G,new Set);Lt(this,_t,this.keydown.bind(this));Lt(this,wt,this.onEditingAction.bind(this));Lt(this,Ot,this.onPageChanging.bind(this));Lt(this,q,{isEditing:!1,isEmpty:!0,hasEmptyClipboard:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1});Lt(this,d,null);Bt(this,d,g),Bt(this,bt,L),R(this,bt)._on("editingaction",R(this,wt)),R(this,bt)._on("pagechanging",R(this,Ot))}destroy(){Mt(this,u,dn).call(this),R(this,bt)._off("editingaction",R(this,wt)),R(this,bt)._off("pagechanging",R(this,Ot));for(const g of R(this,x).values())g.destroy();R(this,x).clear(),R(this,E).clear(),Bt(this,e,null),R(this,G).clear(),R(this,N).destroy(),R(this,I).destroy()}onPageChanging({pageNumber:g}){Bt(this,St,g-1)}focusMainContainer(){R(this,d).focus()}keydown(g){var L;(L=this.getActive())!=null&&L.shouldGetKeyboardEvents()||B._keyboardManager.exec(this,g)}onEditingAction(g){["undo","redo","cut","copy","paste","delete","selectAll"].includes(g.name)&&this[g.name]()}setEditingState(g){g?(Mt(this,u,Tn).call(this),Mt(this,u,ae).call(this,{isEditing:R(this,z)!==f.AnnotationEditorType.NONE,isEmpty:Mt(this,u,Fe).call(this),hasSomethingToUndo:R(this,I).hasSomethingToUndo(),hasSomethingToRedo:R(this,I).hasSomethingToRedo(),hasSelectedEditor:!1,hasEmptyClipboard:R(this,N).isEmpty()})):(Mt(this,u,dn).call(this),Mt(this,u,ae).call(this,{isEditing:!1}))}registerEditorTypes(g){Bt(this,Pt,g);for(const L of R(this,Pt))Mt(this,u,ve).call(this,L.defaultPropertiesToUpdate)}getId(){return R(this,V).getId()}addLayer(g){R(this,x).set(g.pageIndex,g),R(this,O)?g.enable():g.disable()}removeLayer(g){R(this,x).delete(g.pageIndex)}updateMode(g){if(Bt(this,z,g),g===f.AnnotationEditorType.NONE)this.setEditingState(!1),Mt(this,u,Rn).call(this);else{this.setEditingState(!0),Mt(this,u,Dn).call(this);for(const L of R(this,x).values())L.updateMode(g)}}updateToolbar(g){g!==R(this,z)&&R(this,bt).dispatch("switchannotationeditormode",{source:this,mode:g})}updateParams(g,L){for(const At of R(this,G))At.updateParams(g,L);for(const At of R(this,Pt))At.updateDefaultParams(g,L)}getEditors(g){const L=[];for(const At of R(this,E).values())At.pageIndex===g&&L.push(At);return L}getEditor(g){return R(this,E).get(g)}addEditor(g){R(this,E).set(g.id,g)}removeEditor(g){R(this,E).delete(g.id),this.unselect(g)}setActiveEditor(g){R(this,e)!==g&&(Bt(this,e,g),g&&Mt(this,u,ve).call(this,g.propertiesToUpdate))}toggleSelected(g){if(R(this,G).has(g)){R(this,G).delete(g),g.unselect(),Mt(this,u,ae).call(this,{hasSelectedEditor:this.hasSelection});return}R(this,G).add(g),g.select(),Mt(this,u,ve).call(this,g.propertiesToUpdate),Mt(this,u,ae).call(this,{hasSelectedEditor:!0})}setSelected(g){for(const L of R(this,G))L!==g&&L.unselect();R(this,G).clear(),R(this,G).add(g),g.select(),Mt(this,u,ve).call(this,g.propertiesToUpdate),Mt(this,u,ae).call(this,{hasSelectedEditor:!0})}isSelected(g){return R(this,G).has(g)}unselect(g){g.unselect(),R(this,G).delete(g),Mt(this,u,ae).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return R(this,G).size!==0}undo(){R(this,I).undo(),Mt(this,u,ae).call(this,{hasSomethingToUndo:R(this,I).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Mt(this,u,Fe).call(this)})}redo(){R(this,I).redo(),Mt(this,u,ae).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:R(this,I).hasSomethingToRedo(),isEmpty:Mt(this,u,Fe).call(this)})}addCommands(g){R(this,I).add(g),Mt(this,u,ae).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Mt(this,u,Fe).call(this)})}delete(){if(R(this,e)&&R(this,e).commitOrRemove(),!this.hasSelection)return;const g=[...R(this,G)],L=()=>{for(const H of g)H.remove()},At=()=>{for(const H of g)Mt(this,u,hn).call(this,H)};this.addCommands({cmd:L,undo:At,mustExec:!0})}copy(){if(R(this,e)&&R(this,e).commitOrRemove(),this.hasSelection){const g=[];for(const L of R(this,G))L.isEmpty()||g.push(L);if(g.length===0)return;R(this,N).copy(g),Mt(this,u,ae).call(this,{hasEmptyClipboard:!1})}}cut(){this.copy(),this.delete()}paste(){if(R(this,N).isEmpty())return;this.unselectAll();const g=R(this,x).get(R(this,St)),L=R(this,N).paste().map(Q=>g.deserialize(Q)),At=()=>{for(const Q of L)Mt(this,u,hn).call(this,Q);Mt(this,u,we).call(this,L)},H=()=>{for(const Q of L)Q.remove()};this.addCommands({cmd:At,undo:H,mustExec:!0})}selectAll(){for(const g of R(this,G))g.commit();Mt(this,u,we).call(this,R(this,E).values())}unselectAll(){if(R(this,e)){R(this,e).commitOrRemove();return}if(Mt(this,u,we).size!==0){for(const g of R(this,G))g.unselect();R(this,G).clear(),Mt(this,u,ae).call(this,{hasSelectedEditor:!1})}}isActive(g){return R(this,e)===g}getActive(){return R(this,e)}getMode(){return R(this,z)}};e=new WeakMap,E=new WeakMap,x=new WeakMap,N=new WeakMap,I=new WeakMap,St=new WeakMap,Pt=new WeakMap,bt=new WeakMap,V=new WeakMap,O=new WeakMap,z=new WeakMap,G=new WeakMap,_t=new WeakMap,wt=new WeakMap,Ot=new WeakMap,q=new WeakMap,d=new WeakMap,u=new WeakSet,Tn=function(){R(this,d).addEventListener("keydown",R(this,_t))},dn=function(){R(this,d).removeEventListener("keydown",R(this,_t))},ae=function(g){Object.entries(g).some(([At,H])=>R(this,q)[At]!==H)&&R(this,bt).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(R(this,q),g)})},ve=function(g){R(this,bt).dispatch("annotationeditorparamschanged",{source:this,details:g})},Dn=function(){if(!R(this,O)){Bt(this,O,!0);for(const g of R(this,x).values())g.enable()}},Rn=function(){if(this.unselectAll(),R(this,O)){Bt(this,O,!1);for(const g of R(this,x).values())g.disable()}},hn=function(g){const L=R(this,x).get(g.pageIndex);L?L.addOrRebuild(g):this.addEditor(g)},Fe=function(){if(R(this,E).size===0)return!0;if(R(this,E).size===1)for(const g of R(this,E).values())return g.isEmpty();return!1},we=function(g){R(this,G).clear();for(const L of g)L.isEmpty()||(R(this,G).add(L),L.select());Mt(this,u,ae).call(this,{hasSelectedEditor:!0})},se(B,"_keyboardManager",new b([[["ctrl+a","mac+meta+a"],B.prototype.selectAll],[["ctrl+c","mac+meta+c"],B.prototype.copy],[["ctrl+v","mac+meta+v"],B.prototype.paste],[["ctrl+x","mac+meta+x"],B.prototype.cut],[["ctrl+z","mac+meta+z"],B.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],B.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],B.prototype.delete],[["Escape","mac+Escape"],B.prototype.unselectAll]]));let S=B;a.AnnotationEditorUIManager=S}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.StatTimer=a.RenderingCancelledException=a.PixelsPerInch=a.PageViewport=a.PDFDateString=a.DOMStandardFontDataFactory=a.DOMSVGFactory=a.DOMCanvasFactory=a.DOMCMapReaderFactory=a.AnnotationPrefix=void 0,a.deprecated=i,a.getColorValues=I,a.getCurrentTransform=St,a.getCurrentTransformInverse=Pt,a.getFilenameFromUrl=o,a.getPdfFilenameFromUrl=F,a.getRGB=N,a.getXfaPageViewport=x,a.isDataScheme=t,a.isPdfFile=r,a.isValidFetchUrl=l,a.loadScript=n;var f=y(9),_=y(1);const Y="http://www.w3.org/2000/svg",W="pdfjs_internal_id_";a.AnnotationPrefix=W;const bt=class bt{};se(bt,"CSS",96),se(bt,"PDF",72),se(bt,"PDF_TO_CSS_UNITS",bt.CSS/bt.PDF);let K=bt;a.PixelsPerInch=K;class M extends f.BaseCanvasFactory{constructor({ownerDocument:O=globalThis.document}={}){super(),this._document=O}_createCanvas(O,z){const G=this._document.createElement("canvas");return G.width=O,G.height=z,G}}a.DOMCanvasFactory=M;async function b(V,O=!1){if(l(V,document.baseURI)){const z=await fetch(V);if(!z.ok)throw new Error(z.statusText);return O?new Uint8Array(await z.arrayBuffer()):(0,_.stringToBytes)(await z.text())}return new Promise((z,G)=>{const _t=new XMLHttpRequest;_t.open("GET",V,!0),O&&(_t.responseType="arraybuffer"),_t.onreadystatechange=()=>{if(_t.readyState===XMLHttpRequest.DONE){if(_t.status===200||_t.status===0){let wt;if(O&&_t.response?wt=new Uint8Array(_t.response):!O&&_t.responseText&&(wt=(0,_.stringToBytes)(_t.responseText)),wt){z(wt);return}}G(new Error(_t.statusText))}},_t.send(null)})}class w extends f.BaseCMapReaderFactory{_fetchData(O,z){return b(O,this.isCompressed).then(G=>({cMapData:G,compressionType:z}))}}a.DOMCMapReaderFactory=w;class T extends f.BaseStandardFontDataFactory{_fetchData(O){return b(O,!0)}}a.DOMStandardFontDataFactory=T;class S extends f.BaseSVGFactory{_createSVG(O){return document.createElementNS(Y,O)}}a.DOMSVGFactory=S;class v{constructor({viewBox:O,scale:z,rotation:G,offsetX:_t=0,offsetY:wt=0,dontFlip:Ot=!1}){this.viewBox=O,this.scale=z,this.rotation=G,this.offsetX=_t,this.offsetY=wt;const q=(O[2]+O[0])/2,d=(O[3]+O[1])/2;let u,P,j,U;switch(G%=360,G<0&&(G+=360),G){case 180:u=-1,P=0,j=0,U=1;break;case 90:u=0,P=1,j=1,U=0;break;case 270:u=0,P=-1,j=-1,U=0;break;case 0:u=1,P=0,j=0,U=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}Ot&&(j=-j,U=-U);let $,s,h,C;u===0?($=Math.abs(d-O[1])*z+_t,s=Math.abs(q-O[0])*z+wt,h=Math.abs(O[3]-O[1])*z,C=Math.abs(O[2]-O[0])*z):($=Math.abs(q-O[0])*z+_t,s=Math.abs(d-O[1])*z+wt,h=Math.abs(O[2]-O[0])*z,C=Math.abs(O[3]-O[1])*z),this.transform=[u*z,P*z,j*z,U*z,$-u*z*q-j*z*d,s-P*z*q-U*z*d],this.width=h,this.height=C}clone({scale:O=this.scale,rotation:z=this.rotation,offsetX:G=this.offsetX,offsetY:_t=this.offsetY,dontFlip:wt=!1}={}){return new v({viewBox:this.viewBox.slice(),scale:O,rotation:z,offsetX:G,offsetY:_t,dontFlip:wt})}convertToViewportPoint(O,z){return _.Util.applyTransform([O,z],this.transform)}convertToViewportRectangle(O){const z=_.Util.applyTransform([O[0],O[1]],this.transform),G=_.Util.applyTransform([O[2],O[3]],this.transform);return[z[0],z[1],G[0],G[1]]}convertToPdfPoint(O,z){return _.Util.applyInverseTransform([O,z],this.transform)}}a.PageViewport=v;class c extends _.BaseException{constructor(O,z){super(O,"RenderingCancelledException"),this.type=z}}a.RenderingCancelledException=c;function t(V){const O=V.length;let z=0;for(;z<O&&V[z].trim()==="";)z++;return V.substring(z,z+5).toLowerCase()==="data:"}function r(V){return typeof V=="string"&&/\.pdf$/i.test(V)}function o(V){const O=V.indexOf("#"),z=V.indexOf("?"),G=Math.min(O>0?O:V.length,z>0?z:V.length);return V.substring(V.lastIndexOf("/",G)+1,G)}function F(V,O="document.pdf"){if(typeof V!="string")return O;if(t(V))return(0,_.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),O;const z=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,G=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,_t=z.exec(V);let wt=G.exec(_t[1])||G.exec(_t[2])||G.exec(_t[3]);if(wt&&(wt=wt[0],wt.includes("%")))try{wt=G.exec(decodeURIComponent(wt))[0]}catch{}return wt||O}class m{constructor(){this.started=Object.create(null),this.times=[]}time(O){O in this.started&&(0,_.warn)(`Timer is already running for ${O}`),this.started[O]=Date.now()}timeEnd(O){O in this.started||(0,_.warn)(`Timer has not been started for ${O}`),this.times.push({name:O,start:this.started[O],end:Date.now()}),delete this.started[O]}toString(){const O=[];let z=0;for(const G of this.times){const _t=G.name;_t.length>z&&(z=_t.length)}for(const G of this.times){const _t=G.end-G.start;O.push(`${G.name.padEnd(z)} ${_t}ms
|
|
38
|
+
`)}return O.join("")}}a.StatTimer=m;function l(V,O){try{const{protocol:z}=O?new URL(V,O):new URL(V);return z==="http:"||z==="https:"}catch{return!1}}function n(V,O=!1){return new Promise((z,G)=>{const _t=document.createElement("script");_t.src=V,_t.onload=function(wt){O&&_t.remove(),z(wt)},_t.onerror=function(){G(new Error(`Cannot load script at: ${_t.src}`))},(document.head||document.documentElement).append(_t)})}function i(V){console.log("Deprecated API usage: "+V)}let e;class E{static toDateObject(O){if(!O||typeof O!="string")return null;e||(e=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const z=e.exec(O);if(!z)return null;const G=parseInt(z[1],10);let _t=parseInt(z[2],10);_t=_t>=1&&_t<=12?_t-1:0;let wt=parseInt(z[3],10);wt=wt>=1&&wt<=31?wt:1;let Ot=parseInt(z[4],10);Ot=Ot>=0&&Ot<=23?Ot:0;let q=parseInt(z[5],10);q=q>=0&&q<=59?q:0;let d=parseInt(z[6],10);d=d>=0&&d<=59?d:0;const u=z[7]||"Z";let P=parseInt(z[8],10);P=P>=0&&P<=23?P:0;let j=parseInt(z[9],10)||0;return j=j>=0&&j<=59?j:0,u==="-"?(Ot+=P,q+=j):u==="+"&&(Ot-=P,q-=j),new Date(Date.UTC(G,_t,wt,Ot,q,d))}}a.PDFDateString=E;function x(V,{scale:O=1,rotation:z=0}){const{width:G,height:_t}=V.attributes.style,wt=[0,0,parseInt(G),parseInt(_t)];return new v({viewBox:wt,scale:O,rotation:z})}function N(V){if(V.startsWith("#")){const O=parseInt(V.slice(1),16);return[(O&16711680)>>16,(O&65280)>>8,O&255]}return V.startsWith("rgb(")?V.slice(4,-1).split(",").map(O=>parseInt(O)):V.startsWith("rgba(")?V.slice(5,-1).split(",").map(O=>parseInt(O)).slice(0,3):((0,_.warn)(`Not a valid color format: "${V}"`),[0,0,0])}function I(V){const O=document.createElement("span");O.style.visibility="hidden",document.body.append(O);for(const z of V.keys()){O.style.color=z;const G=window.getComputedStyle(O).color;V.set(z,N(G))}O.remove()}function St(V){const{a:O,b:z,c:G,d:_t,e:wt,f:Ot}=V.getTransform();return[O,z,G,_t,wt,Ot]}function Pt(V){const{a:O,b:z,c:G,d:_t,e:wt,f:Ot}=V.getTransform().invertSelf();return[O,z,G,_t,wt,Ot]}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BaseStandardFontDataFactory=a.BaseSVGFactory=a.BaseCanvasFactory=a.BaseCMapReaderFactory=void 0;var f=y(1);class _{constructor(){this.constructor===_&&(0,f.unreachable)("Cannot initialize BaseCanvasFactory.")}create(b,w){if(b<=0||w<=0)throw new Error("Invalid canvas size");const T=this._createCanvas(b,w);return{canvas:T,context:T.getContext("2d")}}reset(b,w,T){if(!b.canvas)throw new Error("Canvas is not specified");if(w<=0||T<=0)throw new Error("Invalid canvas size");b.canvas.width=w,b.canvas.height=T}destroy(b){if(!b.canvas)throw new Error("Canvas is not specified");b.canvas.width=0,b.canvas.height=0,b.canvas=null,b.context=null}_createCanvas(b,w){(0,f.unreachable)("Abstract method `_createCanvas` called.")}}a.BaseCanvasFactory=_;class Y{constructor({baseUrl:b=null,isCompressed:w=!1}){this.constructor===Y&&(0,f.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=b,this.isCompressed=w}async fetch({name:b}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!b)throw new Error("CMap name must be specified.");const w=this.baseUrl+b+(this.isCompressed?".bcmap":""),T=this.isCompressed?f.CMapCompressionType.BINARY:f.CMapCompressionType.NONE;return this._fetchData(w,T).catch(S=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${w}`)})}_fetchData(b,w){(0,f.unreachable)("Abstract method `_fetchData` called.")}}a.BaseCMapReaderFactory=Y;class W{constructor({baseUrl:b=null}){this.constructor===W&&(0,f.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=b}async fetch({filename:b}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!b)throw new Error("Font filename must be specified.");const w=`${this.baseUrl}${b}`;return this._fetchData(w).catch(T=>{throw new Error(`Unable to load font data at: ${w}`)})}_fetchData(b){(0,f.unreachable)("Abstract method `_fetchData` called.")}}a.BaseStandardFontDataFactory=W;class K{constructor(){this.constructor===K&&(0,f.unreachable)("Cannot initialize BaseSVGFactory.")}create(b,w,T=!1){if(b<=0||w<=0)throw new Error("Invalid SVG dimensions");const S=this._createSVG("svg:svg");return S.setAttribute("version","1.1"),T||(S.setAttribute("width",`${b}px`),S.setAttribute("height",`${w}px`)),S.setAttribute("preserveAspectRatio","none"),S.setAttribute("viewBox",`0 0 ${b} ${w}`),S}createElement(b){if(typeof b!="string")throw new Error("Invalid SVG element type");return this._createSVG(b)}_createSVG(b){(0,f.unreachable)("Abstract method `_createSVG` called.")}}a.BaseSVGFactory=K}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.MurmurHash3_64=void 0;var f=y(1);const _=3285377520,Y=4294901760,W=65535;class K{constructor(b){this.h1=b?b&4294967295:_,this.h2=b?b&4294967295:_}update(b){let w,T;if(typeof b=="string"){w=new Uint8Array(b.length*2),T=0;for(let e=0,E=b.length;e<E;e++){const x=b.charCodeAt(e);x<=255?w[T++]=x:(w[T++]=x>>>8,w[T++]=x&255)}}else if((0,f.isArrayBuffer)(b))w=b.slice(),T=w.byteLength;else throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");const S=T>>2,v=T-S*4,c=new Uint32Array(w.buffer,0,S);let t=0,r=0,o=this.h1,F=this.h2;const m=3432918353,l=461845907,n=m&W,i=l&W;for(let e=0;e<S;e++)e&1?(t=c[e],t=t*m&Y|t*n&W,t=t<<15|t>>>17,t=t*l&Y|t*i&W,o^=t,o=o<<13|o>>>19,o=o*5+3864292196):(r=c[e],r=r*m&Y|r*n&W,r=r<<15|r>>>17,r=r*l&Y|r*i&W,F^=r,F=F<<13|F>>>19,F=F*5+3864292196);switch(t=0,v){case 3:t^=w[S*4+2]<<16;case 2:t^=w[S*4+1]<<8;case 1:t^=w[S*4],t=t*m&Y|t*n&W,t=t<<15|t>>>17,t=t*l&Y|t*i&W,S&1?o^=t:F^=t}this.h1=o,this.h2=F}hexdigest(){let b=this.h1,w=this.h2;b^=w>>>1,b=b*3981806797&Y|b*36045&W,w=w*4283543511&Y|((w<<16|b>>>16)*2950163797&Y)>>>16,b^=w>>>1,b=b*444984403&Y|b*60499&W,w=w*3301882366&Y|((w<<16|b>>>16)*3120437893&Y)>>>16,b^=w>>>1;const T=(b>>>0).toString(16),S=(w>>>0).toString(16);return T.padStart(8,"0")+S.padStart(8,"0")}}a.MurmurHash3_64=K}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.FontLoader=a.FontFaceObject=void 0;var f=y(1);class _{constructor({docId:M,onUnsupportedFeature:b,ownerDocument:w=globalThis.document,styleElement:T=null}){this.constructor===_&&(0,f.unreachable)("Cannot initialize BaseFontLoader."),this.docId=M,this._onUnsupportedFeature=b,this._document=w,this.nativeFontFaces=[],this.styleElement=null}addNativeFontFace(M){this.nativeFontFaces.push(M),this._document.fonts.add(M)}insertRule(M){let b=this.styleElement;b||(b=this.styleElement=this._document.createElement("style"),b.id=`PDFJS_FONT_STYLE_TAG_${this.docId}`,this._document.documentElement.getElementsByTagName("head")[0].append(b));const w=b.sheet;w.insertRule(M,w.cssRules.length)}clear(){for(const M of this.nativeFontFaces)this._document.fonts.delete(M);this.nativeFontFaces.length=0,this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async bind(M){if(M.attached||M.missingFile)return;if(M.attached=!0,this.isFontLoadingAPISupported){const w=M.createNativeFontFace();if(w){this.addNativeFontFace(w);try{await w.loaded}catch(T){throw this._onUnsupportedFeature({featureId:f.UNSUPPORTED_FEATURES.errorFontLoadNative}),(0,f.warn)(`Failed to load font '${w.family}': '${T}'.`),M.disableFontFace=!0,T}}return}const b=M.createFontFaceRule();if(b){if(this.insertRule(b),this.isSyncFontLoadingSupported)return;await new Promise(w=>{const T=this._queueLoadingCallback(w);this._prepareFontLoadEvent([b],[M],T)})}}_queueLoadingCallback(M){(0,f.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){var b;const M=!!((b=this._document)!=null&&b.fonts);return(0,f.shadow)(this,"isFontLoadingAPISupported",M)}get isSyncFontLoadingSupported(){(0,f.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,f.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(M,b,w){(0,f.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let Y;a.FontLoader=Y,a.FontLoader=Y=class extends _{constructor(M){super(M),this.loadingContext={requests:[],nextRequestId:0},this.loadTestFontId=0}get isSyncFontLoadingSupported(){let M=!1;if(typeof navigator>"u")M=!0;else{const b=/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);(b==null?void 0:b[1])>=14&&(M=!0)}return(0,f.shadow)(this,"isSyncFontLoadingSupported",M)}_queueLoadingCallback(M){function b(){for((0,f.assert)(!T.done,"completeRequest() cannot be called twice."),T.done=!0;w.requests.length>0&&w.requests[0].done;){const S=w.requests.shift();setTimeout(S.callback,0)}}const w=this.loadingContext,T={id:`pdfjs-font-loading-${w.nextRequestId++}`,done:!1,complete:b,callback:M};return w.requests.push(T),T}get _loadTestFont(){const M=function(){return atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==")};return(0,f.shadow)(this,"_loadTestFont",M())}_prepareFontLoadEvent(M,b,w){function T(Pt,bt){return Pt.charCodeAt(bt)<<24|Pt.charCodeAt(bt+1)<<16|Pt.charCodeAt(bt+2)<<8|Pt.charCodeAt(bt+3)&255}function S(Pt,bt,V,O){const z=Pt.substring(0,bt),G=Pt.substring(bt+V);return z+O+G}let v,c;const t=this._document.createElement("canvas");t.width=1,t.height=1;const r=t.getContext("2d");let o=0;function F(Pt,bt){if(o++,o>30){(0,f.warn)("Load test font never loaded."),bt();return}if(r.font="30px "+Pt,r.fillText(".",0,20),r.getImageData(0,0,1,1).data[3]>0){bt();return}setTimeout(F.bind(null,Pt,bt))}const m=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=S(l,976,m.length,m);const i=16,e=1482184792;let E=T(l,i);for(v=0,c=m.length-3;v<c;v+=4)E=E-e+T(m,v)|0;v<m.length&&(E=E-e+T(m+"XXX",v)|0),l=S(l,i,4,(0,f.string32)(E));const x=`url(data:font/opentype;base64,${btoa(l)});`,N=`@font-face {font-family:"${m}";src:${x}}`;this.insertRule(N);const I=[];for(const Pt of b)I.push(Pt.loadedName);I.push(m);const St=this._document.createElement("div");St.style.visibility="hidden",St.style.width=St.style.height="10px",St.style.position="absolute",St.style.top=St.style.left="0px";for(const Pt of I){const bt=this._document.createElement("span");bt.textContent="Hi",bt.style.fontFamily=Pt,St.append(bt)}this._document.body.append(St),F(m,()=>{St.remove(),w.complete()})}};class W{constructor(M,{isEvalSupported:b=!0,disableFontFace:w=!1,ignoreErrors:T=!1,onUnsupportedFeature:S,fontRegistry:v=null}){this.compiledGlyphs=Object.create(null);for(const c in M)this[c]=M[c];this.isEvalSupported=b!==!1,this.disableFontFace=w===!0,this.ignoreErrors=T===!0,this._onUnsupportedFeature=S,this.fontRegistry=v}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let M;if(!this.cssFontInfo)M=new FontFace(this.loadedName,this.data,{});else{const b={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(b.style=`oblique ${this.cssFontInfo.italicAngle}deg`),M=new FontFace(this.cssFontInfo.fontFamily,this.data,b)}return this.fontRegistry&&this.fontRegistry.registerFont(this),M}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const M=(0,f.bytesToString)(this.data),b=`url(data:${this.mimetype};base64,${btoa(M)});`;let w;if(!this.cssFontInfo)w=`@font-face {font-family:"${this.loadedName}";src:${b}}`;else{let T=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(T+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),w=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${T}src:${b}}`}return this.fontRegistry&&this.fontRegistry.registerFont(this,b),w}getPathGenerator(M,b){if(this.compiledGlyphs[b]!==void 0)return this.compiledGlyphs[b];let w;try{w=M.get(this.loadedName+"_path_"+b)}catch(T){if(!this.ignoreErrors)throw T;return this._onUnsupportedFeature({featureId:f.UNSUPPORTED_FEATURES.errorFontGetPath}),(0,f.warn)(`getPathGenerator - ignoring character: "${T}".`),this.compiledGlyphs[b]=function(S,v){}}if(this.isEvalSupported&&f.FeatureTest.isEvalSupported){const T=[];for(const S of w){const v=S.args!==void 0?S.args.join(","):"";T.push("c.",S.cmd,"(",v,`);
|
|
39
|
+
`)}return this.compiledGlyphs[b]=new Function("c","size",T.join(""))}return this.compiledGlyphs[b]=function(T,S){for(const v of w)v.cmd==="scale"&&(v.args=[S,-S]),T[v.cmd].apply(T,v.args)}}}a.FontFaceObject=W}),((p,a,y)=>{var _t,fn;Object.defineProperty(a,"__esModule",{value:!0}),a.CanvasGraphics=void 0;var f=y(8),_=y(1),Y=y(13),W=y(14),K=y(3);const M=16,b=100,w=4096,T=15,S=10,v=K.isNodeJS&&typeof Path2D>"u"?-1:1e3,c=16;function t(q,d){if(q._removeMirroring)throw new Error("Context is already forwarding operations.");q.__originalSave=q.save,q.__originalRestore=q.restore,q.__originalRotate=q.rotate,q.__originalScale=q.scale,q.__originalTranslate=q.translate,q.__originalTransform=q.transform,q.__originalSetTransform=q.setTransform,q.__originalResetTransform=q.resetTransform,q.__originalClip=q.clip,q.__originalMoveTo=q.moveTo,q.__originalLineTo=q.lineTo,q.__originalBezierCurveTo=q.bezierCurveTo,q.__originalRect=q.rect,q.__originalClosePath=q.closePath,q.__originalBeginPath=q.beginPath,q._removeMirroring=()=>{q.save=q.__originalSave,q.restore=q.__originalRestore,q.rotate=q.__originalRotate,q.scale=q.__originalScale,q.translate=q.__originalTranslate,q.transform=q.__originalTransform,q.setTransform=q.__originalSetTransform,q.resetTransform=q.__originalResetTransform,q.clip=q.__originalClip,q.moveTo=q.__originalMoveTo,q.lineTo=q.__originalLineTo,q.bezierCurveTo=q.__originalBezierCurveTo,q.rect=q.__originalRect,q.closePath=q.__originalClosePath,q.beginPath=q.__originalBeginPath,delete q._removeMirroring},q.save=function(){d.save(),this.__originalSave()},q.restore=function(){d.restore(),this.__originalRestore()},q.translate=function(P,j){d.translate(P,j),this.__originalTranslate(P,j)},q.scale=function(P,j){d.scale(P,j),this.__originalScale(P,j)},q.transform=function(P,j,U,$,s,h){d.transform(P,j,U,$,s,h),this.__originalTransform(P,j,U,$,s,h)},q.setTransform=function(P,j,U,$,s,h){d.setTransform(P,j,U,$,s,h),this.__originalSetTransform(P,j,U,$,s,h)},q.resetTransform=function(){d.resetTransform(),this.__originalResetTransform()},q.rotate=function(P){d.rotate(P),this.__originalRotate(P)},q.clip=function(P){d.clip(P),this.__originalClip(P)},q.moveTo=function(u,P){d.moveTo(u,P),this.__originalMoveTo(u,P)},q.lineTo=function(u,P){d.lineTo(u,P),this.__originalLineTo(u,P)},q.bezierCurveTo=function(u,P,j,U,$,s){d.bezierCurveTo(u,P,j,U,$,s),this.__originalBezierCurveTo(u,P,j,U,$,s)},q.rect=function(u,P,j,U){d.rect(u,P,j,U),this.__originalRect(u,P,j,U)},q.closePath=function(){d.closePath(),this.__originalClosePath()},q.beginPath=function(){d.beginPath(),this.__originalBeginPath()}}class r{constructor(d){this.canvasFactory=d,this.cache=Object.create(null)}getCanvas(d,u,P){let j;return this.cache[d]!==void 0?(j=this.cache[d],this.canvasFactory.reset(j,u,P)):(j=this.canvasFactory.create(u,P),this.cache[d]=j),j}delete(d){delete this.cache[d]}clear(){for(const d in this.cache){const u=this.cache[d];this.canvasFactory.destroy(u),delete this.cache[d]}}}function o(q,d,u,P,j,U,$,s,h,C){const[A,k,B,D,g,L]=(0,f.getCurrentTransform)(q);if(k===0&&B===0){const Q=$*A+g,Ct=Math.round(Q),Tt=s*D+L,It=Math.round(Tt),kt=($+h)*A+g,Ht=Math.abs(Math.round(kt)-Ct)||1,Wt=(s+C)*D+L,jt=Math.abs(Math.round(Wt)-It)||1;return q.setTransform(Math.sign(A),0,0,Math.sign(D),Ct,It),q.drawImage(d,u,P,j,U,0,0,Ht,jt),q.setTransform(A,k,B,D,g,L),[Ht,jt]}if(A===0&&D===0){const Q=s*B+g,Ct=Math.round(Q),Tt=$*k+L,It=Math.round(Tt),kt=(s+C)*B+g,Ht=Math.abs(Math.round(kt)-Ct)||1,Wt=($+h)*k+L,jt=Math.abs(Math.round(Wt)-It)||1;return q.setTransform(0,Math.sign(k),Math.sign(B),0,Ct,It),q.drawImage(d,u,P,j,U,0,0,jt,Ht),q.setTransform(A,k,B,D,g,L),[jt,Ht]}q.drawImage(d,u,P,j,U,$,s,h,C);const At=Math.hypot(A,k),H=Math.hypot(B,D);return[At*h,H*C]}function F(q){const{width:d,height:u}=q;if(d>v||u>v)return null;const P=1e3,j=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),U=d+1;let $=new Uint8Array(U*(u+1)),s,h,C;const A=d+7&-8;let k=new Uint8Array(A*u),B=0;for(const H of q.data){let Q=128;for(;Q>0;)k[B++]=H&Q?0:255,Q>>=1}let D=0;for(B=0,k[B]!==0&&($[0]=1,++D),h=1;h<d;h++)k[B]!==k[B+1]&&($[h]=k[B]?2:1,++D),B++;for(k[B]!==0&&($[h]=2,++D),s=1;s<u;s++){B=s*A,C=s*U,k[B-A]!==k[B]&&($[C]=k[B]?1:8,++D);let H=(k[B]?4:0)+(k[B-A]?8:0);for(h=1;h<d;h++)H=(H>>2)+(k[B+1]?4:0)+(k[B-A+1]?8:0),j[H]&&($[C+h]=j[H],++D),B++;if(k[B-A]!==k[B]&&($[C+h]=k[B]?2:4,++D),D>P)return null}for(B=A*(u-1),C=s*U,k[B]!==0&&($[C]=8,++D),h=1;h<d;h++)k[B]!==k[B+1]&&($[C+h]=k[B]?4:8,++D),B++;if(k[B]!==0&&($[C+h]=4,++D),D>P)return null;const g=new Int32Array([0,U,-1,0,-U,0,0,0,1]),L=new Path2D;for(s=0;D&&s<=u;s++){let H=s*U;const Q=H+d;for(;H<Q&&!$[H];)H++;if(H===Q)continue;L.moveTo(H%U,s);const Ct=H;let Tt=$[H];do{const It=g[Tt];do H+=It;while(!$[H]);const kt=$[H];kt!==5&&kt!==10?(Tt=kt,$[H]=0):(Tt=kt&51*Tt>>4,$[H]&=Tt>>2|Tt<<2),L.lineTo(H%U,H/U|0),$[H]||--D}while(Ct!==H);--s}return k=null,$=null,function(H){H.save(),H.scale(1/d,-1/u),H.translate(0,-u),H.fill(L),H.beginPath(),H.restore()}}class m{constructor(d,u){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=_.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=_.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=_.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=null,this.startNewPathAndClipBox([0,0,d,u])}clone(){const d=Object.create(this);return d.clipBox=this.clipBox.slice(),d}setCurrentPoint(d,u){this.x=d,this.y=u}updatePathMinMax(d,u,P){[u,P]=_.Util.applyTransform([u,P],d),this.minX=Math.min(this.minX,u),this.minY=Math.min(this.minY,P),this.maxX=Math.max(this.maxX,u),this.maxY=Math.max(this.maxY,P)}updateRectMinMax(d,u){const P=_.Util.applyTransform(u,d),j=_.Util.applyTransform(u.slice(2),d);this.minX=Math.min(this.minX,P[0],j[0]),this.minY=Math.min(this.minY,P[1],j[1]),this.maxX=Math.max(this.maxX,P[0],j[0]),this.maxY=Math.max(this.maxY,P[1],j[1])}updateScalingPathMinMax(d,u){_.Util.scaleMinMax(d,u),this.minX=Math.min(this.minX,u[0]),this.maxX=Math.max(this.maxX,u[1]),this.minY=Math.min(this.minY,u[2]),this.maxY=Math.max(this.maxY,u[3])}updateCurvePathMinMax(d,u,P,j,U,$,s,h,C,A){const k=_.Util.bezierBoundingBox(u,P,j,U,$,s,h,C);if(A){A[0]=Math.min(A[0],k[0],k[2]),A[1]=Math.max(A[1],k[0],k[2]),A[2]=Math.min(A[2],k[1],k[3]),A[3]=Math.max(A[3],k[1],k[3]);return}this.updateRectMinMax(d,k)}getPathBoundingBox(d=Y.PathType.FILL,u=null){const P=[this.minX,this.minY,this.maxX,this.maxY];if(d===Y.PathType.STROKE){u||(0,_.unreachable)("Stroke bounding box must include transform.");const j=_.Util.singularValueDecompose2dScale(u),U=j[0]*this.lineWidth/2,$=j[1]*this.lineWidth/2;P[0]-=U,P[1]-=$,P[2]+=U,P[3]+=$}return P}updateClipFromPath(){const d=_.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(d||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(d){this.clipBox=d,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(d=Y.PathType.FILL,u=null){return _.Util.intersect(this.clipBox,this.getPathBoundingBox(d,u))}}function l(q,d,u=null){if(typeof ImageData<"u"&&d instanceof ImageData){q.putImageData(d,0,0);return}const P=d.height,j=d.width,U=P%c,$=(P-U)/c,s=U===0?$:$+1,h=q.createImageData(j,c);let C=0,A;const k=d.data,B=h.data;let D,g,L,At,H,Q,Ct,Tt;if(u)switch(u.length){case 1:H=u[0],Q=u[0],Ct=u[0],Tt=u[0];break;case 4:H=u[0],Q=u[1],Ct=u[2],Tt=u[3];break}if(d.kind===_.ImageKind.GRAYSCALE_1BPP){const It=k.byteLength,kt=new Uint32Array(B.buffer,0,B.byteLength>>2),Ht=kt.length,Wt=j+7>>3;let jt=4294967295,Xt=_.FeatureTest.isLittleEndian?4278190080:255;for(Tt&&Tt[0]===255&&Tt[255]===0&&([jt,Xt]=[Xt,jt]),D=0;D<s;D++){for(L=D<$?c:U,A=0,g=0;g<L;g++){const Vt=It-C;let te=0;const Gt=Vt>Wt?j:Vt*8-7,Yt=Gt&-8;let Kt=0,Qt=0;for(;te<Yt;te+=8)Qt=k[C++],kt[A++]=Qt&128?jt:Xt,kt[A++]=Qt&64?jt:Xt,kt[A++]=Qt&32?jt:Xt,kt[A++]=Qt&16?jt:Xt,kt[A++]=Qt&8?jt:Xt,kt[A++]=Qt&4?jt:Xt,kt[A++]=Qt&2?jt:Xt,kt[A++]=Qt&1?jt:Xt;for(;te<Gt;te++)Kt===0&&(Qt=k[C++],Kt=128),kt[A++]=Qt&Kt?jt:Xt,Kt>>=1}for(;A<Ht;)kt[A++]=0;q.putImageData(h,0,D*c)}}else if(d.kind===_.ImageKind.RGBA_32BPP){const It=!!(H||Q||Ct);for(g=0,At=j*c*4,D=0;D<$;D++){if(B.set(k.subarray(C,C+At)),C+=At,It)for(let kt=0;kt<At;kt+=4)H&&(B[kt+0]=H[B[kt+0]]),Q&&(B[kt+1]=Q[B[kt+1]]),Ct&&(B[kt+2]=Ct[B[kt+2]]);q.putImageData(h,0,g),g+=c}if(D<s){if(At=j*U*4,B.set(k.subarray(C,C+At)),It)for(let kt=0;kt<At;kt+=4)H&&(B[kt+0]=H[B[kt+0]]),Q&&(B[kt+1]=Q[B[kt+1]]),Ct&&(B[kt+2]=Ct[B[kt+2]]);q.putImageData(h,0,g)}}else if(d.kind===_.ImageKind.RGB_24BPP){const It=!!(H||Q||Ct);for(L=c,At=j*L,D=0;D<s;D++){for(D>=$&&(L=U,At=j*L),A=0,g=At;g--;)B[A++]=k[C++],B[A++]=k[C++],B[A++]=k[C++],B[A++]=255;if(It)for(let kt=0;kt<A;kt+=4)H&&(B[kt+0]=H[B[kt+0]]),Q&&(B[kt+1]=Q[B[kt+1]]),Ct&&(B[kt+2]=Ct[B[kt+2]]);q.putImageData(h,0,D*c)}}else throw new Error(`bad image kind: ${d.kind}`)}function n(q,d){if(d.bitmap){q.drawImage(d.bitmap,0,0);return}const u=d.height,P=d.width,j=u%c,U=(u-j)/c,$=j===0?U:U+1,s=q.createImageData(P,c);let h=0;const C=d.data,A=s.data;for(let k=0;k<$;k++){const B=k<U?c:j;({srcPos:h}=(0,W.applyMaskImageData)({src:C,srcPos:h,dest:A,width:P,height:B})),q.putImageData(s,0,k*c)}}function i(q,d){const u=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(let P=0,j=u.length;P<j;P++){const U=u[P];q[U]!==void 0&&(d[U]=q[U])}q.setLineDash!==void 0&&(d.setLineDash(q.getLineDash()),d.lineDashOffset=q.lineDashOffset)}function e(q,d){q.strokeStyle=q.fillStyle=d||"#000000",q.fillRule="nonzero",q.globalAlpha=1,q.lineWidth=1,q.lineCap="butt",q.lineJoin="miter",q.miterLimit=10,q.globalCompositeOperation="source-over",q.font="10px sans-serif",q.setLineDash!==void 0&&(q.setLineDash([]),q.lineDashOffset=0)}function E(q,d,u,P){const j=q.length;for(let U=3;U<j;U+=4){const $=q[U];if($===0)q[U-3]=d,q[U-2]=u,q[U-1]=P;else if($<255){const s=255-$;q[U-3]=q[U-3]*$+d*s>>8,q[U-2]=q[U-2]*$+u*s>>8,q[U-1]=q[U-1]*$+P*s>>8}}}function x(q,d,u){const P=q.length,j=1/255;for(let U=3;U<P;U+=4){const $=u?u[q[U]]:q[U];d[U]=d[U]*$*j|0}}function N(q,d,u){const P=q.length;for(let j=3;j<P;j+=4){const U=q[j-3]*77+q[j-2]*152+q[j-1]*28;d[j]=u?d[j]*u[U>>8]>>8:d[j]*U>>16}}function I(q,d,u,P,j,U,$,s,h,C,A){const k=!!U,B=k?U[0]:0,D=k?U[1]:0,g=k?U[2]:0;let L;j==="Luminosity"?L=N:L=x;const H=Math.min(P,Math.ceil(1048576/u));for(let Q=0;Q<P;Q+=H){const Ct=Math.min(H,P-Q),Tt=q.getImageData(s-C,Q+(h-A),u,Ct),It=d.getImageData(s,Q+h,u,Ct);k&&E(Tt.data,B,D,g),L(Tt.data,It.data,$),d.putImageData(It,s,Q+h)}}function St(q,d,u,P){const j=P[0],U=P[1],$=P[2]-j,s=P[3]-U;$===0||s===0||(I(d.context,u,$,s,d.subtype,d.backdrop,d.transferMap,j,U,d.offsetX,d.offsetY),q.save(),q.globalAlpha=1,q.globalCompositeOperation="source-over",q.setTransform(1,0,0,1,0,0),q.drawImage(u.canvas,0,0),q.restore())}function Pt(q,d){const u=_.Util.singularValueDecompose2dScale(q);u[0]=Math.fround(u[0]),u[1]=Math.fround(u[1]);const P=Math.fround((globalThis.devicePixelRatio||1)*f.PixelsPerInch.PDF_TO_CSS_UNITS);return d!==void 0?d:u[0]<=P||u[1]<=P}const bt=["butt","round","square"],V=["miter","round","bevel"],O={},z={},Ot=class Ot{constructor(d,u,P,j,U,$,s,h){Lt(this,_t);this.ctx=d,this.current=new m(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=u,this.objs=P,this.canvasFactory=j,this.imageLayer=U,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=[],this.optionalContentConfig=$,this.cachedCanvases=new r(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.backgroundColor=(h==null?void 0:h.background)||null,this.foregroundColor=(h==null?void 0:h.foreground)||null,this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(d,u=null){return typeof d=="string"?d.startsWith("g_")?this.commonObjs.get(d):this.objs.get(d):u}beginDrawing({transform:d,viewport:u,transparency:P=!1,background:j=null}){const U=this.ctx.canvas.width,$=this.ctx.canvas.height,s=j||"#ffffff";if(this.ctx.save(),this.foregroundColor&&this.backgroundColor){this.ctx.fillStyle=this.foregroundColor;const h=this.foregroundColor=this.ctx.fillStyle;this.ctx.fillStyle=this.backgroundColor;const C=this.backgroundColor=this.ctx.fillStyle;let A=!0,k=s;if(this.ctx.fillStyle=s,k=this.ctx.fillStyle,A=typeof k=="string"&&/^#[0-9A-Fa-f]{6}$/.test(k),h==="#000000"&&C==="#ffffff"||h===C||!A)this.foregroundColor=this.backgroundColor=null;else{const[B,D,g]=(0,f.getRGB)(k),L=H=>(H/=255,H<=.03928?H/12.92:((H+.055)/1.055)**2.4),At=Math.round(.2126*L(B)+.7152*L(D)+.0722*L(g));this.selectColor=(H,Q,Ct)=>{const Tt=.2126*L(H)+.7152*L(Q)+.0722*L(Ct);return Math.round(Tt)===At?C:h}}}if(this.ctx.fillStyle=this.backgroundColor||s,this.ctx.fillRect(0,0,U,$),this.ctx.restore(),P){const h=this.cachedCanvases.getCanvas("transparent",U,$);this.compositeCtx=this.ctx,this.transparentCanvas=h.canvas,this.ctx=h.context,this.ctx.save(),this.ctx.transform(...(0,f.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),e(this.ctx,this.foregroundColor),d&&(this.ctx.transform(...d),this.outputScaleX=d[0],this.outputScaleY=d[0]),this.ctx.transform(...u.transform),this.viewportScale=u.scale,this.baseTransform=(0,f.getCurrentTransform)(this.ctx),this.imageLayer&&((0,f.deprecated)("The `imageLayer` functionality will be removed in the future."),this.imageLayer.beginLayout())}executeOperatorList(d,u,P,j){const U=d.argsArray,$=d.fnArray;let s=u||0;const h=U.length;if(h===s)return s;const C=h-s>S&&typeof P=="function",A=C?Date.now()+T:0;let k=0;const B=this.commonObjs,D=this.objs;let g;for(;;){if(j!==void 0&&s===j.nextBreakPoint)return j.breakIt(s,P),s;if(g=$[s],g!==_.OPS.dependency)this[g].apply(this,U[s]);else for(const L of U[s]){const At=L.startsWith("g_")?B:D;if(!At.has(L))return At.get(L,P),s}if(s++,s===h)return s;if(C&&++k>S){if(Date.now()>A)return P(),s;k=0}}}endDrawing(){Mt(this,_t,fn).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const d of this._cachedBitmapsMap.values()){for(const u of d.values())typeof HTMLCanvasElement<"u"&&u instanceof HTMLCanvasElement&&(u.width=u.height=0);d.clear()}this._cachedBitmapsMap.clear(),this.imageLayer&&this.imageLayer.endLayout()}_scaleImage(d,u){const P=d.width,j=d.height;let U=Math.max(Math.hypot(u[0],u[1]),1),$=Math.max(Math.hypot(u[2],u[3]),1),s=P,h=j,C="prescale1",A,k;for(;U>2&&s>1||$>2&&h>1;){let B=s,D=h;U>2&&s>1&&(B=Math.ceil(s/2),U/=s/B),$>2&&h>1&&(D=Math.ceil(h/2),$/=h/D),A=this.cachedCanvases.getCanvas(C,B,D),k=A.context,k.clearRect(0,0,B,D),k.drawImage(d,0,0,s,h,0,0,B,D),d=A.canvas,s=B,h=D,C=C==="prescale1"?"prescale2":"prescale1"}return{img:d,paintWidth:s,paintHeight:h}}_createMaskCanvas(d){const u=this.ctx,{width:P,height:j}=d,U=this.current.fillColor,$=this.current.patternFill,s=(0,f.getCurrentTransform)(u);let h,C,A,k;if((d.bitmap||d.data)&&d.count>1){const Ht=d.bitmap||d.data.buffer,Wt=s.slice(0,4);C=JSON.stringify($?Wt:[Wt,U]),h=this._cachedBitmapsMap.get(Ht),h||(h=new Map,this._cachedBitmapsMap.set(Ht,h));const jt=h.get(C);if(jt&&!$){const Xt=Math.round(Math.min(s[0],s[2])+s[4]),Vt=Math.round(Math.min(s[1],s[3])+s[5]);return{canvas:jt,offsetX:Xt,offsetY:Vt}}A=jt}A||(k=this.cachedCanvases.getCanvas("maskCanvas",P,j),n(k.context,d));let B=_.Util.transform(s,[1/P,0,0,-1/j,0,0]);B=_.Util.transform(B,[1,0,0,1,0,-j]);const D=_.Util.applyTransform([0,0],B),g=_.Util.applyTransform([P,j],B),L=_.Util.normalizeRect([D[0],D[1],g[0],g[1]]),At=Math.round(L[2]-L[0])||1,H=Math.round(L[3]-L[1])||1,Q=this.cachedCanvases.getCanvas("fillCanvas",At,H),Ct=Q.context,Tt=Math.min(D[0],g[0]),It=Math.min(D[1],g[1]);Ct.translate(-Tt,-It),Ct.transform(...B),A||(A=this._scaleImage(k.canvas,(0,f.getCurrentTransformInverse)(Ct)),A=A.img,h&&$&&h.set(C,A)),Ct.imageSmoothingEnabled=Pt((0,f.getCurrentTransform)(Ct),d.interpolate),o(Ct,A,0,0,A.width,A.height,0,0,P,j),Ct.globalCompositeOperation="source-in";const kt=_.Util.transform((0,f.getCurrentTransformInverse)(Ct),[1,0,0,1,-Tt,-It]);return Ct.fillStyle=$?U.getPattern(u,this,kt,Y.PathType.FILL):U,Ct.fillRect(0,0,P,j),h&&!$&&(this.cachedCanvases.delete("fillCanvas"),h.set(C,Q.canvas)),{canvas:Q.canvas,offsetX:Math.round(Tt),offsetY:Math.round(It)}}setLineWidth(d){d!==this.current.lineWidth&&(this._cachedScaleForStroking=null),this.current.lineWidth=d,this.ctx.lineWidth=d}setLineCap(d){this.ctx.lineCap=bt[d]}setLineJoin(d){this.ctx.lineJoin=V[d]}setMiterLimit(d){this.ctx.miterLimit=d}setDash(d,u){const P=this.ctx;P.setLineDash!==void 0&&(P.setLineDash(d),P.lineDashOffset=u)}setRenderingIntent(d){}setFlatness(d){}setGState(d){for(let u=0,P=d.length;u<P;u++){const j=d[u],U=j[0],$=j[1];switch(U){case"LW":this.setLineWidth($);break;case"LC":this.setLineCap($);break;case"LJ":this.setLineJoin($);break;case"ML":this.setMiterLimit($);break;case"D":this.setDash($[0],$[1]);break;case"RI":this.setRenderingIntent($);break;case"FL":this.setFlatness($);break;case"Font":this.setFont($[0],$[1]);break;case"CA":this.current.strokeAlpha=j[1];break;case"ca":this.current.fillAlpha=j[1],this.ctx.globalAlpha=j[1];break;case"BM":this.ctx.globalCompositeOperation=$;break;case"SMask":this.current.activeSMask=$?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.current.transferMaps=$}}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const d=this.inSMaskMode;this.current.activeSMask&&!d?this.beginSMaskMode():!this.current.activeSMask&&d&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const d=this.ctx.canvas.width,u=this.ctx.canvas.height,P="smaskGroupAt"+this.groupLevel,j=this.cachedCanvases.getCanvas(P,d,u);this.suspendedCtx=this.ctx,this.ctx=j.context;const U=this.ctx;U.setTransform(...(0,f.getCurrentTransform)(this.suspendedCtx)),i(this.suspendedCtx,U),t(U,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),i(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(d){if(!this.current.activeSMask)return;d?(d[0]=Math.floor(d[0]),d[1]=Math.floor(d[1]),d[2]=Math.ceil(d[2]),d[3]=Math.ceil(d[3])):d=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const u=this.current.activeSMask,P=this.suspendedCtx;St(P,u,this.ctx,d),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}save(){this.inSMaskMode?(i(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const d=this.current;this.stateStack.push(d),this.current=d.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),i(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null)}transform(d,u,P,j,U,$){this.ctx.transform(d,u,P,j,U,$),this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null}constructPath(d,u,P){const j=this.ctx,U=this.current;let $=U.x,s=U.y,h,C;const A=(0,f.getCurrentTransform)(j),k=A[0]===0&&A[3]===0||A[1]===0&&A[2]===0,B=k?P.slice(0):null;for(let D=0,g=0,L=d.length;D<L;D++)switch(d[D]|0){case _.OPS.rectangle:$=u[g++],s=u[g++];const At=u[g++],H=u[g++],Q=$+At,Ct=s+H;j.moveTo($,s),At===0||H===0?j.lineTo(Q,Ct):(j.lineTo(Q,s),j.lineTo(Q,Ct),j.lineTo($,Ct)),k||U.updateRectMinMax(A,[$,s,Q,Ct]),j.closePath();break;case _.OPS.moveTo:$=u[g++],s=u[g++],j.moveTo($,s),k||U.updatePathMinMax(A,$,s);break;case _.OPS.lineTo:$=u[g++],s=u[g++],j.lineTo($,s),k||U.updatePathMinMax(A,$,s);break;case _.OPS.curveTo:h=$,C=s,$=u[g+4],s=u[g+5],j.bezierCurveTo(u[g],u[g+1],u[g+2],u[g+3],$,s),U.updateCurvePathMinMax(A,h,C,u[g],u[g+1],u[g+2],u[g+3],$,s,B),g+=6;break;case _.OPS.curveTo2:h=$,C=s,j.bezierCurveTo($,s,u[g],u[g+1],u[g+2],u[g+3]),U.updateCurvePathMinMax(A,h,C,$,s,u[g],u[g+1],u[g+2],u[g+3],B),$=u[g+2],s=u[g+3],g+=4;break;case _.OPS.curveTo3:h=$,C=s,$=u[g+2],s=u[g+3],j.bezierCurveTo(u[g],u[g+1],$,s,$,s),U.updateCurvePathMinMax(A,h,C,u[g],u[g+1],$,s,$,s,B),g+=4;break;case _.OPS.closePath:j.closePath();break}k&&U.updateScalingPathMinMax(A,B),U.setCurrentPoint($,s)}closePath(){this.ctx.closePath()}stroke(d){d=typeof d<"u"?d:!0;const u=this.ctx,P=this.current.strokeColor;u.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof P=="object"&&(P!=null&&P.getPattern)?(u.save(),u.strokeStyle=P.getPattern(u,this,(0,f.getCurrentTransformInverse)(u),Y.PathType.STROKE),this.rescaleAndStroke(!1),u.restore()):this.rescaleAndStroke(!0)),d&&this.consumePath(this.current.getClippedPathBoundingBox()),u.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(d){d=typeof d<"u"?d:!0;const u=this.ctx,P=this.current.fillColor,j=this.current.patternFill;let U=!1;j&&(u.save(),u.fillStyle=P.getPattern(u,this,(0,f.getCurrentTransformInverse)(u),Y.PathType.FILL),U=!0);const $=this.current.getClippedPathBoundingBox();this.contentVisible&&$!==null&&(this.pendingEOFill?(u.fill("evenodd"),this.pendingEOFill=!1):u.fill()),U&&u.restore(),d&&this.consumePath($)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=O}eoClip(){this.pendingClip=z}beginText(){this.current.textMatrix=_.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const d=this.pendingTextPaths,u=this.ctx;if(d===void 0){u.beginPath();return}u.save(),u.beginPath();for(const P of d)u.setTransform(...P.transform),u.translate(P.x,P.y),P.addToPath(u,P.fontSize);u.restore(),u.clip(),u.beginPath(),delete this.pendingTextPaths}setCharSpacing(d){this.current.charSpacing=d}setWordSpacing(d){this.current.wordSpacing=d}setHScale(d){this.current.textHScale=d/100}setLeading(d){this.current.leading=-d}setFont(d,u){const P=this.commonObjs.get(d),j=this.current;if(!P)throw new Error(`Can't find font for ${d}`);if(j.fontMatrix=P.fontMatrix||_.FONT_IDENTITY_MATRIX,(j.fontMatrix[0]===0||j.fontMatrix[3]===0)&&(0,_.warn)("Invalid font matrix for font "+d),u<0?(u=-u,j.fontDirection=-1):j.fontDirection=1,this.current.font=P,this.current.fontSize=u,P.isType3Font)return;const U=P.loadedName||"sans-serif";let $="normal";P.black?$="900":P.bold&&($="bold");const s=P.italic?"italic":"normal",h=`"${U}", ${P.fallbackName}`;let C=u;u<M?C=M:u>b&&(C=b),this.current.fontSizeScale=u/C,this.ctx.font=`${s} ${$} ${C}px ${h}`}setTextRenderingMode(d){this.current.textRenderingMode=d}setTextRise(d){this.current.textRise=d}moveText(d,u){this.current.x=this.current.lineX+=d,this.current.y=this.current.lineY+=u}setLeadingMoveText(d,u){this.setLeading(-u),this.moveText(d,u)}setTextMatrix(d,u,P,j,U,$){this.current.textMatrix=[d,u,P,j,U,$],this.current.textMatrixScale=Math.hypot(d,u),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(d,u,P,j){const U=this.ctx,$=this.current,s=$.font,h=$.textRenderingMode,C=$.fontSize/$.fontSizeScale,A=h&_.TextRenderingMode.FILL_STROKE_MASK,k=!!(h&_.TextRenderingMode.ADD_TO_PATH_FLAG),B=$.patternFill&&!s.missingFile;let D;(s.disableFontFace||k||B)&&(D=s.getPathGenerator(this.commonObjs,d)),s.disableFontFace||B?(U.save(),U.translate(u,P),U.beginPath(),D(U,C),j&&U.setTransform(...j),(A===_.TextRenderingMode.FILL||A===_.TextRenderingMode.FILL_STROKE)&&U.fill(),(A===_.TextRenderingMode.STROKE||A===_.TextRenderingMode.FILL_STROKE)&&U.stroke(),U.restore()):((A===_.TextRenderingMode.FILL||A===_.TextRenderingMode.FILL_STROKE)&&U.fillText(d,u,P),(A===_.TextRenderingMode.STROKE||A===_.TextRenderingMode.FILL_STROKE)&&U.strokeText(d,u,P)),k&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,f.getCurrentTransform)(U),x:u,y:P,fontSize:C,addToPath:D})}get isFontSubpixelAAEnabled(){const{context:d}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);d.scale(1.5,1),d.fillText("I",0,10);const u=d.getImageData(0,0,10,10).data;let P=!1;for(let j=3;j<u.length;j+=4)if(u[j]>0&&u[j]<255){P=!0;break}return(0,_.shadow)(this,"isFontSubpixelAAEnabled",P)}showText(d){const u=this.current,P=u.font;if(P.isType3Font)return this.showType3Text(d);const j=u.fontSize;if(j===0)return;const U=this.ctx,$=u.fontSizeScale,s=u.charSpacing,h=u.wordSpacing,C=u.fontDirection,A=u.textHScale*C,k=d.length,B=P.vertical,D=B?1:-1,g=P.defaultVMetrics,L=j*u.fontMatrix[0],At=u.textRenderingMode===_.TextRenderingMode.FILL&&!P.disableFontFace&&!u.patternFill;U.save(),U.transform(...u.textMatrix),U.translate(u.x,u.y+u.textRise),C>0?U.scale(A,-1):U.scale(A,1);let H;if(u.patternFill){U.save();const kt=u.fillColor.getPattern(U,this,(0,f.getCurrentTransformInverse)(U),Y.PathType.FILL);H=(0,f.getCurrentTransform)(U),U.restore(),U.fillStyle=kt}let Q=u.lineWidth;const Ct=u.textMatrixScale;if(Ct===0||Q===0){const kt=u.textRenderingMode&_.TextRenderingMode.FILL_STROKE_MASK;(kt===_.TextRenderingMode.STROKE||kt===_.TextRenderingMode.FILL_STROKE)&&(Q=this.getSinglePixelWidth())}else Q/=Ct;$!==1&&(U.scale($,$),Q/=$),U.lineWidth=Q;let Tt=0,It;for(It=0;It<k;++It){const kt=d[It];if(typeof kt=="number"){Tt+=D*kt*j/1e3;continue}let Ht=!1;const Wt=(kt.isSpace?h:0)+s,jt=kt.fontChar,Xt=kt.accent;let Vt,te,Gt=kt.width;if(B){const Kt=kt.vmetric||g,Qt=-(kt.vmetric?Kt[1]:Gt*.5)*L,le=Kt[2]*L;Gt=Kt?-Kt[0]:Gt,Vt=Qt/$,te=(Tt+le)/$}else Vt=Tt/$,te=0;if(P.remeasure&&Gt>0){const Kt=U.measureText(jt).width*1e3/j*$;if(Gt<Kt&&this.isFontSubpixelAAEnabled){const Qt=Gt/Kt;Ht=!0,U.save(),U.scale(Qt,1),Vt/=Qt}else Gt!==Kt&&(Vt+=(Gt-Kt)/2e3*j/$)}if(this.contentVisible&&(kt.isInFont||P.missingFile)){if(At&&!Xt)U.fillText(jt,Vt,te);else if(this.paintChar(jt,Vt,te,H),Xt){const Kt=Vt+j*Xt.offset.x/$,Qt=te-j*Xt.offset.y/$;this.paintChar(Xt.fontChar,Kt,Qt,H)}}let Yt;B?Yt=Gt*L-Wt*C:Yt=Gt*L+Wt*C,Tt+=Yt,Ht&&U.restore()}B?u.y-=Tt:u.x+=Tt*A,U.restore(),this.compose()}showType3Text(d){const u=this.ctx,P=this.current,j=P.font,U=P.fontSize,$=P.fontDirection,s=j.vertical?1:-1,h=P.charSpacing,C=P.wordSpacing,A=P.textHScale*$,k=P.fontMatrix||_.FONT_IDENTITY_MATRIX,B=d.length,D=P.textRenderingMode===_.TextRenderingMode.INVISIBLE;let g,L,At,H;if(!(D||U===0)){for(this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null,u.save(),u.transform(...P.textMatrix),u.translate(P.x,P.y),u.scale(A,$),g=0;g<B;++g){if(L=d[g],typeof L=="number"){H=s*L*U/1e3,this.ctx.translate(H,0),P.x+=H*A;continue}const Q=(L.isSpace?C:0)+h,Ct=j.charProcOperatorList[L.operatorListId];if(!Ct){(0,_.warn)(`Type3 character "${L.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=L,this.save(),u.scale(U,U),u.transform(...k),this.executeOperatorList(Ct),this.restore()),At=_.Util.applyTransform([L.width,0],k)[0]*U+Q,u.translate(At,0),P.x+=At*A}u.restore(),this.processingType3=null}}setCharWidth(d,u){}setCharWidthAndBounds(d,u,P,j,U,$){this.ctx.rect(P,j,U-P,$-j),this.ctx.clip(),this.endPath()}getColorN_Pattern(d){let u;if(d[0]==="TilingPattern"){const P=d[1],j=this.baseTransform||(0,f.getCurrentTransform)(this.ctx),U={createCanvasGraphics:$=>new Ot($,this.commonObjs,this.objs,this.canvasFactory)};u=new Y.TilingPattern(d,P,this.ctx,U,j)}else u=this._getPattern(d[1],d[2]);return u}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(d,u,P){var U;const j=((U=this.selectColor)==null?void 0:U.call(this,d,u,P))||_.Util.makeHexColor(d,u,P);this.ctx.strokeStyle=j,this.current.strokeColor=j}setFillRGBColor(d,u,P){var U;const j=((U=this.selectColor)==null?void 0:U.call(this,d,u,P))||_.Util.makeHexColor(d,u,P);this.ctx.fillStyle=j,this.current.fillColor=j,this.current.patternFill=!1}_getPattern(d,u=null){let P;return this.cachedPatterns.has(d)?P=this.cachedPatterns.get(d):(P=(0,Y.getShadingPattern)(this.objs.get(d)),this.cachedPatterns.set(d,P)),u&&(P.matrix=u),P}shadingFill(d){if(!this.contentVisible)return;const u=this.ctx;this.save();const P=this._getPattern(d);u.fillStyle=P.getPattern(u,this,(0,f.getCurrentTransformInverse)(u),Y.PathType.SHADING);const j=(0,f.getCurrentTransformInverse)(u);if(j){const U=u.canvas,$=U.width,s=U.height,h=_.Util.applyTransform([0,0],j),C=_.Util.applyTransform([0,s],j),A=_.Util.applyTransform([$,0],j),k=_.Util.applyTransform([$,s],j),B=Math.min(h[0],C[0],A[0],k[0]),D=Math.min(h[1],C[1],A[1],k[1]),g=Math.max(h[0],C[0],A[0],k[0]),L=Math.max(h[1],C[1],A[1],k[1]);this.ctx.fillRect(B,D,g-B,L-D)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,_.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,_.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(d,u){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(d)&&d.length===6&&this.transform(...d),this.baseTransform=(0,f.getCurrentTransform)(this.ctx),u)){const P=u[2]-u[0],j=u[3]-u[1];this.ctx.rect(u[0],u[1],P,j),this.current.updateRectMinMax((0,f.getCurrentTransform)(this.ctx),u),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(d){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const u=this.ctx;d.isolated||(0,_.info)("TODO: Support non-isolated groups."),d.knockout&&(0,_.warn)("Knockout groups not supported.");const P=(0,f.getCurrentTransform)(u);if(d.matrix&&u.transform(...d.matrix),!d.bbox)throw new Error("Bounding box is required.");let j=_.Util.getAxialAlignedBoundingBox(d.bbox,(0,f.getCurrentTransform)(u));const U=[0,0,u.canvas.width,u.canvas.height];j=_.Util.intersect(j,U)||[0,0,0,0];const $=Math.floor(j[0]),s=Math.floor(j[1]);let h=Math.max(Math.ceil(j[2])-$,1),C=Math.max(Math.ceil(j[3])-s,1),A=1,k=1;h>w&&(A=h/w,h=w),C>w&&(k=C/w,C=w),this.current.startNewPathAndClipBox([0,0,h,C]);let B="groupAt"+this.groupLevel;d.smask&&(B+="_smask_"+this.smaskCounter++%2);const D=this.cachedCanvases.getCanvas(B,h,C),g=D.context;g.scale(1/A,1/k),g.translate(-$,-s),g.transform(...P),d.smask?this.smaskStack.push({canvas:D.canvas,context:g,offsetX:$,offsetY:s,scaleX:A,scaleY:k,subtype:d.smask.subtype,backdrop:d.smask.backdrop,transferMap:d.smask.transferMap||null,startTransformInverse:null}):(u.setTransform(1,0,0,1,0,0),u.translate($,s),u.scale(A,k),u.save()),i(u,g),this.ctx=g,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(u),this.groupLevel++}endGroup(d){if(!this.contentVisible)return;this.groupLevel--;const u=this.ctx,P=this.groupStack.pop();if(this.ctx=P,this.ctx.imageSmoothingEnabled=!1,d.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const j=(0,f.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...j);const U=_.Util.getAxialAlignedBoundingBox([0,0,u.canvas.width,u.canvas.height],j);this.ctx.drawImage(u.canvas,0,0),this.ctx.restore(),this.compose(U)}}beginAnnotation(d,u,P,j,U){if(Mt(this,_t,fn).call(this),e(this.ctx,this.foregroundColor),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(u)&&u.length===4){const $=u[2]-u[0],s=u[3]-u[1];if(U&&this.annotationCanvasMap){P=P.slice(),P[4]-=u[0],P[5]-=u[1],u=u.slice(),u[0]=u[1]=0,u[2]=$,u[3]=s;const[h,C]=_.Util.singularValueDecompose2dScale((0,f.getCurrentTransform)(this.ctx)),{viewportScale:A}=this,k=Math.ceil($*this.outputScaleX*A),B=Math.ceil(s*this.outputScaleY*A);this.annotationCanvas=this.canvasFactory.create(k,B);const{canvas:D,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(d,D),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.setTransform(h,0,0,-C,0,s*C),e(this.ctx,this.foregroundColor)}else e(this.ctx,this.foregroundColor),this.ctx.rect(u[0],u[1],$,s),this.ctx.clip(),this.endPath()}this.current=new m(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...P),this.transform(...j)}endAnnotation(){this.annotationCanvas&&(this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(d){if(!this.contentVisible)return;const u=d.count;d=this.getObject(d.data,d),d.count=u;const P=this.ctx,j=this.processingType3;if(j&&(j.compiled===void 0&&(j.compiled=F(d)),j.compiled)){j.compiled(P);return}const U=this._createMaskCanvas(d),$=U.canvas;P.save(),P.setTransform(1,0,0,1,0,0),P.drawImage($,U.offsetX,U.offsetY),P.restore(),this.compose()}paintImageMaskXObjectRepeat(d,u,P=0,j=0,U,$){if(!this.contentVisible)return;d=this.getObject(d.data,d);const s=this.ctx;s.save();const h=(0,f.getCurrentTransform)(s);s.transform(u,P,j,U,0,0);const C=this._createMaskCanvas(d);s.setTransform(1,0,0,1,0,0);for(let A=0,k=$.length;A<k;A+=2){const B=_.Util.transform(h,[u,P,j,U,$[A],$[A+1]]),[D,g]=_.Util.applyTransform([0,0],B);s.drawImage(C.canvas,D,g)}s.restore(),this.compose()}paintImageMaskXObjectGroup(d){if(!this.contentVisible)return;const u=this.ctx,P=this.current.fillColor,j=this.current.patternFill;for(const U of d){const{data:$,width:s,height:h,transform:C}=U,A=this.cachedCanvases.getCanvas("maskCanvas",s,h),k=A.context;k.save();const B=this.getObject($,U);n(k,B),k.globalCompositeOperation="source-in",k.fillStyle=j?P.getPattern(k,this,(0,f.getCurrentTransformInverse)(u),Y.PathType.FILL):P,k.fillRect(0,0,s,h),k.restore(),u.save(),u.transform(...C),u.scale(1,-1),o(u,A.canvas,0,0,s,h,0,-1,1,1),u.restore()}this.compose()}paintImageXObject(d){if(!this.contentVisible)return;const u=this.getObject(d);if(!u){(0,_.warn)("Dependent image isn't ready yet");return}this.paintInlineImageXObject(u)}paintImageXObjectRepeat(d,u,P,j){if(!this.contentVisible)return;const U=this.getObject(d);if(!U){(0,_.warn)("Dependent image isn't ready yet");return}const $=U.width,s=U.height,h=[];for(let C=0,A=j.length;C<A;C+=2)h.push({transform:[u,0,0,P,j[C],j[C+1]],x:0,y:0,w:$,h:s});this.paintInlineImageXObjectGroup(U,h)}paintInlineImageXObject(d){if(!this.contentVisible)return;const u=d.width,P=d.height,j=this.ctx;this.save(),j.scale(1/u,-1/P);let U;if(typeof HTMLElement=="function"&&d instanceof HTMLElement||!d.data)U=d;else{const C=this.cachedCanvases.getCanvas("inlineImage",u,P),A=C.context;l(A,d,this.current.transferMaps),U=C.canvas}const $=this._scaleImage(U,(0,f.getCurrentTransformInverse)(j));j.imageSmoothingEnabled=Pt((0,f.getCurrentTransform)(j),d.interpolate);const[s,h]=o(j,$.img,0,0,$.paintWidth,$.paintHeight,0,-P,u,P);if(this.imageLayer){const[C,A]=_.Util.applyTransform([0,-P],(0,f.getCurrentTransform)(this.ctx));this.imageLayer.appendImage({imgData:d,left:C,top:A,width:s,height:h})}this.compose(),this.restore()}paintInlineImageXObjectGroup(d,u){if(!this.contentVisible)return;const P=this.ctx,j=d.width,U=d.height,$=this.cachedCanvases.getCanvas("inlineImage",j,U),s=$.context;l(s,d,this.current.transferMaps);for(const h of u){if(P.save(),P.transform(...h.transform),P.scale(1,-1),o(P,$.canvas,h.x,h.y,h.w,h.h,0,-1,1,1),this.imageLayer){const[C,A]=_.Util.applyTransform([h.x,h.y],(0,f.getCurrentTransform)(this.ctx));this.imageLayer.appendImage({imgData:d,left:C,top:A,width:j,height:U})}P.restore()}this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(d){}markPointProps(d,u){}beginMarkedContent(d){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(d,u){d==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(u)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(d){const u=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(d);const P=this.ctx;this.pendingClip&&(u||(this.pendingClip===z?P.clip("evenodd"):P.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),P.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const d=(0,f.getCurrentTransform)(this.ctx);if(d[1]===0&&d[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(d[0]),Math.abs(d[3]));else{const u=Math.abs(d[0]*d[3]-d[2]*d[1]),P=Math.hypot(d[0],d[2]),j=Math.hypot(d[1],d[3]);this._cachedGetSinglePixelWidth=Math.max(P,j)/u}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(!this._cachedScaleForStroking){const{lineWidth:d}=this.current,u=(0,f.getCurrentTransform)(this.ctx);let P,j;if(u[1]===0&&u[2]===0){const U=Math.abs(u[0]),$=Math.abs(u[3]);if(d===0)P=1/U,j=1/$;else{const s=U*d,h=$*d;P=s<1?1/s:1,j=h<1?1/h:1}}else{const U=Math.abs(u[0]*u[3]-u[2]*u[1]),$=Math.hypot(u[0],u[1]),s=Math.hypot(u[2],u[3]);if(d===0)P=s/U,j=$/U;else{const h=d*U;P=s>h?s/h:1,j=$>h?$/h:1}}this._cachedScaleForStroking=[P,j]}return this._cachedScaleForStroking}rescaleAndStroke(d){const{ctx:u}=this,{lineWidth:P}=this.current,[j,U]=this.getScaleForStroking();if(u.lineWidth=P||1,j===1&&U===1){u.stroke();return}let $,s,h;d&&($=(0,f.getCurrentTransform)(u),s=u.getLineDash().slice(),h=u.lineDashOffset),u.scale(j,U);const C=Math.max(j,U);u.setLineDash(u.getLineDash().map(A=>A/C)),u.lineDashOffset/=C,u.stroke(),d&&(u.setTransform(...$),u.setLineDash(s),u.lineDashOffset=h)}isContentVisible(){for(let d=this.markedContentStack.length-1;d>=0;d--)if(!this.markedContentStack[d].visible)return!1;return!0}};_t=new WeakSet,fn=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)};let G=Ot;a.CanvasGraphics=G;for(const q in _.OPS)G.prototype[q]!==void 0&&(G.prototype[_.OPS[q]]=G.prototype[q])}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.TilingPattern=a.PathType=void 0,a.getShadingPattern=c;var f=y(1),_=y(8),Y=y(3);const W={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};a.PathType=W;function K(o,F){if(!F||Y.isNodeJS)return;const m=F[2]-F[0],l=F[3]-F[1],n=new Path2D;n.rect(F[0],F[1],m,l),o.clip(n)}class M{constructor(){this.constructor===M&&(0,f.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,f.unreachable)("Abstract method `getPattern` called.")}}class b extends M{constructor(F){super(),this._type=F[1],this._bbox=F[2],this._colorStops=F[3],this._p0=F[4],this._p1=F[5],this._r0=F[6],this._r1=F[7],this.matrix=null}_createGradient(F){let m;this._type==="axial"?m=F.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(m=F.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const l of this._colorStops)m.addColorStop(l[0],l[1]);return m}getPattern(F,m,l,n){let i;if(n===W.STROKE||n===W.FILL){const e=m.current.getClippedPathBoundingBox(n,(0,_.getCurrentTransform)(F))||[0,0,0,0],E=Math.ceil(e[2]-e[0])||1,x=Math.ceil(e[3]-e[1])||1,N=m.cachedCanvases.getCanvas("pattern",E,x,!0),I=N.context;I.clearRect(0,0,I.canvas.width,I.canvas.height),I.beginPath(),I.rect(0,0,I.canvas.width,I.canvas.height),I.translate(-e[0],-e[1]),l=f.Util.transform(l,[1,0,0,1,e[0],e[1]]),I.transform(...m.baseTransform),this.matrix&&I.transform(...this.matrix),K(I,this._bbox),I.fillStyle=this._createGradient(I),I.fill(),i=F.createPattern(N.canvas,"no-repeat");const St=new DOMMatrix(l);try{i.setTransform(St)}catch(Pt){(0,f.warn)(`RadialAxialShadingPattern.getPattern: "${Pt==null?void 0:Pt.message}".`)}}else K(F,this._bbox),i=this._createGradient(F);return i}}function w(o,F,m,l,n,i,e,E){const x=F.coords,N=F.colors,I=o.data,St=o.width*4;let Pt;x[m+1]>x[l+1]&&(Pt=m,m=l,l=Pt,Pt=i,i=e,e=Pt),x[l+1]>x[n+1]&&(Pt=l,l=n,n=Pt,Pt=e,e=E,E=Pt),x[m+1]>x[l+1]&&(Pt=m,m=l,l=Pt,Pt=i,i=e,e=Pt);const bt=(x[m]+F.offsetX)*F.scaleX,V=(x[m+1]+F.offsetY)*F.scaleY,O=(x[l]+F.offsetX)*F.scaleX,z=(x[l+1]+F.offsetY)*F.scaleY,G=(x[n]+F.offsetX)*F.scaleX,_t=(x[n+1]+F.offsetY)*F.scaleY;if(V>=_t)return;const wt=N[i],Ot=N[i+1],q=N[i+2],d=N[e],u=N[e+1],P=N[e+2],j=N[E],U=N[E+1],$=N[E+2],s=Math.round(V),h=Math.round(_t);let C,A,k,B,D,g,L,At;for(let H=s;H<=h;H++){if(H<z){let kt;H<V?kt=0:kt=(V-H)/(V-z),C=bt-(bt-O)*kt,A=wt-(wt-d)*kt,k=Ot-(Ot-u)*kt,B=q-(q-P)*kt}else{let kt;H>_t?kt=1:z===_t?kt=0:kt=(z-H)/(z-_t),C=O-(O-G)*kt,A=d-(d-j)*kt,k=u-(u-U)*kt,B=P-(P-$)*kt}let Q;H<V?Q=0:H>_t?Q=1:Q=(V-H)/(V-_t),D=bt-(bt-G)*Q,g=wt-(wt-j)*Q,L=Ot-(Ot-U)*Q,At=q-(q-$)*Q;const Ct=Math.round(Math.min(C,D)),Tt=Math.round(Math.max(C,D));let It=St*H+Ct*4;for(let kt=Ct;kt<=Tt;kt++)Q=(C-kt)/(C-D),Q<0?Q=0:Q>1&&(Q=1),I[It++]=A-(A-g)*Q|0,I[It++]=k-(k-L)*Q|0,I[It++]=B-(B-At)*Q|0,I[It++]=255}}function T(o,F,m){const l=F.coords,n=F.colors;let i,e;switch(F.type){case"lattice":const E=F.verticesPerRow,x=Math.floor(l.length/E)-1,N=E-1;for(i=0;i<x;i++){let I=i*E;for(let St=0;St<N;St++,I++)w(o,m,l[I],l[I+1],l[I+E],n[I],n[I+1],n[I+E]),w(o,m,l[I+E+1],l[I+1],l[I+E],n[I+E+1],n[I+1],n[I+E])}break;case"triangles":for(i=0,e=l.length;i<e;i+=3)w(o,m,l[i],l[i+1],l[i+2],n[i],n[i+1],n[i+2]);break;default:throw new Error("illegal figure")}}class S extends M{constructor(F){super(),this._coords=F[2],this._colors=F[3],this._figures=F[4],this._bounds=F[5],this._bbox=F[7],this._background=F[8],this.matrix=null}_createMeshCanvas(F,m,l){const E=Math.floor(this._bounds[0]),x=Math.floor(this._bounds[1]),N=Math.ceil(this._bounds[2])-E,I=Math.ceil(this._bounds[3])-x,St=Math.min(Math.ceil(Math.abs(N*F[0]*1.1)),3e3),Pt=Math.min(Math.ceil(Math.abs(I*F[1]*1.1)),3e3),bt=N/St,V=I/Pt,O={coords:this._coords,colors:this._colors,offsetX:-E,offsetY:-x,scaleX:1/bt,scaleY:1/V},z=St+4,G=Pt+4,_t=l.getCanvas("mesh",z,G,!1),wt=_t.context,Ot=wt.createImageData(St,Pt);if(m){const d=Ot.data;for(let u=0,P=d.length;u<P;u+=4)d[u]=m[0],d[u+1]=m[1],d[u+2]=m[2],d[u+3]=255}for(const d of this._figures)T(Ot,d,O);return wt.putImageData(Ot,2,2),{canvas:_t.canvas,offsetX:E-2*bt,offsetY:x-2*V,scaleX:bt,scaleY:V}}getPattern(F,m,l,n){K(F,this._bbox);let i;if(n===W.SHADING)i=f.Util.singularValueDecompose2dScale((0,_.getCurrentTransform)(F));else if(i=f.Util.singularValueDecompose2dScale(m.baseTransform),this.matrix){const E=f.Util.singularValueDecompose2dScale(this.matrix);i=[i[0]*E[0],i[1]*E[1]]}const e=this._createMeshCanvas(i,n===W.SHADING?null:this._background,m.cachedCanvases);return n!==W.SHADING&&(F.setTransform(...m.baseTransform),this.matrix&&F.transform(...this.matrix)),F.translate(e.offsetX,e.offsetY),F.scale(e.scaleX,e.scaleY),F.createPattern(e.canvas,"no-repeat")}}class v extends M{getPattern(){return"hotpink"}}function c(o){switch(o[0]){case"RadialAxial":return new b(o);case"Mesh":return new S(o);case"Dummy":return new v}throw new Error(`Unknown IR type: ${o[0]}`)}const t={COLORED:1,UNCOLORED:2};class r{static get MAX_PATTERN_SIZE(){return(0,f.shadow)(this,"MAX_PATTERN_SIZE",3e3)}constructor(F,m,l,n,i){this.operatorList=F[2],this.matrix=F[3]||[1,0,0,1,0,0],this.bbox=F[4],this.xstep=F[5],this.ystep=F[6],this.paintType=F[7],this.tilingType=F[8],this.color=m,this.ctx=l,this.canvasGraphicsFactory=n,this.baseTransform=i}createPatternCanvas(F){const m=this.operatorList,l=this.bbox,n=this.xstep,i=this.ystep,e=this.paintType,E=this.tilingType,x=this.color,N=this.canvasGraphicsFactory;(0,f.info)("TilingType: "+E);const I=l[0],St=l[1],Pt=l[2],bt=l[3],V=f.Util.singularValueDecompose2dScale(this.matrix),O=f.Util.singularValueDecompose2dScale(this.baseTransform),z=[V[0]*O[0],V[1]*O[1]],G=this.getSizeAndScale(n,this.ctx.canvas.width,z[0]),_t=this.getSizeAndScale(i,this.ctx.canvas.height,z[1]),wt=F.cachedCanvases.getCanvas("pattern",G.size,_t.size,!0),Ot=wt.context,q=N.createCanvasGraphics(Ot);q.groupLevel=F.groupLevel,this.setFillAndStrokeStyleToContext(q,e,x);let d=I,u=St,P=Pt,j=bt;return I<0&&(d=0,P+=Math.abs(I)),St<0&&(u=0,j+=Math.abs(St)),Ot.translate(-(G.scale*d),-(_t.scale*u)),q.transform(G.scale,0,0,_t.scale,0,0),Ot.save(),this.clipBbox(q,d,u,P,j),q.baseTransform=(0,_.getCurrentTransform)(q.ctx),q.executeOperatorList(m),q.endDrawing(),{canvas:wt.canvas,scaleX:G.scale,scaleY:_t.scale,offsetX:d,offsetY:u}}getSizeAndScale(F,m,l){F=Math.abs(F);const n=Math.max(r.MAX_PATTERN_SIZE,m);let i=Math.ceil(F*l);return i>=n?i=n:l=i/F,{scale:l,size:i}}clipBbox(F,m,l,n,i){const e=n-m,E=i-l;F.ctx.rect(m,l,e,E),F.current.updateRectMinMax((0,_.getCurrentTransform)(F.ctx),[m,l,n,i]),F.clip(),F.endPath()}setFillAndStrokeStyleToContext(F,m,l){const n=F.ctx,i=F.current;switch(m){case t.COLORED:const e=this.ctx;n.fillStyle=e.fillStyle,n.strokeStyle=e.strokeStyle,i.fillColor=e.fillStyle,i.strokeColor=e.strokeStyle;break;case t.UNCOLORED:const E=f.Util.makeHexColor(l[0],l[1],l[2]);n.fillStyle=E,n.strokeStyle=E,i.fillColor=E,i.strokeColor=E;break;default:throw new f.FormatError(`Unsupported paint type: ${m}`)}}getPattern(F,m,l,n){let i=l;n!==W.SHADING&&(i=f.Util.transform(i,m.baseTransform),this.matrix&&(i=f.Util.transform(i,this.matrix)));const e=this.createPatternCanvas(m);let E=new DOMMatrix(i);E=E.translate(e.offsetX,e.offsetY),E=E.scale(1/e.scaleX,1/e.scaleY);const x=F.createPattern(e.canvas,"repeat");try{x.setTransform(E)}catch(N){(0,f.warn)(`TilingPattern.getPattern: "${N==null?void 0:N.message}".`)}return x}}a.TilingPattern=r}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.applyMaskImageData=_;var f=y(1);function _({src:Y,srcPos:W=0,dest:K,destPos:M=0,width:b,height:w,inverseDecode:T=!1}){const S=f.FeatureTest.isLittleEndian?4278190080:255,[v,c]=T?[0,S]:[S,0],t=b>>3,r=b&7,o=Y.length;K=new Uint32Array(K.buffer);for(let F=0;F<w;F++){for(const l=W+t;W<l;W++){const n=W<o?Y[W]:255;K[M++]=n&128?c:v,K[M++]=n&64?c:v,K[M++]=n&32?c:v,K[M++]=n&16?c:v,K[M++]=n&8?c:v,K[M++]=n&4?c:v,K[M++]=n&2?c:v,K[M++]=n&1?c:v}if(r===0)continue;const m=W<o?Y[W++]:255;for(let l=0;l<r;l++)K[M++]=m&1<<7-l?c:v}return{srcPos:W,destPos:M}}}),((p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.GlobalWorkerOptions=void 0;const y=Object.create(null);a.GlobalWorkerOptions=y,y.workerPort=y.workerPort===void 0?null:y.workerPort,y.workerSrc=y.workerSrc===void 0?"":y.workerSrc}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.MessageHandler=void 0;var f=y(1);const _={DATA:1,ERROR:2},Y={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function W(M){switch(M instanceof Error||typeof M=="object"&&M!==null||(0,f.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),M.name){case"AbortException":return new f.AbortException(M.message);case"MissingPDFException":return new f.MissingPDFException(M.message);case"PasswordException":return new f.PasswordException(M.message,M.code);case"UnexpectedResponseException":return new f.UnexpectedResponseException(M.message,M.status);case"UnknownErrorException":return new f.UnknownErrorException(M.message,M.details);default:return new f.UnknownErrorException(M.message,M.toString())}}class K{constructor(b,w,T){this.sourceName=b,this.targetName=w,this.comObj=T,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=S=>{const v=S.data;if(v.targetName!==this.sourceName)return;if(v.stream){this._processStreamMessage(v);return}if(v.callback){const t=v.callbackId,r=this.callbackCapabilities[t];if(!r)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],v.callback===_.DATA)r.resolve(v.data);else if(v.callback===_.ERROR)r.reject(W(v.reason));else throw new Error("Unexpected callback case");return}const c=this.actionHandler[v.action];if(!c)throw new Error(`Unknown action from worker: ${v.action}`);if(v.callbackId){const t=this.sourceName,r=v.sourceName;new Promise(function(o){o(c(v.data))}).then(function(o){T.postMessage({sourceName:t,targetName:r,callback:_.DATA,callbackId:v.callbackId,data:o})},function(o){T.postMessage({sourceName:t,targetName:r,callback:_.ERROR,callbackId:v.callbackId,reason:W(o)})});return}if(v.streamId){this._createStreamSink(v);return}c(v.data)},T.addEventListener("message",this._onComObjOnMessage)}on(b,w){const T=this.actionHandler;if(T[b])throw new Error(`There is already an actionName called "${b}"`);T[b]=w}send(b,w,T){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:b,data:w},T)}sendWithPromise(b,w,T){const S=this.callbackId++,v=(0,f.createPromiseCapability)();this.callbackCapabilities[S]=v;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:b,callbackId:S,data:w},T)}catch(c){v.reject(c)}return v.promise}sendWithStream(b,w,T,S){const v=this.streamId++,c=this.sourceName,t=this.targetName,r=this.comObj;return new ReadableStream({start:o=>{const F=(0,f.createPromiseCapability)();return this.streamControllers[v]={controller:o,startCall:F,pullCall:null,cancelCall:null,isClosed:!1},r.postMessage({sourceName:c,targetName:t,action:b,streamId:v,data:w,desiredSize:o.desiredSize},S),F.promise},pull:o=>{const F=(0,f.createPromiseCapability)();return this.streamControllers[v].pullCall=F,r.postMessage({sourceName:c,targetName:t,stream:Y.PULL,streamId:v,desiredSize:o.desiredSize}),F.promise},cancel:o=>{(0,f.assert)(o instanceof Error,"cancel must have a valid reason");const F=(0,f.createPromiseCapability)();return this.streamControllers[v].cancelCall=F,this.streamControllers[v].isClosed=!0,r.postMessage({sourceName:c,targetName:t,stream:Y.CANCEL,streamId:v,reason:W(o)}),F.promise}},T)}_createStreamSink(b){const w=b.streamId,T=this.sourceName,S=b.sourceName,v=this.comObj,c=this,t=this.actionHandler[b.action],r={enqueue(o,F=1,m){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=F,l>0&&this.desiredSize<=0&&(this.sinkCapability=(0,f.createPromiseCapability)(),this.ready=this.sinkCapability.promise),v.postMessage({sourceName:T,targetName:S,stream:Y.ENQUEUE,streamId:w,chunk:o},m)},close(){this.isCancelled||(this.isCancelled=!0,v.postMessage({sourceName:T,targetName:S,stream:Y.CLOSE,streamId:w}),delete c.streamSinks[w])},error(o){(0,f.assert)(o instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,v.postMessage({sourceName:T,targetName:S,stream:Y.ERROR,streamId:w,reason:W(o)}))},sinkCapability:(0,f.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:b.desiredSize,ready:null};r.sinkCapability.resolve(),r.ready=r.sinkCapability.promise,this.streamSinks[w]=r,new Promise(function(o){o(t(b.data,r))}).then(function(){v.postMessage({sourceName:T,targetName:S,stream:Y.START_COMPLETE,streamId:w,success:!0})},function(o){v.postMessage({sourceName:T,targetName:S,stream:Y.START_COMPLETE,streamId:w,reason:W(o)})})}_processStreamMessage(b){const w=b.streamId,T=this.sourceName,S=b.sourceName,v=this.comObj,c=this.streamControllers[w],t=this.streamSinks[w];switch(b.stream){case Y.START_COMPLETE:b.success?c.startCall.resolve():c.startCall.reject(W(b.reason));break;case Y.PULL_COMPLETE:b.success?c.pullCall.resolve():c.pullCall.reject(W(b.reason));break;case Y.PULL:if(!t){v.postMessage({sourceName:T,targetName:S,stream:Y.PULL_COMPLETE,streamId:w,success:!0});break}t.desiredSize<=0&&b.desiredSize>0&&t.sinkCapability.resolve(),t.desiredSize=b.desiredSize,new Promise(function(r){r(t.onPull&&t.onPull())}).then(function(){v.postMessage({sourceName:T,targetName:S,stream:Y.PULL_COMPLETE,streamId:w,success:!0})},function(r){v.postMessage({sourceName:T,targetName:S,stream:Y.PULL_COMPLETE,streamId:w,reason:W(r)})});break;case Y.ENQUEUE:if((0,f.assert)(c,"enqueue should have stream controller"),c.isClosed)break;c.controller.enqueue(b.chunk);break;case Y.CLOSE:if((0,f.assert)(c,"close should have stream controller"),c.isClosed)break;c.isClosed=!0,c.controller.close(),this._deleteStreamController(c,w);break;case Y.ERROR:(0,f.assert)(c,"error should have stream controller"),c.controller.error(W(b.reason)),this._deleteStreamController(c,w);break;case Y.CANCEL_COMPLETE:b.success?c.cancelCall.resolve():c.cancelCall.reject(W(b.reason)),this._deleteStreamController(c,w);break;case Y.CANCEL:if(!t)break;new Promise(function(r){r(t.onCancel&&t.onCancel(W(b.reason)))}).then(function(){v.postMessage({sourceName:T,targetName:S,stream:Y.CANCEL_COMPLETE,streamId:w,success:!0})},function(r){v.postMessage({sourceName:T,targetName:S,stream:Y.CANCEL_COMPLETE,streamId:w,reason:W(r)})}),t.sinkCapability.reject(W(b.reason)),t.isCancelled=!0,delete this.streamSinks[w];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(b,w){await Promise.allSettled([b.startCall&&b.startCall.promise,b.pullCall&&b.pullCall.promise,b.cancelCall&&b.cancelCall.promise]),delete this.streamControllers[w]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}a.MessageHandler=K}),((p,a,y)=>{var Y,W;Object.defineProperty(a,"__esModule",{value:!0}),a.Metadata=void 0;var f=y(1);class _{constructor({parsedData:M,rawData:b}){Lt(this,Y);Lt(this,W);Bt(this,Y,M),Bt(this,W,b)}getRaw(){return R(this,W)}get(M){return R(this,Y).get(M)??null}getAll(){return(0,f.objectFromMap)(R(this,Y))}has(M){return R(this,Y).has(M)}}Y=new WeakMap,W=new WeakMap,a.Metadata=_}),((p,a,y)=>{var K,M,b,w,T,S,pn;Object.defineProperty(a,"__esModule",{value:!0}),a.OptionalContentConfig=void 0;var f=y(1);const _=Symbol("INTERNAL");class Y{constructor(t,r){Lt(this,K,!0);this.name=t,this.intent=r}get visible(){return R(this,K)}_setVisible(t,r){t!==_&&(0,f.unreachable)("Internal method `_setVisible` called."),Bt(this,K,r)}}K=new WeakMap;class W{constructor(t){Lt(this,S);Lt(this,M,!0);Lt(this,b,new Map);Lt(this,w,null);Lt(this,T,null);if(this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,Bt(this,T,t.order);for(const r of t.groups)R(this,b).set(r.id,new Y(r.name,r.intent));if(t.baseState==="OFF")for(const r of R(this,b).values())r._setVisible(_,!1);for(const r of t.on)R(this,b).get(r)._setVisible(_,!0);for(const r of t.off)R(this,b).get(r)._setVisible(_,!1);Bt(this,w,new Map);for(const[r,o]of R(this,b))R(this,w).set(r,o.visible)}}isVisible(t){if(R(this,b).size===0)return!0;if(!t)return(0,f.warn)("Optional content group not defined."),!0;if(t.type==="OCG")return R(this,b).has(t.id)?R(this,b).get(t.id).visible:((0,f.warn)(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return Mt(this,S,pn).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const r of t.ids){if(!R(this,b).has(r))return(0,f.warn)(`Optional content group not found: ${r}`),!0;if(R(this,b).get(r).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const r of t.ids){if(!R(this,b).has(r))return(0,f.warn)(`Optional content group not found: ${r}`),!0;if(!R(this,b).get(r).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const r of t.ids){if(!R(this,b).has(r))return(0,f.warn)(`Optional content group not found: ${r}`),!0;if(!R(this,b).get(r).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const r of t.ids){if(!R(this,b).has(r))return(0,f.warn)(`Optional content group not found: ${r}`),!0;if(R(this,b).get(r).visible)return!1}return!0}return(0,f.warn)(`Unknown optional content policy ${t.policy}.`),!0}return(0,f.warn)(`Unknown group type ${t.type}.`),!0}setVisibility(t,r=!0){if(!R(this,b).has(t)){(0,f.warn)(`Optional content group not found: ${t}`);return}R(this,b).get(t)._setVisible(_,!!r),Bt(this,M,null)}get hasInitialVisibility(){if(R(this,M)!==null)return R(this,M);for(const[t,r]of R(this,b)){const o=R(this,w).get(t);if(r.visible!==o)return Bt(this,M,!1)}return Bt(this,M,!0)}getOrder(){return R(this,b).size?R(this,T)?R(this,T).slice():[...R(this,b).keys()]:null}getGroups(){return R(this,b).size>0?(0,f.objectFromMap)(R(this,b)):null}getGroup(t){return R(this,b).get(t)||null}}M=new WeakMap,b=new WeakMap,w=new WeakMap,T=new WeakMap,S=new WeakSet,pn=function(t){const r=t.length;if(r<2)return!0;const o=t[0];for(let F=1;F<r;F++){const m=t[F];let l;if(Array.isArray(m))l=Mt(this,S,pn).call(this,m);else if(R(this,b).has(m))l=R(this,b).get(m).visible;else return(0,f.warn)(`Optional content group not found: ${m}`),!0;switch(o){case"And":if(!l)return!1;break;case"Or":if(l)return!0;break;case"Not":return!l;default:return!0}}return o==="And"},a.OptionalContentConfig=W}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.PDFDataTransportStream=void 0;var f=y(1),_=y(8);class Y{constructor(b,w){(0,f.assert)(w,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=b.progressiveDone||!1,this._contentDispositionFilename=b.contentDispositionFilename||null;const T=b.initialData;if((T==null?void 0:T.length)>0){const S=new Uint8Array(T).buffer;this._queuedChunks.push(S)}this._pdfDataRangeTransport=w,this._isStreamingSupported=!b.disableStream,this._isRangeSupported=!b.disableRange,this._contentLength=b.length,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((S,v)=>{this._onReceiveData({begin:S,chunk:v})}),this._pdfDataRangeTransport.addProgressListener((S,v)=>{this._onProgress({loaded:S,total:v})}),this._pdfDataRangeTransport.addProgressiveReadListener(S=>{this._onReceiveData({chunk:S})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData(b){const w=new Uint8Array(b.chunk).buffer;if(b.begin===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(w):this._queuedChunks.push(w);else{const T=this._rangeReaders.some(function(S){return S._begin!==b.begin?!1:(S._enqueue(w),!0)});(0,f.assert)(T,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var b;return((b=this._fullRequestReader)==null?void 0:b._loaded)??0}_onProgress(b){if(b.total===void 0){const w=this._rangeReaders[0];w!=null&&w.onProgress&&w.onProgress({loaded:b.loaded})}else{const w=this._fullRequestReader;w!=null&&w.onProgress&&w.onProgress({loaded:b.loaded,total:b.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(b){const w=this._rangeReaders.indexOf(b);w>=0&&this._rangeReaders.splice(w,1)}getFullReader(){(0,f.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const b=this._queuedChunks;return this._queuedChunks=null,new W(this,b,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(b,w){if(w<=this._progressiveDataLength)return null;const T=new K(this,b,w);return this._pdfDataRangeTransport.requestDataRange(b,w),this._rangeReaders.push(T),T}cancelAllRequests(b){this._fullRequestReader&&this._fullRequestReader.cancel(b);for(const w of this._rangeReaders.slice(0))w.cancel(b);this._pdfDataRangeTransport.abort()}}a.PDFDataTransportStream=Y;class W{constructor(b,w,T=!1,S=null){this._stream=b,this._done=T||!1,this._filename=(0,_.isPdfFile)(S)?S:null,this._queuedChunks=w||[],this._loaded=0;for(const v of this._queuedChunks)this._loaded+=v.byteLength;this._requests=[],this._headersReady=Promise.resolve(),b._fullRequestReader=this,this.onProgress=null}_enqueue(b){this._done||(this._requests.length>0?this._requests.shift().resolve({value:b,done:!1}):this._queuedChunks.push(b),this._loaded+=b.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const b=(0,f.createPromiseCapability)();return this._requests.push(b),b.promise}cancel(b){this._done=!0;for(const w of this._requests)w.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class K{constructor(b,w,T){this._stream=b,this._begin=w,this._end=T,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(b){if(!this._done){if(this._requests.length===0)this._queuedChunk=b;else{this._requests.shift().resolve({value:b,done:!1});for(const T of this._requests)T.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const w=this._queuedChunk;return this._queuedChunk=null,{value:w,done:!1}}if(this._done)return{value:void 0,done:!0};const b=(0,f.createPromiseCapability)();return this._requests.push(b),b.promise}cancel(b){this._done=!0;for(const w of this._requests)w.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}}),((p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.XfaText=void 0;class y{static textContent(_){const Y=[],W={items:Y,styles:Object.create(null)};function K(M){var T;if(!M)return;let b=null;const w=M.name;if(w==="#text")b=M.value;else if(y.shouldBuildText(w))(T=M==null?void 0:M.attributes)!=null&&T.textContent?b=M.attributes.textContent:M.value&&(b=M.value);else return;if(b!==null&&Y.push({str:b}),!!M.children)for(const S of M.children)K(S)}return K(_),W}static shouldBuildText(_){return!(_==="textarea"||_==="input"||_==="option"||_==="select")}}a.XfaText=y}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.NodeStandardFontDataFactory=a.NodeCanvasFactory=a.NodeCMapReaderFactory=void 0;var f=y(9);const _=function(M){return new Promise((b,w)=>{require$$0.readFile(M,(S,v)=>{if(S||!v){w(new Error(S));return}b(new Uint8Array(v))})})};class Y extends f.BaseCanvasFactory{_createCanvas(b,w){return require$$0.createCanvas(b,w)}}a.NodeCanvasFactory=Y;class W extends f.BaseCMapReaderFactory{_fetchData(b,w){return _(b).then(T=>({cMapData:T,compressionType:w}))}}a.NodeCMapReaderFactory=W;class K extends f.BaseStandardFontDataFactory{_fetchData(b){return _(b)}}a.NodeStandardFontDataFactory=K}),((p,a,y)=>{var M,b,w,T,S,v,c,t,r,gn,Mn,mn,On;Object.defineProperty(a,"__esModule",{value:!0}),a.AnnotationEditorLayer=void 0;var f=y(7),_=y(1),Y=y(23),W=y(24);const n=class n{constructor(e){Lt(this,r);Lt(this,M);Lt(this,b,!1);Lt(this,w,this.pointerup.bind(this));Lt(this,T,this.pointerdown.bind(this));Lt(this,S,new Map);Lt(this,v,!1);Lt(this,c,!1);Lt(this,t);n._initialized||(n._initialized=!0,Y.FreeTextEditor.initialize(e.l10n),W.InkEditor.initialize(e.l10n),e.uiManager.registerEditorTypes([Y.FreeTextEditor,W.InkEditor])),Bt(this,t,e.uiManager),this.annotationStorage=e.annotationStorage,this.pageIndex=e.pageIndex,this.div=e.div,Bt(this,M,e.accessibilityManager),R(this,t).addLayer(this)}updateToolbar(e){R(this,t).updateToolbar(e)}updateMode(e=R(this,t).getMode()){Mt(this,r,On).call(this),e===_.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),R(this,t).unselectAll()}addInkEditorIfNeeded(e){if(!e&&R(this,t).getMode()!==_.AnnotationEditorType.INK)return;if(!e){for(const x of R(this,S).values())if(x.isEmpty()){x.setInBackground();return}}Mt(this,r,mn).call(this,{offsetX:0,offsetY:0}).setInBackground()}setEditingState(e){R(this,t).setEditingState(e)}addCommands(e){R(this,t).addCommands(e)}enable(){this.div.style.pointerEvents="auto";for(const e of R(this,S).values())e.enableEditing()}disable(){this.div.style.pointerEvents="none";for(const e of R(this,S).values())e.disableEditing()}setActiveEditor(e){R(this,t).getActive()!==e&&R(this,t).setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",R(this,T)),this.div.addEventListener("pointerup",R(this,w))}disableClick(){this.div.removeEventListener("pointerdown",R(this,T)),this.div.removeEventListener("pointerup",R(this,w))}attach(e){R(this,S).set(e.id,e)}detach(e){var E;R(this,S).delete(e.id),(E=R(this,M))==null||E.removePointerInTextLayer(e.contentDiv)}remove(e){R(this,t).removeEditor(e),this.detach(e),this.annotationStorage.remove(e.id),e.div.style.display="none",setTimeout(()=>{e.div.style.display="",e.div.remove(),e.isAttachedToDOM=!1,document.activeElement===document.body&&R(this,t).focusMainContainer()},0),R(this,c)||this.addInkEditorIfNeeded(!1)}add(e){if(Mt(this,r,gn).call(this,e),R(this,t).addEditor(e),this.attach(e),!e.isAttachedToDOM){const E=e.render();this.div.append(E),e.isAttachedToDOM=!0}this.moveEditorInDOM(e),e.onceAdded(),this.addToAnnotationStorage(e)}moveEditorInDOM(e){var E;(E=R(this,M))==null||E.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addToAnnotationStorage(e){!e.isEmpty()&&!this.annotationStorage.has(e.id)&&this.annotationStorage.setValue(e.id,e)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}addANewEditor(e){const E=()=>{this.addOrRebuild(e)},x=()=>{e.remove()};this.addCommands({cmd:E,undo:x,mustExec:!0})}addUndoableEditor(e){const E=()=>{this.addOrRebuild(e)},x=()=>{e.remove()};this.addCommands({cmd:E,undo:x,mustExec:!1})}getNextId(){return R(this,t).getId()}deserialize(e){switch(e.annotationType){case _.AnnotationEditorType.FREETEXT:return Y.FreeTextEditor.deserialize(e,this);case _.AnnotationEditorType.INK:return W.InkEditor.deserialize(e,this)}return null}setSelected(e){R(this,t).setSelected(e)}toggleSelected(e){R(this,t).toggleSelected(e)}isSelected(e){return R(this,t).isSelected(e)}unselect(e){R(this,t).unselect(e)}pointerup(e){const E=f.KeyboardManager.platform.isMac;if(!(e.button!==0||e.ctrlKey&&E)&&e.target===this.div&&R(this,v)){if(Bt(this,v,!1),!R(this,b)){Bt(this,b,!0);return}Mt(this,r,mn).call(this,e)}}pointerdown(e){const E=f.KeyboardManager.platform.isMac;if(e.button!==0||e.ctrlKey&&E||e.target!==this.div)return;Bt(this,v,!0);const x=R(this,t).getActive();Bt(this,b,!x||x.isEmpty())}drop(e){const E=e.dataTransfer.getData("text/plain"),x=R(this,t).getEditor(E);if(!x)return;e.preventDefault(),e.dataTransfer.dropEffect="move",Mt(this,r,gn).call(this,x);const N=this.div.getBoundingClientRect(),I=e.clientX-N.x,St=e.clientY-N.y;x.translate(I-x.startX,St-x.startY),this.moveEditorInDOM(x),x.div.focus()}dragover(e){e.preventDefault()}destroy(){var e,E;((e=R(this,t).getActive())==null?void 0:e.parent)===this&&R(this,t).setActiveEditor(null);for(const x of R(this,S).values())(E=R(this,M))==null||E.removePointerInTextLayer(x.contentDiv),x.isAttachedToDOM=!1,x.div.remove(),x.parent=null;this.div=null,R(this,S).clear(),R(this,t).removeLayer(this)}render(e){this.viewport=e.viewport,(0,f.bindEvents)(this,this.div,["dragover","drop"]),this.setDimensions();for(const E of R(this,t).getEditors(this.pageIndex))this.add(E);this.updateMode()}update(e){this.viewport=e.viewport,this.setDimensions(),this.updateMode()}get scaleFactor(){return this.viewport.scale}get pageDimensions(){const[e,E,x,N]=this.viewport.viewBox,I=x-e,St=N-E;return[I,St]}get viewportBaseDimensions(){const{width:e,height:E,rotation:x}=this.viewport;return x%180===0?[e,E]:[E,e]}setDimensions(){const{width:e,height:E,rotation:x}=this.viewport,N=x%180!==0,I=Math.floor(e)+"px",St=Math.floor(E)+"px";this.div.style.width=N?St:I,this.div.style.height=N?I:St,this.div.setAttribute("data-main-rotation",x)}};M=new WeakMap,b=new WeakMap,w=new WeakMap,T=new WeakMap,S=new WeakMap,v=new WeakMap,c=new WeakMap,t=new WeakMap,r=new WeakSet,gn=function(e){var E;e.parent!==this&&(this.attach(e),e.pageIndex=this.pageIndex,(E=e.parent)==null||E.detach(e),e.parent=this,e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))},Mn=function(e){switch(R(this,t).getMode()){case _.AnnotationEditorType.FREETEXT:return new Y.FreeTextEditor(e);case _.AnnotationEditorType.INK:return new W.InkEditor(e)}return null},mn=function(e){const E=this.getNextId(),x=Mt(this,r,Mn).call(this,{parent:this,id:E,x:e.offsetX,y:e.offsetY});return x&&this.add(x),x},On=function(){Bt(this,c,!0);for(const e of R(this,S).values())e.isEmpty()&&e.remove();Bt(this,c,!1)},se(n,"_initialized",!1);let K=n;a.AnnotationEditorLayer=K}),((p,a,y)=>{var K,M,b,w,T,S,v,c,In,Ln,Bn,bn;Object.defineProperty(a,"__esModule",{value:!0}),a.FreeTextEditor=void 0;var f=y(1),_=y(7),Y=y(6);const m=class m extends Y.AnnotationEditor{constructor(i){super({...i,name:"freeTextEditor"});Lt(this,c);Lt(this,K,this.editorDivBlur.bind(this));Lt(this,M,this.editorDivFocus.bind(this));Lt(this,b,this.editorDivKeydown.bind(this));Lt(this,w);Lt(this,T,"");Lt(this,S,!1);Lt(this,v);Bt(this,w,i.color||m._defaultColor||Y.AnnotationEditor._defaultLineColor),Bt(this,v,i.fontSize||m._defaultFontSize)}static initialize(i){this._l10nPromise=new Map(["free_text_default_content","editor_free_text_aria_label"].map(E=>[E,i.get(E)]));const e=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(e.getPropertyValue("--freetext-padding"))}static updateDefaultParams(i,e){switch(i){case f.AnnotationEditorParamsType.FREETEXT_SIZE:m._defaultFontSize=e;break;case f.AnnotationEditorParamsType.FREETEXT_COLOR:m._defaultColor=e;break}}updateParams(i,e){switch(i){case f.AnnotationEditorParamsType.FREETEXT_SIZE:Mt(this,c,In).call(this,e);break;case f.AnnotationEditorParamsType.FREETEXT_COLOR:Mt(this,c,Ln).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[f.AnnotationEditorParamsType.FREETEXT_SIZE,m._defaultFontSize],[f.AnnotationEditorParamsType.FREETEXT_COLOR,m._defaultColor||Y.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[f.AnnotationEditorParamsType.FREETEXT_SIZE,R(this,v)],[f.AnnotationEditorParamsType.FREETEXT_COLOR,R(this,w)]]}getInitialTranslation(){return[-m._internalPadding*this.parent.scaleFactor,-(m._internalPadding+R(this,v))*this.parent.scaleFactor]}rebuild(){super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(f.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.enableEditing(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this.div.draggable=!1,this.editorDiv.addEventListener("keydown",R(this,b)),this.editorDiv.addEventListener("focus",R(this,M)),this.editorDiv.addEventListener("blur",R(this,K)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.disableEditing(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",R(this,b)),this.editorDiv.removeEventListener("focus",R(this,M)),this.editorDiv.removeEventListener("blur",R(this,K)),this.div.focus(),this.isEditing=!1)}focusin(i){super.focusin(i),i.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus())}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent.setEditingState(!0),super.remove()}commit(){super.commit(),R(this,S)||(Bt(this,S,!0),this.parent.addUndoableEditor(this)),this.disableEditMode(),Bt(this,T,Mt(this,c,Bn).call(this).trimEnd()),Mt(this,c,bn).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(i){this.enableEditMode(),this.editorDiv.focus()}keydown(i){i.target===this.div&&i.key==="Enter"&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(i){m._keyboardManager.exec(this,i)}editorDivFocus(i){this.isEditing=!0}editorDivBlur(i){this.isEditing=!1}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let i,e;this.width&&(i=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",`${this.id}-editor`),this.enableEditing(),m._l10nPromise.get("editor_free_text_aria_label").then(x=>{var N;return(N=this.editorDiv)==null?void 0:N.setAttribute("aria-label",x)}),m._l10nPromise.get("free_text_default_content").then(x=>{var N;return(N=this.editorDiv)==null?void 0:N.setAttribute("default-content",x)}),this.editorDiv.contentEditable=!0;const{style:E}=this.editorDiv;if(E.fontSize=`calc(${R(this,v)}px * var(--scale-factor))`,E.color=R(this,w),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,_.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){const[x,N]=this.parent.viewportBaseDimensions;this.setAt(i*x,e*N,this.width*x,this.height*N);for(const I of R(this,T).split(`
|
|
40
|
+
`)){const St=document.createElement("div");St.append(I?document.createTextNode(I):document.createElement("br")),this.editorDiv.append(St)}this.div.draggable=!0,this.editorDiv.contentEditable=!1}else this.div.draggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(i,e){const E=super.deserialize(i,e);return Bt(E,v,i.fontSize),Bt(E,w,f.Util.makeHexColor(...i.color)),Bt(E,T,i.value),E}serialize(){if(this.isEmpty())return null;const i=m._internalPadding*this.parent.scaleFactor,e=this.getRect(i,i),E=Y.AnnotationEditor._colorManager.convert(getComputedStyle(this.editorDiv).color);return{annotationType:f.AnnotationEditorType.FREETEXT,color:E,fontSize:R(this,v),value:R(this,T),pageIndex:this.parent.pageIndex,rect:e,rotation:this.rotation}}};K=new WeakMap,M=new WeakMap,b=new WeakMap,w=new WeakMap,T=new WeakMap,S=new WeakMap,v=new WeakMap,c=new WeakSet,In=function(i){const e=x=>{this.editorDiv.style.fontSize=`calc(${x}px * var(--scale-factor))`,this.translate(0,-(x-R(this,v))*this.parent.scaleFactor),Bt(this,v,x),Mt(this,c,bn).call(this)},E=R(this,v);this.parent.addCommands({cmd:()=>{e(i)},undo:()=>{e(E)},mustExec:!0,type:f.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Ln=function(i){const e=R(this,w);this.parent.addCommands({cmd:()=>{Bt(this,w,i),this.editorDiv.style.color=i},undo:()=>{Bt(this,w,e),this.editorDiv.style.color=e},mustExec:!0,type:f.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Bn=function(){const i=this.editorDiv.getElementsByTagName("div");if(i.length===0)return this.editorDiv.innerText;const e=[];for(let E=0,x=i.length;E<x;E++){const I=i[E].firstChild;(I==null?void 0:I.nodeName)==="#text"?e.push(I.data):e.push("")}return e.join(`
|
|
41
|
+
`)},bn=function(){const[i,e]=this.parent.viewportBaseDimensions,E=this.div.getBoundingClientRect();this.width=E.width/i,this.height=E.height/e},se(m,"_freeTextDefaultContent",""),se(m,"_l10nPromise"),se(m,"_internalPadding",0),se(m,"_defaultColor",null),se(m,"_defaultFontSize",10),se(m,"_keyboardManager",new _.KeyboardManager([[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],m.prototype.commitOrRemove]])),se(m,"_type","freetext");let W=m;a.FreeTextEditor=W}),((p,a,y)=>{var b,w,T,S,v,c,t,r,o,F,m,l,n,i,e,Nn,jn,$n,Un,_n,Wn,qn,Hn,ce,An,tn,en,pe,yn,nn,d,En,zn,Xn,Gn,Cn,sn,ge,vn;Object.defineProperty(a,"__esModule",{value:!0}),a.InkEditor=void 0,Object.defineProperty(a,"fitCurve",{enumerable:!0,get:function(){return Y.fitCurve}});var f=y(1),_=y(6),Y=y(25),W=y(7);const K=16,A=class A extends _.AnnotationEditor{constructor(D){super({...D,name:"inkEditor"});Lt(this,e);Lt(this,b,0);Lt(this,w,0);Lt(this,T,0);Lt(this,S,this.canvasPointermove.bind(this));Lt(this,v,this.canvasPointerleave.bind(this));Lt(this,c,this.canvasPointerup.bind(this));Lt(this,t,this.canvasPointerdown.bind(this));Lt(this,r,!1);Lt(this,o,!1);Lt(this,F,null);Lt(this,m,null);Lt(this,l,0);Lt(this,n,0);Lt(this,i,null);this.color=D.color||null,this.thickness=D.thickness||null,this.opacity=D.opacity||null,this.paths=[],this.bezierPath2D=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0}static initialize(D){this._l10nPromise=new Map(["editor_ink_canvas_aria_label","editor_ink_aria_label"].map(g=>[g,D.get(g)]))}static updateDefaultParams(D,g){switch(D){case f.AnnotationEditorParamsType.INK_THICKNESS:A._defaultThickness=g;break;case f.AnnotationEditorParamsType.INK_COLOR:A._defaultColor=g;break;case f.AnnotationEditorParamsType.INK_OPACITY:A._defaultOpacity=g/100;break}}updateParams(D,g){switch(D){case f.AnnotationEditorParamsType.INK_THICKNESS:Mt(this,e,Nn).call(this,g);break;case f.AnnotationEditorParamsType.INK_COLOR:Mt(this,e,jn).call(this,g);break;case f.AnnotationEditorParamsType.INK_OPACITY:Mt(this,e,$n).call(this,g);break}}static get defaultPropertiesToUpdate(){return[[f.AnnotationEditorParamsType.INK_THICKNESS,A._defaultThickness],[f.AnnotationEditorParamsType.INK_COLOR,A._defaultColor||_.AnnotationEditor._defaultLineColor],[f.AnnotationEditorParamsType.INK_OPACITY,Math.round(A._defaultOpacity*100)]]}get propertiesToUpdate(){return[[f.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||A._defaultThickness],[f.AnnotationEditorParamsType.INK_COLOR,this.color||A._defaultColor||_.AnnotationEditor._defaultLineColor],[f.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??A._defaultOpacity))]]}rebuild(){super.rebuild(),this.div!==null&&(this.canvas||(Mt(this,e,tn).call(this),Mt(this,e,en).call(this)),this.isAttachedToDOM||(this.parent.add(this),Mt(this,e,pe).call(this)),Mt(this,e,ge).call(this))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,R(this,m).disconnect(),Bt(this,m,null),super.remove())}enableEditMode(){R(this,r)||this.canvas===null||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",R(this,t)),this.canvas.addEventListener("pointerup",R(this,c)))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",R(this,t)),this.canvas.removeEventListener("pointerup",R(this,c)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){R(this,r)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),Bt(this,r,!0),this.div.classList.add("disabled"),Mt(this,e,ge).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus())}focusin(D){super.focusin(D),this.enableEditMode()}canvasPointerdown(D){D.button!==0||!this.isInEditMode()||R(this,r)||(this.setInForeground(),D.type!=="mouse"&&this.div.focus(),D.stopPropagation(),this.canvas.addEventListener("pointerleave",R(this,v)),this.canvas.addEventListener("pointermove",R(this,S)),Mt(this,e,Wn).call(this,D.offsetX,D.offsetY))}canvasPointermove(D){D.stopPropagation(),Mt(this,e,qn).call(this,D.offsetX,D.offsetY)}canvasPointerup(D){D.button===0&&this.isInEditMode()&&this.currentPath.length!==0&&(D.stopPropagation(),Mt(this,e,An).call(this,D),this.setInBackground())}canvasPointerleave(D){Mt(this,e,An).call(this,D),this.setInBackground()}render(){if(this.div)return this.div;let D,g;this.width&&(D=this.x,g=this.y),super.render(),A._l10nPromise.get("editor_ink_aria_label").then(Ct=>{var Tt;return(Tt=this.div)==null?void 0:Tt.setAttribute("aria-label",Ct)});const[L,At,H,Q]=Mt(this,e,Un).call(this);if(this.setAt(L,At,0,0),this.setDims(H,Q),Mt(this,e,tn).call(this),this.width){const[Ct,Tt]=this.parent.viewportBaseDimensions;this.setAt(D*Ct,g*Tt,this.width*Ct,this.height*Tt),Bt(this,o,!0),Mt(this,e,pe).call(this),this.setDims(this.width*Ct,this.height*Tt),Mt(this,e,ce).call(this),Mt(this,e,vn).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return Mt(this,e,en).call(this),this.div}setDimensions(D,g){const L=Math.round(D),At=Math.round(g);if(R(this,l)===L&&R(this,n)===At)return;Bt(this,l,L),Bt(this,n,At),this.canvas.style.visibility="hidden",R(this,b)&&Math.abs(R(this,b)-D/g)>.01&&(g=Math.ceil(D/R(this,b)),this.setDims(D,g));const[H,Q]=this.parent.viewportBaseDimensions;this.width=D/H,this.height=g/Q,R(this,r)&&Mt(this,e,yn).call(this,D,g),Mt(this,e,pe).call(this),Mt(this,e,ce).call(this),this.canvas.style.visibility="visible"}static deserialize(D,g){var Ht,Wt;const L=super.deserialize(D,g);L.thickness=D.thickness,L.color=f.Util.makeHexColor(...D.color),L.opacity=D.opacity;const[At,H]=g.pageDimensions,Q=L.width*At,Ct=L.height*H,Tt=g.scaleFactor,It=D.thickness/2;Bt(L,b,Q/Ct),Bt(L,r,!0),Bt(L,l,Math.round(Q)),Bt(L,n,Math.round(Ct));for(const{bezier:jt}of D.paths){const Xt=[];L.paths.push(Xt);let Vt=Tt*(jt[0]-It),te=Tt*(Ct-jt[1]-It);for(let Yt=2,Kt=jt.length;Yt<Kt;Yt+=6){const Qt=Tt*(jt[Yt]-It),le=Tt*(Ct-jt[Yt+1]-It),de=Tt*(jt[Yt+2]-It),he=Tt*(Ct-jt[Yt+3]-It),Dt=Tt*(jt[Yt+4]-It),J=Tt*(Ct-jt[Yt+5]-It);Xt.push([[Vt,te],[Qt,le],[de,he],[Dt,J]]),Vt=Dt,te=J}const Gt=Mt(this,d,En).call(this,Xt);L.bezierPath2D.push(Gt)}const kt=Mt(Ht=L,e,Cn).call(Ht);return Bt(L,T,Math.max(K,kt[2]-kt[0])),Bt(L,w,Math.max(K,kt[3]-kt[1])),Mt(Wt=L,e,yn).call(Wt,Q,Ct),L}serialize(){if(this.isEmpty())return null;const D=this.getRect(0,0),g=this.rotation%180===0?D[3]-D[1]:D[2]-D[0],L=_.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:f.AnnotationEditorType.INK,color:L,thickness:this.thickness,opacity:this.opacity,paths:Mt(this,e,zn).call(this,this.scaleFactor/this.parent.scaleFactor,this.translationX,this.translationY,g),pageIndex:this.parent.pageIndex,rect:D,rotation:this.rotation}}};b=new WeakMap,w=new WeakMap,T=new WeakMap,S=new WeakMap,v=new WeakMap,c=new WeakMap,t=new WeakMap,r=new WeakMap,o=new WeakMap,F=new WeakMap,m=new WeakMap,l=new WeakMap,n=new WeakMap,i=new WeakMap,e=new WeakSet,Nn=function(D){const g=this.thickness;this.parent.addCommands({cmd:()=>{this.thickness=D,Mt(this,e,ge).call(this)},undo:()=>{this.thickness=g,Mt(this,e,ge).call(this)},mustExec:!0,type:f.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},jn=function(D){const g=this.color;this.parent.addCommands({cmd:()=>{this.color=D,Mt(this,e,ce).call(this)},undo:()=>{this.color=g,Mt(this,e,ce).call(this)},mustExec:!0,type:f.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},$n=function(D){D/=100;const g=this.opacity;this.parent.addCommands({cmd:()=>{this.opacity=D,Mt(this,e,ce).call(this)},undo:()=>{this.opacity=g,Mt(this,e,ce).call(this)},mustExec:!0,type:f.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Un=function(){const{width:D,height:g,rotation:L}=this.parent.viewport;switch(L){case 90:return[0,D,D,g];case 180:return[D,g,D,g];case 270:return[g,0,D,g];default:return[0,0,D,g]}},_n=function(){this.ctx.lineWidth=this.thickness*this.parent.scaleFactor/this.scaleFactor,this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.miterLimit=10,this.ctx.strokeStyle=`${this.color}${(0,W.opacityToHex)(this.opacity)}`},Wn=function(D,g){this.isEditing=!0,R(this,o)||(Bt(this,o,!0),Mt(this,e,pe).call(this),this.thickness||(this.thickness=A._defaultThickness),this.color||(this.color=A._defaultColor||_.AnnotationEditor._defaultLineColor),this.opacity??(this.opacity=A._defaultOpacity)),this.currentPath.push([D,g]),Bt(this,F,null),Mt(this,e,_n).call(this),this.ctx.beginPath(),this.ctx.moveTo(D,g),Bt(this,i,()=>{R(this,i)&&(R(this,F)&&(this.isEmpty()?(this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)):Mt(this,e,ce).call(this),this.ctx.lineTo(...R(this,F)),Bt(this,F,null),this.ctx.stroke()),window.requestAnimationFrame(R(this,i)))}),window.requestAnimationFrame(R(this,i))},qn=function(D,g){const[L,At]=this.currentPath.at(-1);D===L&&g===At||(this.currentPath.push([D,g]),Bt(this,F,[D,g]))},Hn=function(D,g){var It;this.ctx.closePath(),Bt(this,i,null),D=Math.min(Math.max(D,0),this.canvas.width),g=Math.min(Math.max(g,0),this.canvas.height);const[L,At]=this.currentPath.at(-1);(D!==L||g!==At)&&this.currentPath.push([D,g]);let H;if(this.currentPath.length!==1)H=(0,Y.fitCurve)(this.currentPath,30,null);else{const kt=[D,g];H=[[kt,kt.slice(),kt.slice(),kt]]}const Q=Mt(It=A,d,En).call(It,H);this.currentPath.length=0;const Ct=()=>{this.paths.push(H),this.bezierPath2D.push(Q),this.rebuild()},Tt=()=>{this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(Mt(this,e,tn).call(this),Mt(this,e,en).call(this)),Mt(this,e,ge).call(this))};this.parent.addCommands({cmd:Ct,undo:Tt,mustExec:!0})},ce=function(){if(this.isEmpty()){Mt(this,e,nn).call(this);return}Mt(this,e,_n).call(this);const{canvas:D,ctx:g}=this;g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,D.width,D.height),Mt(this,e,nn).call(this);for(const L of this.bezierPath2D)g.stroke(L)},An=function(D){Mt(this,e,Hn).call(this,D.offsetX,D.offsetY),this.canvas.removeEventListener("pointerleave",R(this,v)),this.canvas.removeEventListener("pointermove",R(this,S)),this.parent.addToAnnotationStorage(this)},tn=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",A._l10nPromise.get("editor_ink_canvas_aria_label").then(D=>{var g;return(g=this.canvas)==null?void 0:g.setAttribute("aria-label",D)}),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},en=function(){Bt(this,m,new ResizeObserver(D=>{const g=D[0].contentRect;g.width&&g.height&&this.setDimensions(g.width,g.height)})),R(this,m).observe(this.div)},pe=function(){if(!R(this,o))return;const[D,g]=this.parent.viewportBaseDimensions;this.canvas.width=Math.ceil(this.width*D),this.canvas.height=Math.ceil(this.height*g),Mt(this,e,nn).call(this)},yn=function(D,g){const L=Mt(this,e,sn).call(this),At=(D-L)/R(this,T),H=(g-L)/R(this,w);this.scaleFactor=Math.min(At,H)},nn=function(){const D=Mt(this,e,sn).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+D,this.translationY*this.scaleFactor+D)},d=new WeakSet,En=function(D){const g=new Path2D;for(let L=0,At=D.length;L<At;L++){const[H,Q,Ct,Tt]=D[L];L===0&&g.moveTo(...H),g.bezierCurveTo(Q[0],Q[1],Ct[0],Ct[1],Tt[0],Tt[1])}return g},zn=function(D,g,L,At){const Q=[],Ct=this.thickness/2;let Tt,It;for(const kt of this.paths){Tt=[],It=[];for(let Ht=0,Wt=kt.length;Ht<Wt;Ht++){const[jt,Xt,Vt,te]=kt[Ht],Gt=D*(jt[0]+g)+Ct,Yt=At-D*(jt[1]+L)-Ct,Kt=D*(Xt[0]+g)+Ct,Qt=At-D*(Xt[1]+L)-Ct,le=D*(Vt[0]+g)+Ct,de=At-D*(Vt[1]+L)-Ct,he=D*(te[0]+g)+Ct,Dt=At-D*(te[1]+L)-Ct;Ht===0&&(Tt.push(Gt,Yt),It.push(Gt,Yt)),Tt.push(Kt,Qt,le,de,he,Dt),Mt(this,e,Xn).call(this,Gt,Yt,Kt,Qt,le,de,he,Dt,4,It)}Q.push({bezier:Tt,points:It})}return Q},Xn=function(D,g,L,At,H,Q,Ct,Tt,It,kt){if(Mt(this,e,Gn).call(this,D,g,L,At,H,Q,Ct,Tt)){kt.push(Ct,Tt);return}for(let Ht=1;Ht<It-1;Ht++){const Wt=Ht/It,jt=1-Wt;let Xt=Wt*D+jt*L,Vt=Wt*g+jt*At,te=Wt*L+jt*H,Gt=Wt*At+jt*Q;const Yt=Wt*H+jt*Ct,Kt=Wt*Q+jt*Tt;Xt=Wt*Xt+jt*te,Vt=Wt*Vt+jt*Gt,te=Wt*te+jt*Yt,Gt=Wt*Gt+jt*Kt,Xt=Wt*Xt+jt*te,Vt=Wt*Vt+jt*Gt,kt.push(Xt,Vt)}kt.push(Ct,Tt)},Gn=function(D,g,L,At,H,Q,Ct,Tt){const kt=(3*L-2*D-Ct)**2,Ht=(3*At-2*g-Tt)**2,Wt=(3*H-D-2*Ct)**2,jt=(3*Q-g-2*Tt)**2;return Math.max(kt,Wt)+Math.max(Ht,jt)<=10},Cn=function(){let D=1/0,g=-1/0,L=1/0,At=-1/0;for(const H of this.paths)for(const[Q,Ct,Tt,It]of H){const kt=f.Util.bezierBoundingBox(...Q,...Ct,...Tt,...It);D=Math.min(D,kt[0]),L=Math.min(L,kt[1]),g=Math.max(g,kt[2]),At=Math.max(At,kt[3])}return[D,L,g,At]},sn=function(){return R(this,r)?Math.ceil(this.thickness*this.parent.scaleFactor):0},ge=function(D=!1){if(this.isEmpty())return;if(!R(this,r)){Mt(this,e,ce).call(this);return}const g=Mt(this,e,Cn).call(this),L=Mt(this,e,sn).call(this);Bt(this,T,Math.max(K,g[2]-g[0])),Bt(this,w,Math.max(K,g[3]-g[1]));const At=Math.ceil(L+R(this,T)*this.scaleFactor),H=Math.ceil(L+R(this,w)*this.scaleFactor),[Q,Ct]=this.parent.viewportBaseDimensions;this.width=At/Q,this.height=H/Ct,Bt(this,b,At/H),Mt(this,e,vn).call(this);const Tt=this.translationX,It=this.translationY;this.translationX=-g[0],this.translationY=-g[1],Mt(this,e,pe).call(this),Mt(this,e,ce).call(this),Bt(this,l,At),Bt(this,n,H),this.setDims(At,H);const kt=D?L/this.scaleFactor/2:0;this.translate(Tt-this.translationX-kt,It-this.translationY-kt)},vn=function(){const{style:D}=this.div;R(this,b)>=1?(D.minHeight=`${K}px`,D.minWidth=`${Math.round(R(this,b)*K)}px`):(D.minWidth=`${K}px`,D.minHeight=`${Math.round(K/R(this,b))}px`)},Lt(A,d),se(A,"_defaultColor",null),se(A,"_defaultOpacity",1),se(A,"_defaultThickness",1),se(A,"_l10nPromise"),se(A,"_type","ink");let M=A;a.InkEditor=M}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.fitCurve=void 0;const f=y(26);a.fitCurve=f}),(p=>{function a(c,t,r){if(!Array.isArray(c))throw new TypeError("First argument should be an array");if(c.forEach(l=>{if(!Array.isArray(l)||l.some(n=>typeof n!="number")||l.length!==c[0].length)throw Error("Each point should be an array of numbers. Each point should have the same amount of numbers.")}),c=c.filter((l,n)=>n===0||!l.every((i,e)=>i===c[n-1][e])),c.length<2)return[];const o=c.length,F=T(c[1],c[0]),m=T(c[o-2],c[o-1]);return y(c,F,m,t,r)}function y(c,t,r,o,F){var l,n,i,e,E,x,N,I,St,Pt,bt,V,O;if(c.length===2)return V=S.vectorLen(S.subtract(c[0],c[1]))/3,l=[c[0],S.addArrays(c[0],S.mulItems(t,V)),S.addArrays(c[1],S.mulItems(r,V)),c[1]],[l];if(n=K(c),[l,e,x]=f(c,n,n,t,r,F),e===0||e<o)return[l];if(e<o*o)for(i=n,E=e,N=x,O=0;O<20;O++){if(i=Y(l,c,i),[l,e,x]=f(c,n,i,t,r,F),e<o)return[l];if(x===N){let z=e/E;if(z>.9999&&z<1.0001)break}E=e,N=x}return bt=[],I=S.subtract(c[x-1],c[x+1]),I.every(z=>z===0)&&(I=S.subtract(c[x-1],c[x]),[I[0],I[1]]=[-I[1],I[0]]),St=S.normalize(I),Pt=S.mulItems(St,-1),bt=bt.concat(y(c.slice(0,x+1),t,St,o,F)),bt=bt.concat(y(c.slice(x),Pt,r,o,F)),bt}function f(c,t,r,o,F,m){var l,n,i;return l=_(c,r,o,F),[n,i]=M(c,l,t),m&&m({bez:l,points:c,params:t,maxErr:n,maxPoint:i}),[l,n,i]}function _(c,t,r,o){var F,m,l,n,i,e,E,x,N,I,St,Pt,bt,V,O,z,G,_t=c[0],wt=c[c.length-1];for(F=[_t,null,null,wt],m=S.zeros_Xx2x2(t.length),bt=0,V=t.length;bt<V;bt++)z=t[bt],G=1-z,l=m[bt],l[0]=S.mulItems(r,3*z*(G*G)),l[1]=S.mulItems(o,3*G*(z*z));for(n=[[0,0],[0,0]],i=[0,0],bt=0,V=c.length;bt<V;bt++)z=t[bt],l=m[bt],n[0][0]+=S.dot(l[0],l[0]),n[0][1]+=S.dot(l[0],l[1]),n[1][0]+=S.dot(l[0],l[1]),n[1][1]+=S.dot(l[1],l[1]),O=S.subtract(c[bt],v.q([_t,_t,wt,wt],z)),i[0]+=S.dot(l[0],O),i[1]+=S.dot(l[1],O);return e=n[0][0]*n[1][1]-n[1][0]*n[0][1],E=n[0][0]*i[1]-n[1][0]*i[0],x=i[0]*n[1][1]-i[1]*n[0][1],N=e===0?0:x/e,I=e===0?0:E/e,Pt=S.vectorLen(S.subtract(_t,wt)),St=1e-6*Pt,N<St||I<St?(F[1]=S.addArrays(_t,S.mulItems(r,Pt/3)),F[2]=S.addArrays(wt,S.mulItems(o,Pt/3))):(F[1]=S.addArrays(_t,S.mulItems(r,N)),F[2]=S.addArrays(wt,S.mulItems(o,I))),F}function Y(c,t,r){return r.map((o,F)=>W(c,t[F],o))}function W(c,t,r){var o=S.subtract(v.q(c,r),t),F=v.qprime(c,r),m=S.mulMatrix(o,F),l=S.sum(S.squareItems(F))+2*S.mulMatrix(o,v.qprimeprime(c,r));return l===0?r:r-m/l}function K(c){var t=[],r,o,F;return c.forEach((m,l)=>{r=l?o+S.vectorLen(S.subtract(m,F)):0,t.push(r),o=r,F=m}),t=t.map(m=>m/o),t}function M(c,t,r){var o,F,m,l,n,i,e,E;F=0,m=Math.floor(c.length/2);const x=b(t,10);for(n=0,i=c.length;n<i;n++)e=c[n],E=w(t,r[n],x,10),l=S.subtract(v.q(t,E),e),o=l[0]*l[0]+l[1]*l[1],o>F&&(F=o,m=n);return[F,m]}var b=function(c,t){for(var r,o=[0],F=c[0],m=0,l=1;l<=t;l++)r=v.q(c,l/t),m+=S.vectorLen(S.subtract(r,F)),o.push(m),F=r;return o=o.map(n=>n/m),o};function w(c,t,r,o){if(t<0)return 0;if(t>1)return 1;for(var F,m,l,n,i,e=1;e<=o;e++)if(t<=r[e]){n=(e-1)/o,l=e/o,m=r[e-1],F=r[e],i=(t-m)/(F-m)*(l-n)+n;break}return i}function T(c,t){return S.normalize(S.subtract(c,t))}class S{static zeros_Xx2x2(t){for(var r=[];t--;)r.push([0,0]);return r}static mulItems(t,r){return t.map(o=>o*r)}static mulMatrix(t,r){return t.reduce((o,F,m)=>o+F*r[m],0)}static subtract(t,r){return t.map((o,F)=>o-r[F])}static addArrays(t,r){return t.map((o,F)=>o+r[F])}static addItems(t,r){return t.map(o=>o+r)}static sum(t){return t.reduce((r,o)=>r+o)}static dot(t,r){return S.mulMatrix(t,r)}static vectorLen(t){return Math.hypot(...t)}static divItems(t,r){return t.map(o=>o/r)}static squareItems(t){return t.map(r=>r*r)}static normalize(t){return this.divItems(t,this.vectorLen(t))}}class v{static q(t,r){var o=1-r,F=S.mulItems(t[0],o*o*o),m=S.mulItems(t[1],3*o*o*r),l=S.mulItems(t[2],3*o*r*r),n=S.mulItems(t[3],r*r*r);return S.addArrays(S.addArrays(F,m),S.addArrays(l,n))}static qprime(t,r){var o=1-r,F=S.mulItems(S.subtract(t[1],t[0]),3*o*o),m=S.mulItems(S.subtract(t[2],t[1]),6*o*r),l=S.mulItems(S.subtract(t[3],t[2]),3*r*r);return S.addArrays(S.addArrays(F,m),l)}static qprimeprime(t,r){return S.addArrays(S.mulItems(S.addArrays(S.subtract(t[2],S.mulItems(t[1],2)),t[0]),6*(1-r)),S.mulItems(S.addArrays(S.subtract(t[3],S.mulItems(t[2],2)),t[1]),6*r))}}p.exports=a,p.exports.fitCubic=y,p.exports.createTangent=T}),((p,a,y)=>{var d,Fn,Sn,xn;Object.defineProperty(a,"__esModule",{value:!0}),a.AnnotationLayer=void 0;var f=y(1),_=y(8),Y=y(5),W=y(28),K=y(29);const M=1e3,b=9,w=new WeakSet;function T($){return{width:$[2]-$[0],height:$[3]-$[1]}}class S{static create(s){switch(s.data.annotationType){case f.AnnotationType.LINK:return new c(s);case f.AnnotationType.TEXT:return new t(s);case f.AnnotationType.WIDGET:switch(s.data.fieldType){case"Tx":return new o(s);case"Btn":return s.data.radioButton?new m(s):s.data.checkBox?new F(s):new l(s);case"Ch":return new n(s)}return new r(s);case f.AnnotationType.POPUP:return new i(s);case f.AnnotationType.FREETEXT:return new E(s);case f.AnnotationType.LINE:return new x(s);case f.AnnotationType.SQUARE:return new N(s);case f.AnnotationType.CIRCLE:return new I(s);case f.AnnotationType.POLYLINE:return new St(s);case f.AnnotationType.CARET:return new bt(s);case f.AnnotationType.INK:return new V(s);case f.AnnotationType.POLYGON:return new Pt(s);case f.AnnotationType.HIGHLIGHT:return new O(s);case f.AnnotationType.UNDERLINE:return new z(s);case f.AnnotationType.SQUIGGLY:return new G(s);case f.AnnotationType.STRIKEOUT:return new _t(s);case f.AnnotationType.STAMP:return new wt(s);case f.AnnotationType.FILEATTACHMENT:return new Ot(s);default:return new v(s)}}}class v{constructor(s,{isRenderable:h=!1,ignoreBorder:C=!1,createQuadrilaterals:A=!1}={}){this.isRenderable=h,this.data=s.data,this.layer=s.layer,this.page=s.page,this.viewport=s.viewport,this.linkService=s.linkService,this.downloadManager=s.downloadManager,this.imageResourcesPath=s.imageResourcesPath,this.renderForms=s.renderForms,this.svgFactory=s.svgFactory,this.annotationStorage=s.annotationStorage,this.enableScripting=s.enableScripting,this.hasJSActions=s.hasJSActions,this._fieldObjects=s.fieldObjects,this._mouseState=s.mouseState,h&&(this.container=this._createContainer(C)),A&&(this.quadrilaterals=this._createQuadrilaterals(C))}_createContainer(s=!1){const h=this.data,C=this.page,A=this.viewport,k=document.createElement("section"),{width:B,height:D}=T(h.rect),[g,L,At,H]=A.viewBox,Q=At-g,Ct=H-L;k.setAttribute("data-annotation-id",h.id);const Tt=f.Util.normalizeRect([h.rect[0],C.view[3]-h.rect[1]+C.view[1],h.rect[2],C.view[3]-h.rect[3]+C.view[1]]);if(!s&&h.borderStyle.width>0){k.style.borderWidth=`${h.borderStyle.width}px`;const kt=h.borderStyle.horizontalCornerRadius,Ht=h.borderStyle.verticalCornerRadius;if(kt>0||Ht>0){const jt=`calc(${kt}px * var(--scale-factor)) / calc(${Ht}px * var(--scale-factor))`;k.style.borderRadius=jt}else if(this instanceof m){const jt=`calc(${B}px * var(--scale-factor)) / calc(${D}px * var(--scale-factor))`;k.style.borderRadius=jt}switch(h.borderStyle.style){case f.AnnotationBorderStyleType.SOLID:k.style.borderStyle="solid";break;case f.AnnotationBorderStyleType.DASHED:k.style.borderStyle="dashed";break;case f.AnnotationBorderStyleType.BEVELED:(0,f.warn)("Unimplemented border style: beveled");break;case f.AnnotationBorderStyleType.INSET:(0,f.warn)("Unimplemented border style: inset");break;case f.AnnotationBorderStyleType.UNDERLINE:k.style.borderBottomStyle="solid";break}const Wt=h.borderColor||null;Wt?k.style.borderColor=f.Util.makeHexColor(Wt[0]|0,Wt[1]|0,Wt[2]|0):k.style.borderWidth=0}k.style.left=`${100*(Tt[0]-g)/Q}%`,k.style.top=`${100*(Tt[1]-L)/Ct}%`;const{rotation:It}=h;return h.hasOwnCanvas||It===0?(k.style.width=`${100*B/Q}%`,k.style.height=`${100*D/Ct}%`):this.setRotation(It,k),k}setRotation(s,h=this.container){const[C,A,k,B]=this.viewport.viewBox,D=k-C,g=B-A,{width:L,height:At}=T(this.data.rect);let H,Q;s%180===0?(H=100*L/D,Q=100*At/g):(H=100*At/D,Q=100*L/g),h.style.width=`${H}%`,h.style.height=`${Q}%`,h.setAttribute("data-main-rotation",(360-s)%360)}get _commonActions(){const s=(h,C,A)=>{const k=A.detail[h];A.target.style[C]=W.ColorConverters[`${k[0]}_HTML`](k.slice(1))};return(0,f.shadow)(this,"_commonActions",{display:h=>{const C=h.detail.display%2===1;this.container.style.visibility=C?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:C,print:h.detail.display===0||h.detail.display===3})},print:h=>{this.annotationStorage.setValue(this.data.id,{print:h.detail.print})},hidden:h=>{this.container.style.visibility=h.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:h.detail.hidden})},focus:h=>{setTimeout(()=>h.target.focus({preventScroll:!1}),0)},userName:h=>{h.target.title=h.detail.userName},readonly:h=>{h.detail.readonly?h.target.setAttribute("readonly",""):h.target.removeAttribute("readonly")},required:h=>{this._setRequired(h.target,h.detail.required)},bgColor:h=>{s("bgColor","backgroundColor",h)},fillColor:h=>{s("fillColor","backgroundColor",h)},fgColor:h=>{s("fgColor","color",h)},textColor:h=>{s("textColor","color",h)},borderColor:h=>{s("borderColor","borderColor",h)},strokeColor:h=>{s("strokeColor","borderColor",h)},rotation:h=>{const C=h.detail.rotation;this.setRotation(C),this.annotationStorage.setValue(this.data.id,{rotation:C})}})}_dispatchEventFromSandbox(s,h){const C=this._commonActions;for(const A of Object.keys(h.detail)){const k=s[A]||C[A];k&&k(h)}}_setDefaultPropertiesFromJS(s){if(!this.enableScripting)return;const h=this.annotationStorage.getRawValue(this.data.id);if(!h)return;const C=this._commonActions;for(const[A,k]of Object.entries(h)){const B=C[A];if(B){const D={detail:{[A]:k},target:s};B(D),delete h[A]}}}_createQuadrilaterals(s=!1){if(!this.data.quadPoints)return null;const h=[],C=this.data.rect;for(const A of this.data.quadPoints)this.data.rect=[A[2].x,A[2].y,A[1].x,A[1].y],h.push(this._createContainer(s));return this.data.rect=C,h}_createPopup(s,h){let C=this.container;this.quadrilaterals&&(s=s||this.quadrilaterals,C=this.quadrilaterals[0]),s||(s=document.createElement("div"),s.className="popupTriggerArea",C.append(s));const k=new e({container:C,trigger:s,color:h.color,titleObj:h.titleObj,modificationDate:h.modificationDate,contentsObj:h.contentsObj,richText:h.richText,hideWrapper:!0}).render();k.style.left="100%",C.append(k)}_renderQuadrilaterals(s){for(const h of this.quadrilaterals)h.className=s;return this.quadrilaterals}render(){(0,f.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(s,h=null){const C=[];if(this._fieldObjects){const A=this._fieldObjects[s];if(A)for(const{page:k,id:B,exportValues:D}of A){if(k===-1||B===h)continue;const g=typeof D=="string"?D:null,L=document.querySelector(`[data-element-id="${B}"]`);if(L&&!w.has(L)){(0,f.warn)(`_getElementsByName - element not allowed: ${B}`);continue}C.push({id:B,exportValue:g,domElement:L})}return C}for(const A of document.getElementsByName(s)){const{id:k,exportValue:B}=A;k!==h&&w.has(A)&&C.push({id:k,exportValue:B,domElement:A})}return C}static get platform(){const s=typeof navigator<"u"?navigator.platform:"";return(0,f.shadow)(this,"platform",{isWin:s.includes("Win"),isMac:s.includes("Mac")})}}class c extends v{constructor(s,h=null){super(s,{isRenderable:!0,ignoreBorder:!!(h!=null&&h.ignoreBorder),createQuadrilaterals:!0}),this.isTooltipOnly=s.data.isTooltipOnly}render(){const{data:s,linkService:h}=this,C=document.createElement("a");C.setAttribute("data-element-id",s.id);let A=!1;return s.url?(h.addLinkAttributes(C,s.url,s.newWindow),A=!0):s.action?(this._bindNamedAction(C,s.action),A=!0):s.dest?(this._bindLink(C,s.dest),A=!0):(s.actions&&(s.actions.Action||s.actions["Mouse Up"]||s.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(C,s),A=!0),s.resetForm?(this._bindResetFormAction(C,s.resetForm),A=!0):this.isTooltipOnly&&!A&&(this._bindLink(C,""),A=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map((k,B)=>{const D=B===0?C:C.cloneNode();return k.append(D),k}):(this.container.className="linkAnnotation",A&&this.container.append(C),this.container)}_bindLink(s,h){s.href=this.linkService.getDestinationHash(h),s.onclick=()=>(h&&this.linkService.goToDestination(h),!1),(h||h==="")&&(s.className="internalLink")}_bindNamedAction(s,h){s.href=this.linkService.getAnchorUrl(""),s.onclick=()=>(this.linkService.executeNamedAction(h),!1),s.className="internalLink"}_bindJSAction(s,h){s.href=this.linkService.getAnchorUrl("");const C=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const A of Object.keys(h.actions)){const k=C.get(A);k&&(s[k]=()=>{var B;return(B=this.linkService.eventBus)==null||B.dispatch("dispatcheventinsandbox",{source:this,detail:{id:h.id,name:A}}),!1})}s.onclick||(s.onclick=()=>!1),s.className="internalLink"}_bindResetFormAction(s,h){const C=s.onclick;if(C||(s.href=this.linkService.getAnchorUrl("")),s.className="internalLink",!this._fieldObjects){(0,f.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),C||(s.onclick=()=>!1);return}s.onclick=()=>{var At;C&&C();const{fields:A,refs:k,include:B}=h,D=[];if(A.length!==0||k.length!==0){const H=new Set(k);for(const Q of A){const Ct=this._fieldObjects[Q]||[];for(const{id:Tt}of Ct)H.add(Tt)}for(const Q of Object.values(this._fieldObjects))for(const Ct of Q)H.has(Ct.id)===B&&D.push(Ct)}else for(const H of Object.values(this._fieldObjects))D.push(...H);const g=this.annotationStorage,L=[];for(const H of D){const{id:Q}=H;switch(L.push(Q),H.type){case"text":{const Tt=H.defaultValue||"";g.setValue(Q,{value:Tt});break}case"checkbox":case"radiobutton":{const Tt=H.defaultValue===H.exportValues;g.setValue(Q,{value:Tt});break}case"combobox":case"listbox":{const Tt=H.defaultValue||"";g.setValue(Q,{value:Tt});break}default:continue}const Ct=document.querySelector(`[data-element-id="${Q}"]`);if(Ct){if(!w.has(Ct)){(0,f.warn)(`_bindResetFormAction - element not allowed: ${Q}`);continue}}else continue;Ct.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((At=this.linkService.eventBus)==null||At.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:L,name:"ResetForm"}})),!1}}}class t extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h})}render(){this.container.className="textAnnotation";const s=document.createElement("img");return s.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",s.alt="[{{type}} Annotation]",s.dataset.l10nId="text_annotation_type",s.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(s,this.data),this.container.append(s),this.container}}class r extends v{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}_getKeyModifier(s){const{isWin:h,isMac:C}=v.platform;return h&&s.ctrlKey||C&&s.metaKey}_setEventListener(s,h,C,A){h.includes("mouse")?s.addEventListener(h,k=>{var B;(B=this.linkService.eventBus)==null||B.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:C,value:A(k),shift:k.shiftKey,modifier:this._getKeyModifier(k)}})}):s.addEventListener(h,k=>{var B;(B=this.linkService.eventBus)==null||B.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:C,value:A(k)}})})}_setEventListeners(s,h,C){var A;for(const[k,B]of h)(B==="Action"||(A=this.data.actions)!=null&&A[B])&&this._setEventListener(s,k,B,C)}_setBackgroundColor(s){const h=this.data.backgroundColor||null;s.style.backgroundColor=h===null?"transparent":f.Util.makeHexColor(h[0],h[1],h[2])}_setTextStyle(s){const h=["left","center","right"],{fontColor:C}=this.data.defaultAppearanceData,A=this.data.defaultAppearanceData.fontSize||b,k=s.style;let B;if(this.data.multiLine){const D=Math.abs(this.data.rect[3]-this.data.rect[1]),g=Math.round(D/(f.LINE_FACTOR*A))||1,L=D/g;B=Math.min(A,Math.round(L/f.LINE_FACTOR))}else{const D=Math.abs(this.data.rect[3]-this.data.rect[1]);B=Math.min(A,Math.round(D/f.LINE_FACTOR))}k.fontSize=`calc(${B}px * var(--scale-factor))`,k.color=f.Util.makeHexColor(C[0],C[1],C[2]),this.data.textAlignment!==null&&(k.textAlign=h[this.data.textAlignment])}_setRequired(s,h){h?s.setAttribute("required",!0):s.removeAttribute("required"),s.setAttribute("aria-required",h)}}class o extends r{constructor(s){const h=s.renderForms||!s.data.hasAppearance&&!!s.data.fieldValue;super(s,{isRenderable:h})}setPropertyOnSiblings(s,h,C,A){const k=this.annotationStorage;for(const B of this._getElementsByName(s.name,s.id))B.domElement&&(B.domElement[h]=C),k.setValue(B.id,{[A]:C})}render(){var A;const s=this.annotationStorage,h=this.data.id;this.container.className="textWidgetAnnotation";let C=null;if(this.renderForms){const k=s.getValue(h,{value:this.data.fieldValue});let B=k.formattedValue||k.value||"";const D=s.getValue(h,{charLimit:this.data.maxLen}).charLimit;D&&B.length>D&&(B=B.slice(0,D));const g={userValue:B,formattedValue:null,valueOnFocus:""};this.data.multiLine?(C=document.createElement("textarea"),C.textContent=B,this.data.doNotScroll&&(C.style.overflowY="hidden")):(C=document.createElement("input"),C.type="text",C.setAttribute("value",B),this.data.doNotScroll&&(C.style.overflowX="hidden")),w.add(C),C.setAttribute("data-element-id",h),C.disabled=this.data.readOnly,C.name=this.data.fieldName,C.tabIndex=M,this._setRequired(C,this.data.required),D&&(C.maxLength=D),C.addEventListener("input",At=>{s.setValue(h,{value:At.target.value}),this.setPropertyOnSiblings(C,"value",At.target.value,"value")}),C.addEventListener("resetform",At=>{const H=this.data.defaultFieldValue??"";C.value=g.userValue=H,g.formattedValue=null});let L=At=>{const{formattedValue:H}=g;H!=null&&(At.target.value=H),At.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){C.addEventListener("focus",H=>{g.userValue&&(H.target.value=g.userValue),g.valueOnFocus=H.target.value}),C.addEventListener("updatefromsandbox",H=>{const Q={value(Ct){g.userValue=Ct.detail.value??"",s.setValue(h,{value:g.userValue.toString()}),Ct.target.value=g.userValue},formattedValue(Ct){const{formattedValue:Tt}=Ct.detail;g.formattedValue=Tt,Tt!=null&&Ct.target!==document.activeElement&&(Ct.target.value=Tt),s.setValue(h,{formattedValue:Tt})},selRange(Ct){Ct.target.setSelectionRange(...Ct.detail.selRange)},charLimit:Ct=>{var Ht;const{charLimit:Tt}=Ct.detail,{target:It}=Ct;if(Tt===0){It.removeAttribute("maxLength");return}It.setAttribute("maxLength",Tt);let kt=g.userValue;!kt||kt.length<=Tt||(kt=kt.slice(0,Tt),It.value=g.userValue=kt,s.setValue(h,{value:kt}),(Ht=this.linkService.eventBus)==null||Ht.dispatch("dispatcheventinsandbox",{source:this,detail:{id:h,name:"Keystroke",value:kt,willCommit:!0,commitKey:1,selStart:It.selectionStart,selEnd:It.selectionEnd}}))}};this._dispatchEventFromSandbox(Q,H)}),C.addEventListener("keydown",H=>{var Tt;let Q=-1;if(H.key==="Escape"?Q=0:H.key==="Enter"?Q=2:H.key==="Tab"&&(Q=3),Q===-1)return;const{value:Ct}=H.target;g.valueOnFocus!==Ct&&(g.userValue=Ct,(Tt=this.linkService.eventBus)==null||Tt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:h,name:"Keystroke",value:Ct,willCommit:!0,commitKey:Q,selStart:H.target.selectionStart,selEnd:H.target.selectionEnd}}))});const At=L;L=null,C.addEventListener("blur",H=>{var Ct;const{value:Q}=H.target;g.userValue=Q,this._mouseState.isDown&&g.valueOnFocus!==Q&&((Ct=this.linkService.eventBus)==null||Ct.dispatch("dispatcheventinsandbox",{source:this,detail:{id:h,name:"Keystroke",value:Q,willCommit:!0,commitKey:1,selStart:H.target.selectionStart,selEnd:H.target.selectionEnd}})),At(H)}),(A=this.data.actions)!=null&&A.Keystroke&&C.addEventListener("beforeinput",H=>{var jt;const{data:Q,target:Ct}=H,{value:Tt,selectionStart:It,selectionEnd:kt}=Ct;let Ht=It,Wt=kt;switch(H.inputType){case"deleteWordBackward":{const Xt=Tt.substring(0,It).match(/\w*[^\w]*$/);Xt&&(Ht-=Xt[0].length);break}case"deleteWordForward":{const Xt=Tt.substring(It).match(/^[^\w]*\w*/);Xt&&(Wt+=Xt[0].length);break}case"deleteContentBackward":It===kt&&(Ht-=1);break;case"deleteContentForward":It===kt&&(Wt+=1);break}H.preventDefault(),(jt=this.linkService.eventBus)==null||jt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:h,name:"Keystroke",value:Tt,change:Q||"",willCommit:!1,selStart:Ht,selEnd:Wt}})}),this._setEventListeners(C,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],H=>H.target.value)}if(L&&C.addEventListener("blur",L),this.data.comb){const H=(this.data.rect[2]-this.data.rect[0])/D;C.classList.add("comb"),C.style.letterSpacing=`calc(${H}px * var(--scale-factor) - 1ch)`}}else C=document.createElement("div"),C.textContent=this.data.fieldValue,C.style.verticalAlign="middle",C.style.display="table-cell";return this._setTextStyle(C),this._setBackgroundColor(C),this._setDefaultPropertiesFromJS(C),this.container.append(C),this.container}}class F extends r{constructor(s){super(s,{isRenderable:s.renderForms})}render(){const s=this.annotationStorage,h=this.data,C=h.id;let A=s.getValue(C,{value:h.exportValue===h.fieldValue}).value;typeof A=="string"&&(A=A!=="Off",s.setValue(C,{value:A})),this.container.className="buttonWidgetAnnotation checkBox";const k=document.createElement("input");return w.add(k),k.setAttribute("data-element-id",C),k.disabled=h.readOnly,this._setRequired(k,this.data.required),k.type="checkbox",k.name=h.fieldName,A&&k.setAttribute("checked",!0),k.setAttribute("exportValue",h.exportValue),k.tabIndex=M,k.addEventListener("change",B=>{const{name:D,checked:g}=B.target;for(const L of this._getElementsByName(D,C)){const At=g&&L.exportValue===h.exportValue;L.domElement&&(L.domElement.checked=At),s.setValue(L.id,{value:At})}s.setValue(C,{value:g})}),k.addEventListener("resetform",B=>{const D=h.defaultFieldValue||"Off";B.target.checked=D===h.exportValue}),this.enableScripting&&this.hasJSActions&&(k.addEventListener("updatefromsandbox",B=>{const D={value(g){g.target.checked=g.detail.value!=="Off",s.setValue(C,{value:g.target.checked})}};this._dispatchEventFromSandbox(D,B)}),this._setEventListeners(k,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],B=>B.target.checked)),this._setBackgroundColor(k),this._setDefaultPropertiesFromJS(k),this.container.append(k),this.container}}class m extends r{constructor(s){super(s,{isRenderable:s.renderForms})}render(){this.container.className="buttonWidgetAnnotation radioButton";const s=this.annotationStorage,h=this.data,C=h.id;let A=s.getValue(C,{value:h.fieldValue===h.buttonValue}).value;typeof A=="string"&&(A=A!==h.buttonValue,s.setValue(C,{value:A}));const k=document.createElement("input");if(w.add(k),k.setAttribute("data-element-id",C),k.disabled=h.readOnly,this._setRequired(k,this.data.required),k.type="radio",k.name=h.fieldName,A&&k.setAttribute("checked",!0),k.tabIndex=M,k.addEventListener("change",B=>{const{name:D,checked:g}=B.target;for(const L of this._getElementsByName(D,C))s.setValue(L.id,{value:!1});s.setValue(C,{value:g})}),k.addEventListener("resetform",B=>{const D=h.defaultFieldValue;B.target.checked=D!=null&&D===h.buttonValue}),this.enableScripting&&this.hasJSActions){const B=h.buttonValue;k.addEventListener("updatefromsandbox",D=>{const g={value:L=>{const At=B===L.detail.value;for(const H of this._getElementsByName(L.target.name)){const Q=At&&H.id===C;H.domElement&&(H.domElement.checked=Q),s.setValue(H.id,{value:Q})}}};this._dispatchEventFromSandbox(g,D)}),this._setEventListeners(k,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],D=>D.target.checked)}return this._setBackgroundColor(k),this._setDefaultPropertiesFromJS(k),this.container.append(k),this.container}}class l extends c{constructor(s){super(s,{ignoreBorder:s.data.hasAppearance})}render(){const s=super.render();s.className="buttonWidgetAnnotation pushButton",this.data.alternativeText&&(s.title=this.data.alternativeText);const h=s.lastChild;return this.enableScripting&&this.hasJSActions&&h&&(this._setDefaultPropertiesFromJS(h),h.addEventListener("updatefromsandbox",C=>{this._dispatchEventFromSandbox({},C)})),s}}class n extends r{constructor(s){super(s,{isRenderable:s.renderForms})}render(){this.container.className="choiceWidgetAnnotation";const s=this.annotationStorage,h=this.data.id,C=s.getValue(h,{value:this.data.fieldValue}),A=document.createElement("select");w.add(A),A.setAttribute("data-element-id",h),A.disabled=this.data.readOnly,this._setRequired(A,this.data.required),A.name=this.data.fieldName,A.tabIndex=M;let k=this.data.combo&&this.data.options.length>0;this.data.combo||(A.size=this.data.options.length,this.data.multiSelect&&(A.multiple=!0)),A.addEventListener("resetform",L=>{const At=this.data.defaultFieldValue;for(const H of A.options)H.selected=H.value===At});for(const L of this.data.options){const At=document.createElement("option");At.textContent=L.displayValue,At.value=L.exportValue,C.value.includes(L.exportValue)&&(At.setAttribute("selected",!0),k=!1),A.append(At)}let B=null;if(k){const L=document.createElement("option");L.value=" ",L.setAttribute("hidden",!0),L.setAttribute("selected",!0),A.prepend(L),B=()=>{L.remove(),A.removeEventListener("input",B),B=null},A.addEventListener("input",B)}const D=(L,At)=>{const H=At?"value":"textContent",Q=L.target.options;return L.target.multiple?Array.prototype.filter.call(Q,Ct=>Ct.selected).map(Ct=>Ct[H]):Q.selectedIndex===-1?null:Q[Q.selectedIndex][H]},g=L=>{const At=L.target.options;return Array.prototype.map.call(At,H=>({displayValue:H.textContent,exportValue:H.value}))};return this.enableScripting&&this.hasJSActions?(A.addEventListener("updatefromsandbox",L=>{const At={value(H){B==null||B();const Q=H.detail.value,Ct=new Set(Array.isArray(Q)?Q:[Q]);for(const Tt of A.options)Tt.selected=Ct.has(Tt.value);s.setValue(h,{value:D(H,!0)})},multipleSelection(H){A.multiple=!0},remove(H){const Q=A.options,Ct=H.detail.remove;Q[Ct].selected=!1,A.remove(Ct),Q.length>0&&Array.prototype.findIndex.call(Q,It=>It.selected)===-1&&(Q[0].selected=!0),s.setValue(h,{value:D(H,!0),items:g(H)})},clear(H){for(;A.length!==0;)A.remove(0);s.setValue(h,{value:null,items:[]})},insert(H){const{index:Q,displayValue:Ct,exportValue:Tt}=H.detail.insert,It=A.children[Q],kt=document.createElement("option");kt.textContent=Ct,kt.value=Tt,It?It.before(kt):A.append(kt),s.setValue(h,{value:D(H,!0),items:g(H)})},items(H){const{items:Q}=H.detail;for(;A.length!==0;)A.remove(0);for(const Ct of Q){const{displayValue:Tt,exportValue:It}=Ct,kt=document.createElement("option");kt.textContent=Tt,kt.value=It,A.append(kt)}A.options.length>0&&(A.options[0].selected=!0),s.setValue(h,{value:D(H,!0),items:g(H)})},indices(H){const Q=new Set(H.detail.indices);for(const Ct of H.target.options)Ct.selected=Q.has(Ct.index);s.setValue(h,{value:D(H,!0)})},editable(H){H.target.disabled=!H.detail.editable}};this._dispatchEventFromSandbox(At,L)}),A.addEventListener("input",L=>{var Q;const At=D(L,!0),H=D(L,!1);s.setValue(h,{value:At}),(Q=this.linkService.eventBus)==null||Q.dispatch("dispatcheventinsandbox",{source:this,detail:{id:h,name:"Keystroke",value:H,changeEx:At,willCommit:!0,commitKey:1,keyDown:!1}})}),this._setEventListeners(A,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"]],L=>L.target.checked)):A.addEventListener("input",function(L){s.setValue(h,{value:D(L,!0)})}),this.data.combo&&this._setTextStyle(A),this._setBackgroundColor(A),this._setDefaultPropertiesFromJS(A),this.container.append(A),this.container}}class i extends v{constructor(s){var C,A,k;const h=!!((C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h})}render(){const s=["Line","Square","Circle","PolyLine","Polygon","Ink"];if(this.container.className="popupAnnotation",s.includes(this.data.parentType))return this.container;const h=`[data-annotation-id="${this.data.parentId}"]`,C=this.layer.querySelectorAll(h);if(C.length===0)return this.container;const A=new e({container:this.container,trigger:Array.from(C),color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText}),k=this.page,B=f.Util.normalizeRect([this.data.parentRect[0],k.view[3]-this.data.parentRect[1]+k.view[1],this.data.parentRect[2],k.view[3]-this.data.parentRect[3]+k.view[1]]),D=B[0]+this.data.parentRect[2]-this.data.parentRect[0],g=B[1],[L,At,H,Q]=this.viewport.viewBox,Ct=H-L,Tt=Q-At;return this.container.style.left=`${100*(D-L)/Ct}%`,this.container.style.top=`${100*(g-At)/Tt}%`,this.container.append(A.render()),this.container}}class e{constructor(s){this.container=s.container,this.trigger=s.trigger,this.color=s.color,this.titleObj=s.titleObj,this.modificationDate=s.modificationDate,this.contentsObj=s.contentsObj,this.richText=s.richText,this.hideWrapper=s.hideWrapper||!1,this.pinned=!1}render(){var D,g;const h=document.createElement("div");h.className="popupWrapper",this.hideElement=this.hideWrapper?h:this.container,this.hideElement.hidden=!0;const C=document.createElement("div");C.className="popup";const A=this.color;if(A){const L=.7*(255-A[0])+A[0],At=.7*(255-A[1])+A[1],H=.7*(255-A[2])+A[2];C.style.backgroundColor=f.Util.makeHexColor(L|0,At|0,H|0)}const k=document.createElement("h1");k.dir=this.titleObj.dir,k.textContent=this.titleObj.str,C.append(k);const B=_.PDFDateString.toDateObject(this.modificationDate);if(B){const L=document.createElement("span");L.className="popupDate",L.textContent="{{date}}, {{time}}",L.dataset.l10nId="annotation_date_string",L.dataset.l10nArgs=JSON.stringify({date:B.toLocaleDateString(),time:B.toLocaleTimeString()}),C.append(L)}if((D=this.richText)!=null&&D.str&&(!((g=this.contentsObj)!=null&&g.str)||this.contentsObj.str===this.richText.str))K.XfaLayer.render({xfaHtml:this.richText.html,intent:"richText",div:C}),C.lastChild.className="richText popupContent";else{const L=this._formatContents(this.contentsObj);C.append(L)}Array.isArray(this.trigger)||(this.trigger=[this.trigger]);for(const L of this.trigger)L.addEventListener("click",this._toggle.bind(this)),L.addEventListener("mouseover",this._show.bind(this,!1)),L.addEventListener("mouseout",this._hide.bind(this,!1));return C.addEventListener("click",this._hide.bind(this,!0)),h.append(C),h}_formatContents({str:s,dir:h}){const C=document.createElement("p");C.className="popupContent",C.dir=h;const A=s.split(/(?:\r\n?|\n)/);for(let k=0,B=A.length;k<B;++k){const D=A[k];C.append(document.createTextNode(D)),k<B-1&&C.append(document.createElement("br"))}return C}_toggle(){this.pinned?this._hide(!0):this._show(!0)}_show(s=!1){s&&(this.pinned=!0),this.hideElement.hidden&&(this.hideElement.hidden=!1,this.container.style.zIndex=parseInt(this.container.style.zIndex)+1e3)}_hide(s=!0){s&&(this.pinned=!1),!this.hideElement.hidden&&!this.pinned&&(this.hideElement.hidden=!0,this.container.style.zIndex=parseInt(this.container.style.zIndex)-1e3)}}class E extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0}),this.textContent=s.data.textContent}render(){if(this.container.className="freeTextAnnotation",this.textContent){const s=document.createElement("div");s.className="annotationTextContent",s.setAttribute("role","comment");for(const h of this.textContent){const C=document.createElement("span");C.textContent=h,s.append(C)}this.container.append(s)}return this.data.hasPopup||this._createPopup(null,this.data),this.container}}class x extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0})}render(){this.container.className="lineAnnotation";const s=this.data,{width:h,height:C}=T(s.rect),A=this.svgFactory.create(h,C,!0),k=this.svgFactory.createElement("svg:line");return k.setAttribute("x1",s.rect[2]-s.lineCoordinates[0]),k.setAttribute("y1",s.rect[3]-s.lineCoordinates[1]),k.setAttribute("x2",s.rect[2]-s.lineCoordinates[2]),k.setAttribute("y2",s.rect[3]-s.lineCoordinates[3]),k.setAttribute("stroke-width",s.borderStyle.width||1),k.setAttribute("stroke","transparent"),k.setAttribute("fill","transparent"),A.append(k),this.container.append(A),this._createPopup(k,s),this.container}}class N extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0})}render(){this.container.className="squareAnnotation";const s=this.data,{width:h,height:C}=T(s.rect),A=this.svgFactory.create(h,C,!0),k=s.borderStyle.width,B=this.svgFactory.createElement("svg:rect");return B.setAttribute("x",k/2),B.setAttribute("y",k/2),B.setAttribute("width",h-k),B.setAttribute("height",C-k),B.setAttribute("stroke-width",k||1),B.setAttribute("stroke","transparent"),B.setAttribute("fill","transparent"),A.append(B),this.container.append(A),this._createPopup(B,s),this.container}}class I extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0})}render(){this.container.className="circleAnnotation";const s=this.data,{width:h,height:C}=T(s.rect),A=this.svgFactory.create(h,C,!0),k=s.borderStyle.width,B=this.svgFactory.createElement("svg:ellipse");return B.setAttribute("cx",h/2),B.setAttribute("cy",C/2),B.setAttribute("rx",h/2-k/2),B.setAttribute("ry",C/2-k/2),B.setAttribute("stroke-width",k||1),B.setAttribute("stroke","transparent"),B.setAttribute("fill","transparent"),A.append(B),this.container.append(A),this._createPopup(B,s),this.container}}class St extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const s=this.data,{width:h,height:C}=T(s.rect),A=this.svgFactory.create(h,C,!0);let k=[];for(const D of s.vertices){const g=D.x-s.rect[0],L=s.rect[3]-D.y;k.push(g+","+L)}k=k.join(" ");const B=this.svgFactory.createElement(this.svgElementName);return B.setAttribute("points",k),B.setAttribute("stroke-width",s.borderStyle.width||1),B.setAttribute("stroke","transparent"),B.setAttribute("fill","transparent"),A.append(B),this.container.append(A),this._createPopup(B,s),this.container}}class Pt extends St{constructor(s){super(s),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class bt extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0})}render(){return this.container.className="caretAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class V extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const s=this.data,{width:h,height:C}=T(s.rect),A=this.svgFactory.create(h,C,!0);for(const k of s.inkLists){let B=[];for(const g of k){const L=g.x-s.rect[0],At=s.rect[3]-g.y;B.push(`${L},${At}`)}B=B.join(" ");const D=this.svgFactory.createElement(this.svgElementName);D.setAttribute("points",B),D.setAttribute("stroke-width",s.borderStyle.width||1),D.setAttribute("stroke","transparent"),D.setAttribute("fill","transparent"),this._createPopup(D,s),A.append(D)}return this.container.append(A),this.container}}class O extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("highlightAnnotation"):(this.container.className="highlightAnnotation",this.container)}}class z extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("underlineAnnotation"):(this.container.className="underlineAnnotation",this.container)}}class G extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("squigglyAnnotation"):(this.container.className="squigglyAnnotation",this.container)}}class _t extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("strikeoutAnnotation"):(this.container.className="strikeoutAnnotation",this.container)}}class wt extends v{constructor(s){var C,A,k;const h=!!(s.data.hasPopup||(C=s.data.titleObj)!=null&&C.str||(A=s.data.contentsObj)!=null&&A.str||(k=s.data.richText)!=null&&k.str);super(s,{isRenderable:h,ignoreBorder:!0})}render(){return this.container.className="stampAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class Ot extends v{constructor(s){var A;super(s,{isRenderable:!0});const{filename:h,content:C}=this.data.file;this.filename=(0,_.getFilenameFromUrl)(h),this.content=C,(A=this.linkService.eventBus)==null||A.dispatch("fileattachmentannotation",{source:this,filename:h,content:C})}render(){var h,C;this.container.className="fileAttachmentAnnotation";const s=document.createElement("div");return s.className="popupTriggerArea",s.addEventListener("dblclick",this._download.bind(this)),!this.data.hasPopup&&((h=this.data.titleObj)!=null&&h.str||(C=this.data.contentsObj)!=null&&C.str||this.data.richText)&&this._createPopup(s,this.data),this.container.append(s),this.container}_download(){var s;(s=this.downloadManager)==null||s.openOrDownloadData(this.container,this.content,this.filename)}}const U=class U{static render(s){var D,g;const{annotations:h,div:C,viewport:A,accessibilityManager:k}=s;Mt(this,d,Sn).call(this,C,A);let B=0;for(const L of h){if(L.annotationType!==f.AnnotationType.POPUP){const{width:H,height:Q}=T(L.rect);if(H<=0||Q<=0)continue}const At=S.create({data:L,layer:C,page:s.page,viewport:A,linkService:s.linkService,downloadManager:s.downloadManager,imageResourcesPath:s.imageResourcesPath||"",renderForms:s.renderForms!==!1,svgFactory:new _.DOMSVGFactory,annotationStorage:s.annotationStorage||new Y.AnnotationStorage,enableScripting:s.enableScripting,hasJSActions:s.hasJSActions,fieldObjects:s.fieldObjects,mouseState:s.mouseState||{isDown:!1}});if(At.isRenderable){const H=At.render();if(L.hidden&&(H.style.visibility="hidden"),Array.isArray(H))for(const Q of H)Q.style.zIndex=B++,Mt(D=U,d,Fn).call(D,Q,L.id,C,k);else H.style.zIndex=B++,At instanceof i?C.prepend(H):Mt(g=U,d,Fn).call(g,H,L.id,C,k)}}Mt(this,d,xn).call(this,C,s.annotationCanvasMap)}static update(s){const{annotationCanvasMap:h,div:C,viewport:A}=s;Mt(this,d,Sn).call(this,C,A),Mt(this,d,xn).call(this,C,h),C.hidden=!1}};d=new WeakSet,Fn=function(s,h,C,A){const k=s.firstChild||s;k.id=`${_.AnnotationPrefix}${h}`,C.append(s),A==null||A.moveElementInDOM(C,s,k,!1)},Sn=function(s,{width:h,height:C,rotation:A}){const{style:k}=s,B=A%180!==0,D=Math.floor(h)+"px",g=Math.floor(C)+"px";k.width=B?g:D,k.height=B?D:g,s.setAttribute("data-main-rotation",A)},xn=function(s,h){if(h){for(const[C,A]of h){const k=s.querySelector(`[data-annotation-id="${C}"]`);if(!k)continue;const{firstChild:B}=k;B?B.nodeName==="CANVAS"?B.replaceWith(A):B.before(A):k.append(A)}h.clear()}},Lt(U,d);let q=U;a.AnnotationLayer=q}),((p,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ColorConverters=void 0;function y(_){return Math.floor(Math.max(0,Math.min(1,_))*255).toString(16).padStart(2,"0")}class f{static CMYK_G([Y,W,K,M]){return["G",1-Math.min(1,.3*Y+.59*K+.11*W+M)]}static G_CMYK([Y]){return["CMYK",0,0,0,1-Y]}static G_RGB([Y]){return["RGB",Y,Y,Y]}static G_HTML([Y]){const W=y(Y);return`#${W}${W}${W}`}static RGB_G([Y,W,K]){return["G",.3*Y+.59*W+.11*K]}static RGB_HTML([Y,W,K]){const M=y(Y),b=y(W),w=y(K);return`#${M}${b}${w}`}static T_HTML(){return"#00000000"}static CMYK_RGB([Y,W,K,M]){return["RGB",1-Math.min(1,Y+M),1-Math.min(1,K+M),1-Math.min(1,W+M)]}static CMYK_HTML(Y){const W=this.CMYK_RGB(Y).slice(1);return this.RGB_HTML(W)}static RGB_CMYK([Y,W,K]){const M=1-Y,b=1-W,w=1-K,T=Math.min(M,b,w);return["CMYK",M,b,w,T]}}a.ColorConverters=f}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.XfaLayer=void 0;var f=y(20);class _{static setupStorage(W,K,M,b,w){const T=b.getValue(K,{value:null});switch(M.name){case"textarea":if(T.value!==null&&(W.textContent=T.value),w==="print")break;W.addEventListener("input",S=>{b.setValue(K,{value:S.target.value})});break;case"input":if(M.attributes.type==="radio"||M.attributes.type==="checkbox"){if(T.value===M.attributes.xfaOn?W.setAttribute("checked",!0):T.value===M.attributes.xfaOff&&W.removeAttribute("checked"),w==="print")break;W.addEventListener("change",S=>{b.setValue(K,{value:S.target.checked?S.target.getAttribute("xfaOn"):S.target.getAttribute("xfaOff")})})}else{if(T.value!==null&&W.setAttribute("value",T.value),w==="print")break;W.addEventListener("input",S=>{b.setValue(K,{value:S.target.value})})}break;case"select":if(T.value!==null)for(const S of M.children)S.attributes.value===T.value&&(S.attributes.selected=!0);W.addEventListener("input",S=>{const v=S.target.options,c=v.selectedIndex===-1?"":v[v.selectedIndex].value;b.setValue(K,{value:c})});break}}static setAttributes({html:W,element:K,storage:M=null,intent:b,linkService:w}){const{attributes:T}=K,S=W instanceof HTMLAnchorElement;T.type==="radio"&&(T.name=`${T.name}-${b}`);for(const[v,c]of Object.entries(T))if(c!=null)switch(v){case"class":c.length&&W.setAttribute(v,c.join(" "));break;case"dataId":break;case"id":W.setAttribute("data-element-id",c);break;case"style":Object.assign(W.style,c);break;case"textContent":W.textContent=c;break;default:(!S||v!=="href"&&v!=="newWindow")&&W.setAttribute(v,c)}S&&w.addLinkAttributes(W,T.href,T.newWindow),M&&T.dataId&&this.setupStorage(W,T.dataId,K,M)}static render(W){var t;const K=W.annotationStorage,M=W.linkService,b=W.xfaHtml,w=W.intent||"display",T=document.createElement(b.name);b.attributes&&this.setAttributes({html:T,element:b,intent:w,linkService:M});const S=[[b,-1,T]],v=W.div;if(v.append(T),W.viewport){const r=`matrix(${W.viewport.transform.join(",")})`;v.style.transform=r}w!=="richText"&&v.setAttribute("class","xfaLayer xfaFont");const c=[];for(;S.length>0;){const[r,o,F]=S.at(-1);if(o+1===r.children.length){S.pop();continue}const m=r.children[++S.at(-1)[1]];if(m===null)continue;const{name:l}=m;if(l==="#text"){const i=document.createTextNode(m.value);c.push(i),F.append(i);continue}let n;if((t=m==null?void 0:m.attributes)!=null&&t.xmlns?n=document.createElementNS(m.attributes.xmlns,l):n=document.createElement(l),F.append(n),m.attributes&&this.setAttributes({html:n,element:m,storage:K,intent:w,linkService:M}),m.children&&m.children.length>0)S.push([m,-1,n]);else if(m.value){const i=document.createTextNode(m.value);f.XfaText.shouldBuildText(l)&&c.push(i),n.append(i)}}for(const r of v.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))r.setAttribute("readOnly",!0);return{textDivs:c}}static update(W){const K=`matrix(${W.viewport.transform.join(",")})`;W.div.style.transform=K,W.div.hidden=!1}}a.XfaLayer=_}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.TextLayerRenderTask=void 0,a.renderTextLayer=F;var f=y(1),_=y(8);const Y=1e5,W=30,K=.8,M=new Map,b=/^\s+$/g;function w(m,l){const n=M.get(m);if(n)return n;l.save(),l.font=`${W}px ${m}`;const i=l.measureText("");let e=i.fontBoundingBoxAscent,E=Math.abs(i.fontBoundingBoxDescent);if(e){l.restore();const N=e/(e+E);return M.set(m,N),N}l.strokeStyle="red",l.clearRect(0,0,W,W),l.strokeText("g",0,0);let x=l.getImageData(0,0,W,W).data;E=0;for(let N=x.length-1-3;N>=0;N-=4)if(x[N]>0){E=Math.ceil(N/4/W);break}l.clearRect(0,0,W,W),l.strokeText("A",0,W),x=l.getImageData(0,0,W,W).data,e=0;for(let N=0,I=x.length;N<I;N+=4)if(x[N]>0){e=W-Math.floor(N/4/W);break}if(l.restore(),e){const N=e/(e+E);return M.set(m,N),N}return M.set(m,K),K}function T(m,l,n,i){const e=document.createElement("span"),E=m._enhanceTextSelection?{angle:0,canvasWidth:0,hasText:l.str!=="",hasEOL:l.hasEOL,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1,fontSize:0}:{angle:0,canvasWidth:0,hasText:l.str!=="",hasEOL:l.hasEOL,fontSize:0};m._textDivs.push(e);const x=f.Util.transform(m._viewport.transform,l.transform);let N=Math.atan2(x[1],x[0]);const I=n[l.fontName];I.vertical&&(N+=Math.PI/2);const St=Math.hypot(x[2],x[3]),Pt=St*w(I.fontFamily,i);let bt,V;N===0?(bt=x[4],V=x[5]-Pt):(bt=x[4]+Pt*Math.sin(N),V=x[5]-Pt*Math.cos(N)),e.style.left=`${bt}px`,e.style.top=`${V}px`,e.style.fontSize=`${St}px`,e.style.fontFamily=I.fontFamily,E.fontSize=St,e.setAttribute("role","presentation"),e.textContent=l.str,e.dir=l.dir,m._fontInspectorEnabled&&(e.dataset.fontName=l.fontName),N!==0&&(E.angle=N*(180/Math.PI));let O=!1;if(l.str.length>1||m._enhanceTextSelection&&b.test(l.str))O=!0;else if(l.str!==" "&&l.transform[0]!==l.transform[3]){const z=Math.abs(l.transform[0]),G=Math.abs(l.transform[3]);z!==G&&Math.max(z,G)/Math.min(z,G)>1.5&&(O=!0)}if(O&&(I.vertical?E.canvasWidth=l.height*m._viewport.scale:E.canvasWidth=l.width*m._viewport.scale),m._textDivProperties.set(e,E),m._textContentStream&&m._layoutText(e),m._enhanceTextSelection&&E.hasText){let z=1,G=0;N!==0&&(z=Math.cos(N),G=Math.sin(N));const _t=(I.vertical?l.height:l.width)*m._viewport.scale,wt=St;let Ot,q;N!==0?(Ot=[z,G,-G,z,bt,V],q=f.Util.getAxialAlignedBoundingBox([0,0,_t,wt],Ot)):q=[bt,V,bt+_t,V+wt],m._bounds.push({left:q[0],top:q[1],right:q[2],bottom:q[3],div:e,size:[_t,wt],m:Ot})}}function S(m){if(m._canceled)return;const l=m._textDivs,n=m._capability,i=l.length;if(i>Y){m._renderingDone=!0,n.resolve();return}if(!m._textContentStream)for(let e=0;e<i;e++)m._layoutText(l[e]);m._renderingDone=!0,n.resolve()}function v(m,l,n){let i=0;for(let e=0;e<n;e++){const E=m[l++];E>0&&(i=i?Math.min(E,i):E)}return i}function c(m){const l=m._bounds,n=m._viewport,i=t(n.width,n.height,l);for(let e=0;e<i.length;e++){const E=l[e].div,x=m._textDivProperties.get(E);if(x.angle===0){x.paddingLeft=l[e].left-i[e].left,x.paddingTop=l[e].top-i[e].top,x.paddingRight=i[e].right-l[e].right,x.paddingBottom=i[e].bottom-l[e].bottom,m._textDivProperties.set(E,x);continue}const N=i[e],I=l[e],St=I.m,Pt=St[0],bt=St[1],V=[[0,0],[0,I.size[1]],[I.size[0],0],I.size],O=new Float64Array(64);for(let G=0,_t=V.length;G<_t;G++){const wt=f.Util.applyTransform(V[G],St);O[G+0]=Pt&&(N.left-wt[0])/Pt,O[G+4]=bt&&(N.top-wt[1])/bt,O[G+8]=Pt&&(N.right-wt[0])/Pt,O[G+12]=bt&&(N.bottom-wt[1])/bt,O[G+16]=bt&&(N.left-wt[0])/-bt,O[G+20]=Pt&&(N.top-wt[1])/Pt,O[G+24]=bt&&(N.right-wt[0])/-bt,O[G+28]=Pt&&(N.bottom-wt[1])/Pt,O[G+32]=Pt&&(N.left-wt[0])/-Pt,O[G+36]=bt&&(N.top-wt[1])/-bt,O[G+40]=Pt&&(N.right-wt[0])/-Pt,O[G+44]=bt&&(N.bottom-wt[1])/-bt,O[G+48]=bt&&(N.left-wt[0])/bt,O[G+52]=Pt&&(N.top-wt[1])/-Pt,O[G+56]=bt&&(N.right-wt[0])/bt,O[G+60]=Pt&&(N.bottom-wt[1])/-Pt}const z=1+Math.min(Math.abs(Pt),Math.abs(bt));x.paddingLeft=v(O,32,16)/z,x.paddingTop=v(O,48,16)/z,x.paddingRight=v(O,0,16)/z,x.paddingBottom=v(O,16,16)/z,m._textDivProperties.set(E,x)}}function t(m,l,n){const i=n.map(function(E,x){return{x1:E.left,y1:E.top,x2:E.right,y2:E.bottom,index:x,x1New:void 0,x2New:void 0}});r(m,i);const e=new Array(n.length);for(const E of i){const x=E.index;e[x]={left:E.x1New,top:0,right:E.x2New,bottom:0}}n.map(function(E,x){const N=e[x],I=i[x];I.x1=E.top,I.y1=m-N.right,I.x2=E.bottom,I.y2=m-N.left,I.index=x,I.x1New=void 0,I.x2New=void 0}),r(l,i);for(const E of i){const x=E.index;e[x].top=E.x1New,e[x].bottom=E.x2New}return e}function r(m,l){l.sort(function(e,E){return e.x1-E.x1||e.index-E.index});const i=[{start:-1/0,end:1/0,boundary:{x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0}}];for(const e of l){let E=0;for(;E<i.length&&i[E].end<=e.y1;)E++;let x=i.length-1;for(;x>=0&&i[x].start>=e.y2;)x--;let N,I,St,Pt,bt=-1/0;for(St=E;St<=x;St++){N=i[St],I=N.boundary;let z;I.x2>e.x1?z=I.index>e.index?I.x1New:e.x1:I.x2New===void 0?z=(I.x2+e.x1)/2:z=I.x2New,z>bt&&(bt=z)}for(e.x1New=bt,St=E;St<=x;St++)N=i[St],I=N.boundary,I.x2New===void 0?I.x2>e.x1?I.index>e.index&&(I.x2New=I.x2):I.x2New=bt:I.x2New>bt&&(I.x2New=Math.max(bt,I.x2));const V=[];let O=null;for(St=E;St<=x;St++){N=i[St],I=N.boundary;const z=I.x2>e.x2?I:e;O===z?V.at(-1).end=N.end:(V.push({start:N.start,end:N.end,boundary:z}),O=z)}for(i[E].start<e.y1&&(V[0].start=e.y1,V.unshift({start:i[E].start,end:e.y1,boundary:i[E].boundary})),e.y2<i[x].end&&(V.at(-1).end=e.y2,V.push({start:e.y2,end:i[x].end,boundary:i[x].boundary})),St=E;St<=x;St++){if(N=i[St],I=N.boundary,I.x2New!==void 0)continue;let z=!1;for(Pt=E-1;!z&&Pt>=0&&i[Pt].start>=I.y1;Pt--)z=i[Pt].boundary===I;for(Pt=x+1;!z&&Pt<i.length&&i[Pt].end<=I.y2;Pt++)z=i[Pt].boundary===I;for(Pt=0;!z&&Pt<V.length;Pt++)z=V[Pt].boundary===I;z||(I.x2New=bt)}Array.prototype.splice.apply(i,[E,x-E+1,...V])}for(const e of i){const E=e.boundary;E.x2New===void 0&&(E.x2New=Math.max(m,E.x2))}}class o{constructor({textContent:l,textContentStream:n,container:i,viewport:e,textDivs:E,textContentItemsStr:x,enhanceTextSelection:N}){var I;N&&(0,_.deprecated)("The `enhanceTextSelection` functionality will be removed in the future."),this._textContent=l,this._textContentStream=n,this._container=i,this._document=i.ownerDocument,this._viewport=e,this._textDivs=E||[],this._textContentItemsStr=x||[],this._enhanceTextSelection=!!N,this._fontInspectorEnabled=!!((I=globalThis.FontInspector)!=null&&I.enabled),this._reader=null,this._layoutTextLastFontSize=null,this._layoutTextLastFontFamily=null,this._layoutTextCtx=null,this._textDivProperties=new WeakMap,this._renderingDone=!1,this._canceled=!1,this._capability=(0,f.createPromiseCapability)(),this._renderTimer=null,this._bounds=[],this._devicePixelRatio=globalThis.devicePixelRatio||1,this._capability.promise.finally(()=>{this._enhanceTextSelection||(this._textDivProperties=null),this._layoutTextCtx&&(this._layoutTextCtx.canvas.width=0,this._layoutTextCtx.canvas.height=0,this._layoutTextCtx=null)}).catch(()=>{})}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new f.AbortException("TextLayer task cancelled.")).catch(()=>{}),this._reader=null),this._renderTimer!==null&&(clearTimeout(this._renderTimer),this._renderTimer=null),this._capability.reject(new Error("TextLayer task cancelled."))}_processItems(l,n){for(let i=0,e=l.length;i<e;i++){if(l[i].str===void 0){if(l[i].type==="beginMarkedContentProps"||l[i].type==="beginMarkedContent"){const E=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),l[i].id!==null&&this._container.setAttribute("id",`${l[i].id}`),E.append(this._container)}else l[i].type==="endMarkedContent"&&(this._container=this._container.parentNode);continue}this._textContentItemsStr.push(l[i].str),T(this,l[i],n,this._layoutTextCtx)}}_layoutText(l){const n=this._textDivProperties.get(l);let i="";if(n.canvasWidth!==0&&n.hasText){const{fontFamily:e}=l.style,{fontSize:E}=n;(E!==this._layoutTextLastFontSize||e!==this._layoutTextLastFontFamily)&&(this._layoutTextCtx.font=`${E*this._devicePixelRatio}px ${e}`,this._layoutTextLastFontSize=E,this._layoutTextLastFontFamily=e);const{width:x}=this._layoutTextCtx.measureText(l.textContent);if(x>0){const N=this._devicePixelRatio*n.canvasWidth/x;this._enhanceTextSelection&&(n.scale=N),i=`scaleX(${N})`}}if(n.angle!==0&&(i=`rotate(${n.angle}deg) ${i}`),i.length>0&&(this._enhanceTextSelection&&(n.originalTransform=i),l.style.transform=i),n.hasText&&this._container.append(l),n.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation"),this._container.append(e)}}_render(l=0){const n=(0,f.createPromiseCapability)();let i=Object.create(null);const e=this._document.createElement("canvas");if(e.height=e.width=W,this._layoutTextCtx=e.getContext("2d",{alpha:!1}),this._textContent){const E=this._textContent.items,x=this._textContent.styles;this._processItems(E,x),n.resolve()}else if(this._textContentStream){const E=()=>{this._reader.read().then(({value:x,done:N})=>{if(N){n.resolve();return}Object.assign(i,x.styles),this._processItems(x.items,i),E()},n.reject)};this._reader=this._textContentStream.getReader(),E()}else throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');n.promise.then(()=>{i=null,l?this._renderTimer=setTimeout(()=>{S(this),this._renderTimer=null},l):S(this)},this._capability.reject)}expandTextDivs(l=!1){if(!this._enhanceTextSelection||!this._renderingDone)return;this._bounds!==null&&(c(this),this._bounds=null);const n=[],i=[];for(let e=0,E=this._textDivs.length;e<E;e++){const x=this._textDivs[e],N=this._textDivProperties.get(x);N.hasText&&(l?(n.length=0,i.length=0,N.originalTransform&&n.push(N.originalTransform),N.paddingTop>0?(i.push(`${N.paddingTop}px`),n.push(`translateY(${-N.paddingTop}px)`)):i.push(0),N.paddingRight>0?i.push(`${N.paddingRight/N.scale}px`):i.push(0),N.paddingBottom>0?i.push(`${N.paddingBottom}px`):i.push(0),N.paddingLeft>0?(i.push(`${N.paddingLeft/N.scale}px`),n.push(`translateX(${-N.paddingLeft/N.scale}px)`)):i.push(0),x.style.padding=i.join(" "),n.length&&(x.style.transform=n.join(" "))):(x.style.padding=null,x.style.transform=N.originalTransform))}}}a.TextLayerRenderTask=o;function F(m){const l=new o({textContent:m.textContent,textContentStream:m.textContentStream,container:m.container,viewport:m.viewport,textDivs:m.textDivs,textContentItemsStr:m.textContentItemsStr,enhanceTextSelection:m.enhanceTextSelection});return l._render(m.timeout),l}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.SVGGraphics=void 0;var f=y(8),_=y(1),Y=y(3);let W=class{constructor(){(0,_.unreachable)("Not implemented: SVGGraphics")}};a.SVGGraphics=W;{let t=function(n){let i=[];const e=[];for(const E of n){if(E.fn==="save"){i.push({fnId:92,fn:"group",items:[]}),e.push(i),i=i.at(-1).items;continue}E.fn==="restore"?i=e.pop():i.push(E)}return i},r=function(n){if(Number.isInteger(n))return n.toString();const i=n.toFixed(10);let e=i.length-1;if(i[e]!=="0")return i;do e--;while(i[e]==="0");return i.substring(0,i[e]==="."?e:e+1)},o=function(n){if(n[4]===0&&n[5]===0){if(n[1]===0&&n[2]===0)return n[0]===1&&n[3]===1?"":`scale(${r(n[0])} ${r(n[3])})`;if(n[0]===n[3]&&n[1]===-n[2]){const i=Math.acos(n[0])*180/Math.PI;return`rotate(${r(i)})`}}else if(n[0]===1&&n[1]===0&&n[2]===0&&n[3]===1)return`translate(${r(n[4])} ${r(n[5])})`;return`matrix(${r(n[0])} ${r(n[1])} ${r(n[2])} ${r(n[3])} ${r(n[4])} ${r(n[5])})`};const K={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},M="http://www.w3.org/XML/1998/namespace",b="http://www.w3.org/1999/xlink",w=["butt","round","square"],T=["miter","round","bevel"],S=function(n,i="",e=!1){if(URL.createObjectURL&&typeof Blob<"u"&&!e)return URL.createObjectURL(new Blob([n],{type:i}));const E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let x=`data:${i};base64,`;for(let N=0,I=n.length;N<I;N+=3){const St=n[N]&255,Pt=n[N+1]&255,bt=n[N+2]&255,V=St>>2,O=(St&3)<<4|Pt>>4,z=N+1<I?(Pt&15)<<2|bt>>6:64,G=N+2<I?bt&63:64;x+=E[V]+E[O]+E[z]+E[G]}return x},v=(function(){const n=new Uint8Array([137,80,78,71,13,10,26,10]),i=12,e=new Int32Array(256);for(let bt=0;bt<256;bt++){let V=bt;for(let O=0;O<8;O++)V&1?V=3988292384^V>>1&2147483647:V=V>>1&2147483647;e[bt]=V}function E(bt,V,O){let z=-1;for(let G=V;G<O;G++){const _t=(z^bt[G])&255,wt=e[_t];z=z>>>8^wt}return z^-1}function x(bt,V,O,z){let G=z;const _t=V.length;O[G]=_t>>24&255,O[G+1]=_t>>16&255,O[G+2]=_t>>8&255,O[G+3]=_t&255,G+=4,O[G]=bt.charCodeAt(0)&255,O[G+1]=bt.charCodeAt(1)&255,O[G+2]=bt.charCodeAt(2)&255,O[G+3]=bt.charCodeAt(3)&255,G+=4,O.set(V,G),G+=V.length;const wt=E(O,z+4,G);O[G]=wt>>24&255,O[G+1]=wt>>16&255,O[G+2]=wt>>8&255,O[G+3]=wt&255}function N(bt,V,O){let z=1,G=0;for(let _t=V;_t<O;++_t)z=(z+(bt[_t]&255))%65521,G=(G+z)%65521;return G<<16|z}function I(bt){if(!Y.isNodeJS)return St(bt);try{let V;parseInt(process.versions.node)>=8?V=bt:V=Buffer.from(bt);const O=require$$0.deflateSync(V,{level:9});return O instanceof Uint8Array?O:new Uint8Array(O)}catch(V){(0,_.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+V)}return St(bt)}function St(bt){let V=bt.length;const O=65535,z=Math.ceil(V/O),G=new Uint8Array(2+V+z*5+4);let _t=0;G[_t++]=120,G[_t++]=156;let wt=0;for(;V>O;)G[_t++]=0,G[_t++]=255,G[_t++]=255,G[_t++]=0,G[_t++]=0,G.set(bt.subarray(wt,wt+O),_t),_t+=O,wt+=O,V-=O;G[_t++]=1,G[_t++]=V&255,G[_t++]=V>>8&255,G[_t++]=~V&65535&255,G[_t++]=(~V&65535)>>8&255,G.set(bt.subarray(wt),_t),_t+=bt.length-wt;const Ot=N(bt,0,bt.length);return G[_t++]=Ot>>24&255,G[_t++]=Ot>>16&255,G[_t++]=Ot>>8&255,G[_t++]=Ot&255,G}function Pt(bt,V,O,z){const G=bt.width,_t=bt.height;let wt,Ot,q;const d=bt.data;switch(V){case _.ImageKind.GRAYSCALE_1BPP:Ot=0,wt=1,q=G+7>>3;break;case _.ImageKind.RGB_24BPP:Ot=2,wt=8,q=G*3;break;case _.ImageKind.RGBA_32BPP:Ot=6,wt=8,q=G*4;break;default:throw new Error("invalid format")}const u=new Uint8Array((1+q)*_t);let P=0,j=0;for(let A=0;A<_t;++A)u[P++]=0,u.set(d.subarray(j,j+q),P),j+=q,P+=q;if(V===_.ImageKind.GRAYSCALE_1BPP&&z){P=0;for(let A=0;A<_t;A++){P++;for(let k=0;k<q;k++)u[P++]^=255}}const U=new Uint8Array([G>>24&255,G>>16&255,G>>8&255,G&255,_t>>24&255,_t>>16&255,_t>>8&255,_t&255,wt,Ot,0,0,0]),$=I(u),s=n.length+i*3+U.length+$.length,h=new Uint8Array(s);let C=0;return h.set(n,C),C+=n.length,x("IHDR",U,h,C),C+=i+U.length,x("IDATA",$,h,C),C+=i+$.length,x("IEND",new Uint8Array(0),h,C),S(h,"image/png",O)}return function(V,O,z){const G=V.kind===void 0?_.ImageKind.GRAYSCALE_1BPP:V.kind;return Pt(V,G,O,z)}})();class c{constructor(){this.fontSizeScale=1,this.fontWeight=K.fontWeight,this.fontSize=0,this.textMatrix=_.IDENTITY_MATRIX,this.fontMatrix=_.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=_.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=K.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(i,e){this.x=i,this.y=e}}let F=0,m=0,l=0;a.SVGGraphics=W=class{constructor(n,i,e=!1){(0,f.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new f.DOMSVGFactory,this.current=new c,this.transformMatrix=_.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=n,this.objs=i,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!e,this._operatorIdMapping=[];for(const E in _.OPS)this._operatorIdMapping[_.OPS[E]]=E}save(){this.transformStack.push(this.transformMatrix);const n=this.current;this.extraStack.push(n),this.current=n.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(n){this.save(),this.executeOpTree(n),this.restore()}loadDependencies(n){const i=n.fnArray,e=n.argsArray;for(let E=0,x=i.length;E<x;E++)if(i[E]===_.OPS.dependency)for(const N of e[E]){const I=N.startsWith("g_")?this.commonObjs:this.objs,St=new Promise(Pt=>{I.get(N,Pt)});this.current.dependencies.push(St)}return Promise.all(this.current.dependencies)}transform(n,i,e,E,x,N){const I=[n,i,e,E,x,N];this.transformMatrix=_.Util.transform(this.transformMatrix,I),this.tgrp=null}getSVG(n,i){this.viewport=i;const e=this._initialize(i);return this.loadDependencies(n).then(()=>(this.transformMatrix=_.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(n)),e))}convertOpList(n){const i=this._operatorIdMapping,e=n.argsArray,E=n.fnArray,x=[];for(let N=0,I=E.length;N<I;N++){const St=E[N];x.push({fnId:St,fn:i[St],args:e[N]})}return t(x)}executeOpTree(n){for(const i of n){const e=i.fn,E=i.fnId,x=i.args;switch(E|0){case _.OPS.beginText:this.beginText();break;case _.OPS.dependency:break;case _.OPS.setLeading:this.setLeading(x);break;case _.OPS.setLeadingMoveText:this.setLeadingMoveText(x[0],x[1]);break;case _.OPS.setFont:this.setFont(x);break;case _.OPS.showText:this.showText(x[0]);break;case _.OPS.showSpacedText:this.showText(x[0]);break;case _.OPS.endText:this.endText();break;case _.OPS.moveText:this.moveText(x[0],x[1]);break;case _.OPS.setCharSpacing:this.setCharSpacing(x[0]);break;case _.OPS.setWordSpacing:this.setWordSpacing(x[0]);break;case _.OPS.setHScale:this.setHScale(x[0]);break;case _.OPS.setTextMatrix:this.setTextMatrix(x[0],x[1],x[2],x[3],x[4],x[5]);break;case _.OPS.setTextRise:this.setTextRise(x[0]);break;case _.OPS.setTextRenderingMode:this.setTextRenderingMode(x[0]);break;case _.OPS.setLineWidth:this.setLineWidth(x[0]);break;case _.OPS.setLineJoin:this.setLineJoin(x[0]);break;case _.OPS.setLineCap:this.setLineCap(x[0]);break;case _.OPS.setMiterLimit:this.setMiterLimit(x[0]);break;case _.OPS.setFillRGBColor:this.setFillRGBColor(x[0],x[1],x[2]);break;case _.OPS.setStrokeRGBColor:this.setStrokeRGBColor(x[0],x[1],x[2]);break;case _.OPS.setStrokeColorN:this.setStrokeColorN(x);break;case _.OPS.setFillColorN:this.setFillColorN(x);break;case _.OPS.shadingFill:this.shadingFill(x[0]);break;case _.OPS.setDash:this.setDash(x[0],x[1]);break;case _.OPS.setRenderingIntent:this.setRenderingIntent(x[0]);break;case _.OPS.setFlatness:this.setFlatness(x[0]);break;case _.OPS.setGState:this.setGState(x[0]);break;case _.OPS.fill:this.fill();break;case _.OPS.eoFill:this.eoFill();break;case _.OPS.stroke:this.stroke();break;case _.OPS.fillStroke:this.fillStroke();break;case _.OPS.eoFillStroke:this.eoFillStroke();break;case _.OPS.clip:this.clip("nonzero");break;case _.OPS.eoClip:this.clip("evenodd");break;case _.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case _.OPS.paintImageXObject:this.paintImageXObject(x[0]);break;case _.OPS.paintInlineImageXObject:this.paintInlineImageXObject(x[0]);break;case _.OPS.paintImageMaskXObject:this.paintImageMaskXObject(x[0]);break;case _.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(x[0],x[1]);break;case _.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case _.OPS.closePath:this.closePath();break;case _.OPS.closeStroke:this.closeStroke();break;case _.OPS.closeFillStroke:this.closeFillStroke();break;case _.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case _.OPS.nextLine:this.nextLine();break;case _.OPS.transform:this.transform(x[0],x[1],x[2],x[3],x[4],x[5]);break;case _.OPS.constructPath:this.constructPath(x[0],x[1]);break;case _.OPS.endPath:this.endPath();break;case 92:this.group(i.items);break;default:(0,_.warn)(`Unimplemented operator ${e}`);break}}}setWordSpacing(n){this.current.wordSpacing=n}setCharSpacing(n){this.current.charSpacing=n}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(n,i,e,E,x,N){const I=this.current;I.textMatrix=I.lineMatrix=[n,i,e,E,x,N],I.textMatrixScale=Math.hypot(n,i),I.x=I.lineX=0,I.y=I.lineY=0,I.xcoords=[],I.ycoords=[],I.tspan=this.svgFactory.createElement("svg:tspan"),I.tspan.setAttributeNS(null,"font-family",I.fontFamily),I.tspan.setAttributeNS(null,"font-size",`${r(I.fontSize)}px`),I.tspan.setAttributeNS(null,"y",r(-I.y)),I.txtElement=this.svgFactory.createElement("svg:text"),I.txtElement.append(I.tspan)}beginText(){const n=this.current;n.x=n.lineX=0,n.y=n.lineY=0,n.textMatrix=_.IDENTITY_MATRIX,n.lineMatrix=_.IDENTITY_MATRIX,n.textMatrixScale=1,n.tspan=this.svgFactory.createElement("svg:tspan"),n.txtElement=this.svgFactory.createElement("svg:text"),n.txtgrp=this.svgFactory.createElement("svg:g"),n.xcoords=[],n.ycoords=[]}moveText(n,i){const e=this.current;e.x=e.lineX+=n,e.y=e.lineY+=i,e.xcoords=[],e.ycoords=[],e.tspan=this.svgFactory.createElement("svg:tspan"),e.tspan.setAttributeNS(null,"font-family",e.fontFamily),e.tspan.setAttributeNS(null,"font-size",`${r(e.fontSize)}px`),e.tspan.setAttributeNS(null,"y",r(-e.y))}showText(n){const i=this.current,e=i.font,E=i.fontSize;if(E===0)return;const x=i.fontSizeScale,N=i.charSpacing,I=i.wordSpacing,St=i.fontDirection,Pt=i.textHScale*St,bt=e.vertical,V=bt?1:-1,O=e.defaultVMetrics,z=E*i.fontMatrix[0];let G=0;for(const Ot of n){if(Ot===null){G+=St*I;continue}else if(typeof Ot=="number"){G+=V*Ot*E/1e3;continue}const q=(Ot.isSpace?I:0)+N,d=Ot.fontChar;let u,P,j=Ot.width;if(bt){let $;const s=Ot.vmetric||O;$=Ot.vmetric?s[1]:j*.5,$=-$*z;const h=s[2]*z;j=s?-s[0]:j,u=$/x,P=(G+h)/x}else u=G/x,P=0;(Ot.isInFont||e.missingFile)&&(i.xcoords.push(i.x+u),bt&&i.ycoords.push(-i.y+P),i.tspan.textContent+=d);let U;bt?U=j*z-q*St:U=j*z+q*St,G+=U}i.tspan.setAttributeNS(null,"x",i.xcoords.map(r).join(" ")),bt?i.tspan.setAttributeNS(null,"y",i.ycoords.map(r).join(" ")):i.tspan.setAttributeNS(null,"y",r(-i.y)),bt?i.y-=G:i.x+=G*Pt,i.tspan.setAttributeNS(null,"font-family",i.fontFamily),i.tspan.setAttributeNS(null,"font-size",`${r(i.fontSize)}px`),i.fontStyle!==K.fontStyle&&i.tspan.setAttributeNS(null,"font-style",i.fontStyle),i.fontWeight!==K.fontWeight&&i.tspan.setAttributeNS(null,"font-weight",i.fontWeight);const _t=i.textRenderingMode&_.TextRenderingMode.FILL_STROKE_MASK;if(_t===_.TextRenderingMode.FILL||_t===_.TextRenderingMode.FILL_STROKE?(i.fillColor!==K.fillColor&&i.tspan.setAttributeNS(null,"fill",i.fillColor),i.fillAlpha<1&&i.tspan.setAttributeNS(null,"fill-opacity",i.fillAlpha)):i.textRenderingMode===_.TextRenderingMode.ADD_TO_PATH?i.tspan.setAttributeNS(null,"fill","transparent"):i.tspan.setAttributeNS(null,"fill","none"),_t===_.TextRenderingMode.STROKE||_t===_.TextRenderingMode.FILL_STROKE){const Ot=1/(i.textMatrixScale||1);this._setStrokeAttributes(i.tspan,Ot)}let wt=i.textMatrix;i.textRise!==0&&(wt=wt.slice(),wt[5]+=i.textRise),i.txtElement.setAttributeNS(null,"transform",`${o(wt)} scale(${r(Pt)}, -1)`),i.txtElement.setAttributeNS(M,"xml:space","preserve"),i.txtElement.append(i.tspan),i.txtgrp.append(i.txtElement),this._ensureTransformGroup().append(i.txtElement)}setLeadingMoveText(n,i){this.setLeading(-i),this.moveText(n,i)}addFontStyle(n){if(!n.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.append(this.cssStyle));const i=S(n.data,n.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${n.loadedName}"; src: url(${i}); }
|
|
42
|
+
`}setFont(n){const i=this.current,e=this.commonObjs.get(n[0]);let E=n[1];i.font=e,this.embedFonts&&!e.missingFile&&!this.embeddedFonts[e.loadedName]&&(this.addFontStyle(e),this.embeddedFonts[e.loadedName]=e),i.fontMatrix=e.fontMatrix||_.FONT_IDENTITY_MATRIX;let x="normal";e.black?x="900":e.bold&&(x="bold");const N=e.italic?"italic":"normal";E<0?(E=-E,i.fontDirection=-1):i.fontDirection=1,i.fontSize=E,i.fontFamily=e.loadedName,i.fontWeight=x,i.fontStyle=N,i.tspan=this.svgFactory.createElement("svg:tspan"),i.tspan.setAttributeNS(null,"y",r(-i.y)),i.xcoords=[],i.ycoords=[]}endText(){var i;const n=this.current;n.textRenderingMode&_.TextRenderingMode.ADD_TO_PATH_FLAG&&((i=n.txtElement)!=null&&i.hasChildNodes())&&(n.element=n.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(n){n>0&&(this.current.lineWidth=n)}setLineCap(n){this.current.lineCap=w[n]}setLineJoin(n){this.current.lineJoin=T[n]}setMiterLimit(n){this.current.miterLimit=n}setStrokeAlpha(n){this.current.strokeAlpha=n}setStrokeRGBColor(n,i,e){this.current.strokeColor=_.Util.makeHexColor(n,i,e)}setFillAlpha(n){this.current.fillAlpha=n}setFillRGBColor(n,i,e){this.current.fillColor=_.Util.makeHexColor(n,i,e),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(n){this.current.strokeColor=this._makeColorN_Pattern(n)}setFillColorN(n){this.current.fillColor=this._makeColorN_Pattern(n)}shadingFill(n){const i=this.viewport.width,e=this.viewport.height,E=_.Util.inverseTransform(this.transformMatrix),x=_.Util.applyTransform([0,0],E),N=_.Util.applyTransform([0,e],E),I=_.Util.applyTransform([i,0],E),St=_.Util.applyTransform([i,e],E),Pt=Math.min(x[0],N[0],I[0],St[0]),bt=Math.min(x[1],N[1],I[1],St[1]),V=Math.max(x[0],N[0],I[0],St[0]),O=Math.max(x[1],N[1],I[1],St[1]),z=this.svgFactory.createElement("svg:rect");z.setAttributeNS(null,"x",Pt),z.setAttributeNS(null,"y",bt),z.setAttributeNS(null,"width",V-Pt),z.setAttributeNS(null,"height",O-bt),z.setAttributeNS(null,"fill",this._makeShadingPattern(n)),this.current.fillAlpha<1&&z.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(z)}_makeColorN_Pattern(n){return n[0]==="TilingPattern"?this._makeTilingPattern(n):this._makeShadingPattern(n)}_makeTilingPattern(n){const i=n[1],e=n[2],E=n[3]||_.IDENTITY_MATRIX,[x,N,I,St]=n[4],Pt=n[5],bt=n[6],V=n[7],O=`shading${l++}`,[z,G,_t,wt]=_.Util.normalizeRect([..._.Util.applyTransform([x,N],E),..._.Util.applyTransform([I,St],E)]),[Ot,q]=_.Util.singularValueDecompose2dScale(E),d=Pt*Ot,u=bt*q,P=this.svgFactory.createElement("svg:pattern");P.setAttributeNS(null,"id",O),P.setAttributeNS(null,"patternUnits","userSpaceOnUse"),P.setAttributeNS(null,"width",d),P.setAttributeNS(null,"height",u),P.setAttributeNS(null,"x",`${z}`),P.setAttributeNS(null,"y",`${G}`);const j=this.svg,U=this.transformMatrix,$=this.current.fillColor,s=this.current.strokeColor,h=this.svgFactory.create(_t-z,wt-G);if(this.svg=h,this.transformMatrix=E,V===2){const C=_.Util.makeHexColor(...i);this.current.fillColor=C,this.current.strokeColor=C}return this.executeOpTree(this.convertOpList(e)),this.svg=j,this.transformMatrix=U,this.current.fillColor=$,this.current.strokeColor=s,P.append(h.childNodes[0]),this.defs.append(P),`url(#${O})`}_makeShadingPattern(n){switch(typeof n=="string"&&(n=this.objs.get(n)),n[0]){case"RadialAxial":const i=`shading${l++}`,e=n[3];let E;switch(n[1]){case"axial":const x=n[4],N=n[5];E=this.svgFactory.createElement("svg:linearGradient"),E.setAttributeNS(null,"id",i),E.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),E.setAttributeNS(null,"x1",x[0]),E.setAttributeNS(null,"y1",x[1]),E.setAttributeNS(null,"x2",N[0]),E.setAttributeNS(null,"y2",N[1]);break;case"radial":const I=n[4],St=n[5],Pt=n[6],bt=n[7];E=this.svgFactory.createElement("svg:radialGradient"),E.setAttributeNS(null,"id",i),E.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),E.setAttributeNS(null,"cx",St[0]),E.setAttributeNS(null,"cy",St[1]),E.setAttributeNS(null,"r",bt),E.setAttributeNS(null,"fx",I[0]),E.setAttributeNS(null,"fy",I[1]),E.setAttributeNS(null,"fr",Pt);break;default:throw new Error(`Unknown RadialAxial type: ${n[1]}`)}for(const x of e){const N=this.svgFactory.createElement("svg:stop");N.setAttributeNS(null,"offset",x[0]),N.setAttributeNS(null,"stop-color",x[1]),E.append(N)}return this.defs.append(E),`url(#${i})`;case"Mesh":return(0,_.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${n[0]}`)}}setDash(n,i){this.current.dashArray=n,this.current.dashPhase=i}constructPath(n,i){const e=this.current;let E=e.x,x=e.y,N=[],I=0;for(const St of n)switch(St|0){case _.OPS.rectangle:E=i[I++],x=i[I++];const Pt=i[I++],bt=i[I++],V=E+Pt,O=x+bt;N.push("M",r(E),r(x),"L",r(V),r(x),"L",r(V),r(O),"L",r(E),r(O),"Z");break;case _.OPS.moveTo:E=i[I++],x=i[I++],N.push("M",r(E),r(x));break;case _.OPS.lineTo:E=i[I++],x=i[I++],N.push("L",r(E),r(x));break;case _.OPS.curveTo:E=i[I+4],x=i[I+5],N.push("C",r(i[I]),r(i[I+1]),r(i[I+2]),r(i[I+3]),r(E),r(x)),I+=6;break;case _.OPS.curveTo2:N.push("C",r(E),r(x),r(i[I]),r(i[I+1]),r(i[I+2]),r(i[I+3])),E=i[I+2],x=i[I+3],I+=4;break;case _.OPS.curveTo3:E=i[I+2],x=i[I+3],N.push("C",r(i[I]),r(i[I+1]),r(E),r(x),r(E),r(x)),I+=4;break;case _.OPS.closePath:N.push("Z");break}N=N.join(" "),e.path&&n.length>0&&n[0]!==_.OPS.rectangle&&n[0]!==_.OPS.moveTo?N=e.path.getAttributeNS(null,"d")+N:(e.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(e.path)),e.path.setAttributeNS(null,"d",N),e.path.setAttributeNS(null,"fill","none"),e.element=e.path,e.setCurrentPoint(E,x)}endPath(){const n=this.current;if(n.path=null,!this.pendingClip)return;if(!n.element){this.pendingClip=null;return}const i=`clippath${F++}`,e=this.svgFactory.createElement("svg:clipPath");e.setAttributeNS(null,"id",i),e.setAttributeNS(null,"transform",o(this.transformMatrix));const E=n.element.cloneNode(!0);if(this.pendingClip==="evenodd"?E.setAttributeNS(null,"clip-rule","evenodd"):E.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,e.append(E),this.defs.append(e),n.activeClipUrl){n.clipGroup=null;for(const x of this.extraStack)x.clipGroup=null;e.setAttributeNS(null,"clip-path",n.activeClipUrl)}n.activeClipUrl=`url(#${i})`,this.tgrp=null}clip(n){this.pendingClip=n}closePath(){const n=this.current;if(n.path){const i=`${n.path.getAttributeNS(null,"d")}Z`;n.path.setAttributeNS(null,"d",i)}}setLeading(n){this.current.leading=-n}setTextRise(n){this.current.textRise=n}setTextRenderingMode(n){this.current.textRenderingMode=n}setHScale(n){this.current.textHScale=n/100}setRenderingIntent(n){}setFlatness(n){}setGState(n){for(const[i,e]of n)switch(i){case"LW":this.setLineWidth(e);break;case"LC":this.setLineCap(e);break;case"LJ":this.setLineJoin(e);break;case"ML":this.setMiterLimit(e);break;case"D":this.setDash(e[0],e[1]);break;case"RI":this.setRenderingIntent(e);break;case"FL":this.setFlatness(e);break;case"Font":this.setFont(e);break;case"CA":this.setStrokeAlpha(e);break;case"ca":this.setFillAlpha(e);break;default:(0,_.warn)(`Unimplemented graphic state operator ${i}`);break}}fill(){const n=this.current;n.element&&(n.element.setAttributeNS(null,"fill",n.fillColor),n.element.setAttributeNS(null,"fill-opacity",n.fillAlpha),this.endPath())}stroke(){const n=this.current;n.element&&(this._setStrokeAttributes(n.element),n.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(n,i=1){const e=this.current;let E=e.dashArray;i!==1&&E.length>0&&(E=E.map(function(x){return i*x})),n.setAttributeNS(null,"stroke",e.strokeColor),n.setAttributeNS(null,"stroke-opacity",e.strokeAlpha),n.setAttributeNS(null,"stroke-miterlimit",r(e.miterLimit)),n.setAttributeNS(null,"stroke-linecap",e.lineCap),n.setAttributeNS(null,"stroke-linejoin",e.lineJoin),n.setAttributeNS(null,"stroke-width",r(i*e.lineWidth)+"px"),n.setAttributeNS(null,"stroke-dasharray",E.map(r).join(" ")),n.setAttributeNS(null,"stroke-dashoffset",r(i*e.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const n=this.svgFactory.createElement("svg:rect");n.setAttributeNS(null,"x","0"),n.setAttributeNS(null,"y","0"),n.setAttributeNS(null,"width","1px"),n.setAttributeNS(null,"height","1px"),n.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(n)}paintImageXObject(n){const i=n.startsWith("g_")?this.commonObjs.get(n):this.objs.get(n);if(!i){(0,_.warn)(`Dependent image with object ID ${n} is not ready yet`);return}this.paintInlineImageXObject(i)}paintInlineImageXObject(n,i){const e=n.width,E=n.height,x=v(n,this.forceDataSchema,!!i),N=this.svgFactory.createElement("svg:rect");N.setAttributeNS(null,"x","0"),N.setAttributeNS(null,"y","0"),N.setAttributeNS(null,"width",r(e)),N.setAttributeNS(null,"height",r(E)),this.current.element=N,this.clip("nonzero");const I=this.svgFactory.createElement("svg:image");I.setAttributeNS(b,"xlink:href",x),I.setAttributeNS(null,"x","0"),I.setAttributeNS(null,"y",r(-E)),I.setAttributeNS(null,"width",r(e)+"px"),I.setAttributeNS(null,"height",r(E)+"px"),I.setAttributeNS(null,"transform",`scale(${r(1/e)} ${r(-1/E)})`),i?i.append(I):this._ensureTransformGroup().append(I)}paintImageMaskXObject(n){const i=this.current,e=n.width,E=n.height,x=i.fillColor;i.maskId=`mask${m++}`;const N=this.svgFactory.createElement("svg:mask");N.setAttributeNS(null,"id",i.maskId);const I=this.svgFactory.createElement("svg:rect");I.setAttributeNS(null,"x","0"),I.setAttributeNS(null,"y","0"),I.setAttributeNS(null,"width",r(e)),I.setAttributeNS(null,"height",r(E)),I.setAttributeNS(null,"fill",x),I.setAttributeNS(null,"mask",`url(#${i.maskId})`),this.defs.append(N),this._ensureTransformGroup().append(I),this.paintInlineImageXObject(n,N)}paintFormXObjectBegin(n,i){if(Array.isArray(n)&&n.length===6&&this.transform(n[0],n[1],n[2],n[3],n[4],n[5]),i){const e=i[2]-i[0],E=i[3]-i[1],x=this.svgFactory.createElement("svg:rect");x.setAttributeNS(null,"x",i[0]),x.setAttributeNS(null,"y",i[1]),x.setAttributeNS(null,"width",r(e)),x.setAttributeNS(null,"height",r(E)),this.current.element=x,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(n){const i=this.svgFactory.create(n.width,n.height),e=this.svgFactory.createElement("svg:defs");i.append(e),this.defs=e;const E=this.svgFactory.createElement("svg:g");return E.setAttributeNS(null,"transform",o(n.transform)),i.append(E),this.svg=E,i}_ensureClipGroup(){if(!this.current.clipGroup){const n=this.svgFactory.createElement("svg:g");n.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(n),this.current.clipGroup=n}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",o(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.PDFNodeStream=void 0;var f=y(1),_=y(33);const Y=require$$0,W=require$$0,K=require$$0,M=require$$0,b=/^file:\/\/\/[a-zA-Z]:\//;function w(m){const l=M.parse(m);return l.protocol==="file:"||l.host?l:/^[a-z]:[/\\]/i.test(m)?M.parse(`file:///${m}`):(l.host||(l.protocol="file:"),l)}class T{constructor(l){this.source=l,this.url=w(l.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&l.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var l;return((l=this._fullRequestReader)==null?void 0:l._loaded)??0}getFullReader(){return(0,f.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new o(this):new t(this),this._fullRequestReader}getRangeReader(l,n){if(n<=this._progressiveDataLength)return null;const i=this.isFsUrl?new F(this,l,n):new r(this,l,n);return this._rangeRequestReaders.push(i),i}cancelAllRequests(l){this._fullRequestReader&&this._fullRequestReader.cancel(l);for(const n of this._rangeRequestReaders.slice(0))n.cancel(l)}}a.PDFNodeStream=T;class S{constructor(l){this._url=l.url,this._done=!1,this._storedError=null,this.onProgress=null;const n=l.source;this._contentLength=n.length,this._loaded=0,this._filename=null,this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange,this._readableStream=null,this._readCapability=(0,f.createPromiseCapability)(),this._headersCapability=(0,f.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const l=this._readableStream.read();return l===null?(this._readCapability=(0,f.createPromiseCapability)(),this.read()):(this._loaded+=l.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(l).buffer,done:!1})}cancel(l){if(!this._readableStream){this._error(l);return}this._readableStream.destroy(l)}_error(l){this._storedError=l,this._readCapability.resolve()}_setReadableStream(l){this._readableStream=l,l.on("readable",()=>{this._readCapability.resolve()}),l.on("end",()=>{l.destroy(),this._done=!0,this._readCapability.resolve()}),l.on("error",n=>{this._error(n)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new f.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class v{constructor(l){this._url=l.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,f.createPromiseCapability)();const n=l.source;this._isStreamingSupported=!n.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const l=this._readableStream.read();return l===null?(this._readCapability=(0,f.createPromiseCapability)(),this.read()):(this._loaded+=l.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(l).buffer,done:!1})}cancel(l){if(!this._readableStream){this._error(l);return}this._readableStream.destroy(l)}_error(l){this._storedError=l,this._readCapability.resolve()}_setReadableStream(l){this._readableStream=l,l.on("readable",()=>{this._readCapability.resolve()}),l.on("end",()=>{l.destroy(),this._done=!0,this._readCapability.resolve()}),l.on("error",n=>{this._error(n)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function c(m,l){return{protocol:m.protocol,auth:m.auth,host:m.hostname,port:m.port,path:m.path,method:"GET",headers:l}}class t extends S{constructor(l){super(l);const n=i=>{if(i.statusCode===404){const N=new f.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=N,this._headersCapability.reject(N);return}this._headersCapability.resolve(),this._setReadableStream(i);const e=N=>this._readableStream.headers[N.toLowerCase()],{allowRangeRequests:E,suggestedLength:x}=(0,_.validateRangeRequestCapabilities)({getResponseHeader:e,isHttp:l.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=E,this._contentLength=x||this._contentLength,this._filename=(0,_.extractFilenameFromHeader)(e)};this._request=null,this._url.protocol==="http:"?this._request=W.request(c(this._url,l.httpHeaders),n):this._request=K.request(c(this._url,l.httpHeaders),n),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class r extends v{constructor(l,n,i){super(l),this._httpHeaders={};for(const E in l.httpHeaders){const x=l.httpHeaders[E];typeof x>"u"||(this._httpHeaders[E]=x)}this._httpHeaders.Range=`bytes=${n}-${i-1}`;const e=E=>{if(E.statusCode===404){const x=new f.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=x;return}this._setReadableStream(E)};this._request=null,this._url.protocol==="http:"?this._request=W.request(c(this._url,this._httpHeaders),e):this._request=K.request(c(this._url,this._httpHeaders),e),this._request.on("error",E=>{this._storedError=E}),this._request.end()}}class o extends S{constructor(l){super(l);let n=decodeURIComponent(this._url.path);b.test(this._url.href)&&(n=n.replace(/^\//,"")),Y.lstat(n,(i,e)=>{if(i){i.code==="ENOENT"&&(i=new f.MissingPDFException(`Missing PDF "${n}".`)),this._storedError=i,this._headersCapability.reject(i);return}this._contentLength=e.size,this._setReadableStream(Y.createReadStream(n)),this._headersCapability.resolve()})}}class F extends v{constructor(l,n,i){super(l);let e=decodeURIComponent(this._url.path);b.test(this._url.href)&&(e=e.replace(/^\//,"")),this._setReadableStream(Y.createReadStream(e,{start:n,end:i-1}))}}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.createResponseStatusError=M,a.extractFilenameFromHeader=K,a.validateRangeRequestCapabilities=W,a.validateResponseStatus=b;var f=y(1),_=y(34),Y=y(8);function W({getResponseHeader:w,isHttp:T,rangeChunkSize:S,disableRange:v}){const c={allowRangeRequests:!1,suggestedLength:void 0},t=parseInt(w("Content-Length"),10);return!Number.isInteger(t)||(c.suggestedLength=t,t<=2*S)||v||!T||w("Accept-Ranges")!=="bytes"||(w("Content-Encoding")||"identity")!=="identity"||(c.allowRangeRequests=!0),c}function K(w){const T=w("Content-Disposition");if(T){let S=(0,_.getFilenameFromContentDispositionHeader)(T);if(S.includes("%"))try{S=decodeURIComponent(S)}catch{}if((0,Y.isPdfFile)(S))return S}return null}function M(w,T){return w===404||w===0&&T.startsWith("file:")?new f.MissingPDFException('Missing PDF "'+T+'".'):new f.UnexpectedResponseException(`Unexpected server response (${w}) while retrieving PDF "${T}".`,w)}function b(w){return w===200||w===206}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getFilenameFromContentDispositionHeader=_;var f=y(1);function _(Y){let W=!0,K=M("filename\\*","i").exec(Y);if(K){K=K[1];let t=S(K);return t=unescape(t),t=v(t),t=c(t),w(t)}if(K=T(Y),K){const t=c(K);return w(t)}if(K=M("filename","i").exec(Y),K){K=K[1];let t=S(K);return t=c(t),w(t)}function M(t,r){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',r)}function b(t,r){if(t){if(!/^[\x00-\xFF]+$/.test(r))return r;try{const o=new TextDecoder(t,{fatal:!0}),F=(0,f.stringToBytes)(r);r=o.decode(F),W=!1}catch{}}return r}function w(t){return W&&/[\x80-\xff]/.test(t)&&(t=b("utf-8",t),W&&(t=b("iso-8859-1",t))),t}function T(t){const r=[];let o;const F=M("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(o=F.exec(t))!==null;){let[,l,n,i]=o;if(l=parseInt(l,10),l in r){if(l===0)break;continue}r[l]=[n,i]}const m=[];for(let l=0;l<r.length&&l in r;++l){let[n,i]=r[l];i=S(i),n&&(i=unescape(i),l===0&&(i=v(i))),m.push(i)}return m.join("")}function S(t){if(t.startsWith('"')){const r=t.slice(1).split('\\"');for(let o=0;o<r.length;++o){const F=r[o].indexOf('"');F!==-1&&(r[o]=r[o].slice(0,F),r.length=o+1),r[o]=r[o].replace(/\\(.)/g,"$1")}t=r.join('"')}return t}function v(t){const r=t.indexOf("'");if(r===-1)return t;const o=t.slice(0,r),m=t.slice(r+1).replace(/^[^']*'/,"");return b(o,m)}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(r,o,F,m){if(F==="q"||F==="Q")return m=m.replace(/_/g," "),m=m.replace(/=([0-9a-fA-F]{2})/g,function(l,n){return String.fromCharCode(parseInt(n,16))}),b(o,m);try{m=atob(m)}catch{}return b(o,m)})}return""}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.PDFNetworkStream=void 0;var f=y(1),_=y(33);const Y=200,W=206;function K(S){const v=S.response;return typeof v!="string"?v:(0,f.stringToBytes)(v).buffer}class M{constructor(v,c={}){this.url=v,this.isHttp=/^https?:/i.test(v),this.httpHeaders=this.isHttp&&c.httpHeaders||Object.create(null),this.withCredentials=c.withCredentials||!1,this.getXhr=c.getXhr||function(){return new XMLHttpRequest},this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(v,c,t){const r={begin:v,end:c};for(const o in t)r[o]=t[o];return this.request(r)}requestFull(v){return this.request(v)}request(v){const c=this.getXhr(),t=this.currXhrId++,r=this.pendingRequests[t]={xhr:c};c.open("GET",this.url),c.withCredentials=this.withCredentials;for(const o in this.httpHeaders){const F=this.httpHeaders[o];typeof F>"u"||c.setRequestHeader(o,F)}return this.isHttp&&"begin"in v&&"end"in v?(c.setRequestHeader("Range",`bytes=${v.begin}-${v.end-1}`),r.expectedStatus=W):r.expectedStatus=Y,c.responseType="arraybuffer",v.onError&&(c.onerror=function(o){v.onError(c.status)}),c.onreadystatechange=this.onStateChange.bind(this,t),c.onprogress=this.onProgress.bind(this,t),r.onHeadersReceived=v.onHeadersReceived,r.onDone=v.onDone,r.onError=v.onError,r.onProgress=v.onProgress,c.send(null),t}onProgress(v,c){var r;const t=this.pendingRequests[v];t&&((r=t.onProgress)==null||r.call(t,c))}onStateChange(v,c){var l,n,i;const t=this.pendingRequests[v];if(!t)return;const r=t.xhr;if(r.readyState>=2&&t.onHeadersReceived&&(t.onHeadersReceived(),delete t.onHeadersReceived),r.readyState!==4||!(v in this.pendingRequests))return;if(delete this.pendingRequests[v],r.status===0&&this.isHttp){(l=t.onError)==null||l.call(t,r.status);return}const o=r.status||Y;if(!(o===Y&&t.expectedStatus===W)&&o!==t.expectedStatus){(n=t.onError)==null||n.call(t,r.status);return}const m=K(r);if(o===W){const e=r.getResponseHeader("Content-Range"),E=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t.onDone({begin:parseInt(E[1],10),chunk:m})}else m?t.onDone({begin:0,chunk:m}):(i=t.onError)==null||i.call(t,r.status)}getRequestXhr(v){return this.pendingRequests[v].xhr}isPendingRequest(v){return v in this.pendingRequests}abortRequest(v){const c=this.pendingRequests[v].xhr;delete this.pendingRequests[v],c.abort()}}class b{constructor(v){this._source=v,this._manager=new M(v.url,{httpHeaders:v.httpHeaders,withCredentials:v.withCredentials}),this._rangeChunkSize=v.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(v){const c=this._rangeRequestReaders.indexOf(v);c>=0&&this._rangeRequestReaders.splice(c,1)}getFullReader(){return(0,f.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new w(this._manager,this._source),this._fullRequestReader}getRangeReader(v,c){const t=new T(this._manager,v,c);return t.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(t),t}cancelAllRequests(v){var c;(c=this._fullRequestReader)==null||c.cancel(v);for(const t of this._rangeRequestReaders.slice(0))t.cancel(v)}}a.PDFNetworkStream=b;class w{constructor(v,c){this._manager=v;const t={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=c.url,this._fullRequestId=v.requestFull(t),this._headersReceivedCapability=(0,f.createPromiseCapability)(),this._disableRange=c.disableRange||!1,this._contentLength=c.length,this._rangeChunkSize=c.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const v=this._fullRequestId,c=this._manager.getRequestXhr(v),t=F=>c.getResponseHeader(F),{allowRangeRequests:r,suggestedLength:o}=(0,_.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=(0,_.extractFilenameFromHeader)(t),this._isRangeSupported&&this._manager.abortRequest(v),this._headersReceivedCapability.resolve()}_onDone(v){if(v&&(this._requests.length>0?this._requests.shift().resolve({value:v.chunk,done:!1}):this._cachedChunks.push(v.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const c of this._requests)c.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(v){this._storedError=(0,_.createResponseStatusError)(v,this._url),this._headersReceivedCapability.reject(this._storedError);for(const c of this._requests)c.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(v){var c;(c=this.onProgress)==null||c.call(this,{loaded:v.loaded,total:v.lengthComputable?v.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const v=(0,f.createPromiseCapability)();return this._requests.push(v),v.promise}cancel(v){this._done=!0,this._headersReceivedCapability.reject(v);for(const c of this._requests)c.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class T{constructor(v,c,t){this._manager=v;const r={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=v.url,this._requestId=v.requestRange(c,t,r),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var v;(v=this.onClosed)==null||v.call(this,this)}_onDone(v){const c=v.chunk;this._requests.length>0?this._requests.shift().resolve({value:c,done:!1}):this._queuedChunk=c,this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(v){this._storedError=(0,_.createResponseStatusError)(v,this._url);for(const c of this._requests)c.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(v){var c;this.isStreamingSupported||(c=this.onProgress)==null||c.call(this,{loaded:v.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const c=this._queuedChunk;return this._queuedChunk=null,{value:c,done:!1}}if(this._done)return{value:void 0,done:!0};const v=(0,f.createPromiseCapability)();return this._requests.push(v),v.promise}cancel(v){this._done=!0;for(const c of this._requests)c.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}}),((p,a,y)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.PDFFetchStream=void 0;var f=y(1),_=y(33);function Y(w,T,S){return{method:"GET",headers:w,signal:S.signal,mode:"cors",credentials:T?"include":"same-origin",redirect:"follow"}}function W(w){const T=new Headers;for(const S in w){const v=w[S];typeof v>"u"||T.append(S,v)}return T}class K{constructor(T){this.source=T,this.isHttp=/^https?:/i.test(T.url),this.httpHeaders=this.isHttp&&T.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var T;return((T=this._fullRequestReader)==null?void 0:T._loaded)??0}getFullReader(){return(0,f.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new M(this),this._fullRequestReader}getRangeReader(T,S){if(S<=this._progressiveDataLength)return null;const v=new b(this,T,S);return this._rangeRequestReaders.push(v),v}cancelAllRequests(T){this._fullRequestReader&&this._fullRequestReader.cancel(T);for(const S of this._rangeRequestReaders.slice(0))S.cancel(T)}}a.PDFFetchStream=K;class M{constructor(T){this._stream=T,this._reader=null,this._loaded=0,this._filename=null;const S=T.source;this._withCredentials=S.withCredentials||!1,this._contentLength=S.length,this._headersCapability=(0,f.createPromiseCapability)(),this._disableRange=S.disableRange||!1,this._rangeChunkSize=S.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!S.disableStream,this._isRangeSupported=!S.disableRange,this._headers=W(this._stream.httpHeaders);const v=S.url;fetch(v,Y(this._headers,this._withCredentials,this._abortController)).then(c=>{if(!(0,_.validateResponseStatus)(c.status))throw(0,_.createResponseStatusError)(c.status,v);this._reader=c.body.getReader(),this._headersCapability.resolve();const t=F=>c.headers.get(F),{allowRangeRequests:r,suggestedLength:o}=(0,_.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=o||this._contentLength,this._filename=(0,_.extractFilenameFromHeader)(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new f.AbortException("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:T,done:S}=await this._reader.read();return S?{value:T,done:S}:(this._loaded+=T.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(T).buffer,done:!1})}cancel(T){this._reader&&this._reader.cancel(T),this._abortController.abort()}}class b{constructor(T,S,v){this._stream=T,this._reader=null,this._loaded=0;const c=T.source;this._withCredentials=c.withCredentials||!1,this._readCapability=(0,f.createPromiseCapability)(),this._isStreamingSupported=!c.disableStream,this._abortController=new AbortController,this._headers=W(this._stream.httpHeaders),this._headers.append("Range",`bytes=${S}-${v-1}`);const t=c.url;fetch(t,Y(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!(0,_.validateResponseStatus)(r.status))throw(0,_.createResponseStatusError)(r.status,t);this._readCapability.resolve(),this._reader=r.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:T,done:S}=await this._reader.read();return S?{value:T,done:S}:(this._loaded+=T.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(T).buffer,done:!1})}cancel(T){this._reader&&this._reader.cancel(T),this._abortController.abort()}}})],__webpack_module_cache__={};function __w_pdfjs_require__(p){var a=__webpack_module_cache__[p];if(a!==void 0)return a.exports;var y=__webpack_module_cache__[p]={exports:{}};return __webpack_modules__[p](y,y.exports,__w_pdfjs_require__),y.exports}var __webpack_exports__={};return(()=>{var p=__webpack_exports__;Object.defineProperty(p,"__esModule",{value:!0}),Object.defineProperty(p,"AnnotationEditorLayer",{enumerable:!0,get:function(){return _.AnnotationEditorLayer}}),Object.defineProperty(p,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return a.AnnotationEditorParamsType}}),Object.defineProperty(p,"AnnotationEditorType",{enumerable:!0,get:function(){return a.AnnotationEditorType}}),Object.defineProperty(p,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return Y.AnnotationEditorUIManager}}),Object.defineProperty(p,"AnnotationLayer",{enumerable:!0,get:function(){return W.AnnotationLayer}}),Object.defineProperty(p,"AnnotationMode",{enumerable:!0,get:function(){return a.AnnotationMode}}),Object.defineProperty(p,"CMapCompressionType",{enumerable:!0,get:function(){return a.CMapCompressionType}}),Object.defineProperty(p,"GlobalWorkerOptions",{enumerable:!0,get:function(){return K.GlobalWorkerOptions}}),Object.defineProperty(p,"InvalidPDFException",{enumerable:!0,get:function(){return a.InvalidPDFException}}),Object.defineProperty(p,"LoopbackPort",{enumerable:!0,get:function(){return y.LoopbackPort}}),Object.defineProperty(p,"MissingPDFException",{enumerable:!0,get:function(){return a.MissingPDFException}}),Object.defineProperty(p,"OPS",{enumerable:!0,get:function(){return a.OPS}}),Object.defineProperty(p,"PDFDataRangeTransport",{enumerable:!0,get:function(){return y.PDFDataRangeTransport}}),Object.defineProperty(p,"PDFDateString",{enumerable:!0,get:function(){return f.PDFDateString}}),Object.defineProperty(p,"PDFWorker",{enumerable:!0,get:function(){return y.PDFWorker}}),Object.defineProperty(p,"PasswordResponses",{enumerable:!0,get:function(){return a.PasswordResponses}}),Object.defineProperty(p,"PermissionFlag",{enumerable:!0,get:function(){return a.PermissionFlag}}),Object.defineProperty(p,"PixelsPerInch",{enumerable:!0,get:function(){return f.PixelsPerInch}}),Object.defineProperty(p,"RenderingCancelledException",{enumerable:!0,get:function(){return f.RenderingCancelledException}}),Object.defineProperty(p,"SVGGraphics",{enumerable:!0,get:function(){return w.SVGGraphics}}),Object.defineProperty(p,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return a.UNSUPPORTED_FEATURES}}),Object.defineProperty(p,"UnexpectedResponseException",{enumerable:!0,get:function(){return a.UnexpectedResponseException}}),Object.defineProperty(p,"Util",{enumerable:!0,get:function(){return a.Util}}),Object.defineProperty(p,"VerbosityLevel",{enumerable:!0,get:function(){return a.VerbosityLevel}}),Object.defineProperty(p,"XfaLayer",{enumerable:!0,get:function(){return T.XfaLayer}}),Object.defineProperty(p,"build",{enumerable:!0,get:function(){return y.build}}),Object.defineProperty(p,"createPromiseCapability",{enumerable:!0,get:function(){return a.createPromiseCapability}}),Object.defineProperty(p,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return a.createValidAbsoluteUrl}}),Object.defineProperty(p,"getDocument",{enumerable:!0,get:function(){return y.getDocument}}),Object.defineProperty(p,"getFilenameFromUrl",{enumerable:!0,get:function(){return f.getFilenameFromUrl}}),Object.defineProperty(p,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return f.getPdfFilenameFromUrl}}),Object.defineProperty(p,"getXfaPageViewport",{enumerable:!0,get:function(){return f.getXfaPageViewport}}),Object.defineProperty(p,"isPdfFile",{enumerable:!0,get:function(){return f.isPdfFile}}),Object.defineProperty(p,"loadScript",{enumerable:!0,get:function(){return f.loadScript}}),Object.defineProperty(p,"renderTextLayer",{enumerable:!0,get:function(){return b.renderTextLayer}}),Object.defineProperty(p,"shadow",{enumerable:!0,get:function(){return a.shadow}}),Object.defineProperty(p,"version",{enumerable:!0,get:function(){return y.version}});var a=__w_pdfjs_require__(1),y=__w_pdfjs_require__(4),f=__w_pdfjs_require__(8),_=__w_pdfjs_require__(22),Y=__w_pdfjs_require__(7),W=__w_pdfjs_require__(27),K=__w_pdfjs_require__(15),M=__w_pdfjs_require__(3),b=__w_pdfjs_require__(30),w=__w_pdfjs_require__(31),T=__w_pdfjs_require__(29);if(M.isNodeJS){const{PDFNodeStream:S}=__w_pdfjs_require__(32);(0,y.setPDFNetworkStreamFactory)(v=>new S(v))}else{const{PDFNetworkStream:S}=__w_pdfjs_require__(35),{PDFFetchStream:v}=__w_pdfjs_require__(36);(0,y.setPDFNetworkStreamFactory)(c=>(0,f.isValidFetchUrl)(c.url)?new v(c):new S(c))}})(),__webpack_exports__})())})(pdf)),pdf.exports}var pdfExports=requirePdf();const De="#FFEB3B",Be=()=>`annotation_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,ke=({pageNumber:p,scale:a,isAnnotating:y,annotations:f=[],onAnnotationAdd:_,onAnnotationDelete:Y,readOnly:W=!1})=>{const K=useRef(null),[M,b]=useState(!1),[w,T]=useState({x:0,y:0}),[S,v]=useState(null),[c,t]=useState(null),r=useCallback(l=>{if(!y||!K.current)return;const n=K.current.getBoundingClientRect(),i=(l.clientX-n.left)/n.width,e=(l.clientY-n.top)/n.height;console.log("\u9F20\u6807\u6309\u4E0B\u4F4D\u7F6E:",{clientX:l.clientX,clientY:l.clientY,rect:n,x:i,y:e,scale:a}),b(!0),T({x:i,y:e})},[y,a]),o=useCallback(l=>{if(!M||!K.current)return;const n=K.current.getBoundingClientRect(),i=(l.clientX-n.left)/n.width,e=(l.clientY-n.top)/n.height;v({x:Math.min(w.x,i),y:Math.min(w.y,e),width:Math.abs(i-w.x),height:Math.abs(e-w.y)})},[M,w,a]),F=useCallback(()=>{if(!M||!S)return;if(b(!1),S.width<5||S.height<5){v(null);return}const l={id:Be(),pageNumber:p,...S,content:"",color:De};_==null||_(l),v(null)},[M,S,p,_]),m=useCallback(l=>{t(c===l?null:l)},[c]);return useCallback((l,n)=>{const i={...l,content:n};_==null||_(i)},[_]),useCallback(l=>{Y==null||Y(l),t(null)},[Y]),console.log("\u6807\u6CE8\u7EC4\u4EF6\u6E32\u67D3:",{pageNumber:p,annotations:f.length,currentPageAnnotationsCount:f.filter(l=>l.pageNumber===p).length,currentPageAnnotations:f.filter(l=>l.pageNumber===p)}),React__default.createElement("div",{ref:K,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:10,pointerEvents:"auto"},onMouseDown:r,onMouseMove:o,onMouseUp:F,onMouseLeave:F},S&&React__default.createElement("div",{className:"absolute border-2 border-yellow-400 bg-yellow-100/30",style:{left:`${S.x*100}%`,top:`${S.y*100}%`,width:`${S.width*100}%`,height:`${S.height*100}%`}}),f.filter(l=>l.pageNumber===p).map(l=>(console.log("\u6E32\u67D3\u6807\u6CE8:",l.id,`\u4F4D\u7F6E: ${l.x*100}%, ${l.y*100}%`),React__default.createElement("div",{key:l.id,style:{width:"100%",height:"100%",position:"absolute",top:0,left:0}},React__default.createElement("div",{className:"border border-solid",style:{position:"absolute",left:`${l.x*100}%`,top:`${l.y*100}%`,width:`${l.width*100}%`,height:`${l.height*100}%`,borderWidth:"2px",borderColor:`${l.color}`,backgroundColor:`${l.color}4D`,zIndex:1e3},onClick:()=>m(l.id)})))))},Ae=()=>{try{if(xe())console.log("PDF Worker \u5DF2\u7ECF\u6CE8\u518C:",vt());else{const p="/worker/pdf.worker.min.js";console.log("\u6B63\u5728\u6CE8\u518CPDF Worker\uFF0C\u8DEF\u5F84:",p,"\u73AF\u5883:","\u751F\u4EA7"),yt(p)}}catch(p){console.warn("PDF Worker \u81EA\u52A8\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6CE8\u518C:",p)}};Ae();const $e={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"md",size:"md",radius:"md",padding:"md",margin:"md",shadow:"md",lineHeight:"md"}},Pe=dt$1.div`
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
height: 200px;
|
|
47
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
`,_e=dt$1.div`
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
height: 200px;
|
|
54
|
+
color: ${p=>p.$theme.colors.error};
|
|
55
|
+
font-size: 14px;
|
|
56
|
+
text-align: center;
|
|
57
|
+
`,Te=({pdfDocument:p,currentPage:a,pdfStartPage:y=1,scale:f,annotations:_,isAnnotating:Y,isSlidesMode:W=!1,onPageChange:K,onScaleChange:M,onAnnotationChange:b,onAnnotationDelete:w,styles:T})=>{const[S,v]=useState(!1),[c,t]=useState(null),[r,o]=useState(0),[F,m]=useState(0),[l,n]=useState(!1),[i,e]=useState(!0),E=(T==null?void 0:T.theme)||$e,x=useRef(null),N=useRef(null),I=useRef(!1),St=useRef(null),Pt=useCallback(V=>{if(!N.current||!i||!M)return null;const O=N.current,z=O.offsetWidth-40,G=O.offsetHeight-40,_t=z/V.width,wt=G/V.height,Ot=Math.min(_t,wt,1),q=Math.max(.3,Math.min(1,Ot));return console.log("\u81EA\u52A8\u8BA1\u7B97\u7F29\u653E\u6BD4\u4F8B:",{containerWidth:z,containerHeight:G,viewportWidth:V.width,viewportHeight:V.height,scaleX:_t,scaleY:wt,autoScale:Ot,finalScale:q}),q},[i,M]),bt=useCallback(async()=>{if(!(!p||!x.current)){if(I.current||St.current===a){console.log("\u9875\u9762\u6B63\u5728\u6E32\u67D3\u4E2D\uFF0C\u8DF3\u8FC7");return}try{St.current=a,I.current=!0;const V=a-y+1;if(console.log(`\u8BA1\u7B97\u4E0B\uFF0C\u6E32\u67D3\u9875\u9762: PDF\u8D77\u59CB\u9875\uFF1ApdfStartPage=${y}, \u5168\u5C40\u9875\u7801\uFF1AcurrentPage=${a}, \u76F8\u5BF9\u9875\u7801=${V}`),V<1||V>p.numPages)throw console.error(`\u9875\u7801\u8D85\u51FA\u8303\u56F4: \u76F8\u5BF9\u9875\u7801=${V}, PDF\u603B\u9875\u6570=${p.numPages}`),new Error(`\u9875\u7801\u8D85\u51FA\u8303\u56F4: \u8BF7\u6C42\u7B2C${a}\u9875\uFF0C\u4F46PDF\u6587\u6863\u53EA\u5305\u542B${p.numPages}\u9875`);const O=await p.getPage(V),z=x.current,G=z.getContext("2d");console.log("\u5F53\u524Dscale\u503C:",f);const _t=O.getViewport({scale:1});if(console.log("viewport\u5C3A\u5BF8:",_t.width,"x",_t.height),i&&e(!1),z.width=_t.width,z.height=_t.height,await O.render({canvasContext:G,viewport:_t}).promise,console.log("PDF\u6E32\u67D3\u6210\u529F, canvas\u5C3A\u5BF8:",z.width,"x",z.height),N.current){const wt=N.current;console.log("\u5BB9\u5668\u5C3A\u5BF8:",wt.offsetWidth,"x",wt.offsetHeight),console.log("Canvas\u663E\u793A\u5C3A\u5BF8:",z.offsetWidth,"x",z.offsetHeight)}}catch(V){console.error("PDF\u6E32\u67D3\u5931\u8D25:",V)}finally{I.current=!1}}},[p,f,y,Pt,M,a]);return useEffect(()=>{p&&a&&y&&(console.log("\u8BA1\u7B97\u4E0B\uFF0CrenderPage:","pdfStartPage:"+y,"currentPage:"+a,"pdfDocument:",p),bt())},[a,p,y]),useEffect(()=>{p&&a&&bt()},[f,p,a]),S?React__default.createElement("div",{className:"flex justify-center items-center min-h-full"},React__default.createElement(Pe,{$theme:E},"\u52A0\u8F7D\u4E2D...")):c?React__default.createElement("div",{className:"flex justify-center items-center min-h-full"},React__default.createElement(_e,{$theme:E},React__default.createElement("div",null,React__default.createElement("div",null,"\u52A0\u8F7D\u5931\u8D25"),React__default.createElement("div",{style:{fontSize:"12px",marginTop:"8px"}},c)))):React__default.createElement("div",{ref:N,className:"bg-gray-100",style:{display:W?"block":"flex",justifyContent:W?"initial":"center",alignItems:W?"initial":"flex-start",padding:"20px",minHeight:"100%",width:"100%",overflow:"visible"}},S?React__default.createElement("div",{className:"flex flex-col items-center gap-2 mt-20"},React__default.createElement("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900"}),React__default.createElement("div",{className:"text-xs text-gray-600"},"PDF\u52A0\u8F7D\u4E2D...")):c?React__default.createElement("div",{className:"flex flex-col items-center gap-2 mt-20 text-red-500"},React__default.createElement("div",null,"\u6E32\u67D3\u9519\u8BEF"),React__default.createElement("div",{className:"text-xs"},c)):React__default.createElement("div",{className:"flex justify-center items-start"},React__default.createElement("div",{className:"relative",style:{transform:`scale(${f})`,transformOrigin:"center",display:"inline-block"}},React__default.createElement("canvas",{ref:x,className:"shadow-lg bg-white border border-gray-300",style:{display:"block"}}),React__default.createElement(ke,{pageNumber:a,scale:f,isAnnotating:Y,annotations:_,onAnnotationAdd:b,onAnnotationDelete:w,readOnly:!Y}))))},Re=dt$1.div`
|
|
58
|
+
flex: 1;
|
|
59
|
+
background: ${p=>p.$theme.colors.background};
|
|
60
|
+
position: relative;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
scroll-behavior: smooth;
|
|
64
|
+
|
|
65
|
+
min-height: 0; /* 确保flex子元素可以收缩 */
|
|
66
|
+
height: calc(100% - 1px); /* 明确的高度设置,减去header高度 */
|
|
67
|
+
/* 支持大尺寸内容的滚动 */
|
|
68
|
+
overflow-x: auto;
|
|
69
|
+
overflow-y: auto; /* 改为auto,允许垂直滚动 */
|
|
70
|
+
`,Ne=dt$1.div`
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
height: 100%;
|
|
75
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
76
|
+
`,Le=dt$1.div`
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
height: 100%;
|
|
82
|
+
color: ${p=>p.$theme.colors.error};
|
|
83
|
+
text-align: center;
|
|
84
|
+
padding: 20px;
|
|
85
|
+
`,ze=`
|
|
86
|
+
.md-annotation {
|
|
87
|
+
position: relative;
|
|
88
|
+
display: inline;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
transition: opacity 0.2s;
|
|
91
|
+
background-color: var(--highlight-color, #FFE599);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.md-annotation:hover {
|
|
95
|
+
opacity: 0.8;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* \u8868\u683C\u6807\u6CE8\u6837\u5F0F */
|
|
99
|
+
.table-annotation {
|
|
100
|
+
background-color: var(--table-highlight-color, rgba(255, 229, 153, 0.5));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* markdown_table\u6A21\u5F0F\u4E0B\u7684\u8868\u683C\u6837\u5F0F */
|
|
104
|
+
.markdown-table-mode table {
|
|
105
|
+
overflow: visible !important;
|
|
106
|
+
max-width: none !important;
|
|
107
|
+
width: auto !important;
|
|
108
|
+
table-layout: auto !important;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.markdown-table-mode table,
|
|
112
|
+
.markdown-table-mode table * {
|
|
113
|
+
overflow: visible !important;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.markdown-table-mode .table-container{
|
|
117
|
+
margin: 0 !important;
|
|
118
|
+
overflow: auto !important;
|
|
119
|
+
width: 100% !important;
|
|
120
|
+
min-width: 100% !important;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* \u786E\u4FDD\u8868\u683C\u5355\u5143\u683C\u4E0D\u4F1A\u88AB\u538B\u7F29 */
|
|
124
|
+
.markdown-table-mode table td,
|
|
125
|
+
.markdown-table-mode table th {
|
|
126
|
+
white-space: nowrap !important;
|
|
127
|
+
min-width: 50px !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* \u79FB\u9664fit-content\uFF0C\u4F7F\u7528100%\u5BBD\u5EA6\u786E\u4FDD\u5185\u5BB9\u80FD\u6B63\u5E38\u663E\u793A */
|
|
131
|
+
.markdown-table-mode div{
|
|
132
|
+
width: fit-content !important;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* \u4E3A\u8868\u683C\u6DFB\u52A0\u6700\u5C0F\u5BBD\u5EA6\uFF0C\u786E\u4FDD\u5185\u5BB9\u4E0D\u88AB\u538B\u7F29 */
|
|
136
|
+
.markdown-table-mode table {
|
|
137
|
+
min-width: fit-content !important;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.markdown-table-mode.markdown-scrollbar::-webkit-scrollbar {
|
|
141
|
+
width: 12px;
|
|
142
|
+
height: 12px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
/* \u81EA\u5B9A\u4E49\u6EDA\u52A8\u6761\u6837\u5F0F */
|
|
147
|
+
.markdown-scrollbar::-webkit-scrollbar {
|
|
148
|
+
width: 8px;
|
|
149
|
+
height: 8px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.markdown-scrollbar::-webkit-scrollbar-track {
|
|
153
|
+
background: #f1f1f1;
|
|
154
|
+
border-radius: 4px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.markdown-scrollbar::-webkit-scrollbar-thumb {
|
|
158
|
+
background: #c1c1c1;
|
|
159
|
+
border-radius: 4px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.markdown-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
163
|
+
background: #a9a9a;
|
|
164
|
+
}
|
|
165
|
+
`,Se={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"md",size:"md",radius:"md",padding:"md",margin:"md",shadow:"md",lineHeight:"md"}},Me=p=>{if(console.log("=== detectFileType \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",p),!p)return console.log("\u6570\u636E\u4E3A\u7A7A\uFF0C\u8FD4\u56DE unknown"),"unknown";const a=p.fileName||"",y=p.fileType||"",f=p.content;return console.log("\u68C0\u6D4B\u53C2\u6570:",{fileName:a,fileType:y,content:f}),y==="pdf"||y==="pdf_slides"?(console.log("\u68C0\u6D4B\u5230PDF\u6587\u4EF6"),y):y==="image"?(console.log("\u68C0\u6D4B\u5230\u56FE\u7247\u6587\u4EF6"),"image"):y==="markdown_table"?(console.log("\u68C0\u6D4B\u5230Markdown\u8868\u683C\u6587\u4EF6"),"markdown_table"):y==="markdown"?(console.log("\u68C0\u6D4B\u5230Markdown\u6587\u4EF6"),"markdown"):y==="html"?(console.log("\u68C0\u6D4B\u5230HTML\u6587\u4EF6"),"html"):y==="text"?(console.log("\u68C0\u6D4B\u5230\u6587\u672C\u6587\u4EF6"),"text"):a.toLowerCase().endsWith(".pdf")||(f==null?void 0:f.type)==="pdf"?(console.log("\u68C0\u6D4B\u5230PDF\u6587\u4EF6"),"pdf"):a.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)||(f==null?void 0:f.type)==="image"?(console.log("\u68C0\u6D4B\u5230\u56FE\u7247\u6587\u4EF6"),"image"):a.toLowerCase().endsWith(".md")||(f==null?void 0:f.type)==="markdown"?(console.log("\u68C0\u6D4B\u5230Markdown\u6587\u4EF6"),"markdown"):a.toLowerCase().match(/\.(html|htm)$/)||(f==null?void 0:f.type)==="html"?(console.log("\u68C0\u6D4B\u5230HTML\u6587\u4EF6"),"html"):a.toLowerCase().match(/\.(txt|log|json|xml|css|js|ts)$/)||(f==null?void 0:f.type)==="text"?(console.log("\u68C0\u6D4B\u5230\u6587\u672C\u6587\u4EF6"),"text"):(console.log("\u672A\u8BC6\u522B\u7684\u6587\u4EF6\u7C7B\u578B\uFF0C\u8FD4\u56DE unknown"),"unknown")},We=(p,a,y=!1)=>{var f,_,Y,W,K,M,b;console.log("\u8BA1\u7B97\u4E0B\uFF0CrenderPdfContent:","pdfStartPage:"+p.pdfStartPage,"currentPage:"+a.currentPage),console.log("=== renderPdfContent \u5F00\u59CB ==="),console.log("PDF\u6570\u636E:",p),console.log("PDF\u6587\u6863:",(f=p.content)==null?void 0:f.document),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof((_=p.content)==null?void 0:_.document)),console.log("PDF\u6587\u6863\u662F\u5426\u4E3Anull:",((Y=p.content)==null?void 0:Y.document)===null),console.log("PDF\u6587\u6863\u662F\u5426\u4E3Aundefined:",((W=p.content)==null?void 0:W.document)===void 0),console.log("PDF\u6587\u6863\u65B9\u6CD5:",(K=p.content)!=null&&K.document?Object.getOwnPropertyNames(Object.getPrototypeOf(p.content.document)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u5C5E\u6027:",(M=p.content)!=null&&M.document?Object.keys(p.content.document):"\u65E0\u6587\u6863");const w=p.pdfStartPage||1;console.log("PDF\u8D77\u59CB\u9875:",w);const T=(a.annotationData||[]).filter(c=>"pageNumber"in c&&"x"in c&&"y"in c);console.log("=== PDF\u6807\u6CE8\u6570\u636E ==="),console.log("\u539F\u59CBannotationData:",a.annotationData),console.log("\u8FC7\u6EE4\u540E\u7684pdfAnnotations:",T);const S=y?.82:1,v=a.initialZoom||a.scale||S;return React__default.createElement(Te,{pdfDocument:((b=p.content)==null?void 0:b.document)||null,currentPage:a.currentPage||1,pdfStartPage:w,scale:v,annotations:T,isAnnotating:!1,isSlidesMode:y,onPageChange:a.eventsEmit?c=>{var t;return(t=a.eventsEmit)==null?void 0:t.call(a,"pageChange",{pageNumber:c})}:void 0,onScaleChange:a.eventsEmit?c=>{var t;return(t=a.eventsEmit)==null?void 0:t.call(a,"scaleChange",{scale:c})}:void 0,onAnnotationChange:a.eventsEmit?c=>{var t;return(t=a.eventsEmit)==null?void 0:t.call(a,"annotationChange",{annotation:c})}:void 0,onAnnotationDelete:a.eventsEmit?c=>{var t;return(t=a.eventsEmit)==null?void 0:t.call(a,"annotationDelete",{annotationId:c})}:void 0,styles:a.styles})},Ie=(p,a)=>{var y,f,_,Y,W,K,M,b,w,T,S,v,c,t;console.log("=== Fviewer renderImageContent ==="),console.log("data:",p),console.log("data.content:",p.content),console.log("data.content?.url:",(y=p.content)==null?void 0:y.url),console.log("rotation:",a.rotation);const r=((f=p.content)==null?void 0:f.url)||p.content,[o,F]=useState(!0),[m,l]=useState(!1),n=()=>{console.log("\u56FE\u7247\u52A0\u8F7D\u5B8C\u6210:",r),F(!1),l(!1)},i=()=>{console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",r),F(!1),l(!0)};return React__default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"20px",overflow:"auto",position:"relative",backgroundColor:"#272727"}},o&&React__default.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",zIndex:1}},React__default.createElement("div",{style:{width:"32px",height:"32px",border:`3px solid ${((W=(Y=(_=a.styles)==null?void 0:_.theme)==null?void 0:Y.colors)==null?void 0:W.border)||"#dee2e6"}`,borderTop:`3px solid ${((b=(M=(K=a.styles)==null?void 0:K.theme)==null?void 0:M.colors)==null?void 0:b.primary)||"#007bff"}`,borderRadius:"50%",animation:"spin 1s linear infinite"}}),React__default.createElement("div",{style:{fontSize:"12px",color:((S=(T=(w=a.styles)==null?void 0:w.theme)==null?void 0:T.colors)==null?void 0:S.text)||"#343a40"}},"\u56FE\u7247\u52A0\u8F7D\u4E2D...")),m&&React__default.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"flex",flexDirection:"column",alignItems:"center",gap:"8px",zIndex:1}},React__default.createElement("div",{style:{fontSize:"14px",color:((t=(c=(v=a.styles)==null?void 0:v.theme)==null?void 0:c.colors)==null?void 0:t.error)||"#dc3545"}},"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25")),React__default.createElement("img",{src:r,alt:p.fileName||"\u56FE\u7247",onLoad:n,onError:i,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",transform:`scale(${a.scale||1}) rotate(${a.rotation||0}deg)`,opacity:o?0:1,transition:"opacity 0.3s ease-in-out, transform 0.2s ease-in-out"}}),React__default.createElement("style",null,`
|
|
166
|
+
@keyframes spin {
|
|
167
|
+
0% { transform: rotate(0deg); }
|
|
168
|
+
100% { transform: rotate(360deg); }
|
|
169
|
+
}
|
|
170
|
+
`))},je=(p,a)=>{var y,f,_,Y,W;console.log("=== Fviewer renderTextContent ==="),console.log("data:",p),console.log("data.content:",p.content);let K="";typeof p.content=="string"?K=p.content:(y=p.content)!=null&&y.text?K=p.content.text:(f=p.content)!=null&&f.content&&(K=p.content.content),console.log("\u5B9E\u9645\u6587\u672C\u5185\u5BB9:",K);const M=useRef(null),b=useRef(null);return useEffect(()=>{if(M.current&&b.current&&K){const w=setTimeout(()=>{var T;const S=((T=M.current)==null?void 0:T.scrollHeight)||0,v=Math.max(S+80,200);b.current&&(b.current.style.minHeight=`${v}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",v))},100);return()=>clearTimeout(w)}},[K]),React__default.createElement("div",{style:{height:"100%",overflow:"auto",backgroundColor:"#f5f5f5",padding:"20px",display:"flex",justifyContent:"center",position:"relative"}},React__default.createElement("div",{ref:b,style:{width:"100%",maxWidth:"800px",backgroundColor:"white",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"40px",margin:"20px 0",position:"relative",transform:`scale(${a.scale||1})`,transition:"transform 0.2s ease-in-out",transformOrigin:"top center"}},React__default.createElement("div",{ref:M,style:{width:"100%",overflow:"visible"}},React__default.createElement(Wv,{dataSource:{type:oa.TEXT,content:K},size:"md",theme:{primaryColor:((W=(Y=(_=a.styles)==null?void 0:_.theme)==null?void 0:Y.colors)==null?void 0:W.primary)||"#007bff",backgroundColor:"transparent",textColor:"#333",borderColor:"transparent",borderRadius:"0",padding:"0"},style:{border:"none",background:"transparent",width:"100%",height:"auto",overflow:"visible"}})),React__default.createElement("div",{style:{position:"absolute",top:"0",left:"0",right:"0",height:"2px",background:"linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%)",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}})))},Oe=({data:p,parentProps:a,isTableMode:y=!1})=>{var f,_,Y,W,K,M,b,w,T,S,v,c;const t=useRef(null),r=useRef(null),o=useRef(null),F=useRef(!1);useRef(0),useRef(null);const[m]=useState(!1),l=(V,O)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:V,scrollHeight:O}),a.eventsEmit&&a.eventsEmit("markdown_scroll",{scrollTop:V,scrollHeight:O})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_top")},i=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),a.eventsEmit&&a.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=V=>{var O,z;try{if(!y)return;const G=typeof p.content=="string"?p.content:((O=p.content)==null?void 0:O.content)||"";if(!G||I.length===0)return;const _t=JSON.stringify(I.map(Ot=>({o:Ot.offsets,c:Ot.color}))),wt=`${G.length}:${G.substring(0,64)}:${G.substring(G.length-64)}|${_t}`;if(((z=V.dataset)==null?void 0:z.tableAnnoRuntimeSig)===wt)return;setTimeout(()=>{Pt(),V.dataset&&(V.dataset.tableAnnoRuntimeSig=wt)},50)}catch(G){console.warn("[MarkdownRendered] apply failed",G)}};const E=React__default.useCallback(V=>{var O;return(O=e.current)==null?void 0:O.call(e,V)},[]),x=useCallback(()=>{var V;if(!m||!t.current)return;const O=window.getSelection();if(!O||O.isCollapsed)return;const z=O.getRangeAt(0),G=z.toString().trim();if(!G)return;const _t=t.current;let wt=0,Ot=0;const q=document.createTreeWalker(_t,NodeFilter.SHOW_TEXT,{acceptNode:P=>{var j;return(j=P.parentElement)!=null&&j.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let d=q.nextNode();for(;d;){if(d===z.startContainer){Ot=wt+z.startOffset;break}wt+=((V=d.textContent)==null?void 0:V.length)||0,d=q.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:G,startOffset:Ot,charCount:wt,container:z.startContainer.textContent});const u={id:`md-anno-${Date.now()}`,start:Ot,end:Ot+G.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",u),a.eventsEmit&&a.eventsEmit("md_annotation_add",u),O.removeAllRanges()},[m,a.eventsEmit]),N=y?[]:(a.annotationData||[]).filter(V=>"start"in V&&"end"in V&&!("pageNumber"in V)),I=y?(a.annotationData||[]).filter(V=>"offsets"in V&&Array.isArray(V.offsets)):[],St=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u6E05\u7A7A\u6240\u6709\u6807\u6CE8 ==="),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u6E05\u7A7A\u6807\u6CE8");return}const V=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",V.length),V.length>0&&V.forEach(O=>{const z=O.parentNode;z&&z.replaceChild(document.createTextNode(O.textContent||""),O)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),Pt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",I),!t.current||!I.length){console.log("\u8868\u683C\u6807\u6CE8\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u9000\u51FA");return}const V=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",V.length),V.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}F.current=!0,I.forEach((O,z)=>{const G=O.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",O),!Array.isArray(G)||!G.length||!Array.isArray(G[0])||G[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",O);return}G.forEach((_t,wt)=>{const[Ot,q]=_t;if(typeof Ot!="number"||typeof q!="number"){console.warn("[TableAnnotation] offset is not [number, number]",_t);return}V.forEach((d,u)=>{var P,j,U;let $;const s=d.tBodies&&d.tBodies.length>0?Array.from(d.tBodies[0].rows):[];if(s.length>0)$=s[Ot];else{const k=((j=(P=d.tHead)==null?void 0:P.rows)==null?void 0:j.length)||0;$=Array.from(d.rows)[Ot+k]}if(!$){console.warn("[TableAnnotation] row out of range",{row:Ot,tableIndex:u});return}const h=(U=$.cells)==null?void 0:U[q];if(!h){console.warn("[TableAnnotation] cell is undefined",{row:Ot,col:q,tableIndex:u});return}const C=O.color||"rgba(255, 229, 153, 0.5)",A=getComputedStyle(h).backgroundColor;h.getAttribute("data-table-annotated")==="1"&&(A===C||h.style.backgroundColor===C)||(h.style.setProperty("background",C,"important"),h.style.setProperty("background-color",C,"important"),h.setAttribute("data-table-annotated","1")),O.content&&(h.title=O.content),wt===0&&z===0&&setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{F.current=!1})},[I]),bt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!N.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}r.current&&clearTimeout(r.current);const V=()=>{var O;console.log("\u5F00\u59CB\u5E94\u7528\u6807\u6CE8...");const z=(O=t.current)==null?void 0:O.querySelectorAll(".md-annotation");console.log("\u79FB\u9664\u73B0\u6709\u6807\u6CE8\u6570\u91CF:",(z==null?void 0:z.length)||0),z==null||z.forEach(u=>{const P=u.parentNode;P&&P.replaceChild(document.createTextNode(u.textContent||""),u)});const G=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:u=>{var P;return(P=u.parentElement)!=null&&P.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),_t=[];let wt;for(;wt=G.nextNode();)_t.push(wt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",_t.length),_t.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),r.current=setTimeout(()=>{V()},200);return}let Ot=0;const q=_t.map(u=>{var P;const j=Ot;return Ot+=((P=u.textContent)==null?void 0:P.length)||0,{node:u,start:j,end:Ot,text:u.textContent}});console.log("\u6587\u672C\u8282\u70B9\u4F4D\u7F6E:",q),console.log("\u603B\u6587\u672C\u957F\u5EA6:",Ot);const d=[...N].sort((u,P)=>P.start-u.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",d),d.forEach(u=>{const{start:P,end:j,color:U}=u;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:u,nodePositions:q});const $=q.filter(s=>P<s.end&&j>s.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",$.length),$.forEach(({node:s,start:h})=>{var C,A,k,B,D,g;const L=Math.max(0,P-h),At=Math.min(((C=s.textContent)==null?void 0:C.length)||0,j-h);if(console.log("\u672C\u5730\u4F4D\u7F6E:",{localStart:L,localEnd:At,nodeTextLength:(A=s.textContent)==null?void 0:A.length}),L>=At){console.log("\u672C\u5730\u4F4D\u7F6E\u65E0\u6548\uFF0C\u8DF3\u8FC7");return}const H=((k=s.textContent)==null?void 0:k.slice(0,L))||"",Q=((B=s.textContent)==null?void 0:B.slice(L,At))||"",Ct=((D=s.textContent)==null?void 0:D.slice(At))||"";console.log("\u5206\u5272\u6587\u672C:",{before:H,annotatedText:Q,after:Ct});const Tt=document.createElement("span");Tt.className="md-annotation",Tt.style.backgroundColor=U||"#FFE599",Tt.textContent=Q;const It=document.createDocumentFragment();H&&It.appendChild(document.createTextNode(H)),It.appendChild(Tt),Ct&&It.appendChild(document.createTextNode(Ct)),(g=s.parentNode)==null||g.replaceChild(It,s),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",Q)})})};r.current=setTimeout(()=>{V()},100)},[N]);return useEffect(()=>{var V;if(y){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const O=typeof p.content=="string"?p.content:((V=p.content)==null?void 0:V.content)||"";if(!O||typeof O!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8\u9AD8\u4EAE ==="),console.log("markdownRef.current:",t.current),console.log("isTableMode:",y),console.log("mdAnnotations:",N),console.log("tableAnnotations:",I),console.log("data.content:",p.content),console.log("\u5B9E\u9645\u5185\u5BB9:",O),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA\u6807\u6CE8\u5E94\u7528");return}if(y||St(),!y&&N.length>0){bt();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[y,I,N]),useEffect(()=>{if(!y)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,y]),useEffect(()=>{var V;const O=typeof p.content=="string"?p.content:((V=p.content)==null?void 0:V.content)||"";if(!O||typeof O!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8C03\u8BD5\u4FE1\u606F\u6253\u5370");return}console.log("=== Markdown\u5185\u5BB9\u4FE1\u606F ==="),console.log("isTableMode:",y),console.log("\u5185\u5BB9\u957F\u5EA6:",O.length||0),typeof O=="string"?(console.log("\u5185\u5BB9\u524D100\u5B57\u7B26:",O.substring(0,100)),console.log("\u5185\u5BB9\u540E100\u5B57\u7B26:",O.substring(O.length-100))):(console.log("\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B:",typeof O),console.log("\u5185\u5BB9\u503C:",O)),console.log("\u6807\u6CE8\u6570\u636E:",N),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",I)},[N,I,y]),useEffect(()=>{if(y&&t.current){const V=setTimeout(()=>{var O;const z=(O=t.current)==null?void 0:O.querySelectorAll("table");z&&z.length>0&&(console.log("\u8C03\u6574\u8868\u683C\u5C3A\u5BF8\uFF0C\u627E\u5230\u8868\u683C\u6570\u91CF:",z.length),z.forEach((G,_t)=>{if(G instanceof HTMLTableElement){G.style.width="100%",G.style.minWidth="100%",G.style.tableLayout="auto";const wt=G.closest(".markdown-table-mode");wt&&wt instanceof HTMLElement&&(wt.style.width="100%",wt.style.overflowX="auto"),console.log(`\u8868\u683C ${_t+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(V)}},[y,p.content]),useEffect(()=>()=>{r.current&&clearTimeout(r.current),o.current&&(o.current.disconnect(),o.current=null)},[]),React__default.createElement("div",{style:{height:"100%",width:"100%",overflow:"auto"},className:`markdown-container markdown-scrollbar ${y?"markdown-table-mode":""}`},React__default.createElement("style",null,ze),React__default.createElement("div",{ref:t},React__default.createElement(Wv,{dataSource:{type:oa.MARKDOWN,content:(()=>{var V,O;return typeof p.content=="string"?p.content:(V=p.content)!=null&&V.text?p.content.text:(O=p.content)!=null&&O.content?p.content.content:""})()},size:"md",onScroll:y?void 0:l,onScrollToTop:y?void 0:n,onScrollToBottom:y?void 0:i,onRendered:E,theme:{primaryColor:((Y=(_=(f=a.styles)==null?void 0:f.theme)==null?void 0:_.colors)==null?void 0:Y.primary)||"#007bff",backgroundColor:((M=(K=(W=a.styles)==null?void 0:W.theme)==null?void 0:K.colors)==null?void 0:M.background)||"#f8f9fa",textColor:((T=(w=(b=a.styles)==null?void 0:b.theme)==null?void 0:w.colors)==null?void 0:T.text)||"#343a40",borderColor:((c=(v=(S=a.styles)==null?void 0:S.theme)==null?void 0:v.colors)==null?void 0:c.border)||"#dee2e6",borderRadius:y?"0px":"8px",padding:y?"0px":"20px"},style:{height:"100%",border:"none",background:"transparent",overflowY:y?"visible":"scroll"}})))},He=({markdown:p,onRendered:a,tableAnnotations:y=[]})=>{const f=useRef(null),_=W=>{const K=W.split(/\r?\n/).filter(S=>S.trim().length>0);let M=-1;for(let S=0;S<K.length-1;S++){const v=K[S].trim(),c=K[S+1].trim();if(v.startsWith("|")&&v.endsWith("|")&&c.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=S;break}}if(M===-1)return null;const b=K[M].split("|").slice(1,-1).map(S=>S.trim()),w=[];for(let S=M+2;S<K.length;S++){const v=K[S].trim();if(!v.startsWith("|")||!v.endsWith("|"))break;w.push(v)}const T=w.map(S=>S.split("|").slice(1,-1).map(v=>v.trim()));return{headers:b,rows:T}},Y=React__default.useMemo(()=>_(p),[p]);return useEffect(()=>{const W=()=>{try{if(!f.current||!y.length)return;const M=f.current.querySelectorAll("table");if(!M||M.length===0)return;y.forEach((b,w)=>{(b.offsets||[]).forEach((T,S)=>{const[v,c]=T;M.forEach(t=>{var r,o,F;const m=t.tBodies&&t.tBodies.length>0?Array.from(t.tBodies[0].rows):[];let l;if(m.length>0)l=m[v];else{const e=((o=(r=t.tHead)==null?void 0:r.rows)==null?void 0:o.length)||0;l=Array.from(t.rows)[v+e]}if(!l)return;const n=(F=l.cells)==null?void 0:F[c];if(!n)return;const i=b.color||"rgba(255, 229, 153, 0.5)";n.getAttribute("data-table-annotated")==="1"||(n.style.setProperty("background",i,"important"),n.style.setProperty("background-color",i,"important"),n.setAttribute("data-table-annotated","1"),b.content&&(n.title=b.content)),w===0&&S===0&&setTimeout(()=>n.scrollIntoView({behavior:"smooth",block:"start"}),50)})})})}catch(M){console.warn("[MinimalMarkdownTable] apply annotations failed",M)}},K=requestAnimationFrame(()=>{W(),a&&a()});return()=>cancelAnimationFrame(K)},[p,y,a]),Y?React__default.createElement("div",{ref:f,className:"markdown-table-mode z-mdtbl-wrapper"},React__default.createElement("style",null,`
|
|
171
|
+
.z-mdtbl-wrapper { overflow: auto; position: relative; }
|
|
172
|
+
.z-mdtbl { border-collapse: separate; border-spacing: 0; background: transparent; box-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06); border-radius: 8px; }
|
|
173
|
+
.z-mdtbl th, .z-mdtbl td { border: 1px solid #e5e7eb; padding: 10px 14px; font-size: 13px; line-height: 1.4; color: inherit; }
|
|
174
|
+
.z-mdtbl th { background: transparent; font-weight: 600; color: inherit; position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 rgba(0,0,0,.06); }
|
|
175
|
+
.z-mdtbl tbody tr:nth-child(odd) { background: transparent; }
|
|
176
|
+
.z-mdtbl tbody tr:hover { background: transparent; }
|
|
177
|
+
.z-mdtbl td, .z-mdtbl th { white-space: nowrap; }
|
|
178
|
+
.z-mdtbl thead tr:first-child th:first-child { border-top-left-radius: 8px; }
|
|
179
|
+
.z-mdtbl thead tr:first-child th:last-child { border-top-right-radius: 8px; }
|
|
180
|
+
.z-mdtbl tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
|
|
181
|
+
.z-mdtbl tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }
|
|
182
|
+
`),React__default.createElement("table",{className:"z-mdtbl"},React__default.createElement("thead",null,React__default.createElement("tr",null,Y.headers.map((W,K)=>React__default.createElement("th",{key:K},W)))),React__default.createElement("tbody",null,Y.rows.map((W,K)=>React__default.createElement("tr",{key:K},W.map((M,b)=>React__default.createElement("td",{key:b},M))))))):React__default.createElement("div",{ref:f,style:{padding:"8px"}},"\u65E0\u6CD5\u89E3\u6790\u4E3A\u8868\u683C")},Ze=(p,a)=>{var y,f;console.log("=== Fviewer renderHtmlContent ==="),console.log("data:",p),console.log("data.content:",p.content);let _="";return typeof p.content=="string"?_=p.content:(y=p.content)!=null&&y.text?_=p.content.text:(f=p.content)!=null&&f.content&&(_=p.content.content),console.log("\u6700\u7EC8\u4F20\u9012\u7ED9 iframe \u7684 content:",_),React__default.createElement("div",{style:{height:"100%",overflow:"auto",position:"relative"}},React__default.createElement("iframe",{srcDoc:_,style:{width:"100%",height:"100%",border:"none",background:"white"},title:"HTML Preview",sandbox:"allow-same-origin allow-scripts"}))},Xe=(p,a)=>React__default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",color:"#666"}},React__default.createElement("div",null,React__default.createElement("div",null,"\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B"),React__default.createElement("div",{style:{fontSize:"12px",marginTop:"8px"}},p.fileName||"\u672A\u77E5\u6587\u4EF6"))),qe=({data:p,annotationData:a=[],totalPage:y=0,currentPage:f=1,scale:_,rotation:Y=0,eventsEmit:W,styles:K,tools:M={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0},customComponents:b,className:w,contentClass:T})=>{var S,v,c,t;const r=(K==null?void 0:K.theme)||Se,[o,F]=useState(!1),[m]=useState("\u5185\u5BB9\u52A0\u8F7D\u4E2D..."),[l,n]=useState(null);console.log("=== Fviewer \u63A5\u6536\u6570\u636E ==="),console.log("Fviewer data:",p),console.log("Fviewer data.content:",p==null?void 0:p.content),console.log("Fviewer data.content.document:",(S=p==null?void 0:p.content)==null?void 0:S.document),console.log("Fviewer data.content.document\u7C7B\u578B:",typeof((v=p==null?void 0:p.content)==null?void 0:v.document)),console.log("Fviewer data.content.document\u662F\u5426\u4E3Anull:",((c=p==null?void 0:p.content)==null?void 0:c.document)===null),console.log("Fviewer data.content.document\u662F\u5426\u4E3Aundefined:",((t=p==null?void 0:p.content)==null?void 0:t.document)===void 0),console.log("Fviewer currentPage:",f),console.log("Fviewer scale:",_);const i=useRef(null),e=useRef(null),E=useRef(0);E.current+=1,console.log("[Fviewer] render count:",E.current);const x=Me(p);console.log("=== Fviewer \u7EC4\u4EF6 ==="),console.log("\u68C0\u6D4B\u5230\u7684\u6587\u4EF6\u7C7B\u578B:",x),console.log("\u5B8C\u6574\u6570\u636E:",p);const N=()=>{var I;switch(console.log("\u5F00\u59CB\u6E32\u67D3\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B:",x),x){case"pdf":case"pdf_slides":return console.log("\u8BA1\u7B97\u4E0B\uFF0C\u6E32\u67D3PDF\u5185\u5BB9:",x,"pdfStartPage:"+p.pdfStartPage,"currentPage:"+f),We(p,{data:p,annotationData:a,totalPage:y,currentPage:f,scale:_,eventsEmit:W,styles:K,tools:M,className:w,contentClass:T},x==="pdf_slides");case"image":return console.log("\u6E32\u67D3\u56FE\u7247\u5185\u5BB9"),Ie(p,{scale:_,rotation:Y,styles:K});case"text":return console.log("\u6E32\u67D3\u6587\u672C\u5185\u5BB9"),je(p,{scale:_,styles:K});case"markdown":case"markdown_table":if(console.log("\u6E32\u67D3Markdown\u5185\u5BB9:",x),x==="markdown_table"){const St=typeof p.content=="string"?p.content:((I=p.content)==null?void 0:I.content)||"",Pt=(a||[]).filter(bt=>"offsets"in bt&&Array.isArray(bt.offsets));return React__default.createElement(He,{markdown:St,tableAnnotations:Pt})}return React__default.createElement(Oe,{data:p,parentProps:{data:p,annotationData:a,eventsEmit:W,styles:K,tools:M,className:w,contentClass:T},isTableMode:!1});case"html":return console.log("\u6E32\u67D3HTML\u5185\u5BB9"),Ze(p);default:return console.log("\u6E32\u67D3\u672A\u77E5\u7C7B\u578B\u5185\u5BB9"),Xe(p)}};return React__default.useEffect(()=>{const I=i.current,St=e.current,Pt=I!==p,bt=St!==(p?p.content:void 0);console.log("[Fviewer useEffect:data] triggered",{dataChanged:Pt,contentChanged:bt,hasData:!!p,hasContent:!!(p!=null&&p.content),isLoadingBefore:o}),i.current=p,e.current=p?p.content:void 0},[p==null?void 0:p.content]),React__default.useEffect(()=>{l&&F(!1)},[l]),React__default.useEffect(()=>{console.log("=== Fviewer annotationData \u53D8\u5316\u76D1\u542C ==="),console.log("annotationData:",a),console.log("annotationData \u957F\u5EA6:",(a==null?void 0:a.length)||0),console.log("\u5F53\u524D\u6587\u4EF6\u7C7B\u578B:",x)},[a,x]),React__default.createElement(Re,{$theme:r,className:T},o?b!=null&&b.LoadingComponent?React__default.createElement(b.LoadingComponent,{status:m,theme:r}):React__default.createElement(Ne,{$theme:r},m):l?b!=null&&b.ErrorComponent?React__default.createElement(b.ErrorComponent,{error:l,theme:r}):React__default.createElement(Le,{$theme:r},React__default.createElement("div",null,"\u52A0\u8F7D\u5931\u8D25"),React__default.createElement("div",{style:{fontSize:"12px",marginTop:"8px"}},l)):N())};/**
|
|
183
|
+
* @license lucide-react v0.456.0 - ISC
|
|
184
|
+
*
|
|
185
|
+
* This source code is licensed under the ISC license.
|
|
186
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
+
*/const Ue=p=>p.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ye=(...p)=>p.filter((a,y,f)=>!!a&&a.trim()!==""&&f.indexOf(a)===y).join(" ").trim();/**
|
|
188
|
+
* @license lucide-react v0.456.0 - ISC
|
|
189
|
+
*
|
|
190
|
+
* This source code is licensed under the ISC license.
|
|
191
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
+
*/var Ye={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
193
|
+
* @license lucide-react v0.456.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/const Ge=forwardRef(({color:p="currentColor",size:a=24,strokeWidth:y=2,absoluteStrokeWidth:f,className:_="",children:Y,iconNode:W,...K},M)=>createElement("svg",{ref:M,...Ye,width:a,height:a,stroke:p,strokeWidth:f?Number(y)*24/Number(a):y,className:ye("lucide",_),...K},[...W.map(([b,w])=>createElement(b,w)),...Array.isArray(Y)?Y:[Y]]));/**
|
|
198
|
+
* @license lucide-react v0.456.0 - ISC
|
|
199
|
+
*
|
|
200
|
+
* This source code is licensed under the ISC license.
|
|
201
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
+
*/const ue=(p,a)=>{const y=forwardRef(({className:f,..._},Y)=>createElement(Ge,{ref:Y,iconNode:a,className:ye(`lucide-${Ue(p)}`,f),..._}));return y.displayName=`${p}`,y};/**
|
|
203
|
+
* @license lucide-react v0.456.0 - ISC
|
|
204
|
+
*
|
|
205
|
+
* This source code is licensed under the ISC license.
|
|
206
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
207
|
+
*/const Ve=ue("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
208
|
+
* @license lucide-react v0.456.0 - ISC
|
|
209
|
+
*
|
|
210
|
+
* This source code is licensed under the ISC license.
|
|
211
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
212
|
+
*/const Je=ue("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
213
|
+
* @license lucide-react v0.456.0 - ISC
|
|
214
|
+
*
|
|
215
|
+
* This source code is licensed under the ISC license.
|
|
216
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
217
|
+
*/const Ke=ue("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
218
|
+
* @license lucide-react v0.456.0 - ISC
|
|
219
|
+
*
|
|
220
|
+
* This source code is licensed under the ISC license.
|
|
221
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
222
|
+
*/const Qe=ue("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
223
|
+
* @license lucide-react v0.456.0 - ISC
|
|
224
|
+
*
|
|
225
|
+
* This source code is licensed under the ISC license.
|
|
226
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
227
|
+
*/const et=ue("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
228
|
+
* @license lucide-react v0.456.0 - ISC
|
|
229
|
+
*
|
|
230
|
+
* This source code is licensed under the ISC license.
|
|
231
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
232
|
+
*/const tt=ue("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
|
|
233
|
+
* @license lucide-react v0.456.0 - ISC
|
|
234
|
+
*
|
|
235
|
+
* This source code is licensed under the ISC license.
|
|
236
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
237
|
+
*/const ot=ue("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
238
|
+
* @license lucide-react v0.456.0 - ISC
|
|
239
|
+
*
|
|
240
|
+
* This source code is licensed under the ISC license.
|
|
241
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
242
|
+
*/const nt=ue("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
|
|
243
|
+
* @license lucide-react v0.456.0 - ISC
|
|
244
|
+
*
|
|
245
|
+
* This source code is licensed under the ISC license.
|
|
246
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
247
|
+
*/const ut=ue("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),rt=dt$1.div`
|
|
248
|
+
display: flex;
|
|
249
|
+
align-items: center;
|
|
250
|
+
padding: 0px 12px;
|
|
251
|
+
justify-content: space-between;
|
|
252
|
+
padding: ${p=>p.$theme.space.padding};
|
|
253
|
+
border-bottom: 1px solid ${p=>p.$theme.colors.border};
|
|
254
|
+
background: ${p=>p.$theme.colors.background};
|
|
255
|
+
min-height: 52px;
|
|
256
|
+
`,lt=dt$1.div`
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
gap: 8px;
|
|
260
|
+
flex: 1;
|
|
261
|
+
min-width: 0;
|
|
262
|
+
`,it=dt$1.div`
|
|
263
|
+
font-size: 14px;
|
|
264
|
+
font-weight: 500;
|
|
265
|
+
color: ${p=>p.$theme.colors.text};
|
|
266
|
+
white-space: nowrap;
|
|
267
|
+
overflow: hidden;
|
|
268
|
+
text-overflow: ellipsis;
|
|
269
|
+
`,st=dt$1.div`
|
|
270
|
+
font-size: 12px;
|
|
271
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
272
|
+
white-space: nowrap;
|
|
273
|
+
`,at=dt$1.div`
|
|
274
|
+
display: flex;
|
|
275
|
+
align-items: center;
|
|
276
|
+
gap: 4px;
|
|
277
|
+
`,ne=dt$1.button`
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: center;
|
|
280
|
+
justify-content: center;
|
|
281
|
+
width: 32px;
|
|
282
|
+
height: 32px;
|
|
283
|
+
border: none;
|
|
284
|
+
border-radius: ${p=>p.$theme.space.radius};
|
|
285
|
+
background: ${p=>p.$active?p.$theme.colors.primary+"20":"transparent"};
|
|
286
|
+
color: ${p=>p.$active?p.$theme.colors.primary:p.$theme.colors.text};
|
|
287
|
+
cursor: pointer;
|
|
288
|
+
transition: all 0.2s ease;
|
|
289
|
+
|
|
290
|
+
/* 确保图标有默认颜色 */
|
|
291
|
+
& > svg {
|
|
292
|
+
color: currentColor;
|
|
293
|
+
stroke: currentColor;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
&:hover {
|
|
297
|
+
background: ${p=>p.$theme.colors.primary+"10"};
|
|
298
|
+
color: ${p=>p.$theme.colors.primary};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
&:disabled {
|
|
302
|
+
opacity: 0.5;
|
|
303
|
+
cursor: not-allowed;
|
|
304
|
+
}
|
|
305
|
+
`,ct=dt$1.div`
|
|
306
|
+
font-size: 12px;
|
|
307
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
308
|
+
min-width: 40px;
|
|
309
|
+
text-align: center;
|
|
310
|
+
`,dt={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"12px",size:"12px",radius:"4px",padding:"8px 12px",margin:"4px",shadow:"0 2px 4px rgba(0,0,0,0.1)",lineHeight:"1.5"}};React__default.memo(({fileName:p="\u672A\u77E5\u6587\u4EF6",currentPage:a=1,totalPage:y=0,tools:f={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!0},styles:_,onPrevPage:Y,onNextPage:W,onZoomIn:K,onZoomOut:M,onAnnotationToggle:b,onDownload:w,onRotateLeft:T,onRotateRight:S,onClose:v,scale:c=1,isAnnotating:t=!1,className:r})=>{const o=(_==null?void 0:_.theme)||dt;return console.log("Header\u7EC4\u4EF6\u6E32\u67D3 - currentPage:",a,"totalPage:",y),React__default.createElement(rt,{$theme:o,className:r},React__default.createElement(lt,{$theme:o},React__default.createElement(it,{$theme:o},p)),React__default.createElement(at,{$theme:o},f.navigation&&React__default.createElement(React__default.Fragment,null,React__default.createElement(ne,{$theme:o,onClick:Y,disabled:a<=1,title:"\u4E0A\u4E00\u9875"},React__default.createElement(Ve,{size:16})),y>0&&React__default.createElement(st,{$theme:o},a," / ",y),React__default.createElement(ne,{$theme:o,onClick:W,disabled:!y||a>=y,title:"\u4E0B\u4E00\u9875"},React__default.createElement(Je,{size:16}))),f.zoom&&React__default.createElement(React__default.Fragment,null,React__default.createElement(ne,{$theme:o,onClick:M,disabled:c<=.3,title:"\u7F29\u5C0F"},React__default.createElement(ut,{size:16})),React__default.createElement(ct,{$theme:o},Math.round(c*100),"%"),React__default.createElement(ne,{$theme:o,onClick:K,disabled:c>=3,title:"\u653E\u5927"},React__default.createElement(nt,{size:16}))),f.annotation&&React__default.createElement(ne,{$theme:o,$active:t,onClick:b,title:t?"\u9000\u51FA\u6807\u6CE8":"\u5F00\u59CB\u6807\u6CE8"},React__default.createElement(Qe,{size:16})),f.download&&React__default.createElement(ne,{$theme:o,onClick:w,title:"\u4E0B\u8F7D"},React__default.createElement(Ke,{size:16})),f.rotate&&React__default.createElement(React__default.Fragment,null,React__default.createElement(ne,{$theme:o,onClick:T,title:"\u5411\u5DE6\u65CB\u8F6C"},React__default.createElement(et,{size:16})),React__default.createElement(ne,{$theme:o,onClick:S,title:"\u5411\u53F3\u65CB\u8F6C"},React__default.createElement(tt,{size:16}))),f.close&&React__default.createElement(ne,{$theme:o,onClick:v,title:"\u5173\u95ED"},React__default.createElement(ot,{size:16}))))});const mt=()=>{if(xe()){console.log("PDF Worker \u5DF2\u7ECF\u6CE8\u518C");return}const p=`PDF Worker \u672A\u6CE8\u518C\u3002\u8BF7\u5728\u5E94\u7528\u5165\u53E3\u5904\u8C03\u7528 registerPDFWorker() \u6CE8\u518C Worker\u3002
|
|
311
|
+
\u793A\u4F8B\uFF1Aimport { registerPDFWorker } from "@mxmweb/fviewer";
|
|
312
|
+
registerPDFWorker("/worker/pdf.worker.min.js");
|
|
313
|
+
\u6CE8\u610F\uFF1AWorker \u6587\u4EF6\u8DEF\u5F84\u9700\u8981\u6839\u636E\u5B9E\u9645\u90E8\u7F72\u60C5\u51B5\u8C03\u6574\u3002`;throw console.error(p),new Error(p)},be=(p,a,y)=>{if(!p&&!a)return"unknown";const f=p||"",_=a||"";return f.toLowerCase().endsWith(".pdf")||_==="pdf"?"pdf":f.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)||_==="image"?"image":f.toLowerCase().endsWith(".md")||_==="markdown"?_==="markdown_table"?"markdown_table":"markdown":f.toLowerCase().match(/\.(html|htm)$/)||_==="html"?"html":f.toLowerCase().match(/\.(txt|log|json|xml|css|js|ts)$/)||_==="text"?"text":"unknown"},gt=async(p,a={})=>{console.log("=== parsePdfFile \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",{data:typeof p,options:a});try{mt();let y;if(typeof p=="string"){console.log("\u4ECEURL\u52A0\u8F7DPDF:",p);const Y=pdfExports.getDocument({url:p,httpHeaders:a.token?{Authorization:a.token}:void 0});console.log("=== PDF\u52A0\u8F7D\u4EFB\u52A1\u8BE6\u7EC6\u4FE1\u606F ==="),console.log("\u52A0\u8F7D\u4EFB\u52A1\u5BF9\u8C61:",Y),console.log("\u52A0\u8F7D\u4EFB\u52A1\u7C7B\u578B:",typeof Y),console.log("\u52A0\u8F7D\u4EFB\u52A1\u65B9\u6CD5:",Object.getOwnPropertyNames(Object.getPrototypeOf(Y))),console.log("\u52A0\u8F7D\u4EFB\u52A1\u5C5E\u6027:",Object.keys(Y)),y=await Y.promise,console.log("=== PDF\u6587\u6863\u52A0\u8F7D\u5B8C\u6210 ==="),console.log("PDF\u6587\u6863\u5BF9\u8C61:",y),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof y),console.log("PDF\u6587\u6863\u65B9\u6CD5:",Object.getOwnPropertyNames(Object.getPrototypeOf(y))),console.log("PDF\u6587\u6863\u5C5E\u6027:",Object.keys(y))}else{console.log("\u4ECEArrayBuffer\u52A0\u8F7DPDF");const Y=pdfExports.getDocument({data:p});console.log("=== PDF\u52A0\u8F7D\u4EFB\u52A1\u8BE6\u7EC6\u4FE1\u606F ==="),console.log("\u52A0\u8F7D\u4EFB\u52A1\u5BF9\u8C61:",Y),console.log("\u52A0\u8F7D\u4EFB\u52A1\u7C7B\u578B:",typeof Y),y=await Y.promise,console.log("=== PDF\u6587\u6863\u52A0\u8F7D\u5B8C\u6210 ==="),console.log("PDF\u6587\u6863\u5BF9\u8C61:",y),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof y)}const f=y.numPages;console.log("PDF\u52A0\u8F7D\u6210\u529F\uFF0C\u603B\u9875\u6570:",f),console.log("PDF\u6307\u7EB9:",y.fingerprints),console.log("PDF\u4F20\u8F93\u5BF9\u8C61:",y._transport);const _={type:"pdf",content:{type:"pdf",document:y,totalPages:f},fileName:a.fileName,fileType:"pdf",totalPages:f};return console.log("=== \u89E3\u6790\u7ED3\u679C\u8BE6\u7EC6\u4FE1\u606F ==="),console.log("\u89E3\u6790\u7ED3\u679C:",_),console.log("\u89E3\u6790\u7ED3\u679C\u7C7B\u578B:",typeof _),console.log("\u89E3\u6790\u7ED3\u679C\u5C5E\u6027:",Object.keys(_)),console.log("\u5185\u5BB9\u5BF9\u8C61:",_.content),console.log("\u6587\u6863\u5BF9\u8C61:",_.content.document),_}catch(y){console.error("PDF\u89E3\u6790\u5931\u8D25:",y),console.error("\u9519\u8BEF\u8BE6\u60C5:",{message:y instanceof Error?y.message:"\u672A\u77E5\u9519\u8BEF",stack:y instanceof Error?y.stack:void 0,name:y instanceof Error?y.name:void 0,url:typeof p=="string"?p:"ArrayBuffer",options:a});let f="PDF\u89E3\u6790\u5931\u8D25";return y instanceof Error&&(y.message.includes("Invalid PDF structure")?f="PDF\u6587\u4EF6\u7ED3\u6784\u65E0\u6548\uFF0C\u53EF\u80FD\u6587\u4EF6\u635F\u574F\u6216\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u4EF6":y.message.includes("Failed to fetch")?f="PDF\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u548C\u6587\u4EF6URL":y.message.includes("Worker")?f="PDF\u89E3\u6790\u5668\u521D\u59CB\u5316\u5931\u8D25\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u91CD\u8BD5":f=`PDF\u89E3\u6790\u5931\u8D25: ${y.message}`),{type:"pdf",content:null,fileName:a.fileName,fileType:"pdf",error:f}}},ft=async(p,a={})=>{console.log("=== parseImageFile \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",{data:typeof p,options:a});try{let y;if(typeof p=="string")console.log("\u4ECEURL\u52A0\u8F7D\u56FE\u7247:",p),y=p;else{console.log("\u4ECEArrayBuffer\u52A0\u8F7D\u56FE\u7247");const _=new Blob([p]);y=URL.createObjectURL(_)}console.log("\u5F00\u59CB\u9884\u52A0\u8F7D\u56FE\u7247:",y),await new Promise((_,Y)=>{const W=new Image;W.onload=()=>{console.log("\u56FE\u7247\u9884\u52A0\u8F7D\u6210\u529F:",y),console.log("\u56FE\u7247\u5C3A\u5BF8:",W.width,"x",W.height),_()},W.onerror=()=>{console.error("\u56FE\u7247\u9884\u52A0\u8F7D\u5931\u8D25:",y),Y(new Error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"))};const K=setTimeout(()=>{Y(new Error("\u56FE\u7247\u52A0\u8F7D\u8D85\u65F6"))},1e4);W.onload=()=>{clearTimeout(K),console.log("\u56FE\u7247\u9884\u52A0\u8F7D\u6210\u529F:",y),console.log("\u56FE\u7247\u5C3A\u5BF8:",W.width,"x",W.height),_()},W.onerror=()=>{clearTimeout(K),console.error("\u56FE\u7247\u9884\u52A0\u8F7D\u5931\u8D25:",y),Y(new Error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"))},W.src=y});const f={type:"image",content:{type:"image",url:y},fileName:a.fileName,fileType:"image"};return console.log("=== parseImageFile \u7ED3\u679C ==="),console.log("result:",f),f}catch(y){return console.error("\u56FE\u7247\u89E3\u6790\u5931\u8D25:",y),{type:"image",content:null,fileName:a.fileName,fileType:"image",error:`\u56FE\u7247\u89E3\u6790\u5931\u8D25: ${y instanceof Error?y.message:"\u672A\u77E5\u9519\u8BEF"}`}}},Et=async(p,a={})=>{try{let y;if(typeof p=="string"){const f=await fetch(p,{headers:a.token?{Authorization:a.token}:void 0});if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);y=await f.text()}else y=new TextDecoder("utf-8").decode(p);return{type:"text",content:{type:"text",text:y},fileName:a.fileName,fileType:"text"}}catch(y){return{type:"text",content:null,fileName:a.fileName,fileType:"text",error:`\u6587\u672C\u89E3\u6790\u5931\u8D25: ${y instanceof Error?y.message:"\u672A\u77E5\u9519\u8BEF"}`}}},Ft=async(p,a={})=>{try{let y;if(typeof p=="string"){const f=await fetch(p,{headers:a.token?{Authorization:a.token}:void 0});if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);y=await f.text()}else y=new TextDecoder("utf-8").decode(p);return{type:"markdown",content:{type:"markdown",text:y},fileName:a.fileName,fileType:"markdown"}}catch(y){return{type:"markdown",content:null,fileName:a.fileName,fileType:"markdown",error:`Markdown\u89E3\u6790\u5931\u8D25: ${y instanceof Error?y.message:"\u672A\u77E5\u9519\u8BEF"}`}}},ht=async(p,a={})=>{console.log("=== parseHtmlFile \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",{data:typeof p,options:a});try{let y;if(typeof p=="string"){console.log("\u4ECEURL\u52A0\u8F7DHTML:",p);const _=await fetch(p,{headers:a.token?{Authorization:a.token}:void 0});if(console.log("HTTP\u54CD\u5E94\u72B6\u6001:",_.status,_.statusText),!_.ok)throw new Error(`HTTP ${_.status}: ${_.statusText}`);y=await _.text(),console.log("HTML\u5185\u5BB9\u957F\u5EA6:",y.length),console.log("HTML\u5185\u5BB9\u524D500\u5B57\u7B26:",y.substring(0,500))}else console.log("\u4ECEArrayBuffer\u52A0\u8F7DHTML"),y=new TextDecoder("utf-8").decode(p);const f={type:"html",content:{type:"html",text:y},fileName:a.fileName,fileType:"html"};return console.log("=== parseHtmlFile \u7ED3\u679C ==="),console.log("result:",f),console.log("result.content.text \u957F\u5EA6:",f.content.text.length),console.log("result.content.text \u524D200\u5B57\u7B26:",f.content.text.substring(0,200)),f}catch(y){return console.error("HTML\u89E3\u6790\u5931\u8D25:",y),{type:"html",content:null,fileName:a.fileName,fileType:"html",error:`HTML\u89E3\u6790\u5931\u8D25: ${y instanceof Error?y.message:"\u672A\u77E5\u9519\u8BEF"}`}}},pt=async(p,a={})=>{switch(be(a.fileName,a.fileType)){case"pdf":return await gt(p,a);case"image":return await ft(p,a);case"text":return await Et(p,a);case"markdown":case"markdown_table":return await Ft(p,a);case"html":return await ht(p,a);default:return{type:"unknown",content:null,fileName:a.fileName,fileType:a.fileType,error:"\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B"}}};dt$1.div`
|
|
314
|
+
display: flex;
|
|
315
|
+
flex-direction: column;
|
|
316
|
+
height: 100%;
|
|
317
|
+
width: 100%;
|
|
318
|
+
background: ${p=>p.$theme.colors.background};
|
|
319
|
+
border: 1px solid ${p=>p.$theme.colors.border};
|
|
320
|
+
border-radius: ${p=>p.$theme.space.radius};
|
|
321
|
+
overflow: hidden;
|
|
322
|
+
min-height: 0; /* 确保flex子元素可以收缩 */
|
|
323
|
+
`;dt$1.div`
|
|
324
|
+
display: flex;
|
|
325
|
+
align-items: center;
|
|
326
|
+
justify-content: center;
|
|
327
|
+
height: 100%;
|
|
328
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
329
|
+
font-size: 14px;
|
|
330
|
+
`;dt$1.div`
|
|
331
|
+
display: flex;
|
|
332
|
+
flex-direction: column;
|
|
333
|
+
align-items: center;
|
|
334
|
+
justify-content: center;
|
|
335
|
+
height: 100%;
|
|
336
|
+
color: ${p=>p.$theme.colors.error};
|
|
337
|
+
text-align: center;
|
|
338
|
+
padding: 20px;
|
|
339
|
+
`;const xe=()=>!!pdfExports.GlobalWorkerOptions.workerSrc,vt=()=>pdfExports.GlobalWorkerOptions.workerSrc,yt=(p="/worker/pdf.worker.min.js")=>{try{if(pdfExports.GlobalWorkerOptions.workerSrc){console.log("PDF Worker \u5DF2\u7ECF\u6CE8\u518C:",pdfExports.GlobalWorkerOptions.workerSrc);return}pdfExports.GlobalWorkerOptions.workerSrc=p,console.log("PDF Worker \u6CE8\u518C\u6210\u529F:",p)}catch(a){console.error("PDF Worker \u6CE8\u518C\u5931\u8D25:",a)}},HeaderContainer=dt$1.div`
|
|
340
|
+
display: flex;
|
|
341
|
+
align-items: center;
|
|
342
|
+
padding: 0px 12px;
|
|
343
|
+
justify-content: space-between;
|
|
344
|
+
padding: ${p=>p.$theme.space.padding};
|
|
345
|
+
border-bottom: 1px solid ${p=>p.$theme.colors.border};
|
|
346
|
+
background: ${p=>p.$theme.colors.background};
|
|
347
|
+
min-height: 52px;
|
|
348
|
+
`,FileInfo=dt$1.div`
|
|
349
|
+
display: flex;
|
|
350
|
+
align-items: center;
|
|
351
|
+
gap: 8px;
|
|
352
|
+
flex: 1;
|
|
353
|
+
min-width: 0;
|
|
354
|
+
`,FileName=dt$1.div`
|
|
355
|
+
font-size: 14px;
|
|
356
|
+
font-weight: 500;
|
|
357
|
+
color: ${p=>p.$theme.colors.text};
|
|
358
|
+
white-space: nowrap;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
text-overflow: ellipsis;
|
|
361
|
+
`,PageInfo=dt$1.div`
|
|
362
|
+
font-size: 12px;
|
|
363
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
364
|
+
white-space: nowrap;
|
|
365
|
+
`,ToolBar=dt$1.div`
|
|
366
|
+
display: flex;
|
|
367
|
+
align-items: center;
|
|
368
|
+
gap: 4px;
|
|
369
|
+
`,ToolButton=dt$1.button`
|
|
370
|
+
display: flex;
|
|
371
|
+
align-items: center;
|
|
372
|
+
justify-content: center;
|
|
373
|
+
width: 32px;
|
|
374
|
+
height: 32px;
|
|
375
|
+
border: none;
|
|
376
|
+
border-radius: ${p=>p.$theme.space.radius};
|
|
377
|
+
background: ${p=>p.$active?p.$theme.colors.primary+"20":"transparent"};
|
|
378
|
+
color: ${p=>p.$active?p.$theme.colors.primary:p.$theme.colors.text};
|
|
379
|
+
cursor: pointer;
|
|
380
|
+
transition: all 0.2s ease;
|
|
381
|
+
|
|
382
|
+
&:hover {
|
|
383
|
+
background: ${p=>p.$theme.colors.primary+"10"};
|
|
384
|
+
color: ${p=>p.$theme.colors.primary};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
&:disabled {
|
|
388
|
+
opacity: 0.5;
|
|
389
|
+
cursor: not-allowed;
|
|
390
|
+
}
|
|
391
|
+
`,ZoomInfo=dt$1.div`
|
|
392
|
+
font-size: 12px;
|
|
393
|
+
color: ${p=>p.$theme.colors.disabledText};
|
|
394
|
+
min-width: 40px;
|
|
395
|
+
text-align: center;
|
|
396
|
+
`,defaultTheme$1={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"md",size:"md",radius:"md",padding:"md",margin:"md",shadow:"md",lineHeight:"md"}},Header=React__default.memo(({fileName:p="\u672A\u77E5\u6587\u4EF6",currentPage:a=1,totalPage:y=0,tools:f={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!0},styles:_,onPrevPage:Y,onNextPage:W,onZoomIn:K,onZoomOut:M,onAnnotationToggle:b,onDownload:w,onRotateLeft:T,onRotateRight:S,onClose:v,scale:c=1,isAnnotating:t=!1,className:r})=>{const o=(_==null?void 0:_.theme)||defaultTheme$1;return console.log("Header\u7EC4\u4EF6\u6E32\u67D3 - currentPage:",a,"totalPage:",y),jsxs(HeaderContainer,{$theme:o,className:r,children:[jsx(FileInfo,{$theme:o,children:jsx(FileName,{$theme:o,children:p})}),jsxs(ToolBar,{$theme:o,children:[f.navigation&&jsxs(Fragment,{children:[jsx(ToolButton,{$theme:o,onClick:Y,disabled:a<=1,title:"\u4E0A\u4E00\u9875",children:jsx(ChevronLeft,{size:16})}),y>0&&jsxs(PageInfo,{$theme:o,children:[a," / ",y]}),jsx(ToolButton,{$theme:o,onClick:W,disabled:!y||a>=y,title:"\u4E0B\u4E00\u9875",children:jsx(ChevronRight,{size:16})})]}),f.zoom&&jsxs(Fragment,{children:[jsx(ToolButton,{$theme:o,onClick:M,disabled:c<=.3,title:"\u7F29\u5C0F",children:jsx(ZoomOut,{size:16})}),jsxs(ZoomInfo,{$theme:o,children:[Math.round(c*100),"%"]}),jsx(ToolButton,{$theme:o,onClick:K,disabled:c>=3,title:"\u653E\u5927",children:jsx(ZoomIn,{size:16})})]}),f.annotation&&jsx(ToolButton,{$theme:o,$active:t,onClick:b,title:t?"\u9000\u51FA\u6807\u6CE8":"\u5F00\u59CB\u6807\u6CE8",children:jsx(Pencil,{size:16})}),f.download&&jsx(ToolButton,{$theme:o,onClick:w,title:"\u4E0B\u8F7D",children:jsx(Download,{size:16})}),f.rotate&&jsxs(Fragment,{children:[jsx(ToolButton,{$theme:o,onClick:T,title:"\u5411\u5DE6\u65CB\u8F6C",children:jsx(RotateCcw,{size:16})}),jsx(ToolButton,{$theme:o,onClick:S,title:"\u5411\u53F3\u65CB\u8F6C",children:jsx(RotateCw,{size:16})})]}),f.close&&jsx(ToolButton,{$theme:o,onClick:v,title:"\u5173\u95ED",children:jsx(X,{size:16})})]})]})}),ReaderContainer=dt$1.div`
|
|
397
|
+
display: flex;
|
|
398
|
+
flex-direction: column;
|
|
399
|
+
height: 100%;
|
|
400
|
+
width: 100%;
|
|
401
|
+
background: ${p=>p.$theme.colors.background};
|
|
402
|
+
border: 1px solid ${p=>p.$theme.colors.border};
|
|
403
|
+
border-radius: ${p=>p.$theme.space.radius};
|
|
404
|
+
overflow: hidden;
|
|
405
|
+
min-height: 0;
|
|
406
|
+
position: relative; // 添加相对定位,用于loading遮罩的绝对定位
|
|
407
|
+
|
|
408
|
+
/* 添加动画样式 */
|
|
409
|
+
@keyframes spin {
|
|
410
|
+
0% {
|
|
411
|
+
transform: rotate(0deg);
|
|
412
|
+
}
|
|
413
|
+
100% {
|
|
414
|
+
transform: rotate(360deg);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
`,DefaultLoadingComponent=({status:p,theme:a})=>jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px",background:a.colors.background},children:[jsxs("div",{style:{position:"relative",width:"80px",height:"80px",marginBottom:"24px"},children:[jsx("div",{style:{width:"60px",height:"80px",background:a.colors.primary,borderRadius:"8px 8px 0 0",position:"relative",margin:"0 auto"},children:jsx("div",{style:{position:"absolute",top:"0",right:"0",width:"0",height:"0",borderStyle:"solid",borderWidth:"0 20px 20px 0",borderColor:`transparent ${a.colors.background} transparent transparent`}})}),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",borderRadius:"50%",background:a.colors.background,animation:"pulse 1.5s ease-in-out infinite"}})]}),jsx("div",{style:{fontSize:"16px",fontWeight:"500",color:a.colors.text,marginBottom:"8px",textAlign:"center"},children:p}),jsx("div",{style:{width:"200px",height:"4px",background:a.colors.border,borderRadius:"2px",overflow:"hidden",position:"relative"},children:jsx("div",{style:{width:"30%",height:"100%",background:a.colors.primary,borderRadius:"2px",animation:"loading-progress 2s ease-in-out infinite"}})}),jsx("style",{children:`
|
|
418
|
+
@keyframes pulse {
|
|
419
|
+
0%, 100% {
|
|
420
|
+
opacity: 1;
|
|
421
|
+
transform: translate(-50%, -50%) scale(1);
|
|
422
|
+
}
|
|
423
|
+
50% {
|
|
424
|
+
opacity: 0.5;
|
|
425
|
+
transform: translate(-50%, -50%) scale(1.1);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
@keyframes loading-progress {
|
|
430
|
+
0% {
|
|
431
|
+
transform: translateX(-100%);
|
|
432
|
+
}
|
|
433
|
+
50% {
|
|
434
|
+
transform: translateX(0%);
|
|
435
|
+
}
|
|
436
|
+
100% {
|
|
437
|
+
transform: translateX(100%);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
`})]}),ErrorContainer=dt$1.div`
|
|
441
|
+
display: flex;
|
|
442
|
+
flex-direction: column;
|
|
443
|
+
align-items: center;
|
|
444
|
+
justify-content: center;
|
|
445
|
+
height: 100%;
|
|
446
|
+
color: ${p=>p.$theme.colors.error};
|
|
447
|
+
text-align: center;
|
|
448
|
+
padding: 20px;
|
|
449
|
+
`,DEFAULT_STREAM_API_URL="http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream",CACHE_EXPIRY_TIME=300*1e3,defaultTheme={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"12px",size:"12px",radius:"4px",padding:"8px 12px",margin:"4px",shadow:"0 2px 4px rgba(0,0,0,0.1)",lineHeight:"1.5"}},GientechStreamReader=({convertedFilePath:p,fileName:a,fileType:y,csrfToken:f,initialPage:_=1,initialZoom:Y=1,totalPages:W,annotations:K=[],pageSize:M=5,streamApiUrl:b=DEFAULT_STREAM_API_URL,authorization:w,eventsEmit:T=()=>{},tools:S,styles:v,customComponents:c,className:t,headerClass:r,contentClass:o})=>{const[F,m]=useState(!0),[l,n]=useState("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[i,e]=useState(null),[E,x]=useState(_),[N,I]=useState(W||0),[St,Pt]=useState(Y),[bt,V]=useState(0),[O,z]=useState(null),[G,_t]=useState(null),[wt,Ot]=useState(""),[q,d]=useState(null),[u,P]=useState(null),[j,U]=useState({}),$=useRef(!1),s=useRef(!1),h=useRef({}),C=useRef({}),A=useRef(null),k=useRef(null),B=useRef(_),D=useRef(0);D.current+=1,console.log("[GientechStreamReader] render count:",D.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:y,currentPage:E,totalPages:N,hasMarkdown:!!wt,hasImage:!!G,hasText:!!q,hasHtml:!!u,isLoading:F,error:i});const g=(v==null?void 0:v.theme)||defaultTheme;useEffect(()=>{$.current=!1,s.current=!1},[y,p]);const At=useCallback(()=>{const xt={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let Rt;switch(y){case"pdf":case"pdf_slides":Rt={...xt,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":Rt={...xt,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":Rt={...xt,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":Rt={...xt,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:Rt=xt}return S?{...Rt,...S}:Rt},[y,S])(),H=useCallback((xt,Rt)=>{const Ut=Math.floor((xt-1)/Rt)*Rt+1;return`${Ut}-${Ut+Rt-1}`},[]),Q=useCallback(async xt=>{var Zt;if(!(y==="pdf"||y==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7\u7F13\u5B58\u68C0\u67E5`),null;console.log(`\u68C0\u67E5\u9875\u9762 ${xt} \u662F\u5426\u5728\u7F13\u5B58\u4E2D`);const Ut=h.current[xt];if(Ut&&Date.now()-Ut.timestamp<CACHE_EXPIRY_TIME)return console.log(`\u4F7F\u7528\u5355\u4E2A\u9875\u9762\u7F13\u5B58: ${xt}`),Ut.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${xt}`),Ut.pdfDocument):null;const $t=H(xt,M),qt=C.current[$t];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${$t}, \u5B58\u5728: ${!!qt}, \u5305\u542B\u9875\u9762: ${((Zt=qt==null?void 0:qt.pages)==null?void 0:Zt.join(", "))||"\u65E0"}`),qt&&Date.now()-qt.timestamp<CACHE_EXPIRY_TIME){if(qt.pages.includes(xt))return console.log(`\u4F7F\u7528chunk\u7F13\u5B58: ${xt} (chunk: ${$t})`),qt.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${xt}`),qt.pdfDocument):null;console.log(`\u9875\u9762 ${xt} \u4E0D\u5728chunk ${$t} \u4E2D\uFF0Cchunk\u5305\u542B: ${qt.pages.join(", ")}`)}return console.log(`\u9875\u9762 ${xt} \u4E0D\u5728\u4EFB\u4F55\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42`),null},[M,H,y]),Ct=useCallback(async xt=>{var Rt;try{if(!(y==="pdf"||y==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const $t=Math.floor((xt-1)/M)*M+1,qt=H(xt,M);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${$t} (\u5305\u542B\u9875\u9762 ${$t}-${$t+M-1})`);const Zt={"Content-Type":"application/json"};w&&(Zt.Authorization=w),f&&(Zt["X-CSRF-TOKEN-IN"]=f);const ie={convertedFilePath:p,pageNo:$t,pageSize:M},Jt=await axios.post(b,ie,{headers:Zt,responseType:"arraybuffer"}),oe=Jt.headers["x-csrf-token-out"]||Jt.headers["X-CSRF-TOKEN-OUT"];oe&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",oe),T("request_finish",oe));const ee=Array.from({length:M},(me,fe)=>$t+fe);return C.current[qt]={data:Jt.data,pages:ee,timestamp:Date.now(),totalPages:W},console.log(`\u7F13\u5B58PDF chunk\u6570\u636E: ${qt}, \u5305\u542B\u9875\u9762: ${ee.join(", ")}, \u8BF7\u6C42\u7684\u9875\u9762: ${xt}`),console.log("\u5F53\u524D\u6240\u6709\u7F13\u5B58:",Object.keys(C.current)),Jt.data}catch(Ut){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",Ut),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((Rt=Ut.response)==null?void 0:Rt.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[b,p,M,w,H,W,N,y,T]),Tt=useCallback(async(xt,Rt=!1)=>{var $t;if(!xt)return;if(!(y==="pdf"||y==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{Rt?(m(!0),n("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(m(!0),n(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${xt} \u9875...`)),e(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${xt}, \u521D\u59CB\u52A0\u8F7D: ${Rt}`);const qt=await Q(xt);if(qt)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${xt}`),z(qt),m(!1),n(""),console.log(`\u9875\u9762 ${xt} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),qt;const Zt=await Ct(xt),ie=await pt(Zt,{fileName:a||"Stream\u6587\u6863",fileType:"pdf",token:w});if(ie.error)throw new Error(ie.error);if(ie.type!=="pdf"||!(($t=ie.content)!=null&&$t.document))throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u6863");const Jt=ie.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",Jt),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof Jt),console.log("PDF\u6587\u6863\u65B9\u6CD5:",Jt?Object.getOwnPropertyNames(Object.getPrototypeOf(Jt)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",Jt?Jt.numPages:"\u65E0\u9875\u6570"),console.log("\u5F53\u524D\u8BF7\u6C42\u7684\u9875\u9762:",xt),console.log("PDF\u6587\u6863\u5305\u542B\u7684\u9875\u9762\u8303\u56F4:",Jt?`1-${Jt.numPages}`:"\u65E0\u9875\u6570"),z(Jt);const oe=H(xt,M);if(C.current[oe]&&(C.current[oe].pdfDocument=Jt,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${oe}`)),W)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${W}`),I(W);else if(Jt&&Jt.numPages){const ee=Jt.numPages;console.log(`\u7528\u6237\u672A\u4F20\u5165\u603B\u9875\u6570\uFF0C\u4ECEPDF\u6587\u6863\u83B7\u53D6\u5B9E\u9645\u603B\u9875\u6570: ${ee}`),I(ee)}return m(!1),n(""),console.log(`\u9875\u9762 ${xt} \u52A0\u8F7D\u5B8C\u6210`),Jt}catch(qt){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",qt),e(qt.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),m(!1),n(""),qt}},[Ct,a,w,N,Q,H,M,y]),It=useCallback(xt=>{if(!(y==="pdf"||y==="pdf_slides"))return!1;const Ut=h.current[xt];if(Ut&&Date.now()-Ut.timestamp<CACHE_EXPIRY_TIME)return!!Ut.pdfDocument;const $t=H(xt,M),qt=C.current[$t];return qt&&Date.now()-qt.timestamp<CACHE_EXPIRY_TIME?qt.pages.includes(xt)&&!!qt.pdfDocument:!1},[M,H,y]),kt=useCallback(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const xt=A.current;return xt&&Date.now()-xt.timestamp<CACHE_EXPIRY_TIME?(console.log("\u4F7F\u7528markdown\u5185\u5BB9\u7F13\u5B58"),xt.data):(console.log("markdown\u5185\u5BB9\u4E0D\u5728\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42"),null)},[]),Ht=useCallback(async()=>{var xt;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const Rt={"Content-Type":"application/json"};w&&(Rt.Authorization=w),f&&(Rt["X-CSRF-TOKEN-IN"]=f);const Ut={convertedFilePath:p};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",Ut);const $t=await axios.post(b,Ut,{headers:Rt,responseType:"text"}),qt=$t.headers["x-csrf-token-out"]||$t.headers["X-CSRF-TOKEN-OUT"];return qt&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",qt),T("request_finish",qt)),console.log("markdown\u54CD\u5E94\u72B6\u6001:",$t.status),console.log("markdown\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((xt=$t.data)==null?void 0:xt.length)||0),$t.data}catch(Rt){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",Rt),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${Rt.message}`)}},[p,w,b,T]),Wt=useCallback(async()=>{try{m(!0),n("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),e(null),console.log("\u5F00\u59CB\u52A0\u8F7D\u5B8C\u6574markdown\u6587\u6863");const xt=kt();if(xt)return console.log("\u4F7F\u7528\u7F13\u5B58\u7684markdown\u5185\u5BB9"),Ot(xt),m(!1),n(""),xt;const Rt=await Ht();return A.current={data:Rt,timestamp:Date.now()},Ot(Rt),m(!1),n(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),Rt}catch(xt){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",xt),e(xt.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),m(!1),n(""),xt}},[Ht,kt]),jt=useCallback(async()=>{try{const xt={"Content-Type":"application/json"};w&&(xt.Authorization=w),f&&(xt["X-CSRF-TOKEN-IN"]=f);const Rt={convertedFilePath:p},Ut=await axios.post(b,Rt,{headers:xt,responseType:"arraybuffer"}),$t=Ut.headers["x-csrf-token-out"]||Ut.headers["X-CSRF-TOKEN-OUT"];return $t&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",$t),T("request_finish",$t)),Ut.data}catch(xt){throw console.error("\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25:",xt),new Error(`\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25: ${xt.message}`)}},[p,w,b,T]),Xt=useCallback(async()=>{try{m(!0),n("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),e(null);const xt=await jt(),Rt=await pt(xt,{fileName:a||"\u56FE\u7247",fileType:"image",token:w});if(Rt.error)throw new Error(Rt.error);if(Rt.type!=="image"||!Rt.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return _t(Rt.content),m(!1),n(""),Rt.content}catch(xt){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",xt),e(xt.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),m(!1),n(""),xt}},[w,a,jt]),Vt=useCallback(async()=>{var xt;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}`);const Rt={"Content-Type":"application/json"};w&&(Rt.Authorization=w),f&&(Rt["X-CSRF-TOKEN-IN"]=f);const Ut={convertedFilePath:p};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",Ut);const $t=await axios.post(b,Ut,{headers:Rt,responseType:"arraybuffer"}),qt=$t.headers["x-csrf-token-out"]||$t.headers["X-CSRF-TOKEN-OUT"];return qt&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",qt),T("request_finish",qt)),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u72B6\u6001:",$t.status),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((xt=$t.data)==null?void 0:xt.byteLength)||0),$t.data}catch(Rt){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",Rt),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${Rt.message}`)}},[p,w,b,T]),te=useCallback(async()=>{try{if(console.log("=== loadGenericDocument \u88AB\u8C03\u7528 ==="),console.log("\u8C03\u7528\u6808:",new Error().stack),console.log("\u5F53\u524D\u65F6\u95F4:",new Date().toISOString()),$.current){console.log(`\u901A\u7528\u6587\u6863\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}`);return}if(s.current){console.log(`\u901A\u7528\u6587\u6863\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}`);return}const xt=`${y}_${p}`,Rt=j[xt];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${xt}, \u7F13\u5B58\u5B58\u5728: ${!!Rt}, \u7F13\u5B58\u65F6\u95F4: ${Rt?Date.now()-Rt.timestamp:"N/A"}ms`),Rt&&Date.now()-Rt.timestamp<CACHE_EXPIRY_TIME)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}`),y==="text"&&Rt.content?d(Rt.content):y==="html"&&Rt.content&&P(Rt.content),x(1),I(W||1),m(!1),n(""),Rt.content;$.current=!0,m(!0),n(`\u6B63\u5728\u52A0\u8F7D${y}\u6587\u6863...`),e(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}`);const Ut=await Vt(),$t=await pt(Ut,{fileName:a||`${y}\u6587\u6863`,fileType:y,token:w});if($t.error)throw new Error($t.error);let qt=null;if($t.type==="text"&&$t.content)d($t.content),qt=$t.content;else if($t.type==="html"&&$t.content)P($t.content),qt=$t.content;else if($t.type==="image"&&$t.content)_t($t.content),qt=$t.content;else{const ie=new TextDecoder("utf-8").decode(Ut);d({type:"text",content:ie}),qt={type:"text",content:ie}}if(qt){const Zt=`${y}_${p}`,ie={...j,[Zt]:{content:qt,timestamp:Date.now()}};U(ie),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}, \u7F13\u5B58\u952E: ${Zt}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",ie)}return m(!1),n(""),$.current=!1,s.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${y}`),$t}catch(xt){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",xt),e(xt.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),m(!1),n(""),$.current=!1,s.current=!0,xt}},[Vt,a,w]),Gt=useCallback(async xt=>{if(xt===B.current)return;if(F){console.log("\u9875\u9762\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42");return}if(!(y==="pdf"||y==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}console.log("PDF\u9875\u9762\u53D8\u5316:",xt,"\u5F53\u524D\u9875:",B.current),console.log(`\u9875\u9762 ${xt} \u662F\u5426\u5728\u7F13\u5B58\u4E2D:`,It(xt)),B.current=xt,x(xt);try{await Tt(xt,!1),T("pageChange",{pageNumber:xt,totalPages:W||N})}catch(Ut){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",Ut);const $t=B.current;x($t)}},[Tt,N,T,It,F,y]);useEffect(()=>{B.current=E,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",E)},[E]);const Yt=useCallback(xt=>{Pt(xt),T("zoomChange",{scale:xt})},[T]),Kt=useCallback(()=>{T("viewer:close")},[T]),Qt=useCallback(()=>{const xt=Math.min(3,St+.1);Yt(xt)},[St,Yt]),le=useCallback(()=>{const xt=Math.max(.3,St-.1);Yt(xt)},[St,Yt]),de=useCallback(()=>{const xt=(bt-90+360)%360;V(xt),T("rotateChange",{rotation:xt})},[bt,T]),he=useCallback(()=>{const xt=(bt+90)%360;V(xt),T("rotateChange",{rotation:xt})},[bt,T]),Dt=useCallback(()=>{if(!(y==="pdf"||y==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const Rt=B.current-1;Rt>=1&&Gt(Rt)},[Gt,y]),J=useCallback(()=>{if(!(y==="pdf"||y==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${y} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const Rt=B.current+1,Ut=W||N;Ut&&Rt<=Ut&&Gt(Rt)},[N,Gt,y]),Z=useCallback(()=>{const xt=Date.now();Object.keys(h.current).forEach(Rt=>{const Ut=h.current[parseInt(Rt)];xt-Ut.timestamp>CACHE_EXPIRY_TIME&&(delete h.current[parseInt(Rt)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${Rt}`))}),Object.keys(C.current).forEach(Rt=>{const Ut=C.current[Rt];xt-Ut.timestamp>CACHE_EXPIRY_TIME&&(delete C.current[Rt],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${Rt}`))}),A.current&&xt-A.current.timestamp>CACHE_EXPIRY_TIME&&(A.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),U(Rt=>{const Ut={...Rt};return Object.keys(Ut).forEach($t=>{xt-Ut[$t].timestamp>CACHE_EXPIRY_TIME&&(delete Ut[$t],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${$t}`))}),Ut})},[]),Nt=useCallback(()=>{if(a)return a;try{const xt=new URL(p);return decodeURIComponent(xt.pathname.split("/").pop()||"")||"Stream\u6587\u6863"}catch{const xt=p.split("/");return decodeURIComponent(xt[xt.length-1])||"Stream\u6587\u6863"}},[p,a]);if(useEffect(()=>{const xt=setInterval(Z,CACHE_EXPIRY_TIME);return()=>clearInterval(xt)},[Z]),useEffect(()=>()=>{h.current={},C.current={},A.current=null,U({}),console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF0C\u6E05\u7406\u6240\u6709\u7F13\u5B58")},[]),useEffect(()=>{console.log("=== useEffect \u88AB\u89E6\u53D1 ==="),console.log("\u89E6\u53D1\u65F6\u95F4:",new Date().toISOString()),console.log("\u89E6\u53D1\u539F\u56E0:",{initialPage:_,fileType:y}),(async()=>{try{const Rt=y==="pdf"||y==="pdf_slides",Ut=Rt&&_||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",y,"\u6709\u6548\u9875\u7801:",Ut,"\u662F\u5426PDF:",Rt),y==="markdown"||y==="markdown_table"?(await Wt(),x(1),I(W||1),T("pageChange",{pageNumber:1,totalPages:W||1})):y==="image"?(await Xt(),x(1),I(W||1),V(0),T("pageChange",{pageNumber:1,totalPages:W||1})):Rt?(await Tt(Ut,!0),x(Ut),setTimeout(()=>{T("pageChange",{pageNumber:Ut,totalPages:W||N})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",y),await te(),x(1),I(W||1),T("pageChange",{pageNumber:1,totalPages:W||1}))}catch(Rt){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",Rt)}})()},[_,y,p]),i)return jsx(ReaderContainer,{$theme:g,className:t,children:c!=null&&c.ErrorComponent?jsx(c.ErrorComponent,{error:i,theme:g}):jsxs(ErrorContainer,{$theme:g,children:[jsx("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),jsx("div",{style:{fontSize:"12px",marginTop:"8px"},children:i})]})});const zt=useMemo(()=>Math.floor((E-1)/M)*M+1,[E,M]);return F?jsxs(ReaderContainer,{$theme:g,className:t,children:[jsx(Header,{fileName:Nt(),currentPage:E,totalPage:N,scale:St,isAnnotating:!1,tools:At,styles:v,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:Kt,className:r}),c!=null&&c.LoadingComponent?jsx(c.LoadingComponent,{status:l,theme:g}):jsx(DefaultLoadingComponent,{status:l,theme:g})]}):jsxs(ReaderContainer,{$theme:g,className:t,children:[jsx(Header,{fileName:Nt(),currentPage:E,totalPage:N,scale:St,isAnnotating:!1,tools:{...At,navigation:y==="pdf"||y==="pdf_slides"?At.navigation:!1,rotate:y==="image"},styles:v,onPrevPage:Dt,onNextPage:J,onZoomIn:Qt,onZoomOut:le,onRotateLeft:y==="image"?de:void 0,onRotateRight:y==="image"?he:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:Kt,className:r}),y==="markdown"||y==="markdown_table"?jsxs("div",{ref:k,style:{flex:1,overflow:"auto",position:"relative"},className:o,children:[jsx(qe,{data:{content:wt,...Nt()&&{fileName:Nt()},...y&&{fileType:y},...N&&{totalPages:N}},annotationData:K,totalPage:N,currentPage:E,scale:St,eventsEmit:(xt,Rt)=>{console.log("Fviewer\u4E8B\u4EF6:",xt,Rt),T(xt==="md_annotation_add"?"md_annotation_add":xt==="table_annotation_add"?"table_annotation_add":xt,Rt)},styles:v,tools:At,customComponents:c,contentClass:o}),(console.log("=== \u4F20\u9012\u7ED9Fviewer\u7684markdown\u5185\u5BB9 ==="),console.log("markdownContent:",wt),console.log("markdownContent\u957F\u5EA6:",wt.length),console.log("markdownContent\u524D100\u5B57\u7B26:",wt.substring(0,100)),console.log("markdownContent\u540E100\u5B57\u7B26:",wt.substring(wt.length-100)),null)]}):y==="image"?jsx(qe,{data:{content:G,...Nt()&&{fileName:Nt()},...y&&{fileType:y}},annotationData:K,totalPage:1,currentPage:1,scale:St,rotation:bt,eventsEmit:T,styles:v,tools:{...At,navigation:!1,rotate:!0},customComponents:c,contentClass:o}):y==="pdf"||y==="pdf_slides"?jsx(qe,{data:{content:{document:O},...Nt()&&{fileName:Nt()},...y&&{fileType:y},...N&&{totalPages:N},pdfStartPage:zt},annotationData:K,totalPage:N,currentPage:E,scale:St,initialZoom:Y,eventsEmit:(xt,Rt)=>{console.log("Fviewer\u4E8B\u4EF6:",xt,Rt),xt==="scaleChange"&&console.log("\u6536\u5230\u7F29\u653E\u53D8\u5316\u4E8B\u4EF6:",Rt),T(xt,Rt)},styles:v,tools:At,customComponents:c,contentClass:o}):jsx(qe,{data:{content:q||u||{type:"text",content:"\u6587\u4EF6\u5185\u5BB9\u52A0\u8F7D\u4E2D..."},...Nt()&&{fileName:Nt()},...y&&{fileType:y}},annotationData:K,totalPage:1,currentPage:1,scale:St,eventsEmit:T,styles:v,tools:{...At,navigation:!1},customComponents:c,contentClass:o})]})};export{ChevronLeft as C,GientechStreamReader as G,commonjsRequire as c,require$$0 as r,yt as y};
|