@turinhub/atomix-common-ui 0.3.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 (114) hide show
  1. package/README.md +31 -16
  2. package/dist/PDFSidebar-BBtucLK6.js +232 -0
  3. package/dist/PDFSidebar-BBtucLK6.js.map +1 -0
  4. package/dist/PDFSidebar-Di0D-yPS.cjs +2 -0
  5. package/dist/PDFSidebar-Di0D-yPS.cjs.map +1 -0
  6. package/dist/component-types.cjs +2 -0
  7. package/dist/component-types.cjs.map +1 -0
  8. package/dist/component-types.d.ts +2 -0
  9. package/dist/component-types.d.ts.map +1 -0
  10. package/dist/component-types.js +2 -0
  11. package/dist/component-types.js.map +1 -0
  12. package/dist/components/MarkdownReader.d.ts +26 -0
  13. package/dist/components/MarkdownReader.d.ts.map +1 -0
  14. package/dist/components/PDFReader.d.ts +2 -2
  15. package/dist/components/PDFReader.d.ts.map +1 -1
  16. package/dist/components/PDFSidebar.d.ts +1 -1
  17. package/dist/components/PDFSidebar.d.ts.map +1 -1
  18. package/dist/components/SimplePDFReader.d.ts +1 -1
  19. package/dist/data-table.cjs +2 -0
  20. package/dist/data-table.cjs.map +1 -0
  21. package/dist/data-table.d.ts +3 -0
  22. package/dist/data-table.d.ts.map +1 -0
  23. package/dist/data-table.js +159 -0
  24. package/dist/data-table.js.map +1 -0
  25. package/dist/delete-confirm-dialog.cjs +2 -0
  26. package/dist/delete-confirm-dialog.cjs.map +1 -0
  27. package/dist/delete-confirm-dialog.d.ts +3 -0
  28. package/dist/delete-confirm-dialog.d.ts.map +1 -0
  29. package/dist/delete-confirm-dialog.js +109 -0
  30. package/dist/delete-confirm-dialog.js.map +1 -0
  31. package/dist/file-upload.cjs +2 -0
  32. package/dist/file-upload.cjs.map +1 -0
  33. package/dist/file-upload.d.ts +3 -0
  34. package/dist/file-upload.d.ts.map +1 -0
  35. package/dist/file-upload.js +354 -0
  36. package/dist/file-upload.js.map +1 -0
  37. package/dist/{index-miejqTjn.cjs → index-BiA_tnaq.cjs} +3 -3
  38. package/dist/{index-miejqTjn.cjs.map → index-BiA_tnaq.cjs.map} +1 -1
  39. package/dist/{index-DUxYhmkV.js → index-BypbGNpR.js} +2 -2
  40. package/dist/{index-DUxYhmkV.js.map → index-BypbGNpR.js.map} +1 -1
  41. package/dist/index.cjs +2 -0
  42. package/dist/index.cjs.map +1 -0
  43. package/dist/index.d.ts +0 -20
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +2 -12
  46. package/dist/jsx-runtime-B4hRZ52C.js +283 -0
  47. package/dist/jsx-runtime-B4hRZ52C.js.map +1 -0
  48. package/dist/jsx-runtime-BB_1_6y_.cjs +23 -0
  49. package/dist/jsx-runtime-BB_1_6y_.cjs.map +1 -0
  50. package/dist/markdown-reader.cjs +2 -0
  51. package/dist/markdown-reader.cjs.map +1 -0
  52. package/dist/markdown-reader.d.ts +3 -0
  53. package/dist/markdown-reader.d.ts.map +1 -0
  54. package/dist/markdown-reader.js +145 -0
  55. package/dist/markdown-reader.js.map +1 -0
  56. package/dist/pdf-reader.cjs +2 -0
  57. package/dist/pdf-reader.cjs.map +1 -0
  58. package/dist/pdf-reader.d.ts +3 -0
  59. package/dist/pdf-reader.d.ts.map +1 -0
  60. package/dist/pdf-reader.js +427 -0
  61. package/dist/pdf-reader.js.map +1 -0
  62. package/dist/pdf-sidebar.cjs +2 -0
  63. package/dist/pdf-sidebar.cjs.map +1 -0
  64. package/dist/pdf-sidebar.d.ts +3 -0
  65. package/dist/pdf-sidebar.d.ts.map +1 -0
  66. package/dist/pdf-sidebar.js +5 -0
  67. package/dist/pdf-sidebar.js.map +1 -0
  68. package/dist/simple-pdf-reader.cjs +2 -0
  69. package/dist/simple-pdf-reader.cjs.map +1 -0
  70. package/dist/simple-pdf-reader.d.ts +3 -0
  71. package/dist/simple-pdf-reader.d.ts.map +1 -0
  72. package/dist/simple-pdf-reader.js +268 -0
  73. package/dist/simple-pdf-reader.js.map +1 -0
  74. package/dist/table-header.cjs +2 -0
  75. package/dist/table-header.cjs.map +1 -0
  76. package/dist/table-header.d.ts +3 -0
  77. package/dist/table-header.d.ts.map +1 -0
  78. package/dist/table-header.js +63 -0
  79. package/dist/table-header.js.map +1 -0
  80. package/dist/table-pagination.cjs +2 -0
  81. package/dist/table-pagination.cjs.map +1 -0
  82. package/dist/table-pagination.d.ts +3 -0
  83. package/dist/table-pagination.d.ts.map +1 -0
  84. package/dist/table-pagination.js +172 -0
  85. package/dist/table-pagination.js.map +1 -0
  86. package/dist/theme-switcher-content.cjs +2 -0
  87. package/dist/theme-switcher-content.cjs.map +1 -0
  88. package/dist/theme-switcher-content.d.ts +3 -0
  89. package/dist/theme-switcher-content.d.ts.map +1 -0
  90. package/dist/theme-switcher-content.js +103 -0
  91. package/dist/theme-switcher-content.js.map +1 -0
  92. package/dist/theme-switcher.cjs +2 -0
  93. package/dist/theme-switcher.cjs.map +1 -0
  94. package/dist/theme-switcher.d.ts +3 -0
  95. package/dist/theme-switcher.d.ts.map +1 -0
  96. package/dist/theme-switcher.js +140 -0
  97. package/dist/theme-switcher.js.map +1 -0
  98. package/dist/utils-B6yFEsav.js +9 -0
  99. package/dist/utils-B6yFEsav.js.map +1 -0
  100. package/dist/utils-IjLH3w2e.cjs +2 -0
  101. package/dist/utils-IjLH3w2e.cjs.map +1 -0
  102. package/dist/utils.cjs +2 -0
  103. package/dist/utils.cjs.map +1 -0
  104. package/dist/utils.d.ts +2 -0
  105. package/dist/utils.d.ts.map +1 -0
  106. package/dist/utils.js +5 -0
  107. package/dist/utils.js.map +1 -0
  108. package/package.json +161 -3
  109. package/dist/index-DJdfLA8M.js +0 -2140
  110. package/dist/index-DJdfLA8M.js.map +0 -1
  111. package/dist/index-tIca-Q_M.cjs +0 -23
  112. package/dist/index-tIca-Q_M.cjs.map +0 -1
  113. package/dist/index.c.js +0 -2
  114. package/dist/index.c.js.map +0 -1
@@ -1,5 +1,5 @@
1
- "use strict";var xy=Object.defineProperty;var ig=d=>{throw TypeError(d)};var Ty=(d,t,e)=>t in d?xy(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var k=(d,t,e)=>Ty(d,typeof t!="symbol"?t+"":t,e),Xu=(d,t,e)=>t.has(d)||ig("Cannot "+e);var n=(d,t,e)=>(Xu(d,t,"read from private field"),e?e.call(d):t.get(d)),g=(d,t,e)=>t.has(d)?ig("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,e),p=(d,t,e,s)=>(Xu(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e),b=(d,t,e)=>(Xu(d,t,"access private method"),e);var Kt=(d,t,e,s)=>({set _(i){p(d,t,i,e)},get _(){return n(d,t,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ct=require("./index-tIca-Q_M.cjs"),$=require("react"),Gl=require("clsx");var qu=typeof document<"u"?document.currentScript:null;function Py(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}const Be=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),lf=[.001,0,0,.001,0,0],Yu=1.35,bs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Di={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},vh="pdfjs_internal_editor_",X={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},st={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},jg={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ue={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},wh={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},zt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Za={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},hd={ERRORS:0,WARNINGS:1,INFOS:5},$l={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,rawFillPath:94},yd={moveTo:0,lineTo:1,curveTo:2,closePath:3},$g={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Ou=hd.WARNINGS;function Ry(d){Number.isInteger(d)&&(Ou=d)}function ky(){return Ou}function Bu(d){Ou>=hd.INFOS&&console.info(`Info: ${d}`)}function q(d){Ou>=hd.WARNINGS&&console.warn(`Warning: ${d}`)}function _t(d){throw new Error(d)}function nt(d,t){d||_t(t)}function Dy(d){switch(d==null?void 0:d.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Fp(d,t=null,e=null){if(!d)return null;if(e&&typeof d=="string"){if(e.addDefaultProtocol&&d.startsWith("www.")){const i=d.match(/\./g);(i==null?void 0:i.length)>=2&&(d=`http://${d}`)}if(e.tryConvertEncoding)try{d=Ny(d)}catch{}}const s=t?URL.parse(d,t):URL.parse(d);return Dy(s)?s:null}function Np(d,t,e=!1){const s=URL.parse(d);return s?(s.hash=t,s.href):e&&Fp(d,"http://example.com")?d.split("#",1)[0]+`${t?`#${t}`:""}`:""}function J(d,t,e,s=!1){return Object.defineProperty(d,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Ya=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class ng extends Ya{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ku extends Ya{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class au extends Ya{constructor(t){super(t,"InvalidPDFException")}}class Eh extends Ya{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class My extends Ya{constructor(t){super(t,"FormatError")}}class Sn extends Ya{constructor(t){super(t,"AbortException")}}function zg(d){(typeof d!="object"||(d==null?void 0:d.length)===void 0)&&_t("Invalid argument for bytesToString");const t=d.length,e=8192;if(t<e)return String.fromCharCode.apply(null,d);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=d.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function cd(d){typeof d!="string"&&_t("Invalid argument for stringToBytes");const t=d.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=d.charCodeAt(s)&255;return e}function Ly(d){return String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,d&255)}function Iy(){const d=new Uint8Array(4);return d[0]=1,new Uint32Array(d.buffer,0,1)[0]===1}function Fy(){try{return new Function(""),!0}catch{return!1}}class ce{static get isLittleEndian(){return J(this,"isLittleEndian",Iy())}static get isEvalSupported(){return J(this,"isEvalSupported",Fy())}static get isOffscreenCanvasSupported(){return J(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return J(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return J(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return J(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Ju=Array.from(Array(256).keys(),d=>d.toString(16).padStart(2,"0"));var vn,Pd,hf;class H{static makeHexColor(t,e,s){return`#${Ju[t]}${Ju[e]}${Ju[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5];for(let c=0;c<6;c+=2){const u=t[s+c],f=t[s+c+1];t[s+c]=u*i+f*a+l,t[s+c+1]=u*r+f*o+h}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5],c=t[0],u=t[1],f=t[2],m=t[3];let A=i*c+l,y=A,v=i*f+l,w=v,S=o*u+h,E=S,_=o*m+h,C=_;if(r!==0||a!==0){const x=r*c,T=r*f,P=a*u,R=a*m;A+=P,w+=P,v+=R,y+=R,S+=x,C+=x,_+=T,E+=T}s[0]=Math.min(s[0],A,v,y,w),s[1]=Math.min(s[1],S,_,E,C),s[2]=Math.max(s[2],A,v,y,w),s[3]=Math.max(s[3],S,_,E,C)}static inverseTransform(t){const 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,e){const s=t[0],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,h=r**2+a**2,c=(o+h)/2,u=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+u||1),e[1]=Math.sqrt(c-u||1)}static normalizeRect(t){const 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){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,r,a,o,l,h){h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l),b(this,vn,hf).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),b(this,vn,hf).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h)}}vn=new WeakSet,Pd=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const u=1-h,f=h*h,m=f*h,A=u*(u*(u*t+3*h*e)+3*f*s)+m*i,y=u*(u*(u*r+3*h*a)+3*f*o)+m*l;c[0]=Math.min(c[0],A),c[1]=Math.min(c[1],y),c[2]=Math.max(c[2],A),c[3]=Math.max(c[3],y)},hf=function(t,e,s,i,r,a,o,l,h,c,u,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,vn,Pd).call(this,t,e,s,i,r,a,o,l,-u/c,f);return}const m=c**2-4*u*h;if(m<0)return;const A=Math.sqrt(m),y=2*h;b(this,vn,Pd).call(this,t,e,s,i,r,a,o,l,(-c+A)/y,f),b(this,vn,Pd).call(this,t,e,s,i,r,a,o,l,(-c-A)/y,f)},g(H,vn);function Ny(d){return decodeURIComponent(escape(d))}let Qu=null,rg=null;function Gg(d){return Qu||(Qu=/([\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,rg=new Map([["ſt","ſt"]])),d.replaceAll(Qu,(t,e,s)=>e?e.normalize("NFKC"):rg.get(s))}function Op(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),zg(d)}const Bp="pdfjs_internal_id_";function Oy(d,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!d(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}function De(d,t,e){return Math.min(Math.max(d,t),e)}function Vg(d){return Uint8Array.prototype.toBase64?d.toBase64():btoa(zg(d))}function By(d){return Uint8Array.fromBase64?Uint8Array.fromBase64(d):cd(atob(d))}typeof Promise.try!="function"&&(Promise.try=function(d,...t){return new Promise(e=>{e(d(...t))})});typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(d){return d.reduce((t,e)=>t+e,0)});class Sh{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Sh.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class Hp{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=m}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const m=document.createTextNode(i.value);a.append(m),o&&Sh.shouldBuildText(i.name)&&h.push(m)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[m,A,y]=c.at(-1);if(A+1===m.children.length){c.pop();continue}const v=m.children[++c.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const E=document.createTextNode(v.value);h.push(E),y.append(E);continue}const S=(u=v==null?void 0:v.attributes)!=null&&u.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(y.append(S),v.attributes&&this.setAttributes({html:S,element:v,storage:e,intent:r,linkService:s}),((f=v.children)==null?void 0:f.length)>0)c.push([v,-1,S]);else if(v.value){const E=document.createTextNode(v.value);o&&Sh.shouldBuildText(w)&&h.push(E),S.append(E)}}for(const m of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Fi="http://www.w3.org/2000/svg",Mr=class Mr{};k(Mr,"CSS",96),k(Mr,"PDF",72),k(Mr,"PDF_TO_CSS_UNITS",Mr.CSS/Mr.PDF);let _n=Mr;async function Vl(d,t="text"){if(Zl(d,document.baseURI)){const e=await fetch(d);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",d,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class dd{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,u,f,m;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,u=0,f=0,m=1;break;case 90:c=0,u=1,f=1,m=0;break;case 270:c=0,u=-1,f=-1,m=0;break;case 0:c=1,u=0,f=0,m=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,m=-m);let A,y,v,w;c===0?(A=Math.abs(h-t[1])*s+r,y=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(A=Math.abs(l-t[0])*s+r,y=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,u*s,f*s,m*s,A-c*s*l-f*s*h,y-u*s*l-m*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return J(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new dd({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return H.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];H.applyTransform(e,this.transform);const s=[t[2],t[3]];return H.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return H.applyInverseTransform(s,this.transform),s}}class Hu extends Ya{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ud(d){const t=d.length;let e=0;for(;e<t&&d[e].trim()==="";)e++;return d.substring(e,e+5).toLowerCase()==="data:"}function Uu(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function Wg(d){return[d]=d.split(/[#?]/,1),d.substring(d.lastIndexOf("/")+1)}function Xg(d,t="document.pdf"){if(typeof d!="string")return t;if(ud(d))return q('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(d);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:o):l}catch{return o}},r=/\.pdf$/i,a=s.pathname.split("/").at(-1);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=Array.from(s.searchParams.values()).reverse();for(const h of o)if(r.test(h))return i(h);const l=Array.from(s.searchParams.keys()).reverse();for(const h of l)if(r.test(h))return i(h)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return t}class ag{constructor(){k(this,"started",Object.create(null));k(this,"times",[])}time(t){t in this.started&&q(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||q(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:r}of this.times)t.push(`${s.padEnd(e)} ${r-i}ms
2
- `);return t.join("")}}function Zl(d,t){const e=t?URL.parse(d,t):URL.parse(d);return(e==null?void 0:e.protocol)==="http:"||(e==null?void 0:e.protocol)==="https:"}function vs(d){d.preventDefault()}function Nt(d){d.preventDefault(),d.stopPropagation()}function Hy(d){console.log("Deprecated API usage: "+d)}var Rh;class _h{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,Rh)||p(this,Rh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,Rh).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(a+=c,o+=u):h==="+"&&(a-=c,o-=u),new Date(Date.UTC(s,i,r,a,o,l))}}Rh=new WeakMap,g(_h,Rh);function qg(d,{scale:t=1,rotation:e=0}){const{width:s,height:i}=d.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new dd({viewBox:r,userUnit:1,scale:t,rotation:e})}function Wl(d){if(d.startsWith("#")){const t=parseInt(d.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return d.startsWith("rgb(")?d.slice(4,-1).split(",").map(t=>parseInt(t)):d.startsWith("rgba(")?d.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(q(`Not a valid color format: "${d}"`),[0,0,0])}function Uy(d){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of d.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;d.set(e,Wl(s))}t.remove()}function Ft(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform();return[t,e,s,i,r,a]}function ni(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform().invertSelf();return[t,e,s,i,r,a]}function _r(d,t,e=!1,s=!0){if(t instanceof dd){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=d,o=ce.isCSSRoundSupported,l=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${r}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,u=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=u):(a.width=u,a.height=c)}s&&d.setAttribute("data-main-rotation",t.rotation)}class ei{constructor(){const{pixelRatio:t}=ei;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=ei.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const h=Math.min(a,o,l);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const ou=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class jy{static get isDarkMode(){var t;return J(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class Yg{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),J(this,"commentForegroundColor",Wl(s))}}function Kg(d,t,e,s){s=Math.min(Math.max(s??1,0),1);const i=255*(1-s);return d=Math.round(d*s+i),t=Math.round(t*s+i),e=Math.round(e*s+i),[d,t,e]}function og(d,t){const e=d[0]/255,s=d[1]/255,i=d[2]/255,r=Math.max(e,s,i),a=Math.min(e,s,i),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-i)/l+(s<i?6:0))*60;break;case s:t[0]=((i-e)/l+2)*60;break;case i:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function cf(d,t){const e=d[0],s=d[1],i=d[2],r=(1-Math.abs(2*i-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=i-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function lg(d){return d<=.03928?d/12.92:((d+.055)/1.055)**2.4}function hg(d,t,e){cf(d,e),e.map(lg);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];cf(t,e),e.map(lg);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const cg=new Map;function Jg(d,t){const e=d[0]+d[1]*256+d[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=cg.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);og(d,a);const o=i.subarray(6,9);og(t,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),hg(a,o,r)<h){let c,u;l?(c=a[2],u=1):(c=0,u=a[2]);const f=.005;for(;u-c>f;){const m=a[2]=(c+u)/2;l===hg(a,o,r)<h?c=m:u=m}a[2]=l?u:c}return cf(a,r),s=H.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),cg.set(e,s),s}function Up({html:d,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof d=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=d.split(/(?:\r\n?|\n)/);for(let o=0,l=a.length;o<l;++o){const h=a[o];r.append(document.createTextNode(h)),o<l-1&&r.append(document.createElement("br"))}i.append(r)}else Hp.render({xfaHtml:d,div:i,intent:"richText"});i.firstChild.classList.add("richText",e),s.append(i)}var kn,Dn,_s,Cs,kh,Mn,mo,bo,Dh,yu,Qg,ve,Zg,tm,to,th;const Bi=class Bi{constructor(t){g(this,ve);g(this,kn,null);g(this,Dn,null);g(this,_s);g(this,Cs,null);g(this,kh,null);g(this,Mn,null);g(this,mo,null);g(this,bo,null);p(this,_s,t),n(Bi,Dh)||p(Bi,Dh,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",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=p(this,kn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,_s)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",vs,{signal:e}),t.addEventListener("pointerdown",b(Bi,yu,Qg),{signal:e}));const s=p(this,Cs,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,_s).toolbarPosition;if(i){const{style:r}=t,a=n(this,_s)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return n(this,kn)}hide(){var t;n(this,kn).classList.add("hidden"),(t=n(this,Dn))==null||t.hideDropdown()}show(){var t,e;n(this,kn).classList.remove("hidden"),(t=n(this,kh))==null||t.shown(),(e=n(this,Mn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,_s),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Bi,Dh)[t]),b(this,ve,to).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,Cs).append(s)}async addAltText(t){const e=await t.render();b(this,ve,to).call(this,e),n(this,Cs).append(e,n(this,ve,th)),p(this,kh,t)}addComment(t,e=null){if(n(this,Mn))return;const s=t.renderForToolbar();if(!s)return;b(this,ve,to).call(this,s);const i=p(this,mo,n(this,ve,th));e?(n(this,Cs).insertBefore(s,e),n(this,Cs).insertBefore(i,e)):n(this,Cs).append(s,i),p(this,Mn,t),t.toolbar=this}addColorPicker(t){if(n(this,Dn))return;p(this,Dn,t);const e=t.renderButton();b(this,ve,to).call(this,e),n(this,Cs).append(e,n(this,ve,th))}async addEditSignatureButton(t){const e=p(this,bo,await t.renderEditButton(n(this,_s)));b(this,ve,to).call(this,e),n(this,Cs).append(e,n(this,ve,th))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Mn))==null||e.removeToolbarCommentButton(),p(this,Mn,null),(s=n(this,mo))==null||s.remove(),p(this,mo,null);break}}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e);break}}async addButtonBefore(t,e,s){const i=n(this,Cs).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,bo)&&(n(this,bo).title=t)}remove(){var t;n(this,kn).remove(),(t=n(this,Dn))==null||t.destroy(),p(this,Dn,null)}};kn=new WeakMap,Dn=new WeakMap,_s=new WeakMap,Cs=new WeakMap,kh=new WeakMap,Mn=new WeakMap,mo=new WeakMap,bo=new WeakMap,Dh=new WeakMap,yu=new WeakSet,Qg=function(t){t.stopPropagation()},ve=new WeakSet,Zg=function(t){n(this,_s)._focusEventsAllowed=!1,Nt(t)},tm=function(t){n(this,_s)._focusEventsAllowed=!0,Nt(t)},to=function(t){const e=n(this,_s)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,ve,Zg).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,ve,tm).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",vs,{signal:e}),!0)},th=function(){const t=document.createElement("div");return t.className="divider",t},g(Bi,yu),g(Bi,Dh,null);let df=Bi;var Mh,Fr,Ui,Cn,em,sm,uf;class $y{constructor(t){g(this,Cn);g(this,Mh,null);g(this,Fr,null);g(this,Ui);p(this,Ui,t)}show(t,e,s){const[i,r]=b(this,Cn,sm).call(this,e,s),{style:a}=n(this,Fr)||p(this,Fr,b(this,Cn,em).call(this));t.append(n(this,Fr)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Fr).remove()}}Mh=new WeakMap,Fr=new WeakMap,Ui=new WeakMap,Cn=new WeakSet,em=function(){const t=p(this,Fr,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,Ui)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",vs,{signal:e});const s=p(this,Mh,document.createElement("div"));return s.className="buttons",t.append(s),n(this,Ui).hasCommentManager()&&b(this,Cn,uf).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,Ui).commentSelection("floating_button")}),b(this,Cn,uf).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,Ui).highlightSelection("floating_button")}),t},sm=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},uf=function(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=n(this,Ui)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",vs,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,Mh).append(r)};function im(d,t,e){for(const s of e)t.addEventListener(s,d[s].bind(d))}var Au;class zy{constructor(){g(this,Au,0)}get id(){return`${vh}${Kt(this,Au)._++}`}}Au=new WeakMap;var yo,Lh,Ce,Ao,Rd;const Qp=class Qp{constructor(){g(this,Ao);g(this,yo,Op());g(this,Lh,0);g(this,Ce,null)}static get _isSVGFittingCanvas(){const t='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=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return J(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,Ao,Rd).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,Ao,Rd).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,Ao,Rd).call(this,t,s)}async getFromId(t){n(this,Ce)||p(this,Ce,new Map);const e=n(this,Ce).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){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,Ce)||p(this,Ce,new Map);let s=n(this,Ce).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,yo)}_${Kt(this,Lh)._++}`,refCounter:1,isSvg:!1},n(this,Ce).set(t,s),n(this,Ce).set(s.id,s),s}getSvgUrl(t){const e=n(this,Ce).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Ce)||p(this,Ce,new Map);const e=n(this,Ce).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,yo)}_`)}};yo=new WeakMap,Lh=new WeakMap,Ce=new WeakMap,Ao=new WeakSet,Rd=async function(t,e){n(this,Ce)||p(this,Ce,new Map);let s=n(this,Ce).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,yo)}_${Kt(this,Lh)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Vl(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Qp._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=c});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){q(i),s=null}return n(this,Ce).set(t,s),s&&n(this,Ce).set(s.id,s),s};let ff=Qp;var Gt,Ln,Ih,It;class Gy{constructor(t=128){g(this,Gt,[]);g(this,Ln,!1);g(this,Ih);g(this,It,-1);p(this,Ih,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Ln))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,It)===-1){n(this,Gt).length>0&&(n(this,Gt).length=0),p(this,It,0),n(this,Gt).push(l);return}if(a&&n(this,Gt)[n(this,It)].type===r){o&&(l.undo=n(this,Gt)[n(this,It)].undo),n(this,Gt)[n(this,It)]=l;return}const h=n(this,It)+1;h===n(this,Ih)?n(this,Gt).splice(0,1):(p(this,It,h),h<n(this,Gt).length&&n(this,Gt).splice(h)),n(this,Gt).push(l)}undo(){if(n(this,It)===-1)return;p(this,Ln,!0);const{undo:t,post:e}=n(this,Gt)[n(this,It)];t(),e==null||e(),p(this,Ln,!1),p(this,It,n(this,It)-1)}redo(){if(n(this,It)<n(this,Gt).length-1){p(this,It,n(this,It)+1),p(this,Ln,!0);const{cmd:t,post:e}=n(this,Gt)[n(this,It)];t(),e==null||e(),p(this,Ln,!1)}}hasSomethingToUndo(){return n(this,It)!==-1}hasSomethingToRedo(){return n(this,It)<n(this,Gt).length-1}cleanType(t){if(n(this,It)!==-1){for(let e=n(this,It);e>=0;e--)if(n(this,Gt)[e].type!==t){n(this,Gt).splice(e+1,n(this,It)-e),p(this,It,e);return}n(this,Gt).length=0,p(this,It,-1)}}destroy(){p(this,Gt,null)}}Gt=new WeakMap,Ln=new WeakMap,Ih=new WeakMap,It=new WeakMap;var wu,nm;class fd{constructor(t){g(this,wu);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ce.platform;for(const[s,i,r={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(b(this,wu,nm).call(this,e));if(!s)return;const{callback:i,options:{bubbles:r=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(i.bind(t,...a,e)(),r||Nt(e))}}wu=new WeakSet,nm=function(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);const e=this.buffer.join("+");return this.buffer.length=0,e};const vu=class vu{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Uy(t),J(this,"_colors",t)}convert(t){const e=Wl(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return vu._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?H.makeHexColor(...e):t}};k(vu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let pf=vu;var wo,ts,vo,Bt,Qt,Eo,xs,So,Ts,xe,In,Fn,_o,Nn,li,Ps,Nr,Fh,Nh,Co,Oh,hi,On,xo,Bn,ci,Eu,Hn,To,Bh,Un,Or,Po,jn,Hh,Xt,ft,ji,$n,zn,Uh,Ro,jh,Gn,di,$i,$h,zh,Rs,L,kd,gf,rm,am,eh,om,lm,hm,mf,cm,bf,yf,dm,Le,Ni,um,fm,Af,pm,sh,wf;const lo=class lo{constructor(t,e,s,i,r,a,o,l,h,c,u,f,m,A,y,v){g(this,L);g(this,wo,new AbortController);g(this,ts,null);g(this,vo,null);g(this,Bt,new Map);g(this,Qt,new Map);g(this,Eo,null);g(this,xs,null);g(this,So,null);g(this,Ts,new Gy);g(this,xe,null);g(this,In,null);g(this,Fn,null);g(this,_o,0);g(this,Nn,new Set);g(this,li,null);g(this,Ps,null);g(this,Nr,new Set);k(this,"_editorUndoBar",null);g(this,Fh,!1);g(this,Nh,!1);g(this,Co,!1);g(this,Oh,null);g(this,hi,null);g(this,On,null);g(this,xo,null);g(this,Bn,!1);g(this,ci,null);g(this,Eu,new zy);g(this,Hn,!1);g(this,To,!1);g(this,Bh,!1);g(this,Un,null);g(this,Or,null);g(this,Po,null);g(this,jn,null);g(this,Hh,null);g(this,Xt,X.NONE);g(this,ft,new Set);g(this,ji,null);g(this,$n,null);g(this,zn,null);g(this,Uh,null);g(this,Ro,null);g(this,jh,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});g(this,Gn,[0,0]);g(this,di,null);g(this,$i,null);g(this,$h,null);g(this,zh,null);g(this,Rs,null);const w=this._signal=n(this,wo).signal;p(this,$i,t),p(this,$h,e),p(this,zh,s),p(this,Eo,i),p(this,xe,r),p(this,$n,a),p(this,Ro,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),{signal:w}),window.addEventListener("pointerdown",()=>{p(this,To,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{p(this,To,!1)},{capture:!0,signal:w}),b(this,L,om).call(this),b(this,L,dm).call(this),b(this,L,mf).call(this),p(this,xs,l.annotationStorage),p(this,Oh,l.filterFactory),p(this,zn,h),p(this,xo,c||null),p(this,Fh,u),p(this,Nh,f),p(this,Co,m),p(this,Hh,A||null),this.viewParameters={realScale:_n.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=y||null,this._supportsPinchToZoom=v!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=lo.prototype,e=a=>n(a,$i).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return J(this,"_keyboardManager",new fd([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,$i).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,$i).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r,a,o,l,h;(t=n(this,Rs))==null||t.resolve(),p(this,Rs,null),(e=n(this,wo))==null||e.abort(),p(this,wo,null),this._signal=null;for(const c of n(this,Qt).values())c.destroy();n(this,Qt).clear(),n(this,Bt).clear(),n(this,Nr).clear(),(s=n(this,jn))==null||s.clear(),p(this,ts,null),n(this,ft).clear(),n(this,Ts).destroy(),(i=n(this,Eo))==null||i.destroy(),(r=n(this,xe))==null||r.destroy(),(a=n(this,$n))==null||a.destroy(),(o=n(this,ci))==null||o.hide(),p(this,ci,null),(l=n(this,Po))==null||l.destroy(),p(this,Po,null),p(this,vo,null),n(this,hi)&&(clearTimeout(n(this,hi)),p(this,hi,null)),n(this,di)&&(clearTimeout(n(this,di)),p(this,di,null)),(h=this._editorUndoBar)==null||h.destroy(),p(this,Ro,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,Hh)}get useNewAltTextFlow(){return n(this,Nh)}get useNewAltTextWhenAddingImage(){return n(this,Co)}get hcmFilter(){return J(this,"hcmFilter",n(this,zn)?n(this,Oh).addHCMFilter(n(this,zn).foreground,n(this,zn).background):"none")}get direction(){return J(this,"direction",getComputedStyle(n(this,$i)).direction)}get _highlightColors(){return J(this,"_highlightColors",n(this,xo)?new Map(n(this,xo).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return J(this,"highlightColors",null);const e=new Map,s=!!n(this,zn);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,r)}return J(this,"highlightColors",e)}get highlightColorNames(){return J(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Fn,t)}setMainHighlightColorPicker(t){p(this,Po,t)}editAltText(t,e=!1){var s;(s=n(this,Eo))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,xe)}editComment(t,e,s,i){var r;(r=n(this,xe))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,Qt).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,xe))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,xe))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=n(this,xe))==null||e.removeComments([t.uid])}toggleComment(t,e,s=void 0){var i;(i=n(this,xe))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,xe))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,xe))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,Qt).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i),await s}getSignature(t){var e;(e=n(this,$n))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,$n)}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}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,Co,e);break}}onPageChanging({pageNumber:t}){p(this,_o,t-1)}focusMainContainer(){n(this,$i).focus()}findParent(t,e){for(const s of n(this,Qt).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,$h).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Nr).add(t)}removeShouldRescale(t){n(this,Nr).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*_n.PDF_TO_CSS_UNITS;for(const s of n(this,Nr))s.onScaleChanging();(e=n(this,Fn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,L,kd).call(this,s).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;s.empty();const f=b(this,L,gf).call(this,c),m=n(this,Xt)===X.NONE,A=()=>{const y=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});m&&this.showAllEditors("highlight",!0,!0),e&&(y==null||y.editComment())};if(m){this.switchToMode(X.HIGHLIGHT,A);return}A()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,xs))return null;const e=`${vh}${t}`,s=n(this,xs).getRawValue(e);return s&&n(this,xs).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,xs)&&!n(this,xs).has(t.id)&&n(this,xs).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,zh);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,Bn)&&(p(this,Bn,!1),b(this,L,eh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,ft))if(e.div.contains(t)){p(this,Or,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Or))return;const[t,e]=n(this,Or);p(this,Or,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,L,mf).call(this),b(this,L,bf).call(this)}removeEditListeners(){b(this,L,cm).call(this),b(this,L,yf).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Ps))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,Ps))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,ts))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,ft)){const r=i.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of n(this,Ps))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){q(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,L,Af).call(this,l);b(this,L,wf).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){q(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Xt)!==X.NONE&&!this.isEditorHandlingKeyboard&&lo._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Bn)&&(p(this,Bn,!1),b(this,L,eh).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(t){t?(b(this,L,lm).call(this),b(this,L,bf).call(this),b(this,L,Le).call(this,{isEditing:n(this,Xt)!==X.NONE,isEmpty:b(this,L,sh).call(this),hasSomethingToUndo:n(this,Ts).hasSomethingToUndo(),hasSomethingToRedo:n(this,Ts).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,L,hm).call(this),b(this,L,yf).call(this),b(this,L,Le).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Ps)){p(this,Ps,t);for(const e of n(this,Ps))b(this,L,Ni).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Eu).id}get currentLayer(){return n(this,Qt).get(n(this,_o))}getLayer(t){return n(this,Qt).get(t)}get currentPageIndex(){return n(this,_o)}addLayer(t){n(this,Qt).set(t.pageIndex,t),n(this,Hn)?t.enable():t.disable()}removeLayer(t){n(this,Qt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1){var a,o,l,h,c,u;if(n(this,Xt)!==t&&!(n(this,Rs)&&(await n(this,Rs).promise,!n(this,Rs)))){if(p(this,Rs,Promise.withResolvers()),(a=n(this,Fn))==null||a.commitOrRemove(),n(this,Xt)===X.POPUP&&((o=n(this,xe))==null||o.hideSidebar()),(l=n(this,xe))==null||l.destroyPopup(),p(this,Xt,t),t===X.NONE){this.setEditingState(!1),b(this,L,fm).call(this);for(const f of n(this,Bt).values())f.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),n(this,Rs).resolve();return}for(const f of n(this,Bt).values())f.addStandaloneCommentButton();t===X.SIGNATURE&&await((c=n(this,$n))==null?void 0:c.loadSignatures()),this.setEditingState(!0),await b(this,L,um).call(this),this.unselectAll();for(const f of n(this,Qt).values())f.updateMode(t);if(t===X.POPUP){n(this,vo)||p(this,vo,await n(this,Ro).getAnnotationsByType(new Set(n(this,Ps).map(A=>A._editorType))));const f=new Set,m=[];for(const A of n(this,Bt).values()){const{annotationElementId:y,hasComment:v,deleted:w}=A;y&&f.add(y),v&&!w&&m.push(A.getData())}for(const A of n(this,vo)){const{id:y,popupRef:v,contentsObj:w}=A;v&&(w!=null&&w.str)&&!f.has(y)&&!n(this,Nn).has(y)&&m.push(A)}(u=n(this,xe))==null||u.showSidebar(m)}if(!e){s&&this.addNewEditorFromKeyboard(),n(this,Rs).resolve();return}for(const f of n(this,Bt).values())f.uid===e?(this.setSelected(f),r?f.editComment():i?f.enterInEditMode():f.focus()):f.unselect();n(this,Rs).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Xt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,Ps)){switch(t){case st.CREATE:this.currentLayer.addNewEditor(e);return;case st.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Uh)||p(this,Uh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,ft))s.updateParams(t,e);else for(const s of n(this,Ps))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,Bt).values())a.editorType===t&&a.show(e);(((r=n(this,Uh))==null?void 0:r.get(st.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,L,Ni).call(this,[[st.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,Bh)!==t){p(this,Bh,t);for(const e of n(this,Qt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,Bt).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,Bt).get(t)}addEditor(t){n(this,Bt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,hi)&&clearTimeout(n(this,hi)),p(this,hi,setTimeout(()=>{this.focusMainContainer(),p(this,hi,null)},0))),n(this,Bt).delete(t.id),t.annotationElementId&&((e=n(this,jn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Nn).has(t.annotationElementId))&&((s=n(this,xs))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Nn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Nn).has(t)}removeDeletedAnnotationElement(t){n(this,Nn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,ts)!==t&&(p(this,ts,t),t&&b(this,L,Ni).call(this,t.propertiesToUpdate))}updateUI(t){n(this,L,pm)===t&&b(this,L,Ni).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,L,Ni).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,ft).has(t)){n(this,ft).delete(t),t.unselect(),b(this,L,Le).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,ft).add(t),t.select(),b(this,L,Ni).call(this,t.propertiesToUpdate),b(this,L,Le).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),(e=n(this,Fn))==null||e.commitOrRemove();for(const s of n(this,ft))s!==t&&s.unselect();n(this,ft).clear(),n(this,ft).add(t),t.select(),b(this,L,Ni).call(this,t.propertiesToUpdate),b(this,L,Le).call(this,{hasSelectedEditor:!0})}isSelected(t){return n(this,ft).has(t)}get firstSelectedEditor(){return n(this,ft).values().next().value}unselect(t){t.unselect(),n(this,ft).delete(t),b(this,L,Le).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,ft).size!==0}get isEnterHandled(){return n(this,ft).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,Ts).undo(),b(this,L,Le).call(this,{hasSomethingToUndo:n(this,Ts).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,L,sh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,Ts).redo(),b(this,L,Le).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Ts).hasSomethingToRedo(),isEmpty:b(this,L,sh).call(this)})}addCommands(t){n(this,Ts).add(t),b(this,L,Le).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,L,sh).call(this)})}cleanUndoStack(t){n(this,Ts).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,ft)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)b(this,L,Af).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,ts))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,ts)||this.hasSelection}selectAll(){for(const t of n(this,ft))t.commit();b(this,L,wf).call(this,n(this,Bt).values())}unselectAll(){var t;if(!(n(this,ts)&&(n(this,ts).commitOrRemove(),n(this,Xt)!==X.NONE))&&!((t=n(this,Fn))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of n(this,ft))e.unselect();n(this,ft).clear(),b(this,L,Le).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Gn)[0]+=t,n(this,Gn)[1]+=e;const[i,r]=n(this,Gn),a=[...n(this,ft)],o=1e3;n(this,di)&&clearTimeout(n(this,di)),p(this,di,setTimeout(()=>{p(this,di,null),n(this,Gn)[0]=n(this,Gn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,Bt).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,Bt).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,li,new Map);for(const t of n(this,ft))n(this,li).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,li))return!1;this.disableUserSelect(!1);const t=n(this,li);p(this,li,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,Bt).has(i.id)){const l=n(this,Qt).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,li))for(const s of n(this,li).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const 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(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||n(this,ft).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,ts)===t}getActive(){return n(this,ts)}getMode(){return n(this,Xt)}isEditingMode(){return n(this,Xt)!==X.NONE}get imageManager(){return J(this,"imageManager",new ff)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,u,f)=>({x:(c-i)/a,y:1-(h+u-s)/r,width:f/a,height:u/r});break;case"180":o=(h,c,u,f)=>({x:1-(h+u-s)/r,y:1-(c+f-i)/a,width:u/r,height:f/a});break;case"270":o=(h,c,u,f)=>({x:1-(c+f-i)/a,y:(h-s)/r,width:f/a,height:u/r});break;default:o=(h,c,u,f)=>({x:(h-s)/r,y:(c-i)/a,width:u/r,height:f/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const u=e.getRangeAt(h);if(!u.collapsed)for(const{x:f,y:m,width:A,height:y}of u.getClientRects())A===0||y===0||l.push(o(f,m,A,y))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,So)||p(this,So,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,So))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,So))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,xs).getRawValue(e);s&&(n(this,Xt)===X.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,jn))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,jn).delete(t))}addMissingCanvas(t,e){(n(this,jn)||p(this,jn,new Map)).set(t,e)}};wo=new WeakMap,ts=new WeakMap,vo=new WeakMap,Bt=new WeakMap,Qt=new WeakMap,Eo=new WeakMap,xs=new WeakMap,So=new WeakMap,Ts=new WeakMap,xe=new WeakMap,In=new WeakMap,Fn=new WeakMap,_o=new WeakMap,Nn=new WeakMap,li=new WeakMap,Ps=new WeakMap,Nr=new WeakMap,Fh=new WeakMap,Nh=new WeakMap,Co=new WeakMap,Oh=new WeakMap,hi=new WeakMap,On=new WeakMap,xo=new WeakMap,Bn=new WeakMap,ci=new WeakMap,Eu=new WeakMap,Hn=new WeakMap,To=new WeakMap,Bh=new WeakMap,Un=new WeakMap,Or=new WeakMap,Po=new WeakMap,jn=new WeakMap,Hh=new WeakMap,Xt=new WeakMap,ft=new WeakMap,ji=new WeakMap,$n=new WeakMap,zn=new WeakMap,Uh=new WeakMap,Ro=new WeakMap,jh=new WeakMap,Gn=new WeakMap,di=new WeakMap,$i=new WeakMap,$h=new WeakMap,zh=new WeakMap,Rs=new WeakMap,L=new WeakSet,kd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},gf=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Qt).values())if(s.hasTextLayer(t))return s;return null},rm=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,L,kd).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,ci)||p(this,ci,new $y(this)),n(this,ci).show(s,i,this.direction==="ltr"))},am=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,ji)&&((r=n(this,ci))==null||r.hide(),p(this,ji,null),b(this,L,Le).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,ji))return;const i=b(this,L,kd).call(this,t).closest(".textLayer");if(!i){n(this,ji)&&((a=n(this,ci))==null||a.hide(),p(this,ji,null),b(this,L,Le).call(this,{hasSelectedText:!1}));return}if((o=n(this,ci))==null||o.hide(),p(this,ji,e),b(this,L,Le).call(this,{hasSelectedText:!0}),!(n(this,Xt)!==X.HIGHLIGHT&&n(this,Xt)!==X.NONE)&&(n(this,Xt)===X.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Bn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Xt)===X.HIGHLIGHT?b(this,L,gf).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,To)){const h=new AbortController,c=this.combinedSignal(h),u=f=>{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,L,eh).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("blur",u,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,L,eh).call(this,"main_toolbar")}},eh=function(t=""){n(this,Xt)===X.HIGHLIGHT?this.highlightSelection(t):n(this,Fh)&&b(this,L,rm).call(this)},om=function(){document.addEventListener("selectionchange",b(this,L,am).bind(this),{signal:this._signal})},lm=function(){if(n(this,On))return;p(this,On,new AbortController);const t=this.combinedSignal(n(this,On));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},hm=function(){var t;(t=n(this,On))==null||t.abort(),p(this,On,null)},mf=function(){if(n(this,Un))return;p(this,Un,new AbortController);const t=this.combinedSignal(n(this,Un));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},cm=function(){var t;(t=n(this,Un))==null||t.abort(),p(this,Un,null)},bf=function(){if(n(this,In))return;p(this,In,new AbortController);const t=this.combinedSignal(n(this,In));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})},yf=function(){var t;(t=n(this,In))==null||t.abort(),p(this,In,null)},dm=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Le=function(t){Object.entries(t).some(([s,i])=>n(this,jh)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n(this,jh),t)}),n(this,Xt)===X.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,L,Ni).call(this,[[st.HIGHLIGHT_FREE,!0]]))},Ni=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},um=async function(){if(!n(this,Hn)){p(this,Hn,!0);const t=[];for(const e of n(this,Qt).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,Bt).values())e.enable()}},fm=function(){if(this.unselectAll(),n(this,Hn)){p(this,Hn,!1);for(const t of n(this,Qt).values())t.disable();for(const t of n(this,Bt).values())t.disable()}},Af=function(t){const e=n(this,Qt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},pm=function(){let t=null;for(t of n(this,ft));return t},sh=function(){if(n(this,Bt).size===0)return!0;if(n(this,Bt).size===1)for(const t of n(this,Bt).values())return t.isEmpty();return!1},wf=function(t){for(const e of n(this,ft))e.unselect();n(this,ft).clear();for(const e of t)e.isEmpty()||(n(this,ft).add(e),e.select());b(this,L,Le).call(this,{hasSelectedEditor:this.hasSelection})},k(lo,"TRANSLATE_SMALL",1),k(lo,"TRANSLATE_BIG",10);let Cr=lo;var ie,ui,js,ko,fi,es,Do,pi,ze,zi,Br,gi,Vn,ti,ih,Dd;const Ie=class Ie{constructor(t){g(this,ti);g(this,ie,null);g(this,ui,!1);g(this,js,null);g(this,ko,null);g(this,fi,null);g(this,es,null);g(this,Do,!1);g(this,pi,null);g(this,ze,null);g(this,zi,null);g(this,Br,null);g(this,gi,!1);p(this,ze,t),p(this,gi,t._uiManager.useNewAltTextFlow),n(Ie,Vn)||p(Ie,Vn,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){Ie._l10n??(Ie._l10n=t)}async render(){const t=p(this,js,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,ko,document.createElement("span"));t.append(e),n(this,gi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(Ie,Vn).missing),e.setAttribute("data-l10n-id",n(Ie,Vn)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,ze)._uiManager._signal;t.addEventListener("contextmenu",vs,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,ze)._uiManager.editAltText(n(this,ze)),n(this,gi)&&n(this,ze)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ti,ih)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Do,!0),i(r))},{signal:s}),await b(this,ti,Dd).call(this),t}finish(){n(this,js)&&(n(this,js).focus({focusVisible:n(this,Do)}),p(this,Do,!1))}isEmpty(){return n(this,gi)?n(this,ie)===null:!n(this,ie)&&!n(this,ui)}hasData(){return n(this,gi)?n(this,ie)!==null||!!n(this,zi):this.isEmpty()}get guessedText(){return n(this,zi)}async setGuessedText(t){n(this,ie)===null&&(p(this,zi,t),p(this,Br,await Ie._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,ti,Dd).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,gi)||n(this,ie)){(e=n(this,pi))==null||e.remove(),p(this,pi,null);return}if(!n(this,pi)){const s=p(this,pi,document.createElement("div"));s.className="noAltTextBadge",n(this,ze).div.append(s)}n(this,pi).classList.toggle("hidden",!t)}serialize(t){let e=n(this,ie);return!t&&n(this,zi)===e&&(e=n(this,Br)),{altText:e,decorative:n(this,ui),guessedText:n(this,zi),textWithDisclaimer:n(this,Br)}}get data(){return{altText:n(this,ie),decorative:n(this,ui)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,zi,s),p(this,Br,i)),!(n(this,ie)===t&&n(this,ui)===e)&&(r||(p(this,ie,t),p(this,ui,e)),b(this,ti,Dd).call(this))}toggle(t=!1){n(this,js)&&(!t&&n(this,es)&&(clearTimeout(n(this,es)),p(this,es,null)),n(this,js).disabled=!t)}shown(){n(this,ze)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ti,ih)}})}destroy(){var t,e;(t=n(this,js))==null||t.remove(),p(this,js,null),p(this,ko,null),p(this,fi,null),(e=n(this,pi))==null||e.remove(),p(this,pi,null)}};ie=new WeakMap,ui=new WeakMap,js=new WeakMap,ko=new WeakMap,fi=new WeakMap,es=new WeakMap,Do=new WeakMap,pi=new WeakMap,ze=new WeakMap,zi=new WeakMap,Br=new WeakMap,gi=new WeakMap,Vn=new WeakMap,ti=new WeakSet,ih=function(){return n(this,ie)&&"added"||n(this,ie)===null&&this.guessedText&&"review"||"missing"},Dd=async function(){var i,r,a;const t=n(this,js);if(!t)return;if(n(this,gi)){if(t.classList.toggle("done",!!n(this,ie)),t.setAttribute("data-l10n-id",n(Ie,Vn)[n(this,ti,ih)]),(i=n(this,ko))==null||i.setAttribute("data-l10n-id",n(Ie,Vn)[`${n(this,ti,ih)}-label`]),!n(this,ie)){(r=n(this,fi))==null||r.remove();return}}else{if(!n(this,ie)&&!n(this,ui)){t.classList.remove("done"),(a=n(this,fi))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,fi);if(!e){p(this,fi,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,ze).id}`;const o=100,l=n(this,ze)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,es)),p(this,es,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,es,setTimeout(()=>{p(this,es,null),n(this,fi).classList.add("show"),n(this,ze)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,es)&&(clearTimeout(n(this,es)),p(this,es,null)),(h=n(this,fi))==null||h.classList.remove("show")},{signal:l})}n(this,ui)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,ie)),e.parentNode||t.append(e);const s=n(this,ze).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},g(Ie,Vn,null),k(Ie,"_l10n",null);let lu=Ie;var fe,ks,Hr,Ct,Gh,Ur,$s,jr,$r,zr,Vh,vf;class Ad{constructor(t){g(this,Vh);g(this,fe,null);g(this,ks,null);g(this,Hr,!1);g(this,Ct,null);g(this,Gh,null);g(this,Ur,null);g(this,$s,null);g(this,jr,null);g(this,$r,!1);g(this,zr,null);p(this,Ct,t)}renderForToolbar(){const t=p(this,ks,document.createElement("button"));return t.className="comment",b(this,Vh,vf).call(this,t,!1)}renderForStandalone(){const t=p(this,fe,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,Ct).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,Ct)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=n(this,Ct).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Vh,vf).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,fe)??n(this,ks))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,fe))return;const t=n(this,Ct).commentButtonColor;t&&(n(this,fe).style.backgroundColor=t),n(this,Ct)._uiManager.updatePopupColor(n(this,Ct))}get commentButtonWidth(){var t;return(((t=n(this,fe))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,Ct).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,zr))return n(this,zr);if(!n(this,fe))return null;const{x:t,y:e,height:s}=n(this,fe).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Ct).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){p(this,zr,t)}hasDefaultPopupPosition(){return n(this,zr)===null}removeStandaloneCommentButton(){var t;(t=n(this,fe))==null||t.remove(),p(this,fe,null)}removeToolbarCommentButton(){var t;(t=n(this,ks))==null||t.remove(),p(this,ks,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,fe)&&(n(this,fe).classList.toggle("selected",t),n(this,fe).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,Ct).commentButtonPosition;const{width:c,height:u,x:f,y:m}=n(this,Ct);s=f+s*c,i=m+i*u}const r=n(this,Ct).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;n(this,Ct)._uiManager.editComment(n(this,Ct),a+s*l,o+i*h,{...t,parentDimensions:r})}finish(){n(this,ks)&&(n(this,ks).focus({focusVisible:n(this,Hr)}),p(this,Hr,!1))}isDeleted(){return n(this,$r)||n(this,$s)===""}isEmpty(){return n(this,$s)===null}hasBeenEdited(){return this.isDeleted()||n(this,$s)!==n(this,Gh)}serialize(){return this.data}get data(){return{text:n(this,$s),richText:n(this,Ur),date:n(this,jr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,$s)&&p(this,Ur,null),t===null){p(this,$s,""),p(this,$r,!0);return}p(this,$s,t),p(this,jr,new Date),p(this,$r,!1)}setInitialText(t,e=null){p(this,Gh,t),this.data=t,p(this,jr,null),p(this,Ur,e)}shown(){}destroy(){var t,e;(t=n(this,ks))==null||t.remove(),p(this,ks,null),(e=n(this,fe))==null||e.remove(),p(this,fe,null),p(this,$s,""),p(this,Ur,null),p(this,jr,null),p(this,Ct,null),p(this,Hr,!1),p(this,$r,!1)}}fe=new WeakMap,ks=new WeakMap,Hr=new WeakMap,Ct=new WeakMap,Gh=new WeakMap,Ur=new WeakMap,$s=new WeakMap,jr=new WeakMap,$r=new WeakMap,zr=new WeakMap,Vh=new WeakSet,vf=function(t,e){if(!n(this,Ct)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[n(this,Ct)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const s=n(this,Ct)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",vs,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,Ct)._focusEventsAllowed=!1,Nt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,Ct)._focusEventsAllowed=!0,Nt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,ks)?this.edit():n(this,Ct).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Hr,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,Ct).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,Ct).toggleComment(!1,!1)},{signal:s}),t};var Mo,Gr,Wh,Xh,qh,Yh,Kh,Gi,Vr,Vi,Wr,Wi,Tr,gm,mm,bm;const Zp=class Zp{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){g(this,Tr);g(this,Mo);g(this,Gr,!1);g(this,Wh,null);g(this,Xh);g(this,qh);g(this,Yh);g(this,Kh);g(this,Gi,null);g(this,Vr);g(this,Vi,null);g(this,Wr);g(this,Wi,null);p(this,Mo,t),p(this,Wh,s),p(this,Xh,e),p(this,qh,i),p(this,Yh,r),p(this,Kh,a),p(this,Wr,new AbortController),p(this,Vr,AbortSignal.any([o,n(this,Wr).signal])),t.addEventListener("touchstart",b(this,Tr,gm).bind(this),{passive:!1,signal:n(this,Vr)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ei.pixelRatio}destroy(){var t,e;(t=n(this,Wr))==null||t.abort(),p(this,Wr,null),(e=n(this,Gi))==null||e.abort(),p(this,Gi,null)}};Mo=new WeakMap,Gr=new WeakMap,Wh=new WeakMap,Xh=new WeakMap,qh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,Gi=new WeakMap,Vr=new WeakMap,Vi=new WeakMap,Wr=new WeakMap,Wi=new WeakMap,Tr=new WeakSet,gm=function(t){var i,r,a;if((i=n(this,Xh))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,Gi))return;const o=p(this,Gi,new AbortController),l=AbortSignal.any([n(this,Vr),o.signal]),h=n(this,Mo),c={capture:!0,signal:l,passive:!1},u=f=>{var m;f.pointerType==="touch"&&((m=n(this,Gi))==null||m.abort(),p(this,Gi,null))};h.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Nt(f),u(f))},c),h.addEventListener("pointerup",u,c),h.addEventListener("pointercancel",u,c);return}if(!n(this,Wi)){p(this,Wi,new AbortController);const o=AbortSignal.any([n(this,Vr),n(this,Wi).signal]),l=n(this,Mo),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,Tr,mm).bind(this),h);const c=b(this,Tr,bm).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Nt,h),l.addEventListener("pointermove",Nt,h),l.addEventListener("pointercancel",Nt,h),l.addEventListener("pointerup",Nt,h),(r=n(this,qh))==null||r.call(this)}if(Nt(t),t.touches.length!==2||(a=n(this,Wh))!=null&&a.call(this)){p(this,Vi,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,Vi,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},mm=function(t){var _;if(!n(this,Vi)||t.touches.length!==2)return;Nt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,Vi),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:f}=l,m=u-h,A=f-c,y=a-i,v=o-r,w=Math.hypot(y,v)||1,S=Math.hypot(m,A)||1;if(!n(this,Gr)&&Math.abs(S-w)<=Zp.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,Gr)){p(this,Gr,!0);return}const E=[(i+a)/2,(r+o)/2];(_=n(this,Yh))==null||_.call(this,E,S,w)},bm=function(t){var e;t.touches.length>=2||(n(this,Wi)&&(n(this,Wi).abort(),p(this,Wi,null),(e=n(this,Kh))==null||e.call(this)),n(this,Vi)&&(Nt(t),p(this,Vi,null),p(this,Gr,!1)))};let Ch=Zp;var Xr,zs,Dt,vt,Xi,Lo,Wn,Jh,pe,qr,qi,mi,Xn,Qh,Yr,ss,Zh,Kr,Yi,bi,Io,Fo,Ds,Jr,tc,Su,V,Ef,ec,Sf,Md,ym,Am,_f,Ld,Cf,wm,vm,Em,xf,Sm,Tf,_m,Cm,xm,Pf,nh;const Y=class Y{constructor(t){g(this,V);g(this,Xr,null);g(this,zs,null);g(this,Dt,null);g(this,vt,null);g(this,Xi,null);g(this,Lo,!1);g(this,Wn,null);g(this,Jh,"");g(this,pe,null);g(this,qr,null);g(this,qi,null);g(this,mi,null);g(this,Xn,null);g(this,Qh,"");g(this,Yr,!1);g(this,ss,null);g(this,Zh,!1);g(this,Kr,!1);g(this,Yi,!1);g(this,bi,null);g(this,Io,0);g(this,Fo,0);g(this,Ds,null);g(this,Jr,null);k(this,"isSelected",!1);k(this,"_isCopy",!1);k(this,"_editToolbar",null);k(this,"_initialOptions",Object.create(null));k(this,"_initialData",null);k(this,"_isVisible",!0);k(this,"_uiManager",null);k(this,"_focusEventsAllowed",!0);g(this,tc,!1);g(this,Su,Y._zIndex++);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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=Y.prototype._resizeWithKeyboard,e=Cr.TRANSLATE_SMALL,s=Cr.TRANSLATE_BIG;return J(this,"_resizerKeyboardManager",new fd([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],Y.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return J(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Vy({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(Y._l10n??(Y._l10n=t),Y._l10nResizer||(Y._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"})),Y._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);Y._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,tc)}set _isDraggable(t){var e;p(this,tc,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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=n(this,Su)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,V,nh).call(this),(e=n(this,mi))==null||e.remove(),p(this,mi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,Yr)?p(this,Yr,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){b(this,V,Ef).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,ss)||p(this,ss,[this.x,this.y,this.width,this.height]),b(this,V,Ef).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,ss)||p(this,ss,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:u,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,ss)&&(n(this,ss)[0]!==this.x||n(this,ss)[1]!==this.y)}get _hasBeenResized(){return!!n(this,ss)&&(n(this,ss)[2]!==this.width||n(this,ss)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=Y,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=De(r,0,s-o),a=De(a,0,i-l);break;case 90:r=De(r,0,s-l),a=De(a,o,i);break;case 180:r=De(r,o,s),a=De(a,l,i);break;case 270:r=De(r,l,s),a=De(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[h,c]=this.getBaseTranslation();r+=h,a+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=Y,ec,Sf).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=Y,ec,Sf).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,Dt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,Kr))return this._editToolbar;this._editToolbar=new df(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=n(this,Dt))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return n(this,Dt)||(lu.initialize(Y._l10n),p(this,Dt,new lu(this)),n(this,Xr)&&(n(this,Dt).data=n(this,Xr),p(this,Xr,null))),n(this,Dt)}get altTextData(){var t;return(t=n(this,Dt))==null?void 0:t.data}set altTextData(t){n(this,Dt)&&(n(this,Dt).data=t)}get guessedAltText(){var t;return(t=n(this,Dt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,Dt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,Dt))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,Dt)&&!n(this,Dt).isEmpty()}hasAltTextData(){var t;return((t=n(this,Dt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,vt))==null||t.focusButton()}addCommentButton(){return n(this,vt)||p(this,vt,new Ad(this))}addStandaloneCommentButton(){if(n(this,Xi)){this._uiManager.isEditingMode()&&n(this,Xi).classList.remove("hidden");return}this.hasComment&&(p(this,Xi,n(this,vt).renderForStandalone()),this.div.append(n(this,Xi)))}removeStandaloneCommentButton(){n(this,vt).removeStandaloneCommentButton(),p(this,Xi,null)}hideStandaloneCommentButton(){var t;(t=n(this,Xi))==null||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,vt);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,vt)||p(this,vt,new Ad(this)),n(this,vt).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(n(this,vt)||p(this,vt,new Ad(this)),n(this,vt).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=n(this,vt))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,vt))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,vt)&&!n(this,vt).isEmpty()&&!n(this,vt).isDeleted()}async editComment(t){n(this,vt)||p(this,vt,new Ad(this)),n(this,vt).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,vt).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,h=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){n(this,vt).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=n(this,Lo)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,V,Tf).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),im(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,Jr)||p(this,Jr,new Ch({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,V,wm).bind(this),onPinching:b(this,V,vm).bind(this),onPinchEnd:b(this,V,Em).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=ce.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,Yr,!0),this._isDraggable){b(this,V,Sm).call(this,t);return}b(this,V,xf).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,bi)&&clearTimeout(n(this,bi)),p(this,bi,setTimeout(()=>{var t;p(this,bi,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,c=e/i,u=this.x*r,f=this.y*a,m=this.width*r,A=this.height*a;switch(s){case 0:return[u+h+o,a-f-c-A+l,u+h+m+o,a-f-c+l];case 90:return[u+c+o,a-f+h+l,u+c+A+o,a-f+h+m+l];case 180:return[u-h-m+o,a-f+c+l,u-h+o,a-f+c+A+l];case 270:return[u-c-A+o,a-f-h-m+l,u-c+o,a-f-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Y._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,vt))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,Kr,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,Kr,!1),!0):!1}isInEditMode(){return n(this,Kr)}shouldGetKeyboardEvents(){return n(this,Yi)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){b(this,V,Tf).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,p(i,Xr,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=h/r,i.height=c/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=n(this,Xn))==null||t.abort(),p(this,Xn,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),n(this,bi)&&(clearTimeout(n(this,bi)),p(this,bi,null)),b(this,V,nh).call(this),this.removeEditToolbar(),n(this,Ds)){for(const s of n(this,Ds).values())clearTimeout(s);p(this,Ds,null)}this.parent=null,(e=n(this,Jr))==null||e.destroy(),p(this,Jr,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,V,ym).call(this),n(this,pe).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,a]=this.getPDFRect();return[Y._round(s+(r-s)*t),Y._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,vt).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,vt).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,vt).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,vt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){n(this,vt).setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,qi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,pe).children;if(!n(this,zs)){p(this,zs,Array.from(e));const a=b(this,V,_m).bind(this),o=b(this,V,Cm).bind(this),l=this._uiManager._signal;for(const h of n(this,zs)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",b(this,V,xm).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",Y._l10nResizer[c])}}const s=n(this,zs)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,zs).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,pe).append(n(this,pe).firstChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,pe).firstChild.before(n(this,pe).lastChild);let a=0;for(const o of e){const h=n(this,zs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",Y._l10nResizer[h])}}b(this,V,Pf).call(this,0),p(this,Yi,!0),n(this,pe).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,Yi)&&b(this,V,Cf).call(this,n(this,Qh),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,V,nh).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,Dt))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,i,r;this.isSelected&&(this.isSelected=!1,(t=n(this,pe))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,Dt))==null||r.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,Zh)}set isEditing(t){p(this,Zh,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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){n(this,Ds)||p(this,Ds,new Map);const{action:s}=t;let i=n(this,Ds).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Ds).delete(s),n(this,Ds).size===0&&p(this,Ds,null)},Y._telemetryTimeout),n(this,Ds).set(s,i);return}t.type||(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),p(this,Lo,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Lo,!0)}updateFakeAnnotationElement(t){if(!n(this,mi)&&!this.deleted){p(this,mi,t.addFakeAnnotation(this));return}if(this.deleted){n(this,mi).remove(),p(this,mi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,mi).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Xr=new WeakMap,zs=new WeakMap,Dt=new WeakMap,vt=new WeakMap,Xi=new WeakMap,Lo=new WeakMap,Wn=new WeakMap,Jh=new WeakMap,pe=new WeakMap,qr=new WeakMap,qi=new WeakMap,mi=new WeakMap,Xn=new WeakMap,Qh=new WeakMap,Yr=new WeakMap,ss=new WeakMap,Zh=new WeakMap,Kr=new WeakMap,Yi=new WeakMap,bi=new WeakMap,Io=new WeakMap,Fo=new WeakMap,Ds=new WeakMap,Jr=new WeakMap,tc=new WeakMap,Su=new WeakMap,V=new WeakSet,Ef=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},ec=new WeakSet,Sf=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},Md=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},ym=function(){if(n(this,pe))return;p(this,pe,document.createElement("div")),n(this,pe).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");n(this,pe).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,V,Am).bind(this,s),{signal:e}),i.addEventListener("contextmenu",vs,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,pe))},Am=function(t,e){var c;e.preventDefault();const{isMac:s}=ce.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,Dt))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,qr,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,V,Cf).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Nt,{passive:!1,signal:a}),window.addEventListener("contextmenu",vs,{signal:a}),p(this,qi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var u;r.abort(),this.parent.togglePointerEvents(!0),(u=n(this,Dt))==null||u.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,V,Ld).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},_f=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Ld=function(){if(!n(this,qi))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,qi);p(this,qi,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:b(this,V,_f).bind(this,r,a,o,l),undo:b(this,V,_f).bind(this,t,e,s,i),mustExec:!0})},Cf=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=Y.MIN_SIZE/s,c=Y.MIN_SIZE/i,u=b(this,V,Md).call(this,this.rotation),f=(O,F)=>[u[0]*O+u[2]*F,u[1]*O+u[3]*F],m=b(this,V,Md).call(this,360-this.rotation),A=(O,F)=>[m[0]*O+m[2]*F,m[1]*O+m[3]*F];let y,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,y=(O,F)=>[0,0],v=(O,F)=>[O,F];break;case"topMiddle":y=(O,F)=>[O/2,0],v=(O,F)=>[O/2,F];break;case"topRight":w=!0,y=(O,F)=>[O,0],v=(O,F)=>[0,F];break;case"middleRight":S=!0,y=(O,F)=>[O,F/2],v=(O,F)=>[0,F/2];break;case"bottomRight":w=!0,y=(O,F)=>[O,F],v=(O,F)=>[0,0];break;case"bottomMiddle":y=(O,F)=>[O/2,F],v=(O,F)=>[O/2,0];break;case"bottomLeft":w=!0,y=(O,F)=>[0,F],v=(O,F)=>[O,0];break;case"middleLeft":S=!0,y=(O,F)=>[0,F/2],v=(O,F)=>[O,F/2];break}const E=y(o,l),_=v(o,l);let C=f(..._);const x=Y._round(r+C[0]),T=Y._round(a+C[1]);let P=1,R=1,D,M;if(e.fromKeyboard)({deltaX:D,deltaY:M}=e);else{const{screenX:O,screenY:F}=e,[tt,it]=n(this,qr);[D,M]=this.screenToPageTranslation(O-tt,F-it),n(this,qr)[0]=O,n(this,qr)[1]=F}if([D,M]=A(D/s,M/i),w){const O=Math.hypot(o,l);P=R=Math.max(Math.min(Math.hypot(_[0]-E[0]-D,_[1]-E[1]-M)/O,1/o,1/l),h/o,c/l)}else S?P=De(Math.abs(_[0]-E[0]-D),h,1)/o:R=De(Math.abs(_[1]-E[1]-M),c,1)/l;const I=Y._round(o*P),G=Y._round(l*R);C=f(...v(I,G));const N=x-C[0],W=T-C[1];n(this,ss)||p(this,ss,[this.x,this.y,this.width,this.height]),this.width=I,this.height=G,this.x=N,this.y=W,this.setDims(),this.fixAndSetPosition(),this._onResizing()},wm=function(){var t;p(this,qi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,Dt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},vm=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,V,Md).call(this,this.rotation),o=(x,T)=>[a[0]*x+a[2]*T,a[1]*x+a[3]*T],[l,h]=this.parentDimensions,c=this.x,u=this.y,f=this.width,m=this.height,A=Y.MIN_SIZE/l,y=Y.MIN_SIZE/h;r=Math.max(Math.min(r,1/f,1/m),A/f,y/m);const v=Y._round(f*r),w=Y._round(m*r);if(v===f&&w===m)return;n(this,ss)||p(this,ss,[c,u,f,m]);const S=o(f/2,m/2),E=Y._round(c+S[0]),_=Y._round(u+S[1]),C=o(v/2,w/2);this.x=E-C[0],this.y=_-C[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Em=function(){var t;(t=n(this,Dt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,V,Ld).call(this)},xf=function(t){const{isMac:e}=ce.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Sm=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=h=>{i.abort(),p(this,Wn,null),p(this,Yr,!1),this._uiManager.endDragSession()||b(this,V,xf).call(this,h),s&&this._onStopDragging()};e&&(p(this,Io,t.clientX),p(this,Fo,t.clientY),p(this,Wn,t.pointerId),p(this,Jh,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:u,pointerId:f}=h;if(f!==n(this,Wn)){Nt(h);return}const[m,A]=this.screenToPageTranslation(c-n(this,Io),u-n(this,Fo));p(this,Io,c),p(this,Fo,u),this._uiManager.dragSelectedEditors(m,A)},a),window.addEventListener("touchmove",Nt,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,Jh)&&(n(this,Jr)||h.isPrimary)&&o(h),Nt(h)},a));const l=h=>{if(!n(this,Wn)||n(this,Wn)===h.pointerId){o(h);return}Nt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Tf=function(){if(n(this,Xn)||!this.div)return;p(this,Xn,new AbortController);const t=this._uiManager.combinedSignal(n(this,Xn));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},_m=function(t){Y._resizerKeyboardManager.exec(this,t)},Cm=function(t){var e;n(this,Yi)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,pe)&&b(this,V,nh).call(this)},xm=function(t){p(this,Qh,n(this,Yi)?t:"")},Pf=function(t){if(n(this,zs))for(const e of n(this,zs))e.tabIndex=t},nh=function(){p(this,Yi,!1),b(this,V,Pf).call(this,-1),b(this,V,Ld).call(this)},g(Y,ec),k(Y,"_l10n",null),k(Y,"_l10nResizer",null),k(Y,"_borderLineWidth",-1),k(Y,"_colorManager",new pf),k(Y,"_zIndex",1),k(Y,"_telemetryTimeout",1e3);let xt=Y;class Vy extends xt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const dg=3285377520,Es=4294901760,ri=65535;class Tm{constructor(t){this.h1=t?t&4294967295:dg,this.h2=t?t&4294967295:dg}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,v=t.length;y<v;y++){const w=t.charCodeAt(y);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,c=this.h2;const u=3432918353,f=461845907,m=u&ri,A=f&ri;for(let y=0;y<i;y++)y&1?(o=a[y],o=o*u&Es|o*m&ri,o=o<<15|o>>>17,o=o*f&Es|o*A&ri,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*u&Es|l*m&ri,l=l<<15|l>>>17,l=l*f&Es|l*A&ri,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*u&Es|o*m&ri,o=o<<15|o>>>17,o=o*f&Es|o*A&ri,i&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Es|t*36045&ri,e=e*4283543511&Es|((e<<16|t>>>16)*2950163797&Es)>>>16,t^=e>>>1,t=t*444984403&Es|t*60499&ri,e=e*3301882366&Es|((e<<16|t>>>16)*3120437893&Es)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Rf=Object.freeze({map:null,hash:"",transfer:void 0});var Qr,Zr,Ki,ge,_u,Pm;class jp{constructor(){g(this,_u);g(this,Qr,!1);g(this,Zr,null);g(this,Ki,null);g(this,ge,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=n(this,ge).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,ge).get(t)}remove(t){const e=n(this,ge).get(t);if(e!==void 0&&(e instanceof xt&&n(this,Ki).delete(e.annotationElementId),n(this,ge).delete(t),n(this,ge).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const s of n(this,ge).values())if(s instanceof xt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=n(this,ge).get(t);let i=!1;if(s!==void 0)for(const[r,a]of Object.entries(e))s[r]!==a&&(i=!0,s[r]=a);else i=!0,n(this,ge).set(t,e);i&&b(this,_u,Pm).call(this),e instanceof xt&&((n(this,Ki)||p(this,Ki,new Map)).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return n(this,ge).has(t)}get size(){return n(this,ge).size}resetModified(){n(this,Qr)&&(p(this,Qr,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Rm(this)}get serializable(){if(n(this,ge).size===0)return Rf;const t=new Map,e=new Tm,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,ge)){const l=o instanceof xt?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Rf}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,ge).values()){if(!(r instanceof xt)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.has(o)||e.set(o,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[h,c]of Object.entries(a)){if(h==="type")continue;let u=l.get(h);u||(u=new Map,l.set(h,u));const f=u.get(c)??0;u.set(c,f+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){p(this,Zr,null)}updateEditor(t,e){var i;const s=(i=n(this,Ki))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,Ki))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,Zr))return n(this,Zr);const t=[];if(n(this,Ki))for(const e of n(this,Ki).values())e.serialize()&&t.push(e.annotationElementId);return p(this,Zr,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return n(this,ge).entries()}}Qr=new WeakMap,Zr=new WeakMap,Ki=new WeakMap,ge=new WeakMap,_u=new WeakSet,Pm=function(){n(this,Qr)||(p(this,Qr,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var sc;class Rm extends jp{constructor(e){super();g(this,sc);const{map:s,hash:i,transfer:r}=e.serializable,a=structuredClone(s,r?{transfer:r}:null);p(this,sc,{map:a,hash:i,transfer:r})}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,sc)}get modifiedIds(){return J(this,"modifiedIds",{ids:new Set,hash:""})}}sc=new WeakMap;var No;class Wy{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){g(this,No,new Set);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));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),n(this,No).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,No).has(t.loadedName))){if(nt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,No).add(i),s==null||s(t)}catch{q(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}_t("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw q(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return J(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return J(this,"isSyncFontLoadingSupported",Be||ce.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(nt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return J(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(_,C){return _.charCodeAt(C)<<24|_.charCodeAt(C+1)<<16|_.charCodeAt(C+2)<<8|_.charCodeAt(C+3)&255}function i(_,C,x,T){const P=_.substring(0,C),R=_.substring(C+x);return P+T+R}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function c(_,C){if(++h>30){q("Load test font never loaded."),C();return}if(l.font="30px "+_,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(c.bind(null,_,C))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const A=16,y=1482184792;let v=s(f,A);for(r=0,a=u.length-3;r<a;r+=4)v=v-y+s(u,r)|0;r<u.length&&(v=v-y+s(u+"XXX",r)|0),f=i(f,A,4,Ly(v));const w=`url(data:font/opentype;base64,${btoa(f)});`,S=`@font-face {font-family:"${u}";src:${w}}`;this.insertRule(S);const E=this._document.createElement("div");E.style.visibility="hidden",E.style.width=E.style.height="10px",E.style.position="absolute",E.style.top=E.style.left="0px";for(const _ of[t.loadedName,u]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=_,E.append(C)}this._document.body.append(E),c(u,()=>{E.remove(),e.complete()})}}No=new WeakMap;var gt;class Xy{constructor(t,e=null,s,i){g(this,gt);this.compiledGlyphs=Object.create(null),p(this,gt,t),this._inspectFont=e,s&&Object.assign(this,s),i&&(this.charProcOperatorList=i)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Vg(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){q(`getPathGenerator - ignoring character: "${a}".`)}const r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,gt).black}get bold(){return n(this,gt).bold}get disableFontFace(){return n(this,gt).disableFontFace??!1}get fontExtraProperties(){return n(this,gt).fontExtraProperties??!1}get isInvalidPDFjsFont(){return n(this,gt).isInvalidPDFjsFont}get isType3Font(){return n(this,gt).isType3Font}get italic(){return n(this,gt).italic}get missingFile(){return n(this,gt).missingFile}get remeasure(){return n(this,gt).remeasure}get vertical(){return n(this,gt).vertical}get ascent(){return n(this,gt).ascent}get defaultWidth(){return n(this,gt).defaultWidth}get descent(){return n(this,gt).descent}get bbox(){return n(this,gt).bbox}get fontMatrix(){return n(this,gt).fontMatrix}get fallbackName(){return n(this,gt).fallbackName}get loadedName(){return n(this,gt).loadedName}get mimetype(){return n(this,gt).mimetype}get name(){return n(this,gt).name}get data(){return n(this,gt).data}clearData(){n(this,gt).clearData()}get cssFontInfo(){return n(this,gt).cssFontInfo}get systemFontInfo(){return n(this,gt).systemFontInfo}get defaultVMetrics(){return n(this,gt).defaultVMetrics}}gt=new WeakMap;function qy(d){if(d instanceof URL)return d.href;if(typeof d=="string"){if(Be)return d;const t=URL.parse(d,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Yy(d){if(Be&&typeof Buffer<"u"&&d instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength)return d;if(typeof d=="string")return cd(d);if(d instanceof ArrayBuffer||ArrayBuffer.isView(d)||typeof d=="object"&&!isNaN(d==null?void 0:d.length))return new Uint8Array(d);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function wd(d){if(typeof d!="string")return null;if(d.endsWith("/"))return d;throw new Error(`Invalid factory url: "${d}" must include trailing slash.`)}const kf=d=>typeof d=="object"&&Number.isInteger(d==null?void 0:d.num)&&d.num>=0&&Number.isInteger(d==null?void 0:d.gen)&&d.gen>=0,Ky=d=>typeof d=="object"&&typeof(d==null?void 0:d.name)=="string",km=Oy.bind(null,kf,Ky);var Ji,Cu;class Jy{constructor(){g(this,Ji,new Map);g(this,Cu,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,Cu).then(()=>{for(const[i]of n(this,Ji))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){q("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,Ji).set(e,i)}removeEventListener(t,e){const s=n(this,Ji).get(e);s==null||s(),n(this,Ji).delete(e)}terminate(){for(const[,t]of n(this,Ji))t==null||t();n(this,Ji).clear()}}Ji=new WeakMap,Cu=new WeakMap;const vd={DATA:1,ERROR:2},Wt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ug(){}function je(d){if(d instanceof Sn||d instanceof au||d instanceof ng||d instanceof Eh||d instanceof Ku)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||_t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new Sn(d.message);case"InvalidPDFException":return new au(d.message);case"PasswordException":return new ng(d.message,d.code);case"ResponseException":return new Eh(d.message,d.status,d.missing);case"UnknownErrorException":return new Ku(d.message,d.details)}return new Ku(d.message,d.toString())}var Oo,Ns,Dm,Mm,Lm,Id;class rh{constructor(t,e,s){g(this,Ns);g(this,Oo,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,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),s.addEventListener("message",b(this,Ns,Dm).bind(this),{signal:n(this,Oo).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:Wt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{nt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Wt.CANCEL,streamId:r,reason:je(h)}),c.promise}},s)}destroy(){var t;(t=n(this,Oo))==null||t.abort(),p(this,Oo,null)}}Oo=new WeakMap,Ns=new WeakSet,Dm=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Ns,Lm).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===vd.DATA)i.resolve(t.data);else if(t.callback===vd.ERROR)i.reject(je(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:vd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:vd.ERROR,callbackId:t.callbackId,reason:je(a)})});return}if(t.streamId){b(this,Ns,Mm).call(this,t);return}e(t.data)},Mm=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=c,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:Wt.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Wt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){nt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Wt.ERROR,streamId:e,reason:je(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.START_COMPLETE,streamId:e,reason:je(h)})})},Lm=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Wt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(je(t.reason));break;case Wt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(je(t.reason));break;case Wt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||ug).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,reason:je(h)})});break;case Wt.ENQUEUE:if(nt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Wt.CLOSE:if(nt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Ns,Id).call(this,a,e);break;case Wt.ERROR:nt(a,"error should have stream controller"),a.controller.error(je(t.reason)),b(this,Ns,Id).call(this,a,e);break;case Wt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(je(t.reason)),b(this,Ns,Id).call(this,a,e);break;case Wt.CANCEL:if(!o)break;const l=je(t.reason);Promise.try(o.onCancel||ug,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.CANCEL_COMPLETE,streamId:e,reason:je(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Id=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var ic;class Im{constructor({enableHWA:t=!1}){g(this,ic,!1);p(this,ic,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,ic)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){_t("Abstract method `_createCanvas` called.")}}ic=new WeakMap;class Qy extends Im{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Fm{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){_t("Abstract method `_fetch` called.")}}class fg extends Fm{async _fetch(t){const e=await Vl(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):cd(e)}}class Nm{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}destroy(t=!1){}}var ta,Bo,Qi,Zi,Te,ea,sa,B,_e,ah,eo,Fd,so,Om,Df,io,oh,lh,Mf,hh;class Zy extends Nm{constructor({docId:e,ownerDocument:s=globalThis.document}){super();g(this,B);g(this,ta);g(this,Bo);g(this,Qi);g(this,Zi);g(this,Te);g(this,ea);g(this,sa,0);p(this,Zi,e),p(this,Te,s)}addFilter(e){if(!e)return"none";let s=n(this,B,_e).get(e);if(s)return s;const[i,r,a]=b(this,B,Fd).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,B,_e).get(o),s)return n(this,B,_e).set(e,s),s;const l=`g_${n(this,Zi)}_transfer_map_${Kt(this,sa)._++}`,h=b(this,B,so).call(this,l);n(this,B,_e).set(e,h),n(this,B,_e).set(o,h);const c=b(this,B,io).call(this,l);return b(this,B,lh).call(this,i,r,a,c),h}addHCMFilter(e,s){var A;const i=`${e}-${s}`,r="base";let a=n(this,B,ah).get(r);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,B,ah).set(r,a)),!e||!s))return a.url;const o=b(this,B,hh).call(this,e);e=H.makeHexColor(...o);const l=b(this,B,hh).call(this,s);if(s=H.makeHexColor(...l),n(this,B,eo).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let y=0;y<=255;y++){const v=y/255;h[y]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=h.join(","),u=`g_${n(this,Zi)}_hcm_filter`,f=a.filter=b(this,B,io).call(this,u);b(this,B,lh).call(this,c,c,c,f),b(this,B,Df).call(this,f);const m=(y,v)=>{const w=o[y]/255,S=l[y]/255,E=new Array(v+1);for(let _=0;_<=v;_++)E[_]=w+_/v*(S-w);return E.join(",")};return b(this,B,lh).call(this,m(0,5),m(1,5),m(2,5),f),a.url=b(this,B,so).call(this,u),a.url}addAlphaFilter(e){let s=n(this,B,_e).get(e);if(s)return s;const[i]=b(this,B,Fd).call(this,[e]),r=`alpha_${i}`;if(s=n(this,B,_e).get(r),s)return n(this,B,_e).set(e,s),s;const a=`g_${n(this,Zi)}_alpha_map_${Kt(this,sa)._++}`,o=b(this,B,so).call(this,a);n(this,B,_e).set(e,o),n(this,B,_e).set(r,o);const l=b(this,B,io).call(this,a);return b(this,B,Mf).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,B,_e).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,B,Fd).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,B,_e).get(r),s)return n(this,B,_e).set(e,s),s;const a=`g_${n(this,Zi)}_luminosity_map_${Kt(this,sa)._++}`,o=b(this,B,so).call(this,a);n(this,B,_e).set(e,o),n(this,B,_e).set(r,o);const l=b(this,B,io).call(this,a);return b(this,B,Om).call(this,l),e&&b(this,B,Mf).call(this,i,l),o}addHighlightHCMFilter(e,s,i,r,a){var S;const o=`${s}-${i}-${r}-${a}`;let l=n(this,B,ah).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,B,ah).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,B,hh).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[m,A]=[r,a].map(b(this,B,hh).bind(this));f<u&&([u,f,m,A]=[f,u,A,m]),n(this,B,eo).style.color="";const y=(E,_,C)=>{const x=new Array(256),T=(f-u)/C,P=E/255,R=(_-E)/(255*C);let D=0;for(let M=0;M<=C;M++){const I=Math.round(u+M*T),G=P+M*R;for(let N=D;N<=I;N++)x[N]=G;D=I+1}for(let M=D;M<256;M++)x[M]=x[D-1];return x.join(",")},v=`g_${n(this,Zi)}_hcm_${e}_filter`,w=l.filter=b(this,B,io).call(this,v);return b(this,B,Df).call(this,w),b(this,B,lh).call(this,y(m[0],A[0],5),y(m[1],A[1],5),y(m[2],A[2],5),w),l.url=b(this,B,so).call(this,v),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,ea))!=null&&s.size)||((i=n(this,Qi))==null||i.parentNode.parentNode.remove(),p(this,Qi,null),(r=n(this,Bo))==null||r.clear(),p(this,Bo,null),(a=n(this,ea))==null||a.clear(),p(this,ea,null),p(this,sa,0))}}ta=new WeakMap,Bo=new WeakMap,Qi=new WeakMap,Zi=new WeakMap,Te=new WeakMap,ea=new WeakMap,sa=new WeakMap,B=new WeakSet,_e=function(){return n(this,Bo)||p(this,Bo,new Map)},ah=function(){return n(this,ea)||p(this,ea,new Map)},eo=function(){if(!n(this,Qi)){const e=n(this,Te).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,Te).createElementNS(Fi,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Qi,n(this,Te).createElementNS(Fi,"defs")),e.append(i),i.append(n(this,Qi)),n(this,Te).body.append(e)}return n(this,Qi)},Fd=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let f=0;f<256;f++)c[f]=h[f]/255;const u=c.join(",");return[u,u,u]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=i[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},so=function(e){if(n(this,ta)===void 0){p(this,ta,"");const s=n(this,Te).URL;s!==n(this,Te).baseURI&&(ud(s)?q('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,ta,Np(s,"")))}return`url(${n(this,ta)}#${e})`},Om=function(e){const s=n(this,Te).createElementNS(Fi,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},Df=function(e){const s=n(this,Te).createElementNS(Fi,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},io=function(e){const s=n(this,Te).createElementNS(Fi,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,B,eo).append(s),s},oh=function(e,s,i){const r=n(this,Te).createElementNS(Fi,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},lh=function(e,s,i,r){const a=n(this,Te).createElementNS(Fi,"feComponentTransfer");r.append(a),b(this,B,oh).call(this,a,"feFuncR",e),b(this,B,oh).call(this,a,"feFuncG",s),b(this,B,oh).call(this,a,"feFuncB",i)},Mf=function(e,s){const i=n(this,Te).createElementNS(Fi,"feComponentTransfer");s.append(i),b(this,B,oh).call(this,i,"feFuncA",e)},hh=function(e){return n(this,B,eo).style.color=e,Wl(getComputedStyle(n(this,B,eo)).getPropertyValue("color"))};class Bm{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){_t("Abstract method `_fetch` called.")}}class pg extends Bm{async _fetch(t){const e=await Vl(t,"arraybuffer");return new Uint8Array(e)}}class Hm{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){_t("Abstract method `_fetch` called.")}}class gg extends Hm{async _fetch(t){const e=await Vl(t,"arraybuffer");return new Uint8Array(e)}}Be&&q("Please use the `legacy` build in Node.js environments.");async function $p(d){const e=await process.getBuiltinModule("fs").promises.readFile(d);return new Uint8Array(e)}class tA extends Nm{}class eA extends Im{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:qu&&qu.tagName.toUpperCase()==="SCRIPT"&&qu.src||new URL("index-miejqTjn.cjs",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class sA extends Fm{async _fetch(t){return $p(t)}}class iA extends Bm{async _fetch(t){return $p(t)}}class nA extends Hm{async _fetch(t){return $p(t)}}const Qa="__forcedDependency",{floor:mg,ceil:bg}=Math;function Ed(d,t,e,s,i,r){d[t*4+0]=Math.min(d[t*4+0],e),d[t*4+1]=Math.min(d[t*4+1],s),d[t*4+2]=Math.max(d[t*4+2],i),d[t*4+3]=Math.max(d[t*4+3],r)}const Lf=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var Ho,qn;class rA{constructor(t,e){g(this,Ho);g(this,qn);p(this,Ho,t),p(this,qn,e)}get length(){return n(this,Ho).length}isEmpty(t){return n(this,Ho)[t]===Lf}minX(t){return n(this,qn)[t*4+0]/256}minY(t){return n(this,qn)[t*4+1]/256}maxX(t){return(n(this,qn)[t*4+2]+1)/256}maxY(t){return(n(this,qn)[t*4+3]+1)/256}}Ho=new WeakMap,qn=new WeakMap;const Sd=(d,t)=>{if(!d)return;let e=d.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},d.set(t,e)),e};var Ge,Ve,ia,Gs,na,tn,pt,mt,en,We,nc,Uo,ra,aa,sn,Pe,yi,rc,If;class aA{constructor(t,e,s=!1){g(this,rc);g(this,Ge,{__proto__:null});g(this,Ve,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Qa]:[]});g(this,ia,new Map);g(this,Gs,[]);g(this,na,[]);g(this,tn,[[1,0,0,1,0,0]]);g(this,pt,[-1/0,-1/0,1/0,1/0]);g(this,mt,new Float64Array([1/0,1/0,-1/0,-1/0]));g(this,en,-1);g(this,We,new Set);g(this,nc,new Map);g(this,Uo,new Map);g(this,ra);g(this,aa);g(this,sn);g(this,Pe);g(this,yi);p(this,ra,t.width),p(this,aa,t.height),b(this,rc,If).call(this,e),s&&p(this,yi,new Map)}growOperationsCount(t){t>=n(this,Pe).length&&b(this,rc,If).call(this,t,n(this,Pe))}save(t){return p(this,Ge,{__proto__:n(this,Ge)}),p(this,Ve,{__proto__:n(this,Ve),transform:{__proto__:n(this,Ve).transform},moveText:{__proto__:n(this,Ve).moveText},sameLineText:{__proto__:n(this,Ve).sameLineText},[Qa]:{__proto__:n(this,Ve)[Qa]}}),p(this,pt,{__proto__:n(this,pt)}),n(this,Gs).push(t),this}restore(t){var i;const e=Object.getPrototypeOf(n(this,Ge));if(e===null)return this;p(this,Ge,e),p(this,Ve,Object.getPrototypeOf(n(this,Ve))),p(this,pt,Object.getPrototypeOf(n(this,pt)));const s=n(this,Gs).pop();return s!==void 0&&((i=Sd(n(this,yi),t))==null||i.dependencies.add(s),n(this,Pe)[t]=n(this,Pe)[s]),this}recordOpenMarker(t){return n(this,Gs).push(t),this}getOpenMarker(){return n(this,Gs).length===0?null:n(this,Gs).at(-1)}recordCloseMarker(t){var s;const e=n(this,Gs).pop();return e!==void 0&&((s=Sd(n(this,yi),t))==null||s.dependencies.add(e),n(this,Pe)[t]=n(this,Pe)[e]),this}beginMarkedContent(t){return n(this,na).push(t),this}endMarkedContent(t){var s;const e=n(this,na).pop();return e!==void 0&&((s=Sd(n(this,yi),t))==null||s.dependencies.add(e),n(this,Pe)[t]=n(this,Pe)[e]),this}pushBaseTransform(t){return n(this,tn).push(H.multiplyByDOMMatrix(n(this,tn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,tn).length>1&&n(this,tn).pop(),this}recordSimpleData(t,e){return n(this,Ge)[t]=e,this}recordIncrementalData(t,e){return n(this,Ve)[t].push(e),this}resetIncrementalData(t,e){return n(this,Ve)[t].length=0,this}recordNamedData(t,e){return n(this,ia).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Ge)[t]=n(this,ia).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Qa,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Ge)&&this.recordFutureForcedDependency(e,n(this,Ge)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,We))this.recordFutureForcedDependency(Qa,t);return this}resetBBox(t){return n(this,en)!==t&&(p(this,en,t),n(this,mt)[0]=1/0,n(this,mt)[1]=1/0,n(this,mt)[2]=-1/0,n(this,mt)[3]=-1/0),this}recordClipBox(t,e,s,i,r,a){const o=H.multiplyByDOMMatrix(n(this,tn).at(-1),e.getTransform()),l=[1/0,1/0,-1/0,-1/0];H.axialAlignedBoundingBox([s,r,i,a],o,l);const h=H.intersect(n(this,pt),l);return h?(n(this,pt)[0]=h[0],n(this,pt)[1]=h[1],n(this,pt)[2]=h[2],n(this,pt)[3]=h[3]):(n(this,pt)[0]=n(this,pt)[1]=1/0,n(this,pt)[2]=n(this,pt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,pt);if(o[0]===1/0)return this;const l=H.multiplyByDOMMatrix(n(this,tn).at(-1),e.getTransform());if(o[0]===-1/0)return H.axialAlignedBoundingBox([s,r,i,a],l,n(this,mt)),this;const h=[1/0,1/0,-1/0,-1/0];return H.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,mt)[0]=Math.min(n(this,mt)[0],Math.max(h[0],o[0])),n(this,mt)[1]=Math.min(n(this,mt)[1],Math.max(h[1],o[1])),n(this,mt)[2]=Math.max(n(this,mt)[2],Math.min(h[2],o[2])),n(this,mt)[3]=Math.max(n(this,mt)[3],Math.min(h[3],o[3])),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&n(this,Uo).get(s),h!==!1&&(c=[0,0,0,0],H.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&H.scaleMinMax([i,0,0,-i,r,a],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const u=o();return l&&c&&h===void 0&&(h=c[0]<=r-u.actualBoundingBoxLeft&&c[2]>=r+u.actualBoundingBoxRight&&c[1]<=a-u.actualBoundingBoxAscent&&c[3]>=a+u.actualBoundingBoxDescent,n(this,Uo).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,mt)[0]=Math.max(0,n(this,pt)[0]),n(this,mt)[1]=Math.max(0,n(this,pt)[1]),n(this,mt)[2]=Math.min(n(this,ra),n(this,pt)[2]),n(this,mt)[3]=Math.min(n(this,aa),n(this,pt)[3]),this}getSimpleIndex(t){return n(this,Ge)[t]}recordDependencies(t,e){const s=n(this,We),i=n(this,Ge),r=n(this,Ve);for(const a of e)a in n(this,Ge)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,ia).has(e)&&n(this,We).add(n(this,ia).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Qa]),n(this,yi)){const s=Sd(n(this,yi),t),{dependencies:i}=s;n(this,We).forEach(i.add,i),n(this,Gs).forEach(i.add,i),n(this,na).forEach(i.add,i),i.delete(t),s.isRenderingOperation=!0}if(n(this,en)===t){const s=mg(n(this,mt)[0]*256/n(this,ra)),i=mg(n(this,mt)[1]*256/n(this,aa)),r=bg(n(this,mt)[2]*256/n(this,ra)),a=bg(n(this,mt)[3]*256/n(this,aa));Ed(n(this,sn),t,s,i,r,a);for(const o of n(this,We))o!==t&&Ed(n(this,sn),o,s,i,r,a);for(const o of n(this,Gs))o!==t&&Ed(n(this,sn),o,s,i,r,a);for(const o of n(this,na))o!==t&&Ed(n(this,sn),o,s,i,r,a);e||(n(this,We).clear(),p(this,en,-1))}return this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,We));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){return n(this,en)===t&&(p(this,en,-1),n(this,pt)[0]=Math.max(n(this,pt)[0],n(this,mt)[0]),n(this,pt)[1]=Math.max(n(this,pt)[1],n(this,mt)[1]),n(this,pt)[2]=Math.min(n(this,pt)[2],n(this,mt)[2]),n(this,pt)[3]=Math.min(n(this,pt)[3],n(this,mt)[3]),e||n(this,We).clear()),this}_takePendingDependencies(){const t=n(this,We);return p(this,We,new Set),t}_extractOperation(t){const e=n(this,nc).get(t);return n(this,nc).delete(t),e}_pushPendingDependencies(t){for(const e of t)n(this,We).add(e)}take(){return n(this,Uo).clear(),new rA(n(this,Pe),n(this,sn))}takeDebugMetadata(){return n(this,yi)}}Ge=new WeakMap,Ve=new WeakMap,ia=new WeakMap,Gs=new WeakMap,na=new WeakMap,tn=new WeakMap,pt=new WeakMap,mt=new WeakMap,en=new WeakMap,We=new WeakMap,nc=new WeakMap,Uo=new WeakMap,ra=new WeakMap,aa=new WeakMap,sn=new WeakMap,Pe=new WeakMap,yi=new WeakMap,rc=new WeakSet,If=function(t,e){const s=new ArrayBuffer(t*4);p(this,sn,new Uint8ClampedArray(s)),p(this,Pe,new Uint32Array(s)),e&&e.length>0?(n(this,Pe).set(e),n(this,Pe).fill(Lf,e.length)):n(this,Pe).fill(Lf)};var Et,Ht,Vs,jo,$o;const tg=class tg{constructor(t,e,s){g(this,Et);g(this,Ht);g(this,Vs);g(this,jo,0);g(this,$o,0);if(t instanceof tg&&n(t,Vs)===!!s)return t;p(this,Et,t),p(this,Ht,e),p(this,Vs,!!s)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Kt(this,$o)._++,n(this,Et).save(n(this,Ht)),this}restore(t){return n(this,$o)>0&&(n(this,Et).restore(n(this,Ht)),Kt(this,$o)._--),this}recordOpenMarker(t){return Kt(this,jo)._++,this}getOpenMarker(){return n(this,jo)>0?n(this,Ht):n(this,Et).getOpenMarker()}recordCloseMarker(t){return Kt(this,jo)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,Et).pushBaseTransform(t),this}popBaseTransform(){return n(this,Et).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Et).recordSimpleData(t,n(this,Ht)),this}recordIncrementalData(t,e){return n(this,Et).recordIncrementalData(t,n(this,Ht)),this}resetIncrementalData(t,e){return n(this,Et).resetIncrementalData(t,n(this,Ht)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,Et).recordSimpleDataFromNamed(t,e,n(this,Ht)),this}recordFutureForcedDependency(t,e){return n(this,Et).recordFutureForcedDependency(t,n(this,Ht)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,Et).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Et).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Vs)||n(this,Et).resetBBox(n(this,Ht)),this}recordClipBox(t,e,s,i,r,a){return n(this,Vs)||n(this,Et).recordClipBox(n(this,Ht),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Vs)||n(this,Et).recordBBox(n(this,Ht),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Vs)||n(this,Et).recordCharacterBBox(n(this,Ht),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Vs)||n(this,Et).recordFullPageBBox(n(this,Ht)),this}getSimpleIndex(t){return n(this,Et).getSimpleIndex(t)}recordDependencies(t,e){return n(this,Et).recordDependencies(n(this,Ht),e),this}recordNamedDependency(t,e){return n(this,Et).recordNamedDependency(n(this,Ht),e),this}recordOperation(t){return n(this,Et).recordOperation(n(this,Ht),!0),this}recordShowTextOperation(t){return n(this,Et).recordShowTextOperation(n(this,Ht),!0),this}bboxToClipBoxDropOperation(t){return n(this,Vs)||n(this,Et).bboxToClipBoxDropOperation(n(this,Ht),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Et=new WeakMap,Ht=new WeakMap,Vs=new WeakMap,jo=new WeakMap,$o=new WeakMap;let hu=tg;const Ss={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},ye={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Ff(d,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),d.clip(i)}class zp{isModifyingCurrentTransform(){return!1}getPattern(){_t("Abstract method `getPattern` called.")}}class oA extends zp{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let r;if(i===ye.STROKE||i===ye.FILL){const a=e.current.getClippedPathBoundingBox(i,Ft(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=H.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Ff(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(s);r.setTransform(u)}else Ff(t,this._bbox),r=this._createGradient(t);return r}}function Zu(d,t,e,s,i,r,a,o){const l=t.coords,h=t.colors,c=d.data,u=d.width*4;let f;l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=r,r=a,a=f),l[s+1]>l[i+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=r,r=a,a=f);const m=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,w=(l[i]+t.offsetX)*t.scaleX,S=(l[i+1]+t.offsetY)*t.scaleY;if(A>=S)return;const E=h[r],_=h[r+1],C=h[r+2],x=h[a],T=h[a+1],P=h[a+2],R=h[o],D=h[o+1],M=h[o+2],I=Math.round(A),G=Math.round(S);let N,W,O,F,tt,it,ee,Je;for(let rt=I;rt<=G;rt++){if(rt<v){const wt=rt<A?0:(A-rt)/(A-v);N=m-(m-y)*wt,W=E-(E-x)*wt,O=_-(_-T)*wt,F=C-(C-P)*wt}else{let wt;rt>S?wt=1:v===S?wt=0:wt=(v-rt)/(v-S),N=y-(y-w)*wt,W=x-(x-R)*wt,O=T-(T-D)*wt,F=P-(P-M)*wt}let ht;rt<A?ht=0:rt>S?ht=1:ht=(A-rt)/(A-S),tt=m-(m-w)*ht,it=E-(E-R)*ht,ee=_-(_-D)*ht,Je=C-(C-M)*ht;const se=Math.round(Math.min(N,tt)),de=Math.round(Math.max(N,tt));let Ee=u*rt+se*4;for(let wt=se;wt<=de;wt++)ht=(N-wt)/(N-tt),ht<0?ht=0:ht>1&&(ht=1),c[Ee++]=W-(W-it)*ht|0,c[Ee++]=O-(O-ee)*ht|0,c[Ee++]=F-(F-Je)*ht|0,c[Ee++]=255}}function lA(d,t,e){const s=t.coords,i=t.colors;let r,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let c=r*o;for(let u=0;u<h;u++,c++)Zu(d,e,s[c],s[c+1],s[c+o],i[c],i[c+1],i[c+o]),Zu(d,e,s[c+o+1],s[c+1],s[c+o],i[c+o+1],i[c+1],i[c+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)Zu(d,e,s[r],s[r+1],s[r+2],i[r],i[r+1],i[r+2]);break;default:throw new Error("illegal figure")}}class hA extends zp{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),m=h/u,A=c/f,y={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/m,scaleY:1/A},v=u+4,w=f+4,S=s.getCanvas("mesh",v,w),E=S.context,_=E.createImageData(u,f);if(e){const x=_.data;for(let T=0,P=x.length;T<P;T+=4)x[T]=e[0],x[T+1]=e[1],x[T+2]=e[2],x[T+3]=255}for(const x of this._figures)lA(_,x,y);return E.putImageData(_,2,2),{canvas:S.canvas,offsetX:o-2*m,offsetY:l-2*A,scaleX:m,scaleY:A}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Ff(t,this._bbox);const r=new Float32Array(2);if(i===ye.SHADING)H.singularValueDecompose2dScale(Ft(t),r);else if(this.matrix){H.singularValueDecompose2dScale(this.matrix,r);const[o,l]=r;H.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else H.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,i===ye.SHADING?null:this._background,e.cachedCanvases);return i!==ye.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class cA extends zp{getPattern(){return"hotpink"}}function dA(d){switch(d[0]){case"RadialAxial":return new oA(d);case"Mesh":return new hA(d);case"Dummy":return new cA}throw new Error(`Unknown IR type: ${d[0]}`)}const yg={COLORED:1,UNCOLORED:2},xu=class xu{constructor(t,e,s,i){this.color=t[1],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.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i}createPatternCanvas(t,e){var it,ee;const{bbox:s,operatorList:i,paintType:r,tilingType:a,color:o,canvasGraphicsFactory:l}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),Bu("TilingType: "+a);const u=s[0],f=s[1],m=s[2],A=s[3],y=m-u,v=A-f,w=new Float32Array(2);H.singularValueDecompose2dScale(this.matrix,w);const[S,E]=w;H.singularValueDecompose2dScale(this.baseTransform,w);const _=S*w[0],C=E*w[1];let x=y,T=v,P=!1,R=!1;const D=Math.ceil(h*_),M=Math.ceil(c*C),I=Math.ceil(y*_),G=Math.ceil(v*C);D>=I?x=h:P=!0,M>=G?T=c:R=!0;const N=this.getSizeAndScale(x,this.ctx.canvas.width,_),W=this.getSizeAndScale(T,this.ctx.canvas.height,C),O=t.cachedCanvases.getCanvas("pattern",N.size,W.size),F=O.context,tt=l.createCanvasGraphics(F,e);if(tt.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(tt,r,o),F.translate(-N.scale*u,-W.scale*f),tt.transform(0,N.scale,0,0,W.scale,0,0),F.save(),(it=tt.dependencyTracker)==null||it.save(),this.clipBbox(tt,u,f,m,A),tt.baseTransform=Ft(tt.ctx),tt.executeOperatorList(i),tt.endDrawing(),(ee=tt.dependencyTracker)==null||ee.restore(),F.restore(),P||R){const Je=O.canvas;P&&(x=h),R&&(T=c);const rt=this.getSizeAndScale(x,this.ctx.canvas.width,_),ht=this.getSizeAndScale(T,this.ctx.canvas.height,C),se=rt.size,de=ht.size,Ee=t.cachedCanvases.getCanvas("pattern-workaround",se,de),wt=Ee.context,Os=P?Math.floor(y/h):0,ii=R?Math.floor(v/c):0;for(let Ii=0;Ii<=Os;Ii++)for(let Me=0;Me<=ii;Me++)wt.drawImage(Je,se*Ii,de*Me,se,de,0,0,se,de);return{canvas:Ee.canvas,scaleX:rt.scale,scaleY:ht.scale,offsetX:u,offsetY:f}}return{canvas:O.canvas,scaleX:N.scale,scaleY:W.scale,offsetX:u,offsetY:f}}getSizeAndScale(t,e,s){const i=Math.max(xu.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s;t.ctx.rect(e,s,a,o),H.axialAlignedBoundingBox([e,s,i,r],Ft(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(e){case yg.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case yg.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new My(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){let a=s;i!==ye.SHADING&&(a=H.transform(a,e.baseTransform),this.matrix&&(a=H.transform(a,this.matrix)));const o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const h=t.createPattern(o.canvas,"repeat");return h.setTransform(l),h}};k(xu,"MAX_PATTERN_SIZE",3e3);let Nf=xu;function uA({src:d,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ce.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,u=s&7,f=d.length;e=new Uint32Array(e.buffer);let m=0;for(let A=0;A<i;A++){for(const v=t+c;t<v;t++){const w=t<f?d[t]:255;e[m++]=w&128?h:l,e[m++]=w&64?h:l,e[m++]=w&32?h:l,e[m++]=w&16?h:l,e[m++]=w&8?h:l,e[m++]=w&4?h:l,e[m++]=w&2?h:l,e[m++]=w&1?h:l}if(u===0)continue;const y=t<f?d[t++]:255;for(let v=0;v<u;v++)e[m++]=y&1<<7-v?h:l}return{srcPos:t,destPos:m}}const Ag=16,wg=100,fA=15,vg=10,Ke=16,tf=new DOMMatrix,ys=new Float32Array(2),oo=new Float32Array([1/0,1/0,-1/0,-1/0]);function pA(d,t){if(d._removeMirroring)throw new Error("Context is already forwarding operations.");d.__originalSave=d.save,d.__originalRestore=d.restore,d.__originalRotate=d.rotate,d.__originalScale=d.scale,d.__originalTranslate=d.translate,d.__originalTransform=d.transform,d.__originalSetTransform=d.setTransform,d.__originalResetTransform=d.resetTransform,d.__originalClip=d.clip,d.__originalMoveTo=d.moveTo,d.__originalLineTo=d.lineTo,d.__originalBezierCurveTo=d.bezierCurveTo,d.__originalRect=d.rect,d.__originalClosePath=d.closePath,d.__originalBeginPath=d.beginPath,d._removeMirroring=()=>{d.save=d.__originalSave,d.restore=d.__originalRestore,d.rotate=d.__originalRotate,d.scale=d.__originalScale,d.translate=d.__originalTranslate,d.transform=d.__originalTransform,d.setTransform=d.__originalSetTransform,d.resetTransform=d.__originalResetTransform,d.clip=d.__originalClip,d.moveTo=d.__originalMoveTo,d.lineTo=d.__originalLineTo,d.bezierCurveTo=d.__originalBezierCurveTo,d.rect=d.__originalRect,d.closePath=d.__originalClosePath,d.beginPath=d.__originalBeginPath,delete d._removeMirroring},d.save=function(){t.save(),this.__originalSave()},d.restore=function(){t.restore(),this.__originalRestore()},d.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},d.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},d.transform=function(e,s,i,r,a,o){t.transform(e,s,i,r,a,o),this.__originalTransform(e,s,i,r,a,o)},d.setTransform=function(e,s,i,r,a,o){t.setTransform(e,s,i,r,a,o),this.__originalSetTransform(e,s,i,r,a,o)},d.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},d.rotate=function(e){t.rotate(e),this.__originalRotate(e)},d.clip=function(e){t.clip(e),this.__originalClip(e)},d.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},d.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},d.bezierCurveTo=function(e,s,i,r,a,o){t.bezierCurveTo(e,s,i,r,a,o),this.__originalBezierCurveTo(e,s,i,r,a,o)},d.rect=function(e,s,i,r){t.rect(e,s,i,r),this.__originalRect(e,s,i,r)},d.closePath=function(){t.closePath(),this.__originalClosePath()},d.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class gA{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function _d(d,t,e,s,i,r,a,o,l,h){const[c,u,f,m,A,y]=Ft(d);if(u===0&&f===0){const S=a*c+A,E=Math.round(S),_=o*m+y,C=Math.round(_),x=(a+l)*c+A,T=Math.abs(Math.round(x)-E)||1,P=(o+h)*m+y,R=Math.abs(Math.round(P)-C)||1;return d.setTransform(Math.sign(c),0,0,Math.sign(m),E,C),d.drawImage(t,e,s,i,r,0,0,T,R),d.setTransform(c,u,f,m,A,y),[T,R]}if(c===0&&m===0){const S=o*f+A,E=Math.round(S),_=a*u+y,C=Math.round(_),x=(o+h)*f+A,T=Math.abs(Math.round(x)-E)||1,P=(a+l)*u+y,R=Math.abs(Math.round(P)-C)||1;return d.setTransform(0,Math.sign(u),Math.sign(f),0,E,C),d.drawImage(t,e,s,i,r,0,0,R,T),d.setTransform(c,u,f,m,A,y),[R,T]}d.drawImage(t,e,s,i,r,a,o,l,h);const v=Math.hypot(c,u),w=Math.hypot(f,m);return[v*l,w*h]}class Eg{constructor(t,e,s){k(this,"alphaIsShape",!1);k(this,"fontSize",0);k(this,"fontSizeScale",1);k(this,"textMatrix",null);k(this,"textMatrixScale",1);k(this,"fontMatrix",lf);k(this,"leading",0);k(this,"x",0);k(this,"y",0);k(this,"lineX",0);k(this,"lineY",0);k(this,"charSpacing",0);k(this,"wordSpacing",0);k(this,"textHScale",1);k(this,"textRenderingMode",ue.FILL);k(this,"textRise",0);k(this,"fillColor","#000000");k(this,"strokeColor","#000000");k(this,"patternFill",!1);k(this,"patternStroke",!1);k(this,"fillAlpha",1);k(this,"strokeAlpha",1);k(this,"lineWidth",1);k(this,"activeSMask",null);k(this,"transferMaps","none");s==null||s(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=oo.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=ye.FILL,e=null){const s=this.minMax.slice();if(t===ye.STROKE){e||_t("Stroke bounding box must include transform."),H.singularValueDecompose2dScale(e,ys);const i=ys[0]*this.lineWidth/2,r=ys[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=H.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(oo,0)}getClippedPathBoundingBox(t=ye.FILL,e=null){return H.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Sg(d,t){if(t instanceof ImageData){d.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Ke,r=(e-i)/Ke,a=i===0?r:r+1,o=d.createImageData(s,Ke);let l=0,h;const c=t.data,u=o.data;let f,m,A,y;if(t.kind===wh.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(u.buffer,0,u.byteLength>>2),S=w.length,E=s+7>>3,_=4294967295,C=ce.isLittleEndian?4278190080:255;for(f=0;f<a;f++){for(A=f<r?Ke:i,h=0,m=0;m<A;m++){const x=v-l;let T=0;const P=x>E?s:x*8-7,R=P&-8;let D=0,M=0;for(;T<R;T+=8)M=c[l++],w[h++]=M&128?_:C,w[h++]=M&64?_:C,w[h++]=M&32?_:C,w[h++]=M&16?_:C,w[h++]=M&8?_:C,w[h++]=M&4?_:C,w[h++]=M&2?_:C,w[h++]=M&1?_:C;for(;T<P;T++)D===0&&(M=c[l++],D=128),w[h++]=M&D?_:C,D>>=1}for(;h<S;)w[h++]=0;d.putImageData(o,0,f*Ke)}}else if(t.kind===wh.RGBA_32BPP){for(m=0,y=s*Ke*4,f=0;f<r;f++)u.set(c.subarray(l,l+y)),l+=y,d.putImageData(o,0,m),m+=Ke;f<a&&(y=s*i*4,u.set(c.subarray(l,l+y)),d.putImageData(o,0,m))}else if(t.kind===wh.RGB_24BPP)for(A=Ke,y=s*A,f=0;f<a;f++){for(f>=r&&(A=i,y=s*A),h=0,m=y;m--;)u[h++]=c[l++],u[h++]=c[l++],u[h++]=c[l++],u[h++]=255;d.putImageData(o,0,f*Ke)}else throw new Error(`bad image kind: ${t.kind}`)}function _g(d,t){if(t.bitmap){d.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Ke,r=(e-i)/Ke,a=i===0?r:r+1,o=d.createImageData(s,Ke);let l=0;const h=t.data,c=o.data;for(let u=0;u<a;u++){const f=u<r?Ke:i;({srcPos:l}=uA({src:h,srcPos:l,dest:c,width:s,height:f,nonBlackColor:0})),d.putImageData(o,0,u*Ke)}}function Yl(d,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)d[s]!==void 0&&(t[s]=d[s]);d.setLineDash!==void 0&&(t.setLineDash(d.getLineDash()),t.lineDashOffset=d.lineDashOffset)}function Cd(d){d.strokeStyle=d.fillStyle="#000000",d.fillRule="nonzero",d.globalAlpha=1,d.lineWidth=1,d.lineCap="butt",d.lineJoin="miter",d.miterLimit=10,d.globalCompositeOperation="source-over",d.font="10px sans-serif",d.setLineDash!==void 0&&(d.setLineDash([]),d.lineDashOffset=0);const{filter:t}=d;t!=="none"&&t!==""&&(d.filter="none")}function Cg(d,t){if(t)return!0;H.singularValueDecompose2dScale(d,ys);const e=Math.fround(ei.pixelRatio*_n.PDF_TO_CSS_UNITS);return ys[0]<=e&&ys[1]<=e}const mA=["butt","round","square"],bA=["miter","round","bevel"],yA={},xg={};var si,Of,Bf,Hf;const eg=class eg{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c){g(this,si);this.ctx=t,this.current=new Eg(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=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new gA(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null}getObject(t,e,s=null){var i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Ft(this.compositeCtx))}this.ctx.save(),Cd(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=Ft(this.ctx)}executeOperatorList(t,e,s,i,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>vg&&typeof s=="function",u=c?Date.now()+fA:0;let f=0;const m=this.commonObjs,A=this.objs;let y,v;for(;;){if(i!==void 0&&l===i.nextBreakPoint)return i.breakIt(l,s),l;if(!r||r(l))if(y=o[l],v=a[l]??null,y!==$l.dependency)v===null?this[y](l):this[y](l,...v);else for(const S of v){(w=this.dependencyTracker)==null||w.recordNamedData(S,l);const E=S.startsWith("g_")?m:A;if(!E.has(S))return E.get(S,s),l}if(l++,l===h)return l;if(c&&++f>vg){if(Date.now()>u)return s(),l;f=0}}}endDrawing(){b(this,si,Of).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,si,Bf).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,h="prescale1",c,u;for(;r>2&&o>1||a>2&&l>1;){let f=o,m=l;r>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),r/=o/f),a>2&&l>1&&(m=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/m),c=this.cachedCanvases.getCanvas(h,f,m),u=c.context,u.clearRect(0,0,f,m),u.drawImage(t,0,0,o,l,0,0,f,m),t=c.canvas,o=f,l=m,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t,e){var D,M;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Ft(s);let h,c,u,f;if((e.bitmap||e.data)&&e.count>1){const I=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.get(I),h||(h=new Map,this._cachedBitmapsMap.set(I,h));const G=h.get(c);if(G&&!o){const N=Math.round(Math.min(l[0],l[2])+l[4]),W=Math.round(Math.min(l[1],l[3])+l[5]);return(D=this.dependencyTracker)==null||D.recordDependencies(t,Ss.transformAndFill),{canvas:G,offsetX:N,offsetY:W}}u=G}u||(f=this.cachedCanvases.getCanvas("maskCanvas",i,r),_g(f.context,e));let m=H.transform(l,[1/i,0,0,-1/r,0,0]);m=H.transform(m,[1,0,0,1,0,-r]);const A=oo.slice();H.axialAlignedBoundingBox([0,0,i,r],m,A);const[y,v,w,S]=A,E=Math.round(w-y)||1,_=Math.round(S-v)||1,C=this.cachedCanvases.getCanvas("fillCanvas",E,_),x=C.context,T=y,P=v;x.translate(-T,-P),x.transform(...m),u||(u=this._scaleImage(f.canvas,ni(x)),u=u.img,h&&o&&h.set(c,u)),x.imageSmoothingEnabled=Cg(Ft(x),e.interpolate),_d(x,u,0,0,u.width,u.height,0,0,i,r),x.globalCompositeOperation="source-in";const R=H.transform(ni(x),[1,0,0,1,-T,-P]);return x.fillStyle=o?a.getPattern(s,this,R,ye.FILL,t):a,x.fillRect(0,0,i,r),h&&!o&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),(M=this.dependencyTracker)==null||M.recordDependencies(t,Ss.transformAndFill),{canvas:C.canvas,offsetX:Math.round(T),offsetY:Math.round(P)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=mA[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=bA[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,r,a,o;for(const[l,h]of e)switch(l){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,s=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(i,e,s);this.suspendedCtx=this.ctx;const a=this.ctx=r.context;a.setTransform(this.suspendedCtx.getTransform()),Yl(this.suspendedCtx,a),pA(a,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Yl(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];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,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,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,r,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,r,a,o,l,h,c,u){let f=t.canvas,m=l-c,A=h-u;if(a)if(m<0||A<0||m+s>f.width||A+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),w=v.context;w.drawImage(f,-m,-A),w.globalCompositeOperation="destination-atop",w.fillStyle=a,w.fillRect(0,0,s,i),w.globalCompositeOperation="source-over",f=v.canvas,m=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(m,A,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(m,A,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const y=new Path2D;y.rect(l,h,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(f,m,A,s,i,l,h,s,i),e.restore()}save(t){var s;this.inSMaskMode&&Yl(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Yl(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),this[e](t,r);return}if(this.dependencyTracker!==null){const a=e===$l.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}if(!(r instanceof Path2D)){const a=s[0]=new Path2D;for(let o=0,l=r.length;o<l;)switch(r[o++]){case yd.moveTo:a.moveTo(r[o++],r[o++]);break;case yd.lineTo:a.lineTo(r[o++],r[o++]);break;case yd.curveTo:a.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);break;case yd.closePath:a.closePath();break;default:q(`Unrecognized drawing path operator: ${r[o-1]}`);break}r=a}H.axialAlignedBoundingBox(i,Ft(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var a;const i=this.ctx,r=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const o=r.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=r.getPattern(i,this,ni(i),ye.STROKE,t),o){const l=new Path2D;l.addPath(e,i.getTransform().invertSelf().multiplySelf(o)),e=l}this.rescaleAndStroke(e,!1),i.restore()}else this.rescaleAndStroke(e,!0);(a=this.dependencyTracker)==null||a.recordDependencies(t,Ss.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(ye.STROKE,Ft(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,c,u;const i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;if(a){const f=r.isModifyingCurrentTransform()?i.getTransform():null;if((h=this.dependencyTracker)==null||h.save(t),i.save(),i.fillStyle=r.getPattern(i,this,ni(i),ye.FILL,t),f){const m=new Path2D;m.addPath(e,i.getTransform().invertSelf().multiplySelf(f)),e=m}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(i.fill(e,"evenodd"),this.pendingEOFill=!1):i.fill(e)),(c=this.dependencyTracker)==null||c.recordDependencies(t,Ss.fill),o&&(i.restore(),(u=this.dependencyTracker)==null||u.restore(t)),s&&this.consumePath(t,e,l)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var s;this.ctx.fill(e),(s=this.dependencyTracker)==null||s.recordDependencies(t,Ss.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=yA}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=xg}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&i.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var u,f;(u=this.dependencyTracker)==null||u.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||lf,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&q("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const h=i.italic?"italic":"normal";let c=s;s<Ag?c=Ag:s>wg&&(c=wg),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,s,i,r,a){var w,S,E,_;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,u=l.fontSize/l.fontSizeScale,f=c&ue.FILL_STROKE_MASK,m=!!(c&ue.ADD_TO_PATH_FLAG),A=l.patternFill&&!h.missingFile,y=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||m||A||y)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||A||y)){o.save(),o.translate(s,i),o.scale(u,-u),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(f===ue.FILL||f===ue.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const x=b(this,si,Hf).call(this,v,C,r);o.fill(x)}else o.fill(v);if(f===ue.STROKE||f===ue.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:x,b:T,c:P,d:R}=C,D=H.inverseTransform(a),M=H.transform([x,T,P,R,0,0],D);H.singularValueDecompose2dScale(M,ys),o.lineWidth*=Math.max(ys[0],ys[1])/u,o.stroke(b(this,si,Hf).call(this,v,C,a))}else o.lineWidth/=u,o.stroke(v);o.restore()}else(f===ue.FILL||f===ue.FILL_STROKE)&&(o.fillText(e,s,i),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,u,s,i,()=>o.measureText(e))),(f===ue.STROKE||f===ue.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,u,s,i,()=>o.measureText(e)).recordDependencies(t,Ss.stroke)),o.strokeText(e,s,i));m&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ft(o),x:s,y:i,fontSize:u,path:v}),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,h,u,s,i))}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return J(this,"isFontSubpixelAAEnabled",s)}showText(t,e){var P,R,D,M;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Ss.showText).resetBBox(t),this.current.textRenderingMode&ue.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){this.showType3Text(t,e),(P=this.dependencyTracker)==null||P.recordShowTextOperation(t);return}const r=s.fontSize;if(r===0){(R=this.dependencyTracker)==null||R.recordOperation(t);return}const a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,u=s.textHScale*c,f=e.length,m=i.vertical,A=m?1:-1,y=i.defaultVMetrics,v=r*s.fontMatrix[0],w=s.textRenderingMode===ue.FILL&&!i.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),c>0?a.scale(u,-1):a.scale(u,1);let S,E;if(s.patternFill){a.save();const I=s.fillColor.getPattern(a,this,ni(a),ye.FILL,t);S=Ft(a),a.restore(),a.fillStyle=I}if(s.patternStroke){a.save();const I=s.strokeColor.getPattern(a,this,ni(a),ye.STROKE,t);E=Ft(a),a.restore(),a.strokeStyle=I}let _=s.lineWidth;const C=s.textMatrixScale;if(C===0||_===0){const I=s.textRenderingMode&ue.FILL_STROKE_MASK;(I===ue.STROKE||I===ue.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=C;if(o!==1&&(a.scale(o,o),_/=o),a.lineWidth=_,i.isInvalidPDFjsFont){const I=[];let G=0;for(const W of e)I.push(W.unicode),G+=W.width;const N=I.join("");if(a.fillText(N,0,0),this.dependencyTracker!==null){const W=a.measureText(N);this.dependencyTracker.recordBBox(t,this.ctx,-W.actualBoundingBoxLeft,W.actualBoundingBoxRight,-W.actualBoundingBoxAscent,W.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=G*v*u,a.restore(),this.compose();return}let x=0,T;for(T=0;T<f;++T){const I=e[T];if(typeof I=="number"){x+=A*I*r/1e3;continue}let G=!1;const N=(I.isSpace?h:0)+l,W=I.fontChar,O=I.accent;let F,tt,it=I.width;if(m){const rt=I.vmetric||y,ht=-(I.vmetric?rt[1]:it*.5)*v,se=rt[2]*v;it=rt?-rt[0]:it,F=ht/o,tt=(x+se)/o}else F=x/o,tt=0;let ee;if(i.remeasure&&it>0){ee=a.measureText(W);const rt=ee.width*1e3/r*o;if(it<rt&&this.isFontSubpixelAAEnabled){const ht=it/rt;G=!0,a.save(),a.scale(ht,1),F/=ht}else it!==rt&&(F+=(it-rt)/2e3*r/o)}if(this.contentVisible&&(I.isInFont||i.missingFile)){if(w&&!O)a.fillText(W,F,tt),(D=this.dependencyTracker)==null||D.recordCharacterBBox(t,a,ee?{bbox:null}:i,r/o,F,tt,()=>ee??a.measureText(W));else if(this.paintChar(t,W,F,tt,S,E),O){const rt=F+r*O.offset.x/o,ht=tt-r*O.offset.y/o;this.paintChar(t,O.fontChar,rt,ht,S,E)}}const Je=m?it*v-N*c:it*v+N*c;x+=Je,G&&a.restore()}m?s.y-=x:s.x+=x*u,a.restore(),this.compose(),(M=this.dependencyTracker)==null||M.recordShowTextOperation(t)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,u=i.textHScale*o,f=i.fontMatrix||lf,m=e.length,A=i.textRenderingMode===ue.INVISIBLE;let y,v,w,S;if(A||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(u,o);const E=this.dependencyTracker;for(this.dependencyTracker=E?new hu(E,t):null,y=0;y<m;++y){if(v=e[y],typeof v=="number"){S=l*v*a/1e3,this.ctx.translate(S,0),i.x+=S*u;continue}const _=(v.isSpace?c:0)+h,C=r.charProcOperatorList[v.operatorListId];C?this.contentVisible&&(this.save(),s.scale(a,a),s.transform(...f),this.executeOperatorList(C),this.restore()):q(`Type3 character "${v.operatorListId}" is not available.`);const x=[v.width,0];H.applyTransform(x,f),w=x[0]*a+_,s.translate(w,0),i.x+=w*u}s.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,a,o){var h;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,i,a,r,o).recordClipBox(t,this.ctx,i,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||Ft(this.ctx),r={createCanvasGraphics:(a,o)=>new eg(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new hu(this.dependencyTracker,o,!0):null)};s=new Nf(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=dA(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){var a;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const i=this._getPattern(t,e);s.fillStyle=i.getPattern(s,this,ni(s),ye.SHADING,t);const r=ni(s);if(r){const{width:o,height:l}=s.canvas,h=oo.slice();H.axialAlignedBoundingBox([0,0,o,l],r,h);const[c,u,f,m]=h;this.ctx.fillRect(c,u,f-c,m-u)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(a=this.dependencyTracker)==null||a.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ss.transform).recordDependencies(t,Ss.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){_t("Should not call beginInlineImage")}beginImageData(){_t("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Ft(this.ctx),s)){H.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(i=this.dependencyTracker)==null||i.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var E;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;e.isolated||Bu("TODO: Support non-isolated groups."),e.knockout&&q("Knockout groups not supported.");const i=Ft(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=oo.slice();H.axialAlignedBoundingBox(e.bbox,Ft(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=H.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),c=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let u="groupAt"+this.groupLevel;e.smask&&(u+="_smask_"+this.smaskCounter++%2);const f=this.cachedCanvases.getCanvas(u,h,c),m=f.context;m.translate(-o,-l),m.transform(...i);let A=new Path2D;const[y,v,w,S]=e.bbox;if(A.rect(y,v,w-y,S-v),e.matrix){const _=new Path2D;_.addPath(A,new DOMMatrix(e.matrix)),A=_}m.clip(A),e.smask&&this.smaskStack.push({canvas:f.canvas,context:m,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),Yl(s,m),this.ctx=m,(E=this.dependencyTracker)==null||E.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const a=Ft(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...a);const o=oo.slice();H.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],a,o),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,e,s,i,r,a){if(b(this,si,Of).call(this),Cd(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const o=s[2]-s[0],l=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=o,s[3]=l,H.singularValueDecompose2dScale(Ft(this.ctx),ys);const{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),u=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);const{canvas:f,context:m}=this.annotationCanvas;this.annotationCanvasMap.set(e,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(ys[0],0,0,-ys[1],0,l*ys[1]),Cd(this.ctx)}else{Cd(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new Eg(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...i),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,si,Bf).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var o;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,r.offsetX,r.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var u,f,m;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=this.ctx;l.save();const h=Ft(l);l.transform(s,i,r,a,0,0);const c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),(u=this.dependencyTracker)==null||u.resetBBox(t);for(let A=0,y=o.length;A<y;A+=2){const v=H.transform(h,[s,i,r,a,o[A],o[A+1]]);l.drawImage(c.canvas,v[4],v[5]),(f=this.dependencyTracker)==null||f.recordBBox(t,this.ctx,v[4],v[4]+c.canvas.width,v[5],v[5]+c.canvas.height)}l.restore(),this.compose(),(m=this.dependencyTracker)==null||m.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var a,o,l;if(!this.contentVisible)return;const s=this.ctx,i=this.current.fillColor,r=this.current.patternFill;(a=this.dependencyTracker)==null||a.resetBBox(t).recordDependencies(t,Ss.transformAndFill);for(const h of e){const{data:c,width:u,height:f,transform:m}=h,A=this.cachedCanvases.getCanvas("maskCanvas",u,f),y=A.context;y.save();const v=this.getObject(t,c,h);_g(y,v),y.globalCompositeOperation="source-in",y.fillStyle=r?i.getPattern(y,this,ni(s),ye.FILL,t):i,y.fillRect(0,0,u,f),y.restore(),s.save(),s.transform(...m),s.scale(1,-1),_d(s,A.canvas,0,0,u,f,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,s,0,u,0,f),s.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){q("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){q("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,u=r.length;c<u;c+=2)h.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,r=this.cachedCanvases.getCanvas("inlineImage",s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",r.canvas}paintInlineImageXObject(t,e){var h;if(!this.contentVisible)return;const s=e.width,i=e.height,r=this.ctx;this.save(t);const{filter:a}=r;a!=="none"&&a!==""&&(r.filter="none"),r.scale(1/s,-1/i);let o;if(e.bitmap)o=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)o=e;else{const u=this.cachedCanvases.getCanvas("inlineImage",s,i).context;Sg(u,e),o=this.applyTransferMapsToCanvas(u)}const l=this._scaleImage(o,ni(r));r.imageSmoothingEnabled=Cg(Ft(r),e.interpolate),(h=this.dependencyTracker)==null||h.resetBBox(t).recordBBox(t,r,0,s,-i,0).recordDependencies(t,Ss.imageXObject).recordOperation(t),_d(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-i,s,i),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){var a,o,l;if(!this.contentVisible)return;const i=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const h=e.width,c=e.height,f=this.cachedCanvases.getCanvas("inlineImage",h,c).context;Sg(f,e),r=this.applyTransferMapsToCanvas(f)}(a=this.dependencyTracker)==null||a.resetBBox(t);for(const h of s)i.save(),i.transform(...h.transform),i.scale(1,-1),_d(i,r,h.x,h.y,h.w,h.h,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,i,0,1,-1,0),i.restore();(l=this.dependencyTracker)==null||l.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ss.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===xg?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Ft(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,u=h*t;a=c<1?1/c:1,o=u<1?1/u:1}}else{const l=Math.abs(e*r-s*i),h=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)a=c/l,o=h/l;else{const u=t*l;a=c>u?c/u:1,o=h>u?h/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),tf.a=1/r,tf.d=1/a;const l=new Path2D;if(l.addPath(t,tf),o.length>0){const h=Math.max(r,a);s.setLineDash(o.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};si=new WeakSet,Of=function(){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)},Bf=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Hf=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let fo=eg;for(const d in $l)fo.prototype[d]!==void 0&&(fo.prototype[$l[d]]=fo.prototype[d]);var zo,Go,ac,Vo,Nd;const ho=class ho{constructor(t){g(this,Vo);g(this,zo);g(this,Go);g(this,ac);p(this,zo,t),p(this,Go,new DataView(n(this,zo))),p(this,ac,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let i=0;for(const h of ho.strings){const c=e.encode(t[h]);s[h]=c,i+=4+c.length}const r=new ArrayBuffer(i),a=new Uint8Array(r),o=new DataView(r);let l=0;for(const h of ho.strings){const c=s[h],u=c.length;o.setUint32(l,u),a.set(c,l+4),l+=4+u}return nt(l===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return b(this,Vo,Nd).call(this,0)}get fontWeight(){return b(this,Vo,Nd).call(this,1)}get italicAngle(){return b(this,Vo,Nd).call(this,2)}};zo=new WeakMap,Go=new WeakMap,ac=new WeakMap,Vo=new WeakSet,Nd=function(t){nt(t<ho.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=n(this,Go).getUint32(e)+4;const s=n(this,Go).getUint32(e);return n(this,ac).decode(new Uint8Array(n(this,zo),e+4,s))},k(ho,"strings",["fontFamily","fontWeight","italicAngle"]);let cu=ho;var Yn,Ai,oa,la,ch;const co=class co{constructor(t){g(this,la);g(this,Yn);g(this,Ai);g(this,oa);p(this,Yn,t),p(this,Ai,new DataView(n(this,Yn))),p(this,oa,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let i=0;for(const f of co.strings){const m=e.encode(t[f]);s[f]=m,i+=4+m.length}i+=4;let r,a,o=1+i;t.style&&(r=e.encode(t.style.style),a=e.encode(t.style.weight),o+=4+r.length+4+a.length);const l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let u=0;c.setUint8(u++,t.guessFallback?1:0),c.setUint32(u,0),u+=4,i=0;for(const f of co.strings){const m=s[f],A=m.length;i+=4+A,c.setUint32(u,A),h.set(m,u+4),u+=4+A}return c.setUint32(u-i-4,i),t.style&&(c.setUint32(u,r.length),h.set(r,u+4),u+=4+r.length,c.setUint32(u,a.length),h.set(a,u+4),u+=4+a.length),nt(u<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(u)}get guessFallback(){return n(this,Ai).getUint8(0)!==0}get css(){return b(this,la,ch).call(this,0)}get loadedName(){return b(this,la,ch).call(this,1)}get baseFontName(){return b(this,la,ch).call(this,2)}get src(){return b(this,la,ch).call(this,3)}get style(){let t=1;t+=4+n(this,Ai).getUint32(t);const e=n(this,Ai).getUint32(t),s=n(this,oa).decode(new Uint8Array(n(this,Yn),t+4,e));t+=4+e;const i=n(this,Ai).getUint32(t),r=n(this,oa).decode(new Uint8Array(n(this,Yn),t+4,i));return{style:s,weight:r}}};Yn=new WeakMap,Ai=new WeakMap,oa=new WeakMap,la=new WeakSet,ch=function(t){nt(t<co.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=n(this,Ai).getUint32(e)+4;const s=n(this,Ai).getUint32(e);return n(this,oa).decode(new Uint8Array(n(this,Yn),e+4,s))},k(co,"strings",["css","loadedName","baseFontName","src"]);let du=co;var Wo,Xo,qo,Yo,is,wi,oc,bt,$t,Hs,Od,dh;const K=class K{constructor({data:t,extra:e}){g(this,$t);g(this,wi);g(this,oc);g(this,bt);p(this,wi,t),p(this,oc,new TextDecoder),p(this,bt,new DataView(n(this,wi))),e&&Object.assign(this,e)}get black(){return b(this,$t,Hs).call(this,0)}get bold(){return b(this,$t,Hs).call(this,1)}get disableFontFace(){return b(this,$t,Hs).call(this,2)}get fontExtraProperties(){return b(this,$t,Hs).call(this,3)}get isInvalidPDFjsFont(){return b(this,$t,Hs).call(this,4)}get isType3Font(){return b(this,$t,Hs).call(this,5)}get italic(){return b(this,$t,Hs).call(this,6)}get missingFile(){return b(this,$t,Hs).call(this,7)}get remeasure(){return b(this,$t,Hs).call(this,8)}get vertical(){return b(this,$t,Hs).call(this,9)}get ascent(){return b(this,$t,Od).call(this,0)}get defaultWidth(){return b(this,$t,Od).call(this,1)}get descent(){return b(this,$t,Od).call(this,2)}get bbox(){let t=n(K,Xo);if(n(this,bt).getUint8(t)===0)return;t+=1;const s=[];for(let i=0;i<4;i++)s.push(n(this,bt).getInt16(t,!0)),t+=2;return s}get fontMatrix(){let t=n(K,qo);if(n(this,bt).getUint8(t)===0)return;t+=1;const s=[];for(let i=0;i<6;i++)s.push(n(this,bt).getFloat64(t,!0)),t+=8;return s}get defaultVMetrics(){let t=n(K,Yo);if(n(this,bt).getUint8(t)===0)return;t+=1;const s=[];for(let i=0;i<3;i++)s.push(n(this,bt).getInt16(t,!0)),t+=2;return s}get fallbackName(){return b(this,$t,dh).call(this,0)}get loadedName(){return b(this,$t,dh).call(this,1)}get mimetype(){return b(this,$t,dh).call(this,2)}get name(){return b(this,$t,dh).call(this,3)}get data(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);t+=4+s;const i=n(this,bt).getUint32(t);t+=4+i;const r=n(this,bt).getUint32(t);if(r!==0)return new Uint8Array(n(this,wi),t+4,r)}clearData(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);t+=4+s;const i=n(this,bt).getUint32(t);t+=4+i;const r=n(this,bt).getUint32(t);new Uint8Array(n(this,wi),t+4,r).fill(0),n(this,bt).setUint32(t,0)}get cssFontInfo(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);t+=4+s;const i=n(this,bt).getUint32(t);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(n(this,wi),t+4,i)),new cu(r.buffer)}get systemFontInfo(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(n(this,wi),t+4,s)),new du(i.buffer)}static write(t){const e=t.systemFontInfo?du.write(t.systemFontInfo):null,s=t.cssFontInfo?cu.write(t.cssFontInfo):null,i=new TextEncoder,r={};let a=0;for(const y of K.strings)r[y]=i.encode(t[y]),a+=4+r[y].length;const o=n(K,is)+4+a+4+(e?e.byteLength:0)+4+(s?s.byteLength:0)+4+(t.data?t.data.length:0),l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let u=0;const f=K.bools.length;let m=0,A=0;for(let y=0;y<f;y++){const v=t[K.bools[y]];m|=(v===void 0?0:v?2:1)<<A,A+=2,(A===8||y===f-1)&&(c.setUint8(u++,m),m=0,A=0)}nt(u===n(K,Wo),"FontInfo.write: Boolean properties offset mismatch");for(const y of K.numbers)c.setFloat64(u,t[y]),u+=8;if(nt(u===n(K,Xo),"FontInfo.write: Number properties offset mismatch"),t.bbox){c.setUint8(u++,4);for(const y of t.bbox)c.setInt16(u,y,!0),u+=2}else c.setUint8(u++,0),u+=8;if(nt(u===n(K,qo),"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){c.setUint8(u++,6);for(const y of t.fontMatrix)c.setFloat64(u,y,!0),u+=8}else c.setUint8(u++,0),u+=48;if(nt(u===n(K,Yo),"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){c.setUint8(u++,1);for(const y of t.defaultVMetrics)c.setInt16(u,y,!0),u+=2}else c.setUint8(u++,0),u+=6;nt(u===n(K,is),"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(n(K,is),0),u+=4;for(const y of K.strings){const v=r[y],w=v.length;c.setUint32(u,w),h.set(v,u+4),u+=4+w}if(c.setUint32(n(K,is),u-n(K,is)-4),!e)c.setUint32(u,0),u+=4;else{const y=e.byteLength;c.setUint32(u,y),nt(u+4+y<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),u+4),u+=4+y}if(!s)c.setUint32(u,0),u+=4;else{const y=s.byteLength;c.setUint32(u,y),nt(u+4+y<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),u+4),u+=4+y}return t.data===void 0?(c.setUint32(u,0),u+=4):(c.setUint32(u,t.data.length),h.set(t.data,u+4),u+=4+t.data.length),nt(u<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(u)}};Wo=new WeakMap,Xo=new WeakMap,qo=new WeakMap,Yo=new WeakMap,is=new WeakMap,wi=new WeakMap,oc=new WeakMap,bt=new WeakMap,$t=new WeakSet,Hs=function(t){nt(t<K.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=n(this,bt).getUint8(e)>>s&3;return i===0?void 0:i===2},Od=function(t){return nt(t<K.numbers.length,"Invalid number index"),n(this,bt).getFloat64(n(K,Wo)+t*8)},dh=function(t){nt(t<K.strings.length,"Invalid string index");let e=n(K,is)+4;for(let r=0;r<t;r++)e+=n(this,bt).getUint32(e)+4;const s=n(this,bt).getUint32(e),i=new Uint8Array(s);return i.set(new Uint8Array(n(this,wi),e+4,s)),n(this,oc).decode(i)},k(K,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),k(K,"numbers",["ascent","defaultWidth","descent"]),k(K,"strings",["fallbackName","loadedName","mimetype","name"]),g(K,Wo,Math.ceil(K.bools.length*2/8)),g(K,Xo,n(K,Wo)+K.numbers.length*8),g(K,qo,n(K,Xo)+1+8),g(K,Yo,n(K,qo)+1+48),g(K,is,n(K,Yo)+1+6);let Uf=K;var lc,hc;class Zs{static get workerPort(){return n(this,lc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,lc,t)}static get workerSrc(){return n(this,hc)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,hc,t)}}lc=new WeakMap,hc=new WeakMap,g(Zs,lc,null),g(Zs,hc,"");var Ko,cc;class AA{constructor({parsedData:t,rawData:e}){g(this,Ko);g(this,cc);p(this,Ko,t),p(this,cc,e)}getRaw(){return n(this,cc)}get(t){return n(this,Ko).get(t)??null}[Symbol.iterator](){return n(this,Ko).entries()}}Ko=new WeakMap,cc=new WeakMap;const no=Symbol("INTERNAL");var dc,uc,fc,Jo;class wA{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){g(this,dc,!1);g(this,uc,!1);g(this,fc,!1);g(this,Jo,!0);p(this,dc,!!(t&bs.DISPLAY)),p(this,uc,!!(t&bs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,fc))return n(this,Jo);if(!n(this,Jo))return!1;const{print:t,view:e}=this.usage;return n(this,dc)?(e==null?void 0:e.viewState)!=="OFF":n(this,uc)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==no&&_t("Internal method `_setVisible` called."),p(this,fc,s),p(this,Jo,e)}}dc=new WeakMap,uc=new WeakMap,fc=new WeakMap,Jo=new WeakMap;var Kn,yt,Qo,Zo,pc,jf;class vA{constructor(t,e=bs.DISPLAY){g(this,pc);g(this,Kn,null);g(this,yt,new Map);g(this,Qo,null);g(this,Zo,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Zo,t.order);for(const s of t.groups)n(this,yt).set(s.id,new wA(e,s));if(t.baseState==="OFF")for(const s of n(this,yt).values())s._setVisible(no,!1);for(const s of t.on)n(this,yt).get(s)._setVisible(no,!0);for(const s of t.off)n(this,yt).get(s)._setVisible(no,!1);p(this,Qo,this.getHash())}}isVisible(t){if(n(this,yt).size===0)return!0;if(!t)return Bu("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,yt).has(t.id)?n(this,yt).get(t.id).visible:(q(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,pc,jf).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(n(this,yt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!n(this,yt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!n(this,yt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(n(this,yt).get(e).visible)return!1}return!0}return q(`Unknown optional content policy ${t.policy}.`),!0}return q(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,yt).get(t);if(!i){q(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,yt).get(o))==null||r._setVisible(no,!1,!0));i._setVisible(no,!!e,!0),p(this,Kn,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,yt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,Kn,null)}get hasInitialVisibility(){return n(this,Qo)===null||this.getHash()===n(this,Qo)}getOrder(){return n(this,yt).size?n(this,Zo)?n(this,Zo).slice():[...n(this,yt).keys()]:null}getGroup(t){return n(this,yt).get(t)||null}getHash(){if(n(this,Kn)!==null)return n(this,Kn);const t=new Tm;for(const[e,s]of n(this,yt))t.update(`${e}:${s.visible}`);return p(this,Kn,t.hexdigest())}[Symbol.iterator](){return n(this,yt).entries()}}Kn=new WeakMap,yt=new WeakMap,Qo=new WeakMap,Zo=new WeakMap,pc=new WeakSet,jf=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=b(this,pc,jf).call(this,r);else if(n(this,yt).has(r))a=n(this,yt).get(r).visible;else return q(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class EA{constructor(t,{disableRange:e=!1,disableStream:s=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:r,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(r==null?void 0:r.length)>0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(s),!0)});nt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,r;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(r=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||r.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new SA(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new _A(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class SA{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Uu(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class _A{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function CA(d){let t=!0,e=s("filename\\*","i").exec(d);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(d),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(d),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,u){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(c,u){if(c){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(c,{fatal:!0}),m=cd(u);u=f.decode(m),t=!1}catch{}}return u}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function a(c){const u=[];let f;const m=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=m.exec(c))!==null;){let[,y,v,w]=f;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[v,w]}const A=[];for(let y=0;y<u.length&&y in u;++y){let[v,w]=u[y];w=o(w),v&&(w=unescape(w),y===0&&(w=l(w))),A.push(w)}return A.join("")}function o(c){if(c.startsWith('"')){const u=c.slice(1).split('\\"');for(let f=0;f<u.length;++f){const m=u[f].indexOf('"');m!==-1&&(u[f]=u[f].slice(0,m),u.length=f+1),u[f]=u[f].replaceAll(/\\(.)/g,"$1")}c=u.join('"')}return c}function l(c){const u=c.indexOf("'");if(u===-1)return c;const f=c.slice(0,u),A=c.slice(u+1).replace(/^[^']*'/,"");return i(f,A)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,f,m,A){if(m==="q"||m==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(y,v){return String.fromCharCode(parseInt(v,16))}),i(f,A);try{A=atob(A)}catch{}return i(f,A)})}return""}function Um(d,t){const e=new Headers;if(!d||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function ju(d){var t;return((t=URL.parse(d))==null?void 0:t.origin)??null}function jm({responseHeaders:d,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(d.get("Content-Length"),10);return!Number.isInteger(r)||(i.suggestedLength=r,r<=2*e)||s||!t||d.get("Accept-Ranges")!=="bytes"||(d.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function $m(d){const t=d.get("Content-Disposition");if(t){let e=CA(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Uu(e))return e}return null}function pd(d,t){return new Eh(`Unexpected server response (${d}) while retrieving PDF "${t}".`,d,d===404||d===0&&t.startsWith("file:"))}function zm(d){return d===200||d===206}function Gm(d,t,e){return{method:"GET",headers:d,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Vm(d){return d instanceof Uint8Array?d.buffer:d instanceof ArrayBuffer?d:(q(`getArrayBuffer - unexpected data format: ${d}`),new Uint8Array(d).buffer)}class xA{constructor(t){k(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Um(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new TA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new PA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class TA{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 s=new Headers(t.headers),i=e.url;fetch(i,Gm(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=ju(r.url),!zm(r.status))throw pd(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const a=r.headers,{allowRangeRequests:o,suggestedLength:l}=jm({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=$m(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Sn("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:Vm(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class PA{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,Gm(r,this._withCredentials,this._abortController)).then(o=>{const l=ju(o.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!zm(o.status))throw pd(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:Vm(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const ef=200,sf=206;function RA(d){const t=d.response;return typeof t!="string"?t:cd(t).buffer}class kA{constructor({url:t,httpHeaders:e,withCredentials:s}){k(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Um(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,a]of this.headers)e.setRequestHeader(r,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=sf):i.expectedStatus=ef,e.responseType="arraybuffer",nt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}const r=i.status||ef;if(!(r===ef&&s.expectedStatus===sf)&&r!==s.expectedStatus){s.onError(i.status);return}const o=RA(i);if(r===sf){const l=i.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?s.onDone({begin:parseInt(h[1],10),chunk:o}):(q('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):s.onError(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class DA{constructor(t){this._source=t,this._manager=new kA(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new MA(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new LA(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class MA{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(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=ju(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...h]=o.split(": ");return[l,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:a}=jm({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=$m(i),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(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=pd(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of 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 LA{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,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(){var e;const t=ju((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=pd(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const IA=/^[a-z][a-z0-9\-+.]+:/i;function FA(d){if(IA.test(d))return new URL(d);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(d))}class NA{constructor(t){this.source=t,this.url=FA(t.url),nt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new OA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new BA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class OA{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 s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=pd(0,this._url.href)),this._storedError=i,this._headersCapability.reject(i)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Sn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class BA{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Kl=Symbol("INITIAL_DATA");var ns,gc,$f;class Wm{constructor(){g(this,gc);g(this,ns,Object.create(null))}get(t,e=null){if(e){const i=b(this,gc,$f).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=n(this,ns)[t];if(!s||s.data===Kl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,ns)[t];return!!e&&e.data!==Kl}delete(t){const e=n(this,ns)[t];return!e||e.data===Kl?!1:(delete n(this,ns)[t],!0)}resolve(t,e=null){const s=b(this,gc,$f).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in n(this,ns)){const{data:s}=n(this,ns)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,ns,Object.create(null))}*[Symbol.iterator](){for(const t in n(this,ns)){const{data:e}=n(this,ns)[t];e!==Kl&&(yield[t,e])}}}ns=new WeakMap,gc=new WeakSet,$f=function(t){var e;return(e=n(this,ns))[t]||(e[t]={...Promise.withResolvers(),data:Kl})};const HA=1e5,Tg=30;var Hg,Jn,Xe,mc,bc,ha,nn,yc,Ac,ca,tl,el,Qn,sl,wc,il,da,vc,Ec,jt,nl,ua,Sc,Zn,rl,xn,Xm,qm,zf,ws,Bd,Gf,Ym,Km;let xh=(jt=class{constructor({textContentSource:t,container:e,viewport:s}){g(this,xn);g(this,Jn,Promise.withResolvers());g(this,Xe,null);g(this,mc,!1);g(this,bc,!!((Hg=globalThis.FontInspector)!=null&&Hg.enabled));g(this,ha,null);g(this,nn,null);g(this,yc,0);g(this,Ac,0);g(this,ca,null);g(this,tl,null);g(this,el,0);g(this,Qn,0);g(this,sl,Object.create(null));g(this,wc,[]);g(this,il,null);g(this,da,[]);g(this,vc,new WeakMap);g(this,Ec,null);var l;if(t instanceof ReadableStream)p(this,il,t);else if(typeof t=="object")p(this,il,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Xe,p(this,tl,e)),p(this,Qn,s.scale*ei.pixelRatio),p(this,el,s.rotation),p(this,nn,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:r,pageX:a,pageY:o}=s.rawDims;p(this,Ec,[1,0,0,-1,-a,o+r]),p(this,Ac,i),p(this,yc,r),b(l=jt,ws,Ym).call(l),_r(e,s),n(this,Jn).promise.finally(()=>{n(jt,rl).delete(this),p(this,nn,null),p(this,sl,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ce.platform;return J(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{n(this,ca).read().then(({value:e,done:s})=>{if(s){n(this,Jn).resolve();return}n(this,ha)??p(this,ha,e.lang),Object.assign(n(this,sl),e.styles),b(this,xn,Xm).call(this,e.items),t()},n(this,Jn).reject)};return p(this,ca,n(this,il).getReader()),n(jt,rl).add(this),t(),n(this,Jn).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*ei.pixelRatio,i=t.rotation;if(i!==n(this,el)&&(e==null||e(),p(this,el,i),_r(n(this,tl),{rotation:i})),s!==n(this,Qn)){e==null||e(),p(this,Qn,s);const a={div:null,properties:null,ctx:b(r=jt,ws,Bd).call(r,n(this,ha))};for(const o of n(this,da))a.properties=n(this,vc).get(o),a.div=o,b(this,xn,zf).call(this,a)}}cancel(){var e;const t=new Sn("TextLayer task cancelled.");(e=n(this,ca))==null||e.cancel(t).catch(()=>{}),p(this,ca,null),n(this,Jn).reject(t)}get textDivs(){return n(this,da)}get textContentItemsStr(){return n(this,wc)}static cleanup(){if(!(n(this,rl).size>0)){n(this,nl).clear();for(const{canvas:t}of n(this,ua).values())t.remove();n(this,ua).clear()}}},Jn=new WeakMap,Xe=new WeakMap,mc=new WeakMap,bc=new WeakMap,ha=new WeakMap,nn=new WeakMap,yc=new WeakMap,Ac=new WeakMap,ca=new WeakMap,tl=new WeakMap,el=new WeakMap,Qn=new WeakMap,sl=new WeakMap,wc=new WeakMap,il=new WeakMap,da=new WeakMap,vc=new WeakMap,Ec=new WeakMap,nl=new WeakMap,ua=new WeakMap,Sc=new WeakMap,Zn=new WeakMap,rl=new WeakMap,xn=new WeakSet,Xm=function(t){var i,r;if(n(this,mc))return;(r=n(this,nn)).ctx??(r.ctx=b(i=jt,ws,Bd).call(i,n(this,ha)));const e=n(this,da),s=n(this,wc);for(const a of t){if(e.length>HA){q("Ignoring additional textDivs for performance reasons."),p(this,mc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,Xe);p(this,Xe,document.createElement("span")),n(this,Xe).classList.add("markedContent"),a.id&&n(this,Xe).setAttribute("id",`${a.id}`),o.append(n(this,Xe))}else a.type==="endMarkedContent"&&p(this,Xe,n(this,Xe).parentNode);continue}s.push(a.str),b(this,xn,qm).call(this,a)}},qm=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,da).push(e);const i=H.transform(n(this,Ec),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,sl)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,bc)&&a.fontSubstitution||a.fontFamily;o=jt.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*b(y=jt,ws,Km).call(y,o,a,n(this,ha));let c,u;r===0?(c=i[4],u=i[5]-h):(c=i[4]+h*Math.sin(r),u=i[5]-h*Math.cos(r));const f="calc(var(--total-scale-factor) *",m=e.style;n(this,Xe)===n(this,tl)?(m.left=`${(100*c/n(this,Ac)).toFixed(2)}%`,m.top=`${(100*u/n(this,yc)).toFixed(2)}%`):(m.left=`${f}${c.toFixed(2)}px)`,m.top=`${f}${u.toFixed(2)}px)`),m.fontSize=`${f}${(n(jt,Zn)*l).toFixed(2)}px)`,m.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,bc)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const v=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,vc).set(e,s),n(this,nn).div=e,n(this,nn).properties=s,b(this,xn,zf).call(this,n(this,nn)),s.hasText&&n(this,Xe).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),n(this,Xe).append(v)}},zf=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:r}=e;let a="";if(n(jt,Zn)>1&&(a=`scale(${1/n(jt,Zn)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:h,fontSize:c}=s;b(o=jt,ws,Gf).call(o,i,c*n(this,Qn),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${h*n(this,Qn)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},ws=new WeakSet,Bd=function(t=null){let e=n(this,ua).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,ua).set(t,e),n(this,Sc).set(e,{size:0,family:""})}return e},Gf=function(t,e,s){const i=n(this,Sc).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Ym=function(){if(n(this,Zn)!==null)return;const 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),p(this,Zn,t.getBoundingClientRect().height),t.remove()},Km=function(t,e,s){const i=n(this,nl).get(t);if(i)return i;const r=b(this,ws,Bd).call(this,s);r.canvas.width=r.canvas.height=Tg,b(this,ws,Gf).call(this,r,Tg,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return o?h=o/(o+l):(ce.platform.isFirefox&&q("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),n(this,nl).set(t,h),h},g(jt,ws),g(jt,nl,new Map),g(jt,ua,new Map),g(jt,Sc,new WeakMap),g(jt,Zn,null),g(jt,rl,new Set),jt);const UA=100;function Gp(d={}){typeof d=="string"||d instanceof URL?d={url:d}:(d instanceof ArrayBuffer||ArrayBuffer.isView(d))&&(d={data:d});const t=new Vf,{docId:e}=t,s=d.url?qy(d.url):null,i=d.data?Yy(d.data):null,r=d.httpHeaders||null,a=d.withCredentials===!0,o=d.password??null,l=d.range instanceof Vp?d.range:null,h=Number.isInteger(d.rangeChunkSize)&&d.rangeChunkSize>0?d.rangeChunkSize:2**16;let c=d.worker instanceof zl?d.worker:null;const u=d.verbosity,f=typeof d.docBaseUrl=="string"&&!ud(d.docBaseUrl)?d.docBaseUrl:null,m=wd(d.cMapUrl),A=d.cMapPacked!==!1,y=d.CMapReaderFactory||(Be?sA:fg),v=wd(d.iccUrl),w=wd(d.standardFontDataUrl),S=d.StandardFontDataFactory||(Be?iA:pg),E=wd(d.wasmUrl),_=d.WasmFactory||(Be?nA:gg),C=d.stopAtErrors!==!0,x=Number.isInteger(d.maxImageSize)&&d.maxImageSize>-1?d.maxImageSize:-1,T=d.isEvalSupported!==!1,P=typeof d.isOffscreenCanvasSupported=="boolean"?d.isOffscreenCanvasSupported:!Be,R=typeof d.isImageDecoderSupported=="boolean"?d.isImageDecoderSupported:!Be&&(ce.platform.isFirefox||!globalThis.chrome),D=Number.isInteger(d.canvasMaxAreaInBytes)?d.canvasMaxAreaInBytes:-1,M=typeof d.disableFontFace=="boolean"?d.disableFontFace:Be,I=d.fontExtraProperties===!0,G=d.enableXfa===!0,N=d.ownerDocument||globalThis.document,W=d.disableRange===!0,O=d.disableStream===!0,F=d.disableAutoFetch===!0,tt=d.pdfBug===!0,it=d.CanvasFactory||(Be?eA:Qy),ee=d.FilterFactory||(Be?tA:Zy),Je=d.enableHWA===!0,rt=d.useWasm!==!1,ht=l?l.length:d.length??NaN,se=typeof d.useSystemFonts=="boolean"?d.useSystemFonts:!Be&&!M,de=typeof d.useWorkerFetch=="boolean"?d.useWorkerFetch:!!(y===fg&&S===pg&&_===gg&&m&&w&&E&&Zl(m,document.baseURI)&&Zl(w,document.baseURI)&&Zl(E,document.baseURI)),Ee=null;Ry(u);const wt={canvasFactory:new it({ownerDocument:N,enableHWA:Je}),filterFactory:new ee({docId:e,ownerDocument:N}),cMapReaderFactory:de?null:new y({baseUrl:m,isCompressed:A}),standardFontDataFactory:de?null:new S({baseUrl:w}),wasmFactory:de?null:new _({baseUrl:E})};c||(c=zl.create({verbosity:u,port:Zs.workerPort}),t._worker=c);const Os={docId:e,apiVersion:"5.4.296",data:i,password:o,disableAutoFetch:F,rangeChunkSize:h,length:ht,docBaseUrl:f,enableXfa:G,evaluatorOptions:{maxImageSize:x,disableFontFace:M,ignoreErrors:C,isEvalSupported:T,isOffscreenCanvasSupported:P,isImageDecoderSupported:R,canvasMaxAreaInBytes:D,fontExtraProperties:I,useSystemFonts:se,useWasm:rt,useWorkerFetch:de,cMapUrl:m,iccUrl:v,standardFontDataUrl:w,wasmUrl:E}},ii={ownerDocument:N,pdfBug:tt,styleElement:Ee,loadingParams:{disableAutoFetch:F,enableXfa:G}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Ii=c.messageHandler.sendWithPromise("GetDocRequest",Os,i?[i.buffer]:null);let Me;if(l)Me=new EA(l,{disableRange:W,disableStream:O});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");const Tt=Zl(s)?xA:Be?NA:DA;Me=new Tt({url:s,length:ht,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:W,disableStream:O})}return Ii.then(Tt=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Rt=new rh(e,Tt,c.port),Yt=new zA(Rt,t,Me,ii,wt,Je);t._transport=Yt,Rt.send("Ready",null)})}).catch(t._capability.reject),t}var Tu;const Pu=class Pu{constructor(){k(this,"_capability",Promise.withResolvers());k(this,"_transport",null);k(this,"_worker",null);k(this,"docId",`d${Kt(Pu,Tu)._++}`);k(this,"destroyed",!1);k(this,"onPassword",null);k(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Tu=new WeakMap,g(Pu,Tu,0);let Vf=Pu;var fa,_c,Cc,xc,Tc,Ug;let Vp=(Ug=class{constructor(t,e,s=!1,i=null){g(this,fa,Promise.withResolvers());g(this,_c,[]);g(this,Cc,[]);g(this,xc,[]);g(this,Tc,[]);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}addRangeListener(t){n(this,Tc).push(t)}addProgressListener(t){n(this,xc).push(t)}addProgressiveReadListener(t){n(this,Cc).push(t)}addProgressiveDoneListener(t){n(this,_c).push(t)}onDataRange(t,e){for(const s of n(this,Tc))s(t,e)}onDataProgress(t,e){n(this,fa).promise.then(()=>{for(const s of n(this,xc))s(t,e)})}onDataProgressiveRead(t){n(this,fa).promise.then(()=>{for(const e of n(this,Cc))e(t)})}onDataProgressiveDone(){n(this,fa).promise.then(()=>{for(const t of n(this,_c))t()})}transportReady(){n(this,fa).resolve()}requestDataRange(t,e){_t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},fa=new WeakMap,_c=new WeakMap,Cc=new WeakMap,xc=new WeakMap,Tc=new WeakMap,Ug);class jA{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 J(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{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()}}var rn,pa,uh;class $A{constructor(t,e,s,i=!1){g(this,pa);g(this,rn,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new ag:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Wm,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}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:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new dd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{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 J(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Di.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:f=!1,recordOperations:m=!1,operationsFilter:A=null}){var R,D,M;(R=this._stats)==null||R.time("Overall");const y=this._transport.getRenderingIntent(i,r,u,f),{renderingIntent:v,cacheKey:w}=y;p(this,rn,!1),l||(l=this._transport.getOptionalContentConfig(v));let S=this._intentStates.get(w);S||(S=Object.create(null),this._intentStates.set(w,S)),S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);const E=!!(v&bs.PRINT);S.displayReadyCapability||(S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(D=this._stats)==null||D.time("Page Request"),this._pumpOperatorList(y));const _=!!(this._pdfBug&&((M=globalThis.StepperManager)!=null&&M.enabled)),C=!this.recordedBBoxes&&(m||_),x=I=>{var G,N;if(S.renderTasks.delete(T),C){const W=(G=T.gfx)==null?void 0:G.dependencyTracker.take();W&&(T.stepper&&T.stepper.setOperatorBBoxes(W,T.gfx.dependencyTracker.takeDebugMetadata()),m&&(this.recordedBBoxes=W))}E&&p(this,rn,!0),b(this,pa,uh).call(this),I?(T.capability.reject(I),this._abortOperatorList({intentState:S,reason:I instanceof Error?I:new Error(I)})):T.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(N=globalThis.Stats)!=null&&N.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},T=new Wf({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:C?new aA(e,S.operatorList.length,_):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!E,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:A});(S.renderTasks||(S.renderTasks=new Set)).add(T);const P=T.task;return Promise.all([S.displayReadyCapability.promise,l]).then(([I,G])=>{var N;if(this.destroyed){x();return}if((N=this._stats)==null||N.time("Rendering"),!(G.renderingIntent&v))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");T.initializeGraphics({transparency:I,optionalContentConfig:G}),T.operatorListChanged()}).catch(x),P}getOperatorList({intent:t="display",annotationMode:e=Di.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Sh.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function r(){a.read().then(function({value:l,done:h}){if(h){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),r()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,rn,!1),Promise.all(t)}cleanup(t=!1){p(this,rn,!0);const e=b(this,pa,uh).call(this);return t&&e&&this._stats&&(this._stats=new ag),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,pa,uh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:u,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),c())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();b(this,pa,uh).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Hu){let i=UA;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 Sn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}rn=new WeakMap,pa=new WeakSet,uh=function(){if(!n(this,rn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,rn,!1),!0};var tr,Ws,an,ga,Ru,ma,ba,He,Hd,Jm,Qm,fh,al,Ud;const kt=class kt{constructor({name:t=null,port:e=null,verbosity:s=ky()}={}){g(this,He);g(this,tr,Promise.withResolvers());g(this,Ws,null);g(this,an,null);g(this,ga,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(kt,ba).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(kt,ba).set(e,this),b(this,He,Jm).call(this,e)}else b(this,He,Qm).call(this)}get promise(){return n(this,tr).promise}get port(){return n(this,an)}get messageHandler(){return n(this,Ws)}destroy(){var t,e;this.destroyed=!0,(t=n(this,ga))==null||t.terminate(),p(this,ga,null),n(kt,ba).delete(n(this,an)),p(this,an,null),(e=n(this,Ws))==null||e.destroy(),p(this,Ws,null)}static create(t){const e=n(this,ba).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new kt(t)}static get workerSrc(){if(Zs.workerSrc)return Zs.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return J(this,"_setupFakeWorkerGlobal",(async()=>n(this,al,Ud)?n(this,al,Ud):(await import(this.workerSrc)).WorkerMessageHandler)())}};tr=new WeakMap,Ws=new WeakMap,an=new WeakMap,ga=new WeakMap,Ru=new WeakMap,ma=new WeakMap,ba=new WeakMap,He=new WeakSet,Hd=function(){n(this,tr).resolve(),n(this,Ws).send("configure",{verbosity:this.verbosity})},Jm=function(t){p(this,an,t),p(this,Ws,new rh("main","worker",t)),n(this,Ws).on("ready",()=>{}),b(this,He,Hd).call(this)},Qm=function(){if(n(kt,ma)||n(kt,al,Ud)){b(this,He,fh).call(this);return}let{workerSrc:t}=kt;try{kt._isSameOrigin(window.location,t)||(t=kt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new rh("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,tr).reject(new Error("Worker was destroyed")):b(this,He,fh).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,ga)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,Ws,s),p(this,an,e),p(this,ga,e),b(this,He,Hd).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,He,fh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Bu("The worker has been disabled.")}b(this,He,fh).call(this)},fh=function(){n(kt,ma)||(q("Setting up fake worker."),p(kt,ma,!0)),kt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,tr).reject(new Error("Worker was destroyed"));return}const e=new Jy;p(this,an,e);const s=`fake${Kt(kt,Ru)._++}`,i=new rh(s+"_worker",s,e);t.setup(i,e),p(this,Ws,new rh(s,s+"_worker",e)),b(this,He,Hd).call(this)}).catch(t=>{n(this,tr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},al=new WeakSet,Ud=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},g(kt,al),g(kt,Ru,0),g(kt,ma,!1),g(kt,ba,new WeakMap),Be&&(p(kt,ma,!0),Zs.workerSrc||(Zs.workerSrc="./pdf.worker.mjs")),kt._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},kt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},kt.fromPort=t=>{if(Hy("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return kt.create(t)};let zl=kt;var on,vi,ol,ll,ln,ya,ph;class zA{constructor(t,e,s,i,r,a){g(this,ya);g(this,on,new Map);g(this,vi,new Map);g(this,ol,new Map);g(this,ll,new Map);g(this,ln,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Wm,this.fontLoader=new Wy({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=a,this.setupMessageHandler()}get annotationStorage(){return J(this,"annotationStorage",new jp)}getRenderingIntent(t,e=Di.ENABLE,s=null,i=!1,r=!1){let a=bs.DISPLAY,o=Rf;switch(t){case"any":a=bs.ANY;break;case"display":break;case"print":a=bs.PRINT;break;default:q(`getRenderingIntent - invalid intent: ${t}`)}const l=a&bs.PRINT&&s instanceof Rm?s:this.annotationStorage;switch(e){case Di.DISABLE:a+=bs.ANNOTATIONS_DISABLE;break;case Di.ENABLE:break;case Di.ENABLE_FORMS:a+=bs.ANNOTATIONS_FORMS;break;case Di.ENABLE_STORAGE:a+=bs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:q(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=bs.IS_EDITING),r&&(a+=bs.OPLIST);const{ids:h,hash:c}=l.modifiedIds,u=[a,o.hash,c];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,ln))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,vi).values())t.push(i._destroy());n(this,vi).clear(),n(this,ol).clear(),n(this,ll).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,on).clear(),this.filterFactory.destroy(),xh.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new Sn("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:a}){if(a){i.close();return}nt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=this._fullReader;return(!i||!r)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}nt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new jA(s,this))}),t.on("DocException",s=>{e._capability.reject(je(s))}),t.on("PasswordRequest",s=>{p(this,ln,Promise.withResolvers());try{if(!e.onPassword)throw je(s);const i=r=>{r instanceof Error?n(this,ln).reject(r):n(this,ln).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,ln).reject(i)}return n(this,ln).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,vi).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const u=r.error;q(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const o=new Uf(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(u,f)=>globalThis.FontInspector.fontAdded(u,f):null,h=new Xy(o,l,r.extra,r.charProcOperatorList);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h.fontExtraProperties&&h.data&&h.clearData(),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:c}=r;nt(c,"The imageRef must be defined.");for(const u of n(this,vi).values())for(const[,f]of u.objs)if((f==null?void 0:f.ref)===c)return f.dataLen?(this.commonObjs.resolve(s,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,vi).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");const i=this[s.type];if(!i)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return i.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&q("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=n(this,ol).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&n(this,ll).set(r.refStr,t);const a=new $A(e,r,this,this._params.pdfBug);return n(this,vi).set(e,a),a});return n(this,ol).set(e,i),i}getPageIndex(t){return kf(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return b(this,ya,ph).call(this,"GetFieldObjects")}hasJSActions(){return b(this,ya,ph).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return b(this,ya,ph).call(this,"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 b(this,ya,ph).call(this,"GetOptionalContentConfig").then(e=>new vA(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=n(this,on).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var r,a;return{info:i[0],metadata:i[1]?new AA(i[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return n(this,on).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,vi).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,on).clear(),this.filterFactory.destroy(!0),xh.cleanup()}}cachedPageNumber(t){if(!kf(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return n(this,ll).get(e)??null}}on=new WeakMap,vi=new WeakMap,ol=new WeakMap,ll=new WeakMap,ln=new WeakMap,ya=new WeakSet,ph=function(t,e=null){const s=n(this,on).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return n(this,on).set(t,i),i};var er;class GA{constructor(t){g(this,er,null);k(this,"onContinue",null);k(this,"onError",null);p(this,er,t)}get promise(){return n(this,er).capability.promise}cancel(t=0){n(this,er).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=n(this,er).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=n(this,er);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}er=new WeakMap;var sr,Aa;const Lr=class Lr{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:f=null,enableHWA:m=!1,operationsFilter:A=null}){g(this,sr,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new GA(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=m,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=A}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var l,h;if(this.cancelled)return;if(this._canvas){if(n(Lr,Aa).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(Lr,Aa).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new fo(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,sr)&&(window.cancelAnimationFrame(n(this,sr)),p(this,sr,null)),n(Lr,Aa).delete(this._canvas),t||(t=new Hu(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.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?p(this,sr,window.requestAnimationFrame(()=>{p(this,sr,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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(Lr,Aa).delete(this._canvas),this.callback())))}};sr=new WeakMap,Aa=new WeakMap,g(Lr,Aa,new WeakSet);let Wf=Lr;const Zm="5.4.296",tb="f56dc8601";var rs,wa,hl,Zt,Pc,cl,hn,Rc,ir,Xs,kc,At,Xf,qf,Yf,Rr,eb,Rn;const $e=class $e{constructor({editor:t=null,uiManager:e=null}){g(this,At);g(this,rs,null);g(this,wa,null);g(this,hl);g(this,Zt,null);g(this,Pc,!1);g(this,cl,!1);g(this,hn,null);g(this,Rc);g(this,ir,null);g(this,Xs,null);var s,i;t?(p(this,cl,!1),p(this,hn,t)):p(this,cl,!0),p(this,Xs,(t==null?void 0:t._uiManager)||e),p(this,Rc,n(this,Xs)._eventBus),p(this,hl,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Xs))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n($e,kc)||p($e,kc,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"}))}static get _keyboardManager(){return J(this,"_keyboardManager",new fd([[["Escape","mac+Escape"],$e.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],$e.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],$e.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],$e.prototype._moveToPrevious],[["Home","mac+Home"],$e.prototype._moveToBeginning],[["End","mac+End"],$e.prototype._moveToEnd]]))}renderButton(){const t=p(this,rs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,hn)&&(t.ariaControls=`${n(this,hn).id}_colorpicker_dropdown`);const e=n(this,Xs)._signal;t.addEventListener("click",b(this,At,Rr).bind(this),{signal:e}),t.addEventListener("keydown",b(this,At,Yf).bind(this),{signal:e});const s=p(this,wa,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,hl),t.append(s),t}renderMainDropdown(){const t=p(this,Zt,b(this,At,Xf).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,rs)){b(this,At,Rr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,At,qf).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,At,Rn)){b(this,At,Rr).call(this,t);return}if(t.target===n(this,rs)){(e=n(this,Zt).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,Zt))==null?void 0:e.firstChild)||t.target===n(this,rs)){n(this,At,Rn)&&this._hideDropdownFromKeyboard();return}n(this,At,Rn)||b(this,At,Rr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,At,Rn)){b(this,At,Rr).call(this,t);return}(e=n(this,Zt).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,At,Rn)){b(this,At,Rr).call(this,t);return}(e=n(this,Zt).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,Zt))==null||t.classList.add("hidden"),n(this,rs).ariaExpanded="false",(e=n(this,ir))==null||e.abort(),p(this,ir,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,cl)){if(!n(this,At,Rn)){(t=n(this,hn))==null||t.unselect();return}this.hideDropdown(),n(this,rs).focus({preventScroll:!0,focusVisible:n(this,Pc)})}}updateColor(t){if(n(this,wa)&&(n(this,wa).style.backgroundColor=t),!n(this,Zt))return;const e=n(this,Xs).highlightColors.values();for(const s of n(this,Zt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,rs))==null||t.remove(),p(this,rs,null),p(this,wa,null),(e=n(this,Zt))==null||e.remove(),p(this,Zt,null)}};rs=new WeakMap,wa=new WeakMap,hl=new WeakMap,Zt=new WeakMap,Pc=new WeakMap,cl=new WeakMap,hn=new WeakMap,Rc=new WeakMap,ir=new WeakMap,Xs=new WeakMap,kc=new WeakMap,At=new WeakSet,Xf=function(){const t=document.createElement("div"),e=n(this,Xs)._signal;t.addEventListener("contextmenu",vs,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,hn)&&(t.id=`${n(this,hn).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Xs).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n($e,kc)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,hl),r.addEventListener("click",b(this,At,qf).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,At,Yf).bind(this),{signal:e}),t},qf=function(t,e){e.stopPropagation(),n(this,Rc).dispatch("switchannotationeditorparams",{source:this,type:st.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},Yf=function(t){$e._keyboardManager.exec(this,t)},Rr=function(t){if(n(this,At,Rn)){this.hideDropdown();return}if(p(this,Pc,t.detail===0),n(this,ir)||(p(this,ir,new AbortController),window.addEventListener("pointerdown",b(this,At,eb).bind(this),{signal:n(this,Xs).combinedSignal(n(this,ir))})),n(this,rs).ariaExpanded="true",n(this,Zt)){n(this,Zt).classList.remove("hidden");return}const e=p(this,Zt,b(this,At,Xf).call(this));n(this,rs).append(e)},eb=function(t){var e;(e=n(this,Zt))!=null&&e.contains(t.target)||this.hideDropdown()},Rn=function(){return n(this,Zt)&&!n(this,Zt).classList.contains("hidden")},g($e,kc,null);let Th=$e;var Ei,Dc,dl,Mc;const Ir=class Ir{constructor(t){g(this,Ei,null);g(this,Dc,null);g(this,dl,null);p(this,Dc,t),p(this,dl,t._uiManager),n(Ir,Mc)||p(Ir,Mc,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,Ei))return n(this,Ei);const{editorType:t,colorType:e,colorValue:s}=n(this,Dc),i=p(this,Ei,document.createElement("input"));return i.type="color",i.value=s||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",n(Ir,Mc)[t]),i.addEventListener("input",()=>{n(this,dl).updateParams(e,i.value)},{signal:n(this,dl)._signal}),i}update(t){n(this,Ei)&&(n(this,Ei).value=t)}destroy(){var t;(t=n(this,Ei))==null||t.remove(),p(this,Ei,null)}hideDropdown(){}};Ei=new WeakMap,Dc=new WeakMap,dl=new WeakMap,Mc=new WeakMap,g(Ir,Mc,null);let uu=Ir;function Pg(d){return Math.floor(Math.max(0,Math.min(1,d))*255).toString(16).padStart(2,"0")}function Jl(d){return Math.max(0,Math.min(255,255*d))}class Rg{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=Jl(t),[t,t,t]}static G_HTML([t]){const e=Pg(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Jl)}static RGB_HTML(t){return`#${t.map(Pg).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Jl(1-Math.min(1,t+i)),Jl(1-Math.min(1,s+i)),Jl(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class VA{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){_t("Abstract method `_createSVG` called.")}}class Ph extends VA{_createSVG(t){return document.createElementNS(Fi,t)}}const WA=9,Xa=new WeakSet,XA=new Date().getTimezoneOffset()*60*1e3;class kg{static create(t){switch(t.data.annotationType){case zt.LINK:return new Wp(t);case zt.TEXT:return new YA(t);case zt.WIDGET:switch(t.data.fieldType){case"Tx":return new KA(t);case"Btn":return t.data.radioButton?new nb(t):t.data.checkBox?new QA(t):new ZA(t);case"Ch":return new tw(t);case"Sig":return new JA(t)}return new Ka(t);case zt.POPUP:return new Jf(t);case zt.FREETEXT:return new hb(t);case zt.LINE:return new sw(t);case zt.SQUARE:return new iw(t);case zt.CIRCLE:return new nw(t);case zt.POLYLINE:return new cb(t);case zt.CARET:return new aw(t);case zt.INK:return new Xp(t);case zt.POLYGON:return new rw(t);case zt.HIGHLIGHT:return new db(t);case zt.UNDERLINE:return new ow(t);case zt.SQUIGGLY:return new lw(t);case zt.STRIKEOUT:return new hw(t);case zt.STAMP:return new ub(t);case zt.FILEATTACHMENT:return new cw(t);default:return new Ot(t)}}}var va,ul,Ms,Lc,Kf;const sg=class sg{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){g(this,Lc);g(this,va,null);g(this,ul,!1);g(this,Ms,null);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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return sg._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let h=0,c=l.length;h<c;h+=2)l[h+1]>a?(a=l[h+1],r=l[h]):l[h+1]===a&&(r=Math.max(r,l[h]));if(r!==1/0)return[r,a]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/i,t}get commentText(){var e,s,i;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${vh}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((i=t.contentsObj)==null?void 0:i.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${vh}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=n(this,Ms))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,Ms,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,va)||p(this,va,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,Lc,Kf).call(this,e);let i=((r=n(this,Ms))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,Ms).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,Ms,null),this.popup=null))}resetEdited(){var t;n(this,va)&&(b(this,Lc,Kf).call(this,n(this,va).rect),(t=n(this,Ms))==null||t.popup.resetEdited(),p(this,va,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Ka)&&!(this instanceof Wp)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof Jf){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(y>0||v>0){const S=`calc(${y}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=S}else if(this instanceof nb){const S=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case Za.SOLID:a.borderStyle="solid";break;case Za.DASHED:a.borderStyle="dashed";break;case Za.BEVELED:q("Unimplemented border style: beveled");break;case Za.INSET:q("Unimplemented border style: inset");break;case Za.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(p(this,ul,!0),a.borderColor=H.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):a.borderWidth=0}const h=H.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:u,pageX:f,pageY:m}=i.rawDims;a.left=`${100*(h[0]-f)/c}%`,a.top=`${100*(h[1]-m)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/c}%`,a.height=`${100*l/u}%`):this.setRotation(A,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=Rg[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Rg[`${a}_rgb`](o)})};return J(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||s[i];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,v,w,S]=t.subarray(2,6);if(i===y&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(n(this,ul)){const{borderColor:y,borderWidth:v}=a;a.borderWidth=0,o=["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="${y}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=i-e,h=r-s,{svgFactory:c}=this,u=c.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";const f=c.createElement("defs");u.append(f);const m=c.createElement("clipPath"),A=`clippath_${this.data.id}`;m.setAttribute("id",A),m.setAttribute("clipPathUnits","objectBoundingBox"),f.append(m);for(let y=2,v=t.length;y<v;y+=8){const w=t[y],S=t[y+1],E=t[y+2],_=t[y+3],C=c.createElement("rect"),x=(E-e)/l,T=(r-S)/h,P=(w-E)/l,R=(S-_)/h;C.setAttribute("x",x),C.setAttribute("y",T),C.setAttribute("width",P),C.setAttribute("height",R),m.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${T}" width="${P}" height="${R}"/>`)}n(this,ul)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate);const r=p(this,Ms,new Jf({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(r.render())}get hasPopupElement(){return!!(n(this,Ms)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,Ms)}render(){_t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!Xa.has(h)){q(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&Xa.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};va=new WeakMap,ul=new WeakMap,Ms=new WeakMap,Lc=new WeakSet,Kf=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let Ot=sg;class qA extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}var As,kr,sb,ib;class Wp extends Ot{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});g(this,As);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(b(this,As,sb).call(this,i,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,As,ib).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(i),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,As,kr).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),b(this,As,kr).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),b(this,As,kr).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,As,kr).call(this),!this._fieldObjects){q('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const m of r){const A=this._fieldObjects[m]||[];for(const{id:y}of A)f.add(y)}for(const m of Object.values(this._fieldObjects))for(const A of m)f.has(A.id)===o&&l.push(A)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const h=this.annotationStorage,c=[];for(const f of l){const{id:m}=f;switch(c.push(m),f.type){case"text":{const y=f.defaultValue||"";h.setValue(m,{value:y});break}case"checkbox":case"radiobutton":{const y=f.defaultValue===f.exportValues;h.setValue(m,{value:y});break}case"combobox":case"listbox":{const y=f.defaultValue||"";h.setValue(m,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${m}"]`);if(A){if(!Xa.has(A)){q(`_bindResetFormAction - element not allowed: ${m}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}As=new WeakSet,kr=function(){this.container.setAttribute("data-internal-link","")},sb=function(e,s,i="",r=null){e.href=this.linkService.getAnchorUrl(""),s.description?e.title=s.description:i&&(e.title=i),e.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(s.content,s.filename,r),!1},b(this,As,kr).call(this)},ib=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,As,kr).call(this)};class YA extends Ot{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const 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 Ka extends Ot{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ce.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,i),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":H.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||WA,r=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/(Yu*i))||1,u=h/c;a=Math.min(i,l(u/Yu))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/Yu))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=H.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class KA extends Ka{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
1
+ "use strict";var xy=Object.defineProperty;var ig=d=>{throw TypeError(d)};var Ty=(d,t,e)=>t in d?xy(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var k=(d,t,e)=>Ty(d,typeof t!="symbol"?t+"":t,e),Xu=(d,t,e)=>t.has(d)||ig("Cannot "+e);var n=(d,t,e)=>(Xu(d,t,"read from private field"),e?e.call(d):t.get(d)),g=(d,t,e)=>t.has(d)?ig("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,e),p=(d,t,e,s)=>(Xu(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e),b=(d,t,e)=>(Xu(d,t,"access private method"),e);var Kt=(d,t,e,s)=>({set _(i){p(d,t,i,e)},get _(){return n(d,t,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ct=require("./jsx-runtime-BB_1_6y_.cjs"),$=require("react"),Gl=require("clsx");var qu=typeof document<"u"?document.currentScript:null;function Py(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}const Be=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),lf=[.001,0,0,.001,0,0],Yu=1.35,bs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Di={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},vh="pdfjs_internal_editor_",X={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},st={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},jg={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ue={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},wh={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},zt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Za={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},hd={ERRORS:0,WARNINGS:1,INFOS:5},$l={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,rawFillPath:94},yd={moveTo:0,lineTo:1,curveTo:2,closePath:3},$g={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Ou=hd.WARNINGS;function Ry(d){Number.isInteger(d)&&(Ou=d)}function ky(){return Ou}function Bu(d){Ou>=hd.INFOS&&console.info(`Info: ${d}`)}function q(d){Ou>=hd.WARNINGS&&console.warn(`Warning: ${d}`)}function _t(d){throw new Error(d)}function nt(d,t){d||_t(t)}function Dy(d){switch(d==null?void 0:d.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Fp(d,t=null,e=null){if(!d)return null;if(e&&typeof d=="string"){if(e.addDefaultProtocol&&d.startsWith("www.")){const i=d.match(/\./g);(i==null?void 0:i.length)>=2&&(d=`http://${d}`)}if(e.tryConvertEncoding)try{d=Ny(d)}catch{}}const s=t?URL.parse(d,t):URL.parse(d);return Dy(s)?s:null}function Np(d,t,e=!1){const s=URL.parse(d);return s?(s.hash=t,s.href):e&&Fp(d,"http://example.com")?d.split("#",1)[0]+`${t?`#${t}`:""}`:""}function J(d,t,e,s=!1){return Object.defineProperty(d,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Ya=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class ng extends Ya{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ku extends Ya{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class au extends Ya{constructor(t){super(t,"InvalidPDFException")}}class Eh extends Ya{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class My extends Ya{constructor(t){super(t,"FormatError")}}class Sn extends Ya{constructor(t){super(t,"AbortException")}}function zg(d){(typeof d!="object"||(d==null?void 0:d.length)===void 0)&&_t("Invalid argument for bytesToString");const t=d.length,e=8192;if(t<e)return String.fromCharCode.apply(null,d);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=d.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function cd(d){typeof d!="string"&&_t("Invalid argument for stringToBytes");const t=d.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=d.charCodeAt(s)&255;return e}function Ly(d){return String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,d&255)}function Iy(){const d=new Uint8Array(4);return d[0]=1,new Uint32Array(d.buffer,0,1)[0]===1}function Fy(){try{return new Function(""),!0}catch{return!1}}class ce{static get isLittleEndian(){return J(this,"isLittleEndian",Iy())}static get isEvalSupported(){return J(this,"isEvalSupported",Fy())}static get isOffscreenCanvasSupported(){return J(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return J(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return J(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return J(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Ju=Array.from(Array(256).keys(),d=>d.toString(16).padStart(2,"0"));var vn,Pd,hf;class H{static makeHexColor(t,e,s){return`#${Ju[t]}${Ju[e]}${Ju[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5];for(let c=0;c<6;c+=2){const u=t[s+c],f=t[s+c+1];t[s+c]=u*i+f*a+l,t[s+c+1]=u*r+f*o+h}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5],c=t[0],u=t[1],f=t[2],m=t[3];let A=i*c+l,y=A,v=i*f+l,w=v,S=o*u+h,E=S,_=o*m+h,C=_;if(r!==0||a!==0){const x=r*c,T=r*f,P=a*u,R=a*m;A+=P,w+=P,v+=R,y+=R,S+=x,C+=x,_+=T,E+=T}s[0]=Math.min(s[0],A,v,y,w),s[1]=Math.min(s[1],S,_,E,C),s[2]=Math.max(s[2],A,v,y,w),s[3]=Math.max(s[3],S,_,E,C)}static inverseTransform(t){const 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,e){const s=t[0],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,h=r**2+a**2,c=(o+h)/2,u=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+u||1),e[1]=Math.sqrt(c-u||1)}static normalizeRect(t){const 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){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,r,a,o,l,h){h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l),b(this,vn,hf).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),b(this,vn,hf).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h)}}vn=new WeakSet,Pd=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const u=1-h,f=h*h,m=f*h,A=u*(u*(u*t+3*h*e)+3*f*s)+m*i,y=u*(u*(u*r+3*h*a)+3*f*o)+m*l;c[0]=Math.min(c[0],A),c[1]=Math.min(c[1],y),c[2]=Math.max(c[2],A),c[3]=Math.max(c[3],y)},hf=function(t,e,s,i,r,a,o,l,h,c,u,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,vn,Pd).call(this,t,e,s,i,r,a,o,l,-u/c,f);return}const m=c**2-4*u*h;if(m<0)return;const A=Math.sqrt(m),y=2*h;b(this,vn,Pd).call(this,t,e,s,i,r,a,o,l,(-c+A)/y,f),b(this,vn,Pd).call(this,t,e,s,i,r,a,o,l,(-c-A)/y,f)},g(H,vn);function Ny(d){return decodeURIComponent(escape(d))}let Qu=null,rg=null;function Gg(d){return Qu||(Qu=/([\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,rg=new Map([["ſt","ſt"]])),d.replaceAll(Qu,(t,e,s)=>e?e.normalize("NFKC"):rg.get(s))}function Op(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),zg(d)}const Bp="pdfjs_internal_id_";function Oy(d,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!d(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}function De(d,t,e){return Math.min(Math.max(d,t),e)}function Vg(d){return Uint8Array.prototype.toBase64?d.toBase64():btoa(zg(d))}function By(d){return Uint8Array.fromBase64?Uint8Array.fromBase64(d):cd(atob(d))}typeof Promise.try!="function"&&(Promise.try=function(d,...t){return new Promise(e=>{e(d(...t))})});typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(d){return d.reduce((t,e)=>t+e,0)});class Sh{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Sh.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class Hp{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=m}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const m=document.createTextNode(i.value);a.append(m),o&&Sh.shouldBuildText(i.name)&&h.push(m)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[m,A,y]=c.at(-1);if(A+1===m.children.length){c.pop();continue}const v=m.children[++c.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const E=document.createTextNode(v.value);h.push(E),y.append(E);continue}const S=(u=v==null?void 0:v.attributes)!=null&&u.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(y.append(S),v.attributes&&this.setAttributes({html:S,element:v,storage:e,intent:r,linkService:s}),((f=v.children)==null?void 0:f.length)>0)c.push([v,-1,S]);else if(v.value){const E=document.createTextNode(v.value);o&&Sh.shouldBuildText(w)&&h.push(E),S.append(E)}}for(const m of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Fi="http://www.w3.org/2000/svg",Mr=class Mr{};k(Mr,"CSS",96),k(Mr,"PDF",72),k(Mr,"PDF_TO_CSS_UNITS",Mr.CSS/Mr.PDF);let _n=Mr;async function Vl(d,t="text"){if(Zl(d,document.baseURI)){const e=await fetch(d);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",d,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class dd{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,u,f,m;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,u=0,f=0,m=1;break;case 90:c=0,u=1,f=1,m=0;break;case 270:c=0,u=-1,f=-1,m=0;break;case 0:c=1,u=0,f=0,m=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,m=-m);let A,y,v,w;c===0?(A=Math.abs(h-t[1])*s+r,y=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(A=Math.abs(l-t[0])*s+r,y=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,u*s,f*s,m*s,A-c*s*l-f*s*h,y-u*s*l-m*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return J(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new dd({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return H.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];H.applyTransform(e,this.transform);const s=[t[2],t[3]];return H.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return H.applyInverseTransform(s,this.transform),s}}class Hu extends Ya{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ud(d){const t=d.length;let e=0;for(;e<t&&d[e].trim()==="";)e++;return d.substring(e,e+5).toLowerCase()==="data:"}function Uu(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function Wg(d){return[d]=d.split(/[#?]/,1),d.substring(d.lastIndexOf("/")+1)}function Xg(d,t="document.pdf"){if(typeof d!="string")return t;if(ud(d))return q('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(d);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:o):l}catch{return o}},r=/\.pdf$/i,a=s.pathname.split("/").at(-1);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=Array.from(s.searchParams.values()).reverse();for(const h of o)if(r.test(h))return i(h);const l=Array.from(s.searchParams.keys()).reverse();for(const h of l)if(r.test(h))return i(h)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return t}class ag{constructor(){k(this,"started",Object.create(null));k(this,"times",[])}time(t){t in this.started&&q(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||q(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:r}of this.times)t.push(`${s.padEnd(e)} ${r-i}ms
2
+ `);return t.join("")}}function Zl(d,t){const e=t?URL.parse(d,t):URL.parse(d);return(e==null?void 0:e.protocol)==="http:"||(e==null?void 0:e.protocol)==="https:"}function vs(d){d.preventDefault()}function Nt(d){d.preventDefault(),d.stopPropagation()}function Hy(d){console.log("Deprecated API usage: "+d)}var Rh;class _h{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,Rh)||p(this,Rh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,Rh).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(a+=c,o+=u):h==="+"&&(a-=c,o-=u),new Date(Date.UTC(s,i,r,a,o,l))}}Rh=new WeakMap,g(_h,Rh);function qg(d,{scale:t=1,rotation:e=0}){const{width:s,height:i}=d.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new dd({viewBox:r,userUnit:1,scale:t,rotation:e})}function Wl(d){if(d.startsWith("#")){const t=parseInt(d.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return d.startsWith("rgb(")?d.slice(4,-1).split(",").map(t=>parseInt(t)):d.startsWith("rgba(")?d.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(q(`Not a valid color format: "${d}"`),[0,0,0])}function Uy(d){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of d.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;d.set(e,Wl(s))}t.remove()}function Ft(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform();return[t,e,s,i,r,a]}function ni(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform().invertSelf();return[t,e,s,i,r,a]}function _r(d,t,e=!1,s=!0){if(t instanceof dd){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=d,o=ce.isCSSRoundSupported,l=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${r}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,u=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=u):(a.width=u,a.height=c)}s&&d.setAttribute("data-main-rotation",t.rotation)}class ei{constructor(){const{pixelRatio:t}=ei;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=ei.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const h=Math.min(a,o,l);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const ou=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class jy{static get isDarkMode(){var t;return J(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class Yg{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),J(this,"commentForegroundColor",Wl(s))}}function Kg(d,t,e,s){s=Math.min(Math.max(s??1,0),1);const i=255*(1-s);return d=Math.round(d*s+i),t=Math.round(t*s+i),e=Math.round(e*s+i),[d,t,e]}function og(d,t){const e=d[0]/255,s=d[1]/255,i=d[2]/255,r=Math.max(e,s,i),a=Math.min(e,s,i),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-i)/l+(s<i?6:0))*60;break;case s:t[0]=((i-e)/l+2)*60;break;case i:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function cf(d,t){const e=d[0],s=d[1],i=d[2],r=(1-Math.abs(2*i-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=i-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function lg(d){return d<=.03928?d/12.92:((d+.055)/1.055)**2.4}function hg(d,t,e){cf(d,e),e.map(lg);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];cf(t,e),e.map(lg);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const cg=new Map;function Jg(d,t){const e=d[0]+d[1]*256+d[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=cg.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);og(d,a);const o=i.subarray(6,9);og(t,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),hg(a,o,r)<h){let c,u;l?(c=a[2],u=1):(c=0,u=a[2]);const f=.005;for(;u-c>f;){const m=a[2]=(c+u)/2;l===hg(a,o,r)<h?c=m:u=m}a[2]=l?u:c}return cf(a,r),s=H.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),cg.set(e,s),s}function Up({html:d,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof d=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=d.split(/(?:\r\n?|\n)/);for(let o=0,l=a.length;o<l;++o){const h=a[o];r.append(document.createTextNode(h)),o<l-1&&r.append(document.createElement("br"))}i.append(r)}else Hp.render({xfaHtml:d,div:i,intent:"richText"});i.firstChild.classList.add("richText",e),s.append(i)}var kn,Dn,_s,Cs,kh,Mn,mo,bo,Dh,yu,Qg,ve,Zg,tm,to,th;const Bi=class Bi{constructor(t){g(this,ve);g(this,kn,null);g(this,Dn,null);g(this,_s);g(this,Cs,null);g(this,kh,null);g(this,Mn,null);g(this,mo,null);g(this,bo,null);p(this,_s,t),n(Bi,Dh)||p(Bi,Dh,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",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=p(this,kn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,_s)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",vs,{signal:e}),t.addEventListener("pointerdown",b(Bi,yu,Qg),{signal:e}));const s=p(this,Cs,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,_s).toolbarPosition;if(i){const{style:r}=t,a=n(this,_s)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return n(this,kn)}hide(){var t;n(this,kn).classList.add("hidden"),(t=n(this,Dn))==null||t.hideDropdown()}show(){var t,e;n(this,kn).classList.remove("hidden"),(t=n(this,kh))==null||t.shown(),(e=n(this,Mn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,_s),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Bi,Dh)[t]),b(this,ve,to).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,Cs).append(s)}async addAltText(t){const e=await t.render();b(this,ve,to).call(this,e),n(this,Cs).append(e,n(this,ve,th)),p(this,kh,t)}addComment(t,e=null){if(n(this,Mn))return;const s=t.renderForToolbar();if(!s)return;b(this,ve,to).call(this,s);const i=p(this,mo,n(this,ve,th));e?(n(this,Cs).insertBefore(s,e),n(this,Cs).insertBefore(i,e)):n(this,Cs).append(s,i),p(this,Mn,t),t.toolbar=this}addColorPicker(t){if(n(this,Dn))return;p(this,Dn,t);const e=t.renderButton();b(this,ve,to).call(this,e),n(this,Cs).append(e,n(this,ve,th))}async addEditSignatureButton(t){const e=p(this,bo,await t.renderEditButton(n(this,_s)));b(this,ve,to).call(this,e),n(this,Cs).append(e,n(this,ve,th))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Mn))==null||e.removeToolbarCommentButton(),p(this,Mn,null),(s=n(this,mo))==null||s.remove(),p(this,mo,null);break}}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e);break}}async addButtonBefore(t,e,s){const i=n(this,Cs).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,bo)&&(n(this,bo).title=t)}remove(){var t;n(this,kn).remove(),(t=n(this,Dn))==null||t.destroy(),p(this,Dn,null)}};kn=new WeakMap,Dn=new WeakMap,_s=new WeakMap,Cs=new WeakMap,kh=new WeakMap,Mn=new WeakMap,mo=new WeakMap,bo=new WeakMap,Dh=new WeakMap,yu=new WeakSet,Qg=function(t){t.stopPropagation()},ve=new WeakSet,Zg=function(t){n(this,_s)._focusEventsAllowed=!1,Nt(t)},tm=function(t){n(this,_s)._focusEventsAllowed=!0,Nt(t)},to=function(t){const e=n(this,_s)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,ve,Zg).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,ve,tm).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",vs,{signal:e}),!0)},th=function(){const t=document.createElement("div");return t.className="divider",t},g(Bi,yu),g(Bi,Dh,null);let df=Bi;var Mh,Fr,Ui,Cn,em,sm,uf;class $y{constructor(t){g(this,Cn);g(this,Mh,null);g(this,Fr,null);g(this,Ui);p(this,Ui,t)}show(t,e,s){const[i,r]=b(this,Cn,sm).call(this,e,s),{style:a}=n(this,Fr)||p(this,Fr,b(this,Cn,em).call(this));t.append(n(this,Fr)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Fr).remove()}}Mh=new WeakMap,Fr=new WeakMap,Ui=new WeakMap,Cn=new WeakSet,em=function(){const t=p(this,Fr,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,Ui)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",vs,{signal:e});const s=p(this,Mh,document.createElement("div"));return s.className="buttons",t.append(s),n(this,Ui).hasCommentManager()&&b(this,Cn,uf).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,Ui).commentSelection("floating_button")}),b(this,Cn,uf).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,Ui).highlightSelection("floating_button")}),t},sm=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},uf=function(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=n(this,Ui)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",vs,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,Mh).append(r)};function im(d,t,e){for(const s of e)t.addEventListener(s,d[s].bind(d))}var Au;class zy{constructor(){g(this,Au,0)}get id(){return`${vh}${Kt(this,Au)._++}`}}Au=new WeakMap;var yo,Lh,Ce,Ao,Rd;const Qp=class Qp{constructor(){g(this,Ao);g(this,yo,Op());g(this,Lh,0);g(this,Ce,null)}static get _isSVGFittingCanvas(){const t='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=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return J(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,Ao,Rd).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,Ao,Rd).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,Ao,Rd).call(this,t,s)}async getFromId(t){n(this,Ce)||p(this,Ce,new Map);const e=n(this,Ce).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){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,Ce)||p(this,Ce,new Map);let s=n(this,Ce).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,yo)}_${Kt(this,Lh)._++}`,refCounter:1,isSvg:!1},n(this,Ce).set(t,s),n(this,Ce).set(s.id,s),s}getSvgUrl(t){const e=n(this,Ce).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Ce)||p(this,Ce,new Map);const e=n(this,Ce).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,yo)}_`)}};yo=new WeakMap,Lh=new WeakMap,Ce=new WeakMap,Ao=new WeakSet,Rd=async function(t,e){n(this,Ce)||p(this,Ce,new Map);let s=n(this,Ce).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,yo)}_${Kt(this,Lh)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Vl(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Qp._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=c});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){q(i),s=null}return n(this,Ce).set(t,s),s&&n(this,Ce).set(s.id,s),s};let ff=Qp;var Gt,Ln,Ih,It;class Gy{constructor(t=128){g(this,Gt,[]);g(this,Ln,!1);g(this,Ih);g(this,It,-1);p(this,Ih,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Ln))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,It)===-1){n(this,Gt).length>0&&(n(this,Gt).length=0),p(this,It,0),n(this,Gt).push(l);return}if(a&&n(this,Gt)[n(this,It)].type===r){o&&(l.undo=n(this,Gt)[n(this,It)].undo),n(this,Gt)[n(this,It)]=l;return}const h=n(this,It)+1;h===n(this,Ih)?n(this,Gt).splice(0,1):(p(this,It,h),h<n(this,Gt).length&&n(this,Gt).splice(h)),n(this,Gt).push(l)}undo(){if(n(this,It)===-1)return;p(this,Ln,!0);const{undo:t,post:e}=n(this,Gt)[n(this,It)];t(),e==null||e(),p(this,Ln,!1),p(this,It,n(this,It)-1)}redo(){if(n(this,It)<n(this,Gt).length-1){p(this,It,n(this,It)+1),p(this,Ln,!0);const{cmd:t,post:e}=n(this,Gt)[n(this,It)];t(),e==null||e(),p(this,Ln,!1)}}hasSomethingToUndo(){return n(this,It)!==-1}hasSomethingToRedo(){return n(this,It)<n(this,Gt).length-1}cleanType(t){if(n(this,It)!==-1){for(let e=n(this,It);e>=0;e--)if(n(this,Gt)[e].type!==t){n(this,Gt).splice(e+1,n(this,It)-e),p(this,It,e);return}n(this,Gt).length=0,p(this,It,-1)}}destroy(){p(this,Gt,null)}}Gt=new WeakMap,Ln=new WeakMap,Ih=new WeakMap,It=new WeakMap;var wu,nm;class fd{constructor(t){g(this,wu);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ce.platform;for(const[s,i,r={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(b(this,wu,nm).call(this,e));if(!s)return;const{callback:i,options:{bubbles:r=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(i.bind(t,...a,e)(),r||Nt(e))}}wu=new WeakSet,nm=function(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);const e=this.buffer.join("+");return this.buffer.length=0,e};const vu=class vu{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Uy(t),J(this,"_colors",t)}convert(t){const e=Wl(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return vu._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?H.makeHexColor(...e):t}};k(vu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let pf=vu;var wo,ts,vo,Bt,Qt,Eo,xs,So,Ts,xe,In,Fn,_o,Nn,li,Ps,Nr,Fh,Nh,Co,Oh,hi,On,xo,Bn,ci,Eu,Hn,To,Bh,Un,Or,Po,jn,Hh,Xt,ft,ji,$n,zn,Uh,Ro,jh,Gn,di,$i,$h,zh,Rs,L,kd,gf,rm,am,eh,om,lm,hm,mf,cm,bf,yf,dm,Le,Ni,um,fm,Af,pm,sh,wf;const lo=class lo{constructor(t,e,s,i,r,a,o,l,h,c,u,f,m,A,y,v){g(this,L);g(this,wo,new AbortController);g(this,ts,null);g(this,vo,null);g(this,Bt,new Map);g(this,Qt,new Map);g(this,Eo,null);g(this,xs,null);g(this,So,null);g(this,Ts,new Gy);g(this,xe,null);g(this,In,null);g(this,Fn,null);g(this,_o,0);g(this,Nn,new Set);g(this,li,null);g(this,Ps,null);g(this,Nr,new Set);k(this,"_editorUndoBar",null);g(this,Fh,!1);g(this,Nh,!1);g(this,Co,!1);g(this,Oh,null);g(this,hi,null);g(this,On,null);g(this,xo,null);g(this,Bn,!1);g(this,ci,null);g(this,Eu,new zy);g(this,Hn,!1);g(this,To,!1);g(this,Bh,!1);g(this,Un,null);g(this,Or,null);g(this,Po,null);g(this,jn,null);g(this,Hh,null);g(this,Xt,X.NONE);g(this,ft,new Set);g(this,ji,null);g(this,$n,null);g(this,zn,null);g(this,Uh,null);g(this,Ro,null);g(this,jh,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});g(this,Gn,[0,0]);g(this,di,null);g(this,$i,null);g(this,$h,null);g(this,zh,null);g(this,Rs,null);const w=this._signal=n(this,wo).signal;p(this,$i,t),p(this,$h,e),p(this,zh,s),p(this,Eo,i),p(this,xe,r),p(this,$n,a),p(this,Ro,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),{signal:w}),window.addEventListener("pointerdown",()=>{p(this,To,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{p(this,To,!1)},{capture:!0,signal:w}),b(this,L,om).call(this),b(this,L,dm).call(this),b(this,L,mf).call(this),p(this,xs,l.annotationStorage),p(this,Oh,l.filterFactory),p(this,zn,h),p(this,xo,c||null),p(this,Fh,u),p(this,Nh,f),p(this,Co,m),p(this,Hh,A||null),this.viewParameters={realScale:_n.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=y||null,this._supportsPinchToZoom=v!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=lo.prototype,e=a=>n(a,$i).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return J(this,"_keyboardManager",new fd([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,$i).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,$i).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r,a,o,l,h;(t=n(this,Rs))==null||t.resolve(),p(this,Rs,null),(e=n(this,wo))==null||e.abort(),p(this,wo,null),this._signal=null;for(const c of n(this,Qt).values())c.destroy();n(this,Qt).clear(),n(this,Bt).clear(),n(this,Nr).clear(),(s=n(this,jn))==null||s.clear(),p(this,ts,null),n(this,ft).clear(),n(this,Ts).destroy(),(i=n(this,Eo))==null||i.destroy(),(r=n(this,xe))==null||r.destroy(),(a=n(this,$n))==null||a.destroy(),(o=n(this,ci))==null||o.hide(),p(this,ci,null),(l=n(this,Po))==null||l.destroy(),p(this,Po,null),p(this,vo,null),n(this,hi)&&(clearTimeout(n(this,hi)),p(this,hi,null)),n(this,di)&&(clearTimeout(n(this,di)),p(this,di,null)),(h=this._editorUndoBar)==null||h.destroy(),p(this,Ro,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,Hh)}get useNewAltTextFlow(){return n(this,Nh)}get useNewAltTextWhenAddingImage(){return n(this,Co)}get hcmFilter(){return J(this,"hcmFilter",n(this,zn)?n(this,Oh).addHCMFilter(n(this,zn).foreground,n(this,zn).background):"none")}get direction(){return J(this,"direction",getComputedStyle(n(this,$i)).direction)}get _highlightColors(){return J(this,"_highlightColors",n(this,xo)?new Map(n(this,xo).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return J(this,"highlightColors",null);const e=new Map,s=!!n(this,zn);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,r)}return J(this,"highlightColors",e)}get highlightColorNames(){return J(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Fn,t)}setMainHighlightColorPicker(t){p(this,Po,t)}editAltText(t,e=!1){var s;(s=n(this,Eo))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,xe)}editComment(t,e,s,i){var r;(r=n(this,xe))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,Qt).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,xe))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,xe))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=n(this,xe))==null||e.removeComments([t.uid])}toggleComment(t,e,s=void 0){var i;(i=n(this,xe))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,xe))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,xe))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,Qt).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i),await s}getSignature(t){var e;(e=n(this,$n))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,$n)}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}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,Co,e);break}}onPageChanging({pageNumber:t}){p(this,_o,t-1)}focusMainContainer(){n(this,$i).focus()}findParent(t,e){for(const s of n(this,Qt).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,$h).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Nr).add(t)}removeShouldRescale(t){n(this,Nr).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*_n.PDF_TO_CSS_UNITS;for(const s of n(this,Nr))s.onScaleChanging();(e=n(this,Fn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,L,kd).call(this,s).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;s.empty();const f=b(this,L,gf).call(this,c),m=n(this,Xt)===X.NONE,A=()=>{const y=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});m&&this.showAllEditors("highlight",!0,!0),e&&(y==null||y.editComment())};if(m){this.switchToMode(X.HIGHLIGHT,A);return}A()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,xs))return null;const e=`${vh}${t}`,s=n(this,xs).getRawValue(e);return s&&n(this,xs).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,xs)&&!n(this,xs).has(t.id)&&n(this,xs).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,zh);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,Bn)&&(p(this,Bn,!1),b(this,L,eh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,ft))if(e.div.contains(t)){p(this,Or,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Or))return;const[t,e]=n(this,Or);p(this,Or,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,L,mf).call(this),b(this,L,bf).call(this)}removeEditListeners(){b(this,L,cm).call(this),b(this,L,yf).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Ps))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,Ps))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,ts))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,ft)){const r=i.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of n(this,Ps))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){q(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,L,Af).call(this,l);b(this,L,wf).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){q(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Xt)!==X.NONE&&!this.isEditorHandlingKeyboard&&lo._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Bn)&&(p(this,Bn,!1),b(this,L,eh).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(t){t?(b(this,L,lm).call(this),b(this,L,bf).call(this),b(this,L,Le).call(this,{isEditing:n(this,Xt)!==X.NONE,isEmpty:b(this,L,sh).call(this),hasSomethingToUndo:n(this,Ts).hasSomethingToUndo(),hasSomethingToRedo:n(this,Ts).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,L,hm).call(this),b(this,L,yf).call(this),b(this,L,Le).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Ps)){p(this,Ps,t);for(const e of n(this,Ps))b(this,L,Ni).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Eu).id}get currentLayer(){return n(this,Qt).get(n(this,_o))}getLayer(t){return n(this,Qt).get(t)}get currentPageIndex(){return n(this,_o)}addLayer(t){n(this,Qt).set(t.pageIndex,t),n(this,Hn)?t.enable():t.disable()}removeLayer(t){n(this,Qt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1){var a,o,l,h,c,u;if(n(this,Xt)!==t&&!(n(this,Rs)&&(await n(this,Rs).promise,!n(this,Rs)))){if(p(this,Rs,Promise.withResolvers()),(a=n(this,Fn))==null||a.commitOrRemove(),n(this,Xt)===X.POPUP&&((o=n(this,xe))==null||o.hideSidebar()),(l=n(this,xe))==null||l.destroyPopup(),p(this,Xt,t),t===X.NONE){this.setEditingState(!1),b(this,L,fm).call(this);for(const f of n(this,Bt).values())f.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),n(this,Rs).resolve();return}for(const f of n(this,Bt).values())f.addStandaloneCommentButton();t===X.SIGNATURE&&await((c=n(this,$n))==null?void 0:c.loadSignatures()),this.setEditingState(!0),await b(this,L,um).call(this),this.unselectAll();for(const f of n(this,Qt).values())f.updateMode(t);if(t===X.POPUP){n(this,vo)||p(this,vo,await n(this,Ro).getAnnotationsByType(new Set(n(this,Ps).map(A=>A._editorType))));const f=new Set,m=[];for(const A of n(this,Bt).values()){const{annotationElementId:y,hasComment:v,deleted:w}=A;y&&f.add(y),v&&!w&&m.push(A.getData())}for(const A of n(this,vo)){const{id:y,popupRef:v,contentsObj:w}=A;v&&(w!=null&&w.str)&&!f.has(y)&&!n(this,Nn).has(y)&&m.push(A)}(u=n(this,xe))==null||u.showSidebar(m)}if(!e){s&&this.addNewEditorFromKeyboard(),n(this,Rs).resolve();return}for(const f of n(this,Bt).values())f.uid===e?(this.setSelected(f),r?f.editComment():i?f.enterInEditMode():f.focus()):f.unselect();n(this,Rs).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Xt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,Ps)){switch(t){case st.CREATE:this.currentLayer.addNewEditor(e);return;case st.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Uh)||p(this,Uh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,ft))s.updateParams(t,e);else for(const s of n(this,Ps))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,Bt).values())a.editorType===t&&a.show(e);(((r=n(this,Uh))==null?void 0:r.get(st.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,L,Ni).call(this,[[st.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,Bh)!==t){p(this,Bh,t);for(const e of n(this,Qt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,Bt).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,Bt).get(t)}addEditor(t){n(this,Bt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,hi)&&clearTimeout(n(this,hi)),p(this,hi,setTimeout(()=>{this.focusMainContainer(),p(this,hi,null)},0))),n(this,Bt).delete(t.id),t.annotationElementId&&((e=n(this,jn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Nn).has(t.annotationElementId))&&((s=n(this,xs))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Nn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Nn).has(t)}removeDeletedAnnotationElement(t){n(this,Nn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,ts)!==t&&(p(this,ts,t),t&&b(this,L,Ni).call(this,t.propertiesToUpdate))}updateUI(t){n(this,L,pm)===t&&b(this,L,Ni).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,L,Ni).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,ft).has(t)){n(this,ft).delete(t),t.unselect(),b(this,L,Le).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,ft).add(t),t.select(),b(this,L,Ni).call(this,t.propertiesToUpdate),b(this,L,Le).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),(e=n(this,Fn))==null||e.commitOrRemove();for(const s of n(this,ft))s!==t&&s.unselect();n(this,ft).clear(),n(this,ft).add(t),t.select(),b(this,L,Ni).call(this,t.propertiesToUpdate),b(this,L,Le).call(this,{hasSelectedEditor:!0})}isSelected(t){return n(this,ft).has(t)}get firstSelectedEditor(){return n(this,ft).values().next().value}unselect(t){t.unselect(),n(this,ft).delete(t),b(this,L,Le).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,ft).size!==0}get isEnterHandled(){return n(this,ft).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,Ts).undo(),b(this,L,Le).call(this,{hasSomethingToUndo:n(this,Ts).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,L,sh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,Ts).redo(),b(this,L,Le).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Ts).hasSomethingToRedo(),isEmpty:b(this,L,sh).call(this)})}addCommands(t){n(this,Ts).add(t),b(this,L,Le).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,L,sh).call(this)})}cleanUndoStack(t){n(this,Ts).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,ft)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)b(this,L,Af).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,ts))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,ts)||this.hasSelection}selectAll(){for(const t of n(this,ft))t.commit();b(this,L,wf).call(this,n(this,Bt).values())}unselectAll(){var t;if(!(n(this,ts)&&(n(this,ts).commitOrRemove(),n(this,Xt)!==X.NONE))&&!((t=n(this,Fn))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of n(this,ft))e.unselect();n(this,ft).clear(),b(this,L,Le).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Gn)[0]+=t,n(this,Gn)[1]+=e;const[i,r]=n(this,Gn),a=[...n(this,ft)],o=1e3;n(this,di)&&clearTimeout(n(this,di)),p(this,di,setTimeout(()=>{p(this,di,null),n(this,Gn)[0]=n(this,Gn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,Bt).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,Bt).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,li,new Map);for(const t of n(this,ft))n(this,li).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,li))return!1;this.disableUserSelect(!1);const t=n(this,li);p(this,li,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,Bt).has(i.id)){const l=n(this,Qt).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,li))for(const s of n(this,li).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const 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(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||n(this,ft).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,ts)===t}getActive(){return n(this,ts)}getMode(){return n(this,Xt)}isEditingMode(){return n(this,Xt)!==X.NONE}get imageManager(){return J(this,"imageManager",new ff)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,u,f)=>({x:(c-i)/a,y:1-(h+u-s)/r,width:f/a,height:u/r});break;case"180":o=(h,c,u,f)=>({x:1-(h+u-s)/r,y:1-(c+f-i)/a,width:u/r,height:f/a});break;case"270":o=(h,c,u,f)=>({x:1-(c+f-i)/a,y:(h-s)/r,width:f/a,height:u/r});break;default:o=(h,c,u,f)=>({x:(h-s)/r,y:(c-i)/a,width:u/r,height:f/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const u=e.getRangeAt(h);if(!u.collapsed)for(const{x:f,y:m,width:A,height:y}of u.getClientRects())A===0||y===0||l.push(o(f,m,A,y))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,So)||p(this,So,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,So))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,So))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,xs).getRawValue(e);s&&(n(this,Xt)===X.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,jn))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,jn).delete(t))}addMissingCanvas(t,e){(n(this,jn)||p(this,jn,new Map)).set(t,e)}};wo=new WeakMap,ts=new WeakMap,vo=new WeakMap,Bt=new WeakMap,Qt=new WeakMap,Eo=new WeakMap,xs=new WeakMap,So=new WeakMap,Ts=new WeakMap,xe=new WeakMap,In=new WeakMap,Fn=new WeakMap,_o=new WeakMap,Nn=new WeakMap,li=new WeakMap,Ps=new WeakMap,Nr=new WeakMap,Fh=new WeakMap,Nh=new WeakMap,Co=new WeakMap,Oh=new WeakMap,hi=new WeakMap,On=new WeakMap,xo=new WeakMap,Bn=new WeakMap,ci=new WeakMap,Eu=new WeakMap,Hn=new WeakMap,To=new WeakMap,Bh=new WeakMap,Un=new WeakMap,Or=new WeakMap,Po=new WeakMap,jn=new WeakMap,Hh=new WeakMap,Xt=new WeakMap,ft=new WeakMap,ji=new WeakMap,$n=new WeakMap,zn=new WeakMap,Uh=new WeakMap,Ro=new WeakMap,jh=new WeakMap,Gn=new WeakMap,di=new WeakMap,$i=new WeakMap,$h=new WeakMap,zh=new WeakMap,Rs=new WeakMap,L=new WeakSet,kd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},gf=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Qt).values())if(s.hasTextLayer(t))return s;return null},rm=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,L,kd).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,ci)||p(this,ci,new $y(this)),n(this,ci).show(s,i,this.direction==="ltr"))},am=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,ji)&&((r=n(this,ci))==null||r.hide(),p(this,ji,null),b(this,L,Le).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,ji))return;const i=b(this,L,kd).call(this,t).closest(".textLayer");if(!i){n(this,ji)&&((a=n(this,ci))==null||a.hide(),p(this,ji,null),b(this,L,Le).call(this,{hasSelectedText:!1}));return}if((o=n(this,ci))==null||o.hide(),p(this,ji,e),b(this,L,Le).call(this,{hasSelectedText:!0}),!(n(this,Xt)!==X.HIGHLIGHT&&n(this,Xt)!==X.NONE)&&(n(this,Xt)===X.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Bn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Xt)===X.HIGHLIGHT?b(this,L,gf).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,To)){const h=new AbortController,c=this.combinedSignal(h),u=f=>{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,L,eh).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("blur",u,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,L,eh).call(this,"main_toolbar")}},eh=function(t=""){n(this,Xt)===X.HIGHLIGHT?this.highlightSelection(t):n(this,Fh)&&b(this,L,rm).call(this)},om=function(){document.addEventListener("selectionchange",b(this,L,am).bind(this),{signal:this._signal})},lm=function(){if(n(this,On))return;p(this,On,new AbortController);const t=this.combinedSignal(n(this,On));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},hm=function(){var t;(t=n(this,On))==null||t.abort(),p(this,On,null)},mf=function(){if(n(this,Un))return;p(this,Un,new AbortController);const t=this.combinedSignal(n(this,Un));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},cm=function(){var t;(t=n(this,Un))==null||t.abort(),p(this,Un,null)},bf=function(){if(n(this,In))return;p(this,In,new AbortController);const t=this.combinedSignal(n(this,In));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})},yf=function(){var t;(t=n(this,In))==null||t.abort(),p(this,In,null)},dm=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Le=function(t){Object.entries(t).some(([s,i])=>n(this,jh)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n(this,jh),t)}),n(this,Xt)===X.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,L,Ni).call(this,[[st.HIGHLIGHT_FREE,!0]]))},Ni=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},um=async function(){if(!n(this,Hn)){p(this,Hn,!0);const t=[];for(const e of n(this,Qt).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,Bt).values())e.enable()}},fm=function(){if(this.unselectAll(),n(this,Hn)){p(this,Hn,!1);for(const t of n(this,Qt).values())t.disable();for(const t of n(this,Bt).values())t.disable()}},Af=function(t){const e=n(this,Qt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},pm=function(){let t=null;for(t of n(this,ft));return t},sh=function(){if(n(this,Bt).size===0)return!0;if(n(this,Bt).size===1)for(const t of n(this,Bt).values())return t.isEmpty();return!1},wf=function(t){for(const e of n(this,ft))e.unselect();n(this,ft).clear();for(const e of t)e.isEmpty()||(n(this,ft).add(e),e.select());b(this,L,Le).call(this,{hasSelectedEditor:this.hasSelection})},k(lo,"TRANSLATE_SMALL",1),k(lo,"TRANSLATE_BIG",10);let Cr=lo;var ie,ui,js,ko,fi,es,Do,pi,ze,zi,Br,gi,Vn,ti,ih,Dd;const Ie=class Ie{constructor(t){g(this,ti);g(this,ie,null);g(this,ui,!1);g(this,js,null);g(this,ko,null);g(this,fi,null);g(this,es,null);g(this,Do,!1);g(this,pi,null);g(this,ze,null);g(this,zi,null);g(this,Br,null);g(this,gi,!1);p(this,ze,t),p(this,gi,t._uiManager.useNewAltTextFlow),n(Ie,Vn)||p(Ie,Vn,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){Ie._l10n??(Ie._l10n=t)}async render(){const t=p(this,js,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,ko,document.createElement("span"));t.append(e),n(this,gi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(Ie,Vn).missing),e.setAttribute("data-l10n-id",n(Ie,Vn)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,ze)._uiManager._signal;t.addEventListener("contextmenu",vs,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,ze)._uiManager.editAltText(n(this,ze)),n(this,gi)&&n(this,ze)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ti,ih)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Do,!0),i(r))},{signal:s}),await b(this,ti,Dd).call(this),t}finish(){n(this,js)&&(n(this,js).focus({focusVisible:n(this,Do)}),p(this,Do,!1))}isEmpty(){return n(this,gi)?n(this,ie)===null:!n(this,ie)&&!n(this,ui)}hasData(){return n(this,gi)?n(this,ie)!==null||!!n(this,zi):this.isEmpty()}get guessedText(){return n(this,zi)}async setGuessedText(t){n(this,ie)===null&&(p(this,zi,t),p(this,Br,await Ie._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,ti,Dd).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,gi)||n(this,ie)){(e=n(this,pi))==null||e.remove(),p(this,pi,null);return}if(!n(this,pi)){const s=p(this,pi,document.createElement("div"));s.className="noAltTextBadge",n(this,ze).div.append(s)}n(this,pi).classList.toggle("hidden",!t)}serialize(t){let e=n(this,ie);return!t&&n(this,zi)===e&&(e=n(this,Br)),{altText:e,decorative:n(this,ui),guessedText:n(this,zi),textWithDisclaimer:n(this,Br)}}get data(){return{altText:n(this,ie),decorative:n(this,ui)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,zi,s),p(this,Br,i)),!(n(this,ie)===t&&n(this,ui)===e)&&(r||(p(this,ie,t),p(this,ui,e)),b(this,ti,Dd).call(this))}toggle(t=!1){n(this,js)&&(!t&&n(this,es)&&(clearTimeout(n(this,es)),p(this,es,null)),n(this,js).disabled=!t)}shown(){n(this,ze)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ti,ih)}})}destroy(){var t,e;(t=n(this,js))==null||t.remove(),p(this,js,null),p(this,ko,null),p(this,fi,null),(e=n(this,pi))==null||e.remove(),p(this,pi,null)}};ie=new WeakMap,ui=new WeakMap,js=new WeakMap,ko=new WeakMap,fi=new WeakMap,es=new WeakMap,Do=new WeakMap,pi=new WeakMap,ze=new WeakMap,zi=new WeakMap,Br=new WeakMap,gi=new WeakMap,Vn=new WeakMap,ti=new WeakSet,ih=function(){return n(this,ie)&&"added"||n(this,ie)===null&&this.guessedText&&"review"||"missing"},Dd=async function(){var i,r,a;const t=n(this,js);if(!t)return;if(n(this,gi)){if(t.classList.toggle("done",!!n(this,ie)),t.setAttribute("data-l10n-id",n(Ie,Vn)[n(this,ti,ih)]),(i=n(this,ko))==null||i.setAttribute("data-l10n-id",n(Ie,Vn)[`${n(this,ti,ih)}-label`]),!n(this,ie)){(r=n(this,fi))==null||r.remove();return}}else{if(!n(this,ie)&&!n(this,ui)){t.classList.remove("done"),(a=n(this,fi))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,fi);if(!e){p(this,fi,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,ze).id}`;const o=100,l=n(this,ze)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,es)),p(this,es,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,es,setTimeout(()=>{p(this,es,null),n(this,fi).classList.add("show"),n(this,ze)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,es)&&(clearTimeout(n(this,es)),p(this,es,null)),(h=n(this,fi))==null||h.classList.remove("show")},{signal:l})}n(this,ui)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,ie)),e.parentNode||t.append(e);const s=n(this,ze).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},g(Ie,Vn,null),k(Ie,"_l10n",null);let lu=Ie;var fe,ks,Hr,Ct,Gh,Ur,$s,jr,$r,zr,Vh,vf;class Ad{constructor(t){g(this,Vh);g(this,fe,null);g(this,ks,null);g(this,Hr,!1);g(this,Ct,null);g(this,Gh,null);g(this,Ur,null);g(this,$s,null);g(this,jr,null);g(this,$r,!1);g(this,zr,null);p(this,Ct,t)}renderForToolbar(){const t=p(this,ks,document.createElement("button"));return t.className="comment",b(this,Vh,vf).call(this,t,!1)}renderForStandalone(){const t=p(this,fe,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,Ct).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,Ct)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=n(this,Ct).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Vh,vf).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,fe)??n(this,ks))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,fe))return;const t=n(this,Ct).commentButtonColor;t&&(n(this,fe).style.backgroundColor=t),n(this,Ct)._uiManager.updatePopupColor(n(this,Ct))}get commentButtonWidth(){var t;return(((t=n(this,fe))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,Ct).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,zr))return n(this,zr);if(!n(this,fe))return null;const{x:t,y:e,height:s}=n(this,fe).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Ct).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){p(this,zr,t)}hasDefaultPopupPosition(){return n(this,zr)===null}removeStandaloneCommentButton(){var t;(t=n(this,fe))==null||t.remove(),p(this,fe,null)}removeToolbarCommentButton(){var t;(t=n(this,ks))==null||t.remove(),p(this,ks,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,fe)&&(n(this,fe).classList.toggle("selected",t),n(this,fe).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,Ct).commentButtonPosition;const{width:c,height:u,x:f,y:m}=n(this,Ct);s=f+s*c,i=m+i*u}const r=n(this,Ct).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;n(this,Ct)._uiManager.editComment(n(this,Ct),a+s*l,o+i*h,{...t,parentDimensions:r})}finish(){n(this,ks)&&(n(this,ks).focus({focusVisible:n(this,Hr)}),p(this,Hr,!1))}isDeleted(){return n(this,$r)||n(this,$s)===""}isEmpty(){return n(this,$s)===null}hasBeenEdited(){return this.isDeleted()||n(this,$s)!==n(this,Gh)}serialize(){return this.data}get data(){return{text:n(this,$s),richText:n(this,Ur),date:n(this,jr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,$s)&&p(this,Ur,null),t===null){p(this,$s,""),p(this,$r,!0);return}p(this,$s,t),p(this,jr,new Date),p(this,$r,!1)}setInitialText(t,e=null){p(this,Gh,t),this.data=t,p(this,jr,null),p(this,Ur,e)}shown(){}destroy(){var t,e;(t=n(this,ks))==null||t.remove(),p(this,ks,null),(e=n(this,fe))==null||e.remove(),p(this,fe,null),p(this,$s,""),p(this,Ur,null),p(this,jr,null),p(this,Ct,null),p(this,Hr,!1),p(this,$r,!1)}}fe=new WeakMap,ks=new WeakMap,Hr=new WeakMap,Ct=new WeakMap,Gh=new WeakMap,Ur=new WeakMap,$s=new WeakMap,jr=new WeakMap,$r=new WeakMap,zr=new WeakMap,Vh=new WeakSet,vf=function(t,e){if(!n(this,Ct)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[n(this,Ct)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const s=n(this,Ct)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",vs,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,Ct)._focusEventsAllowed=!1,Nt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,Ct)._focusEventsAllowed=!0,Nt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,ks)?this.edit():n(this,Ct).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Hr,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,Ct).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,Ct).toggleComment(!1,!1)},{signal:s}),t};var Mo,Gr,Wh,Xh,qh,Yh,Kh,Gi,Vr,Vi,Wr,Wi,Tr,gm,mm,bm;const Zp=class Zp{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){g(this,Tr);g(this,Mo);g(this,Gr,!1);g(this,Wh,null);g(this,Xh);g(this,qh);g(this,Yh);g(this,Kh);g(this,Gi,null);g(this,Vr);g(this,Vi,null);g(this,Wr);g(this,Wi,null);p(this,Mo,t),p(this,Wh,s),p(this,Xh,e),p(this,qh,i),p(this,Yh,r),p(this,Kh,a),p(this,Wr,new AbortController),p(this,Vr,AbortSignal.any([o,n(this,Wr).signal])),t.addEventListener("touchstart",b(this,Tr,gm).bind(this),{passive:!1,signal:n(this,Vr)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ei.pixelRatio}destroy(){var t,e;(t=n(this,Wr))==null||t.abort(),p(this,Wr,null),(e=n(this,Gi))==null||e.abort(),p(this,Gi,null)}};Mo=new WeakMap,Gr=new WeakMap,Wh=new WeakMap,Xh=new WeakMap,qh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,Gi=new WeakMap,Vr=new WeakMap,Vi=new WeakMap,Wr=new WeakMap,Wi=new WeakMap,Tr=new WeakSet,gm=function(t){var i,r,a;if((i=n(this,Xh))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,Gi))return;const o=p(this,Gi,new AbortController),l=AbortSignal.any([n(this,Vr),o.signal]),h=n(this,Mo),c={capture:!0,signal:l,passive:!1},u=f=>{var m;f.pointerType==="touch"&&((m=n(this,Gi))==null||m.abort(),p(this,Gi,null))};h.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Nt(f),u(f))},c),h.addEventListener("pointerup",u,c),h.addEventListener("pointercancel",u,c);return}if(!n(this,Wi)){p(this,Wi,new AbortController);const o=AbortSignal.any([n(this,Vr),n(this,Wi).signal]),l=n(this,Mo),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,Tr,mm).bind(this),h);const c=b(this,Tr,bm).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Nt,h),l.addEventListener("pointermove",Nt,h),l.addEventListener("pointercancel",Nt,h),l.addEventListener("pointerup",Nt,h),(r=n(this,qh))==null||r.call(this)}if(Nt(t),t.touches.length!==2||(a=n(this,Wh))!=null&&a.call(this)){p(this,Vi,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,Vi,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},mm=function(t){var _;if(!n(this,Vi)||t.touches.length!==2)return;Nt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,Vi),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:f}=l,m=u-h,A=f-c,y=a-i,v=o-r,w=Math.hypot(y,v)||1,S=Math.hypot(m,A)||1;if(!n(this,Gr)&&Math.abs(S-w)<=Zp.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,Gr)){p(this,Gr,!0);return}const E=[(i+a)/2,(r+o)/2];(_=n(this,Yh))==null||_.call(this,E,S,w)},bm=function(t){var e;t.touches.length>=2||(n(this,Wi)&&(n(this,Wi).abort(),p(this,Wi,null),(e=n(this,Kh))==null||e.call(this)),n(this,Vi)&&(Nt(t),p(this,Vi,null),p(this,Gr,!1)))};let Ch=Zp;var Xr,zs,Dt,vt,Xi,Lo,Wn,Jh,pe,qr,qi,mi,Xn,Qh,Yr,ss,Zh,Kr,Yi,bi,Io,Fo,Ds,Jr,tc,Su,V,Ef,ec,Sf,Md,ym,Am,_f,Ld,Cf,wm,vm,Em,xf,Sm,Tf,_m,Cm,xm,Pf,nh;const Y=class Y{constructor(t){g(this,V);g(this,Xr,null);g(this,zs,null);g(this,Dt,null);g(this,vt,null);g(this,Xi,null);g(this,Lo,!1);g(this,Wn,null);g(this,Jh,"");g(this,pe,null);g(this,qr,null);g(this,qi,null);g(this,mi,null);g(this,Xn,null);g(this,Qh,"");g(this,Yr,!1);g(this,ss,null);g(this,Zh,!1);g(this,Kr,!1);g(this,Yi,!1);g(this,bi,null);g(this,Io,0);g(this,Fo,0);g(this,Ds,null);g(this,Jr,null);k(this,"isSelected",!1);k(this,"_isCopy",!1);k(this,"_editToolbar",null);k(this,"_initialOptions",Object.create(null));k(this,"_initialData",null);k(this,"_isVisible",!0);k(this,"_uiManager",null);k(this,"_focusEventsAllowed",!0);g(this,tc,!1);g(this,Su,Y._zIndex++);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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=Y.prototype._resizeWithKeyboard,e=Cr.TRANSLATE_SMALL,s=Cr.TRANSLATE_BIG;return J(this,"_resizerKeyboardManager",new fd([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],Y.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return J(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Vy({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(Y._l10n??(Y._l10n=t),Y._l10nResizer||(Y._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"})),Y._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);Y._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,tc)}set _isDraggable(t){var e;p(this,tc,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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=n(this,Su)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,V,nh).call(this),(e=n(this,mi))==null||e.remove(),p(this,mi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,Yr)?p(this,Yr,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){b(this,V,Ef).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,ss)||p(this,ss,[this.x,this.y,this.width,this.height]),b(this,V,Ef).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,ss)||p(this,ss,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:u,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,ss)&&(n(this,ss)[0]!==this.x||n(this,ss)[1]!==this.y)}get _hasBeenResized(){return!!n(this,ss)&&(n(this,ss)[2]!==this.width||n(this,ss)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=Y,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=De(r,0,s-o),a=De(a,0,i-l);break;case 90:r=De(r,0,s-l),a=De(a,o,i);break;case 180:r=De(r,o,s),a=De(a,l,i);break;case 270:r=De(r,l,s),a=De(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[h,c]=this.getBaseTranslation();r+=h,a+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=Y,ec,Sf).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=Y,ec,Sf).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,Dt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,Kr))return this._editToolbar;this._editToolbar=new df(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=n(this,Dt))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return n(this,Dt)||(lu.initialize(Y._l10n),p(this,Dt,new lu(this)),n(this,Xr)&&(n(this,Dt).data=n(this,Xr),p(this,Xr,null))),n(this,Dt)}get altTextData(){var t;return(t=n(this,Dt))==null?void 0:t.data}set altTextData(t){n(this,Dt)&&(n(this,Dt).data=t)}get guessedAltText(){var t;return(t=n(this,Dt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,Dt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,Dt))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,Dt)&&!n(this,Dt).isEmpty()}hasAltTextData(){var t;return((t=n(this,Dt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,vt))==null||t.focusButton()}addCommentButton(){return n(this,vt)||p(this,vt,new Ad(this))}addStandaloneCommentButton(){if(n(this,Xi)){this._uiManager.isEditingMode()&&n(this,Xi).classList.remove("hidden");return}this.hasComment&&(p(this,Xi,n(this,vt).renderForStandalone()),this.div.append(n(this,Xi)))}removeStandaloneCommentButton(){n(this,vt).removeStandaloneCommentButton(),p(this,Xi,null)}hideStandaloneCommentButton(){var t;(t=n(this,Xi))==null||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,vt);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,vt)||p(this,vt,new Ad(this)),n(this,vt).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(n(this,vt)||p(this,vt,new Ad(this)),n(this,vt).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=n(this,vt))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,vt))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,vt)&&!n(this,vt).isEmpty()&&!n(this,vt).isDeleted()}async editComment(t){n(this,vt)||p(this,vt,new Ad(this)),n(this,vt).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,vt).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,h=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){n(this,vt).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=n(this,Lo)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,V,Tf).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),im(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,Jr)||p(this,Jr,new Ch({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,V,wm).bind(this),onPinching:b(this,V,vm).bind(this),onPinchEnd:b(this,V,Em).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=ce.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,Yr,!0),this._isDraggable){b(this,V,Sm).call(this,t);return}b(this,V,xf).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,bi)&&clearTimeout(n(this,bi)),p(this,bi,setTimeout(()=>{var t;p(this,bi,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,c=e/i,u=this.x*r,f=this.y*a,m=this.width*r,A=this.height*a;switch(s){case 0:return[u+h+o,a-f-c-A+l,u+h+m+o,a-f-c+l];case 90:return[u+c+o,a-f+h+l,u+c+A+o,a-f+h+m+l];case 180:return[u-h-m+o,a-f+c+l,u-h+o,a-f+c+A+l];case 270:return[u-c-A+o,a-f-h-m+l,u-c+o,a-f-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Y._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,vt))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,Kr,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,Kr,!1),!0):!1}isInEditMode(){return n(this,Kr)}shouldGetKeyboardEvents(){return n(this,Yi)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){b(this,V,Tf).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,p(i,Xr,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=h/r,i.height=c/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=n(this,Xn))==null||t.abort(),p(this,Xn,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),n(this,bi)&&(clearTimeout(n(this,bi)),p(this,bi,null)),b(this,V,nh).call(this),this.removeEditToolbar(),n(this,Ds)){for(const s of n(this,Ds).values())clearTimeout(s);p(this,Ds,null)}this.parent=null,(e=n(this,Jr))==null||e.destroy(),p(this,Jr,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,V,ym).call(this),n(this,pe).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,a]=this.getPDFRect();return[Y._round(s+(r-s)*t),Y._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,vt).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,vt).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,vt).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,vt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){n(this,vt).setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,qi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,pe).children;if(!n(this,zs)){p(this,zs,Array.from(e));const a=b(this,V,_m).bind(this),o=b(this,V,Cm).bind(this),l=this._uiManager._signal;for(const h of n(this,zs)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",b(this,V,xm).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",Y._l10nResizer[c])}}const s=n(this,zs)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,zs).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,pe).append(n(this,pe).firstChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,pe).firstChild.before(n(this,pe).lastChild);let a=0;for(const o of e){const h=n(this,zs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",Y._l10nResizer[h])}}b(this,V,Pf).call(this,0),p(this,Yi,!0),n(this,pe).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,Yi)&&b(this,V,Cf).call(this,n(this,Qh),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,V,nh).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,Dt))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,i,r;this.isSelected&&(this.isSelected=!1,(t=n(this,pe))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,Dt))==null||r.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,Zh)}set isEditing(t){p(this,Zh,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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){n(this,Ds)||p(this,Ds,new Map);const{action:s}=t;let i=n(this,Ds).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Ds).delete(s),n(this,Ds).size===0&&p(this,Ds,null)},Y._telemetryTimeout),n(this,Ds).set(s,i);return}t.type||(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),p(this,Lo,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Lo,!0)}updateFakeAnnotationElement(t){if(!n(this,mi)&&!this.deleted){p(this,mi,t.addFakeAnnotation(this));return}if(this.deleted){n(this,mi).remove(),p(this,mi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,mi).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Xr=new WeakMap,zs=new WeakMap,Dt=new WeakMap,vt=new WeakMap,Xi=new WeakMap,Lo=new WeakMap,Wn=new WeakMap,Jh=new WeakMap,pe=new WeakMap,qr=new WeakMap,qi=new WeakMap,mi=new WeakMap,Xn=new WeakMap,Qh=new WeakMap,Yr=new WeakMap,ss=new WeakMap,Zh=new WeakMap,Kr=new WeakMap,Yi=new WeakMap,bi=new WeakMap,Io=new WeakMap,Fo=new WeakMap,Ds=new WeakMap,Jr=new WeakMap,tc=new WeakMap,Su=new WeakMap,V=new WeakSet,Ef=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},ec=new WeakSet,Sf=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},Md=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},ym=function(){if(n(this,pe))return;p(this,pe,document.createElement("div")),n(this,pe).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");n(this,pe).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,V,Am).bind(this,s),{signal:e}),i.addEventListener("contextmenu",vs,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,pe))},Am=function(t,e){var c;e.preventDefault();const{isMac:s}=ce.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,Dt))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,qr,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,V,Cf).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Nt,{passive:!1,signal:a}),window.addEventListener("contextmenu",vs,{signal:a}),p(this,qi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var u;r.abort(),this.parent.togglePointerEvents(!0),(u=n(this,Dt))==null||u.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,V,Ld).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},_f=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Ld=function(){if(!n(this,qi))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,qi);p(this,qi,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:b(this,V,_f).bind(this,r,a,o,l),undo:b(this,V,_f).bind(this,t,e,s,i),mustExec:!0})},Cf=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=Y.MIN_SIZE/s,c=Y.MIN_SIZE/i,u=b(this,V,Md).call(this,this.rotation),f=(O,F)=>[u[0]*O+u[2]*F,u[1]*O+u[3]*F],m=b(this,V,Md).call(this,360-this.rotation),A=(O,F)=>[m[0]*O+m[2]*F,m[1]*O+m[3]*F];let y,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,y=(O,F)=>[0,0],v=(O,F)=>[O,F];break;case"topMiddle":y=(O,F)=>[O/2,0],v=(O,F)=>[O/2,F];break;case"topRight":w=!0,y=(O,F)=>[O,0],v=(O,F)=>[0,F];break;case"middleRight":S=!0,y=(O,F)=>[O,F/2],v=(O,F)=>[0,F/2];break;case"bottomRight":w=!0,y=(O,F)=>[O,F],v=(O,F)=>[0,0];break;case"bottomMiddle":y=(O,F)=>[O/2,F],v=(O,F)=>[O/2,0];break;case"bottomLeft":w=!0,y=(O,F)=>[0,F],v=(O,F)=>[O,0];break;case"middleLeft":S=!0,y=(O,F)=>[0,F/2],v=(O,F)=>[O,F/2];break}const E=y(o,l),_=v(o,l);let C=f(..._);const x=Y._round(r+C[0]),T=Y._round(a+C[1]);let P=1,R=1,D,M;if(e.fromKeyboard)({deltaX:D,deltaY:M}=e);else{const{screenX:O,screenY:F}=e,[tt,it]=n(this,qr);[D,M]=this.screenToPageTranslation(O-tt,F-it),n(this,qr)[0]=O,n(this,qr)[1]=F}if([D,M]=A(D/s,M/i),w){const O=Math.hypot(o,l);P=R=Math.max(Math.min(Math.hypot(_[0]-E[0]-D,_[1]-E[1]-M)/O,1/o,1/l),h/o,c/l)}else S?P=De(Math.abs(_[0]-E[0]-D),h,1)/o:R=De(Math.abs(_[1]-E[1]-M),c,1)/l;const I=Y._round(o*P),G=Y._round(l*R);C=f(...v(I,G));const N=x-C[0],W=T-C[1];n(this,ss)||p(this,ss,[this.x,this.y,this.width,this.height]),this.width=I,this.height=G,this.x=N,this.y=W,this.setDims(),this.fixAndSetPosition(),this._onResizing()},wm=function(){var t;p(this,qi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,Dt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},vm=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,V,Md).call(this,this.rotation),o=(x,T)=>[a[0]*x+a[2]*T,a[1]*x+a[3]*T],[l,h]=this.parentDimensions,c=this.x,u=this.y,f=this.width,m=this.height,A=Y.MIN_SIZE/l,y=Y.MIN_SIZE/h;r=Math.max(Math.min(r,1/f,1/m),A/f,y/m);const v=Y._round(f*r),w=Y._round(m*r);if(v===f&&w===m)return;n(this,ss)||p(this,ss,[c,u,f,m]);const S=o(f/2,m/2),E=Y._round(c+S[0]),_=Y._round(u+S[1]),C=o(v/2,w/2);this.x=E-C[0],this.y=_-C[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Em=function(){var t;(t=n(this,Dt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,V,Ld).call(this)},xf=function(t){const{isMac:e}=ce.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Sm=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=h=>{i.abort(),p(this,Wn,null),p(this,Yr,!1),this._uiManager.endDragSession()||b(this,V,xf).call(this,h),s&&this._onStopDragging()};e&&(p(this,Io,t.clientX),p(this,Fo,t.clientY),p(this,Wn,t.pointerId),p(this,Jh,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:u,pointerId:f}=h;if(f!==n(this,Wn)){Nt(h);return}const[m,A]=this.screenToPageTranslation(c-n(this,Io),u-n(this,Fo));p(this,Io,c),p(this,Fo,u),this._uiManager.dragSelectedEditors(m,A)},a),window.addEventListener("touchmove",Nt,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,Jh)&&(n(this,Jr)||h.isPrimary)&&o(h),Nt(h)},a));const l=h=>{if(!n(this,Wn)||n(this,Wn)===h.pointerId){o(h);return}Nt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Tf=function(){if(n(this,Xn)||!this.div)return;p(this,Xn,new AbortController);const t=this._uiManager.combinedSignal(n(this,Xn));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},_m=function(t){Y._resizerKeyboardManager.exec(this,t)},Cm=function(t){var e;n(this,Yi)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,pe)&&b(this,V,nh).call(this)},xm=function(t){p(this,Qh,n(this,Yi)?t:"")},Pf=function(t){if(n(this,zs))for(const e of n(this,zs))e.tabIndex=t},nh=function(){p(this,Yi,!1),b(this,V,Pf).call(this,-1),b(this,V,Ld).call(this)},g(Y,ec),k(Y,"_l10n",null),k(Y,"_l10nResizer",null),k(Y,"_borderLineWidth",-1),k(Y,"_colorManager",new pf),k(Y,"_zIndex",1),k(Y,"_telemetryTimeout",1e3);let xt=Y;class Vy extends xt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const dg=3285377520,Es=4294901760,ri=65535;class Tm{constructor(t){this.h1=t?t&4294967295:dg,this.h2=t?t&4294967295:dg}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,v=t.length;y<v;y++){const w=t.charCodeAt(y);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,c=this.h2;const u=3432918353,f=461845907,m=u&ri,A=f&ri;for(let y=0;y<i;y++)y&1?(o=a[y],o=o*u&Es|o*m&ri,o=o<<15|o>>>17,o=o*f&Es|o*A&ri,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*u&Es|l*m&ri,l=l<<15|l>>>17,l=l*f&Es|l*A&ri,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*u&Es|o*m&ri,o=o<<15|o>>>17,o=o*f&Es|o*A&ri,i&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Es|t*36045&ri,e=e*4283543511&Es|((e<<16|t>>>16)*2950163797&Es)>>>16,t^=e>>>1,t=t*444984403&Es|t*60499&ri,e=e*3301882366&Es|((e<<16|t>>>16)*3120437893&Es)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Rf=Object.freeze({map:null,hash:"",transfer:void 0});var Qr,Zr,Ki,ge,_u,Pm;class jp{constructor(){g(this,_u);g(this,Qr,!1);g(this,Zr,null);g(this,Ki,null);g(this,ge,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=n(this,ge).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,ge).get(t)}remove(t){const e=n(this,ge).get(t);if(e!==void 0&&(e instanceof xt&&n(this,Ki).delete(e.annotationElementId),n(this,ge).delete(t),n(this,ge).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const s of n(this,ge).values())if(s instanceof xt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=n(this,ge).get(t);let i=!1;if(s!==void 0)for(const[r,a]of Object.entries(e))s[r]!==a&&(i=!0,s[r]=a);else i=!0,n(this,ge).set(t,e);i&&b(this,_u,Pm).call(this),e instanceof xt&&((n(this,Ki)||p(this,Ki,new Map)).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return n(this,ge).has(t)}get size(){return n(this,ge).size}resetModified(){n(this,Qr)&&(p(this,Qr,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Rm(this)}get serializable(){if(n(this,ge).size===0)return Rf;const t=new Map,e=new Tm,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,ge)){const l=o instanceof xt?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Rf}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,ge).values()){if(!(r instanceof xt)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.has(o)||e.set(o,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[h,c]of Object.entries(a)){if(h==="type")continue;let u=l.get(h);u||(u=new Map,l.set(h,u));const f=u.get(c)??0;u.set(c,f+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){p(this,Zr,null)}updateEditor(t,e){var i;const s=(i=n(this,Ki))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,Ki))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,Zr))return n(this,Zr);const t=[];if(n(this,Ki))for(const e of n(this,Ki).values())e.serialize()&&t.push(e.annotationElementId);return p(this,Zr,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return n(this,ge).entries()}}Qr=new WeakMap,Zr=new WeakMap,Ki=new WeakMap,ge=new WeakMap,_u=new WeakSet,Pm=function(){n(this,Qr)||(p(this,Qr,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var sc;class Rm extends jp{constructor(e){super();g(this,sc);const{map:s,hash:i,transfer:r}=e.serializable,a=structuredClone(s,r?{transfer:r}:null);p(this,sc,{map:a,hash:i,transfer:r})}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,sc)}get modifiedIds(){return J(this,"modifiedIds",{ids:new Set,hash:""})}}sc=new WeakMap;var No;class Wy{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){g(this,No,new Set);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));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),n(this,No).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,No).has(t.loadedName))){if(nt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,No).add(i),s==null||s(t)}catch{q(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}_t("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw q(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return J(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return J(this,"isSyncFontLoadingSupported",Be||ce.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(nt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return J(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(_,C){return _.charCodeAt(C)<<24|_.charCodeAt(C+1)<<16|_.charCodeAt(C+2)<<8|_.charCodeAt(C+3)&255}function i(_,C,x,T){const P=_.substring(0,C),R=_.substring(C+x);return P+T+R}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function c(_,C){if(++h>30){q("Load test font never loaded."),C();return}if(l.font="30px "+_,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(c.bind(null,_,C))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const A=16,y=1482184792;let v=s(f,A);for(r=0,a=u.length-3;r<a;r+=4)v=v-y+s(u,r)|0;r<u.length&&(v=v-y+s(u+"XXX",r)|0),f=i(f,A,4,Ly(v));const w=`url(data:font/opentype;base64,${btoa(f)});`,S=`@font-face {font-family:"${u}";src:${w}}`;this.insertRule(S);const E=this._document.createElement("div");E.style.visibility="hidden",E.style.width=E.style.height="10px",E.style.position="absolute",E.style.top=E.style.left="0px";for(const _ of[t.loadedName,u]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=_,E.append(C)}this._document.body.append(E),c(u,()=>{E.remove(),e.complete()})}}No=new WeakMap;var gt;class Xy{constructor(t,e=null,s,i){g(this,gt);this.compiledGlyphs=Object.create(null),p(this,gt,t),this._inspectFont=e,s&&Object.assign(this,s),i&&(this.charProcOperatorList=i)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Vg(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){q(`getPathGenerator - ignoring character: "${a}".`)}const r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,gt).black}get bold(){return n(this,gt).bold}get disableFontFace(){return n(this,gt).disableFontFace??!1}get fontExtraProperties(){return n(this,gt).fontExtraProperties??!1}get isInvalidPDFjsFont(){return n(this,gt).isInvalidPDFjsFont}get isType3Font(){return n(this,gt).isType3Font}get italic(){return n(this,gt).italic}get missingFile(){return n(this,gt).missingFile}get remeasure(){return n(this,gt).remeasure}get vertical(){return n(this,gt).vertical}get ascent(){return n(this,gt).ascent}get defaultWidth(){return n(this,gt).defaultWidth}get descent(){return n(this,gt).descent}get bbox(){return n(this,gt).bbox}get fontMatrix(){return n(this,gt).fontMatrix}get fallbackName(){return n(this,gt).fallbackName}get loadedName(){return n(this,gt).loadedName}get mimetype(){return n(this,gt).mimetype}get name(){return n(this,gt).name}get data(){return n(this,gt).data}clearData(){n(this,gt).clearData()}get cssFontInfo(){return n(this,gt).cssFontInfo}get systemFontInfo(){return n(this,gt).systemFontInfo}get defaultVMetrics(){return n(this,gt).defaultVMetrics}}gt=new WeakMap;function qy(d){if(d instanceof URL)return d.href;if(typeof d=="string"){if(Be)return d;const t=URL.parse(d,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Yy(d){if(Be&&typeof Buffer<"u"&&d instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength)return d;if(typeof d=="string")return cd(d);if(d instanceof ArrayBuffer||ArrayBuffer.isView(d)||typeof d=="object"&&!isNaN(d==null?void 0:d.length))return new Uint8Array(d);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function wd(d){if(typeof d!="string")return null;if(d.endsWith("/"))return d;throw new Error(`Invalid factory url: "${d}" must include trailing slash.`)}const kf=d=>typeof d=="object"&&Number.isInteger(d==null?void 0:d.num)&&d.num>=0&&Number.isInteger(d==null?void 0:d.gen)&&d.gen>=0,Ky=d=>typeof d=="object"&&typeof(d==null?void 0:d.name)=="string",km=Oy.bind(null,kf,Ky);var Ji,Cu;class Jy{constructor(){g(this,Ji,new Map);g(this,Cu,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,Cu).then(()=>{for(const[i]of n(this,Ji))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){q("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,Ji).set(e,i)}removeEventListener(t,e){const s=n(this,Ji).get(e);s==null||s(),n(this,Ji).delete(e)}terminate(){for(const[,t]of n(this,Ji))t==null||t();n(this,Ji).clear()}}Ji=new WeakMap,Cu=new WeakMap;const vd={DATA:1,ERROR:2},Wt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ug(){}function je(d){if(d instanceof Sn||d instanceof au||d instanceof ng||d instanceof Eh||d instanceof Ku)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||_t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new Sn(d.message);case"InvalidPDFException":return new au(d.message);case"PasswordException":return new ng(d.message,d.code);case"ResponseException":return new Eh(d.message,d.status,d.missing);case"UnknownErrorException":return new Ku(d.message,d.details)}return new Ku(d.message,d.toString())}var Oo,Ns,Dm,Mm,Lm,Id;class rh{constructor(t,e,s){g(this,Ns);g(this,Oo,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,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),s.addEventListener("message",b(this,Ns,Dm).bind(this),{signal:n(this,Oo).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:Wt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{nt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Wt.CANCEL,streamId:r,reason:je(h)}),c.promise}},s)}destroy(){var t;(t=n(this,Oo))==null||t.abort(),p(this,Oo,null)}}Oo=new WeakMap,Ns=new WeakSet,Dm=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Ns,Lm).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===vd.DATA)i.resolve(t.data);else if(t.callback===vd.ERROR)i.reject(je(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:vd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:vd.ERROR,callbackId:t.callbackId,reason:je(a)})});return}if(t.streamId){b(this,Ns,Mm).call(this,t);return}e(t.data)},Mm=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=c,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:Wt.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Wt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){nt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Wt.ERROR,streamId:e,reason:je(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.START_COMPLETE,streamId:e,reason:je(h)})})},Lm=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Wt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(je(t.reason));break;case Wt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(je(t.reason));break;case Wt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||ug).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,reason:je(h)})});break;case Wt.ENQUEUE:if(nt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Wt.CLOSE:if(nt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Ns,Id).call(this,a,e);break;case Wt.ERROR:nt(a,"error should have stream controller"),a.controller.error(je(t.reason)),b(this,Ns,Id).call(this,a,e);break;case Wt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(je(t.reason)),b(this,Ns,Id).call(this,a,e);break;case Wt.CANCEL:if(!o)break;const l=je(t.reason);Promise.try(o.onCancel||ug,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.CANCEL_COMPLETE,streamId:e,reason:je(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Id=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var ic;class Im{constructor({enableHWA:t=!1}){g(this,ic,!1);p(this,ic,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,ic)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){_t("Abstract method `_createCanvas` called.")}}ic=new WeakMap;class Qy extends Im{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Fm{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){_t("Abstract method `_fetch` called.")}}class fg extends Fm{async _fetch(t){const e=await Vl(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):cd(e)}}class Nm{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}destroy(t=!1){}}var ta,Bo,Qi,Zi,Te,ea,sa,B,_e,ah,eo,Fd,so,Om,Df,io,oh,lh,Mf,hh;class Zy extends Nm{constructor({docId:e,ownerDocument:s=globalThis.document}){super();g(this,B);g(this,ta);g(this,Bo);g(this,Qi);g(this,Zi);g(this,Te);g(this,ea);g(this,sa,0);p(this,Zi,e),p(this,Te,s)}addFilter(e){if(!e)return"none";let s=n(this,B,_e).get(e);if(s)return s;const[i,r,a]=b(this,B,Fd).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,B,_e).get(o),s)return n(this,B,_e).set(e,s),s;const l=`g_${n(this,Zi)}_transfer_map_${Kt(this,sa)._++}`,h=b(this,B,so).call(this,l);n(this,B,_e).set(e,h),n(this,B,_e).set(o,h);const c=b(this,B,io).call(this,l);return b(this,B,lh).call(this,i,r,a,c),h}addHCMFilter(e,s){var A;const i=`${e}-${s}`,r="base";let a=n(this,B,ah).get(r);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,B,ah).set(r,a)),!e||!s))return a.url;const o=b(this,B,hh).call(this,e);e=H.makeHexColor(...o);const l=b(this,B,hh).call(this,s);if(s=H.makeHexColor(...l),n(this,B,eo).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let y=0;y<=255;y++){const v=y/255;h[y]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=h.join(","),u=`g_${n(this,Zi)}_hcm_filter`,f=a.filter=b(this,B,io).call(this,u);b(this,B,lh).call(this,c,c,c,f),b(this,B,Df).call(this,f);const m=(y,v)=>{const w=o[y]/255,S=l[y]/255,E=new Array(v+1);for(let _=0;_<=v;_++)E[_]=w+_/v*(S-w);return E.join(",")};return b(this,B,lh).call(this,m(0,5),m(1,5),m(2,5),f),a.url=b(this,B,so).call(this,u),a.url}addAlphaFilter(e){let s=n(this,B,_e).get(e);if(s)return s;const[i]=b(this,B,Fd).call(this,[e]),r=`alpha_${i}`;if(s=n(this,B,_e).get(r),s)return n(this,B,_e).set(e,s),s;const a=`g_${n(this,Zi)}_alpha_map_${Kt(this,sa)._++}`,o=b(this,B,so).call(this,a);n(this,B,_e).set(e,o),n(this,B,_e).set(r,o);const l=b(this,B,io).call(this,a);return b(this,B,Mf).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,B,_e).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,B,Fd).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,B,_e).get(r),s)return n(this,B,_e).set(e,s),s;const a=`g_${n(this,Zi)}_luminosity_map_${Kt(this,sa)._++}`,o=b(this,B,so).call(this,a);n(this,B,_e).set(e,o),n(this,B,_e).set(r,o);const l=b(this,B,io).call(this,a);return b(this,B,Om).call(this,l),e&&b(this,B,Mf).call(this,i,l),o}addHighlightHCMFilter(e,s,i,r,a){var S;const o=`${s}-${i}-${r}-${a}`;let l=n(this,B,ah).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,B,ah).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,B,hh).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[m,A]=[r,a].map(b(this,B,hh).bind(this));f<u&&([u,f,m,A]=[f,u,A,m]),n(this,B,eo).style.color="";const y=(E,_,C)=>{const x=new Array(256),T=(f-u)/C,P=E/255,R=(_-E)/(255*C);let D=0;for(let M=0;M<=C;M++){const I=Math.round(u+M*T),G=P+M*R;for(let N=D;N<=I;N++)x[N]=G;D=I+1}for(let M=D;M<256;M++)x[M]=x[D-1];return x.join(",")},v=`g_${n(this,Zi)}_hcm_${e}_filter`,w=l.filter=b(this,B,io).call(this,v);return b(this,B,Df).call(this,w),b(this,B,lh).call(this,y(m[0],A[0],5),y(m[1],A[1],5),y(m[2],A[2],5),w),l.url=b(this,B,so).call(this,v),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,ea))!=null&&s.size)||((i=n(this,Qi))==null||i.parentNode.parentNode.remove(),p(this,Qi,null),(r=n(this,Bo))==null||r.clear(),p(this,Bo,null),(a=n(this,ea))==null||a.clear(),p(this,ea,null),p(this,sa,0))}}ta=new WeakMap,Bo=new WeakMap,Qi=new WeakMap,Zi=new WeakMap,Te=new WeakMap,ea=new WeakMap,sa=new WeakMap,B=new WeakSet,_e=function(){return n(this,Bo)||p(this,Bo,new Map)},ah=function(){return n(this,ea)||p(this,ea,new Map)},eo=function(){if(!n(this,Qi)){const e=n(this,Te).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,Te).createElementNS(Fi,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Qi,n(this,Te).createElementNS(Fi,"defs")),e.append(i),i.append(n(this,Qi)),n(this,Te).body.append(e)}return n(this,Qi)},Fd=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let f=0;f<256;f++)c[f]=h[f]/255;const u=c.join(",");return[u,u,u]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=i[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},so=function(e){if(n(this,ta)===void 0){p(this,ta,"");const s=n(this,Te).URL;s!==n(this,Te).baseURI&&(ud(s)?q('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,ta,Np(s,"")))}return`url(${n(this,ta)}#${e})`},Om=function(e){const s=n(this,Te).createElementNS(Fi,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},Df=function(e){const s=n(this,Te).createElementNS(Fi,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},io=function(e){const s=n(this,Te).createElementNS(Fi,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,B,eo).append(s),s},oh=function(e,s,i){const r=n(this,Te).createElementNS(Fi,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},lh=function(e,s,i,r){const a=n(this,Te).createElementNS(Fi,"feComponentTransfer");r.append(a),b(this,B,oh).call(this,a,"feFuncR",e),b(this,B,oh).call(this,a,"feFuncG",s),b(this,B,oh).call(this,a,"feFuncB",i)},Mf=function(e,s){const i=n(this,Te).createElementNS(Fi,"feComponentTransfer");s.append(i),b(this,B,oh).call(this,i,"feFuncA",e)},hh=function(e){return n(this,B,eo).style.color=e,Wl(getComputedStyle(n(this,B,eo)).getPropertyValue("color"))};class Bm{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){_t("Abstract method `_fetch` called.")}}class pg extends Bm{async _fetch(t){const e=await Vl(t,"arraybuffer");return new Uint8Array(e)}}class Hm{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){_t("Abstract method `_fetch` called.")}}class gg extends Hm{async _fetch(t){const e=await Vl(t,"arraybuffer");return new Uint8Array(e)}}Be&&q("Please use the `legacy` build in Node.js environments.");async function $p(d){const e=await process.getBuiltinModule("fs").promises.readFile(d);return new Uint8Array(e)}class tA extends Nm{}class eA extends Im{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:qu&&qu.tagName.toUpperCase()==="SCRIPT"&&qu.src||new URL("index-BiA_tnaq.cjs",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class sA extends Fm{async _fetch(t){return $p(t)}}class iA extends Bm{async _fetch(t){return $p(t)}}class nA extends Hm{async _fetch(t){return $p(t)}}const Qa="__forcedDependency",{floor:mg,ceil:bg}=Math;function Ed(d,t,e,s,i,r){d[t*4+0]=Math.min(d[t*4+0],e),d[t*4+1]=Math.min(d[t*4+1],s),d[t*4+2]=Math.max(d[t*4+2],i),d[t*4+3]=Math.max(d[t*4+3],r)}const Lf=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var Ho,qn;class rA{constructor(t,e){g(this,Ho);g(this,qn);p(this,Ho,t),p(this,qn,e)}get length(){return n(this,Ho).length}isEmpty(t){return n(this,Ho)[t]===Lf}minX(t){return n(this,qn)[t*4+0]/256}minY(t){return n(this,qn)[t*4+1]/256}maxX(t){return(n(this,qn)[t*4+2]+1)/256}maxY(t){return(n(this,qn)[t*4+3]+1)/256}}Ho=new WeakMap,qn=new WeakMap;const Sd=(d,t)=>{if(!d)return;let e=d.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},d.set(t,e)),e};var Ge,Ve,ia,Gs,na,tn,pt,mt,en,We,nc,Uo,ra,aa,sn,Pe,yi,rc,If;class aA{constructor(t,e,s=!1){g(this,rc);g(this,Ge,{__proto__:null});g(this,Ve,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Qa]:[]});g(this,ia,new Map);g(this,Gs,[]);g(this,na,[]);g(this,tn,[[1,0,0,1,0,0]]);g(this,pt,[-1/0,-1/0,1/0,1/0]);g(this,mt,new Float64Array([1/0,1/0,-1/0,-1/0]));g(this,en,-1);g(this,We,new Set);g(this,nc,new Map);g(this,Uo,new Map);g(this,ra);g(this,aa);g(this,sn);g(this,Pe);g(this,yi);p(this,ra,t.width),p(this,aa,t.height),b(this,rc,If).call(this,e),s&&p(this,yi,new Map)}growOperationsCount(t){t>=n(this,Pe).length&&b(this,rc,If).call(this,t,n(this,Pe))}save(t){return p(this,Ge,{__proto__:n(this,Ge)}),p(this,Ve,{__proto__:n(this,Ve),transform:{__proto__:n(this,Ve).transform},moveText:{__proto__:n(this,Ve).moveText},sameLineText:{__proto__:n(this,Ve).sameLineText},[Qa]:{__proto__:n(this,Ve)[Qa]}}),p(this,pt,{__proto__:n(this,pt)}),n(this,Gs).push(t),this}restore(t){var i;const e=Object.getPrototypeOf(n(this,Ge));if(e===null)return this;p(this,Ge,e),p(this,Ve,Object.getPrototypeOf(n(this,Ve))),p(this,pt,Object.getPrototypeOf(n(this,pt)));const s=n(this,Gs).pop();return s!==void 0&&((i=Sd(n(this,yi),t))==null||i.dependencies.add(s),n(this,Pe)[t]=n(this,Pe)[s]),this}recordOpenMarker(t){return n(this,Gs).push(t),this}getOpenMarker(){return n(this,Gs).length===0?null:n(this,Gs).at(-1)}recordCloseMarker(t){var s;const e=n(this,Gs).pop();return e!==void 0&&((s=Sd(n(this,yi),t))==null||s.dependencies.add(e),n(this,Pe)[t]=n(this,Pe)[e]),this}beginMarkedContent(t){return n(this,na).push(t),this}endMarkedContent(t){var s;const e=n(this,na).pop();return e!==void 0&&((s=Sd(n(this,yi),t))==null||s.dependencies.add(e),n(this,Pe)[t]=n(this,Pe)[e]),this}pushBaseTransform(t){return n(this,tn).push(H.multiplyByDOMMatrix(n(this,tn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,tn).length>1&&n(this,tn).pop(),this}recordSimpleData(t,e){return n(this,Ge)[t]=e,this}recordIncrementalData(t,e){return n(this,Ve)[t].push(e),this}resetIncrementalData(t,e){return n(this,Ve)[t].length=0,this}recordNamedData(t,e){return n(this,ia).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Ge)[t]=n(this,ia).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Qa,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Ge)&&this.recordFutureForcedDependency(e,n(this,Ge)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,We))this.recordFutureForcedDependency(Qa,t);return this}resetBBox(t){return n(this,en)!==t&&(p(this,en,t),n(this,mt)[0]=1/0,n(this,mt)[1]=1/0,n(this,mt)[2]=-1/0,n(this,mt)[3]=-1/0),this}recordClipBox(t,e,s,i,r,a){const o=H.multiplyByDOMMatrix(n(this,tn).at(-1),e.getTransform()),l=[1/0,1/0,-1/0,-1/0];H.axialAlignedBoundingBox([s,r,i,a],o,l);const h=H.intersect(n(this,pt),l);return h?(n(this,pt)[0]=h[0],n(this,pt)[1]=h[1],n(this,pt)[2]=h[2],n(this,pt)[3]=h[3]):(n(this,pt)[0]=n(this,pt)[1]=1/0,n(this,pt)[2]=n(this,pt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,pt);if(o[0]===1/0)return this;const l=H.multiplyByDOMMatrix(n(this,tn).at(-1),e.getTransform());if(o[0]===-1/0)return H.axialAlignedBoundingBox([s,r,i,a],l,n(this,mt)),this;const h=[1/0,1/0,-1/0,-1/0];return H.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,mt)[0]=Math.min(n(this,mt)[0],Math.max(h[0],o[0])),n(this,mt)[1]=Math.min(n(this,mt)[1],Math.max(h[1],o[1])),n(this,mt)[2]=Math.max(n(this,mt)[2],Math.min(h[2],o[2])),n(this,mt)[3]=Math.max(n(this,mt)[3],Math.min(h[3],o[3])),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&n(this,Uo).get(s),h!==!1&&(c=[0,0,0,0],H.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&H.scaleMinMax([i,0,0,-i,r,a],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const u=o();return l&&c&&h===void 0&&(h=c[0]<=r-u.actualBoundingBoxLeft&&c[2]>=r+u.actualBoundingBoxRight&&c[1]<=a-u.actualBoundingBoxAscent&&c[3]>=a+u.actualBoundingBoxDescent,n(this,Uo).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,mt)[0]=Math.max(0,n(this,pt)[0]),n(this,mt)[1]=Math.max(0,n(this,pt)[1]),n(this,mt)[2]=Math.min(n(this,ra),n(this,pt)[2]),n(this,mt)[3]=Math.min(n(this,aa),n(this,pt)[3]),this}getSimpleIndex(t){return n(this,Ge)[t]}recordDependencies(t,e){const s=n(this,We),i=n(this,Ge),r=n(this,Ve);for(const a of e)a in n(this,Ge)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,ia).has(e)&&n(this,We).add(n(this,ia).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Qa]),n(this,yi)){const s=Sd(n(this,yi),t),{dependencies:i}=s;n(this,We).forEach(i.add,i),n(this,Gs).forEach(i.add,i),n(this,na).forEach(i.add,i),i.delete(t),s.isRenderingOperation=!0}if(n(this,en)===t){const s=mg(n(this,mt)[0]*256/n(this,ra)),i=mg(n(this,mt)[1]*256/n(this,aa)),r=bg(n(this,mt)[2]*256/n(this,ra)),a=bg(n(this,mt)[3]*256/n(this,aa));Ed(n(this,sn),t,s,i,r,a);for(const o of n(this,We))o!==t&&Ed(n(this,sn),o,s,i,r,a);for(const o of n(this,Gs))o!==t&&Ed(n(this,sn),o,s,i,r,a);for(const o of n(this,na))o!==t&&Ed(n(this,sn),o,s,i,r,a);e||(n(this,We).clear(),p(this,en,-1))}return this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,We));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){return n(this,en)===t&&(p(this,en,-1),n(this,pt)[0]=Math.max(n(this,pt)[0],n(this,mt)[0]),n(this,pt)[1]=Math.max(n(this,pt)[1],n(this,mt)[1]),n(this,pt)[2]=Math.min(n(this,pt)[2],n(this,mt)[2]),n(this,pt)[3]=Math.min(n(this,pt)[3],n(this,mt)[3]),e||n(this,We).clear()),this}_takePendingDependencies(){const t=n(this,We);return p(this,We,new Set),t}_extractOperation(t){const e=n(this,nc).get(t);return n(this,nc).delete(t),e}_pushPendingDependencies(t){for(const e of t)n(this,We).add(e)}take(){return n(this,Uo).clear(),new rA(n(this,Pe),n(this,sn))}takeDebugMetadata(){return n(this,yi)}}Ge=new WeakMap,Ve=new WeakMap,ia=new WeakMap,Gs=new WeakMap,na=new WeakMap,tn=new WeakMap,pt=new WeakMap,mt=new WeakMap,en=new WeakMap,We=new WeakMap,nc=new WeakMap,Uo=new WeakMap,ra=new WeakMap,aa=new WeakMap,sn=new WeakMap,Pe=new WeakMap,yi=new WeakMap,rc=new WeakSet,If=function(t,e){const s=new ArrayBuffer(t*4);p(this,sn,new Uint8ClampedArray(s)),p(this,Pe,new Uint32Array(s)),e&&e.length>0?(n(this,Pe).set(e),n(this,Pe).fill(Lf,e.length)):n(this,Pe).fill(Lf)};var Et,Ht,Vs,jo,$o;const tg=class tg{constructor(t,e,s){g(this,Et);g(this,Ht);g(this,Vs);g(this,jo,0);g(this,$o,0);if(t instanceof tg&&n(t,Vs)===!!s)return t;p(this,Et,t),p(this,Ht,e),p(this,Vs,!!s)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Kt(this,$o)._++,n(this,Et).save(n(this,Ht)),this}restore(t){return n(this,$o)>0&&(n(this,Et).restore(n(this,Ht)),Kt(this,$o)._--),this}recordOpenMarker(t){return Kt(this,jo)._++,this}getOpenMarker(){return n(this,jo)>0?n(this,Ht):n(this,Et).getOpenMarker()}recordCloseMarker(t){return Kt(this,jo)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,Et).pushBaseTransform(t),this}popBaseTransform(){return n(this,Et).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Et).recordSimpleData(t,n(this,Ht)),this}recordIncrementalData(t,e){return n(this,Et).recordIncrementalData(t,n(this,Ht)),this}resetIncrementalData(t,e){return n(this,Et).resetIncrementalData(t,n(this,Ht)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,Et).recordSimpleDataFromNamed(t,e,n(this,Ht)),this}recordFutureForcedDependency(t,e){return n(this,Et).recordFutureForcedDependency(t,n(this,Ht)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,Et).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Et).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Vs)||n(this,Et).resetBBox(n(this,Ht)),this}recordClipBox(t,e,s,i,r,a){return n(this,Vs)||n(this,Et).recordClipBox(n(this,Ht),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Vs)||n(this,Et).recordBBox(n(this,Ht),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Vs)||n(this,Et).recordCharacterBBox(n(this,Ht),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Vs)||n(this,Et).recordFullPageBBox(n(this,Ht)),this}getSimpleIndex(t){return n(this,Et).getSimpleIndex(t)}recordDependencies(t,e){return n(this,Et).recordDependencies(n(this,Ht),e),this}recordNamedDependency(t,e){return n(this,Et).recordNamedDependency(n(this,Ht),e),this}recordOperation(t){return n(this,Et).recordOperation(n(this,Ht),!0),this}recordShowTextOperation(t){return n(this,Et).recordShowTextOperation(n(this,Ht),!0),this}bboxToClipBoxDropOperation(t){return n(this,Vs)||n(this,Et).bboxToClipBoxDropOperation(n(this,Ht),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Et=new WeakMap,Ht=new WeakMap,Vs=new WeakMap,jo=new WeakMap,$o=new WeakMap;let hu=tg;const Ss={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},ye={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Ff(d,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),d.clip(i)}class zp{isModifyingCurrentTransform(){return!1}getPattern(){_t("Abstract method `getPattern` called.")}}class oA extends zp{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let r;if(i===ye.STROKE||i===ye.FILL){const a=e.current.getClippedPathBoundingBox(i,Ft(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=H.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Ff(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(s);r.setTransform(u)}else Ff(t,this._bbox),r=this._createGradient(t);return r}}function Zu(d,t,e,s,i,r,a,o){const l=t.coords,h=t.colors,c=d.data,u=d.width*4;let f;l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=r,r=a,a=f),l[s+1]>l[i+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=r,r=a,a=f);const m=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,w=(l[i]+t.offsetX)*t.scaleX,S=(l[i+1]+t.offsetY)*t.scaleY;if(A>=S)return;const E=h[r],_=h[r+1],C=h[r+2],x=h[a],T=h[a+1],P=h[a+2],R=h[o],D=h[o+1],M=h[o+2],I=Math.round(A),G=Math.round(S);let N,W,O,F,tt,it,ee,Je;for(let rt=I;rt<=G;rt++){if(rt<v){const wt=rt<A?0:(A-rt)/(A-v);N=m-(m-y)*wt,W=E-(E-x)*wt,O=_-(_-T)*wt,F=C-(C-P)*wt}else{let wt;rt>S?wt=1:v===S?wt=0:wt=(v-rt)/(v-S),N=y-(y-w)*wt,W=x-(x-R)*wt,O=T-(T-D)*wt,F=P-(P-M)*wt}let ht;rt<A?ht=0:rt>S?ht=1:ht=(A-rt)/(A-S),tt=m-(m-w)*ht,it=E-(E-R)*ht,ee=_-(_-D)*ht,Je=C-(C-M)*ht;const se=Math.round(Math.min(N,tt)),de=Math.round(Math.max(N,tt));let Ee=u*rt+se*4;for(let wt=se;wt<=de;wt++)ht=(N-wt)/(N-tt),ht<0?ht=0:ht>1&&(ht=1),c[Ee++]=W-(W-it)*ht|0,c[Ee++]=O-(O-ee)*ht|0,c[Ee++]=F-(F-Je)*ht|0,c[Ee++]=255}}function lA(d,t,e){const s=t.coords,i=t.colors;let r,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let c=r*o;for(let u=0;u<h;u++,c++)Zu(d,e,s[c],s[c+1],s[c+o],i[c],i[c+1],i[c+o]),Zu(d,e,s[c+o+1],s[c+1],s[c+o],i[c+o+1],i[c+1],i[c+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)Zu(d,e,s[r],s[r+1],s[r+2],i[r],i[r+1],i[r+2]);break;default:throw new Error("illegal figure")}}class hA extends zp{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),m=h/u,A=c/f,y={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/m,scaleY:1/A},v=u+4,w=f+4,S=s.getCanvas("mesh",v,w),E=S.context,_=E.createImageData(u,f);if(e){const x=_.data;for(let T=0,P=x.length;T<P;T+=4)x[T]=e[0],x[T+1]=e[1],x[T+2]=e[2],x[T+3]=255}for(const x of this._figures)lA(_,x,y);return E.putImageData(_,2,2),{canvas:S.canvas,offsetX:o-2*m,offsetY:l-2*A,scaleX:m,scaleY:A}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Ff(t,this._bbox);const r=new Float32Array(2);if(i===ye.SHADING)H.singularValueDecompose2dScale(Ft(t),r);else if(this.matrix){H.singularValueDecompose2dScale(this.matrix,r);const[o,l]=r;H.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else H.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,i===ye.SHADING?null:this._background,e.cachedCanvases);return i!==ye.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class cA extends zp{getPattern(){return"hotpink"}}function dA(d){switch(d[0]){case"RadialAxial":return new oA(d);case"Mesh":return new hA(d);case"Dummy":return new cA}throw new Error(`Unknown IR type: ${d[0]}`)}const yg={COLORED:1,UNCOLORED:2},xu=class xu{constructor(t,e,s,i){this.color=t[1],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.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i}createPatternCanvas(t,e){var it,ee;const{bbox:s,operatorList:i,paintType:r,tilingType:a,color:o,canvasGraphicsFactory:l}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),Bu("TilingType: "+a);const u=s[0],f=s[1],m=s[2],A=s[3],y=m-u,v=A-f,w=new Float32Array(2);H.singularValueDecompose2dScale(this.matrix,w);const[S,E]=w;H.singularValueDecompose2dScale(this.baseTransform,w);const _=S*w[0],C=E*w[1];let x=y,T=v,P=!1,R=!1;const D=Math.ceil(h*_),M=Math.ceil(c*C),I=Math.ceil(y*_),G=Math.ceil(v*C);D>=I?x=h:P=!0,M>=G?T=c:R=!0;const N=this.getSizeAndScale(x,this.ctx.canvas.width,_),W=this.getSizeAndScale(T,this.ctx.canvas.height,C),O=t.cachedCanvases.getCanvas("pattern",N.size,W.size),F=O.context,tt=l.createCanvasGraphics(F,e);if(tt.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(tt,r,o),F.translate(-N.scale*u,-W.scale*f),tt.transform(0,N.scale,0,0,W.scale,0,0),F.save(),(it=tt.dependencyTracker)==null||it.save(),this.clipBbox(tt,u,f,m,A),tt.baseTransform=Ft(tt.ctx),tt.executeOperatorList(i),tt.endDrawing(),(ee=tt.dependencyTracker)==null||ee.restore(),F.restore(),P||R){const Je=O.canvas;P&&(x=h),R&&(T=c);const rt=this.getSizeAndScale(x,this.ctx.canvas.width,_),ht=this.getSizeAndScale(T,this.ctx.canvas.height,C),se=rt.size,de=ht.size,Ee=t.cachedCanvases.getCanvas("pattern-workaround",se,de),wt=Ee.context,Os=P?Math.floor(y/h):0,ii=R?Math.floor(v/c):0;for(let Ii=0;Ii<=Os;Ii++)for(let Me=0;Me<=ii;Me++)wt.drawImage(Je,se*Ii,de*Me,se,de,0,0,se,de);return{canvas:Ee.canvas,scaleX:rt.scale,scaleY:ht.scale,offsetX:u,offsetY:f}}return{canvas:O.canvas,scaleX:N.scale,scaleY:W.scale,offsetX:u,offsetY:f}}getSizeAndScale(t,e,s){const i=Math.max(xu.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s;t.ctx.rect(e,s,a,o),H.axialAlignedBoundingBox([e,s,i,r],Ft(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(e){case yg.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case yg.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new My(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){let a=s;i!==ye.SHADING&&(a=H.transform(a,e.baseTransform),this.matrix&&(a=H.transform(a,this.matrix)));const o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const h=t.createPattern(o.canvas,"repeat");return h.setTransform(l),h}};k(xu,"MAX_PATTERN_SIZE",3e3);let Nf=xu;function uA({src:d,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ce.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,u=s&7,f=d.length;e=new Uint32Array(e.buffer);let m=0;for(let A=0;A<i;A++){for(const v=t+c;t<v;t++){const w=t<f?d[t]:255;e[m++]=w&128?h:l,e[m++]=w&64?h:l,e[m++]=w&32?h:l,e[m++]=w&16?h:l,e[m++]=w&8?h:l,e[m++]=w&4?h:l,e[m++]=w&2?h:l,e[m++]=w&1?h:l}if(u===0)continue;const y=t<f?d[t++]:255;for(let v=0;v<u;v++)e[m++]=y&1<<7-v?h:l}return{srcPos:t,destPos:m}}const Ag=16,wg=100,fA=15,vg=10,Ke=16,tf=new DOMMatrix,ys=new Float32Array(2),oo=new Float32Array([1/0,1/0,-1/0,-1/0]);function pA(d,t){if(d._removeMirroring)throw new Error("Context is already forwarding operations.");d.__originalSave=d.save,d.__originalRestore=d.restore,d.__originalRotate=d.rotate,d.__originalScale=d.scale,d.__originalTranslate=d.translate,d.__originalTransform=d.transform,d.__originalSetTransform=d.setTransform,d.__originalResetTransform=d.resetTransform,d.__originalClip=d.clip,d.__originalMoveTo=d.moveTo,d.__originalLineTo=d.lineTo,d.__originalBezierCurveTo=d.bezierCurveTo,d.__originalRect=d.rect,d.__originalClosePath=d.closePath,d.__originalBeginPath=d.beginPath,d._removeMirroring=()=>{d.save=d.__originalSave,d.restore=d.__originalRestore,d.rotate=d.__originalRotate,d.scale=d.__originalScale,d.translate=d.__originalTranslate,d.transform=d.__originalTransform,d.setTransform=d.__originalSetTransform,d.resetTransform=d.__originalResetTransform,d.clip=d.__originalClip,d.moveTo=d.__originalMoveTo,d.lineTo=d.__originalLineTo,d.bezierCurveTo=d.__originalBezierCurveTo,d.rect=d.__originalRect,d.closePath=d.__originalClosePath,d.beginPath=d.__originalBeginPath,delete d._removeMirroring},d.save=function(){t.save(),this.__originalSave()},d.restore=function(){t.restore(),this.__originalRestore()},d.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},d.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},d.transform=function(e,s,i,r,a,o){t.transform(e,s,i,r,a,o),this.__originalTransform(e,s,i,r,a,o)},d.setTransform=function(e,s,i,r,a,o){t.setTransform(e,s,i,r,a,o),this.__originalSetTransform(e,s,i,r,a,o)},d.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},d.rotate=function(e){t.rotate(e),this.__originalRotate(e)},d.clip=function(e){t.clip(e),this.__originalClip(e)},d.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},d.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},d.bezierCurveTo=function(e,s,i,r,a,o){t.bezierCurveTo(e,s,i,r,a,o),this.__originalBezierCurveTo(e,s,i,r,a,o)},d.rect=function(e,s,i,r){t.rect(e,s,i,r),this.__originalRect(e,s,i,r)},d.closePath=function(){t.closePath(),this.__originalClosePath()},d.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class gA{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function _d(d,t,e,s,i,r,a,o,l,h){const[c,u,f,m,A,y]=Ft(d);if(u===0&&f===0){const S=a*c+A,E=Math.round(S),_=o*m+y,C=Math.round(_),x=(a+l)*c+A,T=Math.abs(Math.round(x)-E)||1,P=(o+h)*m+y,R=Math.abs(Math.round(P)-C)||1;return d.setTransform(Math.sign(c),0,0,Math.sign(m),E,C),d.drawImage(t,e,s,i,r,0,0,T,R),d.setTransform(c,u,f,m,A,y),[T,R]}if(c===0&&m===0){const S=o*f+A,E=Math.round(S),_=a*u+y,C=Math.round(_),x=(o+h)*f+A,T=Math.abs(Math.round(x)-E)||1,P=(a+l)*u+y,R=Math.abs(Math.round(P)-C)||1;return d.setTransform(0,Math.sign(u),Math.sign(f),0,E,C),d.drawImage(t,e,s,i,r,0,0,R,T),d.setTransform(c,u,f,m,A,y),[R,T]}d.drawImage(t,e,s,i,r,a,o,l,h);const v=Math.hypot(c,u),w=Math.hypot(f,m);return[v*l,w*h]}class Eg{constructor(t,e,s){k(this,"alphaIsShape",!1);k(this,"fontSize",0);k(this,"fontSizeScale",1);k(this,"textMatrix",null);k(this,"textMatrixScale",1);k(this,"fontMatrix",lf);k(this,"leading",0);k(this,"x",0);k(this,"y",0);k(this,"lineX",0);k(this,"lineY",0);k(this,"charSpacing",0);k(this,"wordSpacing",0);k(this,"textHScale",1);k(this,"textRenderingMode",ue.FILL);k(this,"textRise",0);k(this,"fillColor","#000000");k(this,"strokeColor","#000000");k(this,"patternFill",!1);k(this,"patternStroke",!1);k(this,"fillAlpha",1);k(this,"strokeAlpha",1);k(this,"lineWidth",1);k(this,"activeSMask",null);k(this,"transferMaps","none");s==null||s(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=oo.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=ye.FILL,e=null){const s=this.minMax.slice();if(t===ye.STROKE){e||_t("Stroke bounding box must include transform."),H.singularValueDecompose2dScale(e,ys);const i=ys[0]*this.lineWidth/2,r=ys[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=H.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(oo,0)}getClippedPathBoundingBox(t=ye.FILL,e=null){return H.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Sg(d,t){if(t instanceof ImageData){d.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Ke,r=(e-i)/Ke,a=i===0?r:r+1,o=d.createImageData(s,Ke);let l=0,h;const c=t.data,u=o.data;let f,m,A,y;if(t.kind===wh.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(u.buffer,0,u.byteLength>>2),S=w.length,E=s+7>>3,_=4294967295,C=ce.isLittleEndian?4278190080:255;for(f=0;f<a;f++){for(A=f<r?Ke:i,h=0,m=0;m<A;m++){const x=v-l;let T=0;const P=x>E?s:x*8-7,R=P&-8;let D=0,M=0;for(;T<R;T+=8)M=c[l++],w[h++]=M&128?_:C,w[h++]=M&64?_:C,w[h++]=M&32?_:C,w[h++]=M&16?_:C,w[h++]=M&8?_:C,w[h++]=M&4?_:C,w[h++]=M&2?_:C,w[h++]=M&1?_:C;for(;T<P;T++)D===0&&(M=c[l++],D=128),w[h++]=M&D?_:C,D>>=1}for(;h<S;)w[h++]=0;d.putImageData(o,0,f*Ke)}}else if(t.kind===wh.RGBA_32BPP){for(m=0,y=s*Ke*4,f=0;f<r;f++)u.set(c.subarray(l,l+y)),l+=y,d.putImageData(o,0,m),m+=Ke;f<a&&(y=s*i*4,u.set(c.subarray(l,l+y)),d.putImageData(o,0,m))}else if(t.kind===wh.RGB_24BPP)for(A=Ke,y=s*A,f=0;f<a;f++){for(f>=r&&(A=i,y=s*A),h=0,m=y;m--;)u[h++]=c[l++],u[h++]=c[l++],u[h++]=c[l++],u[h++]=255;d.putImageData(o,0,f*Ke)}else throw new Error(`bad image kind: ${t.kind}`)}function _g(d,t){if(t.bitmap){d.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Ke,r=(e-i)/Ke,a=i===0?r:r+1,o=d.createImageData(s,Ke);let l=0;const h=t.data,c=o.data;for(let u=0;u<a;u++){const f=u<r?Ke:i;({srcPos:l}=uA({src:h,srcPos:l,dest:c,width:s,height:f,nonBlackColor:0})),d.putImageData(o,0,u*Ke)}}function Yl(d,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)d[s]!==void 0&&(t[s]=d[s]);d.setLineDash!==void 0&&(t.setLineDash(d.getLineDash()),t.lineDashOffset=d.lineDashOffset)}function Cd(d){d.strokeStyle=d.fillStyle="#000000",d.fillRule="nonzero",d.globalAlpha=1,d.lineWidth=1,d.lineCap="butt",d.lineJoin="miter",d.miterLimit=10,d.globalCompositeOperation="source-over",d.font="10px sans-serif",d.setLineDash!==void 0&&(d.setLineDash([]),d.lineDashOffset=0);const{filter:t}=d;t!=="none"&&t!==""&&(d.filter="none")}function Cg(d,t){if(t)return!0;H.singularValueDecompose2dScale(d,ys);const e=Math.fround(ei.pixelRatio*_n.PDF_TO_CSS_UNITS);return ys[0]<=e&&ys[1]<=e}const mA=["butt","round","square"],bA=["miter","round","bevel"],yA={},xg={};var si,Of,Bf,Hf;const eg=class eg{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c){g(this,si);this.ctx=t,this.current=new Eg(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=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new gA(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null}getObject(t,e,s=null){var i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Ft(this.compositeCtx))}this.ctx.save(),Cd(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=Ft(this.ctx)}executeOperatorList(t,e,s,i,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>vg&&typeof s=="function",u=c?Date.now()+fA:0;let f=0;const m=this.commonObjs,A=this.objs;let y,v;for(;;){if(i!==void 0&&l===i.nextBreakPoint)return i.breakIt(l,s),l;if(!r||r(l))if(y=o[l],v=a[l]??null,y!==$l.dependency)v===null?this[y](l):this[y](l,...v);else for(const S of v){(w=this.dependencyTracker)==null||w.recordNamedData(S,l);const E=S.startsWith("g_")?m:A;if(!E.has(S))return E.get(S,s),l}if(l++,l===h)return l;if(c&&++f>vg){if(Date.now()>u)return s(),l;f=0}}}endDrawing(){b(this,si,Of).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,si,Bf).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,h="prescale1",c,u;for(;r>2&&o>1||a>2&&l>1;){let f=o,m=l;r>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),r/=o/f),a>2&&l>1&&(m=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/m),c=this.cachedCanvases.getCanvas(h,f,m),u=c.context,u.clearRect(0,0,f,m),u.drawImage(t,0,0,o,l,0,0,f,m),t=c.canvas,o=f,l=m,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t,e){var D,M;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Ft(s);let h,c,u,f;if((e.bitmap||e.data)&&e.count>1){const I=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.get(I),h||(h=new Map,this._cachedBitmapsMap.set(I,h));const G=h.get(c);if(G&&!o){const N=Math.round(Math.min(l[0],l[2])+l[4]),W=Math.round(Math.min(l[1],l[3])+l[5]);return(D=this.dependencyTracker)==null||D.recordDependencies(t,Ss.transformAndFill),{canvas:G,offsetX:N,offsetY:W}}u=G}u||(f=this.cachedCanvases.getCanvas("maskCanvas",i,r),_g(f.context,e));let m=H.transform(l,[1/i,0,0,-1/r,0,0]);m=H.transform(m,[1,0,0,1,0,-r]);const A=oo.slice();H.axialAlignedBoundingBox([0,0,i,r],m,A);const[y,v,w,S]=A,E=Math.round(w-y)||1,_=Math.round(S-v)||1,C=this.cachedCanvases.getCanvas("fillCanvas",E,_),x=C.context,T=y,P=v;x.translate(-T,-P),x.transform(...m),u||(u=this._scaleImage(f.canvas,ni(x)),u=u.img,h&&o&&h.set(c,u)),x.imageSmoothingEnabled=Cg(Ft(x),e.interpolate),_d(x,u,0,0,u.width,u.height,0,0,i,r),x.globalCompositeOperation="source-in";const R=H.transform(ni(x),[1,0,0,1,-T,-P]);return x.fillStyle=o?a.getPattern(s,this,R,ye.FILL,t):a,x.fillRect(0,0,i,r),h&&!o&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),(M=this.dependencyTracker)==null||M.recordDependencies(t,Ss.transformAndFill),{canvas:C.canvas,offsetX:Math.round(T),offsetY:Math.round(P)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=mA[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=bA[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,r,a,o;for(const[l,h]of e)switch(l){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,s=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(i,e,s);this.suspendedCtx=this.ctx;const a=this.ctx=r.context;a.setTransform(this.suspendedCtx.getTransform()),Yl(this.suspendedCtx,a),pA(a,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Yl(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];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,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,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,r,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,r,a,o,l,h,c,u){let f=t.canvas,m=l-c,A=h-u;if(a)if(m<0||A<0||m+s>f.width||A+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),w=v.context;w.drawImage(f,-m,-A),w.globalCompositeOperation="destination-atop",w.fillStyle=a,w.fillRect(0,0,s,i),w.globalCompositeOperation="source-over",f=v.canvas,m=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(m,A,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(m,A,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const y=new Path2D;y.rect(l,h,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(f,m,A,s,i,l,h,s,i),e.restore()}save(t){var s;this.inSMaskMode&&Yl(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Yl(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),this[e](t,r);return}if(this.dependencyTracker!==null){const a=e===$l.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}if(!(r instanceof Path2D)){const a=s[0]=new Path2D;for(let o=0,l=r.length;o<l;)switch(r[o++]){case yd.moveTo:a.moveTo(r[o++],r[o++]);break;case yd.lineTo:a.lineTo(r[o++],r[o++]);break;case yd.curveTo:a.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);break;case yd.closePath:a.closePath();break;default:q(`Unrecognized drawing path operator: ${r[o-1]}`);break}r=a}H.axialAlignedBoundingBox(i,Ft(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var a;const i=this.ctx,r=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const o=r.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=r.getPattern(i,this,ni(i),ye.STROKE,t),o){const l=new Path2D;l.addPath(e,i.getTransform().invertSelf().multiplySelf(o)),e=l}this.rescaleAndStroke(e,!1),i.restore()}else this.rescaleAndStroke(e,!0);(a=this.dependencyTracker)==null||a.recordDependencies(t,Ss.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(ye.STROKE,Ft(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,c,u;const i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;if(a){const f=r.isModifyingCurrentTransform()?i.getTransform():null;if((h=this.dependencyTracker)==null||h.save(t),i.save(),i.fillStyle=r.getPattern(i,this,ni(i),ye.FILL,t),f){const m=new Path2D;m.addPath(e,i.getTransform().invertSelf().multiplySelf(f)),e=m}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(i.fill(e,"evenodd"),this.pendingEOFill=!1):i.fill(e)),(c=this.dependencyTracker)==null||c.recordDependencies(t,Ss.fill),o&&(i.restore(),(u=this.dependencyTracker)==null||u.restore(t)),s&&this.consumePath(t,e,l)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var s;this.ctx.fill(e),(s=this.dependencyTracker)==null||s.recordDependencies(t,Ss.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=yA}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=xg}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&i.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var u,f;(u=this.dependencyTracker)==null||u.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||lf,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&q("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const h=i.italic?"italic":"normal";let c=s;s<Ag?c=Ag:s>wg&&(c=wg),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,s,i,r,a){var w,S,E,_;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,u=l.fontSize/l.fontSizeScale,f=c&ue.FILL_STROKE_MASK,m=!!(c&ue.ADD_TO_PATH_FLAG),A=l.patternFill&&!h.missingFile,y=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||m||A||y)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||A||y)){o.save(),o.translate(s,i),o.scale(u,-u),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(f===ue.FILL||f===ue.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const x=b(this,si,Hf).call(this,v,C,r);o.fill(x)}else o.fill(v);if(f===ue.STROKE||f===ue.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:x,b:T,c:P,d:R}=C,D=H.inverseTransform(a),M=H.transform([x,T,P,R,0,0],D);H.singularValueDecompose2dScale(M,ys),o.lineWidth*=Math.max(ys[0],ys[1])/u,o.stroke(b(this,si,Hf).call(this,v,C,a))}else o.lineWidth/=u,o.stroke(v);o.restore()}else(f===ue.FILL||f===ue.FILL_STROKE)&&(o.fillText(e,s,i),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,u,s,i,()=>o.measureText(e))),(f===ue.STROKE||f===ue.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,u,s,i,()=>o.measureText(e)).recordDependencies(t,Ss.stroke)),o.strokeText(e,s,i));m&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ft(o),x:s,y:i,fontSize:u,path:v}),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,h,u,s,i))}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return J(this,"isFontSubpixelAAEnabled",s)}showText(t,e){var P,R,D,M;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Ss.showText).resetBBox(t),this.current.textRenderingMode&ue.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){this.showType3Text(t,e),(P=this.dependencyTracker)==null||P.recordShowTextOperation(t);return}const r=s.fontSize;if(r===0){(R=this.dependencyTracker)==null||R.recordOperation(t);return}const a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,u=s.textHScale*c,f=e.length,m=i.vertical,A=m?1:-1,y=i.defaultVMetrics,v=r*s.fontMatrix[0],w=s.textRenderingMode===ue.FILL&&!i.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),c>0?a.scale(u,-1):a.scale(u,1);let S,E;if(s.patternFill){a.save();const I=s.fillColor.getPattern(a,this,ni(a),ye.FILL,t);S=Ft(a),a.restore(),a.fillStyle=I}if(s.patternStroke){a.save();const I=s.strokeColor.getPattern(a,this,ni(a),ye.STROKE,t);E=Ft(a),a.restore(),a.strokeStyle=I}let _=s.lineWidth;const C=s.textMatrixScale;if(C===0||_===0){const I=s.textRenderingMode&ue.FILL_STROKE_MASK;(I===ue.STROKE||I===ue.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=C;if(o!==1&&(a.scale(o,o),_/=o),a.lineWidth=_,i.isInvalidPDFjsFont){const I=[];let G=0;for(const W of e)I.push(W.unicode),G+=W.width;const N=I.join("");if(a.fillText(N,0,0),this.dependencyTracker!==null){const W=a.measureText(N);this.dependencyTracker.recordBBox(t,this.ctx,-W.actualBoundingBoxLeft,W.actualBoundingBoxRight,-W.actualBoundingBoxAscent,W.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=G*v*u,a.restore(),this.compose();return}let x=0,T;for(T=0;T<f;++T){const I=e[T];if(typeof I=="number"){x+=A*I*r/1e3;continue}let G=!1;const N=(I.isSpace?h:0)+l,W=I.fontChar,O=I.accent;let F,tt,it=I.width;if(m){const rt=I.vmetric||y,ht=-(I.vmetric?rt[1]:it*.5)*v,se=rt[2]*v;it=rt?-rt[0]:it,F=ht/o,tt=(x+se)/o}else F=x/o,tt=0;let ee;if(i.remeasure&&it>0){ee=a.measureText(W);const rt=ee.width*1e3/r*o;if(it<rt&&this.isFontSubpixelAAEnabled){const ht=it/rt;G=!0,a.save(),a.scale(ht,1),F/=ht}else it!==rt&&(F+=(it-rt)/2e3*r/o)}if(this.contentVisible&&(I.isInFont||i.missingFile)){if(w&&!O)a.fillText(W,F,tt),(D=this.dependencyTracker)==null||D.recordCharacterBBox(t,a,ee?{bbox:null}:i,r/o,F,tt,()=>ee??a.measureText(W));else if(this.paintChar(t,W,F,tt,S,E),O){const rt=F+r*O.offset.x/o,ht=tt-r*O.offset.y/o;this.paintChar(t,O.fontChar,rt,ht,S,E)}}const Je=m?it*v-N*c:it*v+N*c;x+=Je,G&&a.restore()}m?s.y-=x:s.x+=x*u,a.restore(),this.compose(),(M=this.dependencyTracker)==null||M.recordShowTextOperation(t)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,u=i.textHScale*o,f=i.fontMatrix||lf,m=e.length,A=i.textRenderingMode===ue.INVISIBLE;let y,v,w,S;if(A||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(u,o);const E=this.dependencyTracker;for(this.dependencyTracker=E?new hu(E,t):null,y=0;y<m;++y){if(v=e[y],typeof v=="number"){S=l*v*a/1e3,this.ctx.translate(S,0),i.x+=S*u;continue}const _=(v.isSpace?c:0)+h,C=r.charProcOperatorList[v.operatorListId];C?this.contentVisible&&(this.save(),s.scale(a,a),s.transform(...f),this.executeOperatorList(C),this.restore()):q(`Type3 character "${v.operatorListId}" is not available.`);const x=[v.width,0];H.applyTransform(x,f),w=x[0]*a+_,s.translate(w,0),i.x+=w*u}s.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,a,o){var h;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,i,a,r,o).recordClipBox(t,this.ctx,i,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||Ft(this.ctx),r={createCanvasGraphics:(a,o)=>new eg(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new hu(this.dependencyTracker,o,!0):null)};s=new Nf(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=dA(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){var a;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const i=this._getPattern(t,e);s.fillStyle=i.getPattern(s,this,ni(s),ye.SHADING,t);const r=ni(s);if(r){const{width:o,height:l}=s.canvas,h=oo.slice();H.axialAlignedBoundingBox([0,0,o,l],r,h);const[c,u,f,m]=h;this.ctx.fillRect(c,u,f-c,m-u)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(a=this.dependencyTracker)==null||a.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ss.transform).recordDependencies(t,Ss.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){_t("Should not call beginInlineImage")}beginImageData(){_t("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Ft(this.ctx),s)){H.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(i=this.dependencyTracker)==null||i.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var E;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;e.isolated||Bu("TODO: Support non-isolated groups."),e.knockout&&q("Knockout groups not supported.");const i=Ft(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=oo.slice();H.axialAlignedBoundingBox(e.bbox,Ft(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=H.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),c=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let u="groupAt"+this.groupLevel;e.smask&&(u+="_smask_"+this.smaskCounter++%2);const f=this.cachedCanvases.getCanvas(u,h,c),m=f.context;m.translate(-o,-l),m.transform(...i);let A=new Path2D;const[y,v,w,S]=e.bbox;if(A.rect(y,v,w-y,S-v),e.matrix){const _=new Path2D;_.addPath(A,new DOMMatrix(e.matrix)),A=_}m.clip(A),e.smask&&this.smaskStack.push({canvas:f.canvas,context:m,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),Yl(s,m),this.ctx=m,(E=this.dependencyTracker)==null||E.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const a=Ft(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...a);const o=oo.slice();H.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],a,o),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,e,s,i,r,a){if(b(this,si,Of).call(this),Cd(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const o=s[2]-s[0],l=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=o,s[3]=l,H.singularValueDecompose2dScale(Ft(this.ctx),ys);const{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),u=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);const{canvas:f,context:m}=this.annotationCanvas;this.annotationCanvasMap.set(e,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(ys[0],0,0,-ys[1],0,l*ys[1]),Cd(this.ctx)}else{Cd(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new Eg(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...i),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,si,Bf).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var o;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,r.offsetX,r.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var u,f,m;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=this.ctx;l.save();const h=Ft(l);l.transform(s,i,r,a,0,0);const c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),(u=this.dependencyTracker)==null||u.resetBBox(t);for(let A=0,y=o.length;A<y;A+=2){const v=H.transform(h,[s,i,r,a,o[A],o[A+1]]);l.drawImage(c.canvas,v[4],v[5]),(f=this.dependencyTracker)==null||f.recordBBox(t,this.ctx,v[4],v[4]+c.canvas.width,v[5],v[5]+c.canvas.height)}l.restore(),this.compose(),(m=this.dependencyTracker)==null||m.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var a,o,l;if(!this.contentVisible)return;const s=this.ctx,i=this.current.fillColor,r=this.current.patternFill;(a=this.dependencyTracker)==null||a.resetBBox(t).recordDependencies(t,Ss.transformAndFill);for(const h of e){const{data:c,width:u,height:f,transform:m}=h,A=this.cachedCanvases.getCanvas("maskCanvas",u,f),y=A.context;y.save();const v=this.getObject(t,c,h);_g(y,v),y.globalCompositeOperation="source-in",y.fillStyle=r?i.getPattern(y,this,ni(s),ye.FILL,t):i,y.fillRect(0,0,u,f),y.restore(),s.save(),s.transform(...m),s.scale(1,-1),_d(s,A.canvas,0,0,u,f,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,s,0,u,0,f),s.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){q("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){q("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,u=r.length;c<u;c+=2)h.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,r=this.cachedCanvases.getCanvas("inlineImage",s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",r.canvas}paintInlineImageXObject(t,e){var h;if(!this.contentVisible)return;const s=e.width,i=e.height,r=this.ctx;this.save(t);const{filter:a}=r;a!=="none"&&a!==""&&(r.filter="none"),r.scale(1/s,-1/i);let o;if(e.bitmap)o=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)o=e;else{const u=this.cachedCanvases.getCanvas("inlineImage",s,i).context;Sg(u,e),o=this.applyTransferMapsToCanvas(u)}const l=this._scaleImage(o,ni(r));r.imageSmoothingEnabled=Cg(Ft(r),e.interpolate),(h=this.dependencyTracker)==null||h.resetBBox(t).recordBBox(t,r,0,s,-i,0).recordDependencies(t,Ss.imageXObject).recordOperation(t),_d(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-i,s,i),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){var a,o,l;if(!this.contentVisible)return;const i=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const h=e.width,c=e.height,f=this.cachedCanvases.getCanvas("inlineImage",h,c).context;Sg(f,e),r=this.applyTransferMapsToCanvas(f)}(a=this.dependencyTracker)==null||a.resetBBox(t);for(const h of s)i.save(),i.transform(...h.transform),i.scale(1,-1),_d(i,r,h.x,h.y,h.w,h.h,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,i,0,1,-1,0),i.restore();(l=this.dependencyTracker)==null||l.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ss.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===xg?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Ft(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,u=h*t;a=c<1?1/c:1,o=u<1?1/u:1}}else{const l=Math.abs(e*r-s*i),h=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)a=c/l,o=h/l;else{const u=t*l;a=c>u?c/u:1,o=h>u?h/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),tf.a=1/r,tf.d=1/a;const l=new Path2D;if(l.addPath(t,tf),o.length>0){const h=Math.max(r,a);s.setLineDash(o.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};si=new WeakSet,Of=function(){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)},Bf=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Hf=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let fo=eg;for(const d in $l)fo.prototype[d]!==void 0&&(fo.prototype[$l[d]]=fo.prototype[d]);var zo,Go,ac,Vo,Nd;const ho=class ho{constructor(t){g(this,Vo);g(this,zo);g(this,Go);g(this,ac);p(this,zo,t),p(this,Go,new DataView(n(this,zo))),p(this,ac,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let i=0;for(const h of ho.strings){const c=e.encode(t[h]);s[h]=c,i+=4+c.length}const r=new ArrayBuffer(i),a=new Uint8Array(r),o=new DataView(r);let l=0;for(const h of ho.strings){const c=s[h],u=c.length;o.setUint32(l,u),a.set(c,l+4),l+=4+u}return nt(l===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return b(this,Vo,Nd).call(this,0)}get fontWeight(){return b(this,Vo,Nd).call(this,1)}get italicAngle(){return b(this,Vo,Nd).call(this,2)}};zo=new WeakMap,Go=new WeakMap,ac=new WeakMap,Vo=new WeakSet,Nd=function(t){nt(t<ho.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=n(this,Go).getUint32(e)+4;const s=n(this,Go).getUint32(e);return n(this,ac).decode(new Uint8Array(n(this,zo),e+4,s))},k(ho,"strings",["fontFamily","fontWeight","italicAngle"]);let cu=ho;var Yn,Ai,oa,la,ch;const co=class co{constructor(t){g(this,la);g(this,Yn);g(this,Ai);g(this,oa);p(this,Yn,t),p(this,Ai,new DataView(n(this,Yn))),p(this,oa,new TextDecoder)}static write(t){const e=new TextEncoder,s={};let i=0;for(const f of co.strings){const m=e.encode(t[f]);s[f]=m,i+=4+m.length}i+=4;let r,a,o=1+i;t.style&&(r=e.encode(t.style.style),a=e.encode(t.style.weight),o+=4+r.length+4+a.length);const l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let u=0;c.setUint8(u++,t.guessFallback?1:0),c.setUint32(u,0),u+=4,i=0;for(const f of co.strings){const m=s[f],A=m.length;i+=4+A,c.setUint32(u,A),h.set(m,u+4),u+=4+A}return c.setUint32(u-i-4,i),t.style&&(c.setUint32(u,r.length),h.set(r,u+4),u+=4+r.length,c.setUint32(u,a.length),h.set(a,u+4),u+=4+a.length),nt(u<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(u)}get guessFallback(){return n(this,Ai).getUint8(0)!==0}get css(){return b(this,la,ch).call(this,0)}get loadedName(){return b(this,la,ch).call(this,1)}get baseFontName(){return b(this,la,ch).call(this,2)}get src(){return b(this,la,ch).call(this,3)}get style(){let t=1;t+=4+n(this,Ai).getUint32(t);const e=n(this,Ai).getUint32(t),s=n(this,oa).decode(new Uint8Array(n(this,Yn),t+4,e));t+=4+e;const i=n(this,Ai).getUint32(t),r=n(this,oa).decode(new Uint8Array(n(this,Yn),t+4,i));return{style:s,weight:r}}};Yn=new WeakMap,Ai=new WeakMap,oa=new WeakMap,la=new WeakSet,ch=function(t){nt(t<co.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=n(this,Ai).getUint32(e)+4;const s=n(this,Ai).getUint32(e);return n(this,oa).decode(new Uint8Array(n(this,Yn),e+4,s))},k(co,"strings",["css","loadedName","baseFontName","src"]);let du=co;var Wo,Xo,qo,Yo,is,wi,oc,bt,$t,Hs,Od,dh;const K=class K{constructor({data:t,extra:e}){g(this,$t);g(this,wi);g(this,oc);g(this,bt);p(this,wi,t),p(this,oc,new TextDecoder),p(this,bt,new DataView(n(this,wi))),e&&Object.assign(this,e)}get black(){return b(this,$t,Hs).call(this,0)}get bold(){return b(this,$t,Hs).call(this,1)}get disableFontFace(){return b(this,$t,Hs).call(this,2)}get fontExtraProperties(){return b(this,$t,Hs).call(this,3)}get isInvalidPDFjsFont(){return b(this,$t,Hs).call(this,4)}get isType3Font(){return b(this,$t,Hs).call(this,5)}get italic(){return b(this,$t,Hs).call(this,6)}get missingFile(){return b(this,$t,Hs).call(this,7)}get remeasure(){return b(this,$t,Hs).call(this,8)}get vertical(){return b(this,$t,Hs).call(this,9)}get ascent(){return b(this,$t,Od).call(this,0)}get defaultWidth(){return b(this,$t,Od).call(this,1)}get descent(){return b(this,$t,Od).call(this,2)}get bbox(){let t=n(K,Xo);if(n(this,bt).getUint8(t)===0)return;t+=1;const s=[];for(let i=0;i<4;i++)s.push(n(this,bt).getInt16(t,!0)),t+=2;return s}get fontMatrix(){let t=n(K,qo);if(n(this,bt).getUint8(t)===0)return;t+=1;const s=[];for(let i=0;i<6;i++)s.push(n(this,bt).getFloat64(t,!0)),t+=8;return s}get defaultVMetrics(){let t=n(K,Yo);if(n(this,bt).getUint8(t)===0)return;t+=1;const s=[];for(let i=0;i<3;i++)s.push(n(this,bt).getInt16(t,!0)),t+=2;return s}get fallbackName(){return b(this,$t,dh).call(this,0)}get loadedName(){return b(this,$t,dh).call(this,1)}get mimetype(){return b(this,$t,dh).call(this,2)}get name(){return b(this,$t,dh).call(this,3)}get data(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);t+=4+s;const i=n(this,bt).getUint32(t);t+=4+i;const r=n(this,bt).getUint32(t);if(r!==0)return new Uint8Array(n(this,wi),t+4,r)}clearData(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);t+=4+s;const i=n(this,bt).getUint32(t);t+=4+i;const r=n(this,bt).getUint32(t);new Uint8Array(n(this,wi),t+4,r).fill(0),n(this,bt).setUint32(t,0)}get cssFontInfo(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);t+=4+s;const i=n(this,bt).getUint32(t);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(n(this,wi),t+4,i)),new cu(r.buffer)}get systemFontInfo(){let t=n(K,is);const e=n(this,bt).getUint32(t);t+=4+e;const s=n(this,bt).getUint32(t);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(n(this,wi),t+4,s)),new du(i.buffer)}static write(t){const e=t.systemFontInfo?du.write(t.systemFontInfo):null,s=t.cssFontInfo?cu.write(t.cssFontInfo):null,i=new TextEncoder,r={};let a=0;for(const y of K.strings)r[y]=i.encode(t[y]),a+=4+r[y].length;const o=n(K,is)+4+a+4+(e?e.byteLength:0)+4+(s?s.byteLength:0)+4+(t.data?t.data.length:0),l=new ArrayBuffer(o),h=new Uint8Array(l),c=new DataView(l);let u=0;const f=K.bools.length;let m=0,A=0;for(let y=0;y<f;y++){const v=t[K.bools[y]];m|=(v===void 0?0:v?2:1)<<A,A+=2,(A===8||y===f-1)&&(c.setUint8(u++,m),m=0,A=0)}nt(u===n(K,Wo),"FontInfo.write: Boolean properties offset mismatch");for(const y of K.numbers)c.setFloat64(u,t[y]),u+=8;if(nt(u===n(K,Xo),"FontInfo.write: Number properties offset mismatch"),t.bbox){c.setUint8(u++,4);for(const y of t.bbox)c.setInt16(u,y,!0),u+=2}else c.setUint8(u++,0),u+=8;if(nt(u===n(K,qo),"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){c.setUint8(u++,6);for(const y of t.fontMatrix)c.setFloat64(u,y,!0),u+=8}else c.setUint8(u++,0),u+=48;if(nt(u===n(K,Yo),"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){c.setUint8(u++,1);for(const y of t.defaultVMetrics)c.setInt16(u,y,!0),u+=2}else c.setUint8(u++,0),u+=6;nt(u===n(K,is),"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(n(K,is),0),u+=4;for(const y of K.strings){const v=r[y],w=v.length;c.setUint32(u,w),h.set(v,u+4),u+=4+w}if(c.setUint32(n(K,is),u-n(K,is)-4),!e)c.setUint32(u,0),u+=4;else{const y=e.byteLength;c.setUint32(u,y),nt(u+4+y<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),u+4),u+=4+y}if(!s)c.setUint32(u,0),u+=4;else{const y=s.byteLength;c.setUint32(u,y),nt(u+4+y<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),u+4),u+=4+y}return t.data===void 0?(c.setUint32(u,0),u+=4):(c.setUint32(u,t.data.length),h.set(t.data,u+4),u+=4+t.data.length),nt(u<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(u)}};Wo=new WeakMap,Xo=new WeakMap,qo=new WeakMap,Yo=new WeakMap,is=new WeakMap,wi=new WeakMap,oc=new WeakMap,bt=new WeakMap,$t=new WeakSet,Hs=function(t){nt(t<K.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=n(this,bt).getUint8(e)>>s&3;return i===0?void 0:i===2},Od=function(t){return nt(t<K.numbers.length,"Invalid number index"),n(this,bt).getFloat64(n(K,Wo)+t*8)},dh=function(t){nt(t<K.strings.length,"Invalid string index");let e=n(K,is)+4;for(let r=0;r<t;r++)e+=n(this,bt).getUint32(e)+4;const s=n(this,bt).getUint32(e),i=new Uint8Array(s);return i.set(new Uint8Array(n(this,wi),e+4,s)),n(this,oc).decode(i)},k(K,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),k(K,"numbers",["ascent","defaultWidth","descent"]),k(K,"strings",["fallbackName","loadedName","mimetype","name"]),g(K,Wo,Math.ceil(K.bools.length*2/8)),g(K,Xo,n(K,Wo)+K.numbers.length*8),g(K,qo,n(K,Xo)+1+8),g(K,Yo,n(K,qo)+1+48),g(K,is,n(K,Yo)+1+6);let Uf=K;var lc,hc;class Zs{static get workerPort(){return n(this,lc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,lc,t)}static get workerSrc(){return n(this,hc)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,hc,t)}}lc=new WeakMap,hc=new WeakMap,g(Zs,lc,null),g(Zs,hc,"");var Ko,cc;class AA{constructor({parsedData:t,rawData:e}){g(this,Ko);g(this,cc);p(this,Ko,t),p(this,cc,e)}getRaw(){return n(this,cc)}get(t){return n(this,Ko).get(t)??null}[Symbol.iterator](){return n(this,Ko).entries()}}Ko=new WeakMap,cc=new WeakMap;const no=Symbol("INTERNAL");var dc,uc,fc,Jo;class wA{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){g(this,dc,!1);g(this,uc,!1);g(this,fc,!1);g(this,Jo,!0);p(this,dc,!!(t&bs.DISPLAY)),p(this,uc,!!(t&bs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,fc))return n(this,Jo);if(!n(this,Jo))return!1;const{print:t,view:e}=this.usage;return n(this,dc)?(e==null?void 0:e.viewState)!=="OFF":n(this,uc)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==no&&_t("Internal method `_setVisible` called."),p(this,fc,s),p(this,Jo,e)}}dc=new WeakMap,uc=new WeakMap,fc=new WeakMap,Jo=new WeakMap;var Kn,yt,Qo,Zo,pc,jf;class vA{constructor(t,e=bs.DISPLAY){g(this,pc);g(this,Kn,null);g(this,yt,new Map);g(this,Qo,null);g(this,Zo,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Zo,t.order);for(const s of t.groups)n(this,yt).set(s.id,new wA(e,s));if(t.baseState==="OFF")for(const s of n(this,yt).values())s._setVisible(no,!1);for(const s of t.on)n(this,yt).get(s)._setVisible(no,!0);for(const s of t.off)n(this,yt).get(s)._setVisible(no,!1);p(this,Qo,this.getHash())}}isVisible(t){if(n(this,yt).size===0)return!0;if(!t)return Bu("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,yt).has(t.id)?n(this,yt).get(t.id).visible:(q(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,pc,jf).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(n(this,yt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!n(this,yt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(!n(this,yt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,yt).has(e))return q(`Optional content group not found: ${e}`),!0;if(n(this,yt).get(e).visible)return!1}return!0}return q(`Unknown optional content policy ${t.policy}.`),!0}return q(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,yt).get(t);if(!i){q(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,yt).get(o))==null||r._setVisible(no,!1,!0));i._setVisible(no,!!e,!0),p(this,Kn,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,yt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,Kn,null)}get hasInitialVisibility(){return n(this,Qo)===null||this.getHash()===n(this,Qo)}getOrder(){return n(this,yt).size?n(this,Zo)?n(this,Zo).slice():[...n(this,yt).keys()]:null}getGroup(t){return n(this,yt).get(t)||null}getHash(){if(n(this,Kn)!==null)return n(this,Kn);const t=new Tm;for(const[e,s]of n(this,yt))t.update(`${e}:${s.visible}`);return p(this,Kn,t.hexdigest())}[Symbol.iterator](){return n(this,yt).entries()}}Kn=new WeakMap,yt=new WeakMap,Qo=new WeakMap,Zo=new WeakMap,pc=new WeakSet,jf=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=b(this,pc,jf).call(this,r);else if(n(this,yt).has(r))a=n(this,yt).get(r).visible;else return q(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class EA{constructor(t,{disableRange:e=!1,disableStream:s=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:r,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(r==null?void 0:r.length)>0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(s),!0)});nt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,r;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(r=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||r.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new SA(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new _A(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class SA{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Uu(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class _A{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function CA(d){let t=!0,e=s("filename\\*","i").exec(d);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(d),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(d),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,u){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(c,u){if(c){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(c,{fatal:!0}),m=cd(u);u=f.decode(m),t=!1}catch{}}return u}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function a(c){const u=[];let f;const m=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=m.exec(c))!==null;){let[,y,v,w]=f;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[v,w]}const A=[];for(let y=0;y<u.length&&y in u;++y){let[v,w]=u[y];w=o(w),v&&(w=unescape(w),y===0&&(w=l(w))),A.push(w)}return A.join("")}function o(c){if(c.startsWith('"')){const u=c.slice(1).split('\\"');for(let f=0;f<u.length;++f){const m=u[f].indexOf('"');m!==-1&&(u[f]=u[f].slice(0,m),u.length=f+1),u[f]=u[f].replaceAll(/\\(.)/g,"$1")}c=u.join('"')}return c}function l(c){const u=c.indexOf("'");if(u===-1)return c;const f=c.slice(0,u),A=c.slice(u+1).replace(/^[^']*'/,"");return i(f,A)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,f,m,A){if(m==="q"||m==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(y,v){return String.fromCharCode(parseInt(v,16))}),i(f,A);try{A=atob(A)}catch{}return i(f,A)})}return""}function Um(d,t){const e=new Headers;if(!d||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function ju(d){var t;return((t=URL.parse(d))==null?void 0:t.origin)??null}function jm({responseHeaders:d,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(d.get("Content-Length"),10);return!Number.isInteger(r)||(i.suggestedLength=r,r<=2*e)||s||!t||d.get("Accept-Ranges")!=="bytes"||(d.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function $m(d){const t=d.get("Content-Disposition");if(t){let e=CA(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Uu(e))return e}return null}function pd(d,t){return new Eh(`Unexpected server response (${d}) while retrieving PDF "${t}".`,d,d===404||d===0&&t.startsWith("file:"))}function zm(d){return d===200||d===206}function Gm(d,t,e){return{method:"GET",headers:d,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Vm(d){return d instanceof Uint8Array?d.buffer:d instanceof ArrayBuffer?d:(q(`getArrayBuffer - unexpected data format: ${d}`),new Uint8Array(d).buffer)}class xA{constructor(t){k(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Um(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new TA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new PA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class TA{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 s=new Headers(t.headers),i=e.url;fetch(i,Gm(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=ju(r.url),!zm(r.status))throw pd(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const a=r.headers,{allowRangeRequests:o,suggestedLength:l}=jm({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=$m(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Sn("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:Vm(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class PA{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,Gm(r,this._withCredentials,this._abortController)).then(o=>{const l=ju(o.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!zm(o.status))throw pd(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:Vm(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const ef=200,sf=206;function RA(d){const t=d.response;return typeof t!="string"?t:cd(t).buffer}class kA{constructor({url:t,httpHeaders:e,withCredentials:s}){k(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Um(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,a]of this.headers)e.setRequestHeader(r,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=sf):i.expectedStatus=ef,e.responseType="arraybuffer",nt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}const r=i.status||ef;if(!(r===ef&&s.expectedStatus===sf)&&r!==s.expectedStatus){s.onError(i.status);return}const o=RA(i);if(r===sf){const l=i.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?s.onDone({begin:parseInt(h[1],10),chunk:o}):(q('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):s.onError(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class DA{constructor(t){this._source=t,this._manager=new kA(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new MA(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new LA(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class MA{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(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=ju(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...h]=o.split(": ");return[l,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:a}=jm({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=$m(i),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(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=pd(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of 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 LA{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,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(){var e;const t=ju((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=pd(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const IA=/^[a-z][a-z0-9\-+.]+:/i;function FA(d){if(IA.test(d))return new URL(d);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(d))}class NA{constructor(t){this.source=t,this.url=FA(t.url),nt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new OA(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new BA(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class OA{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 s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=pd(0,this._url.href)),this._storedError=i,this._headersCapability.reject(i)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Sn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class BA{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Kl=Symbol("INITIAL_DATA");var ns,gc,$f;class Wm{constructor(){g(this,gc);g(this,ns,Object.create(null))}get(t,e=null){if(e){const i=b(this,gc,$f).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=n(this,ns)[t];if(!s||s.data===Kl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,ns)[t];return!!e&&e.data!==Kl}delete(t){const e=n(this,ns)[t];return!e||e.data===Kl?!1:(delete n(this,ns)[t],!0)}resolve(t,e=null){const s=b(this,gc,$f).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in n(this,ns)){const{data:s}=n(this,ns)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,ns,Object.create(null))}*[Symbol.iterator](){for(const t in n(this,ns)){const{data:e}=n(this,ns)[t];e!==Kl&&(yield[t,e])}}}ns=new WeakMap,gc=new WeakSet,$f=function(t){var e;return(e=n(this,ns))[t]||(e[t]={...Promise.withResolvers(),data:Kl})};const HA=1e5,Tg=30;var Hg,Jn,Xe,mc,bc,ha,nn,yc,Ac,ca,tl,el,Qn,sl,wc,il,da,vc,Ec,jt,nl,ua,Sc,Zn,rl,xn,Xm,qm,zf,ws,Bd,Gf,Ym,Km;let xh=(jt=class{constructor({textContentSource:t,container:e,viewport:s}){g(this,xn);g(this,Jn,Promise.withResolvers());g(this,Xe,null);g(this,mc,!1);g(this,bc,!!((Hg=globalThis.FontInspector)!=null&&Hg.enabled));g(this,ha,null);g(this,nn,null);g(this,yc,0);g(this,Ac,0);g(this,ca,null);g(this,tl,null);g(this,el,0);g(this,Qn,0);g(this,sl,Object.create(null));g(this,wc,[]);g(this,il,null);g(this,da,[]);g(this,vc,new WeakMap);g(this,Ec,null);var l;if(t instanceof ReadableStream)p(this,il,t);else if(typeof t=="object")p(this,il,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Xe,p(this,tl,e)),p(this,Qn,s.scale*ei.pixelRatio),p(this,el,s.rotation),p(this,nn,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:r,pageX:a,pageY:o}=s.rawDims;p(this,Ec,[1,0,0,-1,-a,o+r]),p(this,Ac,i),p(this,yc,r),b(l=jt,ws,Ym).call(l),_r(e,s),n(this,Jn).promise.finally(()=>{n(jt,rl).delete(this),p(this,nn,null),p(this,sl,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ce.platform;return J(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{n(this,ca).read().then(({value:e,done:s})=>{if(s){n(this,Jn).resolve();return}n(this,ha)??p(this,ha,e.lang),Object.assign(n(this,sl),e.styles),b(this,xn,Xm).call(this,e.items),t()},n(this,Jn).reject)};return p(this,ca,n(this,il).getReader()),n(jt,rl).add(this),t(),n(this,Jn).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*ei.pixelRatio,i=t.rotation;if(i!==n(this,el)&&(e==null||e(),p(this,el,i),_r(n(this,tl),{rotation:i})),s!==n(this,Qn)){e==null||e(),p(this,Qn,s);const a={div:null,properties:null,ctx:b(r=jt,ws,Bd).call(r,n(this,ha))};for(const o of n(this,da))a.properties=n(this,vc).get(o),a.div=o,b(this,xn,zf).call(this,a)}}cancel(){var e;const t=new Sn("TextLayer task cancelled.");(e=n(this,ca))==null||e.cancel(t).catch(()=>{}),p(this,ca,null),n(this,Jn).reject(t)}get textDivs(){return n(this,da)}get textContentItemsStr(){return n(this,wc)}static cleanup(){if(!(n(this,rl).size>0)){n(this,nl).clear();for(const{canvas:t}of n(this,ua).values())t.remove();n(this,ua).clear()}}},Jn=new WeakMap,Xe=new WeakMap,mc=new WeakMap,bc=new WeakMap,ha=new WeakMap,nn=new WeakMap,yc=new WeakMap,Ac=new WeakMap,ca=new WeakMap,tl=new WeakMap,el=new WeakMap,Qn=new WeakMap,sl=new WeakMap,wc=new WeakMap,il=new WeakMap,da=new WeakMap,vc=new WeakMap,Ec=new WeakMap,nl=new WeakMap,ua=new WeakMap,Sc=new WeakMap,Zn=new WeakMap,rl=new WeakMap,xn=new WeakSet,Xm=function(t){var i,r;if(n(this,mc))return;(r=n(this,nn)).ctx??(r.ctx=b(i=jt,ws,Bd).call(i,n(this,ha)));const e=n(this,da),s=n(this,wc);for(const a of t){if(e.length>HA){q("Ignoring additional textDivs for performance reasons."),p(this,mc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,Xe);p(this,Xe,document.createElement("span")),n(this,Xe).classList.add("markedContent"),a.id&&n(this,Xe).setAttribute("id",`${a.id}`),o.append(n(this,Xe))}else a.type==="endMarkedContent"&&p(this,Xe,n(this,Xe).parentNode);continue}s.push(a.str),b(this,xn,qm).call(this,a)}},qm=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,da).push(e);const i=H.transform(n(this,Ec),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,sl)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,bc)&&a.fontSubstitution||a.fontFamily;o=jt.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*b(y=jt,ws,Km).call(y,o,a,n(this,ha));let c,u;r===0?(c=i[4],u=i[5]-h):(c=i[4]+h*Math.sin(r),u=i[5]-h*Math.cos(r));const f="calc(var(--total-scale-factor) *",m=e.style;n(this,Xe)===n(this,tl)?(m.left=`${(100*c/n(this,Ac)).toFixed(2)}%`,m.top=`${(100*u/n(this,yc)).toFixed(2)}%`):(m.left=`${f}${c.toFixed(2)}px)`,m.top=`${f}${u.toFixed(2)}px)`),m.fontSize=`${f}${(n(jt,Zn)*l).toFixed(2)}px)`,m.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,bc)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const v=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,vc).set(e,s),n(this,nn).div=e,n(this,nn).properties=s,b(this,xn,zf).call(this,n(this,nn)),s.hasText&&n(this,Xe).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),n(this,Xe).append(v)}},zf=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:r}=e;let a="";if(n(jt,Zn)>1&&(a=`scale(${1/n(jt,Zn)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:h,fontSize:c}=s;b(o=jt,ws,Gf).call(o,i,c*n(this,Qn),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${h*n(this,Qn)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},ws=new WeakSet,Bd=function(t=null){let e=n(this,ua).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,ua).set(t,e),n(this,Sc).set(e,{size:0,family:""})}return e},Gf=function(t,e,s){const i=n(this,Sc).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Ym=function(){if(n(this,Zn)!==null)return;const 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),p(this,Zn,t.getBoundingClientRect().height),t.remove()},Km=function(t,e,s){const i=n(this,nl).get(t);if(i)return i;const r=b(this,ws,Bd).call(this,s);r.canvas.width=r.canvas.height=Tg,b(this,ws,Gf).call(this,r,Tg,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return o?h=o/(o+l):(ce.platform.isFirefox&&q("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),n(this,nl).set(t,h),h},g(jt,ws),g(jt,nl,new Map),g(jt,ua,new Map),g(jt,Sc,new WeakMap),g(jt,Zn,null),g(jt,rl,new Set),jt);const UA=100;function Gp(d={}){typeof d=="string"||d instanceof URL?d={url:d}:(d instanceof ArrayBuffer||ArrayBuffer.isView(d))&&(d={data:d});const t=new Vf,{docId:e}=t,s=d.url?qy(d.url):null,i=d.data?Yy(d.data):null,r=d.httpHeaders||null,a=d.withCredentials===!0,o=d.password??null,l=d.range instanceof Vp?d.range:null,h=Number.isInteger(d.rangeChunkSize)&&d.rangeChunkSize>0?d.rangeChunkSize:2**16;let c=d.worker instanceof zl?d.worker:null;const u=d.verbosity,f=typeof d.docBaseUrl=="string"&&!ud(d.docBaseUrl)?d.docBaseUrl:null,m=wd(d.cMapUrl),A=d.cMapPacked!==!1,y=d.CMapReaderFactory||(Be?sA:fg),v=wd(d.iccUrl),w=wd(d.standardFontDataUrl),S=d.StandardFontDataFactory||(Be?iA:pg),E=wd(d.wasmUrl),_=d.WasmFactory||(Be?nA:gg),C=d.stopAtErrors!==!0,x=Number.isInteger(d.maxImageSize)&&d.maxImageSize>-1?d.maxImageSize:-1,T=d.isEvalSupported!==!1,P=typeof d.isOffscreenCanvasSupported=="boolean"?d.isOffscreenCanvasSupported:!Be,R=typeof d.isImageDecoderSupported=="boolean"?d.isImageDecoderSupported:!Be&&(ce.platform.isFirefox||!globalThis.chrome),D=Number.isInteger(d.canvasMaxAreaInBytes)?d.canvasMaxAreaInBytes:-1,M=typeof d.disableFontFace=="boolean"?d.disableFontFace:Be,I=d.fontExtraProperties===!0,G=d.enableXfa===!0,N=d.ownerDocument||globalThis.document,W=d.disableRange===!0,O=d.disableStream===!0,F=d.disableAutoFetch===!0,tt=d.pdfBug===!0,it=d.CanvasFactory||(Be?eA:Qy),ee=d.FilterFactory||(Be?tA:Zy),Je=d.enableHWA===!0,rt=d.useWasm!==!1,ht=l?l.length:d.length??NaN,se=typeof d.useSystemFonts=="boolean"?d.useSystemFonts:!Be&&!M,de=typeof d.useWorkerFetch=="boolean"?d.useWorkerFetch:!!(y===fg&&S===pg&&_===gg&&m&&w&&E&&Zl(m,document.baseURI)&&Zl(w,document.baseURI)&&Zl(E,document.baseURI)),Ee=null;Ry(u);const wt={canvasFactory:new it({ownerDocument:N,enableHWA:Je}),filterFactory:new ee({docId:e,ownerDocument:N}),cMapReaderFactory:de?null:new y({baseUrl:m,isCompressed:A}),standardFontDataFactory:de?null:new S({baseUrl:w}),wasmFactory:de?null:new _({baseUrl:E})};c||(c=zl.create({verbosity:u,port:Zs.workerPort}),t._worker=c);const Os={docId:e,apiVersion:"5.4.296",data:i,password:o,disableAutoFetch:F,rangeChunkSize:h,length:ht,docBaseUrl:f,enableXfa:G,evaluatorOptions:{maxImageSize:x,disableFontFace:M,ignoreErrors:C,isEvalSupported:T,isOffscreenCanvasSupported:P,isImageDecoderSupported:R,canvasMaxAreaInBytes:D,fontExtraProperties:I,useSystemFonts:se,useWasm:rt,useWorkerFetch:de,cMapUrl:m,iccUrl:v,standardFontDataUrl:w,wasmUrl:E}},ii={ownerDocument:N,pdfBug:tt,styleElement:Ee,loadingParams:{disableAutoFetch:F,enableXfa:G}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Ii=c.messageHandler.sendWithPromise("GetDocRequest",Os,i?[i.buffer]:null);let Me;if(l)Me=new EA(l,{disableRange:W,disableStream:O});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");const Tt=Zl(s)?xA:Be?NA:DA;Me=new Tt({url:s,length:ht,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:W,disableStream:O})}return Ii.then(Tt=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Rt=new rh(e,Tt,c.port),Yt=new zA(Rt,t,Me,ii,wt,Je);t._transport=Yt,Rt.send("Ready",null)})}).catch(t._capability.reject),t}var Tu;const Pu=class Pu{constructor(){k(this,"_capability",Promise.withResolvers());k(this,"_transport",null);k(this,"_worker",null);k(this,"docId",`d${Kt(Pu,Tu)._++}`);k(this,"destroyed",!1);k(this,"onPassword",null);k(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Tu=new WeakMap,g(Pu,Tu,0);let Vf=Pu;var fa,_c,Cc,xc,Tc,Ug;let Vp=(Ug=class{constructor(t,e,s=!1,i=null){g(this,fa,Promise.withResolvers());g(this,_c,[]);g(this,Cc,[]);g(this,xc,[]);g(this,Tc,[]);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}addRangeListener(t){n(this,Tc).push(t)}addProgressListener(t){n(this,xc).push(t)}addProgressiveReadListener(t){n(this,Cc).push(t)}addProgressiveDoneListener(t){n(this,_c).push(t)}onDataRange(t,e){for(const s of n(this,Tc))s(t,e)}onDataProgress(t,e){n(this,fa).promise.then(()=>{for(const s of n(this,xc))s(t,e)})}onDataProgressiveRead(t){n(this,fa).promise.then(()=>{for(const e of n(this,Cc))e(t)})}onDataProgressiveDone(){n(this,fa).promise.then(()=>{for(const t of n(this,_c))t()})}transportReady(){n(this,fa).resolve()}requestDataRange(t,e){_t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},fa=new WeakMap,_c=new WeakMap,Cc=new WeakMap,xc=new WeakMap,Tc=new WeakMap,Ug);class jA{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 J(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{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()}}var rn,pa,uh;class $A{constructor(t,e,s,i=!1){g(this,pa);g(this,rn,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new ag:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Wm,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}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:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new dd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{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 J(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Di.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:f=!1,recordOperations:m=!1,operationsFilter:A=null}){var R,D,M;(R=this._stats)==null||R.time("Overall");const y=this._transport.getRenderingIntent(i,r,u,f),{renderingIntent:v,cacheKey:w}=y;p(this,rn,!1),l||(l=this._transport.getOptionalContentConfig(v));let S=this._intentStates.get(w);S||(S=Object.create(null),this._intentStates.set(w,S)),S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);const E=!!(v&bs.PRINT);S.displayReadyCapability||(S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(D=this._stats)==null||D.time("Page Request"),this._pumpOperatorList(y));const _=!!(this._pdfBug&&((M=globalThis.StepperManager)!=null&&M.enabled)),C=!this.recordedBBoxes&&(m||_),x=I=>{var G,N;if(S.renderTasks.delete(T),C){const W=(G=T.gfx)==null?void 0:G.dependencyTracker.take();W&&(T.stepper&&T.stepper.setOperatorBBoxes(W,T.gfx.dependencyTracker.takeDebugMetadata()),m&&(this.recordedBBoxes=W))}E&&p(this,rn,!0),b(this,pa,uh).call(this),I?(T.capability.reject(I),this._abortOperatorList({intentState:S,reason:I instanceof Error?I:new Error(I)})):T.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(N=globalThis.Stats)!=null&&N.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},T=new Wf({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:C?new aA(e,S.operatorList.length,_):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!E,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:A});(S.renderTasks||(S.renderTasks=new Set)).add(T);const P=T.task;return Promise.all([S.displayReadyCapability.promise,l]).then(([I,G])=>{var N;if(this.destroyed){x();return}if((N=this._stats)==null||N.time("Rendering"),!(G.renderingIntent&v))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");T.initializeGraphics({transparency:I,optionalContentConfig:G}),T.operatorListChanged()}).catch(x),P}getOperatorList({intent:t="display",annotationMode:e=Di.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Sh.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function r(){a.read().then(function({value:l,done:h}){if(h){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),r()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,rn,!1),Promise.all(t)}cleanup(t=!1){p(this,rn,!0);const e=b(this,pa,uh).call(this);return t&&e&&this._stats&&(this._stats=new ag),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,pa,uh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:u,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),c())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();b(this,pa,uh).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Hu){let i=UA;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 Sn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}rn=new WeakMap,pa=new WeakSet,uh=function(){if(!n(this,rn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,rn,!1),!0};var tr,Ws,an,ga,Ru,ma,ba,He,Hd,Jm,Qm,fh,al,Ud;const kt=class kt{constructor({name:t=null,port:e=null,verbosity:s=ky()}={}){g(this,He);g(this,tr,Promise.withResolvers());g(this,Ws,null);g(this,an,null);g(this,ga,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(kt,ba).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(kt,ba).set(e,this),b(this,He,Jm).call(this,e)}else b(this,He,Qm).call(this)}get promise(){return n(this,tr).promise}get port(){return n(this,an)}get messageHandler(){return n(this,Ws)}destroy(){var t,e;this.destroyed=!0,(t=n(this,ga))==null||t.terminate(),p(this,ga,null),n(kt,ba).delete(n(this,an)),p(this,an,null),(e=n(this,Ws))==null||e.destroy(),p(this,Ws,null)}static create(t){const e=n(this,ba).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new kt(t)}static get workerSrc(){if(Zs.workerSrc)return Zs.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return J(this,"_setupFakeWorkerGlobal",(async()=>n(this,al,Ud)?n(this,al,Ud):(await import(this.workerSrc)).WorkerMessageHandler)())}};tr=new WeakMap,Ws=new WeakMap,an=new WeakMap,ga=new WeakMap,Ru=new WeakMap,ma=new WeakMap,ba=new WeakMap,He=new WeakSet,Hd=function(){n(this,tr).resolve(),n(this,Ws).send("configure",{verbosity:this.verbosity})},Jm=function(t){p(this,an,t),p(this,Ws,new rh("main","worker",t)),n(this,Ws).on("ready",()=>{}),b(this,He,Hd).call(this)},Qm=function(){if(n(kt,ma)||n(kt,al,Ud)){b(this,He,fh).call(this);return}let{workerSrc:t}=kt;try{kt._isSameOrigin(window.location,t)||(t=kt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new rh("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,tr).reject(new Error("Worker was destroyed")):b(this,He,fh).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,ga)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,Ws,s),p(this,an,e),p(this,ga,e),b(this,He,Hd).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,He,fh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Bu("The worker has been disabled.")}b(this,He,fh).call(this)},fh=function(){n(kt,ma)||(q("Setting up fake worker."),p(kt,ma,!0)),kt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,tr).reject(new Error("Worker was destroyed"));return}const e=new Jy;p(this,an,e);const s=`fake${Kt(kt,Ru)._++}`,i=new rh(s+"_worker",s,e);t.setup(i,e),p(this,Ws,new rh(s,s+"_worker",e)),b(this,He,Hd).call(this)}).catch(t=>{n(this,tr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},al=new WeakSet,Ud=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},g(kt,al),g(kt,Ru,0),g(kt,ma,!1),g(kt,ba,new WeakMap),Be&&(p(kt,ma,!0),Zs.workerSrc||(Zs.workerSrc="./pdf.worker.mjs")),kt._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},kt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},kt.fromPort=t=>{if(Hy("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return kt.create(t)};let zl=kt;var on,vi,ol,ll,ln,ya,ph;class zA{constructor(t,e,s,i,r,a){g(this,ya);g(this,on,new Map);g(this,vi,new Map);g(this,ol,new Map);g(this,ll,new Map);g(this,ln,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Wm,this.fontLoader=new Wy({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=a,this.setupMessageHandler()}get annotationStorage(){return J(this,"annotationStorage",new jp)}getRenderingIntent(t,e=Di.ENABLE,s=null,i=!1,r=!1){let a=bs.DISPLAY,o=Rf;switch(t){case"any":a=bs.ANY;break;case"display":break;case"print":a=bs.PRINT;break;default:q(`getRenderingIntent - invalid intent: ${t}`)}const l=a&bs.PRINT&&s instanceof Rm?s:this.annotationStorage;switch(e){case Di.DISABLE:a+=bs.ANNOTATIONS_DISABLE;break;case Di.ENABLE:break;case Di.ENABLE_FORMS:a+=bs.ANNOTATIONS_FORMS;break;case Di.ENABLE_STORAGE:a+=bs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:q(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=bs.IS_EDITING),r&&(a+=bs.OPLIST);const{ids:h,hash:c}=l.modifiedIds,u=[a,o.hash,c];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,ln))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,vi).values())t.push(i._destroy());n(this,vi).clear(),n(this,ol).clear(),n(this,ll).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,on).clear(),this.filterFactory.destroy(),xh.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new Sn("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:a}){if(a){i.close();return}nt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=this._fullReader;return(!i||!r)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}nt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new jA(s,this))}),t.on("DocException",s=>{e._capability.reject(je(s))}),t.on("PasswordRequest",s=>{p(this,ln,Promise.withResolvers());try{if(!e.onPassword)throw je(s);const i=r=>{r instanceof Error?n(this,ln).reject(r):n(this,ln).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,ln).reject(i)}return n(this,ln).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,vi).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const u=r.error;q(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const o=new Uf(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(u,f)=>globalThis.FontInspector.fontAdded(u,f):null,h=new Xy(o,l,r.extra,r.charProcOperatorList);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h.fontExtraProperties&&h.data&&h.clearData(),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:c}=r;nt(c,"The imageRef must be defined.");for(const u of n(this,vi).values())for(const[,f]of u.objs)if((f==null?void 0:f.ref)===c)return f.dataLen?(this.commonObjs.resolve(s,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,vi).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");const i=this[s.type];if(!i)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return i.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&q("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=n(this,ol).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&n(this,ll).set(r.refStr,t);const a=new $A(e,r,this,this._params.pdfBug);return n(this,vi).set(e,a),a});return n(this,ol).set(e,i),i}getPageIndex(t){return kf(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return b(this,ya,ph).call(this,"GetFieldObjects")}hasJSActions(){return b(this,ya,ph).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return b(this,ya,ph).call(this,"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 b(this,ya,ph).call(this,"GetOptionalContentConfig").then(e=>new vA(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=n(this,on).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var r,a;return{info:i[0],metadata:i[1]?new AA(i[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return n(this,on).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,vi).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,on).clear(),this.filterFactory.destroy(!0),xh.cleanup()}}cachedPageNumber(t){if(!kf(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return n(this,ll).get(e)??null}}on=new WeakMap,vi=new WeakMap,ol=new WeakMap,ll=new WeakMap,ln=new WeakMap,ya=new WeakSet,ph=function(t,e=null){const s=n(this,on).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return n(this,on).set(t,i),i};var er;class GA{constructor(t){g(this,er,null);k(this,"onContinue",null);k(this,"onError",null);p(this,er,t)}get promise(){return n(this,er).capability.promise}cancel(t=0){n(this,er).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=n(this,er).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=n(this,er);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}er=new WeakMap;var sr,Aa;const Lr=class Lr{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:f=null,enableHWA:m=!1,operationsFilter:A=null}){g(this,sr,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new GA(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=m,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=A}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var l,h;if(this.cancelled)return;if(this._canvas){if(n(Lr,Aa).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(Lr,Aa).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new fo(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,sr)&&(window.cancelAnimationFrame(n(this,sr)),p(this,sr,null)),n(Lr,Aa).delete(this._canvas),t||(t=new Hu(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.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?p(this,sr,window.requestAnimationFrame(()=>{p(this,sr,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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(Lr,Aa).delete(this._canvas),this.callback())))}};sr=new WeakMap,Aa=new WeakMap,g(Lr,Aa,new WeakSet);let Wf=Lr;const Zm="5.4.296",tb="f56dc8601";var rs,wa,hl,Zt,Pc,cl,hn,Rc,ir,Xs,kc,At,Xf,qf,Yf,Rr,eb,Rn;const $e=class $e{constructor({editor:t=null,uiManager:e=null}){g(this,At);g(this,rs,null);g(this,wa,null);g(this,hl);g(this,Zt,null);g(this,Pc,!1);g(this,cl,!1);g(this,hn,null);g(this,Rc);g(this,ir,null);g(this,Xs,null);var s,i;t?(p(this,cl,!1),p(this,hn,t)):p(this,cl,!0),p(this,Xs,(t==null?void 0:t._uiManager)||e),p(this,Rc,n(this,Xs)._eventBus),p(this,hl,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Xs))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n($e,kc)||p($e,kc,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"}))}static get _keyboardManager(){return J(this,"_keyboardManager",new fd([[["Escape","mac+Escape"],$e.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],$e.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],$e.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],$e.prototype._moveToPrevious],[["Home","mac+Home"],$e.prototype._moveToBeginning],[["End","mac+End"],$e.prototype._moveToEnd]]))}renderButton(){const t=p(this,rs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,hn)&&(t.ariaControls=`${n(this,hn).id}_colorpicker_dropdown`);const e=n(this,Xs)._signal;t.addEventListener("click",b(this,At,Rr).bind(this),{signal:e}),t.addEventListener("keydown",b(this,At,Yf).bind(this),{signal:e});const s=p(this,wa,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,hl),t.append(s),t}renderMainDropdown(){const t=p(this,Zt,b(this,At,Xf).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,rs)){b(this,At,Rr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,At,qf).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,At,Rn)){b(this,At,Rr).call(this,t);return}if(t.target===n(this,rs)){(e=n(this,Zt).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,Zt))==null?void 0:e.firstChild)||t.target===n(this,rs)){n(this,At,Rn)&&this._hideDropdownFromKeyboard();return}n(this,At,Rn)||b(this,At,Rr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,At,Rn)){b(this,At,Rr).call(this,t);return}(e=n(this,Zt).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,At,Rn)){b(this,At,Rr).call(this,t);return}(e=n(this,Zt).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,Zt))==null||t.classList.add("hidden"),n(this,rs).ariaExpanded="false",(e=n(this,ir))==null||e.abort(),p(this,ir,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,cl)){if(!n(this,At,Rn)){(t=n(this,hn))==null||t.unselect();return}this.hideDropdown(),n(this,rs).focus({preventScroll:!0,focusVisible:n(this,Pc)})}}updateColor(t){if(n(this,wa)&&(n(this,wa).style.backgroundColor=t),!n(this,Zt))return;const e=n(this,Xs).highlightColors.values();for(const s of n(this,Zt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,rs))==null||t.remove(),p(this,rs,null),p(this,wa,null),(e=n(this,Zt))==null||e.remove(),p(this,Zt,null)}};rs=new WeakMap,wa=new WeakMap,hl=new WeakMap,Zt=new WeakMap,Pc=new WeakMap,cl=new WeakMap,hn=new WeakMap,Rc=new WeakMap,ir=new WeakMap,Xs=new WeakMap,kc=new WeakMap,At=new WeakSet,Xf=function(){const t=document.createElement("div"),e=n(this,Xs)._signal;t.addEventListener("contextmenu",vs,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,hn)&&(t.id=`${n(this,hn).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Xs).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n($e,kc)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,hl),r.addEventListener("click",b(this,At,qf).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,At,Yf).bind(this),{signal:e}),t},qf=function(t,e){e.stopPropagation(),n(this,Rc).dispatch("switchannotationeditorparams",{source:this,type:st.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},Yf=function(t){$e._keyboardManager.exec(this,t)},Rr=function(t){if(n(this,At,Rn)){this.hideDropdown();return}if(p(this,Pc,t.detail===0),n(this,ir)||(p(this,ir,new AbortController),window.addEventListener("pointerdown",b(this,At,eb).bind(this),{signal:n(this,Xs).combinedSignal(n(this,ir))})),n(this,rs).ariaExpanded="true",n(this,Zt)){n(this,Zt).classList.remove("hidden");return}const e=p(this,Zt,b(this,At,Xf).call(this));n(this,rs).append(e)},eb=function(t){var e;(e=n(this,Zt))!=null&&e.contains(t.target)||this.hideDropdown()},Rn=function(){return n(this,Zt)&&!n(this,Zt).classList.contains("hidden")},g($e,kc,null);let Th=$e;var Ei,Dc,dl,Mc;const Ir=class Ir{constructor(t){g(this,Ei,null);g(this,Dc,null);g(this,dl,null);p(this,Dc,t),p(this,dl,t._uiManager),n(Ir,Mc)||p(Ir,Mc,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,Ei))return n(this,Ei);const{editorType:t,colorType:e,colorValue:s}=n(this,Dc),i=p(this,Ei,document.createElement("input"));return i.type="color",i.value=s||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",n(Ir,Mc)[t]),i.addEventListener("input",()=>{n(this,dl).updateParams(e,i.value)},{signal:n(this,dl)._signal}),i}update(t){n(this,Ei)&&(n(this,Ei).value=t)}destroy(){var t;(t=n(this,Ei))==null||t.remove(),p(this,Ei,null)}hideDropdown(){}};Ei=new WeakMap,Dc=new WeakMap,dl=new WeakMap,Mc=new WeakMap,g(Ir,Mc,null);let uu=Ir;function Pg(d){return Math.floor(Math.max(0,Math.min(1,d))*255).toString(16).padStart(2,"0")}function Jl(d){return Math.max(0,Math.min(255,255*d))}class Rg{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=Jl(t),[t,t,t]}static G_HTML([t]){const e=Pg(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Jl)}static RGB_HTML(t){return`#${t.map(Pg).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Jl(1-Math.min(1,t+i)),Jl(1-Math.min(1,s+i)),Jl(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class VA{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){_t("Abstract method `_createSVG` called.")}}class Ph extends VA{_createSVG(t){return document.createElementNS(Fi,t)}}const WA=9,Xa=new WeakSet,XA=new Date().getTimezoneOffset()*60*1e3;class kg{static create(t){switch(t.data.annotationType){case zt.LINK:return new Wp(t);case zt.TEXT:return new YA(t);case zt.WIDGET:switch(t.data.fieldType){case"Tx":return new KA(t);case"Btn":return t.data.radioButton?new nb(t):t.data.checkBox?new QA(t):new ZA(t);case"Ch":return new tw(t);case"Sig":return new JA(t)}return new Ka(t);case zt.POPUP:return new Jf(t);case zt.FREETEXT:return new hb(t);case zt.LINE:return new sw(t);case zt.SQUARE:return new iw(t);case zt.CIRCLE:return new nw(t);case zt.POLYLINE:return new cb(t);case zt.CARET:return new aw(t);case zt.INK:return new Xp(t);case zt.POLYGON:return new rw(t);case zt.HIGHLIGHT:return new db(t);case zt.UNDERLINE:return new ow(t);case zt.SQUIGGLY:return new lw(t);case zt.STRIKEOUT:return new hw(t);case zt.STAMP:return new ub(t);case zt.FILEATTACHMENT:return new cw(t);default:return new Ot(t)}}}var va,ul,Ms,Lc,Kf;const sg=class sg{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){g(this,Lc);g(this,va,null);g(this,ul,!1);g(this,Ms,null);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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return sg._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let h=0,c=l.length;h<c;h+=2)l[h+1]>a?(a=l[h+1],r=l[h]):l[h+1]===a&&(r=Math.max(r,l[h]));if(r!==1/0)return[r,a]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/i,t}get commentText(){var e,s,i;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${vh}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((i=t.contentsObj)==null?void 0:i.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${vh}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=n(this,Ms))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,Ms,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,va)||p(this,va,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,Lc,Kf).call(this,e);let i=((r=n(this,Ms))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,Ms).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,Ms,null),this.popup=null))}resetEdited(){var t;n(this,va)&&(b(this,Lc,Kf).call(this,n(this,va).rect),(t=n(this,Ms))==null||t.popup.resetEdited(),p(this,va,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Ka)&&!(this instanceof Wp)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof Jf){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(y>0||v>0){const S=`calc(${y}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=S}else if(this instanceof nb){const S=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case Za.SOLID:a.borderStyle="solid";break;case Za.DASHED:a.borderStyle="dashed";break;case Za.BEVELED:q("Unimplemented border style: beveled");break;case Za.INSET:q("Unimplemented border style: inset");break;case Za.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(p(this,ul,!0),a.borderColor=H.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):a.borderWidth=0}const h=H.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:u,pageX:f,pageY:m}=i.rawDims;a.left=`${100*(h[0]-f)/c}%`,a.top=`${100*(h[1]-m)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/c}%`,a.height=`${100*l/u}%`):this.setRotation(A,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=Rg[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Rg[`${a}_rgb`](o)})};return J(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||s[i];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,v,w,S]=t.subarray(2,6);if(i===y&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(n(this,ul)){const{borderColor:y,borderWidth:v}=a;a.borderWidth=0,o=["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="${y}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=i-e,h=r-s,{svgFactory:c}=this,u=c.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";const f=c.createElement("defs");u.append(f);const m=c.createElement("clipPath"),A=`clippath_${this.data.id}`;m.setAttribute("id",A),m.setAttribute("clipPathUnits","objectBoundingBox"),f.append(m);for(let y=2,v=t.length;y<v;y+=8){const w=t[y],S=t[y+1],E=t[y+2],_=t[y+3],C=c.createElement("rect"),x=(E-e)/l,T=(r-S)/h,P=(w-E)/l,R=(S-_)/h;C.setAttribute("x",x),C.setAttribute("y",T),C.setAttribute("width",P),C.setAttribute("height",R),m.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${T}" width="${P}" height="${R}"/>`)}n(this,ul)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate);const r=p(this,Ms,new Jf({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(r.render())}get hasPopupElement(){return!!(n(this,Ms)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,Ms)}render(){_t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!Xa.has(h)){q(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&Xa.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};va=new WeakMap,ul=new WeakMap,Ms=new WeakMap,Lc=new WeakSet,Kf=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let Ot=sg;class qA extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}var As,kr,sb,ib;class Wp extends Ot{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});g(this,As);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(b(this,As,sb).call(this,i,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,As,ib).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(i),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,As,kr).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),b(this,As,kr).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),b(this,As,kr).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,As,kr).call(this),!this._fieldObjects){q('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const m of r){const A=this._fieldObjects[m]||[];for(const{id:y}of A)f.add(y)}for(const m of Object.values(this._fieldObjects))for(const A of m)f.has(A.id)===o&&l.push(A)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const h=this.annotationStorage,c=[];for(const f of l){const{id:m}=f;switch(c.push(m),f.type){case"text":{const y=f.defaultValue||"";h.setValue(m,{value:y});break}case"checkbox":case"radiobutton":{const y=f.defaultValue===f.exportValues;h.setValue(m,{value:y});break}case"combobox":case"listbox":{const y=f.defaultValue||"";h.setValue(m,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${m}"]`);if(A){if(!Xa.has(A)){q(`_bindResetFormAction - element not allowed: ${m}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}As=new WeakSet,kr=function(){this.container.setAttribute("data-internal-link","")},sb=function(e,s,i="",r=null){e.href=this.linkService.getAnchorUrl(""),s.description?e.title=s.description:i&&(e.title=i),e.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(s.content,s.filename,r),!1},b(this,As,kr).call(this)},ib=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,As,kr).call(this)};class YA extends Ot{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const 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 Ka extends Ot{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ce.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,i),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":H.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||WA,r=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/(Yu*i))||1,u=h/c;a=Math.min(i,l(u/Yu))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/Yu))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=H.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class KA extends Ka{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
3
3
  `))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Xa.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:u,datetimeType:f,timeStep:m}=this.data,A=!!f&&this.enableScripting;u&&(s.title=u),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",v=>{t.setValue(e,{value:v.target.value}),this.setPropertyOnSiblings(s,"value",v.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",v=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let y=v=>{const{formattedValue:w}=c;w!=null&&(v.target.value=w),v.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var E;if(c.focused)return;const{target:S}=w;if(A&&(S.type=f,m&&(S.step=m)),c.userValue){const _=c.userValue;if(A)if(f==="time"){const C=new Date(_),x=[C.getHours(),C.getMinutes(),C.getSeconds()];S.value=x.map(T=>T.toString().padStart(2,"0")).join(":")}else S.value=new Date(_-XA).toISOString().split(f==="date"?"T":".",1)[0];else S.value=_}c.lastCommittedValue=S.value,c.commitKey=1,(E=this.data.actions)!=null&&E.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.showElementAndHideCanvas(w.target);const S={value(E){c.userValue=E.detail.value??"",A||t.setValue(e,{value:c.userValue.toString()}),E.target.value=c.userValue},formattedValue(E){const{formattedValue:_}=E.detail;c.formattedValue=_,_!=null&&E.target!==document.activeElement&&(E.target.value=_);const C={formattedValue:_};A&&(C.value=_),t.setValue(e,C)},selRange(E){E.target.setSelectionRange(...E.detail.selRange)},charLimit:E=>{var T;const{charLimit:_}=E.detail,{target:C}=E;if(_===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",_);let x=c.userValue;!x||x.length<=_||(x=x.slice(0,_),C.value=c.userValue=x,t.setValue(e,{value:x}),(T=this.linkService.eventBus)==null||T.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(S,w)}),s.addEventListener("keydown",w=>{var _;c.commitKey=1;let S=-1;if(w.key==="Escape"?S=0:w.key==="Enter"&&!this.data.multiLine?S=2:w.key==="Tab"&&(c.commitKey=3),S===-1)return;const{value:E}=w.target;c.lastCommittedValue!==E&&(c.lastCommittedValue=E,c.userValue=E,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:S,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const v=y;y=null,s.addEventListener("blur",w=>{var _,C;if(!c.focused||!w.relatedTarget)return;(_=this.data.actions)!=null&&_.Blur||(c.focused=!1);const{target:S}=w;let{value:E}=S;if(A){if(E&&f==="time"){const x=E.split(":").map(T=>parseInt(T,10));E=new Date(2e3,0,1,x[0],x[1],x[2]||0).valueOf(),S.step=""}else E.includes("T")||(E=`${E}T00:00`),E=new Date(E).valueOf();S.type="text"}c.userValue=E,c.lastCommittedValue!==E&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),v(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var R;c.lastCommittedValue=null;const{data:S,target:E}=w,{value:_,selectionStart:C,selectionEnd:x}=E;let T=C,P=x;switch(w.inputType){case"deleteWordBackward":{const D=_.substring(0,C).match(/\w*[^\w]*$/);D&&(T-=D[0].length);break}case"deleteWordForward":{const D=_.substring(C).match(/^[^\w]*\w*/);D&&(P+=D[0].length);break}case"deleteContentBackward":C===x&&(T-=1);break;case"deleteContentForward":C===x&&(P+=1);break}w.preventDefault(),(R=this.linkService.eventBus)==null||R.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:S||"",willCommit:!1,selStart:T,selEnd:P}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(y&&s.addEventListener("blur",y),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${w}px * var(--total-scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class JA extends Ka{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class QA extends Ka{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return Xa.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const c=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nb extends Ka{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(Xa.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const u of this._getElementsByName(h.target.name)){const f=c&&u.id===s;u.domElement&&(u.domElement.checked=f),t.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ZA extends Wp{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class tw extends Ka{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Xa.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const u=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===u});for(const c of this.data.options){const u=document.createElement("option");u.textContent=c.displayValue,u.value=c.exportValue,s.value.includes(c.exportValue)&&(u.setAttribute("selected",!0),r=!1),i.append(u)}let a=null;if(r){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),a=()=>{c.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=c=>{const u=c?"value":"textContent",{options:f,multiple:m}=i;return m?Array.prototype.filter.call(f,A=>A.selected).map(A=>A[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const h=c=>{const u=c.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const u={value(f){a==null||a();const m=f.detail.value,A=new Set(Array.isArray(m)?m:[m]);for(const y of i.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const m=i.options,A=f.detail.remove;m[A].selected=!1,i.remove(A),m.length>0&&Array.prototype.findIndex.call(m,v=>v.selected)===-1&&(m[0].selected=!0),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:m,displayValue:A,exportValue:y}=f.detail.insert,v=i.children[m],w=document.createElement("option");w.textContent=A,w.value=y,v?v.before(w):i.append(w),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},items(f){const{items:m}=f.detail;for(;i.length!==0;)i.remove(0);for(const A of m){const{displayValue:y,exportValue:v}=A,w=document.createElement("option");w.textContent=y,w.value=v,i.append(w)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},indices(f){const m=new Set(f.detail.indices);for(const A of f.target.options)A.selected=m.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,c)}),i.addEventListener("input",c=>{var m;const u=o(!0),f=o(!1);t.setValue(e,{value:u}),c.preventDefault(),(m=this.linkService.eventBus)==null||m.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var Ic,Qf;class Jf extends Ot{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&Ot._hasPopupData(s)});g(this,Ic);if(this.elements=i,a&&Ot._hasPopupData(s)){const o=this.popup=b(this,Ic,Qf).call(this);for(const l of i)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const s=this.popup=b(this,Ic,Qf).call(this),i=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",i.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(r=>`${Bp}${r}`).join(",")),this.container}}Ic=new WeakSet,Qf=function(){return new ew({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})};var as,nr,ku,Du,fl,pl,Ut,Si,rr,Ea,gl,ml,_i,os,cn,dn,ne,un,ar,Fc,fn,bl,Sa,or,Re,lr,Z,jd,Zf,tp,ep,$d,sp,rb,ab,ob,lb,zd,Gd,ip;class ew{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:u,commentManager:f=null}){g(this,Z);g(this,as,null);g(this,nr,b(this,Z,ob).bind(this));g(this,ku,b(this,Z,ip).bind(this));g(this,Du,b(this,Z,Gd).bind(this));g(this,fl,b(this,Z,zd).bind(this));g(this,pl,null);g(this,Ut,null);g(this,Si,null);g(this,rr,null);g(this,Ea,null);g(this,gl,null);g(this,ml,null);g(this,_i,!1);g(this,os,null);g(this,cn,null);g(this,dn,null);g(this,ne,null);g(this,un,null);g(this,ar,null);g(this,Fc,null);g(this,fn,null);g(this,bl,null);g(this,Sa,null);g(this,or,!1);g(this,Re,null);g(this,lr,null);p(this,Ut,t),p(this,bl,i),p(this,Si,a),p(this,fn,o),p(this,gl,l),p(this,pl,e),p(this,Fc,h),p(this,ml,c),p(this,Ea,s),p(this,as,f),p(this,Re,s[0]),p(this,rr,_h.toDateObject(r)),this.trigger=s.flatMap(m=>m.getElementsToTriggerPopup()),f?this.renderCommentButton():(b(this,Z,jd).call(this),n(this,Ut).hidden=!0,u&&b(this,Z,zd).call(this))}renderCommentButton(){if(n(this,ne)||(n(this,un)||b(this,Z,Zf).call(this),!n(this,un)))return;const{signal:t}=p(this,cn,new AbortController),e=!!n(this,Re).extraPopupElement,s=()=>{n(this,as).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,as).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,as).toggleCommentPopup(this,!1,!1)};if(e){p(this,ne,n(this,Re).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,nr),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=p(this,ne,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,Re).container;a.style.zIndex=o.style.zIndex+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),b(this,Z,ep).call(this),b(this,Z,tp).call(this),a.addEventListener("keydown",n(this,nr),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=n(this,Re).commentData;return t?n(this,gl)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,ne))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=n(this,Re).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,ne)}get comment(){return n(this,lr)||p(this,lr,n(this,Re).commentText),n(this,lr)}set comment(t){t!==this.comment&&(n(this,Re).commentText=p(this,lr,t))}get parentBoundingClientRect(){return n(this,Re).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){n(this,ne)&&(n(this,ne).classList.toggle("selected",t),n(this,ne).ariaExpanded=e)}setSelectedCommentButton(t){n(this,ne).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,ar))return n(this,ar);const{x:t,y:e,height:s}=n(this,ne).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Re).layer.getBoundingClientRect();return[(t-i)/a,(e+s-r)/o]}set commentPopupPosition(t){p(this,ar,t)}hasDefaultPopupPosition(){return n(this,ar)===null}get commentButtonPosition(){return n(this,un)}get commentButtonWidth(){return n(this,ne).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,ar)||this.commentButtonPosition.map(h=>h/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;n(this,as).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,os))return;const t=p(this,os,document.createElement("div"));if(t.className="popup",n(this,pl)){const r=t.style.outlineColor=H.makeHexColor(...n(this,pl));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,bl))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,bl)}if(t.append(e),n(this,rr)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,rr).valueOf()})),r.dateTime=n(this,rr).toISOString(),e.append(r)}Up({html:n(this,Z,$d)||n(this,Si).str,dir:(i=n(this,Si))==null?void 0:i.dir,className:"popupContent"},t),n(this,Ut).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,as)){s?(this.remove(),p(this,lr,null)):e&&(e.deleted?this.remove():(b(this,Z,ep).call(this),p(this,lr,e.text))),t&&(p(this,un,null),b(this,Z,Zf).call(this),b(this,Z,tp).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,Z,jd).call(this),n(this,Sa)||p(this,Sa,{contentsObj:n(this,Si),richText:n(this,fn)}),t&&p(this,dn,null),e&&e.text&&(p(this,fn,b(this,Z,ab).call(this,e.text)),p(this,rr,_h.toDateObject(e.date)),p(this,Si,null)),(i=n(this,os))==null||i.remove(),p(this,os,null)}resetEdited(){var t;n(this,Sa)&&({contentsObj:Kt(this,Si)._,richText:Kt(this,fn)._}=n(this,Sa),p(this,Sa,null),(t=n(this,os))==null||t.remove(),p(this,os,null),p(this,dn,null))}remove(){var t,e,s;if((t=n(this,cn))==null||t.abort(),p(this,cn,null),(e=n(this,os))==null||e.remove(),p(this,os,null),p(this,or,!1),p(this,_i,!1),(s=n(this,ne))==null||s.remove(),p(this,ne,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){p(this,or,this.isVisible),n(this,or)&&(n(this,Ut).hidden=!0)}maybeShow(){n(this,as)||(b(this,Z,jd).call(this),n(this,or)&&(n(this,os)||b(this,Z,Gd).call(this),p(this,or,!1),n(this,Ut).hidden=!1))}get isVisible(){return n(this,as)?!1:n(this,Ut).hidden===!1}}as=new WeakMap,nr=new WeakMap,ku=new WeakMap,Du=new WeakMap,fl=new WeakMap,pl=new WeakMap,Ut=new WeakMap,Si=new WeakMap,rr=new WeakMap,Ea=new WeakMap,gl=new WeakMap,ml=new WeakMap,_i=new WeakMap,os=new WeakMap,cn=new WeakMap,dn=new WeakMap,ne=new WeakMap,un=new WeakMap,ar=new WeakMap,Fc=new WeakMap,fn=new WeakMap,bl=new WeakMap,Sa=new WeakMap,or=new WeakMap,Re=new WeakMap,lr=new WeakMap,Z=new WeakSet,jd=function(){var e;if(n(this,cn))return;p(this,cn,new AbortController);const{signal:t}=n(this,cn);for(const s of this.trigger)s.addEventListener("click",n(this,fl),{signal:t}),s.addEventListener("pointerenter",n(this,Du),{signal:t}),s.addEventListener("pointerleave",n(this,ku),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,Ea))(e=s.container)==null||e.addEventListener("keydown",n(this,nr),{signal:t})},Zf=function(){const t=n(this,Ea).find(e=>e.hasCommentButton);t&&p(this,un,t._normalizePoint(t.commentButtonPosition))},tp=function(){if(n(this,Re).extraPopupElement&&!n(this,Re).editor)return;this.renderCommentButton();const[t,e]=n(this,un),{style:s}=n(this,ne);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},ep=function(){n(this,Re).extraPopupElement||(this.renderCommentButton(),n(this,ne).style.backgroundColor=this.commentButtonColor||"")},$d=function(){const t=n(this,fn),e=n(this,Si);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,fn).html||null},sp=function(){var t,e,s;return((s=(e=(t=n(this,Z,$d))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},rb=function(){var t,e,s;return((s=(e=(t=n(this,Z,$d))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},ab=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,Z,rb),fontSize:n(this,Z,sp)?`calc(${n(this,Z,sp)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
4
4
  `))e.push({name:"span",value:r,attributes:i});return s},ob=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,_i))&&b(this,Z,zd).call(this)},lb=function(){if(n(this,dn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,gl);let a=!!n(this,ml),o=a?n(this,ml):n(this,Fc);for(const A of n(this,Ea))if(!o||H.intersect(A.data.rect,o)!==null){o=A.data.rect,a=!0;break}const l=H.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),c=a?o[2]-o[0]+5:0,u=l[0]+c,f=l[1];p(this,dn,[100*(u-i)/e,100*(f-r)/s]);const{style:m}=n(this,Ut);m.left=`${n(this,dn)[0]}%`,m.top=`${n(this,dn)[1]}%`},zd=function(){if(n(this,as)){n(this,as).toggleCommentPopup(this,!1);return}p(this,_i,!n(this,_i)),n(this,_i)?(b(this,Z,Gd).call(this),n(this,Ut).addEventListener("click",n(this,fl)),n(this,Ut).addEventListener("keydown",n(this,nr))):(b(this,Z,ip).call(this),n(this,Ut).removeEventListener("click",n(this,fl)),n(this,Ut).removeEventListener("keydown",n(this,nr)))},Gd=function(){n(this,os)||this.render(),this.isVisible?n(this,_i)&&n(this,Ut).classList.add("focused"):(b(this,Z,lb).call(this),n(this,Ut).hidden=!1,n(this,Ut).style.zIndex=parseInt(n(this,Ut).style.zIndex)+1e3)},ip=function(){n(this,Ut).classList.remove("focused"),!(n(this,_i)||!this.isVisible)&&(n(this,Ut).hidden=!0,n(this,Ut).style.zIndex=parseInt(n(this,Ut).style.zIndex)-1e3)};class hb extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=X.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Nc;class sw extends Ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Nc,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=p(this,Nc,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,Nc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Nc=new WeakMap;var Oc;class iw extends Ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Oc,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,Oc,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,Oc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Oc=new WeakMap;var Bc;class nw extends Ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Bc,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,Bc,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,Bc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Bc=new WeakMap;var Hc;class cb extends Ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,Hc,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let h=[];for(let u=0,f=s.length;u<f;u+=2){const m=s[u]-e[0],A=e[3]-s[u+1];h.push(`${m},${A}`)}h=h.join(" ");const c=p(this,Hc,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,Hc)}addHighlightArea(){this.container.classList.add("highlightArea")}}Hc=new WeakMap;class rw extends cb{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class aw extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var Uc,_a,jc,np;class Xp extends Ot{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});g(this,jc);g(this,Uc,null);g(this,_a,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?X.HIGHLIGHT:X.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=b(this,jc,np).call(this,s,e),c=this.svgFactory.create(l,h,!0),u=p(this,Uc,this.svgFactory.createElement("svg:g"));c.append(u),u.setAttribute("stroke-width",r.width||1),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-miterlimit",10),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),u.setAttribute("transform",o);for(let f=0,m=i.length;f<m;f++){const A=this.svgFactory.createElement(this.svgElementName);n(this,_a).push(A),A.setAttribute("points",i[f].join(",")),u.append(A)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:r}=e,a=n(this,Uc);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,_a).length;o<l;o++)n(this,_a)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,jc,np).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,_a)}addHighlightArea(){this.container.classList.add("highlightArea")}}Uc=new WeakMap,_a=new WeakMap,jc=new WeakSet,np=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class db extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=X.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class ow extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class lw extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class hw extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class ub extends Ot{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=X.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var $c,zc,rp;class cw extends Ot{constructor(e){var i;super(e,{isRenderable:!0});g(this,zc);g(this,$c,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",b(this,zc,rp).bind(this)),p(this,$c,i);const{isMac:r}=ce.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,zc,rp).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,$c)}addHighlightArea(){this.container.classList.add("highlightArea")}}$c=new WeakMap,zc=new WeakSet,rp=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var yl,Ca,Al,hr,Gc,xa,Pr,ap,op,wl;let qp=(wl=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){g(this,Pr);g(this,yl,null);g(this,Ca,null);g(this,Al,null);g(this,hr,new Map);g(this,Gc,null);g(this,xa,null);this.div=t,p(this,yl,e),p(this,Ca,s),p(this,Gc,o||null),p(this,xa,h||null),p(this,Al,c||new jp),this.page=r,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,hr).size>0}async render(t){var a,o,l;const{annotations:e}=t,s=this.div;_r(s,this.viewport);const i=new Map,r={data:null,layer:s,linkService:n(this,xa),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ph,annotationStorage:n(this,Al),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const h of e){if(h.noHTML)continue;const c=h.annotationType===zt.POPUP;if(c){const m=i.get(h.id);if(!m)continue;r.elements=m}else if(h.rect[2]===h.rect[0]||h.rect[3]===h.rect[1])continue;r.data=h;const u=kg.create(r);if(!u.isRenderable)continue;if(!c&&h.popupRef){const m=i.get(h.popupRef);m?m.push(u):i.set(h.popupRef,[u])}const f=u.render();h.hidden&&(f.style.visibility="hidden"),await b(this,Pr,ap).call(this,f,h.id,r.elements),(o=(a=u.extraPopupElement)==null?void 0:a.popup)==null||o.renderCommentButton(),u._isEditable&&(n(this,hr).set(u.data.id,u),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(u))}b(this,Pr,op).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,xa),svgFactory:new Ph,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=wl._defaultBorderStyle),e.data=s;const i=kg.create(e);if(!i.isRenderable)continue;const r=i.render();await b(this,Pr,ap).call(this,r,s.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,_r(e,{rotation:t.rotation}),b(this,Pr,op).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(n(this,hr).values())}getEditableAnnotation(t){return n(this,hr).get(t)}addFakeAnnotation(t){var o;const{div:e}=this,{id:s,rotation:i}=t,r=new qA({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,xa),annotationStorage:n(this,Al)}),a=r.render();return e.append(a),(o=n(this,yl))==null||o.moveElementInDOM(e,a,a,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return J(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Za.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},yl=new WeakMap,Ca=new WeakMap,Al=new WeakMap,hr=new WeakMap,Gc=new WeakMap,xa=new WeakMap,Pr=new WeakSet,ap=async function(t,e,s){var o,l;const i=t.firstChild||t,r=i.id=`${Bp}${e}`,a=await((o=n(this,Gc))==null?void 0:o.getAriaAttributes(r));if(a)for(const[h,c]of a)i.setAttribute(h,c);s?s.at(-1).container.after(t):(this.div.append(t),(l=n(this,yl))==null||l.moveElementInDOM(this.div,t,i,!1))},op=function(){var e;if(!n(this,Ca))return;const t=this.div;for(const[s,i]of n(this,Ca)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;i.className="annotationContent";const{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(i):a.classList.contains("annotationContent")?a.after(i):a.before(i):r.append(i);const o=n(this,hr).get(s);o&&(o._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,i),o._hasNoCanvas=!1):o.canvas=i)}n(this,Ca).clear()},wl);const xd=/\r\n?|\n/g;var ls,Vc,Ta,hs,qt,fb,pb,gb,Vd,En,Wd,Xd,mb,hp,bb;const Pt=class Pt extends xt{constructor(e){super({...e,name:"freeTextEditor"});g(this,qt);g(this,ls,"");g(this,Vc,`${this.id}-editor`);g(this,Ta,null);g(this,hs);k(this,"_colorPicker",null);this.color=e.color||Pt._defaultColor||xt._defaultLineColor,p(this,hs,e.fontSize||Pt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=Pt.prototype,s=a=>a.isEmpty(),i=Cr.TRANSLATE_SMALL,r=Cr.TRANSLATE_BIG;return J(this,"_keyboardManager",new fd([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){xt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case st.FREETEXT_SIZE:Pt._defaultFontSize=s;break;case st.FREETEXT_COLOR:Pt._defaultColor=s;break}}updateParams(e,s){switch(e){case st.FREETEXT_SIZE:b(this,qt,fb).call(this,s);break;case st.FREETEXT_COLOR:b(this,qt,pb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[st.FREETEXT_SIZE,Pt._defaultFontSize],[st.FREETEXT_COLOR,Pt._defaultColor||xt._defaultLineColor]]}get propertiesToUpdate(){return[[st.FREETEXT_SIZE,n(this,hs)],[st.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new uu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return st.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Pt._internalPadding*e,-(Pt._internalPadding+n(this,hs))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,Ta,new AbortController);const e=this._uiManager.combinedSignal(n(this,Ta));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,Vc)),this._isDraggable=!0,(e=n(this,Ta))==null||e.abort(),p(this,Ta,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=n(this,ls),s=p(this,ls,b(this,qt,gb).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,ls,r),!r){this.remove();return}b(this,qt,Xd).call(this),this._uiManager.rebuild(this),b(this,qt,Vd).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,qt,Vd).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Pt._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",n(this,Vc)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${n(this,hs)}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,u]=this.pageDimensions,[f,m]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-f)/c,y=s+this.height-(o[1]-m)/u;break;case 90:A=e+(o[0]-f)/c,y=s-(o[1]-m)/u,[l,h]=[h,-l];break;case 180:A=e-this.width+(o[0]-f)/c,y=s-(o[1]-m)/u,[l,h]=[-l,-h];break;case 270:A=e+(o[0]-f-this.height*u)/c,y=s+(o[1]-m-this.width*c)/u,[l,h]=[-h,l];break}this.setAt(A*r,y*a,l,h)}else this._moveAfterPaste(e,s);b(this,qt,Xd).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,y,v;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=b(A=Pt,En,hp).call(A,s.getData("text")||"").replaceAll(xd,`
5
5
  `);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
@@ -10,4 +10,4 @@
10
10
  `)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:n(this,ls)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ls=new WeakMap,Vc=new WeakMap,Ta=new WeakMap,hs=new WeakMap,qt=new WeakSet,fb=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,hs))*this.parentScale),p(this,hs,r),b(this,qt,Vd).call(this)},i=n(this,hs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},pb=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},gb=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(b(i=Pt,En,Wd).call(i,r)),s=r);return e.join(`
11
11
  `)},Vd=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},En=new WeakSet,Wd=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(xd,"")},Xd=function(){if(this.editorDiv.replaceChildren(),!!n(this,ls))for(const e of n(this,ls).split(`
12
12
  `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},mb=function(){return n(this,ls).replaceAll(" "," ")},hp=function(e){return e.replaceAll(" "," ")},bb=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},g(Pt,En),k(Pt,"_freeTextDefaultContent",""),k(Pt,"_internalPadding",0),k(Pt,"_defaultColor",null),k(Pt,"_defaultFontSize",10),k(Pt,"_type","freetext"),k(Pt,"_editorType",X.FREETEXT);let lp=Pt;var of;let U=(of=class{toSVGPath(){_t("Abstract method `toSVGPath` must be implemented.")}get box(){_t("Abstract getter `box` must be implemented.")}serialize(t,e){_t("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){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,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}},k(of,"PRECISION",1e-4),of);var cs,qs,vl,El,Ci,et,Pa,Ra,Wc,Xc,Sl,_l,cr,qc,Mu,Lu,te,gh,yb,Ab,wb,vb,Eb,Sb;const Hi=class Hi{constructor({x:t,y:e},s,i,r,a,o=0){g(this,te);g(this,cs);g(this,qs,[]);g(this,vl);g(this,El);g(this,Ci,[]);g(this,et,new Float32Array(18));g(this,Pa);g(this,Ra);g(this,Wc);g(this,Xc);g(this,Sl);g(this,_l);g(this,cr,[]);p(this,cs,s),p(this,_l,r*i),p(this,El,a),n(this,et).set([NaN,NaN,NaN,NaN,t,e],6),p(this,vl,o),p(this,Xc,n(Hi,qc)*i),p(this,Wc,n(Hi,Lu)*i),p(this,Sl,i),n(this,cr).push(t,e)}isEmpty(){return isNaN(n(this,et)[8])}add({x:t,y:e}){var R;p(this,Pa,t),p(this,Ra,e);const[s,i,r,a]=n(this,cs);let[o,l,h,c]=n(this,et).subarray(8,12);const u=t-h,f=e-c,m=Math.hypot(u,f);if(m<n(this,Wc))return!1;const A=m-n(this,Xc),y=A/m,v=y*u,w=y*f;let S=o,E=l;o=h,l=c,h+=v,c+=w,(R=n(this,cr))==null||R.push(t,e);const _=-w/A,C=v/A,x=_*n(this,_l),T=C*n(this,_l);return n(this,et).set(n(this,et).subarray(2,8),0),n(this,et).set([h+x,c+T],4),n(this,et).set(n(this,et).subarray(14,18),12),n(this,et).set([h-x,c-T],16),isNaN(n(this,et)[6])?(n(this,Ci).length===0&&(n(this,et).set([o+x,l+T],2),n(this,Ci).push(NaN,NaN,NaN,NaN,(o+x-s)/r,(l+T-i)/a),n(this,et).set([o-x,l-T],14),n(this,qs).push(NaN,NaN,NaN,NaN,(o-x-s)/r,(l-T-i)/a)),n(this,et).set([S,E,o,l,h,c],6),!this.isEmpty()):(n(this,et).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=n(this,et).subarray(2,6),n(this,Ci).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,E]=n(this,et).subarray(14,18),n(this,qs).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-i)/a),!0):([S,E,o,l,h,c]=n(this,et).subarray(0,6),n(this,Ci).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,S,E]=n(this,et).subarray(12,18),n(this,qs).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,Ci),e=n(this,qs);if(isNaN(n(this,et)[6])&&!this.isEmpty())return b(this,te,yb).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);b(this,te,wb).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return b(this,te,Ab).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new _b(t,e,s,i,r,a)}getOutlines(){var u;const t=n(this,Ci),e=n(this,qs),s=n(this,et),[i,r,a,o]=n(this,cs),l=new Float32Array((((u=n(this,cr))==null?void 0:u.length)??0)+2);for(let f=0,m=l.length-2;f<m;f+=2)l[f]=(n(this,cr)[f]-i)/a,l[f+1]=(n(this,cr)[f+1]-r)/o;if(l[l.length-2]=(n(this,Pa)-i)/a,l[l.length-1]=(n(this,Ra)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,te,vb).call(this,l);const h=new Float32Array(n(this,Ci).length+24+n(this,qs).length);let c=t.length;for(let f=0;f<c;f+=2){if(isNaN(t[f])){h[f]=h[f+1]=NaN;continue}h[f]=t[f],h[f+1]=t[f+1]}c=b(this,te,Sb).call(this,h,c);for(let f=e.length-6;f>=6;f-=6)for(let m=0;m<6;m+=2){if(isNaN(e[f+m])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[f+m],h[c+1]=e[f+m+1],c+=2}return b(this,te,Eb).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,cs),n(this,Sl),n(this,vl),n(this,El))}};cs=new WeakMap,qs=new WeakMap,vl=new WeakMap,El=new WeakMap,Ci=new WeakMap,et=new WeakMap,Pa=new WeakMap,Ra=new WeakMap,Wc=new WeakMap,Xc=new WeakMap,Sl=new WeakMap,_l=new WeakMap,cr=new WeakMap,qc=new WeakMap,Mu=new WeakMap,Lu=new WeakMap,te=new WeakSet,gh=function(){const t=n(this,et).subarray(4,6),e=n(this,et).subarray(16,18),[s,i,r,a]=n(this,cs);return[(n(this,Pa)+(t[0]-e[0])/2-s)/r,(n(this,Ra)+(t[1]-e[1])/2-i)/a,(n(this,Pa)+(e[0]-t[0])/2-s)/r,(n(this,Ra)+(e[1]-t[1])/2-i)/a]},yb=function(){const[t,e,s,i]=n(this,cs),[r,a,o,l]=b(this,te,gh).call(this);return`M${(n(this,et)[2]-t)/s} ${(n(this,et)[3]-e)/i} L${(n(this,et)[4]-t)/s} ${(n(this,et)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,et)[16]-t)/s} ${(n(this,et)[17]-e)/i} L${(n(this,et)[14]-t)/s} ${(n(this,et)[15]-e)/i} Z`},Ab=function(t){const e=n(this,qs);t.push(`L${e[4]} ${e[5]} Z`)},wb=function(t){const[e,s,i,r]=n(this,cs),a=n(this,et).subarray(4,6),o=n(this,et).subarray(16,18),[l,h,c,u]=b(this,te,gh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${u} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},vb=function(t){const e=n(this,et),[s,i,r,a]=n(this,cs),[o,l,h,c]=b(this,te,gh).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(u,t,n(this,cs),n(this,Sl),n(this,vl),n(this,El))},Eb=function(t,e){const s=n(this,qs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Sb=function(t,e){const s=n(this,et).subarray(4,6),i=n(this,et).subarray(16,18),[r,a,o,l]=n(this,cs),[h,c,u,f]=b(this,te,gh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},g(Hi,qc,8),g(Hi,Mu,2),g(Hi,Lu,n(Hi,qc)+n(Hi,Mu));let fu=Hi;var Cl,ka,pn,Yc,ds,Kc,Vt,Iu,Cb;class _b extends U{constructor(e,s,i,r,a,o){super();g(this,Iu);g(this,Cl);g(this,ka,new Float32Array(4));g(this,pn);g(this,Yc);g(this,ds);g(this,Kc);g(this,Vt);p(this,Vt,e),p(this,ds,s),p(this,Cl,i),p(this,Kc,r),p(this,pn,a),p(this,Yc,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,Iu,Cb).call(this,o);const[l,h,c,u]=n(this,ka);for(let f=0,m=e.length;f<m;f+=2)e[f]=(e[f]-l)/c,e[f+1]=(e[f+1]-h)/u;for(let f=0,m=s.length;f<m;f+=2)s[f]=(s[f]-l)/c,s[f+1]=(s[f+1]-h)/u}toSVGPath(){const e=[`M${n(this,Vt)[4]} ${n(this,Vt)[5]}`];for(let s=6,i=n(this,Vt).length;s<i;s+=6){if(isNaN(n(this,Vt)[s])){e.push(`L${n(this,Vt)[s+4]} ${n(this,Vt)[s+5]}`);continue}e.push(`C${n(this,Vt)[s]} ${n(this,Vt)[s+1]} ${n(this,Vt)[s+2]} ${n(this,Vt)[s+3]} ${n(this,Vt)[s+4]} ${n(this,Vt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let h,c;switch(a){case 0:h=U._rescale(n(this,Vt),e,r,o,-l),c=U._rescale(n(this,ds),e,r,o,-l);break;case 90:h=U._rescaleAndSwap(n(this,Vt),e,s,o,l),c=U._rescaleAndSwap(n(this,ds),e,s,o,l);break;case 180:h=U._rescale(n(this,Vt),i,s,-o,l),c=U._rescale(n(this,ds),i,s,-o,l);break;case 270:h=U._rescaleAndSwap(n(this,Vt),i,r,-o,-l),c=U._rescaleAndSwap(n(this,ds),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,ka)}newOutliner(e,s,i,r,a,o=0){return new fu(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,ka),[l,h,c,u]=n(this,Cl),f=a*c,m=o*u,A=i*c+l,y=r*u+h,v=this.newOutliner({x:n(this,ds)[0]*f+A,y:n(this,ds)[1]*m+y},n(this,Cl),n(this,Kc),e,n(this,Yc),s??n(this,pn));for(let w=2;w<n(this,ds).length;w+=2)v.add({x:n(this,ds)[w]*f+A,y:n(this,ds)[w+1]*m+y});return v.getOutlines()}}Cl=new WeakMap,ka=new WeakMap,pn=new WeakMap,Yc=new WeakMap,ds=new WeakMap,Kc=new WeakMap,Vt=new WeakMap,Iu=new WeakSet,Cb=function(e){const s=n(this,Vt);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,c=r;const u=e?Math.max:Math.min,f=new Float32Array(4);for(let A=6,y=s.length;A<y;A+=6){const v=s[A+4],w=s[A+5];isNaN(s[A])?(H.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=u(o,v)),c<w?(h=v,c=w):c===w&&(h=u(h,v))):(f[0]=f[1]=1/0,f[2]=f[3]=-1/0,H.bezierBoundingBox(i,r,...s.slice(A,A+6),f),H.rectBoundingBox(f[0],f[1],f[2],f[3],a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=u(o,f[0])),c<f[3]?(h=f[2],c=f[3]):c===f[3]&&(h=u(h,f[2]))),i=v,r=w}const m=n(this,ka);m[0]=a[0]-n(this,pn),m[1]=a[1]-n(this,pn),m[2]=a[2]-a[0]+2*n(this,pn),m[3]=a[3]-a[1]+2*n(this,pn),this.firstPoint=[o,l],this.lastPoint=[h,c]};var Jc,Qc,Zc,dr,Ys,Ue,xb,qd,Tb,Pb,dp;class cp{constructor(t,e=0,s=0,i=!0){g(this,Ue);g(this,Jc);g(this,Qc);g(this,Zc);g(this,dr,[]);g(this,Ys,[]);const r=[1/0,1/0,-1/0,-1/0],a=10**-4;for(const{x:y,y:v,width:w,height:S}of t){const E=Math.floor((y-e)/a)*a,_=Math.ceil((y+w+e)/a)*a,C=Math.floor((v-e)/a)*a,x=Math.ceil((v+S+e)/a)*a,T=[E,C,x,!0],P=[_,C,x,!1];n(this,dr).push(T,P),H.rectBoundingBox(E,C,_,x,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let u=i?-1/0:1/0,f=1/0;const m=n(this,dr).at(i?-1:-2),A=[m[0],m[2]];for(const y of n(this,dr)){const[v,w,S,E]=y;!E&&i?w<f?(f=w,u=v):w===f&&(u=Math.max(u,v)):E&&!i&&(w<f?(f=w,u=v):w===f&&(u=Math.min(u,v))),y[0]=(v-h)/o,y[1]=(w-c)/l,y[2]=(S-c)/l}p(this,Jc,new Float32Array([h,c,o,l])),p(this,Qc,[u,f]),p(this,Zc,A)}getOutlines(){n(this,dr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,dr))e[3]?(t.push(...b(this,Ue,dp).call(this,e)),b(this,Ue,Tb).call(this,e)):(b(this,Ue,Pb).call(this,e),t.push(...b(this,Ue,dp).call(this,e)));return b(this,Ue,xb).call(this,t)}}Jc=new WeakMap,Qc=new WeakMap,Zc=new WeakMap,dr=new WeakMap,Ys=new WeakMap,Ue=new WeakSet,xb=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,u]=a;s.delete(a);let f=o,m=l;for(r=[o,h],i.push(r);;){let A;if(s.has(c))A=c;else if(s.has(u))A=u;else break;s.delete(A),[o,l,h,c,u]=A,f!==o&&(r.push(f,m,o,m===l?l:h),f=o),m=m===l?h:l}r.push(f,m)}return new dw(i,n(this,Jc),n(this,Qc),n(this,Zc))},qd=function(t){const e=n(this,Ys);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},Tb=function([,t,e]){const s=b(this,Ue,qd).call(this,t);n(this,Ys).splice(s,0,[t,e])},Pb=function([,t,e]){const s=b(this,Ue,qd).call(this,t);for(let i=s;i<n(this,Ys).length;i++){const[r,a]=n(this,Ys)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ys).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,Ys)[i];if(r!==t)break;if(r===t&&a===e){n(this,Ys).splice(i,1);return}}},dp=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Ue,qd).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,Ys)[o];for(let c=0,u=r.length;c<u;c++){const[,f,m]=r[c];if(!(h<=f||m<=l)){if(f>=l){if(m>h)r[c][1]=h;else{if(u===1)return[];r.splice(c,1),c--,u--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var td,xl;class dw extends U{constructor(e,s,i,r){super();g(this,td);g(this,xl);p(this,xl,e),p(this,td,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,xl)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,h=r-s;for(const c of n(this,xl)){const u=new Array(c.length);for(let f=0;f<c.length;f+=2)u[f]=e+c[f]*l,u[f+1]=r-c[f+1]*h;o.push(u)}return o}get box(){return n(this,td)}get classNamesForOutlining(){return["highlightOutline"]}}td=new WeakMap,xl=new WeakMap;class up extends fu{newFreeDrawOutline(t,e,s,i,r,a){return new uw(t,e,s,i,r,a)}}class uw extends _b{newOutliner(t,e,s,i,r,a=0){return new up(t,e,s,i,r,a)}}var Tl,ed,gn,Da,sd,qe,id,nd,Ma,us,fs,me,Pl,Rl,ke,kl,Ls,rd,Q,fp,Yd,Rb,kb,Db,pp,Dr,Fs,ro,Mb,Kd,Jd,Lb,Ib,Fb,Nb,Ob;const dt=class dt extends xt{constructor(e){super({...e,name:"highlightEditor"});g(this,Q);g(this,Tl,null);g(this,ed,0);g(this,gn);g(this,Da,null);g(this,sd,null);g(this,qe,null);g(this,id,null);g(this,nd,0);g(this,Ma,null);g(this,us,null);g(this,fs,null);g(this,me,!1);g(this,Pl,null);g(this,Rl,null);g(this,ke,null);g(this,kl,"");g(this,Ls);g(this,rd,"");this.color=e.color||dt._defaultColor,p(this,Ls,e.thickness||dt._defaultThickness),this.opacity=e.opacity||dt._defaultOpacity,p(this,gn,e.boxes||null),p(this,rd,e.methodOfCreation||""),p(this,kl,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(p(this,me,!0),b(this,Q,Yd).call(this,e),b(this,Q,Dr).call(this)):n(this,gn)&&(p(this,Tl,e.anchorNode),p(this,ed,e.anchorOffset),p(this,id,e.focusNode),p(this,nd,e.focusOffset),b(this,Q,fp).call(this),b(this,Q,Dr).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=dt.prototype;return J(this,"_keyboardManager",new fd([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,me)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,Ls),methodOfCreation:n(this,rd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;xt.initialize(e,s),dt._defaultColor||(dt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case st.HIGHLIGHT_COLOR:dt._defaultColor=s;break;case st.HIGHLIGHT_THICKNESS:dt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,Rl)}get commentButtonPosition(){return n(this,Pl)}updateParams(e,s){switch(e){case st.HIGHLIGHT_COLOR:b(this,Q,Rb).call(this,s);break;case st.HIGHLIGHT_THICKNESS:b(this,Q,kb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[st.HIGHLIGHT_COLOR,dt._defaultColor],[st.HIGHLIGHT_THICKNESS,dt._defaultThickness]]}get propertiesToUpdate(){return[[st.HIGHLIGHT_COLOR,this.color||dt._defaultColor],[st.HIGHLIGHT_THICKNESS,n(this,Ls)||dt._defaultThickness],[st.HIGHLIGHT_FREE,n(this,me)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,fs),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,sd))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,sd,new Th({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,Q,Jd).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,Q,Jd).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,Q,pp).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,Q,Dr).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,Q,pp).call(this):e&&(b(this,Q,Dr).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,me)?(e=(e-this.rotation+360)%360,i=b(r=dt,Fs,ro).call(r,n(this,us).box,e)):i=b(a=dt,Fs,ro).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,fs),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,ke),{bbox:b(o=dt,Fs,ro).call(o,n(this,qe).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,kl)&&(e.setAttribute("aria-label",n(this,kl)),e.setAttribute("role","mark")),n(this,me)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,Q,Mb).bind(this),{signal:this._uiManager._signal});const s=p(this,Ma,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,Da),this.setDims(this.width,this.height),im(this,n(this,Ma),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ke),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ke),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,Q,Kd).call(this,!0);break;case 1:case 3:b(this,Q,Kd).call(this,!1);break}}select(){var e;super.select(),n(this,ke)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,ke),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,ke)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,ke),{rootClass:{selected:!1}}),n(this,me)||b(this,Q,Kd).call(this,!1))}get _mustFixPosition(){return!n(this,me)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,fs),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,ke),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:h,height:c}=i.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),m=A=>{u.abort(),b(this,Fs,Nb).call(this,e,A)};window.addEventListener("blur",m,{signal:f}),window.addEventListener("pointerup",m,{signal:f}),window.addEventListener("pointerdown",Nt,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",vs,{signal:f}),i.addEventListener("pointermove",b(this,Fs,Fb).bind(this,e),{signal:f}),this._freeHighlight=new up({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.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 async deserialize(e,s,i){var y,v,w,S;let r=null;if(e instanceof db){const{data:{quadPoints:E,rect:_,rotation:C,id:x,color:T,opacity:P,popupRef:R,richText:D,contentsObj:M,creationDate:I,modificationDate:G},parent:{page:{pageNumber:N}}}=e;r=e={annotationType:X.HIGHLIGHT,color:Array.from(T),opacity:P,quadPoints:E,boxes:null,pageIndex:N-1,rect:_.slice(0),rotation:C,annotationElementId:x,id:x,deleted:!1,popupRef:R,richText:D,comment:(M==null?void 0:M.str)||null,creationDate:I,modificationDate:G}}else if(e instanceof Xp){const{data:{inkLists:E,rect:_,rotation:C,id:x,color:T,borderStyle:{rawWidth:P},popupRef:R,richText:D,contentsObj:M,creationDate:I,modificationDate:G},parent:{page:{pageNumber:N}}}=e;r=e={annotationType:X.HIGHLIGHT,color:Array.from(T),thickness:P,inkLists:E,boxes:null,pageIndex:N-1,rect:_.slice(0),rotation:C,annotationElementId:x,id:x,deleted:!1,popupRef:R,richText:D,comment:(M==null?void 0:M.str)||null,creationDate:I,modificationDate:G}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,c=await super.deserialize(e,s,i);c.color=H.makeHexColor(...a),c.opacity=h||1,l&&p(c,Ls,e.thickness),c._initialData=r,e.comment&&c.setCommentData(e);const[u,f]=c.pageDimensions,[m,A]=c.pageTranslation;if(o){const E=p(c,gn,[]);for(let _=0;_<o.length;_+=8)E.push({x:(o[_]-m)/u,y:1-(o[_+1]-A)/f,width:(o[_+2]-o[_])/u,height:(o[_+1]-o[_+5])/f});b(y=c,Q,fp).call(y),b(v=c,Q,Dr).call(v),c.rotate(c.rotation)}else if(l){p(c,me,!0);const E=l[0],_={x:E[0]-m,y:f-(E[1]-A)},C=new up(_,[0,0,u,f],1,n(c,Ls)/2,!0,.001);for(let P=0,R=E.length;P<R;P+=2)_.x=E[P]-m,_.y=f-(E[P+1]-A),C.add(_);const{id:x,clipPathId:T}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);b(w=c,Q,Yd).call(w,{highlightOutlines:C.getOutlines(),highlightId:x,clipPathId:T}),b(S=c,Q,Dr).call(S),c.rotate(c.parentRotation)}return c}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=xt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(e);return Object.assign(i,{color:s,opacity:this.opacity,thickness:n(this,Ls),quadPoints:b(this,Q,Lb).call(this),outlines:b(this,Q,Ib).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!b(this,Q,Ob).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};Tl=new WeakMap,ed=new WeakMap,gn=new WeakMap,Da=new WeakMap,sd=new WeakMap,qe=new WeakMap,id=new WeakMap,nd=new WeakMap,Ma=new WeakMap,us=new WeakMap,fs=new WeakMap,me=new WeakMap,Pl=new WeakMap,Rl=new WeakMap,ke=new WeakMap,kl=new WeakMap,Ls=new WeakMap,rd=new WeakMap,Q=new WeakSet,fp=function(){const e=new cp(n(this,gn),.001);p(this,us,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,us).box;const s=new cp(n(this,gn),.0025,.001,this._uiManager.direction==="ltr");p(this,qe,s.getOutlines());const{firstPoint:i}=n(this,us);p(this,Pl,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:r}=n(this,qe);p(this,Rl,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},Yd=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var f,m;if(p(this,us,e),p(this,qe,e.getNewOutline(n(this,Ls)/2+1.5,.0025)),s>=0)p(this,fs,s),p(this,Da,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,ke,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,qe).box,path:{d:n(this,qe).toSVGPath()}},!0));else if(this.parent){const A=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,fs),{bbox:b(f=dt,Fs,ro).call(f,n(this,us).box,(A-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,ke),{bbox:b(m=dt,Fs,ro).call(m,n(this,qe).box,A),path:{d:n(this,qe).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[A,y]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*y/A,this.height=h*A/y;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[A,y]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*y/A,this.height=h*A/y;break}}const{firstPoint:c}=e;p(this,Pl,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:u}=n(this,qe);p(this,Rl,[(u[0]-a)/l,(u[1]-o)/h])},Rb=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,dt._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},kb=function(e){const s=n(this,Ls),i=r=>{p(this,Ls,r),b(this,Q,Db).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Db=function(e){n(this,me)&&(b(this,Q,Yd).call(this,{highlightOutlines:n(this,us).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))},pp=function(){n(this,fs)===null||!this.parent||(this.parent.drawLayer.remove(n(this,fs)),p(this,fs,null),this.parent.drawLayer.remove(n(this,ke)),p(this,ke,null))},Dr=function(e=this.parent){n(this,fs)===null&&({id:Kt(this,fs)._,clipPathId:Kt(this,Da)._}=e.drawLayer.draw({bbox:n(this,us).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,me)},path:{d:n(this,us).toSVGPath()}},!1,!0),p(this,ke,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,me)},bbox:n(this,qe).box,path:{d:n(this,qe).toSVGPath()}},n(this,me))),n(this,Ma)&&(n(this,Ma).style.clipPath=n(this,Da)))},Fs=new WeakSet,ro=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},Mb=function(e){dt._keyboardManager.exec(this,e)},Kd=function(e){if(!n(this,Tl))return;const s=window.getSelection();e?s.setPosition(n(this,Tl),n(this,ed)):s.setPosition(n(this,id),n(this,nd))},Jd=function(){return n(this,me)?this.rotation:0},Lb=function(){if(n(this,me))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,gn),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:u,height:f}of a){const m=h*e+i,A=(1-c)*s+r;o[l]=o[l+4]=m,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=m+u*e,o[l+5]=o[l+7]=A-f*s,l+=8}return o},Ib=function(e){return n(this,us).serialize(e,b(this,Q,Jd).call(this))},Fb=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Nb=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Ob=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},g(dt,Fs),k(dt,"_defaultColor",null),k(dt,"_defaultOpacity",1),k(dt,"_defaultThickness",12),k(dt,"_type","highlight"),k(dt,"_editorType",X.HIGHLIGHT),k(dt,"_freeHighlightId",-1),k(dt,"_freeHighlight",null),k(dt,"_freeHighlightClipId","");let pu=dt;var La;class Bb{constructor(){g(this,La,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,La)[t]=e}toSVGProperties(){const t=n(this,La);return p(this,La,Object.create(null)),{root:t}}reset(){p(this,La,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){_t("Not implemented")}}La=new WeakMap;var ps,Dl,re,Ia,Fa,ur,fr,pr,Na,ot,gp,mp,bp,mh,Hb,Qd,bh,ao;const j=class j extends xt{constructor(e){super(e);g(this,ot);g(this,ps,null);g(this,Dl);k(this,"_colorPicker",null);k(this,"_drawId",null);p(this,Dl,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_addOutlines(e){e.drawOutlines&&(b(this,ot,gp).call(this,e),b(this,ot,mh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){_t("Not implemented")}static get typesMap(){_t("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(j,re).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=n(this,ps).updateProperty(s,l);h&&b(this,ot,bh).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,j._mergeSVGProperties(n(this,ps).getPathResizingSVGProperties(b(this,ot,Qd).call(this)),{bbox:b(this,ot,ao).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,j._mergeSVGProperties(n(this,ps).getPathResizedSVGProperties(b(this,ot,Qd).call(this)),{bbox:b(this,ot,ao).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,ot,ao).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,j._mergeSVGProperties(n(this,ps).getPathTranslatedSVGProperties(b(this,ot,Qd).call(this),this.parentDimensions),{bbox:b(this,ot,ao).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.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(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,Dl)&&(p(this,Dl,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,ot,bp).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,ot,mh).call(this),b(this,ot,bh).call(this,n(this,ps).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,ot,bp).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,ot,mh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,j._mergeSVGProperties({bbox:b(this,ot,ao).call(this)},n(this,ps).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,ot,bh).call(this,n(this,ps).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){_t("Not implemented")}static startDrawing(e,s,i,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(n(j,fr)&&n(j,fr)!==c)return;const{viewport:{rotation:u}}=e,{width:f,height:m}=a.getBoundingClientRect(),A=p(j,Ia,new AbortController),y=e.combinedSignal(A);if(n(j,ur)||p(j,ur,h),n(j,fr)??p(j,fr,c),window.addEventListener("pointerup",w=>{var S;n(j,ur)===w.pointerId?this._endDraw(w):(S=n(j,pr))==null||S.delete(w.pointerId)},{signal:y}),window.addEventListener("pointercancel",w=>{var S;n(j,ur)===w.pointerId?this._currentParent.endDrawingSession():(S=n(j,pr))==null||S.delete(w.pointerId)},{signal:y}),window.addEventListener("pointerdown",w=>{n(j,fr)===w.pointerType&&((n(j,pr)||p(j,pr,new Set)).add(w.pointerId),n(j,re).isCancellable()&&(n(j,re).removeLastElement(),n(j,re).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",vs,{signal:y}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:y}),a.addEventListener("touchmove",w=>{w.timeStamp===n(j,Na)&&Nt(w)},{signal:y}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),n(j,re)){e.drawLayer.updateProperties(this._currentDrawId,n(j,re).startNew(o,l,f,m,u));return}s.updateUIForDefaultProperties(this),p(j,re,this.createDrawerInstance(o,l,f,m,u)),p(j,Fa,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(j,Fa).toSVGProperties(),n(j,re).defaultSVGProperties),!0,!1)}static _drawMove(e){var a;if(p(j,Na,-1),!n(j,re))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(n(j,ur)===r){if(((a=n(j,pr))==null?void 0:a.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(j,re).add(s,i)),p(j,Na,e.timeStamp),Nt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(j,re,null),p(j,Fa,null),p(j,fr,null),p(j,Na,NaN)),n(j,Ia)&&(n(j,Ia).abort(),p(j,Ia,null),p(j,ur,NaN),p(j,pr,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(j,re).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(j,re),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:st.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(st.DRAW_STEP),!n(j,re).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(j,re).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(j,Fa),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){_t("Not implemented")}static async deserialize(e,s,i){var u,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(u=c,ot,gp).call(u,{drawOutlines:h}),b(f=c,ot,mh).call(f),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,ps).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};ps=new WeakMap,Dl=new WeakMap,re=new WeakMap,Ia=new WeakMap,Fa=new WeakMap,ur=new WeakMap,fr=new WeakMap,pr=new WeakMap,Na=new WeakMap,ot=new WeakSet,gp=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,ps,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,ot,mp).call(this,e,this.parent),b(this,ot,bh).call(this,e.box)},mp=function(e,s){const{id:i}=s.drawLayer.draw(j._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},bp=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},mh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,ot,mp).call(this,n(this,ps),e)}},Hb=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Qd=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},bh=function(e){[this.x,this.y,this.width,this.height]=b(this,ot,Hb).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},ao=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/h),r*(h/l),i*(l/h)];case 5:return[1-s,e,i*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),i*(l/h)];case 7:return[s-i*(l/h),1-e-r*(h/l),i*(l/h),r*(h/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(h/l),s,r*(h/l),i*(l/h)];case 13:return[1-s-i*(l/h),e-r*(h/l),i*(l/h),r*(h/l)];case 14:return[1-e,1-s-i*(l/h),r*(h/l),i*(l/h)];case 15:return[s,1-e,i*(l/h),r*(h/l)];default:return[e,s,i,r]}},k(j,"_currentDrawId",-1),k(j,"_currentParent",null),g(j,re,null),g(j,Ia,null),g(j,Fa,null),g(j,ur,NaN),g(j,fr,null),g(j,pr,null),g(j,Na,NaN),k(j,"_INNER_MARGIN",3);let gu=j;var xi,ae,oe,Oa,Ml,Fe,be,Is,Ba,Ha,Ua,Ll,Zd;class fw{constructor(t,e,s,i,r,a){g(this,Ll);g(this,xi,new Float64Array(6));g(this,ae);g(this,oe);g(this,Oa);g(this,Ml);g(this,Fe);g(this,be,"");g(this,Is,0);g(this,Ba,new gd);g(this,Ha);g(this,Ua);p(this,Ha,s),p(this,Ua,i),p(this,Oa,r),p(this,Ml,a),[t,e]=b(this,Ll,Zd).call(this,t,e);const o=p(this,ae,[NaN,NaN,NaN,NaN,t,e]);p(this,Fe,[t,e]),p(this,oe,[{line:o,points:n(this,Fe)}]),n(this,xi).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,Ml,e)}isEmpty(){return!n(this,oe)||n(this,oe).length===0}isCancellable(){return n(this,Fe).length<=10}add(t,e){[t,e]=b(this,Ll,Zd).call(this,t,e);const[s,i,r,a]=n(this,xi).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,Ha)*o,n(this,Ua)*l)<=2?null:(n(this,Fe).push(t,e),isNaN(s)?(n(this,xi).set([r,a,t,e],2),n(this,ae).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,xi)[0])&&n(this,ae).splice(6,6),n(this,xi).set([s,i,r,a,t,e],0),n(this,ae).push(...U.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,Fe).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,Ha,s),p(this,Ua,i),p(this,Oa,r),[t,e]=b(this,Ll,Zd).call(this,t,e);const a=p(this,ae,[NaN,NaN,NaN,NaN,t,e]);p(this,Fe,[t,e]);const o=n(this,oe).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,oe).push({line:a,points:n(this,Fe)}),n(this,xi).set(a,0),p(this,Is,0),this.toSVGPath(),null}getLastElement(){return n(this,oe).at(-1)}setLastElement(t){return n(this,oe)?(n(this,oe).push(t),p(this,ae,t.line),p(this,Fe,t.points),p(this,Is,0),{path:{d:this.toSVGPath()}}):n(this,Ba).setLastElement(t)}removeLastElement(){if(!n(this,oe))return n(this,Ba).removeLastElement();n(this,oe).pop(),p(this,be,"");for(let t=0,e=n(this,oe).length;t<e;t++){const{line:s,points:i}=n(this,oe)[t];p(this,ae,s),p(this,Fe,i),p(this,Is,0),this.toSVGPath()}return{path:{d:n(this,be)}}}toSVGPath(){const t=U.svgRound(n(this,ae)[4]),e=U.svgRound(n(this,ae)[5]);if(n(this,Fe).length===2)return p(this,be,`${n(this,be)} M ${t} ${e} Z`),n(this,be);if(n(this,Fe).length<=6){const i=n(this,be).lastIndexOf("M");p(this,be,`${n(this,be).slice(0,i)} M ${t} ${e}`),p(this,Is,6)}if(n(this,Fe).length===4){const i=U.svgRound(n(this,ae)[10]),r=U.svgRound(n(this,ae)[11]);return p(this,be,`${n(this,be)} L ${i} ${r}`),p(this,Is,12),n(this,be)}const s=[];n(this,Is)===0&&(s.push(`M ${t} ${e}`),p(this,Is,6));for(let i=n(this,Is),r=n(this,ae).length;i<r;i+=6){const[a,o,l,h,c,u]=n(this,ae).slice(i,i+6).map(U.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}return p(this,be,n(this,be)+s.join(" ")),p(this,Is,n(this,ae).length),n(this,be)}getOutlines(t,e,s,i){const r=n(this,oe).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,Ba).build(n(this,oe),t,e,s,n(this,Oa),n(this,Ml),i),p(this,xi,null),p(this,ae,null),p(this,oe,null),p(this,be,null),n(this,Ba)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}xi=new WeakMap,ae=new WeakMap,oe=new WeakMap,Oa=new WeakMap,Ml=new WeakMap,Fe=new WeakMap,be=new WeakMap,Is=new WeakMap,Ba=new WeakMap,Ha=new WeakMap,Ua=new WeakMap,Ll=new WeakSet,Zd=function(t,e){return U._normalizePoint(t,e,n(this,Ha),n(this,Ua),n(this,Oa))};var Ne,ad,od,gs,Ti,Pi,Il,Fl,ja,Ae,Oi,Ub,jb,$b;class gd extends U{constructor(){super(...arguments);g(this,Ae);g(this,Ne);g(this,ad,0);g(this,od);g(this,gs);g(this,Ti);g(this,Pi);g(this,Il);g(this,Fl);g(this,ja)}build(e,s,i,r,a,o,l){p(this,Ti,s),p(this,Pi,i),p(this,Il,r),p(this,Fl,a),p(this,ja,o),p(this,od,l??0),p(this,gs,e),b(this,Ae,jb).call(this)}get thickness(){return n(this,ja)}setLastElement(e){return n(this,gs).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,gs).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,gs)){if(e.push(`M${U.svgRound(s[4])} ${U.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${U.svgRound(s[10])} ${U.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,u]=s.subarray(i,i+6).map(U.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,u,f]=b(this,Ae,Ub).call(this);let m,A,y,v,w,S,E,_,C;switch(n(this,Fl)){case 0:C=U._rescale,m=e,A=s+r,y=i,v=-r,w=e+h*i,S=s+(1-c-f)*r,E=e+(h+u)*i,_=s+(1-c)*r;break;case 90:C=U._rescaleAndSwap,m=e,A=s,y=i,v=r,w=e+c*i,S=s+h*r,E=e+(c+f)*i,_=s+(h+u)*r;break;case 180:C=U._rescale,m=e+i,A=s,y=-i,v=r,w=e+(1-h-u)*i,S=s+c*r,E=e+(1-h)*i,_=s+(c+f)*r;break;case 270:C=U._rescaleAndSwap,m=e+i,A=s+r,y=-i,v=-r,w=e+(1-c-f)*i,S=s+(1-h-u)*r,E=e+(1-c)*i,_=s+(1-h)*r;break}for(const{line:x,points:T}of n(this,gs))o.push(C(x,m,A,y,v,a?new Array(x.length):null)),l.push(C(T,m,A,y,v,a?new Array(T.length):null));return{lines:o,points:l,rect:[w,S,E,_]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const u=[];let f,m,A,y,v;switch(h){case 0:v=U._rescale,f=-e/i,m=s/r+1,A=1/i,y=-1/r;break;case 90:v=U._rescaleAndSwap,f=-s/r,m=-e/i,A=1/r,y=1/i;break;case 180:v=U._rescale,f=e/i+1,m=-s/r,A=-1/i,y=1/r;break;case 270:v=U._rescaleAndSwap,f=s/r+1,m=e/i+1,A=-1/r,y=-1/i;break}if(!o){o=[];for(const S of l){const E=S.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const _=new Float32Array(3*(E-2));o.push(_);let[C,x,T,P]=S.subarray(0,4);_.set([NaN,NaN,NaN,NaN,C,x],0);for(let R=4;R<E;R+=2){const D=S[R],M=S[R+1];_.set(U.createBezierPoints(C,x,T,P,D,M),(R-2)*3),[C,x,T,P]=[T,P,D,M]}}}for(let S=0,E=o.length;S<E;S++)u.push({line:v(o[S].map(_=>_??NaN),f,m,A,y),points:v(l[S].map(_=>_??NaN),f,m,A,y)});const w=new this.prototype.constructor;return w.build(u,i,r,1,h,c,a),w}get box(){return n(this,Ne)}updateProperty(e,s){return e==="stroke-width"?b(this,Ae,$b).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,Ae,Oi).call(this);p(this,Ti,e),p(this,Pi,s),p(this,Il,i);const[o,l]=b(this,Ae,Oi).call(this),h=o-r,c=l-a,u=n(this,Ne);return u[0]-=h,u[1]-=c,u[2]+=2*h,u[3]+=2*c,u}updateRotation(e){return p(this,ad,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Ne).map(U.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,Ne);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${U.svgRound(e)} ${U.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,Ne);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,ad)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${U.svgRound(l)} ${U.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,Ae,Oi).call(this),[l,h,c,u]=n(this,Ne);if(Math.abs(c-a)<=U.PRECISION||Math.abs(u-o)<=U.PRECISION){const v=e+i/2-(l+c/2),w=s+r/2-(h+u/2);return{path:{"transform-origin":`${U.svgRound(e)} ${U.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const f=(i-2*a)/(c-2*a),m=(r-2*o)/(u-2*o),A=c/i,y=u/r;return{path:{"transform-origin":`${U.svgRound(l)} ${U.svgRound(h)}`,transform:`${this.rotationTransform} scale(${A} ${y}) translate(${U.svgRound(a)} ${U.svgRound(o)}) scale(${f} ${m}) translate(${U.svgRound(-a)} ${U.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,Ae,Oi).call(this),l=n(this,Ne),[h,c,u,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(u-a)<=U.PRECISION||Math.abs(f-o)<=U.PRECISION){const w=e+i/2-(h+u/2),S=s+r/2-(c+f/2);for(const{line:E,points:_}of n(this,gs))U._translate(E,w,S,E),U._translate(_,w,S,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${U.svgRound(e)} ${U.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(u-2*a),A=(r-2*o)/(f-2*o),y=-m*(h+a)+e+a,v=-A*(c+o)+s+o;if(m!==1||A!==1||y!==0||v!==0)for(const{line:w,points:S}of n(this,gs))U._rescale(w,y,v,m,A,w),U._rescale(S,y,v,m,A,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${U.svgRound(e)} ${U.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,Ne),l=e-o[0],h=s-o[1];if(n(this,Ti)===r&&n(this,Pi)===a)for(const{line:c,points:u}of n(this,gs))U._translate(c,l,h,c),U._translate(u,l,h,u);else{const c=n(this,Ti)/r,u=n(this,Pi)/a;p(this,Ti,r),p(this,Pi,a);for(const{line:f,points:m}of n(this,gs))U._rescale(f,l,h,c,u,f),U._rescale(m,l,h,c,u,m);o[2]*=c,o[3]*=u}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${U.svgRound(e)} ${U.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,Ne);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${U.svgRound(e[0])} ${U.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Ne=new WeakMap,ad=new WeakMap,od=new WeakMap,gs=new WeakMap,Ti=new WeakMap,Pi=new WeakMap,Il=new WeakMap,Fl=new WeakMap,ja=new WeakMap,Ae=new WeakSet,Oi=function(e=n(this,ja)){const s=n(this,od)+e/2*n(this,Il);return n(this,Fl)%180===0?[s/n(this,Ti),s/n(this,Pi)]:[s/n(this,Pi),s/n(this,Ti)]},Ub=function(){const[e,s,i,r]=n(this,Ne),[a,o]=b(this,Ae,Oi).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},jb=function(){const e=p(this,Ne,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of n(this,gs)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)H.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,u,f,m,A,y]=r.subarray(l,l+6);H.bezierBoundingBox(a,o,c,u,f,m,A,y,e),a=A,o=y}}const[s,i]=b(this,Ae,Oi).call(this);e[0]=De(e[0]-s,0,1),e[1]=De(e[1]-i,0,1),e[2]=De(e[2]+s,0,1),e[3]=De(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},$b=function(e){const[s,i]=b(this,Ae,Oi).call(this);p(this,ja,e);const[r,a]=b(this,Ae,Oi).call(this),[o,l]=[r-s,a-i],h=n(this,Ne);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class $u extends Bb{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:xt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new $u(this._viewParameters);return t.updateAll(this),t}}var Fu,zb;const uo=class uo extends gu{constructor(e){super({...e,name:"inkEditor"});g(this,Fu);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){xt.initialize(e,s),this._defaultDrawingOptions=new $u(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return J(this,"typesMap",new Map([[st.INK_THICKNESS,"stroke-width"],[st.INK_COLOR,"stroke"],[st.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new fw(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return gd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof Xp){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:u,opacity:f,borderStyle:{rawWidth:m},popupRef:A,richText:y,contentsObj:v,creationDate:w,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:X.INK,color:Array.from(u),thickness:m,opacity:f,paths:{points:o},boxes:null,pageIndex:E-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:A,richText:y,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new uu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return st.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=uo.getDefaultDrawingOptions({stroke:H.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:xt._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,Fu,zb).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};Fu=new WeakSet,zb=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},k(uo,"_type","ink"),k(uo,"_editorType",X.INK),k(uo,"_defaultDrawingOptions",null);let yp=uo;class Ap extends gd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Td=8,Ql=3;var $a,ut,wp,Ks,Gb,Vb,vp,tu,Wb,Xb,qb,Ep,Sp,Yb;class Mi{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const u=200,f=c.font=`${s} ${i} ${u}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:A,actualBoundingBoxAscent:y,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:E}=c.measureText(t),_=1.5,C=Math.ceil(Math.max(Math.abs(m)+Math.abs(A)||0,E)*_),x=Math.ceil(Math.max(Math.abs(y)+Math.abs(v)||u,Math.abs(w)+Math.abs(S)||u)*_);h=new OffscreenCanvas(C,x),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=f,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,x),c.fillStyle="black",c.fillText(t,C*(_-1)/2,x*(3-_)/2);const T=b(this,ut,Ep).call(this,c.getImageData(0,0,C,x).data),P=b(this,ut,qb).call(this,T),R=b(this,ut,Sp).call(this,P),D=b(this,ut,vp).call(this,T,C,x,R);return this.processDrawnLines({lines:{curves:D,width:C,height:x},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=b(this,ut,Yb).call(this,t),[h,c]=b(this,ut,Xb).call(this,a,o,l,Math.hypot(o,l)*n(this,$a).sigmaSFactor,n(this,$a).sigmaR,n(this,$a).kernelSize),u=b(this,ut,Sp).call(this,c),f=b(this,ut,vp).call(this,h,o,l,u);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,u=t.thickness??0,f=[],m=Math.min(e/h,s/c),A=m/e,y=m/s,v=[];for(const{points:S}of l){const E=a?b(this,ut,Wb).call(this,S):S;if(!E)continue;v.push(E);const _=E.length,C=new Float32Array(_),x=new Float32Array(3*(_===2?2:_-2));if(f.push({line:x,points:C}),_===2){C[0]=E[0]*A,C[1]=E[1]*y,x.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[T,P,R,D]=E;T*=A,P*=y,R*=A,D*=y,C.set([T,P,R,D],0),x.set([NaN,NaN,NaN,NaN,T,P],0);for(let M=4;M<_;M+=2){const I=C[M]=E[M]*A,G=C[M+1]=E[M+1]*y;x.set(U.createBezierPoints(T,P,R,D,I,G),(M-2)*3),[T,P,R,D]=[R,D,I,G]}}if(f.length===0)return null;const w=o?new Ap:new gd;return w.build(f,e,s,1,i,o?0:u,r),{outline:w,newCurves:v,areContours:o,thickness:u,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const E of t){l+=E.length;for(let _=2,C=E.length;_<C;_++){const x=E[_]-E[_-2];a=Math.min(a,x),o=Math.max(o,x)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,u=Td+Ql*c,f=new Uint32Array(u);let m=0;f[m++]=u*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,f[m++]=0,f[m++]=i,f[m++]=r,f[m++]=e?0:1,f[m++]=Math.max(0,Math.floor(s??0)),f[m++]=c,f[m++]=h.BYTES_PER_ELEMENT;for(const E of t)f[m++]=E.length-2,f[m++]=E[0],f[m++]=E[1];const A=new CompressionStream("deflate-raw"),y=A.writable.getWriter();await y.ready,y.write(f);const v=h.prototype.constructor;for(const E of t){const _=new v(E.length-2);for(let C=2,x=E.length;C<x;C++)_[C-2]=E[C]-E[C-2];y.write(_)}y.close();const w=await new Response(A.readable).arrayBuffer(),S=new Uint8Array(w);return Vg(S)}static async decompressSignature(t){try{const e=By(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const E of s)a||(a=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),a.set(E,o),o+=E.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],u=l[3],f=l[4]===0,m=l[5],A=l[6],y=l[7],v=[],w=(Td+Ql*A)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(y){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let E=0;E<A;E++){const _=l[Ql*E+Td],C=new Float32Array(_+2);v.push(C);for(let x=0;x<Ql-1;x++)C[x]=l[Ql*E+Td+x+1];for(let x=0;x<_;x++)C[x+2]=C[x]+S[o++]}return{areContours:f,thickness:m,outlines:v,width:c,height:u}}catch(e){return q(`decompressSignature: ${e}`),null}}}$a=new WeakMap,ut=new WeakSet,wp=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},Ks=new WeakMap,Gb=function(t,e,s,i,r,a,o){const l=b(this,ut,wp).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,u=n(this,Ks)[2*c],f=n(this,Ks)[2*c+1];if(t[(s+u)*e+(i+f)]!==0)return c}return-1},Vb=function(t,e,s,i,r,a,o){const l=b(this,ut,wp).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,u=n(this,Ks)[2*c],f=n(this,Ks)[2*c+1];if(t[(s+u)*e+(i+f)]!==0)return c}return-1},vp=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let u=1;u<e-1;u++){const f=c*e+u,m=a[f];if(m===0)continue;let A=c,y=u;if(m===1&&a[f-1]===0)o+=1,y-=1;else if(m>=1&&a[f+1]===0)o+=1,y+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const v=[u,c],w=y===u+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let E;for(const M of h)if(M.id===l){E=M;break}E?E.isHole?S.parent=w?E.parent:l:S.parent=w?l:E.parent:S.parent=w?l:0;const _=b(this,ut,Gb).call(this,a,e,c,u,A,y,0);if(_===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let C=n(this,Ks)[2*_],x=n(this,Ks)[2*_+1];const T=c+C,P=u+x;A=T,y=P;let R=c,D=u;for(;;){const M=b(this,ut,Vb).call(this,a,e,R,D,A,y,1);C=n(this,Ks)[2*M],x=n(this,Ks)[2*M+1];const I=R+C,G=D+x;v.push(G,I);const N=R*e+D;if(a[N+1]===0?a[N]=-o:a[N]===1&&(a[N]=o),I===c&&G===u&&R===T&&D===P){a[f]!==1&&(l=Math.abs(a[f]));break}else A=R,y=D,R=I,D=G}}}return h},tu=function(t,e,s,i){if(s-e<=4){for(let T=e;T<s-2;T+=2)i.push(t[T],t[T+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,u=l/h,f=c*a-u*r,m=l/o,A=1/h,y=Math.atan(m),v=Math.cos(y),w=Math.sin(y),S=A*(Math.abs(v)+Math.abs(w)),E=A*(1-S+S**2),_=Math.max(Math.atan(Math.abs(w+v)*E),Math.atan(Math.abs(w-v)*E));let C=0,x=e;for(let T=e+2;T<s-2;T+=2){const P=Math.abs(f-c*t[T+1]+u*t[T]);P>C&&(x=T,C=P)}C>(h*_)**2?(b(this,ut,tu).call(this,t,e,x+2,i),b(this,ut,tu).call(this,t,x,s,i)):i.push(r,a)},Wb=function(t){const e=[],s=t.length;return b(this,ut,tu).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},Xb=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let y=0;y<a;y++){const v=(y-h)**2;for(let w=0;w<a;w++)o[y*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),u=-2*r**2;for(let y=0;y<256;y++)c[y]=Math.exp(y**2/u);const f=t.length,m=new Uint8Array(f),A=new Uint32Array(256);for(let y=0;y<s;y++)for(let v=0;v<e;v++){const w=y*e+v,S=t[w];let E=0,_=0;for(let x=0;x<a;x++){const T=y+x-h;if(!(T<0||T>=s))for(let P=0;P<a;P++){const R=v+P-h;if(R<0||R>=e)continue;const D=t[T*e+R],M=o[x*a+P]*c[Math.abs(D-S)];E+=D*M,_+=M}}const C=m[w]=Math.round(E/_);A[C]++}return[m,A]},qb=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Ep=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];i=Math.max(i,h),r=Math.min(r,h)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Sp=function(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Yb=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,$a);let a=s,o=i;if(s>r||i>r){let f=s,m=i,A=Math.log2(Math.max(s,i)/r);const y=Math.floor(A);A=A===y?y-1:y;for(let w=0;w<A;w++){a=Math.ceil(f/2),o=Math.ceil(m/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,f,m,0,0,a,o),f=a,m=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,ut,Ep).call(this,c),a,o]},g(Mi,ut),g(Mi,$a,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(Mi,Ks,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class Yp extends Bb{constructor(){super(),super.updateProperties({fill:xt._defaultLineColor,"stroke-width":0})}clone(){const t=new Yp;return t.updateAll(this),t}}class Kp extends $u{constructor(t){super(t),super.updateProperties({stroke:xt._defaultLineColor,"stroke-width":1})}clone(){const t=new Kp(this._viewParameters);return t.updateAll(this),t}}var gr,Ri,mr,za;const Ze=class Ze extends gu{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,gr,!1);g(this,Ri,null);g(this,mr,null);g(this,za,null);this._willKeepAspectRatio=!0,p(this,mr,e.signatureData||null),p(this,Ri,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){xt.initialize(e,s),this._defaultDrawingOptions=new Yp,this._defaultDrawnSignatureOptions=new Kp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return J(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Ri)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,mr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,mr),{rawDims:{pageWidth:u,pageHeight:f},rotation:m}=this.parent.viewport,A=Mi.processDrawnLines({lines:r,pageWidth:u,pageHeight:f,rotation:m,innerMargin:Ze._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(A,c,l,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:n(this,Ri)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){p(this,za,e),this.addEditToolbar()}getUuid(){return n(this,za)}get description(){return n(this,Ri)}set description(e){p(this,Ri,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,mr),o=Math.max(r,a),l=Mi.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=p(this,mr,e);p(this,gr,l instanceof Ap),this.description=i;let h;n(this,gr)?h=Ze.getDefaultDrawingOptions():(h=Ze._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let u=s/c;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Mi.process(e,s,i,r,Ze._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Mi.extractContoursFromText(e,s,i,r,a,Ze._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Mi.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Ze._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Ze.getDefaultDrawingOptions():(this._drawingOptions=Ze._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,gr),color:[0,0,0],thickness:n(this,gr)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,za),a.isCopy=!0):a.lines=s,n(this,Ri)&&(a.accessibilityData={type:"Figure",alt:n(this,Ri)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Ap.deserialize(e,s,i,r,a,o):gd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return p(r,gr,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(r,za,e.uuid),r}};gr=new WeakMap,Ri=new WeakMap,mr=new WeakMap,za=new WeakMap,k(Ze,"_type","signature"),k(Ze,"_editorType",X.SIGNATURE),k(Ze,"_defaultDrawingOptions",null);let _p=Ze;var Mt,le,br,mn,yr,Nl,bn,Ga,ki,ms,Ol,lt,yh,Ah,eu,su,iu,xp,nu,Kb;class Cp extends xt{constructor(e){super({...e,name:"stampEditor"});g(this,lt);g(this,Mt,null);g(this,le,null);g(this,br,null);g(this,mn,null);g(this,yr,null);g(this,Nl,"");g(this,bn,null);g(this,Ga,!1);g(this,ki,null);g(this,ms,!1);g(this,Ol,!1);p(this,mn,e.bitmapUrl),p(this,yr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){xt.initialize(e,s)}static isHandlingMimeForPasting(e){return ou.includes(e)}static paste(e,s){s.pasteEditor({mode:X.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;n(this,le)&&(p(this,Mt,null),this._uiManager.imageManager.deleteId(n(this,le)),(e=n(this,bn))==null||e.remove(),p(this,bn,null),n(this,ki)&&(clearTimeout(n(this,ki)),p(this,ki,null))),super.remove()}rebuild(){if(!this.parent){n(this,le)&&b(this,lt,eu).call(this);return}super.rebuild(),this.div!==null&&(n(this,le)&&n(this,bn)===null&&b(this,lt,eu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,br)||n(this,Mt)||n(this,mn)||n(this,yr)||n(this,le)||n(this,Ga))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,Ga)||(n(this,Mt)?b(this,lt,su).call(this):b(this,lt,eu).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(p(this,le,i),r&&p(this,Mt,r),p(this,Ga,!1),b(this,lt,su).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,ki)!==null&&clearTimeout(n(this,ki)),p(this,ki,setTimeout(()=>{p(this,ki,null),b(this,lt,xp).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,Mt),o=new ei;let l=n(this,Mt),h=r,c=a,u=null;if(s){if(r>s||a>s){const T=Math.min(s/r,s/a);h=Math.floor(r*T),c=Math.floor(a*T)}u=document.createElement("canvas");const m=u.width=Math.ceil(h*o.sx),A=u.height=Math.ceil(c*o.sy);n(this,ms)||(l=b(this,lt,iu).call(this,m,A));const y=u.getContext("2d");y.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":jy.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,E=S*o.sx,_=S*o.sy,C=new OffscreenCanvas(E*2,_*2),x=C.getContext("2d");x.fillStyle=v,x.fillRect(0,0,E*2,_*2),x.fillStyle=w,x.fillRect(0,0,E,_),x.fillRect(E,_,E,_),y.fillStyle=y.createPattern(C,"repeat"),y.fillRect(0,0,m,A),y.drawImage(l,0,0,l.width,l.height,0,0,m,A)}let f=null;if(i){let m,A;if(o.symmetric&&l.width<e&&l.height<e)m=l.width,A=l.height;else if(l=n(this,Mt),r>e||a>e){const w=Math.min(e/r,e/a);m=Math.floor(r*w),A=Math.floor(a*w),n(this,ms)||(l=b(this,lt,iu).call(this,m,A))}const v=new OffscreenCanvas(m,A).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,m,A),f={width:m,height:A,data:v.getImageData(0,0,m,A).data}}return{canvas:u,width:h,height:c,imageData:f}}static async deserialize(e,s,i){var v;let r=null,a=!1;if(e instanceof ub){const{data:{rect:w,rotation:S,id:E,structParent:_,popupRef:C,richText:x,contentsObj:T,creationDate:P,modificationDate:R},container:D,parent:{page:{pageNumber:M}},canvas:I}=e;let G,N;I?(delete e.canvas,{id:G,bitmap:N}=i.imageManager.getFromCanvas(D.id,I),I.remove()):(a=!0,e._hasNoCanvas=!0);const W=((v=await s._structTree.getAriaAttributes(`${Bp}${E}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:X.STAMP,bitmapId:G,bitmap:N,pageIndex:M-1,rect:w.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:W},isSvg:!1,structParent:_,popupRef:C,richText:x,comment:(T==null?void 0:T.str)||null,creationDate:P,modificationDate:R}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:f,accessibilityData:m}=e;a?(i.addMissingCanvas(e.id,o),p(o,Ga,!0)):u&&i.imageManager.isValidId(u)?(p(o,le,u),h&&p(o,Mt,h)):p(o,mn,c),p(o,ms,f);const[A,y]=o.pageDimensions;return o.width=(l[2]-l[0])/A,o.height=(l[3]-l[1])/y,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e),p(o,Ol,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,le),isSvg:n(this,ms)});if(this.addComment(i),e)return i.bitmapUrl=b(this,lt,nu).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,lt,Kb).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,ms)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,le)))s.stamps.set(n(this,le),{area:o,serialized:i}),i.bitmap=b(this,lt,nu).call(this,!1);else if(n(this,ms)){const l=s.stamps.get(n(this,le));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,lt,nu).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Mt=new WeakMap,le=new WeakMap,br=new WeakMap,mn=new WeakMap,yr=new WeakMap,Nl=new WeakMap,bn=new WeakMap,Ga=new WeakMap,ki=new WeakMap,ms=new WeakMap,Ol=new WeakMap,lt=new WeakSet,yh=function(e,s=!1){if(!e){this.remove();return}p(this,Mt,e.bitmap),s||(p(this,le,e.id),p(this,ms,e.isSvg)),e.file&&p(this,Nl,e.file.name),b(this,lt,su).call(this)},Ah=function(){if(p(this,br,null),this._uiManager.enableWaiting(!1),!!n(this,bn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Mt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Mt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},eu=function(){if(n(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,le)).then(i=>b(this,lt,yh).call(this,i,!0)).finally(()=>b(this,lt,Ah).call(this));return}if(n(this,mn)){const i=n(this,mn);p(this,mn,null),this._uiManager.enableWaiting(!0),p(this,br,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,lt,yh).call(this,r)).finally(()=>b(this,lt,Ah).call(this)));return}if(n(this,yr)){const i=n(this,yr);p(this,yr,null),this._uiManager.enableWaiting(!0),p(this,br,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,lt,yh).call(this,r)).finally(()=>b(this,lt,Ah).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=ou.join(",");const s=this._uiManager._signal;p(this,br,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,lt,yh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,lt,Ah).call(this))),e.click()},su=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,Mt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const c=Math.min(o*r/s,o*a/i);s*=c,i*=c}this._uiManager.enableWaiting(!1);const l=p(this,bn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,lt,xp).call(this),n(this,Ol)||(this.parent.addUndoableEditor(this),p(this,Ol,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,Nl)&&this.div.setAttribute("aria-description",n(this,Nl)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},iu=function(e,s){const{width:i,height:r}=n(this,Mt);let a=i,o=r,l=n(this,Mt);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=u.transferToImageBitmap()}return l},xp=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new ei,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,bn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,ms)?n(this,Mt):b(this,lt,iu).call(this,o,l),u=h.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(c,0,0,c.width,c.height,0,0,o,l)},nu=function(e){if(e){if(n(this,ms)){const r=this._uiManager.imageManager.getSvgUrl(n(this,le));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,Mt),s.getContext("2d").drawImage(n(this,Mt),0,0),s.toDataURL()}if(n(this,ms)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*_n.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*_n.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,Mt),0,0,n(this,Mt).width,n(this,Mt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,Mt))},Kb=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},k(Cp,"_type","stamp"),k(Cp,"_editorType",X.STAMP);var Va,Bl,Ar,wr,yn,Ye,vr,Hl,Ul,Js,An,he,wn,Er,jl,z,Sr,St,Tp,Jb,ai,Pp,Rp,ru;const Us=class Us{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,St);g(this,Va);g(this,Bl,!1);g(this,Ar,null);g(this,wr,null);g(this,yn,null);g(this,Ye,new Map);g(this,vr,!1);g(this,Hl,!1);g(this,Ul,!1);g(this,Js,null);g(this,An,null);g(this,he,null);g(this,wn,null);g(this,Er,null);g(this,jl,-1);g(this,z);const u=[...n(Us,Sr).values()];if(!Us._initialized){Us._initialized=!0;for(const f of u)f.initialize(c,t)}t.registerEditorTypes(u),p(this,z,t),this.pageIndex=e,this.div=s,p(this,Va,r),p(this,Ar,a),this.viewport=h,p(this,he,l),this.drawLayer=o,this._structTree=i,n(this,z).addLayer(this)}get isEmpty(){return n(this,Ye).size===0}get isInvisible(){return this.isEmpty&&n(this,z).getMode()===X.NONE}updateToolbar(t){n(this,z).updateToolbar(t)}updateMode(t=n(this,z).getMode()){switch(b(this,St,ru).call(this),t){case X.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case X.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case X.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===X.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Us,Sr).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,he))==null?void 0:e.div)}setEditingState(t){n(this,z).setEditingState(t)}addCommands(t){n(this,z).addCommands(t)}cleanUndoStack(t){n(this,z).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=n(this,Ar))==null||e.div.classList.toggle("disabled",!t)}async enable(){var s;p(this,Ul,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Er))==null||s.abort(),p(this,Er,null);const t=new Set;for(const i of n(this,St,Tp))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,z).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,Ar);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,z).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}p(this,Ul,!1),n(this,z)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var s;if(p(this,Hl,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,he)&&!n(this,Er)){p(this,Er,new AbortController);const i=n(this,z).combinedSignal(n(this,Er));n(this,he).div.addEventListener("pointerdown",r=>{const{clientX:o,clientY:l,timeStamp:h}=r,c=n(this,jl);if(h-c>500){p(this,jl,h);return}p(this,jl,-1);const{classList:u}=this.div;u.toggle("getElements",!0);const f=document.elementsFromPoint(o,l);if(u.toggle("getElements",!1),!this.div.contains(f[0]))return;let m;const A=new RegExp(`^${vh}[0-9]+$`);for(const v of f)if(A.test(v.id)){m=v.id;break}if(!m)return;const y=n(this,Ye).get(m);(y==null?void 0:y.annotationElementId)===null&&(r.stopPropagation(),r.preventDefault(),y.dblclick(r))},{signal:i,capture:!0})}const t=n(this,Ar);if(t){const i=new Map,r=new Map;for(const o of n(this,St,Tp)){if(o.disableEditing(),!o.annotationElementId){o.updateFakeAnnotationElement(t);continue}if(o.serialize()!==null){i.set(o.annotationElementId,o);continue}else r.set(o.annotationElementId,o);(s=this.getEditableAnnotation(o.annotationElementId))==null||s.show(),o.remove()}const a=t.getEditableAnnotations();for(const o of a){const{id:l}=o.data;if(n(this,z).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=r.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=i.get(l),h&&(n(this,z).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,St,ru).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const i of n(Us,Sr).values())e.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,Hl,!1)}getEditableAnnotation(t){var e;return((e=n(this,Ar))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,z).getActive()!==t&&n(this,z).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,he))!=null&&t.div&&!n(this,wn)){p(this,wn,new AbortController);const e=n(this,z).combinedSignal(n(this,wn));n(this,he).div.addEventListener("pointerdown",b(this,St,Jb).bind(this),{signal:e}),n(this,he).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,he))!=null&&t.div&&n(this,wn)&&(n(this,wn).abort(),p(this,wn,null),n(this,he).div.classList.remove("highlighting"))}enableClick(){if(n(this,wr))return;p(this,wr,new AbortController);const t=n(this,z).combinedSignal(n(this,wr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=n(this,wr))==null||t.abort(),p(this,wr,null)}attach(t){n(this,Ye).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,z).isDeletedAnnotationElement(e)&&n(this,z).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,Ye).delete(t.id),(e=n(this,Va))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,Hl)&&t.annotationElementId&&n(this,z).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,z).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,z).addDeletedAnnotationElement(t.annotationElementId),xt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.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),n(this,z).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,Ul)),n(this,z).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,yn)&&(t._focusEventsAllowed=!1,p(this,yn,setTimeout(()=>{p(this,yn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,z)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,Va))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of n(this,Ye).values())if(e.uid===t)return e;return null}getNextId(){return n(this,z).getId()}combinedSignal(t){return n(this,z).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,St,ai))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,z).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,St,Rp).call(this),r=this.getNextId(),a=b(this,St,Pp).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,z),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Us,Sr).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,z)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),r=b(this,St,Pp).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,z),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,St,Rp).call(this),!0,t)}setSelected(t){n(this,z).setSelected(t)}toggleSelected(t){n(this,z).toggleSelected(t)}unselect(t){n(this,z).unselect(t)}pointerup(t){var i;const{isMac:e}=ce.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,vr)||(p(this,vr,!1),(i=n(this,St,ai))!=null&&i.isDrawer&&n(this,St,ai).supportMultipleDrawings))return;if(!n(this,Bl)){p(this,Bl,!0);return}const s=n(this,z).getMode();if(s===X.STAMP||s===X.SIGNATURE){n(this,z).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,z).getMode()===X.HIGHLIGHT&&this.enableTextSelection(),n(this,vr)){p(this,vr,!1);return}const{isMac:e}=ce.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,vr,!0),(i=n(this,St,ai))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,z).getActive();p(this,Bl,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,Js)){n(this,St,ai).startDrawing(this,n(this,z),!1,t);return}n(this,z).setCurrentDrawingSession(this),p(this,Js,new AbortController);const e=n(this,z).combinedSignal(n(this,Js));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,An,null),this.commitOrRemove())},{signal:e}),n(this,St,ai).startDrawing(this,n(this,z),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,An,e);return}n(this,An)&&setTimeout(()=>{var e;(e=n(this,An))==null||e.focus(),p(this,An,null)},0)}endDrawingSession(t=!1){return n(this,Js)?(n(this,z).setCurrentDrawingSession(null),n(this,Js).abort(),p(this,Js,null),p(this,An,null),n(this,St,ai).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,z).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,Js)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,Js)&&n(this,St,ai).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,z).getActive())==null?void 0:t.parent)===this&&(n(this,z).commitOrRemove(),n(this,z).setActiveEditor(null)),n(this,yn)&&(clearTimeout(n(this,yn)),p(this,yn,null));for(const s of n(this,Ye).values())(e=n(this,Va))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Ye).clear(),n(this,z).removeLayer(this)}render({viewport:t}){this.viewport=t,_r(this.div,t);for(const e of n(this,z).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){n(this,z).commitOrRemove(),b(this,St,ru).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,_r(this.div,{rotation:s}),e!==s)for(const i of n(this,Ye).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,z).viewParameters.realScale}};Va=new WeakMap,Bl=new WeakMap,Ar=new WeakMap,wr=new WeakMap,yn=new WeakMap,Ye=new WeakMap,vr=new WeakMap,Hl=new WeakMap,Ul=new WeakMap,Js=new WeakMap,An=new WeakMap,he=new WeakMap,wn=new WeakMap,Er=new WeakMap,jl=new WeakMap,z=new WeakMap,Sr=new WeakMap,St=new WeakSet,Tp=function(){return n(this,Ye).size!==0?n(this,Ye).values():n(this,z).getEditors(this.pageIndex)},Jb=function(t){n(this,z).unselectAll();const{target:e}=t;if(e===n(this,he).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&n(this,he).div.contains(e)){const{isMac:s}=ce.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,z).showAllEditors("highlight",!0,!0),n(this,he).div.classList.add("free"),this.toggleDrawing(),pu.startHighlighting(this,n(this,z).direction==="ltr",{target:n(this,he).div,x:t.x,y:t.y}),n(this,he).div.addEventListener("pointerup",()=>{n(this,he).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,z)._signal}),t.preventDefault()}},ai=function(){return n(Us,Sr).get(n(this,z).getMode())},Pp=function(t){const e=n(this,St,ai);return e?new e.prototype.constructor(t):null},Rp=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(r+o)/2-t,c=(a+l)/2-e,[u,f]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:u,offsetY:f}},ru=function(){for(const t of n(this,Ye).values())t.isEmpty()&&t.remove()},k(Us,"_initialized",!1),g(Us,Sr,new Map([lp,yp,Cp,pu,_p].map(t=>[t._editorType,t])));let mu=Us;var Qs,Oe,Wa,ld,Nu,Qb,Li,kp,Zb,Dp;const Jt=class Jt{constructor({pageIndex:t}){g(this,Li);g(this,Qs,null);g(this,Oe,new Map);g(this,Wa,new Map);this.pageIndex=t}setParent(t){if(!n(this,Qs)){p(this,Qs,t);return}if(n(this,Qs)!==t){if(n(this,Oe).size>0)for(const e of n(this,Oe).values())e.remove(),t.append(e);p(this,Qs,t)}}static get _svgFactory(){return J(this,"_svgFactory",new Ph)}draw(t,e=!1,s=!1){const i=Kt(Jt,ld)._++,r=b(this,Li,kp).call(this),a=Jt._svgFactory.createElement("defs");r.append(a);const o=Jt._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,Wa).set(i,o);const h=s?b(this,Li,Zb).call(this,a,l):null,c=Jt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Oe).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=Kt(Jt,ld)._++,i=b(this,Li,kp).call(this),r=Jt._svgFactory.createElement("defs");i.append(r);const a=Jt._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const u=Jt._svgFactory.createElement("mask");r.append(u),l=`mask_p${this.pageIndex}_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const f=Jt._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const m=Jt._svgFactory.createElement("use");u.append(m),m.setAttribute("href",`#${o}`),m.setAttribute("stroke","none"),m.setAttribute("fill","black"),m.setAttribute("fill-rule","nonzero"),m.classList.add("mask")}const h=Jt._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,Oe).set(s,i),s}finalizeDraw(t,e){n(this,Wa).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,Oe).get(t):t;if(o){if(s&&b(this,Li,Dp).call(this,o,s),i&&b(l=Jt,Nu,Qb).call(l,o,i),r){const{classList:h}=o;for(const[c,u]of Object.entries(r))h.toggle(c,u)}if(a){const c=o.firstChild.firstChild;b(this,Li,Dp).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Oe).get(t);s&&(n(e,Qs).append(s),n(this,Oe).delete(t),n(e,Oe).set(t,s))}remove(t){n(this,Wa).delete(t),n(this,Qs)!==null&&(n(this,Oe).get(t).remove(),n(this,Oe).delete(t))}destroy(){p(this,Qs,null);for(const t of n(this,Oe).values())t.remove();n(this,Oe).clear(),n(this,Wa).clear()}};Qs=new WeakMap,Oe=new WeakMap,Wa=new WeakMap,ld=new WeakMap,Nu=new WeakSet,Qb=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},Li=new WeakSet,kp=function(){const t=Jt._svgFactory.create(1,1,!0);return n(this,Qs).append(t),t.setAttribute("aria-hidden",!0),t},Zb=function(t,e){const s=Jt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=Jt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},Dp=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},g(Jt,Nu),g(Jt,ld,0);let bu=Jt;globalThis._pdfjsTestingUtils={HighlightOutliner:cp};globalThis.pdfjsLib={AbortException:Sn,AnnotationEditorLayer:mu,AnnotationEditorParamsType:st,AnnotationEditorType:X,AnnotationEditorUIManager:Cr,AnnotationLayer:qp,AnnotationMode:Di,AnnotationType:zt,applyOpacity:Kg,build:tb,ColorPicker:Th,createValidAbsoluteUrl:Fp,CSSConstants:Yg,DOMSVGFactory:Ph,DrawLayer:bu,FeatureTest:ce,fetchData:Vl,findContrastColor:Jg,getDocument:Gp,getFilenameFromUrl:Wg,getPdfFilenameFromUrl:Xg,getRGB:Wl,getUuid:Op,getXfaPageViewport:qg,GlobalWorkerOptions:Zs,ImageKind:wh,InvalidPDFException:au,isDataScheme:ud,isPdfFile:Uu,isValidExplicitDest:km,MathClamp:De,noContextMenu:vs,normalizeUnicode:Gg,OPS:$l,OutputScale:ei,PasswordResponses:$g,PDFDataRangeTransport:Vp,PDFDateString:_h,PDFWorker:zl,PermissionFlag:jg,PixelsPerInch:_n,RenderingCancelledException:Hu,renderRichText:Up,ResponseException:Eh,setLayerDimensions:_r,shadow:J,SignatureExtractor:Mi,stopEvent:Nt,SupportedImageMimeTypes:ou,TextLayer:xh,TouchManager:Ch,updateUrlHash:Np,Util:H,VerbosityLevel:hd,version:Zm,XfaLayer:Hp};const ty=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Sn,AnnotationEditorLayer:mu,AnnotationEditorParamsType:st,AnnotationEditorType:X,AnnotationEditorUIManager:Cr,AnnotationLayer:qp,AnnotationMode:Di,AnnotationType:zt,CSSConstants:Yg,ColorPicker:Th,DOMSVGFactory:Ph,DrawLayer:bu,FeatureTest:ce,GlobalWorkerOptions:Zs,ImageKind:wh,InvalidPDFException:au,MathClamp:De,OPS:$l,OutputScale:ei,PDFDataRangeTransport:Vp,PDFDateString:_h,PDFWorker:zl,PasswordResponses:$g,PermissionFlag:jg,PixelsPerInch:_n,RenderingCancelledException:Hu,ResponseException:Eh,SignatureExtractor:Mi,SupportedImageMimeTypes:ou,TextLayer:xh,TouchManager:Ch,Util:H,VerbosityLevel:hd,XfaLayer:Hp,applyOpacity:Kg,build:tb,createValidAbsoluteUrl:Fp,fetchData:Vl,findContrastColor:Jg,getDocument:Gp,getFilenameFromUrl:Wg,getPdfFilenameFromUrl:Xg,getRGB:Wl,getUuid:Op,getXfaPageViewport:qg,isDataScheme:ud,isPdfFile:Uu,isValidExplicitDest:km,noContextMenu:vs,normalizeUnicode:Gg,renderRichText:Up,setLayerDimensions:_r,shadow:J,stopEvent:Nt,updateUrlHash:Np,version:Zm},Symbol.toStringTag,{value:"Module"}));var Dg=Object.prototype.hasOwnProperty;function Mg(d,t,e){for(e of d.keys())if(po(e,t))return e}function po(d,t){var e,s,i;if(d===t)return!0;if(d&&t&&(e=d.constructor)===t.constructor){if(e===Date)return d.getTime()===t.getTime();if(e===RegExp)return d.toString()===t.toString();if(e===Array){if((s=d.length)===t.length)for(;s--&&po(d[s],t[s]););return s===-1}if(e===Set){if(d.size!==t.size)return!1;for(s of d)if(i=s,i&&typeof i=="object"&&(i=Mg(t,i),!i)||!t.has(i))return!1;return!0}if(e===Map){if(d.size!==t.size)return!1;for(s of d)if(i=s[0],i&&typeof i=="object"&&(i=Mg(t,i),!i)||!po(s[1],t.get(i)))return!1;return!0}if(e===ArrayBuffer)d=new Uint8Array(d),t=new Uint8Array(t);else if(e===DataView){if((s=d.byteLength)===t.byteLength)for(;s--&&d.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(d)){if((s=d.byteLength)===t.byteLength)for(;s--&&d[s]===t[s];);return s===-1}if(!e||typeof d=="object"){s=0;for(e in d)if(Dg.call(d,e)&&++s&&!Dg.call(t,e)||!(e in t)||!po(d[e],t[e]))return!1;return Object.keys(t).length===s}}return d!==d&&t!==t}function Xl(d){let t=!1;return{promise:new Promise((s,i)=>{d.then(r=>!t&&s(r)).catch(r=>!t&&i(r))}),cancel(){t=!0}}}const pw=["onCopy","onCut","onPaste"],gw=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],mw=["onFocus","onBlur"],bw=["onInput","onInvalid","onReset","onSubmit"],yw=["onLoad","onError"],Aw=["onKeyDown","onKeyPress","onKeyUp"],ww=["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],vw=["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],Ew=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],Sw=["onSelect"],_w=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],Cw=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],xw=["onScroll"],Tw=["onWheel"],Pw=["onAnimationStart","onAnimationEnd","onAnimationIteration"],Rw=["onTransitionEnd"],kw=["onToggle"],Dw=["onChange"],Mw=[...pw,...gw,...mw,...bw,...yw,...Aw,...ww,...vw,...Ew,...Sw,..._w,...Cw,...xw,...Tw,...Pw,...Rw,...Dw,...kw];function Jp(d,t){const e={};for(const s of Mw){const i=d[s];i&&(t?e[s]=(r=>i(r,t(s))):e[s]=i)}return e}var Lw=process.env.NODE_ENV==="production",nf="Invariant failed";function at(d,t){if(!d){if(Lw)throw new Error(nf);var e=typeof t=="function"?t():t,s=e?"".concat(nf,": ").concat(e):nf;throw new Error(s)}}var rf,Lg;function Iw(){if(Lg)return rf;Lg=1;var d=process.env.NODE_ENV!=="production",t=function(){};if(d){var e=function(i,r){var a=arguments.length;r=new Array(a>1?a-1:0);for(var o=1;o<a;o++)r[o-1]=arguments[o];var l=0,h="Warning: "+i.replace(/%s/g,function(){return r[l++]});typeof console<"u"&&console.error(h);try{throw new Error(h)}catch{}};t=function(s,i,r){var a=arguments.length;r=new Array(a>2?a-2:0);for(var o=2;o<a;o++)r[o-2]=arguments[o];if(i===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");s||e.apply(null,[i].concat(r))}}return rf=t,rf}var Fw=Iw();const we=Py(Fw),ey=$.createContext(null),Nw="noopener noreferrer nofollow";class Ow{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHash(){}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return at(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(t){at(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||Nw,t.target=s?"_blank":this.externalLinkTarget||""}goToDestination(t){return new Promise(e=>{at(this.pdfDocument,"PDF document not loaded."),at(t,"Destination is not specified."),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{at(Array.isArray(e),`"${e}" is not a valid destination array.`);const s=e[0];new Promise(i=>{at(this.pdfDocument,"PDF document not loaded."),s instanceof Object?this.pdfDocument.getPageIndex(s).then(r=>{i(r)}).catch(()=>{at(!1,`"${s}" is not a valid page reference.`)}):typeof s=="number"?i(s):at(!1,`"${s}" is not a valid destination reference.`)}).then(i=>{const r=i+1;at(this.pdfViewer,"PDF viewer is not initialized."),at(r>=1&&r<=this.pagesCount,`"${r}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:r})})})}goToPage(t){const e=t-1;at(this.pdfViewer,"PDF viewer is not initialized."),at(t>=1&&t<=this.pagesCount,`"${t}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}goToXY(){}cachePageRef(){}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}executeNamedAction(){}executeSetOCGState(){}isPageVisible(){return!0}isPageCached(){return!0}navigateTo(t){this.goToDestination(t)}}function go({children:d,type:t}){return ct.jsxRuntimeExports.jsx("div",{className:`react-pdf__message react-pdf__message--${t}`,children:d})}const Mp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};function Bw(d,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return d}}function qa(){return $.useReducer(Bw,{value:void 0,error:void 0})}const zu=typeof window<"u",sy=zu&&window.location.protocol==="file:";function iy(d){return typeof d<"u"}function oi(d){return iy(d)&&d!==null}function Hw(d){return typeof d=="string"}function Uw(d){return d instanceof ArrayBuffer}function jw(d){return at(zu,"isBlob can only be used in a browser environment"),d instanceof Blob}function Lp(d){return Hw(d)&&/^data:/.test(d)}function Ig(d){at(Lp(d),"Invalid data URI.");const[t="",e=""]=d.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function $w(){return zu&&window.devicePixelRatio||1}const ny="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function Fg(){we(!sy,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${ny}`)}function zw(){we(!sy,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${ny}`)}function xr(d){d!=null&&d.cancel&&d.cancel()}function Ip(d,t){return Object.defineProperty(d,"width",{get(){return this.getViewport({scale:t}).width},configurable:!0}),Object.defineProperty(d,"height",{get(){return this.getViewport({scale:t}).height},configurable:!0}),Object.defineProperty(d,"originalWidth",{get(){return this.getViewport({scale:1}).width},configurable:!0}),Object.defineProperty(d,"originalHeight",{get(){return this.getViewport({scale:1}).height},configurable:!0}),d}function ry(d){return d.name==="AbortException"||d.name==="RenderingCancelledException"}function Gw(d){return new Promise((t,e)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return e(new Error("Error while reading a file."));t(s.result)},s.onerror=i=>{if(!i.target)return e(new Error("Error while reading a file."));const{error:r}=i.target;if(!r)return e(new Error("Error while reading a file."));switch(r.code){case r.NOT_FOUND_ERR:return e(new Error("Error while reading a file: File not found."));case r.SECURITY_ERR:return e(new Error("Error while reading a file: Security error."));case r.ABORT_ERR:return e(new Error("Error while reading a file: Aborted."));default:return e(new Error("Error while reading a file."))}},s.readAsArrayBuffer(d)})}const{PDFDataRangeTransport:Vw}=ty,Ww=(d,t)=>{switch(t){case Mp.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");d(e);break}case Mp.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");d(e);break}}};function Ng(d){return typeof d=="object"&&d!==null&&("data"in d||"range"in d||"url"in d)}const Xw=$.forwardRef(function({children:t,className:e,error:s="Failed to load PDF file.",externalLinkRel:i,externalLinkTarget:r,file:a,inputRef:o,imageResourcesPath:l,loading:h="Loading PDF…",noData:c="No PDF file specified.",onItemClick:u,onLoadError:f,onLoadProgress:m,onLoadSuccess:A,onPassword:y=Ww,onSourceError:v,onSourceSuccess:w,options:S,renderMode:E,rotate:_,scale:C,...x},T){const[P,R]=qa(),{value:D,error:M}=P,[I,G]=qa(),{value:N,error:W}=I,O=$.useRef(new Ow),F=$.useRef([]),tt=$.useRef(void 0),it=$.useRef(void 0);a&&a!==tt.current&&Ng(a)&&(we(!po(a,tt.current),`File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),tt.current=a),S&&S!==it.current&&(we(!po(S,it.current),`Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),it.current=S);const ee=$.useRef({scrollPageIntoView:Rt=>{const{dest:Yt,pageNumber:Lt,pageIndex:Se=Lt-1}=Rt;if(u){u({dest:Yt,pageIndex:Se,pageNumber:Lt});return}const Qe=F.current[Se];if(Qe){Qe.scrollIntoView();return}we(!1,`An internal link leading to page ${Lt} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});$.useImperativeHandle(T,()=>({linkService:O,pages:F,viewer:ee}),[]);function Je(){w&&w()}function rt(){M&&(we(!1,M.toString()),v&&v(M))}function ht(){R({type:"RESET"})}$.useEffect(ht,[a,R]);const se=$.useCallback(async()=>{if(!a)return null;if(typeof a=="string")return Lp(a)?{data:Ig(a)}:(Fg(),{url:a});if(a instanceof Vw)return{range:a};if(Uw(a))return{data:a};if(zu&&jw(a))return{data:await Gw(a)};if(at(typeof a=="object","Invalid parameter in file, need either Uint8Array, string or a parameter object"),at(Ng(a),"Invalid parameter object: need either .data, .range or .url"),"url"in a&&typeof a.url=="string"){if(Lp(a.url)){const{url:Rt,...Yt}=a;return{data:Ig(Rt),...Yt}}Fg()}return a},[a]);$.useEffect(()=>{const Rt=Xl(se());return Rt.promise.then(Yt=>{R({type:"RESOLVE",value:Yt})}).catch(Yt=>{R({type:"REJECT",error:Yt})}),()=>{xr(Rt)}},[se,R]),$.useEffect(()=>{if(!(typeof D>"u")){if(D===!1){rt();return}Je()}},[D]);function de(){N&&(A&&A(N),F.current=new Array(N.numPages),O.current.setDocument(N))}function Ee(){W&&(we(!1,W.toString()),f&&f(W))}$.useEffect(function(){G({type:"RESET"})},[G,D]),$.useEffect(function(){if(!D)return;const Yt=S?{...D,...S}:D,Lt=Gp(Yt);m&&(Lt.onProgress=m),y&&(Lt.onPassword=y);const Se=Lt;return Se.promise.then(Qe=>{Se.destroyed||G({type:"RESOLVE",value:Qe})}).catch(Qe=>{Se.destroyed||G({type:"REJECT",error:Qe})}),()=>{Se.destroy()}},[S,G,D]),$.useEffect(()=>{if(!(typeof N>"u")){if(N===!1){Ee();return}de()}},[N]),$.useEffect(function(){O.current.setViewer(ee.current),O.current.setExternalLinkRel(i),O.current.setExternalLinkTarget(r)},[i,r]);const wt=$.useCallback((Rt,Yt)=>{F.current[Rt]=Yt},[]),Os=$.useCallback(Rt=>{delete F.current[Rt]},[]),ii=$.useMemo(()=>({imageResourcesPath:l,linkService:O.current,onItemClick:u,pdf:N,registerPage:wt,renderMode:E,rotate:_,scale:C,unregisterPage:Os}),[l,u,N,wt,E,_,C,Os]),Ii=$.useMemo(()=>Jp(x,()=>N),[x,N]);function Me(){function Rt(Lt){return!!(Lt!=null&&Lt.pdf)}if(!Rt(ii))throw new Error("pdf is undefined");const Yt=typeof t=="function"?t(ii):t;return ct.jsxRuntimeExports.jsx(ey.Provider,{value:ii,children:Yt})}function Tt(){return a?N==null?ct.jsxRuntimeExports.jsx(go,{type:"loading",children:typeof h=="function"?h():h}):N===!1?ct.jsxRuntimeExports.jsx(go,{type:"error",children:typeof s=="function"?s():s}):Me():ct.jsxRuntimeExports.jsx(go,{type:"no-data",children:typeof c=="function"?c():c})}return ct.jsxRuntimeExports.jsx("div",{className:Gl("react-pdf__Document",e),ref:o,...Ii,children:Tt()})}),ay=$.createContext(null);class qw{constructor({num:t,gen:e}){this.num=t,this.gen=e}toString(){let t=`${this.num}R`;return this.gen!==0&&(t+=this.gen),t}}function af(d){const t=$.useRef(void 0),e=t.current;return iy(e)?()=>e:()=>{const s=d();return t.current=s,s}}function ql(){return $.useContext(ey)}function oy(){return $.useContext(ay)}function ly(d){const t=ql(),e=oy();at(e,"Unable to find Outline context.");const s={...t,...e,...d},{item:i,linkService:r,onItemClick:a,pdf:o,...l}=s;at(o,"Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.");const h=af(()=>typeof i.dest=="string"?o.getDestination(i.dest):i.dest),c=af(async()=>{const A=await h();if(!A)throw new Error("Destination not found.");const[y]=A;return o.getPageIndex(new qw(y))}),u=af(async()=>await c()+1);function f(A){A.preventDefault(),at(a||r,"Either onItemClick callback or linkService must be defined in order to navigate to an outline item."),a?Promise.all([h(),c(),u()]).then(([y,v,w])=>{a({dest:y,pageIndex:v,pageNumber:w})}):r&&r.goToDestination(i.dest)}function m(){if(!i.items||!i.items.length)return null;const{items:A}=i;return ct.jsxRuntimeExports.jsx("ul",{children:A.map((y,v)=>ct.jsxRuntimeExports.jsx(ly,{item:y,pdf:o,...l},typeof y.dest=="string"?y.dest:v))})}return ct.jsxRuntimeExports.jsxs("li",{children:[ct.jsxRuntimeExports.jsx("a",{href:"#",onClick:f,children:i.title}),m()]})}function Yw(d){const e={...ql(),...d},{className:s,inputRef:i,onItemClick:r,onLoadError:a,onLoadSuccess:o,pdf:l,...h}=e;at(l,"Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.");const[c,u]=qa(),{value:f,error:m}=c;function A(){typeof f>"u"||f===!1||o&&o(f)}function y(){m&&(we(!1,m.toString()),a&&a(m))}$.useEffect(function(){u({type:"RESET"})},[u,l]),$.useEffect(function(){const _=Xl(l.getOutline()),C=_;return _.promise.then(x=>{u({type:"RESOLVE",value:x})}).catch(x=>{u({type:"REJECT",error:x})}),()=>xr(C)},[u,l]),$.useEffect(()=>{if(f!==void 0){if(f===!1){y();return}A()}},[f]);const v=$.useMemo(()=>({onItemClick:r}),[r]),w=$.useMemo(()=>Jp(h,()=>f),[h,f]);if(!f)return null;function S(){return f?ct.jsxRuntimeExports.jsx("ul",{children:f.map((E,_)=>ct.jsxRuntimeExports.jsx(ly,{item:E,pdf:l},typeof E.dest=="string"?E.dest:_))}):null}return ct.jsxRuntimeExports.jsx("div",{className:Gl("react-pdf__Outline",s),ref:i,...w,children:ct.jsxRuntimeExports.jsx(ay.Provider,{value:v,children:S()})})}function hy(){for(var d=[],t=0;t<arguments.length;t++)d[t]=arguments[t];var e=d.filter(Boolean);if(e.length<=1){var s=e[0];return s||null}return function(r){for(var a=0,o=e;a<o.length;a++){var l=o[a];typeof l=="function"?l(r):l&&(l.current=r)}}}const cy=$.createContext(null);function md(){return $.useContext(cy)}function Kw(){const d=ql(),t=md();at(t,"Unable to find Page context.");const e={...d,...t},{filterAnnotations:s,imageResourcesPath:i,linkService:r,onGetAnnotationsError:a,onGetAnnotationsSuccess:o,onRenderAnnotationLayerError:l,onRenderAnnotationLayerSuccess:h,page:c,pdf:u,renderForms:f,rotate:m,scale:A=1}=e;at(u,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),at(c,"Attempted to load page annotations, but no page was specified."),at(r,"Attempted to load page annotations, but no linkService was specified.");const[y,v]=qa(),{value:w,error:S}=y,E=$.useRef(null);we(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function _(){w&&o&&o(w)}function C(){S&&(we(!1,S.toString()),a&&a(S))}$.useEffect(function(){v({type:"RESET"})},[v,c]),$.useEffect(function(){if(!c)return;const D=Xl(c.getAnnotations()),M=D;return D.promise.then(I=>{v({type:"RESOLVE",value:I})}).catch(I=>{v({type:"REJECT",error:I})}),()=>{xr(M)}},[v,c]),$.useEffect(()=>{if(w!==void 0){if(w===!1){C();return}_()}},[w]);function x(){h&&h()}function T(R){we(!1,`${R}`),l&&l(R)}const P=$.useMemo(()=>c.getViewport({scale:A,rotation:m}),[c,m,A]);return $.useEffect(function(){if(!u||!c||!r||!w)return;const{current:D}=E;if(!D)return;const M=P.clone({dontFlip:!0}),I={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,annotationStorage:u.annotationStorage,commentManager:null,div:D,l10n:null,linkService:r,page:c,structTreeLayer:null,viewport:M},G={annotations:s?s({annotations:w}):w,annotationStorage:u.annotationStorage,div:D,imageResourcesPath:i,linkService:r,page:c,renderForms:f,viewport:M};D.innerHTML="";try{new qp(I).render(G),x()}catch(N){T(N)}return()=>{}},[w,s,i,r,c,u,f,P]),ct.jsxRuntimeExports.jsx("div",{className:Gl("react-pdf__Page__annotations","annotationLayer"),ref:E})}const dy={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Jw=/^H(\d+)$/;function Qw(d){return d in dy}function Gu(d){return"children"in d}function uy(d){return Gu(d)?d.children.length===1&&0 in d.children&&"id"in d.children[0]:!1}function Zw(d){const t={};if(Gu(d)){const{role:e}=d,s=e.match(Jw);if(s)t.role="heading",t["aria-level"]=Number(s[1]);else if(Qw(e)){const i=dy[e];i&&(t.role=i)}}return t}function fy(d){const t={};if(Gu(d)){if(d.alt!==void 0&&(t["aria-label"]=d.alt),d.lang!==void 0&&(t.lang=d.lang),uy(d)){const[e]=d.children;if(e){const s=fy(e);return{...t,...s}}}}else"id"in d&&(t["aria-owns"]=d.id);return t}function tv(d){return d?{...Zw(d),...fy(d)}:null}function py({className:d,node:t}){const e=$.useMemo(()=>tv(t),[t]),s=$.useMemo(()=>!Gu(t)||uy(t)?null:t.children.map((i,r)=>ct.jsxRuntimeExports.jsx(py,{node:i},r)),[t]);return ct.jsxRuntimeExports.jsx("span",{className:d,...e,children:s})}function ev(){const d=md();at(d,"Unable to find Page context.");const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=d,[s,i]=qa(),{value:r,error:a}=s,{customTextRenderer:o,page:l}=d;function h(){r&&e&&e(r)}function c(){a&&(we(!1,a.toString()),t&&t(a))}return $.useEffect(function(){i({type:"RESET"})},[i,l]),$.useEffect(function(){if(o||!l)return;const f=Xl(l.getStructTree()),m=f;return f.promise.then(A=>{i({type:"RESOLVE",value:A})}).catch(A=>{i({type:"REJECT",error:A})}),()=>xr(m)},[o,l,i]),$.useEffect(()=>{if(r!==void 0){if(r===!1){c();return}h()}},[r]),r?ct.jsxRuntimeExports.jsx(py,{className:"react-pdf__Page__structTree structTree",node:r}):null}const Og=Di;function sv(d){const t=md();at(t,"Unable to find Page context.");const e={...t,...d},{_className:s,canvasBackground:i,devicePixelRatio:r=$w(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:c,pageColors:u,rotate:f,scale:m}=e,{canvasRef:A}=d;at(l,"Attempted to render page canvas, but no page was specified.");const y=$.useRef(null);function v(){l&&o&&o(Ip(l,m))}function w(C){ry(C)||(we(!1,C.toString()),a&&a(C))}const S=$.useMemo(()=>l.getViewport({scale:m*r,rotation:f}),[r,l,f,m]),E=$.useMemo(()=>l.getViewport({scale:m,rotation:f}),[l,f,m]);$.useEffect(function(){if(!l)return;l.cleanup();const{current:x}=y;if(!x)return;x.width=S.width,x.height=S.height,x.style.width=`${Math.floor(E.width)}px`,x.style.height=`${Math.floor(E.height)}px`,x.style.visibility="hidden";const T={annotationMode:h?Og.ENABLE_FORMS:Og.ENABLE,canvas:x,canvasContext:x.getContext("2d",{alpha:!1}),pageColors:u,viewport:S};i&&(T.background=i);const P=l.render(T),R=P;return P.promise.then(()=>{x.style.visibility="",v()}).catch(w),()=>xr(R)},[i,l,u,h,S,E]);const _=$.useCallback(()=>{const{current:C}=y;C&&(C.width=0,C.height=0)},[]);return $.useEffect(()=>_,[_]),ct.jsxRuntimeExports.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:hy(A,y),style:{display:"block",userSelect:"none"},children:c?ct.jsxRuntimeExports.jsx(ev,{}):null})}function iv(d){return"str"in d}const nv=new Set(["base","embed","iframe","link","meta","object","script","style","template"]),rv=new Set(["action","formaction","href","poster","src","xlink:href"]);function av(d){let t="";for(const e of d){const s=e.charCodeAt(0);s<=32||s===127||(t+=e.toLowerCase())}return t.startsWith("javascript:")||t.startsWith("vbscript:")}function ov(d){return d.nodeType===Node.ELEMENT_NODE}function gy(d){return ov(d)&&d instanceof HTMLElement}function lv(d){return gy(d)&&nv.has(d.tagName.toLowerCase())}function hv(d){const t=document.createElement(d.tagName.toLowerCase());return Array.from(d.attributes).forEach(e=>{const s=e.name.toLowerCase();s.startsWith("on")||s==="srcdoc"||rv.has(s)&&av(e.value)||t.setAttribute(e.name,e.value)}),Array.from(d.childNodes).forEach(e=>{t.append(my(e))}),t}function my(d){var t;return gy(d)&&!lv(d)?hv(d):document.createTextNode((t=d.textContent)!==null&&t!==void 0?t:"")}function cv(d,t){const e=document.createElement("template");e.innerHTML=t;const s=document.createDocumentFragment();Array.from(e.content.childNodes).forEach(i=>{s.append(my(i))}),d.replaceChildren(s)}function dv(){const d=md();at(d,"Unable to find Page context.");const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:r,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:c}=d;at(a,"Attempted to load page text content, but no page was specified.");const[u,f]=qa(),{value:m,error:A}=u,y=$.useRef(null);we(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function v(){m&&s&&s(m)}function w(){A&&(we(!1,A.toString()),e&&e(A))}$.useEffect(function(){f({type:"RESET"})},[a,f]),$.useEffect(function(){if(!a)return;const P=Xl(a.getTextContent()),R=P;return P.promise.then(D=>{f({type:"RESOLVE",value:D})}).catch(D=>{f({type:"REJECT",error:D})}),()=>xr(R)},[a,f]),$.useEffect(()=>{if(m!==void 0){if(m===!1){w();return}v()}},[m]);const S=$.useCallback(()=>{r&&r()},[r]),E=$.useCallback(T=>{ry(T)||(we(!1,T.toString()),i&&i(T))},[i]);function _(){const T=y.current;T&&T.classList.add("selecting")}function C(){const T=y.current;T&&T.classList.remove("selecting")}const x=$.useMemo(()=>a.getViewport({scale:c,rotation:h}),[a,h,c]);return $.useLayoutEffect(function(){if(!a||!m)return;const{current:P}=y;if(!P)return;P.innerHTML="";const R=a.streamTextContent({includeMarkedContent:!0}),D={container:P,textContentSource:R,viewport:x},M=new xh(D),I=M;return M.render().then(()=>{const G=document.createElement("div");G.className="endOfContent",P.append(G);const N=P.querySelectorAll('[role="presentation"]');if(t){let W=0;m.items.forEach((O,F)=>{if(!iv(O))return;const tt=N[W];if(!tt)return;const it=t({pageIndex:o,pageNumber:l,itemIndex:F,...O});cv(tt,it),W+=O.str&&O.hasEOL?2:1})}S()}).catch(E),()=>xr(I)},[t,E,S,a,o,l,m,x]),ct.jsxRuntimeExports.jsx("div",{className:Gl("react-pdf__Page__textContent","textLayer"),onMouseUp:C,onMouseDown:_,ref:y})}const Bg=1;function by(d){const e={...ql(),...d},{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:r,canvasRef:a,children:o,className:l,customRenderer:h,customTextRenderer:c,devicePixelRatio:u,error:f="Failed to load the page.",filterAnnotations:m,height:A,inputRef:y,loading:v="Loading page…",noData:w="No page specified.",onGetAnnotationsError:S,onGetAnnotationsSuccess:E,onGetStructTreeError:_,onGetStructTreeSuccess:C,onGetTextError:x,onGetTextSuccess:T,onLoadError:P,onLoadSuccess:R,onRenderAnnotationLayerError:D,onRenderAnnotationLayerSuccess:M,onRenderError:I,onRenderSuccess:G,onRenderTextLayerError:N,onRenderTextLayerSuccess:W,pageColors:O,pageIndex:F,pageNumber:tt,pdf:it,registerPage:ee,renderAnnotationLayer:Je=!0,renderForms:rt=!1,renderMode:ht="canvas",renderTextLayer:se=!0,rotate:de,scale:Ee=Bg,unregisterPage:wt,width:Os,...ii}=e,[Ii,Me]=qa(),{value:Tt,error:Rt}=Ii,Yt=$.useRef(null);at(it,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const Lt=oi(tt)?tt-1:F??null,Se=tt??(oi(F)?F+1:null),Qe=de??(Tt?Tt.rotate:null),Bs=$.useMemo(()=>{if(!Tt)return null;let Tn=1;const Ja=Ee??Bg;if(Os||A){const Pn=Tt.getViewport({scale:1,rotation:Qe});Os?Tn=Os/Pn.width:A&&(Tn=A/Pn.height)}return Ja*Tn},[A,Tt,Qe,Ee,Os]);$.useEffect(function(){return()=>{oi(Lt)&&i&&wt&&wt(Lt)}},[i,it,Lt,wt]);function yy(){if(R){if(!Tt||!Bs)return;R(Ip(Tt,Bs))}if(i&&ee){if(!oi(Lt)||!Yt.current)return;ee(Lt,Yt.current)}}function Ay(){Rt&&(we(!1,Rt.toString()),P&&P(Rt))}$.useEffect(function(){Me({type:"RESET"})},[Me,it,Lt]),$.useEffect(function(){if(!it||!Se)return;const Ja=Xl(it.getPage(Se)),Pn=Ja;return Ja.promise.then(Wu=>{Me({type:"RESOLVE",value:Wu})}).catch(Wu=>{Me({type:"REJECT",error:Wu})}),()=>xr(Pn)},[Me,it,Se]),$.useEffect(()=>{if(Tt!==void 0){if(Tt===!1){Ay();return}yy()}},[Tt,Bs]);const Vu=$.useMemo(()=>oi(Lt)&&Se&&oi(Qe)&&oi(Bs)?{_className:s,canvasBackground:r,customTextRenderer:c,devicePixelRatio:u,filterAnnotations:m,onGetAnnotationsError:S,onGetAnnotationsSuccess:E,onGetStructTreeError:_,onGetStructTreeSuccess:C,onGetTextError:x,onGetTextSuccess:T,onRenderAnnotationLayerError:D,onRenderAnnotationLayerSuccess:M,onRenderError:I,onRenderSuccess:G,onRenderTextLayerError:N,onRenderTextLayerSuccess:W,page:Tt,pageColors:O,pageIndex:Lt,pageNumber:Se,renderForms:rt,renderTextLayer:se,rotate:Qe,scale:Bs}:null,[s,r,c,u,m,S,E,_,C,x,T,D,M,I,G,N,W,Tt,O,Lt,Se,rt,se,Qe,Bs]),wy=$.useMemo(()=>Jp(ii,()=>Tt&&(Bs?Ip(Tt,Bs):void 0)),[ii,Tt,Bs]),bd=`${Lt}@${Bs}/${Qe}`;function vy(){switch(ht){case"custom":return at(h,'renderMode was set to "custom", but no customRenderer was passed.'),ct.jsxRuntimeExports.jsx(h,{},`${bd}_custom`);case"none":return null;case"canvas":default:return ct.jsxRuntimeExports.jsx(sv,{canvasRef:a},`${bd}_canvas`)}}function Ey(){return se?ct.jsxRuntimeExports.jsx(dv,{},`${bd}_text`):null}function Sy(){return Je?ct.jsxRuntimeExports.jsx(Kw,{},`${bd}_annotations`):null}function _y(){function Tn(Pn){return!!(Pn!=null&&Pn.page)}if(!Tn(Vu))throw new Error("page is undefined");const Ja=typeof o=="function"?o(Vu):o;return ct.jsxRuntimeExports.jsxs(cy.Provider,{value:Vu,children:[vy(),Ey(),Sy(),Ja]})}function Cy(){return Se?it===null||Tt===void 0||Tt===null?ct.jsxRuntimeExports.jsx(go,{type:"loading",children:typeof v=="function"?v():v}):it===!1||Tt===!1?ct.jsxRuntimeExports.jsx(go,{type:"error",children:typeof f=="function"?f():f}):_y():ct.jsxRuntimeExports.jsx(go,{type:"no-data",children:typeof w=="function"?w():w})}return ct.jsxRuntimeExports.jsx("div",{className:Gl(s,l),"data-page-number":Se,ref:hy(y,Yt),style:{"--scale-round-x":"1px","--scale-round-y":"1px","--scale-factor":"1","--user-unit":`${Bs}`,"--total-scale-factor":"calc(var(--scale-factor) * var(--user-unit))",backgroundColor:r||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"},...wy,children:Cy()})}function uv(d){const e={...ql(),...d},{className:s,linkService:i,onItemClick:r,pageIndex:a,pageNumber:o,pdf:l}=e;at(l,"Attempted to load a thumbnail, but no document was specified. Wrap <Thumbnail /> in a <Document /> or pass explicit `pdf` prop.");const h=oi(o)?o-1:a??null,c=o??(oi(a)?a+1:null);function u(y){y.preventDefault(),!(!oi(h)||!c)&&(at(r||i,"Either onItemClick callback or linkService must be defined in order to navigate to an outline item."),r?r({pageIndex:h,pageNumber:c}):i&&i.goToPage(c))}const{className:f,onItemClick:m,...A}=d;return ct.jsxRuntimeExports.jsx("a",{className:Gl("react-pdf__Thumbnail",s),href:c?"#":void 0,onClick:u,children:ct.jsxRuntimeExports.jsx(by,{...A,_className:"react-pdf__Thumbnail__page",_enableRegisterUnregisterPage:!1,renderAnnotationLayer:!1,renderTextLayer:!1})})}zw();Zs.workerSrc="pdf.worker.mjs";exports.Document=Xw;exports.Outline=Yw;exports.Page=by;exports.PasswordResponses=Mp;exports.Thumbnail=uv;exports.pdfjs=ty;exports.useDocumentContext=ql;exports.useOutlineContext=oy;exports.usePageContext=md;
13
- //# sourceMappingURL=index-miejqTjn.cjs.map
13
+ //# sourceMappingURL=index-BiA_tnaq.cjs.map