@k2b/ui 0.54.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/browser/actions/Toolbar.js +16 -7
  2. package/dist/browser/actions/Toolbar.js.map +1 -1
  3. package/dist/browser/chat/ChatComposer.js +28 -27
  4. package/dist/browser/chat/ChatComposer.js.map +1 -1
  5. package/dist/browser/content/Lightbox.js +917 -283
  6. package/dist/browser/content/Lightbox.js.map +1 -1
  7. package/dist/browser/content/MapDialog.js +686 -0
  8. package/dist/browser/content/MapDialog.js.map +1 -0
  9. package/dist/browser/content/MapTile.js +139 -0
  10. package/dist/browser/content/MapTile.js.map +1 -0
  11. package/dist/browser/content/MapView.js +19 -8
  12. package/dist/browser/content/MapView.js.map +1 -1
  13. package/dist/browser/content/PdfPages.js +9 -4
  14. package/dist/browser/content/PdfPages.js.map +1 -1
  15. package/dist/browser/content/PdfThumbnails.js +271 -0
  16. package/dist/browser/content/PdfThumbnails.js.map +1 -0
  17. package/dist/browser/content/PdfViewer.js +11 -3
  18. package/dist/browser/content/PdfViewer.js.map +1 -1
  19. package/dist/browser/content/Timeline.js +116 -117
  20. package/dist/browser/content/Timeline.js.map +1 -1
  21. package/dist/browser/content/code-highlight.js +24 -11
  22. package/dist/browser/content/code-highlight.js.map +1 -1
  23. package/dist/browser/content/index.js +8 -1
  24. package/dist/browser/content/index.js.map +1 -1
  25. package/dist/browser/content/lightbox-messages.js +64 -18
  26. package/dist/browser/content/lightbox-messages.js.map +1 -1
  27. package/dist/browser/content/lightbox-renderers.js +6 -0
  28. package/dist/browser/content/lightbox-renderers.js.map +1 -0
  29. package/dist/browser/content/map-dialog-messages.js +47 -0
  30. package/dist/browser/content/map-dialog-messages.js.map +1 -0
  31. package/dist/browser/content/map-navigation.js +15 -0
  32. package/dist/browser/content/map-navigation.js.map +1 -0
  33. package/dist/browser/content/map-view-messages.js +4 -0
  34. package/dist/browser/content/map-view-messages.js.map +1 -1
  35. package/dist/browser/content/map-view-types.js.map +1 -1
  36. package/dist/browser/content/map-view-worker.js +3 -3
  37. package/dist/browser/content/pdf-messages.js +16 -2
  38. package/dist/browser/content/pdf-messages.js.map +1 -1
  39. package/dist/browser/content/pdf-viewer-engine.js +15 -15
  40. package/dist/browser/content/pdf-viewer-worker.js +4 -5
  41. package/dist/browser/feedback/dialog-core.js +21 -9
  42. package/dist/browser/feedback/dialog-core.js.map +1 -1
  43. package/dist/browser/feedback/prompt-confirm.js +2 -0
  44. package/dist/browser/feedback/prompt-confirm.js.map +1 -1
  45. package/dist/browser/internal/truncated-title.js +9 -0
  46. package/dist/browser/internal/truncated-title.js.map +1 -0
  47. package/dist/browser/layout/Breadcrumbs.js +97 -0
  48. package/dist/browser/layout/Breadcrumbs.js.map +1 -0
  49. package/dist/browser/layout/DetailPanel.js +3 -5
  50. package/dist/browser/layout/DetailPanel.js.map +1 -1
  51. package/dist/browser/layout/PanelDialog.js +3 -1
  52. package/dist/browser/layout/PanelDialog.js.map +1 -1
  53. package/dist/browser/layout/index.js +1 -0
  54. package/dist/browser/layout/index.js.map +1 -1
  55. package/dist/browser/surfaces/Skeleton.js +32 -0
  56. package/dist/browser/surfaces/Skeleton.js.map +1 -1
  57. package/dist/browser/surfaces/index.js +1 -1
  58. package/dist/browser/surfaces/index.js.map +1 -1
  59. package/dist/ssr/actions/CommandMenu.js +2 -2
  60. package/dist/ssr/actions/CommandMenu.js.map +1 -1
  61. package/dist/ssr/actions/Toolbar.js +16 -7
  62. package/dist/ssr/actions/Toolbar.js.map +1 -1
  63. package/dist/ssr/chat/ChatComposer.js +31 -30
  64. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  65. package/dist/ssr/content/Lightbox.js +659 -150
  66. package/dist/ssr/content/Lightbox.js.map +1 -1
  67. package/dist/ssr/content/MapDialog.js +469 -0
  68. package/dist/ssr/content/MapDialog.js.map +1 -0
  69. package/dist/ssr/content/MapTile.js +92 -0
  70. package/dist/ssr/content/MapTile.js.map +1 -0
  71. package/dist/ssr/content/MapView.js +12 -8
  72. package/dist/ssr/content/MapView.js.map +1 -1
  73. package/dist/ssr/content/PdfPages.js +9 -4
  74. package/dist/ssr/content/PdfPages.js.map +1 -1
  75. package/dist/ssr/content/PdfThumbnails.js +189 -0
  76. package/dist/ssr/content/PdfThumbnails.js.map +1 -0
  77. package/dist/ssr/content/PdfViewer.js +11 -3
  78. package/dist/ssr/content/PdfViewer.js.map +1 -1
  79. package/dist/ssr/content/Timeline.js +2 -5
  80. package/dist/ssr/content/Timeline.js.map +1 -1
  81. package/dist/ssr/content/code-highlight.js +24 -11
  82. package/dist/ssr/content/code-highlight.js.map +1 -1
  83. package/dist/ssr/content/index.js +8 -1
  84. package/dist/ssr/content/index.js.map +1 -1
  85. package/dist/ssr/content/lightbox-messages.js +64 -18
  86. package/dist/ssr/content/lightbox-messages.js.map +1 -1
  87. package/dist/ssr/content/lightbox-renderers.js +6 -0
  88. package/dist/ssr/content/lightbox-renderers.js.map +1 -0
  89. package/dist/ssr/content/map-dialog-messages.js +47 -0
  90. package/dist/ssr/content/map-dialog-messages.js.map +1 -0
  91. package/dist/ssr/content/map-navigation.js +15 -0
  92. package/dist/ssr/content/map-navigation.js.map +1 -0
  93. package/dist/ssr/content/map-view-messages.js +4 -0
  94. package/dist/ssr/content/map-view-messages.js.map +1 -1
  95. package/dist/ssr/content/map-view-types.js.map +1 -1
  96. package/dist/ssr/content/pdf-messages.js +16 -2
  97. package/dist/ssr/content/pdf-messages.js.map +1 -1
  98. package/dist/ssr/feedback/dialog-core.js +21 -9
  99. package/dist/ssr/feedback/dialog-core.js.map +1 -1
  100. package/dist/ssr/feedback/prompt-confirm.js +1 -0
  101. package/dist/ssr/feedback/prompt-confirm.js.map +1 -1
  102. package/dist/ssr/inputs/ChoiceInputs.js +2 -2
  103. package/dist/ssr/inputs/ChoiceInputs.js.map +1 -1
  104. package/dist/ssr/inputs/SignatureInput.js +2 -2
  105. package/dist/ssr/inputs/SignatureInput.js.map +1 -1
  106. package/dist/ssr/inputs/markdown/SlashCommands.js +2 -2
  107. package/dist/ssr/inputs/markdown/SlashCommands.js.map +1 -1
  108. package/dist/ssr/internal/truncated-title.js +9 -0
  109. package/dist/ssr/internal/truncated-title.js.map +1 -0
  110. package/dist/ssr/layout/Breadcrumbs.js +62 -0
  111. package/dist/ssr/layout/Breadcrumbs.js.map +1 -0
  112. package/dist/ssr/layout/DetailPanel.js +1 -4
  113. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  114. package/dist/ssr/layout/PanelDialog.js +1 -0
  115. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  116. package/dist/ssr/layout/index.js +1 -0
  117. package/dist/ssr/layout/index.js.map +1 -1
  118. package/dist/ssr/surfaces/Skeleton.js +32 -0
  119. package/dist/ssr/surfaces/Skeleton.js.map +1 -1
  120. package/dist/ssr/surfaces/index.js +1 -1
  121. package/dist/ssr/surfaces/index.js.map +1 -1
  122. package/dist/styles.css +1 -1
  123. package/dist/types/actions/Toolbar.d.ts +6 -0
  124. package/dist/types/chat/ChatComposer.d.ts +1 -0
  125. package/dist/types/content/Lightbox.d.ts +54 -14
  126. package/dist/types/content/MapDialog.d.ts +105 -0
  127. package/dist/types/content/MapTile.d.ts +37 -0
  128. package/dist/types/content/PdfPages.d.ts +7 -1
  129. package/dist/types/content/PdfThumbnails.d.ts +26 -0
  130. package/dist/types/content/PdfViewer.d.ts +12 -3
  131. package/dist/types/content/index.d.ts +7 -2
  132. package/dist/types/content/lightbox-messages.d.ts +31 -8
  133. package/dist/types/content/lightbox-renderers.d.ts +3 -0
  134. package/dist/types/content/map-dialog-messages.d.ts +19 -0
  135. package/dist/types/content/map-navigation.d.ts +13 -0
  136. package/dist/types/content/map-view-messages.d.ts +2 -0
  137. package/dist/types/content/map-view-types.d.ts +5 -0
  138. package/dist/types/content/pdf-messages.d.ts +7 -0
  139. package/dist/types/feedback/dialog-core.d.ts +6 -0
  140. package/dist/types/internal/truncated-title.d.ts +7 -0
  141. package/dist/types/layout/Breadcrumbs.d.ts +19 -0
  142. package/dist/types/layout/index.d.ts +1 -0
  143. package/dist/types/surfaces/Skeleton.d.ts +13 -1
  144. package/dist/types/surfaces/index.d.ts +1 -1
  145. package/package.json +20 -20
@@ -1,7 +1,7 @@
1
- var Zr={9306(t,e,s){var i=s(4901),n=s(6823),r=TypeError;t.exports=function(a){if(i(a))return a;throw new r(n(a)+" is not a function")}},3506(t,e,s){var i=s(3925),n=String,r=TypeError;t.exports=function(a){if(i(a))return a;throw new r("Can't set "+n(a)+" as a prototype")}},7080(t,e,s){var i=s(4402).has;t.exports=function(n){return i(n),n}},3463(t){var e=TypeError;t.exports=function(s){if(typeof s=="string")return s;throw new e("Argument is not a string")}},4328(t,e,s){var i=s(4995),n=new i.WeakMap,{set:r,remove:a}=i;t.exports=function(o){return r(n,o,1),a(n,o),o}},6557(t,e,s){var i=s(4995).has;t.exports=function(n){return i(n),n}},6469(t,e,s){var i=s(8227),n=s(2360),r=s(4913).f,a=i("unscopables"),o=Array.prototype;if(o[a]===void 0)r(o,a,{configurable:!0,value:n(null)});t.exports=function(l){o[a][l]=!0}},679(t,e,s){var i=s(1625),n=TypeError;t.exports=function(r,a){if(i(a,r))return r;throw new n("Incorrect invocation")}},3972(t,e,s){var i=s(34),n=String,r=TypeError;t.exports=function(a){if(a===void 0||i(a))return a;throw new r(n(a)+" is not an object or undefined")}},8551(t,e,s){var i=s(34),n=String,r=TypeError;t.exports=function(a){if(i(a))return a;throw new r(n(a)+" is not an object")}},4154(t,e,s){var i=s(6955),n=TypeError;t.exports=function(r){if(i(r)==="Uint8Array")return r;throw new n("Argument is not an Uint8Array")}},7811(t){t.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"},7394(t,e,s){var i=s(4576),n=s(6706),r=s(2195),{ArrayBuffer:a,TypeError:o}=i;t.exports=a&&n(a.prototype,"byteLength","get")||function(l){if(r(l)!=="ArrayBuffer")throw new o("ArrayBuffer expected");return l.byteLength}},3238(t,e,s){var i=s(4576),n=s(7811),r=s(7394),a=i.DataView;t.exports=function(o){if(!n||r(o)!==0)return!1;try{return new a(o),!1}catch(l){return!0}}},5169(t,e,s){var i=s(3238),n=TypeError;t.exports=function(r){if(i(r))throw new n("ArrayBuffer is detached");return r}},4644(t,e,s){var i=s(7811),n=s(3724),r=s(4576),a=s(4901),o=s(34),l=s(9297),h=s(6955),c=s(6823),d=s(6699),u=s(6840),f=s(2106),p=s(1625),g=s(2787),m=s(2967),v=s(8227),y=s(3392),S=s(1181),{enforce:A,get:b}=S,w=r.Int8Array,x=w&&w.prototype,T=r.Uint8ClampedArray,E=T&&T.prototype,I=w&&g(w),C=x&&g(x),O=Object.prototype,D=r.TypeError,k=v("toStringTag"),R=y("TYPED_ARRAY_TAG"),M="TypedArrayConstructor",_=i&&!!m&&h(r.opera)!=="Opera",U=!1,G,it,rt,J={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},et={BigInt64Array:8,BigUint64Array:8},ht=function(Z){if(!o(Z))return!1;var lt=h(Z);return lt==="DataView"||l(J,lt)||l(et,lt)},Rt=function(V){var Z=g(V);if(!o(Z))return;var lt=b(Z);return lt&&l(lt,M)?lt[M]:Rt(Z)},N=function(V){if(!o(V))return!1;var Z=h(V);return l(J,Z)||l(et,Z)},P=function(V){if(N(V))return V;throw new D("Target is not a typed array")},F=function(V){if(a(V)&&(!m||p(I,V)))return V;throw new D(c(V)+" is not a typed array constructor")},X=function(V,Z,lt,xt){if(!n)return;if(lt)for(var Et in J){var vt=r[Et];if(vt&&l(vt.prototype,V))try{delete vt.prototype[V]}catch($t){try{vt.prototype[V]=Z}catch(Me){}}}if(!C[V]||lt)u(C,V,lt?Z:_&&x[V]||Z,xt)},nt=function(V,Z,lt){var xt,Et;if(!n)return;if(m){if(lt){for(xt in J)if(Et=r[xt],Et&&l(Et,V))try{delete Et[V]}catch(vt){}}if(!I[V]||lt)try{return u(I,V,lt?Z:_&&I[V]||Z)}catch(vt){}else return}for(xt in J)if(Et=r[xt],Et&&(!Et[V]||lt))u(Et,V,Z)};for(G in J)if(it=r[G],rt=it&&it.prototype,rt)A(rt)[M]=it;else _=!1;for(G in et)if(it=r[G],rt=it&&it.prototype,rt)A(rt)[M]=it;if(!_||!a(I)||I===Function.prototype){if(I=function(){throw new D("Incorrect invocation")},_){for(G in J)if(r[G])m(r[G],I)}}if(!_||!C||C===O){if(C=I.prototype,_){for(G in J)if(r[G])m(r[G].prototype,C)}}if(_&&g(E)!==C)m(E,C);if(n&&!l(C,k)){U=!0,f(C,k,{configurable:!0,get:function(){return o(this)?this[R]:void 0}});for(G in J)if(r[G])d(r[G].prototype,R,G)}t.exports={NATIVE_ARRAY_BUFFER_VIEWS:_,TYPED_ARRAY_TAG:U&&R,aTypedArray:P,aTypedArrayConstructor:F,exportTypedArrayMethod:X,exportTypedArrayStaticMethod:nt,getTypedArrayConstructor:Rt,isView:ht,isTypedArray:N,TypedArray:I,TypedArrayPrototype:C}},5370(t,e,s){var i=s(6198);t.exports=function(n,r,a){var o=0,l=arguments.length>2?a:i(r),h=new n(l);while(l>o)h[o]=r[o++];return h}},9617(t,e,s){var i=s(5397),n=s(5610),r=s(6198),a=function(o){return function(l,h,c){var d=i(l),u=r(d);if(u===0)return!o&&-1;var f=n(c,u),p;if(o&&h!==h){while(u>f)if(p=d[f++],p!==p)return!0}else for(;u>f;f++)if((o||(f in d))&&d[f]===h)return o||f||0;return!o&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},4527(t,e,s){var i=s(3724),n=s(4376),r=TypeError,a=Object.getOwnPropertyDescriptor,o=i&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(l){return l instanceof TypeError}}();t.exports=o?function(l,h){if(n(l)&&!a(l,"length").writable)throw new r("Cannot set read only .length");return l.length=h}:function(l,h){return l.length=h}},7680(t,e,s){var i=s(9504);t.exports=i([].slice)},2804(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=e+"+/",i=e+"-_",n=function(r){var a={},o=0;for(;o<64;o++)a[r.charAt(o)]=o;return a};t.exports={i2c:s,c2i:n(s),i2cUrl:i,c2iUrl:n(i)}},6319(t,e,s){var i=s(8551),n=s(9539);t.exports=function(r,a,o,l){try{return l?a(i(o)[0],o[1]):a(o)}catch(h){n(r,"throw",h)}}},2195(t,e,s){var i=s(9504),n=i({}.toString),r=i("".slice);t.exports=function(a){return r(n(a),8,-1)}},6955(t,e,s){var i=s(2140),n=s(4901),r=s(2195),a=s(8227),o=a("toStringTag"),l=Object,h=r(function(){return arguments}())==="Arguments",c=function(d,u){try{return d[u]}catch(f){}};t.exports=i?r:function(d){var u,f,p;return d===void 0?"Undefined":d===null?"Null":typeof(f=c(u=l(d),o))=="string"?f:h?r(u):(p=r(u))==="Object"&&n(u.callee)?"Arguments":p}},7740(t,e,s){var i=s(9297),n=s(5031),r=s(7347),a=s(4913);t.exports=function(o,l,h){var c=n(l),d=a.f,u=r.f;for(var f=0;f<c.length;f++){var p=c[f];if(!i(o,p)&&!(h&&i(h,p)))d(o,p,u(l,p))}}},2211(t,e,s){var i=s(9039);t.exports=!i(function(){function n(){}return n.prototype.constructor=null,Object.getPrototypeOf(new n)!==n.prototype})},2529(t){t.exports=function(e,s){return{value:e,done:s}}},6699(t,e,s){var i=s(3724),n=s(4913),r=s(6980);t.exports=i?function(a,o,l){return n.f(a,o,r(1,l))}:function(a,o,l){return a[o]=l,a}},6980(t){t.exports=function(e,s){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:s}}},4659(t,e,s){var i=s(3724),n=s(4913),r=s(6980);t.exports=function(a,o,l){if(i)n.f(a,o,r(0,l));else a[o]=l}},2106(t,e,s){var i=s(283),n=s(4913);t.exports=function(r,a,o){if(o.get)i(o.get,a,{getter:!0});if(o.set)i(o.set,a,{setter:!0});return n.f(r,a,o)}},6840(t,e,s){var i=s(4901),n=s(4913),r=s(283),a=s(9433);t.exports=function(o,l,h,c){if(!c)c={};var d=c.enumerable,u=c.name!==void 0?c.name:l;if(i(h))r(h,u,c);if(c.global)if(d)o[l]=h;else a(l,h);else{try{if(!c.unsafe)delete o[l];else if(o[l])d=!0}catch(f){}if(d)o[l]=h;else n.f(o,l,{value:h,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return o}},6279(t,e,s){var i=s(6840);t.exports=function(n,r,a){for(var o in r)i(n,o,r[o],a);return n}},9433(t,e,s){var i=s(4576),n=Object.defineProperty;t.exports=function(r,a){try{n(i,r,{value:a,configurable:!0,writable:!0})}catch(o){i[r]=a}return a}},3724(t,e,s){var i=s(9039);t.exports=!i(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},4055(t,e,s){var i=s(4576),n=s(34),r=i.document,a=n(r)&&n(r.createElement);t.exports=function(o){return a?r.createElement(o):{}}},6837(t){var e=TypeError,s=9007199254740991;t.exports=function(i){if(i>s)throw new e("Maximum allowed index exceeded");return i}},5002(t){t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8727(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2839(t,e,s){var i=s(4576),n=i.navigator,r=n&&n.userAgent;t.exports=r?String(r):""},9519(t,e,s){var i=s(4576),n=s(2839),{process:r,Deno:a}=i,o=r&&r.versions||a&&a.version,l=o&&o.v8,h,c;if(l)h=l.split("."),c=h[0]>0&&h[0]<4?1:+(h[0]+h[1]);if(!c&&n){if(h=n.match(/Edge\/(\d+)/),!h||h[1]>=74){if(h=n.match(/Chrome\/(\d+)/),h)c=+h[1]}}t.exports=c},6193(t,e,s){var i=s(9504),n=Error,r=i("".replace),a=function(h){return String(new n(h).stack)}("zxcasd"),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(a);t.exports=function(h,c){if(l&&typeof h=="string"&&!n.prepareStackTrace)while(c--)h=r(h,o,"");return h}},6518(t,e,s){var i=s(4576),n=s(7347).f,r=s(6699),a=s(6840),o=s(9433),l=s(7740),h=s(2796);t.exports=function(c,d){var{target:u,global:f,stat:p}=c,g,m,v,y,S,A;if(f)m=i;else if(p)m=i[u]||o(u,{});else m=i[u]&&i[u].prototype;if(m)for(v in d){if(S=d[v],c.dontCallGetSet)A=n(m,v),y=A&&A.value;else y=m[v];if(g=h(f?v:u+(p?".":"#")+v,c.forced),!g&&y!==void 0){if(typeof S==typeof y)continue;l(S,y)}if(c.sham||y&&y.sham)r(S,"sham",!0);a(m,v,S,c)}}},9039(t){t.exports=function(e){try{return!!e()}catch(s){return!0}}},8745(t,e,s){var i=s(616),n=Function.prototype,{apply:r,call:a}=n;t.exports=typeof Reflect=="object"&&Reflect.apply||(i?a.bind(r):function(){return a.apply(r,arguments)})},6080(t,e,s){var i=s(7476),n=s(9306),r=s(616),a=i(i.bind);t.exports=function(o,l){return n(o),l===void 0?o:r?a(o,l):function(){return o.apply(l,arguments)}}},616(t,e,s){var i=s(9039);t.exports=!i(function(){var n=function(){}.bind();return typeof n!="function"||n.hasOwnProperty("prototype")})},9565(t,e,s){var i=s(616),n=Function.prototype.call;t.exports=i?n.bind(n):function(){return n.apply(n,arguments)}},350(t,e,s){var i=s(3724),n=s(9297),r=Function.prototype,a=i&&Object.getOwnPropertyDescriptor,o=n(r,"name"),l=o&&function(){}.name==="something",h=o&&(!i||i&&a(r,"name").configurable);t.exports={EXISTS:o,PROPER:l,CONFIGURABLE:h}},6706(t,e,s){var i=s(9504),n=s(9306);t.exports=function(r,a,o){try{return i(n(Object.getOwnPropertyDescriptor(r,a)[o]))}catch(l){}}},7476(t,e,s){var i=s(2195),n=s(9504);t.exports=function(r){if(i(r)==="Function")return n(r)}},9504(t,e,s){var i=s(616),n=Function.prototype,r=n.call,a=i&&n.bind.bind(r,r);t.exports=i?a:function(o){return function(){return r.apply(o,arguments)}}},944(t){var e=TypeError;t.exports=function(s){var i=s&&s.alphabet;if(i===void 0||i==="base64"||i==="base64url")return i||"base64";throw new e("Incorrect `alphabet` option")}},7751(t,e,s){var i=s(4576),n=s(4901),r=function(a){return n(a)?a:void 0};t.exports=function(a,o){return arguments.length<2?r(i[a]):i[a]&&i[a][o]}},1767(t){t.exports=function(e){return{iterator:e,next:e.next,done:!1}}},8646(t,e,s){var i=s(9565),n=s(8551),r=s(1767),a=s(3085);t.exports=function(o,l){if(!l||typeof o!=="string")n(o);var h=a(o);return r(n(h!==void 0?i(h,o):o))}},8563(t,e,s){var i=s(9565),n=s(4901),r=s(8551),a=s(6823),o=s(3085),l=TypeError;t.exports=function(h,c){var d=arguments.length<2?o(h):c;if(n(d))return r(i(d,h));throw new l(a(h)+" is not iterable")}},3085(t,e,s){var i=s(2195),n=s(4117),r=s(5966),a=s(8227),o=a("iterator"),l=Array.prototype;t.exports=function(h){if(!n(h))return r(h,o)||r(h,"@@iterator")||(i(h)==="Arguments"?l[o]:void 0)}},5966(t,e,s){var i=s(9306),n=s(4117);t.exports=function(r,a){var o=r[a];return n(o)?void 0:i(o)}},3789(t,e,s){var i=s(9306),n=s(8551),r=s(9565),a=s(1291),o=s(1767),l="Invalid size",h=RangeError,c=TypeError,d=Math.max,u=function(f,p){this.set=f,this.size=d(p,0),this.has=i(f.has),this.keys=i(f.keys)};u.prototype={getIterator:function(){return o(n(r(this.keys,this.set)))},includes:function(f){return r(this.has,this.set,f)}},t.exports=function(f){n(f);var p=+f.size;if(p!==p)throw new c(l);var g=a(p);if(g<0)throw new h(l);return new u(f,g)}},4576(t){var e=function(s){return s&&s.Math===Math&&s};t.exports=e(typeof globalThis=="object"&&globalThis)||e(typeof window=="object"&&window)||e(typeof self=="object"&&self)||e(typeof global=="object"&&global)||e(typeof this=="object"&&this)||function(){return this}()||Function("return this")()},9297(t,e,s){var i=s(9504),n=s(8981),r=i({}.hasOwnProperty);t.exports=Object.hasOwn||function(o,l){return r(n(o),l)}},421(t){t.exports={}},397(t,e,s){var i=s(7751);t.exports=i("document","documentElement")},5917(t,e,s){var i=s(3724),n=s(9039),r=s(4055);t.exports=!i&&!n(function(){return Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a!==7})},7055(t,e,s){var i=s(9504),n=s(9039),r=s(2195),a=Object,o=i("".split);t.exports=n(function(){return!a("z").propertyIsEnumerable(0)})?function(l){return r(l)==="String"?o(l,""):a(l)}:a},3167(t,e,s){var i=s(4901),n=s(34),r=s(2967);t.exports=function(a,o,l){var h,c;if(r&&i(h=o.constructor)&&h!==l&&n(c=h.prototype)&&c!==l.prototype)r(a,c);return a}},3706(t,e,s){var i=s(9504),n=s(4901),r=s(7629),a=i(Function.toString);if(!n(r.inspectSource))r.inspectSource=function(o){return a(o)};t.exports=r.inspectSource},1181(t,e,s){var i=s(8622),n=s(4576),r=s(34),a=s(6699),o=s(9297),l=s(7629),h=s(6119),c=s(421),d="Object already initialized",{TypeError:u,WeakMap:f}=n,p,g,m,v=function(b){return m(b)?g(b):p(b,{})},y=function(b){return function(w){var x;if(!r(w)||(x=g(w)).type!==b)throw new u("Incompatible receiver, "+b+" required");return x}};if(i||l.state){var S=l.state||(l.state=new f);S.get=S.get,S.has=S.has,S.set=S.set,p=function(b,w){if(S.has(b))throw new u(d);return w.facade=b,S.set(b,w),w},g=function(b){return S.get(b)||{}},m=function(b){return S.has(b)}}else{var A=h("state");c[A]=!0,p=function(b,w){if(o(b,A))throw new u(d);return w.facade=b,a(b,A,w),w},g=function(b){return o(b,A)?b[A]:{}},m=function(b){return o(b,A)}}t.exports={set:p,get:g,has:m,enforce:v,getterFor:y}},4209(t,e,s){var i=s(8227),n=s(6269),r=i("iterator"),a=Array.prototype;t.exports=function(o){return o!==void 0&&(n.Array===o||a[r]===o)}},4376(t,e,s){var i=s(2195);t.exports=Array.isArray||function(r){return i(r)==="Array"}},1108(t,e,s){var i=s(6955);t.exports=function(n){var r=i(n);return r==="BigInt64Array"||r==="BigUint64Array"}},4901(t){var e=typeof document=="object"&&document.all;t.exports=typeof e>"u"&&e!==void 0?function(s){return typeof s=="function"||s===e}:function(s){return typeof s=="function"}},2796(t,e,s){var i=s(9039),n=s(4901),r=/#|\.prototype\./,a=function(d,u){var f=l[o(d)];return f===c?!0:f===h?!1:n(u)?i(u):!!u},o=a.normalize=function(d){return String(d).replace(r,".").toLowerCase()},l=a.data={},h=a.NATIVE="N",c=a.POLYFILL="P";t.exports=a},4117(t){t.exports=function(e){return e===null||e===void 0}},34(t,e,s){var i=s(4901);t.exports=function(n){return typeof n=="object"?n!==null:i(n)}},3925(t,e,s){var i=s(34);t.exports=function(n){return i(n)||n===null}},6395(t){t.exports=!1},5810(t,e,s){var i=s(34),n=s(1181).get;t.exports=function(a){if(!i(a))return!1;var o=n(a);return!!o&&o.type==="RawJSON"}},757(t,e,s){var i=s(7751),n=s(4901),r=s(1625),a=s(7040),o=Object;t.exports=a?function(l){return typeof l=="symbol"}:function(l){var h=i("Symbol");return n(h)&&r(h.prototype,o(l))}},507(t,e,s){var i=s(9565);t.exports=function(n,r,a){var o=a?n:n.iterator,l=n.next,h,c;while(!(h=i(l,o)).done)if(c=r(h.value),c!==void 0)return c}},2652(t,e,s){var i=s(6080),n=s(9565),r=s(8551),a=s(6823),o=s(4209),l=s(6198),h=s(1625),c=s(8563),d=s(3085),u=s(9539),f=TypeError,p=function(m,v){this.stopped=m,this.result=v},g=p.prototype;t.exports=function(m,v,y){var S=y&&y.that,A=!!(y&&y.AS_ENTRIES),b=!!(y&&y.IS_RECORD),w=!!(y&&y.IS_ITERATOR),x=!!(y&&y.INTERRUPTED),T=i(v,S),E,I,C,O,D,k,R,M=function(G){var it=E;if(E=void 0,it)u(it,"normal");return new p(!0,G)},_=function(G){if(A)return r(G),x?T(G[0],G[1],M):T(G[0],G[1]);return x?T(G,M):T(G)};if(b)E=m.iterator;else if(w)E=m;else{if(I=d(m),!I)throw new f(a(m)+" is not iterable");if(o(I)){for(C=0,O=l(m);O>C;C++)if(D=_(m[C]),D&&h(g,D))return D;return new p(!1)}E=c(m,I)}k=b?m.next:E.next;while(!(R=n(k,E)).done){var U=R.value;try{D=_(U)}catch(G){if(E)u(E,"throw",G);else throw G}if(typeof D=="object"&&D&&h(g,D))return D}return new p(!1)}},6859(t){t.exports=function(e){e.iterator=e.next=e.nextHandler=e.mapper=e.predicate=e.inner=e.iterables=e.iters=e.openIters=e.padding=e.finishResults=e.buffer=null}},1385(t,e,s){var i=s(9539);t.exports=function(n,r,a){for(var o=n.length-1;o>=0;o--){if(n[o]===void 0)continue;try{a=i(n[o].iterator,r,a)}catch(l){r="throw",a=l}}if(r==="throw")throw a;return a}},9539(t,e,s){var i=s(9565),n=s(8551),r=s(5966);t.exports=function(a,o,l){var h,c;n(a);try{if(h=r(a,"return"),!h){if(o==="throw")throw l;return l}h=i(h,a)}catch(d){c=!0,h=d}if(o==="throw")throw l;if(c)throw h;return n(h),l}},9462(t,e,s){var i=s(9565),n=s(2360),r=s(6699),a=s(6279),o=s(8227),l=s(1181),h=s(5966),c=s(7657).IteratorPrototype,d=s(2529),u=s(9539),f=s(1385),p=s(6859),g=o("toStringTag"),m="IteratorHelper",v="WrapForValidIterator",y="normal",S="throw",A=l.set,b=function(T){var E=l.getterFor(T?v:m);return a(n(c),{next:function(){var C=E(this);if(T)return C.nextHandler();if(C.done)return d(void 0,!0);try{var O=C.nextHandler();if(C.done)p(C);return C.returnHandlerResult?O:d(O,C.done)}catch(D){throw C.done=!0,p(C),D}},return:function(){var I=E(this),{iterator:C,inner:O,openIters:D,done:k}=I;if(I.done=!0,T){var R=h(C,"return");return R?i(R,C):d(void 0,!0)}if(p(I),k)return d(void 0,!0);if(O)try{u(O.iterator,y)}catch(M){return u(C,S,M)}if(D)try{f(D,y)}catch(M){if(C)return u(C,S,M);throw M}if(C)u(C,y);return d(void 0,!0)}})},w=b(!0),x=b(!1);r(x,g,"Iterator Helper"),t.exports=function(T,E,I){var C=function(D,k){if(k)k.iterator=D.iterator,k.next=D.next;else k=D;k.type=E?v:m,k.returnHandlerResult=!!I,k.nextHandler=T,k.counter=0,k.done=!1,A(this,k)};return C.prototype=E?w:x,C}},684(t){t.exports=function(e,s){var i=typeof Iterator=="function"&&Iterator.prototype[e];if(i)try{i.call({next:null},s).next()}catch(n){return!0}}},4549(t,e,s){var i=s(4576);t.exports=function(n,r){var a=i.Iterator,o=a&&a.prototype,l=o&&o[n],h=!1;if(l)try{l.call({next:function(){return{done:!0}},return:function(){h=!0}},-1)}catch(c){if(!(c instanceof r))h=!1}if(!h)return l}},7657(t,e,s){var i=s(9039),n=s(4901),r=s(34),a=s(2360),o=s(2787),l=s(6840),h=s(8227),c=s(6395),d=h("iterator"),u=!1,f,p,g;if([].keys){if(g=[].keys(),!("next"in g))u=!0;else if(p=o(o(g)),p!==Object.prototype)f=p}var m=!r(f)||i(function(){var v={};return f[d].call(v)!==v});if(m)f={};else if(c)f=a(f);if(!n(f[d]))l(f,d,function(){return this});t.exports={IteratorPrototype:f,BUGGY_SAFARI_ITERATORS:u}},6269(t){t.exports=Object.create?Object.create(null):{}},6198(t,e,s){var i=s(8014);t.exports=function(n){return i(n.length)}},283(t,e,s){var i=s(9504),n=s(9039),r=s(4901),a=s(9297),o=s(3724),l=s(350).CONFIGURABLE,h=s(3706),c=s(1181),{enforce:d,get:u}=c,f=String,p=Object.defineProperty,g=i("".slice),m=i("".replace),v=i([].join),y=o&&!n(function(){return p(function(){},"length",{value:8}).length!==8}),S=String(String).split("String"),A=t.exports=function(b,w,x){if(g(f(w),0,7)==="Symbol(")w="["+m(f(w),/^Symbol\(([^)]*)\).*$/,"$1")+"]";if(x&&x.getter)w="get "+w;if(x&&x.setter)w="set "+w;if(!a(b,"name")||l&&b.name!==w)if(o)p(b,"name",{value:w,configurable:!0});else b.name=w;if(y&&x&&a(x,"arity")&&b.length!==x.arity)p(b,"length",{value:x.arity});try{if(x&&a(x,"constructor")&&x.constructor){if(o)p(b,"prototype",{writable:!1})}else if(b.prototype)b.prototype=void 0}catch(E){}var T=d(b);if(!a(T,"source"))T.source=v(S,typeof w=="string"?w:"");return b};Function.prototype.toString=A(function(){return r(this)&&u(this).source||h(this)},"toString")},2248(t,e,s){var i=s(9504),n=Map.prototype;t.exports={Map,set:i(n.set),get:i(n.get),has:i(n.has),remove:i(n.delete),proto:n}},741(t){var{ceil:e,floor:s}=Math;t.exports=Math.trunc||function(n){var r=+n;return(r>0?s:e)(r)}},7819(t,e,s){var i=s(9039);t.exports=!i(function(){var n="9007199254740993",r=JSON.rawJSON(n);return!JSON.isRawJSON(r)||JSON.stringify(r)!==n})},6043(t,e,s){var i=s(9306),n=TypeError,r=function(a){var o,l;this.promise=new a(function(h,c){if(o!==void 0||l!==void 0)throw new n("Bad Promise constructor");o=h,l=c}),this.resolve=i(o),this.reject=i(l)};t.exports.f=function(a){return new r(a)}},2603(t,e,s){var i=s(655);t.exports=function(n,r){return n===void 0?arguments.length<2?"":r:i(n)}},4149(t){var e=RangeError;t.exports=function(s){if(s===s)return s;throw new e("NaN is not allowed")}},2360(t,e,s){var i=s(8551),n=s(6801),r=s(8727),a=s(421),o=s(397),l=s(4055),h=s(6119),c=">",d="<",u="prototype",f="script",p=h("IE_PROTO"),g=function(){},m=function(b){return d+f+c+b+d+"/"+f+c},v=function(b){b.write(m("")),b.close();var w=b.parentWindow.Object;return b=null,w},y=function(){var b=l("iframe"),w="java"+f+":",x;return b.style.display="none",o.appendChild(b),b.src=String(w),x=b.contentWindow.document,x.open(),x.write(m("document.F=Object")),x.close(),x.F},S,A=function(){try{S=new ActiveXObject("htmlfile")}catch(w){}A=typeof document<"u"?document.domain&&S?v(S):y():v(S);var b=r.length;while(b--)delete A[u][r[b]];return A()};a[p]=!0,t.exports=Object.create||function(w,x){var T;if(w!==null)g[u]=i(w),T=new g,g[u]=null,T[p]=w;else T=A();return x===void 0?T:n.f(T,x)}},6801(t,e,s){var i=s(3724),n=s(8686),r=s(4913),a=s(8551),o=s(5397),l=s(1072);e.f=i&&!n?Object.defineProperties:function(c,d){a(c);var u=o(d),f=l(d),p=f.length,g=0,m;while(p>g)r.f(c,m=f[g++],u[m]);return c}},4913(t,e,s){var i=s(3724),n=s(5917),r=s(8686),a=s(8551),o=s(6969),l=TypeError,{defineProperty:h,getOwnPropertyDescriptor:c}=Object,d="enumerable",u="configurable",f="writable";e.f=i?r?function(g,m,v){if(a(g),m=o(m),a(v),typeof g==="function"&&m==="prototype"&&"value"in v&&f in v&&!v[f]){var y=c(g,m);if(y&&y[f])g[m]=v.value,v={configurable:u in v?v[u]:y[u],enumerable:d in v?v[d]:y[d],writable:!1}}return h(g,m,v)}:h:function(g,m,v){if(a(g),m=o(m),a(v),n)try{return h(g,m,v)}catch(y){}if("get"in v||"set"in v)throw new l("Accessors not supported");if("value"in v)g[m]=v.value;return g}},7347(t,e,s){var i=s(3724),n=s(9565),r=s(8773),a=s(6980),o=s(5397),l=s(6969),h=s(9297),c=s(5917),d=Object.getOwnPropertyDescriptor;e.f=i?d:function(f,p){if(f=o(f),p=l(p),c)try{return d(f,p)}catch(g){}if(h(f,p))return a(!n(r.f,f,p),f[p])}},8480(t,e,s){var i=s(1828),n=s(8727),r=n.concat("length","prototype");e.f=Object.getOwnPropertyNames||function(o){return i(o,r)}},3717(t,e){e.f=Object.getOwnPropertySymbols},2787(t,e,s){var i=s(9297),n=s(4901),r=s(8981),a=s(6119),o=s(2211),l=a("IE_PROTO"),h=Object,c=h.prototype;t.exports=o?h.getPrototypeOf:function(d){var u=r(d);if(i(u,l))return u[l];var f=u.constructor;if(n(f)&&u instanceof f)return f.prototype;return u instanceof h?c:null}},1625(t,e,s){var i=s(9504);t.exports=i({}.isPrototypeOf)},1828(t,e,s){var i=s(9504),n=s(9297),r=s(5397),a=s(9617).indexOf,o=s(421),l=i([].push);t.exports=function(h,c){var d=r(h),u=0,f=[],p;for(p in d)!n(o,p)&&n(d,p)&&l(f,p);while(c.length>u)if(n(d,p=c[u++]))~a(f,p)||l(f,p);return f}},1072(t,e,s){var i=s(1828),n=s(8727);t.exports=Object.keys||function(a){return i(a,n)}},8773(t,e){var s={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,n=i&&!s.call({1:2},1);e.f=n?function(a){var o=i(this,a);return!!o&&o.enumerable}:s},2967(t,e,s){var i=s(6706),n=s(34),r=s(7750),a=s(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var o=!1,l={},h;try{h=i(Object.prototype,"__proto__","set"),h(l,[]),o=l instanceof Array}catch(c){}return function(d,u){if(r(d),a(u),!n(d))return d;if(o)h(d,u);else d.__proto__=u;return d}}():void 0)},4270(t,e,s){var i=s(9565),n=s(4901),r=s(34),a=TypeError;t.exports=function(o,l){var h,c;if(l==="string"&&n(h=o.toString)&&!r(c=i(h,o)))return c;if(n(h=o.valueOf)&&!r(c=i(h,o)))return c;if(l!=="string"&&n(h=o.toString)&&!r(c=i(h,o)))return c;throw new a("Can't convert object to primitive value")}},5031(t,e,s){var i=s(7751),n=s(9504),r=s(8480),a=s(3717),o=s(8551),l=n([].concat);t.exports=i("Reflect","ownKeys")||function(c){var d=r.f(o(c)),u=a.f;return u?l(d,u(c)):d}},8235(t,e,s){var i=s(9504),n=s(9297),r=SyntaxError,a=parseInt,o=String.fromCharCode,l=i("".charAt),h=i("".slice),c=i(/./.exec),d={"\\\"":'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
- `,"\\r":"\r","\\t":"\t"},u=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;t.exports=function(p,g){var m=!0,v="";while(g<p.length){var y=l(p,g);if(y==="\\"){var S=h(p,g,g+2);if(n(d,S))v+=d[S],g+=2;else if(S==="\\u"){g+=2;var A=h(p,g,g+4);if(!c(u,A))throw new r("Bad Unicode escape at: "+g);v+=o(a(A,16)),g+=4}else throw new r('Unknown escape sequence: "'+S+'"')}else if(y==='"'){m=!1,g++;break}else{if(c(f,y))throw new r("Bad control character in string literal at: "+g);v+=y,g++}}if(m)throw new r("Unterminated string at: "+g);return{value:v,end:g}}},1103(t){t.exports=function(e){try{return{error:!1,value:e()}}catch(s){return{error:!0,value:s}}}},3438(t,e,s){var i=s(8551),n=s(34),r=s(6043);t.exports=function(a,o){if(i(a),n(o)&&o.constructor===a)return o;var l=r.f(a),h=l.resolve;return h(o),l.promise}},7750(t,e,s){var i=s(4117),n=TypeError;t.exports=function(r){if(i(r))throw new n("Can't call method on "+r);return r}},9286(t,e,s){var i=s(4402),n=s(8469),{Set:r,add:a}=i;t.exports=function(o){var l=new r;return n(o,function(h){a(l,h)}),l}},3440(t,e,s){var i=s(7080),n=s(4402),r=s(9286),a=s(5170),o=s(3789),l=s(8469),h=s(507),{has:c,remove:d}=n;t.exports=function(f){var p=i(this),g=o(f),m=r(p);if(a(m)<=g.size)l(m,function(v){if(g.includes(v))d(m,v)});else h(g.getIterator(),function(v){if(c(m,v))d(m,v)});return m}},4402(t,e,s){var i=s(9504),n=Set.prototype;t.exports={Set,add:i(n.add),has:i(n.has),remove:i(n.delete),proto:n}},8750(t,e,s){var i=s(7080),n=s(4402),r=s(5170),a=s(3789),o=s(8469),l=s(507),{Set:h,add:c,has:d}=n;t.exports=function(f){var p=i(this),g=a(f),m=new h;if(r(p)>g.size)l(g.getIterator(),function(v){if(d(p,v))c(m,v)});else o(p,function(v){if(g.includes(v))c(m,v)});return m}},4449(t,e,s){var i=s(7080),n=s(4402).has,r=s(5170),a=s(3789),o=s(8469),l=s(507),h=s(9539);t.exports=function(d){var u=i(this),f=a(d);if(r(u)<=f.size)return o(u,function(g){if(f.includes(g))return!1},!0)!==!1;var p=f.getIterator();return l(p,function(g){if(n(u,g))return h(p.iterator,"normal",!1)})!==!1}},3838(t,e,s){var i=s(7080),n=s(5170),r=s(8469),a=s(3789);t.exports=function(l){var h=i(this),c=a(l);if(n(h)>c.size)return!1;return r(h,function(d){if(!c.includes(d))return!1},!0)!==!1}},8527(t,e,s){var i=s(7080),n=s(4402).has,r=s(5170),a=s(3789),o=s(507),l=s(9539);t.exports=function(c){var d=i(this),u=a(c);if(r(d)<u.size)return!1;var f=u.getIterator();return o(f,function(p){if(!n(d,p))return l(f.iterator,"normal",!1)})!==!1}},8469(t,e,s){var i=s(9504),n=s(507),r=s(4402),{Set:a,proto:o}=r,l=i(o.forEach),h=i(o.keys),c=h(new a).next;t.exports=function(d,u,f){return f?n({iterator:h(d),next:c},u):l(d,u)}},4916(t,e,s){var i=s(7751),n=function(a){return{size:a,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(a){return{size:a,has:function(){return!0},keys:function(){throw Error("e")}}};t.exports=function(a,o){var l=i("Set");try{new l()[a](n(0));try{return new l()[a](n(-1)),!1}catch(c){if(!o)return!0;try{return new l()[a](r(-1/0)),!1}catch(d){var h=new l([1,2]);return o(h[a](r(1/0)))}}}catch(c){return!1}}},9835(t){t.exports=function(e){try{var s=new Set,i={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return s.clear(),s.add(4),function(){return{done:!0}}}})}},n=s[e](i);return n.size===1&&n.values().next().value===4}catch(r){return!1}}},5170(t,e,s){var i=s(6706),n=s(4402);t.exports=i(n.proto,"size","get")||function(r){return r.size}},3650(t,e,s){var i=s(7080),n=s(4402),r=s(9286),a=s(3789),o=s(507),{add:l,has:h,remove:c}=n;t.exports=function(u){var f=i(this),p=a(u).getIterator(),g=r(f);return o(p,function(m){if(h(f,m))c(g,m);else l(g,m)}),g}},4204(t,e,s){var i=s(7080),n=s(4402).add,r=s(9286),a=s(3789),o=s(507);t.exports=function(h){var c=i(this),d=a(h).getIterator(),u=r(c);return o(d,function(f){n(u,f)}),u}},6119(t,e,s){var i=s(5745),n=s(3392),r=i("keys");t.exports=function(a){return r[a]||(r[a]=n(a))}},7629(t,e,s){var i=s(6395),n=s(4576),r=s(9433),a="__core-js_shared__",o=t.exports=n[a]||r(a,{});(o.versions||(o.versions=[])).push({version:"3.50.0",mode:i?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(t,e,s){var i=s(7629),n=Object.create||Object;t.exports=function(r,a){return i[r]||(i[r]=a||n(null))}},4495(t,e,s){var i=s(9519),n=s(9039),r=s(4576),a=r.String;t.exports=!!Object.getOwnPropertySymbols&&!n(function(){var o=Symbol("symbol detection");return!a(o)||!(Object(o)instanceof Symbol)||!Symbol.sham&&i&&i<41})},1240(t,e,s){var i=s(9504);t.exports=i(1.1 .valueOf)},5610(t,e,s){var i=s(1291),{max:n,min:r}=Math;t.exports=function(a,o){var l=i(a);return l<0?n(l+o,0):r(l,o)}},5854(t,e,s){var i=s(2777),n=TypeError;t.exports=function(r){var a=i(r,"number");if(typeof a=="number")throw new n("Can't convert number to bigint");return BigInt(a)}},5397(t,e,s){var i=s(7055),n=s(7750);t.exports=function(r){return i(n(r))}},1291(t,e,s){var i=s(741);t.exports=function(n){var r=+n;return r!==r||r===0?0:i(r)}},8014(t,e,s){var i=s(1291),n=Math.min;t.exports=function(r){var a=i(r);return a>0?n(a,9007199254740991):0}},8981(t,e,s){var i=s(7750),n=Object;t.exports=function(r){return n(i(r))}},9590(t,e,s){var i=s(1291),n=RangeError;t.exports=function(r){var a=i(r);if(a<0)throw new n("The argument can't be less than 0");return a}},2777(t,e,s){var i=s(9565),n=s(34),r=s(757),a=s(5966),o=s(4270),l=s(8227),h=TypeError,c=l("toPrimitive");t.exports=function(d,u){if(!n(d)||r(d))return d;var f=a(d,c),p;if(f){if(u===void 0)u="default";if(p=i(f,d,u),!n(p)||r(p))return p;throw new h("Can't convert object to primitive value")}if(u===void 0)u="number";return o(d,u)}},6969(t,e,s){var i=s(2777),n=s(757);t.exports=function(r){var a=i(r,"string");return n(a)?a:a+""}},2140(t,e,s){var i=s(8227),n=i("toStringTag"),r={};r[n]="z",t.exports=String(r)==="[object z]"},655(t,e,s){var i=s(6955),n=String;t.exports=function(r){if(i(r)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return n(r)}},6823(t){var e=String;t.exports=function(s){try{return e(s)}catch(i){return"Object"}}},3392(t,e,s){var i=s(9504),n=0,r=Math.random(),a=i(1.1 .toString);t.exports=function(o){return"Symbol("+(o===void 0?"":o)+")_"+a(++n+r,36)}},9143(t,e,s){var i=s(4576),n=s(9504),r=s(3972),a=s(3463),o=s(9297),l=s(2804),h=s(944),c=s(5169),{c2i:d,c2iUrl:u}=l,{SyntaxError:f,TypeError:p,Array:g}=i,m=n("".charAt),v=Math.floor,y=function(b,w){var x=b.length;for(;w<x;w++){var T=m(b,w);if(T!==" "&&T!=="\t"&&T!==`
3
- `&&T!=="\f"&&T!=="\r")break}return w},S=function(b,w,x){var T=b.length;if(T<4)b+=T===2?"AA":"A";var E=(w[m(b,0)]<<18)+(w[m(b,1)]<<12)+(w[m(b,2)]<<6)+w[m(b,3)],I=[E>>16&255,E>>8&255,E&255];if(T===2){if(x&&I[1]!==0)throw new f("Extra bits");return[I[0]]}if(T===3){if(x&&I[2]!==0)throw new f("Extra bits");return[I[0],I[1]]}return I},A=function(b,w,x){var T=w.length;for(var E=0;E<T;E++)b[x+E]=w[E];return x+T};t.exports=function(b,w,x,T){a(b),r(w);var E=h(w)==="base64"?d:u,I=w?w.lastChunkHandling:void 0;if(I===void 0)I="loose";if(I!=="loose"&&I!=="strict"&&I!=="stop-before-partial")throw new p("Incorrect `lastChunkHandling` option");if(x)c(x.buffer);var C=b.length,O=x||g(v(C*3/4)),D=0,k=0,R="",M=0;if(T)while(!0){if(M=y(b,M),M===C){if(R.length>0){if(I==="stop-before-partial")break;if(I==="loose"){if(R.length===1)throw new f("Malformed padding: exactly one additional character");D=A(O,S(R,E,!1),D)}else throw new f("Missing padding")}k=C;break}var _=m(b,M);if(++M,_==="="){if(R.length<2)throw new f("Padding is too early");if(M=y(b,M),R.length===2){if(M===C){if(I==="stop-before-partial")break;throw new f("Malformed padding: only one =")}if(m(b,M)==="=")++M,M=y(b,M)}if(M<C)throw new f("Unexpected character after padding");D=A(O,S(R,E,I==="strict"),D),k=C;break}if(!o(E,_))throw new f("Unexpected character");var U=T-D;if(U===1&&R.length===2||U===2&&R.length===3)break;if(R+=_,R.length===4){if(D=A(O,S(R,E,!1),D),R="",k=M,D===T)break}}if(!x)O.length=D;return{bytes:O,read:k,written:D}}},2303(t,e,s){var i=s(4576),n=s(9504),{Uint8Array:r,SyntaxError:a}=i,o=Math.min,l=n("".match);t.exports=function(h,c){var d=h.length;if(d%2!==0)throw new a("String should be an even number of characters");var u=c?o(c.length,d/2):d/2,f=c||new r(u),p=l(h,/[\S\s]{2}/g),g=0;for(;g<u;g++){var m=+("0x"+p[g]+"0");if(m!==m)throw new a("String should only contain hex characters");f[g]=m>>4}return{bytes:f,read:g<<1}}},7416(t,e,s){var i=s(9039),n=s(8227),r=s(3724),a=s(6395),o=n("iterator");t.exports=!i(function(){var l=new URL("b?a=1&b=2&c=3","https://a"),h=l.searchParams,c=new URLSearchParams("a=1&a=2&b=3"),d="";return l.pathname="c%20d",h.forEach(function(u,f){h.delete("b"),d+=f+u}),c.delete("a",2),c.delete("b",void 0),a&&(!l.toJSON||!c.has("a",1)||c.has("a",2)||!c.has("a",void 0)||c.has("b"))||!h.size&&(a||!r)||!h.sort||l.href!=="https://a/c%20d?a=1&c=3"||h.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!h[o]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||d!=="a1c3"||new URL("https://x",void 0).host!=="x"})},7040(t,e,s){var i=s(4495);t.exports=i&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686(t,e,s){var i=s(3724),n=s(9039);t.exports=i&&n(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})},2812(t){var e=TypeError;t.exports=function(s,i){if(s<i)throw new e("Not enough arguments");return s}},8622(t,e,s){var i=s(4576),n=s(4901),r=i.WeakMap;t.exports=n(r)&&/native code/.test(String(r))},4995(t,e,s){var i=s(9504),n=WeakMap.prototype;t.exports={WeakMap,set:i(n.set),get:i(n.get),has:i(n.has),remove:i(n.delete)}},8227(t,e,s){var i=s(4576),n=s(5745),r=s(9297),a=s(3392),o=s(4495),l=s(7040),h=i.Symbol,c=n("wks"),d=l?h.for||h:h&&h.withoutSetter||a;t.exports=function(u){if(!r(c,u))c[u]=o&&r(h,u)?h[u]:d("Symbol."+u);return c[u]}},4423(t,e,s){var i=s(6518),n=s(9617).includes,r=s(9039),a=s(6469),o=r(function(){return!Array(1).includes()}),l=r(function(){return[,1].includes(void 0,1)});i({target:"Array",proto:!0,forced:o||l},{includes:function(c){return n(this,c,arguments.length>1?arguments[1]:void 0)}}),a("includes")},4114(t,e,s){var i=s(6518),n=s(8981),r=s(6198),a=s(4527),o=s(6837),l=s(9039),h=l(function(){return[].push.call({length:4294967296},1)!==4294967297}),c=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(u){return u instanceof TypeError}},d=h||!c();i({target:"Array",proto:!0,arity:1,forced:d},{push:function(f){var p=n(this),g=r(p),m=arguments.length;o(g+m);for(var v=0;v<m;v++)p[g]=arguments[v],g++;return a(p,g),g}})},8111(t,e,s){var i=s(6518),n=s(4576),r=s(679),a=s(8551),o=s(4901),l=s(2787),h=s(2106),c=s(4659),d=s(9039),u=s(9297),f=s(8227),p=s(7657).IteratorPrototype,g=s(3724),m=s(6395),v="constructor",y="Iterator",S=f("toStringTag"),A=TypeError,b=n[y],w=m||!o(b)||b.prototype!==p||!d(function(){b({})}),x=function(){if(r(this,p),l(this)===p)throw new A("Abstract class Iterator not directly constructable")},T=function(E,I){if(g)h(p,E,{configurable:!0,get:function(){return I},set:function(C){if(a(this),this===p)throw new A("You can't redefine this property");if(u(this,E))this[E]=C;else c(this,E,C)}});else p[E]=I};if(!u(p,S))T(S,y);if(w||!u(p,v)||p[v]===Object)T(v,x);x.prototype=p,i({global:!0,constructor:!0,forced:w},{Iterator:x})},9314(t,e,s){var i=s(6518),n=s(9565),r=s(8551),a=s(1767),o=s(4149),l=s(9590),h=s(9539),c=s(9462),d=s(684),u=s(4549),f=s(6395),p=RangeError,g=1/0,m=!f&&!d("drop",0),v=!f&&!m&&u("drop",RangeError),y=f||m||v||!function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(A){return A instanceof p}}(),S=c(function(){var A=this.iterator,b=this.next,w,x;while(this.remaining)if(this.remaining--,w=r(n(b,A)),x=this.done=!!w.done,x)return;if(w=r(n(b,A)),x=this.done=!!w.done,!x)return w.value});i({target:"Iterator",proto:!0,real:!0,forced:y},{drop:function(b){r(this);var w;try{if(w=l(o(+b)),w>9007199254740991&&w!==g)throw new p("The argument should be a safe integer")}catch(x){h(this,"throw",x)}if(v)return n(v,this,w);return new S(a(this),{remaining:w})}})},1148(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("every",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{every:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;return!r(p,function(m,v){if(!f(m,g++))return v()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(t,e,s){var i=s(6518),n=s(9565),r=s(9306),a=s(8551),o=s(1767),l=s(9462),h=s(6319),c=s(6395),d=s(9539),u=s(684),f=s(4549),p=!c&&!u("filter",function(){}),g=!c&&!p&&f("filter",TypeError),m=c||p||g,v=l(function(){var y=this.iterator,S=this.predicate,A=this.next,b,w,x;while(!0){if(b=a(n(A,y)),w=this.done=!!b.done,w)return;if(x=b.value,h(y,S,[x,this.counter++],!0))return x}});i({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(S){a(this);try{r(S)}catch(A){d(this,"throw",A)}if(g)return n(g,this,S);return new v(o(this),{predicate:S})}})},116(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("find",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{find:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;return r(p,function(m,v){if(f(m,g++))return v(m)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(t,e,s){var i=s(6518),n=s(9565),r=s(9306),a=s(8551),o=s(1767),l=s(8646),h=s(9462),c=s(9539),d=s(9039),u=s(6395),f=s(684),p=s(4549),g=!u&&d(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),m=!u&&!g&&!f("flatMap",function(){}),v=!u&&!g&&!m&&p("flatMap",TypeError),y=u||g||m||v,S=h(function(){var A=this.iterator,b=this.mapper,w,x;while(!0){if(x=this.inner)try{if(w=a(n(x.next,x.iterator)),!w.done)return w.value;this.inner=null}catch(T){c(A,"throw",T)}if(w=a(n(this.next,A)),this.done=!!w.done)return;try{this.inner=l(b(w.value,this.counter++),!1)}catch(T){c(A,"throw",T)}}});i({target:"Iterator",proto:!0,real:!0,forced:y},{flatMap:function(b){a(this);try{r(b)}catch(w){c(this,"throw",w)}if(v)return n(v,this,b);return new S(o(this),{mapper:b,inner:null})}})},7588(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("forEach",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{forEach:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;r(p,function(m){f(m,g++)},{IS_RECORD:!0})}})},1701(t,e,s){var i=s(6518),n=s(9565),r=s(9306),a=s(8551),o=s(1767),l=s(9462),h=s(6319),c=s(9539),d=s(684),u=s(4549),f=s(6395),p=!f&&!d("map",function(){}),g=!f&&!p&&u("map",TypeError),m=f||p||g,v=l(function(){var y=this.iterator,S=a(n(this.next,y)),A=this.done=!!S.done;if(!A)return h(y,this.mapper,[S.value,this.counter++],!0)});i({target:"Iterator",proto:!0,real:!0,forced:m},{map:function(S){a(this);try{r(S)}catch(A){c(this,"throw",A)}if(g)return n(g,this,S);return new v(o(this),{mapper:S})}})},3579(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("some",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{some:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;return r(p,function(m,v){if(f(m,g++))return v()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(t,e,s){var i=s(6518),n=s(9565),r=s(8551),a=s(1767),o=s(4149),l=s(9590),h=s(9462),c=s(9539),d=s(684),u=s(4549),f=s(6395),p=RangeError,g=1/0,m=!f&&!d("take",1),v=!f&&!m&&u("take",RangeError),y=f||m||v||!function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(A){return A instanceof p}}(),S=h(function(){var A=this.iterator;if(!this.remaining--)return this.done=!0,c(A,"normal",void 0);var b=r(n(this.next,A)),w=this.done=!!b.done;if(!w)return b.value});i({target:"Iterator",proto:!0,real:!0,forced:y},{take:function(b){r(this);var w;try{if(w=l(o(+b)),w>9007199254740991&&w!==g)throw new p("The argument should be a safe integer")}catch(x){c(this,"throw",x)}if(v)return n(v,this,w);return new S(a(this),{remaining:w})}})},1806(t,e,s){var i=s(6518),n=s(8551),r=s(4659),a=s(2652),o=s(1767);i({target:"Iterator",proto:!0,real:!0},{toArray:function(){var h=[],c=0;return a(o(n(this)),function(d){r(h,c++,d)},{IS_RECORD:!0}),h}})},9112(t,e,s){var i=s(6518),n=s(3724),r=s(4576),a=s(7751),o=s(9504),l=s(9565),h=s(4901),c=s(34),d=s(4376),u=s(9297),f=s(655),p=s(6198),g=s(4659),m=s(9039),v=s(8235),y=s(4495),{JSON:S,Number:A,SyntaxError:b}=r,w=S&&S.parse,x=a("Object","keys"),T=Object.getOwnPropertyDescriptor,E=o("".charAt),I=o("".slice),C=o(/./.exec),O=o([].push),D=/^\d$/,k=/^[1-9]$/,R=/^[\d-]$/,M=/^[\t\n\r ]$/,_=0,U=1,G=function(N,P){N=f(N);var F=new et(N,0),X=F.parse(),nt=X.value,V=F.skip(M,X.end);if(V<N.length)throw new b('Unexpected extra character: "'+E(N,V)+'" after the parsed data at: '+V);return h(P)?it({"":nt},"",P,X):nt},it=function(N,P,F,X){var nt=N[P],V=X&&nt===X.value,Z=V&&typeof X.source=="string"?{source:X.source}:{},lt,xt,Et,vt,$t;if(c(nt)){var Me=d(nt),ye=V?X.nodes:Me?[]:{};if(Me){lt=ye.length,Et=p(nt);for(vt=0;vt<Et;vt++)rt(nt,vt,it(nt,""+vt,F,vt<lt?ye[vt]:void 0))}else{xt=x(nt),Et=p(xt);for(vt=0;vt<Et;vt++)$t=xt[vt],rt(nt,$t,it(nt,$t,F,u(ye,$t)?ye[$t]:void 0))}}return l(F,N,P,nt,Z)},rt=function(N,P,F){if(n){var X=T(N,P);if(X&&!X.configurable)return}if(F===void 0)delete N[P];else g(N,P,F)},J=function(N,P,F,X){this.value=N,this.end=P,this.source=F,this.nodes=X},et=function(N,P){this.source=N,this.index=P};et.prototype={fork:function(N){return new et(this.source,N)},parse:function(){var N=this.source,P=this.skip(M,this.index),F=this.fork(P),X=E(N,P);if(C(R,X))return F.number();switch(X){case"{":return F.object();case"[":return F.array();case'"':return F.string();case"t":return F.keyword(!0);case"f":return F.keyword(!1);case"n":return F.keyword(null)}throw new b('Unexpected character: "'+X+'" at: '+P)},node:function(N,P,F,X,nt){return new J(P,X,N?null:I(this.source,F,X),nt)},object:function(){var N=this.source,P=this.index+1,F=!1,X={},nt={},V=!1;while(P<N.length){if(P=this.until(['"',"}"],P),E(N,P)==="}"&&!F){P++,V=!0;break}var Z=this.fork(P).string(),lt=Z.value;P=Z.end,P=this.until([":"],P)+1,P=this.skip(M,P),Z=this.fork(P).parse(),g(nt,lt,Z),g(X,lt,Z.value),P=this.until([",","}"],Z.end);var xt=E(N,P);if(xt===",")F=!0,P++;else if(xt==="}"){P++,V=!0;break}}if(!V)throw new b("Unterminated object at: "+P);return this.node(U,X,this.index,P,nt)},array:function(){var N=this.source,P=this.index+1,F=!1,X=[],nt=[],V=!1;while(P<N.length){if(P=this.skip(M,P),E(N,P)==="]"&&!F){P++,V=!0;break}var Z=this.fork(P).parse();if(O(nt,Z),O(X,Z.value),P=this.until([",","]"],Z.end),E(N,P)===",")F=!0,P++;else if(E(N,P)==="]"){P++,V=!0;break}}if(!V)throw new b("Unterminated array at: "+P);return this.node(U,X,this.index,P,nt)},string:function(){var N=this.index,P=v(this.source,this.index+1);return this.node(_,P.value,N,P.end)},number:function(){var N=this.source,P=this.index,F=P;if(E(N,F)==="-")F++;if(E(N,F)==="0")F++;else if(C(k,E(N,F)))F=this.skip(D,F+1);else throw new b("Failed to parse number at: "+F);if(E(N,F)==="."){var X=F+1;if(F=this.skip(D,X),X===F)throw new b("Failed to parse number's fraction at: "+F)}if(E(N,F)==="e"||E(N,F)==="E"){if(F++,E(N,F)==="+"||E(N,F)==="-")F++;var nt=F;if(F=this.skip(D,F),nt===F)throw new b("Failed to parse number's exponent value at: "+F)}return this.node(_,A(I(N,P,F)),P,F)},keyword:function(N){var P=""+N,F=this.index,X=F+P.length;if(I(this.source,F,X)!==P)throw new b("Failed to parse value at: "+F);return this.node(_,N,F,X)},skip:function(N,P){var F=this.source;for(;P<F.length;P++)if(!C(N,E(F,P)))break;return P},until:function(N,P){P=this.skip(M,P);var F=E(this.source,P);for(var X=0;X<N.length;X++)if(N[X]===F)return P;throw new b('Unexpected character: "'+F+'" at: '+P)}};var ht=m(function(){var N="9007199254740993",P;return w(N,function(F,X,nt){P=nt.source}),P!==N}),Rt=y&&!m(function(){return 1/w("-0 \t")!==-1/0});i({target:"JSON",stat:!0,forced:ht},{parse:function(P,F){return Rt&&!h(F)?w(P):G(P,F)}})},3110(t,e,s){var i=s(6518),n=s(7751),r=s(9565),a=s(9504),o=s(9039),l=s(4376),h=s(4901),c=s(34),d=s(2360),u=s(5810),f=s(757),p=s(2195),g=s(1240),m=s(9617).includes,v=s(9297),y=s(655),S=s(8235),A=s(3392),b=s(4495),w=s(7819),x=String,T=TypeError,E=n("JSON","stringify"),I=n("BigInt"),C=a("".valueOf),O=a((!0).valueOf),D=I&&a(I.prototype.valueOf),k=a(/./.exec),R=a("".charAt),M=a("".charCodeAt),_=a("".replace),U=a("".slice),G=a([].push),it=a([].pop),rt=a(1.1 .toString),J=/[\uD800-\uDFFF]/g,et=/^[\uD800-\uDBFF]$/,ht=/^[\uDC00-\uDFFF]$/,Rt=/^\d+$/,N=A(),P=A(),F=A(),X=N.length,nt=P.length,V=!b||o(function(){var tt=n("Symbol")("stringify detection");return E([tt])!=="[null]"||E({a:tt})!=="{}"||E(Object(tt))!=="{}"}),Z=o(function(){return E("\uDF06\uD834")!=='"\\udf06\\ud834"'||E("\uDEAD")!=='"\\udead"'}),lt=w?n("JSON","isRawJSON"):u,xt=V?function(tt,ct,pt){return E(tt,function(It,Pt){var St=r(ct,this,It,Pt);if(!f(St))return St},pt)}:E,Et=function(tt,ct,pt){var It=R(pt,ct-1),Pt=R(pt,ct+1);if(k(et,tt)&&!k(ht,Pt)||k(ht,tt)&&!k(et,It))return"\\u"+rt(M(tt,0),16);return tt},vt=function(tt){if(!l(tt))return;var ct=tt.length,pt=[],It=d(null);for(var Pt=0;Pt<ct;Pt++){var St=tt[Pt],Gt;if(typeof St=="string")Gt=St;else if(typeof St=="number"||p(St)==="Number"||p(St)==="String")Gt=y(St);else continue;if(!v(It,Gt))It[Gt]=!0,G(pt,Gt)}return pt},$t=function(tt,ct){try{return tt(ct),!0}catch(pt){return!1}},Me=function(tt){var ct=p(tt);return ct==="Number"&&$t(g,tt)||ct==="String"&&$t(C,tt)||ct==="Boolean"&&$t(O,tt)||!!D&&ct==="BigInt"&&$t(D,tt)},ye=function(tt){if(!c(tt)||h(tt)||l(tt))return!1;try{return!Me(tt)}catch(ct){return!0}},Yr=function(tt,ct){return{toJSON:function(){var pt=tt[ct];if(c(pt)||typeof pt=="bigint"){var It=pt.toJSON;if(h(It))pt=r(It,pt,ct)}return pt}}},Kr=function(tt){for(var ct=0,pt=tt.length;ct<pt;ct++)if(k(Rt,tt[ct]))return P;return""},Jr=function(tt,ct,pt){var It=d(null);for(var Pt=0,St=ct.length;Pt<St;Pt++){var Gt=ct[Pt];It[pt+Gt]=Yr(tt,Gt)}return It[F]=null,It};if(E)i({target:"JSON",stat:!0,arity:3,forced:V||Z||!w},{stringify:function(ct,pt,It){var Pt=h(pt)?pt:void 0,St=Pt?void 0:vt(pt),Gt=St&&Kr(St),Ni=[],js=[],Fi=[],ts,$s=!1,Bi=!0,qt=xt(ct,function(De,Xt){if(De=x(De),St){if(De===F){it(js),ts=it(Fi);return}if(Bi)Bi=!1;else if(this!==ts&&!l(this)&&!m(St,De))return}else if(Pt)Xt=r(Pt,this,De,Xt);if(lt(Xt)){if(w)return Xt;return $s=!0,N+(G(Ni,Xt.rawJSON)-1)}if(St&&ye(Xt)){if(m(js,Xt))throw new T("Converting circular structure to JSON");var Ui=Jr(Xt,St,Gt);if(G(js,Xt),G(Fi,ts),ts=Ui,Gt)$s=!0;return Ui}return Xt},It);if(typeof qt!="string")return qt;if(Z)qt=_(qt,J,Et);if(!$s)return qt;var Oe="",Qr=qt.length;for(var be=0;be<Qr;be++){var _i=R(qt,be);if(_i==='"'){var Hi=S(qt,++be).end-1,Re=U(qt,be,Hi);if(U(Re,0,X)===N)Oe+=Ni[U(Re,X)];else if(U(Re,0,nt)===P)Oe+='"'+U(Re,nt)+'"';else Oe+='"'+Re+'"';be=Hi}else Oe+=_i}return Oe}})},2731(t,e,s){var i=s(6518),n=s(9306),r=s(2248),a=s(6395),{get:o,has:l,set:h}=r;i({target:"Map",proto:!0,real:!0,forced:a},{getOrInsertComputed:function(d,u){var f=l(this,d);if(n(u),f)return o(this,d);if(d===0&&1/d===-1/0)d=0;var p=u(d);return h(this,d,p),p}})},5367(t,e,s){var i=s(6518),n=s(2248),r=s(6395),{get:a,has:o,set:l}=n;i({target:"Map",proto:!0,real:!0,forced:r},{getOrInsert:function(c,d){if(o(this,c))return a(this,c);return l(this,c,d),d}})},3068(t,e,s){var i=s(6518),n=s(9504),r=s(2652),a=RangeError,o=TypeError,l=1/0,h=NaN,{abs:c,pow:d}=Math,u=n([].push),f=d(2,1023),p=d(2,53)-1,g=Number.MAX_VALUE,m=d(2,971),v={},y={},S={},A={},b={},w=function(x,T){var E=x+T,I=T-(E-x);return{hi:E,lo:I}};i({target:"Math",stat:!0},{sumPrecise:function(T){var E=[],I=0,C=A;switch(r(T,function(N){if(++I>p)throw new a("Maximum allowed index exceeded");if(typeof N!="number")throw new o("Value is not a number");if(C!==v){if(N!==N)C=v;else if(N===l)C=C===y?v:S;else if(N===-l)C=C===S?v:y;else if((N!==0||1/N===l)&&(C===A||C===b))C=b,u(E,N)}}),C){case v:return h;case y:return-l;case S:return l;case A:return-0}var O=[],D=0,k,R,M,_,U,G;for(var it=0;it<E.length;it++){k=E[it];var rt=0;for(var J=0;J<O.length;J++){if(R=O[J],c(k)<c(R))G=k,k=R,R=G;if(M=w(k,R),_=M.hi,U=M.lo,c(_)===l){var et=_===l?1:-1;if(D+=et,k=k-et*f-et*f,c(k)<c(R))G=k,k=R,R=G;M=w(k,R),_=M.hi,U=M.lo}if(U!==0)O[rt++]=U;k=_}if(O.length=rt,k!==0)u(O,k)}var ht=O.length-1;if(_=0,U=0,D!==0){var Rt=ht>=0?O[ht]:0;if(ht--,c(D)>1||D>0&&Rt>0||D<0&&Rt<0)return D>0?l:-l;if(M=w(D*f,Rt/2),_=M.hi,U=M.lo,U*=2,c(2*_)===l){if(_>0)return _===f&&U===-(m/2)&&ht>=0&&O[ht]<0?g:l;return _===-f&&U===m/2&&ht>=0&&O[ht]>0?-g:-l}if(U!==0)O[++ht]=U,U=0;_*=2}while(ht>=0)if(M=w(_,O[ht--]),_=M.hi,U=M.lo,U!==0)break;if(ht>=0&&(U<0&&O[ht]<0||U>0&&O[ht]>0)){if(R=U*2,k=_+R,R===k-_)_=k}return _}})},1689(t,e,s){var i=s(6518),n=s(4576),r=s(8745),a=s(7680),o=s(3438),l=s(6043),h=s(9306),c=s(1103),d=s(9039),u=n.Promise,f=!1,p=!u||!u.try||d(function(){var g=u.resolve();return u.try(function(m){return f=m===8,g},8)!==g})||!f;i({target:"Promise",stat:!0,forced:p},{try:function(g){var m=arguments.length>1?a(arguments,1):[],v=c(function(){return r(h(g),void 0,m)});if(!v.error)return o(this,v.value);var y=l.f(this),S=y.reject;return S(v.value),y.promise}})},7642(t,e,s){var i=s(6518),n=s(3440),r=s(9039),a=s(4916),o=!a("difference",function(h){return h.size===0}),l=o||r(function(){var h={size:1,has:function(){return!0},keys:function(){var d=0;return{next:function(){var u=d++>1;if(c.has(1))c.clear();return{done:u,value:2}}}}},c=new Set([1,2,3,4]);return c.difference(h).size!==3});i({target:"Set",proto:!0,real:!0,forced:l},{difference:n})},8004(t,e,s){var i=s(6518),n=s(9039),r=s(8750),a=s(4916),o=!a("intersection",function(l){return l.size===2&&l.has(1)&&l.has(2)})||n(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});i({target:"Set",proto:!0,real:!0,forced:o},{intersection:r})},3853(t,e,s){var i=s(6518),n=s(4449),r=s(4916),a=!r("isDisjointFrom",function(o){return!o});i({target:"Set",proto:!0,real:!0,forced:a},{isDisjointFrom:n})},5876(t,e,s){var i=s(6518),n=s(3838),r=s(4916),a=!r("isSubsetOf",function(o){return o});i({target:"Set",proto:!0,real:!0,forced:a},{isSubsetOf:n})},2475(t,e,s){var i=s(6518),n=s(8527),r=s(4916),a=!r("isSupersetOf",function(o){return!o});i({target:"Set",proto:!0,real:!0,forced:a},{isSupersetOf:n})},5024(t,e,s){var i=s(6518),n=s(3650),r=s(9835),a=s(4916),o=!a("symmetricDifference")||!r("symmetricDifference");i({target:"Set",proto:!0,real:!0,forced:o},{symmetricDifference:n})},1698(t,e,s){var i=s(6518),n=s(4204),r=s(9835),a=s(4916),o=!a("union")||!r("union");i({target:"Set",proto:!0,real:!0,forced:o},{union:n})},9577(t,e,s){var i=s(4644),n=s(1108),r=s(6198),a=s(1291),o=s(5854),{aTypedArray:l,getTypedArrayConstructor:h,exportTypedArrayMethod:c}=i,d=RangeError,u=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(p){return p===8}}(),f=u&&function(){try{new Int8Array(1).with(-0.5,1)}catch(p){return!0}}();c("with",function(p,g){var m=l(this),v=r(m),y=a(p),S=y<0?v+y:y,A=n(m)?o(g):+g;if(S>=v||S<0)throw new d("Incorrect index");var b=new(h(m))(v),w=0;for(;w<v;w++)b[w]=w===S?A:m[w];return b},!u||f)},5213(t,e,s){var i=s(6518),n=s(4576),r=s(5370),a=s(9143),o=n.Uint8Array,l=!o||!o.fromBase64||!function(){try{o.fromBase64("a");return}catch(h){}try{o.fromBase64("",null)}catch(h){return!0}}();if(o)i({target:"Uint8Array",stat:!0,forced:l},{fromBase64:function(c){var d=a(c,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(o,d.bytes)}})},6632(t,e,s){var i=s(6518),n=s(4576),r=s(9143),a=s(4154),o=n.Uint8Array,l=!o||!o.prototype.setFromBase64||!function(){var h=new o([255,255,255,255,255]);try{h.setFromBase64("",null);return}catch(c){}try{h.setFromBase64("a");return}catch(c){}try{h.setFromBase64("MjYyZg===")}catch(c){return h[0]===50&&h[1]===54&&h[2]===50&&h[3]===255&&h[4]===255}}();if(o)i({target:"Uint8Array",proto:!0,forced:l},{setFromBase64:function(c){a(this);var d=r(c,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:d.read,written:d.written}}})},4226(t,e,s){var i=s(6518),n=s(4576),r=s(3463),a=s(4154),o=s(5169),l=s(2303);function h(){try{var c=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(c).setFromHex("cafed00d")}catch(d){return!0}}if(n.Uint8Array)i({target:"Uint8Array",proto:!0,forced:h()},{setFromHex:function(d){a(this),r(d),o(this.buffer);var u=l(d,this).read;return{read:u,written:u/2}}})},9486(t,e,s){var i=s(6518),n=s(4576),r=s(9504),a=s(3972),o=s(4154),l=s(5169),h=s(2804),c=s(944),{i2c:d,i2cUrl:u}=h,{floor:f,ceil:p}=Math,g=r("".charAt),{Uint8Array:m,Array:v}=n,y=r([].join),S=!m||!m.prototype.toBase64||!function(){try{var A=new m;A.toBase64(null)}catch(b){return!0}}();if(m)i({target:"Uint8Array",proto:!0,forced:S},{toBase64:function(){var b=o(this),w=arguments.length?a(arguments[0]):void 0,x=c(w)==="base64"?d:u,T=!!w&&!!w.omitPadding;l(this.buffer);var E=0,I=b.length,C=v(T?f(I/3)*4+(I%3?I%3+1:0):p(I/3)*4),O=0,D,k=function(R){return g(x,D>>6*R&63)};for(;E+2<I;E+=3)D=(b[E]<<16)+(b[E+1]<<8)+b[E+2],C[O++]=k(3),C[O++]=k(2),C[O++]=k(1),C[O++]=k(0);if(E+2===I){if(D=(b[E]<<16)+(b[E+1]<<8),C[O++]=k(3),C[O++]=k(2),C[O++]=k(1),!T)C[O++]="="}else if(E+1===I){if(D=b[E]<<16,C[O++]=k(3),C[O++]=k(2),!T)C[O++]="=",C[O++]="="}return y(C,"")}})},456(t,e,s){var i=s(6518),n=s(4576),r=s(9504),a=s(4154),o=s(5169),l=r(1.1 .toString),h=r([].join),c=Array,d=n.Uint8Array,u=!d||!d.prototype.toHex||!function(){try{var f=new d([255,255,255,255,255,255,255,255]);return f.toHex()==="ffffffffffffffff"}catch(p){return!1}}();if(d)i({target:"Uint8Array",proto:!0,forced:u},{toHex:function(){a(this),o(this.buffer);var p=c(this.length);for(var g=0,m=this.length;g<m;g++){var v=l(this[g],16);p[g]=v.length===1?"0"+v:v}return h(p,"")}})},9452(t,e,s){var i=s(6518),n=s(9306),r=s(6557),a=s(4328),o=s(4995),l=s(6395),{get:h,has:c,set:d}=o,u=l||!function(){try{if(WeakMap.prototype.getOrInsertComputed)new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(f){return f instanceof TypeError}}();i({target:"WeakMap",proto:!0,real:!0,forced:u},{getOrInsertComputed:function(p,g){if(!l)r(this);if(a(p),n(g),c(this,p))return h(this,p);var m=g(p);return d(this,p,m),m}})},8454(t,e,s){var i=s(6518),n=s(4995),r=s(6395),{get:a,has:o,set:l}=n;i({target:"WeakMap",proto:!0,real:!0,forced:r},{getOrInsert:function(c,d){if(o(this,c))return a(this,c);return l(this,c,d),d}})},4979(t,e,s){var i=s(6518),n=s(4576),r=s(7751),a=s(6980),o=s(4913).f,l=s(9297),h=s(679),c=s(3167),d=s(2603),u=s(5002),f=s(6193),p=s(3724),g=s(6395),m="DOMException",v=r("Error"),y=r(m),S=function(){h(this,A);var M=arguments.length,_=d(M<1?void 0:arguments[0]),U=d(M<2?void 0:arguments[1],"Error"),G=new y(_,U),it=new v(_);return it.name=m,o(G,"stack",a(1,f(it.stack,1))),c(G,this,S),G},A=S.prototype=y.prototype,b="stack"in new v(m),w="stack"in new y(1,2),x=y&&p&&Object.getOwnPropertyDescriptor(n,m),T=!!x&&!(x.writable&&x.configurable),E=b&&!T&&!w;i({global:!0,constructor:!0,forced:g||E},{DOMException:E?S:y});var I=r(m),C=I.prototype;if(C.constructor!==I){if(!g)o(C,"constructor",a(1,I));for(var O in u)if(l(u,O)){var D=u[O],k=D.s;if(!l(I,k))o(I,k,a(6,D.c))}}},5781(t,e,s){var i=s(6518),n=s(7751),r=s(2812),a=s(655),o=s(7416),l=n("URL");i({target:"URL",stat:!0,forced:!o},{parse:function(c){var d=r(arguments.length,1),u=a(c),f=d<2||arguments[1]===void 0?void 0:a(arguments[1]);try{return new l(u,f)}catch(p){return null}}})}};var ji={};function K(t){let e=ji[t];if(e!==void 0)return e.exports;let s=ji[t]={exports:{}};return Zr[t].call(s.exports,s,s.exports,K),s.exports}(()=>{K.d=(t,e)=>{if(Array.isArray(e)){var s=0;while(s<e.length){var i=e[s++],n=e[s++];if(!K.o(t,i))if(n===0)Object.defineProperty(t,i,{enumerable:!0,value:e[s++]});else Object.defineProperty(t,i,{enumerable:!0,get:n});else if(n===0)s++}}else for(var i in e)if(K.o(e,i)&&!K.o(t,i))Object.defineProperty(t,i,{enumerable:!0,get:e[i]})}})();(()=>{K.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)})();var Ja=K(4423),Qa=K(4114),Za=K(8111),qa=K(2489),to=K(5367),eo=K(2731),so=K(7642),io=K(8004),no=K(3853),ro=K(5876),ao=K(2475),oo=K(5024),lo=K(1698),ho=K(9577),co=K(6632),uo=K(4226),fo=K(9486),po=K(456),go=K(5781),Nt=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ee=[1/0,1/0,-1/0,-1/0],de=new Float32Array(ee),Ys=[0.001,0,0,0.001,0,0];var Mt="http://www.w3.org/2000/svg",Lt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ne={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},xe="pdfjs_internal_id_",Ce="pdfjs_internal_editor_",Y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},q={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},qr={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};var bt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},hs={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},gt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27};var Se={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var xs={ERRORS:0,WARNINGS:1,INFOS:5},Qt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},ke={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},ta={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Es=xs.WARNINGS;function ea(t){if(Number.isInteger(t))Es=t}function sa(){return Es}function Ts(t){if(Es>=xs.INFOS)console.info(`Info: ${t}`)}function z(t){if(Es>=xs.WARNINGS)console.warn(`Warning: ${t}`)}function st(t){throw Error(t)}function mt(t,e){if(!t)st(e)}function ia(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mn(t,e=null,s=null){if(!t)return null;if(s&&typeof t==="string"){if(s.addDefaultProtocol&&t.startsWith("www.")){if(t.match(/\./g)?.length>=2)t=`http://${t}`}if(s.tryConvertEncoding)try{t=ra(t)}catch{}}let i=e?URL.parse(t,e):URL.parse(t);return ia(i)?i:null}function vn(t,e,s=!1){let i=URL.parse(t);if(i)return i.hash=e,i.href;if(s&&mn(t,"http://example.com"))return t.split("#",1)[0]+`${e?`#${e}`:""}`;return""}function Ks(t){return t.substring(t.lastIndexOf("/")+1)}function j(t,e,s,i=!1){return Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:!0,writable:!1}),s}var ve=function(){function e(s,i){this.message=s,this.name=i}return e.prototype=Error(),e.constructor=e,e}();class fs extends ve{constructor(t,e){super(t,"PasswordException");this.code=e}}class cs extends ve{constructor(t,e){super(t,"UnknownErrorException");this.details=e}}class ps extends ve{constructor(t){super(t,"InvalidPDFException")}}class Ue extends ve{constructor(t,e,s){super(t,"ResponseException");this.status=e,this.missing=s}}class yn extends ve{constructor(t){super(t,"FormatError")}}class se extends ve{constructor(t){super(t,"AbortException")}}function na(t){if(typeof t!=="object"||t?.length===void 0)st("Invalid argument for bytesToString");let e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);let i=[];for(let n=0;n<e;n+=s){let r=Math.min(n+s,e),a=t.subarray(n,r);i.push(String.fromCharCode.apply(null,a))}return i.join("")}function Cs(t){if(typeof t!=="string")st("Invalid argument for stringToBytes");let e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=t.charCodeAt(i)&255;return s}class ot{static get isLittleEndian(){let t=new Uint8Array(4);t[0]=1;let e=new Uint32Array(t.buffer,0,1);return j(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return j(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return j(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return j(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return j(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return j(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;if(this.isOffscreenCanvasSupported)t=new OffscreenCanvas(1,1).getContext("2d");else if(typeof document<"u")t=document.createElement("canvas").getContext("2d");return j(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return j(this,"isAlphaColorInputSupported",!1);let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",j(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return j(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class L{static get hexNums(){return j(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){let i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){let c=t[s+h],d=t[s+h+1];t[s+h]=c*i+d*r+o,t[s+h+1]=c*n+d*a+l}}static applyInverseTransform(t,e){let s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3],f=i*h+o,p=f,g=i*d+o,m=g,v=a*c+l,y=v,S=a*u+l,A=S;if(n!==0||r!==0){let b=n*h,w=n*d,x=r*c,T=r*u;f+=x,m+=x,g+=T,p+=T,v+=b,A+=b,S+=w,y+=w}s[0]=Math.min(s[0],f,g,p,m),s[1]=Math.min(s[1],v,S,y,A),s[2]=Math.max(s[2],f,g,p,m),s[3]=Math.max(s[3],v,S,y,A)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){let e=t.slice(0);if(t[0]>t[2])e[0]=t[2],e[2]=t[0];if(t[1]>t[3])e[1]=t[3],e[3]=t[1];return e}static intersect(t,e){let s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;let n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));if(n>r)return null;return[s,n,i,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,h){if(l<=0||l>=1)return;let c=1-l,d=l*l,u=d*l,f=c*(c*(c*t+3*l*e)+3*d*s)+u*i,p=c*(c*(c*n+3*l*r)+3*d*a)+u*o;h[0]=Math.min(h[0],f),h[1]=Math.min(h[1],p),h[2]=Math.max(h[2],f),h[3]=Math.max(h[3],p)}static#e(t,e,s,i,n,r,a,o,l,h,c,d){if(Math.abs(l)<0.000000000001){if(Math.abs(h)>=0.000000000001)this.#t(t,e,s,i,n,r,a,o,-c/h,d);return}let u=h**2-4*c*l;if(u<0)return;let f=Math.sqrt(u),p=2*l;this.#t(t,e,s,i,n,r,a,o,(-h+f)/p,d),this.#t(t,e,s,i,n,r,a,o,(-h-f)/p,d)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}}function ra(t){return decodeURIComponent(escape(t))}var Gs=null,$i=null;function aa(t){if(!Gs)Gs=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,$i=new Map([["ſt","ſt"]]);return t.replaceAll(Gs,(e,s,i)=>s?s.normalize("NFKC"):$i.get(i))}function bn(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),na(t)}function oa(t,e,s){if(!Array.isArray(s)||s.length<2)return!1;let[i,n,...r]=s;if(!t(i)&&!Number.isInteger(i))return!1;if(!e(n))return!1;let a=r.length,o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(let l of r){if(typeof l==="number"||o&&l===null)continue;return!1}return!0}var Ie=()=>[],ai=()=>new Map,Js=()=>Object.create(null),la=()=>new Set;if(typeof Blob.prototype.bytes!=="function")Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())};if(typeof Response.prototype.bytes!=="function")Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())};if(typeof Iterator.prototype.join!=="function")Iterator.prototype.join=function(t){return[...this].join(t)};var mo=K(1701);function ut(t,e,s){return Math.min(Math.max(t,e),s)}class Xe{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;let o=(t[2]+t[0])/2,l=(t[3]+t[1])/2,h,c,d,u;if(i%=360,i<0)i+=360;switch(i){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a)d=-d,u=-u;let f,p,g,m;if(h===0)f=Math.abs(l-t[1])*s+n,p=Math.abs(o-t[0])*s+r,g=(t[3]-t[1])*s,m=(t[2]-t[0])*s;else f=Math.abs(o-t[0])*s+n,p=Math.abs(l-t[1])*s+r,g=(t[2]-t[0])*s,m=(t[3]-t[1])*s;this.transform=[h*s,c*s,d*s,u*s,f-h*s*o-d*s*l,p-c*s*o-u*s*l],this.width=g,this.height=m}get rawDims(){let t=this.viewBox;return j(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new Xe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){let s=[t,e];return L.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){let s=[t,e];return L.applyInverseTransform(s,this.transform),s}}class je{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(!je.shouldBuildText(a))return;else if(n?.attributes?.textContent)r=n.attributes.textContent;else if(n.value)r=n.value;if(r!==null)e.push({str:r});if(!n.children)return;for(let o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}var ha=/url\(|image-set\(/i,ca=/^on/i;class oi{static get _allowedHtmlElements(){return j(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return j(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return j(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return j(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return j(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){let r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null)t.textContent=r.value;if(n==="print")break;t.addEventListener("input",(a)=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn)t.setAttribute("checked",!0);else if(r.value===s.attributes.xfaOff)t.removeAttribute("checked");if(n==="print")break;t.addEventListener("change",(a)=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null)t.setAttribute("value",r.value);if(n==="print")break;t.addEventListener("input",(a)=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(let a of s.children)if(a.attributes.value===r.value)a.attributes.selected=!0;else if(Object.hasOwn(a.attributes,"selected"))delete a.attributes.selected}t.addEventListener("input",(a)=>{let o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;if(r.type==="radio")r.name=`${r.name}-${i}`;for(let[o,l]of Object.entries(r)){if(l===null||l===void 0)continue;if(ca.test(o))continue;if(i==="richText"&&!this._allowedRichTextAttributes.has(o))continue;switch(o){case"class":if(l.length)t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){let h=this._allowedRichTextStyles;for(let[c,d]of Object.entries(l))if(h.has(c)&&!ha.test(d))t.style[c]=d}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:if(!a||o!=="href"&&o!=="newWindow")t.setAttribute(o,l)}}if(a)n?.addLinkAttributes(t,r.href,r.newWindow);if(s&&r.dataId)this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){if(s==="richText")return!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null;if(e)return e===Mt&&this._allowedSvgElements.has(t)?document.createElementNS(Mt,t):null;return this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){let{annotationStorage:e,linkService:s,xfaHtml:i}=t,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");if(i.attributes)this.setAttributes({html:r,element:i,intent:n,linkService:s});let a=n!=="richText",o=t.div;if(o.append(r),t.viewport){let c=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=c}if(a)o.setAttribute("class","xfaLayer xfaFont");let l=[];if(i.children.length===0){if(i.value){let c=document.createTextNode(i.value);if(r.append(c),a&&je.shouldBuildText(i.name))l.push(c)}return{textDivs:l}}let h=[[i,-1,r]];while(h.length>0){let[c,d,u]=h.at(-1);if(d+1===c.children.length){h.pop();continue}let f=c.children[++h.at(-1)[1]];if(f===null)continue;let{name:p}=f;if(p==="#text"){let m=document.createTextNode(f.value);l.push(m),u.append(m);continue}let g=this.#t(p,f.attributes?.xmlns,n);if(!g)continue;if(u.append(g),f.attributes)this.setAttributes({html:g,element:f,storage:e,intent:n,linkService:s});if(f.children?.length>0)h.push([f,-1,g]);else if(f.value){let m=document.createTextNode(f.value);if(a&&je.shouldBuildText(p))l.push(m);g.append(m)}}for(let c of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))c.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){let{width:i,height:n}=t.attributes.style;return new Xe({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}class pe{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function li(t,e="text"){if(Be(t,document.baseURI)){let s=await fetch(t);if(!s.ok)throw Error(s.statusText);switch(e){case"blob":return s.blob();case"bytes":return s.bytes();case"json":return s.json()}return s.text()}return new Promise((s,i)=>{let n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e==="bytes"?"arraybuffer":e,n.onreadystatechange=()=>{if(n.readyState!==XMLHttpRequest.DONE)return;if(n.status===200||n.status===0){switch(e){case"bytes":s(new Uint8Array(n.response));return;case"blob":case"json":s(n.response);return}s(n.responseText);return}i(Error(n.statusText))},n.send(null)})}class Is extends ve{constructor(t,e=0){super(t,"RenderingCancelledException");this.extraDelay=e}}function Ps(t){let e=t.length,s=0;while(s<e&&t[s].trim()==="")s++;return t.substring(s,s+5).toLowerCase()==="data:"}function hi(t){return typeof t==="string"&&/\.pdf$/i.test(t)}function da(t){return[t]=t.split(/[#?]/,1),Ks(t)}function ua(t,e="document.pdf"){if(typeof t!=="string")return e;if(Ps(t))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=((o)=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(t);if(!i)return e;let n=(o)=>{try{let l=decodeURIComponent(o);if(l.includes("/")){if(l=Ks(l),l.length===4&&r.test(l))return o}return l}catch{return o}},r=/\.pdf$/i,a=Ks(i.pathname);if(r.test(a))return n(a);if(i.searchParams.size>0){let o=(h)=>[...h].findLast((c)=>r.test(c)),l=o(i.searchParams.values())??o(i.searchParams.keys());if(l)return n(l)}if(i.hash){let{hash:o}=i,l=-1;for(let{index:h}of o.matchAll(/\.pdf\b/gi))l=h;if(l>0){let h=l;while(h>0&&!"/?#=".includes(o[h-1]))h--;if(h<l)return n(o.slice(h,l+4))}}return e}class Qs{#t=new Map;times=[];time(t){if(this.#t.has(t))z(`Timer is already running for ${t}`);this.#t.set(t,Date.now())}timeEnd(t){if(!this.#t.has(t))z(`Timer has not been started for ${t}`);this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){let t=Math.max(...this.times.map((e)=>e.name.length));return this.times.map((e)=>`${e.name.padEnd(t)} ${e.end-e.start}ms
4
- `).join("")}}function Be(t,e){let s=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(s?.protocol??"")}function zt(t){t.preventDefault()}function At(t){t.preventDefault(),t.stopPropagation()}class gs{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!=="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;if(c=c>=0&&c<=59?c:0,l==="-")r+=h,a+=c;else if(l==="+")r-=h,a-=c;return new Date(Date.UTC(s,i,n,r,a,o))}}function Ye(t){if(t.startsWith("#")){let s=t.slice(1);return[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),s.length>=8?parseInt(s.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){let[s,i,n]=t.slice(4,-1).split(",").map((r)=>parseInt(r,10));return[s,i,n,1]}if(t.startsWith("rgba(")){let s=t.slice(5,-1).split(",");return[parseInt(s[0],10),parseInt(s[1],10),parseInt(s[2],10),parseFloat(s[3])]}let e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);if(e)return[Math.round(parseFloat(e[1])*255),Math.round(parseFloat(e[2])*255),Math.round(parseFloat(e[3])*255),e[4]!==void 0&&e[4]!=="none"?parseFloat(e[4]):1];return null}function Ke(t){let e=Ye(t);if(!e)return z(`Not a valid color format: "${t}"`),[0,0,0];return e.slice(0,3)}function fa(t){let e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(let s of t.keys()){e.style.color=s;let i=window.getComputedStyle(e).color;t.set(s,Ke(i))}e.remove()}function dt(t){let{a:e,b:s,c:i,d:n,e:r,f:a}=t.getTransform();return[e,s,i,n,r,a]}function Yt(t){let{a:e,b:s,c:i,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,s,i,n,r,a]}function ge(t,e,s=!1,i=!0){if(e instanceof Xe){let{pageWidth:n,pageHeight:r}=e.rawDims,{style:a}=t,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;if(!s||e.rotation%180===0)a.width=o,a.height=l;else a.width=l,a.height=o}if(i)t.setAttribute("data-main-rotation",e.rotation)}class Wt{constructor(){let{pixelRatio:t}=Wt;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let r=1/0,a=1/0,o=1/0;if(s=Wt.capPixels(s,n),s>0)r=Math.sqrt(s/(t*e));if(i!==-1)a=i/t,o=i/e;let l=Math.min(r,a,o);if(this.sx>l||this.sy>l)return this.sx=l,this.sy=l,!0;return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}var Zs=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class An{static get isDarkMode(){return j(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class Sn{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:s}=window.getComputedStyle(t);return t.remove(),j(this,"commentForegroundColor",Ke(s))}}function pa(t,e){e=ut(e??1,0,1);let s=255*(1-e);return t.map((i)=>Math.round(i*e+s))}function Gi(t,e){let s=t[0]/255,i=t[1]/255,n=t[2]/255,r=Math.max(s,i,n),a=Math.min(s,i,n),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{let l=r-a;switch(e[1]=o<0.5?l/(r+a):l/(2-r-a),r){case s:e[0]=((i-n)/l+(i<n?6:0))*60;break;case i:e[0]=((n-s)/l+2)*60;break;case n:e[0]=((s-i)/l+4)*60;break}}e[2]=o}function qs(t,e){let s=t[0],i=t[1],n=t[2],r=(1-Math.abs(2*n-1))*i,a=r*(1-Math.abs(s/60%2-1)),o=n-r/2;switch(Math.floor(s/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o;break}}function ti(t){return t<=0.03928?t/12.92:((t+0.055)/1.055)**2.4}function Vi(t,e,s){qs(t,s),s.map(ti);let i=0.2126*s[0]+0.7152*s[1]+0.0722*s[2];qs(e,s),s.map(ti);let n=0.2126*s[0]+0.7152*s[1]+0.0722*s[2];return i>n?(i+0.05)/(n+0.05):(n+0.05)/(i+0.05)}var zi=new Map;function ga(t,e){let s=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776,i=zi.get(s);if(i)return i;let n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);Gi(t,a);let o=n.subarray(6,9);Gi(e,o);let l=o[2]<0.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Vi(a,o,r)<h){let c,d;if(l)c=a[2],d=1;else c=0,d=a[2];let u=0.005;while(d-c>u){let f=a[2]=(c+d)/2;if(l===Vi(a,o,r)<h)c=f;else d=f}a[2]=l?d:c}return qs(a,r),i=L.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),zi.set(s,i),i}function wn({html:t,dir:e,className:s},i){let n=document.createDocumentFragment();if(typeof t==="string"){let r=document.createElement("p");r.dir=e||"auto";let a=t.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){let h=a[o];if(r.append(document.createTextNode(h)),o<l-1)r.append(document.createElement("br"))}n.append(r)}else oi.render({xfaHtml:t,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",s),i.append(n)}function xn(t){let e=new Path2D;if(!t)return e;for(let s=0,i=t.length;s<i;)switch(t[s++]){case ke.moveTo:e.moveTo(t[s++],t[s++]);break;case ke.lineTo:e.lineTo(t[s++],t[s++]);break;case ke.curveTo:e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);break;case ke.quadraticCurveTo:e.quadraticCurveTo(t[s++],t[s++],t[s++],t[s++]);break;case ke.closePath:e.closePath();break;default:z(`Unrecognized drawing path operator: ${t[s-1]}`);break}return e}var vo=K(4972),yo=K(8454),bo=K(9452),Ao=K(4979),So=K(3579),wo=K(3110),xo=K(9314),Eo=K(1148),To=K(116),Co=K(9112);class _e{#t=null;#e=null;#s;#i=null;#n=null;#a=null;#r=null;#o=null;static#l=null;constructor(t){this.#s=t,_e.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#s._uiManager._signal;if(e instanceof AbortSignal&&!e.aborted)t.addEventListener("contextmenu",zt,{signal:e}),t.addEventListener("pointerdown",_e.#h,{signal:e});let s=this.#i=document.createElement("div");s.className="buttons",t.append(s);let i=this.#s.toolbarPosition;if(i){let{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#h(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,At(t)}#d(t){this.#s._focusEventsAllowed=!0,At(t)}#f(t){let e=this.#s._uiManager._signal;if(!(e instanceof AbortSignal)||e.aborted)return!1;return t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",zt,{signal:e}),!0}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#n?.shown(),this.#a?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");if(s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",_e.#l[t]),this.#f(s))s.addEventListener("click",(i)=>{e.delete()},{signal:e._signal});this.#i.append(s)}get#g(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#i.append(e,this.#g),this.#n=t}addComment(t,e=null){if(this.#a)return;let s=t.renderForToolbar();if(!s)return;this.#f(s);let i=this.#r=this.#g;if(!e)this.#i.append(s,i);else this.#i.insertBefore(s,e),this.#i.insertBefore(i,e);this.#a=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;let e=t.renderButton();this.#f(e),this.#i.append(e,this.#g)}async addEditSignatureButton(t){let e=this.#o=await t.renderEditButton(this.#s);this.#f(e),this.#i.append(e,this.#g)}removeButton(t){switch(t){case"comment":this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null;break}}async addButton(t,e){switch(t){case"colorPicker":if(e)this.addColorPicker(e);break;case"altText":if(e)await this.addAltText(e);break;case"editSignature":if(e)await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":if(e)this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;let i=this.#i.querySelector(s);if(!i)return;if(t==="comment")this.addComment(e,i)}updateEditSignatureButton(t){if(this.#o)this.#o.title=t}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class En{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;let e=this.#s._signal;if(e instanceof AbortSignal&&!e.aborted)t.addEventListener("contextmenu",zt,{signal:e});let s=this.#t=document.createElement("div");if(s.className="buttons",t.append(s),this.#s.hasCommentManager())this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")});return this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#n(t,e){let s=0,i=0;for(let n of t){let r=n.y+n.height;if(r<s)continue;let a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}if(e){if(a>i)i=a}else if(a<i)i=a}return[e?1-i:i,s]}show(t,e,s){let[i,n]=this.#n(e,s),{style:r}=this.#e||=this.#i();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#a(t,e,s,i){let n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);let r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);let a=this.#s._signal;if(a instanceof AbortSignal&&!a.aborted)n.addEventListener("contextmenu",zt,{signal:a}),n.addEventListener("click",i,{signal:a});this.#t.append(n)}}var ma="59968104-cc61-4cf9-b570-014b35b3709c",Vs=Object.freeze({internal:ma});function Tn(t,e,s){for(let i of s)e.addEventListener(i,t[i].bind(t))}class at{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(at.#e||=new Set).add(t)}static setPointer(t,e){at.#t||=e,at.#i??=t}static setTimeStamp(t){at.#s=t}static isSamePointerId(t){return at.#t===t}static isSamePointerIdOrRemove(t){if(at.#t===t)return!0;return at.#e?.delete(t),!1}static isSamePointerType(t){return at.#i===t}static isInitializedAndDifferentPointerType(t){return at.#i!==null&&!at.isSamePointerType(t)}static isSameTimeStamp(t){return at.#s===t}static isUsingMultiplePointers(){return at.#e?.size>=1}static clearPointerType(){at.#i=null}static clearPointerIds(){at.#t=NaN,at.#e=null}static clearTimeStamp(){at.#s=NaN}}class Cn{#t=0;get id(){return`${Ce}${this.#t++}`}}class ci{#t=bn();#e=0;#s=null;static get _isSVGFittingCanvas(){let t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Mt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;let n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return j(this,"_isSVGFittingCanvas",n)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e==="string")s.url=e,i=await li(e,"blob");else if(e instanceof File)i=s.file=e;else if(e instanceof Blob)i=e;if(i.type==="image/svg+xml"){let n=ci._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{let c=s.svgUrl=r.result;a.src=await n?`${c}#svgView(preserveAspectRatio(none))`:c},a.onerror=r.onerror=h});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){z(i),s=null}if(this.#s.set(t,s),s)this.#s.set(s.id,s);return s}async getFromFile(t){let{lastModified:e,name:s,size:i,type:n}=t;return this.#i(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){let s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;let i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){let e=this.#s.get(t);if(!e?.isSvg)return null;return e.svgUrl}deleteId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return;if(e.refCounter-=1,e.refCounter!==0)return;let{bitmap:s}=e;if(!e.url&&!e.file){let i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class In{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i)t();if(this.#e)return;let o={cmd:t,undo:e,post:s,type:n};if(this.#i===-1){if(this.#t.length>0)this.#t.length=0;this.#i=0,this.#t.push(o);return}if(r&&this.#t[this.#i].type===n){if(a)o.undo=this.#t[this.#i].undo;this.#t[this.#i]=o;return}let l=this.#i+1;if(l===this.#s)this.#t.splice(0,1);else if(this.#i=l,l<this.#t.length)this.#t.splice(l);this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i===-1)return;for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}destroy(){this.#t=null}}class Ft{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:e}=ot.platform;for(let[s,i,n={}]of t){let r=s.some((a)=>a.startsWith("mac+"));for(let a of s){let o=a;if(r){let c=a.startsWith("mac+");if(e!==c)continue;if(c)o=a.slice(4)}let[l,h]=Ft.#t(o);if(l===null)continue;this.callbacks.getOrInsertComputed(l,Ie).push({callback:i,options:n,modifiers:h})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;let n=i.toUpperCase(),r=Ft[n];if(r){s|=r;continue}if(e!==null){z(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":i}if(e===null)z(`KeyboardManager: no key found in shortcut "${t}"`);return[e,s]}static#e(t){let e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);if(!e)return null;return e[1]?.toLowerCase()??e[2]}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;let h=Ft.#e(e.code);if(h===null||h===e.key)return;if(s=this.callbacks.get(h),!s)return}let i=(e.altKey?Ft.ALT:0)|(e.ctrlKey?Ft.CTRL:0)|(e.metaKey?Ft.META:0)|(e.shiftKey?Ft.SHIFT:0),n=s.find((h)=>h.modifiers===i);if(!n)return;let{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=n;if(l&&!l(t,e))return;if(r.bind(t,...o,e)(),!a)At(e)}}class di{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return fa(t),j(this,"_colors",t)}convert(t){let e=Ke(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return di._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);if(!e)return t;return L.makeHexColor(...e)}}class ae{#t=new AbortController;#e=null;#s=null;#i=new Map;#n=new Map;#a=null;#r=null;#o=null;#l=null;#h=null;#u=new In;#d=null;#f=null;#g=null;#m=0;#c=new Set;#p=null;#v=null;#y=new Set;_editorUndoBar=null;#b=!1;#A=!1;#x=!1;#w=null;#E=null;#T=null;#O=null;#P=!1;#I=null;#D=new Cn;#R=!1;#k=!1;#U=!1;#L=null;#F=null;#V=null;#B=null;#j=null;#C=Y.NONE;#S=new Set;#_=null;#$=null;#z=null;#J=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#W=null;#X=null;#tt=null;#et=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=ae.prototype,e=(r)=>r.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){let{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return j(this,"_keyboardManager",new Ft([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,l,h,c,d,u,f,p,g){let m=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=i,this.#d=n,this.#$=r,this.#Y=o,this._eventBus=a;let v={signal:m,...Vs};a.on("editingaction",this.onEditingAction.bind(this),v),a.on("pagechanging",this.onPageChanging.bind(this),v),a.on("scalechanging",this.onScaleChanging.bind(this),v),a.on("rotationchanging",this.onRotationChanging.bind(this),v),a.on("setpreference",this.onSetPreference.bind(this),v),a.on("switchannotationeditorparams",(y)=>this.updateParams(y.type,y.value),v),window.addEventListener("pointerdown",()=>{this.#k=!0},{capture:!0,signal:m}),window.addEventListener("pointerup",()=>{this.#k=!1},{capture:!0,signal:m}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:m}),this.#lt(),this.#pt(),this.#it(),this.#l=o.annotationStorage,this.#w=o.filterFactory,this.#z=l,this.#O=h||null,this.#b=c,this.#A=d,this.#x=u,this.#j=f||null,this.viewParameters={realScale:pe.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=g!==!1,n?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#n.values())t.destroy();if(this.#n.clear(),this.#i.clear(),this.#y.clear(),this.#B?.clear(),this.#e=null,this.#S.clear(),this.#u.destroy(),this.#o?.destroy(),this.#d?.destroy(),this.#$?.destroy(),this.#I?.hide(),this.#I=null,this.#V?.destroy(),this.#V=null,this.#s=null,this.#E)clearTimeout(this.#E),this.#E=null;if(this.#W)clearTimeout(this.#W),this.#W=null;this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#j}get useNewAltTextFlow(){return this.#A}get useNewAltTextWhenAddingImage(){return this.#x}get hcmFilter(){return j(this,"hcmFilter",this.#z?this.#w.addHCMFilter(this.#z.foreground,this.#z.background):"none")}get direction(){return j(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return j(this,"_highlightColors",this.#O?new Map(this.#O.split(",").map((t)=>(t=t.split("=").map((e)=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return j(this,"highlightColors",null);let e=new Map,s=!!this.#z;for(let[i,n]of t){let r=i.endsWith("_HCM");if(s&&r){e.set(i.replace("_HCM",""),n);continue}if(!s&&!r)e.set(i,n)}return j(this,"highlightColors",e)}get highlightColorNames(){return j(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t)=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){if(t)this.unselectAll(),this.disableUserSelect(!0);else this.disableUserSelect(!1);this.#g=t}setMainHighlightColorPicker(t){this.#V=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,s,i){this.#d?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#n.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){let s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#d?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#n.has(t-1))return;let{resolve:e,promise:s}=Promise.withResolvers(),i=(n)=>{if(n.pageNumber===t)this._eventBus.off("editorsrendered",i),e()};this._eventBus.on("editorsrendered",i,Vs),await s}getSignature(t){this.#$?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#$}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Vs}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#x=e;break}}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();if(this.#n.delete(t),this.#m===t)this.#m=0}focusMainContainer(){this.#X.focus()}findParent(t,e){for(let s of this.#n.values()){let{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*pe.PDF_TO_CSS_UNITS;for(let e of this.#y)e.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let s of this.#n.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){let s=document.getSelection();if(!s||s.isCollapsed)return;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a}=s,o=s.toString(),h=this.#q(s).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;s.empty();let d=this.#st(h),u=this.#C===Y.NONE,f=()=>{let p=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a,text:o});if(u)this.showAllEditors("highlight",!0,!0);if(e)p?.editComment()};if(u){this.switchToMode(Y.HIGHLIGHT,f);return}f()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#q(t).closest(".textLayer"),i=this.getSelectionBoxes(s);if(!i)return;this.#I||=new En(this),this.#I.show(s,i,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;let e=`${Ce}${t}`,s=this.#l.getRawValue(e);if(s)this.#l.remove(e);return s}addToAnnotationStorage(t){if(!t.isEmpty()&&this.#l&&!this.#l.has(t.id))this.#l.setValue(t.id,t)}a11yAlert(t,e=null){let s=this.#et;if(!s)return;if(s.setAttribute("data-l10n-id",t),e)s.setAttribute("data-l10n-args",JSON.stringify(e));else s.removeAttribute("data-l10n-args")}#ot(){let t=document.getSelection();if(!t||t.isCollapsed){if(this.#_)this.#I?.hide(),this.#_=null,this.#M({hasSelectedText:!1});return}let{anchorNode:e}=t;if(e===this.#_)return;let i=this.#q(t).closest(".textLayer");if(!i){if(this.#_)this.#I?.hide(),this.#_=null,this.#M({hasSelectedText:!1});return}if(this.#I?.hide(),this.#_=e,this.#M({hasSelectedText:!0}),this.#C!==Y.HIGHLIGHT&&this.#C!==Y.NONE)return;if(this.#C===Y.HIGHLIGHT)this.showAllEditors("highlight",!0,!0);if(this.#P=this.isShiftKeyDown,!this.isShiftKeyDown){let n=this.#C===Y.HIGHLIGHT?this.#st(i):null;if(n?.toggleDrawing(),this.#k){let r=new AbortController,a=this.combinedSignal(r),o=(l)=>{if(l.type==="pointerup"&&l.button!==0)return;if(r.abort(),n?.toggleDrawing(!0),l.type==="pointerup")this.#Q("main_toolbar")};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else n?.toggleDrawing(!0),this.#Q("main_toolbar")}}#Q(t=""){if(this.#C===Y.HIGHLIGHT)this.highlightSelection(t);else if(this.#b)this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ht(){if(this.#T)return;this.#T=new AbortController;let t=this.combinedSignal(this.#T);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#T?.abort(),this.#T=null}blur(){if(this.isShiftKeyDown=!1,this.#P)this.#P=!1,this.#Q("main_toolbar");if(!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#S)if(e.div.contains(t)){this.#F=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#F)return;let[t,e]=this.#F;this.#F=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#it(){if(this.#L)return;this.#L=new AbortController;let t=this.combinedSignal(this.#L);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#L?.abort(),this.#L=null}#ut(){if(this.#f)return;this.#f=new AbortController;let t=this.combinedSignal(this.#f);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#ft(){this.#f?.abort(),this.#f=null}#pt(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#it(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let s of this.#v)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let s of this.#v)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let s of this.#S){let i=s.serialize(!0);if(i)e.push(i)}if(e.length===0)return;t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let n of e.items)for(let r of this.#v)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){z(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let i=this.currentLayer;try{let n=[];for(let o of s){let l=await i.deserialize(o);if(!l)return;n.push(l)}let r=()=>{for(let o of n)this.#nt(o);this.#rt(n)},a=()=>{for(let o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){z(`paste: "${n.message}".`)}}keydown(t){if(!this.isShiftKeyDown&&t.key==="Shift")this.isShiftKeyDown=!0;if(this.#C!==Y.NONE&&!this.isEditorHandlingKeyboard)ae._keyboardManager.exec(this,t)}keyup(t){if(this.isShiftKeyDown&&t.key==="Shift"){if(this.isShiftKeyDown=!1,this.#P)this.#P=!1,this.#Q("main_toolbar")}}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(let i of this.#r.get(t)||[])i.pageIndex=e;let s=this.#a.get(t);if(s)if(s.pageIndex=e,this.#n.set(e,s),this.#R)s.enable();else s.disable()}startUpdatePages(){this.#a=new Map(this.#n),this.#n.clear();let t=this.#r=new Map,e=(s)=>{t.getOrInsertComputed(s.pageIndex,Ie).push(s)};for(let s of this.#i.values())e(s);for(let[s,i]of this.#l)if(s.startsWith(Ce)&&!this.#i.has(s)&&Number.isInteger(i?.pageIndex))e(i)}endUpdatePages(){this.#a=null,this.#r=null}clonePage(t,e){for(let s of this.getEditors(t)){let i=s.serialize(s.mode!==Y.HIGHLIGHT);if(!i)continue;i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#l.setValue(i.id,i)}}findClonesForPage(t){let e=[],{pageIndex:s}=t;for(let[i,n]of this.#l)if(n.pageIndex===s&&n.isClone)this.#l.remove(i),e.push(t.deserialize(n).then((r)=>{if(r)r.isClone=!0,t.addOrRebuild(r)}));return Promise.all(e)}#M(t){if(Object.entries(t).some(([s,i])=>this.#K[s]!==i)){if(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#C===Y.HIGHLIGHT&&t.hasSelectedEditor===!1)this.#G([[q.HIGHLIGHT_FREE,!0]])}}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){if(t)this.#ht(),this.#ut(),this.#M({isEditing:this.#C!==Y.NONE,isEmpty:this.#Z(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1});else this.#ct(),this.#ft(),this.#M({isEditing:!1}),this.disableUserSelect(!1)}registerEditorTypes(t){if(this.#v)return;this.#v=t;for(let e of this.#v)this.#G(e.defaultPropertiesToUpdate)}getId(){return this.#D.id}get currentLayer(){return this.#n.get(this.#m)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#m}addLayer(t){if(this.#n.set(t.pageIndex,t),this.#R)t.enable();else t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1,r=!1){if(this.#C===t)return;if(this.#H){if(await this.#H.promise,!this.#H)return}if(this.#H=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===Y.POPUP)this.#d?.hideSidebar();if(this.#d?.destroyPopup(),this.#C=t,t===Y.NONE){this.setEditingState(!1),this.#mt();for(let a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(let a of this.#i.values())a.addStandaloneCommentButton();if(t===Y.SIGNATURE)await this.#$?.loadSignatures();if(s)at.clearPointerType();this.setEditingState(!0),await this.#gt(),this.unselectAll();for(let a of this.#n.values())a.updateMode(t);if(t===Y.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#v.map((l)=>l._editorType)));let a=new Set,o=[];for(let l of this.#i.values()){let{annotationElementId:h,hasComment:c,deleted:d}=l;if(h)a.add(h);if(c&&!d)o.push(l.getData())}for(let l of this.#s){let{id:h,popupRef:c,contentsObj:d}=l;if(c&&d?.str&&!a.has(h)&&!this.#c.has(h))o.push(l)}this.#d?.showSidebar(o)}if(!e){if(i)this.addNewEditorFromKeyboard();this.#H.resolve();return}for(let a of this.#i.values())if(a.uid===e)if(this.setSelected(a),r)a.editComment();else if(n)a.enterInEditMode();else a.focus();else a.unselect();this.#H.resolve()}addNewEditorFromKeyboard(){if(this.currentLayer.canCreateNewEmptyEditor())this.currentLayer.addNewEditor()}updateToolbar(t){if(t.mode===this.#C)return;this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(!this.#v)return;switch(t){case q.CREATE:this.currentLayer.addNewEditor(e);return;case q.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#J||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(let s of this.#S)s.updateParams(t,e);else for(let s of this.#v)s.updateDefaultParams(t,e)}showAllEditors(t,e,s=!1){for(let n of this.#i.values())if(n.editorType===t)n.show(e);if((this.#J?.get(q.HIGHLIGHT_SHOW_ALL)??!0)!==e)this.#G([[q.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#U===t)return;this.#U=t;for(let e of this.#n.values()){if(t)e.disableClick();else e.enableClick();e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#R){this.#R=!0;let t=[];for(let e of this.#n.values())t.push(e.enable());await Promise.all(t);for(let e of this.#i.values())e.enable()}}#mt(){if(this.unselectAll(),this.#R){this.#R=!1;for(let t of this.#n.values())t.disable();for(let t of this.#i.values())t.disable()}}*getEditors(t){for(let e of this.#i.values())if(e.pageIndex===t)yield e}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){if(t.div.contains(document.activeElement)){if(this.#E)clearTimeout(this.#E);this.#E=setTimeout(()=>{this.focusMainContainer(),this.#E=null},0)}if(this.#i.delete(t.id),t.annotationElementId)this.#B?.delete(t.annotationElementId);if(this.unselect(t),!t.annotationElementId||!this.#c.has(t.annotationElementId))this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#c.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#c.has(t)}removeDeletedAnnotationElement(t){this.#c.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#nt(t){let e=this.#n.get(t.pageIndex);if(e)e.addOrRebuild(t);else this.addEditor(t),this.addToAnnotationStorage(t)}setActiveEditor(t){if(this.#e===t)return;if(this.#e=t,t)this.#G(t.propertiesToUpdate)}get#vt(){let t=null;for(t of this.#S);return t}updateUI(t){if(this.#vt===t)this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#S.has(t)){this.#S.delete(t),t.unselect(),this.#M({hasSelectedEditor:this.hasSelection});return}this.#S.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#M({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#g?.commitOrRemove();for(let e of this.#S)if(e!==t)e.unselect();this.#d?.destroyPopup(),this.#S.clear(),this.#S.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#M({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#S.values().next().value}unselect(t){t.unselect(),this.#S.delete(t),this.#M({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#S.size!==0}get isEnterHandled(){return this.#S.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#M({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Z()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#M({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Z()})}addCommands(t){this.#u.add(t),this.#M({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Z()})}cleanUndoStack(t){this.#u.cleanType(t)}#Z(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(let t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#S],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(let n of e)n.remove()},i=()=>{for(let n of e)this.#nt(n)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#rt(t){for(let e of this.#S)e.unselect();this.#S.clear();for(let e of t){if(e.isEmpty())continue;this.#S.add(e),e.select()}this.#M({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#S)t.commit();this.#rt(this.#i.values())}unselectAll(){if(this.#e){if(this.#e.commitOrRemove(),this.#C!==Y.NONE)return}if(this.#g?.commitOrRemove())return;if(this.#d?.destroyPopup(),!this.hasSelection)return;for(let t of this.#S)t.unselect();this.#S.clear(),this.#M({hasSelectedEditor:!1})}translateSelectedEditors(t,e,s=!1){if(!s)this.commitOrRemove();if(!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;let[i,n]=this.#N,r=[...this.#S],a=1000;if(this.#W)clearTimeout(this.#W);this.#W=setTimeout(()=>{this.#W=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let o of r)if(this.#i.has(o.id))o.translateInPage(i,n),o.translationDone()},undo:()=>{for(let o of r)if(this.#i.has(o.id))o.translateInPage(-i,-n),o.translationDone()},mustExec:!1})},a);for(let o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(!this.hasSelection)return;this.disableUserSelect(!0),this.#p=new Map;for(let t of this.#S)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);let t=this.#p;this.#p=null;let e=!1;for(let[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;let s=(i,n,r,a)=>{if(this.#i.has(i.id)){let o=this.#n.get(a);if(o)i._setParentAndPosition(o,n,r);else i.pageIndex=a,i.x=n,i.y=r}};return this.addCommands({cmd:()=>{for(let[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(let[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(!this.#p)return;for(let s of this.#p.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){let e=this.getLayer(t.pageIndex);if(e)e.changeParent(t),e.addOrRebuild(t);else this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild()}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#S.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==Y.NONE}get imageManager(){return j(this,"imageManager",new ci)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;let{x:s,y:i,width:n,height:r}=t.getBoundingClientRect(),a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,h,c,d)=>({x:(h-i)/r,y:1-(l+c-s)/n,width:d/r,height:c/n});break;case"180":a=(l,h,c,d)=>({x:1-(l+c-s)/n,y:1-(h+d-i)/r,width:c/n,height:d/r});break;case"270":a=(l,h,c,d)=>({x:1-(h+d-i)/r,y:(l-s)/n,width:d/r,height:c/n});break;default:a=(l,h,c,d)=>({x:(l-s)/n,y:(h-i)/r,width:c/n,height:d/r});break}let o=[];for(let l=0,h=e.rangeCount;l<h;l++){let c=e.getRangeAt(l);if(c.collapsed)continue;for(let{x:d,y:u,width:f,height:p}of c.getClientRects()){if(f===0||p===0)continue;o.push(a(d,u,f,p))}}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#h||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#h?.delete(t)}renderAnnotationElement(t){let e=this.#h?.get(t.data.id);if(!e)return;let s=this.#l.getRawValue(e);if(!s)return;if(this.#C===Y.NONE&&!s.hasBeenModified)return;s.renderAnnotationElement(t)}setMissingCanvas(t,e,s){let i=this.#B?.get(t);if(!i)return;i.setCanvas(e,s),this.#B.delete(t)}addMissingCanvas(t,e){(this.#B||=new Map).set(t,e)}}class Zt{#t=null;#e=!1;#s=null;#i=null;#n=null;#a=null;#r=!1;#o=null;#l=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#d=t._uiManager.useNewAltTextFlow,Zt.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){Zt._l10n??=t}async render(){let t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#i=document.createElement("span");if(t.append(e),this.#d)t.classList.add("new"),t.setAttribute("data-l10n-id",Zt.#f.missing),e.setAttribute("data-l10n-id",Zt.#f["missing-label"]);else t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label");let s=this.#l._uiManager._signal;t.addEventListener("contextmenu",zt,{signal:s}),t.addEventListener("pointerdown",(n)=>n.stopPropagation(),{signal:s});let i=(n)=>{if(n.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#d)this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(n)=>{if(n.target===t&&n.key==="Enter")this.#r=!0,i(n)},{signal:s}),await this.#m(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){if(!this.#s)return;this.#s.focus({focusVisible:this.#r}),this.#r=!1}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){if(this.#t!==null)return;this.#h=t,this.#u=await Zt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m()}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;if(!t&&this.#h===e)e=this.#u;return{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){if(s)this.#h=s,this.#u=i;if(this.#t===t&&this.#e===e)return;if(!n)this.#t=t,this.#e=e;this.#m()}toggle(t=!1){if(!this.#s)return;if(!t&&this.#a)clearTimeout(this.#a),this.#a=null;this.#s.disabled=!t}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#n=null,this.#o?.remove(),this.#o=null}async#m(){let t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Zt.#f[this.#g]),this.#i?.setAttribute("data-l10n-id",Zt.#f[`${this.#g}-label`]),!this.#t){this.#n?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;let i=100,n=this.#l._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#n.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{if(this.#a)clearTimeout(this.#a),this.#a=null;this.#n?.classList.remove("show")},{signal:n})}if(this.#e)e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else e.removeAttribute("data-l10n-id"),e.textContent=this.#t;if(!e.parentNode)t.append(e);this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class Fe{#t=null;#e=null;#s=!1;#i=null;#n=null;#a=null;#r=null;#o=null;#l=!1;#h=null;constructor(t){this.#i=t}renderForToolbar(){let t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){let t=this.#t=document.createElement("button");t.className="annotationCommentButton";let e=this.#i.commentButtonPosition;if(e){let{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let i=this.#i.commentButtonColor;if(i)s.backgroundColor=i}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;let t=this.#i.commentButtonColor;if(t)this.#t.style.backgroundColor=t;this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#h)return this.#h;if(!this.#t)return null;let{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/a]}set commentPopupPositionInLayer(t){this.#h=t}hasDefaultPopupPosition(){return this.#h===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#t)return;this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e}#u(t,e){if(!this.#i._uiManager.hasCommentManager())return null;if(t.tabIndex="0",t.ariaHasPopup="dialog",e)t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button");else t.ariaControlsElements=[this.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button");let s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;if(t.addEventListener("contextmenu",zt,{signal:s}),e)t.addEventListener("focusin",(n)=>{this.#i._focusEventsAllowed=!1,At(n)},{capture:!0,signal:s}),t.addEventListener("focusout",(n)=>{this.#i._focusEventsAllowed=!0,At(n)},{capture:!0,signal:s});t.addEventListener("pointerdown",(n)=>n.stopPropagation(),{signal:s});let i=(n)=>{if(n.preventDefault(),t===this.#e)this.edit();else this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(n)=>{if(n.target===t&&n.key==="Enter")this.#s=!0,i(n)},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){let e=this.commentPopupPositionInLayer,s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;let{width:h,height:c,x:d,y:u}=this.#i;s=d+s*h,i=u+i*c}let n=this.#i.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#i._uiManager.editComment(this.#i,r+s*o,a+i*l,{...t,parentDimensions:n})}finish(){if(!this.#e)return;this.#e.focus({focusVisible:this.#s}),this.#s=!1}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#n}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#r)this.#a=null;if(t===null){this.#r="",this.#l=!0;return}this.#r=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#r=t,this.#a=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#n=t,this.data=t,this.#o=null,this.#a=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#r="",this.#a=null,this.#o=null,this.#i=null,this.#s=!1,this.#l=!1}}function Wi(t){t.preventDefault()}var Xi=0.0001;function zs(t){if(t.cancelable)return At(t),!0;return t.stopPropagation(),!1}class ui{#t;#e=!1;#s=null;#i;#n;#a;#r;#o;#l=!1;#h=null;#u;#d=new Set;#f=null;#g;#m=null;#c=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#i=e,this.#n=i,this.#a=n,this.#r=r,this.#o=a,this.#g=new AbortController,this.#u=AbortSignal.any([o,this.#g.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Wt.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/Wt.pixelRatio}#p(t){if(this.#i?.())return;this.#y(t);let e=this.#d;for(let{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#v();return}if(!this.#m){this.#m=new AbortController;let s=AbortSignal.any([this.#u,this.#m.signal]),i=this.#t,n={signal:s,capture:!1,passive:!1};i.addEventListener("touchmove",this.#x.bind(this),n);let r=this.#w.bind(this);i.addEventListener("touchend",r,n),i.addEventListener("touchcancel",r,n),n.capture=!0,i.addEventListener("pointerdown",At,n),i.addEventListener("pointermove",At,n),i.addEventListener("pointercancel",Wi,n),i.addEventListener("pointerup",Wi,n),this.#n?.()}this.#l=zs(t),this.#A(t)}#v(){if(this.#h)return;let t=this.#h=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,i={capture:!0,signal:e,passive:!1},n=(r)=>{if(r.pointerType==="touch")this.#h?.abort(),this.#h=null};s.addEventListener("pointerdown",(r)=>{if(r.pointerType==="touch")At(r),n(r)},i),s.addEventListener("pointerup",n,i),s.addEventListener("pointercancel",n,i)}#y(t){let e=this.#d;if(e.size===0)return;let s=this.#d=new Set;for(let{identifier:i}of t.touches)if(e.has(i))s.add(i)}#b(t){let e=this.#d,s=[];for(let i of t.touches)if(e.has(i.identifier))s.push(i);return s}#A(t){let e=this.#b(t);if(e.length!==2||this.#s?.()){this.#f=null;return}let[s,i]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2}}#x(t){if(!this.#f)return;let e=this.#b(t);if(e.length!==2)return;let s=this.#l;if(this.#l=zs(t),!this.#l)return;if(!s){this.#A(t);return}let[i,n]=e,{screenX:r,screenY:a}=i,{screenX:o,screenY:l}=n,h=this.#f,{touch0X:c,touch0Y:d,touch1X:u,touch1Y:f,panX:p,panY:g}=h,m=u-c,v=f-d,y=o-r,S=l-a,A=(i.clientX+n.clientX)/2,b=(i.clientY+n.clientY)/2;h.panX=A,h.panY=b;let w=A-p,x=b-g,T=(r+o)/2,E=(a+l)/2,I=Math.hypot(T-h.screenPanX,E-h.screenPanY);h.screenPanX=T,h.screenPanY=E;let C=Math.hypot(y,S),O=Math.hypot(m,v),D=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*I;if(C<Xi||O<Xi||Math.abs(O-C)<=D){if(w||x)this.#o?.(w,x);return}h.touch0X=r,h.touch0Y=a,h.touch1X=o,h.touch1Y=l;let k=Math.sign(C-O);if(!this.#e){if(this.#e=!0,this.#c=k,w||x)this.#o?.(w,x);return}if(this.#c){let R=this.#c;if(this.#c=0,k!==R&&Math.abs(C-O)<=2*I){if(this.#e=!1,w||x)this.#o?.(w,x);return}}this.#a?.([p,g],O,C,w,x)}#w(t){if(this.#y(t),this.#d.size>=2){this.#A(t);return}let e=!!this.#f;if(this.#E(),this.#d.size===1)this.#v();if(e)zs(t)}#E(){if(this.#f=null,this.#e=!1,this.#c=0,this.#l=!1,this.#m)this.#m.abort(),this.#m=null,this.#r?.()}destroy(){this.#E(),this.#d.clear(),this.#g?.abort(),this.#g=null,this.#h?.abort(),this.#h=null}}class H{#t=null;#e=null;#s=null;#i=null;#n=null;#a=!1;#r=null;#o="";#l=null;#h=null;#u=null;#d=null;#f=null;#g="";#m=!1;#c=null;#p=!1;#v=!1;#y=!1;#b=null;#A=0;#x=0;#w=null;#E=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#T=!1;#O=H._zIndex++;static _borderLineWidth=-1;static _colorManager=new di;static _zIndex=1;static _telemetryTimeout=1000;static get _resizerKeyboardManager(){let t=H.prototype._resizeWithKeyboard,{TRANSLATE_SMALL:e,TRANSLATE_BIG:s}=ae;return j(this,"_resizerKeyboardManager",new Ft([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],H.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return j(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new Pn({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(H._l10n??=t,H._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),H._l10nResizer??=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),H._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);H._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#T}set _isDraggable(t){this.#T=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#O}setParent(t){if(t!==null)this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions;else this.#N(),this.#d?.remove(),this.#d=null;this.parent=t}focusin(t){if(!this._focusEventsAllowed)return;if(!this.#m)this.parent.setSelected(this);else this.#m=!1}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;if(t.relatedTarget?.closest(`#${this.id}`))return;if(t.preventDefault(),!this.parent?.isMultipleSelection)this.commitOrRemove()}commitOrRemove(){if(this.isEmpty())this.remove();else this.commit()}commit(){if(!this.isInEditMode())return;this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){let[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}let[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#P([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:c,y:d}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,c,d))this.x-=Math.floor(this.x),this.y-=Math.floor(this.y)}let{x:r,y:a}=this,[o,l]=this.getBaseTranslation();r+=o,a+=l;let{style:h}=s;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=H,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[s,i]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=ut(n,0,s-a),r=ut(r,0,i-o);break;case 90:n=ut(n,0,s-o),r=ut(r,a,i);break;case 180:n=ut(n,a,s),r=ut(r,o,i);break;case 270:n=ut(n,o,s),r=ut(r,0,i-a);break}this.x=n/=s,this.y=r/=i;let[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#I(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return H.#I(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return H.#I(t,e,360-this.parentRotation)}#D(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){let{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#R(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let s of t){let i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#k.bind(this,s),{signal:e}),i.addEventListener("contextmenu",zt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#l)}#k(t,e){e.preventDefault();let{isMac:s}=ot.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#h=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#F.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",At,{passive:!1,signal:r}),window.addEventListener("contextmenu",zt,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#L()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#U(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#L(){if(!this.#u)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;let n=this.x,r=this.y,a=this.width,o=this.height;if(n===t&&r===e&&a===s&&o===i)return;this.addCommands({cmd:this.#U.bind(this,n,r,a,o),undo:this.#U.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#F(t,e){let[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=H.MIN_SIZE/s,h=H.MIN_SIZE/i,c=this.#D(this.rotation),d=(R,M)=>[c[0]*R+c[2]*M,c[1]*R+c[3]*M],u=this.#D(360-this.rotation),f=(R,M)=>[u[0]*R+u[2]*M,u[1]*R+u[3]*M],p,g,m=!1,v=!1;switch(t){case"topLeft":m=!0,p=(R,M)=>[0,0],g=(R,M)=>[R,M];break;case"topMiddle":p=(R,M)=>[R/2,0],g=(R,M)=>[R/2,M];break;case"topRight":m=!0,p=(R,M)=>[R,0],g=(R,M)=>[0,M];break;case"middleRight":v=!0,p=(R,M)=>[R,M/2],g=(R,M)=>[0,M/2];break;case"bottomRight":m=!0,p=(R,M)=>[R,M],g=(R,M)=>[0,0];break;case"bottomMiddle":p=(R,M)=>[R/2,M],g=(R,M)=>[R/2,0];break;case"bottomLeft":m=!0,p=(R,M)=>[0,M],g=(R,M)=>[R,0];break;case"middleLeft":v=!0,p=(R,M)=>[0,M/2],g=(R,M)=>[R,M/2];break}let y=p(a,o),S=g(a,o),A=d(...S),b=H._round(n+A[0]),w=H._round(r+A[1]),x=1,T=1,E,I;if(!e.fromKeyboard){let{screenX:R,screenY:M}=e,[_,U]=this.#h;[E,I]=this.screenToPageTranslation(R-_,M-U),this.#h[0]=R,this.#h[1]=M}else({deltaX:E,deltaY:I}=e);if([E,I]=f(E/s,I/i),m){let R=Math.hypot(a,o);x=T=Math.max(Math.min(Math.hypot(S[0]-y[0]-E,S[1]-y[1]-I)/R,1/a,1/o),l/a,h/o)}else if(v)x=ut(Math.abs(S[0]-y[0]-E),l,1)/a;else T=ut(Math.abs(S[1]-y[1]-I),h,1)/o;let C=H._round(a*x),O=H._round(o*T);A=d(...g(C,O));let D=b-A[0],k=w-A[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=C,this.height=O,this.x=D,this.y=k,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#v)return this._editToolbar;this._editToolbar=new _e(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,s]of t)await this._editToolbar.addButton(e,s);if(!this.hasComment)this._editToolbar.addButton("comment",this.addCommentButton());return this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#s?.destroy()}addContainer(t){let e=this._editToolbar?.div;if(e)e.before(t);else this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!this.#s){if(Zt.initialize(H._l10n),this.#s=new Zt(this),this.#t)this.#s.data=this.#t,this.#t=null}return this.#s}get altTextData(){return this.#s?.data}set altTextData(t){if(!this.#s)return;this.#s.data=t}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new Fe(this):null}addStandaloneCommentButton(){if(!this._uiManager.hasCommentManager())return;if(this.#n){if(this._uiManager.isEditingMode())this.#n.classList.remove("hidden");return}if(!this.hasComment)return;this.#n=this.#i.renderForStandalone(),this.div.append(this.#n)}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#n=null}hideStandaloneCommentButton(){this.#n?.classList.add("hidden")}get comment(){if(!this.#i)return null;let{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){if(this.#i||=new Fe(this),typeof t==="object"&&t!==null)this.#i.restoreData(t);else this.#i.data=t;if(this.hasComment)this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this);else this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this)}setCommentData({comment:t,popupRef:e,richText:s}){if(!e)return;if(this.#i||=new Fe(this),this.#i.setInitialText(t,s),!this.annotationElementId)return;let i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);if(i)this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new Fe(this),this.#i.edit(t)}toggleComment(t,e=void 0){if(this.hasComment)this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,i]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");if(t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId)t.setAttribute("data-l10n-id",this.defaultL10nId);if(!this._isVisible)t.classList.add("hidden");this.setInForeground(),this.#_();let[e,s]=this.parentDimensions;if(this.parentRotation%180!==0)t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`;let[i,n]=this.getInitialTranslation();return this.translate(i,n),Tn(this,t,["keydown","pointerdown","dblclick"]),this.#$(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#V(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#B(t,e,s){let n=0.7*(s/e)+1-0.7;if(n===1)return;let r=this.#D(this.rotation),a=(b,w)=>[r[0]*b+r[2]*w,r[1]*b+r[3]*w],[o,l]=this.parentDimensions,h=this.x,c=this.y,d=this.width,u=this.height,f=H.MIN_SIZE/o,p=H.MIN_SIZE/l;n=Math.max(Math.min(n,1/d,1/u),f/d,p/u);let g=H._round(d*n),m=H._round(u*n);if(g===d&&m===u)return;this.#c||=[h,c,d,u];let v=a(d/2,u/2),y=H._round(h+v[0]),S=H._round(c+v[1]),A=a(g/2,m/2);this.x=y-A[0],this.y=S-A[1],this.width=g,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#j(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#L()}pointerdown(t){let{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#S(t);return}this.#C(t)}#C(t){let{isMac:e}=ot.platform;if(t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e)this.parent.toggleSelected(this);else this.parent.setSelected(this)}#S(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=(l)=>{if(i.abort(),this.#r=null,this.#m=!1,!this._uiManager.endDragSession())this.#C(l);if(s)this._onStopDragging()};if(e)this.#A=t.clientX,this.#x=t.clientY,this.#r=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",(l)=>{if(!s)s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging();let{clientX:h,clientY:c,pointerId:d}=l;if(d!==this.#r){At(l);return}let[u,f]=this.screenToPageTranslation(h-this.#A,c-this.#x);this.#A=h,this.#x=c,this._uiManager.dragSelectedEditors(u,f),this.div.scrollIntoView({block:"nearest"})},r),window.addEventListener("touchmove",At,r),window.addEventListener("pointerdown",(l)=>{if(l.pointerType===this.#o){if(this.#E||l.isPrimary)a(l)}At(l)},r);let o=(l)=>{if(!this.#r||this.#r===l.pointerId){a(l);return}At(l)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){if(this.#b)clearTimeout(this.#b);this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,h=e/i,c=this.x*n,d=this.y*r,u=this.width*n,f=this.height*r;switch(s){case 0:return[c+l+a,r-d-h-f+o,c+l+u+a,r-d-h+o];case 90:return[c+h+a,r-d+l+o,c+h+f+a,r-d+l+u+o];case 180:return[c-l-u+a,r-d+h+o,c-l+a,r-d+h+f+o];case 270:return[c-h-f+a,r-d-l-u+o,c-h+a,r-d-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&H._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:s||h,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;return this.parent.setEditingState(!1),this.#v=!0,!0}disableEditMode(){if(!this.isInEditMode())return!1;return this.parent.setEditingState(!0),this.#v=!1,!0}isInEditMode(){return this.#v}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#_(){if(this.#f||!this.div)return;this.#f=new AbortController;let t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#$(){if(this.#E||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom)return;this.#E=new ui({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#V.bind(this),onPinching:this.#B.bind(this),onPinchEnd:this.#j.bind(this),signal:this._uiManager._signal})}rebuild(){this.#_(),this.#$()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){let i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;let[n,r]=i.pageDimensions,[a,o,l,h]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=l/n,i.height=h/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,!this.isEmpty())this.commit();if(this.#E?.destroy(),this.#E=null,this.parent)this.parent.remove(this);else this._uiManager.removeEditor(this);if(this.hideCommentPopup(),this.#b)clearTimeout(this.#b),this.#b=null;if(this.#N(),this.removeEditToolbar(),this.#w){for(let t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){if(this.isResizable)this.#R(),this.#l.classList.remove("hidden")}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[s,i,n,r]=this.getPDFRect();return[H._round(s+(n-s)*t),H._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#l.children;if(!this.#e){this.#e=Array.from(e);let r=this.#z.bind(this),a=this.#J.bind(this),o=this._uiManager._signal;for(let l of this.#e){let h=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,h),{signal:o}),l.setAttribute("data-l10n-id",H._l10nResizer[h])}}let s=this.#e[0],i=0;for(let r of e){if(r===s)break;i++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#l.append(this.#l.firstElementChild);else if(n>i)for(let a=0;a<n-i;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(let a of e){let l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",H._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#z(t){H._resizerKeyboardManager.exec(this,t)}#J(t){if(this.#y&&t.relatedTarget?.parentNode!==this.#l)this.#N()}#Y(t){this.#g=this.#y?t:""}#K(t){if(!this.#e)return;for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){if(!this.#y)return;this.#F(this.#g,{deltaX:t,deltaY:e,fromKeyboard:!0})}#N(){this.#y=!1,this.#K(-1),this.#L()}_stopResizingWithKeyboard(){this.#N(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{if(this.div?.classList.contains("selectedEditor"))this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}focus(){if(this.div&&!this.div.contains(document.activeElement))setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(!this.isSelected)return;if(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement))this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide(),this.#s?.toggleAltTextBadge(!0),this.hideCommentPopup()}hideCommentPopup(){if(this.hasComment)this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(!this.canChangeContent)return;this.enableEditMode(),this.div.focus()}dblclick(t){if(t.target.nodeName==="BUTTON")return;this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){if(this.#p=t,!this.parent)return;if(t)this.parent.setSelected(this),this.parent.setActiveEditor(this);else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#w||=new Map;let{action:s}=t,i=this.#w.get(s);if(i)clearTimeout(i);i=setTimeout(()=>{if(this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0)this.#w=null},H._telemetryTimeout),this.#w.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){if(this.div)this.div.tabIndex=0;this.#a=!1}disable(){if(this.div)this.div.tabIndex=-1;this.#a=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}if(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;if(e?.nodeName==="DIV"&&e.classList.contains("annotationContent"))e.remove()}}class Pn extends H{constructor(t){super(t);this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var Yi=3285377520,_t=4294901760,Kt=65535;class ms{constructor(t){this.h1=t?t&4294967295:Yi,this.h2=t?t&4294967295:Yi}update(t){let e,s;if(typeof t==="string"){e=new Uint8Array(t.length*2),s=0;for(let p=0,g=t.length;p<g;p++){let m=t.charCodeAt(p);if(m<=255)e[s++]=m;else e[s++]=m>>>8,e[s++]=m&255}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i),a=0,o=0,l=this.h1,h=this.h2,c=3432918353,d=461845907,u=c&Kt,f=d&Kt;for(let p=0;p<i;p++)if(p&1)a=r[p],a=a*c&_t|a*u&Kt,a=a<<15|a>>>17,a=a*d&_t|a*f&Kt,l^=a,l=l<<13|l>>>19,l=l*5+3864292196;else o=r[p],o=o*c&_t|o*u&Kt,o=o<<15|o>>>17,o=o*d&_t|o*f&Kt,h^=o,h=h<<13|h>>>19,h=h*5+3864292196;switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:if(a^=e[i*4],a=a*c&_t|a*u&Kt,a=a<<15|a>>>17,a=a*d&_t|a*f&Kt,i&1)l^=a;else h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&_t|t*36045&Kt,e=e*4283543511&_t|((e<<16|t>>>16)*2950163797&_t)>>>16,t^=e>>>1,t=t*444984403&_t|t*60499&Kt,e=e*3301882366&_t|((e<<16|t>>>16)*3120437893&_t)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var $e=Object.freeze({map:null,hash:"",transfer:void 0});class Ms{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let s=this.#i.get(t);if(s===void 0)return e;return Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){let e=this.#i.get(t);if(e===void 0)return;if(e instanceof H)this.#s.delete(e.annotationElementId);if(this.#i.delete(t),this.#i.size===0)this.resetModified();if(this.#i.values().some((s)=>s instanceof H))return;this.onAnnotationEditor?.(null)}setValue(t,e){let s=this.#i.get(t),i=!1;if(s!==void 0){for(let[n,r]of Object.entries(e))if(s[n]!==r)i=!0,s[n]=r}else i=!0,this.#i.set(t,e);if(i)this.#n();if(e instanceof H)(this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type)}has(t){return this.#i.has(t)}get size(){return this.#i.size}#n(){if(!this.#t)this.#t=!0,this.onSetModified?.()}resetModified(){if(this.#t)this.#t=!1,this.onResetModified?.()}get print(){return new fi(this)}get serializable(){if(this.#i.size===0)return $e;let t=new Map,e=new ms,s=[],i=Object.create(null),n=!1;for(let[r,a]of this.#i){let o=a instanceof H?a.serialize(!1,i):a;if(a.page)a.pageIndex=a.page._pageIndex,delete a.page;if(o)t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap}if(n){for(let r of t.values())if(r.bitmap)s.push(r.bitmap)}return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:$e}get editorStats(){let t=null,e=new Map,s=0,i=0;for(let n of this.#i.values()){if(!(n instanceof H)){if(n.popup)if(n.popup.deleted)i+=1;else s+=1;continue}if(n.isCommentDeleted)i+=1;else if(n.hasEditedComment)s+=1;let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(n).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[l,h]of Object.entries(r)){if(l==="type")continue;let c=o.getOrInsertComputed(l,ai);c.set(h,(c.get(h)??0)+1)}}if(i>0||s>0)t||=Object.create(null),t.comments={deleted:i,edited:s};if(!t)return null;for(let[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){let s=this.#s?.get(t);if(s)return s.updateFromAnnotationLayer(e),!0;return!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;let t=[];if(this.#s)for(let s of this.#s.values()){if(!s.serialize())continue;t.push(s.annotationElementId)}let e="";if(t.length){let s=new ms;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}}class fi extends Ms{#t=$e;constructor(t){super();let{serializable:e}=t;if(e===$e)return;let{map:s,hash:i,transfer:n}=e,r=structuredClone(s,n?{transfer:n}:null);this.#t={map:r,hash:i,transfer:[]}}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return j(this,"modifiedIds",{ids:new Set,hash:""})}}var Io=K(7588),Ae="__forcedDependency",{floor:Ki,ceil:Ji}=Math;function Qi(t,e,s,i,n,r){t[e*4+0]=Math.min(t[e*4+0],s),t[e*4+1]=Math.min(t[e*4+1],i),t[e*4+2]=Math.max(t[e*4+2],n),t[e*4+3]=Math.max(t[e*4+3],r)}function va(t,e,s,i,n){let r;if(t){if(t<0)r=n[0],n[0]=n[2],n[2]=r;if(n[0]*=t,n[2]*=t,e<0)r=n[1],n[1]=n[3],n[3]=r;n[1]*=e,n[3]*=e}else n.fill(0);n[0]+=s,n[1]+=i,n[2]+=s,n[3]+=i}var ei=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Mn{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===ei}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}var Zi=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class On{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(ee);_pendingBBoxIdx=-1;#i;#n;#a;#r;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#n=t.height,this.#o(e)}growOperationsCount(t){if(t>=this.#r.length)this.#o(t,this.#r)}#o(t,e){let s=new ArrayBuffer(t*4);if(this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),e&&e.length>0)this.#r.set(e),this.#r.fill(ei,e.length);else this.#r.fill(ei)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){let s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;let i=this._savesStack.pop();if(i!==void 0)e?.(i,t),this.#r[t]=this.#r[i];return this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let s=this._savesStack.pop();if(s!==void 0)e?.(s,t),this.#r[t]=this.#r[s];return this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let s=this._markedContentStack.pop();if(s!==void 0)e?.(s,t),this.#r[t]=this.#r[s];return this}pushBaseTransform(t){return this.#t.push(L.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){if(this.#t.length>1)this.#t.pop();return this}resetBBox(t){if(this._pendingBBoxIdx!==t)this._pendingBBoxIdx=t,this.#s.set(ee,0);return this}recordClipBox(t,e,s,i,n,r){let a=L.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=ee.slice();L.axialAlignedBoundingBox([s,n,i,r],a,o);let l=L.intersect(this.#e,o);if(l)this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3];else this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0;return this}recordBBox(t,e,s,i,n,r){let a=this.#e;if(a[0]===1/0)return this;let o=L.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return L.axialAlignedBoundingBox([s,n,i,r],o,this.#s),this;let l=ee.slice();return L.axialAlignedBoundingBox([s,n,i,r],o,l),this.#s[0]=ut(l[0],a[0],this.#s[0]),this.#s[1]=ut(l[1],a[1],this.#s[1]),this.#s[2]=ut(l[2],this.#s[2],a[2]),this.#s[3]=ut(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#n,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;let i=Ki(this.#s[0]*256/this.#i),n=Ki(this.#s[1]*256/this.#n),r=Ji(this.#s[2]*256/this.#i),a=Ji(this.#s[3]*256/this.#n);if(Qi(this.#a,t,i,n,r,a),s){for(let o of s)for(let l of o)if(l!==t)Qi(this.#a,l,i,n,r,a)}if(!e)this._pendingBBoxIdx=-1;return this}bboxToClipBoxDropOperation(t){if(this._pendingBBoxIdx===t)this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3]);return this}take(){return new Mn(this.#r,this.#a)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){return this}getSimpleIndex(t){return}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Rn{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[Ae]:[]};#s=new Map;#i=new Set;#n=new Map;#a;#r;#o;constructor(t,e=!1){if(this.#o=t,e)this.#a=new Map,this.#r=(s,i)=>{Zi(this.#a,i).dependencies.add(s)}}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[Ae]:{__proto__:this.#e[Ae]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#r);let e=Object.getPrototypeOf(this.#t);if(e===null)return this;return this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#r),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#r),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ae,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)if(e in this.#t)this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#i)this.recordFutureForcedDependency(Ae,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,n,r){return this.#o.recordClipBox(t,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#o.recordBBox(t,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){let o=s.bbox,l,h;if(o){if(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#n.get(s),l!==!1){if(h=[0,0,0,0],L.axialAlignedBoundingBox(o,s.fontMatrix,h),i!==1||n!==0||r!==0)va(i,-i,n,r,h);if(l)return this.recordBBox(t,e,h[0],h[2],h[1],h[3])}}if(!a)return this.recordFullPageBBox(t);let c=a();if(o&&h&&l===void 0){if(l=h[0]<=n-c.actualBoundingBoxLeft&&h[2]>=n+c.actualBoundingBoxRight&&h[1]<=r-c.actualBoundingBoxAscent&&h[3]>=r+c.actualBoundingBoxDescent,this.#n.set(s,l),l)return this.recordBBox(t,e,h[0],h[2],h[1],h[3])}return this.recordBBox(t,e,n-c.actualBoundingBoxLeft,n+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){let s=this.#i,i=this.#t,n=this.#e;for(let r of e)if(r in this.#t)s.add(i[r]);else if(r in n)n[r].forEach(s.add,s);return this}recordNamedDependency(t,e){if(this.#s.has(e))this.#i.add(this.#s.get(e));return this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ae]),this.#a){let i=Zi(this.#a,t),{dependencies:n}=i;this.#i.forEach(n.add,n),this.#o._savesStack.forEach(n.add,n),this.#o._markedContentStack.forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}let s=!e&&t===this.#o._pendingBBoxIdx;if(this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s)this.#i.clear();return this}recordShowTextOperation(t,e=!1){let s=Array.from(this.#i);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(let i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){let s=!e&&t===this.#o._pendingBBoxIdx;if(this.#o.bboxToClipBoxDropOperation(t),s)this.#i.clear();return this}take(){return this.#n.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class Ge{#t;#e;#s;#i=0;#n=0;constructor(t,e,s){if(t instanceof Ge&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#n++,this.#t.save(this.#e),this}restore(t){if(this.#n>0)this.#t.restore(this.#e),this.#n--;return this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){if(!this.#s)this.#t.resetBBox(this.#e);return this}recordClipBox(t,e,s,i,n,r){if(!this.#s)this.#t.recordClipBox(this.#e,e,s,i,n,r);return this}recordBBox(t,e,s,i,n,r){if(!this.#s)this.#t.recordBBox(this.#e,e,s,i,n,r);return this}recordCharacterBBox(t,e,s,i,n,r,a){if(!this.#s)this.#t.recordCharacterBBox(this.#e,e,s,i,n,r,a);return this}recordFullPageBBox(t){if(!this.#s)this.#t.recordFullPageBBox(this.#e);return this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){if(!this.#s)this.#t.bboxToClipBoxDropOperation(this.#e,!0);return this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}var Ht={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class vs{#t;#e;#s=4;#i=0;#n=new vs.#a(this.#s*6);static#a=ot.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;let a=new vs.#a(this.#s*6);a.set(this.#n),this.#n=a}let n=dt(t),r;if(i[0]!==1/0){let a=ee.slice();L.axialAlignedBoundingBox([0,-s,e,0],n,a);let o=L.intersect(i,a);if(!o)return;let[l,h,c,d]=o;if(l!==a[0]||h!==a[1]||c!==a[2]||d!==a[3]){let u=Math.atan2(n[1],n[0]),f=Math.abs(Math.sin(u)),p=Math.abs(Math.cos(u));if(f<0.000001||p<0.000001||Math.abs(f-p)<0.000001)r=[l,h,l,d,c,h];else{let g=c-l,m=d-h,v=f*f,y=p*p,S=p*f,A=y-v,b=(m*y-g*S)/A,w=(m*S-g*v)/A;r=[l+w,h,l,h+b,c,d-b]}}}if(!r)r=[0,-s,0,0,e,-s],L.applyTransform(r,n,0),L.applyTransform(r,n,2),L.applyTransform(r,n,4);r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#n.set(r,this.#i*6),this.#i++}take(){return this.#n.subarray(0,this.#i*6)}}var qi=/\p{Cc}/u;function ya(t){let e=t[0];if(t.length<2||e!=='"'&&e!=="'"||t.at(-1)!==e)return!1;let s=t.length-1;for(let i=1;i<s;i++){let n=t[i];if(n===e||qi.test(n))return!1;if(n==="\\"){if(++i>=s||qi.test(t[i]))return!1}}return!0}function tn(t){if(ya(t))return t;return`"${t.replaceAll(/["\\\p{Cc}]/gu,(s)=>s==='"'||s==="\\"?`\\${s}`:`\\${s.codePointAt(0).toString(16)} `)}"`}class Dn{#t=new Set;#e=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){let e=this.#s();e.insertRule(t,e.cssRules.length)}#s(){if(this.#e)return this.#e;let t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let s=new t;return e.push(s),this.#e=s}}if(!this.styleElement)this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);return this.#e=this.styleElement.sheet}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#t.clear(),this.#e){let{adoptedStyleSheets:t}=this._document;if(t?.includes(this.#e))this._document.adoptedStyleSheets=t.filter((e)=>e!==this.#e);this.#e=null}if(this.styleElement)this.styleElement.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!t||this.#t.has(t.loadedName))return;if(mt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:n,style:r}=t,a=new FontFace(i,n,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(i),s?.(t)}catch{z(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}st("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw z(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((s)=>{let i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return j(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return j(this,"isSyncFontLoadingSupported",Nt||ot.platform.isFirefox)}_queueLoadingCallback(t){function e(){mt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;while(s.length>0&&s[0].done){let n=s.shift();setTimeout(n.callback,0)}}let{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return j(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,b){return A.charCodeAt(b)<<24|A.charCodeAt(b+1)<<16|A.charCodeAt(b+2)<<8|A.charCodeAt(b+3)&255}function i(A){return String.fromCharCode(A>>24&255,A>>16&255,A>>8&255,A&255)}function n(A,b,w,x){let T=A.substring(0,b),E=A.substring(b+w);return T+x+E}let r,a,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0;function c(A,b){if(++h>30){z("Load test font never loaded."),b();return}if(l.font="30px "+A,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){b();return}setTimeout(c.bind(null,A,b))}let d=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=n(u,976,d.length,d);let p=16,g=1482184792,m=s(u,p);for(r=0,a=d.length-3;r<a;r+=4)m=m-g+s(d,r)|0;if(r<d.length)m=m-g+s(d+"XXX",r)|0;u=n(u,p,4,i(m));let v=`url(data:font/opentype;base64,${btoa(u)});`,y=`@font-face {font-family:"${d}";src:${v}}`;this.insertRule(y);let S=this._document.createElement("div");S.style.visibility="hidden",S.style.width=S.style.height="10px",S.style.position="absolute",S.style.top=S.style.left="0px";for(let A of[t.loadedName,d]){let b=this._document.createElement("span");b.textContent="Hi",b.style.fontFamily=A,S.append(b)}this._document.body.append(S),c(d,()=>{S.remove(),e.complete()})}}class kn{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,s,i){if(this.#t=t,this._inspectFont=e,s)this.charProcOperatorList=s;if(i)Object.assign(this,i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};if(this.cssFontInfo.italicAngle)e.style=`oblique ${this.cssFontInfo.italicAngle}deg`;t=new FontFace(tn(this.cssFontInfo.fontFamily),this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;if(this.cssFontInfo.italicAngle)s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;e=`@font-face {font-family:${tn(this.cssFontInfo.fontFamily)};${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e,i;try{i=t.get(s)}catch(r){z(`getPathGenerator - ignoring character: "${r}".`)}let n=xn(i?.path);if(!this.fontExtraProperties)t.delete(s);return this.compiledGlyphs[e]=n}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){j(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}class Ln{static strings=["fontFamily","fontWeight","italicAngle"]}class Nn{static strings=["css","loadedName","baseFontName","src"]}class Ut{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class ie{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class Ve{static get decoder(){return j(this,"decoder",new TextDecoder)}static get encoder(){return j(this,"encoder",new TextEncoder)}}class Fn{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){mt(t<Ln.strings.length,"Invalid string index");let{decoder:e}=Ve,s=0;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class Bn{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}get guessFallback(){return this.#e.getUint8(0)!==0}#s(t){mt(t<Nn.strings.length,"Invalid string index");let{decoder:e}=Ve,s=5;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let{decoder:t}=Ve,e=1;e+=4+this.#e.getUint32(e);let s=this.#e.getUint32(e),i=t.decode(new Uint8Array(this.#t,e+4,s));e+=4+s;let n=this.#e.getUint32(e),r=t.decode(new Uint8Array(this.#t,e+4,n));return{style:i,weight:r}}}class _n{#t;#e;constructor({buffer:t,extra:e}){if(this.#t=t,this.#e=new DataView(t),e)Object.assign(this,e)}#s(t){mt(t<Ut.bools.length,"Invalid boolean index");let e=Math.floor(t/4),s=t*2%8,i=this.#e.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#i(t){return mt(t<Ut.numbers.length,"Invalid number index"),this.#e.getFloat64(Ut.OFFSET_NUMBERS+t*8)}get ascent(){return this.#i(0)}get defaultWidth(){return this.#i(1)}get descent(){return this.#i(2)}#n(t,e,s,i){let n=this.#e.getUint8(t);if(n===0)return;mt(n===e,"Invalid array length."),t+=1;let r=Array(n);for(let a=0;a<n;a++)r[a]=this.#e[s](t,!0),t+=i;return r}get bbox(){return this.#n(Ut.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#n(Ut.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#n(Ut.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#a(t){mt(t<Ut.strings.length,"Invalid string index");let{decoder:e}=Ve,s=Ut.OFFSET_STRINGS+4;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get fallbackName(){return this.#a(0)}get loadedName(){return this.#a(1)}get mimetype(){return this.#a(2)}get name(){return this.#a(3)}#r(){let t=Ut.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);t+=4+s;let i=this.#e.getUint32(t);t+=4+i;let n=this.#e.getUint32(t);return{offset:t,length:n}}get data(){let{offset:t,length:e}=this.#r();return e===0?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){let{offset:t,length:e}=this.#r();if(e===0)return;this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t)}get cssFontInfo(){let t=Ut.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);t+=4+s;let i=this.#e.getUint32(t);if(i===0)return null;let n=new Uint8Array(i);return n.set(new Uint8Array(this.#t,t+4,i)),new Fn(n.buffer)}get systemFontInfo(){let t=Ut.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);if(s===0)return null;let i=new Uint8Array(s);return i.set(new Uint8Array(this.#t,t+4,s)),new Bn(i.buffer)}}class Hn{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[ie.KIND],s=!!this.data[ie.HAS_BBOX],i=!!this.data[ie.HAS_BACKGROUND],n=t.getUint32(ie.N_COORD,!0),r=t.getUint32(ie.N_COLOR,!0),a=t.getUint32(ie.N_STOP,!0),o=20,l=new Float32Array(this.buffer,o,n*2);o+=n*8;let h=new Uint8Array(this.buffer,o,r*4);o+=r*4;let c=[];for(let f=0;f<a;++f){let p=t.getFloat32(o,!0);o+=4;let g=t.getUint32(o,!0);o+=4,c.push([p,`#${g.toString(16).padStart(6,"0")}`])}let d=null;if(s){d=[];for(let f=0;f<4;++f)d.push(t.getFloat32(o,!0)),o+=4}let u=null;if(i)u=new Uint8Array(this.buffer,o,3),o+=3;if(e===1)return["RadialAxial","axial",d,c,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",d,c,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){let f=this.data[ie.SHADING_TYPE],p=null;if(l.length>0){p=ee.slice();for(let g=0,m=l.length;g<m;g+=2)L.pointBoundingBox(l[g],l[g+1],p)}return["Mesh",f,l,h,n,p,d,u]}throw Error(`Unsupported pattern kind: ${e}`)}}class Un{#t;constructor(t){this.#t=t}get path(){if(ot.isFloat16ArraySupported)return new Float16Array(this.#t);return new Float32Array(this.#t)}}function ba(t){if(t instanceof URL)return t;if(typeof t==="string"){if(Nt){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);let s=process.getBuiltinModule("url");return new URL(s.pathToFileURL(t))}let e=URL.parse(t,window.location);if(e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Aa(t){if(Nt&&typeof Buffer<"u"&&t instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t==="string")return Cs(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t==="object"&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function es(t){if(typeof t!=="string")return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}var si=(t)=>typeof t==="object"&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Sa=(t)=>typeof t==="object"&&typeof t?.name==="string",wa=oa.bind(null,si,Sa);class jn{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){let{signal:n}=s;if(n.aborted){z("LoopbackPort - cannot use an `aborted` signal.");return}let r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}}var Po=K(1689),ss={DATA:1,ERROR:2},yt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function en(){}function Dt(t){if(t instanceof se||t instanceof ps||t instanceof fs||t instanceof Ue||t instanceof cs)return t;if(!(t instanceof Error||typeof t==="object"&&t!==null))st('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(t.name){case"AbortException":return new se(t.message);case"InvalidPDFException":return new ps(t.message);case"PasswordException":return new fs(t.message,t.code);case"ResponseException":return new Ue(t.message,t.status,t.missing);case"UnknownErrorException":return new cs(t.message,t.details)}return new cs(t.message,t.toString())}class Ee{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){let s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===ss.DATA)i.resolve(t.data);else if(t.callback===ss.ERROR)i.reject(Dt(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:ss.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:ss.ERROR,callbackId:t.callbackId,reason:Dt(r)})});return}if(t.streamId){this.#s(t);return}e(t.data)}on(t,e){let s=this.actionHandler;if(s[t])throw Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){let i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:(l)=>{let h=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},i),h.promise},pull:(l)=>{let h=Promise.withResolvers();return this.streamControllers[n].pullCall=h,o.postMessage({sourceName:r,targetName:a,stream:yt.PULL,streamId:n,desiredSize:l.desiredSize}),h.promise},cancel:(l)=>{mt(l instanceof Error,"cancel must have a valid reason");let h=Promise.withResolvers();return this.streamControllers[n].cancelCall=h,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:yt.CANCEL,streamId:n,reason:Dt(l)}),h.promise}},s)}#s(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,h=1,c){if(this.isCancelled)return;let d=this.desiredSize;if(this.desiredSize-=h,d>0&&this.desiredSize<=0)this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise;n.postMessage({sourceName:s,targetName:i,stream:yt.ENQUEUE,streamId:e,chunk:l},c)},close(){if(this.isCancelled)return;this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:yt.CLOSE,streamId:e}),delete r.streamSinks[e]},error(l){if(mt(l instanceof Error,"error must have a valid reason"),this.isCancelled)return;this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:yt.ERROR,streamId:e,reason:Dt(l)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,reason:Dt(l)})})}#i(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case yt.START_COMPLETE:if(t.success)r.startCall.resolve();else r.startCall.reject(Dt(t.reason));break;case yt.PULL_COMPLETE:if(t.success)r.pullCall.resolve();else r.pullCall.reject(Dt(t.reason));break;case yt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0});break}if(a.desiredSize<=0&&t.desiredSize>0)a.sinkCapability.resolve();a.desiredSize=t.desiredSize,Promise.try(a.onPull||en).then(function(){n.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,reason:Dt(l)})});break;case yt.ENQUEUE:if(mt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case yt.CLOSE:if(mt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#n(r,e);break;case yt.ERROR:mt(r,"error should have stream controller"),r.controller.error(Dt(t.reason)),this.#n(r,e);break;case yt.CANCEL_COMPLETE:if(t.success)r.cancelCall.resolve();else r.cancelCall.reject(Dt(t.reason));this.#n(r,e);break;case yt.CANCEL:if(!a)break;let o=Dt(t.reason);Promise.try(a.onCancel||en,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,reason:Dt(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async#n(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class pi{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:st(`Not implemented: ${t}`)}let s=this[t];if(!s)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);let i=`${s}${e}`;return this._fetch(i,t).catch((n)=>{throw Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){st("Abstract method `_fetch` called.")}}class ii extends pi{async _fetch(t,e){let s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await li(t,s);return i instanceof Uint8Array?i:Cs(i)}}class gi{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw Error("Canvas is not specified");if(e<=0||s<=0)throw Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){let{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){st("Abstract method `_createCanvas` called.")}}class $n extends gi{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e});this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class mi{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class Gn extends mi{#t;#e;#s;#i;#n;#a;#r=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super();this.#i=t,this.#n=e}get#o(){return this.#e||=new Map}get#l(){return this.#a||=new Map}get#h(){if(!this.#s){let t=this.#n.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let s=this.#n.createElementNS(Mt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#n.createElementNS(Mt,"defs"),t.append(s),s.append(this.#s),this.#n.body.append(t)}return this.#s}#u(t){if(t.length===1){let o=t[0],l=Array(256);for(let c=0;c<256;c++)l[c]=o[c]/255;let h=l.join(",");return[h,h,h]}let[e,s,i]=t,n=Array(256),r=Array(256),a=Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";let e=this.#n.URL;if(e!==this.#n.baseURI)if(Ps(e))z('#createUrl: ignore "data:"-URL for performance reasons.');else this.#t=vn(e,"")}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;let a=`g_${this.#i}_transfer_map_${this.#r++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);let l=this.#m(a);return this.#p(s,i,n,l),o}addHCMFilter(t,e){let s=`${t}-${e}`,i="base",n=this.#l.get("base");if(n?.key===s)return n.url;if(n)n.filter?.remove(),n.key=s,n.url="none",n.filter=null;else n={key:s,url:"none",filter:null},this.#l.set("base",n);if(!t||!e)return n.url;let r=this.#y(t);t=L.makeHexColor(...r);let a=this.#y(e);if(e=L.makeHexColor(...a),this.#A(),t==="#000000"&&e==="#ffffff"||t===e)return n.url;let l=Array.from({length:256},(u,f)=>ti(f/255)).join(","),h=`g_${this.#i}_hcm_filter`,c=n.filter=this.#m(h);this.#p(l,l,l,c),this.#g(c);let d=(u,f)=>{let p=r[u]/255,g=a[u]/255,m=Array(f+1);for(let v=0;v<=f;v++)m[v]=p+v/f*(g-p);return m.join(",")};return this.#p(d(0,5),d(1,5),d(2,5),c),n.url=this.#d(h),n.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){let e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();if(e==="none"||!ot.platform.isFirefox)return null;return{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_alpha_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#m(n);return this.#v(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t)[s]=this.#u([t]),i=`luminosity_${s}`;else i="luminosity";if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_luminosity_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#m(n);if(this.#f(a),t)this.#v(s,a);return r}addKnockoutFilter(t=0){let e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;let n=`g_${this.#i}_knockout_filter_${this.#r++}`,r=this.#d(n);this.#o.set(s,r);let a=this.#m(n),o=this.#n.createElementNS(Mt,"feComponentTransfer");a.append(o);let l=this.#n.createElementNS(Mt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,s,i,n){let r=`${e}-${s}-${i}-${n}`,a=this.#l.get(t);if(a?.key===r)return a.url;if(a)a.filter?.remove(),a.key=r,a.url="none",a.filter=null;else a={key:r,url:"none",filter:null},this.#l.set(t,a);if(!e||!s)return a.url;let[o,l]=[e,s].map(this.#y.bind(this)),h=Math.round(0.2126*o[0]+0.7152*o[1]+0.0722*o[2]),c=Math.round(0.2126*l[0]+0.7152*l[1]+0.0722*l[2]),[d,u]=[i,n].map(this.#x.bind(this));if(c<h)[h,c,d,u]=[c,h,u,d];this.#A();let f=(m,v,y)=>{let S=Array(256),A=(c-h)/y,b=m/255,w=(v-m)/(255*y),x=0;for(let T=0;T<=y;T++){let E=Math.round(h+T*A),I=b+T*w;for(let C=x;C<=E;C++)S[C]=I;x=E+1}for(let T=x;T<256;T++)S[T]=S[x-1];return S.join(",")},p=`g_${this.#i}_hcm_${t}_filter`,g=a.filter=this.#m(p);return this.#g(g),this.#p(f(d[0],u[0],5),f(d[1],u[1],5),f(d[2],u[2],5),g),a.url=this.#d(p),a.url}destroy(t=!1){if(t&&this.#a?.size)return;this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#a?.clear(),this.#a=null,this.#r=0}#f(t){let e=this.#n.createElementNS(Mt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#g(t){let e=this.#n.createElementNS(Mt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#m(t){let e=this.#n.createElementNS(Mt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#c(t,e,s){let i=this.#n.createElementNS(Mt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#p(t,e,s,i){let n=this.#n.createElementNS(Mt,"feComponentTransfer");i.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",s)}#v(t,e){let s=this.#n.createElementNS(Mt,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#y(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Ke(getComputedStyle(this.#h).getPropertyValue("background-color"))}#b(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Ye(getComputedStyle(this.#h).getPropertyValue("background-color"))}#A(){this.#h.style.color="",this.#h.style.backgroundColor=""}#x(t){let[e,s,i,n]=this.#b(t);if(n===1)return[e,s,i];let[r,a,o]=this.#y("Canvas");return[Ws(e,r,n),Ws(s,a,n),Ws(i,o,n)]}}function Ws(t,e,s){return Math.round(s*t+(1-s)*e)}if(Nt){let t;try{let e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(s){z(`Cannot load "@napi-rs/canvas" package: "${s}".`)}}catch(e){z(`Cannot access the \`require\` function: "${e}".`)}if(!globalThis.DOMMatrix)if(t?.DOMMatrix)globalThis.DOMMatrix=t.DOMMatrix;else z("Cannot polyfill `DOMMatrix`, rendering may be broken.");if(!globalThis.Path2D)if(t?.Path2D)globalThis.Path2D=t.Path2D;else z("Cannot polyfill `Path2D`, rendering may be broken.");if(!globalThis.navigator?.language)globalThis.navigator={language:"en-US",platform:"",userAgent:""}}async function xa(t){let s=await process.getBuiltinModule("fs/promises").readFile(t);return new Uint8Array(s)}class Vn extends mi{}class zn extends gi{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Wn extends pi{async _fetch(t,e){return xa(t)}}function Xn({src:t,srcPos:e=0,dest:s,width:i,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){let o=ot.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=i>>3,d=i&7,u=l^h,f=t.length;s=new Uint32Array(s.buffer);let p=0;for(let g=0;g<n;++g){for(let v=e+c;e<v;++e,p+=8){let y=t[e];s[p]=l^-(y>>7&1)&u,s[p+1]=l^-(y>>6&1)&u,s[p+2]=l^-(y>>5&1)&u,s[p+3]=l^-(y>>4&1)&u,s[p+4]=l^-(y>>3&1)&u,s[p+5]=l^-(y>>2&1)&u,s[p+6]=l^-(y>>1&1)&u,s[p+7]=l^-(y&1)&u}if(d===0)continue;let m=e<f?t[e++]:255;for(let v=0;v<d;++v,++p)s[p]=l^-(m>>7-v&1)&u}return{srcPos:e,destPos:p}}function Ea({src:t,srcPos:e=0,dest:s,destPos:i=0,width:n,height:r}){let a=0,o=n*r*3,l=o>>2,h=new Uint32Array(t.buffer,e,l),c=ot.isLittleEndian?4278190080:255;if(ot.isLittleEndian){for(;a<l-2;a+=3,i+=4){let d=h[a],u=h[a+1],f=h[a+2];s[i]=d|c,s[i+1]=d>>>24|u<<8|c,s[i+2]=u>>>16|f<<16|c,s[i+3]=f>>>8|c}for(let d=a*4,u=e+o;d<u;d+=3)s[i++]=t[d]|t[d+1]<<8|t[d+2]<<16|c}else{for(;a<l-2;a+=3,i+=4){let d=h[a],u=h[a+1],f=h[a+2];s[i]=d|c,s[i+1]=d<<24|u>>>8|c,s[i+2]=u<<16|f>>>16|c,s[i+3]=f<<8|c}for(let d=a*4,u=e+o;d<u;d+=3)s[i++]=t[d]<<24|t[d+1]<<16|t[d+2]<<8|c}return{srcPos:e+o,destPos:i}}var Ta=`
1
+ var Ko={463(t){var e=TypeError;t.exports=function(s){if(typeof s=="string")return s;throw new e("Argument is not a string")}},804(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=e+"+/",i=e+"-_",r=function(n){var a={},o=0;for(;o<64;o++)a[n.charAt(o)]=o;return a};t.exports={i2c:s,c2i:r(s),i2cUrl:i,c2iUrl:r(i)}},529(t){t.exports=function(e,s){return{value:e,done:s}}},837(t){var e=TypeError,s=9007199254740991;t.exports=function(i){if(i>s)throw new e("Maximum allowed index exceeded");return i}},2(t){t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},944(t){var e=TypeError;t.exports=function(s){var i=s&&s.alphabet;if(i===void 0||i==="base64"||i==="base64url")return i||"base64";throw new e("Incorrect `alphabet` option")}},767(t){t.exports=function(e){return{iterator:e,next:e.next,done:!1}}},117(t){t.exports=function(e){return e===null||e===void 0}},859(t){t.exports=function(e){e.iterator=e.next=e.nextHandler=e.mapper=e.predicate=e.inner=e.iterables=e.iters=e.openIters=e.padding=e.finishResults=e.buffer=null}},684(t){t.exports=function(e,s){var i=typeof Iterator=="function"&&Iterator.prototype[e];if(i)try{i.call({next:null},s).next()}catch(r){return!0}}},269(t){t.exports=Object.create?Object.create(null):{}},741(t){var{ceil:e,floor:s}=Math;t.exports=Math.trunc||function(r){var n=+r;return(n>0?s:e)(n)}},149(t){var e=RangeError;t.exports=function(s){if(s===s)return s;throw new e("NaN is not allowed")}},717(t,e){e.f=Object.getOwnPropertySymbols},103(t){t.exports=function(e){try{return{error:!1,value:e()}}catch(s){return{error:!0,value:s}}}},750(t,e,s){var i=s(117),r=TypeError;t.exports=function(n){if(i(n))throw new r("Can't call method on "+n);return n}},835(t){t.exports=function(e){try{var s=new Set,i={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return s.clear(),s.add(4),function(){return{done:!0}}}})}},r=s[e](i);return r.size===1&&r.values().next().value===4}catch(n){return!1}}},291(t,e,s){var i=s(741);t.exports=function(r){var n=+r;return n!==n||n===0?0:i(n)}},14(t,e,s){var i=s(291),r=Math.min;t.exports=function(n){var a=i(n);return a>0?r(a,9007199254740991):0}},981(t,e,s){var i=s(750),r=Object;t.exports=function(n){return r(i(n))}},590(t,e,s){var i=s(291),r=RangeError;t.exports=function(n){var a=i(n);if(a<0)throw new r("The argument can't be less than 0");return a}},812(t){var e=TypeError;t.exports=function(s,i){if(s<i)throw new e("Not enough arguments");return s}}},tn={};function S(t){let e=tn[t];if(e!==void 0)return e.exports;let s=tn[t]={exports:{}};return Ko[t](s,s.exports,S),s.exports}S.cw=(t)=>{var e;return()=>{if(t){var s=t;t=0,e={exports:{}},s.call(e.exports,e,e.exports)}return e.exports}};S.d=(t,e)=>{for(var s in e)if(S.o(e,s)&&!S.o(t,s))Object.defineProperty(t,s,{enumerable:!0,get:e[s]})};S.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Nt=S.cw((t)=>{var e=Ct(),s=mi(),i=TypeError;t.exports=function(r){if(e(r))return r;throw new i(s(r)+" is not a function")}}),qo=S.cw((t)=>{var e=Cl(),s=String,i=TypeError;t.exports=function(r){if(e(r))return r;throw new i("Can't set "+s(r)+" as a prototype")}}),je=S.cw((t)=>{var e=he().has;t.exports=function(s){return e(s),s}}),In=()=>S(463),Jo=S.cw((t)=>{var e=yi(),s=new e.WeakMap,{set:i,remove:r}=e;t.exports=function(n){return i(s,n,1),r(s,n),n}}),Qo=S.cw((t)=>{var e=yi().has;t.exports=function(s){return e(s),s}}),Zo=S.cw((t)=>{var e=ee(),s=di(),i=xe().f,r=e("unscopables"),n=Array.prototype;if(n[r]===void 0)i(n,r,{configurable:!0,value:s(null)});t.exports=function(a){n[r][a]=!0}}),Pn=S.cw((t)=>{var e=ui(),s=TypeError;t.exports=function(i,r){if(e(r,i))return i;throw new s("Incorrect invocation")}}),kn=S.cw((t)=>{var e=Ht(),s=String,i=TypeError;t.exports=function(r){if(r===void 0||e(r))return r;throw new i(s(r)+" is not an object or undefined")}}),bt=S.cw((t)=>{var e=Ht(),s=String,i=TypeError;t.exports=function(r){if(e(r))return r;throw new i(s(r)+" is not an object")}}),si=S.cw((t)=>{var e=ri(),s=TypeError;t.exports=function(i){if(e(i)==="Uint8Array")return i;throw new s("Argument is not an Uint8Array")}}),Mn=S.cw((t)=>{t.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),tl=S.cw((t)=>{var e=mt(),s=hr(),i=He(),{ArrayBuffer:r,TypeError:n}=e;t.exports=r&&s(r.prototype,"byteLength","get")||function(a){if(i(a)!=="ArrayBuffer")throw new n("ArrayBuffer expected");return a.byteLength}}),el=S.cw((t)=>{var e=mt(),s=Mn(),i=tl(),r=e.DataView;t.exports=function(n){if(!s||i(n)!==0)return!1;try{return new r(n),!1}catch(a){return!0}}}),ii=S.cw((t)=>{var e=el(),s=TypeError;t.exports=function(i){if(e(i))throw new s("ArrayBuffer is detached");return i}}),sl=S.cw((t)=>{var e=Mn(),s=Bt(),i=mt(),r=Ct(),n=Ht(),a=jt(),o=ri(),l=mi(),c=ni(),h=oi(),d=Fn(),u=ui(),f=gr(),p=mr(),g=ee(),m=vi(),v=hi(),{enforce:y,get:b}=v,_=i.Int8Array,w=_&&_.prototype,A=i.Uint8ClampedArray,x=A&&A.prototype,E=_&&f(_),T=w&&f(w),k=Object.prototype,C=i.TypeError,R=g("toStringTag"),B=m("TYPED_ARRAY_TAG"),N="TypedArrayConstructor",M=e&&!!p&&o(i.opera)!=="Opera",F=!1,j,X,it,q={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Z={BigInt64Array:8,BigUint64Array:8},J=function(Q){if(!n(Q))return!1;var ht=o(Q);return ht==="DataView"||a(q,ht)||a(Z,ht)},P=function(V){var Q=f(V);if(!n(Q))return;var ht=b(Q);return ht&&a(ht,N)?ht[N]:P(Q)},I=function(V){if(!n(V))return!1;var Q=o(V);return a(q,Q)||a(Z,Q)},D=function(V){if(I(V))return V;throw new C("Target is not a typed array")},G=function(V){if(r(V)&&(!p||u(E,V)))return V;throw new C(l(V)+" is not a typed array constructor")},z=function(V,Q,ht,Mt){if(!s)return;if(ht)for(var dt in q){var kt=i[dt];if(kt&&a(kt.prototype,V))try{delete kt.prototype[V]}catch(ss){try{kt.prototype[V]=Q}catch(Ce){}}}if(!T[V]||ht)h(T,V,ht?Q:M&&w[V]||Q,Mt)},tt=function(V,Q,ht){var Mt,dt;if(!s)return;if(p){if(ht){for(Mt in q)if(dt=i[Mt],dt&&a(dt,V))try{delete dt[V]}catch(kt){}}if(!E[V]||ht)try{return h(E,V,ht?Q:M&&E[V]||Q)}catch(kt){}else return}for(Mt in q)if(dt=i[Mt],dt&&(!dt[V]||ht))h(dt,V,Q)};for(j in q)if(X=i[j],it=X&&X.prototype,it)y(it)[N]=X;else M=!1;for(j in Z)if(X=i[j],it=X&&X.prototype,it)y(it)[N]=X;if(!M||!r(E)||E===Function.prototype){if(E=function(){throw new C("Incorrect invocation")},M){for(j in q)if(i[j])p(i[j],E)}}if(!M||!T||T===k){if(T=E.prototype,M){for(j in q)if(i[j])p(i[j].prototype,T)}}if(M&&f(x)!==T)p(x,T);if(s&&!a(T,R)){F=!0,d(T,R,{configurable:!0,get:function(){return n(this)?this[B]:void 0}});for(j in q)if(i[j])c(i[j].prototype,B,j)}t.exports={NATIVE_ARRAY_BUFFER_VIEWS:M,TYPED_ARRAY_TAG:F&&B,aTypedArray:D,aTypedArrayConstructor:G,exportTypedArrayMethod:z,exportTypedArrayStaticMethod:tt,getTypedArrayConstructor:P,isView:J,isTypedArray:I,TypedArray:E,TypedArrayPrototype:T}}),il=S.cw((t)=>{var e=Qe();t.exports=function(s,i,r){var n=0,a=arguments.length>2?r:e(i),o=new s(a);while(a>n)o[n]=i[n++];return o}}),ar=S.cw((t)=>{var e=pi(),s=Jl(),i=Qe(),r=function(n){return function(a,o,l){var c=e(a),h=i(c);if(h===0)return!n&&-1;var d=s(l,h),u;if(n&&o!==o){while(h>d)if(u=c[d++],u!==u)return!0}else for(;h>d;d++)if((n||(d in c))&&c[d]===o)return n||d||0;return!n&&-1}};t.exports={includes:r(!0),indexOf:r(!1)}}),rl=S.cw((t)=>{var e=Bt(),s=fr(),i=TypeError,r=Object.getOwnPropertyDescriptor,n=e&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(a){return a instanceof TypeError}}();t.exports=n?function(a,o){if(s(a)&&!r(a,"length").writable)throw new i("Cannot set read only .length");return a.length=o}:function(a,o){return a.length=o}}),nl=S.cw((t)=>{var e=gt();t.exports=e([].slice)}),On=()=>S(804),Rn=S.cw((t)=>{var e=bt(),s=Ut();t.exports=function(i,r,n,a){try{return a?r(e(n)[0],n[1]):r(n)}catch(o){s(i,"throw",o)}}}),He=S.cw((t)=>{var e=gt(),s=e({}.toString),i=e("".slice);t.exports=function(r){return i(s(r),8,-1)}}),ri=S.cw((t)=>{var e=tc(),s=Ct(),i=He(),r=ee(),n=r("toStringTag"),a=Object,o=i(function(){return arguments}())==="Arguments",l=function(c,h){try{return c[h]}catch(d){}};t.exports=e?i:function(c){var h,d,u;return c===void 0?"Undefined":c===null?"Null":typeof(d=l(h=a(c),n))=="string"?d:o?i(h):(u=i(h))==="Object"&&s(h.callee)?"Arguments":u}}),al=S.cw((t)=>{var e=jt(),s=Hl(),i=Vn(),r=xe();t.exports=function(n,a,o){var l=s(a),c=r.f,h=i.f;for(var d=0;d<l.length;d++){var u=l[d];if(!e(n,u)&&!(o&&e(o,u)))c(n,u,h(a,u))}}}),ol=S.cw((t)=>{var e=_t();t.exports=!e(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype})}),ll=()=>S(529),ni=S.cw((t)=>{var e=Bt(),s=xe(),i=ai();t.exports=e?function(r,n,a){return s.f(r,n,i(1,a))}:function(r,n,a){return r[n]=a,r}}),ai=S.cw((t)=>{t.exports=function(e,s){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:s}}}),or=S.cw((t)=>{var e=Bt(),s=xe(),i=ai();t.exports=function(r,n,a){if(e)s.f(r,n,i(0,a));else r[n]=a}}),Fn=S.cw((t)=>{var e=Un(),s=xe();t.exports=function(i,r,n){if(n.get)e(n.get,r,{getter:!0});if(n.set)e(n.set,r,{setter:!0});return s.f(i,r,n)}}),oi=S.cw((t)=>{var e=Ct(),s=xe(),i=Un(),r=lr();t.exports=function(n,a,o,l){if(!l)l={};var c=l.enumerable,h=l.name!==void 0?l.name:a;if(e(o))i(o,h,l);if(l.global)if(c)n[a]=o;else r(a,o);else{try{if(!l.unsafe)delete n[a];else if(n[a])c=!0}catch(d){}if(c)n[a]=o;else s.f(n,a,{value:o,enumerable:!1,configurable:!l.nonConfigurable,writable:!l.nonWritable})}return n}}),cl=S.cw((t)=>{var e=oi();t.exports=function(s,i,r){for(var n in i)e(s,n,i[n],r);return s}}),lr=S.cw((t)=>{var e=mt(),s=Object.defineProperty;t.exports=function(i,r){try{s(e,i,{value:r,configurable:!0,writable:!0})}catch(n){e[i]=r}return r}}),Bt=S.cw((t)=>{var e=_t();t.exports=!e(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),Dn=S.cw((t)=>{var e=mt(),s=Ht(),i=e.document,r=s(i)&&s(i.createElement);t.exports=function(n){return r?i.createElement(n):{}}}),hl=()=>S(837),dl=()=>S(2),cr=S.cw((t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),ul=S.cw((t)=>{var e=mt(),s=e.navigator,i=s&&s.userAgent;t.exports=i?String(i):""}),fl=S.cw((t)=>{var e=mt(),s=ul(),{process:i,Deno:r}=e,n=i&&i.versions||r&&r.version,a=n&&n.v8,o,l;if(a)o=a.split("."),l=o[0]>0&&o[0]<4?1:+(o[0]+o[1]);if(!l&&s){if(o=s.match(/Edge\/(\d+)/),!o||o[1]>=74){if(o=s.match(/Chrome\/(\d+)/),o)l=+o[1]}}t.exports=l}),pl=S.cw((t)=>{var e=gt(),s=Error,i=e("".replace),r=function(o){return String(new s(o).stack)}("zxcasd"),n=/\n\s*at [^:]*:[^\n]*/,a=n.test(r);t.exports=function(o,l){if(a&&typeof o=="string"&&!s.prepareStackTrace)while(l--)o=i(o,n,"");return o}}),nt=S.cw((t)=>{var e=mt(),s=Vn().f,i=ni(),r=oi(),n=lr(),a=al(),o=Tl();t.exports=function(l,c){var{target:h,global:d,stat:u}=l,f,p,g,m,v,y;if(d)p=e;else if(u)p=e[h]||n(h,{});else p=e[h]&&e[h].prototype;if(p)for(g in c){if(v=c[g],l.dontCallGetSet)y=s(p,g),m=y&&y.value;else m=p[g];if(f=o(d?g:h+(u?".":"#")+g,l.forced),!f&&m!==void 0){if(typeof v==typeof m)continue;a(v,m)}if(l.sham||m&&m.sham)i(v,"sham",!0);r(p,g,v,l)}}}),_t=S.cw((t)=>{t.exports=function(e){try{return!!e()}catch(s){return!0}}}),gl=S.cw((t)=>{var e=li(),s=Function.prototype,{apply:i,call:r}=s;t.exports=typeof Reflect=="object"&&Reflect.apply||(e?r.bind(i):function(){return r.apply(i,arguments)})}),ml=S.cw((t)=>{var e=yl(),s=Nt(),i=li(),r=e(e.bind);t.exports=function(n,a){return s(n),a===void 0?n:i?r(n,a):function(){return n.apply(a,arguments)}}}),li=S.cw((t)=>{var e=_t();t.exports=!e(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")})}),At=S.cw((t)=>{var e=li(),s=Function.prototype.call;t.exports=e?s.bind(s):function(){return s.apply(s,arguments)}}),vl=S.cw((t)=>{var e=Bt(),s=jt(),i=Function.prototype,r=e&&Object.getOwnPropertyDescriptor,n=s(i,"name"),a=n&&function(){}.name==="something",o=n&&(!e||e&&r(i,"name").configurable);t.exports={...null,...null,CONFIGURABLE:o}}),hr=S.cw((t)=>{var e=gt(),s=Nt();t.exports=function(i,r,n){try{return e(s(Object.getOwnPropertyDescriptor(i,r)[n]))}catch(a){}}}),yl=S.cw((t)=>{var e=He(),s=gt();t.exports=function(i){if(e(i)==="Function")return s(i)}}),gt=S.cw((t)=>{var e=li(),s=Function.prototype,i=s.call,r=e&&s.bind.bind(i,i);t.exports=e?r:function(n){return function(){return i.apply(n,arguments)}}}),Ln=()=>S(944),Ee=S.cw((t)=>{var e=mt(),s=Ct(),i=function(r){return s(r)?r:void 0};t.exports=function(r,n){return arguments.length<2?i(e[r]):e[r]&&e[r][n]}}),te=()=>S(767),bl=S.cw((t)=>{var e=At(),s=bt(),i=te(),r=dr();t.exports=function(n,a){if(!a||typeof n!=="string")s(n);var o=r(n);return i(s(o!==void 0?e(o,n):n))}}),Nn=S.cw((t)=>{var e=At(),s=Ct(),i=bt(),r=mi(),n=dr(),a=TypeError;t.exports=function(o,l){var c=arguments.length<2?n(o):l;if(s(c))return i(e(c,o));throw new a(r(o)+" is not iterable")}}),dr=S.cw((t)=>{var e=He(),s=jn(),i=ci(),r=ee(),n=r("iterator"),a=Array.prototype;t.exports=function(o){if(!s(o))return i(o,n)||i(o,"@@iterator")||(e(o)==="Arguments"?a[n]:void 0)}}),ci=S.cw((t)=>{var e=Nt(),s=jn();t.exports=function(i,r){var n=i[r];return s(n)?void 0:e(n)}}),Ue=S.cw((t)=>{var e=Nt(),s=bt(),i=At(),r=_r(),n=te(),a="Invalid size",o=RangeError,l=TypeError,c=Math.max,h=function(d,u){this.set=d,this.size=c(u,0),this.has=e(d.has),this.keys=e(d.keys)};h.prototype={getIterator:function(){return n(s(i(this.keys,this.set)))},includes:function(d){return i(this.has,this.set,d)}},t.exports=function(d){s(d);var u=+d.size;if(u!==u)throw new l(a);var f=r(u);if(f<0)throw new o(a);return new h(d,f)}}),mt=S.cw(function(t){var e=function(s){return s&&s.Math===Math&&s};t.exports=e(typeof globalThis=="object"&&globalThis)||e(typeof window=="object"&&window)||e(typeof self=="object"&&self)||e(typeof global=="object"&&global)||e(typeof this=="object"&&this)||function(){return this}()||Function("return this")()}),jt=S.cw((t)=>{var e=gt(),s=wr(),i=e({}.hasOwnProperty);t.exports=Object.hasOwn||function(n,a){return i(s(n),a)}}),ur=S.cw((t)=>{t.exports={}}),_l=S.cw((t)=>{var e=Ee();t.exports=e("document","documentElement")}),Bn=S.cw((t)=>{var e=Bt(),s=_t(),i=Dn();t.exports=!e&&!s(function(){return Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a!==7})}),wl=S.cw((t)=>{var e=gt(),s=_t(),i=He(),r=Object,n=e("".split);t.exports=s(function(){return!r("z").propertyIsEnumerable(0)})?function(a){return i(a)==="String"?n(a,""):r(a)}:r}),Al=S.cw((t)=>{var e=Ct(),s=Ht(),i=mr();t.exports=function(r,n,a){var o,l;if(i&&e(o=n.constructor)&&o!==a&&s(l=o.prototype)&&l!==a.prototype)i(r,l);return r}}),Sl=S.cw((t)=>{var e=gt(),s=Ct(),i=br(),r=e(Function.toString);if(!s(i.inspectSource))i.inspectSource=function(n){return r(n)};t.exports=i.inspectSource}),hi=S.cw((t)=>{var e=rc(),s=mt(),i=Ht(),r=ni(),n=jt(),a=br(),o=yr(),l=ur(),c="Object already initialized",{TypeError:h,WeakMap:d}=s,u,f,p,g=function(b){return p(b)?f(b):u(b,{})},m=function(b){return function(_){var w;if(!i(_)||(w=f(_)).type!==b)throw new h("Incompatible receiver, "+b+" required");return w}};if(e||a.state){var v=a.state||(a.state=new d);v.get=v.get,v.has=v.has,v.set=v.set,u=function(b,_){if(v.has(b))throw new h(c);return _.facade=b,v.set(b,_),_},f=function(b){return v.get(b)||{}},p=function(b){return v.has(b)}}else{var y=o("state");l[y]=!0,u=function(b,_){if(n(b,y))throw new h(c);return _.facade=b,r(b,y,_),_},f=function(b){return n(b,y)?b[y]:{}},p=function(b){return n(b,y)}}t.exports={set:u,get:f,has:p,enforce:g,getterFor:m}}),El=S.cw((t)=>{var e=ee(),s=Ml(),i=e("iterator"),r=Array.prototype;t.exports=function(n){return n!==void 0&&(s.Array===n||r[i]===n)}}),fr=S.cw((t)=>{var e=He();t.exports=Array.isArray||function(i){return e(i)==="Array"}}),xl=S.cw((t)=>{var e=ri();t.exports=function(s){var i=e(s);return i==="BigInt64Array"||i==="BigUint64Array"}}),Ct=S.cw((t)=>{var e=typeof document=="object"&&document.all;t.exports=typeof e>"u"&&e!==void 0?function(s){return typeof s=="function"||s===e}:function(s){return typeof s=="function"}}),Tl=S.cw((t)=>{var e=_t(),s=Ct(),i=/#|\.prototype\./,r=function(c,h){var d=a[n(c)];return d===l?!0:d===o?!1:s(h)?e(h):!!h},n=r.normalize=function(c){return String(c).replace(i,".").toLowerCase()},a=r.data={},o=r.NATIVE="N",l=r.POLYFILL="P";t.exports=r}),jn=()=>S(117),Ht=S.cw((t)=>{var e=Ct();t.exports=function(s){return typeof s=="object"?s!==null:e(s)}}),Cl=S.cw((t)=>{var e=Ht();t.exports=function(s){return e(s)||s===null}}),zt=S.cw((t)=>{t.exports=!1}),Il=S.cw((t)=>{var e=Ht(),s=hi().get;t.exports=function(r){if(!e(r))return!1;var n=s(r);return!!n&&n.type==="RawJSON"}}),pr=S.cw((t)=>{var e=Ee(),s=Ct(),i=ui(),r=ea(),n=Object;t.exports=r?function(a){return typeof a=="symbol"}:function(a){var o=e("Symbol");return s(o)&&i(o.prototype,n(a))}}),$e=S.cw((t)=>{var e=At();t.exports=function(s,i,r){var n=r?s:s.iterator,a=s.next,o,l;while(!(o=e(a,n)).done)if(l=i(o.value),l!==void 0)return l}}),Je=S.cw((t)=>{var e=ml(),s=At(),i=bt(),r=mi(),n=El(),a=Qe(),o=ui(),l=Nn(),c=dr(),h=Ut(),d=TypeError,u=function(p,g){this.stopped=p,this.result=g},f=u.prototype;t.exports=function(p,g,m){var v=m&&m.that,y=!!(m&&m.AS_ENTRIES),b=!!(m&&m.IS_RECORD),_=!!(m&&m.IS_ITERATOR),w=!!(m&&m.INTERRUPTED),A=e(g,v),x,E,T,k,C,R,B,N=function(j){var X=x;if(x=void 0,X)h(X,"normal");return new u(!0,j)},M=function(j){if(y)return i(j),w?A(j[0],j[1],N):A(j[0],j[1]);return w?A(j,N):A(j)};if(b)x=p.iterator;else if(_)x=p;else{if(E=c(p),!E)throw new d(r(p)+" is not iterable");if(n(E)){for(T=0,k=a(p);k>T;T++)if(C=M(p[T]),C&&o(f,C))return C;return new u(!1)}x=l(p,E)}R=b?p.next:x.next;while(!(B=s(R,x)).done){var F=B.value;try{C=M(F)}catch(j){if(x)h(x,"throw",j);else throw j}if(typeof C=="object"&&C&&o(f,C))return C}return new u(!1)}}),Pl=()=>S(859),kl=S.cw((t)=>{var e=Ut();t.exports=function(s,i,r){for(var n=s.length-1;n>=0;n--){if(s[n]===void 0)continue;try{r=e(s[n].iterator,i,r)}catch(a){i="throw",r=a}}if(i==="throw")throw r;return r}}),Ut=S.cw((t)=>{var e=At(),s=bt(),i=ci();t.exports=function(r,n,a){var o,l;s(r);try{if(o=i(r,"return"),!o){if(n==="throw")throw a;return a}o=e(o,r)}catch(c){l=!0,o=c}if(n==="throw")throw a;if(l)throw o;return s(o),a}}),_s=S.cw((t)=>{var e=At(),s=di(),i=ni(),r=cl(),n=ee(),a=hi(),o=ci(),l=Hn().IteratorPrototype,c=ll(),h=Ut(),d=kl(),u=Pl(),f=n("toStringTag"),p="IteratorHelper",g="WrapForValidIterator",m="normal",v="throw",y=a.set,b=function(A){var x=a.getterFor(A?g:p);return r(s(l),{next:function(){var T=x(this);if(A)return T.nextHandler();if(T.done)return c(void 0,!0);try{var k=T.nextHandler();if(T.done)u(T);return T.returnHandlerResult?k:c(k,T.done)}catch(C){throw T.done=!0,u(T),C}},return:function(){var E=x(this),{iterator:T,inner:k,openIters:C,done:R}=E;if(E.done=!0,A){var B=o(T,"return");return B?e(B,T):c(void 0,!0)}if(u(E),R)return c(void 0,!0);if(k)try{h(k.iterator,m)}catch(N){return h(T,v,N)}if(C)try{d(C,m)}catch(N){if(T)return h(T,v,N);throw N}if(T)h(T,m);return c(void 0,!0)}})},_=b(!0),w=b(!1);i(w,f,"Iterator Helper"),t.exports=function(A,x,E){var T=function(C,R){if(R)R.iterator=C.iterator,R.next=C.next;else R=C;R.type=x?g:p,R.returnHandlerResult=!!E,R.nextHandler=A,R.counter=0,R.done=!1,y(this,R)};return T.prototype=x?_:w,T}}),ws=()=>S(684),ye=S.cw((t)=>{var e=mt();t.exports=function(s,i){var r=e.Iterator,n=r&&r.prototype,a=n&&n[s],o=!1;if(a)try{a.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(l){if(!(l instanceof i))o=!1}if(!o)return a}}),Hn=S.cw((t)=>{var e=_t(),s=Ct(),i=Ht(),r=di(),n=gr(),a=oi(),o=ee(),l=zt(),c=o("iterator"),h=!1,d,u,f;if([].keys){if(f=[].keys(),!("next"in f))h=!0;else if(u=n(n(f)),u!==Object.prototype)d=u}var p=!i(d)||e(function(){var g={};return d[c].call(g)!==g});if(p)d={};else if(l)d=r(d);if(!s(d[c]))a(d,c,function(){return this});t.exports={IteratorPrototype:d,...null}}),Ml=()=>S(269),Qe=S.cw((t)=>{var e=Zl();t.exports=function(s){return e(s.length)}}),Un=S.cw((t)=>{var e=gt(),s=_t(),i=Ct(),r=jt(),n=Bt(),a=vl().CONFIGURABLE,o=Sl(),l=hi(),{enforce:c,get:h}=l,d=String,u=Object.defineProperty,f=e("".slice),p=e("".replace),g=e([].join),m=n&&!s(function(){return u(function(){},"length",{value:8}).length!==8}),v=String(String).split("String"),y=t.exports=function(b,_,w){if(f(d(_),0,7)==="Symbol(")_="["+p(d(_),/^Symbol\(([^)]*)\).*$/,"$1")+"]";if(w&&w.getter)_="get "+_;if(w&&w.setter)_="set "+_;if(!r(b,"name")||a&&b.name!==_)if(n)u(b,"name",{value:_,configurable:!0});else b.name=_;if(m&&w&&r(w,"arity")&&b.length!==w.arity)u(b,"length",{value:w.arity});try{if(w&&r(w,"constructor")&&w.constructor){if(n)u(b,"prototype",{writable:!1})}else if(b.prototype)b.prototype=void 0}catch(x){}var A=c(b);if(!r(A,"source"))A.source=g(v,typeof _=="string"?_:"");return b};Function.prototype.toString=y(function(){return i(this)&&h(this).source||o(this)},"toString")}),$n=S.cw((t)=>{var e=gt(),s=Map.prototype;t.exports={Map,set:e(s.set),get:e(s.get),has:e(s.has),remove:e(s.delete),proto:s}}),Ol=S.cw((t)=>{var e=_t();t.exports=!e(function(){var s="9007199254740993",i=JSON.rawJSON(s);return!JSON.isRawJSON(i)||JSON.stringify(i)!==s})}),Gn=S.cw((t)=>{var e=Nt(),s=TypeError,i=function(r){var n,a;this.promise=new r(function(o,l){if(n!==void 0||a!==void 0)throw new s("Bad Promise constructor");n=o,a=l}),this.resolve=e(n),this.reject=e(a)};t.exports.f=function(r){return new i(r)}}),Rl=S.cw((t)=>{var e=gi();t.exports=function(s,i){return s===void 0?arguments.length<2?"":i:e(s)}}),zn=()=>S(149),di=S.cw((t)=>{var e=bt(),s=Fl(),i=cr(),r=ur(),n=_l(),a=Dn(),o=yr(),l=">",c="<",h="prototype",d="script",u=o("IE_PROTO"),f=function(){},p=function(b){return c+d+l+b+c+"/"+d+l},g=function(b){b.write(p("")),b.close();var _=b.parentWindow.Object;return b=null,_},m=function(){var b=a("iframe"),_="java"+d+":",w;return b.style.display="none",n.appendChild(b),b.src=String(_),w=b.contentWindow.document,w.open(),w.write(p("document.F=Object")),w.close(),w.F},v,y=function(){try{v=new ActiveXObject("htmlfile")}catch(_){}y=typeof document<"u"?document.domain&&v?g(v):m():g(v);var b=i.length;while(b--)delete y[h][i[b]];return y()};r[u]=!0,t.exports=Object.create||function(_,w){var A;if(_!==null)f[h]=e(_),A=new f,f[h]=null,A[u]=_;else A=y();return w===void 0?A:s.f(A,w)}}),Fl=S.cw((t,e)=>{var s=Bt(),i=sa(),r=xe(),n=bt(),a=pi(),o=Nl();e.f=s&&!i?Object.defineProperties:function(c,h){n(c);var d=a(h),u=o(h),f=u.length,p=0,g;while(f>p)r.f(c,g=u[p++],d[g]);return c}}),xe=S.cw((t,e)=>{var s=Bt(),i=Bn(),r=sa(),n=bt(),a=Zn(),o=TypeError,{defineProperty:l,getOwnPropertyDescriptor:c}=Object,h="enumerable",d="configurable",u="writable";e.f=s?r?function(p,g,m){if(n(p),g=a(g),n(m),typeof p==="function"&&g==="prototype"&&"value"in m&&u in m&&!m[u]){var v=c(p,g);if(v&&v[u])p[g]=m.value,m={configurable:d in m?m[d]:v[d],enumerable:h in m?m[h]:v[h],writable:!1}}return l(p,g,m)}:l:function(p,g,m){if(n(p),g=a(g),n(m),i)try{return l(p,g,m)}catch(v){}if("get"in m||"set"in m)throw new o("Accessors not supported");if("value"in m)p[g]=m.value;return p}}),Vn=S.cw((t,e)=>{var s=Bt(),i=At(),r=Bl(),n=ai(),a=pi(),o=Zn(),l=jt(),c=Bn(),h=Object.getOwnPropertyDescriptor;e.f=s?h:function(u,f){if(u=a(u),f=o(f),c)try{return h(u,f)}catch(p){}if(l(u,f))return n(!i(r.f,u,f),u[f])}}),Dl=S.cw((t,e)=>{var s=Wn(),i=cr(),r=i.concat("length","prototype");e.f=Object.getOwnPropertyNames||function(a){return s(a,r)}}),Ll=()=>S(717),gr=S.cw((t)=>{var e=jt(),s=Ct(),i=wr(),r=yr(),n=ol(),a=r("IE_PROTO"),o=Object,l=o.prototype;t.exports=n?o.getPrototypeOf:function(c){var h=i(c);if(e(h,a))return h[a];var d=h.constructor;if(s(d)&&h instanceof d)return d.prototype;return h instanceof o?l:null}}),ui=S.cw((t)=>{var e=gt();t.exports=e({}.isPrototypeOf)}),Wn=S.cw((t)=>{var e=gt(),s=jt(),i=pi(),r=ar().indexOf,n=ur(),a=e([].push);t.exports=function(o,l){var c=i(o),h=0,d=[],u;for(u in c)!s(n,u)&&s(c,u)&&a(d,u);while(l.length>h)if(s(c,u=l[h++]))~r(d,u)||a(d,u);return d}}),Nl=S.cw((t)=>{var e=Wn(),s=cr();t.exports=Object.keys||function(r){return e(r,s)}}),Bl=S.cw((t,e)=>{var s={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,r=i&&!s.call({1:2},1);e.f=r?function(a){var o=i(this,a);return!!o&&o.enumerable}:s}),mr=S.cw((t)=>{var e=hr(),s=Ht(),i=Yn(),r=qo();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var n=!1,a={},o;try{o=e(Object.prototype,"__proto__","set"),o(a,[]),n=a instanceof Array}catch(l){}return function(c,h){if(i(c),r(h),!s(c))return c;if(n)o(c,h);else c.__proto__=h;return c}}():void 0)}),jl=S.cw((t)=>{var e=At(),s=Ct(),i=Ht(),r=TypeError;t.exports=function(n,a){var o,l;if(a==="string"&&s(o=n.toString)&&!i(l=e(o,n)))return l;if(s(o=n.valueOf)&&!i(l=e(o,n)))return l;if(a!=="string"&&s(o=n.toString)&&!i(l=e(o,n)))return l;throw new r("Can't convert object to primitive value")}}),Hl=S.cw((t)=>{var e=Ee(),s=gt(),i=Dl(),r=Ll(),n=bt(),a=s([].concat);t.exports=e("Reflect","ownKeys")||function(l){var c=i.f(n(l)),h=r.f;return h?a(c,h(l)):c}}),Xn=S.cw((t)=>{var e=gt(),s=jt(),i=SyntaxError,r=parseInt,n=String.fromCharCode,a=e("".charAt),o=e("".slice),l=e(/./.exec),c={"\\\"":'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
+ `,"\\r":"\r","\\t":"\t"},h=/^[\da-f]{4}$/i,d=/^[\u0000-\u001F]$/;t.exports=function(u,f){var p=!0,g="";while(f<u.length){var m=a(u,f);if(m==="\\"){var v=o(u,f,f+2);if(s(c,v))g+=c[v],f+=2;else if(v==="\\u"){f+=2;var y=o(u,f,f+4);if(!l(h,y))throw new i("Bad Unicode escape at: "+f);g+=n(r(y,16)),f+=4}else throw new i('Unknown escape sequence: "'+v+'"')}else if(m==='"'){p=!1,f++;break}else{if(l(d,m))throw new i("Bad control character in string literal at: "+f);g+=m,f++}}if(p)throw new i("Unterminated string at: "+f);return{value:g,end:f}}}),Ul=()=>S(103),$l=S.cw((t)=>{var e=bt(),s=Ht(),i=Gn();t.exports=function(r,n){if(e(r),s(n)&&n.constructor===r)return n;var a=i.f(r),o=a.resolve;return o(n),a.promise}}),Yn=()=>S(750),vr=S.cw((t)=>{var e=he(),s=As(),{Set:i,add:r}=e;t.exports=function(n){var a=new i;return s(n,function(o){r(a,o)}),a}}),Gl=S.cw((t)=>{var e=je(),s=he(),i=vr(),r=Ss(),n=Ue(),a=As(),o=$e(),{has:l,remove:c}=s;t.exports=function(d){var u=e(this),f=n(d),p=i(u);if(r(p)<=f.size)a(p,function(g){if(f.includes(g))c(p,g)});else o(f.getIterator(),function(g){if(l(p,g))c(p,g)});return p}}),he=S.cw((t)=>{var e=gt(),s=Set.prototype;t.exports={Set,add:e(s.add),has:e(s.has),remove:e(s.delete),proto:s}}),zl=S.cw((t)=>{var e=je(),s=he(),i=Ss(),r=Ue(),n=As(),a=$e(),{Set:o,add:l,has:c}=s;t.exports=function(d){var u=e(this),f=r(d),p=new o;if(i(u)>f.size)a(f.getIterator(),function(g){if(c(u,g))l(p,g)});else n(u,function(g){if(f.includes(g))l(p,g)});return p}}),Vl=S.cw((t)=>{var e=je(),s=he().has,i=Ss(),r=Ue(),n=As(),a=$e(),o=Ut();t.exports=function(c){var h=e(this),d=r(c);if(i(h)<=d.size)return n(h,function(f){if(d.includes(f))return!1},!0)!==!1;var u=d.getIterator();return a(u,function(f){if(s(h,f))return o(u.iterator,"normal",!1)})!==!1}}),Wl=S.cw((t)=>{var e=je(),s=Ss(),i=As(),r=Ue();t.exports=function(a){var o=e(this),l=r(a);if(s(o)>l.size)return!1;return i(o,function(c){if(!l.includes(c))return!1},!0)!==!1}}),Xl=S.cw((t)=>{var e=je(),s=he().has,i=Ss(),r=Ue(),n=$e(),a=Ut();t.exports=function(l){var c=e(this),h=r(l);if(i(c)<h.size)return!1;var d=h.getIterator();return n(d,function(u){if(!s(c,u))return a(d.iterator,"normal",!1)})!==!1}}),As=S.cw((t)=>{var e=gt(),s=$e(),i=he(),{Set:r,proto:n}=i,a=e(n.forEach),o=e(n.keys),l=o(new r).next;t.exports=function(c,h,d){return d?s({iterator:o(c),next:l},h):a(c,h)}}),Ge=S.cw((t)=>{var e=Ee(),s=function(r){return{size:r,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},i=function(r){return{size:r,has:function(){return!0},keys:function(){throw Error("e")}}};t.exports=function(r,n){var a=e("Set");try{new a()[r](s(0));try{return new a()[r](s(-1)),!1}catch(l){if(!n)return!0;try{return new a()[r](i(-1/0)),!1}catch(c){var o=new a([1,2]);return n(o[r](i(1/0)))}}}catch(l){return!1}}}),Kn=()=>S(835),Ss=S.cw((t)=>{var e=hr(),s=he();t.exports=e(s.proto,"size","get")||function(i){return i.size}}),Yl=S.cw((t)=>{var e=je(),s=he(),i=vr(),r=Ue(),n=$e(),{add:a,has:o,remove:l}=s;t.exports=function(h){var d=e(this),u=r(h).getIterator(),f=i(d);return n(u,function(p){if(o(d,p))l(f,p);else a(f,p)}),f}}),Kl=S.cw((t)=>{var e=je(),s=he().add,i=vr(),r=Ue(),n=$e();t.exports=function(o){var l=e(this),c=r(o).getIterator(),h=i(l);return n(c,function(d){s(h,d)}),h}}),yr=S.cw((t)=>{var e=qn(),s=vi(),i=e("keys");t.exports=function(r){return i[r]||(i[r]=s(r))}}),br=S.cw((t)=>{var e=zt(),s=mt(),i=lr(),r="__core-js_shared__",n=t.exports=s[r]||i(r,{});(n.versions||(n.versions=[])).push({version:"3.51.0",mode:e?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.51.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),qn=S.cw((t)=>{var e=br(),s=Object.create||Object;t.exports=function(i,r){return e[i]||(e[i]=r||s(null))}}),fi=S.cw((t)=>{var e=fl(),s=_t(),i=mt(),r=i.String;t.exports=!!Object.getOwnPropertySymbols&&!s(function(){var n=Symbol("symbol detection");return!r(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&e&&e<41})}),ql=S.cw((t)=>{var e=gt();t.exports=e(1.1 .valueOf)}),Jl=S.cw((t)=>{var e=_r(),{max:s,min:i}=Math;t.exports=function(r,n){var a=e(r);return a<0?s(a+n,0):i(a,n)}}),Ql=S.cw((t)=>{var e=Qn(),s=TypeError;t.exports=function(i){var r=e(i,"number");if(typeof r=="number")throw new s("Can't convert number to bigint");return BigInt(r)}}),pi=S.cw((t)=>{var e=wl(),s=Yn();t.exports=function(i){return e(s(i))}}),_r=()=>S(291),Zl=()=>S(14),wr=()=>S(981),Jn=()=>S(590),Qn=S.cw((t)=>{var e=At(),s=Ht(),i=pr(),r=ci(),n=jl(),a=ee(),o=TypeError,l=a("toPrimitive");t.exports=function(c,h){if(!s(c)||i(c))return c;var d=r(c,l),u;if(d){if(h===void 0)h="default";if(u=e(d,c,h),!s(u)||i(u))return u;throw new o("Can't convert object to primitive value")}if(h===void 0)h="number";return n(c,h)}}),Zn=S.cw((t)=>{var e=Qn(),s=pr();t.exports=function(i){var r=e(i,"string");return s(r)?r:r+""}}),tc=S.cw((t)=>{var e=ee(),s=e("toStringTag"),i={};i[s]="z",t.exports=String(i)==="[object z]"}),gi=S.cw((t)=>{var e=ri(),s=String;t.exports=function(i){if(e(i)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return s(i)}}),mi=S.cw((t)=>{var e=String;t.exports=function(s){try{return e(s)}catch(i){return"Object"}}}),vi=S.cw((t)=>{var e=gt(),s=0,i=Math.random(),r=e(1.1 .toString);t.exports=function(n){return"Symbol("+(n===void 0?"":n)+")_"+r(++s+i,36)}}),ta=S.cw((t)=>{var e=mt(),s=gt(),i=kn(),r=In(),n=jt(),a=On(),o=Ln(),l=ii(),{c2i:c,c2iUrl:h}=a,{SyntaxError:d,TypeError:u,Array:f}=e,p=s("".charAt),g=Math.floor,m=function(b,_){var w=b.length;for(;_<w;_++){var A=p(b,_);if(A!==" "&&A!=="\t"&&A!==`
3
+ `&&A!=="\f"&&A!=="\r")break}return _},v=function(b,_,w){var A=b.length;if(A<4)b+=A===2?"AA":"A";var x=(_[p(b,0)]<<18)+(_[p(b,1)]<<12)+(_[p(b,2)]<<6)+_[p(b,3)],E=[x>>16&255,x>>8&255,x&255];if(A===2){if(w&&E[1]!==0)throw new d("Extra bits");return[E[0]]}if(A===3){if(w&&E[2]!==0)throw new d("Extra bits");return[E[0],E[1]]}return E},y=function(b,_,w){var A=_.length;for(var x=0;x<A;x++)b[w+x]=_[x];return w+A};t.exports=function(b,_,w,A){r(b),i(_);var x=o(_)==="base64"?c:h,E=_?_.lastChunkHandling:void 0;if(E===void 0)E="loose";if(E!=="loose"&&E!=="strict"&&E!=="stop-before-partial")throw new u("Incorrect `lastChunkHandling` option");if(w)l(w.buffer);var T=b.length,k=w||f(g(T*3/4)),C=0,R=0,B="",N=0;if(A)while(!0){if(N=m(b,N),N===T){if(B.length>0){if(E==="stop-before-partial")break;if(E==="loose"){if(B.length===1)throw new d("Malformed padding: exactly one additional character");C=y(k,v(B,x,!1),C)}else throw new d("Missing padding")}R=T;break}var M=p(b,N);if(++N,M==="="){if(B.length<2)throw new d("Padding is too early");if(N=m(b,N),B.length===2){if(N===T){if(E==="stop-before-partial")break;throw new d("Malformed padding: only one =")}if(p(b,N)==="=")++N,N=m(b,N)}if(N<T)throw new d("Unexpected character after padding");C=y(k,v(B,x,E==="strict"),C),R=T;break}if(!n(x,M))throw new d("Unexpected character");var F=A-C;if(F===1&&B.length===2||F===2&&B.length===3)break;if(B+=M,B.length===4){if(C=y(k,v(B,x,!1),C),B="",R=N,C===A)break}}if(!w)k.length=C;return{bytes:k,read:R,written:C}}}),ec=S.cw((t)=>{var e=mt(),s=gt(),{Uint8Array:i,SyntaxError:r}=e,n=Math.min,a=s("".match);t.exports=function(o,l){var c=o.length;if(c%2!==0)throw new r("String should be an even number of characters");var h=l?n(l.length,c/2):c/2,d=l||new i(h),u=a(o,/[\S\s]{2}/g),f=0;for(;f<h;f++){var p=+("0x"+u[f]+"0");if(p!==p)throw new r("String should only contain hex characters");d[f]=p>>4}return{bytes:d,read:f<<1}}}),sc=S.cw((t)=>{var e=_t(),s=ee(),i=Bt(),r=zt(),n=s("iterator");t.exports=!e(function(){var a=new URL("b?a=1&b=2&c=3","https://a"),o=a.searchParams,l=new URLSearchParams("a=1&a=2&b=3"),c="";return a.pathname="c%20d",o.forEach(function(h,d){o.delete("b"),c+=d+h}),l.delete("a",2),l.delete("b",void 0),r&&(!a.toJSON||!l.has("a",1)||l.has("a",2)||!l.has("a",void 0)||l.has("b"))||!o.size&&(r||!i)||!o.sort||a.href!=="https://a/c%20d?a=1&c=3"||o.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!o[n]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||c!=="a1c3"||new URL("https://x",void 0).host!=="x"})}),ea=S.cw((t)=>{var e=fi();t.exports=e&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),sa=S.cw((t)=>{var e=Bt(),s=_t();t.exports=e&&s(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),ic=()=>S(812),rc=S.cw((t)=>{var e=mt(),s=Ct(),i=e.WeakMap;t.exports=s(i)&&/native code/.test(String(i))}),yi=S.cw((t)=>{var e=gt(),s=WeakMap.prototype;t.exports={WeakMap,set:e(s.set),get:e(s.get),has:e(s.has),remove:e(s.delete)}}),ee=S.cw((t)=>{var e=mt(),s=qn(),i=jt(),r=vi(),n=fi(),a=ea(),o=e.Symbol,l=s("wks"),c=a?o.for||o:o&&o.withoutSetter||r;t.exports=function(h){if(!i(l,h))l[h]=n&&i(o,h)?o[h]:c("Symbol."+h);return l[h]}}),nc=S.cw(()=>{var t=nt(),e=ar().includes,s=_t(),i=Zo(),r=s(function(){return!Array(1).includes()}),n=s(function(){return[,1].includes(void 0,1)});t({target:"Array",proto:!0,forced:r||n},{includes:function(o){return e(this,o,arguments.length>1?arguments[1]:void 0)}}),i("includes")}),ac=S.cw(()=>{var t=nt(),e=wr(),s=Qe(),i=rl(),r=hl(),n=_t(),a=n(function(){return[].push.call({length:4294967296},1)!==4294967297}),o=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(c){return c instanceof TypeError}},l=a||!o();t({target:"Array",proto:!0,arity:1,forced:l},{push:function(h){var d=e(this),u=s(d),f=arguments.length;r(u+f);for(var p=0;p<f;p++)d[u]=arguments[p],u++;return i(d,u),u}})}),oc=S.cw(()=>{var t=nt(),e=mt(),s=Pn(),i=bt(),r=Ct(),n=gr(),a=Fn(),o=or(),l=_t(),c=jt(),h=ee(),d=Hn().IteratorPrototype,u=Bt(),f=zt(),p="constructor",g="Iterator",m=h("toStringTag"),v=TypeError,y=e[g],b=f||!r(y)||y.prototype!==d||!l(function(){y({})}),_=function(){if(s(this,d),n(this)===d)throw new v("Abstract class Iterator not directly constructable")},w=function(A,x){if(u)a(d,A,{configurable:!0,get:function(){return x},set:function(E){if(i(this),this===d)throw new v("You can't redefine this property");if(c(this,A))this[A]=E;else o(this,A,E)}});else d[A]=x};if(!c(d,m))w(m,g);if(b||!c(d,p)||d[p]===Object)w(p,_);_.prototype=d,t({global:!0,constructor:!0,forced:b},{Iterator:_})});var lc=S.cw(()=>{var t=nt(),e=At(),s=bt(),i=te(),r=zn(),n=Jn(),a=Ut(),o=_s(),l=ws(),c=ye(),h=zt(),d=RangeError,u=1/0,f=!h&&!l("drop",0),p=!h&&!f&&c("drop",RangeError),g=h||f||p||!function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(v){return v instanceof d}}(),m=o(function(){var v=this.iterator,y=this.next,b,_;while(this.remaining)if(this.remaining--,b=s(e(y,v)),_=this.done=!!b.done,_)return;if(b=s(e(y,v)),_=this.done=!!b.done,!_)return b.value});t({target:"Iterator",proto:!0,real:!0,forced:g},{drop:function(y){s(this);var b;try{if(b=n(r(+y)),b>9007199254740991&&b!==u)throw new d("The argument should be a safe integer")}catch(_){a(this,"throw",_)}if(p)return e(p,this,b);return new m(i(this),{remaining:b})}})}),cc=S.cw(()=>{var t=nt(),e=At(),s=Je(),i=Nt(),r=bt(),n=te(),a=Ut(),o=ye(),l=o("every",TypeError);t({target:"Iterator",proto:!0,real:!0,forced:l},{every:function(h){r(this);try{i(h)}catch(f){a(this,"throw",f)}if(l)return e(l,this,h);var d=n(this),u=0;return!s(d,function(f,p){if(!h(f,u++))return p()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),hc=S.cw(()=>{var t=nt(),e=At(),s=Nt(),i=bt(),r=te(),n=_s(),a=Rn(),o=zt(),l=Ut(),c=ws(),h=ye(),d=!o&&!c("filter",function(){}),u=!o&&!d&&h("filter",TypeError),f=o||d||u,p=n(function(){var g=this.iterator,m=this.predicate,v=this.next,y,b,_;while(!0){if(y=i(e(v,g)),b=this.done=!!y.done,b)return;if(_=y.value,a(g,m,[_,this.counter++],!0))return _}});t({target:"Iterator",proto:!0,real:!0,forced:f},{filter:function(m){i(this);try{s(m)}catch(v){l(this,"throw",v)}if(u)return e(u,this,m);return new p(r(this),{predicate:m})}})}),dc=S.cw(()=>{var t=nt(),e=At(),s=Je(),i=Nt(),r=bt(),n=te(),a=Ut(),o=ye(),l=o("find",TypeError);t({target:"Iterator",proto:!0,real:!0,forced:l},{find:function(h){r(this);try{i(h)}catch(f){a(this,"throw",f)}if(l)return e(l,this,h);var d=n(this),u=0;return s(d,function(f,p){if(h(f,u++))return p(f)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})}),uc=S.cw(()=>{var t=nt(),e=At(),s=Nt(),i=bt(),r=te(),n=bl(),a=_s(),o=Ut(),l=_t(),c=zt(),h=ws(),d=ye(),u=!c&&l(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),f=!c&&!u&&!h("flatMap",function(){}),p=!c&&!u&&!f&&d("flatMap",TypeError),g=c||u||f||p,m=a(function(){var v=this.iterator,y=this.mapper,b,_;while(!0){if(_=this.inner)try{if(b=i(e(_.next,_.iterator)),!b.done)return b.value;this.inner=null}catch(w){o(v,"throw",w)}if(b=i(e(this.next,v)),this.done=!!b.done)return;try{this.inner=n(y(b.value,this.counter++),!1)}catch(w){o(v,"throw",w)}}});t({target:"Iterator",proto:!0,real:!0,forced:g},{flatMap:function(y){i(this);try{s(y)}catch(b){o(this,"throw",b)}if(p)return e(p,this,y);return new m(r(this),{mapper:y,inner:null})}})}),fc=S.cw(()=>{var t=nt(),e=At(),s=Je(),i=Nt(),r=bt(),n=te(),a=Ut(),o=ye(),l=o("forEach",TypeError);t({target:"Iterator",proto:!0,real:!0,forced:l},{forEach:function(h){r(this);try{i(h)}catch(f){a(this,"throw",f)}if(l)return e(l,this,h);var d=n(this),u=0;s(d,function(f){h(f,u++)},{IS_RECORD:!0})}})}),pc=S.cw(()=>{var t=nt(),e=At(),s=Nt(),i=bt(),r=te(),n=_s(),a=Rn(),o=Ut(),l=ws(),c=ye(),h=zt(),d=!h&&!l("map",function(){}),u=!h&&!d&&c("map",TypeError),f=h||d||u,p=n(function(){var g=this.iterator,m=i(e(this.next,g)),v=this.done=!!m.done;if(!v)return a(g,this.mapper,[m.value,this.counter++],!0)});t({target:"Iterator",proto:!0,real:!0,forced:f},{map:function(m){i(this);try{s(m)}catch(v){o(this,"throw",v)}if(u)return e(u,this,m);return new p(r(this),{mapper:m})}})}),gc=S.cw(()=>{var t=nt(),e=At(),s=Je(),i=Nt(),r=bt(),n=te(),a=Ut(),o=ye(),l=o("some",TypeError);t({target:"Iterator",proto:!0,real:!0,forced:l},{some:function(h){r(this);try{i(h)}catch(f){a(this,"throw",f)}if(l)return e(l,this,h);var d=n(this),u=0;return s(d,function(f,p){if(h(f,u++))return p()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),mc=S.cw(()=>{var t=nt(),e=At(),s=bt(),i=te(),r=zn(),n=Jn(),a=_s(),o=Ut(),l=ws(),c=ye(),h=zt(),d=RangeError,u=1/0,f=!h&&!l("take",1),p=!h&&!f&&c("take",RangeError),g=h||f||p||!function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(v){return v instanceof d}}(),m=a(function(){var v=this.iterator;if(!this.remaining--)return this.done=!0,o(v,"normal",void 0);var y=s(e(this.next,v)),b=this.done=!!y.done;if(!b)return y.value});t({target:"Iterator",proto:!0,real:!0,forced:g},{take:function(y){s(this);var b;try{if(b=n(r(+y)),b>9007199254740991&&b!==u)throw new d("The argument should be a safe integer")}catch(_){o(this,"throw",_)}if(p)return e(p,this,b);return new m(i(this),{remaining:b})}})}),vc=S.cw(()=>{var t=nt(),e=bt(),s=or(),i=Je(),r=te();t({target:"Iterator",proto:!0,real:!0},{toArray:function(){var a=[],o=0;return i(r(e(this)),function(l){s(a,o++,l)},{IS_RECORD:!0}),a}})}),yc=S.cw(()=>{var t=nt(),e=Bt(),s=mt(),i=Ee(),r=gt(),n=At(),a=Ct(),o=Ht(),l=fr(),c=jt(),h=gi(),d=Qe(),u=or(),f=_t(),p=Xn(),g=fi(),{JSON:m,Number:v,SyntaxError:y}=s,b=m&&m.parse,_=i("Object","keys"),w=Object.getOwnPropertyDescriptor,A=r("".charAt),x=r("".slice),E=r(/./.exec),T=r([].push),k=/^\d$/,C=/^[1-9]$/,R=/^[\d-]$/,B=/^[\t\n\r ]$/,N=0,M=1,F=function(P,I){P=h(P);var D=new q(P,0),G=D.parse(),z=G.value,tt=D.skip(B,G.end);if(tt<P.length)throw new y('Unexpected extra character: "'+A(P,tt)+'" after the parsed data at: '+tt);return a(I)?j({"":z},"",I,G):z},j=function(P,I,D,G){var z=P[I],tt=G&&z===G.value,V=tt&&typeof G.source=="string"?{source:G.source}:{},Q,ht,Mt,dt,kt;if(o(z)){var ss=l(z),Ce=tt?G.nodes:ss?[]:{};if(ss){Q=Ce.length,Mt=d(z);for(dt=0;dt<Mt;dt++)X(z,dt,j(z,""+dt,D,dt<Q?Ce[dt]:void 0))}else{ht=_(z),Mt=d(ht);for(dt=0;dt<Mt;dt++)kt=ht[dt],X(z,kt,j(z,kt,D,c(Ce,kt)?Ce[kt]:void 0))}}return n(D,P,I,z,V)},X=function(P,I,D){if(e){var G=w(P,I);if(G&&!G.configurable)return}if(D===void 0)delete P[I];else u(P,I,D)},it=function(P,I,D,G){this.value=P,this.end=I,this.source=D,this.nodes=G},q=function(P,I){this.source=P,this.index=I};q.prototype={fork:function(P){return new q(this.source,P)},parse:function(){var P=this.source,I=this.skip(B,this.index),D=this.fork(I),G=A(P,I);if(E(R,G))return D.number();switch(G){case"{":return D.object();case"[":return D.array();case'"':return D.string();case"t":return D.keyword(!0);case"f":return D.keyword(!1);case"n":return D.keyword(null)}throw new y('Unexpected character: "'+G+'" at: '+I)},node:function(P,I,D,G,z){return new it(I,G,P?null:x(this.source,D,G),z)},object:function(){var P=this.source,I=this.index+1,D=!1,G={},z={},tt=!1;while(I<P.length){if(I=this.until(['"',"}"],I),A(P,I)==="}"&&!D){I++,tt=!0;break}var V=this.fork(I).string(),Q=V.value;I=V.end,I=this.until([":"],I)+1,I=this.skip(B,I),V=this.fork(I).parse(),u(z,Q,V),u(G,Q,V.value),I=this.until([",","}"],V.end);var ht=A(P,I);if(ht===",")D=!0,I++;else if(ht==="}"){I++,tt=!0;break}}if(!tt)throw new y("Unterminated object at: "+I);return this.node(M,G,this.index,I,z)},array:function(){var P=this.source,I=this.index+1,D=!1,G=[],z=[],tt=!1;while(I<P.length){if(I=this.skip(B,I),A(P,I)==="]"&&!D){I++,tt=!0;break}var V=this.fork(I).parse();if(T(z,V),T(G,V.value),I=this.until([",","]"],V.end),A(P,I)===",")D=!0,I++;else if(A(P,I)==="]"){I++,tt=!0;break}}if(!tt)throw new y("Unterminated array at: "+I);return this.node(M,G,this.index,I,z)},string:function(){var P=this.index,I=p(this.source,this.index+1);return this.node(N,I.value,P,I.end)},number:function(){var P=this.source,I=this.index,D=I;if(A(P,D)==="-")D++;if(A(P,D)==="0")D++;else if(E(C,A(P,D)))D=this.skip(k,D+1);else throw new y("Failed to parse number at: "+D);if(A(P,D)==="."){var G=D+1;if(D=this.skip(k,G),G===D)throw new y("Failed to parse number's fraction at: "+D)}if(A(P,D)==="e"||A(P,D)==="E"){if(D++,A(P,D)==="+"||A(P,D)==="-")D++;var z=D;if(D=this.skip(k,D),z===D)throw new y("Failed to parse number's exponent value at: "+D)}return this.node(N,v(x(P,I,D)),I,D)},keyword:function(P){var I=""+P,D=this.index,G=D+I.length;if(x(this.source,D,G)!==I)throw new y("Failed to parse value at: "+D);return this.node(N,P,D,G)},skip:function(P,I){var D=this.source;for(;I<D.length;I++)if(!E(P,A(D,I)))break;return I},until:function(P,I){I=this.skip(B,I);var D=A(this.source,I);for(var G=0;G<P.length;G++)if(P[G]===D)return I;throw new y('Unexpected character: "'+D+'" at: '+I)}};var Z=f(function(){var P="9007199254740993",I;return b(P,function(D,G,z){I=z.source}),I!==P}),J=g&&!f(function(){return 1/b("-0 \t")!==-1/0});t({target:"JSON",stat:!0,forced:Z},{parse:function(I,D){return J&&!a(D)?b(I):F(I,D)}})}),bc=S.cw(()=>{var t=nt(),e=Ee(),s=At(),i=gt(),r=_t(),n=fr(),a=Ct(),o=Ht(),l=di(),c=Il(),h=pr(),d=He(),u=ql(),f=ar().includes,p=jt(),g=gi(),m=Xn(),v=vi(),y=fi(),b=Ol(),_=String,w=TypeError,A=e("JSON","stringify"),x=e("BigInt"),E=i("".valueOf),T=i((!0).valueOf),k=x&&i(x.prototype.valueOf),C=i(/./.exec),R=i("".charAt),B=i("".charCodeAt),N=i("".replace),M=i("".slice),F=i([].push),j=i([].pop),X=i(1.1 .toString),it=/[\uD800-\uDFFF]/g,q=/^[\uD800-\uDBFF]$/,Z=/^[\uDC00-\uDFFF]$/,J=/^\d+$/,P=v(),I=v(),D=v(),G=P.length,z=I.length,tt=!y||r(function(){var rt=e("Symbol")("stringify detection");return A([rt])!=="[null]"||A({a:rt})!=="{}"||A(Object(rt))!=="{}"}),V=r(function(){return A("\uDF06\uD834")!=='"\\udf06\\ud834"'||A("\uDEAD")!=='"\\udead"'}),Q=b?e("JSON","isRawJSON"):c,ht=tt?function(rt,ut,vt){return A(rt,function(Ot,Rt){var It=s(ut,this,Ot,Rt);if(!h(It))return It},vt)}:A,Mt=function(rt,ut,vt){var Ot=R(vt,ut-1),Rt=R(vt,ut+1);if(C(q,rt)&&!C(Z,Rt)||C(Z,rt)&&!C(q,Ot))return"\\u"+X(B(rt,0),16);return rt},dt=function(rt){if(!n(rt))return;var ut=rt.length,vt=[],Ot=l(null);for(var Rt=0;Rt<ut;Rt++){var It=rt[Rt],se;if(typeof It=="string")se=It;else if(typeof It=="number"||d(It)==="Number"||d(It)==="String")se=g(It);else continue;if(!p(Ot,se))Ot[se]=!0,F(vt,se)}return vt},kt=function(rt,ut){try{return rt(ut),!0}catch(vt){return!1}},ss=function(rt){var ut=d(rt);return ut==="Number"&&kt(u,rt)||ut==="String"&&kt(E,rt)||ut==="Boolean"&&kt(T,rt)||!!k&&ut==="BigInt"&&kt(k,rt)},Ce=function(rt){if(!o(rt)||a(rt)||n(rt))return!1;try{return!ss(rt)}catch(ut){return!0}},Vo=function(rt,ut){return{toJSON:function(){var vt=rt[ut];if(o(vt)||typeof vt=="bigint"){var Ot=vt.toJSON;if(a(Ot))vt=s(Ot,vt,ut)}return vt}}},Wo=function(rt){for(var ut=0,vt=rt.length;ut<vt;ut++)if(C(J,rt[ut]))return I;return""},Xo=function(rt,ut,vt){var Ot=l(null);for(var Rt=0,It=ut.length;Rt<It;Rt++){var se=ut[Rt];Ot[vt+se]=Vo(rt,se)}return Ot[D]=null,Ot};if(A)t({target:"JSON",stat:!0,arity:3,forced:tt||V||!b},{stringify:function(ut,vt,Ot){var Rt=a(vt)?vt:void 0,It=Rt?void 0:dt(vt),se=It&&Wo(It),Yr=[],Hi=[],Kr=[],ks,Ui=!1,qr=!0,de=ht(ut,function(ns,ne){if(ns=_(ns),It){if(ns===D){j(Hi),ks=j(Kr);return}if(qr)qr=!1;else if(this!==ks&&!n(this)&&!f(It,ns))return}else if(Rt)ne=s(Rt,this,ns,ne);if(Q(ne)){if(b)return ne;return Ui=!0,P+(F(Yr,ne.rawJSON)-1)}if(It&&Ce(ne)){if(f(Hi,ne))throw new w("Converting circular structure to JSON");var Zr=Xo(ne,It,se);if(F(Hi,ne),F(Kr,ks),ks=Zr,se)Ui=!0;return Zr}return ne},Ot);if(typeof de!="string")return de;if(V)de=N(de,it,Mt);if(!Ui)return de;var is="",Yo=de.length;for(var Ve=0;Ve<Yo;Ve++){var Jr=R(de,Ve);if(Jr==='"'){var Qr=m(de,++Ve).end-1,rs=M(de,Ve,Qr);if(M(rs,0,G)===P)is+=Yr[M(rs,G)];else if(M(rs,0,z)===I)is+='"'+M(rs,z)+'"';else is+='"'+rs+'"';Ve=Qr}else is+=Jr}return is}})}),_c=S.cw(()=>{var t=nt(),e=Nt(),s=$n(),i=zt(),{get:r,has:n,set:a}=s;t({target:"Map",proto:!0,real:!0,forced:i},{getOrInsertComputed:function(l,c){var h=n(this,l);if(e(c),h)return r(this,l);if(l===0&&1/l===-1/0)l=0;var d=c(l);return a(this,l,d),d}})}),wc=S.cw(()=>{var t=nt(),e=$n(),s=zt(),{get:i,has:r,set:n}=e;t({target:"Map",proto:!0,real:!0,forced:s},{getOrInsert:function(o,l){if(r(this,o))return i(this,o);return n(this,o,l),l}})}),Ac=S.cw(()=>{var t=nt(),e=gt(),s=Je(),i=_t(),r=Nn(),n=mr(),a=ee(),o=RangeError,l=TypeError,c=1/0,h=NaN,{sumPrecise:d,abs:u,pow:f}=Math,p=e([].push),g=a("iterator"),m=f(2,1023),v=f(2,53)-1,y=Number.MAX_VALUE,b=f(2,971),_={},w={},A={},x={},E={},T=i(function(){if(d([-1])!==-1||d([-y])!==-y)return!0;if(!n)return!1;try{return d(n([1],{})),!0}catch(R){}try{var C={};return C[g]=function(){return this},d(n(r([1]),C)),!0}catch(R){}}),k=function(C,R){var B=C+R,N=R-(B-C);return{hi:B,lo:N}};t({target:"Math",stat:!0,forced:T},{sumPrecise:function(R){var B=[],N=0,M=x;switch(s(R,function(Q){if(++N>v)throw new o("Maximum allowed index exceeded");if(typeof Q!="number")throw new l("Value is not a number");if(M!==_){if(Q!==Q)M=_;else if(Q===c)M=M===w?_:A;else if(Q===-c)M=M===A?_:w;else if((Q!==0||1/Q===c)&&(M===x||M===E))M=E,p(B,Q)}}),M){case _:return h;case w:return-c;case A:return c;case x:return-0}var F=[],j=0,X,it,q,Z,J,P;for(var I=0;I<B.length;I++){X=B[I];var D=0;for(var G=0;G<F.length;G++){if(it=F[G],u(X)<u(it))P=X,X=it,it=P;if(q=k(X,it),Z=q.hi,J=q.lo,u(Z)===c){var z=Z===c?1:-1;if(j+=z,X=X-z*m-z*m,u(X)<u(it))P=X,X=it,it=P;q=k(X,it),Z=q.hi,J=q.lo}if(J!==0)F[D++]=J;X=Z}if(F.length=D,X!==0)p(F,X)}var tt=F.length-1;if(Z=0,J=0,j!==0){var V=tt>=0?F[tt]:0;if(tt--,u(j)>1||j>0&&V>0||j<0&&V<0)return j>0?c:-c;if(q=k(j*m,V/2),Z=q.hi,J=q.lo,J*=2,u(2*Z)===c){if(Z>0)return Z===m&&J===-(b/2)&&tt>=0&&F[tt]<0?y:c;return Z===-m&&J===b/2&&tt>=0&&F[tt]>0?-y:-c}if(J!==0)F[++tt]=J,J=0;Z*=2}while(tt>=0)if(q=k(Z,F[tt--]),Z=q.hi,J=q.lo,J!==0)break;if(tt>=0&&(J<0&&F[tt]<0||J>0&&F[tt]>0)){if(it=J*2,X=Z+it,it===X-Z)Z=X}return Z}})}),Sc=S.cw(()=>{var t=nt(),e=mt(),s=gl(),i=nl(),r=$l(),n=Gn(),a=Nt(),o=Ul(),l=_t(),c=e.Promise,h=!1,d=!c||!c.try||l(function(){var u=c.resolve();return c.try(function(f){return h=f===8,u},8)!==u})||!h;t({target:"Promise",stat:!0,forced:d},{try:function(u){var f=arguments.length>1?i(arguments,1):[],p=o(function(){return s(a(u),void 0,f)});if(!p.error)return r(this,p.value);var g=n.f(this),m=g.reject;return m(p.value),g.promise}})}),Ec=S.cw(()=>{var t=nt(),e=Gl(),s=_t(),i=Ge(),r=!i("difference",function(a){return a.size===0}),n=r||s(function(){var a={size:1,has:function(){return!0},keys:function(){var l=0;return{next:function(){var c=l++>1;if(o.has(1))o.clear();return{done:c,value:2}}}}},o=new Set([1,2,3,4]);return o.difference(a).size!==3});t({target:"Set",proto:!0,real:!0,forced:n},{difference:e})}),xc=S.cw(()=>{var t=nt(),e=_t(),s=zl(),i=Ge(),r=!i("intersection",function(n){return n.size===2&&n.has(1)&&n.has(2)})||e(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});t({target:"Set",proto:!0,real:!0,forced:r},{intersection:s})}),Tc=S.cw(()=>{var t=nt(),e=Vl(),s=Ge(),i=!s("isDisjointFrom",function(r){return!r});t({target:"Set",proto:!0,real:!0,forced:i},{isDisjointFrom:e})}),Cc=S.cw(()=>{var t=nt(),e=Wl(),s=Ge(),i=!s("isSubsetOf",function(r){return r});t({target:"Set",proto:!0,real:!0,forced:i},{isSubsetOf:e})}),Ic=S.cw(()=>{var t=nt(),e=Xl(),s=Ge(),i=!s("isSupersetOf",function(r){return!r});t({target:"Set",proto:!0,real:!0,forced:i},{isSupersetOf:e})}),Pc=S.cw(()=>{var t=nt(),e=Yl(),s=Kn(),i=Ge(),r=!i("symmetricDifference")||!s("symmetricDifference");t({target:"Set",proto:!0,real:!0,forced:r},{symmetricDifference:e})}),kc=S.cw(()=>{var t=nt(),e=Kl(),s=Kn(),i=Ge(),r=!i("union")||!s("union");t({target:"Set",proto:!0,real:!0,forced:r},{union:e})}),Mc=S.cw(()=>{var t=sl(),e=xl(),s=Qe(),i=_r(),r=Ql(),{aTypedArray:n,getTypedArrayConstructor:a,exportTypedArrayMethod:o}=t,l=RangeError,c=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(d){return d===8}}(),h=c&&function(){try{new Int8Array(1).with(-0.5,1)}catch(d){return!0}}();o("with",function(d,u){var f=n(this),p=s(f),g=i(d),m=g<0?p+g:g,v=e(f)?r(u):+u;if(m>=p||m<0)throw new l("Incorrect index");var y=new(a(f))(p),b=0;for(;b<p;b++)y[b]=b===m?v:f[b];return y},!c||h)}),Oc=S.cw(()=>{var t=nt(),e=mt(),s=il(),i=ta(),r=e.Uint8Array,n=!r||!r.fromBase64||!function(){try{r.fromBase64("a");return}catch(a){}try{r.fromBase64("",null)}catch(a){return!0}}();if(r)t({target:"Uint8Array",stat:!0,forced:n},{fromBase64:function(o){var l=i(o,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return s(r,l.bytes)}})}),Rc=S.cw(()=>{var t=nt(),e=mt(),s=ta(),i=si(),r=e.Uint8Array,n=!r||!r.prototype.setFromBase64||!function(){var a=new r([255,255,255,255,255]);try{a.setFromBase64("",null);return}catch(o){}try{a.setFromBase64("a");return}catch(o){}try{a.setFromBase64("MjYyZg===")}catch(o){return a[0]===50&&a[1]===54&&a[2]===50&&a[3]===255&&a[4]===255}}();if(r)t({target:"Uint8Array",proto:!0,forced:n},{setFromBase64:function(o){i(this);var l=s(o,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:l.read,written:l.written}}})}),Fc=S.cw(()=>{var t=nt(),e=mt(),s=In(),i=si(),r=ii(),n=ec();function a(){try{var o=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(o).setFromHex("cafed00d")}catch(l){return!0}}if(e.Uint8Array)t({target:"Uint8Array",proto:!0,forced:a()},{setFromHex:function(l){i(this),s(l),r(this.buffer);var c=n(l,this).read;return{read:c,written:c/2}}})}),Dc=S.cw(()=>{var t=nt(),e=mt(),s=gt(),i=kn(),r=si(),n=ii(),a=On(),o=Ln(),{i2c:l,i2cUrl:c}=a,{floor:h,ceil:d}=Math,u=s("".charAt),{Uint8Array:f,Array:p}=e,g=s([].join),m=!f||!f.prototype.toBase64||!function(){try{var v=new f;v.toBase64(null)}catch(y){return!0}}();if(f)t({target:"Uint8Array",proto:!0,forced:m},{toBase64:function(){var y=r(this),b=arguments.length?i(arguments[0]):void 0,_=o(b)==="base64"?l:c,w=!!b&&!!b.omitPadding;n(this.buffer);var A=0,x=y.length,E=p(w?h(x/3)*4+(x%3?x%3+1:0):d(x/3)*4),T=0,k,C=function(R){return u(_,k>>6*R&63)};for(;A+2<x;A+=3)k=(y[A]<<16)+(y[A+1]<<8)+y[A+2],E[T++]=C(3),E[T++]=C(2),E[T++]=C(1),E[T++]=C(0);if(A+2===x){if(k=(y[A]<<16)+(y[A+1]<<8),E[T++]=C(3),E[T++]=C(2),E[T++]=C(1),!w)E[T++]="="}else if(A+1===x){if(k=y[A]<<16,E[T++]=C(3),E[T++]=C(2),!w)E[T++]="=",E[T++]="="}return g(E,"")}})}),Lc=S.cw(()=>{var t=nt(),e=mt(),s=gt(),i=si(),r=ii(),n=s(1.1 .toString),a=s([].join),o=Array,l=e.Uint8Array,c=!l||!l.prototype.toHex||!function(){try{var h=new l([255,255,255,255,255,255,255,255]);return h.toHex()==="ffffffffffffffff"}catch(d){return!1}}();if(l)t({target:"Uint8Array",proto:!0,forced:c},{toHex:function(){i(this),r(this.buffer);var d=o(this.length);for(var u=0,f=this.length;u<f;u++){var p=n(this[u],16);d[u]=p.length===1?"0"+p:p}return a(d,"")}})}),Nc=S.cw(()=>{var t=nt(),e=Nt(),s=Qo(),i=Jo(),r=yi(),n=zt(),{get:a,has:o,set:l}=r,c=n||!function(){try{if(WeakMap.prototype.getOrInsertComputed)new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(h){return h instanceof TypeError}}();t({target:"WeakMap",proto:!0,real:!0,forced:c},{getOrInsertComputed:function(d,u){if(!n)s(this);if(i(d),e(u),o(this,d))return a(this,d);var f=u(d);return l(this,d,f),f}})}),Bc=S.cw(()=>{var t=nt(),e=yi(),s=zt(),{get:i,has:r,set:n}=e;t({target:"WeakMap",proto:!0,real:!0,forced:s},{getOrInsert:function(o,l){if(r(this,o))return i(this,o);return n(this,o,l),l}})}),jc=S.cw(()=>{var t=nt(),e=mt(),s=Ee(),i=ai(),r=xe().f,n=jt(),a=Pn(),o=Al(),l=Rl(),c=dl(),h=pl(),d=Bt(),u=zt(),f="DOMException",p=s("Error"),g=s(f),m=function(){a(this,v);var B=arguments.length,N=l(B<1?void 0:arguments[0]),M=l(B<2?void 0:arguments[1],"Error"),F=new g(N,M),j=new p(N);return j.name=f,r(F,"stack",i(1,h(j.stack,1))),o(F,this,m),F},v=m.prototype=g.prototype,y="stack"in new p(f),b="stack"in new g(1,2),_=g&&d&&Object.getOwnPropertyDescriptor(e,f),w=!!_&&!(_.writable&&_.configurable),A=y&&!w&&!b;t({global:!0,constructor:!0,forced:u||A},{DOMException:A?m:g});var x=s(f),E=x.prototype;if(E.constructor!==x){if(!u)r(E,"constructor",i(1,x));for(var T in c)if(n(c,T)){var k=c[T],C=k.s;if(!n(x,C))r(x,C,i(6,k.c))}}}),Hc=S.cw(()=>{var t=nt(),e=Ee(),s=ic(),i=gi(),r=sc(),n=e("URL");t({target:"URL",stat:!0,forced:!r},{parse:function(o){var l=s(arguments.length,1),c=i(o),h=l<2||arguments[1]===void 0?void 0:i(arguments[1]);try{return new n(c,h)}catch(d){return null}}})});nc();ac();oc();hc();wc();_c();Ec();xc();Tc();Cc();Ic();Pc();kc();Mc();Rc();Fc();Dc();Lc();Hc();var Wt=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ce=[1/0,1/0,-1/0,-1/0],Re=new Float32Array(ce),Yi=[0.001,0,0,0.001,0,0];var Dt="http://www.w3.org/2000/svg",Vt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},we={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ye="pdfjs_internal_id_",qe="pdfjs_internal_editor_",K={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},st={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},Uc={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};var Et={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},js={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},yt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27};var Xe={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var bi={ERRORS:0,WARNINGS:1,INFOS:5},pe={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},as={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},$c={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},_i=bi.WARNINGS;function Gc(t){if(Number.isInteger(t))_i=t}function ia(){return _i}function wi(t){if(_i>=bi.INFOS)console.info(`Info: ${t}`)}function W(t){if(_i>=bi.WARNINGS)console.warn(`Warning: ${t}`)}function at(t){throw Error(t)}function wt(t,e){if(!t)at(e)}function zc(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function ra(t,e=null,s=null){if(!t)return null;if(s&&typeof t==="string"){if(s.addDefaultProtocol&&t.startsWith("www.")){if(t.match(/\./g)?.length>=2)t=`http://${t}`}if(s.tryConvertEncoding)try{t=Wc(t)}catch{}}let i=e?URL.parse(t,e):URL.parse(t);return zc(i)?i:null}function na(t,e,s=!1){let i=URL.parse(t);if(i)return i.hash=e,i.href;if(s&&ra(t,"http://example.com"))return t.split("#",1)[0]+`${e?`#${e}`:""}`;return""}function Ki(t){return t.substring(t.lastIndexOf("/")+1)}function L(t,e,s,i=!1){return Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:!0,writable:!1}),s}var ze=function(){function e(s,i){this.message=s,this.name=i}return e.prototype=Error(),e.constructor=e,e}();class zs extends ze{constructor(t,e){super(t,"PasswordException");this.code=e}}class cs extends ze{constructor(t,e){super(t,"UnknownErrorException");this.details=e}}class Vs extends ze{constructor(t){super(t,"InvalidPDFException")}}class gs extends ze{constructor(t,e,s){super(t,"ResponseException");this.status=e,this.missing=s}}class aa extends ze{constructor(t){super(t,"FormatError")}}class ve extends ze{constructor(t){super(t,"AbortException")}}function Vc(t){if(typeof t!=="object"||t?.length===void 0)at("Invalid argument for bytesToString");let e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);let i=[];for(let r=0;r<e;r+=s){let n=Math.min(r+s,e),a=t.subarray(r,n);i.push(String.fromCharCode.apply(null,a))}return i.join("")}function Ai(t){if(typeof t!=="string")at("Invalid argument for stringToBytes");let e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=t.charCodeAt(i)&255;return s}class lt{static get isLittleEndian(){let t=new Uint8Array(4);t[0]=1;let e=new Uint32Array(t.buffer,0,1);return L(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return L(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return L(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isVideoFrameSupported(){return L(this,"isVideoFrameSupported",typeof VideoFrame<"u")}static get isFloat16ArraySupported(){return L(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return L(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return L(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;if(this.isOffscreenCanvasSupported)t=new OffscreenCanvas(1,1).getContext("2d");else if(typeof document<"u")t=document.createElement("canvas").getContext("2d");return L(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return L(this,"isAlphaColorInputSupported",!1);let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",L(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return L(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class O{static get hexNums(){return L(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static get identity0to256Map(){return L(this,"identity0to256Map",Uint8Array.from({length:256},(t,e)=>e))}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){let i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){let i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){let h=t[s+c],d=t[s+c+1];t[s+c]=h*i+d*n+o,t[s+c+1]=h*r+d*a+l}}static applyInverseTransform(t,e){let s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){let i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=t[0],h=t[1],d=t[2],u=t[3],f=i*c+o,p=f,g=i*d+o,m=g,v=a*h+l,y=v,b=a*u+l,_=b;if(r!==0||n!==0){let w=r*c,A=r*d,x=n*h,E=n*u;f+=x,m+=x,g+=E,p+=E,v+=w,_+=w,b+=A,y+=A}s[0]=Math.min(s[0],f,g,Math.min(p,m)),s[1]=Math.min(s[1],v,b,Math.min(y,_)),s[2]=Math.max(s[2],f,g,Math.max(p,m)),s[3]=Math.max(s[3],v,b,Math.max(y,_))}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let s=t[0],i=t[1],r=t[2],n=t[3],a=s**2+i**2,o=s*r+i*n,l=r**2+n**2,c=(a+l)/2,h=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+h||1),e[1]=Math.sqrt(c-h||1)}static normalizeRect(t){let e=t.slice(0);if(t[0]>t[2])e[0]=t[2],e[2]=t[0];if(t[1]>t[3])e[1]=t[3],e[3]=t[1];return e}static intersect(t,e){let s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;let r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>n?null:[s,r,i,n]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static#t(t,e,s,i,r,n,a,o,l,c){if(l<=0||l>=1)return;let h=1-l,d=l*l,u=d*l,f=h*(h*(h*t+3*l*e)+3*d*s)+u*i,p=h*(h*(h*r+3*l*n)+3*d*a)+u*o;c[0]=Math.min(c[0],f),c[1]=Math.min(c[1],p),c[2]=Math.max(c[2],f),c[3]=Math.max(c[3],p)}static#e(t,e,s,i,r,n,a,o,l,c,h,d){if(Math.abs(l)<0.000000000001){if(Math.abs(c)>=0.000000000001)this.#t(t,e,s,i,r,n,a,o,-h/c,d);return}let u=c**2-4*h*l;if(u<0)return;let f=Math.sqrt(u),p=2*l;this.#t(t,e,s,i,r,n,a,o,(-c+f)/p,d),this.#t(t,e,s,i,r,n,a,o,(-c-f)/p,d)}static bezierBoundingBox(t,e,s,i,r,n,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,r,a,e,i,n,o,3*(-t+3*(s-r)+a),6*(t-2*s+r),3*(s-t),l),this.#e(t,s,r,a,e,i,n,o,3*(-e+3*(i-n)+o),6*(e-2*i+n),3*(i-e),l)}}function Wc(t){return decodeURIComponent(escape(t))}var $i=null,en=null;function Xc(t){if(!$i)$i=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,en=new Map([["ſt","ſt"]]);return t.replaceAll($i,(e,s,i)=>s?s.normalize("NFKC"):en.get(i))}function oa(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),Vc(t)}function Yc(t,e,s){if(!Array.isArray(s)||s.length<2)return!1;let[i,r,...n]=s;if(!t(i)&&!Number.isInteger(i))return!1;if(!e(r))return!1;let a=n.length,o=!0;switch(r.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(let l of n){if(typeof l==="number"||o&&l===null)continue;return!1}return!0}var Ze=()=>[],Ws=()=>new Map,qi=()=>Object.create(null),Kc=()=>new Set;if(typeof Blob.prototype.bytes!=="function")Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())};if(typeof Response.prototype.bytes!=="function")Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())};if(typeof Iterator.prototype.join!=="function")Iterator.prototype.join=function(t){return[...this].join(t)};pc();function pt(t,e,s){return Math.min(Math.max(t,e),s)}class Le{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class Si extends ze{constructor(t,e=0){super(t,"RenderingCancelledException");this.extraDelay=e}}function ts(t){if(t.startsWith("#")){let s=t.slice(1);return[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),s.length>=8?parseInt(s.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){let[s,i,r]=t.slice(4,-1).split(",").map((n)=>parseInt(n,10));return[s,i,r,1]}if(t.startsWith("rgba(")){let s=t.slice(5,-1).split(",");return[parseInt(s[0],10),parseInt(s[1],10),parseInt(s[2],10),parseFloat(s[3])]}let e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);if(e)return[Math.round(parseFloat(e[1])*255),Math.round(parseFloat(e[2])*255),Math.round(parseFloat(e[3])*255),e[4]!==void 0&&e[4]!=="none"?parseFloat(e[4]):1];return null}function Es(t){let e=ts(t);if(!e)return W(`Not a valid color format: "${t}"`),[0,0,0];return e.slice(0,3)}function ft(t){let{a:e,b:s,c:i,d:r,e:n,f:a}=t.getTransform();return[e,s,i,r,n,a]}function ue(t){let{a:e,b:s,c:i,d:r,e:n,f:a}=t.getTransform().invertSelf();return[e,s,i,r,n,a]}class Kt{constructor(){let{pixelRatio:t}=Kt;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let n=1/0,a=1/0,o=1/0;if(s=Kt.capPixels(s,r),s>0)n=Math.sqrt(s/(t*e));if(i!==-1)a=i/t,o=i/e;let l=Math.min(n,a,o);if(this.sx>l||this.sy>l)return this.sx=l,this.sy=l,!0;return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}function qc(t,e){e=pt(e??1,0,1);let s=255*(1-e);return t.map((i)=>Math.round(i*e+s))}function sn(t,e){let s=t[0]/255,i=t[1]/255,r=t[2]/255,n=Math.max(s,i,r),a=Math.min(s,i,r),o=(n+a)/2;if(n===a)e[0]=e[1]=0;else{let l=n-a;switch(e[1]=o<0.5?l/(n+a):l/(2-n-a),n){case s:e[0]=((i-r)/l+(i<r?6:0))*60;break;case i:e[0]=((r-s)/l+2)*60;break;case r:e[0]=((s-i)/l+4)*60;break}}e[2]=o}function Ji(t,e){let s=t[0],i=t[1],r=t[2],n=(1-Math.abs(2*r-1))*i,a=n*(1-Math.abs(s/60%2-1)),o=r-n/2;switch(Math.floor(s/60)){case 0:e[0]=n+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=n+o,e[2]=o;break;case 2:e[0]=o,e[1]=n+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=n+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=n+o;break;case 5:case 6:e[0]=n+o,e[1]=o,e[2]=a+o;break}}function Qi(t){return t<=0.03928?t/12.92:((t+0.055)/1.055)**2.4}function rn(t,e,s){Ji(t,s),s.map(Qi);let i=0.2126*s[0]+0.7152*s[1]+0.0722*s[2];Ji(e,s),s.map(Qi);let r=0.2126*s[0]+0.7152*s[1]+0.0722*s[2];return i>r?(i+0.05)/(r+0.05):(r+0.05)/(i+0.05)}var nn=new Map;function Jc(t,e){let s=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776,i=nn.get(s);if(i)return i;let r=new Float32Array(9),n=r.subarray(0,3),a=r.subarray(3,6);sn(t,a);let o=r.subarray(6,9);sn(e,o);let l=o[2]<0.5,c=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),rn(a,o,n)<c){let h,d;if(l)h=a[2],d=1;else h=0,d=a[2];let u=0.005;while(d-h>u){let f=a[2]=(h+d)/2;if(l===rn(a,o,n)<c)h=f;else d=f}a[2]=l?d:h}return Ji(a,n),i=O.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),nn.set(s,i),i}function la(t){let e=new Path2D;if(!t)return e;for(let s=0,i=t.length;s<i;)switch(t[s++]){case as.moveTo:e.moveTo(t[s++],t[s++]);break;case as.lineTo:e.lineTo(t[s++],t[s++]);break;case as.curveTo:e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);break;case as.quadraticCurveTo:e.quadraticCurveTo(t[s++],t[s++],t[s++],t[s++]);break;case as.closePath:e.closePath();break;default:W(`Unrecognized drawing path operator: ${t[s-1]}`);break}return e}mc();Bc();Nc();gc();bc();jc();lc();cc();dc();yc();class xs{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=n,s*=e;let o=(t[2]+t[0])/2,l=(t[3]+t[1])/2,c,h,d,u;if(i%=360,i<0)i+=360;switch(i){case 180:c=-1,h=0,d=0,u=1;break;case 90:c=0,h=1,d=1,u=0;break;case 270:c=0,h=-1,d=-1,u=0;break;case 0:c=1,h=0,d=0,u=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a)d=-d,u=-u;let f,p,g,m;if(c===0)f=Math.abs(l-t[1])*s+r,p=Math.abs(o-t[0])*s+n,g=(t[3]-t[1])*s,m=(t[2]-t[0])*s;else f=Math.abs(o-t[0])*s+r,p=Math.abs(l-t[1])*s+n,g=(t[2]-t[0])*s,m=(t[3]-t[1])*s;this.transform=[c*s,h*s,d*s,u*s,f-c*s*o-d*s*l,p-h*s*o-u*s*l],this.width=g,this.height=m}get rawDims(){let t=this.viewBox;return L(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new xs({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){let s=[t,e];return O.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){let s=[t,e];return O.applyInverseTransform(s,this.transform),s}}class ms{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(r){if(!r)return;let n=null,a=r.name;if(a==="#text")n=r.value;else if(!ms.shouldBuildText(a))return;else if(r?.attributes?.textContent)n=r.attributes.textContent;else if(r.value)n=r.value;if(n!==null)e.push({str:n});if(!r.children)return;for(let o of r.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}var Qc=/url\(|image-set\(/i,Zc=/^on/i;class Ar{static get _allowedHtmlElements(){return L(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return L(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return L(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return L(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return L(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,r){let n=i.getValue(e,{value:null});switch(s.name){case"textarea":if(n.value!==null)t.textContent=n.value;if(r==="print")break;t.addEventListener("input",(a)=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(n.value===s.attributes.xfaOn)t.setAttribute("checked",!0);else if(n.value===s.attributes.xfaOff)t.removeAttribute("checked");if(r==="print")break;t.addEventListener("change",(a)=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(n.value!==null)t.setAttribute("value",n.value);if(r==="print")break;t.addEventListener("input",(a)=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(n.value!==null){t.setAttribute("value",n.value);for(let a of s.children)if(a.attributes.value===n.value)a.attributes.selected=!0;else if(Object.hasOwn(a.attributes,"selected"))delete a.attributes.selected}t.addEventListener("input",(a)=>{let o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){let{attributes:n}=e,a=t instanceof HTMLAnchorElement;if(n.type==="radio")n.name=`${n.name}-${i}`;for(let[o,l]of Object.entries(n)){if(l===null||l===void 0||Zc.test(o))continue;if(i==="richText"&&!this._allowedRichTextAttributes.has(o))continue;switch(o){case"class":if(l.length)t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){let c=this._allowedRichTextStyles;for(let[h,d]of Object.entries(l))if(c.has(h)&&!Qc.test(d))t.style[h]=d}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:if(!a||o!=="href"&&o!=="newWindow")t.setAttribute(o,l)}}if(a)r?.addLinkAttributes(t,n.href,n.newWindow);if(s&&n.dataId)this.setupStorage(t,n.dataId,e,s)}static#t(t,e,s){if(s==="richText")return!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null;if(e)return e===Dt&&this._allowedSvgElements.has(t)?document.createElementNS(Dt,t):null;return this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){let{annotationStorage:e,linkService:s,xfaHtml:i}=t,r=t.intent||"display",n=this.#t(i.name,i.attributes?.xmlns,r)??document.createElement("div");if(i.attributes)this.setAttributes({html:n,element:i,intent:r,linkService:s});let a=r!=="richText",o=t.div;if(o.append(n),t.viewport){let h=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=h}if(a)o.setAttribute("class","xfaLayer xfaFont");let l=[];if(i.children.length===0){if(i.value){let h=document.createTextNode(i.value);if(n.append(h),a&&ms.shouldBuildText(i.name))l.push(h)}return{textDivs:l}}let c=[[i,-1,n]];while(c.length>0){let[h,d,u]=c.at(-1);if(d+1===h.children.length){c.pop();continue}let f=h.children[++c.at(-1)[1]];if(f===null)continue;let{name:p}=f;if(p==="#text"){let m=document.createTextNode(f.value);l.push(m),u.append(m);continue}let g=this.#t(p,f.attributes?.xmlns,r);if(!g)continue;if(u.append(g),f.attributes)this.setAttributes({html:g,element:f,storage:e,intent:r,linkService:s});if(f.children?.length>0)c.push([f,-1,g]);else if(f.value){let m=document.createTextNode(f.value);if(a&&ms.shouldBuildText(p))l.push(m);g.append(m)}}for(let h of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))h.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){let{width:i,height:r}=t.attributes.style;return new xs({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}async function Sr(t,e="text"){if(ds(t,document.baseURI)){let s=await fetch(t);if(!s.ok)throw Error(s.statusText);switch(e){case"blob":return s.blob();case"bytes":return s.bytes();case"json":return s.json()}return s.text()}return new Promise((s,i)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e==="bytes"?"arraybuffer":e,r.onreadystatechange=()=>{if(r.readyState!==XMLHttpRequest.DONE)return;if(r.status===200||r.status===0){switch(e){case"bytes":s(new Uint8Array(r.response));return;case"blob":case"json":s(r.response);return}s(r.responseText);return}i(Error(r.statusText))},r.send(null)})}function Ei(t){let e=t.length,s=0;while(s<e&&t[s].trim()==="")s++;return t.substring(s,s+5).toLowerCase()==="data:"}function Er(t){return typeof t==="string"&&/\.pdf$/i.test(t)}function th(t){return[t]=t.split(/[#?]/,1),Ki(t)}function eh(t,e="document.pdf"){if(typeof t!=="string")return e;if(Ei(t))return W('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=((o)=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(t);if(!i)return e;let r=(o)=>{try{let l=decodeURIComponent(o);if(l.includes("/")){if(l=Ki(l),l.length===4&&n.test(l))return o}return l}catch{return o}},n=/\.pdf$/i,a=Ki(i.pathname);if(n.test(a))return r(a);if(i.searchParams.size>0){let o=(c)=>[...c].findLast((h)=>n.test(h)),l=o(i.searchParams.values())??o(i.searchParams.keys());if(l)return r(l)}if(i.hash){let{hash:o}=i,l=-1;for(let{index:c}of o.matchAll(/\.pdf\b/gi))l=c;if(l>0){let c=l;while(c>0&&!"/?#=".includes(o[c-1]))c--;if(c<l)return r(o.slice(c,l+4))}}return e}function ds(t,e){let s=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(s?.protocol??"")}function re(t){t.preventDefault()}function Tt(t){t.preventDefault(),t.stopPropagation()}class Xs{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!=="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(e[9],10)||0;if(h=h>=0&&h<=59?h:0,l==="-")n+=c,a+=h;else if(l==="+")n-=c,a-=h;return new Date(Date.UTC(s,i,r,n,a,o))}}function sh(t){let e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(let s of t.keys()){e.style.color=s;let i=window.getComputedStyle(e).color;t.set(s,Es(i))}e.remove()}function Ne(t,e,s=!1,i=!0){if(e instanceof xs){let{pageWidth:r,pageHeight:n}=e.rawDims,{style:a}=t,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-y))`;if(!s||e.rotation%180===0)a.width=o,a.height=l;else a.width=l,a.height=o}if(i)t.setAttribute("data-main-rotation",e.rotation)}var Zi=new Set(["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"]);class ca{static get isDarkMode(){return L(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class ha{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:s}=window.getComputedStyle(t);return t.remove(),L(this,"commentForegroundColor",Es(s))}}function da({html:t,dir:e,className:s},i){let r=document.createDocumentFragment();if(typeof t==="string"){let n=document.createElement("p");n.dir=e||"auto";let a=t.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){let c=a[o];if(n.append(document.createTextNode(c)),o<l-1)n.append(document.createElement("br"))}r.append(n)}else Ar.render({xfaHtml:t,div:r,intent:"richText"});r.firstElementChild.classList.add("richText",s),i.append(r)}class us{#t=null;#e=null;#s;#i=null;#r=null;#n=null;#a=null;#o=null;static#l=null;constructor(t){this.#s=t,us.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#s._uiManager._signal;if(e instanceof AbortSignal&&!e.aborted)t.addEventListener("contextmenu",re,{signal:e}),t.addEventListener("pointerdown",us.#c,{signal:e});let s=this.#i=document.createElement("div");s.className="buttons",t.append(s);let i=this.#s.toolbarPosition;if(i){let{style:r}=t,n=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*n}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#c(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,Tt(t)}#h(t){this.#s._focusEventsAllowed=!0,Tt(t)}#f(t){let e=this.#s._uiManager._signal;if(!(e instanceof AbortSignal)||e.aborted)return!1;return t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#h.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",re,{signal:e}),!0}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown(),this.#n?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");if(s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",us.#l[t]),this.#f(s))s.addEventListener("click",(i)=>{e.delete()},{signal:e._signal});this.#i.append(s)}get#p(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#i.append(e,this.#p),this.#r=t}addComment(t,e=null){if(this.#n)return;let s=t.renderForToolbar();if(!s)return;this.#f(s);let i=this.#a=this.#p;if(!e)this.#i.append(s,i);else this.#i.insertBefore(s,e),this.#i.insertBefore(i,e);this.#n=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;let e=t.renderButton();this.#f(e),this.#i.append(e,this.#p)}async addEditSignatureButton(t){let e=this.#o=await t.renderEditButton(this.#s);if(!e)return;this.#f(e),this.#i.append(e,this.#p)}removeButton(t){switch(t){case"comment":this.#n?.removeToolbarCommentButton(),this.#n=null,this.#a?.remove(),this.#a=null;break}}async addButton(t,e){switch(t){case"colorPicker":if(e)this.addColorPicker(e);break;case"altText":if(e)await this.addAltText(e);break;case"editSignature":if(e)await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":if(e)this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;let i=this.#i.querySelector(s);if(!i)return;if(t==="comment")this.addComment(e,i)}updateEditSignatureButton(t){if(this.#o)this.#o.title=t}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class ua{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;let e=this.#s._signal;if(e instanceof AbortSignal&&!e.aborted)t.addEventListener("contextmenu",re,{signal:e});let s=this.#t=document.createElement("div");if(s.className="buttons",t.append(s),this.#s.hasCommentManager())this.#n("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")});return this.#n("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#r(t,e){let s=0,i=0;for(let r of t){let n=r.y+r.height;if(n<s)continue;let a=r.x+(e?r.width:0);if(n>s){i=a,s=n;continue}if(e){if(a>i)i=a}else if(a<i)i=a}return[e?1-i:i,s]}show(t,e,s){let[i,r]=this.#r(e,s),{style:n}=this.#e||=this.#i();t.append(this.#e),n.insetInlineEnd=`${100*i}%`,n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#n(t,e,s,i){let r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);let n=document.createElement("span");r.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",s);let a=this.#s._signal;if(a instanceof AbortSignal&&!a.aborted)r.addEventListener("contextmenu",re,{signal:a}),r.addEventListener("click",i,{signal:a});this.#t.append(r)}}var ih="0a475cb6-573c-46ed-869d-fa7c5839d995",Gi=Object.freeze({internal:ih});function fa(t,e,s){for(let i of s)e.addEventListener(i,t[i].bind(t))}class ot{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(ot.#e||=new Set).add(t)}static setPointer(t,e){ot.#t||=e,ot.#i??=t}static setTimeStamp(t){ot.#s=t}static isSamePointerId(t){return ot.#t===t}static isSamePointerIdOrRemove(t){if(ot.#t===t)return!0;return ot.#e?.delete(t),!1}static isSamePointerType(t){return ot.#i===t}static isInitializedAndDifferentPointerType(t){return ot.#i!==null&&!ot.isSamePointerType(t)}static isSameTimeStamp(t){return ot.#s===t}static isUsingMultiplePointers(){return ot.#e?.size>=1}static clearPointerType(){ot.#i=null}static clearPointerIds(){ot.#t=NaN,ot.#e=null}static clearTimeStamp(){ot.#s=NaN}}class pa{#t=0;get id(){return`${qe}${this.#t++}`}}class xr{#t=oa();#e=0;#s=null;static get _isSVGFittingCanvas(){let t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Dt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;let r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return L(this,"_isSVGFittingCanvas",r)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e==="string")s.url=e,i=await Sr(e,"blob");else if(e instanceof File)i=s.file=e;else if(e instanceof Blob)i=e;if(i.type==="image/svg+xml"){let r=xr._isSVGFittingCanvas,n=new FileReader,a=new Image,o=new Promise((l,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},n.onload=async()=>{let h=s.svgUrl=n.result;a.src=await r?`${h}#svgView(preserveAspectRatio(none))`:h},a.onerror=n.onerror=c});n.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){W(i),s=null}if(this.#s.set(t,s),s)this.#s.set(s.id,s);return s}async getFromFile(t){let{lastModified:e,name:s,size:i,type:r}=t;return this.#i(`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){let s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;let i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){let e=this.#s.get(t);return!e?.isSvg?null:e.svgUrl}deleteId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return;if(e.refCounter-=1,e.refCounter!==0)return;let{bitmap:s}=e;if(!e.url&&!e.file){let i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class ga{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(i)t();if(this.#e)return;let o={cmd:t,undo:e,post:s,type:r};if(this.#i===-1){if(this.#t.length>0)this.#t.length=0;this.#i=0,this.#t.push(o);return}if(n&&this.#t[this.#i].type===r){if(a)o.undo=this.#t[this.#i].undo;this.#t[this.#i]=o;return}let l=this.#i+1;if(l===this.#s)this.#t.splice(0,1);else if(this.#i=l,l<this.#t.length)this.#t.splice(l);this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i===-1)return;for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}destroy(){this.#t=null}}class Xt{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:e}=lt.platform;for(let[s,i,r={}]of t){let n=s.some((a)=>a.startsWith("mac+"));for(let a of s){let o=a;if(n){let h=a.startsWith("mac+");if(e!==h)continue;if(h)o=a.slice(4)}let[l,c]=Xt.#t(o);if(l===null)continue;this.callbacks.getOrInsertComputed(l,Ze).push({callback:i,options:r,modifiers:c})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;let r=i.toUpperCase(),n=Xt[r];if(n){s|=n;continue}if(e!==null){W(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}if(e===null)W(`KeyboardManager: no key found in shortcut "${t}"`);return[e,s]}static#e(t){let e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return!e?null:e[1]?.toLowerCase()??e[2]}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;let c=Xt.#e(e.code);if(c===null||c===e.key)return;if(s=this.callbacks.get(c),!s)return}let i=(e.altKey?Xt.ALT:0)|(e.ctrlKey?Xt.CTRL:0)|(e.metaKey?Xt.META:0)|(e.shiftKey?Xt.SHIFT:0),r=s.find((c)=>c.modifiers===i);if(!r)return;let{callback:n,options:{bubbles:a=!1,args:o=[],checker:l=null}}=r;if(l&&!l(t,e))return;if(n.bind(t,...o,e)(),!a)Tt(e)}}class Tr{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return sh(t),L(this,"_colors",t)}convert(t){let e=Es(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,i]of this._colors)if(i.every((r,n)=>r===e[n]))return Tr._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);return!e?t:O.makeHexColor(...e)}}class Se{#t=new AbortController;#e=null;#s=null;#i=new Map;#r=new Map;#n=null;#a=null;#o=null;#l=null;#c=null;#u=new ga;#h=null;#f=null;#p=null;#m=0;#d=new Set;#g=null;#v=null;#y=new Set;_editorUndoBar=null;#b=!1;#_=!1;#A=!1;#S=null;#w=null;#E=null;#M=null;#I=!1;#C=null;#F=new pa;#P=!1;#O=!1;#D=!1;#R=null;#B=null;#V=null;#j=null;#$=null;#T=K.NONE;#x=new Set;#H=null;#G=null;#W=null;#q=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#N=null;#X=null;#tt=null;#et=null;#U=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=Se.prototype,e=(n)=>n.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&n.hasSomethingToControl(),s=(n,{target:a})=>{if(a instanceof HTMLInputElement){let{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return L(this,"_keyboardManager",new Xt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(n,{target:a})=>!(a instanceof HTMLButtonElement)&&n.#X.contains(a)&&!n.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(n,{target:a})=>!(a instanceof HTMLButtonElement)&&n.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,s,i,r,n,a,o,l,c,h,d,u,f,p,g,m){let v=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=i,this.#h=r,this.#G=n,this.#Y=o,this._eventBus=a;let y={signal:v,...Gi};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",(b)=>this.updateParams(b.type,b.value),y),window.addEventListener("pointerdown",()=>{this.#O=!0},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{this.#O=!1},{capture:!0,signal:v}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:v}),this.#lt(),this.#pt(),this.#it(),this.#l=o.annotationStorage,this.#S=o.filterFactory,this.#W=l,this.#M=c||null,this.#b=h,this.#_=d,this.#A=u,this.#$=f||null,this.viewParameters={realScale:Le.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=g!==!1,this._keepToolbarInPage=m===!0,r?.setSidebarUiManager(this)}destroy(){this.#U?.resolve(),this.#U=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#r.values())t.destroy();if(this.#r.clear(),this.#i.clear(),this.#y.clear(),this.#j?.clear(),this.#e=null,this.#x.clear(),this.#u.destroy(),this.#o?.destroy(),this.#h?.destroy(),this.#G?.destroy(),this.#C?.hide(),this.#C=null,this.#V?.destroy(),this.#V=null,this.#s=null,this.#w)clearTimeout(this.#w),this.#w=null;if(this.#N)clearTimeout(this.#N),this.#N=null;this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#$}get useNewAltTextFlow(){return this.#_}get useNewAltTextWhenAddingImage(){return this.#A}get hcmFilter(){return L(this,"hcmFilter",this.#W?this.#S.addHCMFilter(this.#W.foreground,this.#W.background):"none")}get direction(){return L(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return L(this,"_highlightColors",this.#M?new Map(this.#M.split(",").map((t)=>(t=t.split("=").map((e)=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return L(this,"highlightColors",null);let e=new Map,s=!!this.#W;for(let[i,r]of t){let n=i.endsWith("_HCM");if(s&&n){e.set(i.replace("_HCM",""),r);continue}if(!s&&!n)e.set(i,r)}return L(this,"highlightColors",e)}get highlightColorNames(){return L(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t)=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){if(t)this.unselectAll(),this.disableUserSelect(!0);else this.disableUserSelect(!1);this.#p=t}setMainHighlightColorPicker(t){this.#V=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#h}editComment(t,e,s,i){this.#h?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#r.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#h?.updateComment(t.getData())}updatePopupColor(t){this.#h?.updatePopupColor(t)}removeComment(t){this.#h?.removeComments([t.uid])}deleteComment(t,e){let s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#h?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#h?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#h?.dialogElement||null}async waitForEditorsRendered(t){if(this.#r.has(t-1))return;let{resolve:e,promise:s}=Promise.withResolvers(),i=(r)=>{if(r.pageNumber===t)this._eventBus.off("editorsrendered",i),e()};this._eventBus.on("editorsrendered",i,Gi),await s}getSignature(t){this.#G?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#G}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Gi}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#A=e;break}}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();if(this.#r.delete(t),this.#m===t)this.#m=0}focusMainContainer(){this.#X.focus()}findParent(t,e){for(let s of this.#r.values()){let{x:i,y:r,width:n,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+n&&e>=r&&e<=r+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Le.PDF_TO_CSS_UNITS;for(let e of this.#y)e.onScaleChanging();this.#p?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Z({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let s of this.#r.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){let s=document.getSelection();if(!s||s.isCollapsed)return;let{anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:a}=s,o=s.toString(),c=this.#Z(s).closest(".textLayer"),h=this.getSelectionBoxes(c);if(!h)return;s.empty();let d=this.#st(c),u=this.#T===K.NONE,f=()=>{let p=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:a,text:o});if(u)this.showAllEditors("highlight",!0,!0);if(e)p?.editComment()};if(u){this.switchToMode(K.HIGHLIGHT,f);return}f()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#Z(t).closest(".textLayer"),i=this.getSelectionBoxes(s);if(!i)return;this.#C||=new ua(this),this.#C.show(s,i,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;let e=`${qe}${t}`,s=this.#l.getRawValue(e);if(s)this.#l.remove(e);return s}addToAnnotationStorage(t){if(!t.isEmpty()&&this.#l&&!this.#l.has(t.id))this.#l.setValue(t.id,t)}a11yAlert(t,e=null){let s=this.#et;if(!s)return;if(s.setAttribute("data-l10n-id",t),e)s.setAttribute("data-l10n-args",JSON.stringify(e));else s.removeAttribute("data-l10n-args")}#ot(){let t=document.getSelection();if(!t||t.isCollapsed){if(this.#H)this.#C?.hide(),this.#H=null,this.#k({hasSelectedText:!1});return}let{anchorNode:e}=t;if(e===this.#H)return;let i=this.#Z(t).closest(".textLayer");if(!i){if(this.#H)this.#C?.hide(),this.#H=null,this.#k({hasSelectedText:!1});return}if(this.#C?.hide(),this.#H=e,this.#k({hasSelectedText:!0}),this.#T!==K.HIGHLIGHT&&this.#T!==K.NONE)return;if(this.#T===K.HIGHLIGHT)this.showAllEditors("highlight",!0,!0);if(this.#I=this.isShiftKeyDown,!this.isShiftKeyDown){let r=this.#T===K.HIGHLIGHT?this.#st(i):null;if(r?.toggleDrawing(),this.#O){let n=new AbortController,a=this.combinedSignal(n),o=(l)=>{if(l.type==="pointerup"&&l.button!==0)return;if(n.abort(),r?.toggleDrawing(!0),l.type==="pointerup")this.#J("main_toolbar")};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else r?.toggleDrawing(!0),this.#J("main_toolbar")}}#J(t=""){if(this.#T===K.HIGHLIGHT)this.highlightSelection(t);else if(this.#b)this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ct(){if(this.#E)return;this.#E=new AbortController;let t=this.combinedSignal(this.#E);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ht(){this.#E?.abort(),this.#E=null}blur(){if(this.isShiftKeyDown=!1,this.#I)this.#I=!1,this.#J("main_toolbar");if(!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#x)if(e.div.contains(t)){this.#B=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#B)return;let[t,e]=this.#B;this.#B=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#it(){if(this.#R)return;this.#R=new AbortController;let t=this.combinedSignal(this.#R);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#R?.abort(),this.#R=null}#ut(){if(this.#f)return;this.#f=new AbortController;let t=this.combinedSignal(this.#f);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#ft(){this.#f?.abort(),this.#f=null}#pt(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#it(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let s of this.#v)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let s of this.#v)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let s of this.#x){let i=s.serialize(!0);if(i)e.push(i)}if(e.length===0)return;t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let r of e.items)for(let n of this.#v)if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){W(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let i=this.currentLayer;try{let r=[];for(let o of s){let l=await i.deserialize(o);if(!l)return;r.push(l)}let n=()=>{for(let o of r)this.#rt(o);this.#nt(r)},a=()=>{for(let o of r)o.remove()};this.addCommands({cmd:n,undo:a,mustExec:!0})}catch(r){W(`paste: "${r.message}".`)}}keydown(t){if(!this.isShiftKeyDown&&t.key==="Shift")this.isShiftKeyDown=!0;if(this.#T!==K.NONE&&!this.isEditorHandlingKeyboard)Se._keyboardManager.exec(this,t)}keyup(t){if(this.isShiftKeyDown&&t.key==="Shift"){if(this.isShiftKeyDown=!1,this.#I)this.#I=!1,this.#J("main_toolbar")}}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(let i of this.#a.get(t)||[])i.pageIndex=e;let s=this.#n.get(t);if(s)if(s.pageIndex=e,this.#r.set(e,s),this.#P)s.enable();else s.disable()}startUpdatePages(){this.#n=new Map(this.#r),this.#r.clear();let t=this.#a=new Map,e=(s)=>{t.getOrInsertComputed(s.pageIndex,Ze).push(s)};for(let s of this.#i.values())e(s);for(let[s,i]of this.#l)if(s.startsWith(qe)&&!this.#i.has(s)&&Number.isInteger(i?.pageIndex))e(i)}endUpdatePages(){this.#n=null,this.#a=null}clonePage(t,e){for(let s of this.getEditors(t)){let i=s.serialize(s.mode!==K.HIGHLIGHT);if(!i)continue;i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#l.setValue(i.id,i)}}findClonesForPage(t){let e=[],{pageIndex:s}=t;for(let[i,r]of this.#l)if(r.pageIndex===s&&r.isClone)this.#l.remove(i),e.push(t.deserialize(r).then((n)=>{if(n)n.isClone=!0,t.addOrRebuild(n)}));return Promise.all(e)}#k(t){if(Object.entries(t).some(([s,i])=>this.#K[s]!==i)){if(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#T===K.HIGHLIGHT&&t.hasSelectedEditor===!1)this.#z([[st.HIGHLIGHT_FREE,!0]])}}#z(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){if(t)this.#ct(),this.#ut(),this.#k({isEditing:this.#T!==K.NONE,isEmpty:this.#Q(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1});else this.#ht(),this.#ft(),this.#k({isEditing:!1}),this.disableUserSelect(!1)}registerEditorTypes(t){if(this.#v)return;this.#v=t;for(let e of this.#v)this.#z(e.defaultPropertiesToUpdate)}getId(){return this.#F.id}get currentLayer(){return this.#r.get(this.#m)}getLayer(t){return this.#r.get(t)}get currentPageIndex(){return this.#m}addLayer(t){if(this.#r.set(t.pageIndex,t),this.#P)t.enable();else t.disable()}removeLayer(t){this.#r.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,n=!1){if(this.#T===t)return;if(this.#U){if(await this.#U.promise,!this.#U)return}if(this.#U=Promise.withResolvers(),this.#p?.commitOrRemove(),this.#T===K.POPUP)this.#h?.hideSidebar();if(this.#h?.destroyPopup(),this.#T=t,t===K.NONE){this.setEditingState(!1),this.#mt();for(let a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#U.resolve();return}for(let a of this.#i.values())a.addStandaloneCommentButton();if(t===K.SIGNATURE)await this.#G?.loadSignatures();if(s)ot.clearPointerType();this.setEditingState(!0),await this.#gt(),this.unselectAll();for(let a of this.#r.values())a.updateMode(t);if(t===K.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#v.map((l)=>l._editorType)));let a=new Set,o=[];for(let l of this.#i.values()){let{annotationElementId:c,hasComment:h,deleted:d}=l;if(c)a.add(c);if(h&&!d)o.push(l.getData())}for(let l of this.#s){let{id:c,popupRef:h,contentsObj:d}=l;if(h&&d?.str&&!a.has(c)&&!this.#d.has(c))o.push(l)}this.#h?.showSidebar(o)}if(!e){if(i)this.addNewEditorFromKeyboard();this.#U.resolve();return}for(let a of this.#i.values())if(a.uid===e)if(this.setSelected(a),n)a.editComment();else if(r)a.enterInEditMode();else a.focus();else a.unselect();this.#U.resolve()}addNewEditorFromKeyboard(){if(this.currentLayer.canCreateNewEmptyEditor())this.currentLayer.addNewEditor()}updateToolbar(t){if(t.mode===this.#T)return;this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(!this.#v)return;switch(t){case st.CREATE:this.currentLayer.addNewEditor(e);return;case st.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#q||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(let s of this.#x)s.updateParams(t,e);else for(let s of this.#v)s.updateDefaultParams(t,e)}showAllEditors(t,e,s=!1){for(let r of this.#i.values())if(r.editorType===t)r.show(e);if((this.#q?.get(st.HIGHLIGHT_SHOW_ALL)??!0)!==e)this.#z([[st.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#D===t)return;this.#D=t;for(let e of this.#r.values()){if(t)e.disableClick();else e.enableClick();e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#P){this.#P=!0;let t=[];for(let e of this.#r.values())t.push(e.enable());await Promise.all(t);for(let e of this.#i.values())e.enable()}}#mt(){if(this.unselectAll(),this.#P){this.#P=!1;for(let t of this.#r.values())t.disable();for(let t of this.#i.values())t.disable()}}*getEditors(t){for(let e of this.#i.values())if(e.pageIndex===t)yield e}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){if(t.div.contains(document.activeElement)){if(this.#w)clearTimeout(this.#w);this.#w=setTimeout(()=>{this.focusMainContainer(),this.#w=null},0)}if(this.#i.delete(t.id),t.annotationElementId)this.#j?.delete(t.annotationElementId);if(this.unselect(t),!t.annotationElementId||!this.#d.has(t.annotationElementId))this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#rt(t){let e=this.#r.get(t.pageIndex);if(e)e.addOrRebuild(t);else this.addEditor(t),this.addToAnnotationStorage(t)}setActiveEditor(t){if(this.#e===t)return;if(this.#e=t,t)this.#z(t.propertiesToUpdate)}get#vt(){let t=null;for(t of this.#x);return t}updateUI(t){if(this.#vt===t)this.#z(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#z(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#x.has(t)){this.#x.delete(t),t.unselect(),this.#k({hasSelectedEditor:this.hasSelection});return}this.#x.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#k({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#p?.commitOrRemove();for(let e of this.#x)if(e!==t)e.unselect();this.#h?.destroyPopup(),this.#x.clear(),this.#x.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#k({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#x.values().next().value}unselect(t){t.unselect(),this.#x.delete(t),this.#k({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#x.size!==0}get isEnterHandled(){return this.#x.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#k({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Q()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#k({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Q()})}addCommands(t){this.#u.add(t),this.#k({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Q()})}cleanUndoStack(t){this.#u.cleanType(t)}#Q(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(let t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#x],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(let r of e)r.remove()},i=()=>{for(let r of e)this.#rt(r)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#nt(t){for(let e of this.#x)e.unselect();this.#x.clear();for(let e of t){if(e.isEmpty())continue;this.#x.add(e),e.select()}this.#k({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#x)t.commit();this.#nt(this.#i.values())}unselectAll(){if(this.#e){if(this.#e.commitOrRemove(),this.#T!==K.NONE)return}if(this.#p?.commitOrRemove())return;if(this.#h?.destroyPopup(),!this.hasSelection)return;for(let t of this.#x)t.unselect();this.#x.clear(),this.#k({hasSelectedEditor:!1})}translateSelectedEditors(t,e,s=!1){if(!s)this.commitOrRemove();if(!this.hasSelection)return;this.#L[0]+=t,this.#L[1]+=e;let[i,r]=this.#L,n=[...this.#x],a=1000;if(this.#N)clearTimeout(this.#N);this.#N=setTimeout(()=>{this.#N=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:()=>{for(let o of n)if(this.#i.has(o.id))o.translateInPage(i,r),o.translationDone()},undo:()=>{for(let o of n)if(this.#i.has(o.id))o.translateInPage(-i,-r),o.translationDone()},mustExec:!1})},a);for(let o of n)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(!this.hasSelection)return;this.disableUserSelect(!0),this.#g=new Map;for(let t of this.#x)this.#g.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#g)return!1;this.disableUserSelect(!1);let t=this.#g;this.#g=null;let e=!1;for(let[{x:i,y:r,pageIndex:n},a]of t)a.newX=i,a.newY=r,a.newPageIndex=n,e||=i!==a.savedX||r!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;let s=(i,r,n,a)=>{if(this.#i.has(i.id)){let o=this.#r.get(a);if(o)i._setParentAndPosition(o,r,n);else i.pageIndex=a,i.x=r,i.y=n}};return this.addCommands({cmd:()=>{for(let[i,{newX:r,newY:n,newPageIndex:a}]of t)s(i,r,n,a)},undo:()=>{for(let[i,{savedX:r,savedY:n,savedPageIndex:a}]of t)s(i,r,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(!this.#g)return;for(let s of this.#g.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){let e=this.getLayer(t.pageIndex);if(e)e.changeParent(t),e.addOrRebuild(t);else this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild()}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#x.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#T}isEditingMode(){return this.#T!==K.NONE}get imageManager(){return L(this,"imageManager",new xr)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;let{x:s,y:i,width:r,height:n}=t.getBoundingClientRect(),a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,c,h,d)=>({x:(c-i)/n,y:1-(l+h-s)/r,width:d/n,height:h/r});break;case"180":a=(l,c,h,d)=>({x:1-(l+h-s)/r,y:1-(c+d-i)/n,width:h/r,height:d/n});break;case"270":a=(l,c,h,d)=>({x:1-(c+d-i)/n,y:(l-s)/r,width:d/n,height:h/r});break;default:a=(l,c,h,d)=>({x:(l-s)/r,y:(c-i)/n,width:h/r,height:d/n});break}let o=[];for(let l=0,c=e.rangeCount;l<c;l++){let h=e.getRangeAt(l);if(h.collapsed)continue;for(let{x:d,y:u,width:f,height:p}of h.getClientRects()){if(f===0||p===0)continue;o.push(a(d,u,f,p))}}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#c||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#c?.delete(t)}renderAnnotationElement(t){let e=this.#c?.get(t.data.id);if(!e)return;let s=this.#l.getRawValue(e);if(!s)return;if(this.#T===K.NONE&&!s.hasBeenModified)return;s.renderAnnotationElement(t)}setMissingCanvas(t,e,s){let i=this.#j?.get(t);if(!i)return;i.setCanvas(e,s),this.#j.delete(t)}addMissingCanvas(t,e){(this.#j||=new Map).set(t,e)}}class le{#t=null;#e=!1;#s=null;#i=null;#r=null;#n=null;#a=!1;#o=null;#l=null;#c=null;#u=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#h=t._uiManager.useNewAltTextFlow,le.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){le._l10n??=t}async render(){let t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#i=document.createElement("span");if(t.append(e),this.#h)t.classList.add("new"),t.setAttribute("data-l10n-id",le.#f.missing),e.setAttribute("data-l10n-id",le.#f["missing-label"]);else t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label");let s=this.#l._uiManager._signal;t.addEventListener("contextmenu",re,{signal:s}),t.addEventListener("pointerdown",(r)=>r.stopPropagation(),{signal:s});let i=(r)=>{if(r.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#h)this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#p}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(r)=>{if(r.target===t&&r.key==="Enter")this.#a=!0,i(r)},{signal:s}),await this.#m(),t}get#p(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){if(!this.#s)return;this.#s.focus({focusVisible:this.#a}),this.#a=!1}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){if(this.#t!==null)return;this.#c=t,this.#u=await le._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m()}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;if(!t&&this.#c===e)e=this.#u;return{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){if(s)this.#c=s,this.#u=i;if(this.#t===t&&this.#e===e)return;if(!r)this.#t=t,this.#e=e;this.#m()}toggle(t=!1){if(!this.#s)return;if(!t&&this.#n)clearTimeout(this.#n),this.#n=null;this.#s.disabled=!t}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#p}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#r=null,this.#o?.remove(),this.#o=null}async#m(){let t=this.#s;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",le.#f[this.#p]),this.#i?.setAttribute("data-l10n-id",le.#f[`${this.#p}-label`]),!this.#t){this.#r?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#r?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#r;if(!e){this.#r=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;let i=100,r=this.#l._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#n),this.#n=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#n=setTimeout(()=>{this.#n=null,this.#r.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:r}),t.addEventListener("mouseleave",()=>{if(this.#n)clearTimeout(this.#n),this.#n=null;this.#r?.classList.remove("show")},{signal:r})}if(this.#e)e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else e.removeAttribute("data-l10n-id"),e.textContent=this.#t;if(!e.parentNode)t.append(e);this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class hs{#t=null;#e=null;#s=!1;#i=null;#r=null;#n=null;#a=null;#o=null;#l=!1;#c=null;constructor(t){this.#i=t}renderForToolbar(){let t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){let t=this.#t=document.createElement("button");t.className="annotationCommentButton";let e=this.#i.commentButtonPosition;if(e){let{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let i=this.#i.commentButtonColor;if(i)s.backgroundColor=i}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;let t=this.#i.commentButtonColor;if(t)this.#t.style.backgroundColor=t;this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#c)return this.#c;if(!this.#t)return null;let{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:r,width:n,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/n,(e+s-r)/a]}set commentPopupPositionInLayer(t){this.#c=t}hasDefaultPopupPosition(){return this.#c===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#t)return;this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e}#u(t,e){if(!this.#i._uiManager.hasCommentManager())return null;if(t.tabIndex="0",t.ariaHasPopup="dialog",e)t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button");else t.ariaControlsElements=[this.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button");let s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;if(t.addEventListener("contextmenu",re,{signal:s}),e)t.addEventListener("focusin",(r)=>{this.#i._focusEventsAllowed=!1,Tt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",(r)=>{this.#i._focusEventsAllowed=!0,Tt(r)},{capture:!0,signal:s});t.addEventListener("pointerdown",(r)=>r.stopPropagation(),{signal:s});let i=(r)=>{if(r.preventDefault(),t===this.#e)this.edit();else this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(r)=>{if(r.target===t&&r.key==="Enter")this.#s=!0,i(r)},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){let e=this.commentPopupPositionInLayer,s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;let{width:c,height:h,x:d,y:u}=this.#i;s=d+s*c,i=u+i*h}let r=this.#i.parent.boundingClientRect,{x:n,y:a,width:o,height:l}=r;this.#i._uiManager.editComment(this.#i,n+s*o,a+i*l,{...t,parentDimensions:r})}finish(){if(!this.#e)return;this.#e.focus({focusVisible:this.#s}),this.#s=!1}isDeleted(){return this.#l||this.#a===""}isEmpty(){return this.#a===null}hasBeenEdited(){return this.isDeleted()||this.#a!==this.#r}serialize(){return this.data}get data(){return{text:this.#a,richText:this.#n,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#a)this.#n=null;if(t===null){this.#a="",this.#l=!0;return}this.#a=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#a=t,this.#n=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#r=t,this.data=t,this.#o=null,this.#n=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#a="",this.#n=null,this.#o=null,this.#i=null,this.#s=!1,this.#l=!1}}function an(t){t.preventDefault()}var on=0.0001;function zi(t){if(t.cancelable)return Tt(t),!0;return t.stopPropagation(),!1}class Cr{#t;#e=!1;#s=null;#i;#r;#n;#a;#o;#l=!1;#c=null;#u;#h=new Set;#f=null;#p;#m=null;#d=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:n=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#i=e,this.#r=i,this.#n=r,this.#a=n,this.#o=a,this.#p=new AbortController,this.#u=AbortSignal.any([o,this.#p.signal]),t.addEventListener("touchstart",this.#g.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Kt.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/Kt.pixelRatio}#g(t){if(this.#i?.())return;this.#y(t);let e=this.#h;for(let{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#v();return}if(!this.#m){this.#m=new AbortController;let s=AbortSignal.any([this.#u,this.#m.signal]),i=this.#t,r={signal:s,capture:!1,passive:!1};i.addEventListener("touchmove",this.#A.bind(this),r);let n=this.#S.bind(this);i.addEventListener("touchend",n,r),i.addEventListener("touchcancel",n,r),r.capture=!0,i.addEventListener("pointerdown",Tt,r),i.addEventListener("pointermove",Tt,r),i.addEventListener("pointercancel",an,r),i.addEventListener("pointerup",an,r),this.#r?.()}this.#l=zi(t),this.#_(t)}#v(){if(this.#c)return;let t=this.#c=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,i={capture:!0,signal:e,passive:!1},r=(n)=>{if(n.pointerType==="touch")this.#c?.abort(),this.#c=null};s.addEventListener("pointerdown",(n)=>{if(n.pointerType==="touch")Tt(n),r(n)},i),s.addEventListener("pointerup",r,i),s.addEventListener("pointercancel",r,i)}#y(t){let e=this.#h;if(e.size===0)return;let s=this.#h=new Set;for(let{identifier:i}of t.touches)if(e.has(i))s.add(i)}#b(t){let e=this.#h,s=[];for(let i of t.touches)if(e.has(i.identifier))s.push(i);return s}#_(t){let e=this.#b(t);if(e.length!==2||this.#s?.()){this.#f=null;return}let[s,i]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2}}#A(t){if(!this.#f)return;let e=this.#b(t);if(e.length!==2)return;let s=this.#l;if(this.#l=zi(t),!this.#l)return;if(!s){this.#_(t);return}let[i,r]=e,{screenX:n,screenY:a}=i,{screenX:o,screenY:l}=r,c=this.#f,{touch0X:h,touch0Y:d,touch1X:u,touch1Y:f,panX:p,panY:g}=c,m=u-h,v=f-d,y=o-n,b=l-a,_=(i.clientX+r.clientX)/2,w=(i.clientY+r.clientY)/2;c.panX=_,c.panY=w;let A=_-p,x=w-g,E=(n+o)/2,T=(a+l)/2,k=Math.hypot(E-c.screenPanX,T-c.screenPanY);c.screenPanX=E,c.screenPanY=T;let C=Math.hypot(y,b),R=Math.hypot(m,v),B=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*k;if(C<on||R<on||Math.abs(R-C)<=B){if(A||x)this.#o?.(A,x);return}c.touch0X=n,c.touch0Y=a,c.touch1X=o,c.touch1Y=l;let N=Math.sign(C-R);if(!this.#e){if(this.#e=!0,this.#d=N,A||x)this.#o?.(A,x);return}if(this.#d){let M=this.#d;if(this.#d=0,N!==M&&Math.abs(C-R)<=2*k){if(this.#e=!1,A||x)this.#o?.(A,x);return}}this.#n?.([p,g],R,C,A,x)}#S(t){if(this.#y(t),this.#h.size>=2){this.#_(t);return}let e=!!this.#f;if(this.#w(),this.#h.size===1)this.#v();if(e)zi(t)}#w(){if(this.#f=null,this.#e=!1,this.#d=0,this.#l=!1,this.#m)this.#m.abort(),this.#m=null,this.#a?.()}destroy(){this.#w(),this.#h.clear(),this.#p?.abort(),this.#p=null,this.#c?.abort(),this.#c=null}}class U{#t=null;#e=null;#s=null;#i=null;#r=null;#n=!1;#a=null;#o="";#l=null;#c=null;#u=null;#h=null;#f=null;#p="";#m=!1;#d=null;#g=!1;#v=!1;#y=!1;#b=null;#_=0;#A=0;#S=null;#w=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#E=!1;#M=U._zIndex++;static _borderLineWidth=-1;static _colorManager=new Tr;static _zIndex=1;static _telemetryTimeout=1000;static get _resizerKeyboardManager(){let t=U.prototype._resizeWithKeyboard,{TRANSLATE_SMALL:e,TRANSLATE_BIG:s}=Se;return L(this,"_resizerKeyboardManager",new Xt([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],U.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,n];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return L(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new ma({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(U._l10n??=t,U._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),U._l10nResizer??=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),U._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);U._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){at("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#M}setParent(t){if(t!==null)this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions;else this.#L(),this.#h?.remove(),this.#h=null;this.parent=t}focusin(t){if(!this._focusEventsAllowed)return;if(!this.#m)this.parent.setSelected(this);else this.#m=!1}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;if(t.relatedTarget?.closest(`#${this.id}`))return;if(t.preventDefault(),!this.parent?.isMultipleSelection)this.commitOrRemove()}commitOrRemove(){if(this.isEmpty())this.remove();else this.commit()}commit(){if(!this.isInEditMode())return;this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){let[r,n]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}let[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#I([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#I(this.parentDimensions,t,e)}translateInPage(t,e){this.#d||=[this.x,this.y,this.width,this.height],this.#I(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#d||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:h,y:d}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,h,d))this.x-=Math.floor(this.x),this.y-=Math.floor(this.y)}let{x:n,y:a}=this,[o,l]=this.getBaseTranslation();n+=o,a+=l;let{style:c}=s;c.left=`${(100*n).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#d&&(this.#d[0]!==this.x||this.#d[1]!==this.y)}get _hasBeenResized(){return!!this.#d&&(this.#d[2]!==this.width||this.#d[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=U,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[s,i]}=this,{x:r,y:n,width:a,height:o}=this;a*=s,o*=i,r*=s,n*=i;let l=0,c=0,h=this._uiManager._keepToolbarInPage&&this._editToolbar?.div;if(h?.offsetParent){let f=this.parentScale,p=h.offsetLeft+this.div.clientLeft,g=h.offsetTop+this.div.clientTop,m=Math.min(0,p)/f,v=Math.min(0,g)/f,y=a-m+Math.max(0,p+h.offsetWidth-this.div.offsetWidth)/f,b=o-v+Math.max(0,g+h.offsetHeight-this.div.offsetHeight)/f;if(y<=(t%180?i:s))a=y,l=m;if(b<=(t%180?s:i))o=b,c=v;[l,c]=U.#C(l,c,t),r+=l,n+=c}if(this._mustFixPosition)switch(t){case 0:r=pt(r,0,s-a),n=pt(n,0,i-o);break;case 90:r=pt(r,0,s-o),n=pt(n,a,i);break;case 180:r=pt(r,a,s),n=pt(n,o,i);break;case 270:r=pt(r,o,s),n=pt(n,0,i-a);break}this.x=r=(r-l)/s,this.y=n=(n-c)/i;let[d,u]=this.getBaseTranslation();r+=d,n+=u,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#C(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return U.#C(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return U.#C(t,e,360-this.parentRotation)}#F(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){let{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#P(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let s of t){let i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#O.bind(this,s),{signal:e}),i.addEventListener("contextmenu",re,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#l)}#O(t,e){e.preventDefault();let{isMac:s}=lt.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];let r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#B.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",Tt,{passive:!1,signal:n}),window.addEventListener("contextmenu",re,{signal:n}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#R()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#D(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#R(){if(!this.#u)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;let r=this.x,n=this.y,a=this.width,o=this.height;if(r===t&&n===e&&a===s&&o===i)return;this.addCommands({cmd:this.#D.bind(this,r,n,a,o),undo:this.#D.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#B(t,e){let[s,i]=this.parentDimensions,r=this.x,n=this.y,a=this.width,o=this.height,l=U.MIN_SIZE/s,c=U.MIN_SIZE/i,h=this.#F(this.rotation),d=(M,F)=>[h[0]*M+h[2]*F,h[1]*M+h[3]*F],u=this.#F(360-this.rotation),f=(M,F)=>[u[0]*M+u[2]*F,u[1]*M+u[3]*F],p,g,m=!1,v=!1;switch(t){case"topLeft":m=!0,p=(M,F)=>[0,0],g=(M,F)=>[M,F];break;case"topMiddle":p=(M,F)=>[M/2,0],g=(M,F)=>[M/2,F];break;case"topRight":m=!0,p=(M,F)=>[M,0],g=(M,F)=>[0,F];break;case"middleRight":v=!0,p=(M,F)=>[M,F/2],g=(M,F)=>[0,F/2];break;case"bottomRight":m=!0,p=(M,F)=>[M,F],g=(M,F)=>[0,0];break;case"bottomMiddle":p=(M,F)=>[M/2,F],g=(M,F)=>[M/2,0];break;case"bottomLeft":m=!0,p=(M,F)=>[0,F],g=(M,F)=>[M,0];break;case"middleLeft":v=!0,p=(M,F)=>[0,F/2],g=(M,F)=>[M,F/2];break}let y=p(a,o),b=g(a,o),_=d(...b),w=U._round(r+_[0]),A=U._round(n+_[1]),x=1,E=1,T,k;if(!e.fromKeyboard){let{screenX:M,screenY:F}=e,[j,X]=this.#c;[T,k]=this.screenToPageTranslation(M-j,F-X),this.#c[0]=M,this.#c[1]=F}else({deltaX:T,deltaY:k}=e);if([T,k]=f(T/s,k/i),m){let M=Math.hypot(a,o);x=E=Math.max(Math.min(Math.hypot(b[0]-y[0]-T,b[1]-y[1]-k)/M,1/a,1/o),l/a,c/o)}else if(v)x=pt(Math.abs(b[0]-y[0]-T),l,1)/a;else E=pt(Math.abs(b[1]-y[1]-k),c,1)/o;let C=U._round(a*x),R=U._round(o*E);_=d(...g(C,R));let B=w-_[0],N=A-_[1];this.#d||=[this.x,this.y,this.width,this.height],this.width=C,this.height=R,this.x=B,this.y=N,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#v)return this._editToolbar;this._editToolbar=new us(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,s]of t)await this._editToolbar.addButton(e,s);if(!this.hasComment)this._editToolbar.addButton("comment",this.addCommentButton());return this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#s?.destroy()}addContainer(t){let e=this._editToolbar?.div;if(e)e.before(t);else this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!this.#s){if(le.initialize(U._l10n),this.#s=new le(this),this.#t)this.#s.data=this.#t,this.#t=null}return this.#s}get altTextData(){return this.#s?.data}set altTextData(t){if(!this.#s)return;this.#s.data=t}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new hs(this):null}addStandaloneCommentButton(){if(!this._uiManager.hasCommentManager())return;if(this.#r){if(this._uiManager.isEditingMode())this.#r.classList.remove("hidden");return}if(!this.hasComment)return;this.#r=this.#i.renderForStandalone(),this.div.append(this.#r)}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#r=null}hideStandaloneCommentButton(){this.#r?.classList.add("hidden")}get comment(){if(!this.#i)return null;let{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){if(this.#i||=new hs(this),typeof t==="object"&&t!==null)this.#i.restoreData(t);else this.#i.data=t;if(this.hasComment)this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this);else this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this)}setCommentData({comment:t,popupRef:e,richText:s}){if(!e)return;if(this.#i||=new hs(this),this.#i.setInitialText(t,s),!this.annotationElementId)return;let i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);if(i)this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new hs(this),this.#i.edit(t)}toggleComment(t,e=void 0){if(this.hasComment)this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,i]=t.rect,[r]=this.pageDimensions,[n]=this.pageTranslation,a=n+r+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");if(t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#n?-1:0,t.setAttribute("role","application"),this.defaultL10nId)t.setAttribute("data-l10n-id",this.defaultL10nId);if(!this._isVisible)t.classList.add("hidden");this.setInForeground(),this.#H();let[e,s]=this.parentDimensions;if(this.parentRotation%180!==0)t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`;let[i,r]=this.getInitialTranslation();return this.translate(i,r),fa(this,t,["keydown","pointerdown","dblclick"]),this.#G(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#V(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#j(t,e,s){let r=0.7*(s/e)+1-0.7;if(r===1)return;let n=this.#F(this.rotation),a=(w,A)=>[n[0]*w+n[2]*A,n[1]*w+n[3]*A],[o,l]=this.parentDimensions,c=this.x,h=this.y,d=this.width,u=this.height,f=U.MIN_SIZE/o,p=U.MIN_SIZE/l;r=Math.max(Math.min(r,1/d,1/u),f/d,p/u);let g=U._round(d*r),m=U._round(u*r);if(g===d&&m===u)return;this.#d||=[c,h,d,u];let v=a(d/2,u/2),y=U._round(c+v[0]),b=U._round(h+v[1]),_=a(g/2,m/2);this.x=y-_[0],this.y=b-_[1],this.width=g,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#$(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#R()}pointerdown(t){let{isMac:e}=lt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#x(t);return}this.#T(t)}#T(t){let{isMac:e}=lt.platform;if(t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e)this.parent.toggleSelected(this);else this.parent.setSelected(this)}#x(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,i=new AbortController,r=this._uiManager.combinedSignal(i),n={capture:!0,passive:!1,signal:r},a=(l)=>{if(i.abort(),this.#a=null,this.#m=!1,!this._uiManager.endDragSession())this.#T(l);if(s)this._onStopDragging()};if(e)this.#_=t.clientX,this.#A=t.clientY,this.#a=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",(l)=>{if(!s)s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging();let{clientX:c,clientY:h,pointerId:d}=l;if(d!==this.#a){Tt(l);return}let[u,f]=this.screenToPageTranslation(c-this.#_,h-this.#A);this.#_=c,this.#A=h,this._uiManager.dragSelectedEditors(u,f),this.div.scrollIntoView({block:"nearest"})},n),window.addEventListener("touchmove",Tt,n),window.addEventListener("pointerdown",(l)=>{if(l.pointerType===this.#o){if(this.#w||l.isPrimary)a(l)}Tt(l)},n);let o=(l)=>{if(!this.#a||this.#a===l.pointerId){a(l);return}Tt(l)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){if(this.#b)clearTimeout(this.#b);this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let i=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,c=e/i,h=this.x*r,d=this.y*n,u=this.width*r,f=this.height*n;switch(s){case 0:return[h+l+a,n-d-c-f+o,h+l+u+a,n-d-c+o];case 90:return[h+c+a,n-d+l+o,h+c+f+a,n-d+l+u+o];case 180:return[h-l-u+a,n-d+c+o,h-l+a,n-d+c+f+o];case 270:return[h-c-f+a,n-d-l-u+o,h-c+a,n-d-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[s,i,r,n]=t,a=r-s,o=n-i;switch(this.rotation){case 0:return[s,e-n,a,o];case 90:return[s,e-i,o,a];case 180:return[r,e-i,a,o];case 270:return[r,e-n,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&U._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:n},uid:a,pageIndex:o,creationDate:l,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:l,modificationDate:s||c,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;return this.parent.setEditingState(!1),this.#v=!0,!0}disableEditMode(){if(!this.isInEditMode())return!1;return this.parent.setEditingState(!0),this.#v=!1,!0}isInEditMode(){return this.#v}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&i>0&&t<r&&s>0}#H(){if(this.#f||!this.div)return;this.#f=new AbortController;let t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#G(){if(this.#w||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom)return;this.#w=new Cr({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#V.bind(this),onPinching:this.#j.bind(this),onPinchEnd:this.#$.bind(this),signal:this._uiManager._signal})}rebuild(){this.#H(),this.#G()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){let i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;let[r,n]=i.pageDimensions,[a,o,l,c]=i.getRectInCurrentCoords(t.rect,n);return i.x=a/r,i.y=o/n,i.width=l/r,i.height=c/n,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,!this.isEmpty())this.commit();if(this.#w?.destroy(),this.#w=null,this.parent)this.parent.remove(this);else this._uiManager.removeEditor(this);if(this.hideCommentPopup(),this.#b)clearTimeout(this.#b),this.#b=null;if(this.#L(),this.removeEditToolbar(),this.#S){for(let t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#h?.remove(),this.#h=null}get isResizable(){return!1}makeResizable(){if(this.isResizable)this.#P(),this.#l.classList.remove("hidden")}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[s,i,r,n]=this.getPDFRect();return[U._round(s+(r-s)*t),U._round(i+(n-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#l.children;if(!this.#e){this.#e=Array.from(e);let n=this.#W.bind(this),a=this.#q.bind(this),o=this._uiManager._signal;for(let l of this.#e){let c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",n,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,c),{signal:o}),l.setAttribute("data-l10n-id",U._l10nResizer[c])}}let s=this.#e[0],i=0;for(let n of e){if(n===s)break;i++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(r!==i){if(r<i)for(let a=0;a<i-r;a++)this.#l.append(this.#l.firstElementChild);else if(r>i)for(let a=0;a<r-i;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let n=0;for(let a of e){let l=this.#e[n++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",U._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#W(t){U._resizerKeyboardManager.exec(this,t)}#q(t){if(this.#y&&t.relatedTarget?.parentNode!==this.#l)this.#L()}#Y(t){this.#p=this.#y?t:""}#K(t){if(!this.#e)return;for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){if(!this.#y)return;this.#B(this.#p,{deltaX:t,deltaY:e,fromKeyboard:!0})}#L(){this.#y=!1,this.#K(-1),this.#R()}_stopResizingWithKeyboard(){this.#L(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{if(this.div?.classList.contains("selectedEditor"))this.#N()});return}this.#N(),this.#s?.toggleAltTextBadge(!1)}#N(){if(this._editToolbar?.show(),this._uiManager._keepToolbarInPage)this.fixAndSetPosition(),this._onTranslated()}focus(){if(this.div&&!this.div.contains(document.activeElement))setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(!this.isSelected)return;if(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement))this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide(),this.#s?.toggleAltTextBadge(!0),this.hideCommentPopup()}hideCommentPopup(){if(this.hasComment)this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(!this.canChangeContent)return;this.enableEditMode(),this.div.focus()}dblclick(t){if(t.target.nodeName==="BUTTON")return;this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(t){if(this.#g=t,!this.parent)return;if(t)this.parent.setSelected(this),this.parent.setActiveEditor(this);else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#S||=new Map;let{action:s}=t,i=this.#S.get(s);if(i)clearTimeout(i);i=setTimeout(()=>{if(this._reportTelemetry(t),this.#S.delete(s),this.#S.size===0)this.#S=null},U._telemetryTimeout),this.#S.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){if(this.div)this.div.tabIndex=0;this.#n=!1}disable(){if(this.div)this.div.tabIndex=-1;this.#n=!0}updateFakeAnnotationElement(t){if(!this.#h&&!this.deleted){this.#h=t.addFakeAnnotation(this);return}if(this.deleted){this.#h.remove(),this.#h=null;return}if(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)this.#h.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;if(e?.nodeName==="DIV"&&e.classList.contains("annotationContent"))e.remove()}}class ma extends U{constructor(t){super(t);this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var ln=3285377520,qt=4294901760,ae=65535;class Ys{constructor(t){this.h1=t?t&4294967295:ln,this.h2=t?t&4294967295:ln}update(t){let e,s;if(typeof t==="string"){e=new Uint8Array(t.length*2),s=0;for(let p=0,g=t.length;p<g;p++){let m=t.charCodeAt(p);if(m<=255)e[s++]=m;else e[s++]=m>>>8,e[s++]=m&255}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let i=s>>2,r=s-i*4,n=new Uint32Array(e.buffer,0,i),a=0,o=0,l=this.h1,c=this.h2,h=3432918353,d=461845907,u=h&ae,f=d&ae;for(let p=0;p<i;p++)if(p&1)a=n[p],a=a*h&qt|a*u&ae,a=a<<15|a>>>17,a=a*d&qt|a*f&ae,l^=a,l=l<<13|l>>>19,l=l*5+3864292196;else o=n[p],o=o*h&qt|o*u&ae,o=o<<15|o>>>17,o=o*d&qt|o*f&ae,c^=o,c=c<<13|c>>>19,c=c*5+3864292196;switch(a=0,r){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:if(a^=e[i*4],a=a*h&qt|a*u&ae,a=a<<15|a>>>17,a=a*d&qt|a*f&ae,i&1)l^=a;else c^=a}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&qt|t*36045&ae,e=e*4283543511&qt|((e<<16|t>>>16)*2950163797&qt)>>>16,t^=e>>>1,t=t*444984403&qt|t*60499&ae,e=e*3301882366&qt|((e<<16|t>>>16)*3120437893&qt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var vs=Object.freeze({map:null,hash:"",transfer:void 0});class xi{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let s=this.#i.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){let e=this.#i.get(t);if(e===void 0)return;if(e instanceof U)this.#s.delete(e.annotationElementId);if(this.#i.delete(t),this.#i.size===0)this.resetModified();if(this.#i.values().some((s)=>s instanceof U))return;this.onAnnotationEditor?.(null)}setValue(t,e){let s=this.#i.get(t),i=!1;if(s!==void 0){for(let[r,n]of Object.entries(e))if(s[r]!==n)i=!0,s[r]=n}else i=!0,this.#i.set(t,e);if(i)this.#r();if(e instanceof U)(this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type)}has(t){return this.#i.has(t)}get size(){return this.#i.size}#r(){if(!this.#t)this.#t=!0,this.onSetModified?.()}resetModified(){if(this.#t)this.#t=!1,this.onResetModified?.()}get print(){return new Ir(this)}get serializable(){if(this.#i.size===0)return vs;let t=new Map,e=new Ys,s=[],i=Object.create(null),r=!1;for(let[n,a]of this.#i){let o=a instanceof U?a.serialize(!1,i):a;if(a.page)a.pageIndex=a.page._pageIndex,delete a.page;if(o)t.set(n,o),e.update(`${n}:${JSON.stringify(o)}`),r||=!!o.bitmap}if(r){for(let n of t.values())if(n.bitmap)s.push(n.bitmap)}return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:vs}get editorStats(){let t=null,e=new Map,s=0,i=0;for(let r of this.#i.values()){if(!(r instanceof U)){if(r.popup)if(r.popup.deleted)i+=1;else s+=1;continue}if(r.isCommentDeleted)i+=1;else if(r.hasEditedComment)s+=1;let n=r.telemetryFinalData;if(!n)continue;let{type:a}=n;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(r).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[l,c]of Object.entries(n)){if(l==="type")continue;let h=o.getOrInsertComputed(l,Ws);h.set(c,(h.get(c)??0)+1)}}if(i>0||s>0)t||=Object.create(null),t.comments={deleted:i,edited:s};if(!t)return null;for(let[r,n]of e)t[r]=n.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){let s=this.#s?.get(t);if(s)return s.updateFromAnnotationLayer(e),!0;return!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;let t=[];if(this.#s)for(let s of this.#s.values()){if(!s.serialize())continue;t.push(s.annotationElementId)}let e="";if(t.length){let s=new Ys;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}}class Ir extends xi{#t=vs;constructor(t){super();let{serializable:e}=t;if(e===vs)return;let{map:s,hash:i,transfer:r}=e,n=structuredClone(s,r?{transfer:r}:null);this.#t={map:n,hash:i,transfer:[]}}get print(){at("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return L(this,"modifiedIds",{ids:new Set,hash:""})}}function rh(t){if(t instanceof URL)return t;if(typeof t==="string"){if(Wt){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);let s=process.getBuiltinModule("url");return new URL(s.pathToFileURL(t))}let e=URL.parse(t,window.location);if(e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function nh(t){if(Wt&&typeof Buffer<"u"&&t instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t==="string")return Ai(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t==="object"&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Ms(t){if(typeof t!=="string")return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}var tr=(t)=>typeof t==="object"&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,ah=(t)=>typeof t==="object"&&typeof t?.name==="string",oh=Yc.bind(null,tr,ah);function lh(t,e){let s=URL.parse(t);if(!s?.origin||s.origin==="null")return!1;let i=new URL(e,s);return s.origin===i.origin}function va(t){if(!lh(window.location,t)){let e=`await import("${new URL(t,window.location).href}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}return t}class ya{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){let{signal:r}=s;if(r.aborted){W("LoopbackPort - cannot use an `aborted` signal.");return}let n=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}}class er{#t=new Map;times=[];time(t){if(this.#t.has(t))W(`Timer is already running for ${t}`);this.#t.set(t,Date.now())}timeEnd(t){if(!this.#t.has(t))W(`Timer has not been started for ${t}`);this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){let t=Math.max(...this.times.map((e)=>e.name.length));return this.times.map((e)=>`${e.name.padEnd(t)} ${e.end-e.start}ms
4
+ `).join("")}}var ch=`
5
5
  struct Uniforms {
6
6
  offsetX : f32,
7
7
  offsetY : f32,
@@ -44,14 +44,14 @@ fn vs_main(in : VertexInput) -> VertexOutput {
44
44
  fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
45
45
  return vec4<f32>(in.color, 1.0);
46
46
  }
47
- `;class Yn{#t=null;#e=null;#s=null;#i=null;async#n(){if(!globalThis.navigator?.gpu)return!1;try{let t=await navigator.gpu.requestAdapter();if(!t)return!1;return this.#i=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0}catch{return!1}}init(){return this.#t||=this.#n()}get isReady(){return this.#e!==null}loadMeshShader(){if(!this.#e||this.#s)return;let t=this.#e.createShaderModule({code:Ta});this.#s=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#i}]},primitive:{topology:"triangle-list"}})}draw(t,e,s,i,n,r,a,o){this.loadMeshShader();let l=this.#e,{offsetX:h,offsetY:c,scaleX:d,scaleY:u}=i,f=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(t.byteLength>0)l.queue.writeBuffer(f,0,t);let p=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(e.byteLength>0)l.queue.writeBuffer(p,0,e);let g=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(g,0,new Float32Array([h,c,d,u,r,a,o,0]));let m=l.createBindGroup({layout:this.#s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),v=new OffscreenCanvas(r,a),y=v.getContext("webgpu");y.configure({device:l,format:this.#i,alphaMode:n?"opaque":"premultiplied"});let S=n?{r:n[0]/255,g:n[1]/255,b:n[2]/255,a:1}:{r:0,g:0,b:0,a:0},A=l.createCommandEncoder(),b=A.beginRenderPass({colorAttachments:[{view:y.getCurrentTexture().createView(),clearValue:S,loadOp:"clear",storeOp:"store"}]});if(s>0)b.setPipeline(this.#s),b.setBindGroup(0,m),b.setVertexBuffer(0,f),b.setVertexBuffer(1,p),b.draw(s);return b.end(),l.queue.submit([A.finish()]),f.destroy(),p.destroy(),g.destroy(),v.transferToImageBitmap()}}var Os=new Yn;function Ca(){return Os.init()}function Ia(){return Os.isReady}function Pa(){Os.loadMeshShader()}function Ma(t,e,s,i,n,r,a,o){return Os.draw(t,e,s,i,n,r,a,o)}var Ct={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function ds(t,e){if(!e)return;let s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}class Rs{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){st("Abstract method `getPattern` called.")}}class Kn extends Rs{constructor(t){super();this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7]}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;let t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,n=this._p1;if(e)i=i.slice(),n=n.slice(),L.applyTransform(i,e),L.applyTransform(n,e);if(this._type==="axial")s=t.createLinearGradient(i[0],i[1],n[0],n[1]);else if(this._type==="radial"){let r=this._r0,a=this._r1;if(e){let o=new Float32Array(2);L.singularValueDecompose2dScale(e,o),r*=o[0],a*=o[0]}s=t.createRadialGradient(i[0],i[1],r,n[0],n[1],a)}for(let r of this._colorStops)s.addColorStop(r[0],r[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;if(e)s=s.slice(),i=i.slice(),L.applyTransform(s,e),L.applyTransform(i,e);let n=this._r1,r=this._r0;if(e){let l=new Float32Array(2);L.singularValueDecompose2dScale(e,l),n*=l[0],r*=l[0]}let a=t.createRadialGradient(s[0],s[1],n,i[0],i[1],r),o=this._colorStops.map(([l,h])=>[1-l,h]).reverse();for(let[l,h]of o)a.addColorStop(l,h);return a}getPattern(t,e,s,i){let n;if(i===Ct.STROKE||i===Ct.FILL){if(this.isOriginBased()){let d=L.transform(s,e.baseTransform);if(this.matrix)d=L.transform(d,this.matrix);let u=0.001,f=Math.hypot(d[0],d[1]),p=Math.hypot(d[2],d[3]),g=(d[0]*d[2]+d[1]*d[3])/(f*p);if(Math.abs(g)<u)if(this.isRadial()){if(Math.abs(f-p)<u)return this._createGradient(t,d)}else return this._createGradient(t,d)}let r=e.current.getClippedPathBoundingBox(i,dt(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.canvasFactory.create(a,o),h=l.context;if(h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),s=L.transform(s,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix)h.transform(...this.matrix);if(ds(h,this._bbox),this.areConic())h.fillStyle=this._createReversedGradient(h),h.fill();h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);let c=new DOMMatrix(s);n.setTransform(c)}else{if(this.areConic())t.save(),ds(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-10000000000,-10000000000,20000000000,20000000000),t.restore();ds(t,this._bbox),n=this._createGradient(t)}return n}}function Oa(t,e,s,i,n,r,a,o){let{coords:l,colors:h}=e,c=t.data,d=t.width*4,u;if(l[s*2+1]>l[i*2+1])u=s,s=i,i=u,u=r,r=a,a=u;if(l[i*2+1]>l[n*2+1])u=i,i=n,n=u,u=a,a=o,o=u;if(l[s*2+1]>l[i*2+1])u=s,s=i,i=u,u=r,r=a,a=u;let f=(l[s*2]+e.offsetX)*e.scaleX,p=(l[s*2+1]+e.offsetY)*e.scaleY,g=(l[i*2]+e.offsetX)*e.scaleX,m=(l[i*2+1]+e.offsetY)*e.scaleY,v=(l[n*2]+e.offsetX)*e.scaleX,y=(l[n*2+1]+e.offsetY)*e.scaleY;if(p>=y)return;let S=h[r*4],A=h[r*4+1],b=h[r*4+2],w=h[a*4],x=h[a*4+1],T=h[a*4+2],E=h[o*4],I=h[o*4+1],C=h[o*4+2],O=Math.round(p),D=Math.round(y),k,R,M,_,U,G,it,rt;for(let J=O;J<=D;J++){if(J<m){let P=J<p?0:(p-J)/(p-m);k=f-(f-g)*P,R=S-(S-w)*P,M=A-(A-x)*P,_=b-(b-T)*P}else{let P;if(J>y)P=1;else if(m===y)P=0;else P=(m-J)/(m-y);k=g-(g-v)*P,R=w-(w-E)*P,M=x-(x-I)*P,_=T-(T-C)*P}let et;if(J<p)et=0;else if(J>y)et=1;else et=(p-J)/(p-y);U=f-(f-v)*et,G=S-(S-E)*et,it=A-(A-I)*et,rt=b-(b-C)*et;let ht=Math.round(Math.min(k,U)),Rt=Math.round(Math.max(k,U)),N=d*J+ht*4;for(let P=ht;P<=Rt;P++){if(et=(k-P)/(k-U),et<0)et=0;else if(et>1)et=1;c[N++]=R-(R-G)*et|0,c[N++]=M-(M-it)*et|0,c[N++]=_-(_-rt)*et|0,c[N++]=255}}}class Jn extends Rs{constructor(t){super();this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],Pa()}_createMeshCanvas(t,e,s){let a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-a,h=Math.ceil(this._bounds[3])-o,c=Math.min(Math.ceil(Math.abs(l*t[0]*1.1)),3000)||1,d=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3000)||1,u=l?l/c:1,f=h?h/d:1,p={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/u,scaleY:1/f},g=c+4,m=d+4,v=s.create(g,m);if(Ia()&&this._vertexCount>48)v.context.drawImage(Ma(this._posData,this._colData,this._vertexCount,p,e,g,m,2),0,0);else{let y=v.context.createImageData(c,d);if(e){let S=y.data;for(let A=0,b=S.length;A<b;A+=4)S[A]=e[0],S[A+1]=e[1],S[A+2]=e[2],S[A+3]=255}for(let S=0,A=this._vertexCount;S<A;S+=3)Oa(y,p,S,S+1,S+2,S,S+1,S+2);v.context.putImageData(y,2,2)}return{canvas:v.canvas,offsetX:a-2*u,offsetY:o-2*f,scaleX:u,scaleY:f}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){ds(t,this._bbox);let n=new Float32Array(2);if(i===Ct.SHADING)L.singularValueDecompose2dScale(dt(t),n);else if(this.matrix){L.singularValueDecompose2dScale(this.matrix,n);let[o,l]=n;L.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=o,n[1]*=l}else L.singularValueDecompose2dScale(e.baseTransform,n);let r=this._createMeshCanvas(n,i===Ct.SHADING?null:this._background,e.canvasFactory);if(i!==Ct.SHADING){if(t.setTransform(...e.baseTransform),this.matrix)t.transform(...this.matrix)}t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY);let a=t.createPattern(r.canvas,"no-repeat");return e.canvasFactory.destroy(r),a}}class Qn extends Rs{getPattern(){return"hotpink"}}function Ra(t){switch(t[0]){case"RadialAxial":return new Kn(t);case"Mesh":return new Jn(t);case"Dummy":return new Qn}throw Error(`Unknown IR type: ${t[0]}`)}var sn={COLORED:1,UNCOLORED:2};class He{static MAX_PATTERN_SIZE=3000;constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?L.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){let[n,r,a,o]=this.bbox,l=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>l+0.000001||e>h+0.000001)return null;let c=Math.floor((s-a)/l)+1,d=Math.ceil((s+t-n)/l)-1,u=Math.floor((i-o)/h)+1,f=Math.ceil((i+e-r)/h)-1;return d<=c&&f<=u?[c,u]:null}updatePatternDims(t,e){let s=L.inverseTransform(this.patternBaseMatrix),i=[t[0],t[1]],n=[t[2],t[3]];L.applyTransform(i,s),L.applyTransform(n,s),e[0]=Math.abs(n[0]-i[0]),e[1]=Math.abs(n[1]-i[1]),e[2]=Math.min(i[0],n[0]),e[3]=Math.min(i[1],n[1])}_renderTileCanvas(t,e,s,i){let[n,r,a,o]=this.bbox,l=t.canvasFactory.create(s.size,i.size),h=l.context,c=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return c.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(c,this.paintType,this.color),h.translate(-s.scale*n,-i.scale*r),c.transform(0,s.scale,0,0,i.scale,0,0),h.save(),c.dependencyTracker?.save(),this.clipBbox(c,n,r,a,o),c.baseTransform=dt(c.ctx),c.executeOperatorList(this.operatorList),c.endDrawing(),c.dependencyTracker?.restore(),h.restore(),l}_getCombinedScales(){let t=new Float32Array(2);L.singularValueDecompose2dScale(this.matrix,t);let[e,s]=t;return L.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,n],r){let[a,o,l,h]=this.bbox,c=t.dependencyTracker;if(c)t.dependencyTracker=new Ge(c,r);if(t.save(),s)t.ctx.clip(e,"evenodd");else t.ctx.clip(e);if(t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,n*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){let d=l-a,u=h-o,[f,p]=this._getCombinedScales(),g=this.getSizeAndScale(d,this.ctx.canvas.width,f),m=this.getSizeAndScale(u,this.ctx.canvas.height,p),v=this._renderTileCanvas(t,r,g,m);t.ctx.drawImage(v.canvas,a,o,d,u),t.canvasFactory.destroy(v)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=dt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();if(t.restore(),c)t.dependencyTracker=c}createPatternCanvas(t,e){let[s,i,n,r]=this.bbox,a=n-s,o=r-i,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),Ts("TilingType: "+this.tilingType);let[c,d]=this._getCombinedScales(),u=a,f=o,p=!1,g=!1;if(Math.ceil(l*c)>=Math.ceil(a*c))u=l;else p=!0;if(Math.ceil(h*d)>=Math.ceil(o*d))f=h;else g=!0;let m=this.getSizeAndScale(u,this.ctx.canvas.width,c),v=this.getSizeAndScale(f,this.ctx.canvas.height,d),y=this._renderTileCanvas(t,e,m,v);if(p||g){let S=y.canvas;if(p)u=l;if(g)f=h;let A=this.getSizeAndScale(u,this.ctx.canvas.width,c),b=this.getSizeAndScale(f,this.ctx.canvas.height,d),w=A.size,x=b.size,T=t.canvasFactory.create(w,x),E=T.context,I=p?Math.floor(a/l):0,C=g?Math.floor(o/h):0;for(let O=0;O<=I;O++)for(let D=0;D<=C;D++)E.drawImage(S,w*O,x*D,w,x,0,0,w,x);return t.canvasFactory.destroy(y),{canvas:T.canvas,canvasEntry:T,scaleX:A.scale,scaleY:b.scale,offsetX:s,offsetY:i}}return{canvas:y.canvas,canvasEntry:y,scaleX:m.scale,scaleY:v.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){let i=Math.max(He.MAX_PATTERN_SIZE,e),n=Math.ceil(t*s);if(n>=i)n=i;else s=n/t;return{scale:s,size:n}}clipBbox(t,e,s,i,n){let r=i-e,a=n-s,o=new Path2D;o.rect(e,s,r,a),L.axialAlignedBoundingBox([e,s,i,n],dt(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){let{ctx:i,current:n}=t;switch(n.patternFill=n.patternStroke=!1,e){case sn.COLORED:let{fillStyle:r,strokeStyle:a}=this.ctx;i.fillStyle=n.fillColor=r,i.strokeStyle=n.strokeColor=a;break;case sn.UNCOLORED:i.fillStyle=i.strokeStyle=s,n.fillColor=n.strokeColor=s;break;default:throw new yn(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,n){let r=i!==Ct.SHADING?L.transform(s,this.patternBaseMatrix):s,a=this.createPatternCanvas(e,n),o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}var Da=16,ka=100,La=15,nn=10,kt=16,Bt=new Float32Array(2);function rn(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");let s=new Map;for(let i of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){let n=t[i];if(typeof n!=="function"||typeof e[i]!=="function")continue;s.set(i,n),t[i]=function(...r){return e[i](...r),n.apply(this,r)}}t._removeMirroring=()=>{for(let[i,n]of s)t[i]=n;delete t._removeMirroring}}function is(t,e,s,i,n,r,a,o,l,h){let[c,d,u,f,p,g]=dt(t);if(d===0&&u===0){let y=a*c+p,S=Math.round(y),A=o*f+g,b=Math.round(A),w=(a+l)*c+p,x=Math.abs(Math.round(w)-S)||1,T=(o+h)*f+g,E=Math.abs(Math.round(T)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(f),S,b),t.drawImage(e,s,i,n,r,0,0,x,E),t.setTransform(c,d,u,f,p,g),[x,E]}if(c===0&&f===0){let y=o*u+p,S=Math.round(y),A=a*d+g,b=Math.round(A),w=(o+h)*u+p,x=Math.abs(Math.round(w)-S)||1,T=(a+l)*d+g,E=Math.abs(Math.round(T)-b)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,S,b),t.drawImage(e,s,i,n,r,0,0,E,x),t.setTransform(c,d,u,f,p,g),[E,x]}t.drawImage(e,s,i,n,r,a,o,l,h);let m=Math.hypot(c,d),v=Math.hypot(u,f);return[m*l,v*h]}class ni{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Ys;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=bt.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=de.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=Ct.FILL,e=null){let s=this.minMax.slice();if(t===Ct.STROKE){if(!e)st("Stroke bounding box must include transform.");L.singularValueDecompose2dScale(e,Bt);let i=Bt[0]*this.lineWidth/2,n=Bt[1]*this.lineWidth/2;s[0]-=i,s[1]-=n,s[2]+=i,s[3]+=n}return s}updateClipFromPath(){let t=L.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(de,0)}getClippedPathBoundingBox(t=Ct.FILL,e=null){return L.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function an(t,e){let{width:s,height:i,kind:n}=e,r=i%kt,a=(i-r)/kt,o=r===0?a:a+1,l=t.createImageData(s,kt),h=0,c=e.data,d=l.data,u;if(n===hs.GRAYSCALE_1BPP)for(u=0;u<o;u++)({srcPos:h}=Xn({src:c,srcPos:h,dest:d,width:s,height:u<a?kt:r})),t.putImageData(l,0,u*kt);else if(n===hs.RGBA_32BPP){let f=0,p=s*kt*4;for(u=0;u<a;u++)d.set(c.subarray(h,h+p)),h+=p,t.putImageData(l,0,f),f+=kt;if(u<o)p=s*r*4,d.set(c.subarray(h,h+p)),t.putImageData(l,0,f)}else if(n===hs.RGB_24BPP)for(u=0;u<o;u++)({srcPos:h}=Ea({src:c,srcPos:h,dest:new Uint32Array(d.buffer),width:s,height:u<a?kt:r})),t.putImageData(l,0,u*kt);else throw Error(`bad image kind: ${n}`)}function on(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}let{width:s,height:i}=e,n=i%kt,r=(i-n)/kt,a=n===0?r:r+1,o=t.createImageData(s,kt),l=0,h=e.data,c=o.data;for(let d=0;d<a;d++)({srcPos:l}=Xn({src:h,srcPos:l,dest:c,width:s,height:d<r?kt:n,nonBlackColor:0})),t.putImageData(o,0,d*kt)}function le(t,e){let s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let i of s)if(t[i]!==void 0)e[i]=t[i];if(t.setLineDash!==void 0)e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset}function ns(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0)t.setLineDash([]),t.lineDashOffset=0;let{filter:e}=t;if(e!=="none"&&e!=="")t.filter="none"}function ln(t,e){if(e)return!0;L.singularValueDecompose2dScale(t,Bt);let s=Math.fround(Wt.pixelRatio*pe.PDF_TO_CSS_UNITS);return Bt[0]<=s&&Bt[1]<=s}var Na=["butt","round","square"],Fa=["miter","round","bevel"],Ba={},hn={};class fe{static#t=null;#e=0;#s=0;#i=null;#n=null;#a=null;#r=null;#o=1;#l;#h=null;#u=[];constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,h,c){this.ctx=t,this.current=new ni(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=c??null}getObject(t,e,s=null){if(typeof e==="string")return this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e);return s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){let n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){let o=this.transparentCanvasEntry=this.canvasFactory.create(n,r);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=o,this.ctx.save(),this.ctx.transform(...dt(this.compositeCtx))}if(this.ctx.save(),ns(this.ctx),t)this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3];this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=dt(this.ctx)}executeOperatorList(t,e,s,i,n){let{argsArray:r,fnArray:a}=t,o=e||0,l=r.length;if(l===o)return o;let h=l-o>nn&&typeof s==="function",c=h?Date.now()+La:0,d=0,u=this.commonObjs,f=this.objs,p,g;while(!0){if(i!==void 0){if(o===i.nextBreakPoint)return i.breakIt(o,s),o;if(i.shouldSkip(o)){if(++o===l)return o;continue}}if(!n||n(o))if(p=a[o],g=r[o]??null,p!==Qt.dependency)if(g===null)this[p](o);else this[p](o,...g);else for(let m of g){this.dependencyTracker?.recordNamedData(m,o);let v=m.startsWith("g_")?u:f;if(!v.has(m))return v.get(m,s),o}if(o++,o===l)return o;if(h&&++d>nn){if(Date.now()>c)return s(),o;d=0}}}#d(){while(this.stateStack.length||this.inSMaskMode)this.restore();if(this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas)this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null}endDrawing(){this.#d();for(let t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let t of this.#u)this.#A(t);this.#u.length=0,this.#i=null,this.#n=null,this.#a=null,this.#r=null,this.#o=1,this.#h=null,this.#s=0,this.#e=0,this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)e.width=e.height=0;t.clear()}this._cachedBitmapsMap.clear(),this.#f()}#f(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let s=t.width??t.displayWidth,i=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=[],o=n,l=r,h=s,c=i;while(o>2&&h>1||l>2&&c>1){let m=h,v=c;if(o>2&&h>1)m=Math.ceil(h/2),o/=h/m;if(l>2&&c>1)v=Math.ceil(c/2),l/=c/v;a.push({newWidth:m,newHeight:v}),h=m,c=v}if(a.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(a.length===1){let{newWidth:m,newHeight:v}=a[0],y=this.canvasFactory.create(m,v);return y.context.drawImage(t,0,0,s,i,0,0,m,v),{img:y.canvas,paintWidth:m,paintHeight:v,tmpCanvas:y}}let d=this.canvasFactory.create(1,1),u=this.canvasFactory.create(1,1),f=s,p=i,g=t;for(let{newWidth:m,newHeight:v}of a)this.canvasFactory.reset(u,m,v),u.context.drawImage(g,0,0,f,p,0,0,m,v),[d,u]=[u,d],g=d.canvas,f=m,p=v;return this.canvasFactory.destroy(u),{img:d.canvas,paintWidth:f,paintHeight:p,tmpCanvas:d}}_createMaskCanvas(t,e){let s=this.ctx,{width:i,height:n}=e,r=this.current.fillColor,a=this.current.patternFill,o=dt(s),l,h,c,d;if((e.bitmap||e.data)&&e.count>1){let I=e.bitmap||e.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.getOrInsertComputed(I,ai);let C=l.get(h);if(C&&!a){let O=Math.round(Math.min(o[0],o[2])+o[4]),D=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Ht.transformAndFill),{canvas:C,offsetX:O,offsetY:D}}c=C}if(!c)d=this.canvasFactory.create(i,n),on(d.context,e);let u=L.transform(o,[1/i,0,0,-1/n,0,0]);u=L.transform(u,[1,0,0,1,0,-n]);let f=de.slice();L.axialAlignedBoundingBox([0,0,i,n],u,f);let[p,g,m,v]=f,y=Math.round(m-p)||1,S=Math.round(v-g)||1,A=this.canvasFactory.create(y,S),b=A.context,w=p,x=g;b.translate(-w,-x),b.transform(...u);let T=null;if(!c){let I=this._scaleImage(d.canvas,Yt(b));if(c=I.img,T=I.tmpCanvas,c!==d.canvas)this.canvasFactory.destroy(d),d=null;if(l&&a)l.set(h,c),T=null,d=null}if(b.imageSmoothingEnabled=ln(dt(b),e.interpolate),is(b,c,0,0,c.width,c.height,0,0,i,n),T)this.canvasFactory.destroy(T);if(d)this.canvasFactory.destroy(d);b.globalCompositeOperation="source-in";let E=L.transform(Yt(b),[1,0,0,1,-w,-x]);if(b.fillStyle=a?r.getPattern(s,this,E,Ct.FILL,t):r,b.fillRect(0,0,i,n),l&&!a)l.set(h,A.canvas);return this.dependencyTracker?.recordDependencies(t,Ht.transformAndFill),{canvas:A.canvas,canvasEntry:l&&!a?null:A,offsetX:Math.round(w),offsetY:Math.round(x)}}setLineWidth(t,e){if(this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth)this._cachedScaleForStroking[0]=-1;this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Na[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Fa[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);let i=this.ctx;if(i.setLineDash!==void 0)i.setLineDash(e),i.lineDashOffset=s}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[s,i]of e)switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=i;break;case"SMask":if(this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=i?this.tempSMask:null,this.current.activeSMask)this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation;this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry)this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null;this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){if(t===this.smaskPreparedFor)return;this._clearPreparedSMask(),this._prepareSMaskCanvas(t)}checkSMaskState(t){let e=this.inSMaskMode;if(this.current.activeSMask&&!e)this.beginSMaskMode(t);else if(!this.current.activeSMask&&e)this.endSMaskMode();else if(this.current.activeSMask&&e)this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){let{canvas:e,subtype:s,backdrop:i,transferMap:n}=t,r=s==="Luminosity"||s==="Alpha"&&n;if(!r&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let a;if(s==="Luminosity"&&i){let[v,y,S]=Ye(i),A=Math.round(0.3*v+0.59*y+0.11*S);a=n?.[A]??A}else a=n?.[0]??0;let o=4,{width:l,height:h}=this.ctx.canvas,c=e.width*e.height,d=l*h<o*c,u=r?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(n):this.filterFactory.addLuminosityFilter(n),subtype:s,transferMap:n}:null,f=s==="Luminosity"?i:null,p,g,m;if(d)p=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,l,h,f,u),g=0,m=0;else p=this._bakeSMaskCanvas(e,0,0,e.width,e.height,f,u),g=t.offsetX,m=t.offsetY;this.smaskPreparedEntry=p,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=g,this.smaskPreparedOffsetY=m,this.smaskPreparedOOBAlpha=!d&&a!==0?a:null}_bakeSMaskCanvas(t,e,s,i,n,r,a){if(!r&&!a)st("_bakeSMaskCanvas with neither backdrop nor filter");let o=this.canvasFactory.create(i,n),l=o.context;if(l.drawImage(t,e,s),r)l.globalCompositeOperation="destination-atop",l.fillStyle=r,l.fillRect(0,0,i,n);if(!a)return o;let h=this.canvasFactory.create(i,n),c=h.context;c.filter=a.url;let d=ot.isCanvasFilterSupported&&c.filter!=="none"&&c.filter!=="";if(c.drawImage(o.canvas,0,0),ot.isCanvasFilterSupported)c.filter="none";if(!d){let u=c.getImageData(0,0,i,n),{data:f}=u,{transferMap:p}=a;if(a.subtype==="Luminosity")for(let g=0,m=f.length;g<m;g+=4){let v=0.3*f[g]+0.59*f[g+1]+0.11*f[g+2]+0.5|0;f[g]=f[g+1]=f[g+2]=0,f[g+3]=p?.[v]??v}else for(let g=3,m=f.length;g<m;g+=4)f[g]=p[f[g]];c.putImageData(u,0,0)}return this.canvasFactory.destroy(o),h}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;let n=this.ctx=i.context;n.setTransform(this.suspendedCtx.getTransform()),le(this.suspendedCtx,n),rn(n,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),le(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#g(t,e=null,s=1){let{width:i,height:n}=t,r=e??this.canvasFactory.create(i,n),a=r.context;s=Math.round(s*255)/255;let o=s<1;if(o&&this.#l===void 0)this.#l=ot.isCanvasFilterSupported?new Map:"none";let l="none";if(o&&this.#l instanceof Map)l=this.#l.getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s));if(!o||l!=="none"){if(e)a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,n),a.restore();return a.filter=l,a.drawImage(t,0,0),a.filter="none",r}let h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,n),c=a.createImageData(i,n),d=h.data,u=c.data,f=s>0?1/s:1e6;for(let p=3,g=d.length;p<g;p+=4)u[p]=Math.min(Math.round(d[p]*f),255);return a.putImageData(c,0,0),r}#m(t,e,s,i){let n=t?.[e]??null;if(n&&(n.canvas.width!==s||n.canvas.height!==i))this.canvasFactory.destroy(n),n=null;if(!n){if(n=this.canvasFactory.create(s,i),t)t[e]=n;return n}let r=n.context;return r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,s,i),r.restore(),n}#c(t,e,s={}){let{backdropCanvas:i=null,destTransform:n=[1,0,0,1,0,0],backdropOffset:r=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:h="none",knockoutAlpha:c=1}=s,{width:d,height:u}=e,f=this.#g(e,a,c),p=t.globalCompositeOperation;if(t.save(),t.setTransform(...n),t.globalAlpha=1,ot.isCanvasFilterSupported)t.filter="none";if(t.globalCompositeOperation="destination-out",t.drawImage(f.canvas,0,0),i){let[g,m]=r,v=this.#m(o,"knockoutBackdropEntry",d,u),y=v.context;if(y.drawImage(i,g,m,d,u,0,0,d,u),y.globalCompositeOperation="destination-in",y.drawImage(f.canvas,0,0),y.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(v.canvas,0,0),!o)this.canvasFactory.destroy(v)}if(t.globalCompositeOperation=p,t.globalAlpha=l,ot.isCanvasFilterSupported)t.filter=h??"none";if(t.drawImage(e,0,0),t.restore(),!a)this.canvasFactory.destroy(f)}#p(t=1){if(this.#e===0||this.#s>0||!this.contentVisible)return!1;this.#s++,this.#o=t;let e=this.#u.at(-1),{canvas:s}=this.ctx,i=this.#m(e,"knockoutTempEntry",s.width,s.height);this.#i=i;let n=i.context;if(n.save(),n.setTransform(this.ctx.getTransform()),le(this.ctx,n),this.#r=n.globalCompositeOperation,n.globalCompositeOperation="source-over",rn(n,this.ctx),this.#h=e,this.#n=this.ctx,this.#a=this.suspendedCtx,this.ctx=n,this.inSMaskMode)this.suspendedCtx=n;return!0}#v(t){if(!t)return;let e=this.#i,s=this.#n,i=this.#a,n=e.context;if(this.#i=null,this.#n=null,this.#a=null,this.inSMaskMode&&this.suspendedCtx===n&&this.ctx!==n)this.endSMaskMode();if(this.inSMaskMode)this.suspendedCtx=i;this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#r,this.#r=null,le(this.ctx,s),this.ctx=s;let r=this.#h;this.#h=null;let a=this.#o;this.#o=1;try{this.#c(i??s,e.canvas,{backdropCanvas:r?.backdropCtx?.canvas??null,backdropOffset:r?.backdropCtx?[r.offsetX,r.offsetY]:[0,0],reuseMaskEntry:r?.knockoutMaskEntry??null,poolMeta:r,knockoutAlpha:a})}finally{if(n.restore(),this.#s--,!r)this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,s=this.suspendedCtx,i=this.#s>0&&s===this.ctx;if(this.composeSMask(i?null:s,e,this.ctx,t),i)return;this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){let n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;if(a===0||o===0)return;let l=this.smaskPreparedEntry;if(l){let h=n,c=r,d=a,u=o,f=this.smaskPreparedOOBAlpha,p=f!==null;if(p){h=Math.max(n,e.offsetX),c=Math.max(r,e.offsetY);let g=Math.min(n+a,e.offsetX+e.canvas.width),m=Math.min(r+o,e.offsetY+e.canvas.height);d=g-h,u=m-c}if(d>0&&u>0){let g=h-this.smaskPreparedOffsetX,m=c-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);let v=new Path2D;v.rect(h,c,d,u),s.clip(v),s.globalCompositeOperation="destination-in",s.drawImage(l.canvas,g,m,d,u,h,c,d,u),s.restore()}if(p&&f<255)this._applySMaskOOBAlpha(s,n,r,a,o,h,c,h+d,c+u,f)}else this.genericComposeSMask(e,s,a,o,n,r);if(!t)return;t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,n,r,a,o,n,r,a,o),t.restore()}_applySMaskOOBAlpha(t,e,s,i,n,r,a,o,l,h){let c=r<o&&a<l;if(c&&r===e&&a===s&&o===e+i&&l===s+n)return;let d=new Path2D;if(d.rect(e,s,i,n),c)d.rect(r,a,o-r,l-a);t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(d,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,n),t.restore()}genericComposeSMask(t,e,s,i,n,r){let{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let h=new Path2D;h.rect(n,r,s,i),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,n-o,r-l,s,i,n,r,s,i),e.restore()}save(t){if(this.inSMaskMode)le(this.ctx,this.suspendedCtx);this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){if(this.inSMaskMode)this.endSMaskMode();return}if(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode)le(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform());this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,n,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[n]=s;if(!i){if(n||=s[0]=new Path2D,e!==Qt.stroke&&e!==Qt.closeStroke)this.current.tilingPatternDims=null;this[e](t,n);return}if(this.dependencyTracker!==null){let a=e===Qt.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}if(!(n instanceof Path2D))n=s[0]=xn(n);L.axialAlignedBoundingBox(i,dt(this.ctx),this.current.minMax);let r=this.current.tilingPatternDims;if(r&&e!==Qt.stroke&&e!==Qt.closeStroke&&this.current.fillColor instanceof He){let a=L.intersect(this.current.clipBox,this.current.minMax);if(!a)this.current.tilingPatternDims=null;else this.current.fillColor.updatePatternDims(a,r)}this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){let i=s&&this.#p(this.current.strokeAlpha),n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r==="object"&&r?.getPattern){let a=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,Yt(n),Ct.STROKE,t),a){let o=new Path2D;o.addPath(e,n.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);if(this.dependencyTracker?.recordDependencies(t,Ht.stroke),s)this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ct.STROKE,dt(this.ctx)));n.globalAlpha=this.current.fillAlpha,this.#v(i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){let i=s&&this.#p(this.current.fillAlpha),n=this.ctx,r=this.current.fillColor,a=this.current.patternFill,o=!1,l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Ht.fill),a){let h=this.current.tilingPatternDims,c=h&&r.canSkipPatternCanvas(h);if(c){if(r.drawPattern(this,e,this.pendingEOFill,c,t),this.pendingEOFill=!1,s)this.consumePath(t,e,l);this.current.tilingPatternDims=null,this.#v(i);return}let d=r.isModifyingCurrentTransform()?n.getTransform():null;if(this.dependencyTracker?.save(t),n.save(),n.fillStyle=r.getPattern(n,this,Yt(n),Ct.FILL,t),d){let u=new Path2D;u.addPath(e,n.getTransform().invertSelf().multiplySelf(d)),e=u}o=!0}if(this.contentVisible&&l!==null)if(this.pendingEOFill)n.fill(e,"evenodd"),this.pendingEOFill=!1;else n.fill(e);if(o)n.restore(),this.dependencyTracker?.restore(t);if(s)this.consumePath(t,e,l);this.#v(i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){let s=this.#p(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#v(s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){let s=this.#p(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Ht.rawFillPath).recordOperation(t),this.#v(s)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Ba}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=hn}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;if(e!==void 0)i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t);i.recordCloseMarker(t)}if(e!==void 0){let i=new Path2D,n=s.getTransform().invertSelf();for(let{transform:r,x:a,y:o,fontSize:l,path:h}of e){if(!h)continue;i.addPath(h,new DOMMatrix(r).preMultiplySelf(n).translate(a,o).scale(l,-l))}s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let i=this.commonObjs.get(e),n=this.current;if(!i)throw Error(`Can't find font for ${e}`);if(n.fontMatrix=i.fontMatrix||Ys,n.fontMatrix[0]===0||n.fontMatrix[3]===0)z("Invalid font matrix for font "+e);if(s<0)s=-s,n.fontDirection=-1;else n.fontDirection=1;if(this.current.font=i,this.current.fontSize=s,i.isType3Font)return;let r=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${r}", ${i.fallbackName}`,o="normal";if(i.black)o="900";else if(i.bold)o="bold";let l=i.italic?"italic":"normal",h=ut(s,Da,ka);this.current.fontSizeScale=s/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#y(t,e,s){let i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,n,r){let a=this.ctx,o=this.current,{font:l,textRenderingMode:h}=o,c=o.fontSize/o.fontSizeScale,d=h&bt.FILL_STROKE_MASK,u=!!(h&bt.ADD_TO_PATH_FLAG),f=o.patternFill&&!l.missingFile,p=o.patternStroke&&!l.missingFile,g;if((l.disableFontFace||u||f||p)&&!l.missingFile)g=l.getPathGenerator(this.commonObjs,e);if(g&&(l.disableFontFace||f||p)){a.save(),a.translate(s,i),a.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,a,l);let m;if(d===bt.FILL||d===bt.FILL_STROKE)if(n){m=a.getTransform(),a.setTransform(...n);let v=this.#y(g,m,n);a.fill(v)}else a.fill(g);if(d===bt.STROKE||d===bt.FILL_STROKE)if(r){m||=a.getTransform(),a.setTransform(...r);let{a:v,b:y,c:S,d:A}=m,b=L.inverseTransform(r),w=L.transform([v,y,S,A,0,0],b);L.singularValueDecompose2dScale(w,Bt),a.lineWidth*=Math.max(Bt[0],Bt[1])/c,a.stroke(this.#y(g,m,r))}else a.lineWidth/=c,a.stroke(g);a.restore()}else{if(d===bt.FILL||d===bt.FILL_STROKE)a.fillText(e,s,i),this.dependencyTracker?.recordCharacterBBox(t,a,l,c,s,i,()=>a.measureText(e));if(d===bt.STROKE||d===bt.FILL_STROKE){if(this.dependencyTracker)this.dependencyTracker?.recordCharacterBBox(t,a,l,c,s,i,()=>a.measureText(e)).recordDependencies(t,Ht.stroke);a.strokeText(e,s,i)}}if(u)(this.pendingTextPaths||=[]).push({transform:dt(a),x:s,y:i,fontSize:c,path:g}),this.dependencyTracker?.recordCharacterBBox(t,a,l,c,s,i)}get isFontSubpixelAAEnabled(){let t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);let s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let n=3;n<s.length;n+=4)if(s[n]>0&&s[n]<255){i=!0;break}return j(this,"isFontSubpixelAAEnabled",i)}showText(t,e){if(this.dependencyTracker){if(this.dependencyTracker.recordDependencies(t,Ht.showText).resetBBox(t),this.current.textRenderingMode&bt.ADD_TO_PATH_FLAG)this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies()}let s=this.current,i=s.font;if(i.isType3Font){let C=this.#p(s.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#v(C);return}let n=s.fontSize;if(n===0){this.dependencyTracker?.recordOperation(t);return}let r=this.#p(s.fillAlpha),a=this.ctx,{fontSizeScale:o,charSpacing:l,wordSpacing:h,fontDirection:c}=s,d=s.textHScale*c,u=e.length,f=i.vertical,p=f?1:-1,g=i.defaultVMetrics,m=n*s.fontMatrix[0],v=s.textRenderingMode===bt.FILL&&!i.disableFontFace&&!s.patternFill;if(a.save(),s.textMatrix)a.transform(...s.textMatrix);if(a.translate(s.x,s.y+s.textRise),c>0)a.scale(d,-1);else a.scale(d,1);let y,S,A=s.textRenderingMode&bt.FILL_STROKE_MASK,b=A===bt.FILL||A===bt.FILL_STROKE,w=A===bt.STROKE||A===bt.FILL_STROKE,{lineWidth:x,textMatrixScale:T}=s;if(T===0||x===0){if(w)x=this.getSinglePixelWidth()}else x/=T;if(o!==1)a.scale(o,o),x/=o;if(a.lineWidth=x,b&&s.patternFill){a.save();let C=s.fillColor.getPattern(a,this,Yt(a),Ct.FILL,t);y=dt(a),a.restore(),a.fillStyle=C}if(w&&s.patternStroke){a.save();let C=s.strokeColor.getPattern(a,this,Yt(a),Ct.STROKE,t);S=dt(a),a.restore(),a.strokeStyle=C}if(i.isInvalidPDFjsFont){let C=[],O=0;for(let k of e)C.push(k.unicode),O+=k.width;let D=C.join("");if(a.fillText(D,0,0),this.dependencyTracker!==null){let k=a.measureText(D);this.dependencyTracker.recordBBox(t,this.ctx,-k.actualBoundingBoxLeft,k.actualBoundingBoxRight,-k.actualBoundingBoxAscent,k.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=O*m*d,a.restore(),this.compose(),this.#v(r);return}let E=0,I;for(I=0;I<u;++I){let C=e[I];if(typeof C==="number"){E+=p*C*n/1000;continue}let O=!1,D=(C.isSpace?h:0)+l,{fontChar:k,accent:R}=C,M,_,U=C.width;if(f){let rt=C.vmetric||g,J=-(C.vmetric?rt[1]:U*0.5)*m,et=rt[2]*m;U=rt?-rt[0]:U,M=J/o,_=(E+et)/o}else M=E/o,_=0;let G;if(i.remeasure&&U>0){G=a.measureText(k);let rt=G.width*1000/n*o;if(U<rt&&this.isFontSubpixelAAEnabled){let J=U/rt;O=!0,a.save(),a.scale(J,1),M/=J}else if(U!==rt)M+=(U-rt)/2000*n/o}if(this.contentVisible&&(C.isInFont||i.missingFile)){if(v&&!R)a.fillText(k,M,_),this.dependencyTracker?.recordCharacterBBox(t,a,G?{bbox:null}:i,n/o,M,_,()=>G??a.measureText(k));else if(this.paintChar(t,k,M,_,y,S),R){let rt=M+n*R.offset.x/o,J=_-n*R.offset.y/o;this.paintChar(t,R.fontChar,rt,J,y,S)}}let it=f?U*m-D*c:U*m+D*c;if(E+=it,O)a.restore()}if(f)s.y-=E;else s.x+=E*d;a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#v(r)}showType3Text(t,e){let s=this.ctx,i=this.current,{font:n,fontSize:r,fontDirection:a}=i,o=n.vertical?1:-1,{charSpacing:l,wordSpacing:h}=i,c=i.textHScale*a,d=i.fontMatrix||Ys,u=e.length,f=i.textRenderingMode===bt.INVISIBLE,p,g,m,v;if(f||r===0)return;if(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix)s.transform(...i.textMatrix);s.translate(i.x,i.y+i.textRise),s.scale(c,a);let y=this.dependencyTracker;this.dependencyTracker=y?new Ge(y,t):null;for(p=0;p<u;++p){if(g=e[p],typeof g==="number"){v=o*g*r/1000,this.ctx.translate(v,0),i.x+=v*c;continue}let S=(g.isSpace?h:0)+l,A=n.charProcOperatorList.get(g.operatorListId);if(!A)z(`Type3 character "${g.operatorListId}" is not available.`);else if(this.contentVisible){if(this.save(),A.fnArray[0]===Qt.setCharWidth)i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1;s.scale(r,r),s.transform(...d),this.executeOperatorList(A),this.restore()}let b=[g.width,0];L.applyTransform(b,d),m=b[0]*r+S,s.translate(m,0),i.x+=m*c}if(s.restore(),y)this.dependencyTracker=y}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,n,r,a){let o=new Path2D;o.rect(i,n,r-i,a-n),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,i,r,n,a).recordClipBox(t,this.ctx,i,r,n,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){let i=this.baseTransform||dt(this.ctx),n={createCanvasGraphics:(r,a)=>new fe(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ge(this.dependencyTracker,a,!0):null)};s=new He(e,this.ctx,n,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);let s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof He?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){let i=this.cachedPatterns.getOrInsertComputed(e,()=>Ra(this.getObject(t,e)));if(s)i.matrix=s;return i}shadingFill(t,e){if(!this.contentVisible)return;let s=this.#p(this.current.fillAlpha),i=this.ctx;this.save(t);let n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,Yt(i),Ct.SHADING,t);let r=Yt(i);if(r){let{width:a,height:o}=i.canvas,l=de.slice();L.axialAlignedBoundingBox([0,0,a,o],r,l);let[h,c,d,u]=l;this.ctx.fillRect(h,c,d-h,u-c)}else this.ctx.fillRect(-10000000000,-10000000000,20000000000,20000000000);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ht.transform).recordDependencies(t,Ht.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#v(s)}beginInlineImage(){st("Should not call beginInlineImage")}beginImageData(){st("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(!this.contentVisible)return;if(this.save(t),this.baseTransformStack.push(this.baseTransform),e)this.transform(t,...e);if(this.baseTransform=dt(this.ctx),s){L.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);let[i,n,r,a]=s,o=new Path2D;o.rect(i,n,r-i,a-n),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,r,n,a),this.endPath(t)}}paintFormXObjectEnd(t){if(!this.contentVisible)return;this.restore(t),this.baseTransform=this.baseTransformStack.pop()}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);let{inSMaskMode:s}=this;if(s)this.endSMaskMode(),this.current.activeSMask=null;let i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&this.#e===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let S=new Path2D,[A,b,w,x]=e.bbox;if(S.rect(A,b,w-A,x-b),e.matrix){let T=new Path2D;T.addPath(S,new DOMMatrix(e.matrix)),S=T}i.clip(S)}this.groupStack.push(null),this.#u.push(null),this.groupLevel++;return}if(!e.isolated&&!e.knockout&&this.#e===0)Ts("TODO: Fully support non-isolated non-knockout groups.");let n=dt(i);if(e.matrix)i.transform(...e.matrix);let r=[0,0,i.canvas.width,i.canvas.height],a;if(e.bbox)a=de.slice(),L.axialAlignedBoundingBox(e.bbox,dt(i),a),a=L.intersect(a,r)||[0,0,0,0];else a=r;let o=Math.floor(a[0]),l=Math.floor(a[1]),h=Math.max(Math.ceil(a[2])-o,1),c=Math.max(Math.ceil(a[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d=this.canvasFactory.create(h,c);if(e.smask)this.smaskGroupCanvases.push(d);let u=d.context,f=e.knockout&&!e.isolated?i:null,p=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#e>0,g=e.knockout?this.canvasFactory.create(h,c):null,m=this.#e;if(e.knockout)this.#e++;else this.#e=0;u.translate(-o,-l),u.transform(...n);let v=!e.isolated&&!e.smask&&e.needsIsolation,y=v&&!s&&m===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(v&&(s||y))u.save(),u.setTransform(1,0,0,1,0,0),u.drawImage(i.canvas,-o,-l),u.restore();if(e.bbox){let S=new Path2D,[A,b,w,x]=e.bbox;if(S.rect(A,b,w-A,x-b),e.matrix){let T=new Path2D;T.addPath(S,new DOMMatrix(e.matrix)),S=T}u.clip(S)}if(e.smask)this.smaskStack.push({canvas:d.canvas,context:u,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null});if(!e.smask||this.dependencyTracker)i.setTransform(1,0,0,1,0,0),i.translate(o,l),i.save();le(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),this.#u.push({backdropCtx:f,savedKnockoutLevel:m,offsetX:o,offsetY:l,hasInnerBackdrop:p,replaceBackdrop:y,knockoutMaskEntry:g,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let s=this.ctx,i=this.groupStack.pop(),n=this.#u.pop();if(n)this.#e=n.savedKnockoutLevel;if(i===null){this.restore(t);return}if(e.isGray)this.#b(s);if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask){if(this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker){if(this.ctx.restore(),this.inSMaskMode)this.ctx.setTransform(this.suspendedCtx.getTransform())}this.#A(n)}else{this.ctx.restore();let r=dt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...r);let a=de.slice();L.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],r,a);let o=this.#u.at(-1);if(this.#e>0)if(n.hasInnerBackdrop){let{width:l,height:h}=s.canvas,c=this.canvasFactory.create(l,h),d=c.context;d.drawImage(i.canvas,n.offsetX,n.offsetY,l,h,0,0,l,h),d.globalCompositeOperation="source-over",d.drawImage(s.canvas,0,0);let u=this.#g(s.canvas);d.globalCompositeOperation="destination-in",d.drawImage(u.canvas,0,0);let f=this.ctx.globalCompositeOperation,p=this.ctx.globalAlpha,g=this.ctx.filter;if(this.ctx.save(),this.ctx.setTransform(...r),this.ctx.globalAlpha=1,ot.isCanvasFilterSupported)this.ctx.filter="none";if(this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(u.canvas,0,0),this.ctx.globalCompositeOperation=f,this.ctx.globalAlpha=p,ot.isCanvasFilterSupported)this.ctx.filter=g??"none";this.ctx.drawImage(c.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(u),this.canvasFactory.destroy(c)}else{let l=o?.backdropCtx??null;this.#c(this.ctx,s.canvas,{backdropCanvas:l?.canvas??null,destTransform:r,backdropOffset:l?[o.offsetX+n.offsetX,o.offsetY+n.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(n.replaceBackdrop){let l=new Path2D;l.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(l),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),this.#A(n),this.compose(a)}}#b(t){let{canvas:e}=t,{width:s,height:i}=e;if(ot.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}let n=t.getImageData(0,0,s,i),{data:r}=n;for(let a=0,o=r.length;a<o;a+=4){let l=r[a]*0.2126+r[a+1]*0.7152+r[a+2]*0.0722+0.5|0;r[a]=r[a+1]=r[a+2]=l}t.putImageData(n,0,0)}#A(t){if(!t)return;if(t.knockoutMaskEntry)this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null;if(t.knockoutTempEntry)this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null;if(t.knockoutBackdropEntry)this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null}beginAnnotation(t,e,s,i,n,r,a){if(this.#d(),ns(this.ctx),this.ctx.save(),this.save(t),this.baseTransform)this.ctx.setTransform(...this.baseTransform);if(s){let o=s[2]-s[0],l=s[3]-s[1];if(r&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],L.singularValueDecompose2dScale(dt(this.ctx),Bt);let{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),d=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);let{canvas:u,context:f}=this.annotationCanvas;if(a){let p=this.annotationCanvasMap.getOrInsertComputed(e,Ie);u.setAttribute("data-canvas-name",a);let g=p.findIndex((m)=>m.getAttribute("data-canvas-name")===a);if(g===-1)p.push(u);else p[g]=u}else this.annotationCanvasMap.set(e,u);this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(Bt[0],0,0,-Bt[1],0,l*Bt[1]),ns(this.ctx)}else{ns(this.ctx),this.endPath(t);let h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new ni(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...n),this.baseTransform=dt(this.ctx)}endAnnotation(t){if(this.annotationCanvas)this.ctx.restore(),this.#f(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas;this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let s=e.count;e=this.getObject(t,e.data,e),e.count=s;let i=this.#p(this.current.fillAlpha),n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;if(n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(),r.canvasEntry)this.canvasFactory.destroy(r.canvasEntry);this.compose(),this.#v(i)}paintImageMaskXObjectRepeat(t,e,s,i=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.#p(this.current.fillAlpha),l=this.ctx;l.save();let h=dt(l);l.transform(s,i,n,r,0,0);let c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let d=0,u=a.length;d<u;d+=2){let f=L.transform(h,[s,i,n,r,a[d],a[d+1]]);l.drawImage(c.canvas,f[4],f[5]),this.dependencyTracker?.recordBBox(t,this.ctx,f[4],f[4]+c.canvas.width,f[5],f[5]+c.canvas.height)}if(l.restore(),c.canvasEntry)this.canvasFactory.destroy(c.canvasEntry);this.compose(),this.dependencyTracker?.recordOperation(t),this.#v(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let s=this.#p(this.current.fillAlpha),i=this.ctx,n=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Ht.transformAndFill);for(let a of e){let{data:o,width:l,height:h,transform:c}=a,d=this.canvasFactory.create(l,h),u=d.context;u.save();let f=this.getObject(t,o,a);on(u,f),u.globalCompositeOperation="source-in",u.fillStyle=r?n.getPattern(u,this,Yt(i),Ct.FILL,t):n,u.fillRect(0,0,l,h),u.restore(),i.save(),i.transform(...c),i.scale(1,-1),is(i,d.canvas,0,0,l,h,0,-1,1,1),this.canvasFactory.destroy(d),this.dependencyTracker?.recordBBox(t,i,0,l,0,h),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#v(s)}paintImageXObject(t,e){if(!this.contentVisible)return;let s=this.getObject(t,e);if(!s){z("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,n){if(!this.contentVisible)return;let r=this.getObject(t,e);if(!r){z("Dependent image isn't ready yet");return}let{width:a,height:o}=r,l=[];for(let h=0,c=n.length;h<c;h+=2)l.push({transform:[s,0,0,i,n[h],n[h+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){if(this.current.transferMaps!=="none")t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none";return t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};let{bitmap:e,width:s,height:i}=t,n=this.canvasFactory.create(s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",{img:n.canvas,canvasEntry:n}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;let{width:s,height:i}=e,n=this.#p(this.current.fillAlpha),r=this.ctx;this.save(t);let{filter:a}=r;if(a!=="none"&&a!=="")r.filter="none";r.scale(1/s,-1/i);let o,l=null;if(e.bitmap){let c=this.applyTransferMapsToBitmap(e);o=c.img,l=c.canvasEntry}else{let c=this.canvasFactory.create(s,i);an(c.context,e),o=this.applyTransferMapsToCanvas(c.context),l=c}let h=this._scaleImage(o,Yt(r));if(r.imageSmoothingEnabled=ln(dt(r),e.interpolate),this.dependencyTracker)this.dependencyTracker.resetBBox(t).recordBBox(t,r,0,s,-i,0).recordDependencies(t,Ht.imageXObject).recordOperation(t),this.imagesTracker?.record(r,s,i,this.dependencyTracker.clipBox);if(is(r,h.img,0,0,h.paintWidth,h.paintHeight,0,-i,s,i),h.tmpCanvas)this.canvasFactory.destroy(h.tmpCanvas);if(l)this.canvasFactory.destroy(l);this.compose(),this.restore(t),this.#v(n)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;let i=this.#p(this.current.fillAlpha),n=this.ctx,r,a=null;if(e.bitmap)r=e.bitmap;else{let{width:o,height:l}=e,h=this.canvasFactory.create(o,l);an(h.context,e),r=this.applyTransferMapsToCanvas(h.context),a=h}this.dependencyTracker?.resetBBox(t);for(let o of s)n.save(),n.transform(...o.transform),n.scale(1,-1),is(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();if(a)this.canvasFactory.destroy(a);this.dependencyTracker?.recordOperation(t),this.compose(),this.#v(i)}paintSolidColorImageMask(t){if(!this.contentVisible)return;let e=this.#p(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ht.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#v(e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){if(this.dependencyTracker?.beginMarkedContent(t),e==="OC")this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)});else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){let i=this.current.isEmptyClip();if(this.pendingClip)this.current.updateClipFromPath();if(!this.pendingClip)this.compose(s);let n=this.ctx;if(this.pendingClip){if(!i)if(this.pendingClip===hn)n.clip(e,"evenodd");else n.clip(e);this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)}else this.dependencyTracker?.recordOperation(t);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=dt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform(),r,a;if(s===0&&i===0){let o=Math.abs(e),l=Math.abs(n);if(o===l)if(t===0)r=a=1/o;else{let h=o*t;r=a=h<1?1/h:1}else if(t===0)r=1/o,a=1/l;else{let h=o*t,c=l*t;r=h<1?1/h:1,a=c<1?1/c:1}}else{let o=Math.abs(e*n-s*i),l=Math.hypot(e,s),h=Math.hypot(i,n);if(t===0)r=h/o,a=l/o;else{let c=t*o;r=h>c?h/c:1,a=l>c?l/c:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:s,current:{lineWidth:i}}=this,[n,r]=this.getScaleForStroking();if(n===r){s.lineWidth=(i||1)*n,s.stroke(t);return}let a=fe.#t??=new DOMMatrix,o=s.getLineDash();if(e)s.save();s.scale(n,r),a.a=1/n,a.d=1/r;let l=new Path2D;if(l.addPath(t,a),o.length>0){let h=Math.max(n,r);s.setLineDash(o.map((c)=>c/h)),s.lineDashOffset/=h}if(s.lineWidth=i||1,s.stroke(l),e)s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in Qt)if(fe.prototype[t]!==void 0)fe.prototype[Qt[t]]=fe.prototype[t];class Je{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,s){this._source=t,this.#t=e,this.#e=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return mt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new this.#e(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){this._fullReader?.cancel(t);for(let e of new Set(this._rangeReaders))e.cancel(t)}}class Qe{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){st("Abstract method `read` called")}cancel(t){st("Abstract method `cancel` called")}}class Ze{_stream=null;constructor(t,e,s){this._stream=t}async read(){st("Abstract method `read` called")}cancel(t){st("Abstract method `cancel` called")}}function _a(t){let e=!0,s=i("filename\\*","i").exec(t);if(s){s=s[1];let c=o(s);return c=unescape(c),c=l(c),c=h(c),r(c)}if(s=a(t),s){let c=h(s);return r(c)}if(s=i("filename","i").exec(t),s){s=s[1];let c=o(s);return c=h(c),r(c)}function i(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let u=new TextDecoder(c,{fatal:!0}),f=Cs(d);d=u.decode(f),e=!1}catch{}}return d}function r(c){if(e&&/[\x80-\xff]/.test(c)){if(c=n("utf-8",c),e)c=n("iso-8859-1",c)}return c}function a(c){let d=[],u,f=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((u=f.exec(c))!==null){let[,g,m,v]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,v]}let p=[];for(let g=0;g<d.length;++g){if(!(g in d))break;let[m,v]=d[g];if(v=o(v),m){if(v=unescape(v),g===0)v=l(v)}p.push(v)}return p.join("")}function o(c){if(c.startsWith('"')){let d=c.slice(1).split("\\\"");for(let u=0;u<d.length;++u){let f=d[u].indexOf('"');if(f!==-1)d[u]=d[u].slice(0,f),d.length=u+1;d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){let d=c.indexOf("'");if(d===-1)return c;let u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return n(u,p)}function h(c){if(!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c))return c;return c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-f]{2})/gi,function(g,m){return String.fromCharCode(parseInt(m,16))}),n(u,p);try{p=atob(p)}catch{}return n(u,p)})}return""}function Zn(t,e){let s=new Headers;if(!t||!e||typeof e!=="object")return s;for(let i in e){let n=e[i];if(n!==void 0)s.append(i,n)}return s}function Ha(t){let e=t.length;while(e>0&&t[e-1]!==" "&&/\s/.test(t[e-1]))e--;return t.slice(0,e)}function Ds(t){return URL.parse(t)?.origin??null}function qn({responseHeaders:t,isHttp:e,rangeChunkSize:s,disableRange:i}){let n={contentLength:0,isRangeSupported:!1},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.contentLength=r,r<=2*s)return n;if(i||!e)return n;if(t.get("Accept-Ranges")!=="bytes")return n;if((t.get("Content-Encoding")||"identity")==="identity")n.isRangeSupported=!0;return n}function tr(t){let e=t.get("Content-Disposition");if(e){let s=_a(e);if(s.includes("%"))try{s=decodeURIComponent(s)}catch{}if(hi(s))return s}return null}function ks(t,e){return new Ue(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,t===404||t===0&&e.protocol==="file:")}function er(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function sr(t,e,s,i){return fetch(t,{method:"GET",headers:e,signal:i.signal,mode:"cors",credentials:s?"include":"same-origin",redirect:"follow"})}function ir(t,e){if(t!==200&&t!==206)throw ks(t,e)}function Ls(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error(`getArrayBuffer - unexpected data: ${t}`)}class nr extends Je{_responseOrigin=null;constructor(t){super(t,rr,ar);let{httpHeaders:e,url:s}=t;mt(/https?:/.test(s.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Zn(!0,e)}}class rr extends Qe{_abortController=new AbortController;_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,rangeChunkSize:i,url:n,withCredentials:r}=t._source;this._isStreamingSupported=!s;let a=new Headers(t.headers);sr(n,a,r,this._abortController).then((o)=>{t._responseOrigin=Ds(o.url),ir(o.status,n),this._reader=o.body.getReader();let l=o.headers,{contentLength:h,isRangeSupported:c}=qn({responseHeaders:l,isHttp:!0,rangeChunkSize:i,disableRange:e});if(this._contentLength=h,this._isRangeSupported=c,this._filename=tr(l),!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new se("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return this._loaded+=t.byteLength,this._callOnProgress(),{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ar extends Ze{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`),sr(i,r,n,this._abortController).then((a)=>{let o=Ds(a.url);er(o,t._responseOrigin),ir(a.status,i),this._reader=a.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function cn(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function Ns(){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class or extends Je{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,lr,hr);let{pdfDataRangeTransport:e}=t,{initialData:s,progressiveDone:i}=e;if(s?.length>0){let r=cn(s);this._queuedChunks.push(r)}this._progressiveDone=i;let n=(r)=>{switch(r.type){case"range":case"progressiveRead":this.#t(r.begin,r.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};e.transportReady(n)}#t(t,e){let s=cn(e);if(t===void 0)if(this._fullReader)this._fullReader._enqueue(s);else this._queuedChunks.push(s);else{let i=this._rangeReaders.keys().find((n)=>n._begin===t);mt(i,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),i._enqueue(s)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let s=super.getRangeReader(t,e);if(s)s.onDone=()=>this._rangeReaders.delete(s),this._source.pdfDataRangeTransport.requestDataRange(t,e);return s}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class lr extends Qe{#t=Ns.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);let{pdfDataRangeTransport:e,disableRange:s,disableStream:i}=t._source,{length:n,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(let o of this._queuedChunks)this._loaded+=o.byteLength;if(this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!i,this._isRangeSupported=!s,hi(r))this._filename=r;this._headersCapability.resolve();let a=this._loaded;Promise.resolve().then(()=>{if(a>0&&this._loaded===a)this._callOnProgress()})}_enqueue(t){if(this._done)return;if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength,this._callOnProgress()}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){if(this._done||=!0,this._queuedChunks.length===0)this.#t()}}class hr extends Ze{#t=Ns.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,s){super(t,e,s);this._begin=e}_enqueue(t){if(this._done)return;if(this._requests.length===0)this._queuedChunk=t;else this._requests.shift().resolve({value:t,done:!1}),this.#t();this._done=!0,this.onDone?.()}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}}var Xs=200,dn=206;function Ua(t){return typeof t!=="string"?t:Cs(t).buffer}class cr extends Je{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,dr,ur);let{httpHeaders:e,url:s}=t;this.url=s,this.isHttp=/https?:/.test(s.protocol),this.headers=Zn(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,s={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,s),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(let[i,n]of this.headers)e.setRequestHeader(i,n);if(this.isHttp&&"begin"in t&&"end"in t)e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.validateStatus=(i)=>i===dn||i===Xs;else s.validateStatus=(i)=>i===Xs;return e.responseType="arraybuffer",mt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#s.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#s(t,e){let s=this.#t.get(t);if(!s)return;if(t.readyState>=2&&s.onHeadersReceived)s.onHeadersReceived(),delete s.onHeadersReceived;if(t.readyState!==4)return;if(!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){s.onError(t.status);return}let i=t.status||Xs;if(!s.validateStatus(i)){s.onError(t.status);return}let n=Ua(t.response);if(i===dn){let r=t.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(r))s.onDone(n);else z('Missing or invalid "Content-Range" header.'),s.onError(0)}else if(n)s.onDone(n);else s.onError(t.status)}_abortRequest(t){if(this.#t.has(t))this.#t.delete(t),t.abort()}getRangeReader(t,e){let s=super.getRangeReader(t,e);if(s)s.onClosed=()=>this._rangeReaders.delete(s);return s}}class dr extends Qe{#t=Ns.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t);this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:this.#n.bind(this)})}#e(){let t=this._stream,{disableRange:e,rangeChunkSize:s}=t._source,i=this._fullRequestXhr;t._responseOrigin=Ds(i.responseURL);let n=i.getAllResponseHeaders(),r=new Headers(n?Ha(n.trimStart()).split(/[\r\n]+/).map((l)=>{let[h,...c]=l.split(": ");return[h,c.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=qn({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:s,disableRange:e});if(this._contentLength=a,this._isRangeSupported=o,this._filename=tr(r),this._isRangeSupported)t._abortRequest(i);this._headersCapability.resolve()}#s(t){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._cachedChunks.push(t);if(this._done=!0,this._cachedChunks.length===0)this.#t()}#i(t){this._storedError=ks(t,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#n(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class ur extends Ze{#t=Ns.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,s){super(t,e,s);this._requestXhr=t._request({begin:e,end:s,onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:null})}#e(){let t=Ds(this._requestXhr?.responseURL);try{er(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#i(0)}}#s(t){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunk=t;this._done=!0,this.#t(),this.onClosed?.()}#i(t){this._storedError??=ks(t,this._stream.url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function fr(t,e=null){let s=process.getBuiltinModule("fs"),{Readable:i}=process.getBuiltinModule("stream"),n=s.createReadStream(t,e);return i.toWeb(n)}class pr extends Je{constructor(t){super(t,gr,mr);let{url:e}=t;mt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class gr extends Qe{_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,rangeChunkSize:i,url:n}=t._source;this._isStreamingSupported=!s,process.getBuiltinModule("fs/promises").lstat(n).then((a)=>{let o=fr(n);this._reader=o.getReader();let{size:l}=a;if(this._contentLength=l,this._isRangeSupported=!e&&l>2*i,!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new se("Streaming is disabled."));this._headersCapability.resolve()}).catch((a)=>{if(a.code==="ENOENT")a=ks(0,n);this._headersCapability.reject(a)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return this._loaded+=t.byteLength,this._callOnProgress(),{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class mr extends Ze{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i}=t._source;try{let n=fr(i,{start:e,end:s-1});this._reader=n.getReader(),this._readCapability.resolve()}catch(n){this._readCapability.reject(n)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t)}}function ja(t){return Be(t)?nr:Nt?pr:cr}class re{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!=="string")throw Error("Invalid `workerSrc` type.");this.#e=t}}class vr{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}var he=Symbol("INTERNAL");class yr{#t=!1;#e=!1;#s=!1;#i=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){this.#t=!!(t&Lt.DISPLAY),this.#e=!!(t&Lt.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(this.#s)return this.#i;if(!this.#i)return!1;let{print:t,view:e}=this.usage;if(this.#t)return e?.viewState!=="OFF";else if(this.#e)return t?.printState!=="OFF";return!0}_setVisible(t,e,s=!1){if(t!==he)st("Internal method `_setVisible` called.");this.#s=s,this.#i=e}get serializable(){return{userSet:this.#s,visible:this.#i}}}class vi{#t=null;#e=new Map;#s=null;#i=null;#n;creator=null;name=null;constructor(t,e=Lt.DISPLAY,s=null){if(this.#n=t,this.renderingIntent=e,t===null)return;this.name=t.name,this.creator=t.creator,this.#i=t.order;for(let i of t.groups)this.#e.set(i.id,new yr(e,i));if(s){if(s.size!==this.#e.size)st("Incorrect serialized groupState.");for(let[i,n]of s)this.#e.get(i)._setVisible(he,n.visible,n.userSet)}else{if(t.baseState==="OFF")for(let i of this.#e.values())i._setVisible(he,!1);for(let i of t.on)this.#e.get(i)._setVisible(he,!0);for(let i of t.off)this.#e.get(i)._setVisible(he,!1)}this.#s=this.getHash()}#a(t){let e=t.length;if(e<2)return!0;let s=t[0];for(let i=1;i<e;i++){let n=t[i],r;if(Array.isArray(n))r=this.#a(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return z(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Ts("Optional content group not defined."),!0;if(t.type==="OCG"){if(!this.#e.has(t.id))return z(`Optional content group not found: ${t.id}`),!0;return this.#e.get(t.id).visible}else if(t.type==="OCMD"){if(t.expression)return this.#a(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return z(`Unknown optional content policy ${t.policy}.`),!0}return z(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){let i=this.#e.get(t);if(!i){z(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length){for(let n of i.rbGroups)for(let r of n)if(r!==t)this.#e.get(r)?._setVisible(he,!1,!0)}i._setVisible(he,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(let i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}let n=this.#e.get(i);if(!n)continue;switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){if(!this.#e.size)return null;if(this.#i)return this.#i.slice();return[...this.#e.keys()]}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new ms;for(let[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}get serializable(){let t=new Map;for(let[e,s]of this.#e)t.set(e,s.serializable);return{data:this.#n,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new vi(t,e,s)}}class br{#t=null;#e=null;#s=0;#i=null;#n=null;get pagesNumber(){return this.#s}set pagesNumber(t){if(this.#s===t)return;this.#s=t,this.#t=null,this.#e=null}#a(){if(this.#t)return;let t=this.#s,e=this.#t=new Uint32Array(t);for(let s=0;s<t;s++)e[s]=s+1;this.#e=new Int32Array(e)}#r(){let t=new Map,e=this.#t;for(let s=0,i=this.#s;s<i;s++){let n=e[s],r=t.get(n);if(r)r.push(s+1);else t.set(n,[s+1])}return t}movePages(t,e,s){this.#a();let i=this.#t,n=e.length,r=new Uint32Array(n),a=0;for(let d=0;d<n;d++){let u=e[d]-1;if(r[d]=i[u],u<s)a++}let o=this.#s,l=o-n,h=new Int32Array(o),c=ut(s-a,0,l);for(let d=0,u=0;d<o;d++)if(!t.has(d+1))i[u]=i[d],h[u++]=d+1;if(i.copyWithin(c+n,c,l),i.set(r,c),h.copyWithin(c+n,c,l),h.set(e,c),this.#e=h,i.every((d,u)=>d===u+1))this.#t=null}deletePages(t){this.#a();let e=this.#t,s=this.#r();this.#n={pageNumberToId:e.slice(),pagesNumber:this.#s,prevPageNumbers:this.#e.slice()};let i=this.#s-t.length;this.#s=i;let n=this.#t=new Uint32Array(i);this.#e=new Int32Array(i);let r=0,a=0;for(let o of t){let l=o-1;if(l!==r)n.set(e.subarray(r,l),a),a+=l-r;r=l+1}if(r<e.length)n.set(e.subarray(r),a);this.#o(s,new Set(t))}cancelDelete(){if(this.#n)this.#t=this.#n.pageNumberToId,this.#s=this.#n.pagesNumber,this.#e=this.#n.prevPageNumbers,this.#n=null}cleanSavedData(){this.#n=null}copyPages(t){this.#a(),this.#i={pageNumbers:t,pageIds:t.map((e)=>this.#t[e-1])}}cancelCopy(){this.#i=null}pastePages(t){this.#a();let e=this.#t,s=this.#r(),{pageNumbers:i,pageIds:n}=this.#i,r=this.#s+i.length;this.#s=r;let a=this.#t=new Uint32Array(r);this.#e=new Int32Array(r),a.set(e.subarray(0,t),0),a.set(n,t),a.set(e.subarray(t),t+i.length),this.#o(s,null,t,i),this.#i=null}#o(t,e=null,s=-1,i=null){let n=this.#e,r=this.#t,a=s+(i?.length??0),o=new Map;for(let l=0,h=this.#s;l<h;l++){if(l>=s&&l<a){n[l]=-i[l-s];continue}let c=r[l],d=t.get(c),u=o.get(c)||0;if(e&&d)while(u<d.length&&e.has(d[u]))u++;n[l]=d?.[u],o.set(c,u+1)}}hasBeenAltered(){return this.#t!==null}#l(t=null){if(!this.#t)return null;let e=new Int32Array(this.#s).fill(-1),s=new Map;if(t)for(let i of t){let n=this.getPageId(i),r=s.get(n)??0;s.set(n,r+1),e[i-1]=r}else for(let i=0,n=this.#s;i<n;i++){let r=this.#t[i],a=s.get(r)??0;s.set(r,a+1),e[i]=a}return e}getPageMappingForSaving(t=null,e=this.#l()){t??=this.#r();let s=0;for(let n of t.values())s=Math.max(s,n.length);let i=Array(s);for(let n=0;n<s;n++)i[n]={document:null,pageIndices:[],includePages:[]};for(let[n,r]of t)for(let a=0,o=r.length;a<o;a++)i[a].includePages.push([n-1,r[a]-1]);for(let{includePages:n,pageIndices:r}of i){n.sort((a,o)=>a[0]-o[0]);for(let a=0,o=n.length;a<o;a++)r.push(n[a][1]),n[a]=n[a][0]}return{pageInfos:i,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);let e=new Map;for(let s=0,i=t.length;s<i;s++){let n=this.getPageId(t[s]);e.getOrInsertComputed(n,Ie).push(s+1)}return this.getPageMappingForSaving(e,this.#l(t))}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;let e=this.#t;for(let s=0,i=this.#s;s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}var we=Symbol("INITIAL_DATA"),un=()=>({...Promise.withResolvers(),data:we});class yi{#t=new Map;get(t,e=null){if(e){let i=this.#t.getOrInsertComputed(t,un);return i.promise.then(()=>e(i.data)),null}let s=this.#t.get(t);if(!s||s.data===we)throw Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){let e=this.#t.get(t);return!!e&&e.data!==we}delete(t){let e=this.#t.get(t);if(!e||e.data===we)return!1;return this.#t.delete(t),!0}resolve(t,e=null){let s=this.#t.getOrInsertComputed(t,un);if(s.data!==we)throw Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){for(let{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#t)if(e!==we)yield[t,e]}}var $a=1e5,fn=30;class Ot{#t=Promise.withResolvers();#e=null;#s=!1;#i=!!globalThis.FontInspector?.enabled;#n=null;#a=null;#r=null;#o=0;#l=0;#h=null;#u=null;#d=0;#f=0;#g=Object.create(null);#m=[];#c=null;#p=[];#v=new WeakMap;#y=null;static#b=new Map;static#A=new Map;static#x=new WeakMap;static#w=null;static#E=new Set;constructor({textContentSource:t,images:e,container:s,viewport:i}){if(t instanceof ReadableStream)this.#c=t;else if(typeof t==="object")this.#c=new ReadableStream({start(l){l.enqueue(t),l.close()}});else throw Error('No "textContentSource" parameter specified.');this.#e=this.#u=s,this.#n=e,this.#f=i.scale*Wt.pixelRatio,this.#d=i.rotation,this.#r={div:null,properties:null,ctx:null};let{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=i.rawDims;this.#y=[1,0,0,-1,-a,o+r],this.#l=n,this.#o=r,Ot.#R(),s.style.setProperty("--min-font-size",Ot.#w),ge(s,i),this.#t.promise.finally(()=>{Ot.#E.delete(this),this.#r=null,this.#g=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=ot.platform;return j(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){if(this.#n)this.#e.append(this.#n.render());let t=()=>{this.#h.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#a??=e.lang,Object.assign(this.#g,e.styles),this.#T(e.items),t()},this.#t.reject)};return this.#h=this.#c.getReader(),Ot.#E.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let s=t.scale*Wt.pixelRatio,i=t.rotation;if(i!==this.#d)e?.(),this.#d=i,ge(this.#u,{rotation:i});if(s!==this.#f){e?.(),this.#f=s;let n={div:null,properties:null,ctx:Ot.#I(this.#a)};for(let r of this.#p)n.properties=this.#v.get(r),n.div=r,this.#P(n)}}cancel(){let t=new se("TextLayer task cancelled.");this.#h?.cancel(t).catch(()=>{}),this.#h=null,this.#t.reject(t)}get textDivs(){return this.#p}get textContentItemsStr(){return this.#m}#T(t){if(this.#s)return;this.#r.ctx??=Ot.#I(this.#a);let e=this.#p,s=this.#m;for(let i of t){if(e.length>$a){z("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){let n=this.#e;if(this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id)this.#e.setAttribute("id",i.id);if(i.tag==="Artifact")this.#e.ariaHidden=!0;n.append(this.#e)}else if(i.type==="endMarkedContent")this.#e=this.#e.parentNode;continue}s.push(i.str),this.#O(i)}}#O(t){let e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#p.push(e);let i=L.transform(this.#y,t.transform),n=Math.atan2(i[1],i[0]),r=this.#g[t.fontName];if(r.vertical)n+=Math.PI/2;let a=this.#i&&r.fontSubstitution||r.fontFamily;a=Ot.fontFamilyMap.get(a)||a;let o=Math.hypot(i[2],i[3]),l=o*Ot.#k(a,r,this.#a),h,c;if(n===0)h=i[4],c=i[5]-l;else h=i[4]+l*Math.sin(n),c=i[5]-l*Math.cos(n);let d=e.style;if(d.left=`${(100*h/this.#l).toFixed(2)}%`,d.top=`${(100*c/this.#o).toFixed(2)}%`,d.setProperty("--font-height",`${o.toFixed(2)}px`),d.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#i)e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName;if(n!==0)s.angle=n*(180/Math.PI);let u=!1;if(t.str.length>1)u=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let f=Math.abs(t.transform[0]),p=Math.abs(t.transform[3]);if(f!==p&&Math.max(f,p)/Math.min(f,p)>1.5)u=!0}if(u)s.canvasWidth=r.vertical?t.height:t.width;if(this.#v.set(e,s),this.#r.div=e,this.#r.properties=s,this.#P(this.#r),s.hasText)this.#e.append(e);if(s.hasEOL){let f=document.createElement("br");f.setAttribute("role","presentation"),this.#e.append(f)}}#P(t){let{div:e,properties:s,ctx:i}=t,{style:n}=e;if(s.canvasWidth!==0&&s.hasText){let{fontFamily:r}=n,{canvasWidth:a,fontSize:o}=s;Ot.#D(i,o*this.#f,r);let{width:l}=i.measureText(e.textContent);if(l>0)n.setProperty("--scale-x",a*this.#f/l)}if(s.angle!==0)n.setProperty("--rotate",`${s.angle}deg`)}static cleanup(){if(this.#E.size>0)return;this.#b.clear();for(let{canvas:t}of this.#A.values())t.remove();this.#A.clear()}static#I(t=null){let e=this.#A.get(t||="");if(!e){let s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#A.set(t,e),this.#x.set(e,{size:0,family:""})}return e}static#D(t,e,s){let i=this.#x.get(t);if(e===i.size&&s===i.family)return;t.font=`${e}px ${s}`,i.size=e,i.family=s}static#R(){if(this.#w!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#w=t.getBoundingClientRect().height,t.remove()}static#k(t,e,s){let i=this.#b.get(t);if(i)return i;let n=this.#I(s);n.canvas.width=n.canvas.height=fn,this.#D(n,fn,t);let r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=0.8;if(a)l=a/(a+o);else{if(ot.platform.isFirefox)z("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");if(e.ascent)l=e.ascent;else if(e.descent)l=1+e.descent}return this.#b.set(t,l),l}}var Ga=100;function bi(t={}){let e=new Ai,{docId:s}=e,i=t.url?ba(t.url):null,n=t.data?Aa(t.data):null,r=t.httpHeaders||null,a=t.withCredentials===!0,o=t.password??null,l=t.range instanceof Si?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,c=t.worker instanceof Tt?t.worker:null,d=t.verbosity,u=typeof t.docBaseUrl==="string"&&!Ps(t.docBaseUrl)?t.docBaseUrl:null,f=es(t.cMapUrl),p=t.cMapPacked!==!1,g=es(t.iccUrl),m=es(t.standardFontDataUrl),v=es(t.wasmUrl),y=t.stopAtErrors!==!0,S=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=typeof t.isOffscreenCanvasSupported==="boolean"?t.isOffscreenCanvasSupported:!Nt,b=typeof t.isImageDecoderSupported==="boolean"?t.isImageDecoderSupported:!Nt,w=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,x=typeof t.disableFontFace==="boolean"?t.disableFontFace:Nt,T=t.fontExtraProperties===!0,E=t.enableXfa===!0,I=t.ownerDocument||globalThis.document,C=t.disableRange===!0,O=t.disableStream===!0,D=t.disableAutoFetch===!0,k=t.pdfBug===!0,R=t.CanvasFactory||(Nt?zn:$n),M=t.FilterFactory||(Nt?Vn:Gn),_=t.BinaryDataFactory||(Nt?Wn:ii),U=t.enableHWA===!0,it=t.enableWebGPU===!0?Ca():Promise.resolve(!1),rt=t.useWasm!==!1,J=t.pagesMapper||new br,et=typeof t.useSystemFonts==="boolean"?t.useSystemFonts:!Nt&&!x,ht=typeof t.useWorkerFetch==="boolean"?t.useWorkerFetch:!!(_===ii&&f&&p&&m&&v&&Be(f,document.baseURI)&&Be(m,document.baseURI)&&Be(v,document.baseURI)),Rt=null;ea(d);let N={canvasFactory:new R({ownerDocument:I,enableHWA:U}),filterFactory:new M({docId:s,ownerDocument:I}),binaryDataFactory:ht?null:new _({cMapUrl:f,standardFontDataUrl:m,wasmUrl:v})};if(!c)c=Tt.create({verbosity:d,port:re.workerPort}),e._worker=c;let P={docId:s,apiVersion:"6.3.289",data:n,password:o,disableAutoFetch:D,rangeChunkSize:h,docBaseUrl:u,enableXfa:E,evaluatorOptions:{maxImageSize:S,disableFontFace:x,ignoreErrors:y,isOffscreenCanvasSupported:A,isImageDecoderSupported:b,canvasMaxAreaInBytes:w,fontExtraProperties:T,useSystemFonts:et,useWasm:rt,useWorkerFetch:ht,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:v,hasGPU:!1}},F={ownerDocument:I,pdfBug:k,styleElement:Rt,enableHWA:U,loadingParams:{disableAutoFetch:D,enableXfa:E}};return Promise.all([c.promise,it]).then(function([,X]){if(c.destroyed)throw Error("Worker was destroyed");P.evaluatorOptions.hasGPU=X;let nt=c.messageHandler.sendWithPromise("GetDocRequest",P,n?[n.buffer]:null),V;if(n);else if(l)V=new or({pdfDataRangeTransport:l,disableRange:C,disableStream:O});else if(i)V=new(ja(i))({url:i,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:C,disableStream:O});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return nt.then((Z)=>{if(c.destroyed)throw Error("Worker was destroyed");let lt=new Ee(s,Z,c.port),xt=new Sr(lt,e,V,F,N,J);if(e._transport=xt,e.destroyed)throw Error("Loading aborted");lt.send("Ready",null)})}).catch(e._capability.reject).finally(e._setupCapability.resolve),e}class Ai{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${Ai.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{if(this._worker?.port)this._worker._pendingDestroy=!0;await this._setupCapability.promise,await this._transport?.destroy()}catch(t){if(this._worker?.port)delete this._worker._pendingDestroy;throw t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class Si{#t=Promise.withResolvers();#e=null;constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){st("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ar{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return j(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class wi{#t=!1;#e=null;constructor(t,e,s,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=n?new Qs:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new yi,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=i,this.imageCoordinates=null}clone(t){let e=new wi(t,this._pageInfo,this._transport,this.#e,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new Xe({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return j(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:n=ne.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1,recordImages:u=!1,recordOperations:f=!1,operationsFilter:p=null}){this._stats?.time("Overall");let g=this._transport.getRenderingIntent(i,n,c,d),{renderingIntent:m,cacheKey:v}=g;this.#t=!1,o||=this._transport.getOptionalContentConfig(m);let y=this._intentStates.getOrInsertComputed(v,Js);if(y.streamReaderCancelTimeout)clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null;let S=!!(m&Lt.PRINT);if(!y.displayReadyCapability)y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g);let A=!!(this._pdfBug&&globalThis.StepperManager?.enabled),b=!!e&&!this.recordedBBoxes&&(f||A),w=!!e&&!this.imageCoordinates&&u,x=(O)=>{if(y.renderTasks.delete(I),b){let D=I.gfx?.dependencyTracker.take();if(D){if(I.stepper?.setOperatorBBoxes(D,I.gfx.dependencyTracker.takeDebugMetadata()),f)this.recordedBBoxes=D}}if(w&&!O)this.imageCoordinates=I.gfx?.imagesTracker.take();if(S)this.#t=!0;if(this.#s(),O)I.capability.reject(O),this._abortOperatorList({intentState:y,reason:O instanceof Error?O:Error(O)});else I.capability.resolve();if(this._stats){if(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled)globalThis.Stats.add(this.pageNumber,this._stats)}},T=null,E=null;if(b||w)E=new On(e,y.operatorList.length);if(b)T=new Rn(E,A);let I=new Te({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:T??E,imagesTracker:w?new vs(e):null,viewport:s,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(y.renderTasks||=new Set).add(I);let C=I.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([O,D])=>{if(this.destroyed){x();return}if(this._stats?.time("Rendering"),!(D.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:O,optionalContentConfig:D}),I.operatorListChanged()}).catch(x),C}getOperatorList({intent:t="display",annotationMode:e=ne.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function n(){if(a.operatorList.lastChunk)a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o)}let r=this._transport.getRenderingIntent(t,e,s,i,!0),a=this._intentStates.getOrInsertComputed(r.cacheKey,Js),o;if(!a.opListReadCapability)o=Object.create(null),o.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r);return a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((i)=>je.textContent(i));let e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(let i of e)s.lang??=i.lang,Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values()){if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),e.opListReadCapability)continue;for(let s of e.renderTasks)t.push(s.completed),s.cancel()}return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;let e=this.#s();if(t&&e)this._stats&&=new Qs;return e}#s(){if(!this.#t||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}_startRenderPage(t,e){let s=this._intentStates.get(e);if(!s)return;this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t)}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let s of e.renderTasks)s.operatorListChanged();if(t.lastChunk)this.#s()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){let{map:n,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},void 0,r).getReader(),l=this._intentStates.get(e);l.streamReader=o;let h=()=>{o.read().then(({value:c,done:d})=>{if(d){l.streamReader=null;return}if(this._transport.destroyed)return;this._renderPageChunk(c,l),h()},(c)=>{if(l.streamReader=null,this._transport.destroyed)return;if(l.operatorList){l.operatorList.lastChunk=!0;for(let d of l.renderTasks)d.operatorListChanged();this.#s()}if(l.displayReadyCapability)l.displayReadyCapability.reject(c);else if(l.opListReadCapability)l.opListReadCapability.reject(c);else throw c})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(!t.streamReader)return;if(t.streamReaderCancelTimeout)clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null;if(!s){if(t.renderTasks.size>0)return;if(e instanceof Is){let i=Ga;if(e.extraDelay>0&&e.extraDelay<1000)i+=e.extraDelay;t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new se(e.message)).catch(()=>{}),t.streamReader=null,this._transport.destroyed)return;for(let[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}get stats(){return this._stats}}class Tt{#t=Promise.withResolvers();#e=null;#s=null;#i=null;static#n=0;static#a=!1;static#r=new WeakMap;static{if(Nt)this.#a=!0,re.workerSrc||="./pdf.worker.mjs";this._isSameOrigin=(t,e)=>{let s=URL.parse(t);if(!s?.origin||s.origin==="null")return!1;let i=new URL(e,s);return s.origin===i.origin},this._createCDNWrapper=(t)=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:s=sa()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(Tt.#r.has(e))throw Error("Cannot use more than one PDFWorker per port.");Tt.#r.set(e,this),this.#l(e)}else this.#h()}get promise(){return this.#t.promise}#o(){this.#t.resolve(),this.#e.send("configure",{verbosity:this.verbosity})}get port(){return this.#s}get messageHandler(){return this.#e}#l(t){this.#s=t,this.#e=new Ee("main","worker",t),this.#e.on("ready",()=>{}),this.#o()}#h(){if(Tt.#a||Tt.#d){this.#u();return}let{workerSrc:t}=Tt;try{if(!Tt._isSameOrigin(window.location,t))t=Tt._createCDNWrapper(new URL(t,window.location).href);let e=new Worker(t,{type:"module"}),s=new Ee("main","worker",e),i=()=>{if(n.abort(),s.destroy(),e.terminate(),this.destroyed)this.#t.reject(Error("Worker was destroyed"));else this.#u()},n=new AbortController;e.addEventListener("error",()=>{if(!this.#i)i()},{signal:n.signal}),s.on("test",(a)=>{if(n.abort(),this.destroyed||!a){i();return}this.#e=s,this.#s=e,this.#i=e,this.#o()}),s.on("ready",(a)=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this.#u()}});let r=()=>{let a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{Ts("The worker has been disabled.")}this.#u()}#u(){if(!Tt.#a)z("Setting up fake worker."),Tt.#a=!0;Tt._setupFakeWorkerGlobal.then((t)=>{if(this.destroyed){this.#t.reject(Error("Worker was destroyed"));return}let e=new jn;this.#s=e;let s=`fake${Tt.#n++}`,i=new Ee(s+"_worker",s,e);t.setup(i,e),this.#e=new Ee(s,s+"_worker",e),this.#o()}).catch((t)=>{this.#t.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#i?.terminate(),this.#i=null,Tt.#r.delete(this.#s),this.#s=null,this.#e?.destroy(),this.#e=null}static create(t){let e=this.#r.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Tt(t)}static get workerSrc(){if(re.workerSrc)return re.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#d(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return j(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#d)return this.#d;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class Sr{downloadInfoCapability=Promise.withResolvers();#t=null;#e=new Map;#s=null;#i=new Map;#n=new Map;#a=new Map;#r=null;constructor(t,e,s,i,n,r){this.messageHandler=t,this.loadingTask=e,this.#s=s,this.commonObjs=new yi,this.fontLoader=new Dn({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.binaryDataFactory=n.binaryDataFactory,this.pagesMapper=r,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){let{_pageIndex:e}=t;this.#i.set(e,t),this.#n.set(e,Promise.resolve(t))}#o(t,e=null){return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#l({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?ut(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return j(this,"annotationStorage",new Ms)}getRenderingIntent(t,e=ne.ENABLE,s=null,i=!1,n=!1){let r=Lt.DISPLAY,a=$e;switch(t){case"any":r=Lt.ANY;break;case"display":break;case"print":r=Lt.PRINT;break;default:z(`getRenderingIntent - invalid intent: ${t}`)}let o=r&Lt.PRINT&&s instanceof fi?s:this.annotationStorage;switch(e){case ne.DISABLE:r+=Lt.ANNOTATIONS_DISABLE;break;case ne.ENABLE:break;case ne.ENABLE_FORMS:r+=Lt.ANNOTATIONS_FORMS;break;case ne.ENABLE_STORAGE:r+=Lt.ANNOTATIONS_STORAGE,a=o.serializable;break;default:z(`getRenderingIntent - invalid annotationMode: ${e}`)}if(i)r+=Lt.IS_EDITING;if(n)r+=Lt.OPLIST;let{ids:l,hash:h}=o.modifiedIds,c=[r,a.hash,h];return{renderingIntent:r,cacheKey:c.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let s of this.#i.values())t.push(s._destroy());if(this.#i.clear(),this.#n.clear(),this.#a.clear(),Object.hasOwn(this,"annotationStorage"))this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),Ot.cleanup(),this.#s?.cancelAllRequests(new se("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{mt(this.#s,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#s.getFullReader(),this.#t.onProgress=(n)=>this.#l(n),i.onPull=()=>{this.#t.read().then(function({value:n,done:r}){if(r){i.close();return}mt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch((n)=>{i.error(n)})},i.onCancel=(n)=>{this.#t.cancel(n),i.ready.catch((r)=>{if(this.destroyed)return;throw r})}}),t.on("ReaderHeadersReady",async(s)=>{await this.#t.headersReady;let{isStreamingSupported:i,isRangeSupported:n,contentLength:r}=this.#t;if(i&&n)this.#t.onProgress=null;return{isStreamingSupported:i,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{mt(this.#s,"GetRangeReader - no `BasePDFStream` instance available.");let n=this.#s.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}mt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch((r)=>{i.error(r)})},i.onCancel=(r)=>{n.cancel(r),i.ready.catch((a)=>{if(this.destroyed)return;throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Ar(s,this))}),t.on("DocException",(s)=>{e._capability.reject(Dt(s))}),t.on("PasswordRequest",(s)=>{this.#r=Promise.withResolvers();try{if(!e.onPassword)throw Dt(s);let i=(n)=>{if(n instanceof Error)this.#r.reject(n);else this.#r.resolve({password:n})};e.onPassword(i,s.code)}catch(i){this.#r.reject(i)}return this.#r.promise}),t.on("DataLoaded",(s)=>{this.#l({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",(s)=>{if(this.destroyed)return;this.#i.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed)return null;if(this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in n){let c=n.error;z(`Error during font loading: ${c}`),this.commonObjs.resolve(s,c);break}let r=new _n(n),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(c,d)=>globalThis.FontInspector.fontAdded(c,d):null,o=new kn(r,a,n.charProcOperatorList,n.extra);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{if(!o.fontExtraProperties)o.clearData();this.commonObjs.resolve(s,o)});break;case"CopyLocalImage":let{imageRef:l}=n;mt(l,"The imageRef must be defined.");for(let c of this.#i.values())for(let[,d]of c.objs){if(d?.ref!==l)continue;if(!d.dataLen)return null;let u=structuredClone(d);return this.commonObjs.resolve(s,u),d.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new Un(n));break;case"Image":this.commonObjs.resolve(s,n);break;case"Pattern":let h=new Hn(n);this.commonObjs.resolve(s,h.getIR());break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;let a=this.#i.get(i);if(a.objs.has(s))return;if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":case"Pattern":a.objs.resolve(s,r);break;default:throw Error(`Got unknown object type ${n}`)}}),t.on("DocProgress",(s)=>{if(this.destroyed)return;this.#l(s)}),t.on("FetchBinaryData",async(s)=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){if(this.annotationStorage.size<=0)z("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#t?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t,e=null){let s={pageInfos:t},i,n=globalThis.ImageBitmap;if(typeof n==="function"){let r=Array.isArray(t)?t:[t];for(let a of r)if(a?.image instanceof n)(i||=[]).push(a.image)}if(this.annotationStorage.size>0){let r=this.annotationStorage.serializable,{map:a}=r;if(r.transfer?.length)if(i)i.push(...r.transfer);else i=r.transfer;let o=this.pagesMapper.getMapping();if(o){let l=new Map;for(let[h,c]of a){if(c?.pageIndex!==void 0&&c.pageIndex>=0&&c.pageIndex<o.length){let d=e?.[c.pageIndex]??0,u=o[c.pageIndex]-1;if(u!==c.pageIndex||d!==0){l.set(h,{...c,pageIndex:u,copyLevel:d});continue}}l.set(h,c)}a=l}s.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",s,i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,s=this.pagesMapper.getPageId(t)-1,i=this.#n.get(e);if(i)return i;let n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then((r)=>{if(this.destroyed)throw Error("Transport destroyed");if(r.refStr)this.#a.set(r.refStr,s);let a=new wi(e,r,this,this.pagesMapper,this._params.pdfBug);return this.#i.set(e,a),a});return this.#n.set(e,n),n}async getPageIndex(t){if(!si(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#o("GetFieldObjects")}getSignatures(){return this.#o("GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return this.#o("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){if(typeof t!=="string")return Promise.reject(Error("Invalid destination request."));return this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#o("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#o("GetOptionalContentConfig").then((e)=>new vi(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#e.getOrInsertComputed("GetMetadata",()=>this.messageHandler.sendWithPromise("GetMetadata",null).then((e)=>({info:e[0],metadata:e[1]?new vr(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(this.destroyed)return;await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#i.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);if(this.commonObjs.clear(),!t)this.fontLoader.clear();this.#e.clear(),this.filterFactory.destroy(!0),Ot.cleanup()}cachedPageNumber(t){if(!si(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=this.#a.get(e);if(s>=0){let i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}class wr{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class Te{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null,enableHWA:u=!1,operationsFilter:f=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new wr(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=f}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Te.#e.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Te.#e.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled)this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint();let{viewport:s,transform:i,background:n,dependencyTracker:r,imagesTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new fe(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r,a),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){if(this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t)window.cancelAnimationFrame(this.#t),this.#t=null;Te.#e.delete(this._canvas),t||=new Is(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running)return;this._continue()}_continue(){if(this.running=!0,this.cancelled)return;if(this.task.onContinue)this.task.onContinue(this._scheduleNextBound);else this._scheduleNext()}_scheduleNext(){if(this._useRequestAnimationFrame)this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)});else Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length){if(this.running=!1,this.operatorList.lastChunk)this.gfx.endDrawing(),Te.#e.delete(this._canvas),this.callback()}}}var Va="6.3.289",za="1c8020a7d",Mo=K(3068);class jt{#t=null;#e=null;#s;#i=null;#n=!1;#a=!1;#r=null;#o;#l=null;#h=null;static#u=null;static get _keyboardManager(){return j(this,"_keyboardManager",new Ft([[["Escape"],jt.prototype._hideDropdownFromKeyboard],[["Space"],jt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],jt.prototype._moveToNext],[["ArrowUp","ArrowLeft"],jt.prototype._moveToPrevious],[["Home"],jt.prototype._moveToBeginning],[["End"],jt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){if(t)this.#a=!1,this.#r=t;else this.#a=!0;this.#h=t?._uiManager||e,this.#o=this.#h._eventBus,this.#s=t?.color?.toUpperCase()||this.#h?.highlightColors.values().next().value||"#FFFF98",jt.#u||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=document.createElement("button");if(t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r)t.ariaControls=`${this.#r.id}_colorpicker_dropdown`;let e=this.#h._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#g.bind(this),{signal:e});let s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#s,t.append(s),t}renderMainDropdown(){let t=this.#i=this.#d();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#d(){let t=document.createElement("div"),e=this.#h._signal;if(t.addEventListener("contextmenu",zt,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r)t.id=`${this.#r.id}_colorpicker_dropdown`;for(let[s,i]of this.#h.highlightColors){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",jt.#u[s]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.ariaSelected=i===this.#s,n.addEventListener("click",this.#f.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#g.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:q.HIGHLIGHT_COLOR,value:t}),this.update(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");if(!e)return;this.#f(e,t)}_moveToNext(t){if(!this.#p){this.#m(t);return}if(t.target===this.#t){this.#i.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstElementChild||t.target===this.#t){if(this.#p)this._hideDropdownFromKeyboard();return}if(!this.#p)this.#m(t);t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#p){this.#m(t);return}this.#i.firstElementChild?.focus()}_moveToEnd(t){if(!this.#p){this.#m(t);return}this.#i.lastElementChild?.focus()}#g(t){jt._keyboardManager.exec(this,t)}#m(t){if(this.#p){this.hideDropdown();return}if(this.#n=t.detail===0,!this.#l)this.#l=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#h.combinedSignal(this.#l)});if(this.#t.ariaExpanded="true",this.#i){this.#i.classList.remove("hidden");return}let e=this.#i=this.#d();this.#t.append(e)}#c(t){if(this.#i?.contains(t.target))return;this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#p(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(this.#a)return;if(!this.#p){this.#r?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#n})}update(t){if(this.#e)this.#e.style.backgroundColor=t;if(!this.#i)return;let e=this.#h.highlightColors.values();for(let s of this.#i.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}}class ze{#t=null;#e=!1;#s=null;#i=null;static#n=null;constructor(t){this.#s=t,this.#i=t._uiManager,ze.#n||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;let{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:n,opacity:r}=this.#s,a=this.#e=ot.isAlphaColorInputSupported&&i!==void 0,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");let l=L.hexNums[Math.round((r??1)*255)];o.value=(n||"#000000")+l}else o.value=n||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",ze.#n[t]),o.addEventListener("input",()=>{if(a){let l=Ye(o.value);if(!l)return;let[h,c,d,u]=l,f=L.makeHexColor(h,c,d);if(s!==void 0)this.#i.updateParams(s,{color:f,opacity:u});else this.#i.updateParams(e,f),this.#i.updateParams(i,u)}else this.#i.updateParams(e,o.value)},{signal:this.#i._signal}),o}update(t){if(!this.#t)return;if(this.#e){let e=L.hexNums[Math.round(this.#s.opacity*255)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;let e=L.hexNums[Math.round(t*255)];this.#t.value=this.#s.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}var Oo=K(531);function pn(t){return Math.floor(ut(t,0,1)*255).toString(16).padStart(2,"0")}function Le(t){return ut(t,0,1)*255}class ri{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,0.3*t+0.59*s+0.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Le(t),[t,t,t]}static G_HTML([t]){let e=pn(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",0.3*t+0.59*e+0.11*s]}static RGB_rgb(t){return t.map(Le)}static RGB_HTML(t){return`#${t.map(pn).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Le(1-Math.min(1,t+i)),Le(1-Math.min(1,s+i)),Le(1-Math.min(1,e+i))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){let i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class xr{create(t,e,s=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");if(i.setAttribute("version","1.1"),!s)i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`);return i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!=="string")throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){st("Abstract method `_createSVG` called.")}}class We extends xr{_createSVG(t){return document.createElementNS(Mt,t)}}var Wa=9,me=new WeakSet,Xa=new Date().getTimezoneOffset()*60*1000;class us{static create(t){switch(t.data.annotationType){case gt.LINK:return new Fs(t);case gt.TEXT:return new Tr(t);case gt.WIDGET:switch(t.data.fieldType){case"Tx":return new Cr(t);case"Btn":if(t.data.radioButton)return new Mr(t);else if(t.data.checkBox)return new Pr(t);return new Or(t);case"Ch":return new Rr(t);case"Sig":return new Ir(t)}return new oe(t);case gt.POPUP:return new ys(t);case gt.FREETEXT:return new xi(t);case gt.LINE:return new kr(t);case gt.SQUARE:return new Lr(t);case gt.CIRCLE:return new Nr(t);case gt.POLYLINE:return new Ei(t);case gt.CARET:return new Br(t);case gt.INK:return new Bs(t);case gt.POLYGON:return new Fr(t);case gt.HIGHLIGHT:return new Ti(t);case gt.UNDERLINE:return new _r(t);case gt.SQUIGGLY:return new Hr(t);case gt.STRIKEOUT:return new Ur(t);case gt.STAMP:return new Ci(t);case gt.FILEATTACHMENT:return new jr(t);case gt.RICHMEDIA:case gt.SCREEN:case gt.SOUND:return new Ii(t);default:return new ft(t)}}}class ft{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){if(this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e)this.contentElement=this.container=this._createContainer(s);if(i)this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ft._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);if(e)return e.getData();return t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:s,rect:i}=this.data,n=-1/0,r=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)if(e[a+1]>r)r=e[a+1],n=e[a+2];else if(e[a+1]===r)n=Math.max(n,e[a+2]);return[n,r]}if(s?.length>=1){for(let a of s)for(let o=0,l=a.length;o<l;o+=2)if(a[o+1]>r)r=a[o+1],n=a[o];else if(a[o+1]===r)n=Math.max(n,a[o]);if(n!==1/0)return[n,r]}if(i)return[i[2],i[3]];return null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/s,t[1]=100*(t[1]-r)/i,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${Ce}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,s={deleted:!t,contents:t||""};if(!this.annotationStorage.updateEditor(e.id,{popup:s}))this.annotationStorage.setValue(`${Ce}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date});if(!t)this.removePopup()}removePopup(){(this.#s?.popup||this.popup)?.remove(),this.#s=this.popup=null}updateEdited(t){if(!this.container)return;if(t.rect)this.#t||={rect:this.data.rect.slice(0)};let{rect:e,popup:s}=t;if(e)this.#i(e);let i=this.#s?.popup||this.popup;if(!i&&s?.text)this._createPopup(s),i=this.#s.popup;if(!i)return;if(i.updateEdited(t),s?.deleted)i.remove(),this.#s=null,this.popup=null}resetEdited(){if(!this.#t)return;this.#i(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null}#i(t){let{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;if(s?.splice(0,4,...t),e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0)e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/r}%`;else this.setRotation(i)}_createContainer(t){let{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");if(n.setAttribute("data-annotation-id",e.id),!(this instanceof oe)&&!(this instanceof Fs)&&!(this instanceof Ii))n.tabIndex=0;let{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText)n.title=e.alternativeText;if(e.noRotate)n.classList.add("norotate");if(!e.rect||this instanceof ys){let{rotation:p}=e;if(!e.hasOwnCanvas&&p!==0)this.setRotation(p,n);return n}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let p=e.borderStyle.horizontalCornerRadius,g=e.borderStyle.verticalCornerRadius;if(p>0||g>0){let v=`calc(${p}px * var(--total-scale-factor)) / calc(${g}px * var(--total-scale-factor))`;r.borderRadius=v}switch(e.borderStyle.style){case Se.SOLID:r.borderStyle="solid";break;case Se.DASHED:r.borderStyle="dashed";break;case Se.BEVELED:z("Unimplemented border style: beveled");break;case Se.INSET:z("Unimplemented border style: inset");break;case Se.UNDERLINE:r.borderBottomStyle="solid";break;default:break}let m=e.borderColor||null;if(m)this.#e=!0,r.borderColor=L.makeHexColor(...m);else r.borderWidth=0}let l=L.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=i.rawDims;r.left=`${100*(l[0]-d)/h}%`,r.top=`${100*(l[1]-u)/c}%`;let{rotation:f}=e;if(e.hasOwnCanvas||f===0)r.width=`${100*a/h}%`,r.height=`${100*o/c}%`;else this.setRotation(f,n);return n}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=this;if(t%180!==0)[n,r]=[r,n];e.style.width=`${100*n/s}%`,e.style.height=`${100*r/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,s,i)=>{let n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ri[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ri[`${r}_rgb`](a)})};return j(this,"_commonActions",{display:(e)=>{let{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:(e)=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:(e)=>{let{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:(e)=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:(e)=>{e.target.title=e.detail.userName},readonly:(e)=>{e.target.disabled=e.detail.readonly},required:(e)=>{this._setRequired(e.target,e.detail.required)},bgColor:(e)=>{t("bgColor","backgroundColor",e)},fillColor:(e)=>{t("fillColor","backgroundColor",e)},fgColor:(e)=>{t("fgColor","color",e)},textColor:(e)=>{t("textColor","color",e)},borderColor:(e)=>{t("borderColor","borderColor",e)},strokeColor:(e)=>{t("strokeColor","borderColor",e)},rotation:(e)=>{let s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){let s=this._commonActions;for(let i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let s=this._commonActions;for(let[i,n]of Object.entries(e)){let r=s[i];if(r){let a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,s,i,n]=this.data.rect.map(Math.fround);if(t.length===8){let[p,g,m,v]=t.subarray(2,6);if(i===p&&n===g&&e===m&&s===v)return}let{style:r}=this.container,a;if(this.#e){let{borderColor:p,borderWidth:g}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Mt}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${p}" stroke-width="${g}">`],this.container.classList.add("hasBorder")}let o=i-e,l=n-s,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";let d=h.createElement("defs");c.append(d);let u=h.createElement("clipPath"),f=`clippath_${this.data.id}`;u.setAttribute("id",f),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let p=2,g=t.length;p<g;p+=8){let m=t[p],v=t[p+1],y=t[p+2],S=t[p+3],A=h.createElement("rect"),b=(y-e)/o,w=(n-v)/l,x=(m-y)/o,T=(v-S)/l;A.setAttribute("x",b),A.setAttribute("y",w),A.setAttribute("width",x),A.setAttribute("height",T),u.append(A),a?.push(`<rect vector-effect="non-scaling-stroke" x="${b}" y="${w}" width="${x}" height="${T}"/>`)}if(this.#e)a.push("</g></svg>')"),r.backgroundImage=a.join("");this.container.append(c),this.container.style.clipPath=`url(#${f})`}_createPopup(t=null){let{data:e}=this,s,i;if(t)s={str:t.text},i=t.date;else s=e.contentsObj,i=e.modificationDate;this.#s=new ys({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#s||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#s}render(){st("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let s=[];if(this._fieldObjects){let i=this._fieldObjects.get(t)||[];for(let{page:n,id:r,exportValues:a}of i){if(n===-1)continue;if(r===e)continue;let o=typeof a==="string"?a:null,l=document.querySelector(`[data-element-id="${r}"]`);if(l&&!me.has(l)){z(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:l})}return s}for(let i of document.getElementsByName(t)){let{exportValue:n}=i,r=i.getAttribute("data-element-id");if(r===e)continue;if(!me.has(i))continue;s.push({id:r,exportValue:n,domElement:i})}return s}show(){if(this.container)this.container.hidden=!1;this.popup?.maybeShow()}hide(){if(this.container)this.container.hidden=!0;this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;if(t.isVisible(this.data.oc))this.show();else this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":L.makeHexColor(...e)}}class Er extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;if(!t.hasComment)return;this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){if(this.editor.comment=t,!t)this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class Fs extends ft{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;if(t.url)e.addLinkAttributes(s,t.url,t.newWindow),i=!0;else if(t.action)this._bindNamedAction(s,t.action,t.overlaidText),i=!0;else if(t.attachment)this.#e(s,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),i=!0;else if(t.setOCGState)this.#s(s,t.setOCGState,t.overlaidText),i=!0;else if(t.dest)this._bindLink(s,t.dest,t.overlaidText),i=!0;else{if(t.actions&&(t.actions.has("Action")||t.actions.has("Mouse Up")||t.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions)this._bindJSAction(s,t),i=!0;if(t.resetForm)this._bindResetFormAction(s,t.resetForm),i=!0;else if(this.isTooltipOnly&&!i)this._bindLink(s,""),i=!0}if(this.container.classList.add("linkAnnotation"),i)this.contentElement=s,this.container.append(s);return this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){if(t.href=this.linkService.getDestinationHash(e),t.onclick=()=>{if(e)this.linkService.goToDestination(e);return!1},e||e==="")this.#t();if(s)t.title=s}_bindNamedAction(t,e,s=""){if(t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s)t.title=s;this.#t()}#e(t,e,s,i="",n=null){if(t.href=this.linkService.getAnchorUrl(""),s.description)t.title=s.description;else if(i)t.title=i;let r=async()=>{let a=await this.linkService.getAttachmentContent(e);if(a)this.downloadManager?.openOrDownloadData(a,s.filename,n)};t.onclick=()=>(r(),!1),this.#t()}#s(t,e,s=""){if(t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s)t.title=s;this.#t()}_bindJSAction(t,{actions:e,id:s,overlaidText:i}){t.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let r of e.keys()){let a=n.get(r);if(!a)continue;t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:r}}),!1)}if(i)t.title=i;t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){let s=t.onclick;if(!s)t.href=this.linkService.getAnchorUrl("");if(this.#t(),!this._fieldObjects){if(z('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!s)t.onclick=()=>!1;return}t.onclick=()=>{s?.();let{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){let h=new Set(n);for(let c of i){let d=this._fieldObjects.get(c)||[];for(let{id:u}of d)h.add(u)}for(let c of this._fieldObjects.values())for(let d of c)if(h.has(d.id)===r)a.push(d)}else for(let h of this._fieldObjects.values())a.push(...h);let o=this.annotationStorage,l=[];for(let h of a){let{id:c}=h;switch(l.push(c),h.type){case"text":{let u=h.defaultValue||"";o.setValue(c,{value:u});break}case"checkbox":case"radiobutton":{let u=h.defaultValue===h.exportValues;o.setValue(c,{value:u});break}case"combobox":case"listbox":{let u=h.defaultValue||"";o.setValue(c,{value:u});break}default:continue}let d=document.querySelector(`[data-element-id="${c}"]`);if(!d)continue;else if(!me.has(d)){z(`_bindResetFormAction - element not allowed: ${c}`);continue}d.dispatchEvent(new Event("resetform"))}if(this.enableScripting)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}});return!1}}}class Tr extends ft{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");if(t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(t),this.container}}class oe extends ft{render(){return this.container}_getKeyModifier(t){return ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){if(s.includes("mouse"))t.addEventListener(s,(r)=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})});else t.addEventListener(s,(r)=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}if(!n)return;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){let{actions:n}=this.data;for(let[r,a]of s)if(a==="Action"||n?.has(a)){if(a==="Focus"||a==="Blur")e||={focused:!1};if(this._setEventListener(t,e,r,a,i),a==="Focus"&&!n?.has("Blur"))this._setEventListener(t,e,"blur","Blur",null);else if(a==="Blur"&&!n?.has("Focus"))this._setEventListener(t,e,"focus","Focus",null)}}_setTextStyle(t){let e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Wa,n=t.style,r,a=2,o=(l)=>Math.round(10*l)/10;if(this.data.multiLine){let l=Math.abs(this.data.rect[3]-this.data.rect[1]-2),h=Math.round(l/(1.35*i))||1,c=l/h;r=Math.min(i,o(c/1.35))}else{let l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(i,o(l/1.35))}if(n.fontSize=`calc(${r}px * var(--total-scale-factor))`,n.color=L.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb)n.textAlign=e[this.data.textAlignment]}_setRequired(t,e){if(e)t.setAttribute("required",!0);else t.removeAttribute("required");t.setAttribute("aria-required",e)}}class Cr extends oe{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){let n=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id)){if(r.domElement)r.domElement[e]=s;n.setValue(r.id,{[i]:s})}}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){let i=t.getValue(e,{value:this.data.fieldValue}),n=i.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;if(r&&n.length>r)n=n.slice(0,r);let a=i.formattedValue||this.data.textContent?.join(`
48
- `)||null;if(a&&this.data.comb)a=a.replaceAll(/\s+/g,"");let o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){if(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll)s.style.overflowY="hidden"}else if(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",a??n),this.data.doNotScroll)s.style.overflowX="hidden";if(this.data.hasOwnCanvas){if(this.container.classList.add("hasOwnCanvas"),t.has(e))this.container.classList.add("sandboxModified")}me.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:c}=this.data,d=!!h&&this.enableScripting;if(l)s.title=l;if(this._setRequired(s,this.data.required),r)s.maxLength=r;s.addEventListener("input",(f)=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",(f)=>{let p=this.data.defaultFieldValue??"";s.value=o.userValue=p,o.formattedValue=null});let u=(f)=>{let{formattedValue:p}=o;if(p!==null&&p!==void 0)f.target.value=p;f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(p)=>{if(o.focused)return;let{target:g}=p;if(d){if(g.type=h,c)g.step=c}if(o.userValue){let m=o.userValue;if(d)if(h==="time"){let v=new Date(m),y=[v.getHours(),v.getMinutes(),v.getSeconds()];g.value=y.map((S)=>S.toString().padStart(2,"0")).join(":")}else g.value=new Date(m-Xa).toISOString().split(h==="date"?"T":".",1)[0];else g.value=m}if(o.lastCommittedValue=g.value,o.commitKey=1,!this.data.actions?.has("Focus"))o.focused=!0}),s.addEventListener("updatefromsandbox",(p)=>{this.container.classList.add("sandboxModified");let g={value(m){if(o.userValue=m.detail.value??"",!d)t.setValue(e,{value:o.userValue.toString()});m.target.value=o.userValue},formattedValue(m){let{formattedValue:v}=m.detail;if(o.formattedValue=v,v!==null&&v!==void 0&&m.target!==document.activeElement)m.target.value=v;let y={formattedValue:v};if(d)y.value=v;t.setValue(e,y)},selRange(m){m.target.setSelectionRange(...m.detail.selRange)},charLimit:(m)=>{let{charLimit:v}=m.detail,{target:y}=m;if(v===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",v);let S=o.userValue;if(!S||S.length<=v)return;S=S.slice(0,v),y.value=o.userValue=S,t.setValue(e,{value:S}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}})}};this._dispatchEventFromSandbox(g,p)}),s.addEventListener("keydown",(p)=>{o.commitKey=1;let g=-1;if(p.key==="Escape")g=0;else if(p.key==="Enter"&&!this.data.multiLine)g=2;else if(p.key==="Tab")o.commitKey=3;if(g===-1)return;let{value:m}=p.target;if(o.lastCommittedValue===m)return;o.lastCommittedValue=m,o.userValue=m,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:m,willCommit:!0,commitKey:g,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})});let f=u;if(u=null,s.addEventListener("blur",(p)=>{if(!o.focused||!p.relatedTarget)return;if(!this.data.actions?.has("Blur"))o.focused=!1;let{target:g}=p,{value:m}=g;if(d){if(m&&h==="time"){let v=m.split(":").map((y)=>parseInt(y,10));m=new Date(2000,0,1,v[0],v[1],v[2]||0).valueOf(),g.step=""}else{if(!m.includes("T"))m=`${m}T00:00`;m=new Date(m).valueOf()}g.type="text"}if(o.userValue=m,o.lastCommittedValue!==m)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:m,willCommit:!0,commitKey:o.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}});f(p)}),this.data.actions?.has("Keystroke"))s.addEventListener("beforeinput",(p)=>{o.lastCommittedValue=null;let{data:g,target:m}=p,{value:v,selectionStart:y,selectionEnd:S}=m,A=y,b=S;switch(p.inputType){case"deleteWordBackward":{let w=/\w/;while(A>0&&!w.test(v[A-1]))A--;while(A>0&&w.test(v[A-1]))A--;break}case"deleteWordForward":{let w=v.substring(y).match(/^\W*\w*/);if(w)b+=w[0].length;break}case"deleteContentBackward":if(y===S)A-=1;break;case"deleteContentForward":if(y===S)b+=1;break}p.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,change:g||"",willCommit:!1,selStart:A,selEnd:b}})});this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(p)=>p.target.value)}if(u)s.addEventListener("blur",u);if(this.data.comb){let p=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${p}px * var(--total-scale-factor))`);let g=this.data.textAlignment;if(g===1||g===2){let m=()=>{let v=r-s.value.length;s.style.setProperty("--comb-offset",`${g===1?v>>1:v}`)};m();for(let v of["input","blur","resetform","updatefromsandbox"])s.addEventListener(v,m)}}}else if(s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas)s.hidden=!0;return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ir extends oe{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Pr extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;if(typeof i==="string")i=i!=="Off",t.setValue(s,{value:i});this.container.classList.add("buttonWidgetAnnotation","checkBox");let n=document.createElement("input");if(me.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i)n.setAttribute("checked",!0);if(n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",(r)=>{let{name:a,checked:o}=r.target;for(let l of this._getElementsByName(a,s)){let h=o&&l.exportValue===e.exportValue;if(l.domElement)l.domElement.checked=h;t.setValue(l.id,{value:h})}t.setValue(s,{value:o})}),n.addEventListener("resetform",(r)=>{let a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions)n.addEventListener("updatefromsandbox",(r)=>{let a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(r)=>r.target.checked);return this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Mr extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i==="string")i=i!==e.buttonValue,t.setValue(s,{value:i});if(i)for(let r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});let n=document.createElement("input");if(me.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i)n.setAttribute("checked",!0);if(n.tabIndex=0,n.addEventListener("change",(r)=>{let{name:a,checked:o}=r.target;for(let l of this._getElementsByName(a,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",(r)=>{let a=e.defaultFieldValue;r.target.checked=a!==null&&a!==void 0&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){let r=e.buttonValue;n.addEventListener("updatefromsandbox",(a)=>{let o={value:(l)=>{let h=r===l.detail.value;for(let c of this._getElementsByName(l.target.name)){let d=h&&c.id===s;if(c.domElement)c.domElement.checked=d;t.setValue(c.id,{value:d})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(a)=>a.target.checked)}return this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Or extends Fs{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;if(this.enableScripting&&this.hasJSActions&&e)this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(s)=>{this._dispatchEventFromSandbox({},s)});return t}}class Rr extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");me.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;if(!this.data.combo){if(i.size=this.data.options.length,this.data.multiSelect)i.multiple=!0}i.addEventListener("resetform",(c)=>{let d=this.data.defaultFieldValue;for(let u of i.options)u.selected=u.value===d});let r=(c,d)=>{let u=d.replaceAll(" "," ");if(c.textContent=u,u!==d)c.setAttribute("display-value",d)};for(let c of this.data.options){let d=document.createElement("option");if(r(d,c.displayValue),d.value=c.exportValue,s.value.includes(c.exportValue))d.setAttribute("selected",!0),n=!1;i.append(d)}let a=null;if(n){let c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),a=()=>{c.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}let o=(c)=>{let d=c?"value":"textContent",{options:u,multiple:f}=i;if(!f)return u.selectedIndex===-1?null:u[u.selectedIndex][d];return Array.prototype.filter.call(u,(p)=>p.selected).map((p)=>p[d])},l=o(!1),h=(c)=>{let d=c.target.options;return Array.prototype.map.call(d,(u)=>({displayValue:u.getAttribute("display-value")||u.textContent,exportValue:u.value}))};if(this.enableScripting&&this.hasJSActions)i.addEventListener("updatefromsandbox",(c)=>{let d={value(u){a?.();let f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(let g of i.options)g.selected=p.has(g.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(u){i.multiple=!0},remove(u){let f=i.options,p=u.detail.remove;if(f[p].selected=!1,i.remove(p),f.length>0){if(Array.prototype.findIndex.call(f,(m)=>m.selected)===-1)f[0].selected=!0}t.setValue(e,{value:o(!0),items:h(u)}),l=o(!1)},clear(u){while(i.length!==0)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(u){let{index:f,displayValue:p,exportValue:g}=u.detail.insert,m=i.children[f],v=document.createElement("option");if(r(v,p),v.value=g,m)m.before(v);else i.append(v);t.setValue(e,{value:o(!0),items:h(u)}),l=o(!1)},items(u){let{items:f}=u.detail;while(i.length!==0)i.remove(0);for(let p of f){let{displayValue:g,exportValue:m}=p,v=document.createElement("option");r(v,g),v.value=m,i.append(v)}if(i.options.length>0)i.options[0].selected=!0;t.setValue(e,{value:o(!0),items:h(u)}),l=o(!1)},indices(u){let f=new Set(u.detail.indices);for(let p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",(c)=>{let d=o(!0),u=o(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(c)=>c.target.value);else i.addEventListener("input",function(c){t.setValue(e,{value:o(!0)})});if(this.data.combo)this._setTextStyle(i);return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ys extends ft{constructor(t){let{data:e,elements:s,parent:i}=t,n=!!i._commentManager;super(t,{isRenderable:!n&&ft._hasPopupData(e)});if(this.elements=s,n&&ft._hasPopupData(e)){let r=this.popup=this.#t();for(let a of s)a.popup=r}else this.popup=null}#t(){return new Dr({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#t(),s=[];for(let i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map((i)=>`${xe}${i}`).join(",")),this.container}}class Dr{#t=null;#e=this.#V.bind(this);#s=this.#S.bind(this);#i=this.#C.bind(this);#n=this.#j.bind(this);#a=null;#r=null;#o=null;#l=null;#h=null;#u=null;#d=null;#f=!1;#g=null;#m=null;#c=null;#p=null;#v=null;#y=null;#b=null;#A=null;#x=null;#w=null;#E=!1;#T=null;#O=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:c,commentManager:d=null}){if(this.#r=t,this.#x=i,this.#o=r,this.#A=a,this.#u=o,this.#a=e,this.#b=l,this.#d=h,this.#h=s,this.#t=d,this.#T=s[0],this.#l=gs.toDateObject(n),this.trigger=s.flatMap((u)=>u.getElementsToTriggerPopup()),!d){if(this.#P(),this.#r.hidden=!0,c)this.#j()}}#P(){if(this.#m)return;this.#m=new AbortController;let{signal:t}=this.#m;for(let e of this.trigger)e.addEventListener("click",this.#n,{signal:t}),e.addEventListener("pointerenter",this.#i,{signal:t}),e.addEventListener("pointerleave",this.#s,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#h)e.container?.addEventListener("keydown",this.#e,{signal:t})}#I(){let t=this.#h.find((e)=>e.hasCommentButton);if(!t)return;this.#v=t._normalizePoint(t.commentButtonPosition)}renderCommentButton(){if(this.#p){if(!this.#p.parentNode)this.#T.container.after(this.#p);return}if(!this.#v)this.#I();if(!this.#v)return;let{signal:t}=this.#m=new AbortController,e=this.#T.hasOwnCommentButton,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(!e){let r=this.#p=document.createElement("button");r.className="annotationCommentButton";let a=this.#T.container;r.style.zIndex=parseInt(a.style.zIndex,10)+1,r.tabIndex=0,r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#R(),this.#D(),r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",i,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),a.after(r)}else{this.#p=this.#T.container;for(let r of this.trigger)r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",i,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),r.classList.add("popupTriggerArea")}}#D(){if(this.#T.extraPopupElement&&!this.#T.editor)return;if(!this.#p)this.renderCommentButton();let[t,e]=this.#v,{style:s}=this.#p;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#R(){if(this.#T.extraPopupElement)return;if(!this.#p)this.renderCommentButton();this.#p.style.backgroundColor=this.commentButtonColor||""}get commentButtonColor(){let{color:t,opacity:e}=this.#T.commentData;if(!t)return null;return this.#u._commentManager.makeCommentColor(t,e)}focusCommentButton(){setTimeout(()=>{this.#p?.focus()},0)}getData(){let{richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}=this.#T.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}}get elementBeforePopup(){return this.#p}get comment(){return this.#O||=this.#T.commentText,this.#O}set comment(t){if(t===this.comment)return;this.#T.commentText=this.#O=t}focus(){this.#T.container?.focus()}get parentBoundingClientRect(){return this.#T.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#p)return;this.#p.classList.toggle("selected",t),this.#p.ariaExpanded=e}setSelectedCommentButton(t){this.#p.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;let{x:t,y:e,height:s}=this.#p.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#T.layer.getBoundingClientRect();return[(t-i)/r,(e+s-n)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#v}get commentButtonWidth(){return this.#p.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,s]=this.#y||this.commentButtonPosition.map((l)=>l/100),i=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=i;this.#t.showDialog(null,this,n+e*a,r+s*o,{...t,parentDimensions:i})}render(){if(this.#g)return;let t=this.#g=document.createElement("div");if(t.className="popup",this.#a){let s=t.style.outlineColor=L.makeHexColor(...this.#a);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#x?.str){let s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#x}if(t.append(e),this.#l){let s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),s.dateTime=this.#l.toISOString(),e.append(s)}wn({html:this.#k||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#r.append(t)}get#k(){let t=this.#A,e=this.#o;if(t?.str&&(!e?.str||e.str===t.str))return this.#A.html||null;return null}get#U(){return this.#k?.attributes?.style?.fontSize||0}get#L(){return this.#k?.attributes?.style?.color||null}#F(t){let e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#L,fontSize:this.#U?`calc(${this.#U}px * var(--total-scale-factor))`:""}};for(let n of t.split(`
49
- `))e.push({name:"span",value:n,attributes:i});return s}#V(t){if(t.altKey||t.shiftKey||t.ctrlKey||t.metaKey)return;if(t.key==="Enter"||t.key==="Escape"&&this.#f)this.#j()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){if(s)this.remove(),this.#O=null;else if(e)if(e.deleted)this.remove();else this.#R(),this.#O=e.text;if(t)this.#v=null,this.#I(),this.#D();return}if(s||e?.deleted){this.remove();return}if(this.#P(),this.#w||={contentsObj:this.#o,richText:this.#A},t)this.#c=null;if(e&&e.text)this.#A=this.#F(e.text),this.#l=gs.toDateObject(e.date),this.#o=null;this.#g?.remove(),this.#g=null}resetEdited(){if(!this.#w)return;({contentsObj:this.#o,richText:this.#A}=this.#w),this.#w=null,this.#g?.remove(),this.#g=null,this.#c=null}remove(){if(this.#m?.abort(),this.#m=null,this.#g?.remove(),this.#g=null,this.#E=!1,this.#f=!1,this.#p?.remove(),this.#p=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#B(){if(this.#c!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#u,r=!!this.#d,a=r?this.#d:this.#b;for(let f of this.#h)if(!a||L.intersect(f.data.rect,a)!==null){a=f.data.rect,r=!0;break}let o=L.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=5,h=r?a[2]-a[0]+l:0,c=o[0]+h,d=o[1];this.#c=[100*(c-i)/e,100*(d-n)/s];let{style:u}=this.#r;u.left=`${this.#c[0]}%`,u.top=`${this.#c[1]}%`}#j(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}if(this.#f=!this.#f,this.#f)this.#C(),this.#r.addEventListener("click",this.#n),this.#r.addEventListener("keydown",this.#e);else this.#S(),this.#r.removeEventListener("click",this.#n),this.#r.removeEventListener("keydown",this.#e)}#C(){if(!this.#g)this.render();if(!this.isVisible)this.#B(),this.#r.hidden=!1,this.#r.style.zIndex=parseInt(this.#r.style.zIndex,10)+1000;else if(this.#f)this.#r.classList.add("focused")}#S(){if(this.#r.classList.remove("focused"),this.#f||!this.isVisible)return;this.#r.hidden=!0,this.#r.style.zIndex=parseInt(this.#r.style.zIndex,10)-1000}forceHide(){if(this.#E=this.isVisible,!this.#E)return;this.#r.hidden=!0}maybeShow(){if(this.#t)return;if(this.#P(),!this.#E)return;if(!this.#g)this.#C();this.#E=!1,this.#r.hidden=!1}get isVisible(){return!this.#t&&this.#r.hidden===!1}}class xi extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Y.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}if(!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class kr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=this.#t=this.svgFactory.createElement("svg:line");if(n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Lr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");if(r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Nr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");if(r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ei extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:n,height:r}=this;if(!e)return this.container;let a=this.svgFactory.create(n,r,!0),o=[];for(let h=0,c=e.length;h<c;h+=2){let d=e[h]-t[0],u=t[3]-e[h+1];o.push(`${d},${u}`)}o=o.join(" ");let l=this.#t=this.svgFactory.createElement(this.svgElementName);if(l.setAttribute("points",o),l.setAttribute("stroke-width",s.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!i&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Fr extends Ei{constructor(t){super(t);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Br extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){if(this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}}class Bs extends ft{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Y.HIGHLIGHT:Y.INK}#s(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#s(e,t),l=this.svgFactory.create(a,o,!0),h=this.#t=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let c of s){let d=this.svgFactory.createElement(this.svgElementName);this.#e.push(d),d.setAttribute("points",c.join(",")),h.append(d)}if(!n&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:s,rect:i}=t,n=this.#t;if(e>=0)n.setAttribute("stroke-width",e||1);if(s)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",s[r].join(","));if(i){let{transform:r,width:a,height:o}=this.#s(this.data.rotation,i);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ti extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=Y.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class _r extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("underlineAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Hr extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("squigglyAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ur extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("strikeoutAnnotation"),t){let s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ci extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=Y.STAMP}render(){if(this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class jr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0});let{fileId:e,file:s}=this.data;this.filename=s.filename,this.content=s.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,s;if(e.hasAppearance||e.fillAlpha===0)s=document.createElement("div");else if(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1)s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`;s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;let{isMac:i}=ot.platform;if(t.addEventListener("keydown",(n)=>{if(n.key==="Enter"&&(i?n.metaKey:n.ctrlKey))this.#e()}),!e.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();else s.classList.add("popupTriggerArea");return t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}async#e(){let{fileId:t,filename:e,content:s}=this,i=await this.linkService.getAttachmentContent(t)||s;if(i)this.downloadManager?.openOrDownloadData(i,e)}}class Ii extends ft{#t=new AbortController;#e=null;#s=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");let{filename:t}=this.data.richMedia,e=document.createElement("button");return e.className="mediaPlayButton",e.type="button",e.title=e.ariaLabel=t,e.addEventListener("click",()=>this.#i(e),{signal:this.#t.signal}),this.container.append(e),this.container}async#i(t){let{fileId:e,filename:s,contentType:i}=this.data.richMedia;t.disabled=!0;let n;try{n=await this.linkService.getAttachmentContent(e)}catch{return}finally{t.disabled=!1}if(!n||!t.isConnected)return;let{signal:r}=this.#t,a=URL.createObjectURL(new Blob([n],{type:i}));this.#e=a;let o=i.startsWith("audio/"),l=document.createElement(o?"audio":"video");if(this.#s=l,l.className="mediaContent",this._setBackgroundColor(l),l.src=a,l.title=s,l.controls=!0,l.autoplay=!0,l.tabIndex=0,o){let h=!1,c=!1,d=()=>{l.controls=h||c};this.container.addEventListener("pointerenter",()=>{h=!0,d()},{signal:r}),this.container.addEventListener("pointerleave",()=>{h=!1,d()},{signal:r}),this.container.addEventListener("focusin",()=>{c=!0,d()},{signal:r}),this.container.addEventListener("focusout",()=>{c=!1,d()},{signal:r})}l.addEventListener("emptied",()=>this.#n(a),{once:!0,signal:r}),t.replaceWith(l),l.play().catch(()=>{})}#n(t=this.#e){if(t&&t===this.#e)URL.revokeObjectURL(t),this.#e=null}destroy(){if(this.#t.abort(),this.#s)this.#s.pause(),this.#s.removeAttribute("src"),this.#s.load(),this.#s=null;this.#n()}}class Pi{#t=null;#e=null;#s=null;#i=new Map;#n=null;#a=null;#r=[];#o=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#t=e,this.#e=s,this.#n=a||null,this.#a=l||null,this.#s=h||new Ms,this.page=n,this.viewport=r,this._annotationEditorUIManager=i,this._commentManager=o||null}hasEditableAnnotations(){return this.#i.size>0}async render(t){let{annotations:e,optionalContentConfig:s}=t,i=this.div;ge(i,this.viewport);let n=new Map,r=[],a={data:null,layer:i,linkService:this.#a,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new We,annotationStorage:this.#s,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let o of e){if(o.noHTML)continue;let l=o.annotationType===gt.POPUP;if(!l){if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue}else{let d=n.get(o.id);if(!d)continue;if(!this._commentManager){r.push(o);continue}a.elements=d}a.data=o;let h=us.create(a);if(!h.isRenderable)continue;if(!l){if(this.#r.push(h),o.popupRef)n.getOrInsertComputed(o.popupRef,Ie).push(h)}let c=h.render();if(o.hidden)c.style.visibility="hidden";if(h.updateOC(s),h._isEditable)this.#i.set(h.data.id,h),this._annotationEditorUIManager?.renderAnnotationElement(h)}await this.#l();for(let o of r){let l=a.elements=n.get(o.id);a.data=o;let h=us.create(a);if(!h.isRenderable)continue;let c=h.render();if(h.contentElement.id=`${xe}${o.id}`,o.hidden)c.style.visibility="hidden";l.at(-1).container.after(c)}this.#h()}async#l(){if(this.#r.length===0)return;this.div.replaceChildren();let t=[];if(!this.#o){this.#o=!0;for(let{contentElement:s,data:{hidden:i,id:n,oc:r}}of this.#r){let a=s.id=`${xe}${n}`,o=s.localName==="a"&&!i&&!r;t.push(this.#n?.getAriaAttributes(a,{enableLinkOwnership:o}).then((l)=>{if(l)for(let[h,c]of l)s.setAttribute(h,c)}))}}this.#r.sort(({data:{rect:[s,i,n,r]}},{data:{rect:[a,o,l,h]}})=>{if(s===n&&i===r)return 1;if(a===l&&o===h)return-1;let c=r,d=i,u=(i+r)/2,f=h,p=o,g=(o+h)/2;if(u>=f&&g<=d)return-1;if(g>=c&&u<=p)return 1;let m=(s+n)/2,v=(a+l)/2;return m-v});let e=document.createDocumentFragment();for(let s of this.#r)if(e.append(s.container),this._commentManager)(s.extraPopupElement?.popup||s.popup)?.renderCommentButton();else if(s.extraPopupElement)e.append(s.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t){let s=await this.#n?.getAnnotationIds();for(let{contentElement:i}of this.#r){if(s?.has(i.id))continue;this.#t.addPointerInTextLayer(i,!1)}}}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#a,svgFactory:new We,parent:this};for(let s of t){s.borderStyle||=Pi._defaultBorderStyle,e.data=s;let i=us.create(e);if(!i.isRenderable)continue;i.render(),i.contentElement.id=`${xe}${s.id}`,this.#r.push(i)}await this.#l()}update({viewport:t,optionalContentConfig:e}){let s=this.div;this.viewport=t,ge(s,{rotation:t.rotation});for(let i of this.#r)i.updateOC(e);this.#h(),s.hidden=!1}destroy(){for(let t of this.#r)t.destroy?.(),this.#t?.removePointerInTextLayer(t.contentElement);this.#r.length=0,this.#i.clear(),this.div.replaceChildren()}#h(){if(!this.#e)return;let t=this.div;for(let[e,s]of this.#e){let i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;if(Array.isArray(s))for(let l of s)l.className="annotationContent",l.ariaHidden=!0;else s.className="annotationContent",s.ariaHidden=!0;let n=[];for(let l of i.children)if(l.nodeName==="CANVAS")n.push(l);for(let l of n)l.remove();let r=Array.isArray(s)?s[0]:s,{firstChild:a}=i;if(!a)i.append(r);else if(!a.classList.contains("annotationContent"))a.before(r);else a.after(r);if(Array.isArray(s)){let l=r;for(let h=1,c=s.length;h<c;h++)l.after(s[h]),l=s[h]}this.#e.delete(e);let o=this.#i.get(e);if(!o)continue;if(o._hasNoCanvas)this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),o._hasNoCanvas=!1;else o.canvas=s}}refreshCanvases(){this.#h()}getEditableAnnotations(){return this.#i.values()}getEditableAnnotation(t){return this.#i.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:s,rotation:i}=t,n=new Er({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#a,annotationStorage:this.#s});return n.render(),n.contentElement.id=`${xe}${s}`,n.createOrUpdatePopup(),this.#r.push(n),n}removeAnnotation(t){let e=this.#r.findIndex((i)=>i.data.id===t);if(e<0)return;let[s]=this.#r.splice(e,1);this.#t?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length===0)return;for(let e of t)e.updateFakeAnnotationElement(this);this.#l()}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return j(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Se.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}var rs=/\r\n?|\n/g;class wt extends H{#t="";#e=`${this.id}-editor`;#s=null;#i;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=wt.prototype,e=(n)=>n.isEmpty(),{TRANSLATE_SMALL:s,TRANSLATE_BIG:i}=ae;return j(this,"_keyboardManager",new Ft([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=Y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"});if(this.color=t.color||wt._defaultColor||H._defaultLineColor,this.#i=t.fontSize||wt._defaultFontSize,!this.annotationElementId)this._uiManager.a11yAlert(H._l10nAlert.freetext);this.canAddComment=!1}static initialize(t,e){H.initialize(t,e);let s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case q.FREETEXT_SIZE:wt._defaultFontSize=e;break;case q.FREETEXT_COLOR:wt._defaultColor=e;break}}updateParams(t,e){switch(t){case q.FREETEXT_SIZE:this.#n(e);break;case q.FREETEXT_COLOR:this.#a(e);break}}static get defaultPropertiesToUpdate(){return[[q.FREETEXT_SIZE,wt._defaultFontSize],[q.FREETEXT_COLOR,wt._defaultColor||H._defaultLineColor]]}get propertiesToUpdate(){return[[q.FREETEXT_SIZE,this.#i],[q.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new ze(this),[["colorPicker",this._colorPicker]]}get colorType(){return q.FREETEXT_COLOR}#n(t){let e=(i)=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-this.#i)*this.parentScale),this.#i=i,this.#o()},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:q.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#a(t){let e=(i)=>{this.color=i,this.onUpdatedColor()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:q.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-wt._internalPadding*t,-(wt._internalPadding+this.#i)*t]}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(!this.isAttachedToDOM)this.parent.add(this)}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let t=this._uiManager.combinedSignal(this.#s);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){if(!super.disableEditMode())return!1;return this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0}focusin(t){if(!this._focusEventsAllowed)return;if(super.focusin(t),t.target!==this.editorDiv)this.editorDiv.focus()}onceAdded(t){if(this.width)return;if(this.enableEditMode(),t)this.editorDiv.focus();if(this._initialOptions?.isCentered)this.center();this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){if(this.isEditing=!1,this.parent)this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing");super.remove()}#r(){let t=[];this.editorDiv.normalize();let e=null;for(let s of this.editorDiv.childNodes){if(e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR")continue;t.push(wt.#l(s)),e=s}return t.join(`
50
- `)}#o(){let[t,e]=this.parentDimensions,s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{let{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}if(this.rotation%180===this.parentRotation%180)this.width=s.width/t,this.height=s.height/e;else this.width=s.height/t,this.height=s.width/e;this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#t,e=this.#t=this.#r().trimEnd();if(t===e)return;let s=(i)=>{if(this.#t=i,!i){this.remove();return}this.#h(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){if(t.target===this.div&&t.key==="Enter")this.enterInEditMode(),t.preventDefault()}editorDivKeydown(t){wt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy||this.annotationElementId)t=this.x,e=this.y;super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,n]=this.parentDimensions;if(this.annotationElementId){let{position:r}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[l,h]=this.pageDimensions,[c,d]=this.pageTranslation,u,f;switch(this.rotation){case 0:u=t+(r[0]-c)/l,f=e+this.height-(r[1]-d)/h;break;case 90:u=t+(r[0]-c)/l,f=e-(r[1]-d)/h,[a,o]=[o,-a];break;case 180:u=t-this.width+(r[0]-c)/l,f=e-(r[1]-d)/h,[a,o]=[-a,-o];break;case 270:u=t+(r[0]-c-this.height*h)/l,f=e+(r[1]-d-this.width*l)/h,[a,o]=[-o,a];break}this.setAt(u*i,f*n,a,o)}else this._moveAfterPaste(t,e);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(rs,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();let i=wt.#d(e.getData("text")||"").replaceAll(rs,`
51
- `);if(!i)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!i.includes(`
52
- `)){r.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let u=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(rs,"")),u!==this.editorDiv){let f=l;for(let p of this.editorDiv.childNodes){if(p===u){f=h;continue}f.push(wt.#l(p))}}l.push(a.nodeValue.slice(0,o).replaceAll(rs,""))}else if(a===this.editorDiv){let u=l,f=0;for(let p of this.editorDiv.childNodes){if(f++===o)u=h;u.push(wt.#l(p))}}this.#t=`${l.join(`
53
- `)}${i}${h.join(`
54
- `)}`,this.#h();let c=new Range,d=Math.sumPrecise(l.map((u)=>u.length));for(let{firstChild:u}of this.editorDiv.childNodes)if(u.nodeType===Node.TEXT_NODE){let f=u.nodeValue.length;if(d<=f){c.setStart(u,d),c.setEnd(u,d);break}d-=f}n.removeAllRanges(),n.addRange(c)}#h(){if(this.editorDiv.replaceChildren(),!this.#t)return;for(let t of this.#t.split(`
55
- `)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#d(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=wt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof xi){let{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:l,id:h,popupRef:c,richText:d,contentsObj:u,creationDate:f,modificationDate:p},textContent:g,textPosition:m,parent:{page:{pageNumber:v}}}=t;if(!g?.length)return null;i=t={annotationType:Y.FREETEXT,color:Array.from(a),fontSize:r,value:g.join(`
56
- `),position:m,pageIndex:v-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,popupRef:c,comment:u?.str||null,richText:d,creationDate:f,modificationDate:p}}let n=await super.deserialize(t,e,s);if(n.#i=t.fontSize,n.color=L.makeHexColor(...t.color),n.#t=wt.#d(t.value),n._initialData=i,t.comment)n.setCommentData(t);return n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=H._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#i,value:this.#u()});if(this.addComment(s),t)return s.isCopy=!0,s;if(this.annotationElementId&&!this.#f(s))return null;return s.id=this.annotationElementId,s}#f(t){let{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:s}=e;s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(let i of this.#t.split(`
57
- `)){let n=document.createElement("div");n.append(i?document.createTextNode(i):document.createElement("br")),e.append(n)}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 _s{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(!t)return;for(let[e,s]of Object.entries(t))if(!e.startsWith("_"))this.updateProperty(e,s)}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(){st("Not implemented")}}class Q extends H{#t=null;#e;_clipPathId=null;_colorPicker=null;_drawId=null;_drawOutlines=null;_focusDrawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#n=null;static#a=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.#r(t),this.#m()}#r({drawOutlines:t,drawId:e,drawingOptions:s,clipPathId:i}){if(this._drawOutlines=t,this._drawingOptions||=s,!this.annotationElementId)this._uiManager.a11yAlert(H._l10nAlert[this.editorType]);if(e>=0)this._drawId=e,this._clipPathId=i??null,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties),this.#l(this.parent);else this._drawId=this.#o(t,this.parent);this.#v(t.box)}#o(t,e){let{id:s,clipPathId:i}=e.drawLayer.draw(Q._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,this.constructor._hasClipPath);if(this.constructor._hasClipPath)this._clipPathId=i;return this.#l(e),s}#l(t){let e=this._drawOutlines.getFocusSVGProperties(this.#f);if(e)this._focusDrawId=t.drawLayer.drawOutline(e,this._drawOutlines.focusMustRemoveSelfIntersections)}#h(t=this.#f){if(this._focusDrawId===null)return;this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(t))}#u(t){if(this._focusDrawId!==null)this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:t})}#d(){let{parent:t,_drawId:e,_focusDrawId:s,_isVisible:i}=this;if(!t||e===null)return;let n={hidden:!i};if(t.drawLayer.updateProperties(e,{rootClass:n}),s!==null)t.drawLayer.updateProperties(s,{rootClass:n})}static _mergeSVGProperties(t,e){let s=new Set(Object.keys(t));for(let[i,n]of Object.entries(e))if(s.has(i))Object.assign(t[i],n);else t[i]=n;return t}static getDefaultDrawingOptions(t){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}get#f(){return(this.parentRotation-this._drawRotation+360)%360}static updateDefaultParams(t,e){let s=this.typesMap.get(t);if(s)this._defaultDrawingOptions.updateProperty(s,e);if(this._currentParent)Q.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}updateParams(t,e){let s=this.constructor.typesMap.get(t);if(s)this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){let i=this._drawingOptions,n=i[e],r=(a)=>{i.updateProperty(e,a);let o=this._drawOutlines.updateProperty(e,a);if(o)this.#v(o);if(this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType)this.onUpdatedColor();else if(t===this.opacityType)this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e,s=this.colorAndOpacityType){let i=this.constructor.typesMap.get(this.colorType),n=this._opacityName,r=this._drawingOptions,a=r[i],o=r[n],l=(h,c)=>{r.updateProperty(i,h),r.updateProperty(n,c),this._drawOutlines.updateProperty(i,h),this._drawOutlines.updateProperty(n,c),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,t,e),undo:l.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:s,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(this.#p()),{bbox:this.#y()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(this.#p()),{bbox:this.#y()})),this.#h()}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#y()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#y()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}get _mustBeDisabledOnCommit(){return!0}commit(){if(super.commit(),this._mustBeDisabledOnCommit)this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(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._uiManager.removeShouldRescale(this),this.#g(),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#m(),this.#v(this._drawOutlines.box),!this.isAttachedToDOM)this.parent.add(this)}setParent(t){let e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),this.#g();else if(t)this._uiManager.addShouldRescale(this),this.#m(t),e=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(t),this.#d(),e)this.select()}#g(){if(this._drawId===null||!this.parent)return;let{drawLayer:t}=this.parent;if(t.remove(this._drawId),this._drawId=null,this._focusDrawId!==null)t.remove(this._focusDrawId),this._focusDrawId=null;this._drawingOptions.reset()}#m(t=this.parent){if(this._drawId!==null&&this.parent===t)return;if(this._drawId!==null){let{drawLayer:e}=this.parent;if(e.updateParent(this._drawId,t.drawLayer),this._focusDrawId!==null)e.updateParent(this._focusDrawId,t.drawLayer);return}if(this._drawingOptions.updateAll(),this._drawId=this.#o(this._drawOutlines,t),this._clipPathId&&this.#t)this.#t.style.clipPath=this._clipPathId}#c([t,e,s,i]){let{parentDimensions:[n,r],_drawRotation:a}=this;switch(a){case 90:return[e,1-t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#p(){let{x:t,y:e,width:s,height:i,parentDimensions:[n,r],_drawRotation:a}=this;switch(a){case 90:return[1-e,t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#v(t){if([this.x,this.y,this.width,this.height]=this.#c(t),this.div)this.fixAndSetPosition(),this.setDims();this._onResized()}#y(t=this.parentRotation){let{x:e,y:s,width:i,height:n,_drawRotation:r,parentDimensions:[a,o]}=this;switch((r*4+t)/90){case 1:return[1-s-n,e,n,i];case 2:return[1-e-i,1-s-n,i,n];case 3:return[s,1-e-i,n,i];case 4:return[e,s-i*(a/o),n*(o/a),i*(a/o)];case 5:return[1-s,e,i*(a/o),n*(o/a)];case 6:return[1-e-n*(o/a),1-s,n*(o/a),i*(a/o)];case 7:return[s-i*(a/o),1-e-n*(o/a),i*(a/o),n*(o/a)];case 8:return[e-i,s-n,i,n];case 9:return[1-s,e-i,n,i];case 10:return[1-e,1-s,i,n];case 11:return[s-n,1-e,n,i];case 12:return[e-n*(o/a),s,n*(o/a),i*(a/o)];case 13:return[1-s-i*(a/o),e-n*(o/a),i*(a/o),n*(o/a)];case 14:return[1-e,1-s-i*(a/o),n*(o/a),i*(a/o)];case 15:return[s,1-e,i*(a/o),n*(o/a)];default:return[e,s,i,n]}}rotate(t=this.parentRotation){if(!this.parent||this._drawId===null)return;let e=(t-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties({bbox:this.#y(t)},this._drawOutlines.updateRotation(e))),this.#h(e)}show(t=this._isVisible){super.show(t),this.#d()}select(){super.select(),this.#u({hovered:!1,selected:!0})}unselect(){super.unselect(),this.#u({selected:!1})}pointerover(){if(!this.isSelected)this.#u({hovered:!0})}pointerleave(){if(!this.isSelected)this.#u({hovered:!1})}onScaleChanging(){if(!this.parent)return;let t=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);if(t)this.#v(t)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;if(this._isCopy)t=this.x,e=this.y;let s=super.render();if(this.constructor._hasDrawClass)s.classList.add("draw");let i=this.#t=document.createElement("div");if(s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this._clipPathId)i.style.clipPath=this._clipPathId;if(Tn(this,i,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy)this._moveAfterPaste(t,e);return s}static createDrawerInstance(t){st("Not implemented")}static _getDrawingTarget(t,{target:e}){return e}static _getPointerCoords({offsetX:t,offsetY:e,clientX:s,clientY:i},n=null){if(!n)return[t,e];let r=s-n.clientX,a=i-n.clientY;switch(this._currentParent.viewport.rotation){case 90:[r,a]=[a,-r];break;case 180:[r,a]=[-r,-a];break;case 270:[r,a]=[-a,r];break}return[n.offsetX+r,n.offsetY+a]}static _addDrawingListeners(t,e){}static _endDrawingSession(t=!1){return this._currentParent.endDrawingSession(t)}static startDrawing(t,e,s,i){let{pointerId:n,pointerType:r}=i;if(at.isInitializedAndDifferentPointerType(r))return;let a=this._getDrawingTarget(t,i),[o,l]=this._getPointerCoords(i),{viewport:{rotation:h}}=t,{x:c,y:d,width:u,height:f}=a.getBoundingClientRect(),p=Q.#i=new AbortController,g=t.combinedSignal(p);if(at.setPointer(r,n),window.addEventListener("pointerup",(y)=>{if(at.isSamePointerIdOrRemove(y.pointerId))this._endDraw(y)},{signal:g}),window.addEventListener("pointercancel",(y)=>{if(at.isSamePointerIdOrRemove(y.pointerId))this._endDrawingSession()},{signal:g}),window.addEventListener("pointerdown",(y)=>{if(!at.isSamePointerType(y.pointerType))return;if(at.initializeAndAddPointerId(y.pointerId),Q.#s.isCancellable())if(Q.#s.removeLastElement(),Q.#s.isEmpty())this._endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",zt,{signal:g}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),a.addEventListener("touchmove",(y)=>{if(at.isSameTimeStamp(y.timeStamp))At(y)},{signal:g}),this._addDrawingListeners(a,g),t.toggleDrawing(),e._editorUndoBar?.hide(),Q.#s){t.drawLayer.updateProperties(this._currentDrawId,Q.#s.startNew(o,l,u,f,h));return}e.updateUIForDefaultProperties(this),Q.#s=this.createDrawerInstance({x:o,y:l,box:[c,d,u,f],rotation:h,parent:t,isLTR:s}),Q.#n=this.getDefaultDrawingOptions(),this._currentParent=t;let{id:m,clipPathId:v}=t.drawLayer.draw(this._mergeSVGProperties(Q.#n.toSVGProperties(),Q.#s.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=m,Q.#a=this._hasClipPath?v:null}static _drawMove(t){if(at.isSameTimeStamp(t.timeStamp),!Q.#s)return;if(!at.isSamePointerId(t.pointerId))return;if(at.isUsingMultiplePointers()){this._endDraw(t);return}let e,s=t.getCoalescedEvents?.();if(s?.length){let i=[];for(let n of s)i.push(...this._getPointerCoords(n,t));e=Q.#s.addPoints(i)}else e=Q.#s.add(...this._getPointerCoords(t));this._currentParent.drawLayer.updateProperties(this._currentDrawId,e),at.setTimeStamp(t.timeStamp),At(t)}static _cleanup(t){if(t)this._currentDrawId=-1,this._currentParent=null,Q.#s=null,Q.#n=null,Q.#a=null,at.clearTimeStamp();if(Q.#i)Q.#i.abort(),Q.#i=null,at.clearPointerIds()}static _endDraw(t){let e=this._currentParent;if(!e)return;if(e.toggleDrawing(!0),this._cleanup(!1),e.drawLayer.updateProperties(this._currentDrawId,t?.target===e.div?Q.#s.end(...this._getPointerCoords(t)):Q.#s.end()),this.supportMultipleDrawings){let s=Q.#s,i=this._currentDrawId,n=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:q.DRAW_STEP});return}this.endDrawing(!1)}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(q.DRAW_STEP),!Q.#s.isEmpty()){let{pageDimensions:[s,i],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:Q.#a,drawOutlines:Q.#s.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:Q.#n,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,r,a){st("Not implemented")}static async deserialize(t,e,s){let{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,i,n,this._INNER_MARGIN,t,s),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#r({drawOutlines:o}),l.#m(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return this._drawOutlines.serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class B{static PRECISION=0.0001;focusOutline=null;toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){st("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}static _rescale(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}class ue{#t;#e=[];#s;#i;#n=[];#a=new Float32Array(18);#r;#o;#l;#h;#u;#d;#f=[];static#g=8;static#m=2;static#c=ue.#g+ue.#m;constructor(t,e,s,i,n,r,a=0){this.#t=s,this.#d=n*i,this.#i=r,this.#a.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#h=ue.#g*i,this.#l=ue.#c*i,this.#u=i,this.#f.push(t,e)}isEmpty(){return isNaN(this.#a[8])}isCancellable(){return this.#f.length<=10}removeLastElement(){return this.#a.fill(NaN),this.#n.length=this.#e.length=this.#f.length=0,{path:{d:""}}}#p(){let t=this.#a.subarray(4,6),e=this.#a.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#o+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#o+(e[1]-t[1])/2-i)/r]}add(t,e){this.#r=t,this.#o=e;let[s,i,n,r]=this.#t,[a,o,l,h]=this.#a.subarray(8,12),c=t-l,d=e-h,u=Math.hypot(c,d);if(u<this.#l)return!1;let f=u-this.#h,p=f/u,g=p*c,m=p*d,v=a,y=o;a=l,o=h,l+=g,h+=m,this.#f?.push(t,e);let S=-m/f,A=g/f,b=S*this.#d,w=A*this.#d;if(this.#a.set(this.#a.subarray(2,8),0),this.#a.set([l+b,h+w],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([l-b,h-w],16),isNaN(this.#a[6])){if(this.#n.length===0)this.#a.set([a+b,o+w],2),this.#n.push(NaN,NaN,NaN,NaN,(a+b-s)/n,(o+w-i)/r),this.#a.set([a-b,o-w],14),this.#e.push(NaN,NaN,NaN,NaN,(a-b-s)/n,(o-w-i)/r);return this.#a.set([v,y,a,o,l,h],6),!this.isEmpty()}if(this.#a.set([v,y,a,o,l,h],6),Math.abs(Math.atan2(y-o,v-a)-Math.atan2(m,g))<Math.PI/2)return[a,o,l,h]=this.#a.subarray(2,6),this.#n.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/n,((o+h)/2-i)/r),[a,o,v,y]=this.#a.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((v+a)/2-s)/n,((y+o)/2-i)/r),!0;return[v,y,a,o,l,h]=this.#a.subarray(0,6),this.#n.push(((v+5*a)/6-s)/n,((y+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),[l,h,a,o,v,y]=this.#a.subarray(12,18),this.#e.push(((v+5*a)/6-s)/n,((y+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),!0}toSVGPath(){if(this.isEmpty())return"";let t=this.#n,e=this.#e;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#v();let s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)if(isNaN(t[i]))s.push(`L${t[i+4]} ${t[i+5]}`);else s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)if(isNaN(e[i]))s.push(`L${e[i+4]} ${e[i+5]}`);else s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#y(s),s.join(" ")}#v(){let[t,e,s,i]=this.#t,[n,r,a,o]=this.#p();return`M${(this.#a[2]-t)/s} ${(this.#a[3]-e)/i} L${(this.#a[4]-t)/s} ${(this.#a[5]-e)/i} L${n} ${r} L${a} ${o} L${(this.#a[16]-t)/s} ${(this.#a[17]-e)/i} L${(this.#a[14]-t)/s} ${(this.#a[15]-e)/i} Z`}#y(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){let[e,s,i,n]=this.#t,r=this.#a.subarray(4,6),a=this.#a.subarray(16,18),[o,l,h,c]=this.#p();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/i} ${(a[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new Mi(t,e,s,i,n,r)}getOutlines(){let t=this.#n,e=this.#e,s=this.#a,[i,n,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let c=0,d=o.length-2;c<d;c+=2)o[c]=(this.#f[c]-i)/r,o[c+1]=(this.#f[c+1]-n)/a;if(o[o.length-2]=(this.#r-i)/r,o[o.length-1]=(this.#o-n)/a,isNaN(s[6])&&!this.isEmpty())return this.#A(o);let l=new Float32Array(this.#n.length+24+this.#e.length),h=t.length;for(let c=0;c<h;c+=2){if(isNaN(t[c])){l[c]=l[c+1]=NaN;continue}l[c]=t[c],l[c+1]=t[c+1]}h=this.#w(l,h);for(let c=e.length-6;c>=6;c-=6)for(let d=0;d<6;d+=2){if(isNaN(e[c+d])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[c+d],l[h+1]=e[c+d+1],h+=2}return this.#x(l,h),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#i)}#A(t){let e=this.#a,[s,i,n,r]=this.#t,[a,o,l,h]=this.#p(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(c,t,this.#t,this.#u,this.#s,this.#i)}#x(t,e){let s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#w(t,e){let s=this.#a.subarray(4,6),i=this.#a.subarray(16,18),[n,r,a,o]=this.#t,[l,h,c,d]=this.#p();return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o],e),e+=24}}class Mi extends B{#t;#e=new Float32Array(4);#s;#i;#n;#a;#r;constructor(t,e,s,i,n,r){super();this.#r=t,this.#n=e,this.#t=s,this.#a=i,this.#s=n,this.#i=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);let[a,o,l,h]=this.#e;for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-a)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-a)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){let t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){let r=s-t,a=i-e,o,l;switch(n){case 0:o=B._rescale(this.#r,t,i,r,-a),l=B._rescale(this.#n,t,i,r,-a);break;case 90:o=B._rescaleAndSwap(this.#r,t,e,r,a),l=B._rescaleAndSwap(this.#n,t,e,r,a);break;case 180:o=B._rescale(this.#r,s,e,-r,a),l=B._rescale(this.#n,s,e,-r,a);break;case 270:o=B._rescaleAndSwap(this.#r,s,i,-r,-a),l=B._rescaleAndSwap(this.#n,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){let e=this.#r,s=e[4],i=e[5],n=[s,i,s,i],r=s,a=i,o=s,l=i,h=t?Math.max:Math.min,c=new Float32Array(4);for(let u=6,f=e.length;u<f;u+=6){let p=e[u+4],g=e[u+5];if(isNaN(e[u])){if(L.pointBoundingBox(p,g,n),a>g)r=p,a=g;else if(a===g)r=h(r,p);if(l<g)o=p,l=g;else if(l===g)o=h(o,p)}else{if(c.set(ee,0),L.bezierBoundingBox(s,i,...e.slice(u,u+6),c),L.rectBoundingBox(...c,n),a>c[1])r=c[0],a=c[1];else if(a===c[1])r=h(r,c[0]);if(l<c[3])o=c[2],l=c[3];else if(l===c[3])o=h(o,c[2])}s=p,i=g}let d=this.#e;d[0]=n[0]-this.#s,d[1]=n[1]-this.#s,d[2]=n[2]-n[0]+2*this.#s,d[3]=n[3]-n[1]+2*this.#s,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,i,n,r,a=0){return new ue(t,e,s,i,n,r,a)}updateThickness(t){let e=this.getNewOutline(t);return this.#r=e.#r,this.#n=e.#n,this.#e.set(e.#e),this.firstPoint=e.firstPoint,this.lastPoint=e.lastPoint,this.#e}getNewOutline(t,e){let[s,i,n,r]=this.#e,[a,o,l,h]=this.#t,c=n*l,d=r*h,u=s*l+a,f=i*h+o,p=this.#n,g=this.newOutliner(p[0]*c+u,p[1]*d+f,this.#t,this.#a,t,this.#i,e??this.#s);for(let m=2,v=p.length;m<v;m+=2)g.add(p[m]*c+u,p[m+1]*d+f);return g.getOutlines()}}function $r(t){return{bbox:t.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:t.isFree},path:{d:t.toSVGPath()}}}function Gr(t,e){let{focusOutline:s}=t;return{bbox:B._rotateBox(s.box,e),root:{"data-main-rotation":e},rootClass:{highlightOutline:!0,free:t.isFree},path:{d:s.toSVGPath()}}}class bs{#t;#e;#s;#i=[];#n=[];constructor(t,e=0,s=0,i=!0){let n=ee.slice(),r=4,a=0.0001;for(let{x:g,y:m,width:v,height:y}of t){let S=Math.floor((g-e)/0.0001)*0.0001,A=Math.ceil((g+v+e)/0.0001)*0.0001,b=Math.floor((m-e)/0.0001)*0.0001,w=Math.ceil((m+y+e)/0.0001)*0.0001,x=[S,b,w,!0],T=[A,b,w,!1];this.#i.push(x,T),L.rectBoundingBox(S,b,A,w,n)}let o=n[2]-n[0]+2*s,l=n[3]-n[1]+2*s,h=n[0]-s,c=n[1]-s,d=i?-1/0:1/0,u=1/0,f=this.#i.at(i?-1:-2),p=[f[0],f[2]];for(let g of this.#i){let[m,v,y,S]=g;if(!S&&i){if(v<u)u=v,d=m;else if(v===u)d=Math.max(d,m)}else if(S&&!i){if(v<u)u=v,d=m;else if(v===u)d=Math.min(d,m)}g[0]=(m-h)/o,g[1]=(v-c)/l,g[2]=(y-c)/l}this.#t=new Float32Array([h,c,o,l]),this.#e=[d,u],this.#s=p}getOutlines(){this.#i.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);let t=[];for(let e of this.#i)if(e[3])t.push(...this.#h(e)),this.#o(e);else this.#l(e),t.push(...this.#h(e));return this.#a(t)}#a(t){let e=[],s=new Set;for(let r of t){let[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){let o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}let i=[],n;while(s.size>0){let r=s.values().next().value,[a,o,l,h,c]=r;s.delete(r);let d=a,u=o;n=[a,l],i.push(n);while(!0){let f;if(s.has(h))f=h;else if(s.has(c))f=c;else break;if(s.delete(f),[a,o,l,h,c]=f,d!==a)n.push(d,u,a,u===o?o:l),d=a;u=u===o?l:o}n.push(d,u)}return new As(i,this.#t,this.#e,this.#s)}#r(t){let e=this.#n,s=0,i=e.length-1;while(s<=i){let n=s+i>>1,r=e[n][0];if(r===t)return n;if(r<t)s=n+1;else i=n-1}return i+1}#o([,t,e]){let s=this.#r(t);this.#n.splice(s,0,[t,e])}#l([,t,e]){let s=this.#r(t);for(let i=s;i<this.#n.length;i++){let[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}for(let i=s-1;i>=0;i--){let[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}}#h(t){let[e,s,i]=t,n=[[e,s,i]],r=this.#r(i);for(let a=0;a<r;a++){let[o,l]=this.#n[a];for(let h=0,c=n.length;h<c;h++){let[,d,u]=n[h];if(l<=d||u<=o)continue;if(d>=o){if(u>l)n[h][1]=l;else{if(c===1)return[];n.splice(h,1),h--,c--}continue}if(n[h][2]=o,u>l)n.push([e,l,u])}}return n}}class As extends B{#t;#e=null;#s;constructor(t,e,s,i){super();this.#s=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}static build(t,e){let s=new bs(t,0.001).getOutlines();return s.#e=t,s.focusOutline=new bs(t,0.0025,0.001,e).getOutlines(),s}get isFree(){return!1}get defaultSVGProperties(){return $r(this)}getFocusSVGProperties(t){return Gr(this,t)}updateRotation(t){return{root:{"data-main-rotation":t}}}serializeQuadPoints([t,e],[s,i]){let n=this.#e,r=new Float32Array(n.length*8),a=0;for(let{x:o,y:l,width:h,height:c}of n){let d=o*s+t,u=(1-l)*i+e;r[a]=r[a+4]=d,r[a+1]=r[a+3]=u,r[a+2]=r[a+6]=d+h*s,r[a+5]=r[a+7]=u-c*i,a+=8}return r}toSVGPath(){let t=[];for(let e of this.#s){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){let r=e[n],a=e[n+1];if(r===s)t.push(`V${a}`),i=a;else if(a===i)t.push(`H${r}`),s=r}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){let r=[],a=s-t,o=i-e;for(let l of this.#s){let h=Array(l.length);for(let c=0;c<l.length;c+=2)h[c]=t+l[c]*a,h[c+1]=i-l[c+1]*o;r.push(h)}return r}get box(){return this.#t}}class Hs extends ue{newFreeDrawOutline(t,e,s,i,n,r){return new Oi(t,e,s,i,n,r)}}class Vr{#t;#e;constructor(t,e,s,i,n,r,a){this.#t=new Hs(t,e,s,i,n,r,a),this.#e=n}add(t,e){return this.#t.add(t,e)?{path:{d:this.#t.toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=this.#t.add(t[s],t[s+1])||e;return e?{path:{d:this.#t.toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return this.#t.isEmpty()}isCancellable(){return this.#t.isCancellable()}removeLastElement(){return this.#t.removeLastElement()}updateProperty(t,e){return null}getOutlines(){let t=this.#t.getOutlines();return t.buildFocusOutline(2*this.#e),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:this.#t.toSVGPath()}}}}class Oi extends Mi{static#t=1.5;newOutliner(t,e,s,i,n,r,a=0){return new Hs(t,e,s,i,n,r,a)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+Oi.#t,0.0025)}get defaultSVGProperties(){return $r(this)}getFocusSVGProperties(t){return Gr(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;let s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}class Ri extends _s{constructor(t=null){super();super.updateProperties(t)}updateSVGProperty(t,e){if(t!=="thickness")super.updateSVGProperty(t,e)}clone(){let t=new Ri;return t.updateAll(this),t}}class Vt extends Q{#t=null;#e=0;#s=null;#i=0;#n="";#a="";static _DEFAULT_OPACITY=1;static _DEFAULT_THICKNESS=12;static _defaultDrawingOptions=null;static _type="highlight";static _editorType=Y.HIGHLIGHT;static get _keyboardManager(){let t=Vt.prototype;return j(this,"_keyboardManager",new Ft([[["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"});this.#t=t.anchorNode||null,this.#e=t.anchorOffset||0,this.#s=t.focusNode||null,this.#i=t.focusOffset||0,this.#n=t.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""),this.#a=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions||=new Ri({fill:e.highlightColors?.values().next().value||"#fff066","fill-opacity":Vt._DEFAULT_OPACITY,thickness:Vt._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get typesMap(){return j(this,"typesMap",new Map([[q.HIGHLIGHT_COLOR,"fill"],[q.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(t){let{boxes:e,drawOutlines:s}=t;if(!e&&!s)return;if(this._drawingOptions||=t.drawingOptions||Vt.getDefaultDrawingOptions(),e)t={...t,drawOutlines:As.build(e,this._uiManager.direction==="ltr")};super._addOutlines(t)}get colorType(){return q.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:this.#n}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}translateInPage(t,e){}get toolbarPosition(){return this.#r(this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return this.#r(this._drawOutlines.firstPoint)}#r([t,e]){let[s,i,n,r]=this._drawOutlines.box;return[(t-s)/n,(e-i)/r]}updateParams(t,e){switch(t){case q.HIGHLIGHT_COLOR:this._updateColorAndOpacity(e,Vt._DEFAULT_OPACITY,t),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);break;case q.HIGHLIGHT_THICKNESS:super.updateParams(t,e),this._reportTelemetry({action:"thickness_changed",thickness:e},!0);break}}get propertiesToUpdate(){let t=super.propertiesToUpdate;return t.push([q.HIGHLIGHT_FREE,this._drawOutlines.isFree]),t}get toolbarButtons(){if(this._uiManager.highlightColors)return this._colorPicker=new jt({editor:this}),[["colorPicker",this._colorPicker]];return super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(t,e){return super.getRect(t,e,this._drawRotation)}onceAdded(t){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(t)this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;let t=super.render();if(this.#a)t.setAttribute("aria-label",this.#a),t.setAttribute("role","mark");if(this._drawOutlines.isFree)t.classList.add("free");else t.addEventListener("keydown",this.#o.bind(this),{signal:this._uiManager._signal});return this.enableEditing(),t}#o(t){Vt._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#l(!0);break;case 1:case 3:this.#l(!1);break}}#l(t){if(!this.#t)return;let e=window.getSelection();if(t)e.setPosition(this.#t,this.#e);else e.setPosition(this.#s,this.#i)}unselect(){if(super.unselect(),!this._drawOutlines.isFree)this.#l(!1)}static createDrawerInstance({x:t,y:e,box:s,parent:i,isLTR:n}){return new Vr(t,e,s,i.scale,this._defaultDrawingOptions.thickness/2,n,0.001)}static _getDrawingTarget(t,{target:e}){return e.closest(".textLayer")}static _getPointerCoords({x:t,y:e}){return[t,e]}static _addDrawingListeners(t,e){t.classList.add("free"),e.addEventListener("abort",()=>t.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:e}),window.addEventListener("pointerdown",At,{capture:!0,passive:!1,signal:e})}static _endDrawingSession(t=!1){return this.endDrawing(t)}createDrawingOptions({color:t,opacity:e,thickness:s}){let{_defaultDrawingOptions:i,_DEFAULT_OPACITY:n}=Vt;this._drawingOptions=Vt.getDefaultDrawingOptions({fill:L.makeHexColor(...t),"fill-opacity":e||n,thickness:s||i.thickness})}static deserializeDraw(t,e,s,i,n,r,a){let{quadPoints:o}=r;if(o){let u=[];for(let f=0,p=o.length;f<p;f+=8)u.push({x:(o[f]-t)/s,y:1-(o[f+1]-e)/i,width:(o[f+2]-o[f])/s,height:(o[f+1]-o[f+5])/i});return As.build(u,a.direction==="ltr")}let l=r.thickness||this._defaultDrawingOptions.thickness,h=(r.inkLists||r.outlines.points)[0],c=new Hs(h[0]-t,i-(h[1]-e),[0,0,s,i],1,l/2,!0,0.001);for(let u=0,f=h.length;u<f;u+=2)c.add(h[u]-t,i-(h[u+1]-e));let d=c.getOutlines();return d.buildFocusOutline(l),d}static async deserialize(t,e,s){let i=null;if(t instanceof Ti){let{data:{quadPoints:r,rect:a,rotation:o,id:l,color:h,opacity:c,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;i=t={annotationType:Y.HIGHLIGHT,color:Array.from(h),opacity:c,quadPoints:r,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:u,comment:f?.str||null,creationDate:p,modificationDate:g}}else if(t instanceof Bs){let{data:{inkLists:r,rect:a,rotation:o,id:l,color:h,borderStyle:{rawWidth:c},popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;i=t={annotationType:Y.HIGHLIGHT,color:Array.from(h),thickness:c,inkLists:r,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:u,comment:f?.str||null,creationDate:p,modificationDate:g}}let n=await super.deserialize(t,e,s);if(n._initialData=i,t.comment)n.setCommentData(t);return n}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=super.serialize(t);if(Object.assign(e,{color:H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(e.rect,this._drawRotation)}),this.addComment(e),this.annotationElementId&&!this.#h(e))return null;return e.id=this.annotationElementId,e}#h(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class zr{#t=new Float64Array(6);#e=new Float64Array(2);#s;#i;#n;#a;#r;#o="";#l=0;#h=new Pe;#u;#d;constructor(t,e,s,i,n,r){this.#u=s,this.#d=i,this.#n=n,this.#a=r,[t,e]=this.#f(t,e);let a=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#i=[{line:a,points:this.#r}],this.#t.set(a,0),this.#e.set([t,e],0)}updateProperty(t,e){if(t==="stroke-width")this.#a=e}#f(t,e){return B._normalizePoint(t,e,this.#u,this.#d,this.#n)}isEmpty(){return!this.#i?.length}isCancellable(){return this.#r.length<=10}add(t,e){if(this.#g(t,e))this.toSVGPath();return{path:{d:this.#m()}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2){if(!this.#g(t[s],t[s+1]))continue;if(e=!0,this.#r.length<=6)this.toSVGPath(),e=!1}if(e)this.toSVGPath();return{path:{d:this.#m()}}}#g(t,e){[t,e]=this.#f(t,e),this.#e.set([t,e],0);let[s,i,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;if(Math.hypot(this.#u*a,this.#d*o)<=2)return!1;if(this.#r.push(t,e),isNaN(s))return this.#t.set([n,r,t,e],2),this.#s.push(NaN,NaN,NaN,NaN,t,e),!0;if(isNaN(this.#t[0]))this.#s.splice(6,6);return this.#t.set([s,i,n,r,t,e],0),this.#s.push(...B.createBezierPoints(s,i,n,r,t,e)),!0}end(t,e){if(t!==void 0&&this.#g(t,e))return{path:{d:this.toSVGPath()}};if(this.#r.length===2)return{path:{d:this.toSVGPath()}};return{path:{d:this.#o}}}startNew(t,e,s,i,n){this.#u=s,this.#d=i,this.#n=n,[t,e]=this.#f(t,e);let r=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#e.set([t,e],0);let a=this.#i.at(-1);if(a)a.line=new Float32Array(a.line),a.points=new Float32Array(a.points);return this.#i.push({line:r,points:this.#r}),this.#t.set(r,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){if(!this.#i)return this.#h.setLastElement(t);return this.#i.push(t),this.#s=t.line,this.#r=t.points,this.#l=0,{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#i)return this.#h.removeLastElement();this.#i.pop(),this.#o="";for(let t=0,e=this.#i.length;t<e;t++){let{line:s,points:i}=this.#i[t];this.#s=s,this.#r=i,this.#l=0,this.toSVGPath()}return{path:{d:this.#o}}}#m(){let t=B.svgRound(this.#e[0]),e=B.svgRound(this.#e[1]);if(this.#r.length===2){let s=B.svgRound(this.#s[4]),i=B.svgRound(this.#s[5]);return`${this.#o} M ${s} ${i} L ${t} ${e}`}return`${this.#o} L ${t} ${e}`}toSVGPath(){let t=B.svgRound(this.#s[4]),e=B.svgRound(this.#s[5]);if(this.#r.length===2)return this.#o=`${this.#o} M ${t} ${e} Z`,this.#o;if(this.#r.length<=6){let i=this.#o.lastIndexOf("M");this.#o=`${this.#o.slice(0,i)} M ${t} ${e}`,this.#l=6}if(this.#r.length===4){let i=B.svgRound(this.#s[10]),n=B.svgRound(this.#s[11]);return this.#o=`${this.#o} L ${i} ${n}`,this.#l=12,this.#o}let s=[];if(this.#l===0)s.push(`M ${t} ${e}`),this.#l=6;for(let i=this.#l,n=this.#s.length;i<n;i+=6){let[r,a,o,l,h,c]=this.#s.slice(i,i+6).map(B.svgRound);s.push(`C${r} ${a} ${o} ${l} ${h} ${c}`)}return this.#o+=s.join(" "),this.#l=this.#s.length,this.#o}getOutlines(t,e,s,i){let n=this.#i.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#i,t,e,s,this.#n,this.#a,i),this.#t=null,this.#s=null,this.#i=null,this.#o=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Pe extends B{#t;#e=0;#s;#i;#n;#a;#r;#o;#l;build(t,e,s,i,n,r,a){this.#n=e,this.#a=s,this.#r=i,this.#o=n,this.#l=r,this.#s=a??0,this.#i=t,this.#d()}get thickness(){return this.#l}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${B.svgRound(e[4])} ${B.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${B.svgRound(e[10])} ${B.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){let[n,r,a,o,l,h]=e.subarray(s,s+6).map(B.svgRound);t.push(`C${n} ${r} ${a} ${o} ${l} ${h}`)}}return t.join("")}serialize([t,e,s,i],n){let r=[],a=[],[o,l,h,c]=this.#u(),d,u,f,p,g,m,v,y,S;switch(this.#o){case 0:S=B._rescale,d=t,u=e+i,f=s,p=-i,g=t+o*s,m=e+(1-l-c)*i,v=t+(o+h)*s,y=e+(1-l)*i;break;case 90:S=B._rescaleAndSwap,d=t,u=e,f=s,p=i,g=t+l*s,m=e+o*i,v=t+(l+c)*s,y=e+(o+h)*i;break;case 180:S=B._rescale,d=t+s,u=e,f=-s,p=i,g=t+(1-o-h)*s,m=e+l*i,v=t+(1-o)*s,y=e+(l+c)*i;break;case 270:S=B._rescaleAndSwap,d=t+s,u=e+i,f=-s,p=-i,g=t+(1-l-c)*s,m=e+(1-o-h)*i,v=t+(1-l)*s,y=e+(1-o)*i;break}for(let{line:A,points:b}of this.#i)r.push(S(A,d,u,f,p,n?Array(A.length):null)),a.push(S(b,d,u,f,p,n?Array(b.length):null));return{lines:r,points:a,rect:[g,m,v,y]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){let h=[],c,d,u,f,p;switch(o){case 0:p=B._rescale,c=-t/s,d=e/i+1,u=1/s,f=-1/i;break;case 90:p=B._rescaleAndSwap,c=-e/i,d=-t/s,u=1/i,f=1/s;break;case 180:p=B._rescale,c=t/s+1,d=-e/i,u=-1/s,f=1/i;break;case 270:p=B._rescaleAndSwap,c=e/i+1,d=t/s+1,u=-1/i,f=-1/s;break}if(!r){r=[];for(let m of a){let v=m.length;if(v===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(v===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}let y=new Float32Array(3*(v-2));r.push(y);let[S,A,b,w]=m.subarray(0,4);y.set([NaN,NaN,NaN,NaN,S,A],0);for(let x=4;x<v;x+=2){let T=m[x],E=m[x+1];y.set(B.createBezierPoints(S,A,b,w,T,E),(x-2)*3),[S,A,b,w]=[b,w,T,E]}}}for(let m=0,v=r.length;m<v;m++)h.push({line:p(r[m].map((y)=>y??NaN),c,d,u,f),points:p(a[m].map((y)=>y??NaN),c,d,u,f)});let g=new this.prototype.constructor;return g.build(h,s,i,1,o,l,n),g}#h(t=this.#l){let e=this.#s+t/2*this.#r;return this.#o%180===0?[e/this.#n,e/this.#a]:[e/this.#a,e/this.#n]}#u(){let[t,e,s,i]=this.#t,[n,r]=this.#h(0);return[t+n,e+r,s-2*n,i-2*r]}#d(){let t=this.#t=de.slice();for(let{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)L.pointBoundingBox(i[a],i[a+1],t);continue}let n=i[4],r=i[5];for(let a=6,o=i.length;a<o;a+=6){let[l,h,c,d,u,f]=i.subarray(a,a+6);L.bezierBoundingBox(n,r,l,h,c,d,u,f,t),n=u,r=f}}let[e,s]=this.#h();t[0]=ut(t[0]-e,0,1),t[1]=ut(t[1]-s,0,1),t[2]=ut(t[2]+e,0,1),t[3]=ut(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,s]=this.#h();this.#l=t;let[i,n]=this.#h(),[r,a]=[i-e,n-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){let[i,n]=this.#h();this.#n=t,this.#a=e,this.#r=s;let[r,a]=this.#h(),o=r-i,l=a-n,h=this.#t;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(B.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,s=0,i=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:i=e/t,n=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${B.svgRound(a)} ${B.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){let[n,r]=this.#h(),[a,o,l,h]=this.#t;if(Math.abs(l-n)<=B.PRECISION||Math.abs(h-r)<=B.PRECISION){let p=t+s/2-(a+l/2),g=e+i/2-(o+h/2);return{path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`,transform:`${this.rotationTransform} translate(${p} ${g})`}}}let c=(s-2*n)/(l-2*n),d=(i-2*r)/(h-2*r),u=l/s,f=h/i;return{path:{"transform-origin":`${B.svgRound(a)} ${B.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${f}) translate(${B.svgRound(n)} ${B.svgRound(r)}) scale(${c} ${d}) translate(${B.svgRound(-n)} ${B.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){let[n,r]=this.#h(),a=this.#t,[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(h-n)<=B.PRECISION||Math.abs(c-r)<=B.PRECISION){let g=t+s/2-(o+h/2),m=e+i/2-(l+c/2);for(let{line:v,points:y}of this.#i)B._translate(v,g,m,v),B._translate(y,g,m,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(s-2*n)/(h-2*n),u=(i-2*r)/(c-2*r),f=-d*(o+n)+t+n,p=-u*(l+r)+e+r;if(d!==1||u!==1||f!==0||p!==0)for(let{line:g,points:m}of this.#i)B._rescale(g,f,p,d,u,g),B._rescale(m,f,p,d,u,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){let[i,n]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#n===i&&this.#a===n)for(let{line:l,points:h}of this.#i)B._translate(l,a,o,l),B._translate(h,a,o,h);else{let l=this.#n/i,h=this.#a/n;this.#n=i,this.#a=n;for(let{line:c,points:d}of this.#i)B._rescale(c,a,o,l,h,c),B._rescale(d,a,o,l,h,d);r[2]*=l,r[3]*=h}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${B.svgRound(t[0])} ${B.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Us extends _s{constructor(t){super();this._viewParameters=t,super.updateProperties({fill:"none",stroke:H._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 Us(this._viewParameters);return t.updateAll(this),t}}class Di extends Q{static _type="ink";static _editorType=Y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new Us(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,"typesMap",new Map([[q.INK_THICKNESS,"stroke-width"],[q.INK_COLOR,"stroke"],[q.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:t,y:e,box:[,,s,i],rotation:n}){return new zr(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,r){return Pe.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof Bs){let{data:{inkLists:r,rect:a,rotation:o,id:l,color:h,opacity:c,borderStyle:{rawWidth:d},popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;i=t={annotationType:Y.INK,color:Array.from(h),thickness:d,opacity:c,paths:{points:r},boxes:null,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}let n=await super.deserialize(t,e,s);if(n._initialData=i,t.comment)n.setCommentData(t);return n}get toolbarButtons(){return this._colorPicker||=new ze(this),[["colorPicker",this._colorPicker]]}get colorType(){return q.INK_COLOR}get colorAndOpacityType(){return q.INK_COLOR_AND_OPACITY}get opacityType(){return q.INK_OPACITY}updateParams(t,e){if(t===q.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===q.INK_COLOR_AND_OPACITY){super.updateDefaultParams(q.INK_COLOR,e.color),super.updateDefaultParams(q.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:s}=this;e.updateSVGProperty("stroke-width"),s.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:s}){this._drawingOptions=Di.getDefaultDrawingOptions({stroke:L.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:H._colorManager.convert(i),opacity:n,thickness:r,paths:{lines:e,points:s}});if(this.addComment(a),t)return a.isCopy=!0,a;if(this.annotationElementId&&!this.#t(a))return null;return a.id=this.annotationElementId,a}#t(t){let{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class Ss extends Pe{toSVGPath(){let t=super.toSVGPath();if(!t.endsWith("Z"))t+="Z";return t}}var Ro=K(5213),as=8,Ne=3;class ce{static#t={maxDim:512,sigmaSFactor:0.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){if(s-=t,i-=e,s===0)return i>0?0:4;if(s===1)return i+6;return 2-i}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,s,i,n,r,a){let o=this.#e(s,i,n,r);for(let l=0;l<8;l++){let h=(-l+o-a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#n(t,e,s,i,n,r,a){let o=this.#e(s,i,n,r);for(let l=0;l<8;l++){let h=(l+o+a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#a(t,e,s,i){let n=t.length,r=new Int32Array(n);for(let h=0;h<n;h++)r[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)r[h*e]=r[h*e+e-1]=0;for(let h=0;h<e;h++)r[h]=r[e*s-1-h]=0;let a=1,o,l=[];for(let h=1;h<s-1;h++){o=1;for(let c=1;c<e-1;c++){let d=h*e+c,u=r[d];if(u===0)continue;let f=h,p=c;if(u===1&&r[d-1]===0)a+=1,p-=1;else if(u>=1&&r[d+1]===0){if(a+=1,p+=1,u>1)o=u}else{if(u!==1)o=Math.abs(u);continue}let g=[c,h],m=p===c+1,v={isHole:m,points:g,id:a,parent:0};l.push(v);let y;for(let I of l)if(I.id===o){y=I;break}if(!y)v.parent=m?o:0;else if(y.isHole)v.parent=m?y.parent:o;else v.parent=m?o:y.parent;let S=this.#i(r,e,h,c,f,p,0);if(S===-1){if(r[d]=-a,r[d]!==1)o=Math.abs(r[d]);continue}let A=this.#s[2*S],b=this.#s[2*S+1],w=h+A,x=c+b;f=w,p=x;let T=h,E=c;while(!0){let I=this.#n(r,e,T,E,f,p,1);A=this.#s[2*I],b=this.#s[2*I+1];let C=T+A,O=E+b;g.push(O,C);let D=T*e+E;if(r[D+1]===0)r[D]=-a;else if(r[D]===1)r[D]=a;if(C===h&&O===c&&T===w&&E===x){if(r[d]!==1)o=Math.abs(r[d]);break}else f=T,p=E,T=C,E=O}}}return l}static#r(t,e,s,i){if(s-e<=4){for(let w=e;w<s-2;w+=2)i.push(t[w],t[w+1]);return}let n=t[e],r=t[e+1],a=t[s-4]-n,o=t[s-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*n,u=o/a,f=1/l,p=Math.atan(u),g=Math.cos(p),m=Math.sin(p),v=f*(Math.abs(g)+Math.abs(m)),y=f*(1-v+v**2),S=Math.max(Math.atan(Math.abs(m+g)*y),Math.atan(Math.abs(m-g)*y)),A=0,b=e;for(let w=e+2;w<s-2;w+=2){let x=Math.abs(d-h*t[w+1]+c*t[w]);if(x>A)b=w,A=x}if(A>(l*S)**2)this.#r(t,e,b+2,i),this.#r(t,b,s,i);else i.push(n,r)}static#o(t){let e=[],s=t.length;return this.#r(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#l(t,e,s,i,n,r){let a=new Float32Array(r**2),o=-2*i**2,l=r>>1;for(let p=0;p<r;p++){let g=(p-l)**2;for(let m=0;m<r;m++)a[p*r+m]=Math.exp((g+(m-l)**2)/o)}let h=new Float32Array(256),c=-2*n**2;for(let p=0;p<256;p++)h[p]=Math.exp(p**2/c);let d=t.length,u=new Uint8Array(d),f=new Uint32Array(256);for(let p=0;p<s;p++)for(let g=0;g<e;g++){let m=p*e+g,v=t[m],y=0,S=0;for(let b=0;b<r;b++){let w=p+b-l;if(w<0||w>=s)continue;for(let x=0;x<r;x++){let T=g+x-l;if(T<0||T>=e)continue;let E=t[w*e+T],I=a[b*r+x]*h[Math.abs(E-v)];y+=E*I,S+=I}}let A=u[m]=Math.round(y/S);f[A]++}return[u,f]}static#h(t){let e=new Uint32Array(256);for(let s of t)e[s]++;return e}static#u(t){let e=t.length,s=new Uint8ClampedArray(e>>2),i=-1/0,n=1/0;for(let a=0,o=s.length;a<o;a++){let l=s[a]=t[a<<2];i=Math.max(i,l),n=Math.min(n,l)}let r=255/(i-n);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-n)*r;return s}static#d(t){let e,s=-1/0,i=-1/0,n=t.findIndex((o)=>o!==0),r=n,a=n;for(e=n;e<256;e++){let o=t[e];if(o>s){if(e-r>i)i=e-r,a=e-1;s=o,r=e}}for(e=a-1;e>=0;e--)if(t[e]>t[e+1])break;return e}static#f(t){let e=t,{width:s,height:i}=t,{maxDim:n}=this.#t,r=s,a=i;if(s>n||i>n){let d=s,u=i,f=Math.log2(Math.max(s,i)/n),p=Math.floor(f);f=f===p?p-1:p;for(let m=0;m<f;m++){r=Math.ceil(d/2),a=Math.ceil(u/2);let v=new OffscreenCanvas(r,a);if(v.getContext("2d").drawImage(t,0,0,d,u,0,0,r,a),d=r,u=a,t!==e)t.close();t=v.transferToImageBitmap()}let g=Math.min(n/r,n/a);r=Math.round(r*g),a=Math.round(a*g)}let l=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,r,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,r,a);let h=l.getImageData(0,0,r,a).data;return[this.#u(h),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),c=200,d=h.font=`${s} ${i} ${c}px ${e}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:v,width:y}=h.measureText(t),S=1.5,A=Math.ceil(Math.max(Math.abs(u)+Math.abs(f)||0,y)*S),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||c,Math.abs(m)+Math.abs(v)||c)*S);l=new OffscreenCanvas(A,b),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,A,b),h.fillStyle="black",h.fillText(t,A*(S-1)/2,b*(3-S)/2);let w=this.#u(h.getImageData(0,0,A,b).data),x=this.#h(w),T=this.#d(x),E=this.#a(w,A,b,T);return this.processDrawnLines({lines:{curves:E,width:A,height:b},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){let[r,a,o]=this.#f(t),[l,h]=this.#l(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),c=this.#d(h),d=this.#a(l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:r,areContours:a}){if(i%180!==0)[e,s]=[s,e];let{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,s/h),f=u/e,p=u/s,g=[];for(let{points:v}of o){let y=r?this.#o(v):v;if(!y)continue;g.push(y);let S=y.length,A=new Float32Array(S),b=new Float32Array(3*(S===2?2:S-2));if(d.push({line:b,points:A}),S===2){A[0]=y[0]*f,A[1]=y[1]*p,b.set([NaN,NaN,NaN,NaN,A[0],A[1]],0);continue}let[w,x,T,E]=y;w*=f,x*=p,T*=f,E*=p,A.set([w,x,T,E],0),b.set([NaN,NaN,NaN,NaN,w,x],0);for(let I=4;I<S;I+=2){let C=A[I]=y[I]*f,O=A[I+1]=y[I+1]*p;b.set(B.createBezierPoints(w,x,T,E,C,O),(I-2)*3),[w,x,T,E]=[T,E,C,O]}}if(d.length===0)return null;let m=a?new Ss:new Pe;return m.build(d,e,s,1,i,a?0:c,n),{outline:m,newCurves:g,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let r=1/0,a=-1/0,o=0;for(let v of t){o+=v.length;for(let y=2,S=v.length;y<S;y++){let A=v[y]-v[y-2];r=Math.min(r,A),a=Math.max(a,A)}}let l;if(r>=-128&&a<=127)l=Int8Array;else if(r>=-32768&&a<=32767)l=Int16Array;else l=Int32Array;let h=t.length,c=as+Ne*h,d=new Uint32Array(c),u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(o-2*h)*l.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=i,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(s??0)),d[u++]=h,d[u++]=l.BYTES_PER_ELEMENT;for(let v of t)d[u++]=v.length-2,d[u++]=v[0],d[u++]=v[1];let f=new CompressionStream("deflate-raw"),p=f.writable.getWriter();await p.ready,p.write(d);let g=l.prototype.constructor;for(let v of t){let y=new g(v.length-2);for(let S=2,A=v.length;S<A;S++)y[S-2]=v[S]-v[S-2];p.write(y)}return p.close(),(await new Response(f.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),n=i.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let r=null,a=0;for await(let y of s)r||=new Uint8Array(new Uint32Array(y.buffer,0,4)[0]),r.set(y,a),a+=y.length;let o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(l!==0)throw Error(`Invalid version: ${l}`);let h=o[2],c=o[3],d=o[4]===0,u=o[5],f=o[6],p=o[7],g=[],m=(as+Ne*f)*Uint32Array.BYTES_PER_ELEMENT,v;switch(p){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(r.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(r.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(r.buffer,m);break}a=0;for(let y=0;y<f;y++){let S=o[Ne*y+as],A=new Float32Array(S+2);g.push(A);for(let b=0;b<Ne-1;b++)A[b]=o[Ne*y+as+b+1];for(let b=0;b<S;b++)A[b+2]=A[b]+v[a++]}return{areContours:d,thickness:u,outlines:g,width:h,height:c}}catch(e){return z(`decompressSignature: ${e}`),null}}}class ki extends _s{constructor(){super();super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){let t=new ki;return t.updateAll(this),t}}class Li extends Us{constructor(t){super(t);super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){let t=new Li(this._viewParameters);return t.updateAll(this),t}}class Jt extends Q{#t=!1;#e=null;#s=null;#i=null;static _type="signature";static _editorType=Y.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"});this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new ki,this._defaultDrawnSignatureOptions=new Li(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!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:s}=this;if(s)this._isCopy=!1,t=this.x,e=this.y;if(super.render(),this._drawId===null)if(this.#s){let{lines:i,mustSmooth:n,areContours:r,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:h,pageHeight:c},rotation:d}=this.parent.viewport,u=ce.processDrawnLines({lines:i,pageWidth:h,pageHeight:c,rotation:d,innerMargin:Jt._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(u,l,a,o)}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(s)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:s,width:i,height:n}=this.#s,r=Math.max(i,n),a=ce.processDrawnLines({lines:{curves:t.map((o)=>({points:o})),thickness:s,width:i,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){let{x:n,y:r}=this,{outline:a}=this.#s=t;this.#t=a instanceof Ss,this.description=s;let o;if(this.#t)o=Jt.getDefaultDrawingOptions();else o=Jt._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness});this._addOutlines({drawOutlines:a,drawingOptions:o});let[,l]=this.pageDimensions,h=e/l;if(h=h>=1?0.5:h,this.width*=h/this.height,this.width>=1)h*=0.9/this.width,this.width=0.9;this.height=h,this.setDims(),this.x=n,this.y=r,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:!!s}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ce.process(t,e,s,i,Jt._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return ce.extractContoursFromText(t,e,s,i,n,Jt._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ce.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:Jt._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){if(t)this._drawingOptions=Jt.getDefaultDrawingOptions();else this._drawingOptions=Jt._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e})}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});if(this.addComment(n),t)n.paths={lines:e,points:s},n.uuid=this.#i,n.isCopy=!0;else n.lines=e;if(this.#e)n.accessibilityData={type:"Figure",alt:this.#e};return n}static deserializeDraw(t,e,s,i,n,r){if(r.areContours)return Ss.deserialize(t,e,s,i,n,r);return Pe.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class Wr extends H{#t=null;#e=null;#s=null;#i=null;#n=null;#a="";#r=null;#o=!1;#l=null;#h=!1;#u=!1;static _type="stamp";static _editorType=Y.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#i=t.bitmapUrl,this.#n=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){H.initialize(t,e)}static isHandlingMimeForPasting(t){return Zs.includes(t)}static paste(t,e){e.pasteEditor({mode:Y.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}}#d(t,e=!1){if(!t){this.remove();return}if(this.#t=t.bitmap,!e)this.#e=t.id,this.#h=t.isSvg;if(t.file)this.#a=t.file.name;this.#m()}#f(){if(this.#s=null,this._uiManager.enableWaiting(!1),!this.#r)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:s}=this._uiManager;if(!s)throw Error("No ML.");if(!await s.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:i,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.length/(n*r)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;if(await this.setGuessedAltText(o),e&&!this.hasAltTextData())this.altTextData={alt:o,decorative:!1};return o}#g(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then((s)=>this.#d(s,!0)).finally(()=>this.#f());return}if(this.#i){let s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then((i)=>this.#d(i)).finally(()=>this.#f());return}if(this.#n){let s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then((i)=>this.#d(i)).finally(()=>this.#f());return}let t=document.createElement("input");t.type="file",t.accept=Zs.join(",");let e=this._uiManager._signal;this.#s=new Promise((s)=>{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.#d(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){if(this.#e){if(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#l)clearTimeout(this.#l),this.#l=null}super.remove()}rebuild(){if(!this.parent){if(this.#e)this.#g();return}if(super.rebuild(),this.div===null)return;if(this.#e&&this.#r===null)this.#g();if(!this.isAttachedToDOM)this.parent.add(this)}onceAdded(t){if(this._isDraggable=!0,t)this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#n||this.#e||this.#o)}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.#o)if(this.#t)this.#m();else this.#g();if(this._isCopy)this._moveAfterPaste(t,e);return this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){let{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);if(e.remove(),s&&this._uiManager.imageManager.isValidId(s)){if(this.#e=s,i)this.#t=i;this.#o=!1,this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;if(this.#l!==null)clearTimeout(this.#l);let t=200;this.#l=setTimeout(()=>{this.#l=null,this.#p()},t)}#m(){let{div:t}=this,{width:e,height:s}=this.#t,[i,n]=this.pageDimensions,r=0.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>0.75*i||s>0.75*n){let o=Math.min(0.75*i/e,0.75*n/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);let a=this.#r=document.createElement("canvas");if(a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/n,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.#p(),!this.#u)this.parent.addUndoableEditor(this),this.#u=!0;if(this._reportTelemetry({action:"inserted_image"}),this.#a)this.div.setAttribute("aria-description",this.#a);if(!this.annotationElementId)this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;let{width:i,height:n}=this.#t,r=new Wt,a=this.#t,o=i,l=n,h=null;if(e){if(i>e||n>e){let b=Math.min(e/i,e/n);o=Math.floor(i*b),l=Math.floor(n*b)}h=document.createElement("canvas");let d=h.width=Math.ceil(o*r.sx),u=h.height=Math.ceil(l*r.sy);if(!this.#h)a=this.#c(d,u);let f=h.getContext("2d");f.filter=this._uiManager.hcmFilter;let p="white",g="#cfcfd8";if(this._uiManager.hcmFilter!=="none")g="black";else if(An.isDarkMode)p="#8f8f9d",g="#42414d";let m=15,v=m*r.sx,y=m*r.sy,S=new OffscreenCanvas(v*2,y*2),A=S.getContext("2d");A.fillStyle=p,A.fillRect(0,0,v*2,y*2),A.fillStyle=g,A.fillRect(0,0,v,y),A.fillRect(v,y,v,y),f.fillStyle=f.createPattern(S,"repeat"),f.fillRect(0,0,d,u),f.drawImage(a,0,0,a.width,a.height,0,0,d,u)}let c=null;if(s){let d,u;if(r.symmetric&&a.width<t&&a.height<t)d=a.width,u=a.height;else if(a=this.#t,i>t||n>t){let g=Math.min(t/i,t/n);if(d=Math.floor(i*g),u=Math.floor(n*g),!this.#h)a=this.#c(d,u)}let p=new OffscreenCanvas(d,u).getContext("2d",{willReadFrequently:!0});p.drawImage(a,0,0,a.width,a.height,0,0,d,u),c={width:d,height:u,data:p.getImageData(0,0,d,u).data}}return{canvas:h,width:o,height:l,imageData:c}}#c(t,e){let{width:s,height:i}=this.#t,n=s,r=i,a=this.#t;while(n>2*t||r>2*e){let o=n,l=r;if(n>2*t)n=Math.ceil(n/2);if(r>2*e)r=Math.ceil(r/2);let h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(a,0,0,o,l,0,0,n,r),a=h.transferToImageBitmap()}return a}#p(){let[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new Wt,r=Math.ceil(s*t*n.sx),a=Math.ceil(i*e*n.sy),o=this.#r;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;let l=this.#h?this.#t:this.#c(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#v(t){if(t){if(this.#h){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.#h){let[e,s]=this.pageDimensions,i=Math.round(this.width*e*pe.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*pe.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,n=!1;if(t instanceof Ci){let{data:{rect:p,rotation:g,id:m,structParent:v,popupRef:y,richText:S,contentsObj:A,creationDate:b,modificationDate:w},container:x,parent:{page:{pageNumber:T}},canvas:E}=t,I,C;if(E)delete t.canvas,{id:I,bitmap:C}=s.imageManager.getFromCanvas(x.id,E),E.remove();else n=!0,t._hasNoCanvas=!0;let O=(await e._structTree.getAriaAttributes(`${xe}${m}`))?.get("aria-label")||"";i=t={annotationType:Y.STAMP,bitmapId:I,bitmap:C,pageIndex:T-1,rect:p.slice(0),rotation:g,annotationElementId:m,id:m,deleted:!1,accessibilityData:{decorative:!1,altText:O},isSvg:!1,structParent:v,popupRef:y,richText:S,comment:A?.str||null,creationDate:b,modificationDate:w}}let r=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;if(n)s.addMissingCanvas(t.id,r),r.#o=!0;else if(h&&s.imageManager.isValidId(h)){if(r.#e=h,o)r.#t=o}else r.#i=l;r.#h=c;let[u,f]=r.pageDimensions;if(r.width=(a[2]-a[0])/u,r.height=(a[3]-a[1])/f,d)r.altTextData=d;if(r._initialData=i,t.comment)r.setCommentData(t);return r.#u=!!i,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#h});if(this.addComment(s),t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;let{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n)s.accessibilityData={type:"Figure",alt:n};if(this.annotationElementId){let a=this.#y(s);if(a.isSame)return null;if(a.isSameAltText)delete s.accessibilityData;else s.accessibilityData.structParent=this._initialData.structParent??-1;return s.id=this.annotationElementId,delete s.bitmapId,s}if(e===null)return s;e.stamps||=new Map;let r=this.#h?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#v(!1);else if(this.#h){let a=e.stamps.get(this.#e);if(r>a.area)a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1)}return s}#y(t){let{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class te{#t;#e=!1;#s=null;#i=null;#n=null;#a=new Map;#r=!1;#o=!1;#l=!1;#h=null;#u=null;#d=null;#f=null;#g=null;#m=-1;#c;static _initialized=!1;static#p=new Map([wt,Di,Wr,Vt,Jt].map((t)=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){let c=[...te.#p.values()];if(!te._initialized){te._initialized=!0;for(let d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#c=t,this.pageIndex=e,this.div=s,this.#t=n,this.#s=r,this.viewport=l,this.#d=o,this.drawLayer=a,this._structTree=i,this.#c.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===Y.NONE}updateToolbar(t){this.#c.updateToolbar(t)}updateMode(t=this.#c.getMode()){switch(this.#w(),t){case Y.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Y.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===Y.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(let s of te.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#c.setEditingState(t)}addCommands(t){this.#c.addCommands(t)}cleanUndoStack(t){this.#c.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#v(){return this.#a.size!==0?this.#a.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#l=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#g?.abort(),this.#g=null;let t=new Set;for(let s of this.#v)if(s.enableEditing(),s.show(!0),s.annotationElementId)this.#c.removeChangedExistingAnnotation(s),t.add(s.annotationElementId);let e=this.#s;if(e)for(let s of e.getEditableAnnotations()){if(s.hide(),this.#c.isDeletedAnnotationElement(s.data.id))continue;if(t.has(s.data.id))continue;let i=await this.deserialize(s);if(!i)continue;this.addOrRebuild(i),i.enableEditing()}this.#l=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#g){this.#g=new AbortController;let i=this.#c.combinedSignal(this.#g);this.#d.div.addEventListener("pointerdown",(n)=>{let{clientX:a,clientY:o,timeStamp:l}=n,h=this.#m;if(l-h>500){this.#m=l;return}this.#m=-1;let{classList:c}=this.div;c.toggle("getElements",!0);let d=document.elementsFromPoint(a,o);if(c.toggle("getElements",!1),!this.div.contains(d[0]))return;let u,f=new RegExp(`^${Ce}[0-9]+$`);for(let g of d)if(f.test(g.id)){u=g.id;break}if(!u)return;let p=this.#a.get(u);if(p?.annotationElementId===null)At(n),p.dblclick(n)},{signal:i,capture:!0})}let t=this.#s,e=[];if(t){let i=new Map,n=new Map;for(let r of this.#v){if(r.disableEditing(),!r.annotationElementId){e.push(r);continue}if(r.serialize()!==null){i.set(r.annotationElementId,r);continue}else n.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(let r of t.getEditableAnnotations()){let{id:a}=r.data;if(this.#c.isDeletedAnnotationElement(a)){r.updateEdited({deleted:!0});continue}let o=n.get(a);if(o){o.resetAnnotationElement(r),o.show(!1),r.show();continue}if(o=i.get(a),o){if(this.#c.addChangedExistingAnnotation(o),o.renderAnnotationElement(r))o.show(!1)}r.show()}}if(this.#w(),this.isEmpty)this.div.hidden=!0;let{classList:s}=this.div;for(let i of te.#p.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){if(this.#c.getActive()===t)return;this.#c.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let t=this.#c.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){if(this.div.tabIndex=0,this.#d?.div&&this.#f)this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting")}#y(t){this.#c.unselectAll();let{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#d.div.contains(e)){let{isMac:s}=ot.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#c.showAllEditors("highlight",!0,!0),Vt.startDrawing(this,this.#c,this.#c.direction==="ltr",t),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;let t=this.#c.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.#a.set(t.id,t);let{annotationElementId:e}=t;if(e&&this.#c.isDeletedAnnotationElement(e))this.#c.removeDeletedAnnotationElement(t)}detach(t){if(this.#a.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId)this.#c.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#c.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){if(t.parent===this)return;if(t.parent&&t.annotationElementId)this.#c.addDeletedAnnotationElement(t),H.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.#c.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#l),this.#c.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;if(t.div.contains(e)&&!this.#n)t._focusEventsAllowed=!1,this.#n=setTimeout(()=>{if(this.#n=null,!t.div.contains(document.activeElement))t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#c._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),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(let e of this.#a.values())if(e.uid===t)return e;return null}get#b(){return te.#p.get(this.#c.getMode())}combinedSignal(t){return this.#c.combinedSignal(t)}#A(t){let e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#c.updateMode(t.mode);let{offsetX:s,offsetY:i}=this.#x(),n=this.#c.getId(),r=this.#A({parent:this,id:n,x:s,y:i,uiManager:this.#c,isCentered:!0,...e});if(r)this.add(r)}async deserialize(t){return await te.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#c)||null}createAndAddNewEditor(t,e,s={}){let i=this.#c.getId(),n=this.#A({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#c,isCentered:e,...s});if(n)this.add(n);return n}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:t,y:e,width:s,height:i}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(n+a)/2-t,h=(r+o)/2-e,[c,d]=this.viewport.rotation%180===0?[l,h]:[h,l];return{offsetX:c,offsetY:d}}addNewEditor(t={}){this.createAndAddNewEditor(this.#x(),!0,t)}setSelected(t){this.#c.setSelected(t)}toggleSelected(t){this.#c.toggleSelected(t)}unselect(t){this.#c.unselect(t)}pointerup(t){let{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#r)return;if(this.#r=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings)return;if(!this.#e){this.#e=!0;return}let s=this.#c.getMode();if(s===Y.STAMP||s===Y.POPUP||s===Y.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#c.getMode()===Y.HIGHLIGHT)this.enableTextSelection();if(this.#r){this.#r=!1;return}let{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#r=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}let s=this.#c.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#h){this.#b.startDrawing(this,this.#c,!1,t);return}this.#c.setCurrentDrawingSession(this),this.#h=new AbortController;let e=this.#c.combinedSignal(this.#h);this.div.addEventListener("blur",({relatedTarget:s})=>{if(s&&!this.div.contains(s))this.#u=null,this.commitOrRemove()},{signal:e}),this.#b.startDrawing(this,this.#c,!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.#h)return null;return this.#c.setCurrentDrawingSession(null),this.#h.abort(),this.#h=null,this.#u=null,this.#b.endDrawing(t)}findNewParent(t,e,s){let i=this.#c.findParent(e,s);if(i===null||i===this)return!1;return i.changeParent(t),!0}commitOrRemove(){if(this.#h)return this.endDrawingSession(),!0;return!1}onScaleChanging(){if(!this.#h)return;this.#b.onScaleChangingWhenDrawing(this)}destroy(){if(this.commitOrRemove(),this.#c.getActive()?.parent===this)this.#c.commitOrRemove(),this.#c.setActiveEditor(null);if(this.#n)clearTimeout(this.#n),this.#n=null;for(let t of this.#a.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#a.clear(),this.#c.removeLayer(this)}#w(){for(let t of this.#a.values())if(t.isEmpty())t.remove()}async render({viewport:t}){this.viewport=t,ge(this.div,t);for(let e of this.#c.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#c.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#c.commitOrRemove(),this.#w();let e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ge(this.div,{rotation:s}),e!==s)for(let i of this.#a.values())i.rotate(s)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#c.viewParameters.realScale}}var Do=K(1806);function Ya(t,e){if(t===e)return 0;return t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function os(t){if(!t)return null;if(t.nodeType===Node.ELEMENT_NODE)return t.closest(".textLayer");return t.parentElement?.closest(".textLayer")||null}function Ka(t,e,s,i){if(t===s)return e<=i;let n=t.compareDocumentPosition(s);if(n&Node.DOCUMENT_POSITION_FOLLOWING)return!0;if(n&Node.DOCUMENT_POSITION_PRECEDING)return!1;return null}function gn(t,e,s){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||!s.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 W{#t=null;#e=new Map;#s=null;#i=null;#n=null;#a=null;#r=new Map;static#o=0;static#l=0;static#h=null;static#u=new Set;static#d=!1;static#f=new Set;static#g=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){if(this.pageIndex=s,this.#i=t,this.#n=e,i){let n=W.#g.get(i);if(n?.selectionDiv)n.selectionDiv.remove(),W.#u.delete(n.selectionDiv);if(W.#g.set(i,{drawLayer:this}),W.#f.add(i),this.#s=i,this.#a=new MutationObserver((r)=>{if(!this.#t||!this.#s?.isConnected||!W.#c())return;for(let{addedNodes:a}of r)for(let o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){W.#v();return}}),this.#a.observe(i,{childList:!0}),W.#h===null){W.#h=new AbortController;let{signal:r}=W.#h;document.addEventListener("selectionchange",W.#v.bind(W),{signal:r}),document.addEventListener("pointerdown",()=>{W.#d=!0},{signal:r}),document.addEventListener("pointerup",()=>{W.#d=!1},{signal:r}),window.addEventListener("blur",()=>{W.#d=!1},{signal:r})}}}setParent(t){if(!this.#t){if(this.#t=t,this.#s?.isConnected&&W.#c())W.#v();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#m(t){let e=this.#g.get(t);if(!e?.selectionDiv)return;e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null}static#c(){let t=document.getSelection();return!!t&&!t.isCollapsed}static#p(){return this.#f.keys().filter((t)=>t.isConnected).toArray().sort(Ya)}static#v(){let t=document.getSelection();if(!t||t.isCollapsed){for(let r of this.#u)r.remove();this.#u.clear();return}let e=new WeakMap,s=this.#p(),i=[];for(let r=0,a=t.rangeCount;r<a;r++){let o=t.getRangeAt(r);if(o.collapsed)continue;let{startContainer:l,startOffset:h,endContainer:c,endOffset:d}=o,u=os(l),f=os(c),p=u===null,g=f===null;if(this.#d&&p!==g)return;if(t.rangeCount===1){let{anchorNode:y,anchorOffset:S,focusNode:A,focusOffset:b}=t,w=os(y),x=os(A),T=Ka(y,S,A,b);if(w&&x&&T!==null)if(T)l=y,h=S,u=w,c=A,d=b,f=x;else l=A,h=b,u=x,c=y,d=S,f=w}let m=s.filter((y)=>o.intersectsNode(y));if(m.length===0)continue;let v=!1;if(!u)u=m[0],l=u,h=0,v=!0;if(!f)f=m.at(-1),c=f,d=f.childNodes.length,v=!0;if(c.nodeType===Node.ELEMENT_NODE){if(c.classList.contains("endOfContent")){let y=c.previousSibling;if(!y)continue;c=y,d=y.nodeType===Node.TEXT_NODE?y.textContent.length:y.childNodes.length}else if(c.classList.contains("textLayer")&&c.childNodes.length===d){let y=gn(c,d,f);if(!y)continue;c=y.container,d=y.offset}}if(l.nodeType===Node.ELEMENT_NODE){let y=gn(l,h,u);if(!y)continue;l=y.container,h=y.offset}if(u===f&&!v&&m.includes(u)){i.push([o,u]);continue}for(let y of m){let S=y.firstChild;if(!S)continue;let A=document.createRange();if(y===u)A.setStart(l,h);else A.setStartBefore(S);if(y===f)A.setEnd(c,d);else{let b=y.lastChild;if(!b)continue;if(b.nodeType===Node.ELEMENT_NODE&&b.classList.contains("endOfContent")){let w=b.previousSibling;if(!w)continue;A.setEndAfter(w)}else A.setEndAfter(b)}if(!A.collapsed)i.push([A,y])}}let n=new Set(i.map((r)=>r[1]));for(let r of this.#f)if(!n.has(r))this.#m(r);for(let[r,a]of i){let o=W.#g.get(a);if(!o)continue;let l=e.get(a);if(!l){let f=a.getBoundingClientRect();l=(p,g,m,v)=>({x:(p-f.x)/f.width,y:(g-f.y)/f.height,width:m/f.width,height:v/f.height}),e.set(a,l)}let h=[];for(let{x:f,y:p,width:g,height:m}of r.getClientRects()){if(g===0||m===0)continue;if({x:f,y:p,width:g,height:m}=l(f,p,g,m),g===1&&m===1)continue;h.push(`M${f} ${p} h${g} v${m} h-${g} Z`)}if(h.length===0)continue;let{drawLayer:c,selectionDiv:d,path:u}=o;if(!d){let f=`clip_selection_${W.#l++}`;d=document.createElement("div"),d.className="selection",d.style.clipPath=`url(#${f})`;let p=c.#i?.createSelectionStyle(c.#n);if(p)for(let[v,y]of Object.entries(p))d.style.setProperty(v,y);let g=W._svgFactory.create(1,1,!0);g.setAttribute("aria-hidden","true"),g.setAttribute("width","100%"),g.setAttribute("height","100%");let m=W._svgFactory.createElement("clipPath");m.setAttribute("id",f),m.setAttribute("clipPathUnits","objectBoundingBox"),u=W._svgFactory.createElement("path"),m.append(u),g.append(m),d.append(g),o.path=u,o.selectionDiv=d}if(c.#t&&d.parentNode!==c.#t)c.#t.append(d),this.#u.add(d);u.setAttribute("d",h.join(" "))}}static get _svgFactory(){return j(this,"_svgFactory",new We)}static#y(t,[e,s,i,n]){let{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#b(){let t=W._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#A(t,e){let s=W._svgFactory.createElement("clipPath");t.append(s);let i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");let n=W._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}#x(t,e){for(let[s,i]of Object.entries(e))if(i===null)t.removeAttribute(s);else t.setAttribute(s,i)}draw(t,e=!1,s=!1){let i=W.#o++,n=this.#b(),r=W._svgFactory.createElement("defs");n.append(r);let a=W._svgFactory.createElement("path");r.append(a);let o=`path_${i}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e)this.#r.set(i,a);let l=s?this.#A(r,o):null,h=W._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#e.set(i,n),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,e){let s=W.#o++,i=this.#b(),n=W._svgFactory.createElement("defs");i.append(n);let r=W._svgFactory.createElement("path");n.append(r);let a=`path_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){let c=W._svgFactory.createElement("mask");n.append(c),o=`mask_${s}`,c.setAttribute("id",o),c.setAttribute("maskUnits","objectBoundingBox");let d=W._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");let u=W._svgFactory.createElement("use");c.append(u),u.setAttribute("href",`#${a}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}let l=W._svgFactory.createElement("use");if(i.append(l),l.setAttribute("href",`#${a}`),o)l.setAttribute("mask",`url(#${o})`);let h=l.cloneNode();return i.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#r.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t==="number"?this.#e.get(t):t;if(!a)return;if(s)this.#x(a,s);if(i)W.#y(a,i);if(n){let{classList:o}=a;for(let[l,h]of Object.entries(n))o.toggle(l,h)}if(r){let l=a.firstElementChild.firstElementChild;this.#x(l,r)}}updateParent(t,e){if(e===this)return;let s=this.#e.get(t);if(!s)return;e.#t.append(s),this.#e.delete(t),e.#e.set(t,s)}remove(t){if(this.#r.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.#r.clear(),this.#a?.disconnect(),this.#a=null,this.#s){if(W.#g.get(this.#s)?.drawLayer===this){if(W.#m(this.#s),W.#g.delete(this.#s),W.#f.delete(this.#s),W.#f.size===0)W.#h?.abort(),W.#h=null,W.#d=!1}this.#s=null}}}function ls(t){return`${(t*100).toFixed(2)}%`}class ws{#t=[];#e=new Map;#s=null;#i=0;#n=0;#a=0;static#r=null;constructor(t,e,s,i){this.#i=t,this.#t=e,this.#n=s.rawDims.pageWidth,this.#a=s.rawDims.pageHeight,this.#s=i}render(){let t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){let s=this.#o(this.#t.subarray(e,e+6));if(s)t.append(s)}return t.addEventListener("contextmenu",(e)=>{if(!(e.target instanceof HTMLCanvasElement))return;let s=e.target,i=this.#e.get(s);if(!i)return;let n=ws.#r?.deref();if(n===s)return;if(n)n.width=0,n.height=0;ws.#r=new WeakRef(s);let{inverseTransform:r,x1:a,y1:o,width:l,height:h}=i,c=this.#s(),d=Math.ceil(a*c.width),u=Math.ceil(o*c.height),f=Math.floor((a+l/this.#n)*c.width),p=Math.floor((o+h/this.#a)*c.height);s.width=f-d,s.height=p-u;let g=s.getContext("2d");g.setTransform(...r),g.translate(-d,-u),g.drawImage(c,0,0)}),t}#o([t,e,s,i,n,r]){let a=Math.hypot((n-t)*this.#n,(r-e)*this.#a),o=Math.hypot((s-t)*this.#n,(i-e)*this.#a);if(a<this.#i||o<this.#i)return null;let l=[(n-t)*this.#n/a,(r-e)*this.#a/a,(s-t)*this.#n/o,(i-e)*this.#a/o,0,0],h=L.inverseTransform(l),c=document.createElement("canvas");return c.className="textLayerImagePlaceholder",c.width=0,c.height=0,Object.assign(c.style,{opacity:0,position:"absolute",left:ls(t),top:ls(e),width:ls(a/this.#n),height:ls(o/this.#a),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(c,{inverseTransform:h,width:a,height:o,x1:t,y1:e}),c}}globalThis._pdfjsTestingUtils={HighlightOutliner:bs};globalThis.pdfjsLib={AbortException:se,AnnotationEditorLayer:te,AnnotationEditorParamsType:q,AnnotationEditorType:Y,AnnotationEditorUIManager:ae,AnnotationLayer:Pi,AnnotationMode:ne,AnnotationType:gt,applyOpacity:pa,build:za,ColorPicker:jt,createValidAbsoluteUrl:mn,CSSConstants:Sn,DOMSVGFactory:We,DrawLayer:W,FeatureTest:ot,fetchData:li,findContrastColor:ga,getDocument:bi,getFilenameFromUrl:da,getPdfFilenameFromUrl:ua,getRGB:Ke,getRGBA:Ye,getUuid:bn,GlobalWorkerOptions:re,ImageKind:hs,InvalidPDFException:ps,isDataScheme:Ps,isPdfFile:hi,isValidExplicitDest:wa,makeArr:Ie,makeMap:ai,makeObj:Js,makeSet:la,MathClamp:ut,noContextMenu:zt,normalizeUnicode:aa,OPS:Qt,OutputScale:Wt,PasswordException:fs,PasswordResponses:ta,PDFDataRangeTransport:Si,PDFDateString:gs,PDFWorker:Tt,PermissionFlag:qr,PixelsPerInch:pe,RenderingCancelledException:Is,renderRichText:wn,ResponseException:Ue,setLayerDimensions:ge,shadow:j,SignatureExtractor:ce,stopEvent:At,SupportedImageMimeTypes:Zs,TextLayer:Ot,TextLayerImages:ws,TouchManager:ui,updateUrlHash:vn,Util:L,VerbosityLevel:xs,version:Va,XfaLayer:oi};var qe={maxBytes:104857600,maxPages:2000,maxCanvasPixels:16000000,maxImageWidth:4096};var Xr=(t)=>Object.assign(Error(t),{name:"PdfTooLargeError"});async function Bo(t,e,s){if(e.aborted)return null;re.workerSrc=new URL(s,import.meta.url).href;let i=bi({data:new Uint8Array(t),verbosity:0,stopAtErrors:!0,enableXfa:!1,maxImageSize:qe.maxCanvasPixels,canvasMaxAreaInBytes:qe.maxCanvasPixels*4}),n=()=>void i.destroy();e.addEventListener("abort",n,{once:!0});let r=async()=>{e.removeEventListener("abort",n),await i.destroy()};try{let a=await i.promise;if(a.numPages>qe.maxPages)throw Xr(`PDF has more than ${qe.maxPages} pages`);let o=[];for(let c=1;c<=a.numPages;c++){let{width:d,height:u}=(await a.getPage(c)).getViewport({scale:1});if(e.aborted)return await r(),null;o.push({width:d,height:u})}return{pages:o,draw:async(c,d,u)=>{let f=await a.getPage(c+1);if(u.aborted)return null;let p=f.getViewport({scale:d/f.getViewport({scale:1}).width}),g=document.createElement("canvas");try{g.width=Math.round(p.width),g.height=Math.round(p.height);let m=f.render({canvas:g,viewport:p}),v=()=>m.cancel();u.addEventListener("abort",v,{once:!0});try{await m.promise}finally{u.removeEventListener("abort",v)}let y=await new Promise((S,A)=>g.toBlob((b)=>b?S(b):A(Error("The page could not be drawn")),"image/png"));if(u.aborted)return null;return{url:URL.createObjectURL(y),width:g.width,height:g.height}}finally{g.width=0,g.height=0,f.cleanup()}},textLayer:async(c,d,u)=>{let f=await a.getPage(c+1);if(u.aborted)return;let p=f.getViewport({scale:1}),g=new Ot({textContentSource:f.streamTextContent(),container:d,viewport:p}),[m=0,v=0,y=0,S=0]=p.viewBox;d.style.width=`calc(var(--total-scale-factor) * ${y-m}px)`,d.style.height=`calc(var(--total-scale-factor) * ${S-v}px)`;let A=()=>g.cancel();u.addEventListener("abort",A,{once:!0});try{await g.render()}finally{u.removeEventListener("abort",A)}},close:r}}catch(a){if(await r(),e.aborted)return null;throw a}}export{Bo as openPdf};
47
+ `;class ba{#t=null;#e=null;#s=null;#i=null;async#r(){if(!globalThis.navigator?.gpu)return!1;try{let t=await navigator.gpu.requestAdapter();if(!t)return!1;return this.#i=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0}catch{return!1}}init(){return this.#t||=this.#r()}get isReady(){return this.#e!==null}loadMeshShader(){if(!this.#e||this.#s)return;let t=this.#e.createShaderModule({code:ch});this.#s=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#i}]},primitive:{topology:"triangle-list"}})}draw(t,e,s,i,r,n,a,o){this.loadMeshShader();let l=this.#e,{offsetX:c,offsetY:h,scaleX:d,scaleY:u}=i,f=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(t.byteLength>0)l.queue.writeBuffer(f,0,t);let p=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(e.byteLength>0)l.queue.writeBuffer(p,0,e);let g=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(g,0,new Float32Array([c,h,d,u,n,a,o,0]));let m=l.createBindGroup({layout:this.#s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),v=new OffscreenCanvas(n,a),y=v.getContext("webgpu");y.configure({device:l,format:this.#i,alphaMode:r?"opaque":"premultiplied"});let b=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},_=l.createCommandEncoder(),w=_.beginRenderPass({colorAttachments:[{view:y.getCurrentTexture().createView(),clearValue:b,loadOp:"clear",storeOp:"store"}]});if(s>0)w.setPipeline(this.#s),w.setBindGroup(0,m),w.setVertexBuffer(0,f),w.setVertexBuffer(1,p),w.draw(s);return w.end(),l.queue.submit([_.finish()]),f.destroy(),p.destroy(),g.destroy(),v.transferToImageBitmap()}}var Ti=new ba;function _a(){return Ti.init()}function wa(){return Ti.isReady}function hh(){Ti.loadMeshShader()}function dh(t,e,s,i,r,n,a,o){return Ti.draw(t,e,s,i,r,n,a,o)}Sc();var Os={DATA:1,ERROR:2},St={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function cn(){}function $t(t){if(t instanceof ve||t instanceof Vs||t instanceof zs||t instanceof gs||t instanceof cs)return t;if(typeof t!=="object"||t===null)return new cs(String(t),String(t));switch(t.name){case"AbortException":return new ve(t.message);case"InvalidPDFException":return new Vs(t.message);case"PasswordException":return new zs(t.message,t.code);case"ResponseException":return new gs(t.message,t.status,t.missing);case"UnknownErrorException":return new cs(t.message,t.details)}return new cs(t.message,t.toString())}class ge{#t=new Map;#e=new Map;#s=1;#i;#r=new AbortController;#n;#a=new Map;#o=1;#l=new Map;#c;constructor(t,e,s){this.#n=t,this.#c=e,this.#i=s,s.addEventListener("message",this.#u.bind(this),{signal:this.#r.signal})}#u({data:t}){if(t.targetName!==this.#n)return;if(t.stream){this.#f(t);return}if(t.callback){let{callbackId:s,callback:i}=t,r=this.#e.get(s);if(!r)throw Error(`Cannot resolve callback ${s}`);if(this.#e.delete(s),i===Os.DATA)r.resolve(t.data);else if(i===Os.ERROR)r.reject($t(t.reason));else throw Error("Unexpected callback case");return}let e=this.#t.get(t.action);if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.#n,i=t.sourceName,r=this.#i;Promise.try(e,t.data).then((n)=>{r.postMessage({sourceName:s,targetName:i,callback:Os.DATA,callbackId:t.callbackId,data:n})}).catch((n)=>{r.postMessage({sourceName:s,targetName:i,callback:Os.ERROR,callbackId:t.callbackId,reason:$t(n)})});return}if(t.streamId){this.#h(t);return}e(t.data)}on(t,e){let s=this.#t;if(s.has(t))throw Error(`There is already a "${t}" handler.`);s.set(t,e)}send(t,e,s){this.#i.postMessage({sourceName:this.#n,targetName:this.#c,action:t,data:e},s)}sendWithPromise(t,e,s){let i=this.#s++,r=Promise.withResolvers();this.#e.set(i,r);try{this.#i.postMessage({sourceName:this.#n,targetName:this.#c,action:t,callbackId:i,data:e},s)}catch(n){r.reject(n)}return r.promise}sendWithStream(t,e,s,i){let r=this.#o++,n=this.#n,a=this.#c,o=this.#i;return new ReadableStream({start:(l)=>{let c=Promise.withResolvers();return this.#a.set(r,{controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1}),o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:l.desiredSize},i),c.promise},pull:(l)=>{let c=Promise.withResolvers();return this.#a.get(r).pullCall=c,o.postMessage({sourceName:n,targetName:a,stream:St.PULL,streamId:r,desiredSize:l.desiredSize}),c.promise},cancel:(l)=>{wt(l instanceof Error,"cancel must have a valid reason");let c=Promise.withResolvers();return this.#a.get(r).cancelCall=c,this.#a.get(r).isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:St.CANCEL,streamId:r,reason:$t(l)}),c.promise}},s)}#h(t){let e=t.streamId,s=this.#n,i=t.sourceName,r=this.#i,n=this.#l,a=this.#t.get(t.action),o={enqueue(l,c=1,h){if(this.isCancelled)return;let d=this.desiredSize;if(this.desiredSize-=c,d>0&&this.desiredSize<=0)this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise;r.postMessage({sourceName:s,targetName:i,stream:St.ENQUEUE,streamId:e,chunk:l},h)},close(){if(this.isCancelled)return;this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:St.CLOSE,streamId:e}),n.delete(e)},error(l){if(this.isCancelled)return;this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:St.ERROR,streamId:e,reason:$t(l)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,n.set(e,o),Promise.try(a,t.data,o).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:St.START_COMPLETE,streamId:e,success:!0})},(l)=>{r.postMessage({sourceName:s,targetName:i,stream:St.START_COMPLETE,streamId:e,reason:$t(l)})})}#f(t){let e=t.streamId,s=this.#n,i=t.sourceName,r=this.#i,n=this.#a.get(e),a=this.#l.get(e);switch(t.stream){case St.START_COMPLETE:if(t.success)n.startCall.resolve();else n.startCall.reject($t(t.reason));break;case St.PULL_COMPLETE:if(t.success)n.pullCall.resolve();else n.pullCall.reject($t(t.reason));break;case St.PULL:if(!a){r.postMessage({sourceName:s,targetName:i,stream:St.PULL_COMPLETE,streamId:e,success:!0});break}if(a.desiredSize<=0&&t.desiredSize>0)a.sinkCapability.resolve();a.desiredSize=t.desiredSize,Promise.try(a.onPull||cn).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:St.PULL_COMPLETE,streamId:e,success:!0})},(l)=>{r.postMessage({sourceName:s,targetName:i,stream:St.PULL_COMPLETE,streamId:e,reason:$t(l)})});break;case St.ENQUEUE:if(wt(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case St.CLOSE:if(wt(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#p(n,e);break;case St.ERROR:wt(n,"error should have stream controller"),n.controller.error($t(t.reason)),this.#p(n,e);break;case St.CANCEL_COMPLETE:if(t.success)n.cancelCall.resolve();else n.cancelCall.reject($t(t.reason));this.#p(n,e);break;case St.CANCEL:if(!a)break;let o=$t(t.reason);Promise.try(a.onCancel||cn,o).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:St.CANCEL_COMPLETE,streamId:e,success:!0})},(l)=>{r.postMessage({sourceName:s,targetName:i,stream:St.CANCEL_COMPLETE,streamId:e,reason:$t(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,this.#l.delete(e);break;default:throw Error("Unexpected stream case")}}async#p(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),this.#a.delete(e)}destroy(){this.#r?.abort(),this.#r=null}get destroyed(){return!this.#r}}class Pr{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:at(`Not implemented: ${t}`)}let s=this[t];if(!s)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);let i=`${s}${e}`;return this._fetch(i,t).catch((r)=>{throw Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){at("Abstract method `_fetch` called.")}}class sr extends Pr{async _fetch(t,e){let s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await Sr(t,s);return i instanceof Uint8Array?i:Ai(i)}}class kr{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw Error("Canvas is not specified");if(e<=0||s<=0)throw Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){let{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}getNoAlphaContext(t){return t.getContext("2d",{alpha:!1,willReadFrequently:!this.#t})}_createCanvas(t,e){at("Abstract method `_createCanvas` called.")}}class Mr{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}if(Wt){let t;try{let e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(s){W(`Cannot load "@napi-rs/canvas" package: "${s}".`)}}catch(e){W(`Cannot access the \`require\` function: "${e}".`)}if(!globalThis.DOMMatrix)if(t?.DOMMatrix)globalThis.DOMMatrix=t.DOMMatrix;else W("Cannot polyfill `DOMMatrix`, rendering may be broken.");if(!globalThis.Path2D)if(t?.Path2D)globalThis.Path2D=t.Path2D;else W("Cannot polyfill `Path2D`, rendering may be broken.");if(!globalThis.navigator?.language)globalThis.navigator={language:"en-US",platform:"",userAgent:""}}async function uh(t){let s=await process.getBuiltinModule("fs/promises").readFile(t);return new Uint8Array(s)}class Aa extends Mr{}class Sa extends kr{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Ea extends Pr{async _fetch(t,e){return uh(t)}}fc();var We="__forcedDependency",{floor:hn,ceil:dn}=Math;function un(t,e,s,i,r,n){t[e*4+0]=Math.min(t[e*4+0],s),t[e*4+1]=Math.min(t[e*4+1],i),t[e*4+2]=Math.max(t[e*4+2],r),t[e*4+3]=Math.max(t[e*4+3],n)}function fh(t,e,s,i,r){let n;if(t){if(t<0)n=r[0],r[0]=r[2],r[2]=n;if(r[0]*=t,r[2]*=t,e<0)n=r[1],r[1]=r[3],r[3]=n;r[1]*=e,r[3]*=e}else r.fill(0);r[0]+=s,r[1]+=i,r[2]+=s,r[3]+=i}var ir=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Ci{#t;#e;constructor(t,e){this.#t=t,this.#e=e}static fromBuffer(t){return new Ci(new Uint32Array(t),new Uint8ClampedArray(t))}get buffer(){return this.#t.buffer}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===ir}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}var fn=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class xa{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(ce);_pendingBBoxIdx=-1;#i;#r;#n;#a;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#r=t.height,this.#o(e)}growOperationsCount(t){if(t>=this.#a.length)this.#o(t,this.#a)}#o(t,e){let s=new ArrayBuffer(t*4);if(this.#n=new Uint8ClampedArray(s),this.#a=new Uint32Array(s),e&&e.length>0)this.#a.set(e),this.#a.fill(ir,e.length);else this.#a.fill(ir)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){let s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;let i=this._savesStack.pop();if(i!==void 0)e?.(i,t),this.#a[t]=this.#a[i];return this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let s=this._savesStack.pop();if(s!==void 0)e?.(s,t),this.#a[t]=this.#a[s];return this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let s=this._markedContentStack.pop();if(s!==void 0)e?.(s,t),this.#a[t]=this.#a[s];return this}pushBaseTransform(t){return this.#t.push(O.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){if(this.#t.length>1)this.#t.pop();return this}resetBBox(t){if(this._pendingBBoxIdx!==t)this._pendingBBoxIdx=t,this.#s.set(ce,0);return this}recordClipBox(t,e,s,i,r,n){let a=O.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=ce.slice();O.axialAlignedBoundingBox([s,r,i,n],a,o);let l=O.intersect(this.#e,o);if(l)this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3];else this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0;return this}recordBBox(t,e,s,i,r,n){let a=this.#e;if(a[0]===1/0)return this;let o=O.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return O.axialAlignedBoundingBox([s,r,i,n],o,this.#s),this;let l=ce.slice();return O.axialAlignedBoundingBox([s,r,i,n],o,l),this.#s[0]=pt(l[0],a[0],this.#s[0]),this.#s[1]=pt(l[1],a[1],this.#s[1]),this.#s[2]=pt(l[2],this.#s[2],a[2]),this.#s[3]=pt(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#r,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;let i=hn(this.#s[0]*256/this.#i),r=hn(this.#s[1]*256/this.#r),n=dn(this.#s[2]*256/this.#i),a=dn(this.#s[3]*256/this.#r);if(un(this.#n,t,i,r,n,a),s){for(let o of s)for(let l of o)if(l!==t)un(this.#n,l,i,r,n,a)}if(!e)this._pendingBBoxIdx=-1;return this}bboxToClipBoxDropOperation(t){if(this._pendingBBoxIdx===t)this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3]);return this}take(){return new Ci(this.#a,this.#n)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,r=0,n=0,a){return this}getSimpleIndex(t){return}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Ta{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[We]:[]};#s=new Map;#i=new Set;#r=new Map;#n;#a;#o;constructor(t,e=!1){if(this.#o=t,e)this.#n=new Map,this.#a=(s,i)=>{fn(this.#n,i).dependencies.add(s)}}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[We]:{__proto__:this.#e[We]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#a);let e=Object.getPrototypeOf(this.#t);if(e===null)return this;return this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#a),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#a),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#a),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(We,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)if(e in this.#t)this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#i)this.recordFutureForcedDependency(We,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,r,n){return this.#o.recordClipBox(t,e,s,i,r,n),this}recordBBox(t,e,s,i,r,n){return this.#o.recordBBox(t,e,s,i,r,n),this}recordCharacterBBox(t,e,s,i=1,r=0,n=0,a){let o=s.bbox,l,c;if(o){if(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#r.get(s),l!==!1){if(c=[0,0,0,0],O.axialAlignedBoundingBox(o,s.fontMatrix,c),i!==1||r!==0||n!==0)fh(i,-i,r,n,c);if(l)return this.recordBBox(t,e,c[0],c[2],c[1],c[3])}}if(!a)return this.recordFullPageBBox(t);let h=a();if(o&&c&&l===void 0){if(l=c[0]<=r-h.actualBoundingBoxLeft&&c[2]>=r+h.actualBoundingBoxRight&&c[1]<=n-h.actualBoundingBoxAscent&&c[3]>=n+h.actualBoundingBoxDescent,this.#r.set(s,l),l)return this.recordBBox(t,e,c[0],c[2],c[1],c[3])}return this.recordBBox(t,e,r-h.actualBoundingBoxLeft,r+h.actualBoundingBoxRight,n-h.actualBoundingBoxAscent,n+h.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){let s=this.#i,i=this.#t,r=this.#e;for(let n of e)if(n in this.#t)s.add(i[n]);else if(n in r)r[n].forEach(s.add,s);return this}recordNamedDependency(t,e){if(this.#s.has(e))this.#i.add(this.#s.get(e));return this}recordOperation(t,e=!1){if(this.recordDependencies(t,[We]),this.#n){let i=fn(this.#n,t),{dependencies:r}=i;this.#i.forEach(r.add,r),this.#o._savesStack.forEach(r.add,r),this.#o._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}let s=!e&&t===this.#o._pendingBBoxIdx;if(this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s)this.#i.clear();return this}recordShowTextOperation(t,e=!1){let s=Array.from(this.#i);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(let i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){let s=!e&&t===this.#o._pendingBBoxIdx;if(this.#o.bboxToClipBoxDropOperation(t),s)this.#i.clear();return this}take(){return this.#r.clear(),this.#o.take()}takeDebugMetadata(){return this.#n}}class ys{#t;#e;#s;#i=0;#r=0;constructor(t,e,s){if(t instanceof ys&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#r++,this.#t.save(this.#e),this}restore(t){if(this.#r>0)this.#t.restore(this.#e),this.#r--;return this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){if(!this.#s)this.#t.resetBBox(this.#e);return this}recordClipBox(t,e,s,i,r,n){if(!this.#s)this.#t.recordClipBox(this.#e,e,s,i,r,n);return this}recordBBox(t,e,s,i,r,n){if(!this.#s)this.#t.recordBBox(this.#e,e,s,i,r,n);return this}recordCharacterBBox(t,e,s,i,r,n,a){if(!this.#s)this.#t.recordCharacterBBox(this.#e,e,s,i,r,n,a);return this}recordFullPageBBox(t){if(!this.#s)this.#t.recordFullPageBBox(this.#e);return this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){if(!this.#s)this.#t.bboxToClipBoxDropOperation(this.#e,!0);return this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}var Jt={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","filter","fillColor"]};class Ks{#t;#e;#s=4;#i=0;#r=new Ks.#n(this.#s*6);static#n=lt.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;let a=new Ks.#n(this.#s*6);a.set(this.#r),this.#r=a}let r=ft(t),n;if(i[0]!==1/0){let a=ce.slice();O.axialAlignedBoundingBox([0,-s,e,0],r,a);let o=O.intersect(i,a);if(!o)return;let[l,c,h,d]=o;if(l!==a[0]||c!==a[1]||h!==a[2]||d!==a[3]){let u=Math.atan2(r[1],r[0]),f=Math.abs(Math.sin(u)),p=Math.abs(Math.cos(u));if(f<0.000001||p<0.000001||Math.abs(f-p)<0.000001)n=[l,c,l,d,h,c];else{let g=h-l,m=d-c,v=f*f,y=p*p,b=p*f,_=y-v,w=(m*y-g*b)/_,A=(m*b-g*v)/_;n=[l+A,c,l,c+w,h,d-w]}}}if(!n)n=[0,-s,0,0,e,-s],O.applyTransform(n,r,0),O.applyTransform(n,r,2),O.applyTransform(n,r,4);n[0]/=this.#t,n[1]/=this.#e,n[2]/=this.#t,n[3]/=this.#e,n[4]/=this.#t,n[5]/=this.#e,this.#r.set(n,this.#i*6),this.#i++}take(){return this.#r.subarray(0,this.#i*6)}}function ph(t,e,{recordOperations:s=!1,recordImages:i=!1,recordDebugMetadata:r=!1}){let n=s||i?new xa(t,e):null;return{dependencyTracker:s?new Ta(n,r):n,imagesTracker:i?new Ks(t):null}}function Ca({src:t,srcPos:e=0,dest:s,width:i,height:r,nonBlackColor:n=4294967295,inverseDecode:a=!1}){let o=lt.isLittleEndian?4278190080:255,[l,c]=a?[n,o]:[o,n],h=i>>3,d=i&7,u=l^c,f=t.length;s=new Uint32Array(s.buffer);let p=0;for(let g=0;g<r;++g){for(let v=e+h;e<v;++e,p+=8){let y=t[e];s[p]=l^-(y>>7&1)&u,s[p+1]=l^-(y>>6&1)&u,s[p+2]=l^-(y>>5&1)&u,s[p+3]=l^-(y>>4&1)&u,s[p+4]=l^-(y>>3&1)&u,s[p+5]=l^-(y>>2&1)&u,s[p+6]=l^-(y>>1&1)&u,s[p+7]=l^-(y&1)&u}if(d===0)continue;let m=e<f?t[e++]:255;for(let v=0;v<d;++v,++p)s[p]=l^-(m>>7-v&1)&u}return{srcPos:e,destPos:p}}function gh({src:t,srcPos:e=0,dest:s,destPos:i=0,width:r,height:n}){let a=0,o=r*n*3,l=t.byteOffset+e,c=l%4===0?Math.floor(pt(t.length-e,0,o)/4):0,h=c>0?new Uint32Array(t.buffer,l,c):null,d=lt.isLittleEndian?4278190080:255;if(lt.isLittleEndian){for(;a<c-2;a+=3,i+=4){let u=h[a],f=h[a+1],p=h[a+2];s[i]=u|d,s[i+1]=u>>>24|f<<8|d,s[i+2]=f>>>16|p<<16|d,s[i+3]=p>>>8|d}for(let u=e+a*4,f=e+o;u<f;u+=3)s[i++]=t[u]|t[u+1]<<8|t[u+2]<<16|d}else{for(;a<c-2;a+=3,i+=4){let u=h[a],f=h[a+1],p=h[a+2];s[i]=u|d,s[i+1]=u<<24|f>>>8|d,s[i+2]=f<<16|p>>>16|d,s[i+3]=p<<8|d}for(let u=e+a*4,f=e+o;u<f;u+=3)s[i++]=t[u]<<24|t[u+1]<<16|t[u+2]<<8|d}return{srcPos:e+o,destPos:i}}var xt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Hs(t,e){if(!e)return;let s=e[2]-e[0],i=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],s,i),t.clip(r)}class Ii{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){at("Abstract method `getPattern` called.")}}class Ia extends Ii{constructor(t){super();this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7]}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;let t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,r=this._p1;if(e)i=i.slice(),r=r.slice(),O.applyTransform(i,e),O.applyTransform(r,e);if(this._type==="axial")s=t.createLinearGradient(i[0],i[1],r[0],r[1]);else if(this._type==="radial"){let n=this._r0,a=this._r1;if(e){let o=new Float32Array(2);O.singularValueDecompose2dScale(e,o),n*=o[0],a*=o[0]}s=t.createRadialGradient(i[0],i[1],n,r[0],r[1],a)}for(let n of this._colorStops)s.addColorStop(n[0],n[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;if(e)s=s.slice(),i=i.slice(),O.applyTransform(s,e),O.applyTransform(i,e);let r=this._r1,n=this._r0;if(e){let l=new Float32Array(2);O.singularValueDecompose2dScale(e,l),r*=l[0],n*=l[0]}let a=t.createRadialGradient(s[0],s[1],r,i[0],i[1],n),o=this._colorStops.map(([l,c])=>[1-l,c]).reverse();for(let[l,c]of o)a.addColorStop(l,c);return a}_createRasterPattern(t,e,s,i,r,n){let a=Math.ceil(i[2]-i[0])||1,o=Math.ceil(i[3]-i[1])||1,l=e.canvasFactory.create(a,o),c=l.context;if(c.clearRect(0,0,a,o),c.beginPath(),c.rect(0,0,a,o),c.translate(-i[0],-i[1]),s=O.transform(s,[1,0,0,1,i[0],i[1]]),c.transform(...r),Hs(c,this._bbox),this.areConic())c.fillStyle=this._createReversedGradient(c),c.fill();c.fillStyle=this._createGradient(c),c.fill(),n?.applyToCanvas(c);let h=t.createPattern(l.canvas,"no-repeat");return e.canvasFactory.destroy(l),h.setTransform(new DOMMatrix(s)),h}getPattern(t,e,s,i){let r=e.current.transferMapsFallback;if(i===xt.STROKE||i===xt.FILL){if(this.isOriginBased()&&!r){let o=O.transform(s,e.baseTransform);if(this.matrix)o=O.transform(o,this.matrix);let l=0.001,c=Math.hypot(o[0],o[1]),h=Math.hypot(o[2],o[3]),d=(o[0]*o[2]+o[1]*o[3])/(c*h);if(Math.abs(d)<l)if(this.isRadial()){if(Math.abs(c-h)<l)return this._createGradient(t,o)}else return this._createGradient(t,o)}let n=e.current.getClippedPathBoundingBox(i,ft(t))||[0,0,0,0],a=this.matrix?O.transform(e.baseTransform,this.matrix):e.baseTransform;return this._createRasterPattern(t,e,s,n,a,r)}if(r&&s)return this._createRasterPattern(t,e,s,e.current.clipBox,ft(t),r);if(this.areConic())t.save(),Hs(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-10000000000,-10000000000,20000000000,20000000000),t.restore();return Hs(t,this._bbox),this._createGradient(t)}}function mh(t,e,s,i,r,n,a,o){let{coords:l,colors:c}=e,h=t.data,d=t.width*4,u;if(l[s*2+1]>l[i*2+1])u=s,s=i,i=u,u=n,n=a,a=u;if(l[i*2+1]>l[r*2+1])u=i,i=r,r=u,u=a,a=o,o=u;if(l[s*2+1]>l[i*2+1])u=s,s=i,i=u,u=n,n=a,a=u;let f=(l[s*2]+e.offsetX)*e.scaleX,p=(l[s*2+1]+e.offsetY)*e.scaleY,g=(l[i*2]+e.offsetX)*e.scaleX,m=(l[i*2+1]+e.offsetY)*e.scaleY,v=(l[r*2]+e.offsetX)*e.scaleX,y=(l[r*2+1]+e.offsetY)*e.scaleY;if(p>=y)return;let b=c[n*4],_=c[n*4+1],w=c[n*4+2],A=c[a*4],x=c[a*4+1],E=c[a*4+2],T=c[o*4],k=c[o*4+1],C=c[o*4+2],R=Math.round(p),B=Math.round(y),N,M,F,j,X,it,q,Z;for(let J=R;J<=B;J++){if(J<m){let z=J<p?0:(p-J)/(p-m);N=f-(f-g)*z,M=b-(b-A)*z,F=_-(_-x)*z,j=w-(w-E)*z}else{let z;if(J>y)z=1;else if(m===y)z=0;else z=(m-J)/(m-y);N=g-(g-v)*z,M=A-(A-T)*z,F=x-(x-k)*z,j=E-(E-C)*z}let P;if(J<p)P=0;else if(J>y)P=1;else P=(p-J)/(p-y);X=f-(f-v)*P,it=b-(b-T)*P,q=_-(_-k)*P,Z=w-(w-C)*P;let I=Math.round(Math.min(N,X)),D=Math.round(Math.max(N,X)),G=d*J+I*4;for(let z=I;z<=D;z++){if(P=(N-z)/(N-X),P<0)P=0;else if(P>1)P=1;h[G++]=M-(M-it)*P|0,h[G++]=F-(F-q)*P|0,h[G++]=j-(j-Z)*P|0,h[G++]=255}}}class Pa extends Ii{constructor(t){super();this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],hh()}_createMeshCanvas(t,e,s,i=null){let o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,h=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3000)||1,u=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3000)||1,f=c?c/d:1,p=h?h/u:1,g={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/f,scaleY:1/p},m=d+4,v=u+4,y=s.create(m,v);if(wa()&&this._vertexCount>48)y.context.drawImage(dh(this._posData,this._colData,this._vertexCount,g,e,m,v,2),0,0);else{let b=y.context.createImageData(d,u);if(e){let _=b.data;for(let w=0,A=_.length;w<A;w+=4)_[w]=e[0],_[w+1]=e[1],_[w+2]=e[2],_[w+3]=255}for(let _=0,w=this._vertexCount;_<w;_+=3)mh(b,g,_,_+1,_+2,_,_+1,_+2);y.context.putImageData(b,2,2)}return i?.applyToCanvas(y.context),{canvas:y.canvas,offsetX:o-2*f,offsetY:l-2*p,scaleX:f,scaleY:p}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Hs(t,this._bbox);let r=new Float32Array(2);if(i===xt.SHADING)O.singularValueDecompose2dScale(ft(t),r);else if(this.matrix){O.singularValueDecompose2dScale(this.matrix,r);let[o,l]=r;O.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else O.singularValueDecompose2dScale(e.baseTransform,r);let n=this._createMeshCanvas(r,i===xt.SHADING?null:this._background,e.canvasFactory,e.current.transferMapsFallback);if(i!==xt.SHADING){if(t.setTransform(...e.baseTransform),this.matrix)t.transform(...this.matrix)}t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY);let a=t.createPattern(n.canvas,"no-repeat");return e.canvasFactory.destroy(n),a}}class ka extends Ii{getPattern(){return"hotpink"}}function vh(t){switch(t[0]){case"RadialAxial":return new Ia(t);case"Mesh":return new Pa(t);case"Dummy":return new ka}throw Error(`Unknown IR type: ${t[0]}`)}var pn={COLORED:1,UNCOLORED:2};class fs{static MAX_PATTERN_SIZE=3000;constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?O.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){let[r,n,a,o]=this.bbox,l=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>l+0.000001||e>c+0.000001)return null;let h=Math.floor((s-a)/l)+1,d=Math.ceil((s+t-r)/l)-1,u=Math.floor((i-o)/c)+1,f=Math.ceil((i+e-n)/c)-1;return d<=h&&f<=u?[h,u]:null}updatePatternDims(t,e){let s=ce.slice();O.axialAlignedBoundingBox(t,O.inverseTransform(this.patternBaseMatrix),s),e[0]=s[2]-s[0],e[1]=s[3]-s[1],e[2]=s[0],e[3]=s[1]}_renderTileCanvas(t,e,s,i){let[r,n,a,o]=this.bbox,l=t.canvasFactory.create(s.size,i.size),c=l.context,h=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return h.groupLevel=t.groupLevel,h.current.transferMapsFallback=t.current.transferMapsFallback,this.setFillAndStrokeStyleToContext(h,this.paintType,this.color),c.translate(-s.scale*r,-i.scale*n),h.transform(0,s.scale,0,0,i.scale,0,0),c.save(),h.dependencyTracker?.save(),this.clipBbox(h,r,n,a,o),h.baseTransform=ft(h.ctx),h.executeOperatorList(this.operatorList),h.endDrawing(),h.dependencyTracker?.restore(),c.restore(),l}_getCombinedScales(){let t=new Float32Array(2);O.singularValueDecompose2dScale(this.matrix,t);let[e,s]=t;return O.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,r],n){let[a,o,l,c]=this.bbox,h=t.dependencyTracker;if(h)t.dependencyTracker=new ys(h,n);try{if(t.save(),s)t.ctx.clip(e,"evenodd");else t.ctx.clip(e);if(t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){let d=l-a,u=c-o,[f,p]=this._getCombinedScales(),g=this.getSizeAndScale(d,this.ctx.canvas.width,f),m=this.getSizeAndScale(u,this.ctx.canvas.height,p),v=this._renderTileCanvas(t,n,g,m);t.ctx.drawImage(v.canvas,a,o,d,u),t.canvasFactory.destroy(v)}else t.resetGraphicsState(),this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=ft(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore()}finally{if(h)t.dependencyTracker=h}}createPatternCanvas(t,e){let[s,i,r,n]=this.bbox,a=r-s,o=n-i,{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),wi("TilingType: "+this.tilingType);let[h,d]=this._getCombinedScales(),u=a,f=o,p=!1,g=!1;if(Math.ceil(l*h)>=Math.ceil(a*h))u=l;else p=!0;if(Math.ceil(c*d)>=Math.ceil(o*d))f=c;else g=!0;let m=this.getSizeAndScale(u,this.ctx.canvas.width,h),v=this.getSizeAndScale(f,this.ctx.canvas.height,d),y=this._renderTileCanvas(t,e,m,v);if(p||g){let b=y.canvas;if(p)u=l;if(g)f=c;let _=this.getSizeAndScale(u,this.ctx.canvas.width,h),w=this.getSizeAndScale(f,this.ctx.canvas.height,d),A=_.size,x=w.size,E=t.canvasFactory.create(A,x),T=E.context,k=p?Math.min(Math.floor(a/l),Math.ceil(b.width/A)):0,C=g?Math.min(Math.floor(o/c),Math.ceil(b.height/x)):0,R=b,B=null;if(g){B=t.canvasFactory.create(b.width,x);let N=B.context;for(let M=C;M>=0;M--)N.drawImage(b,0,x*M,b.width,x,0,0,b.width,x);R=B.canvas}for(let N=k;N>=0;N--)T.drawImage(R,A*N,0,A,x,0,0,A,x);if(B)t.canvasFactory.destroy(B);return t.canvasFactory.destroy(y),{canvas:E.canvas,canvasEntry:E,scaleX:_.scale,scaleY:w.scale,offsetX:s,offsetY:i}}return{canvas:y.canvas,canvasEntry:y,scaleX:m.scale,scaleY:v.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){let i=Math.max(fs.MAX_PATTERN_SIZE,e),r=Math.ceil(t*s);if(r>=i)r=i;else s=r/t;return{scale:s,size:r}}clipBbox(t,e,s,i,r){let n=i-e,a=r-s,o=new Path2D;o.rect(e,s,n,a),O.axialAlignedBoundingBox([e,s,i,r],ft(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){switch(e){case pn.COLORED:s="#000000";break;case pn.UNCOLORED:break;default:throw new aa(`Unsupported paint type: ${e}`)}let{ctx:i,current:r}=t;r.patternFill=r.patternStroke=!1,i.fillStyle=i.strokeStyle=r.transferMapsFallback?.applyToColor(s)??s,r.fillColor=r.strokeColor=s}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){let n=i!==xt.SHADING?O.transform(s,this.patternBaseMatrix):s,a=this.createPatternCanvas(e,r),o=new DOMMatrix(n);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}var yh=16,bh=100,_h=15,gn=10,Gt=16,Yt=new Float32Array(2);function mn(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");let s=new Map;for(let i of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){let r=t[i];if(typeof r!=="function"||typeof e[i]!=="function")continue;s.set(i,r),t[i]=function(...n){return e[i](...n),r.apply(this,n)}}t._removeMirroring=()=>{for(let[i,r]of s)t[i]=r;delete t._removeMirroring}}function Rs(t,e,s,i,r,n,a,o,l,c){let[h,d,u,f,p,g]=ft(t);if(d===0&&u===0){let y=a*h+p,b=Math.round(y),_=o*f+g,w=Math.round(_),A=(a+l)*h+p,x=Math.abs(Math.round(A)-b)||1,E=(o+c)*f+g,T=Math.abs(Math.round(E)-w)||1;return t.setTransform(Math.sign(h),0,0,Math.sign(f),b,w),t.drawImage(e,s,i,r,n,0,0,x,T),t.setTransform(h,d,u,f,p,g),[x,T]}if(h===0&&f===0){let y=o*u+p,b=Math.round(y),_=a*d+g,w=Math.round(_),A=(o+c)*u+p,x=Math.abs(Math.round(A)-b)||1,E=(a+l)*d+g,T=Math.abs(Math.round(E)-w)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,b,w),t.drawImage(e,s,i,r,n,0,0,T,x),t.setTransform(h,d,u,f,p,g),[T,x]}t.drawImage(e,s,i,r,n,a,o,l,c);let m=Math.hypot(h,d),v=Math.hypot(u,f);return[m*l,v*c]}class Us{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Yi;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=Et.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";transferMapsFallback=null;minMax=Re.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=xt.FILL,e=null){let s=this.minMax.slice();if(t===xt.STROKE){if(!e)at("Stroke bounding box must include transform.");O.singularValueDecompose2dScale(e,Yt);let i=Yt[0]*this.lineWidth/2,r=Yt[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){let t=O.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Re,0)}getClippedPathBoundingBox(t=xt.FILL,e=null){return O.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function vn(t,e){let{width:s,height:i,kind:r}=e,n=i%Gt,a=(i-n)/Gt,o=n===0?a:a+1,l=t.createImageData(s,Gt),c=0,h=e.data,d=l.data,u;if(r===js.GRAYSCALE_1BPP)for(u=0;u<o;u++)({srcPos:c}=Ca({src:h,srcPos:c,dest:d,width:s,height:u<a?Gt:n})),t.putImageData(l,0,u*Gt);else if(r===js.RGBA_32BPP){let f=0,p=s*Gt*4;for(u=0;u<a;u++)d.set(h.subarray(c,c+p)),c+=p,t.putImageData(l,0,f),f+=Gt;if(u<o)p=s*n*4,d.set(h.subarray(c,c+p)),t.putImageData(l,0,f)}else if(r===js.RGB_24BPP)for(u=0;u<o;u++)({srcPos:c}=gh({src:h,srcPos:c,dest:new Uint32Array(d.buffer),width:s,height:u<a?Gt:n})),t.putImageData(l,0,u*Gt);else throw Error(`bad image kind: ${r}`)}function yn(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}let{width:s,height:i}=e,r=i%Gt,n=(i-r)/Gt,a=r===0?n:n+1,o=t.createImageData(s,Gt),l=0,c=e.data,h=o.data;for(let d=0;d<a;d++)({srcPos:l}=Ca({src:c,srcPos:l,dest:h,width:s,height:d<n?Gt:r,nonBlackColor:0})),t.putImageData(o,0,d*Gt)}function Ie(t,e){let s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let i of s)if(t[i]!==void 0)e[i]=t[i];if(t.setLineDash!==void 0)e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset}function Ma(t,e){t.setAttribute?.("data-canvas-name",e),t._pdfjsCanvasName=e}function wh(t){return t._pdfjsCanvasName??null}function Fs(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0)t.setLineDash([]),t.lineDashOffset=0;let{filter:e}=t;if(e!=="none"&&e!=="")t.filter="none"}class Oa{#t;constructor(t){let[e,s=e,i=e]=t,r=O.identity0to256Map.slice();this.#t=[e||r,s||r,i||r]}applyToColor(t){if(typeof t!=="string"||!t.startsWith("#"))return t;let[e,s,i]=ts(t),[r,n,a]=this.#t;return O.makeHexColor(r[e],n[s],a[i])}applyToImageData({data:t}){let[e,s,i]=this.#t;for(let r=0,n=t.length;r<n;r+=4)t[r]=e[t[r]],t[r+1]=s[t[r+1]],t[r+2]=i[t[r+2]]}applyToCanvas(t){let{width:e,height:s}=t.canvas,i=t.getImageData(0,0,e,s);this.applyToImageData(i),t.putImageData(i,0,0)}}function bn(t,e,s){if(e)return!0;O.singularValueDecompose2dScale(t,Yt);let i=Math.fround(s*Le.PDF_TO_CSS_UNITS);return Yt[0]<=i&&Yt[1]<=i}var Ah=["butt","round","square"],Sh=["miter","round","bevel"],Eh={},_n={};class Ae{static#t=null;static#e=new WeakMap;#s=0;#i=0;#r=null;#n=null;#a=null;#o=null;#l=1;#c;#u=null;#h=[];constructor(t,e,s,i,r,{optionalContentConfig:n,markedContentStack:a=null,pixelRatio:o=Kt.pixelRatio},l,c,h,d){this.ctx=t,this.current=new Us(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.pixelRatio=o,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,s=null){if(typeof e==="string")return this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e);return s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){let r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,s){let o=this.transparentCanvasEntry=this.canvasFactory.create(r,n);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=o,this.ctx.save(),this.ctx.transform(...ft(this.compositeCtx))}if(this.ctx.save(),Fs(this.ctx),t)this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3];this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=ft(this.ctx)}executeOperatorList(t,e,s,i,r,n){let{argsArray:a,fnArray:o}=t,l=this._pathCache;this._pathCache=t.pathCache??Ae.#e.getOrInsertComputed(t,Ws);try{let c=e||0,h=a.length;if(h===c)return c;let d=h-c>gn&&typeof s==="function",u=d?Date.now()+_h:0,f=0,p=this.commonObjs,g=this.objs,m,v;while(!0){if(r!==void 0){if(c===r.nextBreakPoint)return r.breakIt(c,s),c;if(r.shouldSkip(c)){if(++c===h)return c;continue}}if(!n||n(c,t))if(m=o[c],v=a[c]??null,m!==pe.dependency)if(v===null)this[m](c);else this[m](c,...v);else for(let y of v){this.dependencyTracker?.recordNamedData(y,c);let b=y.startsWith("g_")?p:g;if(!b.has(y))return b.get(y,s,i),c}if(c++,c===h)return c;if(d&&++f>gn){if(Date.now()>u)return s(),c;f=0}}}finally{this._pathCache=l}}#f(){while(this.stateStack.length||this.inSMaskMode)this.restore();if(this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas)this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null}endDrawing(){this.#f();for(let t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let t of this.#h)this.#w(t);this.#h.length=0,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=1,this.#u=null,this.#i=0,this.#s=0,this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)e.width=e.height=0;t.clear()}this._cachedBitmapsMap.clear(),this.#p()}#p(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let s=t.width??t.displayWidth,i=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),n=Math.max(Math.hypot(e[2],e[3]),1),a=[],o=r,l=n,c=s,h=i;while(o>2&&c>1||l>2&&h>1){let m=c,v=h;if(o>2&&c>1)m=Math.ceil(c/2),o/=c/m;if(l>2&&h>1)v=Math.ceil(h/2),l/=h/v;a.push({newWidth:m,newHeight:v}),c=m,h=v}if(a.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(a.length===1){let{newWidth:m,newHeight:v}=a[0],y=this.canvasFactory.create(m,v);return y.context.drawImage(t,0,0,s,i,0,0,m,v),{img:y.canvas,paintWidth:m,paintHeight:v,tmpCanvas:y}}let d=this.canvasFactory.create(1,1),u=this.canvasFactory.create(1,1),f=s,p=i,g=t;for(let{newWidth:m,newHeight:v}of a)this.canvasFactory.reset(u,m,v),u.context.drawImage(g,0,0,f,p,0,0,m,v),[d,u]=[u,d],g=d.canvas,f=m,p=v;return this.canvasFactory.destroy(u),{img:d.canvas,paintWidth:f,paintHeight:p,tmpCanvas:d}}_createMaskCanvas(t,e){let s=this.ctx,{width:i,height:r}=e,n=this.current.patternFill,a=n?this.current.fillColor:s.fillStyle,o=ft(s),l,c,h,d;if((e.bitmap||e.data)&&e.count>1){let k=e.bitmap||e.data.buffer;c=JSON.stringify(n?o:[o.slice(0,4),a]),l=this._cachedBitmapsMap.getOrInsertComputed(k,Ws);let C=l.get(c);if(C&&!n){let R=Math.round(Math.min(o[0],o[2])+o[4]),B=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Jt.transformAndFill),{canvas:C,offsetX:R,offsetY:B}}h=C}if(!h)d=this.canvasFactory.create(i,r),yn(d.context,e);let u=O.transform(o,[1/i,0,0,-1/r,0,0]);u=O.transform(u,[1,0,0,1,0,-r]);let f=Re.slice();O.axialAlignedBoundingBox([0,0,i,r],u,f);let[p,g,m,v]=f,y=Math.round(m-p)||1,b=Math.round(v-g)||1,_=this.canvasFactory.create(y,b),w=_.context,A=p,x=g;w.translate(-A,-x),w.transform(...u);let E=null;if(!h){let k=this._scaleImage(d.canvas,ue(w));if(h=k.img,E=k.tmpCanvas,h!==d.canvas)this.canvasFactory.destroy(d),d=null;if(l&&n)l.set(c,h),E=null,d=null}if(w.imageSmoothingEnabled=bn(ft(w),e.interpolate,this.pixelRatio),Rs(w,h,0,0,h.width,h.height,0,0,i,r),E)this.canvasFactory.destroy(E);if(d)this.canvasFactory.destroy(d);w.globalCompositeOperation="source-in";let T=O.transform(ue(w),[1,0,0,1,-A,-x]);if(w.fillStyle=n?a.getPattern(s,this,T,xt.FILL,t):a,w.fillRect(0,0,i,r),l&&!n)l.set(c,_.canvas);return this.dependencyTracker?.recordDependencies(t,Jt.transformAndFill),{canvas:_.canvas,canvasEntry:l&&!n?null:_,offsetX:Math.round(A),offsetY:Math.round(x)}}setLineWidth(t,e){if(this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth)this._cachedScaleForStroking[0]=-1;this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Ah[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Sh[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);let i=this.ctx;if(i.setLineDash!==void 0)i.setLineDash(e),i.lineDashOffset=s}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[s,i]of e)switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=i;break;case"SMask":if(this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=i?this.tempSMask:null,this.current.activeSMask)this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation;this.tempSMask=null,this.checkSMaskState(t);break;case"TR":{this.dependencyTracker?.recordSimpleData("filter",t);let r=this.filterFactory.addFilter(i);this.ctx.filter=r;let n=null;if(i&&(r==="none"||!lt.isCanvasFilterSupported||this.ctx.filter==="none"||this.ctx.filter===""))this.ctx.filter=r="none",n=new Oa(i);if(this.current.transferMaps=r,n||this.current.transferMapsFallback){if(this.current.transferMapsFallback=n,!this.current.patternFill)this.ctx.fillStyle=this.#A(this.current.fillColor);if(!this.current.patternStroke)this.ctx.strokeStyle=this.#A(this.current.strokeColor)}break}}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry)this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null;this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){if(t===this.smaskPreparedFor)return;this._clearPreparedSMask(),this._prepareSMaskCanvas(t)}checkSMaskState(t){let e=this.inSMaskMode;if(this.current.activeSMask&&!e)this.beginSMaskMode(t);else if(!this.current.activeSMask&&e)this.endSMaskMode();else if(this.current.activeSMask&&e)this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){let{canvas:e,subtype:s,backdrop:i,transferMap:r}=t,n=s==="Luminosity"||s==="Alpha"&&r;if(!n&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let a;if(s==="Luminosity"&&i){let[v,y,b]=ts(i),_=Math.round(0.3*v+0.59*y+0.11*b);a=r?.[_]??_}else a=r?.[0]??0;let o=4,{width:l,height:c}=this.ctx.canvas,h=e.width*e.height,d=l*c<o*h,u=n?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(r):this.filterFactory.addLuminosityFilter(r),subtype:s,transferMap:r}:null,f=s==="Luminosity"?i:null,p,g,m;if(d)p=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,l,c,f,u),g=0,m=0;else p=this._bakeSMaskCanvas(e,0,0,e.width,e.height,f,u),g=t.offsetX,m=t.offsetY;this.smaskPreparedEntry=p,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=g,this.smaskPreparedOffsetY=m,this.smaskPreparedOOBAlpha=!d&&a!==0?a:null}_bakeSMaskCanvas(t,e,s,i,r,n,a){if(!n&&!a)at("_bakeSMaskCanvas with neither backdrop nor filter");let o=this.canvasFactory.create(i,r),l=o.context;if(l.drawImage(t,e,s),n)l.globalCompositeOperation="destination-atop",l.fillStyle=n,l.fillRect(0,0,i,r);if(!a)return o;let c=this.canvasFactory.create(i,r),h=c.context;h.filter=a.url;let d=lt.isCanvasFilterSupported&&h.filter!=="none"&&h.filter!=="";if(h.drawImage(o.canvas,0,0),lt.isCanvasFilterSupported)h.filter="none";if(!d){let u=h.getImageData(0,0,i,r),{data:f}=u,{transferMap:p}=a;if(a.subtype==="Luminosity")for(let g=0,m=f.length;g<m;g+=4){let v=0.3*f[g]+0.59*f[g+1]+0.11*f[g+2]+0.5|0;f[g]=f[g+1]=f[g+2]=0,f[g+3]=p?.[v]??v}else for(let g=3,m=f.length;g<m;g+=4)f[g]=p[f[g]];h.putImageData(u,0,0)}return this.canvasFactory.destroy(o),c}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;let r=this.ctx=i.context;r.setTransform(this.suspendedCtx.getTransform()),Ie(this.suspendedCtx,r),mn(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ie(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#m(t,e=null,s=1){let{width:i,height:r}=t,n=e??this.canvasFactory.create(i,r),a=n.context;s=Math.round(s*255)/255;let o=s<1;if(o&&this.#c===void 0)this.#c=lt.isCanvasFilterSupported?new Map:"none";let l="none";if(o&&this.#c instanceof Map)l=this.#c.getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s));if(!o||l!=="none"){if(e)a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,r),a.restore();return a.filter=l,a.drawImage(t,0,0),a.filter="none",n}let c=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,r),h=a.createImageData(i,r),d=c.data,u=h.data,f=s>0?1/s:1e6;for(let p=3,g=d.length;p<g;p+=4)u[p]=Math.min(Math.round(d[p]*f),255);return a.putImageData(h,0,0),n}#d(t,e,s,i){let r=t?.[e]??null;if(r&&(r.canvas.width!==s||r.canvas.height!==i))this.canvasFactory.destroy(r),r=null;if(!r){if(r=this.canvasFactory.create(s,i),t)t[e]=r;return r}let n=r.context;return n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,s,i),n.restore(),r}#g(t,e,s={}){let{backdropCanvas:i=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:n=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:c="none",knockoutAlpha:h=1}=s,{width:d,height:u}=e,f=this.#m(e,a,h),p=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,lt.isCanvasFilterSupported)t.filter="none";if(t.globalCompositeOperation="destination-out",t.drawImage(f.canvas,0,0),i){let[g,m]=n,v=this.#d(o,"knockoutBackdropEntry",d,u),y=v.context;if(y.drawImage(i,g,m,d,u,0,0,d,u),y.globalCompositeOperation="destination-in",y.drawImage(f.canvas,0,0),y.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(v.canvas,0,0),!o)this.canvasFactory.destroy(v)}if(t.globalCompositeOperation=p,t.globalAlpha=l,lt.isCanvasFilterSupported)t.filter=c??"none";if(t.drawImage(e,0,0),t.restore(),!a)this.canvasFactory.destroy(f)}#v(t=1){if(this.#s===0||this.#i>0||!this.contentVisible)return!1;this.#i++,this.#l=t;let e=this.#h.at(-1),{canvas:s}=this.ctx,i=this.#d(e,"knockoutTempEntry",s.width,s.height);this.#r=i;let r=i.context;if(r.save(),r.setTransform(this.ctx.getTransform()),Ie(this.ctx,r),this.#o=r.globalCompositeOperation,r.globalCompositeOperation="source-over",mn(r,this.ctx),this.#u=e,this.#n=this.ctx,this.#a=this.suspendedCtx,this.ctx=r,this.inSMaskMode)this.suspendedCtx=r;return!0}#y(t){if(!t)return;let e=this.#r,s=this.#n,i=this.#a,r=e.context;if(this.#r=null,this.#n=null,this.#a=null,this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r)this.endSMaskMode();if(this.inSMaskMode)this.suspendedCtx=i;this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#o,this.#o=null,Ie(this.ctx,s),this.ctx=s;let n=this.#u;this.#u=null;let a=this.#l;this.#l=1;try{this.#g(i??s,e.canvas,{backdropCanvas:n?.backdropCtx?.canvas??null,backdropOffset:n?.backdropCtx?[n.offsetX,n.offsetY]:[0,0],reuseMaskEntry:n?.knockoutMaskEntry??null,poolMeta:n,knockoutAlpha:a})}finally{if(r.restore(),this.#i--,!n)this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,s=this.suspendedCtx,i=this.#i>0&&s===this.ctx;if(this.composeSMask(i?null:s,e,this.ctx,t),i)return;this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){let r=i[0],n=i[1],a=i[2]-r,o=i[3]-n;if(a===0||o===0)return;let l=this.smaskPreparedEntry;if(l){let c=r,h=n,d=a,u=o,f=this.smaskPreparedOOBAlpha,p=f!==null;if(p){c=Math.max(r,e.offsetX),h=Math.max(n,e.offsetY);let g=Math.min(r+a,e.offsetX+e.canvas.width),m=Math.min(n+o,e.offsetY+e.canvas.height);d=g-c,u=m-h}if(d>0&&u>0){let g=c-this.smaskPreparedOffsetX,m=h-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);let v=new Path2D;v.rect(c,h,d,u),s.clip(v),s.globalCompositeOperation="destination-in",s.drawImage(l.canvas,g,m,d,u,c,h,d,u),s.restore()}if(p&&f<255)this._applySMaskOOBAlpha(s,r,n,a,o,c,h,c+d,h+u,f)}else this.genericComposeSMask(e,s,a,o,r,n);if(!t)return;t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,n,a,o,r,n,a,o),t.restore()}_applySMaskOOBAlpha(t,e,s,i,r,n,a,o,l,c){let h=n<o&&a<l;if(h&&n===e&&a===s&&o===e+i&&l===s+r)return;let d=new Path2D;if(d.rect(e,s,i,r),h)d.rect(n,a,o-n,l-a);t.save(),t.globalAlpha=c/255,t.setTransform(1,0,0,1,0,0),t.clip(d,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,r),t.restore()}genericComposeSMask(t,e,s,i,r,n){let{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let c=new Path2D;c.rect(r,n,s,i),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,r-o,n-l,s,i,r,n,s,i),e.restore()}save(t){if(this.inSMaskMode)Ie(this.ctx,this.suspendedCtx);this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){if(this.inSMaskMode)this.endSMaskMode();return}if(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode)Ie(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform());this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1}resetGraphicsState(){let{clipBox:t,transferMaps:e,transferMapsFallback:s}=this.current,i=this.current=new Us(0,0);i.clipBox=t,i.transferMaps=e,i.transferMapsFallback=s;let r=this.ctx;if(r.lineWidth=1,r.lineCap="butt",r.lineJoin="miter",r.miterLimit=10,r.setLineDash!==void 0)r.setLineDash([]),r.lineDashOffset=0;this._cachedScaleForStroking[0]=-1}transform(t,e,s,i,r,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,n,a),this._cachedScaleForStroking[0]=-1}constructPath(t,e,s,i){let r=this._pathCache.get(t);if(!i){if(!r)r=new Path2D,this._pathCache.set(t,r);if(e!==pe.stroke&&e!==pe.closeStroke)this.current.tilingPatternDims=null;this[e](t,r);return}if(this.dependencyTracker!==null){let a=e===pe.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}if(!r)r=la(s[0]),this._pathCache.set(t,r);O.axialAlignedBoundingBox(i,ft(this.ctx),this.current.minMax);let n=this.current.tilingPatternDims;if(n&&e!==pe.stroke&&e!==pe.closeStroke&&this.current.fillColor instanceof fs){let a=O.intersect(this.current.clipBox,this.current.minMax);if(!a)this.current.tilingPatternDims=null;else this.current.fillColor.updatePatternDims(a,n)}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){let i=s&&this.#v(this.current.strokeAlpha),r=this.ctx,n=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof n==="object"&&n?.getPattern){let a=n.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=n.getPattern(r,this,ue(r),xt.STROKE,t),a){let o=new Path2D;o.addPath(e,r.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);if(this.dependencyTracker?.recordDependencies(t,Jt.stroke),s)this.consumePath(t,e,this.current.getClippedPathBoundingBox(xt.STROKE,ft(this.ctx)));r.globalAlpha=this.current.fillAlpha,this.#y(i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){let i=s&&this.#v(this.current.fillAlpha),r=this.ctx,n=this.current.fillColor,a=this.current.patternFill,o=!1,l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Jt.fill),a){let c=this.current.tilingPatternDims,h=c&&n.canSkipPatternCanvas(c);if(h){let{pendingClip:u,pendingEOFill:f}=this;if(this.pendingClip=null,this.pendingEOFill=!1,n.drawPattern(this,e,f,h,t),this.pendingClip=u,s)this.consumePath(t,e,l);this.current.tilingPatternDims=null,this.#y(i);return}let d=n.isModifyingCurrentTransform()?r.getTransform():null;if(this.dependencyTracker?.save(t),r.save(),r.fillStyle=n.getPattern(r,this,ue(r),xt.FILL,t),d){let u=new Path2D;u.addPath(e,r.getTransform().invertSelf().multiplySelf(d)),e=u}o=!0}if(this.contentVisible&&l!==null)if(this.pendingEOFill)r.fill(e,"evenodd"),this.pendingEOFill=!1;else r.fill(e);if(o)r.restore(),this.dependencyTracker?.restore(t);if(s)this.consumePath(t,e,l);this.#y(i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){let s=this.#v(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#y(s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){let s=this.#v(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Jt.rawFillPath).recordOperation(t),this.#y(s)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Eh}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=_n}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;if(e!==void 0)i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t);i.recordCloseMarker(t)}if(e!==void 0){let i=new Path2D,r=s.getTransform().invertSelf();for(let{transform:n,x:a,y:o,fontSize:l,path:c}of e){if(!c)continue;i.addPath(c,new DOMMatrix(n).preMultiplySelf(r).translate(a,o).scale(l,-l))}s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let i=this.commonObjs.get(e),r=this.current;if(!i)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||Yi,r.fontMatrix[0]===0||r.fontMatrix[3]===0)W("Invalid font matrix for font "+e);if(s<0)s=-s,r.fontDirection=-1;else r.fontDirection=1;if(this.current.font=i,this.current.fontSize=s,i.isType3Font)return;let n=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`,o="normal";if(i.black)o="900";else if(i.bold)o="bold";let l=i.italic?"italic":"normal",c=pt(s,yh,bh);this.current.fontSizeScale=s/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#b(t,e,s){let i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,r,n){let a=this.ctx,o=this.current,{font:l,textRenderingMode:c}=o,h=o.fontSize/o.fontSizeScale,d=c&Et.FILL_STROKE_MASK,u=!!(c&Et.ADD_TO_PATH_FLAG),f=o.patternFill&&!l.missingFile,p=o.patternStroke&&!l.missingFile,g;if((l.disableFontFace||u||f||p)&&!l.missingFile)g=l.getPathGenerator(this.commonObjs,e);if(g&&(l.disableFontFace||f||p)){a.save(),a.translate(s,i),a.scale(h,-h),this.dependencyTracker?.recordCharacterBBox(t,a,l);let m;if(d===Et.FILL||d===Et.FILL_STROKE)if(r){m=a.getTransform(),a.setTransform(...r);let v=this.#b(g,m,r);a.fill(v)}else a.fill(g);if(d===Et.STROKE||d===Et.FILL_STROKE)if(n){m||=a.getTransform(),a.setTransform(...n);let{a:v,b:y,c:b,d:_}=m,w=O.inverseTransform(n),A=O.transform([v,y,b,_,0,0],w);O.singularValueDecompose2dScale(A,Yt),a.lineWidth*=Math.max(Yt[0],Yt[1])/h,a.stroke(this.#b(g,m,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else{if(d===Et.FILL||d===Et.FILL_STROKE)a.fillText(e,s,i),this.dependencyTracker?.recordCharacterBBox(t,a,l,h,s,i,()=>a.measureText(e));if(d===Et.STROKE||d===Et.FILL_STROKE){if(this.dependencyTracker)this.dependencyTracker?.recordCharacterBBox(t,a,l,h,s,i,()=>a.measureText(e)).recordDependencies(t,Jt.stroke);a.strokeText(e,s,i)}}if(u)(this.pendingTextPaths||=[]).push({transform:ft(a),x:s,y:i,fontSize:h,path:g}),this.dependencyTracker?.recordCharacterBBox(t,a,l,h,s,i)}get isFontSubpixelAAEnabled(){let t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);let s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return L(this,"isFontSubpixelAAEnabled",i)}#_(t,e,s){let i=this.ctx;i.save();let r=t.getPattern(i,this,ue(i),e,s),n=ft(i);return i.restore(),[r,n]}showText(t,e){if(this.dependencyTracker){if(this.dependencyTracker.recordDependencies(t,Jt.showText).resetBBox(t),this.current.textRenderingMode&Et.ADD_TO_PATH_FLAG)this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies()}let s=this.current,i=s.font;if(i.isType3Font){let C=this.#v(s.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#y(C);return}let r=s.fontSize;if(r===0){this.dependencyTracker?.recordOperation(t);return}let n=this.#v(s.fillAlpha),a=this.ctx,{fontSizeScale:o,charSpacing:l,wordSpacing:c,fontDirection:h}=s,d=s.textHScale*h,u=e.length,f=i.vertical,p=f?1:-1,g=r*s.fontMatrix[0],m=s.textRenderingMode===Et.FILL&&!i.disableFontFace&&!s.patternFill;if(a.save(),s.textMatrix)a.transform(...s.textMatrix);if(a.translate(s.x,s.y+s.textRise),h>0)a.scale(d,-1);else a.scale(d,1);let v,y,b=s.textRenderingMode&Et.FILL_STROKE_MASK,_=b===Et.FILL||b===Et.FILL_STROKE,w=b===Et.STROKE||b===Et.FILL_STROKE,{lineWidth:A,textMatrixScale:x}=s;if(x===0||A===0){if(w)A=this.getSinglePixelWidth()}else A/=x;if(o!==1)a.scale(o,o),A/=o;if(a.lineWidth=A,_&&s.patternFill)[a.fillStyle,v]=this.#_(s.fillColor,xt.FILL,t);if(w&&s.patternStroke)[a.strokeStyle,y]=this.#_(s.strokeColor,xt.STROKE,t);if(i.isInvalidPDFjsFont){let C=[],R=0;for(let N of e)C.push(N.unicode),R+=N.width;let B=C.join("");if(a.fillText(B,0,0),this.dependencyTracker!==null){let N=a.measureText(B);this.dependencyTracker.recordBBox(t,this.ctx,-N.actualBoundingBoxLeft,N.actualBoundingBoxRight,-N.actualBoundingBoxAscent,N.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=R*g*d,a.restore(),this.compose(),this.#y(n);return}let E=0,T,k=null;for(T=0;T<u;++T){let C=e[T];if(typeof C==="number"){E+=p*C*r/1000;continue}let R=!1,B=(C.isSpace?c:0)+l,{fontChar:N,accent:M}=C,F,j,X,it=C.width;if(f){let P=C.vmetric,I=-P[1]*g,D=P[2]*g;if(it=-P[0],F=I/o,j=(E+D)/o,C.isRotated){X=a.measureText(N);let G=g/o,z=C.width/2*G,tt=F+z;F=j-380*G-z,j=(X.actualBoundingBoxAscent-X.actualBoundingBoxDescent)/2-tt,R=!0,a.save(),a.rotate(Math.PI/2)}}else F=E/o,j=0;let q=C.isRotated?C.width:it,Z=1;if((i.remeasure||C.isRotated)&&q>0){X??=a.measureText(N);let P=X.width*1000/r*o;if(q<P&&this.isFontSubpixelAAEnabled){if(Z=q/P,!R)R=!0,a.save();a.scale(Z,1),F/=Z}else if(q!==P)F+=(q-P)/2000*r/o}if(R&&i.missingFile&&(v||y))k||=new Map,[a.fillStyle,a.strokeStyle]=k.getOrInsertComputed(C.isRotated?-Z:Z,()=>[v?this.#_(s.fillColor,xt.FILL,t)[0]:a.fillStyle,y?this.#_(s.strokeColor,xt.STROKE,t)[0]:a.strokeStyle]);if(this.contentVisible&&(C.isInFont||i.missingFile)){if(m&&!M)a.fillText(N,F,j),this.dependencyTracker?.recordCharacterBBox(t,a,X?{bbox:null}:i,r/o,F,j,()=>X??a.measureText(N));else if(this.paintChar(t,N,F,j,v,y),M){let P=F+r*M.offset.x/o,I=j-r*M.offset.y/o;this.paintChar(t,M.fontChar,P,I,v,y)}}let J=f?it*g-B*h:it*g+B*h;if(E+=J,R)a.restore()}if(f)s.y-=E;else s.x+=E*d;a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#y(n)}showType3Text(t,e){let s=this.ctx,i=this.current,{font:r,fontSize:n,fontDirection:a}=i,o=r.vertical?1:-1,{charSpacing:l,wordSpacing:c}=i,h=i.textHScale*a,d=i.fontMatrix||Yi,u=e.length,f=i.textRenderingMode!==Et.INVISIBLE,p,g,m,v;if(n===0)return;if(this._cachedScaleForStroking[0]=-1,s.save(),i.textMatrix)s.transform(...i.textMatrix);s.translate(i.x,i.y+i.textRise),s.scale(h,a);let y=this.dependencyTracker;this.dependencyTracker=y?new ys(y,t):null;try{for(p=0;p<u;++p){if(g=e[p],typeof g==="number"){v=o*g*n/1000,this.ctx.translate(v,0),i.x+=v*h;continue}let b=(g.isSpace?c:0)+l,_=r.charProcOperatorList.get(g.operatorListId);if(!_)W(`Type3 character "${g.operatorListId}" is not available.`);else if(this.contentVisible&&f)this.save(),s.scale(n,n),s.transform(...d),this.executeOperatorList(_),this.restore();m=g.width*d[0]*n+b*a,s.translate(m,0),i.x+=m*h}}finally{if(y)this.dependencyTracker=y}s.restore()}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,n,a){let o=new Path2D;o.rect(i,r,n-i,a-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,i,n,r,a).recordClipBox(t,this.ctx,i,n,r,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){let i=this.baseTransform||ft(this.ctx),r={createCanvasGraphics:(n,a)=>new Ae(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack,pixelRatio:this.pixelRatio},void 0,void 0,this.dependencyTracker?new ys(this.dependencyTracker,a,!0):null)};s=new fs(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);let s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof fs?[0,0,0,0]:null}#A(t){return this.current.transferMapsFallback?.applyToColor(t)??t}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=e,this.ctx.strokeStyle=this.#A(e),this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=e,this.ctx.fillStyle=this.#A(e),this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){let i=this.cachedPatterns.getOrInsertComputed(e,()=>vh(this.getObject(t,e)));if(s)i.matrix=s;return i}shadingFill(t,e){if(!this.contentVisible)return;let s=this.#v(this.current.fillAlpha),i=this.ctx;this.save(t);let r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,ue(i),xt.SHADING,t);let n=ue(i);if(n){let{width:a,height:o}=i.canvas,l=Re.slice();O.axialAlignedBoundingBox([0,0,a,o],n,l);let[c,h,d,u]=l;this.ctx.fillRect(c,h,d-c,u-h)}else this.ctx.fillRect(-10000000000,-10000000000,20000000000,20000000000);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Jt.transform).recordDependencies(t,Jt.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#y(s)}beginInlineImage(){at("Should not call beginInlineImage")}beginImageData(){at("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(!this.contentVisible)return;if(this.save(t),this.baseTransformStack.push(this.baseTransform),e)this.transform(t,...e);if(this.baseTransform=ft(this.ctx),s){O.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);let[i,r,n,a]=s,o=new Path2D;o.rect(i,r,n-i,a-r),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,n,r,a),this.endPath(t)}}paintFormXObjectEnd(t){if(!this.contentVisible)return;this.restore(t),this.baseTransform=this.baseTransformStack.pop()}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);let{inSMaskMode:s}=this;if(s)this.endSMaskMode(),this.current.activeSMask=null;let i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&this.#s===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let b=new Path2D,[_,w,A,x]=e.bbox;if(b.rect(_,w,A-_,x-w),e.matrix){let E=new Path2D;E.addPath(b,new DOMMatrix(e.matrix)),b=E}i.clip(b)}this.groupStack.push(null),this.#h.push(null),this.groupLevel++;return}if(!e.isolated&&!e.knockout&&this.#s===0)wi("TODO: Fully support non-isolated non-knockout groups.");let r=ft(i);if(e.matrix)i.transform(...e.matrix);let n=[0,0,i.canvas.width,i.canvas.height],a;if(e.bbox)a=Re.slice(),O.axialAlignedBoundingBox(e.bbox,ft(i),a),a=O.intersect(a,n)||[0,0,0,0];else a=n;let o=Math.floor(a[0]),l=Math.floor(a[1]),c=Math.max(Math.ceil(a[2])-o,1),h=Math.max(Math.ceil(a[3])-l,1);this.current.startNewPathAndClipBox([0,0,c,h]);let d=this.canvasFactory.create(c,h);if(e.smask)this.smaskGroupCanvases.push(d);let u=d.context,f=e.knockout&&!e.isolated?i:null,p=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#s>0,g=e.knockout?this.canvasFactory.create(c,h):null,m=this.#s;if(e.knockout)this.#s++;else this.#s=0;u.translate(-o,-l),u.transform(...r);let v=!e.isolated&&!e.smask&&e.needsIsolation,y=v&&!s&&m===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none"&&!this.current.transferMapsFallback;if(v&&(s||y))u.save(),u.setTransform(1,0,0,1,0,0),u.drawImage(i.canvas,-o,-l),u.restore();if(e.bbox){let b=new Path2D,[_,w,A,x]=e.bbox;if(b.rect(_,w,A-_,x-w),e.matrix){let E=new Path2D;E.addPath(b,new DOMMatrix(e.matrix)),b=E}u.clip(b)}if(e.smask)this.smaskStack.push({canvas:d.canvas,context:u,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null});if(!e.smask||this.dependencyTracker)i.setTransform(1,0,0,1,0,0),i.translate(o,l),i.save();Ie(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),this.#h.push({backdropCtx:f,savedKnockoutLevel:m,offsetX:o,offsetY:l,hasInnerBackdrop:p,replaceBackdrop:y,knockoutMaskEntry:g,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let s=this.ctx,i=this.groupStack.pop(),r=this.#h.pop();if(r)this.#s=r.savedKnockoutLevel;if(i===null){this.restore(t);return}if(e.isGray)this.#S(s);if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask){if(this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker){if(this.ctx.restore(),this.inSMaskMode)this.ctx.setTransform(this.suspendedCtx.getTransform())}this.#w(r)}else{this.ctx.restore();let n=ft(this.ctx);this.restore(t),this.current.transferMapsFallback?.applyToCanvas(s),this.ctx.save(),this.ctx.setTransform(...n);let a=Re.slice();O.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],n,a);let o=this.#h.at(-1);if(this.#s>0)if(r.hasInnerBackdrop){let{width:l,height:c}=s.canvas,h=this.canvasFactory.create(l,c),d=h.context;d.drawImage(i.canvas,r.offsetX,r.offsetY,l,c,0,0,l,c),d.globalCompositeOperation="source-over",d.drawImage(s.canvas,0,0);let u=this.#m(s.canvas);d.globalCompositeOperation="destination-in",d.drawImage(u.canvas,0,0);let f=this.ctx.globalCompositeOperation,p=this.ctx.globalAlpha,g=this.ctx.filter;if(this.ctx.save(),this.ctx.setTransform(...n),this.ctx.globalAlpha=1,lt.isCanvasFilterSupported)this.ctx.filter="none";if(this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(u.canvas,0,0),this.ctx.globalCompositeOperation=f,this.ctx.globalAlpha=p,lt.isCanvasFilterSupported)this.ctx.filter=g??"none";this.ctx.drawImage(h.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(u),this.canvasFactory.destroy(h)}else{let l=o?.backdropCtx??null;this.#g(this.ctx,s.canvas,{backdropCanvas:l?.canvas??null,destTransform:n,backdropOffset:l?[o.offsetX+r.offsetX,o.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(r.replaceBackdrop){let l=new Path2D;l.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(l),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),this.#w(r),this.compose(a)}}#S(t){let{canvas:e}=t,{width:s,height:i}=e;if(lt.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}let r=t.getImageData(0,0,s,i),{data:n}=r;for(let a=0,o=n.length;a<o;a+=4){let l=n[a]*0.2126+n[a+1]*0.7152+n[a+2]*0.0722+0.5|0;n[a]=n[a+1]=n[a+2]=l}t.putImageData(r,0,0)}#w(t){if(!t)return;if(t.knockoutMaskEntry)this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null;if(t.knockoutTempEntry)this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null;if(t.knockoutBackdropEntry)this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null}beginAnnotation(t,e,s,i,r,n,a){if(this.#f(),Fs(this.ctx),this.ctx.save(),this.save(t),this.baseTransform)this.ctx.setTransform(...this.baseTransform);if(s){let o=s[2]-s[0],l=s[3]-s[1];if(n&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],O.singularValueDecompose2dScale(ft(this.ctx),Yt);let{viewportScale:c}=this,h=Math.ceil(o*this.outputScaleX*c),d=Math.ceil(l*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(h,d);let{canvas:u,context:f}=this.annotationCanvas;if(a){let p=this.annotationCanvasMap.getOrInsertComputed(e,Ze);Ma(u,a);let g=p.findIndex((m)=>wh(m)===a);if(g===-1)p.push(u);else p[g]=u}else this.annotationCanvasMap.set(e,u);this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(Yt[0],0,0,-Yt[1],0,l*Yt[1]),Fs(this.ctx)}else{Fs(this.ctx),this.endPath(t);let c=new Path2D;c.rect(s[0],s[1],o,l),this.ctx.clip(c)}}this.current=new Us(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=ft(this.ctx)}endAnnotation(t){if(this.annotationCanvas)this.ctx.restore(),this.#p(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas;this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let s=e.count;e=this.getObject(t,e.data,e),e.count=s;let i=this.#v(this.current.fillAlpha),r=this.ctx,n=this._createMaskCanvas(t,e),a=n.canvas;if(r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+a.width,n.offsetY,n.offsetY+a.height).recordOperation(t),r.restore(),n.canvasEntry)this.canvasFactory.destroy(n.canvasEntry);this.compose(),this.#y(i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.#v(this.current.fillAlpha),l=this.ctx;l.save();let c=ft(l);l.transform(s,i,r,n,0,0);let h=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,h.offsetX-c[4],h.offsetY-c[5]),this.dependencyTracker?.resetBBox(t);for(let d=0,u=a.length;d<u;d+=2){let f=O.transform(c,[s,i,r,n,a[d],a[d+1]]);l.drawImage(h.canvas,f[4],f[5]),this.dependencyTracker?.recordBBox(t,this.ctx,f[4],f[4]+h.canvas.width,f[5],f[5]+h.canvas.height)}if(l.restore(),h.canvasEntry)this.canvasFactory.destroy(h.canvasEntry);this.compose(),this.dependencyTracker?.recordOperation(t),this.#y(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let s=this.#v(this.current.fillAlpha),i=this.ctx,r=this.current.patternFill,n=r?this.current.fillColor:i.fillStyle;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Jt.transformAndFill);for(let a of e){let{data:o,width:l,height:c,transform:h}=a,d=this.canvasFactory.create(l,c),u=d.context;u.save();let f=this.getObject(t,o,a);yn(u,f),u.globalCompositeOperation="source-in",u.fillStyle=r?n.getPattern(u,this,ue(i),xt.FILL,t):n,u.fillRect(0,0,l,c),u.restore(),i.save(),i.transform(...h),i.scale(1,-1),Rs(i,d.canvas,0,0,l,c,0,-1,1,1),this.canvasFactory.destroy(d),this.dependencyTracker?.recordBBox(t,i,0,l,0,c),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#y(s)}paintImageXObject(t,e){if(!this.contentVisible)return;let s=this.getObject(t,e);if(!s){W("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;let n=this.getObject(t,e);if(!n){W("Dependent image isn't ready yet");return}let{width:a,height:o}=n,l=[];for(let c=0,h=r.length;c<h;c+=2)l.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,l)}applyTransferMapsToCanvas(t){if(this.current.transferMaps!=="none")t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none";else this.current.transferMapsFallback?.applyToCanvas(t);return t.canvas}applyTransferMapsToBitmap(t){let{transferMaps:e,transferMapsFallback:s}=this.current;if(e==="none"&&!s)return{img:t.bitmap,canvasEntry:null};let{bitmap:i,width:r,height:n}=t,a=this.canvasFactory.create(r,n),o=a.context;return o.filter=e,o.drawImage(i,0,0),o.filter="none",s?.applyToCanvas(o),{img:a.canvas,canvasEntry:a}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;let{width:s,height:i}=e,r=this.#v(this.current.fillAlpha),n=this.ctx;this.save(t);let{filter:a}=n;if(a!=="none"&&a!=="")n.filter="none";n.scale(1/s,-1/i);let o,l=null;if(e.bitmap){let h=this.applyTransferMapsToBitmap(e);o=h.img,l=h.canvasEntry}else{let h=this.canvasFactory.create(s,i);vn(h.context,e),o=this.applyTransferMapsToCanvas(h.context),l=h}let c=this._scaleImage(o,ue(n));if(n.imageSmoothingEnabled=bn(ft(n),e.interpolate,this.pixelRatio),this.dependencyTracker)this.dependencyTracker.resetBBox(t).recordBBox(t,n,0,s,-i,0).recordDependencies(t,Jt.imageXObject).recordOperation(t),this.imagesTracker?.record(n,s,i,this.dependencyTracker.clipBox);if(Rs(n,c.img,0,0,c.paintWidth,c.paintHeight,0,-i,s,i),c.tmpCanvas)this.canvasFactory.destroy(c.tmpCanvas);if(l)this.canvasFactory.destroy(l);this.compose(),this.restore(t),this.#y(r)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;let i=this.#v(this.current.fillAlpha),r=this.ctx,n,a=null;if(e.bitmap&&!this.current.transferMapsFallback)n=e.bitmap;else if(e.bitmap)({img:n,canvasEntry:a}=this.applyTransferMapsToBitmap(e));else{let{width:o,height:l}=e,c=this.canvasFactory.create(o,l);vn(c.context,e),n=this.applyTransferMapsToCanvas(c.context),a=c}this.dependencyTracker?.resetBBox(t);for(let o of s)r.save(),r.transform(...o.transform),r.scale(1,-1),Rs(r,n,o.x,o.y,o.w,o.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,r,0,1,-1,0),r.restore();if(a)this.canvasFactory.destroy(a);this.dependencyTracker?.recordOperation(t),this.compose(),this.#y(i)}paintSolidColorImageMask(t){if(!this.contentVisible)return;let e=this.#v(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Jt.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#y(e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){if(this.dependencyTracker?.beginMarkedContent(t),e==="OC")this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)});else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){let i=this.current.isEmptyClip();if(this.pendingClip)this.current.updateClipFromPath();if(!this.pendingClip)this.compose(s);let r=this.ctx;if(this.pendingClip){if(!i)if(this.pendingClip===_n)r.clip(e,"evenodd");else r.clip(e);this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)}else this.dependencyTracker?.recordOperation(t);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){let t=ft(this.ctx);if(t[1]===0&&t[2]===0)return 1/Math.min(Math.abs(t[0]),Math.abs(t[3]));let e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);return Math.max(s,i)/e}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform(),n,a;if(s===0&&i===0){let o=Math.abs(e),l=Math.abs(r);if(o===l)if(t===0)n=a=1/o;else{let c=o*t;n=a=c<1?1/c:1}else if(t===0)n=1/o,a=1/l;else{let c=o*t,h=l*t;n=c<1?1/c:1,a=h<1?1/h:1}}else{let o=Math.abs(e*r-s*i),l=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)n=c/o,a=l/o;else{let h=t*o;n=c>h?c/h:1,a=l>h?l/h:1}}this._cachedScaleForStroking[0]=n,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:s,current:{lineWidth:i}}=this,[r,n]=this.getScaleForStroking();if(r===n){s.lineWidth=(i||1)*r,s.stroke(t);return}let a=Ae.#t??=new DOMMatrix,o=s.getLineDash();if(e)s.save();s.scale(r,n),a.a=1/r,a.d=1/n;let l=new Path2D;if(l.addPath(t,a),o.length>0){let c=Math.max(r,n);s.setLineDash(o.map((h)=>h/c)),s.lineDashOffset/=c}if(s.lineWidth=i||1,s.stroke(l),e)s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in pe)if(Ae.prototype[t]!==void 0)Ae.prototype[pe[t]]=Ae.prototype[t];class Ra extends kr{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e});this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Fa extends Mr{#t;#e;#s;#i;#r;#n;#a=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super();this.#i=t,this.#r=e}get#o(){return this.#e||=new Map}get#l(){return this.#n||=new Map}get#c(){if(!this.#s){let t=this.#r.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let s=this.#r.createElementNS(Dt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#r.createElementNS(Dt,"defs"),t.append(s),s.append(this.#s),this.#r.body.append(t)}return this.#s}#u(t){let e=(n)=>n&&Array.from(n,(a)=>a/255).join(",");if(t.length===1){let n=e(t[0]);return[n,n,n]}let[s,i,r]=t;return[e(s),e(i),e(r)]}#h(t){if(this.#t===void 0){this.#t="";let e=this.#r.URL;if(e!==this.#r.baseURI)if(Ei(e))W('#createUrl: ignore "data:"-URL for performance reasons.');else this.#t=na(e,"")}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[s,i,r]=this.#u(t),n=t.length===1?s:`${s}${i}${r}`;if(e=this.#o.get(n),e)return this.#o.set(t,e),e;let a=`g_${this.#i}_transfer_map_${this.#a++}`,o=this.#h(a);this.#o.set(t,o),this.#o.set(n,o);let l=this.#m(a);return this.#g(s,i,r,l),o}addHCMFilter(t,e){let s=`${t}-${e}`,i="base",r=this.#l.get("base");if(r?.key===s)return r.url;if(r)r.filter?.remove(),r.key=s,r.url="none",r.filter=null;else r={key:s,url:"none",filter:null},this.#l.set("base",r);if(!t||!e)return r.url;let n=this.#y(t);t=O.makeHexColor(...n);let a=this.#y(e);if(e=O.makeHexColor(...a),this.#_(),t==="#000000"&&e==="#ffffff"||t===e)return r.url;let l=Array.from({length:256},(u,f)=>Qi(f/255)).join(","),c=`g_${this.#i}_hcm_filter`,h=r.filter=this.#m(c);this.#g(l,l,l,h),this.#p(h);let d=(u,f)=>{let p=n[u]/255,g=a[u]/255,m=Array(f+1);for(let v=0;v<=f;v++)m[v]=p+v/f*(g-p);return m.join(",")};return this.#g(d(0,5),d(1,5),d(2,5),h),r.url=this.#h(c),r.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){let e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();if(e==="none"||!lt.platform.isFirefox)return null;return{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let r=`g_${this.#i}_alpha_map_${this.#a++}`,n=this.#h(r);this.#o.set(t,n),this.#o.set(i,n);let a=this.#m(r);return this.#v(s,a),n}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t)[s]=this.#u([t]),i=`luminosity_${s}`;else i="luminosity";if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let r=`g_${this.#i}_luminosity_map_${this.#a++}`,n=this.#h(r);this.#o.set(t,n),this.#o.set(i,n);let a=this.#m(r);if(this.#f(a),t)this.#v(s,a);return n}addKnockoutFilter(t=0){let e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;let r=`g_${this.#i}_knockout_filter_${this.#a++}`,n=this.#h(r);this.#o.set(s,n);let a=this.#m(r),o=this.#r.createElementNS(Dt,"feComponentTransfer");a.append(o);let l=this.#r.createElementNS(Dt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),n}addHighlightHCMFilter(t,e,s,i,r){let n=`${e}-${s}-${i}-${r}`,a=this.#l.get(t);if(a?.key===n)return a.url;if(a)a.filter?.remove(),a.key=n,a.url="none",a.filter=null;else a={key:n,url:"none",filter:null},this.#l.set(t,a);if(!e||!s)return a.url;let[o,l]=[e,s].map(this.#y.bind(this)),c=Math.round(0.2126*o[0]+0.7152*o[1]+0.0722*o[2]),h=Math.round(0.2126*l[0]+0.7152*l[1]+0.0722*l[2]),[d,u]=[i,r].map(this.#A.bind(this));if(h<c)[c,h,d,u]=[h,c,u,d];this.#_();let f=(m,v,y)=>{let b=Array(256),_=(h-c)/y,w=m/255,A=(v-m)/(255*y),x=0;for(let E=0;E<=y;E++){let T=Math.round(c+E*_),k=w+E*A;for(let C=x;C<=T;C++)b[C]=k;x=T+1}for(let E=x;E<256;E++)b[E]=b[x-1];return b.join(",")},p=`g_${this.#i}_hcm_${t}_filter`,g=a.filter=this.#m(p);return this.#p(g),this.#g(f(d[0],u[0],5),f(d[1],u[1],5),f(d[2],u[2],5),g),a.url=this.#h(p),a.url}destroy(t=!1){if(t&&this.#n?.size)return;this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#n?.clear(),this.#n=null,this.#a=0}#f(t){let e=this.#r.createElementNS(Dt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#p(t){let e=this.#r.createElementNS(Dt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#m(t){let e=this.#r.createElementNS(Dt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#d(t,e,s){if(!s)return;let i=this.#r.createElementNS(Dt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#g(t,e,s,i){let r=this.#r.createElementNS(Dt,"feComponentTransfer");i.append(r),this.#d(r,"feFuncR",t),this.#d(r,"feFuncG",e),this.#d(r,"feFuncB",s)}#v(t,e){let s=this.#r.createElementNS(Dt,"feComponentTransfer");e.append(s),this.#d(s,"feFuncA",t)}#y(t){return this.#c.style.color="CanvasText",this.#c.style.backgroundColor=t,Es(getComputedStyle(this.#c).getPropertyValue("background-color"))}#b(t){return this.#c.style.color="CanvasText",this.#c.style.backgroundColor=t,ts(getComputedStyle(this.#c).getPropertyValue("background-color"))}#_(){this.#c.style.color="",this.#c.style.backgroundColor=""}#A(t){let[e,s,i,r]=this.#b(t);if(r===1)return[e,s,i];let[n,a,o]=this.#y("Canvas");return[Vi(e,n,r),Vi(s,a,r),Vi(i,o,r)]}}function Vi(t,e,s){return Math.round(s*t+(1-s)*e)}var wn=/\p{Cc}/u;function xh(t){let e=t[0];if(t.length<2||e!=='"'&&e!=="'"||t.at(-1)!==e)return!1;let s=t.length-1;for(let i=1;i<s;i++){let r=t[i];if(r===e||wn.test(r))return!1;if(r==="\\"){if(++i>=s||wn.test(t[i]))return!1}}return!0}function An(t){if(xh(t))return t;return`"${t.replaceAll(/["\\\p{Cc}]/gu,(s)=>s==='"'||s==="\\"?`\\${s}`:`\\${s.codePointAt(0).toString(16)} `)}"`}class Da{#t=new Set;#e=new Set;#s=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.#t.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.#t.delete(t),this._document.fonts.delete(t)}insertRule(t){let e=this.#i();e.insertRule(t,e.cssRules.length)}#i(){if(this.#s)return this.#s;let t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let s=new t;return e.push(s),this.#s=s}}if(!this.styleElement)this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);return this.#s=this.styleElement.sheet}clear(){for(let t of this.#t)this._document.fonts.delete(t);if(this.#t.clear(),this.#e.clear(),this.#s){let{adoptedStyleSheets:t}=this._document;if(t?.includes(this.#s))this._document.adoptedStyleSheets=t.filter((e)=>e!==this.#s);this.#s=null}this.styleElement?.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!t||this.#e.has(t.loadedName))return;if(wt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:r,style:n}=t,a=new FontFace(i,r,n);this.addNativeFontFace(a);try{await a.load(),this.#e.add(i),s?.(t)}catch{W(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}at("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw W(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await this.#r(t)}}get isFontLoadingAPISupported(){return L(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return L(this,"isSyncFontLoadingSupported",Wt||lt.platform.isFirefox)}#r(t){function e(){wt(!n.done,"completeRequest() cannot be called twice."),n.done=!0;while(s.length>0&&s[0].done){let E=s.shift();setTimeout(E.resolve,0)}}let{loadingRequests:s}=this,{promise:i,resolve:r}=Promise.withResolvers(),n={done:!1,resolve:r};s.push(n),this._loadTestFont??=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");function a(E,T){return E.charCodeAt(T)<<24|E.charCodeAt(T+1)<<16|E.charCodeAt(T+2)<<8|E.charCodeAt(T+3)&255}function o(E){return String.fromCharCode(E>>24&255,E>>16&255,E>>8&255,E&255)}function l(E,T,k,C){let R=E.substring(0,T),B=E.substring(T+k);return R+C+B}let c,h,d=this._document.createElement("canvas");d.width=1,d.height=1;let u=d.getContext("2d"),f=0;function p(E,T){if(++f>30){W("Load test font never loaded."),T();return}if(u.font="30px "+E,u.fillText(".",0,20),u.getImageData(0,0,1,1).data[3]>0){T();return}setTimeout(p.bind(null,E,T))}let g=`lt${Date.now()}${this.loadTestFontId++}`,m=this._loadTestFont;m=l(m,976,g.length,g);let y=16,b=1482184792,_=a(m,y);for(c=0,h=g.length-3;c<h;c+=4)_=_-b+a(g,c)|0;if(c<g.length)_=_-b+a(g+"XXX",c)|0;m=l(m,y,4,o(_));let w=`url(data:font/opentype;base64,${btoa(m)});`,A=`@font-face {font-family:"${g}";src:${w}}`;this.insertRule(A);let x=this._document.createElement("div");x.style.visibility="hidden",x.style.width=x.style.height="10px",x.style.position="absolute",x.style.top=x.style.left="0px";for(let E of[t.loadedName,g]){let T=this._document.createElement("span");T.textContent="Hi",T.style.fontFamily=E,x.append(T)}return this._document.body.append(x),p(g,()=>{x.remove(),e()}),i}}class La{#t=new Map;#e;constructor(t,e=null,s,i){if(this.#e=t,this._inspectFont=e,s)this.charProcOperatorList=s;if(i)Object.assign(this,i)}createNativeFontFace(){let{data:t}=this;if(!t||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,t,{});else{let s={weight:this.cssFontInfo.fontWeight};if(this.cssFontInfo.italicAngle)s.style=`oblique ${this.cssFontInfo.italicAngle}deg`;e=new FontFace(An(this.cssFontInfo.fontFamily),t,s)}return this._inspectFont?.(this),e}createFontFaceRule(){let{data:t}=this;if(!t||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${t.toBase64()});`,s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;if(this.cssFontInfo.italicAngle)i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;s=`@font-face {font-family:${An(this.cssFontInfo.fontFamily)};${i}src:${e}}`}return this._inspectFont?.(this,e),s}getPathGenerator(t,e){let s=this.#t.get(e);if(s)return s;let i=`${this.loadedName}_path_${e}`,r;try{r=t.get(i)}catch(n){W(`getPathGenerator - ignoring character: "${n}".`)}if(s=la(r?.path),!this.fontExtraProperties)t.delete(i);return this.#t.set(e,s),s}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(t){L(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.missingFile?null:"font/opentype"}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}}class Ts{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,s){this._source=t,this.#t=e,this.#e=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return wt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new this.#e(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){this._fullReader?.cancel(t);for(let e of new Set(this._rangeReaders))e.cancel(t)}}class Cs{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){at("Abstract method `read` called")}cancel(t){at("Abstract method `cancel` called")}}class Is{_stream=null;constructor(t,e,s){this._stream=t}async read(){at("Abstract method `read` called")}cancel(t){at("Abstract method `cancel` called")}}function Th(t){let e=!0,s=i("filename\\*","i").exec(t);if(s){s=s[1];let h=o(s);return h=unescape(h),h=l(h),h=c(h),n(h)}if(s=a(t),s){let h=c(s);return n(h)}if(s=i("filename","i").exec(t),s){s=s[1];let h=o(s);return h=c(h),n(h)}function i(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function r(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let u=new TextDecoder(h,{fatal:!0}),f=Ai(d);d=u.decode(f),e=!1}catch{}}return d}function n(h){if(e&&/[\x80-\xff]/.test(h)){if(h=r("utf-8",h),e)h=r("iso-8859-1",h)}return h}function a(h){let d=[],u,f=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((u=f.exec(h))!==null){let[,g,m,v]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,v]}let p=[];for(let g=0;g<d.length;++g){if(!(g in d))break;let[m,v]=d[g];if(v=o(v),m){if(v=unescape(v),g===0)v=l(v)}p.push(v)}return p.join("")}function o(h){if(h.startsWith('"')){let d=h.slice(1).split("\\\"");for(let u=0;u<d.length;++u){let f=d[u].indexOf('"');if(f!==-1)d[u]=d[u].slice(0,f),d.length=u+1;d[u]=d[u].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function l(h){let d=h.indexOf("'");if(d===-1)return h;let u=h.slice(0,d),p=h.slice(d+1).replace(/^[^']*'/,"");return r(u,p)}function c(h){if(!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h))return h;return h.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," ").replaceAll(/=([0-9a-f]{2})/gi,(g,m)=>String.fromCharCode(parseInt(m,16))),r(u,p);try{p=atob(p)}catch{}return r(u,p)})}return""}function Na(t,e){let s=new Headers;if(!t||!e||typeof e!=="object")return s;for(let i in e){let r=e[i];if(r!==void 0)s.append(i,r)}return s}function Ch(t){let e=t.length;while(e>0&&t[e-1]!==" "&&/\s/.test(t[e-1]))e--;return t.slice(0,e)}function Pi(t){return URL.parse(t)?.origin??null}function Ba({responseHeaders:t,isHttp:e,rangeChunkSize:s,disableRange:i}){let r={contentLength:0,isRangeSupported:!1},n=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(n))return r;if(r.contentLength=n,n<=2*s)return r;if(i||!e||t.get("Accept-Ranges")!=="bytes")return r;if((t.get("Content-Encoding")||"identity")==="identity")r.isRangeSupported=!0;return r}function ja(t){let e=t.get("Content-Disposition");if(e){let s=Th(e);if(s.includes("%"))try{s=decodeURIComponent(s)}catch{}if(Er(s))return s}return null}function ki(t,e){return new gs(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,t===404||t===0&&e.protocol==="file:")}function Ha(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function Ua(t,e,s,i){return fetch(t,{method:"GET",headers:e,signal:i.signal,mode:"cors",credentials:s?"include":"same-origin",redirect:"follow"})}function $a(t,e){if(t!==200&&t!==206)throw ki(t,e)}function Mi(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error(`getArrayBuffer - unexpected data: ${t}`)}class Ga extends Ts{_responseOrigin=null;constructor(t){super(t,za,Va);let{httpHeaders:e,url:s}=t;wt(/https?:/.test(s.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Na(!0,e)}}class za extends Cs{_abortController=new AbortController;_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,rangeChunkSize:i,url:r,withCredentials:n}=t._source;this._isStreamingSupported=!s;let a=new Headers(t.headers);Ua(r,a,n,this._abortController).then((o)=>{t._responseOrigin=Pi(o.url),$a(o.status,r),this._reader=o.body.getReader();let l=o.headers,{contentLength:c,isRangeSupported:h}=Ba({responseHeaders:l,isHttp:!0,rangeChunkSize:i,disableRange:e});if(this._contentLength=c,this._isRangeSupported=h,this._filename=ja(l),!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new ve("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return this._loaded+=t.byteLength,this._callOnProgress(),{value:Mi(t),done:!1}}cancel(t){this._reader?.cancel(t).catch(()=>{}),this._abortController.abort()}}class Va extends Is{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i,withCredentials:r}=t._source,n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`),Ua(i,n,r,this._abortController).then((a)=>{let o=Pi(a.url);Ha(o,t._responseOrigin),$a(a.status,i),this._reader=a.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject),this._readCapability.promise.catch(()=>{})}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Mi(t),done:!1}}cancel(t){this._reader?.cancel(t).catch(()=>{}),this._abortController.abort()}}function Sn(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function Oi(){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class Wa extends Ts{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,Xa,Ya);let{pdfDataRangeTransport:e}=t,{initialData:s,progressiveDone:i}=e;if(s?.length>0){let n=Sn(s);this._queuedChunks.push(n)}this._progressiveDone=i;let r=(n)=>{switch(n.type){case"range":case"progressiveRead":this.#t(n.begin,n.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};e.transportReady(r)}#t(t,e){let s=Sn(e);if(t===void 0)if(this._fullReader)this._fullReader._enqueue(s);else this._queuedChunks.push(s);else{let i=this._rangeReaders.keys().find((r)=>r._begin===t);wt(i,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),i._enqueue(s)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let s=super.getRangeReader(t,e);if(s)s.onDone=()=>this._rangeReaders.delete(s),this._source.pdfDataRangeTransport.requestDataRange(t,e);return s}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class Xa extends Cs{#t=Oi.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);let{pdfDataRangeTransport:e,disableRange:s,disableStream:i}=t._source,{length:r,contentDispositionFilename:n}=e;this._queuedChunks=t._queuedChunks||[];for(let o of this._queuedChunks)this._loaded+=o.byteLength;if(this._done=t._progressiveDone,this._contentLength=r,this._isStreamingSupported=!i,this._isRangeSupported=!s,Er(n))this._filename=n;this._headersCapability.resolve();let a=this._loaded;Promise.resolve().then(()=>{if(a>0&&this._loaded===a)this._callOnProgress()})}_enqueue(t){if(this._done)return;if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength,this._callOnProgress()}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){if(this._done||=!0,this._queuedChunks.length===0)this.#t()}}class Ya extends Is{#t=Oi.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,s){super(t,e,s);this._begin=e}_enqueue(t){if(this._done)return;if(this._requests.length===0)this._queuedChunk=t;else this._requests.shift().resolve({value:t,done:!1}),this.#t();this._done=!0,this.onDone?.()}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}}var Wi=200,En=206;function Ih(t){return typeof t!=="string"?t:Ai(t).buffer}class Ka extends Ts{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,qa,Ja);let{httpHeaders:e,url:s}=t;this.url=s,this.isHttp=/https?:/.test(s.protocol),this.headers=Na(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,s={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,s),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(let[i,r]of this.headers)e.setRequestHeader(i,r);if(this.isHttp&&"begin"in t&&"end"in t)e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.validateStatus=(i)=>i===En||i===Wi;else s.validateStatus=(i)=>i===Wi;return e.responseType="arraybuffer",wt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#s.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#s(t,e){let s=this.#t.get(t);if(!s)return;if(t.readyState>=2&&s.onHeadersReceived)s.onHeadersReceived(),delete s.onHeadersReceived;if(t.readyState!==4)return;if(!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){s.onError(t.status);return}let i=t.status||Wi;if(!s.validateStatus(i)){s.onError(t.status);return}let r=Ih(t.response);if(i===En){let n=t.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(n))s.onDone(r);else W('Missing or invalid "Content-Range" header.'),s.onError(0)}else if(r)s.onDone(r);else s.onError(t.status)}_abortRequest(t){if(this.#t.has(t))this.#t.delete(t),t.abort()}getRangeReader(t,e){let s=super.getRangeReader(t,e);if(s)s.onClosed=()=>this._rangeReaders.delete(s);return s}}class qa extends Cs{#t=Oi.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t);this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:this.#r.bind(this)})}#e(){let t=this._stream,{disableRange:e,rangeChunkSize:s}=t._source,i=this._fullRequestXhr;t._responseOrigin=Pi(i.responseURL);let r=i.getAllResponseHeaders(),n=new Headers(r?Ch(r.trimStart()).split(/[\r\n]+/).map((l)=>{let[c,...h]=l.split(": ");return[c,h.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=Ba({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:s,disableRange:e});if(this._contentLength=a,this._isRangeSupported=o,this._filename=ja(n),this._isRangeSupported)t._abortRequest(i);this._headersCapability.resolve()}#s(t){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._cachedChunks.push(t);if(this._done=!0,this._cachedChunks.length===0)this.#t()}#i(t){this._storedError=ki(t,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#r(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class Ja extends Is{#t=Oi.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,s){super(t,e,s);this._requestXhr=t._request({begin:e,end:s,onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:null})}#e(){let t=Pi(this._requestXhr?.responseURL);try{Ha(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#i(0)}}#s(t){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunk=t;this._done=!0,this.#t(),this.onClosed?.()}#i(t){this._storedError??=ki(t,this._stream.url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function Qa(t,e=null){let s=process.getBuiltinModule("fs"),{Readable:i}=process.getBuiltinModule("stream"),r=s.createReadStream(t,e);return i.toWeb(r)}class Za extends Ts{constructor(t){super(t,to,eo);let{url:e}=t;wt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class to extends Cs{_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,rangeChunkSize:i,url:r}=t._source;this._isStreamingSupported=!s,process.getBuiltinModule("fs/promises").lstat(r).then((a)=>{let o=Qa(r);this._reader=o.getReader();let{size:l}=a;if(this._contentLength=l,this._isRangeSupported=!e&&l>2*i,!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new ve("Streaming is disabled."));this._headersCapability.resolve()}).catch((a)=>{if(a.code==="ENOENT")a=ki(0,r);this._headersCapability.reject(a)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return this._loaded+=t.byteLength,this._callOnProgress(),{value:Mi(t),done:!1}}cancel(t){this._reader?.cancel(t).catch(()=>{})}}class eo extends Is{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i}=t._source;try{let r=Qa(i,{start:e,end:s-1});this._reader=r.getReader(),this._readCapability.resolve()}catch(r){this._readCapability.reject(r)}this._readCapability.promise.catch(()=>{})}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Mi(t),done:!1}}cancel(t){this._reader?.cancel(t).catch(()=>{})}}function Ph(t){return ds(t)?Ga:Wt?Za:Ka}class Zt{static#t=null;static#e=[];static#s="";static#i="";static get rendererPorts(){return this.#e}static set rendererPorts(t){if(!Array.isArray(t)||!t.every((e)=>typeof Worker<"u"&&e instanceof Worker))throw Error("Invalid `rendererPorts` type.");this.#e=t}static get rendererSrc(){return this.#s}static set rendererSrc(t){if(typeof t!=="string")throw Error("Invalid `rendererSrc` type.");this.#s=t}static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#i}static set workerSrc(t){if(typeof t!=="string")throw Error("Invalid `workerSrc` type.");this.#i=t}}class so{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}class io{static strings=["fontFamily","fontWeight","italicAngle"]}class ro{static strings=["css","loadedName","baseFontName","src"]}class Pe{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static strings=["fallbackName","loadedName"];static OFFSET_BBOX=Math.ceil(this.bools.length*2/8);static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_STRINGS=this.OFFSET_FONT_MATRIX+1+48}class be{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class no{static get decoder(){return L(this,"decoder",new TextDecoder)}static get encoder(){return L(this,"encoder",new TextEncoder)}}function ps(t,e,s,i=0){let{decoder:r}=no;for(let a=0;a<s;a++)i+=e.getUint32(i)+4;let n=e.getUint32(i);return r.decode(new Uint8Array(t,i+4,n))}class ao{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){return wt(t<io.strings.length,"Invalid string index"),ps(this.#t,this.#e,t)}get fontFamily(){return L(this,"fontFamily",this.#s(0))}get fontWeight(){return L(this,"fontWeight",this.#s(1))}get italicAngle(){return L(this,"italicAngle",this.#s(2))}}class oo{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){return wt(t<ro.strings.length,"Invalid string index"),ps(this.#t,this.#e,t,4)}get css(){return L(this,"css",this.#s(0))}get loadedName(){return L(this,"loadedName",this.#s(1))}get baseFontName(){return L(this,"baseFontName",this.#s(2))}get src(){return L(this,"src",this.#s(3))}get style(){let t=0;t+=4+this.#e.getUint32(t);let e=ps(this.#t,this.#e,0,t),s=ps(this.#t,this.#e,1,t);return L(this,"style",{style:e,weight:s})}}class lo{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){wt(t<Pe.bools.length,"Invalid boolean index");let e=Math.floor(t/4),s=t*2%8,i=this.#e.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return L(this,"black",this.#s(0))}get bold(){return L(this,"bold",this.#s(1))}get disableFontFace(){return L(this,"disableFontFace",this.#s(2))}get fontExtraProperties(){return L(this,"fontExtraProperties",this.#s(3))}get isInvalidPDFjsFont(){return L(this,"isInvalidPDFjsFont",this.#s(4))}get isType3Font(){return L(this,"isType3Font",this.#s(5))}get italic(){return L(this,"italic",this.#s(6))}get missingFile(){return L(this,"missingFile",this.#s(7))}get remeasure(){return L(this,"remeasure",this.#s(8))}get vertical(){return L(this,"vertical",this.#s(9))}#i(t,e,s,i){let r=this.#e.getUint8(t++);if(r===0)return;wt(r===e,"Invalid array length.");let n=Array(r);for(let a=0;a<r;a++)n[a]=this.#e[s](t,!0),t+=i;return n}get bbox(){return L(this,"bbox",this.#i(Pe.OFFSET_BBOX,4,"getInt16",2))}get fontMatrix(){return L(this,"fontMatrix",this.#i(Pe.OFFSET_FONT_MATRIX,6,"getFloat64",8))}#r(t){return wt(t<Pe.strings.length,"Invalid string index"),ps(this.#t,this.#e,t,Pe.OFFSET_STRINGS+4)}get fallbackName(){return L(this,"fallbackName",this.#r(0))}get loadedName(){return L(this,"loadedName",this.#r(1))}#n(t){let e=Pe.OFFSET_STRINGS;for(let i=0;i<=t;i++)e+=4+this.#e.getUint32(e);let s=this.#e.getUint32(e);return{offset:e,length:s}}get data(){let{offset:t,length:e}=this.#n(2);return!e?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){let{offset:t,length:e}=this.#n(2);if(!e)return;this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t)}get cssFontInfo(){let{offset:t,length:e}=this.#n(1),s=null;if(e){let i=new Uint8Array(this.#t,t+4,e).slice();s=new ao(i.buffer)}return L(this,"cssFontInfo",s)}get systemFontInfo(){let{offset:t,length:e}=this.#n(0),s=null;if(e){let i=new Uint8Array(this.#t,t+4,e).slice();s=new oo(i.buffer)}return L(this,"systemFontInfo",s)}}class co{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[be.KIND],s=!!this.data[be.HAS_BBOX],i=!!this.data[be.HAS_BACKGROUND],r=t.getUint32(be.N_COORD,!0),n=t.getUint32(be.N_COLOR,!0),a=t.getUint32(be.N_STOP,!0),o=20,l=new Float32Array(this.buffer,o,r*2);o+=r*8;let c=new Uint8Array(this.buffer,o,n*4);o+=n*4;let h=[];for(let f=0;f<a;++f){let p=t.getFloat32(o,!0);o+=4;let g=t.getUint32(o,!0);o+=4,h.push([p,`#${g.toString(16).padStart(6,"0")}`])}let d=null;if(s){d=[];for(let f=0;f<4;++f)d.push(t.getFloat32(o,!0)),o+=4}let u=null;if(i)u=new Uint8Array(this.buffer,o,3),o+=3;if(e===1)return["RadialAxial","axial",d,h,[l[0],l[1]],[l[2],l[3]],null,null];if(e===2)return["RadialAxial","radial",d,h,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){let f=this.data[be.SHADING_TYPE],p=null;if(l.length>0){p=ce.slice();for(let g=0,m=l.length;g<m;g+=2)O.pointBoundingBox(l[g],l[g+1],p)}return["Mesh",f,l,c,r,p,d,u]}throw Error(`Unsupported pattern kind: ${e}`)}}class ho{#t;constructor(t){this.#t=t}get path(){if(lt.isFloat16ArraySupported)return new Float16Array(this.#t);return new Float32Array(this.#t)}}var ke=Symbol("INITIAL_DATA"),Xi=()=>({...Promise.withResolvers(),data:ke});class Ri{#t=new Map;get(t,e=null,s=null){if(e){let r=this.#t.getOrInsertComputed(t,Xi);return r.promise.then(()=>e(r.data),s),null}let i=this.#t.get(t);if(!i||i.data===ke)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#t.get(t);return!!e&&e.data!==ke}delete(t){let e=this.#t.get(t);if(!e||e.data===ke)return!1;return this.#t.delete(t),!0}resolve(t,e=null){let s=this.#t.getOrInsertComputed(t,Xi);if(s.data!==ke)throw Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}reject(t,e){let s=this.#t.getOrInsertComputed(t,Xi);if(s.data!==ke)return;s.promise.catch(()=>{}),s.reject(e)}clear(){for(let{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#t)if(e!==ke)yield[t,e]}}class uo{constructor({messageHandler:t,commonObjs:e,fontLoader:s,pageCache:i,pdfBug:r=!1,shouldCreatePageObjs:n=!1}){this.messageHandler=t,this.commonObjs=e,this.fontLoader=s,this.pageCache=i,this.pdfBug=r,this.shouldCreatePageObjs=n}resolveCommonObject(t,e,s){if(e==="CopyLocalImage"){let{imageRef:i}=s;wt(i,"The imageRef must be defined.");for(let r of this.pageCache.values()){let n=r.objs||r;for(let[,a]of n){if(a?.ref!==i)continue;if(!a.dataLen)return null;let o=structuredClone(a);return this.commonObjs.resolve(t,o),a.dataLen}}return null}switch(e){case"Font":if("error"in s){let o=s.error;W(`Error during font loading: ${o}`),this.commonObjs.resolve(t,o);break}let i=new lo(s.buffer),r=this.pdfBug&&globalThis.FontInspector?.enabled?(o,l)=>globalThis.FontInspector.fontAdded(o,l):null,n=new La(i,r,s.charProcOperatorList,s.extra);this.fontLoader.bind(n).catch(()=>this.messageHandler.sendWithPromise("FontFallback",{id:t}).catch((o)=>{W(`FontFallback failed for "${t}": ${o}`)})).finally(()=>{if(!n.fontExtraProperties)n.clearData();this.commonObjs.resolve(t,n)});break;case"FontPath":this.commonObjs.resolve(t,new ho(s));break;case"Image":this.commonObjs.resolve(t,s);break;case"Pattern":let a=new co(s);this.commonObjs.resolve(t,a.getIR());break;default:throw Error(`Got unknown common object type ${e}`)}return null}resolveObject(t,e,s,i){let r=this.pageCache.get(e);if(!r){if(!this.shouldCreatePageObjs)return!1;r=new Ri,this.pageCache.set(e,r)}let n=r.objs||r;if(n.has(t))return!1;if(r._intentStates?.size===0)return i?.bitmap?.close(),!1;switch(s){case"Image":case"Pattern":return n.resolve(t,i),!0;default:throw Error(`Got unknown object type ${s}`)}}}var Me=Symbol("INTERNAL");class fo{#t=!1;#e=!1;#s=!1;#i=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){this.#t=!!(t&Vt.DISPLAY),this.#e=!!(t&Vt.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(this.#s)return this.#i;if(!this.#i)return!1;let{print:t,view:e}=this.usage;if(this.#t)return e?.viewState!=="OFF";else if(this.#e)return t?.printState!=="OFF";return!0}_setVisible(t,e,s=!1){if(t!==Me)at("Internal method `_setVisible` called.");this.#s=s,this.#i=e}get serializable(){return{userSet:this.#s,visible:this.#i}}}class Or{#t=null;#e=new Map;#s=null;#i=null;#r;creator=null;name=null;constructor(t,e=Vt.DISPLAY,s=null){if(this.#r=t,this.renderingIntent=e,t===null)return;this.name=t.name,this.creator=t.creator,this.#i=t.order;for(let i of t.groups)this.#e.set(i.id,new fo(e,i));if(s){if(s.size!==this.#e.size)at("Incorrect serialized groupState.");for(let[i,r]of s)this.#e.get(i)._setVisible(Me,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(let i of this.#e.values())i._setVisible(Me,!1);for(let i of t.on)this.#e.get(i)._setVisible(Me,!0);for(let i of t.off)this.#e.get(i)._setVisible(Me,!1)}this.#s=this.getHash()}#n(t){let e=t.length;if(e<2)return!0;let s=t[0];for(let i=1;i<e;i++){let r=t[i],n;if(Array.isArray(r))n=this.#n(r);else if(this.#e.has(r))n=this.#e.get(r).visible;else return W(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return wi("Optional content group not defined."),!0;if(t.type==="OCG"){if(!this.#e.has(t.id))return W(`Optional content group not found: ${t.id}`),!0;return this.#e.get(t.id).visible}else if(t.type==="OCMD"){if(t.expression)return this.#n(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return W(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return W(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return W(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return W(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return W(`Unknown optional content policy ${t.policy}.`),!0}return W(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){let i=this.#e.get(t);if(!i){W(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length){for(let r of i.rbGroups)for(let n of r)if(n!==t)this.#e.get(n)?._setVisible(Me,!1,!0)}i._setVisible(Me,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(let i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}let r=this.#e.get(i);if(!r)continue;switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){if(!this.#e.size)return null;return this.#i?this.#i.slice():[...this.#e.keys()]}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new Ys;for(let[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}get serializable(){let t=new Map;for(let[e,s]of this.#e)t.set(e,s.serializable);return{data:this.#r,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new Or(t,e,s)}}class po{#t=null;#e=null;#s=0;#i=0;#r=null;#n=null;get pagesNumber(){return this.#s}set pagesNumber(t){if(this.#s===t)return;this.#s=this.#i=t,this.#t=null,this.#e=null}#a(){if(this.#t)return;let t=this.#s,e=this.#t=new Uint32Array(t);for(let s=0;s<t;s++)e[s]=s+1;this.#e=new Int32Array(e)}#o(){let t=new Map,e=this.#t;for(let s=0,i=this.#s;s<i;s++){let r=e[s],n=t.get(r);if(n)n.push(s+1);else t.set(r,[s+1])}return t}movePages(t,e,s){this.#a();let i=this.#t,r=e.length,n=new Uint32Array(r),a=0;for(let d=0;d<r;d++){let u=e[d]-1;if(n[d]=i[u],u<s)a++}let o=this.#s,l=o-r,c=new Int32Array(o),h=pt(s-a,0,l);for(let d=0,u=0;d<o;d++)if(!t.has(d+1))i[u]=i[d],c[u++]=d+1;if(i.copyWithin(h+r,h,l),i.set(n,h),c.copyWithin(h+r,h,l),c.set(e,h),this.#e=c,o===this.#i&&i.every((d,u)=>d===u+1))this.#t=null}deletePages(t){this.#a();let e=this.#t,s=this.#o();this.#n={pageNumberToId:e.slice(),pagesNumber:this.#s,prevPageNumbers:this.#e.slice()};let i=this.#s-t.length;this.#s=i;let r=this.#t=new Uint32Array(i);this.#e=new Int32Array(i);let n=0,a=0;for(let o of t){let l=o-1;if(l!==n)r.set(e.subarray(n,l),a),a+=l-n;n=l+1}if(n<e.length)r.set(e.subarray(n),a);this.#l(s,new Set(t))}cancelDelete(){if(this.#n)this.#t=this.#n.pageNumberToId,this.#s=this.#n.pagesNumber,this.#e=this.#n.prevPageNumbers,this.#n=null}cleanSavedData(){this.#n=null}copyPages(t){this.#a(),this.#r={pageNumbers:t,pageIds:t.map((e)=>this.#t[e-1])}}cancelCopy(){this.#r=null}pastePages(t){this.#a();let e=this.#t,s=this.#o(),{pageNumbers:i,pageIds:r}=this.#r,n=this.#s+i.length;this.#s=n;let a=this.#t=new Uint32Array(n);this.#e=new Int32Array(n),a.set(e.subarray(0,t),0),a.set(r,t),a.set(e.subarray(t),t+i.length),this.#l(s,null,t,i),this.#r=null}#l(t,e=null,s=-1,i=null){let r=this.#e,n=this.#t,a=s+(i?.length??0),o=new Map;for(let l=0,c=this.#s;l<c;l++){if(l>=s&&l<a){r[l]=-i[l-s];continue}let h=n[l],d=t.get(h),u=o.get(h)||0;if(e&&d)while(u<d.length&&e.has(d[u]))u++;r[l]=d?.[u],o.set(h,u+1)}}hasBeenAltered(){return this.#t!==null}#c(t=null){if(!this.#t)return null;let e=new Int32Array(this.#s).fill(-1),s=new Map;if(t)for(let i of t){let r=this.getPageId(i),n=s.get(r)??0;s.set(r,n+1),e[i-1]=n}else for(let i=0,r=this.#s;i<r;i++){let n=this.#t[i],a=s.get(n)??0;s.set(n,a+1),e[i]=a}return e}getPageMappingForSaving(t=null,e=this.#c()){t??=this.#o();let s=0;for(let r of t.values())s=Math.max(s,r.length);let i=Array(s);for(let r=0;r<s;r++)i[r]={document:null,pageIndices:[],includePages:[]};for(let[r,n]of t)for(let a=0,o=n.length;a<o;a++)i[a].includePages.push([r-1,n[a]-1]);for(let{includePages:r,pageIndices:n}of i){r.sort((a,o)=>a[0]-o[0]);for(let a=0,o=r.length;a<o;a++)n.push(r[a][1]),r[a]=r[a][0]}return{pageInfos:i,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);let e=new Map;for(let s=0,i=t.length;s<i;s++){let r=this.getPageId(t[s]);e.getOrInsertComputed(r,Ze).push(s+1)}return this.getPageMappingForSaving(e,this.#c(t))}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;let e=this.#t;for(let s=0,i=this.#s;s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}var xn=5000;function rr({bitmap:t,annotationBitmaps:e}){if(t?.close(),e)for(let[,,s]of e)s.close()}class go{#t;#e=!1;#s;#i;#r=0;#n;#a;#o;#l;#c;#u;#h;imageCoordinates=null;recordedBBoxes=null;constructor({rendererWorker:t,renderTasks:e,canvas:s,canvasFactory:i,annotationCanvasMap:r,operatorListState:n,initParams:a,onFrame:o,onError:l}){this.#u=t,this.#h=e,this.#s=s,this.#i=i,this.#t=r,this.#c=n,this.#a=a,this.#n=a.renderTaskId,this.#l=o,this.#o=l}async initialize(t,e){try{await this.#u.promise}catch{return!1}if(!this.#u.messageHandler||this.#e)return!1;try{await this.#u.sendWithPromise("InitializeGraphics",{...this.#a,width:this.#s.width,height:this.#s.height,transparency:t,optionalContentConfig:e.serializable})}catch(s){if(!this.#e)W(`Failed to initialize graphics in renderer worker: ${s.message}. Falling back to main-thread rendering.`);return!1}if(!this.#e)this.#h.set(this.#n,this);return!0}async executeOperatorList(t,e,s){let i=this.#u.messageHandler;if(!i)throw Error("Renderer worker was destroyed during rendering.");let{lastChunk:r}=t,n=t.argsArray.length,a=this.#c;if(a.sentLength<n){let c=a.sentLength;i.send("AppendOperatorList",{pageProxyId:this.#a.pageProxyId,operatorListId:a.id,fnArray:t.fnArray.slice(c,n),argsArray:t.argsArray.slice(c,n)}),a.sentLength=n}let o=null;if(s&&this.#r<n){let c=this.#r;o=new Uint8Array(n-c);for(let h=c;h<n;h++)o[h-c]=s(h,t)?1:0;this.#r=n}let l=await this.#u.sendWithPromise("ExecuteOperatorList",{renderTaskId:this.#n,operatorListIdx:e,operatorListLength:n,operationsFilterMask:o,lastChunk:r}).catch((c)=>{if(!this.#e)throw c;return{operatorListIdx:e,aborted:!0}});if(l.aborted&&!this.#e)throw Error("Render task was aborted in the renderer worker.");if(r&&l.operatorListIdx===n){this.#h.delete(this.#n);let{recordedBBoxesBuffer:c,imageCoordinates:h}=l;if(c)this.recordedBBoxes=Ci.fromBuffer(c);this.imageCoordinates=h??null}return l.operatorListIdx}cancel(){this.#e=!0,this.#h.delete(this.#n),this.#u.messageHandler?.send("CleanupRenderTask",{renderTaskId:this.#n})}drawFrame(t){try{if(t.bitmap)this.#i.getNoAlphaContext(this.#s).drawImage(t.bitmap,0,0);if(t.annotationBitmaps)this.#f(t.annotationBitmaps)}catch(e){this.#o(e);return}finally{rr(t)}this.#l()}#f(t){let e=this.#t,s=new Set;for(let[i,r,n]of t){let{canvas:a,context:o}=this.#i.create(n.width,n.height);if(o.drawImage(n,0,0),!r){e.set(i,a);continue}if(Ma(a,r),s.has(i))e.get(i).push(a);else s.add(i),e.set(i,[a])}}}class Fe{#t=Promise.withResolvers();#e;#s;#i=null;#r=0;#n=new WeakMap;#a=[];#o=new Set;#l=null;#c=null;#u=0;#h=new Map;#f=null;#p=null;#m=null;static#d=0;static#g=new WeakSet;destroyed=!1;constructor({port:t=null,verbosity:e=ia(),enableHWA:s=!1,enableWebGPU:i=!1}={}){if(this.verbosity=e,this.#e=s,this.#s=i,t)this.#b(t);else this.#_()}static get isAvailable(){return(!!Zt.rendererSrc||Zt.rendererPorts.length>0)&&typeof Worker<"u"&&lt.isOffscreenCanvasSupported&&!!globalThis.document?.fonts}get promise(){return this.#t.promise}get messageHandler(){return this.#i}get port(){return this.#l}#v(){this.#i.on("RenderFrame",(e)=>{let s=this.#h.get(e.renderTaskId);if(s)s.drawFrame(e);else rr(e)}),this.#t.resolve(),this.#i.send("configure",{verbosity:this.verbosity,enableHWA:this.#e,enableWebGPU:this.#s});let t=this.#a;this.#a=null;for(let e of t)e()}#y(t){this.#a=null,this.#t.reject(t)}#b(t){Fe.#g.add(t),this.#l=t;let e=Fe.#d++,s=`main${e}`,i=`renderer${e}`;this.#c={sourceName:s,targetName:i};let r=new ge("main","renderer",t);r.send("Connect",{sourceName:i,targetName:s}),r.destroy(),this.#A(t,new ge(s,i,t),!0)}#_(){try{let{rendererSrc:t}=Zt;if(!t)throw Error('No "GlobalWorkerOptions.rendererSrc" specified.');let e=new Worker(va(t),{type:"module"});this.#A(e,new ge("main","renderer",e),!1)}catch(t){this.#y(t)}}#A(t,e,s){let i=null,r=(o)=>{if(this.#f=null,clearTimeout(i),n.abort(),e.destroy(),s)this.#l=null;else t.terminate();this.#y(Error(`Renderer worker failed to initialize: "${o?.message??o}".`))};this.#f=r;let n=new AbortController,a=(o,l)=>{if(!this.#i){r(l);return}o.preventDefault(),W(`Renderer worker failed: "${l}". Falling back to main-thread rendering.`),this.destroy()};if(t.addEventListener("error",(o)=>a(o,o.error?.message??o.message),{signal:n.signal}),t.addEventListener("messageerror",(o)=>a(o,"Cannot deserialize a message."),{signal:n.signal}),s)i=setTimeout(()=>r("Connection timed out."),xn);e.on("ready",(o)=>{if(!(o?.testObj instanceof Uint8Array)){r("TypedArray transfer test failed.");return}let l="6.5.438";if(l!==o.workerVersion){r(`The API version "${l}" does not match the Worker version "${o.workerVersion}".`);return}if(this.#f=null,clearTimeout(i),this.#i=e,!s)this.#p=t;this.#m=n,this.#v()})}destroy(){if(this.destroyed=!0,this.#l){if(this.#i)this.#S(this.#l),this.#i.send("Disconnect",null);Fe.#g.delete(this.#l),this.#l=null}this.#f?.("Worker was destroyed."),this.#m?.abort(),this.#m=null,this.#p?.terminate(),this.#p=null,this.#i?.destroy(),this.#i=null;for(let t of this.#o)t(Error("Renderer worker was destroyed."));this.#o.clear()}#S(t){let{sourceName:e,targetName:s}=this.#c,i=new AbortController,r=setTimeout(()=>i.abort(),xn);t.addEventListener("message",({data:n})=>{if(n?.targetName!==e||n.sourceName!==s)return;if(n.action==="RenderFrame")rr(n.data);else if(n.action==="Disconnected")clearTimeout(r),i.abort()},{signal:i.signal})}static create({ports:t=[],...e}={}){let s=t.find((i)=>!this.#g.has(i))??null;if(!s&&t.length>0)W("RendererWorker.create - no unused `rendererPorts` available, falling back to `rendererSrc`.");return new Fe({...e,port:s})}sendWithPromise(t,e){let s=this.#i;if(!s)return Promise.reject(Error("Renderer worker was destroyed."));let{promise:i,resolve:r,reject:n}=Promise.withResolvers();return this.#o.add(n),s.sendWithPromise(t,e).then(r,n),i.finally(()=>{this.#o.delete(n)})}#w(t,e){if(this.#a){this.#a.push(()=>this.#w(t,e));return}this.#i?.send(t,e)}#E(t,e,s,i,r=!1){try{if(this.#a){let n=r?structuredClone(e):e;this.#a.push(()=>this.#E(t,n,s,i));return}this.#i?.send(t,e)}catch(n){W(`RendererWorker - failed to send "${t}": ${n}`),this.#w("objFailed",{id:s,pageProxyId:i,reason:n.message})}}sendCommonObj(t,e,s){this.#E("commonobj",[t,e,s],t,null,e==="Font")}sendObj(t,e,s,i){this.#E("obj",[t,e,s,i],t,e)}cleanup(t){this.#w("Cleanup",{keepLoadedFonts:t})}cleanupPage(t){this.#w("cleanupPage",{pageProxyId:t})}createRenderTask({pageProxyId:t,operatorList:e,params:s,pageColors:i,canvasFactory:r,annotationCanvasMap:n,onFrame:a,onError:o}){let{canvas:l,canvasContext:c,background:h}=s;if(!this.#i&&!this.#a||c||h&&typeof h!=="string"||i||s.recordForDebugger)return null;let d=this.#n.getOrInsertComputed(e,()=>({id:this.#r++,sentLength:0}));return new go({rendererWorker:this,renderTasks:this.#h,canvas:l,canvasFactory:r,annotationCanvasMap:n,operatorListState:d,initParams:{pageProxyId:t,operatorListId:d.id,renderTaskId:this.#u++,hasAnnotationCanvasMap:!!n,recordOperations:s.recordOperations,recordImages:s.recordImages,partialFrames:s.partialFrames,transform:s.transform,viewport:s.viewport,background:h,pixelRatio:Kt.pixelRatio},onFrame:a,onError:o})}}var kh=1e5,Mh=30;class Lt{#t=Promise.withResolvers();#e=null;#s=!1;#i=!!globalThis.FontInspector?.enabled;#r=null;#n=null;#a=null;#o=0;#l=0;#c=Kt.pixelRatio;#u=null;#h=null;#f=0;#p=0;#m=Object.create(null);#d=[];#g=null;#v=[];#y=null;static#b=new Map;static#_=new Map;static#A=new WeakMap;static#S=null;static#w=new Set;constructor({textContentSource:t,images:e,container:s,viewport:i}){if(t instanceof ReadableStream)this.#g=t;else if(typeof t==="object")this.#g=new ReadableStream({start(l){l.enqueue(t),l.close()}});else throw Error('No "textContentSource" parameter specified.');this.#e=this.#h=s,this.#r=e,this.#p=i.scale*this.#c,this.#f=i.rotation,this.#a={div:null,properties:null,ctx:null};let{pageWidth:r,pageHeight:n,pageX:a,pageY:o}=i.rawDims;this.#y=[1,0,0,-1,-a,o+n],this.#l=r,this.#o=n,Lt.#O(),s.style.setProperty("--min-font-size",Lt.#S),Ne(s,i),this.#t.promise.finally(()=>{Lt.#w.delete(this),this.#a=null,this.#m=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=lt.platform;return L(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){if(this.#r)this.#e.append(this.#r.render());let t=()=>{this.#u.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#n??=e.lang,Object.assign(this.#m,e.styles),this.#E(e.items),t()},this.#t.reject)};return this.#u=this.#g.getReader(),Lt.#w.add(this),t(),this.#t.promise}update({viewport:t}){let e=t.scale*Kt.pixelRatio,s=t.rotation;if(s!==this.#f)this.#f=s,Ne(this.#h,{rotation:s});if(e!==this.#p)this.#p=e,this.#c=Kt.pixelRatio}cancel(){let t=new ve("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#v}get textContentItemsStr(){return this.#d}#E(t){if(this.#s)return;this.#a.ctx??=Lt.#C(this.#n);let e=this.#v,s=this.#d;for(let i of t){if(e.length>kh){W("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){let r=this.#e;if(this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id)this.#e.setAttribute("id",i.id);if(i.tag==="Artifact")this.#e.ariaHidden=!0;r.append(this.#e)}else if(i.type==="endMarkedContent")this.#e=this.#e.parentNode;continue}s.push(i.str),this.#M(i)}}#M(t){let e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#v.push(e);let i=O.transform(this.#y,t.transform),r=Math.atan2(i[1],i[0]),n=this.#m[t.fontName];if(n.vertical)r+=Math.PI/2;let a=this.#i&&n.fontSubstitution||n.fontFamily;a=Lt.fontFamilyMap.get(a)||a;let o=Math.hypot(i[2],i[3]),l=o*Lt.#D(a,n,this.#n),c,h;if(r===0)c=i[4],h=i[5]-l;else c=i[4]+l*Math.sin(r),h=i[5]-l*Math.cos(r);let d=e.style;d.left=`${(100*c/this.#l).toFixed(2)}%`,d.top=`${(100*h/this.#o).toFixed(2)}%`;let u=Math.round(o*100)/100;if(d.setProperty("--font-height",`${u}px`),d.fontFamily=a,s.fontSize=u,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#i)e.dataset.fontName=n.fontSubstitutionLoadedName||t.fontName;if(r!==0)s.angle=r*(180/Math.PI);let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let p=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);if(p!==g&&Math.max(p,g)/Math.min(p,g)>1.5)f=!0}if(f)s.canvasWidth=n.vertical?t.height:t.width;if(this.#a.div=e,this.#a.properties=s,this.#I(this.#a),s.hasText)this.#e.append(e);if(s.hasEOL){let p=document.createElement("br");p.setAttribute("role","presentation"),this.#e.append(p)}}#I(t){let{div:e,properties:s,ctx:i}=t,{style:r}=e,{canvasWidth:n,fontSize:a}=s;if(n!==0&&a!==0&&s.hasText){let{fontFamily:o}=r,l=this.#c,c=Lt.#F(a*this.#p/l)*l;Lt.#P(i,c,o);let{width:h}=i.measureText(e.textContent);if(h>0)r.setProperty("--scale-x",n*c/(h*a))}if(s.angle!==0)r.setProperty("--rotate",`${s.angle}deg`)}static cleanup(){if(this.#w.size>0)return;this.#b.clear();for(let{canvas:t}of this.#_.values())t.remove();this.#_.clear()}static#C(t=null){let e=this.#_.get(t||="");if(!e){let s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_.set(t,e),this.#A.set(e,{size:0,family:""})}return e}static#F(t){t=Math.fround(t);let e=Math.fround(t*131073);return Math.fround(e-Math.fround(e-t))}static#P(t,e,s){let i=this.#A.get(t);if(e===i.size&&s===i.family)return;t.font=`${e}px ${s}`,i.size=e,i.family=s}static#O(){if(this.#S!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#S=t.getBoundingClientRect().height,t.remove()}static#D(t,e,s){let i=this.#b.get(t);if(i)return i;let r=this.#C(s);this.#P(r,Mh,t);let n=r.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent),l=0.8;if(a)l=a/(a+o);else{if(lt.platform.isFirefox)W("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");if(e.ascent)l=e.ascent;else if(e.descent)l=1+e.descent}return this.#b.set(t,l),l}}var Oh=100;function Rr(t={}){let e=new Fr,{docId:s}=e,i=t.url?rh(t.url):null,r=t.data?nh(t.data):null,n=t.httpHeaders||null,a=t.withCredentials===!0,o=t.password??null,l=t.range instanceof Dr?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,h=t.worker instanceof Ft?t.worker:null,d=t.verbosity,u=typeof t.docBaseUrl==="string"&&!Ei(t.docBaseUrl)?t.docBaseUrl:null,f=Ms(t.cMapUrl),p=t.cMapPacked!==!1,g=Ms(t.iccUrl),m=Ms(t.standardFontDataUrl),v=Ms(t.wasmUrl),y=t.stopAtErrors!==!0,b=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,_=typeof t.isOffscreenCanvasSupported==="boolean"?t.isOffscreenCanvasSupported:!Wt,w=typeof t.isImageDecoderSupported==="boolean"?t.isImageDecoderSupported:!Wt,A=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,x=typeof t.disableFontFace==="boolean"?t.disableFontFace:Wt,E=t.fontExtraProperties===!0,T=t.enableXfa===!0,k=t.ownerDocument||globalThis.document,C=t.disableRange===!0,R=t.disableStream===!0,B=t.disableAutoFetch===!0,N=t.pdfBug===!0,M=t.CanvasFactory||(Wt?Sa:Ra),F=t.FilterFactory||(Wt?Aa:Fa),j=t.BinaryDataFactory||(Wt?Ea:sr),X=t.enableHWA===!0,it=t.enableWebGPU===!0;if(it)_a();let q=t.useWasm!==!1,Z=t.pagesMapper||new po,J=null,P=typeof t.useSystemFonts==="boolean"?t.useSystemFonts:!Wt&&!x,I=typeof t.useWorkerFetch==="boolean"?t.useWorkerFetch:!!(j===sr&&f&&p&&m&&v&&ds(f,document.baseURI)&&ds(m,document.baseURI)&&ds(v,document.baseURI)),D=t.disableWorkerRendering===!0||!_||k!==globalThis.document||!!J||!Fe.isAvailable;Gc(d);let G={canvasFactory:new M({ownerDocument:k,enableHWA:X}),filterFactory:new F({docId:s,ownerDocument:k}),binaryDataFactory:I?null:new j({cMapUrl:f,standardFontDataUrl:m,wasmUrl:v})};if(!h)h=Ft.create({verbosity:d,port:Zt.workerPort}),e._worker=h;if(!D){let V=Fe.create({verbosity:d,enableHWA:X,enableWebGPU:it,ports:Zt.rendererPorts});V.promise.catch((Q)=>{if(!V.destroyed)W(`Renderer worker disabled: ${Q.message}`),V.destroy()}),e._rendererWorker=V}let z={docId:s,apiVersion:"6.5.438",data:r,password:o,disableAutoFetch:B,rangeChunkSize:c,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:b,disableFontFace:x,ignoreErrors:y,isOffscreenCanvasSupported:_,isImageDecoderSupported:w,canvasMaxAreaInBytes:A,fontExtraProperties:E,useSystemFonts:P,useWasm:q,useWorkerFetch:I,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:v}},tt={ownerDocument:k,pdfBug:N,styleElement:J,rendererWorker:e._rendererWorker,enableWebGPU:it,loadingParams:{disableAutoFetch:B,enableXfa:T}};return h.promise.then(function(){if(h.destroyed)throw Error("Worker was destroyed");let V=h.messageHandler.sendWithPromise("GetDocRequest",z,r?[r.buffer]:null),Q;if(r);else if(l)Q=new Wa({pdfDataRangeTransport:l,disableRange:C,disableStream:R});else if(i)Q=new(Ph(i))({url:i,httpHeaders:n,withCredentials:a,rangeChunkSize:c,disableRange:C,disableStream:R});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return V.then((ht)=>{if(h.destroyed)throw Error("Worker was destroyed");let Mt=new ge(s,ht,h.port),dt=new vo(Mt,e,Q,tt,G,Z);if(e._transport=dt,e.destroyed)throw Error("Loading aborted");Mt.send("Ready",null)})}).catch(e._capability.reject).finally(e._setupCapability.resolve),e}class Fr{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;_rendererWorker=null;docId=`d${Fr.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{if(this._worker?.port)this._worker._pendingDestroy=!0;await this._setupCapability.promise,await this._transport?.destroy()}catch(t){if(this._worker?.port)delete this._worker._pendingDestroy;throw t}finally{this._rendererWorker?.destroy(),this._rendererWorker=null}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class Dr{#t=Promise.withResolvers();#e=null;constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){at("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class mo{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(t){return this._transport.saveDocument(t)}extractPages(t,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class qs{#t=!1;#e=null;static#s=0;constructor(t,e,s,i,r=!1){this._pageIndex=t,this._id=qs.#s++,this._pageInfo=e,this._transport=s,this._stats=r?new er:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new Ri,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=i,this.imageCoordinates=null}clone(t){let e=new qs(t,this._pageInfo,this._transport,this.#e,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new xs({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=we.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:d=!1,recordImages:u=!1,recordOperations:f=!1,partialFrames:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");let m=this._transport.getRenderingIntent(i,r,h,d),{renderingIntent:v,cacheKey:y}=m;this.#t=!1,o||=this._transport.getOptionalContentConfig(v);let b=this._intentStates.getOrInsertComputed(y,qi);if(b.streamReaderCancelTimeout)clearTimeout(b.streamReaderCancelTimeout),b.streamReaderCancelTimeout=null;let _=!!(v&Vt.PRINT);if(!b.displayReadyCapability)b.displayReadyCapability=Promise.withResolvers(),b.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m);let w=!!(this._pdfBug&&globalThis.StepperManager?.enabled),A=!!e&&!this.recordedBBoxes&&(f||w),x=!!e&&!this.imageCoordinates&&u,E=(C)=>{if(b.renderTasks.delete(T),A){let{recordedBBoxes:R}=T;if(R){if(T.stepper?.setOperatorBBoxes(R,T.debugMetadata),f)this.recordedBBoxes=R}}if(x&&!C)this.imageCoordinates=T.imageCoordinates;if(_)this.#t=!0;if(this.#i(),C)T.capability.reject(C),this._abortOperatorList({intentState:b,reason:C instanceof Error?C:Error(C)});else T.capability.resolve();if(this._stats){if(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled)globalThis.Stats.add(this.pageNumber,this._stats)}},T=new Ke({callback:E,params:{canvas:e,canvasContext:t,viewport:s,transform:n,background:a,recordOperations:A,recordImages:x,partialFrames:p,recordForDebugger:w},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:b.operatorList,pageIndex:this._pageIndex,pageProxyId:this._id,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:c,operationsFilter:g,rendererWorker:this._transport.rendererWorker,waitForGPU:()=>this._transport.waitForGPU()});(b.renderTasks||=new Set).add(T);let k=T.task;return Promise.all([b.displayReadyCapability.promise,o]).then(async([C,R])=>{if(this.destroyed){E();return}if(this._stats?.time("Rendering"),!(R.renderingIntent&v))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");await T.initializeGraphics({transparency:C,optionalContentConfig:R}),T.operatorListChanged()}).catch(E),k}getOperatorList({intent:t="display",annotationMode:e=we.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function r(){if(a.operatorList.lastChunk)a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o)}let n=this._transport.getRenderingIntent(t,e,s,i,!0),a=this._intentStates.getOrInsertComputed(n.cacheKey,qi),o;if(!a.opListReadCapability)o=Object.create(null),o.operatorListChanged=r,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n);return a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size:(i)=>i.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((r)=>ms.textContent(r));let s=this.streamTextContent(t).getReader(),i={items:[],styles:Object.create(null),lang:null};while(!0){let{value:r,done:n}=await s.read();if(n)break;i.lang??=r.lang,Object.assign(i.styles,r.styles),i.items.push(...r.items)}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values()){if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),e.opListReadCapability)continue;for(let s of e.renderTasks)t.push(s.completed),s.cancel()}return this.objs.clear(),this._transport.cleanupPage(this._id),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;let e=this.#i();if(t&&e)this._stats&&=new er;return e}#i(){if(!this.#t||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this._transport.cleanupPage(this._id),this.#t=!1,!0}_startRenderPage(t,e){let s=this._intentStates.get(e);if(!s)return;this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t)}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let s of e.renderTasks)s.operatorListChanged();if(t.lastChunk)this.#i()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){let{map:r,transfer:n}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,pageProxyId:this._id,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},void 0,n).getReader(),l=this._intentStates.get(e);l.streamReader=o;let c=()=>{o.read().then(({value:h,done:d})=>{if(d){l.streamReader=null;return}if(this._transport.destroyed)return;this._renderPageChunk(h,l),c()},(h)=>{if(l.streamReader=null,this._transport.destroyed)return;if(l.operatorList){l.operatorList.lastChunk=!0;for(let d of l.renderTasks)d.operatorListChanged();this.#i()}if(l.displayReadyCapability)l.displayReadyCapability.reject(h);else if(l.opListReadCapability)l.opListReadCapability.reject(h);else throw h})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(!t.streamReader)return;if(t.streamReaderCancelTimeout)clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null;if(!s){if(t.renderTasks.size>0)return;if(e instanceof Si){let i=Oh;if(e.extraDelay>0&&e.extraDelay<1000)i+=e.extraDelay;t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new ve(e.message)).catch(()=>{}),t.streamReader=null,this._transport.destroyed)return;for(let[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}get stats(){return this._stats}}class Ft{#t=Promise.withResolvers();#e=null;#s=null;#i=null;static#r=0;static#n=!1;static#a=new WeakMap;static{if(Wt)this.#n=!0,Zt.workerSrc||="./pdf.worker.mjs"}constructor({name:t=null,port:e=null,verbosity:s=ia()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(Ft.#a.has(e))throw Error("Cannot use more than one PDFWorker per port.");Ft.#a.set(e,this),this.#l(e)}else this.#c()}get promise(){return this.#t.promise}#o(){this.#t.resolve(),this.#e.send("configure",{verbosity:this.verbosity})}get port(){return this.#s}get messageHandler(){return this.#e}#l(t){this.#s=t,this.#e=new ge("main","worker",t),this.#e.on("ready",()=>{}),this.#o()}#c(){if(Ft.#n||Ft.#h){this.#u();return}let{workerSrc:t}=Ft;try{let e=new Worker(va(t),{type:"module"}),s=new ge("main","worker",e),i=()=>{if(r.abort(),s.destroy(),e.terminate(),this.destroyed)this.#t.reject(Error("Worker was destroyed"));else this.#u()},r=new AbortController;e.addEventListener("error",()=>{if(!this.#i)i()},{signal:r.signal}),s.on("ready",(n)=>{if(r.abort(),this.destroyed||!(n instanceof Uint8Array)){i();return}this.#e=s,this.#s=e,this.#i=e,this.#o()})}catch{wi("The worker has been disabled."),this.#u()}}#u(){if(!Ft.#n)W("Setting up fake worker."),Ft.#n=!0;Ft._setupFakeWorkerGlobal.then((t)=>{if(this.destroyed){this.#t.reject(Error("Worker was destroyed"));return}let e=new ya;this.#s=e;let s=`fake${Ft.#r++}`,i=new ge(s+"_worker",s,e);t.setup(i,e),this.#e=new ge(s,s+"_worker",e),this.#o()}).catch((t)=>{this.#t.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#i?.terminate(),this.#i=null,Ft.#a.delete(this.#s),this.#s=null,this.#e?.destroy(),this.#e=null}static create(t){let e=this.#a.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Ft(t)}static get workerSrc(){if(Zt.workerSrc)return Zt.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#h(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return L(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#h)return this.#h;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class vo{downloadInfoCapability=Promise.withResolvers();#t=null;#e=!1;#s=new Map;#i=null;#r=new Map;#n=new Map;#a=new Map;#o=null;#l=null;constructor(t,e,s,i,r,n){this.messageHandler=t,this.loadingTask=e,this.#i=s,this.commonObjs=new Ri,this.fontLoader=new Da({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.rendererWorker=i.rendererWorker,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=n,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){this.#r.set(t._id,t),this.#n.set(t._pageIndex,Promise.resolve(t))}#c(t,e=null){return this.#s.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#u({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?pt(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return L(this,"annotationStorage",new xi)}getRenderingIntent(t,e=we.ENABLE,s=null,i=!1,r=!1){let n=Vt.DISPLAY,a=vs;switch(t){case"any":n=Vt.ANY;break;case"display":break;case"print":n=Vt.PRINT;break;default:W(`getRenderingIntent - invalid intent: ${t}`)}let o=n&Vt.PRINT&&s instanceof Ir?s:this.annotationStorage;switch(e){case we.DISABLE:n+=Vt.ANNOTATIONS_DISABLE;break;case we.ENABLE:break;case we.ENABLE_FORMS:n+=Vt.ANNOTATIONS_FORMS;break;case we.ENABLE_STORAGE:n+=Vt.ANNOTATIONS_STORAGE,a=o.serializable;break;default:W(`getRenderingIntent - invalid annotationMode: ${e}`)}if(i)n+=Vt.IS_EDITING;if(r)n+=Vt.OPLIST;let{ids:l,hash:c}=o.modifiedIds,h=[n,a.hash,c];return{renderingIntent:n,cacheKey:h.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let s of this.#r.values())t.push(s._destroy());if(this.#r.clear(),this.#n.clear(),this.#a.clear(),Object.hasOwn(this,"annotationStorage"))this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#s.clear(),this.filterFactory.destroy(),Lt.cleanup(),this.#i?.cancelAllRequests(new ve("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.rendererWorker=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(i,r)=>{wt(this.#i,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#i.getFullReader(),this.#t.onProgress=(n)=>this.#u(n),r.onPull=()=>{this.#t.read().then(function({value:n,done:a}){if(a){r.close();return}wt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(n),1,[n])}).catch((n)=>{r.error(n)})},r.onCancel=(n)=>{this.#t.cancel(n),r.ready.catch((a)=>{if(this.destroyed)return;throw a})}}),t.on("ReaderHeadersReady",async(i)=>{await this.#t.headersReady;let{isStreamingSupported:r,isRangeSupported:n,contentLength:a}=this.#t;if(r&&n)this.#t.onProgress=null;return{isStreamingSupported:r,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(i,r)=>{wt(this.#i,"GetRangeReader - no `BasePDFStream` instance available.");let n=this.#i.getRangeReader(i.begin,i.end);if(!n){r.close();return}r.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){r.close();return}wt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch((a)=>{r.error(a)})},r.onCancel=(a)=>{n.cancel(a),r.ready.catch((o)=>{if(this.destroyed)return;throw o})}}),t.on("GetDoc",({pdfInfo:i})=>{this.pagesMapper.pagesNumber=i.numPages,this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new mo(i,this))}),t.on("DocException",(i)=>{e._capability.reject($t(i))}),t.on("PasswordRequest",(i)=>{this.#o=Promise.withResolvers();try{if(!e.onPassword)throw $t(i);let r=(n)=>{if(n instanceof Error)this.#o.reject(n);else this.#o.resolve({password:n})};e.onPassword(r,i.code)}catch(r){this.#o.reject(r)}return this.#o.promise}),t.on("DataLoaded",(i)=>{this.#u({loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),t.on("StartRenderPage",(i)=>{if(this.destroyed)return;this.#r.get(i.pageProxyId)._startRenderPage(i.transparency,i.cacheKey)});let s=new uo({messageHandler:t,commonObjs:this.commonObjs,fontLoader:this.fontLoader,pageCache:this.#r,pdfBug:this._params.pdfBug});this.rendererWorker?.promise.then(()=>{this.rendererWorker?.messageHandler?.on("FontFallback",(i)=>this.destroyed?null:t.sendWithPromise("FontFallback",i))},()=>{}),t.on("commonobj",([i,r,n])=>{if(this.destroyed)return null;let{rendererWorker:a}=this;if(r==="CopyLocalImage"){if(this.commonObjs.has(i))return null;let o=s.resolveCommonObject(i,r,n);if(o)a?.sendCommonObj(i,"Image",this.commonObjs.get(i));return o}if(a?.sendCommonObj(i,r,n),!this.commonObjs.has(i)){if(s.resolveCommonObject(i,r,n),r==="Pattern"&&this.commonObjs.get(i)[0]==="Mesh")this.#e=!0}return null}),t.on("obj",([i,r,n,a])=>{if(this.destroyed)return;if(n==="Pattern"&&a[0]==="Mesh")this.#e=!0;if(s.resolveObject(i,r,n,a))this.rendererWorker?.sendObj(i,r,n,a)}),t.on("DocProgress",(i)=>{if(this.destroyed)return;this.#u(i)}),t.on("FetchBinaryData",async(i)=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(i)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(t=null){if(this.annotationStorage.size<=0)W("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:s}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,supportsPrintToPDF:this.#l!==null,filename:this.#t?.filename??null},s).finally(()=>{this.#l=null,this.annotationStorage.resetModified()})}extractPages(t,e=null){let s={pageInfos:t},i,r=globalThis.ImageBitmap;if(typeof r==="function"){let n=Array.isArray(t)?t:[t];for(let a of n)if(a?.image instanceof r)(i||=[]).push(a.image)}if(this.annotationStorage.size>0){let n=this.annotationStorage.serializable,{map:a}=n;if(n.transfer?.length)if(i)i.push(...n.transfer);else i=n.transfer;let o=this.pagesMapper.getMapping();if(o){let l=new Map;for(let[c,h]of a){if(h?.pageIndex!==void 0&&h.pageIndex>=0&&h.pageIndex<o.length){let d=e?.[h.pageIndex]??0,u=o[h.pageIndex]-1;if(u!==h.pageIndex||d!==0){l.set(c,{...h,pageIndex:u,copyLevel:d});continue}}l.set(c,h)}a=l}s.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",s,i).finally(()=>{this.annotationStorage.resetModified()})}waitForGPU(){return this._params.enableWebGPU&&this.#e&&!wa()?_a():null}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,s=this.pagesMapper.getPageId(t)-1,i=this.#n.get(e);if(i)return i;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then((n)=>{if(this.destroyed)throw Error("Transport destroyed");if(n.refStr)this.#a.set(n.refStr,s);let a=new qs(e,n,this,this.pagesMapper,this._params.pdfBug);return this.#r.set(a._id,a),a});return this.#n.set(e,r),r}async getPageIndex(t){if(!tr(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#c("GetFieldObjects")}getSignatures(){return this.#c("GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return this.#c("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!=="string"?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#c("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#s.getOrInsertComputed("GetOptionalContentConfig",()=>this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).catch((s)=>(W(`GetOptionalContentConfig: "${s}".`),null))).then((s)=>new Or(s,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#s.getOrInsertComputed("GetMetadata",()=>this.messageHandler.sendWithPromise("GetMetadata",null).then((e)=>({info:e[0],metadata:e[1]?new so(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(this.destroyed)return;await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#r.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);if(this.commonObjs.clear(),!t)this.fontLoader.clear();this.rendererWorker?.cleanup(t),this.#s.clear(),this.filterFactory.destroy(!0),Lt.cleanup()}cleanupPage(t){if(!this.destroyed)this.messageHandler.send("CleanupPage",{pageProxyId:t});this.rendererWorker?.cleanupPage(t)}cachedPageNumber(t){if(!tr(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=this.#a.get(e);if(s>=0){let i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}class yo{_internalRenderTask=null;onContinue=null;onError=null;onFrame=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}get isWorkerRendering(){return this._internalRenderTask.isWorkerRendering}}class Ke{#t=null;#e=null;#s=null;#i=null;#r=null;static#n=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:n,pageIndex:a,pageProxyId:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:u=null,operationsFilter:f=null,rendererWorker:p=null,waitForGPU:g=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new yo(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._operationsFilter=f,this.#r=g,this.#i=p?.createRenderTask({pageProxyId:o,operatorList:n,params:e,pageColors:u,canvasFactory:l,annotationCanvasMap:r,onFrame:()=>this.task.onFrame?.(),onError:(m)=>this.cancel(m)})??null}get completed(){return this.capability.promise.catch(()=>{})}get isWorkerRendering(){return!!this.#i}get imageCoordinates(){return this.#i?this.#i.imageCoordinates:this.#e?.take()}get recordedBBoxes(){return this.#i?this.#i.recordedBBoxes:this.#t?.take()}get debugMetadata(){return this.#t?.takeDebugMetadata()??null}async initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Ke.#n.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Ke.#n.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled)this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint();if(this.#i){let s=await this.#i.initialize(t,e);if(this.cancelled)return;if(!s)this.#i=null}if(!this.#i){let{viewport:s,transform:i,background:r,recordOperations:n,recordImages:a,recordForDebugger:o}=this.params,l=this._canvasContext||this.canvasFactory.getNoAlphaContext(this._canvas),{dependencyTracker:c,imagesTracker:h}=ph(this._canvas,this.operatorList.fnArray.length,{recordOperations:n,recordImages:a,recordDebugMetadata:o});this.#t=c,this.#e=h,this.gfx=new Ae(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,c,h),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r})}this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){if(this.running=!1,this.cancelled=!0,this.#i?.cancel(),this.gfx?.endDrawing(),this.#s)window.cancelAnimationFrame(this.#s),this.#s=null;Ke.#n.delete(this._canvas),t||=new Si(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.#t?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running)return;this._continue()}_continue(){if(this.running=!0,this.cancelled)return;if(this.task.onContinue)this.task.onContinue(this._scheduleNextBound);else this._scheduleNext()}_scheduleNext(){if(this._useRequestAnimationFrame)this.#s=window.requestAnimationFrame(()=>{this.#s=null,this._nextBound().catch(this._cancelBound)});else Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(!this.#i){let s=this.#r?.();if(s){if(await s,this.cancelled)return}}let{operatorList:t}=this,{lastChunk:e}=t;if(this.#i){if(this.operatorListIdx=await this.#i.executeOperatorList(t,this.operatorListIdx,this._operationsFilter),this.cancelled)return;if(this.operatorListIdx!==t.argsArray.length||e!==t.lastChunk){this._continue();return}}else this.operatorListIdx=this.gfx.executeOperatorList(t,this.operatorListIdx,this._continueBound,null,this.stepper,this._operationsFilter);if(this.operatorListIdx===t.argsArray.length){if(this.running=!1,e)this.gfx?.endDrawing(),Ke.#n.delete(this._canvas),this.callback()}}}var Rh="6.5.438",Fh="0a4153349";Ac();class Qt{#t=null;#e=null;#s;#i=null;#r=!1;#n=!1;#a=null;#o;#l=null;#c=null;static#u=null;static get _keyboardManager(){return L(this,"_keyboardManager",new Xt([[["Escape"],Qt.prototype._hideDropdownFromKeyboard],[["Space"],Qt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],Qt.prototype._moveToNext],[["ArrowUp","ArrowLeft"],Qt.prototype._moveToPrevious],[["Home"],Qt.prototype._moveToBeginning],[["End"],Qt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){if(t)this.#n=!1,this.#a=t;else this.#n=!0;this.#c=t?._uiManager||e,this.#o=this.#c._eventBus,this.#s=t?.color?.toUpperCase()||this.#c?.highlightColors.values().next().value||"#FFFF98",Qt.#u||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=document.createElement("button");if(t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#a)t.ariaControls=`${this.#a.id}_colorpicker_dropdown`;let e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#s,t.append(s),t}renderMainDropdown(){let t=this.#i=this.#h();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#h(){let t=document.createElement("div"),e=this.#c._signal;if(t.addEventListener("contextmenu",re,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#a)t.id=`${this.#a.id}_colorpicker_dropdown`;for(let[s,i]of this.#c.highlightColors){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",Qt.#u[s]);let n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=i,r.ariaSelected=i===this.#s,r.addEventListener("click",this.#f.bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:st.HIGHLIGHT_COLOR,value:t}),this.update(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");if(!e)return;this.#f(e,t)}_moveToNext(t){if(!this.#g){this.#m(t);return}if(t.target===this.#t){this.#i.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstElementChild||t.target===this.#t){if(this.#g)this._hideDropdownFromKeyboard();return}if(!this.#g)this.#m(t);t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#g){this.#m(t);return}this.#i.firstElementChild?.focus()}_moveToEnd(t){if(!this.#g){this.#m(t);return}this.#i.lastElementChild?.focus()}#p(t){Qt._keyboardManager.exec(this,t)}#m(t){if(this.#g){this.hideDropdown();return}if(this.#r=t.detail===0,!this.#l)this.#l=new AbortController,window.addEventListener("pointerdown",this.#d.bind(this),{signal:this.#c.combinedSignal(this.#l)});if(this.#t.ariaExpanded="true",this.#i){this.#i.classList.remove("hidden");return}let e=this.#i=this.#h();this.#t.append(e)}#d(t){if(this.#i?.contains(t.target))return;this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#g(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(this.#n)return;if(!this.#g){this.#a?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}update(t){if(this.#e)this.#e.style.backgroundColor=t;if(!this.#i)return;let e=this.#c.highlightColors.values();for(let s of this.#i.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}}class bs{#t=null;#e=!1;#s=null;#i=null;static#r=null;constructor(t){this.#s=t,this.#i=t._uiManager,bs.#r||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;let{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:n}=this.#s,a=this.#e=lt.isAlphaColorInputSupported&&i!==void 0,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");let l=O.hexNums[Math.round((n??1)*255)];o.value=(r||"#000000")+l}else o.value=r||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",bs.#r[t]),o.addEventListener("input",()=>{if(a){let l=ts(o.value);if(!l)return;let[c,h,d,u]=l,f=O.makeHexColor(c,h,d);if(s!==void 0)this.#i.updateParams(s,{color:f,opacity:u});else this.#i.updateParams(e,f),this.#i.updateParams(i,u)}else this.#i.updateParams(e,o.value)},{signal:this.#i._signal}),o}update(t){if(!this.#t)return;if(this.#e){let e=O.hexNums[Math.round(this.#s.opacity*255)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;let e=O.hexNums[Math.round(t*255)];this.#t.value=this.#s.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}uc();function Tn(t){return Math.floor(pt(t,0,1)*255).toString(16).padStart(2,"0")}function os(t){return pt(t,0,1)*255}class nr{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,0.3*t+0.59*s+0.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=os(t),[t,t,t]}static G_HTML([t]){let e=Tn(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",0.3*t+0.59*e+0.11*s]}static RGB_rgb(t){return t.map(os)}static RGB_HTML(t){return`#${t.map(Tn).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[os(1-Math.min(1,t+i)),os(1-Math.min(1,s+i)),os(1-Math.min(1,e+i))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){let i=1-t,r=1-e,n=1-s,a=Math.min(i,r,n);return["CMYK",i,r,n,a]}}class bo{create(t,e,s=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");if(i.setAttribute("version","1.1"),!s)i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`);return i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!=="string")throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){at("Abstract method `_createSVG` called.")}}class Fi extends bo{_createSVG(t){return document.createElementNS(Dt,t)}}var Dh=9,Be=new WeakSet,Lh=new Date().getTimezoneOffset()*60*1000;class $s{static create(t){switch(t.data.annotationType){case yt.LINK:return new Di(t);case yt.TEXT:return new wo(t);case yt.WIDGET:switch(t.data.fieldType){case"Tx":return new Ao(t);case"Btn":if(t.data.radioButton)return new xo(t);else if(t.data.checkBox)return new Eo(t);return new To(t);case"Ch":return new Co(t);case"Sig":return new So(t)}return new Te(t);case yt.POPUP:return new Js(t);case yt.FREETEXT:return new Lr(t);case yt.LINE:return new Po(t);case yt.SQUARE:return new ko(t);case yt.CIRCLE:return new Mo(t);case yt.POLYLINE:return new Nr(t);case yt.CARET:return new Ro(t);case yt.INK:return new Li(t);case yt.POLYGON:return new Oo(t);case yt.HIGHLIGHT:return new Br(t);case yt.UNDERLINE:return new Fo(t);case yt.SQUIGGLY:return new Do(t);case yt.STRIKEOUT:return new Lo(t);case yt.STAMP:return new jr(t);case yt.FILEATTACHMENT:return new No(t);case yt.RICHMEDIA:case yt.SCREEN:case yt.SOUND:return new Hr(t);default:return new ct(t)}}}class ct{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){if(this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableAnnotationEditing=t.enableAnnotationEditing!==!1,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e)this.contentElement=this.container=this._createContainer(s);if(i)this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}static get _svgFactory(){return L(this,"_svgFactory",new Fi)}get _isEditable(){return this.enableAnnotationEditing&&this.data.isEditable}get hasPopupData(){return ct._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:s,rect:i}=this.data,r=-1/0,n=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)if(e[a+1]>n)n=e[a+1],r=e[a+2];else if(e[a+1]===n)r=Math.max(r,e[a+2]);return[r,n]}if(s?.length>=1){for(let a of s)for(let o=0,l=a.length;o<l;o+=2)if(a[o+1]>n)n=a[o+1],r=a[o];else if(a[o+1]===n)r=Math.max(r,a[o]);if(r!==1/0)return[r,n]}return i?[i[2],i[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-n)/i,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${qe}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,s={deleted:!t,contents:t||""};if(!this.annotationStorage.updateEditor(e.id,{popup:s}))this.annotationStorage.setValue(`${qe}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date});if(!t)this.removePopup()}removePopup(){(this.#s?.popup||this.popup)?.remove(),this.#s=this.popup=null}updateEdited(t){if(!this.container)return;if(t.rect)this.#t||={rect:this.data.rect.slice(0)};let{rect:e,popup:s}=t;if(e)this.#i(e);let i=this.#s?.popup||this.popup;if(!i&&s?.text)this._createPopup(s),i=this.#s.popup;if(!i)return;if(i.updateEdited(t),s?.deleted)i.remove(),this.#s=null,this.popup=null}resetEdited(){if(!this.#t)return;this.#i(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null}#i(t){let{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;if(s?.splice(0,4,...t),e.left=`${100*(t[0]-a)/r}%`,e.top=`${100*(n-t[3]+o)/n}%`,i===0)e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/n}%`;else this.setRotation(i)}_createContainer(t){let{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");if(r.setAttribute("data-annotation-id",e.id),!(this instanceof Te)&&!(this instanceof Di)&&!(this instanceof Hr))r.tabIndex=0;let{style:n}=r;if(n.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText)r.title=e.alternativeText;if(e.noRotate)r.classList.add("norotate");if(!e.rect||this instanceof Js){let{rotation:p}=e;if(!e.hasOwnCanvas&&p!==0)this.setRotation(p,r);return r}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;let p=e.borderStyle.horizontalCornerRadius,g=e.borderStyle.verticalCornerRadius;if(p>0||g>0){let v=`calc(${p}px * var(--total-scale-factor)) / calc(${g}px * var(--total-scale-factor))`;n.borderRadius=v}switch(e.borderStyle.style){case Xe.SOLID:n.borderStyle="solid";break;case Xe.DASHED:n.borderStyle="dashed";break;case Xe.BEVELED:W("Unimplemented border style: beveled");break;case Xe.INSET:W("Unimplemented border style: inset");break;case Xe.UNDERLINE:n.borderBottomStyle="solid";break;default:break}let m=e.borderColor||null;if(m)this.#e=!0,n.borderColor=O.makeHexColor(...m);else n.borderWidth=0}let l=O.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:h,pageX:d,pageY:u}=i.rawDims;n.left=`${100*(l[0]-d)/c}%`,n.top=`${100*(l[1]-u)/h}%`;let{rotation:f}=e;if(e.hasOwnCanvas||f===0)n.width=`${100*a/c}%`,n.height=`${100*o/h}%`;else this.setRotation(f,r);return r}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:r,height:n}=this;if(t%180!==0)[r,n]=[n,r];e.style.width=`${100*r/s}%`,e.style.height=`${100*n/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,s,i)=>{let r=i.detail[e],n=r[0],a=r.slice(1);i.target.style[s]=nr[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:nr[`${n}_rgb`](a)})};return L(this,"_commonActions",{display:(e)=>{let{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:(e)=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:(e)=>{let{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:(e)=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:(e)=>{e.target.title=e.detail.userName},readonly:(e)=>{e.target.disabled=e.detail.readonly},required:(e)=>{this._setRequired(e.target,e.detail.required)},bgColor:(e)=>{t("bgColor","backgroundColor",e)},fillColor:(e)=>{t("fillColor","backgroundColor",e)},fgColor:(e)=>{t("fgColor","color",e)},textColor:(e)=>{t("textColor","color",e)},borderColor:(e)=>{t("borderColor","borderColor",e)},strokeColor:(e)=>{t("strokeColor","borderColor",e)},rotation:(e)=>{let s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){let s=this._commonActions;for(let i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let s=this._commonActions;for(let[i,r]of Object.entries(e)){let n=s[i];if(n){let a={detail:{[i]:r},target:t};n(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,s,i,r]=this.data.rect.map(Math.fround);if(t.length===8){let[p,g,m,v]=t.subarray(2,6);if(i===p&&r===g&&e===m&&s===v)return}let{style:n}=this.container,a;if(this.#e){let{borderColor:p,borderWidth:g}=n;n.borderWidth=0,a=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Dt}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${p}" stroke-width="${g}">`],this.container.classList.add("hasBorder")}let o=i-e,l=r-s,c=ct._svgFactory,h=c.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0),h.role="none";let d=c.createElement("defs");h.append(d);let u=c.createElement("clipPath"),f=`clippath_${this.data.id}`;u.setAttribute("id",f),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let p=2,g=t.length;p<g;p+=8){let m=t[p],v=t[p+1],y=t[p+2],b=t[p+3],_=c.createElement("rect"),w=(y-e)/o,A=(r-v)/l,x=(m-y)/o,E=(v-b)/l;_.setAttribute("x",w),_.setAttribute("y",A),_.setAttribute("width",x),_.setAttribute("height",E),u.append(_),a?.push(`<rect vector-effect="non-scaling-stroke" x="${w}" y="${A}" width="${x}" height="${E}"/>`)}if(this.#e)a.push("</g></svg>')"),n.backgroundImage=a.join("");this.container.append(h),this.container.style.clipPath=`url(#${f})`}_createPopup(t=null){let{data:e}=this,s,i;if(t)s={str:t.text},i=t.date;else s=e.contentsObj,i=e.modificationDate;this.#s=new Js({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#s||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#s}render(){at("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let s=[];if(this._fieldObjects){let i=this._fieldObjects.get(t)||[];for(let{page:r,id:n,exportValues:a}of i){if(r===-1||n===e)continue;let o=typeof a==="string"?a:null,l=document.querySelector(`[data-element-id="${n}"]`);if(l&&!Be.has(l)){W(`_getElementsByName - element not allowed: ${n}`);continue}s.push({id:n,exportValue:o,domElement:l})}return s}for(let i of document.getElementsByName(t)){let{exportValue:r}=i,n=i.getAttribute("data-element-id");if(n===e||!Be.has(i))continue;s.push({id:n,exportValue:r,domElement:i})}return s}show(){if(this.container)this.container.hidden=!1;this.popup?.maybeShow()}hide(){if(this.container)this.container.hidden=!0;this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;if(t.isVisible(this.data.oc))this.show();else this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":O.makeHexColor(...e)}}class _o extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;if(!t.hasComment)return;this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){if(this.editor.comment=t,!t)this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class Di extends ct{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;if(t.url)e.addLinkAttributes(s,t.url,t.newWindow),i=!0;else if(t.action)this._bindNamedAction(s,t.action,t.overlaidText),i=!0;else if(t.attachment)this.#e(s,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),i=!0;else if(t.setOCGState)this.#s(s,t.setOCGState,t.overlaidText),i=!0;else if(t.dest)this._bindLink(s,t.dest,t.overlaidText),i=!0;else{if(t.actions&&(t.actions.has("Action")||t.actions.has("Mouse Up")||t.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions)this._bindJSAction(s,t),i=!0;if(t.resetForm)this._bindResetFormAction(s,t.resetForm),i=!0;else if(this.isTooltipOnly&&!i)this._bindLink(s,""),i=!0}if(this.container.classList.add("linkAnnotation"),i)this.contentElement=s,this.container.append(s);return this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){if(t.href=this.linkService.getDestinationHash(e),t.onclick=()=>{if(e)this.linkService.goToDestination(e);return!1},e||e==="")this.#t();if(s)t.title=s}_bindNamedAction(t,e,s=""){if(t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s)t.title=s;this.#t()}#e(t,e,s,i="",r=null){if(t.href=this.linkService.getAnchorUrl(""),s.description)t.title=s.description;else if(i)t.title=i;let n=async()=>{let a=await this.linkService.getAttachmentContent(e);if(a)this.downloadManager?.openOrDownloadData(a,s.filename,r)};t.onclick=()=>(n(),!1),this.#t()}#s(t,e,s=""){if(t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s)t.title=s;this.#t()}_bindJSAction(t,{actions:e,id:s,overlaidText:i}){t.href=this.linkService.getAnchorUrl("");let r=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let n of e.keys()){let a=r.get(n);if(!a)continue;t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:n}}),!1)}if(i)t.title=i;t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){let s=t.onclick;if(!s)t.href=this.linkService.getAnchorUrl("");if(this.#t(),!this._fieldObjects){if(W('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!s)t.onclick=()=>!1;return}t.onclick=()=>{s?.();let{fields:i,refs:r,include:n}=e,a=[];if(i.length!==0||r.length!==0){let c=new Set(r);for(let d of i){let u=this._fieldObjects.get(d)||[];for(let{id:f}of u)c.add(f)}let h=new Map;for(let d of this._fieldObjects.values())for(let{id:u,kidIds:f}of d)if(f)h.set(u,f);for(let d of c)for(let u of h.get(d)||[])c.add(u);for(let d of this._fieldObjects.values())for(let u of d)if(c.has(u.id)===n)a.push(u)}else for(let c of this._fieldObjects.values())a.push(...c);let o=this.annotationStorage,l=[];for(let c of a){let{id:h}=c;switch(l.push(h),c.type){case"text":{let u=c.defaultValue||"";o.setValue(h,{value:u});break}case"checkbox":case"radiobutton":{let u=c.defaultValue===c.exportValues;o.setValue(h,{value:u});break}case"combobox":case"listbox":{let u=c.defaultValue||"";o.setValue(h,{value:u});break}default:continue}let d=document.querySelector(`[data-element-id="${h}"]`);if(!d)continue;else if(!Be.has(d)){W(`_bindResetFormAction - element not allowed: ${h}`);continue}d.dispatchEvent(new Event("resetform"))}if(this.enableScripting)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}});return!1}}}class wo extends ct{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");if(t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(t),this.container}}class Te extends ct{render(){return this.container}_getKeyModifier(t){return lt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){if(s.includes("mouse"))t.addEventListener(s,(n)=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(n),shift:n.shiftKey,modifier:this._getKeyModifier(n)}})});else t.addEventListener(s,(n)=>{if(s==="blur"){if(!e.focused||!n.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}if(!r)return;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(n)}})})}_setEventListeners(t,e,s,i){let{actions:r}=this.data;for(let[n,a]of s)if(a==="Action"||r?.has(a)){if(a==="Focus"||a==="Blur")e||={focused:!1};if(this._setEventListener(t,e,n,a,i),a==="Focus"&&!r?.has("Blur"))this._setEventListener(t,e,"blur","Blur",null);else if(a==="Blur"&&!r?.has("Focus"))this._setEventListener(t,e,"focus","Focus",null)}}_setTextStyle(t){let e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Dh,r=t.style,n,a=2,o=(l)=>Math.round(10*l)/10;if(this.data.multiLine){let l=Math.abs(this.data.rect[3]-this.data.rect[1]-2),c=Math.round(l/(1.35*i))||1,h=l/c;n=Math.min(i,o(h/1.35))}else{let l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);n=Math.min(i,o(l/1.35))}if(r.fontSize=`calc(${n}px * var(--total-scale-factor))`,r.color=O.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb)r.textAlign=e[this.data.textAlignment]}_setRequired(t,e){if(e)t.setAttribute("required",!0);else t.removeAttribute("required");t.setAttribute("aria-required",e)}}class Ao extends Te{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){let r=this.annotationStorage;for(let n of this._getElementsByName(t.name,t.id)){if(n.domElement)n.domElement[e]=s;r.setValue(n.id,{[i]:s})}}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){let i=t.getValue(e,{value:this.data.fieldValue}),r=i.value||"",n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;if(n&&r.length>n)r=r.slice(0,n);let a=i.formattedValue||this.data.textContent?.join(`
48
+ `)||null;if(a&&this.data.comb)a=a.replaceAll(/\s+/g,"");let o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){if(s=document.createElement("textarea"),s.textContent=a??r,this.data.doNotScroll)s.style.overflowY="hidden"}else if(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",a??r),this.data.doNotScroll)s.style.overflowX="hidden";if(this.data.hasOwnCanvas){if(this.container.classList.add("hasOwnCanvas"),t.has(e))this.container.classList.add("sandboxModified")}Be.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;let{datetimeFormat:l,datetimeType:c,timeStep:h}=this.data,d=!!c&&this.enableScripting;if(l)s.title=l;if(this._setRequired(s,this.data.required),n)s.maxLength=n;s.addEventListener("input",(f)=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",(f)=>{let p=this.data.defaultFieldValue??"";s.value=o.userValue=p,o.formattedValue=null});let u=(f)=>{let{formattedValue:p}=o;if(p!==null&&p!==void 0)f.target.value=p;f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(p)=>{if(o.focused)return;let{target:g}=p;if(d){if(g.type=c,h)g.step=h}if(o.userValue){let m=o.userValue;if(d)if(c==="time"){let v=new Date(m),y=[v.getHours(),v.getMinutes(),v.getSeconds()];g.value=y.map((b)=>b.toString().padStart(2,"0")).join(":")}else g.value=new Date(m-Lh).toISOString().split(c==="date"?"T":".",1)[0];else g.value=m}if(o.lastCommittedValue=g.value,o.commitKey=1,!this.data.actions?.has("Focus"))o.focused=!0}),s.addEventListener("updatefromsandbox",(p)=>{this.container.classList.add("sandboxModified");let g={value(m){if(o.userValue=m.detail.value??"",!d)t.setValue(e,{value:o.userValue.toString()});m.target.value=o.userValue},formattedValue(m){let{formattedValue:v}=m.detail;if(o.formattedValue=v,v!==null&&v!==void 0&&m.target!==document.activeElement)m.target.value=v;let y={formattedValue:v};if(d)y.value=v;t.setValue(e,y)},selRange(m){m.target.setSelectionRange(...m.detail.selRange)},charLimit:(m)=>{let{charLimit:v}=m.detail,{target:y}=m;if(v===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",v);let b=o.userValue;if(!b||b.length<=v)return;b=b.slice(0,v),y.value=o.userValue=b,t.setValue(e,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}})}};this._dispatchEventFromSandbox(g,p)}),s.addEventListener("keydown",(p)=>{o.commitKey=1;let g=-1;if(p.key==="Escape")g=0;else if(p.key==="Enter"&&!this.data.multiLine)g=2;else if(p.key==="Tab")o.commitKey=3;if(g===-1)return;let{value:m}=p.target;if(o.lastCommittedValue===m)return;o.lastCommittedValue=m,o.userValue=m,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:m,willCommit:!0,commitKey:g,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})});let f=u;if(u=null,s.addEventListener("blur",(p)=>{if(!o.focused||!p.relatedTarget)return;if(!this.data.actions?.has("Blur"))o.focused=!1;let{target:g}=p,{value:m}=g;if(d){if(m&&c==="time"){let v=m.split(":").map((y)=>parseInt(y,10));m=new Date(2000,0,1,v[0],v[1],v[2]||0).valueOf(),g.step=""}else{if(!m.includes("T"))m=`${m}T00:00`;m=new Date(m).valueOf()}g.type="text"}if(o.userValue=m,o.lastCommittedValue!==m)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:m,willCommit:!0,commitKey:o.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}});f(p)}),this.data.actions?.has("Keystroke"))s.addEventListener("beforeinput",(p)=>{o.lastCommittedValue=null;let{data:g,target:m}=p,{value:v,selectionStart:y,selectionEnd:b}=m,_=y,w=b;switch(p.inputType){case"deleteWordBackward":{let A=/\w/;while(_>0&&!A.test(v[_-1]))_--;while(_>0&&A.test(v[_-1]))_--;break}case"deleteWordForward":{let A=v.substring(y).match(/^\W*\w*/);if(A)w+=A[0].length;break}case"deleteContentBackward":if(y===b)_-=1;break;case"deleteContentForward":if(y===b)w+=1;break}p.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,change:g||"",willCommit:!1,selStart:_,selEnd:w}})});this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(p)=>p.target.value)}if(u)s.addEventListener("blur",u);if(this.data.comb){let p=(this.data.rect[2]-this.data.rect[0])/n;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${p}px * var(--total-scale-factor))`);let g=this.data.textAlignment;if(g===1||g===2){let m=()=>{let v=n-s.value.length;s.style.setProperty("--comb-offset",`${g===1?v>>1:v}`)};m();for(let v of["input","blur","resetform","updatefromsandbox"])s.addEventListener(v,m)}}}else if(s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas)s.hidden=!0;return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class So extends Te{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Eo extends Te{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;if(typeof i==="string")i=i!=="Off",t.setValue(s,{value:i});this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");if(Be.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i)r.setAttribute("checked",!0);if(r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",(n)=>{let{name:a,checked:o}=n.target;for(let l of this._getElementsByName(a,s)){let c=o&&l.exportValue===e.exportValue;if(l.domElement)l.domElement.checked=c;t.setValue(l.id,{value:c})}t.setValue(s,{value:o})}),r.addEventListener("resetform",(n)=>{let a=e.defaultFieldValue||"Off";n.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions)r.addEventListener("updatefromsandbox",(n)=>{let a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,n)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(n)=>n.target.checked);return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class xo extends Te{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i==="string")i=i!==e.buttonValue,t.setValue(s,{value:i});if(i)for(let n of this._getElementsByName(e.fieldName,s))t.setValue(n.id,{value:!1});let r=document.createElement("input");if(Be.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i)r.setAttribute("checked",!0);if(r.tabIndex=0,r.addEventListener("change",(n)=>{let{name:a,checked:o}=n.target;for(let l of this._getElementsByName(a,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:o})}),r.addEventListener("resetform",(n)=>{let a=e.defaultFieldValue;n.target.checked=a!==null&&a!==void 0&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){let n=e.buttonValue;r.addEventListener("updatefromsandbox",(a)=>{let o={value:(l)=>{let c=n===l.detail.value;for(let h of this._getElementsByName(l.target.name)){let d=c&&h.id===s;if(h.domElement)h.domElement.checked=d;t.setValue(h.id,{value:d})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(a)=>a.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class To extends Di{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;if(this.enableScripting&&this.hasJSActions&&e)this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(s)=>{this._dispatchEventFromSandbox({},s)});return t}}class Co extends Te{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Be.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;if(!this.data.combo){if(i.size=this.data.options.length,this.data.multiSelect)i.multiple=!0}i.addEventListener("resetform",(h)=>{let d=this.data.defaultFieldValue;for(let u of i.options)u.selected=u.value===d});let n=(h,d)=>{let u=d.replaceAll(" "," ");if(h.textContent=u,u!==d)h.setAttribute("display-value",d)};for(let h of this.data.options){let d=document.createElement("option");if(n(d,h.displayValue),d.value=h.exportValue,s.value.includes(h.exportValue))d.setAttribute("selected",!0),r=!1;i.append(d)}let a=null;if(r){let h=document.createElement("option");h.value=" ",h.setAttribute("hidden",!0),h.setAttribute("selected",!0),i.prepend(h),a=()=>{h.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}let o=(h)=>{let d=h?"value":"textContent",{options:u,multiple:f}=i;if(!f)return u.selectedIndex===-1?null:u[u.selectedIndex][d];return Array.prototype.filter.call(u,(p)=>p.selected).map((p)=>p[d])},l=o(!1),c=(h)=>{let d=h.target.options;return Array.prototype.map.call(d,(u)=>({displayValue:u.getAttribute("display-value")||u.textContent,exportValue:u.value}))};if(this.enableScripting&&this.hasJSActions)i.addEventListener("updatefromsandbox",(h)=>{let d={value(u){a?.();let f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(let g of i.options)g.selected=p.has(g.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(u){i.multiple=!0},remove(u){let f=i.options,p=u.detail.remove;if(f[p].selected=!1,i.remove(p),f.length>0){if(Array.prototype.findIndex.call(f,(m)=>m.selected)===-1)f[0].selected=!0}t.setValue(e,{value:o(!0),items:c(u)}),l=o(!1)},clear(u){while(i.length!==0)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(u){let{index:f,displayValue:p,exportValue:g}=u.detail.insert,m=i.children[f],v=document.createElement("option");if(n(v,p),v.value=g,m)m.before(v);else i.append(v);t.setValue(e,{value:o(!0),items:c(u)}),l=o(!1)},items(u){let{items:f}=u.detail;while(i.length!==0)i.remove(0);for(let p of f){let{displayValue:g,exportValue:m}=p,v=document.createElement("option");n(v,g),v.value=m,i.append(v)}if(i.options.length>0)i.options[0].selected=!0;t.setValue(e,{value:o(!0),items:c(u)}),l=o(!1)},indices(u){let f=new Set(u.detail.indices);for(let p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,h)}),i.addEventListener("input",(h)=>{let d=o(!0),u=o(!1);t.setValue(e,{value:d}),h.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(h)=>h.target.value);else i.addEventListener("input",function(h){t.setValue(e,{value:o(!0)})});if(this.data.combo)this._setTextStyle(i);return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Js extends ct{constructor(t){let{data:e,elements:s,parent:i}=t,r=!!i._commentManager;super(t,{isRenderable:!r&&ct._hasPopupData(e)});if(this.elements=s,r&&ct._hasPopupData(e)){let n=this.popup=this.#t();for(let a of s)a.popup=n}else this.popup=null}#t(){return new Io({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#t(),s=[];for(let i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map((i)=>`${Ye}${i}`).join(",")),this.container}}class Io{#t=null;#e=this.#V.bind(this);#s=this.#x.bind(this);#i=this.#T.bind(this);#r=this.#$.bind(this);#n=null;#a=null;#o=null;#l=null;#c=null;#u=null;#h=null;#f=!1;#p=null;#m=null;#d=null;#g=null;#v=null;#y=null;#b=null;#_=null;#A=null;#S=null;#w=!1;#E=null;#M=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:l,parentRect:c,open:h,commentManager:d=null}){if(this.#a=t,this.#A=i,this.#o=n,this.#_=a,this.#u=o,this.#n=e,this.#b=l,this.#h=c,this.#c=s,this.#t=d,this.#E=s[0],this.#l=Xs.toDateObject(r),this.trigger=s.flatMap((u)=>u.getElementsToTriggerPopup()),!d){if(this.#I(),this.#a.hidden=!0,h)this.#$()}}#I(){if(this.#m)return;this.#m=new AbortController;let{signal:t}=this.#m;for(let e of this.trigger)e.addEventListener("click",this.#r,{signal:t}),e.addEventListener("pointerenter",this.#i,{signal:t}),e.addEventListener("pointerleave",this.#s,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#c)e.container?.addEventListener("keydown",this.#e,{signal:t})}#C(){let t=this.#c.find((e)=>e.hasCommentButton);if(!t)return;this.#v=t._normalizePoint(t.commentButtonPosition)}renderCommentButton(){if(this.#g){if(!this.#g.parentNode)this.#E.container.after(this.#g);return}if(!this.#v)this.#C();if(!this.#v)return;let{signal:t}=this.#m=new AbortController,e=this.#E.hasOwnCommentButton,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(!e){let n=this.#g=document.createElement("button");n.className="annotationCommentButton";let a=this.#E.container;n.style.zIndex=parseInt(a.style.zIndex,10)+1,n.tabIndex=0,n.ariaHasPopup="dialog",n.ariaControls="commentPopup",n.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#P(),this.#F(),n.addEventListener("keydown",this.#e,{signal:t}),n.addEventListener("click",s,{signal:t}),n.addEventListener("pointerenter",i,{signal:t}),n.addEventListener("pointerleave",r,{signal:t}),a.after(n)}else{this.#g=this.#E.container;for(let n of this.trigger)n.ariaHasPopup="dialog",n.ariaControls="commentPopup",n.addEventListener("keydown",this.#e,{signal:t}),n.addEventListener("click",s,{signal:t}),n.addEventListener("pointerenter",i,{signal:t}),n.addEventListener("pointerleave",r,{signal:t}),n.classList.add("popupTriggerArea")}}#F(){if(this.#E.extraPopupElement&&!this.#E.editor)return;if(!this.#g)this.renderCommentButton();let[t,e]=this.#v,{style:s}=this.#g;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#P(){if(this.#E.extraPopupElement)return;if(!this.#g)this.renderCommentButton();this.#g.style.backgroundColor=this.commentButtonColor||""}get commentButtonColor(){let{color:t,opacity:e}=this.#E.commentData;return!t?null:this.#u._commentManager.makeCommentColor(t,e)}focusCommentButton(){setTimeout(()=>{this.#g?.focus()},0)}getData(){let{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=this.#E.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return this.#g}get comment(){return this.#M||=this.#E.commentText,this.#M}set comment(t){if(t===this.comment)return;this.#E.commentText=this.#M=t}focus(){this.#E.container?.focus()}get parentBoundingClientRect(){return this.#E.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#g)return;this.#g.classList.toggle("selected",t),this.#g.ariaExpanded=e}setSelectedCommentButton(t){this.#g.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;let{x:t,y:e,height:s}=this.#g.getBoundingClientRect(),{x:i,y:r,width:n,height:a}=this.#E.layer.getBoundingClientRect();return[(t-i)/n,(e+s-r)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#v}get commentButtonWidth(){return this.#g.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,s]=this.#y||this.commentButtonPosition.map((l)=>l/100),i=this.parentBoundingClientRect,{x:r,y:n,width:a,height:o}=i;this.#t.showDialog(null,this,r+e*a,n+s*o,{...t,parentDimensions:i})}render(){if(this.#p)return;let t=this.#p=document.createElement("div");if(t.className="popup",this.#n){let s=t.style.outlineColor=O.makeHexColor(...this.#n);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#A?.str){let s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#A}if(t.append(e),this.#l){let s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),s.dateTime=this.#l.toISOString(),e.append(s)}da({html:this.#O||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#a.append(t)}get#O(){let t=this.#_,e=this.#o;if(t?.str&&(!e?.str||e.str===t.str))return this.#_.html||null;return null}get#D(){return this.#O?.attributes?.style?.fontSize||0}get#R(){return this.#O?.attributes?.style?.color||null}#B(t){let e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#R,fontSize:this.#D?`calc(${this.#D}px * var(--total-scale-factor))`:""}};for(let r of t.split(`
49
+ `))e.push({name:"span",value:r,attributes:i});return s}#V(t){if(t.altKey||t.shiftKey||t.ctrlKey||t.metaKey)return;if(t.key==="Enter"||t.key==="Escape"&&this.#f)this.#$()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){if(s)this.remove(),this.#M=null;else if(e)if(e.deleted)this.remove();else this.#P(),this.#M=e.text;if(t)this.#v=null,this.#C(),this.#F();return}if(s||e?.deleted){this.remove();return}if(this.#I(),this.#S||={contentsObj:this.#o,richText:this.#_},t)this.#d=null;if(e&&e.text)this.#_=this.#B(e.text),this.#l=Xs.toDateObject(e.date),this.#o=null;this.#p?.remove(),this.#p=null}resetEdited(){if(!this.#S)return;({contentsObj:this.#o,richText:this.#_}=this.#S),this.#S=null,this.#p?.remove(),this.#p=null,this.#d=null}remove(){if(this.#m?.abort(),this.#m=null,this.#p?.remove(),this.#p=null,this.#w=!1,this.#f=!1,this.#g?.remove(),this.#g=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#j(){if(this.#d!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=this.#u,n=!!this.#h,a=n?this.#h:this.#b;for(let f of this.#c)if(!a||O.intersect(f.data.rect,a)!==null){a=f.data.rect,n=!0;break}let o=O.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=5,c=n?a[2]-a[0]+l:0,h=o[0]+c,d=o[1];this.#d=[100*(h-i)/e,100*(d-r)/s];let{style:u}=this.#a;u.left=`${this.#d[0]}%`,u.top=`${this.#d[1]}%`}#$(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}if(this.#f=!this.#f,this.#f)this.#T(),this.#a.addEventListener("click",this.#r),this.#a.addEventListener("keydown",this.#e);else this.#x(),this.#a.removeEventListener("click",this.#r),this.#a.removeEventListener("keydown",this.#e)}#T(){if(!this.#p)this.render();if(!this.isVisible)this.#j(),this.#a.hidden=!1,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)+1000;else if(this.#f)this.#a.classList.add("focused")}#x(){if(this.#a.classList.remove("focused"),this.#f||!this.isVisible)return;this.#a.hidden=!0,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)-1000}forceHide(){if(this.#w=this.isVisible,!this.#w)return;this.#a.hidden=!0}maybeShow(){if(this.#t)return;if(this.#I(),!this.#w)return;if(!this.#p)this.#T();this.#w=!1,this.#a.hidden=!1}get isVisible(){return!this.#t&&this.#a.hidden===!1}}class Lr extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=K.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}if(!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class Po extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:s}=this,i=ct._svgFactory,r=i.create(e,s,!0),n=this.#t=i.createElement("svg:line");if(n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),r.append(n),this.container.append(r),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ko extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:s}=this,i=ct._svgFactory,r=i.create(e,s,!0),n=t.borderStyle.width,a=this.#t=i.createElement("svg:rect");if(a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",s-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Mo extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:s}=this,i=ct._svgFactory,r=i.create(e,s,!0),n=t.borderStyle.width,a=this.#t=i.createElement("svg:ellipse");if(a.setAttribute("cx",e/2),a.setAttribute("cy",s/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",s/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Nr extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:r,height:n}=this;if(!e)return this.container;let a=ct._svgFactory,o=a.create(r,n,!0),l=[];for(let h=0,d=e.length;h<d;h+=2){let u=e[h]-t[0],f=t[3]-e[h+1];l.push(`${u},${f}`)}l=l.join(" ");let c=this.#t=a.createElement(this.svgElementName);if(c.setAttribute("points",l),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),o.append(c),this.container.append(o),!i&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Oo extends Nr{constructor(t){super(t);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ro extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){if(this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}}class Li extends ct{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?K.HIGHLIGHT:K.INK}#s(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#s(e,t),l=ct._svgFactory,c=l.create(a,o,!0),h=this.#t=l.createElement("svg:g");c.append(h),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",n);for(let d of s){let u=l.createElement(this.svgElementName);this.#e.push(u),u.setAttribute("points",d.join(",")),h.append(u)}if(!r&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:s,rect:i}=t,r=this.#t;if(e>=0)r.setAttribute("stroke-width",e||1);if(s)for(let n=0,a=this.#e.length;n<a;n++)this.#e[n].setAttribute("points",s[n].join(","));if(i){let{transform:n,width:a,height:o}=this.#s(this.data.rotation,i);r.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),r.setAttribute("transform",n)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Br extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=K.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Fo extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("underlineAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Do extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("squigglyAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Lo extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("strikeoutAnnotation"),t){let s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class jr extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=K.STAMP}render(){if(this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class No extends ct{#t=null;constructor(t){super(t,{isRenderable:!0});let{fileId:e,file:s}=this.data;this.filename=s.filename,this.content=s.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,s;if(e.hasAppearance||e.fillAlpha===0)s=document.createElement("div");else if(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1)s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`;s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;let{isMac:i}=lt.platform;if(t.addEventListener("keydown",(r)=>{if(r.key==="Enter"&&(i?r.metaKey:r.ctrlKey))this.#e()}),!e.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();else s.classList.add("popupTriggerArea");return t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}async#e(){let{fileId:t,filename:e,content:s}=this,i=await this.linkService.getAttachmentContent(t)||s;if(i)this.downloadManager?.openOrDownloadData(i,e)}}class Hr extends ct{#t=new AbortController;#e=null;#s=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");let{filename:t}=this.data.richMedia,e=document.createElement("button");return e.className="mediaPlayButton",e.type="button",e.title=e.ariaLabel=t,e.addEventListener("click",()=>this.#i(e),{signal:this.#t.signal}),this.container.append(e),this.container}async#i(t){let{fileId:e,filename:s,contentType:i}=this.data.richMedia;t.disabled=!0;let r;try{r=await this.linkService.getAttachmentContent(e)}catch{return}finally{t.disabled=!1}if(!r||!t.isConnected)return;let{signal:n}=this.#t,a=new Blob([r],{type:i});if(!/^(?:video|audio)\//.test(a.type))return;let o=URL.createObjectURL(a);this.#e=o;let l=a.type.startsWith("audio/"),c=document.createElement(l?"audio":"video");if(this.#s=c,c.className="mediaContent",this._setBackgroundColor(c),c.src=o,c.title=s,c.controls=!0,c.autoplay=!0,c.tabIndex=0,l){let h=!1,d=!1,u=()=>{c.controls=h||d};this.container.addEventListener("pointerenter",()=>{h=!0,u()},{signal:n}),this.container.addEventListener("pointerleave",()=>{h=!1,u()},{signal:n}),this.container.addEventListener("focusin",()=>{d=!0,u()},{signal:n}),this.container.addEventListener("focusout",()=>{d=!1,u()},{signal:n})}c.addEventListener("emptied",()=>this.#r(o),{once:!0,signal:n}),t.replaceWith(c),c.play().catch(()=>{})}#r(t=this.#e){if(t&&t===this.#e)URL.revokeObjectURL(t),this.#e=null}destroy(){if(this.#t.abort(),this.#s)this.#s.pause(),this.#s.removeAttribute("src"),this.#s.load(),this.#s=null;this.#r()}}class Ur{#t=null;#e=null;#s=null;#i=new Map;#r=null;#n=null;#a=[];#o=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:n,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:c}){this.div=t,this.#t=e,this.#e=s,this.#r=a||null,this.#n=l||null,this.#s=c||new xi,this.page=r,this.viewport=n,this._annotationEditorUIManager=i,this._commentManager=o||null}hasEditableAnnotations(){return this.#i.size>0}async render(t){let{annotations:e,optionalContentConfig:s}=t,i=this.div;Ne(i,this.viewport);let r=new Map,n=[],a={data:null,layer:i,linkService:this.#n,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,annotationStorage:this.#s,enableComment:t.enableComment===!0,enableAnnotationEditing:t.enableAnnotationEditing!==!1,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let o of e){if(o.noHTML)continue;let l=o.annotationType===yt.POPUP;if(!l){if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue}else{let d=r.get(o.id);if(!d)continue;if(!this._commentManager){n.push(o);continue}a.elements=d}a.data=o;let c=$s.create(a);if(!c.isRenderable)continue;if(!l){if(this.#a.push(c),o.popupRef)r.getOrInsertComputed(o.popupRef,Ze).push(c)}let h=c.render();if(o.hidden)h.style.visibility="hidden";if(c.updateOC(s),c._isEditable)this.#i.set(c.data.id,c),this._annotationEditorUIManager?.renderAnnotationElement(c)}await this.#l();for(let o of n){let l=a.elements=r.get(o.id);a.data=o;let c=$s.create(a);if(!c.isRenderable)continue;let h=c.render();if(c.contentElement.id=`${Ye}${o.id}`,o.hidden)h.style.visibility="hidden";l.at(-1).container.after(h)}this.#c()}async#l(){if(this.#a.length===0)return;this.div.replaceChildren();let t=[];if(!this.#o){this.#o=!0;for(let{contentElement:s,data:{hidden:i,id:r,oc:n}}of this.#a){let a=s.id=`${Ye}${r}`,o=s.localName==="a"&&!i&&!n;t.push(this.#r?.getAriaAttributes(a,{enableLinkOwnership:o}).then((l)=>{if(l)for(let[c,h]of l)s.setAttribute(c,h)}))}}this.#a.sort(({data:{rect:[s,i,r,n]}},{data:{rect:[a,o,l,c]}})=>{if(s===r&&i===n)return 1;if(a===l&&o===c)return-1;let h=n,d=i,u=(i+n)/2,f=c,p=o,g=(o+c)/2;if(u>=f&&g<=d)return-1;if(g>=h&&u<=p)return 1;let m=(s+r)/2,v=(a+l)/2;return m-v});let e=document.createDocumentFragment();for(let s of this.#a)if(e.append(s.container),this._commentManager)(s.extraPopupElement?.popup||s.popup)?.renderCommentButton();else if(s.extraPopupElement)e.append(s.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t){let s=await this.#r?.getAnnotationIds();for(let{contentElement:i}of this.#a){if(s?.has(i.id))continue;this.#t.addPointerInTextLayer(i,!1)}}}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#n,parent:this};for(let s of t){s.borderStyle||=Ur._defaultBorderStyle,e.data=s;let i=$s.create(e);if(!i.isRenderable)continue;i.render(),i.contentElement.id=`${Ye}${s.id}`,this.#a.push(i)}await this.#l()}update({viewport:t,optionalContentConfig:e}){let s=this.div;this.viewport=t,Ne(s,{rotation:t.rotation});for(let i of this.#a)i.updateOC(e);this.#c(),s.hidden=!1}destroy(){for(let t of this.#a)t.destroy?.(),this.#t?.removePointerInTextLayer(t.contentElement);this.#a.length=0,this.#i.clear(),this.div.replaceChildren()}#c(){if(!this.#e)return;let t=this.div;for(let[e,s]of this.#e){let i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;if(Array.isArray(s))for(let l of s)l.className="annotationContent",l.ariaHidden=!0;else s.className="annotationContent",s.ariaHidden=!0;let r=[];for(let l of i.children)if(l.nodeName==="CANVAS")r.push(l);for(let l of r)l.remove();let n=Array.isArray(s)?s[0]:s,{firstChild:a}=i;if(!a)i.append(n);else if(!a.classList.contains("annotationContent"))a.before(n);else a.after(n);if(Array.isArray(s)){let l=n;for(let c=1,h=s.length;c<h;c++)l.after(s[c]),l=s[c]}this.#e.delete(e);let o=this.#i.get(e);if(!o)continue;if(o._hasNoCanvas)this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),o._hasNoCanvas=!1;else o.canvas=s}}refreshCanvases(){this.#c()}getEditableAnnotations(){return this.#i.values()}getEditableAnnotation(t){return this.#i.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:s,rotation:i}=t,r=new _o({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#n,annotationStorage:this.#s});return r.render(),r.contentElement.id=`${Ye}${s}`,r.createOrUpdatePopup(),this.#a.push(r),r}removeAnnotation(t){let e=this.#a.findIndex((i)=>i.data.id===t);if(e<0)return;let[s]=this.#a.splice(e,1);this.#t?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length===0)return;for(let e of t)e.updateFakeAnnotationElement(this);this.#l()}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return L(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Xe.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}var Ds=/\r\n?|\n/g;class Pt extends U{#t="";#e=`${this.id}-editor`;#s=null;#i;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=Pt.prototype,e=(r)=>r.isEmpty(),{TRANSLATE_SMALL:s,TRANSLATE_BIG:i}=Se;return L(this,"_keyboardManager",new Xt([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=K.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"});if(this.color=t.color||Pt._defaultColor||U._defaultLineColor,this.#i=t.fontSize||Pt._defaultFontSize,!this.annotationElementId)this._uiManager.a11yAlert(U._l10nAlert.freetext);this.canAddComment=!1}static initialize(t,e){U.initialize(t,e);let s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case st.FREETEXT_SIZE:Pt._defaultFontSize=e;break;case st.FREETEXT_COLOR:Pt._defaultColor=e;break}}updateParams(t,e){switch(t){case st.FREETEXT_SIZE:this.#r(e);break;case st.FREETEXT_COLOR:this.#n(e);break}}static get defaultPropertiesToUpdate(){return[[st.FREETEXT_SIZE,Pt._defaultFontSize],[st.FREETEXT_COLOR,Pt._defaultColor||U._defaultLineColor]]}get propertiesToUpdate(){return[[st.FREETEXT_SIZE,this.#i],[st.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new bs(this),[["colorPicker",this._colorPicker]]}get colorType(){return st.FREETEXT_COLOR}#r(t){let e=(i)=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-this.#i)*this.parentScale),this.#i=i,this.#o()},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#n(t){let e=(i)=>{this.color=i,this.onUpdatedColor()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-Pt._internalPadding*t,-(Pt._internalPadding+this.#i)*t]}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(!this.isAttachedToDOM)this.parent.add(this)}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let t=this._uiManager.combinedSignal(this.#s);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){if(!super.disableEditMode())return!1;return this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0}focusin(t){if(!this._focusEventsAllowed)return;if(super.focusin(t),t.target!==this.editorDiv)this.editorDiv.focus()}onceAdded(t){if(this.width)return;if(this.enableEditMode(),t)this.editorDiv.focus();if(this._initialOptions?.isCentered)this.center();this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){if(this.isEditing=!1,this.parent)this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing");super.remove()}#a(){let t=[];this.editorDiv.normalize();let e=null;for(let s of this.editorDiv.childNodes){if(e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR")continue;t.push(Pt.#l(s)),e=s}return t.join(`
50
+ `)}#o(){let[t,e]=this.parentDimensions,s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{let{currentLayer:i,div:r}=this,n=r.style.display,a=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",i.div.append(this.div),s=r.getBoundingClientRect(),r.remove(),r.style.display=n,r.classList.toggle("hidden",a)}if(this.rotation%180===this.parentRotation%180)this.width=s.width/t,this.height=s.height/e;else this.width=s.height/t,this.height=s.width/e;this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#t,e=this.#t=this.#a().trimEnd();if(t===e)return;let s=(i)=>{if(this.#t=i,!i){this.remove();return}this.#c(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){if(t.target===this.div&&t.key==="Enter")this.enterInEditMode(),t.preventDefault()}editorDivKeydown(t){Pt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy||this.annotationElementId)t=this.x,e=this.y;super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,r]=this.parentDimensions;if(this.annotationElementId){let{position:n}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[l,c]=this.pageDimensions,[h,d]=this.pageTranslation,u,f;switch(this.rotation){case 0:u=t+(n[0]-h)/l,f=e+this.height-(n[1]-d)/c;break;case 90:u=t+(n[0]-h)/l,f=e-(n[1]-d)/c,[a,o]=[o,-a];break;case 180:u=t-this.width+(n[0]-h)/l,f=e-(n[1]-d)/c,[a,o]=[-a,-o];break;case 270:u=t+(n[0]-h-this.height*c)/l,f=e+(n[1]-d-this.width*l)/c,[a,o]=[-o,a];break}this.setAt(u*i,f*r,a,o)}else this._moveAfterPaste(t,e);this.#c(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Ds,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();let i=Pt.#h(e.getData("text")||"").replaceAll(Ds,`
51
+ `);if(!i)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let n=r.getRangeAt(0);if(!i.includes(`
52
+ `)){n.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:a,startOffset:o}=n,l=[],c=[];if(a.nodeType===Node.TEXT_NODE){let u=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(Ds,"")),u!==this.editorDiv){let f=l;for(let p of this.editorDiv.childNodes){if(p===u){f=c;continue}f.push(Pt.#l(p))}}l.push(a.nodeValue.slice(0,o).replaceAll(Ds,""))}else if(a===this.editorDiv){let u=l,f=0;for(let p of this.editorDiv.childNodes){if(f++===o)u=c;u.push(Pt.#l(p))}}this.#t=`${l.join(`
53
+ `)}${i}${c.join(`
54
+ `)}`,this.#c();let h=new Range,d=Math.sumPrecise(l.map((u)=>u.length));for(let{firstChild:u}of this.editorDiv.childNodes)if(u.nodeType===Node.TEXT_NODE){let f=u.nodeValue.length;if(d<=f){h.setStart(u,d),h.setEnd(u,d);break}d-=f}r.removeAllRanges(),r.addRange(h)}#c(){if(this.editorDiv.replaceChildren(),!this.#t)return;for(let t of this.#t.split(`
55
+ `)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#h(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=Pt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof Lr){let{data:{defaultAppearanceData:{fontSize:n,fontColor:a},rect:o,rotation:l,id:c,popupRef:h,richText:d,contentsObj:u,creationDate:f,modificationDate:p},textContent:g,textPosition:m,parent:{page:{pageNumber:v}}}=t;if(!g?.length)return null;i=t={annotationType:K.FREETEXT,color:Array.from(a),fontSize:n,value:g.join(`
56
+ `),position:m,pageIndex:v-1,rect:o.slice(0),rotation:l,annotationElementId:c,id:c,deleted:!1,popupRef:h,comment:u?.str||null,richText:d,creationDate:f,modificationDate:p}}let r=await super.deserialize(t,e,s);if(r.#i=t.fontSize,r.color=O.makeHexColor(...t.color),r.#t=Pt.#h(t.value),r._initialData=i,t.comment)r.setCommentData(t);return r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=U._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#i,value:this.#u()});if(this.addComment(s),t)return s.isCopy=!0,s;if(this.annotationElementId&&!this.#f(s))return null;return s.id=this.annotationElementId,s}#f(t){let{value:e,fontSize:s,color:i,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((n,a)=>n!==i[a])||t.pageIndex!==r}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:s}=e;s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(let i of this.#t.split(`
57
+ `)){let r=document.createElement("div");r.append(i?document.createTextNode(i):document.createElement("br")),e.append(r)}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 Ni{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(!t)return;for(let[e,s]of Object.entries(t))if(!e.startsWith("_"))this.updateProperty(e,s)}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(){at("Not implemented")}}class et extends U{#t=null;#e;_clipPathId=null;_colorPicker=null;_drawId=null;_drawOutlines=null;_focusDrawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#r=null;static#n=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.#a(t),this.#m()}#a({drawOutlines:t,drawId:e,drawingOptions:s,clipPathId:i}){if(this._drawOutlines=t,this._drawingOptions||=s,!this.annotationElementId)this._uiManager.a11yAlert(U._l10nAlert[this.editorType]);if(e>=0)this._drawId=e,this._clipPathId=i??null,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties),this.#l(this.parent);else this._drawId=this.#o(t,this.parent);this.#v(t.box)}#o(t,e){let{id:s,clipPathId:i}=e.drawLayer.draw(et._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,this.constructor._hasClipPath);if(this.constructor._hasClipPath)this._clipPathId=i;return this.#l(e),s}#l(t){let e=this._drawOutlines.getFocusSVGProperties(this.#f);if(e)this._focusDrawId=t.drawLayer.drawOutline(e,this._drawOutlines.focusMustRemoveSelfIntersections)}#c(t=this.#f){if(this._focusDrawId===null)return;this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(t))}#u(t){if(this._focusDrawId!==null)this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:t})}#h(){let{parent:t,_drawId:e,_focusDrawId:s,_isVisible:i}=this;if(!t||e===null)return;let r={hidden:!i};if(t.drawLayer.updateProperties(e,{rootClass:r}),s!==null)t.drawLayer.updateProperties(s,{rootClass:r})}static _mergeSVGProperties(t,e){let s=new Set(Object.keys(t));for(let[i,r]of Object.entries(e))if(s.has(i))Object.assign(t[i],r);else t[i]=r;return t}static getDefaultDrawingOptions(t){at("Not implemented")}static get typesMap(){at("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}get#f(){return(this.parentRotation-this._drawRotation+360)%360}static updateDefaultParams(t,e){let s=this.typesMap.get(t);if(s)this._defaultDrawingOptions.updateProperty(s,e);if(this._currentParent)et.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}updateParams(t,e){let s=this.constructor.typesMap.get(t);if(s)this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){let i=this._drawingOptions,r=i[e],n=(a)=>{i.updateProperty(e,a);let o=this._drawOutlines.updateProperty(e,a);if(o)this.#v(o);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,s),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e,s=this.colorAndOpacityType){let i=this.constructor.typesMap.get(this.colorType),r=this._opacityName,n=this._drawingOptions,a=n[i],o=n[r],l=(c,h)=>{n.updateProperty(i,c),n.updateProperty(r,h),this._drawOutlines.updateProperty(i,c),this._drawOutlines.updateProperty(r,h),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,t,e),undo:l.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:s,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(this.#g()),{bbox:this.#y()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(this.#g()),{bbox:this.#y()})),this.#c()}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#y()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(this.#g(),this.parentDimensions),{bbox:this.#y()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}get _mustBeDisabledOnCommit(){return!0}commit(){if(super.commit(),this._mustBeDisabledOnCommit)this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){if(!this.annotationElementId&&this._drawId!==null)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._uiManager.removeShouldRescale(this),this.#p(),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#m(),this.#v(this._drawOutlines.box),!this.isAttachedToDOM)this.parent.add(this)}setParent(t){let e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),this.#p();else if(t)this._uiManager.addShouldRescale(this),this.#m(t),e=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(t),this.#h(),e)this.select()}#p(){if(this._drawId===null||!this.parent)return;let{drawLayer:t}=this.parent;if(t.remove(this._drawId),this._drawId=null,this._focusDrawId!==null)t.remove(this._focusDrawId),this._focusDrawId=null;this._drawingOptions.reset()}#m(t=this.parent){if(this._drawId!==null&&this.parent===t)return;if(this._drawId!==null){let{drawLayer:e}=this.parent;if(e.updateParent(this._drawId,t.drawLayer),this._focusDrawId!==null)e.updateParent(this._focusDrawId,t.drawLayer);return}if(this._drawingOptions.updateAll(),this._drawId=this.#o(this._drawOutlines,t),this._clipPathId&&this.#t)this.#t.style.clipPath=this._clipPathId}#d([t,e,s,i]){let{parentDimensions:[r,n],_drawRotation:a}=this;switch(a){case 90:return[e,1-t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#g(){let{x:t,y:e,width:s,height:i,parentDimensions:[r,n],_drawRotation:a}=this;switch(a){case 90:return[1-e,t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#v(t){if([this.x,this.y,this.width,this.height]=this.#d(t),this.div)this.fixAndSetPosition(),this.setDims();this._onResized()}#y(t=this.parentRotation){let{x:e,y:s,width:i,height:r,_drawRotation:n,parentDimensions:[a,o]}=this;switch((n*4+t)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(a/o),r*(o/a),i*(a/o)];case 5:return[1-s,e,i*(a/o),r*(o/a)];case 6:return[1-e-r*(o/a),1-s,r*(o/a),i*(a/o)];case 7:return[s-i*(a/o),1-e-r*(o/a),i*(a/o),r*(o/a)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(o/a),s,r*(o/a),i*(a/o)];case 13:return[1-s-i*(a/o),e-r*(o/a),i*(a/o),r*(o/a)];case 14:return[1-e,1-s-i*(a/o),r*(o/a),i*(a/o)];case 15:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}}rotate(t=this.parentRotation){if(!this.parent||this._drawId===null)return;let e=(t-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties({bbox:this.#y(t)},this._drawOutlines.updateRotation(e))),this.#c(e)}show(t=this._isVisible){super.show(t),this.#h()}select(){super.select(),this.#u({hovered:!1,selected:!0})}unselect(){super.unselect(),this.#u({selected:!1})}pointerover(){if(!this.isSelected)this.#u({hovered:!0})}pointerleave(){if(!this.isSelected)this.#u({hovered:!1})}onScaleChanging(){if(!this.parent)return;let t=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);if(t)this.#v(t)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;if(this._isCopy)t=this.x,e=this.y;let s=super.render();if(this.constructor._hasDrawClass)s.classList.add("draw");let i=this.#t=document.createElement("div");if(s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this._clipPathId)i.style.clipPath=this._clipPathId;if(fa(this,i,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy)this._moveAfterPaste(t,e);return s}static createDrawerInstance(t){at("Not implemented")}static _getDrawingTarget(t,{target:e}){return e}static _getPointerCoords({offsetX:t,offsetY:e,clientX:s,clientY:i},r=null){if(!r)return[t,e];let n=s-r.clientX,a=i-r.clientY;switch(this._currentParent.viewport.rotation){case 90:[n,a]=[a,-n];break;case 180:[n,a]=[-n,-a];break;case 270:[n,a]=[-a,n];break}return[r.offsetX+n,r.offsetY+a]}static _addDrawingListeners(t,e){}static _endDrawingSession(t=!1){return this._currentParent.endDrawingSession(t)}static startDrawing(t,e,s,i){let{pointerId:r,pointerType:n}=i;if(ot.isInitializedAndDifferentPointerType(n))return;let a=this._getDrawingTarget(t,i),[o,l]=this._getPointerCoords(i),{viewport:{rotation:c}}=t,{x:h,y:d,width:u,height:f}=a.getBoundingClientRect(),p=et.#i=new AbortController,g=t.combinedSignal(p);if(ot.setPointer(n,r),window.addEventListener("pointerup",(y)=>{if(ot.isSamePointerIdOrRemove(y.pointerId))this._endDraw(y)},{signal:g}),window.addEventListener("pointercancel",(y)=>{if(ot.isSamePointerIdOrRemove(y.pointerId))this._endDrawingSession()},{signal:g}),window.addEventListener("pointerdown",(y)=>{if(!ot.isSamePointerType(y.pointerType))return;if(ot.initializeAndAddPointerId(y.pointerId),et.#s.isCancellable())if(et.#s.removeLastElement(),et.#s.isEmpty())this._endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",re,{signal:g}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),a.addEventListener("touchmove",(y)=>{if(ot.isSameTimeStamp(y.timeStamp))Tt(y)},{signal:g}),this._addDrawingListeners(a,g),t.toggleDrawing(),e._editorUndoBar?.hide(),et.#s){t.drawLayer.updateProperties(this._currentDrawId,et.#s.startNew(o,l,u,f,c,i.timeStamp));return}e.updateUIForDefaultProperties(this),et.#s=this.createDrawerInstance({x:o,y:l,box:[h,d,u,f],rotation:c,parent:t,isLTR:s,timeStamp:i.timeStamp}),et.#r=this.getDefaultDrawingOptions(),this._currentParent=t;let{id:m,clipPathId:v}=t.drawLayer.draw(this._mergeSVGProperties(et.#r.toSVGProperties(),et.#s.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=m,et.#n=this._hasClipPath?v:null}static _drawMove(t){if(ot.isSameTimeStamp(t.timeStamp),!et.#s||!ot.isSamePointerId(t.pointerId))return;if(ot.isUsingMultiplePointers()){this._endDraw(t);return}let e,s=t.getCoalescedEvents?.();if(s?.length){let i=[],r=[];for(let n of s)i.push(...this._getPointerCoords(n,t)),r.push(n.timeStamp);e=et.#s.addPoints(i,r)}else e=et.#s.add(...this._getPointerCoords(t),t.timeStamp);this._currentParent.drawLayer.updateProperties(this._currentDrawId,e),ot.setTimeStamp(t.timeStamp),Tt(t)}static _cleanup(t){if(t)this._currentDrawId=-1,this._currentParent=null,et.#s=null,et.#r=null,et.#n=null,ot.clearTimeStamp();if(et.#i)et.#i.abort(),et.#i=null,ot.clearPointerIds()}static _endDraw(t){let e=this._currentParent;if(!e)return;if(e.toggleDrawing(!0),this._cleanup(!1),e.drawLayer.updateProperties(this._currentDrawId,t?.target===e.div?et.#s.end(...this._getPointerCoords(t),t.timeStamp):et.#s.end()),this.supportMultipleDrawings){let s=et.#s,i=this._currentDrawId,r=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(r))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:st.DRAW_STEP});return}this.endDrawing(!1)}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(st.DRAW_STEP),!et.#s.isEmpty()){let{pageDimensions:[s,i],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:et.#n,drawOutlines:et.#s.getOutlines(s*r,i*r,r,this._INNER_MARGIN),drawingOptions:et.#r,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,r,n,a){at("Not implemented")}static async deserialize(t,e,s){let{rawDims:{pageWidth:i,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,i,r,this._INNER_MARGIN,t,s),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#a({drawOutlines:o}),l.#m(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,s]=this.pageTranslation,[i,r]=this.pageDimensions;return this._drawOutlines.serialize([e,s,i,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class H{static PRECISION=0.0001;focusOutline=null;toSVGPath(){at("Abstract method `toSVGPath` must be implemented.")}get box(){at("Abstract getter `box` must be implemented.")}serialize(t,e){at("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){at("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],r){switch(r){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}static _rescale(t,e,s,i,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*i,n[a+1]=s+t[a+1]*r;return n}static _rescaleAndSwap(t,e,s,i,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*i,n[a+1]=s+t[a]*r;return n}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r,n=[]){switch(r){case 90:n[0]=1-e/s,n[1]=t/i;break;case 180:n[0]=1-t/s,n[1]=1-e/i;break;case 270:n[0]=e/s,n[1]=1-t/i;break;default:n[0]=t/s,n[1]=e/i;break}return n}static createBezierPoints(t,e,s,i,r,n,a=[]){return a.push((t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+n)/6,(s+r)/2,(i+n)/2),a}}class De{#t;#e=[];#s;#i;#r=[];#n=new Float32Array(18);#a;#o;#l;#c;#u;#h;#f=[];static#p=8;static#m=2;static#d=De.#p+De.#m;constructor(t,e,s,i,r,n,a=0){this.#t=s,this.#h=r*i,this.#i=n,this.#n.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#c=De.#p*i,this.#l=De.#d*i,this.#u=i,this.#f.push(t,e)}isEmpty(){return isNaN(this.#n[8])}isCancellable(){return this.#f.length<=10}removeLastElement(){return this.#n.fill(NaN),this.#r.length=this.#e.length=this.#f.length=0,{path:{d:""}}}#g(){let t=this.#n.subarray(4,6),e=this.#n.subarray(16,18),[s,i,r,n]=this.#t;return[(this.#a+(t[0]-e[0])/2-s)/r,(this.#o+(t[1]-e[1])/2-i)/n,(this.#a+(e[0]-t[0])/2-s)/r,(this.#o+(e[1]-t[1])/2-i)/n]}add(t,e){this.#a=t,this.#o=e;let[s,i,r,n]=this.#t,[a,o,l,c]=this.#n.subarray(8,12),h=t-l,d=e-c,u=Math.hypot(h,d);if(u<this.#l)return!1;let f=u-this.#c,p=f/u,g=p*h,m=p*d,v=a,y=o;a=l,o=c,l+=g,c+=m,this.#f?.push(t,e);let b=-m/f,_=g/f,w=b*this.#h,A=_*this.#h;if(this.#n.set(this.#n.subarray(2,8),0),this.#n.set([l+w,c+A],4),this.#n.set(this.#n.subarray(14,18),12),this.#n.set([l-w,c-A],16),isNaN(this.#n[6])){if(this.#r.length===0)this.#n.set([a+w,o+A],2),this.#r.push(NaN,NaN,NaN,NaN,(a+w-s)/r,(o+A-i)/n),this.#n.set([a-w,o-A],14),this.#e.push(NaN,NaN,NaN,NaN,(a-w-s)/r,(o-A-i)/n);return this.#n.set([v,y,a,o,l,c],6),!this.isEmpty()}if(this.#n.set([v,y,a,o,l,c],6),Math.abs(Math.atan2(y-o,v-a)-Math.atan2(m,g))<Math.PI/2)return[a,o,l,c]=this.#n.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/r,((o+c)/2-i)/n),[a,o,v,y]=this.#n.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((v+a)/2-s)/r,((y+o)/2-i)/n),!0;return[v,y,a,o,l,c]=this.#n.subarray(0,6),this.#r.push(((v+5*a)/6-s)/r,((y+5*o)/6-i)/n,((5*a+l)/6-s)/r,((5*o+c)/6-i)/n,((a+l)/2-s)/r,((o+c)/2-i)/n),[l,c,a,o,v,y]=this.#n.subarray(12,18),this.#e.push(((v+5*a)/6-s)/r,((y+5*o)/6-i)/n,((5*a+l)/6-s)/r,((5*o+c)/6-i)/n,((a+l)/2-s)/r,((o+c)/2-i)/n),!0}toSVGPath(){if(this.isEmpty())return"";let t=this.#r,e=this.#e;if(isNaN(this.#n[6])&&!this.isEmpty())return this.#v();let s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)if(isNaN(t[i]))s.push(`L${t[i+4]} ${t[i+5]}`);else s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)if(isNaN(e[i]))s.push(`L${e[i+4]} ${e[i+5]}`);else s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#y(s),s.join(" ")}#v(){let[t,e,s,i]=this.#t,[r,n,a,o]=this.#g();return`M${(this.#n[2]-t)/s} ${(this.#n[3]-e)/i} L${(this.#n[4]-t)/s} ${(this.#n[5]-e)/i} L${r} ${n} L${a} ${o} L${(this.#n[16]-t)/s} ${(this.#n[17]-e)/i} L${(this.#n[14]-t)/s} ${(this.#n[15]-e)/i} Z`}#y(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){let[e,s,i,r]=this.#t,n=this.#n.subarray(4,6),a=this.#n.subarray(16,18),[o,l,c,h]=this.#g();t.push(`L${(n[0]-e)/i} ${(n[1]-s)/r} L${o} ${l} L${c} ${h} L${(a[0]-e)/i} ${(a[1]-s)/r}`)}newFreeDrawOutline(t,e,s,i,r,n){return new $r(t,e,s,i,r,n)}getOutlines(){let t=this.#r,e=this.#e,s=this.#n,[i,r,n,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let h=0,d=o.length-2;h<d;h+=2)o[h]=(this.#f[h]-i)/n,o[h+1]=(this.#f[h+1]-r)/a;if(o[o.length-2]=(this.#a-i)/n,o[o.length-1]=(this.#o-r)/a,isNaN(s[6])&&!this.isEmpty())return this.#_(o);let l=new Float32Array(this.#r.length+24+this.#e.length),c=t.length;for(let h=0;h<c;h+=2){if(isNaN(t[h])){l[h]=l[h+1]=NaN;continue}l[h]=t[h],l[h+1]=t[h+1]}c=this.#S(l,c);for(let h=e.length-6;h>=6;h-=6)for(let d=0;d<6;d+=2){if(isNaN(e[h+d])){l[c]=l[c+1]=NaN,c+=2;continue}l[c]=e[h+d],l[c+1]=e[h+d+1],c+=2}return this.#A(l,c),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#i)}#_(t){let e=this.#n,[s,i,r,n]=this.#t,[a,o,l,c]=this.#g(),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/n,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/n,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/n],0),this.newFreeDrawOutline(h,t,this.#t,this.#u,this.#s,this.#i)}#A(t,e){let s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#S(t,e){let s=this.#n.subarray(4,6),i=this.#n.subarray(16,18),[r,n,a,o]=this.#t,[l,c,h,d]=this.#g();return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o],e),e+=24}}class $r extends H{#t;#e=new Float32Array(4);#s;#i;#r;#n;#a;constructor(t,e,s,i,r,n){super();this.#a=t,this.#r=e,this.#t=s,this.#n=i,this.#s=r,this.#i=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(n);let[a,o,l,c]=this.#e;for(let h=0,d=t.length;h<d;h+=2)t[h]=(t[h]-a)/l,t[h+1]=(t[h+1]-o)/c;for(let h=0,d=e.length;h<d;h+=2)e[h]=(e[h]-a)/l,e[h+1]=(e[h+1]-o)/c}toSVGPath(){let t=[`M${this.#a[4]} ${this.#a[5]}`];for(let e=6,s=this.#a.length;e<s;e+=6){if(isNaN(this.#a[e])){t.push(`L${this.#a[e+4]} ${this.#a[e+5]}`);continue}t.push(`C${this.#a[e]} ${this.#a[e+1]} ${this.#a[e+2]} ${this.#a[e+3]} ${this.#a[e+4]} ${this.#a[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],r){let n=s-t,a=i-e,o,l;switch(r){case 0:o=H._rescale(this.#a,t,i,n,-a),l=H._rescale(this.#r,t,i,n,-a);break;case 90:o=H._rescaleAndSwap(this.#a,t,e,n,a),l=H._rescaleAndSwap(this.#r,t,e,n,a);break;case 180:o=H._rescale(this.#a,s,e,-n,a),l=H._rescale(this.#r,s,e,-n,a);break;case 270:o=H._rescaleAndSwap(this.#a,s,i,-n,-a),l=H._rescaleAndSwap(this.#r,s,i,-n,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){let e=this.#a,s=e[4],i=e[5],r=[s,i,s,i],n=s,a=i,o=s,l=i,c=t?Math.max:Math.min,h=new Float32Array(4);for(let u=6,f=e.length;u<f;u+=6){let p=e[u+4],g=e[u+5];if(isNaN(e[u])){if(O.pointBoundingBox(p,g,r),a>g)n=p,a=g;else if(a===g)n=c(n,p);if(l<g)o=p,l=g;else if(l===g)o=c(o,p)}else{if(h.set(ce,0),O.bezierBoundingBox(s,i,...e.slice(u,u+6),h),O.rectBoundingBox(...h,r),a>h[1])n=h[0],a=h[1];else if(a===h[1])n=c(n,h[0]);if(l<h[3])o=h[2],l=h[3];else if(l===h[3])o=c(o,h[2])}s=p,i=g}let d=this.#e;d[0]=r[0]-this.#s,d[1]=r[1]-this.#s,d[2]=r[2]-r[0]+2*this.#s,d[3]=r[3]-r[1]+2*this.#s,this.firstPoint=[n,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,i,r,n,a=0){return new De(t,e,s,i,r,n,a)}updateThickness(t){let e=this.getNewOutline(t);return this.#a=e.#a,this.#r=e.#r,this.#e.set(e.#e),this.firstPoint=e.firstPoint,this.lastPoint=e.lastPoint,this.#e}getNewOutline(t,e){let[s,i,r,n]=this.#e,[a,o,l,c]=this.#t,h=r*l,d=n*c,u=s*l+a,f=i*c+o,p=this.#r,g=this.newOutliner(p[0]*h+u,p[1]*d+f,this.#t,this.#n,t,this.#i,e??this.#s);for(let m=2,v=p.length;m<v;m+=2)g.add(p[m]*h+u,p[m+1]*d+f);return g.getOutlines()}}function Bo(t){return{bbox:t.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:t.isFree},path:{d:t.toSVGPath()}}}function jo(t,e){let{focusOutline:s}=t;return{bbox:H._rotateBox(s.box,e),root:{"data-main-rotation":e},rootClass:{highlightOutline:!0,free:t.isFree},path:{d:s.toSVGPath()}}}class Qs{#t;#e;#s;#i=[];#r=[];constructor(t,e=0,s=0,i=!0){let r=ce.slice(),n=4,a=0.0001;for(let{x:g,y:m,width:v,height:y}of t){let b=Math.floor((g-e)/0.0001)*0.0001,_=Math.ceil((g+v+e)/0.0001)*0.0001,w=Math.floor((m-e)/0.0001)*0.0001,A=Math.ceil((m+y+e)/0.0001)*0.0001,x=[b,w,A,!0],E=[_,w,A,!1];this.#i.push(x,E),O.rectBoundingBox(b,w,_,A,r)}let o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,c=r[0]-s,h=r[1]-s,d=i?-1/0:1/0,u=1/0,f=this.#i.at(i?-1:-2),p=[f[0],f[2]];for(let g of this.#i){let[m,v,y,b]=g;if(!b&&i){if(v<u)u=v,d=m;else if(v===u)d=Math.max(d,m)}else if(b&&!i){if(v<u)u=v,d=m;else if(v===u)d=Math.min(d,m)}g[0]=(m-c)/o,g[1]=(v-h)/l,g[2]=(y-h)/l}this.#t=new Float32Array([c,h,o,l]),this.#e=[d,u],this.#s=p}getOutlines(){this.#i.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);let t=[];for(let e of this.#i)if(e[3])t.push(...this.#c(e)),this.#o(e);else this.#l(e),t.push(...this.#c(e));return this.#n(t)}#n(t){let e=[],s=new Set;for(let r of t){let[n,a,o]=r;e.push([n,a,r],[n,o,r])}e.sort((r,n)=>r[1]-n[1]||r[0]-n[0]);for(let r=0,n=e.length;r<n;r+=2){let a=e[r][2],o=e[r+1][2];a.push(o),o.push(a),s.add(a),s.add(o)}let i=[];while(s.size>0){let r=s.values().next().value,[n,a,o,l,c]=r;s.delete(r);let h=n,d=a,u=[n,o];i.push(u);while(!0){let f;if(s.has(l))f=l;else if(s.has(c))f=c;else break;if(s.delete(f),[n,a,o,l,c]=f,h!==n)u.push(h,d,n,d===a?a:o),h=n;d=d===a?o:a}u.push(h,d)}return new Zs(i,this.#t,this.#e,this.#s)}#a(t){let e=this.#r,s=0,i=e.length-1;while(s<=i){let r=s+i>>1,n=e[r][0];if(n===t)return r;if(n<t)s=r+1;else i=r-1}return i+1}#o([,t,e]){let s=this.#a(t);this.#r.splice(s,0,[t,e])}#l([,t,e]){let s=this.#a(t);for(let i=s;i<this.#r.length;i++){let[r,n]=this.#r[i];if(r!==t)break;if(r===t&&n===e){this.#r.splice(i,1);return}}for(let i=s-1;i>=0;i--){let[r,n]=this.#r[i];if(r!==t)break;if(r===t&&n===e){this.#r.splice(i,1);return}}}#c(t){let[e,s,i]=t,r=[[e,s,i]],n=this.#a(i);for(let a=0;a<n;a++){let[o,l]=this.#r[a];for(let c=0,h=r.length;c<h;c++){let[,d,u]=r[c];if(l<=d||u<=o)continue;if(d>=o){if(u>l)r[c][1]=l;else{if(h===1)return[];r.splice(c,1),c--,h--}continue}if(r[c][2]=o,u>l)r.push([e,l,u])}}return r}}class Zs extends H{#t;#e=null;#s;constructor(t,e,s,i){super();this.#s=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}static build(t,e){let s=new Qs(t,0.001).getOutlines();return s.#e=t,s.focusOutline=new Qs(t,0.0025,0.001,e).getOutlines(),s}get isFree(){return!1}get defaultSVGProperties(){return Bo(this)}getFocusSVGProperties(t){return jo(this,t)}updateRotation(t){return{root:{"data-main-rotation":t}}}serializeQuadPoints([t,e],[s,i]){let r=this.#e,n=new Float32Array(r.length*8),a=0;for(let{x:o,y:l,width:c,height:h}of r){let d=o*s+t,u=(1-l)*i+e;n[a]=n[a+4]=d,n[a+1]=n[a+3]=u,n[a+2]=n[a+6]=d+c*s,n[a+5]=n[a+7]=u-h*i,a+=8}return n}toSVGPath(){let t=[];for(let e of this.#s){let[s,i]=e;t.push(`M${s} ${i}`);for(let r=2;r<e.length;r+=2){let n=e[r],a=e[r+1];if(n===s)t.push(`V${a}`),i=a;else if(a===i)t.push(`H${n}`),s=n}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],r){let n=[],a=s-t,o=i-e;for(let l of this.#s){let c=Array(l.length);for(let h=0;h<l.length;h+=2)c[h]=t+l[h]*a,c[h+1]=i-l[h+1]*o;n.push(c)}return n}get box(){return this.#t}}class Bi extends De{newFreeDrawOutline(t,e,s,i,r,n){return new Gr(t,e,s,i,r,n)}}class Ho{#t;#e;constructor(t,e,s,i,r,n,a){this.#t=new Bi(t,e,s,i,r,n,a),this.#e=r}add(t,e){return this.#t.add(t,e)?{path:{d:this.#t.toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=this.#t.add(t[s],t[s+1])||e;return e?{path:{d:this.#t.toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return this.#t.isEmpty()}isCancellable(){return this.#t.isCancellable()}removeLastElement(){return this.#t.removeLastElement()}updateProperty(t,e){return null}getOutlines(){let t=this.#t.getOutlines();return t.buildFocusOutline(2*this.#e),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:this.#t.toSVGPath()}}}}class Gr extends $r{static#t=1.5;newOutliner(t,e,s,i,r,n,a=0){return new Bi(t,e,s,i,r,n,a)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+Gr.#t,0.0025)}get defaultSVGProperties(){return Bo(this)}getFocusSVGProperties(t){return jo(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;let s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}class zr extends Ni{constructor(t=null){super();super.updateProperties(t)}updateSVGProperty(t,e){if(t!=="thickness")super.updateSVGProperty(t,e)}clone(){let t=new zr;return t.updateAll(this),t}}class ie extends et{#t=null;#e=0;#s=null;#i=0;#r="";#n="";static _DEFAULT_OPACITY=1;static _DEFAULT_THICKNESS=12;static _defaultDrawingOptions=null;static _type="highlight";static _editorType=K.HIGHLIGHT;static get _keyboardManager(){let t=ie.prototype;return L(this,"_keyboardManager",new Xt([[["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"});this.#t=t.anchorNode||null,this.#e=t.anchorOffset||0,this.#s=t.focusNode||null,this.#i=t.focusOffset||0,this.#r=t.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""),this.#n=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static initialize(t,e){U.initialize(t,e),this._defaultDrawingOptions||=new zr({fill:e.highlightColors?.values().next().value||"#fff066","fill-opacity":ie._DEFAULT_OPACITY,thickness:ie._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get typesMap(){return L(this,"typesMap",new Map([[st.HIGHLIGHT_COLOR,"fill"],[st.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(t){let{boxes:e,drawOutlines:s}=t;if(!e&&!s)return;if(this._drawingOptions||=t.drawingOptions||ie.getDefaultDrawingOptions(),e)t={...t,drawOutlines:Zs.build(e,this._uiManager.direction==="ltr")};super._addOutlines(t)}get colorType(){return st.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:this.#r}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}translateInPage(t,e){}get toolbarPosition(){return this.#a(this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return this.#a(this._drawOutlines.firstPoint)}#a([t,e]){let[s,i,r,n]=this._drawOutlines.box;return[(t-s)/r,(e-i)/n]}updateParams(t,e){switch(t){case st.HIGHLIGHT_COLOR:this._updateColorAndOpacity(e,ie._DEFAULT_OPACITY,t),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);break;case st.HIGHLIGHT_THICKNESS:super.updateParams(t,e),this._reportTelemetry({action:"thickness_changed",thickness:e},!0);break}}get propertiesToUpdate(){let t=super.propertiesToUpdate;return t.push([st.HIGHLIGHT_FREE,this._drawOutlines.isFree]),t}get toolbarButtons(){if(this._uiManager.highlightColors)return this._colorPicker=new Qt({editor:this}),[["colorPicker",this._colorPicker]];return super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(t,e){return super.getRect(t,e,this._drawRotation)}onceAdded(t){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(t)this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;let t=super.render();if(this.#n)t.setAttribute("aria-label",this.#n),t.setAttribute("role","mark");if(this._drawOutlines.isFree)t.classList.add("free");else t.addEventListener("keydown",this.#o.bind(this),{signal:this._uiManager._signal});return this.enableEditing(),t}#o(t){ie._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#l(!0);break;case 1:case 3:this.#l(!1);break}}#l(t){if(!this.#t)return;let e=window.getSelection();if(t)e.setPosition(this.#t,this.#e);else e.setPosition(this.#s,this.#i)}unselect(){if(super.unselect(),!this._drawOutlines.isFree)this.#l(!1)}static createDrawerInstance({x:t,y:e,box:s,parent:i,isLTR:r}){return new Ho(t,e,s,i.scale,this._defaultDrawingOptions.thickness/2,r,0.001)}static _getDrawingTarget(t,{target:e}){return e.closest(".textLayer")}static _getPointerCoords({x:t,y:e}){return[t,e]}static _addDrawingListeners(t,e){t.classList.add("free"),e.addEventListener("abort",()=>t.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:e}),window.addEventListener("pointerdown",Tt,{capture:!0,passive:!1,signal:e})}static _endDrawingSession(t=!1){return this.endDrawing(t)}createDrawingOptions({color:t,opacity:e,thickness:s}){let{_defaultDrawingOptions:i,_DEFAULT_OPACITY:r}=ie;this._drawingOptions=ie.getDefaultDrawingOptions({fill:O.makeHexColor(...t),"fill-opacity":e||r,thickness:s||i.thickness})}static deserializeDraw(t,e,s,i,r,n,a){let{quadPoints:o}=n;if(o){let u=[];for(let f=0,p=o.length;f<p;f+=8)u.push({x:(o[f]-t)/s,y:1-(o[f+1]-e)/i,width:(o[f+2]-o[f])/s,height:(o[f+1]-o[f+5])/i});return Zs.build(u,a.direction==="ltr")}let l=n.thickness||this._defaultDrawingOptions.thickness,c=(n.inkLists||n.outlines.points)[0],h=new Bi(c[0]-t,i-(c[1]-e),[0,0,s,i],1,l/2,!0,0.001);for(let u=0,f=c.length;u<f;u+=2)h.add(c[u]-t,i-(c[u+1]-e));let d=h.getOutlines();return d.buildFocusOutline(l),d}static async deserialize(t,e,s){let i=null;if(t instanceof Br){let{data:{quadPoints:n,rect:a,rotation:o,id:l,color:c,opacity:h,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;i=t={annotationType:K.HIGHLIGHT,color:Array.from(c),opacity:h,quadPoints:n,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:u,comment:f?.str||null,creationDate:p,modificationDate:g}}else if(t instanceof Li){let{data:{inkLists:n,rect:a,rotation:o,id:l,color:c,borderStyle:{rawWidth:h},popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;i=t={annotationType:K.HIGHLIGHT,color:Array.from(c),thickness:h,inkLists:n,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:u,comment:f?.str||null,creationDate:p,modificationDate:g}}let r=await super.deserialize(t,e,s);if(r._initialData=i,t.comment)r.setCommentData(t);return r}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=super.serialize(t);if(Object.assign(e,{color:U._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(e.rect,this._drawRotation)}),this.addComment(e),this.annotationElementId&&!this.#c(e))return null;return e.id=this.annotationElementId,e}#c(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class _e{static#t=10;static#e=5.555555555555555;static#s=100;static#i=0.001;#r;#n;#a;constructor(t,e,s){this.#r=[t,e,s],this.#n=this.#a=s}add(t,e,s){let i=this.#r,r=i.at(-1);s=s>r?s:r+_e.#i,i.push(t,e,s);let n=this.#o(s-_e.#t,!0),a=this.#l(this.#a-_e.#t);if(a>=i.length/2)i.copyWithin(0,a),i.length-=a;return n}get pendingPoints(){return this.#o(1/0,!1)}end(){return this.#o(1/0,!0)}#o(t,e){let s=this.#r,i=this.#n,r=s.at(-1),n=[],a=this.#a;for(let o=this.#l(a)+3;o<s.length;o+=3){let l=s[o-1],c=s[o+2]-l,h=Math.min(Math.ceil(c/_e.#e),_e.#s);for(let d=1;d<=h;d++){let u=d===h?s[o+2]:l+c*d/h;if(u<=a)continue;if(u>t)return n;let f=Math.min(_e.#t,u-i,r-u);if(this.#c(u-f,u+f,n),e)this.#a=u}}return n}#l(t){let e=this.#r,s=0,i=e.length/3-1;while(s<i){let r=s+i+1>>1;if(e[3*r+2]<=t)s=r;else i=r-1}return 3*s}#c(t,e,s){let i=this.#r,r=this.#l(t),n=0,a=0,o=0;for(let l=r;l<i.length-3&&i[l+2]<e;l+=3){let c=i[l],h=i[l+1],d=i[l+2],u=i[l+5],f=Math.max(d,t),p=Math.min(u,e);if(p<=f)continue;let g=p-f,m=(f+p-2*d)/(u-d);n+=g*(c+m*(i[l+3]-c)/2),a+=g*(h+m*(i[l+4]-h)/2),o+=g}if(o===0)s.push(i[r],i[r+1]);else s.push(n/o,a/o)}}function me(t,e){return`${H.svgRound(t[e])} ${H.svgRound(t[e+1])}`}function Uo(t,e,s){for(let i=s,r=e.length;i<r;i+=6)t.push(`C${me(e,i)} ${me(e,i+2)} ${me(e,i+4)}`)}function Gs(t){let e=`M${me(t,4)}`;if(t.length===6)return`${e}Z`;if(t.length===12&&isNaN(t[6]))return`${e}L${me(t,10)}`;let s=[e];return Uo(s,t,6),s.join("")}class $o{#t=new Float64Array(6);#e=new Float64Array(2);#s;#i;#r;#n=null;#a;#o;#l=1;#c=new Float64Array(2);#u="";#h=0;#f=new es;#p;#m;constructor(t,e,s,i,r,n,a){this.#p=s,this.#m=i,this.#r=r,this.#a=n,this.#i=[],this.#d(t,e,a)}#d(t,e,s){[t,e]=this.#g(t,e);let i=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#o=[t,e],this.#i.push({line:i,points:this.#o}),this.#t.set(i,0),this.#h=0,this.#l=1,this.#c.set(this.#e),this.#n=s===void 0?null:new _e(t,e,s)}updateProperty(t,e){if(t==="stroke-width")this.#a=e}#g(t,e){return H._normalizePoint(t,e,this.#p,this.#m,this.#r,this.#e)}isEmpty(){return!this.#i?.length}isCancellable(){return this.#l<=5}add(t,e,s){return this.#v(t,e,s),{path:{d:this.#w()}}}addPoints(t,e){for(let s=0,i=t.length;s<i;s+=2)this.#v(t[s],t[s+1],e?.[s/2]);return{path:{d:this.#w()}}}#v(t,e,s){[t,e]=this.#g(t,e);let[i,r]=this.#c;if(!this.#y(t,e,i,r))this.#l++,this.#c.set(this.#e);if(this.#n)this.#b(this.#n.add(t,e,s));else this.#_(t,e)}#y(t,e,s,i){return Math.hypot(this.#p*(t-s),this.#m*(e-i))<=2}#b(t){for(let e=0,s=t.length;e<s;e+=2)this.#_(t[e],t[e+1])}#_(t,e){let[,,s,i,r,n]=this.#t;if(this.#y(t,e,r,n))return;if(this.#o.push(t,e),isNaN(s))this.#s.push(NaN,NaN,NaN,NaN,t,e);else{if(isNaN(this.#t[0]))this.#s.splice(6,6);H.createBezierPoints(s,i,r,n,t,e,this.#s)}this.#t.copyWithin(0,2),this.#t[4]=t,this.#t[5]=e}#A(){let t=this.#s;if(this.#o.length<6||this.#h===t.length)return;let e=[this.#u];if(this.#h===0)e.push(`M${me(t,4)}`),this.#h=6;Uo(e,t,this.#h),this.#u=e.join(""),this.#h=t.length}#S(){if(!this.#s)return;if(this.#n)this.#b(this.#n.end()),this.#n=null;if(this.#o.length<6)this.#u+=Gs(this.#s);else{let[,,t,e,s,i]=this.#t;H.createBezierPoints(t,e,s,i,s,i,this.#s),this.#A()}this.#s=this.#o=null}end(t,e,s){if(this.#s&&t!==void 0)this.#v(t,e,s);return this.#S(),{path:{d:this.#u}}}startNew(t,e,s,i,r,n){this.#p=s,this.#m=i,this.#r=r;let a=this.#i.at(-1);if(a)a.line=new Float32Array(a.line),a.points=new Float32Array(a.points);return this.#d(t,e,n),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){if(!this.#i)return this.#f.setLastElement(t);return this.#i.push(t),this.#u+=Gs(t.line),{path:{d:this.#u}}}removeLastElement(){if(!this.#i)return this.#f.removeLastElement();return this.#s=this.#o=this.#n=null,this.#i.pop(),this.#u=this.#i.map(({line:t})=>Gs(t)).join(""),{path:{d:this.#u}}}#w(){this.#A();let t=[this.#u];if(this.#h===0){if(t.push(`M${me(this.#s,4)}`),this.#o.length===4)t.push(`L${me(this.#s,10)}`)}let e=this.#n?.pendingPoints;if(!e?.length)e=this.#e;for(let s=0,i=e.length;s<i;s+=2)t.push(`L${me(e,s)}`);return t.join("")}getOutlines(t,e,s,i){this.#S();let r=this.#i.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#f.build(this.#i,t,e,s,this.#r,this.#a,i),this.#t=null,this.#s=null,this.#i=null,this.#u=null,this.#f}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class es extends H{#t;#e=0;#s;#i;#r;#n;#a;#o;#l;build(t,e,s,i,r,n,a){this.#r=e,this.#n=s,this.#a=i,this.#o=r,this.#l=n,this.#s=a??0,this.#i=t,this.#h()}get thickness(){return this.#l}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){return this.#i.map(({line:t})=>Gs(t)).join("")}serialize([t,e,s,i],r){let n=[],a=[],[o,l,c,h]=this.#u(),d,u,f,p,g,m,v,y,b;switch(this.#o){case 0:b=H._rescale,d=t,u=e+i,f=s,p=-i,g=t+o*s,m=e+(1-l-h)*i,v=t+(o+c)*s,y=e+(1-l)*i;break;case 90:b=H._rescaleAndSwap,d=t,u=e,f=s,p=i,g=t+l*s,m=e+o*i,v=t+(l+h)*s,y=e+(o+c)*i;break;case 180:b=H._rescale,d=t+s,u=e,f=-s,p=i,g=t+(1-o-c)*s,m=e+l*i,v=t+(1-o)*s,y=e+(l+h)*i;break;case 270:b=H._rescaleAndSwap,d=t+s,u=e+i,f=-s,p=-i,g=t+(1-l-h)*s,m=e+(1-o-c)*i,v=t+(1-l)*s,y=e+(1-o)*i;break}for(let{line:_,points:w}of this.#i)n.push(b(_,d,u,f,p,r?Array(_.length):null)),a.push(b(w,d,u,f,p,r?Array(w.length):null));return{lines:n,points:a,rect:[g,m,v,y]}}static deserialize(t,e,s,i,r,{paths:{lines:n,points:a},rotation:o,thickness:l}){let c=[],h,d,u,f,p;switch(o){case 0:p=H._rescale,h=-t/s,d=e/i+1,u=1/s,f=-1/i;break;case 90:p=H._rescaleAndSwap,h=-e/i,d=-t/s,u=1/i,f=1/s;break;case 180:p=H._rescale,h=t/s+1,d=-e/i,u=-1/s,f=1/i;break;case 270:p=H._rescaleAndSwap,h=e/i+1,d=t/s+1,u=-1/i,f=-1/s;break}if(!n){n=[];for(let m of a){let v=m.length;if(v===2){n.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(v===4){n.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}let y=new Float32Array(3*v);n.push(y);let[b,_,w,A]=m.subarray(0,4);y.set([NaN,NaN,NaN,NaN,b,_],0);for(let x=4;x<=v;x+=2){let E=Math.min(x,v-2),T=m[E],k=m[E+1];y.set(H.createBezierPoints(b,_,w,A,T,k),(x-2)*3),[b,_,w,A]=[w,A,T,k]}}}for(let m=0,v=n.length;m<v;m++)c.push({line:p(n[m].map((y)=>y??NaN),h,d,u,f),points:p(a[m].map((y)=>y??NaN),h,d,u,f)});let g=new this.prototype.constructor;return g.build(c,s,i,1,o,l,r),g}#c(t=this.#l){let e=this.#s+t/2*this.#a;return this.#o%180===0?[e/this.#r,e/this.#n]:[e/this.#n,e/this.#r]}#u(){let[t,e,s,i]=this.#t,[r,n]=this.#c(0);return[t+r,e+n,s-2*r,i-2*n]}#h(){let t=this.#t=Re.slice();for(let{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)O.pointBoundingBox(i[a],i[a+1],t);continue}let r=i[4],n=i[5];for(let a=6,o=i.length;a<o;a+=6){let[l,c,h,d,u,f]=i.subarray(a,a+6);O.bezierBoundingBox(r,n,l,c,h,d,u,f,t),r=u,n=f}}let[e,s]=this.#c();t[0]=pt(t[0]-e,0,1),t[1]=pt(t[1]-s,0,1),t[2]=pt(t[2]+e,0,1),t[3]=pt(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,s]=this.#c();this.#l=t;let[i,r]=this.#c(),[n,a]=[i-e,r-s],o=this.#t;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],s){let[i,r]=this.#c();this.#r=t,this.#n=e,this.#a=s;let[n,a]=this.#c(),o=n-i,l=a-r,c=this.#t;return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(H.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,s=0,i=0,r=0,n=0,a=0,o=0;switch(this.#e){case 90:i=e/t,r=-t/e,a=t;break;case 180:s=-1,n=-1,a=t,o=e;break;case 270:i=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${r} ${n} ${H.svgRound(a)} ${H.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){let[r,n]=this.#c(),[a,o,l,c]=this.#t;if(Math.abs(l-r)<=H.PRECISION||Math.abs(c-n)<=H.PRECISION){let p=t+s/2-(a+l/2),g=e+i/2-(o+c/2);return{path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`,transform:`${this.rotationTransform} translate(${p} ${g})`}}}let h=(s-2*r)/(l-2*r),d=(i-2*n)/(c-2*n),u=l/s,f=c/i;return{path:{"transform-origin":`${H.svgRound(a)} ${H.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${f}) translate(${H.svgRound(r)} ${H.svgRound(n)}) scale(${h} ${d}) translate(${H.svgRound(-r)} ${H.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,s,i]){let[r,n]=this.#c(),a=this.#t,[o,l,c,h]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(c-r)<=H.PRECISION||Math.abs(h-n)<=H.PRECISION){let g=t+s/2-(o+c/2),m=e+i/2-(l+h/2);for(let{line:v,points:y}of this.#i)H._translate(v,g,m,v),H._translate(y,g,m,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(s-2*r)/(c-2*r),u=(i-2*n)/(h-2*n),f=-d*(o+r)+t+r,p=-u*(l+n)+e+n;if(d!==1||u!==1||f!==0||p!==0)for(let{line:g,points:m}of this.#i)H._rescale(g,f,p,d,u,g),H._rescale(m,f,p,d,u,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){let[i,r]=s,n=this.#t,a=t-n[0],o=e-n[1];if(this.#r===i&&this.#n===r)for(let{line:l,points:c}of this.#i)H._translate(l,a,o,l),H._translate(c,a,o,c);else{let l=this.#r/i,c=this.#n/r;this.#r=i,this.#n=r;for(let{line:h,points:d}of this.#i)H._rescale(h,a,o,l,c,h),H._rescale(d,a,o,l,c,d);n[2]*=l,n[3]*=c}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${H.svgRound(t[0])} ${H.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class ji extends Ni{constructor(t){super();this._viewParameters=t,super.updateProperties({fill:"none",stroke:U._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 ji(this._viewParameters);return t.updateAll(this),t}}class Vr extends et{static _type="ink";static _editorType=K.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){U.initialize(t,e),this._defaultDrawingOptions=new ji(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return L(this,"typesMap",new Map([[st.INK_THICKNESS,"stroke-width"],[st.INK_COLOR,"stroke"],[st.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:t,y:e,box:[,,s,i],rotation:r,timeStamp:n}){return new $o(t,e,s,i,r,this._defaultDrawingOptions["stroke-width"],n)}static deserializeDraw(t,e,s,i,r,n){return es.deserialize(t,e,s,i,r,n)}static async deserialize(t,e,s){let i=null;if(t instanceof Li){let{data:{inkLists:n,rect:a,rotation:o,id:l,color:c,opacity:h,borderStyle:{rawWidth:d},popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;i=t={annotationType:K.INK,color:Array.from(c),thickness:d,opacity:h,paths:{points:n},boxes:null,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}let r=await super.deserialize(t,e,s);if(r._initialData=i,t.comment)r.setCommentData(t);return r}get toolbarButtons(){return this._colorPicker||=new bs(this),[["colorPicker",this._colorPicker]]}get colorType(){return st.INK_COLOR}get colorAndOpacityType(){return st.INK_COLOR_AND_OPACITY}get opacityType(){return st.INK_OPACITY}updateParams(t,e){if(t===st.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===st.INK_COLOR_AND_OPACITY){super.updateDefaultParams(st.INK_COLOR,e.color),super.updateDefaultParams(st.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:s}=this;e.updateSVGProperty("stroke-width"),s.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:s}){this._drawingOptions=Vr.getDefaultDrawingOptions({stroke:O.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":r,"stroke-width":n}}=this,a=Object.assign(super.serialize(t),{color:U._colorManager.convert(i),opacity:r,thickness:n,paths:{lines:e,points:s}});if(this.addComment(a),t)return a.isCopy=!0,a;if(this.annotationElementId&&!this.#t(a))return null;return a.id=this.annotationElementId,a}#t(t){let{color:e,thickness:s,opacity:i,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((n,a)=>n!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class ti extends es{toSVGPath(){let t=super.toSVGPath();if(!t.endsWith("Z"))t+="Z";return t}}Oc();var Ls=8,ls=3;class Oe{static#t={maxDim:512,sigmaSFactor:0.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){if(s-=t,i-=e,s===0)return i>0?0:4;return s===1?i+6:2-i}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,s,i,r,n,a){let o=this.#e(s,i,r,n);for(let l=0;l<8;l++){let c=(-l+o-a+16)%8,h=this.#s[2*c],d=this.#s[2*c+1];if(t[(s+h)*e+(i+d)]!==0)return c}return-1}static#r(t,e,s,i,r,n,a){let o=this.#e(s,i,r,n);for(let l=0;l<8;l++){let c=(l+o+a+16)%8,h=this.#s[2*c],d=this.#s[2*c+1];if(t[(s+h)*e+(i+d)]!==0)return c}return-1}static#n(t,e,s,i){let r=t.length,n=new Int32Array(r);for(let c=0;c<r;c++)n[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)n[c*e]=n[c*e+e-1]=0;for(let c=0;c<e;c++)n[c]=n[e*s-1-c]=0;let a=1,o,l=[];for(let c=1;c<s-1;c++){o=1;for(let h=1;h<e-1;h++){let d=c*e+h,u=n[d];if(u===0)continue;let f=c,p=h;if(u===1&&n[d-1]===0)a+=1,p-=1;else if(u>=1&&n[d+1]===0){if(a+=1,p+=1,u>1)o=u}else{if(u!==1)o=Math.abs(u);continue}let g=[h,c],m=p===h+1,v={isHole:m,points:g,id:a,parent:0};l.push(v);let y;for(let k of l)if(k.id===o){y=k;break}if(!y)v.parent=m?o:0;else if(y.isHole)v.parent=m?y.parent:o;else v.parent=m?o:y.parent;let b=this.#i(n,e,c,h,f,p,0);if(b===-1){if(n[d]=-a,n[d]!==1)o=Math.abs(n[d]);continue}let _=this.#s[2*b],w=this.#s[2*b+1],A=c+_,x=h+w;f=A,p=x;let E=c,T=h;while(!0){let k=this.#r(n,e,E,T,f,p,1);_=this.#s[2*k],w=this.#s[2*k+1];let C=E+_,R=T+w;g.push(R,C);let B=E*e+T;if(n[B+1]===0)n[B]=-a;else if(n[B]===1)n[B]=a;if(C===c&&R===h&&E===A&&T===x){if(n[d]!==1)o=Math.abs(n[d]);break}else f=E,p=T,E=C,T=R}}}return l}static#a(t,e,s,i){if(s-e<=4){for(let A=e;A<s-2;A+=2)i.push(t[A],t[A+1]);return}let r=t[e],n=t[e+1],a=t[s-4]-r,o=t[s-3]-n,l=Math.hypot(a,o),c=a/l,h=o/l,d=c*n-h*r,u=o/a,f=1/l,p=Math.atan(u),g=Math.cos(p),m=Math.sin(p),v=f*(Math.abs(g)+Math.abs(m)),y=f*(1-v+v**2),b=Math.max(Math.atan(Math.abs(m+g)*y),Math.atan(Math.abs(m-g)*y)),_=0,w=e;for(let A=e+2;A<s-2;A+=2){let x=Math.abs(d-c*t[A+1]+h*t[A]);if(x>_)w=A,_=x}if(_>(l*b)**2)this.#a(t,e,w+2,i),this.#a(t,w,s,i);else i.push(r,n)}static#o(t){let e=[],s=t.length;return this.#a(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#l(t,e,s,i,r,n){let a=new Float32Array(n**2),o=-2*i**2,l=n>>1;for(let p=0;p<n;p++){let g=(p-l)**2;for(let m=0;m<n;m++)a[p*n+m]=Math.exp((g+(m-l)**2)/o)}let c=new Float32Array(256),h=-2*r**2;for(let p=0;p<256;p++)c[p]=Math.exp(p**2/h);let d=t.length,u=new Uint8Array(d),f=new Uint32Array(256);for(let p=0;p<s;p++)for(let g=0;g<e;g++){let m=p*e+g,v=t[m],y=0,b=0;for(let w=0;w<n;w++){let A=p+w-l;if(A<0||A>=s)continue;for(let x=0;x<n;x++){let E=g+x-l;if(E<0||E>=e)continue;let T=t[A*e+E],k=a[w*n+x]*c[Math.abs(T-v)];y+=T*k,b+=k}}let _=u[m]=Math.round(y/b);f[_]++}return[u,f]}static#c(t){let e=new Uint32Array(256);for(let s of t)e[s]++;return e}static#u(t){let e=t.length,s=new Uint8ClampedArray(e>>2),i=-1/0,r=1/0;for(let a=0,o=s.length;a<o;a++){let l=s[a]=t[a<<2];i=Math.max(i,l),r=Math.min(r,l)}let n=255/(i-r);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-r)*n;return s}static#h(t){let e,s=-1/0,i=-1/0,r=t.findIndex((o)=>o!==0),n=r,a=r;for(e=r;e<256;e++){let o=t[e];if(o>s){if(e-n>i)i=e-n,a=e-1;s=o,n=e}}for(e=a-1;e>=0;e--)if(t[e]>t[e+1])break;return e}static#f(t){let e=t,{width:s,height:i}=t,{maxDim:r}=this.#t,n=s,a=i;if(s>r||i>r){let d=s,u=i,f=Math.log2(Math.max(s,i)/r),p=Math.floor(f);f=f===p?p-1:p;for(let m=0;m<f;m++){n=Math.ceil(d/2),a=Math.ceil(u/2);let v=new OffscreenCanvas(n,a);if(v.getContext("2d").drawImage(t,0,0,d,u,0,0,n,a),d=n,u=a,t!==e)t.close();t=v.transferToImageBitmap()}let g=Math.min(r/n,r/a);n=Math.round(n*g),a=Math.round(a*g)}let l=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,n,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,n,a);let c=l.getImageData(0,0,n,a).data;return[this.#u(c),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,n,a,o){let l=new OffscreenCanvas(1,1),c=l.getContext("2d",{alpha:!1}),h=200,d=c.font=`${s} ${i} ${h}px ${e}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:v,width:y}=c.measureText(t),b=1.5,_=Math.ceil(Math.max(Math.abs(u)+Math.abs(f)||0,y)*b),w=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||h,Math.abs(m)+Math.abs(v)||h)*b);l=new OffscreenCanvas(_,w),c=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=d,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,_,w),c.fillStyle="black",c.fillText(t,_*(b-1)/2,w*(3-b)/2);let A=this.#u(c.getImageData(0,0,_,w).data),x=this.#c(A),E=this.#h(x),T=this.#n(A,_,w,E);return this.processDrawnLines({lines:{curves:T,width:_,height:w},pageWidth:r,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){let[n,a,o]=this.#f(t),[l,c]=this.#l(n,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),h=this.#h(c),d=this.#n(l,a,o,h);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:n,areContours:a}){if(i%180!==0)[e,s]=[s,e];let{curves:o,width:l,height:c}=t,h=t.thickness??0,d=[],u=Math.min(e/l,s/c),f=u/e,p=u/s,g=[];for(let{points:v}of o){let y=n?this.#o(v):v;if(!y)continue;g.push(y);let b=y.length,_=new Float32Array(b),w=new Float32Array(3*(b===2?2:b-2));if(d.push({line:w,points:_}),b===2){_[0]=y[0]*f,_[1]=y[1]*p,w.set([NaN,NaN,NaN,NaN,_[0],_[1]],0);continue}let[A,x,E,T]=y;A*=f,x*=p,E*=f,T*=p,_.set([A,x,E,T],0),w.set([NaN,NaN,NaN,NaN,A,x],0);for(let k=4;k<b;k+=2){let C=_[k]=y[k]*f,R=_[k+1]=y[k+1]*p;w.set(H.createBezierPoints(A,x,E,T,C,R),(k-2)*3),[A,x,E,T]=[E,T,C,R]}}if(d.length===0)return null;let m=a?new ti:new es;return m.build(d,e,s,1,i,a?0:h,r),{outline:m,newCurves:g,areContours:a,thickness:h,width:l,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let n=1/0,a=-1/0,o=0;for(let v of t){o+=v.length;for(let y=2,b=v.length;y<b;y++){let _=v[y]-v[y-2];n=Math.min(n,_),a=Math.max(a,_)}}let l;if(n>=-128&&a<=127)l=Int8Array;else if(n>=-32768&&a<=32767)l=Int16Array;else l=Int32Array;let c=t.length,h=Ls+ls*c,d=new Uint32Array(h),u=0;d[u++]=h*Uint32Array.BYTES_PER_ELEMENT+(o-2*c)*l.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=i,d[u++]=r,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(s??0)),d[u++]=c,d[u++]=l.BYTES_PER_ELEMENT;for(let v of t)d[u++]=v.length-2,d[u++]=v[0],d[u++]=v[1];let f=new CompressionStream("deflate-raw"),p=f.writable.getWriter();await p.ready,p.write(d);let g=l.prototype.constructor;for(let v of t){let y=new g(v.length-2);for(let b=2,_=v.length;b<_;b++)y[b-2]=v[b]-v[b-2];p.write(y)}return p.close(),(await new Response(f.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let n=null,a=0;for await(let y of s)n||=new Uint8Array(new Uint32Array(y.buffer,0,4)[0]),n.set(y,a),a+=y.length;let o=new Uint32Array(n.buffer,0,n.length>>2),l=o[1];if(l!==0)throw Error(`Invalid version: ${l}`);let c=o[2],h=o[3],d=o[4]===0,u=o[5],f=o[6],p=o[7],g=[],m=(Ls+ls*f)*Uint32Array.BYTES_PER_ELEMENT,v;switch(p){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(n.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(n.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(n.buffer,m);break}a=0;for(let y=0;y<f;y++){let b=o[ls*y+Ls],_=new Float32Array(b+2);g.push(_);for(let w=0;w<ls-1;w++)_[w]=o[ls*y+Ls+w+1];for(let w=0;w<b;w++)_[w+2]=_[w]+v[a++]}return{areContours:d,thickness:u,outlines:g,width:c,height:h}}catch(e){return W(`decompressSignature: ${e}`),null}}}class Wr extends Ni{constructor(){super();super.updateProperties({fill:U._defaultLineColor,"stroke-width":0})}clone(){let t=new Wr;return t.updateAll(this),t}}class Xr extends ji{constructor(t){super(t);super.updateProperties({stroke:U._defaultLineColor,"stroke-width":1})}clone(){let t=new Xr(this._viewParameters);return t.updateAll(this),t}}class oe extends et{#t=!1;#e=null;#s=null;#i=null;#r=!1;static _type="signature";static _editorType=K.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"});this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){U.initialize(t,e),this._defaultDrawingOptions=new Wr,this._defaultDrawnSignatureOptions=new Xr(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return L(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}onceAdded(t){this.#r=this._drawId===null,super.onceAdded(t)}onScaleChanging(){if(this._drawId===null)return;super.onScaleChanging()}render(){if(this.div)return this.div;let t,e,{_isCopy:s}=this;if(s)this._isCopy=!1,t=this.x,e=this.y;if(super.render(),this._drawId===null)if(this.#s){let{lines:i,mustSmooth:r,areContours:n,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:c,pageHeight:h},rotation:d}=this.parent.viewport,u=Oe.processDrawnLines({lines:i,pageWidth:c,pageHeight:h,rotation:d,innerMargin:oe._INNER_MARGIN,mustSmooth:r,areContours:n});this.addSignature(u,l,a,o)}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(s)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:s,width:i,height:r}=this.#s,n=Math.max(i,r),a=Oe.processDrawnLines({lines:{curves:t.map((o)=>({points:o})),thickness:s,width:i,height:r},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){let{x:r,y:n}=this,{outline:a}=this.#s=t;this.#t=a instanceof ti,this.description=s;let o;if(this.#t)o=oe.getDefaultDrawingOptions();else o=oe._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness});this._addOutlines({drawOutlines:a,drawingOptions:o});let[,l]=this.pageDimensions,c=e/l;if(c=c>=1?0.5:c,this.width*=c/this.height,this.width>=1)c*=0.9/this.width,this.width=0.9;if(this.height=c,this.setDims(),this.x=r,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:!!s}}),this.div.hidden=!1,this.#r)this.#r=!1,this.parent.addUndoableEditor(this)}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Oe.process(t,e,s,i,oe._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Oe.extractContoursFromText(t,e,s,i,r,oe._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Oe.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:oe._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){if(t)this._drawingOptions=oe.getDefaultDrawingOptions();else this._drawingOptions=oe._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e})}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});if(this.addComment(r),t)r.paths={lines:e,points:s},r.uuid=this.#i,r.isCopy=!0;else r.lines=e;if(this.#e)r.accessibilityData={type:"Figure",alt:this.#e};return r}static deserializeDraw(t,e,s,i,r,n){if(n.areContours)return ti.deserialize(t,e,s,i,r,n);return es.deserialize(t,e,s,i,r,n)}static async deserialize(t,e,s){let i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class Go extends U{#t=null;#e=null;#s=null;#i=null;#r=null;#n="";#a=null;#o=!1;#l=null;#c=!1;#u=!1;static _type="stamp";static _editorType=K.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#i=t.bitmapUrl,this.#r=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){U.initialize(t,e)}static isHandlingMimeForPasting(t){return Zi.has(t)}static paste(t,e){e.pasteEditor({mode:K.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}}#h(t,e=!1){if(!t){this.remove();return}if(this.#t=t.bitmap,!e)this.#e=t.id,this.#c=t.isSvg;if(t.file)this.#n=t.file.name;this.#m()}#f(){if(this.#s=null,this._uiManager.enableWaiting(!1),!this.#a)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:s}=this._uiManager;if(!s)throw Error("No ML.");if(!await s.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:i,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:r,height:n,channels:i.length/(r*n)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;if(await this.setGuessedAltText(o),e&&!this.hasAltTextData())this.altTextData={alt:o,decorative:!1};return o}#p(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then((s)=>this.#h(s,!0)).finally(()=>this.#f());return}if(this.#i){let s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then((i)=>this.#h(i)).finally(()=>this.#f());return}if(this.#r){let s=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then((i)=>this.#h(i)).finally(()=>this.#f());return}let t=document.createElement("input");t.type="file",t.accept=Zi.keys().join(",");let e=this._uiManager._signal;this.#s=new Promise((s)=>{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.#h(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){if(this.#e){if(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#l)clearTimeout(this.#l),this.#l=null}super.remove()}rebuild(){if(!this.parent){if(this.#e)this.#p();return}if(super.rebuild(),this.div===null)return;if(this.#e&&this.#a===null)this.#p();if(!this.isAttachedToDOM)this.parent.add(this)}onceAdded(t){if(this._isDraggable=!0,t)this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#r||this.#e||this.#o)}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.#o)if(this.#t)this.#m();else this.#p();if(this._isCopy)this._moveAfterPaste(t,e);return this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){let{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);if(e.remove(),s&&this._uiManager.imageManager.isValidId(s)){if(this.#e=s,i)this.#t=i;this.#o=!1,this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;if(this.#l!==null)clearTimeout(this.#l);let t=200;this.#l=setTimeout(()=>{this.#l=null,this.#g()},t)}#m(){let{div:t}=this,{width:e,height:s}=this.#t,[i,r]=this.pageDimensions,n=0.75;if(this.width)e=this.width*i,s=this.height*r;else if(e>0.75*i||s>0.75*r){let o=Math.min(0.75*i/e,0.75*r/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);let a=this.#a=document.createElement("canvas");if(a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/r,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.#g(),!this.#u)this.parent.addUndoableEditor(this),this.#u=!0;if(this._reportTelemetry({action:"inserted_image"}),this.#n)this.div.setAttribute("aria-description",this.#n);if(!this.annotationElementId)this._uiManager.a11yAlert(U._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;let{width:i,height:r}=this.#t,n=new Kt,a=this.#t,o=i,l=r,c=null;if(e){if(i>e||r>e){let w=Math.min(e/i,e/r);o=Math.floor(i*w),l=Math.floor(r*w)}c=document.createElement("canvas");let d=c.width=Math.ceil(o*n.sx),u=c.height=Math.ceil(l*n.sy);if(!this.#c)a=this.#d(d,u);let f=c.getContext("2d");f.filter=this._uiManager.hcmFilter;let p="white",g="#cfcfd8";if(this._uiManager.hcmFilter!=="none")g="black";else if(ca.isDarkMode)p="#8f8f9d",g="#42414d";let m=15,v=m*n.sx,y=m*n.sy,b=new OffscreenCanvas(v*2,y*2),_=b.getContext("2d");_.fillStyle=p,_.fillRect(0,0,v*2,y*2),_.fillStyle=g,_.fillRect(0,0,v,y),_.fillRect(v,y,v,y),f.fillStyle=f.createPattern(b,"repeat"),f.fillRect(0,0,d,u),f.drawImage(a,0,0,a.width,a.height,0,0,d,u)}let h=null;if(s){let d,u;if(n.symmetric&&a.width<t&&a.height<t)d=a.width,u=a.height;else if(a=this.#t,i>t||r>t){let g=Math.min(t/i,t/r);if(d=Math.floor(i*g),u=Math.floor(r*g),!this.#c)a=this.#d(d,u)}let p=new OffscreenCanvas(d,u).getContext("2d",{willReadFrequently:!0});p.drawImage(a,0,0,a.width,a.height,0,0,d,u),h={width:d,height:u,data:p.getImageData(0,0,d,u).data}}return{canvas:c,width:o,height:l,imageData:h}}#d(t,e){let{width:s,height:i}=this.#t,r=s,n=i,a=this.#t;while(r>2*t||n>2*e){let o=r,l=n;if(r>2*t)r=Math.ceil(r/2);if(n>2*e)n=Math.ceil(n/2);let c=new OffscreenCanvas(r,n);c.getContext("2d").drawImage(a,0,0,o,l,0,0,r,n),a=c.transferToImageBitmap()}return a}#g(){let[t,e]=this.parentDimensions,{width:s,height:i}=this,r=new Kt,n=Math.ceil(s*t*r.sx),a=Math.ceil(i*e*r.sy),o=this.#a;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;let l=this.#c?this.#t:this.#d(n,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,n,a)}#v(t){if(t){if(this.#c){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.#c){let[e,s]=this.pageDimensions,i=Math.round(this.width*e*Le.PDF_TO_CSS_UNITS),r=Math.round(this.height*s*Le.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,r);return n.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,r),n.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,r=!1;if(t instanceof jr){let{data:{rect:p,rotation:g,id:m,structParent:v,popupRef:y,richText:b,contentsObj:_,creationDate:w,modificationDate:A},container:x,parent:{page:{pageNumber:E}},canvas:T}=t,k,C;if(T)delete t.canvas,{id:k,bitmap:C}=s.imageManager.getFromCanvas(x.id,T),T.remove();else r=!0,t._hasNoCanvas=!0;let R=(await e._structTree.getAriaAttributes(`${Ye}${m}`))?.get("aria-label")||"";i=t={annotationType:K.STAMP,bitmapId:k,bitmap:C,pageIndex:E-1,rect:p.slice(0),rotation:g,annotationElementId:m,id:m,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:v,popupRef:y,richText:b,comment:_?.str||null,creationDate:w,modificationDate:A}}let n=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:c,isSvg:h,accessibilityData:d}=t;if(r)s.addMissingCanvas(t.id,n),n.#o=!0;else if(c&&s.imageManager.isValidId(c)){if(n.#e=c,o)n.#t=o}else n.#i=l;n.#c=h;let[u,f]=n.pageDimensions;if(n.width=(a[2]-a[0])/u,n.height=(a[3]-a[1])/f,d)n.altTextData=d;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 s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#c});if(this.addComment(s),t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;let{decorative:i,altText:r}=this.serializeAltText(!1);if(!i&&r)s.accessibilityData={type:"Figure",alt:r};if(this.annotationElementId){let a=this.#y(s);if(a.isSame)return null;if(a.isSameAltText)delete s.accessibilityData;else{let o=this._initialData.structParent??-1;if(s.accessibilityData)s.accessibilityData.structParent=o;else if(o>=0)s.accessibilityData={type:"Figure",alt:"",structParent:o}}return s.id=this.annotationElementId,delete s.bitmapId,s}if(e===null)return s;e.stamps||=new Map;let n=this.#c?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:n,serialized:s}),s.bitmap=this.#v(!1);else if(this.#c){let a=e.stamps.get(this.#e);if(n>a.area)a.area=n,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1)}return s}#y(t){let{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&r,isSameAltText:r}}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class fe{#t;#e=!1;#s=null;#i=null;#r=null;#n=new Map;#a=!1;#o=!1;#l=!1;#c=null;#u=null;#h=null;#f=null;#p=null;#m=-1;#d;static _initialized=!1;static#g=new Map([Pt,Vr,Go,ie,oe].map((t)=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:c}){let h=[...fe.#g.values()];if(!fe._initialized){fe._initialized=!0;for(let d of h)d.initialize(c,t)}t.registerEditorTypes(h),this.#d=t,this.pageIndex=e,this.div=s,this.#t=r,this.#s=n,this.viewport=l,this.#h=o,this.drawLayer=a,this._structTree=i,this.#d.addLayer(this)}get isEmpty(){return this.#n.size===0}get isInvisible(){return this.isEmpty&&this.#d.getMode()===K.NONE}updateToolbar(t){this.#d.updateToolbar(t)}updateMode(t=this.#d.getMode()){switch(this.#S(),t){case K.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case K.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case K.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===K.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(let s of fe.#g.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#d.setEditingState(t)}addCommands(t){this.#d.addCommands(t)}cleanUndoStack(t){this.#d.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#v(){return this.#n.size!==0?this.#n.values():this.#d.getEditors(this.pageIndex)}async enable(){this.#l=!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 s of this.#v)if(s.enableEditing(),s.show(!0),s.annotationElementId)this.#d.removeChangedExistingAnnotation(s),t.add(s.annotationElementId);let e=this.#s;if(e)for(let s of e.getEditableAnnotations()){if(s.hide(),this.#d.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;let i=await this.deserialize(s);if(!i)continue;this.addOrRebuild(i),i.enableEditing()}this.#l=!1,this.#d._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#h&&!this.#p){this.#p=new AbortController;let i=this.#d.combinedSignal(this.#p);this.#h.div.addEventListener("pointerdown",(r)=>{let{clientX:a,clientY:o,timeStamp:l}=r,c=this.#m;if(l-c>500){this.#m=l;return}this.#m=-1;let{classList:h}=this.div;h.toggle("getElements",!0);let d=document.elementsFromPoint(a,o);if(h.toggle("getElements",!1),!this.div.contains(d[0]))return;let u,f=new RegExp(`^${qe}[0-9]+$`);for(let g of d)if(f.test(g.id)){u=g.id;break}if(!u)return;let p=this.#n.get(u);if(p?.annotationElementId===null)Tt(r),p.dblclick(r)},{signal:i,capture:!0})}let t=this.#s,e=[];if(t){let i=new Map,r=new Map;for(let n of this.#v){if(n.disableEditing(),!n.annotationElementId){e.push(n);continue}if(n.serialize()!==null){i.set(n.annotationElementId,n);continue}else r.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}for(let n of t.getEditableAnnotations()){let{id:a}=n.data;if(this.#d.isDeletedAnnotationElement(a)){n.updateEdited({deleted:!0});continue}let o=r.get(a);if(o){o.resetAnnotationElement(n),o.show(!1),n.show();continue}if(o=i.get(a),o){if(this.#d.addChangedExistingAnnotation(o),o.renderAnnotationElement(n))o.show(!1)}n.show()}}if(this.#S(),this.isEmpty)this.div.hidden=!0;let{classList:s}=this.div;for(let i of fe.#g.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){if(this.#d.getActive()===t)return;this.#d.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;let t=this.#d.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){if(this.div.tabIndex=0,this.#h?.div&&this.#f)this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting")}#y(t){this.#d.unselectAll();let{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#h.div.contains(e)){let{isMac:s}=lt.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#d.showAllEditors("highlight",!0,!0),ie.startDrawing(this,this.#d,this.#d.direction==="ltr",t),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;let t=this.#d.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.#n.set(t.id,t);let{annotationElementId:e}=t;if(e&&this.#d.isDeletedAnnotationElement(e))this.#d.removeDeletedAnnotationElement(t)}detach(t){if(this.#n.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId)this.#d.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#d.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){if(t.parent===this)return;if(t.parent&&t.annotationElementId)this.#d.addDeletedAnnotationElement(t),U.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.#d.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#l),this.#d.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;if(t.div.contains(e)&&!this.#r)t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{if(this.#r=null,!t.div.contains(document.activeElement))t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#d._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),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(let e of this.#n.values())if(e.uid===t)return e;return null}get#b(){return fe.#g.get(this.#d.getMode())}combinedSignal(t){return this.#d.combinedSignal(t)}#_(t){let e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#d.updateMode(t.mode);let{offsetX:s,offsetY:i}=this.#A(),r=this.#d.getId(),n=this.#_({parent:this,id:r,x:s,y:i,uiManager:this.#d,isCentered:!0,...e});if(n)this.add(n)}async deserialize(t){return await fe.#g.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#d)||null}createAndAddNewEditor(t,e,s={}){let i=this.#d.getId(),r=this.#_({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#d,isCentered:e,...s});if(r)this.add(r);return r}get boundingClientRect(){return this.div.getBoundingClientRect()}#A(){let{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),n=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(r+a)/2-t,c=(n+o)/2-e,[h,d]=this.viewport.rotation%180===0?[l,c]:[c,l];return{offsetX:h,offsetY:d}}addNewEditor(t={}){this.createAndAddNewEditor(this.#A(),!0,t)}setSelected(t){this.#d.setSelected(t)}toggleSelected(t){this.#d.toggleSelected(t)}unselect(t){this.#d.unselect(t)}pointerup(t){let{isMac:e}=lt.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#a)return;if(this.#a=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings)return;if(!this.#e){this.#e=!0;return}let s=this.#d.getMode();if(s===K.STAMP||s===K.POPUP||s===K.SIGNATURE){this.#d.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#d.getMode()===K.HIGHLIGHT)this.enableTextSelection();if(this.#a){this.#a=!1;return}let{isMac:e}=lt.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#a=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}let s=this.#d.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#c){this.#b.startDrawing(this,this.#d,!1,t);return}this.#d.setCurrentDrawingSession(this),this.#c=new AbortController;let e=this.#d.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:s})=>{if(s&&!this.div.contains(s))this.#u=null,this.commitOrRemove()},{signal:e}),this.#b.startDrawing(this,this.#d,!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.#c)return null;return this.#d.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#u=null,this.#b.endDrawing(t)}findNewParent(t,e,s){let i=this.#d.findParent(e,s);if(i===null||i===this)return!1;return i.changeParent(t),!0}commitOrRemove(){if(this.#c)return this.endDrawingSession(),!0;return!1}onScaleChanging(){if(!this.#c)return;this.#b.onScaleChangingWhenDrawing(this)}destroy(){if(this.commitOrRemove(),this.#d.getActive()?.parent===this)this.#d.commitOrRemove(),this.#d.setActiveEditor(null);if(this.#r)clearTimeout(this.#r),this.#r=null;for(let t of this.#n.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#n.clear(),this.#d.removeLayer(this)}#S(){for(let t of this.#n.values())if(t.isEmpty())t.remove()}async render({viewport:t}){this.viewport=t,Ne(this.div,t);for(let e of this.#d.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#d.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#d.commitOrRemove(),this.#S();let e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Ne(this.div,{rotation:s}),e!==s)for(let i of this.#n.values())i.rotate(s)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#d.viewParameters.realScale}}vc();function Nh(t,e){if(t===e)return 0;return t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Ns(t){if(!t)return null;return t.nodeType===Node.ELEMENT_NODE?t.closest(".textLayer"):t.parentElement?.closest(".textLayer")||null}function Bh(t,e,s,i){if(t===s)return e<=i;let r=t.compareDocumentPosition(s);if(r&Node.DOCUMENT_POSITION_FOLLOWING)return!0;if(r&Node.DOCUMENT_POSITION_PRECEDING)return!1;return null}function Cn(t,e,s){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||!s.contains(i))return null;return i.nodeType===Node.TEXT_NODE?{container:i,offset:i.textContent.length}:{container:i,offset:i.childNodes.length}}class Y{#t=null;#e=new Map;#s=null;#i=null;#r=null;#n=null;#a=new Map;static#o=0;static#l=0;static#c=null;static#u=new Set;static#h=!1;static#f=new Set;static#p=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){if(this.pageIndex=s,this.#i=t,this.#r=e,i){let r=Y.#p.get(i);if(r?.selectionDiv)r.selectionDiv.remove(),Y.#u.delete(r.selectionDiv);if(Y.#p.set(i,{drawLayer:this}),Y.#f.add(i),this.#s=i,this.#n=new MutationObserver((n)=>{if(!this.#t||!this.#s?.isConnected||!Y.#d())return;for(let{addedNodes:a}of n)for(let o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){Y.#v();return}}),this.#n.observe(i,{childList:!0}),Y.#c===null){Y.#c=new AbortController;let{signal:n}=Y.#c;document.addEventListener("selectionchange",Y.#v.bind(Y),{signal:n}),document.addEventListener("pointerdown",()=>{Y.#h=!0},{signal:n}),document.addEventListener("pointerup",()=>{Y.#h=!1},{signal:n}),window.addEventListener("blur",()=>{Y.#h=!1},{signal:n})}}}setParent(t){if(!this.#t){if(this.#t=t,this.#s?.isConnected&&Y.#d())Y.#v();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#m(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#d(){let t=document.getSelection();return!!t&&!t.isCollapsed}static#g(){return this.#f.keys().filter((t)=>t.isConnected).toArray().sort(Nh)}static#v(){let t=document.getSelection();if(!t||t.isCollapsed){for(let n of this.#u)n.remove();this.#u.clear();return}let e=new WeakMap,s=this.#g(),i=[];for(let n=0,a=t.rangeCount;n<a;n++){let o=t.getRangeAt(n);if(o.collapsed)continue;let{startContainer:l,startOffset:c,endContainer:h,endOffset:d}=o,u=Ns(l),f=Ns(h),p=u===null,g=f===null;if(this.#h&&p!==g)return;if(t.rangeCount===1){let{anchorNode:y,anchorOffset:b,focusNode:_,focusOffset:w}=t,A=Ns(y),x=Ns(_),E=Bh(y,b,_,w);if(A&&x&&E!==null)if(E)l=y,c=b,u=A,h=_,d=w,f=x;else l=_,c=w,u=x,h=y,d=b,f=A}let m=s.filter((y)=>o.intersectsNode(y));if(m.length===0)continue;let v=!1;if(!u)u=m[0],l=u,c=0,v=!0;if(!f)f=m.at(-1),h=f,d=f.childNodes.length,v=!0;if(h.nodeType===Node.ELEMENT_NODE){if(h.classList.contains("endOfContent")){let y=h.previousSibling;if(!y)continue;h=y,d=y.nodeType===Node.TEXT_NODE?y.textContent.length:y.childNodes.length}else if(h.classList.contains("textLayer")&&h.childNodes.length===d){let y=Cn(h,d,f);if(!y)continue;h=y.container,d=y.offset}}if(l.nodeType===Node.ELEMENT_NODE){let y=Cn(l,c,u);if(!y)continue;l=y.container,c=y.offset}if(u===f&&!v&&m.includes(u)){i.push([o,u]);continue}for(let y of m){let b=y.firstChild;if(!b)continue;let _=document.createRange();if(y===u)_.setStart(l,c);else _.setStartBefore(b);if(y===f)_.setEnd(h,d);else{let w=y.lastChild;if(!w)continue;if(w.nodeType===Node.ELEMENT_NODE&&w.classList.contains("endOfContent")){let A=w.previousSibling;if(!A)continue;_.setEndAfter(A)}else _.setEndAfter(w)}if(!_.collapsed)i.push([_,y])}}let r=new Set(i.map((n)=>n[1]));for(let n of this.#f)if(!r.has(n))this.#m(n);for(let[n,a]of i){let o=Y.#p.get(a);if(!o)continue;let l=e.get(a);if(!l){let f=a.getBoundingClientRect();l=(p,g,m,v)=>({x:(p-f.x)/f.width,y:(g-f.y)/f.height,width:m/f.width,height:v/f.height}),e.set(a,l)}let c=[];for(let{x:f,y:p,width:g,height:m}of n.getClientRects()){if(g===0||m===0)continue;if({x:f,y:p,width:g,height:m}=l(f,p,g,m),g===1&&m===1)continue;c.push(`M${f} ${p} h${g} v${m} h-${g} Z`)}if(c.length===0)continue;let{drawLayer:h,selectionDiv:d,path:u}=o;if(!d){let f=`clip_selection_${Y.#l++}`;d=document.createElement("div"),d.className="selection",d.style.clipPath=`url(#${f})`;let p=h.#i?.createSelectionStyle(h.#r);if(p)for(let[v,y]of Object.entries(p))d.style.setProperty(v,y);let g=Y._svgFactory.create(1,1,!0);g.setAttribute("aria-hidden","true"),g.setAttribute("width","100%"),g.setAttribute("height","100%");let m=Y._svgFactory.createElement("clipPath");m.setAttribute("id",f),m.setAttribute("clipPathUnits","objectBoundingBox"),u=Y._svgFactory.createElement("path"),m.append(u),g.append(m),d.append(g),o.path=u,o.selectionDiv=d}if(h.#t&&d.parentNode!==h.#t)h.#t.append(d),this.#u.add(d);u.setAttribute("d",c.join(" "))}}static get _svgFactory(){return L(this,"_svgFactory",new Fi)}static#y(t,[e,s,i,r]){let{style:n}=t;n.top=`${100*s}%`,n.left=`${100*e}%`,n.width=`${100*i}%`,n.height=`${100*r}%`}#b(){let t=Y._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#_(t,e){let s=Y._svgFactory.createElement("clipPath");t.append(s);let i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");let r=Y._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i}#A(t,e){for(let[s,i]of Object.entries(e))if(i===null)t.removeAttribute(s);else t.setAttribute(s,i)}draw(t,e=!1,s=!1){let i=Y.#o++,r=this.#b(),n=Y._svgFactory.createElement("defs");r.append(n);let a=Y._svgFactory.createElement("path");n.append(a);let o=`path_${i}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e)this.#a.set(i,a);let l=s?this.#_(n,o):null,c=Y._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#e.set(i,r),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,e){let s=Y.#o++,i=this.#b(),r=Y._svgFactory.createElement("defs");i.append(r);let n=Y._svgFactory.createElement("path");r.append(n);let a=`path_${s}`;n.setAttribute("id",a),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){let h=Y._svgFactory.createElement("mask");r.append(h),o=`mask_${s}`,h.setAttribute("id",o),h.setAttribute("maskUnits","objectBoundingBox");let d=Y._svgFactory.createElement("rect");h.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");let u=Y._svgFactory.createElement("use");h.append(u),u.setAttribute("href",`#${a}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}let l=Y._svgFactory.createElement("use");if(i.append(l),l.setAttribute("href",`#${a}`),o)l.setAttribute("mask",`url(#${o})`);let c=l.cloneNode();return i.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#a.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:s,bbox:i,rootClass:r,path:n}=e,a=typeof t==="number"?this.#e.get(t):t;if(!a)return;if(s)this.#A(a,s);if(i)Y.#y(a,i);if(r){let{classList:o}=a;for(let[l,c]of Object.entries(r))o.toggle(l,c)}if(n){let l=a.firstElementChild.firstElementChild;this.#A(l,n)}}updateParent(t,e){if(e===this)return;let s=this.#e.get(t);if(!s)return;e.#t.append(s),this.#e.delete(t),e.#e.set(t,s)}remove(t){if(this.#a.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.#a.clear(),this.#n?.disconnect(),this.#n=null,this.#s){if(Y.#p.get(this.#s)?.drawLayer===this){if(Y.#m(this.#s),Y.#p.delete(this.#s),Y.#f.delete(this.#s),Y.#f.size===0)Y.#c?.abort(),Y.#c=null,Y.#h=!1}this.#s=null}}}function Bs(t){return`${(t*100).toFixed(2)}%`}class ei{#t=[];#e=new Map;#s=null;#i=0;#r=0;#n=0;static#a=null;constructor(t,e,s,i){this.#i=t,this.#t=e,this.#r=s.rawDims.pageWidth,this.#n=s.rawDims.pageHeight,this.#s=i}render(){let t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){let s=this.#o(this.#t.subarray(e,e+6));if(s)t.append(s)}return t.addEventListener("contextmenu",(e)=>{if(!(e.target instanceof HTMLCanvasElement))return;let s=e.target,i=this.#e.get(s);if(!i)return;let r=ei.#a?.deref();if(r===s)return;if(r)r.width=0,r.height=0;ei.#a=new WeakRef(s);let{inverseTransform:n,x1:a,y1:o,width:l,height:c}=i,h=this.#s(),d=Math.ceil(a*h.width),u=Math.ceil(o*h.height),f=Math.floor((a+l/this.#r)*h.width),p=Math.floor((o+c/this.#n)*h.height);s.width=f-d,s.height=p-u;let g=s.getContext("2d");g.setTransform(...n),g.translate(-d,-u),g.drawImage(h,0,0)}),t}#o([t,e,s,i,r,n]){let a=Math.hypot((r-t)*this.#r,(n-e)*this.#n),o=Math.hypot((s-t)*this.#r,(i-e)*this.#n);if(a<this.#i||o<this.#i)return null;let l=[(r-t)*this.#r/a,(n-e)*this.#n/a,(s-t)*this.#r/o,(i-e)*this.#n/o,0,0],c=O.inverseTransform(l),h=document.createElement("canvas");return h.className="textLayerImagePlaceholder",h.width=0,h.height=0,Object.assign(h.style,{opacity:0,position:"absolute",left:Bs(t),top:Bs(e),width:Bs(a/this.#r),height:Bs(o/this.#n),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(h,{inverseTransform:c,width:a,height:o,x1:t,y1:e}),h}}globalThis._pdfjsTestingUtils={HighlightOutliner:Qs};globalThis.pdfjsLib={AbortException:ve,AnnotationEditorLayer:fe,AnnotationEditorParamsType:st,AnnotationEditorType:K,AnnotationEditorUIManager:Se,AnnotationLayer:Ur,AnnotationMode:we,AnnotationType:yt,applyOpacity:qc,build:Fh,ColorPicker:Qt,createValidAbsoluteUrl:ra,CSSConstants:ha,DOMSVGFactory:Fi,DrawLayer:Y,FeatureTest:lt,fetchData:Sr,findContrastColor:Jc,getDocument:Rr,getFilenameFromUrl:th,getPdfFilenameFromUrl:eh,getRGB:Es,getRGBA:ts,getUuid:oa,GlobalWorkerOptions:Zt,ImageKind:js,InvalidPDFException:Vs,isDataScheme:Ei,isPdfFile:Er,isValidExplicitDest:oh,makeArr:Ze,makeMap:Ws,makeObj:qi,makeSet:Kc,MathClamp:pt,noContextMenu:re,normalizeUnicode:Xc,OPS:pe,OutputScale:Kt,PasswordException:zs,PasswordResponses:$c,PDFDataRangeTransport:Dr,PDFDateString:Xs,PDFWorker:Ft,PermissionFlag:Uc,PixelsPerInch:Le,RenderingCancelledException:Si,renderRichText:da,ResponseException:gs,setLayerDimensions:Ne,shadow:L,SignatureExtractor:Oe,stopEvent:Tt,SupportedImageMimeTypes:Zi,TextLayer:Lt,TextLayerImages:ei,TouchManager:Cr,updateUrlHash:na,Util:O,VerbosityLevel:bi,version:Rh,XfaLayer:Ar};var Ps={maxBytes:104857600,maxPages:2000,maxCanvasPixels:16000000,maxImageWidth:4096};var zo=(t)=>Object.assign(Error(t),{name:"PdfTooLargeError"});async function Gh(t,e,s){if(e.aborted)return null;Zt.workerSrc=new URL(s,import.meta.url).href;let i=Rr({data:new Uint8Array(t),verbosity:0,stopAtErrors:!0,enableXfa:!1,maxImageSize:Ps.maxCanvasPixels,canvasMaxAreaInBytes:Ps.maxCanvasPixels*4}),r=()=>void i.destroy();e.addEventListener("abort",r,{once:!0});let n=async()=>{e.removeEventListener("abort",r),await i.destroy()};try{let a=await i.promise;if(a.numPages>Ps.maxPages)throw zo(`PDF has more than ${Ps.maxPages} pages`);let o=[];for(let h=1;h<=a.numPages;h++){let{width:d,height:u}=(await a.getPage(h)).getViewport({scale:1});if(e.aborted)return await n(),null;o.push({width:d,height:u})}return{pages:o,draw:async(h,d,u)=>{let f=await a.getPage(h+1);if(u.aborted)return null;let p=f.getViewport({scale:d/f.getViewport({scale:1}).width}),g=document.createElement("canvas");try{g.width=Math.round(p.width),g.height=Math.round(p.height);let m=f.render({canvas:g,viewport:p}),v=()=>m.cancel();u.addEventListener("abort",v,{once:!0});try{await m.promise}finally{u.removeEventListener("abort",v)}let y=await new Promise((b,_)=>g.toBlob((w)=>w?b(w):_(Error("The page could not be drawn")),"image/png"));if(u.aborted)return null;return{url:URL.createObjectURL(y),width:g.width,height:g.height}}finally{g.width=0,g.height=0,f.cleanup()}},textLayer:async(h,d,u)=>{let f=await a.getPage(h+1);if(u.aborted)return;let p=f.getViewport({scale:1}),g=new Lt({textContentSource:f.streamTextContent(),container:d,viewport:p}),[m=0,v=0,y=0,b=0]=p.viewBox;d.style.width=`calc(var(--total-scale-factor) * ${y-m}px)`,d.style.height=`calc(var(--total-scale-factor) * ${b-v}px)`;let _=()=>g.cancel();u.addEventListener("abort",_,{once:!0});try{await g.render()}finally{u.removeEventListener("abort",_)}},close:n}}catch(a){if(await n(),e.aborted)return null;throw a}}export{Gh as openPdf};