@yxp934/prompt-tree 0.2.0 → 0.4.0

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 (120) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +4 -4
  3. package/.next/standalone/.next/build-manifest.json +3 -3
  4. package/.next/standalone/.next/react-loadable-manifest.json +9 -1
  5. package/.next/standalone/.next/server/app/_global-error/page.js +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.html +2 -2
  8. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
  20. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  21. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  23. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  24. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  25. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  26. package/.next/standalone/.next/server/app/api/agent/route.js +2 -2
  27. package/.next/standalone/.next/server/app/api/agent/route_client-reference-manifest.js +1 -1
  28. package/.next/standalone/.next/server/app/api/chat/route.js +1 -1
  29. package/.next/standalone/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
  30. package/.next/standalone/.next/server/app/api/providers/health/route_client-reference-manifest.js +1 -1
  31. package/.next/standalone/.next/server/app/api/providers/models/route_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/api/providers/test/route_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/api/tools/mcp/call-tool/route_client-reference-manifest.js +1 -1
  34. package/.next/standalone/.next/server/app/api/tools/mcp/list-tools/route_client-reference-manifest.js +1 -1
  35. package/.next/standalone/.next/server/app/api/tools/mcp/test/route_client-reference-manifest.js +1 -1
  36. package/.next/standalone/.next/server/app/api/tools/python/route_client-reference-manifest.js +1 -1
  37. package/.next/standalone/.next/server/app/api/tools/search/route_client-reference-manifest.js +1 -1
  38. package/.next/standalone/.next/server/app/index.html +2 -2
  39. package/.next/standalone/.next/server/app/index.rsc +4 -4
  40. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  41. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  42. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  43. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  44. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  45. package/.next/standalone/.next/server/app/page.js +5 -3
  46. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  48. package/.next/standalone/.next/server/app/settings/page.js +2 -2
  49. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  51. package/.next/standalone/.next/server/app/settings.html +1 -1
  52. package/.next/standalone/.next/server/app/settings.rsc +4 -4
  53. package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +4 -4
  54. package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  55. package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +3 -3
  56. package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  57. package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  58. package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  59. package/.next/standalone/.next/server/app-paths-manifest.json +4 -4
  60. package/.next/standalone/.next/server/chunks/270.js +2 -0
  61. package/.next/standalone/.next/server/chunks/471.js +4 -4
  62. package/.next/standalone/.next/server/chunks/689.js +1 -1
  63. package/.next/standalone/.next/server/chunks/732.js +4 -4
  64. package/.next/standalone/.next/server/chunks/734.js +1 -1
  65. package/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
  66. package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  67. package/.next/standalone/.next/server/pages/404.html +1 -1
  68. package/.next/standalone/.next/server/pages/500.html +2 -2
  69. package/.next/standalone/.next/static/chunks/394-ce05579db22c8557.js +30 -0
  70. package/.next/standalone/.next/static/chunks/619.cfe242be4c0b83c0.js +1 -0
  71. package/.next/standalone/.next/static/chunks/787-849e95c38cdb12c0.js +1 -0
  72. package/.next/standalone/.next/static/chunks/991-3901e4f7973e3bc4.js +4 -0
  73. package/.next/standalone/.next/static/chunks/9b0008ae.ebbbe0264e8b748d.js +2 -0
  74. package/.next/standalone/.next/static/chunks/app/_global-error/page-f2489837ae5d03e0.js +1 -0
  75. package/.next/standalone/.next/static/chunks/app/api/agent/route-f2489837ae5d03e0.js +1 -0
  76. package/.next/standalone/.next/static/chunks/app/api/chat/route-f2489837ae5d03e0.js +1 -0
  77. package/.next/standalone/.next/static/chunks/app/api/providers/health/route-f2489837ae5d03e0.js +1 -0
  78. package/.next/standalone/.next/static/chunks/app/api/providers/models/route-f2489837ae5d03e0.js +1 -0
  79. package/.next/standalone/.next/static/chunks/app/api/providers/test/route-f2489837ae5d03e0.js +1 -0
  80. package/.next/standalone/.next/static/chunks/app/api/tools/mcp/call-tool/route-f2489837ae5d03e0.js +1 -0
  81. package/.next/standalone/.next/static/chunks/app/api/tools/mcp/list-tools/route-f2489837ae5d03e0.js +1 -0
  82. package/.next/standalone/.next/static/chunks/app/api/tools/mcp/test/route-f2489837ae5d03e0.js +1 -0
  83. package/.next/standalone/.next/static/chunks/app/api/tools/python/route-f2489837ae5d03e0.js +1 -0
  84. package/.next/standalone/.next/static/chunks/app/api/tools/search/route-f2489837ae5d03e0.js +1 -0
  85. package/.next/standalone/.next/static/chunks/app/page-92589c153be1ab8e.js +1 -0
  86. package/.next/standalone/.next/static/chunks/app/settings/page-ed3f1cc8a5f36f5c.js +1 -0
  87. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-f2489837ae5d03e0.js +1 -0
  88. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-f2489837ae5d03e0.js +1 -0
  89. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-f2489837ae5d03e0.js +1 -0
  90. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f2489837ae5d03e0.js +1 -0
  91. package/.next/standalone/.next/static/chunks/webpack-d7f56a24ad86f880.js +1 -0
  92. package/.next/standalone/.next/static/css/94729c1505529f29.css +1 -0
  93. package/.next/standalone/package.json +2 -1
  94. package/README.md +134 -120
  95. package/README.zh-CN.md +200 -0
  96. package/package.json +2 -1
  97. package/.next/standalone/.next/static/chunks/308-9aca2a7bf1797568.js +0 -2
  98. package/.next/standalone/.next/static/chunks/394-1e8c9367852fd6d7.js +0 -30
  99. package/.next/standalone/.next/static/chunks/787-56a48f915165efd3.js +0 -1
  100. package/.next/standalone/.next/static/chunks/app/_global-error/page-f941084711d16ad3.js +0 -1
  101. package/.next/standalone/.next/static/chunks/app/api/agent/route-f941084711d16ad3.js +0 -1
  102. package/.next/standalone/.next/static/chunks/app/api/chat/route-f941084711d16ad3.js +0 -1
  103. package/.next/standalone/.next/static/chunks/app/api/providers/health/route-f941084711d16ad3.js +0 -1
  104. package/.next/standalone/.next/static/chunks/app/api/providers/models/route-f941084711d16ad3.js +0 -1
  105. package/.next/standalone/.next/static/chunks/app/api/providers/test/route-f941084711d16ad3.js +0 -1
  106. package/.next/standalone/.next/static/chunks/app/api/tools/mcp/call-tool/route-f941084711d16ad3.js +0 -1
  107. package/.next/standalone/.next/static/chunks/app/api/tools/mcp/list-tools/route-f941084711d16ad3.js +0 -1
  108. package/.next/standalone/.next/static/chunks/app/api/tools/mcp/test/route-f941084711d16ad3.js +0 -1
  109. package/.next/standalone/.next/static/chunks/app/api/tools/python/route-f941084711d16ad3.js +0 -1
  110. package/.next/standalone/.next/static/chunks/app/api/tools/search/route-f941084711d16ad3.js +0 -1
  111. package/.next/standalone/.next/static/chunks/app/page-c273f2f3b7ce1609.js +0 -1
  112. package/.next/standalone/.next/static/chunks/app/settings/page-0fc8a4cbf639025c.js +0 -1
  113. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-f941084711d16ad3.js +0 -1
  114. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-f941084711d16ad3.js +0 -1
  115. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-f941084711d16ad3.js +0 -1
  116. package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f941084711d16ad3.js +0 -1
  117. package/.next/standalone/.next/static/chunks/webpack-03a911206b5adca4.js +0 -1
  118. package/.next/standalone/.next/static/css/100bba9d1b2ebade.css +0 -1
  119. /package/.next/standalone/.next/static/{wYfac0R-RsurEa801s_qH → bgKGmnmkLXkhuKgbJwKVn}/_buildManifest.js +0 -0
  120. /package/.next/standalone/.next/static/{wYfac0R-RsurEa801s_qH → bgKGmnmkLXkhuKgbJwKVn}/_ssgManifest.js +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[84],{6898:(t,e,i)=>{i.r(e),i.d(e,{AbortException:()=>iV,AnnotationEditorLayer:()=>iW,AnnotationEditorParamsType:()=>iq,AnnotationEditorType:()=>iX,AnnotationEditorUIManager:()=>iK,AnnotationLayer:()=>iY,AnnotationMode:()=>iQ,ColorPicker:()=>iJ,DOMSVGFactory:()=>iZ,DrawLayer:()=>i0,FeatureTest:()=>i1,GlobalWorkerOptions:()=>i2,ImageKind:()=>i3,InvalidPDFException:()=>i5,MissingPDFException:()=>i6,OPS:()=>i4,OutputScale:()=>i8,PDFDataRangeTransport:()=>i7,PDFDateString:()=>i9,PDFWorker:()=>st,PasswordResponses:()=>se,PermissionFlag:()=>si,PixelsPerInch:()=>ss,RenderingCancelledException:()=>sa,TextLayer:()=>sr,TouchManager:()=>sn,UnexpectedResponseException:()=>so,Util:()=>sl,VerbosityLevel:()=>sh,XfaLayer:()=>sd,build:()=>sc,createValidAbsoluteUrl:()=>su,fetchData:()=>sp,getDocument:()=>sg,getFilenameFromUrl:()=>sm,getPdfFilenameFromUrl:()=>sf,getXfaPageViewport:()=>sb,isDataScheme:()=>sA,isPdfFile:()=>sv,noContextMenu:()=>sy,normalizeUnicode:()=>sw,setLayerDimensions:()=>s_,shadow:()=>sx,stopEvent:()=>sS,version:()=>sC});var s=i(1463),a=i(2619).Buffer,r={};r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n=globalThis.pdfjsLib={};r.d(n,{AbortException:()=>R,AnnotationEditorLayer:()=>iU,AnnotationEditorParamsType:()=>u,AnnotationEditorType:()=>c,AnnotationEditorUIManager:()=>tb,AnnotationLayer:()=>iS,AnnotationMode:()=>d,ColorPicker:()=>iL,DOMSVGFactory:()=>e1,DrawLayer:()=>ij,FeatureTest:()=>N,GlobalWorkerOptions:()=>es,ImageKind:()=>g,InvalidPDFException:()=>M,MissingPDFException:()=>P,OPS:()=>f,OutputScale:()=>tl,PDFDataRangeTransport:()=>ez,PDFDateString:()=>ti,PDFWorker:()=>eU,PasswordResponses:()=>b,PermissionFlag:()=>p,PixelsPerInch:()=>j,RenderingCancelledException:()=>q,TextLayer:()=>ek,TouchManager:()=>tv,UnexpectedResponseException:()=>k,Util:()=>B,VerbosityLevel:()=>m,XfaLayer:()=>e2,build:()=>eY,createValidAbsoluteUrl:()=>x,fetchData:()=>V,getDocument:()=>eN,getFilenameFromUrl:()=>Y,getPdfFilenameFromUrl:()=>Q,getXfaPageViewport:()=>ts,isDataScheme:()=>X,isPdfFile:()=>K,noContextMenu:()=>tt,normalizeUnicode:()=>$,setLayerDimensions:()=>to,shadow:()=>S,stopEvent:()=>te,version:()=>eK});let o="object"==typeof s&&s+""=="[object process]"&&!s.versions.nw&&!(s.versions.electron&&s.type&&"browser"!==s.type),l=[1,0,0,1,0,0],h=[.001,0,0,.001,0,0],d={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},c={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},u={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},p={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},g={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},m={ERRORS:0,WARNINGS:1,INFOS:5},f={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,setStrokeTransparent:92,setFillTransparent:93},b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},A=m.WARNINGS;function v(t){A>=m.INFOS&&console.log(`Info: ${t}`)}function y(t){A>=m.WARNINGS&&console.log(`Warning: ${t}`)}function w(t){throw Error(t)}function _(t,e){t||w(e)}function x(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let a=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a))return a}catch{}return null}function S(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let C=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class E extends C{constructor(t,e){super(t,"PasswordException"),this.code=e}}class T extends C{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class M extends C{constructor(t){super(t,"InvalidPDFException")}}class P extends C{constructor(t){super(t,"MissingPDFException")}}class k extends C{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class D extends C{constructor(t){super(t,"FormatError")}}class R extends C{constructor(t){super(t,"AbortException")}}function I(t){("object"!=typeof t||t?.length===void 0)&&w("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let a=Math.min(s+8192,e),r=t.subarray(s,a);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function L(t){"string"!=typeof t&&w("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function F(t){let e=Object.create(null);for(let[i,s]of t)e[i]=s;return e}class N{static get isLittleEndian(){let t;return S(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]))}static get isEvalSupported(){return S(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return S(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return S(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get platform(){return"u">typeof navigator&&"string"==typeof navigator?.platform?S(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):S(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return S(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let O=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class B{static makeHexColor(t,e,i){return`#${O[t]}${O[e]}${O[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){let i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){let i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),a=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],a[0],r[0]),Math.min(i[1],s[1],a[1],r[1]),Math.max(i[0],s[0],a[0],r[0]),Math.max(i[1],s[1],a[1],r[1])]}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){let e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],a=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],n=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-a*s))/2;return[Math.sqrt(n+o||1),Math.sqrt(n-o||1)]}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;let a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>r?null:[i,a,s,r]}static #t(t,e,i,s,a,r,n,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*a+3*l*r)+3*c*n)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,a,r,n,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,a,r,n,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,a,r,n,o,(-h+p)/g,c),this.#t(t,e,i,s,a,r,n,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,a,r,n,o,l){return l?(l[0]=Math.min(l[0],t,n),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,n),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,n),Math.min(e,o),Math.max(t,n),Math.max(e,o)],this.#e(t,i,a,n,e,s,r,o,3*(-t+3*(i-a)+n),6*(t-2*i+a),3*(i-t),l),this.#e(t,i,a,n,e,s,r,o,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),l),l}}let z=null,H=null;function $(t){return z||(z=/([\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,H=new Map([["ſt","ſt"]])),t.replaceAll(z,(t,e,i)=>e?e.normalize("NFKC"):H.get(i))}let G="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})});let U="http://www.w3.org/2000/svg";class j{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function V(t,e="text"){if(Z(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType=e,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(200===a.status||0===a.status){switch(e){case"arraybuffer":case"blob":case"json":i(a.response);return}i(a.responseText);return}s(Error(a.statusText))}},a.send(null)})}class W{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:a=0,offsetY:r=0,dontFlip:n=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=a,this.offsetY=r,i*=e;const m=(t[2]+t[0])/2,f=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}n&&(h=-h,d=-d),0===o?(c=Math.abs(f-t[1])*i+a,u=Math.abs(m-t[0])*i+r,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(m-t[0])*i+a,u=Math.abs(f-t[1])*i+r,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*m-h*i*f,u-l*i*m-d*i*f],this.width=p,this.height=g}get rawDims(){let{userUnit:t,viewBox:e}=this,i=e.map(e=>e*t);return S(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:a=!1}={}){return new W({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:a})}convertToViewportPoint(t,e){return B.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=B.applyTransform([t[0],t[1]],this.transform),i=B.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return B.applyInverseTransform([t,e],this.transform)}}class q extends C{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function X(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function K(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Y(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Q(t,e="document.pdf"){if("string"!=typeof t)return e;if(X(t))return y('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),a=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(a&&(a=a[0]).includes("%"))try{a=i.exec(decodeURIComponent(a))[0]}catch{}return a||e}class J{started=Object.create(null);times=[];time(t){t in this.started&&y(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||y(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:s,end:a}of this.times)t.push(`${i.padEnd(e)} ${a-s}ms
2
+ `);return t.join("")}}function Z(t,e){try{let{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function tt(t){t.preventDefault()}function te(t){t.preventDefault(),t.stopPropagation()}class ti{static #i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#i.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let n=parseInt(e[5],10);n=n>=0&&n<=59?n:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,n+=d):"+"===l&&(r-=h,n-=d),new Date(Date.UTC(i,s,a,r,n,o))}}function ts(t,{scale:e=1,rotation:i=0}){let{width:s,height:a}=t.attributes.style;return new W({viewBox:[0,0,parseInt(s),parseInt(a)],userUnit:1,scale:e,rotation:i})}function ta(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(0xff0000&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(y(`Not a valid color format: "${t}"`),[0,0,0])}function tr(t){let{a:e,b:i,c:s,d:a,e:r,f:n}=t.getTransform();return[e,i,s,a,r,n]}function tn(t){let{a:e,b:i,c:s,d:a,e:r,f:n}=t.getTransform().invertSelf();return[e,i,s,a,r,n]}function to(t,e,i=!1,s=!0){if(e instanceof W){let{pageWidth:s,pageHeight:a}=e.rawDims,{style:r}=t,n=N.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${a}px`,h=n?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=n?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tl{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class th{#s=null;#a=null;#r;#n=null;#o=null;static #l=null;constructor(t){this.#r=t,th.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#r._uiManager._signal;t.addEventListener("contextmenu",tt,{signal:e}),t.addEventListener("pointerdown",th.#h,{signal:e});let i=this.#n=document.createElement("div");i.className="buttons",t.append(i);let s=this.#r.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static #h(t){t.stopPropagation()}#c(t){this.#r._focusEventsAllowed=!1,te(t)}#u(t){this.#r._focusEventsAllowed=!0,te(t)}#p(t){let e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",tt,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#a?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){let{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",th.#l[t]),this.#p(i),i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#n.append(i)}get #g(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#p(e),this.#n.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#a=t;let e=t.renderButton();this.#p(e),this.#n.prepend(e,this.#g)}remove(){this.#s.remove(),this.#a?.destroy(),this.#a=null}}class td{#n=null;#s=null;#m;constructor(t){this.#m=t}#f(){let t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",tt,{signal:this.#m._signal});let e=this.#n=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#A(t,e){let i=0,s=0;for(let a of t){let t=a.y+a.height;if(t<i)continue;let r=a.x+(e?a.width:0);if(t>i){s=r,i=t;continue}e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){let[s,a]=this.#A(e,i),{style:r}=this.#s||=this.#f();t.append(this.#s),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let i=this.#m._signal;t.addEventListener("contextmenu",tt,{signal:i}),t.addEventListener("click",()=>{this.#m.highlightSelection("floating_button")},{signal:i}),this.#n.append(t)}}function tc(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tu{#v=0;get id(){return`pdfjs_internal_editor_${this.#v++}`}}class tp{#y=(function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),I(t)})();#v=0;#w=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='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>',S(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async #_(t,e){this.#w||=new Map;let i=this.#w.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#v++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await V(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tp._isSVGFittingCanvas,s=new FileReader,a=new Image,r=new Promise((t,r)=>{a.onload=()=>{i.bitmap=a,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;a.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},a.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){y(t),i=null}return this.#w.set(t,i),i&&this.#w.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:a}=t;return this.#_(`${e}_${i}_${s}_${a}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){let i=await e;return this.#_(t,i)}async getFromId(t){this.#w||=new Map;let e=this.#w.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#w||=new Map;let i=this.#w.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#v++}`,refCounter:1,isSvg:!1},this.#w.set(t,i),this.#w.set(i.id,i),i}getSvgUrl(t){let e=this.#w.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#w||=new Map;let e=this.#w.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class tg{#x=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:n=!1}){if(s&&t(),this.#S)return;let o={cmd:t,undo:e,post:i,type:a};if(-1===this.#E){this.#x.length>0&&(this.#x.length=0),this.#E=0,this.#x.push(o);return}if(r&&this.#x[this.#E].type===a){n&&(o.undo=this.#x[this.#E].undo),this.#x[this.#E]=o;return}let l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;let{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;let{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return -1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t){this.#x.splice(e+1,this.#E-e),this.#E=e;return}this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class tm{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=N.platform;for(const[i,s,a={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:a}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:a}),this.allKeys.add(t.split("+").at(-1)))}}#T(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#T(e));if(!i)return;let{callback:s,options:{bubbles:a=!1,args:r=[],checker:n=null}}=i;(!n||n(t,e))&&(s.bind(t,...r,e)(),a||te(e))}}class tf{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,ta(s))}return e.remove(),S(this,"_colors",t)}convert(t){let e=ta(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tf._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?B.makeHexColor(...e):t}}class tb{#M=new AbortController;#P=null;#k=new Map;#D=new Map;#R=null;#I=null;#L=null;#F=new tg;#N=null;#O=null;#B=0;#z=new Set;#H=null;#$=null;#G=new Set;_editorUndoBar=null;#U=!1;#j=!1;#V=!1;#W=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new tu;#Z=!1;#tt=!1;#te=null;#ti=null;#ts=null;#ta=null;#tr=c.NONE;#tn=new Set;#to=null;#tl=null;#th=null;#td={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tc=[0,0];#tu=null;#tp=null;#tg=null;#tm=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tb.prototype,e=t=>t.#tp.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return S(this,"_keyboardManager",new tm([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tp.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tp.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}constructor(t,e,i,s,a,r,n,o,l,h,d,c,u){const p=this._signal=this.#M.signal;this.#tp=t,this.#tg=e,this.#R=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:p}),this.#tf(),this.#tb(),this.#tA(),this.#I=a.annotationStorage,this.#W=a.filterFactory,this.#tl=r,this.#K=n||null,this.#U=o,this.#j=l,this.#V=h,this.#ta=d||null,this.viewParameters={realScale:j.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){for(let t of(this.#tm?.resolve(),this.#tm=null,this.#M?.abort(),this.#M=null,this._signal=null,this.#D.values()))t.destroy();this.#D.clear(),this.#k.clear(),this.#G.clear(),this.#P=null,this.#tn.clear(),this.#F.destroy(),this.#R?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#tu&&(clearTimeout(this.#tu),this.#tu=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#ta}get useNewAltTextFlow(){return this.#j}get useNewAltTextWhenAddingImage(){return this.#V}get hcmFilter(){return S(this,"hcmFilter",this.#tl?this.#W.addHCMFilter(this.#tl.foreground,this.#tl.background):"none")}get direction(){return S(this,"direction",getComputedStyle(this.#tp).direction)}get highlightColors(){return S(this,"highlightColors",this.#K?new Map(this.#K.split(",").map(t=>t.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return S(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#O=t}setMainHighlightColorPicker(t){this.#ts=t}editAltText(t,e=!1){this.#R?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){"enableNewAltTextWhenAddingImage"===t&&(this.#V=e)}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#tp.focus()}findParent(t,e){for(let i of this.#D.values()){let{x:s,y:a,width:r,height:n}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=a&&e<=a+n)return i}return null}disableUserSelect(t=!1){this.#tg.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#G.add(t)}removeShouldRescale(t){this.#G.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*j.PDF_TO_CSS_UNITS,this.#G))e.onScaleChanging();this.#O?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tv({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#ty(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#D.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:i,anchorOffset:s,focusNode:a,focusOffset:r}=e,n=e.toString(),o=this.#tv(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();let h=this.#ty(o),d=this.#tr===c.NONE,u=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:a,focusOffset:r,text:n}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(c.HIGHLIGHT,u):u()}#tw(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tv(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new td(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#I||this.#I.has(t.id)||this.#I.setValue(t.id,t)}#t_(){let t=document.getSelection();if(!t||t.isCollapsed){this.#to&&(this.#Q?.hide(),this.#to=null,this.#tx({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#to)return;let i=this.#tv(t).closest(".textLayer");if(!i){this.#to&&(this.#Q?.hide(),this.#to=null,this.#tx({hasSelectedText:!1}));return}if(this.#Q?.hide(),this.#to=e,this.#tx({hasSelectedText:!0}),(this.#tr===c.HIGHLIGHT||this.#tr===c.NONE)&&(this.#tr===c.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tr===c.HIGHLIGHT?this.#ty(i):null;t?.toggleDrawing();let e=new AbortController,s=this.combinedSignal(e),a=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tS("main_toolbar"))};window.addEventListener("pointerup",a,{signal:s}),window.addEventListener("blur",a,{signal:s})}}#tS(t=""){this.#tr===c.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#tw()}#tf(){document.addEventListener("selectionchange",this.#t_.bind(this),{signal:this._signal})}#tC(){if(this.#X)return;this.#X=new AbortController;let t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#tE(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#tS("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#tn)if(e.div.contains(t)){this.#ti=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#ti)return;let[t,e]=this.#ti;this.#ti=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tA(){if(this.#te)return;this.#te=new AbortController;let t=this.combinedSignal(this.#te);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tT(){this.#te?.abort(),this.#te=null}#tM(){if(this.#N)return;this.#N=new AbortController;let t=this.combinedSignal(this.#N);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#tP(){this.#N?.abort(),this.#N=null}#tb(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tA(),this.#tM()}removeEditListeners(){this.#tT(),this.#tP()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#$)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#$)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#P?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#tn){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#$)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){y(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tk(e);this.#tD(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){y(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tr===c.NONE||this.isEditorHandlingKeyboard||tb._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#tS("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#tx(t){Object.entries(t).some(([t,e])=>this.#td[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#td,t)}),this.#tr===c.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tR([[u.HIGHLIGHT_FREE,!0]]))}#tR(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tC(),this.#tM(),this.#tx({isEditing:this.#tr!==c.NONE,isEmpty:this.#tI(),hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:this.#F.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#tE(),this.#tP(),this.#tx({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#$)for(let e of(this.#$=t,this.#$))this.#tR(e.defaultPropertiesToUpdate)}getId(){return this.#J.id}get currentLayer(){return this.#D.get(this.#B)}getLayer(t){return this.#D.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#D.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#D.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#tr!==t&&(!this.#tm||(await this.#tm.promise,this.#tm))){if(this.#tm=Promise.withResolvers(),this.#tr=t,t===c.NONE){this.setEditingState(!1),this.#tL(),this._editorUndoBar?.hide(),this.#tm.resolve();return}for(let e of(this.setEditingState(!0),await this.#tF(),this.unselectAll(),this.#D.values()))e.updateMode(t);if(!e){i&&this.addNewEditorFromKeyboard(),this.#tm.resolve();return}for(let t of this.#k.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#tm.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#tr&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#$){switch(t){case u.CREATE:this.currentLayer.addNewEditor();return;case u.HIGHLIGHT_DEFAULT_COLOR:this.#ts?.updateColor(e);break;case u.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#th||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(let i of this.#tn)i.updateParams(t,e);for(let i of this.#$)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#k.values())i.editorType===t&&i.show(e);(this.#th?.get(u.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tR([[u.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t)for(let e of(this.#tt=t,this.#D.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tF(){if(!this.#Z){this.#Z=!0;let t=[];for(let e of this.#D.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#k.values()))e.enable()}}#tL(){if(this.unselectAll(),this.#Z){for(let t of(this.#Z=!1,this.#D.values()))t.disable();for(let t of this.#k.values())t.disable()}}getEditors(t){let e=[];for(let i of this.#k.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#k.get(t)}addEditor(t){this.#k.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout(()=>{this.focusMainContainer(),this.#q=null},0)),this.#k.delete(t.id),this.unselect(t),t.annotationElementId&&this.#z.has(t.annotationElementId)||this.#I?.remove(t.id)}addDeletedAnnotationElement(t){this.#z.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#z.has(t)}removeDeletedAnnotationElement(t){this.#z.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tk(t){let e=this.#D.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#P!==t&&(this.#P=t,t&&this.#tR(t.propertiesToUpdate))}get #tN(){let t=null;for(t of this.#tn);return t}updateUI(t){this.#tN===t&&this.#tR(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tR(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#tn.has(t)){this.#tn.delete(t),t.unselect(),this.#tx({hasSelectedEditor:this.hasSelection});return}this.#tn.add(t),t.select(),this.#tR(t.propertiesToUpdate),this.#tx({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.#O?.commitOrRemove(),this.#tn))e!==t&&e.unselect();this.#tn.clear(),this.#tn.add(t),t.select(),this.#tR(t.propertiesToUpdate),this.#tx({hasSelectedEditor:!0})}isSelected(t){return this.#tn.has(t)}get firstSelectedEditor(){return this.#tn.values().next().value}unselect(t){t.unselect(),this.#tn.delete(t),this.#tx({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#tn.size}get isEnterHandled(){return 1===this.#tn.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#F.undo(),this.#tx({hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tI()}),this._editorUndoBar?.hide()}redo(){this.#F.redo(),this.#tx({hasSomethingToUndo:!0,hasSomethingToRedo:this.#F.hasSomethingToRedo(),isEmpty:this.#tI()})}addCommands(t){this.#F.add(t),this.#tx({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tI()})}cleanUndoStack(t){this.#F.cleanType(t)}#tI(){if(0===this.#k.size)return!0;if(1===this.#k.size)for(let t of this.#k.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#tn],i=()=>{for(let t of(this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length),e))t.remove()},s=()=>{for(let t of e)this.#tk(t)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#P?.commitOrRemove()}hasSomethingToControl(){return this.#P||this.hasSelection}#tD(t){for(let t of this.#tn)t.unselect();for(let e of(this.#tn.clear(),t))e.isEmpty()||(this.#tn.add(e),e.select());this.#tx({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#tn)t.commit();this.#tD(this.#k.values())}unselectAll(){if(!this.#P||(this.#P.commitOrRemove(),this.#tr===c.NONE)){if(!this.#O?.commitOrRemove()&&this.hasSelection){for(let t of this.#tn)t.unselect();this.#tn.clear(),this.#tx({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tc[0]+=t,this.#tc[1]+=e;let[s,a]=this.#tc,r=[...this.#tn];for(let i of(this.#tu&&clearTimeout(this.#tu),this.#tu=setTimeout(()=>{this.#tu=null,this.#tc[0]=this.#tc[1]=0,this.addCommands({cmd:()=>{for(let t of r)this.#k.has(t.id)&&t.translateInPage(s,a)},undo:()=>{for(let t of r)this.#k.has(t.id)&&t.translateInPage(-s,-a)},mustExec:!1})},1e3),r))i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#H=new Map,this.#tn))this.#H.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#H)return!1;this.disableUserSelect(!1);let t=this.#H;this.#H=null;let e=!1;for(let[{x:i,y:s,pageIndex:a},r]of t)r.newX=i,r.newY=s,r.newPageIndex=a,e||=i!==r.savedX||s!==r.savedY||a!==r.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#k.has(t.id)){let a=this.#D.get(s);a?t._setParentAndPosition(a,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:a,newPageIndex:r}]of t)i(e,s,a,r)},undo:()=>{for(let[e,{savedX:s,savedY:a,savedPageIndex:r}]of t)i(e,s,a,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#H)for(let i of this.#H.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#tn.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#P===t}getActive(){return this.#P}getMode(){return this.#tr}get imageManager(){return S(this,"imageManager",new tp)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:a,width:r,height:n}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-a)/n,y:1-(t+i-s)/r,width:o/n,height:i/r});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/r,y:1-(e+o-a)/n,width:i/r,height:o/n});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-a)/n,y:(t-s)/r,width:o/n,height:i/r});break;default:e=(t,e,i,o)=>({x:(t-s)/r,y:(e-a)/n,width:i/r,height:o/n})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:a,height:r}of s.getClientRects())0!==a&&0!==r&&o.push(e(t,i,a,r))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#L||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#L?.delete(t)}renderAnnotationElement(t){let e=this.#L?.get(t.data.id);if(!e)return;let i=this.#I.getRawValue(e);!i||(this.#tr!==c.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}}class tA{#o=null;#tO=!1;#tB=null;#tz=null;#tH=null;#t$=null;#tG=!1;#tU=null;#r=null;#tj=null;#tV=null;#tW=!1;static #tq=null;static _l10n=null;constructor(t){this.#r=t,this.#tW=t._uiManager.useNewAltTextFlow,tA.#tq||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){tA._l10n??=t}async render(){let t=this.#tB=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#tz=document.createElement("span");t.append(e),this.#tW?(t.classList.add("new"),t.setAttribute("data-l10n-id",tA.#tq.missing),e.setAttribute("data-l10n-id",tA.#tq["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#r._uiManager._signal;t.addEventListener("contextmenu",tt,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#tW&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#tX}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#tG=!0,s(e))},{signal:i}),await this.#tK(),t}get #tX(){return this.#o&&"added"||null===this.#o&&this.guessedText&&"review"||"missing"}finish(){this.#tB&&(this.#tB.focus({focusVisible:this.#tG}),this.#tG=!1)}isEmpty(){return this.#tW?null===this.#o:!this.#o&&!this.#tO}hasData(){return this.#tW?null!==this.#o||!!this.#tj:this.isEmpty()}get guessedText(){return this.#tj}async setGuessedText(t){null===this.#o&&(this.#tj=t,this.#tV=await tA._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#tK())}toggleAltTextBadge(t=!1){if(!this.#tW||this.#o){this.#tU?.remove(),this.#tU=null;return}if(!this.#tU){let t=this.#tU=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#tU.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#tj!==e||(e=this.#tV),{altText:e,decorative:this.#tO,guessedText:this.#tj,textWithDisclaimer:this.#tV}}get data(){return{altText:this.#o,decorative:this.#tO}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:a=!1}){i&&(this.#tj=i,this.#tV=s),(this.#o!==t||this.#tO!==e)&&(a||(this.#o=t,this.#tO=e),this.#tK())}toggle(t=!1){this.#tB&&(!t&&this.#t$&&(clearTimeout(this.#t$),this.#t$=null),this.#tB.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#tX}})}destroy(){this.#tB?.remove(),this.#tB=null,this.#tz=null,this.#tH=null,this.#tU?.remove(),this.#tU=null}async #tK(){let t=this.#tB;if(!t)return;if(this.#tW){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",tA.#tq[this.#tX]),this.#tz?.setAttribute("data-l10n-id",tA.#tq[`${this.#tX}-label`]),!this.#o)return void this.#tH?.remove()}else{if(!this.#o&&!this.#tO){t.classList.remove("done"),this.#tH?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#tH;if(!e){this.#tH=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;let i=this.#r._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#t$),this.#t$=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#t$=setTimeout(()=>{this.#t$=null,this.#tH.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#t$&&(clearTimeout(this.#t$),this.#t$=null),this.#tH?.classList.remove("show")},{signal:i})}this.#tO?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);let i=this.#r.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}class tv{#tp;#tY=!1;#tQ=null;#tJ;#tZ;#t0;#t1;#t2;#t3=null;#t5;#t6=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:a=null,onPinchEnd:r=null,signal:n}){this.#tp=t,this.#tQ=i,this.#tJ=e,this.#tZ=s,this.#t0=a,this.#t1=r,this.#t5=new AbortController,this.#t2=AbortSignal.any([n,this.#t5.signal]),t.addEventListener("touchstart",this.#t4.bind(this),{passive:!1,signal:this.#t2})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return S(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#t4(t){if(this.#tJ?.()||t.touches.length<2)return;if(!this.#t6){this.#t6=new AbortController;let t=AbortSignal.any([this.#t2,this.#t6.signal]),e=this.#tp,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#t8.bind(this),i),e.addEventListener("touchend",this.#t7.bind(this),i),e.addEventListener("touchcancel",this.#t7.bind(this),i),this.#tZ?.()}if(te(t),2!==t.touches.length||this.#tQ?.()){this.#t3=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#t3={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#t8(t){if(!this.#t3||2!==t.touches.length)return;let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:a}=e,{screenX:r,screenY:n}=i,o=this.#t3,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(r-s,n-a)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#tY&&Math.abs(p-u)<=tv.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=a,o.touch1X=r,o.touch1Y=n,t.preventDefault(),!this.#tY){this.#tY=!0;return}let g=[(s+r)/2,(a+n)/2];this.#t0?.(g,p,u)}#t7(t){this.#t6.abort(),this.#t6=null,this.#t1?.(),this.#t3&&(t.preventDefault(),this.#t3=null,this.#tY=!1)}destroy(){this.#t5?.abort(),this.#t5=null}}class ty{#t9=null;#et=null;#o=null;#ee=!1;#ei=null;#es="";#ea=!1;#er=null;#en=null;#eo=null;#el=null;#eh="";#ed=!1;#ec=null;#eu=!1;#ep=!1;#eg=!1;#em=null;#ef=0;#eb=0;#eA=null;#ev=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ey=!1;#ew=ty._zIndex++;static _borderLineWidth=-1;static _colorManager=new tf;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=ty.prototype._resizeWithKeyboard,e=tb.TRANSLATE_SMALL,i=tb.TRANSLATE_BIG;return S(this,"_resizerKeyboardManager",new tm([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],ty.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[a,r];const[n,o]=this.parentDimensions;this.x=t.x/n,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return S(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tw({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ty._l10n??=t,ty._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==ty._borderLineWidth)return;let i=getComputedStyle(document.documentElement);ty._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){w("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ey}set _isDraggable(t){this.#ey=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#ew}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#e_(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ed?this.#ed=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[a,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/a,this.y=(e+s)/r,this.fixAndSetPosition()}#ex([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#ex(this.parentDimensions,t,e)}translateInPage(t,e){this.#ec||=[this.x,this.y,this.width,this.height],this.#ex(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#ec||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,a]}=this;if(this.x+=t/s,this.y+=e/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:n}=this,[o,l]=this.getBaseTranslation();r+=o,n+=l;let{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*n).toFixed(2)}%`,this._onTranslating(r,n),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#ec&&(this.#ec[0]!==this.x||this.#ec[1]!==this.y)}get _hasBeenResized(){return!!this.#ec&&(this.#ec[2]!==this.width||this.#ec[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=ty,s=i/t,a=i/e;switch(this.rotation){case 90:return[-s,a];case 180:return[s,a];case 270:return[s,-a];default:return[-s,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:a,y:r,width:n,height:o}=this;if(n*=i,o*=s,a*=i,r*=s,this._mustFixPosition)switch(t){case 0:a=Math.max(0,Math.min(i-n,a)),r=Math.max(0,Math.min(s-o,r));break;case 90:a=Math.max(0,Math.min(i-o,a)),r=Math.min(s,Math.max(n,r));break;case 180:a=Math.min(i,Math.max(n,a)),r=Math.min(s,Math.max(o,r));break;case 270:a=Math.min(i,Math.max(o,a)),r=Math.max(0,Math.min(s-n,r))}this.x=a/=i,this.y=r/=s;let[l,h]=this.getBaseTranslation();a+=l,r+=h,e.left=`${(100*a).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static #eS(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return ty.#eS(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ty.#eS(t,e,360-this.parentRotation)}#eC(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){let[i,s]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*t/i).toFixed(2)}%`,this.#ea||(a.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),a=!this.#ea&&e.endsWith("%");if(s&&a)return;let[r,n]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ea||a||(t.height=`${(100*parseFloat(e)/n).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#eE(){if(this.#er)return;this.#er=document.createElement("div"),this.#er.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#er.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#eT.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#er)}#eT(t,e){e.preventDefault();let{isMac:i}=N.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#en=[e.screenX,e.screenY];let a=new AbortController,r=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#eM.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",te,{passive:!1,signal:r}),window.addEventListener("contextmenu",tt,{signal:r}),this.#eo={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=n,this.div.style.cursor=o,this.#eP()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#ek(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;let[a,r]=this.parentDimensions;this.setDims(a*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#eP(){if(!this.#eo)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eo;this.#eo=null;let a=this.x,r=this.y,n=this.width,o=this.height;(a!==t||r!==e||n!==i||o!==s)&&this.addCommands({cmd:this.#ek.bind(this,a,r,n,o),undo:this.#ek.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#eM(t,e){let i,s,a,r,n,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=ty.MIN_SIZE/l,m=ty.MIN_SIZE/h,f=this.#eC(this.rotation),b=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e],A=this.#eC(360-this.rotation),v=!1,y=!1;switch(t){case"topLeft":v=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":v=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":y=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":v=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":v=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":y=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let w=i(u,p),_=s(u,p),x=b(..._),S=ty._round(d+x[0]),C=ty._round(c+x[1]),E=1,T=1;if(e.fromKeyboard)({deltaX:a,deltaY:r}=e);else{let{screenX:t,screenY:i}=e,[s,n]=this.#en;[a,r]=this.screenToPageTranslation(t-s,i-n),this.#en[0]=t,this.#en[1]=i}if([a,r]=(n=a/l,o=r/h,[A[0]*n+A[2]*o,A[1]*n+A[3]*o]),v){let t=Math.hypot(u,p);E=T=Math.max(Math.min(Math.hypot(_[0]-w[0]-a,_[1]-w[1]-r)/t,1/u,1/p),g/u,m/p)}else y?E=Math.max(g,Math.min(1,Math.abs(_[0]-w[0]-a)))/u:T=Math.max(m,Math.min(1,Math.abs(_[1]-w[1]-r)))/p;let M=ty._round(u*E),P=ty._round(p*T),k=S-(x=b(...s(M,P)))[0],D=C-x[1];this.#ec||=[this.x,this.y,this.width,this.height],this.width=M,this.height=P,this.x=k,this.y=D,this.setDims(l*M,h*P),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#ep||(this._editToolbar=new th(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(tA.initialize(ty._l10n),this.#o=new tA(this),this.#t9&&(this.#o.data=this.#t9,this.#t9=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await this.#o?.setGuessedText(t)}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}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.tabIndex=this.#ee?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#eD();let[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);let[i,s]=this.getInitialTranslation();return this.translate(i,s),tc(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#ev||=new tv({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#eR.bind(this),onPinching:this.#eI.bind(this),onPinchEnd:this.#eL.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#eR(){this.#eo={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#eI(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let a=this.#eC(this.rotation),r=(t,e)=>[a[0]*t+a[2]*e,a[1]*t+a[3]*e],[n,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),ty.MIN_SIZE/n/d,ty.MIN_SIZE/o/c);let u=ty._round(d*s),p=ty._round(c*s);if(u===d&&p===c)return;this.#ec||=[l,h,d,c];let g=r(d/2,c/2),m=ty._round(l+g[0]),f=ty._round(h+g[1]),b=r(u/2,p/2);this.x=m-b[0],this.y=f-b[1],this.width=u,this.height=p,this.setDims(n*u,o*p),this.fixAndSetPosition(),this._onResizing()}#eL(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#eP()}pointerdown(t){let{isMac:e}=N.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ed=!0,this._isDraggable)?this.#eF(t):this.#eN(t)}get isSelected(){return this._uiManager.isSelected(this)}#eN(t){let{isMac:e}=N.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#eF(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,a=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:a},n=t=>{s.abort(),this.#ei=null,this.#ed=!1,this._uiManager.endDragSession()||this.#eN(t),i&&this._onStopDragging()};e&&(this.#ef=t.clientX,this.#eb=t.clientY,this.#ei=t.pointerId,this.#es=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._onStartDragging());let{clientX:e,clientY:s,pointerId:a}=t;if(a!==this.#ei)return void te(t);let[r,n]=this.screenToPageTranslation(e-this.#ef,s-this.#eb);this.#ef=e,this.#eb=s,this._uiManager.dragSelectedEditors(r,n)},r),window.addEventListener("touchmove",te,r),window.addEventListener("pointerdown",t=>{t.pointerType===this.#es&&(this.#ev||t.isPrimary)&&n(t),te(t)},r));let o=t=>{this.#ei&&this.#ei!==t.pointerId?te(t):n(t)};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#em&&clearTimeout(this.#em),this.#em=setTimeout(()=>{this.#em=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){let s=this.parentScale,[a,r]=this.pageDimensions,[n,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*a,c=this.y*r,u=this.width*a,p=this.height*r;switch(i){case 0:return[d+l+n,r-c-h-p+o,d+l+u+n,r-c-h+o];case 90:return[d+h+n,r-c+l+o,d+h+p+n,r-c+l+u+o];case 180:return[d-l-u+n,r-c+h+o,d-l+n,r-c+h+p+o];case 270:return[d-h-p+n,r-c-l-u+o,d-h+n,r-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,a,r]=t,n=a-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,n,o];case 90:return[i,e-s,o,n];case 180:return[a,e-s,n,o];case 270:return[a,e-r,o,n];default:throw Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#ep=!0}disableEditMode(){this.#ep=!1}isInEditMode(){return this.#ep}shouldGetKeyboardEvents(){return this.#eg}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:a,innerWidth:r}=window;return e<r&&s>0&&t<a&&i>0}#eD(){if(this.#el||!this.div)return;this.#el=new AbortController;let t=this._uiManager.combinedSignal(this.#el);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#eD()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){w("An editor must be serializable")}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#t9=t.accessibilityData;let[a,r]=s.pageDimensions,[n,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=n/a,s.y=o/r,s.width=l/a,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#el?.abort(),this.#el=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#em&&(clearTimeout(this.#em),this.#em=null),this.#e_(),this.removeEditToolbar(),this.#eA){for(let t of this.#eA.values())clearTimeout(t);this.#eA=null}this.parent=null,this.#ev?.destroy(),this.#ev=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eE(),this.#er.classList.remove("hidden"),tc(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eo={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#er.children;if(!this.#et){this.#et=Array.from(e);let t=this.#eO.bind(this),i=this.#eB.bind(this),s=this._uiManager._signal;for(let e of this.#et){let a=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#ez.bind(this,a),{signal:s}),e.setAttribute("data-l10n-id",ty._l10nResizer[a])}}let i=this.#et[0],s=0;for(let t of e){if(t===i)break;s++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#et.length/4);if(a!==s){if(a<s)for(let t=0;t<s-a;t++)this.#er.append(this.#er.firstChild);else if(a>s)for(let t=0;t<a-s;t++)this.#er.firstChild.before(this.#er.lastChild);let t=0;for(let i of e){let e=this.#et[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ty._l10nResizer[e])}}this.#eH(0),this.#eg=!0,this.#er.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#eO(t){ty._resizerKeyboardManager.exec(this,t)}#eB(t){this.#eg&&t.relatedTarget?.parentNode!==this.#er&&this.#e_()}#ez(t){this.#eh=this.#eg?t:""}#eH(t){if(this.#et)for(let e of this.#et)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#eg&&this.#eM(this.#eh,{deltaX:t,deltaY:e,fromKeyboard:!0})}#e_(){this.#eg=!1,this.#eH(-1),this.#eP()}_stopResizingWithKeyboard(){this.#e_(),this.div.focus()}select(){(this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar)?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}unselect(){this.#er?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#eu}set isEditing(t){this.#eu=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ea=!0;let{style:i}=this.div;i.aspectRatio=t/e,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#eA||=new Map;let{action:e}=t,i=this.#eA.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eA.delete(e),0===this.#eA.size&&(this.#eA=null)},ty._telemetryTimeout),this.#eA.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ee=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ee=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tw extends ty{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class t_{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,a=t.length;s<a;s++){let a=t.charCodeAt(s);a<=255?e[i++]=a:(e[i++]=a>>>8,e[i++]=255&a)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,a=i-4*s,r=new Uint32Array(e.buffer,0,s),n=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=n=0x1b873593*(n=(n=0xcc9e2d51*(n=r[t])&0xffff0000|11601*n&65535)<<15|n>>>17)&0xffff0000|13715*n&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=r[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(n=0,a){case 3:n^=e[4*s+2]<<16;case 2:n^=e[4*s+1]<<8;case 1:n^=e[4*s],n=0x1b873593*(n=(n=0xcc9e2d51*n&0xffff0000|11601*n&65535)<<15|n>>>17)&0xffff0000|13715*n&65535,1&s?l^=n:h^=n}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tx=Object.freeze({map:null,hash:"",transfer:void 0});class tS{#e$=!1;#eG=null;#eU=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#eU.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#eU.get(t)}remove(t){if(this.#eU.delete(t),0===this.#eU.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let t of this.#eU.values())if(t instanceof ty)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#eU.get(t),s=!1;if(void 0!==i)for(let[t,a]of Object.entries(e))i[t]!==a&&(s=!0,i[t]=a);else s=!0,this.#eU.set(t,e);s&&this.#ej(),e instanceof ty&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#eU.has(t)}getAll(){return this.#eU.size>0?F(this.#eU):null}setAll(t){for(let[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#eU.size}#ej(){this.#e$||(this.#e$=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#e$&&(this.#e$=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new tC(this)}get serializable(){if(0===this.#eU.size)return tx;let t=new Map,e=new t_,i=[],s=Object.create(null),a=!1;for(let[i,r]of this.#eU){let n=r instanceof ty?r.serialize(!1,s):r;n&&(t.set(i,n),e.update(`${i}:${JSON.stringify(n)}`),a||=!!n.bitmap)}if(a)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tx}get editorStats(){let t=null,e=new Map;for(let i of this.#eU.values()){if(!(i instanceof ty))continue;let s=i.telemetryFinalData;if(!s)continue;let{type:a}=s;e.has(a)||e.set(a,Object.getPrototypeOf(i).constructor),t||=Object.create(null);let r=t[a]||=new Map;for(let[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));let s=i.get(e)??0;i.set(e,s+1)}}for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#eG=null}get modifiedIds(){if(this.#eG)return this.#eG;let t=[];for(let e of this.#eU.values())e instanceof ty&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#eG={ids:new Set(t),hash:t.join(",")}}}class tC extends tS{#eV;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,a=structuredClone(e,s?{transfer:s}:null);this.#eV={map:a,hash:i,transfer:s}}get print(){w("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#eV}get modifiedIds(){return S(this,"modifiedIds",{ids:new Set,hash:""})}}class tE{#eW=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#eW.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#eW.has(t.loadedName))){if(_(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:s,style:a}=t,r=new FontFace(i,s,a);this.addNativeFontFace(r);try{await r.load(),this.#eW.add(i),e?.(t)}catch{y(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}w("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw y(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return S(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return o?t=!0:"u">typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)&&(t=!0),S(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(_(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return S(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,a;function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=r(c=n(c,976,d.length,d),16);for(s=0,a=d.length-3;s<a;s+=4)u=u-0x58585858+r(d,s)|0;s<d.length&&(u=u-0x58585858+r(d+"XXX",s)|0),c=n(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){y("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class tT{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){for(const e in this.compiledGlyphs=Object.create(null),t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){var t;let e;if(!this.data||this.disableFontFace)return null;let i=`url(data:${this.mimetype};base64,${(t=this.data,Uint8Array.prototype.toBase64?t.toBase64():btoa(I(t)))});`;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${i}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${i}}`;return this._inspectFont?.(this,i),e}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){y(`getPathGenerator - ignoring character: "${t}".`)}let a=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=a}}function tM(){}function tP(t){if(t instanceof R||t instanceof M||t instanceof P||t instanceof E||t instanceof k||t instanceof T)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&w('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new R(t.message);case"InvalidPDFException":return new M(t.message);case"MissingPDFException":return new P(t.message);case"PasswordException":return new E(t.message,t.code);case"UnexpectedResponseException":return new k(t.message,t.status);case"UnknownErrorException":return new T(t.message,t.details)}return new T(t.message,t.toString())}class tk{#eq=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#eX.bind(this),{signal:this.#eq.signal})}#eX({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#eK(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(tP(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,a=this.comObj;Promise.try(e,t.data).then(function(e){a.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){a.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:tP(e)})});return}t.streamId?this.#eY(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let s=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[s]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){a.reject(t)}return a.promise}sendWithStream(t,e,i,s){let a=this.streamId++,r=this.sourceName,n=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[a]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:n,action:t,streamId:a,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[a].pullCall=e,o.postMessage({sourceName:r,targetName:n,stream:6,streamId:a,desiredSize:t.desiredSize}),e.promise},cancel:t=>{_(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[a].cancelCall=e,this.streamControllers[a].isClosed=!0,o.postMessage({sourceName:r,targetName:n,stream:1,streamId:a,reason:tP(t)}),e.promise}},i)}#eY(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,a=this.comObj,r=this,n=this.actionHandler[t.action],o={enqueue(t,r=1,n){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},n)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete r.streamSinks[e])},error(t){_(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:tP(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(n,t.data,o).then(function(){a.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){a.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:tP(t)})})}#eK(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,a=this.comObj,r=this.streamControllers[e],n=this.streamSinks[e];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(tP(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(tP(t.reason));break;case 6:if(!n){a.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}n.desiredSize<=0&&t.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=t.desiredSize,Promise.try(n.onPull||tM).then(function(){a.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){a.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:tP(t)})});break;case 4:if(_(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(_(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#eQ(r,e);break;case 5:_(r,"error should have stream controller"),r.controller.error(tP(t.reason)),this.#eQ(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(tP(t.reason)),this.#eQ(r,e);break;case 1:if(!n)break;let o=tP(t.reason);Promise.try(n.onCancel||tM,o).then(function(){a.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){a.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:tP(t)})}),n.sinkCapability.reject(o),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #eQ(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#eq?.abort(),this.#eq=null}}class tD{#eJ=!1;constructor({enableHWA:t=!1}){this.#eJ=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#eJ})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){w("Abstract method `_createCanvas` called.")}}class tR extends tD{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class tI{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){w("Abstract method `_fetch` called.")}}class tL extends tI{async _fetch(t){let e=await V(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):L(e)}}class tF{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,a){return"none"}destroy(t=!1){}}class tN extends tF{#eZ;#e0;#e1;#e2;#e3;#e5;#v=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#e2=t,this.#e3=e}get #w(){return this.#e0||=new Map}get #e6(){return this.#e5||=new Map}get #e4(){if(!this.#e1){let t=this.#e3.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let i=this.#e3.createElementNS(U,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#e1=this.#e3.createElementNS(U,"defs"),t.append(i),i.append(this.#e1),this.#e3.body.append(t)}return this.#e1}#e8(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,a=Array(256),r=Array(256),n=Array(256);for(let t=0;t<256;t++)a[t]=e[t]/255,r[t]=i[t]/255,n[t]=s[t]/255;return[a.join(","),r.join(","),n.join(",")]}#e7(t){if(void 0===this.#eZ){this.#eZ="";let t=this.#e3.URL;t!==this.#e3.baseURI&&(X(t)?y('#createUrl: ignore "data:"-URL for performance reasons.'):this.#eZ=t.split("#",1)[0])}return`url(${this.#eZ}#${t})`}addFilter(t){if(!t)return"none";let e=this.#w.get(t);if(e)return e;let[i,s,a]=this.#e8(t),r=1===t.length?i:`${i}${s}${a}`;if(e=this.#w.get(r))return this.#w.set(t,e),e;let n=`g_${this.#e2}_transfer_map_${this.#v++}`,o=this.#e7(n);this.#w.set(t,o),this.#w.set(r,o);let l=this.#e9(n);return this.#it(i,s,a,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",a=this.#e6.get(s);if(a?.key===i||(a?(a.filter?.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},this.#e6.set(s,a)),!t||!e))return a.url;let r=this.#ie(t);t=B.makeHexColor(...r);let n=this.#ie(e);if(e=B.makeHexColor(...n),this.#e4.style.color="","#000000"===t&&"#ffffff"===e||t===e)return a.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#e2}_hcm_filter`,d=a.filter=this.#e9(h);this.#it(l,l,l,d),this.#ii(d);let c=(t,e)=>{let i=r[t]/255,s=n[t]/255,a=Array(e+1);for(let t=0;t<=e;t++)a[t]=i+t/e*(s-i);return a.join(",")};return this.#it(c(0,5),c(1,5),c(2,5),d),a.url=this.#e7(h),a.url}addAlphaFilter(t){let e=this.#w.get(t);if(e)return e;let[i]=this.#e8([t]),s=`alpha_${i}`;if(e=this.#w.get(s))return this.#w.set(t,e),e;let a=`g_${this.#e2}_alpha_map_${this.#v++}`,r=this.#e7(a);this.#w.set(t,r),this.#w.set(s,r);let n=this.#e9(a);return this.#is(i,n),r}addLuminosityFilter(t){let e,i,s=this.#w.get(t||"luminosity");if(s)return s;if(t?([e]=this.#e8([t]),i=`luminosity_${e}`):i="luminosity",s=this.#w.get(i))return this.#w.set(t,s),s;let a=`g_${this.#e2}_luminosity_map_${this.#v++}`,r=this.#e7(a);this.#w.set(t,r),this.#w.set(i,r);let n=this.#e9(a);return this.#ia(n),t&&this.#is(e,n),r}addHighlightHCMFilter(t,e,i,s,a){let r=`${e}-${i}-${s}-${a}`,n=this.#e6.get(t);if(n?.key===r||(n?(n.filter?.remove(),n.key=r,n.url="none",n.filter=null):(n={key:r,url:"none",filter:null},this.#e6.set(t,n)),!e||!i))return n.url;let[o,l]=[e,i].map(this.#ie.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,a].map(this.#ie.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#e4.style.color="";let p=(t,e,i)=>{let s=Array(256),a=(d-h)/i,r=t/255,n=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*a),i=r+t*n;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#e2}_hcm_${t}_filter`,m=n.filter=this.#e9(g);return this.#ii(m),this.#it(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),n.url=this.#e7(g),n.url}destroy(t=!1){t&&this.#e5?.size||(this.#e1?.parentNode.parentNode.remove(),this.#e1=null,this.#e0?.clear(),this.#e0=null,this.#e5?.clear(),this.#e5=null,this.#v=0)}#ia(t){let e=this.#e3.createElementNS(U,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#ii(t){let e=this.#e3.createElementNS(U,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#e9(t){let e=this.#e3.createElementNS(U,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#e4.append(e),e}#ir(t,e,i){let s=this.#e3.createElementNS(U,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#it(t,e,i,s){let a=this.#e3.createElementNS(U,"feComponentTransfer");s.append(a),this.#ir(a,"feFuncR",t),this.#ir(a,"feFuncG",e),this.#ir(a,"feFuncB",i)}#is(t,e){let i=this.#e3.createElementNS(U,"feComponentTransfer");e.append(i),this.#ir(i,"feFuncA",t)}#ie(t){return this.#e4.style.color=t,ta(getComputedStyle(this.#e4).getPropertyValue("color"))}}class tO{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}async _fetch(t){w("Abstract method `_fetch` called.")}}class tB extends tO{async _fetch(t){return new Uint8Array(await V(t,"arraybuffer"))}}async function tz(t){let e=s.getBuiltinModule("fs");return new Uint8Array(await e.promises.readFile(t))}o&&y("Please use the `legacy` build in Node.js environments.");class tH extends tF{}class t$ extends tD{_createCanvas(t,e){return s.getBuiltinModule("module").createRequire("file:///Users/yxp/Documents/new-chat/ai-chat-client/node_modules/pdfjs-dist/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}class tG extends tI{async _fetch(t){return tz(t)}}class tU extends tO{async _fetch(t){return tz(t)}}let tj="Fill",tV="Stroke",tW="Shading";function tq(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],a=new Path2D;a.rect(e[0],e[1],i,s),t.clip(a)}class tX{getPattern(){w("Abstract method `getPattern` called.")}}class tK extends tX{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;for(let i of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let a;if(s===tV||s===tj){let r=e.current.getClippedPathBoundingBox(s,tr(t))||[0,0,0,0],n=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",n,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=B.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),tq(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),a=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);a.setTransform(d)}else tq(t,this._bbox),a=this._createGradient(t);return a}}function tY(t,e,i,s,a,r,n,o){let l,h,d,c,u,p,g,m,f,b=e.coords,A=e.colors,v=t.data,y=4*t.width;b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=n,n=l),b[s+1]>b[a+1]&&(l=s,s=a,a=l,l=n,n=o,o=l),b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=r,r=n,n=l);let w=(b[i]+e.offsetX)*e.scaleX,_=(b[i+1]+e.offsetY)*e.scaleY,x=(b[s]+e.offsetX)*e.scaleX,S=(b[s+1]+e.offsetY)*e.scaleY,C=(b[a]+e.offsetX)*e.scaleX,E=(b[a+1]+e.offsetY)*e.scaleY;if(_>=E)return;let T=A[r],M=A[r+1],P=A[r+2],k=A[n],D=A[n+1],R=A[n+2],I=A[o],L=A[o+1],F=A[o+2],N=Math.round(_),O=Math.round(E);for(let t=N;t<=O;t++){let e;if(t<S){let e=t<_?0:(_-t)/(_-S);h=w-(w-x)*e,d=T-(T-k)*e,c=M-(M-D)*e,u=P-(P-R)*e}else{let e;h=x-(x-C)*(e=t>E?1:S===E?0:(S-t)/(S-E)),d=k-(k-I)*e,c=D-(D-L)*e,u=R-(R-F)*e}p=w-(w-C)*(e=t<_?0:t>E?1:(_-t)/(_-E)),g=T-(T-I)*e,m=M-(M-L)*e,f=P-(P-F)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),a=y*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),v[a++]=d-(d-g)*e|0,v[a++]=c-(c-m)*e|0,v[a++]=u-(u-f)*e|0,v[a++]=255}}class tQ extends tX{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),a=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,n=Math.ceil(this._bounds[3])-a,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(n*t[1]*1.1)),3e3),h=r/o,d=n/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-a,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){let t=f.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(let t of this._figures)!function(t,e,i){let s,a,r=e.coords,n=e.colors;switch(e.type){case"lattice":let o=e.verticesPerRow,l=Math.floor(r.length/o)-1,h=o-1;for(s=0;s<l;s++){let e=s*o;for(let s=0;s<h;s++,e++)tY(t,i,r[e],r[e+1],r[e+o],n[e],n[e+1],n[e+o]),tY(t,i,r[e+o+1],r[e+1],r[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(s=0,a=r.length;s<a;s+=3)tY(t,i,r[s],r[s+1],r[s+2],n[s],n[s+1],n[s+2]);break;default:throw Error("illegal figure")}}(f,t,c);return m.putImageData(f,2,2),{canvas:g.canvas,offsetX:s-2*h,offsetY:a-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let a;if(tq(t,this._bbox),s===tW)a=B.singularValueDecompose2dScale(tr(t));else if(a=B.singularValueDecompose2dScale(e.baseTransform),this.matrix){let t=B.singularValueDecompose2dScale(this.matrix);a=[a[0]*t[0],a[1]*t[1]]}let r=this._createMeshCanvas(a,s===tW?null:this._background,e.cachedCanvases);return s!==tW&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class tJ extends tX{getPattern(){return"hotpink"}}class tZ{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=a}createPatternCanvas(t){let{bbox:e,operatorList:i,paintType:s,tilingType:a,color:r,canvasGraphicsFactory:n}=this,{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),v("TilingType: "+a);let h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,m=B.singularValueDecompose2dScale(this.matrix),f=B.singularValueDecompose2dScale(this.baseTransform),b=m[0]*f[0],A=m[1]*f[1],y=p,w=g,_=!1,x=!1,S=Math.ceil(l*A),C=Math.ceil(g*A);Math.ceil(o*b)>=Math.ceil(p*b)?y=o:_=!0,S>=C?w=l:x=!0;let E=this.getSizeAndScale(y,this.ctx.canvas.width,b),T=this.getSizeAndScale(w,this.ctx.canvas.height,A),M=t.cachedCanvases.getCanvas("pattern",E.size,T.size),P=M.context,k=n.createCanvasGraphics(P);if(k.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(k,s,r),P.translate(-E.scale*h,-T.scale*d),k.transform(E.scale,0,0,T.scale,0,0),P.save(),this.clipBbox(k,h,d,c,u),k.baseTransform=tr(k.ctx),k.executeOperatorList(i),k.endDrawing(),P.restore(),_||x){let e=M.canvas;_&&(y=o),x&&(w=l);let i=this.getSizeAndScale(y,this.ctx.canvas.width,b),s=this.getSizeAndScale(w,this.ctx.canvas.height,A),a=i.size,r=s.size,n=t.cachedCanvases.getCanvas("pattern-workaround",a,r),c=n.context,u=_?Math.floor(p/o):0,m=x?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=m;i++)c.drawImage(e,a*t,r*i,a,r,0,0,a,r);return{canvas:n.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:M.canvas,scaleX:E.scale,scaleY:T.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){let s=Math.max(tZ.MAX_PATTERN_SIZE,e),a=Math.ceil(t*i);return a>=s?a=s:i=a/t,{scale:i,size:a}}clipBbox(t,e,i,s,a){let r=s-e,n=a-i;t.ctx.rect(e,i,r,n),t.current.updateRectMinMax(tr(t.ctx),[e,i,s,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,a=t.current;switch(e){case 1:let r=this.ctx;s.fillStyle=r.fillStyle,s.strokeStyle=r.strokeStyle,a.fillColor=r.fillStyle,a.strokeColor=r.strokeStyle;break;case 2:let n=B.makeHexColor(i[0],i[1],i[2]);s.fillStyle=n,s.strokeStyle=n,a.fillColor=n,a.strokeColor=n;break;default:throw new D(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let a=i;s!==tW&&(a=B.transform(a,e.baseTransform),this.matrix&&(a=B.transform(a,this.matrix)));let r=this.createPatternCanvas(e),n=new DOMMatrix(a);n=(n=n.translate(r.offsetX,r.offsetY)).scale(1/r.scaleX,1/r.scaleY);let o=t.createPattern(r.canvas,"repeat");return o.setTransform(n),o}}class t0{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function t1(t,e,i,s,a,r,n,o,l,h){let[d,c,u,p,g,m]=tr(t);if(0===c&&0===u){let f=Math.round(n*d+g),b=Math.round(o*p+m),A=Math.abs(Math.round((n+l)*d+g)-f)||1,v=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,a,r,0,0,A,v),t.setTransform(d,c,u,p,g,m),[A,v]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(n*c+m),A=Math.abs(Math.round((o+h)*u+g)-f)||1,v=Math.abs(Math.round((n+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,a,r,0,0,v,A),t.setTransform(d,c,u,p,g,m),[v,A]}return t.drawImage(e,i,s,a,r,n,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class t2{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=l,this.textMatrixScale=1,this.fontMatrix=h,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=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=B.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){let i=B.applyTransform(e,t),s=B.applyTransform(e.slice(2),t),a=B.applyTransform([e[0],e[3]],t),r=B.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],a[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],a[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],a[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],a[1],r[1])}updateScalingPathMinMax(t,e){B.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,a,r,n,o,l,h){let d=B.bezierBoundingBox(e,i,s,a,r,n,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=tj,e=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(t===tV){e||w("Stroke bounding box must include transform.");let t=B.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,a=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=a,i[2]+=s,i[3]+=a}return i}updateClipFromPath(){let t=B.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=tj,e=null){return B.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function t3(t,e){let i,s,a,r;if(e instanceof ImageData)return void t.putImageData(e,0,0);let n=e.height,o=e.width,l=n%16,h=(n-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,p,m=e.data,f=c.data;if(e.kind===g.GRAYSCALE_1BPP){let e=m.byteLength,r=new Uint32Array(f.buffer,0,f.byteLength>>2),n=r.length,g=o+7>>3,b=N.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(s=0,a=i<h?16:l,p=0;s<a;s++){let t=e-u,i=0,s=t>g?o:8*t-7,a=-8&s,n=0,l=0;for(;i<a;i+=8)l=m[u++],r[p++]=128&l?0xffffffff:b,r[p++]=64&l?0xffffffff:b,r[p++]=32&l?0xffffffff:b,r[p++]=16&l?0xffffffff:b,r[p++]=8&l?0xffffffff:b,r[p++]=4&l?0xffffffff:b,r[p++]=2&l?0xffffffff:b,r[p++]=1&l?0xffffffff:b;for(;i<s;i++)0===n&&(l=m[u++],n=128),r[p++]=l&n?0xffffffff:b,n>>=1}for(;p<n;)r[p++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===g.RGBA_32BPP){for(i=0,s=0,r=16*o*4;i<h;i++)f.set(m.subarray(u,u+r)),u+=r,t.putImageData(c,0,s),s+=16;i<d&&(r=o*l*4,f.set(m.subarray(u,u+r)),t.putImageData(c,0,s))}else if(e.kind===g.RGB_24BPP)for(i=0,r=o*(a=16);i<d;i++){for(i>=h&&(r=o*(a=l)),p=0,s=r;s--;)f[p++]=m[u++],f[p++]=m[u++],f[p++]=m[u++],f[p++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function t5(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,s=e.width,a=i%16,r=(i-a)/16,n=0===a?r:r+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<n;e++){let i=e<r?16:a;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:a,nonBlackColor:r=0xffffffff,inverseDecode:n=!1}){let o=N.isLittleEndian?0xff000000:255,[l,h]=n?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<a;s++){for(let s=e+d;e<s;e++){let s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;let s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function t6(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function t4(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!o){let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function t8(t,e){if(e)return!0;let i=B.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);let s=Math.fround((globalThis.devicePixelRatio||1)*j.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}let t7=["butt","round","square"],t9=["miter","round","bevel"],et={},ee={};class ei{constructor(t,e,i,s,a,{optionalContentConfig:r,markedContentStack:n=null},o,l){this.ctx=t,this.current=new t2(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=a,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=n||[],this.optionalContentConfig=r,this.cachedCanvases=new t0(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let a=this.ctx.canvas.width,r=this.ctx.canvas.height,n=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,a,r),this.ctx.fillStyle=n,i){let t=this.cachedCanvases.getCanvas("transparent",a,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...tr(this.compositeCtx))}this.ctx.save(),t4(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=tr(this.ctx)}executeOperatorList(t,e,i,s){let a,r=t.argsArray,n=t.fnArray,o=e||0,l=r.length;if(l===o)return o;let h=l-o>10&&"function"==typeof i,d=h?Date.now()+15:0,c=0,u=this.commonObjs,p=this.objs;for(;;){if(void 0!==s&&o===s.nextBreakPoint)return s.breakIt(o,i),o;if((a=n[o])!==f.dependency)this[a].apply(this,r[o]);else for(let t of r[o]){let e=t.startsWith("g_")?u:p;if(!e.has(t))return e.get(t,i),o}if(++o===l)return o;if(h&&++c>10){if(Date.now()>d)return i(),o;c=0}}}#io(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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)}endDrawing(){for(let t of(this.#io(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#il()}#il(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,s,a=t.width??t.displayWidth,r=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=a,h=r,d="prescale1";for(;n>2&&l>1||o>2&&h>1;){let e=l,a=h;n>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),n/=l/e),o>2&&h>1&&(a=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/a),(s=(i=this.cachedCanvases.getCanvas(d,e,a)).context).clearRect(0,0,e,a),s.drawImage(t,0,0,l,h,0,0,e,a),t=i.canvas,l=e,h=a,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){let e,i,s,a,r=this.ctx,{width:n,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,d=tr(r);if((t.bitmap||t.data)&&t.count>1){let a=t.bitmap||t.data.buffer;i=JSON.stringify(h?d:[d.slice(0,4),l]),(e=this._cachedBitmapsMap.get(a))||(e=new Map,this._cachedBitmapsMap.set(a,e));let r=e.get(i);if(r&&!h)return{canvas:r,offsetX:Math.round(Math.min(d[0],d[2])+d[4]),offsetY:Math.round(Math.min(d[1],d[3])+d[5])};s=r}s||t5((a=this.cachedCanvases.getCanvas("maskCanvas",n,o)).context,t);let c=B.transform(d,[1/n,0,0,-1/o,0,0]);c=B.transform(c,[1,0,0,1,0,-o]);let[u,p,g,m]=B.getAxialAlignedBoundingBox([0,0,n,o],c),f=Math.round(g-u)||1,b=Math.round(m-p)||1,A=this.cachedCanvases.getCanvas("fillCanvas",f,b),v=A.context;v.translate(-u,-p),v.transform(...c),!s&&(s=(s=this._scaleImage(a.canvas,tn(v))).img,e&&h&&e.set(i,s)),v.imageSmoothingEnabled=t8(tr(v),t.interpolate),t1(v,s,0,0,s.width,s.height,0,0,n,o),v.globalCompositeOperation="source-in";let y=B.transform(tn(v),[1,0,0,1,-u,-p]);return v.fillStyle=h?l.getPattern(r,this,y,tj):l,v.fillRect(0,0,n,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(i,A.canvas)),{canvas:A.canvas,offsetX:Math.round(u),offsetY:Math.round(p)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=t7[t]}setLineJoin(t){this.ctx.lineJoin=t9[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;let a=this.ctx;a.setTransform(...tr(this.suspendedCtx)),t6(this.suspendedCtx,a);var r=this.suspendedCtx;if(a._removeMirroring)throw Error("Context is already forwarding operations.");a.__originalSave=a.save,a.__originalRestore=a.restore,a.__originalRotate=a.rotate,a.__originalScale=a.scale,a.__originalTranslate=a.translate,a.__originalTransform=a.transform,a.__originalSetTransform=a.setTransform,a.__originalResetTransform=a.resetTransform,a.__originalClip=a.clip,a.__originalMoveTo=a.moveTo,a.__originalLineTo=a.lineTo,a.__originalBezierCurveTo=a.bezierCurveTo,a.__originalRect=a.rect,a.__originalClosePath=a.closePath,a.__originalBeginPath=a.beginPath,a._removeMirroring=()=>{a.save=a.__originalSave,a.restore=a.__originalRestore,a.rotate=a.__originalRotate,a.scale=a.__originalScale,a.translate=a.__originalTranslate,a.transform=a.__originalTransform,a.setTransform=a.__originalSetTransform,a.resetTransform=a.__originalResetTransform,a.clip=a.__originalClip,a.moveTo=a.__originalMoveTo,a.lineTo=a.__originalLineTo,a.bezierCurveTo=a.__originalBezierCurveTo,a.rect=a.__originalRect,a.closePath=a.__originalClosePath,a.beginPath=a.__originalBeginPath,delete a._removeMirroring},a.save=function(){r.save(),this.__originalSave()},a.restore=function(){r.restore(),this.__originalRestore()},a.translate=function(t,e){r.translate(t,e),this.__originalTranslate(t,e)},a.scale=function(t,e){r.scale(t,e),this.__originalScale(t,e)},a.transform=function(t,e,i,s,a,n){r.transform(t,e,i,s,a,n),this.__originalTransform(t,e,i,s,a,n)},a.setTransform=function(t,e,i,s,a,n){r.setTransform(t,e,i,s,a,n),this.__originalSetTransform(t,e,i,s,a,n)},a.resetTransform=function(){r.resetTransform(),this.__originalResetTransform()},a.rotate=function(t){r.rotate(t),this.__originalRotate(t)},a.clip=function(t){r.clip(t),this.__originalClip(t)},a.moveTo=function(t,e){r.moveTo(t,e),this.__originalMoveTo(t,e)},a.lineTo=function(t,e){r.lineTo(t,e),this.__originalLineTo(t,e)},a.bezierCurveTo=function(t,e,i,s,a,n){r.bezierCurveTo(t,e,i,s,a,n),this.__originalBezierCurveTo(t,e,i,s,a,n)},a.rect=function(t,e,i,s){r.rect(t,e,i,s),this.__originalRect(t,e,i,s)},a.closePath=function(){r.closePath(),this.__originalClosePath()},a.beginPath=function(){r.beginPath(),this.__originalBeginPath()},this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),t6(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),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()}composeSMask(t,e,i,s){let a=s[0],r=s[1],n=s[2]-a,o=s[3]-r;0!==n&&0!==o&&(this.genericComposeSMask(e.context,i,n,o,e.subtype,e.backdrop,e.transferMap,a,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,a,r,n,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r){let e=B.makeHexColor(...r);if(u<0||p<0||u+i>c.width||p+s>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,s),a=t.context;a.drawImage(c,-u,-p),a.globalCompositeOperation="destination-atop",a.fillStyle=e,a.fillRect(0,0,i,s),a.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let a=new Path2D;a.rect(u,p,i,s),t.clip(a),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===a&&n?e.filter=this.filterFactory.addAlphaFilter(n):"Luminosity"===a&&(e.filter=this.filterFactory.addLuminosityFilter(n));let g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(t6(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),t6(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,a,r){this.ctx.transform(t,e,i,s,a,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let s,a,r=this.ctx,n=this.current,o=n.x,l=n.y,h=tr(r),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case f.rectangle:o=e[u++],l=e[u++];let p=e[u++],g=e[u++],m=o+p,b=l+g;r.moveTo(o,l),0===p||0===g?r.lineTo(m,b):(r.lineTo(m,l),r.lineTo(m,b),r.lineTo(o,b)),d||n.updateRectMinMax(h,[o,l,m,b]),r.closePath();break;case f.moveTo:o=e[u++],l=e[u++],r.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case f.lineTo:o=e[u++],l=e[u++],r.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case f.curveTo:s=o,a=l,o=e[u+4],l=e[u+5],r.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,s,a,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case f.curveTo2:s=o,a=l,r.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,s,a,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case f.curveTo3:s=o,a=l,o=e[u+2],l=e[u+3],r.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,s,a,e[u],e[u+1],o,l,o,l,c),u+=4;break;case f.closePath:r.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,tn(e),tV),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,i=this.current.fillColor,s=this.current.patternFill,a=!1;s&&(e.save(),e.fillStyle=i.getPattern(e,this,tn(e),tj),a=!0);let r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),a&&e.restore(),t&&this.consumePath(r)}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=et}eoClip(){this.pendingClip=ee}beginText(){this.current.textMatrix=l,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();let i=new Path2D,s=e.getTransform().invertSelf();for(let{transform:e,x:a,y:r,fontSize:n,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(a,r).scale(n,-n));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let i=this.commonObjs.get(t),s=this.current;if(!i)throw Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||h,(0===s.fontMatrix[0]||0===s.fontMatrix[3])&&y("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;let a=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${a}", ${i.fallbackName}`,n="normal";i.black?n="900":i.bold&&(n="bold");let o=i.italic?"italic":"normal",l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${n} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,a,r){this.current.textMatrix=[t,e,i,s,a,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#ih(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,a){let r,n=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,c=3&h,u=!!(4&h),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;if((l.disableFontFace||u||p||g)&&(r=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||g){if(n.save(),n.translate(e,i),n.scale(d,-d),0===c||2===c)if(s){let t=n.getTransform();n.setTransform(...s),n.fill(this.#ih(r,t,s))}else n.fill(r);if(1===c||2===c)if(a){let t=n.getTransform();n.setTransform(...a),n.stroke(this.#ih(r,t,a))}else n.lineWidth/=d,n.stroke(r);n.restore()}else(0===c||2===c)&&n.fillText(t,e,i),(1===c||2===c)&&n.strokeText(t,e,i);u&&(this.pendingTextPaths||=[]).push({transform:tr(n),x:e,y:i,fontSize:d,path:r})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return S(this,"isFontSubpixelAAEnabled",i)}showText(t){let e,i,s=this.current,a=s.font;if(a.isType3Font)return this.showType3Text(t);let r=s.fontSize;if(0===r)return;let n=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,d=s.fontDirection,c=s.textHScale*d,u=t.length,p=a.vertical,g=p?1:-1,m=a.defaultVMetrics,f=r*s.fontMatrix[0],b=0===s.textRenderingMode&&!a.disableFontFace&&!s.patternFill;if(n.save(),n.transform(...s.textMatrix),n.translate(s.x,s.y+s.textRise),d>0?n.scale(c,-1):n.scale(c,1),s.patternFill){n.save();let t=s.fillColor.getPattern(n,this,tn(n),tj);e=tr(n),n.restore(),n.fillStyle=t}if(s.patternStroke){n.save();let t=s.strokeColor.getPattern(n,this,tn(n),tV);i=tr(n),n.restore(),n.strokeStyle=t}let A=s.lineWidth,v=s.textMatrixScale;if(0===v||0===A){let t=3&s.textRenderingMode;(1===t||2===t)&&(A=this.getSinglePixelWidth())}else A/=v;if(1!==o&&(n.scale(o,o),A/=o),n.lineWidth=A,a.isInvalidPDFjsFont){let e=[],i=0;for(let s of t)e.push(s.unicode),i+=s.width;n.fillText(e.join(""),0,0),s.x+=i*f*c,n.restore(),this.compose();return}let y=0,w;for(w=0;w<u;++w){let s,c,u=t[w];if("number"==typeof u){y+=g*u*r/1e3;continue}let A=!1,v=(u.isSpace?h:0)+l,_=u.fontChar,x=u.accent,S=u.width;if(p){let t=u.vmetric||m,e=-(u.vmetric?t[1]:.5*S)*f,i=t[2]*f;S=t?-t[0]:S,s=e/o,c=(y+i)/o}else s=y/o,c=0;if(a.remeasure&&S>0){let t=1e3*n.measureText(_).width/r*o;if(S<t&&this.isFontSubpixelAAEnabled){let e=S/t;A=!0,n.save(),n.scale(e,1),s/=e}else S!==t&&(s+=(S-t)/2e3*r/o)}if(this.contentVisible&&(u.isInFont||a.missingFile)){if(b&&!x)n.fillText(_,s,c);else if(this.paintChar(_,s,c,e,i),x){let t=s+r*x.offset.x/o,a=c-r*x.offset.y/o;this.paintChar(x.fontChar,t,a,e,i)}}y+=p?S*f-v*d:S*f+v*d,A&&n.restore()}p?s.y-=y:s.x+=y*c,n.restore(),this.compose()}showType3Text(t){let e,i,s,a,r=this.ctx,n=this.current,o=n.font,l=n.fontSize,d=n.fontDirection,c=o.vertical?1:-1,u=n.charSpacing,p=n.wordSpacing,g=n.textHScale*d,m=n.fontMatrix||h,f=t.length;if(3!==n.textRenderingMode&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),r.transform(...n.textMatrix),r.translate(n.x,n.y),r.scale(g,d),e=0;e<f;++e){if("number"==typeof(i=t[e])){a=c*i*l/1e3,this.ctx.translate(a,0),n.x+=a*g;continue}let h=(i.isSpace?p:0)+u,d=o.charProcOperatorList[i.operatorListId];if(!d){y(`Type3 character "${i.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=i,this.save(),r.scale(l,l),r.transform(...m),this.executeOperatorList(d),this.restore()),s=B.applyTransform([i.width,0],m)[0]*l+h,r.translate(s,0),n.x+=s*g}r.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,a,r){this.ctx.rect(i,s,a-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){let i=t[1],s=this.baseTransform||tr(this.ctx);e=new tZ(t,i,this.ctx,{createCanvasGraphics:t=>new ei(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=B.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=B.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new tK(t);case"Mesh":return new tQ(t);case"Dummy":return new tJ}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save(),e.fillStyle=this._getPattern(t).getPattern(e,this,tn(e),tW);let i=tn(e);if(i){let{width:t,height:s}=e.canvas,[a,r,n,o]=B.getAxialAlignedBoundingBox([0,0,t,s],i);this.ctx.fillRect(a,r,n-a,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){w("Should not call beginInlineImage")}beginImageData(){w("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=tr(this.ctx),e)){let t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(tr(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let e=this.ctx;t.isolated||v("TODO: Support non-isolated groups."),t.knockout&&y("Knockout groups not supported.");let i=tr(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw Error("Bounding box is required.");let s=B.getAxialAlignedBoundingBox(t.bbox,tr(e)),a=[0,0,e.canvas.width,e.canvas.height],r=Math.floor((s=B.intersect(s,a)||[0,0,0,0])[0]),n=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-n,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);let d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-r,-n),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:r,offsetY:n,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,n),e.save()),t6(e,c),this.ctx=c,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let t=tr(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);let i=B.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,a){if(this.#io(),t4(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let s=e[2]-e[0],r=e[3]-e[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;let[a,n]=B.singularValueDecompose2dScale(tr(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);let{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(a,0,0,-n,0,r*n),t4(this.ctx)}else t4(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new t2(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#il(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;(t=this.getObject(t.data,t)).count=e;let i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){let e,i,s,{width:a,height:r}=t;if(a>1e3||r>1e3)return null;let n=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=a+1,l=new Uint8Array(o*(r+1)),h=a+7&-8,d=new Uint8Array(h*r),c=0;for(let e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(0!==d[c=0]&&(l[0]=1,++u),i=1;i<a;i++)d[c]!==d[c+1]&&(l[i]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[i]=2,++u),e=1;e<r;e++){c=e*h,s=e*o,d[c-h]!==d[c]&&(l[s]=d[c]?1:8,++u);let t=4*!!d[c]+8*!!d[c-h];for(i=1;i<a;i++)n[t=(t>>2)+4*!!d[c+1]+8*!!d[c-h+1]]&&(l[s+i]=n[t],++u),c++;if(d[c-h]!==d[c]&&(l[s+i]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(r-1),s=e*o,0!==d[c]&&(l[s]=8,++u),i=1;i<a;i++)d[c]!==d[c+1]&&(l[s+i]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[s+i]=4,++u),u>1e3)return null;let p=new Int32Array([0,o,-1,0,-o,0,0,0,1]),g=new Path2D;for(e=0;u&&e<=r;e++){let t=e*o,i=t+a;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%o,e);let s=t,r=l[t];do{let e=p[r];do t+=e;while(!l[t]);let i=l[t];5!==i&&10!==i?(r=i,l[t]=0):(r=i&51*r>>4,l[t]&=r>>2|r<<2),g.lineTo(t%o,t/o|0),!l[t]&&--u}while(s!==t);--e}return d=null,l=null,function(t){t.save(),t.scale(1/a,-1/r),t.translate(0,-r),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);let a=this._createMaskCanvas(t),r=a.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,a.offsetX,a.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,a,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);let n=this.ctx;n.save();let o=tr(n);n.transform(e,i,s,a,0,0);let l=this._createMaskCanvas(t);n.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){let h=B.transform(o,[e,i,s,a,r[t],r[t+1]]),[d,c]=B.applyTransform([0,0],h);n.drawImage(l.canvas,d,c)}n.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(let a of t){let{data:t,width:r,height:n,transform:o}=a,l=this.cachedCanvases.getCanvas("maskCanvas",r,n),h=l.context;h.save(),t5(h,this.getObject(t,a)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,tn(e),tj):i,h.fillRect(0,0,r,n),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),t1(e,l.canvas,0,0,r,n,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);e?this.paintInlineImageXObject(e):y("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;let a=this.getObject(t);if(!a)return void y("Dependent image isn't ready yet");let r=a.width,n=a.height,o=[];for(let t=0,a=s.length;t<a;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:n});this.paintInlineImageXObjectGroup(a,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;let{bitmap:e,width:i,height:s}=t,a=this.cachedCanvases.getCanvas("inlineImage",i,s),r=a.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",a.canvas}paintInlineImageXObject(t){let e;if(!this.contentVisible)return;let i=t.width,s=t.height,a=this.ctx;if(this.save(),!o){let{filter:t}=a;"none"!==t&&""!==t&&(a.filter="none")}if(a.scale(1/i,-1/s),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{let a=this.cachedCanvases.getCanvas("inlineImage",i,s).context;t3(a,t),e=this.applyTransferMapsToCanvas(a)}let r=this._scaleImage(e,tn(a));a.imageSmoothingEnabled=t8(tr(a),t.interpolate),t1(a,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,i,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){let i;if(!this.contentVisible)return;let s=this.ctx;if(t.bitmap)i=t.bitmap;else{let e=t.width,s=t.height,a=this.cachedCanvases.getCanvas("inlineImage",e,s).context;t3(a,t),i=this.applyTransferMapsToCanvas(a)}for(let t of e)s.save(),s.transform(...t.transform),s.scale(1,-1),t1(s,i,t.x,t.y,t.w,t.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let i=this.ctx;this.pendingClip&&(e||(this.pendingClip===ee?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=tr(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:a,c:r,d:n}=this.ctx.getTransform();if(0===a&&0===r){let a=Math.abs(s),r=Math.abs(n);if(a===r)if(0===i)t=e=1/a;else{let s=a*i;t=e=s<1?1/s:1}else if(0===i)t=1/a,e=1/r;else{let s=a*i,n=r*i;t=s<1?1/s:1,e=n<1?1/n:1}}else{let o=Math.abs(s*n-a*r),l=Math.hypot(s,a),h=Math.hypot(r,n);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:i}=this.current,[s,a]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===a)return void e.stroke();let r=e.getLineDash();if(t&&e.save(),e.scale(s,a),r.length>0){let t=Math.max(s,a);e.setLineDash(r.map(e=>e/t)),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in f)void 0!==ei.prototype[t]&&(ei.prototype[f[t]]=ei.prototype[t]);class es{static #id=null;static #ic="";static get workerPort(){return this.#id}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#id=t}static get workerSrc(){return this.#ic}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#ic=t}}class ea{#iu;#ip;constructor({parsedData:t,rawData:e}){this.#iu=t,this.#ip=e}getRaw(){return this.#ip}get(t){return this.#iu.get(t)??null}getAll(){return F(this.#iu)}has(t){return this.#iu.has(t)}}let er=Symbol("INTERNAL");class en{#ig=!1;#im=!1;#ib=!1;#iA=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:a}){this.#ig=!!(2&t),this.#im=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=a}get visible(){if(this.#ib)return this.#iA;if(!this.#iA)return!1;let{print:t,view:e}=this.usage;return this.#ig?e?.viewState!=="OFF":!this.#im||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==er&&w("Internal method `_setVisible` called."),this.#ib=i,this.#iA=e}}class eo{#iv=null;#iy=new Map;#iw=null;#i_=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#i_=t.order,t.groups))this.#iy.set(i.id,new en(e,i));if("OFF"===t.baseState)for(const t of this.#iy.values())t._setVisible(er,!1);for(const e of t.on)this.#iy.get(e)._setVisible(er,!0);for(const e of t.off)this.#iy.get(e)._setVisible(er,!1);this.#iw=this.getHash()}#ix(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,a=t[s];if(Array.isArray(a))e=this.#ix(a);else{if(!this.#iy.has(a))return y(`Optional content group not found: ${a}`),!0;e=this.#iy.get(a).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#iy.size)return!0;if(!t)return v("Optional content group not defined."),!0;if("OCG"===t.type)return this.#iy.has(t.id)?this.#iy.get(t.id).visible:(y(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#ix(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#iy.has(e)){y(`Optional content group not found: ${e}`);break}if(!this.#iy.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#iy.has(e))return y(`Optional content group not found: ${e}`),!0;if(!this.#iy.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#iy.has(e)){y(`Optional content group not found: ${e}`);break}if(this.#iy.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#iy.has(e))return y(`Optional content group not found: ${e}`),!0;if(this.#iy.get(e).visible)return!0}return!1}return y(`Unknown optional content policy ${t.policy}.`),!0}return y(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#iy.get(t);if(!s)return void y(`Optional content group not found: ${t}`);if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#iy.get(i)?._setVisible(er,!1,!0);s._setVisible(er,!!e,!0),this.#iv=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#iy.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#iv=null}get hasInitialVisibility(){return null===this.#iw||this.getHash()===this.#iw}getOrder(){return this.#iy.size?this.#i_?this.#i_.slice():[...this.#iy.keys()]:null}getGroups(){return this.#iy.size>0?F(this.#iy):null}getGroup(t){return this.#iy.get(t)||null}getHash(){if(null!==this.#iv)return this.#iv;let t=new t_;for(let[e,i]of this.#iy)t.update(`${e}:${i.visible}`);return this.#iv=t.hexdigest()}}class el{constructor(t,{disableRange:e=!1,disableStream:i=!1}){_(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:a,progressiveDone:r,contentDispositionFilename:n}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=n,a?.length>0){const t=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):_(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){_(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new eh(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ed(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeReaders.slice(0)))e.cancel(t);this._pdfDataRangeTransport.abort()}}class eh{constructor(t,e,i=!1,s=null){for(const a of(this._stream=t,this._done=i||!1,this._filename=K(s)?s:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=a.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ed{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.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){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ec(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function eu(t){try{return new URL(t).origin}catch{}return null}function ep({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let a={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)&&(a.suggestedLength=r,r<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0)),a}function eg(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=n(i=i[1]);return r(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],a=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=a.exec(t));){let[,t,s,a]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,a]}let r=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=n(s),e&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t))return r(l(i));if(i=s("filename","i").exec(t)){let t=n(i=i[1]);return r(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function a(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),a=L(i);i=s.decode(a),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=a("utf-8",t),e&&(t=a("iso-8859-1",t))),t}function n(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:a(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return a(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return a(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(K(t))return t}return null}function em(t,e){return 404===t||0===t&&e.startsWith("file:")?new P('Missing PDF "'+e+'".'):new k(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function ef(t){return 200===t||206===t}function eb(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function eA(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(y(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class ev{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ec(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return _(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ey(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ew(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class ey{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,eb(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=eu(e.url),!ef(e.status))throw em(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();let i=e.headers,{allowRangeRequests:a,suggestedLength:r}=ep({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=r||this._contentLength,this._filename=eg(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new R("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:eA(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ew{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const a=new Headers(t.headers);a.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,eb(a,this._withCredentials,this._abortController)).then(e=>{let i=eu(e.url);if(i!==t._responseOrigin)throw Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ef(e.status))throw em(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:eA(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class e_{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=ec(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};for(let[t,i]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",_(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){let i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){let i,s=this.pendingRequests[t];if(!s)return;let a=s.xhr;if(a.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==a.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===a.status&&this.isHttp)return void s.onError(a.status);let r=a.status||200;if((200!==r||206!==s.expectedStatus)&&r!==s.expectedStatus)return void s.onError(a.status);let n="string"!=typeof(i=a.response)?i:L(i).buffer;if(206===r){let t=a.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?s.onDone({begin:parseInt(e[1],10),chunk:n}):(y('Missing or invalid "Content-Range" header.'),s.onError(0))}else n?s.onDone({begin:0,chunk:n}):s.onError(a.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class ex{constructor(t){this._source=t,this._manager=new e_(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return _(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new eS(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let i=new eC(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eS{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.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(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=eu(e.responseURL);let i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:r}=ep({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=eg(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(let e of(this._storedError=em(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.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._headersCapability.promise}async read(){if(await this._headersCapability.promise,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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class eC{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=eu(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;for(let t of(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){for(let e of(this._storedError??=em(t,this._url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}let eE=/^[a-z][a-z0-9\-+.]+:/i;class eT{constructor(t){this.source=t,this.url=function(t){return new URL(eE.test(t)?t:s.getBuiltinModule("url").pathToFileURL(t))}(t.url),_("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return _(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new eM(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new eP(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eM{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=s.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=new P(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new R("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class eP{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const a=t.source;this._isStreamingSupported=!a.disableStream;const r=s.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class ek{#iS=Promise.withResolvers();#tp=null;#iC=!1;#iE=!!globalThis.FontInspector?.enabled;#iT=null;#iM=null;#iP=0;#ik=0;#iD=null;#iR=null;#iI=0;#iL=0;#iF=Object.create(null);#iN=[];#iO=null;#iB=[];#iz=new WeakMap;#iH=null;static #i$=new Map;static #iG=new Map;static #iU=new WeakMap;static #ij=null;static #iV=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#iO=t;else if("object"==typeof t)this.#iO=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tp=this.#iR=e,this.#iL=i.scale*(globalThis.devicePixelRatio||1),this.#iI=i.rotation,this.#iM={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:a,pageX:r,pageY:n}=i.rawDims;this.#iH=[1,0,0,-1,-r,n+a],this.#ik=s,this.#iP=a,ek.#iW(),to(e,i),this.#iS.promise.finally(()=>{ek.#iV.delete(this),this.#iM=null,this.#iF=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=N.platform;return S(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#iD.read().then(({value:e,done:i})=>{i?this.#iS.resolve():(this.#iT??=e.lang,Object.assign(this.#iF,e.styles),this.#iq(e.items),t())},this.#iS.reject)};return this.#iD=this.#iO.getReader(),ek.#iV.add(this),t(),this.#iS.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==this.#iI&&(e?.(),this.#iI=s,to(this.#iR,{rotation:s})),i!==this.#iL){e?.(),this.#iL=i;let t={div:null,properties:null,ctx:ek.#iX(this.#iT)};for(let e of this.#iB)t.properties=this.#iz.get(e),t.div=e,this.#iK(t)}}cancel(){let t=new R("TextLayer task cancelled.");this.#iD?.cancel(t).catch(()=>{}),this.#iD=null,this.#iS.reject(t)}get textDivs(){return this.#iB}get textContentItemsStr(){return this.#iN}#iq(t){if(this.#iC)return;this.#iM.ctx??=ek.#iX(this.#iT);let e=this.#iB,i=this.#iN;for(let s of t){if(e.length>1e5){y("Ignoring additional textDivs for performance reasons."),this.#iC=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tp;this.#tp=document.createElement("span"),this.#tp.classList.add("markedContent"),null!==s.id&&this.#tp.setAttribute("id",`${s.id}`),t.append(this.#tp)}else"endMarkedContent"===s.type&&(this.#tp=this.#tp.parentNode);continue}i.push(s.str),this.#iY(s)}}#iY(t){let e,i,s=document.createElement("span"),a={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#iB.push(s);let r=B.transform(this.#iH,t.transform),n=Math.atan2(r[1],r[0]),o=this.#iF[t.fontName];o.vertical&&(n+=Math.PI/2);let l=this.#iE&&o.fontSubstitution||o.fontFamily;l=ek.fontFamilyMap.get(l)||l;let h=Math.hypot(r[2],r[3]),d=h*ek.#iQ(l,this.#iT);0===n?(e=r[4],i=r[5]-d):(e=r[4]+d*Math.sin(n),i=r[5]-d*Math.cos(n));let c="calc(var(--scale-factor)*",u=s.style;this.#tp===this.#iR?(u.left=`${(100*e/this.#ik).toFixed(2)}%`,u.top=`${(100*i/this.#iP).toFixed(2)}%`):(u.left=`${c}${e.toFixed(2)}px)`,u.top=`${c}${i.toFixed(2)}px)`),u.fontSize=`${c}${(ek.#ij*h).toFixed(2)}px)`,u.fontFamily=l,a.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#iE&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==n&&(a.angle=180/Math.PI*n);let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(a.canvasWidth=o.vertical?t.height:t.width),this.#iz.set(s,a),this.#iM.div=s,this.#iM.properties=a,this.#iK(this.#iM),a.hasText&&this.#tp.append(s),a.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tp.append(t)}}#iK(t){let{div:e,properties:i,ctx:s}=t,{style:a}=e,r="";if(ek.#ij>1&&(r=`scale(${1/ek.#ij})`),0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=a,{canvasWidth:n,fontSize:o}=i;ek.#iJ(s,o*this.#iL,t);let{width:l}=s.measureText(e.textContent);l>0&&(r=`scaleX(${n*this.#iL/l}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(a.transform=r)}static cleanup(){if(!(this.#iV.size>0)){for(let{canvas:t}of(this.#i$.clear(),this.#iG.values()))t.remove();this.#iG.clear()}}static #iX(t=null){let e=this.#iG.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#iG.set(t,e),this.#iU.set(e,{size:0,family:""})}return e}static #iJ(t,e,i){let s=this.#iU.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #iW(){if(null!==this.#ij)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#ij=t.getBoundingClientRect().height,t.remove()}static #iQ(t,e){let i=this.#i$.get(t);if(i)return i;let s=this.#iX(e);s.canvas.width=s.canvas.height=30,this.#iJ(s,30,t);let a=s.measureText(""),r=a.fontBoundingBoxAscent,n=Math.abs(a.fontBoundingBoxDescent);if(r){let e=r/(r+n);return this.#i$.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,30,30),s.strokeText("g",0,0);let o=s.getImageData(0,0,30,30).data;n=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){n=Math.ceil(t/4/30);break}s.clearRect(0,0,30,30),s.strokeText("A",0,30),o=s.getImageData(0,0,30,30).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=30-Math.floor(t/4/30);break}s.canvas.width=s.canvas.height=0;let l=r?r/(r+n):.8;return this.#i$.set(t,l),l}}class eD{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,a=i.name;if("#text"===a)s=i.value;else{if(!eD.shouldBuildText(a))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}let eR=o?t$:tR,eI=o?tG:tL,eL=o?tH:tN,eF=o?tU:tB;function eN(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new eB,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(o&&"string"==typeof t)return t}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,r=t.data?function(t){if(o&&void 0!==a&&t instanceof a)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return L(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,n=t.httpHeaders||null,l=!0===t.withCredentials,h=t.password??null,d=t.range instanceof ez?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,u=t.worker instanceof eU?t.worker:null,p=t.verbosity,g="string"!=typeof t.docBaseUrl||X(t.docBaseUrl)?null:t.docBaseUrl,m="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,b=t.CMapReaderFactory||eI,v="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,y=t.StandardFontDataFactory||eF,w=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,S="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!o,C="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!o&&(N.platform.isFirefox||!globalThis.chrome),E=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,T="boolean"==typeof t.disableFontFace?t.disableFontFace:o,M=!0===t.fontExtraProperties,P=!0===t.enableXfa,k=t.ownerDocument||globalThis.document,D=!0===t.disableRange,R=!0===t.disableStream,I=!0===t.disableAutoFetch,F=!0===t.pdfBug,O=t.CanvasFactory||eR,B=t.FilterFactory||eL,z=!0===t.enableHWA,H=d?d.length:t.length??NaN,$="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!o&&!T,G="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:b===tL&&y===tB&&m&&v&&Z(m,document.baseURI)&&Z(v,document.baseURI);Number.isInteger(p)&&(A=p);let U={canvasFactory:new O({ownerDocument:k,enableHWA:z}),filterFactory:new B({docId:i,ownerDocument:k}),cMapReaderFactory:G?null:new b({baseUrl:m,isCompressed:f}),standardFontDataFactory:G?null:new y({baseUrl:v})};if(!u){let t={verbosity:p,port:es.workerPort};e._worker=u=t.port?eU.fromPort(t):new eU(t)}let j={docId:i,apiVersion:"4.10.38",data:r,password:h,disableAutoFetch:I,rangeChunkSize:c,length:H,docBaseUrl:g,enableXfa:P,evaluatorOptions:{maxImageSize:_,disableFontFace:T,ignoreErrors:w,isEvalSupported:x,isOffscreenCanvasSupported:S,isImageDecoderSupported:C,canvasMaxAreaInBytes:E,fontExtraProperties:M,useSystemFonts:$,cMapUrl:G?m:null,standardFontDataUrl:G?v:null}},V={disableFontFace:T,fontExtraProperties:M,ownerDocument:k,pdfBug:F,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:P}};return u.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let a=u.messageHandler.sendWithPromise("GetDocRequest",j,r?[r.buffer]:null);if(d)t=new el(d,{disableRange:D,disableStream:R});else if(!r){let e;if(!s)throw Error("getDocument - no `url` parameter provided.");if(o)if(Z(s)){if("u"<typeof fetch||"u"<typeof Response||!("body"in Response.prototype))throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=ev}else e=eT;else e=Z(s)?ev:ex;t=new e({url:s,length:H,httpHeaders:n,withCredentials:l,rangeChunkSize:c,disableRange:D,disableStream:R})}return a.then(s=>{if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let a=new tk(i,s,u.port),r=new ej(a,e,t,V,U);e._transport=r,a.send("Ready",null)})}).catch(e._capability.reject),e}function eO(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class eB{static #e2=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${eB.#e2++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}class ez{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(let i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let i of this._progressListeners)i(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){w("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class eH{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return S(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}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(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}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()}}class e${#iZ=null;#i0=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new J:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new eW,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:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:a=!1}={}){return new W({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:a})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return S(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=d.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:n=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:c=!1}){this._stats?.time("Overall");let u=this._transport.getRenderingIntent(i,s,h,c),{renderingIntent:p,cacheKey:g}=u;this.#i0=!1,this.#i1(),n||=this._transport.getOptionalContentConfig(p);let m=this._intentStates.get(g);m||(m=Object.create(null),this._intentStates.set(g,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);let f=!!(4&p);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));let b=t=>{m.renderTasks.delete(A),(this._maybeCleanupAfterRender||f)&&(this.#i0=!0),this.#i2(!f),t?(A.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:Error(t)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new eX({callback:b,params:{canvasContext:t,viewport:e,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(m.renderTasks||=new Set).add(A);let v=A.task;return Promise.all([m.displayReadyCapability.promise,n]).then(([t,e])=>{if(this.destroyed)return void b();if(this._stats?.time("Rendering"),!(e.renderingIntent&p))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:t,optionalContentConfig:e}),A.operatorListChanged()}).catch(b),v}getOperatorList({intent:t="display",annotationMode:e=d.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let a,r=this._transport.getRenderingIntent(t,e,i,s,!0),n=this._intentStates.get(r.cacheKey);return n||(n=Object.create(null),this._intentStates.set(r.cacheKey,n)),n.opListReadCapability||((a=Object.create(null)).operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(a))},n.opListReadCapability=Promise.withResolvers(),(n.renderTasks||=new Set).add(a),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),n.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>eD.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let s=e.getReader(),a={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(a):(a.lang??=i.lang,Object.assign(a.styles,i.styles),a.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#i0=!1,this.#i1(),Promise.all(t)}cleanup(t=!1){this.#i0=!0;let e=this.#i2(!1);return t&&e&&(this._stats&&=new J),e}#i2(t=!1){if(this.#i1(),!this.#i0||this.destroyed)return!1;if(t)return this.#iZ=setTimeout(()=>{this.#iZ=null,this.#i2(!1)},5e3),!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#i0=!1,!0}#i1(){this.#iZ&&(clearTimeout(this.#iZ),this.#iZ=null)}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#i2(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:a,transfer:r}=i,n=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=n;let l=()=>{n.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#i2(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof q){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new R(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class eG{#i3=new Map;#i5=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#i5.then(()=>{for(let[t]of this.#i3)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:a}=i;if(a.aborted)return void y("LoopbackPort - cannot use an `aborted` signal.");let r=()=>this.removeEventListener(t,e);s=()=>a.removeEventListener("abort",r),a.addEventListener("abort",r)}this.#i3.set(e,s)}removeEventListener(t,e){let i=this.#i3.get(e);i?.(),this.#i3.delete(e)}terminate(){for(let[,t]of this.#i3)t?.();this.#i3.clear()}}class eU{static #i6=0;static #i4=!1;static #i8;static{o&&(this.#i4=!0,es.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(!(i=new URL(t)).origin||"null"===i.origin)return!1}catch{return!1}let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=A}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(eU.#i8?.has(e))throw Error("Cannot use more than one PDFWorker per port.");(eU.#i8||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#i7(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new tk("main","worker",t),this._messageHandler.on("ready",function(){}),this.#i7()}_initialize(){if(eU.#i4||eU.#i9)return void this._setupFakeWorker();let{workerSrc:t}=eU;try{eU._isSameOrigin(window.location.href,t)||(t=eU._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new tk("main","worker",e),s=()=>{a.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:a.signal}),i.on("test",t=>{(a.abort(),this.destroyed||!t)?s():(this._messageHandler=i,this._port=e,this._webWorker=e,this.#i7())}),i.on("ready",t=>{if(a.abort(),this.destroyed)return void s();try{r()}catch{this._setupFakeWorker()}});let r=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};r();return}catch{v("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){eU.#i4||(y("Setting up fake worker."),eU.#i4=!0),eU._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this._readyCapability.reject(Error("Worker was destroyed"));let e=new eG;this._port=e;let i=`fake${eU.#i6++}`,s=new tk(i+"_worker",i,e);t.setup(s,e),this._messageHandler=new tk(i,i+"_worker",e),this.#i7()}).catch(t=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,eU.#i8?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");let e=this.#i8?.get(t.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new eU(t)}static get workerSrc(){if(es.workerSrc)return es.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #i9(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return S(this,"_setupFakeWorkerGlobal",(async()=>this.#i9?this.#i9:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ej{#st=new Map;#se=new Map;#si=new Map;#ss=new Map;#sa=null;constructor(t,e,i,s,a){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new eW,this.fontLoader=new tE({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#sr(t,e=null){let i=this.#st.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise(t,e);return this.#st.set(t,s),s}get annotationStorage(){return S(this,"annotationStorage",new tS)}getRenderingIntent(t,e=d.ENABLE,i=null,s=!1,a=!1){let r=2,n=tx;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:y(`getRenderingIntent - invalid intent: ${t}`)}let o=4&r&&i instanceof tC?i:this.annotationStorage;switch(e){case d.DISABLE:r+=64;break;case d.ENABLE:break;case d.ENABLE_FORMS:r+=16;break;case d.ENABLE_STORAGE:r+=32,n=o.serializable;break;default:y(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=128),a&&(r+=256);let{ids:l,hash:h}=o.modifiedIds,c=[r,n.hash,h];return{renderingIntent:r,cacheKey:c.join("_"),annotationStorageSerializable:n,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#sa?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#se.values())t.push(e._destroy());this.#se.clear(),this.#si.clear(),this.#ss.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#st.clear(),this.filterFactory.destroy(),ek.cleanup(),this._networkStream?.cancelAllRequests(new R("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{_(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(_(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:s,contentLength:a}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:a}}),t.on("GetRangeReader",(t,e)=>{_(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(_(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new eH(t,this))}),t.on("DocException",t=>{e._capability.reject(tP(t))}),t.on("PasswordRequest",t=>{this.#sa=Promise.withResolvers();try{if(!e.onPassword)throw tP(t);let i=t=>{t instanceof Error?this.#sa.reject(t):this.#sa.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#sa.reject(t)}return this.#sa.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#se.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":let{disableFontFace:a,fontExtraProperties:r,pdfBug:n}=this._params;if("error"in s){let t=s.error;y(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let o=new tT(s,{disableFontFace:a,fontExtraProperties:r,inspectFont:n&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null});this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!r&&o.data&&(o.data=null),this.commonObjs.resolve(e,o)});break;case"CopyLocalImage":let{imageRef:l}=s;for(let t of(_(l,"The imageRef must be defined."),this.#se.values()))for(let[,i]of t.objs)if(i?.ref===l){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let a=this.#se.get(e);if(!a.objs.has(t)){if(0===a._intentStates.size)return void s?.bitmap?.close();switch(i){case"Image":a.objs.resolve(t,s),s?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBuiltInCMap",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)}),t.on("FetchStandardFontData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&y("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#si.get(e);if(i)return i;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw Error("Transport destroyed");i.refStr&&this.#ss.set(i.refStr,t);let s=new e$(e,i,this,this._params.pdfBug);return this.#se.set(e,s),s});return this.#si.set(e,s),s}getPageIndex(t){return eO(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#sr("GetFieldObjects")}hasJSActions(){return this.#sr("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#sr("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#sr("GetOptionalContentConfig").then(e=>new eo(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#st.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new ea(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#st.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#se.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#st.clear(),this.filterFactory.destroy(!0),ek.cleanup()}}cachedPageNumber(t){if(!eO(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#ss.get(e)??null}}let eV=Symbol("INITIAL_DATA");class eW{#sn=Object.create(null);#so(t){return this.#sn[t]||={...Promise.withResolvers(),data:eV}}get(t,e=null){if(e){let i=this.#so(t);return i.promise.then(()=>e(i.data)),null}let i=this.#sn[t];if(!i||i.data===eV)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#sn[t];return!!e&&e.data!==eV}delete(t){let e=this.#sn[t];return!!e&&e.data!==eV&&(delete this.#sn[t],!0)}resolve(t,e=null){let i=this.#so(t);i.data=e,i.resolve()}clear(){for(let t in this.#sn){let{data:e}=this.#sn[t];e?.bitmap?.close()}this.#sn=Object.create(null)}*[Symbol.iterator](){for(let t in this.#sn){let{data:e}=this.#sn[t];e!==eV&&(yield[t,e])}}}class eq{#sl=null;constructor(t){this.#sl=t,this.onContinue=null}get promise(){return this.#sl.capability.promise}cancel(t=0){this.#sl.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#sl.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#sl;return t.form||t.canvas&&e?.size>0}}class eX{#sh=null;static #sd=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:a,operatorList:r,pageIndex:n,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=n,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new eq(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=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(eX.#sd.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");eX.#sd.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:i,viewport:s,transform:a,background:r}=this.params;this.gfx=new ei(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#sh&&(window.cancelAnimationFrame(this.#sh),this.#sh=null),eX.#sd.delete(this._canvas),this.callback(t||new q(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#sh=window.requestAnimationFrame(()=>{this.#sh=null,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(),eX.#sd.delete(this._canvas),this.callback())))}}let eK="4.10.38",eY="f9bea397f";function eQ(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function eJ(t){return Math.max(0,Math.min(255,255*t))}class eZ{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=eJ(t),t,t]}static G_HTML([t]){let e=eQ(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(eJ)}static RGB_HTML(t){return`#${t.map(eQ).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[eJ(1-Math.min(1,t+s)),eJ(1-Math.min(1,i+s)),eJ(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,a=1-e,r=1-i,n=Math.min(s,a,r);return["CMYK",s,a,r,n]}}class e0{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){w("Abstract method `_createSVG` called.")}}class e1 extends e0{_createSVG(t){return document.createElementNS(U,t)}}class e2{static setupStorage(t,e,i,s,a){let r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===a)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===a)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===a)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value)for(let e of(t.setAttribute("value",r.value),i.children))e.attributes.value===r.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,a=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:a})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:a}){let{attributes:r}=e,n=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===r.type&&(r.name=`${r.name}-${s}`),Object.entries(r)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:n&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}n&&a.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,a=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:a,linkService:i});let n="richText"!==a,o=t.div;if(o.append(r),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}n&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);r.append(t),n&&eD.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,r]];for(;h.length>0;){let[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),r.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:a,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);n&&eD.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let e3=new WeakSet;function e5(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class e6{static create(t){switch(t.data.annotationType){case 2:return new e8(t);case 1:return new e7(t);case 20:switch(t.data.fieldType){case"Tx":return new it(t);case"Btn":if(t.data.radioButton)return new is(t);if(t.data.checkBox)return new ii(t);return new ia(t);case"Ch":return new ir(t);case"Sig":return new ie(t)}return new e9(t);case 16:return new io(t);case 3:return new ih(t);case 4:return new id(t);case 5:return new ic(t);case 6:return new iu(t);case 8:return new ip(t);case 14:return new im(t);case 15:return new ib(t);case 7:return new ig(t);case 9:return new iA(t);case 10:return new iv(t);case 11:return new iy(t);case 12:return new iw(t);case 13:return new i_(t);case 17:return new ix(t);default:return new e4(t)}}}class e4{#sc=null;#su=!1;#sp=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e4._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#sc||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#sg(e),this.#sp?.popup.updateEdited(t)}resetEdited(){this.#sc&&(this.#sg(this.#sc.rect),this.#sp?.popup.resetEdited(),this.#sc=null)}#sg(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:r,pageX:n,pageY:o}}}}=this;i?.splice(0,4,...t);let{width:l,height:h}=e5(t);e.left=`${100*(t[0]-n)/a}%`,e.top=`${100*(r-t[3]+o)/r}%`,0===s?(e.width=`${100*l/a}%`,e.height=`${100*h/r}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof e9||(a.tabIndex=1e3);let{style:r}=a;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof io){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,a),a}let{width:n,height:o}=e5(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?r.borderRadius=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`:this instanceof is&&(r.borderRadius=`calc(${n}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`),e.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:y("Unimplemented border style: beveled");break;case 4:y("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#su=!0,r.borderColor=B.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}let l=B.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=`${100*(l[0]-c)/h}%`,r.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=`${100*n/h}%`,r.height=`${100*o/d}%`):this.setRotation(p,a),a}setRotation(t,e=this.container){let i,s;if(!this.data.rect)return;let{pageWidth:a,pageHeight:r}=this.parent.viewport.rawDims,{width:n,height:o}=e5(this.data.rect);t%180==0?(i=100*n/a,s=100*o/r):(i=100*o/a,s=100*n/r),e.style.width=`${i}%`,e.style.height=`${s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],a=s[0],r=s.slice(1);i.target.style[e]=eZ[`${a}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:eZ[`${a}_rgb`](r)})};return S(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let a=t[s]||i[s];a?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,a]of Object.entries(e)){let r=i[s];r&&(r({detail:{[s]:a},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,a,r]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,n,o,l]=e.subarray(2,6);if(a===t&&r===n&&i===o&&s===l)return}let{style:n}=this.container;if(this.#su){let{borderColor:e,borderWidth:i}=n;n.borderWidth=0,t=["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="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=a-i,l=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,a=e.length;s<a;s+=8){let a=e[s],n=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,m=(r-n)/l,f=(a-d)/o,b=(n-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#su&&(t.push("</g></svg>')"),n.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{data:t}=this,e=this.#sp=new io({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){w("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:a,exportValues:r}of s){if(-1===t||a===e)continue;let s="string"==typeof r?r:null,n=document.querySelector(`[data-element-id="${a}"]`);if(n&&!e3.has(n)){y(`_getElementsByName - element not allowed: ${a}`);continue}i.push({id:a,exportValue:s,domElement:n})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,a=s.getAttribute("data-element-id");a!==e&&e3.has(s)&&i.push({id:a,exportValue:t,domElement:s})}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class e8 extends e4{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#sm(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#sf(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#sb(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#sb()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#sb()}#sm(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#sb()}#sf(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#sb()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let a=i.get(s);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#sb()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#sb(),!this._fieldObjects){y('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:a}=e,r=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===a&&r.push(i)}else for(let t of Object.values(this._fieldObjects))r.push(...t);let n=this.annotationStorage,o=[];for(let t of r){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";n.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;n.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";n.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!e3.has(i)){y(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class e7 extends e4{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class e9 extends e4{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return N.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,a){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:a(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:a(t)}})})}_setEventListeners(t,e,i,s){for(let[a,r]of i)("Action"===r||this.data.actions?.[r])&&(("Focus"===r||"Blur"===r)&&(e||={focused:!1}),this._setEventListener(t,e,a,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":B.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,a=t.style,r=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,r(t/i/1.35))}else e=Math.min(s,r(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));a.fontSize=`calc(${e}px * var(--scale-factor))`,a.color=B.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(a.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class it extends e9{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){let a=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),a.setValue(r.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),a=s.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&a.length>r&&(a=a.slice(0,r));let n=s.formattedValue||this.data.textContent?.join("\n")||null;n&&this.data.comb&&(n=n.replaceAll(/\s+/g,""));let o={userValue:a,formattedValue:n,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=n??a,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type="text",i.setAttribute("value",n??a),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),e3.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=1e3,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let l=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:a}=i;if(0===s)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",s);let r=o.userValue;r&&!(r.length<=s)&&(a.value=o.userValue=r=r.slice(0,s),t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=l;l=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:a,selectionStart:r,selectionEnd:n}=s,l=r,h=n;switch(t.inputType){case"deleteWordBackward":{let t=a.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=a.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===n&&(l-=1);break;case"deleteContentForward":r===n&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(l&&i.addEventListener("blur",l),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else(i=document.createElement("div")).textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ie extends e9{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class ii extends e9{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let a=document.createElement("input");return e3.add(a),a.setAttribute("data-element-id",i),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,s&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=1e3,a.addEventListener("change",s=>{let{name:a,checked:r}=s.target;for(let s of this._getElementsByName(a,i)){let i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})}),a.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class is extends e9{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let a=document.createElement("input");if(e3.add(a),a.setAttribute("data-element-id",i),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,s&&a.setAttribute("checked",!0),a.tabIndex=1e3,a.addEventListener("change",e=>{let{name:s,checked:a}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:a})}),a.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;a.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let a=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=a&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class ia extends e8{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class ir extends e9{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");e3.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=1e3;let a=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),a=!1),s.append(e)}let r=null;if(a){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}let n=t=>{let e=t?"value":"textContent",{options:i,multiple:a}=s;return a?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=n(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){r?.();let a=i.detail.value,l=new Set(Array.isArray(a)?a:[a]);for(let t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:n(!0)}),o=n(!1)},multipleSelection(t){s.multiple=!0},remove(i){let a=s.options,r=i.detail.remove;a[r].selected=!1,s.remove(r),a.length>0&&-1===Array.prototype.findIndex.call(a,t=>t.selected)&&(a[0].selected=!0),t.setValue(e,{value:n(!0),items:l(i)}),o=n(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=n(!1)},insert(i){let{index:a,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[a],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:n(!0),items:l(i)}),o=n(!1)},items(i){let{items:a}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of a){let{displayValue:e,exportValue:i}=t,a=document.createElement("option");a.textContent=e,a.value=i,s.append(a)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:n(!0),items:l(i)}),o=n(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:n(!0)}),o=n(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=n(!0),a=n(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:a,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:n(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class io extends e4{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:e4._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new il({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}),e=[];for(let i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(t=>`${G}${t}`).join(",")),this.container}}class il{#sA=this.#sv.bind(this);#sy=this.#sw.bind(this);#s_=this.#sx.bind(this);#sS=this.#sC.bind(this);#sE=null;#tp=null;#sT=null;#sM=null;#sP=null;#sk=null;#sD=null;#sR=!1;#sI=null;#E=null;#sL=null;#sF=null;#sN=null;#sc=null;#sO=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:a,contentsObj:r,richText:n,parent:o,rect:l,parentRect:h,open:d}){for(const d of(this.#tp=t,this.#sN=s,this.#sT=r,this.#sF=n,this.#sk=o,this.#sE=e,this.#sL=l,this.#sD=h,this.#sP=i,this.#sM=ti.toDateObject(a),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),this.trigger))d.addEventListener("click",this.#sS),d.addEventListener("mouseenter",this.#s_),d.addEventListener("mouseleave",this.#sy),d.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#sA);this.#tp.hidden=!0,d&&this.#sC()}render(){if(this.#sI)return;let t=this.#sI=document.createElement("div");if(t.className="popup",this.#sE){let e=t.style.outlineColor=B.makeHexColor(...this.#sE);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:t.style.backgroundColor=B.makeHexColor(...this.#sE.map(t=>Math.floor(.7*(255-t)+t)))}let e=document.createElement("span");e.className="header";let i=document.createElement("h1");if(e.append(i),{dir:i.dir,str:i.textContent}=this.#sN,t.append(e),this.#sM){let t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#sM.valueOf()})),e.append(t)}let s=this.#sB;if(s)e2.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let e=this._formatContents(this.#sT);t.append(e)}this.#tp.append(t)}get #sB(){let t=this.#sF,e=this.#sT;return t?.str&&(!e?.str||e.str===t.str)&&this.#sF.html||null}get #sz(){return this.#sB?.attributes?.style?.fontSize||0}get #sH(){return this.#sB?.attributes?.style?.color||null}#s$(t){let e=[],i={style:{color:this.#sH,fontSize:this.#sz?`calc(${this.#sz}px * var(--scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}_formatContents({str:t,dir:e}){let i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let a=s[t];i.append(document.createTextNode(a)),t<e-1&&i.append(document.createElement("br"))}return i}#sv(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#sR)&&this.#sC()}updateEdited({rect:t,popupContent:e}){this.#sc||={contentsObj:this.#sT,richText:this.#sF},t&&(this.#E=null),e&&(this.#sF=this.#s$(e),this.#sT=null),this.#sI?.remove(),this.#sI=null}resetEdited(){this.#sc&&({contentsObj:this.#sT,richText:this.#sF}=this.#sc,this.#sc=null,this.#sI?.remove(),this.#sI=null,this.#E=null)}#sG(){if(null!==this.#E)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:a}}}=this.#sk,r=!!this.#sD,n=r?this.#sD:this.#sL;for(let t of this.#sP)if(!n||null!==B.intersect(t.data.rect,n)){n=t.data.rect,r=!0;break}let o=B.normalizeRect([n[0],t[3]-n[1]+t[1],n[2],t[3]-n[3]+t[1]]),l=r?n[2]-n[0]+5:0,h=o[0]+l,d=o[1];this.#E=[100*(h-s)/e,100*(d-a)/i];let{style:c}=this.#tp;c.left=`${this.#E[0]}%`,c.top=`${this.#E[1]}%`}#sC(){this.#sR=!this.#sR,this.#sR?(this.#sx(),this.#tp.addEventListener("click",this.#sS),this.#tp.addEventListener("keydown",this.#sA)):(this.#sw(),this.#tp.removeEventListener("click",this.#sS),this.#tp.removeEventListener("keydown",this.#sA))}#sx(){this.#sI||this.render(),this.isVisible?this.#sR&&this.#tp.classList.add("focused"):(this.#sG(),this.#tp.hidden=!1,this.#tp.style.zIndex=parseInt(this.#tp.style.zIndex)+1e3)}#sw(){this.#tp.classList.remove("focused"),!this.#sR&&this.isVisible&&(this.#tp.hidden=!0,this.#tp.style.zIndex=parseInt(this.#tp.style.zIndex)-1e3)}forceHide(){this.#sO=this.isVisible,this.#sO&&(this.#tp.hidden=!0)}maybeShow(){this.#sO&&(this.#sI||this.#sx(),this.#sO=!1,this.#tp.hidden=!1)}get isVisible(){return!1===this.#tp.hidden}}class ih extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=c.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class id extends e4{#sU=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:i}=e5(t.rect),s=this.svgFactory.create(e,i,!0),a=this.#sU=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sU}addHighlightArea(){this.container.classList.add("highlightArea")}}class ic extends e4{#sj=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:i}=e5(t.rect),s=this.svgFactory.create(e,i,!0),a=t.borderStyle.width,r=this.#sj=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",a/2),r.setAttribute("y",a/2),r.setAttribute("width",e-a),r.setAttribute("height",i-a),r.setAttribute("stroke-width",a||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sj}addHighlightArea(){this.container.classList.add("highlightArea")}}class iu extends e4{#sV=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:i}=e5(t.rect),s=this.svgFactory.create(e,i,!0),a=t.borderStyle.width,r=this.#sV=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-a/2),r.setAttribute("ry",i/2-a/2),r.setAttribute("stroke-width",a||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sV}addHighlightArea(){this.container.classList.add("highlightArea")}}class ip extends e4{#sW=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;let{width:a,height:r}=e5(t),n=this.svgFactory.create(a,r,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],a=t[3]-e[i+1];o.push(`${s},${a}`)}o=o.join(" ");let l=this.#sW=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),n.append(l),this.container.append(n),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sW}addHighlightArea(){this.container.classList.add("highlightArea")}}class ig extends ip{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class im extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class ib extends e4{#sq=null;#sX=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?c.HIGHLIGHT:c.INK}#sK(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:a}}=this,{transform:r,width:n,height:o}=this.#sK(e,t),l=this.svgFactory.create(n,o,!0),h=this.#sq=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#sX.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,a=this.#sq;if(e>=0&&a.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#sX.length;t<e;t++)this.#sX[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#sK(this.data.rotation,s);a.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),a.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#sX}addHighlightArea(){this.container.classList.add("highlightArea")}}class iA extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=c.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class iv extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class iy extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class iw extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class i_ extends e4{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=c.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class ix extends e4{#sY=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#sQ.bind(this)),this.#sY=t;let{isMac:s}=N.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#sQ()}),!i.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#sY}addHighlightArea(){this.container.classList.add("highlightArea")}#sQ(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class iS{#sJ=null;#sZ=null;#s0=new Map;#s1=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:a,viewport:r,structTreeLayer:n}){this.div=t,this.#sJ=e,this.#sZ=i,this.#s1=n||null,this.page=a,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#s0.size>0}async #s2(t,e){let i=t.firstChild||t,s=i.id=`${G}${e}`,a=await this.#s1?.getAriaAttributes(s);if(a)for(let[t,e]of a)i.setAttribute(t,e);this.div.append(t),this.#sJ?.moveElementInDOM(this.div,t,i,!1)}async render(t){let{annotations:e}=t,i=this.div;to(i,this.viewport);let s=new Map,a={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new e1,annotationStorage:t.annotationStorage||new tS,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=16===t.annotationType;if(e){let e=s.get(t.id);if(!e)continue;a.elements=e}else{let{width:e,height:i}=e5(t.rect);if(e<=0||i<=0)continue}a.data=t;let i=e6.create(a);if(!i.isRenderable)continue;if(!e&&t.popupRef){let e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}let r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#s2(r,t.id),i._isEditable&&(this.#s0.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#s3()}update({viewport:t}){let e=this.div;this.viewport=t,to(e,{rotation:t.rotation}),this.#s3(),e.hidden=!1}#s3(){if(!this.#sZ)return;let t=this.div;for(let[e,i]of this.#sZ){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:a}=s;a?"CANVAS"===a.nodeName?a.replaceWith(i):a.classList.contains("annotationContent")?a.after(i):a.before(i):s.append(i)}this.#sZ.clear()}getEditableAnnotations(){return Array.from(this.#s0.values())}getEditableAnnotation(t){return this.#s0.get(t)}}let iC=/\r\n?|\n/g;class iE extends ty{#sE;#s5="";#s6=`${this.id}-editor`;#s4=null;#sz;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=iE.prototype,e=t=>t.isEmpty(),i=tb.TRANSLATE_SMALL,s=tb.TRANSLATE_BIG;return S(this,"_keyboardManager",new tm([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=c.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#sE=t.color||iE._defaultColor||ty._defaultLineColor,this.#sz=t.fontSize||iE._defaultFontSize}static initialize(t,e){ty.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case u.FREETEXT_SIZE:iE._defaultFontSize=e;break;case u.FREETEXT_COLOR:iE._defaultColor=e}}updateParams(t,e){switch(t){case u.FREETEXT_SIZE:this.#s8(e);break;case u.FREETEXT_COLOR:this.#s7(e)}}static get defaultPropertiesToUpdate(){return[[u.FREETEXT_SIZE,iE._defaultFontSize],[u.FREETEXT_COLOR,iE._defaultColor||ty._defaultLineColor]]}get propertiesToUpdate(){return[[u.FREETEXT_SIZE,this.#sz],[u.FREETEXT_COLOR,this.#sE]]}#s8(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#sz)*this.parentScale),this.#sz=t,this.#s9()},i=this.#sz;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#s7(t){let e=t=>{this.#sE=this.editorDiv.style.color=t},i=this.#sE;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-iE._internalPadding*t,-(iE._internalPadding+this.#sz)*t]}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(c.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s4=new AbortController;let t=this._uiManager.combinedSignal(this.#s4);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#s6),this._isDraggable=!0,this.#s4?.abort(),this.#s4=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.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()}#at(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(iE.#ae(i)),e=i);return t.join("\n")}#s9(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,a=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",a)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#s5,e=this.#s5=this.#at().trimEnd();if(t===e)return;let i=t=>{(this.#s5=t,t)?(this.#ai(),this._uiManager.rebuild(this),this.#s9()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#s9()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){iE._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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(){let t,e;if(this.div)return this.div;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#s6),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#sz}px * var(--scale-factor))`,i.color=this.#sE,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),tc(this,this.div,["dblclick","keydown"]),this.width){let[i,s]=this.parentDimensions;if(this.annotationElementId){let a,r,{position:n}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:a=t+(n[0]-c)/h,r=e+this.height-(n[1]-u)/d;break;case 90:a=t+(n[0]-c)/h,r=e-(n[1]-u)/d,[o,l]=[l,-o];break;case 180:a=t-this.width+(n[0]-c)/h,r=e-(n[1]-u)/d,[o,l]=[-o,-l];break;case 270:a=t+(n[0]-c-this.height*d)/h,r=e+(n[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(a*i,r*s,o,l)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#ai(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #ae(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(iC,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=iE.#as(e.getData("text")||"").replaceAll(iC,"\n");if(!s)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let r=a.getRangeAt(0);if(!s.includes("\n")){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:n,startOffset:o}=r,l=[],h=[];if(n.nodeType===Node.TEXT_NODE){let t=n.parentElement;if(h.push(n.nodeValue.slice(o).replaceAll(iC,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(iE.#ae(i))}}l.push(n.nodeValue.slice(0,o).replaceAll(iC,""))}else if(n===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(iE.#ae(i))}this.#s5=`${l.join("\n")}${s}${h.join("\n")}`,this.#ai();let d=new Range,c=l.reduce((t,e)=>t+e.length,0);for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}a.removeAllRanges(),a.addRange(d)}#ai(){if(this.editorDiv.replaceChildren(),this.#s5)for(let t of this.#s5.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#aa(){return this.#s5.replaceAll("\xa0"," ")}static #as(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof ih){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:a,rotation:r,id:n,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:c.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:a.slice(0),rotation:r,id:n,deleted:!1,popupRef:o}}let a=await super.deserialize(t,e,i);return a.#sz=t.fontSize,a.#sE=B.makeHexColor(...t.color),a.#s5=iE.#as(t.value),a.annotationElementId=t.id||null,a._initialData=s,a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=iE._internalPadding*this.parentScale,i=this.getRect(e,e),s=ty._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#sE),a={annotationType:c.FREETEXT,color:s,fontSize:this.#sz,value:this.#aa(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!this.#ar(a)?null:(a.id=this.annotationElementId,a)}#ar(t){let{value:e,fontSize:i,color:s,pageIndex:a}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==a}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#sz}px * var(--scale-factor))`,i.color=this.#sE,e.replaceChildren(),this.#s5.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}let s=iE._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#s5}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class iT{static PRECISION=1e-4;toSVGPath(){w("Abstract method `toSVGPath` must be implemented.")}get box(){w("Abstract getter `box` must be implemented.")}serialize(t,e){w("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,a,r){r||=new Float32Array(t.length);for(let n=0,o=t.length;n<o;n+=2)r[n]=e+t[n]*s,r[n+1]=i+t[n+1]*a;return r}static _rescaleAndSwap(t,e,i,s,a,r){r||=new Float32Array(t.length);for(let n=0,o=t.length;n<o;n+=2)r[n]=e+t[n+1]*s,r[n+1]=i+t[n]*a;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let a=0,r=t.length;a<r;a+=2)s[a]=e+t[a],s[a+1]=i+t[a+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,a){switch(a){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,a,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+a)/6,(5*s+r)/6,(i+a)/2,(s+r)/2]}}class iM{#an;#ao=[];#al;#ah;#ad=[];#ac=new Float32Array(18);#au;#ap;#ag;#am;#af;#ab;#aA=[];static #av=8;static #ay=2;static #aw=iM.#av+iM.#ay;constructor({x:t,y:e},i,s,a,r,n=0){this.#an=i,this.#ab=a*s,this.#ah=r,this.#ac.set([NaN,NaN,NaN,NaN,t,e],6),this.#al=n,this.#am=iM.#av*s,this.#ag=iM.#aw*s,this.#af=s,this.#aA.push(t,e)}isEmpty(){return isNaN(this.#ac[8])}#a_(){let t=this.#ac.subarray(4,6),e=this.#ac.subarray(16,18),[i,s,a,r]=this.#an;return[(this.#au+(t[0]-e[0])/2-i)/a,(this.#ap+(t[1]-e[1])/2-s)/r,(this.#au+(e[0]-t[0])/2-i)/a,(this.#ap+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#au=t,this.#ap=e;let[i,s,a,r]=this.#an,[n,o,l,h]=this.#ac.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#ag)return!1;let p=u-this.#am,g=p/u,m=g*d,f=g*c,b=n,A=o;n=l,o=h,l+=m,h+=f,this.#aA?.push(t,e);let v=-f/p*this.#ab,y=m/p*this.#ab;return(this.#ac.set(this.#ac.subarray(2,8),0),this.#ac.set([l+v,h+y],4),this.#ac.set(this.#ac.subarray(14,18),12),this.#ac.set([l-v,h-y],16),isNaN(this.#ac[6]))?(0===this.#ad.length&&(this.#ac.set([n+v,o+y],2),this.#ad.push(NaN,NaN,NaN,NaN,(n+v-i)/a,(o+y-s)/r),this.#ac.set([n-v,o-y],14),this.#ao.push(NaN,NaN,NaN,NaN,(n-v-i)/a,(o-y-s)/r)),this.#ac.set([b,A,n,o,l,h],6),!this.isEmpty()):((this.#ac.set([b,A,n,o,l,h],6),Math.abs(Math.atan2(A-o,b-n)-Math.atan2(f,m))<Math.PI/2)?([n,o,l,h]=this.#ac.subarray(2,6),this.#ad.push(NaN,NaN,NaN,NaN,((n+l)/2-i)/a,((o+h)/2-s)/r),[n,o,b,A]=this.#ac.subarray(14,18),this.#ao.push(NaN,NaN,NaN,NaN,((b+n)/2-i)/a,((A+o)/2-s)/r)):([b,A,n,o,l,h]=this.#ac.subarray(0,6),this.#ad.push(((b+5*n)/6-i)/a,((A+5*o)/6-s)/r,((5*n+l)/6-i)/a,((5*o+h)/6-s)/r,((n+l)/2-i)/a,((o+h)/2-s)/r),[l,h,n,o,b,A]=this.#ac.subarray(12,18),this.#ao.push(((b+5*n)/6-i)/a,((A+5*o)/6-s)/r,((5*n+l)/6-i)/a,((5*o+h)/6-s)/r,((n+l)/2-i)/a,((o+h)/2-s)/r)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#ad,e=this.#ao;if(isNaN(this.#ac[6])&&!this.isEmpty())return this.#ax();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#aS(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#aC(i),i.join(" ")}#ax(){let[t,e,i,s]=this.#an,[a,r,n,o]=this.#a_();return`M${(this.#ac[2]-t)/i} ${(this.#ac[3]-e)/s} L${(this.#ac[4]-t)/i} ${(this.#ac[5]-e)/s} L${a} ${r} L${n} ${o} L${(this.#ac[16]-t)/i} ${(this.#ac[17]-e)/s} L${(this.#ac[14]-t)/i} ${(this.#ac[15]-e)/s} Z`}#aC(t){let e=this.#ao;t.push(`L${e[4]} ${e[5]} Z`)}#aS(t){let[e,i,s,a]=this.#an,r=this.#ac.subarray(4,6),n=this.#ac.subarray(16,18),[o,l,h,d]=this.#a_();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/a} L${o} ${l} L${h} ${d} L${(n[0]-e)/s} ${(n[1]-i)/a}`)}newFreeDrawOutline(t,e,i,s,a,r){return new iP(t,e,i,s,a,r)}getOutlines(){let t=this.#ad,e=this.#ao,i=this.#ac,[s,a,r,n]=this.#an,o=new Float32Array((this.#aA?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#aA[t]-s)/r,o[t+1]=(this.#aA[t+1]-a)/n;if(o[o.length-2]=(this.#au-s)/r,o[o.length-1]=(this.#ap-a)/n,isNaN(i[6])&&!this.isEmpty())return this.#aE(o);let l=new Float32Array(this.#ad.length+24+this.#ao.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#aT(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#aM(l,h),this.newFreeDrawOutline(l,o,this.#an,this.#af,this.#al,this.#ah)}#aE(t){let e=this.#ac,[i,s,a,r]=this.#an,[n,o,l,h]=this.#a_(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/a,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/a,(e[5]-s)/r,NaN,NaN,NaN,NaN,n,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/a,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/a,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#an,this.#af,this.#al,this.#ah)}#aM(t,e){let i=this.#ao;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#aT(t,e){let i=this.#ac.subarray(4,6),s=this.#ac.subarray(16,18),[a,r,n,o]=this.#an,[l,h,d,c]=this.#a_();return t.set([NaN,NaN,NaN,NaN,(i[0]-a)/n,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-a)/n,(s[1]-r)/o],e),e+=24}}class iP extends iT{#an;#aP=new Float32Array(4);#al;#ah;#aA;#af;#ak;constructor(t,e,i,s,a,r){super(),this.#ak=t,this.#aA=e,this.#an=i,this.#af=s,this.#al=a,this.#ah=r,this.lastPoint=[NaN,NaN],this.#aD(r);const[n,o,l,h]=this.#aP;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-n)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-n)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#ak[4]} ${this.#ak[5]}`];for(let e=6,i=this.#ak.length;e<i;e+=6){if(isNaN(this.#ak[e])){t.push(`L${this.#ak[e+4]} ${this.#ak[e+5]}`);continue}t.push(`C${this.#ak[e]} ${this.#ak[e+1]} ${this.#ak[e+2]} ${this.#ak[e+3]} ${this.#ak[e+4]} ${this.#ak[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],a){let r,n,o=i-t,l=s-e;switch(a){case 0:r=iT._rescale(this.#ak,t,s,o,-l),n=iT._rescale(this.#aA,t,s,o,-l);break;case 90:r=iT._rescaleAndSwap(this.#ak,t,e,o,l),n=iT._rescaleAndSwap(this.#aA,t,e,o,l);break;case 180:r=iT._rescale(this.#ak,i,e,-o,l),n=iT._rescale(this.#aA,i,e,-o,l);break;case 270:r=iT._rescaleAndSwap(this.#ak,i,s,-o,-l),n=iT._rescaleAndSwap(this.#aA,i,s,-o,-l)}return{outline:Array.from(r),points:[Array.from(n)]}}#aD(t){let e=this.#ak,i=e[4],s=e[5],a=i,r=s,n=i,o=s,l=i,h=s,d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))a=Math.min(a,e[t+4]),r=Math.min(r,e[t+5]),n=Math.max(n,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{let c=B.bezierBoundingBox(i,s,...e.slice(t,t+6));a=Math.min(a,c[0]),r=Math.min(r,c[1]),n=Math.max(n,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}let c=this.#aP;c[0]=a-this.#al,c[1]=r-this.#al,c[2]=n-a+2*this.#al,c[3]=o-r+2*this.#al,this.lastPoint=[l,h]}get box(){return this.#aP}newOutliner(t,e,i,s,a,r=0){return new iM(t,e,i,s,a,r)}getNewOutline(t,e){let[i,s,a,r]=this.#aP,[n,o,l,h]=this.#an,d=a*l,c=r*h,u=i*l+n,p=s*h+o,g=this.newOutliner({x:this.#aA[0]*d+u,y:this.#aA[1]*c+p},this.#an,this.#af,t,this.#ah,e??this.#al);for(let t=2;t<this.#aA.length;t+=2)g.add({x:this.#aA[t]*d+u,y:this.#aA[t+1]*c+p});return g.getOutlines()}}class ik{#an;#aR;#aI=[];#aL=[];constructor(t,e=0,i=0,s=!0){let a=1/0,r=-1/0,n=1/0,o=-1/0;for(const{x:i,y:s,width:l,height:h}of t){const t=1e-4*Math.floor((i-e)/1e-4),d=1e-4*Math.ceil((i+l+e)/1e-4),c=1e-4*Math.floor((s-e)/1e-4),u=1e-4*Math.ceil((s+h+e)/1e-4),p=[t,c,u,!0],g=[d,c,u,!1];this.#aI.push(p,g),a=Math.min(a,t),r=Math.max(r,d),n=Math.min(n,c),o=Math.max(o,u)}const l=r-a+2*i,h=o-n+2*i,d=a-i,c=n-i,u=this.#aI.at(s?-1:-2),p=[u[0],u[2]];for(const t of this.#aI){const[e,i,s]=t;t[0]=(e-d)/l,t[1]=(i-c)/h,t[2]=(s-c)/h}this.#an=new Float32Array([d,c,l,h]),this.#aR=p}getOutlines(){this.#aI.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#aI)e[3]?(t.push(...this.#aF(e)),this.#aN(e)):(this.#aO(e),t.push(...this.#aF(e)));return this.#aB(t)}#aB(t){let e,i=[],s=new Set;for(let e of t){let[t,s,a]=e;i.push([t,s,e],[t,a,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],a=i[t+1][2];e.push(a),a.push(e),s.add(e),s.add(a)}let a=[];for(;s.size>0;){let t=s.values().next().value,[i,r,n,o,l]=t;s.delete(t);let h=i,d=r;for(e=[i,n],a.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,r,n,o,l]=t,h!==i&&(e.push(h,d,i,d===r?r:n),h=i),d=d===r?n:r}e.push(h,d)}return new iD(a,this.#an,this.#aR)}#az(t){let e=this.#aL,i=0,s=e.length-1;for(;i<=s;){let a=i+s>>1,r=e[a][0];if(r===t)return a;r<t?i=a+1:s=a-1}return s+1}#aN([,t,e]){let i=this.#az(t);this.#aL.splice(i,0,[t,e])}#aO([,t,e]){let i=this.#az(t);for(let s=i;s<this.#aL.length;s++){let[i,a]=this.#aL[s];if(i!==t)break;if(i===t&&a===e)return void this.#aL.splice(s,1)}for(let s=i-1;s>=0;s--){let[i,a]=this.#aL[s];if(i!==t)break;if(i===t&&a===e)return void this.#aL.splice(s,1)}}#aF(t){let[e,i,s]=t,a=[[e,i,s]],r=this.#az(s);for(let t=0;t<r;t++){let[i,s]=this.#aL[t];for(let t=0,r=a.length;t<r;t++){let[,n,o]=a[t];if(!(s<=n)&&!(o<=i)){if(n>=i){if(o>s)a[t][1]=s;else{if(1===r)return[];a.splice(t,1),t--,r--}continue}a[t][2]=i,o>s&&a.push([e,s,o])}}}return a}}class iD extends iT{#an;#aH;constructor(t,e,i){super(),this.#aH=t,this.#an=e,this.lastPoint=i}toSVGPath(){let t=[];for(let e of this.#aH){let[i,s]=e;t.push(`M${i} ${s}`);for(let a=2;a<e.length;a+=2){let r=e[a],n=e[a+1];r===i?(t.push(`V${n}`),s=n):n===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],a){let r=[],n=i-t,o=s-e;for(let e of this.#aH){let i=Array(e.length);for(let a=0;a<e.length;a+=2)i[a]=t+e[a]*n,i[a+1]=s-e[a+1]*o;r.push(i)}return r}get box(){return this.#an}get classNamesForOutlining(){return["highlightOutline"]}}class iR extends iM{newFreeDrawOutline(t,e,i,s,a,r){return new iI(t,e,i,s,a,r)}}class iI extends iP{newOutliner(t,e,i,s,a,r=0){return new iR(t,e,i,s,a,r)}}class iL{#a$=null;#aG=null;#aU;#aj=null;#aV=!1;#aW=!1;#r=null;#aq;#aX=null;#m=null;#aK;static #aY=null;static get _keyboardManager(){return S(this,"_keyboardManager",new tm([[["Escape","mac+Escape"],iL.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],iL.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],iL.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],iL.prototype._moveToPrevious],[["Home","mac+Home"],iL.prototype._moveToBeginning],[["End","mac+End"],iL.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#aW=!1,this.#aK=u.HIGHLIGHT_COLOR,this.#r=t):(this.#aW=!0,this.#aK=u.HIGHLIGHT_DEFAULT_COLOR),this.#m=t?._uiManager||e,this.#aq=this.#m._eventBus,this.#aU=t?.color||this.#m?.highlightColors.values().next().value||"#FFFF98",iL.#aY||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#a$=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#m._signal;t.addEventListener("click",this.#aQ.bind(this),{signal:e}),t.addEventListener("keydown",this.#sv.bind(this),{signal:e});let i=this.#aG=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#aU,t.append(i),t}renderMainDropdown(){let t=this.#aj=this.#aJ();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#aJ(){let t=document.createElement("div"),e=this.#m._signal;for(let[i,s]of(t.addEventListener("contextmenu",tt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#m.highlightColors)){let a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",s),a.title=i,a.setAttribute("data-l10n-id",iL.#aY[i]);let r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=s,a.setAttribute("aria-selected",s===this.#aU),a.addEventListener("click",this.#aZ.bind(this,s),{signal:e}),t.append(a)}return t.addEventListener("keydown",this.#sv.bind(this),{signal:e}),t}#aZ(t,e){e.stopPropagation(),this.#aq.dispatch("switchannotationeditorparams",{source:this,type:this.#aK,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#a$)return void this.#aQ(t);let e=t.target.getAttribute("data-color");e&&this.#aZ(e,t)}_moveToNext(t){this.#a0?t.target===this.#a$?this.#aj.firstChild?.focus():t.target.nextSibling?.focus():this.#aQ(t)}_moveToPrevious(t){if(t.target===this.#aj?.firstChild||t.target===this.#a$){this.#a0&&this._hideDropdownFromKeyboard();return}this.#a0||this.#aQ(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#a0?this.#aj.firstChild?.focus():this.#aQ(t)}_moveToEnd(t){this.#a0?this.#aj.lastChild?.focus():this.#aQ(t)}#sv(t){iL._keyboardManager.exec(this,t)}#aQ(t){if(this.#a0)return void this.hideDropdown();if(this.#aV=0===t.detail,this.#aX||(this.#aX=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#m.combinedSignal(this.#aX)})),this.#aj)return void this.#aj.classList.remove("hidden");let e=this.#aj=this.#aJ();this.#a$.append(e)}#h(t){this.#aj?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#aj?.classList.add("hidden"),this.#aX?.abort(),this.#aX=null}get #a0(){return this.#aj&&!this.#aj.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#aW){if(!this.#a0)return void this.#r?.unselect();this.hideDropdown(),this.#a$.focus({preventScroll:!0,focusVisible:this.#aV})}}updateColor(t){if(this.#aG&&(this.#aG.style.backgroundColor=t),!this.#aj)return;let e=this.#m.highlightColors.values();for(let i of this.#aj.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#a$?.remove(),this.#a$=null,this.#aG=null,this.#aj?.remove(),this.#aj=null}}class iF extends ty{#a1=null;#a2=0;#a3;#a5=null;#a=null;#a6=null;#a4=null;#a8=0;#a7=null;#a9=null;#v=null;#rt=!1;#aR=null;#re;#ri=null;#rs="";#ab;#ra="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=c.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=iF.prototype;return S(this,"_keyboardManager",new tm([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||iF._defaultColor,this.#ab=t.thickness||iF._defaultThickness,this.#re=t.opacity||iF._defaultOpacity,this.#a3=t.boxes||null,this.#ra=t.methodOfCreation||"",this.#rs=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#rt=!0,this.#rr(t),this.#rn()):this.#a3&&(this.#a1=t.anchorNode,this.#a2=t.anchorOffset,this.#a4=t.focusNode,this.#a8=t.focusOffset,this.#ro(),this.#rn(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#rt?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#ab,methodOfCreation:this.#ra}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ro(){let t=new ik(this.#a3,.001);this.#a9=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#a9.box;let e=new ik(this.#a3,.0025,.001,"ltr"===this._uiManager.direction);this.#a6=e.getOutlines();let{lastPoint:i}=this.#a6;this.#aR=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#rr({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#a9=t,this.#a6=t.getNewOutline(this.#ab/2+1.5,.0025),e>=0)this.#v=e,this.#a5=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ri=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a6.box,path:{d:this.#a6.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#v,{bbox:iF.#rl(this.#a9.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ri,{bbox:iF.#rl(this.#a6.box,e),path:{d:this.#a6.toSVGPath()}})}let[s,a,r,n]=t.box;switch(this.rotation){case 0:this.x=s,this.y=a,this.width=r,this.height=n;break;case 90:{let[t,e]=this.parentDimensions;this.x=a,this.y=1-s,this.width=r*e/t,this.height=n*t/e;break}case 180:this.x=1-s,this.y=1-a,this.width=r,this.height=n;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-a,this.y=s,this.width=r*e/t,this.height=n*t/e}}let{lastPoint:o}=this.#a6;this.#aR=[(o[0]-s)/r,(o[1]-a)/n]}static initialize(t,e){ty.initialize(t,e),iF._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case u.HIGHLIGHT_DEFAULT_COLOR:iF._defaultColor=e;break;case u.HIGHLIGHT_THICKNESS:iF._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#aR}updateParams(t,e){switch(t){case u.HIGHLIGHT_COLOR:this.#s7(e);break;case u.HIGHLIGHT_THICKNESS:this.#rh(e)}}static get defaultPropertiesToUpdate(){return[[u.HIGHLIGHT_DEFAULT_COLOR,iF._defaultColor],[u.HIGHLIGHT_THICKNESS,iF._defaultThickness]]}get propertiesToUpdate(){return[[u.HIGHLIGHT_COLOR,this.color||iF._defaultColor],[u.HIGHLIGHT_THICKNESS,this.#ab||iF._defaultThickness],[u.HIGHLIGHT_FREE,this.#rt]]}#s7(t){let e=(t,e)=>{this.color=t,this.#re=e,this.parent?.drawLayer.updateProperties(this.#v,{root:{fill:t,"fill-opacity":e}}),this.#a?.updateColor(t)},i=this.color,s=this.#re;this.addCommands({cmd:e.bind(this,t,iF._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#rh(t){let e=this.#ab,i=t=>{this.#ab=t,this.#rd(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#a=new iL({editor:this}),t.addColorPicker(this.#a)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#rc())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#rc())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#ru(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#rn(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#ru():t&&(this.#rn(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#rd(t){if(!this.#rt)return;this.#rr({highlightOutlines:this.#a9.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#ru(){null!==this.#v&&this.parent&&(this.parent.drawLayer.remove(this.#v),this.#v=null,this.parent.drawLayer.remove(this.#ri),this.#ri=null)}#rn(t=this.parent){null===this.#v&&({id:this.#v,clipPathId:this.#a5}=t.drawLayer.draw({bbox:this.#a9.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#re},rootClass:{highlight:!0,free:this.#rt},path:{d:this.#a9.toSVGPath()}},!1,!0),this.#ri=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#rt},bbox:this.#a6.box,path:{d:this.#a6.toSVGPath()}},this.#rt),this.#a7&&(this.#a7.style.clipPath=this.#a5))}static #rl([t,e,i,s],a){switch(a){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){let e,{drawLayer:i}=this.parent;this.#rt?(t=(t-this.rotation+360)%360,e=iF.#rl(this.#a9.box,t)):e=iF.#rl([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#v,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#ri,{bbox:iF.#rl(this.#a6.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#rs&&(t.setAttribute("aria-label",this.#rs),t.setAttribute("role","mark")),this.#rt?t.classList.add("free"):this.div.addEventListener("keydown",this.#rp.bind(this),{signal:this._uiManager._signal});let e=this.#a7=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#a5;let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),tc(this,this.#a7,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ri,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ri,{rootClass:{hovered:!1}})}#rp(t){iF._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#rg(!0);break;case 1:case 3:this.#rg(!1)}}#rg(t){if(!this.#a1)return;let e=window.getSelection();t?e.setPosition(this.#a1,this.#a2):e.setPosition(this.#a4,this.#a8)}select(){super.select(),this.#ri&&this.parent?.drawLayer.updateProperties(this.#ri,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ri&&(this.parent?.drawLayer.updateProperties(this.#ri,{rootClass:{selected:!1}}),this.#rt||this.#rg(!1))}get _mustFixPosition(){return!this.#rt}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#v,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ri,{rootClass:{hidden:!t}}))}#rc(){return this.#rt?this.rotation:0}#rm(){if(this.#rt)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,a=this.#a3,r=new Float32Array(8*a.length),n=0;for(let{x:o,y:l,width:h,height:d}of a){let a=o*t+i,c=(1-l)*e+s;r[n]=r[n+4]=a,r[n+1]=r[n+3]=c,r[n+2]=r[n+6]=a+h*t,r[n+5]=r[n+7]=c-d*e,n+=8}return r}#rf(t){return this.#a9.serialize(t,this.#rc())}static startHighlighting(t,e,{target:i,x:s,y:a}){let{x:r,y:n,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#rb(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",te,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",tt,{signal:d}),i.addEventListener("pointermove",this.#rA.bind(this,t),{signal:d}),this._freeHighlight=new iR({x:s,y:a},[r,n,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static #rA(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #rb(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof iA){let{data:{quadPoints:e,rect:i,rotation:a,id:r,color:n,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:c.HIGHLIGHT,color:Array.from(n),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:a,id:r,deleted:!1,popupRef:l}}else if(t instanceof ib){let{data:{inkLists:e,rect:i,rotation:a,id:r,color:n,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:c.HIGHLIGHT,color:Array.from(n),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:a,id:r,deleted:!1,popupRef:l}}let{color:a,quadPoints:r,inkLists:n,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=B.makeHexColor(...a),l.#re=o||1,n&&(l.#ab=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;let[h,d]=l.pageDimensions,[u,p]=l.pageTranslation;if(r){let t=l.#a3=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-u)/h,y:1-(r[e+1]-p)/d,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/d});l.#ro(),l.#rn(),l.rotate(l.rotation)}else if(n){l.#rt=!0;let t=n[0],i={x:t[0]-u,y:d-(t[1]-p)},s=new iR(i,[0,0,h,d],1,l.#ab/2,!0,.001);for(let e=0,a=t.length;e<a;e+=2)i.x=t[e]-u,i.y=d-(t[e+1]-p),s.add(i);let{id:a,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#rr({highlightOutlines:s.getOutlines(),highlightId:a,clipPathId:r}),l.#rn()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),i=ty._colorManager.convert(this.color),s={annotationType:c.HIGHLIGHT,color:i,opacity:this.#re,thickness:this.#ab,quadPoints:this.#rm(),outlines:this.#rf(e),pageIndex:this.pageIndex,rect:e,rotation:this.#rc(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#ar(s)?null:(s.id=this.annotationElementId,s)}#ar(t){let{color:e}=this._initialData;return t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class iN{#rv=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#rv[t]=e}toSVGProperties(){let t=this.#rv;return this.#rv=Object.create(null),{root:t}}reset(){this.#rv=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){w("Not implemented")}}class iO extends ty{#ry=null;#rw;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #r_=null;static #rx=null;static #rS=null;static #rC=NaN;static #rE=null;static #rT=null;static #rM=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#rw=t.mustBeCommitted||!1,t.drawOutlines&&(this.#rP(t),this.#rn())}#rP({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ry=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#rk(t,this.parent),this.#rD(t.box)}#rk(t,e){let{id:i}=e.drawLayer.draw(iO._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,a]of Object.entries(e))i.has(s)?Object.assign(t[s],a):t[s]=a;return t}static getDefaultDrawingOptions(t){w("Not implemented")}static get typesMap(){w("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(iO.#r_.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,a=s[e],r=t=>{s.updateProperty(e,t);let i=this.#ry.updateProperty(e,t);i&&this.#rD(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,iO._mergeSVGProperties(this.#ry.getPathResizingSVGProperties(this.#rR()),{bbox:this.#rI()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,iO._mergeSVGProperties(this.#ry.getPathResizedSVGProperties(this.#rR()),{bbox:this.#rI()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#rI(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,iO._mergeSVGProperties(this.#ry.getPathTranslatedSVGProperties(this.#rR(),this.parentDimensions),{bbox:this.#rI()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#rw&&(this.#rw=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#ru(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#rn(),this.#rD(this.#ry.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#ru()):t&&(this._uiManager.addShouldRescale(this),this.#rn(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#ru(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#rn(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#rk(this.#ry,t)}}#rL([t,e,i,s]){let{parentDimensions:[a,r],rotation:n}=this;switch(n){case 90:return[e,1-t,r/a*i,a/r*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,r/a*i,a/r*s];default:return[t,e,i,s]}}#rR(){let{x:t,y:e,width:i,height:s,parentDimensions:[a,r],rotation:n}=this;switch(n){case 90:return[1-e,t,a/r*i,r/a*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,a/r*i,r/a*s];default:return[t,e,i,s]}}#rD(t){if([this.x,this.y,this.width,this.height]=this.#rL(t),this.div){this.fixAndSetPosition();let[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#rI(){let{x:t,y:e,width:i,height:s,rotation:a,parentRotation:r,parentDimensions:[n,o]}=this;switch((4*a+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-n/o*i,o/n*s,n/o*i];case 5:return[1-e,t,n/o*i,o/n*s];case 6:return[1-t-o/n*s,1-e,o/n*s,n/o*i];case 7:return[e-n/o*i,1-t-o/n*s,n/o*i,o/n*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/n*s,e,o/n*s,n/o*i];case 13:return[1-e-n/o*i,t-o/n*s,n/o*i,o/n*s];case 14:return[1-t,1-e-n/o*i,o/n*s,n/o*i];case 15:return[e,1-t,n/o*i,o/n*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,iO._mergeSVGProperties({bbox:this.#rI()},this.#ry.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#rD(this.#ry.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,a){w("Not implemented")}static startDrawing(t,e,i,s){let{target:a,offsetX:r,offsetY:n,pointerId:o,pointerType:l}=s;if(iO.#rE&&iO.#rE!==l)return;let{viewport:{rotation:h}}=t,{width:d,height:c}=a.getBoundingClientRect(),u=iO.#rx=new AbortController,p=t.combinedSignal(u);(iO.#rC||=o,iO.#rE??=l,window.addEventListener("pointerup",t=>{iO.#rC===t.pointerId?this._endDraw(t):iO.#rT?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointercancel",t=>{iO.#rC===t.pointerId?this._currentParent.endDrawingSession():iO.#rT?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointerdown",t=>{iO.#rE===t.pointerType&&((iO.#rT||=new Set).add(t.pointerId),iO.#r_.isCancellable()&&(iO.#r_.removeLastElement(),iO.#r_.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",tt,{signal:p}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),a.addEventListener("touchmove",t=>{t.timeStamp===iO.#rM&&te(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),iO.#r_)?t.drawLayer.updateProperties(this._currentDrawId,iO.#r_.startNew(r,n,d,c,h)):(e.updateUIForDefaultProperties(this),iO.#r_=this.createDrawerInstance(r,n,d,c,h),iO.#rS=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(iO.#rS.toSVGProperties(),iO.#r_.defaultSVGProperties),!0,!1))}static _drawMove(t){if(iO.#rM=-1,!iO.#r_)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(iO.#rC===s){if(iO.#rT?.size>=1)return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,iO.#r_.add(e,i)),iO.#rM=t.timeStamp,te(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,iO.#r_=null,iO.#rS=null,iO.#rE=null,iO.#rM=NaN),iO.#rx&&(iO.#rx.abort(),iO.#rx=null,iO.#rC=NaN,iO.#rT=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,iO.#r_.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=iO.#r_,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:u.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(u.DRAW_STEP),!iO.#r_.isEmpty()){let{pageDimensions:[i,s],scale:a}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:iO.#r_.getOutlines(i*a,s*a,a,this._INNER_MARGIN),drawingOptions:iO.#rS,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,a,r){w("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:a,pageX:r,pageY:n}}=e.viewport,o=this.deserializeDraw(r,n,s,a,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#rP({drawOutlines:o}),l.#rn(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,a]=this.pageDimensions;return this.#ry.serialize([e,i,s,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class iB{#ac=new Float64Array(6);#sU;#rF;#iI;#ab;#aA;#rN="";#rO=0;#aH=new iz;#rB;#rz;constructor(t,e,i,s,a,r){this.#rB=i,this.#rz=s,this.#iI=a,this.#ab=r,[t,e]=this.#rH(t,e);const n=this.#sU=[NaN,NaN,NaN,NaN,t,e];this.#aA=[t,e],this.#rF=[{line:n,points:this.#aA}],this.#ac.set(n,0)}updateProperty(t,e){"stroke-width"===t&&(this.#ab=e)}#rH(t,e){return iT._normalizePoint(t,e,this.#rB,this.#rz,this.#iI)}isEmpty(){return!this.#rF||0===this.#rF.length}isCancellable(){return this.#aA.length<=10}add(t,e){[t,e]=this.#rH(t,e);let[i,s,a,r]=this.#ac.subarray(2,6),n=t-a,o=e-r;return 2>=Math.hypot(this.#rB*n,this.#rz*o)?null:((this.#aA.push(t,e),isNaN(i))?(this.#ac.set([a,r,t,e],2),this.#sU.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#ac[0])&&this.#sU.splice(6,6),this.#ac.set([i,s,a,r,t,e],0),this.#sU.push(...iT.createBezierPoints(i,s,a,r,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);return i||(2===this.#aA.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,a){this.#rB=i,this.#rz=s,this.#iI=a,[t,e]=this.#rH(t,e);let r=this.#sU=[NaN,NaN,NaN,NaN,t,e];this.#aA=[t,e];let n=this.#rF.at(-1);return n&&(n.line=new Float32Array(n.line),n.points=new Float32Array(n.points)),this.#rF.push({line:r,points:this.#aA}),this.#ac.set(r,0),this.#rO=0,this.toSVGPath(),null}getLastElement(){return this.#rF.at(-1)}setLastElement(t){return this.#rF?(this.#rF.push(t),this.#sU=t.line,this.#aA=t.points,this.#rO=0,{path:{d:this.toSVGPath()}}):this.#aH.setLastElement(t)}removeLastElement(){if(!this.#rF)return this.#aH.removeLastElement();this.#rF.pop(),this.#rN="";for(let t=0,e=this.#rF.length;t<e;t++){let{line:e,points:i}=this.#rF[t];this.#sU=e,this.#aA=i,this.#rO=0,this.toSVGPath()}return{path:{d:this.#rN}}}toSVGPath(){let t=iT.svgRound(this.#sU[4]),e=iT.svgRound(this.#sU[5]);if(2===this.#aA.length)return this.#rN=`${this.#rN} M ${t} ${e} Z`,this.#rN;if(this.#aA.length<=6){let i=this.#rN.lastIndexOf("M");this.#rN=`${this.#rN.slice(0,i)} M ${t} ${e}`,this.#rO=6}if(4===this.#aA.length){let t=iT.svgRound(this.#sU[10]),e=iT.svgRound(this.#sU[11]);return this.#rN=`${this.#rN} L ${t} ${e}`,this.#rO=12,this.#rN}let i=[];0===this.#rO&&(i.push(`M ${t} ${e}`),this.#rO=6);for(let t=this.#rO,e=this.#sU.length;t<e;t+=6){let[e,s,a,r,n,o]=this.#sU.slice(t,t+6).map(iT.svgRound);i.push(`C${e} ${s} ${a} ${r} ${n} ${o}`)}return this.#rN+=i.join(" "),this.#rO=this.#sU.length,this.#rN}getOutlines(t,e,i,s){let a=this.#rF.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#aH.build(this.#rF,t,e,i,this.#iI,this.#ab,s),this.#ac=null,this.#sU=null,this.#rF=null,this.#rN=null,this.#aH}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class iz extends iT{#aP;#r$=0;#al;#rF;#rB;#rz;#rG;#iI;#ab;build(t,e,i,s,a,r,n){this.#rB=e,this.#rz=i,this.#rG=s,this.#iI=a,this.#ab=r,this.#al=n??0,this.#rF=t,this.#rU()}setLastElement(t){return this.#rF.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#rF.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#rF){if(t.push(`M${iT.svgRound(e[4])} ${iT.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length){t.push(`L${iT.svgRound(e[10])} ${iT.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,a,r,n,o,l]=e.subarray(i,i+6).map(iT.svgRound);t.push(`C${s} ${a} ${r} ${n} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],a){let r,n,o,l,h,d,c,u,p,g=[],m=[],[f,b,A,v]=this.#rj();switch(this.#iI){case 0:p=iT._rescale,r=t,n=e+s,o=i,l=-s,h=t+f*i,d=e+(1-b-v)*s,c=t+(f+A)*i,u=e+(1-b)*s;break;case 90:p=iT._rescaleAndSwap,r=t,n=e,o=i,l=s,h=t+b*i,d=e+f*s,c=t+(b+v)*i,u=e+(f+A)*s;break;case 180:p=iT._rescale,r=t+i,n=e,o=-i,l=s,h=t+(1-f-A)*i,d=e+b*s,c=t+(1-f)*i,u=e+(b+v)*s;break;case 270:p=iT._rescaleAndSwap,r=t+i,n=e+s,o=-i,l=-s,h=t+(1-b-v)*i,d=e+(1-f-A)*s,c=t+(1-b)*i,u=e+(1-f)*s}for(let{line:t,points:e}of this.#rF)g.push(p(t,r,n,o,l,a?Array(t.length):null)),m.push(p(e,r,n,o,l,a?Array(e.length):null));return{lines:g,points:m,rect:[h,d,c,u]}}static deserialize(t,e,i,s,a,{paths:{lines:r,points:n},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=iT._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=iT._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=iT._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=iT._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!r)for(let t of(r=[],n)){let e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));r.push(i);let[s,a,n,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,a],0);for(let r=4;r<e;r+=2){let e=t[r],l=t[r+1];i.set(iT.createBezierPoints(s,a,n,o,e,l),(r-2)*3),[s,a,n,o]=[n,o,e,l]}}for(let t=0,e=r.length;t<e;t++)g.push({line:p(r[t].map(t=>t??NaN),h,d,c,u),points:p(n[t].map(t=>t??NaN),h,d,c,u)});let m=new iz;return m.build(g,i,s,1,o,l,a),m}#rV(t=this.#ab){let e=this.#al+t/2*this.#rG;return this.#iI%180==0?[e/this.#rB,e/this.#rz]:[e/this.#rz,e/this.#rB]}#rj(){let[t,e,i,s]=this.#aP,[a,r]=this.#rV(0);return[t+a,e+r,i-2*a,s-2*r]}#rU(){let t=this.#aP=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:e}of this.#rF){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){let[s,a]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],a),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],a)}continue}let i=e[4],s=e[5];for(let a=6,r=e.length;a<r;a+=6){let[r,n,o,l,h,d]=e.subarray(a,a+6);B.bezierBoundingBox(i,s,r,n,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#rV();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#aP}updateProperty(t,e){return"stroke-width"===t?this.#rh(e):null}#rh(t){let[e,i]=this.#rV();this.#ab=t;let[s,a]=this.#rV(),[r,n]=[s-e,a-i],o=this.#aP;return o[0]-=r,o[1]-=n,o[2]+=2*r,o[3]+=2*n,o}updateParentDimensions([t,e],i){let[s,a]=this.#rV();this.#rB=t,this.#rz=e,this.#rG=i;let[r,n]=this.#rV(),o=r-s,l=n-a,h=this.#aP;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#r$=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#aP.map(iT.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#aP;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${iT.svgRound(t)} ${iT.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#aP,i=0,s=0,a=0,r=0,n=0,o=0;switch(this.#r$){case 90:s=e/t,a=-t/e,n=t;break;case 180:i=-1,r=-1,n=t,o=e;break;case 270:s=-e/t,a=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${a} ${r} ${iT.svgRound(n)} ${iT.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[a,r]=this.#rV(),[n,o,l,h]=this.#aP;if(Math.abs(l-a)<=iT.PRECISION||Math.abs(h-r)<=iT.PRECISION){let a=t+i/2-(n+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${iT.svgRound(t)} ${iT.svgRound(e)}`,transform:`${this.rotationTransform} translate(${a} ${r})`}}}let d=(i-2*a)/(l-2*a),c=(s-2*r)/(h-2*r);return{path:{"transform-origin":`${iT.svgRound(n)} ${iT.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${iT.svgRound(a)} ${iT.svgRound(r)}) scale(${d} ${c}) translate(${iT.svgRound(-a)} ${iT.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[a,r]=this.#rV(),n=this.#aP,[o,l,h,d]=n;if(n[0]=t,n[1]=e,n[2]=i,n[3]=s,Math.abs(h-a)<=iT.PRECISION||Math.abs(d-r)<=iT.PRECISION){let a=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#rF)iT._translate(t,a,r,t),iT._translate(e,a,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${iT.svgRound(t)} ${iT.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*a)/(h-2*a),u=(s-2*r)/(d-2*r),p=-c*(o+a)+t+a,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#rF)iT._rescale(t,p,g,c,u,t),iT._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${iT.svgRound(t)} ${iT.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,a]=i,r=this.#aP,n=t-r[0],o=e-r[1];if(this.#rB===s&&this.#rz===a)for(let{line:t,points:e}of this.#rF)iT._translate(t,n,o,t),iT._translate(e,n,o,e);else{let t=this.#rB/s,e=this.#rz/a;for(let{line:i,points:r}of(this.#rB=s,this.#rz=a,this.#rF))iT._rescale(i,n,o,t,e,i),iT._rescale(r,n,o,t,e,r);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${iT.svgRound(t)} ${iT.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#aP;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${iT.svgRound(t[0])} ${iT.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class iH extends iN{#rW;constructor(t){super(),this.#rW=t,super.updateProperties({fill:"none",stroke:ty._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#rW.realScale),super.updateSVGProperty(t,e)}clone(){let t=new iH(this.#rW);return t.updateAll(this),t}}class i$ extends iO{static _type="ink";static _editorType=c.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){ty.initialize(t,e),this._defaultDrawingOptions=new iH(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return S(this,"typesMap",new Map([[u.INK_THICKNESS,"stroke-width"],[u.INK_COLOR,"stroke"],[u.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,a){return new iB(t,e,i,s,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,a,r){return iz.deserialize(t,e,i,s,a,r)}static async deserialize(t,e,i){let s=null;if(t instanceof ib){let{data:{inkLists:e,rect:i,rotation:a,id:r,color:n,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:c.INK,color:Array.from(n),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:a,id:r,deleted:!1,popupRef:h}}let a=await super.deserialize(t,e,i);return a.annotationElementId=t.id||null,a._initialData=s,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=i$.getDefaultDrawingOptions({stroke:B.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:a,"stroke-opacity":r,"stroke-width":n}}=this,o={annotationType:c.INK,color:ty._colorManager.convert(a),opacity:r,thickness:n,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#ar(o)?null:(o.id=this.annotationElementId,o)}#ar(t){let{color:e,thickness:i,opacity:s,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==a}renderAnnotationElement(t){let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class iG extends ty{#rq=null;#rX=null;#rK=null;#rY=null;#rQ=null;#rJ="";#rZ=null;#r0=null;#r1=!1;#r2=!1;static _type="stamp";static _editorType=c.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#rY=t.bitmapUrl,this.#rQ=t.bitmapFile}static initialize(t,e){ty.initialize(t,e)}static get supportedTypes(){return S(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return S(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(c.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#r3(t,e=!1){t?(this.#rq=t.bitmap,e||(this.#rX=t.id,this.#r1=t.isSvg),t.file&&(this.#rJ=t.file.name),this.#r5()):this.remove()}#r6(){if(this.#rK=null,this._uiManager.enableWaiting(!1),this.#rZ){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#rq){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#rq){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:a,height:r}=t||this.copyCanvas(null,null,!0).imageData,n=await i.guess({name:"altText",request:{data:s,width:a,height:r,channels:s.length/(a*r)}});if(!n)throw Error("No response from the AI service.");if(n.error)throw Error("Error from the AI service.");if(n.cancel)return null;if(!n.output)throw Error("No valid response from the AI service.");let o=n.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#r4(){if(this.#rX){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#rX).then(t=>this.#r3(t,!0)).finally(()=>this.#r6());return}if(this.#rY){let t=this.#rY;this.#rY=null,this._uiManager.enableWaiting(!0),this.#rK=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#r3(t)).finally(()=>this.#r6());return}if(this.#rQ){let t=this.#rQ;this.#rQ=null,this._uiManager.enableWaiting(!0),this.#rK=this._uiManager.imageManager.getFromFile(t).then(t=>this.#r3(t)).finally(()=>this.#r6());return}let t=document.createElement("input");t.type="file",t.accept=iG.supportedTypesStr;let e=this._uiManager._signal;this.#rK=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#r3(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#r6()),t.click()}remove(){this.#rX&&(this.#rq=null,this._uiManager.imageManager.deleteId(this.#rX),this.#rZ?.remove(),this.#rZ=null,this.#r0&&(clearTimeout(this.#r0),this.#r0=null)),super.remove()}rebuild(){if(!this.parent){this.#rX&&this.#r4();return}super.rebuild(),null!==this.div&&(this.#rX&&null===this.#rZ&&this.#r4(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#rK||this.#rq||this.#rY||this.#rQ||this.#rX)}get isResizable(){return!0}render(){let t,e;if(this.div)return this.div;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#rq?this.#r5():this.#r4(),this.width&&!this.annotationElementId){let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#r0&&clearTimeout(this.#r0),this.#r0=setTimeout(()=>{this.#r0=null,this.#r8()},200))}#r5(){let{div:t}=this,{width:e,height:i}=this.#rq,[s,a]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*a;else if(e>.75*s||i>.75*a){let t=Math.min(.75*s/e,.75*a/i);e*=t,i*=t}let[r,n]=this.parentDimensions;this.setDims(e*r/s,i*n/a),this._uiManager.enableWaiting(!1);let o=this.#rZ=document.createElement("canvas");o.setAttribute("role","img"),this.addContainer(o),this.width=e/s,this.height=i/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#r8(),this.#r2||(this.parent.addUndoableEditor(this),this.#r2=!0),this._reportTelemetry({action:"inserted_image"}),this.#rJ&&o.setAttribute("aria-label",this.#rJ)}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:a}=this.#rq,r=new tl,n=this.#rq,o=s,l=a,h=null;if(e){if(s>e||a>e){let t=Math.min(e/s,e/a);o=Math.floor(s*t),l=Math.floor(a*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#r1||(n=this.#r7(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");let p=15*r.sx,g=15*r.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=c,f.fillRect(0,0,2*p,2*g),f.fillStyle=u,f.fillRect(0,0,p,g),f.fillRect(p,g,p,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(n,0,0,n.width,n.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&n.width<t&&n.height<t)e=n.width,i=n.height;else if(n=this.#rq,s>t||a>t){let r=Math.min(t/s,t/a);e=Math.floor(s*r),i=Math.floor(a*r),this.#r1||(n=this.#r7(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(n,0,0,n.width,n.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#r7(t,e){let{width:i,height:s}=this.#rq,a=i,r=s,n=this.#rq;for(;a>2*t||r>2*e;){let i=a,s=r;a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));let o=new OffscreenCanvas(a,r);o.getContext("2d").drawImage(n,0,0,i,s,0,0,a,r),n=o.transferToImageBitmap()}return n}#r8(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,a=new tl,r=Math.ceil(i*t*a.sx),n=Math.ceil(s*e*a.sy),o=this.#rZ;if(!o||o.width===r&&o.height===n)return;o.width=r,o.height=n;let l=this.#r1?this.#rq:this.#r7(r,n),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,n)}getImageForAltText(){return this.#rZ}#r9(t){if(t){if(this.#r1){let t=this._uiManager.imageManager.getSvgUrl(this.#rX);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#rq,t.getContext("2d").drawImage(this.#rq,0,0),t.toDataURL()}if(this.#r1){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*j.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*j.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(i,s);return a.getContext("2d").drawImage(this.#rq,0,0,this.#rq.width,this.#rq.height,0,0,i,s),a.transferToImageBitmap()}return structuredClone(this.#rq)}static async deserialize(t,e,i){let s=null;if(t instanceof i_){let{data:{rect:a,rotation:r,id:n,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,u=h.querySelector("canvas"),p=i.imageManager.getFromCanvas(h.id,u);u.remove();let g=(await e._structTree.getAriaAttributes(`${G}${n}`))?.get("aria-label")||"";s=t={annotationType:c.STAMP,bitmapId:p.id,bitmap:p.bitmap,pageIndex:d-1,rect:a.slice(0),rotation:r,id:n,deleted:!1,accessibilityData:{decorative:!1,altText:g},isSvg:!1,structParent:o,popupRef:l}}let a=await super.deserialize(t,e,i),{rect:r,bitmap:n,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(a.#rX=l,n&&(a.#rq=n)):a.#rY=o,a.#r1=h;let[u,p]=a.pageDimensions;return a.width=(r[2]-r[0])/u,a.height=(r[3]-r[1])/p,a.annotationElementId=t.id||null,d&&(a.altTextData=d),a._initialData=s,a.#r2=!!s,a}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i={annotationType:c.STAMP,bitmapId:this.#rX,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#r1,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#r9(!0),i.accessibilityData=this.serializeAltText(!0),i;let{decorative:s,altText:a}=this.serializeAltText(!1);if(!s&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){let t=this.#ar(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;let r=this.#r1?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#rX)){if(this.#r1){let t=e.stamps.get(this.#rX);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#r9(!1))}}else e.stamps.set(this.#rX,{area:r,serialized:i}),i.bitmap=this.#r9(!1);return i}#ar(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,a=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&a,isSameAltText:a}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class iU{#sJ;#nt=!1;#ne=null;#ni=null;#ns=null;#na=new Map;#nr=!1;#nn=!1;#no=!1;#nl=null;#nh=null;#nd=null;#nc=null;#m;static _initialized=!1;static #$=new Map([iE,i$,iG,iF].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:a,annotationLayer:r,drawLayer:n,textLayer:o,viewport:l,l10n:h}){const d=[...iU.#$.values()];if(!iU._initialized)for(const e of(iU._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#m=t,this.pageIndex=e,this.div=i,this.#sJ=a,this.#ne=r,this.viewport=l,this.#nd=o,this.drawLayer=n,this._structTree=s,this.#m.addLayer(this)}get isEmpty(){return 0===this.#na.size}get isInvisible(){return this.isEmpty&&this.#m.getMode()===c.NONE}updateToolbar(t){this.#m.updateToolbar(t)}updateMode(t=this.#m.getMode()){switch(this.#nu(),t){case c.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case c.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case c.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;for(let i of iU.#$.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#nd?.div}setEditingState(t){this.#m.setEditingState(t)}addCommands(t){this.#m.addCommands(t)}cleanUndoStack(t){this.#m.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ne?.div.classList.toggle("disabled",!t)}async enable(){this.#no=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let e of this.#na.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#m.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ne){this.#no=!1;return}for(let e of this.#ne.getEditableAnnotations()){if(e.hide(),this.#m.isDeletedAnnotationElement(e.data.id)||t.has(e.data.id))continue;let i=await this.deserialize(e);i&&(this.addOrRebuild(i),i.enableEditing())}this.#no=!1}disable(){this.#nn=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let i of this.#na.values())if(i.disableEditing(),i.annotationElementId){if(null!==i.serialize()){t.set(i.annotationElementId,i);continue}e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}if(this.#ne)for(let i of this.#ne.getEditableAnnotations()){let{id:s}=i.data;if(this.#m.isDeletedAnnotationElement(s))continue;let a=e.get(s);if(a){a.resetAnnotationElement(i),a.show(!1),i.show();continue}(a=t.get(s))&&(this.#m.addChangedExistingAnnotation(a),a.renderAnnotationElement(i)&&a.show(!1)),i.show()}this.#nu(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let t of iU.#$.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#nn=!1}getEditableAnnotation(t){return this.#ne?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#m.getActive()!==t&&this.#m.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#nd?.div&&!this.#nc){this.#nc=new AbortController;let t=this.#m.combinedSignal(this.#nc);this.#nd.div.addEventListener("pointerdown",this.#np.bind(this),{signal:t}),this.#nd.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#nd?.div&&this.#nc&&(this.#nc.abort(),this.#nc=null,this.#nd.div.classList.remove("highlighting"))}#np(t){this.#m.unselectAll();let{target:e}=t;if(e===this.#nd.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#nd.div.contains(e)){let{isMac:e}=N.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#m.showAllEditors("highlight",!0,!0),this.#nd.div.classList.add("free"),this.toggleDrawing(),iF.startHighlighting(this,"ltr"===this.#m.direction,{target:this.#nd.div,x:t.x,y:t.y}),this.#nd.div.addEventListener("pointerup",()=>{this.#nd.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#m._signal}),t.preventDefault()}}enableClick(){if(this.#ni)return;this.#ni=new AbortController;let t=this.#m.combinedSignal(this.#ni);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ni?.abort(),this.#ni=null}attach(t){this.#na.set(t.id,t);let{annotationElementId:e}=t;e&&this.#m.isDeletedAnnotationElement(e)&&this.#m.removeDeletedAnnotationElement(t)}detach(t){this.#na.delete(t.id),this.#sJ?.removePointerInTextLayer(t.contentDiv),!this.#nn&&t.annotationElementId&&this.#m.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#m.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#m.addDeletedAnnotationElement(t.annotationElementId),ty.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#m.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#no),this.#m.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#ns&&(t._focusEventsAllowed=!1,this.#ns=setTimeout(()=>{this.#ns=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#m._signal}),e.focus())},0)),t._structTreeParentId=this.#sJ?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#m.getId()}get #ng(){return iU.#$.get(this.#m.getMode())}combinedSignal(t){return this.#m.combinedSignal(t)}#nm(t){let e=this.#ng;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#ng?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#m.updateToolbar(t),this.#m.updateMode(t);let{offsetX:i,offsetY:s}=this.#nf(),a=this.getNextId(),r=this.#nm({parent:this,id:a,x:i,y:s,uiManager:this.#m,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await iU.#$.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#m)||null}createAndAddNewEditor(t,e,i={}){let s=this.getNextId(),a=this.#nm({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#m,isCentered:e,...i});return a&&this.add(a),a}#nf(){let{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),a=Math.max(0,t),r=Math.max(0,e),n=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(a+n)/2-t,h=(r+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(){this.createAndAddNewEditor(this.#nf(),!0)}setSelected(t){this.#m.setSelected(t)}toggleSelected(t){this.#m.toggleSelected(t)}unselect(t){this.#m.unselect(t)}pointerup(t){let{isMac:e}=N.platform;if(0===t.button&&(!t.ctrlKey||!e)&&t.target===this.div&&this.#nr&&(this.#nr=!1,!this.#ng?.isDrawer||!this.#ng.supportMultipleDrawings)){if(!this.#nt){this.#nt=!0;return}if(this.#m.getMode()===c.STAMP)return void this.#m.unselectAll();this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#m.getMode()===c.HIGHLIGHT&&this.enableTextSelection(),this.#nr){this.#nr=!1;return}let{isMac:e}=N.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#nr=!0,this.#ng?.isDrawer)return void this.startDrawingSession(t);let i=this.#m.getActive();this.#nt=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#nl)return void this.#ng.startDrawing(this,this.#m,!1,t);this.#m.setCurrentDrawingSession(this),this.#nl=new AbortController;let e=this.#m.combinedSignal(this.#nl);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#nh=null,this.commitOrRemove())},{signal:e}),this.#ng.startDrawing(this,this.#m,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#nh=t);return}this.#nh&&setTimeout(()=>{this.#nh?.focus(),this.#nh=null},0)}endDrawingSession(t=!1){return this.#nl?(this.#m.setCurrentDrawingSession(null),this.#nl.abort(),this.#nl=null,this.#nh=null,this.#ng.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#m.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#nl&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#nl&&this.#ng.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#m.getActive()?.parent===this&&(this.#m.commitOrRemove(),this.#m.setActiveEditor(null)),this.#ns&&(clearTimeout(this.#ns),this.#ns=null),this.#na.values()))this.#sJ?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#na.clear(),this.#m.removeLayer(this)}#nu(){for(let t of this.#na.values())t.isEmpty()&&t.remove()}render({viewport:t}){for(let e of(this.viewport=t,to(this.div,t),this.#m.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#m.commitOrRemove(),this.#nu();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,to(this.div,{rotation:i}),e!==i)for(let t of this.#na.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#m.viewParameters.realScale}}class ij{#sk=null;#v=0;#nb=new Map;#nA=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#sk){this.#sk=t;return}if(this.#sk!==t){if(this.#nb.size>0)for(let e of this.#nb.values())e.remove(),t.append(e);this.#sk=t}}static get _svgFactory(){return S(this,"_svgFactory",new e1)}static #nv(t,[e,i,s,a]){let{style:r}=t;r.top=`${100*i}%`,r.left=`${100*e}%`,r.width=`${100*s}%`,r.height=`${100*a}%`}#ny(){let t=ij._svgFactory.create(1,1,!0);return this.#sk.append(t),t.setAttribute("aria-hidden",!0),t}#nw(t,e){let i=ij._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let a=ij._svgFactory.createElement("use");return i.append(a),a.setAttribute("href",`#${e}`),a.classList.add("clip"),s}#n_(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=this.#v++,a=this.#ny(),r=ij._svgFactory.createElement("defs");a.append(r);let n=ij._svgFactory.createElement("path");r.append(n);let o=`path_p${this.pageIndex}_${s}`;n.setAttribute("id",o),n.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#nA.set(s,n);let l=i?this.#nw(r,o):null,h=ij._svgFactory.createElement("use");return a.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(a,t),this.#nb.set(s,a),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,s=this.#v++,a=this.#ny(),r=ij._svgFactory.createElement("defs");a.append(r);let n=ij._svgFactory.createElement("path");r.append(n);let o=`path_p${this.pageIndex}_${s}`;if(n.setAttribute("id",o),n.setAttribute("vector-effect","non-scaling-stroke"),e){let t=ij._svgFactory.createElement("mask");r.append(t),i=`mask_p${this.pageIndex}_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=ij._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let a=ij._svgFactory.createElement("use");t.append(a),a.setAttribute("href",`#${o}`),a.setAttribute("stroke","none"),a.setAttribute("fill","black"),a.setAttribute("fill-rule","nonzero"),a.classList.add("mask")}let l=ij._svgFactory.createElement("use");a.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return a.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(a,t),this.#nb.set(s,a),s}finalizeDraw(t,e){this.#nA.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:a,path:r}=e,n="number"==typeof t?this.#nb.get(t):t;if(n){if(i&&this.#n_(n,i),s&&ij.#nv(n,s),a){let{classList:t}=n;for(let[e,i]of Object.entries(a))t.toggle(e,i)}if(r){let t=n.firstChild.firstChild;this.#n_(t,r)}}}updateParent(t,e){if(e===this)return;let i=this.#nb.get(t);i&&(e.#sk.append(i),this.#nb.delete(t),e.#nb.set(t,i))}remove(t){this.#nA.delete(t),null!==this.#sk&&(this.#nb.get(t).remove(),this.#nb.delete(t))}destroy(){for(let t of(this.#sk=null,this.#nb.values()))t.remove();this.#nb.clear(),this.#nA.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:ik};var iV=n.AbortException,iW=n.AnnotationEditorLayer,iq=n.AnnotationEditorParamsType,iX=n.AnnotationEditorType,iK=n.AnnotationEditorUIManager,iY=n.AnnotationLayer,iQ=n.AnnotationMode,iJ=n.ColorPicker,iZ=n.DOMSVGFactory,i0=n.DrawLayer,i1=n.FeatureTest,i2=n.GlobalWorkerOptions,i3=n.ImageKind,i5=n.InvalidPDFException,i6=n.MissingPDFException,i4=n.OPS,i8=n.OutputScale,i7=n.PDFDataRangeTransport,i9=n.PDFDateString,st=n.PDFWorker,se=n.PasswordResponses,si=n.PermissionFlag,ss=n.PixelsPerInch,sa=n.RenderingCancelledException,sr=n.TextLayer,sn=n.TouchManager,so=n.UnexpectedResponseException,sl=n.Util,sh=n.VerbosityLevel,sd=n.XfaLayer,sc=n.build,su=n.createValidAbsoluteUrl,sp=n.fetchData,sg=n.getDocument,sm=n.getFilenameFromUrl,sf=n.getPdfFilenameFromUrl,sb=n.getXfaPageViewport,sA=n.isDataScheme,sv=n.isPdfFile,sy=n.noContextMenu,sw=n.normalizeUnicode,s_=n.setLayerDimensions,sx=n.shadow,sS=n.stopEvent,sC=n.version}}]);