corisco 1.3.4-hml → 1.3.4

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.
@@ -15,9 +15,9 @@ const Ai = {
15
15
  app: {
16
16
  name: "Corisco ChatJT",
17
17
  version: "1.3.0",
18
- iframe_url: "https://poc-ia.jt.jus.br/chat/"
18
+ iframe_url: "https://ia.jt.jus.br/chat/"
19
19
  },
20
- env: "hml",
20
+ env: "prd",
21
21
  // 'dev' | 'hml' | 'prd'
22
22
  ui: {
23
23
  panel: {
@@ -25,7 +25,7 @@ const Ai = {
25
25
  max_width_ratio: 0.9
26
26
  }
27
27
  },
28
- max_pdf_size: 10,
28
+ max_pdf_size: 15,
29
29
  // em MB
30
30
  action_map: [
31
31
  {
@@ -21436,11 +21436,11 @@ const Lk = ({ size: l = 32, ...t }) => /* @__PURE__ */ se.jsxDEV(
21436
21436
  children: /* @__PURE__ */ se.jsxDEV("g", { transform: "translate(0,865) scale(0.1,-0.1)", stroke: "none", children: /* @__PURE__ */ se.jsxDEV("path", { d: "M5151 8487 c0 -4 -10 -49 -21 -100 -10 -50 -31 -157 -45 -237 -23 -137 -43 -244 -116 -640 -16 -91 -41 -226 -54 -300 -14 -74 -34 -182 -44 -240 -11 -58 -34 -181 -51 -275 -17 -93 -46 -253 -65 -355 -32 -175 -53 -290 -125 -687 -17 -93 -44 -238 -60 -323 -16 -85 -32 -179 -36 -208 -5 -42 -11 -55 -29 -62 -20 -8 -154 -46 -475 -136 -69 -19 -171 -48 -227 -65 -57 -16 -149 -42 -205 -58 -57 -17 -161 -46 -233 -66 -71 -20 -166 -47 -210 -60 -44 -13 -179 -51 -300 -85 -121 -33 -265 -74 -320 -90 -55 -16 -205 -59 -333 -95 -128 -36 -321 -94 -430 -130 -108 -35 -285 -92 -392 -126 -107 -35 -196 -65 -198 -68 -5 -12 -113 -204 -241 -431 -240 -421 -302 -532 -409 -725 -187 -338 -176 -315 -155 -331 16 -11 -3 -13 -138 -14 -86 0 -158 -2 -161 -5 -3 -3 3 -60 13 -128 48 -319 174 -568 372 -737 195 -166 409 -243 677 -243 147 0 270 20 390 63 414 151 660 478 660 877 0 61 -3 125 -6 142 l-7 31 -146 1 c-112 0 -142 3 -129 11 14 10 -26 95 -348 741 -201 401 -362 732 -359 735 5 6 96 0 625 -43 102 -8 320 -21 485 -30 165 -8 433 -21 595 -30 162 -8 439 -22 615 -31 176 -9 473 -23 659 -33 279 -13 340 -19 347 -31 4 -8 17 -82 28 -165 22 -154 53 -370 116 -790 19 -132 47 -316 60 -410 14 -93 41 -278 61 -410 19 -132 48 -328 64 -435 47 -318 87 -590 125 -845 64 -437 85 -580 85 -595 1 -39 19 22 33 115 9 55 32 199 51 320 19 121 49 310 66 420 17 110 40 250 50 310 11 61 31 184 45 275 13 91 39 251 56 355 16 105 39 246 49 315 11 69 31 195 45 280 14 85 41 256 60 380 20 124 47 293 60 375 14 83 32 195 40 250 25 167 43 257 52 265 4 4 130 13 278 19 149 7 335 16 415 22 80 5 375 20 655 34 668 33 1212 63 1355 75 325 26 600 44 606 37 4 -3 2 -12 -3 -19 -6 -7 -25 -40 -44 -73 -18 -33 -49 -88 -68 -122 -20 -35 -71 -125 -113 -200 -43 -76 -110 -194 -149 -263 -39 -69 -104 -183 -144 -255 -40 -71 -81 -146 -92 -165 -105 -186 -193 -350 -193 -359 0 -6 5 -11 10 -11 6 0 10 -4 10 -10 0 -6 -59 -10 -156 -10 l-156 0 7 -57 c62 -514 311 -865 711 -1002 120 -41 206 -54 354 -54 239 0 458 66 650 197 74 50 198 175 249 251 57 86 116 222 132 307 13 66 16 329 5 347 -5 7 -57 11 -148 11 -122 0 -139 2 -128 15 10 12 -53 143 -349 736 -199 397 -361 730 -361 739 0 11 -13 20 -42 27 -24 6 -97 26 -163 46 -376 111 -577 170 -655 192 -50 15 -227 66 -430 126 -74 22 -171 51 -215 63 -121 35 -443 129 -600 176 -136 40 -243 72 -490 144 -66 19 -160 47 -210 61 -49 15 -142 42 -205 60 -63 19 -155 46 -205 60 -49 15 -98 30 -107 32 -10 3 -20 19 -23 37 -2 17 -9 58 -15 92 -6 33 -21 139 -35 235 -26 179 -70 486 -125 854 -17 116 -44 303 -60 416 -16 113 -31 217 -35 230 -3 13 -16 105 -30 204 -23 166 -42 297 -124 855 -17 113 -37 255 -46 315 -17 119 -32 205 -34 192z m-3733 -5400 c133 -265 242 -488 242 -495 0 -9 -115 -12 -520 -12 -359 0 -520 3 -520 11 0 12 177 337 358 654 68 121 138 244 154 273 16 28 33 52 36 52 4 0 116 -217 250 -483z m7811 -11 c133 -263 241 -483 241 -487 0 -5 -235 -9 -525 -9 -289 0 -525 3 -525 8 0 4 13 30 28 57 16 28 85 151 154 275 182 327 326 581 355 629 8 13 19 19 23 15 4 -5 117 -224 249 -488z" }, void 0, !1, {
21437
21437
  fileName: "C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",
21438
21438
  lineNumber: 19,
21439
- columnNumber: 9
21439
+ columnNumber: 17
21440
21440
  }, void 0) }, void 0, !1, {
21441
21441
  fileName: "C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",
21442
21442
  lineNumber: 18,
21443
- columnNumber: 7
21443
+ columnNumber: 13
21444
21444
  }, void 0)
21445
21445
  },
21446
21446
  void 0,
@@ -21448,10 +21448,10 @@ const Lk = ({ size: l = 32, ...t }) => /* @__PURE__ */ se.jsxDEV(
21448
21448
  {
21449
21449
  fileName: "C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",
21450
21450
  lineNumber: 9,
21451
- columnNumber: 5
21451
+ columnNumber: 9
21452
21452
  },
21453
21453
  void 0
21454
- ), Ik = ({ size: l = 32, className: t = "", ...i }) => /* @__PURE__ */ se.jsxDEV("svg", { xmlns: "http://www.w3.org/2000/svg", width: l, height: l, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: `${t} lucide lucide-chevron-right-icon lucide-chevron-right`, ...i, children: /* @__PURE__ */ se.jsxDEV("path", { d: "m9 18 6-6-6-6" }, void 0, !1, {
21454
+ ), Ik = ({ size: l = 32, className: t = "", ...i }) => /* @__PURE__ */ se.jsxDEV("svg", { xmlns: "http://www.w3.org/2000/svg", width: l, height: l, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round", className: `${t} lucide lucide-chevron-right-icon lucide-chevron-right`, ...i, children: /* @__PURE__ */ se.jsxDEV("path", { d: "m9 18 6-6-6-6" }, void 0, !1, {
21455
21455
  fileName: "C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChevronRight.tsx",
21456
21456
  lineNumber: 11,
21457
21457
  columnNumber: 13
@@ -21957,7 +21957,7 @@ let zk = class {
21957
21957
  window.addEventListener("message", (t) => {
21958
21958
  try {
21959
21959
  const i = this.validateMessage(t.data);
21960
- i ? this.handleMessage(i, t) : O.warn("Mensagem inválida recebida, ignorando:", t.data);
21960
+ i && this.handleMessage(i, t);
21961
21961
  } catch (i) {
21962
21962
  O.error("Erro ao processar mensagem:", i);
21963
21963
  }
@@ -1,4 +1,4 @@
1
- (function(ne,Yt){typeof exports=="object"&&typeof module<"u"?module.exports=Yt():typeof define=="function"&&define.amd?define(Yt):(ne=typeof globalThis<"u"?globalThis:ne||self,ne.Corisco=Yt())})(this,function(){"use strict";var W1=ne=>{throw TypeError(ne)};var Hy=(ne,Yt,mt)=>Yt.has(ne)||W1("Cannot "+mt);var ye=(ne,Yt,mt)=>(Hy(ne,Yt,"read from private field"),mt?mt.call(ne):Yt.get(ne)),Yi=(ne,Yt,mt)=>Yt.has(ne)?W1("Cannot add the same private member more than once"):Yt instanceof WeakSet?Yt.add(ne):Yt.set(ne,mt),kn=(ne,Yt,mt,Qt)=>(Hy(ne,Yt,"write to private field"),Qt?Qt.call(ne,mt):Yt.set(ne,mt),mt),Wi=(ne,Yt,mt)=>(Hy(ne,Yt,"access private method"),mt);var Q1=(ne,Yt,mt,Qt)=>({set _(Qi){kn(ne,Yt,Qi,mt)},get _(){return ye(ne,Yt,Qt)}});var Us,fi,es,xa,Lu,Ca,Ra,fn,Oh,K1,Z1,zc,Dr,kh;var ne=typeof document<"u"?document.currentScript:null;const Yt={app:{name:"Corisco ChatJT",version:"1.3.0",iframe_url:"https://poc-ia.jt.jus.br/chat/"},env:"hml",ui:{panel:{min_width:420,max_width_ratio:.9}},max_pdf_size:10,action_map:[{tool:"pje",allowed_hosts:["/^.*pje.*\\.jus\\.br\\/pjekz\\/.*$/","/^.*localhost:[0-9]+\\/.*$/"],actions:[{name:"Anexar selecionados",description:"Anexa os processos selecionados da timeline do PJe",job:"pje-docs-selecionados",loading_message:"Anexando documentos selecionados...",icon_menu:"SQUARE_MOUSE_POINTER",message:"EXTRACT_SELECTED_DOCUMENTS",auto_capture:!1,metadata_capture:!1},{name:"Processo completo",description:"Extrai o processo completo do PJe",job:"pje-processo-completo",loading_message:"Capturando processo completo...",icon_menu:"BOOK_UP",message:"EXTRACT_FULL_PROCESS",auto_capture:!1,metadata_capture:!1},{name:"Capturar documento visualizado",description:"Faz a captura automática do documento visualizado no PJe",job:"pje-doc-visualizado",loading_message:null,icon_menu:null,message:"EXTRACT_VISIBLE_DOCUMENT",auto_capture:!0,metadata_capture:!1},{name:"Capturar metadados da página",description:"Faz a captura automática dos metadados da página no PJe",job:"pje-metadados",loading_message:null,icon_menu:null,message:"EXTRACT_METADATA",auto_capture:!0,metadata_capture:!0}],mapping:{"/processo/\\d+/detalhe":["pje-processo-completo","pje-docs-selecionados","pje-doc-visualizado","pje-metadados"],"/processo/\\d+/detalhe/peticao/\\d+":["pje-processo-completo","pje-docs-selecionados","pje-doc-visualizado","pje-metadados"],"/processo/\\d+/documento/\\d+/conteudo":["pje-doc-visualizado","pje-metadados"],"/processo/\\d+/tarefa/\\d+/minutar":["pje-processo-completo","pje-metadados"],"/painel/global/\\d+/lista-processos":["pje-metadados"]}}]},mt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Qt=globalThis,Qi="10.8.0";function Hc(){return Bc(Qt),Qt}function Bc(l){const t=l.__SENTRY__=l.__SENTRY__||{};return t.version=t.version||Qi,t[Qi]=t[Qi]||{}}function Io(l,t,i=Qt){const a=i.__SENTRY__=i.__SENTRY__||{},r=a[Qi]=a[Qi]||{};return r[l]||(r[l]=t())}const J1=["debug","info","warn","error","log","assert","trace"],tw="Sentry Logger ",Fc={};function hr(l){if(!("console"in Qt))return l();const t=Qt.console,i={},a=Object.keys(Fc);a.forEach(r=>{const c=Fc[r];i[r]=t[r],t[r]=c});try{return l()}finally{a.forEach(r=>{t[r]=i[r]})}}function ew(){Lh().enabled=!0}function nw(){Lh().enabled=!1}function By(){return Lh().enabled}function iw(...l){Nh("log",...l)}function sw(...l){Nh("warn",...l)}function aw(...l){Nh("error",...l)}function Nh(l,...t){mt&&By()&&hr(()=>{Qt.console[l](`${tw}[${l}]:`,...t)})}function Lh(){return mt?Io("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Tt={enable:ew,disable:nw,isEnabled:By,log:iw,warn:sw,error:aw},Fy=50,ya="?",jy=/\(error: (.*)\)/,$y=/captureMessage|captureException/;function Gy(...l){const t=l.sort((i,a)=>i[0]-a[0]).map(i=>i[1]);return(i,a=0,r=0)=>{const c=[],u=i.split(`
1
+ (function(ne,Yt){typeof exports=="object"&&typeof module<"u"?module.exports=Yt():typeof define=="function"&&define.amd?define(Yt):(ne=typeof globalThis<"u"?globalThis:ne||self,ne.Corisco=Yt())})(this,function(){"use strict";var W1=ne=>{throw TypeError(ne)};var Hy=(ne,Yt,mt)=>Yt.has(ne)||W1("Cannot "+mt);var ye=(ne,Yt,mt)=>(Hy(ne,Yt,"read from private field"),mt?mt.call(ne):Yt.get(ne)),Yi=(ne,Yt,mt)=>Yt.has(ne)?W1("Cannot add the same private member more than once"):Yt instanceof WeakSet?Yt.add(ne):Yt.set(ne,mt),kn=(ne,Yt,mt,Qt)=>(Hy(ne,Yt,"write to private field"),Qt?Qt.call(ne,mt):Yt.set(ne,mt),mt),Wi=(ne,Yt,mt)=>(Hy(ne,Yt,"access private method"),mt);var Q1=(ne,Yt,mt,Qt)=>({set _(Qi){kn(ne,Yt,Qi,mt)},get _(){return ye(ne,Yt,Qt)}});var Us,fi,es,xa,Lu,Ca,Ra,fn,Oh,K1,Z1,zc,Dr,kh;var ne=typeof document<"u"?document.currentScript:null;const Yt={app:{name:"Corisco ChatJT",version:"1.3.0",iframe_url:"https://ia.jt.jus.br/chat/"},env:"prd",ui:{panel:{min_width:420,max_width_ratio:.9}},max_pdf_size:15,action_map:[{tool:"pje",allowed_hosts:["/^.*pje.*\\.jus\\.br\\/pjekz\\/.*$/","/^.*localhost:[0-9]+\\/.*$/"],actions:[{name:"Anexar selecionados",description:"Anexa os processos selecionados da timeline do PJe",job:"pje-docs-selecionados",loading_message:"Anexando documentos selecionados...",icon_menu:"SQUARE_MOUSE_POINTER",message:"EXTRACT_SELECTED_DOCUMENTS",auto_capture:!1,metadata_capture:!1},{name:"Processo completo",description:"Extrai o processo completo do PJe",job:"pje-processo-completo",loading_message:"Capturando processo completo...",icon_menu:"BOOK_UP",message:"EXTRACT_FULL_PROCESS",auto_capture:!1,metadata_capture:!1},{name:"Capturar documento visualizado",description:"Faz a captura automática do documento visualizado no PJe",job:"pje-doc-visualizado",loading_message:null,icon_menu:null,message:"EXTRACT_VISIBLE_DOCUMENT",auto_capture:!0,metadata_capture:!1},{name:"Capturar metadados da página",description:"Faz a captura automática dos metadados da página no PJe",job:"pje-metadados",loading_message:null,icon_menu:null,message:"EXTRACT_METADATA",auto_capture:!0,metadata_capture:!0}],mapping:{"/processo/\\d+/detalhe":["pje-processo-completo","pje-docs-selecionados","pje-doc-visualizado","pje-metadados"],"/processo/\\d+/detalhe/peticao/\\d+":["pje-processo-completo","pje-docs-selecionados","pje-doc-visualizado","pje-metadados"],"/processo/\\d+/documento/\\d+/conteudo":["pje-doc-visualizado","pje-metadados"],"/processo/\\d+/tarefa/\\d+/minutar":["pje-processo-completo","pje-metadados"],"/painel/global/\\d+/lista-processos":["pje-metadados"]}}]},mt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Qt=globalThis,Qi="10.8.0";function Hc(){return Bc(Qt),Qt}function Bc(l){const t=l.__SENTRY__=l.__SENTRY__||{};return t.version=t.version||Qi,t[Qi]=t[Qi]||{}}function Io(l,t,i=Qt){const a=i.__SENTRY__=i.__SENTRY__||{},r=a[Qi]=a[Qi]||{};return r[l]||(r[l]=t())}const J1=["debug","info","warn","error","log","assert","trace"],tw="Sentry Logger ",Fc={};function hr(l){if(!("console"in Qt))return l();const t=Qt.console,i={},a=Object.keys(Fc);a.forEach(r=>{const c=Fc[r];i[r]=t[r],t[r]=c});try{return l()}finally{a.forEach(r=>{t[r]=i[r]})}}function ew(){Lh().enabled=!0}function nw(){Lh().enabled=!1}function By(){return Lh().enabled}function iw(...l){Nh("log",...l)}function sw(...l){Nh("warn",...l)}function aw(...l){Nh("error",...l)}function Nh(l,...t){mt&&By()&&hr(()=>{Qt.console[l](`${tw}[${l}]:`,...t)})}function Lh(){return mt?Io("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const Tt={enable:ew,disable:nw,isEnabled:By,log:iw,warn:sw,error:aw},Fy=50,ya="?",jy=/\(error: (.*)\)/,$y=/captureMessage|captureException/;function Gy(...l){const t=l.sort((i,a)=>i[0]-a[0]).map(i=>i[1]);return(i,a=0,r=0)=>{const c=[],u=i.split(`
2
2
  `);for(let h=a;h<u.length;h++){let p=u[h];p.length>1024&&(p=p.slice(0,1024));const m=jy.test(p)?p.replace(jy,"$1"):p;if(!m.match(/\S*Error: /)){for(const g of t){const y=g(m);if(y){c.push(y);break}}if(c.length>=Fy+r)break}}return ow(c.slice(r))}}function rw(l){return Array.isArray(l)?Gy(...l):l}function ow(l){if(!l.length)return[];const t=Array.from(l);return/sentryWrapped/.test(jc(t).function||"")&&t.pop(),t.reverse(),$y.test(jc(t).function||"")&&(t.pop(),$y.test(jc(t).function||"")&&t.pop()),t.slice(0,Fy).map(i=>({...i,filename:i.filename||jc(t).filename,function:i.function||ya}))}function jc(l){return l[l.length-1]||{}}const Ih="<anonymous>";function Ds(l){try{return!l||typeof l!="function"?Ih:l.name||Ih}catch{return Ih}}function Vy(l){const t=l.exception;if(t){const i=[];try{return t.values.forEach(a=>{a.stacktrace.frames&&i.push(...a.stacktrace.frames)}),i}catch{return}}}const $c={},qy={};function Gc(l,t){$c[l]=$c[l]||[],$c[l].push(t)}function Vc(l,t){if(!qy[l]){qy[l]=!0;try{t()}catch(i){mt&&Tt.error(`Error while instrumenting ${l}`,i)}}}function fr(l,t){const i=l&&$c[l];if(i)for(const a of i)try{a(t)}catch(r){mt&&Tt.error(`Error while triggering instrumentation handler.
3
3
  Type: ${l}
4
4
  Name: ${Ds(a)}
@@ -285,7 +285,7 @@ You might need to use a local HTTP server (instead of file://): https://react.de
285
285
  <%s {...props} />
286
286
  React keys must be passed directly to JSX without using spread:
287
287
  let props = %s;
288
- <%s key={someKey} {...props} />`,vt,Kt,Te,Kt),wt[Kt+vt]=!0)}if(Kt=null,Q!==void 0&&(i(Q),Kt=""+Q),u(dt)&&(i(dt.key),Kt=""+dt.key),"key"in dt){Q={};for(var Ye in dt)Ye!=="key"&&(Q[Ye]=dt[Ye])}else Q=dt;return Kt&&h(Q,typeof W=="function"?W.displayName||W.name||"Unknown":W),m(W,Kt,ae,Vt,r(),Q,At,Wt)}function y(W){typeof W=="object"&&W!==null&&W.$$typeof===S&&W._store&&(W._store.validated=1)}var b=du(),S=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),k=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),tt=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),st=Symbol.for("react.client.reference"),Z=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ot=Object.prototype.hasOwnProperty,St=Array.isArray,yt=console.createTask?console.createTask:function(){return null};b={"react-stack-bottom-frame":function(W){return W()}};var Gt,B={},K=b["react-stack-bottom-frame"].bind(b,c)(),ut=yt(a(c)),wt={};hu.Fragment=_,hu.jsxDEV=function(W,dt,Q,vt,Vt,ae){var At=1e4>Z.recentlyCreatedOwnerStacks++;return g(W,dt,Q,vt,Vt,ae,At?Error("react-stack-top-frame"):K,At?yt(a(W)):ut)}}(),hu}var Uv;function eM(){return Uv||(Uv=1,Rf.exports=tM()),Rf.exports}var ie=eM();const nM=({size:l=32,...t})=>ie.jsxDEV("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 1011 865",preserveAspectRatio:"xMidYMid meet",fill:"currentColor",...t,children:ie.jsxDEV("g",{transform:"translate(0,865) scale(0.1,-0.1)",stroke:"none",children:ie.jsxDEV("path",{d:"M5151 8487 c0 -4 -10 -49 -21 -100 -10 -50 -31 -157 -45 -237 -23 -137 -43 -244 -116 -640 -16 -91 -41 -226 -54 -300 -14 -74 -34 -182 -44 -240 -11 -58 -34 -181 -51 -275 -17 -93 -46 -253 -65 -355 -32 -175 -53 -290 -125 -687 -17 -93 -44 -238 -60 -323 -16 -85 -32 -179 -36 -208 -5 -42 -11 -55 -29 -62 -20 -8 -154 -46 -475 -136 -69 -19 -171 -48 -227 -65 -57 -16 -149 -42 -205 -58 -57 -17 -161 -46 -233 -66 -71 -20 -166 -47 -210 -60 -44 -13 -179 -51 -300 -85 -121 -33 -265 -74 -320 -90 -55 -16 -205 -59 -333 -95 -128 -36 -321 -94 -430 -130 -108 -35 -285 -92 -392 -126 -107 -35 -196 -65 -198 -68 -5 -12 -113 -204 -241 -431 -240 -421 -302 -532 -409 -725 -187 -338 -176 -315 -155 -331 16 -11 -3 -13 -138 -14 -86 0 -158 -2 -161 -5 -3 -3 3 -60 13 -128 48 -319 174 -568 372 -737 195 -166 409 -243 677 -243 147 0 270 20 390 63 414 151 660 478 660 877 0 61 -3 125 -6 142 l-7 31 -146 1 c-112 0 -142 3 -129 11 14 10 -26 95 -348 741 -201 401 -362 732 -359 735 5 6 96 0 625 -43 102 -8 320 -21 485 -30 165 -8 433 -21 595 -30 162 -8 439 -22 615 -31 176 -9 473 -23 659 -33 279 -13 340 -19 347 -31 4 -8 17 -82 28 -165 22 -154 53 -370 116 -790 19 -132 47 -316 60 -410 14 -93 41 -278 61 -410 19 -132 48 -328 64 -435 47 -318 87 -590 125 -845 64 -437 85 -580 85 -595 1 -39 19 22 33 115 9 55 32 199 51 320 19 121 49 310 66 420 17 110 40 250 50 310 11 61 31 184 45 275 13 91 39 251 56 355 16 105 39 246 49 315 11 69 31 195 45 280 14 85 41 256 60 380 20 124 47 293 60 375 14 83 32 195 40 250 25 167 43 257 52 265 4 4 130 13 278 19 149 7 335 16 415 22 80 5 375 20 655 34 668 33 1212 63 1355 75 325 26 600 44 606 37 4 -3 2 -12 -3 -19 -6 -7 -25 -40 -44 -73 -18 -33 -49 -88 -68 -122 -20 -35 -71 -125 -113 -200 -43 -76 -110 -194 -149 -263 -39 -69 -104 -183 -144 -255 -40 -71 -81 -146 -92 -165 -105 -186 -193 -350 -193 -359 0 -6 5 -11 10 -11 6 0 10 -4 10 -10 0 -6 -59 -10 -156 -10 l-156 0 7 -57 c62 -514 311 -865 711 -1002 120 -41 206 -54 354 -54 239 0 458 66 650 197 74 50 198 175 249 251 57 86 116 222 132 307 13 66 16 329 5 347 -5 7 -57 11 -148 11 -122 0 -139 2 -128 15 10 12 -53 143 -349 736 -199 397 -361 730 -361 739 0 11 -13 20 -42 27 -24 6 -97 26 -163 46 -376 111 -577 170 -655 192 -50 15 -227 66 -430 126 -74 22 -171 51 -215 63 -121 35 -443 129 -600 176 -136 40 -243 72 -490 144 -66 19 -160 47 -210 61 -49 15 -142 42 -205 60 -63 19 -155 46 -205 60 -49 15 -98 30 -107 32 -10 3 -20 19 -23 37 -2 17 -9 58 -15 92 -6 33 -21 139 -35 235 -26 179 -70 486 -125 854 -17 116 -44 303 -60 416 -16 113 -31 217 -35 230 -3 13 -16 105 -30 204 -23 166 -42 297 -124 855 -17 113 -37 255 -46 315 -17 119 -32 205 -34 192z m-3733 -5400 c133 -265 242 -488 242 -495 0 -9 -115 -12 -520 -12 -359 0 -520 3 -520 11 0 12 177 337 358 654 68 121 138 244 154 273 16 28 33 52 36 52 4 0 116 -217 250 -483z m7811 -11 c133 -263 241 -483 241 -487 0 -5 -235 -9 -525 -9 -289 0 -525 3 -525 8 0 4 13 30 28 57 16 28 85 151 154 275 182 327 326 581 355 629 8 13 19 19 23 15 4 -5 117 -224 249 -488z"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",lineNumber:19,columnNumber:9},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",lineNumber:18,columnNumber:7},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",lineNumber:9,columnNumber:5},void 0),iM=({size:l=32,className:t="",...i})=>ie.jsxDEV("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`${t} lucide lucide-chevron-right-icon lucide-chevron-right`,...i,children:ie.jsxDEV("path",{d:"m9 18 6-6-6-6"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChevronRight.tsx",lineNumber:11,columnNumber:13},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChevronRight.tsx",lineNumber:10,columnNumber:9},void 0),sM=()=>{const l=Yt.app.iframe_url,t=Yt.ui.panel.min_width,i=Yt.ui.panel.max_width_ratio,a=540,r=()=>{try{const Q=localStorage.getItem("chatjt-panel-width");return Q?parseInt(Q,10):a}catch{return a}},c=Q=>{try{localStorage.setItem("chatjt-panel-width",Q.toString())}catch{}},[u,h]=En.useState(!1),[p,m]=En.useState(!1),[g,y]=En.useState(!1),[b,S]=En.useState(!1),[A,_]=En.useState(r()||a),[R,x]=En.useState(!1),L=En.useRef(null),k=En.useRef(null),U=En.useRef(null);En.useEffect(()=>{const Q=U.current,vt=L.current;if(!Q||!vt)return;let Vt=!1;const ae=Kt=>{if(!R)return;const Te=window.innerWidth*i,Ye=window.innerWidth-Kt.clientX;if(Ye>=t){const In=Math.max(t,Math.min(Te,Ye));_(In),S(!1),Vt=!1}else _(t),S(!0),Vt=!0},At=()=>{R&&(x(!1),document.body.style.userSelect="",k.current&&(k.current.style.pointerEvents="auto"),Q.style.backgroundColor="transparent",Vt?h(!1):c(A),S(!1),Vt=!1),x(!1)},Wt=()=>{x(!0),document.body.style.userSelect="none",k.current&&(k.current.style.pointerEvents="none"),Q.style.backgroundColor="#1591EA90"};return Q.addEventListener("mousedown",Wt),window.addEventListener("mousemove",ae),window.addEventListener("mouseup",At),()=>{Q.removeEventListener("mousedown",Wt),window.removeEventListener("mousemove",ae),window.removeEventListener("mouseup",At)}},[t,i,R,A]),En.useEffect(()=>{!u&&A!==r()&&c(A)},[u,A]),En.useEffect(()=>{u&&S(!1)},[u]);const P=()=>{m(!0),y(!1)},j=()=>{y(!0)},F=()=>{y(!1),k.current?.contentWindow?.location.reload()},tt={position:"absolute",bottom:50,right:50,width:60,height:60,backgroundColor:"#111827",color:"white",border:"none",borderRadius:"33%",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.2)",zIndex:9998,transition:"transform 0.3s ease, box-shadow 0.3s ease",padding:10,boxSizing:"border-box"},Y={position:"fixed",top:0,right:0,height:"100vh",width:A,backgroundColor:"#f8f9fa",borderLeft:"1px solid #111827",boxShadow:"-5px 0 15px rgba(0, 0, 0, 0.1)",zIndex:9999,display:"flex",flexDirection:"column",transition:u?"transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease":"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), visibility 0s 0.2s, opacity 0s 0.2s ease",transform:u?"translateX(0)":"translateX(100%)",visibility:u?"visible":"hidden"},st={position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.15)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10003,opacity:b?1:0,visibility:b?"visible":"hidden",transition:"opacity 0.2s ease, visibility 0.2s ease"},Z={color:"white",fontSize:18,fontWeight:600,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",textAlign:"center",textShadow:"0 2px 4px rgba(0, 0, 0, 0.5)",animation:b?"chatjt-pulse 1.5s ease-in-out infinite":""},ot={position:"absolute",top:0,left:-8,width:8,height:"100%",cursor:"col-resize",backgroundColor:"transparent",zIndex:10002},St={position:"absolute",top:"50%",left:-36,width:28,height:50,transform:"translateY(-50%)",backgroundColor:"#111827",color:"white",borderRadius:20,cursor:"pointer",zIndex:10001,display:"flex",justifyContent:"center",alignItems:"center",transition:"transform 0.2s ease",padding:"6px 4px",boxSizing:"border-box"},yt={position:"relative",flexGrow:1,overflow:"hidden"},Gt={width:"100%",height:"100%",border:"none",transition:"opacity 0.3s ease"},B={position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"linear-gradient(135deg, #253557 0%, #111827 100%)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},K={textAlign:"center",color:"white"},ut={width:40,height:40,border:"3px solid rgba(255, 255, 255, 0.3)",borderRadius:"50%",borderTopColor:"white",animation:"chatjt-spin 1s ease-in-out infinite",margin:"0 auto 16px auto"},wt={fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:14,fontWeight:500,marginBottom:12},W={fontSize:32,marginBottom:12,animation:"chatjt-pulse 2s ease-in-out infinite"},dt={background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",color:"white",padding:"10px 20px",borderRadius:6,cursor:"pointer",fontSize:13,fontWeight:500,transition:"all 0.2s ease",marginTop:8};return En.useEffect(()=>{const Q=document.createElement("style");return Q.innerHTML=`
288
+ <%s key={someKey} {...props} />`,vt,Kt,Te,Kt),wt[Kt+vt]=!0)}if(Kt=null,Q!==void 0&&(i(Q),Kt=""+Q),u(dt)&&(i(dt.key),Kt=""+dt.key),"key"in dt){Q={};for(var Ye in dt)Ye!=="key"&&(Q[Ye]=dt[Ye])}else Q=dt;return Kt&&h(Q,typeof W=="function"?W.displayName||W.name||"Unknown":W),m(W,Kt,ae,Vt,r(),Q,At,Wt)}function y(W){typeof W=="object"&&W!==null&&W.$$typeof===S&&W._store&&(W._store.validated=1)}var b=du(),S=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),k=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),tt=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),st=Symbol.for("react.client.reference"),Z=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ot=Object.prototype.hasOwnProperty,St=Array.isArray,yt=console.createTask?console.createTask:function(){return null};b={"react-stack-bottom-frame":function(W){return W()}};var Gt,B={},K=b["react-stack-bottom-frame"].bind(b,c)(),ut=yt(a(c)),wt={};hu.Fragment=_,hu.jsxDEV=function(W,dt,Q,vt,Vt,ae){var At=1e4>Z.recentlyCreatedOwnerStacks++;return g(W,dt,Q,vt,Vt,ae,At?Error("react-stack-top-frame"):K,At?yt(a(W)):ut)}}(),hu}var Uv;function eM(){return Uv||(Uv=1,Rf.exports=tM()),Rf.exports}var ie=eM();const nM=({size:l=32,...t})=>ie.jsxDEV("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 1011 865",preserveAspectRatio:"xMidYMid meet",fill:"currentColor",...t,children:ie.jsxDEV("g",{transform:"translate(0,865) scale(0.1,-0.1)",stroke:"none",children:ie.jsxDEV("path",{d:"M5151 8487 c0 -4 -10 -49 -21 -100 -10 -50 -31 -157 -45 -237 -23 -137 -43 -244 -116 -640 -16 -91 -41 -226 -54 -300 -14 -74 -34 -182 -44 -240 -11 -58 -34 -181 -51 -275 -17 -93 -46 -253 -65 -355 -32 -175 -53 -290 -125 -687 -17 -93 -44 -238 -60 -323 -16 -85 -32 -179 -36 -208 -5 -42 -11 -55 -29 -62 -20 -8 -154 -46 -475 -136 -69 -19 -171 -48 -227 -65 -57 -16 -149 -42 -205 -58 -57 -17 -161 -46 -233 -66 -71 -20 -166 -47 -210 -60 -44 -13 -179 -51 -300 -85 -121 -33 -265 -74 -320 -90 -55 -16 -205 -59 -333 -95 -128 -36 -321 -94 -430 -130 -108 -35 -285 -92 -392 -126 -107 -35 -196 -65 -198 -68 -5 -12 -113 -204 -241 -431 -240 -421 -302 -532 -409 -725 -187 -338 -176 -315 -155 -331 16 -11 -3 -13 -138 -14 -86 0 -158 -2 -161 -5 -3 -3 3 -60 13 -128 48 -319 174 -568 372 -737 195 -166 409 -243 677 -243 147 0 270 20 390 63 414 151 660 478 660 877 0 61 -3 125 -6 142 l-7 31 -146 1 c-112 0 -142 3 -129 11 14 10 -26 95 -348 741 -201 401 -362 732 -359 735 5 6 96 0 625 -43 102 -8 320 -21 485 -30 165 -8 433 -21 595 -30 162 -8 439 -22 615 -31 176 -9 473 -23 659 -33 279 -13 340 -19 347 -31 4 -8 17 -82 28 -165 22 -154 53 -370 116 -790 19 -132 47 -316 60 -410 14 -93 41 -278 61 -410 19 -132 48 -328 64 -435 47 -318 87 -590 125 -845 64 -437 85 -580 85 -595 1 -39 19 22 33 115 9 55 32 199 51 320 19 121 49 310 66 420 17 110 40 250 50 310 11 61 31 184 45 275 13 91 39 251 56 355 16 105 39 246 49 315 11 69 31 195 45 280 14 85 41 256 60 380 20 124 47 293 60 375 14 83 32 195 40 250 25 167 43 257 52 265 4 4 130 13 278 19 149 7 335 16 415 22 80 5 375 20 655 34 668 33 1212 63 1355 75 325 26 600 44 606 37 4 -3 2 -12 -3 -19 -6 -7 -25 -40 -44 -73 -18 -33 -49 -88 -68 -122 -20 -35 -71 -125 -113 -200 -43 -76 -110 -194 -149 -263 -39 -69 -104 -183 -144 -255 -40 -71 -81 -146 -92 -165 -105 -186 -193 -350 -193 -359 0 -6 5 -11 10 -11 6 0 10 -4 10 -10 0 -6 -59 -10 -156 -10 l-156 0 7 -57 c62 -514 311 -865 711 -1002 120 -41 206 -54 354 -54 239 0 458 66 650 197 74 50 198 175 249 251 57 86 116 222 132 307 13 66 16 329 5 347 -5 7 -57 11 -148 11 -122 0 -139 2 -128 15 10 12 -53 143 -349 736 -199 397 -361 730 -361 739 0 11 -13 20 -42 27 -24 6 -97 26 -163 46 -376 111 -577 170 -655 192 -50 15 -227 66 -430 126 -74 22 -171 51 -215 63 -121 35 -443 129 -600 176 -136 40 -243 72 -490 144 -66 19 -160 47 -210 61 -49 15 -142 42 -205 60 -63 19 -155 46 -205 60 -49 15 -98 30 -107 32 -10 3 -20 19 -23 37 -2 17 -9 58 -15 92 -6 33 -21 139 -35 235 -26 179 -70 486 -125 854 -17 116 -44 303 -60 416 -16 113 -31 217 -35 230 -3 13 -16 105 -30 204 -23 166 -42 297 -124 855 -17 113 -37 255 -46 315 -17 119 -32 205 -34 192z m-3733 -5400 c133 -265 242 -488 242 -495 0 -9 -115 -12 -520 -12 -359 0 -520 3 -520 11 0 12 177 337 358 654 68 121 138 244 154 273 16 28 33 52 36 52 4 0 116 -217 250 -483z m7811 -11 c133 -263 241 -483 241 -487 0 -5 -235 -9 -525 -9 -289 0 -525 3 -525 8 0 4 13 30 28 57 16 28 85 151 154 275 182 327 326 581 355 629 8 13 19 19 23 15 4 -5 117 -224 249 -488z"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",lineNumber:19,columnNumber:17},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",lineNumber:18,columnNumber:13},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChatJTIcon.tsx",lineNumber:9,columnNumber:9},void 0),iM=({size:l=32,className:t="",...i})=>ie.jsxDEV("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:l,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",className:`${t} lucide lucide-chevron-right-icon lucide-chevron-right`,...i,children:ie.jsxDEV("path",{d:"m9 18 6-6-6-6"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChevronRight.tsx",lineNumber:11,columnNumber:13},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/components/ChevronRight.tsx",lineNumber:10,columnNumber:9},void 0),sM=()=>{const l=Yt.app.iframe_url,t=Yt.ui.panel.min_width,i=Yt.ui.panel.max_width_ratio,a=540,r=()=>{try{const Q=localStorage.getItem("chatjt-panel-width");return Q?parseInt(Q,10):a}catch{return a}},c=Q=>{try{localStorage.setItem("chatjt-panel-width",Q.toString())}catch{}},[u,h]=En.useState(!1),[p,m]=En.useState(!1),[g,y]=En.useState(!1),[b,S]=En.useState(!1),[A,_]=En.useState(r()||a),[R,x]=En.useState(!1),L=En.useRef(null),k=En.useRef(null),U=En.useRef(null);En.useEffect(()=>{const Q=U.current,vt=L.current;if(!Q||!vt)return;let Vt=!1;const ae=Kt=>{if(!R)return;const Te=window.innerWidth*i,Ye=window.innerWidth-Kt.clientX;if(Ye>=t){const In=Math.max(t,Math.min(Te,Ye));_(In),S(!1),Vt=!1}else _(t),S(!0),Vt=!0},At=()=>{R&&(x(!1),document.body.style.userSelect="",k.current&&(k.current.style.pointerEvents="auto"),Q.style.backgroundColor="transparent",Vt?h(!1):c(A),S(!1),Vt=!1),x(!1)},Wt=()=>{x(!0),document.body.style.userSelect="none",k.current&&(k.current.style.pointerEvents="none"),Q.style.backgroundColor="#1591EA90"};return Q.addEventListener("mousedown",Wt),window.addEventListener("mousemove",ae),window.addEventListener("mouseup",At),()=>{Q.removeEventListener("mousedown",Wt),window.removeEventListener("mousemove",ae),window.removeEventListener("mouseup",At)}},[t,i,R,A]),En.useEffect(()=>{!u&&A!==r()&&c(A)},[u,A]),En.useEffect(()=>{u&&S(!1)},[u]);const P=()=>{m(!0),y(!1)},j=()=>{y(!0)},F=()=>{y(!1),k.current?.contentWindow?.location.reload()},tt={position:"absolute",bottom:50,right:50,width:60,height:60,backgroundColor:"#111827",color:"white",border:"none",borderRadius:"33%",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.2)",zIndex:9998,transition:"transform 0.3s ease, box-shadow 0.3s ease",padding:10,boxSizing:"border-box"},Y={position:"fixed",top:0,right:0,height:"100vh",width:A,backgroundColor:"#f8f9fa",borderLeft:"1px solid #111827",boxShadow:"-5px 0 15px rgba(0, 0, 0, 0.1)",zIndex:9999,display:"flex",flexDirection:"column",transition:u?"transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease":"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), visibility 0s 0.2s, opacity 0s 0.2s ease",transform:u?"translateX(0)":"translateX(100%)",visibility:u?"visible":"hidden"},st={position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.15)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10003,opacity:b?1:0,visibility:b?"visible":"hidden",transition:"opacity 0.2s ease, visibility 0.2s ease"},Z={color:"white",fontSize:18,fontWeight:600,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",textAlign:"center",textShadow:"0 2px 4px rgba(0, 0, 0, 0.5)",animation:b?"chatjt-pulse 1.5s ease-in-out infinite":""},ot={position:"absolute",top:0,left:-8,width:8,height:"100%",cursor:"col-resize",backgroundColor:"transparent",zIndex:10002},St={position:"absolute",top:"50%",left:-36,width:28,height:50,transform:"translateY(-50%)",backgroundColor:"#111827",color:"white",borderRadius:20,cursor:"pointer",zIndex:10001,display:"flex",justifyContent:"center",alignItems:"center",transition:"transform 0.2s ease",padding:"6px 4px",boxSizing:"border-box"},yt={position:"relative",flexGrow:1,overflow:"hidden"},Gt={width:"100%",height:"100%",border:"none",transition:"opacity 0.3s ease"},B={position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"linear-gradient(135deg, #253557 0%, #111827 100%)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},K={textAlign:"center",color:"white"},ut={width:40,height:40,border:"3px solid rgba(255, 255, 255, 0.3)",borderRadius:"50%",borderTopColor:"white",animation:"chatjt-spin 1s ease-in-out infinite",margin:"0 auto 16px auto"},wt={fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:14,fontWeight:500,marginBottom:12},W={fontSize:32,marginBottom:12,animation:"chatjt-pulse 2s ease-in-out infinite"},dt={background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",color:"white",padding:"10px 20px",borderRadius:6,cursor:"pointer",fontSize:13,fontWeight:500,transition:"all 0.2s ease",marginTop:8};return En.useEffect(()=>{const Q=document.createElement("style");return Q.innerHTML=`
289
289
  @keyframes chatjt-spin {
290
290
  to { transform: rotate(360deg); }
291
291
  }
@@ -293,7 +293,7 @@ React keys must be passed directly to JSX without using spread:
293
293
  0%, 100% { opacity: 1; transform: scale(1);}
294
294
  50% { opacity: 0.7; transform: scale(1.05);}
295
295
  }
296
- `,document.head.appendChild(Q),()=>{document.head.removeChild(Q)}},[]),ie.jsxDEV(ie.Fragment,{children:[!u&&ie.jsxDEV("button",{id:"chatjt-open-button",style:tt,onClick:()=>h(!0),onMouseEnter:Q=>{Q.currentTarget.style.transform="translateY(-10%) scale(1.05)",Q.currentTarget.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.2)"},onMouseLeave:Q=>{Q.currentTarget.style.transform="",Q.currentTarget.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)"},children:ie.jsxDEV(nM,{},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:341,columnNumber:21},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:328,columnNumber:17},void 0),ie.jsxDEV("div",{id:"chatjt-panel",ref:L,style:Y,children:[ie.jsxDEV("div",{id:"chatjt-resizer",ref:U,style:ot,onMouseMove:Q=>{R?(Q.currentTarget.style.background="linear-gradient(to right, transparent 95%, #1591EA90 95%)",Q.currentTarget.style.left="-160px",Q.currentTarget.style.width="160px"):(Q.currentTarget.style.left="-8px",Q.currentTarget.style.width="8px")},onMouseEnter:Q=>{R||(Q.currentTarget.style.background="#11182750")},onMouseLeave:Q=>{R||(Q.currentTarget.style.background="transparent")}},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:352,columnNumber:17},void 0),ie.jsxDEV("div",{id:"chatjt-iframe-container",style:yt,children:[g?ie.jsxDEV("div",{id:"chatjt-loading",style:B,children:ie.jsxDEV("div",{style:K,children:[ie.jsxDEV("div",{style:W,children:"⚠️"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:384,columnNumber:33},void 0),ie.jsxDEV("div",{style:wt,children:"Erro ao carregar ChatJT"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:385,columnNumber:33},void 0),ie.jsxDEV("button",{style:dt,onClick:F,onMouseEnter:Q=>{Q.currentTarget.style.background="rgba(255,255,255,0.3)",Q.currentTarget.style.borderColor="rgba(255,255,255,0.5)",Q.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:Q=>{Q.currentTarget.style.background="rgba(255,255,255,0.2)",Q.currentTarget.style.borderColor="rgba(255,255,255,0.3)",Q.currentTarget.style.transform=""},onMouseDown:Q=>{Q.currentTarget.style.transform="translateY(0)"},children:"Tentar novamente"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:386,columnNumber:33},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:383,columnNumber:29},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:382,columnNumber:25},void 0):ie.jsxDEV(ie.Fragment,{children:[!p&&ie.jsxDEV("div",{id:"chatjt-loading",style:B,children:ie.jsxDEV("div",{style:K,children:[ie.jsxDEV("div",{style:ut},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:412,columnNumber:41},void 0),ie.jsxDEV("div",{style:wt,children:"Carregando ChatJT..."},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:413,columnNumber:41},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:411,columnNumber:37},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:410,columnNumber:33},void 0),ie.jsxDEV("iframe",{id:"chatjt-iframe",ref:k,src:l,style:Gt,onLoad:P,onError:j,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-storage-access-by-user-activation allow-top-navigation-by-user-activation allow-modals",allow:"storage-access 'src'"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:417,columnNumber:29},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:408,columnNumber:25},void 0),ie.jsxDEV("div",{style:st,children:ie.jsxDEV("div",{style:Z,children:"Solte para fechar"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:432,columnNumber:25},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:431,columnNumber:21},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:380,columnNumber:17},void 0),ie.jsxDEV("div",{id:"chatjt-close-button",style:St,title:"Fechar painel","aria-label":"Fechar painel",onClick:()=>h(!1),onMouseEnter:Q=>{Q.currentTarget.style.transform="translateY(-50%) scale(1.1)",Q.currentTarget.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.2)"},onMouseLeave:Q=>{Q.currentTarget.style.transform="translateY(-50%)",Q.currentTarget.style.boxShadow=""},children:ie.jsxDEV(iM,{size:24},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:454,columnNumber:21},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:439,columnNumber:17},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:346,columnNumber:13},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:325,columnNumber:9},void 0)},Df="chatjt-container",zv="chatjt-open-button",Hv="chatjt-panel";class aM{root=null;container=null;async init(){try{if(document.getElementById(Df))return;this.container=document.createElement("div"),this.container.id=Df,this.container.style.pointerEvents="auto",document.body.appendChild(this.container),this.root=JD.createRoot(this.container),this.root.render(qD.createElement(sM)),O.info("UI da extensão inicializada via React"),setTimeout(()=>{const t=document.getElementById(zv),i=document.getElementById(Hv);O.info("Elementos criados:",{button:!!t,panel:!!i})},100)}catch(t){O.error("Erro ao inicializar UI:",t)}}destroy(){try{this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.remove(),this.container=null);const t=document.getElementById(Df);t&&t.remove();const i=document.getElementById(zv);i&&i.remove();const a=document.getElementById(Hv);a&&a.remove(),O.info("UI da extensão destruída")}catch(t){O.error("Erro ao destruir UI:",t)}}}const Mf={EXTENSION:"extension",IFRAME:"iframe"},ce={HANDSHAKE:"HANDSHAKE",HANDSHAKE_ACK:"HANDSHAKE_ACK",SINGLE_DOCUMENT_EXTRACTED:"SINGLE_DOCUMENT_EXTRACTED",MULTIPLE_DOCUMENTS_EXTRACTED:"MULTIPLE_DOCUMENTS_EXTRACTED",METADATA_EXTRACTED:"METADATA_EXTRACTED",AUTO_CAPTURE_DETECTION:"AUTO_CAPTURE_DETECTION",AUTO_CAPTURE_CLEANUP:"AUTO_CAPTURE_CLEANUP",EXTRACT_FULL_PROCESS:"EXTRACT_FULL_PROCESS",EXTRACT_SELECTED_DOCUMENTS:"EXTRACT_SELECTED_DOCUMENTS",EXTRACT_VISIBLE_DOCUMENT:"EXTRACT_VISIBLE_DOCUMENT",EXTRACT_METADATA:"EXTRACT_METADATA",EXTRACTION_ERROR:"EXTRACTION_ERROR",GENERIC_ERROR:"GENERIC_ERROR",UNSUPPORTED_MESSAGE:"UNSUPPORTED_MESSAGE"};let rM=class{source;isHandshakeComplete=!1;messageQueue=[];listeners=new Map;iframe;constructor(t=Mf.EXTENSION){this.source=t,this.iframe=null,this.initializeIframe(),this.setupMessageListener()}initializeIframe(){this.iframe=document.querySelector("#chatjt-iframe"),this.iframe?(O.info("Iframe encontrado e inicializado"),this.onIframeReady()):(O.detail("Iframe não encontrado inicialmente, aguardando criação..."),this.waitForIframe())}waitForIframe(){const t=new MutationObserver(i=>{i.forEach(a=>{a.type==="childList"&&a.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const c=r,u=c.id==="chatjt-iframe"?c:c.querySelector("#chatjt-iframe");u&&(this.iframe=u,O.info("Iframe detectado via MutationObserver"),this.onIframeReady(),t.disconnect())}})})});t.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{t.disconnect(),this.iframe||O.error("Timeout: Iframe não foi encontrado após 10 segundos")},1e4)}onIframeReady(){this.iframe&&(this.iframe.contentWindow?this.processQueuedMessages():this.iframe.addEventListener("load",()=>{O.info("Iframe carregado completamente"),this.processQueuedMessages()}))}setupMessageListener(){window.addEventListener("message",t=>{try{const i=this.validateMessage(t.data);i?this.handleMessage(i,t):O.warn("Mensagem inválida recebida, ignorando:",t.data)}catch(i){O.error("Erro ao processar mensagem:",i)}})}validateMessage(t){return!t||typeof t!="object"||!t.type||typeof t.type!="string"?null:this.isErrorMessage(t.type)&&t.source===this.source?(O.warn(`Mensagem de erro própria ignorada: ${t.type}`,t),null):t.source!==Mf.IFRAME?null:{id:t.id??crypto.randomUUID(),type:t.type,data:t.data??null,error:t.error??null,responseTo:t.responseTo??null,timestamp:t.timestamp??new Date().toISOString(),source:t.source??this.source}}isErrorMessage(t){return[ce.GENERIC_ERROR,ce.UNSUPPORTED_MESSAGE].includes(t)}handleMessage(t,i){if(O.info(`Mensagem recebida: ${t.type}`,t),t.type===ce.HANDSHAKE){this.handleHandshake();return}if(!this.isHandshakeComplete){this.messageQueue.push({message:t,event:i}),O.info(`Mensagem enfileirada - handshake pendente: ${t.type}`);return}this.processMessage(t,i)}handleHandshake(){O.info("Handshake recebido do iframe"),this.isHandshakeComplete=!0;let t="";try{t=window.location.href}catch{t="unknown"}O.info("URL do iframe:",t);const i=$D(t);O.info("Ações disponíveis para a URL do iframe:",i),this.sendMessage(ce.HANDSHAKE_ACK,{extensionVersion:Yt.app.version??"unknown",actions:i}),this.processQueuedMessages()}processMessage(t,i){const a=this.listeners.get(t.type);a?a(t,i):O.info(`Tipo de mensagem não suportado ou listener não configurado: ${t.type}`,t)}processQueuedMessages(){for(;this.messageQueue.length>0;){const{message:t,event:i}=this.messageQueue.shift();O.info(`Processando mensagem enfileirada: ${t.type}`),this.processMessage(t,i)}}sendMessage(t,i,a,r=null){const c={id:crypto.randomUUID(),type:t,data:i??null,error:a??void 0,responseTo:r??void 0,timestamp:new Date().toISOString(),source:this.source};if(O.info(`Enviando mensagem: ${t}`,c),!this.iframe||!this.iframe.contentWindow){O.warn(`Iframe não disponível, enfileirando mensagem: ${t}`),this.messageQueue.push({message:c,event:null});return}try{this.iframe.contentWindow.postMessage(c,"*"),O.info(`Mensagem enviada para o iframe: ${t}`)}catch(u){O.error("Erro ao enviar mensagem:",u),this.messageQueue.push({message:c,event:null})}}sendSuccessMessage(t,i=null,a){this.sendMessage(t,i,null,a??null)}sendError(t,i,a){this.sendMessage(t,null,i,a??null)}onMessage(t,i){this.listeners.set(t,i)}};const un=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Of=[.001,0,0,.001,0,0],kf=1.35,Nn={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ls={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Bv="pdfjs_internal_editor_",xt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},$t={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},oM={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},sn={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},fu={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},De={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},Er={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},pu={ERRORS:0,WARNINGS:1,INFOS:5},mu={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},gu={moveTo:0,lineTo:1,curveTo:2,closePath:3},lM={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let yu=pu.WARNINGS;function cM(l){Number.isInteger(l)&&(yu=l)}function uM(){return yu}function bu(l){yu>=pu.INFOS&&console.log(`Info: ${l}`)}function Ct(l){yu>=pu.WARNINGS&&console.log(`Warning: ${l}`)}function se(l){throw new Error(l)}function Me(l,t){l||se(t)}function dM(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Fv(l,t=null,i=null){if(!l)return null;if(i&&typeof l=="string"&&(i.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),i.tryConvertEncoding))try{l=gM(l)}catch{}const a=t?URL.parse(l,t):URL.parse(l);return dM(a)?a:null}function jv(l,t,i=!1){const a=URL.parse(l);return a?(a.hash=t,a.href):i&&Fv(l,"http://example.com")?l.split("#",1)[0]+`${t?`#${t}`:""}`:""}function zt(l,t,i,a=!1){return Object.defineProperty(l,t,{value:i,enumerable:!a,configurable:!0,writable:!1}),i}const Ea=function(){function t(i,a){this.message=i,this.name=a}return t.prototype=new Error,t.constructor=t,t}();class $v extends Ea{constructor(t,i){super(t,"PasswordException"),this.code=i}}class Nf extends Ea{constructor(t,i){super(t,"UnknownErrorException"),this.details=i}}class Lf extends Ea{constructor(t){super(t,"InvalidPDFException")}}class vu extends Ea{constructor(t,i,a){super(t,"ResponseException"),this.status=i,this.missing=a}}class hM extends Ea{constructor(t){super(t,"FormatError")}}class Is extends Ea{constructor(t){super(t,"AbortException")}}function Gv(l){(typeof l!="object"||l?.length===void 0)&&se("Invalid argument for bytesToString");const t=l.length,i=8192;if(t<i)return String.fromCharCode.apply(null,l);const a=[];for(let r=0;r<t;r+=i){const c=Math.min(r+i,t),u=l.subarray(r,c);a.push(String.fromCharCode.apply(null,u))}return a.join("")}function Yo(l){typeof l!="string"&&se("Invalid argument for stringToBytes");const t=l.length,i=new Uint8Array(t);for(let a=0;a<t;++a)i[a]=l.charCodeAt(a)&255;return i}function fM(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function pM(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function mM(){try{return new Function(""),!0}catch{return!1}}class Ve{static get isLittleEndian(){return zt(this,"isLittleEndian",pM())}static get isEvalSupported(){return zt(this,"isEvalSupported",mM())}static get isOffscreenCanvasSupported(){return zt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return zt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:i}=navigator;return zt(this,"platform",{isAndroid:i.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:i.includes("Firefox")})}static get isCSSRoundSupported(){return zt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const If=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class pt{static makeHexColor(t,i,a){return`#${If[t]}${If[i]}${If[a]}`}static scaleMinMax(t,i){let a;t[0]?(t[0]<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=t[0],i[2]*=t[0],t[3]<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t[3],i[3]*=t[3]):(a=i[0],i[0]=i[1],i[1]=a,a=i[2],i[2]=i[3],i[3]=a,t[1]<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t[1],i[3]*=t[1],t[2]<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=t[2],i[2]*=t[2]),i[0]+=t[4],i[1]+=t[5],i[2]+=t[4],i[3]+=t[5]}static transform(t,i){return[t[0]*i[0]+t[2]*i[1],t[1]*i[0]+t[3]*i[1],t[0]*i[2]+t[2]*i[3],t[1]*i[2]+t[3]*i[3],t[0]*i[4]+t[2]*i[5]+t[4],t[1]*i[4]+t[3]*i[5]+t[5]]}static applyTransform(t,i,a=0){const r=t[a],c=t[a+1];t[a]=r*i[0]+c*i[2]+i[4],t[a+1]=r*i[1]+c*i[3]+i[5]}static applyTransformToBezier(t,i,a=0){const r=i[0],c=i[1],u=i[2],h=i[3],p=i[4],m=i[5];for(let g=0;g<6;g+=2){const y=t[a+g],b=t[a+g+1];t[a+g]=y*r+b*u+p,t[a+g+1]=y*c+b*h+m}}static applyInverseTransform(t,i){const a=t[0],r=t[1],c=i[0]*i[3]-i[1]*i[2];t[0]=(a*i[3]-r*i[2]+i[2]*i[5]-i[4]*i[3])/c,t[1]=(-a*i[1]+r*i[0]+i[4]*i[1]-i[5]*i[0])/c}static axialAlignedBoundingBox(t,i,a){const r=i[0],c=i[1],u=i[2],h=i[3],p=i[4],m=i[5],g=t[0],y=t[1],b=t[2],S=t[3];let A=r*g+p,_=A,R=r*b+p,x=R,L=h*y+m,k=L,U=h*S+m,P=U;if(c!==0||u!==0){const j=c*g,F=c*b,tt=u*y,Y=u*S;A+=tt,x+=tt,R+=Y,_+=Y,L+=j,P+=j,U+=F,k+=F}a[0]=Math.min(a[0],A,R,_,x),a[1]=Math.min(a[1],L,U,k,P),a[2]=Math.max(a[2],A,R,_,x),a[3]=Math.max(a[3],L,U,k,P)}static inverseTransform(t){const i=t[0]*t[3]-t[1]*t[2];return[t[3]/i,-t[1]/i,-t[2]/i,t[0]/i,(t[2]*t[5]-t[4]*t[3])/i,(t[4]*t[1]-t[5]*t[0])/i]}static singularValueDecompose2dScale(t,i){const a=t[0],r=t[1],c=t[2],u=t[3],h=a**2+r**2,p=a*c+r*u,m=c**2+u**2,g=(h+m)/2,y=Math.sqrt(g**2-(h*m-p**2));i[0]=Math.sqrt(g+y||1),i[1]=Math.sqrt(g-y||1)}static normalizeRect(t){const i=t.slice(0);return t[0]>t[2]&&(i[0]=t[2],i[2]=t[0]),t[1]>t[3]&&(i[1]=t[3],i[3]=t[1]),i}static intersect(t,i){const a=Math.max(Math.min(t[0],t[2]),Math.min(i[0],i[2])),r=Math.min(Math.max(t[0],t[2]),Math.max(i[0],i[2]));if(a>r)return null;const c=Math.max(Math.min(t[1],t[3]),Math.min(i[1],i[3])),u=Math.min(Math.max(t[1],t[3]),Math.max(i[1],i[3]));return c>u?null:[a,c,r,u]}static pointBoundingBox(t,i,a){a[0]=Math.min(a[0],t),a[1]=Math.min(a[1],i),a[2]=Math.max(a[2],t),a[3]=Math.max(a[3],i)}static rectBoundingBox(t,i,a,r,c){c[0]=Math.min(c[0],t,a),c[1]=Math.min(c[1],i,r),c[2]=Math.max(c[2],t,a),c[3]=Math.max(c[3],i,r)}static#t(t,i,a,r,c,u,h,p,m,g){if(m<=0||m>=1)return;const y=1-m,b=m*m,S=b*m,A=y*(y*(y*t+3*m*i)+3*b*a)+S*r,_=y*(y*(y*c+3*m*u)+3*b*h)+S*p;g[0]=Math.min(g[0],A),g[1]=Math.min(g[1],_),g[2]=Math.max(g[2],A),g[3]=Math.max(g[3],_)}static#e(t,i,a,r,c,u,h,p,m,g,y,b){if(Math.abs(m)<1e-12){Math.abs(g)>=1e-12&&this.#t(t,i,a,r,c,u,h,p,-y/g,b);return}const S=g**2-4*y*m;if(S<0)return;const A=Math.sqrt(S),_=2*m;this.#t(t,i,a,r,c,u,h,p,(-g+A)/_,b),this.#t(t,i,a,r,c,u,h,p,(-g-A)/_,b)}static bezierBoundingBox(t,i,a,r,c,u,h,p,m){m[0]=Math.min(m[0],t,h),m[1]=Math.min(m[1],i,p),m[2]=Math.max(m[2],t,h),m[3]=Math.max(m[3],i,p),this.#e(t,a,c,h,i,r,u,p,3*(-t+3*(a-c)+h),6*(t-2*a+c),3*(a-t),m),this.#e(t,a,c,h,i,r,u,p,3*(-i+3*(r-u)+p),6*(i-2*r+u),3*(r-i),m)}}function gM(l){return decodeURIComponent(escape(l))}let Pf=null,Vv=null;function yM(l){return Pf||(Pf=/([\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,Vv=new Map([["ſt","ſt"]])),l.replaceAll(Pf,(t,i,a)=>i?i.normalize("NFKC"):Vv.get(a))}function qv(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);return crypto.getRandomValues(l),Gv(l)}const Uf="pdfjs_internal_id_";function bM(l,t,i){if(!Array.isArray(i)||i.length<2)return!1;const[a,r,...c]=i;if(!l(a)&&!Number.isInteger(a)||!t(r))return!1;const u=c.length;let h=!0;switch(r.name){case"XYZ":if(u<2||u>3)return!1;break;case"Fit":case"FitB":return u===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(u>1)return!1;break;case"FitR":if(u!==4)return!1;h=!1;break;default:return!1}for(const p of c)if(!(typeof p=="number"||h&&p===null))return!1;return!0}function dn(l,t,i){return Math.min(Math.max(l,t),i)}function Xv(l){return Uint8Array.prototype.toBase64?l.toBase64():btoa(Gv(l))}function vM(l){return Uint8Array.fromBase64?Uint8Array.fromBase64(l):Yo(atob(l))}typeof Promise.try!="function"&&(Promise.try=function(l,...t){return new Promise(i=>{i(l(...t))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(l){return l.reduce((t,i)=>t+i,0)});const Ji="http://www.w3.org/2000/svg";class Ar{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Wo(l,t="text"){if(Ko(l,document.baseURI)){const i=await fetch(l);if(!i.ok)throw new Error(i.statusText);switch(t){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,a)=>{const r=new XMLHttpRequest;r.open("GET",l,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(t){case"arraybuffer":case"blob":case"json":i(r.response);return}i(r.responseText);return}a(new Error(r.statusText))}},r.send(null)})}class Qo{constructor({viewBox:t,userUnit:i,scale:a,rotation:r,offsetX:c=0,offsetY:u=0,dontFlip:h=!1}){this.viewBox=t,this.userUnit=i,this.scale=a,this.rotation=r,this.offsetX=c,this.offsetY=u,a*=i;const p=(t[2]+t[0])/2,m=(t[3]+t[1])/2;let g,y,b,S;switch(r%=360,r<0&&(r+=360),r){case 180:g=-1,y=0,b=0,S=1;break;case 90:g=0,y=1,b=1,S=0;break;case 270:g=0,y=-1,b=-1,S=0;break;case 0:g=1,y=0,b=0,S=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}h&&(b=-b,S=-S);let A,_,R,x;g===0?(A=Math.abs(m-t[1])*a+c,_=Math.abs(p-t[0])*a+u,R=(t[3]-t[1])*a,x=(t[2]-t[0])*a):(A=Math.abs(p-t[0])*a+c,_=Math.abs(m-t[1])*a+u,R=(t[2]-t[0])*a,x=(t[3]-t[1])*a),this.transform=[g*a,y*a,b*a,S*a,A-g*a*p-b*a*m,_-y*a*p-S*a*m],this.width=R,this.height=x}get rawDims(){const t=this.viewBox;return zt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:i=this.rotation,offsetX:a=this.offsetX,offsetY:r=this.offsetY,dontFlip:c=!1}={}){return new Qo({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:i,offsetX:a,offsetY:r,dontFlip:c})}convertToViewportPoint(t,i){const a=[t,i];return pt.applyTransform(a,this.transform),a}convertToViewportRectangle(t){const i=[t[0],t[1]];pt.applyTransform(i,this.transform);const a=[t[2],t[3]];return pt.applyTransform(a,this.transform),[i[0],i[1],a[0],a[1]]}convertToPdfPoint(t,i){const a=[t,i];return pt.applyInverseTransform(a,this.transform),a}}class zf extends Ea{constructor(t,i=0){super(t,"RenderingCancelledException"),this.extraDelay=i}}function Su(l){const t=l.length;let i=0;for(;i<t&&l[i].trim()==="";)i++;return l.substring(i,i+5).toLowerCase()==="data:"}function Hf(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function SM(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function EM(l,t="document.pdf"){if(typeof l!="string")return t;if(Su(l))return Ct('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const a=(h=>{try{return new URL(h)}catch{try{return new URL(decodeURIComponent(h))}catch{try{return new URL(h,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(h),"https://foo.bar")}catch{return null}}}}})(l);if(!a)return t;const r=h=>{try{let p=decodeURIComponent(h);return p.includes("/")?(p=p.split("/").at(-1),p.test(/^\.pdf$/i)?p:h):p}catch{return h}},c=/\.pdf$/i,u=a.pathname.split("/").at(-1);if(c.test(u))return r(u);if(a.searchParams.size>0){const h=Array.from(a.searchParams.values()).reverse();for(const m of h)if(c.test(m))return r(m);const p=Array.from(a.searchParams.keys()).reverse();for(const m of p)if(c.test(m))return r(m)}if(a.hash){const p=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(a.hash);if(p)return r(p[0])}return t}class Yv{started=Object.create(null);times=[];time(t){t in this.started&&Ct(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Ct(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let i=0;for(const{name:a}of this.times)i=Math.max(a.length,i);for(const{name:a,start:r,end:c}of this.times)t.push(`${a.padEnd(i)} ${c-r}ms
296
+ `,document.head.appendChild(Q),()=>{document.head.removeChild(Q)}},[]),ie.jsxDEV(ie.Fragment,{children:[!u&&ie.jsxDEV("button",{id:"chatjt-open-button",style:tt,onClick:()=>h(!0),onMouseEnter:Q=>{Q.currentTarget.style.transform="translateY(-10%) scale(1.05)",Q.currentTarget.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.2)"},onMouseLeave:Q=>{Q.currentTarget.style.transform="",Q.currentTarget.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)"},children:ie.jsxDEV(nM,{},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:341,columnNumber:21},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:328,columnNumber:17},void 0),ie.jsxDEV("div",{id:"chatjt-panel",ref:L,style:Y,children:[ie.jsxDEV("div",{id:"chatjt-resizer",ref:U,style:ot,onMouseMove:Q=>{R?(Q.currentTarget.style.background="linear-gradient(to right, transparent 95%, #1591EA90 95%)",Q.currentTarget.style.left="-160px",Q.currentTarget.style.width="160px"):(Q.currentTarget.style.left="-8px",Q.currentTarget.style.width="8px")},onMouseEnter:Q=>{R||(Q.currentTarget.style.background="#11182750")},onMouseLeave:Q=>{R||(Q.currentTarget.style.background="transparent")}},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:352,columnNumber:17},void 0),ie.jsxDEV("div",{id:"chatjt-iframe-container",style:yt,children:[g?ie.jsxDEV("div",{id:"chatjt-loading",style:B,children:ie.jsxDEV("div",{style:K,children:[ie.jsxDEV("div",{style:W,children:"⚠️"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:384,columnNumber:33},void 0),ie.jsxDEV("div",{style:wt,children:"Erro ao carregar ChatJT"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:385,columnNumber:33},void 0),ie.jsxDEV("button",{style:dt,onClick:F,onMouseEnter:Q=>{Q.currentTarget.style.background="rgba(255,255,255,0.3)",Q.currentTarget.style.borderColor="rgba(255,255,255,0.5)",Q.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:Q=>{Q.currentTarget.style.background="rgba(255,255,255,0.2)",Q.currentTarget.style.borderColor="rgba(255,255,255,0.3)",Q.currentTarget.style.transform=""},onMouseDown:Q=>{Q.currentTarget.style.transform="translateY(0)"},children:"Tentar novamente"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:386,columnNumber:33},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:383,columnNumber:29},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:382,columnNumber:25},void 0):ie.jsxDEV(ie.Fragment,{children:[!p&&ie.jsxDEV("div",{id:"chatjt-loading",style:B,children:ie.jsxDEV("div",{style:K,children:[ie.jsxDEV("div",{style:ut},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:412,columnNumber:41},void 0),ie.jsxDEV("div",{style:wt,children:"Carregando ChatJT..."},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:413,columnNumber:41},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:411,columnNumber:37},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:410,columnNumber:33},void 0),ie.jsxDEV("iframe",{id:"chatjt-iframe",ref:k,src:l,style:Gt,onLoad:P,onError:j,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-storage-access-by-user-activation allow-top-navigation-by-user-activation allow-modals",allow:"storage-access 'src'"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:417,columnNumber:29},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:408,columnNumber:25},void 0),ie.jsxDEV("div",{style:st,children:ie.jsxDEV("div",{style:Z,children:"Solte para fechar"},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:432,columnNumber:25},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:431,columnNumber:21},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:380,columnNumber:17},void 0),ie.jsxDEV("div",{id:"chatjt-close-button",style:St,title:"Fechar painel","aria-label":"Fechar painel",onClick:()=>h(!1),onMouseEnter:Q=>{Q.currentTarget.style.transform="translateY(-50%) scale(1.1)",Q.currentTarget.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.2)"},onMouseLeave:Q=>{Q.currentTarget.style.transform="translateY(-50%)",Q.currentTarget.style.boxShadow=""},children:ie.jsxDEV(iM,{size:24},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:454,columnNumber:21},void 0)},void 0,!1,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:439,columnNumber:17},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:346,columnNumber:13},void 0)]},void 0,!0,{fileName:"C:/Users/guilherme.moreira/git/chat-jt-extensao/apps/corisco/src/ui/ExtensionPanel.tsx",lineNumber:325,columnNumber:9},void 0)},Df="chatjt-container",zv="chatjt-open-button",Hv="chatjt-panel";class aM{root=null;container=null;async init(){try{if(document.getElementById(Df))return;this.container=document.createElement("div"),this.container.id=Df,this.container.style.pointerEvents="auto",document.body.appendChild(this.container),this.root=JD.createRoot(this.container),this.root.render(qD.createElement(sM)),O.info("UI da extensão inicializada via React"),setTimeout(()=>{const t=document.getElementById(zv),i=document.getElementById(Hv);O.info("Elementos criados:",{button:!!t,panel:!!i})},100)}catch(t){O.error("Erro ao inicializar UI:",t)}}destroy(){try{this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.remove(),this.container=null);const t=document.getElementById(Df);t&&t.remove();const i=document.getElementById(zv);i&&i.remove();const a=document.getElementById(Hv);a&&a.remove(),O.info("UI da extensão destruída")}catch(t){O.error("Erro ao destruir UI:",t)}}}const Mf={EXTENSION:"extension",IFRAME:"iframe"},ce={HANDSHAKE:"HANDSHAKE",HANDSHAKE_ACK:"HANDSHAKE_ACK",SINGLE_DOCUMENT_EXTRACTED:"SINGLE_DOCUMENT_EXTRACTED",MULTIPLE_DOCUMENTS_EXTRACTED:"MULTIPLE_DOCUMENTS_EXTRACTED",METADATA_EXTRACTED:"METADATA_EXTRACTED",AUTO_CAPTURE_DETECTION:"AUTO_CAPTURE_DETECTION",AUTO_CAPTURE_CLEANUP:"AUTO_CAPTURE_CLEANUP",EXTRACT_FULL_PROCESS:"EXTRACT_FULL_PROCESS",EXTRACT_SELECTED_DOCUMENTS:"EXTRACT_SELECTED_DOCUMENTS",EXTRACT_VISIBLE_DOCUMENT:"EXTRACT_VISIBLE_DOCUMENT",EXTRACT_METADATA:"EXTRACT_METADATA",EXTRACTION_ERROR:"EXTRACTION_ERROR",GENERIC_ERROR:"GENERIC_ERROR",UNSUPPORTED_MESSAGE:"UNSUPPORTED_MESSAGE"};let rM=class{source;isHandshakeComplete=!1;messageQueue=[];listeners=new Map;iframe;constructor(t=Mf.EXTENSION){this.source=t,this.iframe=null,this.initializeIframe(),this.setupMessageListener()}initializeIframe(){this.iframe=document.querySelector("#chatjt-iframe"),this.iframe?(O.info("Iframe encontrado e inicializado"),this.onIframeReady()):(O.detail("Iframe não encontrado inicialmente, aguardando criação..."),this.waitForIframe())}waitForIframe(){const t=new MutationObserver(i=>{i.forEach(a=>{a.type==="childList"&&a.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const c=r,u=c.id==="chatjt-iframe"?c:c.querySelector("#chatjt-iframe");u&&(this.iframe=u,O.info("Iframe detectado via MutationObserver"),this.onIframeReady(),t.disconnect())}})})});t.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{t.disconnect(),this.iframe||O.error("Timeout: Iframe não foi encontrado após 10 segundos")},1e4)}onIframeReady(){this.iframe&&(this.iframe.contentWindow?this.processQueuedMessages():this.iframe.addEventListener("load",()=>{O.info("Iframe carregado completamente"),this.processQueuedMessages()}))}setupMessageListener(){window.addEventListener("message",t=>{try{const i=this.validateMessage(t.data);i&&this.handleMessage(i,t)}catch(i){O.error("Erro ao processar mensagem:",i)}})}validateMessage(t){return!t||typeof t!="object"||!t.type||typeof t.type!="string"?null:this.isErrorMessage(t.type)&&t.source===this.source?(O.warn(`Mensagem de erro própria ignorada: ${t.type}`,t),null):t.source!==Mf.IFRAME?null:{id:t.id??crypto.randomUUID(),type:t.type,data:t.data??null,error:t.error??null,responseTo:t.responseTo??null,timestamp:t.timestamp??new Date().toISOString(),source:t.source??this.source}}isErrorMessage(t){return[ce.GENERIC_ERROR,ce.UNSUPPORTED_MESSAGE].includes(t)}handleMessage(t,i){if(O.info(`Mensagem recebida: ${t.type}`,t),t.type===ce.HANDSHAKE){this.handleHandshake();return}if(!this.isHandshakeComplete){this.messageQueue.push({message:t,event:i}),O.info(`Mensagem enfileirada - handshake pendente: ${t.type}`);return}this.processMessage(t,i)}handleHandshake(){O.info("Handshake recebido do iframe"),this.isHandshakeComplete=!0;let t="";try{t=window.location.href}catch{t="unknown"}O.info("URL do iframe:",t);const i=$D(t);O.info("Ações disponíveis para a URL do iframe:",i),this.sendMessage(ce.HANDSHAKE_ACK,{extensionVersion:Yt.app.version??"unknown",actions:i}),this.processQueuedMessages()}processMessage(t,i){const a=this.listeners.get(t.type);a?a(t,i):O.info(`Tipo de mensagem não suportado ou listener não configurado: ${t.type}`,t)}processQueuedMessages(){for(;this.messageQueue.length>0;){const{message:t,event:i}=this.messageQueue.shift();O.info(`Processando mensagem enfileirada: ${t.type}`),this.processMessage(t,i)}}sendMessage(t,i,a,r=null){const c={id:crypto.randomUUID(),type:t,data:i??null,error:a??void 0,responseTo:r??void 0,timestamp:new Date().toISOString(),source:this.source};if(O.info(`Enviando mensagem: ${t}`,c),!this.iframe||!this.iframe.contentWindow){O.warn(`Iframe não disponível, enfileirando mensagem: ${t}`),this.messageQueue.push({message:c,event:null});return}try{this.iframe.contentWindow.postMessage(c,"*"),O.info(`Mensagem enviada para o iframe: ${t}`)}catch(u){O.error("Erro ao enviar mensagem:",u),this.messageQueue.push({message:c,event:null})}}sendSuccessMessage(t,i=null,a){this.sendMessage(t,i,null,a??null)}sendError(t,i,a){this.sendMessage(t,null,i,a??null)}onMessage(t,i){this.listeners.set(t,i)}};const un=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Of=[.001,0,0,.001,0,0],kf=1.35,Nn={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ls={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Bv="pdfjs_internal_editor_",xt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},$t={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},oM={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},sn={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},fu={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},De={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},Er={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},pu={ERRORS:0,WARNINGS:1,INFOS:5},mu={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},gu={moveTo:0,lineTo:1,curveTo:2,closePath:3},lM={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let yu=pu.WARNINGS;function cM(l){Number.isInteger(l)&&(yu=l)}function uM(){return yu}function bu(l){yu>=pu.INFOS&&console.log(`Info: ${l}`)}function Ct(l){yu>=pu.WARNINGS&&console.log(`Warning: ${l}`)}function se(l){throw new Error(l)}function Me(l,t){l||se(t)}function dM(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Fv(l,t=null,i=null){if(!l)return null;if(i&&typeof l=="string"&&(i.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),i.tryConvertEncoding))try{l=gM(l)}catch{}const a=t?URL.parse(l,t):URL.parse(l);return dM(a)?a:null}function jv(l,t,i=!1){const a=URL.parse(l);return a?(a.hash=t,a.href):i&&Fv(l,"http://example.com")?l.split("#",1)[0]+`${t?`#${t}`:""}`:""}function zt(l,t,i,a=!1){return Object.defineProperty(l,t,{value:i,enumerable:!a,configurable:!0,writable:!1}),i}const Ea=function(){function t(i,a){this.message=i,this.name=a}return t.prototype=new Error,t.constructor=t,t}();class $v extends Ea{constructor(t,i){super(t,"PasswordException"),this.code=i}}class Nf extends Ea{constructor(t,i){super(t,"UnknownErrorException"),this.details=i}}class Lf extends Ea{constructor(t){super(t,"InvalidPDFException")}}class vu extends Ea{constructor(t,i,a){super(t,"ResponseException"),this.status=i,this.missing=a}}class hM extends Ea{constructor(t){super(t,"FormatError")}}class Is extends Ea{constructor(t){super(t,"AbortException")}}function Gv(l){(typeof l!="object"||l?.length===void 0)&&se("Invalid argument for bytesToString");const t=l.length,i=8192;if(t<i)return String.fromCharCode.apply(null,l);const a=[];for(let r=0;r<t;r+=i){const c=Math.min(r+i,t),u=l.subarray(r,c);a.push(String.fromCharCode.apply(null,u))}return a.join("")}function Yo(l){typeof l!="string"&&se("Invalid argument for stringToBytes");const t=l.length,i=new Uint8Array(t);for(let a=0;a<t;++a)i[a]=l.charCodeAt(a)&255;return i}function fM(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function pM(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function mM(){try{return new Function(""),!0}catch{return!1}}class Ve{static get isLittleEndian(){return zt(this,"isLittleEndian",pM())}static get isEvalSupported(){return zt(this,"isEvalSupported",mM())}static get isOffscreenCanvasSupported(){return zt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return zt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:i}=navigator;return zt(this,"platform",{isAndroid:i.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:i.includes("Firefox")})}static get isCSSRoundSupported(){return zt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const If=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class pt{static makeHexColor(t,i,a){return`#${If[t]}${If[i]}${If[a]}`}static scaleMinMax(t,i){let a;t[0]?(t[0]<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=t[0],i[2]*=t[0],t[3]<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t[3],i[3]*=t[3]):(a=i[0],i[0]=i[1],i[1]=a,a=i[2],i[2]=i[3],i[3]=a,t[1]<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t[1],i[3]*=t[1],t[2]<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=t[2],i[2]*=t[2]),i[0]+=t[4],i[1]+=t[5],i[2]+=t[4],i[3]+=t[5]}static transform(t,i){return[t[0]*i[0]+t[2]*i[1],t[1]*i[0]+t[3]*i[1],t[0]*i[2]+t[2]*i[3],t[1]*i[2]+t[3]*i[3],t[0]*i[4]+t[2]*i[5]+t[4],t[1]*i[4]+t[3]*i[5]+t[5]]}static applyTransform(t,i,a=0){const r=t[a],c=t[a+1];t[a]=r*i[0]+c*i[2]+i[4],t[a+1]=r*i[1]+c*i[3]+i[5]}static applyTransformToBezier(t,i,a=0){const r=i[0],c=i[1],u=i[2],h=i[3],p=i[4],m=i[5];for(let g=0;g<6;g+=2){const y=t[a+g],b=t[a+g+1];t[a+g]=y*r+b*u+p,t[a+g+1]=y*c+b*h+m}}static applyInverseTransform(t,i){const a=t[0],r=t[1],c=i[0]*i[3]-i[1]*i[2];t[0]=(a*i[3]-r*i[2]+i[2]*i[5]-i[4]*i[3])/c,t[1]=(-a*i[1]+r*i[0]+i[4]*i[1]-i[5]*i[0])/c}static axialAlignedBoundingBox(t,i,a){const r=i[0],c=i[1],u=i[2],h=i[3],p=i[4],m=i[5],g=t[0],y=t[1],b=t[2],S=t[3];let A=r*g+p,_=A,R=r*b+p,x=R,L=h*y+m,k=L,U=h*S+m,P=U;if(c!==0||u!==0){const j=c*g,F=c*b,tt=u*y,Y=u*S;A+=tt,x+=tt,R+=Y,_+=Y,L+=j,P+=j,U+=F,k+=F}a[0]=Math.min(a[0],A,R,_,x),a[1]=Math.min(a[1],L,U,k,P),a[2]=Math.max(a[2],A,R,_,x),a[3]=Math.max(a[3],L,U,k,P)}static inverseTransform(t){const i=t[0]*t[3]-t[1]*t[2];return[t[3]/i,-t[1]/i,-t[2]/i,t[0]/i,(t[2]*t[5]-t[4]*t[3])/i,(t[4]*t[1]-t[5]*t[0])/i]}static singularValueDecompose2dScale(t,i){const a=t[0],r=t[1],c=t[2],u=t[3],h=a**2+r**2,p=a*c+r*u,m=c**2+u**2,g=(h+m)/2,y=Math.sqrt(g**2-(h*m-p**2));i[0]=Math.sqrt(g+y||1),i[1]=Math.sqrt(g-y||1)}static normalizeRect(t){const i=t.slice(0);return t[0]>t[2]&&(i[0]=t[2],i[2]=t[0]),t[1]>t[3]&&(i[1]=t[3],i[3]=t[1]),i}static intersect(t,i){const a=Math.max(Math.min(t[0],t[2]),Math.min(i[0],i[2])),r=Math.min(Math.max(t[0],t[2]),Math.max(i[0],i[2]));if(a>r)return null;const c=Math.max(Math.min(t[1],t[3]),Math.min(i[1],i[3])),u=Math.min(Math.max(t[1],t[3]),Math.max(i[1],i[3]));return c>u?null:[a,c,r,u]}static pointBoundingBox(t,i,a){a[0]=Math.min(a[0],t),a[1]=Math.min(a[1],i),a[2]=Math.max(a[2],t),a[3]=Math.max(a[3],i)}static rectBoundingBox(t,i,a,r,c){c[0]=Math.min(c[0],t,a),c[1]=Math.min(c[1],i,r),c[2]=Math.max(c[2],t,a),c[3]=Math.max(c[3],i,r)}static#t(t,i,a,r,c,u,h,p,m,g){if(m<=0||m>=1)return;const y=1-m,b=m*m,S=b*m,A=y*(y*(y*t+3*m*i)+3*b*a)+S*r,_=y*(y*(y*c+3*m*u)+3*b*h)+S*p;g[0]=Math.min(g[0],A),g[1]=Math.min(g[1],_),g[2]=Math.max(g[2],A),g[3]=Math.max(g[3],_)}static#e(t,i,a,r,c,u,h,p,m,g,y,b){if(Math.abs(m)<1e-12){Math.abs(g)>=1e-12&&this.#t(t,i,a,r,c,u,h,p,-y/g,b);return}const S=g**2-4*y*m;if(S<0)return;const A=Math.sqrt(S),_=2*m;this.#t(t,i,a,r,c,u,h,p,(-g+A)/_,b),this.#t(t,i,a,r,c,u,h,p,(-g-A)/_,b)}static bezierBoundingBox(t,i,a,r,c,u,h,p,m){m[0]=Math.min(m[0],t,h),m[1]=Math.min(m[1],i,p),m[2]=Math.max(m[2],t,h),m[3]=Math.max(m[3],i,p),this.#e(t,a,c,h,i,r,u,p,3*(-t+3*(a-c)+h),6*(t-2*a+c),3*(a-t),m),this.#e(t,a,c,h,i,r,u,p,3*(-i+3*(r-u)+p),6*(i-2*r+u),3*(r-i),m)}}function gM(l){return decodeURIComponent(escape(l))}let Pf=null,Vv=null;function yM(l){return Pf||(Pf=/([\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,Vv=new Map([["ſt","ſt"]])),l.replaceAll(Pf,(t,i,a)=>i?i.normalize("NFKC"):Vv.get(a))}function qv(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);return crypto.getRandomValues(l),Gv(l)}const Uf="pdfjs_internal_id_";function bM(l,t,i){if(!Array.isArray(i)||i.length<2)return!1;const[a,r,...c]=i;if(!l(a)&&!Number.isInteger(a)||!t(r))return!1;const u=c.length;let h=!0;switch(r.name){case"XYZ":if(u<2||u>3)return!1;break;case"Fit":case"FitB":return u===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(u>1)return!1;break;case"FitR":if(u!==4)return!1;h=!1;break;default:return!1}for(const p of c)if(!(typeof p=="number"||h&&p===null))return!1;return!0}function dn(l,t,i){return Math.min(Math.max(l,t),i)}function Xv(l){return Uint8Array.prototype.toBase64?l.toBase64():btoa(Gv(l))}function vM(l){return Uint8Array.fromBase64?Uint8Array.fromBase64(l):Yo(atob(l))}typeof Promise.try!="function"&&(Promise.try=function(l,...t){return new Promise(i=>{i(l(...t))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(l){return l.reduce((t,i)=>t+i,0)});const Ji="http://www.w3.org/2000/svg";class Ar{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Wo(l,t="text"){if(Ko(l,document.baseURI)){const i=await fetch(l);if(!i.ok)throw new Error(i.statusText);switch(t){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,a)=>{const r=new XMLHttpRequest;r.open("GET",l,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(r.status===200||r.status===0){switch(t){case"arraybuffer":case"blob":case"json":i(r.response);return}i(r.responseText);return}a(new Error(r.statusText))}},r.send(null)})}class Qo{constructor({viewBox:t,userUnit:i,scale:a,rotation:r,offsetX:c=0,offsetY:u=0,dontFlip:h=!1}){this.viewBox=t,this.userUnit=i,this.scale=a,this.rotation=r,this.offsetX=c,this.offsetY=u,a*=i;const p=(t[2]+t[0])/2,m=(t[3]+t[1])/2;let g,y,b,S;switch(r%=360,r<0&&(r+=360),r){case 180:g=-1,y=0,b=0,S=1;break;case 90:g=0,y=1,b=1,S=0;break;case 270:g=0,y=-1,b=-1,S=0;break;case 0:g=1,y=0,b=0,S=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}h&&(b=-b,S=-S);let A,_,R,x;g===0?(A=Math.abs(m-t[1])*a+c,_=Math.abs(p-t[0])*a+u,R=(t[3]-t[1])*a,x=(t[2]-t[0])*a):(A=Math.abs(p-t[0])*a+c,_=Math.abs(m-t[1])*a+u,R=(t[2]-t[0])*a,x=(t[3]-t[1])*a),this.transform=[g*a,y*a,b*a,S*a,A-g*a*p-b*a*m,_-y*a*p-S*a*m],this.width=R,this.height=x}get rawDims(){const t=this.viewBox;return zt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:i=this.rotation,offsetX:a=this.offsetX,offsetY:r=this.offsetY,dontFlip:c=!1}={}){return new Qo({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:i,offsetX:a,offsetY:r,dontFlip:c})}convertToViewportPoint(t,i){const a=[t,i];return pt.applyTransform(a,this.transform),a}convertToViewportRectangle(t){const i=[t[0],t[1]];pt.applyTransform(i,this.transform);const a=[t[2],t[3]];return pt.applyTransform(a,this.transform),[i[0],i[1],a[0],a[1]]}convertToPdfPoint(t,i){const a=[t,i];return pt.applyInverseTransform(a,this.transform),a}}class zf extends Ea{constructor(t,i=0){super(t,"RenderingCancelledException"),this.extraDelay=i}}function Su(l){const t=l.length;let i=0;for(;i<t&&l[i].trim()==="";)i++;return l.substring(i,i+5).toLowerCase()==="data:"}function Hf(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function SM(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function EM(l,t="document.pdf"){if(typeof l!="string")return t;if(Su(l))return Ct('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const a=(h=>{try{return new URL(h)}catch{try{return new URL(decodeURIComponent(h))}catch{try{return new URL(h,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(h),"https://foo.bar")}catch{return null}}}}})(l);if(!a)return t;const r=h=>{try{let p=decodeURIComponent(h);return p.includes("/")?(p=p.split("/").at(-1),p.test(/^\.pdf$/i)?p:h):p}catch{return h}},c=/\.pdf$/i,u=a.pathname.split("/").at(-1);if(c.test(u))return r(u);if(a.searchParams.size>0){const h=Array.from(a.searchParams.values()).reverse();for(const m of h)if(c.test(m))return r(m);const p=Array.from(a.searchParams.keys()).reverse();for(const m of p)if(c.test(m))return r(m)}if(a.hash){const p=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(a.hash);if(p)return r(p[0])}return t}class Yv{started=Object.create(null);times=[];time(t){t in this.started&&Ct(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Ct(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let i=0;for(const{name:a}of this.times)i=Math.max(a.length,i);for(const{name:a,start:r,end:c}of this.times)t.push(`${a.padEnd(i)} ${c-r}ms
297
297
  `);return t.join("")}}function Ko(l,t){const i=t?URL.parse(l,t):URL.parse(l);return i?.protocol==="http:"||i?.protocol==="https:"}function qn(l){l.preventDefault()}function Oe(l){l.preventDefault(),l.stopPropagation()}function AM(l){console.log("Deprecated API usage: "+l)}class Bf{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const i=this.#t.exec(t);if(!i)return null;const a=parseInt(i[1],10);let r=parseInt(i[2],10);r=r>=1&&r<=12?r-1:0;let c=parseInt(i[3],10);c=c>=1&&c<=31?c:1;let u=parseInt(i[4],10);u=u>=0&&u<=23?u:0;let h=parseInt(i[5],10);h=h>=0&&h<=59?h:0;let p=parseInt(i[6],10);p=p>=0&&p<=59?p:0;const m=i[7]||"Z";let g=parseInt(i[8],10);g=g>=0&&g<=23?g:0;let y=parseInt(i[9],10)||0;return y=y>=0&&y<=59?y:0,m==="-"?(u+=g,h+=y):m==="+"&&(u-=g,h-=y),new Date(Date.UTC(a,r,c,u,h,p))}}function _M(l,{scale:t=1,rotation:i=0}){const{width:a,height:r}=l.attributes.style,c=[0,0,parseInt(a),parseInt(r)];return new Qo({viewBox:c,userUnit:1,scale:t,rotation:i})}function Eu(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Ct(`Not a valid color format: "${l}"`),[0,0,0])}function TM(l){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const i of l.keys()){t.style.color=i;const a=window.getComputedStyle(t).color;l.set(i,Eu(a))}t.remove()}function be(l){const{a:t,b:i,c:a,d:r,e:c,f:u}=l.getTransform();return[t,i,a,r,c,u]}function xi(l){const{a:t,b:i,c:a,d:r,e:c,f:u}=l.getTransform().invertSelf();return[t,i,a,r,c,u]}function Aa(l,t,i=!1,a=!0){if(t instanceof Qo){const{pageWidth:r,pageHeight:c}=t.rawDims,{style:u}=l,h=Ve.isCSSRoundSupported,p=`var(--total-scale-factor) * ${r}px`,m=`var(--total-scale-factor) * ${c}px`,g=h?`round(down, ${p}, var(--scale-round-x))`:`calc(${p})`,y=h?`round(down, ${m}, var(--scale-round-y))`:`calc(${m})`;!i||t.rotation%180===0?(u.width=g,u.height=y):(u.width=y,u.height=g)}a&&l.setAttribute("data-main-rotation",t.rotation)}class Ci{constructor(){const{pixelRatio:t}=Ci;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,i,a,r,c=-1){let u=1/0,h=1/0,p=1/0;a=Ci.capPixels(a,c),a>0&&(u=Math.sqrt(a/(t*i))),r!==-1&&(h=r/t,p=r/i);const m=Math.min(u,h,p);return this.sx>m||this.sy>m?(this.sx=m,this.sy=m,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,i){if(i>=0){const a=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+i/100));return t>0?Math.min(t,a):a}return t}}const Ff=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Zo{#t=null;#e=null;#n;#i=null;#a=null;#s=null;#r=null;static#o=null;constructor(t){this.#n=t,Zo.#o||=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=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const i=this.#n._uiManager._signal;t.addEventListener("contextmenu",qn,{signal:i}),t.addEventListener("pointerdown",Zo.#u,{signal:i});const a=this.#i=document.createElement("div");a.className="buttons",t.append(a);const r=this.#n.toolbarPosition;if(r){const{style:c}=t,u=this.#n._uiManager.direction==="ltr"?1-r[0]:r[0];c.insetInlineEnd=`${100*u}%`,c.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#u(t){t.stopPropagation()}#c(t){this.#n._focusEventsAllowed=!1,Oe(t)}#h(t){this.#n._focusEventsAllowed=!0,Oe(t)}#l(t){const i=this.#n._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:i}),t.addEventListener("focusout",this.#h.bind(this),{capture:!0,signal:i}),t.addEventListener("contextmenu",qn,{signal:i})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#a?.shown(),this.#s?.shown()}addDeleteButton(){const{editorType:t,_uiManager:i}=this.#n,a=document.createElement("button");a.className="delete",a.tabIndex=0,a.setAttribute("data-l10n-id",Zo.#o[t]),this.#l(a),a.addEventListener("click",r=>{i.delete()},{signal:i._signal}),this.#i.append(a)}get#p(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const i=await t.render();this.#l(i),this.#i.append(i,this.#p),this.#a=t}addComment(t){if(this.#s)return;const i=t.render();i&&(this.#l(i),this.#i.prepend(i,this.#p),this.#s=t,t.toolbar=this)}addColorPicker(t){if(this.#e)return;this.#e=t;const i=t.renderButton();this.#l(i),this.#i.append(i,this.#p)}async addEditSignatureButton(t){const i=this.#r=await t.renderEditButton(this.#n);this.#l(i),this.#i.append(i,this.#p)}async addButton(t,i){switch(t){case"colorPicker":this.addColorPicker(i);break;case"altText":await this.addAltText(i);break;case"editSignature":await this.addEditSignatureButton(i);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(i);break}}updateEditSignatureButton(t){this.#r&&(this.#r.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class wM{#t=null;#e=null;#n;constructor(t){this.#n=t}#i(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",qn,{signal:this.#n._signal});const i=this.#t=document.createElement("div");return i.className="buttons",t.append(i),this.#s(),t}#a(t,i){let a=0,r=0;for(const c of t){const u=c.y+c.height;if(u<a)continue;const h=c.x+(i?c.width:0);if(u>a){r=h,a=u;continue}i?h>r&&(r=h):h<r&&(r=h)}return[i?1-r:r,a]}show(t,i,a){const[r,c]=this.#a(i,a),{style:u}=this.#e||=this.#i();t.append(this.#e),u.insetInlineEnd=`${100*r}%`,u.top=`calc(${100*c}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#s(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const i=document.createElement("span");t.append(i),i.className="visuallyHidden",i.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const a=this.#n._signal;t.addEventListener("contextmenu",qn,{signal:a}),t.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:a}),this.#t.append(t)}}function Wv(l,t,i){for(const a of i)t.addEventListener(a,l[a].bind(l))}class xM{#t=0;get id(){return`${Bv}${this.#t++}`}}class jf{#t=qv();#e=0;#n=null;static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',a=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),r=new Image;r.src=t;const c=r.decode().then(()=>(a.drawImage(r,0,0,1,1,0,0,1,3),new Uint32Array(a.getImageData(0,0,1,1).data.buffer)[0]===0));return zt(this,"_isSVGFittingCanvas",c)}async#i(t,i){this.#n||=new Map;let a=this.#n.get(t);if(a===null)return null;if(a?.bitmap)return a.refCounter+=1,a;try{a||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let r;if(typeof i=="string"?(a.url=i,r=await Wo(i,"blob")):i instanceof File?r=a.file=i:i instanceof Blob&&(r=i),r.type==="image/svg+xml"){const c=jf._isSVGFittingCanvas,u=new FileReader,h=new Image,p=new Promise((m,g)=>{h.onload=()=>{a.bitmap=h,a.isSvg=!0,m()},u.onload=async()=>{const y=a.svgUrl=u.result;h.src=await c?`${y}#svgView(preserveAspectRatio(none))`:y},h.onerror=u.onerror=g});u.readAsDataURL(r),await p}else a.bitmap=await createImageBitmap(r);a.refCounter=1}catch(r){Ct(r),a=null}return this.#n.set(t,a),a&&this.#n.set(a.id,a),a}async getFromFile(t){const{lastModified:i,name:a,size:r,type:c}=t;return this.#i(`${i}_${a}_${r}_${c}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,i){const a=await i;return this.#i(t,a)}async getFromId(t){this.#n||=new Map;const i=this.#n.get(t);if(!i)return null;if(i.bitmap)return i.refCounter+=1,i;if(i.file)return this.getFromFile(i.file);if(i.blobPromise){const{blobPromise:a}=i;return delete i.blobPromise,this.getFromBlob(i.id,a)}return this.getFromUrl(i.url)}getFromCanvas(t,i){this.#n||=new Map;let a=this.#n.get(t);if(a?.bitmap)return a.refCounter+=1,a;const r=new OffscreenCanvas(i.width,i.height);return r.getContext("2d").drawImage(i,0,0),a={bitmap:r.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#n.set(t,a),this.#n.set(a.id,a),a}getSvgUrl(t){const i=this.#n.get(t);return i?.isSvg?i.svgUrl:null}deleteId(t){this.#n||=new Map;const i=this.#n.get(t);if(!i||(i.refCounter-=1,i.refCounter!==0))return;const{bitmap:a}=i;if(!i.url&&!i.file){const r=new OffscreenCanvas(a.width,a.height);r.getContext("bitmaprenderer").transferFromImageBitmap(a),i.blobPromise=r.convertToBlob()}a.close?.(),i.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class CM{#t=[];#e=!1;#n;#i=-1;constructor(t=128){this.#n=t}add({cmd:t,undo:i,post:a,mustExec:r,type:c=NaN,overwriteIfSameType:u=!1,keepUndo:h=!1}){if(r&&t(),this.#e)return;const p={cmd:t,undo:i,post:a,type:c};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(p);return}if(u&&this.#t[this.#i].type===c){h&&(p.undo=this.#t[this.#i].undo),this.#t[this.#i]=p;return}const m=this.#i+1;m===this.#n?this.#t.splice(0,1):(this.#i=m,m<this.#t.length&&this.#t.splice(m)),this.#t.push(p)}undo(){if(this.#i===-1)return;this.#e=!0;const{undo:t,post:i}=this.#t[this.#i];t(),i?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;const{cmd:t,post:i}=this.#t[this.#i];t(),i?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let i=this.#i;i>=0;i--)if(this.#t[i].type!==t){this.#t.splice(i+1,this.#i-i),this.#i=i;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}}class Jo{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:i}=Ve.platform;for(const[a,r,c={}]of t)for(const u of a){const h=u.startsWith("mac+");i&&h?(this.callbacks.set(u.slice(4),{callback:r,options:c}),this.allKeys.add(u.split("+").at(-1))):!i&&!h&&(this.callbacks.set(u,{callback:r,options:c}),this.allKeys.add(u.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const i=this.buffer.join("+");return this.buffer.length=0,i}exec(t,i){if(!this.allKeys.has(i.key))return;const a=this.callbacks.get(this.#t(i));if(!a)return;const{callback:r,options:{bubbles:c=!1,args:u=[],checker:h=null}}=a;h&&!h(t,i)||(r.bind(t,...u,i)(),c||Oe(i))}}class $f{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return TM(t),zt(this,"_colors",t)}convert(t){const i=Eu(t);if(!window.matchMedia("(forced-colors: active)").matches)return i;for(const[a,r]of this._colors)if(r.every((c,u)=>c===i[u]))return $f._colorsMapping.get(a);return i}getHexCode(t){const i=this._colors.get(t);return i?pt.makeHexColor(...i):t}}class Ps{#t=new AbortController;#e=null;#n=new Map;#i=new Map;#a=null;#s=null;#r=null;#o=new CM;#u=null;#c=null;#h=null;#l=0;#p=new Set;#g=null;#f=null;#d=new Set;_editorUndoBar=null;#m=!1;#v=!1;#y=!1;#E=null;#A=null;#b=null;#T=null;#D=!1;#_=null;#M=new xM;#R=!1;#C=!1;#x=null;#k=null;#U=null;#N=null;#F=null;#w=xt.NONE;#S=new Set;#z=null;#H=null;#j=null;#V=null;#q={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#$=[0,0];#L=null;#I=null;#G=null;#Q=null;#P=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Ps.prototype,i=u=>u.#I.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&u.hasSomethingToControl(),a=(u,{target:h})=>{if(h instanceof HTMLInputElement){const{type:p}=h;return p!=="text"&&p!=="number"}return!0},r=this.TRANSLATE_SMALL,c=this.TRANSLATE_BIG;return zt(this,"_keyboardManager",new Jo([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:a}],[["ctrl+z","mac+meta+z"],t.undo,{checker:a}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:a}],[["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:a}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(u,{target:h})=>!(h instanceof HTMLButtonElement)&&u.#I.contains(h)&&!u.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(u,{target:h})=>!(h instanceof HTMLButtonElement)&&u.#I.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-c,0],checker:i}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[c,0],checker:i}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-c],checker:i}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,c],checker:i}]]))}constructor(t,i,a,r,c,u,h,p,m,g,y,b,S,A,_,R){const x=this._signal=this.#t.signal;this.#I=t,this.#G=i,this.#Q=a,this.#a=r,this.#u=c,this.#H=u,this._eventBus=h,h._on("editingaction",this.onEditingAction.bind(this),{signal:x}),h._on("pagechanging",this.onPageChanging.bind(this),{signal:x}),h._on("scalechanging",this.onScaleChanging.bind(this),{signal:x}),h._on("rotationchanging",this.onRotationChanging.bind(this),{signal:x}),h._on("setpreference",this.onSetPreference.bind(this),{signal:x}),h._on("switchannotationeditorparams",L=>this.updateParams(L.type,L.value),{signal:x}),this.#at(),this.#ct(),this.#Z(),this.#s=p.annotationStorage,this.#E=p.filterFactory,this.#j=m,this.#T=g||null,this.#m=y,this.#v=b,this.#y=S,this.#F=A||null,this.viewParameters={realScale:Ar.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=_||null,this._supportsPinchToZoom=R!==!1}destroy(){this.#P?.resolve(),this.#P=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#i.values())t.destroy();this.#i.clear(),this.#n.clear(),this.#d.clear(),this.#N?.clear(),this.#e=null,this.#S.clear(),this.#o.destroy(),this.#a?.destroy(),this.#u?.destroy(),this.#H?.destroy(),this.#_?.hide(),this.#_=null,this.#U?.destroy(),this.#U=null,this.#A&&(clearTimeout(this.#A),this.#A=null),this.#L&&(clearTimeout(this.#L),this.#L=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#F}get useNewAltTextFlow(){return this.#v}get useNewAltTextWhenAddingImage(){return this.#y}get hcmFilter(){return zt(this,"hcmFilter",this.#j?this.#E.addHCMFilter(this.#j.foreground,this.#j.background):"none")}get direction(){return zt(this,"direction",getComputedStyle(this.#I).direction)}get _highlightColors(){return zt(this,"_highlightColors",this.#T?new Map(this.#T.split(",").map(t=>(t=t.split("=").map(i=>i.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return zt(this,"highlightColors",null);const i=new Map,a=!!this.#j;for(const[r,c]of t){const u=r.endsWith("_HCM");if(a&&u){i.set(r.replace("_HCM",""),c);continue}!a&&!u&&i.set(r,c)}return zt(this,"highlightColors",i)}get highlightColorNames(){return zt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const i=this.highlightColorNames.get(t);return this._highlightColors.get(i)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#h=t}setMainHighlightColorPicker(t){this.#U=t}editAltText(t,i=!1){this.#a?.editAltText(this,t,i)}hasCommentManager(){return!!this.#u}editComment(t,i){this.#u?.open(this,t,i)}getSignature(t){this.#H?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#H}switchToMode(t,i){this._eventBus.on("annotationeditormodechanged",i,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,i){this._eventBus.dispatch("setpreference",{source:this,name:t,value:i})}onSetPreference({name:t,value:i}){switch(t){case"enableNewAltTextWhenAddingImage":this.#y=i;break}}onPageChanging({pageNumber:t}){this.#l=t-1}focusMainContainer(){this.#I.focus()}findParent(t,i){for(const a of this.#i.values()){const{x:r,y:c,width:u,height:h}=a.div.getBoundingClientRect();if(t>=r&&t<=r+u&&i>=c&&i<=c+h)return a}return null}disableUserSelect(t=!1){this.#G.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#d.add(t)}removeShouldRescale(t){this.#d.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Ar.PDF_TO_CSS_UNITS;for(const i of this.#d)i.onScaleChanging();this.#h?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Y({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#K(t){const{currentLayer:i}=this;if(i.hasTextLayer(t))return i;for(const a of this.#i.values())if(a.hasTextLayer(t))return a;return null}highlightSelection(t=""){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:a,anchorOffset:r,focusNode:c,focusOffset:u}=i,h=i.toString(),m=this.#Y(i).closest(".textLayer"),g=this.getSelectionBoxes(m);if(!g)return;i.empty();const y=this.#K(m),b=this.#w===xt.NONE,S=()=>{y?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:g,anchorNode:a,anchorOffset:r,focusNode:c,focusOffset:u,text:h}),b&&this.showAllEditors("highlight",!0,!0)};if(b){this.switchToMode(xt.HIGHLIGHT,S);return}S()}#it(){const t=document.getSelection();if(!t||t.isCollapsed)return;const a=this.#Y(t).closest(".textLayer"),r=this.getSelectionBoxes(a);r&&(this.#_||=new wM(this),this.#_.show(a,r,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#s&&!this.#s.has(t.id)&&this.#s.setValue(t.id,t)}a11yAlert(t,i=null){const a=this.#Q;a&&(a.setAttribute("data-l10n-id",t),i?a.setAttribute("data-l10n-args",JSON.stringify(i)):a.removeAttribute("data-l10n-args"))}#st(){const t=document.getSelection();if(!t||t.isCollapsed){this.#z&&(this.#_?.hide(),this.#z=null,this.#O({hasSelectedText:!1}));return}const{anchorNode:i}=t;if(i===this.#z)return;const r=this.#Y(t).closest(".textLayer");if(!r){this.#z&&(this.#_?.hide(),this.#z=null,this.#O({hasSelectedText:!1}));return}if(this.#_?.hide(),this.#z=i,this.#O({hasSelectedText:!0}),!(this.#w!==xt.HIGHLIGHT&&this.#w!==xt.NONE)&&(this.#w===xt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#D=this.isShiftKeyDown,!this.isShiftKeyDown)){const c=this.#w===xt.HIGHLIGHT?this.#K(r):null;c?.toggleDrawing();const u=new AbortController,h=this.combinedSignal(u),p=m=>{m.type==="pointerup"&&m.button!==0||(u.abort(),c?.toggleDrawing(!0),m.type==="pointerup"&&this.#W("main_toolbar"))};window.addEventListener("pointerup",p,{signal:h}),window.addEventListener("blur",p,{signal:h})}}#W(t=""){this.#w===xt.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#it()}#at(){document.addEventListener("selectionchange",this.#st.bind(this),{signal:this._signal})}#rt(){if(this.#b)return;this.#b=new AbortController;const t=this.combinedSignal(this.#b);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ot(){this.#b?.abort(),this.#b=null}blur(){if(this.isShiftKeyDown=!1,this.#D&&(this.#D=!1,this.#W("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const i of this.#S)if(i.div.contains(t)){this.#k=[i,t],i._focusEventsAllowed=!1;break}}focus(){if(!this.#k)return;const[t,i]=this.#k;this.#k=null,i.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),i.focus()}#Z(){if(this.#x)return;this.#x=new AbortController;const t=this.combinedSignal(this.#x);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#lt(){this.#x?.abort(),this.#x=null}#J(){if(this.#c)return;this.#c=new AbortController;const t=this.combinedSignal(this.#c);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})}#tt(){this.#c?.abort(),this.#c=null}#ct(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Z(),this.#J()}removeEditListeners(){this.#lt(),this.#tt()}dragOver(t){for(const{type:i}of t.dataTransfer.items)for(const a of this.#f)if(a.isHandlingMimeForPasting(i)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const i of t.dataTransfer.items)for(const a of this.#f)if(a.isHandlingMimeForPasting(i.type)){a.paste(i,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const i=[];for(const a of this.#S){const r=a.serialize(!0);r&&i.push(r)}i.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:i}=t;for(const c of i.items)for(const u of this.#f)if(u.isHandlingMimeForPasting(c.type)){u.paste(c,this.currentLayer);return}let a=i.getData("application/pdfjs");if(!a)return;try{a=JSON.parse(a)}catch(c){Ct(`paste: "${c.message}".`);return}if(!Array.isArray(a))return;this.unselectAll();const r=this.currentLayer;try{const c=[];for(const p of a){const m=await r.deserialize(p);if(!m)return;c.push(m)}const u=()=>{for(const p of c)this.#et(p);this.#nt(c)},h=()=>{for(const p of c)p.remove()};this.addCommands({cmd:u,undo:h,mustExec:!0})}catch(c){Ct(`paste: "${c.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#w!==xt.NONE&&!this.isEditorHandlingKeyboard&&Ps._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#D&&(this.#D=!1,this.#W("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}}#O(t){Object.entries(t).some(([a,r])=>this.#q[a]!==r)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#q,t)}),this.#w===xt.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[$t.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#J(),this.#O({isEditing:this.#w!==xt.NONE,isEmpty:this.#X(),hasSomethingToUndo:this.#o.hasSomethingToUndo(),hasSomethingToRedo:this.#o.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ot(),this.#tt(),this.#O({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#f){this.#f=t;for(const i of this.#f)this.#B(i.defaultPropertiesToUpdate)}}getId(){return this.#M.id}get currentLayer(){return this.#i.get(this.#l)}getLayer(t){return this.#i.get(t)}get currentPageIndex(){return this.#l}addLayer(t){this.#i.set(t.pageIndex,t),this.#R?t.enable():t.disable()}removeLayer(t){this.#i.delete(t.pageIndex)}async updateMode(t,i=null,a=!1,r=!1,c=!1){if(this.#w!==t&&!(this.#P&&(await this.#P.promise,!this.#P))){if(this.#P=Promise.withResolvers(),this.#h?.commitOrRemove(),this.#w=t,t===xt.NONE){this.setEditingState(!1),this.#dt(),this._editorUndoBar?.hide(),this.#P.resolve();return}t===xt.SIGNATURE&&await this.#H?.loadSignatures(),this.setEditingState(!0),await this.#ut(),this.unselectAll();for(const u of this.#i.values())u.updateMode(t);if(!i){a&&this.addNewEditorFromKeyboard(),this.#P.resolve();return}for(const u of this.#n.values())u.annotationElementId===i||u.id===i?(this.setSelected(u),c?u.editComment():r&&u.enterInEditMode()):u.unselect();this.#P.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#w&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,i){if(this.#f){switch(t){case $t.CREATE:this.currentLayer.addNewEditor(i);return;case $t.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#V||=new Map).set(t,i),this.showAllEditors("highlight",i);break}if(this.hasSelection)for(const a of this.#S)a.updateParams(t,i);else for(const a of this.#f)a.updateDefaultParams(t,i)}}showAllEditors(t,i,a=!1){for(const c of this.#n.values())c.editorType===t&&c.show(i);(this.#V?.get($t.HIGHLIGHT_SHOW_ALL)??!0)!==i&&this.#B([[$t.HIGHLIGHT_SHOW_ALL,i]])}enableWaiting(t=!1){if(this.#C!==t){this.#C=t;for(const i of this.#i.values())t?i.disableClick():i.enableClick(),i.div.classList.toggle("waiting",t)}}async#ut(){if(!this.#R){this.#R=!0;const t=[];for(const i of this.#i.values())t.push(i.enable());await Promise.all(t);for(const i of this.#n.values())i.enable()}}#dt(){if(this.unselectAll(),this.#R){this.#R=!1;for(const t of this.#i.values())t.disable();for(const t of this.#n.values())t.disable()}}getEditors(t){const i=[];for(const a of this.#n.values())a.pageIndex===t&&i.push(a);return i}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#A&&clearTimeout(this.#A),this.#A=setTimeout(()=>{this.focusMainContainer(),this.#A=null},0)),this.#n.delete(t.id),t.annotationElementId&&this.#N?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#p.has(t.annotationElementId))&&this.#s?.remove(t.id)}addDeletedAnnotationElement(t){this.#p.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#p.has(t)}removeDeletedAnnotationElement(t){this.#p.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#et(t){const i=this.#i.get(t.pageIndex);i?i.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#ht(){let t=null;for(t of this.#S);return t}updateUI(t){this.#ht===t&&this.#B(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#B(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#S.has(t)){this.#S.delete(t),t.unselect(),this.#O({hasSelectedEditor:this.hasSelection});return}this.#S.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#O({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.id}),this.#h?.commitOrRemove();for(const i of this.#S)i!==t&&i.unselect();this.#S.clear(),this.#S.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#O({hasSelectedEditor:!0})}isSelected(t){return this.#S.has(t)}get firstSelectedEditor(){return this.#S.values().next().value}unselect(t){t.unselect(),this.#S.delete(t),this.#O({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#S.size!==0}get isEnterHandled(){return this.#S.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#o.undo(),this.#O({hasSomethingToUndo:this.#o.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#X()}),this._editorUndoBar?.hide()}redo(){this.#o.redo(),this.#O({hasSomethingToUndo:!0,hasSomethingToRedo:this.#o.hasSomethingToRedo(),isEmpty:this.#X()})}addCommands(t){this.#o.add(t),this.#O({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#X()})}cleanUndoStack(t){this.#o.cleanType(t)}#X(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(const t of this.#n.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const i=t?[t]:[...this.#S],a=()=>{this._editorUndoBar?.show(r,i.length===1?i[0].editorType:i.length);for(const c of i)c.remove()},r=()=>{for(const c of i)this.#et(c)};this.addCommands({cmd:a,undo:r,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#nt(t){for(const i of this.#S)i.unselect();this.#S.clear();for(const i of t)i.isEmpty()||(this.#S.add(i),i.select());this.#O({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#S)t.commit();this.#nt(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#w!==xt.NONE))&&!this.#h?.commitOrRemove()&&this.hasSelection){for(const t of this.#S)t.unselect();this.#S.clear(),this.#O({hasSelectedEditor:!1})}}translateSelectedEditors(t,i,a=!1){if(a||this.commitOrRemove(),!this.hasSelection)return;this.#$[0]+=t,this.#$[1]+=i;const[r,c]=this.#$,u=[...this.#S],h=1e3;this.#L&&clearTimeout(this.#L),this.#L=setTimeout(()=>{this.#L=null,this.#$[0]=this.#$[1]=0,this.addCommands({cmd:()=>{for(const p of u)this.#n.has(p.id)&&(p.translateInPage(r,c),p.translationDone())},undo:()=>{for(const p of u)this.#n.has(p.id)&&(p.translateInPage(-r,-c),p.translationDone())},mustExec:!1})},h);for(const p of u)p.translateInPage(t,i),p.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#g=new Map;for(const t of this.#S)this.#g.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#g)return!1;this.disableUserSelect(!1);const t=this.#g;this.#g=null;let i=!1;for(const[{x:r,y:c,pageIndex:u},h]of t)h.newX=r,h.newY=c,h.newPageIndex=u,i||=r!==h.savedX||c!==h.savedY||u!==h.savedPageIndex;if(!i)return!1;const a=(r,c,u,h)=>{if(this.#n.has(r.id)){const p=this.#i.get(h);p?r._setParentAndPosition(p,c,u):(r.pageIndex=h,r.x=c,r.y=u)}};return this.addCommands({cmd:()=>{for(const[r,{newX:c,newY:u,newPageIndex:h}]of t)a(r,c,u,h)},undo:()=>{for(const[r,{savedX:c,savedY:u,savedPageIndex:h}]of t)a(r,c,u,h)},mustExec:!0}),!0}dragSelectedEditors(t,i){if(this.#g)for(const a of this.#g.keys())a.drag(t,i)}rebuild(t){if(t.parent===null){const i=this.getLayer(t.pageIndex);i?(i.changeParent(t),i.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#S.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#w}get imageManager(){return zt(this,"imageManager",new jf)}getSelectionBoxes(t){if(!t)return null;const i=document.getSelection();for(let m=0,g=i.rangeCount;m<g;m++)if(!t.contains(i.getRangeAt(m).commonAncestorContainer))return null;const{x:a,y:r,width:c,height:u}=t.getBoundingClientRect();let h;switch(t.getAttribute("data-main-rotation")){case"90":h=(m,g,y,b)=>({x:(g-r)/u,y:1-(m+y-a)/c,width:b/u,height:y/c});break;case"180":h=(m,g,y,b)=>({x:1-(m+y-a)/c,y:1-(g+b-r)/u,width:y/c,height:b/u});break;case"270":h=(m,g,y,b)=>({x:1-(g+b-r)/u,y:(m-a)/c,width:b/u,height:y/c});break;default:h=(m,g,y,b)=>({x:(m-a)/c,y:(g-r)/u,width:y/c,height:b/u});break}const p=[];for(let m=0,g=i.rangeCount;m<g;m++){const y=i.getRangeAt(m);if(!y.collapsed)for(const{x:b,y:S,width:A,height:_}of y.getClientRects())A===0||_===0||p.push(h(b,S,A,_))}return p.length===0?null:p}addChangedExistingAnnotation({annotationElementId:t,id:i}){(this.#r||=new Map).set(t,i)}removeChangedExistingAnnotation({annotationElementId:t}){this.#r?.delete(t)}renderAnnotationElement(t){const i=this.#r?.get(t.data.id);if(!i)return;const a=this.#s.getRawValue(i);a&&(this.#w===xt.NONE&&!a.hasBeenModified||a.renderAnnotationElement(t))}setMissingCanvas(t,i,a){const r=this.#N?.get(t);r&&(r.setCanvas(i,a),this.#N.delete(t))}addMissingCanvas(t,i){(this.#N||=new Map).set(t,i)}}class Ri{#t=null;#e=!1;#n=null;#i=null;#a=null;#s=null;#r=!1;#o=null;#u=null;#c=null;#h=null;#l=!1;static#p=null;static _l10n=null;constructor(t){this.#u=t,this.#l=t._uiManager.useNewAltTextFlow,Ri.#p||=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){Ri._l10n??=t}async render(){const t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";const i=this.#i=document.createElement("span");t.append(i),this.#l?(t.classList.add("new"),t.setAttribute("data-l10n-id",Ri.#p.missing),i.setAttribute("data-l10n-id",Ri.#p["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const a=this.#u._uiManager._signal;t.addEventListener("contextmenu",qn,{signal:a}),t.addEventListener("pointerdown",c=>c.stopPropagation(),{signal:a});const r=c=>{c.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#l&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",r,{capture:!0,signal:a}),t.addEventListener("keydown",c=>{c.target===t&&c.key==="Enter"&&(this.#r=!0,r(c))},{signal:a}),await this.#f(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#l?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#l?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#h=await Ri._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#f())}toggleAltTextBadge(t=!1){if(!this.#l||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const i=this.#o=document.createElement("div");i.className="noAltTextBadge",this.#u.div.append(i)}this.#o.classList.toggle("hidden",!t)}serialize(t){let i=this.#t;return!t&&this.#c===i&&(i=this.#h),{altText:i,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#h}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:i,guessedText:a,textWithDisclaimer:r,cancel:c=!1}){a&&(this.#c=a,this.#h=r),!(this.#t===t&&this.#e===i)&&(c||(this.#t=t,this.#e=i),this.#f())}toggle(t=!1){this.#n&&(!t&&this.#s&&(clearTimeout(this.#s),this.#s=null),this.#n.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#n?.remove(),this.#n=null,this.#i=null,this.#a=null,this.#o?.remove(),this.#o=null}async#f(){const t=this.#n;if(!t)return;if(this.#l){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Ri.#p[this.#g]),this.#i?.setAttribute("data-l10n-id",Ri.#p[`${this.#g}-label`]),!this.#t){this.#a?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#a?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=this.#a;if(!i){this.#a=i=document.createElement("span"),i.className="tooltip",i.setAttribute("role","tooltip"),i.id=`alt-text-tooltip-${this.#u.id}`;const r=100,c=this.#u._uiManager._signal;c.addEventListener("abort",()=>{clearTimeout(this.#s),this.#s=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#s=setTimeout(()=>{this.#s=null,this.#a.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},r)},{signal:c}),t.addEventListener("mouseleave",()=>{this.#s&&(clearTimeout(this.#s),this.#s=null),this.#a?.classList.remove("show")},{signal:c})}this.#e?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=this.#t),i.parentNode||t.append(i),this.#u.getElementForAltText()?.setAttribute("aria-describedby",i.id)}}class Au{#t=null;#e=!1;#n=null;#i=null;#a=null;#s=null;#r=!1;constructor(t){this.#n=t,this.toolbar=null}render(){if(!this.#n._uiManager.hasCommentManager())return null;const t=this.#t=document.createElement("button");t.className="comment",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const i=this.#n._uiManager._signal;t.addEventListener("contextmenu",qn,{signal:i}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:i});const a=r=>{r.preventDefault(),this.edit()};return t.addEventListener("click",a,{capture:!0,signal:i}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(this.#e=!0,a(r))},{signal:i}),t}edit(){const{bottom:t,left:i,right:a}=this.#n.getClientDimensions(),r={top:t};this.#n._uiManager.direction==="ltr"?r.right=a:r.left=i,this.#n._uiManager.editComment(this.#n,r)}finish(){this.#t&&(this.#t.focus({focusVisible:this.#e}),this.#e=!1)}isDeleted(){return this.#r||this.#a===""}hasBeenEdited(){return this.isDeleted()||this.#a!==this.#i}serialize(){return this.data}get data(){return{text:this.#a,date:this.#s,deleted:this.#r}}set data(t){if(t===null){this.#a="",this.#r=!0;return}this.#a=t,this.#s=new Date,this.#r=!1}setInitialText(t){this.#i=t,this.data=t}toggle(t=!1){this.#t&&(this.#t.disabled=!t)}shown(){}destroy(){this.#t?.remove(),this.#t=null,this.#a="",this.#s=null,this.#n=null,this.#e=!1,this.#r=!1}}class _u{#t;#e=!1;#n=null;#i;#a;#s;#r;#o=null;#u;#c=null;#h;#l=null;constructor({container:t,isPinchingDisabled:i=null,isPinchingStopped:a=null,onPinchStart:r=null,onPinching:c=null,onPinchEnd:u=null,signal:h}){this.#t=t,this.#n=a,this.#i=i,this.#a=r,this.#s=c,this.#r=u,this.#h=new AbortController,this.#u=AbortSignal.any([h,this.#h.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ci.pixelRatio}#p(t){if(this.#i?.())return;if(t.touches.length===1){if(this.#o)return;const r=this.#o=new AbortController,c=AbortSignal.any([this.#u,r.signal]),u=this.#t,h={capture:!0,signal:c,passive:!1},p=m=>{m.pointerType==="touch"&&(this.#o?.abort(),this.#o=null)};u.addEventListener("pointerdown",m=>{m.pointerType==="touch"&&(Oe(m),p(m))},h),u.addEventListener("pointerup",p,h),u.addEventListener("pointercancel",p,h);return}if(!this.#l){this.#l=new AbortController;const r=AbortSignal.any([this.#u,this.#l.signal]),c=this.#t,u={signal:r,capture:!1,passive:!1};c.addEventListener("touchmove",this.#g.bind(this),u);const h=this.#f.bind(this);c.addEventListener("touchend",h,u),c.addEventListener("touchcancel",h,u),u.capture=!0,c.addEventListener("pointerdown",Oe,u),c.addEventListener("pointermove",Oe,u),c.addEventListener("pointercancel",Oe,u),c.addEventListener("pointerup",Oe,u),this.#a?.()}if(Oe(t),t.touches.length!==2||this.#n?.()){this.#c=null;return}let[i,a]=t.touches;i.identifier>a.identifier&&([i,a]=[a,i]),this.#c={touch0X:i.screenX,touch0Y:i.screenY,touch1X:a.screenX,touch1Y:a.screenY}}#g(t){if(!this.#c||t.touches.length!==2)return;Oe(t);let[i,a]=t.touches;i.identifier>a.identifier&&([i,a]=[a,i]);const{screenX:r,screenY:c}=i,{screenX:u,screenY:h}=a,p=this.#c,{touch0X:m,touch0Y:g,touch1X:y,touch1Y:b}=p,S=y-m,A=b-g,_=u-r,R=h-c,x=Math.hypot(_,R)||1,L=Math.hypot(S,A)||1;if(!this.#e&&Math.abs(L-x)<=_u.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(p.touch0X=r,p.touch0Y=c,p.touch1X=u,p.touch1Y=h,!this.#e){this.#e=!0;return}const k=[(r+u)/2,(c+h)/2];this.#s?.(k,L,x)}#f(t){t.touches.length>=2||(this.#l&&(this.#l.abort(),this.#l=null,this.#r?.()),this.#c&&(Oe(t),this.#c=null,this.#e=!1))}destroy(){this.#h?.abort(),this.#h=null,this.#o?.abort(),this.#o=null}}class gt{#t=null;#e=null;#n=null;#i=null;#a=!1;#s=null;#r="";#o=!1;#u=null;#c=null;#h=null;#l=null;#p="";#g=!1;#f=null;#d=!1;#m=!1;#v=!1;#y=null;#E=0;#A=0;#b=null;#T=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#D=!1;#_=gt._zIndex++;static _borderLineWidth=-1;static _colorManager=new $f;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=gt.prototype._resizeWithKeyboard,i=Ps.TRANSLATE_SMALL,a=Ps.TRANSLATE_BIG;return zt(this,"_resizerKeyboardManager",new Jo([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-i,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-a,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[i,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[a,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-i]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-a]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,i]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,a]}],[["Escape","mac+Escape"],gt.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null;const{rotation:i,rawDims:{pageWidth:a,pageHeight:r,pageX:c,pageY:u}}=this.parent.viewport;this.rotation=i,this.pageRotation=(360+i-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[a,r],this.pageTranslation=[c,u];const[h,p]=this.parentDimensions;this.x=t.x/h,this.y=t.y/p,this.isAttachedToDOM=!1,this.deleted=!1}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 zt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const i=new RM({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});i.annotationElementId=t.annotationElementId,i.deleted=!0,i._uiManager.addToAnnotationStorage(i)}static initialize(t,i){if(gt._l10n??=t,gt._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"}),gt._borderLineWidth!==-1)return;const a=getComputedStyle(document.documentElement);gt._borderLineWidth=parseFloat(a.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,i){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,i){se("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#D}set _isDraggable(t){this.#D=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,i]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*i/(t*2),this.y+=this.width*t/(i*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*i/(t*2),this.y-=this.width*t/(i*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=this.#_}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#G(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#g?this.#g=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,i,a,r){const[c,u]=this.parentDimensions;[a,r]=this.screenToPageTranslation(a,r),this.x=(t+a)/c,this.y=(i+r)/u,this.fixAndSetPosition()}_moveAfterPaste(t,i){const[a,r]=this.parentDimensions;this.setAt(t*a,i*r,this.width*a,this.height*r),this._onTranslated()}#M([t,i],a,r){[a,r]=this.screenToPageTranslation(a,r),this.x+=a/t,this.y+=r/i,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,i){this.#M(this.parentDimensions,t,i)}translateInPage(t,i){this.#f||=[this.x,this.y,this.width,this.height],this.#M(this.pageDimensions,t,i),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,i){this.#f||=[this.x,this.y,this.width,this.height];const{div:a,parentDimensions:[r,c]}=this;if(this.x+=t/r,this.y+=i/c,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:y,y:b}=this.div.getBoundingClientRect();this.parent.findNewParent(this,y,b)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:u,y:h}=this;const[p,m]=this.getBaseTranslation();u+=p,h+=m;const{style:g}=a;g.left=`${(100*u).toFixed(2)}%`,g.top=`${(100*h).toFixed(2)}%`,this._onTranslating(u,h),a.scrollIntoView({block:"nearest"})}_onTranslating(t,i){}_onTranslated(t,i){}get _hasBeenMoved(){return!!this.#f&&(this.#f[0]!==this.x||this.#f[1]!==this.y)}get _hasBeenResized(){return!!this.#f&&(this.#f[2]!==this.width||this.#f[3]!==this.height)}getBaseTranslation(){const[t,i]=this.parentDimensions,{_borderLineWidth:a}=gt,r=a/t,c=a/i;switch(this.rotation){case 90:return[-r,c];case 180:return[r,c];case 270:return[r,-c];default:return[-r,-c]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:i},pageDimensions:[a,r]}=this;let{x:c,y:u,width:h,height:p}=this;if(h*=a,p*=r,c*=a,u*=r,this._mustFixPosition)switch(t){case 0:c=dn(c,0,a-h),u=dn(u,0,r-p);break;case 90:c=dn(c,0,a-p),u=dn(u,h,r);break;case 180:c=dn(c,h,a),u=dn(u,p,r);break;case 270:c=dn(c,p,a),u=dn(u,0,r-h);break}this.x=c/=a,this.y=u/=r;const[m,g]=this.getBaseTranslation();c+=m,u+=g,i.left=`${(100*c).toFixed(2)}%`,i.top=`${(100*u).toFixed(2)}%`,this.moveInDOM()}static#R(t,i,a){switch(a){case 90:return[i,-t];case 180:return[-t,-i];case 270:return[-i,t];default:return[t,i]}}screenToPageTranslation(t,i){return gt.#R(t,i,this.parentRotation)}pageTranslationToScreen(t,i){return gt.#R(t,i,360-this.parentRotation)}#C(t){switch(t){case 90:{const[i,a]=this.pageDimensions;return[0,-i/a,a/i,0]}case 180:return[-1,0,0,-1];case 270:{const[i,a]=this.pageDimensions;return[0,i/a,-a/i,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[i,a]}=this;return[i*t,a*t]}setDims(t,i){const[a,r]=this.parentDimensions,{style:c}=this.div;c.width=`${(100*t/a).toFixed(2)}%`,this.#o||(c.height=`${(100*i/r).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:i,width:a}=t,r=a.endsWith("%"),c=!this.#o&&i.endsWith("%");if(r&&c)return;const[u,h]=this.parentDimensions;r||(t.width=`${(100*parseFloat(a)/u).toFixed(2)}%`),!this.#o&&!c&&(t.height=`${(100*parseFloat(i)/h).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#x(){if(this.#u)return;this.#u=document.createElement("div"),this.#u.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],i=this._uiManager._signal;for(const a of t){const r=document.createElement("div");this.#u.append(r),r.classList.add("resizer",a),r.setAttribute("data-resizer-name",a),r.addEventListener("pointerdown",this.#k.bind(this,a),{signal:i}),r.addEventListener("contextmenu",qn,{signal:i}),r.tabIndex=-1}this.div.prepend(this.#u)}#k(t,i){i.preventDefault();const{isMac:a}=Ve.platform;if(i.button!==0||i.ctrlKey&&a)return;this.#n?.toggle(!1);const r=this._isDraggable;this._isDraggable=!1,this.#c=[i.screenX,i.screenY];const c=new AbortController,u=this._uiManager.combinedSignal(c);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#F.bind(this,t),{passive:!0,capture:!0,signal:u}),window.addEventListener("touchmove",Oe,{passive:!1,signal:u}),window.addEventListener("contextmenu",qn,{signal:u}),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const h=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(i.target).cursor;const m=()=>{c.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=h,this.div.style.cursor=p,this.#N()};window.addEventListener("pointerup",m,{signal:u}),window.addEventListener("blur",m,{signal:u})}#U(t,i,a,r){this.width=a,this.height=r,this.x=t,this.y=i;const[c,u]=this.parentDimensions;this.setDims(c*a,u*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#N(){if(!this.#h)return;const{savedX:t,savedY:i,savedWidth:a,savedHeight:r}=this.#h;this.#h=null;const c=this.x,u=this.y,h=this.width,p=this.height;c===t&&u===i&&h===a&&p===r||this.addCommands({cmd:this.#U.bind(this,c,u,h,p),undo:this.#U.bind(this,t,i,a,r),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#F(t,i){const[a,r]=this.parentDimensions,c=this.x,u=this.y,h=this.width,p=this.height,m=gt.MIN_SIZE/a,g=gt.MIN_SIZE/r,y=this.#C(this.rotation),b=(B,K)=>[y[0]*B+y[2]*K,y[1]*B+y[3]*K],S=this.#C(360-this.rotation),A=(B,K)=>[S[0]*B+S[2]*K,S[1]*B+S[3]*K];let _,R,x=!1,L=!1;switch(t){case"topLeft":x=!0,_=(B,K)=>[0,0],R=(B,K)=>[B,K];break;case"topMiddle":_=(B,K)=>[B/2,0],R=(B,K)=>[B/2,K];break;case"topRight":x=!0,_=(B,K)=>[B,0],R=(B,K)=>[0,K];break;case"middleRight":L=!0,_=(B,K)=>[B,K/2],R=(B,K)=>[0,K/2];break;case"bottomRight":x=!0,_=(B,K)=>[B,K],R=(B,K)=>[0,0];break;case"bottomMiddle":_=(B,K)=>[B/2,K],R=(B,K)=>[B/2,0];break;case"bottomLeft":x=!0,_=(B,K)=>[0,K],R=(B,K)=>[B,0];break;case"middleLeft":L=!0,_=(B,K)=>[0,K/2],R=(B,K)=>[B,K/2];break}const k=_(h,p),U=R(h,p);let P=b(...U);const j=gt._round(c+P[0]),F=gt._round(u+P[1]);let tt=1,Y=1,st,Z;if(i.fromKeyboard)({deltaX:st,deltaY:Z}=i);else{const{screenX:B,screenY:K}=i,[ut,wt]=this.#c;[st,Z]=this.screenToPageTranslation(B-ut,K-wt),this.#c[0]=B,this.#c[1]=K}if([st,Z]=A(st/a,Z/r),x){const B=Math.hypot(h,p);tt=Y=Math.max(Math.min(Math.hypot(U[0]-k[0]-st,U[1]-k[1]-Z)/B,1/h,1/p),m/h,g/p)}else L?tt=dn(Math.abs(U[0]-k[0]-st),m,1)/h:Y=dn(Math.abs(U[1]-k[1]-Z),g,1)/p;const ot=gt._round(h*tt),St=gt._round(p*Y);P=b(...R(ot,St));const yt=j-P[0],Gt=F-P[1];this.#f||=[this.x,this.y,this.width,this.height],this.width=ot,this.height=St,this.x=yt,this.y=Gt,this.setDims(a*ot,r*St),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#m)return this._editToolbar;this._editToolbar=new Zo(this),this.div.append(this._editToolbar.render()),this._editToolbar.addButton("comment",this.addCommentButton());const{toolbarButtons:t}=this;if(t)for(const[i,a]of t)await this._editToolbar.addButton(i,a);return this._editToolbar.addButton("delete"),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(t){const i=this._editToolbar?.div;i?i.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#n||(Ri.initialize(gt._l10n),this.#n=new Ri(this),this.#t&&(this.#n.data=this.#t,this.#t=null)),this.#n}get altTextData(){return this.#n?.data}set altTextData(t){this.#n&&(this.#n.data=t)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(t){await this.#n?.setGuessedText(t)}serializeAltText(t){return this.#n?.serialize(t)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}addCommentButton(){return this.#i?this.#i:this.#i=new Au(this)}get commentColor(){return null}get comment(){const t=this.#i;return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){this.#i||(this.#i=new Au(this)),this.#i.data=t}setCommentData(t){this.#i||(this.#i=new Au(this)),this.#i.setInitialText(t)}get hasEditedComment(){return this.#i?.hasBeenEdited()}async editComment(){this.#i||(this.#i=new Au(this)),this.#i.edit()}addComment(t){this.hasEditedComment&&(t.popup={contents:this.comment.text,deleted:this.comment.deleted})}render(){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=this.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#V();const[i,a]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*a/i).toFixed(2)}%`,t.style.maxHeight=`${(100*i/a).toFixed(2)}%`);const[r,c]=this.getInitialTranslation();return this.translate(r,c),Wv(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new _u({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#w.bind(this),onPinching:this.#S.bind(this),onPinchEnd:this.#z.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),t}#w(){this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#S(t,i,a){let c=.7*(a/i)+1-.7;if(c===1)return;const u=this.#C(this.rotation),h=(j,F)=>[u[0]*j+u[2]*F,u[1]*j+u[3]*F],[p,m]=this.parentDimensions,g=this.x,y=this.y,b=this.width,S=this.height,A=gt.MIN_SIZE/p,_=gt.MIN_SIZE/m;c=Math.max(Math.min(c,1/b,1/S),A/b,_/S);const R=gt._round(b*c),x=gt._round(S*c);if(R===b&&x===S)return;this.#f||=[g,y,b,S];const L=h(b/2,S/2),k=gt._round(g+L[0]),U=gt._round(y+L[1]),P=h(R/2,x/2);this.x=k-P[0],this.y=U-P[1],this.width=R,this.height=x,this.setDims(p*R,m*x),this.fixAndSetPosition(),this._onResizing()}#z(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#N()}pointerdown(t){const{isMac:i}=Ve.platform;if(t.button!==0||t.ctrlKey&&i){t.preventDefault();return}if(this.#g=!0,this._isDraggable){this.#j(t);return}this.#H(t)}#H(t){const{isMac:i}=Ve.platform;t.ctrlKey&&!i||t.shiftKey||t.metaKey&&i?this.parent.toggleSelected(this):this.parent.setSelected(this)}#j(t){const{isSelected:i}=this;this._uiManager.setUpDragSession();let a=!1;const r=new AbortController,c=this._uiManager.combinedSignal(r),u={capture:!0,passive:!1,signal:c},h=m=>{r.abort(),this.#s=null,this.#g=!1,this._uiManager.endDragSession()||this.#H(m),a&&this._onStopDragging()};i&&(this.#E=t.clientX,this.#A=t.clientY,this.#s=t.pointerId,this.#r=t.pointerType,window.addEventListener("pointermove",m=>{a||(a=!0,this._onStartDragging());const{clientX:g,clientY:y,pointerId:b}=m;if(b!==this.#s){Oe(m);return}const[S,A]=this.screenToPageTranslation(g-this.#E,y-this.#A);this.#E=g,this.#A=y,this._uiManager.dragSelectedEditors(S,A)},u),window.addEventListener("touchmove",Oe,u),window.addEventListener("pointerdown",m=>{m.pointerType===this.#r&&(this.#T||m.isPrimary)&&h(m),Oe(m)},u));const p=m=>{if(!this.#s||this.#s===m.pointerId){h(m);return}Oe(m)};window.addEventListener("pointerup",p,{signal:c}),window.addEventListener("blur",p,{signal:c})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,i,a){t.changeParent(this),this.x=i,this.y=a,this.fixAndSetPosition(),this._onTranslated()}getRect(t,i,a=this.rotation){const r=this.parentScale,[c,u]=this.pageDimensions,[h,p]=this.pageTranslation,m=t/r,g=i/r,y=this.x*c,b=this.y*u,S=this.width*c,A=this.height*u;switch(a){case 0:return[y+m+h,u-b-g-A+p,y+m+S+h,u-b-g+p];case 90:return[y+g+h,u-b+m+p,y+g+A+h,u-b+m+S+p];case 180:return[y-m-S+h,u-b+g+p,y-m+h,u-b+g+A+p];case 270:return[y-g-A+h,u-b-m-S+p,y-g+h,u-b-m+p];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,i){const[a,r,c,u]=t,h=c-a,p=u-r;switch(this.rotation){case 0:return[a,i-u,h,p];case 90:return[a,i-r,p,h];case 180:return[c,i-r,h,p];case 270:return[c,i-u,p,h];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#m=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#m=!1,!0):!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#v}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:i,bottom:a,right:r}=this.getClientDimensions(),{innerHeight:c,innerWidth:u}=window;return i<u&&r>0&&t<c&&a>0}#V(){if(this.#l||!this.div)return;this.#l=new AbortController;const t=this._uiManager.combinedSignal(this.#l);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#V()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,i=null){se("An editor must be serializable")}static async deserialize(t,i,a){const r=new this.prototype.constructor({parent:i,id:i.getNextId(),uiManager:a,annotationElementId:t.annotationElementId});r.rotation=t.rotation,r.#t=t.accessibilityData,r._isCopy=t.isCopy||!1;const[c,u]=r.pageDimensions,[h,p,m,g]=r.getRectInCurrentCoords(t.rect,u);return r.x=h/c,r.y=p/u,r.width=m/c,r.height=g/u,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#l?.abort(),this.#l=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#y&&(clearTimeout(this.#y),this.#y=null),this.#G(),this.removeEditToolbar(),this.#b){for(const t of this.#b.values())clearTimeout(t);this.#b=null}this.parent=null,this.#T?.destroy(),this.#T=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#x(),this.#u.classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const i=this.#u.children;if(!this.#e){this.#e=Array.from(i);const u=this.#q.bind(this),h=this.#$.bind(this),p=this._uiManager._signal;for(const m of this.#e){const g=m.getAttribute("data-resizer-name");m.setAttribute("role","spinbutton"),m.addEventListener("keydown",u,{signal:p}),m.addEventListener("blur",h,{signal:p}),m.addEventListener("focus",this.#L.bind(this,g),{signal:p}),m.setAttribute("data-l10n-id",gt._l10nResizer[g])}}const a=this.#e[0];let r=0;for(const u of i){if(u===a)break;r++}const c=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(c!==r){if(c<r)for(let h=0;h<r-c;h++)this.#u.append(this.#u.firstChild);else if(c>r)for(let h=0;h<c-r;h++)this.#u.firstChild.before(this.#u.lastChild);let u=0;for(const h of i){const m=this.#e[u++].getAttribute("data-resizer-name");h.setAttribute("data-l10n-id",gt._l10nResizer[m])}}this.#I(0),this.#v=!0,this.#u.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#q(t){gt._resizerKeyboardManager.exec(this,t)}#$(t){this.#v&&t.relatedTarget?.parentNode!==this.#u&&this.#G()}#L(t){this.#p=this.#v?t:""}#I(t){if(this.#e)for(const i of this.#e)i.tabIndex=t}_resizeWithKeyboard(t,i){this.#v&&this.#F(this.#p,{deltaX:t,deltaY:i,fromKeyboard:!0})}#G(){this.#v=!1,this.#I(-1),this.#N()}_stopResizingWithKeyboard(){this.#G(),this.div.focus()}select(){if(!(this.isSelected&&this._editToolbar)){if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}}unselect(){this.isSelected&&(this.isSelected=!1,this.#u?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0))}updateParams(t,i){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#d}set isEditing(t){this.#d=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,i){this.#o=!0;const a=t/i,{style:r}=this.div;r.aspectRatio=a,r.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,i=!1){if(i){this.#b||=new Map;const{action:a}=t;let r=this.#b.get(a);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#b.delete(a),this.#b.size===0&&(this.#b=null)},gt._telemetryTimeout),this.#b.set(a,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}renderAnnotationElement(t){let i=t.container.querySelector(".annotationContent");if(!i)i=document.createElement("div"),i.classList.add("annotationContent",this.editorType),t.container.prepend(i);else if(i.nodeName==="CANVAS"){const a=i;i=document.createElement("div"),i.classList.add("annotationContent",this.editorType),a.before(i)}return i}resetAnnotationElement(t){const{firstChild:i}=t.container;i?.nodeName==="DIV"&&i.classList.contains("annotationContent")&&i.remove()}}class RM extends gt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Qv=3285377520,Xn=4294901760,Di=65535;class Kv{constructor(t){this.h1=t?t&4294967295:Qv,this.h2=t?t&4294967295:Qv}update(t){let i,a;if(typeof t=="string"){i=new Uint8Array(t.length*2),a=0;for(let _=0,R=t.length;_<R;_++){const x=t.charCodeAt(_);x<=255?i[a++]=x:(i[a++]=x>>>8,i[a++]=x&255)}}else if(ArrayBuffer.isView(t))i=t.slice(),a=i.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const r=a>>2,c=a-r*4,u=new Uint32Array(i.buffer,0,r);let h=0,p=0,m=this.h1,g=this.h2;const y=3432918353,b=461845907,S=y&Di,A=b&Di;for(let _=0;_<r;_++)_&1?(h=u[_],h=h*y&Xn|h*S&Di,h=h<<15|h>>>17,h=h*b&Xn|h*A&Di,m^=h,m=m<<13|m>>>19,m=m*5+3864292196):(p=u[_],p=p*y&Xn|p*S&Di,p=p<<15|p>>>17,p=p*b&Xn|p*A&Di,g^=p,g=g<<13|g>>>19,g=g*5+3864292196);switch(h=0,c){case 3:h^=i[r*4+2]<<16;case 2:h^=i[r*4+1]<<8;case 1:h^=i[r*4],h=h*y&Xn|h*S&Di,h=h<<15|h>>>17,h=h*b&Xn|h*A&Di,r&1?m^=h:g^=h}this.h1=m,this.h2=g}hexdigest(){let t=this.h1,i=this.h2;return t^=i>>>1,t=t*3981806797&Xn|t*36045&Di,i=i*4283543511&Xn|((i<<16|t>>>16)*2950163797&Xn)>>>16,t^=i>>>1,t=t*444984403&Xn|t*60499&Di,i=i*3301882366&Xn|((i<<16|t>>>16)*3120437893&Xn)>>>16,t^=i>>>1,(t>>>0).toString(16).padStart(8,"0")+(i>>>0).toString(16).padStart(8,"0")}}const Gf=Object.freeze({map:null,hash:"",transfer:void 0});class Vf{#t=!1;#e=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,i){const a=this.#n.get(t);return a===void 0?i:Object.assign(i,a)}getRawValue(t){return this.#n.get(t)}remove(t){if(this.#n.delete(t),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const i of this.#n.values())if(i instanceof gt)return;this.onAnnotationEditor(null)}}setValue(t,i){const a=this.#n.get(t);let r=!1;if(a!==void 0)for(const[c,u]of Object.entries(i))a[c]!==u&&(r=!0,a[c]=u);else r=!0,this.#n.set(t,i);r&&this.#i(),i instanceof gt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(i.constructor._type)}has(t){return this.#n.has(t)}get size(){return this.#n.size}#i(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Zv(this)}get serializable(){if(this.#n.size===0)return Gf;const t=new Map,i=new Kv,a=[],r=Object.create(null);let c=!1;for(const[u,h]of this.#n){const p=h instanceof gt?h.serialize(!1,r):h;p&&(t.set(u,p),i.update(`${u}:${JSON.stringify(p)}`),c||=!!p.bitmap)}if(c)for(const u of t.values())u.bitmap&&a.push(u.bitmap);return t.size>0?{map:t,hash:i.hexdigest(),transfer:a}:Gf}get editorStats(){let t=null;const i=new Map;for(const a of this.#n.values()){if(!(a instanceof gt))continue;const r=a.telemetryFinalData;if(!r)continue;const{type:c}=r;i.has(c)||i.set(c,Object.getPrototypeOf(a).constructor),t||=Object.create(null);const u=t[c]||=new Map;for(const[h,p]of Object.entries(r)){if(h==="type")continue;let m=u.get(h);m||(m=new Map,u.set(h,m));const g=m.get(p)??0;m.set(p,g+1)}}for(const[a,r]of i)t[a]=r.computeTelemetryFinalData(t[a]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;const t=[];for(const i of this.#n.values())!(i instanceof gt)||!i.annotationElementId||!i.serialize()||t.push(i.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#n.entries()}}class Zv extends Vf{#t;constructor(t){super();const{map:i,hash:a,transfer:r}=t.serializable,c=structuredClone(i,r?{transfer:r}:null);this.#t={map:c,hash:a,transfer:r}}get print(){se("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return zt(this,"modifiedIds",{ids:new Set,hash:""})}}class DM{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:i=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const i=this.styleElement.sheet;i.insertRule(t,i.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:i,_inspectFont:a}){if(!(!t||this.#t.has(t.loadedName))){if(Me(!i,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:r,src:c,style:u}=t,h=new FontFace(r,c,u);this.addNativeFontFace(h);try{await h.load(),this.#t.add(r),a?.(t)}catch{Ct(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(h)}return}se("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 a=t.createNativeFontFace();if(a){this.addNativeFontFace(a);try{await a.loaded}catch(r){throw Ct(`Failed to load font '${a.family}': '${r}'.`),t.disableFontFace=!0,r}}return}const i=t.createFontFaceRule();if(i){if(this.insertRule(i),this.isSyncFontLoadingSupported)return;await new Promise(a=>{const r=this._queueLoadingCallback(a);this._prepareFontLoadEvent(t,r)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return zt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return zt(this,"isSyncFontLoadingSupported",un||Ve.platform.isFirefox)}_queueLoadingCallback(t){function i(){for(Me(!r.done,"completeRequest() cannot be called twice."),r.done=!0;a.length>0&&a[0].done;){const c=a.shift();setTimeout(c.callback,0)}}const{loadingRequests:a}=this,r={done:!1,complete:i,callback:t};return a.push(r),r}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return zt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,i){function a(U,P){return U.charCodeAt(P)<<24|U.charCodeAt(P+1)<<16|U.charCodeAt(P+2)<<8|U.charCodeAt(P+3)&255}function r(U,P,j,F){const tt=U.substring(0,P),Y=U.substring(P+j);return tt+F+Y}let c,u;const h=this._document.createElement("canvas");h.width=1,h.height=1;const p=h.getContext("2d");let m=0;function g(U,P){if(++m>30){Ct("Load test font never loaded."),P();return}if(p.font="30px "+U,p.fillText(".",0,20),p.getImageData(0,0,1,1).data[3]>0){P();return}setTimeout(g.bind(null,U,P))}const y=`lt${Date.now()}${this.loadTestFontId++}`;let b=this._loadTestFont;b=r(b,976,y.length,y);const A=16,_=1482184792;let R=a(b,A);for(c=0,u=y.length-3;c<u;c+=4)R=R-_+a(y,c)|0;c<y.length&&(R=R-_+a(y+"XXX",c)|0),b=r(b,A,4,fM(R));const x=`url(data:font/opentype;base64,${btoa(b)});`,L=`@font-face {font-family:"${y}";src:${x}}`;this.insertRule(L);const k=this._document.createElement("div");k.style.visibility="hidden",k.style.width=k.style.height="10px",k.style.position="absolute",k.style.top=k.style.left="0px";for(const U of[t.loadedName,y]){const P=this._document.createElement("span");P.textContent="Hi",P.style.fontFamily=U,k.append(P)}this._document.body.append(k),g(y,()=>{k.remove(),i.complete()})}}class MM{constructor(t,i=null){this.compiledGlyphs=Object.create(null);for(const a in t)this[a]=t[a];this._inspectFont=i}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,i)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Xv(this.data)});`;let i;if(!this.cssFontInfo)i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${t}}`}return this._inspectFont?.(this,t),i}getPathGenerator(t,i){if(this.compiledGlyphs[i]!==void 0)return this.compiledGlyphs[i];const a=this.loadedName+"_path_"+i;let r;try{r=t.get(a)}catch(u){Ct(`getPathGenerator - ignoring character: "${u}".`)}const c=new Path2D(r||"");return this.fontExtraProperties||t.delete(a),this.compiledGlyphs[i]=c}}function OM(l){if(l instanceof URL)return l.href;if(typeof l=="string"){if(un)return l;const t=URL.parse(l,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function kM(l){if(un&&typeof Buffer<"u"&&l instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return Yo(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Tu(l){if(typeof l!="string")return null;if(l.endsWith("/"))return l;throw new Error(`Invalid factory url: "${l}" must include trailing slash.`)}const qf=l=>typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0,NM=l=>typeof l=="object"&&typeof l?.name=="string",LM=bM.bind(null,qf,NM);class IM{#t=new Map;#e=Promise.resolve();postMessage(t,i){const a={data:structuredClone(t,i?{transfer:i}:null)};this.#e.then(()=>{for(const[r]of this.#t)r.call(this,a)})}addEventListener(t,i,a=null){let r=null;if(a?.signal instanceof AbortSignal){const{signal:c}=a;if(c.aborted){Ct("LoopbackPort - cannot use an `aborted` signal.");return}const u=()=>this.removeEventListener(t,i);r=()=>c.removeEventListener("abort",u),c.addEventListener("abort",u)}this.#t.set(i,r)}removeEventListener(t,i){this.#t.get(i)?.(),this.#t.delete(i)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}const wu={DATA:1,ERROR:2},ke={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Jv(){}function An(l){if(l instanceof Is||l instanceof Lf||l instanceof $v||l instanceof vu||l instanceof Nf)return l;switch(l instanceof Error||typeof l=="object"&&l!==null||se('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Is(l.message);case"InvalidPDFException":return new Lf(l.message);case"PasswordException":return new $v(l.message,l.code);case"ResponseException":return new vu(l.message,l.status,l.missing);case"UnknownErrorException":return new Nf(l.message,l.details)}return new Nf(l.message,l.toString())}class tl{#t=new AbortController;constructor(t,i,a){this.sourceName=t,this.targetName=i,this.comObj=a,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),a.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){const a=t.callbackId,r=this.callbackCapabilities[a];if(!r)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],t.callback===wu.DATA)r.resolve(t.data);else if(t.callback===wu.ERROR)r.reject(An(t.reason));else throw new Error("Unexpected callback case");return}const i=this.actionHandler[t.action];if(!i)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const a=this.sourceName,r=t.sourceName,c=this.comObj;Promise.try(i,t.data).then(function(u){c.postMessage({sourceName:a,targetName:r,callback:wu.DATA,callbackId:t.callbackId,data:u})},function(u){c.postMessage({sourceName:a,targetName:r,callback:wu.ERROR,callbackId:t.callbackId,reason:An(u)})});return}if(t.streamId){this.#n(t);return}i(t.data)}on(t,i){const a=this.actionHandler;if(a[t])throw new Error(`There is already an actionName called "${t}"`);a[t]=i}send(t,i,a){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:i},a)}sendWithPromise(t,i,a){const r=this.callbackId++,c=Promise.withResolvers();this.callbackCapabilities[r]=c;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:i},a)}catch(u){c.reject(u)}return c.promise}sendWithStream(t,i,a,r){const c=this.streamId++,u=this.sourceName,h=this.targetName,p=this.comObj;return new ReadableStream({start:m=>{const g=Promise.withResolvers();return this.streamControllers[c]={controller:m,startCall:g,pullCall:null,cancelCall:null,isClosed:!1},p.postMessage({sourceName:u,targetName:h,action:t,streamId:c,data:i,desiredSize:m.desiredSize},r),g.promise},pull:m=>{const g=Promise.withResolvers();return this.streamControllers[c].pullCall=g,p.postMessage({sourceName:u,targetName:h,stream:ke.PULL,streamId:c,desiredSize:m.desiredSize}),g.promise},cancel:m=>{Me(m instanceof Error,"cancel must have a valid reason");const g=Promise.withResolvers();return this.streamControllers[c].cancelCall=g,this.streamControllers[c].isClosed=!0,p.postMessage({sourceName:u,targetName:h,stream:ke.CANCEL,streamId:c,reason:An(m)}),g.promise}},a)}#n(t){const i=t.streamId,a=this.sourceName,r=t.sourceName,c=this.comObj,u=this,h=this.actionHandler[t.action],p={enqueue(m,g=1,y){if(this.isCancelled)return;const b=this.desiredSize;this.desiredSize-=g,b>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),c.postMessage({sourceName:a,targetName:r,stream:ke.ENQUEUE,streamId:i,chunk:m},y)},close(){this.isCancelled||(this.isCancelled=!0,c.postMessage({sourceName:a,targetName:r,stream:ke.CLOSE,streamId:i}),delete u.streamSinks[i])},error(m){Me(m instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,c.postMessage({sourceName:a,targetName:r,stream:ke.ERROR,streamId:i,reason:An(m)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};p.sinkCapability.resolve(),p.ready=p.sinkCapability.promise,this.streamSinks[i]=p,Promise.try(h,t.data,p).then(function(){c.postMessage({sourceName:a,targetName:r,stream:ke.START_COMPLETE,streamId:i,success:!0})},function(m){c.postMessage({sourceName:a,targetName:r,stream:ke.START_COMPLETE,streamId:i,reason:An(m)})})}#i(t){const i=t.streamId,a=this.sourceName,r=t.sourceName,c=this.comObj,u=this.streamControllers[i],h=this.streamSinks[i];switch(t.stream){case ke.START_COMPLETE:t.success?u.startCall.resolve():u.startCall.reject(An(t.reason));break;case ke.PULL_COMPLETE:t.success?u.pullCall.resolve():u.pullCall.reject(An(t.reason));break;case ke.PULL:if(!h){c.postMessage({sourceName:a,targetName:r,stream:ke.PULL_COMPLETE,streamId:i,success:!0});break}h.desiredSize<=0&&t.desiredSize>0&&h.sinkCapability.resolve(),h.desiredSize=t.desiredSize,Promise.try(h.onPull||Jv).then(function(){c.postMessage({sourceName:a,targetName:r,stream:ke.PULL_COMPLETE,streamId:i,success:!0})},function(m){c.postMessage({sourceName:a,targetName:r,stream:ke.PULL_COMPLETE,streamId:i,reason:An(m)})});break;case ke.ENQUEUE:if(Me(u,"enqueue should have stream controller"),u.isClosed)break;u.controller.enqueue(t.chunk);break;case ke.CLOSE:if(Me(u,"close should have stream controller"),u.isClosed)break;u.isClosed=!0,u.controller.close(),this.#a(u,i);break;case ke.ERROR:Me(u,"error should have stream controller"),u.controller.error(An(t.reason)),this.#a(u,i);break;case ke.CANCEL_COMPLETE:t.success?u.cancelCall.resolve():u.cancelCall.reject(An(t.reason)),this.#a(u,i);break;case ke.CANCEL:if(!h)break;const p=An(t.reason);Promise.try(h.onCancel||Jv,p).then(function(){c.postMessage({sourceName:a,targetName:r,stream:ke.CANCEL_COMPLETE,streamId:i,success:!0})},function(m){c.postMessage({sourceName:a,targetName:r,stream:ke.CANCEL_COMPLETE,streamId:i,reason:An(m)})}),h.sinkCapability.reject(p),h.isCancelled=!0,delete this.streamSinks[i];break;default:throw new Error("Unexpected stream case")}}async#a(t,i){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[i]}destroy(){this.#t?.abort(),this.#t=null}}class t0{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,i){if(t<=0||i<=0)throw new Error("Invalid canvas size");const a=this._createCanvas(t,i);return{canvas:a,context:a.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,i,a){if(!t.canvas)throw new Error("Canvas is not specified");if(i<=0||a<=0)throw new Error("Invalid canvas size");t.canvas.width=i,t.canvas.height=a}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,i){se("Abstract method `_createCanvas` called.")}}class PM extends t0{constructor({ownerDocument:t=globalThis.document,enableHWA:i=!1}){super({enableHWA:i}),this._document=t}_createCanvas(t,i){const a=this._document.createElement("canvas");return a.width=t,a.height=i,a}}class e0{constructor({baseUrl:t=null,isCompressed:i=!0}){this.baseUrl=t,this.isCompressed=i}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const i=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(i).then(a=>({cMapData:a,isCompressed:this.isCompressed})).catch(a=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${i}`)})}async _fetch(t){se("Abstract method `_fetch` called.")}}class n0 extends e0{async _fetch(t){const i=await Wo(t,this.isCompressed?"arraybuffer":"text");return i instanceof ArrayBuffer?new Uint8Array(i):Yo(i)}}class i0{addFilter(t){return"none"}addHCMFilter(t,i){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,i,a,r,c){return"none"}destroy(t=!1){}}class UM extends i0{#t;#e;#n;#i;#a;#s;#r=0;constructor({docId:t,ownerDocument:i=globalThis.document}){super(),this.#i=t,this.#a=i}get#o(){return this.#e||=new Map}get#u(){return this.#s||=new Map}get#c(){if(!this.#n){const t=this.#a.createElement("div"),{style:i}=t;i.visibility="hidden",i.contain="strict",i.width=i.height=0,i.position="absolute",i.top=i.left=0,i.zIndex=-1;const a=this.#a.createElementNS(Ji,"svg");a.setAttribute("width",0),a.setAttribute("height",0),this.#n=this.#a.createElementNS(Ji,"defs"),t.append(a),a.append(this.#n),this.#a.body.append(t)}return this.#n}#h(t){if(t.length===1){const p=t[0],m=new Array(256);for(let y=0;y<256;y++)m[y]=p[y]/255;const g=m.join(",");return[g,g,g]}const[i,a,r]=t,c=new Array(256),u=new Array(256),h=new Array(256);for(let p=0;p<256;p++)c[p]=i[p]/255,u[p]=a[p]/255,h[p]=r[p]/255;return[c.join(","),u.join(","),h.join(",")]}#l(t){if(this.#t===void 0){this.#t="";const i=this.#a.URL;i!==this.#a.baseURI&&(Su(i)?Ct('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=jv(i,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let i=this.#o.get(t);if(i)return i;const[a,r,c]=this.#h(t),u=t.length===1?a:`${a}${r}${c}`;if(i=this.#o.get(u),i)return this.#o.set(t,i),i;const h=`g_${this.#i}_transfer_map_${this.#r++}`,p=this.#l(h);this.#o.set(t,p),this.#o.set(u,p);const m=this.#f(h);return this.#m(a,r,c,m),p}addHCMFilter(t,i){const a=`${t}-${i}`,r="base";let c=this.#u.get(r);if(c?.key===a||(c?(c.filter?.remove(),c.key=a,c.url="none",c.filter=null):(c={key:a,url:"none",filter:null},this.#u.set(r,c)),!t||!i))return c.url;const u=this.#y(t);t=pt.makeHexColor(...u);const h=this.#y(i);if(i=pt.makeHexColor(...h),this.#c.style.color="",t==="#000000"&&i==="#ffffff"||t===i)return c.url;const p=new Array(256);for(let S=0;S<=255;S++){const A=S/255;p[S]=A<=.03928?A/12.92:((A+.055)/1.055)**2.4}const m=p.join(","),g=`g_${this.#i}_hcm_filter`,y=c.filter=this.#f(g);this.#m(m,m,m,y),this.#g(y);const b=(S,A)=>{const _=u[S]/255,R=h[S]/255,x=new Array(A+1);for(let L=0;L<=A;L++)x[L]=_+L/A*(R-_);return x.join(",")};return this.#m(b(0,5),b(1,5),b(2,5),y),c.url=this.#l(g),c.url}addAlphaFilter(t){let i=this.#o.get(t);if(i)return i;const[a]=this.#h([t]),r=`alpha_${a}`;if(i=this.#o.get(r),i)return this.#o.set(t,i),i;const c=`g_${this.#i}_alpha_map_${this.#r++}`,u=this.#l(c);this.#o.set(t,u),this.#o.set(r,u);const h=this.#f(c);return this.#v(a,h),u}addLuminosityFilter(t){let i=this.#o.get(t||"luminosity");if(i)return i;let a,r;if(t?([a]=this.#h([t]),r=`luminosity_${a}`):r="luminosity",i=this.#o.get(r),i)return this.#o.set(t,i),i;const c=`g_${this.#i}_luminosity_map_${this.#r++}`,u=this.#l(c);this.#o.set(t,u),this.#o.set(r,u);const h=this.#f(c);return this.#p(h),t&&this.#v(a,h),u}addHighlightHCMFilter(t,i,a,r,c){const u=`${i}-${a}-${r}-${c}`;let h=this.#u.get(t);if(h?.key===u||(h?(h.filter?.remove(),h.key=u,h.url="none",h.filter=null):(h={key:u,url:"none",filter:null},this.#u.set(t,h)),!i||!a))return h.url;const[p,m]=[i,a].map(this.#y.bind(this));let g=Math.round(.2126*p[0]+.7152*p[1]+.0722*p[2]),y=Math.round(.2126*m[0]+.7152*m[1]+.0722*m[2]),[b,S]=[r,c].map(this.#y.bind(this));y<g&&([g,y,b,S]=[y,g,S,b]),this.#c.style.color="";const A=(x,L,k)=>{const U=new Array(256),P=(y-g)/k,j=x/255,F=(L-x)/(255*k);let tt=0;for(let Y=0;Y<=k;Y++){const st=Math.round(g+Y*P),Z=j+Y*F;for(let ot=tt;ot<=st;ot++)U[ot]=Z;tt=st+1}for(let Y=tt;Y<256;Y++)U[Y]=U[tt-1];return U.join(",")},_=`g_${this.#i}_hcm_${t}_filter`,R=h.filter=this.#f(_);return this.#g(R),this.#m(A(b[0],S[0],5),A(b[1],S[1],5),A(b[2],S[2],5),R),h.url=this.#l(_),h.url}destroy(t=!1){t&&this.#s?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#e?.clear(),this.#e=null,this.#s?.clear(),this.#s=null,this.#r=0)}#p(t){const i=this.#a.createElementNS(Ji,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(i)}#g(t){const i=this.#a.createElementNS(Ji,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(i)}#f(t){const i=this.#a.createElementNS(Ji,"filter");return i.setAttribute("color-interpolation-filters","sRGB"),i.setAttribute("id",t),this.#c.append(i),i}#d(t,i,a){const r=this.#a.createElementNS(Ji,i);r.setAttribute("type","discrete"),r.setAttribute("tableValues",a),t.append(r)}#m(t,i,a,r){const c=this.#a.createElementNS(Ji,"feComponentTransfer");r.append(c),this.#d(c,"feFuncR",t),this.#d(c,"feFuncG",i),this.#d(c,"feFuncB",a)}#v(t,i){const a=this.#a.createElementNS(Ji,"feComponentTransfer");i.append(a),this.#d(a,"feFuncA",t)}#y(t){return this.#c.style.color=t,Eu(getComputedStyle(this.#c).getPropertyValue("color"))}}class s0{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const i=`${this.baseUrl}${t}`;return this._fetch(i).catch(a=>{throw new Error(`Unable to load font data at: ${i}`)})}async _fetch(t){se("Abstract method `_fetch` called.")}}class a0 extends s0{async _fetch(t){const i=await Wo(t,"arraybuffer");return new Uint8Array(i)}}class r0{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const i=`${this.baseUrl}${t}`;return this._fetch(i).catch(a=>{throw new Error(`Unable to load wasm data at: ${i}`)})}async _fetch(t){se("Abstract method `_fetch` called.")}}class o0 extends r0{async _fetch(t){const i=await Wo(t,"arraybuffer");return new Uint8Array(i)}}un&&Ct("Please use the `legacy` build in Node.js environments.");async function Xf(l){const i=await process.getBuiltinModule("fs").promises.readFile(l);return new Uint8Array(i)}class zM extends i0{}class HM extends t0{_createCanvas(t,i){return process.getBuiltinModule("module").createRequire(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("corisco.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,i)}}class BM extends e0{async _fetch(t){return Xf(t)}}class FM extends s0{async _fetch(t){return Xf(t)}}class jM extends r0{async _fetch(t){return Xf(t)}}const qe={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Yf(l,t){if(!t)return;const i=t[2]-t[0],a=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],i,a),l.clip(r)}class Wf{isModifyingCurrentTransform(){return!1}getPattern(){se("Abstract method `getPattern` called.")}}class $M extends Wf{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let i;this._type==="axial"?i=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(i=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const a of this._colorStops)i.addColorStop(a[0],a[1]);return i}getPattern(t,i,a,r){let c;if(r===qe.STROKE||r===qe.FILL){const u=i.current.getClippedPathBoundingBox(r,be(t))||[0,0,0,0],h=Math.ceil(u[2]-u[0])||1,p=Math.ceil(u[3]-u[1])||1,m=i.cachedCanvases.getCanvas("pattern",h,p),g=m.context;g.clearRect(0,0,g.canvas.width,g.canvas.height),g.beginPath(),g.rect(0,0,g.canvas.width,g.canvas.height),g.translate(-u[0],-u[1]),a=pt.transform(a,[1,0,0,1,u[0],u[1]]),g.transform(...i.baseTransform),this.matrix&&g.transform(...this.matrix),Yf(g,this._bbox),g.fillStyle=this._createGradient(g),g.fill(),c=t.createPattern(m.canvas,"no-repeat");const y=new DOMMatrix(a);c.setTransform(y)}else Yf(t,this._bbox),c=this._createGradient(t);return c}}function Qf(l,t,i,a,r,c,u,h){const p=t.coords,m=t.colors,g=l.data,y=l.width*4;let b;p[i+1]>p[a+1]&&(b=i,i=a,a=b,b=c,c=u,u=b),p[a+1]>p[r+1]&&(b=a,a=r,r=b,b=u,u=h,h=b),p[i+1]>p[a+1]&&(b=i,i=a,a=b,b=c,c=u,u=b);const S=(p[i]+t.offsetX)*t.scaleX,A=(p[i+1]+t.offsetY)*t.scaleY,_=(p[a]+t.offsetX)*t.scaleX,R=(p[a+1]+t.offsetY)*t.scaleY,x=(p[r]+t.offsetX)*t.scaleX,L=(p[r+1]+t.offsetY)*t.scaleY;if(A>=L)return;const k=m[c],U=m[c+1],P=m[c+2],j=m[u],F=m[u+1],tt=m[u+2],Y=m[h],st=m[h+1],Z=m[h+2],ot=Math.round(A),St=Math.round(L);let yt,Gt,B,K,ut,wt,W,dt;for(let Q=ot;Q<=St;Q++){if(Q<R){const Wt=Q<A?0:(A-Q)/(A-R);yt=S-(S-_)*Wt,Gt=k-(k-j)*Wt,B=U-(U-F)*Wt,K=P-(P-tt)*Wt}else{let Wt;Q>L?Wt=1:R===L?Wt=0:Wt=(R-Q)/(R-L),yt=_-(_-x)*Wt,Gt=j-(j-Y)*Wt,B=F-(F-st)*Wt,K=tt-(tt-Z)*Wt}let vt;Q<A?vt=0:Q>L?vt=1:vt=(A-Q)/(A-L),ut=S-(S-x)*vt,wt=k-(k-Y)*vt,W=U-(U-st)*vt,dt=P-(P-Z)*vt;const Vt=Math.round(Math.min(yt,ut)),ae=Math.round(Math.max(yt,ut));let At=y*Q+Vt*4;for(let Wt=Vt;Wt<=ae;Wt++)vt=(yt-Wt)/(yt-ut),vt<0?vt=0:vt>1&&(vt=1),g[At++]=Gt-(Gt-wt)*vt|0,g[At++]=B-(B-W)*vt|0,g[At++]=K-(K-dt)*vt|0,g[At++]=255}}function GM(l,t,i){const a=t.coords,r=t.colors;let c,u;switch(t.type){case"lattice":const h=t.verticesPerRow,p=Math.floor(a.length/h)-1,m=h-1;for(c=0;c<p;c++){let g=c*h;for(let y=0;y<m;y++,g++)Qf(l,i,a[g],a[g+1],a[g+h],r[g],r[g+1],r[g+h]),Qf(l,i,a[g+h+1],a[g+1],a[g+h],r[g+h+1],r[g+1],r[g+h])}break;case"triangles":for(c=0,u=a.length;c<u;c+=3)Qf(l,i,a[c],a[c+1],a[c+2],r[c],r[c+1],r[c+2]);break;default:throw new Error("illegal figure")}}class VM extends Wf{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,i,a){const h=Math.floor(this._bounds[0]),p=Math.floor(this._bounds[1]),m=Math.ceil(this._bounds[2])-h,g=Math.ceil(this._bounds[3])-p,y=Math.min(Math.ceil(Math.abs(m*t[0]*1.1)),3e3),b=Math.min(Math.ceil(Math.abs(g*t[1]*1.1)),3e3),S=m/y,A=g/b,_={coords:this._coords,colors:this._colors,offsetX:-h,offsetY:-p,scaleX:1/S,scaleY:1/A},R=y+4,x=b+4,L=a.getCanvas("mesh",R,x),k=L.context,U=k.createImageData(y,b);if(i){const j=U.data;for(let F=0,tt=j.length;F<tt;F+=4)j[F]=i[0],j[F+1]=i[1],j[F+2]=i[2],j[F+3]=255}for(const j of this._figures)GM(U,j,_);return k.putImageData(U,2,2),{canvas:L.canvas,offsetX:h-2*S,offsetY:p-2*A,scaleX:S,scaleY:A}}isModifyingCurrentTransform(){return!0}getPattern(t,i,a,r){Yf(t,this._bbox);const c=new Float32Array(2);if(r===qe.SHADING)pt.singularValueDecompose2dScale(be(t),c);else if(this.matrix){pt.singularValueDecompose2dScale(this.matrix,c);const[h,p]=c;pt.singularValueDecompose2dScale(i.baseTransform,c),c[0]*=h,c[1]*=p}else pt.singularValueDecompose2dScale(i.baseTransform,c);const u=this._createMeshCanvas(c,r===qe.SHADING?null:this._background,i.cachedCanvases);return r!==qe.SHADING&&(t.setTransform(...i.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(u.offsetX,u.offsetY),t.scale(u.scaleX,u.scaleY),t.createPattern(u.canvas,"no-repeat")}}class qM extends Wf{getPattern(){return"hotpink"}}function XM(l){switch(l[0]){case"RadialAxial":return new $M(l);case"Mesh":return new VM(l);case"Dummy":return new qM}throw new Error(`Unknown IR type: ${l[0]}`)}const l0={COLORED:1,UNCOLORED:2};class Kf{static MAX_PATTERN_SIZE=3e3;constructor(t,i,a,r){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=i,this.canvasGraphicsFactory=a,this.baseTransform=r}createPatternCanvas(t){const{bbox:i,operatorList:a,paintType:r,tilingType:c,color:u,canvasGraphicsFactory:h}=this;let{xstep:p,ystep:m}=this;p=Math.abs(p),m=Math.abs(m),bu("TilingType: "+c);const g=i[0],y=i[1],b=i[2],S=i[3],A=b-g,_=S-y,R=new Float32Array(2);pt.singularValueDecompose2dScale(this.matrix,R);const[x,L]=R;pt.singularValueDecompose2dScale(this.baseTransform,R);const k=x*R[0],U=L*R[1];let P=A,j=_,F=!1,tt=!1;const Y=Math.ceil(p*k),st=Math.ceil(m*U),Z=Math.ceil(A*k),ot=Math.ceil(_*U);Y>=Z?P=p:F=!0,st>=ot?j=m:tt=!0;const St=this.getSizeAndScale(P,this.ctx.canvas.width,k),yt=this.getSizeAndScale(j,this.ctx.canvas.height,U),Gt=t.cachedCanvases.getCanvas("pattern",St.size,yt.size),B=Gt.context,K=h.createCanvasGraphics(B);if(K.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(K,r,u),B.translate(-St.scale*g,-yt.scale*y),K.transform(St.scale,0,0,yt.scale,0,0),B.save(),this.clipBbox(K,g,y,b,S),K.baseTransform=be(K.ctx),K.executeOperatorList(a),K.endDrawing(),B.restore(),F||tt){const ut=Gt.canvas;F&&(P=p),tt&&(j=m);const wt=this.getSizeAndScale(P,this.ctx.canvas.width,k),W=this.getSizeAndScale(j,this.ctx.canvas.height,U),dt=wt.size,Q=W.size,vt=t.cachedCanvases.getCanvas("pattern-workaround",dt,Q),Vt=vt.context,ae=F?Math.floor(A/p):0,At=tt?Math.floor(_/m):0;for(let Wt=0;Wt<=ae;Wt++)for(let Kt=0;Kt<=At;Kt++)Vt.drawImage(ut,dt*Wt,Q*Kt,dt,Q,0,0,dt,Q);return{canvas:vt.canvas,scaleX:wt.scale,scaleY:W.scale,offsetX:g,offsetY:y}}return{canvas:Gt.canvas,scaleX:St.scale,scaleY:yt.scale,offsetX:g,offsetY:y}}getSizeAndScale(t,i,a){const r=Math.max(Kf.MAX_PATTERN_SIZE,i);let c=Math.ceil(t*a);return c>=r?c=r:a=c/t,{scale:a,size:c}}clipBbox(t,i,a,r,c){const u=r-i,h=c-a;t.ctx.rect(i,a,u,h),pt.axialAlignedBoundingBox([i,a,r,c],be(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,i,a){const r=t.ctx,c=t.current;switch(i){case l0.COLORED:const{fillStyle:u,strokeStyle:h}=this.ctx;r.fillStyle=c.fillColor=u,r.strokeStyle=c.strokeColor=h;break;case l0.UNCOLORED:r.fillStyle=r.strokeStyle=a,c.fillColor=c.strokeColor=a;break;default:throw new hM(`Unsupported paint type: ${i}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,i,a,r){let c=a;r!==qe.SHADING&&(c=pt.transform(c,i.baseTransform),this.matrix&&(c=pt.transform(c,this.matrix)));const u=this.createPatternCanvas(i);let h=new DOMMatrix(c);h=h.translate(u.offsetX,u.offsetY),h=h.scale(1/u.scaleX,1/u.scaleY);const p=t.createPattern(u.canvas,"repeat");return p.setTransform(h),p}}function YM({src:l,srcPos:t=0,dest:i,width:a,height:r,nonBlackColor:c=4294967295,inverseDecode:u=!1}){const h=Ve.isLittleEndian?4278190080:255,[p,m]=u?[c,h]:[h,c],g=a>>3,y=a&7,b=l.length;i=new Uint32Array(i.buffer);let S=0;for(let A=0;A<r;A++){for(const R=t+g;t<R;t++){const x=t<b?l[t]:255;i[S++]=x&128?m:p,i[S++]=x&64?m:p,i[S++]=x&32?m:p,i[S++]=x&16?m:p,i[S++]=x&8?m:p,i[S++]=x&4?m:p,i[S++]=x&2?m:p,i[S++]=x&1?m:p}if(y===0)continue;const _=t<b?l[t++]:255;for(let R=0;R<y;R++)i[S++]=_&1<<7-R?m:p}return{srcPos:t,destPos:S}}const c0=16,u0=100,WM=15,d0=10,_n=16,Zf=new DOMMatrix,Ln=new Float32Array(2),_r=new Float32Array([1/0,1/0,-1/0,-1/0]);function QM(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(i,a){t.translate(i,a),this.__originalTranslate(i,a)},l.scale=function(i,a){t.scale(i,a),this.__originalScale(i,a)},l.transform=function(i,a,r,c,u,h){t.transform(i,a,r,c,u,h),this.__originalTransform(i,a,r,c,u,h)},l.setTransform=function(i,a,r,c,u,h){t.setTransform(i,a,r,c,u,h),this.__originalSetTransform(i,a,r,c,u,h)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(i){t.rotate(i),this.__originalRotate(i)},l.clip=function(i){t.clip(i),this.__originalClip(i)},l.moveTo=function(i,a){t.moveTo(i,a),this.__originalMoveTo(i,a)},l.lineTo=function(i,a){t.lineTo(i,a),this.__originalLineTo(i,a)},l.bezierCurveTo=function(i,a,r,c,u,h){t.bezierCurveTo(i,a,r,c,u,h),this.__originalBezierCurveTo(i,a,r,c,u,h)},l.rect=function(i,a,r,c){t.rect(i,a,r,c),this.__originalRect(i,a,r,c)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class KM{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,i,a){let r;return this.cache[t]!==void 0?(r=this.cache[t],this.canvasFactory.reset(r,i,a)):(r=this.canvasFactory.create(i,a),this.cache[t]=r),r}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const i=this.cache[t];this.canvasFactory.destroy(i),delete this.cache[t]}}}function xu(l,t,i,a,r,c,u,h,p,m){const[g,y,b,S,A,_]=be(l);if(y===0&&b===0){const L=u*g+A,k=Math.round(L),U=h*S+_,P=Math.round(U),j=(u+p)*g+A,F=Math.abs(Math.round(j)-k)||1,tt=(h+m)*S+_,Y=Math.abs(Math.round(tt)-P)||1;return l.setTransform(Math.sign(g),0,0,Math.sign(S),k,P),l.drawImage(t,i,a,r,c,0,0,F,Y),l.setTransform(g,y,b,S,A,_),[F,Y]}if(g===0&&S===0){const L=h*b+A,k=Math.round(L),U=u*y+_,P=Math.round(U),j=(h+m)*b+A,F=Math.abs(Math.round(j)-k)||1,tt=(u+p)*y+_,Y=Math.abs(Math.round(tt)-P)||1;return l.setTransform(0,Math.sign(y),Math.sign(b),0,k,P),l.drawImage(t,i,a,r,c,0,0,Y,F),l.setTransform(g,y,b,S,A,_),[Y,F]}l.drawImage(t,i,a,r,c,u,h,p,m);const R=Math.hypot(g,y),x=Math.hypot(b,S);return[R*p,x*m]}class h0{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Of;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=sn.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,i){this.clipBox=new Float32Array([0,0,t,i]),this.minMax=_r.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=qe.FILL,i=null){const a=this.minMax.slice();if(t===qe.STROKE){i||se("Stroke bounding box must include transform."),pt.singularValueDecompose2dScale(i,Ln);const r=Ln[0]*this.lineWidth/2,c=Ln[1]*this.lineWidth/2;a[0]-=r,a[1]-=c,a[2]+=r,a[3]+=c}return a}updateClipFromPath(){const t=pt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(_r,0)}getClippedPathBoundingBox(t=qe.FILL,i=null){return pt.intersect(this.clipBox,this.getPathBoundingBox(t,i))}}function f0(l,t){if(t instanceof ImageData){l.putImageData(t,0,0);return}const i=t.height,a=t.width,r=i%_n,c=(i-r)/_n,u=r===0?c:c+1,h=l.createImageData(a,_n);let p=0,m;const g=t.data,y=h.data;let b,S,A,_;if(t.kind===fu.GRAYSCALE_1BPP){const R=g.byteLength,x=new Uint32Array(y.buffer,0,y.byteLength>>2),L=x.length,k=a+7>>3,U=4294967295,P=Ve.isLittleEndian?4278190080:255;for(b=0;b<u;b++){for(A=b<c?_n:r,m=0,S=0;S<A;S++){const j=R-p;let F=0;const tt=j>k?a:j*8-7,Y=tt&-8;let st=0,Z=0;for(;F<Y;F+=8)Z=g[p++],x[m++]=Z&128?U:P,x[m++]=Z&64?U:P,x[m++]=Z&32?U:P,x[m++]=Z&16?U:P,x[m++]=Z&8?U:P,x[m++]=Z&4?U:P,x[m++]=Z&2?U:P,x[m++]=Z&1?U:P;for(;F<tt;F++)st===0&&(Z=g[p++],st=128),x[m++]=Z&st?U:P,st>>=1}for(;m<L;)x[m++]=0;l.putImageData(h,0,b*_n)}}else if(t.kind===fu.RGBA_32BPP){for(S=0,_=a*_n*4,b=0;b<c;b++)y.set(g.subarray(p,p+_)),p+=_,l.putImageData(h,0,S),S+=_n;b<u&&(_=a*r*4,y.set(g.subarray(p,p+_)),l.putImageData(h,0,S))}else if(t.kind===fu.RGB_24BPP)for(A=_n,_=a*A,b=0;b<u;b++){for(b>=c&&(A=r,_=a*A),m=0,S=_;S--;)y[m++]=g[p++],y[m++]=g[p++],y[m++]=g[p++],y[m++]=255;l.putImageData(h,0,b*_n)}else throw new Error(`bad image kind: ${t.kind}`)}function p0(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}const i=t.height,a=t.width,r=i%_n,c=(i-r)/_n,u=r===0?c:c+1,h=l.createImageData(a,_n);let p=0;const m=t.data,g=h.data;for(let y=0;y<u;y++){const b=y<c?_n:r;({srcPos:p}=YM({src:m,srcPos:p,dest:g,width:a,height:b,nonBlackColor:0})),l.putImageData(h,0,y*_n)}}function el(l,t){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const a of i)l[a]!==void 0&&(t[a]=l[a]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Cu(l){l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0);const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}function m0(l,t){if(t)return!0;pt.singularValueDecompose2dScale(l,Ln);const i=Math.fround(Ci.pixelRatio*Ar.PDF_TO_CSS_UNITS);return Ln[0]<=i&&Ln[1]<=i}const ZM=["butt","round","square"],JM=["miter","round","bevel"],tO={},g0={};class Tr{constructor(t,i,a,r,c,{optionalContentConfig:u,markedContentStack:h=null},p,m){this.ctx=t,this.current=new h0(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=i,this.objs=a,this.canvasFactory=r,this.filterFactory=c,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=u,this.cachedCanvases=new KM(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=p,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=m,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,i=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):i}beginDrawing({transform:t,viewport:i,transparency:a=!1,background:r=null}){const c=this.ctx.canvas.width,u=this.ctx.canvas.height,h=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,c,u),this.ctx.fillStyle=h,a){const p=this.cachedCanvases.getCanvas("transparent",c,u);this.compositeCtx=this.ctx,this.transparentCanvas=p.canvas,this.ctx=p.context,this.ctx.save(),this.ctx.transform(...be(this.compositeCtx))}this.ctx.save(),Cu(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...i.transform),this.viewportScale=i.scale,this.baseTransform=be(this.ctx)}executeOperatorList(t,i,a,r){const c=t.argsArray,u=t.fnArray;let h=i||0;const p=c.length;if(p===h)return h;const m=p-h>d0&&typeof a=="function",g=m?Date.now()+WM:0;let y=0;const b=this.commonObjs,S=this.objs;let A;for(;;){if(r!==void 0&&h===r.nextBreakPoint)return r.breakIt(h,a),h;if(A=u[h],A!==mu.dependency)this[A].apply(this,c[h]);else for(const _ of c[h]){const R=_.startsWith("g_")?b:S;if(!R.has(_))return R.get(_,a),h}if(h++,h===p)return h;if(m&&++y>d0){if(Date.now()>g)return a(),h;y=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const i of t.values())typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement&&(i.width=i.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const i=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=i}}}_scaleImage(t,i){const a=t.width??t.displayWidth,r=t.height??t.displayHeight;let c=Math.max(Math.hypot(i[0],i[1]),1),u=Math.max(Math.hypot(i[2],i[3]),1),h=a,p=r,m="prescale1",g,y;for(;c>2&&h>1||u>2&&p>1;){let b=h,S=p;c>2&&h>1&&(b=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h/2),c/=h/b),u>2&&p>1&&(S=p>=16384?Math.floor(p/2)-1||1:Math.ceil(p)/2,u/=p/S),g=this.cachedCanvases.getCanvas(m,b,S),y=g.context,y.clearRect(0,0,b,S),y.drawImage(t,0,0,h,p,0,0,b,S),t=g.canvas,h=b,p=S,m=m==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:p}}_createMaskCanvas(t){const i=this.ctx,{width:a,height:r}=t,c=this.current.fillColor,u=this.current.patternFill,h=be(i);let p,m,g,y;if((t.bitmap||t.data)&&t.count>1){const Y=t.bitmap||t.data.buffer;m=JSON.stringify(u?h:[h.slice(0,4),c]),p=this._cachedBitmapsMap.get(Y),p||(p=new Map,this._cachedBitmapsMap.set(Y,p));const st=p.get(m);if(st&&!u){const Z=Math.round(Math.min(h[0],h[2])+h[4]),ot=Math.round(Math.min(h[1],h[3])+h[5]);return{canvas:st,offsetX:Z,offsetY:ot}}g=st}g||(y=this.cachedCanvases.getCanvas("maskCanvas",a,r),p0(y.context,t));let b=pt.transform(h,[1/a,0,0,-1/r,0,0]);b=pt.transform(b,[1,0,0,1,0,-r]);const S=_r.slice();pt.axialAlignedBoundingBox([0,0,a,r],b,S);const[A,_,R,x]=S,L=Math.round(R-A)||1,k=Math.round(x-_)||1,U=this.cachedCanvases.getCanvas("fillCanvas",L,k),P=U.context,j=A,F=_;P.translate(-j,-F),P.transform(...b),g||(g=this._scaleImage(y.canvas,xi(P)),g=g.img,p&&u&&p.set(m,g)),P.imageSmoothingEnabled=m0(be(P),t.interpolate),xu(P,g,0,0,g.width,g.height,0,0,a,r),P.globalCompositeOperation="source-in";const tt=pt.transform(xi(P),[1,0,0,1,-j,-F]);return P.fillStyle=u?c.getPattern(i,this,tt,qe.FILL):c,P.fillRect(0,0,a,r),p&&!u&&(this.cachedCanvases.delete("fillCanvas"),p.set(m,U.canvas)),{canvas:U.canvas,offsetX:Math.round(j),offsetY:Math.round(F)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ZM[t]}setLineJoin(t){this.ctx.lineJoin=JM[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,i){const a=this.ctx;a.setLineDash!==void 0&&(a.setLineDash(t),a.lineDashOffset=i)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[i,a]of t)switch(i){case"LW":this.setLineWidth(a);break;case"LC":this.setLineCap(a);break;case"LJ":this.setLineJoin(a);break;case"ML":this.setMiterLimit(a);break;case"D":this.setDash(a[0],a[1]);break;case"RI":this.setRenderingIntent(a);break;case"FL":this.setFlatness(a);break;case"Font":this.setFont(a[0],a[1]);break;case"CA":this.current.strokeAlpha=a;break;case"ca":this.ctx.globalAlpha=this.current.fillAlpha=a;break;case"BM":this.ctx.globalCompositeOperation=a;break;case"SMask":this.current.activeSMask=a?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(a);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,i=this.ctx.canvas.height,a="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(a,t,i);this.suspendedCtx=this.ctx;const c=this.ctx=r.context;c.setTransform(this.suspendedCtx.getTransform()),el(this.suspendedCtx,c),QM(c,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),el(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const i=this.current.activeSMask,a=this.suspendedCtx;this.composeSMask(a,i,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,i,a,r){const c=r[0],u=r[1],h=r[2]-c,p=r[3]-u;h===0||p===0||(this.genericComposeSMask(i.context,a,h,p,i.subtype,i.backdrop,i.transferMap,c,u,i.offsetX,i.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(a.canvas,0,0),t.restore())}genericComposeSMask(t,i,a,r,c,u,h,p,m,g,y){let b=t.canvas,S=p-g,A=m-y;if(u)if(S<0||A<0||S+a>b.width||A+r>b.height){const R=this.cachedCanvases.getCanvas("maskExtension",a,r),x=R.context;x.drawImage(b,-S,-A),x.globalCompositeOperation="destination-atop",x.fillStyle=u,x.fillRect(0,0,a,r),x.globalCompositeOperation="source-over",b=R.canvas,S=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const R=new Path2D;R.rect(S,A,a,r),t.clip(R),t.globalCompositeOperation="destination-atop",t.fillStyle=u,t.fillRect(S,A,a,r),t.restore()}i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0),c==="Alpha"&&h?i.filter=this.filterFactory.addAlphaFilter(h):c==="Luminosity"&&(i.filter=this.filterFactory.addLuminosityFilter(h));const _=new Path2D;_.rect(p,m,a,r),i.clip(_),i.globalCompositeOperation="destination-in",i.drawImage(b,S,A,a,r,p,m,a,r),i.restore()}save(){this.inSMaskMode&&el(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){if(this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&el(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,i,a,r,c,u){this.ctx.transform(t,i,a,r,c,u),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,i,a){let[r]=i;if(!a){r||=i[0]=new Path2D,this[t](r);return}if(!(r instanceof Path2D)){const c=i[0]=new Path2D;for(let u=0,h=r.length;u<h;)switch(r[u++]){case gu.moveTo:c.moveTo(r[u++],r[u++]);break;case gu.lineTo:c.lineTo(r[u++],r[u++]);break;case gu.curveTo:c.bezierCurveTo(r[u++],r[u++],r[u++],r[u++],r[u++],r[u++]);break;case gu.closePath:c.closePath();break;default:Ct(`Unrecognized drawing path operator: ${r[u-1]}`);break}r=c}pt.axialAlignedBoundingBox(a,be(this.ctx),this.current.minMax),this[t](r)}closePath(){this.ctx.closePath()}stroke(t,i=!0){const a=this.ctx,r=this.current.strokeColor;if(a.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&r?.getPattern){const c=r.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.strokeStyle=r.getPattern(a,this,xi(a),qe.STROKE),c){const u=new Path2D;u.addPath(t,a.getTransform().invertSelf().multiplySelf(c)),t=u}this.rescaleAndStroke(t,!1),a.restore()}else this.rescaleAndStroke(t,!0);i&&this.consumePath(t,this.current.getClippedPathBoundingBox(qe.STROKE,be(this.ctx))),a.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,i=!0){const a=this.ctx,r=this.current.fillColor,c=this.current.patternFill;let u=!1;if(c){const p=r.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.fillStyle=r.getPattern(a,this,xi(a),qe.FILL),p){const m=new Path2D;m.addPath(t,a.getTransform().invertSelf().multiplySelf(p)),t=m}u=!0}const h=this.current.getClippedPathBoundingBox();this.contentVisible&&h!==null&&(this.pendingEOFill?(a.fill(t,"evenodd"),this.pendingEOFill=!1):a.fill(t)),u&&a.restore(),i&&this.consumePath(t,h)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=tO}eoClip(){this.pendingClip=g0}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,i=this.ctx;if(t===void 0)return;const a=new Path2D,r=i.getTransform().invertSelf();for(const{transform:c,x:u,y:h,fontSize:p,path:m}of t)m&&a.addPath(m,new DOMMatrix(c).preMultiplySelf(r).translate(u,h).scale(p,-p));i.clip(a),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,i){const a=this.commonObjs.get(t),r=this.current;if(!a)throw new Error(`Can't find font for ${t}`);if(r.fontMatrix=a.fontMatrix||Of,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&Ct("Invalid font matrix for font "+t),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=a,this.current.fontSize=i,a.isType3Font)return;const c=a.loadedName||"sans-serif",u=a.systemFontInfo?.css||`"${c}", ${a.fallbackName}`;let h="normal";a.black?h="900":a.bold&&(h="bold");const p=a.italic?"italic":"normal";let m=i;i<c0?m=c0:i>u0&&(m=u0),this.current.fontSizeScale=i/m,this.ctx.font=`${p} ${h} ${m}px ${u}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,i){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,i){this.setLeading(-i),this.moveText(t,i)}setTextMatrix(t){const{current:i}=this;i.textMatrix=t,i.textMatrixScale=Math.hypot(t[0],t[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(t,i,a){const r=new Path2D;return r.addPath(t,new DOMMatrix(a).invertSelf().multiplySelf(i)),r}paintChar(t,i,a,r,c){const u=this.ctx,h=this.current,p=h.font,m=h.textRenderingMode,g=h.fontSize/h.fontSizeScale,y=m&sn.FILL_STROKE_MASK,b=!!(m&sn.ADD_TO_PATH_FLAG),S=h.patternFill&&!p.missingFile,A=h.patternStroke&&!p.missingFile;let _;if((p.disableFontFace||b||S||A)&&!p.missingFile&&(_=p.getPathGenerator(this.commonObjs,t)),_&&(p.disableFontFace||S||A)){u.save(),u.translate(i,a),u.scale(g,-g);let R;if((y===sn.FILL||y===sn.FILL_STROKE)&&(r?(R=u.getTransform(),u.setTransform(...r),u.fill(this.#n(_,R,r))):u.fill(_)),y===sn.STROKE||y===sn.FILL_STROKE)if(c){R||=u.getTransform(),u.setTransform(...c);const{a:x,b:L,c:k,d:U}=R,P=pt.inverseTransform(c),j=pt.transform([x,L,k,U,0,0],P);pt.singularValueDecompose2dScale(j,Ln),u.lineWidth*=Math.max(Ln[0],Ln[1])/g,u.stroke(this.#n(_,R,c))}else u.lineWidth/=g,u.stroke(_);u.restore()}else(y===sn.FILL||y===sn.FILL_STROKE)&&u.fillText(t,i,a),(y===sn.STROKE||y===sn.FILL_STROKE)&&u.strokeText(t,i,a);b&&(this.pendingTextPaths||=[]).push({transform:be(u),x:i,y:a,fontSize:g,path:_})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const i=t.getImageData(0,0,10,10).data;let a=!1;for(let r=3;r<i.length;r+=4)if(i[r]>0&&i[r]<255){a=!0;break}return zt(this,"isFontSubpixelAAEnabled",a)}showText(t){const i=this.current,a=i.font;if(a.isType3Font)return this.showType3Text(t);const r=i.fontSize;if(r===0)return;const c=this.ctx,u=i.fontSizeScale,h=i.charSpacing,p=i.wordSpacing,m=i.fontDirection,g=i.textHScale*m,y=t.length,b=a.vertical,S=b?1:-1,A=a.defaultVMetrics,_=r*i.fontMatrix[0],R=i.textRenderingMode===sn.FILL&&!a.disableFontFace&&!i.patternFill;c.save(),i.textMatrix&&c.transform(...i.textMatrix),c.translate(i.x,i.y+i.textRise),m>0?c.scale(g,-1):c.scale(g,1);let x,L;if(i.patternFill){c.save();const F=i.fillColor.getPattern(c,this,xi(c),qe.FILL);x=be(c),c.restore(),c.fillStyle=F}if(i.patternStroke){c.save();const F=i.strokeColor.getPattern(c,this,xi(c),qe.STROKE);L=be(c),c.restore(),c.strokeStyle=F}let k=i.lineWidth;const U=i.textMatrixScale;if(U===0||k===0){const F=i.textRenderingMode&sn.FILL_STROKE_MASK;(F===sn.STROKE||F===sn.FILL_STROKE)&&(k=this.getSinglePixelWidth())}else k/=U;if(u!==1&&(c.scale(u,u),k/=u),c.lineWidth=k,a.isInvalidPDFjsFont){const F=[];let tt=0;for(const Y of t)F.push(Y.unicode),tt+=Y.width;c.fillText(F.join(""),0,0),i.x+=tt*_*g,c.restore(),this.compose();return}let P=0,j;for(j=0;j<y;++j){const F=t[j];if(typeof F=="number"){P+=S*F*r/1e3;continue}let tt=!1;const Y=(F.isSpace?p:0)+h,st=F.fontChar,Z=F.accent;let ot,St,yt=F.width;if(b){const B=F.vmetric||A,K=-(F.vmetric?B[1]:yt*.5)*_,ut=B[2]*_;yt=B?-B[0]:yt,ot=K/u,St=(P+ut)/u}else ot=P/u,St=0;if(a.remeasure&&yt>0){const B=c.measureText(st).width*1e3/r*u;if(yt<B&&this.isFontSubpixelAAEnabled){const K=yt/B;tt=!0,c.save(),c.scale(K,1),ot/=K}else yt!==B&&(ot+=(yt-B)/2e3*r/u)}if(this.contentVisible&&(F.isInFont||a.missingFile)){if(R&&!Z)c.fillText(st,ot,St);else if(this.paintChar(st,ot,St,x,L),Z){const B=ot+r*Z.offset.x/u,K=St-r*Z.offset.y/u;this.paintChar(Z.fontChar,B,K,x,L)}}const Gt=b?yt*_-Y*m:yt*_+Y*m;P+=Gt,tt&&c.restore()}b?i.y-=P:i.x+=P*g,c.restore(),this.compose()}showType3Text(t){const i=this.ctx,a=this.current,r=a.font,c=a.fontSize,u=a.fontDirection,h=r.vertical?1:-1,p=a.charSpacing,m=a.wordSpacing,g=a.textHScale*u,y=a.fontMatrix||Of,b=t.length,S=a.textRenderingMode===sn.INVISIBLE;let A,_,R,x;if(!(S||c===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),a.textMatrix&&i.transform(...a.textMatrix),i.translate(a.x,a.y+a.textRise),i.scale(g,u),A=0;A<b;++A){if(_=t[A],typeof _=="number"){x=h*_*c/1e3,this.ctx.translate(x,0),a.x+=x*g;continue}const L=(_.isSpace?m:0)+p,k=r.charProcOperatorList[_.operatorListId];k?this.contentVisible&&(this.save(),i.scale(c,c),i.transform(...y),this.executeOperatorList(k),this.restore()):Ct(`Type3 character "${_.operatorListId}" is not available.`);const U=[_.width,0];pt.applyTransform(U,y),R=U[0]*c+L,i.translate(R,0),a.x+=R*g}i.restore()}}setCharWidth(t,i){}setCharWidthAndBounds(t,i,a,r,c,u){const h=new Path2D;h.rect(a,r,c-a,u-r),this.ctx.clip(h),this.endPath()}getColorN_Pattern(t){let i;if(t[0]==="TilingPattern"){const a=this.baseTransform||be(this.ctx),r={createCanvasGraphics:c=>new Tr(c,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};i=new Kf(t,this.ctx,r,a)}else i=this._getPattern(t[1],t[2]);return i}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,i=null){let a;return this.cachedPatterns.has(t)?a=this.cachedPatterns.get(t):(a=XM(this.getObject(t)),this.cachedPatterns.set(t,a)),i&&(a.matrix=i),a}shadingFill(t){if(!this.contentVisible)return;const i=this.ctx;this.save();const a=this._getPattern(t);i.fillStyle=a.getPattern(i,this,xi(i),qe.SHADING);const r=xi(i);if(r){const{width:c,height:u}=i.canvas,h=_r.slice();pt.axialAlignedBoundingBox([0,0,c,u],r,h);const[p,m,g,y]=h;this.ctx.fillRect(p,m,g-p,y-m)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){se("Should not call beginInlineImage")}beginImageData(){se("Should not call beginImageData")}paintFormXObjectBegin(t,i){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=be(this.ctx),i)){pt.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[a,r,c,u]=i,h=new Path2D;h.rect(a,r,c-a,u-r),this.ctx.clip(h),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;t.isolated||bu("TODO: Support non-isolated groups."),t.knockout&&Ct("Knockout groups not supported.");const a=be(i);if(t.matrix&&i.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=_r.slice();pt.axialAlignedBoundingBox(t.bbox,be(i),r);const c=[0,0,i.canvas.width,i.canvas.height];r=pt.intersect(r,c)||[0,0,0,0];const u=Math.floor(r[0]),h=Math.floor(r[1]),p=Math.max(Math.ceil(r[2])-u,1),m=Math.max(Math.ceil(r[3])-h,1);this.current.startNewPathAndClipBox([0,0,p,m]);let g="groupAt"+this.groupLevel;t.smask&&(g+="_smask_"+this.smaskCounter++%2);const y=this.cachedCanvases.getCanvas(g,p,m),b=y.context;b.translate(-u,-h),b.transform(...a);let S=new Path2D;const[A,_,R,x]=t.bbox;if(S.rect(A,_,R-A,x-_),t.matrix){const L=new Path2D;L.addPath(S,new DOMMatrix(t.matrix)),S=L}b.clip(S),t.smask?this.smaskStack.push({canvas:y.canvas,context:b,offsetX:u,offsetY:h,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(i.setTransform(1,0,0,1,0,0),i.translate(u,h),i.save()),el(i,b),this.ctx=b,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,a=this.groupStack.pop();if(this.ctx=a,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const r=be(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const c=_r.slice();pt.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],r,c),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(c)}}beginAnnotation(t,i,a,r,c){if(this.#t(),Cu(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const u=i[2]-i[0],h=i[3]-i[1];if(c&&this.annotationCanvasMap){a=a.slice(),a[4]-=i[0],a[5]-=i[1],i=i.slice(),i[0]=i[1]=0,i[2]=u,i[3]=h,pt.singularValueDecompose2dScale(be(this.ctx),Ln);const{viewportScale:p}=this,m=Math.ceil(u*this.outputScaleX*p),g=Math.ceil(h*this.outputScaleY*p);this.annotationCanvas=this.canvasFactory.create(m,g);const{canvas:y,context:b}=this.annotationCanvas;this.annotationCanvasMap.set(t,y),this.annotationCanvas.savedCtx=this.ctx,this.ctx=b,this.ctx.save(),this.ctx.setTransform(Ln[0],0,0,-Ln[1],0,h*Ln[1]),Cu(this.ctx)}else{Cu(this.ctx),this.endPath();const p=new Path2D;p.rect(i[0],i[1],u,h),this.ctx.clip(p)}}this.current=new h0(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...a),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const i=t.count;t=this.getObject(t.data,t),t.count=i;const a=this.ctx,r=this._createMaskCanvas(t),c=r.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(c,r.offsetX,r.offsetY),a.restore(),this.compose()}paintImageMaskXObjectRepeat(t,i,a=0,r=0,c,u){if(!this.contentVisible)return;t=this.getObject(t.data,t);const h=this.ctx;h.save();const p=be(h);h.transform(i,a,r,c,0,0);const m=this._createMaskCanvas(t);h.setTransform(1,0,0,1,m.offsetX-p[4],m.offsetY-p[5]);for(let g=0,y=u.length;g<y;g+=2){const b=pt.transform(p,[i,a,r,c,u[g],u[g+1]]);h.drawImage(m.canvas,b[4],b[5])}h.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const i=this.ctx,a=this.current.fillColor,r=this.current.patternFill;for(const c of t){const{data:u,width:h,height:p,transform:m}=c,g=this.cachedCanvases.getCanvas("maskCanvas",h,p),y=g.context;y.save();const b=this.getObject(u,c);p0(y,b),y.globalCompositeOperation="source-in",y.fillStyle=r?a.getPattern(y,this,xi(i),qe.FILL):a,y.fillRect(0,0,h,p),y.restore(),i.save(),i.transform(...m),i.scale(1,-1),xu(i,g.canvas,0,0,h,p,0,-1,1,1),i.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const i=this.getObject(t);if(!i){Ct("Dependent image isn't ready yet");return}this.paintInlineImageXObject(i)}paintImageXObjectRepeat(t,i,a,r){if(!this.contentVisible)return;const c=this.getObject(t);if(!c){Ct("Dependent image isn't ready yet");return}const u=c.width,h=c.height,p=[];for(let m=0,g=r.length;m<g;m+=2)p.push({transform:[i,0,0,a,r[m],r[m+1]],x:0,y:0,w:u,h});this.paintInlineImageXObjectGroup(c,p)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:i,width:a,height:r}=t,c=this.cachedCanvases.getCanvas("inlineImage",a,r),u=c.context;return u.filter=this.current.transferMaps,u.drawImage(i,0,0),u.filter="none",c.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const i=t.width,a=t.height,r=this.ctx;this.save();const{filter:c}=r;c!=="none"&&c!==""&&(r.filter="none"),r.scale(1/i,-1/a);let u;if(t.bitmap)u=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)u=t;else{const m=this.cachedCanvases.getCanvas("inlineImage",i,a).context;f0(m,t),u=this.applyTransferMapsToCanvas(m)}const h=this._scaleImage(u,xi(r));r.imageSmoothingEnabled=m0(be(r),t.interpolate),xu(r,h.img,0,0,h.paintWidth,h.paintHeight,0,-a,i,a),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,i){if(!this.contentVisible)return;const a=this.ctx;let r;if(t.bitmap)r=t.bitmap;else{const c=t.width,u=t.height,p=this.cachedCanvases.getCanvas("inlineImage",c,u).context;f0(p,t),r=this.applyTransferMapsToCanvas(p)}for(const c of i)a.save(),a.transform(...c.transform),a.scale(1,-1),xu(a,r,c.x,c.y,c.w,c.h,0,-1,1,1),a.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,i){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,i){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t,i){const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const r=this.ctx;this.pendingClip&&(a||(this.pendingClip===g0?r.clip(t,"evenodd"):r.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=be(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const i=Math.abs(t[0]*t[3]-t[2]*t[1]),a=Math.hypot(t[0],t[2]),r=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(a,r)/i}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:i,b:a,c:r,d:c}=this.ctx.getTransform();let u,h;if(a===0&&r===0){const p=Math.abs(i),m=Math.abs(c);if(p===m)if(t===0)u=h=1/p;else{const g=p*t;u=h=g<1?1/g:1}else if(t===0)u=1/p,h=1/m;else{const g=p*t,y=m*t;u=g<1?1/g:1,h=y<1?1/y:1}}else{const p=Math.abs(i*c-a*r),m=Math.hypot(i,a),g=Math.hypot(r,c);if(t===0)u=g/p,h=m/p;else{const y=t*p;u=g>y?g/y:1,h=m>y?m/y:1}}this._cachedScaleForStroking[0]=u,this._cachedScaleForStroking[1]=h}return this._cachedScaleForStroking}rescaleAndStroke(t,i){const{ctx:a,current:{lineWidth:r}}=this,[c,u]=this.getScaleForStroking();if(c===u){a.lineWidth=(r||1)*c,a.stroke(t);return}const h=a.getLineDash();i&&a.save(),a.scale(c,u),Zf.a=1/c,Zf.d=1/u;const p=new Path2D;if(p.addPath(t,Zf),h.length>0){const m=Math.max(c,u);a.setLineDash(h.map(g=>g/m)),a.lineDashOffset/=m}a.lineWidth=r||1,a.stroke(p),i&&a.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const l in mu)Tr.prototype[l]!==void 0&&(Tr.prototype[mu[l]]=Tr.prototype[l]);class wr{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}class eO{#t;#e;constructor({parsedData:t,rawData:i}){this.#t=t,this.#e=i}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}const xr=Symbol("INTERNAL");class nO{#t=!1;#e=!1;#n=!1;#i=!0;constructor(t,{name:i,intent:a,usage:r,rbGroups:c}){this.#t=!!(t&Nn.DISPLAY),this.#e=!!(t&Nn.PRINT),this.name=i,this.intent=a,this.usage=r,this.rbGroups=c}get visible(){if(this.#n)return this.#i;if(!this.#i)return!1;const{print:t,view:i}=this.usage;return this.#t?i?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,i,a=!1){t!==xr&&se("Internal method `_setVisible` called."),this.#n=a,this.#i=i}}class iO{#t=null;#e=new Map;#n=null;#i=null;constructor(t,i=Nn.DISPLAY){if(this.renderingIntent=i,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#i=t.order;for(const a of t.groups)this.#e.set(a.id,new nO(i,a));if(t.baseState==="OFF")for(const a of this.#e.values())a._setVisible(xr,!1);for(const a of t.on)this.#e.get(a)._setVisible(xr,!0);for(const a of t.off)this.#e.get(a)._setVisible(xr,!1);this.#n=this.getHash()}}#a(t){const i=t.length;if(i<2)return!0;const a=t[0];for(let r=1;r<i;r++){const c=t[r];let u;if(Array.isArray(c))u=this.#a(c);else if(this.#e.has(c))u=this.#e.get(c).visible;else return Ct(`Optional content group not found: ${c}`),!0;switch(a){case"And":if(!u)return!1;break;case"Or":if(u)return!0;break;case"Not":return!u;default:return!0}}return a==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return bu("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(Ct(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#a(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const i of t.ids){if(!this.#e.has(i))return Ct(`Optional content group not found: ${i}`),!0;if(this.#e.get(i).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const i of t.ids){if(!this.#e.has(i))return Ct(`Optional content group not found: ${i}`),!0;if(!this.#e.get(i).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const i of t.ids){if(!this.#e.has(i))return Ct(`Optional content group not found: ${i}`),!0;if(!this.#e.get(i).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const i of t.ids){if(!this.#e.has(i))return Ct(`Optional content group not found: ${i}`),!0;if(this.#e.get(i).visible)return!1}return!0}return Ct(`Unknown optional content policy ${t.policy}.`),!0}return Ct(`Unknown group type ${t.type}.`),!0}setVisibility(t,i=!0,a=!0){const r=this.#e.get(t);if(!r){Ct(`Optional content group not found: ${t}`);return}if(a&&i&&r.rbGroups.length)for(const c of r.rbGroups)for(const u of c)u!==t&&this.#e.get(u)?._setVisible(xr,!1,!0);r._setVisible(xr,!!i,!0),this.#t=null}setOCGState({state:t,preserveRB:i}){let a;for(const r of t){switch(r){case"ON":case"OFF":case"Toggle":a=r;continue}const c=this.#e.get(r);if(c)switch(a){case"ON":this.setVisibility(r,!0,i);break;case"OFF":this.setVisibility(r,!1,i);break;case"Toggle":this.setVisibility(r,!c.visible,i);break}}this.#t=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#e.size?this.#i?this.#i.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new Kv;for(const[i,a]of this.#e)t.update(`${i}:${a.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}}class sO{constructor(t,{disableRange:i=!1,disableStream:a=!1}){Me(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:c,progressiveDone:u,contentDispositionFilename:h}=t;if(this._queuedChunks=[],this._progressiveDone=u,this._contentDispositionFilename=h,c?.length>0){const p=c instanceof Uint8Array&&c.byteLength===c.buffer.byteLength?c.buffer:new Uint8Array(c).buffer;this._queuedChunks.push(p)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!a,this._isRangeSupported=!i,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((p,m)=>{this._onReceiveData({begin:p,chunk:m})}),t.addProgressListener((p,m)=>{this._onProgress({loaded:p,total:m})}),t.addProgressiveReadListener(p=>{this._onReceiveData({chunk:p})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:i}){const a=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(a):this._queuedChunks.push(a);else{const r=this._rangeReaders.some(function(c){return c._begin!==t?!1:(c._enqueue(a),!0)});Me(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const i=this._rangeReaders.indexOf(t);i>=0&&this._rangeReaders.splice(i,1)}getFullReader(){Me(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new aO(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,i){if(i<=this._progressiveDataLength)return null;const a=new rO(this,t,i);return this._pdfDataRangeTransport.requestDataRange(t,i),this._rangeReaders.push(a),a}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const i of this._rangeReaders.slice(0))i.cancel(t);this._pdfDataRangeTransport.abort()}}class aO{constructor(t,i,a=!1,r=null){this._stream=t,this._done=a||!1,this._filename=Hf(r)?r:null,this._queuedChunks=i||[],this._loaded=0;for(const c of this._queuedChunks)this._loaded+=c.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class rO{constructor(t,i,a){this._stream=t,this._begin=i,this._end=a,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const a of this._requests)a.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const i=this._queuedChunk;return this._queuedChunk=null,{value:i,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function oO(l){let t=!0,i=a("filename\\*","i").exec(l);if(i){i=i[1];let g=h(i);return g=unescape(g),g=p(g),g=m(g),c(g)}if(i=u(l),i){const g=m(i);return c(g)}if(i=a("filename","i").exec(l),i){i=i[1];let g=h(i);return g=m(g),c(g)}function a(g,y){return new RegExp("(?:^|;)\\s*"+g+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',y)}function r(g,y){if(g){if(!/^[\x00-\xFF]+$/.test(y))return y;try{const b=new TextDecoder(g,{fatal:!0}),S=Yo(y);y=b.decode(S),t=!1}catch{}}return y}function c(g){return t&&/[\x80-\xff]/.test(g)&&(g=r("utf-8",g),t&&(g=r("iso-8859-1",g))),g}function u(g){const y=[];let b;const S=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(b=S.exec(g))!==null;){let[,_,R,x]=b;if(_=parseInt(_,10),_ in y){if(_===0)break;continue}y[_]=[R,x]}const A=[];for(let _=0;_<y.length&&_ in y;++_){let[R,x]=y[_];x=h(x),R&&(x=unescape(x),_===0&&(x=p(x))),A.push(x)}return A.join("")}function h(g){if(g.startsWith('"')){const y=g.slice(1).split('\\"');for(let b=0;b<y.length;++b){const S=y[b].indexOf('"');S!==-1&&(y[b]=y[b].slice(0,S),y.length=b+1),y[b]=y[b].replaceAll(/\\(.)/g,"$1")}g=y.join('"')}return g}function p(g){const y=g.indexOf("'");if(y===-1)return g;const b=g.slice(0,y),A=g.slice(y+1).replace(/^[^']*'/,"");return r(b,A)}function m(g){return!g.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(g)?g:g.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(y,b,S,A){if(S==="q"||S==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(_,R){return String.fromCharCode(parseInt(R,16))}),r(b,A);try{A=atob(A)}catch{}return r(b,A)})}return""}function y0(l,t){const i=new Headers;if(!l||!t||typeof t!="object")return i;for(const a in t){const r=t[a];r!==void 0&&i.append(a,r)}return i}function Ru(l){return URL.parse(l)?.origin??null}function b0({responseHeaders:l,isHttp:t,rangeChunkSize:i,disableRange:a}){const r={allowRangeRequests:!1,suggestedLength:void 0},c=parseInt(l.get("Content-Length"),10);return!Number.isInteger(c)||(r.suggestedLength=c,c<=2*i)||a||!t||l.get("Accept-Ranges")!=="bytes"||(l.get("Content-Encoding")||"identity")!=="identity"||(r.allowRangeRequests=!0),r}function v0(l){const t=l.get("Content-Disposition");if(t){let i=oO(t);if(i.includes("%"))try{i=decodeURIComponent(i)}catch{}if(Hf(i))return i}return null}function nl(l,t){return new vu(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l,l===404||l===0&&t.startsWith("file:"))}function S0(l){return l===200||l===206}function E0(l,t,i){return{method:"GET",headers:l,signal:i.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function A0(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(Ct(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class lO{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=y0(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Me(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new cO(this),this._fullRequestReader}getRangeReader(t,i){if(i<=this._progressiveDataLength)return null;const a=new uO(this,t,i);return this._rangeRequestReaders.push(a),a}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class cO{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const i=t.source;this._withCredentials=i.withCredentials||!1,this._contentLength=i.length,this._headersCapability=Promise.withResolvers(),this._disableRange=i.disableRange||!1,this._rangeChunkSize=i.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!i.disableStream,this._isRangeSupported=!i.disableRange;const a=new Headers(t.headers),r=i.url;fetch(r,E0(a,this._withCredentials,this._abortController)).then(c=>{if(t._responseOrigin=Ru(c.url),!S0(c.status))throw nl(c.status,r);this._reader=c.body.getReader(),this._headersCapability.resolve();const u=c.headers,{allowRangeRequests:h,suggestedLength:p}=b0({responseHeaders:u,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=h,this._contentLength=p||this._contentLength,this._filename=v0(u),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Is("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:i}=await this._reader.read();return i?{value:t,done:i}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:A0(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class uO{constructor(t,i,a){this._stream=t,this._reader=null,this._loaded=0;const r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const c=new Headers(t.headers);c.append("Range",`bytes=${i}-${a-1}`);const u=r.url;fetch(u,E0(c,this._withCredentials,this._abortController)).then(h=>{const p=Ru(h.url);if(p!==t._responseOrigin)throw new Error(`Expected range response-origin "${p}" to match "${t._responseOrigin}".`);if(!S0(h.status))throw nl(h.status,u);this._readCapability.resolve(),this._reader=h.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:i}=await this._reader.read();return i?{value:t,done:i}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:A0(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const Jf=200,tp=206;function dO(l){const t=l.response;return typeof t!="string"?t:Yo(t).buffer}class hO{_responseOrigin=null;constructor({url:t,httpHeaders:i,withCredentials:a}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=y0(this.isHttp,i),this.withCredentials=a||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const i=new XMLHttpRequest,a=this.currXhrId++,r=this.pendingRequests[a]={xhr:i};i.open("GET",this.url),i.withCredentials=this.withCredentials;for(const[c,u]of this.headers)i.setRequestHeader(c,u);return this.isHttp&&"begin"in t&&"end"in t?(i.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=tp):r.expectedStatus=Jf,i.responseType="arraybuffer",Me(t.onError,"Expected `onError` callback to be provided."),i.onerror=()=>{t.onError(i.status)},i.onreadystatechange=this.onStateChange.bind(this,a),i.onprogress=this.onProgress.bind(this,a),r.onHeadersReceived=t.onHeadersReceived,r.onDone=t.onDone,r.onError=t.onError,r.onProgress=t.onProgress,i.send(null),a}onProgress(t,i){const a=this.pendingRequests[t];a&&a.onProgress?.(i)}onStateChange(t,i){const a=this.pendingRequests[t];if(!a)return;const r=a.xhr;if(r.readyState>=2&&a.onHeadersReceived&&(a.onHeadersReceived(),delete a.onHeadersReceived),r.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],r.status===0&&this.isHttp){a.onError(r.status);return}const c=r.status||Jf;if(!(c===Jf&&a.expectedStatus===tp)&&c!==a.expectedStatus){a.onError(r.status);return}const h=dO(r);if(c===tp){const p=r.getResponseHeader("Content-Range"),m=/bytes (\d+)-(\d+)\/(\d+)/.exec(p);m?a.onDone({begin:parseInt(m[1],10),chunk:h}):(Ct('Missing or invalid "Content-Range" header.'),a.onError(0))}else h?a.onDone({begin:0,chunk:h}):a.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const i=this.pendingRequests[t].xhr;delete this.pendingRequests[t],i.abort()}}class fO{constructor(t){this._source=t,this._manager=new hO(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const i=this._rangeRequestReaders.indexOf(t);i>=0&&this._rangeRequestReaders.splice(i,1)}getFullReader(){return Me(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new pO(this._manager,this._source),this._fullRequestReader}getRangeReader(t,i){const a=new mO(this._manager,t,i);return a.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(a),a}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class pO{constructor(t,i){this._manager=t,this._url=i.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=i.disableRange||!1,this._contentLength=i.length,this._rangeChunkSize=i.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,i=this._manager.getRequestXhr(t);this._manager._responseOrigin=Ru(i.responseURL);const a=i.getAllResponseHeaders(),r=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{const[p,...m]=h.split(": ");return[p,m.join(": ")]}):[]),{allowRangeRequests:c,suggestedLength:u}=b0({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});c&&(this._isRangeSupported=!0),this._contentLength=u||this._contentLength,this._filename=v0(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=nl(t,this._url),this._headersCapability.reject(this._storedError);for(const i of this._requests)i.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class mO{constructor(t,i,a){this._manager=t,this._url=t.url,this._requestId=t.request({begin:i,end:a,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Ru(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const i=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:i,done:!1}):this._queuedChunk=i,this._done=!0;for(const a of this._requests)a.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=nl(t,this._url);for(const i of this._requests)i.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const i=this._queuedChunk;return this._queuedChunk=null,{value:i,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const gO=/^[a-z][a-z0-9\-+.]+:/i;function yO(l){if(gO.test(l))return new URL(l);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(l))}class bO{constructor(t){this.source=t,this.url=yO(t.url),Me(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Me(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new vO(this),this._fullRequestReader}getRangeReader(t,i){if(i<=this._progressiveDataLength)return null;const a=new SO(this,t,i);return this._rangeRequestReaders.push(a),a}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class vO{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const i=t.source;this._contentLength=i.length,this._loaded=0,this._filename=null,this._disableRange=i.disableRange||!1,this._rangeChunkSize=i.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!i.disableStream,this._isRangeSupported=!i.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const a=process.getBuiltinModule("fs");a.promises.lstat(this._url).then(r=>{this._contentLength=r.size,this._setReadableStream(a.createReadStream(this._url)),this._headersCapability.resolve()},r=>{r.code==="ENOENT"&&(r=nl(0,this._url.href)),this._storedError=r,this._headersCapability.reject(r)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",i=>{this._error(i)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Is("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class SO{constructor(t,i,a){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=t.source;this._isStreamingSupported=!r.disableStream;const c=process.getBuiltinModule("fs");this._setReadableStream(c.createReadStream(this._url,{start:i,end:a-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",i=>{this._error(i)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const il=Symbol("INITIAL_DATA");class _0{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:il}}get(t,i=null){if(i){const r=this.#e(t);return r.promise.then(()=>i(r.data)),null}const a=this.#t[t];if(!a||a.data===il)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return a.data}has(t){const i=this.#t[t];return!!i&&i.data!==il}delete(t){const i=this.#t[t];return!i||i.data===il?!1:(delete this.#t[t],!0)}resolve(t,i=null){const a=this.#e(t);a.data=i,a.resolve()}clear(){for(const t in this.#t){const{data:i}=this.#t[t];i?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:i}=this.#t[t];i!==il&&(yield[t,i])}}}const EO=1e5,T0=30;class hn{#t=Promise.withResolvers();#e=null;#n=!1;#i=!!globalThis.FontInspector?.enabled;#a=null;#s=null;#r=0;#o=0;#u=null;#c=null;#h=0;#l=0;#p=Object.create(null);#g=[];#f=null;#d=[];#m=new WeakMap;#v=null;static#y=new Map;static#E=new Map;static#A=new WeakMap;static#b=null;static#T=new Set;constructor({textContentSource:t,container:i,viewport:a}){if(t instanceof ReadableStream)this.#f=t;else if(typeof t=="object")this.#f=new ReadableStream({start(p){p.enqueue(t),p.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#c=i,this.#l=a.scale*Ci.pixelRatio,this.#h=a.rotation,this.#s={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:c,pageX:u,pageY:h}=a.rawDims;this.#v=[1,0,0,-1,-u,h+c],this.#o=r,this.#r=c,hn.#x(),Aa(i,a),this.#t.promise.finally(()=>{hn.#T.delete(this),this.#s=null,this.#p=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:i}=Ve.platform;return zt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&i?"Calibri, ":""}sans-serif`],["monospace",`${t&&i?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{this.#u.read().then(({value:i,done:a})=>{if(a){this.#t.resolve();return}this.#a??=i.lang,Object.assign(this.#p,i.styles),this.#D(i.items),t()},this.#t.reject)};return this.#u=this.#f.getReader(),hn.#T.add(this),t(),this.#t.promise}update({viewport:t,onBefore:i=null}){const a=t.scale*Ci.pixelRatio,r=t.rotation;if(r!==this.#h&&(i?.(),this.#h=r,Aa(this.#c,{rotation:r})),a!==this.#l){i?.(),this.#l=a;const c={div:null,properties:null,ctx:hn.#R(this.#a)};for(const u of this.#d)c.properties=this.#m.get(u),c.div=u,this.#M(c)}}cancel(){const t=new Is("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#d}get textContentItemsStr(){return this.#g}#D(t){if(this.#n)return;this.#s.ctx??=hn.#R(this.#a);const i=this.#d,a=this.#g;for(const r of t){if(i.length>EO){Ct("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const c=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),r.id&&this.#e.setAttribute("id",`${r.id}`),c.append(this.#e)}else r.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}a.push(r.str),this.#_(r)}}#_(t){const i=document.createElement("span"),a={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#d.push(i);const r=pt.transform(this.#v,t.transform);let c=Math.atan2(r[1],r[0]);const u=this.#p[t.fontName];u.vertical&&(c+=Math.PI/2);let h=this.#i&&u.fontSubstitution||u.fontFamily;h=hn.fontFamilyMap.get(h)||h;const p=Math.hypot(r[2],r[3]),m=p*hn.#k(h,u,this.#a);let g,y;c===0?(g=r[4],y=r[5]-m):(g=r[4]+m*Math.sin(c),y=r[5]-m*Math.cos(c));const b="calc(var(--total-scale-factor) *",S=i.style;this.#e===this.#c?(S.left=`${(100*g/this.#o).toFixed(2)}%`,S.top=`${(100*y/this.#r).toFixed(2)}%`):(S.left=`${b}${g.toFixed(2)}px)`,S.top=`${b}${y.toFixed(2)}px)`),S.fontSize=`${b}${(hn.#b*p).toFixed(2)}px)`,S.fontFamily=h,a.fontSize=p,i.setAttribute("role","presentation"),i.textContent=t.str,i.dir=t.dir,this.#i&&(i.dataset.fontName=u.fontSubstitutionLoadedName||t.fontName),c!==0&&(a.angle=c*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const _=Math.abs(t.transform[0]),R=Math.abs(t.transform[3]);_!==R&&Math.max(_,R)/Math.min(_,R)>1.5&&(A=!0)}if(A&&(a.canvasWidth=u.vertical?t.height:t.width),this.#m.set(i,a),this.#s.div=i,this.#s.properties=a,this.#M(this.#s),a.hasText&&this.#e.append(i),a.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),this.#e.append(_)}}#M(t){const{div:i,properties:a,ctx:r}=t,{style:c}=i;let u="";if(hn.#b>1&&(u=`scale(${1/hn.#b})`),a.canvasWidth!==0&&a.hasText){const{fontFamily:h}=c,{canvasWidth:p,fontSize:m}=a;hn.#C(r,m*this.#l,h);const{width:g}=r.measureText(i.textContent);g>0&&(u=`scaleX(${p*this.#l/g}) ${u}`)}a.angle!==0&&(u=`rotate(${a.angle}deg) ${u}`),u.length>0&&(c.transform=u)}static cleanup(){if(!(this.#T.size>0)){this.#y.clear();for(const{canvas:t}of this.#E.values())t.remove();this.#E.clear()}}static#R(t=null){let i=this.#E.get(t||="");if(!i){const a=document.createElement("canvas");a.className="hiddenCanvasElement",a.lang=t,document.body.append(a),i=a.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#E.set(t,i),this.#A.set(i,{size:0,family:""})}return i}static#C(t,i,a){const r=this.#A.get(t);i===r.size&&a===r.family||(t.font=`${i}px ${a}`,r.size=i,r.family=a)}static#x(){if(this.#b!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#b=t.getBoundingClientRect().height,t.remove()}static#k(t,i,a){const r=this.#y.get(t);if(r)return r;const c=this.#R(a);c.canvas.width=c.canvas.height=T0,this.#C(c,T0,t);const u=c.measureText(""),h=u.fontBoundingBoxAscent,p=Math.abs(u.fontBoundingBoxDescent);c.canvas.width=c.canvas.height=0;let m=.8;return h?m=h/(h+p):(Ve.platform.isFirefox&&Ct("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),i.ascent?m=i.ascent:i.descent&&(m=1+i.descent)),this.#y.set(t,m),m}}class sl{static textContent(t){const i=[],a={items:i,styles:Object.create(null)};function r(c){if(!c)return;let u=null;const h=c.name;if(h==="#text")u=c.value;else if(sl.shouldBuildText(h))c?.attributes?.textContent?u=c.attributes.textContent:c.value&&(u=c.value);else return;if(u!==null&&i.push({str:u}),!!c.children)for(const p of c.children)r(p)}return r(t),a}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const AO=100;function w0(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new ep,{docId:i}=t,a=l.url?OM(l.url):null,r=l.data?kM(l.data):null,c=l.httpHeaders||null,u=l.withCredentials===!0,h=l.password??null,p=l.range instanceof x0?l.range:null,m=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:2**16;let g=l.worker instanceof al?l.worker:null;const y=l.verbosity,b=typeof l.docBaseUrl=="string"&&!Su(l.docBaseUrl)?l.docBaseUrl:null,S=Tu(l.cMapUrl),A=l.cMapPacked!==!1,_=l.CMapReaderFactory||(un?BM:n0),R=Tu(l.iccUrl),x=Tu(l.standardFontDataUrl),L=l.StandardFontDataFactory||(un?FM:a0),k=Tu(l.wasmUrl),U=l.WasmFactory||(un?jM:o0),P=l.stopAtErrors!==!0,j=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,F=l.isEvalSupported!==!1,tt=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!un,Y=typeof l.isImageDecoderSupported=="boolean"?l.isImageDecoderSupported:!un&&(Ve.platform.isFirefox||!globalThis.chrome),st=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,Z=typeof l.disableFontFace=="boolean"?l.disableFontFace:un,ot=l.fontExtraProperties===!0,St=l.enableXfa===!0,yt=l.ownerDocument||globalThis.document,Gt=l.disableRange===!0,B=l.disableStream===!0,K=l.disableAutoFetch===!0,ut=l.pdfBug===!0,wt=l.CanvasFactory||(un?HM:PM),W=l.FilterFactory||(un?zM:UM),dt=l.enableHWA===!0,Q=l.useWasm!==!1,vt=p?p.length:l.length??NaN,Vt=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!un&&!Z,ae=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:!!(_===n0&&L===a0&&U===o0&&S&&x&&k&&Ko(S,document.baseURI)&&Ko(x,document.baseURI)&&Ko(k,document.baseURI)),At=null;cM(y);const Wt={canvasFactory:new wt({ownerDocument:yt,enableHWA:dt}),filterFactory:new W({docId:i,ownerDocument:yt}),cMapReaderFactory:ae?null:new _({baseUrl:S,isCompressed:A}),standardFontDataFactory:ae?null:new L({baseUrl:x}),wasmFactory:ae?null:new U({baseUrl:k})};g||(g=al.create({verbosity:y,port:wr.workerPort}),t._worker=g);const Kt={docId:i,apiVersion:"5.4.54",data:r,password:h,disableAutoFetch:K,rangeChunkSize:m,length:vt,docBaseUrl:b,enableXfa:St,evaluatorOptions:{maxImageSize:j,disableFontFace:Z,ignoreErrors:P,isEvalSupported:F,isOffscreenCanvasSupported:tt,isImageDecoderSupported:Y,canvasMaxAreaInBytes:st,fontExtraProperties:ot,useSystemFonts:Vt,useWasm:Q,useWorkerFetch:ae,cMapUrl:S,iccUrl:R,standardFontDataUrl:x,wasmUrl:k}},Te={ownerDocument:yt,pdfBug:ut,styleElement:At,loadingParams:{disableAutoFetch:K,enableXfa:St}};return g.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(g.destroyed)throw new Error("Worker was destroyed");const Ye=g.messageHandler.sendWithPromise("GetDocRequest",Kt,r?[r.buffer]:null);let In;if(p)In=new sO(p,{disableRange:Gt,disableStream:B});else if(!r){if(!a)throw new Error("getDocument - no `url` parameter provided.");const ns=Ko(a)?lO:un?bO:fO;In=new ns({url:a,length:vt,httpHeaders:c,withCredentials:u,rangeChunkSize:m,disableRange:Gt,disableStream:B})}return Ye.then(ns=>{if(t.destroyed)throw new Error("Loading aborted");if(g.destroyed)throw new Error("Worker was destroyed");const pi=new tl(i,ns,g.port),Mr=new wO(pi,t,In,Te,Wt,dt);t._transport=Mr,pi.send("Ready",null)})}).catch(t._capability.reject),t}class ep{static#t=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${ep.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class x0{#t=Promise.withResolvers();#e=[];#n=[];#i=[];#a=[];constructor(t,i,a=!1,r=null){this.length=t,this.initialData=i,this.progressiveDone=a,this.contentDispositionFilename=r}addRangeListener(t){this.#a.push(t)}addProgressListener(t){this.#i.push(t)}addProgressiveReadListener(t){this.#n.push(t)}addProgressiveDoneListener(t){this.#e.push(t)}onDataRange(t,i){for(const a of this.#a)a(t,i)}onDataProgress(t,i){this.#t.promise.then(()=>{for(const a of this.#i)a(t,i)})}onDataProgressiveRead(t){this.#t.promise.then(()=>{for(const i of this.#n)i(t)})}onDataProgressiveDone(){this.#t.promise.then(()=>{for(const t of this.#e)t()})}transportReady(){this.#t.resolve()}requestDataRange(t,i){se("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class _O{constructor(t,i){this._pdfInfo=t,this._transport=i}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return zt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:i}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(i)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class TO{#t=!1;constructor(t,i,a,r=!1){this._pageIndex=t,this._pageInfo=i,this._transport=a,this._stats=r?new Yv:null,this._pdfBug=r,this.commonObjs=a.commonObjs,this.objs=new _0,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:i=this.rotate,offsetX:a=0,offsetY:r=0,dontFlip:c=!1}={}){return new Qo({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:i,offsetX:a,offsetY:r,dontFlip:c})}getAnnotations({intent:t="display"}={}){const{renderingIntent:i}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,i)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return zt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:i=t.canvas,viewport:a,intent:r="display",annotationMode:c=Ls.ENABLE,transform:u=null,background:h=null,optionalContentConfigPromise:p=null,annotationCanvasMap:m=null,pageColors:g=null,printAnnotationStorage:y=null,isEditing:b=!1}){this._stats?.time("Overall");const S=this._transport.getRenderingIntent(r,c,y,b),{renderingIntent:A,cacheKey:_}=S;this.#t=!1,p||=this._transport.getOptionalContentConfig(A);let R=this._intentStates.get(_);R||(R=Object.create(null),this._intentStates.set(_,R)),R.streamReaderCancelTimeout&&(clearTimeout(R.streamReaderCancelTimeout),R.streamReaderCancelTimeout=null);const x=!!(A&Nn.PRINT);R.displayReadyCapability||(R.displayReadyCapability=Promise.withResolvers(),R.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(S));const L=P=>{R.renderTasks.delete(k),x&&(this.#t=!0),this.#e(),P?(k.capability.reject(P),this._abortOperatorList({intentState:R,reason:P instanceof Error?P:new Error(P)})):k.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},k=new Cr({callback:L,params:{canvas:i,canvasContext:t,viewport:a,transform:u,background:h},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:m,operatorList:R.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!x,pdfBug:this._pdfBug,pageColors:g,enableHWA:this._transport.enableHWA});(R.renderTasks||=new Set).add(k);const U=k.task;return Promise.all([R.displayReadyCapability.promise,p]).then(([P,j])=>{if(this.destroyed){L();return}if(this._stats?.time("Rendering"),!(j.renderingIntent&A))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");k.initializeGraphics({transparency:P,optionalContentConfig:j}),k.operatorListChanged()}).catch(L),U}getOperatorList({intent:t="display",annotationMode:i=Ls.ENABLE,printAnnotationStorage:a=null,isEditing:r=!1}={}){function c(){h.operatorList.lastChunk&&(h.opListReadCapability.resolve(h.operatorList),h.renderTasks.delete(p))}const u=this._transport.getRenderingIntent(t,i,a,r,!0);let h=this._intentStates.get(u.cacheKey);h||(h=Object.create(null),this._intentStates.set(u.cacheKey,h));let p;return h.opListReadCapability||(p=Object.create(null),p.operatorListChanged=c,h.opListReadCapability=Promise.withResolvers(),(h.renderTasks||=new Set).add(p),h.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u)),h.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:i=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:i===!0},{highWaterMark:100,size(r){return r.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(a=>sl.textContent(a));const i=this.streamTextContent(t);return new Promise(function(a,r){function c(){u.read().then(function({value:p,done:m}){if(m){a(h);return}h.lang??=p.lang,Object.assign(h.styles,p.styles),h.items.push(...p.items),c()},r)}const u=i.getReader(),h={items:[],styles:Object.create(null),lang:null};c()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const i of this._intentStates.values())if(this._abortOperatorList({intentState:i,reason:new Error("Page was destroyed."),force:!0}),!i.opListReadCapability)for(const a of i.renderTasks)t.push(a.completed),a.cancel();return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;const i=this.#e();return t&&i&&(this._stats&&=new Yv),i}#e(){if(!this.#t||this.destroyed)return!1;for(const{renderTasks:t,operatorList:i}of this._intentStates.values())if(t.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}_startRenderPage(t,i){const a=this._intentStates.get(i);a&&(this._stats?.timeEnd("Page Request"),a.displayReadyCapability?.resolve(t))}_renderPageChunk(t,i){for(let a=0,r=t.length;a<r;a++)i.operatorList.fnArray.push(t.fnArray[a]),i.operatorList.argsArray.push(t.argsArray[a]);i.operatorList.lastChunk=t.lastChunk,i.operatorList.separateAnnots=t.separateAnnots;for(const a of i.renderTasks)a.operatorListChanged();t.lastChunk&&this.#e()}_pumpOperatorList({renderingIntent:t,cacheKey:i,annotationStorageSerializable:a,modifiedIds:r}){const{map:c,transfer:u}=a,p=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:i,annotationStorage:c,modifiedIds:r},u).getReader(),m=this._intentStates.get(i);m.streamReader=p;const g=()=>{p.read().then(({value:y,done:b})=>{if(b){m.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(y,m),g())},y=>{if(m.streamReader=null,!this._transport.destroyed){if(m.operatorList){m.operatorList.lastChunk=!0;for(const b of m.renderTasks)b.operatorListChanged();this.#e()}if(m.displayReadyCapability)m.displayReadyCapability.reject(y);else if(m.opListReadCapability)m.opListReadCapability.reject(y);else throw y}})};g()}_abortOperatorList({intentState:t,reason:i,force:a=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!a){if(t.renderTasks.size>0)return;if(i instanceof zf){let r=AO;i.extraDelay>0&&i.extraDelay<1e3&&(r+=i.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:i,force:!0})},r);return}}if(t.streamReader.cancel(new Is(i.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[r,c]of this._intentStates)if(c===t){this._intentStates.delete(r);break}this.cleanup()}}}get stats(){return this._stats}}const pe=class pe{constructor({name:t=null,port:i=null,verbosity:a=uM()}={}){Yi(this,fn);Yi(this,Us,Promise.withResolvers());Yi(this,fi,null);Yi(this,es,null);Yi(this,xa,null);if(this.name=t,this.destroyed=!1,this.verbosity=a,i){if(ye(pe,Ra).has(i))throw new Error("Cannot use more than one PDFWorker per port.");ye(pe,Ra).set(i,this),Wi(this,fn,K1).call(this,i)}else Wi(this,fn,Z1).call(this)}get promise(){return ye(this,Us).promise}get port(){return ye(this,es)}get messageHandler(){return ye(this,fi)}destroy(){this.destroyed=!0,ye(this,xa)?.terminate(),kn(this,xa,null),ye(pe,Ra).delete(ye(this,es)),kn(this,es,null),ye(this,fi)?.destroy(),kn(this,fi,null)}static create(t){const i=ye(this,Ra).get(t?.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new pe(t)}static get workerSrc(){if(wr.workerSrc)return wr.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return zt(this,"_setupFakeWorkerGlobal",(async()=>ye(this,Dr,kh)?ye(this,Dr,kh):(await import(this.workerSrc)).WorkerMessageHandler)())}};Us=new WeakMap,fi=new WeakMap,es=new WeakMap,xa=new WeakMap,Lu=new WeakMap,Ca=new WeakMap,Ra=new WeakMap,fn=new WeakSet,Oh=function(){ye(this,Us).resolve(),ye(this,fi).send("configure",{verbosity:this.verbosity})},K1=function(t){kn(this,es,t),kn(this,fi,new tl("main","worker",t)),ye(this,fi).on("ready",()=>{}),Wi(this,fn,Oh).call(this)},Z1=function(){if(ye(pe,Ca)||ye(pe,Dr,kh)){Wi(this,fn,zc).call(this);return}let{workerSrc:t}=pe;try{pe._isSameOrigin(window.location,t)||(t=pe._createCDNWrapper(new URL(t,window.location).href));const i=new Worker(t,{type:"module"}),a=new tl("main","worker",i),r=()=>{c.abort(),a.destroy(),i.terminate(),this.destroyed?ye(this,Us).reject(new Error("Worker was destroyed")):Wi(this,fn,zc).call(this)},c=new AbortController;i.addEventListener("error",()=>{ye(this,xa)||r()},{signal:c.signal}),a.on("test",h=>{if(c.abort(),this.destroyed||!h){r();return}kn(this,fi,a),kn(this,es,i),kn(this,xa,i),Wi(this,fn,Oh).call(this)}),a.on("ready",h=>{if(c.abort(),this.destroyed){r();return}try{u()}catch{Wi(this,fn,zc).call(this)}});const u=()=>{const h=new Uint8Array;a.send("test",h,[h.buffer])};u();return}catch{bu("The worker has been disabled.")}Wi(this,fn,zc).call(this)},zc=function(){ye(pe,Ca)||(Ct("Setting up fake worker."),kn(pe,Ca,!0)),pe._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){ye(this,Us).reject(new Error("Worker was destroyed"));return}const i=new IM;kn(this,es,i);const a=`fake${Q1(pe,Lu)._++}`,r=new tl(a+"_worker",a,i);t.setup(r,i),kn(this,fi,new tl(a,a+"_worker",i)),Wi(this,fn,Oh).call(this)}).catch(t=>{ye(this,Us).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Dr=new WeakSet,kh=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}},Yi(pe,Dr),Yi(pe,Lu,0),Yi(pe,Ca,!1),Yi(pe,Ra,new WeakMap),un&&(kn(pe,Ca,!0),wr.workerSrc||="./pdf.worker.mjs"),pe._isSameOrigin=(t,i)=>{const a=URL.parse(t);if(!a?.origin||a.origin==="null")return!1;const r=new URL(i,a);return a.origin===r.origin},pe._createCDNWrapper=t=>{const i=`await import("${t}");`;return URL.createObjectURL(new Blob([i],{type:"text/javascript"}))},pe.fromPort=t=>{if(AM("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return pe.create(t)};let al=pe;class wO{#t=new Map;#e=new Map;#n=new Map;#i=new Map;#a=null;constructor(t,i,a,r,c,u){this.messageHandler=t,this.loadingTask=i,this.commonObjs=new _0,this.fontLoader=new DM({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=c.canvasFactory,this.filterFactory=c.filterFactory,this.cMapReaderFactory=c.cMapReaderFactory,this.standardFontDataFactory=c.standardFontDataFactory,this.wasmFactory=c.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=a,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=u,this.setupMessageHandler()}#s(t,i=null){const a=this.#t.get(t);if(a)return a;const r=this.messageHandler.sendWithPromise(t,i);return this.#t.set(t,r),r}get annotationStorage(){return zt(this,"annotationStorage",new Vf)}getRenderingIntent(t,i=Ls.ENABLE,a=null,r=!1,c=!1){let u=Nn.DISPLAY,h=Gf;switch(t){case"any":u=Nn.ANY;break;case"display":break;case"print":u=Nn.PRINT;break;default:Ct(`getRenderingIntent - invalid intent: ${t}`)}const p=u&Nn.PRINT&&a instanceof Zv?a:this.annotationStorage;switch(i){case Ls.DISABLE:u+=Nn.ANNOTATIONS_DISABLE;break;case Ls.ENABLE:break;case Ls.ENABLE_FORMS:u+=Nn.ANNOTATIONS_FORMS;break;case Ls.ENABLE_STORAGE:u+=Nn.ANNOTATIONS_STORAGE,h=p.serializable;break;default:Ct(`getRenderingIntent - invalid annotationMode: ${i}`)}r&&(u+=Nn.IS_EDITING),c&&(u+=Nn.OPLIST);const{ids:m,hash:g}=p.modifiedIds,y=[u,h.hash,g];return{renderingIntent:u,cacheKey:y.join("_"),annotationStorageSerializable:h,modifiedIds:m}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#a?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const a of this.#e.values())t.push(a._destroy());this.#e.clear(),this.#n.clear(),this.#i.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const i=this.messageHandler.sendWithPromise("Terminate",null);return t.push(i),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),hn.cleanup(),this._networkStream?.cancelAllRequests(new Is("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:i}=this;t.on("GetReader",(a,r)=>{Me(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=c=>{this._lastProgress={loaded:c.loaded,total:c.total}},r.onPull=()=>{this._fullReader.read().then(function({value:c,done:u}){if(u){r.close();return}Me(c instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(c),1,[c])}).catch(c=>{r.error(c)})},r.onCancel=c=>{this._fullReader.cancel(c),r.ready.catch(u=>{if(!this.destroyed)throw u})}}),t.on("ReaderHeadersReady",async a=>{await this._fullReader.headersReady;const{isStreamingSupported:r,isRangeSupported:c,contentLength:u}=this._fullReader;return(!r||!c)&&(this._lastProgress&&i.onProgress?.(this._lastProgress),this._fullReader.onProgress=h=>{i.onProgress?.({loaded:h.loaded,total:h.total})}),{isStreamingSupported:r,isRangeSupported:c,contentLength:u}}),t.on("GetRangeReader",(a,r)=>{Me(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const c=this._networkStream.getRangeReader(a.begin,a.end);if(!c){r.close();return}r.onPull=()=>{c.read().then(function({value:u,done:h}){if(h){r.close();return}Me(u instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(u),1,[u])}).catch(u=>{r.error(u)})},r.onCancel=u=>{c.cancel(u),r.ready.catch(h=>{if(!this.destroyed)throw h})}}),t.on("GetDoc",({pdfInfo:a})=>{this._numPages=a.numPages,this._htmlForXfa=a.htmlForXfa,delete a.htmlForXfa,i._capability.resolve(new _O(a,this))}),t.on("DocException",a=>{i._capability.reject(An(a))}),t.on("PasswordRequest",a=>{this.#a=Promise.withResolvers();try{if(!i.onPassword)throw An(a);const r=c=>{c instanceof Error?this.#a.reject(c):this.#a.resolve({password:c})};i.onPassword(r,a.code)}catch(r){this.#a.reject(r)}return this.#a.promise}),t.on("DataLoaded",a=>{i.onProgress?.({loaded:a.length,total:a.length}),this.downloadInfoCapability.resolve(a)}),t.on("StartRenderPage",a=>{if(this.destroyed)return;this.#e.get(a.pageIndex)._startRenderPage(a.transparency,a.cacheKey)}),t.on("commonobj",([a,r,c])=>{if(this.destroyed||this.commonObjs.has(a))return null;switch(r){case"Font":if("error"in c){const m=c.error;Ct(`Error during font loading: ${m}`),this.commonObjs.resolve(a,m);break}const u=this._params.pdfBug&&globalThis.FontInspector?.enabled?(m,g)=>globalThis.FontInspector.fontAdded(m,g):null,h=new MM(c,u);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:a})).finally(()=>{!h.fontExtraProperties&&h.data&&(h.data=null),this.commonObjs.resolve(a,h)});break;case"CopyLocalImage":const{imageRef:p}=c;Me(p,"The imageRef must be defined.");for(const m of this.#e.values())for(const[,g]of m.objs)if(g?.ref===p)return g.dataLen?(this.commonObjs.resolve(a,structuredClone(g)),g.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(a,c);break;default:throw new Error(`Got unknown common object type ${r}`)}return null}),t.on("obj",([a,r,c,u])=>{if(this.destroyed)return;const h=this.#e.get(r);if(!h.objs.has(a)){if(h._intentStates.size===0){u?.bitmap?.close();return}switch(c){case"Image":case"Pattern":h.objs.resolve(a,u);break;default:throw new Error(`Got unknown object type ${c}`)}}}),t.on("DocProgress",a=>{this.destroyed||i.onProgress?.({loaded:a.loaded,total:a.total})}),t.on("FetchBinaryData",async a=>{if(this.destroyed)throw new Error("Worker was destroyed.");const r=this[a.type];if(!r)throw new Error(`${a.type} not initialized, see the \`useWorkerFetch\` parameter.`);return r.fetch(a)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Ct("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const i=t-1,a=this.#n.get(i);if(a)return a;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(c=>{if(this.destroyed)throw new Error("Transport destroyed");c.refStr&&this.#i.set(c.refStr,t);const u=new TO(i,c,this,this._params.pdfBug);return this.#e.set(i,u),u});return this.#n.set(i,r),r}getPageIndex(t){return qf(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,i){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:i})}getFieldObjects(){return this.#s("GetFieldObjects")}hasJSActions(){return this.#s("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#s("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#s("GetOptionalContentConfig").then(i=>new iO(i,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",i=this.#t.get(t);if(i)return i;const a=this.messageHandler.sendWithPromise(t,null).then(r=>({info:r[0],metadata:r[1]?new eO(r[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,a),a}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const i of this.#e.values())if(!i.cleanup())throw new Error(`startCleanup: Page ${i.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),hn.cleanup()}}cachedPageNumber(t){if(!qf(t))return null;const i=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#i.get(i)??null}}class xO{#t=null;onContinue=null;onError=null;constructor(t){this.#t=t}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:i}=this.#t;return t.form||t.canvas&&i?.size>0}}class Cr{#t=null;static#e=new WeakSet;constructor({callback:t,params:i,objs:a,commonObjs:r,annotationCanvasMap:c,operatorList:u,pageIndex:h,canvasFactory:p,filterFactory:m,useRequestAnimationFrame:g=!1,pdfBug:y=!1,pageColors:b=null,enableHWA:S=!1}){this.callback=t,this.params=i,this.objs=a,this.commonObjs=r,this.annotationCanvasMap=c,this.operatorListIdx=null,this.operatorList=u,this._pageIndex=h,this.canvasFactory=p,this.filterFactory=m,this._pdfBug=y,this.pageColors=b,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=g===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new xO(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=i.canvas,this._canvasContext=i.canvas?null:i.canvasContext,this._enableHWA=S}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:i}){if(this.cancelled)return;if(this._canvas){if(Cr.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Cr.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:a,transform:r,background:c}=this.params,u=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Tr(u,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:a,transparency:t,background:c}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,i=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),Cr.#e.delete(this._canvas),t||=new zf(`Rendering cancelled, page ${this._pageIndex+1}`,i),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Cr.#e.delete(this._canvas),this.callback())))}}const CO="5.4.54",RO="295fb3ec4";class Yn{#t=null;#e=null;#n;#i=null;#a=!1;#s=!1;#r=null;#o;#u=null;#c=null;static#h=null;static get _keyboardManager(){return zt(this,"_keyboardManager",new Jo([[["Escape","mac+Escape"],Yn.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Yn.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Yn.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Yn.prototype._moveToPrevious],[["Home","mac+Home"],Yn.prototype._moveToBeginning],[["End","mac+End"],Yn.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:i=null}){t?(this.#s=!1,this.#r=t):this.#s=!0,this.#c=t?._uiManager||i,this.#o=this.#c._eventBus,this.#n=t?.color?.toUpperCase()||this.#c?.highlightColors.values().next().value||"#FFFF98",Yn.#h||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r&&(t.ariaControls=`${this.#r.id}_colorpicker_dropdown`);const i=this.#c._signal;t.addEventListener("click",this.#f.bind(this),{signal:i}),t.addEventListener("keydown",this.#g.bind(this),{signal:i});const a=this.#e=document.createElement("span");return a.className="swatch",a.ariaHidden="true",a.style.backgroundColor=this.#n,t.append(a),t}renderMainDropdown(){const t=this.#i=this.#l();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#l(){const t=document.createElement("div"),i=this.#c._signal;t.addEventListener("contextmenu",qn,{signal:i}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r&&(t.id=`${this.#r.id}_colorpicker_dropdown`);for(const[a,r]of this.#c.highlightColors){const c=document.createElement("button");c.tabIndex="0",c.role="option",c.setAttribute("data-color",r),c.title=a,c.setAttribute("data-l10n-id",Yn.#h[a]);const u=document.createElement("span");c.append(u),u.className="swatch",u.style.backgroundColor=r,c.ariaSelected=r===this.#n,c.addEventListener("click",this.#p.bind(this,r),{signal:i}),t.append(c)}return t.addEventListener("keydown",this.#g.bind(this),{signal:i}),t}#p(t,i){i.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:$t.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#f(t);return}const i=t.target.getAttribute("data-color");i&&this.#p(i,t)}_moveToNext(t){if(!this.#m){this.#f(t);return}if(t.target===this.#t){this.#i.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstChild||t.target===this.#t){this.#m&&this._hideDropdownFromKeyboard();return}this.#m||this.#f(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#m){this.#f(t);return}this.#i.firstChild?.focus()}_moveToEnd(t){if(!this.#m){this.#f(t);return}this.#i.lastChild?.focus()}#g(t){Yn._keyboardManager.exec(this,t)}#f(t){if(this.#m){this.hideDropdown();return}if(this.#a=t.detail===0,this.#u||(this.#u=new AbortController,window.addEventListener("pointerdown",this.#d.bind(this),{signal:this.#c.combinedSignal(this.#u)})),this.#t.ariaExpanded="true",this.#i){this.#i.classList.remove("hidden");return}const i=this.#i=this.#l();this.#t.append(i)}#d(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#u?.abort(),this.#u=null}get#m(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#s){if(!this.#m){this.#r?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#a})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#i)return;const i=this.#c.highlightColors.values();for(const a of this.#i.children)a.ariaSelected=i.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}}class rl{#t=null;#e=null;#n=null;static#i=null;constructor(t){this.#e=t,this.#n=t._uiManager,rl.#i||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;const{editorType:t,colorType:i,colorValue:a}=this.#e,r=this.#t=document.createElement("input");return r.type="color",r.value=a||"#000000",r.className="basicColorPicker",r.tabIndex=0,r.setAttribute("data-l10n-id",rl.#i[t]),r.addEventListener("input",()=>{this.#n.updateParams(i,r.value)},{signal:this.#n._signal}),r}update(t){this.#t&&(this.#t.value=t)}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}function C0(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function ol(l){return Math.max(0,Math.min(255,255*l))}class R0{static CMYK_G([t,i,a,r]){return["G",1-Math.min(1,.3*t+.59*a+.11*i+r)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=ol(t),[t,t,t]}static G_HTML([t]){const i=C0(t);return`#${i}${i}${i}`}static RGB_G([t,i,a]){return["G",.3*t+.59*i+.11*a]}static RGB_rgb(t){return t.map(ol)}static RGB_HTML(t){return`#${t.map(C0).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,i,a,r]){return["RGB",1-Math.min(1,t+r),1-Math.min(1,a+r),1-Math.min(1,i+r)]}static CMYK_rgb([t,i,a,r]){return[ol(1-Math.min(1,t+r)),ol(1-Math.min(1,a+r)),ol(1-Math.min(1,i+r))]}static CMYK_HTML(t){const i=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(i)}static RGB_CMYK([t,i,a]){const r=1-t,c=1-i,u=1-a,h=Math.min(r,c,u);return["CMYK",r,c,u,h]}}class DO{create(t,i,a=!1){if(t<=0||i<=0)throw new Error("Invalid SVG dimensions");const r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),a||(r.setAttribute("width",`${t}px`),r.setAttribute("height",`${i}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${t} ${i}`),r}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){se("Abstract method `_createSVG` called.")}}class Du extends DO{_createSVG(t){return document.createElementNS(Ji,t)}}class D0{static setupStorage(t,i,a,r,c){const u=r.getValue(i,{value:null});switch(a.name){case"textarea":if(u.value!==null&&(t.textContent=u.value),c==="print")break;t.addEventListener("input",h=>{r.setValue(i,{value:h.target.value})});break;case"input":if(a.attributes.type==="radio"||a.attributes.type==="checkbox"){if(u.value===a.attributes.xfaOn?t.setAttribute("checked",!0):u.value===a.attributes.xfaOff&&t.removeAttribute("checked"),c==="print")break;t.addEventListener("change",h=>{r.setValue(i,{value:h.target.checked?h.target.getAttribute("xfaOn"):h.target.getAttribute("xfaOff")})})}else{if(u.value!==null&&t.setAttribute("value",u.value),c==="print")break;t.addEventListener("input",h=>{r.setValue(i,{value:h.target.value})})}break;case"select":if(u.value!==null){t.setAttribute("value",u.value);for(const h of a.children)h.attributes.value===u.value?h.attributes.selected=!0:h.attributes.hasOwnProperty("selected")&&delete h.attributes.selected}t.addEventListener("input",h=>{const p=h.target.options,m=p.selectedIndex===-1?"":p[p.selectedIndex].value;r.setValue(i,{value:m})});break}}static setAttributes({html:t,element:i,storage:a=null,intent:r,linkService:c}){const{attributes:u}=i,h=t instanceof HTMLAnchorElement;u.type==="radio"&&(u.name=`${u.name}-${r}`);for(const[p,m]of Object.entries(u))if(m!=null)switch(p){case"class":m.length&&t.setAttribute(p,m.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",m);break;case"style":Object.assign(t.style,m);break;case"textContent":t.textContent=m;break;default:(!h||p!=="href"&&p!=="newWindow")&&t.setAttribute(p,m)}h&&c.addLinkAttributes(t,u.href,u.newWindow),a&&u.dataId&&this.setupStorage(t,u.dataId,i,a)}static render(t){const i=t.annotationStorage,a=t.linkService,r=t.xfaHtml,c=t.intent||"display",u=document.createElement(r.name);r.attributes&&this.setAttributes({html:u,element:r,intent:c,linkService:a});const h=c!=="richText",p=t.div;if(p.append(u),t.viewport){const y=`matrix(${t.viewport.transform.join(",")})`;p.style.transform=y}h&&p.setAttribute("class","xfaLayer xfaFont");const m=[];if(r.children.length===0){if(r.value){const y=document.createTextNode(r.value);u.append(y),h&&sl.shouldBuildText(r.name)&&m.push(y)}return{textDivs:m}}const g=[[r,-1,u]];for(;g.length>0;){const[y,b,S]=g.at(-1);if(b+1===y.children.length){g.pop();continue}const A=y.children[++g.at(-1)[1]];if(A===null)continue;const{name:_}=A;if(_==="#text"){const x=document.createTextNode(A.value);m.push(x),S.append(x);continue}const R=A?.attributes?.xmlns?document.createElementNS(A.attributes.xmlns,_):document.createElement(_);if(S.append(R),A.attributes&&this.setAttributes({html:R,element:A,storage:i,intent:c,linkService:a}),A.children?.length>0)g.push([A,-1,R]);else if(A.value){const x=document.createTextNode(A.value);h&&sl.shouldBuildText(_)&&m.push(x),R.append(x)}}for(const y of p.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.setAttribute("readOnly",!0);return{textDivs:m}}static update(t){const i=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=i,t.div.hidden=!1}}const MO=9,_a=new WeakSet,OO=new Date().getTimezoneOffset()*60*1e3;class M0{static create(t){switch(t.data.annotationType){case De.LINK:return new np(t);case De.TEXT:return new kO(t);case De.WIDGET:switch(t.data.fieldType){case"Tx":return new NO(t);case"Btn":return t.data.radioButton?new O0(t):t.data.checkBox?new IO(t):new PO(t);case"Ch":return new UO(t);case"Sig":return new LO(t)}return new Ta(t);case De.POPUP:return new ip(t);case De.FREETEXT:return new k0(t);case De.LINE:return new HO(t);case De.SQUARE:return new BO(t);case De.CIRCLE:return new FO(t);case De.POLYLINE:return new N0(t);case De.CARET:return new $O(t);case De.INK:return new sp(t);case De.POLYGON:return new jO(t);case De.HIGHLIGHT:return new L0(t);case De.UNDERLINE:return new GO(t);case De.SQUIGGLY:return new VO(t);case De.STRIKEOUT:return new qO(t);case De.STAMP:return new I0(t);case De.FILEATTACHMENT:return new XO(t);default:return new Ae(t)}}}class Ae{#t=null;#e=!1;#n=null;constructor(t,{isRenderable:i=!1,ignoreBorder:a=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=i,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,i&&(this.container=this._createContainer(a)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:i}){return!!(t?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Ae._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});const{rect:i,popup:a}=t;i&&this.#i(i);let r=this.#n?.popup||this.popup;!r&&a?.text&&(this._createPopup(a),r=this.#n.popup),r&&(r.updateEdited(t),a?.deleted&&(r.remove(),this.#n=null,this.popup=null))}resetEdited(){this.#t&&(this.#i(this.#t.rect),this.#n?.popup.resetEdited(),this.#t=null)}#i(t){const{container:{style:i},data:{rect:a,rotation:r},parent:{viewport:{rawDims:{pageWidth:c,pageHeight:u,pageX:h,pageY:p}}}}=this;a?.splice(0,4,...t),i.left=`${100*(t[0]-h)/c}%`,i.top=`${100*(u-t[3]+p)/u}%`,r===0?(i.width=`${100*(t[2]-t[0])/c}%`,i.height=`${100*(t[3]-t[1])/u}%`):this.setRotation(r)}_createContainer(t){const{data:i,parent:{page:a,viewport:r}}=this,c=document.createElement("section");c.setAttribute("data-annotation-id",i.id),!(this instanceof Ta)&&!(this instanceof np)&&(c.tabIndex=0);const{style:u}=c;if(u.zIndex=this.parent.zIndex++,i.alternativeText&&(c.title=i.alternativeText),i.noRotate&&c.classList.add("norotate"),!i.rect||this instanceof ip){const{rotation:_}=i;return!i.hasOwnCanvas&&_!==0&&this.setRotation(_,c),c}const{width:h,height:p}=this;if(!t&&i.borderStyle.width>0){u.borderWidth=`${i.borderStyle.width}px`;const _=i.borderStyle.horizontalCornerRadius,R=i.borderStyle.verticalCornerRadius;if(_>0||R>0){const L=`calc(${_}px * var(--total-scale-factor)) / calc(${R}px * var(--total-scale-factor))`;u.borderRadius=L}else if(this instanceof O0){const L=`calc(${h}px * var(--total-scale-factor)) / calc(${p}px * var(--total-scale-factor))`;u.borderRadius=L}switch(i.borderStyle.style){case Er.SOLID:u.borderStyle="solid";break;case Er.DASHED:u.borderStyle="dashed";break;case Er.BEVELED:Ct("Unimplemented border style: beveled");break;case Er.INSET:Ct("Unimplemented border style: inset");break;case Er.UNDERLINE:u.borderBottomStyle="solid";break}const x=i.borderColor||null;x?(this.#e=!0,u.borderColor=pt.makeHexColor(x[0]|0,x[1]|0,x[2]|0)):u.borderWidth=0}const m=pt.normalizeRect([i.rect[0],a.view[3]-i.rect[1]+a.view[1],i.rect[2],a.view[3]-i.rect[3]+a.view[1]]),{pageWidth:g,pageHeight:y,pageX:b,pageY:S}=r.rawDims;u.left=`${100*(m[0]-b)/g}%`,u.top=`${100*(m[1]-S)/y}%`;const{rotation:A}=i;return i.hasOwnCanvas||A===0?(u.width=`${100*h/g}%`,u.height=`${100*p/y}%`):this.setRotation(A,c),c}setRotation(t,i=this.container){if(!this.data.rect)return;const{pageWidth:a,pageHeight:r}=this.parent.viewport.rawDims;let{width:c,height:u}=this;t%180!==0&&([c,u]=[u,c]),i.style.width=`${100*c/a}%`,i.style.height=`${100*u/r}%`,i.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(i,a,r)=>{const c=r.detail[i],u=c[0],h=c.slice(1);r.target.style[a]=R0[`${u}_HTML`](h),this.annotationStorage.setValue(this.data.id,{[a]:R0[`${u}_rgb`](h)})};return zt(this,"_commonActions",{display:i=>{const{display:a}=i.detail,r=a%2===1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:a===1||a===2})},print:i=>{this.annotationStorage.setValue(this.data.id,{noPrint:!i.detail.print})},hidden:i=>{const{hidden:a}=i.detail;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:a,noView:a})},focus:i=>{setTimeout(()=>i.target.focus({preventScroll:!1}),0)},userName:i=>{i.target.title=i.detail.userName},readonly:i=>{i.target.disabled=i.detail.readonly},required:i=>{this._setRequired(i.target,i.detail.required)},bgColor:i=>{t("bgColor","backgroundColor",i)},fillColor:i=>{t("fillColor","backgroundColor",i)},fgColor:i=>{t("fgColor","color",i)},textColor:i=>{t("textColor","color",i)},borderColor:i=>{t("borderColor","borderColor",i)},strokeColor:i=>{t("strokeColor","borderColor",i)},rotation:i=>{const a=i.detail.rotation;this.setRotation(a),this.annotationStorage.setValue(this.data.id,{rotation:a})}})}_dispatchEventFromSandbox(t,i){const a=this._commonActions;for(const r of Object.keys(i.detail))(t[r]||a[r])?.(i)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const i=this.annotationStorage.getRawValue(this.data.id);if(!i)return;const a=this._commonActions;for(const[r,c]of Object.entries(i)){const u=a[r];if(u){const h={detail:{[r]:c},target:t};u(h),delete i[r]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[i,a,r,c]=this.data.rect.map(_=>Math.fround(_));if(t.length===8){const[_,R,x,L]=t.subarray(2,6);if(r===_&&c===R&&i===x&&a===L)return}const{style:u}=this.container;let h;if(this.#e){const{borderColor:_,borderWidth:R}=u;u.borderWidth=0,h=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${_}" stroke-width="${R}">`],this.container.classList.add("hasBorder")}const p=r-i,m=c-a,{svgFactory:g}=this,y=g.createElement("svg");y.classList.add("quadrilateralsContainer"),y.setAttribute("width",0),y.setAttribute("height",0),y.role="none";const b=g.createElement("defs");y.append(b);const S=g.createElement("clipPath"),A=`clippath_${this.data.id}`;S.setAttribute("id",A),S.setAttribute("clipPathUnits","objectBoundingBox"),b.append(S);for(let _=2,R=t.length;_<R;_+=8){const x=t[_],L=t[_+1],k=t[_+2],U=t[_+3],P=g.createElement("rect"),j=(k-i)/p,F=(c-L)/m,tt=(x-k)/p,Y=(L-U)/m;P.setAttribute("x",j),P.setAttribute("y",F),P.setAttribute("width",tt),P.setAttribute("height",Y),S.append(P),h?.push(`<rect vector-effect="non-scaling-stroke" x="${j}" y="${F}" width="${tt}" height="${Y}"/>`)}this.#e&&(h.push("</g></svg>')"),u.backgroundImage=h.join("")),this.container.append(y),this.container.style.clipPath=`url(#${A})`}_createPopup(t=null){const{data:i}=this;let a,r;t?(a={str:t.text},r=t.date):(a=i.contentsObj,r=i.modificationDate);const c=this.#n=new ip({data:{color:i.color,titleObj:i.titleObj,modificationDate:r,contentsObj:a,richText:i.richText,parentRect:i.rect,borderStyle:0,id:`popup_${i.id}`,rotation:i.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]});this.parent.div.append(c.render())}get hasPopupElement(){return!!(this.#n||this.popup||this.data.popupRef)}render(){se("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,i=null){const a=[];if(this._fieldObjects){const r=this._fieldObjects[t];if(r)for(const{page:c,id:u,exportValues:h}of r){if(c===-1||u===i)continue;const p=typeof h=="string"?h:null,m=document.querySelector(`[data-element-id="${u}"]`);if(m&&!_a.has(m)){Ct(`_getElementsByName - element not allowed: ${u}`);continue}a.push({id:u,exportValue:p,domElement:m})}return a}for(const r of document.getElementsByName(t)){const{exportValue:c}=r,u=r.getAttribute("data-element-id");u!==i&&_a.has(r)&&a.push({id:u,exportValue:c,domElement:r})}return a}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const i of t)i.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:i}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:i,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class np extends Ae{constructor(t,i=null){super(t,{isRenderable:!0,ignoreBorder:!!i?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:i}=this,a=document.createElement("a");a.setAttribute("data-element-id",t.id);let r=!1;return t.url?(i.addLinkAttributes(a,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(a,t.action,t.overlaidText),r=!0):t.attachment?(this.#e(a,t.attachment,t.overlaidText,t.attachmentDest),r=!0):t.setOCGState?(this.#n(a,t.setOCGState,t.overlaidText),r=!0):t.dest?(this._bindLink(a,t.dest,t.overlaidText),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,t),r=!0),t.resetForm?(this._bindResetFormAction(a,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(a,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(a),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,i,a=""){t.href=this.linkService.getDestinationHash(i),t.onclick=()=>(i&&this.linkService.goToDestination(i),!1),(i||i==="")&&this.#t(),a&&(t.title=a)}_bindNamedAction(t,i,a=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(i),!1),a&&(t.title=a),this.#t()}#e(t,i,a="",r=null){t.href=this.linkService.getAnchorUrl(""),i.description?t.title=i.description:a&&(t.title=a),t.onclick=()=>(this.downloadManager?.openOrDownloadData(i.content,i.filename,r),!1),this.#t()}#n(t,i,a=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(i),!1),a&&(t.title=a),this.#t()}_bindJSAction(t,i){t.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(i.actions)){const c=a.get(r);c&&(t[c]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i.id,name:r}}),!1))}i.overlaidText&&(t.title=i.overlaidText),t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,i){const a=t.onclick;if(a||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){Ct('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),a||(t.onclick=()=>!1);return}t.onclick=()=>{a?.();const{fields:r,refs:c,include:u}=i,h=[];if(r.length!==0||c.length!==0){const g=new Set(c);for(const y of r){const b=this._fieldObjects[y]||[];for(const{id:S}of b)g.add(S)}for(const y of Object.values(this._fieldObjects))for(const b of y)g.has(b.id)===u&&h.push(b)}else for(const g of Object.values(this._fieldObjects))h.push(...g);const p=this.annotationStorage,m=[];for(const g of h){const{id:y}=g;switch(m.push(y),g.type){case"text":{const S=g.defaultValue||"";p.setValue(y,{value:S});break}case"checkbox":case"radiobutton":{const S=g.defaultValue===g.exportValues;p.setValue(y,{value:S});break}case"combobox":case"listbox":{const S=g.defaultValue||"";p.setValue(y,{value:S});break}default:continue}const b=document.querySelector(`[data-element-id="${y}"]`);if(b){if(!_a.has(b)){Ct(`_bindResetFormAction - element not allowed: ${y}`);continue}}else continue;b.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:m,name:"ResetForm"}}),!1}}}class kO extends Ae{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Ta extends Ae{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Ve.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,i,a,r,c){a.includes("mouse")?t.addEventListener(a,u=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:c(u),shift:u.shiftKey,modifier:this._getKeyModifier(u)}})}):t.addEventListener(a,u=>{if(a==="blur"){if(!i.focused||!u.relatedTarget)return;i.focused=!1}else if(a==="focus"){if(i.focused)return;i.focused=!0}c&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:c(u)}})})}_setEventListeners(t,i,a,r){for(const[c,u]of a)(u==="Action"||this.data.actions?.[u])&&((u==="Focus"||u==="Blur")&&(i||={focused:!1}),this._setEventListener(t,i,c,u,r),u==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,i,"blur","Blur",null):u==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,i,"focus","Focus",null))}_setBackgroundColor(t){const i=this.data.backgroundColor||null;t.style.backgroundColor=i===null?"transparent":pt.makeHexColor(i[0],i[1],i[2])}_setTextStyle(t){const i=["left","center","right"],{fontColor:a}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||MO,c=t.style;let u;const h=2,p=m=>Math.round(10*m)/10;if(this.data.multiLine){const m=Math.abs(this.data.rect[3]-this.data.rect[1]-h),g=Math.round(m/(kf*r))||1,y=m/g;u=Math.min(r,p(y/kf))}else{const m=Math.abs(this.data.rect[3]-this.data.rect[1]-h);u=Math.min(r,p(m/kf))}c.fontSize=`calc(${u}px * var(--total-scale-factor))`,c.color=pt.makeHexColor(a[0],a[1],a[2]),this.data.textAlignment!==null&&(c.textAlign=i[this.data.textAlignment])}_setRequired(t,i){i?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",i)}}class NO extends Ta{constructor(t){const i=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:i})}setPropertyOnSiblings(t,i,a,r){const c=this.annotationStorage;for(const u of this._getElementsByName(t.name,t.id))u.domElement&&(u.domElement[i]=a),c.setValue(u.id,{[r]:a})}render(){const t=this.annotationStorage,i=this.data.id;this.container.classList.add("textWidgetAnnotation");let a=null;if(this.renderForms){const r=t.getValue(i,{value:this.data.fieldValue});let c=r.value||"";const u=t.getValue(i,{charLimit:this.data.maxLen}).charLimit;u&&c.length>u&&(c=c.slice(0,u));let h=r.formattedValue||this.data.textContent?.join(`
298
298
  `)||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const p={userValue:c,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(a=document.createElement("textarea"),a.textContent=h??c,this.data.doNotScroll&&(a.style.overflowY="hidden")):(a=document.createElement("input"),a.type=this.data.password?"password":"text",a.setAttribute("value",h??c),this.data.doNotScroll&&(a.style.overflowX="hidden")),this.data.hasOwnCanvas&&(a.hidden=!0),_a.add(a),a.setAttribute("data-element-id",i),a.disabled=this.data.readOnly,a.name=this.data.fieldName,a.tabIndex=0;const{datetimeFormat:m,datetimeType:g,timeStep:y}=this.data,b=!!g&&this.enableScripting;m&&(a.title=m),this._setRequired(a,this.data.required),u&&(a.maxLength=u),a.addEventListener("input",A=>{t.setValue(i,{value:A.target.value}),this.setPropertyOnSiblings(a,"value",A.target.value,"value"),p.formattedValue=null}),a.addEventListener("resetform",A=>{const _=this.data.defaultFieldValue??"";a.value=p.userValue=_,p.formattedValue=null});let S=A=>{const{formattedValue:_}=p;_!=null&&(A.target.value=_),A.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){a.addEventListener("focus",_=>{if(p.focused)return;const{target:R}=_;if(b&&(R.type=g,y&&(R.step=y)),p.userValue){const x=p.userValue;if(b)if(g==="time"){const L=new Date(x),k=[L.getHours(),L.getMinutes(),L.getSeconds()];R.value=k.map(U=>U.toString().padStart(2,"0")).join(":")}else R.value=new Date(x-OO).toISOString().split(g==="date"?"T":".",1)[0];else R.value=x}p.lastCommittedValue=R.value,p.commitKey=1,this.data.actions?.Focus||(p.focused=!0)}),a.addEventListener("updatefromsandbox",_=>{this.showElementAndHideCanvas(_.target);const R={value(x){p.userValue=x.detail.value??"",b||t.setValue(i,{value:p.userValue.toString()}),x.target.value=p.userValue},formattedValue(x){const{formattedValue:L}=x.detail;p.formattedValue=L,L!=null&&x.target!==document.activeElement&&(x.target.value=L);const k={formattedValue:L};b&&(k.value=L),t.setValue(i,k)},selRange(x){x.target.setSelectionRange(...x.detail.selRange)},charLimit:x=>{const{charLimit:L}=x.detail,{target:k}=x;if(L===0){k.removeAttribute("maxLength");return}k.setAttribute("maxLength",L);let U=p.userValue;!U||U.length<=L||(U=U.slice(0,L),k.value=p.userValue=U,t.setValue(i,{value:U}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:U,willCommit:!0,commitKey:1,selStart:k.selectionStart,selEnd:k.selectionEnd}}))}};this._dispatchEventFromSandbox(R,_)}),a.addEventListener("keydown",_=>{p.commitKey=1;let R=-1;if(_.key==="Escape"?R=0:_.key==="Enter"&&!this.data.multiLine?R=2:_.key==="Tab"&&(p.commitKey=3),R===-1)return;const{value:x}=_.target;p.lastCommittedValue!==x&&(p.lastCommittedValue=x,p.userValue=x,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:x,willCommit:!0,commitKey:R,selStart:_.target.selectionStart,selEnd:_.target.selectionEnd}}))});const A=S;S=null,a.addEventListener("blur",_=>{if(!p.focused||!_.relatedTarget)return;this.data.actions?.Blur||(p.focused=!1);const{target:R}=_;let{value:x}=R;if(b){if(x&&g==="time"){const L=x.split(":").map(k=>parseInt(k,10));x=new Date(2e3,0,1,L[0],L[1],L[2]||0).valueOf(),R.step=""}else x=new Date(x).valueOf();R.type="text"}p.userValue=x,p.lastCommittedValue!==x&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:x,willCommit:!0,commitKey:p.commitKey,selStart:_.target.selectionStart,selEnd:_.target.selectionEnd}}),A(_)}),this.data.actions?.Keystroke&&a.addEventListener("beforeinput",_=>{p.lastCommittedValue=null;const{data:R,target:x}=_,{value:L,selectionStart:k,selectionEnd:U}=x;let P=k,j=U;switch(_.inputType){case"deleteWordBackward":{const F=L.substring(0,k).match(/\w*[^\w]*$/);F&&(P-=F[0].length);break}case"deleteWordForward":{const F=L.substring(k).match(/^[^\w]*\w*/);F&&(j+=F[0].length);break}case"deleteContentBackward":k===U&&(P-=1);break;case"deleteContentForward":k===U&&(j+=1);break}_.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:L,change:R||"",willCommit:!1,selStart:P,selEnd:j}})}),this._setEventListeners(a,p,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],_=>_.target.value)}if(S&&a.addEventListener("blur",S),this.data.comb){const _=(this.data.rect[2]-this.data.rect[0])/u;a.classList.add("comb"),a.style.letterSpacing=`calc(${_}px * var(--total-scale-factor) - 1ch)`}}else a=document.createElement("div"),a.textContent=this.data.fieldValue,a.style.verticalAlign="middle",a.style.display="table-cell",this.data.hasOwnCanvas&&(a.hidden=!0);return this._setTextStyle(a),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class LO extends Ta{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class IO extends Ta{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,i=this.data,a=i.id;let r=t.getValue(a,{value:i.exportValue===i.fieldValue}).value;typeof r=="string"&&(r=r!=="Off",t.setValue(a,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const c=document.createElement("input");return _a.add(c),c.setAttribute("data-element-id",a),c.disabled=i.readOnly,this._setRequired(c,this.data.required),c.type="checkbox",c.name=i.fieldName,r&&c.setAttribute("checked",!0),c.setAttribute("exportValue",i.exportValue),c.tabIndex=0,c.addEventListener("change",u=>{const{name:h,checked:p}=u.target;for(const m of this._getElementsByName(h,a)){const g=p&&m.exportValue===i.exportValue;m.domElement&&(m.domElement.checked=g),t.setValue(m.id,{value:g})}t.setValue(a,{value:p})}),c.addEventListener("resetform",u=>{const h=i.defaultFieldValue||"Off";u.target.checked=h===i.exportValue}),this.enableScripting&&this.hasJSActions&&(c.addEventListener("updatefromsandbox",u=>{const h={value(p){p.target.checked=p.detail.value!=="Off",t.setValue(a,{value:p.target.checked})}};this._dispatchEventFromSandbox(h,u)}),this._setEventListeners(c,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.checked)),this._setBackgroundColor(c),this._setDefaultPropertiesFromJS(c),this.container.append(c),this.container}}class O0 extends Ta{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,i=this.data,a=i.id;let r=t.getValue(a,{value:i.fieldValue===i.buttonValue}).value;if(typeof r=="string"&&(r=r!==i.buttonValue,t.setValue(a,{value:r})),r)for(const u of this._getElementsByName(i.fieldName,a))t.setValue(u.id,{value:!1});const c=document.createElement("input");if(_a.add(c),c.setAttribute("data-element-id",a),c.disabled=i.readOnly,this._setRequired(c,this.data.required),c.type="radio",c.name=i.fieldName,r&&c.setAttribute("checked",!0),c.tabIndex=0,c.addEventListener("change",u=>{const{name:h,checked:p}=u.target;for(const m of this._getElementsByName(h,a))t.setValue(m.id,{value:!1});t.setValue(a,{value:p})}),c.addEventListener("resetform",u=>{const h=i.defaultFieldValue;u.target.checked=h!=null&&h===i.buttonValue}),this.enableScripting&&this.hasJSActions){const u=i.buttonValue;c.addEventListener("updatefromsandbox",h=>{const p={value:m=>{const g=u===m.detail.value;for(const y of this._getElementsByName(m.target.name)){const b=g&&y.id===a;y.domElement&&(y.domElement.checked=b),t.setValue(y.id,{value:b})}}};this._dispatchEventFromSandbox(p,h)}),this._setEventListeners(c,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],h=>h.target.checked)}return this._setBackgroundColor(c),this._setDefaultPropertiesFromJS(c),this.container.append(c),this.container}}class PO extends np{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const i=t.lastChild;return this.enableScripting&&this.hasJSActions&&i&&(this._setDefaultPropertiesFromJS(i),i.addEventListener("updatefromsandbox",a=>{this._dispatchEventFromSandbox({},a)})),t}}class UO extends Ta{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,i=this.data.id,a=t.getValue(i,{value:this.data.fieldValue}),r=document.createElement("select");_a.add(r),r.setAttribute("data-element-id",i),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=0;let c=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",g=>{const y=this.data.defaultFieldValue;for(const b of r.options)b.selected=b.value===y});for(const g of this.data.options){const y=document.createElement("option");y.textContent=g.displayValue,y.value=g.exportValue,a.value.includes(g.exportValue)&&(y.setAttribute("selected",!0),c=!1),r.append(y)}let u=null;if(c){const g=document.createElement("option");g.value=" ",g.setAttribute("hidden",!0),g.setAttribute("selected",!0),r.prepend(g),u=()=>{g.remove(),r.removeEventListener("input",u),u=null},r.addEventListener("input",u)}const h=g=>{const y=g?"value":"textContent",{options:b,multiple:S}=r;return S?Array.prototype.filter.call(b,A=>A.selected).map(A=>A[y]):b.selectedIndex===-1?null:b[b.selectedIndex][y]};let p=h(!1);const m=g=>{const y=g.target.options;return Array.prototype.map.call(y,b=>({displayValue:b.textContent,exportValue:b.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",g=>{const y={value(b){u?.();const S=b.detail.value,A=new Set(Array.isArray(S)?S:[S]);for(const _ of r.options)_.selected=A.has(_.value);t.setValue(i,{value:h(!0)}),p=h(!1)},multipleSelection(b){r.multiple=!0},remove(b){const S=r.options,A=b.detail.remove;S[A].selected=!1,r.remove(A),S.length>0&&Array.prototype.findIndex.call(S,R=>R.selected)===-1&&(S[0].selected=!0),t.setValue(i,{value:h(!0),items:m(b)}),p=h(!1)},clear(b){for(;r.length!==0;)r.remove(0);t.setValue(i,{value:null,items:[]}),p=h(!1)},insert(b){const{index:S,displayValue:A,exportValue:_}=b.detail.insert,R=r.children[S],x=document.createElement("option");x.textContent=A,x.value=_,R?R.before(x):r.append(x),t.setValue(i,{value:h(!0),items:m(b)}),p=h(!1)},items(b){const{items:S}=b.detail;for(;r.length!==0;)r.remove(0);for(const A of S){const{displayValue:_,exportValue:R}=A,x=document.createElement("option");x.textContent=_,x.value=R,r.append(x)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(i,{value:h(!0),items:m(b)}),p=h(!1)},indices(b){const S=new Set(b.detail.indices);for(const A of b.target.options)A.selected=S.has(A.index);t.setValue(i,{value:h(!0)}),p=h(!1)},editable(b){b.target.disabled=!b.detail.editable}};this._dispatchEventFromSandbox(y,g)}),r.addEventListener("input",g=>{const y=h(!0),b=h(!1);t.setValue(i,{value:y}),g.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:p,change:b,changeEx:y,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],g=>g.target.value)):r.addEventListener("input",function(g){t.setValue(i,{value:h(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ip extends Ae{constructor(t){const{data:i,elements:a}=t;super(t,{isRenderable:Ae._hasPopupData(i)}),this.elements=a,this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const i=this.popup=new zO({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),a=[];for(const r of this.elements)r.popup=i,r.container.ariaHasPopup="dialog",a.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",a.map(r=>`${Uf}${r}`).join(",")),this.container}}class zO{#t=this.#M.bind(this);#e=this.#k.bind(this);#n=this.#x.bind(this);#i=this.#C.bind(this);#a=null;#s=null;#r=null;#o=null;#u=null;#c=null;#h=null;#l=!1;#p=null;#g=null;#f=null;#d=null;#m=null;#v=null;#y=null;#E=!1;constructor({container:t,color:i,elements:a,titleObj:r,modificationDate:c,contentsObj:u,richText:h,parent:p,rect:m,parentRect:g,open:y}){this.#s=t,this.#v=r,this.#r=u,this.#m=h,this.#c=p,this.#a=i,this.#d=m,this.#h=g,this.#u=a,this.#o=Bf.toDateObject(c),this.trigger=a.flatMap(b=>b.getElementsToTriggerPopup()),this.#A(),this.#s.hidden=!0,y&&this.#C()}#A(){if(this.#g)return;this.#g=new AbortController;const{signal:t}=this.#g;for(const i of this.trigger)i.addEventListener("click",this.#i,{signal:t}),i.addEventListener("mouseenter",this.#n,{signal:t}),i.addEventListener("mouseleave",this.#e,{signal:t}),i.classList.add("popupTriggerArea");for(const i of this.#u)i.container?.addEventListener("keydown",this.#t,{signal:t})}render(){if(this.#p)return;const t=this.#p=document.createElement("div");if(t.className="popup",this.#a){const r=t.style.outlineColor=pt.makeHexColor(...this.#a);t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const i=document.createElement("span");if(i.className="header",this.#v?.str){const r=document.createElement("span");r.className="title",i.append(r),{dir:r.dir,str:r.textContent}=this.#v}if(t.append(i),this.#o){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#o.valueOf()})),r.dateTime=this.#o.toISOString(),i.append(r)}const a=this.#b;if(a)D0.render({xfaHtml:a,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const r=this._formatContents(this.#r);t.append(r)}this.#s.append(t)}get#b(){const t=this.#m,i=this.#r;return t?.str&&(!i?.str||i.str===t.str)&&this.#m.html||null}get#T(){return this.#b?.attributes?.style?.fontSize||0}get#D(){return this.#b?.attributes?.style?.color||null}#_(t){const i=[],a={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:i}]}},r={style:{color:this.#D,fontSize:this.#T?`calc(${this.#T}px * var(--total-scale-factor))`:""}};for(const c of t.split(`
299
299
  `))i.push({name:"span",value:c,attributes:r});return a}_formatContents({str:t,dir:i}){const a=document.createElement("p");a.classList.add("popupContent"),a.dir=i;const r=t.split(/(?:\r\n?|\n)/);for(let c=0,u=r.length;c<u;++c){const h=r[c];a.append(document.createTextNode(h)),c<u-1&&a.append(document.createElement("br"))}return a}#M(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#l)&&this.#C()}updateEdited({rect:t,popup:i,deleted:a}){if(a||i?.deleted){this.remove();return}this.#A(),this.#y||={contentsObj:this.#r,richText:this.#m},t&&(this.#f=null),i&&(this.#m=this.#_(i.text),this.#o=Bf.toDateObject(i.date),this.#r=null),this.#p?.remove(),this.#p=null}resetEdited(){this.#y&&({contentsObj:this.#r,richText:this.#m}=this.#y,this.#y=null,this.#p?.remove(),this.#p=null,this.#f=null)}remove(){this.#g?.abort(),this.#g=null,this.#p?.remove(),this.#p=null,this.#E=!1,this.#l=!1;for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#R(){if(this.#f!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:r,pageY:c}}}=this.#c;let u=!!this.#h,h=u?this.#h:this.#d;for(const A of this.#u)if(!h||pt.intersect(A.data.rect,h)!==null){h=A.data.rect,u=!0;break}const p=pt.normalizeRect([h[0],t[3]-h[1]+t[1],h[2],t[3]-h[3]+t[1]]),g=u?h[2]-h[0]+5:0,y=p[0]+g,b=p[1];this.#f=[100*(y-r)/i,100*(b-c)/a];const{style:S}=this.#s;S.left=`${this.#f[0]}%`,S.top=`${this.#f[1]}%`}#C(){this.#l=!this.#l,this.#l?(this.#x(),this.#s.addEventListener("click",this.#i),this.#s.addEventListener("keydown",this.#t)):(this.#k(),this.#s.removeEventListener("click",this.#i),this.#s.removeEventListener("keydown",this.#t))}#x(){this.#p||this.render(),this.isVisible?this.#l&&this.#s.classList.add("focused"):(this.#R(),this.#s.hidden=!1,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)+1e3)}#k(){this.#s.classList.remove("focused"),!(this.#l||!this.isVisible)&&(this.#s.hidden=!0,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)-1e3)}forceHide(){this.#E=this.isVisible,this.#E&&(this.#s.hidden=!0)}maybeShow(){this.#A(),this.#E&&(this.#p||this.#x(),this.#E=!1,this.#s.hidden=!1)}get isVisible(){return this.#s.hidden===!1}}class k0 extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=xt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const i of this.textContent){const a=document.createElement("span");a.textContent=i,t.append(a)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class HO extends Ae{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:i,height:a}=this,r=this.svgFactory.create(i,a,!0),c=this.#t=this.svgFactory.createElement("svg:line");return c.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),c.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),c.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),c.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),c.setAttribute("stroke-width",t.borderStyle.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),r.append(c),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class BO extends Ae{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:i,height:a}=this,r=this.svgFactory.create(i,a,!0),c=t.borderStyle.width,u=this.#t=this.svgFactory.createElement("svg:rect");return u.setAttribute("x",c/2),u.setAttribute("y",c/2),u.setAttribute("width",i-c),u.setAttribute("height",a-c),u.setAttribute("stroke-width",c||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),r.append(u),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class FO extends Ae{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:i,height:a}=this,r=this.svgFactory.create(i,a,!0),c=t.borderStyle.width,u=this.#t=this.svgFactory.createElement("svg:ellipse");return u.setAttribute("cx",i/2),u.setAttribute("cy",a/2),u.setAttribute("rx",i/2-c/2),u.setAttribute("ry",a/2-c/2),u.setAttribute("stroke-width",c||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),r.append(u),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class N0 extends Ae{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:i,borderStyle:a,popupRef:r},width:c,height:u}=this;if(!i)return this.container;const h=this.svgFactory.create(c,u,!0);let p=[];for(let g=0,y=i.length;g<y;g+=2){const b=i[g]-t[0],S=t[3]-i[g+1];p.push(`${b},${S}`)}p=p.join(" ");const m=this.#t=this.svgFactory.createElement(this.svgElementName);return m.setAttribute("points",p),m.setAttribute("stroke-width",a.width||1),m.setAttribute("stroke","transparent"),m.setAttribute("fill","transparent"),h.append(m),this.container.append(h),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class jO extends N0{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class $O extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class sp extends Ae{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?xt.HIGHLIGHT:xt.INK}#n(t,i){switch(t){case 90:return{transform:`rotate(90) translate(${-i[0]},${i[1]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};case 180:return{transform:`rotate(180) translate(${-i[2]},${i[1]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]};case 270:return{transform:`rotate(270) translate(${-i[2]},${i[3]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};default:return{transform:`translate(${-i[0]},${i[3]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:i,inkLists:a,borderStyle:r,popupRef:c}}=this,{transform:u,width:h,height:p}=this.#n(i,t),m=this.svgFactory.create(h,p,!0),g=this.#t=this.svgFactory.createElement("svg:g");m.append(g),g.setAttribute("stroke-width",r.width||1),g.setAttribute("stroke-linecap","round"),g.setAttribute("stroke-linejoin","round"),g.setAttribute("stroke-miterlimit",10),g.setAttribute("stroke","transparent"),g.setAttribute("fill","transparent"),g.setAttribute("transform",u);for(let y=0,b=a.length;y<b;y++){const S=this.svgFactory.createElement(this.svgElementName);this.#e.push(S),S.setAttribute("points",a[y].join(",")),g.append(S)}return!c&&this.hasPopupData&&this._createPopup(),this.container.append(m),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:i,points:a,rect:r}=t,c=this.#t;if(i>=0&&c.setAttribute("stroke-width",i||1),a)for(let u=0,h=this.#e.length;u<h;u++)this.#e[u].setAttribute("points",a[u].join(","));if(r){const{transform:u,width:h,height:p}=this.#n(this.data.rotation,r);c.parentElement.setAttribute("viewBox",`0 0 ${h} ${p}`),c.setAttribute("transform",u)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class L0 extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=xt.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const a=document.createElement("mark");a.classList.add("overlaidText"),a.textContent=t,this.container.append(a)}return this.container}}class GO extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const a=document.createElement("u");a.classList.add("overlaidText"),a.textContent=t,this.container.append(a)}return this.container}}class VO extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const a=document.createElement("u");a.classList.add("overlaidText"),a.textContent=t,this.container.append(a)}return this.container}}class qO extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const a=document.createElement("s");a.classList.add("overlaidText"),a.textContent=t,this.container.append(a)}return this.container}}class I0 extends Ae{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=xt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class XO extends Ae{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:i}=this.data;this.filename=i.filename,this.content=i.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:i}=this;let a;i.hasAppearance||i.fillAlpha===0?a=document.createElement("div"):(a=document.createElement("img"),a.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(a.style=`filter: opacity(${Math.round(i.fillAlpha*100)}%);`)),a.addEventListener("dblclick",this.#e.bind(this)),this.#t=a;const{isMac:r}=Ve.platform;return t.addEventListener("keydown",c=>{c.key==="Enter"&&(r?c.metaKey:c.ctrlKey)&&this.#e()}),!i.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),t.append(a),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ap{#t=null;#e=null;#n=new Map;#i=null;constructor({div:t,accessibilityManager:i,annotationCanvasMap:a,annotationEditorUIManager:r,page:c,viewport:u,structTreeLayer:h}){this.div=t,this.#t=i,this.#e=a,this.#i=h||null,this.page=c,this.viewport=u,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#a(t,i,a){const r=t.firstChild||t,c=r.id=`${Uf}${i}`,u=await this.#i?.getAriaAttributes(c);if(u)for(const[h,p]of u)r.setAttribute(h,p);a?a.at(-1).container.after(t):(this.div.append(t),this.#t?.moveElementInDOM(this.div,t,r,!1))}async render(t){const{annotations:i}=t,a=this.div;Aa(a,this.viewport);const r=new Map,c={data:null,layer:a,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Du,annotationStorage:t.annotationStorage||new Vf,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const u of i){if(u.noHTML)continue;const h=u.annotationType===De.POPUP;if(h){const g=r.get(u.id);if(!g)continue;c.elements=g}else if(u.rect[2]===u.rect[0]||u.rect[3]===u.rect[1])continue;c.data=u;const p=M0.create(c);if(!p.isRenderable)continue;if(!h&&u.popupRef){const g=r.get(u.popupRef);g?g.push(p):r.set(u.popupRef,[p])}const m=p.render();u.hidden&&(m.style.visibility="hidden"),await this.#a(m,u.id,c.elements),p._isEditable&&(this.#n.set(p.data.id,p),this._annotationEditorUIManager?.renderAnnotationElement(p))}this.#s()}async addLinkAnnotations(t,i){const a={data:null,layer:this.div,linkService:i,svgFactory:new Du,parent:this};for(const r of t){r.borderStyle||=ap._defaultBorderStyle,a.data=r;const c=M0.create(a);if(!c.isRenderable)continue;const u=c.render();await this.#a(u,r.id,null)}}update({viewport:t}){const i=this.div;this.viewport=t,Aa(i,{rotation:t.rotation}),this.#s(),i.hidden=!1}#s(){if(!this.#e)return;const t=this.div;for(const[i,a]of this.#e){const r=t.querySelector(`[data-annotation-id="${i}"]`);if(!r)continue;a.className="annotationContent";const{firstChild:c}=r;c?c.nodeName==="CANVAS"?c.replaceWith(a):c.classList.contains("annotationContent")?c.after(a):c.before(a):r.append(a);const u=this.#n.get(i);u&&(u._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(i,r.id,a),u._hasNoCanvas=!1):u.canvas=a)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(t){return this.#n.get(t)}static get _defaultBorderStyle(){return zt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Er.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const Mu=/\r\n?|\n/g;class Ue extends gt{#t;#e="";#n=`${this.id}-editor`;#i=null;#a;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Ue.prototype,i=c=>c.isEmpty(),a=Ps.TRANSLATE_SMALL,r=Ps.TRANSLATE_BIG;return zt(this,"_keyboardManager",new Jo([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-a,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[a,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-a],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,a],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:i}]]))}static _type="freetext";static _editorType=xt.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||Ue._defaultColor||gt._defaultLineColor,this.#a=t.fontSize||Ue._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static initialize(t,i){gt.initialize(t,i);const a=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(a.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,i){switch(t){case $t.FREETEXT_SIZE:Ue._defaultFontSize=i;break;case $t.FREETEXT_COLOR:Ue._defaultColor=i;break}}updateParams(t,i){switch(t){case $t.FREETEXT_SIZE:this.#s(i);break;case $t.FREETEXT_COLOR:this.#r(i);break}}static get defaultPropertiesToUpdate(){return[[$t.FREETEXT_SIZE,Ue._defaultFontSize],[$t.FREETEXT_COLOR,Ue._defaultColor||gt._defaultLineColor]]}get propertiesToUpdate(){return[[$t.FREETEXT_SIZE,this.#a],[$t.FREETEXT_COLOR,this.#t]]}get toolbarButtons(){return this._colorPicker||=new rl(this),[["colorPicker",this._colorPicker]]}get colorType(){return $t.FREETEXT_COLOR}get colorValue(){return this.#t}#s(t){const i=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-this.#a)*this.parentScale),this.#a=r,this.#u()},a=this.#a;this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$t.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#r(t){const i=r=>{this.#t=this.editorDiv.style.color=r,this._colorPicker?.update(r)},a=this.#t;this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$t.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,i){this._uiManager.translateSelectedEditors(t,i,!0)}getInitialTranslation(){const t=this.parentScale;return[-Ue._internalPadding*t,-(Ue._internalPadding+this.#a)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#i=new AbortController;const t=this._uiManager.combinedSignal(this.#i);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#i?.abort(),this.#i=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#o(){const t=[];this.editorDiv.normalize();let i=null;for(const a of this.editorDiv.childNodes)i?.nodeType===Node.TEXT_NODE&&a.nodeName==="BR"||(t.push(Ue.#c(a)),i=a);return t.join(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corisco",
3
3
  "private": false,
4
- "version": "1.3.4-hml",
4
+ "version": "1.3.4",
5
5
  "description": "Corisco - Extensão ChatJT para captura de documentos PJe",
6
6
  "type": "module",
7
7
  "main": "dist/corisco.umd.js",