@av-pi-studio/web-client 0.0.116 → 0.0.118

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 (128) hide show
  1. package/README.md +15 -12
  2. package/dist/web/assets/BinaryFallbackViewer-6oStgFbx.js +1 -0
  3. package/dist/web/assets/ChatPanel-BVw71R5q.js +11 -0
  4. package/dist/web/assets/CodeView-DBvTM0BW.js +1 -0
  5. package/dist/web/assets/{DiffView-D1TsZBGe.js → DiffView-Bp1YwIcs.js} +1 -1
  6. package/dist/web/assets/FilePanel-Bl5ytI3U.js +1 -0
  7. package/dist/web/assets/HtmlViewer-D52zbW1I.js +1 -0
  8. package/dist/web/assets/ImageViewer-DyQNZCKd.js +1 -0
  9. package/dist/web/assets/MarkdownFileViewer-BZJbZEGK.js +1 -0
  10. package/dist/web/assets/ModelProvidersPanel-DoQ6F0J7.js +1 -0
  11. package/dist/web/assets/MoleculeViewerPanel-CUgDBSd_.js +1 -0
  12. package/dist/web/assets/PdfViewer-BHiGul5n.js +1 -0
  13. package/dist/web/assets/SaveFileButton-469govDl.js +1 -0
  14. package/dist/web/assets/SettingsDialog-D2rCwciZ.js +8 -0
  15. package/dist/web/assets/SkillsPanel-Bwa_B9KI.js +1 -0
  16. package/dist/web/assets/SkillsPanel-Cs4iUzys.css +1 -0
  17. package/dist/web/assets/StatusBadge-eoBBn7zF.js +1 -0
  18. package/dist/web/assets/{Switch-1I6AMAC7.js → Switch-DvBJf8Rd.js} +1 -1
  19. package/dist/web/assets/TerminalPanel-B8j4fo6Z.js +1 -0
  20. package/dist/web/assets/TextViewer-DNjD6up3.js +1 -0
  21. package/dist/web/assets/VideoViewer-BeiZJGIs.js +1 -0
  22. package/dist/web/assets/ViewersPanel-DbKljM62.js +1 -0
  23. package/dist/web/assets/{abnfDiagram-N423BO3Z-DQx_Q_du.js → abnfDiagram-N423BO3Z-CpfpOF_O.js} +1 -1
  24. package/dist/web/assets/{arc-NwFlaU6N.js → arc-DBTSI6_N.js} +1 -1
  25. package/dist/web/assets/{architectureDiagram-T3A2C74G-CG7FCMjZ.js → architectureDiagram-T3A2C74G-BSevfMW_.js} +1 -1
  26. package/dist/web/assets/{blockDiagram-VBNYF7ZC-D8Dt2XvX.js → blockDiagram-VBNYF7ZC-mjH_gzpo.js} +1 -1
  27. package/dist/web/assets/{c4Diagram-5PPSVZJV-6WjaBIv7.js → c4Diagram-5PPSVZJV-CKvGPw0r.js} +1 -1
  28. package/dist/web/assets/channel-DewxN4Jo.js +1 -0
  29. package/dist/web/assets/{chunk-2GRJ4B5K-D17AHR0R.js → chunk-2GRJ4B5K-DX9yxpY8.js} +1 -1
  30. package/dist/web/assets/{chunk-2Q5K7J3B-C9IyfEM4.js → chunk-2Q5K7J3B-CLN7DvaK.js} +1 -1
  31. package/dist/web/assets/{chunk-5RXB4S5H-V5UWp0VD.js → chunk-5RXB4S5H-_JxweRkX.js} +1 -1
  32. package/dist/web/assets/{chunk-5VM5RSS4-XEeU6W1F.js → chunk-5VM5RSS4-3BAvSy1_.js} +1 -1
  33. package/dist/web/assets/{chunk-6Q2QTUOP-C99sGYcg.js → chunk-6Q2QTUOP-DQLD88Lm.js} +1 -1
  34. package/dist/web/assets/{chunk-GF5L2VYU-DOVkSmJv.js → chunk-GF5L2VYU-D-1fx8P7.js} +1 -1
  35. package/dist/web/assets/{chunk-JWPE2WC7-DHn7mt7E.js → chunk-JWPE2WC7-C2fToatl.js} +1 -1
  36. package/dist/web/assets/{chunk-KBJHAD2P-DZ1cvEI3.js → chunk-KBJHAD2P-DHjSexvX.js} +1 -1
  37. package/dist/web/assets/{chunk-RYQCIY6F-BoE5aK7J.js → chunk-RYQCIY6F-DsVSVTjX.js} +1 -1
  38. package/dist/web/assets/{chunk-XXDRQBXY-va2-6IlH.js → chunk-XXDRQBXY-Csxxsn8g.js} +1 -1
  39. package/dist/web/assets/classDiagram-JCYQIIEL-YbS66O-E.js +1 -0
  40. package/dist/web/assets/classDiagram-v2-OCEON4UE-YbS66O-E.js +1 -0
  41. package/dist/web/assets/{cose-bilkent-JH36ORCC-Cr6PX_gX.js → cose-bilkent-JH36ORCC-DIVX_YPY.js} +1 -1
  42. package/dist/web/assets/{cynefin-VYW2F7L2-CqvughFy.js → cynefin-VYW2F7L2-fVS7Seyd.js} +1 -1
  43. package/dist/web/assets/{cynefinDiagram-MW4NZA55-Bj_6GLhZ.js → cynefinDiagram-MW4NZA55-krsTOg0x.js} +1 -1
  44. package/dist/web/assets/{dagre-VZM6K2ZE-CgOi1CPd.js → dagre-VZM6K2ZE-Byz_9-UR.js} +1 -1
  45. package/dist/web/assets/{diagram-7IWD3JNH-rQLPxuMo.js → diagram-7IWD3JNH-CAwWHICT.js} +1 -1
  46. package/dist/web/assets/{diagram-B4RE2ZJO-PJI4Buwu.js → diagram-B4RE2ZJO-zvv-V2co.js} +1 -1
  47. package/dist/web/assets/{diagram-LBJQPF4R-Cal1_yHP.js → diagram-LBJQPF4R-i5y2WTdZ.js} +1 -1
  48. package/dist/web/assets/{diagram-Q27KOJAE-BWo2xVP9.js → diagram-Q27KOJAE-B1inWemu.js} +1 -1
  49. package/dist/web/assets/{diagram-UB23O5K3-DV90Qcmx.js → diagram-UB23O5K3-Dh89SZOh.js} +1 -1
  50. package/dist/web/assets/{ebnfDiagram-BXEA7PRR-DKFZTIRm.js → ebnfDiagram-BXEA7PRR-su2ygatX.js} +1 -1
  51. package/dist/web/assets/{erDiagram-JOGREHBK-LX1ZeseQ.js → erDiagram-JOGREHBK-BbsgEzQn.js} +1 -1
  52. package/dist/web/assets/{flowDiagram-UKHOOZJN-Djz1ZNIJ.js → flowDiagram-UKHOOZJN-Chl_0-ag.js} +1 -1
  53. package/dist/web/assets/{ganttDiagram-PKOTCBZU-BffSzw5A.js → ganttDiagram-PKOTCBZU-CYMojHU0.js} +1 -1
  54. package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-Dj4HeSPG.js → gitGraphDiagram-DS77QQ5N-BZQF2UJa.js} +1 -1
  55. package/dist/web/assets/{graph-bitvlgYx.js → graph-q4AqDxwU.js} +1 -1
  56. package/dist/web/assets/{href-resolution-CSqTI9Vm.js → href-resolution-A_PcAhnr.js} +1 -1
  57. package/dist/web/assets/index-Dg0mhDS9.css +1 -0
  58. package/dist/web/assets/index-DjRqFIN0.js +19 -0
  59. package/dist/web/assets/{infoDiagram-6WML65LV-DlWDf94X.js → infoDiagram-6WML65LV-L2kKwrdb.js} +1 -1
  60. package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-CFJts585.js → ishikawaDiagram-WSZJBQD7-B-hdpT0j.js} +1 -1
  61. package/dist/web/assets/{journeyDiagram-NVQOT4AX-DOykXQ5K.js → journeyDiagram-NVQOT4AX-DtZbDU0g.js} +1 -1
  62. package/dist/web/assets/{kanban-definition-27J2QSJJ-D1TWwfVH.js → kanban-definition-27J2QSJJ-BNVi4euz.js} +1 -1
  63. package/dist/web/assets/{layout-CDBUU1vE.js → layout-ZLTTNfUo.js} +1 -1
  64. package/dist/web/assets/{linear-B_PoZzPq.js → linear-Dg9CPt0k.js} +1 -1
  65. package/dist/web/assets/markdown-lfaaW_Mn.js +5 -0
  66. package/dist/web/assets/{mermaid.core-IS9aUP88.js → mermaid.core-524tR-D2.js} +4 -4
  67. package/dist/web/assets/{mindmap-definition-FAOFIHXS-e6GML3xR.js → mindmap-definition-FAOFIHXS-CJKkZcYQ.js} +1 -1
  68. package/dist/web/assets/{ordinal-DW4V92iz.js → ordinal-B7gl1e82.js} +1 -1
  69. package/dist/web/assets/{pegDiagram-VL7TDLO6-l5AAajde.js → pegDiagram-VL7TDLO6-C29SbD0M.js} +1 -1
  70. package/dist/web/assets/{pieDiagram-7S7Q4E2Y-BJMl2q2D.js → pieDiagram-7S7Q4E2Y-BpeO9BuX.js} +1 -1
  71. package/dist/web/assets/{provider-auth-store-9hsJ07X1.js → provider-auth-store-CpmUGwuu.js} +1 -1
  72. package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-DKC1ILMK.js → quadrantDiagram-CIZ2JOQS-yU4K00QE.js} +1 -1
  73. package/dist/web/assets/{railroadDiagram-AXF67PYL-wXEBz91m.js → railroadDiagram-AXF67PYL-DIkSup17.js} +1 -1
  74. package/dist/web/assets/{requirementDiagram-LRYGKXZP-8AXE33_8.js → requirementDiagram-LRYGKXZP-DB5tgpS1.js} +1 -1
  75. package/dist/web/assets/{sankeyDiagram-W5VNT64P-BEMi273m.js → sankeyDiagram-W5VNT64P-DYPa3r0S.js} +1 -1
  76. package/dist/web/assets/{sequenceDiagram-SI44F4Z6-D2uxwHar.js → sequenceDiagram-SI44F4Z6-C_rD0zxP.js} +1 -1
  77. package/dist/web/assets/{sizeCapture-X5ZJPWSS-B7Hjo6Av.js → sizeCapture-X5ZJPWSS-DzC-Nn78.js} +1 -1
  78. package/dist/web/assets/{stateDiagram-OKZ733FA-EapYZet8.js → stateDiagram-OKZ733FA-DQdSURcD.js} +1 -1
  79. package/dist/web/assets/stateDiagram-v2-UEYNNEHI-BCmrjJ-P.js +1 -0
  80. package/dist/web/assets/{swimlanes-SLNWSIFB-OULFMW43.js → swimlanes-SLNWSIFB-BA-Oww3o.js} +2 -2
  81. package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-BtietnZ5.js +8 -0
  82. package/dist/web/assets/{timeline-definition-Z64GVDOM-HZ7n4Pcs.js → timeline-definition-Z64GVDOM-C7JXpk1W.js} +1 -1
  83. package/dist/web/assets/use-file-download-FoQrf961.js +1 -0
  84. package/dist/web/assets/{use-file-watch-CYQrRagj.js → use-file-watch-Th-A-3Ws.js} +1 -1
  85. package/dist/web/assets/{use-provider-auth-list-CPbr4xbh.js → use-provider-auth-list-D5pguVWm.js} +1 -1
  86. package/dist/web/assets/{vendor-dnd-CayJj8TC.js → vendor-dnd-vJGfGIIi.js} +1 -1
  87. package/dist/web/assets/{vendor-highlight-Ddi_n-Jh.js → vendor-highlight-DaCUEPaW.js} +1 -1
  88. package/dist/web/assets/{vendor-icons-Bh5CT32q.js → vendor-icons-CSCeICuX.js} +2 -2
  89. package/dist/web/assets/{vendor-markdown-DJUOT8ep.js → vendor-markdown-Bo-Xpsuy.js} +1 -1
  90. package/dist/web/assets/{vendor-molviewer-DeAF8d5d.js → vendor-molviewer-7FbONJs2.js} +1 -1
  91. package/dist/web/assets/vendor-overlays-DjMT65Ip.js +1 -0
  92. package/dist/web/assets/{vendor-pdfjs-BrYGnqfM.js → vendor-pdfjs-BSchhGel.js} +2 -2
  93. package/dist/web/assets/{vendor-query-i7fr__Xm.js → vendor-query-CDNPrdQ8.js} +1 -1
  94. package/dist/web/assets/{vendor-react-DQUAl2K8.js → vendor-react-Dka9ZH0B.js} +1 -1
  95. package/dist/web/assets/{vendor-DaF96HbP.js → vendor-z183l2lP.js} +6 -6
  96. package/dist/web/assets/{vennDiagram-T6HMQDX7-BIcLY6tu.js → vennDiagram-T6HMQDX7-C_y33Ta5.js} +1 -1
  97. package/dist/web/assets/{wardleyDiagram-T6FBY63Y-BrZ83jaD.js → wardleyDiagram-T6FBY63Y-gxOBkNAp.js} +1 -1
  98. package/dist/web/assets/{xychartDiagram-ELKLHX3M-C3Tsplob.js → xychartDiagram-ELKLHX3M-BEdGwPiU.js} +1 -1
  99. package/dist/web/index.html +9 -8
  100. package/package.json +5 -41
  101. package/dist/web/assets/BinaryFallbackViewer-CgqvcH7r.js +0 -1
  102. package/dist/web/assets/ChatPanel-DrY_su6H.js +0 -11
  103. package/dist/web/assets/CodeView-CLqXf_zq.js +0 -1
  104. package/dist/web/assets/FilePanel-D70tIhDP.js +0 -1
  105. package/dist/web/assets/HtmlViewer-DSjhzjwY.js +0 -1
  106. package/dist/web/assets/ImageViewer-5Up9iJJ7.js +0 -1
  107. package/dist/web/assets/MarkdownFileViewer-BtXDNRcG.js +0 -1
  108. package/dist/web/assets/ModelProvidersPanel-CEj669D0.js +0 -1
  109. package/dist/web/assets/MoleculeViewerPanel-BiSKuUKH.js +0 -1
  110. package/dist/web/assets/PdfViewer-FoRGVMMP.js +0 -1
  111. package/dist/web/assets/SettingsDialog-BduWeTtA.js +0 -8
  112. package/dist/web/assets/SkillsPanel-DFN65SoZ.js +0 -1
  113. package/dist/web/assets/SkillsPanel-DH-_EKrv.css +0 -1
  114. package/dist/web/assets/StatusBadge-BMKAPA9O.js +0 -1
  115. package/dist/web/assets/TerminalPanel-DN6tM7eR.js +0 -1
  116. package/dist/web/assets/TextViewer-Cu-49yJ_.js +0 -1
  117. package/dist/web/assets/VideoViewer-CD56-Rpo.js +0 -1
  118. package/dist/web/assets/ViewersPanel-CAoHz8Or.js +0 -1
  119. package/dist/web/assets/channel-BnCumRF3.js +0 -1
  120. package/dist/web/assets/classDiagram-JCYQIIEL-D2TYG8cH.js +0 -1
  121. package/dist/web/assets/classDiagram-v2-OCEON4UE-D2TYG8cH.js +0 -1
  122. package/dist/web/assets/index-CchwjcLZ.js +0 -19
  123. package/dist/web/assets/index-D0vOQcoX.css +0 -1
  124. package/dist/web/assets/markdown-2gm-29tf.js +0 -5
  125. package/dist/web/assets/stateDiagram-v2-UEYNNEHI-s953Nt6G.js +0 -1
  126. package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-DYHKzS9R.js +0 -8
  127. package/dist/web/assets/use-file-download-8zPww5m-.js +0 -1
  128. package/dist/web/assets/vendor-overlays-3MkedLFU.js +0 -1
