@shumai-one/shumai 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/bin/chunk-0aj303as.js +3 -0
  2. package/bin/{chunk-kbzm1pwx.js → chunk-0qkj838r.js} +1 -1
  3. package/bin/{chunk-5a2maxwp.js → chunk-0rxhc7ka.js} +2 -2
  4. package/bin/chunk-0xbf8bcg.js +2 -0
  5. package/bin/{chunk-xh2ntgmk.js → chunk-14fh4s1a.js} +2 -2
  6. package/bin/{chunk-6mn3jqm9.js → chunk-15sefy5t.js} +2 -2
  7. package/bin/{chunk-mjan6b09.js → chunk-1wm57c6y.js} +3 -3
  8. package/bin/{chunk-pf8edn5x.js → chunk-1xpec5r8.js} +2 -2
  9. package/bin/chunk-23d3968z.js +2 -0
  10. package/bin/{chunk-r3n9zpfw.js → chunk-262hkppb.js} +2 -2
  11. package/bin/{chunk-3n1k9qt5.js → chunk-29tx9qe2.js} +1 -1
  12. package/bin/chunk-2aamsc5v.js +2 -0
  13. package/bin/chunk-2aascrtb.js +2 -0
  14. package/bin/chunk-2dsmsa6a.js +3 -0
  15. package/bin/chunk-2g12s6mc.js +2 -0
  16. package/bin/chunk-31baz5n0.js +2 -0
  17. package/bin/{chunk-a5kfa0k9.js → chunk-3rmc8nz6.js} +1 -1
  18. package/bin/{chunk-dyybbn07.js → chunk-46ar48f9.js} +1 -1
  19. package/bin/chunk-4e3jbp84.js +1 -0
  20. package/bin/chunk-4jk0y1w1.js +1 -0
  21. package/bin/{chunk-7ddaxdpf.js → chunk-4qpa7b5t.js} +1 -1
  22. package/bin/{chunk-8wv3kdz9.js → chunk-54tr7y2x.js} +2 -2
  23. package/bin/{chunk-ehfk24cf.js → chunk-5d2q46mx.js} +1 -1
  24. package/bin/{chunk-2cmg5sfn.js → chunk-5m9be8an.js} +2 -2
  25. package/bin/{chunk-yk3k5g5w.js → chunk-5r8858hx.js} +2 -2
  26. package/bin/{chunk-fwe9g818.js → chunk-5t6c3038.js} +1 -1
  27. package/bin/chunk-6z65xd0w.js +3 -0
  28. package/bin/{chunk-cp18trqb.js → chunk-77r8w95d.js} +2 -2
  29. package/bin/chunk-7b17fb36.js +6 -0
  30. package/bin/chunk-7e06b2zb.js +2 -0
  31. package/bin/{chunk-29ectt6g.js → chunk-7hsgmjpa.js} +2 -2
  32. package/bin/chunk-7we7ex0m.js +3 -0
  33. package/bin/{chunk-6r9w7z15.js → chunk-88fg1sw7.js} +2 -2
  34. package/bin/chunk-891h8br6.js +3 -0
  35. package/bin/{chunk-m7jfszqt.js → chunk-8mkfgcvb.js} +2 -2
  36. package/bin/chunk-8qg47kj6.js +3 -0
  37. package/bin/chunk-8tf6kgdj.js +2 -0
  38. package/bin/{chunk-s8d2045p.js → chunk-8wqfkm4c.js} +1 -1
  39. package/bin/{chunk-3rajscaz.js → chunk-922nnh39.js} +1 -1
  40. package/bin/{chunk-aakzq0w1.js → chunk-925q4paa.js} +1 -1
  41. package/bin/{chunk-frm7vz6v.js → chunk-92xxys10.js} +6 -6
  42. package/bin/chunk-97jzve52.js +4 -0
  43. package/bin/{chunk-w4y97tzy.js → chunk-9ab6k4rq.js} +1 -1
  44. package/bin/chunk-9avkn3x1.js +3 -0
  45. package/bin/{chunk-22dje1f5.js → chunk-9h027f50.js} +1 -1
  46. package/bin/{chunk-ec88pb09.js → chunk-9h3ds7rn.js} +2 -2
  47. package/bin/chunk-av71yjaa.js +1 -0
  48. package/bin/{chunk-xpqcvxej.js → chunk-b8js74jk.js} +1 -1
  49. package/bin/chunk-bd71dp4j.js +8 -0
  50. package/bin/{chunk-yhj8c5re.js → chunk-bs0fjz3w.js} +2 -2
  51. package/bin/chunk-byqc8tzq.js +1 -0
  52. package/bin/chunk-c45rh4hk.js +3 -0
  53. package/bin/chunk-ccw7mjgq.js +5 -0
  54. package/bin/{chunk-3x62t1m0.js → chunk-cxhmr356.js} +1 -1
  55. package/bin/chunk-d2vxmn9v.js +3 -0
  56. package/bin/chunk-d3wmdjze.js +8 -0
  57. package/bin/{chunk-z42cyc20.js → chunk-de99643r.js} +2 -2
  58. package/bin/{chunk-4kk5g619.js → chunk-dghtwyq1.js} +2 -2
  59. package/bin/chunk-dqgv5yy1.js +6 -0
  60. package/bin/chunk-e3s3rz2e.js +12 -0
  61. package/bin/chunk-e52nga6c.js +3 -0
  62. package/bin/chunk-e7ndw3hg.js +12 -0
  63. package/bin/chunk-f14sqw1d.js +1 -0
  64. package/bin/chunk-f7sbkfmk.js +2 -0
  65. package/bin/{chunk-mnv6pj0k.js → chunk-fa2g2wge.js} +2 -2
  66. package/bin/{chunk-fcb14agg.js → chunk-fbte2rmd.js} +1 -1
  67. package/bin/chunk-fcvtgx1y.js +7 -0
  68. package/bin/chunk-fd5a3pdd.js +1 -0
  69. package/bin/{chunk-49ej1y67.js → chunk-fepymbka.js} +2 -2
  70. package/bin/{chunk-j8q688sx.js → chunk-fz88kkk1.js} +2 -2
  71. package/bin/chunk-g6zzg6v2.js +1 -0
  72. package/bin/chunk-g8th86na.js +2 -0
  73. package/bin/chunk-gswbc6y9.js +2 -0
  74. package/bin/{chunk-d1ka11hc.js → chunk-gtrc5ka2.js} +1 -1
  75. package/bin/chunk-h0ytx8zc.js +2 -0
  76. package/bin/{chunk-gdm6y33a.js → chunk-hkbybhww.js} +1 -1
  77. package/bin/chunk-hr97a5j5.js +4 -0
  78. package/bin/{chunk-dypsm6m2.js → chunk-j8qtab70.js} +1 -1
  79. package/bin/{chunk-hdk93ghf.js → chunk-jf3vn5c3.js} +2 -2
  80. package/bin/{chunk-ajqsprm0.js → chunk-kfhtk3eh.js} +2 -2
  81. package/bin/chunk-kr06nrbx.js +2 -0
  82. package/bin/{chunk-9rw65s3e.js → chunk-m4zpf9gg.js} +2 -2
  83. package/bin/{chunk-y1xs4c5j.js → chunk-mqjzmn0e.js} +1 -1
  84. package/bin/{chunk-d2y3rbjm.js → chunk-mzg1h07d.js} +1 -1
  85. package/bin/{chunk-ysq64j13.js → chunk-n4meg9wb.js} +1 -1
  86. package/bin/{chunk-acxm86fh.js → chunk-nrwna4ha.js} +1 -1
  87. package/bin/chunk-nyhqy6q2.js +62 -0
  88. package/bin/{chunk-4zq8vxcy.css → chunk-pmswtfe3.css} +1 -1
  89. package/bin/chunk-pq18zenh.js +2 -0
  90. package/bin/chunk-pxw97qbq.js +3 -0
  91. package/bin/chunk-q09dfja5.js +3 -0
  92. package/bin/{chunk-m54p1cvp.js → chunk-q24epdh8.js} +2 -2
  93. package/bin/{chunk-k5w64spz.js → chunk-qksb0v3c.js} +2 -2
  94. package/bin/chunk-qqk51620.js +2 -0
  95. package/bin/chunk-r0w920zb.js +1 -0
  96. package/bin/{chunk-08m8mzfa.js → chunk-re0b7sj7.js} +1 -1
  97. package/bin/chunk-rtngbgpk.js +7 -0
  98. package/bin/{chunk-5tmf3c0g.js → chunk-ry33f2qk.js} +2 -2
  99. package/bin/{chunk-9n0etqsy.js → chunk-s1n39qte.js} +1 -1
  100. package/bin/{chunk-3qdn3pty.js → chunk-s46zwr4p.js} +1 -1
  101. package/bin/chunk-s8t74q9m.js +1 -0
  102. package/bin/chunk-sd86v1e6.js +1 -0
  103. package/bin/{chunk-kpy0kpna.js → chunk-srn8t0v7.js} +2 -2
  104. package/bin/chunk-szzff7gd.js +1 -0
  105. package/bin/{chunk-fwf8yne2.js → chunk-t3t6021k.js} +2 -2
  106. package/bin/{chunk-eadb78m8.js → chunk-ta7bfdrn.js} +1 -1
  107. package/bin/chunk-thsbcbay.js +8 -0
  108. package/bin/chunk-tspps87j.js +1 -0
  109. package/bin/chunk-w7dn1m95.js +2 -0
  110. package/bin/chunk-w88219ex.js +3 -0
  111. package/bin/{chunk-pqm0g14r.js → chunk-wc8sc9r9.js} +2 -2
  112. package/bin/chunk-wg98cacx.js +2 -0
  113. package/bin/chunk-wsyg4rwg.js +2 -0
  114. package/bin/{chunk-n5hfy93f.js → chunk-xcwbg4w9.js} +3 -3
  115. package/bin/{chunk-dgx2zxze.js → chunk-xyjw8w3r.js} +2 -2
  116. package/bin/chunk-y2qp11v9.js +1 -0
  117. package/bin/{chunk-1fpqq6ed.js → chunk-ybhgmvxa.js} +2 -2
  118. package/bin/{chunk-1wq9hjjr.js → chunk-ygz6pawn.js} +1 -1
  119. package/bin/{chunk-mv79zk8q.js → chunk-ymeycphq.js} +3 -3
  120. package/bin/{chunk-wv4fe1fj.js → chunk-zemrvz79.js} +2 -2
  121. package/bin/{chunk-3rt9mnj3.js → chunk-ztmj61z9.js} +1 -1
  122. package/bin/chunk-zzx99j8t.js +2 -0
  123. package/bin/shumai-app.html +1 -1
  124. package/bin/shumai-app.js +308 -283
  125. package/package.json +7 -7
  126. package/prisma/migrations/20260722022359_add_skill_permission/migration.sql +2 -0
  127. package/prisma/migrations/20260723025234_add_ai_usage_table/migration.sql +28 -0
  128. package/prisma/migrations/20260723032755_add_ai_usage_unique_constraint/migration.sql +8 -0
  129. package/prisma/schema.prisma +26 -0
  130. package/bin/chunk-09wp20mv.js +0 -1
  131. package/bin/chunk-0at8vxt5.js +0 -3
  132. package/bin/chunk-0zv7f9ca.js +0 -2
  133. package/bin/chunk-2k4vp654.js +0 -2
  134. package/bin/chunk-2s5a64nr.js +0 -2
  135. package/bin/chunk-2tbya52d.js +0 -2
  136. package/bin/chunk-2vs3evc7.js +0 -14
  137. package/bin/chunk-33169en9.js +0 -8
  138. package/bin/chunk-33ee1cvv.js +0 -2
  139. package/bin/chunk-3m39v371.js +0 -1
  140. package/bin/chunk-4hnrd4qh.js +0 -2
  141. package/bin/chunk-6c4c7t0n.js +0 -1
  142. package/bin/chunk-6frqqxkv.js +0 -1
  143. package/bin/chunk-7rhjej0x.js +0 -3
  144. package/bin/chunk-7wvgtw25.js +0 -3
  145. package/bin/chunk-8s0ae37g.js +0 -1
  146. package/bin/chunk-94h8644q.js +0 -2
  147. package/bin/chunk-ac2ky3q0.js +0 -12
  148. package/bin/chunk-axx5bh38.js +0 -2
  149. package/bin/chunk-cthpdt54.js +0 -11
  150. package/bin/chunk-d0earxhc.js +0 -4
  151. package/bin/chunk-d0n8nxp3.js +0 -3
  152. package/bin/chunk-d22pyc5n.js +0 -1
  153. package/bin/chunk-dmgjse02.js +0 -4
  154. package/bin/chunk-e5833tbd.js +0 -2
  155. package/bin/chunk-g7wrxnmd.js +0 -1
  156. package/bin/chunk-gk7158n4.js +0 -2
  157. package/bin/chunk-hb5v9ees.js +0 -2
  158. package/bin/chunk-jrvrg4fx.js +0 -1
  159. package/bin/chunk-k712q1zj.js +0 -2
  160. package/bin/chunk-kef0rnwn.js +0 -1
  161. package/bin/chunk-n296vcfw.js +0 -3
  162. package/bin/chunk-n6jgyv4y.js +0 -3
  163. package/bin/chunk-nar4s9v9.js +0 -3
  164. package/bin/chunk-nn8e9j7c.js +0 -1
  165. package/bin/chunk-nwtb6dt1.js +0 -62
  166. package/bin/chunk-ps4h3387.js +0 -5
  167. package/bin/chunk-q4f5vvtx.js +0 -2
  168. package/bin/chunk-qqesrgjk.js +0 -7
  169. package/bin/chunk-qz9xht6d.js +0 -2
  170. package/bin/chunk-symna5cj.js +0 -1
  171. package/bin/chunk-twzgpwst.js +0 -2
  172. package/bin/chunk-vgvmt2m1.js +0 -2
  173. package/bin/chunk-w4t9n9te.js +0 -6
  174. package/bin/chunk-z14hh99h.js +0 -2
  175. package/bin/chunk-zsdwska1.js +0 -1
