@gientech/modual 1.4.7 → 1.5.2

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.
Files changed (65) hide show
  1. package/dist/assets/GientechStreamReader-KtCNi1G3.js +447 -0
  2. package/dist/assets/Input-CNqIA41v.js +236 -0
  3. package/dist/assets/index-Bof0D4vl.js +1088 -0
  4. package/dist/assets/{index-BVENTW1Q.js → index-C5RhLYRh.js} +1 -1
  5. package/dist/assets/index-COcmK9my.js +1 -0
  6. package/dist/assets/index-CysDmrpo.js +1798 -0
  7. package/dist/assets/{index-7rZAt9P3.js → index-DP8Ki8qW.js} +1 -1
  8. package/dist/assets/index-pybYlMAT.js +11 -0
  9. package/dist/assets/{plus-CrtEUXaQ.js → plus-CzbYbK8K.js} +1 -1
  10. package/dist/assets/style3.css +1 -1
  11. package/dist/assets/worker-BbpylX7l.js +13 -0
  12. package/dist/assets/{x-Dr3EBTzJ.js → x-DdRafKQU.js} +1 -1
  13. package/dist/chat.d.ts +17 -0
  14. package/dist/chat.js +2539 -52
  15. package/dist/database.js +2 -2
  16. package/dist/databaseId.js +1 -11
  17. package/dist/databaseTable.js +2 -2
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.js +1 -14
  20. package/dist/modelManage.js +1 -1
  21. package/dist/package.json +1 -1
  22. package/dist/sensitive.js +1 -1
  23. package/dist/streamFilesReader.js +1 -1
  24. package/dist/worker/pdf.worker1.min.js +23 -0
  25. package/package.json +6 -6
  26. package/public/worker/pdf.worker1.min.js +23 -0
  27. package/scripts/README.md +133 -133
  28. package/scripts/build-demo.js +88 -88
  29. package/scripts/demo-selector.js +216 -216
  30. package/scripts/preview-demo.js +130 -130
  31. package/scripts/run-demo.bat +34 -34
  32. package/src/assets/img/close.png +0 -0
  33. package/src/assets/img/database.png +0 -0
  34. package/src/assets/img/downLoad.png +0 -0
  35. package/src/assets/img/graphIcon.png +0 -0
  36. package/src/assets/img/pdf.png +0 -0
  37. package/src/assets/img/singleQa.png +0 -0
  38. package/src/assets/img/webSearch.png +0 -0
  39. package/src/examples/chat/index.tsx +5 -29
  40. package/src/main.tsx.backup +5 -5
  41. package/src/modules/chat/ReferenceBar.tsx +522 -0
  42. package/src/modules/chat/constants.tsx +29 -6
  43. package/src/modules/chat/index.tsx +118 -4
  44. package/src/modules/chat/referenceCom/DeleteModal.tsx +75 -0
  45. package/src/modules/chat/referenceCom/DrawerContent.tsx +136 -0
  46. package/src/modules/chat/referenceCom/DrawerDatabase.tsx +110 -0
  47. package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +86 -0
  48. package/src/modules/chat/referenceCom/DrawerPreview.tsx +73 -0
  49. package/src/modules/chat/referenceCom/DrawerTitle.tsx +26 -0
  50. package/src/modules/chat/referenceCom/RenameModal.tsx +86 -0
  51. package/src/modules/chat/referenceCom/TagCom.tsx +30 -0
  52. package/src/modules/chat/style.css +3 -0
  53. package/src/modules/chat/utils/index.ts +326 -0
  54. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +231 -18
  55. package/src/utils/testconfigs/index.ts +1 -1
  56. package/stats.html +1 -1
  57. package/dist/assets/AppLoading-mci3gLZt.js +0 -414
  58. package/dist/assets/GientechStreamReader-4496nAm0.js +0 -446
  59. package/dist/assets/index-Bb8_WB-l.js +0 -1
  60. package/dist/assets/index-BpJ9Bm5x.js +0 -21
  61. package/dist/assets/index-CNxDI4h-.js +0 -1078
  62. package/dist/assets/index-CWzpBU29.js +0 -1
  63. package/dist/assets/index-D1m34Ij7.js +0 -1429
  64. package/dist/assets/index-_gBtdXQV.js +0 -585
  65. package/dist/assets/style4.css +0 -1
@@ -0,0 +1,447 @@
1
+ var Zs=Object.defineProperty;var bs=d=>{throw TypeError(d)};var Qs=(d,e,b)=>e in d?Zs(d,e,{enumerable:!0,configurable:!0,writable:!0,value:b}):d[e]=b;var Fe=(d,e,b)=>Qs(d,typeof e!="symbol"?e+"":e,b),Ln=(d,e,b)=>e.has(d)||bs("Cannot "+b);var t=(d,e,b)=>(Ln(d,e,"read from private field"),b?b.call(d):e.get(d)),Tt=(d,e,b)=>e.has(d)?bs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(d):e.set(d,b),Rt=(d,e,b,i)=>(Ln(d,e,"write to private field"),i?i.call(d,b):e.set(d,b),b),K=(d,e,b)=>(Ln(d,e,"access private method"),b);var fn=(d,e,b,i)=>({set _(y){Rt(d,e,y,b)},get _(){return t(d,e,i)}});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(d){throw new Error('Could not dynamically require "'+d+'". 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(e,b){module.exports=e.pdfjsLib=b()})(globalThis,()=>(()=>{var __webpack_modules__=[,((d,e)=>{var Ee;Object.defineProperty(e,"__esModule",{value:!0}),e.VerbosityLevel=e.Util=e.UnknownErrorException=e.UnexpectedResponseException=e.TextRenderingMode=e.RenderingIntentFlag=e.PromiseCapability=e.PermissionFlag=e.PasswordResponses=e.PasswordException=e.PageActionEventType=e.OPS=e.MissingPDFException=e.MAX_IMAGE_SIZE_TO_CACHE=e.LINE_FACTOR=e.LINE_DESCENT_FACTOR=e.InvalidPDFException=e.ImageKind=e.IDENTITY_MATRIX=e.FormatError=e.FeatureTest=e.FONT_IDENTITY_MATRIX=e.DocumentActionEventType=e.CMapCompressionType=e.BaseException=e.BASELINE_FACTOR=e.AnnotationType=e.AnnotationReplyType=e.AnnotationPrefix=e.AnnotationMode=e.AnnotationFlag=e.AnnotationFieldFlag=e.AnnotationEditorType=e.AnnotationEditorPrefix=e.AnnotationEditorParamsType=e.AnnotationBorderStyleType=e.AnnotationActionEventType=e.AbortException=void 0,e.assert=D,e.bytesToString=It,e.createValidAbsoluteUrl=J,e.getModificationDate=Kt,e.getUuid=re,e.getVerbosityLevel=U,e.info=G,e.isArrayBuffer=bt,e.isArrayEqual=Jt,e.isNodeJS=void 0,e.normalizeUnicode=Qt,e.objectFromMap=Xt,e.objectSize=Ut,e.setVerbosityLevel=wt,e.shadow=S,e.string32=jt,e.stringToBytes=Bt,e.stringToPDFString=Nt,e.stringToUTF8String=zt,e.unreachable=_t,e.utf8StringToString=qt,e.warn=H;const b=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");e.isNodeJS=b;const i=[1,0,0,1,0,0];e.IDENTITY_MATRIX=i;const y=[.001,0,0,.001,0,0];e.FONT_IDENTITY_MATRIX=y;const Q=1e7;e.MAX_IMAGE_SIZE_TO_CACHE=Q;const z=1.35;e.LINE_FACTOR=z;const xt=.35;e.LINE_DESCENT_FACTOR=xt;const B=xt/z;e.BASELINE_FACTOR=B;const k={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};e.RenderingIntentFlag=k;const f={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};e.AnnotationMode=f;const P="pdfjs_internal_editor_";e.AnnotationEditorPrefix=P;const T={DISABLE:-1,NONE:0,FREETEXT:3,STAMP:13,INK:15};e.AnnotationEditorType=T;const A={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23};e.AnnotationEditorParamsType=A;const g={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};e.PermissionFlag=g;const E={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};e.TextRenderingMode=E;const _={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};e.ImageKind=_;const c={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};e.AnnotationType=c;const C={GROUP:"Group",REPLY:"R"};e.AnnotationReplyType=C;const I={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};e.AnnotationFlag=I;const m={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};e.AnnotationFieldFlag=m;const r={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};e.AnnotationBorderStyleType=r;const h={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"};e.AnnotationActionEventType=h;const a={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};e.DocumentActionEventType=a;const l={O:"PageOpen",C:"PageClose"};e.PageActionEventType=l;const u={ERRORS:0,WARNINGS:1,INFOS:5};e.VerbosityLevel=u;const R={NONE:0,BINARY:1};e.CMapCompressionType=R;const o={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,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};e.OPS=o;const F={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};e.PasswordResponses=F;let $=u.WARNINGS;function wt(Gt){Number.isInteger(Gt)&&($=Gt)}function U(){return $}function G(Gt){$>=u.INFOS&&console.log(`Info: ${Gt}`)}function H(Gt){$>=u.WARNINGS&&console.log(`Warning: ${Gt}`)}function _t(Gt){throw new Error(Gt)}function D(Gt,Pt){Gt||_t(Pt)}function W(Gt){switch(Gt==null?void 0:Gt.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function J(Gt,Pt=null,Mt=null){if(!Gt)return null;try{if(Mt&&typeof Gt=="string"){if(Mt.addDefaultProtocol&&Gt.startsWith("www.")){const ge=Gt.match(/\./g);(ge==null?void 0:ge.length)>=2&&(Gt=`http://${Gt}`)}if(Mt.tryConvertEncoding)try{Gt=zt(Gt)}catch{}}const te=Pt?new URL(Gt,Pt):new URL(Gt);if(W(te))return te}catch{}return null}function S(Gt,Pt,Mt,te=!1){return Object.defineProperty(Gt,Pt,{value:Mt,enumerable:!te,configurable:!0,writable:!1}),Mt}const n=(function(){function Pt(Mt,te){this.constructor===Pt&&_t("Cannot initialize BaseException."),this.message=Mt,this.name=te}return Pt.prototype=new Error,Pt.constructor=Pt,Pt})();e.BaseException=n;class s extends n{constructor(Pt,Mt){super(Pt,"PasswordException"),this.code=Mt}}e.PasswordException=s;class p extends n{constructor(Pt,Mt){super(Pt,"UnknownErrorException"),this.details=Mt}}e.UnknownErrorException=p;class M extends n{constructor(Pt){super(Pt,"InvalidPDFException")}}e.InvalidPDFException=M;class O extends n{constructor(Pt){super(Pt,"MissingPDFException")}}e.MissingPDFException=O;class L extends n{constructor(Pt,Mt){super(Pt,"UnexpectedResponseException"),this.status=Mt}}e.UnexpectedResponseException=L;class V extends n{constructor(Pt){super(Pt,"FormatError")}}e.FormatError=V;class At extends n{constructor(Pt){super(Pt,"AbortException")}}e.AbortException=At;function It(Gt){(typeof Gt!="object"||(Gt==null?void 0:Gt.length)===void 0)&&_t("Invalid argument for bytesToString");const Pt=Gt.length,Mt=8192;if(Pt<Mt)return String.fromCharCode.apply(null,Gt);const te=[];for(let ge=0;ge<Pt;ge+=Mt){const de=Math.min(ge+Mt,Pt),j=Gt.subarray(ge,de);te.push(String.fromCharCode.apply(null,j))}return te.join("")}function Bt(Gt){typeof Gt!="string"&&_t("Invalid argument for stringToBytes");const Pt=Gt.length,Mt=new Uint8Array(Pt);for(let te=0;te<Pt;++te)Mt[te]=Gt.charCodeAt(te)&255;return Mt}function jt(Gt){return String.fromCharCode(Gt>>24&255,Gt>>16&255,Gt>>8&255,Gt&255)}function Ut(Gt){return Object.keys(Gt).length}function Xt(Gt){const Pt=Object.create(null);for(const[Mt,te]of Gt)Pt[Mt]=te;return Pt}function vt(){const Gt=new Uint8Array(4);return Gt[0]=1,new Uint32Array(Gt.buffer,0,1)[0]===1}function kt(){try{return new Function(""),!0}catch{return!1}}class v{static get isLittleEndian(){return S(this,"isLittleEndian",vt())}static get isEvalSupported(){return S(this,"isEvalSupported",kt())}static get isOffscreenCanvasSupported(){return S(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator>"u"?S(this,"platform",{isWin:!1,isMac:!1}):S(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}static get isCSSRoundSupported(){var Pt,Mt;return S(this,"isCSSRoundSupported",(Mt=(Pt=globalThis.CSS)==null?void 0:Pt.supports)==null?void 0:Mt.call(Pt,"width: round(1.5px, 1px)"))}}e.FeatureTest=v;const N=[...Array(256).keys()].map(Gt=>Gt.toString(16).padStart(2,"0"));class Z{static makeHexColor(Pt,Mt,te){return`#${N[Pt]}${N[Mt]}${N[te]}`}static scaleMinMax(Pt,Mt){let te;Pt[0]?(Pt[0]<0&&(te=Mt[0],Mt[0]=Mt[1],Mt[1]=te),Mt[0]*=Pt[0],Mt[1]*=Pt[0],Pt[3]<0&&(te=Mt[2],Mt[2]=Mt[3],Mt[3]=te),Mt[2]*=Pt[3],Mt[3]*=Pt[3]):(te=Mt[0],Mt[0]=Mt[2],Mt[2]=te,te=Mt[1],Mt[1]=Mt[3],Mt[3]=te,Pt[1]<0&&(te=Mt[2],Mt[2]=Mt[3],Mt[3]=te),Mt[2]*=Pt[1],Mt[3]*=Pt[1],Pt[2]<0&&(te=Mt[0],Mt[0]=Mt[1],Mt[1]=te),Mt[0]*=Pt[2],Mt[1]*=Pt[2]),Mt[0]+=Pt[4],Mt[1]+=Pt[4],Mt[2]+=Pt[5],Mt[3]+=Pt[5]}static transform(Pt,Mt){return[Pt[0]*Mt[0]+Pt[2]*Mt[1],Pt[1]*Mt[0]+Pt[3]*Mt[1],Pt[0]*Mt[2]+Pt[2]*Mt[3],Pt[1]*Mt[2]+Pt[3]*Mt[3],Pt[0]*Mt[4]+Pt[2]*Mt[5]+Pt[4],Pt[1]*Mt[4]+Pt[3]*Mt[5]+Pt[5]]}static applyTransform(Pt,Mt){const te=Pt[0]*Mt[0]+Pt[1]*Mt[2]+Mt[4],ge=Pt[0]*Mt[1]+Pt[1]*Mt[3]+Mt[5];return[te,ge]}static applyInverseTransform(Pt,Mt){const te=Mt[0]*Mt[3]-Mt[1]*Mt[2],ge=(Pt[0]*Mt[3]-Pt[1]*Mt[2]+Mt[2]*Mt[5]-Mt[4]*Mt[3])/te,de=(-Pt[0]*Mt[1]+Pt[1]*Mt[0]+Mt[4]*Mt[1]-Mt[5]*Mt[0])/te;return[ge,de]}static getAxialAlignedBoundingBox(Pt,Mt){const te=this.applyTransform(Pt,Mt),ge=this.applyTransform(Pt.slice(2,4),Mt),de=this.applyTransform([Pt[0],Pt[3]],Mt),j=this.applyTransform([Pt[2],Pt[1]],Mt);return[Math.min(te[0],ge[0],de[0],j[0]),Math.min(te[1],ge[1],de[1],j[1]),Math.max(te[0],ge[0],de[0],j[0]),Math.max(te[1],ge[1],de[1],j[1])]}static inverseTransform(Pt){const Mt=Pt[0]*Pt[3]-Pt[1]*Pt[2];return[Pt[3]/Mt,-Pt[1]/Mt,-Pt[2]/Mt,Pt[0]/Mt,(Pt[2]*Pt[5]-Pt[4]*Pt[3])/Mt,(Pt[4]*Pt[1]-Pt[5]*Pt[0])/Mt]}static singularValueDecompose2dScale(Pt){const Mt=[Pt[0],Pt[2],Pt[1],Pt[3]],te=Pt[0]*Mt[0]+Pt[1]*Mt[2],ge=Pt[0]*Mt[1]+Pt[1]*Mt[3],de=Pt[2]*Mt[0]+Pt[3]*Mt[2],j=Pt[2]*Mt[1]+Pt[3]*Mt[3],$t=(te+j)/2,Y=Math.sqrt((te+j)**2-4*(te*j-de*ge))/2,Lt=$t+Y||1,Vt=$t-Y||1;return[Math.sqrt(Lt),Math.sqrt(Vt)]}static normalizeRect(Pt){const Mt=Pt.slice(0);return Pt[0]>Pt[2]&&(Mt[0]=Pt[2],Mt[2]=Pt[0]),Pt[1]>Pt[3]&&(Mt[1]=Pt[3],Mt[3]=Pt[1]),Mt}static intersect(Pt,Mt){const te=Math.max(Math.min(Pt[0],Pt[2]),Math.min(Mt[0],Mt[2])),ge=Math.min(Math.max(Pt[0],Pt[2]),Math.max(Mt[0],Mt[2]));if(te>ge)return null;const de=Math.max(Math.min(Pt[1],Pt[3]),Math.min(Mt[1],Mt[3])),j=Math.min(Math.max(Pt[1],Pt[3]),Math.max(Mt[1],Mt[3]));return de>j?null:[te,de,ge,j]}static bezierBoundingBox(Pt,Mt,te,ge,de,j,$t,Y){const Lt=[],Vt=[[],[]];let Wt,w,x,q,Dt,Ot,Ht,Yt;for(let he=0;he<2;++he){if(he===0?(w=6*Pt-12*te+6*de,Wt=-3*Pt+9*te-9*de+3*$t,x=3*te-3*Pt):(w=6*Mt-12*ge+6*j,Wt=-3*Mt+9*ge-9*j+3*Y,x=3*ge-3*Mt),Math.abs(Wt)<1e-12){if(Math.abs(w)<1e-12)continue;q=-x/w,0<q&&q<1&&Lt.push(q);continue}Ht=w*w-4*x*Wt,Yt=Math.sqrt(Ht),!(Ht<0)&&(Dt=(-w+Yt)/(2*Wt),0<Dt&&Dt<1&&Lt.push(Dt),Ot=(-w-Yt)/(2*Wt),0<Ot&&Ot<1&&Lt.push(Ot))}let ee=Lt.length,se;const Zt=ee;for(;ee--;)q=Lt[ee],se=1-q,Vt[0][ee]=se*se*se*Pt+3*se*se*q*te+3*se*q*q*de+q*q*q*$t,Vt[1][ee]=se*se*se*Mt+3*se*se*q*ge+3*se*q*q*j+q*q*q*Y;return Vt[0][Zt]=Pt,Vt[1][Zt]=Mt,Vt[0][Zt+1]=$t,Vt[1][Zt+1]=Y,Vt[0].length=Vt[1].length=Zt+2,[Math.min(...Vt[0]),Math.min(...Vt[1]),Math.max(...Vt[0]),Math.max(...Vt[1])]}}e.Util=Z;const St=[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 Nt(Gt){if(Gt[0]>="\xEF"){let Mt;if(Gt[0]==="\xFE"&&Gt[1]==="\xFF"?Mt="utf-16be":Gt[0]==="\xFF"&&Gt[1]==="\xFE"?Mt="utf-16le":Gt[0]==="\xEF"&&Gt[1]==="\xBB"&&Gt[2]==="\xBF"&&(Mt="utf-8"),Mt)try{const te=new TextDecoder(Mt,{fatal:!0}),ge=Bt(Gt);return te.decode(ge)}catch(te){H(`stringToPDFString: "${te}".`)}}const Pt=[];for(let Mt=0,te=Gt.length;Mt<te;Mt++){const ge=St[Gt.charCodeAt(Mt)];Pt.push(ge?String.fromCharCode(ge):Gt.charAt(Mt))}return Pt.join("")}function zt(Gt){return decodeURIComponent(escape(Gt))}function qt(Gt){return unescape(encodeURIComponent(Gt))}function bt(Gt){return typeof Gt=="object"&&(Gt==null?void 0:Gt.byteLength)!==void 0}function Jt(Gt,Pt){if(Gt.length!==Pt.length)return!1;for(let Mt=0,te=Gt.length;Mt<te;Mt++)if(Gt[Mt]!==Pt[Mt])return!1;return!0}function Kt(Gt=new Date){return[Gt.getUTCFullYear().toString(),(Gt.getUTCMonth()+1).toString().padStart(2,"0"),Gt.getUTCDate().toString().padStart(2,"0"),Gt.getUTCHours().toString().padStart(2,"0"),Gt.getUTCMinutes().toString().padStart(2,"0"),Gt.getUTCSeconds().toString().padStart(2,"0")].join("")}class ce{constructor(){Tt(this,Ee,!1);this.promise=new Promise((Pt,Mt)=>{this.resolve=te=>{Rt(this,Ee,!0),Pt(te)},this.reject=te=>{Rt(this,Ee,!0),Mt(te)}})}get settled(){return t(this,Ee)}}Ee=new WeakMap,e.PromiseCapability=ce;let oe=null,me=null;function Qt(Gt){return oe||(oe=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,me=new Map([["\uFB05","\u017Ft"]])),Gt.replaceAll(oe,(Pt,Mt,te)=>Mt?Mt.normalize("NFKC"):me.get(te))}function re(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const Gt=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(Gt);else for(let Pt=0;Pt<32;Pt++)Gt[Pt]=Math.floor(Math.random()*255);return It(Gt)}const pe="pdfjs_internal_id_";e.AnnotationPrefix=pe}),((__unused_webpack_module,exports,__w_pdfjs_require__)=>{var d,b,i,y,ln,En,xt,B,k,f,P,T,A,g,E,vn,c,C,On,m,r;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,Object.defineProperty(exports,"SVGGraphics",{enumerable:!0,get:function(){return _displaySvg.SVGGraphics}}),exports.build=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_displayNode_utils=__w_pdfjs_require__(10),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_displayFetch_stream=__w_pdfjs_require__(19),_displayNetwork=__w_pdfjs_require__(22),_displayNode_stream=__w_pdfjs_require__(23),_displaySvg=__w_pdfjs_require__(24),_xfa_text=__w_pdfjs_require__(25);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_util.isNodeJS?_displayNode_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_util.isNodeJS?_displayNode_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultFilterFactory=_util.isNodeJS?_displayNode_utils.NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;const DefaultStandardFontDataFactory=_util.isNodeJS?_displayNode_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;function getDocument(a){if(typeof a=="string"||a instanceof URL?a={url:a}:(0,_util.isArrayBuffer)(a)&&(a={data:a}),typeof a!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!a.url&&!a.data&&!a.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const l=new PDFDocumentLoadingTask,{docId:u}=l,R=a.url?getUrlProp(a.url):null,o=a.data?getDataProp(a.data):null,F=a.httpHeaders||null,$=a.withCredentials===!0,wt=a.password??null,U=a.range instanceof PDFDataRangeTransport?a.range:null,G=Number.isInteger(a.rangeChunkSize)&&a.rangeChunkSize>0?a.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE;let H=a.worker instanceof PDFWorker?a.worker:null;const _t=a.verbosity,D=typeof a.docBaseUrl=="string"&&!(0,_display_utils.isDataScheme)(a.docBaseUrl)?a.docBaseUrl:null,W=typeof a.cMapUrl=="string"?a.cMapUrl:null,J=a.cMapPacked!==!1,S=a.CMapReaderFactory||DefaultCMapReaderFactory,n=typeof a.standardFontDataUrl=="string"?a.standardFontDataUrl:null,s=a.StandardFontDataFactory||DefaultStandardFontDataFactory,p=a.stopAtErrors!==!0,M=Number.isInteger(a.maxImageSize)&&a.maxImageSize>-1?a.maxImageSize:-1,O=a.isEvalSupported!==!1,L=typeof a.isOffscreenCanvasSupported=="boolean"?a.isOffscreenCanvasSupported:!_util.isNodeJS,V=Number.isInteger(a.canvasMaxAreaInBytes)?a.canvasMaxAreaInBytes:-1,At=typeof a.disableFontFace=="boolean"?a.disableFontFace:_util.isNodeJS,It=a.fontExtraProperties===!0,Bt=a.enableXfa===!0,jt=a.ownerDocument||globalThis.document,Ut=a.disableRange===!0,Xt=a.disableStream===!0,vt=a.disableAutoFetch===!0,kt=a.pdfBug===!0,v=U?U.length:a.length??NaN,N=typeof a.useSystemFonts=="boolean"?a.useSystemFonts:!_util.isNodeJS&&!At,Z=typeof a.useWorkerFetch=="boolean"?a.useWorkerFetch:S===_display_utils.DOMCMapReaderFactory&&s===_display_utils.DOMStandardFontDataFactory&&W&&n&&(0,_display_utils.isValidFetchUrl)(W,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(n,document.baseURI),St=a.canvasFactory||new DefaultCanvasFactory({ownerDocument:jt}),Nt=a.filterFactory||new DefaultFilterFactory({docId:u,ownerDocument:jt}),zt=null;(0,_util.setVerbosityLevel)(_t);const qt={canvasFactory:St,filterFactory:Nt};if(Z||(qt.cMapReaderFactory=new S({baseUrl:W,isCompressed:J}),qt.standardFontDataFactory=new s({baseUrl:n})),!H){const Kt={verbosity:_t,port:_worker_options.GlobalWorkerOptions.workerPort};H=Kt.port?PDFWorker.fromPort(Kt):new PDFWorker(Kt),l._worker=H}const bt={docId:u,apiVersion:"3.11.174",data:o,password:wt,disableAutoFetch:vt,rangeChunkSize:G,length:v,docBaseUrl:D,enableXfa:Bt,evaluatorOptions:{maxImageSize:M,disableFontFace:At,ignoreErrors:p,isEvalSupported:O,isOffscreenCanvasSupported:L,canvasMaxAreaInBytes:V,fontExtraProperties:It,useSystemFonts:N,cMapUrl:Z?W:null,standardFontDataUrl:Z?n:null}},Jt={ignoreErrors:p,isEvalSupported:O,disableFontFace:At,fontExtraProperties:It,enableXfa:Bt,ownerDocument:jt,disableAutoFetch:vt,pdfBug:kt,styleElement:zt};return H.promise.then(function(){if(l.destroyed)throw new Error("Loading aborted");const Kt=_fetchDocument(H,bt),ce=new Promise(function(oe){let me;U?me=new _transport_stream.PDFDataTransportStream({length:v,initialData:U.initialData,progressiveDone:U.progressiveDone,contentDispositionFilename:U.contentDispositionFilename,disableRange:Ut,disableStream:Xt},U):o||(me=(re=>_util.isNodeJS?new _displayNode_stream.PDFNodeStream(re):(0,_display_utils.isValidFetchUrl)(re.url)?new _displayFetch_stream.PDFFetchStream(re):new _displayNetwork.PDFNetworkStream(re))({url:R,length:v,httpHeaders:F,withCredentials:$,rangeChunkSize:G,disableRange:Ut,disableStream:Xt})),oe(me)});return Promise.all([Kt,ce]).then(function([oe,me]){if(l.destroyed)throw new Error("Loading aborted");const Qt=new _message_handler.MessageHandler(u,oe,H.port),re=new WorkerTransport(Qt,l,me,Jt,qt);l._transport=re,Qt.send("Ready",null)})}).catch(l._capability.reject),l}async function _fetchDocument(a,l){if(a.destroyed)throw new Error("Worker was destroyed");const u=await a.messageHandler.sendWithPromise("GetDocRequest",l,l.data?[l.data.buffer]:null);if(a.destroyed)throw new Error("Worker was destroyed");return u}function getUrlProp(a){if(a instanceof URL)return a.href;try{return new URL(a,window.location).href}catch{if(_util.isNodeJS&&typeof a=="string")return a}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(a){if(_util.isNodeJS&&typeof Buffer<"u"&&a instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength)return a;if(typeof a=="string")return(0,_util.stringToBytes)(a);if(typeof a=="object"&&!isNaN(a==null?void 0:a.length)||(0,_util.isArrayBuffer)(a))return new Uint8Array(a);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}const e=class e{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId=`d${fn(e,d)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var l,u,R;this.destroyed=!0;try{(l=this._worker)!=null&&l.port&&(this._worker._pendingDestroy=!0),await((u=this._transport)==null?void 0:u.destroy())}catch(o){throw(R=this._worker)!=null&&R.port&&delete this._worker._pendingDestroy,o}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};d=new WeakMap,Tt(e,d,0);let PDFDocumentLoadingTask=e;exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(l,u,R=!1,o=null){this.length=l,this.initialData=u,this.progressiveDone=R,this.contentDispositionFilename=o,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener(l){this._rangeListeners.push(l)}addProgressListener(l){this._progressListeners.push(l)}addProgressiveReadListener(l){this._progressiveReadListeners.push(l)}addProgressiveDoneListener(l){this._progressiveDoneListeners.push(l)}onDataRange(l,u){for(const R of this._rangeListeners)R(l,u)}onDataProgress(l,u){this._readyCapability.promise.then(()=>{for(const R of this._progressListeners)R(l,u)})}onDataProgressiveRead(l){this._readyCapability.promise.then(()=>{for(const u of this._progressiveReadListeners)u(l)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const l of this._progressiveDoneListeners)l()})}transportReady(){this._readyCapability.resolve()}requestDataRange(l,u){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(l,u){this._pdfInfo=l,this._transport=u,Object.defineProperty(this,"getJavaScript",{value:()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, please use `PDFDocumentProxy.getJSActions` instead."),this.getJSActions().then(R=>{if(!R)return R;const o=[];for(const F in R)o.push(...R[F]);return o}))})}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(l){return this._transport.getPage(l)}getPageIndex(l){return this._transport.getPageIndex(l)}getDestinations(){return this._transport.getDestinations()}getDestination(l){return this._transport.getDestination(l)}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()}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()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(l=!1){return this._transport.startCleanup(l||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(l,u,R,o=!1){Tt(this,y);Tt(this,b,null);Tt(this,i,!1);this._pageIndex=l,this._pageInfo=u,this._transport=R,this._stats=o?new _display_utils.StatTimer:null,this._pdfBug=o,this.commonObjs=R.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=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:l,rotation:u=this.rotate,offsetX:R=0,offsetY:o=0,dontFlip:F=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:l,rotation:u,offsetX:R,offsetY:o,dontFlip:F})}getAnnotations({intent:l="display"}={}){const u=this._transport.getRenderingIntent(l);return this._transport.getAnnotations(this._pageIndex,u.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var l;return((l=this._transport._htmlForXfa)==null?void 0:l.children[this._pageIndex])||null}render({canvasContext:l,viewport:u,intent:R="display",annotationMode:o=_util.AnnotationMode.ENABLE,transform:F=null,background:$=null,optionalContentConfigPromise:wt=null,annotationCanvasMap:U=null,pageColors:G=null,printAnnotationStorage:H=null}){var s,p;(s=this._stats)==null||s.time("Overall");const _t=this._transport.getRenderingIntent(R,o,H);Rt(this,i,!1),K(this,y,En).call(this),wt||(wt=this._transport.getOptionalContentConfig());let D=this._intentStates.get(_t.cacheKey);D||(D=Object.create(null),this._intentStates.set(_t.cacheKey,D)),D.streamReaderCancelTimeout&&(clearTimeout(D.streamReaderCancelTimeout),D.streamReaderCancelTimeout=null);const W=!!(_t.renderingIntent&_util.RenderingIntentFlag.PRINT);D.displayReadyCapability||(D.displayReadyCapability=new _util.PromiseCapability,D.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(p=this._stats)==null||p.time("Page Request"),this._pumpOperatorList(_t));const J=M=>{var O,L;D.renderTasks.delete(S),(this._maybeCleanupAfterRender||W)&&Rt(this,i,!0),K(this,y,ln).call(this,!W),M?(S.capability.reject(M),this._abortOperatorList({intentState:D,reason:M instanceof Error?M:new Error(M)})):S.capability.resolve(),(O=this._stats)==null||O.timeEnd("Rendering"),(L=this._stats)==null||L.timeEnd("Overall")},S=new InternalRenderTask({callback:J,params:{canvasContext:l,viewport:u,transform:F,background:$},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:U,operatorList:D.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!W,pdfBug:this._pdfBug,pageColors:G});(D.renderTasks||(D.renderTasks=new Set)).add(S);const n=S.task;return Promise.all([D.displayReadyCapability.promise,wt]).then(([M,O])=>{var L;if(this.destroyed){J();return}(L=this._stats)==null||L.time("Rendering"),S.initializeGraphics({transparency:M,optionalContentConfig:O}),S.operatorListChanged()}).catch(J),n}getOperatorList({intent:l="display",annotationMode:u=_util.AnnotationMode.ENABLE,printAnnotationStorage:R=null}={}){var U;function o(){$.operatorList.lastChunk&&($.opListReadCapability.resolve($.operatorList),$.renderTasks.delete(wt))}const F=this._transport.getRenderingIntent(l,u,R,!0);let $=this._intentStates.get(F.cacheKey);$||($=Object.create(null),this._intentStates.set(F.cacheKey,$));let wt;return $.opListReadCapability||(wt=Object.create(null),wt.operatorListChanged=o,$.opListReadCapability=new _util.PromiseCapability,($.renderTasks||($.renderTasks=new Set)).add(wt),$.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(U=this._stats)==null||U.time("Page Request"),this._pumpOperatorList(F)),$.opListReadCapability.promise}streamTextContent({includeMarkedContent:l=!1,disableNormalization:u=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:l===!0,disableNormalization:u===!0},{highWaterMark:100,size(o){return o.items.length}})}getTextContent(l={}){if(this._transport._htmlForXfa)return this.getXfa().then(R=>_xfa_text.XfaText.textContent(R));const u=this.streamTextContent(l);return new Promise(function(R,o){function F(){$.read().then(function({value:U,done:G}){if(G){R(wt);return}Object.assign(wt.styles,U.styles),wt.items.push(...U.items),F()},o)}const $=u.getReader(),wt={items:[],styles:Object.create(null)};F()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const l=[];for(const u of this._intentStates.values())if(this._abortOperatorList({intentState:u,reason:new Error("Page was destroyed."),force:!0}),!u.opListReadCapability)for(const R of u.renderTasks)l.push(R.completed),R.cancel();return this.objs.clear(),Rt(this,i,!1),K(this,y,En).call(this),Promise.all(l)}cleanup(l=!1){Rt(this,i,!0);const u=K(this,y,ln).call(this,!1);return l&&u&&this._stats&&(this._stats=new _display_utils.StatTimer),u}_startRenderPage(l,u){var o,F;const R=this._intentStates.get(u);R&&((o=this._stats)==null||o.timeEnd("Page Request"),(F=R.displayReadyCapability)==null||F.resolve(l))}_renderPageChunk(l,u){for(let R=0,o=l.length;R<o;R++)u.operatorList.fnArray.push(l.fnArray[R]),u.operatorList.argsArray.push(l.argsArray[R]);u.operatorList.lastChunk=l.lastChunk,u.operatorList.separateAnnots=l.separateAnnots;for(const R of u.renderTasks)R.operatorListChanged();l.lastChunk&&K(this,y,ln).call(this,!0)}_pumpOperatorList({renderingIntent:l,cacheKey:u,annotationStorageSerializable:R}){const{map:o,transfers:F}=R,wt=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:l,cacheKey:u,annotationStorage:o},F).getReader(),U=this._intentStates.get(u);U.streamReader=wt;const G=()=>{wt.read().then(({value:H,done:_t})=>{if(_t){U.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(H,U),G())},H=>{if(U.streamReader=null,!this._transport.destroyed){if(U.operatorList){U.operatorList.lastChunk=!0;for(const _t of U.renderTasks)_t.operatorListChanged();K(this,y,ln).call(this,!0)}if(U.displayReadyCapability)U.displayReadyCapability.reject(H);else if(U.opListReadCapability)U.opListReadCapability.reject(H);else throw H}})};G()}_abortOperatorList({intentState:l,reason:u,force:R=!1}){if(l.streamReader){if(l.streamReaderCancelTimeout&&(clearTimeout(l.streamReaderCancelTimeout),l.streamReaderCancelTimeout=null),!R){if(l.renderTasks.size>0)return;if(u instanceof _display_utils.RenderingCancelledException){let o=RENDERING_CANCELLED_TIMEOUT;u.extraDelay>0&&u.extraDelay<1e3&&(o+=u.extraDelay),l.streamReaderCancelTimeout=setTimeout(()=>{l.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:l,reason:u,force:!0})},o);return}}if(l.streamReader.cancel(new _util.AbortException(u.message)).catch(()=>{}),l.streamReader=null,!this._transport.destroyed){for(const[o,F]of this._intentStates)if(F===l){this._intentStates.delete(o);break}this.cleanup()}}}get stats(){return this._stats}}b=new WeakMap,i=new WeakMap,y=new WeakSet,ln=function(l=!1){if(K(this,y,En).call(this),!t(this,i)||this.destroyed)return!1;if(l)return Rt(this,b,setTimeout(()=>{Rt(this,b,null),K(this,y,ln).call(this,!1)},DELAYED_CLEANUP_TIMEOUT)),!1;for(const{renderTasks:u,operatorList:R}of this._intentStates.values())if(u.size>0||!R.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Rt(this,i,!1),!0},En=function(){t(this,b)&&(clearTimeout(t(this,b)),Rt(this,b,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){Tt(this,xt,new Set);Tt(this,B,Promise.resolve())}postMessage(l,u){const R={data:structuredClone(l,u?{transfer:u}:null)};t(this,B).then(()=>{for(const o of t(this,xt))o.call(this,R)})}addEventListener(l,u){t(this,xt).add(u)}removeEventListener(l,u){t(this,xt).delete(u)}terminate(){t(this,xt).clear()}}xt=new WeakMap,B=new WeakMap,exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;{if(_util.isNodeJS&&typeof commonjsRequire=="function")PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if(typeof document=="object"){const a=(k=document==null?void 0:document.currentScript)==null?void 0:k.src;a&&(PDFWorkerUtil.fallbackWorkerSrc=a.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(a,l){let u;try{if(u=new URL(a),!u.origin||u.origin==="null")return!1}catch{return!1}const R=new URL(l,u);return u.origin===R.origin},PDFWorkerUtil.createCDNWrapper=function(a){const l=`importScripts("${a}");`;return URL.createObjectURL(new Blob([l]))}}const _PDFWorker=class _PDFWorker{constructor({name:a=null,port:l=null,verbosity:u=(0,_util.getVerbosityLevel)()}={}){var R;if(this.name=a,this.destroyed=!1,this.verbosity=u,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,l){if((R=t(_PDFWorker,f))!=null&&R.has(l))throw new Error("Cannot use more than one PDFWorker per port.");(t(_PDFWorker,f)||Rt(_PDFWorker,f,new WeakMap)).set(l,this),this._initializeFromPort(l);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(a){this._port=a,this._messageHandler=new _message_handler.MessageHandler("main","worker",a),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:a}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,a)||(a=PDFWorkerUtil.createCDNWrapper(new URL(a,window.location).href));const l=new Worker(a),u=new _message_handler.MessageHandler("main","worker",l),R=()=>{l.removeEventListener("error",o),u.destroy(),l.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},o=()=>{this._webWorker||R()};l.addEventListener("error",o),u.on("test",$=>{if(l.removeEventListener("error",o),this.destroyed){R();return}$?(this._messageHandler=u,this._port=l,this._webWorker=l,this._readyCapability.resolve(),u.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),u.destroy(),l.terminate())}),u.on("ready",$=>{if(l.removeEventListener("error",o),this.destroyed){R();return}try{F()}catch{this._setupFakeWorker()}});const F=()=>{const $=new Uint8Array;u.send("test",$,[$.buffer])};F();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(a=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const l=new LoopbackPort;this._port=l;const u=`fake${PDFWorkerUtil.fakeWorkerId++}`,R=new _message_handler.MessageHandler(u+"_worker",u,l);a.setup(R,l);const o=new _message_handler.MessageHandler(u,u+"_worker",l);this._messageHandler=o,this._readyCapability.resolve(),o.send("configure",{verbosity:this.verbosity})}).catch(a=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${a.message}".`))})}destroy(){var a;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(a=t(_PDFWorker,f))==null||a.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(a){var u;if(!(a!=null&&a.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const l=(u=t(this,f))==null?void 0:u.get(a.port);if(l){if(l._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return l}return new _PDFWorker(a)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(PDFWorkerUtil.fallbackWorkerSrc!==null)return _util.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var a;try{return((a=globalThis.pdfjsWorker)==null?void 0:a.WorkerMessageHandler)||null}catch{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_util.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,Tt(_PDFWorker,f);let PDFWorker=_PDFWorker;exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(l,u,R,o,F){Tt(this,E);Tt(this,P,new Map);Tt(this,T,new Map);Tt(this,A,new Map);Tt(this,g,null);this.messageHandler=l,this.loadingTask=u,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:o.ownerDocument,styleElement:o.styleElement}),this._params=o,this.canvasFactory=F.canvasFactory,this.filterFactory=F.filterFactory,this.cMapReaderFactory=F.cMapReaderFactory,this.standardFontDataFactory=F.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=R,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(l,u=_util.AnnotationMode.ENABLE,R=null,o=!1){let F=_util.RenderingIntentFlag.DISPLAY,$=_annotation_storage.SerializableEmpty;switch(l){case"any":F=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":F=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${l}`)}switch(u){case _util.AnnotationMode.DISABLE:F+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:F+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:F+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,$=(F&_util.RenderingIntentFlag.PRINT&&R instanceof _annotation_storage.PrintAnnotationStorage?R:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${u}`)}return o&&(F+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:F,cacheKey:`${F}_${$.hash}`,annotationStorageSerializable:$}}destroy(){var R;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,(R=t(this,g))==null||R.reject(new Error("Worker was destroyed during onPassword callback"));const l=[];for(const o of t(this,T).values())l.push(o._destroy());t(this,T).clear(),t(this,A).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const u=this.messageHandler.sendWithPromise("Terminate",null);return l.push(u),Promise.all(l).then(()=>{var o;this.commonObjs.clear(),this.fontLoader.clear(),t(this,P).clear(),this.filterFactory.destroy(),(o=this._networkStream)==null||o.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:l,loadingTask:u}=this;l.on("GetReader",(R,o)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=F=>{this._lastProgress={loaded:F.loaded,total:F.total}},o.onPull=()=>{this._fullReader.read().then(function({value:F,done:$}){if($){o.close();return}(0,_util.assert)(F instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),o.enqueue(new Uint8Array(F),1,[F])}).catch(F=>{o.error(F)})},o.onCancel=F=>{this._fullReader.cancel(F),o.ready.catch($=>{if(!this.destroyed)throw $})}}),l.on("ReaderHeadersReady",R=>{const o=new _util.PromiseCapability,F=this._fullReader;return F.headersReady.then(()=>{var $;(!F.isStreamingSupported||!F.isRangeSupported)&&(this._lastProgress&&(($=u.onProgress)==null||$.call(u,this._lastProgress)),F.onProgress=wt=>{var U;(U=u.onProgress)==null||U.call(u,{loaded:wt.loaded,total:wt.total})}),o.resolve({isStreamingSupported:F.isStreamingSupported,isRangeSupported:F.isRangeSupported,contentLength:F.contentLength})},o.reject),o.promise}),l.on("GetRangeReader",(R,o)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const F=this._networkStream.getRangeReader(R.begin,R.end);if(!F){o.close();return}o.onPull=()=>{F.read().then(function({value:$,done:wt}){if(wt){o.close();return}(0,_util.assert)($ instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),o.enqueue(new Uint8Array($),1,[$])}).catch($=>{o.error($)})},o.onCancel=$=>{F.cancel($),o.ready.catch(wt=>{if(!this.destroyed)throw wt})}}),l.on("GetDoc",({pdfInfo:R})=>{this._numPages=R.numPages,this._htmlForXfa=R.htmlForXfa,delete R.htmlForXfa,u._capability.resolve(new PDFDocumentProxy(R,this))}),l.on("DocException",function(R){let o;switch(R.name){case"PasswordException":o=new _util.PasswordException(R.message,R.code);break;case"InvalidPDFException":o=new _util.InvalidPDFException(R.message);break;case"MissingPDFException":o=new _util.MissingPDFException(R.message);break;case"UnexpectedResponseException":o=new _util.UnexpectedResponseException(R.message,R.status);break;case"UnknownErrorException":o=new _util.UnknownErrorException(R.message,R.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}u._capability.reject(o)}),l.on("PasswordRequest",R=>{if(Rt(this,g,new _util.PromiseCapability),u.onPassword){const o=F=>{F instanceof Error?t(this,g).reject(F):t(this,g).resolve({password:F})};try{u.onPassword(o,R.code)}catch(F){t(this,g).reject(F)}}else t(this,g).reject(new _util.PasswordException(R.message,R.code));return t(this,g).promise}),l.on("DataLoaded",R=>{var o;(o=u.onProgress)==null||o.call(u,{loaded:R.length,total:R.length}),this.downloadInfoCapability.resolve(R)}),l.on("StartRenderPage",R=>{if(this.destroyed)return;t(this,T).get(R.pageIndex)._startRenderPage(R.transparency,R.cacheKey)}),l.on("commonobj",([R,o,F])=>{var $;if(!this.destroyed&&!this.commonObjs.has(R))switch(o){case"Font":const wt=this._params;if("error"in F){const H=F.error;(0,_util.warn)(`Error during font loading: ${H}`),this.commonObjs.resolve(R,H);break}const U=wt.pdfBug&&(($=globalThis.FontInspector)!=null&&$.enabled)?(H,_t)=>globalThis.FontInspector.fontAdded(H,_t):null,G=new _font_loader.FontFaceObject(F,{isEvalSupported:wt.isEvalSupported,disableFontFace:wt.disableFontFace,ignoreErrors:wt.ignoreErrors,inspectFont:U});this.fontLoader.bind(G).catch(H=>l.sendWithPromise("FontFallback",{id:R})).finally(()=>{!wt.fontExtraProperties&&G.data&&(G.data=null),this.commonObjs.resolve(R,G)});break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(R,F);break;default:throw new Error(`Got unknown common object type ${o}`)}}),l.on("obj",([R,o,F,$])=>{var U;if(this.destroyed)return;const wt=t(this,T).get(o);if(!wt.objs.has(R))switch(F){case"Image":if(wt.objs.resolve(R,$),$){let G;if($.bitmap){const{width:H,height:_t}=$;G=H*_t*4}else G=((U=$.data)==null?void 0:U.length)||0;G>_util.MAX_IMAGE_SIZE_TO_CACHE&&(wt._maybeCleanupAfterRender=!0)}break;case"Pattern":wt.objs.resolve(R,$);break;default:throw new Error(`Got unknown object type ${F}`)}}),l.on("DocProgress",R=>{var o;this.destroyed||(o=u.onProgress)==null||o.call(u,{loaded:R.loaded,total:R.total})}),l.on("FetchBuiltInCMap",R=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(R):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),l.on("FetchStandardFontData",R=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(R):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var R;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:l,transfers:u}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:l,filename:((R=this._fullReader)==null?void 0:R.filename)??null},u).finally(()=>{this.annotationStorage.resetModified()})}getPage(l){if(!Number.isInteger(l)||l<=0||l>this._numPages)return Promise.reject(new Error("Invalid page request."));const u=l-1,R=t(this,A).get(u);if(R)return R;const o=this.messageHandler.sendWithPromise("GetPage",{pageIndex:u}).then(F=>{if(this.destroyed)throw new Error("Transport destroyed");const $=new PDFPageProxy(u,F,this,this._params.pdfBug);return t(this,T).set(u,$),$});return t(this,A).set(u,o),o}getPageIndex(l){return typeof l!="object"||l===null||!Number.isInteger(l.num)||l.num<0||!Number.isInteger(l.gen)||l.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:l.num,gen:l.gen})}getAnnotations(l,u){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:l,intent:u})}getFieldObjects(){return K(this,E,vn).call(this,"GetFieldObjects")}hasJSActions(){return K(this,E,vn).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(l){return typeof l!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:l})}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)}getDocJSActions(){return K(this,E,vn).call(this,"GetDocJSActions")}getPageJSActions(l){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:l})}getStructTree(l){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:l})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then(l=>new _optional_content_config.OptionalContentConfig(l))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const l="GetMetadata",u=t(this,P).get(l);if(u)return u;const R=this.messageHandler.sendWithPromise(l,null).then(o=>{var F,$;return{info:o[0],metadata:o[1]?new _metadata.Metadata(o[1]):null,contentDispositionFilename:((F=this._fullReader)==null?void 0:F.filename)??null,contentLength:(($=this._fullReader)==null?void 0:$.contentLength)??null}});return t(this,P).set(l,R),R}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(l=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const u of t(this,T).values())if(!u.cleanup())throw new Error(`startCleanup: Page ${u.pageNumber} is currently rendering.`);this.commonObjs.clear(),l||this.fontLoader.clear(),t(this,P).clear(),this.filterFactory.destroy(!0)}}get loadingParams(){const{disableAutoFetch:l,enableXfa:u}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:l,enableXfa:u})}}P=new WeakMap,T=new WeakMap,A=new WeakMap,g=new WeakMap,E=new WeakSet,vn=function(l,u=null){const R=t(this,P).get(l);if(R)return R;const o=this.messageHandler.sendWithPromise(l,u);return t(this,P).set(l,o),o};class PDFObjects{constructor(){Tt(this,C);Tt(this,c,Object.create(null))}get(l,u=null){if(u){const o=K(this,C,On).call(this,l);return o.capability.promise.then(()=>u(o.data)),null}const R=t(this,c)[l];if(!(R!=null&&R.capability.settled))throw new Error(`Requesting object that isn't resolved yet ${l}.`);return R.data}has(l){const u=t(this,c)[l];return(u==null?void 0:u.capability.settled)||!1}resolve(l,u=null){const R=K(this,C,On).call(this,l);R.data=u,R.capability.resolve()}clear(){var l;for(const u in t(this,c)){const{data:R}=t(this,c)[u];(l=R==null?void 0:R.bitmap)==null||l.close()}Rt(this,c,Object.create(null))}}c=new WeakMap,C=new WeakSet,On=function(l){var u;return(u=t(this,c))[l]||(u[l]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(l){Tt(this,m,null);Rt(this,m,l),this.onContinue=null}get promise(){return t(this,m).capability.promise}cancel(l=0){t(this,m).cancel(null,l)}get separateAnnots(){const{separateAnnots:l}=t(this,m).operatorList;if(!l)return!1;const{annotationCanvasMap:u}=t(this,m);return l.form||l.canvas&&(u==null?void 0:u.size)>0}}m=new WeakMap,exports.RenderTask=RenderTask;const h=class h{constructor({callback:l,params:u,objs:R,commonObjs:o,annotationCanvasMap:F,operatorList:$,pageIndex:wt,canvasFactory:U,filterFactory:G,useRequestAnimationFrame:H=!1,pdfBug:_t=!1,pageColors:D=null}){this.callback=l,this.params=u,this.objs=R,this.commonObjs=o,this.annotationCanvasMap=F,this.operatorListIdx=null,this.operatorList=$,this._pageIndex=wt,this.canvasFactory=U,this.filterFactory=G,this._pdfBug=_t,this.pageColors=D,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=H===!0&&typeof window<"u",this.cancelled=!1,this.capability=new _util.PromiseCapability,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=u.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:l=!1,optionalContentConfig:u}){var wt,U;if(this.cancelled)return;if(this._canvas){if(t(h,r).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.");t(h,r).add(this._canvas)}this._pdfBug&&((wt=globalThis.StepperManager)!=null&&wt.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:R,viewport:o,transform:F,background:$}=this.params;this.gfx=new _canvas.CanvasGraphics(R,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:u},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:F,viewport:o,transparency:l,background:$}),this.operatorListIdx=0,this.graphicsReady=!0,(U=this.graphicsReadyCallback)==null||U.call(this)}cancel(l=null,u=0){var R;this.running=!1,this.cancelled=!0,(R=this.gfx)==null||R.endDrawing(),t(h,r).delete(this._canvas),this.callback(l||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,u))}operatorListChanged(){var l;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(l=this.stepper)==null||l.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(),t(h,r).delete(this._canvas),this.callback())))}};r=new WeakMap,Tt(h,r,new WeakSet);let InternalRenderTask=h;const version="3.11.174";exports.version=version;const build="ce8716743";exports.build=build}),((d,e,b)=>{var k,f,P,_s,A;Object.defineProperty(e,"__esModule",{value:!0}),e.SerializableEmpty=e.PrintAnnotationStorage=e.AnnotationStorage=void 0;var i=b(1),y=b(4),Q=b(8);const z=Object.freeze({map:null,hash:"",transfers:void 0});e.SerializableEmpty=z;class xt{constructor(){Tt(this,P);Tt(this,k,!1);Tt(this,f,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(E,_){const c=t(this,f).get(E);return c===void 0?_:Object.assign(_,c)}getRawValue(E){return t(this,f).get(E)}remove(E){if(t(this,f).delete(E),t(this,f).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const _ of t(this,f).values())if(_ instanceof y.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(E,_){const c=t(this,f).get(E);let C=!1;if(c!==void 0)for(const[I,m]of Object.entries(_))c[I]!==m&&(C=!0,c[I]=m);else C=!0,t(this,f).set(E,_);C&&K(this,P,_s).call(this),_ instanceof y.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(_.constructor._type)}has(E){return t(this,f).has(E)}getAll(){return t(this,f).size>0?(0,i.objectFromMap)(t(this,f)):null}setAll(E){for(const[_,c]of Object.entries(E))this.setValue(_,c)}get size(){return t(this,f).size}resetModified(){t(this,k)&&(Rt(this,k,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new B(this)}get serializable(){if(t(this,f).size===0)return z;const E=new Map,_=new Q.MurmurHash3_64,c=[],C=Object.create(null);let I=!1;for(const[m,r]of t(this,f)){const h=r instanceof y.AnnotationEditor?r.serialize(!1,C):r;h&&(E.set(m,h),_.update(`${m}:${JSON.stringify(h)}`),I||(I=!!h.bitmap))}if(I)for(const m of E.values())m.bitmap&&c.push(m.bitmap);return E.size>0?{map:E,hash:_.hexdigest(),transfers:c}:z}}k=new WeakMap,f=new WeakMap,P=new WeakSet,_s=function(){t(this,k)||(Rt(this,k,!0),typeof this.onSetModified=="function"&&this.onSetModified())},e.AnnotationStorage=xt;class B extends xt{constructor(_){super();Tt(this,A);const{map:c,hash:C,transfers:I}=_.serializable,m=structuredClone(c,I?{transfer:I}:null);Rt(this,A,{map:m,hash:C,transfers:I})}get print(){(0,i.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return t(this,A)}}A=new WeakMap,e.PrintAnnotationStorage=B}),((d,e,b)=>{var B,k,f,P,T,A,g,E,_,c,C,I,m,r,h,Bn,Nn,u,$n,jn,As,ys,Es,Un,vs;Object.defineProperty(e,"__esModule",{value:!0}),e.AnnotationEditor=void 0;var i=b(5),y=b(1),Q=b(6);const H=class H{constructor(D){Tt(this,h);Tt(this,B,"");Tt(this,k,!1);Tt(this,f,null);Tt(this,P,null);Tt(this,T,null);Tt(this,A,!1);Tt(this,g,null);Tt(this,E,this.focusin.bind(this));Tt(this,_,this.focusout.bind(this));Tt(this,c,!1);Tt(this,C,!1);Tt(this,I,!1);Fe(this,"_initialOptions",Object.create(null));Fe(this,"_uiManager",null);Fe(this,"_focusEventsAllowed",!0);Fe(this,"_l10nPromise",null);Tt(this,m,!1);Tt(this,r,H._zIndex++);this.constructor===H&&(0,y.unreachable)("Cannot initialize AnnotationEditor."),this.parent=D.parent,this.id=D.id,this.width=this.height=null,this.pageIndex=D.parent.pageIndex,this.name=D.name,this.div=null,this._uiManager=D.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=D.isCentered,this._structTreeParentId=null;const{rotation:W,rawDims:{pageWidth:J,pageHeight:S,pageX:n,pageY:s}}=this.parent.viewport;this.rotation=W,this.pageRotation=(360+W-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[J,S],this.pageTranslation=[n,s];const[p,M]=this.parentDimensions;this.x=D.x/p,this.y=D.y/M,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,y.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(D){const W=new xt({id:D.parent.getNextId(),parent:D.parent,uiManager:D._uiManager});W.annotationElementId=D.annotationElementId,W.deleted=!0,W._uiManager.addToAnnotationStorage(W)}static initialize(D,W=null){if(H._l10nPromise||(H._l10nPromise=new Map(["editor_alt_text_button_label","editor_alt_text_edit_button_label","editor_alt_text_decorative_tooltip"].map(S=>[S,D.get(S)]))),W!=null&&W.strings)for(const S of W.strings)H._l10nPromise.set(S,D.get(S));if(H._borderLineWidth!==-1)return;const J=getComputedStyle(document.documentElement);H._borderLineWidth=parseFloat(J.getPropertyValue("--outline-width"))||0}static updateDefaultParams(D,W){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(D){return!1}static paste(D,W){(0,y.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return t(this,m)}set _isDraggable(D){var W;Rt(this,m,D),(W=this.div)==null||W.classList.toggle("draggable",D)}center(){const[D,W]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*W/(D*2),this.y+=this.width*D/(W*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*W/(D*2),this.y-=this.width*D/(W*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(D){this._uiManager.addCommands(D)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=t(this,r)}setParent(D){D!==null&&(this.pageIndex=D.pageIndex,this.pageDimensions=D.pageDimensions),this.parent=D}focusin(D){this._focusEventsAllowed&&(t(this,c)?Rt(this,c,!1):this.parent.setSelected(this))}focusout(D){var J;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const W=D.relatedTarget;W!=null&&W.closest(`#${this.id}`)||(D.preventDefault(),(J=this.parent)!=null&&J.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(D,W,J,S){const[n,s]=this.parentDimensions;[J,S]=this.screenToPageTranslation(J,S),this.x=(D+J)/n,this.y=(W+S)/s,this.fixAndSetPosition()}translate(D,W){K(this,h,Bn).call(this,this.parentDimensions,D,W)}translateInPage(D,W){K(this,h,Bn).call(this,this.pageDimensions,D,W),this.div.scrollIntoView({block:"nearest"})}drag(D,W){const[J,S]=this.parentDimensions;if(this.x+=D/J,this.y+=W/S,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:O,y:L}=this.div.getBoundingClientRect();this.parent.findNewParent(this,O,L)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:s}=this;const[p,M]=K(this,h,Nn).call(this);n+=p,s+=M,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*s).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}fixAndSetPosition(){const[D,W]=this.pageDimensions;let{x:J,y:S,width:n,height:s}=this;switch(n*=D,s*=W,J*=D,S*=W,this.rotation){case 0:J=Math.max(0,Math.min(D-n,J)),S=Math.max(0,Math.min(W-s,S));break;case 90:J=Math.max(0,Math.min(D-s,J)),S=Math.min(W,Math.max(n,S));break;case 180:J=Math.min(D,Math.max(n,J)),S=Math.min(W,Math.max(s,S));break;case 270:J=Math.min(D,Math.max(s,J)),S=Math.max(0,Math.min(W-n,S));break}this.x=J/=D,this.y=S/=W;const[p,M]=K(this,h,Nn).call(this);J+=p,S+=M;const{style:O}=this.div;O.left=`${(100*J).toFixed(2)}%`,O.top=`${(100*S).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(D,W){var J;return K(J=H,u,$n).call(J,D,W,this.parentRotation)}pageTranslationToScreen(D,W){var J;return K(J=H,u,$n).call(J,D,W,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:D,pageDimensions:[W,J]}=this,S=W*D,n=J*D;return y.FeatureTest.isCSSRoundSupported?[Math.round(S),Math.round(n)]:[S,n]}setDims(D,W){var n;const[J,S]=this.parentDimensions;this.div.style.width=`${(100*D/J).toFixed(2)}%`,t(this,A)||(this.div.style.height=`${(100*W/S).toFixed(2)}%`),(n=t(this,f))==null||n.classList.toggle("small",D<H.SMALL_EDITOR_SIZE||W<H.SMALL_EDITOR_SIZE)}fixDims(){const{style:D}=this.div,{height:W,width:J}=D,S=J.endsWith("%"),n=!t(this,A)&&W.endsWith("%");if(S&&n)return;const[s,p]=this.parentDimensions;S||(D.width=`${(100*parseFloat(J)/s).toFixed(2)}%`),!t(this,A)&&!n&&(D.height=`${(100*parseFloat(W)/p).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}async addAltTextButton(){if(t(this,f))return;const D=Rt(this,f,document.createElement("button"));D.className="altText";const W=await H._l10nPromise.get("editor_alt_text_button_label");D.textContent=W,D.setAttribute("aria-label",W),D.tabIndex="0",D.addEventListener("contextmenu",Q.noContextMenu),D.addEventListener("pointerdown",J=>J.stopPropagation()),D.addEventListener("click",J=>{J.preventDefault(),this._uiManager.editAltText(this)},{capture:!0}),D.addEventListener("keydown",J=>{J.target===D&&J.key==="Enter"&&(J.preventDefault(),this._uiManager.editAltText(this))}),K(this,h,Un).call(this),this.div.append(D),H.SMALL_EDITOR_SIZE||(H.SMALL_EDITOR_SIZE=Math.min(128,Math.round(D.getBoundingClientRect().width*1.4)))}getClientDimensions(){return this.div.getBoundingClientRect()}get altTextData(){return{altText:t(this,B),decorative:t(this,k)}}set altTextData({altText:D,decorative:W}){t(this,B)===D&&t(this,k)===W||(Rt(this,B,D),Rt(this,k,W),K(this,h,Un).call(this))}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",t(this,E)),this.div.addEventListener("focusout",t(this,_));const[D,W]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*W/D).toFixed(2)}%`,this.div.style.maxHeight=`${(100*D/W).toFixed(2)}%`);const[J,S]=this.getInitialTranslation();return this.translate(J,S),(0,i.bindEvents)(this,this.div,["pointerdown"]),this.div}pointerdown(D){const{isMac:W}=y.FeatureTest.platform;if(D.button!==0||D.ctrlKey&&W){D.preventDefault();return}Rt(this,c,!0),K(this,h,vs).call(this,D)}moveInDOM(){var D;(D=this.parent)==null||D.moveEditorInDOM(this)}_setParentAndPosition(D,W,J){D.changeParent(this),this.x=W,this.y=J,this.fixAndSetPosition()}getRect(D,W){const J=this.parentScale,[S,n]=this.pageDimensions,[s,p]=this.pageTranslation,M=D/J,O=W/J,L=this.x*S,V=this.y*n,At=this.width*S,It=this.height*n;switch(this.rotation){case 0:return[L+M+s,n-V-O-It+p,L+M+At+s,n-V-O+p];case 90:return[L+O+s,n-V+M+p,L+O+It+s,n-V+M+At+p];case 180:return[L-M-At+s,n-V+O+p,L-M+s,n-V+O+It+p];case 270:return[L-O-It+s,n-V-M-At+p,L-O+s,n-V-M+p];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(D,W){const[J,S,n,s]=D,p=n-J,M=s-S;switch(this.rotation){case 0:return[J,W-s,p,M];case 90:return[J,W-S,M,p];case 180:return[n,W-S,p,M];case 270:return[n,W-s,M,p];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){Rt(this,I,!0)}disableEditMode(){Rt(this,I,!1)}isInEditMode(){return t(this,I)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var D,W;(D=this.div)==null||D.addEventListener("focusin",t(this,E)),(W=this.div)==null||W.addEventListener("focusout",t(this,_))}serialize(D=!1,W=null){(0,y.unreachable)("An editor must be serializable")}static deserialize(D,W,J){const S=new this.prototype.constructor({parent:W,id:W.getNextId(),uiManager:J});S.rotation=D.rotation;const[n,s]=S.pageDimensions,[p,M,O,L]=S.getRectInCurrentCoords(D.rect,s);return S.x=p/n,S.y=M/s,S.width=O/n,S.height=L/s,S}remove(){var D;this.div.removeEventListener("focusin",t(this,E)),this.div.removeEventListener("focusout",t(this,_)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),(D=t(this,f))==null||D.remove(),Rt(this,f,null),Rt(this,P,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(K(this,h,As).call(this),t(this,g).classList.remove("hidden"))}select(){var D;this.makeResizable(),(D=this.div)==null||D.classList.add("selectedEditor")}unselect(){var D,W,J;(D=t(this,g))==null||D.classList.add("hidden"),(W=this.div)==null||W.classList.remove("selectedEditor"),(J=this.div)!=null&&J.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus()}updateParams(D,W){}disableEditing(){t(this,f)&&(t(this,f).hidden=!0)}enableEditing(){t(this,f)&&(t(this,f).hidden=!1)}enterInEditMode(){}get contentDiv(){return this.div}get isEditing(){return t(this,C)}set isEditing(D){Rt(this,C,D),this.parent&&(D?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(D,W){Rt(this,A,!0);const J=D/W,{style:S}=this.div;S.aspectRatio=J,S.height="auto"}static get MIN_SIZE(){return 16}};B=new WeakMap,k=new WeakMap,f=new WeakMap,P=new WeakMap,T=new WeakMap,A=new WeakMap,g=new WeakMap,E=new WeakMap,_=new WeakMap,c=new WeakMap,C=new WeakMap,I=new WeakMap,m=new WeakMap,r=new WeakMap,h=new WeakSet,Bn=function([D,W],J,S){[J,S]=this.screenToPageTranslation(J,S),this.x+=J/D,this.y+=S/W,this.fixAndSetPosition()},Nn=function(){const[D,W]=this.parentDimensions,{_borderLineWidth:J}=H,S=J/D,n=J/W;switch(this.rotation){case 90:return[-S,n];case 180:return[S,n];case 270:return[S,-n];default:return[-S,-n]}},u=new WeakSet,$n=function(D,W,J){switch(J){case 90:return[W,-D];case 180:return[-D,-W];case 270:return[-W,D];default:return[D,W]}},jn=function(D){switch(D){case 90:{const[W,J]=this.pageDimensions;return[0,-W/J,J/W,0]}case 180:return[-1,0,0,-1];case 270:{const[W,J]=this.pageDimensions;return[0,W/J,-J/W,0]}default:return[1,0,0,1]}},As=function(){if(t(this,g))return;Rt(this,g,document.createElement("div")),t(this,g).classList.add("resizers");const D=["topLeft","topRight","bottomRight","bottomLeft"];this._willKeepAspectRatio||D.push("topMiddle","middleRight","bottomMiddle","middleLeft");for(const W of D){const J=document.createElement("div");t(this,g).append(J),J.classList.add("resizer",W),J.addEventListener("pointerdown",K(this,h,ys).bind(this,W)),J.addEventListener("contextmenu",Q.noContextMenu)}this.div.prepend(t(this,g))},ys=function(D,W){W.preventDefault();const{isMac:J}=y.FeatureTest.platform;if(W.button!==0||W.ctrlKey&&J)return;const S=K(this,h,Es).bind(this,D),n=this._isDraggable;this._isDraggable=!1;const s={passive:!0,capture:!0};window.addEventListener("pointermove",S,s);const p=this.x,M=this.y,O=this.width,L=this.height,V=this.parent.div.style.cursor,At=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(W.target).cursor;const It=()=>{this._isDraggable=n,window.removeEventListener("pointerup",It),window.removeEventListener("blur",It),window.removeEventListener("pointermove",S,s),this.parent.div.style.cursor=V,this.div.style.cursor=At;const Bt=this.x,jt=this.y,Ut=this.width,Xt=this.height;Bt===p&&jt===M&&Ut===O&&Xt===L||this.addCommands({cmd:()=>{this.width=Ut,this.height=Xt,this.x=Bt,this.y=jt;const[vt,kt]=this.parentDimensions;this.setDims(vt*Ut,kt*Xt),this.fixAndSetPosition()},undo:()=>{this.width=O,this.height=L,this.x=p,this.y=M;const[vt,kt]=this.parentDimensions;this.setDims(vt*O,kt*L),this.fixAndSetPosition()},mustExec:!0})};window.addEventListener("pointerup",It),window.addEventListener("blur",It)},Es=function(D,W){const[J,S]=this.parentDimensions,n=this.x,s=this.y,p=this.width,M=this.height,O=H.MIN_SIZE/J,L=H.MIN_SIZE/S,V=Qt=>Math.round(Qt*1e4)/1e4,At=K(this,h,jn).call(this,this.rotation),It=(Qt,re)=>[At[0]*Qt+At[2]*re,At[1]*Qt+At[3]*re],Bt=K(this,h,jn).call(this,360-this.rotation),jt=(Qt,re)=>[Bt[0]*Qt+Bt[2]*re,Bt[1]*Qt+Bt[3]*re];let Ut,Xt,vt=!1,kt=!1;switch(D){case"topLeft":vt=!0,Ut=(Qt,re)=>[0,0],Xt=(Qt,re)=>[Qt,re];break;case"topMiddle":Ut=(Qt,re)=>[Qt/2,0],Xt=(Qt,re)=>[Qt/2,re];break;case"topRight":vt=!0,Ut=(Qt,re)=>[Qt,0],Xt=(Qt,re)=>[0,re];break;case"middleRight":kt=!0,Ut=(Qt,re)=>[Qt,re/2],Xt=(Qt,re)=>[0,re/2];break;case"bottomRight":vt=!0,Ut=(Qt,re)=>[Qt,re],Xt=(Qt,re)=>[0,0];break;case"bottomMiddle":Ut=(Qt,re)=>[Qt/2,re],Xt=(Qt,re)=>[Qt/2,0];break;case"bottomLeft":vt=!0,Ut=(Qt,re)=>[0,re],Xt=(Qt,re)=>[Qt,0];break;case"middleLeft":kt=!0,Ut=(Qt,re)=>[0,re/2],Xt=(Qt,re)=>[Qt,re/2];break}const v=Ut(p,M),N=Xt(p,M);let Z=It(...N);const St=V(n+Z[0]),Nt=V(s+Z[1]);let zt=1,qt=1,[bt,Jt]=this.screenToPageTranslation(W.movementX,W.movementY);if([bt,Jt]=jt(bt/J,Jt/S),vt){const Qt=Math.hypot(p,M);zt=qt=Math.max(Math.min(Math.hypot(N[0]-v[0]-bt,N[1]-v[1]-Jt)/Qt,1/p,1/M),O/p,L/M)}else kt?zt=Math.max(O,Math.min(1,Math.abs(N[0]-v[0]-bt)))/p:qt=Math.max(L,Math.min(1,Math.abs(N[1]-v[1]-Jt)))/M;const Kt=V(p*zt),ce=V(M*qt);Z=It(...Xt(Kt,ce));const oe=St-Z[0],me=Nt-Z[1];this.width=Kt,this.height=ce,this.x=oe,this.y=me,this.setDims(J*Kt,S*ce),this.fixAndSetPosition()},Un=async function(){var J;const D=t(this,f);if(!D)return;if(!t(this,B)&&!t(this,k)){D.classList.remove("done"),(J=t(this,P))==null||J.remove();return}H._l10nPromise.get("editor_alt_text_edit_button_label").then(S=>{D.setAttribute("aria-label",S)});let W=t(this,P);if(!W){Rt(this,P,W=document.createElement("span")),W.className="tooltip",W.setAttribute("role","tooltip");const S=W.id=`alt-text-tooltip-${this.id}`;D.setAttribute("aria-describedby",S);const n=100;D.addEventListener("mouseenter",()=>{Rt(this,T,setTimeout(()=>{Rt(this,T,null),t(this,P).classList.add("show"),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"alt_text_tooltip"}}})},n))}),D.addEventListener("mouseleave",()=>{var s;clearTimeout(t(this,T)),Rt(this,T,null),(s=t(this,P))==null||s.classList.remove("show")})}D.classList.add("done"),W.innerText=t(this,k)?await H._l10nPromise.get("editor_alt_text_decorative_tooltip"):t(this,B),W.parentNode||D.append(W)},vs=function(D){if(!this._isDraggable)return;const W=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let J,S;W&&(J={passive:!0,capture:!0},S=s=>{const[p,M]=this.screenToPageTranslation(s.movementX,s.movementY);this._uiManager.dragSelectedEditors(p,M)},window.addEventListener("pointermove",S,J));const n=()=>{if(window.removeEventListener("pointerup",n),window.removeEventListener("blur",n),W&&window.removeEventListener("pointermove",S,J),Rt(this,c,!1),!this._uiManager.endDragSession()){const{isMac:s}=y.FeatureTest.platform;D.ctrlKey&&!s||D.shiftKey||D.metaKey&&s?this.parent.toggleSelected(this):this.parent.setSelected(this)}};window.addEventListener("pointerup",n),window.addEventListener("blur",n)},Tt(H,u),Fe(H,"_borderLineWidth",-1),Fe(H,"_colorManager",new i.ColorManager),Fe(H,"_zIndex",1),Fe(H,"SMALL_EDITOR_SIZE",0);let z=H;e.AnnotationEditor=z;class xt extends z{constructor(D){super(D),this.annotationElementId=D.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}}),((d,e,b)=>{var A,g,E,_,c,Hn,m,r,h,a,l,Cs,o,F,$,wt,U,G,H,_t,D,W,J,S,n,s,p,M,O,L,V,At,It,Bt,jt,Ut,Xt,vt,kt,v,N,Z,St,Nt,zt,qt,bt,Fs,Wn,zn,Cn,Xn,Gn,en,pn,ws,Ss,qn,gn,Vn;Object.defineProperty(e,"__esModule",{value:!0}),e.KeyboardManager=e.CommandManager=e.ColorManager=e.AnnotationEditorUIManager=void 0,e.bindEvents=Q,e.opacityToHex=z;var i=b(1),y=b(6);function Q(de,j,$t){for(const Y of $t)j.addEventListener(Y,de[Y].bind(de))}function z(de){return Math.round(Math.min(255,Math.max(1,255*de))).toString(16).padStart(2,"0")}class xt{constructor(){Tt(this,A,0)}getId(){return`${i.AnnotationEditorPrefix}${fn(this,A)._++}`}}A=new WeakMap;const I=class I{constructor(){Tt(this,c);Tt(this,g,(0,i.getUuid)());Tt(this,E,0);Tt(this,_,null)}static get _isSVGFittingCanvas(){const j='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Y=new OffscreenCanvas(1,3).getContext("2d"),Lt=new Image;Lt.src=j;const Vt=Lt.decode().then(()=>(Y.drawImage(Lt,0,0,1,1,0,0,1,3),new Uint32Array(Y.getImageData(0,0,1,1).data.buffer)[0]===0));return(0,i.shadow)(this,"_isSVGFittingCanvas",Vt)}async getFromFile(j){const{lastModified:$t,name:Y,size:Lt,type:Vt}=j;return K(this,c,Hn).call(this,`${$t}_${Y}_${Lt}_${Vt}`,j)}async getFromUrl(j){return K(this,c,Hn).call(this,j,j)}async getFromId(j){t(this,_)||Rt(this,_,new Map);const $t=t(this,_).get(j);return $t?$t.bitmap?($t.refCounter+=1,$t):$t.file?this.getFromFile($t.file):this.getFromUrl($t.url):null}getSvgUrl(j){const $t=t(this,_).get(j);return $t!=null&&$t.isSvg?$t.svgUrl:null}deleteId(j){t(this,_)||Rt(this,_,new Map);const $t=t(this,_).get(j);$t&&($t.refCounter-=1,$t.refCounter===0&&($t.bitmap=null))}isValidId(j){return j.startsWith(`image_${t(this,g)}_`)}};g=new WeakMap,E=new WeakMap,_=new WeakMap,c=new WeakSet,Hn=async function(j,$t){t(this,_)||Rt(this,_,new Map);let Y=t(this,_).get(j);if(Y===null)return null;if(Y!=null&&Y.bitmap)return Y.refCounter+=1,Y;try{Y||(Y={bitmap:null,id:`image_${t(this,g)}_${fn(this,E)._++}`,refCounter:0,isSvg:!1});let Lt;if(typeof $t=="string"){Y.url=$t;const Vt=await fetch($t);if(!Vt.ok)throw new Error(Vt.statusText);Lt=await Vt.blob()}else Lt=Y.file=$t;if(Lt.type==="image/svg+xml"){const Vt=I._isSVGFittingCanvas,Wt=new FileReader,w=new Image,x=new Promise((q,Dt)=>{w.onload=()=>{Y.bitmap=w,Y.isSvg=!0,q()},Wt.onload=async()=>{const Ot=Y.svgUrl=Wt.result;w.src=await Vt?`${Ot}#svgView(preserveAspectRatio(none))`:Ot},w.onerror=Wt.onerror=Dt});Wt.readAsDataURL(Lt),await x}else Y.bitmap=await createImageBitmap(Lt);Y.refCounter=1}catch(Lt){console.error(Lt),Y=null}return t(this,_).set(j,Y),Y&&t(this,_).set(Y.id,Y),Y};let B=I;class k{constructor(j=128){Tt(this,m,[]);Tt(this,r,!1);Tt(this,h);Tt(this,a,-1);Rt(this,h,j)}add({cmd:j,undo:$t,mustExec:Y,type:Lt=NaN,overwriteIfSameType:Vt=!1,keepUndo:Wt=!1}){if(Y&&j(),t(this,r))return;const w={cmd:j,undo:$t,type:Lt};if(t(this,a)===-1){t(this,m).length>0&&(t(this,m).length=0),Rt(this,a,0),t(this,m).push(w);return}if(Vt&&t(this,m)[t(this,a)].type===Lt){Wt&&(w.undo=t(this,m)[t(this,a)].undo),t(this,m)[t(this,a)]=w;return}const x=t(this,a)+1;x===t(this,h)?t(this,m).splice(0,1):(Rt(this,a,x),x<t(this,m).length&&t(this,m).splice(x)),t(this,m).push(w)}undo(){t(this,a)!==-1&&(Rt(this,r,!0),t(this,m)[t(this,a)].undo(),Rt(this,r,!1),Rt(this,a,t(this,a)-1))}redo(){t(this,a)<t(this,m).length-1&&(Rt(this,a,t(this,a)+1),Rt(this,r,!0),t(this,m)[t(this,a)].cmd(),Rt(this,r,!1))}hasSomethingToUndo(){return t(this,a)!==-1}hasSomethingToRedo(){return t(this,a)<t(this,m).length-1}destroy(){Rt(this,m,null)}}m=new WeakMap,r=new WeakMap,h=new WeakMap,a=new WeakMap,e.CommandManager=k;class f{constructor(j){Tt(this,l);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:$t}=i.FeatureTest.platform;for(const[Y,Lt,Vt={}]of j)for(const Wt of Y){const w=Wt.startsWith("mac+");$t&&w?(this.callbacks.set(Wt.slice(4),{callback:Lt,options:Vt}),this.allKeys.add(Wt.split("+").at(-1))):!$t&&!w&&(this.callbacks.set(Wt,{callback:Lt,options:Vt}),this.allKeys.add(Wt.split("+").at(-1)))}}exec(j,$t){if(!this.allKeys.has($t.key))return;const Y=this.callbacks.get(K(this,l,Cs).call(this,$t));if(!Y)return;const{callback:Lt,options:{bubbles:Vt=!1,args:Wt=[],checker:w=null}}=Y;w&&!w(j,$t)||(Lt.bind(j,...Wt)(),Vt||($t.stopPropagation(),$t.preventDefault()))}}l=new WeakSet,Cs=function(j){j.altKey&&this.buffer.push("alt"),j.ctrlKey&&this.buffer.push("ctrl"),j.metaKey&&this.buffer.push("meta"),j.shiftKey&&this.buffer.push("shift"),this.buffer.push(j.key);const $t=this.buffer.join("+");return this.buffer.length=0,$t},e.KeyboardManager=f;const R=class R{get _colors(){const j=new Map([["CanvasText",null],["Canvas",null]]);return(0,y.getColorValues)(j),(0,i.shadow)(this,"_colors",j)}convert(j){const $t=(0,y.getRGB)(j);if(!window.matchMedia("(forced-colors: active)").matches)return $t;for(const[Y,Lt]of this._colors)if(Lt.every((Vt,Wt)=>Vt===$t[Wt]))return R._colorsMapping.get(Y);return $t}getHexCode(j){const $t=this._colors.get(j);return $t?i.Util.makeHexColor(...$t):j}};Fe(R,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let P=R;e.ColorManager=P;const ge=class ge{constructor(j,$t,Y,Lt,Vt,Wt){Tt(this,bt);Tt(this,o,null);Tt(this,F,new Map);Tt(this,$,new Map);Tt(this,wt,null);Tt(this,U,null);Tt(this,G,new k);Tt(this,H,0);Tt(this,_t,new Set);Tt(this,D,null);Tt(this,W,null);Tt(this,J,new Set);Tt(this,S,null);Tt(this,n,new xt);Tt(this,s,!1);Tt(this,p,!1);Tt(this,M,null);Tt(this,O,i.AnnotationEditorType.NONE);Tt(this,L,new Set);Tt(this,V,null);Tt(this,At,this.blur.bind(this));Tt(this,It,this.focus.bind(this));Tt(this,Bt,this.copy.bind(this));Tt(this,jt,this.cut.bind(this));Tt(this,Ut,this.paste.bind(this));Tt(this,Xt,this.keydown.bind(this));Tt(this,vt,this.onEditingAction.bind(this));Tt(this,kt,this.onPageChanging.bind(this));Tt(this,v,this.onScaleChanging.bind(this));Tt(this,N,this.onRotationChanging.bind(this));Tt(this,Z,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1});Tt(this,St,[0,0]);Tt(this,Nt,null);Tt(this,zt,null);Tt(this,qt,null);Rt(this,zt,j),Rt(this,qt,$t),Rt(this,wt,Y),this._eventBus=Lt,this._eventBus._on("editingaction",t(this,vt)),this._eventBus._on("pagechanging",t(this,kt)),this._eventBus._on("scalechanging",t(this,v)),this._eventBus._on("rotationchanging",t(this,N)),Rt(this,U,Vt.annotationStorage),Rt(this,S,Vt.filterFactory),Rt(this,V,Wt),this.viewParameters={realScale:y.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){const j=ge.prototype,$t=Vt=>{const{activeElement:Wt}=document;return Wt&&t(Vt,zt).contains(Wt)&&Vt.hasSomethingToControl()},Y=this.TRANSLATE_SMALL,Lt=this.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new f([[["ctrl+a","mac+meta+a"],j.selectAll],[["ctrl+z","mac+meta+z"],j.undo],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],j.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],j.delete],[["Escape","mac+Escape"],j.unselectAll],[["ArrowLeft","mac+ArrowLeft"],j.translateSelectedEditors,{args:[-Y,0],checker:$t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],j.translateSelectedEditors,{args:[-Lt,0],checker:$t}],[["ArrowRight","mac+ArrowRight"],j.translateSelectedEditors,{args:[Y,0],checker:$t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],j.translateSelectedEditors,{args:[Lt,0],checker:$t}],[["ArrowUp","mac+ArrowUp"],j.translateSelectedEditors,{args:[0,-Y],checker:$t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],j.translateSelectedEditors,{args:[0,-Lt],checker:$t}],[["ArrowDown","mac+ArrowDown"],j.translateSelectedEditors,{args:[0,Y],checker:$t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],j.translateSelectedEditors,{args:[0,Lt],checker:$t}]]))}destroy(){K(this,bt,Cn).call(this),K(this,bt,Wn).call(this),this._eventBus._off("editingaction",t(this,vt)),this._eventBus._off("pagechanging",t(this,kt)),this._eventBus._off("scalechanging",t(this,v)),this._eventBus._off("rotationchanging",t(this,N));for(const j of t(this,$).values())j.destroy();t(this,$).clear(),t(this,F).clear(),t(this,J).clear(),Rt(this,o,null),t(this,L).clear(),t(this,G).destroy(),t(this,wt).destroy()}get hcmFilter(){return(0,i.shadow)(this,"hcmFilter",t(this,V)?t(this,S).addHCMFilter(t(this,V).foreground,t(this,V).background):"none")}get direction(){return(0,i.shadow)(this,"direction",getComputedStyle(t(this,zt)).direction)}editAltText(j){var $t;($t=t(this,wt))==null||$t.editAltText(this,j)}onPageChanging({pageNumber:j}){Rt(this,H,j-1)}focusMainContainer(){t(this,zt).focus()}findParent(j,$t){for(const Y of t(this,$).values()){const{x:Lt,y:Vt,width:Wt,height:w}=Y.div.getBoundingClientRect();if(j>=Lt&&j<=Lt+Wt&&$t>=Vt&&$t<=Vt+w)return Y}return null}disableUserSelect(j=!1){t(this,qt).classList.toggle("noUserSelect",j)}addShouldRescale(j){t(this,J).add(j)}removeShouldRescale(j){t(this,J).delete(j)}onScaleChanging({scale:j}){this.commitOrRemove(),this.viewParameters.realScale=j*y.PixelsPerInch.PDF_TO_CSS_UNITS;for(const $t of t(this,J))$t.onScaleChanging()}onRotationChanging({pagesRotation:j}){this.commitOrRemove(),this.viewParameters.rotation=j}addToAnnotationStorage(j){!j.isEmpty()&&t(this,U)&&!t(this,U).has(j.id)&&t(this,U).setValue(j.id,j)}blur(){if(!this.hasSelection)return;const{activeElement:j}=document;for(const $t of t(this,L))if($t.div.contains(j)){Rt(this,M,[$t,j]),$t._focusEventsAllowed=!1;break}}focus(){if(!t(this,M))return;const[j,$t]=t(this,M);Rt(this,M,null),$t.addEventListener("focusin",()=>{j._focusEventsAllowed=!0},{once:!0}),$t.focus()}addEditListeners(){K(this,bt,zn).call(this),K(this,bt,Xn).call(this)}removeEditListeners(){K(this,bt,Cn).call(this),K(this,bt,Gn).call(this)}copy(j){var Y;if(j.preventDefault(),(Y=t(this,o))==null||Y.commitOrRemove(),!this.hasSelection)return;const $t=[];for(const Lt of t(this,L)){const Vt=Lt.serialize(!0);Vt&&$t.push(Vt)}$t.length!==0&&j.clipboardData.setData("application/pdfjs",JSON.stringify($t))}cut(j){this.copy(j),this.delete()}paste(j){j.preventDefault();const{clipboardData:$t}=j;for(const Vt of $t.items)for(const Wt of t(this,W))if(Wt.isHandlingMimeForPasting(Vt.type)){Wt.paste(Vt,this.currentLayer);return}let Y=$t.getData("application/pdfjs");if(!Y)return;try{Y=JSON.parse(Y)}catch(Vt){(0,i.warn)(`paste: "${Vt.message}".`);return}if(!Array.isArray(Y))return;this.unselectAll();const Lt=this.currentLayer;try{const Vt=[];for(const x of Y){const q=Lt.deserialize(x);if(!q)return;Vt.push(q)}const Wt=()=>{for(const x of Vt)K(this,bt,qn).call(this,x);K(this,bt,Vn).call(this,Vt)},w=()=>{for(const x of Vt)x.remove()};this.addCommands({cmd:Wt,undo:w,mustExec:!0})}catch(Vt){(0,i.warn)(`paste: "${Vt.message}".`)}}keydown(j){var $t;($t=this.getActive())!=null&&$t.shouldGetKeyboardEvents()||ge._keyboardManager.exec(this,j)}onEditingAction(j){["undo","redo","delete","selectAll"].includes(j.name)&&this[j.name]()}setEditingState(j){j?(K(this,bt,Fs).call(this),K(this,bt,zn).call(this),K(this,bt,Xn).call(this),K(this,bt,en).call(this,{isEditing:t(this,O)!==i.AnnotationEditorType.NONE,isEmpty:K(this,bt,gn).call(this),hasSomethingToUndo:t(this,G).hasSomethingToUndo(),hasSomethingToRedo:t(this,G).hasSomethingToRedo(),hasSelectedEditor:!1})):(K(this,bt,Wn).call(this),K(this,bt,Cn).call(this),K(this,bt,Gn).call(this),K(this,bt,en).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(j){if(!t(this,W)){Rt(this,W,j);for(const $t of t(this,W))K(this,bt,pn).call(this,$t.defaultPropertiesToUpdate)}}getId(){return t(this,n).getId()}get currentLayer(){return t(this,$).get(t(this,H))}getLayer(j){return t(this,$).get(j)}get currentPageIndex(){return t(this,H)}addLayer(j){t(this,$).set(j.pageIndex,j),t(this,s)?j.enable():j.disable()}removeLayer(j){t(this,$).delete(j.pageIndex)}updateMode(j,$t=null){if(t(this,O)!==j){if(Rt(this,O,j),j===i.AnnotationEditorType.NONE){this.setEditingState(!1),K(this,bt,Ss).call(this);return}this.setEditingState(!0),K(this,bt,ws).call(this),this.unselectAll();for(const Y of t(this,$).values())Y.updateMode(j);if($t){for(const Y of t(this,F).values())if(Y.annotationElementId===$t){this.setSelected(Y),Y.enterInEditMode();break}}}}updateToolbar(j){j!==t(this,O)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:j})}updateParams(j,$t){if(t(this,W)){if(j===i.AnnotationEditorParamsType.CREATE){this.currentLayer.addNewEditor(j);return}for(const Y of t(this,L))Y.updateParams(j,$t);for(const Y of t(this,W))Y.updateDefaultParams(j,$t)}}enableWaiting(j=!1){if(t(this,p)!==j){Rt(this,p,j);for(const $t of t(this,$).values())j?$t.disableClick():$t.enableClick(),$t.div.classList.toggle("waiting",j)}}getEditors(j){const $t=[];for(const Y of t(this,F).values())Y.pageIndex===j&&$t.push(Y);return $t}getEditor(j){return t(this,F).get(j)}addEditor(j){t(this,F).set(j.id,j)}removeEditor(j){var $t;t(this,F).delete(j.id),this.unselect(j),(!j.annotationElementId||!t(this,_t).has(j.annotationElementId))&&(($t=t(this,U))==null||$t.remove(j.id))}addDeletedAnnotationElement(j){t(this,_t).add(j.annotationElementId),j.deleted=!0}isDeletedAnnotationElement(j){return t(this,_t).has(j)}removeDeletedAnnotationElement(j){t(this,_t).delete(j.annotationElementId),j.deleted=!1}setActiveEditor(j){t(this,o)!==j&&(Rt(this,o,j),j&&K(this,bt,pn).call(this,j.propertiesToUpdate))}toggleSelected(j){if(t(this,L).has(j)){t(this,L).delete(j),j.unselect(),K(this,bt,en).call(this,{hasSelectedEditor:this.hasSelection});return}t(this,L).add(j),j.select(),K(this,bt,pn).call(this,j.propertiesToUpdate),K(this,bt,en).call(this,{hasSelectedEditor:!0})}setSelected(j){for(const $t of t(this,L))$t!==j&&$t.unselect();t(this,L).clear(),t(this,L).add(j),j.select(),K(this,bt,pn).call(this,j.propertiesToUpdate),K(this,bt,en).call(this,{hasSelectedEditor:!0})}isSelected(j){return t(this,L).has(j)}unselect(j){j.unselect(),t(this,L).delete(j),K(this,bt,en).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return t(this,L).size!==0}undo(){t(this,G).undo(),K(this,bt,en).call(this,{hasSomethingToUndo:t(this,G).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:K(this,bt,gn).call(this)})}redo(){t(this,G).redo(),K(this,bt,en).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:t(this,G).hasSomethingToRedo(),isEmpty:K(this,bt,gn).call(this)})}addCommands(j){t(this,G).add(j),K(this,bt,en).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:K(this,bt,gn).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const j=[...t(this,L)],$t=()=>{for(const Lt of j)Lt.remove()},Y=()=>{for(const Lt of j)K(this,bt,qn).call(this,Lt)};this.addCommands({cmd:$t,undo:Y,mustExec:!0})}commitOrRemove(){var j;(j=t(this,o))==null||j.commitOrRemove()}hasSomethingToControl(){return t(this,o)||this.hasSelection}selectAll(){for(const j of t(this,L))j.commit();K(this,bt,Vn).call(this,t(this,F).values())}unselectAll(){if(t(this,o)){t(this,o).commitOrRemove();return}if(this.hasSelection){for(const j of t(this,L))j.unselect();t(this,L).clear(),K(this,bt,en).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(j,$t,Y=!1){if(Y||this.commitOrRemove(),!this.hasSelection)return;t(this,St)[0]+=j,t(this,St)[1]+=$t;const[Lt,Vt]=t(this,St),Wt=[...t(this,L)],w=1e3;t(this,Nt)&&clearTimeout(t(this,Nt)),Rt(this,Nt,setTimeout(()=>{Rt(this,Nt,null),t(this,St)[0]=t(this,St)[1]=0,this.addCommands({cmd:()=>{for(const x of Wt)t(this,F).has(x.id)&&x.translateInPage(Lt,Vt)},undo:()=>{for(const x of Wt)t(this,F).has(x.id)&&x.translateInPage(-Lt,-Vt)},mustExec:!1})},w));for(const x of Wt)x.translateInPage(j,$t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Rt(this,D,new Map);for(const j of t(this,L))t(this,D).set(j,{savedX:j.x,savedY:j.y,savedPageIndex:j.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!t(this,D))return!1;this.disableUserSelect(!1);const j=t(this,D);Rt(this,D,null);let $t=!1;for(const[{x:Lt,y:Vt,pageIndex:Wt},w]of j)w.newX=Lt,w.newY=Vt,w.newPageIndex=Wt,$t||($t=Lt!==w.savedX||Vt!==w.savedY||Wt!==w.savedPageIndex);if(!$t)return!1;const Y=(Lt,Vt,Wt,w)=>{if(t(this,F).has(Lt.id)){const x=t(this,$).get(w);x?Lt._setParentAndPosition(x,Vt,Wt):(Lt.pageIndex=w,Lt.x=Vt,Lt.y=Wt)}};return this.addCommands({cmd:()=>{for(const[Lt,{newX:Vt,newY:Wt,newPageIndex:w}]of j)Y(Lt,Vt,Wt,w)},undo:()=>{for(const[Lt,{savedX:Vt,savedY:Wt,savedPageIndex:w}]of j)Y(Lt,Vt,Wt,w)},mustExec:!0}),!0}dragSelectedEditors(j,$t){if(t(this,D))for(const Y of t(this,D).keys())Y.drag(j,$t)}rebuild(j){if(j.parent===null){const $t=this.getLayer(j.pageIndex);$t?($t.changeParent(j),$t.addOrRebuild(j)):(this.addEditor(j),this.addToAnnotationStorage(j),j.rebuild())}else j.parent.addOrRebuild(j)}isActive(j){return t(this,o)===j}getActive(){return t(this,o)}getMode(){return t(this,O)}get imageManager(){return(0,i.shadow)(this,"imageManager",new B)}};o=new WeakMap,F=new WeakMap,$=new WeakMap,wt=new WeakMap,U=new WeakMap,G=new WeakMap,H=new WeakMap,_t=new WeakMap,D=new WeakMap,W=new WeakMap,J=new WeakMap,S=new WeakMap,n=new WeakMap,s=new WeakMap,p=new WeakMap,M=new WeakMap,O=new WeakMap,L=new WeakMap,V=new WeakMap,At=new WeakMap,It=new WeakMap,Bt=new WeakMap,jt=new WeakMap,Ut=new WeakMap,Xt=new WeakMap,vt=new WeakMap,kt=new WeakMap,v=new WeakMap,N=new WeakMap,Z=new WeakMap,St=new WeakMap,Nt=new WeakMap,zt=new WeakMap,qt=new WeakMap,bt=new WeakSet,Fs=function(){window.addEventListener("focus",t(this,It)),window.addEventListener("blur",t(this,At))},Wn=function(){window.removeEventListener("focus",t(this,It)),window.removeEventListener("blur",t(this,At))},zn=function(){window.addEventListener("keydown",t(this,Xt),{capture:!0})},Cn=function(){window.removeEventListener("keydown",t(this,Xt),{capture:!0})},Xn=function(){document.addEventListener("copy",t(this,Bt)),document.addEventListener("cut",t(this,jt)),document.addEventListener("paste",t(this,Ut))},Gn=function(){document.removeEventListener("copy",t(this,Bt)),document.removeEventListener("cut",t(this,jt)),document.removeEventListener("paste",t(this,Ut))},en=function(j){Object.entries(j).some(([Y,Lt])=>t(this,Z)[Y]!==Lt)&&this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(t(this,Z),j)})},pn=function(j){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:j})},ws=function(){if(!t(this,s)){Rt(this,s,!0);for(const j of t(this,$).values())j.enable()}},Ss=function(){if(this.unselectAll(),t(this,s)){Rt(this,s,!1);for(const j of t(this,$).values())j.disable()}},qn=function(j){const $t=t(this,$).get(j.pageIndex);$t?$t.addOrRebuild(j):this.addEditor(j)},gn=function(){if(t(this,F).size===0)return!0;if(t(this,F).size===1)for(const j of t(this,F).values())return j.isEmpty();return!1},Vn=function(j){t(this,L).clear();for(const $t of j)$t.isEmpty()||(t(this,L).add($t),$t.select());K(this,bt,en).call(this,{hasSelectedEditor:!0})},Fe(ge,"TRANSLATE_SMALL",1),Fe(ge,"TRANSLATE_BIG",10);let T=ge;e.AnnotationEditorUIManager=T}),((d,e,b)=>{var H,_t,D,W,J,S,n,s,p,M,O,L,cn,un,Yn,Fn,wn,mn,bn;Object.defineProperty(e,"__esModule",{value:!0}),e.StatTimer=e.RenderingCancelledException=e.PixelsPerInch=e.PageViewport=e.PDFDateString=e.DOMStandardFontDataFactory=e.DOMSVGFactory=e.DOMFilterFactory=e.DOMCanvasFactory=e.DOMCMapReaderFactory=void 0,e.deprecated=a,e.getColorValues=F,e.getCurrentTransform=$,e.getCurrentTransformInverse=wt,e.getFilenameFromUrl=c,e.getPdfFilenameFromUrl=C,e.getRGB=o,e.getXfaPageViewport=R,e.isDataScheme=E,e.isPdfFile=_,e.isValidFetchUrl=m,e.loadScript=h,e.noContextMenu=r,e.setLayerDimensions=U;var i=b(7),y=b(1);const Q="http://www.w3.org/2000/svg",G=class G{};Fe(G,"CSS",96),Fe(G,"PDF",72),Fe(G,"PDF_TO_CSS_UNITS",G.CSS/G.PDF);let z=G;e.PixelsPerInch=z;class xt extends i.BaseFilterFactory{constructor({docId:v,ownerDocument:N=globalThis.document}={}){super();Tt(this,L);Tt(this,H);Tt(this,_t);Tt(this,D);Tt(this,W);Tt(this,J);Tt(this,S);Tt(this,n);Tt(this,s);Tt(this,p);Tt(this,M);Tt(this,O,0);Rt(this,D,v),Rt(this,W,N)}addFilter(v){if(!v)return"none";let N=t(this,L,cn).get(v);if(N)return N;let Z,St,Nt,zt;if(v.length===1){const Kt=v[0],ce=new Array(256);for(let oe=0;oe<256;oe++)ce[oe]=Kt[oe]/255;zt=Z=St=Nt=ce.join(",")}else{const[Kt,ce,oe]=v,me=new Array(256),Qt=new Array(256),re=new Array(256);for(let pe=0;pe<256;pe++)me[pe]=Kt[pe]/255,Qt[pe]=ce[pe]/255,re[pe]=oe[pe]/255;Z=me.join(","),St=Qt.join(","),Nt=re.join(","),zt=`${Z}${St}${Nt}`}if(N=t(this,L,cn).get(zt),N)return t(this,L,cn).set(v,N),N;const qt=`g_${t(this,D)}_transfer_map_${fn(this,O)._++}`,bt=`url(#${qt})`;t(this,L,cn).set(v,bt),t(this,L,cn).set(zt,bt);const Jt=K(this,L,Fn).call(this,qt);return K(this,L,mn).call(this,Z,St,Nt,Jt),bt}addHCMFilter(v,N){var ce;const Z=`${v}-${N}`;if(t(this,S)===Z)return t(this,n);if(Rt(this,S,Z),Rt(this,n,"none"),(ce=t(this,J))==null||ce.remove(),!v||!N)return t(this,n);const St=K(this,L,bn).call(this,v);v=y.Util.makeHexColor(...St);const Nt=K(this,L,bn).call(this,N);if(N=y.Util.makeHexColor(...Nt),t(this,L,un).style.color="",v==="#000000"&&N==="#ffffff"||v===N)return t(this,n);const zt=new Array(256);for(let oe=0;oe<=255;oe++){const me=oe/255;zt[oe]=me<=.03928?me/12.92:((me+.055)/1.055)**2.4}const qt=zt.join(","),bt=`g_${t(this,D)}_hcm_filter`,Jt=Rt(this,s,K(this,L,Fn).call(this,bt));K(this,L,mn).call(this,qt,qt,qt,Jt),K(this,L,Yn).call(this,Jt);const Kt=(oe,me)=>{const Qt=St[oe]/255,re=Nt[oe]/255,pe=new Array(me+1);for(let Ee=0;Ee<=me;Ee++)pe[Ee]=Qt+Ee/me*(re-Qt);return pe.join(",")};return K(this,L,mn).call(this,Kt(0,5),Kt(1,5),Kt(2,5),Jt),Rt(this,n,`url(#${bt})`),t(this,n)}addHighlightHCMFilter(v,N,Z,St){var re;const Nt=`${v}-${N}-${Z}-${St}`;if(t(this,p)===Nt)return t(this,M);if(Rt(this,p,Nt),Rt(this,M,"none"),(re=t(this,s))==null||re.remove(),!v||!N)return t(this,M);const[zt,qt]=[v,N].map(K(this,L,bn).bind(this));let bt=Math.round(.2126*zt[0]+.7152*zt[1]+.0722*zt[2]),Jt=Math.round(.2126*qt[0]+.7152*qt[1]+.0722*qt[2]),[Kt,ce]=[Z,St].map(K(this,L,bn).bind(this));Jt<bt&&([bt,Jt,Kt,ce]=[Jt,bt,ce,Kt]),t(this,L,un).style.color="";const oe=(pe,Ee,Gt)=>{const Pt=new Array(256),Mt=(Jt-bt)/Gt,te=pe/255,ge=(Ee-pe)/(255*Gt);let de=0;for(let j=0;j<=Gt;j++){const $t=Math.round(bt+j*Mt),Y=te+j*ge;for(let Lt=de;Lt<=$t;Lt++)Pt[Lt]=Y;de=$t+1}for(let j=de;j<256;j++)Pt[j]=Pt[de-1];return Pt.join(",")},me=`g_${t(this,D)}_hcm_highlight_filter`,Qt=Rt(this,s,K(this,L,Fn).call(this,me));return K(this,L,Yn).call(this,Qt),K(this,L,mn).call(this,oe(Kt[0],ce[0],5),oe(Kt[1],ce[1],5),oe(Kt[2],ce[2],5),Qt),Rt(this,M,`url(#${me})`),t(this,M)}destroy(v=!1){v&&(t(this,n)||t(this,M))||(t(this,_t)&&(t(this,_t).parentNode.parentNode.remove(),Rt(this,_t,null)),t(this,H)&&(t(this,H).clear(),Rt(this,H,null)),Rt(this,O,0))}}H=new WeakMap,_t=new WeakMap,D=new WeakMap,W=new WeakMap,J=new WeakMap,S=new WeakMap,n=new WeakMap,s=new WeakMap,p=new WeakMap,M=new WeakMap,O=new WeakMap,L=new WeakSet,cn=function(){return t(this,H)||Rt(this,H,new Map)},un=function(){if(!t(this,_t)){const v=t(this,W).createElement("div"),{style:N}=v;N.visibility="hidden",N.contain="strict",N.width=N.height=0,N.position="absolute",N.top=N.left=0,N.zIndex=-1;const Z=t(this,W).createElementNS(Q,"svg");Z.setAttribute("width",0),Z.setAttribute("height",0),Rt(this,_t,t(this,W).createElementNS(Q,"defs")),v.append(Z),Z.append(t(this,_t)),t(this,W).body.append(v)}return t(this,_t)},Yn=function(v){const N=t(this,W).createElementNS(Q,"feColorMatrix");N.setAttribute("type","matrix"),N.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),v.append(N)},Fn=function(v){const N=t(this,W).createElementNS(Q,"filter");return N.setAttribute("color-interpolation-filters","sRGB"),N.setAttribute("id",v),t(this,L,un).append(N),N},wn=function(v,N,Z){const St=t(this,W).createElementNS(Q,N);St.setAttribute("type","discrete"),St.setAttribute("tableValues",Z),v.append(St)},mn=function(v,N,Z,St){const Nt=t(this,W).createElementNS(Q,"feComponentTransfer");St.append(Nt),K(this,L,wn).call(this,Nt,"feFuncR",v),K(this,L,wn).call(this,Nt,"feFuncG",N),K(this,L,wn).call(this,Nt,"feFuncB",Z)},bn=function(v){return t(this,L,un).style.color=v,o(getComputedStyle(t(this,L,un)).getPropertyValue("color"))},e.DOMFilterFactory=xt;class B extends i.BaseCanvasFactory{constructor({ownerDocument:kt=globalThis.document}={}){super(),this._document=kt}_createCanvas(kt,v){const N=this._document.createElement("canvas");return N.width=kt,N.height=v,N}}e.DOMCanvasFactory=B;async function k(vt,kt=!1){if(m(vt,document.baseURI)){const v=await fetch(vt);if(!v.ok)throw new Error(v.statusText);return kt?new Uint8Array(await v.arrayBuffer()):(0,y.stringToBytes)(await v.text())}return new Promise((v,N)=>{const Z=new XMLHttpRequest;Z.open("GET",vt,!0),kt&&(Z.responseType="arraybuffer"),Z.onreadystatechange=()=>{if(Z.readyState===XMLHttpRequest.DONE){if(Z.status===200||Z.status===0){let St;if(kt&&Z.response?St=new Uint8Array(Z.response):!kt&&Z.responseText&&(St=(0,y.stringToBytes)(Z.responseText)),St){v(St);return}}N(new Error(Z.statusText))}},Z.send(null)})}class f extends i.BaseCMapReaderFactory{_fetchData(kt,v){return k(kt,this.isCompressed).then(N=>({cMapData:N,compressionType:v}))}}e.DOMCMapReaderFactory=f;class P extends i.BaseStandardFontDataFactory{_fetchData(kt){return k(kt,!0)}}e.DOMStandardFontDataFactory=P;class T extends i.BaseSVGFactory{_createSVG(kt){return document.createElementNS(Q,kt)}}e.DOMSVGFactory=T;class A{constructor({viewBox:kt,scale:v,rotation:N,offsetX:Z=0,offsetY:St=0,dontFlip:Nt=!1}){this.viewBox=kt,this.scale=v,this.rotation=N,this.offsetX=Z,this.offsetY=St;const zt=(kt[2]+kt[0])/2,qt=(kt[3]+kt[1])/2;let bt,Jt,Kt,ce;switch(N%=360,N<0&&(N+=360),N){case 180:bt=-1,Jt=0,Kt=0,ce=1;break;case 90:bt=0,Jt=1,Kt=1,ce=0;break;case 270:bt=0,Jt=-1,Kt=-1,ce=0;break;case 0:bt=1,Jt=0,Kt=0,ce=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}Nt&&(Kt=-Kt,ce=-ce);let oe,me,Qt,re;bt===0?(oe=Math.abs(qt-kt[1])*v+Z,me=Math.abs(zt-kt[0])*v+St,Qt=(kt[3]-kt[1])*v,re=(kt[2]-kt[0])*v):(oe=Math.abs(zt-kt[0])*v+Z,me=Math.abs(qt-kt[1])*v+St,Qt=(kt[2]-kt[0])*v,re=(kt[3]-kt[1])*v),this.transform=[bt*v,Jt*v,Kt*v,ce*v,oe-bt*v*zt-Kt*v*qt,me-Jt*v*zt-ce*v*qt],this.width=Qt,this.height=re}get rawDims(){const{viewBox:kt}=this;return(0,y.shadow)(this,"rawDims",{pageWidth:kt[2]-kt[0],pageHeight:kt[3]-kt[1],pageX:kt[0],pageY:kt[1]})}clone({scale:kt=this.scale,rotation:v=this.rotation,offsetX:N=this.offsetX,offsetY:Z=this.offsetY,dontFlip:St=!1}={}){return new A({viewBox:this.viewBox.slice(),scale:kt,rotation:v,offsetX:N,offsetY:Z,dontFlip:St})}convertToViewportPoint(kt,v){return y.Util.applyTransform([kt,v],this.transform)}convertToViewportRectangle(kt){const v=y.Util.applyTransform([kt[0],kt[1]],this.transform),N=y.Util.applyTransform([kt[2],kt[3]],this.transform);return[v[0],v[1],N[0],N[1]]}convertToPdfPoint(kt,v){return y.Util.applyInverseTransform([kt,v],this.transform)}}e.PageViewport=A;class g extends y.BaseException{constructor(kt,v=0){super(kt,"RenderingCancelledException"),this.extraDelay=v}}e.RenderingCancelledException=g;function E(vt){const kt=vt.length;let v=0;for(;v<kt&&vt[v].trim()==="";)v++;return vt.substring(v,v+5).toLowerCase()==="data:"}function _(vt){return typeof vt=="string"&&/\.pdf$/i.test(vt)}function c(vt,kt=!1){return kt||([vt]=vt.split(/[#?]/,1)),vt.substring(vt.lastIndexOf("/")+1)}function C(vt,kt="document.pdf"){if(typeof vt!="string")return kt;if(E(vt))return(0,y.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),kt;const v=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,N=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,Z=v.exec(vt);let St=N.exec(Z[1])||N.exec(Z[2])||N.exec(Z[3]);if(St&&(St=St[0],St.includes("%")))try{St=N.exec(decodeURIComponent(St))[0]}catch{}return St||kt}class I{constructor(){Fe(this,"started",Object.create(null));Fe(this,"times",[])}time(kt){kt in this.started&&(0,y.warn)(`Timer is already running for ${kt}`),this.started[kt]=Date.now()}timeEnd(kt){kt in this.started||(0,y.warn)(`Timer has not been started for ${kt}`),this.times.push({name:kt,start:this.started[kt],end:Date.now()}),delete this.started[kt]}toString(){const kt=[];let v=0;for(const{name:N}of this.times)v=Math.max(N.length,v);for(const{name:N,start:Z,end:St}of this.times)kt.push(`${N.padEnd(v)} ${St-Z}ms
37
+ `);return kt.join("")}}e.StatTimer=I;function m(vt,kt){try{const{protocol:v}=kt?new URL(vt,kt):new URL(vt);return v==="http:"||v==="https:"}catch{return!1}}function r(vt){vt.preventDefault()}function h(vt,kt=!1){return new Promise((v,N)=>{const Z=document.createElement("script");Z.src=vt,Z.onload=function(St){kt&&Z.remove(),v(St)},Z.onerror=function(){N(new Error(`Cannot load script at: ${Z.src}`))},(document.head||document.documentElement).append(Z)})}function a(vt){console.log("Deprecated API usage: "+vt)}let l;class u{static toDateObject(kt){if(!kt||typeof kt!="string")return null;l||(l=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const v=l.exec(kt);if(!v)return null;const N=parseInt(v[1],10);let Z=parseInt(v[2],10);Z=Z>=1&&Z<=12?Z-1:0;let St=parseInt(v[3],10);St=St>=1&&St<=31?St:1;let Nt=parseInt(v[4],10);Nt=Nt>=0&&Nt<=23?Nt:0;let zt=parseInt(v[5],10);zt=zt>=0&&zt<=59?zt:0;let qt=parseInt(v[6],10);qt=qt>=0&&qt<=59?qt:0;const bt=v[7]||"Z";let Jt=parseInt(v[8],10);Jt=Jt>=0&&Jt<=23?Jt:0;let Kt=parseInt(v[9],10)||0;return Kt=Kt>=0&&Kt<=59?Kt:0,bt==="-"?(Nt+=Jt,zt+=Kt):bt==="+"&&(Nt-=Jt,zt-=Kt),new Date(Date.UTC(N,Z,St,Nt,zt,qt))}}e.PDFDateString=u;function R(vt,{scale:kt=1,rotation:v=0}){const{width:N,height:Z}=vt.attributes.style,St=[0,0,parseInt(N),parseInt(Z)];return new A({viewBox:St,scale:kt,rotation:v})}function o(vt){if(vt.startsWith("#")){const kt=parseInt(vt.slice(1),16);return[(kt&16711680)>>16,(kt&65280)>>8,kt&255]}return vt.startsWith("rgb(")?vt.slice(4,-1).split(",").map(kt=>parseInt(kt)):vt.startsWith("rgba(")?vt.slice(5,-1).split(",").map(kt=>parseInt(kt)).slice(0,3):((0,y.warn)(`Not a valid color format: "${vt}"`),[0,0,0])}function F(vt){const kt=document.createElement("span");kt.style.visibility="hidden",document.body.append(kt);for(const v of vt.keys()){kt.style.color=v;const N=window.getComputedStyle(kt).color;vt.set(v,o(N))}kt.remove()}function $(vt){const{a:kt,b:v,c:N,d:Z,e:St,f:Nt}=vt.getTransform();return[kt,v,N,Z,St,Nt]}function wt(vt){const{a:kt,b:v,c:N,d:Z,e:St,f:Nt}=vt.getTransform().invertSelf();return[kt,v,N,Z,St,Nt]}function U(vt,kt,v=!1,N=!0){if(kt instanceof A){const{pageWidth:Z,pageHeight:St}=kt.rawDims,{style:Nt}=vt,zt=y.FeatureTest.isCSSRoundSupported,qt=`var(--scale-factor) * ${Z}px`,bt=`var(--scale-factor) * ${St}px`,Jt=zt?`round(${qt}, 1px)`:`calc(${qt})`,Kt=zt?`round(${bt}, 1px)`:`calc(${bt})`;!v||kt.rotation%180===0?(Nt.width=Jt,Nt.height=Kt):(Nt.width=Kt,Nt.height=Jt)}N&&vt.setAttribute("data-main-rotation",kt.rotation)}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseStandardFontDataFactory=e.BaseSVGFactory=e.BaseFilterFactory=e.BaseCanvasFactory=e.BaseCMapReaderFactory=void 0;var i=b(1);class y{constructor(){this.constructor===y&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(f){return"none"}addHCMFilter(f,P){return"none"}addHighlightHCMFilter(f,P,T,A){return"none"}destroy(f=!1){}}e.BaseFilterFactory=y;class Q{constructor(){this.constructor===Q&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(f,P){if(f<=0||P<=0)throw new Error("Invalid canvas size");const T=this._createCanvas(f,P);return{canvas:T,context:T.getContext("2d")}}reset(f,P,T){if(!f.canvas)throw new Error("Canvas is not specified");if(P<=0||T<=0)throw new Error("Invalid canvas size");f.canvas.width=P,f.canvas.height=T}destroy(f){if(!f.canvas)throw new Error("Canvas is not specified");f.canvas.width=0,f.canvas.height=0,f.canvas=null,f.context=null}_createCanvas(f,P){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}e.BaseCanvasFactory=Q;class z{constructor({baseUrl:f=null,isCompressed:P=!0}){this.constructor===z&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=f,this.isCompressed=P}async fetch({name:f}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!f)throw new Error("CMap name must be specified.");const P=this.baseUrl+f+(this.isCompressed?".bcmap":""),T=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(P,T).catch(A=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${P}`)})}_fetchData(f,P){(0,i.unreachable)("Abstract method `_fetchData` called.")}}e.BaseCMapReaderFactory=z;class xt{constructor({baseUrl:f=null}){this.constructor===xt&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=f}async fetch({filename:f}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!f)throw new Error("Font filename must be specified.");const P=`${this.baseUrl}${f}`;return this._fetchData(P).catch(T=>{throw new Error(`Unable to load font data at: ${P}`)})}_fetchData(f){(0,i.unreachable)("Abstract method `_fetchData` called.")}}e.BaseStandardFontDataFactory=xt;class B{constructor(){this.constructor===B&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(f,P,T=!1){if(f<=0||P<=0)throw new Error("Invalid SVG dimensions");const A=this._createSVG("svg:svg");return A.setAttribute("version","1.1"),T||(A.setAttribute("width",`${f}px`),A.setAttribute("height",`${P}px`)),A.setAttribute("preserveAspectRatio","none"),A.setAttribute("viewBox",`0 0 ${f} ${P}`),A}createElement(f){if(typeof f!="string")throw new Error("Invalid SVG element type");return this._createSVG(f)}_createSVG(f){(0,i.unreachable)("Abstract method `_createSVG` called.")}}e.BaseSVGFactory=B}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MurmurHash3_64=void 0;var i=b(1);const y=3285377520,Q=4294901760,z=65535;class xt{constructor(k){this.h1=k?k&4294967295:y,this.h2=k?k&4294967295:y}update(k){let f,P;if(typeof k=="string"){f=new Uint8Array(k.length*2),P=0;for(let a=0,l=k.length;a<l;a++){const u=k.charCodeAt(a);u<=255?f[P++]=u:(f[P++]=u>>>8,f[P++]=u&255)}}else if((0,i.isArrayBuffer)(k))f=k.slice(),P=f.byteLength;else throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");const T=P>>2,A=P-T*4,g=new Uint32Array(f.buffer,0,T);let E=0,_=0,c=this.h1,C=this.h2;const I=3432918353,m=461845907,r=I&z,h=m&z;for(let a=0;a<T;a++)a&1?(E=g[a],E=E*I&Q|E*r&z,E=E<<15|E>>>17,E=E*m&Q|E*h&z,c^=E,c=c<<13|c>>>19,c=c*5+3864292196):(_=g[a],_=_*I&Q|_*r&z,_=_<<15|_>>>17,_=_*m&Q|_*h&z,C^=_,C=C<<13|C>>>19,C=C*5+3864292196);switch(E=0,A){case 3:E^=f[T*4+2]<<16;case 2:E^=f[T*4+1]<<8;case 1:E^=f[T*4],E=E*I&Q|E*r&z,E=E<<15|E>>>17,E=E*m&Q|E*h&z,T&1?c^=E:C^=E}this.h1=c,this.h2=C}hexdigest(){let k=this.h1,f=this.h2;return k^=f>>>1,k=k*3981806797&Q|k*36045&z,f=f*4283543511&Q|((f<<16|k>>>16)*2950163797&Q)>>>16,k^=f>>>1,k=k*444984403&Q|k*60499&z,f=f*3301882366&Q|((f<<16|k>>>16)*3120437893&Q)>>>16,k^=f>>>1,(k>>>0).toString(16).padStart(8,"0")+(f>>>0).toString(16).padStart(8,"0")}}e.MurmurHash3_64=xt}),((d,e,b)=>{var z;Object.defineProperty(e,"__esModule",{value:!0}),e.FontLoader=e.FontFaceObject=void 0;var i=b(1);class y{constructor({ownerDocument:B=globalThis.document,styleElement:k=null}){Tt(this,z,new Set);this._document=B,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(B){this.nativeFontFaces.add(B),this._document.fonts.add(B)}removeNativeFontFace(B){this.nativeFontFaces.delete(B),this._document.fonts.delete(B)}insertRule(B){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const k=this.styleElement.sheet;k.insertRule(B,k.cssRules.length)}clear(){for(const B of this.nativeFontFaces)this._document.fonts.delete(B);this.nativeFontFaces.clear(),t(this,z).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont(B){if(!(!B||t(this,z).has(B.loadedName))){if((0,i.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:k,src:f,style:P}=B,T=new FontFace(k,f,P);this.addNativeFontFace(T);try{await T.load(),t(this,z).add(k)}catch{(0,i.warn)(`Cannot load system font: ${B.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(T)}return}(0,i.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(B){if(B.attached||B.missingFile&&!B.systemFontInfo)return;if(B.attached=!0,B.systemFontInfo){await this.loadSystemFont(B.systemFontInfo);return}if(this.isFontLoadingAPISupported){const f=B.createNativeFontFace();if(f){this.addNativeFontFace(f);try{await f.loaded}catch(P){throw(0,i.warn)(`Failed to load font '${f.family}': '${P}'.`),B.disableFontFace=!0,P}}return}const k=B.createFontFaceRule();if(k){if(this.insertRule(k),this.isSyncFontLoadingSupported)return;await new Promise(f=>{const P=this._queueLoadingCallback(f);this._prepareFontLoadEvent(B,P)})}}get isFontLoadingAPISupported(){var k;const B=!!((k=this._document)!=null&&k.fonts);return(0,i.shadow)(this,"isFontLoadingAPISupported",B)}get isSyncFontLoadingSupported(){let B=!1;return(i.isNodeJS||typeof navigator<"u"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(B=!0),(0,i.shadow)(this,"isSyncFontLoadingSupported",B)}_queueLoadingCallback(B){function k(){for((0,i.assert)(!P.done,"completeRequest() cannot be called twice."),P.done=!0;f.length>0&&f[0].done;){const T=f.shift();setTimeout(T.callback,0)}}const{loadingRequests:f}=this,P={done:!1,complete:k,callback:B};return f.push(P),P}get _loadTestFont(){const B=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,i.shadow)(this,"_loadTestFont",B)}_prepareFontLoadEvent(B,k){function f(o,F){return o.charCodeAt(F)<<24|o.charCodeAt(F+1)<<16|o.charCodeAt(F+2)<<8|o.charCodeAt(F+3)&255}function P(o,F,$,wt){const U=o.substring(0,F),G=o.substring(F+$);return U+wt+G}let T,A;const g=this._document.createElement("canvas");g.width=1,g.height=1;const E=g.getContext("2d");let _=0;function c(o,F){if(++_>30){(0,i.warn)("Load test font never loaded."),F();return}if(E.font="30px "+o,E.fillText(".",0,20),E.getImageData(0,0,1,1).data[3]>0){F();return}setTimeout(c.bind(null,o,F))}const C=`lt${Date.now()}${this.loadTestFontId++}`;let I=this._loadTestFont;I=P(I,976,C.length,C);const r=16,h=1482184792;let a=f(I,r);for(T=0,A=C.length-3;T<A;T+=4)a=a-h+f(C,T)|0;T<C.length&&(a=a-h+f(C+"XXX",T)|0),I=P(I,r,4,(0,i.string32)(a));const l=`url(data:font/opentype;base64,${btoa(I)});`,u=`@font-face {font-family:"${C}";src:${l}}`;this.insertRule(u);const R=this._document.createElement("div");R.style.visibility="hidden",R.style.width=R.style.height="10px",R.style.position="absolute",R.style.top=R.style.left="0px";for(const o of[B.loadedName,C]){const F=this._document.createElement("span");F.textContent="Hi",F.style.fontFamily=o,R.append(F)}this._document.body.append(R),c(C,()=>{R.remove(),k.complete()})}}z=new WeakMap,e.FontLoader=y;class Q{constructor(B,{isEvalSupported:k=!0,disableFontFace:f=!1,ignoreErrors:P=!1,inspectFont:T=null}){this.compiledGlyphs=Object.create(null);for(const A in B)this[A]=B[A];this.isEvalSupported=k!==!1,this.disableFontFace=f===!0,this.ignoreErrors=P===!0,this._inspectFont=T}createNativeFontFace(){var k;if(!this.data||this.disableFontFace)return null;let B;if(!this.cssFontInfo)B=new FontFace(this.loadedName,this.data,{});else{const f={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(f.style=`oblique ${this.cssFontInfo.italicAngle}deg`),B=new FontFace(this.cssFontInfo.fontFamily,this.data,f)}return(k=this._inspectFont)==null||k.call(this,this),B}createFontFaceRule(){var P;if(!this.data||this.disableFontFace)return null;const B=(0,i.bytesToString)(this.data),k=`url(data:${this.mimetype};base64,${btoa(B)});`;let f;if(!this.cssFontInfo)f=`@font-face {font-family:"${this.loadedName}";src:${k}}`;else{let T=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(T+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),f=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${T}src:${k}}`}return(P=this._inspectFont)==null||P.call(this,this,k),f}getPathGenerator(B,k){if(this.compiledGlyphs[k]!==void 0)return this.compiledGlyphs[k];let f;try{f=B.get(this.loadedName+"_path_"+k)}catch(P){if(!this.ignoreErrors)throw P;return(0,i.warn)(`getPathGenerator - ignoring character: "${P}".`),this.compiledGlyphs[k]=function(T,A){}}if(this.isEvalSupported&&i.FeatureTest.isEvalSupported){const P=[];for(const T of f){const A=T.args!==void 0?T.args.join(","):"";P.push("c.",T.cmd,"(",A,`);
38
+ `)}return this.compiledGlyphs[k]=new Function("c","size",P.join(""))}return this.compiledGlyphs[k]=function(P,T){for(const A of f)A.cmd==="scale"&&(A.args=[T,-T]),P[A.cmd].apply(P,A.args)}}}e.FontFaceObject=Q}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NodeStandardFontDataFactory=e.NodeFilterFactory=e.NodeCanvasFactory=e.NodeCMapReaderFactory=void 0;var i=b(7);b(1);const y=function(k){return new Promise((f,P)=>{require$$0.readFile(k,(A,g)=>{if(A||!g){P(new Error(A));return}f(new Uint8Array(g))})})};class Q extends i.BaseFilterFactory{}e.NodeFilterFactory=Q;class z extends i.BaseCanvasFactory{_createCanvas(f,P){return require$$0.createCanvas(f,P)}}e.NodeCanvasFactory=z;class xt extends i.BaseCMapReaderFactory{_fetchData(f,P){return y(f).then(T=>({cMapData:T,compressionType:P}))}}e.NodeCMapReaderFactory=xt;class B extends i.BaseStandardFontDataFactory{_fetchData(f){return y(f)}}e.NodeStandardFontDataFactory=B}),((d,e,b)=>{var _t,Kn,Jn;Object.defineProperty(e,"__esModule",{value:!0}),e.CanvasGraphics=void 0;var i=b(1),y=b(6),Q=b(12),z=b(13);const xt=16,B=100,k=4096,f=15,P=10,T=1e3,A=16;function g(S,n){if(S._removeMirroring)throw new Error("Context is already forwarding operations.");S.__originalSave=S.save,S.__originalRestore=S.restore,S.__originalRotate=S.rotate,S.__originalScale=S.scale,S.__originalTranslate=S.translate,S.__originalTransform=S.transform,S.__originalSetTransform=S.setTransform,S.__originalResetTransform=S.resetTransform,S.__originalClip=S.clip,S.__originalMoveTo=S.moveTo,S.__originalLineTo=S.lineTo,S.__originalBezierCurveTo=S.bezierCurveTo,S.__originalRect=S.rect,S.__originalClosePath=S.closePath,S.__originalBeginPath=S.beginPath,S._removeMirroring=()=>{S.save=S.__originalSave,S.restore=S.__originalRestore,S.rotate=S.__originalRotate,S.scale=S.__originalScale,S.translate=S.__originalTranslate,S.transform=S.__originalTransform,S.setTransform=S.__originalSetTransform,S.resetTransform=S.__originalResetTransform,S.clip=S.__originalClip,S.moveTo=S.__originalMoveTo,S.lineTo=S.__originalLineTo,S.bezierCurveTo=S.__originalBezierCurveTo,S.rect=S.__originalRect,S.closePath=S.__originalClosePath,S.beginPath=S.__originalBeginPath,delete S._removeMirroring},S.save=function(){n.save(),this.__originalSave()},S.restore=function(){n.restore(),this.__originalRestore()},S.translate=function(p,M){n.translate(p,M),this.__originalTranslate(p,M)},S.scale=function(p,M){n.scale(p,M),this.__originalScale(p,M)},S.transform=function(p,M,O,L,V,At){n.transform(p,M,O,L,V,At),this.__originalTransform(p,M,O,L,V,At)},S.setTransform=function(p,M,O,L,V,At){n.setTransform(p,M,O,L,V,At),this.__originalSetTransform(p,M,O,L,V,At)},S.resetTransform=function(){n.resetTransform(),this.__originalResetTransform()},S.rotate=function(p){n.rotate(p),this.__originalRotate(p)},S.clip=function(p){n.clip(p),this.__originalClip(p)},S.moveTo=function(s,p){n.moveTo(s,p),this.__originalMoveTo(s,p)},S.lineTo=function(s,p){n.lineTo(s,p),this.__originalLineTo(s,p)},S.bezierCurveTo=function(s,p,M,O,L,V){n.bezierCurveTo(s,p,M,O,L,V),this.__originalBezierCurveTo(s,p,M,O,L,V)},S.rect=function(s,p,M,O){n.rect(s,p,M,O),this.__originalRect(s,p,M,O)},S.closePath=function(){n.closePath(),this.__originalClosePath()},S.beginPath=function(){n.beginPath(),this.__originalBeginPath()}}class E{constructor(n){this.canvasFactory=n,this.cache=Object.create(null)}getCanvas(n,s,p){let M;return this.cache[n]!==void 0?(M=this.cache[n],this.canvasFactory.reset(M,s,p)):(M=this.canvasFactory.create(s,p),this.cache[n]=M),M}delete(n){delete this.cache[n]}clear(){for(const n in this.cache){const s=this.cache[n];this.canvasFactory.destroy(s),delete this.cache[n]}}}function _(S,n,s,p,M,O,L,V,At,It){const[Bt,jt,Ut,Xt,vt,kt]=(0,y.getCurrentTransform)(S);if(jt===0&&Ut===0){const Z=L*Bt+vt,St=Math.round(Z),Nt=V*Xt+kt,zt=Math.round(Nt),qt=(L+At)*Bt+vt,bt=Math.abs(Math.round(qt)-St)||1,Jt=(V+It)*Xt+kt,Kt=Math.abs(Math.round(Jt)-zt)||1;return S.setTransform(Math.sign(Bt),0,0,Math.sign(Xt),St,zt),S.drawImage(n,s,p,M,O,0,0,bt,Kt),S.setTransform(Bt,jt,Ut,Xt,vt,kt),[bt,Kt]}if(Bt===0&&Xt===0){const Z=V*Ut+vt,St=Math.round(Z),Nt=L*jt+kt,zt=Math.round(Nt),qt=(V+It)*Ut+vt,bt=Math.abs(Math.round(qt)-St)||1,Jt=(L+At)*jt+kt,Kt=Math.abs(Math.round(Jt)-zt)||1;return S.setTransform(0,Math.sign(jt),Math.sign(Ut),0,St,zt),S.drawImage(n,s,p,M,O,0,0,Kt,bt),S.setTransform(Bt,jt,Ut,Xt,vt,kt),[Kt,bt]}S.drawImage(n,s,p,M,O,L,V,At,It);const v=Math.hypot(Bt,jt),N=Math.hypot(Ut,Xt);return[v*At,N*It]}function c(S){const{width:n,height:s}=S;if(n>T||s>T)return null;const p=1e3,M=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),O=n+1;let L=new Uint8Array(O*(s+1)),V,At,It;const Bt=n+7&-8;let jt=new Uint8Array(Bt*s),Ut=0;for(const N of S.data){let Z=128;for(;Z>0;)jt[Ut++]=N&Z?0:255,Z>>=1}let Xt=0;for(Ut=0,jt[Ut]!==0&&(L[0]=1,++Xt),At=1;At<n;At++)jt[Ut]!==jt[Ut+1]&&(L[At]=jt[Ut]?2:1,++Xt),Ut++;for(jt[Ut]!==0&&(L[At]=2,++Xt),V=1;V<s;V++){Ut=V*Bt,It=V*O,jt[Ut-Bt]!==jt[Ut]&&(L[It]=jt[Ut]?1:8,++Xt);let N=(jt[Ut]?4:0)+(jt[Ut-Bt]?8:0);for(At=1;At<n;At++)N=(N>>2)+(jt[Ut+1]?4:0)+(jt[Ut-Bt+1]?8:0),M[N]&&(L[It+At]=M[N],++Xt),Ut++;if(jt[Ut-Bt]!==jt[Ut]&&(L[It+At]=jt[Ut]?2:4,++Xt),Xt>p)return null}for(Ut=Bt*(s-1),It=V*O,jt[Ut]!==0&&(L[It]=8,++Xt),At=1;At<n;At++)jt[Ut]!==jt[Ut+1]&&(L[It+At]=jt[Ut]?4:8,++Xt),Ut++;if(jt[Ut]!==0&&(L[It+At]=4,++Xt),Xt>p)return null;const vt=new Int32Array([0,O,-1,0,-O,0,0,0,1]),kt=new Path2D;for(V=0;Xt&&V<=s;V++){let N=V*O;const Z=N+n;for(;N<Z&&!L[N];)N++;if(N===Z)continue;kt.moveTo(N%O,V);const St=N;let Nt=L[N];do{const zt=vt[Nt];do N+=zt;while(!L[N]);const qt=L[N];qt!==5&&qt!==10?(Nt=qt,L[N]=0):(Nt=qt&51*Nt>>4,L[N]&=Nt>>2|Nt<<2),kt.lineTo(N%O,N/O|0),L[N]||--Xt}while(St!==N);--V}return jt=null,L=null,function(N){N.save(),N.scale(1/n,-1/s),N.translate(0,-s),N.fill(kt),N.beginPath(),N.restore()}}class C{constructor(n,s){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=i.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=i.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="none",this.startNewPathAndClipBox([0,0,n,s])}clone(){const n=Object.create(this);return n.clipBox=this.clipBox.slice(),n}setCurrentPoint(n,s){this.x=n,this.y=s}updatePathMinMax(n,s,p){[s,p]=i.Util.applyTransform([s,p],n),this.minX=Math.min(this.minX,s),this.minY=Math.min(this.minY,p),this.maxX=Math.max(this.maxX,s),this.maxY=Math.max(this.maxY,p)}updateRectMinMax(n,s){const p=i.Util.applyTransform(s,n),M=i.Util.applyTransform(s.slice(2),n);this.minX=Math.min(this.minX,p[0],M[0]),this.minY=Math.min(this.minY,p[1],M[1]),this.maxX=Math.max(this.maxX,p[0],M[0]),this.maxY=Math.max(this.maxY,p[1],M[1])}updateScalingPathMinMax(n,s){i.Util.scaleMinMax(n,s),this.minX=Math.min(this.minX,s[0]),this.maxX=Math.max(this.maxX,s[1]),this.minY=Math.min(this.minY,s[2]),this.maxY=Math.max(this.maxY,s[3])}updateCurvePathMinMax(n,s,p,M,O,L,V,At,It,Bt){const jt=i.Util.bezierBoundingBox(s,p,M,O,L,V,At,It);if(Bt){Bt[0]=Math.min(Bt[0],jt[0],jt[2]),Bt[1]=Math.max(Bt[1],jt[0],jt[2]),Bt[2]=Math.min(Bt[2],jt[1],jt[3]),Bt[3]=Math.max(Bt[3],jt[1],jt[3]);return}this.updateRectMinMax(n,jt)}getPathBoundingBox(n=Q.PathType.FILL,s=null){const p=[this.minX,this.minY,this.maxX,this.maxY];if(n===Q.PathType.STROKE){s||(0,i.unreachable)("Stroke bounding box must include transform.");const M=i.Util.singularValueDecompose2dScale(s),O=M[0]*this.lineWidth/2,L=M[1]*this.lineWidth/2;p[0]-=O,p[1]-=L,p[2]+=O,p[3]+=L}return p}updateClipFromPath(){const n=i.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(n||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(n){this.clipBox=n,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(n=Q.PathType.FILL,s=null){return i.Util.intersect(this.clipBox,this.getPathBoundingBox(n,s))}}function I(S,n){if(typeof ImageData<"u"&&n instanceof ImageData){S.putImageData(n,0,0);return}const s=n.height,p=n.width,M=s%A,O=(s-M)/A,L=M===0?O:O+1,V=S.createImageData(p,A);let At=0,It;const Bt=n.data,jt=V.data;let Ut,Xt,vt,kt;if(n.kind===i.ImageKind.GRAYSCALE_1BPP){const v=Bt.byteLength,N=new Uint32Array(jt.buffer,0,jt.byteLength>>2),Z=N.length,St=p+7>>3,Nt=4294967295,zt=i.FeatureTest.isLittleEndian?4278190080:255;for(Ut=0;Ut<L;Ut++){for(vt=Ut<O?A:M,It=0,Xt=0;Xt<vt;Xt++){const qt=v-At;let bt=0;const Jt=qt>St?p:qt*8-7,Kt=Jt&-8;let ce=0,oe=0;for(;bt<Kt;bt+=8)oe=Bt[At++],N[It++]=oe&128?Nt:zt,N[It++]=oe&64?Nt:zt,N[It++]=oe&32?Nt:zt,N[It++]=oe&16?Nt:zt,N[It++]=oe&8?Nt:zt,N[It++]=oe&4?Nt:zt,N[It++]=oe&2?Nt:zt,N[It++]=oe&1?Nt:zt;for(;bt<Jt;bt++)ce===0&&(oe=Bt[At++],ce=128),N[It++]=oe&ce?Nt:zt,ce>>=1}for(;It<Z;)N[It++]=0;S.putImageData(V,0,Ut*A)}}else if(n.kind===i.ImageKind.RGBA_32BPP){for(Xt=0,kt=p*A*4,Ut=0;Ut<O;Ut++)jt.set(Bt.subarray(At,At+kt)),At+=kt,S.putImageData(V,0,Xt),Xt+=A;Ut<L&&(kt=p*M*4,jt.set(Bt.subarray(At,At+kt)),S.putImageData(V,0,Xt))}else if(n.kind===i.ImageKind.RGB_24BPP)for(vt=A,kt=p*vt,Ut=0;Ut<L;Ut++){for(Ut>=O&&(vt=M,kt=p*vt),It=0,Xt=kt;Xt--;)jt[It++]=Bt[At++],jt[It++]=Bt[At++],jt[It++]=Bt[At++],jt[It++]=255;S.putImageData(V,0,Ut*A)}else throw new Error(`bad image kind: ${n.kind}`)}function m(S,n){if(n.bitmap){S.drawImage(n.bitmap,0,0);return}const s=n.height,p=n.width,M=s%A,O=(s-M)/A,L=M===0?O:O+1,V=S.createImageData(p,A);let At=0;const It=n.data,Bt=V.data;for(let jt=0;jt<L;jt++){const Ut=jt<O?A:M;({srcPos:At}=(0,z.convertBlackAndWhiteToRGBA)({src:It,srcPos:At,dest:Bt,width:p,height:Ut,nonBlackColor:0})),S.putImageData(V,0,jt*A)}}function r(S,n){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const p of s)S[p]!==void 0&&(n[p]=S[p]);S.setLineDash!==void 0&&(n.setLineDash(S.getLineDash()),n.lineDashOffset=S.lineDashOffset)}function h(S){if(S.strokeStyle=S.fillStyle="#000000",S.fillRule="nonzero",S.globalAlpha=1,S.lineWidth=1,S.lineCap="butt",S.lineJoin="miter",S.miterLimit=10,S.globalCompositeOperation="source-over",S.font="10px sans-serif",S.setLineDash!==void 0&&(S.setLineDash([]),S.lineDashOffset=0),!i.isNodeJS){const{filter:n}=S;n!=="none"&&n!==""&&(S.filter="none")}}function a(S,n,s,p){const M=S.length;for(let O=3;O<M;O+=4){const L=S[O];if(L===0)S[O-3]=n,S[O-2]=s,S[O-1]=p;else if(L<255){const V=255-L;S[O-3]=S[O-3]*L+n*V>>8,S[O-2]=S[O-2]*L+s*V>>8,S[O-1]=S[O-1]*L+p*V>>8}}}function l(S,n,s){const p=S.length,M=1/255;for(let O=3;O<p;O+=4){const L=s?s[S[O]]:S[O];n[O]=n[O]*L*M|0}}function u(S,n,s){const p=S.length;for(let M=3;M<p;M+=4){const O=S[M-3]*77+S[M-2]*152+S[M-1]*28;n[M]=s?n[M]*s[O>>8]>>8:n[M]*O>>16}}function R(S,n,s,p,M,O,L,V,At,It,Bt){const jt=!!O,Ut=jt?O[0]:0,Xt=jt?O[1]:0,vt=jt?O[2]:0,kt=M==="Luminosity"?u:l,N=Math.min(p,Math.ceil(1048576/s));for(let Z=0;Z<p;Z+=N){const St=Math.min(N,p-Z),Nt=S.getImageData(V-It,Z+(At-Bt),s,St),zt=n.getImageData(V,Z+At,s,St);jt&&a(Nt.data,Ut,Xt,vt),kt(Nt.data,zt.data,L),n.putImageData(zt,V,Z+At)}}function o(S,n,s,p){const M=p[0],O=p[1],L=p[2]-M,V=p[3]-O;L===0||V===0||(R(n.context,s,L,V,n.subtype,n.backdrop,n.transferMap,M,O,n.offsetX,n.offsetY),S.save(),S.globalAlpha=1,S.globalCompositeOperation="source-over",S.setTransform(1,0,0,1,0,0),S.drawImage(s.canvas,0,0),S.restore())}function F(S,n){const s=i.Util.singularValueDecompose2dScale(S);s[0]=Math.fround(s[0]),s[1]=Math.fround(s[1]);const p=Math.fround((globalThis.devicePixelRatio||1)*y.PixelsPerInch.PDF_TO_CSS_UNITS);return n!==void 0?n:s[0]<=p||s[1]<=p}const $=["butt","round","square"],wt=["miter","round","bevel"],U={},G={},J=class J{constructor(n,s,p,M,O,{optionalContentConfig:L,markedContentStack:V=null},At,It){Tt(this,_t);this.ctx=n,this.current=new C(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=s,this.objs=p,this.canvasFactory=M,this.filterFactory=O,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=V||[],this.optionalContentConfig=L,this.cachedCanvases=new E(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=At,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=It,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(n,s=null){return typeof n=="string"?n.startsWith("g_")?this.commonObjs.get(n):this.objs.get(n):s}beginDrawing({transform:n,viewport:s,transparency:p=!1,background:M=null}){const O=this.ctx.canvas.width,L=this.ctx.canvas.height,V=this.ctx.fillStyle;if(this.ctx.fillStyle=M||"#ffffff",this.ctx.fillRect(0,0,O,L),this.ctx.fillStyle=V,p){const At=this.cachedCanvases.getCanvas("transparent",O,L);this.compositeCtx=this.ctx,this.transparentCanvas=At.canvas,this.ctx=At.context,this.ctx.save(),this.ctx.transform(...(0,y.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),h(this.ctx),n&&(this.ctx.transform(...n),this.outputScaleX=n[0],this.outputScaleY=n[0]),this.ctx.transform(...s.transform),this.viewportScale=s.scale,this.baseTransform=(0,y.getCurrentTransform)(this.ctx)}executeOperatorList(n,s,p,M){const O=n.argsArray,L=n.fnArray;let V=s||0;const At=O.length;if(At===V)return V;const It=At-V>P&&typeof p=="function",Bt=It?Date.now()+f:0;let jt=0;const Ut=this.commonObjs,Xt=this.objs;let vt;for(;;){if(M!==void 0&&V===M.nextBreakPoint)return M.breakIt(V,p),V;if(vt=L[V],vt!==i.OPS.dependency)this[vt].apply(this,O[V]);else for(const kt of O[V]){const v=kt.startsWith("g_")?Ut:Xt;if(!v.has(kt))return v.get(kt,p),V}if(V++,V===At)return V;if(It&&++jt>P){if(Date.now()>Bt)return p(),V;jt=0}}}endDrawing(){K(this,_t,Kn).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const n of this._cachedBitmapsMap.values()){for(const s of n.values())typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement&&(s.width=s.height=0);n.clear()}this._cachedBitmapsMap.clear(),K(this,_t,Jn).call(this)}_scaleImage(n,s){const p=n.width,M=n.height;let O=Math.max(Math.hypot(s[0],s[1]),1),L=Math.max(Math.hypot(s[2],s[3]),1),V=p,At=M,It="prescale1",Bt,jt;for(;O>2&&V>1||L>2&&At>1;){let Ut=V,Xt=At;O>2&&V>1&&(Ut=V>=16384?Math.floor(V/2)-1||1:Math.ceil(V/2),O/=V/Ut),L>2&&At>1&&(Xt=At>=16384?Math.floor(At/2)-1||1:Math.ceil(At)/2,L/=At/Xt),Bt=this.cachedCanvases.getCanvas(It,Ut,Xt),jt=Bt.context,jt.clearRect(0,0,Ut,Xt),jt.drawImage(n,0,0,V,At,0,0,Ut,Xt),n=Bt.canvas,V=Ut,At=Xt,It=It==="prescale1"?"prescale2":"prescale1"}return{img:n,paintWidth:V,paintHeight:At}}_createMaskCanvas(n){const s=this.ctx,{width:p,height:M}=n,O=this.current.fillColor,L=this.current.patternFill,V=(0,y.getCurrentTransform)(s);let At,It,Bt,jt;if((n.bitmap||n.data)&&n.count>1){const bt=n.bitmap||n.data.buffer;It=JSON.stringify(L?V:[V.slice(0,4),O]),At=this._cachedBitmapsMap.get(bt),At||(At=new Map,this._cachedBitmapsMap.set(bt,At));const Jt=At.get(It);if(Jt&&!L){const Kt=Math.round(Math.min(V[0],V[2])+V[4]),ce=Math.round(Math.min(V[1],V[3])+V[5]);return{canvas:Jt,offsetX:Kt,offsetY:ce}}Bt=Jt}Bt||(jt=this.cachedCanvases.getCanvas("maskCanvas",p,M),m(jt.context,n));let Ut=i.Util.transform(V,[1/p,0,0,-1/M,0,0]);Ut=i.Util.transform(Ut,[1,0,0,1,0,-M]);const Xt=i.Util.applyTransform([0,0],Ut),vt=i.Util.applyTransform([p,M],Ut),kt=i.Util.normalizeRect([Xt[0],Xt[1],vt[0],vt[1]]),v=Math.round(kt[2]-kt[0])||1,N=Math.round(kt[3]-kt[1])||1,Z=this.cachedCanvases.getCanvas("fillCanvas",v,N),St=Z.context,Nt=Math.min(Xt[0],vt[0]),zt=Math.min(Xt[1],vt[1]);St.translate(-Nt,-zt),St.transform(...Ut),Bt||(Bt=this._scaleImage(jt.canvas,(0,y.getCurrentTransformInverse)(St)),Bt=Bt.img,At&&L&&At.set(It,Bt)),St.imageSmoothingEnabled=F((0,y.getCurrentTransform)(St),n.interpolate),_(St,Bt,0,0,Bt.width,Bt.height,0,0,p,M),St.globalCompositeOperation="source-in";const qt=i.Util.transform((0,y.getCurrentTransformInverse)(St),[1,0,0,1,-Nt,-zt]);return St.fillStyle=L?O.getPattern(s,this,qt,Q.PathType.FILL):O,St.fillRect(0,0,p,M),At&&!L&&(this.cachedCanvases.delete("fillCanvas"),At.set(It,Z.canvas)),{canvas:Z.canvas,offsetX:Math.round(Nt),offsetY:Math.round(zt)}}setLineWidth(n){n!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=n,this.ctx.lineWidth=n}setLineCap(n){this.ctx.lineCap=$[n]}setLineJoin(n){this.ctx.lineJoin=wt[n]}setMiterLimit(n){this.ctx.miterLimit=n}setDash(n,s){const p=this.ctx;p.setLineDash!==void 0&&(p.setLineDash(n),p.lineDashOffset=s)}setRenderingIntent(n){}setFlatness(n){}setGState(n){for(const[s,p]of n)switch(s){case"LW":this.setLineWidth(p);break;case"LC":this.setLineCap(p);break;case"LJ":this.setLineJoin(p);break;case"ML":this.setMiterLimit(p);break;case"D":this.setDash(p[0],p[1]);break;case"RI":this.setRenderingIntent(p);break;case"FL":this.setFlatness(p);break;case"Font":this.setFont(p[0],p[1]);break;case"CA":this.current.strokeAlpha=p;break;case"ca":this.current.fillAlpha=p,this.ctx.globalAlpha=p;break;case"BM":this.ctx.globalCompositeOperation=p;break;case"SMask":this.current.activeSMask=p?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(p);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const n=this.inSMaskMode;this.current.activeSMask&&!n?this.beginSMaskMode():!this.current.activeSMask&&n&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const n=this.ctx.canvas.width,s=this.ctx.canvas.height,p="smaskGroupAt"+this.groupLevel,M=this.cachedCanvases.getCanvas(p,n,s);this.suspendedCtx=this.ctx,this.ctx=M.context;const O=this.ctx;O.setTransform(...(0,y.getCurrentTransform)(this.suspendedCtx)),r(this.suspendedCtx,O),g(O,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(),r(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(n){if(!this.current.activeSMask)return;n?(n[0]=Math.floor(n[0]),n[1]=Math.floor(n[1]),n[2]=Math.ceil(n[2]),n[3]=Math.ceil(n[3])):n=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const s=this.current.activeSMask,p=this.suspendedCtx;o(p,s,this.ctx,n),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?(r(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const n=this.current;this.stateStack.push(n),this.current=n.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),r(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(n,s,p,M,O,L){this.ctx.transform(n,s,p,M,O,L),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(n,s,p){const M=this.ctx,O=this.current;let L=O.x,V=O.y,At,It;const Bt=(0,y.getCurrentTransform)(M),jt=Bt[0]===0&&Bt[3]===0||Bt[1]===0&&Bt[2]===0,Ut=jt?p.slice(0):null;for(let Xt=0,vt=0,kt=n.length;Xt<kt;Xt++)switch(n[Xt]|0){case i.OPS.rectangle:L=s[vt++],V=s[vt++];const v=s[vt++],N=s[vt++],Z=L+v,St=V+N;M.moveTo(L,V),v===0||N===0?M.lineTo(Z,St):(M.lineTo(Z,V),M.lineTo(Z,St),M.lineTo(L,St)),jt||O.updateRectMinMax(Bt,[L,V,Z,St]),M.closePath();break;case i.OPS.moveTo:L=s[vt++],V=s[vt++],M.moveTo(L,V),jt||O.updatePathMinMax(Bt,L,V);break;case i.OPS.lineTo:L=s[vt++],V=s[vt++],M.lineTo(L,V),jt||O.updatePathMinMax(Bt,L,V);break;case i.OPS.curveTo:At=L,It=V,L=s[vt+4],V=s[vt+5],M.bezierCurveTo(s[vt],s[vt+1],s[vt+2],s[vt+3],L,V),O.updateCurvePathMinMax(Bt,At,It,s[vt],s[vt+1],s[vt+2],s[vt+3],L,V,Ut),vt+=6;break;case i.OPS.curveTo2:At=L,It=V,M.bezierCurveTo(L,V,s[vt],s[vt+1],s[vt+2],s[vt+3]),O.updateCurvePathMinMax(Bt,At,It,L,V,s[vt],s[vt+1],s[vt+2],s[vt+3],Ut),L=s[vt+2],V=s[vt+3],vt+=4;break;case i.OPS.curveTo3:At=L,It=V,L=s[vt+2],V=s[vt+3],M.bezierCurveTo(s[vt],s[vt+1],L,V,L,V),O.updateCurvePathMinMax(Bt,At,It,s[vt],s[vt+1],L,V,L,V,Ut),vt+=4;break;case i.OPS.closePath:M.closePath();break}jt&&O.updateScalingPathMinMax(Bt,Ut),O.setCurrentPoint(L,V)}closePath(){this.ctx.closePath()}stroke(n=!0){const s=this.ctx,p=this.current.strokeColor;s.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof p=="object"&&(p!=null&&p.getPattern)?(s.save(),s.strokeStyle=p.getPattern(s,this,(0,y.getCurrentTransformInverse)(s),Q.PathType.STROKE),this.rescaleAndStroke(!1),s.restore()):this.rescaleAndStroke(!0)),n&&this.consumePath(this.current.getClippedPathBoundingBox()),s.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(n=!0){const s=this.ctx,p=this.current.fillColor,M=this.current.patternFill;let O=!1;M&&(s.save(),s.fillStyle=p.getPattern(s,this,(0,y.getCurrentTransformInverse)(s),Q.PathType.FILL),O=!0);const L=this.current.getClippedPathBoundingBox();this.contentVisible&&L!==null&&(this.pendingEOFill?(s.fill("evenodd"),this.pendingEOFill=!1):s.fill()),O&&s.restore(),n&&this.consumePath(L)}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=U}eoClip(){this.pendingClip=G}beginText(){this.current.textMatrix=i.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const n=this.pendingTextPaths,s=this.ctx;if(n===void 0){s.beginPath();return}s.save(),s.beginPath();for(const p of n)s.setTransform(...p.transform),s.translate(p.x,p.y),p.addToPath(s,p.fontSize);s.restore(),s.clip(),s.beginPath(),delete this.pendingTextPaths}setCharSpacing(n){this.current.charSpacing=n}setWordSpacing(n){this.current.wordSpacing=n}setHScale(n){this.current.textHScale=n/100}setLeading(n){this.current.leading=-n}setFont(n,s){var Bt;const p=this.commonObjs.get(n),M=this.current;if(!p)throw new Error(`Can't find font for ${n}`);if(M.fontMatrix=p.fontMatrix||i.FONT_IDENTITY_MATRIX,(M.fontMatrix[0]===0||M.fontMatrix[3]===0)&&(0,i.warn)("Invalid font matrix for font "+n),s<0?(s=-s,M.fontDirection=-1):M.fontDirection=1,this.current.font=p,this.current.fontSize=s,p.isType3Font)return;const O=p.loadedName||"sans-serif",L=((Bt=p.systemFontInfo)==null?void 0:Bt.css)||`"${O}", ${p.fallbackName}`;let V="normal";p.black?V="900":p.bold&&(V="bold");const At=p.italic?"italic":"normal";let It=s;s<xt?It=xt:s>B&&(It=B),this.current.fontSizeScale=s/It,this.ctx.font=`${At} ${V} ${It}px ${L}`}setTextRenderingMode(n){this.current.textRenderingMode=n}setTextRise(n){this.current.textRise=n}moveText(n,s){this.current.x=this.current.lineX+=n,this.current.y=this.current.lineY+=s}setLeadingMoveText(n,s){this.setLeading(-s),this.moveText(n,s)}setTextMatrix(n,s,p,M,O,L){this.current.textMatrix=[n,s,p,M,O,L],this.current.textMatrixScale=Math.hypot(n,s),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(n,s,p,M){const O=this.ctx,L=this.current,V=L.font,At=L.textRenderingMode,It=L.fontSize/L.fontSizeScale,Bt=At&i.TextRenderingMode.FILL_STROKE_MASK,jt=!!(At&i.TextRenderingMode.ADD_TO_PATH_FLAG),Ut=L.patternFill&&!V.missingFile;let Xt;(V.disableFontFace||jt||Ut)&&(Xt=V.getPathGenerator(this.commonObjs,n)),V.disableFontFace||Ut?(O.save(),O.translate(s,p),O.beginPath(),Xt(O,It),M&&O.setTransform(...M),(Bt===i.TextRenderingMode.FILL||Bt===i.TextRenderingMode.FILL_STROKE)&&O.fill(),(Bt===i.TextRenderingMode.STROKE||Bt===i.TextRenderingMode.FILL_STROKE)&&O.stroke(),O.restore()):((Bt===i.TextRenderingMode.FILL||Bt===i.TextRenderingMode.FILL_STROKE)&&O.fillText(n,s,p),(Bt===i.TextRenderingMode.STROKE||Bt===i.TextRenderingMode.FILL_STROKE)&&O.strokeText(n,s,p)),jt&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,y.getCurrentTransform)(O),x:s,y:p,fontSize:It,addToPath:Xt})}get isFontSubpixelAAEnabled(){const{context:n}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);n.scale(1.5,1),n.fillText("I",0,10);const s=n.getImageData(0,0,10,10).data;let p=!1;for(let M=3;M<s.length;M+=4)if(s[M]>0&&s[M]<255){p=!0;break}return(0,i.shadow)(this,"isFontSubpixelAAEnabled",p)}showText(n){const s=this.current,p=s.font;if(p.isType3Font)return this.showType3Text(n);const M=s.fontSize;if(M===0)return;const O=this.ctx,L=s.fontSizeScale,V=s.charSpacing,At=s.wordSpacing,It=s.fontDirection,Bt=s.textHScale*It,jt=n.length,Ut=p.vertical,Xt=Ut?1:-1,vt=p.defaultVMetrics,kt=M*s.fontMatrix[0],v=s.textRenderingMode===i.TextRenderingMode.FILL&&!p.disableFontFace&&!s.patternFill;O.save(),O.transform(...s.textMatrix),O.translate(s.x,s.y+s.textRise),It>0?O.scale(Bt,-1):O.scale(Bt,1);let N;if(s.patternFill){O.save();const qt=s.fillColor.getPattern(O,this,(0,y.getCurrentTransformInverse)(O),Q.PathType.FILL);N=(0,y.getCurrentTransform)(O),O.restore(),O.fillStyle=qt}let Z=s.lineWidth;const St=s.textMatrixScale;if(St===0||Z===0){const qt=s.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;(qt===i.TextRenderingMode.STROKE||qt===i.TextRenderingMode.FILL_STROKE)&&(Z=this.getSinglePixelWidth())}else Z/=St;if(L!==1&&(O.scale(L,L),Z/=L),O.lineWidth=Z,p.isInvalidPDFjsFont){const qt=[];let bt=0;for(const Jt of n)qt.push(Jt.unicode),bt+=Jt.width;O.fillText(qt.join(""),0,0),s.x+=bt*kt*Bt,O.restore(),this.compose();return}let Nt=0,zt;for(zt=0;zt<jt;++zt){const qt=n[zt];if(typeof qt=="number"){Nt+=Xt*qt*M/1e3;continue}let bt=!1;const Jt=(qt.isSpace?At:0)+V,Kt=qt.fontChar,ce=qt.accent;let oe,me,Qt=qt.width;if(Ut){const pe=qt.vmetric||vt,Ee=-(qt.vmetric?pe[1]:Qt*.5)*kt,Gt=pe[2]*kt;Qt=pe?-pe[0]:Qt,oe=Ee/L,me=(Nt+Gt)/L}else oe=Nt/L,me=0;if(p.remeasure&&Qt>0){const pe=O.measureText(Kt).width*1e3/M*L;if(Qt<pe&&this.isFontSubpixelAAEnabled){const Ee=Qt/pe;bt=!0,O.save(),O.scale(Ee,1),oe/=Ee}else Qt!==pe&&(oe+=(Qt-pe)/2e3*M/L)}if(this.contentVisible&&(qt.isInFont||p.missingFile)){if(v&&!ce)O.fillText(Kt,oe,me);else if(this.paintChar(Kt,oe,me,N),ce){const pe=oe+M*ce.offset.x/L,Ee=me-M*ce.offset.y/L;this.paintChar(ce.fontChar,pe,Ee,N)}}const re=Ut?Qt*kt-Jt*It:Qt*kt+Jt*It;Nt+=re,bt&&O.restore()}Ut?s.y-=Nt:s.x+=Nt*Bt,O.restore(),this.compose()}showType3Text(n){const s=this.ctx,p=this.current,M=p.font,O=p.fontSize,L=p.fontDirection,V=M.vertical?1:-1,At=p.charSpacing,It=p.wordSpacing,Bt=p.textHScale*L,jt=p.fontMatrix||i.FONT_IDENTITY_MATRIX,Ut=n.length,Xt=p.textRenderingMode===i.TextRenderingMode.INVISIBLE;let vt,kt,v,N;if(!(Xt||O===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),s.transform(...p.textMatrix),s.translate(p.x,p.y),s.scale(Bt,L),vt=0;vt<Ut;++vt){if(kt=n[vt],typeof kt=="number"){N=V*kt*O/1e3,this.ctx.translate(N,0),p.x+=N*Bt;continue}const Z=(kt.isSpace?It:0)+At,St=M.charProcOperatorList[kt.operatorListId];if(!St){(0,i.warn)(`Type3 character "${kt.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=kt,this.save(),s.scale(O,O),s.transform(...jt),this.executeOperatorList(St),this.restore()),v=i.Util.applyTransform([kt.width,0],jt)[0]*O+Z,s.translate(v,0),p.x+=v*Bt}s.restore(),this.processingType3=null}}setCharWidth(n,s){}setCharWidthAndBounds(n,s,p,M,O,L){this.ctx.rect(p,M,O-p,L-M),this.ctx.clip(),this.endPath()}getColorN_Pattern(n){let s;if(n[0]==="TilingPattern"){const p=n[1],M=this.baseTransform||(0,y.getCurrentTransform)(this.ctx),O={createCanvasGraphics:L=>new J(L,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};s=new Q.TilingPattern(n,p,this.ctx,O,M)}else s=this._getPattern(n[1],n[2]);return s}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(n,s,p){const M=i.Util.makeHexColor(n,s,p);this.ctx.strokeStyle=M,this.current.strokeColor=M}setFillRGBColor(n,s,p){const M=i.Util.makeHexColor(n,s,p);this.ctx.fillStyle=M,this.current.fillColor=M,this.current.patternFill=!1}_getPattern(n,s=null){let p;return this.cachedPatterns.has(n)?p=this.cachedPatterns.get(n):(p=(0,Q.getShadingPattern)(this.getObject(n)),this.cachedPatterns.set(n,p)),s&&(p.matrix=s),p}shadingFill(n){if(!this.contentVisible)return;const s=this.ctx;this.save();const p=this._getPattern(n);s.fillStyle=p.getPattern(s,this,(0,y.getCurrentTransformInverse)(s),Q.PathType.SHADING);const M=(0,y.getCurrentTransformInverse)(s);if(M){const{width:O,height:L}=s.canvas,[V,At,It,Bt]=i.Util.getAxialAlignedBoundingBox([0,0,O,L],M);this.ctx.fillRect(V,At,It-V,Bt-At)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,i.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,i.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(n,s){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(n)&&n.length===6&&this.transform(...n),this.baseTransform=(0,y.getCurrentTransform)(this.ctx),s)){const p=s[2]-s[0],M=s[3]-s[1];this.ctx.rect(s[0],s[1],p,M),this.current.updateRectMinMax((0,y.getCurrentTransform)(this.ctx),s),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(n){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;n.isolated||(0,i.info)("TODO: Support non-isolated groups."),n.knockout&&(0,i.warn)("Knockout groups not supported.");const p=(0,y.getCurrentTransform)(s);if(n.matrix&&s.transform(...n.matrix),!n.bbox)throw new Error("Bounding box is required.");let M=i.Util.getAxialAlignedBoundingBox(n.bbox,(0,y.getCurrentTransform)(s));const O=[0,0,s.canvas.width,s.canvas.height];M=i.Util.intersect(M,O)||[0,0,0,0];const L=Math.floor(M[0]),V=Math.floor(M[1]);let At=Math.max(Math.ceil(M[2])-L,1),It=Math.max(Math.ceil(M[3])-V,1),Bt=1,jt=1;At>k&&(Bt=At/k,At=k),It>k&&(jt=It/k,It=k),this.current.startNewPathAndClipBox([0,0,At,It]);let Ut="groupAt"+this.groupLevel;n.smask&&(Ut+="_smask_"+this.smaskCounter++%2);const Xt=this.cachedCanvases.getCanvas(Ut,At,It),vt=Xt.context;vt.scale(1/Bt,1/jt),vt.translate(-L,-V),vt.transform(...p),n.smask?this.smaskStack.push({canvas:Xt.canvas,context:vt,offsetX:L,offsetY:V,scaleX:Bt,scaleY:jt,subtype:n.smask.subtype,backdrop:n.smask.backdrop,transferMap:n.smask.transferMap||null,startTransformInverse:null}):(s.setTransform(1,0,0,1,0,0),s.translate(L,V),s.scale(Bt,jt),s.save()),r(s,vt),this.ctx=vt,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(n){if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,p=this.groupStack.pop();if(this.ctx=p,this.ctx.imageSmoothingEnabled=!1,n.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const M=(0,y.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...M);const O=i.Util.getAxialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],M);this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(O)}}beginAnnotation(n,s,p,M,O){if(K(this,_t,Kn).call(this),h(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(s)&&s.length===4){const L=s[2]-s[0],V=s[3]-s[1];if(O&&this.annotationCanvasMap){p=p.slice(),p[4]-=s[0],p[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=L,s[3]=V;const[At,It]=i.Util.singularValueDecompose2dScale((0,y.getCurrentTransform)(this.ctx)),{viewportScale:Bt}=this,jt=Math.ceil(L*this.outputScaleX*Bt),Ut=Math.ceil(V*this.outputScaleY*Bt);this.annotationCanvas=this.canvasFactory.create(jt,Ut);const{canvas:Xt,context:vt}=this.annotationCanvas;this.annotationCanvasMap.set(n,Xt),this.annotationCanvas.savedCtx=this.ctx,this.ctx=vt,this.ctx.save(),this.ctx.setTransform(At,0,0,-It,0,V*It),h(this.ctx)}else h(this.ctx),this.ctx.rect(s[0],s[1],L,V),this.ctx.clip(),this.endPath()}this.current=new C(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...p),this.transform(...M)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),K(this,_t,Jn).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(n){if(!this.contentVisible)return;const s=n.count;n=this.getObject(n.data,n),n.count=s;const p=this.ctx,M=this.processingType3;if(M&&(M.compiled===void 0&&(M.compiled=c(n)),M.compiled)){M.compiled(p);return}const O=this._createMaskCanvas(n),L=O.canvas;p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(L,O.offsetX,O.offsetY),p.restore(),this.compose()}paintImageMaskXObjectRepeat(n,s,p=0,M=0,O,L){if(!this.contentVisible)return;n=this.getObject(n.data,n);const V=this.ctx;V.save();const At=(0,y.getCurrentTransform)(V);V.transform(s,p,M,O,0,0);const It=this._createMaskCanvas(n);V.setTransform(1,0,0,1,It.offsetX-At[4],It.offsetY-At[5]);for(let Bt=0,jt=L.length;Bt<jt;Bt+=2){const Ut=i.Util.transform(At,[s,p,M,O,L[Bt],L[Bt+1]]),[Xt,vt]=i.Util.applyTransform([0,0],Ut);V.drawImage(It.canvas,Xt,vt)}V.restore(),this.compose()}paintImageMaskXObjectGroup(n){if(!this.contentVisible)return;const s=this.ctx,p=this.current.fillColor,M=this.current.patternFill;for(const O of n){const{data:L,width:V,height:At,transform:It}=O,Bt=this.cachedCanvases.getCanvas("maskCanvas",V,At),jt=Bt.context;jt.save();const Ut=this.getObject(L,O);m(jt,Ut),jt.globalCompositeOperation="source-in",jt.fillStyle=M?p.getPattern(jt,this,(0,y.getCurrentTransformInverse)(s),Q.PathType.FILL):p,jt.fillRect(0,0,V,At),jt.restore(),s.save(),s.transform(...It),s.scale(1,-1),_(s,Bt.canvas,0,0,V,At,0,-1,1,1),s.restore()}this.compose()}paintImageXObject(n){if(!this.contentVisible)return;const s=this.getObject(n);if(!s){(0,i.warn)("Dependent image isn't ready yet");return}this.paintInlineImageXObject(s)}paintImageXObjectRepeat(n,s,p,M){if(!this.contentVisible)return;const O=this.getObject(n);if(!O){(0,i.warn)("Dependent image isn't ready yet");return}const L=O.width,V=O.height,At=[];for(let It=0,Bt=M.length;It<Bt;It+=2)At.push({transform:[s,0,0,p,M[It],M[It+1]],x:0,y:0,w:L,h:V});this.paintInlineImageXObjectGroup(O,At)}applyTransferMapsToCanvas(n){return this.current.transferMaps!=="none"&&(n.filter=this.current.transferMaps,n.drawImage(n.canvas,0,0),n.filter="none"),n.canvas}applyTransferMapsToBitmap(n){if(this.current.transferMaps==="none")return n.bitmap;const{bitmap:s,width:p,height:M}=n,O=this.cachedCanvases.getCanvas("inlineImage",p,M),L=O.context;return L.filter=this.current.transferMaps,L.drawImage(s,0,0),L.filter="none",O.canvas}paintInlineImageXObject(n){if(!this.contentVisible)return;const s=n.width,p=n.height,M=this.ctx;if(this.save(),!i.isNodeJS){const{filter:V}=M;V!=="none"&&V!==""&&(M.filter="none")}M.scale(1/s,-1/p);let O;if(n.bitmap)O=this.applyTransferMapsToBitmap(n);else if(typeof HTMLElement=="function"&&n instanceof HTMLElement||!n.data)O=n;else{const At=this.cachedCanvases.getCanvas("inlineImage",s,p).context;I(At,n),O=this.applyTransferMapsToCanvas(At)}const L=this._scaleImage(O,(0,y.getCurrentTransformInverse)(M));M.imageSmoothingEnabled=F((0,y.getCurrentTransform)(M),n.interpolate),_(M,L.img,0,0,L.paintWidth,L.paintHeight,0,-p,s,p),this.compose(),this.restore()}paintInlineImageXObjectGroup(n,s){if(!this.contentVisible)return;const p=this.ctx;let M;if(n.bitmap)M=n.bitmap;else{const O=n.width,L=n.height,At=this.cachedCanvases.getCanvas("inlineImage",O,L).context;I(At,n),M=this.applyTransferMapsToCanvas(At)}for(const O of s)p.save(),p.transform(...O.transform),p.scale(1,-1),_(p,M,O.x,O.y,O.w,O.h,0,-1,1,1),p.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(n){}markPointProps(n,s){}beginMarkedContent(n){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(n,s){n==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(n){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(n);const p=this.ctx;this.pendingClip&&(s||(this.pendingClip===G?p.clip("evenodd"):p.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),p.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const n=(0,y.getCurrentTransform)(this.ctx);if(n[1]===0&&n[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(n[0]),Math.abs(n[3]));else{const s=Math.abs(n[0]*n[3]-n[2]*n[1]),p=Math.hypot(n[0],n[2]),M=Math.hypot(n[1],n[3]);this._cachedGetSinglePixelWidth=Math.max(p,M)/s}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:n}=this.current,{a:s,b:p,c:M,d:O}=this.ctx.getTransform();let L,V;if(p===0&&M===0){const At=Math.abs(s),It=Math.abs(O);if(At===It)if(n===0)L=V=1/At;else{const Bt=At*n;L=V=Bt<1?1/Bt:1}else if(n===0)L=1/At,V=1/It;else{const Bt=At*n,jt=It*n;L=Bt<1?1/Bt:1,V=jt<1?1/jt:1}}else{const At=Math.abs(s*O-p*M),It=Math.hypot(s,p),Bt=Math.hypot(M,O);if(n===0)L=Bt/At,V=It/At;else{const jt=n*At;L=Bt>jt?Bt/jt:1,V=It>jt?It/jt:1}}this._cachedScaleForStroking[0]=L,this._cachedScaleForStroking[1]=V}return this._cachedScaleForStroking}rescaleAndStroke(n){const{ctx:s}=this,{lineWidth:p}=this.current,[M,O]=this.getScaleForStroking();if(s.lineWidth=p||1,M===1&&O===1){s.stroke();return}const L=s.getLineDash();if(n&&s.save(),s.scale(M,O),L.length>0){const V=Math.max(M,O);s.setLineDash(L.map(At=>At/V)),s.lineDashOffset/=V}s.stroke(),n&&s.restore()}isContentVisible(){for(let n=this.markedContentStack.length-1;n>=0;n--)if(!this.markedContentStack[n].visible)return!1;return!0}};_t=new WeakSet,Kn=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)},Jn=function(){if(this.pageColors){const n=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(n!=="none"){const s=this.ctx.filter;this.ctx.filter=n,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=s}}};let H=J;e.CanvasGraphics=H;for(const S in i.OPS)H.prototype[S]!==void 0&&(H.prototype[i.OPS[S]]=H.prototype[S])}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TilingPattern=e.PathType=void 0,e.getShadingPattern=A;var i=b(1),y=b(6);const Q={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};e.PathType=Q;function z(c,C){if(!C)return;const I=C[2]-C[0],m=C[3]-C[1],r=new Path2D;r.rect(C[0],C[1],I,m),c.clip(r)}class xt{constructor(){this.constructor===xt&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class B extends xt{constructor(C){super(),this._type=C[1],this._bbox=C[2],this._colorStops=C[3],this._p0=C[4],this._p1=C[5],this._r0=C[6],this._r1=C[7],this.matrix=null}_createGradient(C){let I;this._type==="axial"?I=C.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(I=C.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const m of this._colorStops)I.addColorStop(m[0],m[1]);return I}getPattern(C,I,m,r){let h;if(r===Q.STROKE||r===Q.FILL){const a=I.current.getClippedPathBoundingBox(r,(0,y.getCurrentTransform)(C))||[0,0,0,0],l=Math.ceil(a[2]-a[0])||1,u=Math.ceil(a[3]-a[1])||1,R=I.cachedCanvases.getCanvas("pattern",l,u,!0),o=R.context;o.clearRect(0,0,o.canvas.width,o.canvas.height),o.beginPath(),o.rect(0,0,o.canvas.width,o.canvas.height),o.translate(-a[0],-a[1]),m=i.Util.transform(m,[1,0,0,1,a[0],a[1]]),o.transform(...I.baseTransform),this.matrix&&o.transform(...this.matrix),z(o,this._bbox),o.fillStyle=this._createGradient(o),o.fill(),h=C.createPattern(R.canvas,"no-repeat");const F=new DOMMatrix(m);h.setTransform(F)}else z(C,this._bbox),h=this._createGradient(C);return h}}function k(c,C,I,m,r,h,a,l){const u=C.coords,R=C.colors,o=c.data,F=c.width*4;let $;u[I+1]>u[m+1]&&($=I,I=m,m=$,$=h,h=a,a=$),u[m+1]>u[r+1]&&($=m,m=r,r=$,$=a,a=l,l=$),u[I+1]>u[m+1]&&($=I,I=m,m=$,$=h,h=a,a=$);const wt=(u[I]+C.offsetX)*C.scaleX,U=(u[I+1]+C.offsetY)*C.scaleY,G=(u[m]+C.offsetX)*C.scaleX,H=(u[m+1]+C.offsetY)*C.scaleY,_t=(u[r]+C.offsetX)*C.scaleX,D=(u[r+1]+C.offsetY)*C.scaleY;if(U>=D)return;const W=R[h],J=R[h+1],S=R[h+2],n=R[a],s=R[a+1],p=R[a+2],M=R[l],O=R[l+1],L=R[l+2],V=Math.round(U),At=Math.round(D);let It,Bt,jt,Ut,Xt,vt,kt,v;for(let N=V;N<=At;N++){if(N<H){const qt=N<U?0:(U-N)/(U-H);It=wt-(wt-G)*qt,Bt=W-(W-n)*qt,jt=J-(J-s)*qt,Ut=S-(S-p)*qt}else{let qt;N>D?qt=1:H===D?qt=0:qt=(H-N)/(H-D),It=G-(G-_t)*qt,Bt=n-(n-M)*qt,jt=s-(s-O)*qt,Ut=p-(p-L)*qt}let Z;N<U?Z=0:N>D?Z=1:Z=(U-N)/(U-D),Xt=wt-(wt-_t)*Z,vt=W-(W-M)*Z,kt=J-(J-O)*Z,v=S-(S-L)*Z;const St=Math.round(Math.min(It,Xt)),Nt=Math.round(Math.max(It,Xt));let zt=F*N+St*4;for(let qt=St;qt<=Nt;qt++)Z=(It-qt)/(It-Xt),Z<0?Z=0:Z>1&&(Z=1),o[zt++]=Bt-(Bt-vt)*Z|0,o[zt++]=jt-(jt-kt)*Z|0,o[zt++]=Ut-(Ut-v)*Z|0,o[zt++]=255}}function f(c,C,I){const m=C.coords,r=C.colors;let h,a;switch(C.type){case"lattice":const l=C.verticesPerRow,u=Math.floor(m.length/l)-1,R=l-1;for(h=0;h<u;h++){let o=h*l;for(let F=0;F<R;F++,o++)k(c,I,m[o],m[o+1],m[o+l],r[o],r[o+1],r[o+l]),k(c,I,m[o+l+1],m[o+1],m[o+l],r[o+l+1],r[o+1],r[o+l])}break;case"triangles":for(h=0,a=m.length;h<a;h+=3)k(c,I,m[h],m[h+1],m[h+2],r[h],r[h+1],r[h+2]);break;default:throw new Error("illegal figure")}}class P extends xt{constructor(C){super(),this._coords=C[2],this._colors=C[3],this._figures=C[4],this._bounds=C[5],this._bbox=C[7],this._background=C[8],this.matrix=null}_createMeshCanvas(C,I,m){const l=Math.floor(this._bounds[0]),u=Math.floor(this._bounds[1]),R=Math.ceil(this._bounds[2])-l,o=Math.ceil(this._bounds[3])-u,F=Math.min(Math.ceil(Math.abs(R*C[0]*1.1)),3e3),$=Math.min(Math.ceil(Math.abs(o*C[1]*1.1)),3e3),wt=R/F,U=o/$,G={coords:this._coords,colors:this._colors,offsetX:-l,offsetY:-u,scaleX:1/wt,scaleY:1/U},H=F+4,_t=$+4,D=m.getCanvas("mesh",H,_t,!1),W=D.context,J=W.createImageData(F,$);if(I){const n=J.data;for(let s=0,p=n.length;s<p;s+=4)n[s]=I[0],n[s+1]=I[1],n[s+2]=I[2],n[s+3]=255}for(const n of this._figures)f(J,n,G);return W.putImageData(J,2,2),{canvas:D.canvas,offsetX:l-2*wt,offsetY:u-2*U,scaleX:wt,scaleY:U}}getPattern(C,I,m,r){z(C,this._bbox);let h;if(r===Q.SHADING)h=i.Util.singularValueDecompose2dScale((0,y.getCurrentTransform)(C));else if(h=i.Util.singularValueDecompose2dScale(I.baseTransform),this.matrix){const l=i.Util.singularValueDecompose2dScale(this.matrix);h=[h[0]*l[0],h[1]*l[1]]}const a=this._createMeshCanvas(h,r===Q.SHADING?null:this._background,I.cachedCanvases);return r!==Q.SHADING&&(C.setTransform(...I.baseTransform),this.matrix&&C.transform(...this.matrix)),C.translate(a.offsetX,a.offsetY),C.scale(a.scaleX,a.scaleY),C.createPattern(a.canvas,"no-repeat")}}class T extends xt{getPattern(){return"hotpink"}}function A(c){switch(c[0]){case"RadialAxial":return new B(c);case"Mesh":return new P(c);case"Dummy":return new T}throw new Error(`Unknown IR type: ${c[0]}`)}const g={COLORED:1,UNCOLORED:2},_=class _{constructor(C,I,m,r,h){this.operatorList=C[2],this.matrix=C[3]||[1,0,0,1,0,0],this.bbox=C[4],this.xstep=C[5],this.ystep=C[6],this.paintType=C[7],this.tilingType=C[8],this.color=I,this.ctx=m,this.canvasGraphicsFactory=r,this.baseTransform=h}createPatternCanvas(C){const I=this.operatorList,m=this.bbox,r=this.xstep,h=this.ystep,a=this.paintType,l=this.tilingType,u=this.color,R=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+l);const o=m[0],F=m[1],$=m[2],wt=m[3],U=i.Util.singularValueDecompose2dScale(this.matrix),G=i.Util.singularValueDecompose2dScale(this.baseTransform),H=[U[0]*G[0],U[1]*G[1]],_t=this.getSizeAndScale(r,this.ctx.canvas.width,H[0]),D=this.getSizeAndScale(h,this.ctx.canvas.height,H[1]),W=C.cachedCanvases.getCanvas("pattern",_t.size,D.size,!0),J=W.context,S=R.createCanvasGraphics(J);S.groupLevel=C.groupLevel,this.setFillAndStrokeStyleToContext(S,a,u);let n=o,s=F,p=$,M=wt;return o<0&&(n=0,p+=Math.abs(o)),F<0&&(s=0,M+=Math.abs(F)),J.translate(-(_t.scale*n),-(D.scale*s)),S.transform(_t.scale,0,0,D.scale,0,0),J.save(),this.clipBbox(S,n,s,p,M),S.baseTransform=(0,y.getCurrentTransform)(S.ctx),S.executeOperatorList(I),S.endDrawing(),{canvas:W.canvas,scaleX:_t.scale,scaleY:D.scale,offsetX:n,offsetY:s}}getSizeAndScale(C,I,m){C=Math.abs(C);const r=Math.max(_.MAX_PATTERN_SIZE,I);let h=Math.ceil(C*m);return h>=r?h=r:m=h/C,{scale:m,size:h}}clipBbox(C,I,m,r,h){const a=r-I,l=h-m;C.ctx.rect(I,m,a,l),C.current.updateRectMinMax((0,y.getCurrentTransform)(C.ctx),[I,m,r,h]),C.clip(),C.endPath()}setFillAndStrokeStyleToContext(C,I,m){const r=C.ctx,h=C.current;switch(I){case g.COLORED:const a=this.ctx;r.fillStyle=a.fillStyle,r.strokeStyle=a.strokeStyle,h.fillColor=a.fillStyle,h.strokeColor=a.strokeStyle;break;case g.UNCOLORED:const l=i.Util.makeHexColor(m[0],m[1],m[2]);r.fillStyle=l,r.strokeStyle=l,h.fillColor=l,h.strokeColor=l;break;default:throw new i.FormatError(`Unsupported paint type: ${I}`)}}getPattern(C,I,m,r){let h=m;r!==Q.SHADING&&(h=i.Util.transform(h,I.baseTransform),this.matrix&&(h=i.Util.transform(h,this.matrix)));const a=this.createPatternCanvas(I);let l=new DOMMatrix(h);l=l.translate(a.offsetX,a.offsetY),l=l.scale(1/a.scaleX,1/a.scaleY);const u=C.createPattern(a.canvas,"repeat");return u.setTransform(l),u}};Fe(_,"MAX_PATTERN_SIZE",3e3);let E=_;e.TilingPattern=E}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.convertBlackAndWhiteToRGBA=Q,e.convertToRGBA=y,e.grayToRGBA=xt;var i=b(1);function y(B){switch(B.kind){case i.ImageKind.GRAYSCALE_1BPP:return Q(B);case i.ImageKind.RGB_24BPP:return z(B)}return null}function Q({src:B,srcPos:k=0,dest:f,width:P,height:T,nonBlackColor:A=4294967295,inverseDecode:g=!1}){const E=i.FeatureTest.isLittleEndian?4278190080:255,[_,c]=g?[A,E]:[E,A],C=P>>3,I=P&7,m=B.length;f=new Uint32Array(f.buffer);let r=0;for(let h=0;h<T;h++){for(const l=k+C;k<l;k++){const u=k<m?B[k]:255;f[r++]=u&128?c:_,f[r++]=u&64?c:_,f[r++]=u&32?c:_,f[r++]=u&16?c:_,f[r++]=u&8?c:_,f[r++]=u&4?c:_,f[r++]=u&2?c:_,f[r++]=u&1?c:_}if(I===0)continue;const a=k<m?B[k++]:255;for(let l=0;l<I;l++)f[r++]=a&1<<7-l?c:_}return{srcPos:k,destPos:r}}function z({src:B,srcPos:k=0,dest:f,destPos:P=0,width:T,height:A}){let g=0;const E=B.length>>2,_=new Uint32Array(B.buffer,k,E);if(i.FeatureTest.isLittleEndian){for(;g<E-2;g+=3,P+=4){const c=_[g],C=_[g+1],I=_[g+2];f[P]=c|4278190080,f[P+1]=c>>>24|C<<8|4278190080,f[P+2]=C>>>16|I<<16|4278190080,f[P+3]=I>>>8|4278190080}for(let c=g*4,C=B.length;c<C;c+=3)f[P++]=B[c]|B[c+1]<<8|B[c+2]<<16|4278190080}else{for(;g<E-2;g+=3,P+=4){const c=_[g],C=_[g+1],I=_[g+2];f[P]=c|255,f[P+1]=c<<24|C>>>8|255,f[P+2]=C<<16|I>>>16|255,f[P+3]=I<<8|255}for(let c=g*4,C=B.length;c<C;c+=3)f[P++]=B[c]<<24|B[c+1]<<16|B[c+2]<<8|255}return{srcPos:k,destPos:P}}function xt(B,k){if(i.FeatureTest.isLittleEndian)for(let f=0,P=B.length;f<P;f++)k[f]=B[f]*65793|4278190080;else for(let f=0,P=B.length;f<P;f++)k[f]=B[f]*16843008|255}}),((d,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalWorkerOptions=void 0;const b=Object.create(null);e.GlobalWorkerOptions=b,b.workerPort=null,b.workerSrc=""}),((d,e,b)=>{var B,xs,ks,Sn;Object.defineProperty(e,"__esModule",{value:!0}),e.MessageHandler=void 0;var i=b(1);const y={DATA:1,ERROR:2},Q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function z(T){switch(T instanceof Error||typeof T=="object"&&T!==null||(0,i.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),T.name){case"AbortException":return new i.AbortException(T.message);case"MissingPDFException":return new i.MissingPDFException(T.message);case"PasswordException":return new i.PasswordException(T.message,T.code);case"UnexpectedResponseException":return new i.UnexpectedResponseException(T.message,T.status);case"UnknownErrorException":return new i.UnknownErrorException(T.message,T.details);default:return new i.UnknownErrorException(T.message,T.toString())}}class xt{constructor(A,g,E){Tt(this,B);this.sourceName=A,this.targetName=g,this.comObj=E,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=_=>{const c=_.data;if(c.targetName!==this.sourceName)return;if(c.stream){K(this,B,ks).call(this,c);return}if(c.callback){const I=c.callbackId,m=this.callbackCapabilities[I];if(!m)throw new Error(`Cannot resolve callback ${I}`);if(delete this.callbackCapabilities[I],c.callback===y.DATA)m.resolve(c.data);else if(c.callback===y.ERROR)m.reject(z(c.reason));else throw new Error("Unexpected callback case");return}const C=this.actionHandler[c.action];if(!C)throw new Error(`Unknown action from worker: ${c.action}`);if(c.callbackId){const I=this.sourceName,m=c.sourceName;new Promise(function(r){r(C(c.data))}).then(function(r){E.postMessage({sourceName:I,targetName:m,callback:y.DATA,callbackId:c.callbackId,data:r})},function(r){E.postMessage({sourceName:I,targetName:m,callback:y.ERROR,callbackId:c.callbackId,reason:z(r)})});return}if(c.streamId){K(this,B,xs).call(this,c);return}C(c.data)},E.addEventListener("message",this._onComObjOnMessage)}on(A,g){const E=this.actionHandler;if(E[A])throw new Error(`There is already an actionName called "${A}"`);E[A]=g}send(A,g,E){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:A,data:g},E)}sendWithPromise(A,g,E){const _=this.callbackId++,c=new i.PromiseCapability;this.callbackCapabilities[_]=c;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:A,callbackId:_,data:g},E)}catch(C){c.reject(C)}return c.promise}sendWithStream(A,g,E,_){const c=this.streamId++,C=this.sourceName,I=this.targetName,m=this.comObj;return new ReadableStream({start:r=>{const h=new i.PromiseCapability;return this.streamControllers[c]={controller:r,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},m.postMessage({sourceName:C,targetName:I,action:A,streamId:c,data:g,desiredSize:r.desiredSize},_),h.promise},pull:r=>{const h=new i.PromiseCapability;return this.streamControllers[c].pullCall=h,m.postMessage({sourceName:C,targetName:I,stream:Q.PULL,streamId:c,desiredSize:r.desiredSize}),h.promise},cancel:r=>{(0,i.assert)(r instanceof Error,"cancel must have a valid reason");const h=new i.PromiseCapability;return this.streamControllers[c].cancelCall=h,this.streamControllers[c].isClosed=!0,m.postMessage({sourceName:C,targetName:I,stream:Q.CANCEL,streamId:c,reason:z(r)}),h.promise}},E)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}B=new WeakSet,xs=function(A){const g=A.streamId,E=this.sourceName,_=A.sourceName,c=this.comObj,C=this,I=this.actionHandler[A.action],m={enqueue(r,h=1,a){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=h,l>0&&this.desiredSize<=0&&(this.sinkCapability=new i.PromiseCapability,this.ready=this.sinkCapability.promise),c.postMessage({sourceName:E,targetName:_,stream:Q.ENQUEUE,streamId:g,chunk:r},a)},close(){this.isCancelled||(this.isCancelled=!0,c.postMessage({sourceName:E,targetName:_,stream:Q.CLOSE,streamId:g}),delete C.streamSinks[g])},error(r){(0,i.assert)(r instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,c.postMessage({sourceName:E,targetName:_,stream:Q.ERROR,streamId:g,reason:z(r)}))},sinkCapability:new i.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:A.desiredSize,ready:null};m.sinkCapability.resolve(),m.ready=m.sinkCapability.promise,this.streamSinks[g]=m,new Promise(function(r){r(I(A.data,m))}).then(function(){c.postMessage({sourceName:E,targetName:_,stream:Q.START_COMPLETE,streamId:g,success:!0})},function(r){c.postMessage({sourceName:E,targetName:_,stream:Q.START_COMPLETE,streamId:g,reason:z(r)})})},ks=function(A){const g=A.streamId,E=this.sourceName,_=A.sourceName,c=this.comObj,C=this.streamControllers[g],I=this.streamSinks[g];switch(A.stream){case Q.START_COMPLETE:A.success?C.startCall.resolve():C.startCall.reject(z(A.reason));break;case Q.PULL_COMPLETE:A.success?C.pullCall.resolve():C.pullCall.reject(z(A.reason));break;case Q.PULL:if(!I){c.postMessage({sourceName:E,targetName:_,stream:Q.PULL_COMPLETE,streamId:g,success:!0});break}I.desiredSize<=0&&A.desiredSize>0&&I.sinkCapability.resolve(),I.desiredSize=A.desiredSize,new Promise(function(m){var r;m((r=I.onPull)==null?void 0:r.call(I))}).then(function(){c.postMessage({sourceName:E,targetName:_,stream:Q.PULL_COMPLETE,streamId:g,success:!0})},function(m){c.postMessage({sourceName:E,targetName:_,stream:Q.PULL_COMPLETE,streamId:g,reason:z(m)})});break;case Q.ENQUEUE:if((0,i.assert)(C,"enqueue should have stream controller"),C.isClosed)break;C.controller.enqueue(A.chunk);break;case Q.CLOSE:if((0,i.assert)(C,"close should have stream controller"),C.isClosed)break;C.isClosed=!0,C.controller.close(),K(this,B,Sn).call(this,C,g);break;case Q.ERROR:(0,i.assert)(C,"error should have stream controller"),C.controller.error(z(A.reason)),K(this,B,Sn).call(this,C,g);break;case Q.CANCEL_COMPLETE:A.success?C.cancelCall.resolve():C.cancelCall.reject(z(A.reason)),K(this,B,Sn).call(this,C,g);break;case Q.CANCEL:if(!I)break;new Promise(function(m){var r;m((r=I.onCancel)==null?void 0:r.call(I,z(A.reason)))}).then(function(){c.postMessage({sourceName:E,targetName:_,stream:Q.CANCEL_COMPLETE,streamId:g,success:!0})},function(m){c.postMessage({sourceName:E,targetName:_,stream:Q.CANCEL_COMPLETE,streamId:g,reason:z(m)})}),I.sinkCapability.reject(z(A.reason)),I.isCancelled=!0,delete this.streamSinks[g];break;default:throw new Error("Unexpected stream case")}},Sn=async function(A,g){var E,_,c;await Promise.allSettled([(E=A.startCall)==null?void 0:E.promise,(_=A.pullCall)==null?void 0:_.promise,(c=A.cancelCall)==null?void 0:c.promise]),delete this.streamControllers[g]},e.MessageHandler=xt}),((d,e,b)=>{var Q,z;Object.defineProperty(e,"__esModule",{value:!0}),e.Metadata=void 0;var i=b(1);class y{constructor({parsedData:B,rawData:k}){Tt(this,Q);Tt(this,z);Rt(this,Q,B),Rt(this,z,k)}getRaw(){return t(this,z)}get(B){return t(this,Q).get(B)??null}getAll(){return(0,i.objectFromMap)(t(this,Q))}has(B){return t(this,Q).has(B)}}Q=new WeakMap,z=new WeakMap,e.Metadata=y}),((d,e,b)=>{var B,k,f,P,T,A,Zn;Object.defineProperty(e,"__esModule",{value:!0}),e.OptionalContentConfig=void 0;var i=b(1),y=b(8);const Q=Symbol("INTERNAL");class z{constructor(_,c){Tt(this,B,!0);this.name=_,this.intent=c}get visible(){return t(this,B)}_setVisible(_,c){_!==Q&&(0,i.unreachable)("Internal method `_setVisible` called."),Rt(this,B,c)}}B=new WeakMap;class xt{constructor(_){Tt(this,A);Tt(this,k,null);Tt(this,f,new Map);Tt(this,P,null);Tt(this,T,null);if(this.name=null,this.creator=null,_!==null){this.name=_.name,this.creator=_.creator,Rt(this,T,_.order);for(const c of _.groups)t(this,f).set(c.id,new z(c.name,c.intent));if(_.baseState==="OFF")for(const c of t(this,f).values())c._setVisible(Q,!1);for(const c of _.on)t(this,f).get(c)._setVisible(Q,!0);for(const c of _.off)t(this,f).get(c)._setVisible(Q,!1);Rt(this,P,this.getHash())}}isVisible(_){if(t(this,f).size===0)return!0;if(!_)return(0,i.warn)("Optional content group not defined."),!0;if(_.type==="OCG")return t(this,f).has(_.id)?t(this,f).get(_.id).visible:((0,i.warn)(`Optional content group not found: ${_.id}`),!0);if(_.type==="OCMD"){if(_.expression)return K(this,A,Zn).call(this,_.expression);if(!_.policy||_.policy==="AnyOn"){for(const c of _.ids){if(!t(this,f).has(c))return(0,i.warn)(`Optional content group not found: ${c}`),!0;if(t(this,f).get(c).visible)return!0}return!1}else if(_.policy==="AllOn"){for(const c of _.ids){if(!t(this,f).has(c))return(0,i.warn)(`Optional content group not found: ${c}`),!0;if(!t(this,f).get(c).visible)return!1}return!0}else if(_.policy==="AnyOff"){for(const c of _.ids){if(!t(this,f).has(c))return(0,i.warn)(`Optional content group not found: ${c}`),!0;if(!t(this,f).get(c).visible)return!0}return!1}else if(_.policy==="AllOff"){for(const c of _.ids){if(!t(this,f).has(c))return(0,i.warn)(`Optional content group not found: ${c}`),!0;if(t(this,f).get(c).visible)return!1}return!0}return(0,i.warn)(`Unknown optional content policy ${_.policy}.`),!0}return(0,i.warn)(`Unknown group type ${_.type}.`),!0}setVisibility(_,c=!0){if(!t(this,f).has(_)){(0,i.warn)(`Optional content group not found: ${_}`);return}t(this,f).get(_)._setVisible(Q,!!c),Rt(this,k,null)}get hasInitialVisibility(){return t(this,P)===null||this.getHash()===t(this,P)}getOrder(){return t(this,f).size?t(this,T)?t(this,T).slice():[...t(this,f).keys()]:null}getGroups(){return t(this,f).size>0?(0,i.objectFromMap)(t(this,f)):null}getGroup(_){return t(this,f).get(_)||null}getHash(){if(t(this,k)!==null)return t(this,k);const _=new y.MurmurHash3_64;for(const[c,C]of t(this,f))_.update(`${c}:${C.visible}`);return Rt(this,k,_.hexdigest())}}k=new WeakMap,f=new WeakMap,P=new WeakMap,T=new WeakMap,A=new WeakSet,Zn=function(_){const c=_.length;if(c<2)return!0;const C=_[0];for(let I=1;I<c;I++){const m=_[I];let r;if(Array.isArray(m))r=K(this,A,Zn).call(this,m);else if(t(this,f).has(m))r=t(this,f).get(m).visible;else return(0,i.warn)(`Optional content group not found: ${m}`),!0;switch(C){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return C==="And"},e.OptionalContentConfig=xt}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFDataTransportStream=void 0;var i=b(1),y=b(6);class Q{constructor({length:k,initialData:f,progressiveDone:P=!1,contentDispositionFilename:T=null,disableRange:A=!1,disableStream:g=!1},E){if((0,i.assert)(E,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=P,this._contentDispositionFilename=T,(f==null?void 0:f.length)>0){const _=f instanceof Uint8Array&&f.byteLength===f.buffer.byteLength?f.buffer:new Uint8Array(f).buffer;this._queuedChunks.push(_)}this._pdfDataRangeTransport=E,this._isStreamingSupported=!g,this._isRangeSupported=!A,this._contentLength=k,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((_,c)=>{this._onReceiveData({begin:_,chunk:c})}),this._pdfDataRangeTransport.addProgressListener((_,c)=>{this._onProgress({loaded:_,total:c})}),this._pdfDataRangeTransport.addProgressiveReadListener(_=>{this._onReceiveData({chunk:_})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:k,chunk:f}){const P=f instanceof Uint8Array&&f.byteLength===f.buffer.byteLength?f.buffer:new Uint8Array(f).buffer;if(k===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(P):this._queuedChunks.push(P);else{const T=this._rangeReaders.some(function(A){return A._begin!==k?!1:(A._enqueue(P),!0)});(0,i.assert)(T,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var k;return((k=this._fullRequestReader)==null?void 0:k._loaded)??0}_onProgress(k){var f,P,T,A;k.total===void 0?(P=(f=this._rangeReaders[0])==null?void 0:f.onProgress)==null||P.call(f,{loaded:k.loaded}):(A=(T=this._fullRequestReader)==null?void 0:T.onProgress)==null||A.call(T,{loaded:k.loaded,total:k.total})}_onProgressiveDone(){var k;(k=this._fullRequestReader)==null||k.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(k){const f=this._rangeReaders.indexOf(k);f>=0&&this._rangeReaders.splice(f,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const k=this._queuedChunks;return this._queuedChunks=null,new z(this,k,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(k,f){if(f<=this._progressiveDataLength)return null;const P=new xt(this,k,f);return this._pdfDataRangeTransport.requestDataRange(k,f),this._rangeReaders.push(P),P}cancelAllRequests(k){var f;(f=this._fullRequestReader)==null||f.cancel(k);for(const P of this._rangeReaders.slice(0))P.cancel(k);this._pdfDataRangeTransport.abort()}}e.PDFDataTransportStream=Q;class z{constructor(k,f,P=!1,T=null){this._stream=k,this._done=P||!1,this._filename=(0,y.isPdfFile)(T)?T:null,this._queuedChunks=f||[],this._loaded=0;for(const A of this._queuedChunks)this._loaded+=A.byteLength;this._requests=[],this._headersReady=Promise.resolve(),k._fullRequestReader=this,this.onProgress=null}_enqueue(k){this._done||(this._requests.length>0?this._requests.shift().resolve({value:k,done:!1}):this._queuedChunks.push(k),this._loaded+=k.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 k=new i.PromiseCapability;return this._requests.push(k),k.promise}cancel(k){this._done=!0;for(const f of this._requests)f.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class xt{constructor(k,f,P){this._stream=k,this._begin=f,this._end=P,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(k){if(!this._done){if(this._requests.length===0)this._queuedChunk=k;else{this._requests.shift().resolve({value:k,done:!1});for(const P of this._requests)P.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 f=this._queuedChunk;return this._queuedChunk=null,{value:f,done:!1}}if(this._done)return{value:void 0,done:!0};const k=new i.PromiseCapability;return this._requests.push(k),k.promise}cancel(k){this._done=!0;for(const f of this._requests)f.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFFetchStream=void 0;var i=b(1),y=b(20);function Q(P,T,A){return{method:"GET",headers:P,signal:A.signal,mode:"cors",credentials:T?"include":"same-origin",redirect:"follow"}}function z(P){const T=new Headers;for(const A in P){const g=P[A];g!==void 0&&T.append(A,g)}return T}function xt(P){return P instanceof Uint8Array?P.buffer:P instanceof ArrayBuffer?P:((0,i.warn)(`getArrayBuffer - unexpected data format: ${P}`),new Uint8Array(P).buffer)}class B{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,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new k(this),this._fullRequestReader}getRangeReader(T,A){if(A<=this._progressiveDataLength)return null;const g=new f(this,T,A);return this._rangeRequestReaders.push(g),g}cancelAllRequests(T){var A;(A=this._fullRequestReader)==null||A.cancel(T);for(const g of this._rangeRequestReaders.slice(0))g.cancel(T)}}e.PDFFetchStream=B;class k{constructor(T){this._stream=T,this._reader=null,this._loaded=0,this._filename=null;const A=T.source;this._withCredentials=A.withCredentials||!1,this._contentLength=A.length,this._headersCapability=new i.PromiseCapability,this._disableRange=A.disableRange||!1,this._rangeChunkSize=A.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!A.disableStream,this._isRangeSupported=!A.disableRange,this._headers=z(this._stream.httpHeaders);const g=A.url;fetch(g,Q(this._headers,this._withCredentials,this._abortController)).then(E=>{if(!(0,y.validateResponseStatus)(E.status))throw(0,y.createResponseStatusError)(E.status,g);this._reader=E.body.getReader(),this._headersCapability.resolve();const _=I=>E.headers.get(I),{allowRangeRequests:c,suggestedLength:C}=(0,y.validateRangeRequestCapabilities)({getResponseHeader:_,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=c,this._contentLength=C||this._contentLength,this._filename=(0,y.extractFilenameFromHeader)(_),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.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(){var g;await this._headersCapability.promise;const{value:T,done:A}=await this._reader.read();return A?{value:T,done:A}:(this._loaded+=T.byteLength,(g=this.onProgress)==null||g.call(this,{loaded:this._loaded,total:this._contentLength}),{value:xt(T),done:!1})}cancel(T){var A;(A=this._reader)==null||A.cancel(T),this._abortController.abort()}}class f{constructor(T,A,g){this._stream=T,this._reader=null,this._loaded=0;const E=T.source;this._withCredentials=E.withCredentials||!1,this._readCapability=new i.PromiseCapability,this._isStreamingSupported=!E.disableStream,this._abortController=new AbortController,this._headers=z(this._stream.httpHeaders),this._headers.append("Range",`bytes=${A}-${g-1}`);const _=E.url;fetch(_,Q(this._headers,this._withCredentials,this._abortController)).then(c=>{if(!(0,y.validateResponseStatus)(c.status))throw(0,y.createResponseStatusError)(c.status,_);this._readCapability.resolve(),this._reader=c.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var g;await this._readCapability.promise;const{value:T,done:A}=await this._reader.read();return A?{value:T,done:A}:(this._loaded+=T.byteLength,(g=this.onProgress)==null||g.call(this,{loaded:this._loaded}),{value:xt(T),done:!1})}cancel(T){var A;(A=this._reader)==null||A.cancel(T),this._abortController.abort()}}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createResponseStatusError=B,e.extractFilenameFromHeader=xt,e.validateRangeRequestCapabilities=z,e.validateResponseStatus=k;var i=b(1),y=b(21),Q=b(6);function z({getResponseHeader:f,isHttp:P,rangeChunkSize:T,disableRange:A}){const g={allowRangeRequests:!1,suggestedLength:void 0},E=parseInt(f("Content-Length"),10);return!Number.isInteger(E)||(g.suggestedLength=E,E<=2*T)||A||!P||f("Accept-Ranges")!=="bytes"||(f("Content-Encoding")||"identity")!=="identity"||(g.allowRangeRequests=!0),g}function xt(f){const P=f("Content-Disposition");if(P){let T=(0,y.getFilenameFromContentDispositionHeader)(P);if(T.includes("%"))try{T=decodeURIComponent(T)}catch{}if((0,Q.isPdfFile)(T))return T}return null}function B(f,P){return f===404||f===0&&P.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+P+'".'):new i.UnexpectedResponseException(`Unexpected server response (${f}) while retrieving PDF "${P}".`,f)}function k(f){return f===200||f===206}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getFilenameFromContentDispositionHeader=y;var i=b(1);function y(Q){let z=!0,xt=B("filename\\*","i").exec(Q);if(xt){xt=xt[1];let E=T(xt);return E=unescape(E),E=A(E),E=g(E),f(E)}if(xt=P(Q),xt){const E=g(xt);return f(E)}if(xt=B("filename","i").exec(Q),xt){xt=xt[1];let E=T(xt);return E=g(E),f(E)}function B(E,_){return new RegExp("(?:^|;)\\s*"+E+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',_)}function k(E,_){if(E){if(!/^[\x00-\xFF]+$/.test(_))return _;try{const c=new TextDecoder(E,{fatal:!0}),C=(0,i.stringToBytes)(_);_=c.decode(C),z=!1}catch{}}return _}function f(E){return z&&/[\x80-\xff]/.test(E)&&(E=k("utf-8",E),z&&(E=k("iso-8859-1",E))),E}function P(E){const _=[];let c;const C=B("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(c=C.exec(E))!==null;){let[,m,r,h]=c;if(m=parseInt(m,10),m in _){if(m===0)break;continue}_[m]=[r,h]}const I=[];for(let m=0;m<_.length&&m in _;++m){let[r,h]=_[m];h=T(h),r&&(h=unescape(h),m===0&&(h=A(h))),I.push(h)}return I.join("")}function T(E){if(E.startsWith('"')){const _=E.slice(1).split('\\"');for(let c=0;c<_.length;++c){const C=_[c].indexOf('"');C!==-1&&(_[c]=_[c].slice(0,C),_.length=c+1),_[c]=_[c].replaceAll(/\\(.)/g,"$1")}E=_.join('"')}return E}function A(E){const _=E.indexOf("'");if(_===-1)return E;const c=E.slice(0,_),I=E.slice(_+1).replace(/^[^']*'/,"");return k(c,I)}function g(E){return!E.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(E)?E:E.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(_,c,C,I){if(C==="q"||C==="Q")return I=I.replaceAll("_"," "),I=I.replaceAll(/=([0-9a-fA-F]{2})/g,function(m,r){return String.fromCharCode(parseInt(r,16))}),k(c,I);try{I=atob(I)}catch{}return k(c,I)})}return""}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFNetworkStream=void 0;var i=b(1),y=b(20);const Q=200,z=206;function xt(T){const A=T.response;return typeof A!="string"?A:(0,i.stringToBytes)(A).buffer}class B{constructor(A,g={}){this.url=A,this.isHttp=/^https?:/i.test(A),this.httpHeaders=this.isHttp&&g.httpHeaders||Object.create(null),this.withCredentials=g.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(A,g,E){const _={begin:A,end:g};for(const c in E)_[c]=E[c];return this.request(_)}requestFull(A){return this.request(A)}request(A){const g=new XMLHttpRequest,E=this.currXhrId++,_=this.pendingRequests[E]={xhr:g};g.open("GET",this.url),g.withCredentials=this.withCredentials;for(const c in this.httpHeaders){const C=this.httpHeaders[c];C!==void 0&&g.setRequestHeader(c,C)}return this.isHttp&&"begin"in A&&"end"in A?(g.setRequestHeader("Range",`bytes=${A.begin}-${A.end-1}`),_.expectedStatus=z):_.expectedStatus=Q,g.responseType="arraybuffer",A.onError&&(g.onerror=function(c){A.onError(g.status)}),g.onreadystatechange=this.onStateChange.bind(this,E),g.onprogress=this.onProgress.bind(this,E),_.onHeadersReceived=A.onHeadersReceived,_.onDone=A.onDone,_.onError=A.onError,_.onProgress=A.onProgress,g.send(null),E}onProgress(A,g){var _;const E=this.pendingRequests[A];E&&((_=E.onProgress)==null||_.call(E,g))}onStateChange(A,g){var m,r,h;const E=this.pendingRequests[A];if(!E)return;const _=E.xhr;if(_.readyState>=2&&E.onHeadersReceived&&(E.onHeadersReceived(),delete E.onHeadersReceived),_.readyState!==4||!(A in this.pendingRequests))return;if(delete this.pendingRequests[A],_.status===0&&this.isHttp){(m=E.onError)==null||m.call(E,_.status);return}const c=_.status||Q;if(!(c===Q&&E.expectedStatus===z)&&c!==E.expectedStatus){(r=E.onError)==null||r.call(E,_.status);return}const I=xt(_);if(c===z){const a=_.getResponseHeader("Content-Range"),l=/bytes (\d+)-(\d+)\/(\d+)/.exec(a);E.onDone({begin:parseInt(l[1],10),chunk:I})}else I?E.onDone({begin:0,chunk:I}):(h=E.onError)==null||h.call(E,_.status)}getRequestXhr(A){return this.pendingRequests[A].xhr}isPendingRequest(A){return A in this.pendingRequests}abortRequest(A){const g=this.pendingRequests[A].xhr;delete this.pendingRequests[A],g.abort()}}class k{constructor(A){this._source=A,this._manager=new B(A.url,{httpHeaders:A.httpHeaders,withCredentials:A.withCredentials}),this._rangeChunkSize=A.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(A){const g=this._rangeRequestReaders.indexOf(A);g>=0&&this._rangeRequestReaders.splice(g,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new f(this._manager,this._source),this._fullRequestReader}getRangeReader(A,g){const E=new P(this._manager,A,g);return E.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(E),E}cancelAllRequests(A){var g;(g=this._fullRequestReader)==null||g.cancel(A);for(const E of this._rangeRequestReaders.slice(0))E.cancel(A)}}e.PDFNetworkStream=k;class f{constructor(A,g){this._manager=A;const E={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=g.url,this._fullRequestId=A.requestFull(E),this._headersReceivedCapability=new i.PromiseCapability,this._disableRange=g.disableRange||!1,this._contentLength=g.length,this._rangeChunkSize=g.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 A=this._fullRequestId,g=this._manager.getRequestXhr(A),E=C=>g.getResponseHeader(C),{allowRangeRequests:_,suggestedLength:c}=(0,y.validateRangeRequestCapabilities)({getResponseHeader:E,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});_&&(this._isRangeSupported=!0),this._contentLength=c||this._contentLength,this._filename=(0,y.extractFilenameFromHeader)(E),this._isRangeSupported&&this._manager.abortRequest(A),this._headersReceivedCapability.resolve()}_onDone(A){if(A&&(this._requests.length>0?this._requests.shift().resolve({value:A.chunk,done:!1}):this._cachedChunks.push(A.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(A){this._storedError=(0,y.createResponseStatusError)(A,this._url),this._headersReceivedCapability.reject(this._storedError);for(const g of this._requests)g.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(A){var g;(g=this.onProgress)==null||g.call(this,{loaded:A.loaded,total:A.lengthComputable?A.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 A=new i.PromiseCapability;return this._requests.push(A),A.promise}cancel(A){this._done=!0,this._headersReceivedCapability.reject(A);for(const g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class P{constructor(A,g,E){this._manager=A;const _={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=A.url,this._requestId=A.requestRange(g,E,_),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var A;(A=this.onClosed)==null||A.call(this,this)}_onDone(A){const g=A.chunk;this._requests.length>0?this._requests.shift().resolve({value:g,done:!1}):this._queuedChunk=g,this._done=!0;for(const E of this._requests)E.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(A){this._storedError=(0,y.createResponseStatusError)(A,this._url);for(const g of this._requests)g.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(A){var g;this.isStreamingSupported||(g=this.onProgress)==null||g.call(this,{loaded:A.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const g=this._queuedChunk;return this._queuedChunk=null,{value:g,done:!1}}if(this._done)return{value:void 0,done:!0};const A=new i.PromiseCapability;return this._requests.push(A),A.promise}cancel(A){this._done=!0;for(const g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PDFNodeStream=void 0;var i=b(1),y=b(20);const Q=/^file:\/\/\/[a-zA-Z]:\//;function z(E){const _=require$$0,c=_.parse(E);return c.protocol==="file:"||c.host?c:/^[a-z]:[/\\]/i.test(E)?_.parse(`file:///${E}`):(c.host||(c.protocol="file:"),c)}class xt{constructor(_){this.source=_,this.url=z(_.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&_.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var _;return((_=this._fullRequestReader)==null?void 0:_._loaded)??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new A(this):new P(this),this._fullRequestReader}getRangeReader(_,c){if(c<=this._progressiveDataLength)return null;const C=this.isFsUrl?new g(this,_,c):new T(this,_,c);return this._rangeRequestReaders.push(C),C}cancelAllRequests(_){var c;(c=this._fullRequestReader)==null||c.cancel(_);for(const C of this._rangeRequestReaders.slice(0))C.cancel(_)}}e.PDFNodeStream=xt;class B{constructor(_){this._url=_.url,this._done=!1,this._storedError=null,this.onProgress=null;const c=_.source;this._contentLength=c.length,this._loaded=0,this._filename=null,this._disableRange=c.disableRange||!1,this._rangeChunkSize=c.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!c.disableStream,this._isRangeSupported=!c.disableRange,this._readableStream=null,this._readCapability=new i.PromiseCapability,this._headersCapability=new i.PromiseCapability}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(){var C;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const _=this._readableStream.read();return _===null?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=_.length,(C=this.onProgress)==null||C.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(_).buffer,done:!1})}cancel(_){if(!this._readableStream){this._error(_);return}this._readableStream.destroy(_)}_error(_){this._storedError=_,this._readCapability.resolve()}_setReadableStream(_){this._readableStream=_,_.on("readable",()=>{this._readCapability.resolve()}),_.on("end",()=>{_.destroy(),this._done=!0,this._readCapability.resolve()}),_.on("error",c=>{this._error(c)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class k{constructor(_){this._url=_.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new i.PromiseCapability;const c=_.source;this._isStreamingSupported=!c.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var C;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const _=this._readableStream.read();return _===null?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=_.length,(C=this.onProgress)==null||C.call(this,{loaded:this._loaded}),{value:new Uint8Array(_).buffer,done:!1})}cancel(_){if(!this._readableStream){this._error(_);return}this._readableStream.destroy(_)}_error(_){this._storedError=_,this._readCapability.resolve()}_setReadableStream(_){this._readableStream=_,_.on("readable",()=>{this._readCapability.resolve()}),_.on("end",()=>{_.destroy(),this._done=!0,this._readCapability.resolve()}),_.on("error",c=>{this._error(c)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function f(E,_){return{protocol:E.protocol,auth:E.auth,host:E.hostname,port:E.port,path:E.path,method:"GET",headers:_}}class P extends B{constructor(_){super(_);const c=C=>{if(C.statusCode===404){const h=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=h,this._headersCapability.reject(h);return}this._headersCapability.resolve(),this._setReadableStream(C);const I=h=>this._readableStream.headers[h.toLowerCase()],{allowRangeRequests:m,suggestedLength:r}=(0,y.validateRangeRequestCapabilities)({getResponseHeader:I,isHttp:_.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=m,this._contentLength=r||this._contentLength,this._filename=(0,y.extractFilenameFromHeader)(I)};if(this._request=null,this._url.protocol==="http:"){const C=require$$0;this._request=C.request(f(this._url,_.httpHeaders),c)}else{const C=require$$0;this._request=C.request(f(this._url,_.httpHeaders),c)}this._request.on("error",C=>{this._storedError=C,this._headersCapability.reject(C)}),this._request.end()}}class T extends k{constructor(_,c,C){super(_),this._httpHeaders={};for(const m in _.httpHeaders){const r=_.httpHeaders[m];r!==void 0&&(this._httpHeaders[m]=r)}this._httpHeaders.Range=`bytes=${c}-${C-1}`;const I=m=>{if(m.statusCode===404){const r=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=r;return}this._setReadableStream(m)};if(this._request=null,this._url.protocol==="http:"){const m=require$$0;this._request=m.request(f(this._url,this._httpHeaders),I)}else{const m=require$$0;this._request=m.request(f(this._url,this._httpHeaders),I)}this._request.on("error",m=>{this._storedError=m}),this._request.end()}}class A extends B{constructor(_){super(_);let c=decodeURIComponent(this._url.path);Q.test(this._url.href)&&(c=c.replace(/^\//,""));const C=require$$0;C.lstat(c,(I,m)=>{if(I){I.code==="ENOENT"&&(I=new i.MissingPDFException(`Missing PDF "${c}".`)),this._storedError=I,this._headersCapability.reject(I);return}this._contentLength=m.size,this._setReadableStream(C.createReadStream(c)),this._headersCapability.resolve()})}}class g extends k{constructor(_,c,C){super(_);let I=decodeURIComponent(this._url.path);Q.test(this._url.href)&&(I=I.replace(/^\//,""));const m=require$$0;this._setReadableStream(m.createReadStream(I,{start:c,end:C-1}))}}}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SVGGraphics=void 0;var i=b(6),y=b(1);const Q={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},z="http://www.w3.org/XML/1998/namespace",xt="http://www.w3.org/1999/xlink",B=["butt","round","square"],k=["miter","round","bevel"],f=function(m,r="",h=!1){if(URL.createObjectURL&&typeof Blob<"u"&&!h)return URL.createObjectURL(new Blob([m],{type:r}));const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let l=`data:${r};base64,`;for(let u=0,R=m.length;u<R;u+=3){const o=m[u]&255,F=m[u+1]&255,$=m[u+2]&255,wt=o>>2,U=(o&3)<<4|F>>4,G=u+1<R?(F&15)<<2|$>>6:64,H=u+2<R?$&63:64;l+=a[wt]+a[U]+a[G]+a[H]}return l},P=(function(){const m=new Uint8Array([137,80,78,71,13,10,26,10]),r=12,h=new Int32Array(256);for(let $=0;$<256;$++){let wt=$;for(let U=0;U<8;U++)wt=wt&1?3988292384^wt>>1&2147483647:wt>>1&2147483647;h[$]=wt}function a($,wt,U){let G=-1;for(let H=wt;H<U;H++){const _t=(G^$[H])&255,D=h[_t];G=G>>>8^D}return G^-1}function l($,wt,U,G){let H=G;const _t=wt.length;U[H]=_t>>24&255,U[H+1]=_t>>16&255,U[H+2]=_t>>8&255,U[H+3]=_t&255,H+=4,U[H]=$.charCodeAt(0)&255,U[H+1]=$.charCodeAt(1)&255,U[H+2]=$.charCodeAt(2)&255,U[H+3]=$.charCodeAt(3)&255,H+=4,U.set(wt,H),H+=wt.length;const D=a(U,G+4,H);U[H]=D>>24&255,U[H+1]=D>>16&255,U[H+2]=D>>8&255,U[H+3]=D&255}function u($,wt,U){let G=1,H=0;for(let _t=wt;_t<U;++_t)G=(G+($[_t]&255))%65521,H=(H+G)%65521;return H<<16|G}function R($){if(!y.isNodeJS)return o($);try{const wt=parseInt(process.versions.node)>=8?$:Buffer.from($),U=require$$0.deflateSync(wt,{level:9});return U instanceof Uint8Array?U:new Uint8Array(U)}catch(wt){(0,y.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+wt)}return o($)}function o($){let wt=$.length;const U=65535,G=Math.ceil(wt/U),H=new Uint8Array(2+wt+G*5+4);let _t=0;H[_t++]=120,H[_t++]=156;let D=0;for(;wt>U;)H[_t++]=0,H[_t++]=255,H[_t++]=255,H[_t++]=0,H[_t++]=0,H.set($.subarray(D,D+U),_t),_t+=U,D+=U,wt-=U;H[_t++]=1,H[_t++]=wt&255,H[_t++]=wt>>8&255,H[_t++]=~wt&65535&255,H[_t++]=(~wt&65535)>>8&255,H.set($.subarray(D),_t),_t+=$.length-D;const W=u($,0,$.length);return H[_t++]=W>>24&255,H[_t++]=W>>16&255,H[_t++]=W>>8&255,H[_t++]=W&255,H}function F($,wt,U,G){const H=$.width,_t=$.height;let D,W,J;const S=$.data;switch(wt){case y.ImageKind.GRAYSCALE_1BPP:W=0,D=1,J=H+7>>3;break;case y.ImageKind.RGB_24BPP:W=2,D=8,J=H*3;break;case y.ImageKind.RGBA_32BPP:W=6,D=8,J=H*4;break;default:throw new Error("invalid format")}const n=new Uint8Array((1+J)*_t);let s=0,p=0;for(let It=0;It<_t;++It)n[s++]=0,n.set(S.subarray(p,p+J),s),p+=J,s+=J;if(wt===y.ImageKind.GRAYSCALE_1BPP&&G){s=0;for(let It=0;It<_t;It++){s++;for(let Bt=0;Bt<J;Bt++)n[s++]^=255}}const M=new Uint8Array([H>>24&255,H>>16&255,H>>8&255,H&255,_t>>24&255,_t>>16&255,_t>>8&255,_t&255,D,W,0,0,0]),O=R(n),L=m.length+r*3+M.length+O.length,V=new Uint8Array(L);let At=0;return V.set(m,At),At+=m.length,l("IHDR",M,V,At),At+=r+M.length,l("IDATA",O,V,At),At+=r+O.length,l("IEND",new Uint8Array(0),V,At),f(V,"image/png",U)}return function(wt,U,G){const H=wt.kind===void 0?y.ImageKind.GRAYSCALE_1BPP:wt.kind;return F(wt,H,U,G)}})();class T{constructor(){this.fontSizeScale=1,this.fontWeight=Q.fontWeight,this.fontSize=0,this.textMatrix=y.IDENTITY_MATRIX,this.fontMatrix=y.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=y.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=Q.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(r,h){this.x=r,this.y=h}}function A(m){let r=[];const h=[];for(const a of m){if(a.fn==="save"){r.push({fnId:92,fn:"group",items:[]}),h.push(r),r=r.at(-1).items;continue}a.fn==="restore"?r=h.pop():r.push(a)}return r}function g(m){if(Number.isInteger(m))return m.toString();const r=m.toFixed(10);let h=r.length-1;if(r[h]!=="0")return r;do h--;while(r[h]==="0");return r.substring(0,r[h]==="."?h:h+1)}function E(m){if(m[4]===0&&m[5]===0){if(m[1]===0&&m[2]===0)return m[0]===1&&m[3]===1?"":`scale(${g(m[0])} ${g(m[3])})`;if(m[0]===m[3]&&m[1]===-m[2]){const r=Math.acos(m[0])*180/Math.PI;return`rotate(${g(r)})`}}else if(m[0]===1&&m[1]===0&&m[2]===0&&m[3]===1)return`translate(${g(m[4])} ${g(m[5])})`;return`matrix(${g(m[0])} ${g(m[1])} ${g(m[2])} ${g(m[3])} ${g(m[4])} ${g(m[5])})`}let _=0,c=0,C=0;class I{constructor(r,h,a=!1){(0,i.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new i.DOMSVGFactory,this.current=new T,this.transformMatrix=y.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=r,this.objs=h,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!a,this._operatorIdMapping=[];for(const l in y.OPS)this._operatorIdMapping[y.OPS[l]]=l}getObject(r,h=null){return typeof r=="string"?r.startsWith("g_")?this.commonObjs.get(r):this.objs.get(r):h}save(){this.transformStack.push(this.transformMatrix);const r=this.current;this.extraStack.push(r),this.current=r.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(r){this.save(),this.executeOpTree(r),this.restore()}loadDependencies(r){const h=r.fnArray,a=r.argsArray;for(let l=0,u=h.length;l<u;l++)if(h[l]===y.OPS.dependency)for(const R of a[l]){const o=R.startsWith("g_")?this.commonObjs:this.objs,F=new Promise($=>{o.get(R,$)});this.current.dependencies.push(F)}return Promise.all(this.current.dependencies)}transform(r,h,a,l,u,R){const o=[r,h,a,l,u,R];this.transformMatrix=y.Util.transform(this.transformMatrix,o),this.tgrp=null}getSVG(r,h){this.viewport=h;const a=this._initialize(h);return this.loadDependencies(r).then(()=>(this.transformMatrix=y.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(r)),a))}convertOpList(r){const h=this._operatorIdMapping,a=r.argsArray,l=r.fnArray,u=[];for(let R=0,o=l.length;R<o;R++){const F=l[R];u.push({fnId:F,fn:h[F],args:a[R]})}return A(u)}executeOpTree(r){for(const h of r){const a=h.fn,l=h.fnId,u=h.args;switch(l|0){case y.OPS.beginText:this.beginText();break;case y.OPS.dependency:break;case y.OPS.setLeading:this.setLeading(u);break;case y.OPS.setLeadingMoveText:this.setLeadingMoveText(u[0],u[1]);break;case y.OPS.setFont:this.setFont(u);break;case y.OPS.showText:this.showText(u[0]);break;case y.OPS.showSpacedText:this.showText(u[0]);break;case y.OPS.endText:this.endText();break;case y.OPS.moveText:this.moveText(u[0],u[1]);break;case y.OPS.setCharSpacing:this.setCharSpacing(u[0]);break;case y.OPS.setWordSpacing:this.setWordSpacing(u[0]);break;case y.OPS.setHScale:this.setHScale(u[0]);break;case y.OPS.setTextMatrix:this.setTextMatrix(u[0],u[1],u[2],u[3],u[4],u[5]);break;case y.OPS.setTextRise:this.setTextRise(u[0]);break;case y.OPS.setTextRenderingMode:this.setTextRenderingMode(u[0]);break;case y.OPS.setLineWidth:this.setLineWidth(u[0]);break;case y.OPS.setLineJoin:this.setLineJoin(u[0]);break;case y.OPS.setLineCap:this.setLineCap(u[0]);break;case y.OPS.setMiterLimit:this.setMiterLimit(u[0]);break;case y.OPS.setFillRGBColor:this.setFillRGBColor(u[0],u[1],u[2]);break;case y.OPS.setStrokeRGBColor:this.setStrokeRGBColor(u[0],u[1],u[2]);break;case y.OPS.setStrokeColorN:this.setStrokeColorN(u);break;case y.OPS.setFillColorN:this.setFillColorN(u);break;case y.OPS.shadingFill:this.shadingFill(u[0]);break;case y.OPS.setDash:this.setDash(u[0],u[1]);break;case y.OPS.setRenderingIntent:this.setRenderingIntent(u[0]);break;case y.OPS.setFlatness:this.setFlatness(u[0]);break;case y.OPS.setGState:this.setGState(u[0]);break;case y.OPS.fill:this.fill();break;case y.OPS.eoFill:this.eoFill();break;case y.OPS.stroke:this.stroke();break;case y.OPS.fillStroke:this.fillStroke();break;case y.OPS.eoFillStroke:this.eoFillStroke();break;case y.OPS.clip:this.clip("nonzero");break;case y.OPS.eoClip:this.clip("evenodd");break;case y.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case y.OPS.paintImageXObject:this.paintImageXObject(u[0]);break;case y.OPS.paintInlineImageXObject:this.paintInlineImageXObject(u[0]);break;case y.OPS.paintImageMaskXObject:this.paintImageMaskXObject(u[0]);break;case y.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(u[0],u[1]);break;case y.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case y.OPS.closePath:this.closePath();break;case y.OPS.closeStroke:this.closeStroke();break;case y.OPS.closeFillStroke:this.closeFillStroke();break;case y.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case y.OPS.nextLine:this.nextLine();break;case y.OPS.transform:this.transform(u[0],u[1],u[2],u[3],u[4],u[5]);break;case y.OPS.constructPath:this.constructPath(u[0],u[1]);break;case y.OPS.endPath:this.endPath();break;case 92:this.group(h.items);break;default:(0,y.warn)(`Unimplemented operator ${a}`);break}}}setWordSpacing(r){this.current.wordSpacing=r}setCharSpacing(r){this.current.charSpacing=r}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(r,h,a,l,u,R){const o=this.current;o.textMatrix=o.lineMatrix=[r,h,a,l,u,R],o.textMatrixScale=Math.hypot(r,h),o.x=o.lineX=0,o.y=o.lineY=0,o.xcoords=[],o.ycoords=[],o.tspan=this.svgFactory.createElement("svg:tspan"),o.tspan.setAttributeNS(null,"font-family",o.fontFamily),o.tspan.setAttributeNS(null,"font-size",`${g(o.fontSize)}px`),o.tspan.setAttributeNS(null,"y",g(-o.y)),o.txtElement=this.svgFactory.createElement("svg:text"),o.txtElement.append(o.tspan)}beginText(){const r=this.current;r.x=r.lineX=0,r.y=r.lineY=0,r.textMatrix=y.IDENTITY_MATRIX,r.lineMatrix=y.IDENTITY_MATRIX,r.textMatrixScale=1,r.tspan=this.svgFactory.createElement("svg:tspan"),r.txtElement=this.svgFactory.createElement("svg:text"),r.txtgrp=this.svgFactory.createElement("svg:g"),r.xcoords=[],r.ycoords=[]}moveText(r,h){const a=this.current;a.x=a.lineX+=r,a.y=a.lineY+=h,a.xcoords=[],a.ycoords=[],a.tspan=this.svgFactory.createElement("svg:tspan"),a.tspan.setAttributeNS(null,"font-family",a.fontFamily),a.tspan.setAttributeNS(null,"font-size",`${g(a.fontSize)}px`),a.tspan.setAttributeNS(null,"y",g(-a.y))}showText(r){const h=this.current,a=h.font,l=h.fontSize;if(l===0)return;const u=h.fontSizeScale,R=h.charSpacing,o=h.wordSpacing,F=h.fontDirection,$=h.textHScale*F,wt=a.vertical,U=wt?1:-1,G=a.defaultVMetrics,H=l*h.fontMatrix[0];let _t=0;for(const J of r){if(J===null){_t+=F*o;continue}else if(typeof J=="number"){_t+=U*J*l/1e3;continue}const S=(J.isSpace?o:0)+R,n=J.fontChar;let s,p,M=J.width;if(wt){let L;const V=J.vmetric||G;L=J.vmetric?V[1]:M*.5,L=-L*H;const At=V[2]*H;M=V?-V[0]:M,s=L/u,p=(_t+At)/u}else s=_t/u,p=0;(J.isInFont||a.missingFile)&&(h.xcoords.push(h.x+s),wt&&h.ycoords.push(-h.y+p),h.tspan.textContent+=n);const O=wt?M*H-S*F:M*H+S*F;_t+=O}h.tspan.setAttributeNS(null,"x",h.xcoords.map(g).join(" ")),wt?h.tspan.setAttributeNS(null,"y",h.ycoords.map(g).join(" ")):h.tspan.setAttributeNS(null,"y",g(-h.y)),wt?h.y-=_t:h.x+=_t*$,h.tspan.setAttributeNS(null,"font-family",h.fontFamily),h.tspan.setAttributeNS(null,"font-size",`${g(h.fontSize)}px`),h.fontStyle!==Q.fontStyle&&h.tspan.setAttributeNS(null,"font-style",h.fontStyle),h.fontWeight!==Q.fontWeight&&h.tspan.setAttributeNS(null,"font-weight",h.fontWeight);const D=h.textRenderingMode&y.TextRenderingMode.FILL_STROKE_MASK;if(D===y.TextRenderingMode.FILL||D===y.TextRenderingMode.FILL_STROKE?(h.fillColor!==Q.fillColor&&h.tspan.setAttributeNS(null,"fill",h.fillColor),h.fillAlpha<1&&h.tspan.setAttributeNS(null,"fill-opacity",h.fillAlpha)):h.textRenderingMode===y.TextRenderingMode.ADD_TO_PATH?h.tspan.setAttributeNS(null,"fill","transparent"):h.tspan.setAttributeNS(null,"fill","none"),D===y.TextRenderingMode.STROKE||D===y.TextRenderingMode.FILL_STROKE){const J=1/(h.textMatrixScale||1);this._setStrokeAttributes(h.tspan,J)}let W=h.textMatrix;h.textRise!==0&&(W=W.slice(),W[5]+=h.textRise),h.txtElement.setAttributeNS(null,"transform",`${E(W)} scale(${g($)}, -1)`),h.txtElement.setAttributeNS(z,"xml:space","preserve"),h.txtElement.append(h.tspan),h.txtgrp.append(h.txtElement),this._ensureTransformGroup().append(h.txtElement)}setLeadingMoveText(r,h){this.setLeading(-h),this.moveText(r,h)}addFontStyle(r){if(!r.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 h=f(r.data,r.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${r.loadedName}"; src: url(${h}); }
39
+ `}setFont(r){const h=this.current,a=this.commonObjs.get(r[0]);let l=r[1];h.font=a,this.embedFonts&&!a.missingFile&&!this.embeddedFonts[a.loadedName]&&(this.addFontStyle(a),this.embeddedFonts[a.loadedName]=a),h.fontMatrix=a.fontMatrix||y.FONT_IDENTITY_MATRIX;let u="normal";a.black?u="900":a.bold&&(u="bold");const R=a.italic?"italic":"normal";l<0?(l=-l,h.fontDirection=-1):h.fontDirection=1,h.fontSize=l,h.fontFamily=a.loadedName,h.fontWeight=u,h.fontStyle=R,h.tspan=this.svgFactory.createElement("svg:tspan"),h.tspan.setAttributeNS(null,"y",g(-h.y)),h.xcoords=[],h.ycoords=[]}endText(){var h;const r=this.current;r.textRenderingMode&y.TextRenderingMode.ADD_TO_PATH_FLAG&&((h=r.txtElement)!=null&&h.hasChildNodes())&&(r.element=r.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(r){r>0&&(this.current.lineWidth=r)}setLineCap(r){this.current.lineCap=B[r]}setLineJoin(r){this.current.lineJoin=k[r]}setMiterLimit(r){this.current.miterLimit=r}setStrokeAlpha(r){this.current.strokeAlpha=r}setStrokeRGBColor(r,h,a){this.current.strokeColor=y.Util.makeHexColor(r,h,a)}setFillAlpha(r){this.current.fillAlpha=r}setFillRGBColor(r,h,a){this.current.fillColor=y.Util.makeHexColor(r,h,a),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(r){this.current.strokeColor=this._makeColorN_Pattern(r)}setFillColorN(r){this.current.fillColor=this._makeColorN_Pattern(r)}shadingFill(r){const{width:h,height:a}=this.viewport,l=y.Util.inverseTransform(this.transformMatrix),[u,R,o,F]=y.Util.getAxialAlignedBoundingBox([0,0,h,a],l),$=this.svgFactory.createElement("svg:rect");$.setAttributeNS(null,"x",u),$.setAttributeNS(null,"y",R),$.setAttributeNS(null,"width",o-u),$.setAttributeNS(null,"height",F-R),$.setAttributeNS(null,"fill",this._makeShadingPattern(r)),this.current.fillAlpha<1&&$.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append($)}_makeColorN_Pattern(r){return r[0]==="TilingPattern"?this._makeTilingPattern(r):this._makeShadingPattern(r)}_makeTilingPattern(r){const h=r[1],a=r[2],l=r[3]||y.IDENTITY_MATRIX,[u,R,o,F]=r[4],$=r[5],wt=r[6],U=r[7],G=`shading${C++}`,[H,_t,D,W]=y.Util.normalizeRect([...y.Util.applyTransform([u,R],l),...y.Util.applyTransform([o,F],l)]),[J,S]=y.Util.singularValueDecompose2dScale(l),n=$*J,s=wt*S,p=this.svgFactory.createElement("svg:pattern");p.setAttributeNS(null,"id",G),p.setAttributeNS(null,"patternUnits","userSpaceOnUse"),p.setAttributeNS(null,"width",n),p.setAttributeNS(null,"height",s),p.setAttributeNS(null,"x",`${H}`),p.setAttributeNS(null,"y",`${_t}`);const M=this.svg,O=this.transformMatrix,L=this.current.fillColor,V=this.current.strokeColor,At=this.svgFactory.create(D-H,W-_t);if(this.svg=At,this.transformMatrix=l,U===2){const It=y.Util.makeHexColor(...h);this.current.fillColor=It,this.current.strokeColor=It}return this.executeOpTree(this.convertOpList(a)),this.svg=M,this.transformMatrix=O,this.current.fillColor=L,this.current.strokeColor=V,p.append(At.childNodes[0]),this.defs.append(p),`url(#${G})`}_makeShadingPattern(r){switch(typeof r=="string"&&(r=this.objs.get(r)),r[0]){case"RadialAxial":const h=`shading${C++}`,a=r[3];let l;switch(r[1]){case"axial":const u=r[4],R=r[5];l=this.svgFactory.createElement("svg:linearGradient"),l.setAttributeNS(null,"id",h),l.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),l.setAttributeNS(null,"x1",u[0]),l.setAttributeNS(null,"y1",u[1]),l.setAttributeNS(null,"x2",R[0]),l.setAttributeNS(null,"y2",R[1]);break;case"radial":const o=r[4],F=r[5],$=r[6],wt=r[7];l=this.svgFactory.createElement("svg:radialGradient"),l.setAttributeNS(null,"id",h),l.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),l.setAttributeNS(null,"cx",F[0]),l.setAttributeNS(null,"cy",F[1]),l.setAttributeNS(null,"r",wt),l.setAttributeNS(null,"fx",o[0]),l.setAttributeNS(null,"fy",o[1]),l.setAttributeNS(null,"fr",$);break;default:throw new Error(`Unknown RadialAxial type: ${r[1]}`)}for(const u of a){const R=this.svgFactory.createElement("svg:stop");R.setAttributeNS(null,"offset",u[0]),R.setAttributeNS(null,"stop-color",u[1]),l.append(R)}return this.defs.append(l),`url(#${h})`;case"Mesh":return(0,y.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${r[0]}`)}}setDash(r,h){this.current.dashArray=r,this.current.dashPhase=h}constructPath(r,h){const a=this.current;let l=a.x,u=a.y,R=[],o=0;for(const F of r)switch(F|0){case y.OPS.rectangle:l=h[o++],u=h[o++];const $=h[o++],wt=h[o++],U=l+$,G=u+wt;R.push("M",g(l),g(u),"L",g(U),g(u),"L",g(U),g(G),"L",g(l),g(G),"Z");break;case y.OPS.moveTo:l=h[o++],u=h[o++],R.push("M",g(l),g(u));break;case y.OPS.lineTo:l=h[o++],u=h[o++],R.push("L",g(l),g(u));break;case y.OPS.curveTo:l=h[o+4],u=h[o+5],R.push("C",g(h[o]),g(h[o+1]),g(h[o+2]),g(h[o+3]),g(l),g(u)),o+=6;break;case y.OPS.curveTo2:R.push("C",g(l),g(u),g(h[o]),g(h[o+1]),g(h[o+2]),g(h[o+3])),l=h[o+2],u=h[o+3],o+=4;break;case y.OPS.curveTo3:l=h[o+2],u=h[o+3],R.push("C",g(h[o]),g(h[o+1]),g(l),g(u),g(l),g(u)),o+=4;break;case y.OPS.closePath:R.push("Z");break}R=R.join(" "),a.path&&r.length>0&&r[0]!==y.OPS.rectangle&&r[0]!==y.OPS.moveTo?R=a.path.getAttributeNS(null,"d")+R:(a.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(a.path)),a.path.setAttributeNS(null,"d",R),a.path.setAttributeNS(null,"fill","none"),a.element=a.path,a.setCurrentPoint(l,u)}endPath(){const r=this.current;if(r.path=null,!this.pendingClip)return;if(!r.element){this.pendingClip=null;return}const h=`clippath${_++}`,a=this.svgFactory.createElement("svg:clipPath");a.setAttributeNS(null,"id",h),a.setAttributeNS(null,"transform",E(this.transformMatrix));const l=r.element.cloneNode(!0);if(this.pendingClip==="evenodd"?l.setAttributeNS(null,"clip-rule","evenodd"):l.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,a.append(l),this.defs.append(a),r.activeClipUrl){r.clipGroup=null;for(const u of this.extraStack)u.clipGroup=null;a.setAttributeNS(null,"clip-path",r.activeClipUrl)}r.activeClipUrl=`url(#${h})`,this.tgrp=null}clip(r){this.pendingClip=r}closePath(){const r=this.current;if(r.path){const h=`${r.path.getAttributeNS(null,"d")}Z`;r.path.setAttributeNS(null,"d",h)}}setLeading(r){this.current.leading=-r}setTextRise(r){this.current.textRise=r}setTextRenderingMode(r){this.current.textRenderingMode=r}setHScale(r){this.current.textHScale=r/100}setRenderingIntent(r){}setFlatness(r){}setGState(r){for(const[h,a]of r)switch(h){case"LW":this.setLineWidth(a);break;case"LC":this.setLineCap(a);break;case"LJ":this.setLineJoin(a);break;case"ML":this.setMiterLimit(a);break;case"D":this.setDash(a[0],a[1]);break;case"RI":this.setRenderingIntent(a);break;case"FL":this.setFlatness(a);break;case"Font":this.setFont(a);break;case"CA":this.setStrokeAlpha(a);break;case"ca":this.setFillAlpha(a);break;default:(0,y.warn)(`Unimplemented graphic state operator ${h}`);break}}fill(){const r=this.current;r.element&&(r.element.setAttributeNS(null,"fill",r.fillColor),r.element.setAttributeNS(null,"fill-opacity",r.fillAlpha),this.endPath())}stroke(){const r=this.current;r.element&&(this._setStrokeAttributes(r.element),r.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(r,h=1){const a=this.current;let l=a.dashArray;h!==1&&l.length>0&&(l=l.map(function(u){return h*u})),r.setAttributeNS(null,"stroke",a.strokeColor),r.setAttributeNS(null,"stroke-opacity",a.strokeAlpha),r.setAttributeNS(null,"stroke-miterlimit",g(a.miterLimit)),r.setAttributeNS(null,"stroke-linecap",a.lineCap),r.setAttributeNS(null,"stroke-linejoin",a.lineJoin),r.setAttributeNS(null,"stroke-width",g(h*a.lineWidth)+"px"),r.setAttributeNS(null,"stroke-dasharray",l.map(g).join(" ")),r.setAttributeNS(null,"stroke-dashoffset",g(h*a.dashPhase)+"px")}eoFill(){var r;(r=this.current.element)==null||r.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){var r;(r=this.current.element)==null||r.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const r=this.svgFactory.createElement("svg:rect");r.setAttributeNS(null,"x","0"),r.setAttributeNS(null,"y","0"),r.setAttributeNS(null,"width","1px"),r.setAttributeNS(null,"height","1px"),r.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(r)}paintImageXObject(r){const h=this.getObject(r);if(!h){(0,y.warn)(`Dependent image with object ID ${r} is not ready yet`);return}this.paintInlineImageXObject(h)}paintInlineImageXObject(r,h){const a=r.width,l=r.height,u=P(r,this.forceDataSchema,!!h),R=this.svgFactory.createElement("svg:rect");R.setAttributeNS(null,"x","0"),R.setAttributeNS(null,"y","0"),R.setAttributeNS(null,"width",g(a)),R.setAttributeNS(null,"height",g(l)),this.current.element=R,this.clip("nonzero");const o=this.svgFactory.createElement("svg:image");o.setAttributeNS(xt,"xlink:href",u),o.setAttributeNS(null,"x","0"),o.setAttributeNS(null,"y",g(-l)),o.setAttributeNS(null,"width",g(a)+"px"),o.setAttributeNS(null,"height",g(l)+"px"),o.setAttributeNS(null,"transform",`scale(${g(1/a)} ${g(-1/l)})`),h?h.append(o):this._ensureTransformGroup().append(o)}paintImageMaskXObject(r){const h=this.getObject(r.data,r);if(h.bitmap){(0,y.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");return}const a=this.current,l=h.width,u=h.height,R=a.fillColor;a.maskId=`mask${c++}`;const o=this.svgFactory.createElement("svg:mask");o.setAttributeNS(null,"id",a.maskId);const F=this.svgFactory.createElement("svg:rect");F.setAttributeNS(null,"x","0"),F.setAttributeNS(null,"y","0"),F.setAttributeNS(null,"width",g(l)),F.setAttributeNS(null,"height",g(u)),F.setAttributeNS(null,"fill",R),F.setAttributeNS(null,"mask",`url(#${a.maskId})`),this.defs.append(o),this._ensureTransformGroup().append(F),this.paintInlineImageXObject(h,o)}paintFormXObjectBegin(r,h){if(Array.isArray(r)&&r.length===6&&this.transform(r[0],r[1],r[2],r[3],r[4],r[5]),h){const a=h[2]-h[0],l=h[3]-h[1],u=this.svgFactory.createElement("svg:rect");u.setAttributeNS(null,"x",h[0]),u.setAttributeNS(null,"y",h[1]),u.setAttributeNS(null,"width",g(a)),u.setAttributeNS(null,"height",g(l)),this.current.element=u,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(r){const h=this.svgFactory.create(r.width,r.height),a=this.svgFactory.createElement("svg:defs");h.append(a),this.defs=a;const l=this.svgFactory.createElement("svg:g");return l.setAttributeNS(null,"transform",E(r.transform)),h.append(l),this.svg=l,h}_ensureClipGroup(){if(!this.current.clipGroup){const r=this.svgFactory.createElement("svg:g");r.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(r),this.current.clipGroup=r}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",E(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}e.SVGGraphics=I}),((d,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.XfaText=void 0;class b{static textContent(y){const Q=[],z={items:Q,styles:Object.create(null)};function xt(B){var P;if(!B)return;let k=null;const f=B.name;if(f==="#text")k=B.value;else if(b.shouldBuildText(f))(P=B==null?void 0:B.attributes)!=null&&P.textContent?k=B.attributes.textContent:B.value&&(k=B.value);else return;if(k!==null&&Q.push({str:k}),!!B.children)for(const T of B.children)xt(T)}return xt(y),z}static shouldBuildText(y){return!(y==="textarea"||y==="input"||y==="option"||y==="select")}}e.XfaText=b}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TextLayerRenderTask=void 0,e.renderTextLayer=E,e.updateTextLayer=_;var i=b(1),y=b(6);const Q=1e5,z=30,xt=.8,B=new Map;function k(c,C){let I;if(C&&i.FeatureTest.isOffscreenCanvasSupported)I=new OffscreenCanvas(c,c).getContext("2d",{alpha:!1});else{const m=document.createElement("canvas");m.width=m.height=c,I=m.getContext("2d",{alpha:!1})}return I}function f(c,C){const I=B.get(c);if(I)return I;const m=k(z,C);m.font=`${z}px ${c}`;const r=m.measureText("");let h=r.fontBoundingBoxAscent,a=Math.abs(r.fontBoundingBoxDescent);if(h){const u=h/(h+a);return B.set(c,u),m.canvas.width=m.canvas.height=0,u}m.strokeStyle="red",m.clearRect(0,0,z,z),m.strokeText("g",0,0);let l=m.getImageData(0,0,z,z).data;a=0;for(let u=l.length-1-3;u>=0;u-=4)if(l[u]>0){a=Math.ceil(u/4/z);break}m.clearRect(0,0,z,z),m.strokeText("A",0,z),l=m.getImageData(0,0,z,z).data,h=0;for(let u=0,R=l.length;u<R;u+=4)if(l[u]>0){h=z-Math.floor(u/4/z);break}if(m.canvas.width=m.canvas.height=0,h){const u=h/(h+a);return B.set(c,u),u}return B.set(c,xt),xt}function P(c,C,I){const m=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:C.str!=="",hasEOL:C.hasEOL,fontSize:0};c._textDivs.push(m);const h=i.Util.transform(c._transform,C.transform);let a=Math.atan2(h[1],h[0]);const l=I[C.fontName];l.vertical&&(a+=Math.PI/2);const u=Math.hypot(h[2],h[3]),R=u*f(l.fontFamily,c._isOffscreenCanvasSupported);let o,F;a===0?(o=h[4],F=h[5]-R):(o=h[4]+R*Math.sin(a),F=h[5]-R*Math.cos(a));const $="calc(var(--scale-factor)*",wt=m.style;c._container===c._rootContainer?(wt.left=`${(100*o/c._pageWidth).toFixed(2)}%`,wt.top=`${(100*F/c._pageHeight).toFixed(2)}%`):(wt.left=`${$}${o.toFixed(2)}px)`,wt.top=`${$}${F.toFixed(2)}px)`),wt.fontSize=`${$}${u.toFixed(2)}px)`,wt.fontFamily=l.fontFamily,r.fontSize=u,m.setAttribute("role","presentation"),m.textContent=C.str,m.dir=C.dir,c._fontInspectorEnabled&&(m.dataset.fontName=C.fontName),a!==0&&(r.angle=a*(180/Math.PI));let U=!1;if(C.str.length>1)U=!0;else if(C.str!==" "&&C.transform[0]!==C.transform[3]){const G=Math.abs(C.transform[0]),H=Math.abs(C.transform[3]);G!==H&&Math.max(G,H)/Math.min(G,H)>1.5&&(U=!0)}U&&(r.canvasWidth=l.vertical?C.height:C.width),c._textDivProperties.set(m,r),c._isReadableStream&&c._layoutText(m)}function T(c){const{div:C,scale:I,properties:m,ctx:r,prevFontSize:h,prevFontFamily:a}=c,{style:l}=C;let u="";if(m.canvasWidth!==0&&m.hasText){const{fontFamily:R}=l,{canvasWidth:o,fontSize:F}=m;(h!==F||a!==R)&&(r.font=`${F*I}px ${R}`,c.prevFontSize=F,c.prevFontFamily=R);const{width:$}=r.measureText(C.textContent);$>0&&(u=`scaleX(${o*I/$})`)}m.angle!==0&&(u=`rotate(${m.angle}deg) ${u}`),u.length>0&&(l.transform=u)}function A(c){if(c._canceled)return;const C=c._textDivs,I=c._capability;if(C.length>Q){I.resolve();return}if(!c._isReadableStream)for(const r of C)c._layoutText(r);I.resolve()}class g{constructor({textContentSource:C,container:I,viewport:m,textDivs:r,textDivProperties:h,textContentItemsStr:a,isOffscreenCanvasSupported:l}){var $;this._textContentSource=C,this._isReadableStream=C instanceof ReadableStream,this._container=this._rootContainer=I,this._textDivs=r||[],this._textContentItemsStr=a||[],this._isOffscreenCanvasSupported=l,this._fontInspectorEnabled=!!(($=globalThis.FontInspector)!=null&&$.enabled),this._reader=null,this._textDivProperties=h||new WeakMap,this._canceled=!1,this._capability=new i.PromiseCapability,this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:m.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:k(0,l)};const{pageWidth:u,pageHeight:R,pageX:o,pageY:F}=m.rawDims;this._transform=[1,0,0,-1,-o,F+R],this._pageWidth=u,this._pageHeight=R,(0,y.setLayerDimensions)(I,m),this._capability.promise.finally(()=>{this._layoutTextParams=null}).catch(()=>{})}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch(()=>{}),this._reader=null),this._capability.reject(new i.AbortException("TextLayer task cancelled."))}_processItems(C,I){for(const m of C){if(m.str===void 0){if(m.type==="beginMarkedContentProps"||m.type==="beginMarkedContent"){const r=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),m.id!==null&&this._container.setAttribute("id",`${m.id}`),r.append(this._container)}else m.type==="endMarkedContent"&&(this._container=this._container.parentNode);continue}this._textContentItemsStr.push(m.str),P(this,m,I)}}_layoutText(C){const I=this._layoutTextParams.properties=this._textDivProperties.get(C);if(this._layoutTextParams.div=C,T(this._layoutTextParams),I.hasText&&this._container.append(C),I.hasEOL){const m=document.createElement("br");m.setAttribute("role","presentation"),this._container.append(m)}}_render(){const C=new i.PromiseCapability;let I=Object.create(null);if(this._isReadableStream){const m=()=>{this._reader.read().then(({value:r,done:h})=>{if(h){C.resolve();return}Object.assign(I,r.styles),this._processItems(r.items,I),m()},C.reject)};this._reader=this._textContentSource.getReader(),m()}else if(this._textContentSource){const{items:m,styles:r}=this._textContentSource;this._processItems(m,r),C.resolve()}else throw new Error('No "textContentSource" parameter specified.');C.promise.then(()=>{I=null,A(this)},this._capability.reject)}}e.TextLayerRenderTask=g;function E(c){!c.textContentSource&&(c.textContent||c.textContentStream)&&((0,y.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead."),c.textContentSource=c.textContent||c.textContentStream);const{container:C,viewport:I}=c,m=getComputedStyle(C),r=m.getPropertyValue("visibility"),h=parseFloat(m.getPropertyValue("--scale-factor"));r==="visible"&&(!h||Math.abs(h-I.scale)>1e-5)&&console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");const a=new g(c);return a._render(),a}function _({container:c,viewport:C,textDivs:I,textDivProperties:m,isOffscreenCanvasSupported:r,mustRotate:h=!0,mustRescale:a=!0}){if(h&&(0,y.setLayerDimensions)(c,{rotation:C.rotation}),a){const l=k(0,r),R={prevFontSize:null,prevFontFamily:null,div:null,scale:C.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:l};for(const o of I)R.properties=m.get(o),R.div=o,T(R)}}}),((d,e,b)=>{var f,P,T,A,g,E,_,c,C,I,m,Qn,xn,ts,es;Object.defineProperty(e,"__esModule",{value:!0}),e.AnnotationEditorLayer=void 0;var i=b(1),y=b(4),Q=b(28),z=b(33),xt=b(6),B=b(34);const u=class u{constructor({uiManager:o,pageIndex:F,div:$,accessibilityManager:wt,annotationLayer:U,viewport:G,l10n:H}){Tt(this,m);Tt(this,f);Tt(this,P,!1);Tt(this,T,null);Tt(this,A,this.pointerup.bind(this));Tt(this,g,this.pointerdown.bind(this));Tt(this,E,new Map);Tt(this,_,!1);Tt(this,c,!1);Tt(this,C,!1);Tt(this,I);const _t=[Q.FreeTextEditor,z.InkEditor,B.StampEditor];if(!u._initialized){u._initialized=!0;for(const D of _t)D.initialize(H)}o.registerEditorTypes(_t),Rt(this,I,o),this.pageIndex=F,this.div=$,Rt(this,f,wt),Rt(this,T,U),this.viewport=G,t(this,I).addLayer(this)}get isEmpty(){return t(this,E).size===0}updateToolbar(o){t(this,I).updateToolbar(o)}updateMode(o=t(this,I).getMode()){K(this,m,es).call(this),o===i.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),o!==i.AnnotationEditorType.NONE&&(this.div.classList.toggle("freeTextEditing",o===i.AnnotationEditorType.FREETEXT),this.div.classList.toggle("inkEditing",o===i.AnnotationEditorType.INK),this.div.classList.toggle("stampEditing",o===i.AnnotationEditorType.STAMP),this.div.hidden=!1)}addInkEditorIfNeeded(o){if(!o&&t(this,I).getMode()!==i.AnnotationEditorType.INK)return;if(!o){for(const $ of t(this,E).values())if($.isEmpty()){$.setInBackground();return}}K(this,m,xn).call(this,{offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(o){t(this,I).setEditingState(o)}addCommands(o){t(this,I).addCommands(o)}enable(){this.div.style.pointerEvents="auto";const o=new Set;for(const $ of t(this,E).values())$.enableEditing(),$.annotationElementId&&o.add($.annotationElementId);if(!t(this,T))return;const F=t(this,T).getEditableAnnotations();for(const $ of F){if($.hide(),t(this,I).isDeletedAnnotationElement($.data.id)||o.has($.data.id))continue;const wt=this.deserialize($);wt&&(this.addOrRebuild(wt),wt.enableEditing())}}disable(){var F;Rt(this,C,!0),this.div.style.pointerEvents="none";const o=new Set;for(const $ of t(this,E).values()){if($.disableEditing(),!$.annotationElementId||$.serialize()!==null){o.add($.annotationElementId);continue}(F=this.getEditableAnnotation($.annotationElementId))==null||F.show(),$.remove()}if(t(this,T)){const $=t(this,T).getEditableAnnotations();for(const wt of $){const{id:U}=wt.data;o.has(U)||t(this,I).isDeletedAnnotationElement(U)||wt.show()}}K(this,m,es).call(this),this.isEmpty&&(this.div.hidden=!0),Rt(this,C,!1)}getEditableAnnotation(o){var F;return((F=t(this,T))==null?void 0:F.getEditableAnnotation(o))||null}setActiveEditor(o){t(this,I).getActive()!==o&&t(this,I).setActiveEditor(o)}enableClick(){this.div.addEventListener("pointerdown",t(this,g)),this.div.addEventListener("pointerup",t(this,A))}disableClick(){this.div.removeEventListener("pointerdown",t(this,g)),this.div.removeEventListener("pointerup",t(this,A))}attach(o){t(this,E).set(o.id,o);const{annotationElementId:F}=o;F&&t(this,I).isDeletedAnnotationElement(F)&&t(this,I).removeDeletedAnnotationElement(o)}detach(o){var F;t(this,E).delete(o.id),(F=t(this,f))==null||F.removePointerInTextLayer(o.contentDiv),!t(this,C)&&o.annotationElementId&&t(this,I).addDeletedAnnotationElement(o)}remove(o){this.detach(o),t(this,I).removeEditor(o),o.div.contains(document.activeElement)&&setTimeout(()=>{t(this,I).focusMainContainer()},0),o.div.remove(),o.isAttachedToDOM=!1,t(this,c)||this.addInkEditorIfNeeded(!1)}changeParent(o){var F;o.parent!==this&&(o.annotationElementId&&(t(this,I).addDeletedAnnotationElement(o.annotationElementId),y.AnnotationEditor.deleteAnnotationElement(o),o.annotationElementId=null),this.attach(o),(F=o.parent)==null||F.detach(o),o.setParent(this),o.div&&o.isAttachedToDOM&&(o.div.remove(),this.div.append(o.div)))}add(o){if(this.changeParent(o),t(this,I).addEditor(o),this.attach(o),!o.isAttachedToDOM){const F=o.render();this.div.append(F),o.isAttachedToDOM=!0}o.fixAndSetPosition(),o.onceAdded(),t(this,I).addToAnnotationStorage(o)}moveEditorInDOM(o){var $;if(!o.isAttachedToDOM)return;const{activeElement:F}=document;o.div.contains(F)&&(o._focusEventsAllowed=!1,setTimeout(()=>{o.div.contains(document.activeElement)?o._focusEventsAllowed=!0:(o.div.addEventListener("focusin",()=>{o._focusEventsAllowed=!0},{once:!0}),F.focus())},0)),o._structTreeParentId=($=t(this,f))==null?void 0:$.moveElementInDOM(this.div,o.div,o.contentDiv,!0)}addOrRebuild(o){o.needsToBeRebuilt()?o.rebuild():this.add(o)}addUndoableEditor(o){const F=()=>o._uiManager.rebuild(o),$=()=>{o.remove()};this.addCommands({cmd:F,undo:$,mustExec:!1})}getNextId(){return t(this,I).getId()}pasteEditor(o,F){t(this,I).updateToolbar(o),t(this,I).updateMode(o);const{offsetX:$,offsetY:wt}=K(this,m,ts).call(this),U=this.getNextId(),G=K(this,m,Qn).call(this,{parent:this,id:U,x:$,y:wt,uiManager:t(this,I),isCentered:!0,...F});G&&this.add(G)}deserialize(o){switch(o.annotationType??o.annotationEditorType){case i.AnnotationEditorType.FREETEXT:return Q.FreeTextEditor.deserialize(o,this,t(this,I));case i.AnnotationEditorType.INK:return z.InkEditor.deserialize(o,this,t(this,I));case i.AnnotationEditorType.STAMP:return B.StampEditor.deserialize(o,this,t(this,I))}return null}addNewEditor(){K(this,m,xn).call(this,K(this,m,ts).call(this),!0)}setSelected(o){t(this,I).setSelected(o)}toggleSelected(o){t(this,I).toggleSelected(o)}isSelected(o){return t(this,I).isSelected(o)}unselect(o){t(this,I).unselect(o)}pointerup(o){const{isMac:F}=i.FeatureTest.platform;if(!(o.button!==0||o.ctrlKey&&F)&&o.target===this.div&&t(this,_)){if(Rt(this,_,!1),!t(this,P)){Rt(this,P,!0);return}if(t(this,I).getMode()===i.AnnotationEditorType.STAMP){t(this,I).unselectAll();return}K(this,m,xn).call(this,o,!1)}}pointerdown(o){if(t(this,_)){Rt(this,_,!1);return}const{isMac:F}=i.FeatureTest.platform;if(o.button!==0||o.ctrlKey&&F||o.target!==this.div)return;Rt(this,_,!0);const $=t(this,I).getActive();Rt(this,P,!$||$.isEmpty())}findNewParent(o,F,$){const wt=t(this,I).findParent(F,$);return wt===null||wt===this?!1:(wt.changeParent(o),!0)}destroy(){var o,F;((o=t(this,I).getActive())==null?void 0:o.parent)===this&&(t(this,I).commitOrRemove(),t(this,I).setActiveEditor(null));for(const $ of t(this,E).values())(F=t(this,f))==null||F.removePointerInTextLayer($.contentDiv),$.setParent(null),$.isAttachedToDOM=!1,$.div.remove();this.div=null,t(this,E).clear(),t(this,I).removeLayer(this)}render({viewport:o}){this.viewport=o,(0,xt.setLayerDimensions)(this.div,o);for(const F of t(this,I).getEditors(this.pageIndex))this.add(F);this.updateMode()}update({viewport:o}){t(this,I).commitOrRemove(),this.viewport=o,(0,xt.setLayerDimensions)(this.div,{rotation:o.rotation}),this.updateMode()}get pageDimensions(){const{pageWidth:o,pageHeight:F}=this.viewport.rawDims;return[o,F]}};f=new WeakMap,P=new WeakMap,T=new WeakMap,A=new WeakMap,g=new WeakMap,E=new WeakMap,_=new WeakMap,c=new WeakMap,C=new WeakMap,I=new WeakMap,m=new WeakSet,Qn=function(o){switch(t(this,I).getMode()){case i.AnnotationEditorType.FREETEXT:return new Q.FreeTextEditor(o);case i.AnnotationEditorType.INK:return new z.InkEditor(o);case i.AnnotationEditorType.STAMP:return new B.StampEditor(o)}return null},xn=function(o,F){const $=this.getNextId(),wt=K(this,m,Qn).call(this,{parent:this,id:$,x:o.offsetX,y:o.offsetY,uiManager:t(this,I),isCentered:F});return wt&&this.add(wt),wt},ts=function(){const{x:o,y:F,width:$,height:wt}=this.div.getBoundingClientRect(),U=Math.max(0,o),G=Math.max(0,F),H=Math.min(window.innerWidth,o+$),_t=Math.min(window.innerHeight,F+wt),D=(U+H)/2-o,W=(G+_t)/2-F,[J,S]=this.viewport.rotation%180===0?[D,W]:[W,D];return{offsetX:J,offsetY:S}},es=function(){Rt(this,c,!0);for(const o of t(this,E).values())o.isEmpty()&&o.remove();Rt(this,c,!1)},Fe(u,"_initialized",!1);let k=u;e.AnnotationEditorLayer=k}),((d,e,b)=>{var B,k,f,P,T,A,g,E,_,c,Ds,Ps,Ts,_n,ns,Rs,ss;Object.defineProperty(e,"__esModule",{value:!0}),e.FreeTextEditor=void 0;var i=b(1),y=b(5),Q=b(4),z=b(29);const u=class u extends Q.AnnotationEditor{constructor(F){super({...F,name:"freeTextEditor"});Tt(this,c);Tt(this,B,this.editorDivBlur.bind(this));Tt(this,k,this.editorDivFocus.bind(this));Tt(this,f,this.editorDivInput.bind(this));Tt(this,P,this.editorDivKeydown.bind(this));Tt(this,T);Tt(this,A,"");Tt(this,g,`${this.id}-editor`);Tt(this,E);Tt(this,_,null);Rt(this,T,F.color||u._defaultColor||Q.AnnotationEditor._defaultLineColor),Rt(this,E,F.fontSize||u._defaultFontSize)}static get _keyboardManager(){const F=u.prototype,$=G=>G.isEmpty(),wt=y.AnnotationEditorUIManager.TRANSLATE_SMALL,U=y.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new y.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],F.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],F.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],F._translateEmpty,{args:[-wt,0],checker:$}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],F._translateEmpty,{args:[-U,0],checker:$}],[["ArrowRight","mac+ArrowRight"],F._translateEmpty,{args:[wt,0],checker:$}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],F._translateEmpty,{args:[U,0],checker:$}],[["ArrowUp","mac+ArrowUp"],F._translateEmpty,{args:[0,-wt],checker:$}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],F._translateEmpty,{args:[0,-U],checker:$}],[["ArrowDown","mac+ArrowDown"],F._translateEmpty,{args:[0,wt],checker:$}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],F._translateEmpty,{args:[0,U],checker:$}]]))}static initialize(F){Q.AnnotationEditor.initialize(F,{strings:["free_text2_default_content","editor_free_text2_aria_label"]});const $=getComputedStyle(document.documentElement);this._internalPadding=parseFloat($.getPropertyValue("--freetext-padding"))}static updateDefaultParams(F,$){switch(F){case i.AnnotationEditorParamsType.FREETEXT_SIZE:u._defaultFontSize=$;break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:u._defaultColor=$;break}}updateParams(F,$){switch(F){case i.AnnotationEditorParamsType.FREETEXT_SIZE:K(this,c,Ds).call(this,$);break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:K(this,c,Ps).call(this,$);break}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,u._defaultFontSize],[i.AnnotationEditorParamsType.FREETEXT_COLOR,u._defaultColor||Q.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,t(this,E)],[i.AnnotationEditorParamsType.FREETEXT_COLOR,t(this,T)]]}_translateEmpty(F,$){this._uiManager.translateSelectedEditors(F,$,!0)}getInitialTranslation(){const F=this.parentScale;return[-u._internalPadding*F,-(u._internalPadding+t(this,E))*F]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(i.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",t(this,P)),this.editorDiv.addEventListener("focus",t(this,k)),this.editorDiv.addEventListener("blur",t(this,B)),this.editorDiv.addEventListener("input",t(this,f)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",t(this,g)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",t(this,P)),this.editorDiv.removeEventListener("focus",t(this,k)),this.editorDiv.removeEventListener("blur",t(this,B)),this.editorDiv.removeEventListener("input",t(this,f)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freeTextEditing"))}focusin(F){this._focusEventsAllowed&&(super.focusin(F),F.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var F;if(this.width){K(this,c,ss).call(this);return}this.enableEditMode(),this.editorDiv.focus(),(F=this._initialOptions)!=null&&F.isCentered&&this.center(),this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freeTextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const F=t(this,A),$=Rt(this,A,K(this,c,Ts).call(this).trimEnd());if(F===$)return;const wt=U=>{if(Rt(this,A,U),!U){this.remove();return}K(this,c,ns).call(this),this._uiManager.rebuild(this),K(this,c,_n).call(this)};this.addCommands({cmd:()=>{wt($)},undo:()=>{wt(F)},mustExec:!1}),K(this,c,_n).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(F){this.enterInEditMode()}keydown(F){F.target===this.div&&F.key==="Enter"&&(this.enterInEditMode(),F.preventDefault())}editorDivKeydown(F){u._keyboardManager.exec(this,F)}editorDivFocus(F){this.isEditing=!0}editorDivBlur(F){this.isEditing=!1}editorDivInput(F){this.parent.div.classList.toggle("freeTextEditing",this.isEmpty())}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 F,$;this.width&&(F=this.x,$=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",t(this,g)),this.enableEditing(),Q.AnnotationEditor._l10nPromise.get("editor_free_text2_aria_label").then(U=>{var G;return(G=this.editorDiv)==null?void 0:G.setAttribute("aria-label",U)}),Q.AnnotationEditor._l10nPromise.get("free_text2_default_content").then(U=>{var G;return(G=this.editorDiv)==null?void 0:G.setAttribute("default-content",U)}),this.editorDiv.contentEditable=!0;const{style:wt}=this.editorDiv;if(wt.fontSize=`calc(${t(this,E)}px * var(--scale-factor))`,wt.color=t(this,T),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,y.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){const[U,G]=this.parentDimensions;if(this.annotationElementId){const{position:H}=t(this,_);let[_t,D]=this.getInitialTranslation();[_t,D]=this.pageTranslationToScreen(_t,D);const[W,J]=this.pageDimensions,[S,n]=this.pageTranslation;let s,p;switch(this.rotation){case 0:s=F+(H[0]-S)/W,p=$+this.height-(H[1]-n)/J;break;case 90:s=F+(H[0]-S)/W,p=$-(H[1]-n)/J,[_t,D]=[D,-_t];break;case 180:s=F-this.width+(H[0]-S)/W,p=$-(H[1]-n)/J,[_t,D]=[-_t,-D];break;case 270:s=F+(H[0]-S-this.height*J)/W,p=$+(H[1]-n-this.width*W)/J,[_t,D]=[-D,_t];break}this.setAt(s*U,p*G,_t,D)}else this.setAt(F*U,$*G,this.width*U,this.height*G);K(this,c,ns).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(F,$,wt){let U=null;if(F instanceof z.FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:H,fontColor:_t},rect:D,rotation:W,id:J},textContent:S,textPosition:n,parent:{page:{pageNumber:s}}}=F;if(!S||S.length===0)return null;U=F={annotationType:i.AnnotationEditorType.FREETEXT,color:Array.from(_t),fontSize:H,value:S.join(`
40
+ `),position:n,pageIndex:s-1,rect:D,rotation:W,id:J,deleted:!1}}const G=super.deserialize(F,$,wt);return Rt(G,E,F.fontSize),Rt(G,T,i.Util.makeHexColor(...F.color)),Rt(G,A,F.value),G.annotationElementId=F.id||null,Rt(G,_,U),G}serialize(F=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const $=u._internalPadding*this.parentScale,wt=this.getRect($,$),U=Q.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:t(this,T)),G={annotationType:i.AnnotationEditorType.FREETEXT,color:U,fontSize:t(this,E),value:t(this,A),pageIndex:this.pageIndex,rect:wt,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return F?G:this.annotationElementId&&!K(this,c,Rs).call(this,G)?null:(G.id=this.annotationElementId,G)}};B=new WeakMap,k=new WeakMap,f=new WeakMap,P=new WeakMap,T=new WeakMap,A=new WeakMap,g=new WeakMap,E=new WeakMap,_=new WeakMap,c=new WeakSet,Ds=function(F){const $=U=>{this.editorDiv.style.fontSize=`calc(${U}px * var(--scale-factor))`,this.translate(0,-(U-t(this,E))*this.parentScale),Rt(this,E,U),K(this,c,_n).call(this)},wt=t(this,E);this.addCommands({cmd:()=>{$(F)},undo:()=>{$(wt)},mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Ps=function(F){const $=t(this,T);this.addCommands({cmd:()=>{Rt(this,T,this.editorDiv.style.color=F)},undo:()=>{Rt(this,T,this.editorDiv.style.color=$)},mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Ts=function(){const F=this.editorDiv.getElementsByTagName("div");if(F.length===0)return this.editorDiv.innerText;const $=[];for(const wt of F)$.push(wt.innerText.replace(/\r\n?|\n/,""));return $.join(`
41
+ `)},_n=function(){const[F,$]=this.parentDimensions;let wt;if(this.isAttachedToDOM)wt=this.div.getBoundingClientRect();else{const{currentLayer:U,div:G}=this,H=G.style.display;G.style.display="hidden",U.div.append(this.div),wt=G.getBoundingClientRect(),G.remove(),G.style.display=H}this.rotation%180===this.parentRotation%180?(this.width=wt.width/F,this.height=wt.height/$):(this.width=wt.height/F,this.height=wt.width/$),this.fixAndSetPosition()},ns=function(){if(this.editorDiv.replaceChildren(),!!t(this,A))for(const F of t(this,A).split(`
42
+ `)){const $=document.createElement("div");$.append(F?document.createTextNode(F):document.createElement("br")),this.editorDiv.append($)}},Rs=function(F){const{value:$,fontSize:wt,color:U,rect:G,pageIndex:H}=t(this,_);return F.value!==$||F.fontSize!==wt||F.rect.some((_t,D)=>Math.abs(_t-G[D])>=1)||F.color.some((_t,D)=>_t!==U[D])||F.pageIndex!==H},ss=function(F=!1){if(!this.annotationElementId)return;if(K(this,c,_n).call(this),!F&&(this.width===0||this.height===0)){setTimeout(()=>K(this,c,ss).call(this,!0),0);return}const $=u._internalPadding*this.parentScale;t(this,_).rect=this.getRect($,$)},Fe(u,"_freeTextDefaultContent",""),Fe(u,"_internalPadding",0),Fe(u,"_defaultColor",null),Fe(u,"_defaultFontSize",10),Fe(u,"_type","freetext");let xt=u;e.FreeTextEditor=xt}),((d,e,b)=>{var p,O,on,Ms,At,It,Bt,jt,Ut,Xt,vt,kt,v,N,Z,St,Nt,zt,qt,bt,Jt,Kt,Is,kn,is,rs,re,pe,Ee,Gt,Pt,Mt,te,as,de,j,$t,Y,Ls,os;Object.defineProperty(e,"__esModule",{value:!0}),e.StampAnnotationElement=e.InkAnnotationElement=e.FreeTextAnnotationElement=e.AnnotationLayer=void 0;var i=b(1),y=b(6),Q=b(3),z=b(30),xt=b(31),B=b(32);const k=1e3,f=9,P=new WeakSet;function T(Wt){return{width:Wt[2]-Wt[0],height:Wt[3]-Wt[1]}}class A{static create(w){switch(w.data.annotationType){case i.AnnotationType.LINK:return new E(w);case i.AnnotationType.TEXT:return new _(w);case i.AnnotationType.WIDGET:switch(w.data.fieldType){case"Tx":return new C(w);case"Btn":return w.data.radioButton?new r(w):w.data.checkBox?new m(w):new h(w);case"Ch":return new a(w);case"Sig":return new I(w)}return new c(w);case i.AnnotationType.POPUP:return new l(w);case i.AnnotationType.FREETEXT:return new R(w);case i.AnnotationType.LINE:return new o(w);case i.AnnotationType.SQUARE:return new F(w);case i.AnnotationType.CIRCLE:return new $(w);case i.AnnotationType.POLYLINE:return new wt(w);case i.AnnotationType.CARET:return new G(w);case i.AnnotationType.INK:return new H(w);case i.AnnotationType.POLYGON:return new U(w);case i.AnnotationType.HIGHLIGHT:return new _t(w);case i.AnnotationType.UNDERLINE:return new D(w);case i.AnnotationType.SQUIGGLY:return new W(w);case i.AnnotationType.STRIKEOUT:return new J(w);case i.AnnotationType.STAMP:return new S(w);case i.AnnotationType.FILEATTACHMENT:return new n(w);default:return new g(w)}}}const M=class M{constructor(w,{isRenderable:x=!1,ignoreBorder:q=!1,createQuadrilaterals:Dt=!1}={}){Tt(this,p,!1);this.isRenderable=x,this.data=w.data,this.layer=w.layer,this.linkService=w.linkService,this.downloadManager=w.downloadManager,this.imageResourcesPath=w.imageResourcesPath,this.renderForms=w.renderForms,this.svgFactory=w.svgFactory,this.annotationStorage=w.annotationStorage,this.enableScripting=w.enableScripting,this.hasJSActions=w.hasJSActions,this._fieldObjects=w.fieldObjects,this.parent=w.parent,x&&(this.container=this._createContainer(q)),Dt&&this._createQuadrilaterals()}static _hasPopupData({titleObj:w,contentsObj:x,richText:q}){return!!(w!=null&&w.str||x!=null&&x.str||q!=null&&q.str)}get hasPopupData(){return M._hasPopupData(this.data)}_createContainer(w){const{data:x,parent:{page:q,viewport:Dt}}=this,Ot=document.createElement("section");Ot.setAttribute("data-annotation-id",x.id),this instanceof c||(Ot.tabIndex=k),Ot.style.zIndex=this.parent.zIndex++,this.data.popupRef&&Ot.setAttribute("aria-haspopup","dialog"),x.noRotate&&Ot.classList.add("norotate");const{pageWidth:Ht,pageHeight:Yt,pageX:ee,pageY:se}=Dt.rawDims;if(!x.rect||this instanceof l){const{rotation:le}=x;return!x.hasOwnCanvas&&le!==0&&this.setRotation(le,Ot),Ot}const{width:Zt,height:he}=T(x.rect),ie=i.Util.normalizeRect([x.rect[0],q.view[3]-x.rect[1]+q.view[1],x.rect[2],q.view[3]-x.rect[3]+q.view[1]]);if(!w&&x.borderStyle.width>0){Ot.style.borderWidth=`${x.borderStyle.width}px`;const le=x.borderStyle.horizontalCornerRadius,fe=x.borderStyle.verticalCornerRadius;if(le>0||fe>0){const Ce=`calc(${le}px * var(--scale-factor)) / calc(${fe}px * var(--scale-factor))`;Ot.style.borderRadius=Ce}else if(this instanceof r){const Ce=`calc(${Zt}px * var(--scale-factor)) / calc(${he}px * var(--scale-factor))`;Ot.style.borderRadius=Ce}switch(x.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:Ot.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:Ot.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:Ot.style.borderBottomStyle="solid";break}const ve=x.borderColor||null;ve?(Rt(this,p,!0),Ot.style.borderColor=i.Util.makeHexColor(ve[0]|0,ve[1]|0,ve[2]|0)):Ot.style.borderWidth=0}Ot.style.left=`${100*(ie[0]-ee)/Ht}%`,Ot.style.top=`${100*(ie[1]-se)/Yt}%`;const{rotation:ae}=x;return x.hasOwnCanvas||ae===0?(Ot.style.width=`${100*Zt/Ht}%`,Ot.style.height=`${100*he/Yt}%`):this.setRotation(ae,Ot),Ot}setRotation(w,x=this.container){if(!this.data.rect)return;const{pageWidth:q,pageHeight:Dt}=this.parent.viewport.rawDims,{width:Ot,height:Ht}=T(this.data.rect);let Yt,ee;w%180===0?(Yt=100*Ot/q,ee=100*Ht/Dt):(Yt=100*Ht/q,ee=100*Ot/Dt),x.style.width=`${Yt}%`,x.style.height=`${ee}%`,x.setAttribute("data-main-rotation",(360-w)%360)}get _commonActions(){const w=(x,q,Dt)=>{const Ot=Dt.detail[x],Ht=Ot[0],Yt=Ot.slice(1);Dt.target.style[q]=z.ColorConverters[`${Ht}_HTML`](Yt),this.annotationStorage.setValue(this.data.id,{[q]:z.ColorConverters[`${Ht}_rgb`](Yt)})};return(0,i.shadow)(this,"_commonActions",{display:x=>{const{display:q}=x.detail,Dt=q%2===1;this.container.style.visibility=Dt?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:Dt,noPrint:q===1||q===2})},print:x=>{this.annotationStorage.setValue(this.data.id,{noPrint:!x.detail.print})},hidden:x=>{const{hidden:q}=x.detail;this.container.style.visibility=q?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:q,noView:q})},focus:x=>{setTimeout(()=>x.target.focus({preventScroll:!1}),0)},userName:x=>{x.target.title=x.detail.userName},readonly:x=>{x.target.disabled=x.detail.readonly},required:x=>{this._setRequired(x.target,x.detail.required)},bgColor:x=>{w("bgColor","backgroundColor",x)},fillColor:x=>{w("fillColor","backgroundColor",x)},fgColor:x=>{w("fgColor","color",x)},textColor:x=>{w("textColor","color",x)},borderColor:x=>{w("borderColor","borderColor",x)},strokeColor:x=>{w("strokeColor","borderColor",x)},rotation:x=>{const q=x.detail.rotation;this.setRotation(q),this.annotationStorage.setValue(this.data.id,{rotation:q})}})}_dispatchEventFromSandbox(w,x){const q=this._commonActions;for(const Dt of Object.keys(x.detail)){const Ot=w[Dt]||q[Dt];Ot==null||Ot(x)}}_setDefaultPropertiesFromJS(w){if(!this.enableScripting)return;const x=this.annotationStorage.getRawValue(this.data.id);if(!x)return;const q=this._commonActions;for(const[Dt,Ot]of Object.entries(x)){const Ht=q[Dt];if(Ht){const Yt={detail:{[Dt]:Ot},target:w};Ht(Yt),delete x[Dt]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:w}=this.data;if(!w)return;const[x,q,Dt,Ot]=this.data.rect;if(w.length===1){const[,{x:fe,y:ve},{x:Ce,y:tn}]=w[0];if(Dt===fe&&Ot===ve&&x===Ce&&q===tn)return}const{style:Ht}=this.container;let Yt;if(t(this,p)){const{borderColor:fe,borderWidth:ve}=Ht;Ht.borderWidth=0,Yt=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${fe}" stroke-width="${ve}">`],this.container.classList.add("hasBorder")}const ee=Dt-x,se=Ot-q,{svgFactory:Zt}=this,he=Zt.createElement("svg");he.classList.add("quadrilateralsContainer"),he.setAttribute("width",0),he.setAttribute("height",0);const ie=Zt.createElement("defs");he.append(ie);const ae=Zt.createElement("clipPath"),le=`clippath_${this.data.id}`;ae.setAttribute("id",le),ae.setAttribute("clipPathUnits","objectBoundingBox"),ie.append(ae);for(const[,{x:fe,y:ve},{x:Ce,y:tn}]of w){const we=Zt.createElement("rect"),nn=(Ce-x)/ee,rn=(Ot-ve)/se,an=(fe-Ce)/ee,ms=(ve-tn)/se;we.setAttribute("x",nn),we.setAttribute("y",rn),we.setAttribute("width",an),we.setAttribute("height",ms),ae.append(we),Yt==null||Yt.push(`<rect vector-effect="non-scaling-stroke" x="${nn}" y="${rn}" width="${an}" height="${ms}"/>`)}t(this,p)&&(Yt.push("</g></svg>')"),Ht.backgroundImage=Yt.join("")),this.container.append(he),this.container.style.clipPath=`url(#${le})`}_createPopup(){const{container:w,data:x}=this;w.setAttribute("aria-haspopup","dialog");const q=new l({data:{color:x.color,titleObj:x.titleObj,modificationDate:x.modificationDate,contentsObj:x.contentsObj,richText:x.richText,parentRect:x.rect,borderStyle:0,id:`popup_${x.id}`,rotation:x.rotation},parent:this.parent,elements:[this]});this.parent.div.append(q.render())}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(w,x=null){const q=[];if(this._fieldObjects){const Dt=this._fieldObjects[w];if(Dt)for(const{page:Ot,id:Ht,exportValues:Yt}of Dt){if(Ot===-1||Ht===x)continue;const ee=typeof Yt=="string"?Yt:null,se=document.querySelector(`[data-element-id="${Ht}"]`);if(se&&!P.has(se)){(0,i.warn)(`_getElementsByName - element not allowed: ${Ht}`);continue}q.push({id:Ht,exportValue:ee,domElement:se})}return q}for(const Dt of document.getElementsByName(w)){const{exportValue:Ot}=Dt,Ht=Dt.getAttribute("data-element-id");Ht!==x&&P.has(Dt)&&q.push({id:Ht,exportValue:Ot,domElement:Dt})}return q}show(){var w;this.container&&(this.container.hidden=!1),(w=this.popup)==null||w.maybeShow()}hide(){var w;this.container&&(this.container.hidden=!0),(w=this.popup)==null||w.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const w=this.getElementsToTriggerPopup();if(Array.isArray(w))for(const x of w)x.classList.add("highlightArea");else w.classList.add("highlightArea")}_editOnDoubleClick(){const{annotationEditorType:w,data:{id:x}}=this;this.container.addEventListener("dblclick",()=>{var q;(q=this.linkService.eventBus)==null||q.dispatch("switchannotationeditormode",{source:this,mode:w,editId:x})})}};p=new WeakMap;let g=M;class E extends g{constructor(x,q=null){super(x,{isRenderable:!0,ignoreBorder:!!(q!=null&&q.ignoreBorder),createQuadrilaterals:!0});Tt(this,O);this.isTooltipOnly=x.data.isTooltipOnly}render(){const{data:x,linkService:q}=this,Dt=document.createElement("a");Dt.setAttribute("data-element-id",x.id);let Ot=!1;return x.url?(q.addLinkAttributes(Dt,x.url,x.newWindow),Ot=!0):x.action?(this._bindNamedAction(Dt,x.action),Ot=!0):x.attachment?(this._bindAttachment(Dt,x.attachment),Ot=!0):x.setOCGState?(K(this,O,Ms).call(this,Dt,x.setOCGState),Ot=!0):x.dest?(this._bindLink(Dt,x.dest),Ot=!0):(x.actions&&(x.actions.Action||x.actions["Mouse Up"]||x.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(Dt,x),Ot=!0),x.resetForm?(this._bindResetFormAction(Dt,x.resetForm),Ot=!0):this.isTooltipOnly&&!Ot&&(this._bindLink(Dt,""),Ot=!0)),this.container.classList.add("linkAnnotation"),Ot&&this.container.append(Dt),this.container}_bindLink(x,q){x.href=this.linkService.getDestinationHash(q),x.onclick=()=>(q&&this.linkService.goToDestination(q),!1),(q||q==="")&&K(this,O,on).call(this)}_bindNamedAction(x,q){x.href=this.linkService.getAnchorUrl(""),x.onclick=()=>(this.linkService.executeNamedAction(q),!1),K(this,O,on).call(this)}_bindAttachment(x,q){x.href=this.linkService.getAnchorUrl(""),x.onclick=()=>{var Dt;return(Dt=this.downloadManager)==null||Dt.openOrDownloadData(this.container,q.content,q.filename),!1},K(this,O,on).call(this)}_bindJSAction(x,q){x.href=this.linkService.getAnchorUrl("");const Dt=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const Ot of Object.keys(q.actions)){const Ht=Dt.get(Ot);Ht&&(x[Ht]=()=>{var Yt;return(Yt=this.linkService.eventBus)==null||Yt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:q.id,name:Ot}}),!1})}x.onclick||(x.onclick=()=>!1),K(this,O,on).call(this)}_bindResetFormAction(x,q){const Dt=x.onclick;if(Dt||(x.href=this.linkService.getAnchorUrl("")),K(this,O,on).call(this),!this._fieldObjects){(0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),Dt||(x.onclick=()=>!1);return}x.onclick=()=>{var he;Dt==null||Dt();const{fields:Ot,refs:Ht,include:Yt}=q,ee=[];if(Ot.length!==0||Ht.length!==0){const ie=new Set(Ht);for(const ae of Ot){const le=this._fieldObjects[ae]||[];for(const{id:fe}of le)ie.add(fe)}for(const ae of Object.values(this._fieldObjects))for(const le of ae)ie.has(le.id)===Yt&&ee.push(le)}else for(const ie of Object.values(this._fieldObjects))ee.push(...ie);const se=this.annotationStorage,Zt=[];for(const ie of ee){const{id:ae}=ie;switch(Zt.push(ae),ie.type){case"text":{const fe=ie.defaultValue||"";se.setValue(ae,{value:fe});break}case"checkbox":case"radiobutton":{const fe=ie.defaultValue===ie.exportValues;se.setValue(ae,{value:fe});break}case"combobox":case"listbox":{const fe=ie.defaultValue||"";se.setValue(ae,{value:fe});break}default:continue}const le=document.querySelector(`[data-element-id="${ae}"]`);if(le){if(!P.has(le)){(0,i.warn)(`_bindResetFormAction - element not allowed: ${ae}`);continue}}else continue;le.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((he=this.linkService.eventBus)==null||he.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:Zt,name:"ResetForm"}})),!1}}}O=new WeakSet,on=function(){this.container.setAttribute("data-internal-link","")},Ms=function(x,q){x.href=this.linkService.getAnchorUrl(""),x.onclick=()=>(this.linkService.executeSetOCGState(q),!1),K(this,O,on).call(this)};class _ extends g{constructor(w){super(w,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const w=document.createElement("img");return w.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",w.alt="[{{type}} Annotation]",w.dataset.l10nId="text_annotation_type",w.dataset.l10nArgs=JSON.stringify({type:this.data.name}),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(w),this.container}}class c extends g{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}showElementAndHideCanvas(w){var x;this.data.hasOwnCanvas&&(((x=w.previousSibling)==null?void 0:x.nodeName)==="CANVAS"&&(w.previousSibling.hidden=!0),w.hidden=!1)}_getKeyModifier(w){const{isWin:x,isMac:q}=i.FeatureTest.platform;return x&&w.ctrlKey||q&&w.metaKey}_setEventListener(w,x,q,Dt,Ot){q.includes("mouse")?w.addEventListener(q,Ht=>{var Yt;(Yt=this.linkService.eventBus)==null||Yt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:Dt,value:Ot(Ht),shift:Ht.shiftKey,modifier:this._getKeyModifier(Ht)}})}):w.addEventListener(q,Ht=>{var Yt;if(q==="blur"){if(!x.focused||!Ht.relatedTarget)return;x.focused=!1}else if(q==="focus"){if(x.focused)return;x.focused=!0}Ot&&((Yt=this.linkService.eventBus)==null||Yt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:Dt,value:Ot(Ht)}}))})}_setEventListeners(w,x,q,Dt){var Ot,Ht,Yt;for(const[ee,se]of q)(se==="Action"||(Ot=this.data.actions)!=null&&Ot[se])&&((se==="Focus"||se==="Blur")&&(x||(x={focused:!1})),this._setEventListener(w,x,ee,se,Dt),se==="Focus"&&!((Ht=this.data.actions)!=null&&Ht.Blur)?this._setEventListener(w,x,"blur","Blur",null):se==="Blur"&&!((Yt=this.data.actions)!=null&&Yt.Focus)&&this._setEventListener(w,x,"focus","Focus",null))}_setBackgroundColor(w){const x=this.data.backgroundColor||null;w.style.backgroundColor=x===null?"transparent":i.Util.makeHexColor(x[0],x[1],x[2])}_setTextStyle(w){const x=["left","center","right"],{fontColor:q}=this.data.defaultAppearanceData,Dt=this.data.defaultAppearanceData.fontSize||f,Ot=w.style;let Ht;const Yt=2,ee=se=>Math.round(10*se)/10;if(this.data.multiLine){const se=Math.abs(this.data.rect[3]-this.data.rect[1]-Yt),Zt=Math.round(se/(i.LINE_FACTOR*Dt))||1,he=se/Zt;Ht=Math.min(Dt,ee(he/i.LINE_FACTOR))}else{const se=Math.abs(this.data.rect[3]-this.data.rect[1]-Yt);Ht=Math.min(Dt,ee(se/i.LINE_FACTOR))}Ot.fontSize=`calc(${Ht}px * var(--scale-factor))`,Ot.color=i.Util.makeHexColor(q[0],q[1],q[2]),this.data.textAlignment!==null&&(Ot.textAlign=x[this.data.textAlignment])}_setRequired(w,x){x?w.setAttribute("required",!0):w.removeAttribute("required"),w.setAttribute("aria-required",x)}}class C extends c{constructor(w){const x=w.renderForms||!w.data.hasAppearance&&!!w.data.fieldValue;super(w,{isRenderable:x})}setPropertyOnSiblings(w,x,q,Dt){const Ot=this.annotationStorage;for(const Ht of this._getElementsByName(w.name,w.id))Ht.domElement&&(Ht.domElement[x]=q),Ot.setValue(Ht.id,{[Dt]:q})}render(){var Dt,Ot;const w=this.annotationStorage,x=this.data.id;this.container.classList.add("textWidgetAnnotation");let q=null;if(this.renderForms){const Ht=w.getValue(x,{value:this.data.fieldValue});let Yt=Ht.value||"";const ee=w.getValue(x,{charLimit:this.data.maxLen}).charLimit;ee&&Yt.length>ee&&(Yt=Yt.slice(0,ee));let se=Ht.formattedValue||((Dt=this.data.textContent)==null?void 0:Dt.join(`
43
+ `))||null;se&&this.data.comb&&(se=se.replaceAll(/\s+/g,""));const Zt={userValue:Yt,formattedValue:se,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(q=document.createElement("textarea"),q.textContent=se??Yt,this.data.doNotScroll&&(q.style.overflowY="hidden")):(q=document.createElement("input"),q.type="text",q.setAttribute("value",se??Yt),this.data.doNotScroll&&(q.style.overflowX="hidden")),this.data.hasOwnCanvas&&(q.hidden=!0),P.add(q),q.setAttribute("data-element-id",x),q.disabled=this.data.readOnly,q.name=this.data.fieldName,q.tabIndex=k,this._setRequired(q,this.data.required),ee&&(q.maxLength=ee),q.addEventListener("input",ie=>{w.setValue(x,{value:ie.target.value}),this.setPropertyOnSiblings(q,"value",ie.target.value,"value"),Zt.formattedValue=null}),q.addEventListener("resetform",ie=>{const ae=this.data.defaultFieldValue??"";q.value=Zt.userValue=ae,Zt.formattedValue=null});let he=ie=>{const{formattedValue:ae}=Zt;ae!=null&&(ie.target.value=ae),ie.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){q.addEventListener("focus",ae=>{if(Zt.focused)return;const{target:le}=ae;Zt.userValue&&(le.value=Zt.userValue),Zt.lastCommittedValue=le.value,Zt.commitKey=1,Zt.focused=!0}),q.addEventListener("updatefromsandbox",ae=>{this.showElementAndHideCanvas(ae.target);const le={value(fe){Zt.userValue=fe.detail.value??"",w.setValue(x,{value:Zt.userValue.toString()}),fe.target.value=Zt.userValue},formattedValue(fe){const{formattedValue:ve}=fe.detail;Zt.formattedValue=ve,ve!=null&&fe.target!==document.activeElement&&(fe.target.value=ve),w.setValue(x,{formattedValue:ve})},selRange(fe){fe.target.setSelectionRange(...fe.detail.selRange)},charLimit:fe=>{var we;const{charLimit:ve}=fe.detail,{target:Ce}=fe;if(ve===0){Ce.removeAttribute("maxLength");return}Ce.setAttribute("maxLength",ve);let tn=Zt.userValue;!tn||tn.length<=ve||(tn=tn.slice(0,ve),Ce.value=Zt.userValue=tn,w.setValue(x,{value:tn}),(we=this.linkService.eventBus)==null||we.dispatch("dispatcheventinsandbox",{source:this,detail:{id:x,name:"Keystroke",value:tn,willCommit:!0,commitKey:1,selStart:Ce.selectionStart,selEnd:Ce.selectionEnd}}))}};this._dispatchEventFromSandbox(le,ae)}),q.addEventListener("keydown",ae=>{var ve;Zt.commitKey=1;let le=-1;if(ae.key==="Escape"?le=0:ae.key==="Enter"&&!this.data.multiLine?le=2:ae.key==="Tab"&&(Zt.commitKey=3),le===-1)return;const{value:fe}=ae.target;Zt.lastCommittedValue!==fe&&(Zt.lastCommittedValue=fe,Zt.userValue=fe,(ve=this.linkService.eventBus)==null||ve.dispatch("dispatcheventinsandbox",{source:this,detail:{id:x,name:"Keystroke",value:fe,willCommit:!0,commitKey:le,selStart:ae.target.selectionStart,selEnd:ae.target.selectionEnd}}))});const ie=he;he=null,q.addEventListener("blur",ae=>{var fe;if(!Zt.focused||!ae.relatedTarget)return;Zt.focused=!1;const{value:le}=ae.target;Zt.userValue=le,Zt.lastCommittedValue!==le&&((fe=this.linkService.eventBus)==null||fe.dispatch("dispatcheventinsandbox",{source:this,detail:{id:x,name:"Keystroke",value:le,willCommit:!0,commitKey:Zt.commitKey,selStart:ae.target.selectionStart,selEnd:ae.target.selectionEnd}})),ie(ae)}),(Ot=this.data.actions)!=null&&Ot.Keystroke&&q.addEventListener("beforeinput",ae=>{var rn;Zt.lastCommittedValue=null;const{data:le,target:fe}=ae,{value:ve,selectionStart:Ce,selectionEnd:tn}=fe;let we=Ce,nn=tn;switch(ae.inputType){case"deleteWordBackward":{const an=ve.substring(0,Ce).match(/\w*[^\w]*$/);an&&(we-=an[0].length);break}case"deleteWordForward":{const an=ve.substring(Ce).match(/^[^\w]*\w*/);an&&(nn+=an[0].length);break}case"deleteContentBackward":Ce===tn&&(we-=1);break;case"deleteContentForward":Ce===tn&&(nn+=1);break}ae.preventDefault(),(rn=this.linkService.eventBus)==null||rn.dispatch("dispatcheventinsandbox",{source:this,detail:{id:x,name:"Keystroke",value:ve,change:le||"",willCommit:!1,selStart:we,selEnd:nn}})}),this._setEventListeners(q,Zt,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],ae=>ae.target.value)}if(he&&q.addEventListener("blur",he),this.data.comb){const ae=(this.data.rect[2]-this.data.rect[0])/ee;q.classList.add("comb"),q.style.letterSpacing=`calc(${ae}px * var(--scale-factor) - 1ch)`}}else q=document.createElement("div"),q.textContent=this.data.fieldValue,q.style.verticalAlign="middle",q.style.display="table-cell";return this._setTextStyle(q),this._setBackgroundColor(q),this._setDefaultPropertiesFromJS(q),this.container.append(q),this.container}}class I extends c{constructor(w){super(w,{isRenderable:!!w.data.hasOwnCanvas})}}class m extends c{constructor(w){super(w,{isRenderable:w.renderForms})}render(){const w=this.annotationStorage,x=this.data,q=x.id;let Dt=w.getValue(q,{value:x.exportValue===x.fieldValue}).value;typeof Dt=="string"&&(Dt=Dt!=="Off",w.setValue(q,{value:Dt})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const Ot=document.createElement("input");return P.add(Ot),Ot.setAttribute("data-element-id",q),Ot.disabled=x.readOnly,this._setRequired(Ot,this.data.required),Ot.type="checkbox",Ot.name=x.fieldName,Dt&&Ot.setAttribute("checked",!0),Ot.setAttribute("exportValue",x.exportValue),Ot.tabIndex=k,Ot.addEventListener("change",Ht=>{const{name:Yt,checked:ee}=Ht.target;for(const se of this._getElementsByName(Yt,q)){const Zt=ee&&se.exportValue===x.exportValue;se.domElement&&(se.domElement.checked=Zt),w.setValue(se.id,{value:Zt})}w.setValue(q,{value:ee})}),Ot.addEventListener("resetform",Ht=>{const Yt=x.defaultFieldValue||"Off";Ht.target.checked=Yt===x.exportValue}),this.enableScripting&&this.hasJSActions&&(Ot.addEventListener("updatefromsandbox",Ht=>{const Yt={value(ee){ee.target.checked=ee.detail.value!=="Off",w.setValue(q,{value:ee.target.checked})}};this._dispatchEventFromSandbox(Yt,Ht)}),this._setEventListeners(Ot,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],Ht=>Ht.target.checked)),this._setBackgroundColor(Ot),this._setDefaultPropertiesFromJS(Ot),this.container.append(Ot),this.container}}class r extends c{constructor(w){super(w,{isRenderable:w.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const w=this.annotationStorage,x=this.data,q=x.id;let Dt=w.getValue(q,{value:x.fieldValue===x.buttonValue}).value;typeof Dt=="string"&&(Dt=Dt!==x.buttonValue,w.setValue(q,{value:Dt}));const Ot=document.createElement("input");if(P.add(Ot),Ot.setAttribute("data-element-id",q),Ot.disabled=x.readOnly,this._setRequired(Ot,this.data.required),Ot.type="radio",Ot.name=x.fieldName,Dt&&Ot.setAttribute("checked",!0),Ot.tabIndex=k,Ot.addEventListener("change",Ht=>{const{name:Yt,checked:ee}=Ht.target;for(const se of this._getElementsByName(Yt,q))w.setValue(se.id,{value:!1});w.setValue(q,{value:ee})}),Ot.addEventListener("resetform",Ht=>{const Yt=x.defaultFieldValue;Ht.target.checked=Yt!=null&&Yt===x.buttonValue}),this.enableScripting&&this.hasJSActions){const Ht=x.buttonValue;Ot.addEventListener("updatefromsandbox",Yt=>{const ee={value:se=>{const Zt=Ht===se.detail.value;for(const he of this._getElementsByName(se.target.name)){const ie=Zt&&he.id===q;he.domElement&&(he.domElement.checked=ie),w.setValue(he.id,{value:ie})}}};this._dispatchEventFromSandbox(ee,Yt)}),this._setEventListeners(Ot,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],Yt=>Yt.target.checked)}return this._setBackgroundColor(Ot),this._setDefaultPropertiesFromJS(Ot),this.container.append(Ot),this.container}}class h extends E{constructor(w){super(w,{ignoreBorder:w.data.hasAppearance})}render(){const w=super.render();w.classList.add("buttonWidgetAnnotation","pushButton"),this.data.alternativeText&&(w.title=this.data.alternativeText);const x=w.lastChild;return this.enableScripting&&this.hasJSActions&&x&&(this._setDefaultPropertiesFromJS(x),x.addEventListener("updatefromsandbox",q=>{this._dispatchEventFromSandbox({},q)})),w}}class a extends c{constructor(w){super(w,{isRenderable:w.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const w=this.annotationStorage,x=this.data.id,q=w.getValue(x,{value:this.data.fieldValue}),Dt=document.createElement("select");P.add(Dt),Dt.setAttribute("data-element-id",x),Dt.disabled=this.data.readOnly,this._setRequired(Dt,this.data.required),Dt.name=this.data.fieldName,Dt.tabIndex=k;let Ot=this.data.combo&&this.data.options.length>0;this.data.combo||(Dt.size=this.data.options.length,this.data.multiSelect&&(Dt.multiple=!0)),Dt.addEventListener("resetform",Zt=>{const he=this.data.defaultFieldValue;for(const ie of Dt.options)ie.selected=ie.value===he});for(const Zt of this.data.options){const he=document.createElement("option");he.textContent=Zt.displayValue,he.value=Zt.exportValue,q.value.includes(Zt.exportValue)&&(he.setAttribute("selected",!0),Ot=!1),Dt.append(he)}let Ht=null;if(Ot){const Zt=document.createElement("option");Zt.value=" ",Zt.setAttribute("hidden",!0),Zt.setAttribute("selected",!0),Dt.prepend(Zt),Ht=()=>{Zt.remove(),Dt.removeEventListener("input",Ht),Ht=null},Dt.addEventListener("input",Ht)}const Yt=Zt=>{const he=Zt?"value":"textContent",{options:ie,multiple:ae}=Dt;return ae?Array.prototype.filter.call(ie,le=>le.selected).map(le=>le[he]):ie.selectedIndex===-1?null:ie[ie.selectedIndex][he]};let ee=Yt(!1);const se=Zt=>{const he=Zt.target.options;return Array.prototype.map.call(he,ie=>({displayValue:ie.textContent,exportValue:ie.value}))};return this.enableScripting&&this.hasJSActions?(Dt.addEventListener("updatefromsandbox",Zt=>{const he={value(ie){Ht==null||Ht();const ae=ie.detail.value,le=new Set(Array.isArray(ae)?ae:[ae]);for(const fe of Dt.options)fe.selected=le.has(fe.value);w.setValue(x,{value:Yt(!0)}),ee=Yt(!1)},multipleSelection(ie){Dt.multiple=!0},remove(ie){const ae=Dt.options,le=ie.detail.remove;ae[le].selected=!1,Dt.remove(le),ae.length>0&&Array.prototype.findIndex.call(ae,ve=>ve.selected)===-1&&(ae[0].selected=!0),w.setValue(x,{value:Yt(!0),items:se(ie)}),ee=Yt(!1)},clear(ie){for(;Dt.length!==0;)Dt.remove(0);w.setValue(x,{value:null,items:[]}),ee=Yt(!1)},insert(ie){const{index:ae,displayValue:le,exportValue:fe}=ie.detail.insert,ve=Dt.children[ae],Ce=document.createElement("option");Ce.textContent=le,Ce.value=fe,ve?ve.before(Ce):Dt.append(Ce),w.setValue(x,{value:Yt(!0),items:se(ie)}),ee=Yt(!1)},items(ie){const{items:ae}=ie.detail;for(;Dt.length!==0;)Dt.remove(0);for(const le of ae){const{displayValue:fe,exportValue:ve}=le,Ce=document.createElement("option");Ce.textContent=fe,Ce.value=ve,Dt.append(Ce)}Dt.options.length>0&&(Dt.options[0].selected=!0),w.setValue(x,{value:Yt(!0),items:se(ie)}),ee=Yt(!1)},indices(ie){const ae=new Set(ie.detail.indices);for(const le of ie.target.options)le.selected=ae.has(le.index);w.setValue(x,{value:Yt(!0)}),ee=Yt(!1)},editable(ie){ie.target.disabled=!ie.detail.editable}};this._dispatchEventFromSandbox(he,Zt)}),Dt.addEventListener("input",Zt=>{var ie;const he=Yt(!0);w.setValue(x,{value:he}),Zt.preventDefault(),(ie=this.linkService.eventBus)==null||ie.dispatch("dispatcheventinsandbox",{source:this,detail:{id:x,name:"Keystroke",value:ee,changeEx:he,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(Dt,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],Zt=>Zt.target.value)):Dt.addEventListener("input",function(Zt){w.setValue(x,{value:Yt(!0)})}),this.data.combo&&this._setTextStyle(Dt),this._setBackgroundColor(Dt),this._setDefaultPropertiesFromJS(Dt),this.container.append(Dt),this.container}}class l extends g{constructor(w){const{data:x,elements:q}=w;super(w,{isRenderable:g._hasPopupData(x)}),this.elements=q}render(){this.container.classList.add("popupAnnotation");const w=new u({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),x=[];for(const q of this.elements)q.popup=w,x.push(q.data.id),q.addHighlightArea();return this.container.setAttribute("aria-controls",x.map(q=>`${i.AnnotationPrefix}${q}`).join(",")),this.container}}class u{constructor({container:w,color:x,elements:q,titleObj:Dt,modificationDate:Ot,contentsObj:Ht,richText:Yt,parent:ee,rect:se,parentRect:Zt,open:he}){Tt(this,Kt);Tt(this,At,null);Tt(this,It,K(this,Kt,Is).bind(this));Tt(this,Bt,K(this,Kt,rs).bind(this));Tt(this,jt,K(this,Kt,is).bind(this));Tt(this,Ut,K(this,Kt,kn).bind(this));Tt(this,Xt,null);Tt(this,vt,null);Tt(this,kt,null);Tt(this,v,null);Tt(this,N,null);Tt(this,Z,null);Tt(this,St,!1);Tt(this,Nt,null);Tt(this,zt,null);Tt(this,qt,null);Tt(this,bt,null);Tt(this,Jt,!1);var ae;Rt(this,vt,w),Rt(this,bt,Dt),Rt(this,kt,Ht),Rt(this,qt,Yt),Rt(this,N,ee),Rt(this,Xt,x),Rt(this,zt,se),Rt(this,Z,Zt),Rt(this,v,q);const ie=y.PDFDateString.toDateObject(Ot);ie&&Rt(this,At,ee.l10n.get("annotation_date_string",{date:ie.toLocaleDateString(),time:ie.toLocaleTimeString()})),this.trigger=q.flatMap(le=>le.getElementsToTriggerPopup());for(const le of this.trigger)le.addEventListener("click",t(this,Ut)),le.addEventListener("mouseenter",t(this,jt)),le.addEventListener("mouseleave",t(this,Bt)),le.classList.add("popupTriggerArea");for(const le of q)(ae=le.container)==null||ae.addEventListener("keydown",t(this,It));t(this,vt).hidden=!0,he&&K(this,Kt,kn).call(this)}render(){if(t(this,Nt))return;const{page:{view:w},viewport:{rawDims:{pageWidth:x,pageHeight:q,pageX:Dt,pageY:Ot}}}=t(this,N),Ht=Rt(this,Nt,document.createElement("div"));if(Ht.className="popup",t(this,Xt)){const we=Ht.style.outlineColor=i.Util.makeHexColor(...t(this,Xt));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?Ht.style.backgroundColor=`color-mix(in srgb, ${we} 30%, white)`:Ht.style.backgroundColor=i.Util.makeHexColor(...t(this,Xt).map(rn=>Math.floor(.7*(255-rn)+rn)))}const Yt=document.createElement("span");Yt.className="header";const ee=document.createElement("h1");if(Yt.append(ee),{dir:ee.dir,str:ee.textContent}=t(this,bt),Ht.append(Yt),t(this,At)){const we=document.createElement("span");we.classList.add("popupDate"),t(this,At).then(nn=>{we.textContent=nn}),Yt.append(we)}const se=t(this,kt),Zt=t(this,qt);if(Zt!=null&&Zt.str&&(!(se!=null&&se.str)||se.str===Zt.str))B.XfaLayer.render({xfaHtml:Zt.html,intent:"richText",div:Ht}),Ht.lastChild.classList.add("richText","popupContent");else{const we=this._formatContents(se);Ht.append(we)}let he=!!t(this,Z),ie=he?t(this,Z):t(this,zt);for(const we of t(this,v))if(!ie||i.Util.intersect(we.data.rect,ie)!==null){ie=we.data.rect,he=!0;break}const ae=i.Util.normalizeRect([ie[0],w[3]-ie[1]+w[1],ie[2],w[3]-ie[3]+w[1]]),fe=he?ie[2]-ie[0]+5:0,ve=ae[0]+fe,Ce=ae[1],{style:tn}=t(this,vt);tn.left=`${100*(ve-Dt)/x}%`,tn.top=`${100*(Ce-Ot)/q}%`,t(this,vt).append(Ht)}_formatContents({str:w,dir:x}){const q=document.createElement("p");q.classList.add("popupContent"),q.dir=x;const Dt=w.split(/(?:\r\n?|\n)/);for(let Ot=0,Ht=Dt.length;Ot<Ht;++Ot){const Yt=Dt[Ot];q.append(document.createTextNode(Yt)),Ot<Ht-1&&q.append(document.createElement("br"))}return q}forceHide(){Rt(this,Jt,this.isVisible),t(this,Jt)&&(t(this,vt).hidden=!0)}maybeShow(){t(this,Jt)&&(Rt(this,Jt,!1),t(this,vt).hidden=!1)}get isVisible(){return t(this,vt).hidden===!1}}At=new WeakMap,It=new WeakMap,Bt=new WeakMap,jt=new WeakMap,Ut=new WeakMap,Xt=new WeakMap,vt=new WeakMap,kt=new WeakMap,v=new WeakMap,N=new WeakMap,Z=new WeakMap,St=new WeakMap,Nt=new WeakMap,zt=new WeakMap,qt=new WeakMap,bt=new WeakMap,Jt=new WeakMap,Kt=new WeakSet,Is=function(w){w.altKey||w.shiftKey||w.ctrlKey||w.metaKey||(w.key==="Enter"||w.key==="Escape"&&t(this,St))&&K(this,Kt,kn).call(this)},kn=function(){Rt(this,St,!t(this,St)),t(this,St)?(K(this,Kt,is).call(this),t(this,vt).addEventListener("click",t(this,Ut)),t(this,vt).addEventListener("keydown",t(this,It))):(K(this,Kt,rs).call(this),t(this,vt).removeEventListener("click",t(this,Ut)),t(this,vt).removeEventListener("keydown",t(this,It)))},is=function(){t(this,Nt)||this.render(),this.isVisible?t(this,St)&&t(this,vt).classList.add("focused"):(t(this,vt).hidden=!1,t(this,vt).style.zIndex=parseInt(t(this,vt).style.zIndex)+1e3)},rs=function(){t(this,vt).classList.remove("focused"),!(t(this,St)||!this.isVisible)&&(t(this,vt).hidden=!0,t(this,vt).style.zIndex=parseInt(t(this,vt).style.zIndex)-1e3)};class R extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0}),this.textContent=w.data.textContent,this.textPosition=w.data.textPosition,this.annotationEditorType=i.AnnotationEditorType.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const w=document.createElement("div");w.classList.add("annotationTextContent"),w.setAttribute("role","comment");for(const x of this.textContent){const q=document.createElement("span");q.textContent=x,w.append(q)}this.container.append(w)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}e.FreeTextAnnotationElement=R;class o extends g{constructor(x){super(x,{isRenderable:!0,ignoreBorder:!0});Tt(this,re,null)}render(){this.container.classList.add("lineAnnotation");const x=this.data,{width:q,height:Dt}=T(x.rect),Ot=this.svgFactory.create(q,Dt,!0),Ht=Rt(this,re,this.svgFactory.createElement("svg:line"));return Ht.setAttribute("x1",x.rect[2]-x.lineCoordinates[0]),Ht.setAttribute("y1",x.rect[3]-x.lineCoordinates[1]),Ht.setAttribute("x2",x.rect[2]-x.lineCoordinates[2]),Ht.setAttribute("y2",x.rect[3]-x.lineCoordinates[3]),Ht.setAttribute("stroke-width",x.borderStyle.width||1),Ht.setAttribute("stroke","transparent"),Ht.setAttribute("fill","transparent"),Ot.append(Ht),this.container.append(Ot),!x.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,re)}addHighlightArea(){this.container.classList.add("highlightArea")}}re=new WeakMap;class F extends g{constructor(x){super(x,{isRenderable:!0,ignoreBorder:!0});Tt(this,pe,null)}render(){this.container.classList.add("squareAnnotation");const x=this.data,{width:q,height:Dt}=T(x.rect),Ot=this.svgFactory.create(q,Dt,!0),Ht=x.borderStyle.width,Yt=Rt(this,pe,this.svgFactory.createElement("svg:rect"));return Yt.setAttribute("x",Ht/2),Yt.setAttribute("y",Ht/2),Yt.setAttribute("width",q-Ht),Yt.setAttribute("height",Dt-Ht),Yt.setAttribute("stroke-width",Ht||1),Yt.setAttribute("stroke","transparent"),Yt.setAttribute("fill","transparent"),Ot.append(Yt),this.container.append(Ot),!x.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,pe)}addHighlightArea(){this.container.classList.add("highlightArea")}}pe=new WeakMap;class $ extends g{constructor(x){super(x,{isRenderable:!0,ignoreBorder:!0});Tt(this,Ee,null)}render(){this.container.classList.add("circleAnnotation");const x=this.data,{width:q,height:Dt}=T(x.rect),Ot=this.svgFactory.create(q,Dt,!0),Ht=x.borderStyle.width,Yt=Rt(this,Ee,this.svgFactory.createElement("svg:ellipse"));return Yt.setAttribute("cx",q/2),Yt.setAttribute("cy",Dt/2),Yt.setAttribute("rx",q/2-Ht/2),Yt.setAttribute("ry",Dt/2-Ht/2),Yt.setAttribute("stroke-width",Ht||1),Yt.setAttribute("stroke","transparent"),Yt.setAttribute("fill","transparent"),Ot.append(Yt),this.container.append(Ot),!x.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,Ee)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ee=new WeakMap;class wt extends g{constructor(x){super(x,{isRenderable:!0,ignoreBorder:!0});Tt(this,Gt,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const x=this.data,{width:q,height:Dt}=T(x.rect),Ot=this.svgFactory.create(q,Dt,!0);let Ht=[];for(const ee of x.vertices){const se=ee.x-x.rect[0],Zt=x.rect[3]-ee.y;Ht.push(se+","+Zt)}Ht=Ht.join(" ");const Yt=Rt(this,Gt,this.svgFactory.createElement(this.svgElementName));return Yt.setAttribute("points",Ht),Yt.setAttribute("stroke-width",x.borderStyle.width||1),Yt.setAttribute("stroke","transparent"),Yt.setAttribute("fill","transparent"),Ot.append(Yt),this.container.append(Ot),!x.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,Gt)}addHighlightArea(){this.container.classList.add("highlightArea")}}Gt=new WeakMap;class U extends wt{constructor(w){super(w),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class G extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class H extends g{constructor(x){super(x,{isRenderable:!0,ignoreBorder:!0});Tt(this,Pt,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=i.AnnotationEditorType.INK}render(){this.container.classList.add(this.containerClassName);const x=this.data,{width:q,height:Dt}=T(x.rect),Ot=this.svgFactory.create(q,Dt,!0);for(const Ht of x.inkLists){let Yt=[];for(const se of Ht){const Zt=se.x-x.rect[0],he=x.rect[3]-se.y;Yt.push(`${Zt},${he}`)}Yt=Yt.join(" ");const ee=this.svgFactory.createElement(this.svgElementName);t(this,Pt).push(ee),ee.setAttribute("points",Yt),ee.setAttribute("stroke-width",x.borderStyle.width||1),ee.setAttribute("stroke","transparent"),ee.setAttribute("fill","transparent"),!x.popupRef&&this.hasPopupData&&this._createPopup(),Ot.append(ee)}return this.container.append(Ot),this.container}getElementsToTriggerPopup(){return t(this,Pt)}addHighlightArea(){this.container.classList.add("highlightArea")}}Pt=new WeakMap,e.InkAnnotationElement=H;class _t extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class D extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class W extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class J extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class S extends g{constructor(w){super(w,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}e.StampAnnotationElement=S;class n extends g{constructor(x){var Ot;super(x,{isRenderable:!0});Tt(this,te);Tt(this,Mt,null);const{filename:q,content:Dt}=this.data.file;this.filename=(0,y.getFilenameFromUrl)(q,!0),this.content=Dt,(Ot=this.linkService.eventBus)==null||Ot.dispatch("fileattachmentannotation",{source:this,filename:q,content:Dt})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:x,data:q}=this;let Dt;q.hasAppearance||q.fillAlpha===0?Dt=document.createElement("div"):(Dt=document.createElement("img"),Dt.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(q.name)?"paperclip":"pushpin"}.svg`,q.fillAlpha&&q.fillAlpha<1&&(Dt.style=`filter: opacity(${Math.round(q.fillAlpha*100)}%);`)),Dt.addEventListener("dblclick",K(this,te,as).bind(this)),Rt(this,Mt,Dt);const{isMac:Ot}=i.FeatureTest.platform;return x.addEventListener("keydown",Ht=>{Ht.key==="Enter"&&(Ot?Ht.metaKey:Ht.ctrlKey)&&K(this,te,as).call(this)}),!q.popupRef&&this.hasPopupData?this._createPopup():Dt.classList.add("popupTriggerArea"),x.append(Dt),x}getElementsToTriggerPopup(){return t(this,Mt)}addHighlightArea(){this.container.classList.add("highlightArea")}}Mt=new WeakMap,te=new WeakSet,as=function(){var x;(x=this.downloadManager)==null||x.openOrDownloadData(this.container,this.content,this.filename)};class s{constructor({div:w,accessibilityManager:x,annotationCanvasMap:q,l10n:Dt,page:Ot,viewport:Ht}){Tt(this,Y);Tt(this,de,null);Tt(this,j,null);Tt(this,$t,new Map);this.div=w,Rt(this,de,x),Rt(this,j,q),this.l10n=Dt,this.page=Ot,this.viewport=Ht,this.zIndex=0,this.l10n||(this.l10n=xt.NullL10n)}async render(w){const{annotations:x}=w,q=this.div;(0,y.setLayerDimensions)(q,this.viewport);const Dt=new Map,Ot={data:null,layer:q,linkService:w.linkService,downloadManager:w.downloadManager,imageResourcesPath:w.imageResourcesPath||"",renderForms:w.renderForms!==!1,svgFactory:new y.DOMSVGFactory,annotationStorage:w.annotationStorage||new Q.AnnotationStorage,enableScripting:w.enableScripting===!0,hasJSActions:w.hasJSActions,fieldObjects:w.fieldObjects,parent:this,elements:null};for(const Ht of x){if(Ht.noHTML)continue;const Yt=Ht.annotationType===i.AnnotationType.POPUP;if(Yt){const Zt=Dt.get(Ht.id);if(!Zt)continue;Ot.elements=Zt}else{const{width:Zt,height:he}=T(Ht.rect);if(Zt<=0||he<=0)continue}Ot.data=Ht;const ee=A.create(Ot);if(!ee.isRenderable)continue;if(!Yt&&Ht.popupRef){const Zt=Dt.get(Ht.popupRef);Zt?Zt.push(ee):Dt.set(Ht.popupRef,[ee])}ee.annotationEditorType>0&&t(this,$t).set(ee.data.id,ee);const se=ee.render();Ht.hidden&&(se.style.visibility="hidden"),K(this,Y,Ls).call(this,se,Ht.id)}K(this,Y,os).call(this),await this.l10n.translate(q)}update({viewport:w}){const x=this.div;this.viewport=w,(0,y.setLayerDimensions)(x,{rotation:w.rotation}),K(this,Y,os).call(this),x.hidden=!1}getEditableAnnotations(){return Array.from(t(this,$t).values())}getEditableAnnotation(w){return t(this,$t).get(w)}}de=new WeakMap,j=new WeakMap,$t=new WeakMap,Y=new WeakSet,Ls=function(w,x){var Dt;const q=w.firstChild||w;q.id=`${i.AnnotationPrefix}${x}`,this.div.append(w),(Dt=t(this,de))==null||Dt.moveElementInDOM(this.div,w,q,!1)},os=function(){if(!t(this,j))return;const w=this.div;for(const[x,q]of t(this,j)){const Dt=w.querySelector(`[data-annotation-id="${x}"]`);if(!Dt)continue;const{firstChild:Ot}=Dt;Ot?Ot.nodeName==="CANVAS"?Ot.replaceWith(q):Ot.before(q):Dt.append(q)}t(this,j).clear()},e.AnnotationLayer=s}),((d,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ColorConverters=void 0;function b(Q){return Math.floor(Math.max(0,Math.min(1,Q))*255).toString(16).padStart(2,"0")}function i(Q){return Math.max(0,Math.min(255,255*Q))}class y{static CMYK_G([z,xt,B,k]){return["G",1-Math.min(1,.3*z+.59*B+.11*xt+k)]}static G_CMYK([z]){return["CMYK",0,0,0,1-z]}static G_RGB([z]){return["RGB",z,z,z]}static G_rgb([z]){return z=i(z),[z,z,z]}static G_HTML([z]){const xt=b(z);return`#${xt}${xt}${xt}`}static RGB_G([z,xt,B]){return["G",.3*z+.59*xt+.11*B]}static RGB_rgb(z){return z.map(i)}static RGB_HTML(z){return`#${z.map(b).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([z,xt,B,k]){return["RGB",1-Math.min(1,z+k),1-Math.min(1,B+k),1-Math.min(1,xt+k)]}static CMYK_rgb([z,xt,B,k]){return[i(1-Math.min(1,z+k)),i(1-Math.min(1,B+k)),i(1-Math.min(1,xt+k))]}static CMYK_HTML(z){const xt=this.CMYK_RGB(z).slice(1);return this.RGB_HTML(xt)}static RGB_CMYK([z,xt,B]){const k=1-z,f=1-xt,P=1-B,T=Math.min(k,f,P);return["CMYK",k,f,P,T]}}e.ColorConverters=y}),((d,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NullL10n=void 0,e.getL10nFallback=i;const b={of_pages:"of {{pagesCount}}",page_of_pages:"({{pageNumber}} of {{pagesCount}})",document_properties_kb:"{{size_kb}} KB ({{size_b}} bytes)",document_properties_mb:"{{size_mb}} MB ({{size_b}} bytes)",document_properties_date_string:"{{date}}, {{time}}",document_properties_page_size_unit_inches:"in",document_properties_page_size_unit_millimeters:"mm",document_properties_page_size_orientation_portrait:"portrait",document_properties_page_size_orientation_landscape:"landscape",document_properties_page_size_name_a3:"A3",document_properties_page_size_name_a4:"A4",document_properties_page_size_name_letter:"Letter",document_properties_page_size_name_legal:"Legal",document_properties_page_size_dimension_string:"{{width}} \xD7 {{height}} {{unit}} ({{orientation}})",document_properties_page_size_dimension_name_string:"{{width}} \xD7 {{height}} {{unit}} ({{name}}, {{orientation}})",document_properties_linearized_yes:"Yes",document_properties_linearized_no:"No",additional_layers:"Additional Layers",page_landmark:"Page {{page}}",thumb_page_title:"Page {{page}}",thumb_page_canvas:"Thumbnail of Page {{page}}",find_reached_top:"Reached top of document, continued from bottom",find_reached_bottom:"Reached end of document, continued from top","find_match_count[one]":"{{current}} of {{total}} match","find_match_count[other]":"{{current}} of {{total}} matches","find_match_count_limit[one]":"More than {{limit}} match","find_match_count_limit[other]":"More than {{limit}} matches",find_not_found:"Phrase not found",page_scale_width:"Page Width",page_scale_fit:"Page Fit",page_scale_auto:"Automatic Zoom",page_scale_actual:"Actual Size",page_scale_percent:"{{scale}}%",loading_error:"An error occurred while loading the PDF.",invalid_file_error:"Invalid or corrupted PDF file.",missing_file_error:"Missing PDF file.",unexpected_response_error:"Unexpected server response.",rendering_error:"An error occurred while rendering the page.",annotation_date_string:"{{date}}, {{time}}",printing_not_supported:"Warning: Printing is not fully supported by this browser.",printing_not_ready:"Warning: The PDF is not fully loaded for printing.",web_fonts_disabled:"Web fonts are disabled: unable to use embedded PDF fonts.",free_text2_default_content:"Start typing\u2026",editor_free_text2_aria_label:"Text Editor",editor_ink2_aria_label:"Draw Editor",editor_ink_canvas_aria_label:"User-created image",editor_alt_text_button_label:"Alt text",editor_alt_text_edit_button_label:"Edit alt text",editor_alt_text_decorative_tooltip:"Marked as decorative"};b.print_progress_percent="{{progress}}%";function i(z,xt){switch(z){case"find_match_count":z=`find_match_count[${xt.total===1?"one":"other"}]`;break;case"find_match_count_limit":z=`find_match_count_limit[${xt.limit===1?"one":"other"}]`;break}return b[z]||""}function y(z,xt){return xt?z.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,(B,k)=>k in xt?xt[k]:"{{"+k+"}}"):z}const Q={async getLanguage(){return"en-us"},async getDirection(){return"ltr"},async get(z,xt=null,B=i(z,xt)){return y(B,xt)},async translate(z){}};e.NullL10n=Q}),((d,e,b)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.XfaLayer=void 0;var i=b(25);class y{static setupStorage(z,xt,B,k,f){const P=k.getValue(xt,{value:null});switch(B.name){case"textarea":if(P.value!==null&&(z.textContent=P.value),f==="print")break;z.addEventListener("input",T=>{k.setValue(xt,{value:T.target.value})});break;case"input":if(B.attributes.type==="radio"||B.attributes.type==="checkbox"){if(P.value===B.attributes.xfaOn?z.setAttribute("checked",!0):P.value===B.attributes.xfaOff&&z.removeAttribute("checked"),f==="print")break;z.addEventListener("change",T=>{k.setValue(xt,{value:T.target.checked?T.target.getAttribute("xfaOn"):T.target.getAttribute("xfaOff")})})}else{if(P.value!==null&&z.setAttribute("value",P.value),f==="print")break;z.addEventListener("input",T=>{k.setValue(xt,{value:T.target.value})})}break;case"select":if(P.value!==null){z.setAttribute("value",P.value);for(const T of B.children)T.attributes.value===P.value?T.attributes.selected=!0:T.attributes.hasOwnProperty("selected")&&delete T.attributes.selected}z.addEventListener("input",T=>{const A=T.target.options,g=A.selectedIndex===-1?"":A[A.selectedIndex].value;k.setValue(xt,{value:g})});break}}static setAttributes({html:z,element:xt,storage:B=null,intent:k,linkService:f}){const{attributes:P}=xt,T=z instanceof HTMLAnchorElement;P.type==="radio"&&(P.name=`${P.name}-${k}`);for(const[A,g]of Object.entries(P))if(g!=null)switch(A){case"class":g.length&&z.setAttribute(A,g.join(" "));break;case"dataId":break;case"id":z.setAttribute("data-element-id",g);break;case"style":Object.assign(z.style,g);break;case"textContent":z.textContent=g;break;default:(!T||A!=="href"&&A!=="newWindow")&&z.setAttribute(A,g)}T&&f.addLinkAttributes(z,P.href,P.newWindow),B&&P.dataId&&this.setupStorage(z,P.dataId,xt,B)}static render(z){var E;const xt=z.annotationStorage,B=z.linkService,k=z.xfaHtml,f=z.intent||"display",P=document.createElement(k.name);k.attributes&&this.setAttributes({html:P,element:k,intent:f,linkService:B});const T=[[k,-1,P]],A=z.div;if(A.append(P),z.viewport){const _=`matrix(${z.viewport.transform.join(",")})`;A.style.transform=_}f!=="richText"&&A.setAttribute("class","xfaLayer xfaFont");const g=[];for(;T.length>0;){const[_,c,C]=T.at(-1);if(c+1===_.children.length){T.pop();continue}const I=_.children[++T.at(-1)[1]];if(I===null)continue;const{name:m}=I;if(m==="#text"){const h=document.createTextNode(I.value);g.push(h),C.append(h);continue}const r=(E=I==null?void 0:I.attributes)!=null&&E.xmlns?document.createElementNS(I.attributes.xmlns,m):document.createElement(m);if(C.append(r),I.attributes&&this.setAttributes({html:r,element:I,storage:xt,intent:f,linkService:B}),I.children&&I.children.length>0)T.push([I,-1,r]);else if(I.value){const h=document.createTextNode(I.value);i.XfaText.shouldBuildText(m)&&g.push(h),r.append(h)}}for(const _ of A.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))_.setAttribute("readOnly",!0);return{textDivs:g}}static update(z){const xt=`matrix(${z.viewport.transform.join(",")})`;z.div.style.transform=xt,z.div.hidden=!1}}e.XfaLayer=y}),((d,e,b)=>{var k,f,P,T,A,g,E,_,c,C,I,m,r,h,a,Os,Bs,Ns,$s,ls,js,cs,Us,Hs,Ws,zs,Xs,sn,us,Dn,Pn,hn,hs,Tn,O,Gs,ds,qs,Vs,fs,Rn,dn;Object.defineProperty(e,"__esModule",{value:!0}),e.InkEditor=void 0;var i=b(1),y=b(4),Q=b(29),z=b(6),xt=b(5);const Xt=class Xt extends y.AnnotationEditor{constructor(v){super({...v,name:"inkEditor"});Tt(this,a);Tt(this,k,0);Tt(this,f,0);Tt(this,P,this.canvasPointermove.bind(this));Tt(this,T,this.canvasPointerleave.bind(this));Tt(this,A,this.canvasPointerup.bind(this));Tt(this,g,this.canvasPointerdown.bind(this));Tt(this,E,new Path2D);Tt(this,_,!1);Tt(this,c,!1);Tt(this,C,!1);Tt(this,I,null);Tt(this,m,0);Tt(this,r,0);Tt(this,h,null);this.color=v.color||null,this.thickness=v.thickness||null,this.opacity=v.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(v){y.AnnotationEditor.initialize(v,{strings:["editor_ink_canvas_aria_label","editor_ink2_aria_label"]})}static updateDefaultParams(v,N){switch(v){case i.AnnotationEditorParamsType.INK_THICKNESS:Xt._defaultThickness=N;break;case i.AnnotationEditorParamsType.INK_COLOR:Xt._defaultColor=N;break;case i.AnnotationEditorParamsType.INK_OPACITY:Xt._defaultOpacity=N/100;break}}updateParams(v,N){switch(v){case i.AnnotationEditorParamsType.INK_THICKNESS:K(this,a,Os).call(this,N);break;case i.AnnotationEditorParamsType.INK_COLOR:K(this,a,Bs).call(this,N);break;case i.AnnotationEditorParamsType.INK_OPACITY:K(this,a,Ns).call(this,N);break}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.INK_THICKNESS,Xt._defaultThickness],[i.AnnotationEditorParamsType.INK_COLOR,Xt._defaultColor||y.AnnotationEditor._defaultLineColor],[i.AnnotationEditorParamsType.INK_OPACITY,Math.round(Xt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||Xt._defaultThickness],[i.AnnotationEditorParamsType.INK_COLOR,this.color||Xt._defaultColor||y.AnnotationEditor._defaultLineColor],[i.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??Xt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(K(this,a,Dn).call(this),K(this,a,Pn).call(this)),this.isAttachedToDOM||(this.parent.add(this),K(this,a,hn).call(this)),K(this,a,dn).call(this)))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,t(this,I).disconnect(),Rt(this,I,null),super.remove())}setParent(v){!this.parent&&v?this._uiManager.removeShouldRescale(this):this.parent&&v===null&&this._uiManager.addShouldRescale(this),super.setParent(v)}onScaleChanging(){const[v,N]=this.parentDimensions,Z=this.width*v,St=this.height*N;this.setDimensions(Z,St)}enableEditMode(){t(this,_)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",t(this,g)))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",t(this,g)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){t(this,_)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),Rt(this,_,!0),this.div.classList.add("disabled"),K(this,a,dn).call(this,!0),this.makeResizable(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(v){this._focusEventsAllowed&&(super.focusin(v),this.enableEditMode())}canvasPointerdown(v){v.button!==0||!this.isInEditMode()||t(this,_)||(this.setInForeground(),v.preventDefault(),v.type!=="mouse"&&this.div.focus(),K(this,a,js).call(this,v.offsetX,v.offsetY))}canvasPointermove(v){v.preventDefault(),K(this,a,cs).call(this,v.offsetX,v.offsetY)}canvasPointerup(v){v.preventDefault(),K(this,a,us).call(this,v)}canvasPointerleave(v){K(this,a,us).call(this,v)}get isResizable(){return!this.isEmpty()&&t(this,_)}render(){if(this.div)return this.div;let v,N;this.width&&(v=this.x,N=this.y),super.render(),y.AnnotationEditor._l10nPromise.get("editor_ink2_aria_label").then(qt=>{var bt;return(bt=this.div)==null?void 0:bt.setAttribute("aria-label",qt)});const[Z,St,Nt,zt]=K(this,a,$s).call(this);if(this.setAt(Z,St,0,0),this.setDims(Nt,zt),K(this,a,Dn).call(this),this.width){const[qt,bt]=this.parentDimensions;this.setAspectRatio(this.width*qt,this.height*bt),this.setAt(v*qt,N*bt,this.width*qt,this.height*bt),Rt(this,C,!0),K(this,a,hn).call(this),this.setDims(this.width*qt,this.height*bt),K(this,a,sn).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return K(this,a,Pn).call(this),this.div}setDimensions(v,N){const Z=Math.round(v),St=Math.round(N);if(t(this,m)===Z&&t(this,r)===St)return;Rt(this,m,Z),Rt(this,r,St),this.canvas.style.visibility="hidden";const[Nt,zt]=this.parentDimensions;this.width=v/Nt,this.height=N/zt,this.fixAndSetPosition(),t(this,_)&&K(this,a,hs).call(this,v,N),K(this,a,hn).call(this),K(this,a,sn).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(v,N,Z){var re,pe,Ee;if(v instanceof Q.InkAnnotationElement)return null;const St=super.deserialize(v,N,Z);St.thickness=v.thickness,St.color=i.Util.makeHexColor(...v.color),St.opacity=v.opacity;const[Nt,zt]=St.pageDimensions,qt=St.width*Nt,bt=St.height*zt,Jt=St.parentScale,Kt=v.thickness/2;Rt(St,_,!0),Rt(St,m,Math.round(qt)),Rt(St,r,Math.round(bt));const{paths:ce,rect:oe,rotation:me}=v;for(let{bezier:Gt}of ce){Gt=K(re=Xt,O,qs).call(re,Gt,oe,me);const Pt=[];St.paths.push(Pt);let Mt=Jt*(Gt[0]-Kt),te=Jt*(Gt[1]-Kt);for(let de=2,j=Gt.length;de<j;de+=6){const $t=Jt*(Gt[de]-Kt),Y=Jt*(Gt[de+1]-Kt),Lt=Jt*(Gt[de+2]-Kt),Vt=Jt*(Gt[de+3]-Kt),Wt=Jt*(Gt[de+4]-Kt),w=Jt*(Gt[de+5]-Kt);Pt.push([[Mt,te],[$t,Y],[Lt,Vt],[Wt,w]]),Mt=Wt,te=w}const ge=K(this,O,Gs).call(this,Pt);St.bezierPath2D.push(ge)}const Qt=K(pe=St,a,fs).call(pe);return Rt(St,f,Math.max(y.AnnotationEditor.MIN_SIZE,Qt[2]-Qt[0])),Rt(St,k,Math.max(y.AnnotationEditor.MIN_SIZE,Qt[3]-Qt[1])),K(Ee=St,a,hs).call(Ee,qt,bt),St}serialize(){if(this.isEmpty())return null;const v=this.getRect(0,0),N=y.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:i.AnnotationEditorType.INK,color:N,thickness:this.thickness,opacity:this.opacity,paths:K(this,a,Vs).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,v),pageIndex:this.pageIndex,rect:v,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};k=new WeakMap,f=new WeakMap,P=new WeakMap,T=new WeakMap,A=new WeakMap,g=new WeakMap,E=new WeakMap,_=new WeakMap,c=new WeakMap,C=new WeakMap,I=new WeakMap,m=new WeakMap,r=new WeakMap,h=new WeakMap,a=new WeakSet,Os=function(v){const N=this.thickness;this.addCommands({cmd:()=>{this.thickness=v,K(this,a,dn).call(this)},undo:()=>{this.thickness=N,K(this,a,dn).call(this)},mustExec:!0,type:i.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},Bs=function(v){const N=this.color;this.addCommands({cmd:()=>{this.color=v,K(this,a,sn).call(this)},undo:()=>{this.color=N,K(this,a,sn).call(this)},mustExec:!0,type:i.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Ns=function(v){v/=100;const N=this.opacity;this.addCommands({cmd:()=>{this.opacity=v,K(this,a,sn).call(this)},undo:()=>{this.opacity=N,K(this,a,sn).call(this)},mustExec:!0,type:i.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},$s=function(){const{parentRotation:v,parentDimensions:[N,Z]}=this;switch(v){case 90:return[0,Z,Z,N];case 180:return[N,Z,N,Z];case 270:return[N,0,Z,N];default:return[0,0,N,Z]}},ls=function(){const{ctx:v,color:N,opacity:Z,thickness:St,parentScale:Nt,scaleFactor:zt}=this;v.lineWidth=St*Nt/zt,v.lineCap="round",v.lineJoin="round",v.miterLimit=10,v.strokeStyle=`${N}${(0,xt.opacityToHex)(Z)}`},js=function(v,N){this.canvas.addEventListener("contextmenu",z.noContextMenu),this.canvas.addEventListener("pointerleave",t(this,T)),this.canvas.addEventListener("pointermove",t(this,P)),this.canvas.addEventListener("pointerup",t(this,A)),this.canvas.removeEventListener("pointerdown",t(this,g)),this.isEditing=!0,t(this,C)||(Rt(this,C,!0),K(this,a,hn).call(this),this.thickness||(this.thickness=Xt._defaultThickness),this.color||(this.color=Xt._defaultColor||y.AnnotationEditor._defaultLineColor),this.opacity??(this.opacity=Xt._defaultOpacity)),this.currentPath.push([v,N]),Rt(this,c,!1),K(this,a,ls).call(this),Rt(this,h,()=>{K(this,a,Ws).call(this),t(this,h)&&window.requestAnimationFrame(t(this,h))}),window.requestAnimationFrame(t(this,h))},cs=function(v,N){const[Z,St]=this.currentPath.at(-1);if(this.currentPath.length>1&&v===Z&&N===St)return;const Nt=this.currentPath;let zt=t(this,E);if(Nt.push([v,N]),Rt(this,c,!0),Nt.length<=2){zt.moveTo(...Nt[0]),zt.lineTo(v,N);return}Nt.length===3&&(Rt(this,E,zt=new Path2D),zt.moveTo(...Nt[0])),K(this,a,zs).call(this,zt,...Nt.at(-3),...Nt.at(-2),v,N)},Us=function(){if(this.currentPath.length===0)return;const v=this.currentPath.at(-1);t(this,E).lineTo(...v)},Hs=function(v,N){Rt(this,h,null),v=Math.min(Math.max(v,0),this.canvas.width),N=Math.min(Math.max(N,0),this.canvas.height),K(this,a,cs).call(this,v,N),K(this,a,Us).call(this);let Z;if(this.currentPath.length!==1)Z=K(this,a,Xs).call(this);else{const bt=[v,N];Z=[[bt,bt.slice(),bt.slice(),bt]]}const St=t(this,E),Nt=this.currentPath;this.currentPath=[],Rt(this,E,new Path2D);const zt=()=>{this.allRawPaths.push(Nt),this.paths.push(Z),this.bezierPath2D.push(St),this.rebuild()},qt=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(K(this,a,Dn).call(this),K(this,a,Pn).call(this)),K(this,a,dn).call(this))};this.addCommands({cmd:zt,undo:qt,mustExec:!0})},Ws=function(){if(!t(this,c))return;Rt(this,c,!1);const v=Math.ceil(this.thickness*this.parentScale),N=this.currentPath.slice(-3),Z=N.map(zt=>zt[0]),St=N.map(zt=>zt[1]);Math.min(...Z)-v,Math.max(...Z)+v,Math.min(...St)-v,Math.max(...St)+v;const{ctx:Nt}=this;Nt.save(),Nt.clearRect(0,0,this.canvas.width,this.canvas.height);for(const zt of this.bezierPath2D)Nt.stroke(zt);Nt.stroke(t(this,E)),Nt.restore()},zs=function(v,N,Z,St,Nt,zt,qt){const bt=(N+St)/2,Jt=(Z+Nt)/2,Kt=(St+zt)/2,ce=(Nt+qt)/2;v.bezierCurveTo(bt+2*(St-bt)/3,Jt+2*(Nt-Jt)/3,Kt+2*(St-Kt)/3,ce+2*(Nt-ce)/3,Kt,ce)},Xs=function(){const v=this.currentPath;if(v.length<=2)return[[v[0],v[0],v.at(-1),v.at(-1)]];const N=[];let Z,[St,Nt]=v[0];for(Z=1;Z<v.length-2;Z++){const[oe,me]=v[Z],[Qt,re]=v[Z+1],pe=(oe+Qt)/2,Ee=(me+re)/2,Gt=[St+2*(oe-St)/3,Nt+2*(me-Nt)/3],Pt=[pe+2*(oe-pe)/3,Ee+2*(me-Ee)/3];N.push([[St,Nt],Gt,Pt,[pe,Ee]]),[St,Nt]=[pe,Ee]}const[zt,qt]=v[Z],[bt,Jt]=v[Z+1],Kt=[St+2*(zt-St)/3,Nt+2*(qt-Nt)/3],ce=[bt+2*(zt-bt)/3,Jt+2*(qt-Jt)/3];return N.push([[St,Nt],Kt,ce,[bt,Jt]]),N},sn=function(){if(this.isEmpty()){K(this,a,Tn).call(this);return}K(this,a,ls).call(this);const{canvas:v,ctx:N}=this;N.setTransform(1,0,0,1,0,0),N.clearRect(0,0,v.width,v.height),K(this,a,Tn).call(this);for(const Z of this.bezierPath2D)N.stroke(Z)},us=function(v){this.canvas.removeEventListener("pointerleave",t(this,T)),this.canvas.removeEventListener("pointermove",t(this,P)),this.canvas.removeEventListener("pointerup",t(this,A)),this.canvas.addEventListener("pointerdown",t(this,g)),setTimeout(()=>{this.canvas.removeEventListener("contextmenu",z.noContextMenu)},10),K(this,a,Hs).call(this,v.offsetX,v.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Dn=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",y.AnnotationEditor._l10nPromise.get("editor_ink_canvas_aria_label").then(v=>{var N;return(N=this.canvas)==null?void 0:N.setAttribute("aria-label",v)}),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Pn=function(){Rt(this,I,new ResizeObserver(v=>{const N=v[0].contentRect;N.width&&N.height&&this.setDimensions(N.width,N.height)})),t(this,I).observe(this.div)},hn=function(){if(!t(this,C))return;const[v,N]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*v),this.canvas.height=Math.ceil(this.height*N),K(this,a,Tn).call(this)},hs=function(v,N){const Z=K(this,a,Rn).call(this),St=(v-Z)/t(this,f),Nt=(N-Z)/t(this,k);this.scaleFactor=Math.min(St,Nt)},Tn=function(){const v=K(this,a,Rn).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+v,this.translationY*this.scaleFactor+v)},O=new WeakSet,Gs=function(v){const N=new Path2D;for(let Z=0,St=v.length;Z<St;Z++){const[Nt,zt,qt,bt]=v[Z];Z===0&&N.moveTo(...Nt),N.bezierCurveTo(zt[0],zt[1],qt[0],qt[1],bt[0],bt[1])}return N},ds=function(v,N,Z){const[St,Nt,zt,qt]=N;switch(Z){case 0:for(let bt=0,Jt=v.length;bt<Jt;bt+=2)v[bt]+=St,v[bt+1]=qt-v[bt+1];break;case 90:for(let bt=0,Jt=v.length;bt<Jt;bt+=2){const Kt=v[bt];v[bt]=v[bt+1]+St,v[bt+1]=Kt+Nt}break;case 180:for(let bt=0,Jt=v.length;bt<Jt;bt+=2)v[bt]=zt-v[bt],v[bt+1]+=Nt;break;case 270:for(let bt=0,Jt=v.length;bt<Jt;bt+=2){const Kt=v[bt];v[bt]=zt-v[bt+1],v[bt+1]=qt-Kt}break;default:throw new Error("Invalid rotation")}return v},qs=function(v,N,Z){const[St,Nt,zt,qt]=N;switch(Z){case 0:for(let bt=0,Jt=v.length;bt<Jt;bt+=2)v[bt]-=St,v[bt+1]=qt-v[bt+1];break;case 90:for(let bt=0,Jt=v.length;bt<Jt;bt+=2){const Kt=v[bt];v[bt]=v[bt+1]-Nt,v[bt+1]=Kt-St}break;case 180:for(let bt=0,Jt=v.length;bt<Jt;bt+=2)v[bt]=zt-v[bt],v[bt+1]-=Nt;break;case 270:for(let bt=0,Jt=v.length;bt<Jt;bt+=2){const Kt=v[bt];v[bt]=qt-v[bt+1],v[bt+1]=zt-Kt}break;default:throw new Error("Invalid rotation")}return v},Vs=function(v,N,Z,St){var Jt,Kt;const Nt=[],zt=this.thickness/2,qt=v*N+zt,bt=v*Z+zt;for(const ce of this.paths){const oe=[],me=[];for(let Qt=0,re=ce.length;Qt<re;Qt++){const[pe,Ee,Gt,Pt]=ce[Qt],Mt=v*pe[0]+qt,te=v*pe[1]+bt,ge=v*Ee[0]+qt,de=v*Ee[1]+bt,j=v*Gt[0]+qt,$t=v*Gt[1]+bt,Y=v*Pt[0]+qt,Lt=v*Pt[1]+bt;Qt===0&&(oe.push(Mt,te),me.push(Mt,te)),oe.push(ge,de,j,$t,Y,Lt),me.push(ge,de),Qt===re-1&&me.push(Y,Lt)}Nt.push({bezier:K(Jt=Xt,O,ds).call(Jt,oe,St,this.rotation),points:K(Kt=Xt,O,ds).call(Kt,me,St,this.rotation)})}return Nt},fs=function(){let v=1/0,N=-1/0,Z=1/0,St=-1/0;for(const Nt of this.paths)for(const[zt,qt,bt,Jt]of Nt){const Kt=i.Util.bezierBoundingBox(...zt,...qt,...bt,...Jt);v=Math.min(v,Kt[0]),Z=Math.min(Z,Kt[1]),N=Math.max(N,Kt[2]),St=Math.max(St,Kt[3])}return[v,Z,N,St]},Rn=function(){return t(this,_)?Math.ceil(this.thickness*this.parentScale):0},dn=function(v=!1){if(this.isEmpty())return;if(!t(this,_)){K(this,a,sn).call(this);return}const N=K(this,a,fs).call(this),Z=K(this,a,Rn).call(this);Rt(this,f,Math.max(y.AnnotationEditor.MIN_SIZE,N[2]-N[0])),Rt(this,k,Math.max(y.AnnotationEditor.MIN_SIZE,N[3]-N[1]));const St=Math.ceil(Z+t(this,f)*this.scaleFactor),Nt=Math.ceil(Z+t(this,k)*this.scaleFactor),[zt,qt]=this.parentDimensions;this.width=St/zt,this.height=Nt/qt,this.setAspectRatio(St,Nt);const bt=this.translationX,Jt=this.translationY;this.translationX=-N[0],this.translationY=-N[1],K(this,a,hn).call(this),K(this,a,sn).call(this),Rt(this,m,St),Rt(this,r,Nt),this.setDims(St,Nt);const Kt=v?Z/this.scaleFactor/2:0;this.translate(bt-this.translationX-Kt,Jt-this.translationY-Kt)},Tt(Xt,O),Fe(Xt,"_defaultColor",null),Fe(Xt,"_defaultOpacity",1),Fe(Xt,"_defaultThickness",1),Fe(Xt,"_type","ink");let B=Xt;e.InkEditor=B}),((d,e,b)=>{var B,k,f,P,T,A,g,E,_,c,C,An,yn,Mn,ps,Ys,Ks,gs,In,Js;Object.defineProperty(e,"__esModule",{value:!0}),e.StampEditor=void 0;var i=b(1),y=b(4),Q=b(6),z=b(29);const F=class F extends y.AnnotationEditor{constructor(U){super({...U,name:"stampEditor"});Tt(this,C);Tt(this,B,null);Tt(this,k,null);Tt(this,f,null);Tt(this,P,null);Tt(this,T,null);Tt(this,A,null);Tt(this,g,null);Tt(this,E,null);Tt(this,_,!1);Tt(this,c,!1);Rt(this,P,U.bitmapUrl),Rt(this,T,U.bitmapFile)}static initialize(U){y.AnnotationEditor.initialize(U)}static get supportedTypes(){const U=["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"];return(0,i.shadow)(this,"supportedTypes",U.map(G=>`image/${G}`))}static get supportedTypesStr(){return(0,i.shadow)(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(U){return this.supportedTypes.includes(U)}static paste(U,G){G.pasteEditor(i.AnnotationEditorType.STAMP,{bitmapFile:U.getAsFile()})}remove(){var U,G;t(this,k)&&(Rt(this,B,null),this._uiManager.imageManager.deleteId(t(this,k)),(U=t(this,A))==null||U.remove(),Rt(this,A,null),(G=t(this,g))==null||G.disconnect(),Rt(this,g,null)),super.remove()}rebuild(){if(!this.parent){t(this,k)&&K(this,C,Mn).call(this);return}super.rebuild(),this.div!==null&&(t(this,k)&&K(this,C,Mn).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(t(this,f)||t(this,B)||t(this,P)||t(this,T))}get isResizable(){return!0}render(){if(this.div)return this.div;let U,G;if(this.width&&(U=this.x,G=this.y),super.render(),this.div.hidden=!0,t(this,B)?K(this,C,ps).call(this):K(this,C,Mn).call(this),this.width){const[H,_t]=this.parentDimensions;this.setAt(U*H,G*_t,this.width*H,this.height*_t)}return this.div}static deserialize(U,G,H){if(U instanceof z.StampAnnotationElement)return null;const _t=super.deserialize(U,G,H),{rect:D,bitmapUrl:W,bitmapId:J,isSvg:S,accessibilityData:n}=U;J&&H.imageManager.isValidId(J)?Rt(_t,k,J):Rt(_t,P,W),Rt(_t,_,S);const[s,p]=_t.pageDimensions;return _t.width=(D[2]-D[0])/s,_t.height=(D[3]-D[1])/p,n&&(_t.altTextData=n),_t}serialize(U=!1,G=null){if(this.isEmpty())return null;const H={annotationType:i.AnnotationEditorType.STAMP,bitmapId:t(this,k),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:t(this,_),structTreeParentId:this._structTreeParentId};if(U)return H.bitmapUrl=K(this,C,In).call(this,!0),H.accessibilityData=this.altTextData,H;const{decorative:_t,altText:D}=this.altTextData;if(!_t&&D&&(H.accessibilityData={type:"Figure",alt:D}),G===null)return H;G.stamps||(G.stamps=new Map);const W=t(this,_)?(H.rect[2]-H.rect[0])*(H.rect[3]-H.rect[1]):null;if(!G.stamps.has(t(this,k)))G.stamps.set(t(this,k),{area:W,serialized:H}),H.bitmap=K(this,C,In).call(this,!1);else if(t(this,_)){const J=G.stamps.get(t(this,k));W>J.area&&(J.area=W,J.serialized.bitmap.close(),J.serialized.bitmap=K(this,C,In).call(this,!1))}return H}};B=new WeakMap,k=new WeakMap,f=new WeakMap,P=new WeakMap,T=new WeakMap,A=new WeakMap,g=new WeakMap,E=new WeakMap,_=new WeakMap,c=new WeakMap,C=new WeakSet,An=function(U,G=!1){if(!U){this.remove();return}Rt(this,B,U.bitmap),G||(Rt(this,k,U.id),Rt(this,_,U.isSvg)),K(this,C,ps).call(this)},yn=function(){Rt(this,f,null),this._uiManager.enableWaiting(!1),t(this,A)&&this.div.focus()},Mn=function(){if(t(this,k)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(t(this,k)).then(G=>K(this,C,An).call(this,G,!0)).finally(()=>K(this,C,yn).call(this));return}if(t(this,P)){const G=t(this,P);Rt(this,P,null),this._uiManager.enableWaiting(!0),Rt(this,f,this._uiManager.imageManager.getFromUrl(G).then(H=>K(this,C,An).call(this,H)).finally(()=>K(this,C,yn).call(this)));return}if(t(this,T)){const G=t(this,T);Rt(this,T,null),this._uiManager.enableWaiting(!0),Rt(this,f,this._uiManager.imageManager.getFromFile(G).then(H=>K(this,C,An).call(this,H)).finally(()=>K(this,C,yn).call(this)));return}const U=document.createElement("input");U.type="file",U.accept=F.supportedTypesStr,Rt(this,f,new Promise(G=>{U.addEventListener("change",async()=>{if(!U.files||U.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const H=await this._uiManager.imageManager.getFromFile(U.files[0]);K(this,C,An).call(this,H)}G()}),U.addEventListener("cancel",()=>{this.remove(),G()})}).finally(()=>K(this,C,yn).call(this))),U.click()},ps=function(){const{div:U}=this;let{width:G,height:H}=t(this,B);const[_t,D]=this.pageDimensions,W=.75;if(this.width)G=this.width*_t,H=this.height*D;else if(G>W*_t||H>W*D){const s=Math.min(W*_t/G,W*D/H);G*=s,H*=s}const[J,S]=this.parentDimensions;this.setDims(G*J/_t,H*S/D),this._uiManager.enableWaiting(!1);const n=Rt(this,A,document.createElement("canvas"));U.append(n),U.hidden=!1,K(this,C,gs).call(this,G,H),K(this,C,Js).call(this),t(this,c)||(this.parent.addUndoableEditor(this),Rt(this,c,!0)),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"inserted_image"}}}),this.addAltTextButton()},Ys=function(U,G){var W;const[H,_t]=this.parentDimensions;this.width=U/H,this.height=G/_t,this.setDims(U,G),(W=this._initialOptions)!=null&&W.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,t(this,E)!==null&&clearTimeout(t(this,E)),Rt(this,E,setTimeout(()=>{Rt(this,E,null),K(this,C,gs).call(this,U,G)},200))},Ks=function(U,G){const{width:H,height:_t}=t(this,B);let D=H,W=_t,J=t(this,B);for(;D>2*U||W>2*G;){const S=D,n=W;D>2*U&&(D=D>=16384?Math.floor(D/2)-1:Math.ceil(D/2)),W>2*G&&(W=W>=16384?Math.floor(W/2)-1:Math.ceil(W/2));const s=new OffscreenCanvas(D,W);s.getContext("2d").drawImage(J,0,0,S,n,0,0,D,W),J=s.transferToImageBitmap()}return J},gs=function(U,G){U=Math.ceil(U),G=Math.ceil(G);const H=t(this,A);if(!H||H.width===U&&H.height===G)return;H.width=U,H.height=G;const _t=t(this,_)?t(this,B):K(this,C,Ks).call(this,U,G),D=H.getContext("2d");D.filter=this._uiManager.hcmFilter,D.drawImage(_t,0,0,_t.width,_t.height,0,0,U,G)},In=function(U){if(U){if(t(this,_)){const _t=this._uiManager.imageManager.getSvgUrl(t(this,k));if(_t)return _t}const G=document.createElement("canvas");return{width:G.width,height:G.height}=t(this,B),G.getContext("2d").drawImage(t(this,B),0,0),G.toDataURL()}if(t(this,_)){const[G,H]=this.pageDimensions,_t=Math.round(this.width*G*Q.PixelsPerInch.PDF_TO_CSS_UNITS),D=Math.round(this.height*H*Q.PixelsPerInch.PDF_TO_CSS_UNITS),W=new OffscreenCanvas(_t,D);return W.getContext("2d").drawImage(t(this,B),0,0,t(this,B).width,t(this,B).height,0,0,_t,D),W.transferToImageBitmap()}return structuredClone(t(this,B))},Js=function(){Rt(this,g,new ResizeObserver(U=>{const G=U[0].contentRect;G.width&&G.height&&K(this,C,Ys).call(this,G.width,G.height)})),t(this,g).observe(this.div)},Fe(F,"_type","stamp");let xt=F;e.StampEditor=xt})],__webpack_module_cache__={};function __w_pdfjs_require__(d){var e=__webpack_module_cache__[d];if(e!==void 0)return e.exports;var b=__webpack_module_cache__[d]={exports:{}};return __webpack_modules__[d](b,b.exports,__w_pdfjs_require__),b.exports}var __webpack_exports__={};return(()=>{var d=__webpack_exports__;Object.defineProperty(d,"__esModule",{value:!0}),Object.defineProperty(d,"AbortException",{enumerable:!0,get:function(){return e.AbortException}}),Object.defineProperty(d,"AnnotationEditorLayer",{enumerable:!0,get:function(){return Q.AnnotationEditorLayer}}),Object.defineProperty(d,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return e.AnnotationEditorParamsType}}),Object.defineProperty(d,"AnnotationEditorType",{enumerable:!0,get:function(){return e.AnnotationEditorType}}),Object.defineProperty(d,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return z.AnnotationEditorUIManager}}),Object.defineProperty(d,"AnnotationLayer",{enumerable:!0,get:function(){return xt.AnnotationLayer}}),Object.defineProperty(d,"AnnotationMode",{enumerable:!0,get:function(){return e.AnnotationMode}}),Object.defineProperty(d,"CMapCompressionType",{enumerable:!0,get:function(){return e.CMapCompressionType}}),Object.defineProperty(d,"DOMSVGFactory",{enumerable:!0,get:function(){return i.DOMSVGFactory}}),Object.defineProperty(d,"FeatureTest",{enumerable:!0,get:function(){return e.FeatureTest}}),Object.defineProperty(d,"GlobalWorkerOptions",{enumerable:!0,get:function(){return B.GlobalWorkerOptions}}),Object.defineProperty(d,"ImageKind",{enumerable:!0,get:function(){return e.ImageKind}}),Object.defineProperty(d,"InvalidPDFException",{enumerable:!0,get:function(){return e.InvalidPDFException}}),Object.defineProperty(d,"MissingPDFException",{enumerable:!0,get:function(){return e.MissingPDFException}}),Object.defineProperty(d,"OPS",{enumerable:!0,get:function(){return e.OPS}}),Object.defineProperty(d,"PDFDataRangeTransport",{enumerable:!0,get:function(){return b.PDFDataRangeTransport}}),Object.defineProperty(d,"PDFDateString",{enumerable:!0,get:function(){return i.PDFDateString}}),Object.defineProperty(d,"PDFWorker",{enumerable:!0,get:function(){return b.PDFWorker}}),Object.defineProperty(d,"PasswordResponses",{enumerable:!0,get:function(){return e.PasswordResponses}}),Object.defineProperty(d,"PermissionFlag",{enumerable:!0,get:function(){return e.PermissionFlag}}),Object.defineProperty(d,"PixelsPerInch",{enumerable:!0,get:function(){return i.PixelsPerInch}}),Object.defineProperty(d,"PromiseCapability",{enumerable:!0,get:function(){return e.PromiseCapability}}),Object.defineProperty(d,"RenderingCancelledException",{enumerable:!0,get:function(){return i.RenderingCancelledException}}),Object.defineProperty(d,"SVGGraphics",{enumerable:!0,get:function(){return b.SVGGraphics}}),Object.defineProperty(d,"UnexpectedResponseException",{enumerable:!0,get:function(){return e.UnexpectedResponseException}}),Object.defineProperty(d,"Util",{enumerable:!0,get:function(){return e.Util}}),Object.defineProperty(d,"VerbosityLevel",{enumerable:!0,get:function(){return e.VerbosityLevel}}),Object.defineProperty(d,"XfaLayer",{enumerable:!0,get:function(){return k.XfaLayer}}),Object.defineProperty(d,"build",{enumerable:!0,get:function(){return b.build}}),Object.defineProperty(d,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return e.createValidAbsoluteUrl}}),Object.defineProperty(d,"getDocument",{enumerable:!0,get:function(){return b.getDocument}}),Object.defineProperty(d,"getFilenameFromUrl",{enumerable:!0,get:function(){return i.getFilenameFromUrl}}),Object.defineProperty(d,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return i.getPdfFilenameFromUrl}}),Object.defineProperty(d,"getXfaPageViewport",{enumerable:!0,get:function(){return i.getXfaPageViewport}}),Object.defineProperty(d,"isDataScheme",{enumerable:!0,get:function(){return i.isDataScheme}}),Object.defineProperty(d,"isPdfFile",{enumerable:!0,get:function(){return i.isPdfFile}}),Object.defineProperty(d,"loadScript",{enumerable:!0,get:function(){return i.loadScript}}),Object.defineProperty(d,"noContextMenu",{enumerable:!0,get:function(){return i.noContextMenu}}),Object.defineProperty(d,"normalizeUnicode",{enumerable:!0,get:function(){return e.normalizeUnicode}}),Object.defineProperty(d,"renderTextLayer",{enumerable:!0,get:function(){return y.renderTextLayer}}),Object.defineProperty(d,"setLayerDimensions",{enumerable:!0,get:function(){return i.setLayerDimensions}}),Object.defineProperty(d,"shadow",{enumerable:!0,get:function(){return e.shadow}}),Object.defineProperty(d,"updateTextLayer",{enumerable:!0,get:function(){return y.updateTextLayer}}),Object.defineProperty(d,"version",{enumerable:!0,get:function(){return b.version}});var e=__w_pdfjs_require__(1),b=__w_pdfjs_require__(2),i=__w_pdfjs_require__(6),y=__w_pdfjs_require__(26),Q=__w_pdfjs_require__(27),z=__w_pdfjs_require__(5),xt=__w_pdfjs_require__(29),B=__w_pdfjs_require__(14),k=__w_pdfjs_require__(32)})(),__webpack_exports__})())})(pdf)),pdf.exports}var pdfExports=requirePdf();const Be="#FFEB3B",ke=()=>`annotation_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,Ae=({pageNumber:d,scale:e,isAnnotating:b,annotations:i=[],onAnnotationAdd:y,onAnnotationDelete:Q,readOnly:z=!1})=>{const xt=useRef(null),[B,k]=useState(!1),[f,P]=useState({x:0,y:0}),[T,A]=useState(null),[g,E]=useState(null),_=useCallback(m=>{if(!b||!xt.current)return;const r=xt.current.getBoundingClientRect(),h=(m.clientX-r.left)/r.width,a=(m.clientY-r.top)/r.height;console.log("\u9F20\u6807\u6309\u4E0B\u4F4D\u7F6E:",{clientX:m.clientX,clientY:m.clientY,rect:r,x:h,y:a,scale:e}),k(!0),P({x:h,y:a})},[b,e]),c=useCallback(m=>{if(!B||!xt.current)return;const r=xt.current.getBoundingClientRect(),h=(m.clientX-r.left)/r.width,a=(m.clientY-r.top)/r.height;A({x:Math.min(f.x,h),y:Math.min(f.y,a),width:Math.abs(h-f.x),height:Math.abs(a-f.y)})},[B,f,e]),C=useCallback(()=>{if(!B||!T)return;if(k(!1),T.width<5||T.height<5){A(null);return}const m={id:ke(),pageNumber:d,...T,content:"",color:Be};y==null||y(m),A(null)},[B,T,d,y]),I=useCallback(m=>{E(g===m?null:m)},[g]);return useCallback((m,r)=>{const h={...m,content:r};y==null||y(h)},[y]),useCallback(m=>{Q==null||Q(m),E(null)},[Q]),console.log("\u6807\u6CE8\u7EC4\u4EF6\u6E32\u67D3:",{pageNumber:d,annotations:i.length,currentPageAnnotationsCount:i.filter(m=>m.pageNumber===d).length,currentPageAnnotations:i.filter(m=>m.pageNumber===d)}),React__default.createElement("div",{ref:xt,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:10,pointerEvents:"auto"},onMouseDown:_,onMouseMove:c,onMouseUp:C,onMouseLeave:C},T&&React__default.createElement("div",{className:"absolute border-2 border-yellow-400 bg-yellow-100/30",style:{left:`${T.x*100}%`,top:`${T.y*100}%`,width:`${T.width*100}%`,height:`${T.height*100}%`}}),i.filter(m=>m.pageNumber===d).map(m=>(console.log("\u6E32\u67D3\u6807\u6CE8:",m.id,`\u4F4D\u7F6E: ${m.x*100}%, ${m.y*100}%`),React__default.createElement("div",{key:m.id,style:{width:"100%",height:"100%",position:"absolute",top:0,left:0}},React__default.createElement("div",{className:"border border-solid",style:{position:"absolute",left:`${m.x*100}%`,top:`${m.y*100}%`,width:`${m.width*100}%`,height:`${m.height*100}%`,borderWidth:"2px",borderColor:`${m.color}`,backgroundColor:`${m.color}4D`,zIndex:1e3},onClick:()=>I(m.id)})))))},$e=()=>{try{if(xe())console.log("PDF Worker \u5DF2\u7ECF\u6CE8\u518C:",yt());else{const d="/worker/pdf.worker.min.js";console.log("\u6B63\u5728\u6CE8\u518CPDF Worker\uFF0C\u8DEF\u5F84:",d,"\u73AF\u5883:","\u751F\u4EA7"),De(d)}}catch(d){console.warn("PDF Worker \u81EA\u52A8\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6CE8\u518C:",d)}};$e();const Pe={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"}},_e=dt$1.div`
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ height: 200px;
48
+ color: ${d=>d.$theme.colors.disabledText};
49
+ font-size: 14px;
50
+ `,Te=dt$1.div`
51
+ display: flex;
52
+ align-items: center;
53
+ justify-content: center;
54
+ height: 200px;
55
+ color: ${d=>d.$theme.colors.error};
56
+ font-size: 14px;
57
+ text-align: center;
58
+ `,Re=({pdfDocument:d,currentPage:e,pdfStartPage:b=1,scale:i,annotations:y,isAnnotating:Q,isSlidesMode:z=!1,onPageChange:xt,onScaleChange:B,onAnnotationChange:k,onAnnotationDelete:f,styles:P})=>{const[T,A]=useState(!1),[g,E]=useState(null),[_,c]=useState(0),[C,I]=useState(0),[m,r]=useState(!1),[h,a]=useState(!0),l=(P==null?void 0:P.theme)||Pe,u=useRef(null),R=useRef(null),o=useRef(!1),F=useRef(null),$=useCallback(U=>{if(!R.current||!h||!B)return null;const G=R.current,H=G.offsetWidth-40,_t=G.offsetHeight-40,D=H/U.width,W=_t/U.height,J=Math.min(D,W,1),S=Math.max(.3,Math.min(1,J));return console.log("\u81EA\u52A8\u8BA1\u7B97\u7F29\u653E\u6BD4\u4F8B:",{containerWidth:H,containerHeight:_t,viewportWidth:U.width,viewportHeight:U.height,scaleX:D,scaleY:W,autoScale:J,finalScale:S}),S},[h,B]),wt=useCallback(async()=>{if(!(!d||!u.current)){if(o.current||F.current===e){console.log("\u9875\u9762\u6B63\u5728\u6E32\u67D3\u4E2D\uFF0C\u8DF3\u8FC7");return}try{F.current=e,o.current=!0;const U=e-b+1;if(console.log(`\u8BA1\u7B97\u4E0B\uFF0C\u6E32\u67D3\u9875\u9762: PDF\u8D77\u59CB\u9875\uFF1ApdfStartPage=${b}, \u5168\u5C40\u9875\u7801\uFF1AcurrentPage=${e}, \u76F8\u5BF9\u9875\u7801=${U}`),U<1||U>d.numPages)throw console.error(`\u9875\u7801\u8D85\u51FA\u8303\u56F4: \u76F8\u5BF9\u9875\u7801=${U}, PDF\u603B\u9875\u6570=${d.numPages}`),new Error(`\u9875\u7801\u8D85\u51FA\u8303\u56F4: \u8BF7\u6C42\u7B2C${e}\u9875\uFF0C\u4F46PDF\u6587\u6863\u53EA\u5305\u542B${d.numPages}\u9875`);const G=await d.getPage(U),H=u.current,_t=H.getContext("2d");console.log("\u5F53\u524Dscale\u503C:",i);const D=G.getViewport({scale:1});if(console.log("viewport\u5C3A\u5BF8:",D.width,"x",D.height),h&&a(!1),H.width=D.width,H.height=D.height,await G.render({canvasContext:_t,viewport:D}).promise,console.log("PDF\u6E32\u67D3\u6210\u529F, canvas\u5C3A\u5BF8:",H.width,"x",H.height),R.current){const W=R.current;console.log("\u5BB9\u5668\u5C3A\u5BF8:",W.offsetWidth,"x",W.offsetHeight),console.log("Canvas\u663E\u793A\u5C3A\u5BF8:",H.offsetWidth,"x",H.offsetHeight)}}catch(U){console.error("PDF\u6E32\u67D3\u5931\u8D25:",U)}finally{o.current=!1}}},[d,i,b,$,B,e]);return useEffect(()=>{d&&e&&b&&(console.log("\u8BA1\u7B97\u4E0B\uFF0CrenderPage:","pdfStartPage:"+b,"currentPage:"+e,"pdfDocument:",d),wt())},[e,d,b]),useEffect(()=>{d&&e&&wt()},[i,d,e]),T?React__default.createElement("div",{className:"flex justify-center items-center min-h-full"},React__default.createElement(_e,{$theme:l},"\u52A0\u8F7D\u4E2D...")):g?React__default.createElement("div",{className:"flex justify-center items-center min-h-full"},React__default.createElement(Te,{$theme:l},React__default.createElement("div",null,React__default.createElement("div",null,"\u52A0\u8F7D\u5931\u8D25"),React__default.createElement("div",{style:{fontSize:"12px",marginTop:"8px"}},g)))):React__default.createElement("div",{ref:R,className:"bg-gray-100",style:{display:z?"block":"flex",justifyContent:z?"initial":"center",alignItems:z?"initial":"flex-start",padding:"20px",minHeight:"100%",width:"100%",overflow:"visible"}},T?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...")):g?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"},g)):React__default.createElement("div",{className:"flex justify-center items-start"},React__default.createElement("div",{className:"relative",style:{transform:`scale(${i})`,transformOrigin:"center",display:"inline-block"}},React__default.createElement("canvas",{ref:u,className:"shadow-lg bg-white border border-gray-300",style:{display:"block"}}),React__default.createElement(Ae,{pageNumber:e,scale:i,isAnnotating:Q,annotations:y,onAnnotationAdd:k,onAnnotationDelete:f,readOnly:!Q}))))},Ne=dt$1.div`
59
+ flex: 1;
60
+ background: ${d=>d.$theme.colors.background};
61
+ position: relative;
62
+ display: flex;
63
+ flex-direction: column;
64
+ scroll-behavior: smooth;
65
+
66
+ min-height: 0; /* 确保flex子元素可以收缩 */
67
+ height: calc(100% - 1px); /* 明确的高度设置,减去header高度 */
68
+ /* 支持大尺寸内容的滚动 */
69
+ overflow-x: auto;
70
+ overflow-y: auto; /* 改为auto,允许垂直滚动 */
71
+ `,Le=dt$1.div`
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ height: 100%;
76
+ color: ${d=>d.$theme.colors.disabledText};
77
+ `,ze=dt$1.div`
78
+ display: flex;
79
+ flex-direction: column;
80
+ align-items: center;
81
+ justify-content: center;
82
+ height: 100%;
83
+ color: ${d=>d.$theme.colors.error};
84
+ text-align: center;
85
+ padding: 20px;
86
+ `,Se=`
87
+ .md-annotation {
88
+ position: relative;
89
+ display: inline;
90
+ cursor: pointer;
91
+ transition: opacity 0.2s;
92
+ background-color: var(--highlight-color, #FFE599);
93
+ }
94
+
95
+ .md-annotation:hover {
96
+ opacity: 0.8;
97
+ }
98
+
99
+ /* \u8868\u683C\u6807\u6CE8\u6837\u5F0F */
100
+ .table-annotation {
101
+ background-color: var(--table-highlight-color, rgba(255, 229, 153, 0.5));
102
+ }
103
+
104
+ /* markdown_table\u6A21\u5F0F\u4E0B\u7684\u8868\u683C\u6837\u5F0F */
105
+ .markdown-table-mode table {
106
+ overflow: visible !important;
107
+ max-width: none !important;
108
+ width: auto !important;
109
+ table-layout: auto !important;
110
+ }
111
+
112
+ .markdown-table-mode table,
113
+ .markdown-table-mode table * {
114
+ overflow: visible !important;
115
+ }
116
+
117
+ .markdown-table-mode .table-container{
118
+ margin: 0 !important;
119
+ overflow: auto !important;
120
+ width: 100% !important;
121
+ min-width: 100% !important;
122
+ }
123
+
124
+ /* \u786E\u4FDD\u8868\u683C\u5355\u5143\u683C\u4E0D\u4F1A\u88AB\u538B\u7F29 */
125
+ .markdown-table-mode table td,
126
+ .markdown-table-mode table th {
127
+ white-space: nowrap !important;
128
+ min-width: 50px !important;
129
+ }
130
+
131
+ /* \u79FB\u9664fit-content\uFF0C\u4F7F\u7528100%\u5BBD\u5EA6\u786E\u4FDD\u5185\u5BB9\u80FD\u6B63\u5E38\u663E\u793A */
132
+ .markdown-table-mode div{
133
+ width: fit-content !important;
134
+ }
135
+
136
+ /* \u4E3A\u8868\u683C\u6DFB\u52A0\u6700\u5C0F\u5BBD\u5EA6\uFF0C\u786E\u4FDD\u5185\u5BB9\u4E0D\u88AB\u538B\u7F29 */
137
+ .markdown-table-mode table {
138
+ min-width: fit-content !important;
139
+ }
140
+
141
+ .markdown-table-mode.markdown-scrollbar::-webkit-scrollbar {
142
+ width: 12px;
143
+ height: 12px;
144
+ }
145
+
146
+
147
+ /* \u81EA\u5B9A\u4E49\u6EDA\u52A8\u6761\u6837\u5F0F */
148
+ .markdown-scrollbar::-webkit-scrollbar {
149
+ width: 8px;
150
+ height: 8px;
151
+ }
152
+
153
+ .markdown-scrollbar::-webkit-scrollbar-track {
154
+ background: #f1f1f1;
155
+ border-radius: 4px;
156
+ }
157
+
158
+ .markdown-scrollbar::-webkit-scrollbar-thumb {
159
+ background: #c1c1c1;
160
+ border-radius: 4px;
161
+ }
162
+
163
+ .markdown-scrollbar::-webkit-scrollbar-thumb:hover {
164
+ background: #a9a9a;
165
+ }
166
+ `,Me={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"}},We=d=>{if(console.log("=== detectFileType \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",d),!d)return console.log("\u6570\u636E\u4E3A\u7A7A\uFF0C\u8FD4\u56DE unknown"),"unknown";const e=d.fileName||"",b=d.fileType||"",i=d.content;return console.log("\u68C0\u6D4B\u53C2\u6570:",{fileName:e,fileType:b,content:i}),b==="pdf"||b==="pdf_slides"?(console.log("\u68C0\u6D4B\u5230PDF\u6587\u4EF6"),b):b==="image"?(console.log("\u68C0\u6D4B\u5230\u56FE\u7247\u6587\u4EF6"),"image"):b==="markdown_table"?(console.log("\u68C0\u6D4B\u5230Markdown\u8868\u683C\u6587\u4EF6"),"markdown_table"):b==="markdown"?(console.log("\u68C0\u6D4B\u5230Markdown\u6587\u4EF6"),"markdown"):b==="html"?(console.log("\u68C0\u6D4B\u5230HTML\u6587\u4EF6"),"html"):b==="text"?(console.log("\u68C0\u6D4B\u5230\u6587\u672C\u6587\u4EF6"),"text"):e.toLowerCase().endsWith(".pdf")||(i==null?void 0:i.type)==="pdf"?(console.log("\u68C0\u6D4B\u5230PDF\u6587\u4EF6"),"pdf"):e.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)||(i==null?void 0:i.type)==="image"?(console.log("\u68C0\u6D4B\u5230\u56FE\u7247\u6587\u4EF6"),"image"):e.toLowerCase().endsWith(".md")||(i==null?void 0:i.type)==="markdown"?(console.log("\u68C0\u6D4B\u5230Markdown\u6587\u4EF6"),"markdown"):e.toLowerCase().match(/\.(html|htm)$/)||(i==null?void 0:i.type)==="html"?(console.log("\u68C0\u6D4B\u5230HTML\u6587\u4EF6"),"html"):e.toLowerCase().match(/\.(txt|log|json|xml|css|js|ts)$/)||(i==null?void 0:i.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")},Ie=(d,e,b=!1)=>{var i,y,Q,z,xt,B,k;console.log("\u8BA1\u7B97\u4E0B\uFF0CrenderPdfContent:","pdfStartPage:"+d.pdfStartPage,"currentPage:"+e.currentPage),console.log("=== renderPdfContent \u5F00\u59CB ==="),console.log("PDF\u6570\u636E:",d),console.log("PDF\u6587\u6863:",(i=d.content)==null?void 0:i.document),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof((y=d.content)==null?void 0:y.document)),console.log("PDF\u6587\u6863\u662F\u5426\u4E3Anull:",((Q=d.content)==null?void 0:Q.document)===null),console.log("PDF\u6587\u6863\u662F\u5426\u4E3Aundefined:",((z=d.content)==null?void 0:z.document)===void 0),console.log("PDF\u6587\u6863\u65B9\u6CD5:",(xt=d.content)!=null&&xt.document?Object.getOwnPropertyNames(Object.getPrototypeOf(d.content.document)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u5C5E\u6027:",(B=d.content)!=null&&B.document?Object.keys(d.content.document):"\u65E0\u6587\u6863");const f=d.pdfStartPage||1;console.log("PDF\u8D77\u59CB\u9875:",f);const P=(e.annotationData||[]).filter(g=>"pageNumber"in g&&"x"in g&&"y"in g);console.log("=== PDF\u6807\u6CE8\u6570\u636E ==="),console.log("\u539F\u59CBannotationData:",e.annotationData),console.log("\u8FC7\u6EE4\u540E\u7684pdfAnnotations:",P);const T=b?.82:1,A=e.initialZoom||e.scale||T;return React__default.createElement(Re,{pdfDocument:((k=d.content)==null?void 0:k.document)||null,currentPage:e.currentPage||1,pdfStartPage:f,scale:A,annotations:P,isAnnotating:!1,isSlidesMode:b,onPageChange:e.eventsEmit?g=>{var E;return(E=e.eventsEmit)==null?void 0:E.call(e,"pageChange",{pageNumber:g})}:void 0,onScaleChange:e.eventsEmit?g=>{var E;return(E=e.eventsEmit)==null?void 0:E.call(e,"scaleChange",{scale:g})}:void 0,onAnnotationChange:e.eventsEmit?g=>{var E;return(E=e.eventsEmit)==null?void 0:E.call(e,"annotationChange",{annotation:g})}:void 0,onAnnotationDelete:e.eventsEmit?g=>{var E;return(E=e.eventsEmit)==null?void 0:E.call(e,"annotationDelete",{annotationId:g})}:void 0,styles:e.styles})},je=(d,e)=>{var b,i,y,Q,z,xt,B,k,f,P,T,A,g,E;console.log("=== Fviewer renderImageContent ==="),console.log("data:",d),console.log("data.content:",d.content),console.log("data.content?.url:",(b=d.content)==null?void 0:b.url),console.log("rotation:",e.rotation);const _=((i=d.content)==null?void 0:i.url)||d.content,[c,C]=useState(!0),[I,m]=useState(!1),r=()=>{console.log("\u56FE\u7247\u52A0\u8F7D\u5B8C\u6210:",_),C(!1),m(!1)},h=()=>{console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",_),C(!1),m(!0)};return React__default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"20px",overflow:"auto",position:"relative",backgroundColor:"#272727"}},c&&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 ${((z=(Q=(y=e.styles)==null?void 0:y.theme)==null?void 0:Q.colors)==null?void 0:z.border)||"#dee2e6"}`,borderTop:`3px solid ${((k=(B=(xt=e.styles)==null?void 0:xt.theme)==null?void 0:B.colors)==null?void 0:k.primary)||"#007bff"}`,borderRadius:"50%",animation:"spin 1s linear infinite"}}),React__default.createElement("div",{style:{fontSize:"12px",color:((T=(P=(f=e.styles)==null?void 0:f.theme)==null?void 0:P.colors)==null?void 0:T.text)||"#343a40"}},"\u56FE\u7247\u52A0\u8F7D\u4E2D...")),I&&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:((E=(g=(A=e.styles)==null?void 0:A.theme)==null?void 0:g.colors)==null?void 0:E.error)||"#dc3545"}},"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25")),React__default.createElement("img",{src:_,alt:d.fileName||"\u56FE\u7247",onLoad:r,onError:h,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",transform:`scale(${e.scale||1}) rotate(${e.rotation||0}deg)`,opacity:c?0:1,transition:"opacity 0.3s ease-in-out, transform 0.2s ease-in-out"}}),React__default.createElement("style",null,`
167
+ @keyframes spin {
168
+ 0% { transform: rotate(0deg); }
169
+ 100% { transform: rotate(360deg); }
170
+ }
171
+ `))},Oe=(d,e)=>{var b,i,y,Q,z;console.log("=== Fviewer renderTextContent ==="),console.log("data:",d),console.log("data.content:",d.content);let xt="";typeof d.content=="string"?xt=d.content:(b=d.content)!=null&&b.text?xt=d.content.text:(i=d.content)!=null&&i.content&&(xt=d.content.content),console.log("\u5B9E\u9645\u6587\u672C\u5185\u5BB9:",xt);const B=useRef(null),k=useRef(null);return useEffect(()=>{if(B.current&&k.current&&xt){const f=setTimeout(()=>{var P;const T=((P=B.current)==null?void 0:P.scrollHeight)||0,A=Math.max(T+80,200);k.current&&(k.current.style.minHeight=`${A}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",A))},100);return()=>clearTimeout(f)}},[xt]),React__default.createElement("div",{style:{height:"100%",overflow:"auto",backgroundColor:"#f5f5f5",padding:"20px",display:"flex",justifyContent:"center",position:"relative"}},React__default.createElement("div",{ref:k,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(${e.scale||1})`,transition:"transform 0.2s ease-in-out",transformOrigin:"top center"}},React__default.createElement("div",{ref:B,style:{width:"100%",overflow:"visible"}},React__default.createElement(Wv,{dataSource:{type:oa.TEXT,content:xt},size:"md",theme:{primaryColor:((z=(Q=(y=e.styles)==null?void 0:y.theme)==null?void 0:Q.colors)==null?void 0:z.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"}})))},He=({data:d,parentProps:e,isTableMode:b=!1})=>{var i,y,Q,z,xt,B,k,f,P,T,A,g;const E=useRef(null),_=useRef(null),c=useRef(null),C=useRef(!1);useRef(0),useRef(null);const[I]=useState(!1),m=(U,G)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:U,scrollHeight:G}),e.eventsEmit&&e.eventsEmit("markdown_scroll",{scrollTop:U,scrollHeight:G})},r=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),e.eventsEmit&&e.eventsEmit("markdown_scroll_to_top")},h=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),e.eventsEmit&&e.eventsEmit("markdown_scroll_to_bottom")},a=useRef();a.current=U=>{var G,H;try{if(!b)return;const _t=typeof d.content=="string"?d.content:((G=d.content)==null?void 0:G.content)||"";if(!_t||o.length===0)return;const D=JSON.stringify(o.map(J=>({o:J.offsets,c:J.color}))),W=`${_t.length}:${_t.substring(0,64)}:${_t.substring(_t.length-64)}|${D}`;if(((H=U.dataset)==null?void 0:H.tableAnnoRuntimeSig)===W)return;setTimeout(()=>{$(),U.dataset&&(U.dataset.tableAnnoRuntimeSig=W)},50)}catch(_t){console.warn("[MarkdownRendered] apply failed",_t)}};const l=React__default.useCallback(U=>{var G;return(G=a.current)==null?void 0:G.call(a,U)},[]),u=useCallback(()=>{var U;if(!I||!E.current)return;const G=window.getSelection();if(!G||G.isCollapsed)return;const H=G.getRangeAt(0),_t=H.toString().trim();if(!_t)return;const D=E.current;let W=0,J=0;const S=document.createTreeWalker(D,NodeFilter.SHOW_TEXT,{acceptNode:p=>{var M;return(M=p.parentElement)!=null&&M.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let n=S.nextNode();for(;n;){if(n===H.startContainer){J=W+H.startOffset;break}W+=((U=n.textContent)==null?void 0:U.length)||0,n=S.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:_t,startOffset:J,charCount:W,container:H.startContainer.textContent});const s={id:`md-anno-${Date.now()}`,start:J,end:J+_t.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",s),e.eventsEmit&&e.eventsEmit("md_annotation_add",s),G.removeAllRanges()},[I,e.eventsEmit]),R=b?[]:(e.annotationData||[]).filter(U=>"start"in U&&"end"in U&&!("pageNumber"in U)),o=b?(e.annotationData||[]).filter(U=>"offsets"in U&&Array.isArray(U.offsets)):[],F=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u6E05\u7A7A\u6240\u6709\u6807\u6CE8 ==="),!E.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u6E05\u7A7A\u6807\u6CE8");return}const U=E.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",U.length),U.length>0&&U.forEach(G=>{const H=G.parentNode;H&&H.replaceChild(document.createTextNode(G.textContent||""),G)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),$=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",o),!E.current||!o.length){console.log("\u8868\u683C\u6807\u6CE8\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u9000\u51FA");return}const U=E.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",U.length),U.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}C.current=!0,o.forEach((G,H)=>{const _t=G.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",G),!Array.isArray(_t)||!_t.length||!Array.isArray(_t[0])||_t[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",G);return}_t.forEach((D,W)=>{const[J,S]=D;if(typeof J!="number"||typeof S!="number"){console.warn("[TableAnnotation] offset is not [number, number]",D);return}U.forEach((n,s)=>{var p,M,O;let L;const V=n.tBodies&&n.tBodies.length>0?Array.from(n.tBodies[0].rows):[];if(V.length>0)L=V[J];else{const jt=((M=(p=n.tHead)==null?void 0:p.rows)==null?void 0:M.length)||0;L=Array.from(n.rows)[J+jt]}if(!L){console.warn("[TableAnnotation] row out of range",{row:J,tableIndex:s});return}const At=(O=L.cells)==null?void 0:O[S];if(!At){console.warn("[TableAnnotation] cell is undefined",{row:J,col:S,tableIndex:s});return}const It=G.color||"rgba(255, 229, 153, 0.5)",Bt=getComputedStyle(At).backgroundColor;At.getAttribute("data-table-annotated")==="1"&&(Bt===It||At.style.backgroundColor===It)||(At.style.setProperty("background",It,"important"),At.style.setProperty("background-color",It,"important"),At.setAttribute("data-table-annotated","1")),G.content&&(At.title=G.content),W===0&&H===0&&setTimeout(()=>{At.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{C.current=!1})},[o]),wt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!E.current||!R.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}_.current&&clearTimeout(_.current);const U=()=>{var G;console.log("\u5F00\u59CB\u5E94\u7528\u6807\u6CE8...");const H=(G=E.current)==null?void 0:G.querySelectorAll(".md-annotation");console.log("\u79FB\u9664\u73B0\u6709\u6807\u6CE8\u6570\u91CF:",(H==null?void 0:H.length)||0),H==null||H.forEach(s=>{const p=s.parentNode;p&&p.replaceChild(document.createTextNode(s.textContent||""),s)});const _t=document.createTreeWalker(E.current,NodeFilter.SHOW_TEXT,{acceptNode:s=>{var p;return(p=s.parentElement)!=null&&p.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),D=[];let W;for(;W=_t.nextNode();)D.push(W);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",D.length),D.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),_.current=setTimeout(()=>{U()},200);return}let J=0;const S=D.map(s=>{var p;const M=J;return J+=((p=s.textContent)==null?void 0:p.length)||0,{node:s,start:M,end:J,text:s.textContent}});console.log("\u6587\u672C\u8282\u70B9\u4F4D\u7F6E:",S),console.log("\u603B\u6587\u672C\u957F\u5EA6:",J);const n=[...R].sort((s,p)=>p.start-s.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",n),n.forEach(s=>{const{start:p,end:M,color:O}=s;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:s,nodePositions:S});const L=S.filter(V=>p<V.end&&M>V.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",L.length),L.forEach(({node:V,start:At})=>{var It,Bt,jt,Ut,Xt,vt;const kt=Math.max(0,p-At),v=Math.min(((It=V.textContent)==null?void 0:It.length)||0,M-At);if(console.log("\u672C\u5730\u4F4D\u7F6E:",{localStart:kt,localEnd:v,nodeTextLength:(Bt=V.textContent)==null?void 0:Bt.length}),kt>=v){console.log("\u672C\u5730\u4F4D\u7F6E\u65E0\u6548\uFF0C\u8DF3\u8FC7");return}const N=((jt=V.textContent)==null?void 0:jt.slice(0,kt))||"",Z=((Ut=V.textContent)==null?void 0:Ut.slice(kt,v))||"",St=((Xt=V.textContent)==null?void 0:Xt.slice(v))||"";console.log("\u5206\u5272\u6587\u672C:",{before:N,annotatedText:Z,after:St});const Nt=document.createElement("span");Nt.className="md-annotation",Nt.style.backgroundColor=O||"#FFE599",Nt.textContent=Z;const zt=document.createDocumentFragment();N&&zt.appendChild(document.createTextNode(N)),zt.appendChild(Nt),St&&zt.appendChild(document.createTextNode(St)),(vt=V.parentNode)==null||vt.replaceChild(zt,V),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",Z)})})};_.current=setTimeout(()=>{U()},100)},[R]);return useEffect(()=>{var U;if(b){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const G=typeof d.content=="string"?d.content:((U=d.content)==null?void 0:U.content)||"";if(!G||typeof G!="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:",E.current),console.log("isTableMode:",b),console.log("mdAnnotations:",R),console.log("tableAnnotations:",o),console.log("data.content:",d.content),console.log("\u5B9E\u9645\u5185\u5BB9:",G),!E.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA\u6807\u6CE8\u5E94\u7528");return}if(b||F(),!b&&R.length>0){wt();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[b,o,R]),useEffect(()=>{if(!b)return document.addEventListener("mouseup",u),()=>{document.removeEventListener("mouseup",u)}},[u,b]),useEffect(()=>{var U;const G=typeof d.content=="string"?d.content:((U=d.content)==null?void 0:U.content)||"";if(!G||typeof G!="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:",b),console.log("\u5185\u5BB9\u957F\u5EA6:",G.length||0),typeof G=="string"?(console.log("\u5185\u5BB9\u524D100\u5B57\u7B26:",G.substring(0,100)),console.log("\u5185\u5BB9\u540E100\u5B57\u7B26:",G.substring(G.length-100))):(console.log("\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B:",typeof G),console.log("\u5185\u5BB9\u503C:",G)),console.log("\u6807\u6CE8\u6570\u636E:",R),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",o)},[R,o,b]),useEffect(()=>{if(b&&E.current){const U=setTimeout(()=>{var G;const H=(G=E.current)==null?void 0:G.querySelectorAll("table");H&&H.length>0&&(console.log("\u8C03\u6574\u8868\u683C\u5C3A\u5BF8\uFF0C\u627E\u5230\u8868\u683C\u6570\u91CF:",H.length),H.forEach((_t,D)=>{if(_t instanceof HTMLTableElement){_t.style.width="100%",_t.style.minWidth="100%",_t.style.tableLayout="auto";const W=_t.closest(".markdown-table-mode");W&&W instanceof HTMLElement&&(W.style.width="100%",W.style.overflowX="auto"),console.log(`\u8868\u683C ${D+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(U)}},[b,d.content]),useEffect(()=>()=>{_.current&&clearTimeout(_.current),c.current&&(c.current.disconnect(),c.current=null)},[]),React__default.createElement("div",{style:{height:"100%",width:"100%",overflow:"auto"},className:`markdown-container markdown-scrollbar ${b?"markdown-table-mode":""}`},React__default.createElement("style",null,Se),React__default.createElement("div",{ref:E},React__default.createElement(Wv,{dataSource:{type:oa.MARKDOWN,content:(()=>{var U,G;return typeof d.content=="string"?d.content:(U=d.content)!=null&&U.text?d.content.text:(G=d.content)!=null&&G.content?d.content.content:""})()},size:"md",onScroll:b?void 0:m,onScrollToTop:b?void 0:r,onScrollToBottom:b?void 0:h,onRendered:l,theme:{primaryColor:((Q=(y=(i=e.styles)==null?void 0:i.theme)==null?void 0:y.colors)==null?void 0:Q.primary)||"#007bff",backgroundColor:((B=(xt=(z=e.styles)==null?void 0:z.theme)==null?void 0:xt.colors)==null?void 0:B.background)||"#f8f9fa",textColor:((P=(f=(k=e.styles)==null?void 0:k.theme)==null?void 0:f.colors)==null?void 0:P.text)||"#343a40",borderColor:((g=(A=(T=e.styles)==null?void 0:T.theme)==null?void 0:A.colors)==null?void 0:g.border)||"#dee2e6",borderRadius:b?"0px":"8px",padding:b?"0px":"20px"},style:{height:"100%",border:"none",background:"transparent",overflowY:b?"visible":"scroll"}})))},Ze=({markdown:d,onRendered:e,tableAnnotations:b=[]})=>{const i=useRef(null),y=z=>{const xt=z.split(/\r?\n/).filter(T=>T.trim().length>0);let B=-1;for(let T=0;T<xt.length-1;T++){const A=xt[T].trim(),g=xt[T+1].trim();if(A.startsWith("|")&&A.endsWith("|")&&g.replace(/\s|:|\|/g,"").match(/^[-]+$/)){B=T;break}}if(B===-1)return null;const k=xt[B].split("|").slice(1,-1).map(T=>T.trim()),f=[];for(let T=B+2;T<xt.length;T++){const A=xt[T].trim();if(!A.startsWith("|")||!A.endsWith("|"))break;f.push(A)}const P=f.map(T=>T.split("|").slice(1,-1).map(A=>A.trim()));return{headers:k,rows:P}},Q=React__default.useMemo(()=>y(d),[d]);return useEffect(()=>{const z=()=>{try{if(!i.current||!b.length)return;const B=i.current.querySelectorAll("table");if(!B||B.length===0)return;b.forEach((k,f)=>{(k.offsets||[]).forEach((P,T)=>{const[A,g]=P;B.forEach(E=>{var _,c,C;const I=E.tBodies&&E.tBodies.length>0?Array.from(E.tBodies[0].rows):[];let m;if(I.length>0)m=I[A];else{const a=((c=(_=E.tHead)==null?void 0:_.rows)==null?void 0:c.length)||0;m=Array.from(E.rows)[A+a]}if(!m)return;const r=(C=m.cells)==null?void 0:C[g];if(!r)return;const h=k.color||"rgba(255, 229, 153, 0.5)";r.getAttribute("data-table-annotated")==="1"||(r.style.setProperty("background",h,"important"),r.style.setProperty("background-color",h,"important"),r.setAttribute("data-table-annotated","1"),k.content&&(r.title=k.content)),f===0&&T===0&&setTimeout(()=>r.scrollIntoView({behavior:"smooth",block:"start"}),50)})})})}catch(B){console.warn("[MinimalMarkdownTable] apply annotations failed",B)}},xt=requestAnimationFrame(()=>{z(),e&&e()});return()=>cancelAnimationFrame(xt)},[d,b,e]),Q?React__default.createElement("div",{ref:i,className:"markdown-table-mode z-mdtbl-wrapper"},React__default.createElement("style",null,`
172
+ .z-mdtbl-wrapper { overflow: auto; position: relative; }
173
+ .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; }
174
+ .z-mdtbl th, .z-mdtbl td { border: 1px solid #e5e7eb; padding: 10px 14px; font-size: 13px; line-height: 1.4; color: inherit; }
175
+ .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); }
176
+ .z-mdtbl tbody tr:nth-child(odd) { background: transparent; }
177
+ .z-mdtbl tbody tr:hover { background: transparent; }
178
+ .z-mdtbl td, .z-mdtbl th { white-space: nowrap; }
179
+ .z-mdtbl thead tr:first-child th:first-child { border-top-left-radius: 8px; }
180
+ .z-mdtbl thead tr:first-child th:last-child { border-top-right-radius: 8px; }
181
+ .z-mdtbl tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
182
+ .z-mdtbl tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }
183
+ `),React__default.createElement("table",{className:"z-mdtbl"},React__default.createElement("thead",null,React__default.createElement("tr",null,Q.headers.map((z,xt)=>React__default.createElement("th",{key:xt},z)))),React__default.createElement("tbody",null,Q.rows.map((z,xt)=>React__default.createElement("tr",{key:xt},z.map((B,k)=>React__default.createElement("td",{key:k},B))))))):React__default.createElement("div",{ref:i,style:{padding:"8px"}},"\u65E0\u6CD5\u89E3\u6790\u4E3A\u8868\u683C")},Xe=(d,e)=>{var b,i;console.log("=== Fviewer renderHtmlContent ==="),console.log("data:",d),console.log("data.content:",d.content);let y="";return typeof d.content=="string"?y=d.content:(b=d.content)!=null&&b.text?y=d.content.text:(i=d.content)!=null&&i.content&&(y=d.content.content),console.log("\u6700\u7EC8\u4F20\u9012\u7ED9 iframe \u7684 content:",y),React__default.createElement("div",{style:{height:"100%",overflow:"auto",position:"relative"}},React__default.createElement("iframe",{srcDoc:y,style:{width:"100%",height:"100%",border:"none",background:"white"},title:"HTML Preview",sandbox:"allow-same-origin allow-scripts"}))},qe=(d,e)=>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"}},d.fileName||"\u672A\u77E5\u6587\u4EF6"))),Ue=({data:d,annotationData:e=[],totalPage:b=0,currentPage:i=1,scale:y,rotation:Q=0,eventsEmit:z,styles:xt,tools:B={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0},customComponents:k,className:f,contentClass:P})=>{var T,A,g,E;const _=(xt==null?void 0:xt.theme)||Me,[c,C]=useState(!1),[I]=useState("\u5185\u5BB9\u52A0\u8F7D\u4E2D..."),[m,r]=useState(null);console.log("=== Fviewer \u63A5\u6536\u6570\u636E ==="),console.log("Fviewer data:",d),console.log("Fviewer data.content:",d==null?void 0:d.content),console.log("Fviewer data.content.document:",(T=d==null?void 0:d.content)==null?void 0:T.document),console.log("Fviewer data.content.document\u7C7B\u578B:",typeof((A=d==null?void 0:d.content)==null?void 0:A.document)),console.log("Fviewer data.content.document\u662F\u5426\u4E3Anull:",((g=d==null?void 0:d.content)==null?void 0:g.document)===null),console.log("Fviewer data.content.document\u662F\u5426\u4E3Aundefined:",((E=d==null?void 0:d.content)==null?void 0:E.document)===void 0),console.log("Fviewer currentPage:",i),console.log("Fviewer scale:",y);const h=useRef(null),a=useRef(null),l=useRef(0);l.current+=1,console.log("[Fviewer] render count:",l.current);const u=We(d);console.log("=== Fviewer \u7EC4\u4EF6 ==="),console.log("\u68C0\u6D4B\u5230\u7684\u6587\u4EF6\u7C7B\u578B:",u),console.log("\u5B8C\u6574\u6570\u636E:",d);const R=()=>{var o;switch(console.log("\u5F00\u59CB\u6E32\u67D3\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B:",u),u){case"pdf":case"pdf_slides":return console.log("\u8BA1\u7B97\u4E0B\uFF0C\u6E32\u67D3PDF\u5185\u5BB9:",u,"pdfStartPage:"+d.pdfStartPage,"currentPage:"+i),Ie(d,{data:d,annotationData:e,totalPage:b,currentPage:i,scale:y,eventsEmit:z,styles:xt,tools:B,className:f,contentClass:P},u==="pdf_slides");case"image":return console.log("\u6E32\u67D3\u56FE\u7247\u5185\u5BB9"),je(d,{scale:y,rotation:Q,styles:xt});case"text":return console.log("\u6E32\u67D3\u6587\u672C\u5185\u5BB9"),Oe(d,{scale:y,styles:xt});case"markdown":case"markdown_table":if(console.log("\u6E32\u67D3Markdown\u5185\u5BB9:",u),u==="markdown_table"){const F=typeof d.content=="string"?d.content:((o=d.content)==null?void 0:o.content)||"",$=(e||[]).filter(wt=>"offsets"in wt&&Array.isArray(wt.offsets));return React__default.createElement(Ze,{markdown:F,tableAnnotations:$})}return React__default.createElement(He,{data:d,parentProps:{data:d,annotationData:e,eventsEmit:z,styles:xt,tools:B,className:f,contentClass:P},isTableMode:!1});case"html":return console.log("\u6E32\u67D3HTML\u5185\u5BB9"),Xe(d);default:return console.log("\u6E32\u67D3\u672A\u77E5\u7C7B\u578B\u5185\u5BB9"),qe(d)}};return React__default.useEffect(()=>{const o=h.current,F=a.current,$=o!==d,wt=F!==(d?d.content:void 0);console.log("[Fviewer useEffect:data] triggered",{dataChanged:$,contentChanged:wt,hasData:!!d,hasContent:!!(d!=null&&d.content),isLoadingBefore:c}),h.current=d,a.current=d?d.content:void 0},[d==null?void 0:d.content]),React__default.useEffect(()=>{m&&C(!1)},[m]),React__default.useEffect(()=>{console.log("=== Fviewer annotationData \u53D8\u5316\u76D1\u542C ==="),console.log("annotationData:",e),console.log("annotationData \u957F\u5EA6:",(e==null?void 0:e.length)||0),console.log("\u5F53\u524D\u6587\u4EF6\u7C7B\u578B:",u)},[e,u]),React__default.createElement(Ne,{$theme:_,className:P},c?k!=null&&k.LoadingComponent?React__default.createElement(k.LoadingComponent,{status:I,theme:_}):React__default.createElement(Le,{$theme:_},I):m?k!=null&&k.ErrorComponent?React__default.createElement(k.ErrorComponent,{error:m,theme:_}):React__default.createElement(ze,{$theme:_},React__default.createElement("div",null,"\u52A0\u8F7D\u5931\u8D25"),React__default.createElement("div",{style:{fontSize:"12px",marginTop:"8px"}},m)):R())};/**
184
+ * @license lucide-react v0.456.0 - ISC
185
+ *
186
+ * This source code is licensed under the ISC license.
187
+ * See the LICENSE file in the root directory of this source tree.
188
+ */const Ye=d=>d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ye=(...d)=>d.filter((e,b,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===b).join(" ").trim();/**
189
+ * @license lucide-react v0.456.0 - ISC
190
+ *
191
+ * This source code is licensed under the ISC license.
192
+ * See the LICENSE file in the root directory of this source tree.
193
+ */var Ge={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"};/**
194
+ * @license lucide-react v0.456.0 - ISC
195
+ *
196
+ * This source code is licensed under the ISC license.
197
+ * See the LICENSE file in the root directory of this source tree.
198
+ */const Ve=forwardRef(({color:d="currentColor",size:e=24,strokeWidth:b=2,absoluteStrokeWidth:i,className:y="",children:Q,iconNode:z,...xt},B)=>createElement("svg",{ref:B,...Ge,width:e,height:e,stroke:d,strokeWidth:i?Number(b)*24/Number(e):b,className:ye("lucide",y),...xt},[...z.map(([k,f])=>createElement(k,f)),...Array.isArray(Q)?Q:[Q]]));/**
199
+ * @license lucide-react v0.456.0 - ISC
200
+ *
201
+ * This source code is licensed under the ISC license.
202
+ * See the LICENSE file in the root directory of this source tree.
203
+ */const ue=(d,e)=>{const b=forwardRef(({className:i,...y},Q)=>createElement(Ve,{ref:Q,iconNode:e,className:ye(`lucide-${Ye(d)}`,i),...y}));return b.displayName=`${d}`,b};/**
204
+ * @license lucide-react v0.456.0 - ISC
205
+ *
206
+ * This source code is licensed under the ISC license.
207
+ * See the LICENSE file in the root directory of this source tree.
208
+ */const Je=ue("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
209
+ * @license lucide-react v0.456.0 - ISC
210
+ *
211
+ * This source code is licensed under the ISC license.
212
+ * See the LICENSE file in the root directory of this source tree.
213
+ */const Ke=ue("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
214
+ * @license lucide-react v0.456.0 - ISC
215
+ *
216
+ * This source code is licensed under the ISC license.
217
+ * See the LICENSE file in the root directory of this source tree.
218
+ */const Qe=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"}]]);/**
219
+ * @license lucide-react v0.456.0 - ISC
220
+ *
221
+ * This source code is licensed under the ISC license.
222
+ * See the LICENSE file in the root directory of this source tree.
223
+ */const et=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"}]]);/**
224
+ * @license lucide-react v0.456.0 - ISC
225
+ *
226
+ * This source code is licensed under the ISC license.
227
+ * See the LICENSE file in the root directory of this source tree.
228
+ */const tt=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"}]]);/**
229
+ * @license lucide-react v0.456.0 - ISC
230
+ *
231
+ * This source code is licensed under the ISC license.
232
+ * See the LICENSE file in the root directory of this source tree.
233
+ */const ot=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"}]]);/**
234
+ * @license lucide-react v0.456.0 - ISC
235
+ *
236
+ * This source code is licensed under the ISC license.
237
+ * See the LICENSE file in the root directory of this source tree.
238
+ */const nt=ue("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
239
+ * @license lucide-react v0.456.0 - ISC
240
+ *
241
+ * This source code is licensed under the ISC license.
242
+ * See the LICENSE file in the root directory of this source tree.
243
+ */const ut=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"}]]);/**
244
+ * @license lucide-react v0.456.0 - ISC
245
+ *
246
+ * This source code is licensed under the ISC license.
247
+ * See the LICENSE file in the root directory of this source tree.
248
+ */const rt=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"}]]),lt=dt$1.div`
249
+ display: flex;
250
+ align-items: center;
251
+ padding: 0px 12px;
252
+ justify-content: space-between;
253
+ padding: ${d=>d.$theme.space.padding};
254
+ border-bottom: 1px solid ${d=>d.$theme.colors.border};
255
+ background: ${d=>d.$theme.colors.background};
256
+ min-height: 52px;
257
+ `,at=dt$1.div`
258
+ display: flex;
259
+ align-items: center;
260
+ gap: 8px;
261
+ flex: 1;
262
+ min-width: 0;
263
+ `,st=dt$1.div`
264
+ font-size: 14px;
265
+ font-weight: 500;
266
+ color: ${d=>d.$theme.colors.text};
267
+ white-space: nowrap;
268
+ overflow: hidden;
269
+ text-overflow: ellipsis;
270
+ `,it=dt$1.div`
271
+ font-size: 12px;
272
+ color: ${d=>d.$theme.colors.disabledText};
273
+ white-space: nowrap;
274
+ `,ct=dt$1.div`
275
+ display: flex;
276
+ align-items: center;
277
+ gap: 4px;
278
+ `,ne=dt$1.button`
279
+ display: flex;
280
+ align-items: center;
281
+ justify-content: center;
282
+ width: 32px;
283
+ height: 32px;
284
+ border: none;
285
+ border-radius: ${d=>d.$theme.space.radius};
286
+ background: ${d=>d.$active?d.$theme.colors.primary+"20":"transparent"};
287
+ color: ${d=>d.$active?d.$theme.colors.primary:d.$theme.colors.text};
288
+ cursor: pointer;
289
+ transition: all 0.2s ease;
290
+
291
+ /* 确保图标有默认颜色 */
292
+ & > svg {
293
+ color: currentColor;
294
+ stroke: currentColor;
295
+ }
296
+
297
+ &:hover {
298
+ background: ${d=>d.$theme.colors.primary+"10"};
299
+ color: ${d=>d.$theme.colors.primary};
300
+ }
301
+
302
+ &:disabled {
303
+ opacity: 0.5;
304
+ cursor: not-allowed;
305
+ }
306
+ `,dt=dt$1.div`
307
+ font-size: 12px;
308
+ color: ${d=>d.$theme.colors.disabledText};
309
+ min-width: 40px;
310
+ text-align: center;
311
+ `,mt={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:d="\u672A\u77E5\u6587\u4EF6",currentPage:e=1,totalPage:b=0,tools:i={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!0},styles:y,onPrevPage:Q,onNextPage:z,onZoomIn:xt,onZoomOut:B,onAnnotationToggle:k,onDownload:f,onRotateLeft:P,onRotateRight:T,onClose:A,scale:g=1,isAnnotating:E=!1,className:_})=>{const c=(y==null?void 0:y.theme)||mt;return console.log("Header\u7EC4\u4EF6\u6E32\u67D3 - currentPage:",e,"totalPage:",b),React__default.createElement(lt,{$theme:c,className:_},React__default.createElement(at,{$theme:c},React__default.createElement(st,{$theme:c},d)),React__default.createElement(ct,{$theme:c},i.navigation&&React__default.createElement(React__default.Fragment,null,React__default.createElement(ne,{$theme:c,onClick:Q,disabled:e<=1,title:"\u4E0A\u4E00\u9875"},React__default.createElement(Je,{size:16})),b>0&&React__default.createElement(it,{$theme:c},e," / ",b),React__default.createElement(ne,{$theme:c,onClick:z,disabled:!b||e>=b,title:"\u4E0B\u4E00\u9875"},React__default.createElement(Ke,{size:16}))),i.zoom&&React__default.createElement(React__default.Fragment,null,React__default.createElement(ne,{$theme:c,onClick:B,disabled:g<=.3,title:"\u7F29\u5C0F"},React__default.createElement(rt,{size:16})),React__default.createElement(dt,{$theme:c},Math.round(g*100),"%"),React__default.createElement(ne,{$theme:c,onClick:xt,disabled:g>=3,title:"\u653E\u5927"},React__default.createElement(ut,{size:16}))),i.annotation&&React__default.createElement(ne,{$theme:c,$active:E,onClick:k,title:E?"\u9000\u51FA\u6807\u6CE8":"\u5F00\u59CB\u6807\u6CE8"},React__default.createElement(et,{size:16})),i.download&&React__default.createElement(ne,{$theme:c,onClick:f,title:"\u4E0B\u8F7D"},React__default.createElement(Qe,{size:16})),i.rotate&&React__default.createElement(React__default.Fragment,null,React__default.createElement(ne,{$theme:c,onClick:P,title:"\u5411\u5DE6\u65CB\u8F6C"},React__default.createElement(tt,{size:16})),React__default.createElement(ne,{$theme:c,onClick:T,title:"\u5411\u53F3\u65CB\u8F6C"},React__default.createElement(ot,{size:16}))),i.close&&React__default.createElement(ne,{$theme:c,onClick:A,title:"\u5173\u95ED"},React__default.createElement(nt,{size:16}))))});const gt=()=>{try{if(xe()){console.log("PDF Worker \u5DF2\u7ECF\u6CE8\u518C");return}const d="/worker/pdf.worker.min.js";De(d),console.log("PDF Worker \u5DF2\u901A\u8FC7\u7EDF\u4E00\u51FD\u6570\u6CE8\u518C:",d)}catch(d){throw console.error("PDF Worker \u6CE8\u518C\u5931\u8D25:",d),d}},be=(d,e,b)=>{if(!d&&!e)return"unknown";const i=d||"",y=e||"";return i.toLowerCase().endsWith(".pdf")||y==="pdf"?"pdf":i.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)||y==="image"?"image":i.toLowerCase().endsWith(".md")||y==="markdown"?y==="markdown_table"?"markdown_table":"markdown":i.toLowerCase().match(/\.(html|htm)$/)||y==="html"?"html":i.toLowerCase().match(/\.(txt|log|json|xml|css|js|ts)$/)||y==="text"?"text":"unknown"},ft=async(d,e={})=>{console.log("=== parsePdfFile \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",{data:typeof d,options:e});try{gt();let b;if(typeof d=="string"){console.log("\u4ECEURL\u52A0\u8F7DPDF:",d);const Q=pdfExports.getDocument({url:d,httpHeaders:e.token?{Authorization:e.token}:void 0});console.log("=== PDF\u52A0\u8F7D\u4EFB\u52A1\u8BE6\u7EC6\u4FE1\u606F ==="),console.log("\u52A0\u8F7D\u4EFB\u52A1\u5BF9\u8C61:",Q),console.log("\u52A0\u8F7D\u4EFB\u52A1\u7C7B\u578B:",typeof Q),console.log("\u52A0\u8F7D\u4EFB\u52A1\u65B9\u6CD5:",Object.getOwnPropertyNames(Object.getPrototypeOf(Q))),console.log("\u52A0\u8F7D\u4EFB\u52A1\u5C5E\u6027:",Object.keys(Q)),b=await Q.promise,console.log("=== PDF\u6587\u6863\u52A0\u8F7D\u5B8C\u6210 ==="),console.log("PDF\u6587\u6863\u5BF9\u8C61:",b),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof b),console.log("PDF\u6587\u6863\u65B9\u6CD5:",Object.getOwnPropertyNames(Object.getPrototypeOf(b))),console.log("PDF\u6587\u6863\u5C5E\u6027:",Object.keys(b))}else{console.log("\u4ECEArrayBuffer\u52A0\u8F7DPDF");const Q=pdfExports.getDocument({data:d});console.log("=== PDF\u52A0\u8F7D\u4EFB\u52A1\u8BE6\u7EC6\u4FE1\u606F ==="),console.log("\u52A0\u8F7D\u4EFB\u52A1\u5BF9\u8C61:",Q),console.log("\u52A0\u8F7D\u4EFB\u52A1\u7C7B\u578B:",typeof Q),b=await Q.promise,console.log("=== PDF\u6587\u6863\u52A0\u8F7D\u5B8C\u6210 ==="),console.log("PDF\u6587\u6863\u5BF9\u8C61:",b),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof b)}const i=b.numPages;console.log("PDF\u52A0\u8F7D\u6210\u529F\uFF0C\u603B\u9875\u6570:",i),console.log("PDF\u6307\u7EB9:",b.fingerprints),console.log("PDF\u4F20\u8F93\u5BF9\u8C61:",b._transport);const y={type:"pdf",content:{type:"pdf",document:b,totalPages:i},fileName:e.fileName,fileType:"pdf",totalPages:i};return console.log("=== \u89E3\u6790\u7ED3\u679C\u8BE6\u7EC6\u4FE1\u606F ==="),console.log("\u89E3\u6790\u7ED3\u679C:",y),console.log("\u89E3\u6790\u7ED3\u679C\u7C7B\u578B:",typeof y),console.log("\u89E3\u6790\u7ED3\u679C\u5C5E\u6027:",Object.keys(y)),console.log("\u5185\u5BB9\u5BF9\u8C61:",y.content),console.log("\u6587\u6863\u5BF9\u8C61:",y.content.document),y}catch(b){console.error("PDF\u89E3\u6790\u5931\u8D25:",b),console.error("\u9519\u8BEF\u8BE6\u60C5:",{message:b instanceof Error?b.message:"\u672A\u77E5\u9519\u8BEF",stack:b instanceof Error?b.stack:void 0,name:b instanceof Error?b.name:void 0,url:typeof d=="string"?d:"ArrayBuffer",options:e});let i="PDF\u89E3\u6790\u5931\u8D25";return b instanceof Error&&(b.message.includes("Invalid PDF structure")?i="PDF\u6587\u4EF6\u7ED3\u6784\u65E0\u6548\uFF0C\u53EF\u80FD\u6587\u4EF6\u635F\u574F\u6216\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u4EF6":b.message.includes("Failed to fetch")?i="PDF\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u548C\u6587\u4EF6URL":b.message.includes("Worker")?i="PDF\u89E3\u6790\u5668\u521D\u59CB\u5316\u5931\u8D25\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u91CD\u8BD5":i=`PDF\u89E3\u6790\u5931\u8D25: ${b.message}`),{type:"pdf",content:null,fileName:e.fileName,fileType:"pdf",error:i}}},Et=async(d,e={})=>{console.log("=== parseImageFile \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",{data:typeof d,options:e});try{let b;if(typeof d=="string")console.log("\u4ECEURL\u52A0\u8F7D\u56FE\u7247:",d),b=d;else{console.log("\u4ECEArrayBuffer\u52A0\u8F7D\u56FE\u7247");const y=new Blob([d]);b=URL.createObjectURL(y)}console.log("\u5F00\u59CB\u9884\u52A0\u8F7D\u56FE\u7247:",b),await new Promise((y,Q)=>{const z=new Image;z.onload=()=>{console.log("\u56FE\u7247\u9884\u52A0\u8F7D\u6210\u529F:",b),console.log("\u56FE\u7247\u5C3A\u5BF8:",z.width,"x",z.height),y()},z.onerror=()=>{console.error("\u56FE\u7247\u9884\u52A0\u8F7D\u5931\u8D25:",b),Q(new Error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"))};const xt=setTimeout(()=>{Q(new Error("\u56FE\u7247\u52A0\u8F7D\u8D85\u65F6"))},1e4);z.onload=()=>{clearTimeout(xt),console.log("\u56FE\u7247\u9884\u52A0\u8F7D\u6210\u529F:",b),console.log("\u56FE\u7247\u5C3A\u5BF8:",z.width,"x",z.height),y()},z.onerror=()=>{clearTimeout(xt),console.error("\u56FE\u7247\u9884\u52A0\u8F7D\u5931\u8D25:",b),Q(new Error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"))},z.src=b});const i={type:"image",content:{type:"image",url:b},fileName:e.fileName,fileType:"image"};return console.log("=== parseImageFile \u7ED3\u679C ==="),console.log("result:",i),i}catch(b){return console.error("\u56FE\u7247\u89E3\u6790\u5931\u8D25:",b),{type:"image",content:null,fileName:e.fileName,fileType:"image",error:`\u56FE\u7247\u89E3\u6790\u5931\u8D25: ${b instanceof Error?b.message:"\u672A\u77E5\u9519\u8BEF"}`}}},ht=async(d,e={})=>{try{let b;if(typeof d=="string"){const i=await fetch(d,{headers:e.token?{Authorization:e.token}:void 0});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);b=await i.text()}else b=new TextDecoder("utf-8").decode(d);return{type:"text",content:{type:"text",text:b},fileName:e.fileName,fileType:"text"}}catch(b){return{type:"text",content:null,fileName:e.fileName,fileType:"text",error:`\u6587\u672C\u89E3\u6790\u5931\u8D25: ${b instanceof Error?b.message:"\u672A\u77E5\u9519\u8BEF"}`}}},Ft=async(d,e={})=>{try{let b;if(typeof d=="string"){const i=await fetch(d,{headers:e.token?{Authorization:e.token}:void 0});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);b=await i.text()}else b=new TextDecoder("utf-8").decode(d);return{type:"markdown",content:{type:"markdown",text:b},fileName:e.fileName,fileType:"markdown"}}catch(b){return{type:"markdown",content:null,fileName:e.fileName,fileType:"markdown",error:`Markdown\u89E3\u6790\u5931\u8D25: ${b instanceof Error?b.message:"\u672A\u77E5\u9519\u8BEF"}`}}},pt=async(d,e={})=>{console.log("=== parseHtmlFile \u5F00\u59CB ==="),console.log("\u8F93\u5165\u6570\u636E:",{data:typeof d,options:e});try{let b;if(typeof d=="string"){console.log("\u4ECEURL\u52A0\u8F7DHTML:",d);const y=await fetch(d,{headers:e.token?{Authorization:e.token}:void 0});if(console.log("HTTP\u54CD\u5E94\u72B6\u6001:",y.status,y.statusText),!y.ok)throw new Error(`HTTP ${y.status}: ${y.statusText}`);b=await y.text(),console.log("HTML\u5185\u5BB9\u957F\u5EA6:",b.length),console.log("HTML\u5185\u5BB9\u524D500\u5B57\u7B26:",b.substring(0,500))}else console.log("\u4ECEArrayBuffer\u52A0\u8F7DHTML"),b=new TextDecoder("utf-8").decode(d);const i={type:"html",content:{type:"html",text:b},fileName:e.fileName,fileType:"html"};return console.log("=== parseHtmlFile \u7ED3\u679C ==="),console.log("result:",i),console.log("result.content.text \u957F\u5EA6:",i.content.text.length),console.log("result.content.text \u524D200\u5B57\u7B26:",i.content.text.substring(0,200)),i}catch(b){return console.error("HTML\u89E3\u6790\u5931\u8D25:",b),{type:"html",content:null,fileName:e.fileName,fileType:"html",error:`HTML\u89E3\u6790\u5931\u8D25: ${b instanceof Error?b.message:"\u672A\u77E5\u9519\u8BEF"}`}}},Ct=async(d,e={})=>{switch(be(e.fileName,e.fileType)){case"pdf":return await ft(d,e);case"image":return await Et(d,e);case"text":return await ht(d,e);case"markdown":case"markdown_table":return await Ft(d,e);case"html":return await pt(d,e);default:return{type:"unknown",content:null,fileName:e.fileName,fileType:e.fileType,error:"\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B"}}};dt$1.div`
312
+ display: flex;
313
+ flex-direction: column;
314
+ height: 100%;
315
+ width: 100%;
316
+ background: ${d=>d.$theme.colors.background};
317
+ border: 1px solid ${d=>d.$theme.colors.border};
318
+ border-radius: ${d=>d.$theme.space.radius};
319
+ overflow: hidden;
320
+ min-height: 0; /* 确保flex子元素可以收缩 */
321
+ `;dt$1.div`
322
+ display: flex;
323
+ align-items: center;
324
+ justify-content: center;
325
+ height: 100%;
326
+ color: ${d=>d.$theme.colors.disabledText};
327
+ font-size: 14px;
328
+ `;dt$1.div`
329
+ display: flex;
330
+ flex-direction: column;
331
+ align-items: center;
332
+ justify-content: center;
333
+ height: 100%;
334
+ color: ${d=>d.$theme.colors.error};
335
+ text-align: center;
336
+ padding: 20px;
337
+ `;const xe=()=>!!pdfExports.GlobalWorkerOptions.workerSrc,yt=()=>pdfExports.GlobalWorkerOptions.workerSrc,De=(d="/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=d,console.log("PDF Worker \u6CE8\u518C\u6210\u529F:",d)}catch(e){console.error("PDF Worker \u6CE8\u518C\u5931\u8D25:",e)}},HeaderContainer=dt$1.div`
338
+ display: flex;
339
+ align-items: center;
340
+ padding: 0px 12px;
341
+ justify-content: space-between;
342
+ padding: ${d=>d.$theme.space.padding};
343
+ border-bottom: 1px solid ${d=>d.$theme.colors.border};
344
+ background: ${d=>d.$theme.colors.background};
345
+ min-height: 52px;
346
+ `,FileInfo=dt$1.div`
347
+ display: flex;
348
+ align-items: center;
349
+ gap: 8px;
350
+ flex: 1;
351
+ min-width: 0;
352
+ `,FileName=dt$1.div`
353
+ font-size: 14px;
354
+ font-weight: 500;
355
+ color: ${d=>d.$theme.colors.text};
356
+ white-space: nowrap;
357
+ overflow: hidden;
358
+ text-overflow: ellipsis;
359
+ `,PageInfo=dt$1.div`
360
+ font-size: 12px;
361
+ color: ${d=>d.$theme.colors.disabledText};
362
+ white-space: nowrap;
363
+ `,ToolBar=dt$1.div`
364
+ display: flex;
365
+ align-items: center;
366
+ gap: 4px;
367
+ `,ToolButton=dt$1.button`
368
+ display: flex;
369
+ align-items: center;
370
+ justify-content: center;
371
+ width: 32px;
372
+ height: 32px;
373
+ border: none;
374
+ border-radius: ${d=>d.$theme.space.radius};
375
+ background: ${d=>d.$active?d.$theme.colors.primary+"20":"transparent"};
376
+ color: ${d=>d.$active?d.$theme.colors.primary:d.$theme.colors.text};
377
+ cursor: pointer;
378
+ transition: all 0.2s ease;
379
+
380
+ &:hover {
381
+ background: ${d=>d.$theme.colors.primary+"10"};
382
+ color: ${d=>d.$theme.colors.primary};
383
+ }
384
+
385
+ &:disabled {
386
+ opacity: 0.5;
387
+ cursor: not-allowed;
388
+ }
389
+ `,ZoomInfo=dt$1.div`
390
+ font-size: 12px;
391
+ color: ${d=>d.$theme.colors.disabledText};
392
+ min-width: 40px;
393
+ text-align: center;
394
+ `,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:d="\u672A\u77E5\u6587\u4EF6",currentPage:e=1,totalPage:b=0,tools:i={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!0},styles:y,onPrevPage:Q,onNextPage:z,onZoomIn:xt,onZoomOut:B,onAnnotationToggle:k,onDownload:f,onRotateLeft:P,onRotateRight:T,onClose:A,scale:g=1,isAnnotating:E=!1,className:_})=>{const c=(y==null?void 0:y.theme)||defaultTheme$1;return console.log("Header\u7EC4\u4EF6\u6E32\u67D3 - currentPage:",e,"totalPage:",b),jsxs(HeaderContainer,{$theme:c,className:_,children:[jsx(FileInfo,{$theme:c,children:jsx(FileName,{$theme:c,children:d})}),jsxs(ToolBar,{$theme:c,children:[i.navigation&&jsxs(Fragment,{children:[jsx(ToolButton,{$theme:c,onClick:Q,disabled:e<=1,title:"\u4E0A\u4E00\u9875",children:jsx(ChevronLeft,{size:16})}),b>0&&jsxs(PageInfo,{$theme:c,children:[e," / ",b]}),jsx(ToolButton,{$theme:c,onClick:z,disabled:!b||e>=b,title:"\u4E0B\u4E00\u9875",children:jsx(ChevronRight,{size:16})})]}),i.zoom&&jsxs(Fragment,{children:[jsx(ToolButton,{$theme:c,onClick:B,disabled:g<=.3,title:"\u7F29\u5C0F",children:jsx(ZoomOut,{size:16})}),jsxs(ZoomInfo,{$theme:c,children:[Math.round(g*100),"%"]}),jsx(ToolButton,{$theme:c,onClick:xt,disabled:g>=3,title:"\u653E\u5927",children:jsx(ZoomIn,{size:16})})]}),i.annotation&&jsx(ToolButton,{$theme:c,$active:E,onClick:k,title:E?"\u9000\u51FA\u6807\u6CE8":"\u5F00\u59CB\u6807\u6CE8",children:jsx(Pencil,{size:16})}),i.download&&jsx(ToolButton,{$theme:c,onClick:f,title:"\u4E0B\u8F7D",children:jsx(Download,{size:16})}),i.rotate&&jsxs(Fragment,{children:[jsx(ToolButton,{$theme:c,onClick:P,title:"\u5411\u5DE6\u65CB\u8F6C",children:jsx(RotateCcw,{size:16})}),jsx(ToolButton,{$theme:c,onClick:T,title:"\u5411\u53F3\u65CB\u8F6C",children:jsx(RotateCw,{size:16})})]}),i.close&&jsx(ToolButton,{$theme:c,onClick:A,title:"\u5173\u95ED",children:jsx(X,{size:16})})]})]})}),ReaderContainer=dt$1.div`
395
+ display: flex;
396
+ flex-direction: column;
397
+ height: 100%;
398
+ width: 100%;
399
+ background: ${d=>d.$theme.colors.background};
400
+ border: 1px solid ${d=>d.$theme.colors.border};
401
+ border-radius: ${d=>d.$theme.space.radius};
402
+ overflow: hidden;
403
+ min-height: 0;
404
+ position: relative; // 添加相对定位,用于loading遮罩的绝对定位
405
+
406
+ /* 添加动画样式 */
407
+ @keyframes spin {
408
+ 0% {
409
+ transform: rotate(0deg);
410
+ }
411
+ 100% {
412
+ transform: rotate(360deg);
413
+ }
414
+ }
415
+ `,DefaultLoadingComponent=({status:d,theme:e})=>jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px",background:e.colors.background},children:[jsxs("div",{style:{position:"relative",width:"80px",height:"80px",marginBottom:"24px"},children:[jsx("div",{style:{width:"60px",height:"80px",background:e.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 ${e.colors.background} transparent transparent`}})}),jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",borderRadius:"50%",background:e.colors.background,animation:"pulse 1.5s ease-in-out infinite"}})]}),jsx("div",{style:{fontSize:"16px",fontWeight:"500",color:e.colors.text,marginBottom:"8px",textAlign:"center"},children:d}),jsx("div",{style:{width:"200px",height:"4px",background:e.colors.border,borderRadius:"2px",overflow:"hidden",position:"relative"},children:jsx("div",{style:{width:"30%",height:"100%",background:e.colors.primary,borderRadius:"2px",animation:"loading-progress 2s ease-in-out infinite"}})}),jsx("style",{children:`
416
+ @keyframes pulse {
417
+ 0%, 100% {
418
+ opacity: 1;
419
+ transform: translate(-50%, -50%) scale(1);
420
+ }
421
+ 50% {
422
+ opacity: 0.5;
423
+ transform: translate(-50%, -50%) scale(1.1);
424
+ }
425
+ }
426
+
427
+ @keyframes loading-progress {
428
+ 0% {
429
+ transform: translateX(-100%);
430
+ }
431
+ 50% {
432
+ transform: translateX(0%);
433
+ }
434
+ 100% {
435
+ transform: translateX(100%);
436
+ }
437
+ }
438
+ `})]}),ErrorContainer=dt$1.div`
439
+ display: flex;
440
+ flex-direction: column;
441
+ align-items: center;
442
+ justify-content: center;
443
+ height: 100%;
444
+ color: ${d=>d.$theme.colors.error};
445
+ text-align: center;
446
+ padding: 20px;
447
+ `,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:d,fileName:e,fileType:b,csrfToken:i,initialPage:y=1,initialZoom:Q=1,totalPages:z,annotations:xt=[],pageSize:B=5,streamApiUrl:k=DEFAULT_STREAM_API_URL,authorization:f,eventsEmit:P=()=>{},tools:T,styles:A,customComponents:g,className:E,headerClass:_,contentClass:c})=>{const[C,I]=useState(!0),[m,r]=useState("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[h,a]=useState(null),[l,u]=useState(y),[R,o]=useState(z||0),[F,$]=useState(Q),[wt,U]=useState(0),[G,H]=useState(null),[_t,D]=useState(null),[W,J]=useState(""),[S,n]=useState(null),[s,p]=useState(null),[M,O]=useState({}),L=useRef(!1),V=useRef(!1),At=useRef({}),It=useRef({}),Bt=useRef(null),jt=useRef(null),Ut=useRef(y),Xt=useRef(0);Xt.current+=1,console.log("[GientechStreamReader] render count:",Xt.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:b,currentPage:l,totalPages:R,hasMarkdown:!!W,hasImage:!!_t,hasText:!!S,hasHtml:!!s,isLoading:C,error:h});const vt=(A==null?void 0:A.theme)||defaultTheme;useEffect(()=>{L.current=!1,V.current=!1},[b,d]);const v=useCallback(()=>{const Y={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let Lt;switch(b){case"pdf":case"pdf_slides":Lt={...Y,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":Lt={...Y,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":Lt={...Y,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":Lt={...Y,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:Lt=Y}return T?{...Lt,...T}:Lt},[b,T])(),N=useCallback((Y,Lt)=>{const Vt=Math.floor((Y-1)/Lt)*Lt+1;return`${Vt}-${Vt+Lt-1}`},[]),Z=useCallback(async Y=>{var x;if(!(b==="pdf"||b==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7\u7F13\u5B58\u68C0\u67E5`),null;console.log(`\u68C0\u67E5\u9875\u9762 ${Y} \u662F\u5426\u5728\u7F13\u5B58\u4E2D`);const Vt=At.current[Y];if(Vt&&Date.now()-Vt.timestamp<CACHE_EXPIRY_TIME)return console.log(`\u4F7F\u7528\u5355\u4E2A\u9875\u9762\u7F13\u5B58: ${Y}`),Vt.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${Y}`),Vt.pdfDocument):null;const Wt=N(Y,B),w=It.current[Wt];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${Wt}, \u5B58\u5728: ${!!w}, \u5305\u542B\u9875\u9762: ${((x=w==null?void 0:w.pages)==null?void 0:x.join(", "))||"\u65E0"}`),w&&Date.now()-w.timestamp<CACHE_EXPIRY_TIME){if(w.pages.includes(Y))return console.log(`\u4F7F\u7528chunk\u7F13\u5B58: ${Y} (chunk: ${Wt})`),w.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${Y}`),w.pdfDocument):null;console.log(`\u9875\u9762 ${Y} \u4E0D\u5728chunk ${Wt} \u4E2D\uFF0Cchunk\u5305\u542B: ${w.pages.join(", ")}`)}return console.log(`\u9875\u9762 ${Y} \u4E0D\u5728\u4EFB\u4F55\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42`),null},[B,N,b]),St=useCallback(async Y=>{var Lt;try{if(!(b==="pdf"||b==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const Wt=Math.floor((Y-1)/B)*B+1,w=N(Y,B);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${Wt} (\u5305\u542B\u9875\u9762 ${Wt}-${Wt+B-1})`);const x={"Content-Type":"application/json"};f&&(x.Authorization=f),i&&(x["X-CSRF-TOKEN-IN"]=i);const q={convertedFilePath:d,pageNo:Wt,pageSize:B},Dt=await axios.post(k,q,{headers:x,responseType:"arraybuffer"}),Ot=Dt.headers["x-csrf-token-out"]||Dt.headers["X-CSRF-TOKEN-OUT"];Ot&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",Ot),P("request_finish",Ot));const Ht=Array.from({length:B},(Yt,ee)=>Wt+ee);return It.current[w]={data:Dt.data,pages:Ht,timestamp:Date.now(),totalPages:z},console.log(`\u7F13\u5B58PDF chunk\u6570\u636E: ${w}, \u5305\u542B\u9875\u9762: ${Ht.join(", ")}, \u8BF7\u6C42\u7684\u9875\u9762: ${Y}`),console.log("\u5F53\u524D\u6240\u6709\u7F13\u5B58:",Object.keys(It.current)),Dt.data}catch(Vt){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",Vt),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((Lt=Vt.response)==null?void 0:Lt.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[k,d,B,f,N,z,R,b,P]),Nt=useCallback(async(Y,Lt=!1)=>{var Wt;if(!Y)return;if(!(b==="pdf"||b==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{Lt?(I(!0),r("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(I(!0),r(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${Y} \u9875...`)),a(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${Y}, \u521D\u59CB\u52A0\u8F7D: ${Lt}`);const w=await Z(Y);if(w)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${Y}`),H(w),I(!1),r(""),console.log(`\u9875\u9762 ${Y} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),w;const x=await St(Y),q=await Ct(x,{fileName:e||"Stream\u6587\u6863",fileType:"pdf",token:f});if(q.error)throw new Error(q.error);if(q.type!=="pdf"||!((Wt=q.content)!=null&&Wt.document))throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u6863");const Dt=q.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",Dt),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof Dt),console.log("PDF\u6587\u6863\u65B9\u6CD5:",Dt?Object.getOwnPropertyNames(Object.getPrototypeOf(Dt)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",Dt?Dt.numPages:"\u65E0\u9875\u6570"),console.log("\u5F53\u524D\u8BF7\u6C42\u7684\u9875\u9762:",Y),console.log("PDF\u6587\u6863\u5305\u542B\u7684\u9875\u9762\u8303\u56F4:",Dt?`1-${Dt.numPages}`:"\u65E0\u9875\u6570"),H(Dt);const Ot=N(Y,B);if(It.current[Ot]&&(It.current[Ot].pdfDocument=Dt,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${Ot}`)),z)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${z}`),o(z);else if(Dt&&Dt.numPages){const Ht=Dt.numPages;console.log(`\u7528\u6237\u672A\u4F20\u5165\u603B\u9875\u6570\uFF0C\u4ECEPDF\u6587\u6863\u83B7\u53D6\u5B9E\u9645\u603B\u9875\u6570: ${Ht}`),o(Ht)}return I(!1),r(""),console.log(`\u9875\u9762 ${Y} \u52A0\u8F7D\u5B8C\u6210`),Dt}catch(w){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",w),a(w.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),I(!1),r(""),w}},[St,e,f,R,Z,N,B,b]),zt=useCallback(Y=>{if(!(b==="pdf"||b==="pdf_slides"))return!1;const Vt=At.current[Y];if(Vt&&Date.now()-Vt.timestamp<CACHE_EXPIRY_TIME)return!!Vt.pdfDocument;const Wt=N(Y,B),w=It.current[Wt];return w&&Date.now()-w.timestamp<CACHE_EXPIRY_TIME?w.pages.includes(Y)&&!!w.pdfDocument:!1},[B,N,b]),qt=useCallback(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const Y=Bt.current;return Y&&Date.now()-Y.timestamp<CACHE_EXPIRY_TIME?(console.log("\u4F7F\u7528markdown\u5185\u5BB9\u7F13\u5B58"),Y.data):(console.log("markdown\u5185\u5BB9\u4E0D\u5728\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42"),null)},[]),bt=useCallback(async()=>{var Y;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const Lt={"Content-Type":"application/json"};f&&(Lt.Authorization=f),i&&(Lt["X-CSRF-TOKEN-IN"]=i);const Vt={convertedFilePath:d};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",Vt);const Wt=await axios.post(k,Vt,{headers:Lt,responseType:"text"}),w=Wt.headers["x-csrf-token-out"]||Wt.headers["X-CSRF-TOKEN-OUT"];return w&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",w),P("request_finish",w)),console.log("markdown\u54CD\u5E94\u72B6\u6001:",Wt.status),console.log("markdown\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((Y=Wt.data)==null?void 0:Y.length)||0),Wt.data}catch(Lt){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",Lt),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${Lt.message}`)}},[d,f,k,P]),Jt=useCallback(async()=>{try{I(!0),r("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),a(null),console.log("\u5F00\u59CB\u52A0\u8F7D\u5B8C\u6574markdown\u6587\u6863");const Y=qt();if(Y)return console.log("\u4F7F\u7528\u7F13\u5B58\u7684markdown\u5185\u5BB9"),J(Y),I(!1),r(""),Y;const Lt=await bt();return Bt.current={data:Lt,timestamp:Date.now()},J(Lt),I(!1),r(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),Lt}catch(Y){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",Y),a(Y.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),I(!1),r(""),Y}},[bt,qt]),Kt=useCallback(async()=>{try{const Y={"Content-Type":"application/json"};f&&(Y.Authorization=f),i&&(Y["X-CSRF-TOKEN-IN"]=i);const Lt={convertedFilePath:d},Vt=await axios.post(k,Lt,{headers:Y,responseType:"arraybuffer"}),Wt=Vt.headers["x-csrf-token-out"]||Vt.headers["X-CSRF-TOKEN-OUT"];return Wt&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",Wt),P("request_finish",Wt)),Vt.data}catch(Y){throw console.error("\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25:",Y),new Error(`\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25: ${Y.message}`)}},[d,f,k,P]),ce=useCallback(async()=>{try{I(!0),r("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),a(null);const Y=await Kt(),Lt=await Ct(Y,{fileName:e||"\u56FE\u7247",fileType:"image",token:f});if(Lt.error)throw new Error(Lt.error);if(Lt.type!=="image"||!Lt.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return D(Lt.content),I(!1),r(""),Lt.content}catch(Y){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",Y),a(Y.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),I(!1),r(""),Y}},[f,e,Kt]),oe=useCallback(async()=>{var Y;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}`);const Lt={"Content-Type":"application/json"};f&&(Lt.Authorization=f),i&&(Lt["X-CSRF-TOKEN-IN"]=i);const Vt={convertedFilePath:d};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",Vt);const Wt=await axios.post(k,Vt,{headers:Lt,responseType:"arraybuffer"}),w=Wt.headers["x-csrf-token-out"]||Wt.headers["X-CSRF-TOKEN-OUT"];return w&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",w),P("request_finish",w)),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u72B6\u6001:",Wt.status),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((Y=Wt.data)==null?void 0:Y.byteLength)||0),Wt.data}catch(Lt){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",Lt),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${Lt.message}`)}},[d,f,k,P]),me=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()),L.current){console.log(`\u901A\u7528\u6587\u6863\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}`);return}if(V.current){console.log(`\u901A\u7528\u6587\u6863\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}`);return}const Y=`${b}_${d}`,Lt=M[Y];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${Y}, \u7F13\u5B58\u5B58\u5728: ${!!Lt}, \u7F13\u5B58\u65F6\u95F4: ${Lt?Date.now()-Lt.timestamp:"N/A"}ms`),Lt&&Date.now()-Lt.timestamp<CACHE_EXPIRY_TIME)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}`),b==="text"&&Lt.content?n(Lt.content):b==="html"&&Lt.content&&p(Lt.content),u(1),o(z||1),I(!1),r(""),Lt.content;L.current=!0,I(!0),r(`\u6B63\u5728\u52A0\u8F7D${b}\u6587\u6863...`),a(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}`);const Vt=await oe(),Wt=await Ct(Vt,{fileName:e||`${b}\u6587\u6863`,fileType:b,token:f});if(Wt.error)throw new Error(Wt.error);let w=null;if(Wt.type==="text"&&Wt.content)n(Wt.content),w=Wt.content;else if(Wt.type==="html"&&Wt.content)p(Wt.content),w=Wt.content;else if(Wt.type==="image"&&Wt.content)D(Wt.content),w=Wt.content;else{const q=new TextDecoder("utf-8").decode(Vt);n({type:"text",content:q}),w={type:"text",content:q}}if(w){const x=`${b}_${d}`,q={...M,[x]:{content:w,timestamp:Date.now()}};O(q),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}, \u7F13\u5B58\u952E: ${x}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",q)}return I(!1),r(""),L.current=!1,V.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${b}`),Wt}catch(Y){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",Y),a(Y.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),I(!1),r(""),L.current=!1,V.current=!0,Y}},[oe,e,f]),Qt=useCallback(async Y=>{if(Y===Ut.current)return;if(C){console.log("\u9875\u9762\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42");return}if(!(b==="pdf"||b==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}console.log("PDF\u9875\u9762\u53D8\u5316:",Y,"\u5F53\u524D\u9875:",Ut.current),console.log(`\u9875\u9762 ${Y} \u662F\u5426\u5728\u7F13\u5B58\u4E2D:`,zt(Y)),Ut.current=Y,u(Y);try{await Nt(Y,!1),P("pageChange",{pageNumber:Y,totalPages:z||R})}catch(Vt){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",Vt);const Wt=Ut.current;u(Wt)}},[Nt,R,P,zt,C,b]);useEffect(()=>{Ut.current=l,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",l)},[l]);const re=useCallback(Y=>{$(Y),P("zoomChange",{scale:Y})},[P]),pe=useCallback(()=>{P("viewer:close")},[P]),Ee=useCallback(()=>{const Y=Math.min(3,F+.1);re(Y)},[F,re]),Gt=useCallback(()=>{const Y=Math.max(.3,F-.1);re(Y)},[F,re]),Pt=useCallback(()=>{const Y=(wt-90+360)%360;U(Y),P("rotateChange",{rotation:Y})},[wt,P]),Mt=useCallback(()=>{const Y=(wt+90)%360;U(Y),P("rotateChange",{rotation:Y})},[wt,P]),te=useCallback(()=>{if(!(b==="pdf"||b==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const Lt=Ut.current-1;Lt>=1&&Qt(Lt)},[Qt,b]),ge=useCallback(()=>{if(!(b==="pdf"||b==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${b} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const Lt=Ut.current+1,Vt=z||R;Vt&&Lt<=Vt&&Qt(Lt)},[R,Qt,b]),de=useCallback(()=>{const Y=Date.now();Object.keys(At.current).forEach(Lt=>{const Vt=At.current[parseInt(Lt)];Y-Vt.timestamp>CACHE_EXPIRY_TIME&&(delete At.current[parseInt(Lt)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${Lt}`))}),Object.keys(It.current).forEach(Lt=>{const Vt=It.current[Lt];Y-Vt.timestamp>CACHE_EXPIRY_TIME&&(delete It.current[Lt],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${Lt}`))}),Bt.current&&Y-Bt.current.timestamp>CACHE_EXPIRY_TIME&&(Bt.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),O(Lt=>{const Vt={...Lt};return Object.keys(Vt).forEach(Wt=>{Y-Vt[Wt].timestamp>CACHE_EXPIRY_TIME&&(delete Vt[Wt],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${Wt}`))}),Vt})},[]),j=useCallback(()=>{if(e)return e;try{const Y=new URL(d);return decodeURIComponent(Y.pathname.split("/").pop()||"")||"Stream\u6587\u6863"}catch{const Y=d.split("/");return decodeURIComponent(Y[Y.length-1])||"Stream\u6587\u6863"}},[d,e]);if(useEffect(()=>{const Y=setInterval(de,CACHE_EXPIRY_TIME);return()=>clearInterval(Y)},[de]),useEffect(()=>()=>{At.current={},It.current={},Bt.current=null,O({}),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:y,fileType:b}),(async()=>{try{const Lt=b==="pdf"||b==="pdf_slides",Vt=Lt&&y||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",b,"\u6709\u6548\u9875\u7801:",Vt,"\u662F\u5426PDF:",Lt),b==="markdown"||b==="markdown_table"?(await Jt(),u(1),o(z||1),P("pageChange",{pageNumber:1,totalPages:z||1})):b==="image"?(await ce(),u(1),o(z||1),U(0),P("pageChange",{pageNumber:1,totalPages:z||1})):Lt?(await Nt(Vt,!0),u(Vt),setTimeout(()=>{P("pageChange",{pageNumber:Vt,totalPages:z||R})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",b),await me(),u(1),o(z||1),P("pageChange",{pageNumber:1,totalPages:z||1}))}catch(Lt){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",Lt)}})()},[y,b,d]),h)return jsx(ReaderContainer,{$theme:vt,className:E,children:g!=null&&g.ErrorComponent?jsx(g.ErrorComponent,{error:h,theme:vt}):jsxs(ErrorContainer,{$theme:vt,children:[jsx("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),jsx("div",{style:{fontSize:"12px",marginTop:"8px"},children:h})]})});const $t=useMemo(()=>Math.floor((l-1)/B)*B+1,[l,B]);return C?jsxs(ReaderContainer,{$theme:vt,className:E,children:[jsx(Header,{fileName:j(),currentPage:l,totalPage:R,scale:F,isAnnotating:!1,tools:v,styles:A,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:pe,className:_}),g!=null&&g.LoadingComponent?jsx(g.LoadingComponent,{status:m,theme:vt}):jsx(DefaultLoadingComponent,{status:m,theme:vt})]}):jsxs(ReaderContainer,{$theme:vt,className:E,children:[jsx(Header,{fileName:j(),currentPage:l,totalPage:R,scale:F,isAnnotating:!1,tools:{...v,navigation:b==="pdf"||b==="pdf_slides"?v.navigation:!1,rotate:b==="image"},styles:A,onPrevPage:te,onNextPage:ge,onZoomIn:Ee,onZoomOut:Gt,onRotateLeft:b==="image"?Pt:void 0,onRotateRight:b==="image"?Mt:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:pe,className:_}),b==="markdown"||b==="markdown_table"?jsxs("div",{ref:jt,style:{flex:1,overflow:"auto",position:"relative"},className:c,children:[jsx(Ue,{data:{content:W,...j()&&{fileName:j()},...b&&{fileType:b},...R&&{totalPages:R}},annotationData:xt,totalPage:R,currentPage:l,scale:F,eventsEmit:(Y,Lt)=>{console.log("Fviewer\u4E8B\u4EF6:",Y,Lt),P(Y==="md_annotation_add"?"md_annotation_add":Y==="table_annotation_add"?"table_annotation_add":Y,Lt)},styles:A,tools:v,customComponents:g,contentClass:c}),(console.log("=== \u4F20\u9012\u7ED9Fviewer\u7684markdown\u5185\u5BB9 ==="),console.log("markdownContent:",W),console.log("markdownContent\u957F\u5EA6:",W.length),console.log("markdownContent\u524D100\u5B57\u7B26:",W.substring(0,100)),console.log("markdownContent\u540E100\u5B57\u7B26:",W.substring(W.length-100)),null)]}):b==="image"?jsx(Ue,{data:{content:_t,...j()&&{fileName:j()},...b&&{fileType:b}},annotationData:xt,totalPage:1,currentPage:1,scale:F,rotation:wt,eventsEmit:P,styles:A,tools:{...v,navigation:!1,rotate:!0},customComponents:g,contentClass:c}):b==="pdf"||b==="pdf_slides"?jsx(Ue,{data:{content:{document:G},...j()&&{fileName:j()},...b&&{fileType:b},...R&&{totalPages:R},pdfStartPage:$t},annotationData:xt,totalPage:R,currentPage:l,scale:F,initialZoom:Q,eventsEmit:(Y,Lt)=>{console.log("Fviewer\u4E8B\u4EF6:",Y,Lt),Y==="scaleChange"&&console.log("\u6536\u5230\u7F29\u653E\u53D8\u5316\u4E8B\u4EF6:",Lt),P(Y,Lt)},styles:A,tools:v,customComponents:g,contentClass:c}):jsx(Ue,{data:{content:S||s||{type:"text",content:"\u6587\u4EF6\u5185\u5BB9\u52A0\u8F7D\u4E2D..."},...j()&&{fileName:j()},...b&&{fileType:b}},annotationData:xt,totalPage:1,currentPage:1,scale:F,eventsEmit:P,styles:A,tools:{...v,navigation:!1},customComponents:g,contentClass:c})]})};export{ChevronLeft as C,De as D,GientechStreamReader as G,commonjsRequire as c,require$$0 as r};