@@ -1,4 +1,4 @@
1
- var KA=Object.defineProperty;var Nm=p=>{throw TypeError(p)};var qA=(p,t,e)=>t in p?KA(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var T=(p,t,e)=>qA(p,typeof t!="symbol"?t+"":t,e),mp=(p,t,e)=>t.has(p)||Nm("Cannot "+e);var n=(p,t,e)=>(mp(p,t,"read from private field"),e?e.call(p):t.get(p)),g=(p,t,e)=>t.has(p)?Nm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(p):t.set(p,e),u=(p,t,e,s)=>(mp(p,t,"write to private field"),s?s.call(p,e):t.set(p,e),e),b=(p,t,e)=>(mp(p,t,"access private method"),e);var yt=(p,t,e,s)=>({set _(i){u(p,t,i,e)},get _(){return n(p,t,s)}});const ps=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Ui=[1/0,1/0,-1/0,-1/0],na=new Float32Array(Ui),xp=[.001,0,0,.001,0,0],Fe="http://www.w3.org/2000/svg",fs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Dn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Yo="pdfjs_internal_id_",Ph="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},et={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},gb={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Qt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ac={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Et={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,RICHMEDIA:27},zo={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},du={ERRORS:0,WARNINGS:1,INFOS:5},ni={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},Oh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},mb={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Qf=du.WARNINGS;function QA(p){Number.isInteger(p)&&(Qf=p)}function JA(){return Qf}function Jf(p){Qf>=du.INFOS&&console.info(`Info: ${p}`)}function X(p){Qf>=du.WARNINGS&&console.warn(`Warning: ${p}`)}function st(p){throw new Error(p)}function Gt(p,t){p||st(t)}function ZA(p){switch(p==null?void 0:p.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function gm(p,t=null,e=null){if(!p)return null;if(e&&typeof p=="string"){if(e.addDefaultProtocol&&p.startsWith("www.")){const i=p.match(/\./g);(i==null?void 0:i.length)>=2&&(p=`http://${p}`)}if(e.tryConvertEncoding)try{p=s0(p)}catch{}}const s=t?URL.parse(p,t):URL.parse(p);return ZA(s)?s:null}function mm(p,t,e=!1){const s=URL.parse(p);return s?(s.hash=t,s.href):e&&gm(p,"http://example.com")?p.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Cp(p){return p.substring(p.lastIndexOf("/")+1)}function F(p,t,e,s=!1){return Object.defineProperty(p,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Bo=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class cf extends Bo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class bp extends Bo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class df extends Bo{constructor(t){super(t,"InvalidPDFException")}}class fc extends Bo{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class t0 extends Bo{constructor(t){super(t,"FormatError")}}class Fn extends Bo{constructor(t){super(t,"AbortException")}}function e0(p){(typeof p!="object"||(p==null?void 0:p.length)===void 0)&&st("Invalid argument for bytesToString");const t=p.length,e=8192;if(t<e)return String.fromCharCode.apply(null,p);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=p.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Zf(p){typeof p!="string"&&st("Invalid argument for stringToBytes");const t=p.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=p.charCodeAt(s)&255;return e}class ot{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return F(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return F(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return F(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return F(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return F(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return F(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),F(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return F(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",F(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return F(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var In,xu,_p;class I{static get hexNums(){return F(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}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 d=t[s+c],f=t[s+c+1];t[s+c]=d*i+f*a+l,t[s+c+1]=d*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],d=t[1],f=t[2],m=t[3];let y=i*c+l,A=y,w=i*f+l,v=w,S=o*d+h,E=S,x=o*m+h,C=x;if(r!==0||a!==0){const _=r*c,k=r*f,M=a*d,P=a*m;y+=M,v+=M,w+=P,A+=P,S+=_,C+=_,x+=k,E+=k}s[0]=Math.min(s[0],y,w,A,v),s[1]=Math.min(s[1],S,x,E,C),s[2]=Math.max(s[2],y,w,A,v),s[3]=Math.max(s[3],S,x,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,d=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||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,In,_p).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,In,_p).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)}}In=new WeakSet,xu=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const d=1-h,f=h*h,m=f*h,y=d*(d*(d*t+3*h*e)+3*f*s)+m*i,A=d*(d*(d*r+3*h*a)+3*f*o)+m*l;c[0]=Math.min(c[0],y),c[1]=Math.min(c[1],A),c[2]=Math.max(c[2],y),c[3]=Math.max(c[3],A)},_p=function(t,e,s,i,r,a,o,l,h,c,d,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,In,xu).call(this,t,e,s,i,r,a,o,l,-d/c,f);return}const m=c**2-4*d*h;if(m<0)return;const y=Math.sqrt(m),A=2*h;b(this,In,xu).call(this,t,e,s,i,r,a,o,l,(-c+y)/A,f),b(this,In,xu).call(this,t,e,s,i,r,a,o,l,(-c-y)/A,f)},g(I,In);function s0(p){return decodeURIComponent(escape(p))}let yp=null,Bm=null;function bb(p){return yp||(yp=/([\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,Bm=new Map([["ſt","ſt"]])),p.replaceAll(yp,(t,e,s)=>e?e.normalize("NFKC"):Bm.get(s))}function bm(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const p=new Uint8Array(32);return crypto.getRandomValues(p),e0(p)}function i0(p,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!p(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}const Ho=()=>[],tp=()=>new Map,uf=()=>Object.create(null),yb=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(p){return[...this].join(p)});function wt(p,t,e){return Math.min(Math.max(p,t),e)}class uu{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,d,f,m;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,f=0,m=1;break;case 90:c=0,d=1,f=1,m=0;break;case 270:c=0,d=-1,f=-1,m=0;break;case 0:c=1,d=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 y,A,w,v;c===0?(y=Math.abs(h-t[1])*s+r,A=Math.abs(l-t[0])*s+a,w=(t[3]-t[1])*s,v=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,A=Math.abs(h-t[1])*s+a,w=(t[2]-t[0])*s,v=(t[3]-t[1])*s),this.transform=[c*s,d*s,f*s,m*s,y-c*s*l-f*s*h,A-d*s*l-m*s*h],this.width=w,this.height=v}get rawDims(){const t=this.viewBox;return F(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 uu({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 I.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return I.applyInverseTransform(s,this.transform),s}}class pc{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(pc.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")}}const n0=/url\(|image-set\(/i,r0=/^on/i;var vc,Tp;class ep{static get _allowedHtmlElements(){return F(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return F(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return F(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return F(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return F(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}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:Object.hasOwn(o.attributes,"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||r0.test(l))&&!(i==="richText"&&!this._allowedRichTextAttributes.has(l)))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":if(i==="richText"){const c=this._allowedRichTextStyles;for(const[d,f]of Object.entries(h))c.has(d)&&!n0.test(f)&&(t.style[d]=f)}else Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&(r==null||r.addLinkAttributes(t,a.href,a.newWindow)),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f,m;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=b(this,vc,Tp).call(this,i.name,(d=i.attributes)==null?void 0:d.xmlns,r)??document.createElement("div");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 y=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=y}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const y=document.createTextNode(i.value);a.append(y),o&&pc.shouldBuildText(i.name)&&h.push(y)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[y,A,w]=c.at(-1);if(A+1===y.children.length){c.pop();continue}const v=y.children[++c.at(-1)[1]];if(v===null)continue;const{name:S}=v;if(S==="#text"){const x=document.createTextNode(v.value);h.push(x),w.append(x);continue}const E=b(this,vc,Tp).call(this,S,(f=v.attributes)==null?void 0:f.xmlns,r);if(E){if(w.append(E),v.attributes&&this.setAttributes({html:E,element:v,storage:e,intent:r,linkService:s}),((m=v.children)==null?void 0:m.length)>0)c.push([v,-1,E]);else if(v.value){const x=document.createTextNode(v.value);o&&pc.shouldBuildText(S)&&h.push(x),E.append(x)}}}for(const y of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.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}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:r}=t.attributes.style;return new uu({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}vc=new WeakSet,Tp=function(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===Fe&&this._allowedSvgElements.has(t)?document.createElementNS(Fe,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null},g(ep,vc);const ta=class ta{};T(ta,"CSS",96),T(ta,"PDF",72),T(ta,"PDF_TO_CSS_UNITS",ta.CSS/ta.PDF);let Rn=ta;async function sp(p,t="text"){if(oc(p,document.baseURI)){const e=await fetch(p);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",p,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class ip extends Bo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function fu(p){const t=p.length;let e=0;for(;e<t&&p[e].trim()==="";)e++;return p.substring(e,e+5).toLowerCase()==="data:"}function np(p){return typeof p=="string"&&/\.pdf$/i.test(p)}function Ab(p){return[p]=p.split(/[#?]/,1),Cp(p)}function wb(p,t="document.pdf"){if(typeof p!="string")return t;if(fu(p))return X('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})(p);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=Cp(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=Cp(s.pathname);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=h=>[...h].findLast(c=>r.test(c)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const{hash:o}=s;let l=-1;for(const{index:h}of o.matchAll(/\.pdf\b/gi))l=h;if(l>0){let h=l;for(;h>0&&!"/?#=".includes(o[h-1]);)h--;if(h<l)return i(o.slice(h,l+4))}}return t}var Gn;class Hm{constructor(){g(this,Gn,new Map);T(this,"times",[])}time(t){n(this,Gn).has(t)&&X(`Timer is already running for ${t}`),n(this,Gn).set(t,Date.now())}timeEnd(t){n(this,Gn).has(t)||X(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,Gn).get(t),end:Date.now()}),n(this,Gn).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
1
+ var KA=Object.defineProperty;var Nm=p=>{throw TypeError(p)};var qA=(p,t,e)=>t in p?KA(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var T=(p,t,e)=>qA(p,typeof t!="symbol"?t+"":t,e),mp=(p,t,e)=>t.has(p)||Nm("Cannot "+e);var n=(p,t,e)=>(mp(p,t,"read from private field"),e?e.call(p):t.get(p)),g=(p,t,e)=>t.has(p)?Nm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(p):t.set(p,e),u=(p,t,e,s)=>(mp(p,t,"write to private field"),s?s.call(p,e):t.set(p,e),e),b=(p,t,e)=>(mp(p,t,"access private method"),e);var yt=(p,t,e,s)=>({set _(i){u(p,t,i,e)},get _(){return n(p,t,s)}});function Qw(p){return new Worker("/assets/pdf.worker.min-ypFJvUNP.js",{type:"module",name:p==null?void 0:p.name})}const ps=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Ui=[1/0,1/0,-1/0,-1/0],na=new Float32Array(Ui),xp=[.001,0,0,.001,0,0],Fe="http://www.w3.org/2000/svg",fs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Dn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Yo="pdfjs_internal_id_",Ph="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},et={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},gb={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Qt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ac={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Et={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,RICHMEDIA:27},zo={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},du={ERRORS:0,WARNINGS:1,INFOS:5},ni={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},Oh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},mb={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Qf=du.WARNINGS;function QA(p){Number.isInteger(p)&&(Qf=p)}function JA(){return Qf}function Jf(p){Qf>=du.INFOS&&console.info(`Info: ${p}`)}function X(p){Qf>=du.WARNINGS&&console.warn(`Warning: ${p}`)}function st(p){throw new Error(p)}function Gt(p,t){p||st(t)}function ZA(p){switch(p==null?void 0:p.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function gm(p,t=null,e=null){if(!p)return null;if(e&&typeof p=="string"){if(e.addDefaultProtocol&&p.startsWith("www.")){const i=p.match(/\./g);(i==null?void 0:i.length)>=2&&(p=`http://${p}`)}if(e.tryConvertEncoding)try{p=s0(p)}catch{}}const s=t?URL.parse(p,t):URL.parse(p);return ZA(s)?s:null}function mm(p,t,e=!1){const s=URL.parse(p);return s?(s.hash=t,s.href):e&&gm(p,"http://example.com")?p.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Cp(p){return p.substring(p.lastIndexOf("/")+1)}function F(p,t,e,s=!1){return Object.defineProperty(p,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Bo=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class cf extends Bo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class bp extends Bo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class df extends Bo{constructor(t){super(t,"InvalidPDFException")}}class fc extends Bo{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class t0 extends Bo{constructor(t){super(t,"FormatError")}}class Fn extends Bo{constructor(t){super(t,"AbortException")}}function e0(p){(typeof p!="object"||(p==null?void 0:p.length)===void 0)&&st("Invalid argument for bytesToString");const t=p.length,e=8192;if(t<e)return String.fromCharCode.apply(null,p);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=p.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Zf(p){typeof p!="string"&&st("Invalid argument for stringToBytes");const t=p.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=p.charCodeAt(s)&255;return e}class ot{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return F(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return F(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return F(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return F(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return F(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return F(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),F(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return F(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",F(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return F(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var In,xu,_p;class I{static get hexNums(){return F(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}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 d=t[s+c],f=t[s+c+1];t[s+c]=d*i+f*a+l,t[s+c+1]=d*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],d=t[1],f=t[2],m=t[3];let y=i*c+l,A=y,w=i*f+l,v=w,S=o*d+h,E=S,x=o*m+h,C=x;if(r!==0||a!==0){const _=r*c,k=r*f,M=a*d,P=a*m;y+=M,v+=M,w+=P,A+=P,S+=_,C+=_,x+=k,E+=k}s[0]=Math.min(s[0],y,w,A,v),s[1]=Math.min(s[1],S,x,E,C),s[2]=Math.max(s[2],y,w,A,v),s[3]=Math.max(s[3],S,x,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,d=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||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,In,_p).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,In,_p).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)}}In=new WeakSet,xu=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const d=1-h,f=h*h,m=f*h,y=d*(d*(d*t+3*h*e)+3*f*s)+m*i,A=d*(d*(d*r+3*h*a)+3*f*o)+m*l;c[0]=Math.min(c[0],y),c[1]=Math.min(c[1],A),c[2]=Math.max(c[2],y),c[3]=Math.max(c[3],A)},_p=function(t,e,s,i,r,a,o,l,h,c,d,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,In,xu).call(this,t,e,s,i,r,a,o,l,-d/c,f);return}const m=c**2-4*d*h;if(m<0)return;const y=Math.sqrt(m),A=2*h;b(this,In,xu).call(this,t,e,s,i,r,a,o,l,(-c+y)/A,f),b(this,In,xu).call(this,t,e,s,i,r,a,o,l,(-c-y)/A,f)},g(I,In);function s0(p){return decodeURIComponent(escape(p))}let yp=null,Bm=null;function bb(p){return yp||(yp=/([\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,Bm=new Map([["ſt","ſt"]])),p.replaceAll(yp,(t,e,s)=>e?e.normalize("NFKC"):Bm.get(s))}function bm(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const p=new Uint8Array(32);return crypto.getRandomValues(p),e0(p)}function i0(p,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!p(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}const Ho=()=>[],tp=()=>new Map,uf=()=>Object.create(null),yb=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(p){return[...this].join(p)});function wt(p,t,e){return Math.min(Math.max(p,t),e)}class uu{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,d,f,m;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,f=0,m=1;break;case 90:c=0,d=1,f=1,m=0;break;case 270:c=0,d=-1,f=-1,m=0;break;case 0:c=1,d=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 y,A,w,v;c===0?(y=Math.abs(h-t[1])*s+r,A=Math.abs(l-t[0])*s+a,w=(t[3]-t[1])*s,v=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,A=Math.abs(h-t[1])*s+a,w=(t[2]-t[0])*s,v=(t[3]-t[1])*s),this.transform=[c*s,d*s,f*s,m*s,y-c*s*l-f*s*h,A-d*s*l-m*s*h],this.width=w,this.height=v}get rawDims(){const t=this.viewBox;return F(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 uu({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 I.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return I.applyInverseTransform(s,this.transform),s}}class pc{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(pc.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")}}const n0=/url\(|image-set\(/i,r0=/^on/i;var vc,Tp;class ep{static get _allowedHtmlElements(){return F(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return F(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return F(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return F(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return F(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}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:Object.hasOwn(o.attributes,"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||r0.test(l))&&!(i==="richText"&&!this._allowedRichTextAttributes.has(l)))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":if(i==="richText"){const c=this._allowedRichTextStyles;for(const[d,f]of Object.entries(h))c.has(d)&&!n0.test(f)&&(t.style[d]=f)}else Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&(r==null||r.addLinkAttributes(t,a.href,a.newWindow)),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f,m;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=b(this,vc,Tp).call(this,i.name,(d=i.attributes)==null?void 0:d.xmlns,r)??document.createElement("div");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 y=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=y}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const y=document.createTextNode(i.value);a.append(y),o&&pc.shouldBuildText(i.name)&&h.push(y)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[y,A,w]=c.at(-1);if(A+1===y.children.length){c.pop();continue}const v=y.children[++c.at(-1)[1]];if(v===null)continue;const{name:S}=v;if(S==="#text"){const x=document.createTextNode(v.value);h.push(x),w.append(x);continue}const E=b(this,vc,Tp).call(this,S,(f=v.attributes)==null?void 0:f.xmlns,r);if(E){if(w.append(E),v.attributes&&this.setAttributes({html:E,element:v,storage:e,intent:r,linkService:s}),((m=v.children)==null?void 0:m.length)>0)c.push([v,-1,E]);else if(v.value){const x=document.createTextNode(v.value);o&&pc.shouldBuildText(S)&&h.push(x),E.append(x)}}}for(const y of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.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}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:r}=t.attributes.style;return new uu({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}vc=new WeakSet,Tp=function(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===Fe&&this._allowedSvgElements.has(t)?document.createElementNS(Fe,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null},g(ep,vc);const ta=class ta{};T(ta,"CSS",96),T(ta,"PDF",72),T(ta,"PDF_TO_CSS_UNITS",ta.CSS/ta.PDF);let Rn=ta;async function sp(p,t="text"){if(oc(p,document.baseURI)){const e=await fetch(p);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",p,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class ip extends Bo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function fu(p){const t=p.length;let e=0;for(;e<t&&p[e].trim()==="";)e++;return p.substring(e,e+5).toLowerCase()==="data:"}function np(p){return typeof p=="string"&&/\.pdf$/i.test(p)}function Ab(p){return[p]=p.split(/[#?]/,1),Cp(p)}function wb(p,t="document.pdf"){if(typeof p!="string")return t;if(fu(p))return X('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})(p);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=Cp(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=Cp(s.pathname);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=h=>[...h].findLast(c=>r.test(c)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const{hash:o}=s;let l=-1;for(const{index:h}of o.matchAll(/\.pdf\b/gi))l=h;if(l>0){let h=l;for(;h>0&&!"/?#=".includes(o[h-1]);)h--;if(h<l)return i(o.slice(h,l+4))}}return t}var Gn;class Hm{constructor(){g(this,Gn,new Map);T(this,"times",[])}time(t){n(this,Gn).has(t)&&X(`Timer is already running for ${t}`),n(this,Gn).set(t,Date.now())}timeEnd(t){n(this,Gn).has(t)||X(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,Gn).get(t),end:Date.now()}),n(this,Gn).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
2
2
  `).join("")}}Gn=new WeakMap;function oc(p,t){const e=t?URL.parse(p,t):URL.parse(p);return/https?:/.test((e==null?void 0:e.protocol)??"")}function Us(p){p.preventDefault()}function Kt(p){p.preventDefault(),p.stopPropagation()}var Sc;class gc{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,Sc)||u(this,Sc,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,Sc).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 d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(a+=c,o+=d):h==="+"&&(a-=c,o-=d),new Date(Date.UTC(s,i,r,a,o,l))}}Sc=new WeakMap,g(gc,Sc);function Uo(p){if(p.startsWith("#")){const e=p.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(p.startsWith("rgb(")){const[e,s,i]=p.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,1]}if(p.startsWith("rgba(")){const e=p.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=p.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Rh(p){const t=Uo(p);return t?t.slice(0,3):(X(`Not a valid color format: "${p}"`),[0,0,0])}function a0(p){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of p.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;p.set(e,Rh(s))}t.remove()}function mt(p){const{a:t,b:e,c:s,d:i,e:r,f:a}=p.getTransform();return[t,e,s,i,r,a]}function ai(p){const{a:t,b:e,c:s,d:i,e:r,f:a}=p.getTransform().invertSelf();return[t,e,s,i,r,a]}function jr(p,t,e=!1,s=!0){if(t instanceof uu){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=p,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!e||t.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&p.setAttribute("data-main-rotation",t.rotation)}class bs{constructor(){const{pixelRatio:t}=bs;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=bs.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 ff=new Set(["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"]);class o0{static get isDarkMode(){var t;return F(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class vb{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(),F(this,"commentForegroundColor",Rh(s))}}function Sb(p,t){t=wt(t??1,0,1);const e=255*(1-t);return p.map(s=>Math.round(s*t+e))}function Um(p,t){const e=p[0]/255,s=p[1]/255,i=p[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 kp(p,t){const e=p[0],s=p[1],i=p[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 Pp(p){return p<=.03928?p/12.92:((p+.055)/1.055)**2.4}function Gm(p,t,e){kp(p,e),e.map(Pp);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];kp(t,e),e.map(Pp);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const $m=new Map;function Eb(p,t){const e=p[0]+p[1]*256+p[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=$m.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);Um(p,a);const o=i.subarray(6,9);Um(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]),Gm(a,o,r)<h){let c,d;l?(c=a[2],d=1):(c=0,d=a[2]);const f=.005;for(;d-c>f;){const m=a[2]=(c+d)/2;l===Gm(a,o,r)<h?c=m:d=m}a[2]=l?d:c}return kp(a,r),s=I.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),$m.set(e,s),s}function ym({html:p,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof p=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=p.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 ep.render({xfaHtml:p,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function xb(p){const t=new Path2D;if(!p)return t;for(let e=0,s=p.length;e<s;)switch(p[e++]){case Oh.moveTo:t.moveTo(p[e++],p[e++]);break;case Oh.lineTo:t.lineTo(p[e++],p[e++]);break;case Oh.curveTo:t.bezierCurveTo(p[e++],p[e++],p[e++],p[e++],p[e++],p[e++]);break;case Oh.quadraticCurveTo:t.quadraticCurveTo(p[e++],p[e++],p[e++],p[e++]);break;case Oh.closePath:t.closePath();break;default:X(`Unrecognized drawing path operator: ${p[e-1]}`);break}return t}var $n,zn,Ss,Es,Ec,Vn,Jo,Zo,xc,Sf,Cb,be,_b,Tb,Vo,Hh;const Wi=class Wi{constructor(t){g(this,be);g(this,$n,null);g(this,zn,null);g(this,Ss);g(this,Es,null);g(this,Ec,null);g(this,Vn,null);g(this,Jo,null);g(this,Zo,null);u(this,Ss,t),n(Wi,xc)||u(Wi,xc,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=u(this,$n,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,Ss)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Us,{signal:e}),t.addEventListener("pointerdown",b(Wi,Sf,Cb),{signal:e}));const s=u(this,Es,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,Ss).toolbarPosition;if(i){const{style:r}=t,a=n(this,Ss)._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,$n)}hide(){var t;n(this,$n).classList.add("hidden"),(t=n(this,zn))==null||t.hideDropdown()}show(){var t,e;n(this,$n).classList.remove("hidden"),(t=n(this,Ec))==null||t.shown(),(e=n(this,Vn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,Ss),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Wi,xc)[t]),b(this,be,Vo).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,Es).append(s)}async addAltText(t){const e=await t.render();b(this,be,Vo).call(this,e),n(this,Es).append(e,n(this,be,Hh)),u(this,Ec,t)}addComment(t,e=null){if(n(this,Vn))return;const s=t.renderForToolbar();if(!s)return;b(this,be,Vo).call(this,s);const i=u(this,Jo,n(this,be,Hh));e?(n(this,Es).insertBefore(s,e),n(this,Es).insertBefore(i,e)):n(this,Es).append(s,i),u(this,Vn,t),t.toolbar=this}addColorPicker(t){if(n(this,zn))return;u(this,zn,t);const e=t.renderButton();b(this,be,Vo).call(this,e),n(this,Es).append(e,n(this,be,Hh))}async addEditSignatureButton(t){const e=u(this,Zo,await t.renderEditButton(n(this,Ss)));e&&(b(this,be,Vo).call(this,e),n(this,Es).append(e,n(this,be,Hh)))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Vn))==null||e.removeToolbarCommentButton(),u(this,Vn,null),(s=n(this,Jo))==null||s.remove(),u(this,Jo,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const i=n(this,Es).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,Zo)&&(n(this,Zo).title=t)}remove(){var t;n(this,$n).remove(),(t=n(this,zn))==null||t.destroy(),u(this,zn,null)}};$n=new WeakMap,zn=new WeakMap,Ss=new WeakMap,Es=new WeakMap,Ec=new WeakMap,Vn=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,xc=new WeakMap,Sf=new WeakSet,Cb=function(t){t.stopPropagation()},be=new WeakSet,_b=function(t){n(this,Ss)._focusEventsAllowed=!1,Kt(t)},Tb=function(t){n(this,Ss)._focusEventsAllowed=!0,Kt(t)},Vo=function(t){const e=n(this,Ss)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,be,_b).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,be,Tb).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Us,{signal:e}),!0)},Hh=function(){const t=document.createElement("div");return t.className="divider",t},g(Wi,Sf),g(Wi,xc,null);let Mp=Wi;var Cc,ra,di,On,kb,Pb,Dp;class l0{constructor(t){g(this,On);g(this,Cc,null);g(this,ra,null);g(this,di);u(this,di,t)}show(t,e,s){const[i,r]=b(this,On,Pb).call(this,e,s),{style:a}=n(this,ra)||u(this,ra,b(this,On,kb).call(this));t.append(n(this,ra)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,ra).remove()}}Cc=new WeakMap,ra=new WeakMap,di=new WeakMap,On=new WeakSet,kb=function(){const t=u(this,ra,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=n(this,di).direction;const e=n(this,di)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Us,{signal:e});const s=u(this,Cc,document.createElement("div"));return s.className="buttons",t.append(s),n(this,di).hasCommentManager()&&b(this,On,Dp).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,di).commentSelection("floating_button")}),b(this,On,Dp).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,di).highlightSelection("floating_button")}),t},Pb=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]},Dp=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,di)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",Us,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,Cc).append(r)};const h0="2837668c-d334-48d1-ba74-aa7deba483da",Ap=Object.freeze({internal:h0});function Mb(p,t,e){for(const s of e)t.addEventListener(s,p[s].bind(p))}var aa,oa,tl,la;const ct=class ct{static initializeAndAddPointerId(t){(n(ct,oa)||u(ct,oa,new Set)).add(t)}static setPointer(t,e){n(ct,aa)||u(ct,aa,e),n(ct,la)??u(ct,la,t)}static setTimeStamp(t){u(ct,tl,t)}static isSamePointerId(t){return n(ct,aa)===t}static isSamePointerIdOrRemove(t){var e;return n(ct,aa)===t?!0:((e=n(ct,oa))==null||e.delete(t),!1)}static isSamePointerType(t){return n(ct,la)===t}static isInitializedAndDifferentPointerType(t){return n(ct,la)!==null&&!ct.isSamePointerType(t)}static isSameTimeStamp(t){return n(ct,tl)===t}static isUsingMultiplePointers(){var t;return((t=n(ct,oa))==null?void 0:t.size)>=1}static clearPointerType(){u(ct,la,null)}static clearPointerIds(){u(ct,aa,NaN),u(ct,oa,null)}static clearTimeStamp(){u(ct,tl,NaN)}};aa=new WeakMap,oa=new WeakMap,tl=new WeakMap,la=new WeakMap,g(ct,aa,NaN),g(ct,oa,null),g(ct,tl,NaN),g(ct,la,null);let we=ct;var Ef;class c0{constructor(){g(this,Ef,0)}get id(){return`${Ph}${yt(this,Ef)._++}`}}Ef=new WeakMap;var el,_c,ve,sl,Cu;const Mm=class Mm{constructor(){g(this,sl);g(this,el,bm());g(this,_c,0);g(this,ve,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Fe}"><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 F(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,sl,Cu).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,sl,Cu).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,sl,Cu).call(this,t,s)}async getFromId(t){n(this,ve)||u(this,ve,new Map);const e=n(this,ve).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,ve)||u(this,ve,new Map);let s=n(this,ve).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,el)}_${yt(this,_c)._++}`,refCounter:1,isSvg:!1},n(this,ve).set(t,s),n(this,ve).set(s.id,s),s}getSvgUrl(t){const e=n(this,ve).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,ve)||u(this,ve,new Map);const e=n(this,ve).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,el)}_`)}};el=new WeakMap,_c=new WeakMap,ve=new WeakMap,sl=new WeakSet,Cu=async function(t,e){n(this,ve)||u(this,ve,new Map);let s=n(this,ve).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,el)}_${yt(this,_c)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await sp(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Mm._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 d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=c});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){X(i),s=null}return n(this,ve).set(t,s),s&&n(this,ve).set(s.id,s),s};let Ip=Mm;var zt,jn,Tc,Mt;class d0{constructor(t=128){g(this,zt,[]);g(this,jn,!1);g(this,Tc);g(this,Mt,-1);u(this,Tc,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,jn))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,Mt)===-1){n(this,zt).length>0&&(n(this,zt).length=0),u(this,Mt,0),n(this,zt).push(l);return}if(a&&n(this,zt)[n(this,Mt)].type===r){o&&(l.undo=n(this,zt)[n(this,Mt)].undo),n(this,zt)[n(this,Mt)]=l;return}const h=n(this,Mt)+1;h===n(this,Tc)?n(this,zt).splice(0,1):(u(this,Mt,h),h<n(this,zt).length&&n(this,zt).splice(h)),n(this,zt).push(l)}undo(){if(n(this,Mt)===-1)return;u(this,jn,!0);const{undo:t,post:e}=n(this,zt)[n(this,Mt)];t(),e==null||e(),u(this,jn,!1),u(this,Mt,n(this,Mt)-1)}redo(){if(n(this,Mt)<n(this,zt).length-1){u(this,Mt,n(this,Mt)+1),u(this,jn,!0);const{cmd:t,post:e}=n(this,zt)[n(this,Mt)];t(),e==null||e(),u(this,jn,!1)}}hasSomethingToUndo(){return n(this,Mt)!==-1}hasSomethingToRedo(){return n(this,Mt)<n(this,zt).length-1}cleanType(t){if(n(this,Mt)!==-1){for(let e=n(this,Mt);e>=0;e--)if(n(this,zt)[e].type!==t){n(this,zt).splice(e+1,n(this,Mt)-e),u(this,Mt,e);return}n(this,zt).length=0,u(this,Mt,-1)}}destroy(){u(this,zt,null)}}zt=new WeakMap,jn=new WeakMap,Tc=new WeakMap,Mt=new WeakMap;var Ih,Db,Ib;const Ge=class Ge{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=ot.platform;for(const[i,r,a={}]of t){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let h=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(h=l.slice(4))}const[c,d]=b(s=Ge,Ih,Db).call(s,h);c!==null&&this.callbacks.getOrInsertComputed(c,Ho).push({callback:r,options:a,modifiers:d})}}}exec(t,e){var c;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const d=b(c=Ge,Ih,Ib).call(c,e.code);if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const i=(e.altKey?Ge.ALT:0)|(e.ctrlKey?Ge.CTRL:0)|(e.metaKey?Ge.META:0)|(e.shiftKey?Ge.SHIFT:0),r=s.find(d=>d.modifiers===i);if(!r)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:h=null}}=r;h&&!h(t,e)||(a.bind(t,...l,e)(),o||Kt(e))}};Ih=new WeakSet,Db=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=Ge[r];if(a){s|=a;continue}if(e!==null){X(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&X(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},Ib=function(t){var s;const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?((s=e[1])==null?void 0:s.toLowerCase())??e[2]:null},g(Ge,Ih),T(Ge,"ALT",1),T(Ge,"CTRL",2),T(Ge,"META",4),T(Ge,"SHIFT",8);let Ro=Ge;const xf=class xf{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return a0(t),F(this,"_colors",t)}convert(t){const e=Rh(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 xf._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?I.makeHexColor(...e):t}};T(xf,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Lp=xf;var il,Je,nl,xt,Dt,rl,al,ol,Se,ll,xs,ne,Wn,Xn,Yn,Kn,ui,Cs,ha,kc,Pc,hl,Mc,fi,qn,cl,Qn,pi,Cf,Yi,dl,Dc,Jn,ca,ul,Zn,Ic,jt,dt,Ki,tr,er,Lc,fl,Fc,sr,gi,qi,Rc,Oc,_s,R,_u,Fp,Lb,Fb,Uh,Rb,Ob,Nb,Rp,Bb,Hb,Ub,Gb,Te,Vi,$b,zb,Op,Vb,Gh,Np;const Ko=class Ko{constructor(t,e,s,i,r,a,o,l,h,c,d,f,m,y,A,w){g(this,R);g(this,il,new AbortController);g(this,Je,null);g(this,nl,null);g(this,xt,new Map);g(this,Dt,new Map);g(this,rl,null);g(this,al,null);g(this,ol,null);g(this,Se,null);g(this,ll,null);g(this,xs,new d0);g(this,ne,null);g(this,Wn,null);g(this,Xn,null);g(this,Yn,0);g(this,Kn,new Set);g(this,ui,null);g(this,Cs,null);g(this,ha,new Set);T(this,"_editorUndoBar",null);g(this,kc,!1);g(this,Pc,!1);g(this,hl,!1);g(this,Mc,null);g(this,fi,null);g(this,qn,null);g(this,cl,null);g(this,Qn,!1);g(this,pi,null);g(this,Cf,new c0);g(this,Yi,!1);g(this,dl,!1);g(this,Dc,!1);g(this,Jn,null);g(this,ca,null);g(this,ul,null);g(this,Zn,null);g(this,Ic,null);g(this,jt,W.NONE);g(this,dt,new Set);g(this,Ki,null);g(this,tr,null);g(this,er,null);g(this,Lc,null);g(this,fl,null);g(this,Fc,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});g(this,sr,[0,0]);g(this,gi,null);g(this,qi,null);g(this,Rc,null);g(this,Oc,null);g(this,_s,null);const v=this._signal=n(this,il).signal;u(this,qi,t),u(this,Rc,e),u(this,Oc,s),u(this,ol,i),u(this,ne,r),u(this,tr,a),u(this,fl,l),this._eventBus=o;const S={signal:v,...Ap};o.on("editingaction",this.onEditingAction.bind(this),S),o.on("pagechanging",this.onPageChanging.bind(this),S),o.on("scalechanging",this.onScaleChanging.bind(this),S),o.on("rotationchanging",this.onRotationChanging.bind(this),S),o.on("setpreference",this.onSetPreference.bind(this),S),o.on("switchannotationeditorparams",E=>this.updateParams(E.type,E.value),S),window.addEventListener("pointerdown",()=>{u(this,dl,!0)},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{u(this,dl,!1)},{capture:!0,signal:v}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:v}),b(this,R,Rb).call(this),b(this,R,Gb).call(this),b(this,R,Rp).call(this),u(this,Se,l.annotationStorage),u(this,Mc,l.filterFactory),u(this,er,h),u(this,cl,c||null),u(this,kc,d),u(this,Pc,f),u(this,hl,m),u(this,Ic,y||null),this.viewParameters={realScale:Rn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=A||null,this._supportsPinchToZoom=w!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=Ko.prototype,e=a=>n(a,qi).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 F(this,"_keyboardManager",new Ro([[["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"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,qi).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,qi).contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["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,_s))==null||t.resolve(),u(this,_s,null),(e=n(this,il))==null||e.abort(),u(this,il,null),this._signal=null;for(const c of n(this,Dt).values())c.destroy();n(this,Dt).clear(),n(this,xt).clear(),n(this,ha).clear(),(s=n(this,Zn))==null||s.clear(),u(this,Je,null),n(this,dt).clear(),n(this,xs).destroy(),(i=n(this,ol))==null||i.destroy(),(r=n(this,ne))==null||r.destroy(),(a=n(this,tr))==null||a.destroy(),(o=n(this,pi))==null||o.hide(),u(this,pi,null),(l=n(this,ul))==null||l.destroy(),u(this,ul,null),u(this,nl,null),n(this,fi)&&(clearTimeout(n(this,fi)),u(this,fi,null)),n(this,gi)&&(clearTimeout(n(this,gi)),u(this,gi,null)),(h=this._editorUndoBar)==null||h.destroy(),u(this,fl,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,Ic)}get useNewAltTextFlow(){return n(this,Pc)}get useNewAltTextWhenAddingImage(){return n(this,hl)}get hcmFilter(){return F(this,"hcmFilter",n(this,er)?n(this,Mc).addHCMFilter(n(this,er).foreground,n(this,er).background):"none")}get direction(){return F(this,"direction",getComputedStyle(n(this,qi)).direction)}get _highlightColors(){return F(this,"_highlightColors",n(this,cl)?new Map(n(this,cl).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 F(this,"highlightColors",null);const e=new Map,s=!!n(this,er);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 F(this,"highlightColors",e)}get highlightColorNames(){return F(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),u(this,Xn,t)}setMainHighlightColorPicker(t){u(this,ul,t)}editAltText(t,e=!1){var s;(s=n(this,ol))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,ne)}editComment(t,e,s,i){var r;(r=n(this,ne))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,Dt).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,ne))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,ne))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=n(this,ne))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var i;(i=n(this,ne))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,ne))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,ne))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,Dt).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,Ap),await s}getSignature(t){var e;(e=n(this,tr))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,tr)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Ap}),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":u(this,hl,e);break}}onPageChanging({pageNumber:t}){u(this,Yn,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,Dt).delete(t),n(this,Yn)===t&&u(this,Yn,0)}focusMainContainer(){n(this,qi).focus()}findParent(t,e){for(const s of n(this,Dt).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,Rc).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,ha).add(t)}removeShouldRescale(t){n(this,ha).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Rn.PDF_TO_CSS_UNITS;for(const s of n(this,ha))s.onScaleChanging();(e=n(this,Xn))==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,R,_u).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const f=b(this,R,Fp).call(this,c),m=n(this,jt)===W.NONE,y=()=>{const A=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});m&&this.showAllEditors("highlight",!0,!0),e&&(A==null||A.editComment())};if(m){this.switchToMode(W.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){var t;this.commitOrRemove(),(t=this.currentLayer)==null||t.endDrawingSession(!1)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,Se))return null;const e=`${Ph}${t}`,s=n(this,Se).getRawValue(e);return s&&n(this,Se).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,Se)&&!n(this,Se).has(t.id)&&n(this,Se).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,Oc);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,Qn)&&(u(this,Qn,!1),b(this,R,Uh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,dt))if(e.div.contains(t)){u(this,ca,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,ca))return;const[t,e]=n(this,ca);u(this,ca,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,R,Rp).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,R,Bb).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Cs))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,Cs))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,Je))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,dt)){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,Cs))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){X(`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,R,Op).call(this,l);b(this,R,Np).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){X(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,jt)!==W.NONE&&!this.isEditorHandlingKeyboard&&Ko._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Qn)&&(u(this,Qn,!1),b(this,R,Uh).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}}updatePageIndex(t,e){for(const i of n(this,al).get(t)||[])i.pageIndex=e;const s=n(this,rl).get(t);s&&(s.pageIndex=e,n(this,Dt).set(e,s),n(this,Yi)?s.enable():s.disable())}startUpdatePages(){u(this,rl,new Map(n(this,Dt))),n(this,Dt).clear();const t=u(this,al,new Map),e=s=>{t.getOrInsertComputed(s.pageIndex,Ho).push(s)};for(const s of n(this,xt).values())e(s);for(const[s,i]of n(this,Se))s.startsWith(Ph)&&!n(this,xt).has(s)&&Number.isInteger(i==null?void 0:i.pageIndex)&&e(i)}endUpdatePages(){u(this,rl,null),u(this,al,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==W.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,Se).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of n(this,Se))r.pageIndex===s&&r.isClone&&(n(this,Se).remove(i),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(b(this,R,Ob).call(this),b(this,R,Hb).call(this),b(this,R,Te).call(this,{isEditing:n(this,jt)!==W.NONE,isEmpty:b(this,R,Gh).call(this),hasSomethingToUndo:n(this,xs).hasSomethingToUndo(),hasSomethingToRedo:n(this,xs).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,R,Nb).call(this),b(this,R,Ub).call(this),b(this,R,Te).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Cs)){u(this,Cs,t);for(const e of n(this,Cs))b(this,R,Vi).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Cf).id}get currentLayer(){return n(this,Dt).get(n(this,Yn))}getLayer(t){return n(this,Dt).get(t)}get currentPageIndex(){return n(this,Yn)}addLayer(t){n(this,Dt).set(t.pageIndex,t),n(this,Yi)?t.enable():t.disable()}removeLayer(t){n(this,Dt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,h,c,d,f;if(n(this,jt)!==t&&!(n(this,_s)&&(await n(this,_s).promise,!n(this,_s)))){if(u(this,_s,Promise.withResolvers()),(o=n(this,Xn))==null||o.commitOrRemove(),n(this,jt)===W.POPUP&&((l=n(this,ne))==null||l.hideSidebar()),(h=n(this,ne))==null||h.destroyPopup(),u(this,jt,t),t===W.NONE){this.setEditingState(!1),b(this,R,zb).call(this);for(const m of n(this,xt).values())m.hideStandaloneCommentButton();(c=this._editorUndoBar)==null||c.hide(),this.toggleComment(null),n(this,_s).resolve();return}for(const m of n(this,xt).values())m.addStandaloneCommentButton();t===W.SIGNATURE&&await((d=n(this,tr))==null?void 0:d.loadSignatures()),s&&we.clearPointerType(),this.setEditingState(!0),await b(this,R,$b).call(this),this.unselectAll();for(const m of n(this,Dt).values())m.updateMode(t);if(t===W.POPUP){n(this,nl)||u(this,nl,await n(this,fl).getAnnotationsByType(new Set(n(this,Cs).map(A=>A._editorType))));const m=new Set,y=[];for(const A of n(this,xt).values()){const{annotationElementId:w,hasComment:v,deleted:S}=A;w&&m.add(w),v&&!S&&y.push(A.getData())}for(const A of n(this,nl)){const{id:w,popupRef:v,contentsObj:S}=A;v&&(S!=null&&S.str)&&!m.has(w)&&!n(this,Kn).has(w)&&y.push(A)}(f=n(this,ne))==null||f.showSidebar(y)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,_s).resolve();return}for(const m of n(this,xt).values())m.uid===e?(this.setSelected(m),a?m.editComment():r?m.enterInEditMode():m.focus()):m.unselect();n(this,_s).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,jt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,Cs)){switch(t){case et.CREATE:this.currentLayer.addNewEditor(e);return;case et.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Lc)||u(this,Lc,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,dt))s.updateParams(t,e);else for(const s of n(this,Cs))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,xt).values())a.editorType===t&&a.show(e);(((r=n(this,Lc))==null?void 0:r.get(et.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,R,Vi).call(this,[[et.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,Dc)!==t){u(this,Dc,t);for(const e of n(this,Dt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,xt).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,xt).get(t)}addEditor(t){n(this,xt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,fi)&&clearTimeout(n(this,fi)),u(this,fi,setTimeout(()=>{this.focusMainContainer(),u(this,fi,null)},0))),n(this,xt).delete(t.id),t.annotationElementId&&((e=n(this,Zn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Kn).has(t.annotationElementId))&&((s=n(this,Se))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Kn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Kn).has(t)}removeDeletedAnnotationElement(t){n(this,Kn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,Je)!==t&&(u(this,Je,t),t&&b(this,R,Vi).call(this,t.propertiesToUpdate))}updateUI(t){n(this,R,Vb)===t&&b(this,R,Vi).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,R,Vi).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,dt).has(t)){n(this,dt).delete(t),t.unselect(),b(this,R,Te).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,dt).add(t),t.select(),b(this,R,Vi).call(this,t.propertiesToUpdate),b(this,R,Te).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,Xn))==null||e.commitOrRemove();for(const i of n(this,dt))i!==t&&i.unselect();(s=n(this,ne))==null||s.destroyPopup(),n(this,dt).clear(),n(this,dt).add(t),t.select(),b(this,R,Vi).call(this,t.propertiesToUpdate),b(this,R,Te).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,dt).values().next().value}unselect(t){t.unselect(),n(this,dt).delete(t),b(this,R,Te).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,dt).size!==0}get isEnterHandled(){return n(this,dt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,xs).undo(),b(this,R,Te).call(this,{hasSomethingToUndo:n(this,xs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,R,Gh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,xs).redo(),b(this,R,Te).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,xs).hasSomethingToRedo(),isEmpty:b(this,R,Gh).call(this)})}addCommands(t){n(this,xs).add(t),b(this,R,Te).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,R,Gh).call(this)})}cleanUndoStack(t){n(this,xs).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,dt)],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,R,Op).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,Je))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,Je)||this.hasSelection}selectAll(){for(const t of n(this,dt))t.commit();b(this,R,Np).call(this,n(this,xt).values())}unselectAll(){var t,e;if(!(n(this,Je)&&(n(this,Je).commitOrRemove(),n(this,jt)!==W.NONE))&&!((t=n(this,Xn))!=null&&t.commitOrRemove())&&((e=n(this,ne))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of n(this,dt))s.unselect();n(this,dt).clear(),b(this,R,Te).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,sr)[0]+=t,n(this,sr)[1]+=e;const[i,r]=n(this,sr),a=[...n(this,dt)],o=1e3;n(this,gi)&&clearTimeout(n(this,gi)),u(this,gi,setTimeout(()=>{u(this,gi,null),n(this,sr)[0]=n(this,sr)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,xt).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,xt).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),u(this,ui,new Map);for(const t of n(this,dt))n(this,ui).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,ui))return!1;this.disableUserSelect(!1);const t=n(this,ui);u(this,ui,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,xt).has(i.id)){const l=n(this,Dt).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,ui))for(const s of n(this,ui).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,dt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,Je)===t}getActive(){return n(this,Je)}getMode(){return n(this,jt)}isEditingMode(){return n(this,jt)!==W.NONE}get imageManager(){return F(this,"imageManager",new Ip)}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,d,f)=>({x:(c-i)/a,y:1-(h+d-s)/r,width:f/a,height:d/r});break;case"180":o=(h,c,d,f)=>({x:1-(h+d-s)/r,y:1-(c+f-i)/a,width:d/r,height:f/a});break;case"270":o=(h,c,d,f)=>({x:1-(c+f-i)/a,y:(h-s)/r,width:f/a,height:d/r});break;default:o=(h,c,d,f)=>({x:(h-s)/r,y:(c-i)/a,width:d/r,height:f/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:f,y:m,width:y,height:A}of d.getClientRects())y===0||A===0||l.push(o(f,m,y,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,ll)||u(this,ll,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,ll))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,ll))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,Se).getRawValue(e);s&&(n(this,jt)===W.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,Zn))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,Zn).delete(t))}addMissingCanvas(t,e){(n(this,Zn)||u(this,Zn,new Map)).set(t,e)}};il=new WeakMap,Je=new WeakMap,nl=new WeakMap,xt=new WeakMap,Dt=new WeakMap,rl=new WeakMap,al=new WeakMap,ol=new WeakMap,Se=new WeakMap,ll=new WeakMap,xs=new WeakMap,ne=new WeakMap,Wn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,Kn=new WeakMap,ui=new WeakMap,Cs=new WeakMap,ha=new WeakMap,kc=new WeakMap,Pc=new WeakMap,hl=new WeakMap,Mc=new WeakMap,fi=new WeakMap,qn=new WeakMap,cl=new WeakMap,Qn=new WeakMap,pi=new WeakMap,Cf=new WeakMap,Yi=new WeakMap,dl=new WeakMap,Dc=new WeakMap,Jn=new WeakMap,ca=new WeakMap,ul=new WeakMap,Zn=new WeakMap,Ic=new WeakMap,jt=new WeakMap,dt=new WeakMap,Ki=new WeakMap,tr=new WeakMap,er=new WeakMap,Lc=new WeakMap,fl=new WeakMap,Fc=new WeakMap,sr=new WeakMap,gi=new WeakMap,qi=new WeakMap,Rc=new WeakMap,Oc=new WeakMap,_s=new WeakMap,R=new WeakSet,_u=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Fp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Dt).values())if(s.hasTextLayer(t))return s;return null},Lb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,R,_u).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,pi)||u(this,pi,new l0(this)),n(this,pi).show(s,i,this.direction==="ltr"))},Fb=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,Ki)&&((r=n(this,pi))==null||r.hide(),u(this,Ki,null),b(this,R,Te).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,Ki))return;const i=b(this,R,_u).call(this,t).closest(".textLayer");if(!i){n(this,Ki)&&((a=n(this,pi))==null||a.hide(),u(this,Ki,null),b(this,R,Te).call(this,{hasSelectedText:!1}));return}if((o=n(this,pi))==null||o.hide(),u(this,Ki,e),b(this,R,Te).call(this,{hasSelectedText:!0}),!(n(this,jt)!==W.HIGHLIGHT&&n(this,jt)!==W.NONE)&&(n(this,jt)===W.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),u(this,Qn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,jt)===W.HIGHLIGHT?b(this,R,Fp).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,dl)){const h=new AbortController,c=this.combinedSignal(h),d=f=>{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,R,Uh).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("blur",d,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,R,Uh).call(this,"main_toolbar")}},Uh=function(t=""){n(this,jt)===W.HIGHLIGHT?this.highlightSelection(t):n(this,kc)&&b(this,R,Lb).call(this)},Rb=function(){document.addEventListener("selectionchange",b(this,R,Fb).bind(this),{signal:this._signal})},Ob=function(){if(n(this,qn))return;u(this,qn,new AbortController);const t=this.combinedSignal(n(this,qn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Nb=function(){var t;(t=n(this,qn))==null||t.abort(),u(this,qn,null)},Rp=function(){if(n(this,Jn))return;u(this,Jn,new AbortController);const t=this.combinedSignal(n(this,Jn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Bb=function(){var t;(t=n(this,Jn))==null||t.abort(),u(this,Jn,null)},Hb=function(){if(n(this,Wn))return;u(this,Wn,new AbortController);const t=this.combinedSignal(n(this,Wn));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})},Ub=function(){var t;(t=n(this,Wn))==null||t.abort(),u(this,Wn,null)},Gb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Te=function(t){Object.entries(t).some(([s,i])=>n(this,Fc)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,Fc),t)}),n(this,jt)===W.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,R,Vi).call(this,[[et.HIGHLIGHT_FREE,!0]]))},Vi=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},$b=async function(){if(!n(this,Yi)){u(this,Yi,!0);const t=[];for(const e of n(this,Dt).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,xt).values())e.enable()}},zb=function(){if(this.unselectAll(),n(this,Yi)){u(this,Yi,!1);for(const t of n(this,Dt).values())t.disable();for(const t of n(this,xt).values())t.disable()}},Op=function(t){const e=n(this,Dt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Vb=function(){let t=null;for(t of n(this,dt));return t},Gh=function(){if(n(this,xt).size===0)return!0;if(n(this,xt).size===1)for(const t of n(this,xt).values())return t.isEmpty();return!1},Np=function(t){for(const e of n(this,dt))e.unselect();n(this,dt).clear();for(const e of t)e.isEmpty()||(n(this,dt).add(e),e.select());b(this,R,Te).call(this,{hasSelectedEditor:this.hasSelection})},T(Ko,"TRANSLATE_SMALL",1),T(Ko,"TRANSLATE_BIG",10);let Wr=Ko;var re,mi,zs,pl,bi,Ze,gl,yi,ze,Qi,da,Ai,ir,ri,$h,Tu;const ke=class ke{constructor(t){g(this,ri);g(this,re,null);g(this,mi,!1);g(this,zs,null);g(this,pl,null);g(this,bi,null);g(this,Ze,null);g(this,gl,!1);g(this,yi,null);g(this,ze,null);g(this,Qi,null);g(this,da,null);g(this,Ai,!1);u(this,ze,t),u(this,Ai,t._uiManager.useNewAltTextFlow),n(ke,ir)||u(ke,ir,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){ke._l10n??(ke._l10n=t)}async render(){const t=u(this,zs,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=u(this,pl,document.createElement("span"));t.append(e),n(this,Ai)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(ke,ir).missing),e.setAttribute("data-l10n-id",n(ke,ir)["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",Us,{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,Ai)&&n(this,ze)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ri,$h)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(u(this,gl,!0),i(r))},{signal:s}),await b(this,ri,Tu).call(this),t}finish(){n(this,zs)&&(n(this,zs).focus({focusVisible:n(this,gl)}),u(this,gl,!1))}isEmpty(){return n(this,Ai)?n(this,re)===null:!n(this,re)&&!n(this,mi)}hasData(){return n(this,Ai)?n(this,re)!==null||!!n(this,Qi):this.isEmpty()}get guessedText(){return n(this,Qi)}async setGuessedText(t){n(this,re)===null&&(u(this,Qi,t),u(this,da,await ke._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,ri,Tu).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,Ai)||n(this,re)){(e=n(this,yi))==null||e.remove(),u(this,yi,null);return}if(!n(this,yi)){const s=u(this,yi,document.createElement("div"));s.className="noAltTextBadge",n(this,ze).div.append(s)}n(this,yi).classList.toggle("hidden",!t)}serialize(t){let e=n(this,re);return!t&&n(this,Qi)===e&&(e=n(this,da)),{altText:e,decorative:n(this,mi),guessedText:n(this,Qi),textWithDisclaimer:n(this,da)}}get data(){return{altText:n(this,re),decorative:n(this,mi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(u(this,Qi,s),u(this,da,i)),!(n(this,re)===t&&n(this,mi)===e)&&(r||(u(this,re,t),u(this,mi,e)),b(this,ri,Tu).call(this))}toggle(t=!1){n(this,zs)&&(!t&&n(this,Ze)&&(clearTimeout(n(this,Ze)),u(this,Ze,null)),n(this,zs).disabled=!t)}shown(){n(this,ze)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ri,$h)}})}destroy(){var t,e;(t=n(this,zs))==null||t.remove(),u(this,zs,null),u(this,pl,null),u(this,bi,null),(e=n(this,yi))==null||e.remove(),u(this,yi,null)}};re=new WeakMap,mi=new WeakMap,zs=new WeakMap,pl=new WeakMap,bi=new WeakMap,Ze=new WeakMap,gl=new WeakMap,yi=new WeakMap,ze=new WeakMap,Qi=new WeakMap,da=new WeakMap,Ai=new WeakMap,ir=new WeakMap,ri=new WeakSet,$h=function(){return n(this,re)&&"added"||n(this,re)===null&&this.guessedText&&"review"||"missing"},Tu=async function(){var i,r,a;const t=n(this,zs);if(!t)return;if(n(this,Ai)){if(t.classList.toggle("done",!!n(this,re)),t.setAttribute("data-l10n-id",n(ke,ir)[n(this,ri,$h)]),(i=n(this,pl))==null||i.setAttribute("data-l10n-id",n(ke,ir)[`${n(this,ri,$h)}-label`]),!n(this,re)){(r=n(this,bi))==null||r.remove();return}}else{if(!n(this,re)&&!n(this,mi)){t.classList.remove("done"),(a=n(this,bi))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,bi);if(!e){u(this,bi,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,Ze)),u(this,Ze,null)},{once:!0}),t.addEventListener("mouseenter",()=>{u(this,Ze,setTimeout(()=>{u(this,Ze,null),n(this,bi).classList.add("show"),n(this,ze)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,Ze)&&(clearTimeout(n(this,Ze)),u(this,Ze,null)),(h=n(this,bi))==null||h.classList.remove("show")},{signal:l})}n(this,mi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,re)),e.parentNode||t.append(e);const s=n(this,ze).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},g(ke,ir,null),T(ke,"_l10n",null);let pf=ke;var ce,Ts,ua,At,Nc,nr,ks,rr,ar,fa,Bc,Bp;class gu{constructor(t){g(this,Bc);g(this,ce,null);g(this,Ts,null);g(this,ua,!1);g(this,At,null);g(this,Nc,null);g(this,nr,null);g(this,ks,null);g(this,rr,null);g(this,ar,!1);g(this,fa,null);u(this,At,t)}renderForToolbar(){const t=u(this,Ts,document.createElement("button"));return t.className="comment",b(this,Bc,Bp).call(this,t,!1)}renderForStandalone(){const t=u(this,ce,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,At).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,At)._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,At).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Bc,Bp).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,ce)??n(this,Ts))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,ce))return;const t=n(this,At).commentButtonColor;t&&(n(this,ce).style.backgroundColor=t),n(this,At)._uiManager.updatePopupColor(n(this,At))}get commentButtonWidth(){var t;return(((t=n(this,ce))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,At).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,fa))return n(this,fa);if(!n(this,ce))return null;const{x:t,y:e,height:s}=n(this,ce).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,At).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){u(this,fa,t)}hasDefaultPopupPosition(){return n(this,fa)===null}removeStandaloneCommentButton(){var t;(t=n(this,ce))==null||t.remove(),u(this,ce,null)}removeToolbarCommentButton(){var t;(t=n(this,Ts))==null||t.remove(),u(this,Ts,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,ce)&&(n(this,ce).classList.toggle("selected",t),n(this,ce).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,At).commentButtonPosition;const{width:c,height:d,x:f,y:m}=n(this,At);s=f+s*c,i=m+i*d}const r=n(this,At).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;n(this,At)._uiManager.editComment(n(this,At),a+s*l,o+i*h,{...t,parentDimensions:r})}finish(){n(this,Ts)&&(n(this,Ts).focus({focusVisible:n(this,ua)}),u(this,ua,!1))}isDeleted(){return n(this,ar)||n(this,ks)===""}isEmpty(){return n(this,ks)===null}hasBeenEdited(){return this.isDeleted()||n(this,ks)!==n(this,Nc)}serialize(){return this.data}get data(){return{text:n(this,ks),richText:n(this,nr),date:n(this,rr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,ks)&&u(this,nr,null),t===null){u(this,ks,""),u(this,ar,!0);return}u(this,ks,t),u(this,rr,new Date),u(this,ar,!1)}restoreData({text:t,richText:e,date:s}){u(this,ks,t),u(this,nr,e),u(this,rr,s),u(this,ar,!1)}setInitialText(t,e=null){u(this,Nc,t),this.data=t,u(this,rr,null),u(this,nr,e)}shown(){}destroy(){var t,e;(t=n(this,Ts))==null||t.remove(),u(this,Ts,null),(e=n(this,ce))==null||e.remove(),u(this,ce,null),u(this,ks,""),u(this,nr,null),u(this,rr,null),u(this,At,null),u(this,ua,!1),u(this,ar,!1)}}ce=new WeakMap,Ts=new WeakMap,ua=new WeakMap,At=new WeakMap,Nc=new WeakMap,nr=new WeakMap,ks=new WeakMap,rr=new WeakMap,ar=new WeakMap,fa=new WeakMap,Bc=new WeakSet,Bp=function(t,e){if(!n(this,At)._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,At)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,At)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Us,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,At)._focusEventsAllowed=!1,Kt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,At)._focusEventsAllowed=!0,Kt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,Ts)?this.edit():n(this,At).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(u(this,ua,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,At).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,At).toggleComment(!1,!1)},{signal:s}),t};function zm(p){p.preventDefault()}const Vm=1e-4;function wp(p){return p.cancelable?(Kt(p),!0):(p.stopPropagation(),!1)}var ml,or,Hc,Uc,Gc,$c,zc,pa,lr,Ji,ga,wi,Zi,ma,tn,hr,Pt,jb,Hp,Up,Gp,ku,Wb,Xb,$p;class Am{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,onPanning:o=null,signal:l}){g(this,Pt);g(this,ml);g(this,or,!1);g(this,Hc,null);g(this,Uc);g(this,Gc);g(this,$c);g(this,zc);g(this,pa);g(this,lr,!1);g(this,Ji,null);g(this,ga);g(this,wi,new Set);g(this,Zi,null);g(this,ma);g(this,tn,null);g(this,hr,0);u(this,ml,t),u(this,Hc,s),u(this,Uc,e),u(this,Gc,i),u(this,$c,r),u(this,zc,a),u(this,pa,o),u(this,ma,new AbortController),u(this,ga,AbortSignal.any([l,n(this,ma).signal])),t.addEventListener("touchstart",b(this,Pt,jb).bind(this),{passive:!1,signal:n(this,ga)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/bs.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/bs.pixelRatio}destroy(){var t,e;b(this,Pt,$p).call(this),n(this,wi).clear(),(t=n(this,ma))==null||t.abort(),u(this,ma,null),(e=n(this,Ji))==null||e.abort(),u(this,Ji,null)}}ml=new WeakMap,or=new WeakMap,Hc=new WeakMap,Uc=new WeakMap,Gc=new WeakMap,$c=new WeakMap,zc=new WeakMap,pa=new WeakMap,lr=new WeakMap,Ji=new WeakMap,ga=new WeakMap,wi=new WeakMap,Zi=new WeakMap,ma=new WeakMap,tn=new WeakMap,hr=new WeakMap,Pt=new WeakSet,jb=function(t){var s,i;if((s=n(this,Uc))!=null&&s.call(this))return;b(this,Pt,Up).call(this,t);const e=n(this,wi);for(const{identifier:r}of t.changedTouches)e.add(r);if(e.size===1){b(this,Pt,Hp).call(this);return}if(!n(this,tn)){u(this,tn,new AbortController);const r=AbortSignal.any([n(this,ga),n(this,tn).signal]),a=n(this,ml),o={signal:r,capture:!1,passive:!1};a.addEventListener("touchmove",b(this,Pt,Wb).bind(this),o);const l=b(this,Pt,Xb).bind(this);a.addEventListener("touchend",l,o),a.addEventListener("touchcancel",l,o),o.capture=!0,a.addEventListener("pointerdown",Kt,o),a.addEventListener("pointermove",Kt,o),a.addEventListener("pointercancel",zm,o),a.addEventListener("pointerup",zm,o),(i=n(this,Gc))==null||i.call(this)}u(this,lr,wp(t)),b(this,Pt,ku).call(this,t)},Hp=function(){if(n(this,Ji))return;const t=u(this,Ji,new AbortController),e=AbortSignal.any([n(this,ga),t.signal]),s=n(this,ml),i={capture:!0,signal:e,passive:!1},r=a=>{var o;a.pointerType==="touch"&&((o=n(this,Ji))==null||o.abort(),u(this,Ji,null))};s.addEventListener("pointerdown",a=>{a.pointerType==="touch"&&(Kt(a),r(a))},i),s.addEventListener("pointerup",r,i),s.addEventListener("pointercancel",r,i)},Up=function(t){const e=n(this,wi);if(e.size===0)return;const s=u(this,wi,new Set);for(const{identifier:i}of t.touches)e.has(i)&&s.add(i)},Gp=function(t){const e=n(this,wi),s=[];for(const i of t.touches)e.has(i.identifier)&&s.push(i);return s},ku=function(t){var r;const e=b(this,Pt,Gp).call(this,t);if(e.length!==2||(r=n(this,Hc))!=null&&r.call(this)){u(this,Zi,null);return}const[s,i]=e;u(this,Zi,{touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2})},Wb=function(t){var B,G,nt,he;if(!n(this,Zi))return;const e=b(this,Pt,Gp).call(this,t);if(e.length!==2)return;const s=n(this,lr);if(u(this,lr,wp(t)),!n(this,lr))return;if(!s){b(this,Pt,ku).call(this,t);return}const[i,r]=e,{screenX:a,screenY:o}=i,{screenX:l,screenY:h}=r,c=n(this,Zi),{touch0X:d,touch0Y:f,touch1X:m,touch1Y:y,panX:A,panY:w}=c,v=m-d,S=y-f,E=l-a,x=h-o,C=(i.clientX+r.clientX)/2,_=(i.clientY+r.clientY)/2;c.panX=C,c.panY=_;const k=C-A,M=_-w,P=(a+l)/2,D=(o+h)/2,N=Math.hypot(P-c.screenPanX,D-c.screenPanY);c.screenPanX=P,c.screenPanY=D;const Z=Math.hypot(E,x),Q=Math.hypot(v,S),Y=n(this,or)?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*N;if(Z<Vm||Q<Vm||Math.abs(Q-Z)<=Y){(k||M)&&((B=n(this,pa))==null||B.call(this,k,M));return}c.touch0X=a,c.touch0Y=o,c.touch1X=l,c.touch1Y=h;const K=Math.sign(Z-Q);if(!n(this,or)){u(this,or,!0),u(this,hr,K),(k||M)&&((G=n(this,pa))==null||G.call(this,k,M));return}if(n(this,hr)){const ee=n(this,hr);if(u(this,hr,0),K!==ee&&Math.abs(Z-Q)<=2*N){u(this,or,!1),(k||M)&&((nt=n(this,pa))==null||nt.call(this,k,M));return}}(he=n(this,$c))==null||he.call(this,[A,w],Q,Z,k,M)},Xb=function(t){if(b(this,Pt,Up).call(this,t),n(this,wi).size>=2){b(this,Pt,ku).call(this,t);return}const e=!!n(this,Zi);b(this,Pt,$p).call(this),n(this,wi).size===1&&b(this,Pt,Hp).call(this),e&&wp(t)},$p=function(){var t;u(this,Zi,null),u(this,or,!1),u(this,hr,0),u(this,lr,!1),n(this,tn)&&(n(this,tn).abort(),u(this,tn,null),(t=n(this,zc))==null||t.call(this))};var ba,Vs,Ct,ht,en,bl,cr,Vc,de,ya,sn,Ps,dr,jc,Aa,ts,Wc,wa,nn,vi,yl,Al,Ms,ur,Xc,_f,z,zp,Yc,Vp,Pu,Yb,Kb,jp,Mu,Wp,qb,Qb,Jb,Xp,Zb,Yp,Kp,ty,ey,sy,qp,zh;const j=class j{constructor(t){g(this,z);g(this,ba,null);g(this,Vs,null);g(this,Ct,null);g(this,ht,null);g(this,en,null);g(this,bl,!1);g(this,cr,null);g(this,Vc,"");g(this,de,null);g(this,ya,null);g(this,sn,null);g(this,Ps,null);g(this,dr,null);g(this,jc,"");g(this,Aa,!1);g(this,ts,null);g(this,Wc,!1);g(this,wa,!1);g(this,nn,!1);g(this,vi,null);g(this,yl,0);g(this,Al,0);g(this,Ms,null);g(this,ur,null);T(this,"isSelected",!1);T(this,"_isCopy",!1);T(this,"_editToolbar",null);T(this,"_initialOptions",Object.create(null));T(this,"_initialData",null);T(this,"_isVisible",!0);T(this,"_uiManager",null);T(this,"_focusEventsAllowed",!0);g(this,Xc,!1);g(this,_f,j._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,this.canAddComment=!0;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=j.prototype._resizeWithKeyboard,e=Wr.TRANSLATE_SMALL,s=Wr.TRANSLATE_BIG;return F(this,"_resizerKeyboardManager",new Ro([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],j.prototype._stopResizingWithKeyboard]]))}updatePageIndex(t){this.pageIndex=t}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 F(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new u0({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(j._l10n??(j._l10n=t),j._l10nAlert??(j._l10nAlert=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"})),j._l10nResizer??(j._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"})),j._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);j._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,Xc)}set _isDraggable(t){var e;u(this,Xc,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,_f)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,z,zh).call(this),(e=n(this,Ps))==null||e.remove(),u(this,Ps,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,Aa)?u(this,Aa,!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){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){b(this,z,zp).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,ts)||u(this,ts,[this.x,this.y,this.width,this.height]),b(this,z,zp).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,ts)||u(this,ts,[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:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,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)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,ts)&&(n(this,ts)[0]!==this.x||n(this,ts)[1]!==this.y)}get _hasBeenResized(){return!!n(this,ts)&&(n(this,ts)[2]!==this.width||n(this,ts)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=j,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=wt(r,0,s-o),a=wt(a,0,i-l);break;case 90:r=wt(r,0,s-l),a=wt(a,o,i);break;case 180:r=wt(r,o,s),a=wt(a,l,i);break;case 270:r=wt(r,l,s),a=wt(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=j,Yc,Vp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=j,Yc,Vp).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,Ct))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,wa))return this._editToolbar;this._editToolbar=new Mp(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,Ct))==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,Ct)||(pf.initialize(j._l10n),u(this,Ct,new pf(this)),n(this,ba)&&(n(this,Ct).data=n(this,ba),u(this,ba,null))),n(this,Ct)}get altTextData(){var t;return(t=n(this,Ct))==null?void 0:t.data}set altTextData(t){n(this,Ct)&&(n(this,Ct).data=t)}get guessedAltText(){var t;return(t=n(this,Ct))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,Ct))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,Ct))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,Ct)&&!n(this,Ct).isEmpty()}hasAltTextData(){var t;return((t=n(this,Ct))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,ht))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,ht)||u(this,ht,new gu(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,en)){this._uiManager.isEditingMode()&&n(this,en).classList.remove("hidden");return}this.hasComment&&(u(this,en,n(this,ht).renderForStandalone()),this.div.append(n(this,en)))}}removeStandaloneCommentButton(){n(this,ht).removeStandaloneCommentButton(),u(this,en,null)}hideStandaloneCommentButton(){var t;(t=n(this,en))==null||t.classList.add("hidden")}get comment(){if(!n(this,ht))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,ht);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,ht)||u(this,ht,new gu(this)),typeof t=="object"&&t!==null?n(this,ht).restoreData(t):n(this,ht).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,ht)||u(this,ht,new gu(this)),n(this,ht).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,ht))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,ht))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,ht)&&!n(this,ht).isEmpty()&&!n(this,ht).isDeleted()}async editComment(t){n(this,ht)||u(this,ht,new gu(this)),n(this,ht).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,ht).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,ht).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,bl)?-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,z,Yp).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),Mb(this,t,["keydown","pointerdown","dblclick"]),b(this,z,Kp).call(this),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(u(this,Aa,!0),this._isDraggable){b(this,z,Zb).call(this,t);return}b(this,z,Xp).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,vi)&&clearTimeout(n(this,vi)),u(this,vi,setTimeout(()=>{var t;u(this,vi,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,d=this.x*r,f=this.y*a,m=this.width*r,y=this.height*a;switch(s){case 0:return[d+h+o,a-f-c-y+l,d+h+m+o,a-f-c+l];case 90:return[d+c+o,a-f+h+l,d+c+y+o,a-f+h+m+l];case 180:return[d-h-m+o,a-f+c+l,d-h+o,a-f+c+y+l];case 270:return[d-c-y+o,a-f-h-m+l,d-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&&j._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,ht))==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),u(this,wa,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),u(this,wa,!1),!0):!1}isInEditMode(){return n(this,wa)}shouldGetKeyboardEvents(){return n(this,nn)}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,z,Yp).call(this),b(this,z,Kp).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:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,u(i,ba,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,s;if((t=n(this,dr))==null||t.abort(),u(this,dr,null),this.isEmpty()||this.commit(),(e=n(this,ur))==null||e.destroy(),u(this,ur,null),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,vi)&&(clearTimeout(n(this,vi)),u(this,vi,null)),b(this,z,zh).call(this),this.removeEditToolbar(),n(this,Ms)){for(const i of n(this,Ms).values())clearTimeout(i);u(this,Ms,null)}this.parent=null,(s=n(this,Ps))==null||s.remove(),u(this,Ps,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,z,Yb).call(this),n(this,de).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[j._round(s+(r-s)*t),j._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,ht).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,ht).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,ht).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,ht).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,ht))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),u(this,sn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,de).children;if(!n(this,Vs)){u(this,Vs,Array.from(e));const a=b(this,z,ty).bind(this),o=b(this,z,ey).bind(this),l=this._uiManager._signal;for(const h of n(this,Vs)){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,z,sy).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",j._l10nResizer[c])}}const s=n(this,Vs)[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,Vs).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,de).append(n(this,de).firstElementChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,de).firstElementChild.before(n(this,de).lastElementChild);let a=0;for(const o of e){const h=n(this,Vs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",j._l10nResizer[h])}}b(this,z,qp).call(this,0),u(this,nn,!0),n(this,de).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,nn)&&b(this,z,Wp).call(this,n(this,jc),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,z,zh).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,Ct))==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,de))==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,Ct))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}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.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,Wc)}set isEditing(t){u(this,Wc,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,Ms)||u(this,Ms,new Map);const{action:s}=t;let i=n(this,Ms).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Ms).delete(s),n(this,Ms).size===0&&u(this,Ms,null)},j._telemetryTimeout),n(this,Ms).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),u(this,bl,!1)}disable(){this.div&&(this.div.tabIndex=-1),u(this,bl,!0)}updateFakeAnnotationElement(t){if(!n(this,Ps)&&!this.deleted){u(this,Ps,t.addFakeAnnotation(this));return}if(this.deleted){n(this,Ps).remove(),u(this,Ps,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,Ps).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{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};ba=new WeakMap,Vs=new WeakMap,Ct=new WeakMap,ht=new WeakMap,en=new WeakMap,bl=new WeakMap,cr=new WeakMap,Vc=new WeakMap,de=new WeakMap,ya=new WeakMap,sn=new WeakMap,Ps=new WeakMap,dr=new WeakMap,jc=new WeakMap,Aa=new WeakMap,ts=new WeakMap,Wc=new WeakMap,wa=new WeakMap,nn=new WeakMap,vi=new WeakMap,yl=new WeakMap,Al=new WeakMap,Ms=new WeakMap,ur=new WeakMap,Xc=new WeakMap,_f=new WeakMap,z=new WeakSet,zp=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()},Yc=new WeakSet,Vp=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]}},Pu=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]}},Yb=function(){if(n(this,de))return;u(this,de,document.createElement("div")),n(this,de).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,de).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,z,Kb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Us,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,de))},Kb=function(t,e){var c;e.preventDefault();const{isMac:s}=ot.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,Ct))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,u(this,ya,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,z,Wp).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Kt,{passive:!1,signal:a}),window.addEventListener("contextmenu",Us,{signal:a}),u(this,sn,{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 d;r.abort(),this.parent.togglePointerEvents(!0),(d=n(this,Ct))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,z,Mu).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},jp=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Mu=function(){if(!n(this,sn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,sn);u(this,sn,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,z,jp).bind(this,r,a,o,l),undo:b(this,z,jp).bind(this,t,e,s,i),mustExec:!0})},Wp=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=j.MIN_SIZE/s,c=j.MIN_SIZE/i,d=b(this,z,Pu).call(this,this.rotation),f=(B,G)=>[d[0]*B+d[2]*G,d[1]*B+d[3]*G],m=b(this,z,Pu).call(this,360-this.rotation),y=(B,G)=>[m[0]*B+m[2]*G,m[1]*B+m[3]*G];let A,w,v=!1,S=!1;switch(t){case"topLeft":v=!0,A=(B,G)=>[0,0],w=(B,G)=>[B,G];break;case"topMiddle":A=(B,G)=>[B/2,0],w=(B,G)=>[B/2,G];break;case"topRight":v=!0,A=(B,G)=>[B,0],w=(B,G)=>[0,G];break;case"middleRight":S=!0,A=(B,G)=>[B,G/2],w=(B,G)=>[0,G/2];break;case"bottomRight":v=!0,A=(B,G)=>[B,G],w=(B,G)=>[0,0];break;case"bottomMiddle":A=(B,G)=>[B/2,G],w=(B,G)=>[B/2,0];break;case"bottomLeft":v=!0,A=(B,G)=>[0,G],w=(B,G)=>[B,0];break;case"middleLeft":S=!0,A=(B,G)=>[0,G/2],w=(B,G)=>[B,G/2];break}const E=A(o,l),x=w(o,l);let C=f(...x);const _=j._round(r+C[0]),k=j._round(a+C[1]);let M=1,P=1,D,N;if(e.fromKeyboard)({deltaX:D,deltaY:N}=e);else{const{screenX:B,screenY:G}=e,[nt,he]=n(this,ya);[D,N]=this.screenToPageTranslation(B-nt,G-he),n(this,ya)[0]=B,n(this,ya)[1]=G}if([D,N]=y(D/s,N/i),v){const B=Math.hypot(o,l);M=P=Math.max(Math.min(Math.hypot(x[0]-E[0]-D,x[1]-E[1]-N)/B,1/o,1/l),h/o,c/l)}else S?M=wt(Math.abs(x[0]-E[0]-D),h,1)/o:P=wt(Math.abs(x[1]-E[1]-N),c,1)/l;const Z=j._round(o*M),Q=j._round(l*P);C=f(...w(Z,Q));const Y=_-C[0],K=k-C[1];n(this,ts)||u(this,ts,[this.x,this.y,this.width,this.height]),this.width=Z,this.height=Q,this.x=Y,this.y=K,this.setDims(),this.fixAndSetPosition(),this._onResizing()},qb=function(){var t;u(this,sn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,Ct))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Qb=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,z,Pu).call(this,this.rotation),o=(_,k)=>[a[0]*_+a[2]*k,a[1]*_+a[3]*k],[l,h]=this.parentDimensions,c=this.x,d=this.y,f=this.width,m=this.height,y=j.MIN_SIZE/l,A=j.MIN_SIZE/h;r=Math.max(Math.min(r,1/f,1/m),y/f,A/m);const w=j._round(f*r),v=j._round(m*r);if(w===f&&v===m)return;n(this,ts)||u(this,ts,[c,d,f,m]);const S=o(f/2,m/2),E=j._round(c+S[0]),x=j._round(d+S[1]),C=o(w/2,v/2);this.x=E-C[0],this.y=x-C[1],this.width=w,this.height=v,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Jb=function(){var t;(t=n(this,Ct))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,z,Mu).call(this)},Xp=function(t){const{isMac:e}=ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Zb=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(),u(this,cr,null),u(this,Aa,!1),this._uiManager.endDragSession()||b(this,z,Xp).call(this,h),s&&this._onStopDragging()};e&&(u(this,yl,t.clientX),u(this,Al,t.clientY),u(this,cr,t.pointerId),u(this,Vc,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:f}=h;if(f!==n(this,cr)){Kt(h);return}const[m,y]=this.screenToPageTranslation(c-n(this,yl),d-n(this,Al));u(this,yl,c),u(this,Al,d),this._uiManager.dragSelectedEditors(m,y),this.div.scrollIntoView({block:"nearest"})},a),window.addEventListener("touchmove",Kt,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,Vc)&&(n(this,ur)||h.isPrimary)&&o(h),Kt(h)},a));const l=h=>{if(!n(this,cr)||n(this,cr)===h.pointerId){o(h);return}Kt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Yp=function(){if(n(this,dr)||!this.div)return;u(this,dr,new AbortController);const t=this._uiManager.combinedSignal(n(this,dr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Kp=function(){n(this,ur)||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||u(this,ur,new Am({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,z,qb).bind(this),onPinching:b(this,z,Qb).bind(this),onPinchEnd:b(this,z,Jb).bind(this),signal:this._uiManager._signal}))},ty=function(t){j._resizerKeyboardManager.exec(this,t)},ey=function(t){var e;n(this,nn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,de)&&b(this,z,zh).call(this)},sy=function(t){u(this,jc,n(this,nn)?t:"")},qp=function(t){if(n(this,Vs))for(const e of n(this,Vs))e.tabIndex=t},zh=function(){u(this,nn,!1),b(this,z,qp).call(this,-1),b(this,z,Mu).call(this)},g(j,Yc),T(j,"_l10n",null),T(j,"_l10nAlert",null),T(j,"_l10nResizer",null),T(j,"_borderLineWidth",-1),T(j,"_colorManager",new Lp),T(j,"_zIndex",1),T(j,"_telemetryTimeout",1e3);let gt=j;class u0 extends gt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const jm=3285377520,ws=4294901760,oi=65535;class Qp{constructor(t){this.h1=t?t&4294967295:jm,this.h2=t?t&4294967295:jm}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,w=t.length;A<w;A++){const v=t.charCodeAt(A);v<=255?e[s++]=v:(e[s++]=v>>>8,e[s++]=v&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 d=3432918353,f=461845907,m=d&oi,y=f&oi;for(let A=0;A<i;A++)A&1?(o=a[A],o=o*d&ws|o*m&oi,o=o<<15|o>>>17,o=o*f&ws|o*y&oi,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[A],l=l*d&ws|l*m&oi,l=l<<15|l>>>17,l=l*f&ws|l*y&oi,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*d&ws|o*m&oi,o=o<<15|o>>>17,o=o*f&ws|o*y&oi,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&ws|t*36045&oi,e=e*4283543511&ws|((e<<16|t>>>16)*2950163797&ws)>>>16,t^=e>>>1,t=t*444984403&ws|t*60499&oi,e=e*3301882366&ws|((e<<16|t>>>16)*3120437893&ws)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const mc=Object.freeze({map:null,hash:"",transfer:void 0});var va,Sa,rn,ue,Tf,iy;class wm{constructor(){g(this,Tf);g(this,va,!1);g(this,Sa,null);g(this,rn,null);g(this,ue,new Map);T(this,"onSetModified",null);T(this,"onResetModified",null);T(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,ue).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,ue).get(t)}remove(t){var s;const e=n(this,ue).get(t);e!==void 0&&(e instanceof gt&&n(this,rn).delete(e.annotationElementId),n(this,ue).delete(t),n(this,ue).size===0&&this.resetModified(),!n(this,ue).values().some(i=>i instanceof gt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,ue).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,ue).set(t,e);i&&b(this,Tf,iy).call(this),e instanceof gt&&((n(this,rn)||u(this,rn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,ue).has(t)}get size(){return n(this,ue).size}resetModified(){var t;n(this,va)&&(u(this,va,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new ny(this)}get serializable(){if(n(this,ue).size===0)return mc;const t=new Map,e=new Qp,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,ue)){const l=o instanceof gt?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),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}:mc}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,ue).values()){if(!(r instanceof gt)){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.getOrInsertComputed(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;const d=l.getOrInsertComputed(h,tp);d.set(c,(d.get(c)??0)+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(){u(this,Sa,null)}updateEditor(t,e){var i;const s=(i=n(this,rn))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,rn))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,Sa))return n(this,Sa);const t=[];if(n(this,rn))for(const s of n(this,rn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Qp;s.update(t.join(",")),e=s.hexdigest()}return u(this,Sa,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,ue).entries()}}va=new WeakMap,Sa=new WeakMap,rn=new WeakMap,ue=new WeakMap,Tf=new WeakSet,iy=function(){var t;n(this,va)||(u(this,va,!0),(t=this.onSetModified)==null||t.call(this))};var Kc;class ny extends wm{constructor(e){super();g(this,Kc,mc);const{serializable:s}=e;if(s===mc)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);u(this,Kc,{map:o,hash:r,transfer:[]})}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Kc)}get modifiedIds(){return F(this,"modifiedIds",{ids:new Set,hash:""})}}Kc=new WeakMap;const $o="__forcedDependency",{floor:Wm,ceil:Xm}=Math;function Ym(p,t,e,s,i,r){p[t*4+0]=Math.min(p[t*4+0],e),p[t*4+1]=Math.min(p[t*4+1],s),p[t*4+2]=Math.max(p[t*4+2],i),p[t*4+3]=Math.max(p[t*4+3],r)}function f0(p,t,e,s,i){let r;p?(p<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=p,i[2]*=p,t<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const Jp=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var wl,fr;class p0{constructor(t,e){g(this,wl);g(this,fr);u(this,wl,t),u(this,fr,e)}get length(){return n(this,wl).length}isEmpty(t){return n(this,wl)[t]===Jp}minX(t){return n(this,fr)[t*4+0]/256}minY(t){return n(this,fr)[t*4+1]/256}maxX(t){return(n(this,fr)[t*4+2]+1)/256}maxY(t){return(n(this,fr)[t*4+3]+1)/256}}wl=new WeakMap,fr=new WeakMap;const Km=(p,t)=>p==null?void 0:p.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var an,at,St,Ea,xa,Ca,Ee,qc,Zp;class g0{constructor(t,e){g(this,qc);g(this,an,[[1,0,0,1,0,0]]);g(this,at,[-1/0,-1/0,1/0,1/0]);g(this,St,new Float64Array(Ui));T(this,"_pendingBBoxIdx",-1);g(this,Ea);g(this,xa);g(this,Ca);g(this,Ee);T(this,"_savesStack",[]);T(this,"_markedContentStack",[]);u(this,Ea,t.width),u(this,xa,t.height),b(this,qc,Zp).call(this,e)}growOperationsCount(t){t>=n(this,Ee).length&&b(this,qc,Zp).call(this,t,n(this,Ee))}get clipBox(){return n(this,at)}save(t){return u(this,at,{__proto__:n(this,at)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,at));if(s===null)return this;u(this,at,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,Ee)[t]=n(this,Ee)[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,Ee)[t]=n(this,Ee)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,Ee)[t]=n(this,Ee)[s]),this}pushBaseTransform(t){return n(this,an).push(I.multiplyByDOMMatrix(n(this,an).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,an).length>1&&n(this,an).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,St).set(Ui,0)),this}recordClipBox(t,e,s,i,r,a){const o=I.multiplyByDOMMatrix(n(this,an).at(-1),e.getTransform()),l=Ui.slice();I.axialAlignedBoundingBox([s,r,i,a],o,l);const h=I.intersect(n(this,at),l);return h?(n(this,at)[0]=h[0],n(this,at)[1]=h[1],n(this,at)[2]=h[2],n(this,at)[3]=h[3]):(n(this,at)[0]=n(this,at)[1]=1/0,n(this,at)[2]=n(this,at)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,at);if(o[0]===1/0)return this;const l=I.multiplyByDOMMatrix(n(this,an).at(-1),e.getTransform());if(o[0]===-1/0)return I.axialAlignedBoundingBox([s,r,i,a],l,n(this,St)),this;const h=Ui.slice();return I.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,St)[0]=wt(h[0],o[0],n(this,St)[0]),n(this,St)[1]=wt(h[1],o[1],n(this,St)[1]),n(this,St)[2]=wt(h[2],n(this,St)[2],o[2]),n(this,St)[3]=wt(h[3],n(this,St)[3],o[3]),this}recordFullPageBBox(t){return n(this,St)[0]=Math.max(0,n(this,at)[0]),n(this,St)[1]=Math.max(0,n(this,at)[1]),n(this,St)[2]=Math.min(n(this,Ea),n(this,at)[2]),n(this,St)[3]=Math.min(n(this,xa),n(this,at)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=Wm(n(this,St)[0]*256/n(this,Ea)),r=Wm(n(this,St)[1]*256/n(this,xa)),a=Xm(n(this,St)[2]*256/n(this,Ea)),o=Xm(n(this,St)[3]*256/n(this,xa));if(Ym(n(this,Ca),t,i,r,a,o),s)for(const l of s)for(const h of l)h!==t&&Ym(n(this,Ca),h,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,at)[0]=Math.max(n(this,at)[0],n(this,St)[0]),n(this,at)[1]=Math.max(n(this,at)[1],n(this,St)[1]),n(this,at)[2]=Math.min(n(this,at)[2],n(this,St)[2]),n(this,at)[3]=Math.min(n(this,at)[3],n(this,St)[3])),this}take(){return new p0(n(this,Ee),n(this,Ca))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}an=new WeakMap,at=new WeakMap,St=new WeakMap,Ea=new WeakMap,xa=new WeakMap,Ca=new WeakMap,Ee=new WeakMap,qc=new WeakSet,Zp=function(t,e){const s=new ArrayBuffer(t*4);u(this,Ca,new Uint8ClampedArray(s)),u(this,Ee,new Uint32Array(s)),e&&e.length>0?(n(this,Ee).set(e),n(this,Ee).fill(Jp,e.length)):n(this,Ee).fill(Jp)};var Ve,je,_a,js,vl,pr,gr,ut;class m0{constructor(t,e=!1){g(this,Ve,{__proto__:null});g(this,je,{__proto__:null,transform:[],moveText:[],sameLineText:[],[$o]:[]});g(this,_a,new Map);g(this,js,new Set);g(this,vl,new Map);g(this,pr);g(this,gr);g(this,ut);u(this,ut,t),e&&(u(this,pr,new Map),u(this,gr,(s,i)=>{Km(n(this,pr),i).dependencies.add(s)}))}get clipBox(){return n(this,ut).clipBox}growOperationsCount(t){n(this,ut).growOperationsCount(t)}save(t){return u(this,Ve,{__proto__:n(this,Ve)}),u(this,je,{__proto__:n(this,je),transform:{__proto__:n(this,je).transform},moveText:{__proto__:n(this,je).moveText},sameLineText:{__proto__:n(this,je).sameLineText},[$o]:{__proto__:n(this,je)[$o]}}),n(this,ut).save(t),this}restore(t){n(this,ut).restore(t,n(this,gr));const e=Object.getPrototypeOf(n(this,Ve));return e===null?this:(u(this,Ve,e),u(this,je,Object.getPrototypeOf(n(this,je))),this)}recordOpenMarker(t){return n(this,ut).recordOpenMarker(t,n(this,gr)),this}getOpenMarker(){return n(this,ut).getOpenMarker()}recordCloseMarker(t){return n(this,ut).recordCloseMarker(t,n(this,gr)),this}beginMarkedContent(t){return n(this,ut).beginMarkedContent(t),this}endMarkedContent(t){return n(this,ut).endMarkedContent(t,n(this,gr)),this}pushBaseTransform(t){return n(this,ut).pushBaseTransform(t),this}popBaseTransform(){return n(this,ut).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Ve)[t]=e,this}recordIncrementalData(t,e){return n(this,je)[t].push(e),this}resetIncrementalData(t,e){return n(this,je)[t].length=0,this}recordNamedData(t,e){return n(this,_a).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Ve)[t]=n(this,_a).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData($o,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Ve)&&this.recordFutureForcedDependency(e,n(this,Ve)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,js))this.recordFutureForcedDependency($o,t);return this}resetBBox(t){return n(this,ut).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,ut).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,ut).recordBBox(t,e,s,i,r,a),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,vl).get(s),h!==!1&&(c=[0,0,0,0],I.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&f0(i,-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 d=o();return l&&c&&h===void 0&&(h=c[0]<=r-d.actualBoundingBoxLeft&&c[2]>=r+d.actualBoundingBoxRight&&c[1]<=a-d.actualBoundingBoxAscent&&c[3]>=a+d.actualBoundingBoxDescent,n(this,vl).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,ut).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,Ve)[t]}recordDependencies(t,e){const s=n(this,js),i=n(this,Ve),r=n(this,je);for(const a of e)a in n(this,Ve)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,_a).has(e)&&n(this,js).add(n(this,_a).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[$o]),n(this,pr)){const i=Km(n(this,pr),t),{dependencies:r}=i;n(this,js).forEach(r.add,r),n(this,ut)._savesStack.forEach(r.add,r),n(this,ut)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,ut)._pendingBBoxIdx;return n(this,ut).recordOperation(t,e,[n(this,js),n(this,ut)._savesStack,n(this,ut)._markedContentStack]),s&&n(this,js).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,js));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===n(this,ut)._pendingBBoxIdx;return n(this,ut).bboxToClipBoxDropOperation(t),s&&n(this,js).clear(),this}take(){return n(this,vl).clear(),n(this,ut).take()}takeDebugMetadata(){return n(this,pr)}}Ve=new WeakMap,je=new WeakMap,_a=new WeakMap,js=new WeakMap,vl=new WeakMap,pr=new WeakMap,gr=new WeakMap,ut=new WeakMap;var ft,Nt,Ws,Sl,El;const Dm=class Dm{constructor(t,e,s){g(this,ft);g(this,Nt);g(this,Ws);g(this,Sl,0);g(this,El,0);if(t instanceof Dm&&n(t,Ws)===!!s)return t;u(this,ft,t),u(this,Nt,e),u(this,Ws,!!s)}get clipBox(){return n(this,ft).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return yt(this,El)._++,n(this,ft).save(n(this,Nt)),this}restore(t){return n(this,El)>0&&(n(this,ft).restore(n(this,Nt)),yt(this,El)._--),this}recordOpenMarker(t){return yt(this,Sl)._++,this}getOpenMarker(){return n(this,Sl)>0?n(this,Nt):n(this,ft).getOpenMarker()}recordCloseMarker(t){return yt(this,Sl)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,ft).pushBaseTransform(t),this}popBaseTransform(){return n(this,ft).popBaseTransform(),this}recordSimpleData(t,e){return n(this,ft).recordSimpleData(t,n(this,Nt)),this}recordIncrementalData(t,e){return n(this,ft).recordIncrementalData(t,n(this,Nt)),this}resetIncrementalData(t,e){return n(this,ft).resetIncrementalData(t,n(this,Nt)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,ft).recordSimpleDataFromNamed(t,e,n(this,Nt)),this}recordFutureForcedDependency(t,e){return n(this,ft).recordFutureForcedDependency(t,n(this,Nt)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,ft).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,ft).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Ws)||n(this,ft).resetBBox(n(this,Nt)),this}recordClipBox(t,e,s,i,r,a){return n(this,Ws)||n(this,ft).recordClipBox(n(this,Nt),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Ws)||n(this,ft).recordBBox(n(this,Nt),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Ws)||n(this,ft).recordCharacterBBox(n(this,Nt),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Ws)||n(this,ft).recordFullPageBBox(n(this,Nt)),this}getSimpleIndex(t){return n(this,ft).getSimpleIndex(t)}recordDependencies(t,e){return n(this,ft).recordDependencies(n(this,Nt),e),this}recordNamedDependency(t,e){return n(this,ft).recordNamedDependency(n(this,Nt),e),this}recordOperation(t){return n(this,ft).recordOperation(n(this,Nt),!0),this}recordShowTextOperation(t){return n(this,ft).recordShowTextOperation(n(this,Nt),!0),this}bboxToClipBoxDropOperation(t){return n(this,Ws)||n(this,ft).bboxToClipBoxDropOperation(n(this,Nt),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};ft=new WeakMap,Nt=new WeakMap,Ws=new WeakMap,Sl=new WeakMap,El=new WeakMap;let bc=Dm;const vs={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","filter","fillColor"]};var Ta,ka,Pa,Ma,Da,Qc;const cc=class cc{constructor(t){g(this,Ta);g(this,ka);g(this,Pa,4);g(this,Ma,0);g(this,Da,new(n(cc,Qc))(n(this,Pa)*6));u(this,Ta,t.width),u(this,ka,t.height)}record(t,e,s,i){if(n(this,Ma)===n(this,Pa)){u(this,Pa,n(this,Pa)*2);const o=new(n(cc,Qc))(n(this,Pa)*6);o.set(n(this,Da)),u(this,Da,o)}const r=mt(t);let a;if(i[0]!==1/0){const o=Ui.slice();I.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=I.intersect(i,o);if(!l)return;const[h,c,d,f]=l;if(h!==o[0]||c!==o[1]||d!==o[2]||f!==o[3]){const m=Math.atan2(r[1],r[0]),y=Math.abs(Math.sin(m)),A=Math.abs(Math.cos(m));if(y<1e-6||A<1e-6||Math.abs(y-A)<1e-6)a=[h,c,h,f,d,c];else{const w=d-h,v=f-c,S=y*y,E=A*A,x=A*y,C=E-S,_=(v*E-w*x)/C,k=(v*x-w*S)/C;a=[h+k,c,h,c+_,d,f-_]}}}a||(a=[0,-s,0,0,e,-s],I.applyTransform(a,r,0),I.applyTransform(a,r,2),I.applyTransform(a,r,4)),a[0]/=n(this,Ta),a[1]/=n(this,ka),a[2]/=n(this,Ta),a[3]/=n(this,ka),a[4]/=n(this,Ta),a[5]/=n(this,ka),n(this,Da).set(a,n(this,Ma)*6),yt(this,Ma)._++}take(){return n(this,Da).subarray(0,n(this,Ma)*6)}};Ta=new WeakMap,ka=new WeakMap,Pa=new WeakMap,Ma=new WeakMap,Da=new WeakMap,Qc=new WeakMap,g(cc,Qc,ot.isFloat16ArraySupported?Float16Array:Float32Array);let tg=cc;const qm=new RegExp("\\p{Cc}","u");function b0(p){const t=p[0];if(p.length<2||t!=='"'&&t!=="'"||p.at(-1)!==t)return!1;const e=p.length-1;for(let s=1;s<e;s++){const i=p[s];if(i===t||qm.test(i)||i==="\\"&&(++s>=e||qm.test(p[s])))return!1}return!0}function Qm(p){return b0(p)?p:`"${p.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}var Ia,xl,Xs,Lh,ry,ay;class y0{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){g(this,Lh);g(this,Ia,new Set);g(this,xl,new Set);g(this,Xs,null);this._document=t,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){n(this,Ia).add(t),this._document.fonts.add(t)}removeNativeFontFace(t){n(this,Ia).delete(t),this._document.fonts.delete(t)}insertRule(t){const e=b(this,Lh,ry).call(this);e.insertRule(t,e.cssRules.length)}clear(){var t;for(const e of n(this,Ia))this._document.fonts.delete(e);if(n(this,Ia).clear(),n(this,xl).clear(),n(this,Xs)){const{adoptedStyleSheets:e}=this._document;e!=null&&e.includes(n(this,Xs))&&(this._document.adoptedStyleSheets=e.filter(s=>s!==n(this,Xs))),u(this,Xs,null)}(t=this.styleElement)==null||t.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,xl).has(t.loadedName))){if(Gt(!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,xl).add(i),s==null||s(t)}catch{X(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}st("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 X(`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 b(this,Lh,ay).call(this,t)}}get isFontLoadingAPISupported(){var t;return F(this,"isFontLoadingAPISupported",!!((t=this._document)!=null&&t.fonts))}get isSyncFontLoadingSupported(){return F(this,"isSyncFontLoadingSupported",ps||ot.platform.isFirefox)}}Ia=new WeakMap,xl=new WeakMap,Xs=new WeakMap,Lh=new WeakSet,ry=function(){var e;if(n(this,Xs))return n(this,Xs);const t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:s}=this._document;if(s){const i=new t;return s.push(i),u(this,Xs,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),u(this,Xs,this.styleElement.sheet)},ay=function(t){function e(){for(Gt(!a.done,"completeRequest() cannot be called twice."),a.done=!0;s.length>0&&s[0].done;){const P=s.shift();setTimeout(P.resolve,0)}}const{loadingRequests:s}=this,{promise:i,resolve:r}=Promise.withResolvers(),a={done:!1,resolve:r};s.push(a),this._loadTestFont??(this._loadTestFont=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="));function o(P,D){return P.charCodeAt(D)<<24|P.charCodeAt(D+1)<<16|P.charCodeAt(D+2)<<8|P.charCodeAt(D+3)&255}function l(P){return String.fromCharCode(P>>24&255,P>>16&255,P>>8&255,P&255)}function h(P,D,N,Z){const Q=P.substring(0,D),Y=P.substring(D+N);return Q+Z+Y}let c,d;const f=this._document.createElement("canvas");f.width=1,f.height=1;const m=f.getContext("2d");let y=0;function A(P,D){if(++y>30){X("Load test font never loaded."),D();return}if(m.font="30px "+P,m.fillText(".",0,20),m.getImageData(0,0,1,1).data[3]>0){D();return}setTimeout(A.bind(null,P,D))}const w=`lt${Date.now()}${this.loadTestFontId++}`;let v=this._loadTestFont;v=h(v,976,w.length,w);const E=16,x=1482184792;let C=o(v,E);for(c=0,d=w.length-3;c<d;c+=4)C=C-x+o(w,c)|0;c<w.length&&(C=C-x+o(w+"XXX",c)|0),v=h(v,E,4,l(C));const _=`url(data:font/opentype;base64,${btoa(v)});`,k=`@font-face {font-family:"${w}";src:${_}}`;this.insertRule(k);const M=this._document.createElement("div");M.style.visibility="hidden",M.style.width=M.style.height="10px",M.style.position="absolute",M.style.top=M.style.left="0px";for(const P of[t.loadedName,w]){const D=this._document.createElement("span");D.textContent="Hi",D.style.fontFamily=P,M.append(D)}return this._document.body.append(M),A(w,()=>{M.remove(),e()}),i};var Jc,Bt;class A0{constructor(t,e=null,s,i){g(this,Jc,new Map);g(this,Bt);u(this,Bt,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){var s;const{data:t}=this;if(!t||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,t,{});else{const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(Qm(this.cssFontInfo.fontFamily),t,i)}return(s=this._inspectFont)==null||s.call(this,this),e}createFontFaceRule(){var i;const{data:t}=this;if(!t||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t.toBase64()});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let r=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(r+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:${Qm(this.cssFontInfo.fontFamily)};${r}src:${e}}`}return(i=this._inspectFont)==null||i.call(this,this,e),s}getPathGenerator(t,e){let s=n(this,Jc).get(e);if(s)return s;const i=`${this.loadedName}_path_${e}`;let r;try{r=t.get(i)}catch(a){X(`getPathGenerator - ignoring character: "${a}".`)}return s=xb(r==null?void 0:r.path),this.fontExtraProperties||t.delete(i),n(this,Jc).set(e,s),s}get black(){return n(this,Bt).black}get bold(){return n(this,Bt).bold}get disableFontFace(){return n(this,Bt).disableFontFace}set disableFontFace(t){F(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,Bt).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,Bt).isInvalidPDFjsFont}get isType3Font(){return n(this,Bt).isType3Font}get italic(){return n(this,Bt).italic}get missingFile(){return n(this,Bt).missingFile}get remeasure(){return n(this,Bt).remeasure}get vertical(){return n(this,Bt).vertical}get bbox(){return n(this,Bt).bbox}get fontMatrix(){return n(this,Bt).fontMatrix}get fallbackName(){return n(this,Bt).fallbackName}get loadedName(){return n(this,Bt).loadedName}get mimetype(){return this.missingFile?null:"font/opentype"}get data(){return n(this,Bt).data}clearData(){n(this,Bt).clearData()}get cssFontInfo(){return n(this,Bt).cssFontInfo}get systemFontInfo(){return n(this,Bt).systemFontInfo}}Jc=new WeakMap,Bt=new WeakMap;class oy{}T(oy,"strings",["fontFamily","fontWeight","italicAngle"]);class ly{}T(ly,"strings",["css","loadedName","baseFontName","src"]);const ci=class ci{};T(ci,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),T(ci,"strings",["fallbackName","loadedName"]),T(ci,"OFFSET_BBOX",Math.ceil(ci.bools.length*2/8)),T(ci,"OFFSET_FONT_MATRIX",ci.OFFSET_BBOX+1+8),T(ci,"OFFSET_STRINGS",ci.OFFSET_FONT_MATRIX+1+48);let Un=ci;class Re{}T(Re,"KIND",0),T(Re,"HAS_BBOX",1),T(Re,"HAS_BACKGROUND",2),T(Re,"SHADING_TYPE",3),T(Re,"N_COORD",4),T(Re,"N_COLOR",8),T(Re,"N_STOP",12),T(Re,"N_FIGURES",16);class w0{static get decoder(){return F(this,"decoder",new TextDecoder)}static get encoder(){return F(this,"encoder",new TextEncoder)}}function lc(p,t,e,s=0){const{decoder:i}=w0;for(let a=0;a<e;a++)s+=t.getUint32(s)+4;const r=t.getUint32(s);return i.decode(new Uint8Array(p,s+4,r))}var Zc,td,Cl,Du;class v0{constructor(t){g(this,Cl);g(this,Zc);g(this,td);u(this,Zc,t),u(this,td,new DataView(t))}get fontFamily(){return F(this,"fontFamily",b(this,Cl,Du).call(this,0))}get fontWeight(){return F(this,"fontWeight",b(this,Cl,Du).call(this,1))}get italicAngle(){return F(this,"italicAngle",b(this,Cl,Du).call(this,2))}}Zc=new WeakMap,td=new WeakMap,Cl=new WeakSet,Du=function(t){return Gt(t<oy.strings.length,"Invalid string index"),lc(n(this,Zc),n(this,td),t)};var La,mr,Fa,Vh;class S0{constructor(t){g(this,Fa);g(this,La);g(this,mr);u(this,La,t),u(this,mr,new DataView(t))}get css(){return F(this,"css",b(this,Fa,Vh).call(this,0))}get loadedName(){return F(this,"loadedName",b(this,Fa,Vh).call(this,1))}get baseFontName(){return F(this,"baseFontName",b(this,Fa,Vh).call(this,2))}get src(){return F(this,"src",b(this,Fa,Vh).call(this,3))}get style(){let t=0;t+=4+n(this,mr).getUint32(t);const e=lc(n(this,La),n(this,mr),0,t),s=lc(n(this,La),n(this,mr),1,t);return F(this,"style",{style:e,weight:s})}}La=new WeakMap,mr=new WeakMap,Fa=new WeakSet,Vh=function(t){return Gt(t<ly.strings.length,"Invalid string index"),lc(n(this,La),n(this,mr),t,4)};var Ys,Ds,Tt,Gs,eg,sg,jh;class E0{constructor(t){g(this,Tt);g(this,Ys);g(this,Ds);u(this,Ys,t),u(this,Ds,new DataView(t))}get black(){return F(this,"black",b(this,Tt,Gs).call(this,0))}get bold(){return F(this,"bold",b(this,Tt,Gs).call(this,1))}get disableFontFace(){return F(this,"disableFontFace",b(this,Tt,Gs).call(this,2))}get fontExtraProperties(){return F(this,"fontExtraProperties",b(this,Tt,Gs).call(this,3))}get isInvalidPDFjsFont(){return F(this,"isInvalidPDFjsFont",b(this,Tt,Gs).call(this,4))}get isType3Font(){return F(this,"isType3Font",b(this,Tt,Gs).call(this,5))}get italic(){return F(this,"italic",b(this,Tt,Gs).call(this,6))}get missingFile(){return F(this,"missingFile",b(this,Tt,Gs).call(this,7))}get remeasure(){return F(this,"remeasure",b(this,Tt,Gs).call(this,8))}get vertical(){return F(this,"vertical",b(this,Tt,Gs).call(this,9))}get bbox(){return F(this,"bbox",b(this,Tt,eg).call(this,Un.OFFSET_BBOX,4,"getInt16",2))}get fontMatrix(){return F(this,"fontMatrix",b(this,Tt,eg).call(this,Un.OFFSET_FONT_MATRIX,6,"getFloat64",8))}get fallbackName(){return F(this,"fallbackName",b(this,Tt,sg).call(this,0))}get loadedName(){return F(this,"loadedName",b(this,Tt,sg).call(this,1))}get data(){const{offset:t,length:e}=b(this,Tt,jh).call(this,2);return e?new Uint8Array(n(this,Ys),t+4,e):void 0}clearData(){const{offset:t,length:e}=b(this,Tt,jh).call(this,2);e&&(n(this,Ds).setUint32(t,0),u(this,Ys,new Uint8Array(n(this,Ys),0,t+4).slice().buffer),u(this,Ds,new DataView(n(this,Ys))))}get cssFontInfo(){const{offset:t,length:e}=b(this,Tt,jh).call(this,1);let s=null;if(e){const i=new Uint8Array(n(this,Ys),t+4,e).slice();s=new v0(i.buffer)}return F(this,"cssFontInfo",s)}get systemFontInfo(){const{offset:t,length:e}=b(this,Tt,jh).call(this,0);let s=null;if(e){const i=new Uint8Array(n(this,Ys),t+4,e).slice();s=new S0(i.buffer)}return F(this,"systemFontInfo",s)}}Ys=new WeakMap,Ds=new WeakMap,Tt=new WeakSet,Gs=function(t){Gt(t<Un.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=n(this,Ds).getUint8(e)>>s&3;return i===0?void 0:i===2},eg=function(t,e,s,i){const r=n(this,Ds).getUint8(t++);if(r===0)return;Gt(r===e,"Invalid array length.");const a=new Array(r);for(let o=0;o<r;o++)a[o]=n(this,Ds)[s](t,!0),t+=i;return a},sg=function(t){return Gt(t<Un.strings.length,"Invalid string index"),lc(n(this,Ys),n(this,Ds),t,Un.OFFSET_STRINGS+4)},jh=function(t){let e=Un.OFFSET_STRINGS;for(let i=0;i<=t;i++)e+=4+n(this,Ds).getUint32(e);const s=n(this,Ds).getUint32(e);return{offset:e,length:s}};class x0{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Re.KIND],s=!!this.data[Re.HAS_BBOX],i=!!this.data[Re.HAS_BACKGROUND],r=t.getUint32(Re.N_COORD,!0),a=t.getUint32(Re.N_COLOR,!0),o=t.getUint32(Re.N_STOP,!0);let l=20;const h=new Float32Array(this.buffer,l,r*2);l+=r*8;const c=new Uint8Array(this.buffer,l,a*4);l+=a*4;const d=[];for(let y=0;y<o;++y){const A=t.getFloat32(l,!0);l+=4;const w=t.getUint32(l,!0);l+=4,d.push([A,`#${w.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let y=0;y<4;++y)f.push(t.getFloat32(l,!0)),l+=4}let m=null;if(i&&(m=new Uint8Array(this.buffer,l,3),l+=3),e===1)return["RadialAxial","axial",f,d,[h[0],h[1]],[h[2],h[3]],null,null];if(e===2)return["RadialAxial","radial",f,d,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(e===3){const y=this.data[Re.SHADING_TYPE];let A=null;if(h.length>0){A=Ui.slice();for(let w=0,v=h.length;w<v;w+=2)I.pointBoundingBox(h[w],h[w+1],A)}return["Mesh",y,h,c,r,A,f,m]}throw new Error(`Unsupported pattern kind: ${e}`)}}var _l;class C0{constructor(t){g(this,_l);u(this,_l,t)}get path(){return ot.isFloat16ArraySupported?new Float16Array(n(this,_l)):new Float32Array(n(this,_l))}}_l=new WeakMap;function _0(p){if(p instanceof URL)return p;if(typeof p=="string"){if(ps){if(/^[a-z][a-z0-9\-+.]+:/i.test(p))return new URL(p);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(p))}const t=URL.parse(p,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function T0(p){if(ps&&typeof Buffer<"u"&&p instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength)return p;if(typeof p=="string")return Zf(p);if(p instanceof ArrayBuffer||ArrayBuffer.isView(p)||typeof p=="object"&&!isNaN(p==null?void 0:p.length))return new Uint8Array(p);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function mu(p){if(typeof p!="string")return null;if(p.endsWith("/"))return p;throw new Error(`Invalid factory url: "${p}" must include trailing slash.`)}const ig=p=>typeof p=="object"&&Number.isInteger(p==null?void 0:p.num)&&p.num>=0&&Number.isInteger(p==null?void 0:p.gen)&&p.gen>=0,k0=p=>typeof p=="object"&&typeof(p==null?void 0:p.name)=="string",hy=i0.bind(null,ig,k0);var on,kf;class P0{constructor(){g(this,on,new Map);g(this,kf,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,kf).then(()=>{for(const[i]of n(this,on))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){X("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,on).set(e,i)}removeEventListener(t,e){const s=n(this,on).get(e);s==null||s(),n(this,on).delete(e)}terminate(){for(const[,t]of n(this,on))t==null||t();n(this,on).clear()}}on=new WeakMap,kf=new WeakMap;const bu={DATA:1,ERROR:2},Vt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Jm(){}function Ue(p){if(p instanceof Fn||p instanceof df||p instanceof cf||p instanceof fc||p instanceof bp)return p;switch(p instanceof Error||typeof p=="object"&&p!==null||st('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),p.name){case"AbortException":return new Fn(p.message);case"InvalidPDFException":return new df(p.message);case"PasswordException":return new cf(p.message,p.code);case"ResponseException":return new fc(p.message,p.status,p.missing);case"UnknownErrorException":return new bp(p.message,p.details)}return new bp(p.message,p.toString())}var Tl,kl,Pf,Si,Pl,Ks,ln,Mf,Ml,Ra,Hs,cy,dy,uy,Iu;class Wh{constructor(t,e,s){g(this,Hs);g(this,Tl,new Map);g(this,kl,new Map);g(this,Pf,1);g(this,Si);g(this,Pl,new AbortController);g(this,Ks);g(this,ln,new Map);g(this,Mf,1);g(this,Ml,new Map);g(this,Ra);u(this,Ks,t),u(this,Ra,e),u(this,Si,s),s.addEventListener("message",b(this,Hs,cy).bind(this),{signal:n(this,Pl).signal})}on(t,e){const s=n(this,Tl);if(s.has(t))throw new Error(`There is already a "${t}" handler.`);s.set(t,e)}send(t,e,s){n(this,Si).postMessage({sourceName:n(this,Ks),targetName:n(this,Ra),action:t,data:e},s)}sendWithPromise(t,e,s){const i=yt(this,Pf)._++,r=Promise.withResolvers();n(this,kl).set(i,r);try{n(this,Si).postMessage({sourceName:n(this,Ks),targetName:n(this,Ra),action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=yt(this,Mf)._++,a=n(this,Ks),o=n(this,Ra),l=n(this,Si);return new ReadableStream({start:h=>{const c=Promise.withResolvers();return n(this,ln).set(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 n(this,ln).get(r).pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:Vt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{Gt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return n(this,ln).get(r).cancelCall=c,n(this,ln).get(r).isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Vt.CANCEL,streamId:r,reason:Ue(h)}),c.promise}},s)}destroy(){var t;(t=n(this,Pl))==null||t.abort(),u(this,Pl,null)}}Tl=new WeakMap,kl=new WeakMap,Pf=new WeakMap,Si=new WeakMap,Pl=new WeakMap,Ks=new WeakMap,ln=new WeakMap,Mf=new WeakMap,Ml=new WeakMap,Ra=new WeakMap,Hs=new WeakSet,cy=function({data:t}){if(t.targetName!==n(this,Ks))return;if(t.stream){b(this,Hs,uy).call(this,t);return}if(t.callback){const{callbackId:s,callback:i}=t,r=n(this,kl).get(s);if(!r)throw new Error(`Cannot resolve callback ${s}`);if(n(this,kl).delete(s),i===bu.DATA)r.resolve(t.data);else if(i===bu.ERROR)r.reject(Ue(t.reason));else throw new Error("Unexpected callback case");return}const e=n(this,Tl).get(t.action);if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=n(this,Ks),i=t.sourceName,r=n(this,Si);Promise.try(e,t.data).then(a=>{r.postMessage({sourceName:s,targetName:i,callback:bu.DATA,callbackId:t.callbackId,data:a})},a=>{r.postMessage({sourceName:s,targetName:i,callback:bu.ERROR,callbackId:t.callbackId,reason:Ue(a)})});return}if(t.streamId){b(this,Hs,dy).call(this,t);return}e(t.data)},dy=function(t){const e=t.streamId,s=n(this,Ks),i=t.sourceName,r=n(this,Si),a=n(this,Ml),o=n(this,Tl).get(t.action),l={enqueue(h,c=1,d){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:Vt.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Vt.CLOSE,streamId:e}),a.delete(e))},error(h){Gt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Vt.ERROR,streamId:e,reason:Ue(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,a.set(e,l),Promise.try(o,t.data,l).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:Vt.START_COMPLETE,streamId:e,success:!0})},h=>{r.postMessage({sourceName:s,targetName:i,stream:Vt.START_COMPLETE,streamId:e,reason:Ue(h)})})},uy=function(t){const e=t.streamId,s=n(this,Ks),i=t.sourceName,r=n(this,Si),a=n(this,ln).get(e),o=n(this,Ml).get(e);switch(t.stream){case Vt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(Ue(t.reason));break;case Vt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(Ue(t.reason));break;case Vt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:Vt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Jm).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:Vt.PULL_COMPLETE,streamId:e,success:!0})},h=>{r.postMessage({sourceName:s,targetName:i,stream:Vt.PULL_COMPLETE,streamId:e,reason:Ue(h)})});break;case Vt.ENQUEUE:if(Gt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Vt.CLOSE:if(Gt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Hs,Iu).call(this,a,e);break;case Vt.ERROR:Gt(a,"error should have stream controller"),a.controller.error(Ue(t.reason)),b(this,Hs,Iu).call(this,a,e);break;case Vt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(Ue(t.reason)),b(this,Hs,Iu).call(this,a,e);break;case Vt.CANCEL:if(!o)break;const l=Ue(t.reason);Promise.try(o.onCancel||Jm,l).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:Vt.CANCEL_COMPLETE,streamId:e,success:!0})},h=>{r.postMessage({sourceName:s,targetName:i,stream:Vt.CANCEL_COMPLETE,streamId:e,reason:Ue(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,n(this,Ml).delete(e);break;default:throw new Error("Unexpected stream case")}},Iu=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]),n(this,ln).delete(e)};var Df;class fy{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){g(this,Df,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:st(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${n(this,Df)[t]} data at: ${i}`)})}async _fetch(t,e){st("Abstract method `_fetch` called.")}}Df=new WeakMap;class Zm extends fy{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await sp(t,s);return i instanceof Uint8Array?i:Zf(i)}}var ed;class py{constructor({enableHWA:t=!1}){g(this,ed,!1);u(this,ed,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,ed)})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){st("Abstract method `_createCanvas` called.")}}ed=new WeakMap;class M0 extends py{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 gy{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var Oa,Dl,hn,Ei,ae,Na,br,L,se,Xh,li,Lu,Kr,my,ng,qr,Yh,Kh,rg,qh,by,ag,yy;class D0 extends gy{constructor({docId:e,ownerDocument:s=globalThis.document}){super();g(this,L);g(this,Oa);g(this,Dl);g(this,hn);g(this,Ei);g(this,ae);g(this,Na);g(this,br,0);u(this,Ei,e),u(this,ae,s)}addFilter(e){if(!e)return"none";let s=n(this,L,se).get(e);if(s)return s;const[i,r,a]=b(this,L,Lu).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,L,se).get(o),s)return n(this,L,se).set(e,s),s;const l=`g_${n(this,Ei)}_transfer_map_${yt(this,br)._++}`,h=b(this,L,Kr).call(this,l);n(this,L,se).set(e,h),n(this,L,se).set(o,h);const c=b(this,L,qr).call(this,l);return b(this,L,Kh).call(this,i,r,a,c),h}addHCMFilter(e,s){var y;const i=`${e}-${s}`,r="base";let a=n(this,L,Xh).get(r);if((a==null?void 0:a.key)===i||(a?((y=a.filter)==null||y.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,L,Xh).set(r,a)),!e||!s))return a.url;const o=b(this,L,qh).call(this,e);e=I.makeHexColor(...o);const l=b(this,L,qh).call(this,s);if(s=I.makeHexColor(...l),b(this,L,ag).call(this),e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=Array.from({length:256},(A,w)=>Pp(w/255)).join(","),d=`g_${n(this,Ei)}_hcm_filter`,f=a.filter=b(this,L,qr).call(this,d);b(this,L,Kh).call(this,c,c,c,f),b(this,L,ng).call(this,f);const m=(A,w)=>{const v=o[A]/255,S=l[A]/255,E=new Array(w+1);for(let x=0;x<=w;x++)E[x]=v+x/w*(S-v);return E.join(",")};return b(this,L,Kh).call(this,m(0,5),m(1,5),m(2,5),f),a.url=b(this,L,Kr).call(this,d),a.url}addSelectionHCMFilter(e,s){return this.addHighlightHCMFilter("selection",e,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const s=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return s==="none"||!ot.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=n(this,L,se).get(e);if(s)return s;const[i]=b(this,L,Lu).call(this,[e]),r=`alpha_${i}`;if(s=n(this,L,se).get(r),s)return n(this,L,se).set(e,s),s;const a=`g_${n(this,Ei)}_alpha_map_${yt(this,br)._++}`,o=b(this,L,Kr).call(this,a);n(this,L,se).set(e,o),n(this,L,se).set(r,o);const l=b(this,L,qr).call(this,a);return b(this,L,rg).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,L,se).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,L,Lu).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,L,se).get(r),s)return n(this,L,se).set(e,s),s;const a=`g_${n(this,Ei)}_luminosity_map_${yt(this,br)._++}`,o=b(this,L,Kr).call(this,a);n(this,L,se).set(e,o),n(this,L,se).set(r,o);const l=b(this,L,qr).call(this,a);return b(this,L,my).call(this,l),e&&b(this,L,rg).call(this,i,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${s}`,r=n(this,L,se).get(i);if(r)return r;const a=`g_${n(this,Ei)}_knockout_filter_${yt(this,br)._++}`,o=b(this,L,Kr).call(this,a);n(this,L,se).set(i,o);const l=b(this,L,qr).call(this,a),h=n(this,ae).createElementNS(Fe,"feComponentTransfer");l.append(h);const c=n(this,ae).createElementNS(Fe,"feFuncA");return c.setAttribute("type","linear"),c.setAttribute("slope",`${s}`),c.setAttribute("intercept","0"),h.append(c),o}addHighlightHCMFilter(e,s,i,r,a){var S;const o=`${s}-${i}-${r}-${a}`;let l=n(this,L,Xh).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,L,Xh).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,L,qh).bind(this));let d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[m,y]=[r,a].map(b(this,L,yy).bind(this));f<d&&([d,f,m,y]=[f,d,y,m]),b(this,L,ag).call(this);const A=(E,x,C)=>{const _=new Array(256),k=(f-d)/C,M=E/255,P=(x-E)/(255*C);let D=0;for(let N=0;N<=C;N++){const Z=Math.round(d+N*k),Q=M+N*P;for(let Y=D;Y<=Z;Y++)_[Y]=Q;D=Z+1}for(let N=D;N<256;N++)_[N]=_[D-1];return _.join(",")},w=`g_${n(this,Ei)}_hcm_${e}_filter`,v=l.filter=b(this,L,qr).call(this,w);return b(this,L,ng).call(this,v),b(this,L,Kh).call(this,A(m[0],y[0],5),A(m[1],y[1],5),A(m[2],y[2],5),v),l.url=b(this,L,Kr).call(this,w),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,Na))!=null&&s.size)||((i=n(this,hn))==null||i.parentNode.parentNode.remove(),u(this,hn,null),(r=n(this,Dl))==null||r.clear(),u(this,Dl,null),(a=n(this,Na))==null||a.clear(),u(this,Na,null),u(this,br,0))}}Oa=new WeakMap,Dl=new WeakMap,hn=new WeakMap,Ei=new WeakMap,ae=new WeakMap,Na=new WeakMap,br=new WeakMap,L=new WeakSet,se=function(){return n(this,Dl)||u(this,Dl,new Map)},Xh=function(){return n(this,Na)||u(this,Na,new Map)},li=function(){if(!n(this,hn)){const e=n(this,ae).createElement("div"),{style:s}=e;s.colorScheme="only light",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,ae).createElementNS(Fe,"svg");i.setAttribute("width",0),i.setAttribute("height",0),u(this,hn,n(this,ae).createElementNS(Fe,"defs")),e.append(i),i.append(n(this,hn)),n(this,ae).body.append(e)}return n(this,hn)},Lu=function(e){const s=o=>o&&Array.from(o,l=>l/255).join(",");if(e.length===1){const o=s(e[0]);return[o,o,o]}const[i,r,a]=e;return[s(i),s(r),s(a)]},Kr=function(e){if(n(this,Oa)===void 0){u(this,Oa,"");const s=n(this,ae).URL;s!==n(this,ae).baseURI&&(fu(s)?X('#createUrl: ignore "data:"-URL for performance reasons.'):u(this,Oa,mm(s,"")))}return`url(${n(this,Oa)}#${e})`},my=function(e){const s=n(this,ae).createElementNS(Fe,"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)},ng=function(e){const s=n(this,ae).createElementNS(Fe,"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)},qr=function(e){const s=n(this,ae).createElementNS(Fe,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,L,li).append(s),s},Yh=function(e,s,i){if(!i)return;const r=n(this,ae).createElementNS(Fe,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Kh=function(e,s,i,r){const a=n(this,ae).createElementNS(Fe,"feComponentTransfer");r.append(a),b(this,L,Yh).call(this,a,"feFuncR",e),b(this,L,Yh).call(this,a,"feFuncG",s),b(this,L,Yh).call(this,a,"feFuncB",i)},rg=function(e,s){const i=n(this,ae).createElementNS(Fe,"feComponentTransfer");s.append(i),b(this,L,Yh).call(this,i,"feFuncA",e)},qh=function(e){return n(this,L,li).style.color="CanvasText",n(this,L,li).style.backgroundColor=e,Rh(getComputedStyle(n(this,L,li)).getPropertyValue("background-color"))},by=function(e){return n(this,L,li).style.color="CanvasText",n(this,L,li).style.backgroundColor=e,Uo(getComputedStyle(n(this,L,li)).getPropertyValue("background-color"))},ag=function(){n(this,L,li).style.color="",n(this,L,li).style.backgroundColor=""},yy=function(e){const[s,i,r,a]=b(this,L,by).call(this,e);if(a===1)return[s,i,r];const[o,l,h]=b(this,L,qh).call(this,"Canvas");return[vp(s,o,a),vp(i,l,a),vp(r,h,a)]};function vp(p,t,e){return Math.round(e*p+(1-e)*t)}ps&&X("Please use the `legacy` build in Node.js environments.");async function I0(p){const e=await process.getBuiltinModule("fs/promises").readFile(p);return new Uint8Array(e)}class L0 extends gy{}class F0 extends py{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class R0 extends fy{async _fetch(t,e){return I0(t)}}function Ay({src:p,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ot.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=s&7,f=l^h,m=p.length;e=new Uint32Array(e.buffer);let y=0;for(let A=0;A<i;++A){for(const v=t+c;t<v;++t,y+=8){const S=p[t];e[y]=l^-(S>>7&1)&f,e[y+1]=l^-(S>>6&1)&f,e[y+2]=l^-(S>>5&1)&f,e[y+3]=l^-(S>>4&1)&f,e[y+4]=l^-(S>>3&1)&f,e[y+5]=l^-(S>>2&1)&f,e[y+6]=l^-(S>>1&1)&f,e[y+7]=l^-(S&1)&f}if(d===0)continue;const w=t<m?p[t++]:255;for(let v=0;v<d;++v,++y)e[y]=l^-(w>>7-v&1)&f}return{srcPos:t,destPos:y}}function O0({src:p,srcPos:t=0,dest:e,destPos:s=0,width:i,height:r}){let a=0;const o=i*r*3,l=o>>2,h=new Uint32Array(p.buffer,t,l),c=ot.isLittleEndian?4278190080:255;if(ot.isLittleEndian){for(;a<l-2;a+=3,s+=4){const d=h[a],f=h[a+1],m=h[a+2];e[s]=d|c,e[s+1]=d>>>24|f<<8|c,e[s+2]=f>>>16|m<<16|c,e[s+3]=m>>>8|c}for(let d=t+a*4,f=t+o;d<f;d+=3)e[s++]=p[d]|p[d+1]<<8|p[d+2]<<16|c}else{for(;a<l-2;a+=3,s+=4){const d=h[a],f=h[a+1],m=h[a+2];e[s]=d|c,e[s+1]=d<<24|f>>>8|c,e[s+2]=f<<16|m>>>16|c,e[s+3]=m<<8|c}for(let d=t+a*4,f=t+o;d<f;d+=3)e[s++]=p[d]<<24|p[d+1]<<16|p[d+2]<<8|c}return{srcPos:t+o,destPos:s}}const N0=`
3
3
  struct Uniforms {
4
4
  offsetX : f32,
@@ -52,4 +52,4 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
52
52
  `),position:E,pageIndex:x-1,rect:c.slice(0),rotation:d,annotationElementId:f,id:f,deleted:!1,popupRef:m,comment:(A==null?void 0:A.str)||null,richText:y,creationDate:w,modificationDate:v}}const a=await super.deserialize(e,s,i);return u(a,ls,e.fontSize),a.color=I.makeHexColor(...e.color),u(a,os,b(o=vt,Ln,Hg).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=gt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,ls),value:b(this,qt,dA).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!b(this,qt,uA).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,ls)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,os).split(`
53
53
  `)){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,os)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};os=new WeakMap,Gd=new WeakMap,yo=new WeakMap,ls=new WeakMap,qt=new WeakSet,lA=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,ls))*this.parentScale),u(this,ls,r),b(this,qt,Yu).call(this)},i=n(this,ls);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:et.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},hA=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:et.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},cA=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=vt,Ln,Ku).call(i,r)),s=r);return e.join(`
54
54
  `)},Yu=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()},Ln=new WeakSet,Ku=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(wu,"")},qu=function(){if(this.editorDiv.replaceChildren(),!!n(this,os))for(const e of n(this,os).split(`
55
- `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},dA=function(){return n(this,os).replaceAll(" "," ")},Hg=function(e){return e.replaceAll(" "," ")},uA=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(vt,Ln),T(vt,"_freeTextDefaultContent",""),T(vt,"_internalPadding",0),T(vt,"_defaultColor",null),T(vt,"_defaultFontSize",10),T(vt,"_type","freetext"),T(vt,"_editorType",W.FREETEXT);let Bg=vt;var Ao;class Cm{constructor(){g(this,Ao,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,Ao)[t]=e}toSVGProperties(){const t=n(this,Ao);return u(this,Ao,Object.create(null)),{root:t}}reset(){u(this,Ao,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}Ao=new WeakMap;var oh,lh,Wt,wo,vo,hh,V,Ug,Gg,$g,zg,tc,Vg,jg,Wg,ec,fA,Qu,sc,Xo;const q=class q extends gt{constructor(e){super(e);g(this,V);g(this,oh,null);g(this,lh);T(this,"_clipPathId",null);T(this,"_colorPicker",null);T(this,"_drawId",null);T(this,"_drawOutlines",null);T(this,"_focusDrawId",null);u(this,lh,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,V,Ug).call(this,e),b(this,V,ec).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){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(q,Wt).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=this._drawOutlines.updateProperty(s,l);h&&b(this,V,sc).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};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})}_updateColorAndOpacity(e,s,i=this.colorAndOpacityType){const r=this.constructor.typesMap.get(this.colorType),a=this._opacityName,o=this._drawingOptions,l=o[r],h=o[a],c=(d,f)=>{var m;o.updateProperty(r,d),o.updateProperty(a,f),this._drawOutlines.updateProperty(r,d),this._drawOutlines.updateProperty(a,f),(m=this.parent)==null||m.drawLayer.updateProperties(this._drawId,o.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:c.bind(this,e,s),undo:c.bind(this,l,h),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(b(this,V,Qu).call(this)),{bbox:b(this,V,Xo).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(b(this,V,Qu).call(this)),{bbox:b(this,V,Xo).call(this)})),b(this,V,zg).call(this)}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,V,Xo).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(b(this,V,Qu).call(this),this.parentDimensions),{bbox:b(this,V,Xo).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}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit(),this._mustBeDisabledOnCommit&&(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,lh)&&(u(this,lh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),b(this,V,Wg).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,V,ec).call(this),b(this,V,sc).call(this,this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,V,Wg).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,V,ec).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),b(this,V,Vg).call(this),s&&this.select()}rotate(e=this.parentRotation){if(!this.parent||this._drawId===null)return;const s=(e-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties({bbox:b(this,V,Xo).call(this,e)},this._drawOutlines.updateRotation(s))),b(this,V,zg).call(this,s)}show(e=this._isVisible){super.show(e),b(this,V,Vg).call(this)}select(){super.select(),b(this,V,tc).call(this,{hovered:!1,selected:!0})}unselect(){super.unselect(),b(this,V,tc).call(this,{selected:!1})}pointerover(){this.isSelected||b(this,V,tc).call(this,{hovered:!0})}pointerleave(){this.isSelected||b(this,V,tc).call(this,{hovered:!1})}onScaleChanging(){if(!this.parent)return;const e=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);e&&b(this,V,sc).call(this,e)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();this.constructor._hasDrawClass&&i.classList.add("draw");const r=u(this,oh,document.createElement("div"));return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this._clipPathId&&(r.style.clipPath=this._clipPathId),Mb(this,r,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e){st("Not implemented")}static _getDrawingTarget(e,{target:s}){return s}static _getPointerCoords({offsetX:e,offsetY:s,clientX:i,clientY:r},a=null){if(!a)return[e,s];let o=i-a.clientX,l=r-a.clientY;switch(this._currentParent.viewport.rotation){case 90:[o,l]=[l,-o];break;case 180:[o,l]=[-o,-l];break;case 270:[o,l]=[-l,o];break}return[a.offsetX+o,a.offsetY+l]}static _addDrawingListeners(e,s){}static _endDrawingSession(e=!1){return this._currentParent.endDrawingSession(e)}static startDrawing(e,s,i,r){var x;const{pointerId:a,pointerType:o}=r;if(we.isInitializedAndDifferentPointerType(o))return;const l=this._getDrawingTarget(e,r),[h,c]=this._getPointerCoords(r),{viewport:{rotation:d}}=e,{x:f,y:m,width:y,height:A}=l.getBoundingClientRect(),w=u(q,wo,new AbortController),v=e.combinedSignal(w);if(we.setPointer(o,a),window.addEventListener("pointerup",C=>{we.isSamePointerIdOrRemove(C.pointerId)&&this._endDraw(C)},{signal:v}),window.addEventListener("pointercancel",C=>{we.isSamePointerIdOrRemove(C.pointerId)&&this._endDrawingSession()},{signal:v}),window.addEventListener("pointerdown",C=>{we.isSamePointerType(C.pointerType)&&(we.initializeAndAddPointerId(C.pointerId),n(q,Wt).isCancellable()&&(n(q,Wt).removeLastElement(),n(q,Wt).isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",Us,{signal:v}),l.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),l.addEventListener("touchmove",C=>{we.isSameTimeStamp(C.timeStamp)&&Kt(C)},{signal:v}),this._addDrawingListeners(l,v),e.toggleDrawing(),(x=s._editorUndoBar)==null||x.hide(),n(q,Wt)){e.drawLayer.updateProperties(this._currentDrawId,n(q,Wt).startNew(h,c,y,A,d));return}s.updateUIForDefaultProperties(this),u(q,Wt,this.createDrawerInstance({x:h,y:c,box:[f,m,y,A],rotation:d,parent:e,isLTR:i})),u(q,vo,this.getDefaultDrawingOptions()),this._currentParent=e;const{id:S,clipPathId:E}=e.drawLayer.draw(this._mergeSVGProperties(n(q,vo).toSVGProperties(),n(q,Wt).defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=S,u(q,hh,this._hasClipPath?E:null)}static _drawMove(e){var r;if(we.isSameTimeStamp(e.timeStamp),!n(q,Wt)||!we.isSamePointerId(e.pointerId))return;if(we.isUsingMultiplePointers()){this._endDraw(e);return}let s;const i=(r=e.getCoalescedEvents)==null?void 0:r.call(e);if(i!=null&&i.length){const a=[];for(const o of i)a.push(...this._getPointerCoords(o,e));s=n(q,Wt).addPoints(a)}else s=n(q,Wt).add(...this._getPointerCoords(e));this._currentParent.drawLayer.updateProperties(this._currentDrawId,s),we.setTimeStamp(e.timeStamp),Kt(e)}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,u(q,Wt,null),u(q,vo,null),u(q,hh,null),we.clearTimeStamp()),n(q,wo)&&(n(q,wo).abort(),u(q,wo,null),we.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),s.drawLayer.updateProperties(this._currentDrawId,(e==null?void 0:e.target)===s.div?n(q,Wt).end(...this._getPointerCoords(e)):n(q,Wt).end()),this.supportMultipleDrawings){const i=n(q,Wt),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:et.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(et.DRAW_STEP),!n(q,Wt).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:n(q,hh),drawOutlines:n(q,Wt).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(q,vo),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,l){st("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e,i),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(d=c,V,Ug).call(d,{drawOutlines:h}),b(f=c,V,ec).call(f),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return this._drawOutlines.serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};oh=new WeakMap,lh=new WeakMap,Wt=new WeakMap,wo=new WeakMap,vo=new WeakMap,hh=new WeakMap,V=new WeakSet,Ug=function({drawOutlines:e,drawId:s,drawingOptions:i,clipPathId:r}){this._drawOutlines=e,this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(gt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this._clipPathId=r??null,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties),b(this,V,$g).call(this,this.parent)):this._drawId=b(this,V,Gg).call(this,e,this.parent),b(this,V,sc).call(this,e.box)},Gg=function(e,s){const{id:i,clipPathId:r}=s.drawLayer.draw(q._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,this.constructor._hasClipPath);return this.constructor._hasClipPath&&(this._clipPathId=r),b(this,V,$g).call(this,s),i},$g=function(e){const s=this._drawOutlines.getFocusSVGProperties(n(this,V,jg));s&&(this._focusDrawId=e.drawLayer.drawOutline(s,this._drawOutlines.focusMustRemoveSelfIntersections))},zg=function(e=n(this,V,jg)){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(e)))},tc=function(e){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,{rootClass:e}))},Vg=function(){const{parent:e,_drawId:s,_focusDrawId:i,_isVisible:r}=this;if(!e||s===null)return;const a={hidden:!r};e.drawLayer.updateProperties(s,{rootClass:a}),i!==null&&e.drawLayer.updateProperties(i,{rootClass:a})},jg=function(){return(this.parentRotation-this._drawRotation+360)%360},Wg=function(){if(this._drawId===null||!this.parent)return;const{drawLayer:e}=this.parent;e.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(e.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()},ec=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){const{drawLayer:s}=this.parent;s.updateParent(this._drawId,e.drawLayer),this._focusDrawId!==null&&s.updateParent(this._focusDrawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,V,Gg).call(this,this._drawOutlines,e),this._clipPathId&&n(this,oh)&&(n(this,oh).style.clipPath=this._clipPathId)}},fA=function([e,s,i,r]){const{parentDimensions:[a,o],_drawRotation: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]}},Qu=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],_drawRotation: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]}},sc=function(e){[this.x,this.y,this.width,this.height]=b(this,V,fA).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Xo=function(e=this.parentRotation){const{x:s,y:i,width:r,height:a,_drawRotation:o,parentDimensions:[l,h]}=this;switch((o*4+e)/90){case 1:return[1-i-a,s,a,r];case 2:return[1-s-r,1-i-a,r,a];case 3:return[i,1-s-r,a,r];case 4:return[s,i-r*(l/h),a*(h/l),r*(l/h)];case 5:return[1-i,s,r*(l/h),a*(h/l)];case 6:return[1-s-a*(h/l),1-i,a*(h/l),r*(l/h)];case 7:return[i-r*(l/h),1-s-a*(h/l),r*(l/h),a*(h/l)];case 8:return[s-r,i-a,r,a];case 9:return[1-i,s-r,a,r];case 10:return[1-s,1-i,r,a];case 11:return[i-a,1-s,a,r];case 12:return[s-a*(h/l),i,a*(h/l),r*(l/h)];case 13:return[1-i-r*(l/h),s-a*(h/l),r*(l/h),a*(h/l)];case 14:return[1-s,1-i-r*(l/h),a*(h/l),r*(l/h)];case 15:return[i,1-s,r*(l/h),a*(h/l)];default:return[s,i,r,a]}},T(q,"_currentDrawId",-1),T(q,"_currentParent",null),g(q,Wt,null),g(q,wo,null),g(q,vo,null),g(q,hh,null),T(q,"_INNER_MARGIN",3);let wc=q;class O{constructor(){T(this,"focusOutline",null)}toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){st("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],r){switch(r){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}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 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]}}T(O,"PRECISION",1e-4);var hs,Rs,ch,dh,Zs,tt,So,Eo,$d,zd,uh,fh,Pi,Vd,zf,Vf,te,ic,pA,gA,mA,bA,yA,AA;const Xi=class Xi{constructor(t,e,s,i,r,a,o=0){g(this,te);g(this,hs);g(this,Rs,[]);g(this,ch);g(this,dh);g(this,Zs,[]);g(this,tt,new Float32Array(18));g(this,So);g(this,Eo);g(this,$d);g(this,zd);g(this,uh);g(this,fh);g(this,Pi,[]);u(this,hs,s),u(this,fh,r*i),u(this,dh,a),n(this,tt).set([NaN,NaN,NaN,NaN,t,e],6),u(this,ch,o),u(this,zd,n(Xi,Vd)*i),u(this,$d,n(Xi,Vf)*i),u(this,uh,i),n(this,Pi).push(t,e)}isEmpty(){return isNaN(n(this,tt)[8])}isCancellable(){return n(this,Pi).length<=10}removeLastElement(){return n(this,tt).fill(NaN),n(this,Zs).length=n(this,Rs).length=n(this,Pi).length=0,{path:{d:""}}}add(t,e){var P;u(this,So,t),u(this,Eo,e);const[s,i,r,a]=n(this,hs);let[o,l,h,c]=n(this,tt).subarray(8,12);const d=t-h,f=e-c,m=Math.hypot(d,f);if(m<n(this,$d))return!1;const y=m-n(this,zd),A=y/m,w=A*d,v=A*f;let S=o,E=l;o=h,l=c,h+=w,c+=v,(P=n(this,Pi))==null||P.push(t,e);const x=-v/y,C=w/y,_=x*n(this,fh),k=C*n(this,fh);return n(this,tt).set(n(this,tt).subarray(2,8),0),n(this,tt).set([h+_,c+k],4),n(this,tt).set(n(this,tt).subarray(14,18),12),n(this,tt).set([h-_,c-k],16),isNaN(n(this,tt)[6])?(n(this,Zs).length===0&&(n(this,tt).set([o+_,l+k],2),n(this,Zs).push(NaN,NaN,NaN,NaN,(o+_-s)/r,(l+k-i)/a),n(this,tt).set([o-_,l-k],14),n(this,Rs).push(NaN,NaN,NaN,NaN,(o-_-s)/r,(l-k-i)/a)),n(this,tt).set([S,E,o,l,h,c],6),!this.isEmpty()):(n(this,tt).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(v,w))<Math.PI/2?([o,l,h,c]=n(this,tt).subarray(2,6),n(this,Zs).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,E]=n(this,tt).subarray(14,18),n(this,Rs).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-i)/a),!0):([S,E,o,l,h,c]=n(this,tt).subarray(0,6),n(this,Zs).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,tt).subarray(12,18),n(this,Rs).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,Zs),e=n(this,Rs);if(isNaN(n(this,tt)[6])&&!this.isEmpty())return b(this,te,pA).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,mA).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,gA).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new wA(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,Zs),e=n(this,Rs),s=n(this,tt),[i,r,a,o]=n(this,hs),l=new Float32Array((((d=n(this,Pi))==null?void 0:d.length)??0)+2);for(let f=0,m=l.length-2;f<m;f+=2)l[f]=(n(this,Pi)[f]-i)/a,l[f+1]=(n(this,Pi)[f+1]-r)/o;if(l[l.length-2]=(n(this,So)-i)/a,l[l.length-1]=(n(this,Eo)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,te,bA).call(this,l);const h=new Float32Array(n(this,Zs).length+24+n(this,Rs).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,AA).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,yA).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,hs),n(this,uh),n(this,ch),n(this,dh))}};hs=new WeakMap,Rs=new WeakMap,ch=new WeakMap,dh=new WeakMap,Zs=new WeakMap,tt=new WeakMap,So=new WeakMap,Eo=new WeakMap,$d=new WeakMap,zd=new WeakMap,uh=new WeakMap,fh=new WeakMap,Pi=new WeakMap,Vd=new WeakMap,zf=new WeakMap,Vf=new WeakMap,te=new WeakSet,ic=function(){const t=n(this,tt).subarray(4,6),e=n(this,tt).subarray(16,18),[s,i,r,a]=n(this,hs);return[(n(this,So)+(t[0]-e[0])/2-s)/r,(n(this,Eo)+(t[1]-e[1])/2-i)/a,(n(this,So)+(e[0]-t[0])/2-s)/r,(n(this,Eo)+(e[1]-t[1])/2-i)/a]},pA=function(){const[t,e,s,i]=n(this,hs),[r,a,o,l]=b(this,te,ic).call(this);return`M${(n(this,tt)[2]-t)/s} ${(n(this,tt)[3]-e)/i} L${(n(this,tt)[4]-t)/s} ${(n(this,tt)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,tt)[16]-t)/s} ${(n(this,tt)[17]-e)/i} L${(n(this,tt)[14]-t)/s} ${(n(this,tt)[15]-e)/i} Z`},gA=function(t){const e=n(this,Rs);t.push(`L${e[4]} ${e[5]} Z`)},mA=function(t){const[e,s,i,r]=n(this,hs),a=n(this,tt).subarray(4,6),o=n(this,tt).subarray(16,18),[l,h,c,d]=b(this,te,ic).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${d} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},bA=function(t){const e=n(this,tt),[s,i,r,a]=n(this,hs),[o,l,h,c]=b(this,te,ic).call(this),d=new Float32Array(36);return d.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(d,t,n(this,hs),n(this,uh),n(this,ch),n(this,dh))},yA=function(t,e){const s=n(this,Rs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},AA=function(t,e){const s=n(this,tt).subarray(4,6),i=n(this,tt).subarray(16,18),[r,a,o,l]=n(this,hs),[h,c,d,f]=b(this,te,ic).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,d,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},g(Xi,Vd,8),g(Xi,zf,2),g(Xi,Vf,n(Xi,Vd)+n(Xi,zf));let bf=Xi;var ph,Mi,xn,jd,ti,Wd,Lt,jf,vA;class wA extends O{constructor(e,s,i,r,a,o){super();g(this,jf);g(this,ph);g(this,Mi,new Float32Array(4));g(this,xn);g(this,jd);g(this,ti);g(this,Wd);g(this,Lt);u(this,Lt,e),u(this,ti,s),u(this,ph,i),u(this,Wd,r),u(this,xn,a),u(this,jd,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,jf,vA).call(this,o);const[l,h,c,d]=n(this,Mi);for(let f=0,m=e.length;f<m;f+=2)e[f]=(e[f]-l)/c,e[f+1]=(e[f+1]-h)/d;for(let f=0,m=s.length;f<m;f+=2)s[f]=(s[f]-l)/c,s[f+1]=(s[f+1]-h)/d}toSVGPath(){const e=[`M${n(this,Lt)[4]} ${n(this,Lt)[5]}`];for(let s=6,i=n(this,Lt).length;s<i;s+=6){if(isNaN(n(this,Lt)[s])){e.push(`L${n(this,Lt)[s+4]} ${n(this,Lt)[s+5]}`);continue}e.push(`C${n(this,Lt)[s]} ${n(this,Lt)[s+1]} ${n(this,Lt)[s+2]} ${n(this,Lt)[s+3]} ${n(this,Lt)[s+4]} ${n(this,Lt)[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=O._rescale(n(this,Lt),e,r,o,-l),c=O._rescale(n(this,ti),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(n(this,Lt),e,s,o,l),c=O._rescaleAndSwap(n(this,ti),e,s,o,l);break;case 180:h=O._rescale(n(this,Lt),i,s,-o,l),c=O._rescale(n(this,ti),i,s,-o,l);break;case 270:h=O._rescaleAndSwap(n(this,Lt),i,r,-o,-l),c=O._rescaleAndSwap(n(this,ti),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Mi)}newOutliner(e,s,i,r,a,o,l=0){return new bf(e,s,i,r,a,o,l)}updateThickness(e){const s=this.getNewOutline(e);return u(this,Lt,n(s,Lt)),u(this,ti,n(s,ti)),n(this,Mi).set(n(s,Mi)),this.firstPoint=s.firstPoint,this.lastPoint=s.lastPoint,n(this,Mi)}getNewOutline(e,s){const[i,r,a,o]=n(this,Mi),[l,h,c,d]=n(this,ph),f=a*c,m=o*d,y=i*c+l,A=r*d+h,w=n(this,ti),v=this.newOutliner(w[0]*f+y,w[1]*m+A,n(this,ph),n(this,Wd),e,n(this,jd),s??n(this,xn));for(let S=2,E=w.length;S<E;S+=2)v.add(w[S]*f+y,w[S+1]*m+A);return v.getOutlines()}}ph=new WeakMap,Mi=new WeakMap,xn=new WeakMap,jd=new WeakMap,ti=new WeakMap,Wd=new WeakMap,Lt=new WeakMap,jf=new WeakSet,vA=function(e){const s=n(this,Lt);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,c=r;const d=e?Math.max:Math.min,f=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const w=s[y+4],v=s[y+5];isNaN(s[y])?(I.pointBoundingBox(w,v,a),l>v?(o=w,l=v):l===v&&(o=d(o,w)),c<v?(h=w,c=v):c===v&&(h=d(h,w))):(f.set(Ui,0),I.bezierBoundingBox(i,r,...s.slice(y,y+6),f),I.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),c<f[3]?(h=f[2],c=f[3]):c===f[3]&&(h=d(h,f[2]))),i=w,r=v}const m=n(this,Mi);m[0]=a[0]-n(this,xn),m[1]=a[1]-n(this,xn),m[2]=a[2]-a[0]+2*n(this,xn),m[3]=a[3]-a[1]+2*n(this,xn),this.firstPoint=[o,l],this.lastPoint=[h,c]};function SA(p){return{bbox:p.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:p.isFree},path:{d:p.toSVGPath()}}}function EA(p,t){const{focusOutline:e}=p;return{bbox:O._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:p.isFree},path:{d:e.toSVGPath()}}}var Xd,Yd,Kd,Mr,ei,Ne,xA,Ju,CA,_A,Yg;class Xg{constructor(t,e=0,s=0,i=!0){g(this,Ne);g(this,Xd);g(this,Yd);g(this,Kd);g(this,Mr,[]);g(this,ei,[]);const r=Ui.slice(),a=10**-4;for(const{x:A,y:w,width:v,height:S}of t){const E=Math.floor((A-e)/a)*a,x=Math.ceil((A+v+e)/a)*a,C=Math.floor((w-e)/a)*a,_=Math.ceil((w+S+e)/a)*a,k=[E,C,_,!0],M=[x,C,_,!1];n(this,Mr).push(k,M),I.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 d=i?-1/0:1/0,f=1/0;const m=n(this,Mr).at(i?-1:-2),y=[m[0],m[2]];for(const A of n(this,Mr)){const[w,v,S,E]=A;!E&&i?v<f?(f=v,d=w):v===f&&(d=Math.max(d,w)):E&&!i&&(v<f?(f=v,d=w):v===f&&(d=Math.min(d,w))),A[0]=(w-h)/o,A[1]=(v-c)/l,A[2]=(S-c)/l}u(this,Xd,new Float32Array([h,c,o,l])),u(this,Yd,[d,f]),u(this,Kd,y)}getOutlines(){n(this,Mr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,Mr))e[3]?(t.push(...b(this,Ne,Yg).call(this,e)),b(this,Ne,CA).call(this,e)):(b(this,Ne,_A).call(this,e),t.push(...b(this,Ne,Yg).call(this,e)));return b(this,Ne,xA).call(this,t)}}Xd=new WeakMap,Yd=new WeakMap,Kd=new WeakMap,Mr=new WeakMap,ei=new WeakMap,Ne=new WeakSet,xA=function(t){const e=[],s=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const i=[];for(;s.size>0;){const r=s.values().next().value;let[a,o,l,h,c]=r;s.delete(r);let d=a,f=o;const m=[a,l];for(i.push(m);;){let y;if(s.has(h))y=h;else if(s.has(c))y=c;else break;s.delete(y),[a,o,l,h,c]=y,d!==a&&(m.push(d,f,a,f===o?o:l),d=a),f=f===o?l:o}m.push(d,f)}return new Kg(i,n(this,Xd),n(this,Yd),n(this,Kd))},Ju=function(t){const e=n(this,ei);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},CA=function([,t,e]){const s=b(this,Ne,Ju).call(this,t);n(this,ei).splice(s,0,[t,e])},_A=function([,t,e]){const s=b(this,Ne,Ju).call(this,t);for(let i=s;i<n(this,ei).length;i++){const[r,a]=n(this,ei)[i];if(r!==t)break;if(r===t&&a===e){n(this,ei).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,ei)[i];if(r!==t)break;if(r===t&&a===e){n(this,ei).splice(i,1);return}}},Yg=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Ne,Ju).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,ei)[o];for(let c=0,d=r.length;c<d;c++){const[,f,m]=r[c];if(!(h<=f||m<=l)){if(f>=l){if(m>h)r[c][1]=h;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var qd,Qd,gh;class Kg extends O{constructor(e,s,i,r){super();g(this,qd);g(this,Qd,null);g(this,gh);u(this,gh,e),u(this,qd,s),this.firstPoint=i,this.lastPoint=r}static build(e,s){const i=new Xg(e,.001).getOutlines();return u(i,Qd,e),i.focusOutline=new Xg(e,.0025,.001,s).getOutlines(),i}get isFree(){return!1}get defaultSVGProperties(){return SA(this)}getFocusSVGProperties(e){return EA(this,e)}updateRotation(e){return{root:{"data-main-rotation":e}}}serializeQuadPoints([e,s],[i,r]){const a=n(this,Qd),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:f}of a){const m=h*i+e,y=(1-c)*r+s;o[l]=o[l+4]=m,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=m+d*i,o[l+5]=o[l+7]=y-f*r,l+=8}return o}toSVGPath(){const e=[];for(const s of n(this,gh)){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,gh)){const d=new Array(c.length);for(let f=0;f<c.length;f+=2)d[f]=e+c[f]*l,d[f+1]=r-c[f+1]*h;o.push(d)}return o}get box(){return n(this,qd)}}qd=new WeakMap,Qd=new WeakMap,gh=new WeakMap;class _m extends bf{newFreeDrawOutline(t,e,s,i,r,a){return new qg(t,e,s,i,r,a)}}var cs,Jd;class Ww{constructor(t,e,s,i,r,a,o){g(this,cs);g(this,Jd);u(this,cs,new _m(t,e,s,i,r,a,o)),u(this,Jd,r)}add(t,e){return n(this,cs).add(t,e)?{path:{d:n(this,cs).toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=n(this,cs).add(t[s],t[s+1])||e;return e?{path:{d:n(this,cs).toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return n(this,cs).isEmpty()}isCancellable(){return n(this,cs).isCancellable()}removeLastElement(){return n(this,cs).removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=n(this,cs).getOutlines();return t.buildFocusOutline(2*n(this,Jd)),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:n(this,cs).toSVGPath()}}}}cs=new WeakMap,Jd=new WeakMap;var Wf;const Xf=class Xf extends wA{newOutliner(t,e,s,i,r,a,o=0){return new _m(t,e,s,i,r,a,o)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+n(Xf,Wf),.0025)}get defaultSVGProperties(){return SA(this)}getFocusSVGProperties(t){return EA(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}};Wf=new WeakMap,g(Xf,Wf,1.5);let qg=Xf;class Tm extends Cm{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new Tm;return t.updateAll(this),t}}var mh,Zd,tu,eu,su,bh,ys,Qg,TA,Zu,kA;const Pe=class Pe extends wc{constructor(e){var s;super({...e,name:"highlightEditor"});g(this,ys);g(this,mh,null);g(this,Zd,0);g(this,tu,null);g(this,eu,0);g(this,su,"");g(this,bh,"");u(this,mh,e.anchorNode||null),u(this,Zd,e.anchorOffset||0),u(this,tu,e.focusNode||null),u(this,eu,e.focusOffset||0),u(this,su,e.methodOfCreation||((s=this._drawOutlines)!=null&&s.isFree?"main_toolbar":"")),u(this,bh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static get _keyboardManager(){const e=Pe.prototype;return F(this,"_keyboardManager",new Ro([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}static initialize(e,s){var i;gt.initialize(e,s),this._defaultDrawingOptions||(this._defaultDrawingOptions=new Tm({fill:((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066","fill-opacity":Pe._DEFAULT_OPACITY,thickness:Pe._DEFAULT_THICKNESS}))}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get typesMap(){return F(this,"typesMap",new Map([[et.HIGHLIGHT_COLOR,"fill"],[et.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(e){const{boxes:s,drawOutlines:i}=e;!s&&!i||(this._drawingOptions||(this._drawingOptions=e.drawingOptions||Pe.getDefaultDrawingOptions()),s&&(e={...e,drawOutlines:Kg.build(s,this._uiManager.direction==="ltr")}),super._addOutlines(e))}get colorType(){return et.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){var e;return(e=this._drawOutlines)!=null&&e.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){var e;return!((e=this._drawOutlines)!=null&&e.isFree)}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:n(this,su)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}translateInPage(e,s){}get toolbarPosition(){return b(this,ys,Qg).call(this,this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return b(this,ys,Qg).call(this,this._drawOutlines.firstPoint)}updateParams(e,s){switch(e){case et.HIGHLIGHT_COLOR:this._updateColorAndOpacity(s,Pe._DEFAULT_OPACITY,e),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(s)},!0);break;case et.HIGHLIGHT_THICKNESS:super.updateParams(e,s),this._reportTelemetry({action:"thickness_changed",thickness:s},!0);break}}get propertiesToUpdate(){const e=super.propertiesToUpdate;return e.push([et.HIGHLIGHT_FREE,this._drawOutlines.isFree]),e}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new yc({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(e,s){return super.getRect(e,s,this._drawRotation)}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;const e=super.render();return n(this,bh)&&(e.setAttribute("aria-label",n(this,bh)),e.setAttribute("role","mark")),this._drawOutlines.isFree?e.classList.add("free"):e.addEventListener("keydown",b(this,ys,TA).bind(this),{signal:this._uiManager._signal}),this.enableEditing(),e}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,ys,Zu).call(this,!0);break;case 1:case 3:b(this,ys,Zu).call(this,!1);break}}unselect(){super.unselect(),this._drawOutlines.isFree||b(this,ys,Zu).call(this,!1)}static createDrawerInstance({x:e,y:s,box:i,parent:r,isLTR:a}){return new Ww(e,s,i,r.scale,this._defaultDrawingOptions.thickness/2,a,.001)}static _getDrawingTarget(e,{target:s}){return s.closest(".textLayer")}static _getPointerCoords({x:e,y:s}){return[e,s]}static _addDrawingListeners(e,s){e.classList.add("free"),s.addEventListener("abort",()=>e.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:s}),window.addEventListener("pointerdown",Kt,{capture:!0,passive:!1,signal:s})}static _endDrawingSession(e=!1){return this.endDrawing(e)}createDrawingOptions({color:e,opacity:s,thickness:i}){const{_defaultDrawingOptions:r,_DEFAULT_OPACITY:a}=Pe;this._drawingOptions=Pe.getDefaultDrawingOptions({fill:I.makeHexColor(...e),"fill-opacity":s||a,thickness:i||r.thickness})}static deserializeDraw(e,s,i,r,a,o,l){const{quadPoints:h}=o;if(h){const y=[];for(let A=0,w=h.length;A<w;A+=8)y.push({x:(h[A]-e)/i,y:1-(h[A+1]-s)/r,width:(h[A+2]-h[A])/i,height:(h[A+1]-h[A+5])/r});return Kg.build(y,l.direction==="ltr")}const c=o.thickness||this._defaultDrawingOptions.thickness,d=(o.inkLists||o.outlines.points)[0],f=new _m(d[0]-e,r-(d[1]-s),[0,0,i,r],1,c/2,!0,.001);for(let y=0,A=d.length;y<A;y+=2)f.add(d[y]-e,r-(d[y+1]-s));const m=f.getOutlines();return m.buildFocusOutline(c),m}static async deserialize(e,s,i){let r=null;if(e instanceof nA){const{data:{quadPoints:o,rect:l,rotation:h,id:c,color:d,opacity:f,popupRef:m,richText:y,contentsObj:A,creationDate:w,modificationDate:v},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),opacity:f,quadPoints:o,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:m,richText:y,comment:(A==null?void 0:A.str)||null,creationDate:w,modificationDate:v}}else if(e instanceof xm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,borderStyle:{rawWidth:f},popupRef:m,richText:y,contentsObj:A,creationDate:w,modificationDate:v},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),thickness:f,inkLists:o,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:m,richText:y,comment:(A==null?void 0:A.str)||null,creationDate:w,modificationDate:v}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=super.serialize(e);return Object.assign(s,{color:gt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(s.rect,this._drawRotation)}),this.addComment(s),this.annotationElementId&&!b(this,ys,kA).call(this,s)?null:(s.id=this.annotationElementId,s)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}};mh=new WeakMap,Zd=new WeakMap,tu=new WeakMap,eu=new WeakMap,su=new WeakMap,bh=new WeakMap,ys=new WeakSet,Qg=function([e,s]){const[i,r,a,o]=this._drawOutlines.box;return[(e-i)/a,(s-r)/o]},TA=function(e){Pe._keyboardManager.exec(this,e)},Zu=function(e){if(!n(this,mh))return;const s=window.getSelection();e?s.setPosition(n(this,mh),n(this,Zd)):s.setPosition(n(this,tu),n(this,eu))},kA=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},T(Pe,"_DEFAULT_OPACITY",1),T(Pe,"_DEFAULT_THICKNESS",12),T(Pe,"_defaultDrawingOptions",null),T(Pe,"_type","highlight"),T(Pe,"_editorType",W.HIGHLIGHT);let yf=Pe;var Di,Dr,Xt,fe,xo,yh,pe,Yt,Os,Co,_o,To,As,tf,ef,Jg;class Xw{constructor(t,e,s,i,r,a){g(this,As);g(this,Di,new Float64Array(6));g(this,Dr,new Float64Array(2));g(this,Xt);g(this,fe);g(this,xo);g(this,yh);g(this,pe);g(this,Yt,"");g(this,Os,0);g(this,Co,new pu);g(this,_o);g(this,To);u(this,_o,s),u(this,To,i),u(this,xo,r),u(this,yh,a),[t,e]=b(this,As,tf).call(this,t,e);const o=u(this,Xt,[NaN,NaN,NaN,NaN,t,e]);u(this,pe,[t,e]),u(this,fe,[{line:o,points:n(this,pe)}]),n(this,Di).set(o,0),n(this,Dr).set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&u(this,yh,e)}isEmpty(){var t;return!((t=n(this,fe))!=null&&t.length)}isCancellable(){return n(this,pe).length<=10}add(t,e){return b(this,As,ef).call(this,t,e)&&this.toSVGPath(),{path:{d:b(this,As,Jg).call(this)}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)b(this,As,ef).call(this,t[s],t[s+1])&&(e=!0,n(this,pe).length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:b(this,As,Jg).call(this)}}}end(t,e){return t!==void 0&&b(this,As,ef).call(this,t,e)?{path:{d:this.toSVGPath()}}:n(this,pe).length===2?{path:{d:this.toSVGPath()}}:{path:{d:n(this,Yt)}}}startNew(t,e,s,i,r){u(this,_o,s),u(this,To,i),u(this,xo,r),[t,e]=b(this,As,tf).call(this,t,e);const a=u(this,Xt,[NaN,NaN,NaN,NaN,t,e]);u(this,pe,[t,e]),n(this,Dr).set([t,e],0);const o=n(this,fe).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,fe).push({line:a,points:n(this,pe)}),n(this,Di).set(a,0),u(this,Os,0),this.toSVGPath(),null}getLastElement(){return n(this,fe).at(-1)}setLastElement(t){return n(this,fe)?(n(this,fe).push(t),u(this,Xt,t.line),u(this,pe,t.points),u(this,Os,0),{path:{d:this.toSVGPath()}}):n(this,Co).setLastElement(t)}removeLastElement(){if(!n(this,fe))return n(this,Co).removeLastElement();n(this,fe).pop(),u(this,Yt,"");for(let t=0,e=n(this,fe).length;t<e;t++){const{line:s,points:i}=n(this,fe)[t];u(this,Xt,s),u(this,pe,i),u(this,Os,0),this.toSVGPath()}return{path:{d:n(this,Yt)}}}toSVGPath(){const t=O.svgRound(n(this,Xt)[4]),e=O.svgRound(n(this,Xt)[5]);if(n(this,pe).length===2)return u(this,Yt,`${n(this,Yt)} M ${t} ${e} Z`),n(this,Yt);if(n(this,pe).length<=6){const i=n(this,Yt).lastIndexOf("M");u(this,Yt,`${n(this,Yt).slice(0,i)} M ${t} ${e}`),u(this,Os,6)}if(n(this,pe).length===4){const i=O.svgRound(n(this,Xt)[10]),r=O.svgRound(n(this,Xt)[11]);return u(this,Yt,`${n(this,Yt)} L ${i} ${r}`),u(this,Os,12),n(this,Yt)}const s=[];n(this,Os)===0&&(s.push(`M ${t} ${e}`),u(this,Os,6));for(let i=n(this,Os),r=n(this,Xt).length;i<r;i+=6){const[a,o,l,h,c,d]=n(this,Xt).slice(i,i+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return u(this,Yt,n(this,Yt)+s.join(" ")),u(this,Os,n(this,Xt).length),n(this,Yt)}getOutlines(t,e,s,i){const r=n(this,fe).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,Co).build(n(this,fe),t,e,s,n(this,xo),n(this,yh),i),u(this,Di,null),u(this,Xt,null),u(this,fe,null),u(this,Yt,null),n(this,Co)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Di=new WeakMap,Dr=new WeakMap,Xt=new WeakMap,fe=new WeakMap,xo=new WeakMap,yh=new WeakMap,pe=new WeakMap,Yt=new WeakMap,Os=new WeakMap,Co=new WeakMap,_o=new WeakMap,To=new WeakMap,As=new WeakSet,tf=function(t,e){return O._normalizePoint(t,e,n(this,_o),n(this,To),n(this,xo))},ef=function(t,e){[t,e]=b(this,As,tf).call(this,t,e),n(this,Dr).set([t,e],0);const[s,i,r,a]=n(this,Di).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,_o)*o,n(this,To)*l)<=2?!1:(n(this,pe).push(t,e),isNaN(s)?(n(this,Di).set([r,a,t,e],2),n(this,Xt).push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(n(this,Di)[0])&&n(this,Xt).splice(6,6),n(this,Di).set([s,i,r,a,t,e],0),n(this,Xt).push(...O.createBezierPoints(s,i,r,a,t,e)),!0))},Jg=function(){const t=O.svgRound(n(this,Dr)[0]),e=O.svgRound(n(this,Dr)[1]);if(n(this,pe).length===2){const s=O.svgRound(n(this,Xt)[4]),i=O.svgRound(n(this,Xt)[5]);return`${n(this,Yt)} M ${s} ${i} L ${t} ${e}`}return`${n(this,Yt)} L ${t} ${e}`};var De,iu,nu,ds,Ii,Li,Ah,wh,ko,me,ji,PA,MA,DA;class pu extends O{constructor(){super(...arguments);g(this,me);g(this,De);g(this,iu,0);g(this,nu);g(this,ds);g(this,Ii);g(this,Li);g(this,Ah);g(this,wh);g(this,ko)}build(e,s,i,r,a,o,l){u(this,Ii,s),u(this,Li,i),u(this,Ah,r),u(this,wh,a),u(this,ko,o),u(this,nu,l??0),u(this,ds,e),b(this,me,MA).call(this)}get thickness(){return n(this,ko)}setLastElement(e){return n(this,ds).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,ds).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,ds)){if(e.push(`M${O.svgRound(s[4])} ${O.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${O.svgRound(s[10])} ${O.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,d]=s.subarray(i,i+6).map(O.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,d,f]=b(this,me,PA).call(this);let m,y,A,w,v,S,E,x,C;switch(n(this,wh)){case 0:C=O._rescale,m=e,y=s+r,A=i,w=-r,v=e+h*i,S=s+(1-c-f)*r,E=e+(h+d)*i,x=s+(1-c)*r;break;case 90:C=O._rescaleAndSwap,m=e,y=s,A=i,w=r,v=e+c*i,S=s+h*r,E=e+(c+f)*i,x=s+(h+d)*r;break;case 180:C=O._rescale,m=e+i,y=s,A=-i,w=r,v=e+(1-h-d)*i,S=s+c*r,E=e+(1-h)*i,x=s+(c+f)*r;break;case 270:C=O._rescaleAndSwap,m=e+i,y=s+r,A=-i,w=-r,v=e+(1-c-f)*i,S=s+(1-h-d)*r,E=e+(1-c)*i,x=s+(1-h)*r;break}for(const{line:_,points:k}of n(this,ds))o.push(C(_,m,y,A,w,a?new Array(_.length):null)),l.push(C(k,m,y,A,w,a?new Array(k.length):null));return{lines:o,points:l,rect:[v,S,E,x]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let f,m,y,A,w;switch(h){case 0:w=O._rescale,f=-e/i,m=s/r+1,y=1/i,A=-1/r;break;case 90:w=O._rescaleAndSwap,f=-s/r,m=-e/i,y=1/r,A=1/i;break;case 180:w=O._rescale,f=e/i+1,m=-s/r,y=-1/i,A=1/r;break;case 270:w=O._rescaleAndSwap,f=s/r+1,m=e/i+1,y=-1/r,A=-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 x=new Float32Array(3*(E-2));o.push(x);let[C,_,k,M]=S.subarray(0,4);x.set([NaN,NaN,NaN,NaN,C,_],0);for(let P=4;P<E;P+=2){const D=S[P],N=S[P+1];x.set(O.createBezierPoints(C,_,k,M,D,N),(P-2)*3),[C,_,k,M]=[k,M,D,N]}}}for(let S=0,E=o.length;S<E;S++)d.push({line:w(o[S].map(x=>x??NaN),f,m,y,A),points:w(l[S].map(x=>x??NaN),f,m,y,A)});const v=new this.prototype.constructor;return v.build(d,i,r,1,h,c,a),v}get box(){return n(this,De)}updateProperty(e,s){return e==="stroke-width"?b(this,me,DA).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,me,ji).call(this);u(this,Ii,e),u(this,Li,s),u(this,Ah,i);const[o,l]=b(this,me,ji).call(this),h=o-r,c=l-a,d=n(this,De);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return u(this,iu,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,De).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,De);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,De);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,iu)){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} ${O.svgRound(l)} ${O.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,me,ji).call(this),[l,h,c,d]=n(this,De);if(Math.abs(c-a)<=O.PRECISION||Math.abs(d-o)<=O.PRECISION){const w=e+i/2-(l+c/2),v=s+r/2-(h+d/2);return{path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:`${this.rotationTransform} translate(${w} ${v})`}}}const f=(i-2*a)/(c-2*a),m=(r-2*o)/(d-2*o),y=c/i,A=d/r;return{path:{"transform-origin":`${O.svgRound(l)} ${O.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${O.svgRound(a)} ${O.svgRound(o)}) scale(${f} ${m}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,me,ji).call(this),l=n(this,De),[h,c,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=O.PRECISION||Math.abs(f-o)<=O.PRECISION){const v=e+i/2-(h+d/2),S=s+r/2-(c+f/2);for(const{line:E,points:x}of n(this,ds))O._translate(E,v,S,E),O._translate(x,v,S,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(d-2*a),y=(r-2*o)/(f-2*o),A=-m*(h+a)+e+a,w=-y*(c+o)+s+o;if(m!==1||y!==1||A!==0||w!==0)for(const{line:v,points:S}of n(this,ds))O._rescale(v,A,w,m,y,v),O._rescale(S,A,w,m,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,De),l=e-o[0],h=s-o[1];if(n(this,Ii)===r&&n(this,Li)===a)for(const{line:c,points:d}of n(this,ds))O._translate(c,l,h,c),O._translate(d,l,h,d);else{const c=n(this,Ii)/r,d=n(this,Li)/a;u(this,Ii,r),u(this,Li,a);for(const{line:f,points:m}of n(this,ds))O._rescale(f,l,h,c,d,f),O._rescale(m,l,h,c,d,m);o[2]*=c,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,De);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e[0])} ${O.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}De=new WeakMap,iu=new WeakMap,nu=new WeakMap,ds=new WeakMap,Ii=new WeakMap,Li=new WeakMap,Ah=new WeakMap,wh=new WeakMap,ko=new WeakMap,me=new WeakSet,ji=function(e=n(this,ko)){const s=n(this,nu)+e/2*n(this,Ah);return n(this,wh)%180===0?[s/n(this,Ii),s/n(this,Li)]:[s/n(this,Li),s/n(this,Ii)]},PA=function(){const[e,s,i,r]=n(this,De),[a,o]=b(this,me,ji).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},MA=function(){const e=u(this,De,na.slice());for(const{line:r}of n(this,ds)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)I.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,d,f,m,y,A]=r.subarray(l,l+6);I.bezierBoundingBox(a,o,c,d,f,m,y,A,e),a=y,o=A}}const[s,i]=b(this,me,ji).call(this);e[0]=wt(e[0]-s,0,1),e[1]=wt(e[1]-i,0,1),e[2]=wt(e[2]+s,0,1),e[3]=wt(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},DA=function(e){const[s,i]=b(this,me,ji).call(this);u(this,ko,e);const[r,a]=b(this,me,ji).call(this),[o,l]=[r-s,a-i],h=n(this,De);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class fp extends Cm{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:gt._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 fp(this._viewParameters);return t.updateAll(this),t}}var Yf,IA;const qo=class qo extends wc{constructor(e){super({...e,name:"inkEditor"});g(this,Yf);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){gt.initialize(e,s),this._defaultDrawingOptions=new fp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return F(this,"typesMap",new Map([[et.INK_THICKNESS,"stroke-width"],[et.INK_COLOR,"stroke"],[et.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:e,y:s,box:[,,i,r],rotation:a}){return new Xw(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return pu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof xm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,opacity:f,borderStyle:{rawWidth:m},popupRef:y,richText:A,contentsObj:w,creationDate:v,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:W.INK,color:Array.from(d),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:y,richText:A,comment:(w==null?void 0:w.str)||null,creationDate:v,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 gf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return et.INK_COLOR}get colorAndOpacityType(){return et.INK_COLOR_AND_OPACITY}get opacityType(){return et.INK_OPACITY}updateParams(e,s){if(e===et.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===et.INK_COLOR_AND_OPACITY){super.updateDefaultParams(et.INK_COLOR,s.color),super.updateDefaultParams(et.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}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=qo.getDefaultDrawingOptions({stroke:I.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:gt._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,Yf,IA).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}};Yf=new WeakSet,IA=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},T(qo,"_type","ink"),T(qo,"_editorType",W.INK),T(qo,"_defaultDrawingOptions",null);let Zg=qo;class tm extends pu{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const vu=8,Bh=3;var Po,lt,em,si,LA,FA,sm,sf,RA,OA,NA,im,nm,BA;class Hi{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 d=200,f=c.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:w,fontBoundingBoxAscent:v,fontBoundingBoxDescent:S,width:E}=c.measureText(t),x=1.5,C=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||0,E)*x),_=Math.ceil(Math.max(Math.abs(A)+Math.abs(w)||d,Math.abs(v)+Math.abs(S)||d)*x);h=new OffscreenCanvas(C,_),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=f,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,_),c.fillStyle="black",c.fillText(t,C*(x-1)/2,_*(3-x)/2);const k=b(this,lt,im).call(this,c.getImageData(0,0,C,_).data),M=b(this,lt,NA).call(this,k),P=b(this,lt,nm).call(this,M),D=b(this,lt,sm).call(this,k,C,_,P);return this.processDrawnLines({lines:{curves:D,width:C,height:_},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,lt,BA).call(this,t),[h,c]=b(this,lt,OA).call(this,a,o,l,Math.hypot(o,l)*n(this,Po).sigmaSFactor,n(this,Po).sigmaR,n(this,Po).kernelSize),d=b(this,lt,nm).call(this,c),f=b(this,lt,sm).call(this,h,o,l,d);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,d=t.thickness??0,f=[],m=Math.min(e/h,s/c),y=m/e,A=m/s,w=[];for(const{points:S}of l){const E=a?b(this,lt,RA).call(this,S):S;if(!E)continue;w.push(E);const x=E.length,C=new Float32Array(x),_=new Float32Array(3*(x===2?2:x-2));if(f.push({line:_,points:C}),x===2){C[0]=E[0]*y,C[1]=E[1]*A,_.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[k,M,P,D]=E;k*=y,M*=A,P*=y,D*=A,C.set([k,M,P,D],0),_.set([NaN,NaN,NaN,NaN,k,M],0);for(let N=4;N<x;N+=2){const Z=C[N]=E[N]*y,Q=C[N+1]=E[N+1]*A;_.set(O.createBezierPoints(k,M,P,D,Z,Q),(N-2)*3),[k,M,P,D]=[P,D,Z,Q]}}if(f.length===0)return null;const v=o?new tm:new pu;return v.build(f,e,s,1,i,o?0:d,r),{outline:v,newCurves:w,areContours:o,thickness:d,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 S of t){l+=S.length;for(let E=2,x=S.length;E<x;E++){const C=S[E]-S[E-2];a=Math.min(a,C),o=Math.max(o,C)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=vu+Bh*c,f=new Uint32Array(d);let m=0;f[m++]=d*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 S of t)f[m++]=S.length-2,f[m++]=S[0],f[m++]=S[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(f);const w=h.prototype.constructor;for(const S of t){const E=new w(S.length-2);for(let x=2,C=S.length;x<C;x++)E[x-2]=S[x]-S[x-2];A.write(E)}return A.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(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],d=l[3],f=l[4]===0,m=l[5],y=l[6],A=l[7],w=[],v=(vu+Bh*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,v);break}o=0;for(let E=0;E<y;E++){const x=l[Bh*E+vu],C=new Float32Array(x+2);w.push(C);for(let _=0;_<Bh-1;_++)C[_]=l[Bh*E+vu+_+1];for(let _=0;_<x;_++)C[_+2]=C[_]+S[o++]}return{areContours:f,thickness:m,outlines:w,width:c,height:d}}catch(e){return X(`decompressSignature: ${e}`),null}}}Po=new WeakMap,lt=new WeakSet,em=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},si=new WeakMap,LA=function(t,e,s,i,r,a,o){const l=b(this,lt,em).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=n(this,si)[2*c],f=n(this,si)[2*c+1];if(t[(s+d)*e+(i+f)]!==0)return c}return-1},FA=function(t,e,s,i,r,a,o){const l=b(this,lt,em).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=n(this,si)[2*c],f=n(this,si)[2*c+1];if(t[(s+d)*e+(i+f)]!==0)return c}return-1},sm=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 d=1;d<e-1;d++){const f=c*e+d,m=a[f];if(m===0)continue;let y=c,A=d;if(m===1&&a[f-1]===0)o+=1,A-=1;else if(m>=1&&a[f+1]===0)o+=1,A+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const w=[d,c],v=A===d+1,S={isHole:v,points:w,id:o,parent:0};h.push(S);let E;for(const N of h)if(N.id===l){E=N;break}E?E.isHole?S.parent=v?E.parent:l:S.parent=v?l:E.parent:S.parent=v?l:0;const x=b(this,lt,LA).call(this,a,e,c,d,y,A,0);if(x===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let C=n(this,si)[2*x],_=n(this,si)[2*x+1];const k=c+C,M=d+_;y=k,A=M;let P=c,D=d;for(;;){const N=b(this,lt,FA).call(this,a,e,P,D,y,A,1);C=n(this,si)[2*N],_=n(this,si)[2*N+1];const Z=P+C,Q=D+_;w.push(Q,Z);const Y=P*e+D;if(a[Y+1]===0?a[Y]=-o:a[Y]===1&&(a[Y]=o),Z===c&&Q===d&&P===k&&D===M){a[f]!==1&&(l=Math.abs(a[f]));break}else y=P,A=D,P=Z,D=Q}}}return h},sf=function(t,e,s,i){if(s-e<=4){for(let k=e;k<s-2;k+=2)i.push(t[k],t[k+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,d=l/h,f=c*a-d*r,m=l/o,y=1/h,A=Math.atan(m),w=Math.cos(A),v=Math.sin(A),S=y*(Math.abs(w)+Math.abs(v)),E=y*(1-S+S**2),x=Math.max(Math.atan(Math.abs(v+w)*E),Math.atan(Math.abs(v-w)*E));let C=0,_=e;for(let k=e+2;k<s-2;k+=2){const M=Math.abs(f-c*t[k+1]+d*t[k]);M>C&&(_=k,C=M)}C>(h*x)**2?(b(this,lt,sf).call(this,t,e,_+2,i),b(this,lt,sf).call(this,t,_,s,i)):i.push(r,a)},RA=function(t){const e=[],s=t.length;return b(this,lt,sf).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},OA=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let A=0;A<a;A++){const w=(A-h)**2;for(let v=0;v<a;v++)o[A*a+v]=Math.exp((w+(v-h)**2)/l)}const c=new Float32Array(256),d=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/d);const f=t.length,m=new Uint8Array(f),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let w=0;w<e;w++){const v=A*e+w,S=t[v];let E=0,x=0;for(let _=0;_<a;_++){const k=A+_-h;if(!(k<0||k>=s))for(let M=0;M<a;M++){const P=w+M-h;if(P<0||P>=e)continue;const D=t[k*e+P],N=o[_*a+M]*c[Math.abs(D-S)];E+=D*N,x+=N}}const C=m[v]=Math.round(E/x);y[C]++}return[m,y]},NA=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},im=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},nm=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},BA=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,Po);let a=s,o=i;if(s>r||i>r){let f=s,m=i,y=Math.log2(Math.max(s,i)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let v=0;v<y;v++){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 w=Math.min(r/a,r/o);a=Math.round(a*w),o=Math.round(o*w)}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,lt,im).call(this,c),a,o]},g(Hi,lt),g(Hi,Po,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(Hi,si,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class km extends Cm{constructor(){super(),super.updateProperties({fill:gt._defaultLineColor,"stroke-width":0})}clone(){const t=new km;return t.updateAll(this),t}}class Pm extends fp{constructor(t){super(t),super.updateProperties({stroke:gt._defaultLineColor,"stroke-width":1})}clone(){const t=new Pm(this._viewParameters);return t.updateAll(this),t}}var Ir,Fi,Lr,Mo;const Qe=class Qe extends wc{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,Ir,!1);g(this,Fi,null);g(this,Lr,null);g(this,Mo,null);this._willKeepAspectRatio=!0,u(this,Lr,e.signatureData||null),u(this,Fi,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){gt.initialize(e,s),this._defaultDrawingOptions=new km,this._defaultDrawnSignatureOptions=new Pm(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return F(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Fi)}}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,Lr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,Lr),{rawDims:{pageWidth:d,pageHeight:f},rotation:m}=this.parent.viewport,y=Hi.processDrawnLines({lines:r,pageWidth:d,pageHeight:f,rotation:m,innerMargin:Qe._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,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,Fi)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){u(this,Mo,e),this.addEditToolbar()}getUuid(){return n(this,Mo)}get description(){return n(this,Fi)}set description(e){u(this,Fi,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,Lr),o=Math.max(r,a),l=Hi.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}=u(this,Lr,e);u(this,Ir,l instanceof tm),this.description=i;let h;n(this,Ir)?h=Qe.getDefaultDrawingOptions():(h=Qe._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let d=s/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,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 Hi.process(e,s,i,r,Qe._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Hi.extractContoursFromText(e,s,i,r,a,Qe._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Hi.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Qe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Qe.getDefaultDrawingOptions():(this._drawingOptions=Qe._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,Ir),color:[0,0,0],thickness:n(this,Ir)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,Mo),a.isCopy=!0):a.lines=s,n(this,Fi)&&(a.accessibilityData={type:"Figure",alt:n(this,Fi)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?tm.deserialize(e,s,i,r,a,o):pu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return u(r,Ir,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",u(r,Mo,e.uuid),r}};Ir=new WeakMap,Fi=new WeakMap,Lr=new WeakMap,Mo=new WeakMap,T(Qe,"_type","signature"),T(Qe,"_editorType",W.SIGNATURE),T(Qe,"_defaultDrawingOptions",null);let rm=Qe;var _t,le,Fr,Cn,Rr,vh,_n,Do,Ri,us,Sh,it,nc,rc,nf,rf,af,om,of,HA;class am extends gt{constructor(e){super({...e,name:"stampEditor"});g(this,it);g(this,_t,null);g(this,le,null);g(this,Fr,null);g(this,Cn,null);g(this,Rr,null);g(this,vh,"");g(this,_n,null);g(this,Do,!1);g(this,Ri,null);g(this,us,!1);g(this,Sh,!1);u(this,Cn,e.bitmapUrl),u(this,Rr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){gt.initialize(e,s)}static isHandlingMimeForPasting(e){return ff.has(e)}static paste(e,s){s.pasteEditor({mode:W.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)&&(u(this,_t,null),this._uiManager.imageManager.deleteId(n(this,le)),(e=n(this,_n))==null||e.remove(),u(this,_n,null),n(this,Ri)&&(clearTimeout(n(this,Ri)),u(this,Ri,null))),super.remove()}rebuild(){if(!this.parent){n(this,le)&&b(this,it,nf).call(this);return}super.rebuild(),this.div!==null&&(n(this,le)&&n(this,_n)===null&&b(this,it,nf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Fr)||n(this,_t)||n(this,Cn)||n(this,Rr)||n(this,le)||n(this,Do))}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,Do)||(n(this,_t)?b(this,it,rf).call(this):b(this,it,nf).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)&&(u(this,le,i),r&&u(this,_t,r),u(this,Do,!1),b(this,it,rf).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Ri)!==null&&clearTimeout(n(this,Ri)),u(this,Ri,setTimeout(()=>{u(this,Ri,null),b(this,it,om).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,_t),o=new bs;let l=n(this,_t),h=r,c=a,d=null;if(s){if(r>s||a>s){const k=Math.min(s/r,s/a);h=Math.floor(r*k),c=Math.floor(a*k)}d=document.createElement("canvas");const m=d.width=Math.ceil(h*o.sx),y=d.height=Math.ceil(c*o.sy);n(this,us)||(l=b(this,it,af).call(this,m,y));const A=d.getContext("2d");A.filter=this._uiManager.hcmFilter;let w="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":o0.isDarkMode&&(w="#8f8f9d",v="#42414d");const S=15,E=S*o.sx,x=S*o.sy,C=new OffscreenCanvas(E*2,x*2),_=C.getContext("2d");_.fillStyle=w,_.fillRect(0,0,E*2,x*2),_.fillStyle=v,_.fillRect(0,0,E,x),_.fillRect(E,x,E,x),A.fillStyle=A.createPattern(C,"repeat"),A.fillRect(0,0,m,y),A.drawImage(l,0,0,l.width,l.height,0,0,m,y)}let f=null;if(i){let m,y;if(o.symmetric&&l.width<e&&l.height<e)m=l.width,y=l.height;else if(l=n(this,_t),r>e||a>e){const v=Math.min(e/r,e/a);m=Math.floor(r*v),y=Math.floor(a*v),n(this,us)||(l=b(this,it,af).call(this,m,y))}const w=new OffscreenCanvas(m,y).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,m,y),f={width:m,height:y,data:w.getImageData(0,0,m,y).data}}return{canvas:d,width:h,height:c,imageData:f}}static async deserialize(e,s,i){var w;let r=null,a=!1;if(e instanceof rA){const{data:{rect:v,rotation:S,id:E,structParent:x,popupRef:C,richText:_,contentsObj:k,creationDate:M,modificationDate:P},container:D,parent:{page:{pageNumber:N}},canvas:Z}=e;let Q,Y;Z?(delete e.canvas,{id:Q,bitmap:Y}=i.imageManager.getFromCanvas(D.id,Z),Z.remove()):(a=!0,e._hasNoCanvas=!0);const K=((w=await s._structTree.getAriaAttributes(`${Yo}${E}`))==null?void 0:w.get("aria-label"))||"";r=e={annotationType:W.STAMP,bitmapId:Q,bitmap:Y,pageIndex:N-1,rect:v.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:K},isSvg:!1,structParent:x,popupRef:C,richText:_,comment:(k==null?void 0:k.str)||null,creationDate:M,modificationDate:P}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:f,accessibilityData:m}=e;a?(i.addMissingCanvas(e.id,o),u(o,Do,!0)):d&&i.imageManager.isValidId(d)?(u(o,le,d),h&&u(o,_t,h)):u(o,Cn,c),u(o,us,f);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e),u(o,Sh,!!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,us)});if(this.addComment(i),e)return i.bitmapUrl=b(this,it,of).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,it,HA).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,us)?(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,it,of).call(this,!1);else if(n(this,us)){const l=s.stamps.get(n(this,le));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,it,of).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}_t=new WeakMap,le=new WeakMap,Fr=new WeakMap,Cn=new WeakMap,Rr=new WeakMap,vh=new WeakMap,_n=new WeakMap,Do=new WeakMap,Ri=new WeakMap,us=new WeakMap,Sh=new WeakMap,it=new WeakSet,nc=function(e,s=!1){if(!e){this.remove();return}u(this,_t,e.bitmap),s||(u(this,le,e.id),u(this,us,e.isSvg)),e.file&&u(this,vh,e.file.name),b(this,it,rf).call(this)},rc=function(){if(u(this,Fr,null),this._uiManager.enableWaiting(!1),!!n(this,_n)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,_t)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,_t)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},nf=function(){if(n(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,le)).then(i=>b(this,it,nc).call(this,i,!0)).finally(()=>b(this,it,rc).call(this));return}if(n(this,Cn)){const i=n(this,Cn);u(this,Cn,null),this._uiManager.enableWaiting(!0),u(this,Fr,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,it,nc).call(this,r)).finally(()=>b(this,it,rc).call(this)));return}if(n(this,Rr)){const i=n(this,Rr);u(this,Rr,null),this._uiManager.enableWaiting(!0),u(this,Fr,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,it,nc).call(this,r)).finally(()=>b(this,it,rc).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=ff.keys().join(",");const s=this._uiManager._signal;u(this,Fr,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,it,nc).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,it,rc).call(this))),e.click()},rf=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,_t);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=u(this,_n,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,it,om).call(this),n(this,Sh)||(this.parent.addUndoableEditor(this),u(this,Sh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,vh)&&this.div.setAttribute("aria-description",n(this,vh)),this.annotationElementId||this._uiManager.a11yAlert(gt._l10nAlert.stamp)},af=function(e,s){const{width:i,height:r}=n(this,_t);let a=i,o=r,l=n(this,_t);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=d.transferToImageBitmap()}return l},om=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new bs,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,_n);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,us)?n(this,_t):b(this,it,af).call(this,o,l),d=h.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(c,0,0,c.width,c.height,0,0,o,l)},of=function(e){if(e){if(n(this,us)){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,_t),s.getContext("2d").drawImage(n(this,_t),0,0),s.toDataURL()}if(n(this,us)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Rn.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Rn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,_t),0,0,n(this,_t).width,n(this,_t).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,_t))},HA=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}},T(am,"_type","stamp"),T(am,"_editorType",W.STAMP);var Io,Eh,Or,Nr,Tn,We,Br,xh,Ch,ii,kn,Xe,Pn,Hr,_h,H,Ur,bt,lm,UA,hi,hm,cm,lf;const $s=class $s{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,bt);g(this,Io);g(this,Eh,!1);g(this,Or,null);g(this,Nr,null);g(this,Tn,null);g(this,We,new Map);g(this,Br,!1);g(this,xh,!1);g(this,Ch,!1);g(this,ii,null);g(this,kn,null);g(this,Xe,null);g(this,Pn,null);g(this,Hr,null);g(this,_h,-1);g(this,H);const d=[...n($s,Ur).values()];if(!$s._initialized){$s._initialized=!0;for(const f of d)f.initialize(c,t)}t.registerEditorTypes(d),u(this,H,t),this.pageIndex=e,this.div=s,u(this,Io,r),u(this,Or,a),this.viewport=h,u(this,Xe,l),this.drawLayer=o,this._structTree=i,n(this,H).addLayer(this)}get isEmpty(){return n(this,We).size===0}get isInvisible(){return this.isEmpty&&n(this,H).getMode()===W.NONE}updateToolbar(t){n(this,H).updateToolbar(t)}updateMode(t=n(this,H).getMode()){switch(b(this,bt,lf).call(this),t){case W.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case W.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case W.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===W.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n($s,Ur).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Xe))==null?void 0:e.div)}setEditingState(t){n(this,H).setEditingState(t)}addCommands(t){n(this,H).addCommands(t)}cleanUndoStack(t){n(this,H).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,Or))==null||e.togglePointerEvents(t)}async enable(){var s;u(this,Ch,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Hr))==null||s.abort(),u(this,Hr,null);const t=new Set;for(const i of n(this,bt,lm))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,H).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,Or);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,H).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}u(this,Ch,!1),n(this,H)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(u(this,xh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Xe)&&!n(this,Hr)){u(this,Hr,new AbortController);const r=n(this,H).combinedSignal(n(this,Hr));n(this,Xe).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,d=n(this,_h);if(c-d>500){u(this,_h,c);return}u(this,_h,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const m=document.elementsFromPoint(l,h);if(f.toggle("getElements",!1),!this.div.contains(m[0]))return;let y;const A=new RegExp(`^${Ph}[0-9]+$`);for(const v of m)if(A.test(v.id)){y=v.id;break}if(!y)return;const w=n(this,We).get(y);(w==null?void 0:w.annotationElementId)===null&&(Kt(a),w.dblclick(a))},{signal:r,capture:!0})}const t=n(this,Or),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,bt,lm)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,H).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(n(this,H).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,bt,lf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n($s,Ur).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),u(this,xh,!1)}getEditableAnnotation(t){var e;return((e=n(this,Or))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,H).getActive()!==t&&n(this,H).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Xe))!=null&&t.div&&!n(this,Pn)){u(this,Pn,new AbortController);const e=n(this,H).combinedSignal(n(this,Pn));n(this,Xe).div.addEventListener("pointerdown",b(this,bt,UA).bind(this),{signal:e}),n(this,Xe).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Xe))!=null&&t.div&&n(this,Pn)&&(n(this,Pn).abort(),u(this,Pn,null),n(this,Xe).div.classList.remove("highlighting"))}enableClick(){if(n(this,Nr))return;u(this,Nr,new AbortController);const t=n(this,H).combinedSignal(n(this,Nr));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,Nr))==null||t.abort(),u(this,Nr,null)}attach(t){n(this,We).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,H).isDeletedAnnotationElement(e)&&n(this,H).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,We).delete(t.id),(e=n(this,Io))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,xh)&&t.annotationElementId&&n(this,H).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,H).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,H).addDeletedAnnotationElement(t),gt.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,H).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,Ch)),n(this,H).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,Tn)&&(t._focusEventsAllowed=!1,u(this,Tn,setTimeout(()=>{u(this,Tn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,H)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,Io))==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,We).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,H).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,bt,hi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,H).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,bt,cm).call(this),r=n(this,H).getId(),a=b(this,bt,hm).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,H),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n($s,Ur).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,H)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,H).getId(),r=b(this,bt,hm).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,H),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,bt,cm).call(this),!0,t)}setSelected(t){n(this,H).setSelected(t)}toggleSelected(t){n(this,H).toggleSelected(t)}unselect(t){n(this,H).unselect(t)}pointerup(t){var i;const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Br)||(u(this,Br,!1),(i=n(this,bt,hi))!=null&&i.isDrawer&&n(this,bt,hi).supportMultipleDrawings))return;if(!n(this,Eh)){u(this,Eh,!0);return}const s=n(this,H).getMode();if(s===W.STAMP||s===W.POPUP||s===W.SIGNATURE){n(this,H).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,H).getMode()===W.HIGHLIGHT&&this.enableTextSelection(),n(this,Br)){u(this,Br,!1);return}const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(u(this,Br,!0),(i=n(this,bt,hi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,H).getActive();u(this,Eh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,ii)){n(this,bt,hi).startDrawing(this,n(this,H),!1,t);return}n(this,H).setCurrentDrawingSession(this),u(this,ii,new AbortController);const e=n(this,H).combinedSignal(n(this,ii));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(u(this,kn,null),this.commitOrRemove())},{signal:e}),n(this,bt,hi).startDrawing(this,n(this,H),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&u(this,kn,e);return}n(this,kn)&&setTimeout(()=>{var e;(e=n(this,kn))==null||e.focus(),u(this,kn,null)},0)}endDrawingSession(t=!1){return n(this,ii)?(n(this,H).setCurrentDrawingSession(null),n(this,ii).abort(),u(this,ii,null),u(this,kn,null),n(this,bt,hi).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,H).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,ii)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,ii)&&n(this,bt,hi).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,H).getActive())==null?void 0:t.parent)===this&&(n(this,H).commitOrRemove(),n(this,H).setActiveEditor(null)),n(this,Tn)&&(clearTimeout(n(this,Tn)),u(this,Tn,null));for(const s of n(this,We).values())(e=n(this,Io))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,We).clear(),n(this,H).removeLayer(this)}async render({viewport:t}){this.viewport=t,jr(this.div,t);for(const e of n(this,H).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,H).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,H).commitOrRemove(),b(this,bt,lf).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,jr(this.div,{rotation:s}),e!==s)for(const i of n(this,We).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,H).viewParameters.realScale}};Io=new WeakMap,Eh=new WeakMap,Or=new WeakMap,Nr=new WeakMap,Tn=new WeakMap,We=new WeakMap,Br=new WeakMap,xh=new WeakMap,Ch=new WeakMap,ii=new WeakMap,kn=new WeakMap,Xe=new WeakMap,Pn=new WeakMap,Hr=new WeakMap,_h=new WeakMap,H=new WeakMap,Ur=new WeakMap,bt=new WeakSet,lm=function(){return n(this,We).size!==0?n(this,We).values():n(this,H).getEditors(this.pageIndex)},UA=function(t){n(this,H).unselectAll();const{target:e}=t;if(e===n(this,Xe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,Xe).div.contains(e)){const{isMac:s}=ot.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,H).showAllEditors("highlight",!0,!0),yf.startDrawing(this,n(this,H),n(this,H).direction==="ltr",t),t.preventDefault()}},hi=function(){return n($s,Ur).get(n(this,H).getMode())},hm=function(t){const e=n(this,bt,hi);return e?new e.prototype.constructor(t):null},cm=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,[d,f]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:f}},lf=function(){for(const t of n(this,We).values())t.isEmpty()&&t.remove()},T($s,"_initialized",!1),g($s,Ur,new Map([Bg,Zg,am,yf,rm].map(t=>[t._editorType,t])));let Af=$s;function Yw(p,t){return p===t?0:p.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Su(p){var t;return p?p.nodeType===Node.ELEMENT_NODE?p.closest(".textLayer"):((t=p.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function Kw(p,t,e,s){if(p===e)return t<=s;const i=p.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function fb(p,t,e){if(p.nodeType!==Node.ELEMENT_NODE||!p.classList.contains("textLayer")||t!==p.childNodes.length)return{container:p,offset:t};let s=p.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var Ie,Le,Ns,ru,au,Lo,Fo,ou,Kf,Gr,$r,zr,Vr,Mn,Ce,dm,um,GA,hf,$A,zi,fm,zA,pm;const $=class ${constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){g(this,zi);g(this,Ie,null);g(this,Le,new Map);g(this,Ns,null);g(this,ru,null);g(this,au,null);g(this,Lo,null);g(this,Fo,new Map);if(this.pageIndex=s,u(this,ru,t),u(this,au,e),i){const r=n($,Mn).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n($,$r).delete(r.selectionDiv)),n($,Mn).set(i,{drawLayer:this}),n($,Vr).add(i),u(this,Ns,i),u(this,Lo,new MutationObserver(a=>{var o,l,h;if(!(!n(this,Ie)||!((o=n(this,Ns))!=null&&o.isConnected)||!b(l=$,Ce,um).call(l))){for(const{addedNodes:c}of a)for(const d of c)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){b(h=$,Ce,hf).call(h);return}}})),n(this,Lo).observe(i,{childList:!0}),n($,Gr)===null){u($,Gr,new AbortController);const{signal:a}=n($,Gr);document.addEventListener("selectionchange",b($,Ce,hf).bind($),{signal:a}),document.addEventListener("pointerdown",()=>{u($,zr,!0)},{signal:a}),document.addEventListener("pointerup",()=>{u($,zr,!1)},{signal:a}),window.addEventListener("blur",()=>{u($,zr,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Ie)){u(this,Ie,t),(e=n(this,Ns))!=null&&e.isConnected&&b(s=$,Ce,um).call(s)&&b(i=$,Ce,hf).call(i);return}if(n(this,Ie)!==t){if(n(this,Le).size>0)for(const r of n(this,Le).values())r.remove(),t.append(r);u(this,Ie,t)}}static get _svgFactory(){return F(this,"_svgFactory",new Ac)}draw(t,e=!1,s=!1){const i=yt($,ou)._++,r=b(this,zi,fm).call(this),a=$._svgFactory.createElement("defs");r.append(a);const o=$._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,Fo).set(i,o);const h=s?b(this,zi,zA).call(this,a,l):null,c=$._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Le).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=yt($,ou)._++,i=b(this,zi,fm).call(this),r=$._svgFactory.createElement("defs");i.append(r);const a=$._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=$._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=$._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const m=$._svgFactory.createElement("use");d.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=$._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,Le).set(s,i),s}finalizeDraw(t,e){n(this,Fo).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,Le).get(t):t;if(o){if(s&&b(this,zi,pm).call(this,o,s),i&&b(l=$,Ce,$A).call(l,o,i),r){const{classList:h}=o;for(const[c,d]of Object.entries(r))h.toggle(c,d)}if(a){const c=o.firstElementChild.firstElementChild;b(this,zi,pm).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Le).get(t);s&&(n(e,Ie).append(s),n(this,Le).delete(t),n(e,Le).set(t,s))}remove(t){n(this,Fo).delete(t),n(this,Ie)!==null&&(n(this,Le).get(t).remove(),n(this,Le).delete(t))}destroy(){var t,e,s;u(this,Ie,null);for(const i of n(this,Le).values())i.remove();if(n(this,Le).clear(),n(this,Fo).clear(),(t=n(this,Lo))==null||t.disconnect(),u(this,Lo,null),n(this,Ns)){const i=n($,Mn).get(n(this,Ns));(i==null?void 0:i.drawLayer)===this&&(b(e=$,Ce,dm).call(e,n(this,Ns)),n($,Mn).delete(n(this,Ns)),n($,Vr).delete(n(this,Ns)),n($,Vr).size===0&&((s=n($,Gr))==null||s.abort(),u($,Gr,null),u($,zr,!1))),u(this,Ns,null)}}};Ie=new WeakMap,Le=new WeakMap,Ns=new WeakMap,ru=new WeakMap,au=new WeakMap,Lo=new WeakMap,Fo=new WeakMap,ou=new WeakMap,Kf=new WeakMap,Gr=new WeakMap,$r=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Mn=new WeakMap,Ce=new WeakSet,dm=function(t){const e=n(this,Mn).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,$r).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},um=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},GA=function(){return n(this,Vr).keys().filter(t=>t.isConnected).toArray().sort(Yw)},hf=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,$r))o.remove();n(this,$r).clear();return}const e=new WeakMap,s=b(this,Ce,GA).call(this),i=[];for(let o=0,l=t.rangeCount;o<l;o++){const h=t.getRangeAt(o);if(h.collapsed)continue;let{startContainer:c,startOffset:d,endContainer:f,endOffset:m}=h,y=Su(c),A=Su(f);const w=y===null,v=A===null;if(n(this,zr)&&w!==v)return;if(t.rangeCount===1){const{anchorNode:x,anchorOffset:C,focusNode:_,focusOffset:k}=t,M=Su(x),P=Su(_),D=Kw(x,C,_,k);M&&P&&D!==null&&(D?(c=x,d=C,y=M,f=_,m=k,A=P):(c=_,d=k,y=P,f=x,m=C,A=M))}const S=s.filter(x=>h.intersectsNode(x));if(S.length===0)continue;let E=!1;if(y||(y=S[0],c=y,d=0,E=!0),A||(A=S.at(-1),f=A,m=A.childNodes.length,E=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const x=f.previousSibling;if(!x)continue;f=x,m=x.nodeType===Node.TEXT_NODE?x.textContent.length:x.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===m){const x=fb(f,m,A);if(!x)continue;f=x.container,m=x.offset}}if(c.nodeType===Node.ELEMENT_NODE){const x=fb(c,d,y);if(!x)continue;c=x.container,d=x.offset}if(y===A&&!E&&S.includes(y)){i.push([h,y]);continue}for(const x of S){const C=x.firstChild;if(!C)continue;const _=document.createRange();if(x===y?_.setStart(c,d):_.setStartBefore(C),x===A)_.setEnd(f,m);else{const k=x.lastChild;if(!k)continue;if(k.nodeType===Node.ELEMENT_NODE&&k.classList.contains("endOfContent")){const M=k.previousSibling;if(!M)continue;_.setEndAfter(M)}else _.setEndAfter(k)}_.collapsed||i.push([_,x])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,Vr))r.has(o)||b(this,Ce,dm).call(this,o);for(const[o,l]of i){const h=n($,Mn).get(l);if(!h)continue;let c=e.get(l);if(!c){const A=l.getBoundingClientRect();c=(w,v,S,E)=>({x:(w-A.x)/A.width,y:(v-A.y)/A.height,width:S/A.width,height:E/A.height}),e.set(l,c)}const d=[];for(let{x:A,y:w,width:v,height:S}of o.getClientRects())v===0||S===0||({x:A,y:w,width:v,height:S}=c(A,w,v,S),!(v===1&&S===1)&&d.push(`M${A} ${w} h${v} v${S} h-${v} Z`));if(d.length===0)continue;const f=h.drawLayer;let m=h.selectionDiv,y=h.path;if(!m){const A=`clip_selection_${yt($,Kf)._++}`;m=document.createElement("div"),m.className="selection",m.style.clipPath=`url(#${A})`;const w=(a=n(f,ru))==null?void 0:a.createSelectionStyle(n(f,au));if(w)for(const[E,x]of Object.entries(w))m.style.setProperty(E,x);const v=$._svgFactory.create(1,1,!0);v.setAttribute("aria-hidden","true"),v.setAttribute("width","100%"),v.setAttribute("height","100%");const S=$._svgFactory.createElement("clipPath");S.setAttribute("id",A),S.setAttribute("clipPathUnits","objectBoundingBox"),y=$._svgFactory.createElement("path"),S.append(y),v.append(S),m.append(v),h.path=y,h.selectionDiv=m}n(f,Ie)&&m.parentNode!==n(f,Ie)&&(n(f,Ie).append(m),n(this,$r).add(m)),y.setAttribute("d",d.join(" "))}},$A=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}%`},zi=new WeakSet,fm=function(){const t=$._svgFactory.create(1,1,!0);return n(this,Ie).append(t),t.setAttribute("aria-hidden","true"),t},zA=function(t,e){const s=$._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=$._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},pm=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},g($,Ce),g($,ou,0),g($,Kf,0),g($,Gr,null),g($,$r,new Set),g($,zr,!1),g($,Vr,new Set),g($,Mn,new WeakMap);let wf=$;function Eu(p){return`${(p*100).toFixed(2)}%`}var Th,lu,hu,kh,Oi,Ni,cu,qf,VA;const uc=class uc{constructor(t,e,s,i){g(this,qf);g(this,Th,[]);g(this,lu,new Map);g(this,hu,null);g(this,kh,0);g(this,Oi,0);g(this,Ni,0);u(this,kh,t),u(this,Th,e),u(this,Oi,s.rawDims.pageWidth),u(this,Ni,s.rawDims.pageHeight),u(this,hu,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,Th).length;e+=6){const s=b(this,qf,VA).call(this,n(this,Th).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var v;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,lu).get(s);if(!i)return;const r=(v=n(uc,cu))==null?void 0:v.deref();if(r===s)return;r&&(r.width=0,r.height=0),u(uc,cu,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,d=n(this,hu).call(this),f=Math.ceil(o*d.width),m=Math.ceil(l*d.height),y=Math.floor((o+h/n(this,Oi))*d.width),A=Math.floor((l+c/n(this,Ni))*d.height);s.width=y-f,s.height=A-m;const w=s.getContext("2d");w.setTransform(...a),w.translate(-f,-m),w.drawImage(d,0,0)}),t}};Th=new WeakMap,lu=new WeakMap,hu=new WeakMap,kh=new WeakMap,Oi=new WeakMap,Ni=new WeakMap,cu=new WeakMap,qf=new WeakSet,VA=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Oi),(a-e)*n(this,Ni)),l=Math.hypot((s-t)*n(this,Oi),(i-e)*n(this,Ni));if(o<n(this,kh)||l<n(this,kh))return null;const h=[(r-t)*n(this,Oi)/o,(a-e)*n(this,Ni)/o,(s-t)*n(this,Oi)/l,(i-e)*n(this,Ni)/l,0,0],c=I.inverseTransform(h),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:Eu(t),top:Eu(e),width:Eu(o/n(this,Oi)),height:Eu(l/n(this,Ni)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,lu).set(d,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),d},g(uc,cu,null);let vf=uc;globalThis._pdfjsTestingUtils={HighlightOutliner:Xg};globalThis.pdfjsLib={AbortException:Fn,AnnotationEditorLayer:Af,AnnotationEditorParamsType:et,AnnotationEditorType:W,AnnotationEditorUIManager:Wr,AnnotationLayer:mf,AnnotationMode:Dn,AnnotationType:Et,applyOpacity:Sb,build:Yy,ColorPicker:yc,createValidAbsoluteUrl:gm,CSSConstants:vb,DOMSVGFactory:Ac,DrawLayer:wf,FeatureTest:ot,fetchData:sp,findContrastColor:Eb,getDocument:Vy,getFilenameFromUrl:Ab,getPdfFilenameFromUrl:wb,getRGB:Rh,getRGBA:Uo,getUuid:bm,GlobalWorkerOptions:Bi,ImageKind:ac,InvalidPDFException:df,isDataScheme:fu,isPdfFile:np,isValidExplicitDest:hy,makeArr:Ho,makeMap:tp,makeObj:uf,makeSet:yb,MathClamp:wt,noContextMenu:Us,normalizeUnicode:bb,OPS:ni,OutputScale:bs,PasswordException:cf,PasswordResponses:mb,PDFDataRangeTransport:Sm,PDFDateString:gc,PDFWorker:Dh,PermissionFlag:gb,PixelsPerInch:Rn,RenderingCancelledException:ip,renderRichText:ym,ResponseException:fc,setLayerDimensions:jr,shadow:F,SignatureExtractor:Hi,stopEvent:Kt,SupportedImageMimeTypes:ff,TextLayer:Mh,TextLayerImages:vf,TouchManager:Am,updateUrlHash:mm,Util:I,VerbosityLevel:du,version:Xy,XfaLayer:ep};const Qw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Fn,AnnotationEditorLayer:Af,AnnotationEditorParamsType:et,AnnotationEditorType:W,AnnotationEditorUIManager:Wr,AnnotationLayer:mf,AnnotationMode:Dn,AnnotationType:Et,CSSConstants:vb,ColorPicker:yc,DOMSVGFactory:Ac,DrawLayer:wf,FeatureTest:ot,GlobalWorkerOptions:Bi,ImageKind:ac,InvalidPDFException:df,MathClamp:wt,OPS:ni,OutputScale:bs,PDFDataRangeTransport:Sm,PDFDateString:gc,PDFWorker:Dh,PasswordException:cf,PasswordResponses:mb,PermissionFlag:gb,PixelsPerInch:Rn,RenderingCancelledException:ip,ResponseException:fc,SignatureExtractor:Hi,SupportedImageMimeTypes:ff,TextLayer:Mh,TextLayerImages:vf,TouchManager:Am,Util:I,VerbosityLevel:du,XfaLayer:ep,applyOpacity:Sb,build:Yy,createValidAbsoluteUrl:gm,fetchData:sp,findContrastColor:Eb,getDocument:Vy,getFilenameFromUrl:Ab,getPdfFilenameFromUrl:wb,getRGB:Rh,getRGBA:Uo,getUuid:bm,isDataScheme:fu,isPdfFile:np,isValidExplicitDest:hy,makeArr:Ho,makeMap:tp,makeObj:uf,makeSet:yb,noContextMenu:Us,normalizeUnicode:bb,renderRichText:ym,setLayerDimensions:jr,shadow:F,stopEvent:Kt,updateUrlHash:mm,version:Xy},Symbol.toStringTag,{value:"Module"}));function Jw(p){return new Worker("/assets/pdf.worker.min-ypFJvUNP.js",{type:"module",name:p==null?void 0:p.name})}export{Bi as G,Jw as W,Qw as p};
55
+ `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},dA=function(){return n(this,os).replaceAll(" "," ")},Hg=function(e){return e.replaceAll(" "," ")},uA=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(vt,Ln),T(vt,"_freeTextDefaultContent",""),T(vt,"_internalPadding",0),T(vt,"_defaultColor",null),T(vt,"_defaultFontSize",10),T(vt,"_type","freetext"),T(vt,"_editorType",W.FREETEXT);let Bg=vt;var Ao;class Cm{constructor(){g(this,Ao,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,Ao)[t]=e}toSVGProperties(){const t=n(this,Ao);return u(this,Ao,Object.create(null)),{root:t}}reset(){u(this,Ao,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}Ao=new WeakMap;var oh,lh,Wt,wo,vo,hh,V,Ug,Gg,$g,zg,tc,Vg,jg,Wg,ec,fA,Qu,sc,Xo;const q=class q extends gt{constructor(e){super(e);g(this,V);g(this,oh,null);g(this,lh);T(this,"_clipPathId",null);T(this,"_colorPicker",null);T(this,"_drawId",null);T(this,"_drawOutlines",null);T(this,"_focusDrawId",null);u(this,lh,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,V,Ug).call(this,e),b(this,V,ec).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){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(q,Wt).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=this._drawOutlines.updateProperty(s,l);h&&b(this,V,sc).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};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})}_updateColorAndOpacity(e,s,i=this.colorAndOpacityType){const r=this.constructor.typesMap.get(this.colorType),a=this._opacityName,o=this._drawingOptions,l=o[r],h=o[a],c=(d,f)=>{var m;o.updateProperty(r,d),o.updateProperty(a,f),this._drawOutlines.updateProperty(r,d),this._drawOutlines.updateProperty(a,f),(m=this.parent)==null||m.drawLayer.updateProperties(this._drawId,o.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:c.bind(this,e,s),undo:c.bind(this,l,h),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(b(this,V,Qu).call(this)),{bbox:b(this,V,Xo).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(b(this,V,Qu).call(this)),{bbox:b(this,V,Xo).call(this)})),b(this,V,zg).call(this)}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,V,Xo).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(b(this,V,Qu).call(this),this.parentDimensions),{bbox:b(this,V,Xo).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}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit(),this._mustBeDisabledOnCommit&&(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,lh)&&(u(this,lh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),b(this,V,Wg).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,V,ec).call(this),b(this,V,sc).call(this,this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,V,Wg).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,V,ec).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),b(this,V,Vg).call(this),s&&this.select()}rotate(e=this.parentRotation){if(!this.parent||this._drawId===null)return;const s=(e-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,q._mergeSVGProperties({bbox:b(this,V,Xo).call(this,e)},this._drawOutlines.updateRotation(s))),b(this,V,zg).call(this,s)}show(e=this._isVisible){super.show(e),b(this,V,Vg).call(this)}select(){super.select(),b(this,V,tc).call(this,{hovered:!1,selected:!0})}unselect(){super.unselect(),b(this,V,tc).call(this,{selected:!1})}pointerover(){this.isSelected||b(this,V,tc).call(this,{hovered:!0})}pointerleave(){this.isSelected||b(this,V,tc).call(this,{hovered:!1})}onScaleChanging(){if(!this.parent)return;const e=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);e&&b(this,V,sc).call(this,e)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();this.constructor._hasDrawClass&&i.classList.add("draw");const r=u(this,oh,document.createElement("div"));return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this._clipPathId&&(r.style.clipPath=this._clipPathId),Mb(this,r,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e){st("Not implemented")}static _getDrawingTarget(e,{target:s}){return s}static _getPointerCoords({offsetX:e,offsetY:s,clientX:i,clientY:r},a=null){if(!a)return[e,s];let o=i-a.clientX,l=r-a.clientY;switch(this._currentParent.viewport.rotation){case 90:[o,l]=[l,-o];break;case 180:[o,l]=[-o,-l];break;case 270:[o,l]=[-l,o];break}return[a.offsetX+o,a.offsetY+l]}static _addDrawingListeners(e,s){}static _endDrawingSession(e=!1){return this._currentParent.endDrawingSession(e)}static startDrawing(e,s,i,r){var x;const{pointerId:a,pointerType:o}=r;if(we.isInitializedAndDifferentPointerType(o))return;const l=this._getDrawingTarget(e,r),[h,c]=this._getPointerCoords(r),{viewport:{rotation:d}}=e,{x:f,y:m,width:y,height:A}=l.getBoundingClientRect(),w=u(q,wo,new AbortController),v=e.combinedSignal(w);if(we.setPointer(o,a),window.addEventListener("pointerup",C=>{we.isSamePointerIdOrRemove(C.pointerId)&&this._endDraw(C)},{signal:v}),window.addEventListener("pointercancel",C=>{we.isSamePointerIdOrRemove(C.pointerId)&&this._endDrawingSession()},{signal:v}),window.addEventListener("pointerdown",C=>{we.isSamePointerType(C.pointerType)&&(we.initializeAndAddPointerId(C.pointerId),n(q,Wt).isCancellable()&&(n(q,Wt).removeLastElement(),n(q,Wt).isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",Us,{signal:v}),l.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),l.addEventListener("touchmove",C=>{we.isSameTimeStamp(C.timeStamp)&&Kt(C)},{signal:v}),this._addDrawingListeners(l,v),e.toggleDrawing(),(x=s._editorUndoBar)==null||x.hide(),n(q,Wt)){e.drawLayer.updateProperties(this._currentDrawId,n(q,Wt).startNew(h,c,y,A,d));return}s.updateUIForDefaultProperties(this),u(q,Wt,this.createDrawerInstance({x:h,y:c,box:[f,m,y,A],rotation:d,parent:e,isLTR:i})),u(q,vo,this.getDefaultDrawingOptions()),this._currentParent=e;const{id:S,clipPathId:E}=e.drawLayer.draw(this._mergeSVGProperties(n(q,vo).toSVGProperties(),n(q,Wt).defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=S,u(q,hh,this._hasClipPath?E:null)}static _drawMove(e){var r;if(we.isSameTimeStamp(e.timeStamp),!n(q,Wt)||!we.isSamePointerId(e.pointerId))return;if(we.isUsingMultiplePointers()){this._endDraw(e);return}let s;const i=(r=e.getCoalescedEvents)==null?void 0:r.call(e);if(i!=null&&i.length){const a=[];for(const o of i)a.push(...this._getPointerCoords(o,e));s=n(q,Wt).addPoints(a)}else s=n(q,Wt).add(...this._getPointerCoords(e));this._currentParent.drawLayer.updateProperties(this._currentDrawId,s),we.setTimeStamp(e.timeStamp),Kt(e)}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,u(q,Wt,null),u(q,vo,null),u(q,hh,null),we.clearTimeStamp()),n(q,wo)&&(n(q,wo).abort(),u(q,wo,null),we.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),s.drawLayer.updateProperties(this._currentDrawId,(e==null?void 0:e.target)===s.div?n(q,Wt).end(...this._getPointerCoords(e)):n(q,Wt).end()),this.supportMultipleDrawings){const i=n(q,Wt),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:et.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(et.DRAW_STEP),!n(q,Wt).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:n(q,hh),drawOutlines:n(q,Wt).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(q,vo),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,l){st("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e,i),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(d=c,V,Ug).call(d,{drawOutlines:h}),b(f=c,V,ec).call(f),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return this._drawOutlines.serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};oh=new WeakMap,lh=new WeakMap,Wt=new WeakMap,wo=new WeakMap,vo=new WeakMap,hh=new WeakMap,V=new WeakSet,Ug=function({drawOutlines:e,drawId:s,drawingOptions:i,clipPathId:r}){this._drawOutlines=e,this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(gt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this._clipPathId=r??null,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties),b(this,V,$g).call(this,this.parent)):this._drawId=b(this,V,Gg).call(this,e,this.parent),b(this,V,sc).call(this,e.box)},Gg=function(e,s){const{id:i,clipPathId:r}=s.drawLayer.draw(q._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,this.constructor._hasClipPath);return this.constructor._hasClipPath&&(this._clipPathId=r),b(this,V,$g).call(this,s),i},$g=function(e){const s=this._drawOutlines.getFocusSVGProperties(n(this,V,jg));s&&(this._focusDrawId=e.drawLayer.drawOutline(s,this._drawOutlines.focusMustRemoveSelfIntersections))},zg=function(e=n(this,V,jg)){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(e)))},tc=function(e){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,{rootClass:e}))},Vg=function(){const{parent:e,_drawId:s,_focusDrawId:i,_isVisible:r}=this;if(!e||s===null)return;const a={hidden:!r};e.drawLayer.updateProperties(s,{rootClass:a}),i!==null&&e.drawLayer.updateProperties(i,{rootClass:a})},jg=function(){return(this.parentRotation-this._drawRotation+360)%360},Wg=function(){if(this._drawId===null||!this.parent)return;const{drawLayer:e}=this.parent;e.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(e.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()},ec=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){const{drawLayer:s}=this.parent;s.updateParent(this._drawId,e.drawLayer),this._focusDrawId!==null&&s.updateParent(this._focusDrawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,V,Gg).call(this,this._drawOutlines,e),this._clipPathId&&n(this,oh)&&(n(this,oh).style.clipPath=this._clipPathId)}},fA=function([e,s,i,r]){const{parentDimensions:[a,o],_drawRotation: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]}},Qu=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],_drawRotation: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]}},sc=function(e){[this.x,this.y,this.width,this.height]=b(this,V,fA).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Xo=function(e=this.parentRotation){const{x:s,y:i,width:r,height:a,_drawRotation:o,parentDimensions:[l,h]}=this;switch((o*4+e)/90){case 1:return[1-i-a,s,a,r];case 2:return[1-s-r,1-i-a,r,a];case 3:return[i,1-s-r,a,r];case 4:return[s,i-r*(l/h),a*(h/l),r*(l/h)];case 5:return[1-i,s,r*(l/h),a*(h/l)];case 6:return[1-s-a*(h/l),1-i,a*(h/l),r*(l/h)];case 7:return[i-r*(l/h),1-s-a*(h/l),r*(l/h),a*(h/l)];case 8:return[s-r,i-a,r,a];case 9:return[1-i,s-r,a,r];case 10:return[1-s,1-i,r,a];case 11:return[i-a,1-s,a,r];case 12:return[s-a*(h/l),i,a*(h/l),r*(l/h)];case 13:return[1-i-r*(l/h),s-a*(h/l),r*(l/h),a*(h/l)];case 14:return[1-s,1-i-r*(l/h),a*(h/l),r*(l/h)];case 15:return[i,1-s,r*(l/h),a*(h/l)];default:return[s,i,r,a]}},T(q,"_currentDrawId",-1),T(q,"_currentParent",null),g(q,Wt,null),g(q,wo,null),g(q,vo,null),g(q,hh,null),T(q,"_INNER_MARGIN",3);let wc=q;class O{constructor(){T(this,"focusOutline",null)}toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){st("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],r){switch(r){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}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 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]}}T(O,"PRECISION",1e-4);var hs,Rs,ch,dh,Zs,tt,So,Eo,$d,zd,uh,fh,Pi,Vd,zf,Vf,te,ic,pA,gA,mA,bA,yA,AA;const Xi=class Xi{constructor(t,e,s,i,r,a,o=0){g(this,te);g(this,hs);g(this,Rs,[]);g(this,ch);g(this,dh);g(this,Zs,[]);g(this,tt,new Float32Array(18));g(this,So);g(this,Eo);g(this,$d);g(this,zd);g(this,uh);g(this,fh);g(this,Pi,[]);u(this,hs,s),u(this,fh,r*i),u(this,dh,a),n(this,tt).set([NaN,NaN,NaN,NaN,t,e],6),u(this,ch,o),u(this,zd,n(Xi,Vd)*i),u(this,$d,n(Xi,Vf)*i),u(this,uh,i),n(this,Pi).push(t,e)}isEmpty(){return isNaN(n(this,tt)[8])}isCancellable(){return n(this,Pi).length<=10}removeLastElement(){return n(this,tt).fill(NaN),n(this,Zs).length=n(this,Rs).length=n(this,Pi).length=0,{path:{d:""}}}add(t,e){var P;u(this,So,t),u(this,Eo,e);const[s,i,r,a]=n(this,hs);let[o,l,h,c]=n(this,tt).subarray(8,12);const d=t-h,f=e-c,m=Math.hypot(d,f);if(m<n(this,$d))return!1;const y=m-n(this,zd),A=y/m,w=A*d,v=A*f;let S=o,E=l;o=h,l=c,h+=w,c+=v,(P=n(this,Pi))==null||P.push(t,e);const x=-v/y,C=w/y,_=x*n(this,fh),k=C*n(this,fh);return n(this,tt).set(n(this,tt).subarray(2,8),0),n(this,tt).set([h+_,c+k],4),n(this,tt).set(n(this,tt).subarray(14,18),12),n(this,tt).set([h-_,c-k],16),isNaN(n(this,tt)[6])?(n(this,Zs).length===0&&(n(this,tt).set([o+_,l+k],2),n(this,Zs).push(NaN,NaN,NaN,NaN,(o+_-s)/r,(l+k-i)/a),n(this,tt).set([o-_,l-k],14),n(this,Rs).push(NaN,NaN,NaN,NaN,(o-_-s)/r,(l-k-i)/a)),n(this,tt).set([S,E,o,l,h,c],6),!this.isEmpty()):(n(this,tt).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(v,w))<Math.PI/2?([o,l,h,c]=n(this,tt).subarray(2,6),n(this,Zs).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,E]=n(this,tt).subarray(14,18),n(this,Rs).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-i)/a),!0):([S,E,o,l,h,c]=n(this,tt).subarray(0,6),n(this,Zs).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,tt).subarray(12,18),n(this,Rs).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,Zs),e=n(this,Rs);if(isNaN(n(this,tt)[6])&&!this.isEmpty())return b(this,te,pA).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,mA).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,gA).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new wA(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,Zs),e=n(this,Rs),s=n(this,tt),[i,r,a,o]=n(this,hs),l=new Float32Array((((d=n(this,Pi))==null?void 0:d.length)??0)+2);for(let f=0,m=l.length-2;f<m;f+=2)l[f]=(n(this,Pi)[f]-i)/a,l[f+1]=(n(this,Pi)[f+1]-r)/o;if(l[l.length-2]=(n(this,So)-i)/a,l[l.length-1]=(n(this,Eo)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,te,bA).call(this,l);const h=new Float32Array(n(this,Zs).length+24+n(this,Rs).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,AA).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,yA).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,hs),n(this,uh),n(this,ch),n(this,dh))}};hs=new WeakMap,Rs=new WeakMap,ch=new WeakMap,dh=new WeakMap,Zs=new WeakMap,tt=new WeakMap,So=new WeakMap,Eo=new WeakMap,$d=new WeakMap,zd=new WeakMap,uh=new WeakMap,fh=new WeakMap,Pi=new WeakMap,Vd=new WeakMap,zf=new WeakMap,Vf=new WeakMap,te=new WeakSet,ic=function(){const t=n(this,tt).subarray(4,6),e=n(this,tt).subarray(16,18),[s,i,r,a]=n(this,hs);return[(n(this,So)+(t[0]-e[0])/2-s)/r,(n(this,Eo)+(t[1]-e[1])/2-i)/a,(n(this,So)+(e[0]-t[0])/2-s)/r,(n(this,Eo)+(e[1]-t[1])/2-i)/a]},pA=function(){const[t,e,s,i]=n(this,hs),[r,a,o,l]=b(this,te,ic).call(this);return`M${(n(this,tt)[2]-t)/s} ${(n(this,tt)[3]-e)/i} L${(n(this,tt)[4]-t)/s} ${(n(this,tt)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,tt)[16]-t)/s} ${(n(this,tt)[17]-e)/i} L${(n(this,tt)[14]-t)/s} ${(n(this,tt)[15]-e)/i} Z`},gA=function(t){const e=n(this,Rs);t.push(`L${e[4]} ${e[5]} Z`)},mA=function(t){const[e,s,i,r]=n(this,hs),a=n(this,tt).subarray(4,6),o=n(this,tt).subarray(16,18),[l,h,c,d]=b(this,te,ic).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${d} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},bA=function(t){const e=n(this,tt),[s,i,r,a]=n(this,hs),[o,l,h,c]=b(this,te,ic).call(this),d=new Float32Array(36);return d.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(d,t,n(this,hs),n(this,uh),n(this,ch),n(this,dh))},yA=function(t,e){const s=n(this,Rs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},AA=function(t,e){const s=n(this,tt).subarray(4,6),i=n(this,tt).subarray(16,18),[r,a,o,l]=n(this,hs),[h,c,d,f]=b(this,te,ic).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,d,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},g(Xi,Vd,8),g(Xi,zf,2),g(Xi,Vf,n(Xi,Vd)+n(Xi,zf));let bf=Xi;var ph,Mi,xn,jd,ti,Wd,Lt,jf,vA;class wA extends O{constructor(e,s,i,r,a,o){super();g(this,jf);g(this,ph);g(this,Mi,new Float32Array(4));g(this,xn);g(this,jd);g(this,ti);g(this,Wd);g(this,Lt);u(this,Lt,e),u(this,ti,s),u(this,ph,i),u(this,Wd,r),u(this,xn,a),u(this,jd,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,jf,vA).call(this,o);const[l,h,c,d]=n(this,Mi);for(let f=0,m=e.length;f<m;f+=2)e[f]=(e[f]-l)/c,e[f+1]=(e[f+1]-h)/d;for(let f=0,m=s.length;f<m;f+=2)s[f]=(s[f]-l)/c,s[f+1]=(s[f+1]-h)/d}toSVGPath(){const e=[`M${n(this,Lt)[4]} ${n(this,Lt)[5]}`];for(let s=6,i=n(this,Lt).length;s<i;s+=6){if(isNaN(n(this,Lt)[s])){e.push(`L${n(this,Lt)[s+4]} ${n(this,Lt)[s+5]}`);continue}e.push(`C${n(this,Lt)[s]} ${n(this,Lt)[s+1]} ${n(this,Lt)[s+2]} ${n(this,Lt)[s+3]} ${n(this,Lt)[s+4]} ${n(this,Lt)[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=O._rescale(n(this,Lt),e,r,o,-l),c=O._rescale(n(this,ti),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(n(this,Lt),e,s,o,l),c=O._rescaleAndSwap(n(this,ti),e,s,o,l);break;case 180:h=O._rescale(n(this,Lt),i,s,-o,l),c=O._rescale(n(this,ti),i,s,-o,l);break;case 270:h=O._rescaleAndSwap(n(this,Lt),i,r,-o,-l),c=O._rescaleAndSwap(n(this,ti),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Mi)}newOutliner(e,s,i,r,a,o,l=0){return new bf(e,s,i,r,a,o,l)}updateThickness(e){const s=this.getNewOutline(e);return u(this,Lt,n(s,Lt)),u(this,ti,n(s,ti)),n(this,Mi).set(n(s,Mi)),this.firstPoint=s.firstPoint,this.lastPoint=s.lastPoint,n(this,Mi)}getNewOutline(e,s){const[i,r,a,o]=n(this,Mi),[l,h,c,d]=n(this,ph),f=a*c,m=o*d,y=i*c+l,A=r*d+h,w=n(this,ti),v=this.newOutliner(w[0]*f+y,w[1]*m+A,n(this,ph),n(this,Wd),e,n(this,jd),s??n(this,xn));for(let S=2,E=w.length;S<E;S+=2)v.add(w[S]*f+y,w[S+1]*m+A);return v.getOutlines()}}ph=new WeakMap,Mi=new WeakMap,xn=new WeakMap,jd=new WeakMap,ti=new WeakMap,Wd=new WeakMap,Lt=new WeakMap,jf=new WeakSet,vA=function(e){const s=n(this,Lt);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,c=r;const d=e?Math.max:Math.min,f=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const w=s[y+4],v=s[y+5];isNaN(s[y])?(I.pointBoundingBox(w,v,a),l>v?(o=w,l=v):l===v&&(o=d(o,w)),c<v?(h=w,c=v):c===v&&(h=d(h,w))):(f.set(Ui,0),I.bezierBoundingBox(i,r,...s.slice(y,y+6),f),I.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),c<f[3]?(h=f[2],c=f[3]):c===f[3]&&(h=d(h,f[2]))),i=w,r=v}const m=n(this,Mi);m[0]=a[0]-n(this,xn),m[1]=a[1]-n(this,xn),m[2]=a[2]-a[0]+2*n(this,xn),m[3]=a[3]-a[1]+2*n(this,xn),this.firstPoint=[o,l],this.lastPoint=[h,c]};function SA(p){return{bbox:p.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:p.isFree},path:{d:p.toSVGPath()}}}function EA(p,t){const{focusOutline:e}=p;return{bbox:O._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:p.isFree},path:{d:e.toSVGPath()}}}var Xd,Yd,Kd,Mr,ei,Ne,xA,Ju,CA,_A,Yg;class Xg{constructor(t,e=0,s=0,i=!0){g(this,Ne);g(this,Xd);g(this,Yd);g(this,Kd);g(this,Mr,[]);g(this,ei,[]);const r=Ui.slice(),a=10**-4;for(const{x:A,y:w,width:v,height:S}of t){const E=Math.floor((A-e)/a)*a,x=Math.ceil((A+v+e)/a)*a,C=Math.floor((w-e)/a)*a,_=Math.ceil((w+S+e)/a)*a,k=[E,C,_,!0],M=[x,C,_,!1];n(this,Mr).push(k,M),I.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 d=i?-1/0:1/0,f=1/0;const m=n(this,Mr).at(i?-1:-2),y=[m[0],m[2]];for(const A of n(this,Mr)){const[w,v,S,E]=A;!E&&i?v<f?(f=v,d=w):v===f&&(d=Math.max(d,w)):E&&!i&&(v<f?(f=v,d=w):v===f&&(d=Math.min(d,w))),A[0]=(w-h)/o,A[1]=(v-c)/l,A[2]=(S-c)/l}u(this,Xd,new Float32Array([h,c,o,l])),u(this,Yd,[d,f]),u(this,Kd,y)}getOutlines(){n(this,Mr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,Mr))e[3]?(t.push(...b(this,Ne,Yg).call(this,e)),b(this,Ne,CA).call(this,e)):(b(this,Ne,_A).call(this,e),t.push(...b(this,Ne,Yg).call(this,e)));return b(this,Ne,xA).call(this,t)}}Xd=new WeakMap,Yd=new WeakMap,Kd=new WeakMap,Mr=new WeakMap,ei=new WeakMap,Ne=new WeakSet,xA=function(t){const e=[],s=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const i=[];for(;s.size>0;){const r=s.values().next().value;let[a,o,l,h,c]=r;s.delete(r);let d=a,f=o;const m=[a,l];for(i.push(m);;){let y;if(s.has(h))y=h;else if(s.has(c))y=c;else break;s.delete(y),[a,o,l,h,c]=y,d!==a&&(m.push(d,f,a,f===o?o:l),d=a),f=f===o?l:o}m.push(d,f)}return new Kg(i,n(this,Xd),n(this,Yd),n(this,Kd))},Ju=function(t){const e=n(this,ei);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},CA=function([,t,e]){const s=b(this,Ne,Ju).call(this,t);n(this,ei).splice(s,0,[t,e])},_A=function([,t,e]){const s=b(this,Ne,Ju).call(this,t);for(let i=s;i<n(this,ei).length;i++){const[r,a]=n(this,ei)[i];if(r!==t)break;if(r===t&&a===e){n(this,ei).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,ei)[i];if(r!==t)break;if(r===t&&a===e){n(this,ei).splice(i,1);return}}},Yg=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Ne,Ju).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,ei)[o];for(let c=0,d=r.length;c<d;c++){const[,f,m]=r[c];if(!(h<=f||m<=l)){if(f>=l){if(m>h)r[c][1]=h;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var qd,Qd,gh;class Kg extends O{constructor(e,s,i,r){super();g(this,qd);g(this,Qd,null);g(this,gh);u(this,gh,e),u(this,qd,s),this.firstPoint=i,this.lastPoint=r}static build(e,s){const i=new Xg(e,.001).getOutlines();return u(i,Qd,e),i.focusOutline=new Xg(e,.0025,.001,s).getOutlines(),i}get isFree(){return!1}get defaultSVGProperties(){return SA(this)}getFocusSVGProperties(e){return EA(this,e)}updateRotation(e){return{root:{"data-main-rotation":e}}}serializeQuadPoints([e,s],[i,r]){const a=n(this,Qd),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:f}of a){const m=h*i+e,y=(1-c)*r+s;o[l]=o[l+4]=m,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=m+d*i,o[l+5]=o[l+7]=y-f*r,l+=8}return o}toSVGPath(){const e=[];for(const s of n(this,gh)){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,gh)){const d=new Array(c.length);for(let f=0;f<c.length;f+=2)d[f]=e+c[f]*l,d[f+1]=r-c[f+1]*h;o.push(d)}return o}get box(){return n(this,qd)}}qd=new WeakMap,Qd=new WeakMap,gh=new WeakMap;class _m extends bf{newFreeDrawOutline(t,e,s,i,r,a){return new qg(t,e,s,i,r,a)}}var cs,Jd;class Ww{constructor(t,e,s,i,r,a,o){g(this,cs);g(this,Jd);u(this,cs,new _m(t,e,s,i,r,a,o)),u(this,Jd,r)}add(t,e){return n(this,cs).add(t,e)?{path:{d:n(this,cs).toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=n(this,cs).add(t[s],t[s+1])||e;return e?{path:{d:n(this,cs).toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return n(this,cs).isEmpty()}isCancellable(){return n(this,cs).isCancellable()}removeLastElement(){return n(this,cs).removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=n(this,cs).getOutlines();return t.buildFocusOutline(2*n(this,Jd)),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:n(this,cs).toSVGPath()}}}}cs=new WeakMap,Jd=new WeakMap;var Wf;const Xf=class Xf extends wA{newOutliner(t,e,s,i,r,a,o=0){return new _m(t,e,s,i,r,a,o)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+n(Xf,Wf),.0025)}get defaultSVGProperties(){return SA(this)}getFocusSVGProperties(t){return EA(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}};Wf=new WeakMap,g(Xf,Wf,1.5);let qg=Xf;class Tm extends Cm{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new Tm;return t.updateAll(this),t}}var mh,Zd,tu,eu,su,bh,ys,Qg,TA,Zu,kA;const Pe=class Pe extends wc{constructor(e){var s;super({...e,name:"highlightEditor"});g(this,ys);g(this,mh,null);g(this,Zd,0);g(this,tu,null);g(this,eu,0);g(this,su,"");g(this,bh,"");u(this,mh,e.anchorNode||null),u(this,Zd,e.anchorOffset||0),u(this,tu,e.focusNode||null),u(this,eu,e.focusOffset||0),u(this,su,e.methodOfCreation||((s=this._drawOutlines)!=null&&s.isFree?"main_toolbar":"")),u(this,bh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static get _keyboardManager(){const e=Pe.prototype;return F(this,"_keyboardManager",new Ro([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}static initialize(e,s){var i;gt.initialize(e,s),this._defaultDrawingOptions||(this._defaultDrawingOptions=new Tm({fill:((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066","fill-opacity":Pe._DEFAULT_OPACITY,thickness:Pe._DEFAULT_THICKNESS}))}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get typesMap(){return F(this,"typesMap",new Map([[et.HIGHLIGHT_COLOR,"fill"],[et.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(e){const{boxes:s,drawOutlines:i}=e;!s&&!i||(this._drawingOptions||(this._drawingOptions=e.drawingOptions||Pe.getDefaultDrawingOptions()),s&&(e={...e,drawOutlines:Kg.build(s,this._uiManager.direction==="ltr")}),super._addOutlines(e))}get colorType(){return et.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){var e;return(e=this._drawOutlines)!=null&&e.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){var e;return!((e=this._drawOutlines)!=null&&e.isFree)}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:n(this,su)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}translateInPage(e,s){}get toolbarPosition(){return b(this,ys,Qg).call(this,this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return b(this,ys,Qg).call(this,this._drawOutlines.firstPoint)}updateParams(e,s){switch(e){case et.HIGHLIGHT_COLOR:this._updateColorAndOpacity(s,Pe._DEFAULT_OPACITY,e),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(s)},!0);break;case et.HIGHLIGHT_THICKNESS:super.updateParams(e,s),this._reportTelemetry({action:"thickness_changed",thickness:s},!0);break}}get propertiesToUpdate(){const e=super.propertiesToUpdate;return e.push([et.HIGHLIGHT_FREE,this._drawOutlines.isFree]),e}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new yc({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(e,s){return super.getRect(e,s,this._drawRotation)}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;const e=super.render();return n(this,bh)&&(e.setAttribute("aria-label",n(this,bh)),e.setAttribute("role","mark")),this._drawOutlines.isFree?e.classList.add("free"):e.addEventListener("keydown",b(this,ys,TA).bind(this),{signal:this._uiManager._signal}),this.enableEditing(),e}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,ys,Zu).call(this,!0);break;case 1:case 3:b(this,ys,Zu).call(this,!1);break}}unselect(){super.unselect(),this._drawOutlines.isFree||b(this,ys,Zu).call(this,!1)}static createDrawerInstance({x:e,y:s,box:i,parent:r,isLTR:a}){return new Ww(e,s,i,r.scale,this._defaultDrawingOptions.thickness/2,a,.001)}static _getDrawingTarget(e,{target:s}){return s.closest(".textLayer")}static _getPointerCoords({x:e,y:s}){return[e,s]}static _addDrawingListeners(e,s){e.classList.add("free"),s.addEventListener("abort",()=>e.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:s}),window.addEventListener("pointerdown",Kt,{capture:!0,passive:!1,signal:s})}static _endDrawingSession(e=!1){return this.endDrawing(e)}createDrawingOptions({color:e,opacity:s,thickness:i}){const{_defaultDrawingOptions:r,_DEFAULT_OPACITY:a}=Pe;this._drawingOptions=Pe.getDefaultDrawingOptions({fill:I.makeHexColor(...e),"fill-opacity":s||a,thickness:i||r.thickness})}static deserializeDraw(e,s,i,r,a,o,l){const{quadPoints:h}=o;if(h){const y=[];for(let A=0,w=h.length;A<w;A+=8)y.push({x:(h[A]-e)/i,y:1-(h[A+1]-s)/r,width:(h[A+2]-h[A])/i,height:(h[A+1]-h[A+5])/r});return Kg.build(y,l.direction==="ltr")}const c=o.thickness||this._defaultDrawingOptions.thickness,d=(o.inkLists||o.outlines.points)[0],f=new _m(d[0]-e,r-(d[1]-s),[0,0,i,r],1,c/2,!0,.001);for(let y=0,A=d.length;y<A;y+=2)f.add(d[y]-e,r-(d[y+1]-s));const m=f.getOutlines();return m.buildFocusOutline(c),m}static async deserialize(e,s,i){let r=null;if(e instanceof nA){const{data:{quadPoints:o,rect:l,rotation:h,id:c,color:d,opacity:f,popupRef:m,richText:y,contentsObj:A,creationDate:w,modificationDate:v},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),opacity:f,quadPoints:o,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:m,richText:y,comment:(A==null?void 0:A.str)||null,creationDate:w,modificationDate:v}}else if(e instanceof xm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,borderStyle:{rawWidth:f},popupRef:m,richText:y,contentsObj:A,creationDate:w,modificationDate:v},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),thickness:f,inkLists:o,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:m,richText:y,comment:(A==null?void 0:A.str)||null,creationDate:w,modificationDate:v}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=super.serialize(e);return Object.assign(s,{color:gt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(s.rect,this._drawRotation)}),this.addComment(s),this.annotationElementId&&!b(this,ys,kA).call(this,s)?null:(s.id=this.annotationElementId,s)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}};mh=new WeakMap,Zd=new WeakMap,tu=new WeakMap,eu=new WeakMap,su=new WeakMap,bh=new WeakMap,ys=new WeakSet,Qg=function([e,s]){const[i,r,a,o]=this._drawOutlines.box;return[(e-i)/a,(s-r)/o]},TA=function(e){Pe._keyboardManager.exec(this,e)},Zu=function(e){if(!n(this,mh))return;const s=window.getSelection();e?s.setPosition(n(this,mh),n(this,Zd)):s.setPosition(n(this,tu),n(this,eu))},kA=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},T(Pe,"_DEFAULT_OPACITY",1),T(Pe,"_DEFAULT_THICKNESS",12),T(Pe,"_defaultDrawingOptions",null),T(Pe,"_type","highlight"),T(Pe,"_editorType",W.HIGHLIGHT);let yf=Pe;var Di,Dr,Xt,fe,xo,yh,pe,Yt,Os,Co,_o,To,As,tf,ef,Jg;class Xw{constructor(t,e,s,i,r,a){g(this,As);g(this,Di,new Float64Array(6));g(this,Dr,new Float64Array(2));g(this,Xt);g(this,fe);g(this,xo);g(this,yh);g(this,pe);g(this,Yt,"");g(this,Os,0);g(this,Co,new pu);g(this,_o);g(this,To);u(this,_o,s),u(this,To,i),u(this,xo,r),u(this,yh,a),[t,e]=b(this,As,tf).call(this,t,e);const o=u(this,Xt,[NaN,NaN,NaN,NaN,t,e]);u(this,pe,[t,e]),u(this,fe,[{line:o,points:n(this,pe)}]),n(this,Di).set(o,0),n(this,Dr).set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&u(this,yh,e)}isEmpty(){var t;return!((t=n(this,fe))!=null&&t.length)}isCancellable(){return n(this,pe).length<=10}add(t,e){return b(this,As,ef).call(this,t,e)&&this.toSVGPath(),{path:{d:b(this,As,Jg).call(this)}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)b(this,As,ef).call(this,t[s],t[s+1])&&(e=!0,n(this,pe).length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:b(this,As,Jg).call(this)}}}end(t,e){return t!==void 0&&b(this,As,ef).call(this,t,e)?{path:{d:this.toSVGPath()}}:n(this,pe).length===2?{path:{d:this.toSVGPath()}}:{path:{d:n(this,Yt)}}}startNew(t,e,s,i,r){u(this,_o,s),u(this,To,i),u(this,xo,r),[t,e]=b(this,As,tf).call(this,t,e);const a=u(this,Xt,[NaN,NaN,NaN,NaN,t,e]);u(this,pe,[t,e]),n(this,Dr).set([t,e],0);const o=n(this,fe).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,fe).push({line:a,points:n(this,pe)}),n(this,Di).set(a,0),u(this,Os,0),this.toSVGPath(),null}getLastElement(){return n(this,fe).at(-1)}setLastElement(t){return n(this,fe)?(n(this,fe).push(t),u(this,Xt,t.line),u(this,pe,t.points),u(this,Os,0),{path:{d:this.toSVGPath()}}):n(this,Co).setLastElement(t)}removeLastElement(){if(!n(this,fe))return n(this,Co).removeLastElement();n(this,fe).pop(),u(this,Yt,"");for(let t=0,e=n(this,fe).length;t<e;t++){const{line:s,points:i}=n(this,fe)[t];u(this,Xt,s),u(this,pe,i),u(this,Os,0),this.toSVGPath()}return{path:{d:n(this,Yt)}}}toSVGPath(){const t=O.svgRound(n(this,Xt)[4]),e=O.svgRound(n(this,Xt)[5]);if(n(this,pe).length===2)return u(this,Yt,`${n(this,Yt)} M ${t} ${e} Z`),n(this,Yt);if(n(this,pe).length<=6){const i=n(this,Yt).lastIndexOf("M");u(this,Yt,`${n(this,Yt).slice(0,i)} M ${t} ${e}`),u(this,Os,6)}if(n(this,pe).length===4){const i=O.svgRound(n(this,Xt)[10]),r=O.svgRound(n(this,Xt)[11]);return u(this,Yt,`${n(this,Yt)} L ${i} ${r}`),u(this,Os,12),n(this,Yt)}const s=[];n(this,Os)===0&&(s.push(`M ${t} ${e}`),u(this,Os,6));for(let i=n(this,Os),r=n(this,Xt).length;i<r;i+=6){const[a,o,l,h,c,d]=n(this,Xt).slice(i,i+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return u(this,Yt,n(this,Yt)+s.join(" ")),u(this,Os,n(this,Xt).length),n(this,Yt)}getOutlines(t,e,s,i){const r=n(this,fe).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,Co).build(n(this,fe),t,e,s,n(this,xo),n(this,yh),i),u(this,Di,null),u(this,Xt,null),u(this,fe,null),u(this,Yt,null),n(this,Co)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Di=new WeakMap,Dr=new WeakMap,Xt=new WeakMap,fe=new WeakMap,xo=new WeakMap,yh=new WeakMap,pe=new WeakMap,Yt=new WeakMap,Os=new WeakMap,Co=new WeakMap,_o=new WeakMap,To=new WeakMap,As=new WeakSet,tf=function(t,e){return O._normalizePoint(t,e,n(this,_o),n(this,To),n(this,xo))},ef=function(t,e){[t,e]=b(this,As,tf).call(this,t,e),n(this,Dr).set([t,e],0);const[s,i,r,a]=n(this,Di).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,_o)*o,n(this,To)*l)<=2?!1:(n(this,pe).push(t,e),isNaN(s)?(n(this,Di).set([r,a,t,e],2),n(this,Xt).push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(n(this,Di)[0])&&n(this,Xt).splice(6,6),n(this,Di).set([s,i,r,a,t,e],0),n(this,Xt).push(...O.createBezierPoints(s,i,r,a,t,e)),!0))},Jg=function(){const t=O.svgRound(n(this,Dr)[0]),e=O.svgRound(n(this,Dr)[1]);if(n(this,pe).length===2){const s=O.svgRound(n(this,Xt)[4]),i=O.svgRound(n(this,Xt)[5]);return`${n(this,Yt)} M ${s} ${i} L ${t} ${e}`}return`${n(this,Yt)} L ${t} ${e}`};var De,iu,nu,ds,Ii,Li,Ah,wh,ko,me,ji,PA,MA,DA;class pu extends O{constructor(){super(...arguments);g(this,me);g(this,De);g(this,iu,0);g(this,nu);g(this,ds);g(this,Ii);g(this,Li);g(this,Ah);g(this,wh);g(this,ko)}build(e,s,i,r,a,o,l){u(this,Ii,s),u(this,Li,i),u(this,Ah,r),u(this,wh,a),u(this,ko,o),u(this,nu,l??0),u(this,ds,e),b(this,me,MA).call(this)}get thickness(){return n(this,ko)}setLastElement(e){return n(this,ds).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,ds).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,ds)){if(e.push(`M${O.svgRound(s[4])} ${O.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${O.svgRound(s[10])} ${O.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,d]=s.subarray(i,i+6).map(O.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,d,f]=b(this,me,PA).call(this);let m,y,A,w,v,S,E,x,C;switch(n(this,wh)){case 0:C=O._rescale,m=e,y=s+r,A=i,w=-r,v=e+h*i,S=s+(1-c-f)*r,E=e+(h+d)*i,x=s+(1-c)*r;break;case 90:C=O._rescaleAndSwap,m=e,y=s,A=i,w=r,v=e+c*i,S=s+h*r,E=e+(c+f)*i,x=s+(h+d)*r;break;case 180:C=O._rescale,m=e+i,y=s,A=-i,w=r,v=e+(1-h-d)*i,S=s+c*r,E=e+(1-h)*i,x=s+(c+f)*r;break;case 270:C=O._rescaleAndSwap,m=e+i,y=s+r,A=-i,w=-r,v=e+(1-c-f)*i,S=s+(1-h-d)*r,E=e+(1-c)*i,x=s+(1-h)*r;break}for(const{line:_,points:k}of n(this,ds))o.push(C(_,m,y,A,w,a?new Array(_.length):null)),l.push(C(k,m,y,A,w,a?new Array(k.length):null));return{lines:o,points:l,rect:[v,S,E,x]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let f,m,y,A,w;switch(h){case 0:w=O._rescale,f=-e/i,m=s/r+1,y=1/i,A=-1/r;break;case 90:w=O._rescaleAndSwap,f=-s/r,m=-e/i,y=1/r,A=1/i;break;case 180:w=O._rescale,f=e/i+1,m=-s/r,y=-1/i,A=1/r;break;case 270:w=O._rescaleAndSwap,f=s/r+1,m=e/i+1,y=-1/r,A=-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 x=new Float32Array(3*(E-2));o.push(x);let[C,_,k,M]=S.subarray(0,4);x.set([NaN,NaN,NaN,NaN,C,_],0);for(let P=4;P<E;P+=2){const D=S[P],N=S[P+1];x.set(O.createBezierPoints(C,_,k,M,D,N),(P-2)*3),[C,_,k,M]=[k,M,D,N]}}}for(let S=0,E=o.length;S<E;S++)d.push({line:w(o[S].map(x=>x??NaN),f,m,y,A),points:w(l[S].map(x=>x??NaN),f,m,y,A)});const v=new this.prototype.constructor;return v.build(d,i,r,1,h,c,a),v}get box(){return n(this,De)}updateProperty(e,s){return e==="stroke-width"?b(this,me,DA).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,me,ji).call(this);u(this,Ii,e),u(this,Li,s),u(this,Ah,i);const[o,l]=b(this,me,ji).call(this),h=o-r,c=l-a,d=n(this,De);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return u(this,iu,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,De).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,De);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,De);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,iu)){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} ${O.svgRound(l)} ${O.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,me,ji).call(this),[l,h,c,d]=n(this,De);if(Math.abs(c-a)<=O.PRECISION||Math.abs(d-o)<=O.PRECISION){const w=e+i/2-(l+c/2),v=s+r/2-(h+d/2);return{path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:`${this.rotationTransform} translate(${w} ${v})`}}}const f=(i-2*a)/(c-2*a),m=(r-2*o)/(d-2*o),y=c/i,A=d/r;return{path:{"transform-origin":`${O.svgRound(l)} ${O.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${O.svgRound(a)} ${O.svgRound(o)}) scale(${f} ${m}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,me,ji).call(this),l=n(this,De),[h,c,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=O.PRECISION||Math.abs(f-o)<=O.PRECISION){const v=e+i/2-(h+d/2),S=s+r/2-(c+f/2);for(const{line:E,points:x}of n(this,ds))O._translate(E,v,S,E),O._translate(x,v,S,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(d-2*a),y=(r-2*o)/(f-2*o),A=-m*(h+a)+e+a,w=-y*(c+o)+s+o;if(m!==1||y!==1||A!==0||w!==0)for(const{line:v,points:S}of n(this,ds))O._rescale(v,A,w,m,y,v),O._rescale(S,A,w,m,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,De),l=e-o[0],h=s-o[1];if(n(this,Ii)===r&&n(this,Li)===a)for(const{line:c,points:d}of n(this,ds))O._translate(c,l,h,c),O._translate(d,l,h,d);else{const c=n(this,Ii)/r,d=n(this,Li)/a;u(this,Ii,r),u(this,Li,a);for(const{line:f,points:m}of n(this,ds))O._rescale(f,l,h,c,d,f),O._rescale(m,l,h,c,d,m);o[2]*=c,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,De);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e[0])} ${O.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}De=new WeakMap,iu=new WeakMap,nu=new WeakMap,ds=new WeakMap,Ii=new WeakMap,Li=new WeakMap,Ah=new WeakMap,wh=new WeakMap,ko=new WeakMap,me=new WeakSet,ji=function(e=n(this,ko)){const s=n(this,nu)+e/2*n(this,Ah);return n(this,wh)%180===0?[s/n(this,Ii),s/n(this,Li)]:[s/n(this,Li),s/n(this,Ii)]},PA=function(){const[e,s,i,r]=n(this,De),[a,o]=b(this,me,ji).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},MA=function(){const e=u(this,De,na.slice());for(const{line:r}of n(this,ds)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)I.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,d,f,m,y,A]=r.subarray(l,l+6);I.bezierBoundingBox(a,o,c,d,f,m,y,A,e),a=y,o=A}}const[s,i]=b(this,me,ji).call(this);e[0]=wt(e[0]-s,0,1),e[1]=wt(e[1]-i,0,1),e[2]=wt(e[2]+s,0,1),e[3]=wt(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},DA=function(e){const[s,i]=b(this,me,ji).call(this);u(this,ko,e);const[r,a]=b(this,me,ji).call(this),[o,l]=[r-s,a-i],h=n(this,De);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class fp extends Cm{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:gt._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 fp(this._viewParameters);return t.updateAll(this),t}}var Yf,IA;const qo=class qo extends wc{constructor(e){super({...e,name:"inkEditor"});g(this,Yf);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){gt.initialize(e,s),this._defaultDrawingOptions=new fp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return F(this,"typesMap",new Map([[et.INK_THICKNESS,"stroke-width"],[et.INK_COLOR,"stroke"],[et.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:e,y:s,box:[,,i,r],rotation:a}){return new Xw(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return pu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof xm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,opacity:f,borderStyle:{rawWidth:m},popupRef:y,richText:A,contentsObj:w,creationDate:v,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:W.INK,color:Array.from(d),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:y,richText:A,comment:(w==null?void 0:w.str)||null,creationDate:v,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 gf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return et.INK_COLOR}get colorAndOpacityType(){return et.INK_COLOR_AND_OPACITY}get opacityType(){return et.INK_OPACITY}updateParams(e,s){if(e===et.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===et.INK_COLOR_AND_OPACITY){super.updateDefaultParams(et.INK_COLOR,s.color),super.updateDefaultParams(et.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}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=qo.getDefaultDrawingOptions({stroke:I.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:gt._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,Yf,IA).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}};Yf=new WeakSet,IA=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},T(qo,"_type","ink"),T(qo,"_editorType",W.INK),T(qo,"_defaultDrawingOptions",null);let Zg=qo;class tm extends pu{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const vu=8,Bh=3;var Po,lt,em,si,LA,FA,sm,sf,RA,OA,NA,im,nm,BA;class Hi{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 d=200,f=c.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:w,fontBoundingBoxAscent:v,fontBoundingBoxDescent:S,width:E}=c.measureText(t),x=1.5,C=Math.ceil(Math.max(Math.abs(m)+Math.abs(y)||0,E)*x),_=Math.ceil(Math.max(Math.abs(A)+Math.abs(w)||d,Math.abs(v)+Math.abs(S)||d)*x);h=new OffscreenCanvas(C,_),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=f,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,_),c.fillStyle="black",c.fillText(t,C*(x-1)/2,_*(3-x)/2);const k=b(this,lt,im).call(this,c.getImageData(0,0,C,_).data),M=b(this,lt,NA).call(this,k),P=b(this,lt,nm).call(this,M),D=b(this,lt,sm).call(this,k,C,_,P);return this.processDrawnLines({lines:{curves:D,width:C,height:_},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,lt,BA).call(this,t),[h,c]=b(this,lt,OA).call(this,a,o,l,Math.hypot(o,l)*n(this,Po).sigmaSFactor,n(this,Po).sigmaR,n(this,Po).kernelSize),d=b(this,lt,nm).call(this,c),f=b(this,lt,sm).call(this,h,o,l,d);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,d=t.thickness??0,f=[],m=Math.min(e/h,s/c),y=m/e,A=m/s,w=[];for(const{points:S}of l){const E=a?b(this,lt,RA).call(this,S):S;if(!E)continue;w.push(E);const x=E.length,C=new Float32Array(x),_=new Float32Array(3*(x===2?2:x-2));if(f.push({line:_,points:C}),x===2){C[0]=E[0]*y,C[1]=E[1]*A,_.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[k,M,P,D]=E;k*=y,M*=A,P*=y,D*=A,C.set([k,M,P,D],0),_.set([NaN,NaN,NaN,NaN,k,M],0);for(let N=4;N<x;N+=2){const Z=C[N]=E[N]*y,Q=C[N+1]=E[N+1]*A;_.set(O.createBezierPoints(k,M,P,D,Z,Q),(N-2)*3),[k,M,P,D]=[P,D,Z,Q]}}if(f.length===0)return null;const v=o?new tm:new pu;return v.build(f,e,s,1,i,o?0:d,r),{outline:v,newCurves:w,areContours:o,thickness:d,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 S of t){l+=S.length;for(let E=2,x=S.length;E<x;E++){const C=S[E]-S[E-2];a=Math.min(a,C),o=Math.max(o,C)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=vu+Bh*c,f=new Uint32Array(d);let m=0;f[m++]=d*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 S of t)f[m++]=S.length-2,f[m++]=S[0],f[m++]=S[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(f);const w=h.prototype.constructor;for(const S of t){const E=new w(S.length-2);for(let x=2,C=S.length;x<C;x++)E[x-2]=S[x]-S[x-2];A.write(E)}return A.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(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],d=l[3],f=l[4]===0,m=l[5],y=l[6],A=l[7],w=[],v=(vu+Bh*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,v);break}o=0;for(let E=0;E<y;E++){const x=l[Bh*E+vu],C=new Float32Array(x+2);w.push(C);for(let _=0;_<Bh-1;_++)C[_]=l[Bh*E+vu+_+1];for(let _=0;_<x;_++)C[_+2]=C[_]+S[o++]}return{areContours:f,thickness:m,outlines:w,width:c,height:d}}catch(e){return X(`decompressSignature: ${e}`),null}}}Po=new WeakMap,lt=new WeakSet,em=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},si=new WeakMap,LA=function(t,e,s,i,r,a,o){const l=b(this,lt,em).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=n(this,si)[2*c],f=n(this,si)[2*c+1];if(t[(s+d)*e+(i+f)]!==0)return c}return-1},FA=function(t,e,s,i,r,a,o){const l=b(this,lt,em).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=n(this,si)[2*c],f=n(this,si)[2*c+1];if(t[(s+d)*e+(i+f)]!==0)return c}return-1},sm=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 d=1;d<e-1;d++){const f=c*e+d,m=a[f];if(m===0)continue;let y=c,A=d;if(m===1&&a[f-1]===0)o+=1,A-=1;else if(m>=1&&a[f+1]===0)o+=1,A+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const w=[d,c],v=A===d+1,S={isHole:v,points:w,id:o,parent:0};h.push(S);let E;for(const N of h)if(N.id===l){E=N;break}E?E.isHole?S.parent=v?E.parent:l:S.parent=v?l:E.parent:S.parent=v?l:0;const x=b(this,lt,LA).call(this,a,e,c,d,y,A,0);if(x===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let C=n(this,si)[2*x],_=n(this,si)[2*x+1];const k=c+C,M=d+_;y=k,A=M;let P=c,D=d;for(;;){const N=b(this,lt,FA).call(this,a,e,P,D,y,A,1);C=n(this,si)[2*N],_=n(this,si)[2*N+1];const Z=P+C,Q=D+_;w.push(Q,Z);const Y=P*e+D;if(a[Y+1]===0?a[Y]=-o:a[Y]===1&&(a[Y]=o),Z===c&&Q===d&&P===k&&D===M){a[f]!==1&&(l=Math.abs(a[f]));break}else y=P,A=D,P=Z,D=Q}}}return h},sf=function(t,e,s,i){if(s-e<=4){for(let k=e;k<s-2;k+=2)i.push(t[k],t[k+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,d=l/h,f=c*a-d*r,m=l/o,y=1/h,A=Math.atan(m),w=Math.cos(A),v=Math.sin(A),S=y*(Math.abs(w)+Math.abs(v)),E=y*(1-S+S**2),x=Math.max(Math.atan(Math.abs(v+w)*E),Math.atan(Math.abs(v-w)*E));let C=0,_=e;for(let k=e+2;k<s-2;k+=2){const M=Math.abs(f-c*t[k+1]+d*t[k]);M>C&&(_=k,C=M)}C>(h*x)**2?(b(this,lt,sf).call(this,t,e,_+2,i),b(this,lt,sf).call(this,t,_,s,i)):i.push(r,a)},RA=function(t){const e=[],s=t.length;return b(this,lt,sf).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},OA=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let A=0;A<a;A++){const w=(A-h)**2;for(let v=0;v<a;v++)o[A*a+v]=Math.exp((w+(v-h)**2)/l)}const c=new Float32Array(256),d=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/d);const f=t.length,m=new Uint8Array(f),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let w=0;w<e;w++){const v=A*e+w,S=t[v];let E=0,x=0;for(let _=0;_<a;_++){const k=A+_-h;if(!(k<0||k>=s))for(let M=0;M<a;M++){const P=w+M-h;if(P<0||P>=e)continue;const D=t[k*e+P],N=o[_*a+M]*c[Math.abs(D-S)];E+=D*N,x+=N}}const C=m[v]=Math.round(E/x);y[C]++}return[m,y]},NA=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},im=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},nm=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},BA=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,Po);let a=s,o=i;if(s>r||i>r){let f=s,m=i,y=Math.log2(Math.max(s,i)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let v=0;v<y;v++){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 w=Math.min(r/a,r/o);a=Math.round(a*w),o=Math.round(o*w)}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,lt,im).call(this,c),a,o]},g(Hi,lt),g(Hi,Po,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),g(Hi,si,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class km extends Cm{constructor(){super(),super.updateProperties({fill:gt._defaultLineColor,"stroke-width":0})}clone(){const t=new km;return t.updateAll(this),t}}class Pm extends fp{constructor(t){super(t),super.updateProperties({stroke:gt._defaultLineColor,"stroke-width":1})}clone(){const t=new Pm(this._viewParameters);return t.updateAll(this),t}}var Ir,Fi,Lr,Mo;const Qe=class Qe extends wc{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});g(this,Ir,!1);g(this,Fi,null);g(this,Lr,null);g(this,Mo,null);this._willKeepAspectRatio=!0,u(this,Lr,e.signatureData||null),u(this,Fi,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){gt.initialize(e,s),this._defaultDrawingOptions=new km,this._defaultDrawnSignatureOptions=new Pm(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return F(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Fi)}}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,Lr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,Lr),{rawDims:{pageWidth:d,pageHeight:f},rotation:m}=this.parent.viewport,y=Hi.processDrawnLines({lines:r,pageWidth:d,pageHeight:f,rotation:m,innerMargin:Qe._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,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,Fi)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){u(this,Mo,e),this.addEditToolbar()}getUuid(){return n(this,Mo)}get description(){return n(this,Fi)}set description(e){u(this,Fi,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,Lr),o=Math.max(r,a),l=Hi.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}=u(this,Lr,e);u(this,Ir,l instanceof tm),this.description=i;let h;n(this,Ir)?h=Qe.getDefaultDrawingOptions():(h=Qe._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let d=s/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,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 Hi.process(e,s,i,r,Qe._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Hi.extractContoursFromText(e,s,i,r,a,Qe._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Hi.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Qe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Qe.getDefaultDrawingOptions():(this._drawingOptions=Qe._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,Ir),color:[0,0,0],thickness:n(this,Ir)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,Mo),a.isCopy=!0):a.lines=s,n(this,Fi)&&(a.accessibilityData={type:"Figure",alt:n(this,Fi)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?tm.deserialize(e,s,i,r,a,o):pu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return u(r,Ir,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",u(r,Mo,e.uuid),r}};Ir=new WeakMap,Fi=new WeakMap,Lr=new WeakMap,Mo=new WeakMap,T(Qe,"_type","signature"),T(Qe,"_editorType",W.SIGNATURE),T(Qe,"_defaultDrawingOptions",null);let rm=Qe;var _t,le,Fr,Cn,Rr,vh,_n,Do,Ri,us,Sh,it,nc,rc,nf,rf,af,om,of,HA;class am extends gt{constructor(e){super({...e,name:"stampEditor"});g(this,it);g(this,_t,null);g(this,le,null);g(this,Fr,null);g(this,Cn,null);g(this,Rr,null);g(this,vh,"");g(this,_n,null);g(this,Do,!1);g(this,Ri,null);g(this,us,!1);g(this,Sh,!1);u(this,Cn,e.bitmapUrl),u(this,Rr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){gt.initialize(e,s)}static isHandlingMimeForPasting(e){return ff.has(e)}static paste(e,s){s.pasteEditor({mode:W.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)&&(u(this,_t,null),this._uiManager.imageManager.deleteId(n(this,le)),(e=n(this,_n))==null||e.remove(),u(this,_n,null),n(this,Ri)&&(clearTimeout(n(this,Ri)),u(this,Ri,null))),super.remove()}rebuild(){if(!this.parent){n(this,le)&&b(this,it,nf).call(this);return}super.rebuild(),this.div!==null&&(n(this,le)&&n(this,_n)===null&&b(this,it,nf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Fr)||n(this,_t)||n(this,Cn)||n(this,Rr)||n(this,le)||n(this,Do))}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,Do)||(n(this,_t)?b(this,it,rf).call(this):b(this,it,nf).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)&&(u(this,le,i),r&&u(this,_t,r),u(this,Do,!1),b(this,it,rf).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Ri)!==null&&clearTimeout(n(this,Ri)),u(this,Ri,setTimeout(()=>{u(this,Ri,null),b(this,it,om).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,_t),o=new bs;let l=n(this,_t),h=r,c=a,d=null;if(s){if(r>s||a>s){const k=Math.min(s/r,s/a);h=Math.floor(r*k),c=Math.floor(a*k)}d=document.createElement("canvas");const m=d.width=Math.ceil(h*o.sx),y=d.height=Math.ceil(c*o.sy);n(this,us)||(l=b(this,it,af).call(this,m,y));const A=d.getContext("2d");A.filter=this._uiManager.hcmFilter;let w="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":o0.isDarkMode&&(w="#8f8f9d",v="#42414d");const S=15,E=S*o.sx,x=S*o.sy,C=new OffscreenCanvas(E*2,x*2),_=C.getContext("2d");_.fillStyle=w,_.fillRect(0,0,E*2,x*2),_.fillStyle=v,_.fillRect(0,0,E,x),_.fillRect(E,x,E,x),A.fillStyle=A.createPattern(C,"repeat"),A.fillRect(0,0,m,y),A.drawImage(l,0,0,l.width,l.height,0,0,m,y)}let f=null;if(i){let m,y;if(o.symmetric&&l.width<e&&l.height<e)m=l.width,y=l.height;else if(l=n(this,_t),r>e||a>e){const v=Math.min(e/r,e/a);m=Math.floor(r*v),y=Math.floor(a*v),n(this,us)||(l=b(this,it,af).call(this,m,y))}const w=new OffscreenCanvas(m,y).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,m,y),f={width:m,height:y,data:w.getImageData(0,0,m,y).data}}return{canvas:d,width:h,height:c,imageData:f}}static async deserialize(e,s,i){var w;let r=null,a=!1;if(e instanceof rA){const{data:{rect:v,rotation:S,id:E,structParent:x,popupRef:C,richText:_,contentsObj:k,creationDate:M,modificationDate:P},container:D,parent:{page:{pageNumber:N}},canvas:Z}=e;let Q,Y;Z?(delete e.canvas,{id:Q,bitmap:Y}=i.imageManager.getFromCanvas(D.id,Z),Z.remove()):(a=!0,e._hasNoCanvas=!0);const K=((w=await s._structTree.getAriaAttributes(`${Yo}${E}`))==null?void 0:w.get("aria-label"))||"";r=e={annotationType:W.STAMP,bitmapId:Q,bitmap:Y,pageIndex:N-1,rect:v.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:K},isSvg:!1,structParent:x,popupRef:C,richText:_,comment:(k==null?void 0:k.str)||null,creationDate:M,modificationDate:P}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:f,accessibilityData:m}=e;a?(i.addMissingCanvas(e.id,o),u(o,Do,!0)):d&&i.imageManager.isValidId(d)?(u(o,le,d),h&&u(o,_t,h)):u(o,Cn,c),u(o,us,f);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e),u(o,Sh,!!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,us)});if(this.addComment(i),e)return i.bitmapUrl=b(this,it,of).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,it,HA).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,us)?(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,it,of).call(this,!1);else if(n(this,us)){const l=s.stamps.get(n(this,le));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,it,of).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}_t=new WeakMap,le=new WeakMap,Fr=new WeakMap,Cn=new WeakMap,Rr=new WeakMap,vh=new WeakMap,_n=new WeakMap,Do=new WeakMap,Ri=new WeakMap,us=new WeakMap,Sh=new WeakMap,it=new WeakSet,nc=function(e,s=!1){if(!e){this.remove();return}u(this,_t,e.bitmap),s||(u(this,le,e.id),u(this,us,e.isSvg)),e.file&&u(this,vh,e.file.name),b(this,it,rf).call(this)},rc=function(){if(u(this,Fr,null),this._uiManager.enableWaiting(!1),!!n(this,_n)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,_t)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,_t)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},nf=function(){if(n(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,le)).then(i=>b(this,it,nc).call(this,i,!0)).finally(()=>b(this,it,rc).call(this));return}if(n(this,Cn)){const i=n(this,Cn);u(this,Cn,null),this._uiManager.enableWaiting(!0),u(this,Fr,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,it,nc).call(this,r)).finally(()=>b(this,it,rc).call(this)));return}if(n(this,Rr)){const i=n(this,Rr);u(this,Rr,null),this._uiManager.enableWaiting(!0),u(this,Fr,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,it,nc).call(this,r)).finally(()=>b(this,it,rc).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=ff.keys().join(",");const s=this._uiManager._signal;u(this,Fr,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,it,nc).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,it,rc).call(this))),e.click()},rf=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,_t);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=u(this,_n,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,it,om).call(this),n(this,Sh)||(this.parent.addUndoableEditor(this),u(this,Sh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,vh)&&this.div.setAttribute("aria-description",n(this,vh)),this.annotationElementId||this._uiManager.a11yAlert(gt._l10nAlert.stamp)},af=function(e,s){const{width:i,height:r}=n(this,_t);let a=i,o=r,l=n(this,_t);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=d.transferToImageBitmap()}return l},om=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new bs,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,_n);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,us)?n(this,_t):b(this,it,af).call(this,o,l),d=h.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(c,0,0,c.width,c.height,0,0,o,l)},of=function(e){if(e){if(n(this,us)){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,_t),s.getContext("2d").drawImage(n(this,_t),0,0),s.toDataURL()}if(n(this,us)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Rn.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Rn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,_t),0,0,n(this,_t).width,n(this,_t).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,_t))},HA=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}},T(am,"_type","stamp"),T(am,"_editorType",W.STAMP);var Io,Eh,Or,Nr,Tn,We,Br,xh,Ch,ii,kn,Xe,Pn,Hr,_h,H,Ur,bt,lm,UA,hi,hm,cm,lf;const $s=class $s{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){g(this,bt);g(this,Io);g(this,Eh,!1);g(this,Or,null);g(this,Nr,null);g(this,Tn,null);g(this,We,new Map);g(this,Br,!1);g(this,xh,!1);g(this,Ch,!1);g(this,ii,null);g(this,kn,null);g(this,Xe,null);g(this,Pn,null);g(this,Hr,null);g(this,_h,-1);g(this,H);const d=[...n($s,Ur).values()];if(!$s._initialized){$s._initialized=!0;for(const f of d)f.initialize(c,t)}t.registerEditorTypes(d),u(this,H,t),this.pageIndex=e,this.div=s,u(this,Io,r),u(this,Or,a),this.viewport=h,u(this,Xe,l),this.drawLayer=o,this._structTree=i,n(this,H).addLayer(this)}get isEmpty(){return n(this,We).size===0}get isInvisible(){return this.isEmpty&&n(this,H).getMode()===W.NONE}updateToolbar(t){n(this,H).updateToolbar(t)}updateMode(t=n(this,H).getMode()){switch(b(this,bt,lf).call(this),t){case W.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case W.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case W.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===W.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n($s,Ur).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Xe))==null?void 0:e.div)}setEditingState(t){n(this,H).setEditingState(t)}addCommands(t){n(this,H).addCommands(t)}cleanUndoStack(t){n(this,H).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,Or))==null||e.togglePointerEvents(t)}async enable(){var s;u(this,Ch,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Hr))==null||s.abort(),u(this,Hr,null);const t=new Set;for(const i of n(this,bt,lm))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,H).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,Or);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,H).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}u(this,Ch,!1),n(this,H)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(u(this,xh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Xe)&&!n(this,Hr)){u(this,Hr,new AbortController);const r=n(this,H).combinedSignal(n(this,Hr));n(this,Xe).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,d=n(this,_h);if(c-d>500){u(this,_h,c);return}u(this,_h,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const m=document.elementsFromPoint(l,h);if(f.toggle("getElements",!1),!this.div.contains(m[0]))return;let y;const A=new RegExp(`^${Ph}[0-9]+$`);for(const v of m)if(A.test(v.id)){y=v.id;break}if(!y)return;const w=n(this,We).get(y);(w==null?void 0:w.annotationElementId)===null&&(Kt(a),w.dblclick(a))},{signal:r,capture:!0})}const t=n(this,Or),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,bt,lm)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,H).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(n(this,H).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,bt,lf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n($s,Ur).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),u(this,xh,!1)}getEditableAnnotation(t){var e;return((e=n(this,Or))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,H).getActive()!==t&&n(this,H).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Xe))!=null&&t.div&&!n(this,Pn)){u(this,Pn,new AbortController);const e=n(this,H).combinedSignal(n(this,Pn));n(this,Xe).div.addEventListener("pointerdown",b(this,bt,UA).bind(this),{signal:e}),n(this,Xe).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Xe))!=null&&t.div&&n(this,Pn)&&(n(this,Pn).abort(),u(this,Pn,null),n(this,Xe).div.classList.remove("highlighting"))}enableClick(){if(n(this,Nr))return;u(this,Nr,new AbortController);const t=n(this,H).combinedSignal(n(this,Nr));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,Nr))==null||t.abort(),u(this,Nr,null)}attach(t){n(this,We).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,H).isDeletedAnnotationElement(e)&&n(this,H).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,We).delete(t.id),(e=n(this,Io))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,xh)&&t.annotationElementId&&n(this,H).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,H).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,H).addDeletedAnnotationElement(t),gt.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,H).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,Ch)),n(this,H).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,Tn)&&(t._focusEventsAllowed=!1,u(this,Tn,setTimeout(()=>{u(this,Tn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,H)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,Io))==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,We).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,H).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,bt,hi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,H).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,bt,cm).call(this),r=n(this,H).getId(),a=b(this,bt,hm).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,H),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n($s,Ur).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,H)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,H).getId(),r=b(this,bt,hm).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,H),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,bt,cm).call(this),!0,t)}setSelected(t){n(this,H).setSelected(t)}toggleSelected(t){n(this,H).toggleSelected(t)}unselect(t){n(this,H).unselect(t)}pointerup(t){var i;const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Br)||(u(this,Br,!1),(i=n(this,bt,hi))!=null&&i.isDrawer&&n(this,bt,hi).supportMultipleDrawings))return;if(!n(this,Eh)){u(this,Eh,!0);return}const s=n(this,H).getMode();if(s===W.STAMP||s===W.POPUP||s===W.SIGNATURE){n(this,H).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,H).getMode()===W.HIGHLIGHT&&this.enableTextSelection(),n(this,Br)){u(this,Br,!1);return}const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(u(this,Br,!0),(i=n(this,bt,hi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,H).getActive();u(this,Eh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,ii)){n(this,bt,hi).startDrawing(this,n(this,H),!1,t);return}n(this,H).setCurrentDrawingSession(this),u(this,ii,new AbortController);const e=n(this,H).combinedSignal(n(this,ii));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(u(this,kn,null),this.commitOrRemove())},{signal:e}),n(this,bt,hi).startDrawing(this,n(this,H),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&u(this,kn,e);return}n(this,kn)&&setTimeout(()=>{var e;(e=n(this,kn))==null||e.focus(),u(this,kn,null)},0)}endDrawingSession(t=!1){return n(this,ii)?(n(this,H).setCurrentDrawingSession(null),n(this,ii).abort(),u(this,ii,null),u(this,kn,null),n(this,bt,hi).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,H).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,ii)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,ii)&&n(this,bt,hi).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,H).getActive())==null?void 0:t.parent)===this&&(n(this,H).commitOrRemove(),n(this,H).setActiveEditor(null)),n(this,Tn)&&(clearTimeout(n(this,Tn)),u(this,Tn,null));for(const s of n(this,We).values())(e=n(this,Io))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,We).clear(),n(this,H).removeLayer(this)}async render({viewport:t}){this.viewport=t,jr(this.div,t);for(const e of n(this,H).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,H).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,H).commitOrRemove(),b(this,bt,lf).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,jr(this.div,{rotation:s}),e!==s)for(const i of n(this,We).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,H).viewParameters.realScale}};Io=new WeakMap,Eh=new WeakMap,Or=new WeakMap,Nr=new WeakMap,Tn=new WeakMap,We=new WeakMap,Br=new WeakMap,xh=new WeakMap,Ch=new WeakMap,ii=new WeakMap,kn=new WeakMap,Xe=new WeakMap,Pn=new WeakMap,Hr=new WeakMap,_h=new WeakMap,H=new WeakMap,Ur=new WeakMap,bt=new WeakSet,lm=function(){return n(this,We).size!==0?n(this,We).values():n(this,H).getEditors(this.pageIndex)},UA=function(t){n(this,H).unselectAll();const{target:e}=t;if(e===n(this,Xe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,Xe).div.contains(e)){const{isMac:s}=ot.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,H).showAllEditors("highlight",!0,!0),yf.startDrawing(this,n(this,H),n(this,H).direction==="ltr",t),t.preventDefault()}},hi=function(){return n($s,Ur).get(n(this,H).getMode())},hm=function(t){const e=n(this,bt,hi);return e?new e.prototype.constructor(t):null},cm=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,[d,f]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:f}},lf=function(){for(const t of n(this,We).values())t.isEmpty()&&t.remove()},T($s,"_initialized",!1),g($s,Ur,new Map([Bg,Zg,am,yf,rm].map(t=>[t._editorType,t])));let Af=$s;function Yw(p,t){return p===t?0:p.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Su(p){var t;return p?p.nodeType===Node.ELEMENT_NODE?p.closest(".textLayer"):((t=p.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function Kw(p,t,e,s){if(p===e)return t<=s;const i=p.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function fb(p,t,e){if(p.nodeType!==Node.ELEMENT_NODE||!p.classList.contains("textLayer")||t!==p.childNodes.length)return{container:p,offset:t};let s=p.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var Ie,Le,Ns,ru,au,Lo,Fo,ou,Kf,Gr,$r,zr,Vr,Mn,Ce,dm,um,GA,hf,$A,zi,fm,zA,pm;const $=class ${constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){g(this,zi);g(this,Ie,null);g(this,Le,new Map);g(this,Ns,null);g(this,ru,null);g(this,au,null);g(this,Lo,null);g(this,Fo,new Map);if(this.pageIndex=s,u(this,ru,t),u(this,au,e),i){const r=n($,Mn).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n($,$r).delete(r.selectionDiv)),n($,Mn).set(i,{drawLayer:this}),n($,Vr).add(i),u(this,Ns,i),u(this,Lo,new MutationObserver(a=>{var o,l,h;if(!(!n(this,Ie)||!((o=n(this,Ns))!=null&&o.isConnected)||!b(l=$,Ce,um).call(l))){for(const{addedNodes:c}of a)for(const d of c)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){b(h=$,Ce,hf).call(h);return}}})),n(this,Lo).observe(i,{childList:!0}),n($,Gr)===null){u($,Gr,new AbortController);const{signal:a}=n($,Gr);document.addEventListener("selectionchange",b($,Ce,hf).bind($),{signal:a}),document.addEventListener("pointerdown",()=>{u($,zr,!0)},{signal:a}),document.addEventListener("pointerup",()=>{u($,zr,!1)},{signal:a}),window.addEventListener("blur",()=>{u($,zr,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Ie)){u(this,Ie,t),(e=n(this,Ns))!=null&&e.isConnected&&b(s=$,Ce,um).call(s)&&b(i=$,Ce,hf).call(i);return}if(n(this,Ie)!==t){if(n(this,Le).size>0)for(const r of n(this,Le).values())r.remove(),t.append(r);u(this,Ie,t)}}static get _svgFactory(){return F(this,"_svgFactory",new Ac)}draw(t,e=!1,s=!1){const i=yt($,ou)._++,r=b(this,zi,fm).call(this),a=$._svgFactory.createElement("defs");r.append(a);const o=$._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,Fo).set(i,o);const h=s?b(this,zi,zA).call(this,a,l):null,c=$._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Le).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=yt($,ou)._++,i=b(this,zi,fm).call(this),r=$._svgFactory.createElement("defs");i.append(r);const a=$._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=$._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=$._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const m=$._svgFactory.createElement("use");d.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=$._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,Le).set(s,i),s}finalizeDraw(t,e){n(this,Fo).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,Le).get(t):t;if(o){if(s&&b(this,zi,pm).call(this,o,s),i&&b(l=$,Ce,$A).call(l,o,i),r){const{classList:h}=o;for(const[c,d]of Object.entries(r))h.toggle(c,d)}if(a){const c=o.firstElementChild.firstElementChild;b(this,zi,pm).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Le).get(t);s&&(n(e,Ie).append(s),n(this,Le).delete(t),n(e,Le).set(t,s))}remove(t){n(this,Fo).delete(t),n(this,Ie)!==null&&(n(this,Le).get(t).remove(),n(this,Le).delete(t))}destroy(){var t,e,s;u(this,Ie,null);for(const i of n(this,Le).values())i.remove();if(n(this,Le).clear(),n(this,Fo).clear(),(t=n(this,Lo))==null||t.disconnect(),u(this,Lo,null),n(this,Ns)){const i=n($,Mn).get(n(this,Ns));(i==null?void 0:i.drawLayer)===this&&(b(e=$,Ce,dm).call(e,n(this,Ns)),n($,Mn).delete(n(this,Ns)),n($,Vr).delete(n(this,Ns)),n($,Vr).size===0&&((s=n($,Gr))==null||s.abort(),u($,Gr,null),u($,zr,!1))),u(this,Ns,null)}}};Ie=new WeakMap,Le=new WeakMap,Ns=new WeakMap,ru=new WeakMap,au=new WeakMap,Lo=new WeakMap,Fo=new WeakMap,ou=new WeakMap,Kf=new WeakMap,Gr=new WeakMap,$r=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Mn=new WeakMap,Ce=new WeakSet,dm=function(t){const e=n(this,Mn).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,$r).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},um=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},GA=function(){return n(this,Vr).keys().filter(t=>t.isConnected).toArray().sort(Yw)},hf=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,$r))o.remove();n(this,$r).clear();return}const e=new WeakMap,s=b(this,Ce,GA).call(this),i=[];for(let o=0,l=t.rangeCount;o<l;o++){const h=t.getRangeAt(o);if(h.collapsed)continue;let{startContainer:c,startOffset:d,endContainer:f,endOffset:m}=h,y=Su(c),A=Su(f);const w=y===null,v=A===null;if(n(this,zr)&&w!==v)return;if(t.rangeCount===1){const{anchorNode:x,anchorOffset:C,focusNode:_,focusOffset:k}=t,M=Su(x),P=Su(_),D=Kw(x,C,_,k);M&&P&&D!==null&&(D?(c=x,d=C,y=M,f=_,m=k,A=P):(c=_,d=k,y=P,f=x,m=C,A=M))}const S=s.filter(x=>h.intersectsNode(x));if(S.length===0)continue;let E=!1;if(y||(y=S[0],c=y,d=0,E=!0),A||(A=S.at(-1),f=A,m=A.childNodes.length,E=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const x=f.previousSibling;if(!x)continue;f=x,m=x.nodeType===Node.TEXT_NODE?x.textContent.length:x.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===m){const x=fb(f,m,A);if(!x)continue;f=x.container,m=x.offset}}if(c.nodeType===Node.ELEMENT_NODE){const x=fb(c,d,y);if(!x)continue;c=x.container,d=x.offset}if(y===A&&!E&&S.includes(y)){i.push([h,y]);continue}for(const x of S){const C=x.firstChild;if(!C)continue;const _=document.createRange();if(x===y?_.setStart(c,d):_.setStartBefore(C),x===A)_.setEnd(f,m);else{const k=x.lastChild;if(!k)continue;if(k.nodeType===Node.ELEMENT_NODE&&k.classList.contains("endOfContent")){const M=k.previousSibling;if(!M)continue;_.setEndAfter(M)}else _.setEndAfter(k)}_.collapsed||i.push([_,x])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,Vr))r.has(o)||b(this,Ce,dm).call(this,o);for(const[o,l]of i){const h=n($,Mn).get(l);if(!h)continue;let c=e.get(l);if(!c){const A=l.getBoundingClientRect();c=(w,v,S,E)=>({x:(w-A.x)/A.width,y:(v-A.y)/A.height,width:S/A.width,height:E/A.height}),e.set(l,c)}const d=[];for(let{x:A,y:w,width:v,height:S}of o.getClientRects())v===0||S===0||({x:A,y:w,width:v,height:S}=c(A,w,v,S),!(v===1&&S===1)&&d.push(`M${A} ${w} h${v} v${S} h-${v} Z`));if(d.length===0)continue;const f=h.drawLayer;let m=h.selectionDiv,y=h.path;if(!m){const A=`clip_selection_${yt($,Kf)._++}`;m=document.createElement("div"),m.className="selection",m.style.clipPath=`url(#${A})`;const w=(a=n(f,ru))==null?void 0:a.createSelectionStyle(n(f,au));if(w)for(const[E,x]of Object.entries(w))m.style.setProperty(E,x);const v=$._svgFactory.create(1,1,!0);v.setAttribute("aria-hidden","true"),v.setAttribute("width","100%"),v.setAttribute("height","100%");const S=$._svgFactory.createElement("clipPath");S.setAttribute("id",A),S.setAttribute("clipPathUnits","objectBoundingBox"),y=$._svgFactory.createElement("path"),S.append(y),v.append(S),m.append(v),h.path=y,h.selectionDiv=m}n(f,Ie)&&m.parentNode!==n(f,Ie)&&(n(f,Ie).append(m),n(this,$r).add(m)),y.setAttribute("d",d.join(" "))}},$A=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}%`},zi=new WeakSet,fm=function(){const t=$._svgFactory.create(1,1,!0);return n(this,Ie).append(t),t.setAttribute("aria-hidden","true"),t},zA=function(t,e){const s=$._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=$._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},pm=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},g($,Ce),g($,ou,0),g($,Kf,0),g($,Gr,null),g($,$r,new Set),g($,zr,!1),g($,Vr,new Set),g($,Mn,new WeakMap);let wf=$;function Eu(p){return`${(p*100).toFixed(2)}%`}var Th,lu,hu,kh,Oi,Ni,cu,qf,VA;const uc=class uc{constructor(t,e,s,i){g(this,qf);g(this,Th,[]);g(this,lu,new Map);g(this,hu,null);g(this,kh,0);g(this,Oi,0);g(this,Ni,0);u(this,kh,t),u(this,Th,e),u(this,Oi,s.rawDims.pageWidth),u(this,Ni,s.rawDims.pageHeight),u(this,hu,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,Th).length;e+=6){const s=b(this,qf,VA).call(this,n(this,Th).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var v;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,lu).get(s);if(!i)return;const r=(v=n(uc,cu))==null?void 0:v.deref();if(r===s)return;r&&(r.width=0,r.height=0),u(uc,cu,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,d=n(this,hu).call(this),f=Math.ceil(o*d.width),m=Math.ceil(l*d.height),y=Math.floor((o+h/n(this,Oi))*d.width),A=Math.floor((l+c/n(this,Ni))*d.height);s.width=y-f,s.height=A-m;const w=s.getContext("2d");w.setTransform(...a),w.translate(-f,-m),w.drawImage(d,0,0)}),t}};Th=new WeakMap,lu=new WeakMap,hu=new WeakMap,kh=new WeakMap,Oi=new WeakMap,Ni=new WeakMap,cu=new WeakMap,qf=new WeakSet,VA=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Oi),(a-e)*n(this,Ni)),l=Math.hypot((s-t)*n(this,Oi),(i-e)*n(this,Ni));if(o<n(this,kh)||l<n(this,kh))return null;const h=[(r-t)*n(this,Oi)/o,(a-e)*n(this,Ni)/o,(s-t)*n(this,Oi)/l,(i-e)*n(this,Ni)/l,0,0],c=I.inverseTransform(h),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:Eu(t),top:Eu(e),width:Eu(o/n(this,Oi)),height:Eu(l/n(this,Ni)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,lu).set(d,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),d},g(uc,cu,null);let vf=uc;globalThis._pdfjsTestingUtils={HighlightOutliner:Xg};globalThis.pdfjsLib={AbortException:Fn,AnnotationEditorLayer:Af,AnnotationEditorParamsType:et,AnnotationEditorType:W,AnnotationEditorUIManager:Wr,AnnotationLayer:mf,AnnotationMode:Dn,AnnotationType:Et,applyOpacity:Sb,build:Yy,ColorPicker:yc,createValidAbsoluteUrl:gm,CSSConstants:vb,DOMSVGFactory:Ac,DrawLayer:wf,FeatureTest:ot,fetchData:sp,findContrastColor:Eb,getDocument:Vy,getFilenameFromUrl:Ab,getPdfFilenameFromUrl:wb,getRGB:Rh,getRGBA:Uo,getUuid:bm,GlobalWorkerOptions:Bi,ImageKind:ac,InvalidPDFException:df,isDataScheme:fu,isPdfFile:np,isValidExplicitDest:hy,makeArr:Ho,makeMap:tp,makeObj:uf,makeSet:yb,MathClamp:wt,noContextMenu:Us,normalizeUnicode:bb,OPS:ni,OutputScale:bs,PasswordException:cf,PasswordResponses:mb,PDFDataRangeTransport:Sm,PDFDateString:gc,PDFWorker:Dh,PermissionFlag:gb,PixelsPerInch:Rn,RenderingCancelledException:ip,renderRichText:ym,ResponseException:fc,setLayerDimensions:jr,shadow:F,SignatureExtractor:Hi,stopEvent:Kt,SupportedImageMimeTypes:ff,TextLayer:Mh,TextLayerImages:vf,TouchManager:Am,updateUrlHash:mm,Util:I,VerbosityLevel:du,version:Xy,XfaLayer:ep};const Jw=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Fn,AnnotationEditorLayer:Af,AnnotationEditorParamsType:et,AnnotationEditorType:W,AnnotationEditorUIManager:Wr,AnnotationLayer:mf,AnnotationMode:Dn,AnnotationType:Et,CSSConstants:vb,ColorPicker:yc,DOMSVGFactory:Ac,DrawLayer:wf,FeatureTest:ot,GlobalWorkerOptions:Bi,ImageKind:ac,InvalidPDFException:df,MathClamp:wt,OPS:ni,OutputScale:bs,PDFDataRangeTransport:Sm,PDFDateString:gc,PDFWorker:Dh,PasswordException:cf,PasswordResponses:mb,PermissionFlag:gb,PixelsPerInch:Rn,RenderingCancelledException:ip,ResponseException:fc,SignatureExtractor:Hi,SupportedImageMimeTypes:ff,TextLayer:Mh,TextLayerImages:vf,TouchManager:Am,Util:I,VerbosityLevel:du,XfaLayer:ep,applyOpacity:Sb,build:Yy,createValidAbsoluteUrl:gm,fetchData:sp,findContrastColor:Eb,getDocument:Vy,getFilenameFromUrl:Ab,getPdfFilenameFromUrl:wb,getRGB:Rh,getRGBA:Uo,getUuid:bm,isDataScheme:fu,isPdfFile:np,isValidExplicitDest:hy,makeArr:Ho,makeMap:tp,makeObj:uf,makeSet:yb,noContextMenu:Us,normalizeUnicode:bb,renderRichText:ym,setLayerDimensions:jr,shadow:F,stopEvent:Kt,updateUrlHash:mm,version:Xy},Symbol.toStringTag,{value:"Module"}));export{Bi as G,Qw as W,Jw as p};