@zhuyunjing/file-viewer 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
!function(e
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self)["TdhHelperfile-viewer"]=e()}(this,function(){"use strict";var t="undefined"!=typeof document?document.currentScript:null;function e(t,e,i,s,n,r,a){try{var o=t[r](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(s,n)}function i(t){return function(){var i=this,s=arguments;return new Promise(function(n,r){var a=t.apply(i,s);function o(t){e(a,n,r,o,l,"next",t)}function l(t){e(a,n,r,o,l,"throw",t)}o(void 0)})}}function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function n(t){var e=function(t,e){if("object"!=s(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==s(e)?e:e+""}function r(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,n(s.key),s)}}function a(t,e,i){return(e=n(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var l={exports:{}},h={exports:{}};!function(t){t.exports=function(t,e){this.v=t,this.k=e},t.exports.__esModule=!0,t.exports.default=t.exports}(h);var c=h.exports,d={exports:{}},u={exports:{}};!function(t){function e(i,s,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(i){a=0}t.exports=e=function(t,i,s,n){function r(i,s){e(t,i,function(t){return this._invoke(i,s,t)})}i?a?a(t,i,{value:s,enumerable:!n,configurable:!n,writable:!n}):t[i]=s:(r("next",0),r("throw",1),r("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(i,s,n,r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(u);var p=u.exports;!function(t){var e=p;function i(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var r,i,a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.toStringTag||"@@toStringTag";function c(e,n,a,o){var s=n&&n.prototype instanceof u?n:u,c=Object.create(s.prototype);return t(c,"_invoke",function(e,t,n){var a,o,s,c=0,u=n||[],d=!1,p={p:0,n:0,v:r,a:h,f:h.bind(r,4),d:function(e,t){return a=e,o=0,s=r,p.n=t,l}};function h(e,t){for(o=e,s=t,i=0;!d&&c&&!n&&i<u.length;i++){var n,a=u[i],h=p.p,f=a[2];e>3?(n=f===t)&&(s=a[(o=a[4])?5:(o=3,3)],a[4]=a[5]=r):a[0]<=h&&((n=e<2&&h<a[1])?(o=0,p.v=t,p.n=a[1]):h<f&&(n=e<3||a[0]>t||t>f)&&(a[4]=e,a[5]=t,p.n=f,o=0))}if(n||e>1)return l;throw d=!0,t}return function(n,u,f){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,f),o=u,s=f;(i=o<2?r:s)||!d;){a||(o?o<3?(o>1&&(p.n=-1),h(o,s)):p.n=s:p.v=s);try{if(c=2,a){if(o||(n="next"),i=a[n]){if(!(i=i.call(a,s)))throw TypeError("iterator result is not an object");if(!i.done)return i;s=i.value,o<2&&(o=0)}else 1===o&&(i=a.return)&&i.call(a),o<2&&(s=TypeError("The iterator does not provide a '"+n+"' method"),o=1);a=r}else if((i=(d=p.n<0)?s:e.call(t,p))!==l)break}catch(e){a=r,o=1,s=e}finally{c=1}}return{value:i,done:d}}}(e,a,o),!0),c}var l={};function u(){}function d(){}function p(){}i=Object.getPrototypeOf;var h=[][o]?i(i([][o]())):(t(i={},o,function(){return this}),i),f=p.prototype=u.prototype=Object.create(h);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,t(e,s,"GeneratorFunction")),e.prototype=Object.create(f),e}return d.prototype=p,t(f,"constructor",p),t(p,"constructor",d),d.displayName="GeneratorFunction",t(p,s,"GeneratorFunction"),t(f),t(f,s,"Generator"),t(f,o,function(){return this}),t(f,"toString",function(){return"[object Generator]"}),(e.exports=n=function(){return{w:c,m:g}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(f);var b=f.exports,x={exports:{}},y={exports:{}},m={exports:{}};!function(e){var t=h,n=v;e.exports=function e(r,i){function a(e,n,o,s){try{var c=r[e](n),l=c.value;return l instanceof t?i.resolve(l.v).then(function(e){a("next",e,o,s)},function(e){a("throw",e,o,s)}):i.resolve(l).then(function(e){c.value=e,o(c)},function(e){return a("throw",e,o,s)})}catch(e){s(e)}}var o;this.next||(n(e.prototype),n(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),n(this,"_invoke",function(e,t,n){function r(){return new i(function(t,r){a(e,n,t,r)})}return o=o?o.then(r,r):r()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(m);var k=m.exports;!function(e){var t=b,n=k;e.exports=function(e,r,i,a,o){return new n(t().w(e,r,i,a),o||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(y);var w=y.exports;!function(e){var t=w;e.exports=function(e,n,r,i,a){var o=t(e,n,r,i,a);return o.next().then(function(e){return e.done?e.value:o.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(x);var P=x.exports,C={exports:{}};!function(e){e.exports=function(e){var t=Object(e),n=[];for(var r in t)n.unshift(r);return function e(){for(;n.length;)if((r=n.pop())in t)return e.value=r,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(C);var S=C.exports,T={exports:{}},E={exports:{}};!function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(E);var L=E.exports;!function(e){var t=L.default;e.exports=function(e){if(null!=e){var n=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(T);var j=T.exports;!function(e){var t=h,n=b,r=P,i=w,a=k,o=S,s=j;function c(){var l=n(),u=l.m(c),d=(Object.getPrototypeOf?Object.getPrototypeOf(u):u.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))}var h={throw:1,return:2,break:3,continue:3};function f(e){var t,n;return function(r){t||(t={stop:function(){return n(r.a,2)},catch:function(){return r.v},abrupt:function(e,t){return n(r.a,h[e],t)},delegateYield:function(e,i,a){return t.resultName=i,n(r.d,s(e),a)},finish:function(e){return n(r.f,e)}},n=function(e,n,i){r.p=t.prev,r.n=t.next;try{return e(n,i)}finally{t.next=r.n}}),t.resultName&&(t[t.resultName]=r.v,t.resultName=void 0),t.sent=r.v,t.next=r.n;try{return e.call(this,t)}finally{r.p=t.prev,r.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,n,r){return l.w(f(e),t,n,r&&r.reverse())},isGeneratorFunction:p,mark:l.m,awrap:function(e,n){return new t(e,n)},AsyncIterator:a,async:function(e,t,n,a,o){return(p(t)?i:r)(f(e),t,n,a,o)},keys:o,values:s}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(d);var I=d.exports,O=I(),D=O;try{regeneratorRuntime=O}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=O:Function("r","regeneratorRuntime = r")(O)}var M,H=u(D),A={wrapper:{display:"flex",flexDirection:"column",height:"100%",background:"#525659",fontFamily:"sans-serif",fontSize:"12px"},toolbar:{display:"flex",alignItems:"center",padding:"4px 6px",background:"#474747",borderBottom:"1px solid #525659",gap:"4px"},toolbarGroup:{display:"flex",alignItems:"center",gap:"2px"},toolbarSeparator:{width:"1px",height:"24px",background:"#525659",margin:"0 4px"},button:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",padding:"0",background:"transparent",border:"none",borderRadius:"2px",cursor:"pointer",color:"#f0f0f0",fontSize:"14px",transition:"background 0.15s"},buttonHover:{background:"#5a5a5a"},buttonActive:{background:"#6a6a6a"},buttonDisabled:{opacity:"0.5",cursor:"not-allowed"},buttonImg:{width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center"},input:{width:"50px",padding:"4px 6px",background:"#3a3a3a",border:"1px solid #525659",borderRadius:"2px",color:"#f0f0f0",fontSize:"12px",textAlign:"center"},inputFocus:{outline:"none",borderColor:"#00a1de"},label:{color:"#f0f0f0",margin:"0 4px"},select:{padding:"4px 8px",background:"#3a3a3a",border:"1px solid #525659",borderRadius:"2px",color:"#f0f0f0",fontSize:"12px",cursor:"pointer"},selectFocus:{outline:"none",borderColor:"#00a1de"},main:{display:"flex",flex:"1",overflow:"hidden",position:"relative"},sidebar:{width:"200px",background:"#3a3a3a",borderRight:"1px solid #525659",display:"flex",flexDirection:"column",transition:"width 0.2s ease",position:"absolute",top:"0",left:"0",bottom:"0",zIndex:"10"},sidebarHidden:{width:"0",display:"none",borderRight:"none"},sidebarHeader:{display:"flex",padding:"8px",background:"#474747",borderBottom:"1px solid #525659"},sidebarTab:{flex:"1",padding:"6px 12px",background:"transparent",border:"none",borderRadius:"2px",color:"#f0f0f0",fontSize:"11px",cursor:"pointer",textAlign:"center"},sidebarTabHover:{background:"#5a5a5a"},sidebarTabActive:{background:"#6a6a6a"},sidebarContent:{flex:"1",overflowY:"auto",padding:"8px"},thumbnail:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"12px",padding:"8px",background:"#474747",borderRadius:"4px",cursor:"pointer",transition:"background 0.15s"},thumbnailHover:{background:"#5a5a5a"},thumbnailActive:{background:"#00a1de"},thumbnailCanvas:{maxWidth:"100%",maxHeight:"150px",border:"1px solid #525659"},thumbnailPage:{color:"#f0f0f0",fontSize:"11px",marginTop:"4px"},content:{flex:"1",display:"flex",flexDirection:"column",overflow:"auto",transition:"marginLeft 0.2s ease"},contentNoSidebar:{marginLeft:"0"},findbar:{display:"flex",alignItems:"center",padding:"4px 8px",background:"#474747",borderBottom:"1px solid #525659",gap:"8px",position:"absolute",right:0,zIndex:"1"},findbarHidden:{display:"none"},findInput:{flex:"1",maxWidth:"300px",padding:"4px 8px",background:"#3a3a3a",border:"1px solid #525659",borderRadius:"2px",color:"#f0f0f0",fontSize:"12px"},findInputFocus:{outline:"none",borderColor:"#00a1de"},findResults:{color:"#f0f0f0",fontSize:"11px",minWidth:"60px",textAlign:"right"},canvasContainer:{display:"flex",flexDirection:"column",background:"#525659"},canvas:{background:"white"},outlineItem:{display:"flex",alignItems:"center",padding:"4px 8px",color:"#f0f0f0",cursor:"pointer",borderRadius:"2px",fontSize:"11px"},outlineItemHover:{background:"#5a5a5a"},outlineItemActive:{background:"#00a1de"},outlineIcon:{width:"16px",height:"16px",marginRight:"4px",display:"inline-flex",alignItems:"center"},outlineChildren:{paddingLeft:"16px"}};function z(e,t){var n;return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];clearTimeout(n),n=setTimeout(function(){return e.apply(void 0,i)},t)}}function _(e,t){Object.assign(e.style,t)}function R(e,t){var n={};e.addEventListener("mouseenter",function(){if("true"!==e.dataset.active){var r=window.getComputedStyle(e);Object.keys(t).forEach(function(e){n[e]=r.getPropertyValue(e)}),Object.assign(e.style,t)}}),e.addEventListener("mouseleave",function(){"true"!==e.dataset.active&&(Object.keys(n).forEach(function(t){e.style.setProperty(t,n[t])}),n={})})}function F(e){return B.apply(this,arguments)}function B(){return(B=a(H.mark(function e(t){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t instanceof ArrayBuffer)){e.next=1;break}return e.abrupt("return",new Uint8Array(t));case 1:if(!(t instanceof Uint8Array)){e.next=2;break}return e.abrupt("return",t);case 2:return e.abrupt("return",new Promise(function(e,n){var r=new FileReader;r.onload=function(){e(new Uint8Array(r.result))},r.onerror=n,r.readAsArrayBuffer(t)}));case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}function N(e){for(var t=atob(e),n=new Uint8Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function V(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return q(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?q(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function U(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}null!==(M=r.GlobalWorkerOptions)&&void 0!==M&&M.workerSrc||(r.GlobalWorkerOptions.workerSrc=new URL("pdfjs-dist/legacy/build/pdf.worker.min.mjs","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("index.js",document.baseURI).href).href);var G=function(){return t=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,"instanceId",void 0),l(this,"pdfDoc",null),l(this,"container",void 0),l(this,"options",void 0),l(this,"currentPage",1),l(this,"currentScale","auto"),l(this,"pdfjsLib",void 0),l(this,"canvas",void 0),l(this,"ctx",void 0),l(this,"thumbnails",new Map),l(this,"sidebarContentCreated",!1),l(this,"outline",[]),l(this,"findController",null),l(this,"textLayer",null),l(this,"pageCanvases",new Map),l(this,"pagePlaceholders",new Map),l(this,"renderedPages",new Set),l(this,"pagesContainer",null),l(this,"content",null),l(this,"pageHeights",new Map),l(this,"scrollHandler",null),l(this,"isNavigating",!1),l(this,"isRendering",!1),l(this,"renderQueue",[]),l(this,"maxConcurrentRenders",2),l(this,"loadingTask",null),l(this,"sidebarScrollHandler",null),this.instanceId="pdf-preview-".concat(++e.instanceCounter),this.options=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?U(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({scale:"auto",page:1,rotation:0,cMapPacked:!0,showToolbar:!1,showSidebar:!1,textLayer:!1},t),this.container=this.getContainer(this.options.container);var n=this.container.__pdfPreviewInstance;n&&n!==this&&n.destroy(),this.container.__pdfPreviewInstance=this,this.currentScale=this.options.scale||"auto",this.currentPage=this.options.page||1,this.canvas=document.createElement("canvas"),_(this.canvas,A.canvas),this.ctx=this.canvas.getContext("2d"),this.createUI(),this.initPdfJs()},n=[{key:"getContainer",value:function(e){if("string"==typeof e){var t=e.replace(new RegExp("#","g"),""),n=document.getElementById(t);if(!n)throw new Error("Container element not found: ".concat(e));return n}return console.log(11234,e),e}},{key:"createUI",value:function(){if(this.container.innerHTML="",_(this.container,A.wrapper),this.options.showToolbar){var e=this.createToolbar();this.container.appendChild(e)}var t=document.createElement("div");if(_(t,A.main),this.options.showToolbar){var n=this.createSidebar();t.appendChild(n)}var r=this.createContent();t.appendChild(r),this.container.appendChild(t)}},{key:"createToolbar",value:function(){var e=this,t=document.createElement("div");_(t,A.toolbar);var n=document.createElement("div");_(n,A.toolbarGroup);var r=this.createButton("sidebar-toggle","Toggle Sidebar",function(){e.toggleSidebar()});n.appendChild(r);var i=document.createElement("div");_(i,A.toolbarSeparator),n.appendChild(i);var a=this.createButton("prev-page","Previous Page",function(){e.prevPage()});n.appendChild(a);var o=document.createElement("input");_(o,A.input),o.min="1",o.value="1",o.id="".concat(this.instanceId,"-page-input"),o.addEventListener("focus",function(){Object.assign(o.style,A.inputFocus)}),o.addEventListener("blur",function(){Object.keys(A.inputFocus).forEach(function(e){o.style.removeProperty(e)})}),o.addEventListener("change",function(t){var n=parseInt(t.target.value);e.goToPage(n)}),n.appendChild(o);var s=document.createElement("span");_(s,A.label),s.id="".concat(this.instanceId,"-page-label"),s.textContent="/ 1",n.appendChild(s);var c=this.createButton("next-page","Next Page",function(){e.nextPage()});n.appendChild(c);var l=document.createElement("div");_(l,A.toolbarSeparator),n.appendChild(l);var u=this.createButton("zoom-out","Zoom Out",function(){e.zoomOut()});n.appendChild(u);var d=document.createElement("select");_(d,A.select),d.innerHTML='\n <option value="auto">Auto</option>\n <option value="0.5">50%</option>\n <option value="0.75">75%</option>\n <option value="1">100%</option>\n <option value="1.25">125%</option>\n <option value="1.5">150%</option>\n <option value="2">200%</option>\n <option value="3">300%</option>\n <option value="4">400%</option>\n ',d.value=this.currentScale,d.addEventListener("focus",function(){Object.assign(d.style,A.selectFocus)}),d.addEventListener("blur",function(){Object.keys(A.selectFocus).forEach(function(e){d.style.removeProperty(e)})}),d.addEventListener("change",function(t){var n=t.target.value,r="auto"===n?"auto":parseFloat(n);e.setScale(r)}),n.appendChild(d);var p=this.createButton("zoom-in","Zoom In",function(){e.zoomIn()});n.appendChild(p);var h=document.createElement("div");_(h,A.toolbarSeparator),n.appendChild(h);var f=this.createButton("rotate-cw","Rotate Clockwise",function(){e.setRotation((e.options.rotation+90)%360)});n.appendChild(f);var g=this.createButton("rotate-ccw","Rotate Counterclockwise",function(){e.setRotation((e.options.rotation-90+360)%360)});n.appendChild(g);var v=document.createElement("div");_(v,A.toolbarSeparator),n.appendChild(v);var b=this.createButton("find","Find in Document",function(){e.toggleFindbar()});return n.appendChild(b),t.appendChild(n),t}},{key:"createButton",value:function(e,t,n){var r=document.createElement("button");return _(r,A.button),r.title=t,r.innerHTML={"sidebar-toggle":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>',"prev-page":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>',"next-page":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',"zoom-out":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M19 13H5v-2h14v2z"/></svg>',"zoom-in":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',"rotate-cw":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></svg>',"rotate-ccw":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M12 5V1l-5 5 5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" transform="scale(-1,1) translate(-24,0)"/></svg>',find:'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>',"find-prev":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>',"find-next":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',close:'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>'}[e]||"",r.addEventListener("click",n),R(r,A.buttonHover),r}},{key:"createSidebar",value:function(){var e=document.createElement("div");this.options.showSidebar?_(e,A.sidebar):_(e,A.sidebarHidden);var t=document.createElement("div");return _(t,A.sidebarContent),t.id="".concat(this.instanceId,"-sidebar-content"),e.appendChild(t),e}},{key:"createContent",value:function(){var e=document.createElement("div");_(e,A.content);var t=this.createFindbar();return e.appendChild(t),this.pagesContainer=document.createElement("div"),_(this.pagesContainer,A.canvasContainer),this.pagesContainer.id="".concat(this.instanceId,"-canvas-container"),e.appendChild(this.pagesContainer),this.content=e,e}},{key:"createFindbar",value:function(){var e=this,t=document.createElement("div");_(t,A.findbar),_(t,A.findbarHidden),t.id="".concat(this.instanceId,"-findbar");var n=document.createElement("input");n.type="text",_(n,A.findInput),n.placeholder="Find in document...",n.addEventListener("focus",function(){Object.assign(n.style,A.findInputFocus)}),n.addEventListener("blur",function(){Object.keys(A.findInputFocus).forEach(function(e){n.style.removeProperty(e)})}),n.addEventListener("input",function(t){e.findText(t.target.value)}),t.appendChild(n);var r=this.createButton("find-prev","Previous",function(){e.findPrevious()});t.appendChild(r);var i=this.createButton("find-next","Next",function(){e.findNext()});t.appendChild(i);var a=document.createElement("span");_(a,A.findResults),a.textContent="0/0",a.id="".concat(this.instanceId,"-find-results"),t.appendChild(a);var o=this.createButton("close","Close",function(){e.toggleFindbar()});return t.appendChild(o),t}},{key:"toggleSidebar",value:function(){var e=Array.from(this.container.children)[1];if(e){var t=e.firstChild,n=e.children[1];t&&n&&("0px"===t.style.width?(Object.assign(t.style,A.sidebar),this.renderThumbnails()):Object.assign(t.style,A.sidebarHidden))}}},{key:"toggleFindbar",value:function(){var e=this.container.querySelector("#".concat(this.instanceId,"-findbar"));if(e){var t="none"===e.style.display;t?Object.assign(e.style,A.findbar):Object.assign(e.style,A.findbarHidden),t||e.querySelector("input").focus()}}},{key:"switchSidebarTab",value:function(e){var t=this.container.querySelectorAll("button");if(t.forEach(function(e){var t=e;"Thumbnails"!==t.textContent&&"Outline"!==t.textContent||Object.keys(A.sidebarTabActive).forEach(function(e){t.style.removeProperty(e)})}),this.container.querySelector("#".concat(this.instanceId,"-sidebar-content")).innerHTML="","thumbnails"===e){var n=t[0];"Thumbnails"===n.textContent&&Object.assign(n.style,A.sidebarTabActive),this.renderThumbnails()}else if("outline"===e){var r=t[1];"Outline"===r.textContent&&Object.assign(r.style,A.sidebarTabActive),this.renderOutline()}}},{key:"renderThumbnails",value:(D=a(H.mark(function e(){var t,n,r,i=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.container.querySelector("#".concat(this.instanceId,"-sidebar-content")),this.pdfDoc){e.next=1;break}return e.abrupt("return");case 1:if(this.sidebarContentCreated){e.next=6;break}t.innerHTML="",n=H.mark(function e(n){var r,a,o;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:_(r=document.createElement("div"),A.thumbnail),n===i.currentPage?(Object.assign(r.style,A.thumbnailActive),r.dataset.active="true"):r.dataset.active="false",r.addEventListener("click",function(){i.goToPage(n)}),R(r,A.thumbnailHover),r.dataset.page=n.toString(),(a=document.createElement("div")).style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.color="#999",a.style.fontSize="12px",a.style.width="100%",a.style.height="80px",r.appendChild(a),_(o=document.createElement("div"),A.thumbnailPage),o.textContent="Page ".concat(n),r.appendChild(o),t.appendChild(r);case 1:case"end":return e.stop()}},e)}),r=1;case 2:if(!(r<=this.pdfDoc.numPages)){e.next=4;break}return e.delegateYield(n(r),"t0",3);case 3:r++,e.next=2;break;case 4:return this.sidebarScrollHandler=z(function(){return i.loadVisibleThumbnails(t)},50),t.addEventListener("scroll",this.sidebarScrollHandler),this.sidebarContentCreated=!0,e.next=5,this.loadVisibleThumbnails(t);case 5:e.next=7;break;case 6:return t.querySelectorAll("[data-active]").forEach(function(e,t){t+1===i.currentPage?(Object.assign(e.style,A.thumbnailActive),e.dataset.active="true"):(Object.keys(A.thumbnailActive).forEach(function(t){e.style.removeProperty(t)}),e.dataset.active="false")}),e.next=7,this.loadVisibleThumbnails(t);case 7:case"end":return e.stop()}},e,this)})),function(){return D.apply(this,arguments)})},{key:"loadVisibleThumbnails",value:(O=a(H.mark(function e(t){var n,r,i,o,s,c,l,u=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc){e.next=1;break}return e.abrupt("return");case 1:n=t.querySelectorAll("[data-page]"),r=t.getBoundingClientRect(),i=Array.from(n).filter(function(e){var t=e.getBoundingClientRect();return t.top<r.bottom+100&&t.bottom>r.top-100}),o=3,s=0;case 2:if(!(s<i.length)){e.next=4;break}return c=i.slice(s,s+o),l=c.map(function(){var e=a(H.mark(function e(t){var n;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=parseInt(t.dataset.page||"0"))||t.querySelector("canvas")){e.next=1;break}return e.next=1,u.renderSingleThumbnail(t,n);case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),e.next=3,Promise.all(l);case 3:s+=o,e.next=2;break;case 4:case"end":return e.stop()}},e,this)})),function(e){return O.apply(this,arguments)})},{key:"renderSingleThumbnail",value:(I=a(H.mark(function e(t,n){var r,i,a,o,s,c,l,u;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,e.next=2,this.pdfDoc.getPage(n);case 2:return r=e.sent,i=r.getViewport({scale:.2}),(a=document.createElement("canvas")).width=i.width,a.height=i.height,o=a.getContext("2d"),e.next=3,r.render({canvasContext:o,viewport:i}).promise;case 3:(s=t.firstChild)&&t.removeChild(s),_(c=document.createElement("canvas"),A.thumbnailCanvas),c.width=i.width,c.height=i.height,c.getContext("2d").drawImage(a,0,0),(l=t.querySelector("div:last-child"))?t.insertBefore(c,l):t.appendChild(c),this.thumbnails.set(n,a),e.next=5;break;case 4:e.prev=4,u=e.catch(1),console.error("Error rendering thumbnail:",u);case 5:case"end":return e.stop()}},e,this,[[1,4]])})),function(e,t){return I.apply(this,arguments)})},{key:"renderOutline",value:(j=a(H.mark(function e(){var t,n,r,i;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((t=this.container.querySelector("#".concat(this.instanceId,"-sidebar-content"))).innerHTML="",this.pdfDoc){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,e.next=2,this.pdfDoc.getOutline();case 2:(n=e.sent)&&n.length>0?(this.outline=n,this.renderOutlineItems(n,t,0)):(_(r=document.createElement("div"),A.label),r.textContent="No outline available",r.style.padding="8px",t.appendChild(r)),e.next=4;break;case 3:e.prev=3,e.catch(1),_(i=document.createElement("div"),A.label),i.textContent="Failed to load outline",i.style.padding="8px",t.appendChild(i);case 4:case"end":return e.stop()}},e,this,[[1,3]])})),function(){return j.apply(this,arguments)})},{key:"renderOutlineItems",value:function(e,t,n){var r=this;e.forEach(function(e){var i=document.createElement("div");_(i,A.outlineItem),R(i,A.outlineItemHover);var a=document.createElement("span");_(a,A.outlineIcon),e.items&&e.items.length>0?a.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>':a.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>',i.appendChild(a);var o=document.createElement("span");o.textContent=e.title,i.appendChild(o),i.addEventListener("click",function(){e.dest&&r.pdfDoc.getPageIndex(e.dest).then(function(e){r.goToPage(e+1)})}),t.appendChild(i),e.items&&e.items.length>0&&r.renderOutlineItems(e.items,t,n+1)})}},{key:"initPdfJs",value:(L=a(H.mark(function e(){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.pdfjsLib=r,this.loadPdf();case 1:case"end":return e.stop()}},e,this)})),function(){return L.apply(this,arguments)})},{key:"loadPdf",value:(E=a(H.mark(function e(){var t,n,r,i,a,o,s,c,l=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cleanup(),e.prev=1,!this.options.url){e.next=2;break}r=this.pdfjsLib.getDocument({url:this.options.url,cMapUrl:this.options.cMapUrl||"pdfjs-dist/cmaps/",cMapPacked:this.options.cMapPacked}),e.next=6;break;case 2:if(!this.options.file){e.next=4;break}return e.next=3,F(this.options.file);case 3:i=e.sent,r=this.pdfjsLib.getDocument({data:i,cMapUrl:this.options.cMapUrl||"pdfjs-dist/cmaps/",cMapPacked:this.options.cMapPacked}),e.next=6;break;case 4:if(!this.options.base64){e.next=5;break}a=N(this.options.base64),r=this.pdfjsLib.getDocument({data:a,cMapUrl:this.options.cMapUrl||"pdfjs-dist/cmaps/",cMapPacked:this.options.cMapPacked}),e.next=6;break;case 5:throw new Error("No PDF source provided. Please provide url, file, or base64.");case 6:return this.loadingTask=r,this.options.onProgress&&(r.onProgress=function(e){var t,n,r=e.loaded/e.total*100;null===(t=(n=l.options).onProgress)||void 0===t||t.call(n,r)}),e.next=7,r.promise;case 7:this.pdfDoc=e.sent,this.loadingTask=null,this.updatePageInfo(),this.options.showToolbar&&this.renderThumbnails(),null===(t=(n=this.options).onLoad)||void 0===t||t.call(n),this.renderAllPages(),e.next=9;break;case 8:e.prev=8,c=e.catch(1),this.loadingTask=null,null===(o=(s=this.options).onError)||void 0===o||o.call(s,c);case 9:case"end":return e.stop()}},e,this,[[1,8]])})),function(){return E.apply(this,arguments)})},{key:"loadFile",value:(T=a(H.mark(function e(t){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cleanup(),!t.url){e.next=1;break}this.options.url=t.url,this.options.file=void 0,this.options.base64=void 0,e.next=4;break;case 1:if(!t.file){e.next=2;break}this.options.file=t.file,this.options.url=void 0,this.options.base64=void 0,e.next=4;break;case 2:if(!t.base64){e.next=3;break}this.options.base64=t.base64,this.options.url=void 0,this.options.file=void 0,e.next=4;break;case 3:throw new Error("No PDF source provided. Please provide url, file, or base64.");case 4:return this.currentPage=1,e.next=5,this.loadPdf();case 5:case"end":return e.stop()}},e,this)})),function(e){return T.apply(this,arguments)})},{key:"updatePageInfo",value:function(){var e=this.container.querySelector("#".concat(this.instanceId,"-page-input")),t=this.container.querySelector("#".concat(this.instanceId,"-page-label"));e&&t&&this.pdfDoc&&(e.max=this.pdfDoc.numPages.toString(),t.textContent="/ ".concat(this.pdfDoc.numPages))}},{key:"createPageContainer",value:(S=a(H.mark(function t(n){var r,i,a,o,s,c,l,u,d,p,h,f,g,v,b,x;return H.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,this.pdfDoc.getPage(n);case 1:return r=t.sent,t.next=2,this.getScaleValue(r);case 2:return i=t.sent,a=r.getViewport({scale:i,rotation:this.options.rotation}),(o=document.createElement("div")).style.position="relative",o.style.margin="0 auto 20px auto",o.style.width="fit-content",o.style.setProperty("--scale-factor",i.toString()),s=document.createDocumentFragment(),c=document.createElement("canvas"),l=window.devicePixelRatio||1,u=a.clone({scale:a.scale*l}),c.width=u.width,c.height=u.height,c.style.width="".concat(a.width,"px"),c.style.height="".concat(a.height,"px"),c.style.display="block",_(c,A.canvas),d=c.getContext("2d"),p={canvasContext:d,viewport:u},t.next=3,r.render(p).promise;case 3:if(s.appendChild(c),!this.options.textLayer){t.next=5;break}return(h=document.createElement("div")).className="textLayer",_(h,A.textLayer),(f=document.createElement("style")).textContent='.textLayer {\n position: absolute;\n text-align: initial;\n inset: 0;\n overflow: clip;\n opacity: 1;\n line-height: 1;\n -webkit-text-size-adjust: none;\n -moz-text-size-adjust: none;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n z-index: 0;\n}\n\n.textLayer.highlighting {\n touch-action: none;\n}\n\n.textLayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n}\n\n.textLayer> :not(.markedContent),\n.textLayer .markedContent span:not(.markedContent) {\n z-index: 1;\n}\n\n.textLayer span.markedContent {\n top: 0;\n height: 0;\n}\n\n.textLayer span[role="img"] {\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n cursor: default;\n}\n\n.textLayer .highlight {\n --highlight-bg-color: rgb(180 0 170 / 0.25);\n --highlight-selected-bg-color: rgb(0 100 0 / 0.25);\n --highlight-backdrop-filter: none;\n --highlight-selected-backdrop-filter: none;\n}\n\n@media screen and (forced-colors: active) {\n .textLayer .highlight {\n --highlight-bg-color: transparent;\n --highlight-selected-bg-color: transparent;\n --highlight-backdrop-filter: var(--hcm-highlight-filter);\n --highlight-selected-backdrop-filter: var(--hcm-highlight-selected-filter);\n }\n}\n\n.textLayer .highlight {\n margin: -1px;\n padding: 1px;\n background-color: var(--highlight-bg-color);\n -webkit-backdrop-filter: var(--highlight-backdrop-filter);\n backdrop-filter: var(--highlight-backdrop-filter);\n border-radius: 4px;\n}\n\n.appended:is(.textLayer .highlight) {\n position: initial;\n}\n\n.begin:is(.textLayer .highlight) {\n border-radius: 4px 0 0 4px;\n}\n\n.end:is(.textLayer .highlight) {\n border-radius: 0 4px 4px 0;\n}\n\n.middle:is(.textLayer .highlight) {\n border-radius: 0;\n}\n\n.selected:is(.textLayer .highlight) {\n background-color: var(--highlight-selected-bg-color);\n -webkit-backdrop-filter: var(--highlight-selected-backdrop-filter);\n backdrop-filter: var(--highlight-selected-backdrop-filter);\n}\n\n.textLayer ::-moz-selection {\n background: rgba(0, 0, 255, 0.3);\n}\n\n.textLayer ::selection {\n background: rgba(0, 0, 255, 0.3);\n}\n\n.textLayer br::-moz-selection {\n background: transparent;\n}\n\n.textLayer br::selection {\n background: transparent;\n}\n\n.textLayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n\n.textLayer.selecting .endOfContent {\n top: 0;\n}\n',h.appendChild(f),g=e.TextLayer,v=h,t.next=4,r.getTextContent();case 4:b=t.sent,x=a.clone({dontFlip:!0}),new g({container:v,textContentSource:b,viewport:x}).render(),s.appendChild(h);case 5:return o.appendChild(s),t.abrupt("return",o);case 6:case"end":return t.stop()}},t,this)})),function(e){return S.apply(this,arguments)})},{key:"renderPage",value:(C=a(H.mark(function e(t){var n,r,i,a,o,s,c;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc){e.next=1;break}throw new Error("PDF document not loaded");case 1:if(!(t<1||t>this.pdfDoc.numPages)){e.next=2;break}throw new Error("Page number ".concat(t," is out of range"));case 2:return this.currentPage=t,e.prev=3,e.next=4,this.createPageContainer(t);case 4:i=e.sent,this.pageCanvases.set(t,i),this.options.showToolbar&&((a=this.container.querySelector("#".concat(this.instanceId,"-page-input")))&&(a.value=t.toString()),this.updateThumbnailActive(t)),null===(n=(r=this.options).onPageRendered)||void 0===n||n.call(r,t),e.next=6;break;case 5:e.prev=5,c=e.catch(3),null===(o=(s=this.options).onError)||void 0===o||o.call(s,c);case 6:case"end":return e.stop()}},e,this,[[3,5]])})),function(e){return C.apply(this,arguments)})},{key:"renderAllPages",value:(P=a(H.mark(function e(){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:if(!this.options.renderAllPages){e.next=3;break}return e.next=2,this.renderFullPages();case 2:e.next=4;break;case 3:return e.next=4,this.renderVirtualPages();case 4:case"end":return e.stop()}},e,this)})),function(){return P.apply(this,arguments)})},{key:"renderFullPages",value:(w=a(H.mark(function e(){var t,n,r,i,a,o,s,c,l,u,d,p,h;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:this.pagesContainer.innerHTML="",this.pageCanvases.clear(),this.pagePlaceholders.clear(),this.renderedPages.clear(),this.pageHeights.clear(),this.renderQueue=[],this.scrollHandler&&(null===(t=this.content)||void 0===t||t.removeEventListener("scroll",this.scrollHandler)),n=document.createDocumentFragment(),r=1;case 2:if(!(r<=this.pdfDoc.numPages)){e.next=9;break}return e.prev=3,e.next=4,this.createPageContainer(r);case 4:return o=e.sent,this.pageCanvases.set(r,o),this.renderedPages.add(r),e.next=5,this.pdfDoc.getPage(r);case 5:return s=e.sent,e.next=6,this.getScaleValue(s);case 6:c=e.sent,l=s.getViewport({scale:c,rotation:this.options.rotation}),this.pageHeights.set(r,l.height+20),n.appendChild(o),null===(i=(a=this.options).onPageRendered)||void 0===i||i.call(a,r),e.next=8;break;case 7:e.prev=7,h=e.catch(3),null===(u=(d=this.options).onError)||void 0===u||u.call(d,h);case 8:r++,e.next=2;break;case 9:this.pagesContainer.appendChild(n),this.options.showToolbar&&((p=this.container.querySelector("#".concat(this.instanceId,"-page-input")))&&(p.value=this.currentPage.toString()),this.updateThumbnailActive(this.currentPage));case 10:case"end":return e.stop()}},e,this,[[3,7]])})),function(){return w.apply(this,arguments)})},{key:"renderVirtualPages",value:(k=a(H.mark(function e(){var t,n,r,i,a,o=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:if(this.pagesContainer.innerHTML="",this.pageCanvases.clear(),this.pagePlaceholders.clear(),this.renderedPages.clear(),this.pageHeights.clear(),this.renderQueue=[],this.scrollHandler&&(null===(n=this.content)||void 0===n||n.removeEventListener("scroll",this.scrollHandler)),r=null,"number"==typeof this.currentScale){e.next=6;break}return e.prev=2,e.next=3,this.pdfDoc.getPage(1);case 3:return i=e.sent,e.next=4,this.getScaleValue(i);case 4:r=e.sent,e.next=6;break;case 5:e.prev=5,e.catch(2),r=1;case 6:return e.next=7,this.createPagePlaceholders(r);case 7:return this.scrollHandler=z(function(){return o.handleScroll()},50),null===(t=this.content)||void 0===t||t.addEventListener("scroll",this.scrollHandler),e.next=8,this.renderInitialPages();case 8:return e.next=9,this.renderVisiblePages();case 9:this.options.showToolbar&&((a=this.container.querySelector("#".concat(this.instanceId,"-page-input")))&&(a.value=this.currentPage.toString()),this.updateThumbnailActive(this.currentPage));case 10:case"end":return e.stop()}},e,this,[[2,5]])})),function(){return k.apply(this,arguments)})},{key:"createPagePlaceholders",value:(m=a(H.mark(function e(t){var n,r,i,o,s,c,l,u,d,p,h,f=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:n=document.createDocumentFragment(),r=[],i=H.mark(function e(n){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r.push(a(H.mark(function e(){var r,i,a,o;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,f.pdfDoc.getPage(n);case 1:if(r=e.sent,null===t){e.next=2;break}o=t,e.next=4;break;case 2:return e.next=3,f.getScaleValue(r);case 3:o=e.sent;case 4:return i=o,a=r.getViewport({scale:i,rotation:f.options.rotation}),e.abrupt("return",{i:n,viewport:a,scale:i});case 5:return e.prev=5,e.catch(0),e.abrupt("return",{i:n,viewport:{width:800,height:1e3},scale:1});case 6:case"end":return e.stop()}},e,null,[[0,5]])}))());case 1:case"end":return e.stop()}},e)}),o=1;case 2:if(!(o<=this.pdfDoc.numPages)){e.next=4;break}return e.delegateYield(i(o),"t0",3);case 3:o++,e.next=2;break;case 4:return e.next=5,Promise.all(r);case 5:s=e.sent,c=V(s);try{for(c.s();!(l=c.n()).done;)u=l.value,d=u.i,p=u.viewport,(h=document.createElement("div")).style.width="".concat(p.width,"px"),h.style.height="".concat(p.height,"px"),h.style.margin="0 auto 20px auto",h.style.background="#e0e0e0",h.style.display="flex",h.style.alignItems="center",h.style.justifyContent="center",h.style.color="#999",h.style.fontSize="14px",h.textContent="Loading page ".concat(d,"..."),this.pagePlaceholders.set(d,h),this.pageHeights.set(d,p.height+20),n.appendChild(h)}catch(e){c.e(e)}finally{c.f()}this.pagesContainer.appendChild(n);case 6:case"end":return e.stop()}},e,this)})),function(e){return m.apply(this,arguments)})},{key:"renderInitialPages",value:(y=a(H.mark(function e(){var t,n,r;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&this.content){e.next=1;break}return e.abrupt("return");case 1:t=Math.max(1,this.currentPage-1),n=Math.min(this.pdfDoc.numPages,this.currentPage+1),r=t;case 2:if(!(r<=n)){e.next=4;break}return e.next=3,this.renderSinglePage(r);case 3:r++,e.next=2;break;case 4:case"end":return e.stop()}},e,this)})),function(){return y.apply(this,arguments)})},{key:"renderVisiblePages",value:(x=a(H.mark(function e(){var t,n,r,i,a,o,s,c,l,u,d,p=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.content&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:for(t=this.content.scrollTop,n=this.content.clientHeight,r=this.pageHeights.get(this.currentPage+1)||0,i=Math.max(n,r),a=t-i,o=t+n+i,s=0,c=[],l=1;l<=this.pdfDoc.numPages;l++)u=this.pageHeights.get(l)||0,(d=s+u)>=a&&s<=o&&!this.renderedPages.has(l)&&c.push(l),s=d;this.renderQueue=c.filter(function(e){return!p.renderQueue.includes(e)}),this.processRenderQueue();case 2:case"end":return e.stop()}},e,this)})),function(){return x.apply(this,arguments)})},{key:"processRenderQueue",value:(b=a(H.mark(function e(){var t,n,r=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isRendering&&0!==this.renderQueue.length){e.next=1;break}return e.abrupt("return");case 1:return this.isRendering=!0,t=this.renderQueue.splice(0,this.maxConcurrentRenders),n=t.map(function(e){return r.renderSinglePage(e)}),e.next=2,Promise.all(n);case 2:this.isRendering=!1,this.renderQueue.length>0&&this.processRenderQueue();case 3:case"end":return e.stop()}},e,this)})),function(){return b.apply(this,arguments)})},{key:"renderSinglePage",value:(v=a(H.mark(function e(t){var n,r,i,a,o,s,c;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&!this.renderedPages.has(t)){e.next=1;break}return e.abrupt("return");case 1:if(n=this.pagePlaceholders.get(t)){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=3,this.createPageContainer(t);case 3:a=e.sent,this.pageCanvases.set(t,a),this.renderedPages.add(t),n.parentNode&&n.parentNode.replaceChild(a,n),null===(r=(i=this.options).onPageRendered)||void 0===r||r.call(i,t),e.next=5;break;case 4:e.prev=4,c=e.catch(2),null===(o=(s=this.options).onError)||void 0===o||o.call(s,c);case 5:case"end":return e.stop()}},e,this,[[2,4]])})),function(e){return v.apply(this,arguments)})},{key:"unloadPage",value:function(e){var t=this.pageCanvases.get(e);if(t){var n=this.pagePlaceholders.get(e);n&&t.parentNode&&t.parentNode.replaceChild(n,t),this.pageCanvases.delete(e),this.renderedPages.delete(e)}}},{key:"handleScroll",value:function(){this.renderVisiblePages(),this.updateCurrentPageFromScroll()}},{key:"updateCurrentPageFromScroll",value:function(){if(this.content&&this.pdfDoc&&!this.isNavigating){for(var e=this.content.scrollTop,t=this.content.clientHeight,n=0,r=this.currentPage,i=1;i<=this.pdfDoc.numPages;i++){var a=n+(this.pageHeights.get(i)||0);if(a>e+.3*t&&n<e+.7*t){r=i;break}n=a}if(r!==this.currentPage&&(this.currentPage=r,this.options.showToolbar)){var o=this.container.querySelector("#".concat(this.instanceId,"-page-input"));o&&(o.value=r.toString()),this.updateThumbnailActive(r)}}}},{key:"updateThumbnailActive",value:function(e){this.container.querySelectorAll("#".concat(this.instanceId,"-sidebar-content > div")).forEach(function(t,n){var r=t;n+1===e?(Object.assign(r.style,A.thumbnailActive),r.dataset.active="true"):(Object.keys(A.thumbnailActive).forEach(function(e){r.style.removeProperty(e)}),r.dataset.active="false")})}},{key:"getScaleValue",value:(g=a(H.mark(function e(t){var n,r,i;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("number"!=typeof this.currentScale){e.next=1;break}return e.abrupt("return",this.currentScale);case 1:if("auto"!==this.currentScale&&this.currentScale){e.next=2;break}if(r=t.getViewport({scale:1,rotation:this.options.rotation}),!((i=null===(n=this.content)||void 0===n?void 0:n.clientWidth)>0)){e.next=2;break}return e.abrupt("return",(i-30)/r.width);case 2:return e.abrupt("return",1);case 3:case"end":return e.stop()}},e,this)})),function(e){return g.apply(this,arguments)})},{key:"updatePageUI",value:function(e){if(this.options.showToolbar){var t=this.container.querySelector("#".concat(this.instanceId,"-page-input"));t&&(t.value=e.toString()),this.updateThumbnailActive(e)}}},{key:"nextPage",value:(f=a(H.mark(function e(){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:this.currentPage<this.pdfDoc.numPages&&(this.currentPage=this.currentPage+1,this.scrollToPage(this.currentPage),this.updatePageUI(this.currentPage));case 2:case"end":return e.stop()}},e,this)})),function(){return f.apply(this,arguments)})},{key:"prevPage",value:(h=a(H.mark(function e(){return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.currentPage>1&&(this.currentPage=this.currentPage-1,this.scrollToPage(this.currentPage),this.updatePageUI(this.currentPage));case 1:case"end":return e.stop()}},e,this)})),function(){return h.apply(this,arguments)})},{key:"goToPage",value:(p=a(H.mark(function e(t){var n;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t<1||t>((null===(n=this.pdfDoc)||void 0===n?void 0:n.numPages)||0))){e.next=1;break}return e.abrupt("return");case 1:this.currentPage=t,this.scrollToPage(t),this.updatePageUI(t);case 2:case"end":return e.stop()}},e,this)})),function(e){return p.apply(this,arguments)})},{key:"scrollToPage",value:(d=a(H.mark(function e(t){var n,r,i,a,o,s=this;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.content&&this.pagesContainer){e.next=1;break}return e.abrupt("return");case 1:for(n=0,r=1;r<t;r++)i=this.pageHeights.get(r)||0,n+=i;this.isNavigating=!0,a=setTimeout(function(){var e;s.isNavigating=!1,null===(e=s.content)||void 0===e||e.removeEventListener("scrollend",o),s.handleScroll()},2e3),o=function(){var e;clearTimeout(a),s.isNavigating=!1,null===(e=s.content)||void 0===e||e.removeEventListener("scrollend",o),s.handleScroll()},this.content.addEventListener("scrollend",o),this.content.scrollTo({top:n,behavior:"smooth"});case 2:case"end":return e.stop()}},e,this)})),function(e){return d.apply(this,arguments)})},{key:"zoomIn",value:function(){if("number"==typeof this.currentScale){var e=Math.min(this.currentScale+.25,4);this.setScale(e)}else this.setScale(1)}},{key:"zoomOut",value:function(){if("number"==typeof this.currentScale){var e=Math.max(this.currentScale-.25,.5);this.setScale(e)}else this.setScale(1)}},{key:"findText",value:(u=a(H.mark(function e(t){var n,r,i,a,o,s,c;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&this.pdfDoc){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,e.next=2,this.pdfDoc.getPage(this.currentPage);case 2:return n=e.sent,e.next=3,n.getTextContent();case 3:r=e.sent,i=r.items.filter(function(e){return e.str.includes(t)}),(a=this.container.querySelector("#".concat(this.instanceId,"-find-results")))&&(a.textContent="".concat(i.length," matches")),e.next=5;break;case 4:e.prev=4,c=e.catch(1),null===(o=(s=this.options).onError)||void 0===o||o.call(s,c);case 5:case"end":return e.stop()}},e,this,[[1,4]])})),function(e){return u.apply(this,arguments)})},{key:"findPrevious",value:function(){}},{key:"findNext",value:function(){}},{key:"setScale",value:function(e){this.currentScale=e;var t=this.container.querySelector("select");t&&(t.value=e),this.renderAllPages()}},{key:"setRotation",value:function(e){this.options.rotation=e,this.renderAllPages()}},{key:"getRotation",value:function(){return this.options.rotation}},{key:"getDocumentInfo",value:(s=a(H.mark(function e(){var t,n,r,i,a,o,s,c,l;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc){e.next=1;break}return e.abrupt("return",null);case 1:return e.next=2,this.pdfDoc.getMetadata();case 2:return l=e.sent,e.abrupt("return",{numPages:this.pdfDoc.numPages,fingerprint:this.pdfDoc.fingerprint,title:null==l||null===(t=l.info)||void 0===t?void 0:t.Title,author:null==l||null===(n=l.info)||void 0===n?void 0:n.Author,subject:null==l||null===(r=l.info)||void 0===r?void 0:r.Subject,keywords:null==l||null===(i=l.info)||void 0===i?void 0:i.Keywords,creator:null==l||null===(a=l.info)||void 0===a?void 0:a.Creator,producer:null==l||null===(o=l.info)||void 0===o?void 0:o.Producer,creationDate:null==l||null===(s=l.info)||void 0===s?void 0:s.CreationDate,modificationDate:null==l||null===(c=l.info)||void 0===c?void 0:c.ModDate});case 3:case"end":return e.stop()}},e,this)})),function(){return s.apply(this,arguments)})},{key:"getPageInfo",value:(o=a(H.mark(function e(t){var n,r;return H.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.pdfDoc){e.next=1;break}return e.abrupt("return",null);case 1:return e.prev=1,e.next=2,this.pdfDoc.getPage(t);case 2:return n=e.sent,r=n.getViewport({scale:1}),e.abrupt("return",{pageNumber:t,width:r.width,height:r.height,rotate:r.rotation});case 3:return e.prev=3,e.catch(1),e.abrupt("return",null);case 4:case"end":return e.stop()}},e,this,[[1,3]])})),function(e){return o.apply(this,arguments)})},{key:"getCurrentPage",value:function(){return this.currentPage}},{key:"getTotalPages",value:function(){var e;return(null===(e=this.pdfDoc)||void 0===e?void 0:e.numPages)||0}},{key:"destroy",value:function(){this.cleanup(),this.container&&(this.container.innerHTML="",delete this.container.__pdfPreviewInstance)}},{key:"cleanup",value:function(){var e;if(this.loadingTask&&(this.loadingTask.destroy(),this.loadingTask=null),this.scrollHandler&&(null===(e=this.content)||void 0===e||e.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null),this.sidebarScrollHandler){var t=this.container.querySelector("#".concat(this.instanceId,"-sidebar-content"));t&&t.removeEventListener("scroll",this.sidebarScrollHandler),this.sidebarScrollHandler=null}this.thumbnails.forEach(function(e){if(e&&e.getContext("2d")){var t=e.width,n=e.height;e.width=1,e.height=1,e.width=t,e.height=n}}),this.thumbnails.clear(),this.pageCanvases.forEach(function(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)}),this.pageCanvases.clear(),this.pagePlaceholders.clear(),this.renderedPages.clear(),this.pageHeights.clear(),this.pdfDoc&&(this.pdfDoc.destroy(),this.pdfDoc=null),this.renderQueue=[]}}],n&&c(t.prototype,n),i&&c(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,o,s,u,d,p,h,f,g,v,b,x,y,m,k,w,P,C,S,T,E,L,j,I,O,D}();l(G,"instanceCounter",0);var Q=Symbol("originalInstance"),W={PdfPreview:G,createPdfPreview:function(e){return function(e){return new Proxy(e,{get:function(e,t){if(t===Q)return e;var n=e[t];return"function"==typeof n?function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return n.apply(e,r)}:n}})}(new G(e))}};return W});
|
|
3
|
+
var s,n,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function l(t,i,r,a){var o=i&&i.prototype instanceof c?i:c,l=Object.create(o.prototype);return e(l,"_invoke",function(t,e,i){var r,a,o,l=0,c=i||[],d=!1,u={p:0,n:0,v:s,a:p,f:p.bind(s,4),d:function(t,e){return r=t,a=0,o=s,u.n=e,h}};function p(t,e){for(a=t,o=e,n=0;!d&&l&&!i&&n<c.length;n++){var i,r=c[n],p=u.p,g=r[2];t>3?(i=g===e)&&(o=r[(a=r[4])?5:(a=3,3)],r[4]=r[5]=s):r[0]<=p&&((i=t<2&&p<r[1])?(a=0,u.v=e,u.n=r[1]):p<g&&(i=t<3||r[0]>e||e>g)&&(r[4]=t,r[5]=e,u.n=g,a=0))}if(i||t>1)return h;throw d=!0,e}return function(i,c,g){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&p(c,g),a=c,o=g;(n=a<2?s:o)||!d;){r||(a?a<3?(a>1&&(u.n=-1),p(a,o)):u.n=o:u.v=o);try{if(l=2,r){if(a||(i="next"),n=r[i]){if(!(n=n.call(r,o)))throw TypeError("iterator result is not an object");if(!n.done)return n;o=n.value,a<2&&(a=0)}else 1===a&&(n=r.return)&&n.call(r),a<2&&(o=TypeError("The iterator does not provide a '"+i+"' method"),a=1);r=s}else if((n=(d=u.n<0)?o:t.call(e,u))!==h)break}catch(t){r=s,a=1,o=t}finally{l=1}}return{value:n,done:d}}}(t,r,a),!0),l}var h={};function c(){}function d(){}function u(){}n=Object.getPrototypeOf;var p=[][a]?n(n([][a]())):(e(n={},a,function(){return this}),n),g=u.prototype=c.prototype=Object.create(p);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,e(t,o,"GeneratorFunction")),t.prototype=Object.create(g),t}return d.prototype=u,e(g,"constructor",u),e(u,"constructor",d),d.displayName="GeneratorFunction",e(u,o,"GeneratorFunction"),e(g),e(g,o,"Generator"),e(g,a,function(){return this}),e(g,"toString",function(){return"[object Generator]"}),(t.exports=i=function(){return{w:l,m:f}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}(d);var g=d.exports,f={exports:{}},m={exports:{}},b={exports:{}};!function(t){var e=c,i=p;t.exports=function t(s,n){function r(t,i,a,o){try{var l=s[t](i),h=l.value;return h instanceof e?n.resolve(h.v).then(function(t){r("next",t,a,o)},function(t){r("throw",t,a,o)}):n.resolve(h).then(function(t){l.value=t,a(l)},function(t){return r("throw",t,a,o)})}catch(t){o(t)}}var a;this.next||(i(t.prototype),i(t.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),i(this,"_invoke",function(t,e,i){function s(){return new n(function(e,s){r(t,i,e,s)})}return a=a?a.then(s,s):s()},!0)},t.exports.__esModule=!0,t.exports.default=t.exports}(b);var v=b.exports;!function(t){var e=g,i=v;t.exports=function(t,s,n,r,a){return new i(e().w(t,s,n,r),a||Promise)},t.exports.__esModule=!0,t.exports.default=t.exports}(m);var y=m.exports;!function(t){var e=y;t.exports=function(t,i,s,n,r){var a=e(t,i,s,n,r);return a.next().then(function(t){return t.done?t.value:a.next()})},t.exports.__esModule=!0,t.exports.default=t.exports}(f);var w=f.exports,x={exports:{}};!function(t){t.exports=function(t){var e=Object(t),i=[];for(var s in e)i.unshift(s);return function t(){for(;i.length;)if((s=i.pop())in e)return t.value=s,t.done=!1,t;return t.done=!0,t}},t.exports.__esModule=!0,t.exports.default=t.exports}(x);var A=x.exports,_={exports:{}},S={exports:{}};!function(t){function e(i){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(i)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(S);var C=S.exports;!function(t){var e=C.default;t.exports=function(t){if(null!=t){var i=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],s=0;if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}}}throw new TypeError(e(t)+" is not iterable")},t.exports.__esModule=!0,t.exports.default=t.exports}(_);var E=_.exports;!function(t){var e=c,i=g,s=w,n=y,r=v,a=A,o=E;function l(){var h=i(),c=h.m(l),d=(Object.getPrototypeOf?Object.getPrototypeOf(c):c.__proto__).constructor;function u(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))}var p={throw:1,return:2,break:3,continue:3};function g(t){var e,i;return function(s){e||(e={stop:function(){return i(s.a,2)},catch:function(){return s.v},abrupt:function(t,e){return i(s.a,p[t],e)},delegateYield:function(t,n,r){return e.resultName=n,i(s.d,o(t),r)},finish:function(t){return i(s.f,t)}},i=function(t,i,n){s.p=e.prev,s.n=e.next;try{return t(i,n)}finally{e.next=s.n}}),e.resultName&&(e[e.resultName]=s.v,e.resultName=void 0),e.sent=s.v,e.next=s.n;try{return t.call(this,e)}finally{s.p=e.prev,s.n=e.next}}}return(t.exports=l=function(){return{wrap:function(t,e,i,s){return h.w(g(t),e,i,s&&s.reverse())},isGeneratorFunction:u,mark:h.m,awrap:function(t,i){return new e(t,i)},AsyncIterator:r,async:function(t,e,i,r,a){return(u(e)?n:s)(g(t),e,i,r,a)},keys:a,values:o}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=l,t.exports.__esModule=!0,t.exports.default=t.exports}(l);var T=l.exports,k=T(),P=k;try{regeneratorRuntime=k}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=k:Function("r","regeneratorRuntime = r")(k)}var M=o(P),I={9306:(t,e,i)=>{var s=i(4901),n=i(6823),r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not a function")}},3506:(t,e,i)=>{var s=i(3925),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r("Can't set "+n(t)+" as a prototype")}},7080:(t,e,i)=>{var s=i(4402).has;t.exports=function(t){return s(t),t}},679:(t,e,i)=>{var s=i(1625),n=TypeError;t.exports=function(t,e){if(s(e,t))return t;throw new n("Incorrect invocation")}},8551:(t,e,i)=>{var s=i(34),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not an object")}},7811:t=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7394:(t,e,i)=>{var s=i(4576),n=i(6706),r=i(2195),a=s.ArrayBuffer,o=s.TypeError;t.exports=a&&n(a.prototype,"byteLength","get")||function(t){if("ArrayBuffer"!==r(t))throw new o("ArrayBuffer expected");return t.byteLength}},3238:(t,e,i)=>{var s=i(4576),n=i(7476),r=i(7394),a=s.ArrayBuffer,o=a&&a.prototype,l=o&&n(o.slice);t.exports=function(t){if(0!==r(t))return!1;if(!l)return!1;try{return l(t,0,0),!1}catch(t){return!0}}},5169:(t,e,i)=>{var s=i(3238),n=TypeError;t.exports=function(t){if(s(t))throw new n("ArrayBuffer is detached");return t}},5636:(t,e,i)=>{var s=i(4576),n=i(9504),r=i(6706),a=i(7696),o=i(5169),l=i(7394),h=i(4483),c=i(1548),d=s.structuredClone,u=s.ArrayBuffer,p=s.DataView,g=Math.min,f=u.prototype,m=p.prototype,b=n(f.slice),v=r(f,"resizable","get"),y=r(f,"maxByteLength","get"),w=n(m.getInt8),x=n(m.setInt8);t.exports=(c||h)&&function(t,e,i){var s,n=l(t),r=void 0===e?n:a(e),f=!v||!v(t);if(o(t),c&&(t=d(t,{transfer:[t]}),n===r&&(i||f)))return t;if(n>=r&&(!i||f))s=b(t,0,r);else{var m=i&&!f&&y?{maxByteLength:y(t)}:void 0;s=new u(r,m);for(var A=new p(t),_=new p(s),S=g(r,n),C=0;C<S;C++)x(_,C,w(A,C))}return c||h(t),s}},4644:(t,e,i)=>{var s,n,r,a=i(7811),o=i(3724),l=i(4576),h=i(4901),c=i(34),d=i(9297),u=i(6955),p=i(6823),g=i(6699),f=i(6840),m=i(2106),b=i(1625),v=i(2787),y=i(2967),w=i(8227),x=i(3392),A=i(1181),_=A.enforce,S=A.get,C=l.Int8Array,E=C&&C.prototype,T=l.Uint8ClampedArray,k=T&&T.prototype,P=C&&v(C),M=E&&v(E),I=Object.prototype,D=l.TypeError,R=w("toStringTag"),L=x("TYPED_ARRAY_TAG"),F="TypedArrayConstructor",O=a&&!!y&&"Opera"!==u(l.opera),N=!1,B={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},z={BigInt64Array:8,BigUint64Array:8},H=function(t){var e=v(t);if(c(e)){var i=S(e);return i&&d(i,F)?i[F]:H(e)}},j=function(t){if(!c(t))return!1;var e=u(t);return d(B,e)||d(z,e)};for(s in B)(r=(n=l[s])&&n.prototype)?_(r)[F]=n:O=!1;for(s in z)(r=(n=l[s])&&n.prototype)&&(_(r)[F]=n);if((!O||!h(P)||P===Function.prototype)&&(P=function(){throw new D("Incorrect invocation")},O))for(s in B)l[s]&&y(l[s],P);if((!O||!M||M===I)&&(M=P.prototype,O))for(s in B)l[s]&&y(l[s].prototype,M);if(O&&v(k)!==M&&y(k,M),o&&!d(M,R))for(s in N=!0,m(M,R,{configurable:!0,get:function(){return c(this)?this[L]:void 0}}),B)l[s]&&g(l[s],L,s);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:O,TYPED_ARRAY_TAG:N&&L,aTypedArray:function(t){if(j(t))return t;throw new D("Target is not a typed array")},aTypedArrayConstructor:function(t){if(h(t)&&(!y||b(P,t)))return t;throw new D(p(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,e,i,s){if(o){if(i)for(var n in B){var r=l[n];if(r&&d(r.prototype,t))try{delete r.prototype[t]}catch(i){try{r.prototype[t]=e}catch(t){}}}M[t]&&!i||f(M,t,i?e:O&&E[t]||e,s)}},exportTypedArrayStaticMethod:function(t,e,i){var s,n;if(o){if(y){if(i)for(s in B)if((n=l[s])&&d(n,t))try{delete n[t]}catch(t){}if(P[t]&&!i)return;try{return f(P,t,i?e:O&&P[t]||e)}catch(t){}}for(s in B)!(n=l[s])||n[t]&&!i||f(n,t,e)}},getTypedArrayConstructor:H,isView:function(t){if(!c(t))return!1;var e=u(t);return"DataView"===e||d(B,e)||d(z,e)},isTypedArray:j,TypedArray:P,TypedArrayPrototype:M}},5370:(t,e,i)=>{var s=i(6198);t.exports=function(t,e,i){for(var n=0,r=arguments.length>2?i:s(e),a=new t(r);r>n;)a[n]=e[n++];return a}},9617:(t,e,i)=>{var s=i(5397),n=i(5610),r=i(6198),a=function(t){return function(e,i,a){var o=s(e),l=r(o);if(0===l)return!t&&-1;var h,c=n(a,l);if(t&&i!=i){for(;l>c;)if((h=o[c++])!=h)return!0}else for(;l>c;c++)if((t||c in o)&&o[c]===i)return t||c||0;return!t&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},4527:(t,e,i)=>{var s=i(3724),n=i(4376),r=TypeError,a=Object.getOwnPropertyDescriptor,o=s&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();t.exports=o?function(t,e){if(n(t)&&!a(t,"length").writable)throw new r("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},7680:(t,e,i)=>{var s=i(9504);t.exports=s([].slice)},7628:(t,e,i)=>{var s=i(6198);t.exports=function(t,e){for(var i=s(t),n=new e(i),r=0;r<i;r++)n[r]=t[i-r-1];return n}},9928:(t,e,i)=>{var s=i(6198),n=i(1291),r=RangeError;t.exports=function(t,e,i,a){var o=s(t),l=n(i),h=l<0?o+l:l;if(h>=o||h<0)throw new r("Incorrect index");for(var c=new e(o),d=0;d<o;d++)c[d]=d===h?a:t[d];return c}},6319:(t,e,i)=>{var s=i(8551),n=i(9539);t.exports=function(t,e,i,r){try{return r?e(s(i)[0],i[1]):e(i)}catch(e){n(t,"throw",e)}}},2195:(t,e,i)=>{var s=i(9504),n=s({}.toString),r=s("".slice);t.exports=function(t){return r(n(t),8,-1)}},6955:(t,e,i)=>{var s=i(2140),n=i(4901),r=i(2195),a=i(8227)("toStringTag"),o=Object,l="Arguments"===r(function(){return arguments}());t.exports=s?r:function(t){var e,i,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=o(t),a))?i:l?r(e):"Object"===(s=r(e))&&n(e.callee)?"Arguments":s}},7740:(t,e,i)=>{var s=i(9297),n=i(5031),r=i(7347),a=i(4913);t.exports=function(t,e,i){for(var o=n(e),l=a.f,h=r.f,c=0;c<o.length;c++){var d=o[c];s(t,d)||i&&s(i,d)||l(t,d,h(e,d))}}},2211:(t,e,i)=>{var s=i(9039);t.exports=!s(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})},2529:t=>{t.exports=function(t,e){return{value:t,done:e}}},6699:(t,e,i)=>{var s=i(3724),n=i(4913),r=i(6980);t.exports=s?function(t,e,i){return n.f(t,e,r(1,i))}:function(t,e,i){return t[e]=i,t}},6980:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},4659:(t,e,i)=>{var s=i(3724),n=i(4913),r=i(6980);t.exports=function(t,e,i){s?n.f(t,e,r(0,i)):t[e]=i}},2106:(t,e,i)=>{var s=i(283),n=i(4913);t.exports=function(t,e,i){return i.get&&s(i.get,e,{getter:!0}),i.set&&s(i.set,e,{setter:!0}),n.f(t,e,i)}},6840:(t,e,i)=>{var s=i(4901),n=i(4913),r=i(283),a=i(9433);t.exports=function(t,e,i,o){o||(o={});var l=o.enumerable,h=void 0!==o.name?o.name:e;if(s(i)&&r(i,h,o),o.global)l?t[e]=i:a(e,i);else{try{o.unsafe?t[e]&&(l=!0):delete t[e]}catch(t){}l?t[e]=i:n.f(t,e,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return t}},6279:(t,e,i)=>{var s=i(6840);t.exports=function(t,e,i){for(var n in e)s(t,n,e[n],i);return t}},9433:(t,e,i)=>{var s=i(4576),n=Object.defineProperty;t.exports=function(t,e){try{n(s,t,{value:e,configurable:!0,writable:!0})}catch(i){s[t]=e}return e}},3724:(t,e,i)=>{var s=i(9039);t.exports=!s(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})},4483:(t,e,i)=>{var s,n,r,a,o=i(4576),l=i(9429),h=i(1548),c=o.structuredClone,d=o.ArrayBuffer,u=o.MessageChannel,p=!1;if(h)p=function(t){c(t,{transfer:[t]})};else if(d)try{u||(s=l("worker_threads"))&&(u=s.MessageChannel),u&&(n=new u,r=new d(2),a=function(t){n.port1.postMessage(null,[t])},2===r.byteLength&&(a(r),0===r.byteLength&&(p=a)))}catch(t){}t.exports=p},4055:(t,e,i)=>{var s=i(4576),n=i(34),r=s.document,a=n(r)&&n(r.createElement);t.exports=function(t){return a?r.createElement(t):{}}},6837:t=>{var e=TypeError;t.exports=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}},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"]},6193:(t,e,i)=>{var s=i(4215);t.exports="NODE"===s},2839:(t,e,i)=>{var s=i(4576).navigator,n=s&&s.userAgent;t.exports=n?String(n):""},9519:(t,e,i)=>{var s,n,r=i(4576),a=i(2839),o=r.process,l=r.Deno,h=o&&o.versions||l&&l.version,c=h&&h.v8;c&&(n=(s=c.split("."))[0]>0&&s[0]<4?1:+(s[0]+s[1])),!n&&a&&(!(s=a.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=a.match(/Chrome\/(\d+)/))&&(n=+s[1]),t.exports=n},4215:(t,e,i)=>{var s=i(4576),n=i(2839),r=i(2195),a=function(t){return n.slice(0,t.length)===t};t.exports=a("Bun/")?"BUN":a("Cloudflare-Workers")?"CLOUDFLARE":a("Deno/")?"DENO":a("Node.js/")?"NODE":s.Bun&&"string"==typeof Bun.version?"BUN":s.Deno&&"object"==typeof Deno.version?"DENO":"process"===r(s.process)?"NODE":s.window&&s.document?"BROWSER":"REST"},8574:(t,e,i)=>{var s=i(9504),n=Error,r=s("".replace),a=String(new n("zxcasd").stack),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(a);t.exports=function(t,e){if(l&&"string"==typeof t&&!n.prepareStackTrace)for(;e--;)t=r(t,o,"");return t}},6518:(t,e,i)=>{var s=i(4576),n=i(7347).f,r=i(6699),a=i(6840),o=i(9433),l=i(7740),h=i(2796);t.exports=function(t,e){var i,c,d,u,p,g=t.target,f=t.global,m=t.stat;if(i=f?s:m?s[g]||o(g,{}):s[g]&&s[g].prototype)for(c in e){if(u=e[c],d=t.dontCallGetSet?(p=n(i,c))&&p.value:i[c],!h(f?c:g+(m?".":"#")+c,t.forced)&&void 0!==d){if(typeof u==typeof d)continue;l(u,d)}(t.sham||d&&d.sham)&&r(u,"sham",!0),a(i,c,u,t)}}},9039:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},8745:(t,e,i)=>{var s=i(616),n=Function.prototype,r=n.apply,a=n.call;t.exports="object"==typeof Reflect&&Reflect.apply||(s?a.bind(r):function(){return a.apply(r,arguments)})},6080:(t,e,i)=>{var s=i(7476),n=i(9306),r=i(616),a=s(s.bind);t.exports=function(t,e){return n(t),void 0===e?t:r?a(t,e):function(){return t.apply(e,arguments)}}},616:(t,e,i)=>{var s=i(9039);t.exports=!s(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})},9565:(t,e,i)=>{var s=i(616),n=Function.prototype.call;t.exports=s?n.bind(n):function(){return n.apply(n,arguments)}},350:(t,e,i)=>{var s=i(3724),n=i(9297),r=Function.prototype,a=s&&Object.getOwnPropertyDescriptor,o=n(r,"name"),l=o&&"something"===function(){}.name,h=o&&(!s||s&&a(r,"name").configurable);t.exports={EXISTS:o,PROPER:l,CONFIGURABLE:h}},6706:(t,e,i)=>{var s=i(9504),n=i(9306);t.exports=function(t,e,i){try{return s(n(Object.getOwnPropertyDescriptor(t,e)[i]))}catch(t){}}},7476:(t,e,i)=>{var s=i(2195),n=i(9504);t.exports=function(t){if("Function"===s(t))return n(t)}},9504:(t,e,i)=>{var s=i(616),n=Function.prototype,r=n.call,a=s&&n.bind.bind(r,r);t.exports=s?a:function(t){return function(){return r.apply(t,arguments)}}},9429:(t,e,i)=>{var s=i(4576),n=i(6193);t.exports=function(t){if(n){try{return s.process.getBuiltinModule(t)}catch(t){}try{return Function('return require("'+t+'")')()}catch(t){}}}},7751:(t,e,i)=>{var s=i(4576),n=i(4901);t.exports=function(t,e){return arguments.length<2?(i=s[t],n(i)?i:void 0):s[t]&&s[t][e];var i}},1767:t=>{t.exports=function(t){return{iterator:t,next:t.next,done:!1}}},8646:(t,e,i)=>{var s=i(9565),n=i(8551),r=i(1767),a=i(851);t.exports=function(t,e){e&&"string"==typeof t||n(t);var i=a(t);return r(n(void 0!==i?s(i,t):t))}},851:(t,e,i)=>{var s=i(6955),n=i(5966),r=i(4117),a=i(6269),o=i(8227)("iterator");t.exports=function(t){if(!r(t))return n(t,o)||n(t,"@@iterator")||a[s(t)]}},81:(t,e,i)=>{var s=i(9565),n=i(9306),r=i(8551),a=i(6823),o=i(851),l=TypeError;t.exports=function(t,e){var i=arguments.length<2?o(t):e;if(n(i))return r(s(i,t));throw new l(a(t)+" is not iterable")}},5966:(t,e,i)=>{var s=i(9306),n=i(4117);t.exports=function(t,e){var i=t[e];return n(i)?void 0:s(i)}},3789:(t,e,i)=>{var s=i(9306),n=i(8551),r=i(9565),a=i(1291),o=i(1767),l="Invalid size",h=RangeError,c=TypeError,d=Math.max,u=function(t,e){this.set=t,this.size=d(e,0),this.has=s(t.has),this.keys=s(t.keys)};u.prototype={getIterator:function(){return o(n(r(this.keys,this.set)))},includes:function(t){return r(this.has,this.set,t)}},t.exports=function(t){n(t);var e=+t.size;if(e!=e)throw new c(l);var i=a(e);if(i<0)throw new h(l);return new u(t,i)}},4576:function(t){var e=function(t){return t&&t.Math===Math&&t};t.exports=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof global&&global)||e("object"==typeof this&&this)||function(){return this}()||Function("return this")()},9297:(t,e,i)=>{var s=i(9504),n=i(8981),r=s({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return r(n(t),e)}},421:t=>{t.exports={}},397:(t,e,i)=>{var s=i(7751);t.exports=s("document","documentElement")},5917:(t,e,i)=>{var s=i(3724),n=i(9039),r=i(4055);t.exports=!s&&!n(function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a})},7055:(t,e,i)=>{var s=i(9504),n=i(9039),r=i(2195),a=Object,o=s("".split);t.exports=n(function(){return!a("z").propertyIsEnumerable(0)})?function(t){return"String"===r(t)?o(t,""):a(t)}:a},3167:(t,e,i)=>{var s=i(4901),n=i(34),r=i(2967);t.exports=function(t,e,i){var a,o;return r&&s(a=e.constructor)&&a!==i&&n(o=a.prototype)&&o!==i.prototype&&r(t,o),t}},3706:(t,e,i)=>{var s=i(9504),n=i(4901),r=i(7629),a=s(Function.toString);n(r.inspectSource)||(r.inspectSource=function(t){return a(t)}),t.exports=r.inspectSource},1181:(t,e,i)=>{var s,n,r,a=i(8622),o=i(4576),l=i(34),h=i(6699),c=i(9297),d=i(7629),u=i(6119),p=i(421),g="Object already initialized",f=o.TypeError,m=o.WeakMap;if(a||d.state){var b=d.state||(d.state=new m);b.get=b.get,b.has=b.has,b.set=b.set,s=function(t,e){if(b.has(t))throw new f(g);return e.facade=t,b.set(t,e),e},n=function(t){return b.get(t)||{}},r=function(t){return b.has(t)}}else{var v=u("state");p[v]=!0,s=function(t,e){if(c(t,v))throw new f(g);return e.facade=t,h(t,v,e),e},n=function(t){return c(t,v)?t[v]:{}},r=function(t){return c(t,v)}}t.exports={set:s,get:n,has:r,enforce:function(t){return r(t)?n(t):s(t,{})},getterFor:function(t){return function(e){var i;if(!l(e)||(i=n(e)).type!==t)throw new f("Incompatible receiver, "+t+" required");return i}}}},4209:(t,e,i)=>{var s=i(8227),n=i(6269),r=s("iterator"),a=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||a[r]===t)}},4376:(t,e,i)=>{var s=i(2195);t.exports=Array.isArray||function(t){return"Array"===s(t)}},1108:(t,e,i)=>{var s=i(6955);t.exports=function(t){var e=s(t);return"BigInt64Array"===e||"BigUint64Array"===e}},4901:t=>{var e="object"==typeof document&&document.all;t.exports=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(t){return"function"==typeof t}},2796:(t,e,i)=>{var s=i(9039),n=i(4901),r=/#|\.prototype\./,a=function(t,e){var i=l[o(t)];return i===c||i!==h&&(n(e)?s(e):!!e)},o=a.normalize=function(t){return String(t).replace(r,".").toLowerCase()},l=a.data={},h=a.NATIVE="N",c=a.POLYFILL="P";t.exports=a},4117:t=>{t.exports=function(t){return null==t}},34:(t,e,i)=>{var s=i(4901);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},3925:(t,e,i)=>{var s=i(34);t.exports=function(t){return s(t)||null===t}},6395:t=>{t.exports=!1},757:(t,e,i)=>{var s=i(7751),n=i(4901),r=i(1625),a=i(7040),o=Object;t.exports=a?function(t){return"symbol"==typeof t}:function(t){var e=s("Symbol");return n(e)&&r(e.prototype,o(t))}},507:(t,e,i)=>{var s=i(9565);t.exports=function(t,e,i){for(var n,r,a=i?t:t.iterator,o=t.next;!(n=s(o,a)).done;)if(void 0!==(r=e(n.value)))return r}},2652:(t,e,i)=>{var s=i(6080),n=i(9565),r=i(8551),a=i(6823),o=i(4209),l=i(6198),h=i(1625),c=i(81),d=i(851),u=i(9539),p=TypeError,g=function(t,e){this.stopped=t,this.result=e},f=g.prototype;t.exports=function(t,e,i){var m,b,v,y,w,x,A,_=i&&i.that,S=!(!i||!i.AS_ENTRIES),C=!(!i||!i.IS_RECORD),E=!(!i||!i.IS_ITERATOR),T=!(!i||!i.INTERRUPTED),k=s(e,_),P=function(t){return m&&u(m,"normal",t),new g(!0,t)},M=function(t){return S?(r(t),T?k(t[0],t[1],P):k(t[0],t[1])):T?k(t,P):k(t)};if(C)m=t.iterator;else if(E)m=t;else{if(!(b=d(t)))throw new p(a(t)+" is not iterable");if(o(b)){for(v=0,y=l(t);y>v;v++)if((w=M(t[v]))&&h(f,w))return w;return new g(!1)}m=c(t,b)}for(x=C?t.next:m.next;!(A=n(x,m)).done;){try{w=M(A.value)}catch(t){u(m,"throw",t)}if("object"==typeof w&&w&&h(f,w))return w}return new g(!1)}},9539:(t,e,i)=>{var s=i(9565),n=i(8551),r=i(5966);t.exports=function(t,e,i){var a,o;n(t);try{if(!(a=r(t,"return"))){if("throw"===e)throw i;return i}a=s(a,t)}catch(t){o=!0,a=t}if("throw"===e)throw i;if(o)throw a;return n(a),i}},9462:(t,e,i)=>{var s=i(9565),n=i(2360),r=i(6699),a=i(6279),o=i(8227),l=i(1181),h=i(5966),c=i(7657).IteratorPrototype,d=i(2529),u=i(9539),p=o("toStringTag"),g="IteratorHelper",f="WrapForValidIterator",m=l.set,b=function(t){var e=l.getterFor(t?f:g);return a(n(c),{next:function(){var i=e(this);if(t)return i.nextHandler();try{var s=i.done?void 0:i.nextHandler();return d(s,i.done)}catch(t){throw i.done=!0,t}},return:function(){var i=e(this),n=i.iterator;if(i.done=!0,t){var r=h(n,"return");return r?s(r,n):d(void 0,!0)}if(i.inner)try{u(i.inner.iterator,"normal")}catch(t){return u(n,"throw",t)}return n&&u(n,"normal"),d(void 0,!0)}})},v=b(!0),y=b(!1);r(y,p,"Iterator Helper"),t.exports=function(t,e){var i=function(i,s){s?(s.iterator=i.iterator,s.next=i.next):s=i,s.type=e?f:g,s.nextHandler=t,s.counter=0,s.done=!1,m(this,s)};return i.prototype=e?v:y,i}},713:(t,e,i)=>{var s=i(9565),n=i(9306),r=i(8551),a=i(1767),o=i(9462),l=i(6319),h=o(function(){var t=this.iterator,e=r(s(this.next,t));if(!(this.done=!!e.done))return l(t,this.mapper,[e.value,this.counter++],!0)});t.exports=function(t){return r(this),n(t),new h(a(this),{mapper:t})}},7657:(t,e,i)=>{var s,n,r,a=i(9039),o=i(4901),l=i(34),h=i(2360),c=i(2787),d=i(6840),u=i(8227),p=i(6395),g=u("iterator"),f=!1;[].keys&&("next"in(r=[].keys())?(n=c(c(r)))!==Object.prototype&&(s=n):f=!0),!l(s)||a(function(){var t={};return s[g].call(t)!==t})?s={}:p&&(s=h(s)),o(s[g])||d(s,g,function(){return this}),t.exports={IteratorPrototype:s,BUGGY_SAFARI_ITERATORS:f}},6269:t=>{t.exports={}},6198:(t,e,i)=>{var s=i(8014);t.exports=function(t){return s(t.length)}},283:(t,e,i)=>{var s=i(9504),n=i(9039),r=i(4901),a=i(9297),o=i(3724),l=i(350).CONFIGURABLE,h=i(3706),c=i(1181),d=c.enforce,u=c.get,p=String,g=Object.defineProperty,f=s("".slice),m=s("".replace),b=s([].join),v=o&&!n(function(){return 8!==g(function(){},"length",{value:8}).length}),y=String(String).split("String"),w=t.exports=function(t,e,i){"Symbol("===f(p(e),0,7)&&(e="["+m(p(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!a(t,"name")||l&&t.name!==e)&&(o?g(t,"name",{value:e,configurable:!0}):t.name=e),v&&i&&a(i,"arity")&&t.length!==i.arity&&g(t,"length",{value:i.arity});try{i&&a(i,"constructor")&&i.constructor?o&&g(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var s=d(t);return a(s,"source")||(s.source=b(y,"string"==typeof e?e:"")),t};Function.prototype.toString=w(function(){return r(this)&&u(this).source||h(this)},"toString")},741:t=>{var e=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(t){var s=+t;return(s>0?i:e)(s)}},6043:(t,e,i)=>{var s=i(9306),n=TypeError,r=function(t){var e,i;this.promise=new t(function(t,s){if(void 0!==e||void 0!==i)throw new n("Bad Promise constructor");e=t,i=s}),this.resolve=s(e),this.reject=s(i)};t.exports.f=function(t){return new r(t)}},2603:(t,e,i)=>{var s=i(655);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:s(t)}},4149:t=>{var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},2360:(t,e,i)=>{var s,n=i(8551),r=i(6801),a=i(8727),o=i(421),l=i(397),h=i(4055),c=i(6119),d="prototype",u="script",p=c("IE_PROTO"),g=function(){},f=function(t){return"<"+u+">"+t+"</"+u+">"},m=function(t){t.write(f("")),t.close();var e=t.parentWindow.Object;return t=null,e},b=function(){try{s=new ActiveXObject("htmlfile")}catch(t){}var t,e,i;b="undefined"!=typeof document?document.domain&&s?m(s):(e=h("iframe"),i="java"+u+":",e.style.display="none",l.appendChild(e),e.src=String(i),(t=e.contentWindow.document).open(),t.write(f("document.F=Object")),t.close(),t.F):m(s);for(var n=a.length;n--;)delete b[d][a[n]];return b()};o[p]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(g[d]=n(t),i=new g,g[d]=null,i[p]=t):i=b(),void 0===e?i:r.f(i,e)}},6801:(t,e,i)=>{var s=i(3724),n=i(8686),r=i(4913),a=i(8551),o=i(5397),l=i(1072);e.f=s&&!n?Object.defineProperties:function(t,e){a(t);for(var i,s=o(e),n=l(e),h=n.length,c=0;h>c;)r.f(t,i=n[c++],s[i]);return t}},4913:(t,e,i)=>{var s=i(3724),n=i(5917),r=i(8686),a=i(8551),o=i(6969),l=TypeError,h=Object.defineProperty,c=Object.getOwnPropertyDescriptor,d="enumerable",u="configurable",p="writable";e.f=s?r?function(t,e,i){if(a(t),e=o(e),a(i),"function"==typeof t&&"prototype"===e&&"value"in i&&p in i&&!i[p]){var s=c(t,e);s&&s[p]&&(t[e]=i.value,i={configurable:u in i?i[u]:s[u],enumerable:d in i?i[d]:s[d],writable:!1})}return h(t,e,i)}:h:function(t,e,i){if(a(t),e=o(e),a(i),n)try{return h(t,e,i)}catch(t){}if("get"in i||"set"in i)throw new l("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},7347:(t,e,i)=>{var s=i(3724),n=i(9565),r=i(8773),a=i(6980),o=i(5397),l=i(6969),h=i(9297),c=i(5917),d=Object.getOwnPropertyDescriptor;e.f=s?d:function(t,e){if(t=o(t),e=l(e),c)try{return d(t,e)}catch(t){}if(h(t,e))return a(!n(r.f,t,e),t[e])}},8480:(t,e,i)=>{var s=i(1828),n=i(8727).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,n)}},3717:(t,e)=>{e.f=Object.getOwnPropertySymbols},2787:(t,e,i)=>{var s=i(9297),n=i(4901),r=i(8981),a=i(6119),o=i(2211),l=a("IE_PROTO"),h=Object,c=h.prototype;t.exports=o?h.getPrototypeOf:function(t){var e=r(t);if(s(e,l))return e[l];var i=e.constructor;return n(i)&&e instanceof i?i.prototype:e instanceof h?c:null}},1625:(t,e,i)=>{var s=i(9504);t.exports=s({}.isPrototypeOf)},1828:(t,e,i)=>{var s=i(9504),n=i(9297),r=i(5397),a=i(9617).indexOf,o=i(421),l=s([].push);t.exports=function(t,e){var i,s=r(t),h=0,c=[];for(i in s)!n(o,i)&&n(s,i)&&l(c,i);for(;e.length>h;)n(s,i=e[h++])&&(~a(c,i)||l(c,i));return c}},1072:(t,e,i)=>{var s=i(1828),n=i(8727);t.exports=Object.keys||function(t){return s(t,n)}},8773:(t,e)=>{var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,n=s&&!i.call({1:2},1);e.f=n?function(t){var e=s(this,t);return!!e&&e.enumerable}:i},2967:(t,e,i)=>{var s=i(6706),n=i(34),r=i(7750),a=i(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,i={};try{(t=s(Object.prototype,"__proto__","set"))(i,[]),e=i instanceof Array}catch(t){}return function(i,s){return r(i),a(s),n(i)?(e?t(i,s):i.__proto__=s,i):i}}():void 0)},4270:(t,e,i)=>{var s=i(9565),n=i(4901),r=i(34),a=TypeError;t.exports=function(t,e){var i,o;if("string"===e&&n(i=t.toString)&&!r(o=s(i,t)))return o;if(n(i=t.valueOf)&&!r(o=s(i,t)))return o;if("string"!==e&&n(i=t.toString)&&!r(o=s(i,t)))return o;throw new a("Can't convert object to primitive value")}},5031:(t,e,i)=>{var s=i(7751),n=i(9504),r=i(8480),a=i(3717),o=i(8551),l=n([].concat);t.exports=s("Reflect","ownKeys")||function(t){var e=r.f(o(t)),i=a.f;return i?l(e,i(t)):e}},8235:(t,e,i)=>{var s=i(9504),n=i(9297),r=SyntaxError,a=parseInt,o=String.fromCharCode,l=s("".charAt),h=s("".slice),c=s(/./.exec),d={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t"},u=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;t.exports=function(t,e){for(var i=!0,s="";e<t.length;){var g=l(t,e);if("\\"===g){var f=h(t,e,e+2);if(n(d,f))s+=d[f],e+=2;else{if("\\u"!==f)throw new r('Unknown escape sequence: "'+f+'"');var m=h(t,e+=2,e+4);if(!c(u,m))throw new r("Bad Unicode escape at: "+e);s+=o(a(m,16)),e+=4}}else{if('"'===g){i=!1,e++;break}if(c(p,g))throw new r("Bad control character in string literal at: "+e);s+=g,e++}}if(i)throw new r("Unterminated string at: "+e);return{value:s,end:e}}},1103:t=>{t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},7750:(t,e,i)=>{var s=i(4117),n=TypeError;t.exports=function(t){if(s(t))throw new n("Can't call method on "+t);return t}},9286:(t,e,i)=>{var s=i(4402),n=i(8469),r=s.Set,a=s.add;t.exports=function(t){var e=new r;return n(t,function(t){a(e,t)}),e}},3440:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(9286),a=i(5170),o=i(3789),l=i(8469),h=i(507),c=n.has,d=n.remove;t.exports=function(t){var e=s(this),i=o(t),n=r(e);return a(e)<=i.size?l(e,function(t){i.includes(t)&&d(n,t)}):h(i.getIterator(),function(t){c(e,t)&&d(n,t)}),n}},4402:(t,e,i)=>{var s=i(9504),n=Set.prototype;t.exports={Set:Set,add:s(n.add),has:s(n.has),remove:s(n.delete),proto:n}},8750:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(5170),a=i(3789),o=i(8469),l=i(507),h=n.Set,c=n.add,d=n.has;t.exports=function(t){var e=s(this),i=a(t),n=new h;return r(e)>i.size?l(i.getIterator(),function(t){d(e,t)&&c(n,t)}):o(e,function(t){i.includes(t)&&c(n,t)}),n}},4449:(t,e,i)=>{var s=i(7080),n=i(4402).has,r=i(5170),a=i(3789),o=i(8469),l=i(507),h=i(9539);t.exports=function(t){var e=s(this),i=a(t);if(r(e)<=i.size)return!1!==o(e,function(t){if(i.includes(t))return!1},!0);var c=i.getIterator();return!1!==l(c,function(t){if(n(e,t))return h(c,"normal",!1)})}},3838:(t,e,i)=>{var s=i(7080),n=i(5170),r=i(8469),a=i(3789);t.exports=function(t){var e=s(this),i=a(t);return!(n(e)>i.size)&&!1!==r(e,function(t){if(!i.includes(t))return!1},!0)}},8527:(t,e,i)=>{var s=i(7080),n=i(4402).has,r=i(5170),a=i(3789),o=i(507),l=i(9539);t.exports=function(t){var e=s(this),i=a(t);if(r(e)<i.size)return!1;var h=i.getIterator();return!1!==o(h,function(t){if(!n(e,t))return l(h,"normal",!1)})}},8469:(t,e,i)=>{var s=i(9504),n=i(507),r=i(4402),a=r.Set,o=r.proto,l=s(o.forEach),h=s(o.keys),c=h(new a).next;t.exports=function(t,e,i){return i?n({iterator:h(t),next:c},e):l(t,e)}},4916:(t,e,i)=>{var s=i(7751),n=function(t){return{size:t,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}};t.exports=function(t){var e=s("Set");try{(new e)[t](n(0));try{return(new e)[t](n(-1)),!1}catch(t){return!0}}catch(t){return!1}}},5170:(t,e,i)=>{var s=i(6706),n=i(4402);t.exports=s(n.proto,"size","get")||function(t){return t.size}},3650:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(9286),a=i(3789),o=i(507),l=n.add,h=n.has,c=n.remove;t.exports=function(t){var e=s(this),i=a(t).getIterator(),n=r(e);return o(i,function(t){h(e,t)?c(n,t):l(n,t)}),n}},4204:(t,e,i)=>{var s=i(7080),n=i(4402).add,r=i(9286),a=i(3789),o=i(507);t.exports=function(t){var e=s(this),i=a(t).getIterator(),l=r(e);return o(i,function(t){n(l,t)}),l}},6119:(t,e,i)=>{var s=i(5745),n=i(3392),r=s("keys");t.exports=function(t){return r[t]||(r[t]=n(t))}},7629:(t,e,i)=>{var s=i(6395),n=i(4576),r=i(9433),a="__core-js_shared__",o=t.exports=n[a]||r(a,{});(o.versions||(o.versions=[])).push({version:"3.39.0",mode:s?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745:(t,e,i)=>{var s=i(7629);t.exports=function(t,e){return s[t]||(s[t]=e||{})}},1548:(t,e,i)=>{var s=i(4576),n=i(9039),r=i(9519),a=i(4215),o=s.structuredClone;t.exports=!!o&&!n(function(){if("DENO"===a&&r>92||"NODE"===a&&r>94||"BROWSER"===a&&r>97)return!1;var t=new ArrayBuffer(8),e=o(t,{transfer:[t]});return 0!==t.byteLength||8!==e.byteLength})},4495:(t,e,i)=>{var s=i(9519),n=i(9039),r=i(4576).String;t.exports=!!Object.getOwnPropertySymbols&&!n(function(){var t=Symbol("symbol detection");return!r(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41})},5610:(t,e,i)=>{var s=i(1291),n=Math.max,r=Math.min;t.exports=function(t,e){var i=s(t);return i<0?n(i+e,0):r(i,e)}},5854:(t,e,i)=>{var s=i(2777),n=TypeError;t.exports=function(t){var e=s(t,"number");if("number"==typeof e)throw new n("Can't convert number to bigint");return BigInt(e)}},7696:(t,e,i)=>{var s=i(1291),n=i(8014),r=RangeError;t.exports=function(t){if(void 0===t)return 0;var e=s(t),i=n(e);if(e!==i)throw new r("Wrong length or index");return i}},5397:(t,e,i)=>{var s=i(7055),n=i(7750);t.exports=function(t){return s(n(t))}},1291:(t,e,i)=>{var s=i(741);t.exports=function(t){var e=+t;return e!=e||0===e?0:s(e)}},8014:(t,e,i)=>{var s=i(1291),n=Math.min;t.exports=function(t){var e=s(t);return e>0?n(e,9007199254740991):0}},8981:(t,e,i)=>{var s=i(7750),n=Object;t.exports=function(t){return n(s(t))}},9590:(t,e,i)=>{var s=i(1291),n=RangeError;t.exports=function(t){var e=s(t);if(e<0)throw new n("The argument can't be less than 0");return e}},2777:(t,e,i)=>{var s=i(9565),n=i(34),r=i(757),a=i(5966),o=i(4270),l=i(8227),h=TypeError,c=l("toPrimitive");t.exports=function(t,e){if(!n(t)||r(t))return t;var i,l=a(t,c);if(l){if(void 0===e&&(e="default"),i=s(l,t,e),!n(i)||r(i))return i;throw new h("Can't convert object to primitive value")}return void 0===e&&(e="number"),o(t,e)}},6969:(t,e,i)=>{var s=i(2777),n=i(757);t.exports=function(t){var e=s(t,"string");return n(e)?e:e+""}},2140:(t,e,i)=>{var s={};s[i(8227)("toStringTag")]="z",t.exports="[object z]"===String(s)},655:(t,e,i)=>{var s=i(6955),n=String;t.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return n(t)}},6823:t=>{var e=String;t.exports=function(t){try{return e(t)}catch(t){return"Object"}}},3392:(t,e,i)=>{var s=i(9504),n=0,r=Math.random(),a=s(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+a(++n+r,36)}},7040:(t,e,i)=>{var s=i(4495);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},8686:(t,e,i)=>{var s=i(3724),n=i(9039);t.exports=s&&n(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})},2812:t=>{var e=TypeError;t.exports=function(t,i){if(t<i)throw new e("Not enough arguments");return t}},8622:(t,e,i)=>{var s=i(4576),n=i(4901),r=s.WeakMap;t.exports=n(r)&&/native code/.test(String(r))},8227:(t,e,i)=>{var s=i(4576),n=i(5745),r=i(9297),a=i(3392),o=i(4495),l=i(7040),h=s.Symbol,c=n("wks"),d=l?h.for||h:h&&h.withoutSetter||a;t.exports=function(t){return r(c,t)||(c[t]=o&&r(h,t)?h[t]:d("Symbol."+t)),c[t]}},6573:(t,e,i)=>{var s=i(3724),n=i(2106),r=i(3238),a=ArrayBuffer.prototype;s&&!("detached"in a)&&n(a,"detached",{configurable:!0,get:function(){return r(this)}})},7936:(t,e,i)=>{var s=i(6518),n=i(5636);n&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return n(this,arguments.length?arguments[0]:void 0,!1)}})},8100:(t,e,i)=>{var s=i(6518),n=i(5636);n&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return n(this,arguments.length?arguments[0]:void 0,!0)}})},4114:(t,e,i)=>{var s=i(6518),n=i(8981),r=i(6198),a=i(4527),o=i(6837);s({target:"Array",proto:!0,arity:1,forced:i(9039)(function(){return 4294967297!==[].push.call({length:4294967296},1)})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(t){return t instanceof TypeError}}()},{push:function(t){var e=n(this),i=r(e),s=arguments.length;o(i+s);for(var l=0;l<s;l++)e[i]=arguments[l],i++;return a(e,i),i}})},8111:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(679),a=i(8551),o=i(4901),l=i(2787),h=i(2106),c=i(4659),d=i(9039),u=i(9297),p=i(8227),g=i(7657).IteratorPrototype,f=i(3724),m=i(6395),b="constructor",v="Iterator",y=p("toStringTag"),w=TypeError,x=n[v],A=m||!o(x)||x.prototype!==g||!d(function(){x({})}),_=function(){if(r(this,g),l(this)===g)throw new w("Abstract class Iterator not directly constructable")},S=function(t,e){f?h(g,t,{configurable:!0,get:function(){return e},set:function(e){if(a(this),this===g)throw new w("You can't redefine this property");u(this,t)?this[t]=e:c(this,t,e)}}):g[t]=e};u(g,y)||S(y,v),!A&&u(g,b)&&g[b]!==Object||S(b,_),_.prototype=g,s({global:!0,constructor:!0,forced:A},{Iterator:_})},9314:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(8551),a=i(1767),o=i(4149),l=i(9590),h=i(9462),c=i(6395),d=h(function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=r(n(i,e)),this.done=!!t.done)return;if(t=r(n(i,e)),!(this.done=!!t.done))return t.value});s({target:"Iterator",proto:!0,real:!0,forced:c},{drop:function(t){r(this);var e=l(o(+t));return new d(a(this),{remaining:e})}})},1148:(t,e,i)=>{var s=i(6518),n=i(2652),r=i(9306),a=i(8551),o=i(1767);s({target:"Iterator",proto:!0,real:!0},{every:function(t){a(this),r(t);var e=o(this),i=0;return!n(e,function(e,s){if(!t(e,i++))return s()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),a=i(8551),o=i(1767),l=i(9462),h=i(6319),c=i(6395),d=l(function(){for(var t,e,i=this.iterator,s=this.predicate,r=this.next;;){if(t=a(n(r,i)),this.done=!!t.done)return;if(e=t.value,h(i,s,[e,this.counter++],!0))return e}});s({target:"Iterator",proto:!0,real:!0,forced:c},{filter:function(t){return a(this),r(t),new d(o(this),{predicate:t})}})},531:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),a=i(8551),o=i(1767),l=i(8646),h=i(9462),c=i(9539),d=i(6395),u=h(function(){for(var t,e,i=this.iterator,s=this.mapper;;){if(e=this.inner)try{if(!(t=a(n(e.next,e.iterator))).done)return t.value;this.inner=null}catch(t){c(i,"throw",t)}if(t=a(n(this.next,i)),this.done=!!t.done)return;try{this.inner=l(s(t.value,this.counter++),!1)}catch(t){c(i,"throw",t)}}});s({target:"Iterator",proto:!0,real:!0,forced:d},{flatMap:function(t){return a(this),r(t),new u(o(this),{mapper:t,inner:null})}})},1701:(t,e,i)=>{var s=i(6518),n=i(713);s({target:"Iterator",proto:!0,real:!0,forced:i(6395)},{map:n})},3579:(t,e,i)=>{var s=i(6518),n=i(2652),r=i(9306),a=i(8551),o=i(1767);s({target:"Iterator",proto:!0,real:!0},{some:function(t){a(this),r(t);var e=o(this),i=0;return n(e,function(e,s){if(t(e,i++))return s()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},1689:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(8745),a=i(7680),o=i(6043),l=i(9306),h=i(1103),c=n.Promise,d=!1;s({target:"Promise",stat:!0,forced:!c||!c.try||h(function(){c.try(function(t){d=8===t},8)}).error||!d},{try:function(t){var e=arguments.length>1?a(arguments,1):[],i=o.f(this),s=h(function(){return r(l(t),void 0,e)});return(s.error?i.reject:i.resolve)(s.value),i.promise}})},4628:(t,e,i)=>{var s=i(6518),n=i(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var t=n.f(this);return{promise:t.promise,resolve:t.resolve,reject:t.reject}}})},7642:(t,e,i)=>{var s=i(6518),n=i(3440);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference")},{difference:n})},8004:(t,e,i)=>{var s=i(6518),n=i(9039),r=i(8750);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("intersection")||n(function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))})},{intersection:r})},3853:(t,e,i)=>{var s=i(6518),n=i(4449);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isDisjointFrom")},{isDisjointFrom:n})},5876:(t,e,i)=>{var s=i(6518),n=i(3838);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSubsetOf")},{isSubsetOf:n})},2475:(t,e,i)=>{var s=i(6518),n=i(8527);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSupersetOf")},{isSupersetOf:n})},5024:(t,e,i)=>{var s=i(6518),n=i(3650);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")},{symmetricDifference:n})},1698:(t,e,i)=>{var s=i(6518),n=i(4204);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")},{union:n})},7467:(t,e,i)=>{var s=i(7628),n=i(4644),r=n.aTypedArray,a=n.exportTypedArrayMethod,o=n.getTypedArrayConstructor;a("toReversed",function(){return s(r(this),o(this))})},4732:(t,e,i)=>{var s=i(4644),n=i(9504),r=i(9306),a=i(5370),o=s.aTypedArray,l=s.getTypedArrayConstructor,h=s.exportTypedArrayMethod,c=n(s.TypedArrayPrototype.sort);h("toSorted",function(t){void 0!==t&&r(t);var e=o(this),i=a(l(e),e);return c(i,t)})},9577:(t,e,i)=>{var s=i(9928),n=i(4644),r=i(1108),a=i(1291),o=i(5854),l=n.aTypedArray,h=n.getTypedArrayConstructor,c=n.exportTypedArrayMethod,d=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(t){return 8===t}}();c("with",{with:function(t,e){var i=l(this),n=a(t),c=r(i)?o(e):+e;return s(i,h(i),n,c)}}.with,!d)},8992:(t,e,i)=>{i(8111)},4743:(t,e,i)=>{i(9314)},3215:(t,e,i)=>{i(1148)},4520:(t,e,i)=>{i(2489)},670:(t,e,i)=>{i(531)},1454:(t,e,i)=>{i(1701)},7550:(t,e,i)=>{i(3579)},8335:(t,e,i)=>{var s=i(6518),n=i(3724),r=i(4576),a=i(7751),o=i(9504),l=i(9565),h=i(4901),c=i(34),d=i(4376),u=i(9297),p=i(655),g=i(6198),f=i(4659),m=i(9039),b=i(8235),v=i(4495),y=r.JSON,w=r.Number,x=r.SyntaxError,A=y&&y.parse,_=a("Object","keys"),S=Object.getOwnPropertyDescriptor,C=o("".charAt),E=o("".slice),T=o(/./.exec),k=o([].push),P=/^\d$/,M=/^[1-9]$/,I=/^[\d-]$/,D=/^[\t\n\r ]$/,R=function(t,e,i,s){var n,r,a,o,h,p=t[e],f=s&&p===s.value,m=f&&"string"==typeof s.source?{source:s.source}:{};if(c(p)){var b=d(p),v=f?s.nodes:b?[]:{};if(b)for(n=v.length,a=g(p),o=0;o<a;o++)L(p,o,R(p,""+o,i,o<n?v[o]:void 0));else for(r=_(p),a=g(r),o=0;o<a;o++)h=r[o],L(p,h,R(p,h,i,u(v,h)?v[h]:void 0))}return l(i,t,e,p,m)},L=function(t,e,i){if(n){var s=S(t,e);if(s&&!s.configurable)return}void 0===i?delete t[e]:f(t,e,i)},F=function(t,e,i,s){this.value=t,this.end=e,this.source=i,this.nodes=s},O=function(t,e){this.source=t,this.index=e};O.prototype={fork:function(t){return new O(this.source,t)},parse:function(){var t=this.source,e=this.skip(D,this.index),i=this.fork(e),s=C(t,e);if(T(I,s))return i.number();switch(s){case"{":return i.object();case"[":return i.array();case'"':return i.string();case"t":return i.keyword(!0);case"f":return i.keyword(!1);case"n":return i.keyword(null)}throw new x('Unexpected character: "'+s+'" at: '+e)},node:function(t,e,i,s,n){return new F(e,s,t?null:E(this.source,i,s),n)},object:function(){for(var t=this.source,e=this.index+1,i=!1,s={},n={};e<t.length;){if(e=this.until(['"',"}"],e),"}"===C(t,e)&&!i){e++;break}var r=this.fork(e).string(),a=r.value;e=r.end,e=this.until([":"],e)+1,e=this.skip(D,e),r=this.fork(e).parse(),f(n,a,r),f(s,a,r.value),e=this.until([",","}"],r.end);var o=C(t,e);if(","===o)i=!0,e++;else if("}"===o){e++;break}}return this.node(1,s,this.index,e,n)},array:function(){for(var t=this.source,e=this.index+1,i=!1,s=[],n=[];e<t.length;){if(e=this.skip(D,e),"]"===C(t,e)&&!i){e++;break}var r=this.fork(e).parse();if(k(n,r),k(s,r.value),e=this.until([",","]"],r.end),","===C(t,e))i=!0,e++;else if("]"===C(t,e)){e++;break}}return this.node(1,s,this.index,e,n)},string:function(){var t=this.index,e=b(this.source,this.index+1);return this.node(0,e.value,t,e.end)},number:function(){var t=this.source,e=this.index,i=e;if("-"===C(t,i)&&i++,"0"===C(t,i))i++;else{if(!T(M,C(t,i)))throw new x("Failed to parse number at: "+i);i=this.skip(P,i+1)}if(("."===C(t,i)&&(i=this.skip(P,i+1)),"e"===C(t,i)||"E"===C(t,i))&&(i++,"+"!==C(t,i)&&"-"!==C(t,i)||i++,i===(i=this.skip(P,i))))throw new x("Failed to parse number's exponent value at: "+i);return this.node(0,w(E(t,e,i)),e,i)},keyword:function(t){var e=""+t,i=this.index,s=i+e.length;if(E(this.source,i,s)!==e)throw new x("Failed to parse value at: "+i);return this.node(0,t,i,s)},skip:function(t,e){for(var i=this.source;e<i.length&&T(t,C(i,e));e++);return e},until:function(t,e){e=this.skip(D,e);for(var i=C(this.source,e),s=0;s<t.length;s++)if(t[s]===i)return e;throw new x('Unexpected character: "'+i+'" at: '+e)}};var N=m(function(){var t,e="9007199254740993";return A(e,function(e,i,s){t=s.source}),t!==e}),B=v&&!m(function(){return 1/A("-0 \t")!=-1/0});s({target:"JSON",stat:!0,forced:N},{parse:function(t,e){return B&&!h(e)?A(t):function(t,e){t=p(t);var i=new O(t,0,""),s=i.parse(),n=s.value,r=i.skip(D,s.end);if(r<t.length)throw new x('Unexpected extra character: "'+C(t,r)+'" after the parsed data at: '+r);return h(e)?R({"":n},"",e,s):n}(t,e)}})},5247:(t,e,i)=>{i(1689)},4979:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(7751),a=i(6980),o=i(4913).f,l=i(9297),h=i(679),c=i(3167),d=i(2603),u=i(5002),p=i(8574),g=i(3724),f=i(6395),m="DOMException",b=r("Error"),v=r(m),y=function(){h(this,w);var t=arguments.length,e=d(t<1?void 0:arguments[0]),i=d(t<2?void 0:arguments[1],"Error"),s=new v(e,i),n=new b(e);return n.name=m,o(s,"stack",a(1,p(n.stack,1))),c(s,this,y),s},w=y.prototype=v.prototype,x="stack"in new b(m),A="stack"in new v(1,2),_=v&&g&&Object.getOwnPropertyDescriptor(n,m),S=!(!_||_.writable&&_.configurable),C=x&&!S&&!A;s({global:!0,constructor:!0,forced:f||C},{DOMException:C?y:v});var E=r(m),T=E.prototype;if(T.constructor!==E)for(var k in f||o(T,"constructor",a(1,E)),u)if(l(u,k)){var P=u[k],M=P.s;l(E,M)||o(E,M,a(6,P.c))}},4603:(t,e,i)=>{var s=i(6840),n=i(9504),r=i(655),a=i(2812),o=URLSearchParams,l=o.prototype,h=n(l.append),c=n(l.delete),d=n(l.forEach),u=n([].push),p=new o("a=1&a=2&b=3");p.delete("a",1),p.delete("b",void 0),p+""!="a=2"&&s(l,"delete",function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return c(this,t);var s=[];d(this,function(t,e){u(s,{key:e,value:t})}),a(e,1);for(var n,o=r(t),l=r(i),p=0,g=0,f=!1,m=s.length;p<m;)n=s[p++],f||n.key===o?(f=!0,c(this,n.key)):g++;for(;g<m;)(n=s[g++]).key===o&&n.value===l||h(this,n.key,n.value)},{enumerable:!0,unsafe:!0})},7566:(t,e,i)=>{var s=i(6840),n=i(9504),r=i(655),a=i(2812),o=URLSearchParams,l=o.prototype,h=n(l.getAll),c=n(l.has),d=new o("a=1");!d.has("a",2)&&d.has("a",void 0)||s(l,"has",function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return c(this,t);var s=h(this,t);a(e,1);for(var n=r(i),o=0;o<s.length;)if(s[o++]===n)return!0;return!1},{enumerable:!0,unsafe:!0})},8721:(t,e,i)=>{var s=i(3724),n=i(9504),r=i(2106),a=URLSearchParams.prototype,o=n(a.forEach);s&&!("size"in a)&&r(a,"size",{get:function(){var t=0;return o(this,function(){t++}),t},configurable:!0,enumerable:!0})}},D={};
|
|
4
|
+
/**
|
|
5
|
+
* @licstart The following is the entire license notice for the
|
|
6
|
+
* JavaScript code in this page
|
|
7
|
+
*
|
|
8
|
+
* Copyright 2024 Mozilla Foundation
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*
|
|
22
|
+
* @licend The above is the entire license notice for the
|
|
23
|
+
* JavaScript code in this page
|
|
24
|
+
*/function R(t){var e=D[t];if(void 0!==e)return e.exports;var i=D[t]={exports:{}};return I[t].call(i.exports,i,i.exports,R),i.exports}R.d=(t,e)=>{for(var i in e)R.o(e,i)&&!R.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},R.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var L=globalThis.pdfjsLib={};R.d(L,{AbortException:()=>Wt,AnnotationEditorLayer:()=>Nn,AnnotationEditorParamsType:()=>Y,AnnotationEditorType:()=>X,AnnotationEditorUIManager:()=>Ie,AnnotationLayer:()=>vn,AnnotationMode:()=>q,ColorPicker:()=>kn,DOMSVGFactory:()=>zs,DrawLayer:()=>Bn,FeatureTest:()=>Kt,GlobalWorkerOptions:()=>zi,ImageKind:()=>st,InvalidPDFException:()=>Ut,MissingPDFException:()=>Vt,OPS:()=>kt,OutputScale:()=>Ae,PDFDataRangeTransport:()=>_s,PDFDateString:()=>me,PDFWorker:()=>Ts,PasswordResponses:()=>Pt,PermissionFlag:()=>K,PixelsPerInch:()=>ne,RenderingCancelledException:()=>oe,TextLayer:()=>ps,TouchManager:()=>Re,UnexpectedResponseException:()=>$t,Util:()=>Jt,VerbosityLevel:()=>Tt,XfaLayer:()=>Hs,build:()=>Ls,createValidAbsoluteUrl:()=>Nt,fetchData:()=>re,getDocument:()=>ws,getFilenameFromUrl:()=>ce,getPdfFilenameFromUrl:()=>de,getXfaPageViewport:()=>be,isDataScheme:()=>le,isPdfFile:()=>he,noContextMenu:()=>ge,normalizeUnicode:()=>ee,setLayerDimensions:()=>xe,shadow:()=>Bt,stopEvent:()=>fe,version:()=>Rs});R(4114),R(6573),R(8100),R(7936),R(7467),R(4732),R(9577),R(5247),R(4979),R(4603),R(7566),R(8721);const F=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),O=[1,0,0,1,0,0],N=[.001,0,0,.001,0,0],B=1.35,z=1,H=2,j=4,U=16,V=32,$=64,G=128,W=256,q={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},X={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Y={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},K={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Q=0,J=1,Z=2,tt=3,et=3,it=4,st={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},nt=1,rt=2,at=3,ot=4,lt=5,ht=6,ct=7,dt=8,ut=9,pt=10,gt=11,ft=12,mt=13,bt=14,vt=15,yt=16,wt=17,xt=20,At=1,_t=2,St=3,Ct=4,Et=5,Tt={ERRORS:0,WARNINGS:1,INFOS:5},kt={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},Pt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Mt=Tt.WARNINGS;function It(t){Number.isInteger(t)&&(Mt=t)}function Dt(){return Mt}function Rt(t){Mt>=Tt.INFOS&&console.log(`Info: ${t}`)}function Lt(t){Mt>=Tt.WARNINGS&&console.log(`Warning: ${t}`)}function Ft(t){throw new Error(t)}function Ot(t,e){t||Ft(e)}function Nt(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function Bt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const zt=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Ht extends zt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class jt extends zt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ut extends zt{constructor(t){super(t,"InvalidPDFException")}}class Vt extends zt{constructor(t){super(t,"MissingPDFException")}}class $t extends zt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Gt extends zt{constructor(t){super(t,"FormatError")}}class Wt extends zt{constructor(t){super(t,"AbortException")}}function qt(t){"object"==typeof t&&void 0!==t?.length||Ft("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Xt(t){"string"!=typeof t&&Ft("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function Yt(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class Kt{static get isLittleEndian(){return Bt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Bt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Bt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Bt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?Bt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):Bt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Bt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Qt=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class Jt{static makeHexColor(t,e,i){return`#${Qt[t]}${Qt[e]}${Qt[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const 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]));return n>r?null:[i,n,s,r]}static#t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*s,g=c*(c*(c*n+3*l*r)+3*d*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,r,a,o,l,h,c,d){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-c/h,d));const u=h**2-4*c*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,d),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,d)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){return 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)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,n,a,e,s,r,o,3*(3*(i-n)-t+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(3*(s-r)-e+o),6*(e-2*s+r),3*(s-e),l),l}}let Zt=null,te=null;function ee(t){return Zt||(Zt=/([\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,te=new Map([["ſt","ſt"]])),t.replaceAll(Zt,(t,e,i)=>e?e.normalize("NFKC"):te.get(i))}const ie="pdfjs_internal_id_";R(4628),R(7642),R(8004),R(3853),R(5876),R(2475),R(5024),R(1698),R(1454),R(8992),R(4743),R(3215),R(7550),R(8335);const se="http://www.w3.org/2000/svg";class ne{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function re(t,e="text"){if(pe(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)})}class ae{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){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 new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map(e=>e*t);return Bt(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new ae({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return Jt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=Jt.applyTransform([t[0],t[1]],this.transform),i=Jt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return Jt.applyInverseTransform([t,e],this.transform)}}class oe extends zt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function le(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function he(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function ce(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function de(t,e="document.pdf"){if("string"!=typeof t)return e;if(le(t))return Lt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class ue{started=Object.create(null);times=[];time(t){t in this.started&&Lt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Lt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function pe(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function ge(t){t.preventDefault()}function fe(t){t.preventDefault(),t.stopPropagation()}class me{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-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;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(r+=h,a+=c):"+"===l&&(r-=h,a-=c),new Date(Date.UTC(i,s,n,r,a,o))}}function be(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new ae({viewBox:r,userUnit:1,scale:e,rotation:i})}function ve(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Lt(`Not a valid color format: "${t}"`),[0,0,0])}function ye(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function we(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function xe(t,e,i=!1,s=!0){if(e instanceof ae){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=Kt.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,c=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=c,r.height=h):(r.width=h,r.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}class Ae{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class _e{#s=null;#n=null;#r;#a=null;#o=null;static#l=null;constructor(t){this.#r=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"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",ge,{signal:e}),t.addEventListener("pointerdown",_e.#h,{signal:e});const i=this.#a=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#d(t){this.#r._focusEventsAllowed=!1,fe(t)}#u(t){this.#r._focusEventsAllowed=!0,fe(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ge,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#c(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",_e.#l[t]),this.#p(i),i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#a.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#a.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#a.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Se{#a=null;#s=null;#f;constructor(t){this.#f=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ge,{signal:this.#f._signal});const e=this.#a=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#v(e,i),{style:r}=this.#s||=this.#m();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#f._signal;t.addEventListener("contextmenu",ge,{signal:i}),t.addEventListener("click",()=>{this.#f.highlightSelection("floating_button")},{signal:i}),this.#a.append(t)}}function Ce(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Ee{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class Te{#w=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),qt(t)}();#y=0;#x=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return Bt(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async#A(t,e){this.#x||=new Map;let i=this.#x.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#w}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await re(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Te._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r});s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){Lt(t),i=null}return this.#x.set(t,i),i&&this.#x.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#A(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#A(t,t)}async getFromBlob(t,e){const i=await e;return this.#A(t,i)}async getFromId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#x||=new Map;let i=this.#x.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#w}_${this.#y++}`,refCounter:1,isSvg:!1},this.#x.set(t,i),this.#x.set(i.id,i),i}getSvgUrl(t){const e=this.#x.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#w}_`)}}class ke{#_=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#S)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#_.length>0&&(this.#_.length=0),this.#E=0,void this.#_.push(o);if(r&&this.#_[this.#E].type===n)return a&&(o.undo=this.#_[this.#E].undo),void(this.#_[this.#E]=o);const l=this.#E+1;l===this.#C?this.#_.splice(0,1):(this.#E=l,l<this.#_.length&&this.#_.splice(l)),this.#_.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#_[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#_.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#_[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#_.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#_[e].type!==t)return this.#_.splice(e+1,this.#E-e),void(this.#E=e);this.#_.length=0,this.#E=-1}}destroy(){this.#_=null}}class Pe{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Kt.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#T(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#T(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||fe(e))}}class Me{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,ve(s))}e.remove()}(t),Bt(this,"_colors",t)}convert(t){const e=ve(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return Me._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Jt.makeHexColor(...e):t}}class Ie{#k=new AbortController;#P=null;#M=new Map;#I=new Map;#D=null;#R=null;#L=null;#F=new ke;#O=null;#N=null;#B=0;#z=new Set;#H=null;#j=null;#U=new Set;_editorUndoBar=null;#V=!1;#$=!1;#G=!1;#W=null;#q=null;#X=null;#Y=null;#K=!1;#Q=null;#J=new Ee;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#rt=X.NONE;#at=new Set;#ot=null;#lt=null;#ht=null;#ct={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#dt=[0,0];#ut=null;#pt=null;#gt=null;#ft=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Ie.prototype,e=t=>t.#pt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return Bt(this,"_keyboardManager",new Pe([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["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:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,a,o,l,h,c,d,u){const p=this._signal=this.#k.signal;this.#pt=t,this.#gt=e,this.#D=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:p}),this.#mt(),this.#bt(),this.#vt(),this.#R=n.annotationStorage,this.#W=n.filterFactory,this.#lt=r,this.#Y=a||null,this.#V=o,this.#$=l,this.#G=h,this.#nt=c||null,this.viewParameters={realScale:ne.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ft?.resolve(),this.#ft=null,this.#k?.abort(),this.#k=null,this._signal=null;for(const t of this.#I.values())t.destroy();this.#I.clear(),this.#M.clear(),this.#U.clear(),this.#P=null,this.#at.clear(),this.#F.destroy(),this.#D?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#ut&&(clearTimeout(this.#ut),this.#ut=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#nt}get useNewAltTextFlow(){return this.#$}get useNewAltTextWhenAddingImage(){return this.#G}get hcmFilter(){return Bt(this,"hcmFilter",this.#lt?this.#W.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return Bt(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return Bt(this,"highlightColors",this.#Y?new Map(this.#Y.split(",").map(t=>t.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return Bt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#N=t}setMainHighlightColorPicker(t){this.#st=t}editAltText(t,e=!1){this.#D?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#G=e}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#pt.focus()}findParent(t,e){for(const i of this.#I.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#gt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#U.add(t)}removeShouldRescale(t){this.#U.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*ne.PDF_TO_CSS_UNITS;for(const t of this.#U)t.onScaleChanging();this.#N?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#yt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#wt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#I.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,a=e.toString(),o=this.#yt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#wt(o),c=this.#rt===X.NONE,d=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:a}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(X.HIGHLIGHT,d):d()}#xt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#yt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new Se(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#R||this.#R.has(t.id)||this.#R.setValue(t.id,t)}#At(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#_t({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ot)return;const i=this.#yt(t).closest(".textLayer");if(i){if(this.#Q?.hide(),this.#ot=e,this.#_t({hasSelectedText:!0}),(this.#rt===X.HIGHLIGHT||this.#rt===X.NONE)&&(this.#rt===X.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#K=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#rt===X.HIGHLIGHT?this.#wt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#_t({hasSelectedText:!1}))}#St(t=""){this.#rt===X.HIGHLIGHT?this.highlightSelection(t):this.#V&&this.#xt()}#mt(){document.addEventListener("selectionchange",this.#At.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#it=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#it)return;const[t,e]=this.#it;this.#it=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#vt(){if(this.#et)return;this.#et=new AbortController;const t=this.combinedSignal(this.#et);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Tt(){this.#et?.abort(),this.#et=null}#kt(){if(this.#O)return;this.#O=new AbortController;const t=this.combinedSignal(this.#O);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})}#Pt(){this.#O?.abort(),this.#O=null}#bt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#vt(),this.#kt()}removeEditListeners(){this.#Tt(),this.#Pt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#j)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#j)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#P?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#j)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void Lt(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#Mt(e);this.#It(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){Lt(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#rt===X.NONE||this.isEditorHandlingKeyboard||Ie._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#_t(t){Object.entries(t).some(([t,e])=>this.#ct[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ct,t)}),this.#rt===X.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Dt([[Y.HIGHLIGHT_FREE,!0]]))}#Dt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#kt(),this.#_t({isEditing:this.#rt!==X.NONE,isEmpty:this.#Rt(),hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:this.#F.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Pt(),this.#_t({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#j){this.#j=t;for(const t of this.#j)this.#Dt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#I.get(this.#B)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#I.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#I.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#rt!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#rt=t,t===X.NONE)return this.setEditingState(!1),this.#Lt(),this._editorUndoBar?.hide(),void this.#ft.resolve();this.setEditingState(!0),await this.#Ft(),this.unselectAll();for(const e of this.#I.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#ft.resolve();for(const t of this.#M.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#ft.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#rt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#j){switch(t){case Y.CREATE:return void this.currentLayer.addNewEditor();case Y.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case Y.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ht||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#j)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#M.values())i.editorType===t&&i.show(e);(this.#ht?.get(Y.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Dt([[Y.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#I.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Ft(){if(!this.#Z){this.#Z=!0;const t=[];for(const e of this.#I.values())t.push(e.enable());await Promise.all(t);for(const t of this.#M.values())t.enable()}}#Lt(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const t of this.#I.values())t.disable();for(const t of this.#M.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#M.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#M.get(t)}addEditor(t){this.#M.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout(()=>{this.focusMainContainer(),this.#q=null},0)),this.#M.delete(t.id),this.unselect(t),t.annotationElementId&&this.#z.has(t.annotationElementId)||this.#R?.remove(t.id)}addDeletedAnnotationElement(t){this.#z.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#z.has(t)}removeDeletedAnnotationElement(t){this.#z.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Mt(t){const e=this.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#P!==t&&(this.#P=t,t&&this.#Dt(t.propertiesToUpdate))}get#Ot(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ot===t&&this.#Dt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Dt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#_t({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#Dt(t.propertiesToUpdate),this.#_t({hasSelectedEditor:!0})}setSelected(t){this.#N?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#Dt(t.propertiesToUpdate),this.#_t({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#_t({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#F.undo(),this.#_t({hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Rt()}),this._editorUndoBar?.hide()}redo(){this.#F.redo(),this.#_t({hasSomethingToUndo:!0,hasSomethingToRedo:this.#F.hasSomethingToRedo(),isEmpty:this.#Rt()})}addCommands(t){this.#F.add(t),this.#_t({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Rt()})}cleanUndoStack(t){this.#F.cleanType(t)}#Rt(){if(0===this.#M.size)return!0;if(1===this.#M.size)for(const t of this.#M.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#at],i=()=>{for(const t of e)this.#Mt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#P?.commitOrRemove()}hasSomethingToControl(){return this.#P||this.hasSelection}#It(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#_t({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#It(this.#M.values())}unselectAll(){if((!this.#P||(this.#P.commitOrRemove(),this.#rt===X.NONE))&&!this.#N?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#_t({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#dt[0]+=t,this.#dt[1]+=e;const[s,n]=this.#dt,r=[...this.#at];this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout(()=>{this.#ut=null,this.#dt[0]=this.#dt[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#M.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of r)this.#M.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})},1e3);for(const i of r)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#H=new Map;for(const t of this.#at)this.#H.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#H)return!1;this.disableUserSelect(!1);const t=this.#H;this.#H=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#M.has(t.id)){const n=this.#I.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#H)for(const i of this.#H.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#P===t}getActive(){return this.#P}getMode(){return this.#rt}get imageManager(){return Bt(this,"imageManager",new Te)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(a(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#L||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#L?.delete(t)}renderAnnotationElement(t){const e=this.#L?.get(t.data.id);if(!e)return;const i=this.#R.getRawValue(e);i&&(this.#rt!==X.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}}class De{#o=null;#Nt=!1;#Bt=null;#zt=null;#Ht=null;#jt=null;#Ut=!1;#Vt=null;#r=null;#$t=null;#Gt=null;#Wt=!1;static#qt=null;static _l10n=null;constructor(t){this.#r=t,this.#Wt=t._uiManager.useNewAltTextFlow,De.#qt||=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){De._l10n??=t}async render(){const t=this.#Bt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#zt=document.createElement("span");t.append(e),this.#Wt?(t.classList.add("new"),t.setAttribute("data-l10n-id",De.#qt.missing),e.setAttribute("data-l10n-id",De.#qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",ge,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#Wt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Xt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#Ut=!0,s(e))},{signal:i}),await this.#Yt(),t}get#Xt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Bt&&(this.#Bt.focus({focusVisible:this.#Ut}),this.#Ut=!1)}isEmpty(){return this.#Wt?null===this.#o:!this.#o&&!this.#Nt}hasData(){return this.#Wt?null!==this.#o||!!this.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Gt=await De._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Yt())}toggleAltTextBadge(t=!1){if(!this.#Wt||this.#o)return this.#Vt?.remove(),void(this.#Vt=null);if(!this.#Vt){const t=this.#Vt=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Vt.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Gt),{altText:e,decorative:this.#Nt,guessedText:this.#$t,textWithDisclaimer:this.#Gt}}get data(){return{altText:this.#o,decorative:this.#Nt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#$t=i,this.#Gt=s),this.#o===t&&this.#Nt===e||(n||(this.#o=t,this.#Nt=e),this.#Yt())}toggle(t=!1){this.#Bt&&(!t&&this.#jt&&(clearTimeout(this.#jt),this.#jt=null),this.#Bt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Xt}})}destroy(){this.#Bt?.remove(),this.#Bt=null,this.#zt=null,this.#Ht=null,this.#Vt?.remove(),this.#Vt=null}async#Yt(){const t=this.#Bt;if(!t)return;if(this.#Wt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",De.#qt[this.#Xt]),this.#zt?.setAttribute("data-l10n-id",De.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Ht?.remove()}else{if(!this.#o&&!this.#Nt)return t.classList.remove("done"),void this.#Ht?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Ht;if(!e){this.#Ht=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",()=>{clearTimeout(this.#jt),this.#jt=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#jt=setTimeout(()=>{this.#jt=null,this.#Ht.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:s}),t.addEventListener("mouseleave",()=>{this.#jt&&(clearTimeout(this.#jt),this.#jt=null),this.#Ht?.classList.remove("show")},{signal:s})}this.#Nt?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#r.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}class Re{#pt;#Kt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#re=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=r,this.#ne=new AbortController,this.#ie=AbortSignal.any([a,this.#ne.signal]),t.addEventListener("touchstart",this.#ae.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Bt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ae(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#re){this.#re=new AbortController;const t=AbortSignal.any([this.#ie,this.#re.signal]),e=this.#pt,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#oe.bind(this),i),e.addEventListener("touchend",this.#le.bind(this),i),e.addEventListener("touchcancel",this.#le.bind(this),i),this.#Zt?.()}if(fe(t),2!==t.touches.length||this.#Qt?.())return void(this.#se=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#se={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#oe(t){if(!this.#se||2!==t.touches.length)return;let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:s,screenY:n}=e,{screenX:r,screenY:a}=i,o=this.#se,{touch0X:l,touch0Y:h,touch1X:c,touch1Y:d}=o,u=c-l,p=d-h,g=r-s,f=a-n,m=Math.hypot(g,f)||1,b=Math.hypot(u,p)||1;if(!this.#Kt&&Math.abs(b-m)<=Re.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=n,o.touch1X=r,o.touch1Y=a,t.preventDefault(),!this.#Kt)return void(this.#Kt=!0);const v=[(s+r)/2,(n+a)/2];this.#te?.(v,b,m)}#le(t){this.#re.abort(),this.#re=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Kt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}}class Le{#he=null;#ce=null;#o=null;#de=!1;#ue=null;#pe="";#ge=!1;#fe=null;#me=null;#be=null;#ve=null;#ye="";#we=!1;#xe=null;#Ae=!1;#_e=!1;#Se=!1;#Ce=null;#Ee=0;#Te=0;#ke=null;#Pe=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#Me=!1;#Ie=Le._zIndex++;static _borderLineWidth=-1;static _colorManager=new Me;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Le.prototype._resizeWithKeyboard,e=Ie.TRANSLATE_SMALL,i=Ie.TRANSLATE_BIG;return Bt(this,"_resizerKeyboardManager",new Pe([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],Le.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;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Bt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Fe({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(Le._l10n??=t,Le._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"}),-1!==Le._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Le._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Ft("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Me}set _isDraggable(t){this.#Me=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}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.#Ie}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#De(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#we?this.#we=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}#Re([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#Re(this.parentDimensions,t,e)}translateInPage(t,e){this.#xe||=[this.x,this.y,this.width,this.height],this.#Re(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#xe||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#xe&&(this.#xe[0]!==this.x||this.#xe[1]!==this.y)}get _hasBeenResized(){return!!this.#xe&&(this.#xe[2]!==this.width||this.#xe[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=Le,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-o,r));break;case 90:n=Math.max(0,Math.min(i-o,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(o,r));break;case 270:n=Math.min(i,Math.max(o,n)),r=Math.max(0,Math.min(s-a,r))}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#Le(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Le.#Le(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Le.#Le(t,e,360-this.parentRotation)}#Fe(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ge||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ge&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Oe(){if(this.#fe)return;this.#fe=document.createElement("div"),this.#fe.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#fe.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Ne.bind(this,i),{signal:e}),t.addEventListener("contextmenu",ge,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Ne(t,e){e.preventDefault();const{isMac:i}=Kt.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#me=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",fe,{passive:!1,signal:r}),window.addEventListener("contextmenu",ge,{signal:r}),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const 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;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#ze()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#He(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#ze(){if(!this.#be)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#be;this.#be=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#He.bind(this,n,r,a,o),undo:this.#He.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Be(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=Le.MIN_SIZE/i,h=Le.MIN_SIZE/s,c=this.#Fe(this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=this.#Fe(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let y=d(...v);const w=Le._round(n+y[0]),x=Le._round(r+y[1]);let A,_,S=1,C=1;if(e.fromKeyboard)({deltaX:A,deltaY:_}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#me;[A,_]=this.screenToPageTranslation(t-s,i-n),this.#me[0]=t,this.#me[1]=i}var E,T;if([A,_]=(E=A/i,T=_/s,[u[0]*E+u[2]*T,u[1]*E+u[3]*T]),f){const t=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-A,v[1]-b[1]-_)/t,1/a,1/o),l/a,h/o)}else m?S=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-A)))/a:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-_)))/o;const k=Le._round(a*S),P=Le._round(o*C);y=d(...g(k,P));const M=w-y[0],I=x-y[1];this.#xe||=[this.x,this.y,this.width,this.height],this.width=k,this.height=P,this.x=M,this.y=I,this.setDims(i*k,s*P),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#_e||(this._editToolbar=new _e(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(De.initialize(Le._l10n),this.#o=new De(this),this.#he&&(this.#o.data=this.#he,this.#he=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#de?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#je();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),Ce(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Pe||=new Re({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Ue.bind(this),onPinching:this.#Ve.bind(this),onPinchEnd:this.#$e.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#Ue(){this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ve(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Fe(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=Le.MIN_SIZE/a,p=Le.MIN_SIZE/o;s=Math.max(Math.min(s,1/c,1/d),u/c,p/d);const g=Le._round(c*s),f=Le._round(d*s);if(g===c&&f===d)return;this.#xe||=[l,h,c,d];const m=r(c/2,d/2),b=Le._round(l+m[0]),v=Le._round(h+m[1]),y=r(g/2,f/2);this.x=b-y[0],this.y=v-y[1],this.width=g,this.height=f,this.setDims(a*g,o*f),this.fixAndSetPosition(),this._onResizing()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#ze()}pointerdown(t){const{isMac:e}=Kt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#we=!0,this._isDraggable?this.#Ge(t):this.#We(t))}get isSelected(){return this._uiManager.isSelected(this)}#We(t){const{isMac:e}=Kt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#Ge(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#ue=null,this.#we=!1,this._uiManager.endDragSession()||this.#We(t),i&&this._onStopDragging()};e&&(this.#Ee=t.clientX,this.#Te=t.clientY,this.#ue=t.pointerId,this.#pe=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ue)return void fe(t);const[r,a]=this.screenToPageTranslation(e-this.#Ee,s-this.#Te);this.#Ee=e,this.#Te=s,this._uiManager.dragSelectedEditors(r,a)},r),window.addEventListener("touchmove",fe,r),window.addEventListener("pointerdown",t=>{t.pointerType===this.#pe&&(this.#Pe||t.isPrimary)&&a(t),fe(t)},r));const o=t=>{this.#ue&&this.#ue!==t.pointerId?fe(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ce&&clearTimeout(this.#Ce),this.#Ce=setTimeout(()=>{this.#Ce=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,c=this.x*n,d=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[c+l+a,r-d-h-p+o,c+l+u+a,r-d-h+o];case 90:return[c+h+a,r-d+l+o,c+h+p+a,r-d+l+u+o];case 180:return[c-l-u+a,r-d+h+o,c-l+a,r-d+h+p+o];case 270:return[c-h-p+a,r-d-l-u+o,c-h+a,r-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#_e=!0}disableEditMode(){this.#_e=!1}isInEditMode(){return this.#_e}shouldGetKeyboardEvents(){return this.#Se}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#je(){if(this.#ve||!this.div)return;this.#ve=new AbortController;const t=this._uiManager.combinedSignal(this.#ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#je()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){Ft("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#he=t.accessibilityData;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#ve?.abort(),this.#ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ce&&(clearTimeout(this.#Ce),this.#Ce=null),this.#De(),this.removeEditToolbar(),this.#ke){for(const t of this.#ke.values())clearTimeout(t);this.#ke=null}this.parent=null,this.#Pe?.destroy(),this.#Pe=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Oe(),this.#fe.classList.remove("hidden"),Ce(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#fe.children;if(!this.#ce){this.#ce=Array.from(e);const t=this.#qe.bind(this),i=this.#Xe.bind(this),s=this._uiManager._signal;for(const e of this.#ce){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ye.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",Le._l10nResizer[n])}}const i=this.#ce[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#ce.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#fe.append(this.#fe.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#fe.firstChild.before(this.#fe.lastChild);let t=0;for(const i of e){const e=this.#ce[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",Le._l10nResizer[e])}}this.#Ke(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){Le._resizerKeyboardManager.exec(this,t)}#Xe(t){this.#Se&&t.relatedTarget?.parentNode!==this.#fe&&this.#De()}#Ye(t){this.#ye=this.#Se?t:""}#Ke(t){if(this.#ce)for(const e of this.#ce)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Se&&this.#Be(this.#ye,{deltaX:t,deltaY:e,fromKeyboard:!0})}#De(){this.#Se=!1,this.#Ke(-1),this.#ze()}_stopResizingWithKeyboard(){this.#De(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}unselect(){this.#fe?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#Ae}set isEditing(t){this.#Ae=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ge=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}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.#ke||=new Map;const{action:e}=t;let i=this.#ke.get(e);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#ke.delete(e),0===this.#ke.size&&(this.#ke=null)},Le._telemetryTimeout),void this.#ke.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#de=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#de=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class Fe extends Le{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Oe=3285377520,Ne=4294901760,Be=65535;class ze{constructor(t){this.h1=t?4294967295&t:Oe,this.h2=t?4294967295&t:Oe}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(a=r[t],a=a*c&Ne|a*u&Be,a=a<<15|a>>>17,a=a*d&Ne|a*p&Be,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*c&Ne|o*u&Be,o=o<<15|o>>>17,o=o*d&Ne|o*p&Be,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*c&Ne|a*u&Be,a=a<<15|a>>>17,a=a*d&Ne|a*p&Be,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Ne|36045*t&Be,e=4283543511*e&Ne|(2950163797*(e<<16|t>>>16)&Ne)>>>16,t^=e>>>1,t=444984403*t&Ne|60499*t&Be,e=3301882366*e&Ne|(3120437893*(e<<16|t>>>16)&Ne)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const He=Object.freeze({map:null,hash:"",transfer:void 0});class je{#Qe=!1;#Je=null;#Ze=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Ze.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ze.get(t)}remove(t){if(this.#Ze.delete(t),0===this.#Ze.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Ze.values())if(t instanceof Le)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Ze.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#Ze.set(t,e);s&&this.#ti(),e instanceof Le&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?Yt(this.#Ze):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Ze.size}#ti(){this.#Qe||(this.#Qe=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qe&&(this.#Qe=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Ue(this)}get serializable(){if(0===this.#Ze.size)return He;const t=new Map,e=new ze,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Ze){const a=r instanceof Le?r.serialize(!1,s):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:He}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof Le))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Je=null}get modifiedIds(){if(this.#Je)return this.#Je;const t=[];for(const e of this.#Ze.values())e instanceof Le&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class Ue extends je{#ei;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ei={map:n,hash:i,transfer:s}}get print(){Ft("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return Bt(this,"modifiedIds",{ids:new Set,hash:""})}}class Ve{#ii=new Set;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){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#ii.has(t.loadedName)){if(Ot(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ii.add(i),e?.(t)}catch{Lt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}Ft("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)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw Lt(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return Bt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(F||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Bt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(Ot(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return Bt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=s(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-d+i(h,n)|0;var p;n<h.length&&(u=u-d+i(h+"XXX",n)|0),c=s(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return Lt("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,()=>{f.remove(),e.complete()})}}class $e{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(qt(e))});`;var e;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){Lt(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const Ge=1,We=2,qe=1,Xe=2,Ye=3,Ke=4,Qe=5,Je=6,Ze=7,ti=8;function ei(){}function ii(t){if(t instanceof Wt||t instanceof Ut||t instanceof Vt||t instanceof Ht||t instanceof $t||t instanceof jt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||Ft('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Wt(t.message);case"InvalidPDFException":return new Ut(t.message);case"MissingPDFException":return new Vt(t.message);case"PasswordException":return new Ht(t.message,t.code);case"UnexpectedResponseException":return new $t(t.message,t.status);case"UnknownErrorException":return new jt(t.message,t.details)}return new jt(t.message,t.toString())}class si{#si=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#ni.bind(this),{signal:this.#si.signal})}#ni({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ri(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Ge)i.resolve(t.data);else{if(t.callback!==We)throw new Error("Unexpected callback case");i.reject(ii(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;return void Promise.try(e,t.data).then(function(e){n.postMessage({sourceName:i,targetName:s,callback:Ge,callbackId:t.callbackId,data:e})},function(e){n.postMessage({sourceName:i,targetName:s,callback:We,callbackId:t.callbackId,reason:ii(e)})})}t.streamId?this.#ai(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:Je,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{Ot(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:qe,streamId:n,reason:ii(t)}),e.promise}},i)}#ai(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Ke,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Ye,streamId:e}),delete r.streamSinks[e])},error(t){Ot(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Qe,streamId:e,reason:ii(t)}))},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:i,targetName:s,stream:ti,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:ti,streamId:e,reason:ii(t)})})}#ri(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case ti:t.success?r.startCall.resolve():r.startCall.reject(ii(t.reason));break;case Ze:t.success?r.pullCall.resolve():r.pullCall.reject(ii(t.reason));break;case Je:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Ze,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||ei).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Ze,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Ze,streamId:e,reason:ii(t)})});break;case Ke:if(Ot(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Ye:if(Ot(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#oi(r,e);break;case Qe:Ot(r,"error should have stream controller"),r.controller.error(ii(t.reason)),this.#oi(r,e);break;case Xe:t.success?r.cancelCall.resolve():r.cancelCall.reject(ii(t.reason)),this.#oi(r,e);break;case qe:if(!a)break;const o=ii(t.reason);Promise.try(a.onCancel||ei,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:Xe,streamId:e,success:!0})},function(t){n.postMessage({sourceName:i,targetName:s,stream:Xe,streamId:e,reason:ii(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#oi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#si?.abort(),this.#si=null}}class ni{#li=!1;constructor({enableHWA:t=!1}){this.#li=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#li})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Ft("Abstract method `_createCanvas` called.")}}class ri{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Ft("Abstract method `_fetch` called.")}}class ai extends ri{async _fetch(t){const e=await re(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Xt(e)}}R(4520);class oi{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class li{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){Ft("Abstract method `_fetch` called.")}}class hi extends li{async _fetch(t){const e=await re(t,"arraybuffer");return new Uint8Array(e)}}if(F){let e;try{const i=process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("index.js",document.baseURI).href);try{e=i("@napi-rs/canvas")}catch(t){Lt(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){Lt(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(e?.DOMMatrix?globalThis.DOMMatrix=e.DOMMatrix:Lt("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(e?.ImageData?globalThis.ImageData=e.ImageData:Lt("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(e?.Path2D?globalThis.Path2D=e.Path2D:Lt("Cannot polyfill `Path2D`, rendering may be broken."))}async function ci(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}const di="Fill",ui="Stroke",pi="Shading";function gi(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class fi{getPattern(){Ft("Abstract method `getPattern` called.")}}class mi extends fi{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,i,s){let n;if(s===ui||s===di){const r=e.current.getClippedPathBoundingBox(s,ye(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;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]),i=Jt.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),gi(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);n.setTransform(c)}else gi(t,this._bbox),n=this._createGradient(t);return n}}function bi(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,b=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const y=h[r],w=h[r+1],x=h[r+2],A=h[a],_=h[a+1],S=h[a+2],C=h[o],E=h[o+1],T=h[o+2],k=Math.round(g),P=Math.round(v);let M,I,D,R,L,F,O,N;for(let t=k;t<=P;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);M=p-(p-f)*e,I=y-(y-A)*e,D=w-(w-_)*e,R=x-(x-S)*e}else{let e;e=t>v?1:m===v?0:(m-t)/(m-v),M=f-(f-b)*e,I=A-(A-C)*e,D=_-(_-E)*e,R=S-(S-T)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),L=p-(p-b)*e,F=y-(y-C)*e,O=w-(w-E)*e,N=x-(x-T)*e;const i=Math.round(Math.min(M,L)),s=Math.round(Math.max(M,L));let n=d*t+4*i;for(let t=i;t<=s;t++)e=(M-t)/(M-L),e<0?e=0:e>1&&(e=1),c[n++]=I-(I-F)*e|0,c[n++]=D-(D-O)*e|0,c[n++]=R-(R-N)*e|0,c[n++]=255}}function vi(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)bi(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),bi(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)bi(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class yi extends fi{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,c=a/l,d={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)vi(m,t,d);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}getPattern(t,e,i,s){let n;if(gi(t,this._bbox),s===pi)n=Jt.singularValueDecompose2dScale(ye(t));else if(n=Jt.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=Jt.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const r=this._createMeshCanvas(n,s===pi?null:this._background,e.cachedCanvases);return s!==pi&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class wi extends fi{getPattern(){return"hotpink"}}const xi=1,Ai=2;class _i{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){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.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),Rt("TilingType: "+n);const h=e[0],c=e[1],d=e[2],u=e[3],p=d-h,g=u-c,f=Jt.singularValueDecompose2dScale(this.matrix),m=Jt.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1];let y=p,w=g,x=!1,A=!1;const _=Math.ceil(o*b),S=Math.ceil(l*v);_>=Math.ceil(p*b)?y=o:x=!0,S>=Math.ceil(g*v)?w=l:A=!0;const C=this.getSizeAndScale(y,this.ctx.canvas.width,b),E=this.getSizeAndScale(w,this.ctx.canvas.height,v),T=t.cachedCanvases.getCanvas("pattern",C.size,E.size),k=T.context,P=a.createCanvasGraphics(k);if(P.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(P,s,r),k.translate(-C.scale*h,-E.scale*c),P.transform(C.scale,0,0,E.scale,0,0),k.save(),this.clipBbox(P,h,c,d,u),P.baseTransform=ye(P.ctx),P.executeOperatorList(i),P.endDrawing(),k.restore(),x||A){const e=T.canvas;x&&(y=o),A&&(w=l);const i=this.getSizeAndScale(y,this.ctx.canvas.width,b),s=this.getSizeAndScale(w,this.ctx.canvas.height,v),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),d=a.context,u=x?Math.floor(p/o):0,f=A?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)d.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:c}}return{canvas:T.canvas,scaleX:C.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,i){const s=Math.max(_i.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),t.current.updateRectMinMax(ye(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case xi:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case Ai:const r=Jt.makeHexColor(i[0],i[1],i[2]);s.fillStyle=r,s.strokeStyle=r,n.fillColor=r,n.strokeColor=r;break;default:throw new Gt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==pi&&(n=Jt.transform(n,e.baseTransform),this.matrix&&(n=Jt.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function Si({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Kt.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+c;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===d)continue;const s=e<u?t[e++]:255;for(let t=0;t<d;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const Ci=16;class Ei{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Ti(t,e,i,s,n,r,a,o,l,h){const[c,d,u,p,g,f]=ye(t);if(0===d&&0===u){const m=a*c+g,b=Math.round(m),v=o*p+f,y=Math.round(v),w=(a+l)*c+g,x=Math.abs(Math.round(w)-b)||1,A=(o+h)*p+f,_=Math.abs(Math.round(A)-y)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),b,y),t.drawImage(e,i,s,n,r,0,0,x,_),t.setTransform(c,d,u,p,g,f),[x,_]}if(0===c&&0===p){const m=o*u+g,b=Math.round(m),v=a*d+f,y=Math.round(v),w=(o+h)*u+g,x=Math.abs(Math.round(w)-b)||1,A=(a+l)*d+f,_=Math.abs(Math.round(A)-y)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,b,y),t.drawImage(e,i,s,n,r,0,0,_,x),t.setTransform(c,d,u,p,g,f),[_,x]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class ki{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=O,this.textMatrixScale=1,this.fontMatrix=N,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Q,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=Jt.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=Jt.applyTransform(e,t),s=Jt.applyTransform(e.slice(2),t),n=Jt.applyTransform([e[0],e[3]],t),r=Jt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(t,e){Jt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,r,a,o,l,h){const c=Jt.bezierBoundingBox(e,i,s,n,r,a,o,l,h);h||this.updateRectMinMax(t,c)}getPathBoundingBox(t=di,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===ui){e||Ft("Stroke bounding box must include transform.");const t=Jt.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=Jt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=di,e=null){return Jt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Pi(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Ci,r=(i-n)/Ci,a=0===n?r:r+1,o=t.createImageData(s,Ci);let l,h=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===st.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),f=i.length,m=s+7>>3,b=4294967295,v=Kt.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?Ci:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,d=0;for(;n<a;n+=8)d=c[h++],i[l++]=128&d?b:v,i[l++]=64&d?b:v,i[l++]=32&d?b:v,i[l++]=16&d?b:v,i[l++]=8&d?b:v,i[l++]=4&d?b:v,i[l++]=2&d?b:v,i[l++]=1&d?b:v;for(;n<r;n++)0===o&&(d=c[h++],o=128),i[l++]=d&o?b:v,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*Ci)}}else if(e.kind===st.RGBA_32BPP){for(p=0,f=s*Ci*4,u=0;u<r;u++)d.set(c.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=Ci;u<a&&(f=s*n*4,d.set(c.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==st.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Ci,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*Ci)}}}function Mi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Ci,r=(i-n)/Ci,a=0===n?r:r+1,o=t.createImageData(s,Ci);let l=0;const h=e.data,c=o.data;for(let e=0;e<a;e++){const i=e<r?Ci:n;({srcPos:l}=Si({src:h,srcPos:l,dest:c,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Ci)}}function Ii(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Di(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",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!F){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function Ri(t,e){if(e)return!0;const i=Jt.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*ne.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const Li=["butt","round","square"],Fi=["miter","round","bevel"],Oi={},Ni={};class Bi{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new ki(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Ei(this.canvasFactory),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}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...ye(this.compositeCtx))}this.ctx.save(),Di(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=ye(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const l=o-a>10&&"function"==typeof i,h=l?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(p=r[a],p!==kt.dependency)this[p].apply(this,n[a]);else for(const t of n[a]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,i),a}if(a++,a===o)return a;if(l&&++c>10){if(Date.now()>h)return i(),a;c=0}}}#hi(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#hi(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#ci()}#ci(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,c="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(c,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,a=ye(e);let o,l,h,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!r){return{canvas:i,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])}}h=i}h||(c=this.cachedCanvases.getCanvas("maskCanvas",i,s),Mi(c.context,t));let d=Jt.transform(a,[1/i,0,0,-1/s,0,0]);d=Jt.transform(d,[1,0,0,1,0,-s]);const[u,p,g,f]=Jt.getAxialAlignedBoundingBox([0,0,i,s],d),m=Math.round(g-u)||1,b=Math.round(f-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,b),y=v.context,w=u,x=p;y.translate(-w,-x),y.transform(...d),h||(h=this._scaleImage(c.canvas,we(y)),h=h.img,o&&r&&o.set(l,h)),y.imageSmoothingEnabled=Ri(ye(y),t.interpolate),Ti(y,h,0,0,h.width,h.height,0,0,i,s),y.globalCompositeOperation="source-in";const A=Jt.transform(we(y),[1,0,0,1,-w,-x]);return y.fillStyle=r?n.getPattern(e,this,A,di):n,y.fillRect(0,0,i,s),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(w),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Li[t]}setLineJoin(t){this.ctx.lineJoin=Fi[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...ye(this.suspendedCtx)),Ii(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ii(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(r){const e=Jt.makeHexColor(...r);if(u<0||p<0||u+i>d.width||p+s>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),n=t.context;n.drawImage(d,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,i,s),n.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,i,s),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(Ii(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Ii(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let r,a,o=n.x,l=n.y;const h=ye(s),c=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],d=c?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case kt.rectangle:o=e[u++],l=e[u++];const t=e[u++],i=e[u++],p=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(p,g):(s.lineTo(p,l),s.lineTo(p,g),s.lineTo(o,g)),c||n.updateRectMinMax(h,[o,l,p,g]),s.closePath();break;case kt.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),c||n.updatePathMinMax(h,o,l);break;case kt.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),c||n.updatePathMinMax(h,o,l);break;case kt.curveTo:r=o,a=l,o=e[u+4],l=e[u+5],s.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],e[u+2],e[u+3],o,l,d),u+=6;break;case kt.curveTo2:r=o,a=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,r,a,o,l,e[u],e[u+1],e[u+2],e[u+3],d),o=e[u+2],l=e[u+3],u+=4;break;case kt.curveTo3:r=o,a=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],o,l,o,l,d),u+=4;break;case kt.closePath:s.closePath()}c&&n.updateScalingPathMinMax(h,d),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,we(e),ui),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,we(e),di),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Oi}eoClip(){this.pendingClip=Ni}beginText(){this.current.textMatrix=O,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:a,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(a,-a));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||N,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||Lt("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,r){this.current.textMatrix=[t,e,i,s,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#di(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,c=l&et,d=!!(l&it),u=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||d||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){if(r.save(),r.translate(e,i),r.scale(h,-h),c===Q||c===Z)if(s){const t=r.getTransform();r.setTransform(...s),r.fill(this.#di(g,t,s))}else r.fill(g);if(c===J||c===Z)if(n){const t=r.getTransform();r.setTransform(...n),r.stroke(this.#di(g,t,n))}else r.lineWidth/=h,r.stroke(g);r.restore()}else c!==Q&&c!==Z||r.fillText(t,e,i),c!==J&&c!==Z||r.strokeText(t,e,i);if(d){(this.pendingTextPaths||=[]).push({transform:ye(r),x:e,y:i,fontSize:h,path:g})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return Bt(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,c=t.length,d=i.vertical,u=d?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===Q&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,we(n),di);m=ye(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,we(n),ui);b=ye(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const y=e.textMatrixScale;if(0===y||0===v){const t=e.textRenderingMode&et;t!==J&&t!==Z||(v=this.getSinglePixelWidth())}else v/=y;if(1!==r&&(n.scale(r,r),v/=r),n.lineWidth=v,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let w,x=0;for(w=0;w<c;++w){const e=t[w];if("number"==typeof e){x+=u*e*s/1e3;continue}let h=!1;const c=(e.isSpace?o:0)+a,v=e.fontChar,y=e.accent;let A,_,S=e.width;if(d){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*S)*g,s=t[2]*g;S=t?-t[0]:S,A=i/r,_=(x+s)/r}else A=x/r,_=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*r;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),A/=e}else S!==t&&(A+=(S-t)/2e3*s/r)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!y)n.fillText(v,A,_);else if(this.paintChar(v,A,_,m,b),y){const t=A+s*y.offset.x/r,e=_-s*y.offset.y/r;this.paintChar(y.fontChar,t,e,m,b)}x+=d?S*g-c*l:S*g+c*l,h&&n.restore()}d?e.y-=x:e.x+=x*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*r,c=i.fontMatrix||N,d=t.length;let u,p,g,f;if(!(i.textRenderingMode===tt)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(h,r),u=0;u<d;++u){if(p=t[u],"number"==typeof p){f=a*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const r=(p.isSpace?l:0)+o,d=s.charProcOperatorList[p.operatorListId];if(!d){Lt(`Type3 character "${p.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=p,this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(d),this.restore());g=Jt.applyTransform([p.width,0],c)[0]*n+r,e.translate(g,0),i.x+=g*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||ye(this.ctx),n={createCanvasGraphics:t=>new Bi(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new _i(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=Jt.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=Jt.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new mi(t);case"Mesh":return new yi(t);case"Dummy":return new wi}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,we(e),pi);const s=we(e);if(s){const{width:t,height:i}=e.canvas,[n,r,a,o]=Jt.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,r,a-n,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Ft("Should not call beginInlineImage")}beginImageData(){Ft("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ye(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(ye(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||Rt("TODO: Support non-isolated groups."),t.knockout&&Lt("Knockout groups not supported.");const i=ye(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=Jt.getAxialAlignedBoundingBox(t.bbox,ye(e));const n=[0,0,e.canvas.width,e.canvas.height];s=Jt.intersect(s,n)||[0,0,0,0];const r=Math.floor(s[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(h,o,l),d=c.context;d.translate(-r,-a),d.transform(...i),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),Ii(e,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=ye(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=Jt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#hi(),Di(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;const[n,a]=Jt.singularValueDecompose2dScale(ye(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:c,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(t,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(n,0,0,-a,0,r*a),Di(this.ctx)}else Di(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new ki(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#ci(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let r,a,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let c=new Uint8Array(h*i),d=0;for(const e of t.data){let t=128;for(;t>0;)c[d++]=e&t?0:255,t>>=1}let u=0;for(d=0,0!==c[d]&&(l[0]=1,++u),a=1;a<e;a++)c[d]!==c[d+1]&&(l[a]=c[d]?2:1,++u),d++;for(0!==c[d]&&(l[a]=2,++u),r=1;r<i;r++){d=r*h,o=r*n,c[d-h]!==c[d]&&(l[o]=c[d]?1:8,++u);let t=(c[d]?4:0)+(c[d-h]?8:0);for(a=1;a<e;a++)t=(t>>2)+(c[d+1]?4:0)+(c[d-h+1]?8:0),s[t]&&(l[o+a]=s[t],++u),d++;if(c[d-h]!==c[d]&&(l[o+a]=c[d]?2:4,++u),u>1e3)return null}for(d=h*(i-1),o=r*n,0!==c[d]&&(l[o]=8,++u),a=1;a<e;a++)c[d]!==c[d+1]&&(l[o+a]=c[d]?4:8,++u),d++;if(0!==c[d]&&(l[o+a]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(r=0;u&&r<=i;r++){let t=r*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,r);const s=t;let a=l[t];do{const e=p[a];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(a=i,l[t]=0):(a=i&51*a>>4,l[t]&=a>>2|a<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--r}return c=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=ye(a);a.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){const h=Jt.transform(o,[e,i,s,n,r[t],r[t+1]]),[c,d]=Jt.applyTransform([0,0],h);a.drawImage(l.canvas,c,d)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:a,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",r,a),h=l.context;h.save();Mi(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,we(e),di):i,h.fillRect(0,0,r,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),Ti(e,l.canvas,0,0,r,a,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):Lt("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void Lt("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!F){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Pi(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,we(s));s.imageSmoothingEnabled=Ri(ye(s),t.interpolate),Ti(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Pi(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Ti(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===Ni?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ye(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(s,n),r.length>0){const t=Math.max(s,n);e.setLineDash(r.map(e=>e/t)),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in kt)void 0!==Bi.prototype[t]&&(Bi.prototype[kt[t]]=Bi.prototype[t]);class zi{static#ui=null;static#pi="";static get workerPort(){return this.#ui}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ui=t}static get workerSrc(){return this.#pi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#pi=t}}class Hi{#gi;#fi;constructor({parsedData:t,rawData:e}){this.#gi=t,this.#fi=e}getRaw(){return this.#fi}get(t){return this.#gi.get(t)??null}getAll(){return Yt(this.#gi)}has(t){return this.#gi.has(t)}}const ji=Symbol("INTERNAL");class Ui{#mi=!1;#bi=!1;#vi=!1;#yi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&H),this.#bi=!!(t&j),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#vi)return this.#yi;if(!this.#yi)return!1;const{print:t,view:e}=this.usage;return this.#mi?"OFF"!==e?.viewState:!this.#bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==ji&&Ft("Internal method `_setVisible` called."),this.#vi=i,this.#yi=e}}class Vi{#wi=null;#xi=new Map;#Ai=null;#_i=null;constructor(t,e=H){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#_i=t.order;for(const i of t.groups)this.#xi.set(i.id,new Ui(e,i));if("OFF"===t.baseState)for(const t of this.#xi.values())t._setVisible(ji,!1);for(const e of t.on)this.#xi.get(e)._setVisible(ji,!0);for(const e of t.off)this.#xi.get(e)._setVisible(ji,!1);this.#Ai=this.getHash()}}#Si(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Si(e);else{if(!this.#xi.has(e))return Lt(`Optional content group not found: ${e}`),!0;n=this.#xi.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#xi.size)return!0;if(!t)return Rt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#xi.has(t.id)?this.#xi.get(t.id).visible:(Lt(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Si(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#xi.has(e))return Lt(`Optional content group not found: ${e}`),!0;if(this.#xi.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#xi.has(e))return Lt(`Optional content group not found: ${e}`),!0;if(!this.#xi.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#xi.has(e))return Lt(`Optional content group not found: ${e}`),!0;if(!this.#xi.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#xi.has(e))return Lt(`Optional content group not found: ${e}`),!0;if(this.#xi.get(e).visible)return!1}return!0}return Lt(`Unknown optional content policy ${t.policy}.`),!0}return Lt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#xi.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#xi.get(i)?._setVisible(ji,!1,!0);s._setVisible(ji,!!e,!0),this.#wi=null}else Lt(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#xi.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#wi=null}get hasInitialVisibility(){return null===this.#Ai||this.getHash()===this.#Ai}getOrder(){return this.#xi.size?this.#_i?this.#_i.slice():[...this.#xi.keys()]:null}getGroups(){return this.#xi.size>0?Yt(this.#xi):null}getGroup(t){return this.#xi.get(t)||null}getHash(){if(null!==this.#wi)return this.#wi;const t=new ze;for(const[e,i]of this.#xi)t.update(`${e}:${i.visible}`);return this.#wi=t.hexdigest()}}class $i{constructor(t,{disableRange:e=!1,disableStream:i=!1}){Ot(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{Ot(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Ot(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Gi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Wi(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Gi{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=he(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Wi{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function qi(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function Xi(t){try{return new URL(t).origin}catch{}return null}function Yi({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function Ki(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=a(s),i&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=Xt(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return n(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(he(t))return t}return null}function Qi(t,e){return 404===t||0===t&&e.startsWith("file:")?new Vt('Missing PDF "'+e+'".'):new $t(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Ji(t){return 200===t||206===t}function Zi(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function ts(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Lt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class es{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=qi(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Ot(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new is(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ss(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class is{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Zi(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=Xi(e.url),!Ji(e.status))throw Qi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=Yi({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Ki(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Wt("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:ts(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ss{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,Zi(n,this._withCredentials,this._abortController)).then(e=>{const i=Xi(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Ji(e.status))throw Qi(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:ts(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ns{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=qi(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",Ot(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:Xt(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(Lt('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class rs{constructor(t){this._source=t,this._manager=new ns(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Ot(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new as(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new os(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class as{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Xi(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=Yi({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Ki(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Qi(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class os{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Xi(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Qi(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const ls=/^[a-z][a-z0-9\-+.]+:/i;class hs{constructor(t){this.source=t,this.url=function(t){if(ls.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),Ot("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Ot(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new cs(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ds(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class cs{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=new Vt(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Wt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class ds{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const us=30;class ps{#Ci=Promise.withResolvers();#pt=null;#Ei=!1;#Ti=!!globalThis.FontInspector?.enabled;#ki=null;#Pi=null;#Mi=0;#Ii=0;#Di=null;#Ri=null;#Li=0;#Fi=0;#Oi=Object.create(null);#Ni=[];#Bi=null;#zi=[];#Hi=new WeakMap;#ji=null;static#Ui=new Map;static#Vi=new Map;static#$i=new WeakMap;static#Gi=null;static#Wi=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#Bi=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#Bi=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#pt=this.#Ri=e,this.#Fi=i.scale*(globalThis.devicePixelRatio||1),this.#Li=i.rotation,this.#Pi={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:r,pageY:a}=i.rawDims;this.#ji=[1,0,0,-1,-r,a+n],this.#Ii=s,this.#Mi=n,ps.#qi(),xe(e,i),this.#Ci.promise.finally(()=>{ps.#Wi.delete(this),this.#Pi=null,this.#Oi=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Kt.platform;return Bt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#Di.read().then(({value:e,done:i})=>{i?this.#Ci.resolve():(this.#ki??=e.lang,Object.assign(this.#Oi,e.styles),this.#Xi(e.items),t())},this.#Ci.reject)};return this.#Di=this.#Bi.getReader(),ps.#Wi.add(this),t(),this.#Ci.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==this.#Li&&(e?.(),this.#Li=s,xe(this.#Ri,{rotation:s})),i!==this.#Fi){e?.(),this.#Fi=i;const t={div:null,properties:null,ctx:ps.#Yi(this.#ki)};for(const e of this.#zi)t.properties=this.#Hi.get(e),t.div=e,this.#Ki(t)}}cancel(){const t=new Wt("TextLayer task cancelled.");this.#Di?.cancel(t).catch(()=>{}),this.#Di=null,this.#Ci.reject(t)}get textDivs(){return this.#zi}get textContentItemsStr(){return this.#Ni}#Xi(t){if(this.#Ei)return;this.#Pi.ctx??=ps.#Yi(this.#ki);const e=this.#zi,i=this.#Ni;for(const s of t){if(e.length>1e5)return Lt("Ignoring additional textDivs for performance reasons."),void(this.#Ei=!0);if(void 0!==s.str)i.push(s.str),this.#Qi(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#pt;this.#pt=document.createElement("span"),this.#pt.classList.add("markedContent"),null!==s.id&&this.#pt.setAttribute("id",`${s.id}`),t.append(this.#pt)}else"endMarkedContent"===s.type&&(this.#pt=this.#pt.parentNode)}}#Qi(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#zi.push(e);const s=Jt.transform(this.#ji,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#Oi[t.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#Ti&&r.fontSubstitution||r.fontFamily;a=ps.fontFamilyMap.get(a)||a;const o=Math.hypot(s[2],s[3]),l=o*ps.#Ji(a,this.#ki);let h,c;0===n?(h=s[4],c=s[5]-l):(h=s[4]+l*Math.sin(n),c=s[5]-l*Math.cos(n));const d="calc(var(--scale-factor)*",u=e.style;this.#pt===this.#Ri?(u.left=`${(100*h/this.#Ii).toFixed(2)}%`,u.top=`${(100*c/this.#Mi).toFixed(2)}%`):(u.left=`${d}${h.toFixed(2)}px)`,u.top=`${d}${c.toFixed(2)}px)`),u.fontSize=`${d}${(ps.#Gi*o).toFixed(2)}px)`,u.fontFamily=a,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Ti&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(i.canvasWidth=r.vertical?t.height:t.width),this.#Hi.set(e,i),this.#Pi.div=e,this.#Pi.properties=i,this.#Ki(this.#Pi),i.hasText&&this.#pt.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Ki(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let r="";if(ps.#Gi>1&&(r=`scale(${1/ps.#Gi})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:a,fontSize:o}=i;ps.#Zi(s,o*this.#Fi,t);const{width:l}=s.measureText(e.textContent);l>0&&(r=`scaleX(${a*this.#Fi/l}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#Wi.size>0)){this.#Ui.clear();for(const{canvas:t}of this.#Vi.values())t.remove();this.#Vi.clear()}}static#Yi(t=null){let e=this.#Vi.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Vi.set(t,e),this.#$i.set(e,{size:0,family:""})}return e}static#Zi(t,e,i){const s=this.#$i.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#qi(){if(null!==this.#Gi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Gi=t.getBoundingClientRect().height,t.remove()}static#Ji(t,e){const i=this.#Ui.get(t);if(i)return i;const s=this.#Yi(e);s.canvas.width=s.canvas.height=us,this.#Zi(s,us,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const e=r/(r+a);return this.#Ui.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,us,us),s.strokeText("g",0,0);let o=s.getImageData(0,0,us,us).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/us);break}s.clearRect(0,0,us,us),s.strokeText("A",0,us),o=s.getImageData(0,0,us,us).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=us-Math.floor(t/4/us);break}s.canvas.width=s.canvas.height=0;const l=r?r/(r+a):.8;return this.#Ui.set(t,l),l}}class gs{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!gs.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const fs=65536,ms=F?class extends ni{_createCanvas(e,i){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(e,i)}}:class extends ni{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}},bs=F?class extends ri{async _fetch(t){return ci(t)}}:ai,vs=F?class extends oi{}:class extends oi{#ts;#es;#is;#ss;#ns;#rs;#y=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#x(){return this.#es||=new Map}get#as(){return this.#rs||=new Map}get#os(){if(!this.#is){const t=this.#ns.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#ns.createElementNS(se,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS(se,"defs"),t.append(i),i.append(this.#is),this.#ns.body.append(t)}return this.#is}#ls(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(le(t)?Lt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ts=t.split("#",1)[0])}return`url(${this.#ts}#${t})`}addFilter(t){if(!t)return"none";let e=this.#x.get(t);if(e)return e;const[i,s,n]=this.#ls(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#x.get(r),e)return this.#x.set(t,e),e;const a=`g_${this.#ss}_transfer_map_${this.#y++}`,o=this.#hs(a);this.#x.set(t,o),this.#x.set(r,o);const l=this.#cs(a);return this.#ds(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#as.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#as.set(s,n)),!t||!e)return n.url;const r=this.#us(t);t=Jt.makeHexColor(...r);const a=this.#us(e);if(e=Jt.makeHexColor(...a),this.#os.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#ss}_hcm_filter`,c=n.filter=this.#cs(h);this.#ds(l,l,l,c),this.#ps(c);const d=(t,e)=>{const i=r[t]/255,s=a[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#ds(d(0,5),d(1,5),d(2,5),c),n.url=this.#hs(h),n.url}addAlphaFilter(t){let e=this.#x.get(t);if(e)return e;const[i]=this.#ls([t]),s=`alpha_${i}`;if(e=this.#x.get(s),e)return this.#x.set(t,e),e;const n=`g_${this.#ss}_alpha_map_${this.#y++}`,r=this.#hs(n);this.#x.set(t,r),this.#x.set(s,r);const a=this.#cs(n);return this.#gs(i,a),r}addLuminosityFilter(t){let e,i,s=this.#x.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ls([t]),i=`luminosity_${e}`):i="luminosity",s=this.#x.get(i),s)return this.#x.set(t,s),s;const n=`g_${this.#ss}_luminosity_map_${this.#y++}`,r=this.#hs(n);this.#x.set(t,r),this.#x.set(i,r);const a=this.#cs(n);return this.#fs(a),t&&this.#gs(e,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#as.get(t);if(a?.key===r)return a.url;if(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#as.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#us.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[s,n].map(this.#us.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#os.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(c-h)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ss}_hcm_${t}_filter`,f=a.filter=this.#cs(g);return this.#ps(f),this.#ds(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),a.url=this.#hs(g),a.url}destroy(t=!1){t&&this.#rs?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#rs?.clear(),this.#rs=null,this.#y=0)}#fs(t){const e=this.#ns.createElementNS(se,"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)}#ps(t){const e=this.#ns.createElementNS(se,"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)}#cs(t){const e=this.#ns.createElementNS(se,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#os.append(e),e}#ms(t,e,i){const s=this.#ns.createElementNS(se,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#ds(t,e,i,s){const n=this.#ns.createElementNS(se,"feComponentTransfer");s.append(n),this.#ms(n,"feFuncR",t),this.#ms(n,"feFuncG",e),this.#ms(n,"feFuncB",i)}#gs(t,e){const i=this.#ns.createElementNS(se,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,ve(getComputedStyle(this.#os).getPropertyValue("color"))}},ys=F?class extends li{async _fetch(t){return ci(t)}}:hi;function ws(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new As,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(F&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(F&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Xt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof _s?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:fs;let c=t.worker instanceof Ts?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||le(t.docBaseUrl)?null:t.docBaseUrl,p="string"==typeof t.cMapUrl?t.cMapUrl:null,g=!1!==t.cMapPacked,f=t.CMapReaderFactory||bs,m="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,b=t.StandardFontDataFactory||ys,v=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,w=!1!==t.isEvalSupported,x="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!F,A="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!F&&(Kt.platform.isFirefox||!globalThis.chrome),_=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,S="boolean"==typeof t.disableFontFace?t.disableFontFace:F,C=!0===t.fontExtraProperties,E=!0===t.enableXfa,T=t.ownerDocument||globalThis.document,k=!0===t.disableRange,P=!0===t.disableStream,M=!0===t.disableAutoFetch,I=!0===t.pdfBug,D=t.CanvasFactory||ms,R=t.FilterFactory||vs,L=!0===t.enableHWA,O=l?l.length:t.length??NaN,N="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!F&&!S,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:f===ai&&b===hi&&p&&m&&pe(p,document.baseURI)&&pe(m,document.baseURI);It(d);const z={canvasFactory:new D({ownerDocument:T,enableHWA:L}),filterFactory:new R({docId:i,ownerDocument:T}),cMapReaderFactory:B?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:B?null:new b({baseUrl:m})};if(!c){const t={verbosity:d,port:zi.workerPort};c=t.port?Ts.fromPort(t):new Ts(t),e._worker=c}const H={docId:i,apiVersion:"4.10.38",data:n,password:o,disableAutoFetch:M,rangeChunkSize:h,length:O,docBaseUrl:u,enableXfa:E,evaluatorOptions:{maxImageSize:y,disableFontFace:S,ignoreErrors:v,isEvalSupported:w,isOffscreenCanvasSupported:x,isImageDecoderSupported:A,canvasMaxAreaInBytes:_,fontExtraProperties:C,useSystemFonts:N,cMapUrl:B?p:null,standardFontDataUrl:B?m:null}},j={disableFontFace:S,fontExtraProperties:C,ownerDocument:T,pdfBug:I,styleElement:null,loadingParams:{disableAutoFetch:M,enableXfa:E}};return c.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",H,n?[n.buffer]:null);let o;if(l)o=new $i(l,{disableRange:k,disableStream:P});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(F)if(pe(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=es}else t=hs;else t=pe(s)?es:rs;o=new t({url:s,length:O,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:k,disableStream:P})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new si(i,t,c.port),n=new ks(s,e,o,j,z);e._transport=n,s.send("Ready",null)})}).catch(e._capability.reject),e}function xs(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class As{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+As.#ss++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}class _s{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const i of this._progressListeners)i(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Ft("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ss{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Bt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Cs{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new ue:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new Ms,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new ae({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Bt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=q.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:c=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(i,s,h,c),{renderingIntent:u,cacheKey:p}=d;this.#vs=!1,this.#ys(),a||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&j);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const m=t=>{g.renderTasks.delete(b),(this._maybeCleanupAfterRender||f)&&(this.#vs=!0),this.#ws(!f),t?(b.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new Ds({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||=new Set).add(b);const v=b.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:t,optionalContentConfig:e}),b.operatorListChanged()}}).catch(m),v}getOperatorList({intent:t="display",annotationMode:e=q.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>gs.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#vs=!1,this.#ys(),Promise.all(t)}cleanup(t=!1){this.#vs=!0;const e=this.#ws(!1);return t&&e&&(this._stats&&=new ue),e}#ws(t=!1){if(this.#ys(),!this.#vs||this.destroyed)return!1;if(t)return this.#bs=setTimeout(()=>{this.#bs=null,this.#ws(!1)},5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#vs=!1,!0}#ys(){this.#bs&&(clearTimeout(this.#bs),this.#bs=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#ws(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then(({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#ws(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof oe){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i))}}if(t.streamReader.cancel(new Wt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class Es{#xs=new Map;#As=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#As.then(()=>{for(const[t]of this.#xs)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void Lt("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#xs.set(e,s)}removeEventListener(t,e){const i=this.#xs.get(e);i?.(),this.#xs.delete(e)}terminate(){for(const[,t]of this.#xs)t?.();this.#xs.clear()}}class Ts{static#_s=0;static#Ss=!1;static#Cs;static{F&&(this.#Ss=!0,zi.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=Dt()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(Ts.#Cs?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(Ts.#Cs||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return this._readyCapability.promise}#Es(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new si("main","worker",t),this._messageHandler.on("ready",function(){}),this.#Es()}_initialize(){if(Ts.#Ss||Ts.#Ts)return void this._setupFakeWorker();let{workerSrc:t}=Ts;try{Ts._isSameOrigin(window.location.href,t)||(t=Ts._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new si("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:n.signal}),i.on("test",t=>{n.abort(),!this.destroyed&&t?(this._messageHandler=i,this._port=e,this._webWorker=e,this.#Es()):s()}),i.on("ready",t=>{if(n.abort(),this.destroyed)s();else try{r()}catch{this._setupFakeWorker()}});const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{Rt("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Ts.#Ss||(Lt("Setting up fake worker."),Ts.#Ss=!0),Ts._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new Es;this._port=e;const i="fake"+Ts.#_s++,s=new si(i+"_worker",i,e);t.setup(s,e),this._messageHandler=new si(i,i+"_worker",e),this.#Es()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,Ts.#Cs?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#Cs?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Ts(t)}static get workerSrc(){if(zi.workerSrc)return zi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ts(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Bt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ts)return this.#Ts;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class ks{#ks=new Map;#Ps=new Map;#Ms=new Map;#Is=new Map;#Ds=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Ms,this.fontLoader=new Ve({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Rs(t,e=null){const i=this.#ks.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#ks.set(t,s),s}get annotationStorage(){return Bt(this,"annotationStorage",new je)}getRenderingIntent(t,e=q.ENABLE,i=null,s=!1,n=!1){let r=H,a=He;switch(t){case"any":r=z;break;case"display":break;case"print":r=j;break;default:Lt(`getRenderingIntent - invalid intent: ${t}`)}const o=r&j&&i instanceof Ue?i:this.annotationStorage;switch(e){case q.DISABLE:r+=$;break;case q.ENABLE:break;case q.ENABLE_FORMS:r+=U;break;case q.ENABLE_STORAGE:r+=V,a=o.serializable;break;default:Lt(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=G),n&&(r+=W);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ds?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ps.values())t.push(e._destroy());this.#Ps.clear(),this.#Ms.clear(),this.#Is.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#ks.clear(),this.filterFactory.destroy(),ps.cleanup(),this._networkStream?.cancelAllRequests(new Wt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{Ot(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(Ot(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}}),t.on("GetRangeReader",(t,e)=>{Ot(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(Ot(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Ss(t,this))}),t.on("DocException",t=>{e._capability.reject(ii(t))}),t.on("PasswordRequest",t=>{this.#Ds=Promise.withResolvers();try{if(!e.onPassword)throw ii(t);const i=t=>{t instanceof Error?this.#Ds.reject(t):this.#Ds.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Ds.reject(t)}return this.#Ds.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;this.#Ps.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const{disableFontFace:n,fontExtraProperties:r,pdfBug:a}=this._params;if("error"in s){const t=s.error;Lt(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new $e(s,{disableFontFace:n,fontExtraProperties:r,inspectFont:o});this.fontLoader.bind(l).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!r&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)});break;case"CopyLocalImage":const{imageRef:h}=s;Ot(h,"The imageRef must be defined.");for(const t of this.#Ps.values())for(const[,i]of t.objs)if(i?.ref===h)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;const n=this.#Ps.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":n.objs.resolve(t,s),s?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBuiltInCMap",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)}),t.on("FetchStandardFontData",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Lt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#Ms.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Is.set(i.refStr,t);const s=new Cs(e,i,this,this._params.pdfBug);return this.#Ps.set(e,s),s});return this.#Ms.set(e,s),s}getPageIndex(t){return xs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#Rs("GetFieldObjects")}hasJSActions(){return this.#Rs("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Rs("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Rs("GetOptionalContentConfig").then(e=>new Vi(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#ks.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new Hi(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#ks.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Ps.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#ks.clear(),this.filterFactory.destroy(!0),ps.cleanup()}}cachedPageNumber(t){if(!xs(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Is.get(e)??null}}const Ps=Symbol("INITIAL_DATA");class Ms{#Ls=Object.create(null);#Fs(t){return this.#Ls[t]||={...Promise.withResolvers(),data:Ps}}get(t,e=null){if(e){const i=this.#Fs(t);return i.promise.then(()=>e(i.data)),null}const i=this.#Ls[t];if(!i||i.data===Ps)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Ls[t];return!!e&&e.data!==Ps}delete(t){const e=this.#Ls[t];return!(!e||e.data===Ps)&&(delete this.#Ls[t],!0)}resolve(t,e=null){const i=this.#Fs(t);i.data=e,i.resolve()}clear(){for(const t in this.#Ls){const{data:e}=this.#Ls[t];e?.bitmap?.close()}this.#Ls=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Ls){const{data:e}=this.#Ls[t];e!==Ps&&(yield[t,e])}}}class Is{#Os=null;constructor(t){this.#Os=t,this.onContinue=null}get promise(){return this.#Os.capability.promise}cancel(t=0){this.#Os.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Os.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Os;return t.form||t.canvas&&e?.size>0}}class Ds{#Ns=null;static#Bs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,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=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Is(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.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Ds.#Bs.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Ds.#Bs.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new Bi(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Ns&&(window.cancelAnimationFrame(this.#Ns),this.#Ns=null),Ds.#Bs.delete(this._canvas),this.callback(t||new oe(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Ns=window.requestAnimationFrame(()=>{this.#Ns=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Ds.#Bs.delete(this._canvas),this.callback())))}}const Rs="4.10.38",Ls="f9bea397f";R(670);function Fs(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Os(t){return Math.max(0,Math.min(255,255*t))}class Ns{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}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]}static G_HTML([t]){const e=Fs(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Os)}static RGB_HTML(t){return`#${t.map(Fs).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Os(1-Math.min(1,t+s)),Os(1-Math.min(1,i+s)),Os(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Bs{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Ft("Abstract method `_createSVG` called.")}}class zs extends Bs{_createSVG(t){return document.createElementNS(se,t)}}class Hs{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a="richText"!==n,o=t.div;if(o.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),a&&gs.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,r]];for(;h.length>0;){const[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);l.push(t),r.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(r.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);a&&gs.shouldBuildText(c)&&l.push(t),d.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const js=1e3,Us=new WeakSet;function Vs(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class $s{static create(t){switch(t.data.annotationType){case rt:return new Ws(t);case nt:return new qs(t);case xt:switch(t.data.fieldType){case"Tx":return new Ys(t);case"Btn":return t.data.radioButton?new Js(t):t.data.checkBox?new Qs(t):new Zs(t);case"Ch":return new tn(t);case"Sig":return new Ks(t)}return new Xs(t);case yt:return new en(t);case at:return new nn(t);case ot:return new rn(t);case lt:return new an(t);case ht:return new on(t);case dt:return new ln(t);case bt:return new cn(t);case vt:return new dn(t);case ct:return new hn(t);case ut:return new un(t);case pt:return new pn(t);case gt:return new gn(t);case ft:return new fn(t);case mt:return new mn(t);case wt:return new bn(t);default:return new Gs(t)}}}class Gs{#zs=null;#Hs=!1;#js=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){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.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Gs._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#zs||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#Us(e),this.#js?.popup.updateEdited(t)}resetEdited(){this.#zs&&(this.#Us(this.#zs.rect),this.#js?.popup.resetEdited(),this.#zs=null)}#Us(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=Vs(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Xs||(n.tabIndex=js);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof en){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=Vs(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof Js){const t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case At:r.borderStyle="solid";break;case _t:r.borderStyle="dashed";break;case St:Lt("Unimplemented border style: beveled");break;case Ct:Lt("Unimplemented border style: inset");break;case Et:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Hs=!0,r.borderColor=Jt.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=Jt.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=s.rawDims;r.left=100*(l[0]-d)/h+"%",r.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=Vs(this.data.rect);let a,o;t%180==0?(a=100*n/i,o=100*r/s):(a=100*r/i,o=100*n/s),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Ns[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Ns[`${n}_rgb`](r)})};return Bt(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.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:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Hs){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],c=t[i+2],d=t[i+3],p=h.createElement("rect"),g=(c-e)/o,f=(n-r)/l,m=(s-c)/o,b=(r-d)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#Hs&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#js=new en({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){Ft("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||Us.has(a)?i.push({id:n,exportValue:s,domElement:a}):Lt(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(Us.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class Ws extends Gs{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#Vs(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#$s(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#Gs(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Gs()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Gs()}#Vs(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#Gs()}#$s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Gs()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Gs()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Gs(),!this._fieldObjects)return Lt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const a=this.annotationStorage,o=[];for(const t of r){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Us.has(i)?i.dispatchEvent(new Event("resetform")):Lt(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class qs extends Gs{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Xs extends Gs{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Kt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})})}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Jt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(B*s))||1);r=Math.min(s,a(e/B))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/B))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=Jt.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Ys extends Xs{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Us.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=js,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const s=l;l=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Ks extends Xs{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Qs extends Xs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Us.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=js,n.addEventListener("change",s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})}),n.addEventListener("resetform",t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Js extends Xs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Us.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=js,n.addEventListener("change",e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})}),n.addEventListener("resetform",t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Zs extends Ws{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class tn extends Xs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Us.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=js;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e});for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{const n={value(i){r?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,c=s.children[n],d=document.createElement("option");d.textContent=r,d.value=h,c?c.before(d):s.append(d),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)}),s.addEventListener("input",i=>{const s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class en extends Gs{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:Gs._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new sn({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(t=>`${ie}${t}`).join(",")),this.container}}class sn{#Ws=this.#qs.bind(this);#Xs=this.#Ys.bind(this);#Ks=this.#Qs.bind(this);#Js=this.#Zs.bind(this);#tn=null;#pt=null;#en=null;#in=null;#sn=null;#nn=null;#rn=null;#an=!1;#on=null;#E=null;#ln=null;#hn=null;#cn=null;#zs=null;#dn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:c}){this.#pt=t,this.#cn=s,this.#en=r,this.#hn=a,this.#nn=o,this.#tn=e,this.#ln=l,this.#rn=h,this.#sn=i,this.#in=me.toDateObject(n),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup());for(const t of this.trigger)t.addEventListener("click",this.#Js),t.addEventListener("mouseenter",this.#Ks),t.addEventListener("mouseleave",this.#Xs),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Ws);this.#pt.hidden=!0,c&&this.#Zs()}render(){if(this.#on)return;const t=this.#on=document.createElement("div");if(t.className="popup",this.#tn){const e=t.style.outlineColor=Jt.makeHexColor(...this.#tn);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=Jt.makeHexColor(...this.#tn.map(t=>Math.floor(e*(255-t)+t)))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#cn),t.append(e),this.#in){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#in.valueOf()})),e.append(t)}const s=this.#un;if(s)Hs.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#en);t.append(e)}this.#pt.append(t)}get#un(){const t=this.#hn,e=this.#en;return!t?.str||e?.str&&e.str!==t.str?null:this.#hn.html||null}get#pn(){return this.#un?.attributes?.style?.fontSize||0}get#gn(){return this.#un?.attributes?.style?.color||null}#fn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#gn,fontSize:this.#pn?`calc(${this.#pn}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#qs(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#an)&&this.#Zs()}updateEdited({rect:t,popupContent:e}){this.#zs||={contentsObj:this.#en,richText:this.#hn},t&&(this.#E=null),e&&(this.#hn=this.#fn(e),this.#en=null),this.#on?.remove(),this.#on=null}resetEdited(){this.#zs&&(({contentsObj:this.#en,richText:this.#hn}=this.#zs),this.#zs=null,this.#on?.remove(),this.#on=null,this.#E=null)}#mn(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nn;let r=!!this.#rn,a=r?this.#rn:this.#ln;for(const t of this.#sn)if(!a||null!==Jt.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=Jt.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,c=o[1];this.#E=[100*(h-s)/e,100*(c-n)/i];const{style:d}=this.#pt;d.left=`${this.#E[0]}%`,d.top=`${this.#E[1]}%`}#Zs(){this.#an=!this.#an,this.#an?(this.#Qs(),this.#pt.addEventListener("click",this.#Js),this.#pt.addEventListener("keydown",this.#Ws)):(this.#Ys(),this.#pt.removeEventListener("click",this.#Js),this.#pt.removeEventListener("keydown",this.#Ws))}#Qs(){this.#on||this.render(),this.isVisible?this.#an&&this.#pt.classList.add("focused"):(this.#mn(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ys(){this.#pt.classList.remove("focused"),!this.#an&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#dn=this.isVisible,this.#dn&&(this.#pt.hidden=!0)}maybeShow(){this.#dn&&(this.#on||this.#Qs(),this.#dn=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class nn extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=X.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class rn extends Gs{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=Vs(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#bn=this.svgFactory.createElement("svg:line");return 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"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#bn}addHighlightArea(){this.container.classList.add("highlightArea")}}class an extends Gs{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=Vs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#vn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class on extends Gs{#yn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=Vs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#yn=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class ln extends Gs{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:r}=Vs(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#wn=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class hn extends ln{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class cn extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class dn extends Gs{#xn=null;#An=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?X.HIGHLIGHT:X.INK}#_n(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);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#_n(e,t),l=this.svgFactory.create(a,o,!0),h=this.#xn=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.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 t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#An.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#xn;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#An.length;t<e;t++)this.#An[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#_n(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#An}addHighlightArea(){this.container.classList.add("highlightArea")}}class un extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=X.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class pn extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class gn extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class fn extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class mn extends Gs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=X.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class bn extends Gs{#Sn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Cn.bind(this)),this.#Sn=i;const{isMac:s}=Kt.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Cn()}),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}#Cn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class vn{#En=null;#Tn=null;#kn=new Map;#Pn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#En=e,this.#Tn=i,this.#Pn=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#kn.size>0}async#Mn(t,e){const i=t.firstChild||t,s=i.id=`${ie}${e}`,n=await(this.#Pn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#En?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;xe(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new zs,annotationStorage:t.annotationStorage||new je,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===yt;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=Vs(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=$s.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#Mn(r,t.id),i._isEditable&&(this.#kn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#In()}update({viewport:t}){const e=this.div;this.viewport=t,xe(e,{rotation:t.rotation}),this.#In(),e.hidden=!1}#In(){if(!this.#Tn)return;const t=this.div;for(const[e,i]of this.#Tn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#Tn.clear()}getEditableAnnotations(){return Array.from(this.#kn.values())}getEditableAnnotation(t){return this.#kn.get(t)}}const yn=/\r\n?|\n/g;class wn extends Le{#tn;#Dn="";#Rn=`${this.id}-editor`;#Ln=null;#pn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=wn.prototype,e=t=>t.isEmpty(),i=Ie.TRANSLATE_SMALL,s=Ie.TRANSLATE_BIG;return Bt(this,"_keyboardManager",new Pe([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=X.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#tn=t.color||wn._defaultColor||Le._defaultLineColor,this.#pn=t.fontSize||wn._defaultFontSize}static initialize(t,e){Le.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Y.FREETEXT_SIZE:wn._defaultFontSize=e;break;case Y.FREETEXT_COLOR:wn._defaultColor=e}}updateParams(t,e){switch(t){case Y.FREETEXT_SIZE:this.#Fn(e);break;case Y.FREETEXT_COLOR:this.#On(e)}}static get defaultPropertiesToUpdate(){return[[Y.FREETEXT_SIZE,wn._defaultFontSize],[Y.FREETEXT_COLOR,wn._defaultColor||Le._defaultLineColor]]}get propertiesToUpdate(){return[[Y.FREETEXT_SIZE,this.#pn],[Y.FREETEXT_COLOR,this.#tn]]}#Fn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#pn)*this.parentScale),this.#pn=t,this.#Nn()},i=this.#pn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#On(t){const e=t=>{this.#tn=this.editorDiv.style.color=t},i=this.#tn;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-wn._internalPadding*t,-(wn._internalPadding+this.#pn)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(X.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Ln=new AbortController;const t=this._uiManager.combinedSignal(this.#Ln);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})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Rn),this._isDraggable=!0,this.#Ln?.abort(),this.#Ln=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Bn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(wn.#zn(i)),e=i);return t.join("\n")}#Nn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Dn,e=this.#Dn=this.#Bn().trimEnd();if(t===e)return;const i=t=>{this.#Dn=t,t?(this.#Hn(),this._uiManager.rebuild(this),this.#Nn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Nn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){wn._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)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Rn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ce(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[r,a]=[a,-r];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[r,a]=[-r,-a];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[r,a]=[-a,r]}this.setAt(d*i,u*s,r,a)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#Hn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#zn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(yn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=wn.#jn(e.getData("text")||"").replaceAll(yn,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(yn,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(wn.#zn(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(yn,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(wn.#zn(i))}this.#Dn=`${l.join("\n")}${s}${h.join("\n")}`,this.#Hn();const c=new Range;let d=l.reduce((t,e)=>t+e.length,0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(d<=e){c.setStart(t,d),c.setEnd(t,d);break}d-=e}n.removeAllRanges(),n.addRange(c)}#Hn(){if(this.editorDiv.replaceChildren(),this.#Dn)for(const t of this.#Dn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Un(){return this.#Dn.replaceAll(" "," ")}static#jn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof nn){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:c}}}=t;if(!l||0===l.length)return null;s=t={annotationType:X.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:c-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#pn=t.fontSize,n.#tn=Jt.makeHexColor(...t.color),n.#Dn=wn.#jn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=wn._internalPadding*this.parentScale,i=this.getRect(e,e),s=Le._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:X.FREETEXT,color:s,fontSize:this.#pn,value:this.#Un(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Vn(n)?null:(n.id=this.annotationElementId,n)}#Vn(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#pn}px * var(--scale-factor))`,i.color=this.#tn,e.replaceChildren();for(const t of this.#Dn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=wn._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Dn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class xn{static PRECISION=1e-4;toSVGPath(){Ft("Abstract method `toSVGPath` must be implemented.")}get box(){Ft("Abstract getter `box` must be implemented.")}serialize(t,e){Ft("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class An{#$n;#Gn=[];#Wn;#qn;#Xn=[];#Yn=new Float32Array(18);#Kn;#Qn;#Jn;#Zn;#tr;#er;#ir=[];static#sr=8;static#nr=2;static#rr=An.#sr+An.#nr;constructor({x:t,y:e},i,s,n,r,a=0){this.#$n=i,this.#er=n*s,this.#qn=r,this.#Yn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Wn=a,this.#Zn=An.#sr*s,this.#Jn=An.#rr*s,this.#tr=s,this.#ir.push(t,e)}isEmpty(){return isNaN(this.#Yn[8])}#ar(){const t=this.#Yn.subarray(4,6),e=this.#Yn.subarray(16,18),[i,s,n,r]=this.#$n;return[(this.#Kn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/r,(this.#Kn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#Kn=t,this.#Qn=e;const[i,s,n,r]=this.#$n;let[a,o,l,h]=this.#Yn.subarray(8,12);const c=t-l,d=e-h,u=Math.hypot(c,d);if(u<this.#Jn)return!1;const p=u-this.#Zn,g=p/u,f=g*c,m=g*d;let b=a,v=o;a=l,o=h,l+=f,h+=m,this.#ir?.push(t,e);const y=f/p,w=-m/p*this.#er,x=y*this.#er;if(this.#Yn.set(this.#Yn.subarray(2,8),0),this.#Yn.set([l+w,h+x],4),this.#Yn.set(this.#Yn.subarray(14,18),12),this.#Yn.set([l-w,h-x],16),isNaN(this.#Yn[6]))return 0===this.#Xn.length&&(this.#Yn.set([a+w,o+x],2),this.#Xn.push(NaN,NaN,NaN,NaN,(a+w-i)/n,(o+x-s)/r),this.#Yn.set([a-w,o-x],14),this.#Gn.push(NaN,NaN,NaN,NaN,(a-w-i)/n,(o-x-s)/r)),this.#Yn.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Yn.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(m,f))<Math.PI/2?([a,o,l,h]=this.#Yn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#Yn.subarray(14,18),this.#Gn.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r),!0):([b,v,a,o,l,h]=this.#Yn.subarray(0,6),this.#Xn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,v]=this.#Yn.subarray(12,18),this.#Gn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Xn,e=this.#Gn;if(isNaN(this.#Yn[6])&&!this.isEmpty())return this.#or();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#lr(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#hr(i),i.join(" ")}#or(){const[t,e,i,s]=this.#$n,[n,r,a,o]=this.#ar();return`M${(this.#Yn[2]-t)/i} ${(this.#Yn[3]-e)/s} L${(this.#Yn[4]-t)/i} ${(this.#Yn[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#Yn[16]-t)/i} ${(this.#Yn[17]-e)/s} L${(this.#Yn[14]-t)/i} ${(this.#Yn[15]-e)/s} Z`}#hr(t){const e=this.#Gn;t.push(`L${e[4]} ${e[5]} Z`)}#lr(t){const[e,i,s,n]=this.#$n,r=this.#Yn.subarray(4,6),a=this.#Yn.subarray(16,18),[o,l,h,c]=this.#ar();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new _n(t,e,i,s,n,r)}getOutlines(){const t=this.#Xn,e=this.#Gn,i=this.#Yn,[s,n,r,a]=this.#$n,o=new Float32Array((this.#ir?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ir[t]-s)/r,o[t+1]=(this.#ir[t+1]-n)/a;if(o[o.length-2]=(this.#Kn-s)/r,o[o.length-1]=(this.#Qn-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#cr(o);const l=new Float32Array(this.#Xn.length+24+this.#Gn.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#dr(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#ur(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#tr,this.#Wn,this.#qn)}#cr(t){const e=this.#Yn,[i,s,n,r]=this.#$n,[a,o,l,h]=this.#ar(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(c,t,this.#$n,this.#tr,this.#Wn,this.#qn)}#ur(t,e){const i=this.#Gn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#dr(t,e){const i=this.#Yn.subarray(4,6),s=this.#Yn.subarray(16,18),[n,r,a,o]=this.#$n,[l,h,c,d]=this.#ar();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24}}class _n extends xn{#$n;#pr=new Float32Array(4);#Wn;#qn;#ir;#tr;#gr;constructor(t,e,i,s,n,r){super(),this.#gr=t,this.#ir=e,this.#$n=i,this.#tr=s,this.#Wn=n,this.#qn=r,this.lastPoint=[NaN,NaN],this.#fr(r);const[a,o,l,h]=this.#pr;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#gr[4]} ${this.#gr[5]}`];for(let e=6,i=this.#gr.length;e<i;e+=6)isNaN(this.#gr[e])?t.push(`L${this.#gr[e+4]} ${this.#gr[e+5]}`):t.push(`C${this.#gr[e]} ${this.#gr[e+1]} ${this.#gr[e+2]} ${this.#gr[e+3]} ${this.#gr[e+4]} ${this.#gr[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=xn._rescale(this.#gr,t,s,r,-a),l=xn._rescale(this.#ir,t,s,r,-a);break;case 90:o=xn._rescaleAndSwap(this.#gr,t,e,r,a),l=xn._rescaleAndSwap(this.#ir,t,e,r,a);break;case 180:o=xn._rescale(this.#gr,i,e,-r,a),l=xn._rescale(this.#ir,i,e,-r,a);break;case 270:o=xn._rescaleAndSwap(this.#gr,i,s,-r,-a),l=xn._rescaleAndSwap(this.#ir,i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#fr(t){const e=this.#gr;let i=e[4],s=e[5],n=i,r=s,a=i,o=s,l=i,h=s;const c=t?Math.max:Math.min;for(let t=6,d=e.length;t<d;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),r=Math.min(r,e[t+5]),a=Math.max(a,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=c(l,e[t+4]));else{const d=Jt.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,d[0]),r=Math.min(r,d[1]),a=Math.max(a,d[2]),o=Math.max(o,d[3]),h<d[3]?(l=d[2],h=d[3]):h===d[3]&&(l=c(l,d[2]))}i=e[t+4],s=e[t+5]}const d=this.#pr;d[0]=n-this.#Wn,d[1]=r-this.#Wn,d[2]=a-n+2*this.#Wn,d[3]=o-r+2*this.#Wn,this.lastPoint=[l,h]}get box(){return this.#pr}newOutliner(t,e,i,s,n,r=0){return new An(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#pr,[a,o,l,h]=this.#$n,c=n*l,d=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#ir[0]*c+u,y:this.#ir[1]*d+p},this.#$n,this.#tr,t,this.#qn,e??this.#Wn);for(let t=2;t<this.#ir.length;t+=2)g.add({x:this.#ir[t]*c+u,y:this.#ir[t+1]*d+p});return g.getOutlines()}}class Sn{#$n;#mr;#br=[];#vr=[];constructor(t,e=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:c}of t){const t=Math.floor((i-e)/l)*l,d=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+c+e)/l)*l,g=[t,u,p,!0],f=[d,u,p,!1];this.#br.push(g,f),n=Math.min(n,t),r=Math.max(r,d),a=Math.min(a,u),o=Math.max(o,p)}const h=r-n+2*i,c=o-a+2*i,d=n-i,u=a-i,p=this.#br.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#br){const[e,i,s]=t;t[0]=(e-d)/h,t[1]=(i-u)/c,t[2]=(s-u)/c}this.#$n=new Float32Array([d,u,h,c]),this.#mr=g}getOutlines(){this.#br.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of this.#br)e[3]?(t.push(...this.#yr(e)),this.#wr(e)):(this.#xr(e),t.push(...this.#yr(e)));return this.#Ar(t)}#Ar(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,c=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,c,e,c===r?r:a),h=e),c=c===r?a:r}n.push(h,c)}return new Cn(s,this.#$n,this.#mr)}#_r(t){const e=this.#vr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#wr([,t,e]){const i=this.#_r(t);this.#vr.splice(i,0,[t,e])}#xr([,t,e]){const i=this.#_r(t);for(let s=i;s<this.#vr.length;s++){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}}#yr(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#_r(s);for(let t=0;t<r;t++){const[i,s]=this.#vr[t];for(let t=0,r=n.length;t<r;t++){const[,a,o]=n[t];if(!(s<=a||o<=i))if(a>=i)if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class Cn extends xn{#$n;#Sr;constructor(t,e,i){super(),this.#Sr=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sr){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const e of this.#Sr){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class En extends An{newFreeDrawOutline(t,e,i,s,n,r){return new Tn(t,e,i,s,n,r)}}class Tn extends _n{newOutliner(t,e,i,s,n,r=0){return new En(t,e,i,s,n,r)}}class kn{#Cr=null;#Er=null;#Tr;#kr=null;#Pr=!1;#Mr=!1;#r=null;#Ir;#Dr=null;#f=null;#Rr;static#Lr=null;static get _keyboardManager(){return Bt(this,"_keyboardManager",new Pe([[["Escape","mac+Escape"],kn.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],kn.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],kn.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],kn.prototype._moveToPrevious],[["Home","mac+Home"],kn.prototype._moveToBeginning],[["End","mac+End"],kn.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#Mr=!1,this.#Rr=Y.HIGHLIGHT_COLOR,this.#r=t):(this.#Mr=!0,this.#Rr=Y.HIGHLIGHT_DEFAULT_COLOR),this.#f=t?._uiManager||e,this.#Ir=this.#f._eventBus,this.#Tr=t?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",kn.#Lr||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#Cr=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#f._signal;t.addEventListener("click",this.#Fr.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Er=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Tr,t.append(i),t}renderMainDropdown(){const t=this.#kr=this.#Or();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Or(){const t=document.createElement("div"),e=this.#f._signal;t.addEventListener("contextmenu",ge,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#f.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",kn.#Lr[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#Tr),n.addEventListener("click",this.#Nr.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#qs.bind(this),{signal:e}),t}#Nr(t,e){e.stopPropagation(),this.#Ir.dispatch("switchannotationeditorparams",{source:this,type:this.#Rr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Cr)return void this.#Fr(t);const e=t.target.getAttribute("data-color");e&&this.#Nr(e,t)}_moveToNext(t){this.#Br?t.target!==this.#Cr?t.target.nextSibling?.focus():this.#kr.firstChild?.focus():this.#Fr(t)}_moveToPrevious(t){t.target!==this.#kr?.firstChild&&t.target!==this.#Cr?(this.#Br||this.#Fr(t),t.target.previousSibling?.focus()):this.#Br&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Br?this.#kr.firstChild?.focus():this.#Fr(t)}_moveToEnd(t){this.#Br?this.#kr.lastChild?.focus():this.#Fr(t)}#qs(t){kn._keyboardManager.exec(this,t)}#Fr(t){if(this.#Br)return void this.hideDropdown();if(this.#Pr=0===t.detail,this.#Dr||(this.#Dr=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#Dr)})),this.#kr)return void this.#kr.classList.remove("hidden");const e=this.#kr=this.#Or();this.#Cr.append(e)}#h(t){this.#kr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#kr?.classList.add("hidden"),this.#Dr?.abort(),this.#Dr=null}get#Br(){return this.#kr&&!this.#kr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Mr||(this.#Br?(this.hideDropdown(),this.#Cr.focus({preventScroll:!0,focusVisible:this.#Pr})):this.#r?.unselect())}updateColor(t){if(this.#Er&&(this.#Er.style.backgroundColor=t),!this.#kr)return;const e=this.#f.highlightColors.values();for(const i of this.#kr.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Cr?.remove(),this.#Cr=null,this.#Er=null,this.#kr?.remove(),this.#kr=null}}class Pn extends Le{#zr=null;#Hr=0;#jr;#Ur=null;#n=null;#Vr=null;#$r=null;#Gr=0;#Wr=null;#qr=null;#y=null;#Xr=!1;#mr=null;#Yr;#Kr=null;#Qr="";#er;#Jr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=X.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Pn.prototype;return Bt(this,"_keyboardManager",new Pe([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||Pn._defaultColor,this.#er=t.thickness||Pn._defaultThickness,this.#Yr=t.opacity||Pn._defaultOpacity,this.#jr=t.boxes||null,this.#Jr=t.methodOfCreation||"",this.#Qr=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xr=!0,this.#Zr(t),this.#ta()):this.#jr&&(this.#zr=t.anchorNode,this.#Hr=t.anchorOffset,this.#$r=t.focusNode,this.#Gr=t.focusOffset,this.#ea(),this.#ta(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xr?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#er,methodOfCreation:this.#Jr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ea(){const t=new Sn(this.#jr,.001);this.#qr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qr.box;const e=new Sn(this.#jr,.0025,.001,"ltr"===this._uiManager.direction);this.#Vr=e.getOutlines();const{lastPoint:i}=this.#Vr;this.#mr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Zr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qr=t;if(this.#Vr=t.getNewOutline(this.#er/2+1.5,.0025),e>=0)this.#y=e,this.#Ur=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Kr=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Vr.box,path:{d:this.#Vr.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:Pn.#ia(this.#qr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Kr,{bbox:Pn.#ia(this.#Vr.box,e),path:{d:this.#Vr.toSVGPath()}})}const[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e;break}}const{lastPoint:o}=this.#Vr;this.#mr=[(o[0]-s)/r,(o[1]-n)/a]}static initialize(t,e){Le.initialize(t,e),Pn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Y.HIGHLIGHT_DEFAULT_COLOR:Pn._defaultColor=e;break;case Y.HIGHLIGHT_THICKNESS:Pn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#mr}updateParams(t,e){switch(t){case Y.HIGHLIGHT_COLOR:this.#On(e);break;case Y.HIGHLIGHT_THICKNESS:this.#sa(e)}}static get defaultPropertiesToUpdate(){return[[Y.HIGHLIGHT_DEFAULT_COLOR,Pn._defaultColor],[Y.HIGHLIGHT_THICKNESS,Pn._defaultThickness]]}get propertiesToUpdate(){return[[Y.HIGHLIGHT_COLOR,this.color||Pn._defaultColor],[Y.HIGHLIGHT_THICKNESS,this.#er||Pn._defaultThickness],[Y.HIGHLIGHT_FREE,this.#Xr]]}#On(t){const e=(t,e)=>{this.color=t,this.#Yr=e,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Yr;this.addCommands({cmd:e.bind(this,t,Pn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#sa(t){const e=this.#er,i=t=>{this.#er=t,this.#na(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Y.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new kn({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#ra())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ra())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#aa(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aa():t&&(this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#na(t){if(!this.#Xr)return;this.#Zr({highlightOutlines:this.#qr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#aa(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Kr),this.#Kr=null)}#ta(t=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#Ur}=t.drawLayer.draw({bbox:this.#qr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Yr},rootClass:{highlight:!0,free:this.#Xr},path:{d:this.#qr.toSVGPath()}},!1,!0)),this.#Kr=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xr},bbox:this.#Vr.box,path:{d:this.#Vr.toSVGPath()}},this.#Xr),this.#Wr&&(this.#Wr.style.clipPath=this.#Ur))}static#ia([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#Xr?(t=(t-this.rotation+360)%360,i=Pn.#ia(this.#qr.box,t)):i=Pn.#ia([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#y,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Kr,{bbox:Pn.#ia(this.#Vr.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Qr&&(t.setAttribute("aria-label",this.#Qr),t.setAttribute("role","mark")),this.#Xr?t.classList.add("free"):this.div.addEventListener("keydown",this.#oa.bind(this),{signal:this._uiManager._signal});const e=this.#Wr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Ur;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Ce(this,this.#Wr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Kr,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Kr,{rootClass:{hovered:!1}})}#oa(t){Pn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#la(!0);break;case 1:case 3:this.#la(!1)}}#la(t){if(!this.#zr)return;const e=window.getSelection();t?e.setPosition(this.#zr,this.#Hr):e.setPosition(this.#$r,this.#Gr)}select(){super.select(),this.#Kr&&this.parent?.drawLayer.updateProperties(this.#Kr,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Kr&&(this.parent?.drawLayer.updateProperties(this.#Kr,{rootClass:{selected:!1}}),this.#Xr||this.#la(!1))}get _mustFixPosition(){return!this.#Xr}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Kr,{rootClass:{hidden:!t}}))}#ra(){return this.#Xr?this.rotation:0}#ha(){if(this.#Xr)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#jr,r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+i,d=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=d,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=d-c*e,a+=8}return r}#ca(t){return this.#qr.serialize(t,this.#ra())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),this.#da(t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",fe,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",ge,{signal:c}),i.addEventListener("pointermove",this.#ua.bind(this,t),{signal:c}),this._freeHighlight=new En({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#ua(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#da(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof un){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:X.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}else if(t instanceof dn){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:X.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}const{color:n,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=Jt.makeHexColor(...n),l.#Yr=o||1,a&&(l.#er=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,c]=l.pageDimensions,[d,u]=l.pageTranslation;if(r){const t=l.#jr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-d)/h,y:1-(r[e+1]-u)/c,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/c});l.#ea(),l.#ta(),l.rotate(l.rotation)}else if(a){l.#Xr=!0;const t=a[0],i={x:t[0]-d,y:c-(t[1]-u)},s=new En(i,[0,0,h,c],1,l.#er/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-d,i.y=c-(t[e+1]-u),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#Zr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#ta()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=Le._colorManager.convert(this.color),s={annotationType:X.HIGHLIGHT,color:i,opacity:this.#Yr,thickness:this.#er,quadPoints:this.#ha(),outlines:this.#ca(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ra(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Vn(s)?null:(s.id=this.annotationElementId,s)}#Vn(t){const{color:e}=this._initialData;return t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Mn{#pa=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#pa[t]=e}toSVGProperties(){const t=this.#pa;return this.#pa=Object.create(null),{root:t}}reset(){this.#pa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){Ft("Not implemented")}}class In extends Le{#ga=null;#fa;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ma=null;static#ba=null;static#va=null;static#ya=NaN;static#wa=null;static#xa=null;static#Aa=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fa=t.mustBeCommitted||!1,t.drawOutlines&&(this.#_a(t),this.#ta())}#_a({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ga=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sa(t,this.parent),this.#Ca(t.box)}#Sa(t,e){const{id:i}=e.drawLayer.draw(In._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){Ft("Not implemented")}static get typesMap(){Ft("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(In.#ma.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#ga.updateProperty(e,t);i&&this.#Ca(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,In._mergeSVGProperties(this.#ga.getPathResizingSVGProperties(this.#Ea()),{bbox:this.#Ta()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,In._mergeSVGProperties(this.#ga.getPathResizedSVGProperties(this.#Ea()),{bbox:this.#Ta()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Ta(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,In._mergeSVGProperties(this.#ga.getPathTranslatedSVGProperties(this.#Ea(),this.parentDimensions),{bbox:this.#Ta()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#fa&&(this.#fa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#aa(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.#Ca(this.#ga.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#aa()):t&&(this._uiManager.addShouldRescale(this),this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#aa(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ta(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sa(this.#ga,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#ka([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#Ea(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#Ca(t){if([this.x,this.y,this.width,this.height]=this.#ka(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Ta(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,In._mergeSVGProperties({bbox:this.#Ta()},this.#ga.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Ca(this.#ga.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){Ft("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(In.#wa&&In.#wa!==l)return;const{viewport:{rotation:h}}=t,{width:c,height:d}=n.getBoundingClientRect(),u=In.#ba=new AbortController,p=t.combinedSignal(u);In.#ya||=o,In.#wa??=l,window.addEventListener("pointerup",t=>{In.#ya===t.pointerId?this._endDraw(t):In.#xa?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointercancel",t=>{In.#ya===t.pointerId?this._currentParent.endDrawingSession():In.#xa?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointerdown",t=>{In.#wa===t.pointerType&&((In.#xa||=new Set).add(t.pointerId),In.#ma.isCancellable()&&(In.#ma.removeLastElement(),In.#ma.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",ge,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",t=>{t.timeStamp===In.#Aa&&fe(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),In.#ma?t.drawLayer.updateProperties(this._currentDrawId,In.#ma.startNew(r,a,c,d,h)):(e.updateUIForDefaultProperties(this),In.#ma=this.createDrawerInstance(r,a,c,d,h),In.#va=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(In.#va.toSVGProperties(),In.#ma.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(In.#Aa=-1,!In.#ma)return;const{offsetX:e,offsetY:i,pointerId:s}=t;In.#ya===s&&(In.#xa?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,In.#ma.add(e,i)),In.#Aa=t.timeStamp,fe(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,In.#ma=null,In.#va=null,In.#wa=null,In.#Aa=NaN),In.#ba&&(In.#ba.abort(),In.#ba=null,In.#ya=NaN,In.#xa=null)}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,In.#ma.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=In.#ma,i=this._currentDrawId,s=t.getLastElement();return void e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:Y.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Y.DRAW_STEP),!In.#ma.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:In.#ma.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:In.#va,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){Ft("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#_a({drawOutlines:o}),l.#ta(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ga.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Dn{#Yn=new Float64Array(6);#bn;#Pa;#Li;#er;#ir;#Ma="";#Ia=0;#Sr=new Rn;#Da;#Ra;constructor(t,e,i,s,n,r){this.#Da=i,this.#Ra=s,this.#Li=n,this.#er=r,[t,e]=this.#La(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e],this.#Pa=[{line:a,points:this.#ir}],this.#Yn.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#er=e)}#La(t,e){return xn._normalizePoint(t,e,this.#Da,this.#Ra,this.#Li)}isEmpty(){return!this.#Pa||0===this.#Pa.length}isCancellable(){return this.#ir.length<=10}add(t,e){[t,e]=this.#La(t,e);const[i,s,n,r]=this.#Yn.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#Da*a,this.#Ra*o)<=2?null:(this.#ir.push(t,e),isNaN(i)?(this.#Yn.set([n,r,t,e],2),this.#bn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Yn[0])&&this.#bn.splice(6,6),this.#Yn.set([i,s,n,r,t,e],0),this.#bn.push(...xn.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ir.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Da=i,this.#Ra=s,this.#Li=n,[t,e]=this.#La(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e];const a=this.#Pa.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#Pa.push({line:r,points:this.#ir}),this.#Yn.set(r,0),this.#Ia=0,this.toSVGPath(),null}getLastElement(){return this.#Pa.at(-1)}setLastElement(t){return this.#Pa?(this.#Pa.push(t),this.#bn=t.line,this.#ir=t.points,this.#Ia=0,{path:{d:this.toSVGPath()}}):this.#Sr.setLastElement(t)}removeLastElement(){if(!this.#Pa)return this.#Sr.removeLastElement();this.#Pa.pop(),this.#Ma="";for(let t=0,e=this.#Pa.length;t<e;t++){const{line:e,points:i}=this.#Pa[t];this.#bn=e,this.#ir=i,this.#Ia=0,this.toSVGPath()}return{path:{d:this.#Ma}}}toSVGPath(){const t=xn.svgRound(this.#bn[4]),e=xn.svgRound(this.#bn[5]);if(2===this.#ir.length)return this.#Ma=`${this.#Ma} M ${t} ${e} Z`,this.#Ma;if(this.#ir.length<=6){const i=this.#Ma.lastIndexOf("M");this.#Ma=`${this.#Ma.slice(0,i)} M ${t} ${e}`,this.#Ia=6}if(4===this.#ir.length){const t=xn.svgRound(this.#bn[10]),e=xn.svgRound(this.#bn[11]);return this.#Ma=`${this.#Ma} L ${t} ${e}`,this.#Ia=12,this.#Ma}const i=[];0===this.#Ia&&(i.push(`M ${t} ${e}`),this.#Ia=6);for(let t=this.#Ia,e=this.#bn.length;t<e;t+=6){const[e,s,n,r,a,o]=this.#bn.slice(t,t+6).map(xn.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#Ma+=i.join(" "),this.#Ia=this.#bn.length,this.#Ma}getOutlines(t,e,i,s){const n=this.#Pa.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sr.build(this.#Pa,t,e,i,this.#Li,this.#er,s),this.#Yn=null,this.#bn=null,this.#Pa=null,this.#Ma=null,this.#Sr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Rn extends xn{#pr;#Fa=0;#Wn;#Pa;#Da;#Ra;#Oa;#Li;#er;build(t,e,i,s,n,r,a){this.#Da=e,this.#Ra=i,this.#Oa=s,this.#Li=n,this.#er=r,this.#Wn=a??0,this.#Pa=t,this.#Na()}setLastElement(t){return this.#Pa.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Pa.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Pa)if(t.push(`M${xn.svgRound(e[4])} ${xn.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(xn.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push(`L${xn.svgRound(e[10])} ${xn.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,c]=this.#Ba();let d,u,p,g,f,m,b,v,y;switch(this.#Li){case 0:y=xn._rescale,d=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-c)*s,b=t+(o+h)*i,v=e+(1-l)*s;break;case 90:y=xn._rescaleAndSwap,d=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,b=t+(l+c)*i,v=e+(o+h)*s;break;case 180:y=xn._rescale,d=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,b=t+(1-o)*i,v=e+(l+c)*s;break;case 270:y=xn._rescaleAndSwap,d=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-c)*i,m=e+(1-o-h)*s,b=t+(1-l)*i,v=e+(1-o)*s}for(const{line:t,points:e}of this.#Pa)r.push(y(t,d,u,p,g,n?new Array(t.length):null)),a.push(y(e,d,u,p,g,n?new Array(e.length):null));return{lines:r,points:a,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=xn._rescale,c=-t/i,d=e/s+1,u=1/i,p=-1/s;break;case 90:g=xn._rescaleAndSwap,c=-e/s,d=-t/i,u=1/s,p=1/i;break;case 180:g=xn._rescale,c=t/i+1,d=-e/s,u=-1/i,p=1/s;break;case 270:g=xn._rescaleAndSwap,c=e/s+1,d=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(xn.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let t=0,e=r.length;t<e;t++)h.push({line:g(r[t].map(t=>t??NaN),c,d,u,p),points:g(a[t].map(t=>t??NaN),c,d,u,p)});const f=new Rn;return f.build(h,i,s,1,o,l,n),f}#za(t=this.#er){const e=this.#Wn+t/2*this.#Oa;return this.#Li%180==0?[e/this.#Da,e/this.#Ra]:[e/this.#Ra,e/this.#Da]}#Ba(){const[t,e,i,s]=this.#pr,[n,r]=this.#za(0);return[t+n,e+r,i-2*n,s-2*r]}#Na(){const t=this.#pr=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Pa){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){const[s,n]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],n)}continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,a,o,l,h,c]=e.subarray(n,n+6);Jt.bezierBoundingBox(i,s,r,a,o,l,h,c,t),i=h,s=c}}const[e,i]=this.#za();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#pr}updateProperty(t,e){return"stroke-width"===t?this.#sa(e):null}#sa(t){const[e,i]=this.#za();this.#er=t;const[s,n]=this.#za(),[r,a]=[s-e,n-i],o=this.#pr;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#za();this.#Da=t,this.#Ra=e,this.#Oa=i;const[r,a]=this.#za(),o=r-s,l=a-n,h=this.#pr;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Fa=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pr.map(xn.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pr;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${xn.svgRound(t)} ${xn.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pr;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#Fa){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${xn.svgRound(a)} ${xn.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#za(),[a,o,l,h]=this.#pr;if(Math.abs(l-n)<=xn.PRECISION||Math.abs(h-r)<=xn.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${xn.svgRound(t)} ${xn.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const c=(i-2*n)/(l-2*n),d=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${xn.svgRound(a)} ${xn.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${xn.svgRound(n)} ${xn.svgRound(r)}) scale(${c} ${d}) translate(${xn.svgRound(-n)} ${xn.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#za(),a=this.#pr,[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=xn.PRECISION||Math.abs(c-r)<=xn.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+c/2);for(const{line:t,points:e}of this.#Pa)xn._translate(t,n,r,t),xn._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${xn.svgRound(t)} ${xn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(i-2*n)/(h-2*n),u=(s-2*r)/(c-2*r),p=-d*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==d||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Pa)xn._rescale(t,p,g,d,u,t),xn._rescale(e,p,g,d,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${xn.svgRound(t)} ${xn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#pr,a=t-r[0],o=e-r[1];if(this.#Da===s&&this.#Ra===n)for(const{line:t,points:e}of this.#Pa)xn._translate(t,a,o,t),xn._translate(e,a,o,e);else{const t=this.#Da/s,e=this.#Ra/n;this.#Da=s,this.#Ra=n;for(const{line:i,points:s}of this.#Pa)xn._rescale(i,a,o,t,e,i),xn._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${xn.svgRound(t)} ${xn.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pr;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${xn.svgRound(t[0])} ${xn.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Ln extends Mn{#Ha;constructor(t){super(),this.#Ha=t,super.updateProperties({fill:"none",stroke:Le._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#Ha.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Ln(this.#Ha);return t.updateAll(this),t}}class Fn extends In{static _type="ink";static _editorType=X.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Le.initialize(t,e),this._defaultDrawingOptions=new Ln(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Bt(this,"typesMap",new Map([[Y.INK_THICKNESS,"stroke-width"],[Y.INK_COLOR,"stroke"],[Y.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Dn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Rn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof dn){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:X.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=Fn.getDefaultDrawingOptions({stroke:Jt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:X.INK,color:Le._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#Vn(o)?null:(o.id=this.annotationElementId,o)}#Vn(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class On extends Le{#ja=null;#Ua=null;#Va=null;#$a=null;#Ga=null;#Wa="";#qa=null;#Xa=null;#Ya=!1;#Ka=!1;static _type="stamp";static _editorType=X.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$a=t.bitmapUrl,this.#Ga=t.bitmapFile}static initialize(t,e){Le.initialize(t,e)}static get supportedTypes(){return Bt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return Bt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(X.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Qa(t,e=!1){t?(this.#ja=t.bitmap,e||(this.#Ua=t.id,this.#Ya=t.isSvg),t.file&&(this.#Wa=t.file.name),this.#Ja()):this.remove()}#Za(){if(this.#Va=null,this._uiManager.enableWaiting(!1),this.#qa){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ja)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ja){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;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#to(){if(this.#Ua)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Ua).then(t=>this.#Qa(t,!0)).finally(()=>this.#Za());if(this.#$a){const t=this.#$a;return this.#$a=null,this._uiManager.enableWaiting(!0),void(this.#Va=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#Qa(t)).finally(()=>this.#Za()))}if(this.#Ga){const t=this.#Ga;return this.#Ga=null,this._uiManager.enableWaiting(!0),void(this.#Va=this._uiManager.imageManager.getFromFile(t).then(t=>this.#Qa(t)).finally(()=>this.#Za()))}const t=document.createElement("input");t.type="file",t.accept=On.supportedTypesStr;const e=this._uiManager._signal;this.#Va=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qa(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#Za()),t.click()}remove(){this.#Ua&&(this.#ja=null,this._uiManager.imageManager.deleteId(this.#Ua),this.#qa?.remove(),this.#qa=null,this.#Xa&&(clearTimeout(this.#Xa),this.#Xa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Ua&&null===this.#qa&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#Ua&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Va||this.#ja||this.#$a||this.#Ga||this.#Ua)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#ja?this.#Ja():this.#to(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Xa&&clearTimeout(this.#Xa);this.#Xa=setTimeout(()=>{this.#Xa=null,this.#eo()},200)}#Ja(){const{div:t}=this;let{width:e,height:i}=this.#ja;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[a,o]=this.parentDimensions;this.setDims(e*a/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#qa=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#eo(),this.#Ka||(this.parent.addUndoableEditor(this),this.#Ka=!0),this._reportTelemetry({action:"inserted_image"}),this.#Wa&&l.setAttribute("aria-label",this.#Wa)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#ja,r=new Ae;let a=this.#ja,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#Ya||(a=this.#io(t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),b=m.getContext("2d");b.fillStyle=d,b.fillRect(0,0,2*g,2*f),b.fillStyle=u,b.fillRect(0,0,g,f),b.fillRect(g,f,g,f),c.fillStyle=c.createPattern(m,"repeat"),c.fillRect(0,0,t,i),c.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let c=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#ja,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Ya||(a=this.#io(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}#io(t,e){const{width:i,height:s}=this.#ja;let n=i,r=s,a=this.#ja;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Ae,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#qa;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#Ya?this.#ja:this.#io(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}getImageForAltText(){return this.#qa}#so(t){if(t){if(this.#Ya){const t=this._uiManager.imageManager.getSvgUrl(this.#Ua);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#ja);return t.getContext("2d").drawImage(this.#ja,0,0),t.toDataURL()}if(this.#Ya){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*ne.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*ne.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#ja,0,0,this.#ja.width,this.#ja.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#ja)}static async deserialize(t,e,i){let s=null;if(t instanceof mn){const{data:{rect:n,rotation:r,id:a,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:c}}}=t,d=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,d);d.remove();const p=(await e._structTree.getAriaAttributes(`${ie}${a}`))?.get("aria-label")||"";s=t={annotationType:X.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:c-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:c}=t;l&&i.imageManager.isValidId(l)?(n.#Ua=l,a&&(n.#ja=a)):n.#$a=o,n.#Ya=h;const[d,u]=n.pageDimensions;return n.width=(r[2]-r[0])/d,n.height=(r[3]-r[1])/u,n.annotationElementId=t.id||null,c&&(n.altTextData=c),n._initialData=s,n.#Ka=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:X.STAMP,bitmapId:this.#Ua,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ya,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#so(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Vn(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Ya?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#Ua)){if(this.#Ya){const t=e.stamps.get(this.#Ua);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#Ua,{area:r,serialized:i}),i.bitmap=this.#so(!1);return i}#Vn(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class Nn{#En;#no=!1;#ro=null;#ao=null;#oo=null;#lo=new Map;#ho=!1;#co=!1;#do=!1;#uo=null;#po=null;#go=null;#fo=null;#f;static _initialized=!1;static#j=new Map([wn,Fn,On,Pn].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const c=[...Nn.#j.values()];if(!Nn._initialized){Nn._initialized=!0;for(const e of c)e.initialize(h,t)}t.registerEditorTypes(c),this.#f=t,this.pageIndex=e,this.div=i,this.#En=n,this.#ro=r,this.viewport=l,this.#go=o,this.drawLayer=a,this._structTree=s,this.#f.addLayer(this)}get isEmpty(){return 0===this.#lo.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===X.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(t=this.#f.getMode()){switch(this.#mo(),t){case X.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case X.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case X.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const i of Nn.#j.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#go?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ro?.div.classList.toggle("disabled",!t)}async enable(){this.#do=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#lo.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ro)return void(this.#do=!1);const e=this.#ro.getEditableAnnotations();for(const i of e){if(i.hide(),this.#f.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#do=!1}disable(){this.#co=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#lo.values())i.disableEditing(),i.annotationElementId&&(null===i.serialize()?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#ro){const i=this.#ro.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#f.isDeletedAnnotationElement(i))continue;let n=e.get(i);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=t.get(i),n&&(this.#f.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#mo(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of Nn.#j.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#co=!1}getEditableAnnotation(t){return this.#ro?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#go?.div&&!this.#fo){this.#fo=new AbortController;const t=this.#f.combinedSignal(this.#fo);this.#go.div.addEventListener("pointerdown",this.#bo.bind(this),{signal:t}),this.#go.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#go?.div&&this.#fo&&(this.#fo.abort(),this.#fo=null,this.#go.div.classList.remove("highlighting"))}#bo(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#go.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#go.div.contains(e)){const{isMac:e}=Kt.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),Pn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#go.div,x:t.x,y:t.y}),this.#go.div.addEventListener("pointerup",()=>{this.#go.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ao)return;this.#ao=new AbortController;const t=this.#f.combinedSignal(this.#ao);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ao?.abort(),this.#ao=null}attach(t){this.#lo.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#lo.delete(t.id),this.#En?.removePointerInTextLayer(t.contentDiv),!this.#co&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),Le.deleteAnnotationElement(t),t.annotationElementId=null),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){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#do),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#oo&&(t._focusEventsAllowed=!1,this.#oo=setTimeout(()=>{this.#oo=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#f._signal}),e.focus())},0)),t._structTreeParentId=this.#En?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get#vo(){return Nn.#j.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#yo(t){const e=this.#vo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#vo?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#wo(),n=this.getNextId(),r=this.#yo({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await(Nn.#j.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#f))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#yo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#wo(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#wo(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){const{isMac:e}=Kt.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#ho&&(this.#ho=!1,this.#vo?.isDrawer&&this.#vo.supportMultipleDrawings||(this.#no?this.#f.getMode()!==X.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===X.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=Kt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#ho=!0,this.#vo?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#no=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#uo)return void this.#vo.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#uo=new AbortController;const e=this.#f.combinedSignal(this.#uo);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#po=null,this.commitOrRemove())},{signal:e}),this.#vo.startDrawing(this,this.#f,!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&(this.#po=t))}this.#po&&setTimeout(()=>{this.#po?.focus(),this.#po=null},0)}endDrawingSession(t=!1){return this.#uo?(this.#f.setCurrentDrawingSession(null),this.#uo.abort(),this.#uo=null,this.#po=null,this.#vo.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#uo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#uo&&this.#vo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#oo&&(clearTimeout(this.#oo),this.#oo=null);for(const t of this.#lo.values())this.#En?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lo.clear(),this.#f.removeLayer(this)}#mo(){for(const t of this.#lo.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,xe(this.div,t);for(const t of this.#f.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#mo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,xe(this.div,{rotation:i}),e!==i)for(const t of this.#lo.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}}class Bn{#nn=null;#y=0;#xo=new Map;#Ao=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#nn){if(this.#nn!==t){if(this.#xo.size>0)for(const e of this.#xo.values())e.remove(),t.append(e);this.#nn=t}}else this.#nn=t}static get _svgFactory(){return Bt(this,"_svgFactory",new zs)}static#_o(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#So(){const t=Bn._svgFactory.create(1,1,!0);return this.#nn.append(t),t.setAttribute("aria-hidden",!0),t}#Co(t,e){const i=Bn._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=Bn._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#Eo(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=this.#y++,n=this.#So(),r=Bn._svgFactory.createElement("defs");n.append(r);const a=Bn._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#Ao.set(s,a);const l=i?this.#Co(r,o):null,h=Bn._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#xo.set(s,n),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){const i=this.#y++,s=this.#So(),n=Bn._svgFactory.createElement("defs");s.append(n);const r=Bn._svgFactory.createElement("path");n.append(r);const a=`path_p${this.pageIndex}_${i}`;let o;if(r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke"),e){const t=Bn._svgFactory.createElement("mask");n.append(t),o=`mask_p${this.pageIndex}_${i}`,t.setAttribute("id",o),t.setAttribute("maskUnits","objectBoundingBox");const e=Bn._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=Bn._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${a}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const l=Bn._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return s.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#xo.set(i,s),i}finalizeDraw(t,e){this.#Ao.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:r}=e,a="number"==typeof t?this.#xo.get(t):t;if(a){if(i&&this.#Eo(a,i),s&&Bn.#_o(a,s),n){const{classList:t}=a;for(const[e,i]of Object.entries(n))t.toggle(e,i)}if(r){const t=a.firstChild.firstChild;this.#Eo(t,r)}}}updateParent(t,e){if(e===this)return;const i=this.#xo.get(t);i&&(e.#nn.append(i),this.#xo.delete(t),e.#xo.set(t,i))}remove(t){this.#Ao.delete(t),null!==this.#nn&&(this.#xo.get(t).remove(),this.#xo.delete(t))}destroy(){this.#nn=null;for(const t of this.#xo.values())t.remove();this.#xo.clear(),this.#Ao.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:Sn};var zn,Hn=L.AbortException,jn=L.AnnotationEditorLayer,Un=L.AnnotationEditorParamsType,Vn=L.AnnotationEditorType,$n=L.AnnotationEditorUIManager,Gn=L.AnnotationLayer,Wn=L.AnnotationMode,qn=L.ColorPicker,Xn=L.DOMSVGFactory,Yn=L.DrawLayer,Kn=L.FeatureTest,Qn=L.GlobalWorkerOptions,Jn=L.ImageKind,Zn=L.InvalidPDFException,tr=L.MissingPDFException,er=L.OPS,ir=L.OutputScale,sr=L.PDFDataRangeTransport,nr=L.PDFDateString,rr=L.PDFWorker,ar=L.PasswordResponses,or=L.PermissionFlag,lr=L.PixelsPerInch,hr=L.RenderingCancelledException,cr=L.TextLayer,dr=L.TouchManager,ur=L.UnexpectedResponseException,pr=L.Util,gr=L.VerbosityLevel,fr=L.XfaLayer,mr=L.build,br=L.createValidAbsoluteUrl,vr=L.fetchData,yr=L.getDocument,wr=L.getFilenameFromUrl,xr=L.getPdfFilenameFromUrl,Ar=L.getXfaPageViewport,_r=L.isDataScheme,Sr=L.isPdfFile,Cr=L.noContextMenu,Er=L.normalizeUnicode,Tr=L.setLayerDimensions,kr=L.shadow,Pr=L.stopEvent,Mr=L.version,Ir=Object.freeze({__proto__:null,AbortException:Hn,AnnotationEditorLayer:jn,AnnotationEditorParamsType:Un,AnnotationEditorType:Vn,AnnotationEditorUIManager:$n,AnnotationLayer:Gn,AnnotationMode:Wn,ColorPicker:qn,DOMSVGFactory:Xn,DrawLayer:Yn,FeatureTest:Kn,GlobalWorkerOptions:Qn,ImageKind:Jn,InvalidPDFException:Zn,MissingPDFException:tr,OPS:er,OutputScale:ir,PDFDataRangeTransport:sr,PDFDateString:nr,PDFWorker:rr,PasswordResponses:ar,PermissionFlag:or,PixelsPerInch:lr,RenderingCancelledException:hr,TextLayer:cr,TouchManager:dr,UnexpectedResponseException:ur,Util:pr,VerbosityLevel:gr,XfaLayer:fr,build:mr,createValidAbsoluteUrl:br,fetchData:vr,getDocument:yr,getFilenameFromUrl:wr,getPdfFilenameFromUrl:xr,getXfaPageViewport:Ar,isDataScheme:_r,isPdfFile:Sr,noContextMenu:Cr,normalizeUnicode:Er,setLayerDimensions:Tr,shadow:kr,stopEvent:Pr,version:Mr}),Dr={wrapper:{display:"flex",flexDirection:"column",height:"100%",background:"#525659",fontFamily:"sans-serif",fontSize:"12px"},toolbar:{display:"flex",alignItems:"center",padding:"4px 6px",background:"#474747",borderBottom:"1px solid #525659",gap:"4px"},toolbarGroup:{display:"flex",alignItems:"center",gap:"2px"},toolbarSeparator:{width:"1px",height:"24px",background:"#525659",margin:"0 4px"},button:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",padding:"0",background:"transparent",border:"none",borderRadius:"2px",cursor:"pointer",color:"#f0f0f0",fontSize:"14px",transition:"background 0.15s"},buttonHover:{background:"#5a5a5a"},buttonActive:{background:"#6a6a6a"},buttonDisabled:{opacity:"0.5",cursor:"not-allowed"},buttonImg:{width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center"},input:{width:"50px",padding:"4px 6px",background:"#3a3a3a",border:"1px solid #525659",borderRadius:"2px",color:"#f0f0f0",fontSize:"12px",textAlign:"center"},inputFocus:{outline:"none",borderColor:"#00a1de"},label:{color:"#f0f0f0",margin:"0 4px"},select:{padding:"4px 8px",background:"#3a3a3a",border:"1px solid #525659",borderRadius:"2px",color:"#f0f0f0",fontSize:"12px",cursor:"pointer"},selectFocus:{outline:"none",borderColor:"#00a1de"},main:{display:"flex",flex:"1",overflow:"hidden",position:"relative"},sidebar:{width:"200px",background:"#3a3a3a",borderRight:"1px solid #525659",display:"flex",flexDirection:"column",transition:"width 0.2s ease",position:"absolute",top:"0",left:"0",bottom:"0",zIndex:"10"},sidebarHidden:{width:"0",display:"none",borderRight:"none"},sidebarHeader:{display:"flex",padding:"8px",background:"#474747",borderBottom:"1px solid #525659"},sidebarTab:{flex:"1",padding:"6px 12px",background:"transparent",border:"none",borderRadius:"2px",color:"#f0f0f0",fontSize:"11px",cursor:"pointer",textAlign:"center"},sidebarTabHover:{background:"#5a5a5a"},sidebarTabActive:{background:"#6a6a6a"},sidebarContent:{flex:"1",overflowY:"auto",padding:"8px"},thumbnail:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"12px",padding:"8px",background:"#474747",borderRadius:"4px",cursor:"pointer",transition:"background 0.15s"},thumbnailHover:{background:"#5a5a5a"},thumbnailActive:{background:"#00a1de"},thumbnailCanvas:{maxWidth:"100%",maxHeight:"150px",border:"1px solid #525659"},thumbnailPage:{color:"#f0f0f0",fontSize:"11px",marginTop:"4px"},content:{flex:"1",display:"flex",flexDirection:"column",overflow:"auto",transition:"marginLeft 0.2s ease"},contentNoSidebar:{marginLeft:"0"},findbar:{display:"flex",alignItems:"center",padding:"4px 8px",background:"#474747",borderBottom:"1px solid #525659",gap:"8px",position:"absolute",right:0,zIndex:"1"},findbarHidden:{display:"none"},findInput:{flex:"1",maxWidth:"300px",padding:"4px 8px",background:"#3a3a3a",border:"1px solid #525659",borderRadius:"2px",color:"#f0f0f0",fontSize:"12px"},findInputFocus:{outline:"none",borderColor:"#00a1de"},findResults:{color:"#f0f0f0",fontSize:"11px",minWidth:"60px",textAlign:"right"},canvasContainer:{display:"flex",flexDirection:"column",background:"#525659"},canvas:{background:"white"},outlineItem:{display:"flex",alignItems:"center",padding:"4px 8px",color:"#f0f0f0",cursor:"pointer",borderRadius:"2px",fontSize:"11px"},outlineItemHover:{background:"#5a5a5a"},outlineItemActive:{background:"#00a1de"},outlineIcon:{width:"16px",height:"16px",marginRight:"4px",display:"inline-flex",alignItems:"center"},outlineChildren:{paddingLeft:"16px"}};function Rr(t,e){var i;return function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];clearTimeout(i),i=setTimeout(function(){return t.apply(void 0,n)},e)}}function Lr(t,e){Object.assign(t.style,e)}function Fr(t,e){var i={};t.addEventListener("mouseenter",function(){if("true"!==t.dataset.active){var s=window.getComputedStyle(t);Object.keys(e).forEach(function(t){i[t]=s.getPropertyValue(t)}),Object.assign(t.style,e)}}),t.addEventListener("mouseleave",function(){"true"!==t.dataset.active&&(Object.keys(i).forEach(function(e){t.style.setProperty(e,i[e])}),i={})})}function Or(t){return Nr.apply(this,arguments)}function Nr(){return(Nr=i(M.mark(function t(e){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e instanceof ArrayBuffer)){t.next=1;break}return t.abrupt("return",new Uint8Array(e));case 1:if(!(e instanceof Uint8Array)){t.next=2;break}return t.abrupt("return",e);case 2:return t.abrupt("return",new Promise(function(t,i){var s=new FileReader;s.onload=function(){t(new Uint8Array(s.result))},s.onerror=i,s.readAsArrayBuffer(e)}));case 3:case"end":return t.stop()}},t)}))).apply(this,arguments)}function Br(t){for(var e=atob(t),i=new Uint8Array(e.length),s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return i}function zr(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return Hr(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Hr(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var s=0,n=function(){};return{s:n,n:function(){return s>=t.length?{done:!0}:{done:!1,value:t[s++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,a=!0,o=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return a=t.done,t},e:function(t){o=!0,r=t},f:function(){try{a||null==i.return||i.return()}finally{if(o)throw r}}}}function Hr(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,s=Array(e);i<e;i++)s[i]=t[i];return s}function jr(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,s)}return i}null!==(zn=Qn)&&void 0!==zn&&zn.workerSrc||(Qn.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.10.38/pdf.worker.min.mjs");var Ur=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),a(this,"instanceId",void 0),a(this,"pdfDoc",null),a(this,"container",void 0),a(this,"options",void 0),a(this,"currentPage",1),a(this,"currentScale","auto"),a(this,"pdfjsLib",void 0),a(this,"canvas",void 0),a(this,"ctx",void 0),a(this,"thumbnails",new Map),a(this,"sidebarContentCreated",!1),a(this,"outline",[]),a(this,"findController",null),a(this,"textLayer",null),a(this,"pageCanvases",new Map),a(this,"pagePlaceholders",new Map),a(this,"renderedPages",new Set),a(this,"pagesContainer",null),a(this,"content",null),a(this,"pageHeights",new Map),a(this,"scrollHandler",null),a(this,"isNavigating",!1),a(this,"isRendering",!1),a(this,"renderQueue",[]),a(this,"maxConcurrentRenders",2),a(this,"loadingTask",null),a(this,"sidebarScrollHandler",null),this.instanceId="pdf-preview-".concat(++t.instanceCounter),this.options=function(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?jr(Object(i),!0).forEach(function(e){a(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):jr(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}({scale:"auto",page:1,rotation:0,cMapPacked:!0,showToolbar:!1,showSidebar:!1,textLayer:!1},e),this.container=this.getContainer(this.options.container);var i=this.container.__pdfPreviewInstance;i&&i!==this&&i.destroy(),this.container.__pdfPreviewInstance=this,this.currentScale=this.options.scale||"auto",this.currentPage=this.options.page||1,this.canvas=document.createElement("canvas"),Lr(this.canvas,Dr.canvas),this.ctx=this.canvas.getContext("2d"),this.createUI(),this.initPdfJs()},e=[{key:"getContainer",value:function(t){if("string"==typeof t){var e=t.replace(new RegExp("#","g"),""),i=document.getElementById(e);if(!i)throw new Error("Container element not found: ".concat(t));return i}return console.log(11234,t),t}},{key:"createUI",value:function(){if(this.container.innerHTML="",Lr(this.container,Dr.wrapper),this.options.showToolbar){var t=this.createToolbar();this.container.appendChild(t)}var e=document.createElement("div");if(Lr(e,Dr.main),this.options.showToolbar){var i=this.createSidebar();e.appendChild(i)}var s=this.createContent();e.appendChild(s),this.container.appendChild(e)}},{key:"createToolbar",value:function(){var t=this,e=document.createElement("div");Lr(e,Dr.toolbar);var i=document.createElement("div");Lr(i,Dr.toolbarGroup);var s=this.createButton("sidebar-toggle","Toggle Sidebar",function(){t.toggleSidebar()});i.appendChild(s);var n=document.createElement("div");Lr(n,Dr.toolbarSeparator),i.appendChild(n);var r=this.createButton("prev-page","Previous Page",function(){t.prevPage()});i.appendChild(r);var a=document.createElement("input");Lr(a,Dr.input),a.min="1",a.value="1",a.id="".concat(this.instanceId,"-page-input"),a.addEventListener("focus",function(){Object.assign(a.style,Dr.inputFocus)}),a.addEventListener("blur",function(){Object.keys(Dr.inputFocus).forEach(function(t){a.style.removeProperty(t)})}),a.addEventListener("change",function(e){var i=parseInt(e.target.value);t.goToPage(i)}),i.appendChild(a);var o=document.createElement("span");Lr(o,Dr.label),o.id="".concat(this.instanceId,"-page-label"),o.textContent="/ 1",i.appendChild(o);var l=this.createButton("next-page","Next Page",function(){t.nextPage()});i.appendChild(l);var h=document.createElement("div");Lr(h,Dr.toolbarSeparator),i.appendChild(h);var c=this.createButton("zoom-out","Zoom Out",function(){t.zoomOut()});i.appendChild(c);var d=document.createElement("select");Lr(d,Dr.select),d.innerHTML='\n <option value="auto">Auto</option>\n <option value="0.5">50%</option>\n <option value="0.75">75%</option>\n <option value="1">100%</option>\n <option value="1.25">125%</option>\n <option value="1.5">150%</option>\n <option value="2">200%</option>\n <option value="3">300%</option>\n <option value="4">400%</option>\n ',d.value=this.currentScale,d.addEventListener("focus",function(){Object.assign(d.style,Dr.selectFocus)}),d.addEventListener("blur",function(){Object.keys(Dr.selectFocus).forEach(function(t){d.style.removeProperty(t)})}),d.addEventListener("change",function(e){var i=e.target.value,s="auto"===i?"auto":parseFloat(i);t.setScale(s)}),i.appendChild(d);var u=this.createButton("zoom-in","Zoom In",function(){t.zoomIn()});i.appendChild(u);var p=document.createElement("div");Lr(p,Dr.toolbarSeparator),i.appendChild(p);var g=this.createButton("rotate-cw","Rotate Clockwise",function(){t.setRotation((t.options.rotation+90)%360)});i.appendChild(g);var f=this.createButton("rotate-ccw","Rotate Counterclockwise",function(){t.setRotation((t.options.rotation-90+360)%360)});i.appendChild(f);var m=document.createElement("div");Lr(m,Dr.toolbarSeparator),i.appendChild(m);var b=this.createButton("find","Find in Document",function(){t.toggleFindbar()});return i.appendChild(b),e.appendChild(i),e}},{key:"createButton",value:function(t,e,i){var s=document.createElement("button");return Lr(s,Dr.button),s.title=e,s.innerHTML={"sidebar-toggle":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>',"prev-page":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>',"next-page":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',"zoom-out":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M19 13H5v-2h14v2z"/></svg>',"zoom-in":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',"rotate-cw":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></svg>',"rotate-ccw":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M12 5V1l-5 5 5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" transform="scale(-1,1) translate(-24,0)"/></svg>',find:'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>',"find-prev":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>',"find-next":'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>',close:'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="display:block"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>'}[t]||"",s.addEventListener("click",i),Fr(s,Dr.buttonHover),s}},{key:"createSidebar",value:function(){var t=document.createElement("div");this.options.showSidebar?Lr(t,Dr.sidebar):Lr(t,Dr.sidebarHidden);var e=document.createElement("div");return Lr(e,Dr.sidebarContent),e.id="".concat(this.instanceId,"-sidebar-content"),t.appendChild(e),t}},{key:"createContent",value:function(){var t=document.createElement("div");Lr(t,Dr.content);var e=this.createFindbar();return t.appendChild(e),this.pagesContainer=document.createElement("div"),Lr(this.pagesContainer,Dr.canvasContainer),this.pagesContainer.id="".concat(this.instanceId,"-canvas-container"),t.appendChild(this.pagesContainer),this.content=t,t}},{key:"createFindbar",value:function(){var t=this,e=document.createElement("div");Lr(e,Dr.findbar),Lr(e,Dr.findbarHidden),e.id="".concat(this.instanceId,"-findbar");var i=document.createElement("input");i.type="text",Lr(i,Dr.findInput),i.placeholder="Find in document...",i.addEventListener("focus",function(){Object.assign(i.style,Dr.findInputFocus)}),i.addEventListener("blur",function(){Object.keys(Dr.findInputFocus).forEach(function(t){i.style.removeProperty(t)})}),i.addEventListener("input",function(e){t.findText(e.target.value)}),e.appendChild(i);var s=this.createButton("find-prev","Previous",function(){t.findPrevious()});e.appendChild(s);var n=this.createButton("find-next","Next",function(){t.findNext()});e.appendChild(n);var r=document.createElement("span");Lr(r,Dr.findResults),r.textContent="0/0",r.id="".concat(this.instanceId,"-find-results"),e.appendChild(r);var a=this.createButton("close","Close",function(){t.toggleFindbar()});return e.appendChild(a),e}},{key:"toggleSidebar",value:function(){var t=Array.from(this.container.children)[1];if(t){var e=t.firstChild,i=t.children[1];e&&i&&("0px"===e.style.width?(Object.assign(e.style,Dr.sidebar),this.renderThumbnails()):Object.assign(e.style,Dr.sidebarHidden))}}},{key:"toggleFindbar",value:function(){var t=this.container.querySelector("#".concat(this.instanceId,"-findbar"));if(t){var e="none"===t.style.display;e?Object.assign(t.style,Dr.findbar):Object.assign(t.style,Dr.findbarHidden),e||t.querySelector("input").focus()}}},{key:"switchSidebarTab",value:function(t){var e=this.container.querySelectorAll("button");if(e.forEach(function(t){var e=t;"Thumbnails"!==e.textContent&&"Outline"!==e.textContent||Object.keys(Dr.sidebarTabActive).forEach(function(t){e.style.removeProperty(t)})}),this.container.querySelector("#".concat(this.instanceId,"-sidebar-content")).innerHTML="","thumbnails"===t){var i=e[0];"Thumbnails"===i.textContent&&Object.assign(i.style,Dr.sidebarTabActive),this.renderThumbnails()}else if("outline"===t){var s=e[1];"Outline"===s.textContent&&Object.assign(s.style,Dr.sidebarTabActive),this.renderOutline()}}},{key:"renderThumbnails",value:(I=i(M.mark(function t(){var e,i,s,n=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.container.querySelector("#".concat(this.instanceId,"-sidebar-content")),this.pdfDoc){t.next=1;break}return t.abrupt("return");case 1:if(this.sidebarContentCreated){t.next=6;break}e.innerHTML="",i=M.mark(function t(i){var s,r,a;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:Lr(s=document.createElement("div"),Dr.thumbnail),i===n.currentPage?(Object.assign(s.style,Dr.thumbnailActive),s.dataset.active="true"):s.dataset.active="false",s.addEventListener("click",function(){n.goToPage(i)}),Fr(s,Dr.thumbnailHover),s.dataset.page=i.toString(),(r=document.createElement("div")).style.display="flex",r.style.alignItems="center",r.style.justifyContent="center",r.style.color="#999",r.style.fontSize="12px",r.style.width="100%",r.style.height="80px",s.appendChild(r),Lr(a=document.createElement("div"),Dr.thumbnailPage),a.textContent="Page ".concat(i),s.appendChild(a),e.appendChild(s);case 1:case"end":return t.stop()}},t)}),s=1;case 2:if(!(s<=this.pdfDoc.numPages)){t.next=4;break}return t.delegateYield(i(s),"t0",3);case 3:s++,t.next=2;break;case 4:return this.sidebarScrollHandler=Rr(function(){return n.loadVisibleThumbnails(e)},50),e.addEventListener("scroll",this.sidebarScrollHandler),this.sidebarContentCreated=!0,t.next=5,this.loadVisibleThumbnails(e);case 5:t.next=7;break;case 6:return e.querySelectorAll("[data-active]").forEach(function(t,e){e+1===n.currentPage?(Object.assign(t.style,Dr.thumbnailActive),t.dataset.active="true"):(Object.keys(Dr.thumbnailActive).forEach(function(e){t.style.removeProperty(e)}),t.dataset.active="false")}),t.next=7,this.loadVisibleThumbnails(e);case 7:case"end":return t.stop()}},t,this)})),function(){return I.apply(this,arguments)})},{key:"loadVisibleThumbnails",value:(P=i(M.mark(function t(e){var s,n,r,a,o,l,h,c=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc){t.next=1;break}return t.abrupt("return");case 1:s=e.querySelectorAll("[data-page]"),n=e.getBoundingClientRect(),r=Array.from(s).filter(function(t){var e=t.getBoundingClientRect();return e.top<n.bottom+100&&e.bottom>n.top-100}),a=3,o=0;case 2:if(!(o<r.length)){t.next=4;break}return l=r.slice(o,o+a),h=l.map(function(){var t=i(M.mark(function t(e){var i;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i=parseInt(e.dataset.page||"0"))||e.querySelector("canvas")){t.next=1;break}return t.next=1,c.renderSingleThumbnail(e,i);case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),t.next=3,Promise.all(h);case 3:o+=a,t.next=2;break;case 4:case"end":return t.stop()}},t,this)})),function(t){return P.apply(this,arguments)})},{key:"renderSingleThumbnail",value:(k=i(M.mark(function t(e,i){var s,n,r,a,o,l,h,c;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc){t.next=1;break}return t.abrupt("return");case 1:return t.prev=1,t.next=2,this.pdfDoc.getPage(i);case 2:return s=t.sent,n=s.getViewport({scale:.2}),(r=document.createElement("canvas")).width=n.width,r.height=n.height,a=r.getContext("2d"),t.next=3,s.render({canvasContext:a,viewport:n}).promise;case 3:(o=e.firstChild)&&e.removeChild(o),Lr(l=document.createElement("canvas"),Dr.thumbnailCanvas),l.width=n.width,l.height=n.height,l.getContext("2d").drawImage(r,0,0),(h=e.querySelector("div:last-child"))?e.insertBefore(l,h):e.appendChild(l),this.thumbnails.set(i,r),t.next=5;break;case 4:t.prev=4,c=t.catch(1),console.error("Error rendering thumbnail:",c);case 5:case"end":return t.stop()}},t,this,[[1,4]])})),function(t,e){return k.apply(this,arguments)})},{key:"renderOutline",value:(T=i(M.mark(function t(){var e,i,s,n;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if((e=this.container.querySelector("#".concat(this.instanceId,"-sidebar-content"))).innerHTML="",this.pdfDoc){t.next=1;break}return t.abrupt("return");case 1:return t.prev=1,t.next=2,this.pdfDoc.getOutline();case 2:(i=t.sent)&&i.length>0?(this.outline=i,this.renderOutlineItems(i,e,0)):(Lr(s=document.createElement("div"),Dr.label),s.textContent="No outline available",s.style.padding="8px",e.appendChild(s)),t.next=4;break;case 3:t.prev=3,t.catch(1),Lr(n=document.createElement("div"),Dr.label),n.textContent="Failed to load outline",n.style.padding="8px",e.appendChild(n);case 4:case"end":return t.stop()}},t,this,[[1,3]])})),function(){return T.apply(this,arguments)})},{key:"renderOutlineItems",value:function(t,e,i){var s=this;t.forEach(function(t){var n=document.createElement("div");Lr(n,Dr.outlineItem),Fr(n,Dr.outlineItemHover);var r=document.createElement("span");Lr(r,Dr.outlineIcon),t.items&&t.items.length>0?r.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>':r.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>',n.appendChild(r);var a=document.createElement("span");a.textContent=t.title,n.appendChild(a),n.addEventListener("click",function(){t.dest&&s.pdfDoc.getPageIndex(t.dest).then(function(t){s.goToPage(t+1)})}),e.appendChild(n),t.items&&t.items.length>0&&s.renderOutlineItems(t.items,e,i+1)})}},{key:"initPdfJs",value:(E=i(M.mark(function t(){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:this.pdfjsLib=Ir,this.loadPdf();case 1:case"end":return t.stop()}},t,this)})),function(){return E.apply(this,arguments)})},{key:"loadPdf",value:(C=i(M.mark(function t(){var e,i,s,n,r,a,o,l,h=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cleanup(),t.prev=1,!this.options.url){t.next=2;break}s=this.pdfjsLib.getDocument({url:this.options.url,cMapUrl:this.options.cMapUrl||"pdfjs-dist/cmaps/",cMapPacked:this.options.cMapPacked}),t.next=6;break;case 2:if(!this.options.file){t.next=4;break}return t.next=3,Or(this.options.file);case 3:n=t.sent,s=this.pdfjsLib.getDocument({data:n,cMapUrl:this.options.cMapUrl||"pdfjs-dist/cmaps/",cMapPacked:this.options.cMapPacked}),t.next=6;break;case 4:if(!this.options.base64){t.next=5;break}r=Br(this.options.base64),s=this.pdfjsLib.getDocument({data:r,cMapUrl:this.options.cMapUrl||"pdfjs-dist/cmaps/",cMapPacked:this.options.cMapPacked}),t.next=6;break;case 5:throw new Error("No PDF source provided. Please provide url, file, or base64.");case 6:return this.loadingTask=s,this.options.onProgress&&(s.onProgress=function(t){var e,i,s=t.loaded/t.total*100;null===(e=(i=h.options).onProgress)||void 0===e||e.call(i,s)}),t.next=7,s.promise;case 7:this.pdfDoc=t.sent,this.loadingTask=null,this.updatePageInfo(),this.options.showToolbar&&this.renderThumbnails(),null===(e=(i=this.options).onLoad)||void 0===e||e.call(i),this.renderAllPages(),t.next=9;break;case 8:t.prev=8,l=t.catch(1),this.loadingTask=null,null===(a=(o=this.options).onError)||void 0===a||a.call(o,l);case 9:case"end":return t.stop()}},t,this,[[1,8]])})),function(){return C.apply(this,arguments)})},{key:"loadFile",value:(S=i(M.mark(function t(e){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cleanup(),!e.url){t.next=1;break}this.options.url=e.url,this.options.file=void 0,this.options.base64=void 0,t.next=4;break;case 1:if(!e.file){t.next=2;break}this.options.file=e.file,this.options.url=void 0,this.options.base64=void 0,t.next=4;break;case 2:if(!e.base64){t.next=3;break}this.options.base64=e.base64,this.options.url=void 0,this.options.file=void 0,t.next=4;break;case 3:throw new Error("No PDF source provided. Please provide url, file, or base64.");case 4:return this.currentPage=1,t.next=5,this.loadPdf();case 5:case"end":return t.stop()}},t,this)})),function(t){return S.apply(this,arguments)})},{key:"updatePageInfo",value:function(){var t=this.container.querySelector("#".concat(this.instanceId,"-page-input")),e=this.container.querySelector("#".concat(this.instanceId,"-page-label"));t&&e&&this.pdfDoc&&(t.max=this.pdfDoc.numPages.toString(),e.textContent="/ ".concat(this.pdfDoc.numPages))}},{key:"createPageContainer",value:(_=i(M.mark(function t(e){var i,s,n,r,a,o,l,h,c,d,u,p,g,f,m,b;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,this.pdfDoc.getPage(e);case 1:return i=t.sent,t.next=2,this.getScaleValue(i);case 2:return s=t.sent,n=i.getViewport({scale:s,rotation:this.options.rotation}),(r=document.createElement("div")).style.position="relative",r.style.margin="0 auto 20px auto",r.style.width="fit-content",r.style.setProperty("--scale-factor",s.toString()),a=document.createDocumentFragment(),o=document.createElement("canvas"),l=window.devicePixelRatio||1,h=n.clone({scale:n.scale*l}),o.width=h.width,o.height=h.height,o.style.width="".concat(n.width,"px"),o.style.height="".concat(n.height,"px"),o.style.display="block",Lr(o,Dr.canvas),c=o.getContext("2d"),d={canvasContext:c,viewport:h},t.next=3,i.render(d).promise;case 3:if(a.appendChild(o),!this.options.textLayer){t.next=5;break}return(u=document.createElement("div")).className="textLayer",Lr(u,Dr.textLayer),(p=document.createElement("style")).textContent='.textLayer {\n position: absolute;\n text-align: initial;\n inset: 0;\n overflow: clip;\n opacity: 1;\n line-height: 1;\n -webkit-text-size-adjust: none;\n -moz-text-size-adjust: none;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n z-index: 0;\n}\n\n.textLayer.highlighting {\n touch-action: none;\n}\n\n.textLayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n}\n\n.textLayer> :not(.markedContent),\n.textLayer .markedContent span:not(.markedContent) {\n z-index: 1;\n}\n\n.textLayer span.markedContent {\n top: 0;\n height: 0;\n}\n\n.textLayer span[role="img"] {\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n cursor: default;\n}\n\n.textLayer .highlight {\n --highlight-bg-color: rgb(180 0 170 / 0.25);\n --highlight-selected-bg-color: rgb(0 100 0 / 0.25);\n --highlight-backdrop-filter: none;\n --highlight-selected-backdrop-filter: none;\n}\n\n@media screen and (forced-colors: active) {\n .textLayer .highlight {\n --highlight-bg-color: transparent;\n --highlight-selected-bg-color: transparent;\n --highlight-backdrop-filter: var(--hcm-highlight-filter);\n --highlight-selected-backdrop-filter: var(--hcm-highlight-selected-filter);\n }\n}\n\n.textLayer .highlight {\n margin: -1px;\n padding: 1px;\n background-color: var(--highlight-bg-color);\n -webkit-backdrop-filter: var(--highlight-backdrop-filter);\n backdrop-filter: var(--highlight-backdrop-filter);\n border-radius: 4px;\n}\n\n.appended:is(.textLayer .highlight) {\n position: initial;\n}\n\n.begin:is(.textLayer .highlight) {\n border-radius: 4px 0 0 4px;\n}\n\n.end:is(.textLayer .highlight) {\n border-radius: 0 4px 4px 0;\n}\n\n.middle:is(.textLayer .highlight) {\n border-radius: 0;\n}\n\n.selected:is(.textLayer .highlight) {\n background-color: var(--highlight-selected-bg-color);\n -webkit-backdrop-filter: var(--highlight-selected-backdrop-filter);\n backdrop-filter: var(--highlight-selected-backdrop-filter);\n}\n\n.textLayer ::-moz-selection {\n background: rgba(0, 0, 255, 0.3);\n}\n\n.textLayer ::selection {\n background: rgba(0, 0, 255, 0.3);\n}\n\n.textLayer br::-moz-selection {\n background: transparent;\n}\n\n.textLayer br::selection {\n background: transparent;\n}\n\n.textLayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n\n.textLayer.selecting .endOfContent {\n top: 0;\n}\n',u.appendChild(p),g=cr,f=u,t.next=4,i.getTextContent();case 4:m=t.sent,b=n.clone({dontFlip:!0}),new g({container:f,textContentSource:m,viewport:b}).render(),a.appendChild(u);case 5:return r.appendChild(a),t.abrupt("return",r);case 6:case"end":return t.stop()}},t,this)})),function(t){return _.apply(this,arguments)})},{key:"renderPage",value:(A=i(M.mark(function t(e){var i,s,n,r,a,o,l;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc){t.next=1;break}throw new Error("PDF document not loaded");case 1:if(!(e<1||e>this.pdfDoc.numPages)){t.next=2;break}throw new Error("Page number ".concat(e," is out of range"));case 2:return this.currentPage=e,t.prev=3,t.next=4,this.createPageContainer(e);case 4:n=t.sent,this.pageCanvases.set(e,n),this.options.showToolbar&&((r=this.container.querySelector("#".concat(this.instanceId,"-page-input")))&&(r.value=e.toString()),this.updateThumbnailActive(e)),null===(i=(s=this.options).onPageRendered)||void 0===i||i.call(s,e),t.next=6;break;case 5:t.prev=5,l=t.catch(3),null===(a=(o=this.options).onError)||void 0===a||a.call(o,l);case 6:case"end":return t.stop()}},t,this,[[3,5]])})),function(t){return A.apply(this,arguments)})},{key:"renderAllPages",value:(x=i(M.mark(function t(){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:if(!this.options.renderAllPages){t.next=3;break}return t.next=2,this.renderFullPages();case 2:t.next=4;break;case 3:return t.next=4,this.renderVirtualPages();case 4:case"end":return t.stop()}},t,this)})),function(){return x.apply(this,arguments)})},{key:"renderFullPages",value:(w=i(M.mark(function t(){var e,i,s,n,r,a,o,l,h,c,d,u,p;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:this.pagesContainer.innerHTML="",this.pageCanvases.clear(),this.pagePlaceholders.clear(),this.renderedPages.clear(),this.pageHeights.clear(),this.renderQueue=[],this.scrollHandler&&(null===(e=this.content)||void 0===e||e.removeEventListener("scroll",this.scrollHandler)),i=document.createDocumentFragment(),s=1;case 2:if(!(s<=this.pdfDoc.numPages)){t.next=9;break}return t.prev=3,t.next=4,this.createPageContainer(s);case 4:return a=t.sent,this.pageCanvases.set(s,a),this.renderedPages.add(s),t.next=5,this.pdfDoc.getPage(s);case 5:return o=t.sent,t.next=6,this.getScaleValue(o);case 6:l=t.sent,h=o.getViewport({scale:l,rotation:this.options.rotation}),this.pageHeights.set(s,h.height+20),i.appendChild(a),null===(n=(r=this.options).onPageRendered)||void 0===n||n.call(r,s),t.next=8;break;case 7:t.prev=7,p=t.catch(3),null===(c=(d=this.options).onError)||void 0===c||c.call(d,p);case 8:s++,t.next=2;break;case 9:this.pagesContainer.appendChild(i),this.options.showToolbar&&((u=this.container.querySelector("#".concat(this.instanceId,"-page-input")))&&(u.value=this.currentPage.toString()),this.updateThumbnailActive(this.currentPage));case 10:case"end":return t.stop()}},t,this,[[3,7]])})),function(){return w.apply(this,arguments)})},{key:"renderVirtualPages",value:(y=i(M.mark(function t(){var e,i,s,n,r,a=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:if(this.pagesContainer.innerHTML="",this.pageCanvases.clear(),this.pagePlaceholders.clear(),this.renderedPages.clear(),this.pageHeights.clear(),this.renderQueue=[],this.scrollHandler&&(null===(i=this.content)||void 0===i||i.removeEventListener("scroll",this.scrollHandler)),s=null,"number"==typeof this.currentScale){t.next=6;break}return t.prev=2,t.next=3,this.pdfDoc.getPage(1);case 3:return n=t.sent,t.next=4,this.getScaleValue(n);case 4:s=t.sent,t.next=6;break;case 5:t.prev=5,t.catch(2),s=1;case 6:return t.next=7,this.createPagePlaceholders(s);case 7:return this.scrollHandler=Rr(function(){return a.handleScroll()},50),null===(e=this.content)||void 0===e||e.addEventListener("scroll",this.scrollHandler),t.next=8,this.renderInitialPages();case 8:return t.next=9,this.renderVisiblePages();case 9:this.options.showToolbar&&((r=this.container.querySelector("#".concat(this.instanceId,"-page-input")))&&(r.value=this.currentPage.toString()),this.updateThumbnailActive(this.currentPage));case 10:case"end":return t.stop()}},t,this,[[2,5]])})),function(){return y.apply(this,arguments)})},{key:"createPagePlaceholders",value:(v=i(M.mark(function t(e){var s,n,r,a,o,l,h,c,d,u,p,g=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:s=document.createDocumentFragment(),n=[],r=M.mark(function t(s){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n.push(i(M.mark(function t(){var i,n,r,a;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,g.pdfDoc.getPage(s);case 1:if(i=t.sent,null===e){t.next=2;break}a=e,t.next=4;break;case 2:return t.next=3,g.getScaleValue(i);case 3:a=t.sent;case 4:return n=a,r=i.getViewport({scale:n,rotation:g.options.rotation}),t.abrupt("return",{i:s,viewport:r,scale:n});case 5:return t.prev=5,t.catch(0),t.abrupt("return",{i:s,viewport:{width:800,height:1e3},scale:1});case 6:case"end":return t.stop()}},t,null,[[0,5]])}))());case 1:case"end":return t.stop()}},t)}),a=1;case 2:if(!(a<=this.pdfDoc.numPages)){t.next=4;break}return t.delegateYield(r(a),"t0",3);case 3:a++,t.next=2;break;case 4:return t.next=5,Promise.all(n);case 5:o=t.sent,l=zr(o);try{for(l.s();!(h=l.n()).done;)c=h.value,d=c.i,u=c.viewport,(p=document.createElement("div")).style.width="".concat(u.width,"px"),p.style.height="".concat(u.height,"px"),p.style.margin="0 auto 20px auto",p.style.background="#e0e0e0",p.style.display="flex",p.style.alignItems="center",p.style.justifyContent="center",p.style.color="#999",p.style.fontSize="14px",p.textContent="Loading page ".concat(d,"..."),this.pagePlaceholders.set(d,p),this.pageHeights.set(d,u.height+20),s.appendChild(p)}catch(t){l.e(t)}finally{l.f()}this.pagesContainer.appendChild(s);case 6:case"end":return t.stop()}},t,this)})),function(t){return v.apply(this,arguments)})},{key:"renderInitialPages",value:(b=i(M.mark(function t(){var e,i,s;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&this.content){t.next=1;break}return t.abrupt("return");case 1:e=Math.max(1,this.currentPage-1),i=Math.min(this.pdfDoc.numPages,this.currentPage+1),s=e;case 2:if(!(s<=i)){t.next=4;break}return t.next=3,this.renderSinglePage(s);case 3:s++,t.next=2;break;case 4:case"end":return t.stop()}},t,this)})),function(){return b.apply(this,arguments)})},{key:"renderVisiblePages",value:(m=i(M.mark(function t(){var e,i,s,n,r,a,o,l,h,c,d,u=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.content&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:for(e=this.content.scrollTop,i=this.content.clientHeight,s=this.pageHeights.get(this.currentPage+1)||0,n=Math.max(i,s),r=e-n,a=e+i+n,o=0,l=[],h=1;h<=this.pdfDoc.numPages;h++)c=this.pageHeights.get(h)||0,(d=o+c)>=r&&o<=a&&!this.renderedPages.has(h)&&l.push(h),o=d;this.renderQueue=l.filter(function(t){return!u.renderQueue.includes(t)}),this.processRenderQueue();case 2:case"end":return t.stop()}},t,this)})),function(){return m.apply(this,arguments)})},{key:"processRenderQueue",value:(f=i(M.mark(function t(){var e,i,s=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isRendering&&0!==this.renderQueue.length){t.next=1;break}return t.abrupt("return");case 1:return this.isRendering=!0,e=this.renderQueue.splice(0,this.maxConcurrentRenders),i=e.map(function(t){return s.renderSinglePage(t)}),t.next=2,Promise.all(i);case 2:this.isRendering=!1,this.renderQueue.length>0&&this.processRenderQueue();case 3:case"end":return t.stop()}},t,this)})),function(){return f.apply(this,arguments)})},{key:"renderSinglePage",value:(g=i(M.mark(function t(e){var i,s,n,r,a,o,l;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&!this.renderedPages.has(e)){t.next=1;break}return t.abrupt("return");case 1:if(i=this.pagePlaceholders.get(e)){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=3,this.createPageContainer(e);case 3:r=t.sent,this.pageCanvases.set(e,r),this.renderedPages.add(e),i.parentNode&&i.parentNode.replaceChild(r,i),null===(s=(n=this.options).onPageRendered)||void 0===s||s.call(n,e),t.next=5;break;case 4:t.prev=4,l=t.catch(2),null===(a=(o=this.options).onError)||void 0===a||a.call(o,l);case 5:case"end":return t.stop()}},t,this,[[2,4]])})),function(t){return g.apply(this,arguments)})},{key:"unloadPage",value:function(t){var e=this.pageCanvases.get(t);if(e){var i=this.pagePlaceholders.get(t);i&&e.parentNode&&e.parentNode.replaceChild(i,e),this.pageCanvases.delete(t),this.renderedPages.delete(t)}}},{key:"handleScroll",value:function(){this.renderVisiblePages(),this.updateCurrentPageFromScroll()}},{key:"updateCurrentPageFromScroll",value:function(){if(this.content&&this.pdfDoc&&!this.isNavigating){for(var t=this.content.scrollTop,e=this.content.clientHeight,i=0,s=this.currentPage,n=1;n<=this.pdfDoc.numPages;n++){var r=i+(this.pageHeights.get(n)||0);if(r>t+.3*e&&i<t+.7*e){s=n;break}i=r}if(s!==this.currentPage&&(this.currentPage=s,this.options.showToolbar)){var a=this.container.querySelector("#".concat(this.instanceId,"-page-input"));a&&(a.value=s.toString()),this.updateThumbnailActive(s)}}}},{key:"updateThumbnailActive",value:function(t){this.container.querySelectorAll("#".concat(this.instanceId,"-sidebar-content > div")).forEach(function(e,i){var s=e;i+1===t?(Object.assign(s.style,Dr.thumbnailActive),s.dataset.active="true"):(Object.keys(Dr.thumbnailActive).forEach(function(t){s.style.removeProperty(t)}),s.dataset.active="false")})}},{key:"getScaleValue",value:(p=i(M.mark(function t(e){var i,s,n;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if("number"!=typeof this.currentScale){t.next=1;break}return t.abrupt("return",this.currentScale);case 1:if("auto"!==this.currentScale&&this.currentScale){t.next=2;break}if(s=e.getViewport({scale:1,rotation:this.options.rotation}),!((n=null===(i=this.content)||void 0===i?void 0:i.clientWidth)>0)){t.next=2;break}return t.abrupt("return",(n-30)/s.width);case 2:return t.abrupt("return",1);case 3:case"end":return t.stop()}},t,this)})),function(t){return p.apply(this,arguments)})},{key:"updatePageUI",value:function(t){if(this.options.showToolbar){var e=this.container.querySelector("#".concat(this.instanceId,"-page-input"));e&&(e.value=t.toString()),this.updateThumbnailActive(t)}}},{key:"nextPage",value:(u=i(M.mark(function t(){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:this.currentPage<this.pdfDoc.numPages&&(this.currentPage=this.currentPage+1,this.scrollToPage(this.currentPage),this.updatePageUI(this.currentPage));case 2:case"end":return t.stop()}},t,this)})),function(){return u.apply(this,arguments)})},{key:"prevPage",value:(d=i(M.mark(function t(){return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:this.currentPage>1&&(this.currentPage=this.currentPage-1,this.scrollToPage(this.currentPage),this.updatePageUI(this.currentPage));case 1:case"end":return t.stop()}},t,this)})),function(){return d.apply(this,arguments)})},{key:"goToPage",value:(c=i(M.mark(function t(e){var i;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<1||e>((null===(i=this.pdfDoc)||void 0===i?void 0:i.numPages)||0))){t.next=1;break}return t.abrupt("return");case 1:this.currentPage=e,this.scrollToPage(e),this.updatePageUI(e);case 2:case"end":return t.stop()}},t,this)})),function(t){return c.apply(this,arguments)})},{key:"scrollToPage",value:(h=i(M.mark(function t(e){var i,s,n,r,a,o=this;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.content&&this.pagesContainer){t.next=1;break}return t.abrupt("return");case 1:for(i=0,s=1;s<e;s++)n=this.pageHeights.get(s)||0,i+=n;this.isNavigating=!0,r=setTimeout(function(){var t;o.isNavigating=!1,null===(t=o.content)||void 0===t||t.removeEventListener("scrollend",a),o.handleScroll()},2e3),a=function(){var t;clearTimeout(r),o.isNavigating=!1,null===(t=o.content)||void 0===t||t.removeEventListener("scrollend",a),o.handleScroll()},this.content.addEventListener("scrollend",a),this.content.scrollTo({top:i,behavior:"smooth"});case 2:case"end":return t.stop()}},t,this)})),function(t){return h.apply(this,arguments)})},{key:"zoomIn",value:function(){if("number"==typeof this.currentScale){var t=Math.min(this.currentScale+.25,4);this.setScale(t)}else this.setScale(1)}},{key:"zoomOut",value:function(){if("number"==typeof this.currentScale){var t=Math.max(this.currentScale-.25,.5);this.setScale(t)}else this.setScale(1)}},{key:"findText",value:(l=i(M.mark(function t(e){var i,s,n,r,a,o,l;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e&&this.pdfDoc){t.next=1;break}return t.abrupt("return");case 1:return t.prev=1,t.next=2,this.pdfDoc.getPage(this.currentPage);case 2:return i=t.sent,t.next=3,i.getTextContent();case 3:s=t.sent,n=s.items.filter(function(t){return t.str.includes(e)}),(r=this.container.querySelector("#".concat(this.instanceId,"-find-results")))&&(r.textContent="".concat(n.length," matches")),t.next=5;break;case 4:t.prev=4,l=t.catch(1),null===(a=(o=this.options).onError)||void 0===a||a.call(o,l);case 5:case"end":return t.stop()}},t,this,[[1,4]])})),function(t){return l.apply(this,arguments)})},{key:"findPrevious",value:function(){}},{key:"findNext",value:function(){}},{key:"setScale",value:function(t){this.currentScale=t;var e=this.container.querySelector("select");e&&(e.value=t),this.renderAllPages()}},{key:"setRotation",value:function(t){this.options.rotation=t,this.renderAllPages()}},{key:"getRotation",value:function(){return this.options.rotation}},{key:"getDocumentInfo",value:(o=i(M.mark(function t(){var e,i,s,n,r,a,o,l,h;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc){t.next=1;break}return t.abrupt("return",null);case 1:return t.next=2,this.pdfDoc.getMetadata();case 2:return h=t.sent,t.abrupt("return",{numPages:this.pdfDoc.numPages,fingerprint:this.pdfDoc.fingerprint,title:null==h||null===(e=h.info)||void 0===e?void 0:e.Title,author:null==h||null===(i=h.info)||void 0===i?void 0:i.Author,subject:null==h||null===(s=h.info)||void 0===s?void 0:s.Subject,keywords:null==h||null===(n=h.info)||void 0===n?void 0:n.Keywords,creator:null==h||null===(r=h.info)||void 0===r?void 0:r.Creator,producer:null==h||null===(a=h.info)||void 0===a?void 0:a.Producer,creationDate:null==h||null===(o=h.info)||void 0===o?void 0:o.CreationDate,modificationDate:null==h||null===(l=h.info)||void 0===l?void 0:l.ModDate});case 3:case"end":return t.stop()}},t,this)})),function(){return o.apply(this,arguments)})},{key:"getPageInfo",value:(n=i(M.mark(function t(e){var i,s;return M.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.pdfDoc){t.next=1;break}return t.abrupt("return",null);case 1:return t.prev=1,t.next=2,this.pdfDoc.getPage(e);case 2:return i=t.sent,s=i.getViewport({scale:1}),t.abrupt("return",{pageNumber:e,width:s.width,height:s.height,rotate:s.rotation});case 3:return t.prev=3,t.catch(1),t.abrupt("return",null);case 4:case"end":return t.stop()}},t,this,[[1,3]])})),function(t){return n.apply(this,arguments)})},{key:"getCurrentPage",value:function(){return this.currentPage}},{key:"getTotalPages",value:function(){var t;return(null===(t=this.pdfDoc)||void 0===t?void 0:t.numPages)||0}},{key:"destroy",value:function(){this.cleanup(),this.container&&(this.container.innerHTML="",delete this.container.__pdfPreviewInstance)}},{key:"cleanup",value:function(){var t;if(this.loadingTask&&(this.loadingTask.destroy(),this.loadingTask=null),this.scrollHandler&&(null===(t=this.content)||void 0===t||t.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null),this.sidebarScrollHandler){var e=this.container.querySelector("#".concat(this.instanceId,"-sidebar-content"));e&&e.removeEventListener("scroll",this.sidebarScrollHandler),this.sidebarScrollHandler=null}this.thumbnails.forEach(function(t){if(t&&t.getContext("2d")){var e=t.width,i=t.height;t.width=1,t.height=1,t.width=e,t.height=i}}),this.thumbnails.clear(),this.pageCanvases.forEach(function(t){if(t)for(;t.firstChild;)t.removeChild(t.firstChild)}),this.pageCanvases.clear(),this.pagePlaceholders.clear(),this.renderedPages.clear(),this.pageHeights.clear(),this.pdfDoc&&(this.pdfDoc.destroy(),this.pdfDoc=null),this.renderQueue=[]}}],e&&r(t.prototype,e),s&&r(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,s,n,o,l,h,c,d,u,p,g,f,m,b,v,y,w,x,A,_,S,C,E,T,k,P,I}();a(Ur,"instanceCounter",0);var Vr=Symbol("originalInstance"),$r={PdfPreview:Ur,createPdfPreview:function(t){return function(t){return new Proxy(t,{get:function(t,e){if(e===Vr)return t;var i=t[e];return"function"==typeof i?function(){for(var e=arguments.length,s=new Array(e),n=0;n<e;n++)s[n]=arguments[n];return i.apply(t,s)}:i}})}(new Ur(t))}};return $r});
|
|
4
25
|
//# sourceMappingURL=index.js.map
|