@@ -1,4 +1,4 @@
1
- import{A as B5,B as O5,I as Qd,J as bO,K as $k,L as cl,M as i3,N as P7,O as H3,v as gO,x as Jd,z as F5}from"./chunk-axx5bh38.js";import{$ as Ed}from"./chunk-q4f5vvtx.js";import{Xa as _p}from"./chunk-ajqsprm0.js";import{$a as Hd,_a as Od,ab as Md,bb as Dd,cb as Td,db as Rd,eb as Nd,fb as zd}from"./chunk-4hnrd4qh.js";import{$e as kp,Ie as C3,Je as _3,Ke as v_,Me as kb,Ne as S_,Oe as y_,Qe as k_,Re as M_,Se as Cb,Te as C_,Ue as __,Ve as wd,We as jd,Xe as dd,Ye as qd,Ze as hO,_e as cO,af as Cp,hf as _5}from"./chunk-cp18trqb.js";import{Jf as yd}from"./chunk-j8q688sx.js";import{Rf as c8}from"./chunk-4kk5g619.js";import{Wf as uO,Xf as wo,Yf as hi}from"./chunk-mnv6pj0k.js";import{$f as Pa,Eg as Le,Li as E2,Mg as bd,Ng as Zd,Ph as l3,Pi as Mi,Ri as Ln,Si as Ad,Th as f3,Ti as vd,Uh as ul,Ui as Sd,Vi as Mf,Wg as Ud,Xh as Xd,Xi as Df,Yg as r8,Yh as Vk,Yi as Tf,Zh as hh,Zi as l1,_g as O3,_h as ch,ag as mo,ai as Kd,aj as n3,bg as x,bi as Yk,cg as rt,dg as k5,dh as Id,di as Jk,fg as po,gh as oh,hg as Hf,hh as jo,hi as Ld,hj as It,ig as oO,ih as aO,ij as Yd,jh as iO,jj as mO,ki as l8,kj as h8,lj as kd,mi as pd,mj as Cd,nj as _d,oh as Gd,oi as Vd,pj as Fd,qh as $_,qj as Bd,th as Vn,ti as Qk,ui as Zk,wh as C5,wi as qo,xg as xd}from"./chunk-nwtb6dt1.js";import{$j as o4,Zj as Ie,_j as Me}from"./chunk-kbzm1pwx.js";var kw=Me((lJ,yw)=>{var qw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wM=/\n/g,jM=/^\s*/,dM=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,qM=/^:\s*/,AM=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,vM=/^[;\s]*/,SM=/^\s+|\s+$/g,yM=`
1
+ import{B as gO,D as Jd,F as F5,G as B5,H as O5,O as Qd,P as bO,Q as $k,R as cl,S as i3,T as P7,U as H3}from"./chunk-pq18zenh.js";import{ea as Ed}from"./chunk-wsyg4rwg.js";import{Wa as _p}from"./chunk-kfhtk3eh.js";import{$a as Hd,_a as Od,ab as Md,bb as Dd,cb as Td,db as Rd,eb as Nd,fb as zd}from"./chunk-0xbf8bcg.js";import{Bf as C3,Cf as _3,Df as v_,Ff as kb,Gf as S_,Hf as y_,Jf as k_,Kf as M_,Lf as Cb,Mf as C_,Nf as __,Of as wd,Pf as jd,Qf as dd,Rf as qd,Sf as hO,Tf as cO,Uf as kp,Vf as Cp,ag as _5}from"./chunk-77r8w95d.js";import{og as uO,pg as wo,qg as hi}from"./chunk-fa2g2wge.js";import{Mg as yd}from"./chunk-fz88kkk1.js";import{Og as c8}from"./chunk-dghtwyq1.js";import{Qg as Ln,Rg as Mf,Tg as Df,Ug as Tf,Vg as l1,Yg as n3,bh as Yd,ch as mO,dh as h8,eh as kd,fh as Cd,gh as _d,ih as Fd,jh as Bd}from"./chunk-gswbc6y9.js";import{$h as bd,Aj as l8,Cj as pd,Ei as Gd,Ej as Vd,Gi as $_,Ji as Vn,Jj as Qk,Kj as Zk,Lh as xd,Mi as C5,Mj as qo,Sh as Le,ai as Zd,bk as E2,dj as l3,gk as Mi,hj as f3,hk as Ad,ij as ul,ik as vd,ji as Ud,jk as Sd,li as r8,lj as Xd,mh as Pa,mj as Vk,mk as It,nh as mo,ni as O3,nj as hh,oh as x,oj as ch,ph as rt,qh as k5,qj as Kd,rj as Yk,si as Id,th as po,tj as Jk,vh as Hf,vi as oh,wh as oO,wi as jo,xi as aO,xj as Ld,yi as iO}from"./chunk-nyhqy6q2.js";import{Vk as Ie,Wk as Me,Xk as o4}from"./chunk-0qkj838r.js";var kw=Me((lJ,yw)=>{var qw=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wM=/\n/g,jM=/^\s*/,dM=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,qM=/^:\s*/,AM=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,vM=/^[;\s]*/,SM=/^\s+|\s+$/g,yM=`
2
2
  `,Aw="/",vw="*",Cf="",kM="comment",CM="declaration";function _M(t,e){if(typeof t!=="string")throw TypeError("First argument must be a string");if(!t)return[];e=e||{};var a=1,i=1;function s(d){var v=d.match(wM);if(v)a+=v.length;var k=d.lastIndexOf(yM);i=~k?d.length-k:i+d.length}function n(){var d={line:a,column:i};return function(v){return v.position=new l(d),c(),v}}function l(d){this.start=d,this.end={line:a,column:i},this.source=e.source}l.prototype.content=t;function f(d){var v=Error(e.source+":"+a+":"+i+": "+d);if(v.reason=d,v.filename=e.source,v.line=a,v.column=i,v.source=t,e.silent);else throw v}function o(d){var v=d.exec(t);if(!v)return;var k=v[0];return s(k),t=t.slice(k.length),v}function c(){o(jM)}function u(d){var v;d=d||[];while(v=m())if(v!==!1)d.push(v);return d}function m(){var d=n();if(Aw!=t.charAt(0)||vw!=t.charAt(1))return;var v=2;while(Cf!=t.charAt(v)&&(vw!=t.charAt(v)||Aw!=t.charAt(v+1)))++v;if(v+=2,Cf===t.charAt(v-1))return f("End of comment missing");var k=t.slice(2,v-2);return i+=2,s(k),t=t.slice(v),i+=2,d({type:kM,comment:k})}function p(){var d=n(),v=o(dM);if(!v)return;if(m(),!o(qM))return f("property missing ':'");var k=o(AM),y=d({type:CM,property:Sw(v[0].replace(qw,Cf)),value:k?Sw(k[0].replace(qw,Cf)):Cf});return o(vM),y}function w(){var d=[];u(d);var v;while(v=p())if(v!==!1)d.push(v),u(d);return d}return c(),w()}function Sw(t){return t?t.replace(SM,Cf):Cf}yw.exports=_M});var Cw=Me((Dc)=>{var FM=Dc&&Dc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Dc,"__esModule",{value:!0});Dc.default=OM;var BM=FM(kw());function OM(t,e){let a=null;if(!t||typeof t!=="string")return a;let i=(0,BM.default)(t),s=typeof e==="function";return i.forEach((n)=>{if(n.type!=="declaration")return;let{property:l,value:f}=n;if(s)e(l,f,n);else if(f)a=a||{},a[l]=f}),a}});var Ow=Me((Fw)=>{Object.defineProperty(Fw,"__esModule",{value:!0});Fw.camelCase=void 0;var HM=/^--[a-zA-Z0-9_-]+$/,MM=/-([a-z])/g,DM=/^[^-]+$/,TM=/^-(webkit|moz|ms|o|khtml)-/,RM=/^-(ms)-/,NM=function(t){return!t||DM.test(t)||HM.test(t)},zM=function(t,e){return e.toUpperCase()},_w=function(t,e){return"".concat(e,"-")},EM=function(t,e){if(e===void 0)e={};if(NM(t))return t;if(t=t.toLowerCase(),e.reactCompat)t=t.replace(RM,_w);else t=t.replace(TM,_w);return t.replace(MM,zM)};Fw.camelCase=EM});var Mw=Me((j4,Hw)=>{var xM=j4&&j4.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},UM=xM(Cw()),IM=Ow();function w4(t,e){var a={};if(!t||typeof t!=="string")return a;return(0,UM.default)(t,function(i,s){if(i&&s)a[(0,IM.camelCase)(i,e)]=s}),a}w4.default=w4;Hw.exports=w4});var ad=Me((ZP,ed)=>{var v5=Object.prototype.hasOwnProperty,td=Object.prototype.toString,Jj=Object.defineProperty,Qj=Object.getOwnPropertyDescriptor,Zj=function(e){if(typeof Array.isArray==="function")return Array.isArray(e);return td.call(e)==="[object Array]"},$j=function(e){if(!e||td.call(e)!=="[object Object]")return!1;var a=v5.call(e,"constructor"),i=e.constructor&&e.constructor.prototype&&v5.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!a&&!i)return!1;var s;for(s in e);return typeof s>"u"||v5.call(e,s)},Wj=function(e,a){if(Jj&&a.name==="__proto__")Jj(e,a.name,{enumerable:!0,configurable:!0,value:a.newValue,writable:!0});else e[a.name]=a.newValue},Pj=function(e,a){if(a==="__proto__"){if(!v5.call(e,a))return;else if(Qj)return Qj(e,a).value}return e[a]};ed.exports=function t(){var e,a,i,s,n,l,f=arguments[0],o=1,c=arguments.length,u=!1;if(typeof f==="boolean")u=f,f=arguments[1]||{},o=2;if(f==null||typeof f!=="object"&&typeof f!=="function")f={};for(;o<c;++o)if(e=arguments[o],e!=null){for(a in e)if(i=Pj(f,a),s=Pj(e,a),f!==s){if(u&&s&&($j(s)||(n=Zj(s)))){if(n)n=!1,l=i&&Zj(i)?i:[];else l=i&&$j(i)?i:{};Wj(f,{name:a,newValue:t(u,l,s)})}else if(typeof s<"u")Wj(f,{name:a,newValue:s})}}return f}});var h0=Me((Met,Wd)=>{var $c;if(typeof window<"u")$c=window;else if(typeof global<"u")$c=global;else if(typeof self<"u")$c=self;else $c={};Wd.exports=$c});var u8=Me((Det,tq)=>{var Pd=Array.prototype.slice;tq.exports=AR;function AR(t,e){if(!("length"in t))t=[t];t=Pd.call(t);while(t.length){var a=t.shift(),i=e(a);if(i)return i;if(a.childNodes&&a.childNodes.length)t=Pd.call(a.childNodes).concat(t)}}});var aq=Me((Tet,eq)=>{eq.exports=Ao;function Ao(t,e){if(!(this instanceof Ao))return new Ao(t,e);this.data=t,this.nodeValue=t,this.length=t.length,this.ownerDocument=e||null}Ao.prototype.nodeType=8;Ao.prototype.nodeName="#comment";Ao.prototype.toString=function(){return"[object Comment]"}});var sq=Me((Ret,iq)=>{iq.exports=ml;function ml(t,e){if(!(this instanceof ml))return new ml(t);this.data=t||"",this.length=this.data.length,this.ownerDocument=e||null}ml.prototype.type="DOMTextNode";ml.prototype.nodeType=3;ml.prototype.nodeName="#text";ml.prototype.toString=function(){return this.data};ml.prototype.replaceData=function(e,a,i){var s=this.data,n=s.substring(0,e),l=s.substring(e+a,s.length);this.data=n+i+l,this.length=this.data.length}});var m8=Me((Net,nq)=>{nq.exports=vR;function vR(t){var e=this,a=t.type;if(!t.target)t.target=e;if(!e.listeners)e.listeners={};var i=e.listeners[a];if(i)return i.forEach(function(s){if(t.currentTarget=e,typeof s==="function")s(t);else s.handleEvent(t)});if(e.parentNode)e.parentNode.dispatchEvent(t)}});var g8=Me((zet,lq)=>{lq.exports=SR;function SR(t,e){var a=this;if(!a.listeners)a.listeners={};if(!a.listeners[t])a.listeners[t]=[];if(a.listeners[t].indexOf(e)===-1)a.listeners[t].push(e)}});var b8=Me((Eet,fq)=>{fq.exports=yR;function yR(t,e){var a=this;if(!a.listeners)return;if(!a.listeners[t])return;var i=a.listeners[t],s=i.indexOf(e);if(s!==-1)i.splice(s,1)}});var cq=Me((xet,hq)=>{hq.exports=rq;var kR=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function rq(t){switch(t.nodeType){case 3:return p8(t.data);case 8:return"<!--"+t.data+"-->";default:return CR(t)}}function CR(t){var e=[],a=t.tagName;if(t.namespaceURI==="http://www.w3.org/1999/xhtml")a=a.toLowerCase();if(e.push("<"+a+OR(t)+BR(t)),kR.indexOf(a)>-1)e.push(" />");else{if(e.push(">"),t.childNodes.length)e.push.apply(e,t.childNodes.map(rq));else if(t.textContent||t.innerText)e.push(p8(t.textContent||t.innerText));else if(t.innerHTML)e.push(t.innerHTML);e.push("</"+a+">")}return e.join("")}function _R(t,e){var a=typeof t[e];if(e==="style"&&Object.keys(t.style).length>0)return!0;return t.hasOwnProperty(e)&&(a==="string"||a==="boolean"||a==="number")&&e!=="nodeName"&&e!=="className"&&e!=="tagName"&&e!=="textContent"&&e!=="innerText"&&e!=="namespaceURI"&&e!=="innerHTML"}function FR(t){if(typeof t==="string")return t;var e="";return Object.keys(t).forEach(function(a){var i=t[a];a=a.replace(/[A-Z]/g,function(s){return"-"+s.toLowerCase()}),e+=a+":"+i+";"}),e}function BR(t){var e=t.dataset,a=[];for(var i in e)a.push({name:"data-"+i,value:e[i]});return a.length?oq(a):""}function oq(t){var e=[];return t.forEach(function(a){var{name:i,value:s}=a;if(i==="style")s=FR(s);e.push(i+'="'+HR(s)+'"')}),e.length?" "+e.join(" "):""}function OR(t){var e=[];for(var a in t)if(_R(t,a))e.push({name:a,value:t[a]});for(var i in t._attributes)for(var s in t._attributes[i]){var n=t._attributes[i][s],l=(n.prefix?n.prefix+":":"")+s;e.push({name:l,value:n.value})}if(t.className)e.push({name:"class",value:t.className});return e.length?oq(e):""}function p8(t){var e="";if(typeof t==="string")e=t;else if(t)e=t.toString();return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function HR(t){return p8(t).replace(/"/g,"&quot;")}});var j8=Me((Uet,mq)=>{var w8=u8(),MR=m8(),DR=g8(),TR=b8(),RR=cq(),uq="http://www.w3.org/1999/xhtml";mq.exports=Ca;function Ca(t,e,a){if(!(this instanceof Ca))return new Ca(t);var i=a===void 0?uq:a||null;if(this.tagName=i===uq?String(t).toUpperCase():t,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=e||null,this.namespaceURI=i,this._attributes={},this.tagName==="INPUT")this.type="text"}Ca.prototype.type="DOMElement";Ca.prototype.nodeType=1;Ca.prototype.appendChild=function(e){if(e.parentNode)e.parentNode.removeChild(e);return this.childNodes.push(e),e.parentNode=this,e};Ca.prototype.replaceChild=function(e,a){if(e.parentNode)e.parentNode.removeChild(e);var i=this.childNodes.indexOf(a);return a.parentNode=null,this.childNodes[i]=e,e.parentNode=this,a};Ca.prototype.removeChild=function(e){var a=this.childNodes.indexOf(e);return this.childNodes.splice(a,1),e.parentNode=null,e};Ca.prototype.insertBefore=function(e,a){if(e.parentNode)e.parentNode.removeChild(e);var i=a===null||a===void 0?-1:this.childNodes.indexOf(a);if(i>-1)this.childNodes.splice(i,0,e);else this.childNodes.push(e);return e.parentNode=this,e};Ca.prototype.setAttributeNS=function(e,a,i){var s=null,n=a,l=a.indexOf(":");if(l>-1)s=a.substr(0,l),n=a.substr(l+1);if(this.tagName==="INPUT"&&a==="type")this.type=i;else{var f=this._attributes[e]||(this._attributes[e]={});f[n]={value:i,prefix:s}}};Ca.prototype.getAttributeNS=function(e,a){var i=this._attributes[e],s=i&&i[a]&&i[a].value;if(this.tagName==="INPUT"&&a==="type")return this.type;if(typeof s!=="string")return null;return s};Ca.prototype.removeAttributeNS=function(e,a){if(!Object.prototype.hasOwnProperty.call(this._attributes,e))return;var i=this._attributes[e];if(i&&Object.prototype.hasOwnProperty.call(i,a))delete i[a]};Ca.prototype.hasAttributeNS=function(e,a){var i=this._attributes[e];return!!i&&a in i};Ca.prototype.setAttribute=function(e,a){return this.setAttributeNS(null,e,a)};Ca.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)};Ca.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)};Ca.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)};Ca.prototype.removeEventListener=TR;Ca.prototype.addEventListener=DR;Ca.prototype.dispatchEvent=MR;Ca.prototype.focus=function(){return};Ca.prototype.toString=function(){return RR(this)};Ca.prototype.getElementsByClassName=function(e){var a=e.split(" "),i=[];return w8(this,function(s){if(s.nodeType===1){var n=s.className||"",l=n.split(" ");if(a.every(function(f){return l.indexOf(f)!==-1}))i.push(s)}}),i};Ca.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var a=[];return w8(this.childNodes,function(i){if(i.nodeType===1&&(e==="*"||i.tagName.toLowerCase()===e))a.push(i)}),a};Ca.prototype.contains=function(e){return w8(this,function(a){return e===a})||!1}});var bq=Me((Iet,gq)=>{var d8=j8();gq.exports=c0;function c0(t){if(!(this instanceof c0))return new c0;this.childNodes=[],this.parentNode=null,this.ownerDocument=t||null}c0.prototype.type="DocumentFragment";c0.prototype.nodeType=11;c0.prototype.nodeName="#document-fragment";c0.prototype.appendChild=d8.prototype.appendChild;c0.prototype.replaceChild=d8.prototype.replaceChild;c0.prototype.removeChild=d8.prototype.removeChild;c0.prototype.toString=function(){return this.childNodes.map(function(e){return String(e)}).join("")}});var wq=Me((Get,pq)=>{pq.exports=q8;function q8(t){}q8.prototype.initEvent=function(e,a,i){this.type=e,this.bubbles=a,this.cancelable=i};q8.prototype.preventDefault=function(){}});var dq=Me((Xet,jq)=>{var NR=u8(),zR=aq(),ER=sq(),Wc=j8(),xR=bq(),UR=wq(),IR=m8(),GR=g8(),XR=b8();jq.exports=H5;function H5(){if(!(this instanceof H5))return new H5;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Ws=H5.prototype;Ws.createTextNode=function(e){return new ER(e,this)};Ws.createElementNS=function(e,a){var i=e===null?null:String(e);return new Wc(a,this,i)};Ws.createElement=function(e){return new Wc(e,this)};Ws.createDocumentFragment=function(){return new xR(this)};Ws.createEvent=function(e){return new UR(e)};Ws.createComment=function(e){return new zR(e,this)};Ws.getElementById=function(e){e=String(e);var a=NR(this.childNodes,function(i){if(String(i.id)===e)return i});return a||null};Ws.getElementsByClassName=Wc.prototype.getElementsByClassName;Ws.getElementsByTagName=Wc.prototype.getElementsByTagName;Ws.contains=Wc.prototype.contains;Ws.removeEventListener=XR;Ws.addEventListener=GR;Ws.dispatchEvent=IR});var Aq=Me((Ket,qq)=>{var KR=dq();qq.exports=new KR});var A8=Me((Let,Sq)=>{var vq=typeof global<"u"?global:typeof window<"u"?window:{},LR=Aq(),Pc;if(typeof document<"u")Pc=document;else if(Pc=vq["__GLOBAL_DOCUMENT_CACHE@4"],!Pc)Pc=vq["__GLOBAL_DOCUMENT_CACHE@4"]=LR;Sq.exports=Pc});var yq=Me((Vet,f1)=>{function v8(){return f1.exports=v8=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var i in a)({}).hasOwnProperty.call(a,i)&&(t[i]=a[i])}return t},f1.exports.__esModule=!0,f1.exports.default=f1.exports,v8.apply(null,arguments)}f1.exports=v8,f1.exports.__esModule=!0,f1.exports.default=f1.exports});var Cq=Me((Yet,kq)=>{kq.exports=YR;var VR=Object.prototype.toString;function YR(t){if(!t)return!1;var e=VR.call(t);return e==="[object Function]"||typeof t==="function"&&e!=="[object RegExp]"||typeof window<"u"&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}});var Bq=Me((Jet,Fq)=>{function JR(t,e){var a=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a)return(a=a.call(t)).next.bind(a);if(Array.isArray(t)||(a=QR(t))||e&&t&&typeof t.length==="number"){if(a)t=a;var i=0;return function(){if(i>=t.length)return{done:!0};return{done:!1,value:t[i++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QR(t,e){if(!t)return;if(typeof t==="string")return _q(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor)a=t.constructor.name;if(a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _q(t,e)}function _q(t,e){if(e==null||e>t.length)e=t.length;for(var a=0,i=Array(e);a<e;a++)i[a]=t[a];return i}var ZR=function(){function t(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var e=t.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},e.addInterceptor=function(i,s){if(!this.typeToInterceptorsMap_.has(i))this.typeToInterceptorsMap_.set(i,new Set);var n=this.typeToInterceptorsMap_.get(i);if(n.has(s))return!1;return n.add(s),!0},e.removeInterceptor=function(i,s){var n=this.typeToInterceptorsMap_.get(i);if(n&&n.has(s))return n.delete(s),!0;return!1},e.clearInterceptorsByType=function(i){var s=this.typeToInterceptorsMap_.get(i);if(!s)return!1;return this.typeToInterceptorsMap_.delete(i),this.typeToInterceptorsMap_.set(i,new Set),!0},e.clear=function(){if(!this.typeToInterceptorsMap_.size)return!1;return this.typeToInterceptorsMap_=new Map,!0},e.getForType=function(i){return this.typeToInterceptorsMap_.get(i)||new Set},e.execute=function(i,s){var n=this.getForType(i);for(var l=JR(n),f;!(f=l()).done;){var o=f.value;try{s=o(s)}catch(c){}}return s},t}();Fq.exports=ZR});var Hq=Me((Qet,Oq)=>{var $R=function(){function t(){this.maxAttempts_=1,this.delayFactor_=0.1,this.fuzzFactor_=0.1,this.initialDelay_=1000,this.enabled_=!1}var e=t.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.maxAttempts_=1,this.delayFactor_=0.1,this.fuzzFactor_=0.1,this.initialDelay_=1000,this.enabled_=!1},e.getMaxAttempts=function(){return this.maxAttempts_},e.setMaxAttempts=function(i){this.maxAttempts_=i},e.getDelayFactor=function(){return this.delayFactor_},e.setDelayFactor=function(i){this.delayFactor_=i},e.getFuzzFactor=function(){return this.fuzzFactor_},e.setFuzzFactor=function(i){this.fuzzFactor_=i},e.getInitialDelay=function(){return this.initialDelay_},e.setInitialDelay=function(i){this.initialDelay_=i},e.createRetry=function(i){var s=i===void 0?{}:i,n=s.maxAttempts,l=s.delayFactor,f=s.fuzzFactor,o=s.initialDelay;return new WR({maxAttempts:n||this.maxAttempts_,delayFactor:l||this.delayFactor_,fuzzFactor:f||this.fuzzFactor_,initialDelay:o||this.initialDelay_})},t}(),WR=function(){function t(a){this.maxAttempts_=a.maxAttempts,this.delayFactor_=a.delayFactor,this.fuzzFactor_=a.fuzzFactor,this.currentDelay_=a.initialDelay,this.currentAttempt_=1}var e=t.prototype;return e.moveToNextAttempt=function(){this.currentAttempt_++;var i=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+i},e.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},e.getCurrentDelay=function(){return this.currentDelay_},e.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},e.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},e.getCurrentFuzzedDelay=function(){var i=this.getCurrentMinPossibleDelay(),s=this.getCurrentMaxPossibleDelay();return i+Math.random()*(s-i)},t}();Oq.exports=$R});var Dq=Me((Zet,Mq)=>{var PR=h0(),tN=function(e,a){if(a===void 0)a=!1;return function(i,s,n){if(i){e(i);return}if(s.statusCode>=400&&s.statusCode<=599){var l=n;if(a)if(PR.TextDecoder){var f=eN(s.headers&&s.headers["content-type"]);try{l=new TextDecoder(f).decode(n)}catch(o){}}else l=String.fromCharCode.apply(null,new Uint8Array(n));e({cause:l});return}e(null,n)}};function eN(t){if(t===void 0)t="";return t.toLowerCase().split(";").reduce(function(e,a){var i=a.split("="),s=i[0],n=i[1];if(s.trim()==="charset")return n.trim();return e},"utf-8")}Mq.exports=tN});var zq=Me(($et,y8)=>{var Tq=h0(),aN=yq(),iN=Cq(),Rq=Bq(),sN=Hq();ti.httpHandler=Dq();ti.requestInterceptorsStorage=new Rq;ti.responseInterceptorsStorage=new Rq;ti.retryManager=new sN;var nN=function(e){var a={};if(!e)return a;return e.trim().split(`
4
4
  `).forEach(function(i){var s=i.indexOf(":"),n=i.slice(0,s).trim().toLowerCase(),l=i.slice(s+1).trim();if(typeof a[n]>"u")a[n]=l;else if(Array.isArray(a[n]))a[n].push(l);else a[n]=[a[n],l]}),a};y8.exports=ti;y8.exports.default=ti;ti.XMLHttpRequest=Tq.XMLHttpRequest||oN;ti.XDomainRequest="withCredentials"in new ti.XMLHttpRequest?ti.XMLHttpRequest:Tq.XDomainRequest;lN(["get","put","post","patch","head","delete"],function(t){ti[t==="delete"?"del":t]=function(e,a,i){return a=Nq(e,a,i),a.method=t.toUpperCase(),S8(a)}});function lN(t,e){for(var a=0;a<t.length;a++)e(t[a])}function fN(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function Nq(t,e,a){var i=t;if(iN(e)){if(a=e,typeof t==="string")i={uri:t}}else i=aN({},e,{uri:t});return i.callback=a,i}function ti(t,e,a){return e=Nq(t,e,a),S8(e)}function S8(t){if(typeof t.callback>"u")throw Error("callback argument missing");if(t.requestType&&ti.requestInterceptorsStorage.getIsEnabled()){var e={uri:t.uri||t.url,headers:t.headers||{},body:t.body,metadata:t.metadata||{},retry:t.retry,timeout:t.timeout},a=ti.requestInterceptorsStorage.execute(t.requestType,e);t.uri=a.uri,t.headers=a.headers,t.body=a.body,t.metadata=a.metadata,t.retry=a.retry,t.timeout=a.timeout}var i=!1,s=function(D,T,z){if(!i)i=!0,t.callback(D,T,z)};function n(){if(c.readyState===4&&!ti.responseInterceptorsStorage.getIsEnabled())setTimeout(o,0)}function l(){var M=void 0;if(c.response)M=c.response;else M=c.responseText||rN(c);if(y)try{M=JSON.parse(M)}catch(D){}return M}function f(M){if(clearTimeout(B),clearTimeout(t.retryTimeout),!(M instanceof Error))M=Error(""+(M||"Unknown XMLHttpRequest Error"));if(M.statusCode=0,!m&&ti.retryManager.getIsEnabled()&&t.retry&&t.retry.shouldRetry()){t.retryTimeout=setTimeout(function(){t.retry.moveToNextAttempt(),t.xhr=c,S8(t)},t.retry.getCurrentFuzzedDelay());return}if(t.requestType&&ti.responseInterceptorsStorage.getIsEnabled()){var D={headers:H.headers||{},body:H.body,responseUrl:c.responseURL,responseType:c.responseType},T=ti.responseInterceptorsStorage.execute(t.requestType,D);H.body=T.body,H.headers=T.headers}return s(M,H)}function o(){if(m)return;var M;if(clearTimeout(B),clearTimeout(t.retryTimeout),t.useXDR&&c.status===void 0)M=200;else M=c.status===1223?204:c.status;var D=H,T=null;if(M!==0){if(D={body:l(),statusCode:M,method:w,headers:{},url:p,rawRequest:c},c.getAllResponseHeaders)D.headers=nN(c.getAllResponseHeaders())}else T=Error("Internal XMLHttpRequest Error");if(t.requestType&&ti.responseInterceptorsStorage.getIsEnabled()){var z={headers:D.headers||{},body:D.body,responseUrl:c.responseURL,responseType:c.responseType},E=ti.responseInterceptorsStorage.execute(t.requestType,z);D.body=E.body,D.headers=E.headers}return s(T,D,D.body)}var c=t.xhr||null;if(!c)if(t.cors||t.useXDR)c=new ti.XDomainRequest;else c=new ti.XMLHttpRequest;var u,m,p=c.url=t.uri||t.url,w=c.method=t.method||"GET",d=t.body||t.data,v=c.headers=t.headers||{},k=!!t.sync,y=!1,B,H={body:void 0,headers:{},statusCode:0,method:w,url:p,rawRequest:c};if("json"in t&&t.json!==!1){if(y=!0,v.accept||v.Accept||(v.Accept="application/json"),w!=="GET"&&w!=="HEAD")v["content-type"]||v["Content-Type"]||(v["Content-Type"]="application/json"),d=JSON.stringify(t.json===!0?d:t.json)}if(c.onreadystatechange=n,c.onload=o,c.onerror=f,c.onprogress=function(){},c.onabort=function(){m=!0,clearTimeout(t.retryTimeout)},c.ontimeout=f,c.open(w,p,!k,t.username,t.password),!k)c.withCredentials=!!t.withCredentials;if(!k&&t.timeout>0)B=setTimeout(function(){if(m)return;m=!0,c.abort("timeout");var M=Error("XMLHttpRequest timeout");M.code="ETIMEDOUT",f(M)},t.timeout);if(c.setRequestHeader){for(u in v)if(v.hasOwnProperty(u))c.setRequestHeader(u,v[u])}else if(t.headers&&!fN(t.headers))throw Error("Headers cannot be set on an XDomainRequest object");if("responseType"in t)c.responseType=t.responseType;if("beforeSend"in t&&typeof t.beforeSend==="function")t.beforeSend(c);return c.send(d||null),c}function rN(t){try{if(t.responseType==="document")return t.responseXML;var e=t.responseXML&&t.responseXML.documentElement.nodeName==="parsererror";if(t.responseType===""&&!e)return t.responseXML}catch(a){}return null}function oN(){}});var Kq=Me((Wet,Xq)=>{var Eq=A8(),C8=Object.create||function(){function t(){}return function(e){if(arguments.length!==1)throw Error("Object.create shim only accepts one parameter.");return t.prototype=e,new t}}();function Ps(t,e){this.name="ParsingError",this.code=t.code,this.message=e||t.message}Ps.prototype=C8(Error.prototype);Ps.prototype.constructor=Ps;Ps.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function _8(t){function e(i,s,n,l){return(i|0)*3600+(s|0)*60+(n|0)+(l|0)/1000}var a=t.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);if(!a)return null;if(a[3])return e(a[1],a[2],a[3].replace(":",""),a[4]);else if(a[1]>59)return e(a[1],a[2],0,a[4]);else return e(0,a[1],a[2],a[4])}function e2(){this.values=C8(null)}e2.prototype={set:function(t,e){if(!this.get(t)&&e!=="")this.values[t]=e},get:function(t,e,a){if(a)return this.has(t)?this.values[t]:e[a];return this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,a){for(var i=0;i<a.length;++i)if(e===a[i]){this.set(t,e);break}},integer:function(t,e){if(/^-?\d+$/.test(e))this.set(t,parseInt(e,10))},percent:function(t,e){var a;if(a=e.match(/^([\d]{1,3})(\.[\d]*)?%$/)){if(e=parseFloat(e),e>=0&&e<=100)return this.set(t,e),!0}return!1}};function t2(t,e,a,i){var s=i?t.split(i):[t];for(var n in s){if(typeof s[n]!=="string")continue;var l=s[n].split(a);if(l.length!==2)continue;var f=l[0].trim(),o=l[1].trim();e(f,o)}}function hN(t,e,a){var i=t;function s(){var f=_8(t);if(f===null)throw new Ps(Ps.Errors.BadTimeStamp,"Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),f}function n(f,o){var c=new e2;t2(f,function(u,m){switch(u){case"region":for(var p=a.length-1;p>=0;p--)if(a[p].id===m){c.set(u,a[p].region);break}break;case"vertical":c.alt(u,m,["rl","lr"]);break;case"line":var w=m.split(","),d=w[0];if(c.integer(u,d),c.percent(u,d)&&c.set("snapToLines",!1),c.alt(u,d,["auto"]),w.length===2)c.alt("lineAlign",w[1],["start","center","end"]);break;case"position":if(w=m.split(","),c.percent(u,w[0]),w.length===2)c.alt("positionAlign",w[1],["start","center","end"]);break;case"size":c.percent(u,m);break;case"align":c.alt(u,m,["start","center","end","left","right"]);break}},/:/,/\s/),o.region=c.get("region",null),o.vertical=c.get("vertical","");try{o.line=c.get("line","auto")}catch(u){}o.lineAlign=c.get("lineAlign","start"),o.snapToLines=c.get("snapToLines",!0),o.size=c.get("size",100);try{o.align=c.get("align","center")}catch(u){o.align=c.get("align","middle")}try{o.position=c.get("position","auto")}catch(u){o.position=c.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},o.align)}o.positionAlign=c.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},o.align)}function l(){t=t.replace(/^\s+/,"")}if(l(),e.startTime=s(),l(),t.substr(0,3)!=="-->")throw new Ps(Ps.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+i);t=t.substr(3),l(),e.endTime=s(),l(),n(t,e)}var k8=Eq.createElement&&Eq.createElement("textarea"),cN={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},xq={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},uN={v:"title",lang:"lang"},Uq={rt:"ruby"};function Gq(t,e){function a(){if(!e)return null;function d(k){return e=e.substr(k.length),k}var v=e.match(/^([^<]*)(<[^>]*>?)?/);return d(v[1]?v[1]:v[2])}function i(d){return k8.innerHTML=d,d=k8.textContent,k8.textContent="",d}function s(d,v){return!Uq[v.localName]||Uq[v.localName]===d.localName}function n(d,v){var k=cN[d];if(!k)return null;var y=t.document.createElement(k),B=uN[d];if(B&&v)y[B]=v.trim();return y}var l=t.document.createElement("div"),f=l,o,c=[];while((o=a())!==null){if(o[0]==="<"){if(o[1]==="/"){if(c.length&&c[c.length-1]===o.substr(2).replace(">",""))c.pop(),f=f.parentNode;continue}var u=_8(o.substr(1,o.length-2)),m;if(u){m=t.document.createProcessingInstruction("timestamp",u),f.appendChild(m);continue}var p=o.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!p)continue;if(m=n(p[1],p[3]),!m)continue;if(!s(f,m))continue;if(p[2]){var w=p[2].split(".");w.forEach(function(d){var v=/^bg_/.test(d),k=v?d.slice(3):d;if(xq.hasOwnProperty(k)){var y=v?"background-color":"color",B=xq[k];m.style[y]=B}}),m.className=w.join(" ")}c.push(p[1]),f.appendChild(m),f=m;continue}f.appendChild(t.document.createTextNode(i(o)))}return l}var Iq=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function mN(t){for(var e=0;e<Iq.length;e++){var a=Iq[e];if(t>=a[0]&&t<=a[1])return!0}return!1}function gN(t){var e=[],a="",i;if(!t||!t.childNodes)return"ltr";function s(f,o){for(var c=o.childNodes.length-1;c>=0;c--)f.push(o.childNodes[c])}function n(f){if(!f||!f.length)return null;var o=f.pop(),c=o.textContent||o.innerText;if(c){var u=c.match(/^.*(\n|\r)/);if(u)return f.length=0,u[0];return c}if(o.tagName==="ruby")return n(f);if(o.childNodes)return s(f,o),n(f)}s(e,t);while(a=n(e))for(var l=0;l<a.length;l++)if(i=a.charCodeAt(l),mN(i))return"rtl";return"ltr"}function bN(t){if(typeof t.line==="number"&&(t.snapToLines||t.line>=0&&t.line<=100))return t.line;if(!t.track||!t.track.textTrackList||!t.track.textTrackList.mediaElement)return-1;var e=t.track,a=e.textTrackList,i=0;for(var s=0;s<a.length&&a[s]!==e;s++)if(a[s].mode==="showing")i++;return++i*-1}function D5(){}D5.prototype.applyStyles=function(t,e){e=e||this.div;for(var a in t)if(t.hasOwnProperty(a))e.style[a]=t[a]};D5.prototype.formatStyle=function(t,e){return t===0?0:t+e};function M5(t,e,a){D5.call(this),this.cue=e,this.cueDiv=Gq(t,e.text);var i={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(i,this.cueDiv),this.div=t.document.createElement("div"),i={direction:gN(this.cueDiv),writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:e.align==="middle"?"center":e.align,font:a.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(i),this.div.appendChild(this.cueDiv);var s=0;switch(e.positionAlign){case"start":case"line-left":s=e.position;break;case"center":s=e.position-e.size/2;break;case"end":case"line-right":s=e.position-e.size;break}if(e.vertical==="")this.applyStyles({left:this.formatStyle(s,"%"),width:this.formatStyle(e.size,"%")});else this.applyStyles({top:this.formatStyle(s,"%"),height:this.formatStyle(e.size,"%")});this.move=function(n){this.applyStyles({top:this.formatStyle(n.top,"px"),bottom:this.formatStyle(n.bottom,"px"),left:this.formatStyle(n.left,"px"),right:this.formatStyle(n.right,"px"),height:this.formatStyle(n.height,"px"),width:this.formatStyle(n.width,"px")})}}M5.prototype=C8(D5.prototype);M5.prototype.constructor=M5;function hs(t){var e,a,i,s;if(t.div){a=t.div.offsetHeight,i=t.div.offsetWidth,s=t.div.offsetTop;var n=(n=t.div.childNodes)&&(n=n[0])&&n.getClientRects&&n.getClientRects();t=t.div.getBoundingClientRect(),e=n?Math.max(n[0]&&n[0].height||0,t.height/n.length):0}this.left=t.left,this.right=t.right,this.top=t.top||s,this.height=t.height||a,this.bottom=t.bottom||s+(t.height||a),this.width=t.width||i,this.lineHeight=e!==void 0?e:t.lineHeight}hs.prototype.move=function(t,e){switch(e=e!==void 0?e:this.lineHeight,t){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e;break}};hs.prototype.overlaps=function(t){return this.left<t.right&&this.right>t.left&&this.top<t.bottom&&this.bottom>t.top};hs.prototype.overlapsAny=function(t){for(var e=0;e<t.length;e++)if(this.overlaps(t[e]))return!0;return!1};hs.prototype.within=function(t){return this.top>=t.top&&this.bottom<=t.bottom&&this.left>=t.left&&this.right<=t.right};hs.prototype.overlapsOppositeAxis=function(t,e){switch(e){case"+x":return this.left<t.left;case"-x":return this.right>t.right;case"+y":return this.top<t.top;case"-y":return this.bottom>t.bottom}};hs.prototype.intersectPercentage=function(t){var e=Math.max(0,Math.min(this.right,t.right)-Math.max(this.left,t.left)),a=Math.max(0,Math.min(this.bottom,t.bottom)-Math.max(this.top,t.top)),i=e*a;return i/(this.height*this.width)};hs.prototype.toCSSCompatValues=function(t){return{top:this.top-t.top,bottom:t.bottom-this.bottom,left:this.left-t.left,right:t.right-this.right,height:this.height,width:this.width}};hs.getSimpleBoxPosition=function(t){var e=t.div?t.div.offsetHeight:t.tagName?t.offsetHeight:0,a=t.div?t.div.offsetWidth:t.tagName?t.offsetWidth:0,i=t.div?t.div.offsetTop:t.tagName?t.offsetTop:0;t=t.div?t.div.getBoundingClientRect():t.tagName?t.getBoundingClientRect():t;var s={left:t.left,right:t.right,top:t.top||i,height:t.height||e,bottom:t.bottom||i+(t.height||e),width:t.width||a};return s};function pN(t,e,a,i){function s(k,y){var B,H=new hs(k),M=1;for(var D=0;D<y.length;D++){while(k.overlapsOppositeAxis(a,y[D])||k.within(a)&&k.overlapsAny(i))k.move(y[D]);if(k.within(a))return k;var T=k.intersectPercentage(a);if(M>T)B=new hs(k),M=T;k=new hs(H)}return B||H}var n=new hs(e),l=e.cue,f=bN(l),o=[];if(l.snapToLines){var c;switch(l.vertical){case"":o=["+y","-y"],c="height";break;case"rl":o=["+x","-x"],c="width";break;case"lr":o=["-x","+x"],c="width";break}var u=n.lineHeight,m=u*Math.round(f),p=a[c]+u,w=o[0];if(Math.abs(m)>p)m=m<0?-1:1,m*=Math.ceil(p/u)*u;if(f<0)m+=l.vertical===""?a.height:a.width,o=o.reverse();n.move(w,m)}else{var d=n.lineHeight/a.height*100;switch(l.lineAlign){case"center":f-=d/2;break;case"end":f-=d;break}switch(l.vertical){case"":e.applyStyles({top:e.formatStyle(f,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(f,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(f,"%")});break}o=["+y","-x","+x","-y"],n=new hs(e)}var v=s(n,o);e.move(v.toCSSCompatValues(a))}function vo(){}vo.StringDecoder=function(){return{decode:function(t){if(!t)return"";if(typeof t!=="string")throw Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}};vo.convertCueToDOMTree=function(t,e){if(!t||!e)return null;return Gq(t,e)};var wN=0.05,jN="sans-serif",dN="1.5%";vo.processCues=function(t,e,a){if(!t||!e||!a)return null;while(a.firstChild)a.removeChild(a.firstChild);var i=t.document.createElement("div");i.style.position="absolute",i.style.left="0",i.style.right="0",i.style.top="0",i.style.bottom="0",i.style.margin=dN,a.appendChild(i);function s(u){for(var m=0;m<u.length;m++)if(u[m].hasBeenReset||!u[m].displayState)return!0;return!1}if(!s(e)){for(var n=0;n<e.length;n++)i.appendChild(e[n].displayState);return}var l=[],f=hs.getSimpleBoxPosition(i),o=Math.round(f.height*wN*100)/100,c={font:o+"px "+jN};(function(){var u,m;for(var p=0;p<e.length;p++)m=e[p],u=new M5(t,m,c),i.appendChild(u.div),pN(t,u,f,l),m.displayState=u.div,l.push(hs.getSimpleBoxPosition(u))})()};vo.Parser=function(t,e,a){if(!a)a=e,e={};if(!e)e={};this.window=t,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=a||new TextDecoder("utf8"),this.regionList=[]};vo.Parser.prototype={reportOrThrowError:function(t){if(t instanceof Ps)this.onparsingerror&&this.onparsingerror(t);else throw t},parse:function(t){var e=this;if(t)e.buffer+=e.decoder.decode(t,{stream:!0});function a(){var u=e.buffer,m=0;while(m<u.length&&u[m]!=="\r"&&u[m]!==`
@@ -317,4 +317,4 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
317
317
  `)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#c(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=Ti._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,a){let i=null;if(t instanceof mp){let{data:{defaultAppearanceData:{fontSize:n,fontColor:l},rect:f,rotation:o,id:c,popupRef:u,richText:m,contentsObj:p,creationDate:w,modificationDate:d},textContent:v,textPosition:k,parent:{page:{pageNumber:y}}}=t;if(!v?.length)return null;i=t={annotationType:je.FREETEXT,color:Array.from(l),fontSize:n,value:v.join(`
318
318
  `),position:k,pageIndex:y-1,rect:f.slice(0),rotation:o,annotationElementId:c,id:c,deleted:!1,popupRef:u,comment:p?.str||null,richText:m,creationDate:w,modificationDate:d}}let s=await super.deserialize(t,e,a);if(s.#i=t.fontSize,s.color=Nt.makeHexColor(...t.color),s.#t=Ti.#c(t.value),s._initialData=i,t.comment)s.setCommentData(t);return s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=se._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),a=Object.assign(super.serialize(t),{color:e,fontSize:this.#i,value:this.#u()});if(this.addComment(a),t)return a.isCopy=!0,a;if(this.annotationElementId&&!this.#g(a))return null;return a.id=this.annotationElementId,a}#g(t){let{value:e,fontSize:a,color:i,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==a||t.color.some((n,l)=>n!==i[l])||t.pageIndex!==s}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:a}=e;a.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,a.color=this.color,e.replaceChildren();for(let i of this.#t.split(`
319
319
  `)){let s=document.createElement("div");s.append(i?document.createTextNode(i):document.createElement("br")),e.append(s)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Jt{static PRECISION=0.0001;toSVGPath(){Qe("Abstract method `toSVGPath` must be implemented.")}get box(){Qe("Abstract getter `box` must be implemented.")}serialize(t,e){Qe("Abstract method `serialize` must be implemented.")}static _rescale(t,e,a,i,s,n){n||=new Float32Array(t.length);for(let l=0,f=t.length;l<f;l+=2)n[l]=e+t[l]*i,n[l+1]=a+t[l+1]*s;return n}static _rescaleAndSwap(t,e,a,i,s,n){n||=new Float32Array(t.length);for(let l=0,f=t.length;l<f;l+=2)n[l]=e+t[l+1]*i,n[l+1]=a+t[l]*s;return n}static _translate(t,e,a,i){i||=new Float32Array(t.length);for(let s=0,n=t.length;s<n;s+=2)i[s]=e+t[s],i[s+1]=a+t[s+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,a,i,s){switch(s){case 90:return[1-e/a,t/i];case 180:return[1-t/a,1-e/i];case 270:return[e/a,1-t/i];default:return[t/a,e/i]}}static createBezierPoints(t,e,a,i,s,n){return[(t+5*a)/6,(e+5*i)/6,(5*a+s)/6,(5*i+n)/6,(a+s)/2,(i+n)/2]}}class fr{#t;#e=[];#a;#i;#s=[];#l=new Float32Array(18);#n;#f;#o;#r;#u;#c;#g=[];static#p=8;static#b=2;static#h=fr.#p+fr.#b;constructor({x:t,y:e},a,i,s,n,l=0){this.#t=a,this.#c=s*i,this.#i=n,this.#l.set([NaN,NaN,NaN,NaN,t,e],6),this.#a=l,this.#r=fr.#p*i,this.#o=fr.#h*i,this.#u=i,this.#g.push(t,e)}isEmpty(){return isNaN(this.#l[8])}#m(){let t=this.#l.subarray(4,6),e=this.#l.subarray(16,18),[a,i,s,n]=this.#t;return[(this.#n+(t[0]-e[0])/2-a)/s,(this.#f+(t[1]-e[1])/2-i)/n,(this.#n+(e[0]-t[0])/2-a)/s,(this.#f+(e[1]-t[1])/2-i)/n]}add({x:t,y:e}){this.#n=t,this.#f=e;let[a,i,s,n]=this.#t,[l,f,o,c]=this.#l.subarray(8,12),u=t-o,m=e-c,p=Math.hypot(u,m);if(p<this.#o)return!1;let w=p-this.#r,d=w/p,v=d*u,k=d*m,y=l,B=f;l=o,f=c,o+=v,c+=k,this.#g?.push(t,e);let H=-k/w,M=v/w,D=H*this.#c,T=M*this.#c;if(this.#l.set(this.#l.subarray(2,8),0),this.#l.set([o+D,c+T],4),this.#l.set(this.#l.subarray(14,18),12),this.#l.set([o-D,c-T],16),isNaN(this.#l[6])){if(this.#s.length===0)this.#l.set([l+D,f+T],2),this.#s.push(NaN,NaN,NaN,NaN,(l+D-a)/s,(f+T-i)/n),this.#l.set([l-D,f-T],14),this.#e.push(NaN,NaN,NaN,NaN,(l-D-a)/s,(f-T-i)/n);return this.#l.set([y,B,l,f,o,c],6),!this.isEmpty()}if(this.#l.set([y,B,l,f,o,c],6),Math.abs(Math.atan2(B-f,y-l)-Math.atan2(k,v))<Math.PI/2)return[l,f,o,c]=this.#l.subarray(2,6),this.#s.push(NaN,NaN,NaN,NaN,((l+o)/2-a)/s,((f+c)/2-i)/n),[l,f,y,B]=this.#l.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+l)/2-a)/s,((B+f)/2-i)/n),!0;return[y,B,l,f,o,c]=this.#l.subarray(0,6),this.#s.push(((y+5*l)/6-a)/s,((B+5*f)/6-i)/n,((5*l+o)/6-a)/s,((5*f+c)/6-i)/n,((l+o)/2-a)/s,((f+c)/2-i)/n),[o,c,l,f,y,B]=this.#l.subarray(12,18),this.#e.push(((y+5*l)/6-a)/s,((B+5*f)/6-i)/n,((5*l+o)/6-a)/s,((5*f+c)/6-i)/n,((l+o)/2-a)/s,((f+c)/2-i)/n),!0}toSVGPath(){if(this.isEmpty())return"";let t=this.#s,e=this.#e;if(isNaN(this.#l[6])&&!this.isEmpty())return this.#j();let a=[];a.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)if(isNaN(t[i]))a.push(`L${t[i+4]} ${t[i+5]}`);else a.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#w(a);for(let i=e.length-6;i>=6;i-=6)if(isNaN(e[i]))a.push(`L${e[i+4]} ${e[i+5]}`);else a.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#d(a),a.join(" ")}#j(){let[t,e,a,i]=this.#t,[s,n,l,f]=this.#m();return`M${(this.#l[2]-t)/a} ${(this.#l[3]-e)/i} L${(this.#l[4]-t)/a} ${(this.#l[5]-e)/i} L${s} ${n} L${l} ${f} L${(this.#l[16]-t)/a} ${(this.#l[17]-e)/i} L${(this.#l[14]-t)/a} ${(this.#l[15]-e)/i} Z`}#d(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#w(t){let[e,a,i,s]=this.#t,n=this.#l.subarray(4,6),l=this.#l.subarray(16,18),[f,o,c,u]=this.#m();t.push(`L${(n[0]-e)/i} ${(n[1]-a)/s} L${f} ${o} L${c} ${u} L${(l[0]-e)/i} ${(l[1]-a)/s}`)}newFreeDrawOutline(t,e,a,i,s,n){return new dp(t,e,a,i,s,n)}getOutlines(){let t=this.#s,e=this.#e,a=this.#l,[i,s,n,l]=this.#t,f=new Float32Array((this.#g?.length??0)+2);for(let u=0,m=f.length-2;u<m;u+=2)f[u]=(this.#g[u]-i)/n,f[u+1]=(this.#g[u+1]-s)/l;if(f[f.length-2]=(this.#n-i)/n,f[f.length-1]=(this.#f-s)/l,isNaN(a[6])&&!this.isEmpty())return this.#S(f);let o=new Float32Array(this.#s.length+24+this.#e.length),c=t.length;for(let u=0;u<c;u+=2){if(isNaN(t[u])){o[u]=o[u+1]=NaN;continue}o[u]=t[u],o[u+1]=t[u+1]}c=this.#q(o,c);for(let u=e.length-6;u>=6;u-=6)for(let m=0;m<6;m+=2){if(isNaN(e[u+m])){o[c]=o[c+1]=NaN,c+=2;continue}o[c]=e[u+m],o[c+1]=e[u+m+1],c+=2}return this.#y(o,c),this.newFreeDrawOutline(o,f,this.#t,this.#u,this.#a,this.#i)}#S(t){let e=this.#l,[a,i,s,n]=this.#t,[l,f,o,c]=this.#m(),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-a)/s,(e[3]-i)/n,NaN,NaN,NaN,NaN,(e[4]-a)/s,(e[5]-i)/n,NaN,NaN,NaN,NaN,l,f,NaN,NaN,NaN,NaN,o,c,NaN,NaN,NaN,NaN,(e[16]-a)/s,(e[17]-i)/n,NaN,NaN,NaN,NaN,(e[14]-a)/s,(e[15]-i)/n],0),this.newFreeDrawOutline(u,t,this.#t,this.#u,this.#a,this.#i)}#y(t,e){let a=this.#e;return t.set([NaN,NaN,NaN,NaN,a[4],a[5]],e),e+=6}#q(t,e){let a=this.#l.subarray(4,6),i=this.#l.subarray(16,18),[s,n,l,f]=this.#t,[o,c,u,m]=this.#m();return t.set([NaN,NaN,NaN,NaN,(a[0]-s)/l,(a[1]-n)/f,NaN,NaN,NaN,NaN,o,c,NaN,NaN,NaN,NaN,u,m,NaN,NaN,NaN,NaN,(i[0]-s)/l,(i[1]-n)/f],e),e+=24}}class dp extends Jt{#t;#e=new Float32Array(4);#a;#i;#s;#l;#n;constructor(t,e,a,i,s,n){super();this.#n=t,this.#s=e,this.#t=a,this.#l=i,this.#a=s,this.#i=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#f(n);let[l,f,o,c]=this.#e;for(let u=0,m=t.length;u<m;u+=2)t[u]=(t[u]-l)/o,t[u+1]=(t[u+1]-f)/c;for(let u=0,m=e.length;u<m;u+=2)e[u]=(e[u]-l)/o,e[u+1]=(e[u+1]-f)/c}toSVGPath(){let t=[`M${this.#n[4]} ${this.#n[5]}`];for(let e=6,a=this.#n.length;e<a;e+=6){if(isNaN(this.#n[e])){t.push(`L${this.#n[e+4]} ${this.#n[e+5]}`);continue}t.push(`C${this.#n[e]} ${this.#n[e+1]} ${this.#n[e+2]} ${this.#n[e+3]} ${this.#n[e+4]} ${this.#n[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,a,i],s){let n=a-t,l=i-e,f,o;switch(s){case 0:f=Jt._rescale(this.#n,t,i,n,-l),o=Jt._rescale(this.#s,t,i,n,-l);break;case 90:f=Jt._rescaleAndSwap(this.#n,t,e,n,l),o=Jt._rescaleAndSwap(this.#s,t,e,n,l);break;case 180:f=Jt._rescale(this.#n,a,e,-n,l),o=Jt._rescale(this.#s,a,e,-n,l);break;case 270:f=Jt._rescaleAndSwap(this.#n,a,i,-n,-l),o=Jt._rescaleAndSwap(this.#s,a,i,-n,-l);break}return{outline:Array.from(f),points:[Array.from(o)]}}#f(t){let e=this.#n,a=e[4],i=e[5],s=[a,i,a,i],n=a,l=i,f=a,o=i,c=t?Math.max:Math.min,u=new Float32Array(4);for(let p=6,w=e.length;p<w;p+=6){let d=e[p+4],v=e[p+5];if(isNaN(e[p])){if(Nt.pointBoundingBox(d,v,s),l>v)n=d,l=v;else if(l===v)n=c(n,d);if(o<v)f=d,o=v;else if(o===v)f=c(f,d)}else{if(u.set(y1,0),Nt.bezierBoundingBox(a,i,...e.slice(p,p+6),u),Nt.rectBoundingBox(...u,s),l>u[1])n=u[0],l=u[1];else if(l===u[1])n=c(n,u[0]);if(o<u[3])f=u[2],o=u[3];else if(o===u[3])f=c(f,u[2])}a=d,i=v}let m=this.#e;m[0]=s[0]-this.#a,m[1]=s[1]-this.#a,m[2]=s[2]-s[0]+2*this.#a,m[3]=s[3]-s[1]+2*this.#a,this.firstPoint=[n,l],this.lastPoint=[f,o]}get box(){return this.#e}newOutliner(t,e,a,i,s,n=0){return new fr(t,e,a,i,s,n)}getNewOutline(t,e){let[a,i,s,n]=this.#e,[l,f,o,c]=this.#t,u=s*o,m=n*c,p=a*o+l,w=i*c+f,d=this.newOutliner({x:this.#s[0]*u+p,y:this.#s[1]*m+w},this.#t,this.#l,t,this.#i,e??this.#a);for(let v=2;v<this.#s.length;v+=2)d.add({x:this.#s[v]*u+p,y:this.#s[v+1]*m+w});return d.getOutlines()}}class P3{#t;#e;#a;#i=[];#s=[];constructor(t,e=0,a=0,i=!0){let s=y1.slice(),n=4,l=0.0001;for(let{x:v,y:k,width:y,height:B}of t){let H=Math.floor((v-e)/0.0001)*0.0001,M=Math.ceil((v+y+e)/0.0001)*0.0001,D=Math.floor((k-e)/0.0001)*0.0001,T=Math.ceil((k+B+e)/0.0001)*0.0001,z=[H,D,T,!0],E=[M,D,T,!1];this.#i.push(z,E),Nt.rectBoundingBox(H,D,M,T,s)}let f=s[2]-s[0]+2*a,o=s[3]-s[1]+2*a,c=s[0]-a,u=s[1]-a,m=i?-1/0:1/0,p=1/0,w=this.#i.at(i?-1:-2),d=[w[0],w[2]];for(let v of this.#i){let[k,y,B,H]=v;if(!H&&i){if(y<p)p=y,m=k;else if(y===p)m=Math.max(m,k)}else if(H&&!i){if(y<p)p=y,m=k;else if(y===p)m=Math.min(m,k)}v[0]=(k-c)/f,v[1]=(y-u)/o,v[2]=(B-u)/o}this.#t=new Float32Array([c,u,f,o]),this.#e=[m,p],this.#a=d}getOutlines(){this.#i.sort((e,a)=>e[0]-a[0]||e[1]-a[1]||e[2]-a[2]);let t=[];for(let e of this.#i)if(e[3])t.push(...this.#r(e)),this.#f(e);else this.#o(e),t.push(...this.#r(e));return this.#l(t)}#l(t){let e=[],a=new Set;for(let n of t){let[l,f,o]=n;e.push([l,f,n],[l,o,n])}e.sort((n,l)=>n[1]-l[1]||n[0]-l[0]);for(let n=0,l=e.length;n<l;n+=2){let f=e[n][2],o=e[n+1][2];f.push(o),o.push(f),a.add(f),a.add(o)}let i=[],s;while(a.size>0){let n=a.values().next().value,[l,f,o,c,u]=n;a.delete(n);let m=l,p=f;s=[l,o],i.push(s);while(!0){let w;if(a.has(c))w=c;else if(a.has(u))w=u;else break;if(a.delete(w),[l,f,o,c,u]=w,m!==l)s.push(m,p,l,p===f?f:o),m=l;p=p===f?o:f}s.push(m,p)}return new WB(i,this.#t,this.#e,this.#a)}#n(t){let e=this.#s,a=0,i=e.length-1;while(a<=i){let s=a+i>>1,n=e[s][0];if(n===t)return s;if(n<t)a=s+1;else i=s-1}return i+1}#f([,t,e]){let a=this.#n(t);this.#s.splice(a,0,[t,e])}#o([,t,e]){let a=this.#n(t);for(let i=a;i<this.#s.length;i++){let[s,n]=this.#s[i];if(s!==t)break;if(s===t&&n===e){this.#s.splice(i,1);return}}for(let i=a-1;i>=0;i--){let[s,n]=this.#s[i];if(s!==t)break;if(s===t&&n===e){this.#s.splice(i,1);return}}}#r(t){let[e,a,i]=t,s=[[e,a,i]],n=this.#n(i);for(let l=0;l<n;l++){let[f,o]=this.#s[l];for(let c=0,u=s.length;c<u;c++){let[,m,p]=s[c];if(o<=m||p<=f)continue;if(m>=f){if(p>o)s[c][1]=o;else{if(u===1)return[];s.splice(c,1),c--,u--}continue}if(s[c][2]=f,p>o)s.push([e,o,p])}}return s}}class WB extends Jt{#t;#e;constructor(t,e,a,i){super();this.#e=t,this.#t=e,this.firstPoint=a,this.lastPoint=i}toSVGPath(){let t=[];for(let e of this.#e){let[a,i]=e;t.push(`M${a} ${i}`);for(let s=2;s<e.length;s+=2){let n=e[s],l=e[s+1];if(n===a)t.push(`V${l}`),i=l;else if(l===i)t.push(`H${n}`),a=n}t.push("Z")}return t.join(" ")}serialize([t,e,a,i],s){let n=[],l=a-t,f=i-e;for(let o of this.#e){let c=Array(o.length);for(let u=0;u<o.length;u+=2)c[u]=t+o[u]*l,c[u+1]=i-o[u+1]*f;n.push(c)}return n}get box(){return this.#t}}class t6 extends fr{newFreeDrawOutline(t,e,a,i,s,n){return new PB(t,e,a,i,s,n)}}class PB extends dp{newOutliner(t,e,a,i,s,n=0){return new t6(t,e,a,i,s,n)}}class ai extends se{#t=null;#e=0;#a;#i=null;#s=null;#l=null;#n=null;#f=0;#o=null;#r=null;#u=null;#c=!1;#g=null;#p=null;#b=null;#h="";#m;#j="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=je.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=ai.prototype;return be(this,"_keyboardManager",new fn([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"});if(this.color=t.color||ai._defaultColor,this.#m=t.thickness||ai._defaultThickness,this.opacity=t.opacity||ai._defaultOpacity,this.#a=t.boxes||null,this.#j=t.methodOfCreation||"",this.#h=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1)this.#c=!0,this.#w(t),this.#v();else if(this.#a)this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#n=t.focusNode,this.#f=t.focusOffset,this.#d(),this.#v(),this.rotate(this.rotation);if(!this.annotationElementId)this._uiManager.a11yAlert(se._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#c?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#m,methodOfCreation:this.#j}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#d(){let t=new P3(this.#a,0.001);this.#r=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#r.box;let e=new P3(this.#a,0.0025,0.001,this._uiManager.direction==="ltr");this.#l=e.getOutlines();let{firstPoint:a}=this.#r;this.#g=[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height];let{lastPoint:i}=this.#l;this.#p=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#w({highlightOutlines:t,highlightId:e,clipPathId:a}){this.#r=t;let i=1.5;if(this.#l=t.getNewOutline(this.#m/2+i,0.0025),e>=0)this.#u=e,this.#i=a,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#b=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#l.box,path:{d:this.#l.toSVGPath()}},!0);else if(this.parent){let u=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:ai.#_(this.#r.box,(u-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#b,{bbox:ai.#_(this.#l.box,u),path:{d:this.#l.toSVGPath()}})}let[s,n,l,f]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=l,this.height=f;break;case 90:{let[u,m]=this.parentDimensions;this.x=n,this.y=1-s,this.width=l*m/u,this.height=f*u/m;break}case 180:this.x=1-s,this.y=1-n,this.width=l,this.height=f;break;case 270:{let[u,m]=this.parentDimensions;this.x=1-n,this.y=s,this.width=l*m/u,this.height=f*u/m;break}}let{firstPoint:o}=t;this.#g=[(o[0]-s)/l,(o[1]-n)/f];let{lastPoint:c}=this.#l;this.#p=[(c[0]-s)/l,(c[1]-n)/f]}static initialize(t,e){se.initialize(t,e),ai._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Ce.HIGHLIGHT_COLOR:ai._defaultColor=e;break;case Ce.HIGHLIGHT_THICKNESS:ai._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#g}updateParams(t,e){switch(t){case Ce.HIGHLIGHT_COLOR:this.#S(e);break;case Ce.HIGHLIGHT_THICKNESS:this.#y(e);break}}static get defaultPropertiesToUpdate(){return[[Ce.HIGHLIGHT_COLOR,ai._defaultColor],[Ce.HIGHLIGHT_THICKNESS,ai._defaultThickness]]}get propertiesToUpdate(){return[[Ce.HIGHLIGHT_COLOR,this.color||ai._defaultColor],[Ce.HIGHLIGHT_THICKNESS,this.#m||ai._defaultThickness],[Ce.HIGHLIGHT_FREE,this.#c]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#s?.updateColor(this.color),super.onUpdatedColor()}#S(t){let e=(s,n)=>{this.color=s,this.opacity=n,this.onUpdatedColor()},a=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,t,ai._defaultOpacity),undo:e.bind(this,a,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ce.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#y(t){let e=this.#m,a=(i)=>{this.#m=i,this.#q(i)};this.addCommands({cmd:a.bind(this,t),undo:a.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ce.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[["colorPicker",this.#s=new Rn({editor:this})]];return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#F())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#F())}onceAdded(t){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(t)this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#v(),!this.isAttachedToDOM)this.parent.add(this)}setParent(t){let e=!1;if(this.parent&&!t)this.#k();else if(t)this.#v(t),e=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(t),this.show(this._isVisible),e)this.select()}#q(t){if(!this.#c)return;this.#w({highlightOutlines:this.#r.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims()}#k(){if(this.#u===null||!this.parent)return;this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#b),this.#b=null}#v(t=this.parent){if(this.#u!==null)return;if({id:this.#u,clipPathId:this.#i}=t.drawLayer.draw({bbox:this.#r.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#c},path:{d:this.#r.toSVGPath()}},!1,!0),this.#b=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#c},bbox:this.#l.box,path:{d:this.#l.toSVGPath()}},this.#c),this.#o)this.#o.style.clipPath=this.#i}static#_([t,e,a,i],s){switch(s){case 90:return[1-e-i,t,i,a];case 180:return[1-t-a,1-e-i,a,i];case 270:return[e,1-t-a,i,a]}return[t,e,a,i]}rotate(t){let{drawLayer:e}=this.parent,a;if(this.#c)t=(t-this.rotation+360)%360,a=ai.#_(this.#r.box,t);else a=ai.#_([this.x,this.y,this.width,this.height],t);e.updateProperties(this.#u,{bbox:a,root:{"data-main-rotation":t}}),e.updateProperties(this.#b,{bbox:ai.#_(this.#l.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();if(this.#h)t.setAttribute("aria-label",this.#h),t.setAttribute("role","mark");if(this.#c)t.classList.add("free");else this.div.addEventListener("keydown",this.#B.bind(this),{signal:this._uiManager._signal});let e=this.#o=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#i,this.setDims(),RF(this,this.#o,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){if(!this.isSelected)this.parent?.drawLayer.updateProperties(this.#b,{rootClass:{hovered:!0}})}pointerleave(){if(!this.isSelected)this.parent?.drawLayer.updateProperties(this.#b,{rootClass:{hovered:!1}})}#B(t){ai._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#O(!0);break;case 1:case 3:this.#O(!1);break}}#O(t){if(!this.#t)return;let e=window.getSelection();if(t)e.setPosition(this.#t,this.#e);else e.setPosition(this.#n,this.#f)}select(){if(super.select(),!this.#b)return;this.parent?.drawLayer.updateProperties(this.#b,{rootClass:{hovered:!1,selected:!0}})}unselect(){if(super.unselect(),!this.#b)return;if(this.parent?.drawLayer.updateProperties(this.#b,{rootClass:{selected:!1}}),!this.#c)this.#O(!1)}get _mustFixPosition(){return!this.#c}show(t=this._isVisible){if(super.show(t),this.parent)this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#b,{rootClass:{hidden:!t}})}#F(){return this.#c?this.rotation:0}#D(){if(this.#c)return null;let[t,e]=this.pageDimensions,[a,i]=this.pageTranslation,s=this.#a,n=new Float32Array(s.length*8),l=0;for(let{x:f,y:o,width:c,height:u}of s){let m=f*t+a,p=(1-o)*e+i;n[l]=n[l+4]=m,n[l+1]=n[l+3]=p,n[l+2]=n[l+6]=m+c*t,n[l+5]=n[l+7]=p-u*e,l+=8}return n}#T(t){return this.#r.serialize(t,this.#F())}static startHighlighting(t,e,{target:a,x:i,y:s}){let{x:n,y:l,width:f,height:o}=a.getBoundingClientRect(),c=new AbortController,u=t.combinedSignal(c),m=(p)=>{c.abort(),this.#R(t,p)};window.addEventListener("blur",m,{signal:u}),window.addEventListener("pointerup",m,{signal:u}),window.addEventListener("pointerdown",Ia,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",Nn,{signal:u}),a.addEventListener("pointermove",this.#M.bind(this,t),{signal:u}),this._freeHighlight=new t6({x:i,y:s},[n,l,f,o],t.scale,this._defaultThickness/2,e,0.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#M(t,e){if(this._freeHighlight.add(e))t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#R(t,e){if(!this._freeHighlight.isEmpty())t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"});else t.drawLayer.remove(this._freeHighlightId);this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,a){let i=null;if(t instanceof bp){let{data:{quadPoints:d,rect:v,rotation:k,id:y,color:B,opacity:H,popupRef:M,richText:D,contentsObj:T,creationDate:z,modificationDate:E},parent:{page:{pageNumber:V}}}=t;i=t={annotationType:je.HIGHLIGHT,color:Array.from(B),opacity:H,quadPoints:d,boxes:null,pageIndex:V-1,rect:v.slice(0),rotation:k,annotationElementId:y,id:y,deleted:!1,popupRef:M,richText:D,comment:T?.str||null,creationDate:z,modificationDate:E}}else if(t instanceof j6){let{data:{inkLists:d,rect:v,rotation:k,id:y,color:B,borderStyle:{rawWidth:H},popupRef:M,richText:D,contentsObj:T,creationDate:z,modificationDate:E},parent:{page:{pageNumber:V}}}=t;i=t={annotationType:je.HIGHLIGHT,color:Array.from(B),thickness:H,inkLists:d,boxes:null,pageIndex:V-1,rect:v.slice(0),rotation:k,annotationElementId:y,id:y,deleted:!1,popupRef:M,richText:D,comment:T?.str||null,creationDate:z,modificationDate:E}}let{color:s,quadPoints:n,inkLists:l,outlines:f,opacity:o}=t,c=await super.deserialize(t,e,a);if(c.color=Nt.makeHexColor(...s),c.opacity=o||1,l)c.#m=t.thickness;if(c._initialData=i,t.comment)c.setCommentData(t);let[u,m]=c.pageDimensions,[p,w]=c.pageTranslation;if(n){let d=c.#a=[];for(let v=0;v<n.length;v+=8)d.push({x:(n[v]-p)/u,y:1-(n[v+1]-w)/m,width:(n[v+2]-n[v])/u,height:(n[v+1]-n[v+5])/m});c.#d(),c.#v(),c.rotate(c.rotation)}else if(l||f){c.#c=!0;let d=(l||f.points)[0],v={x:d[0]-p,y:m-(d[1]-w)},k=new t6(v,[0,0,u,m],1,c.#m/2,!0,0.001);for(let H=0,M=d.length;H<M;H+=2)v.x=d[H]-p,v.y=m-(d[H+1]-w),k.add(v);let{id:y,clipPathId:B}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);c.#w({highlightOutlines:k.getOutlines(),highlightId:y,clipPathId:B}),c.#v(),c.rotate(c.parentRotation)}return c}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=se._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),a=super.serialize(t);if(Object.assign(a,{color:e,opacity:this.opacity,thickness:this.#m,quadPoints:this.#D(),outlines:this.#T(a.rect)}),this.addComment(a),this.annotationElementId&&!this.#z(a))return null;return a.id=this.annotationElementId,a}#z(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((a,i)=>a!==e[i])}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class qp{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(!t)return;for(let[e,a]of Object.entries(t))if(!e.startsWith("_"))this.updateProperty(e,a)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){Qe("Not implemented")}}class $e extends se{#t=null;#e;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#a=null;static#i=null;static#s=null;static _INNER_MARGIN=3;constructor(t){super(t);this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){if(t.drawOutlines)this.#l(t),this.#o()}#l({drawOutlines:t,drawId:e,drawingOptions:a}){if(this.#t=t,this._drawingOptions||=a,!this.annotationElementId)this._uiManager.a11yAlert(se._l10nAlert[this.editorType]);if(e>=0)this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties);else this._drawId=this.#n(t,this.parent);this.#c(t.box)}#n(t,e){let{id:a}=e.drawLayer.draw($e._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return a}static _mergeSVGProperties(t,e){let a=new Set(Object.keys(t));for(let[i,s]of Object.entries(e))if(a.has(i))Object.assign(t[i],s);else t[i]=s;return t}static getDefaultDrawingOptions(t){Qe("Not implemented")}static get typesMap(){Qe("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let a=this.typesMap.get(t);if(a)this._defaultDrawingOptions.updateProperty(a,e);if(this._currentParent)$e.#a.updateProperty(a,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}updateParams(t,e){let a=this.constructor.typesMap.get(t);if(a)this._updateProperty(t,a,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[a,i]of this.typesMap)t.push([a,e[i]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[a,i]of this.constructor.typesMap)t.push([a,e[i]]);return t}_updateProperty(t,e,a){let i=this._drawingOptions,s=i[e],n=(l)=>{i.updateProperty(e,l);let f=this.#t.updateProperty(e,l);if(f)this.#c(f);if(this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType)this.onUpdatedColor();else if(t===this.opacityType)this.onUpdatedOpacity()};this.addCommands({cmd:n.bind(this,a),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){let a=this.constructor.typesMap.get(this.colorType),i=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,n=s[a],l=s[i],f=(o,c)=>{s.updateProperty(a,o),s.updateProperty(i,c),this.#t.updateProperty(a,o),this.#t.updateProperty(i,c),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:f.bind(this,t,e),undo:f.bind(this,n,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ce.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$e._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#u()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$e._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#u()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$e._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(this._isDraggable=!0,this.#e){if(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen)this.div.focus()}}remove(){this.#f(),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#o(),this.#c(this.#t.box),!this.isAttachedToDOM)this.parent.add(this)}setParent(t){let e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),this.#f();else if(t)this._uiManager.addShouldRescale(this),this.#o(t),e=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(t),e)this.select()}#f(){if(this._drawId===null||!this.parent)return;this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset()}#o(t=this.parent){if(this._drawId!==null&&this.parent===t)return;if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#n(this.#t,t)}#r([t,e,a,i]){let{parentDimensions:[s,n],rotation:l}=this;switch(l){case 90:return[e,1-t,a*(n/s),i*(s/n)];case 180:return[1-t,1-e,a,i];case 270:return[1-e,t,a*(n/s),i*(s/n)];default:return[t,e,a,i]}}#u(){let{x:t,y:e,width:a,height:i,parentDimensions:[s,n],rotation:l}=this;switch(l){case 90:return[1-e,t,a*(s/n),i*(n/s)];case 180:return[1-t,1-e,a,i];case 270:return[e,1-t,a*(s/n),i*(n/s)];default:return[t,e,a,i]}}#c(t){if([this.x,this.y,this.width,this.height]=this.#r(t),this.div)this.fixAndSetPosition(),this.setDims();this._onResized()}#g(){let{x:t,y:e,width:a,height:i,rotation:s,parentRotation:n,parentDimensions:[l,f]}=this;switch((s*4+n)/90){case 1:return[1-e-i,t,i,a];case 2:return[1-t-a,1-e-i,a,i];case 3:return[e,1-t-a,i,a];case 4:return[t,e-a*(l/f),i*(f/l),a*(l/f)];case 5:return[1-e,t,a*(l/f),i*(f/l)];case 6:return[1-t-i*(f/l),1-e,i*(f/l),a*(l/f)];case 7:return[e-a*(l/f),1-t-i*(f/l),a*(l/f),i*(f/l)];case 8:return[t-a,e-i,a,i];case 9:return[1-e,t-a,i,a];case 10:return[1-t,1-e,a,i];case 11:return[e-i,1-t,i,a];case 12:return[t-i*(f/l),e,i*(f/l),a*(l/f)];case 13:return[1-e-a*(l/f),t-i*(f/l),a*(l/f),i*(f/l)];case 14:return[1-t,1-e-a*(l/f),i*(f/l),a*(l/f)];case 15:return[e,1-t,a*(l/f),i*(f/l)];default:return[t,e,a,i]}}rotate(){if(!this.parent)return;this.parent.drawLayer.updateProperties(this._drawId,$e._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){if(!this.parent)return;this.#c(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;if(this._isCopy)t=this.x,e=this.y;let a=super.render();a.classList.add("draw");let i=document.createElement("div");if(a.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy)this._moveAfterPaste(t,e);return a}static createDrawerInstance(t,e,a,i,s){Qe("Not implemented")}static startDrawing(t,e,a,i){let{target:s,offsetX:n,offsetY:l,pointerId:f,pointerType:o}=i;if(We.isInitializedAndDifferentPointerType(o))return;let{viewport:{rotation:c}}=t,{width:u,height:m}=s.getBoundingClientRect(),p=$e.#i=new AbortController,w=t.combinedSignal(p);if(We.setPointer(o,f),window.addEventListener("pointerup",(d)=>{if(We.isSamePointerIdOrRemove(d.pointerId))this._endDraw(d)},{signal:w}),window.addEventListener("pointercancel",(d)=>{if(We.isSamePointerIdOrRemove(d.pointerId))this._currentParent.endDrawingSession()},{signal:w}),window.addEventListener("pointerdown",(d)=>{if(!We.isSamePointerType(d.pointerType))return;if(We.initializeAndAddPointerId(d.pointerId),$e.#a.isCancellable())if($e.#a.removeLastElement(),$e.#a.isEmpty())this._currentParent.endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:w}),window.addEventListener("contextmenu",Nn,{signal:w}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:w}),s.addEventListener("touchmove",(d)=>{if(We.isSameTimeStamp(d.timeStamp))Ia(d)},{signal:w}),t.toggleDrawing(),e._editorUndoBar?.hide(),$e.#a){t.drawLayer.updateProperties(this._currentDrawId,$e.#a.startNew(n,l,u,m,c));return}e.updateUIForDefaultProperties(this),$e.#a=this.createDrawerInstance(n,l,u,m,c),$e.#s=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties($e.#s.toSVGProperties(),$e.#a.defaultSVGProperties),!0,!1)}static _drawMove(t){if(We.isSameTimeStamp(t.timeStamp),!$e.#a)return;let{offsetX:e,offsetY:a,pointerId:i}=t;if(!We.isSamePointerId(i))return;if(We.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,$e.#a.add(e,a)),We.setTimeStamp(t.timeStamp),Ia(t)}static _cleanup(t){if(t)this._currentDrawId=-1,this._currentParent=null,$e.#a=null,$e.#s=null,We.clearTimeStamp();if($e.#i)$e.#i.abort(),$e.#i=null,We.clearPointerIds()}static _endDraw(t){let e=this._currentParent;if(!e)return;if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div)e.drawLayer.updateProperties(this._currentDrawId,$e.#a.end(t.offsetX,t.offsetY));if(this.supportMultipleDrawings){let a=$e.#a,i=this._currentDrawId,s=a.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,a.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,a.removeLastElement())},mustExec:!1,type:Ce.DRAW_STEP});return}this.endDrawing(!1)}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Ce.DRAW_STEP),!$e.#a.isEmpty()){let{pageDimensions:[a,i],scale:s}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$e.#a.getOutlines(a*s,i*s,s,this._INNER_MARGIN),drawingOptions:$e.#s,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,a,i,s,n){Qe("Not implemented")}static async deserialize(t,e,a){let{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:l}}=e.viewport,f=this.deserializeDraw(n,l,i,s,this._INNER_MARGIN,t),o=await super.deserialize(t,e,a);return o.createDrawingOptions(t),o.#l({drawOutlines:f}),o.#o(),o.onScaleChanging(),o.rotate(),o}serializeDraw(t){let[e,a]=this.pageTranslation,[i,s]=this.pageDimensions;return this.#t.serialize([e,a,i,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class tO{#t=new Float64Array(6);#e;#a;#i;#s;#l;#n="";#f=0;#o=new Bh;#r;#u;constructor(t,e,a,i,s,n){this.#r=a,this.#u=i,this.#i=s,this.#s=n,[t,e]=this.#c(t,e);let l=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#l=[t,e],this.#a=[{line:l,points:this.#l}],this.#t.set(l,0)}updateProperty(t,e){if(t==="stroke-width")this.#s=e}#c(t,e){return Jt._normalizePoint(t,e,this.#r,this.#u,this.#i)}isEmpty(){return!this.#a?.length}isCancellable(){return this.#l.length<=10}add(t,e){[t,e]=this.#c(t,e);let[a,i,s,n]=this.#t.subarray(2,6),l=t-s,f=e-n;if(Math.hypot(this.#r*l,this.#u*f)<=2)return null;if(this.#l.push(t,e),isNaN(a))return this.#t.set([s,n,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}};if(isNaN(this.#t[0]))this.#e.splice(6,6);return this.#t.set([a,i,s,n,t,e],0),this.#e.push(...Jt.createBezierPoints(a,i,s,n,t,e)),{path:{d:this.toSVGPath()}}}end(t,e){let a=this.add(t,e);if(a)return a;if(this.#l.length===2)return{path:{d:this.toSVGPath()}};return null}startNew(t,e,a,i,s){this.#r=a,this.#u=i,this.#i=s,[t,e]=this.#c(t,e);let n=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#l=[t,e];let l=this.#a.at(-1);if(l)l.line=new Float32Array(l.line),l.points=new Float32Array(l.points);return this.#a.push({line:n,points:this.#l}),this.#t.set(n,0),this.#f=0,this.toSVGPath(),null}getLastElement(){return this.#a.at(-1)}setLastElement(t){if(!this.#a)return this.#o.setLastElement(t);return this.#a.push(t),this.#e=t.line,this.#l=t.points,this.#f=0,{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#a)return this.#o.removeLastElement();this.#a.pop(),this.#n="";for(let t=0,e=this.#a.length;t<e;t++){let{line:a,points:i}=this.#a[t];this.#e=a,this.#l=i,this.#f=0,this.toSVGPath()}return{path:{d:this.#n}}}toSVGPath(){let t=Jt.svgRound(this.#e[4]),e=Jt.svgRound(this.#e[5]);if(this.#l.length===2)return this.#n=`${this.#n} M ${t} ${e} Z`,this.#n;if(this.#l.length<=6){let i=this.#n.lastIndexOf("M");this.#n=`${this.#n.slice(0,i)} M ${t} ${e}`,this.#f=6}if(this.#l.length===4){let i=Jt.svgRound(this.#e[10]),s=Jt.svgRound(this.#e[11]);return this.#n=`${this.#n} L ${i} ${s}`,this.#f=12,this.#n}let a=[];if(this.#f===0)a.push(`M ${t} ${e}`),this.#f=6;for(let i=this.#f,s=this.#e.length;i<s;i+=6){let[n,l,f,o,c,u]=this.#e.slice(i,i+6).map(Jt.svgRound);a.push(`C${n} ${l} ${f} ${o} ${c} ${u}`)}return this.#n+=a.join(" "),this.#f=this.#e.length,this.#n}getOutlines(t,e,a,i){let s=this.#a.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#o.build(this.#a,t,e,a,this.#i,this.#s,i),this.#t=null,this.#e=null,this.#a=null,this.#n=null,this.#o}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Bh extends Jt{#t;#e=0;#a;#i;#s;#l;#n;#f;#o;build(t,e,a,i,s,n,l){this.#s=e,this.#l=a,this.#n=i,this.#f=s,this.#o=n,this.#a=l??0,this.#i=t,this.#c()}get thickness(){return this.#o}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#i){if(t.push(`M${Jt.svgRound(e[4])} ${Jt.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${Jt.svgRound(e[10])} ${Jt.svgRound(e[11])}`);continue}for(let a=6,i=e.length;a<i;a+=6){let[s,n,l,f,o,c]=e.subarray(a,a+6).map(Jt.svgRound);t.push(`C${s} ${n} ${l} ${f} ${o} ${c}`)}}return t.join("")}serialize([t,e,a,i],s){let n=[],l=[],[f,o,c,u]=this.#u(),m,p,w,d,v,k,y,B,H;switch(this.#f){case 0:H=Jt._rescale,m=t,p=e+i,w=a,d=-i,v=t+f*a,k=e+(1-o-u)*i,y=t+(f+c)*a,B=e+(1-o)*i;break;case 90:H=Jt._rescaleAndSwap,m=t,p=e,w=a,d=i,v=t+o*a,k=e+f*i,y=t+(o+u)*a,B=e+(f+c)*i;break;case 180:H=Jt._rescale,m=t+a,p=e,w=-a,d=i,v=t+(1-f-c)*a,k=e+o*i,y=t+(1-f)*a,B=e+(o+u)*i;break;case 270:H=Jt._rescaleAndSwap,m=t+a,p=e+i,w=-a,d=-i,v=t+(1-o-u)*a,k=e+(1-f-c)*i,y=t+(1-o)*a,B=e+(1-f)*i;break}for(let{line:M,points:D}of this.#i)n.push(H(M,m,p,w,d,s?Array(M.length):null)),l.push(H(D,m,p,w,d,s?Array(D.length):null));return{lines:n,points:l,rect:[v,k,y,B]}}static deserialize(t,e,a,i,s,{paths:{lines:n,points:l},rotation:f,thickness:o}){let c=[],u,m,p,w,d;switch(f){case 0:d=Jt._rescale,u=-t/a,m=e/i+1,p=1/a,w=-1/i;break;case 90:d=Jt._rescaleAndSwap,u=-e/i,m=-t/a,p=1/i,w=1/a;break;case 180:d=Jt._rescale,u=t/a+1,m=-e/i,p=-1/a,w=1/i;break;case 270:d=Jt._rescaleAndSwap,u=e/i+1,m=t/a+1,p=-1/i,w=-1/a;break}if(!n){n=[];for(let k of l){let y=k.length;if(y===2){n.push(new Float32Array([NaN,NaN,NaN,NaN,k[0],k[1]]));continue}if(y===4){n.push(new Float32Array([NaN,NaN,NaN,NaN,k[0],k[1],NaN,NaN,NaN,NaN,k[2],k[3]]));continue}let B=new Float32Array(3*(y-2));n.push(B);let[H,M,D,T]=k.subarray(0,4);B.set([NaN,NaN,NaN,NaN,H,M],0);for(let z=4;z<y;z+=2){let E=k[z],V=k[z+1];B.set(Jt.createBezierPoints(H,M,D,T,E,V),(z-2)*3),[H,M,D,T]=[D,T,E,V]}}}for(let k=0,y=n.length;k<y;k++)c.push({line:d(n[k].map((B)=>B??NaN),u,m,p,w),points:d(l[k].map((B)=>B??NaN),u,m,p,w)});let v=new this.prototype.constructor;return v.build(c,a,i,1,f,o,s),v}#r(t=this.#o){let e=this.#a+t/2*this.#n;return this.#f%180===0?[e/this.#s,e/this.#l]:[e/this.#l,e/this.#s]}#u(){let[t,e,a,i]=this.#t,[s,n]=this.#r(0);return[t+s,e+n,a-2*s,i-2*n]}#c(){let t=this.#t=lr.slice();for(let{line:i}of this.#i){if(i.length<=12){for(let l=4,f=i.length;l<f;l+=6)Nt.pointBoundingBox(i[l],i[l+1],t);continue}let s=i[4],n=i[5];for(let l=6,f=i.length;l<f;l+=6){let[o,c,u,m,p,w]=i.subarray(l,l+6);Nt.bezierBoundingBox(s,n,o,c,u,m,p,w,t),s=p,n=w}}let[e,a]=this.#r();t[0]=_a(t[0]-e,0,1),t[1]=_a(t[1]-a,0,1),t[2]=_a(t[2]+e,0,1),t[3]=_a(t[3]+a,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){if(t==="stroke-width")return this.#g(e);return null}#g(t){let[e,a]=this.#r();this.#o=t;let[i,s]=this.#r(),[n,l]=[i-e,s-a],f=this.#t;return f[0]-=n,f[1]-=l,f[2]+=2*n,f[3]+=2*l,f}updateParentDimensions([t,e],a){let[i,s]=this.#r();this.#s=t,this.#l=e,this.#n=a;let[n,l]=this.#r(),f=n-i,o=l-s,c=this.#t;return c[0]-=f,c[1]-=o,c[2]+=2*f,c[3]+=2*o,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(Jt.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,a=0,i=0,s=0,n=0,l=0,f=0;switch(this.#e){case 90:i=e/t,s=-t/e,l=t;break;case 180:a=-1,n=-1,l=t,f=e;break;case 270:i=-e/t,s=t/e,f=e;break;default:return""}return`matrix(${a} ${i} ${s} ${n} ${Jt.svgRound(l)} ${Jt.svgRound(f)})`}getPathResizingSVGProperties([t,e,a,i]){let[s,n]=this.#r(),[l,f,o,c]=this.#t;if(Math.abs(o-s)<=Jt.PRECISION||Math.abs(c-n)<=Jt.PRECISION){let d=t+a/2-(l+o/2),v=e+i/2-(f+c/2);return{path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:`${this.rotationTransform} translate(${d} ${v})`}}}let u=(a-2*s)/(o-2*s),m=(i-2*n)/(c-2*n),p=o/a,w=c/i;return{path:{"transform-origin":`${Jt.svgRound(l)} ${Jt.svgRound(f)}`,transform:`${this.rotationTransform} scale(${p} ${w}) translate(${Jt.svgRound(s)} ${Jt.svgRound(n)}) scale(${u} ${m}) translate(${Jt.svgRound(-s)} ${Jt.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,a,i]){let[s,n]=this.#r(),l=this.#t,[f,o,c,u]=l;if(l[0]=t,l[1]=e,l[2]=a,l[3]=i,Math.abs(c-s)<=Jt.PRECISION||Math.abs(u-n)<=Jt.PRECISION){let v=t+a/2-(f+c/2),k=e+i/2-(o+u/2);for(let{line:y,points:B}of this.#i)Jt._translate(y,v,k,y),Jt._translate(B,v,k,B);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let m=(a-2*s)/(c-2*s),p=(i-2*n)/(u-2*n),w=-m*(f+s)+t+s,d=-p*(o+n)+e+n;if(m!==1||p!==1||w!==0||d!==0)for(let{line:v,points:k}of this.#i)Jt._rescale(v,w,d,m,p,v),Jt._rescale(k,w,d,m,p,k);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],a){let[i,s]=a,n=this.#t,l=t-n[0],f=e-n[1];if(this.#s===i&&this.#l===s)for(let{line:o,points:c}of this.#i)Jt._translate(o,l,f,o),Jt._translate(c,l,f,c);else{let o=this.#s/i,c=this.#l/s;this.#s=i,this.#l=s;for(let{line:u,points:m}of this.#i)Jt._rescale(u,l,f,o,c,u),Jt._rescale(m,l,f,o,c,m);n[2]*=o,n[3]*=c}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Jt.svgRound(t)} ${Jt.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Jt.svgRound(t[0])} ${Jt.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class d6 extends qp{constructor(t){super();this._viewParameters=t,super.updateProperties({fill:"none",stroke:se._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){if(t==="stroke-width")e??=this["stroke-width"],e*=this._viewParameters.realScale;super.updateSVGProperty(t,e)}clone(){let t=new d6(this._viewParameters);return t.updateAll(this),t}}class Ap extends $e{static _type="ink";static _editorType=je.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){se.initialize(t,e),this._defaultDrawingOptions=new d6(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return be(this,"typesMap",new Map([[Ce.INK_THICKNESS,"stroke-width"],[Ce.INK_COLOR,"stroke"],[Ce.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,a,i,s){return new tO(t,e,a,i,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,a,i,s,n){return Bh.deserialize(t,e,a,i,s,n)}static async deserialize(t,e,a){let i=null;if(t instanceof j6){let{data:{inkLists:n,rect:l,rotation:f,id:o,color:c,opacity:u,borderStyle:{rawWidth:m},popupRef:p,richText:w,contentsObj:d,creationDate:v,modificationDate:k},parent:{page:{pageNumber:y}}}=t;i=t={annotationType:je.INK,color:Array.from(c),thickness:m,opacity:u,paths:{points:n},boxes:null,pageIndex:y-1,rect:l.slice(0),rotation:f,annotationElementId:o,id:o,deleted:!1,popupRef:p,richText:w,comment:d?.str||null,creationDate:v,modificationDate:k}}let s=await super.deserialize(t,e,a);if(s._initialData=i,t.comment)s.setCommentData(t);return s}get toolbarButtons(){return this._colorPicker||=new b9(this),[["colorPicker",this._colorPicker]]}get colorType(){return Ce.INK_COLOR}get colorAndOpacityType(){return Ce.INK_COLOR_AND_OPACITY}get opacityType(){return Ce.INK_OPACITY}updateParams(t,e){if(t===Ce.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===Ce.INK_COLOR_AND_OPACITY){super.updateDefaultParams(Ce.INK_COLOR,e.color),super.updateDefaultParams(Ce.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:a}=this;e.updateSVGProperty("stroke-width"),a.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;if(!t)return;super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}createDrawingOptions({color:t,thickness:e,opacity:a}){this._drawingOptions=Ap.getDefaultDrawingOptions({stroke:Nt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":a})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:a}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":s,"stroke-width":n}}=this,l=Object.assign(super.serialize(t),{color:se._colorManager.convert(i),opacity:s,thickness:n,paths:{lines:e,points:a}});if(this.addComment(l),t)return l.isCopy=!0,l;if(this.annotationElementId&&!this.#t(l))return null;return l.id=this.annotationElementId,l}#t(t){let{color:e,thickness:a,opacity:i,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((n,l)=>n!==e[l])||t.thickness!==a||t.opacity!==i||t.pageIndex!==s}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:a}=this.serializeDraw(!1);return t.updateEdited({rect:a,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class e6 extends Bh{toSVGPath(){let t=super.toSVGPath();if(!t.endsWith("Z"))t+="Z";return t}}var U3=8,l9=3;class nr{static#t={maxDim:512,sigmaSFactor:0.02,sigmaR:25,kernelSize:16};static#e(t,e,a,i){if(a-=t,i-=e,a===0)return i>0?0:4;if(a===1)return i+6;return 2-i}static#a=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,a,i,s,n,l){let f=this.#e(a,i,s,n);for(let o=0;o<8;o++){let c=(-o+f-l+16)%8,u=this.#a[2*c],m=this.#a[2*c+1];if(t[(a+u)*e+(i+m)]!==0)return c}return-1}static#s(t,e,a,i,s,n,l){let f=this.#e(a,i,s,n);for(let o=0;o<8;o++){let c=(o+f+l+16)%8,u=this.#a[2*c],m=this.#a[2*c+1];if(t[(a+u)*e+(i+m)]!==0)return c}return-1}static#l(t,e,a,i){let s=t.length,n=new Int32Array(s);for(let c=0;c<s;c++)n[c]=t[c]<=i?1:0;for(let c=1;c<a-1;c++)n[c*e]=n[c*e+e-1]=0;for(let c=0;c<e;c++)n[c]=n[e*a-1-c]=0;let l=1,f,o=[];for(let c=1;c<a-1;c++){f=1;for(let u=1;u<e-1;u++){let m=c*e+u,p=n[m];if(p===0)continue;let w=c,d=u;if(p===1&&n[m-1]===0)l+=1,d-=1;else if(p>=1&&n[m+1]===0){if(l+=1,d+=1,p>1)f=p}else{if(p!==1)f=Math.abs(p);continue}let v=[u,c],k=d===u+1,y={isHole:k,points:v,id:l,parent:0};o.push(y);let B;for(let tt of o)if(tt.id===f){B=tt;break}if(!B)y.parent=k?f:0;else if(B.isHole)y.parent=k?B.parent:f;else y.parent=k?f:B.parent;let H=this.#i(n,e,c,u,w,d,0);if(H===-1){if(n[m]=-l,n[m]!==1)f=Math.abs(n[m]);continue}let M=this.#a[2*H],D=this.#a[2*H+1],T=c+M,z=u+D;w=T,d=z;let E=c,V=u;while(!0){let tt=this.#s(n,e,E,V,w,d,1);M=this.#a[2*tt],D=this.#a[2*tt+1];let at=E+M,Q=V+D;v.push(Q,at);let Z=E*e+V;if(n[Z+1]===0)n[Z]=-l;else if(n[Z]===1)n[Z]=l;if(at===c&&Q===u&&E===T&&V===z){if(n[m]!==1)f=Math.abs(n[m]);break}else w=E,d=V,E=at,V=Q}}}return o}static#n(t,e,a,i){if(a-e<=4){for(let T=e;T<a-2;T+=2)i.push(t[T],t[T+1]);return}let s=t[e],n=t[e+1],l=t[a-4]-s,f=t[a-3]-n,o=Math.hypot(l,f),c=l/o,u=f/o,m=c*n-u*s,p=f/l,w=1/o,d=Math.atan(p),v=Math.cos(d),k=Math.sin(d),y=w*(Math.abs(v)+Math.abs(k)),B=w*(1-y+y**2),H=Math.max(Math.atan(Math.abs(k+v)*B),Math.atan(Math.abs(k-v)*B)),M=0,D=e;for(let T=e+2;T<a-2;T+=2){let z=Math.abs(m-c*t[T+1]+u*t[T]);if(z>M)D=T,M=z}if(M>(o*H)**2)this.#n(t,e,D+2,i),this.#n(t,D,a,i);else i.push(s,n)}static#f(t){let e=[],a=t.length;return this.#n(t,0,a,e),e.push(t[a-2],t[a-1]),e.length<=4?null:e}static#o(t,e,a,i,s,n){let l=new Float32Array(n**2),f=-2*i**2,o=n>>1;for(let d=0;d<n;d++){let v=(d-o)**2;for(let k=0;k<n;k++)l[d*n+k]=Math.exp((v+(k-o)**2)/f)}let c=new Float32Array(256),u=-2*s**2;for(let d=0;d<256;d++)c[d]=Math.exp(d**2/u);let m=t.length,p=new Uint8Array(m),w=new Uint32Array(256);for(let d=0;d<a;d++)for(let v=0;v<e;v++){let k=d*e+v,y=t[k],B=0,H=0;for(let D=0;D<n;D++){let T=d+D-o;if(T<0||T>=a)continue;for(let z=0;z<n;z++){let E=v+z-o;if(E<0||E>=e)continue;let V=t[T*e+E],tt=l[D*n+z]*c[Math.abs(V-y)];B+=V*tt,H+=tt}}let M=p[k]=Math.round(B/H);w[M]++}return[p,w]}static#r(t){let e=new Uint32Array(256);for(let a of t)e[a]++;return e}static#u(t){let e=t.length,a=new Uint8ClampedArray(e>>2),i=-1/0,s=1/0;for(let l=0,f=a.length;l<f;l++){let o=a[l]=t[l<<2];i=Math.max(i,o),s=Math.min(s,o)}let n=255/(i-s);for(let l=0,f=a.length;l<f;l++)a[l]=(a[l]-s)*n;return a}static#c(t){let e,a=-1/0,i=-1/0,s=t.findIndex((f)=>f!==0),n=s,l=s;for(e=s;e<256;e++){let f=t[e];if(f>a){if(e-n>i)i=e-n,l=e-1;a=f,n=e}}for(e=l-1;e>=0;e--)if(t[e]>t[e+1])break;return e}static#g(t){let e=t,{width:a,height:i}=t,{maxDim:s}=this.#t,n=a,l=i;if(a>s||i>s){let m=a,p=i,w=Math.log2(Math.max(a,i)/s),d=Math.floor(w);w=w===d?d-1:d;for(let k=0;k<w;k++){n=Math.ceil(m/2),l=Math.ceil(p/2);let y=new OffscreenCanvas(n,l);if(y.getContext("2d").drawImage(t,0,0,m,p,0,0,n,l),m=n,p=l,t!==e)t.close();t=y.transferToImageBitmap()}let v=Math.min(s/n,s/l);n=Math.round(n*v),l=Math.round(l*v)}let o=new OffscreenCanvas(n,l).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,n,l),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,n,l);let c=o.getImageData(0,0,n,l).data;return[this.#u(c),n,l]}static extractContoursFromText(t,{fontFamily:e,fontStyle:a,fontWeight:i},s,n,l,f){let o=new OffscreenCanvas(1,1),c=o.getContext("2d",{alpha:!1}),u=200,m=c.font=`${a} ${i} ${u}px ${e}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:w,actualBoundingBoxAscent:d,actualBoundingBoxDescent:v,fontBoundingBoxAscent:k,fontBoundingBoxDescent:y,width:B}=c.measureText(t),H=1.5,M=Math.ceil(Math.max(Math.abs(p)+Math.abs(w)||0,B)*H),D=Math.ceil(Math.max(Math.abs(d)+Math.abs(v)||u,Math.abs(k)+Math.abs(y)||u)*H);o=new OffscreenCanvas(M,D),c=o.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=m,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,M,D),c.fillStyle="black",c.fillText(t,M*(H-1)/2,D*(3-H)/2);let T=this.#u(c.getImageData(0,0,M,D).data),z=this.#r(T),E=this.#c(z),V=this.#l(T,M,D,E);return this.processDrawnLines({lines:{curves:V,width:M,height:D},pageWidth:s,pageHeight:n,rotation:l,innerMargin:f,mustSmooth:!0,areContours:!0})}static process(t,e,a,i,s){let[n,l,f]=this.#g(t),[o,c]=this.#o(n,l,f,Math.hypot(l,f)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),u=this.#c(c),m=this.#l(o,l,f,u);return this.processDrawnLines({lines:{curves:m,width:l,height:f},pageWidth:e,pageHeight:a,rotation:i,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:a,rotation:i,innerMargin:s,mustSmooth:n,areContours:l}){if(i%180!==0)[e,a]=[a,e];let{curves:f,width:o,height:c}=t,u=t.thickness??0,m=[],p=Math.min(e/o,a/c),w=p/e,d=p/a,v=[];for(let{points:y}of f){let B=n?this.#f(y):y;if(!B)continue;v.push(B);let H=B.length,M=new Float32Array(H),D=new Float32Array(3*(H===2?2:H-2));if(m.push({line:D,points:M}),H===2){M[0]=B[0]*w,M[1]=B[1]*d,D.set([NaN,NaN,NaN,NaN,M[0],M[1]],0);continue}let[T,z,E,V]=B;T*=w,z*=d,E*=w,V*=d,M.set([T,z,E,V],0),D.set([NaN,NaN,NaN,NaN,T,z],0);for(let tt=4;tt<H;tt+=2){let at=M[tt]=B[tt]*w,Q=M[tt+1]=B[tt+1]*d;D.set(Jt.createBezierPoints(T,z,E,V,at,Q),(tt-2)*3),[T,z,E,V]=[E,V,at,Q]}}if(m.length===0)return null;let k=l?new e6:new Bh;return k.build(m,e,a,1,i,l?0:u,s),{outline:k,newCurves:v,areContours:l,thickness:u,width:o,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:a,width:i,height:s}){let n=1/0,l=-1/0,f=0;for(let y of t){f+=y.length;for(let B=2,H=y.length;B<H;B++){let M=y[B]-y[B-2];n=Math.min(n,M),l=Math.max(l,M)}}let o;if(n>=-128&&l<=127)o=Int8Array;else if(n>=-32768&&l<=32767)o=Int16Array;else o=Int32Array;let c=t.length,u=U3+l9*c,m=new Uint32Array(u),p=0;m[p++]=u*Uint32Array.BYTES_PER_ELEMENT+(f-2*c)*o.BYTES_PER_ELEMENT,m[p++]=0,m[p++]=i,m[p++]=s,m[p++]=e?0:1,m[p++]=Math.max(0,Math.floor(a??0)),m[p++]=c,m[p++]=o.BYTES_PER_ELEMENT;for(let y of t)m[p++]=y.length-2,m[p++]=y[0],m[p++]=y[1];let w=new CompressionStream("deflate-raw"),d=w.writable.getWriter();await d.ready,d.write(m);let v=o.prototype.constructor;for(let y of t){let B=new v(y.length-2);for(let H=2,M=y.length;H<M;H++)B[H-2]=y[H]-y[H-2];d.write(B)}return d.close(),(await new Response(w.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e=Uint8Array.fromBase64(t),{readable:a,writable:i}=new DecompressionStream("deflate-raw"),s=i.getWriter();await s.ready,s.write(e).then(async()=>{await s.ready,await s.close()}).catch(()=>{});let n=null,l=0;for await(let B of a)n||=new Uint8Array(new Uint32Array(B.buffer,0,4)[0]),n.set(B,l),l+=B.length;let f=new Uint32Array(n.buffer,0,n.length>>2),o=f[1];if(o!==0)throw Error(`Invalid version: ${o}`);let c=f[2],u=f[3],m=f[4]===0,p=f[5],w=f[6],d=f[7],v=[],k=(U3+l9*w)*Uint32Array.BYTES_PER_ELEMENT,y;switch(d){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(n.buffer,k);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(n.buffer,k);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(n.buffer,k);break}l=0;for(let B=0;B<w;B++){let H=f[l9*B+U3],M=new Float32Array(H+2);v.push(M);for(let D=0;D<l9-1;D++)M[D]=f[l9*B+U3+D+1];for(let D=0;D<H;D++)M[D+2]=M[D]+y[l++]}return{areContours:m,thickness:p,outlines:v,width:c,height:u}}catch(e){return de(`decompressSignature: ${e}`),null}}}class vp extends qp{constructor(){super();super.updateProperties({fill:se._defaultLineColor,"stroke-width":0})}clone(){let t=new vp;return t.updateAll(this),t}}class Sp extends d6{constructor(t){super(t);super.updateProperties({stroke:se._defaultLineColor,"stroke-width":1})}clone(){let t=new Sp(this._viewParameters);return t.updateAll(this),t}}class D0 extends $e{#t=!1;#e=null;#a=null;#i=null;static _type="signature";static _editorType=je.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"});this._willKeepAspectRatio=!0,this.#a=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){se.initialize(t,e),this._defaultDrawingOptions=new vp,this._defaultDrawnSignatureOptions=new Sp(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return be(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){if(this._drawId===null)return;super.onScaleChanging()}render(){if(this.div)return this.div;let t,e,{_isCopy:a}=this;if(a)this._isCopy=!1,t=this.x,e=this.y;if(super.render(),this._drawId===null)if(this.#a){let{lines:i,mustSmooth:s,areContours:n,description:l,uuid:f,heightInPage:o}=this.#a,{rawDims:{pageWidth:c,pageHeight:u},rotation:m}=this.parent.viewport,p=nr.processDrawnLines({lines:i,pageWidth:c,pageHeight:u,rotation:m,innerMargin:D0._INNER_MARGIN,mustSmooth:s,areContours:n});this.addSignature(p,o,l,f)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#e||""}));if(a)this._isCopy=!0,this._moveAfterPaste(t,e);return this.div}setUuid(t){this.#i=t,this.addEditToolbar()}getUuid(){return this.#i}get description(){return this.#e}set description(t){if(this.#e=t,!this.div)return;this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then((e)=>{e?.updateEditSignatureButton(t)})}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:a,width:i,height:s}=this.#a,n=Math.max(i,s),l=nr.processDrawnLines({lines:{curves:t.map((f)=>({points:f})),thickness:a,width:i,height:s},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:l.outline}}get toolbarButtons(){if(this._uiManager.signatureManager)return[["editSignature",this._uiManager.signatureManager]];return super.toolbarButtons}addSignature(t,e,a,i){let{x:s,y:n}=this,{outline:l}=this.#a=t;this.#t=l instanceof e6,this.description=a;let f;if(this.#t)f=D0.getDefaultDrawingOptions();else f=D0._defaultDrawnSignatureOptions.clone(),f.updateProperties({"stroke-width":l.thickness});this._addOutlines({drawOutlines:l,drawingOptions:f});let[,o]=this.pageDimensions,c=e/o;if(c=c>=1?0.5:c,this.width*=c/this.height,this.width>=1)c*=0.9/this.width,this.width=0.9;this.height=c,this.setDims(),this.x=s,this.y=n,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!a}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:a},rotation:i}=this.parent.viewport;return nr.process(t,e,a,i,D0._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:a,pageHeight:i},rotation:s}=this.parent.viewport;return nr.extractContoursFromText(t,e,a,i,s,D0._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:a},rotation:i}=this.parent.viewport;return nr.processDrawnLines({lines:t,pageWidth:e,pageHeight:a,rotation:i,innerMargin:D0._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){if(t)this._drawingOptions=D0.getDefaultDrawingOptions();else this._drawingOptions=D0._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e})}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:a}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});if(this.addComment(s),t)s.paths={lines:e,points:a},s.uuid=this.#i,s.isCopy=!0;else s.lines=e;if(this.#e)s.accessibilityData={type:"Figure",alt:this.#e};return s}static deserializeDraw(t,e,a,i,s,n){if(n.areContours)return e6.deserialize(t,e,a,i,s,n);return Bh.deserialize(t,e,a,i,s,n)}static async deserialize(t,e,a){let i=await super.deserialize(t,e,a);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class eO extends se{#t=null;#e=null;#a=null;#i=null;#s=null;#l="";#n=null;#f=!1;#o=null;#r=!1;#u=!1;static _type="stamp";static _editorType=je.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#i=t.bitmapUrl,this.#s=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){se.initialize(t,e)}static isHandlingMimeForPasting(t){return Kb.includes(t)}static paste(t,e){e.pasteEditor({mode:je.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){if(this._uiManager.useNewAltTextFlow)this.div.hidden=!1;super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#c(t,e=!1){if(!t){this.remove();return}if(this.#t=t.bitmap,!e)this.#e=t.id,this.#r=t.isSvg;if(t.file)this.#l=t.file.name;this.#b()}#g(){if(this.#a=null,this._uiManager.enableWaiting(!1),!this.#n)return;if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:a}=this._uiManager;if(!a)throw Error("No ML.");if(!await a.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:i,width:s,height:n}=t||this.copyCanvas(null,null,!0).imageData,l=await a.guess({name:"altText",request:{data:i,width:s,height:n,channels:i.length/(s*n)}});if(!l)throw Error("No response from the AI service.");if(l.error)throw Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw Error("No valid response from the AI service.");let f=l.output;if(await this.setGuessedAltText(f),e&&!this.hasAltTextData())this.altTextData={alt:f,decorative:!1};return f}#p(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then((a)=>this.#c(a,!0)).finally(()=>this.#g());return}if(this.#i){let a=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#a=this._uiManager.imageManager.getFromUrl(a).then((i)=>this.#c(i)).finally(()=>this.#g());return}if(this.#s){let a=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#a=this._uiManager.imageManager.getFromFile(a).then((i)=>this.#c(i)).finally(()=>this.#g());return}let t=document.createElement("input");t.type="file",t.accept=Kb.join(",");let e=this._uiManager._signal;this.#a=new Promise((a)=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#c(i)}a()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),a()},{signal:e})}).finally(()=>this.#g()),t.click()}remove(){if(this.#e){if(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#n?.remove(),this.#n=null,this.#o)clearTimeout(this.#o),this.#o=null}super.remove()}rebuild(){if(!this.parent){if(this.#e)this.#p();return}if(super.rebuild(),this.div===null)return;if(this.#e&&this.#n===null)this.#p();if(!this.isAttachedToDOM)this.parent.add(this)}onceAdded(t){if(this._isDraggable=!0,t)this.div.focus()}isEmpty(){return!(this.#a||this.#t||this.#i||this.#s||this.#e||this.#f)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy)t=this.x,e=this.y;if(super.render(),this.div.hidden=!0,this.createAltText(),!this.#f)if(this.#t)this.#b();else this.#p();if(this._isCopy)this._moveAfterPaste(t,e);return this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){let{id:a,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);if(e.remove(),a&&this._uiManager.imageManager.isValidId(a)){if(this.#e=a,i)this.#t=i;this.#f=!1,this.#b()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;if(this.#o!==null)clearTimeout(this.#o);let t=200;this.#o=setTimeout(()=>{this.#o=null,this.#m()},t)}#b(){let{div:t}=this,{width:e,height:a}=this.#t,[i,s]=this.pageDimensions,n=0.75;if(this.width)e=this.width*i,a=this.height*s;else if(e>0.75*i||a>0.75*s){let f=Math.min(0.75*i/e,0.75*s/a);e*=f,a*=f}this._uiManager.enableWaiting(!1);let l=this.#n=document.createElement("canvas");if(l.setAttribute("role","img"),this.addContainer(l),this.width=e/i,this.height=a/s,this.setDims(),this._initialOptions?.isCentered)this.center();else this.fixAndSetPosition();if(this._initialOptions=null,!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)t.hidden=!1;if(this.#m(),!this.#u)this.parent.addUndoableEditor(this),this.#u=!0;if(this._reportTelemetry({action:"inserted_image"}),this.#l)this.div.setAttribute("aria-description",this.#l);if(!this.annotationElementId)this._uiManager.a11yAlert(se._l10nAlert.stamp)}copyCanvas(t,e,a=!1){if(!t)t=224;let{width:i,height:s}=this.#t,n=new N0,l=this.#t,f=i,o=s,c=null;if(e){if(i>e||s>e){let D=Math.min(e/i,e/s);f=Math.floor(i*D),o=Math.floor(s*D)}c=document.createElement("canvas");let m=c.width=Math.ceil(f*n.sx),p=c.height=Math.ceil(o*n.sy);if(!this.#r)l=this.#h(m,p);let w=c.getContext("2d");w.filter=this._uiManager.hcmFilter;let d="white",v="#cfcfd8";if(this._uiManager.hcmFilter!=="none")v="black";else if(OF.isDarkMode)d="#8f8f9d",v="#42414d";let k=15,y=k*n.sx,B=k*n.sy,H=new OffscreenCanvas(y*2,B*2),M=H.getContext("2d");M.fillStyle=d,M.fillRect(0,0,y*2,B*2),M.fillStyle=v,M.fillRect(0,0,y,B),M.fillRect(y,B,y,B),w.fillStyle=w.createPattern(H,"repeat"),w.fillRect(0,0,m,p),w.drawImage(l,0,0,l.width,l.height,0,0,m,p)}let u=null;if(a){let m,p;if(n.symmetric&&l.width<t&&l.height<t)m=l.width,p=l.height;else if(l=this.#t,i>t||s>t){let v=Math.min(t/i,t/s);if(m=Math.floor(i*v),p=Math.floor(s*v),!this.#r)l=this.#h(m,p)}let d=new OffscreenCanvas(m,p).getContext("2d",{willReadFrequently:!0});d.drawImage(l,0,0,l.width,l.height,0,0,m,p),u={width:m,height:p,data:d.getImageData(0,0,m,p).data}}return{canvas:c,width:f,height:o,imageData:u}}#h(t,e){let{width:a,height:i}=this.#t,s=a,n=i,l=this.#t;while(s>2*t||n>2*e){let f=s,o=n;if(s>2*t)s=Math.ceil(s/2);if(n>2*e)n=Math.ceil(n/2);let c=new OffscreenCanvas(s,n);c.getContext("2d").drawImage(l,0,0,f,o,0,0,s,n),l=c.transferToImageBitmap()}return l}#m(){let[t,e]=this.parentDimensions,{width:a,height:i}=this,s=new N0,n=Math.ceil(a*t*s.sx),l=Math.ceil(i*e*s.sy),f=this.#n;if(!f||f.width===n&&f.height===l)return;f.width=n,f.height=l;let o=this.#r?this.#t:this.#h(n,l),c=f.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(o,0,0,o.width,o.height,0,0,n,l)}#j(t){if(t){if(this.#r){let i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#r){let[e,a]=this.pageDimensions,i=Math.round(this.width*e*rr.PDF_TO_CSS_UNITS),s=Math.round(this.height*a*rr.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,a){let i=null,s=!1;if(t instanceof pp){let{data:{rect:d,rotation:v,id:k,structParent:y,popupRef:B,richText:H,contentsObj:M,creationDate:D,modificationDate:T},container:z,parent:{page:{pageNumber:E}},canvas:V}=t,tt,at;if(V)delete t.canvas,{id:tt,bitmap:at}=a.imageManager.getFromCanvas(z.id,V),V.remove();else s=!0,t._hasNoCanvas=!0;let Q=(await e._structTree.getAriaAttributes(`pdfjs_internal_id_${k}`))?.get("aria-label")||"";i=t={annotationType:je.STAMP,bitmapId:tt,bitmap:at,pageIndex:E-1,rect:d.slice(0),rotation:v,annotationElementId:k,id:k,deleted:!1,accessibilityData:{decorative:!1,altText:Q},isSvg:!1,structParent:y,popupRef:B,richText:H,comment:M?.str||null,creationDate:D,modificationDate:T}}let n=await super.deserialize(t,e,a),{rect:l,bitmap:f,bitmapUrl:o,bitmapId:c,isSvg:u,accessibilityData:m}=t;if(s)a.addMissingCanvas(t.id,n),n.#f=!0;else if(c&&a.imageManager.isValidId(c)){if(n.#e=c,f)n.#t=f}else n.#i=o;n.#r=u;let[p,w]=n.pageDimensions;if(n.width=(l[2]-l[0])/p,n.height=(l[3]-l[1])/w,m)n.altTextData=m;if(n._initialData=i,t.comment)n.setCommentData(t);return n.#u=!!i,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let a=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#r});if(this.addComment(a),t)return a.bitmapUrl=this.#j(!0),a.accessibilityData=this.serializeAltText(!0),a.isCopy=!0,a;let{decorative:i,altText:s}=this.serializeAltText(!1);if(!i&&s)a.accessibilityData={type:"Figure",alt:s};if(this.annotationElementId){let l=this.#d(a);if(l.isSame)return null;if(l.isSameAltText)delete a.accessibilityData;else a.accessibilityData.structParent=this._initialData.structParent??-1;return a.id=this.annotationElementId,delete a.bitmapId,a}if(e===null)return a;e.stamps||=new Map;let n=this.#r?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:n,serialized:a}),a.bitmap=this.#j(!1);else if(this.#r){let l=e.stamps.get(this.#e);if(n>l.area)l.area=n,l.serialized.bitmap.close(),l.serialized.bitmap=this.#j(!1)}return a}#d(t){let{pageIndex:e,accessibilityData:{altText:a}}=this._initialData,i=t.pageIndex===e,s=(t.accessibilityData?.alt||"")===a;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&s,isSameAltText:s}}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class S1{#t;#e=!1;#a=null;#i=null;#s=null;#l=new Map;#n=!1;#f=!1;#o=!1;#r=null;#u=null;#c=null;#g=null;#p=null;#b=-1;#h;static _initialized=!1;static#m=new Map([Ti,Ap,eO,ai,D0].map((t)=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:a,structTreeLayer:i,accessibilityManager:s,annotationLayer:n,drawLayer:l,textLayer:f,viewport:o,l10n:c}){let u=[...S1.#m.values()];if(!S1._initialized){S1._initialized=!0;for(let m of u)m.initialize(c,t)}t.registerEditorTypes(u),this.#h=t,this.pageIndex=e,this.div=a,this.#t=s,this.#a=n,this.viewport=o,this.#c=f,this.drawLayer=l,this._structTree=i,this.#h.addLayer(this)}get isEmpty(){return this.#l.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===je.NONE}updateToolbar(t){this.#h.updateToolbar(t)}updateMode(t=this.#h.getMode()){switch(this.#q(),t){case je.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case je.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case je.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===je.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(let a of S1.#m.values())e.toggle(`${a._type}Editing`,t===a._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#c?.div}setEditingState(t){this.#h.setEditingState(t)}addCommands(t){this.#h.addCommands(t)}cleanUndoStack(t){this.#h.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#a?.togglePointerEvents(t)}get#j(){return this.#l.size!==0?this.#l.values():this.#h.getEditors(this.pageIndex)}async enable(){this.#o=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#p?.abort(),this.#p=null;let t=new Set;for(let a of this.#j)if(a.enableEditing(),a.show(!0),a.annotationElementId)this.#h.removeChangedExistingAnnotation(a),t.add(a.annotationElementId);let e=this.#a;if(e)for(let a of e.getEditableAnnotations()){if(a.hide(),this.#h.isDeletedAnnotationElement(a.data.id))continue;if(t.has(a.data.id))continue;let i=await this.deserialize(a);if(!i)continue;this.addOrRebuild(i),i.enableEditing()}this.#o=!1,this.#h._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#f=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#c&&!this.#p){this.#p=new AbortController;let i=this.#h.combinedSignal(this.#p);this.#c.div.addEventListener("pointerdown",(s)=>{let{clientX:l,clientY:f,timeStamp:o}=s,c=this.#b;if(o-c>500){this.#b=o;return}this.#b=-1;let{classList:u}=this.div;u.toggle("getElements",!0);let m=document.elementsFromPoint(l,f);if(u.toggle("getElements",!1),!this.div.contains(m[0]))return;let p,w=new RegExp("^pdfjs_internal_editor_[0-9]+$");for(let v of m)if(w.test(v.id)){p=v.id;break}if(!p)return;let d=this.#l.get(p);if(d?.annotationElementId===null)Ia(s),d.dblclick(s)},{signal:i,capture:!0})}let t=this.#a,e=[];if(t){let i=new Map,s=new Map;for(let n of this.#j){if(n.disableEditing(),!n.annotationElementId){e.push(n);continue}if(n.serialize()!==null){i.set(n.annotationElementId,n);continue}else s.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}for(let n of t.getEditableAnnotations()){let{id:l}=n.data;if(this.#h.isDeletedAnnotationElement(l)){n.updateEdited({deleted:!0});continue}let f=s.get(l);if(f){f.resetAnnotationElement(n),f.show(!1),n.show();continue}if(f=i.get(l),f){if(this.#h.addChangedExistingAnnotation(f),f.renderAnnotationElement(n))f.show(!1)}n.show()}}if(this.#q(),this.isEmpty)this.div.hidden=!0;let{classList:a}=this.div;for(let i of S1.#m.values())a.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#f=!1}getEditableAnnotation(t){return this.#a?.getEditableAnnotation(t)||null}setActiveEditor(t){if(this.#h.getActive()===t)return;this.#h.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#c?.div&&!this.#g){this.#g=new AbortController;let t=this.#h.combinedSignal(this.#g);this.#c.div.addEventListener("pointerdown",this.#d.bind(this),{signal:t}),this.#c.div.classList.add("highlighting")}}disableTextSelection(){if(this.div.tabIndex=0,this.#c?.div&&this.#g)this.#g.abort(),this.#g=null,this.#c.div.classList.remove("highlighting")}#d(t){this.#h.unselectAll();let{target:e}=t;if(e===this.#c.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#c.div.contains(e)){let{isMac:a}=ha.platform;if(t.button!==0||t.ctrlKey&&a)return;this.#h.showAllEditors("highlight",!0,!0),this.#c.div.classList.add("free"),this.toggleDrawing(),ai.startHighlighting(this,this.#h.direction==="ltr",{target:this.#c.div,x:t.x,y:t.y}),this.#c.div.addEventListener("pointerup",()=>{this.#c.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#h._signal}),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;let t=this.#h.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#l.set(t.id,t);let{annotationElementId:e}=t;if(e&&this.#h.isDeletedAnnotationElement(e))this.#h.removeDeletedAnnotationElement(t)}detach(t){if(this.#l.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#f&&t.annotationElementId)this.#h.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#h.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){if(t.parent===this)return;if(t.parent&&t.annotationElementId)this.#h.addDeletedAnnotationElement(t),se.deleteAnnotationElement(t),t.annotationElementId=null;if(this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM)t.div.remove(),this.div.append(t.div)}add(t){if(t.parent===this&&t.isAttachedToDOM)return;if(this.changeParent(t),this.#h.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#o),this.#h.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;if(t.div.contains(e)&&!this.#s)t._focusEventsAllowed=!1,this.#s=setTimeout(()=>{if(this.#s=null,!t.div.contains(document.activeElement))t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal}),e.focus();else t._focusEventsAllowed=!0},0);t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){if(t.needsToBeRebuilt())t.parent||=this,t.rebuild(),t.show();else this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),a=()=>{t.remove()};this.addCommands({cmd:e,undo:a,mustExec:!1})}getEditorByUID(t){for(let e of this.#l.values())if(e.uid===t)return e;return null}get#w(){return S1.#m.get(this.#h.getMode())}combinedSignal(t){return this.#h.combinedSignal(t)}#S(t){let e=this.#w;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#w?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#h.updateMode(t.mode);let{offsetX:a,offsetY:i}=this.#y(),s=this.#h.getId(),n=this.#S({parent:this,id:s,x:a,y:i,uiManager:this.#h,isCentered:!0,...e});if(n)this.add(n)}async deserialize(t){return await S1.#m.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#h)||null}createAndAddNewEditor(t,e,a={}){let i=this.#h.getId(),s=this.#S({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#h,isCentered:e,...a});if(s)this.add(s);return s}get boundingClientRect(){return this.div.getBoundingClientRect()}#y(){let{x:t,y:e,width:a,height:i}=this.boundingClientRect,s=Math.max(0,t),n=Math.max(0,e),l=Math.min(window.innerWidth,t+a),f=Math.min(window.innerHeight,e+i),o=(s+l)/2-t,c=(n+f)/2-e,[u,m]=this.viewport.rotation%180===0?[o,c]:[c,o];return{offsetX:u,offsetY:m}}addNewEditor(t={}){this.createAndAddNewEditor(this.#y(),!0,t)}setSelected(t){this.#h.setSelected(t)}toggleSelected(t){this.#h.toggleSelected(t)}unselect(t){this.#h.unselect(t)}pointerup(t){let{isMac:e}=ha.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#n)return;if(this.#n=!1,this.#w?.isDrawer&&this.#w.supportMultipleDrawings)return;if(!this.#e){this.#e=!0;return}let a=this.#h.getMode();if(a===je.STAMP||a===je.POPUP||a===je.SIGNATURE){this.#h.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#h.getMode()===je.HIGHLIGHT)this.enableTextSelection();if(this.#n){this.#n=!1;return}let{isMac:e}=ha.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#n=!0,this.#w?.isDrawer){this.startDrawingSession(t);return}let a=this.#h.getActive();this.#e=!a||a.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#r){this.#w.startDrawing(this,this.#h,!1,t);return}this.#h.setCurrentDrawingSession(this),this.#r=new AbortController;let e=this.#h.combinedSignal(this.#r);this.div.addEventListener("blur",({relatedTarget:a})=>{if(a&&!this.div.contains(a))this.#u=null,this.commitOrRemove()},{signal:e}),this.#w.startDrawing(this,this.#h,!1,t)}pause(t){if(t){let{activeElement:e}=document;if(this.div.contains(e))this.#u=e;return}if(this.#u)setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){if(!this.#r)return null;return this.#h.setCurrentDrawingSession(null),this.#r.abort(),this.#r=null,this.#u=null,this.#w.endDrawing(t)}findNewParent(t,e,a){let i=this.#h.findParent(e,a);if(i===null||i===this)return!1;return i.changeParent(t),!0}commitOrRemove(){if(this.#r)return this.endDrawingSession(),!0;return!1}onScaleChanging(){if(!this.#r)return;this.#w.onScaleChangingWhenDrawing(this)}destroy(){if(this.commitOrRemove(),this.#h.getActive()?.parent===this)this.#h.commitOrRemove(),this.#h.setActiveEditor(null);if(this.#s)clearTimeout(this.#s),this.#s=null;for(let t of this.#l.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#l.clear(),this.#h.removeLayer(this)}#q(){for(let t of this.#l.values())if(t.isEmpty())t.remove()}async render({viewport:t}){this.viewport=t,or(this.div,t);for(let e of this.#h.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#h.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#h.commitOrRemove(),this.#q();let e=this.viewport.rotation,a=t.rotation;if(this.viewport=t,or(this.div,{rotation:a}),e!==a)for(let i of this.#l.values())i.rotate(a)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#h.viewParameters.realScale}}function YV(t,e){if(t===e)return 0;return t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function I3(t){if(!t)return null;if(t.nodeType===Node.ELEMENT_NODE)return t.closest(".textLayer");return t.parentElement?.closest(".textLayer")||null}function JV(t,e,a,i){if(t===a)return e<=i;let s=t.compareDocumentPosition(a);if(s&Node.DOCUMENT_POSITION_FOLLOWING)return!0;if(s&Node.DOCUMENT_POSITION_PRECEDING)return!1;return null}function kF(t,e,a){if(t.nodeType!==Node.ELEMENT_NODE||!t.classList.contains("textLayer")||e!==t.childNodes.length)return{container:t,offset:e};let i=t.lastChild;if(i?.nodeType===Node.ELEMENT_NODE&&i.classList.contains("endOfContent"))i=i.previousSibling;if(!i||!a.contains(i))return null;if(i.nodeType===Node.TEXT_NODE)return{container:i,offset:i.textContent.length};return{container:i,offset:i.childNodes.length}}class ge{#t=null;#e=new Map;#a=null;#i=null;#s=null;#l=null;#n=new Map;static#f=0;static#o=0;static#r=null;static#u=new Set;static#c=!1;static#g=new Set;static#p=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:a,textLayer:i=null}){if(this.pageIndex=a,this.#i=t,this.#s=e,i){let s=ge.#p.get(i);if(s?.selectionDiv)s.selectionDiv.remove(),ge.#u.delete(s.selectionDiv);if(ge.#p.set(i,{drawLayer:this}),ge.#g.add(i),this.#a=i,this.#l=new MutationObserver((n)=>{if(!this.#t||!this.#a?.isConnected||!ge.#h())return;for(let{addedNodes:l}of n)for(let f of l)if(f.nodeType===Node.ELEMENT_NODE&&f.classList.contains("endOfContent")){ge.#j();return}}),this.#l.observe(i,{childList:!0}),ge.#r===null){ge.#r=new AbortController;let{signal:n}=ge.#r;document.addEventListener("selectionchange",ge.#j.bind(ge),{signal:n}),document.addEventListener("pointerdown",()=>{ge.#c=!0},{signal:n}),document.addEventListener("pointerup",()=>{ge.#c=!1},{signal:n}),window.addEventListener("blur",()=>{ge.#c=!1},{signal:n})}}}setParent(t){if(!this.#t){if(this.#t=t,this.#a?.isConnected&&ge.#h())ge.#j();return}if(this.#t!==t){if(this.#e.size>0)for(let e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#b(t){let e=this.#p.get(t);if(!e?.selectionDiv)return;e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null}static#h(){let t=document.getSelection();return!!t&&!t.isCollapsed}static#m(){return[...this.#g].filter((t)=>t.isConnected).sort(YV)}static#j(){let t=document.getSelection();if(!t||t.isCollapsed){for(let n of this.#u)n.remove();this.#u.clear();return}let e=new WeakMap,a=this.#m(),i=[];for(let n=0,l=t.rangeCount;n<l;n++){let f=t.getRangeAt(n);if(f.collapsed)continue;let{startContainer:o,startOffset:c,endContainer:u,endOffset:m}=f,p=I3(o),w=I3(u),d=p===null,v=w===null;if(this.#c&&d!==v)return;if(t.rangeCount===1){let{anchorNode:B,anchorOffset:H,focusNode:M,focusOffset:D}=t,T=I3(B),z=I3(M),E=JV(B,H,M,D);if(T&&z&&E!==null)if(E)o=B,c=H,p=T,u=M,m=D,w=z;else o=M,c=D,p=z,u=B,m=H,w=T}let k=a.filter((B)=>f.intersectsNode(B));if(k.length===0)continue;let y=!1;if(!p)p=k[0],o=p,c=0,y=!0;if(!w)w=k.at(-1),u=w,m=w.childNodes.length,y=!0;if(u.nodeType===Node.ELEMENT_NODE){if(u.classList.contains("endOfContent")){let B=u.previousSibling;if(!B)continue;u=B,m=B.nodeType===Node.TEXT_NODE?B.textContent.length:B.childNodes.length}else if(u.classList.contains("textLayer")&&u.childNodes.length===m){let B=kF(u,m,w);if(!B)continue;u=B.container,m=B.offset}}if(o.nodeType===Node.ELEMENT_NODE){let B=kF(o,c,p);if(!B)continue;o=B.container,c=B.offset}if(p===w&&!y&&k.includes(p)){i.push([f,p]);continue}for(let B of k){let H=B.firstChild;if(!H)continue;let M=document.createRange();if(B===p)M.setStart(o,c);else M.setStartBefore(H);if(B===w)M.setEnd(u,m);else{let D=B.lastChild;if(!D)continue;if(D.nodeType===Node.ELEMENT_NODE&&D.classList.contains("endOfContent")){let T=D.previousSibling;if(!T)continue;M.setEndAfter(T)}else M.setEndAfter(D)}if(!M.collapsed)i.push([M,B])}}let s=new Set(i.map((n)=>n[1]));for(let n of this.#g)if(!s.has(n))this.#b(n);for(let[n,l]of i){let f=ge.#p.get(l);if(!f)continue;let o=e.get(l);if(!o){let w=l.getBoundingClientRect();o=(d,v,k,y)=>({x:(d-w.x)/w.width,y:(v-w.y)/w.height,width:k/w.width,height:y/w.height}),e.set(l,o)}let c=[];for(let{x:w,y:d,width:v,height:k}of n.getClientRects()){if(v===0||k===0)continue;if({x:w,y:d,width:v,height:k}=o(w,d,v,k),v===1&&k===1)continue;c.push(`M${w} ${d} h${v} v${k} h-${v} Z`)}if(c.length===0)continue;let{drawLayer:u,selectionDiv:m,path:p}=f;if(!m){let w=`clip_selection_${ge.#o++}`;m=document.createElement("div"),m.className="selection",m.style.clipPath=`url(#${w})`;let d=u.#i?.createSelectionStyle(u.#s);if(d)for(let[y,B]of Object.entries(d))m.style.setProperty(y,B);let v=ge._svgFactory.create(1,1,!0);v.setAttribute("aria-hidden","true"),v.setAttribute("width","100%"),v.setAttribute("height","100%");let k=ge._svgFactory.createElement("clipPath");k.setAttribute("id",w),k.setAttribute("clipPathUnits","objectBoundingBox"),p=ge._svgFactory.createElement("path"),k.append(p),v.append(k),m.append(v),f.path=p,f.selectionDiv=m}if(!m.parentNode&&u.#t)u.#t.append(m),this.#u.add(m);p.setAttribute("d",c.join(" "))}}static get _svgFactory(){return be(this,"_svgFactory",new p9)}static#d(t,[e,a,i,s]){let{style:n}=t;n.top=`${100*a}%`,n.left=`${100*e}%`,n.width=`${100*i}%`,n.height=`${100*s}%`}#w(){let t=ge._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#S(t,e){let a=ge._svgFactory.createElement("clipPath");t.append(a);let i=`clip_${e}`;a.setAttribute("id",i),a.setAttribute("clipPathUnits","objectBoundingBox");let s=ge._svgFactory.createElement("use");return a.append(s),s.setAttribute("href",`#${e}`),s.classList.add("clip"),i}#y(t,e){for(let[a,i]of Object.entries(e))if(i===null)t.removeAttribute(a);else t.setAttribute(a,i)}draw(t,e=!1,a=!1){let i=ge.#f++,s=this.#w(),n=ge._svgFactory.createElement("defs");s.append(n);let l=ge._svgFactory.createElement("path");n.append(l);let f=`path_${i}`;if(l.setAttribute("id",f),l.setAttribute("vector-effect","non-scaling-stroke"),e)this.#n.set(i,l);let o=a?this.#S(n,f):null,c=ge._svgFactory.createElement("use");return s.append(c),c.setAttribute("href",`#${f}`),this.updateProperties(s,t),this.#e.set(i,s),{id:i,clipPathId:`url(#${o})`}}drawOutline(t,e){let a=ge.#f++,i=this.#w(),s=ge._svgFactory.createElement("defs");i.append(s);let n=ge._svgFactory.createElement("path");s.append(n);let l=`path_${a}`;n.setAttribute("id",l),n.setAttribute("vector-effect","non-scaling-stroke");let f;if(e){let u=ge._svgFactory.createElement("mask");s.append(u),f=`mask_${a}`,u.setAttribute("id",f),u.setAttribute("maskUnits","objectBoundingBox");let m=ge._svgFactory.createElement("rect");u.append(m),m.setAttribute("width","1"),m.setAttribute("height","1"),m.setAttribute("fill","white");let p=ge._svgFactory.createElement("use");u.append(p),p.setAttribute("href",`#${l}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}let o=ge._svgFactory.createElement("use");if(i.append(o),o.setAttribute("href",`#${l}`),f)o.setAttribute("mask",`url(#${f})`);let c=o.cloneNode();return i.append(c),o.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(a,i),a}finalizeDraw(t,e){this.#n.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:a,bbox:i,rootClass:s,path:n}=e,l=typeof t==="number"?this.#e.get(t):t;if(!l)return;if(a)this.#y(l,a);if(i)ge.#d(l,i);if(s){let{classList:f}=l;for(let[o,c]of Object.entries(s))f.toggle(o,c)}if(n){let o=l.firstElementChild.firstElementChild;this.#y(o,n)}}updateParent(t,e){if(e===this)return;let a=this.#e.get(t);if(!a)return;e.#t.append(a),this.#e.delete(t),e.#e.set(t,a)}remove(t){if(this.#n.delete(t),this.#t===null)return;this.#e.get(t).remove(),this.#e.delete(t)}destroy(){this.#t=null;for(let t of this.#e.values())t.remove();if(this.#e.clear(),this.#n.clear(),this.#l?.disconnect(),this.#l=null,this.#a){if(ge.#p.get(this.#a)?.drawLayer===this){if(ge.#b(this.#a),ge.#p.delete(this.#a),ge.#g.delete(this.#a),ge.#g.size===0)ge.#r?.abort(),ge.#r=null,ge.#c=!1}this.#a=null}}}function G3(t){return`${(t*100).toFixed(2)}%`}class a6{#t=[];#e=new Map;#a=null;#i=0;#s=0;#l=0;static#n=null;constructor(t,e,a,i){this.#i=t,this.#t=e,this.#s=a.rawDims.pageWidth,this.#l=a.rawDims.pageHeight,this.#a=i}render(){let t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){let a=this.#f(this.#t.subarray(e,e+6));if(a)t.append(a)}return t.addEventListener("contextmenu",(e)=>{if(!(e.target instanceof HTMLCanvasElement))return;let a=e.target,i=this.#e.get(a);if(!i)return;let s=a6.#n?.deref();if(s===a)return;if(s)s.width=0,s.height=0;a6.#n=new WeakRef(a);let{inverseTransform:n,x1:l,y1:f,width:o,height:c}=i,u=this.#a(),m=Math.ceil(l*u.width),p=Math.ceil(f*u.height),w=Math.floor((l+o/this.#s)*u.width),d=Math.floor((f+c/this.#l)*u.height);a.width=w-m,a.height=d-p;let v=a.getContext("2d");v.setTransform(...n),v.translate(-m,-p),v.drawImage(u,0,0)}),t}#f([t,e,a,i,s,n]){let l=Math.hypot((s-t)*this.#s,(n-e)*this.#l),f=Math.hypot((a-t)*this.#s,(i-e)*this.#l);if(l<this.#i||f<this.#i)return null;let o=[(s-t)*this.#s/l,(n-e)*this.#l/l,(a-t)*this.#s/f,(i-e)*this.#l/f,0,0],c=Nt.inverseTransform(o),u=document.createElement("canvas");return u.className="textLayerImagePlaceholder",u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:"absolute",left:G3(t),top:G3(e),width:G3(l/this.#s),height:G3(f/this.#l),transformOrigin:"0% 0%",transform:`matrix(${o.join(",")})`}),this.#e.set(u,{inverseTransform:c,width:l,height:f,x1:t,y1:e}),u}}globalThis._pdfjsTestingUtils={HighlightOutliner:P3};globalThis.pdfjsLib={AbortException:C1,AnnotationEditorLayer:S1,AnnotationEditorParamsType:Ce,AnnotationEditorType:je,AnnotationEditorUIManager:Tl,AnnotationLayer:jp,AnnotationMode:Dl,AnnotationType:Ja,applyOpacity:bV,build:KV,ColorPicker:Rn,createValidAbsoluteUrl:CF,CSSConstants:HF,DOMSVGFactory:p9,DrawLayer:ge,FeatureTest:ha,fetchData:Pb,findContrastColor:pV,getDocument:op,getFilenameFromUrl:uV,getPdfFilenameFromUrl:mV,getRGB:q9,getRGBA:d9,getUuid:BF,GlobalWorkerOptions:k1,ImageKind:X3,InvalidPDFException:J3,isDataScheme:r6,isPdfFile:tp,isValidExplicitDest:vV,makeArr:w9,makeMap:$b,makeObj:Gb,MathClamp:_a,noContextMenu:Nn,normalizeUnicode:hV,OPS:T0,OutputScale:N0,PasswordException:Y3,PasswordResponses:sV,PDFDataRangeTransport:cp,PDFDateString:Q3,PDFWorker:Ji,PermissionFlag:iV,PixelsPerInch:rr,RenderingCancelledException:f6,renderRichText:MF,ResponseException:c9,setLayerDimensions:or,shadow:be,SignatureExtractor:nr,stopEvent:Ia,SupportedImageMimeTypes:Kb,TextLayer:nn,TextLayerImages:a6,TouchManager:o6,updateUrlHash:_F,Util:Nt,VerbosityLevel:i6,version:XV,XfaLayer:Wb};var Fa=Ie(Pa(),1);function sO({currentPage:t,totalPages:e,onPageChange:a,zoom:i,onZoomIn:s,onZoomOut:n,onFit:l,onDownload:f,canDownload:o}){return rt("div",{className:"relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-between gap-2 transition-colors duration-200",children:[rt("div",{className:"flex items-center gap-1.5 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5",children:[x("button",{onClick:()=>a(Math.max(1,t-1)),disabled:t<=1,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40",title:It.previous_page(),children:x(aO,{size:16})}),x("span",{className:"px-2 text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none",children:It.page_of_pages({current:t,total:e||1})}),x("button",{onClick:()=>a(Math.min(e,t+1)),disabled:t>=e,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors disabled:opacity-40",title:It.next_page(),children:x(iO,{size:16})})]}),rt("div",{className:"flex items-center gap-2",children:[rt("div",{className:"flex items-center gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5",children:[x("button",{onClick:n,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:It.zoom_out(),children:x(ul,{size:16})}),rt("span",{className:"w-12 text-center text-xs font-mono font-medium text-gray-900 dark:text-gray-100 select-none",children:[Math.round(i*100),"%"]}),x("button",{onClick:s,className:"p-1.5 rounded hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors",title:It.zoom_in(),children:x(ch,{size:16})})]}),x("button",{onClick:l,className:"text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent",children:It.fit()}),rt("button",{onClick:f,disabled:!o,className:"flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50",title:It.download_original_file(),children:[x(Vn,{size:14}),It.download()]})]})]})}var Oh="./pdf.worker.min-szxdj13d.mjs";if(typeof window<"u"&&k1){let t=typeof Oh==="string"?Oh.startsWith("/")?Oh:"/"+Oh.replace(/^\.\//,""):Oh;k1.workerSrc=t}var $V=Fa.default.forwardRef(({file:t,annotations:e,shareId:a,children:i,onPlay:s,onPause:n,onTimeUpdate:l,startTime:f},o)=>{let{isDrawing:c,currentTool:u,currentColor:m,addAnnotation:p,annotations:w}=_s(),[d,v]=Fa.useState(null),[k,y]=Fa.useState(()=>f&&!isNaN(f)?Math.max(1,Math.round(f)):1),[B,H]=Fa.useState(1),[M,D]=Fa.useState(""),[T,z]=Fa.useState({width:800,height:1000}),[E,V]=Fa.useState(!0),[tt,at]=Fa.useState(null);Fa.useImperativeHandle(o,()=>({play:()=>{s?.()},pause:()=>{n?.()},seekTo:(Dt)=>{if(Dt&&!isNaN(Dt)){let Mt=Math.max(1,Math.min(B,Math.round(Dt)));y(Mt)}}}),[B,s,n]),Fa.useEffect(()=>{l?.(k)},[k,l]),Fa.useEffect(()=>{let Dt=(Mt)=>{let Xt=document.activeElement;if(Xt&&(Xt.tagName==="INPUT"||Xt.tagName==="TEXTAREA"||Xt instanceof HTMLElement&&Xt.isContentEditable))return;if(Mt.key==="ArrowRight"||Mt.key==="ArrowDown"||Mt.key==="PageDown")Mt.preventDefault(),y((Gt)=>{let ae=Math.min(B,Gt+1);if(ae!==Gt)s?.();return ae});else if(Mt.key==="ArrowLeft"||Mt.key==="ArrowUp"||Mt.key==="PageUp")Mt.preventDefault(),y((Gt)=>{let ae=Math.max(1,Gt-1);if(ae!==Gt)s?.();return ae});else if(Mt.key==="Home")Mt.preventDefault(),y(1),s?.();else if(Mt.key==="End")Mt.preventDefault(),y(B),s?.()};return window.addEventListener("keydown",Dt),()=>{window.removeEventListener("keydown",Dt)}},[B,s]);let[Q,Z]=Fa.useState({width:0,height:0}),[J,Y]=Fa.useState(1),[W,ft]=Fa.useState({x:0,y:0}),nt=Fa.useRef(null),qt=Fa.useCallback((Dt)=>{if(nt.current)nt.current.disconnect(),nt.current=null;if(Dt!==null){let Mt=new ResizeObserver((Xt)=>{let Gt=Xt[0];if(Gt)Z({width:Gt.contentRect.width,height:Gt.contentRect.height})});Mt.observe(Dt),nt.current=Mt}},[]),R=t.media?.pdfTranscode?.url||t.media?.original?.downloadUrl;Fa.useEffect(()=>{if(!R){at("No PDF URL available"),V(!1);return}let Dt=!0;V(!0),at(null);let Mt=op({url:R});return Mt.promise.then((Xt)=>{if(!Dt)return;v(Xt),H(Xt.numPages),y((Gt)=>f&&!isNaN(f)?Math.max(1,Math.min(Xt.numPages,Math.round(f))):Gt),V(!1)}).catch((Xt)=>{if(!Dt)return;console.error("Failed to load PDF:",Xt),at("Failed to load PDF document"),V(!1)}),()=>{Dt=!1,Mt.destroy().catch(()=>{})}},[R,f]),Fa.useEffect(()=>{if(!d)return;let Dt=!0,Mt=null;return d.getPage(k).then((Xt)=>{if(!Dt)return;let Gt=Xt.getViewport({scale:1}),ae=2,Xe=Xt.getViewport({scale:ae}),Re=document.createElement("canvas");Re.width=Xe.width,Re.height=Xe.height;let da=Re.getContext("2d");if(!da)return;if(Mt=Xt.render({canvasContext:da,viewport:Xe,canvas:Re}),!Dt){Mt.cancel();return}Mt.promise.then(()=>{if(!Dt)return;D(Re.toDataURL("image/png")),z({width:Gt.width,height:Gt.height})}).catch((Ve)=>{if(!Dt||Ve&&typeof Ve==="object"&&"name"in Ve&&Ve.name==="RenderingCancelledException")return;console.error("Failed to render page:",Ve)})}).catch((Xt)=>{if(!Dt)return;console.error("Failed to get page:",Xt)}),()=>{if(Dt=!1,Mt)Mt.cancel()}},[d,k]);let{width:ct,height:pt}=Q,G=T.width,Ct=T.height,Kt=1;if(ct>0&&pt>0&&G>0&&Ct>0)Kt=Math.min(ct/G,pt/Ct);Fa.useEffect(()=>{if(ct>0&&pt>0&&G>0&&Ct>0){Y(Kt);let Dt=(ct-G*Kt)/2,Mt=(pt-Ct*Kt)/2;ft({x:Dt,y:Mt})}},[t.id,k,ct,pt,Kt,G,Ct]);let le=(Dt)=>{let Mt=ct/2,Xt=pt/2,Gt=J*Dt;if(Gt<0.01||Gt>50)return;let ae=Mt-(Mt-W.x)*(Gt/J),Xe=Xt-(Xt-W.y)*(Gt/J);Y(Gt),ft({x:ae,y:Xe})},Ft=()=>{Y(Kt);let Dt=(ct-G*Kt)/2,Mt=(pt-Ct*Kt)/2;ft({x:Dt,y:Mt})},Et=async()=>{let Dt=t.media?.original?.key;if(!Dt||!t.id)return;try{let Mt=a?await Le.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:a,fileId:t.id},json:{key:Dt}}):await Le.api.files["download-url"].$post({json:{key:Dt,assetId:t.id}});if(!Mt.ok)return;let{url:Xt}=await Mt.json(),Gt=document.createElement("a");Gt.href=Xt,Gt.download=t.name||"document.pdf",document.body.appendChild(Gt),Gt.click(),document.body.removeChild(Gt)}catch{}},$t=[...e||[],...w];return rt("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[rt("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[i,x("div",{ref:qt,className:"flex-1 relative overflow-hidden",children:E?x("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 z-20",children:x("div",{className:"w-8 h-8 border-4 border-white/30 border-t-white rounded-full animate-spin"})}):tt?x("div",{className:"absolute inset-0 flex items-center justify-center text-gray-500 text-sm",children:tt}):x(O0,{width:ct,height:pt,mediaDimensions:T,imageUrl:M,annotations:$t,scale:J,offset:W,onPan:ft,className:"absolute inset-0 z-0",isDrawing:c,currentTool:u,currentColor:m,onAddAnnotation:p})})]}),x(sO,{currentPage:k,totalPages:B,onPageChange:(Dt)=>{y(Dt),s?.()},zoom:J,onZoomIn:()=>le(1.2),onZoomOut:()=>le(0.8),onFit:Ft,onDownload:Et,canDownload:!!t.media?.original?.key})]})}),nO=$V;var lO={id:"pdf",name:"PDF",match:(t)=>t.proxyType==="pdf",viewer:nO,commentsConfig:{hasTimestamp:!0,hasAnnotations:!0,hasAiBots:!0,formatTimestamp:(t)=>`P${Math.round(t)}`}};var q6=Ie(Pa(),1);var WV=q6.default.forwardRef(({file:t,shareId:e,children:a},i)=>{return q6.useImperativeHandle(i,()=>({play:()=>{},pause:()=>{},seekTo:()=>{}})),rt("div",{className:"flex flex-col flex-1 h-full overflow-hidden bg-gray-100 dark:bg-gray-950 relative",children:[rt("div",{className:"flex-1 flex flex-col-reverse md:flex-row min-h-0 relative",children:[a,x("div",{className:"flex-1 flex items-center justify-center",children:x("p",{className:"text-muted-foreground",children:"Preview unavailable"})})]}),x("div",{className:"relative px-4 py-3 bg-card border-t border-gray-200 dark:border-gray-700 z-10 flex items-center justify-end gap-2 transition-colors duration-200",children:rt("button",{onClick:async()=>{let n=t.media?.original?.key;if(!n||!t.id)return;try{let l=e?await Le.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:e,fileId:t.id},json:{key:n}}):await Le.api.files["download-url"].$post({json:{key:n,assetId:t.id}});if(!l.ok)return;let{url:f}=await l.json(),o=document.createElement("a");o.href=f,o.download="",document.body.appendChild(o),o.click(),document.body.removeChild(o)}catch{}},disabled:!t.media?.original?.key,className:"flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded bg-gray-200/50 dark:bg-white/10 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 transition-colors border border-transparent disabled:opacity-50 animate-in fade-in zoom-in-95 duration-200",title:"Download original file",children:[x(Vn,{size:14}),"Download"]})})]})}),fO=WV;var yp={id:"default",name:"Default",match:()=>!0,viewer:fO,commentsConfig:{hasTimestamp:!1,hasAnnotations:!1,hasAiBots:!1}};var PV=[lO,Z_,eF];function rO(t){if(!t)return yp;return PV.find((a)=>a.match(t))||yp}function vot({teamId:t,projectId:e,file:a,onSaveField:i,members:s,onCommentSelect:n,hideAnnotationControl:l=!1,readOnly:f=!1,publicFields:o,isPublic:c=!1,shareId:u,currentTime:m,onTyping:p,selectedCommentId:w}){let{canEdit:d}=mO(e),{fields:v,setFields:k}=gO(),y=k5(),{ref:B,inView:H}=uO(),[M,D]=zn.useState(null),[T,z]=zn.useState(null),[E,V]=zn.useState(!1),[tt,at]=zn.useState(null),{data:Q}=po({queryKey:["fields",e],queryFn:async()=>{let Ft=await Le.api.projects[":projectId"].fields.$get({param:{projectId:e}});if(!Ft.ok)throw Error("Failed to fetch fields");return await Ft.json()},enabled:!!e&&!o}),{data:Z}=po({queryKey:["projects",e,"bots"],queryFn:async()=>{let Ft=await Le.api.projects[":projectId"].bots.$get({param:{projectId:e}});if(!Ft.ok)throw Error("Failed to fetch bots");return await Ft.json()},enabled:!!e&&!f}),J=rO(a),W=J?.commentsConfig?.hasAiBots?Z||[]:[];zn.useEffect(()=>{if(o)k(o,e);else if(Q)k(Q,e)},[Q,o,e,k]);let{data:ft,fetchNextPage:nt,hasNextPage:qt}=oO({queryKey:c?["shares",u,"files",a?.id,"comments"]:["files",a?.id,"comments"],queryFn:async({pageParam:Ft})=>{if(c){let Et=localStorage.getItem(`share_pwd_${u}`)||"",$t=await Le.api.shares[":shareId"].files[":fileId"].comments.$get({param:{shareId:u,fileId:a.id},query:{after:Ft}},{headers:{"x-share-password":Et}});if(!$t.ok)throw Error("Failed to fetch comments");return await $t.json()}else{let Et=await Le.api.files[":fileId"].comments.$get({param:{fileId:a.id},query:{after:Ft}});if(!Et.ok)throw Error("Failed to fetch comments");return await Et.json()}},enabled:!!a?.id&&(!c||!!u),initialPageParam:"",refetchInterval:2000,getNextPageParam:(Ft)=>Ft.pageInfo?.cursor||void 0}),{mutate:R}=Hf({mutationFn:async({text:Ft,attachmentIds:Et,annotations:$t,replyToId:Dt,guestUserId:Mt,second:Xt})=>{if(c){let Gt=localStorage.getItem(`share_pwd_${u}`)||"",ae=await Le.api.shares[":shareId"].files[":fileId"].comments.$post({param:{shareId:u,fileId:a.id},json:{message:Ft,attachmentIds:Et,replyToId:Dt??void 0,annotations:$t,second:Xt??void 0}},{headers:{"x-share-password":Gt,...Mt?{"x-guest-user-id":Mt}:{}}});if(!ae.ok)throw Error("Failed to create comment");return await ae.json()}else{let Gt=await Le.api.files[":fileId"].comments.$post({param:{fileId:a.id},json:{message:Ft,attachmentIds:Et,replyToId:Dt??void 0,annotations:$t,second:Xt??void 0}});if(!Gt.ok)throw Error("Failed to create comment");return await Gt.json()}},onSuccess:()=>{y.invalidateQueries({queryKey:c?["shares",u,"files",a?.id,"comments"]:["files",a?.id,"comments"]})}});zn.default.useEffect(()=>{if(H&&qt)nt()},[H,nt,qt]);let ct=zn.useMemo(()=>{return(a?.fieldValues||[]).reduce((Ft,Et)=>{return Ft[Et.fieldId]=Et,Ft},{})},[a?.fieldValues]),pt=zn.useMemo(()=>{return[...v].sort((Ft,Et)=>{let $t=Ft.config?.name?.toLowerCase()||"",Dt=Et.config?.name?.toLowerCase()||"";if($t<Dt)return-1;if($t>Dt)return 1;return 0})},[v]),G=ft?.pages.flatMap((Ft)=>Ft.data??[])??[],Ct=async(Ft,Et,$t,Dt,Mt)=>{if(!a?.id)return;if(c){console.log("[handleSendMessage] checking auth status");let Xt=await Le.api.me.$get(),{id:Gt}=await Xt.json();if(console.log("[handleSendMessage] loggedInUserId:",Gt),!Gt){let ae=localStorage.getItem("guest_user_id");if(console.log("[handleSendMessage] guestUserId from storage:",ae),!ae){console.log("[handleSendMessage] no guest ID, opening popup"),at({text:Ft,attachmentIds:Et,annotations:$t,replyToId:Dt,second:Mt}),V(!0);return}R({text:Ft,attachmentIds:Et,annotations:$t,replyToId:Dt,guestUserId:ae,second:Mt})}else R({text:Ft,attachmentIds:Et,annotations:$t,replyToId:Dt,second:Mt})}else R({text:Ft,attachmentIds:Et,annotations:$t,replyToId:Dt,second:Mt});D(null)},Kt=(Ft)=>{if(console.log("[handleGuestSuccess] guestUserId:",Ft),tt)R({...tt,guestUserId:Ft}),at(null),D(null)},le=(Ft)=>{let Et=s.find(($t)=>$t.id===Ft);if(Et)return Et;if(Z){let $t=Z.find((Dt)=>Dt.id===Ft);if($t)return{id:$t.id,name:$t.name,role:"bot"}}return{id:"unknown",name:"Unknown",role:"unknown"}};if(!a)return x("div",{className:"flex h-full items-center justify-center p-8 text-center bg-background",children:rt("div",{className:"space-y-2",children:[x("p",{className:"text-sm font-medium text-foreground",children:It.no_item_selected()}),x("p",{className:"text-xs text-muted-foreground",children:It.select_file_to_view_details()})]})});return rt("div",{className:"bg-background h-full flex flex-col overflow-hidden",children:[T&&T.proxyType==="image"&&rt("div",{className:"fixed inset-0 z-[100] bg-black/95 flex flex-col items-center justify-center p-4 animate-in fade-in duration-200",onClick:()=>z(null),children:[x("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white bg-white/10 hover:bg-white/20 rounded-full p-2 transition-colors z-50",children:x(qo,{className:"w-8 h-8"})}),x("div",{className:"w-full h-full flex items-center justify-center p-2",children:x("img",{src:T.url,alt:"Enlarged view",className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:()=>z(null)})})]}),rt(hO,{defaultValue:"comments",className:"p-1 flex-1 flex flex-col px-2 min-h-0",children:[rt(cO,{className:"w-full shrink-0",children:[x(kp,{value:"comments",className:"flex-1",children:It.comments()}),x(kp,{value:"fields",className:"flex-1",children:It.fields()})]}),rt(Cp,{value:"comments",className:"flex-1 flex flex-col overflow-hidden min-h-0 mt-0",children:[x(_p,{className:"flex-1 min-h-0 [&>div>div]:block!",children:rt("div",{className:"space-y-4",children:[G.map((Ft)=>rt("div",{children:[x(f8,{teamId:t,message:Ft,getUser:le,onReply:D,onViewAttachment:z,hasReplies:!!Ft.replies?.length,formatTimestamp:J?.commentsConfig?.formatTimestamp,frameRate:J?.commentsConfig?.hasTimestamp?a?.media?.metadata?.frameRate||30:void 0,startTimecode:J?.commentsConfig?.hasTimestamp?a?.media?.metadata?.startTimecode:void 0,isSelected:w===Ft.id,onSelect:()=>{n?.(Ft)}}),Ft.replies?.map((Et,$t)=>x("div",{children:x(f8,{teamId:t,isReply:!0,message:Et,getUser:le,onReply:D,onViewAttachment:z,hasReplies:!1,isLastReply:$t===(Ft.replies?.length??0)-1,formatTimestamp:J?.commentsConfig?.formatTimestamp,frameRate:J?.commentsConfig?.hasTimestamp?a?.media?.metadata?.frameRate||30:void 0,startTimecode:J?.commentsConfig?.hasTimestamp?a?.media?.metadata?.startTimecode:void 0,isSelected:w===Et.id,onSelect:()=>{n?.(Et)}})},Et.id))]},Ft.id)),x("div",{ref:B})]})}),(!f||c)&&x("div",{className:"mt-4 shrink-0",children:x($d,{isOpen:E,onClose:()=>V(!1),onSuccess:Kt,children:x(o8,{projectId:e,onSendMessage:Ct,replyingTo:M,onCancelReply:()=>D(null),bots:W,hideAnnotationControl:l,disableMentions:c,currentTime:J?.commentsConfig?.hasTimestamp?m:void 0,formatTimestamp:J?.commentsConfig?.formatTimestamp,frameRate:J?.commentsConfig?.hasTimestamp?a?.media?.metadata?.frameRate||30:void 0,startTimecode:J?.commentsConfig?.hasTimestamp?a?.media?.metadata?.startTimecode:void 0,onTyping:p})})})]}),x(Cp,{value:"fields",className:"flex-1 flex flex-col overflow-hidden min-h-0 mt-4",children:x(_p,{className:"flex-1 px-4 min-h-0 [&>div>div]:block!",children:pt&&pt.length>0&&x("div",{className:"space-y-4 pb-4",children:pt.map((Ft)=>rt("div",{className:"space-y-1",children:[x("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:Ft.config?.name}),x("div",{className:"min-h-[28px]",children:x(bO,{config:Ft.config,value:ct[Ft.id]?.value,onSave:d?(Et)=>i(Ft.id,Et):void 0,readOnly:f||Ft.readOnly||!d})})]},Ft.id))})})})]})]})}
320
- export{go as i,Wk as j,tY as k,W_ as l,rO as m,vot as n};
320
+ export{go as n,Wk as o,tY as p,W_ as q,rO as r,vot as s};
@@ -0,0 +1 @@
1
+ import{g as B}from"./chunk-qqk51620.js";import"./chunk-h0ytx8zc.js";import"./chunk-xyjw8w3r.js";import"./chunk-ccw7mjgq.js";import"./chunk-pq18zenh.js";import"./chunk-wsyg4rwg.js";import"./chunk-7e06b2zb.js";import"./chunk-srn8t0v7.js";import"./chunk-kfhtk3eh.js";import"./chunk-kr06nrbx.js";import"./chunk-b8js74jk.js";import"./chunk-0xbf8bcg.js";import"./chunk-wg98cacx.js";import"./chunk-15sefy5t.js";import"./chunk-77r8w95d.js";import"./chunk-t3t6021k.js";import"./chunk-54tr7y2x.js";import"./chunk-1xpec5r8.js";import"./chunk-0rxhc7ka.js";import"./chunk-fa2g2wge.js";import"./chunk-fz88kkk1.js";import"./chunk-dghtwyq1.js";import"./chunk-gswbc6y9.js";import{Gh as w,oh as q}from"./chunk-nyhqy6q2.js";import"./chunk-0qkj838r.js";function O(){let{shareId:C,fileId:D}=k.useParams(),{start:E,version:G,compare:H,cmpLeft:J,cmpRight:K,cmpActive:N}=k.useSearch();return q(B,{shareId:C,initialFileId:D,startTime:E,versionId:G,compare:H,compareLeftId:J,compareRightId:K,compareActiveSide:N})}var k=w("/share/$shareId/files/$fileId")({component:O});export{k as Route};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Fj as G}from"./chunk-yhj8c5re.js";import{Zj as F}from"./chunk-kbzm1pwx.js";var y=F(G(),1),H=new Set(['"',"\\","/","b","f","n","r","t","u"]);function K(b){let f=b.codePointAt(0);return f!==void 0&&f>=0&&f<=31}function Q(b){switch(b){case"\b":return"\\b";case"\f":return"\\f";case`
2
+ import{Bk as G}from"./chunk-bs0fjz3w.js";import{Vk as F}from"./chunk-0qkj838r.js";var y=F(G(),1),H=new Set(['"',"\\","/","b","f","n","r","t","u"]);function K(b){let f=b.codePointAt(0);return f!==void 0&&f>=0&&f<=31}function Q(b){switch(b){case"\b":return"\\b";case"\f":return"\\f";case`
3
3
  `:return"\\n";case"\r":return"\\r";case"\t":return"\\t";default:return`\\u${b.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function B(b){let f="",v=!1;for(let k=0;k<b.length;k++){let q=b[k];if(!v){if(f+=q,q==='"')v=!0;continue}if(q==='"'){f+=q,v=!1;continue}if(q==="\\"){let w=b[k+1];if(w===void 0){f+="\\\\";continue}if(w==="u"){let z=b.slice(k+2,k+6);if(/^[0-9a-fA-F]{4}$/.test(z)){f+=`\\u${z}`,k+=5;continue}}if(H.has(w)){f+=`\\${w}`,k+=1;continue}f+="\\\\";continue}f+=K(q)?Q(q):q}return f}function T(b){try{return JSON.parse(b)}catch(f){let v=B(b);if(v!==b)return JSON.parse(v);throw f}}function X(b){if(!b||b.trim()==="")return{};try{return T(b)}catch{try{return y.parse(b)??{}}catch{try{return y.parse(B(b))??{}}catch{return{}}}}}
4
- export{T as Dj,X as Ej};
4
+ export{T as We,X as Xe};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{wj as S,xj as T,yj as C}from"./chunk-29ectt6g.js";import"./chunk-a5kfa0k9.js";import{Aj as D}from"./chunk-fwe9g818.js";import{Cj as Z}from"./chunk-w4y97tzy.js";import"./chunk-1fpqq6ed.js";import"./chunk-yhj8c5re.js";import{Gj as k}from"./chunk-n296vcfw.js";import{Sj as f}from"./chunk-08m8mzfa.js";import{Wj as M,Xj as V}from"./chunk-3rajscaz.js";import"./chunk-eadb78m8.js";import"./chunk-kbzm1pwx.js";var j="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function K(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function g(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return K(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function B(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var I=(G,Q,w)=>{let W=new V;return(async()=>{let X=g(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Y=w?.apiKey;if(!Y)throw Error(`No API key for provider: ${G.provider}`);let $=z(G,Y,w),q=b(G,Q,w,X),F=await w?.onPayload?.(q,G);if(F!==void 0)q=F;let L={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},maxRetries:w?.maxRetries??0},{data:_,response:H}=await $.responses.create(q,L).withResponse();if(await w?.onResponse?.({status:H.status,headers:k(H.headers)},G),W.push({type:"start",partial:J}),await C(_,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=B(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},c=(G,Q,w)=>{let W=w?.apiKey;if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=f(G,w,W),J=w?.reasoning?M(G,w.reasoning):void 0;return I(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function P(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function O(G){return`https://${G}.openai.azure.com/openai/v1`}function h(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||j,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=O(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)throw Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:P(J),apiVersion:w}}function z(G,Q,w){let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=h(G,w);return new Z({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function b(G,Q,w,W){let X=S(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:D(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=T(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{c as streamSimpleAzureOpenAIResponses,I as streamAzureOpenAIResponses};
2
+ import{sk as S,tk as T,uk as C}from"./chunk-7hsgmjpa.js";import"./chunk-j8qtab70.js";import{wk as D}from"./chunk-5t6c3038.js";import{yk as Z}from"./chunk-9ab6k4rq.js";import"./chunk-zemrvz79.js";import"./chunk-bs0fjz3w.js";import{Ck as k}from"./chunk-4qpa7b5t.js";import{Ok as f}from"./chunk-re0b7sj7.js";import{Sk as M,Tk as V}from"./chunk-922nnh39.js";import"./chunk-9h027f50.js";import"./chunk-0qkj838r.js";var j="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function K(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function g(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return K(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function B(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var I=(G,Q,w)=>{let W=new V;return(async()=>{let X=g(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Y=w?.apiKey;if(!Y)throw Error(`No API key for provider: ${G.provider}`);let $=z(G,Y,w),q=b(G,Q,w,X),F=await w?.onPayload?.(q,G);if(F!==void 0)q=F;let L={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},maxRetries:w?.maxRetries??0},{data:_,response:H}=await $.responses.create(q,L).withResponse();if(await w?.onResponse?.({status:H.status,headers:k(H.headers)},G),W.push({type:"start",partial:J}),await C(_,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=B(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},c=(G,Q,w)=>{let W=w?.apiKey;if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=f(G,w,W),J=w?.reasoning?M(G,w.reasoning):void 0;return I(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function P(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function O(G){return`https://${G}.openai.azure.com/openai/v1`}function h(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||j,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=O(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)throw Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:P(J),apiVersion:w}}function z(G,Q,w){let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=h(G,w);return new Z({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function b(G,Q,w,W){let X=S(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:D(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=T(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{c as streamSimpleAzureOpenAIResponses,I as streamAzureOpenAIResponses};