From a171903d472b62fb547f59fda9ccc9e096302f4f Mon Sep 17 00:00:00 2001 From: BlazerYoo Date: Sat, 17 Aug 2024 00:46:25 +0000 Subject: [PATCH] bundle all (no cdn) --- dist/bundle.js | 2 +- dist/pdf.worker.min.mjs | 21 + index.html | 2 +- src/file-parse.js | 3 +- style.css | 1126 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 1142 insertions(+), 12 deletions(-) create mode 100644 dist/pdf.worker.min.mjs diff --git a/dist/bundle.js b/dist/bundle.js index 831f053..eb538a3 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1,2 +1,2 @@ /*! For license information please see bundle.js.LICENSE.txt */ -(()=>{"use strict";var t={};function e(t){return t+.5|0}(t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})})(t);const A=(t,e,A)=>Math.max(Math.min(t,A),e);function i(t){return A(e(2.55*t),0,255)}function s(t){return A(e(255*t),0,255)}function a(t){return A(e(t/2.55)/100,0,1)}function n(t){return A(e(100*t),0,100)}const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},o=[..."0123456789ABCDEF"],g=t=>o[15&t],c=t=>o[(240&t)>>4]+o[15&t],h=t=>(240&t)>>4==(15&t);const l=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function I(t,e,A){const i=e*Math.min(A,1-A),s=(e,s=(e+t/30)%12)=>A-i*Math.max(Math.min(s-3,9-s,1),-1);return[s(0),s(8),s(4)]}function d(t,e,A){const i=(i,s=(i+t/60)%6)=>A-A*e*Math.max(Math.min(s,4-s,1),0);return[i(5),i(3),i(1)]}function u(t,e,A){const i=I(t,1,.5);let s;for(e+A>1&&(s=1/(e+A),e*=s,A*=s),s=0;s<3;s++)i[s]*=1-e-A,i[s]+=e;return i}function C(t){const e=t.r/255,A=t.g/255,i=t.b/255,s=Math.max(e,A,i),a=Math.min(e,A,i),n=(s+a)/2;let r,o,g;return s!==a&&(g=s-a,o=n>.5?g/(2-s-a):g/(s+a),r=function(t,e,A,i,s){return t===s?(e-A)/i+(et<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,w=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function D(t,e,A){if(t){let i=C(t);i[e]=Math.max(0,Math.min(i[e]+i[e]*A,0===e?360:1)),i=Q(i),t.r=i[0],t.g=i[1],t.b=i[2]}}function k(t,e){return t?Object.assign(e||{},t):t}function S(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=s(t[3]))):(e=k(t,{r:0,g:0,b:0,a:1})).a=s(e.a),e}function x(t){return"r"===t.charAt(0)?function(t){const e=y.exec(t);let s,a,n,r=255;if(e){if(e[7]!==s){const t=+e[7];r=e[8]?i(t):A(255*t,0,255)}return s=+e[1],a=+e[3],n=+e[5],s=255&(e[2]?i(s):A(s,0,255)),a=255&(e[4]?i(a):A(a,0,255)),n=255&(e[6]?i(n):A(n,0,255)),{r:s,g:a,b:n,a:r}}}(t):function(t){const e=l.exec(t);let A,a=255;if(!e)return;e[5]!==A&&(a=e[6]?i(+e[5]):s(+e[5]));const n=E(+e[2]),r=+e[3]/100,o=+e[4]/100;return A="hwb"===e[1]?function(t,e,A){return B(u,t,e,A)}(n,r,o):"hsv"===e[1]?function(t,e,A){return B(d,t,e,A)}(n,r,o):Q(n,r,o),{r:A[0],g:A[1],b:A[2],a}}(t)}class F{constructor(t){if(t instanceof F)return t;const e=typeof t;let A;var i,s,a;"object"===e?A=S(t):"string"===e&&(a=(i=t).length,"#"===i[0]&&(4===a||5===a?s={r:255&17*r[i[1]],g:255&17*r[i[2]],b:255&17*r[i[3]],a:5===a?17*r[i[4]]:255}:7!==a&&9!==a||(s={r:r[i[1]]<<4|r[i[2]],g:r[i[3]]<<4|r[i[4]],b:r[i[5]]<<4|r[i[6]],a:9===a?r[i[7]]<<4|r[i[8]]:255})),A=s||function(t){m||(m=function(){const t={},e=Object.keys(p),A=Object.keys(f);let i,s,a,n,r;for(i=0;i>16&255,a>>8&255,255&a]}return t}(),m.transparent=[0,0,0,0]);const e=m[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}(t)||x(t)),this._rgb=A,this._valid=!!A}get valid(){return this._valid}get rgb(){var t=k(this._rgb);return t&&(t.a=a(t.a)),t}set rgb(t){this._rgb=S(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${a(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?(t=this._rgb,e=(t=>h(t.r)&&h(t.g)&&h(t.b)&&h(t.a))(t)?g:c,t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0):void 0;var t,e}hslString(){return this._valid?function(t){if(!t)return;const e=C(t),A=e[0],i=n(e[1]),s=n(e[2]);return t.a<255?`hsla(${A}, ${i}%, ${s}%, ${a(t.a)})`:`hsl(${A}, ${i}%, ${s}%)`}(this._rgb):void 0}mix(t,e){if(t){const A=this.rgb,i=t.rgb;let s;const a=e===s?.5:e,n=2*a-1,r=A.a-i.a,o=((n*r==-1?n:(n+r)/(1+n*r))+1)/2;s=1-o,A.r=255&o*A.r+s*i.r+.5,A.g=255&o*A.g+s*i.g+.5,A.b=255&o*A.b+s*i.b+.5,A.a=a*A.a+(1-a)*i.a,this.rgb=A}return this}interpolate(t,e){return t&&(this._rgb=function(t,e,A){const i=w(a(t.r)),n=w(a(t.g)),r=w(a(t.b));return{r:s(b(i+A*(w(a(e.r))-i))),g:s(b(n+A*(w(a(e.g))-n))),b:s(b(r+A*(w(a(e.b))-r))),a:t.a+A*(e.a-t.a)}}(this._rgb,t._rgb,e)),this}clone(){return new F(this.rgb)}alpha(t){return this._rgb.a=s(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,A=e(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=A,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return D(this._rgb,2,t),this}darken(t){return D(this._rgb,2,-t),this}saturate(t){return D(this._rgb,1,t),this}desaturate(t){return D(this._rgb,1,-t),this}rotate(t){return function(t,e){var A=C(t);A[0]=E(A[0]+e),A=Q(A),t.r=A[0],t.g=A[1],t.b=A[2]}(this._rgb,t),this}}function R(){}const v=(()=>{let t=0;return()=>t++})();function N(t){return null==t}function M(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function G(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function L(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function U(t,e){return L(t)?t:e}function H(t,e){return void 0===t?e:t}const J=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function _(t,e,A){if(t&&"function"==typeof t.call)return t.apply(A,e)}function Y(t,e,A,i){let s,a,n;if(M(t))if(a=t.length,i)for(s=a-1;s>=0;s--)e.call(A,t[s],s);else for(s=0;st,x:t=>t.x,y:t=>t.y};function Z(t,e){const A=V[e]||(V[e]=function(t){const e=function(t){const e=t.split("."),A=[];let i="";for(const t of e)i+=t,i.endsWith("\\")?i=i.slice(0,-1)+".":(A.push(i),i="");return A}(t);return t=>{for(const A of e){if(""===A)break;t=t&&t[A]}return t}}(e));return A(t)}function X(t){return t.charAt(0).toUpperCase()+t.slice(1)}const z=t=>void 0!==t,$=t=>"function"==typeof t,tt=(t,e)=>{if(t.size!==e.size)return!1;for(const A of t)if(!e.has(A))return!1;return!0},et=Math.PI,At=2*et,it=At+et,st=Number.POSITIVE_INFINITY,at=et/180,nt=et/2,rt=et/4,ot=2*et/3,gt=Math.log10,ct=Math.sign;function ht(t,e,A){return Math.abs(t-e)o&&g=Math.min(e,A)-i&&t<=Math.max(e,A)+i}function wt(t,e,A){A=A||(A=>t[A]1;)i=a+s>>1,A(i)?a=i:s=i;return{lo:a,hi:s}}const Dt=(t,e,A,i)=>wt(t,A,i?i=>{const s=t[i][e];return st[i][e]wt(t,A,(i=>t[i][e]>=A)),St=["push","pop","shift","splice","unshift"];function xt(t,e){const A=t._chartjs;if(!A)return;const i=A.listeners,s=i.indexOf(e);-1!==s&&i.splice(s,1),i.length>0||(St.forEach((e=>{delete t[e]})),delete t._chartjs)}function Ft(t){const e=new Set(t);return e.size===t.length?t:Array.from(e)}const Rt="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function vt(t,e){let A=[],i=!1;return function(...s){A=s,i||(i=!0,Rt.call(window,(()=>{i=!1,t.apply(e,A)})))}}const Nt=t=>"start"===t?"left":"end"===t?"right":"center",Mt=(t,e,A)=>"start"===t?e:"end"===t?A:(e+A)/2;function Gt(t,e,A){const i=e.length;let s=0,a=i;if(t._sorted){const{iScale:n,_parsed:r}=t,o=n.axis,{min:g,max:c,minDefined:h,maxDefined:l}=n.getUserBounds();h&&(s=yt(Math.min(Dt(r,o,g).lo,A?i:Dt(e,o,n.getPixelForValue(g)).lo),0,i-1)),a=l?yt(Math.max(Dt(r,n.axis,c,!0).hi+1,A?0:Dt(e,o,n.getPixelForValue(c),!0).hi+1),s,i)-s:i-s}return{start:s,count:a}}function Lt(t){const{xScale:e,yScale:A,_scaleRanges:i}=t,s={xmin:e.min,xmax:e.max,ymin:A.min,ymax:A.max};if(!i)return t._scaleRanges=s,!0;const a=i.xmin!==e.min||i.xmax!==e.max||i.ymin!==A.min||i.ymax!==A.max;return Object.assign(i,s),a}const Ut=t=>0===t||1===t,Ht=(t,e,A)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*At/A),Jt=(t,e,A)=>Math.pow(2,-10*t)*Math.sin((t-e)*At/A)+1,_t={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*nt),easeOutSine:t=>Math.sin(t*nt),easeInOutSine:t=>-.5*(Math.cos(et*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Ut(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Ut(t)?t:Ht(t,.075,.3),easeOutElastic:t=>Ut(t)?t:Jt(t,.075,.3),easeInOutElastic(t){const e=.1125;return Ut(t)?t:t<.5?.5*Ht(2*t,e,.45):.5+.5*Jt(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-_t.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,A=2.75;return t<1/A?e*t*t:t<2/A?e*(t-=1.5/A)*t+.75:t<2.5/A?e*(t-=2.25/A)*t+.9375:e*(t-=2.625/A)*t+.984375},easeInOutBounce:t=>t<.5?.5*_t.easeInBounce(2*t):.5*_t.easeOutBounce(2*t-1)+.5};function Yt(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function Tt(t){return Yt(t)?t:new F(t)}function Pt(t){return Yt(t)?t:new F(t).saturate(.5).darken(.1).hexString()}const Kt=["x","y","borderWidth","radius","tension"],qt=["color","borderColor","backgroundColor"],Ot=new Map;function Wt(t,e,A){return function(t,e){e=e||{};const A=t+JSON.stringify(e);let i=Ot.get(A);return i||(i=new Intl.NumberFormat(t,e),Ot.set(A,i)),i}(e,A).format(t)}const jt={values:t=>M(t)?t:""+t,numeric(t,e,A){if(0===t)return"0";const i=this.chart.options.locale;let s,a=t;if(A.length>1){const e=Math.max(Math.abs(A[0].value),Math.abs(A[A.length-1].value));(e<1e-4||e>1e15)&&(s="scientific"),a=function(t,e){let A=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(A)>=1&&t!==Math.floor(t)&&(A=t-Math.floor(t)),A}(t,A)}const n=gt(Math.abs(a)),r=isNaN(n)?1:Math.max(Math.min(-1*Math.floor(n),20),0),o={notation:s,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(o,this.options.ticks.format),Wt(t,i,o)},logarithmic(t,e,A){if(0===t)return"0";const i=A[e].significand||t/Math.pow(10,Math.floor(gt(t)));return[1,2,3,5,10,15].includes(i)||e>.8*A.length?jt.numeric.call(this,t,e,A):""}};var Vt={formatters:jt};const Zt=Object.create(null),Xt=Object.create(null);function zt(t,e){if(!e)return t;const A=e.split(".");for(let e=0,i=A.length;et.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>Pt(e.backgroundColor),this.hoverBorderColor=(t,e)=>Pt(e.borderColor),this.hoverColor=(t,e)=>Pt(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return $t(this,t,e)}get(t){return zt(this,t)}describe(t,e){return $t(Xt,t,e)}override(t,e){return $t(Zt,t,e)}route(t,e,A,i){const s=zt(this,t),a=zt(this,A),n="_"+e;Object.defineProperties(s,{[n]:{value:s[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[n],e=a[i];return G(t)?Object.assign({},e,t):H(t,e)},set(t){this[n]=t}}})}apply(t){t.forEach((t=>t(this)))}}var ee=new te({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:qt},numbers:{type:"number",properties:Kt}}),t.describe("animations",{_fallback:"animation"}),t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}})},function(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(t){t.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Vt.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}]);function Ae(t,e,A,i,s){let a=e[s];return a||(a=e[s]=t.measureText(s).width,A.push(s)),a>i&&(i=a),i}function ie(t,e,A,i){let s=(i=i||{}).data=i.data||{},a=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(s=i.data={},a=i.garbageCollect=[],i.font=e),t.save(),t.font=e;let n=0;const r=A.length;let o,g,c,h,l;for(o=0;oA.length){for(o=0;o0&&t.stroke()}}function oe(t,e,A){return A=A||.5,!e||t&&t.x>e.left-A&&t.xe.top-A&&t.y0&&""!==a.strokeColor;let o,g;for(t.save(),t.font=s.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),N(e.rotation)||t.rotate(e.rotation),e.color&&(t.fillStyle=e.color),e.textAlign&&(t.textAlign=e.textAlign),e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,a),o=0;o+t||0;function pe(t,e){const A={},i=G(e),s=i?Object.keys(e):e,a=G(t)?i?A=>H(t[A],t[e[A]]):e=>t[e]:()=>t;for(const t of s)A[t]=fe(a(t));return A}function me(t){return pe(t,{top:"y",right:"x",bottom:"y",left:"x"})}function ye(t){return pe(t,["topLeft","topRight","bottomLeft","bottomRight"])}function be(t){const e=me(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function we(t,e){t=t||{},e=e||ee.font;let A=H(t.size,e.size);"string"==typeof A&&(A=parseInt(A,10));let i=H(t.style,e.style);i&&!(""+i).match(Qe)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:H(t.family,e.family),lineHeight:Ee(H(t.lineHeight,e.lineHeight),A),size:A,style:i,weight:H(t.weight,e.weight),string:""};return s.string=function(t){return!t||N(t.size)||N(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(s),s}function De(t,e,A,i){let s,a,n,r=!0;for(s=0,a=t.length;st[0]){const a=A||t;void 0===i&&(i=Je("_fallback",t));const n={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:a,_fallback:i,_getTarget:s,override:A=>Se([A,...t],e,a,i)};return new Proxy(n,{deleteProperty:(e,A)=>(delete e[A],delete e._keys,delete t[0][A],!0),get:(A,i)=>Ne(A,i,(()=>function(t,e,A,i){let s;for(const a of e)if(s=Je(Re(a,t),A),void 0!==s)return ve(t,s)?Ue(A,i,t,s):s}(i,e,t,A))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>_e(t).includes(e),ownKeys:t=>_e(t),set(t,e,A){const i=t._storage||(t._storage=s());return t[e]=i[e]=A,delete t._keys,!0}})}function xe(t,e,A,i){const s={_cacheable:!1,_proxy:t,_context:e,_subProxy:A,_stack:new Set,_descriptors:Fe(t,i),setContext:e=>xe(t,e,A,i),override:s=>xe(t.override(s),e,A,i)};return new Proxy(s,{deleteProperty:(e,A)=>(delete e[A],delete t[A],!0),get:(t,e,A)=>Ne(t,e,(()=>function(t,e,A){const{_proxy:i,_context:s,_subProxy:a,_descriptors:n}=t;let r=i[e];return $(r)&&n.isScriptable(e)&&(r=function(t,e,A,i){const{_proxy:s,_context:a,_subProxy:n,_stack:r}=A;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t);let o=e(a,n||i);return r.delete(t),ve(t,o)&&(o=Ue(s._scopes,s,t,o)),o}(e,r,t,A)),M(r)&&r.length&&(r=function(t,e,A,i){const{_proxy:s,_context:a,_subProxy:n,_descriptors:r}=A;if(void 0!==a.index&&i(t))return e[a.index%e.length];if(G(e[0])){const A=e,i=s._scopes.filter((t=>t!==A));e=[];for(const o of A){const A=Ue(i,s,t,o);e.push(xe(A,a,n&&n[t],r))}}return e}(e,r,t,n.isIndexable)),ve(e,r)&&(r=xe(r,s,a&&a[e],n)),r}(t,e,A))),getOwnPropertyDescriptor:(e,A)=>e._descriptors.allKeys?Reflect.has(t,A)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,A),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,A)=>Reflect.has(t,A),ownKeys:()=>Reflect.ownKeys(t),set:(e,A,i)=>(t[A]=i,delete e[A],!0)})}function Fe(t,e={scriptable:!0,indexable:!0}){const{_scriptable:A=e.scriptable,_indexable:i=e.indexable,_allKeys:s=e.allKeys}=t;return{allKeys:s,scriptable:A,indexable:i,isScriptable:$(A)?A:()=>A,isIndexable:$(i)?i:()=>i}}const Re=(t,e)=>t?t+X(e):e,ve=(t,e)=>G(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function Ne(t,e,A){if(Object.prototype.hasOwnProperty.call(t,e)||"constructor"===e)return t[e];const i=A();return t[e]=i,i}function Me(t,e,A){return $(t)?t(e,A):t}const Ge=(t,e)=>!0===t?e:"string"==typeof t?Z(e,t):void 0;function Le(t,e,A,i,s){for(const a of e){const e=Ge(A,a);if(e){t.add(e);const a=Me(e._fallback,A,s);if(void 0!==a&&a!==A&&a!==i)return a}else if(!1===e&&void 0!==i&&A!==i)return null}return!1}function Ue(t,e,A,i){const s=e._rootScopes,a=Me(e._fallback,A,i),n=[...t,...s],r=new Set;r.add(i);let o=He(r,n,A,a||A,i);return null!==o&&(void 0===a||a===A||(o=He(r,n,a,o,i),null!==o))&&Se(Array.from(r),[""],s,a,(()=>function(t,e,A){const i=t._getTarget();e in i||(i[e]={});const s=i[e];return M(s)&&G(A)?A:s||{}}(e,A,i)))}function He(t,e,A,i,s){for(;A;)A=Le(t,e,A,i,s);return A}function Je(t,e){for(const A of e){if(!A)continue;const e=A[t];if(void 0!==e)return e}}function _e(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const A of t)for(const t of Object.keys(A).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}function Ye(t,e,A,i){const{iScale:s}=t,{key:a="r"}=this._parsing,n=new Array(i);let r,o,g,c;for(r=0,o=i;re"x"===t?"y":"x";function qe(t,e,A,i){const s=t.skip?e:t,a=e,n=A.skip?e:A,r=Et(a,s),o=Et(n,a);let g=r/(r+o),c=o/(r+o);g=isNaN(g)?0:g,c=isNaN(c)?0:c;const h=i*g,l=i*c;return{previous:{x:a.x-h*(n.x-s.x),y:a.y-h*(n.y-s.y)},next:{x:a.x+l*(n.x-s.x),y:a.y+l*(n.y-s.y)}}}function Oe(t,e,A){return Math.max(Math.min(t,A),e)}function We(t,e,A,i,s){let a,n,r,o;if(e.spanGaps&&(t=t.filter((t=>!t.skip))),"monotone"===e.cubicInterpolationMode)!function(t,e="x"){const A=Ke(e),i=t.length,s=Array(i).fill(0),a=Array(i);let n,r,o,g=Pe(t,0);for(n=0;nt.ownerDocument.defaultView.getComputedStyle(t,null),ze=["top","right","bottom","left"];function $e(t,e,A){const i={};A=A?"-"+A:"";for(let s=0;s<4;s++){const a=ze[s];i[a]=parseFloat(t[e+"-"+a+A])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const tA=(t,e,A)=>(t>0||e>0)&&(!A||!A.shadowRoot);function eA(t,e){if("native"in t)return t;const{canvas:A,currentDevicePixelRatio:i}=e,s=Xe(A),a="border-box"===s.boxSizing,n=$e(s,"padding"),r=$e(s,"border","width"),{x:o,y:g,box:c}=function(t,e){const A=t.touches,i=A&&A.length?A[0]:t,{offsetX:s,offsetY:a}=i;let n,r,o=!1;if(tA(s,a,t.target))n=s,r=a;else{const t=e.getBoundingClientRect();n=i.clientX-t.left,r=i.clientY-t.top,o=!0}return{x:n,y:r,box:o}}(t,A),h=n.left+(c&&r.left),l=n.top+(c&&r.top);let{width:I,height:d}=e;return a&&(I-=n.width+r.width,d-=n.height+r.height),{x:Math.round((o-h)/I*A.width/i),y:Math.round((g-l)/d*A.height/i)}}const AA=t=>Math.round(10*t)/10;function iA(t,e,A){const i=e||1,s=Math.floor(t.height*i),a=Math.floor(t.width*i);t.height=Math.floor(t.height),t.width=Math.floor(t.width);const n=t.canvas;return n.style&&(A||!n.style.height&&!n.style.width)&&(n.style.height=`${t.height}px`,n.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==i||n.height!==s||n.width!==a)&&(t.currentDevicePixelRatio=i,n.height=s,n.width=a,t.ctx.setTransform(i,0,0,i,0,0),!0)}const sA=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};je()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch(t){}return t}();function aA(t,e){const A=function(t,e){return Xe(t).getPropertyValue(e)}(t,e),i=A&&A.match(/^(\d+)(\.\d+)?px$/);return i?+i[1]:void 0}function nA(t,e,A,i){return{x:t.x+A*(e.x-t.x),y:t.y+A*(e.y-t.y)}}function rA(t,e,A,i){return{x:t.x+A*(e.x-t.x),y:"middle"===i?A<.5?t.y:e.y:"after"===i?A<1?t.y:e.y:A>0?e.y:t.y}}function oA(t,e,A,i){const s={x:t.cp2x,y:t.cp2y},a={x:e.cp1x,y:e.cp1y},n=nA(t,s,A),r=nA(s,a,A),o=nA(a,e,A),g=nA(n,r,A),c=nA(r,o,A);return nA(g,c,A)}function gA(t,e,A){return t?function(t,e){return{x:A=>t+t+e-A,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,A):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function cA(t,e){let A,i;"ltr"!==e&&"rtl"!==e||(A=t.canvas.style,i=[A.getPropertyValue("direction"),A.getPropertyPriority("direction")],A.setProperty("direction",e,"important"),t.prevTextDirection=i)}function hA(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function lA(t){return"angle"===t?{between:mt,compare:ft,normalize:pt}:{between:bt,compare:(t,e)=>t-e,normalize:t=>t}}function IA({start:t,end:e,count:A,loop:i,style:s}){return{start:t%A,end:e%A,loop:i&&(e-t+1)%A==0,style:s}}function dA(t,e,A){if(!A)return[t];const{property:i,start:s,end:a}=A,n=e.length,{compare:r,between:o,normalize:g}=lA(i),{start:c,end:h,loop:l,style:I}=function(t,e,A){const{property:i,start:s,end:a}=A,{between:n,normalize:r}=lA(i),o=e.length;let g,c,{start:h,end:l,loop:I}=t;if(I){for(h+=o,l+=o,g=0,c=o;gi({chart:t,initial:e.initial,numSteps:a,currentStep:Math.min(A-e.start,a)})))}_refresh(){this._request||(this._running=!0,this._request=Rt.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((A,i)=>{if(!A.running||!A.items.length)return;const s=A.items;let a,n=s.length-1,r=!1;for(;n>=0;--n)a=s[n],a._active?(a._total>A.duration&&(A.duration=a._total),a.tick(t),r=!0):(s[n]=s[s.length-1],s.pop());r&&(i.draw(),this._notify(i,A,t,"progress")),s.length||(A.running=!1,this._notify(i,A,t,"complete"),A.initial=!1),e+=s.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let A=e.get(t);return A||(A={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,A)),A}listen(t,e,A){this._getAnims(t).listeners[e].push(A)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const A=e.items;let i=A.length-1;for(;i>=0;--i)A[i].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var EA=new QA;const fA="transparent",pA={boolean:(t,e,A)=>A>.5?e:t,color(t,e,A){const i=Tt(t||fA),s=i.valid&&Tt(e||fA);return s&&s.valid?s.mix(i,A).hexString():e},number:(t,e,A)=>t+(e-t)*A};class mA{constructor(t,e,A,i){const s=e[A];i=De([t.to,i,s,t.from]);const a=De([t.from,s,i]);this._active=!0,this._fn=t.fn||pA[t.type||typeof a],this._easing=_t[t.easing]||_t.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=A,this._from=a,this._to=i,this._promises=void 0}active(){return this._active}update(t,e,A){if(this._active){this._notify(!1);const i=this._target[this._prop],s=A-this._start,a=this._duration-s;this._start=A,this._duration=Math.floor(Math.max(a,t.duration)),this._total+=s,this._loop=!!t.loop,this._to=De([t.to,e,i,t.from]),this._from=De([t.from,i,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,A=this._duration,i=this._prop,s=this._from,a=this._loop,n=this._to;let r;if(this._active=s!==n&&(a||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[i]=this._fn(s,n,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,A)=>{t.push({res:e,rej:A})}))}_notify(t){const e=t?"res":"rej",A=this._promises||[];for(let t=0;t{const s=t[i];if(!G(s))return;const a={};for(const t of e)a[t]=s[t];(M(s.properties)&&s.properties||[i]).forEach((t=>{t!==i&&A.has(t)||A.set(t,a)}))}))}_animateOptions(t,e){const A=e.options,i=function(t,e){if(!e)return;let A=t.options;if(A)return A.$shared&&(t.options=A=Object.assign({},A,{$shared:!1,$animations:{}})),A;t.options=e}(t,A);if(!i)return[];const s=this._createAnimations(i,A);return A.$shared&&function(t,e){const A=[],i=Object.keys(e);for(let e=0;e{t.options=A}),(()=>{})),s}_createAnimations(t,e){const A=this._properties,i=[],s=t.$animations||(t.$animations={}),a=Object.keys(e),n=Date.now();let r;for(r=a.length-1;r>=0;--r){const o=a[r];if("$"===o.charAt(0))continue;if("options"===o){i.push(...this._animateOptions(t,e));continue}const g=e[o];let c=s[o];const h=A.get(o);if(c){if(h&&c.active()){c.update(h,g,n);continue}c.cancel()}h&&h.duration?(s[o]=c=new mA(h,t,o,g),i.push(c)):t[o]=g}return i}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const A=this._createAnimations(t,e);return A.length?(EA.add(this._chart,A),!0):void 0}}function bA(t,e){const A=t&&t.options||{},i=A.reverse,s=void 0===A.min?e:0,a=void 0===A.max?e:0;return{start:i?a:s,end:i?s:a}}function wA(t,e){const A=[],i=t._getSortedDatasetMetas(e);let s,a;for(s=0,a=i.length;s0||!A&&e<0)return s.index}return null}function FA(t,e){const{chart:A,_cachedMeta:i}=t,s=A._stacks||(A._stacks={}),{iScale:a,vScale:n,index:r}=i,o=a.axis,g=n.axis,c=function(t,e,A){return`${t.id}.${e.id}.${A.stack||A.type}`}(a,n,i),h=e.length;let l;for(let t=0;tA[t].axis===e)).shift()}function vA(t,e){const A=t.controller.index,i=t.vScale&&t.vScale.axis;if(i){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[i]||void 0===e[i][A])return;delete e[i][A],void 0!==e[i]._visualValues&&void 0!==e[i]._visualValues[A]&&delete e[i]._visualValues[A]}}}const NA=t=>"reset"===t||"none"===t,MA=(t,e)=>e?t:Object.assign({},t);class GA{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=kA(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&vA(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,A=this.getDataset(),i=(t,e,A,i)=>"x"===t?e:"r"===t?i:A,s=e.xAxisID=H(A.xAxisID,RA(t,"x")),a=e.yAxisID=H(A.yAxisID,RA(t,"y")),n=e.rAxisID=H(A.rAxisID,RA(t,"r")),r=e.indexAxis,o=e.iAxisID=i(r,s,a,n),g=e.vAxisID=i(r,a,s,n);e.xScale=this.getScaleForId(s),e.yScale=this.getScaleForId(a),e.rScale=this.getScaleForId(n),e.iScale=this.getScaleForId(o),e.vScale=this.getScaleForId(g)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&xt(this._data,this),t._stacked&&vA(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),A=this._data;if(G(e)){const t=this._cachedMeta;this._data=function(t,e){const{iScale:A,vScale:i}=e,s="x"===A.axis?"x":"y",a="x"===i.axis?"x":"y",n=Object.keys(t),r=new Array(n.length);let o,g,c;for(o=0,g=n.length;o{const e="_onData"+X(t),A=i[t];Object.defineProperty(i,t,{configurable:!0,enumerable:!1,value(...t){const s=A.apply(this,t);return i._chartjs.listeners.forEach((A=>{"function"==typeof A[e]&&A[e](...t)})),s}})})))),this._syncList=[],this._data=e}var i}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,A=this.getDataset();let i=!1;this._dataCheck();const s=e._stacked;e._stacked=kA(e.vScale,e),e.stack!==A.stack&&(i=!0,vA(e),e.stack=A.stack),this._resyncElements(t),(i||s!==e._stacked)&&FA(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),A=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(A,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:A,_data:i}=this,{iScale:s,_stacked:a}=A,n=s.axis;let r,o,g,c=0===t&&e===i.length||A._sorted,h=t>0&&A._parsed[t-1];if(!1===this._parsing)A._parsed=i,A._sorted=!0,g=i;else{g=M(i[t])?this.parseArrayData(A,i,t,e):G(i[t])?this.parseObjectData(A,i,t,e):this.parsePrimitiveData(A,i,t,e);const s=()=>null===o[n]||h&&o[n]t&&!e.hidden&&e._stacked&&{keys:wA(A,!0),values:null})(e,A,this.chart),o={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:g,max:c}=function(t){const{min:e,max:A,minDefined:i,maxDefined:s}=t.getUserBounds();return{min:i?e:Number.NEGATIVE_INFINITY,max:s?A:Number.POSITIVE_INFINITY}}(n);let h,l;function I(){l=i[h];const e=l[n.axis];return!L(l[t.axis])||g>e||c=0;--h)if(!I()){this.updateRangeFromParsed(o,t,l,r);break}return o}getAllParsedValues(t){const e=this._cachedMeta._parsed,A=[];let i,s,a;for(i=0,s=e.length;i=0&&tthis.getContext(A,i,e)),c);return I.$shared&&(I.$shared=r,s[a]=Object.freeze(MA(I,r))),I}_resolveAnimations(t,e,A){const i=this.chart,s=this._cachedDataOpts,a=`animation-${e}`,n=s[a];if(n)return n;let r;if(!1!==i.options.animation){const i=this.chart.config,s=i.datasetAnimationScopeKeys(this._type,e),a=i.getOptionScopes(this.getDataset(),s);r=i.createResolver(a,this.getContext(t,A,e))}const o=new yA(i,r&&r.animations);return r&&r._cacheable&&(s[a]=Object.freeze(o)),o}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||NA(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const A=this.resolveDataElementOptions(t,e),i=this._sharedOptions,s=this.getSharedOptions(A),a=this.includeOptions(e,s)||s!==i;return this.updateSharedOptions(s,e,A),{sharedOptions:s,includeOptions:a}}updateElement(t,e,A,i){NA(i)?Object.assign(t,A):this._resolveAnimations(e,i).update(t,A)}updateSharedOptions(t,e,A){t&&!NA(e)&&this._resolveAnimations(void 0,e).update(t,A)}_setStyle(t,e,A,i){t.active=i;const s=this.getStyle(e,i);this._resolveAnimations(e,A,i).update(t,{options:!i&&this.getSharedOptions(s)||s})}removeHoverStyle(t,e,A){this._setStyle(t,A,"active",!1)}setHoverStyle(t,e,A){this._setStyle(t,A,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,A=this._cachedMeta.data;for(const[t,e,A]of this._syncList)this[t](e,A);this._syncList=[];const i=A.length,s=e.length,a=Math.min(s,i);a&&this.parse(0,a),s>i?this._insertElements(i,s-i,t):s{for(t.length+=e,n=t.length-1;n>=a;n--)t[n]=t[n-e]};for(r(s),n=t;nt-e)))}return t._cache.$bar}(e,t.type);let i,s,a,n,r=e._length;const o=()=>{32767!==a&&-32768!==a&&(z(n)&&(r=Math.min(r,Math.abs(a-n)||r)),n=a)};for(i=0,s=A.length;iMath.abs(r)&&(o=r,g=n),e[A.axis]=g,e._custom={barStart:o,barEnd:g,start:s,end:a,min:n,max:r}}(t,e,A,i):e[A.axis]=A.parse(t,i),e}function HA(t,e,A,i){const s=t.iScale,a=t.vScale,n=s.getLabels(),r=s===a,o=[];let g,c,h,l;for(g=A,c=A+i;gt.x,A="left",i="right"):(e=t.base"spacing"!==t,_indexable:t=>"spacing"!==t&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:A,color:i}}=t.legend.options;return e.labels.map(((e,s)=>{const a=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:i,lineWidth:a.borderWidth,pointStyle:A,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,A){A.chart.toggleDataVisibility(e.index),A.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const A=this.getDataset().data,i=this._cachedMeta;if(!1===this._parsing)i._parsed=A;else{let s,a,n=t=>+A[t];if(G(A[t])){const{key:t="value"}=this._parsing;n=e=>+Z(A[e],t)}for(s=t,a=t+e;smt(t,r,o,!0)?1:Math.max(e,e*A,i,i*A),d=(t,e,i)=>mt(t,r,o,!0)?-1:Math.min(e,e*A,i,i*A),u=I(0,g,h),C=I(nt,c,l),B=d(et,g,h),Q=d(et+nt,c,l);i=(u-B)/2,s=(C-Q)/2,a=-(u+B)/2,n=-(C+Q)/2}return{ratioX:i,ratioY:s,offsetX:a,offsetY:n}}(l,h,r),B=(A.width-a)/I,Q=(A.height-a)/d,E=Math.max(Math.min(B,Q)/2,0),f=J(this.options.radius,E),p=(f-Math.max(f*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=u*f,this.offsetY=C*f,i.total=this.calculateTotal(),this.outerRadius=f-p*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-p*c,0),this.updateElements(s,0,s.length,t)}_circumference(t,e){const A=this.options,i=this._cachedMeta,s=this._getCircumference();return e&&A.animation.animateRotate||!this.chart.getDataVisibility(t)||null===i._parsed[t]||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*s/At)}updateElements(t,e,A,i){const s="reset"===i,a=this.chart,n=a.chartArea,r=a.options.animation,o=(n.left+n.right)/2,g=(n.top+n.bottom)/2,c=s&&r.animateScale,h=c?0:this.innerRadius,l=c?0:this.outerRadius,{sharedOptions:I,includeOptions:d}=this._getSharedOptions(e,i);let u,C=this._getRotation();for(u=0;u0&&!isNaN(t)?At*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,A=this.chart,i=A.data.labels||[],s=Wt(e._parsed[t],A.options.locale);return{label:i[t]||"",value:s}}getMaxBorderWidth(t){let e=0;const A=this.chart;let i,s,a,n,r;if(!t)for(i=0,s=A.data.datasets.length;i{const a=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:i,lineWidth:a.borderWidth,pointStyle:A,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,A){A.chart.toggleDataVisibility(e.index),A.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,A=this.chart,i=A.data.labels||[],s=Wt(e._parsed[t].r,A.options.locale);return{label:i[t]||"",value:s}}parseObjectData(t,e,A,i){return Ye.bind(this)(t,e,A,i)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach(((t,A)=>{const i=this.getParsed(A).r;!isNaN(i)&&this.chart.getDataVisibility(A)&&(ie.max&&(e.max=i))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,A=t.options,i=Math.min(e.right-e.left,e.bottom-e.top),s=Math.max(i/2,0),a=(s-Math.max(A.cutoutPercentage?s/100*A.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=s-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,A,i){const s="reset"===i,a=this.chart,n=a.options.animation,r=this._cachedMeta.rScale,o=r.xCenter,g=r.yCenter,c=r.getIndexAngle(0)-.5*et;let h,l=c;const I=360/this.countVisibleElements();for(h=0;h{!isNaN(this.getParsed(A).r)&&this.chart.getDataVisibility(A)&&e++})),e}_computeAngle(t,e,A){return this.chart.getDataVisibility(t)?ut(this.resolveDataElementOptions(t,e).angle||A):0}}var OA=Object.freeze({__proto__:null,BarController:class extends GA{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,e,A,i){return HA(t,e,A,i)}parseArrayData(t,e,A,i){return HA(t,e,A,i)}parseObjectData(t,e,A,i){const{iScale:s,vScale:a}=t,{xAxisKey:n="x",yAxisKey:r="y"}=this._parsing,o="x"===s.axis?n:r,g="x"===a.axis?n:r,c=[];let h,l,I,d;for(h=A,l=A+i;ht.controller.options.grouped)),s=A.options.stacked,a=[],n=t=>{const A=t.controller.getParsed(e),i=A&&A[t.vScale.axis];if(N(i)||isNaN(i))return!0};for(const A of i)if((void 0===e||!n(A))&&((!1===s||-1===a.indexOf(A.stack)||void 0===s&&void 0===A.stack)&&a.push(A.stack),A.index===t))break;return a.length||a.push(void 0),a}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,A){const i=this._getStacks(t,A),s=void 0!==e?i.indexOf(e):-1;return-1===s?i.length-1:s}_getRuler(){const t=this.options,e=this._cachedMeta,A=e.iScale,i=[];let s,a;for(s=0,a=e.data.length;s=A?1:-1)}(h,e,n)*a,l===n&&(C-=h/2);const t=e.getPixelForDecimal(0),s=e.getPixelForDecimal(1),o=Math.min(t,s),I=Math.max(t,s);C=Math.max(Math.min(C,I),o),c=C+h,A&&!g&&(r._stacks[e.axis]._visualValues[i]=e.getValueForPixel(c)-e.getValueForPixel(C))}if(C===e.getPixelForValue(n)){const t=ct(h)*e.getLineWidthForValue(n)/2;C+=t,h-=t}return{size:h,base:C,head:c,center:c+h/2}}_calculateBarIndexPixels(t,e){const A=e.scale,i=this.options,s=i.skipNull,a=H(i.maxBarThickness,1/0);let n,r;if(e.grouped){const A=s?this._getStackCount(t):e.stackCount,o="flex"===i.barThickness?function(t,e,A,i){const s=e.pixels,a=s[t];let n=t>0?s[t-1]:null,r=t=0;--A)e=Math.max(e,t[A].size(this.resolveDataElementOptions(A))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,A=this.chart.data.labels||[],{xScale:i,yScale:s}=e,a=this.getParsed(t),n=i.getLabelForValue(a.x),r=s.getLabelForValue(a.y),o=a._custom;return{label:A[t]||"",value:"("+n+", "+r+(o?", "+o:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,A,i){const s="reset"===i,{iScale:a,vScale:n}=this._cachedMeta,{sharedOptions:r,includeOptions:o}=this._getSharedOptions(e,i),g=a.axis,c=n.axis;for(let h=e;h0&&this.getParsed(e-1);for(let A=0;A=B){Q.skip=!0;continue}const f=this.getParsed(A),p=N(f[l]),m=Q[h]=a.getPixelForValue(f[h],A),y=Q[l]=s||p?n.getBasePixel():n.getPixelForValue(r?this.applyStack(n,f,r):f[l],A);Q.skip=isNaN(m)||isNaN(y)||p,Q.stop=A>0&&Math.abs(f[h]-E[h])>u,d&&(Q.parsed=f,Q.raw=o.data[A]),c&&(Q.options=g||this.resolveDataElementOptions(A,I.active?"active":i)),C||this.updateElement(I,A,Q,i),E=f}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,A=e.options&&e.options.borderWidth||0,i=t.data||[];if(!i.length)return A;const s=i[0].size(this.resolveDataElementOptions(0)),a=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(A,s,a)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}},PieController:class extends KA{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:qA,RadarController:class extends GA{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale,A=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(A[e.axis])}}parseObjectData(t,e,A,i){return Ye.bind(this)(t,e,A,i)}update(t){const e=this._cachedMeta,A=e.dataset,i=e.data||[],s=e.iScale.getLabels();if(A.points=i,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const a={_loop:!0,_fullLoop:s.length===i.length,options:e};this.updateElement(A,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,A,i){const s=this._cachedMeta.rScale,a="reset"===i;for(let n=e;n0&&this.getParsed(e-1);for(let g=e;g0&&Math.abs(A[l]-Q[l])>C,u&&(d.parsed=A,d.raw=o.data[g]),h&&(d.options=c||this.resolveDataElementOptions(g,e.active?"active":i)),B||this.updateElement(e,g,d,i),Q=A}this.updateSharedOptions(c,i,g)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let A=e.length-1;A>=0;--A)t=Math.max(t,e[A].size(this.resolveDataElementOptions(A))/2);return t>0&&t}const A=t.dataset,i=A.options&&A.options.borderWidth||0;if(!e.length)return i;const s=e[0].size(this.resolveDataElementOptions(0)),a=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,s,a)/2}}});function WA(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class jA{static override(t){Object.assign(jA.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return WA()}parse(){return WA()}format(){return WA()}add(){return WA()}diff(){return WA()}startOf(){return WA()}endOf(){return WA()}}var VA=jA;function ZA(t,e,A,i){const{controller:s,data:a,_sorted:n}=t,r=s._cachedMeta.iScale;if(r&&e===r.axis&&"r"!==e&&n&&a.length){const t=r._reversePixels?kt:Dt;if(!i)return t(a,e,A);if(s._sharedOptions){const i=a[0],s="function"==typeof i.getRange&&i.getRange(e);if(s){const i=t(a,e,A-s),n=t(a,e,A+s);return{lo:i.lo,hi:n.hi}}}}return{lo:0,hi:a.length-1}}function XA(t,e,A,i,s){const a=t.getSortedVisibleDatasetMetas(),n=A[e];for(let t=0,A=a.length;t{t[n](e[A],s)&&(a.push({element:t,datasetIndex:i,index:o}),r=r||t.inRange(e.x,e.y,s))})),i&&!r?[]:a}var ei={evaluateInteractionItems:XA,modes:{index(t,e,A,i){const s=eA(e,t),a=A.axis||"x",n=A.includeInvisible||!1,r=A.intersect?zA(t,s,a,i,n):$A(t,s,a,!1,i,n),o=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,A=t.data[e];A&&!A.skip&&o.push({element:A,datasetIndex:t.index,index:e})})),o):[]},dataset(t,e,A,i){const s=eA(e,t),a=A.axis||"xy",n=A.includeInvisible||!1;let r=A.intersect?zA(t,s,a,i,n):$A(t,s,a,!1,i,n);if(r.length>0){const e=r[0].datasetIndex,A=t.getDatasetMeta(e).data;r=[];for(let t=0;tzA(t,eA(e,t),A.axis||"xy",i,A.includeInvisible||!1),nearest(t,e,A,i){const s=eA(e,t),a=A.axis||"xy",n=A.includeInvisible||!1;return $A(t,s,a,A.intersect,i,n)},x:(t,e,A,i)=>ti(t,eA(e,t),"x",A.intersect,i),y:(t,e,A,i)=>ti(t,eA(e,t),"y",A.intersect,i)}};const Ai=["left","top","right","bottom"];function ii(t,e){return t.filter((t=>t.pos===e))}function si(t,e){return t.filter((t=>-1===Ai.indexOf(t.pos)&&t.box.axis===e))}function ai(t,e){return t.sort(((t,A)=>{const i=e?A:t,s=e?t:A;return i.weight===s.weight?i.index-s.index:i.weight-s.weight}))}function ni(t,e,A,i){return Math.max(t[A],e[A])+Math.max(t[i],e[i])}function ri(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function oi(t,e,A,i){const{pos:s,box:a}=A,n=t.maxPadding;if(!G(s)){A.size&&(t[s]-=A.size);const e=i[A.stack]||{size:0,count:1};e.size=Math.max(e.size,A.horizontal?a.height:a.width),A.size=e.size/e.count,t[s]+=A.size}a.getPadding&&ri(n,a.getPadding());const r=Math.max(0,e.outerWidth-ni(n,t,"left","right")),o=Math.max(0,e.outerHeight-ni(n,t,"top","bottom")),g=r!==t.w,c=o!==t.h;return t.w=r,t.h=o,A.horizontal?{same:g,other:c}:{same:c,other:g}}function gi(t,e){const A=e.maxPadding;return function(t){const i={left:0,top:0,right:0,bottom:0};return t.forEach((t=>{i[t]=Math.max(e[t],A[t])})),i}(t?["left","right"]:["top","bottom"])}function ci(t,e,A,i){const s=[];let a,n,r,o,g,c;for(a=0,n=t.length,g=0;at.box.fullSize)),!0),i=ai(ii(e,"left"),!0),s=ai(ii(e,"right")),a=ai(ii(e,"top"),!0),n=ai(ii(e,"bottom")),r=si(e,"x"),o=si(e,"y");return{fullSize:A,leftAndTop:i.concat(a),rightAndBottom:s.concat(o).concat(n).concat(r),chartArea:ii(e,"chartArea"),vertical:i.concat(s).concat(o),horizontal:a.concat(n).concat(r)}}(t.boxes),o=r.vertical,g=r.horizontal;Y(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=o.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,h=Object.freeze({outerWidth:e,outerHeight:A,padding:s,availableWidth:a,availableHeight:n,vBoxMaxWidth:a/2/c,hBoxMaxHeight:n/2}),l=Object.assign({},s);ri(l,be(i));const I=Object.assign({maxPadding:l,w:a,h:n,x:s.left,y:s.top},s),d=function(t,e){const A=function(t){const e={};for(const A of t){const{stack:t,pos:i,stackWeight:s}=A;if(!t||!Ai.includes(i))continue;const a=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});a.count++,a.weight+=s}return e}(t),{vBoxMaxWidth:i,hBoxMaxHeight:s}=e;let a,n,r;for(a=0,n=t.length;a{const A=e.box;Object.assign(A,t.chartArea),A.update(I.w,I.h,{left:0,top:0,right:0,bottom:0})}))}};class di{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,A){}removeEventListener(t,e,A){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,A,i){return e=Math.max(0,e||t.width),A=A||t.height,{width:e,height:Math.max(0,i?Math.floor(e/i):A)}}isAttached(t){return!0}updateConfig(t){}}class ui extends di{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Ci="$chartjs",Bi={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Qi=t=>null===t||""===t,Ei=!!sA&&{passive:!0};function fi(t,e,A){t&&t.canvas&&t.canvas.removeEventListener(e,A,Ei)}function pi(t,e){for(const A of t)if(A===e||A.contains(e))return!0}function mi(t,e,A){const i=t.canvas,s=new MutationObserver((t=>{let e=!1;for(const A of t)e=e||pi(A.addedNodes,i),e=e&&!pi(A.removedNodes,i);e&&A()}));return s.observe(document,{childList:!0,subtree:!0}),s}function yi(t,e,A){const i=t.canvas,s=new MutationObserver((t=>{let e=!1;for(const A of t)e=e||pi(A.removedNodes,i),e=e&&!pi(A.addedNodes,i);e&&A()}));return s.observe(document,{childList:!0,subtree:!0}),s}const bi=new Map;let wi=0;function Di(){const t=window.devicePixelRatio;t!==wi&&(wi=t,bi.forEach(((e,A)=>{A.currentDevicePixelRatio!==t&&e()})))}function ki(t,e,A){const i=t.canvas,s=i&&Ve(i);if(!s)return;const a=vt(((t,e)=>{const i=s.clientWidth;A(t,e),i{const e=t[0],A=e.contentRect.width,i=e.contentRect.height;0===A&&0===i||a(A,i)}));return n.observe(s),function(t,e){bi.size||window.addEventListener("resize",Di),bi.set(t,e)}(t,a),n}function Si(t,e,A){A&&A.disconnect(),"resize"===e&&function(t){bi.delete(t),bi.size||window.removeEventListener("resize",Di)}(t)}function xi(t,e,A){const i=t.canvas,s=vt((e=>{null!==t.ctx&&A(function(t,e){const A=Bi[t.type]||t.type,{x:i,y:s}=eA(t,e);return{type:A,chart:e,native:t,x:void 0!==i?i:null,y:void 0!==s?s:null}}(e,t))}),t);return function(t,e,A){t&&t.addEventListener(e,A,Ei)}(i,e,s),s}class Fi extends di{acquireContext(t,e){const A=t&&t.getContext&&t.getContext("2d");return A&&A.canvas===t?(function(t,e){const A=t.style,i=t.getAttribute("height"),s=t.getAttribute("width");if(t[Ci]={initial:{height:i,width:s,style:{display:A.display,height:A.height,width:A.width}}},A.display=A.display||"block",A.boxSizing=A.boxSizing||"border-box",Qi(s)){const e=aA(t,"width");void 0!==e&&(t.width=e)}if(Qi(i))if(""===t.style.height)t.height=t.width/(e||2);else{const e=aA(t,"height");void 0!==e&&(t.height=e)}}(t,e),A):null}releaseContext(t){const e=t.canvas;if(!e[Ci])return!1;const A=e[Ci].initial;["height","width"].forEach((t=>{const i=A[t];N(i)?e.removeAttribute(t):e.setAttribute(t,i)}));const i=A.style||{};return Object.keys(i).forEach((t=>{e.style[t]=i[t]})),e.width=e.width,delete e[Ci],!0}addEventListener(t,e,A){this.removeEventListener(t,e);const i=t.$proxies||(t.$proxies={}),s={attach:mi,detach:yi,resize:ki}[e]||xi;i[e]=s(t,e,A)}removeEventListener(t,e){const A=t.$proxies||(t.$proxies={}),i=A[e];i&&(({attach:Si,detach:Si,resize:Si}[e]||fi)(t,e,i),A[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,A,i){return function(t,e,A,i){const s=Xe(t),a=$e(s,"margin"),n=Ze(s.maxWidth,t,"clientWidth")||st,r=Ze(s.maxHeight,t,"clientHeight")||st,o=function(t,e,A){let i,s;if(void 0===e||void 0===A){const a=t&&Ve(t);if(a){const t=a.getBoundingClientRect(),n=Xe(a),r=$e(n,"border","width"),o=$e(n,"padding");e=t.width-o.width-r.width,A=t.height-o.height-r.height,i=Ze(n.maxWidth,a,"clientWidth"),s=Ze(n.maxHeight,a,"clientHeight")}else e=t.clientWidth,A=t.clientHeight}return{width:e,height:A,maxWidth:i||st,maxHeight:s||st}}(t,e,A);let{width:g,height:c}=o;if("content-box"===s.boxSizing){const t=$e(s,"border","width"),e=$e(s,"padding");g-=e.width+t.width,c-=e.height+t.height}return g=Math.max(0,g-a.width),c=Math.max(0,i?g/i:c-a.height),g=AA(Math.min(g,n,o.maxWidth)),c=AA(Math.min(c,r,o.maxHeight)),g&&!c&&(c=AA(g/2)),(void 0!==e||void 0!==A)&&i&&o.height&&c>o.height&&(c=o.height,g=AA(Math.floor(c*i))),{width:g,height:c}}(t,e,A,i)}isAttached(t){const e=t&&Ve(t);return!(!e||!e.isConnected)}}class Ri{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:A}=this.getProps(["x","y"],t);return{x:e,y:A}}hasValue(){return It(this.x)&&It(this.y)}getProps(t,e){const A=this.$animations;if(!e||!A)return this;const i={};return t.forEach((t=>{i[t]=A[t]&&A[t].active()?A[t]._to:this[t]})),i}}function vi(t,e,A,i,s){const a=H(i,0),n=Math.min(H(s,t.length),t.length);let r,o,g,c=0;for(A=Math.ceil(A),s&&(r=s-i,A=r/Math.floor(r/A)),g=a;g<0;)c++,g=Math.round(a+c*A);for(o=Math.max(a,0);o"top"===e||"left"===e?t[e]+A:t[e]-A,Mi=(t,e)=>Math.min(e||t,t);function Gi(t,e){const A=[],i=t.length/e,s=t.length;let a=0;for(;an+r)))return g}function Ui(t){return t.drawTicks?t.tickLength:0}function Hi(t,e){if(!t.display)return 0;const A=we(t.font,e),i=be(t.padding);return(M(t.text)?t.text.length:1)*A.lineHeight+i.height}function Ji(t,e,A){let i=Nt(t);return(A&&"right"!==e||!A&&"right"===e)&&(i=(t=>"left"===t?"right":"right"===t?"left":t)(i)),i}class _i extends Ri{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:A,_suggestedMax:i}=this;return t=U(t,Number.POSITIVE_INFINITY),e=U(e,Number.NEGATIVE_INFINITY),A=U(A,Number.POSITIVE_INFINITY),i=U(i,Number.NEGATIVE_INFINITY),{min:U(t,A),max:U(e,i),minDefined:L(t),maxDefined:L(e)}}getMinMax(t){let e,{min:A,max:i,minDefined:s,maxDefined:a}=this.getUserBounds();if(s&&a)return{min:A,max:i};const n=this.getMatchingVisibleMetas();for(let r=0,o=n.length;ri?i:A,i=s&&A>i?A:i,{min:U(A,U(i,A)),max:U(i,U(A,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){_(this.options.beforeUpdate,[this])}update(t,e,A){const{beginAtZero:i,grace:s,ticks:a}=this.options,n=a.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=A=Object.assign({left:0,right:0,top:0,bottom:0},A),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+A.left+A.right:this.height+A.top+A.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=function(t,e,A){const{min:i,max:s}=t,a=J(e,(s-i)/2),n=(t,e)=>A&&0===t?0:t+e;return{min:n(i,-Math.abs(a)),max:n(s,a)}}(this,s,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=ns)return function(t,e,A,i){let s,a=0,n=A[0];for(i=Math.ceil(i),s=0;st-e)).pop(),e}(i);for(let t=0,e=a.length-1;ts)return e}return Math.max(s,1)}(a,e,s);if(n>0){let t,A;const i=n>1?Math.round((o-r)/(n-1)):null;for(vi(e,g,c,N(i)?0:r-i,r),t=0,A=n-1;t=s||A<=1||!this.isHorizontal())return void(this.labelRotation=i);const g=this._getLabelSizes(),c=g.widest.width,h=g.highest.height,l=yt(this.chart.width-c,0,this.maxWidth);a=t.offset?this.maxWidth/A:l/(A-1),c+6>a&&(a=l/(A-(t.offset?.5:1)),n=this.maxHeight-Ui(t.grid)-e.padding-Hi(t.title,this.chart.options.font),r=Math.sqrt(c*c+h*h),o=Ct(Math.min(Math.asin(yt((g.highest.height+6)/a,-1,1)),Math.asin(yt(n/r,-1,1))-Math.asin(yt(h/r,-1,1)))),o=Math.max(i,Math.min(s,o))),this.labelRotation=o}afterCalculateLabelRotation(){_(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){_(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:A,title:i,grid:s}}=this,a=this._isVisible(),n=this.isHorizontal();if(a){const a=Hi(i,e.options.font);if(n?(t.width=this.maxWidth,t.height=Ui(s)+a):(t.height=this.maxHeight,t.width=Ui(s)+a),A.display&&this.ticks.length){const{first:e,last:i,widest:s,highest:a}=this._getLabelSizes(),r=2*A.padding,o=ut(this.labelRotation),g=Math.cos(o),c=Math.sin(o);if(n){const e=A.mirror?0:c*s.width+g*a.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=A.mirror?0:g*s.width+c*a.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,i,c,g)}}this._handleMargins(),n?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,A,i){const{ticks:{align:s,padding:a},position:n}=this.options,r=0!==this.labelRotation,o="top"!==n&&"x"===this.axis;if(this.isHorizontal()){const n=this.getPixelForTick(0)-this.left,g=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,h=0;r?o?(c=i*t.width,h=A*e.height):(c=A*t.height,h=i*e.width):"start"===s?h=e.width:"end"===s?c=t.width:"inner"!==s&&(c=t.width/2,h=e.width/2),this.paddingLeft=Math.max((c-n+a)*this.width/(this.width-n),0),this.paddingRight=Math.max((h-g+a)*this.width/(this.width-g),0)}else{let A=e.height/2,i=t.height/2;"start"===s?(A=0,i=t.height):"end"===s&&(A=e.height,i=0),this.paddingTop=A+a,this.paddingBottom=i+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){_(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,A;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,A=t.length;e{const A=t.gc,i=A.length/2;let s;if(i>e){for(s=0;s({width:a[t]||0,height:n[t]||0});return{first:y(0),last:y(e-1),widest:y(p),highest:y(m),widths:a,heights:n}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return yt(this._alignToPixels?se(this.chart,e,0):e,-32768,32767)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&tn*i?n/A:r/i:r*i0}_computeGridLineItems(t){const e=this.axis,A=this.chart,i=this.options,{grid:s,position:a,border:n}=i,r=s.offset,o=this.isHorizontal(),g=this.ticks.length+(r?1:0),c=Ui(s),h=[],l=n.setContext(this.getContext()),I=l.display?l.width:0,d=I/2,u=function(t){return se(A,t,I)};let C,B,Q,E,f,p,m,y,b,w,D,k;if("top"===a)C=u(this.bottom),p=this.bottom-c,y=C-d,w=u(t.top)+d,k=t.bottom;else if("bottom"===a)C=u(this.top),w=t.top,k=u(t.bottom)-d,p=C+d,y=this.top+c;else if("left"===a)C=u(this.right),f=this.right-c,m=C-d,b=u(t.left)+d,D=t.right;else if("right"===a)C=u(this.left),b=t.left,D=u(t.right)-d,f=C+d,m=this.left+c;else if("x"===e){if("center"===a)C=u((t.top+t.bottom)/2+.5);else if(G(a)){const t=Object.keys(a)[0],e=a[t];C=u(this.chart.scales[t].getPixelForValue(e))}w=t.top,k=t.bottom,p=C+d,y=p+c}else if("y"===e){if("center"===a)C=u((t.left+t.right)/2);else if(G(a)){const t=Object.keys(a)[0],e=a[t];C=u(this.chart.scales[t].getPixelForValue(e))}f=C-d,m=f-c,b=t.left,D=t.right}const S=H(i.ticks.maxTicksLimit,g),x=Math.max(1,Math.ceil(g/S));for(B=0;B0&&(a-=i/2)}h={left:a,top:s,width:i+e.width,height:A+e.height,color:t.backdropColor}}u.push({label:E,font:b,textOffset:k,options:{rotation:d,color:A,strokeColor:r,strokeWidth:g,textAlign:l,textBaseline:S,translation:[f,p],backdrop:h}})}return u}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-ut(this.labelRotation))return"top"===t?"left":"right";let A="center";return"start"===e.align?A="left":"end"===e.align?A="right":"inner"===e.align&&(A="inner"),A}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:A,mirror:i,padding:s}}=this.options,a=t+s,n=this._getLabelSizes().widest.width;let r,o;return"left"===e?i?(o=this.right+s,"near"===A?r="left":"center"===A?(r="center",o+=n/2):(r="right",o+=n)):(o=this.right-a,"near"===A?r="right":"center"===A?(r="center",o-=n/2):(r="left",o=this.left)):"right"===e?i?(o=this.left+s,"near"===A?r="right":"center"===A?(r="center",o-=n/2):(r="left",o-=n)):(o=this.left+a,"near"===A?r="left":"center"===A?(r="center",o+=n/2):(r="right",o=this.right)):r="right",{textAlign:r,x:o}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:A,top:i,width:s,height:a}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(A,i,s,a),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const A=this.ticks.findIndex((e=>e.value===t));return A>=0?e.setContext(this.getContext(A)).lineWidth:0}drawGrid(t){const e=this.options.grid,A=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let s,a;const n=(t,e,i)=>{i.width&&i.color&&(A.save(),A.lineWidth=i.width,A.strokeStyle=i.color,A.setLineDash(i.borderDash||[]),A.lineDashOffset=i.borderDashOffset,A.beginPath(),A.moveTo(t.x,t.y),A.lineTo(e.x,e.y),A.stroke(),A.restore())};if(e.display)for(s=0,a=i.length;s{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),A=this.axis+"AxisID",i=[];let s,a;for(s=0,a=e.length;s{const i=A.split("."),s=i.pop(),a=[t].concat(i).join("."),n=e[A].split("."),r=n.pop(),o=n.join(".");ee.route(a,s,o,r)}))}(e,t.defaultRoutes),t.descriptors&&ee.describe(e,t.descriptors)}(t,a,A),this.override&&ee.override(t.id,t.overrides)),a}get(t){return this.items[t]}unregister(t){const e=this.items,A=t.id,i=this.scope;A in e&&delete e[A],i&&A in ee[i]&&(delete ee[i][A],this.override&&delete Zt[A])}}class Ti{constructor(){this.controllers=new Yi(GA,"datasets",!0),this.elements=new Yi(Ri,"elements"),this.plugins=new Yi(Object,"plugins"),this.scales=new Yi(_i,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,A){[...e].forEach((e=>{const i=A||this._getRegistryForType(e);A||i.isForType(e)||i===this.plugins&&e.id?this._exec(t,i,e):Y(e,(e=>{const i=A||this._getRegistryForType(e);this._exec(t,i,e)}))}))}_exec(t,e,A){const i=X(t);_(A["before"+i],[],A),e[t](A),_(A["after"+i],[],A)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(i(e,A),t,"stop"),this._notify(i(A,e),t,"start")}}function qi(t,e){return e||!1!==t?!0===t?{}:t:null}function Oi(t,{plugin:e,local:A},i,s){const a=t.pluginScopeKeys(e),n=t.getOptionScopes(i,a);return A&&e.defaults&&n.push(e.defaults),t.createResolver(n,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Wi(t,e){const A=ee.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||A.indexAxis||"x"}function ji(t){if("x"===t||"y"===t||"r"===t)return t}function Vi(t,...e){if(ji(t))return t;for(const i of e){const e=i.axis||("top"===(A=i.position)||"bottom"===A?"x":"left"===A||"right"===A?"y":void 0)||t.length>1&&ji(t[0].toLowerCase());if(e)return e}var A;throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function Zi(t,e,A){if(A[e+"AxisID"]===t)return{axis:e}}function Xi(t){const e=t.options||(t.options={});e.plugins=H(e.plugins,{}),e.scales=function(t,e){const A=Zt[t.type]||{scales:{}},i=e.scales||{},s=Wi(t.type,e),a=Object.create(null);return Object.keys(i).forEach((e=>{const n=i[e];if(!G(n))return console.error(`Invalid scale configuration for scale: ${e}`);if(n._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${e}`);const r=Vi(e,n,function(t,e){if(e.data&&e.data.datasets){const A=e.data.datasets.filter((e=>e.xAxisID===t||e.yAxisID===t));if(A.length)return Zi(t,"x",A[0])||Zi(t,"y",A[0])}return{}}(e,t),ee.scales[n.type]),o=function(t,e){return t===e?"_index_":"_value_"}(r,s),g=A.scales||{};a[e]=W(Object.create(null),[{axis:r},n,g[r],g[o]])})),t.data.datasets.forEach((A=>{const s=A.type||t.type,n=A.indexAxis||Wi(s,e),r=(Zt[s]||{}).scales||{};Object.keys(r).forEach((t=>{const e=function(t,e){let A=t;return"_index_"===t?A=e:"_value_"===t&&(A="x"===e?"y":"x"),A}(t,n),s=A[e+"AxisID"]||e;a[s]=a[s]||Object.create(null),W(a[s],[{axis:e},i[s],r[t]])}))})),Object.keys(a).forEach((t=>{const e=a[t];W(e,[ee.scales[e.type],ee.scale])})),a}(t,e)}function zi(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const $i=new Map,ts=new Set;function es(t,e){let A=$i.get(t);return A||(A=e(),$i.set(t,A),ts.add(A)),A}const As=(t,e,A)=>{const i=Z(e,A);void 0!==i&&t.add(i)};class is{constructor(t){this._config=function(t){return(t=t||{}).data=zi(t.data),Xi(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=zi(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Xi(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return es(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return es(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return es(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return es(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const A=this._scopeCache;let i=A.get(t);return i&&!e||(i=new Map,A.set(t,i)),i}getOptionScopes(t,e,A){const{options:i,type:s}=this,a=this._cachedScopes(t,A),n=a.get(e);if(n)return n;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>As(r,t,e)))),e.forEach((t=>As(r,i,t))),e.forEach((t=>As(r,Zt[s]||{},t))),e.forEach((t=>As(r,ee,t))),e.forEach((t=>As(r,Xt,t)))}));const o=Array.from(r);return 0===o.length&&o.push(Object.create(null)),ts.has(e)&&a.set(e,o),o}chartOptionScopes(){const{options:t,type:e}=this;return[t,Zt[e]||{},ee.datasets[e]||{},{type:e},ee,Xt]}resolveNamedOptions(t,e,A,i=[""]){const s={$shared:!0},{resolver:a,subPrefixes:n}=ss(this._resolverCache,t,i);let r=a;(function(t,e){const{isScriptable:A,isIndexable:i}=Fe(t);for(const s of e){const e=A(s),a=i(s),n=(a||e)&&t[s];if(e&&($(n)||as(n))||a&&M(n))return!0}return!1})(a,e)&&(s.$shared=!1,r=xe(a,A=$(A)?A():A,this.createResolver(t,A,n)));for(const t of e)s[t]=r[t];return s}createResolver(t,e,A=[""],i){const{resolver:s}=ss(this._resolverCache,t,A);return G(e)?xe(s,e,void 0,i):s}}function ss(t,e,A){let i=t.get(e);i||(i=new Map,t.set(e,i));const s=A.join();let a=i.get(s);return a||(a={resolver:Se(e,A),subPrefixes:A.filter((t=>!t.toLowerCase().includes("hover")))},i.set(s,a)),a}const as=t=>G(t)&&Object.getOwnPropertyNames(t).some((e=>$(t[e]))),ns=["top","bottom","left","right","chartArea"];function rs(t,e){return"top"===t||"bottom"===t||-1===ns.indexOf(t)&&"x"===e}function os(t,e){return function(A,i){return A[t]===i[t]?A[e]-i[e]:A[t]-i[t]}}function gs(t){const e=t.chart,A=e.options.animation;e.notifyPlugins("afterRender"),_(A&&A.onComplete,[t],e)}function cs(t){const e=t.chart,A=e.options.animation;_(A&&A.onProgress,[t],e)}function hs(t){return je()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const ls={},Is=t=>{const e=hs(t);return Object.values(ls).filter((t=>t.canvas===e)).pop()};function ds(t,e,A){const i=Object.keys(t);for(const s of i){const i=+s;if(i>=e){const a=t[s];delete t[s],(A>0||i>e)&&(t[i+A]=a)}}}function us(t,e,A){return t.options.clip?t[A]:e[A]}class Cs{static defaults=ee;static instances=ls;static overrides=Zt;static registry=Pi;static version="4.4.3";static getChart=Is;static register(...t){Pi.add(...t),Bs()}static unregister(...t){Pi.remove(...t),Bs()}constructor(t,e){const A=this.config=new is(e),i=hs(t),s=Is(i);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas with ID '"+s.canvas.id+"' can be reused.");const a=A.createResolver(A.chartOptionScopes(),this.getContext());this.platform=new(A.platform||function(t){return!je()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?ui:Fi}(i)),this.platform.updateConfig(A);const n=this.platform.acquireContext(i,a.aspectRatio),r=n&&n.canvas,o=r&&r.height,g=r&&r.width;this.id=v(),this.ctx=n,this.canvas=r,this.width=g,this.height=o,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Ki,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=function(t,e){let A;return function(...i){return e?(clearTimeout(A),A=setTimeout(t,e,i)):t.apply(this,i),e}}((t=>this.update(t)),a.resizeDelay||0),this._dataChanges=[],ls[this.id]=this,n&&r?(EA.listen(this,"complete",gs),EA.listen(this,"progress",cs),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:A,height:i,_aspectRatio:s}=this;return N(t)?e&&s?s:i?A/i:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Pi}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():iA(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return ae(this.canvas,this.ctx),this}stop(){return EA.stop(this),this}resize(t,e){EA.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const A=this.options,i=this.canvas,s=A.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(i,t,e,s),n=A.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,iA(this,n,!0)&&(this.notifyPlugins("resize",{size:a}),_(A.onResize,[this,a],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){Y(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,A=this.scales,i=Object.keys(A).reduce(((t,e)=>(t[e]=!1,t)),{});let s=[];e&&(s=s.concat(Object.keys(e).map((t=>{const A=e[t],i=Vi(t,A),s="r"===i,a="x"===i;return{options:A,dposition:s?"chartArea":a?"bottom":"left",dtype:s?"radialLinear":a?"category":"linear"}})))),Y(s,(e=>{const s=e.options,a=s.id,n=Vi(a,s),r=H(s.type,e.dtype);void 0!==s.position&&rs(s.position,n)===rs(e.dposition)||(s.position=e.dposition),i[a]=!0;let o=null;a in A&&A[a].type===r?o=A[a]:(o=new(Pi.getScale(r))({id:a,type:r,ctx:this.ctx,chart:this}),A[o.id]=o),o.init(s,t)})),Y(i,((t,e)=>{t||delete A[e]})),Y(A,(t=>{Ii.configure(this,t,t.options),Ii.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,A=t.length;if(t.sort(((t,e)=>t.index-e.index)),A>e){for(let t=e;te.length&&delete this._stacks,t.forEach(((t,A)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(A)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let A,i;for(this._removeUnreferencedMetasets(),A=0,i=e.length;A{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const A=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!A.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const s=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let a=0;for(let t=0,e=this.data.datasets.length;t{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(os("z","_idx"));const{_active:n,_lastEvent:r}=this;r?this._eventHandler(r,!0):n.length&&this._updateHoverStyles(n,n,!0),this.render()}_updateScales(){Y(this.scales,(t=>{Ii.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),A=new Set(t.events);tt(e,A)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:A,start:i,count:s}of e)ds(t,i,"_removeElements"===A?-s:s)}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,A=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),i=A(0);for(let t=1;tt.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;Ii.update(this,this.width,this.height,t);const e=this.chartArea,A=e.width<=0||e.height<=0;this._layers=[],Y(this.boxes,(t=>{A&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,A=t._clip,i=!A.disabled,s=function(t,e){const{xScale:A,yScale:i}=t;return A&&i?{left:us(A,e,"left"),right:us(A,e,"right"),top:us(i,e,"top"),bottom:us(i,e,"bottom")}:e}(t,this.chartArea),a={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",a)&&(i&&ge(e,{left:!1===A.left?0:s.left-A.left,right:!1===A.right?this.width:s.right+A.right,top:!1===A.top?0:s.top-A.top,bottom:!1===A.bottom?this.height:s.bottom+A.bottom}),t.controller.draw(),i&&ce(e),a.cancelable=!1,this.notifyPlugins("afterDatasetDraw",a))}isPointInArea(t){return oe(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,A,i){const s=ei.modes[e];return"function"==typeof s?s(this,t,A,i):[]}getDatasetMeta(t){const e=this.data.datasets[t],A=this._metasets;let i=A.filter((t=>t&&t._dataset===e)).pop();return i||(i={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},A.push(i)),i}getContext(){return this.$context||(this.$context=ke(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const A=this.getDatasetMeta(t);return"boolean"==typeof A.hidden?!A.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,A){const i=A?"show":"hide",s=this.getDatasetMeta(t),a=s.controller._resolveAnimations(void 0,i);z(e)?(s.data[e].hidden=!A,this.update()):(this.setDatasetVisibility(t,A),a.update(s,{visible:A}),this.update((e=>e.datasetIndex===t?i:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),EA.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,A,i),t[A]=i},i=(t,e,A)=>{t.offsetX=e,t.offsetY=A,this._eventHandler(t)};Y(this.options.events,(t=>A(t,i)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,A=(A,i)=>{e.addEventListener(this,A,i),t[A]=i},i=(A,i)=>{t[A]&&(e.removeEventListener(this,A,i),delete t[A])},s=(t,e)=>{this.canvas&&this.resize(t,e)};let a;const n=()=>{i("attach",n),this.attached=!0,this.resize(),A("resize",s),A("detach",a)};a=()=>{this.attached=!1,i("resize",s),this._stop(),this._resize(0,0),A("attach",n)},e.isAttached(this.canvas)?n():a()}unbindEvents(){Y(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},Y(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,A){const i=A?"set":"remove";let s,a,n,r;for("dataset"===e&&(s=this.getDatasetMeta(t[0].datasetIndex),s.controller["_"+i+"DatasetHoverStyle"]()),n=0,r=t.length;n{const A=this.getDatasetMeta(t);if(!A)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:A.data[e],index:e}}));!T(A,e)&&(this._active=A,this._lastEvent=null,this._updateHoverStyles(A,e))}notifyPlugins(t,e,A){return this._plugins.notify(this,t,e,A)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,A){const i=this.options.hover,s=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),a=s(e,t),n=A?t:s(t,e);a.length&&this.updateHoverStyle(a,i.mode,!1),n.length&&i.mode&&this.updateHoverStyle(n,i.mode,!0)}_eventHandler(t,e){const A={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},i=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",A,i))return;const s=this._handleEvent(t,e,A.inChartArea);return A.cancelable=!1,this.notifyPlugins("afterEvent",A,i),(s||A.changed)&&this.render(),this}_handleEvent(t,e,A){const{_active:i=[],options:s}=this,a=e,n=this._getActiveElements(t,i,A,a),r=function(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}(t),o=function(t,e,A,i){return A&&"mouseout"!==t.type?i?e:t:null}(t,this._lastEvent,A,r);A&&(this._lastEvent=null,_(s.onHover,[t,n,this],this),r&&_(s.onClick,[t,n,this],this));const g=!T(n,i);return(g||e)&&(this._active=n,this._updateHoverStyles(n,i,e)),this._lastEvent=o,g}_getActiveElements(t,e,A,i){if("mouseout"===t.type)return[];if(!A)return e;const s=this.options.hover;return this.getElementsAtEventForMode(t,s.mode,s,i)}}function Bs(){return Y(Cs.instances,(t=>t._plugins.invalidate()))}function Qs(t,e,A,i){return{x:A+t*Math.cos(e),y:i+t*Math.sin(e)}}function Es(t,e,A,i,s,a){const{x:n,y:r,startAngle:o,pixelMargin:g,innerRadius:c}=e,h=Math.max(e.outerRadius+i+A-g,0),l=c>0?c+i+A+g:0;let I=0;const d=s-o;if(i){const t=((c>0?c-i:0)+(h>0?h-i:0))/2;I=(d-(0!==t?d*t/(t+i):d))/2}const u=(d-Math.max(.001,d*h-A/et)/h)/2,C=o+u+I,B=s-u-I,{outerStart:Q,outerEnd:E,innerStart:f,innerEnd:p}=function(t,e,A,i){const s=pe(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]),a=(A-e)/2,n=Math.min(a,i*e/2),r=t=>{const e=(A-Math.min(a,t))*i/2;return yt(t,0,Math.min(a,e))};return{outerStart:r(s.outerStart),outerEnd:r(s.outerEnd),innerStart:yt(s.innerStart,0,n),innerEnd:yt(s.innerEnd,0,n)}}(e,l,h,B-C),m=h-Q,y=h-E,b=C+Q/m,w=B-E/y,D=l+f,k=l+p,S=C+f/D,x=B-p/k;if(t.beginPath(),a){const e=(b+w)/2;if(t.arc(n,r,h,b,e),t.arc(n,r,h,e,w),E>0){const e=Qs(y,w,n,r);t.arc(e.x,e.y,E,w,B+nt)}const A=Qs(k,B,n,r);if(t.lineTo(A.x,A.y),p>0){const e=Qs(k,x,n,r);t.arc(e.x,e.y,p,B+nt,x+Math.PI)}const i=(B-p/l+(C+f/l))/2;if(t.arc(n,r,l,B-p/l,i,!0),t.arc(n,r,l,i,C+f/l,!0),f>0){const e=Qs(D,S,n,r);t.arc(e.x,e.y,f,S+Math.PI,C-nt)}const s=Qs(m,C,n,r);if(t.lineTo(s.x,s.y),Q>0){const e=Qs(m,b,n,r);t.arc(e.x,e.y,Q,C-nt,b)}}else{t.moveTo(n,r);const e=Math.cos(b)*h+n,A=Math.sin(b)*h+r;t.lineTo(e,A);const i=Math.cos(w)*h+n,s=Math.sin(w)*h+r;t.lineTo(i,s)}t.closePath()}function fs(t,e,A=e){t.lineCap=H(A.borderCapStyle,e.borderCapStyle),t.setLineDash(H(A.borderDash,e.borderDash)),t.lineDashOffset=H(A.borderDashOffset,e.borderDashOffset),t.lineJoin=H(A.borderJoinStyle,e.borderJoinStyle),t.lineWidth=H(A.borderWidth,e.borderWidth),t.strokeStyle=H(A.borderColor,e.borderColor)}function ps(t,e,A){t.lineTo(A.x,A.y)}function ms(t,e,A={}){const i=t.length,{start:s=0,end:a=i-1}=A,{start:n,end:r}=e,o=Math.max(s,n),g=Math.min(a,r),c=sr&&a>r;return{count:i,start:o,loop:e.loop,ilen:g(n+(g?r-t:t))%a,E=()=>{I!==d&&(t.lineTo(C,d),t.lineTo(C,I),t.lineTo(C,u))};for(o&&(h=s[Q(0)],t.moveTo(h.x,h.y)),c=0;c<=r;++c){if(h=s[Q(c)],h.skip)continue;const e=h.x,A=h.y,i=0|e;i===l?(Ad&&(d=A),C=(B*C+e)/++B):(E(),t.lineTo(e,A),l=i,B=0,I=d=A),u=A}E()}function ws(t){const e=t.options,A=e.borderDash&&e.borderDash.length;return t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||A?ys:bs}const Ds="function"==typeof Path2D;class ks extends Ri{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t&&"fill"!==t};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const A=this.options;if((A.tension||"monotone"===A.cubicInterpolationMode)&&!A.stepped&&!this._pointsUpdated){const i=A.spanGaps?this._loop:this._fullLoop;We(this._points,A,t,i,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=function(t,e){const A=t.points,i=t.options.spanGaps,s=A.length;if(!s)return[];const a=!!t._loop,{start:n,end:r}=function(t,e,A,i){let s=0,a=e-1;if(A&&!i)for(;ss&&t[a%e].skip;)a--;return a%=e,{start:s,end:a}}(A,s,a,i);return function(t,e,A,i){return i&&i.setContext&&A?function(t,e,A,i){const s=t._chart.getContext(),a=CA(t.options),{_datasetIndex:n,options:{spanGaps:r}}=t,o=A.length,g=[];let c=a,h=e[0].start,l=h;function I(t,e,i,s){const a=r?-1:1;if(t!==e){for(t+=o;A[t%o].skip;)t-=a;for(;A[e%o].skip;)e+=a;t%o!=e%o&&(g.push({start:t%o,end:e%o,loop:i,style:s}),c=s,h=e%o)}}for(const t of e){h=r?h:t.start;let e,a=A[h%o];for(l=h+1;l<=t.end;l++){const r=A[l%o];e=CA(i.setContext(ke(s,{type:"segment",p0:a,p1:r,p0DataIndex:(l-1)%o,p1DataIndex:l%o,datasetIndex:n}))),BA(e,c)&&I(h,l-1,t.loop,c),a=r,c=e}h"borderDash"!==t};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,A){const i=this.getProps(["x","y"],A),{angle:s,distance:a}=Qt(i,{x:t,y:e}),{startAngle:n,endAngle:r,innerRadius:o,outerRadius:g,circumference:c}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],A),h=(this.options.spacing+this.options.borderWidth)/2,l=H(c,r-n)>=At||mt(s,n,r),I=bt(a,o+h,g+h);return l&&I}getCenterPoint(t){const{x:e,y:A,startAngle:i,endAngle:s,innerRadius:a,outerRadius:n}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:r,spacing:o}=this.options,g=(i+s)/2,c=(a+n+o+r)/2;return{x:e+Math.cos(g)*c,y:A+Math.sin(g)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:A}=this,i=(e.offset||0)/4,s=(e.spacing||0)/2,a=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=A>At?Math.floor(A/At):0,0===A||this.innerRadius<0||this.outerRadius<0)return;t.save();const n=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(n)*i,Math.sin(n)*i);const r=i*(1-Math.sin(Math.min(et,A||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,function(t,e,A,i,s){const{fullCircles:a,startAngle:n,circumference:r}=e;let o=e.endAngle;if(a){Es(t,e,A,i,o,s);for(let e=0;es?(g=s/o,t.arc(a,n,o,A+g,i-g,!0)):t.arc(a,n,s,A+nt,i-nt),t.closePath(),t.clip()}(t,e,d),a||(Es(t,e,A,i,d,s),t.stroke())}(t,this,r,s,a),t.restore()}},BarElement:class extends Ri{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:A,backgroundColor:i}}=this,{inner:s,outer:a}=function(t){const e=xs(t),A=e.right-e.left,i=e.bottom-e.top,s=function(t,e,A){const i=t.options.borderWidth,s=t.borderSkipped,a=me(i);return{t:Fs(s.top,a.top,0,A),r:Fs(s.right,a.right,0,e),b:Fs(s.bottom,a.bottom,0,A),l:Fs(s.left,a.left,0,e)}}(t,A/2,i/2),a=function(t,e,A){const{enableBorderRadius:i}=t.getProps(["enableBorderRadius"]),s=t.options.borderRadius,a=ye(s),n=Math.min(e,A),r=t.borderSkipped,o=i||G(s);return{topLeft:Fs(!o||r.top||r.left,a.topLeft,0,n),topRight:Fs(!o||r.top||r.right,a.topRight,0,n),bottomLeft:Fs(!o||r.bottom||r.left,a.bottomLeft,0,n),bottomRight:Fs(!o||r.bottom||r.right,a.bottomRight,0,n)}}(t,A/2,i/2);return{outer:{x:e.left,y:e.top,w:A,h:i,radius:a},inner:{x:e.left+s.l,y:e.top+s.t,w:A-s.l-s.r,h:i-s.t-s.b,radius:{topLeft:Math.max(0,a.topLeft-Math.max(s.t,s.l)),topRight:Math.max(0,a.topRight-Math.max(s.t,s.r)),bottomLeft:Math.max(0,a.bottomLeft-Math.max(s.b,s.l)),bottomRight:Math.max(0,a.bottomRight-Math.max(s.b,s.r))}}}}(this),n=(r=a.radius).topLeft||r.topRight||r.bottomLeft||r.bottomRight?Ce:vs;var r;t.save(),a.w===s.w&&a.h===s.h||(t.beginPath(),n(t,Ns(a,e,s)),t.clip(),n(t,Ns(s,-e,a)),t.fillStyle=A,t.fill("evenodd")),t.beginPath(),n(t,Ns(s,e)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,e,A){return Rs(this,t,e,A)}inXRange(t,e){return Rs(this,t,null,e)}inYRange(t,e){return Rs(this,null,t,e)}getCenterPoint(t){const{x:e,y:A,base:i,horizontal:s}=this.getProps(["x","y","base","horizontal"],t);return{x:s?(e+i)/2:e,y:s?A:(A+i)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}},LineElement:ks,PointElement:class extends Ri{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,A){const i=this.options,{x:s,y:a}=this.getProps(["x","y"],A);return Math.pow(t-s,2)+Math.pow(e-a,2)t.replace("rgb(","rgba(").replace(")",", 0.5)")));function Us(t){return Gs[t%Gs.length]}function Hs(t){return Ls[t%Ls.length]}function Js(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}var _s={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,A){if(!A.enabled)return;const{data:{datasets:i},options:s}=t.config,{elements:a}=s;if(!A.forceOverride&&(Js(i)||(n=s)&&(n.borderColor||n.backgroundColor)||a&&Js(a)))return;var n;const r=function(t){let e=0;return(A,i)=>{const s=t.getDatasetMeta(i).controller;s instanceof KA?e=function(t,e){return t.backgroundColor=t.data.map((()=>Us(e++))),e}(A,e):s instanceof qA?e=function(t,e){return t.backgroundColor=t.data.map((()=>Hs(e++))),e}(A,e):s&&(e=function(t,e){return t.borderColor=Us(e),t.backgroundColor=Hs(e),++e}(A,e))}}(t);i.forEach(r)}};function Ys(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function Ts(t){t.data.datasets.forEach((t=>{Ys(t)}))}var Ps={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,A)=>{if(!A.enabled)return void Ts(t);const i=t.width;t.data.datasets.forEach(((e,s)=>{const{_data:a,indexAxis:n}=e,r=t.getDatasetMeta(s),o=a||e.data;if("y"===De([n,t.options.indexAxis]))return;if(!r.controller.supportsDecimation)return;const g=t.scales[r.xAxisID];if("linear"!==g.type&&"time"!==g.type)return;if(t.options.parsing)return;let c,{start:h,count:l}=function(t,e){const A=e.length;let i,s=0;const{iScale:a}=t,{min:n,max:r,minDefined:o,maxDefined:g}=a.getUserBounds();return o&&(s=yt(Dt(e,a.axis,n).lo,0,A-1)),i=g?yt(Dt(e,a.axis,r).hi+1,s,A)-s:A-s,{start:s,count:i}}(r,o);if(l<=(A.threshold||4*i))Ys(e);else{switch(N(a)&&(e._data=o,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),A.algorithm){case"lttb":c=function(t,e,A,i,s){const a=s.samples||i;if(a>=A)return t.slice(e,e+A);const n=[],r=(A-2)/(a-2);let o=0;const g=e+A-1;let c,h,l,I,d,u=e;for(n[o++]=t[u],c=0;cl&&(l=I,h=t[i],d=i);n[o++]=h,u=d}return n[o++]=t[g],n}(o,h,l,i,A);break;case"min-max":c=function(t,e,A,i){let s,a,n,r,o,g,c,h,l,I,d=0,u=0;const C=[],B=e+A-1,Q=t[e].x,E=t[B].x-Q;for(s=e;sI&&(I=r,c=s),d=(u*d+a.x)/++u;else{const A=s-1;if(!N(g)&&!N(c)){const e=Math.min(g,c),i=Math.max(g,c);e!==h&&e!==A&&C.push({...t[e],x:d}),i!==h&&i!==A&&C.push({...t[i],x:d})}s>0&&A!==h&&C.push(t[A]),C.push(a),o=e,u=0,l=I=r,g=c=h=s}}return C}(o,h,l,i);break;default:throw new Error(`Unsupported decimation algorithm '${A.algorithm}'`)}e._decimated=c}}))},destroy(t){Ts(t)}};function Ks(t,e,A,i){if(i)return;let s=e[t],a=A[t];return"angle"===t&&(s=pt(s),a=pt(a)),{property:t,start:s,end:a}}function qs(t,e,A){for(;e>t;e--){const t=A[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function Os(t,e,A,i){return t&&e?i(t[A],e[A]):t?t[A]:e?e[A]:0}function Ws(t,e){let A=[],i=!1;return M(t)?(i=!0,A=t):A=function(t,e){const{x:A=null,y:i=null}=t||{},s=e.points,a=[];return e.segments.forEach((({start:t,end:e})=>{e=qs(t,e,s);const n=s[t],r=s[e];null!==i?(a.push({x:n.x,y:i}),a.push({x:r.x,y:i})):null!==A&&(a.push({x:A,y:n.y}),a.push({x:A,y:r.y}))})),a}(t,e),A.length?new ks({points:A,options:{tension:0},_loop:i,_fullLoop:i}):null}function js(t){return t&&!1!==t.fill}function Vs(t,e,A){let i=t[e].fill;const s=[e];let a;if(!A)return i;for(;!1!==i&&-1===s.indexOf(i);){if(!L(i))return i;if(a=t[i],!a)return!1;if(a.visible)return i;s.push(i),i=a.fill}return!1}function Zs(t,e,A){const i=function(t){const e=t.options,A=e.fill;let i=H(A&&A.target,A);return void 0===i&&(i=!!e.backgroundColor),!1!==i&&null!==i&&(!0===i?"origin":i)}(t);if(G(i))return!isNaN(i.value)&&i;let s=parseFloat(i);return L(s)&&Math.floor(s)===s?function(t,e,A,i){return"-"!==t&&"+"!==t||(A=e+A),!(A===e||A<0||A>=i)&&A}(i[0],e,s,A):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function Xs(t,e,A){const i=[];for(let s=0;s=0;--e){const A=s[e].$filler;A&&(A.line.updateControlPoints(a,A.axis),i&&A.fill&&ta(t.ctx,A,a))}},beforeDatasetsDraw(t,e,A){if("beforeDatasetsDraw"!==A.drawTime)return;const i=t.getSortedVisibleDatasetMetas();for(let e=i.length-1;e>=0;--e){const A=i[e].$filler;js(A)&&ta(t.ctx,A,t.chartArea)}},beforeDatasetDraw(t,e,A){const i=e.meta.$filler;js(i)&&"beforeDatasetDraw"===A.drawTime&&ta(t.ctx,i,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const na=(t,e)=>{let{boxHeight:A=e,boxWidth:i=e}=t;return t.usePointStyle&&(A=Math.min(A,e),i=t.pointStyleWidth||Math.min(i,e)),{boxWidth:i,boxHeight:A,itemHeight:Math.max(e,A)}};class ra extends Ri{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,A){this.maxWidth=t,this.maxHeight=e,this._margins=A,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=_(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,A)=>t.sort(e,A,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const A=t.labels,i=we(A.font),s=i.size,a=this._computeTitleHeight(),{boxWidth:n,itemHeight:r}=na(A,s);let o,g;e.font=i.string,this.isHorizontal()?(o=this.maxWidth,g=this._fitRows(a,s,n,r)+10):(g=this.maxHeight,o=this._fitCols(a,i,n,r)+10),this.width=Math.min(o,t.maxWidth||this.maxWidth),this.height=Math.min(g,t.maxHeight||this.maxHeight)}_fitRows(t,e,A,i){const{ctx:s,maxWidth:a,options:{labels:{padding:n}}}=this,r=this.legendHitBoxes=[],o=this.lineWidths=[0],g=i+n;let c=t;s.textAlign="left",s.textBaseline="middle";let h=-1,l=-g;return this.legendItems.forEach(((t,I)=>{const d=A+e/2+s.measureText(t.text).width;(0===I||o[o.length-1]+d+2*n>a)&&(c+=g,o[o.length-(I>0?0:1)]=0,l+=g,h++),r[I]={left:0,top:l,row:h,width:d,height:i},o[o.length-1]+=d+n})),c}_fitCols(t,e,A,i){const{ctx:s,maxHeight:a,options:{labels:{padding:n}}}=this,r=this.legendHitBoxes=[],o=this.columnSizes=[],g=a-t;let c=n,h=0,l=0,I=0,d=0;return this.legendItems.forEach(((t,a)=>{const{itemWidth:u,itemHeight:C}=function(t,e,A,i,s){const a=function(t,e,A,i){let s=t.text;return s&&"string"!=typeof s&&(s=s.reduce(((t,e)=>t.length>e.length?t:e))),e+A.size/2+i.measureText(s).width}(i,t,e,A),n=function(t,e,A){let i=t;return"string"!=typeof e.text&&(i=oa(e,A)),i}(s,i,e.lineHeight);return{itemWidth:a,itemHeight:n}}(A,e,s,t,i);a>0&&l+C+2*n>g&&(c+=h+n,o.push({width:h,height:l}),I+=h+n,d++,h=l=0),r[a]={left:I,top:l,col:d,width:u,height:C},h=Math.max(h,u),l+=C+n})),c+=h,o.push({width:h,height:l}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:A,labels:{padding:i},rtl:s}}=this,a=gA(s,this.left,this.width);if(this.isHorizontal()){let s=0,n=Mt(A,this.left+i,this.right-this.lineWidths[s]);for(const r of e)s!==r.row&&(s=r.row,n=Mt(A,this.left+i,this.right-this.lineWidths[s])),r.top+=this.top+t+i,r.left=a.leftForLtr(a.x(n),r.width),n+=r.width+i}else{let s=0,n=Mt(A,this.top+t+i,this.bottom-this.columnSizes[s].height);for(const r of e)r.col!==s&&(s=r.col,n=Mt(A,this.top+t+i,this.bottom-this.columnSizes[s].height)),r.top=n,r.left+=this.left+i,r.left=a.leftForLtr(a.x(r.left),r.width),n+=r.height+i}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;ge(t,this),this._draw(),ce(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:A,ctx:i}=this,{align:s,labels:a}=t,n=ee.color,r=gA(t.rtl,this.left,this.width),o=we(a.font),{padding:g}=a,c=o.size,h=c/2;let l;this.drawTitle(),i.textAlign=r.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=o.string;const{boxWidth:I,boxHeight:d,itemHeight:u}=na(a,c),C=this.isHorizontal(),B=this._computeTitleHeight();l=C?{x:Mt(s,this.left+g,this.right-A[0]),y:this.top+g+B,line:0}:{x:this.left+g,y:Mt(s,this.top+B+g,this.bottom-e[0].height),line:0},cA(this.ctx,t.textDirection);const Q=u+g;this.legendItems.forEach(((E,f)=>{i.strokeStyle=E.fontColor,i.fillStyle=E.fontColor;const p=i.measureText(E.text).width,m=r.textAlign(E.textAlign||(E.textAlign=a.textAlign)),y=I+h+p;let b=l.x,w=l.y;if(r.setWidth(this.width),C?f>0&&b+y+g>this.right&&(w=l.y+=Q,l.line++,b=l.x=Mt(s,this.left+g,this.right-A[l.line])):f>0&&w+Q>this.bottom&&(b=l.x=b+e[l.line].width+g,l.line++,w=l.y=Mt(s,this.top+B+g,this.bottom-e[l.line].height)),function(t,e,A){if(isNaN(I)||I<=0||isNaN(d)||d<0)return;i.save();const s=H(A.lineWidth,1);if(i.fillStyle=H(A.fillStyle,n),i.lineCap=H(A.lineCap,"butt"),i.lineDashOffset=H(A.lineDashOffset,0),i.lineJoin=H(A.lineJoin,"miter"),i.lineWidth=s,i.strokeStyle=H(A.strokeStyle,n),i.setLineDash(H(A.lineDash,[])),a.usePointStyle){const n={radius:d*Math.SQRT2/2,pointStyle:A.pointStyle,rotation:A.rotation,borderWidth:s},o=r.xPlus(t,I/2);re(i,n,o,e+h,a.pointStyleWidth&&I)}else{const a=e+Math.max((c-d)/2,0),n=r.leftForLtr(t,I),o=ye(A.borderRadius);i.beginPath(),Object.values(o).some((t=>0!==t))?Ce(i,{x:n,y:a,w:I,h:d,radius:o}):i.rect(n,a,I,d),i.fill(),0!==s&&i.stroke()}i.restore()}(r.x(b),w,E),b=((t,e,A,i)=>t===(i?"left":"right")?A:"center"===t?(e+A)/2:e)(m,b+I+h,C?b+y:this.right,t.rtl),function(t,e,A){ue(i,A.text,t,e+u/2,o,{strikethrough:A.hidden,textAlign:r.textAlign(A.textAlign)})}(r.x(b),w,E),C)l.x+=y+g;else if("string"!=typeof E.text){const t=o.lineHeight;l.y+=oa(E,t)+g}else l.y+=Q})),hA(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,A=we(e.font),i=be(e.padding);if(!e.display)return;const s=gA(t.rtl,this.left,this.width),a=this.ctx,n=e.position,r=A.size/2,o=i.top+r;let g,c=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),g=this.top+o,c=Mt(t.align,c,this.right-h);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);g=o+Mt(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const l=Mt(n,c,c+h);a.textAlign=s.textAlign(Nt(n)),a.textBaseline="middle",a.strokeStyle=e.color,a.fillStyle=e.color,a.font=A.string,ue(a,e.text,l,g,A)}_computeTitleHeight(){const t=this.options.title,e=we(t.font),A=be(t.padding);return t.display?e.lineHeight+A.height:0}_getLegendItemAt(t,e){let A,i,s;if(bt(t,this.left,this.right)&&bt(e,this.top,this.bottom))for(s=this.legendHitBoxes,A=0;Anull!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index)(i,A);i&&!s&&_(e.onLeave,[t,i,this],this),this._hoveredItem=A,A&&!s&&_(e.onHover,[t,A,this],this)}else A&&_(e.onClick,[t,A,this],this)}}function oa(t,e){return e*(t.text?t.text.length:0)}var ga={id:"legend",_element:ra,start(t,e,A){const i=t.legend=new ra({ctx:t.ctx,options:A,chart:t});Ii.configure(t,i,A),Ii.addBox(t,i)},stop(t){Ii.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,A){const i=t.legend;Ii.configure(t,i,A),i.options=A},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,A){const i=e.datasetIndex,s=A.chart;s.isDatasetVisible(i)?(s.hide(i),e.hidden=!0):(s.show(i),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:A,pointStyle:i,textAlign:s,color:a,useBorderRadius:n,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const o=t.controller.getStyle(A?0:void 0),g=be(o.borderWidth);return{text:e[t.index].label,fillStyle:o.backgroundColor,fontColor:a,hidden:!t.visible,lineCap:o.borderCapStyle,lineDash:o.borderDash,lineDashOffset:o.borderDashOffset,lineJoin:o.borderJoinStyle,lineWidth:(g.width+g.height)/4,strokeStyle:o.borderColor,pointStyle:i||o.pointStyle,rotation:o.rotation,textAlign:s||o.textAlign,borderRadius:n&&(r||o.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class ca extends Ri{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const A=this.options;if(this.left=0,this.top=0,!A.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const i=M(A.text)?A.text.length:1;this._padding=be(A.padding);const s=i*we(A.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=s:this.width=s}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:A,bottom:i,right:s,options:a}=this,n=a.align;let r,o,g,c=0;return this.isHorizontal()?(o=Mt(n,A,s),g=e+t,r=s-A):("left"===a.position?(o=A+t,g=Mt(n,i,e),c=-.5*et):(o=s-t,g=Mt(n,e,i),c=.5*et),r=i-e),{titleX:o,titleY:g,maxWidth:r,rotation:c}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const A=we(e.font),i=A.lineHeight/2+this._padding.top,{titleX:s,titleY:a,maxWidth:n,rotation:r}=this._drawArgs(i);ue(t,e.text,0,0,A,{color:e.color,maxWidth:n,rotation:r,textAlign:Nt(e.align),textBaseline:"middle",translation:[s,a]})}}var ha={id:"title",_element:ca,start(t,e,A){!function(t,e){const A=new ca({ctx:t.ctx,options:e,chart:t});Ii.configure(t,A,e),Ii.addBox(t,A),t.titleBlock=A}(t,A)},stop(t){const e=t.titleBlock;Ii.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,A){const i=t.titleBlock;Ii.configure(t,i,A),i.options=A},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const la=new WeakMap;var Ia={id:"subtitle",start(t,e,A){const i=new ca({ctx:t.ctx,options:A,chart:t});Ii.configure(t,i,A),Ii.addBox(t,i),la.set(t,i)},stop(t){Ii.removeBox(t,la.get(t)),la.delete(t)},beforeUpdate(t,e,A){const i=la.get(t);Ii.configure(t,i,A),i.options=A},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const da={average(t){if(!t.length)return!1;let e,A,i=new Set,s=0,a=0;for(e=0,A=t.length;et+e))/i.size;return{x:n,y:s/a}},nearest(t,e){if(!t.length)return!1;let A,i,s,a=e.x,n=e.y,r=Number.POSITIVE_INFINITY;for(A=0,i=t.length;A-1?t.split("\n"):t}function Ba(t,e){const{element:A,datasetIndex:i,index:s}=e,a=t.getDatasetMeta(i).controller,{label:n,value:r}=a.getLabelAndValue(s);return{chart:t,label:n,parsed:a.getParsed(s),raw:t.data.datasets[i].data[s],formattedValue:r,dataset:a.getDataset(),dataIndex:s,datasetIndex:i,element:A}}function Qa(t,e){const A=t.chart.ctx,{body:i,footer:s,title:a}=t,{boxWidth:n,boxHeight:r}=e,o=we(e.bodyFont),g=we(e.titleFont),c=we(e.footerFont),h=a.length,l=s.length,I=i.length,d=be(e.padding);let u=d.height,C=0,B=i.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);B+=t.beforeBody.length+t.afterBody.length,h&&(u+=h*g.lineHeight+(h-1)*e.titleSpacing+e.titleMarginBottom),B&&(u+=I*(e.displayColors?Math.max(r,o.lineHeight):o.lineHeight)+(B-I)*o.lineHeight+(B-1)*e.bodySpacing),l&&(u+=e.footerMarginTop+l*c.lineHeight+(l-1)*e.footerSpacing);let Q=0;const E=function(t){C=Math.max(C,A.measureText(t).width+Q)};return A.save(),A.font=g.string,Y(t.title,E),A.font=o.string,Y(t.beforeBody.concat(t.afterBody),E),Q=e.displayColors?n+2+e.boxPadding:0,Y(i,(t=>{Y(t.before,E),Y(t.lines,E),Y(t.after,E)})),Q=0,A.font=c.string,Y(t.footer,E),A.restore(),C+=d.width,{width:C,height:u}}function Ea(t,e,A,i){const{x:s,width:a}=A,{width:n,chartArea:{left:r,right:o}}=t;let g="center";return"center"===i?g=s<=(r+o)/2?"left":"right":s<=a/2?g="left":s>=n-a/2&&(g="right"),function(t,e,A,i){const{x:s,width:a}=i,n=A.caretSize+A.caretPadding;return"left"===t&&s+a+n>e.width||"right"===t&&s-a-n<0||void 0}(g,t,e,A)&&(g="center"),g}function fa(t,e,A){const i=A.yAlign||e.yAlign||function(t,e){const{y:A,height:i}=e;return At.height-i/2?"bottom":"center"}(t,A);return{xAlign:A.xAlign||e.xAlign||Ea(t,e,A,i),yAlign:i}}function pa(t,e,A,i){const{caretSize:s,caretPadding:a,cornerRadius:n}=t,{xAlign:r,yAlign:o}=A,g=s+a,{topLeft:c,topRight:h,bottomLeft:l,bottomRight:I}=ye(n);let d=function(t,e){let{x:A,width:i}=t;return"right"===e?A-=i:"center"===e&&(A-=i/2),A}(e,r);const u=function(t,e,A){let{y:i,height:s}=t;return"top"===e?i+=A:i-="bottom"===e?s+A:s/2,i}(e,o,g);return"center"===o?"left"===r?d+=g:"right"===r&&(d-=g):"left"===r?d-=Math.max(c,l)+s:"right"===r&&(d+=Math.max(h,I)+s),{x:yt(d,0,i.width-e.width),y:yt(u,0,i.height-e.height)}}function ma(t,e,A){const i=be(A.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.right:t.x+i.left}function ya(t){return ua([],Ca(t))}function ba(t,e){const A=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return A?t.override(A):t}const wa={beforeTitle:R,title(t){if(t.length>0){const e=t[0],A=e.chart.data.labels,i=A?A.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(i>0&&e.dataIndex{const e={before:[],lines:[],after:[]},s=ba(A,t);ua(e.before,Ca(Da(s,"beforeLabel",this,t))),ua(e.lines,Da(s,"label",this,t)),ua(e.after,Ca(Da(s,"afterLabel",this,t))),i.push(e)})),i}getAfterBody(t,e){return ya(Da(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:A}=e,i=Da(A,"beforeFooter",this,t),s=Da(A,"footer",this,t),a=Da(A,"afterFooter",this,t);let n=[];return n=ua(n,Ca(i)),n=ua(n,Ca(s)),n=ua(n,Ca(a)),n}_createItems(t){const e=this._active,A=this.chart.data,i=[],s=[],a=[];let n,r,o=[];for(n=0,r=e.length;nt.filter(e,i,s,A)))),t.itemSort&&(o=o.sort(((e,i)=>t.itemSort(e,i,A)))),Y(o,(e=>{const A=ba(t.callbacks,e);i.push(Da(A,"labelColor",this,e)),s.push(Da(A,"labelPointStyle",this,e)),a.push(Da(A,"labelTextColor",this,e))})),this.labelColors=i,this.labelPointStyles=s,this.labelTextColors=a,this.dataPoints=o,o}update(t,e){const A=this.options.setContext(this.getContext()),i=this._active;let s,a=[];if(i.length){const t=da[A.position].call(this,i,this._eventPosition);a=this._createItems(A),this.title=this.getTitle(a,A),this.beforeBody=this.getBeforeBody(a,A),this.body=this.getBody(a,A),this.afterBody=this.getAfterBody(a,A),this.footer=this.getFooter(a,A);const e=this._size=Qa(this,A),n=Object.assign({},t,e),r=fa(this.chart,A,n),o=pa(A,n,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,s={opacity:1,x:o.x,y:o.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(s={opacity:0});this._tooltipItems=a,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&A.external&&A.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,A,i){const s=this.getCaretPosition(t,A,i);e.lineTo(s.x1,s.y1),e.lineTo(s.x2,s.y2),e.lineTo(s.x3,s.y3)}getCaretPosition(t,e,A){const{xAlign:i,yAlign:s}=this,{caretSize:a,cornerRadius:n}=A,{topLeft:r,topRight:o,bottomLeft:g,bottomRight:c}=ye(n),{x:h,y:l}=t,{width:I,height:d}=e;let u,C,B,Q,E,f;return"center"===s?(E=l+d/2,"left"===i?(u=h,C=u-a,Q=E+a,f=E-a):(u=h+I,C=u+a,Q=E-a,f=E+a),B=u):(C="left"===i?h+Math.max(r,g)+a:"right"===i?h+I-Math.max(o,c)-a:this.caretX,"top"===s?(Q=l,E=Q-a,u=C-a,B=C+a):(Q=l+d,E=Q+a,u=C+a,B=C-a),f=Q),{x1:u,x2:C,x3:B,y1:Q,y2:E,y3:f}}drawTitle(t,e,A){const i=this.title,s=i.length;let a,n,r;if(s){const o=gA(A.rtl,this.x,this.width);for(t.x=ma(this,A.titleAlign,A),e.textAlign=o.textAlign(A.titleAlign),e.textBaseline="middle",a=we(A.titleFont),n=A.titleSpacing,e.fillStyle=A.titleColor,e.font=a.string,r=0;r0!==t))?(t.beginPath(),t.fillStyle=s.multiKeyBackground,Ce(t,{x:e,y:I,w:o,h:r,radius:n}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),Ce(t,{x:A,y:I+1,w:o-2,h:r-2,radius:n}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(e,I,o,r),t.strokeRect(e,I,o,r),t.fillStyle=a.backgroundColor,t.fillRect(A,I+1,o-2,r-2))}t.fillStyle=this.labelTextColors[A]}drawBody(t,e,A){const{body:i}=this,{bodySpacing:s,bodyAlign:a,displayColors:n,boxHeight:r,boxWidth:o,boxPadding:g}=A,c=we(A.bodyFont);let h=c.lineHeight,l=0;const I=gA(A.rtl,this.x,this.width),d=function(A){e.fillText(A,I.x(t.x+l),t.y+h/2),t.y+=h+s},u=I.textAlign(a);let C,B,Q,E,f,p,m;for(e.textAlign=a,e.textBaseline="middle",e.font=c.string,t.x=ma(this,u,A),e.fillStyle=A.bodyColor,Y(this.beforeBody,d),l=n&&"right"!==u?"center"===a?o/2+g:o+2+g:0,E=0,p=i.length;E0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,A=this.$animations,i=A&&A.x,s=A&&A.y;if(i||s){const A=da[t.position].call(this,this._active,this._eventPosition);if(!A)return;const a=this._size=Qa(this,t),n=Object.assign({},A,this._size),r=fa(e,t,n),o=pa(t,n,r,e);i._to===o.x&&s._to===o.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=a.width,this.height=a.height,this.caretX=A.x,this.caretY=A.y,this._resolveAnimations().update(this,o))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let A=this.opacity;if(!A)return;this._updateAnimationTarget(e);const i={width:this.width,height:this.height},s={x:this.x,y:this.y};A=Math.abs(A)<.001?0:A;const a=be(e.padding),n=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&n&&(t.save(),t.globalAlpha=A,this.drawBackground(s,t,i,e),cA(t,e.textDirection),s.y+=a.top,this.drawTitle(s,t,e),this.drawBody(s,t,e),this.drawFooter(s,t,e),hA(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const A=this._active,i=t.map((({datasetIndex:t,index:e})=>{const A=this.chart.getDatasetMeta(t);if(!A)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:A.data[e],index:e}})),s=!T(A,i),a=this._positionChanged(i,e);(s||a)&&(this._active=i,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,A=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,s=this._active||[],a=this._getActiveElements(t,s,e,A),n=this._positionChanged(a,t),r=e||!T(a,s)||n;return r&&(this._active=a,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,A,i){const s=this.options;if("mouseout"===t.type)return[];if(!i)return e.filter((t=>this.chart.data.datasets[t.datasetIndex]&&void 0!==this.chart.getDatasetMeta(t.datasetIndex).controller.getParsed(t.index)));const a=this.chart.getElementsAtEventForMode(t,s.mode,s,A);return s.reverse&&a.reverse(),a}_positionChanged(t,e){const{caretX:A,caretY:i,options:s}=this,a=da[s.position].call(this,t,e);return!1!==a&&(A!==a.x||i!==a.y)}}var Sa={id:"tooltip",_element:ka,positioners:da,afterInit(t,e,A){A&&(t.tooltip=new ka({chart:t,options:A}))},beforeUpdate(t,e,A){t.tooltip&&t.tooltip.initialize(A)},reset(t,e,A){t.tooltip&&t.tooltip.initialize(A)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const A={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...A,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",A)}},afterEvent(t,e){if(t.tooltip){const A=e.replay;t.tooltip.handleEvent(e.event,A,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:wa},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},xa=Object.freeze({__proto__:null,Colors:_s,Decimation:Ps,Filler:aa,Legend:ga,SubTitle:Ia,Title:ha,Tooltip:Sa});function Fa(t){const e=this.getLabels();return t>=0&&ti=e?i:t,n=t=>s=A?s:t;if(t){const t=ct(i),e=ct(s);t<0&&e<0?n(0):t>0&&e>0&&a(0)}if(i===s){let e=0===s?1:Math.abs(.05*s);n(s+e),t||a(i-e)}this.min=i,this.max=s}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:A,stepSize:i}=t;return i?(e=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),A=A||11),A&&(e=Math.min(A,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let A=this.getTickLimit();A=Math.max(2,A);const i=function(t,e){const A=[],{bounds:i,step:s,min:a,max:n,precision:r,count:o,maxTicks:g,maxDigits:c,includeBounds:h}=t,l=s||1,I=g-1,{min:d,max:u}=e,C=!N(a),B=!N(n),Q=!N(o),E=(u-d)/(c+1);let f,p,m,y,b=lt((u-d)/I/l)*l;if(b<1e-14&&!C&&!B)return[{value:d},{value:u}];y=Math.ceil(u/b)-Math.floor(d/b),y>I&&(b=lt(y*b/I/l)*l),N(r)||(f=Math.pow(10,r),b=Math.ceil(b*f)/f),"ticks"===i?(p=Math.floor(d/b)*b,m=Math.ceil(u/b)*b):(p=d,m=u),C&&B&&s&&function(t,e){const A=Math.round(t);return A-e<=t&&A+e>=t}((n-a)/s,b/1e3)?(y=Math.round(Math.min((n-a)/b,g)),b=(n-a)/y,p=a,m=n):Q?(p=C?a:p,m=B?n:m,y=o-1,b=(m-p)/y):(y=(m-p)/b,y=ht(y,Math.round(y),b/1e3)?Math.round(y):Math.ceil(y));const w=Math.max(Bt(b),Bt(p));f=Math.pow(10,N(r)?w:r),p=Math.round(p*f)/f,m=Math.round(m*f)/f;let D=0;for(C&&(h&&p!==a?(A.push({value:a}),pn)break;A.push({value:t})}return B&&h&&m!==n?A.length&&ht(A[A.length-1].value,n,Ra(n,E,t))?A[A.length-1].value=n:A.push({value:n}):B&&m!==n||A.push({value:m}),A}({maxTicks:A,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&dt(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}configure(){const t=this.ticks;let e=this.min,A=this.max;if(super.configure(),this.options.offset&&t.length){const i=(A-e)/Math.max(t.length-1,1)/2;e-=i,A+=i}this._startValue=e,this._endValue=A,this._valueRange=A-e}getLabelForValue(t){return Wt(t,this.chart.options.locale,this.options.ticks.format)}}class Na extends va{static id="linear";static defaults={ticks:{callback:Vt.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=L(t)?t:0,this.max=L(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,A=ut(this.options.ticks.minRotation),i=(t?Math.sin(A):Math.cos(A))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,s.lineHeight/i))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Ma=t=>Math.floor(gt(t)),Ga=(t,e)=>Math.pow(10,Ma(t)+e);function La(t){return 1==t/Math.pow(10,Ma(t))}function Ua(t,e,A){const i=Math.pow(10,A),s=Math.floor(t/i);return Math.ceil(e/i)-s}class Ha extends _i{static id="logarithmic";static defaults={ticks:{callback:Vt.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const A=va.prototype.parse.apply(this,[t,e]);if(0!==A)return L(A)&&A>0?A:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=L(t)?Math.max(0,t):null,this.max=L(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!L(this._userMin)&&(this.min=t===Ga(this.min,0)?Ga(this.min,-1):Ga(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let A=this.min,i=this.max;const s=e=>A=t?A:e,a=t=>i=e?i:t;A===i&&(A<=0?(s(1),a(10)):(s(Ga(A,-1)),a(Ga(i,1)))),A<=0&&s(Ga(i,-1)),i<=0&&a(Ga(A,1)),this.min=A,this.max=i}buildTicks(){const t=this.options,e=function(t,{min:e,max:A}){e=U(t.min,e);const i=[],s=Ma(e);let a=function(t,e){let A=Ma(e-t);for(;Ua(t,e,A)>10;)A++;for(;Ua(t,e,A)<10;)A--;return Math.min(A,Ma(t))}(e,A),n=a<0?Math.pow(10,Math.abs(a)):1;const r=Math.pow(10,a),o=s>a?Math.pow(10,s):0,g=Math.round((e-o)*n)/n,c=Math.floor((e-o)/r/10)*r*10;let h=Math.floor((g-c)/Math.pow(10,a)),l=U(t.min,Math.round((o+c+h*Math.pow(10,a))*n)/n);for(;l=10?h=h<15?15:20:h++,h>=20&&(a++,h=2,n=a>=0?1:n),l=Math.round((o+c+h*Math.pow(10,a))*n)/n;const I=U(t.max,l);return i.push({value:I,major:La(I),significand:h}),i}({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&dt(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return void 0===t?"0":Wt(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=gt(t),this._valueRange=gt(this.max)-gt(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(gt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function Ja(t){const e=t.ticks;if(e.display&&t.display){const t=be(e.backdropPadding);return H(e.font&&e.font.size,ee.font.size)+t.height}return 0}function _a(t,e,A,i,s){return t===i||t===s?{start:e-A/2,end:e+A/2}:ts?{start:e-A,end:e}:{start:e,end:e+A}}function Ya(t,e,A,i,s){const a=Math.abs(Math.sin(A)),n=Math.abs(Math.cos(A));let r=0,o=0;i.starte.r&&(r=(i.end-e.r)/a,t.r=Math.max(t.r,e.r+r)),s.starte.b&&(o=(s.end-e.b)/n,t.b=Math.max(t.b,e.b+o))}function Ta(t,e,A){const i=t.drawingArea,{extra:s,additionalAngle:a,padding:n,size:r}=A,o=t.getPointPosition(e,i+s+n,a),g=Math.round(Ct(pt(o.angle+nt))),c=function(t,e,A){return 90===A||270===A?t-=e/2:(A>270||A<90)&&(t-=e),t}(o.y,r.h,g),h=function(t){return 0===t||180===t?"center":t<180?"left":"right"}(g),l=(I=o.x,d=r.w,"right"===(u=h)?I-=d:"center"===u&&(I-=d/2),I);var I,d,u;return{visible:!0,x:o.x,y:c,textAlign:h,left:l,top:c,right:l+r.w,bottom:c+r.h}}function Pa(t,e){if(!e)return!0;const{left:A,top:i,right:s,bottom:a}=t;return!(oe({x:A,y:i},e)||oe({x:A,y:a},e)||oe({x:s,y:i},e)||oe({x:s,y:a},e))}function Ka(t,e,A){const{left:i,top:s,right:a,bottom:n}=A,{backdropColor:r}=e;if(!N(r)){const A=ye(e.borderRadius),o=be(e.backdropPadding);t.fillStyle=r;const g=i-o.left,c=s-o.top,h=a-i+o.width,l=n-s+o.height;Object.values(A).some((t=>0!==t))?(t.beginPath(),Ce(t,{x:g,y:c,w:h,h:l,radius:A}),t.fill()):t.fillRect(g,c,h,l)}}function qa(t,e,A,i){const{ctx:s}=t;if(A)s.arc(t.xCenter,t.yCenter,e,0,At);else{let A=t.getPointPosition(0,e);s.moveTo(A.x,A.y);for(let a=1;at,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=be(Ja(this.options)/2),e=this.width=this.maxWidth-t.width,A=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+A/2+t.top),this.drawingArea=Math.floor(Math.min(e,A)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=L(t)&&!isNaN(t)?t:0,this.max=L(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Ja(this.options))}generateTickLabels(t){va.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const A=_(this.options.pointLabels.callback,[t,e],this);return A||0===A?A:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?function(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},A=Object.assign({},e),i=[],s=[],a=t._pointLabels.length,n=t.options.pointLabels,r=n.centerPointLabels?et/a:0;for(let h=0;h=0&&t=0;s--){const e=t._pointLabelItems[s];if(!e.visible)continue;const a=i.setContext(t.getPointLabelContext(s));Ka(A,a,e);const n=we(a.font),{x:r,y:o,textAlign:g}=e;ue(A,t._pointLabels[s],r,o+n.lineHeight/2,n,{color:a.color,textAlign:g,textBaseline:"middle"})}}(this,a),i.display&&this.ticks.forEach(((t,e)=>{if(0!==e||0===e&&this.min<0){r=this.getDistanceFromCenterForValue(t.value);const A=this.getContext(e),n=i.setContext(A),o=s.setContext(A);!function(t,e,A,i,s){const a=t.ctx,n=e.circular,{color:r,lineWidth:o}=e;!n&&!i||!r||!o||A<0||(a.save(),a.strokeStyle=r,a.lineWidth=o,a.setLineDash(s.dash),a.lineDashOffset=s.dashOffset,a.beginPath(),qa(t,A,n,i),a.closePath(),a.stroke(),a.restore())}(this,n,r,a,o)}})),A.display){for(t.save(),n=a-1;n>=0;n--){const i=A.setContext(this.getPointLabelContext(n)),{color:s,lineWidth:a}=i;a&&s&&(t.lineWidth=a,t.strokeStyle=s,t.setLineDash(i.borderDash),t.lineDashOffset=i.borderDashOffset,r=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),o=this.getPointPosition(n,r),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,A=e.ticks;if(!A.display)return;const i=this.getIndexAngle(0);let s,a;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((i,n)=>{if(0===n&&this.min>=0&&!e.reverse)return;const r=A.setContext(this.getContext(n)),o=we(r.font);if(s=this.getDistanceFromCenterForValue(this.ticks[n].value),r.showLabelBackdrop){t.font=o.string,a=t.measureText(i.label).width,t.fillStyle=r.backdropColor;const e=be(r.backdropPadding);t.fillRect(-a/2-e.left,-s-o.size/2-e.top,a+e.width,o.size+e.height)}ue(t,i.label,0,-s,o,{color:r.color,strokeColor:r.textStrokeColor,strokeWidth:r.textStrokeWidth})})),t.restore()}drawTitle(){}}const Wa={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ja=Object.keys(Wa);function Va(t,e){return t-e}function Za(t,e){if(N(e))return null;const A=t._adapter,{parser:i,round:s,isoWeekday:a}=t._parseOpts;let n=e;return"function"==typeof i&&(n=i(n)),L(n)||(n="string"==typeof i?A.parse(n,i):A.parse(n)),null===n?null:(s&&(n="week"!==s||!It(a)&&!0!==a?A.startOf(n,s):A.startOf(n,"isoWeek",a)),+n)}function Xa(t,e,A,i){const s=ja.length;for(let a=ja.indexOf(t);a=e?A[i]:A[s]]=!0}}else t[e]=!0}function $a(t,e,A){const i=[],s={},a=e.length;let n,r;for(n=0;n=0&&(e[o].major=!0);return e}(t,i,s,A):i}class tn extends _i{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){const A=t.time||(t.time={}),i=this._adapter=new VA(t.adapters.date);i.init(e),W(A.displayFormats,i.formats()),this._parseOpts={parser:A.parser,round:A.round,isoWeekday:A.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:Za(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,A=t.time.unit||"day";let{min:i,max:s,minDefined:a,maxDefined:n}=this.getUserBounds();function r(t){a||isNaN(t.min)||(i=Math.min(i,t.min)),n||isNaN(t.max)||(s=Math.max(s,t.max))}a&&n||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),i=L(i)&&!isNaN(i)?i:+e.startOf(Date.now(),A),s=L(s)&&!isNaN(s)?s:+e.endOf(Date.now(),A)+1,this.min=Math.min(i,s-1),this.max=Math.max(i+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,A=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],A=t[t.length-1]),{min:e,max:A}}buildTicks(){const t=this.options,e=t.time,A=t.ticks,i="labels"===A.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const s=this.min,a=function(t,e,A){let i=0,s=t.length;for(;ii&&t[s-1]>A;)s--;return i>0||s=ja.indexOf(A);a--){const A=ja[a];if(Wa[A].common&&t._adapter.diff(s,i,A)>=e-1)return A}return ja[A?ja.indexOf(A):0]}(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=A.major.enabled&&"year"!==this._unit?function(t){for(let e=ja.indexOf(t)+1,A=ja.length;e+t.value)))}initOffsets(t=[]){let e,A,i=0,s=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),i=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,A=this.getDecimalForValue(t[t.length-1]),s=1===t.length?A:(A-this.getDecimalForValue(t[t.length-2]))/2);const a=t.length<3?.5:.25;i=yt(i,0,a),s=yt(s,0,a),this._offsets={start:i,end:s,factor:1/(i+1+s)}}_generate(){const t=this._adapter,e=this.min,A=this.max,i=this.options,s=i.time,a=s.unit||Xa(s.minUnit,e,A,this._getLabelCapacity(e)),n=H(i.ticks.stepSize,1),r="week"===a&&s.isoWeekday,o=It(r)||!0===r,g={};let c,h,l=e;if(o&&(l=+t.startOf(l,"isoWeek",r)),l=+t.startOf(l,o?"day":a),t.diff(A,e,a)>1e5*n)throw new Error(e+" and "+A+" are too far apart with stepSize of "+n+" "+a);const I="data"===i.ticks.source&&this.getDataTimestamps();for(c=l,h=0;c+t))}getLabelForValue(t){const e=this._adapter,A=this.options.time;return A.tooltipFormat?e.format(t,A.tooltipFormat):e.format(t,A.displayFormats.datetime)}format(t,e){const A=this.options.time.displayFormats,i=this._unit,s=e||A[i];return this._adapter.format(t,s)}_tickFormatFunction(t,e,A,i){const s=this.options,a=s.ticks.callback;if(a)return _(a,[t,e,A],this);const n=s.time.displayFormats,r=this._unit,o=this._majorUnit,g=r&&n[r],c=o&&n[o],h=A[e],l=o&&c&&h&&h.major;return this._adapter.format(t,i||(l?c:g))}generateTickLabels(t){let e,A,i;for(e=0,A=t.length;e0?n:1}getDataTimestamps(){let t,e,A=this._cache.data||[];if(A.length)return A;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(t=0,e=i.length;t=t[r].pos&&e<=t[o].pos&&({lo:r,hi:o}=Dt(t,"pos",e)),({pos:i,time:a}=t[r]),({pos:s,time:n}=t[o])):(e>=t[r].time&&e<=t[o].time&&({lo:r,hi:o}=Dt(t,"time",e)),({time:i,pos:a}=t[r]),({time:s,pos:n}=t[o]));const g=s-i;return g?a+(n-a)*(e-i)/g:a}var An=Object.freeze({__proto__:null,CategoryScale:class extends _i{static id="category";static defaults={ticks:{callback:Fa}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:A,label:i}of e)t[A]===i&&t.splice(A,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(N(t))return null;const A=this.getLabels();return((t,e)=>null===t?null:yt(Math.round(t),0,e))(e=isFinite(e)&&A[e]===t?e:function(t,e,A,i){const s=t.indexOf(e);return-1===s?((t,e,A,i)=>("string"==typeof e?(A=t.push(e)-1,i.unshift({index:A,label:e})):isNaN(e)&&(A=null),A))(t,e,A,i):s!==t.lastIndexOf(e)?A:s}(A,t,H(e,t),this._addedLabels),A.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:A,max:i}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(A=0),e||(i=this.getLabels().length-1)),this.min=A,this.max=i}buildTicks(){const t=this.min,e=this.max,A=this.options.offset,i=[];let s=this.getLabels();s=0===t&&e===s.length-1?s:s.slice(t,e+1),this._valueRange=Math.max(s.length-(A?0:1),1),this._startValue=this.min-(A?.5:0);for(let A=t;A<=e;A++)i.push({value:A});return i}getLabelForValue(t){return Fa.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:Na,LogarithmicScale:Ha,RadialLinearScale:Oa,TimeScale:tn,TimeSeriesScale:class extends tn{static id="timeseries";static defaults=tn.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=en(e,this.min),this._tableRange=en(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:A}=this,i=[],s=[];let a,n,r,o,g;for(a=0,n=t.length;a=e&&o<=A&&i.push(o);if(i.length<2)return[{time:e,pos:0},{time:A,pos:1}];for(a=0,n=i.length;at-e))}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),A=this.getLabelTimestamps();return t=e.length&&A.length?this.normalize(e.concat(A)):e.length?e:A,t=this._cache.all=t,t}getDecimalForValue(t){return(en(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,A=this.getDecimalForPixel(t)/e.factor-e.end;return en(this._table,A*this._tableRange+this._minPos,!0)}}});const sn=[OA,Ms,xa,An];Cs.register(...sn);const an=Cs,nn={layout:{padding:0},plugins:{legend:{labels:{padding:3}}},scales:{x:{display:!1},y:{display:!1}}},rn={layout:{padding:0},plugins:{legend:{labels:{padding:3}}}};function on(t,e){return t.reduce(((t,A)=>(t[A[e]]=(t[A[e]]||0)+1,t)),{})}function gn(t){document.getElementById("stats-div").innerHTML='

Colleges

\n
\n
\n

Buildings

\n
\n
\n

Room Types

\n
\n
\n

Sq. Ft.

';const e=on(t,"college"),A=on(t,"building"),i=on(t,"type"),s=function(t){const e=t.map((t=>parseFloat(t.sqft))),A=Math.min(...e),i=Math.max(...e),s=50,a=Math.floor(A/s)*s,n=Math.floor(i/s)*s;console.log(`min: ${A} - max: ${i} - lowerBound: ${a} - upperBound: ${n}`);const r={};for(let t=a;t<=n;t+=s)r[`${t} - ${t+s-1}`]=0;return e.forEach((t=>{const e=Math.floor(t/s)*s;r[`${e} - ${e+s-1}`]+=1})),r}(t);console.log(e),console.log(Object.values(e).reduce(((t,e)=>t+e),0)),console.log(A),console.log(Object.values(A).reduce(((t,e)=>t+e),0)),console.log(i),console.log(Object.values(i).reduce(((t,e)=>t+e),0)),console.log(s),console.log(Object.values(s).reduce(((t,e)=>t+e),0));const a={college:["pie",e,nn],building:["pie",A,nn],type:["pie",i,nn],sqft:["bar",s,rn]},n=document.getElementsByTagName("canvas");Array.from(n).forEach((t=>{const e=t.id.split("-")[0];new an(t,{type:a[e][0],data:{labels:Object.keys(a[e][1]),datasets:[{label:"Frequency",data:Object.values(a[e][1])}]},options:a[e][2]})}))}var cn={d:(t,e)=>{for(var A in e)cn.o(e,A)&&!cn.o(t,A)&&Object.defineProperty(t,A,{enumerable:!0,get:e[A]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},hn=globalThis.pdfjsLib={};cn.d(hn,{AbortException:()=>Yn,AnnotationEditorLayer:()=>Qc,AnnotationEditorParamsType:()=>Qn,AnnotationEditorType:()=>Bn,AnnotationEditorUIManager:()=>Nr,AnnotationLayer:()=>nc,AnnotationMode:()=>Cn,CMapCompressionType:()=>mn,ColorPicker:()=>dc,DOMSVGFactory:()=>or,DrawLayer:()=>Ec,FeatureTest:()=>qn,GlobalWorkerOptions:()=>yo,ImageKind:()=>fn,InvalidPDFException:()=>Un,MissingPDFException:()=>Hn,OPS:()=>yn,PDFDataRangeTransport:()=>Ig,PDFDateString:()=>Er,PDFWorker:()=>Qg,PasswordResponses:()=>bn,PermissionFlag:()=>En,PixelsPerInch:()=>sr,RenderingCancelledException:()=>cr,TextLayer:()=>ig,UnexpectedResponseException:()=>Jn,Util:()=>Wn,VerbosityLevel:()=>pn,XfaLayer:()=>xg,build:()=>wg,createValidAbsoluteUrl:()=>vn,fetchData:()=>ar,getDocument:()=>cg,getFilenameFromUrl:()=>Ir,getPdfFilenameFromUrl:()=>dr,getXfaPageViewport:()=>fr,isDataScheme:()=>hr,isPdfFile:()=>lr,noContextMenu:()=>Br,normalizeUnicode:()=>Zn,setLayerDimensions:()=>br,shadow:()=>Nn,version:()=>bg});const ln=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),In=[1,0,0,1,0,0],dn=[.001,0,0,.001,0,0],un=1.35,Cn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Bn={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Qn={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},En={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},fn={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},pn={ERRORS:0,WARNINGS:1,INFOS:5},mn={NONE:0,BINARY:1},yn={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},bn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let wn=pn.WARNINGS;function Dn(t){Number.isInteger(t)&&(wn=t)}function kn(){return wn}function Sn(t){wn>=pn.INFOS&&console.log(`Info: ${t}`)}function xn(t){wn>=pn.WARNINGS&&console.log(`Warning: ${t}`)}function Fn(t){throw new Error(t)}function Rn(t,e){t||Fn(e)}function vn(t,e=null,A=null){if(!t)return null;try{if(A&&"string"==typeof t){if(A.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(A.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const i=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}}(i))return i}catch{}return null}function Nn(t,e,A,i=!1){return Object.defineProperty(t,e,{value:A,enumerable:!i,configurable:!0,writable:!1}),A}const Mn=function(){function t(e,A){this.constructor===t&&Fn("Cannot initialize BaseException."),this.message=e,this.name=A}return t.prototype=new Error,t.constructor=t,t}();class Gn extends Mn{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ln extends Mn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Un extends Mn{constructor(t){super(t,"InvalidPDFException")}}class Hn extends Mn{constructor(t){super(t,"MissingPDFException")}}class Jn extends Mn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class _n extends Mn{constructor(t){super(t,"FormatError")}}class Yn extends Mn{constructor(t){super(t,"AbortException")}}function Tn(t){"object"==typeof t&&void 0!==t?.length||Fn("Invalid argument for bytesToString");const e=t.length,A=8192;if(et.toString(16).padStart(2,"0")));class Wn{static makeHexColor(t,e,A){return`#${On[t]}${On[e]}${On[A]}`}static scaleMinMax(t,e){let A;t[0]?(t[0]<0&&(A=e[0],e[0]=e[2],e[2]=A),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(A=e[1],e[1]=e[3],e[3]=A),e[1]*=t[3],e[3]*=t[3]):(A=e[0],e[0]=e[1],e[1]=A,A=e[2],e[2]=e[3],e[3]=A,t[1]<0&&(A=e[1],e[1]=e[3],e[3]=A),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(A=e[0],e[0]=e[2],e[2]=A),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 A=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])/A,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/A]}static getAxialAlignedBoundingBox(t,e){const A=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),s=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(A[0],i[0],s[0],a[0]),Math.min(A[1],i[1],s[1],a[1]),Math.max(A[0],i[0],s[0],a[0]),Math.max(A[1],i[1],s[1],a[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]],A=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],s=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],n=(A+a)/2,r=Math.sqrt((A+a)**2-4*(A*a-s*i))/2,o=n+r||1,g=n-r||1;return[Math.sqrt(o),Math.sqrt(g)]}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 A=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(A>i)return null;const s=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return s>a?null:[A,s,i,a]}static#t(t,e,A,i,s,a,n,r,o,g){if(o<=0||o>=1)return;const c=1-o,h=o*o,l=h*o,I=c*(c*(c*t+3*o*e)+3*h*A)+l*i,d=c*(c*(c*s+3*o*a)+3*h*n)+l*r;g[0]=Math.min(g[0],I),g[1]=Math.min(g[1],d),g[2]=Math.max(g[2],I),g[3]=Math.max(g[3],d)}static#e(t,e,A,i,s,a,n,r,o,g,c,h){if(Math.abs(o)<1e-12)return void(Math.abs(g)>=1e-12&&this.#t(t,e,A,i,s,a,n,r,-c/g,h));const l=g**2-4*c*o;if(l<0)return;const I=Math.sqrt(l),d=2*o;this.#t(t,e,A,i,s,a,n,r,(-g+I)/d,h),this.#t(t,e,A,i,s,a,n,r,(-g-I)/d,h)}static bezierBoundingBox(t,e,A,i,s,a,n,r,o){return o?(o[0]=Math.min(o[0],t,n),o[1]=Math.min(o[1],e,r),o[2]=Math.max(o[2],t,n),o[3]=Math.max(o[3],e,r)):o=[Math.min(t,n),Math.min(e,r),Math.max(t,n),Math.max(e,r)],this.#e(t,A,s,n,e,i,a,r,3*(3*(A-s)-t+n),6*(t-2*A+s),3*(A-t),o),this.#e(t,A,s,n,e,i,a,r,3*(3*(i-a)-e+r),6*(e-2*i+a),3*(i-e),o),o}}let jn=null,Vn=null;function Zn(t){return jn||(jn=/([\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,Vn=new Map([["ſt","ſt"]])),t.replaceAll(jn,((t,e,A)=>e?e.normalize("NFKC"):Vn.get(A)))}const Xn="pdfjs_internal_id_";class zn{constructor(){this.constructor===zn&&Fn("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,A,i,s){return"none"}destroy(t=!1){}}class $n{#A=!1;constructor({enableHWA:t=!1}={}){this.constructor===$n&&Fn("Cannot initialize BaseCanvasFactory."),this.#A=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const A=this._createCanvas(t,e);return{canvas:A,context:A.getContext("2d",{willReadFrequently:!this.#A})}}reset(t,e,A){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||A<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=A}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Fn("Abstract method `_createCanvas` called.")}}class tr{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===tr&&Fn("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, 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":""),A=this.isCompressed?mn.BINARY:mn.NONE;return this._fetchData(e,A).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(t,e){Fn("Abstract method `_fetchData` called.")}}class er{constructor({baseUrl:t=null}){this.constructor===er&&Fn("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, 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._fetchData(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(t){Fn("Abstract method `_fetchData` called.")}}class Ar{constructor(){this.constructor===Ar&&Fn("Cannot initialize BaseSVGFactory.")}create(t,e,A=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),A||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Fn("Abstract method `_createSVG` called.")}}const ir="http://www.w3.org/2000/svg";class sr{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function ar(t,e="text"){if(Cr(t,document.baseURI)){const A=await fetch(t);if(!A.ok)throw new Error(A.statusText);switch(e){case"arraybuffer":return A.arrayBuffer();case"blob":return A.blob();case"json":return A.json()}return A.text()}return new Promise(((A,i)=>{const s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType=e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)i(new Error(s.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void A(s.response)}A(s.responseText)}},s.send(null)}))}class nr extends tr{_fetchData(t,e){return ar(t,this.isCompressed?"arraybuffer":"text").then((t=>({cMapData:t instanceof ArrayBuffer?new Uint8Array(t):Pn(t),compressionType:e})))}}class rr extends er{_fetchData(t){return ar(t,"arraybuffer").then((t=>new Uint8Array(t)))}}class or extends Ar{_createSVG(t){return document.createElementNS(ir,t)}}class gr{constructor({viewBox:t,scale:e,rotation:A,offsetX:i=0,offsetY:s=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=A,this.offsetX=i,this.offsetY=s;const n=(t[2]+t[0])/2,r=(t[3]+t[1])/2;let o,g,c,h,l,I,d,u;switch((A%=360)<0&&(A+=360),A){case 180:o=-1,g=0,c=0,h=1;break;case 90:o=0,g=1,c=1,h=0;break;case 270:o=0,g=-1,c=-1,h=0;break;case 0:o=1,g=0,c=0,h=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,h=-h),0===o?(l=Math.abs(r-t[1])*e+i,I=Math.abs(n-t[0])*e+s,d=(t[3]-t[1])*e,u=(t[2]-t[0])*e):(l=Math.abs(n-t[0])*e+i,I=Math.abs(r-t[1])*e+s,d=(t[2]-t[0])*e,u=(t[3]-t[1])*e),this.transform=[o*e,g*e,c*e,h*e,l-o*e*n-c*e*r,I-g*e*n-h*e*r],this.width=d,this.height=u}get rawDims(){const{viewBox:t}=this;return Nn(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:A=this.offsetX,offsetY:i=this.offsetY,dontFlip:s=!1}={}){return new gr({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:A,offsetY:i,dontFlip:s})}convertToViewportPoint(t,e){return Wn.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=Wn.applyTransform([t[0],t[1]],this.transform),A=Wn.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],A[0],A[1]]}convertToPdfPoint(t,e){return Wn.applyInverseTransform([t,e],this.transform)}}class cr extends Mn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function hr(t){const e=t.length;let A=0;for(;A=1&&i<=12?i-1:0;let s=parseInt(e[3],10);s=s>=1&&s<=31?s:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let n=parseInt(e[5],10);n=n>=0&&n<=59?n:0;let r=parseInt(e[6],10);r=r>=0&&r<=59?r:0;const o=e[7]||"Z";let g=parseInt(e[8],10);g=g>=0&&g<=23?g:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===o?(a+=g,n+=c):"+"===o&&(a-=g,n-=c),new Date(Date.UTC(A,i,s,a,n,r))}}function fr(t,{scale:e=1,rotation:A=0}){const{width:i,height:s}=t.attributes.style,a=[0,0,parseInt(i),parseInt(s)];return new gr({viewBox:a,scale:e,rotation:A})}function pr(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):(xn(`Not a valid color format: "${t}"`),[0,0,0])}function mr(t){const{a:e,b:A,c:i,d:s,e:a,f:n}=t.getTransform();return[e,A,i,s,a,n]}function yr(t){const{a:e,b:A,c:i,d:s,e:a,f:n}=t.getTransform().invertSelf();return[e,A,i,s,a,n]}function br(t,e,A=!1,i=!0){if(e instanceof gr){const{pageWidth:i,pageHeight:s}=e.rawDims,{style:a}=t,n=qn.isCSSRoundSupported,r=`var(--scale-factor) * ${i}px`,o=`var(--scale-factor) * ${s}px`,g=n?`round(${r}, 1px)`:`calc(${r})`,c=n?`round(${o}, 1px)`:`calc(${o})`;A&&e.rotation%180!=0?(a.width=c,a.height=g):(a.width=g,a.height=c)}i&&t.setAttribute("data-main-rotation",e.rotation)}class wr{#i=null;#s=null;#a;#n=null;constructor(t){this.#a=t}render(){const t=this.#i=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",Br,{signal:e}),t.addEventListener("pointerdown",wr.#r,{signal:e});const A=this.#n=document.createElement("div");A.className="buttons",t.append(A);const i=this.#a.toolbarPosition;if(i){const{style:e}=t,A="ltr"===this.#a._uiManager.direction?1-i[0]:i[0];e.insetInlineEnd=100*A+"%",e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#o(),t}static#r(t){t.stopPropagation()}#g(t){this.#a._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#c(t){this.#a._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#h(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Br,{signal:e})}hide(){this.#i.classList.add("hidden"),this.#s?.hideDropdown()}show(){this.#i.classList.remove("hidden")}#o(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#a.editorType}-button`),this.#h(t),t.addEventListener("click",(t=>{this.#a._uiManager.delete()}),{signal:this.#a._uiManager._signal}),this.#n.append(t)}get#l(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#h(t),this.#n.prepend(t,this.#l)}addColorPicker(t){this.#s=t;const e=t.renderButton();this.#h(e),this.#n.prepend(e,this.#l)}remove(){this.#i.remove(),this.#s?.destroy(),this.#s=null}}class Dr{#n=null;#i=null;#I;constructor(t){this.#I=t}#d(){const t=this.#i=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Br,{signal:this.#I._signal});const e=this.#n=document.createElement("div");return e.className="buttons",t.append(e),this.#u(),t}#C(t,e){let A=0,i=0;for(const s of t){const t=s.y+s.height;if(tA?(i=a,A=t):e?a>i&&(i=a):a{this.#I.highlightSelection("floating_button")}),{signal:A}),this.#n.append(t)}}function kr(t,e,A){for(const i of A)e.addEventListener(i,t[i].bind(t))}class Sr{#B=0;get id(){return"pdfjs_internal_editor_"+this.#B++}}class xr{#Q=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return Tn(t)}();#B=0;#E=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,',Nn(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#f(t,e){this.#E||=new Map;let A=this.#E.get(t);if(null===A)return null;if(A?.bitmap)return A.refCounter+=1,A;try{let t;if(A||={bitmap:null,id:`image_${this.#Q}_${this.#B++}`,refCounter:0,isSvg:!1},"string"==typeof e?(A.url=e,t=await ar(e,"blob")):t=A.file=e,"image/svg+xml"===t.type){const e=xr._isSVGFittingCanvas,i=new FileReader,s=new Image,a=new Promise(((t,a)=>{s.onload=()=>{A.bitmap=s,A.isSvg=!0,t()},i.onload=async()=>{const t=A.svgUrl=i.result;s.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},s.onerror=i.onerror=a}));i.readAsDataURL(t),await a}else A.bitmap=await createImageBitmap(t);A.refCounter=1}catch(t){console.error(t),A=null}return this.#E.set(t,A),A&&this.#E.set(A.id,A),A}async getFromFile(t){const{lastModified:e,name:A,size:i,type:s}=t;return this.#f(`${e}_${A}_${i}_${s}`,t)}async getFromUrl(t){return this.#f(t,t)}async getFromId(t){this.#E||=new Map;const e=this.#E.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#E.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#E||=new Map;const e=this.#E.get(t);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#Q}_`)}}class Fr{#p=[];#m=!1;#y;#b=-1;constructor(t=128){this.#y=t}add({cmd:t,undo:e,post:A,mustExec:i,type:s=NaN,overwriteIfSameType:a=!1,keepUndo:n=!1}){if(i&&t(),this.#m)return;const r={cmd:t,undo:e,post:A,type:s};if(-1===this.#b)return this.#p.length>0&&(this.#p.length=0),this.#b=0,void this.#p.push(r);if(a&&this.#p[this.#b].type===s)return n&&(r.undo=this.#p[this.#b].undo),void(this.#p[this.#b]=r);const o=this.#b+1;o===this.#y?this.#p.splice(0,1):(this.#b=o,ot===e[A])))return vr._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Wn.makeHexColor(...e):t}}class Nr{#D=new AbortController;#k=null;#S=new Map;#x=new Map;#F=null;#R=null;#v=null;#N=new Fr;#M=0;#G=new Set;#L=null;#U=null;#H=new Set;#J=!1;#_=!1;#Y=null;#T=null;#P=null;#K=!1;#q=null;#O=new Sr;#W=!1;#j=!1;#V=null;#Z=null;#X=null;#z=Bn.NONE;#$=new Set;#tt=null;#et=null;#At=null;#it=this.blur.bind(this);#st=this.focus.bind(this);#at=this.copy.bind(this);#nt=this.cut.bind(this);#rt=this.paste.bind(this);#ot=this.keydown.bind(this);#gt=this.keyup.bind(this);#ct=this.onEditingAction.bind(this);#ht=this.onPageChanging.bind(this);#lt=this.onScaleChanging.bind(this);#It=this.onRotationChanging.bind(this);#dt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ut=[0,0];#Ct=null;#Bt=null;#Qt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Nr.prototype,e=t=>t.#Bt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),A=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},i=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return Nn(this,"_keyboardManager",new Rr([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:A}],[["ctrl+z","mac+meta+z"],t.undo,{checker:A}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:A}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:A}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Bt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Bt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}]]))}constructor(t,e,A,i,s,a,n,r,o,g){this._signal=this.#D.signal,this.#Bt=t,this.#Qt=e,this.#F=A,this._eventBus=i,this._eventBus._on("editingaction",this.#ct),this._eventBus._on("pagechanging",this.#ht),this._eventBus._on("scalechanging",this.#lt),this._eventBus._on("rotationchanging",this.#It),this.#Et(),this.#ft(),this.#pt(),this.#R=s.annotationStorage,this.#Y=s.filterFactory,this.#et=a,this.#P=n||null,this.#J=r,this.#_=o,this.#X=g||null,this.viewParameters={realScale:sr.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#D?.abort(),this.#D=null,this._signal=null,this._eventBus._off("editingaction",this.#ct),this._eventBus._off("pagechanging",this.#ht),this._eventBus._off("scalechanging",this.#lt),this._eventBus._off("rotationchanging",this.#It);for(const t of this.#x.values())t.destroy();this.#x.clear(),this.#S.clear(),this.#H.clear(),this.#k=null,this.#$.clear(),this.#N.destroy(),this.#F?.destroy(),this.#q?.hide(),this.#q=null,this.#T&&(clearTimeout(this.#T),this.#T=null),this.#Ct&&(clearTimeout(this.#Ct),this.#Ct=null)}async mlGuess(t){return this.#X?.guess(t)||null}async isMLEnabledFor(t){return!!await(this.#X?.isEnabledFor(t))}get useNewAltTextFlow(){return this.#_}get hcmFilter(){return Nn(this,"hcmFilter",this.#et?this.#Y.addHCMFilter(this.#et.foreground,this.#et.background):"none")}get direction(){return Nn(this,"direction",getComputedStyle(this.#Bt).direction)}get highlightColors(){return Nn(this,"highlightColors",this.#P?new Map(this.#P.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Nn(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setMainHighlightColorPicker(t){this.#Z=t}editAltText(t){this.#F?.editAltText(this,t)}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})}onPageChanging({pageNumber:t}){this.#M=t-1}focusMainContainer(){this.#Bt.focus()}findParent(t,e){for(const A of this.#x.values()){const{x:i,y:s,width:a,height:n}=A.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=s&&e<=s+n)return A}return null}disableUserSelect(t=!1){this.#Qt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#H.add(t)}removeShouldRescale(t){this.#H.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*sr.PDF_TO_CSS_UNITS;for(const t of this.#H)t.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#mt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#yt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#x.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:A,anchorOffset:i,focusNode:s,focusOffset:a}=e,n=e.toString(),r=this.#mt(e).closest(".textLayer"),o=this.getSelectionBoxes(r);if(!o)return;e.empty();const g=this.#yt(r),c=this.#z===Bn.NONE,h=()=>{g?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:o,anchorNode:A,anchorOffset:i,focusNode:s,focusOffset:a,text:n}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(Bn.HIGHLIGHT,h):h()}#bt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#mt(t).closest(".textLayer"),A=this.getSelectionBoxes(e);A&&(this.#q||=new Dr(this),this.#q.show(e,A,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#R||this.#R.has(t.id)||this.#R.setValue(t.id,t)}#wt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#tt&&(this.#q?.hide(),this.#tt=null,this.#Dt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#tt)return;const A=this.#mt(t).closest(".textLayer");if(A){if(this.#q?.hide(),this.#tt=e,this.#Dt({hasSelectedText:!0}),(this.#z===Bn.HIGHLIGHT||this.#z===Bn.NONE)&&(this.#z===Bn.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#K=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#z===Bn.HIGHLIGHT?this.#yt(A):null;t?.toggleDrawing();const e=this._signal,i=e=>{"pointerup"===e.type&&0!==e.button||(t?.toggleDrawing(!0),window.removeEventListener("pointerup",i),window.removeEventListener("blur",i),"pointerup"===e.type&&this.#kt("main_toolbar"))};window.addEventListener("pointerup",i,{signal:e}),window.addEventListener("blur",i,{signal:e})}}else this.#tt&&(this.#q?.hide(),this.#tt=null,this.#Dt({hasSelectedText:!1}))}#kt(t=""){this.#z===Bn.HIGHLIGHT?this.highlightSelection(t):this.#J&&this.#bt()}#Et(){document.addEventListener("selectionchange",this.#wt.bind(this),{signal:this._signal})}#St(){const t=this._signal;window.addEventListener("focus",this.#st,{signal:t}),window.addEventListener("blur",this.#it,{signal:t})}#xt(){window.removeEventListener("focus",this.#st),window.removeEventListener("blur",this.#it)}blur(){if(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#kt("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#$)if(e.div.contains(t)){this.#V=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#V)return;const[t,e]=this.#V;this.#V=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#pt(){const t=this._signal;window.addEventListener("keydown",this.#ot,{signal:t}),window.addEventListener("keyup",this.#gt,{signal:t})}#Ft(){window.removeEventListener("keydown",this.#ot),window.removeEventListener("keyup",this.#gt)}#Rt(){const t=this._signal;document.addEventListener("copy",this.#at,{signal:t}),document.addEventListener("cut",this.#nt,{signal:t}),document.addEventListener("paste",this.#rt,{signal:t})}#vt(){document.removeEventListener("copy",this.#at),document.removeEventListener("cut",this.#nt),document.removeEventListener("paste",this.#rt)}#ft(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#pt(),this.#Rt()}removeEditListeners(){this.#Ft(),this.#vt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const A of this.#U)if(A.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const A of this.#U)if(A.isHandlingMimeForPasting(e.type))return A.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#$){const A=t.serialize(!0);A&&e.push(A)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#U)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let A=e.getData("application/pdfjs");if(!A)return;try{A=JSON.parse(A)}catch(t){return void xn(`paste: "${t.message}".`)}if(!Array.isArray(A))return;this.unselectAll();const i=this.currentLayer;try{const t=[];for(const e of A){const A=i.deserialize(e);if(!A)return;t.push(A)}const e=()=>{for(const e of t)this.#Nt(e);this.#Mt(t)},s=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:s,mustExec:!0})}catch(t){xn(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#z===Bn.NONE||this.isEditorHandlingKeyboard||Nr._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#kt("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#Dt(t){Object.entries(t).some((([t,e])=>this.#dt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#dt,t)}),this.#z===Bn.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Gt([[Qn.HIGHLIGHT_FREE,!0]]))}#Gt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#St(),this.#Rt(),this.#Dt({isEditing:this.#z!==Bn.NONE,isEmpty:this.#Lt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#xt(),this.#vt(),this.#Dt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#U){this.#U=t;for(const t of this.#U)this.#Gt(t.defaultPropertiesToUpdate)}}getId(){return this.#O.id}get currentLayer(){return this.#x.get(this.#M)}getLayer(t){return this.#x.get(t)}get currentPageIndex(){return this.#M}addLayer(t){this.#x.set(t.pageIndex,t),this.#W?t.enable():t.disable()}removeLayer(t){this.#x.delete(t.pageIndex)}updateMode(t,e=null,A=!1){if(this.#z!==t){if(this.#z=t,t===Bn.NONE)return this.setEditingState(!1),void this.#Ut();this.setEditingState(!0),this.#Ht(),this.unselectAll();for(const e of this.#x.values())e.updateMode(t);if(e||!A){if(e)for(const t of this.#S.values())if(t.annotationElementId===e){this.setSelected(t),t.enterInEditMode();break}}else this.addNewEditorFromKeyboard()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#z&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#U){switch(t){case Qn.CREATE:return void this.currentLayer.addNewEditor();case Qn.HIGHLIGHT_DEFAULT_COLOR:this.#Z?.updateColor(e);break;case Qn.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#At||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const A of this.#$)A.updateParams(t,e);for(const A of this.#U)A.updateDefaultParams(t,e)}}showAllEditors(t,e,A=!1){for(const A of this.#S.values())A.editorType===t&&A.show(e);(this.#At?.get(Qn.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Gt([[Qn.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#j!==t){this.#j=t;for(const e of this.#x.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#Ht(){if(!this.#W){this.#W=!0;for(const t of this.#x.values())t.enable();for(const t of this.#S.values())t.enable()}}#Ut(){if(this.unselectAll(),this.#W){this.#W=!1;for(const t of this.#x.values())t.disable();for(const t of this.#S.values())t.disable()}}getEditors(t){const e=[];for(const A of this.#S.values())A.pageIndex===t&&e.push(A);return e}getEditor(t){return this.#S.get(t)}addEditor(t){this.#S.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#T&&clearTimeout(this.#T),this.#T=setTimeout((()=>{this.focusMainContainer(),this.#T=null}),0)),this.#S.delete(t.id),this.unselect(t),t.annotationElementId&&this.#G.has(t.annotationElementId)||this.#R?.remove(t.id)}addDeletedAnnotationElement(t){this.#G.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#G.has(t)}removeDeletedAnnotationElement(t){this.#G.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Nt(t){const e=this.#x.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#k!==t&&(this.#k=t,t&&this.#Gt(t.propertiesToUpdate))}get#Jt(){let t=null;for(t of this.#$);return t}updateUI(t){this.#Jt===t&&this.#Gt(t.propertiesToUpdate)}toggleSelected(t){if(this.#$.has(t))return this.#$.delete(t),t.unselect(),void this.#Dt({hasSelectedEditor:this.hasSelection});this.#$.add(t),t.select(),this.#Gt(t.propertiesToUpdate),this.#Dt({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#$)e!==t&&e.unselect();this.#$.clear(),this.#$.add(t),t.select(),this.#Gt(t.propertiesToUpdate),this.#Dt({hasSelectedEditor:!0})}isSelected(t){return this.#$.has(t)}get firstSelectedEditor(){return this.#$.values().next().value}unselect(t){t.unselect(),this.#$.delete(t),this.#Dt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#$.size}get isEnterHandled(){return 1===this.#$.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#Dt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Lt()})}redo(){this.#N.redo(),this.#Dt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Lt()})}addCommands(t){this.#N.add(t),this.#Dt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Lt()})}#Lt(){if(0===this.#S.size)return!0;if(1===this.#S.size)for(const t of this.#S.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#$];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)this.#Nt(e)},mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#Mt(t){for(const t of this.#$)t.unselect();this.#$.clear();for(const e of t)e.isEmpty()||(this.#$.add(e),e.select());this.#Dt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#$)t.commit();this.#Mt(this.#S.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#z===Bn.NONE))&&this.hasSelection){for(const t of this.#$)t.unselect();this.#$.clear(),this.#Dt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,A=!1){if(A||this.commitOrRemove(),!this.hasSelection)return;this.#ut[0]+=t,this.#ut[1]+=e;const[i,s]=this.#ut,a=[...this.#$];this.#Ct&&clearTimeout(this.#Ct),this.#Ct=setTimeout((()=>{this.#Ct=null,this.#ut[0]=this.#ut[1]=0,this.addCommands({cmd:()=>{for(const t of a)this.#S.has(t.id)&&t.translateInPage(i,s)},undo:()=>{for(const t of a)this.#S.has(t.id)&&t.translateInPage(-i,-s)},mustExec:!1})}),1e3);for(const A of a)A.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#L=new Map;for(const t of this.#$)this.#L.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#L)return!1;this.disableUserSelect(!1);const t=this.#L;this.#L=null;let e=!1;for(const[{x:A,y:i,pageIndex:s},a]of t)a.newX=A,a.newY=i,a.newPageIndex=s,e||=A!==a.savedX||i!==a.savedY||s!==a.savedPageIndex;if(!e)return!1;const A=(t,e,A,i)=>{if(this.#S.has(t.id)){const s=this.#x.get(i);s?t._setParentAndPosition(s,e,A):(t.pageIndex=i,t.x=e,t.y=A)}};return this.addCommands({cmd:()=>{for(const[e,{newX:i,newY:s,newPageIndex:a}]of t)A(e,i,s,a)},undo:()=>{for(const[e,{savedX:i,savedY:s,savedPageIndex:a}]of t)A(e,i,s,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#L)for(const A of this.#L.keys())A.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.#$.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#k===t}getActive(){return this.#k}getMode(){return this.#z}get imageManager(){return Nn(this,"imageManager",new xr)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let A=0,i=e.rangeCount;A({x:(e-i)/a,y:1-(t+n-A)/s,width:r/a,height:n/s});break;case"180":n=(t,e,n,r)=>({x:1-(t+n-A)/s,y:1-(e+r-i)/a,width:n/s,height:r/a});break;case"270":n=(t,e,n,r)=>({x:1-(e+r-i)/a,y:(t-A)/s,width:r/a,height:n/s});break;default:n=(t,e,n,r)=>({x:(t-A)/s,y:(e-i)/a,width:n/s,height:r/a})}const r=[];for(let t=0,A=e.rangeCount;tt.stopPropagation()),{signal:A});const i=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a)};return t.addEventListener("click",i,{capture:!0,signal:A}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#qt=!0,i(e))}),{signal:A}),await this.#Ot(),t}finish(){this.#Tt&&(this.#Tt.focus({focusVisible:this.#qt}),this.#qt=!1)}isEmpty(){return!this.#_t&&!this.#Yt}get data(){return{altText:this.#_t,decorative:this.#Yt}}set data({altText:t,decorative:e}){this.#_t===t&&this.#Yt===e||(this.#_t=t,this.#Yt=e,this.#Ot())}toggle(t=!1){this.#Tt&&(!t&&this.#Kt&&(clearTimeout(this.#Kt),this.#Kt=null),this.#Tt.disabled=!t)}destroy(){this.#Tt?.remove(),this.#Tt=null,this.#Pt=null}async#Ot(){const t=this.#Tt;if(!t)return;if(!this.#_t&&!this.#Yt)return t.classList.remove("done"),void this.#Pt?.remove();t.classList.add("done"),Mr._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((e=>{t.setAttribute("aria-label",e)}));let e=this.#Pt;if(!e){this.#Pt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const A=e.id=`alt-text-tooltip-${this.#a.id}`;t.setAttribute("aria-describedby",A);const i=100,s=this.#a._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Kt),this.#Kt=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Kt=setTimeout((()=>{this.#Kt=null,this.#Pt.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Kt&&(clearTimeout(this.#Kt),this.#Kt=null),this.#Pt?.classList.remove("show")}),{signal:s})}e.innerText=this.#Yt?await Mr._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#_t,e.parentNode||t.append(e);const A=this.#a.getImageForAltText();A?.setAttribute("aria-describedby",e.id)}}class Gr{#Wt=null;#jt=null;#_t=null;#Vt=!1;#Zt=!1;#Xt=null;#zt=null;#$t=this.focusin.bind(this);#te=this.focusout.bind(this);#ee=null;#Ae="";#ie=!1;#se=null;#ae=!1;#ne=!1;#re=!1;#oe=null;#ge=0;#ce=0;#he=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#le=!1;#Ie=Gr._zIndex++;static _borderLineWidth=-1;static _colorManager=new vr;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Gr.prototype._resizeWithKeyboard,e=Nr.TRANSLATE_SMALL,A=Nr.TRANSLATE_BIG;return Nn(this,"_resizerKeyboardManager",new Rr([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-A,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[A,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-A]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,A]}],[["Escape","mac+Escape"],Gr.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===Gr&&Fn("Cannot initialize AnnotationEditor."),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:A,pageHeight:i,pageX:s,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[A,i],this.pageTranslation=[s,a];const[n,r]=this.parentDimensions;this.x=t.x/n,this.y=t.y/r,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return Nn(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Lr({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,A){if(Gr._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map((e=>[e,t.get(e.replaceAll(/([A-Z])/g,(t=>`-${t.toLowerCase()}`)))]))),A?.strings)for(const e of A.strings)Gr._l10nPromise.set(e,t.get(e));if(-1!==Gr._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Gr._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Fn("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#le}set _isDraggable(t){this.#le=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.#ie?this.#ie=!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,A,i){const[s,a]=this.parentDimensions;[A,i]=this.screenToPageTranslation(A,i),this.x=(t+A)/s,this.y=(e+i)/a,this.fixAndSetPosition()}#ue([t,e],A,i){[A,i]=this.screenToPageTranslation(A,i),this.x+=A/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#ue(this.parentDimensions,t,e)}translateInPage(t,e){this.#se||=[this.x,this.y],this.#ue(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#se||=[this.x,this.y];const[A,i]=this.parentDimensions;if(this.x+=t/A,this.y+=e/i,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:s,y:a}=this;const[n,r]=this.getBaseTranslation();s+=n,a+=r,this.div.style.left=`${(100*s).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#se&&(this.#se[0]!==this.x||this.#se[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:A}=Gr,i=A/t,s=A/e;switch(this.rotation){case 90:return[-i,s];case 180:return[i,s];case 270:return[i,-s];default:return[-i,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,A]=this.pageDimensions;let{x:i,y:s,width:a,height:n}=this;if(a*=e,n*=A,i*=e,s*=A,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-a,i)),s=Math.max(0,Math.min(A-n,s));break;case 90:i=Math.max(0,Math.min(e-n,i)),s=Math.min(A,Math.max(a,s));break;case 180:i=Math.min(e,Math.max(a,i)),s=Math.min(A,Math.max(n,s));break;case 270:i=Math.min(e,Math.max(n,i)),s=Math.max(0,Math.min(A-a,s))}this.x=i/=e,this.y=s/=A;const[r,o]=this.getBaseTranslation();i+=r,s+=o;const{style:g}=this.div;g.left=`${(100*i).toFixed(2)}%`,g.top=`${(100*s).toFixed(2)}%`,this.moveInDOM()}static#Ce(t,e,A){switch(A){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Gr.#Ce(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Gr.#Ce(t,e,360-this.parentRotation)}#Be(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,A]}=this,i=e*t,s=A*t;return qn.isCSSRoundSupported?[Math.round(i),Math.round(s)]:[i,s]}setDims(t,e){const[A,i]=this.parentDimensions;this.div.style.width=`${(100*t/A).toFixed(2)}%`,this.#Zt||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:A}=t,i=A.endsWith("%"),s=!this.#Zt&&e.endsWith("%");if(i&&s)return;const[a,n]=this.parentDimensions;i||(t.width=`${(100*parseFloat(A)/a).toFixed(2)}%`),this.#Zt||s||(t.height=`${(100*parseFloat(e)/n).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Qe(){if(this.#Xt)return;this.#Xt=document.createElement("div"),this.#Xt.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 A of t){const t=document.createElement("div");this.#Xt.append(t),t.classList.add("resizer",A),t.setAttribute("data-resizer-name",A),t.addEventListener("pointerdown",this.#Ee.bind(this,A),{signal:e}),t.addEventListener("contextmenu",Br,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Xt)}#Ee(t,e){e.preventDefault();const{isMac:A}=qn.platform;if(0!==e.button||e.ctrlKey&&A)return;this.#_t?.toggle(!1);const i=this.#fe.bind(this,t),s=this._isDraggable;this._isDraggable=!1;const a=this._uiManager._signal,n={passive:!0,capture:!0,signal:a};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,n),window.addEventListener("contextmenu",Br,{signal:a});const r=this.x,o=this.y,g=this.width,c=this.height,h=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const I=()=>{this.parent.togglePointerEvents(!0),this.#_t?.toggle(!0),this._isDraggable=s,window.removeEventListener("pointerup",I),window.removeEventListener("blur",I),window.removeEventListener("pointermove",i,n),window.removeEventListener("contextmenu",Br),this.parent.div.style.cursor=h,this.div.style.cursor=l,this.#pe(r,o,g,c)};window.addEventListener("pointerup",I,{signal:a}),window.addEventListener("blur",I,{signal:a})}#pe(t,e,A,i){const s=this.x,a=this.y,n=this.width,r=this.height;s===t&&a===e&&n===A&&r===i||this.addCommands({cmd:()=>{this.width=n,this.height=r,this.x=s,this.y=a;const[t,e]=this.parentDimensions;this.setDims(t*n,e*r),this.fixAndSetPosition()},undo:()=>{this.width=A,this.height=i,this.x=t,this.y=e;const[s,a]=this.parentDimensions;this.setDims(s*A,a*i),this.fixAndSetPosition()},mustExec:!0})}#fe(t,e){const[A,i]=this.parentDimensions,s=this.x,a=this.y,n=this.width,r=this.height,o=Gr.MIN_SIZE/A,g=Gr.MIN_SIZE/i,c=t=>Math.round(1e4*t)/1e4,h=this.#Be(this.rotation),l=(t,e)=>[h[0]*t+h[2]*e,h[1]*t+h[3]*e],I=this.#Be(360-this.rotation);let d,u,C=!1,B=!1;switch(t){case"topLeft":C=!0,d=(t,e)=>[0,0],u=(t,e)=>[t,e];break;case"topMiddle":d=(t,e)=>[t/2,0],u=(t,e)=>[t/2,e];break;case"topRight":C=!0,d=(t,e)=>[t,0],u=(t,e)=>[0,e];break;case"middleRight":B=!0,d=(t,e)=>[t,e/2],u=(t,e)=>[0,e/2];break;case"bottomRight":C=!0,d=(t,e)=>[t,e],u=(t,e)=>[0,0];break;case"bottomMiddle":d=(t,e)=>[t/2,e],u=(t,e)=>[t/2,0];break;case"bottomLeft":C=!0,d=(t,e)=>[0,e],u=(t,e)=>[t,0];break;case"middleLeft":B=!0,d=(t,e)=>[0,e/2],u=(t,e)=>[t,e/2]}const Q=d(n,r),E=u(n,r);let f=l(...E);const p=c(s+f[0]),m=c(a+f[1]);let y=1,b=1,[w,D]=this.screenToPageTranslation(e.movementX,e.movementY);if([w,D]=((t,e)=>[I[0]*t+I[2]*e,I[1]*t+I[3]*e])(w/A,D/i),C){const t=Math.hypot(n,r);y=b=Math.max(Math.min(Math.hypot(E[0]-Q[0]-w,E[1]-Q[1]-D)/t,1/n,1/r),o/n,g/r)}else B?y=Math.max(o,Math.min(1,Math.abs(E[0]-Q[0]-w)))/n:b=Math.max(g,Math.min(1,Math.abs(E[1]-Q[1]-D)))/r;const k=c(n*y),S=c(r*b);f=l(...u(k,S));const x=p-f[0],F=m-f[1];this.width=k,this.height=S,this.x=x,this.y=F,this.setDims(A*k,i*S),this.fixAndSetPosition()}altTextFinish(){this.#_t?.finish()}async addEditToolbar(){return this.#ee||this.#ne||(this.#ee=new wr(this),this.div.append(this.#ee.render()),this.#_t&&this.#ee.addAltTextButton(await this.#_t.render())),this.#ee}removeEditToolbar(){this.#ee&&(this.#ee.remove(),this.#ee=null,this.#_t?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#_t||(Mr.initialize(Gr._l10nPromise),this.#_t=new Mr(this),this.#Wt&&(this.#_t.data=this.#Wt,this.#Wt=null),await this.addEditToolbar())}get altTextData(){return this.#_t?.data}set altTextData(t){this.#_t&&(this.#_t.data=t)}hasAltText(){return!this.#_t?.isEmpty()}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.#Vt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#$t,{signal:t}),this.div.addEventListener("focusout",this.#te,{signal:t});const[e,A]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*A/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/A).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),kr(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=qn.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ie=!0,this._isDraggable?this.#me(t):this.#ye(t))}#ye(t){const{isMac:e}=qn.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#me(t){const e=this._uiManager.isSelected(this);let A,i;this._uiManager.setUpDragSession();const s=this._uiManager._signal;e&&(this.div.classList.add("moving"),A={passive:!0,capture:!0,signal:s},this.#ge=t.clientX,this.#ce=t.clientY,i=t=>{const{clientX:e,clientY:A}=t,[i,s]=this.screenToPageTranslation(e-this.#ge,A-this.#ce);this.#ge=e,this.#ce=A,this._uiManager.dragSelectedEditors(i,s)},window.addEventListener("pointermove",i,A));const a=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("blur",a),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,A)),this.#ie=!1,this._uiManager.endDragSession()||this.#ye(t)};window.addEventListener("pointerup",a,{signal:s}),window.addEventListener("blur",a,{signal:s})}moveInDOM(){this.#oe&&clearTimeout(this.#oe),this.#oe=setTimeout((()=>{this.#oe=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,A){t.changeParent(this),this.x=e,this.y=A,this.fixAndSetPosition()}getRect(t,e,A=this.rotation){const i=this.parentScale,[s,a]=this.pageDimensions,[n,r]=this.pageTranslation,o=t/i,g=e/i,c=this.x*s,h=this.y*a,l=this.width*s,I=this.height*a;switch(A){case 0:return[c+o+n,a-h-g-I+r,c+o+l+n,a-h-g+r];case 90:return[c+g+n,a-h+o+r,c+g+I+n,a-h+o+l+r];case 180:return[c-o-l+n,a-h+g+r,c-o+n,a-h+g+I+r];case 270:return[c-g-I+n,a-h-o-l+r,c-g+n,a-h-o+r];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[A,i,s,a]=t,n=s-A,r=a-i;switch(this.rotation){case 0:return[A,e-a,n,r];case 90:return[A,e-i,r,n];case 180:return[s,e-i,n,r];case 270:return[s,e-a,r,n];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#ne=!0}disableEditMode(){this.#ne=!1}isInEditMode(){return this.#ne}shouldGetKeyboardEvents(){return this.#re}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#$t,{signal:t}),this.div?.addEventListener("focusout",this.#te,{signal:t})}rotate(t){}serialize(t=!1,e=null){Fn("An editor must be serializable")}static deserialize(t,e,A){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:A});i.rotation=t.rotation,i.#Wt=t.accessibilityData;const[s,a]=i.pageDimensions,[n,r,o,g]=i.getRectInCurrentCoords(t.rect,a);return i.x=n/s,i.y=r/a,i.width=o/s,i.height=g/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",this.#$t),this.div.removeEventListener("focusout",this.#te),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#oe&&(clearTimeout(this.#oe),this.#oe=null),this.#de(),this.removeEditToolbar(),this.#he){for(const t of this.#he.values())clearTimeout(t);this.#he=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Qe(),this.#Xt.classList.remove("hidden"),kr(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.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#Xt.children;if(!this.#jt){this.#jt=Array.from(e);const t=this.#be.bind(this),A=this.#we.bind(this),i=this._uiManager._signal;for(const e of this.#jt){const s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:i}),e.addEventListener("blur",A,{signal:i}),e.addEventListener("focus",this.#De.bind(this,s),{signal:i}),Gr._l10nPromise.get(`pdfjs-editor-resizer-label-${s}`).then((t=>e.setAttribute("aria-label",t)))}}const A=this.#jt[0];let i=0;for(const t of e){if(t===A)break;i++}const s=(360-this.rotation+this.parentRotation)%360/90*(this.#jt.length/4);if(s!==i){if(si)for(let t=0;tA.setAttribute("aria-label",t)))}}this.#ke(0),this.#re=!0,this.#Xt.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#be(t){Gr._resizerKeyboardManager.exec(this,t)}#we(t){this.#re&&t.relatedTarget?.parentNode!==this.#Xt&&this.#de()}#De(t){this.#Ae=this.#re?t:""}#ke(t){if(this.#jt)for(const e of this.#jt)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#re&&this.#fe(this.#Ae,{movementX:t,movementY:e})}#de(){if(this.#re=!1,this.#ke(-1),this.#zt){const{savedX:t,savedY:e,savedWidth:A,savedHeight:i}=this.#zt;this.#pe(t,e,A,i),this.#zt=null}}_stopResizingWithKeyboard(){this.#de(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this.#ee?this.#ee?.show():this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this.#ee?.show()}))}unselect(){this.#Xt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#ee?.hide()}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.#Zt=!0;const A=t/e,{style:i}=this.div;i.aspectRatio=A,i.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.#he||=new Map;const{action:e}=t;let A=this.#he.get(e);return A&&clearTimeout(A),A=setTimeout((()=>{this._reportTelemetry(t),this.#he.delete(e),0===this.#he.size&&(this.#he=null)}),Gr._telemetryTimeout),void this.#he.set(e,A)}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.#Vt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Vt=!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 Lr extends Gr{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const Ur=3285377520,Hr=4294901760,Jr=65535;class _r{constructor(t){this.h1=t?4294967295&t:Ur,this.h2=t?4294967295&t:Ur}update(t){let e,A;if("string"==typeof t){e=new Uint8Array(2*t.length),A=0;for(let i=0,s=t.length;i>>8,e[A++]=255&s)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),A=e.byteLength}const i=A>>2,s=A-4*i,a=new Uint32Array(e.buffer,0,i);let n=0,r=0,o=this.h1,g=this.h2;const c=3432918353,h=461845907,l=11601,I=13715;for(let t=0;t>>17,n=n*h&Hr|n*I&Jr,o^=n,o=o<<13|o>>>19,o=5*o+3864292196):(r=a[t],r=r*c&Hr|r*l&Jr,r=r<<15|r>>>17,r=r*h&Hr|r*I&Jr,g^=r,g=g<<13|g>>>19,g=5*g+3864292196);switch(n=0,s){case 3:n^=e[4*i+2]<<16;case 2:n^=e[4*i+1]<<8;case 1:n^=e[4*i],n=n*c&Hr|n*l&Jr,n=n<<15|n>>>17,n=n*h&Hr|n*I&Jr,1&i?o^=n:g^=n}this.h1=o,this.h2=g}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Hr|36045*t&Jr,e=4283543511*e&Hr|(2950163797*(e<<16|t>>>16)&Hr)>>>16,t^=e>>>1,t=444984403*t&Hr|60499*t&Jr,e=3301882366*e&Hr|(3120437893*(e<<16|t>>>16)&Hr)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Yr=Object.freeze({map:null,hash:"",transfer:void 0});class Tr{#Se=!1;#xe=null;#Fe=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const A=this.#Fe.get(t);return void 0===A?e:Object.assign(e,A)}getRawValue(t){return this.#Fe.get(t)}remove(t){if(this.#Fe.delete(t),0===this.#Fe.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Fe.values())if(t instanceof Gr)return;this.onAnnotationEditor(null)}}setValue(t,e){const A=this.#Fe.get(t);let i=!1;if(void 0!==A)for(const[t,s]of Object.entries(e))A[t]!==s&&(i=!0,A[t]=s);else i=!0,this.#Fe.set(t,e);i&&this.#Re(),e instanceof Gr&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Fe.has(t)}getAll(){return this.#Fe.size>0?Kn(this.#Fe):null}setAll(t){for(const[e,A]of Object.entries(t))this.setValue(e,A)}get size(){return this.#Fe.size}#Re(){this.#Se||(this.#Se=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Se&&(this.#Se=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Pr(this)}get serializable(){if(0===this.#Fe.size)return Yr;const t=new Map,e=new _r,A=[],i=Object.create(null);let s=!1;for(const[A,a]of this.#Fe){const n=a instanceof Gr?a.serialize(!1,i):a;n&&(t.set(A,n),e.update(`${A}:${JSON.stringify(n)}`),s||=!!n.bitmap)}if(s)for(const e of t.values())e.bitmap&&A.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:A}:Yr}get editorStats(){let t=null;const e=new Map;for(const A of this.#Fe.values()){if(!(A instanceof Gr))continue;const i=A.telemetryFinalData;if(!i)continue;const{type:s}=i;e.has(s)||e.set(s,Object.getPrototypeOf(A).constructor),t||=Object.create(null);const a=t[s]||=new Map;for(const[t,e]of Object.entries(i)){if("type"===t)continue;let A=a.get(t);A||(A=new Map,a.set(t,A));const i=A.get(e)??0;A.set(e,i+1)}}for(const[A,i]of e)t[A]=i.computeTelemetryFinalData(t[A]);return t}resetModifiedIds(){this.#xe=null}get modifiedIds(){if(this.#xe)return this.#xe;const t=[];for(const e of this.#Fe.values())e instanceof Gr&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#xe={ids:new Set(t),hash:t.join(",")}}}class Pr extends Tr{#ve;constructor(t){super();const{map:e,hash:A,transfer:i}=t.serializable,s=structuredClone(e,i?{transfer:i}:null);this.#ve={map:s,hash:A,transfer:i}}get print(){Fn("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ve}get modifiedIds(){return Nn(this,"modifiedIds",{ids:new Set,hash:""})}}class Kr{#Ne=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.#Ne.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#Ne.has(t.loadedName))if(Rn(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:A,src:i,style:s}=t,a=new FontFace(A,i,s);this.addNativeFontFace(a);try{await a.load(),this.#Ne.add(A),e?.(t)}catch{xn(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else Fn("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(A){throw xn(`Failed to load font '${e.family}': '${A}'.`),t.disableFontFace=!0,A}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const A=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,A)}))}}get isFontLoadingAPISupported(){return Nn(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(ln||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Nn(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,A={done:!1,complete:function(){for(Rn(!A.done,"completeRequest() cannot be called twice."),A.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(A),A}get _loadTestFont(){return Nn(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function A(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function i(t,e,A,i){return t.substring(0,e)+i+t.substring(e+A)}let s,a;const n=this._document.createElement("canvas");n.width=1,n.height=1;const r=n.getContext("2d");let o=0;const g=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=i(c,976,g.length,g);const h=1482184792;let l=A(c,16);for(s=0,a=g.length-3;s>24&255,I>>16&255,I>>8&255,255&I)));const d=`@font-face {font-family:"${g}";src:url(data:font/opentype;base64,${btoa(c)});}`;this.insertRule(d);const u=this._document.createElement("div");u.style.visibility="hidden",u.style.width=u.style.height="10px",u.style.position="absolute",u.style.top=u.style.left="0px";for(const e of[t.loadedName,g]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,u.append(t)}this._document.body.append(u),function t(e,A){if(++o>30)return xn("Load test font never loaded."),void A();r.font="30px "+e,r.fillText(".",0,20),r.getImageData(0,0,1,1).data[3]>0?A():setTimeout(t.bind(null,e,A))}(g,(()=>{u.remove(),e.complete()}))}}class qr{constructor(t,{disableFontFace:e=!1,inspectFont:A=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this._inspectFont=A}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=Tn(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let A;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),A=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else A=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),A}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let A;try{A=t.get(this.loadedName+"_path_"+e)}catch(t){xn(`getPathGenerator - ignoring character: "${t}".`)}if(!Array.isArray(A)||0===A.length)return this.compiledGlyphs[e]=function(t,e){};const i=[];for(let t=0,e=A.length;tt.bezierCurveTo(e,s,a,n,r,o))),t+=6}break;case 1:{const[e,s]=A.slice(t,t+2);i.push((t=>t.moveTo(e,s))),t+=2}break;case 2:{const[e,s]=A.slice(t,t+2);i.push((t=>t.lineTo(e,s))),t+=2}break;case 3:{const[e,s,a,n]=A.slice(t,t+4);i.push((t=>t.quadraticCurveTo(e,s,a,n))),t+=4}break;case 4:i.push((t=>t.restore()));break;case 5:i.push((t=>t.save()));break;case 6:Rn(2===i.length,"Scale command is only valid at the third position.");break;case 7:{const[e,s,a,n,r,o]=A.slice(t,t+6);i.push((t=>t.transform(e,s,a,n,r,o))),t+=6}break;case 8:{const[e,s]=A.slice(t,t+2);i.push((t=>t.translate(e,s))),t+=2}}return this.compiledGlyphs[e]=function(t,e){i[0](t),i[1](t),t.scale(e,-e);for(let e=2,A=i.length;e{const t=await import("fs"),e=await import("http"),A=await import("https"),i=await import("url");return new Map(Object.entries({fs:t,http:e,https:A,url:i,canvas:void 0,path2d:void 0}))};t().then((t=>{Wr=t,Or.resolve()}),(t=>{xn(`loadPackages: ${t}`),Wr=new Map,Or.resolve()}))}class jr{static get promise(){return Or.promise}static get(t){return Wr?.get(t)}}const Vr=function(t){return jr.get("fs").promises.readFile(t).then((t=>new Uint8Array(t)))},Zr="Fill",Xr="Stroke",zr="Shading";function $r(t,e){if(!e)return;const A=e[2]-e[0],i=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],A,i),t.clip(s)}class to{constructor(){this.constructor===to&&Fn("Cannot initialize BaseShadingPattern.")}getPattern(){Fn("Abstract method `getPattern` called.")}}class eo extends to{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,A,i){let s;if(i===Xr||i===Zr){const a=e.current.getClippedPathBoundingBox(i,mr(t))||[0,0,0,0],n=Math.ceil(a[2]-a[0])||1,r=Math.ceil(a[3]-a[1])||1,o=e.cachedCanvases.getCanvas("pattern",n,r,!0),g=o.context;g.clearRect(0,0,g.canvas.width,g.canvas.height),g.beginPath(),g.rect(0,0,g.canvas.width,g.canvas.height),g.translate(-a[0],-a[1]),A=Wn.transform(A,[1,0,0,1,a[0],a[1]]),g.transform(...e.baseTransform),this.matrix&&g.transform(...this.matrix),$r(g,this._bbox),g.fillStyle=this._createGradient(g),g.fill(),s=t.createPattern(o.canvas,"no-repeat");const c=new DOMMatrix(A);s.setTransform(c)}else $r(t,this._bbox),s=this._createGradient(t);return s}}function Ao(t,e,A,i,s,a,n,r){const o=e.coords,g=e.colors,c=t.data,h=4*t.width;let l;o[A+1]>o[i+1]&&(l=A,A=i,i=l,l=a,a=n,n=l),o[i+1]>o[s+1]&&(l=i,i=s,s=l,l=n,n=r,r=l),o[A+1]>o[i+1]&&(l=A,A=i,i=l,l=a,a=n,n=l);const I=(o[A]+e.offsetX)*e.scaleX,d=(o[A+1]+e.offsetY)*e.scaleY,u=(o[i]+e.offsetX)*e.scaleX,C=(o[i+1]+e.offsetY)*e.scaleY,B=(o[s]+e.offsetX)*e.scaleX,Q=(o[s+1]+e.offsetY)*e.scaleY;if(d>=Q)return;const E=g[a],f=g[a+1],p=g[a+2],m=g[n],y=g[n+1],b=g[n+2],w=g[r],D=g[r+1],k=g[r+2],S=Math.round(d),x=Math.round(Q);let F,R,v,N,M,G,L,U;for(let t=S;t<=x;t++){if(tQ?1:C===Q?0:(C-t)/(C-Q),F=u-(u-B)*e,R=m-(m-w)*e,v=y-(y-D)*e,N=b-(b-k)*e}let e;e=tQ?1:(d-t)/(d-Q),M=I-(I-B)*e,G=E-(E-w)*e,L=f-(f-D)*e,U=p-(p-k)*e;const A=Math.round(Math.min(F,M)),i=Math.round(Math.max(F,M));let s=h*t+4*A;for(let t=A;t<=i;t++)e=(F-t)/(F-M),e<0?e=0:e>1&&(e=1),c[s++]=R-(R-G)*e|0,c[s++]=v-(v-L)*e|0,c[s++]=N-(N-U)*e|0,c[s++]=255}}function io(t,e,A){const i=e.coords,s=e.colors;let a,n;switch(e.type){case"lattice":const r=e.verticesPerRow,o=Math.floor(i.length/r)-1,g=r-1;for(a=0;a=i?s=i:A=s/t,{scale:A,size:s}}clipBbox(t,e,A,i,s){const a=i-e,n=s-A;t.ctx.rect(e,A,a,n),t.current.updateRectMinMax(mr(t.ctx),[e,A,i,s]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,A){const i=t.ctx,s=t.current;switch(e){case 1:const t=this.ctx;i.fillStyle=t.fillStyle,i.strokeStyle=t.strokeStyle,s.fillColor=t.fillStyle,s.strokeColor=t.strokeStyle;break;case 2:const a=Wn.makeHexColor(A[0],A[1],A[2]);i.fillStyle=a,i.strokeStyle=a,s.fillColor=a,s.strokeColor=a;break;default:throw new _n(`Unsupported paint type: ${e}`)}}getPattern(t,e,A,i){let s=A;i!==zr&&(s=Wn.transform(s,e.baseTransform),this.matrix&&(s=Wn.transform(s,this.matrix)));const a=this.createPatternCanvas(e);let n=new DOMMatrix(s);n=n.translate(a.offsetX,a.offsetY),n=n.scale(1/a.scaleX,1/a.scaleY);const r=t.createPattern(a.canvas,"repeat");return r.setTransform(n),r}}function ro({src:t,srcPos:e=0,dest:A,width:i,height:s,nonBlackColor:a=4294967295,inverseDecode:n=!1}){const r=qn.isLittleEndian?4278190080:255,[o,g]=n?[a,r]:[r,a],c=i>>3,h=7&i,l=t.length;A=new Uint32Array(A.buffer);let I=0;for(let i=0;i>2),u=A.length,C=i+7>>3,B=4294967295,Q=qn.isLittleEndian?4278190080:255;for(l=0;lC?i:8*t-7,n=-8&a;let r=0,h=0;for(;s>=1}for(;o=a&&(d=s,u=i*d),o=0,I=u;I--;)h[o++]=c[g++],h[o++]=c[g++],h[o++]=c[g++],h[o++]=255;t.putImageData(r,0,l*oo)}}}function Io(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const A=e.height,i=e.width,s=A%oo,a=(A-s)/oo,n=0===s?a:a+1,r=t.createImageData(i,oo);let o=0;const g=e.data,c=r.data;for(let e=0;e10&&"function"==typeof A,g=o?Date.now()+15:0;let c=0;const h=this.commonObjs,l=this.objs;let I;for(;;){if(void 0!==i&&n===i.nextBreakPoint)return i.breakIt(n,A),n;if(I=a[n],I!==yn.dependency)this[I].apply(this,s[n]);else for(const t of s[n]){const e=t.startsWith("g_")?h:l;if(!e.has(t))return e.get(t,A),n}if(n++,n===r)return n;if(o&&++c>10){if(Date.now()>g)return A(),n;c=0}}}#Me(){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.#Me(),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.#Ge()}#Ge(){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 A=t.width,i=t.height;let s,a,n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),o=A,g=i,c="prescale1";for(;n>2&&o>1||r>2&&g>1;){let e=o,A=g;n>2&&o>1&&(e=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),n/=o/e),r>2&&g>1&&(A=g>=16384?Math.floor(g/2)-1||1:Math.ceil(g)/2,r/=g/A),s=this.cachedCanvases.getCanvas(c,e,A),a=s.context,a.clearRect(0,0,e,A),a.drawImage(t,0,0,o,g,0,0,e,A),t=s.canvas,o=e,g=A,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:g}}_createMaskCanvas(t){const e=this.ctx,{width:A,height:i}=t,s=this.current.fillColor,a=this.current.patternFill,n=mr(e);let r,o,g,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;o=JSON.stringify(a?n:[n.slice(0,4),s]),r=this._cachedBitmapsMap.get(e),r||(r=new Map,this._cachedBitmapsMap.set(e,r));const A=r.get(o);if(A&&!a)return{canvas:A,offsetX:Math.round(Math.min(n[0],n[2])+n[4]),offsetY:Math.round(Math.min(n[1],n[3])+n[5])};g=A}g||(c=this.cachedCanvases.getCanvas("maskCanvas",A,i),Io(c.context,t));let h=Wn.transform(n,[1/A,0,0,-1/i,0,0]);h=Wn.transform(h,[1,0,0,1,0,-i]);const[l,I,d,u]=Wn.getAxialAlignedBoundingBox([0,0,A,i],h),C=Math.round(d-l)||1,B=Math.round(u-I)||1,Q=this.cachedCanvases.getCanvas("fillCanvas",C,B),E=Q.context,f=l,p=I;E.translate(-f,-p),E.transform(...h),g||(g=this._scaleImage(c.canvas,yr(E)),g=g.img,r&&a&&r.set(o,g)),E.imageSmoothingEnabled=Bo(mr(E),t.interpolate),co(E,g,0,0,g.width,g.height,0,0,A,i),E.globalCompositeOperation="source-in";const m=Wn.transform(yr(E),[1,0,0,1,-f,-p]);return E.fillStyle=a?s.getPattern(e,this,m,Zr):s,E.fillRect(0,0,A,i),r&&!a&&(this.cachedCanvases.delete("fillCanvas"),r.set(o,Q.canvas)),{canvas:Q.canvas,offsetX:Math.round(f),offsetY:Math.round(p)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Qo[t]}setLineJoin(t){this.ctx.lineJoin=Eo[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const A=this.ctx;void 0!==A.setLineDash&&(A.setLineDash(t),A.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,A]of t)switch(e){case"LW":this.setLineWidth(A);break;case"LC":this.setLineCap(A);break;case"LJ":this.setLineJoin(A);break;case"ML":this.setMiterLimit(A);break;case"D":this.setDash(A[0],A[1]);break;case"RI":this.setRenderingIntent(A);break;case"FL":this.setFlatness(A);break;case"Font":this.setFont(A[0],A[1]);break;case"CA":this.current.strokeAlpha=A;break;case"ca":this.current.fillAlpha=A,this.ctx.globalAlpha=A;break;case"BM":this.ctx.globalCompositeOperation=A;break;case"SMask":this.current.activeSMask=A?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(A)}}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,A="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(A,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const s=this.ctx;s.setTransform(...mr(this.suspendedCtx)),uo(this.suspendedCtx,s),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,A){e.translate(t,A),this.__originalTranslate(t,A)},t.scale=function(t,A){e.scale(t,A),this.__originalScale(t,A)},t.transform=function(t,A,i,s,a,n){e.transform(t,A,i,s,a,n),this.__originalTransform(t,A,i,s,a,n)},t.setTransform=function(t,A,i,s,a,n){e.setTransform(t,A,i,s,a,n),this.__originalSetTransform(t,A,i,s,a,n)},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,A){e.moveTo(t,A),this.__originalMoveTo(t,A)},t.lineTo=function(t,A){e.lineTo(t,A),this.__originalLineTo(t,A)},t.bezierCurveTo=function(t,A,i,s,a,n){e.bezierCurveTo(t,A,i,s,a,n),this.__originalBezierCurveTo(t,A,i,s,a,n)},t.rect=function(t,A,i,s){e.rect(t,A,i,s),this.__originalRect(t,A,i,s)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(s,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(),uo(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,A=this.suspendedCtx;this.composeSMask(A,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,A,i){const s=i[0],a=i[1],n=i[2]-s,r=i[3]-a;0!==n&&0!==r&&(this.genericComposeSMask(e.context,A,n,r,e.subtype,e.backdrop,e.transferMap,s,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(A.canvas,0,0),t.restore())}genericComposeSMask(t,e,A,i,s,a,n,r,o,g,c){let h=t.canvas,l=r-g,I=o-c;if(a)if(l<0||I<0||l+A>h.width||I+i>h.height){const t=this.cachedCanvases.getCanvas("maskExtension",A,i),e=t.context;e.drawImage(h,-l,-I),a.some((t=>0!==t))&&(e.globalCompositeOperation="destination-atop",e.fillStyle=Wn.makeHexColor(...a),e.fillRect(0,0,A,i),e.globalCompositeOperation="source-over"),h=t.canvas,l=I=0}else if(a.some((t=>0!==t))){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(l,I,A,i),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=Wn.makeHexColor(...a),t.fillRect(l,I,A,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===s&&n?e.filter=this.filterFactory.addAlphaFilter(n):"Luminosity"===s&&(e.filter=this.filterFactory.addLuminosityFilter(n));const d=new Path2D;d.rect(r,o,A,i),e.clip(d),e.globalCompositeOperation="destination-in",e.drawImage(h,l,I,A,i,r,o,A,i),e.restore()}save(){this.inSMaskMode?(uo(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(),uo(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,A,i,s,a){this.ctx.transform(t,e,A,i,s,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,A){const i=this.ctx,s=this.current;let a,n,r=s.x,o=s.y;const g=mr(i),c=0===g[0]&&0===g[3]||0===g[1]&&0===g[2],h=c?A.slice(0):null;for(let A=0,l=0,I=t.length;A100&&(o=100),this.current.fontSizeScale=e/o,this.ctx.font=`${r} ${n} ${o}px ${a}`}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,A,i,s,a){this.current.textMatrix=[t,e,A,i,s,a],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)}paintChar(t,e,A,i){const s=this.ctx,a=this.current,n=a.font,r=a.textRenderingMode,o=a.fontSize/a.fontSizeScale,g=3&r,c=!!(4&r),h=a.patternFill&&!n.missingFile;let l;(n.disableFontFace||c||h)&&(l=n.getPathGenerator(this.commonObjs,t)),n.disableFontFace||h?(s.save(),s.translate(e,A),s.beginPath(),l(s,o),i&&s.setTransform(...i),0!==g&&2!==g||s.fill(),1!==g&&2!==g||s.stroke(),s.restore()):(0!==g&&2!==g||s.fillText(t,e,A),1!==g&&2!==g||s.strokeText(t,e,A)),c&&(this.pendingTextPaths||=[]).push({transform:mr(s),x:e,y:A,fontSize:o,addToPath:l})}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 A=!1;for(let t=3;t0&&e[t]<255){A=!0;break}return Nn(this,"isFontSubpixelAAEnabled",A)}showText(t){const e=this.current,A=e.font;if(A.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(0===i)return;const s=this.ctx,a=e.fontSizeScale,n=e.charSpacing,r=e.wordSpacing,o=e.fontDirection,g=e.textHScale*o,c=t.length,h=A.vertical,l=h?1:-1,I=A.defaultVMetrics,d=i*e.fontMatrix[0],u=0===e.textRenderingMode&&!A.disableFontFace&&!e.patternFill;let C;if(s.save(),s.transform(...e.textMatrix),s.translate(e.x,e.y+e.textRise),o>0?s.scale(g,-1):s.scale(g,1),e.patternFill){s.save();const t=e.fillColor.getPattern(s,this,yr(s),Zr);C=mr(s),s.restore(),s.fillStyle=t}let B=e.lineWidth;const Q=e.textMatrixScale;if(0===Q||0===B){const t=3&e.textRenderingMode;1!==t&&2!==t||(B=this.getSinglePixelWidth())}else B/=Q;if(1!==a&&(s.scale(a,a),B/=a),s.lineWidth=B,A.isInvalidPDFjsFont){const A=[];let i=0;for(const e of t)A.push(e.unicode),i+=e.width;return s.fillText(A.join(""),0,0),e.x+=i*d*g,s.restore(),void this.compose()}let E,f=0;for(E=0;E0){const t=1e3*s.measureText(B).width/i*a;if(ynew mo(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new no(t,A,this.ctx,s,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,A){this.ctx.strokeStyle=this.current.strokeColor=Wn.makeHexColor(t,e,A)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,A){this.ctx.fillStyle=this.current.fillColor=Wn.makeHexColor(t,e,A),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let A;return this.cachedPatterns.has(t)?A=this.cachedPatterns.get(t):(A=function(t){switch(t[0]){case"RadialAxial":return new eo(t);case"Mesh":return new so(t);case"Dummy":return new ao}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,A)),e&&(A.matrix=e),A}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const A=this._getPattern(t);e.fillStyle=A.getPattern(e,this,yr(e),zr);const i=yr(e);if(i){const{width:t,height:A}=e.canvas,[s,a,n,r]=Wn.getAxialAlignedBoundingBox([0,0,t,A],i);this.ctx.fillRect(s,a,n-s,r-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Fn("Should not call beginInlineImage")}beginImageData(){Fn("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=mr(this.ctx),e)){const t=e[2]-e[0],A=e[3]-e[1];this.ctx.rect(e[0],e[1],t,A),this.current.updateRectMinMax(mr(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||Sn("TODO: Support non-isolated groups."),t.knockout&&xn("Knockout groups not supported.");const A=mr(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=Wn.getAxialAlignedBoundingBox(t.bbox,mr(e));const s=[0,0,e.canvas.width,e.canvas.height];i=Wn.intersect(i,s)||[0,0,0,0];const a=Math.floor(i[0]),n=Math.floor(i[1]),r=Math.max(Math.ceil(i[2])-a,1),o=Math.max(Math.ceil(i[3])-n,1);this.current.startNewPathAndClipBox([0,0,r,o]);let g="groupAt"+this.groupLevel;t.smask&&(g+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(g,r,o),h=c.context;h.translate(-a,-n),h.transform(...A),t.smask?this.smaskStack.push({canvas:c.canvas,context:h,offsetX:a,offsetY:n,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(a,n),e.save()),uo(e,h),this.ctx=h,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,A=this.groupStack.pop();if(this.ctx=A,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=mr(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const A=Wn.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(A)}}beginAnnotation(t,e,A,i,s){if(this.#Me(),Co(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const i=e[2]-e[0],a=e[3]-e[1];if(s&&this.annotationCanvasMap){(A=A.slice())[4]-=e[0],A[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=i,e[3]=a;const[s,n]=Wn.singularValueDecompose2dScale(mr(this.ctx)),{viewportScale:r}=this,o=Math.ceil(i*this.outputScaleX*r),g=Math.ceil(a*this.outputScaleY*r);this.annotationCanvas=this.canvasFactory.create(o,g);const{canvas:c,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(t,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(s,0,0,-n,0,a*n),Co(this.ctx)}else Co(this.ctx),this.ctx.rect(e[0],e[1],i,a),this.ctx.clip(),this.endPath()}this.current=new ho(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...A),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Ge(),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 A=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(t){const{width:e,height:A}=t;if(e>1e3||A>1e3)return null;const i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),s=e+1;let a,n,r,o=new Uint8Array(s*(A+1));const g=e+7&-8;let c=new Uint8Array(g*A),h=0;for(const e of t.data){let t=128;for(;t>0;)c[h++]=e&t?0:255,t>>=1}let l=0;for(h=0,0!==c[h]&&(o[0]=1,++l),n=1;n>2)+(c[h+1]?4:0)+(c[h-g+1]?8:0),i[t]&&(o[r+n]=i[t],++l),h++;if(c[h-g]!==c[h]&&(o[r+n]=c[h]?2:4,++l),l>1e3)return null}for(h=g*(A-1),r=a*s,0!==c[h]&&(o[r]=8,++l),n=1;n1e3)return null;const I=new Int32Array([0,s,-1,0,-s,0,0,0,1]),d=new Path2D;for(a=0;l&&a<=A;a++){let t=a*s;const A=t+e;for(;t>4,o[t]&=n>>2|n<<2),d.lineTo(t%s,t/s|0),o[t]||--l}while(i!==t);--a}return c=null,o=null,function(t){t.save(),t.scale(1/e,-1/A),t.translate(0,-A),t.fill(d),t.beginPath(),t.restore()}}(t)),i.compiled))return void i.compiled(A);const s=this._createMaskCanvas(t),a=s.canvas;A.save(),A.setTransform(1,0,0,1,0,0),A.drawImage(a,s.offsetX,s.offsetY),A.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,A=0,i=0,s,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const n=this.ctx;n.save();const r=mr(n);n.transform(e,A,i,s,0,0);const o=this._createMaskCanvas(t);n.setTransform(1,0,0,1,o.offsetX-r[4],o.offsetY-r[5]);for(let t=0,g=a.length;te?g/e:1,n=o>e?o/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=n}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:A}=this.current,[i,s]=this.getScaleForStroking();if(e.lineWidth=A||1,1===i&&1===s)return void e.stroke();const a=e.getLineDash();if(t&&e.save(),e.scale(i,s),a.length>0){const t=Math.max(i,s);e.setLineDash(a.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 yn)void 0!==mo.prototype[t]&&(mo.prototype[yn[t]]=mo.prototype[t]);class yo{static#Le=null;static#Ue="";static get workerPort(){return this.#Le}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Le=t}static get workerSrc(){return this.#Ue}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Ue=t}}function bo(t){switch(t instanceof Error||"object"==typeof t&&null!==t||Fn('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Yn(t.message);case"MissingPDFException":return new Hn(t.message);case"PasswordException":return new Gn(t.message,t.code);case"UnexpectedResponseException":return new Jn(t.message,t.status);case"UnknownErrorException":return new Ln(t.message,t.details);default:return new Ln(t.message,t.toString())}}class wo{constructor(t,e,A){this.sourceName=t,this.targetName=e,this.comObj=A,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#He(e);if(e.callback){const t=e.callbackId,A=this.callbackCapabilities[t];if(!A)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)A.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");A.reject(bo(e.reason))}return}const i=this.actionHandler[e.action];if(!i)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,s=e.sourceName;new Promise((function(t){t(i(e.data))})).then((function(i){A.postMessage({sourceName:t,targetName:s,callback:1,callbackId:e.callbackId,data:i})}),(function(i){A.postMessage({sourceName:t,targetName:s,callback:2,callbackId:e.callbackId,reason:bo(i)})}))}else e.streamId?this.#Je(e):i(e.data)},A.addEventListener("message",this._onComObjOnMessage)}on(t,e){const A=this.actionHandler;if(A[t])throw new Error(`There is already an actionName called "${t}"`);A[t]=e}send(t,e,A){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},A)}sendWithPromise(t,e,A){const i=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[i]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},A)}catch(t){s.reject(t)}return s.promise}sendWithStream(t,e,A,i){const s=this.streamId++,a=this.sourceName,n=this.targetName,r=this.comObj;return new ReadableStream({start:A=>{const o=Promise.withResolvers();return this.streamControllers[s]={controller:A,startCall:o,pullCall:null,cancelCall:null,isClosed:!1},r.postMessage({sourceName:a,targetName:n,action:t,streamId:s,data:e,desiredSize:A.desiredSize},i),o.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[s].pullCall=e,r.postMessage({sourceName:a,targetName:n,stream:6,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{Rn(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[s].cancelCall=e,this.streamControllers[s].isClosed=!0,r.postMessage({sourceName:a,targetName:n,stream:1,streamId:s,reason:bo(t)}),e.promise}},A)}#Je(t){const e=t.streamId,A=this.sourceName,i=t.sourceName,s=this.comObj,a=this,n=this.actionHandler[t.action],r={enqueue(t,a=1,n){if(this.isCancelled)return;const r=this.desiredSize;this.desiredSize-=a,r>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:A,targetName:i,stream:4,streamId:e,chunk:t},n)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:A,targetName:i,stream:3,streamId:e}),delete a.streamSinks[e])},error(t){Rn(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:A,targetName:i,stream:5,streamId:e,reason:bo(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};r.sinkCapability.resolve(),r.ready=r.sinkCapability.promise,this.streamSinks[e]=r,new Promise((function(e){e(n(t.data,r))})).then((function(){s.postMessage({sourceName:A,targetName:i,stream:8,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:A,targetName:i,stream:8,streamId:e,reason:bo(t)})}))}#He(t){const e=t.streamId,A=this.sourceName,i=t.sourceName,s=this.comObj,a=this.streamControllers[e],n=this.streamSinks[e];switch(t.stream){case 8:t.success?a.startCall.resolve():a.startCall.reject(bo(t.reason));break;case 7:t.success?a.pullCall.resolve():a.pullCall.reject(bo(t.reason));break;case 6:if(!n){s.postMessage({sourceName:A,targetName:i,stream:7,streamId:e,success:!0});break}n.desiredSize<=0&&t.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=t.desiredSize,new Promise((function(t){t(n.onPull?.())})).then((function(){s.postMessage({sourceName:A,targetName:i,stream:7,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:A,targetName:i,stream:7,streamId:e,reason:bo(t)})}));break;case 4:if(Rn(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case 3:if(Rn(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#_e(a,e);break;case 5:Rn(a,"error should have stream controller"),a.controller.error(bo(t.reason)),this.#_e(a,e);break;case 2:t.success?a.cancelCall.resolve():a.cancelCall.reject(bo(t.reason)),this.#_e(a,e);break;case 1:if(!n)break;new Promise((function(e){e(n.onCancel?.(bo(t.reason)))})).then((function(){s.postMessage({sourceName:A,targetName:i,stream:2,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:A,targetName:i,stream:2,streamId:e,reason:bo(t)})})),n.sinkCapability.reject(bo(t.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#_e(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class Do{#Ye;#Te;constructor({parsedData:t,rawData:e}){this.#Ye=t,this.#Te=e}getRaw(){return this.#Te}get(t){return this.#Ye.get(t)??null}getAll(){return Kn(this.#Ye)}has(t){return this.#Ye.has(t)}}const ko=Symbol("INTERNAL");class So{#Pe=!1;#Ke=!1;#qe=!1;#Oe=!0;constructor(t,{name:e,intent:A,usage:i}){this.#Pe=!!(2&t),this.#Ke=!!(4&t),this.name=e,this.intent=A,this.usage=i}get visible(){if(this.#qe)return this.#Oe;if(!this.#Oe)return!1;const{print:t,view:e}=this.usage;return this.#Pe?"OFF"!==e?.viewState:!this.#Ke||"OFF"!==t?.printState}_setVisible(t,e,A=!1){t!==ko&&Fn("Internal method `_setVisible` called."),this.#qe=A,this.#Oe=e}}class xo{#We=null;#je=new Map;#Ve=null;#Ze=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#Ze=t.order;for(const A of t.groups)this.#je.set(A.id,new So(e,A));if("OFF"===t.baseState)for(const t of this.#je.values())t._setVisible(ko,!1);for(const e of t.on)this.#je.get(e)._setVisible(ko,!0);for(const e of t.off)this.#je.get(e)._setVisible(ko,!1);this.#Ve=this.getHash()}}#Xe(t){const e=t.length;if(e<2)return!0;const A=t[0];for(let i=1;i0?Kn(this.#je):null}getGroup(t){return this.#je.get(t)||null}getHash(){if(null!==this.#We)return this.#We;const t=new _r;for(const[e,A]of this.#je)t.update(`${e}:${A.visible}`);return this.#We=t.hexdigest()}}class Fo{constructor(t,{disableRange:e=!1,disableStream:A=!1}){Rn(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:s,progressiveDone:a,contentDispositionFilename:n}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=n,s?.length>0){const t=s instanceof Uint8Array&&s.byteLength===s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!A,this._isRangeSupported=!e,this._contentLength=i,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 A=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(A):this._queuedChunks.push(A):Rn(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(A),!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(){Rn(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Ro(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const A=new vo(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(A),A}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Ro{constructor(t,e,A=!1,i=null){this._stream=t,this._done=A||!1,this._filename=lr(i)?i: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){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class vo{constructor(t,e,A){this._stream=t,this._begin=e,this._end=A,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 No({getResponseHeader:t,isHttp:e,rangeChunkSize:A,disableRange:i}){const s={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t("Content-Length"),10);return Number.isInteger(a)?(s.suggestedLength=a,a<=2*A||i||!e||"bytes"!==t("Accept-Ranges")||"identity"!==(t("Content-Encoding")||"identity")||(s.allowRangeRequests=!0),s):s}function Mo(t){const e=t("Content-Disposition");if(e){let t=function(t){let e=!0,A=i("filename\\*","i").exec(t);if(A){A=A[1];let t=n(A);return t=unescape(t),t=r(t),t=o(t),a(t)}if(A=function(t){const e=[];let A;const s=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(A=s.exec(t));){let[,t,i,s]=A;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,s]}const a=[];for(let t=0;t{if(!Lo(t.status))throw Go(t.status,A);this._reader=t.body.getReader(),this._headersCapability.resolve();const e=e=>t.headers.get(e),{allowRangeRequests:i,suggestedLength:s}=No({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=s||this._contentLength,this._filename=Mo(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Yn("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:Jo(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class To{constructor(t,e,A){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=Ho(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${A-1}`);const s=i.url;fetch(s,Uo(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!Lo(t.status))throw Go(t.status,s);this._readCapability.resolve(),this._reader=t.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:Jo(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Po{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,A){const i={begin:t,end:e};for(const t in A)i[t]=A[t];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,A=this.currXhrId++,i=this.pendingRequests[A]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const t in this.httpHeaders){const A=this.httpHeaders[t];void 0!==A&&e.setRequestHeader(t,A)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(A){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,A),e.onprogress=this.onProgress.bind(this,A),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),A}onProgress(t,e){const A=this.pendingRequests[t];A&&A.onProgress?.(e)}onStateChange(t,e){const A=this.pendingRequests[t];if(!A)return;const i=A.xhr;if(i.readyState>=2&&A.onHeadersReceived&&(A.onHeadersReceived(),delete A.onHeadersReceived),4!==i.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===i.status&&this.isHttp)return void A.onError?.(i.status);const s=i.status||200;if((200!==s||206!==A.expectedStatus)&&s!==A.expectedStatus)return void A.onError?.(i.status);const a=function(t){const e=t.response;return"string"!=typeof e?e:Pn(e).buffer}(i);if(206===s){const t=i.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);A.onDone({begin:parseInt(e[1],10),chunk:a})}else a?A.onDone({begin:0,chunk:a}):A.onError?.(i.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 Ko{constructor(t){this._source=t,this._manager=new Po(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),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 Rn(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new qo(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const A=new Oo(this._manager,t,e);return A.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(A),A}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class qo{constructor(t,e){this._manager=t;const A={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(A),this._headersReceivedCapability=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),A=t=>e.getResponseHeader(t),{allowRangeRequests:i,suggestedLength:s}=No({getResponseHeader:A,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=s||this._contentLength,this._filename=Mo(A),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Go(t,this._url),this._headersReceivedCapability.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._headersReceivedCapability.promise}async read(){if(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._headersReceivedCapability.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 Oo{constructor(t,e,A){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,A,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):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=Go(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 Wo=/^file:\/\/\/[a-zA-Z]:\//;class jo{constructor(t){this.source=t,this.url=function(t){const e=jr.get("url"),A=e.parse(t);return"file:"===A.protocol||A.host?A:/^[a-z]:[/\\]/i.test(t)?e.parse(`file:///${t}`):(A.host||(A.protocol="file:"),A)}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Rn(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new tg(this):new zo(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const A=this.isFsUrl?new eg(this,t,e):new $o(this,t,e);return this._rangeRequestReaders.push(A),A}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Vo{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()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){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 Yn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Zo{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{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)}}function Xo(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class zo extends Vo{constructor(t){super(t);const e=e=>{if(404===e.statusCode){const t=new Hn(`Missing PDF "${this._url}".`);return this._storedError=t,void this._headersCapability.reject(t)}this._headersCapability.resolve(),this._setReadableStream(e);const A=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:i,suggestedLength:s}=No({getResponseHeader:A,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=s||this._contentLength,this._filename=Mo(A)};if(this._request=null,"http:"===this._url.protocol){const A=jr.get("http");this._request=A.request(Xo(this._url,t.httpHeaders),e)}else{const A=jr.get("https");this._request=A.request(Xo(this._url,t.httpHeaders),e)}this._request.on("error",(t=>{this._storedError=t,this._headersCapability.reject(t)})),this._request.end()}}class $o extends Zo{constructor(t,e,A){super(t),this._httpHeaders={};for(const e in t.httpHeaders){const A=t.httpHeaders[e];void 0!==A&&(this._httpHeaders[e]=A)}this._httpHeaders.Range=`bytes=${e}-${A-1}`;const i=t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new Hn(`Missing PDF "${this._url}".`);this._storedError=t}};if(this._request=null,"http:"===this._url.protocol){const t=jr.get("http");this._request=t.request(Xo(this._url,this._httpHeaders),i)}else{const t=jr.get("https");this._request=t.request(Xo(this._url,this._httpHeaders),i)}this._request.on("error",(t=>{this._storedError=t})),this._request.end()}}class tg extends Vo{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Wo.test(this._url.href)&&(e=e.replace(/^\//,""));const A=jr.get("fs");A.promises.lstat(e).then((t=>{this._contentLength=t.size,this._setReadableStream(A.createReadStream(e)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new Hn(`Missing PDF "${e}".`)),this._storedError=t,this._headersCapability.reject(t)}))}}class eg extends Zo{constructor(t,e,A){super(t);let i=decodeURIComponent(this._url.path);Wo.test(this._url.href)&&(i=i.replace(/^\//,""));const s=jr.get("fs");this._setReadableStream(s.createReadStream(i,{start:e,end:A-1}))}}const Ag=30;class ig{#ze=Promise.withResolvers();#Bt=null;#$e=!1;#tA=!!globalThis.FontInspector?.enabled;#eA=null;#AA=null;#iA=0;#sA=0;#aA=null;#nA=null;#rA=0;#oA=0;#gA=Object.create(null);#cA=[];#hA=null;#lA=[];#IA=new WeakMap;#dA=null;static#uA=new Map;static#CA=new Map;static#BA=null;static#QA=new Set;constructor({textContentSource:t,container:e,viewport:A}){if(t instanceof ReadableStream)this.#hA=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#hA=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#Bt=this.#nA=e,this.#oA=A.scale*(globalThis.devicePixelRatio||1),this.#rA=A.rotation,this.#AA={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:s,pageX:a,pageY:n}=A.rawDims;this.#dA=[1,0,0,-1,-a,n+s],this.#sA=i,this.#iA=s,ig.#EA(),br(e,A),this.#ze.promise.catch((()=>{})).then((()=>{ig.#QA.delete(this),this.#AA=null,this.#gA=null}))}render(){const t=()=>{this.#aA.read().then((({value:e,done:A})=>{A?this.#ze.resolve():(this.#eA??=e.lang,Object.assign(this.#gA,e.styles),this.#fA(e.items),t())}),this.#ze.reject)};return this.#aA=this.#hA.getReader(),ig.#QA.add(this),t(),this.#ze.promise}update({viewport:t,onBefore:e=null}){const A=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#rA&&(e?.(),this.#rA=i,br(this.#nA,{rotation:i})),A!==this.#oA){e?.(),this.#oA=A;const t={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:ig.#pA(this.#eA)};for(const e of this.#lA)t.properties=this.#IA.get(e),t.div=e,this.#mA(t)}}cancel(){const t=new Yn("TextLayer task cancelled.");this.#aA?.cancel(t).catch((()=>{})),this.#aA=null,this.#ze.reject(t)}get textDivs(){return this.#lA}get textContentItemsStr(){return this.#cA}#fA(t){if(this.#$e)return;this.#AA.ctx??=ig.#pA(this.#eA);const e=this.#lA,A=this.#cA;for(const i of t){if(e.length>1e5)return xn("Ignoring additional textDivs for performance reasons."),void(this.#$e=!0);if(void 0!==i.str)A.push(i.str),this.#yA(i);else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){const t=this.#Bt;this.#Bt=document.createElement("span"),this.#Bt.classList.add("markedContent"),null!==i.id&&this.#Bt.setAttribute("id",`${i.id}`),t.append(this.#Bt)}else"endMarkedContent"===i.type&&(this.#Bt=this.#Bt.parentNode)}}#yA(t){const e=document.createElement("span"),A={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#lA.push(e);const i=Wn.transform(this.#dA,t.transform);let s=Math.atan2(i[1],i[0]);const a=this.#gA[t.fontName];a.vertical&&(s+=Math.PI/2);const n=this.#tA&&a.fontSubstitution||a.fontFamily,r=Math.hypot(i[2],i[3]),o=r*ig.#bA(n,this.#eA);let g,c;0===s?(g=i[4],c=i[5]-o):(g=i[4]+o*Math.sin(s),c=i[5]-o*Math.cos(s));const h="calc(var(--scale-factor)*",l=e.style;this.#Bt===this.#nA?(l.left=`${(100*g/this.#sA).toFixed(2)}%`,l.top=`${(100*c/this.#iA).toFixed(2)}%`):(l.left=`${h}${g.toFixed(2)}px)`,l.top=`${h}${c.toFixed(2)}px)`),l.fontSize=`${h}${(ig.#BA*r).toFixed(2)}px)`,l.fontFamily=n,A.fontSize=r,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#tA&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==s&&(A.angle=s*(180/Math.PI));let I=!1;if(t.str.length>1)I=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),A=Math.abs(t.transform[3]);e!==A&&Math.max(e,A)/Math.min(e,A)>1.5&&(I=!0)}if(I&&(A.canvasWidth=a.vertical?t.height:t.width),this.#IA.set(e,A),this.#AA.div=e,this.#AA.properties=A,this.#mA(this.#AA),A.hasText&&this.#Bt.append(e),A.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#Bt.append(t)}}#mA(t){const{div:e,properties:A,ctx:i,prevFontSize:s,prevFontFamily:a}=t,{style:n}=e;let r="";if(ig.#BA>1&&(r=`scale(${1/ig.#BA})`),0!==A.canvasWidth&&A.hasText){const{fontFamily:o}=n,{canvasWidth:g,fontSize:c}=A;s===c&&a===o||(i.font=`${c*this.#oA}px ${o}`,t.prevFontSize=c,t.prevFontFamily=o);const{width:h}=i.measureText(e.textContent);h>0&&(r=`scaleX(${g*this.#oA/h}) ${r}`)}0!==A.angle&&(r=`rotate(${A.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#QA.size>0)){this.#uA.clear();for(const{canvas:t}of this.#CA.values())t.remove();this.#CA.clear()}}static#pA(t=null){let e=this.#CA.get(t||="");if(!e){const A=document.createElement("canvas");A.className="hiddenCanvasElement",A.lang=t,document.body.append(A),e=A.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#CA.set(t,e)}return e}static#EA(){if(null!==this.#BA)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.#BA=t.getBoundingClientRect().height,t.remove()}static#bA(t,e){const A=this.#uA.get(t);if(A)return A;const i=this.#pA(e),s=i.font;i.canvas.width=i.canvas.height=Ag,i.font=`30px ${t}`;const a=i.measureText("");let n=a.fontBoundingBoxAscent,r=Math.abs(a.fontBoundingBoxDescent);if(n){const e=n/(n+r);return this.#uA.set(t,e),i.canvas.width=i.canvas.height=0,i.font=s,e}i.strokeStyle="red",i.clearRect(0,0,Ag,Ag),i.strokeText("g",0,0);let o=i.getImageData(0,0,Ag,Ag).data;r=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){r=Math.ceil(t/4/Ag);break}i.clearRect(0,0,Ag,Ag),i.strokeText("A",0,Ag),o=i.getImageData(0,0,Ag,Ag).data,n=0;for(let t=0,e=o.length;t0){n=Ag-Math.floor(t/4/Ag);break}i.canvas.width=i.canvas.height=0,i.font=s;const g=n?n/(n+r):.8;return this.#uA.set(t,g),g}}class sg{static textContent(t){const e=[],A={items:e,styles:Object.create(null)};return function t(A){if(!A)return;let i=null;const s=A.name;if("#text"===s)i=A.value;else{if(!sg.shouldBuildText(s))return;A?.attributes?.textContent?i=A.attributes.textContent:A.value&&(i=A.value)}if(null!==i&&e.push({str:i}),A.children)for(const e of A.children)t(e)}(t),A}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const ag=65536,ng=ln?class extends $n{_createCanvas(t,e){return jr.get("canvas").createCanvas(t,e)}}:class extends $n{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const A=this._document.createElement("canvas");return A.width=t,A.height=e,A}},rg=ln?class extends tr{_fetchData(t,e){return Vr(t).then((t=>({cMapData:t,compressionType:e})))}}:nr,og=ln?class extends zn{}:class extends zn{#wA;#DA;#kA;#SA;#xA;#FA;#B=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#SA=t,this.#xA=e}get#E(){return this.#DA||=new Map}get#RA(){return this.#FA||=new Map}get#vA(){if(!this.#kA){const t=this.#xA.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 A=this.#xA.createElementNS(ir,"svg");A.setAttribute("width",0),A.setAttribute("height",0),this.#kA=this.#xA.createElementNS(ir,"defs"),t.append(A),A.append(this.#kA),this.#xA.body.append(t)}return this.#kA}#NA(t){if(1===t.length){const e=t[0],A=new Array(256);for(let t=0;t<256;t++)A[t]=e[t]/255;const i=A.join(",");return[i,i,i]}const[e,A,i]=t,s=new Array(256),a=new Array(256),n=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255,a[t]=A[t]/255,n[t]=i[t]/255;return[s.join(","),a.join(","),n.join(",")]}#MA(t){if(void 0===this.#wA){this.#wA="";const t=this.#xA.URL;t!==this.#xA.baseURI&&(hr(t)?xn('#createUrl: ignore "data:"-URL for performance reasons.'):this.#wA=t.split("#",1)[0])}return`url(${this.#wA}#${t})`}addFilter(t){if(!t)return"none";let e=this.#E.get(t);if(e)return e;const[A,i,s]=this.#NA(t),a=1===t.length?A:`${A}${i}${s}`;if(e=this.#E.get(a),e)return this.#E.set(t,e),e;const n=`g_${this.#SA}_transfer_map_${this.#B++}`,r=this.#MA(n);this.#E.set(t,r),this.#E.set(a,r);const o=this.#GA(n);return this.#LA(A,i,s,o),r}addHCMFilter(t,e){const A=`${t}-${e}`,i="base";let s=this.#RA.get(i);if(s?.key===A)return s.url;if(s?(s.filter?.remove(),s.key=A,s.url="none",s.filter=null):(s={key:A,url:"none",filter:null},this.#RA.set(i,s)),!t||!e)return s.url;const a=this.#UA(t);t=Wn.makeHexColor(...a);const n=this.#UA(e);if(e=Wn.makeHexColor(...n),this.#vA.style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;const r=new Array(256);for(let t=0;t<=255;t++){const e=t/255;r[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const o=r.join(","),g=`g_${this.#SA}_hcm_filter`,c=s.filter=this.#GA(g);this.#LA(o,o,o,c),this.#HA(c);const h=(t,e)=>{const A=a[t]/255,i=n[t]/255,s=new Array(e+1);for(let t=0;t<=e;t++)s[t]=A+t/e*(i-A);return s.join(",")};return this.#LA(h(0,5),h(1,5),h(2,5),c),s.url=this.#MA(g),s.url}addAlphaFilter(t){let e=this.#E.get(t);if(e)return e;const[A]=this.#NA([t]),i=`alpha_${A}`;if(e=this.#E.get(i),e)return this.#E.set(t,e),e;const s=`g_${this.#SA}_alpha_map_${this.#B++}`,a=this.#MA(s);this.#E.set(t,a),this.#E.set(i,a);const n=this.#GA(s);return this.#JA(A,n),a}addLuminosityFilter(t){let e,A,i=this.#E.get(t||"luminosity");if(i)return i;if(t?([e]=this.#NA([t]),A=`luminosity_${e}`):A="luminosity",i=this.#E.get(A),i)return this.#E.set(t,i),i;const s=`g_${this.#SA}_luminosity_map_${this.#B++}`,a=this.#MA(s);this.#E.set(t,a),this.#E.set(A,a);const n=this.#GA(s);return this.#_A(n),t&&this.#JA(e,n),a}addHighlightHCMFilter(t,e,A,i,s){const a=`${e}-${A}-${i}-${s}`;let n=this.#RA.get(t);if(n?.key===a)return n.url;if(n?(n.filter?.remove(),n.key=a,n.url="none",n.filter=null):(n={key:a,url:"none",filter:null},this.#RA.set(t,n)),!e||!A)return n.url;const[r,o]=[e,A].map(this.#UA.bind(this));let g=Math.round(.2126*r[0]+.7152*r[1]+.0722*r[2]),c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),[h,l]=[i,s].map(this.#UA.bind(this));c{const i=new Array(256),s=(c-g)/A,a=t/255,n=(e-t)/(255*A);let r=0;for(let t=0;t<=A;t++){const e=Math.round(g+t*s),A=a+t*n;for(let t=r;t<=e;t++)i[t]=A;r=e+1}for(let t=r;t<256;t++)i[t]=i[r-1];return i.join(",")},d=`g_${this.#SA}_hcm_${t}_filter`,u=n.filter=this.#GA(d);return this.#HA(u),this.#LA(I(h[0],l[0],5),I(h[1],l[1],5),I(h[2],l[2],5),u),n.url=this.#MA(d),n.url}destroy(t=!1){t&&0!==this.#RA.size||(this.#kA&&(this.#kA.parentNode.parentNode.remove(),this.#kA=null),this.#DA&&(this.#DA.clear(),this.#DA=null),this.#B=0)}#_A(t){const e=this.#xA.createElementNS(ir,"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)}#HA(t){const e=this.#xA.createElementNS(ir,"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)}#GA(t){const e=this.#xA.createElementNS(ir,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#vA.append(e),e}#YA(t,e,A){const i=this.#xA.createElementNS(ir,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",A),t.append(i)}#LA(t,e,A,i){const s=this.#xA.createElementNS(ir,"feComponentTransfer");i.append(s),this.#YA(s,"feFuncR",t),this.#YA(s,"feFuncG",e),this.#YA(s,"feFuncB",A)}#JA(t,e){const A=this.#xA.createElementNS(ir,"feComponentTransfer");e.append(A),this.#YA(A,"feFuncA",t)}#UA(t){return this.#vA.style.color=t,pr(getComputedStyle(this.#vA).getPropertyValue("color"))}},gg=ln?class extends er{_fetchData(t){return Vr(t)}}:rr;function cg(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new lg,{docId:A}=e,i=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(ln&&"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,s=t.data?function(t){if(ln&&"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 Pn(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,a=t.httpHeaders||null,n=!0===t.withCredentials,r=t.password??null,o=t.range instanceof Ig?t.range:null,g=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:ag;let c=t.worker instanceof Qg?t.worker:null;const h=t.verbosity,l="string"!=typeof t.docBaseUrl||hr(t.docBaseUrl)?null:t.docBaseUrl,I="string"==typeof t.cMapUrl?t.cMapUrl:null,d=!1!==t.cMapPacked,u=t.CMapReaderFactory||rg,C="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,B=t.StandardFontDataFactory||gg,Q=!0!==t.stopAtErrors,E=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,f=!1!==t.isEvalSupported,p="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!ln,m=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,y="boolean"==typeof t.disableFontFace?t.disableFontFace:ln,b=!0===t.fontExtraProperties,w=!0===t.enableXfa,D=t.ownerDocument||globalThis.document,k=!0===t.disableRange,S=!0===t.disableStream,x=!0===t.disableAutoFetch,F=!0===t.pdfBug,R=!0===t.enableHWA,v=o?o.length:t.length??NaN,N="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!ln&&!y,M="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:u===nr&&B===rr&&I&&C&&Cr(I,document.baseURI)&&Cr(C,document.baseURI),G=t.canvasFactory||new ng({ownerDocument:D,enableHWA:R}),L=t.filterFactory||new og({docId:A,ownerDocument:D});Dn(h);const U={canvasFactory:G,filterFactory:L};if(M||(U.cMapReaderFactory=new u({baseUrl:I,isCompressed:d}),U.standardFontDataFactory=new B({baseUrl:C})),!c){const t={verbosity:h,port:yo.workerPort};c=t.port?Qg.fromPort(t):new Qg(t),e._worker=c}const H={docId:A,apiVersion:"4.5.136",data:s,password:r,disableAutoFetch:x,rangeChunkSize:g,length:v,docBaseUrl:l,enableXfa:w,evaluatorOptions:{maxImageSize:E,disableFontFace:y,ignoreErrors:Q,isEvalSupported:f,isOffscreenCanvasSupported:p,canvasMaxAreaInBytes:m,fontExtraProperties:b,useSystemFonts:N,cMapUrl:M?I:null,standardFontDataUrl:M?C:null}},J={disableFontFace:y,fontExtraProperties:b,ownerDocument:D,pdfBug:F,styleElement:null,loadingParams:{disableAutoFetch:x,enableXfa:w}};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,s?[s.buffer]:null);let r;if(o)r=new Fo(o,{disableRange:k,disableStream:S});else if(!s){if(!i)throw new Error("getDocument - no `url` parameter provided.");h={url:i,length:v,httpHeaders:a,withCredentials:n,rangeChunkSize:g,disableRange:k,disableStream:S},r=ln?"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&Cr(h.url)?new _o(h):new jo(h):Cr(h.url)?new _o(h):new Ko(h)}var h;return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const i=new wo(A,t,c.port),s=new Eg(i,e,r,J,U);e._transport=s,i.send("Ready",null)}))})).catch(e._capability.reject),e}function hg(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class lg{static#SA=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+lg.#SA++,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&&(this._worker.destroy(),this._worker=null)}}class Ig{constructor(t,e,A=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=A,this.contentDispositionFilename=i,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 A of this._rangeListeners)A(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const A of this._progressListeners)A(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){Fn("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class dg{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Nn(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 ug{#TA=null;#PA=!1;constructor(t,e,A,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=A,this._stats=i?new ur:null,this._pdfBug=i,this.commonObjs=A.commonObjs,this.objs=new pg,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:A=0,offsetY:i=0,dontFlip:s=!1}={}){return new gr({viewBox:this.view,scale:t,rotation:e,offsetX:A,offsetY:i,dontFlip:s})}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 Nn(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:A="display",annotationMode:i=Cn.ENABLE,transform:s=null,background:a=null,optionalContentConfigPromise:n=null,annotationCanvasMap:r=null,pageColors:o=null,printAnnotationStorage:g=null,isEditing:c=!1}){this._stats?.time("Overall");const h=this._transport.getRenderingIntent(A,i,g,c),{renderingIntent:l,cacheKey:I}=h;this.#PA=!1,this.#KA(),n||=this._transport.getOptionalContentConfig(l);let d=this._intentStates.get(I);d||(d=Object.create(null),this._intentStates.set(I,d)),d.streamReaderCancelTimeout&&(clearTimeout(d.streamReaderCancelTimeout),d.streamReaderCancelTimeout=null);const u=!!(4&l);d.displayReadyCapability||(d.displayReadyCapability=Promise.withResolvers(),d.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(h));const C=t=>{d.renderTasks.delete(B),(this._maybeCleanupAfterRender||u)&&(this.#PA=!0),this.#qA(!u),t?(B.capability.reject(t),this._abortOperatorList({intentState:d,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 yg({callback:C,params:{canvasContext:t,viewport:e,transform:s,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:r,operatorList:d.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!u,pdfBug:this._pdfBug,pageColors:o});(d.renderTasks||=new Set).add(B);const Q=B.task;return Promise.all([d.displayReadyCapability.promise,n]).then((([t,e])=>{if(this.destroyed)C();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&l))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(C),Q}getOperatorList({intent:t="display",annotationMode:e=Cn.ENABLE,printAnnotationStorage:A=null,isEditing:i=!1}={}){const s=this._transport.getRenderingIntent(t,e,A,i,!0);let a,n=this._intentStates.get(s.cacheKey);return n||(n=Object.create(null),this._intentStates.set(s.cacheKey,n)),n.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(a))},n.opListReadCapability=Promise.withResolvers(),(n.renderTasks||=new Set).add(a),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(s)),n.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=>sg.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,A){const i=e.getReader(),s={items:[],styles:Object.create(null),lang:null};!function e(){i.read().then((function({value:A,done:i}){i?t(s):(s.lang??=A.lang,Object.assign(s.styles,A.styles),s.items.push(...A.items),e())}),A)}()}))}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 A of e.renderTasks)t.push(A.completed),A.cancel();return this.objs.clear(),this.#PA=!1,this.#KA(),Promise.all(t)}cleanup(t=!1){this.#PA=!0;const e=this.#qA(!1);return t&&e&&(this._stats&&=new ur),e}#qA(t=!1){if(this.#KA(),!this.#PA||this.destroyed)return!1;if(t)return this.#TA=setTimeout((()=>{this.#TA=null,this.#qA(!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.#PA=!1,!0}#KA(){this.#TA&&(clearTimeout(this.#TA),this.#TA=null)}_startRenderPage(t,e){const A=this._intentStates.get(e);A&&(this._stats?.timeEnd("Page Request"),A.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let A=0,i=t.length;A{n.read().then((({value:t,done:e})=>{e?r.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,r),o())}),(t=>{if(r.streamReader=null,!this._transport.destroyed){if(r.operatorList){r.operatorList.lastChunk=!0;for(const t of r.renderTasks)t.operatorListChanged();this.#qA(!0)}if(r.displayReadyCapability)r.displayReadyCapability.reject(t);else{if(!r.opListReadCapability)throw t;r.opListReadCapability.reject(t)}}}))};o()}_abortOperatorList({intentState:t,reason:e,force:A=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!A){if(t.renderTasks.size>0)return;if(e instanceof cr){let A=100;return e.extraDelay>0&&e.extraDelay<1e3&&(A+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),A))}}if(t.streamReader.cancel(new Yn(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,A]of this._intentStates)if(A===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class Cg{#OA=new Set;#WA=Promise.resolve();postMessage(t,e){const A={data:structuredClone(t,e?{transfer:e}:null)};this.#WA.then((()=>{for(const t of this.#OA)t.call(this,A)}))}addEventListener(t,e){this.#OA.add(e)}removeEventListener(t,e){this.#OA.delete(e)}terminate(){this.#OA.clear()}}const Bg={isWorkerDisabled:!1,fakeWorkerId:0};ln&&(Bg.isWorkerDisabled=!0,yo.workerSrc||="./pdf.worker.mjs"),Bg.isSameOrigin=function(t,e){let A;try{if(A=new URL(t),!A.origin||"null"===A.origin)return!1}catch{return!1}const i=new URL(e,A);return A.origin===i.origin},Bg.createCDNWrapper=function(t){const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};class Qg{static#jA;constructor({name:t=null,port:e=null,verbosity:A=kn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=A,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(Qg.#jA?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(Qg.#jA||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return ln?Promise.all([jr.promise,this._readyCapability.promise]):this._readyCapability.promise}#VA(){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 wo("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#VA()}_initialize(){if(Bg.isWorkerDisabled||Qg.#ZA)return void this._setupFakeWorker();let{workerSrc:t}=Qg;try{Bg.isSameOrigin(window.location.href,t)||(t=Bg.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),A=new wo("main","worker",e),i=()=>{s.abort(),A.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},s=new AbortController;e.addEventListener("error",(()=>{this._webWorker||i()}),{signal:s.signal}),A.on("test",(t=>{s.abort(),!this.destroyed&&t?(this._messageHandler=A,this._port=e,this._webWorker=e,this.#VA()):i()})),A.on("ready",(t=>{if(s.abort(),this.destroyed)i();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;A.send("test",t,[t.buffer])};return void a()}catch{Sn("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Bg.isWorkerDisabled||(xn("Setting up fake worker."),Bg.isWorkerDisabled=!0),Qg._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new Cg;this._port=e;const A="fake"+Bg.fakeWorkerId++,i=new wo(A+"_worker",A,e);t.setup(i,e),this._messageHandler=new wo(A,A+"_worker",e),this.#VA()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),Qg.#jA?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#jA?.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 Qg(t)}static get workerSrc(){if(yo.workerSrc)return yo.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#ZA(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Nn(this,"_setupFakeWorkerGlobal",(async()=>this.#ZA?this.#ZA:(await import(this.workerSrc)).WorkerMessageHandler)())}}class Eg{#XA=new Map;#zA=new Map;#$A=new Map;#ti=new Map;#ei=null;constructor(t,e,A,i,s){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new pg,this.fontLoader=new Kr({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.cMapReaderFactory=s.cMapReaderFactory,this.standardFontDataFactory=s.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=A,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ai(t,e=null){const A=this.#XA.get(t);if(A)return A;const i=this.messageHandler.sendWithPromise(t,e);return this.#XA.set(t,i),i}get annotationStorage(){return Nn(this,"annotationStorage",new Tr)}getRenderingIntent(t,e=Cn.ENABLE,A=null,i=!1,s=!1){let a=2,n=Yr;switch(t){case"any":a=1;break;case"display":break;case"print":a=4;break;default:xn(`getRenderingIntent - invalid intent: ${t}`)}const r=4&a&&A instanceof Pr?A:this.annotationStorage;switch(e){case Cn.DISABLE:a+=64;break;case Cn.ENABLE:break;case Cn.ENABLE_FORMS:a+=16;break;case Cn.ENABLE_STORAGE:a+=32,n=r.serializable;break;default:xn(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=128),s&&(a+=256);const{ids:o,hash:g}=r.modifiedIds;return{renderingIntent:a,cacheKey:[a,n.hash,g].join("_"),annotationStorageSerializable:n,modifiedIds:o}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#ei?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#zA.values())t.push(e._destroy());this.#zA.clear(),this.#$A.clear(),this.#ti.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.#XA.clear(),this.filterFactory.destroy(),ig.cleanup(),this._networkStream?.cancelAllRequests(new Yn("Worker was terminated.")),this.messageHandler&&(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)=>{Rn(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:A}){A?e.close():(Rn(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",(t=>{const A=Promise.withResolvers(),i=this._fullReader;return i.headersReady.then((()=>{i.isStreamingSupported&&i.isRangeSupported||(this._lastProgress&&e.onProgress?.(this._lastProgress),i.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),A.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})}),A.reject),A.promise})),t.on("GetRangeReader",((t,e)=>{Rn(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const A=this._networkStream.getRangeReader(t.begin,t.end);A?(e.onPull=()=>{A.read().then((function({value:t,done:A}){A?e.close():(Rn(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{A.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 dg(t,this))})),t.on("DocException",(function(t){let A;switch(t.name){case"PasswordException":A=new Gn(t.message,t.code);break;case"InvalidPDFException":A=new Un(t.message);break;case"MissingPDFException":A=new Hn(t.message);break;case"UnexpectedResponseException":A=new Jn(t.message,t.status);break;case"UnknownErrorException":A=new Ln(t.message,t.details);break;default:Fn("DocException - expected a valid Error.")}e._capability.reject(A)})),t.on("PasswordRequest",(t=>{if(this.#ei=Promise.withResolvers(),e.onPassword){const A=t=>{t instanceof Error?this.#ei.reject(t):this.#ei.resolve({password:t})};try{e.onPassword(A,t.code)}catch(t){this.#ei.reject(t)}}else this.#ei.reject(new Gn(t.message,t.code));return this.#ei.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#zA.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,A,i])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(A){case"Font":const{disableFontFace:s,fontExtraProperties:a,pdfBug:n}=this._params;if("error"in i){const t=i.error;xn(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const r=n&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,o=new qr(i,{disableFontFace:s,inspectFont:r});this.fontLoader.bind(o).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a&&o.data&&(o.data=null),this.commonObjs.resolve(e,o)}));break;case"CopyLocalImage":const{imageRef:g}=i;Rn(g,"The imageRef must be defined.");for(const t of this.#zA.values())for(const[,A]of t.objs)if(A?.ref===g)return A.dataLen?(this.commonObjs.resolve(e,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${A}`)}return null})),t.on("obj",(([t,e,A,i])=>{if(this.destroyed)return;const s=this.#zA.get(e);if(!s.objs.has(t))if(0!==s._intentStates.size)switch(A){case"Image":s.objs.resolve(t,i),i?.dataLen>1e7&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${A}`)}else i?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(t):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),t.on("FetchStandardFontData",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(t):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&xn("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,A=this.#$A.get(e);if(A)return A;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((A=>{if(this.destroyed)throw new Error("Transport destroyed");A.refStr&&this.#ti.set(A.refStr,t);const i=new ug(e,A,this,this._params.pdfBug);return this.#zA.set(e,i),i}));return this.#$A.set(e,i),i}getPageIndex(t){return hg(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.#Ai("GetFieldObjects")}hasJSActions(){return this.#Ai("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.#Ai("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.#Ai("GetOptionalContentConfig").then((e=>new xo(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#XA.get(t);if(e)return e;const A=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Do(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#XA.set(t,A),A}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#zA.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#XA.clear(),this.filterFactory.destroy(!0),ig.cleanup()}}cachedPageNumber(t){if(!hg(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#ti.get(e)??null}}const fg=Symbol("INITIAL_DATA");class pg{#ii=Object.create(null);#si(t){return this.#ii[t]||={...Promise.withResolvers(),data:fg}}get(t,e=null){if(e){const A=this.#si(t);return A.promise.then((()=>e(A.data))),null}const A=this.#ii[t];if(!A||A.data===fg)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return A.data}has(t){const e=this.#ii[t];return!!e&&e.data!==fg}resolve(t,e=null){const A=this.#si(t);A.data=e,A.resolve()}clear(){for(const t in this.#ii){const{data:e}=this.#ii[t];e?.bitmap?.close()}this.#ii=Object.create(null)}*[Symbol.iterator](){for(const t in this.#ii){const{data:e}=this.#ii[t];e!==fg&&(yield[t,e])}}}class mg{#ai=null;constructor(t){this.#ai=t,this.onContinue=null}get promise(){return this.#ai.capability.promise}cancel(t=0){this.#ai.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#ai.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#ai;return t.form||t.canvas&&e?.size>0}}class yg{#ni=null;static#ri=new WeakSet;constructor({callback:t,params:e,objs:A,commonObjs:i,annotationCanvasMap:s,operatorList:a,pageIndex:n,canvasFactory:r,filterFactory:o,useRequestAnimationFrame:g=!1,pdfBug:c=!1,pageColors:h=null}){this.callback=t,this.params=e,this.objs=A,this.commonObjs=i,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=n,this.canvasFactory=r,this.filterFactory=o,this._pdfBug=c,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===g&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new mg(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(yg.#ri.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.");yg.#ri.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:A,viewport:i,transform:s,background:a}=this.params;this.gfx=new mo(A,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#ni&&(window.cancelAnimationFrame(this.#ni),this.#ni=null),yg.#ri.delete(this._canvas),this.callback(t||new cr(`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.#ni=window.requestAnimationFrame((()=>{this.#ni=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(),yg.#ri.delete(this._canvas),this.callback())))}}const bg="4.5.136",wg="3a21f03b0";function Dg(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function kg(t){return Math.max(0,Math.min(255,255*t))}class Sg{static CMYK_G([t,e,A,i]){return["G",1-Math.min(1,.3*t+.59*A+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=kg(t),t,t]}static G_HTML([t]){const e=Dg(t);return`#${e}${e}${e}`}static RGB_G([t,e,A]){return["G",.3*t+.59*e+.11*A]}static RGB_rgb(t){return t.map(kg)}static RGB_HTML(t){return`#${t.map(Dg).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,A,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,A+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,A,i]){return[kg(1-Math.min(1,t+i)),kg(1-Math.min(1,A+i)),kg(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,A]){const i=1-t,s=1-e,a=1-A;return["CMYK",i,s,a,Math.min(i,s,a)]}}class xg{static setupStorage(t,e,A,i,s){const a=i.getValue(e,{value:null});switch(A.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===s)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===A.attributes.type||"checkbox"===A.attributes.type){if(a.value===A.attributes.xfaOn?t.setAttribute("checked",!0):a.value===A.attributes.xfaOff&&t.removeAttribute("checked"),"print"===s)break;t.addEventListener("change",(t=>{i.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===s)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of A.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const A=t.target.options,s=-1===A.selectedIndex?"":A[A.selectedIndex].value;i.setValue(e,{value:s})}))}}static setAttributes({html:t,element:e,storage:A=null,intent:i,linkService:s}){const{attributes:a}=e,n=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${i}`);for(const[e,A]of Object.entries(a))if(null!=A)switch(e){case"class":A.length&&t.setAttribute(e,A.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",A);break;case"style":Object.assign(t.style,A);break;case"textContent":t.textContent=A;break;default:(!n||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,A)}n&&s.addLinkAttributes(t,a.href,a.newWindow),A&&a.dataId&&this.setupStorage(t,a.dataId,e,A)}static render(t){const e=t.annotationStorage,A=t.linkService,i=t.xfaHtml,s=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:s,linkService:A});const n="richText"!==s,r=t.div;if(r.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;r.style.transform=e}n&&r.setAttribute("class","xfaLayer xfaFont");const o=[];if(0===i.children.length){if(i.value){const t=document.createTextNode(i.value);a.append(t),n&&sg.shouldBuildText(i.name)&&o.push(t)}return{textDivs:o}}const g=[[i,-1,a]];for(;g.length>0;){const[t,i,a]=g.at(-1);if(i+1===t.children.length){g.pop();continue}const r=t.children[++g.at(-1)[1]];if(null===r)continue;const{name:c}=r;if("#text"===c){const t=document.createTextNode(r.value);o.push(t),a.append(t);continue}const h=r?.attributes?.xmlns?document.createElementNS(r.attributes.xmlns,c):document.createElement(c);if(a.append(h),r.attributes&&this.setAttributes({html:h,element:r,storage:e,intent:s,linkService:A}),r.children?.length>0)g.push([r,-1,h]);else if(r.value){const t=document.createTextNode(r.value);n&&sg.shouldBuildText(c)&&o.push(t),h.append(t)}}for(const t of r.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:o}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Fg=1e3,Rg=new WeakSet;function vg(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Ng{static create(t){switch(t.data.annotationType){case 2:return new Gg(t);case 1:return new Lg(t);case 20:switch(t.data.fieldType){case"Tx":return new Hg(t);case"Btn":return t.data.radioButton?new Yg(t):t.data.checkBox?new _g(t):new Tg(t);case"Ch":return new Pg(t);case"Sig":return new Jg(t)}return new Ug(t);case 16:return new Kg(t);case 3:return new Og(t);case 4:return new Wg(t);case 5:return new jg(t);case 6:return new Vg(t);case 8:return new Zg(t);case 14:return new zg(t);case 15:return new $g(t);case 7:return new Xg(t);case 9:return new tc(t);case 10:return new ec(t);case 11:return new Ac(t);case 12:return new ic(t);case 13:return new sc(t);case 17:return new ac(t);default:return new Mg(t)}}}class Mg{#oi=null;#gi=!1;#ci=null;constructor(t,{isRenderable:e=!1,ignoreBorder:A=!1,createQuadrilaterals:i=!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(A)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:A}){return!!(t?.str||e?.str||A?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Mg._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#oi||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#hi(e),this.#ci?.popup.updateEdited(t)}resetEdited(){this.#oi&&(this.#hi(this.#oi.rect),this.#ci?.popup.resetEdited(),this.#oi=null)}#hi(t){const{container:{style:e},data:{rect:A,rotation:i},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:a,pageX:n,pageY:r}}}}=this;A?.splice(0,4,...t);const{width:o,height:g}=vg(t);e.left=100*(t[0]-n)/s+"%",e.top=100*(a-t[3]+r)/a+"%",0===i?(e.width=100*o/s+"%",e.height=100*g/a+"%"):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:A,viewport:i}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",e.id),this instanceof Ug||(s.tabIndex=Fg);const{style:a}=s;if(a.zIndex=this.parent.zIndex++,e.popupRef&&s.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(s.title=e.alternativeText),e.noRotate&&s.classList.add("norotate"),!e.rect||this instanceof Kg){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,s),s}const{width:n,height:r}=vg(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,A=e.borderStyle.verticalCornerRadius;if(t>0||A>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${A}px * var(--scale-factor))`;a.borderRadius=e}else if(this instanceof Yg){const t=`calc(${n}px * var(--scale-factor)) / calc(${r}px * var(--scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case 1:a.borderStyle="solid";break;case 2:a.borderStyle="dashed";break;case 3:xn("Unimplemented border style: beveled");break;case 4:xn("Unimplemented border style: inset");break;case 5:a.borderBottomStyle="solid"}const i=e.borderColor||null;i?(this.#gi=!0,a.borderColor=Wn.makeHexColor(0|i[0],0|i[1],0|i[2])):a.borderWidth=0}const o=Wn.normalizeRect([e.rect[0],A.view[3]-e.rect[1]+A.view[1],e.rect[2],A.view[3]-e.rect[3]+A.view[1]]),{pageWidth:g,pageHeight:c,pageX:h,pageY:l}=i.rawDims;a.left=100*(o[0]-h)/g+"%",a.top=100*(o[1]-l)/c+"%";const{rotation:I}=e;return e.hasOwnCanvas||0===I?(a.width=100*n/g+"%",a.height=100*r/c+"%"):this.setRotation(I,s),s}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:A,pageHeight:i}=this.parent.viewport.rawDims,{width:s,height:a}=vg(this.data.rect);let n,r;t%180==0?(n=100*s/A,r=100*a/i):(n=100*a/A,r=100*s/i),e.style.width=`${n}%`,e.style.height=`${r}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,A)=>{const i=A.detail[t],s=i[0],a=i.slice(1);A.target.style[e]=Sg[`${s}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:Sg[`${s}_rgb`](a)})};return Nn(this,"_commonActions",{display:t=>{const{display:e}=t.detail,A=e%2==1;this.container.style.visibility=A?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:A,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 A=this._commonActions;for(const i of Object.keys(e.detail)){const s=t[i]||A[i];s?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const A=this._commonActions;for(const[i,s]of Object.entries(e)){const a=A[i];a&&(a({detail:{[i]:s},target:t}),delete e[i])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,A,i,s]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[a,n,r,o]=t.subarray(2,6);if(i===a&&s===n&&e===r&&A===o)return}const{style:a}=this.container;let n;if(this.#gi){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,n=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const r=i-e,o=s-A,{svgFactory:g}=this,c=g.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const h=g.createElement("defs");c.append(h);const l=g.createElement("clipPath"),I=`clippath_${this.data.id}`;l.setAttribute("id",I),l.setAttribute("clipPathUnits","objectBoundingBox"),h.append(l);for(let A=2,i=t.length;A`)}this.#gi&&(n.push("')"),a.backgroundImage=n.join("")),this.container.append(c),this.container.style.clipPath=`url(#${I})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const A=this.#ci=new Kg({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(A.render())}render(){Fn("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const A=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:t,id:s,exportValues:a}of i){if(-1===t)continue;if(s===e)continue;const i="string"==typeof a?a:null,n=document.querySelector(`[data-element-id="${s}"]`);!n||Rg.has(n)?A.push({id:s,exportValue:i,domElement:n}):xn(`_getElementsByName - element not allowed: ${s}`)}return A}for(const i of document.getElementsByName(t)){const{exportValue:t}=i,s=i.getAttribute("data-element-id");s!==e&&Rg.has(i)&&A.push({id:s,exportValue:t,domElement:i})}return A}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const 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 Gg extends Mg{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,A=document.createElement("a");A.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(A,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(A,t.action),i=!0):t.attachment?(this.#li(A,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#Ii(A,t.setOCGState),i=!0):t.dest?(this._bindLink(A,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(A,t),i=!0),t.resetForm?(this._bindResetFormAction(A,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(A,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(A),this.container}#di(){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.#di()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#di()}#li(t,e,A=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,A),!1),this.#di()}#Ii(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#di()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const A=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const s=A.get(i);s&&(t[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#di()}_bindResetFormAction(t,e){const A=t.onclick;if(A||(t.href=this.linkService.getAnchorUrl("")),this.#di(),!this._fieldObjects)return xn('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(A||(t.onclick=()=>!1));t.onclick=()=>{A?.();const{fields:t,refs:i,include:s}=e,a=[];if(0!==t.length||0!==i.length){const e=new Set(i);for(const A of t){const t=this._fieldObjects[A]||[];for(const{id:A}of t)e.add(A)}for(const t of Object.values(this._fieldObjects))for(const A of t)e.has(A.id)===s&&a.push(A)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const n=this.annotationStorage,r=[];for(const t of a){const{id:e}=t;switch(r.push(e),t.type){case"text":{const A=t.defaultValue||"";n.setValue(e,{value:A});break}case"checkbox":case"radiobutton":{const A=t.defaultValue===t.exportValues;n.setValue(e,{value:A});break}case"combobox":case"listbox":{const A=t.defaultValue||"";n.setValue(e,{value:A});break}default:continue}const A=document.querySelector(`[data-element-id="${e}"]`);A&&(Rg.has(A)?A.dispatchEvent(new Event("resetform")):xn(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:r,name:"ResetForm"}}),!1}}}class Lg extends Mg{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 Ug extends Mg{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return qn.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,A,i,s){A.includes("mouse")?t.addEventListener(A,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:s(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(A,(t=>{if("blur"===A){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===A){if(e.focused)return;e.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:s(t)}})}))}_setEventListeners(t,e,A,i){for(const[s,a]of A)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,s,a,i),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||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":Wn.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const{fontColor:e}=this.data.defaultAppearanceData,A=this.data.defaultAppearanceData.fontSize||9,i=t.style;let s;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/(un*A))||1);s=Math.min(A,a(e/un))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);s=Math.min(A,a(t/un))}i.fontSize=`calc(${s}px * var(--scale-factor))`,i.color=Wn.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Hg extends Ug{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,A,i){const s=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=A),s.setValue(a.id,{[i]:A})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let A=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let s=i.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&s.length>a&&(s=s.slice(0,a));let n=i.formattedValue||this.data.textContent?.join("\n")||null;n&&this.data.comb&&(n=n.replaceAll(/\s+/g,""));const r={userValue:s,formattedValue:n,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(A=document.createElement("textarea"),A.textContent=n??s,this.data.doNotScroll&&(A.style.overflowY="hidden")):(A=document.createElement("input"),A.type="text",A.setAttribute("value",n??s),this.data.doNotScroll&&(A.style.overflowX="hidden")),this.data.hasOwnCanvas&&(A.hidden=!0),Rg.add(A),A.setAttribute("data-element-id",e),A.disabled=this.data.readOnly,A.name=this.data.fieldName,A.tabIndex=Fg,this._setRequired(A,this.data.required),a&&(A.maxLength=a),A.addEventListener("input",(i=>{t.setValue(e,{value:i.target.value}),this.setPropertyOnSiblings(A,"value",i.target.value,"value"),r.formattedValue=null})),A.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";A.value=r.userValue=e,r.formattedValue=null}));let o=t=>{const{formattedValue:e}=r;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){A.addEventListener("focus",(t=>{if(r.focused)return;const{target:e}=t;r.userValue&&(e.value=r.userValue),r.lastCommittedValue=e.value,r.commitKey=1,this.data.actions?.Focus||(r.focused=!0)})),A.addEventListener("updatefromsandbox",(A=>{this.showElementAndHideCanvas(A.target);const i={value(A){r.userValue=A.detail.value??"",t.setValue(e,{value:r.userValue.toString()}),A.target.value=r.userValue},formattedValue(A){const{formattedValue:i}=A.detail;r.formattedValue=i,null!=i&&A.target!==document.activeElement&&(A.target.value=i),t.setValue(e,{formattedValue:i})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:A=>{const{charLimit:i}=A.detail,{target:s}=A;if(0===i)return void s.removeAttribute("maxLength");s.setAttribute("maxLength",i);let a=r.userValue;!a||a.length<=i||(a=a.slice(0,i),s.value=r.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}}))}};this._dispatchEventFromSandbox(i,A)})),A.addEventListener("keydown",(t=>{r.commitKey=1;let A=-1;if("Escape"===t.key?A=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(r.commitKey=3):A=2,-1===A)return;const{value:i}=t.target;r.lastCommittedValue!==i&&(r.lastCommittedValue=i,r.userValue=i,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:A,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const i=o;o=null,A.addEventListener("blur",(t=>{if(!r.focused||!t.relatedTarget)return;this.data.actions?.Blur||(r.focused=!1);const{value:A}=t.target;r.userValue=A,r.lastCommittedValue!==A&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:r.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),i(t)})),this.data.actions?.Keystroke&&A.addEventListener("beforeinput",(t=>{r.lastCommittedValue=null;const{data:A,target:i}=t,{value:s,selectionStart:a,selectionEnd:n}=i;let o=a,g=n;switch(t.inputType){case"deleteWordBackward":{const t=s.substring(0,a).match(/\w*[^\w]*$/);t&&(o-=t[0].length);break}case"deleteWordForward":{const t=s.substring(a).match(/^[^\w]*\w*/);t&&(g+=t[0].length);break}case"deleteContentBackward":a===n&&(o-=1);break;case"deleteContentForward":a===n&&(g+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,change:A||"",willCommit:!1,selStart:o,selEnd:g}})})),this._setEventListeners(A,r,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(o&&A.addEventListener("blur",o),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;A.classList.add("comb"),A.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else A=document.createElement("div"),A.textContent=this.data.fieldValue,A.style.verticalAlign="middle",A.style.display="table-cell",this.data.hasOwnCanvas&&(A.hidden=!0);return this._setTextStyle(A),this._setBackgroundColor(A),this._setDefaultPropertiesFromJS(A),this.container.append(A),this.container}}class Jg extends Ug{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class _g extends Ug{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,A=e.id;let i=t.getValue(A,{value:e.exportValue===e.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,t.setValue(A,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");return Rg.add(s),s.setAttribute("data-element-id",A),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=e.fieldName,i&&s.setAttribute("checked",!0),s.setAttribute("exportValue",e.exportValue),s.tabIndex=Fg,s.addEventListener("change",(i=>{const{name:s,checked:a}=i.target;for(const i of this._getElementsByName(s,A)){const A=a&&i.exportValue===e.exportValue;i.domElement&&(i.domElement.checked=A),t.setValue(i.id,{value:A})}t.setValue(A,{value:a})})),s.addEventListener("resetform",(t=>{const A=e.defaultFieldValue||"Off";t.target.checked=A===e.exportValue})),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",(e=>{const i={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(A,{value:e.target.checked})}};this._dispatchEventFromSandbox(i,e)})),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Yg extends Ug{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,A=e.id;let i=t.getValue(A,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof i&&(i=i!==e.buttonValue,t.setValue(A,{value:i})),i)for(const i of this._getElementsByName(e.fieldName,A))t.setValue(i.id,{value:!1});const s=document.createElement("input");if(Rg.add(s),s.setAttribute("data-element-id",A),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=e.fieldName,i&&s.setAttribute("checked",!0),s.tabIndex=Fg,s.addEventListener("change",(e=>{const{name:i,checked:s}=e.target;for(const e of this._getElementsByName(i,A))t.setValue(e.id,{value:!1});t.setValue(A,{value:s})})),s.addEventListener("resetform",(t=>{const A=e.defaultFieldValue;t.target.checked=null!=A&&A===e.buttonValue})),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;s.addEventListener("updatefromsandbox",(e=>{const s={value:e=>{const s=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=s&&i.id===A;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Tg extends Gg{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 Pg extends Ug{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,A=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Rg.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=Fg;let s=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of i.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,A.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),s=!1),i.append(e)}let a=null;if(s){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),i.prepend(t),a=()=>{t.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const n=t=>{const e=t?"value":"textContent",{options:A,multiple:s}=i;return s?Array.prototype.filter.call(A,(t=>t.selected)).map((t=>t[e])):-1===A.selectedIndex?null:A[A.selectedIndex][e]};let r=n(!1);const o=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",(A=>{const s={value(A){a?.();const s=A.detail.value,o=new Set(Array.isArray(s)?s:[s]);for(const t of i.options)t.selected=o.has(t.value);t.setValue(e,{value:n(!0)}),r=n(!1)},multipleSelection(t){i.multiple=!0},remove(A){const s=i.options,a=A.detail.remove;s[a].selected=!1,i.remove(a),s.length>0&&-1===Array.prototype.findIndex.call(s,(t=>t.selected))&&(s[0].selected=!0),t.setValue(e,{value:n(!0),items:o(A)}),r=n(!1)},clear(A){for(;0!==i.length;)i.remove(0);t.setValue(e,{value:null,items:[]}),r=n(!1)},insert(A){const{index:s,displayValue:a,exportValue:g}=A.detail.insert,c=i.children[s],h=document.createElement("option");h.textContent=a,h.value=g,c?c.before(h):i.append(h),t.setValue(e,{value:n(!0),items:o(A)}),r=n(!1)},items(A){const{items:s}=A.detail;for(;0!==i.length;)i.remove(0);for(const t of s){const{displayValue:e,exportValue:A}=t,s=document.createElement("option");s.textContent=e,s.value=A,i.append(s)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:n(!0),items:o(A)}),r=n(!1)},indices(A){const i=new Set(A.detail.indices);for(const t of A.target.options)t.selected=i.has(t.index);t.setValue(e,{value:n(!0)}),r=n(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(s,A)})),i.addEventListener("input",(A=>{const i=n(!0),s=n(!1);t.setValue(e,{value:i}),A.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:s,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):i.addEventListener("input",(function(A){t.setValue(e,{value:n(!0)})})),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Kg extends Mg{constructor(t){const{data:e,elements:A}=t;super(t,{isRenderable:Mg._hasPopupData(e)}),this.elements=A,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new qg({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 A of this.elements)A.popup=t,e.push(A.data.id),A.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${Xn}${t}`)).join(",")),this.container}}class qg{#ui=this.#Ci.bind(this);#Bi=this.#Qi.bind(this);#Ei=this.#fi.bind(this);#pi=this.#mi.bind(this);#yi=null;#Bt=null;#bi=null;#wi=null;#Di=null;#ki=null;#Si=null;#xi=!1;#Fi=null;#b=null;#Ri=null;#vi=null;#Ni=null;#oi=null;#Mi=!1;constructor({container:t,color:e,elements:A,titleObj:i,modificationDate:s,contentsObj:a,richText:n,parent:r,rect:o,parentRect:g,open:c}){this.#Bt=t,this.#Ni=i,this.#bi=a,this.#vi=n,this.#ki=r,this.#yi=e,this.#Ri=o,this.#Si=g,this.#Di=A,this.#wi=Er.toDateObject(s),this.trigger=A.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#pi),t.addEventListener("mouseenter",this.#Ei),t.addEventListener("mouseleave",this.#Bi),t.classList.add("popupTriggerArea");for(const t of A)t.container?.addEventListener("keydown",this.#ui);this.#Bt.hidden=!0,c&&this.#mi()}render(){if(this.#Fi)return;const t=this.#Fi=document.createElement("div");if(t.className="popup",this.#yi){const e=t.style.outlineColor=Wn.makeHexColor(...this.#yi);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=Wn.makeHexColor(...this.#yi.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const A=document.createElement("h1");if(e.append(A),({dir:A.dir,str:A.textContent}=this.#Ni),t.append(e),this.#wi){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),t.setAttribute("data-l10n-args",JSON.stringify({date:this.#wi.toLocaleDateString(),time:this.#wi.toLocaleTimeString()})),e.append(t)}const i=this.#Gi;if(i)xg.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#bi);t.append(e)}this.#Bt.append(t)}get#Gi(){const t=this.#vi,e=this.#bi;return!t?.str||e?.str&&e.str!==t.str?null:this.#vi.html||null}get#Li(){return this.#Gi?.attributes?.style?.fontSize||0}get#Ui(){return this.#Gi?.attributes?.style?.color||null}#Hi(t){const e=[],A={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#Ui,fontSize:this.#Li?`calc(${this.#Li}px * var(--scale-factor))`:""}};for(const A of t.split("\n"))e.push({name:"span",value:A,attributes:i});return A}_formatContents({str:t,dir:e}){const A=document.createElement("p");A.classList.add("popupContent"),A.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let t=0,e=i.length;t{"Enter"===t.key&&(i?t.metaKey:t.ctrlKey)&&this.#Oi()})),!e.popupRef&&this.hasPopupData?this._createPopup():A.classList.add("popupTriggerArea"),t.append(A),t}getElementsToTriggerPopup(){return this.#qi}addHighlightArea(){this.container.classList.add("highlightArea")}#Oi(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class nc{#Wi=null;#ji=null;#Vi=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:A,annotationEditorUIManager:i,page:s,viewport:a}){this.div=t,this.#Wi=e,this.#ji=A,this.page=s,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return this.#Vi.size>0}#Zi(t,e){const A=t.firstChild||t;A.id=`${Xn}${e}`,this.div.append(t),this.#Wi?.moveElementInDOM(this.div,t,A,!1)}async render(t){const{annotations:e}=t,A=this.div;br(A,this.viewport);const i=new Map,s={data:null,layer:A,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new or,annotationStorage:t.annotationStorage||new Tr,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=16===t.annotationType;if(e){const e=i.get(t.id);if(!e)continue;s.elements=e}else{const{width:e,height:A}=vg(t.rect);if(e<=0||A<=0)continue}s.data=t;const A=Ng.create(s);if(!A.isRenderable)continue;if(!e&&t.popupRef){const e=i.get(t.popupRef);e?e.push(A):i.set(t.popupRef,[A])}const a=A.render();t.hidden&&(a.style.visibility="hidden"),this.#Zi(a,t.id),A._isEditable&&(this.#Vi.set(A.data.id,A),this._annotationEditorUIManager?.renderAnnotationElement(A))}this.#Xi()}update({viewport:t}){const e=this.div;this.viewport=t,br(e,{rotation:t.rotation}),this.#Xi(),e.hidden=!1}#Xi(){if(!this.#ji)return;const t=this.div;for(const[e,A]of this.#ji){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;A.className="annotationContent";const{firstChild:s}=i;s?"CANVAS"===s.nodeName?s.replaceWith(A):s.classList.contains("annotationContent")?s.after(A):s.before(A):i.append(A)}this.#ji.clear()}getEditableAnnotations(){return Array.from(this.#Vi.values())}getEditableAnnotation(t){return this.#Vi.get(t)}}const rc=/\r\n?|\n/g;class oc extends Gr{#zi=this.editorDivBlur.bind(this);#$i=this.editorDivFocus.bind(this);#ts=this.editorDivInput.bind(this);#es=this.editorDivKeydown.bind(this);#As=this.editorDivPaste.bind(this);#yi;#is="";#ss=`${this.id}-editor`;#Li;#as=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=oc.prototype,e=t=>t.isEmpty(),A=Nr.TRANSLATE_SMALL,i=Nr.TRANSLATE_BIG;return Nn(this,"_keyboardManager",new Rr([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-A,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[A,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-A],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,A],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=Bn.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#yi=t.color||oc._defaultColor||Gr._defaultLineColor,this.#Li=t.fontSize||oc._defaultFontSize}static initialize(t,e){Gr.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const A=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(A.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Qn.FREETEXT_SIZE:oc._defaultFontSize=e;break;case Qn.FREETEXT_COLOR:oc._defaultColor=e}}updateParams(t,e){switch(t){case Qn.FREETEXT_SIZE:this.#ns(e);break;case Qn.FREETEXT_COLOR:this.#rs(e)}}static get defaultPropertiesToUpdate(){return[[Qn.FREETEXT_SIZE,oc._defaultFontSize],[Qn.FREETEXT_COLOR,oc._defaultColor||Gr._defaultLineColor]]}get propertiesToUpdate(){return[[Qn.FREETEXT_SIZE,this.#Li],[Qn.FREETEXT_COLOR,this.#yi]]}#ns(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#Li)*this.parentScale),this.#Li=t,this.#os()},A=this.#Li;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#rs(t){const e=t=>{this.#yi=this.editorDiv.style.color=t},A=this.#yi;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-oc._internalPadding*t,-(oc._internalPadding+this.#Li)*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(Bn.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#es,{signal:t}),this.editorDiv.addEventListener("focus",this.#$i,{signal:t}),this.editorDiv.addEventListener("blur",this.#zi,{signal:t}),this.editorDiv.addEventListener("input",this.#ts,{signal:t}),this.editorDiv.addEventListener("paste",this.#As,{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.#ss),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#es),this.editorDiv.removeEventListener("focus",this.#$i),this.editorDiv.removeEventListener("blur",this.#zi),this.editorDiv.removeEventListener("input",this.#ts),this.editorDiv.removeEventListener("paste",this.#As),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(){this.width||(this.enableEditMode(),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()}#gs(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(oc.#cs(e));return t.join("\n")}#os(){const[t,e]=this.parentDimensions;let A;if(this.isAttachedToDOM)A=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,i=e.style.display,s=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),A=e.getBoundingClientRect(),e.remove(),e.style.display=i,e.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=A.width/t,this.height=A.height/e):(this.width=A.height/t,this.height=A.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#is,e=this.#is=this.#gs().trimEnd();if(t===e)return;const A=t=>{this.#is=t,t?(this.#hs(),this._uiManager.rebuild(this),this.#os()):this.remove()};this.addCommands({cmd:()=>{A(e)},undo:()=>{A(t)},mustExec:!1}),this.#os()}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){oc._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.#ss),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),Gr._l10nPromise.get("pdfjs-free-text-default-content").then((t=>this.editorDiv?.setAttribute("default-content",t))),this.editorDiv.contentEditable=!0;const{style:A}=this.editorDiv;if(A.fontSize=`calc(${this.#Li}px * var(--scale-factor))`,A.color=this.#yi,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),kr(this,this.div,["dblclick","keydown"]),this.width){const[A,i]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this.#as;let[a,n]=this.getInitialTranslation();[a,n]=this.pageTranslationToScreen(a,n);const[r,o]=this.pageDimensions,[g,c]=this.pageTranslation;let h,l;switch(this.rotation){case 0:h=t+(s[0]-g)/r,l=e+this.height-(s[1]-c)/o;break;case 90:h=t+(s[0]-g)/r,l=e-(s[1]-c)/o,[a,n]=[n,-a];break;case 180:h=t-this.width+(s[0]-g)/r,l=e-(s[1]-c)/o,[a,n]=[-a,-n];break;case 270:h=t+(s[0]-g-this.height*o)/r,l=e+(s[1]-c-this.width*r)/o,[a,n]=[-n,a]}this.setAt(h*A,l*i,a,n)}else this.setAt(t*A,e*i,this.width*A,this.height*i);this.#hs(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#cs(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(rc,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:A}=e;if(1===A.length&&"text/plain"===A[0])return;t.preventDefault();const i=oc.#ls(e.getData("text")||"").replaceAll(rc,"\n");if(!i)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();const a=s.getRangeAt(0);if(!i.includes("\n"))return a.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),void s.collapseToStart();const{startContainer:n,startOffset:r}=a,o=[],g=[];if(n.nodeType===Node.TEXT_NODE){const t=n.parentElement;if(g.push(n.nodeValue.slice(r).replaceAll(rc,"")),t!==this.editorDiv){let e=o;for(const A of this.editorDiv.childNodes)A!==t?e.push(oc.#cs(A)):e=g}o.push(n.nodeValue.slice(0,r).replaceAll(rc,""))}else if(n===this.editorDiv){let t=o,e=0;for(const A of this.editorDiv.childNodes)e++===r&&(t=g),t.push(oc.#cs(A))}this.#is=`${o.join("\n")}${i}${g.join("\n")}`,this.#hs();const c=new Range;let h=o.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(h<=e){c.setStart(t,h),c.setEnd(t,h);break}h-=e}s.removeAllRanges(),s.addRange(c)}#hs(){if(this.editorDiv.replaceChildren(),this.#is)for(const t of this.#is.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Is(){return this.#is.replaceAll(" "," ")}static#ls(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static deserialize(t,e,A){let i=null;if(t instanceof Og){const{data:{defaultAppearanceData:{fontSize:e,fontColor:A},rect:s,rotation:a,id:n},textContent:r,textPosition:o,parent:{page:{pageNumber:g}}}=t;if(!r||0===r.length)return null;i=t={annotationType:Bn.FREETEXT,color:Array.from(A),fontSize:e,value:r.join("\n"),position:o,pageIndex:g-1,rect:s.slice(0),rotation:a,id:n,deleted:!1}}const s=super.deserialize(t,e,A);return s.#Li=t.fontSize,s.#yi=Wn.makeHexColor(...t.color),s.#is=oc.#ls(t.value),s.annotationElementId=t.id||null,s.#as=i,s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=oc._internalPadding*this.parentScale,A=this.getRect(e,e),i=Gr._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#yi),s={annotationType:Bn.FREETEXT,color:i,fontSize:this.#Li,value:this.#Is(),pageIndex:this.pageIndex,rect:A,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?s:this.annotationElementId&&!this.#ds(s)?null:(s.id=this.annotationElementId,s)}#ds(t){const{value:e,fontSize:A,color:i,pageIndex:s}=this.#as;return this._hasBeenMoved||t.value!==e||t.fontSize!==A||t.color.some(((t,e)=>t!==i[e]))||t.pageIndex!==s}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:A}=e;A.fontSize=`calc(${this.#Li}px * var(--scale-factor))`,A.color=this.#yi,e.replaceChildren();for(const t of this.#is.split("\n")){const A=document.createElement("div");A.append(t?document.createTextNode(t):document.createElement("br")),e.append(A)}const i=oc._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#is}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class gc{#us;#Cs=[];#Bs=[];constructor(t,e=0,A=0,i=!0){let s=1/0,a=-1/0,n=1/0,r=-1/0;const o=10**-4;for(const{x:A,y:i,width:g,height:c}of t){const t=Math.floor((A-e)/o)*o,h=Math.ceil((A+g+e)/o)*o,l=Math.floor((i-e)/o)*o,I=Math.ceil((i+c+e)/o)*o,d=[t,l,I,!0],u=[h,l,I,!1];this.#Cs.push(d,u),s=Math.min(s,t),a=Math.max(a,h),n=Math.min(n,l),r=Math.max(r,I)}const g=a-s+2*A,c=r-n+2*A,h=s-A,l=n-A,I=this.#Cs.at(i?-1:-2),d=[I[0],I[2]];for(const t of this.#Cs){const[e,A,i]=t;t[0]=(e-h)/g,t[1]=(A-l)/c,t[2]=(i-l)/c}this.#us={x:h,y:l,width:g,height:c,lastPoint:d}}getOutlines(){this.#Cs.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Cs)e[3]?(t.push(...this.#Qs(e)),this.#Es(e)):(this.#fs(e),t.push(...this.#Qs(e)));return this.#ps(t)}#ps(t){const e=[],A=new Set;for(const A of t){const[t,i,s]=A;e.push([t,i,A],[t,s,A])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,i=e.length;t0;){const t=A.values().next().value;let[e,a,n,r,o]=t;A.delete(t);let g=e,c=a;for(s=[e,n],i.push(s);;){let t;if(A.has(r))t=r;else{if(!A.has(o))break;t=o}A.delete(t),[e,a,n,r,o]=t,g!==e&&(s.push(g,c,e,c===a?a:n),g=e),c=c===a?n:a}s.push(g,c)}return new hc(i,this.#us)}#ms(t){const e=this.#Bs;let A=0,i=e.length-1;for(;A<=i;){const s=A+i>>1,a=e[s][0];if(a===t)return s;a=0;i--){const[A,s]=this.#Bs[i];if(A!==t)break;if(A===t&&s===e)return void this.#Bs.splice(i,1)}}#Qs(t){const[e,A,i]=t,s=[[e,A,i]],a=this.#ms(i);for(let t=0;t=A)if(r>i)s[t][1]=i;else{if(1===a)return[];s.splice(t,1),t--,a--}else s[t][2]=A,r>i&&s.push([e,i,r])}}return s}}class cc{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(t,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof Ic}}class hc extends cc{#us;#ys;constructor(t,e){super(),this.#ys=t,this.#us=e}toSVGPath(){const t=[];for(const e of this.#ys){let[A,i]=e;t.push(`M${A} ${i}`);for(let s=2;s=6;t-=6)isNaN(e[t])?l.push(`L${e[t+4]} ${e[t+5]}`):l.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return l.push(`L${e[4]} ${e[5]} Z`),l.join(" ")}getOutlines(){const t=this.#ks,e=this.#bs,A=this.#Ss,i=A.subarray(4,6),s=A.subarray(16,18),[a,n,r,o]=this.#us,g=new Float64Array((this.#Gs?.length??0)+2);for(let t=0,e=g.length-2;t=6;t-=6)for(let A=0;A<6;A+=2)isNaN(e[t+A])?(d[u]=d[u+1]=NaN,u+=2):(d[u]=e[t+A],d[u+1]=e[t+A+1],u+=2);return d.set([NaN,NaN,NaN,NaN,e[4],e[5]],u),new Ic(d,g,this.#us,this.#Ns,this.#ws,this.#Ds)}}class Ic extends cc{#us;#_s=null;#ws;#Ds;#Gs;#Ns;#Ys;constructor(t,e,A,i,s,a){super(),this.#Ys=t,this.#Gs=e,this.#us=A,this.#Ns=i,this.#ws=s,this.#Ds=a,this.#Ts(a);const{x:n,y:r,width:o,height:g}=this.#_s;for(let e=0,A=t.length;e-1?(this.#Ia=!0,this.#fa(t),this.#pa()):(this.#sa=t.anchorNode,this.#aa=t.anchorOffset,this.#ga=t.focusNode,this.#ca=t.focusOffset,this.#ma(),this.#pa(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Ia?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#Ms,methodOfCreation:this.#Ea}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ma(){const t=new gc(this.#na,.001);this.#la=t.getOutlines(),({x:this.x,y:this.y,width:this.width,height:this.height}=this.#la.box);const e=new gc(this.#na,.0025,.001,"ltr"===this._uiManager.direction);this.#oa=e.getOutlines();const{lastPoint:A}=this.#oa.box;this.#ua=[(A[0]-this.x)/this.width,(A[1]-this.y)/this.height]}#fa({highlightOutlines:t,highlightId:e,clipPathId:A}){if(this.#la=t,this.#oa=t.getNewOutline(this.#Ms/2+1.5,.0025),e>=0)this.#B=e,this.#ra=A,this.parent.drawLayer.finalizeLine(e,t),this.#Ba=this.parent.drawLayer.highlightOutline(this.#oa);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#B,t),this.parent.drawLayer.updateBox(this.#B,uc.#ya(this.#la.box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#Ba,this.#oa),this.parent.drawLayer.updateBox(this.#Ba,uc.#ya(this.#oa.box,e))}const{x:i,y:s,width:a,height:n}=t.box;switch(this.rotation){case 0:this.x=i,this.y=s,this.width=a,this.height=n;break;case 90:{const[t,e]=this.parentDimensions;this.x=s,this.y=1-i,this.width=a*e/t,this.height=n*t/e;break}case 180:this.x=1-i,this.y=1-s,this.width=a,this.height=n;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-s,this.y=i,this.width=a*e/t,this.height=n*t/e;break}}const{lastPoint:r}=this.#oa.box;this.#ua=[(r[0]-i)/a,(r[1]-s)/n]}static initialize(t,e){Gr.initialize(t,e),uc._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Qn.HIGHLIGHT_DEFAULT_COLOR:uc._defaultColor=e;break;case Qn.HIGHLIGHT_THICKNESS:uc._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ua}updateParams(t,e){switch(t){case Qn.HIGHLIGHT_COLOR:this.#rs(e);break;case Qn.HIGHLIGHT_THICKNESS:this.#ba(e)}}static get defaultPropertiesToUpdate(){return[[Qn.HIGHLIGHT_DEFAULT_COLOR,uc._defaultColor],[Qn.HIGHLIGHT_THICKNESS,uc._defaultThickness]]}get propertiesToUpdate(){return[[Qn.HIGHLIGHT_COLOR,this.color||uc._defaultColor],[Qn.HIGHLIGHT_THICKNESS,this.#Ms||uc._defaultThickness],[Qn.HIGHLIGHT_FREE,this.#Ia]]}#rs(t){const e=t=>{this.color=t,this.parent?.drawLayer.changeColor(this.#B,t),this.#s?.updateColor(t)},A=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#ba(t){const e=this.#Ms,A=t=>{this.#Ms=t,this.#wa(t)};this.addCommands({cmd:A.bind(this,t),undo:A.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.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.#s=new dc({editor:this}),t.addColorPicker(this.#s)),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.#Da())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Da())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#ka(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#pa(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#ka():t&&(this.#pa(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#wa(t){if(!this.#Ia)return;this.#fa({highlightOutlines:this.#la.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,A]=this.parentDimensions;this.setDims(this.width*e,this.height*A)}#ka(){null!==this.#B&&this.parent&&(this.parent.drawLayer.remove(this.#B),this.#B=null,this.parent.drawLayer.remove(this.#Ba),this.#Ba=null)}#pa(t=this.parent){null===this.#B&&(({id:this.#B,clipPathId:this.#ra}=t.drawLayer.highlight(this.#la,this.color,this.#Ca)),this.#Ba=t.drawLayer.highlightOutline(this.#oa),this.#ha&&(this.#ha.style.clipPath=this.#ra))}static#ya({x:t,y:e,width:A,height:i},s){switch(s){case 90:return{x:1-e-i,y:t,width:i,height:A};case 180:return{x:1-t-A,y:1-e-i,width:A,height:i};case 270:return{x:e,y:1-t-A,width:i,height:A}}return{x:t,y:e,width:A,height:i}}rotate(t){const{drawLayer:e}=this.parent;let A;this.#Ia?(t=(t-this.rotation+360)%360,A=uc.#ya(this.#la.box,t)):A=uc.#ya(this,t),e.rotate(this.#B,t),e.rotate(this.#Ba,t),e.updateBox(this.#B,A),e.updateBox(this.#Ba,uc.#ya(this.#oa.box,t))}render(){if(this.div)return this.div;const t=super.render();this.#Qa&&(t.setAttribute("aria-label",this.#Qa),t.setAttribute("role","mark")),this.#Ia?t.classList.add("free"):this.div.addEventListener("keydown",this.#ot,{signal:this._uiManager._signal});const e=this.#ha=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#ra;const[A,i]=this.parentDimensions;return this.setDims(this.width*A,this.height*i),kr(this,this.#ha,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#Ba,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#Ba,"hovered")}#da(t){uc._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#Sa(!0);break;case 1:case 3:this.#Sa(!1)}}#Sa(t){if(!this.#sa)return;const e=window.getSelection();t?e.setPosition(this.#sa,this.#aa):e.setPosition(this.#ga,this.#ca)}select(){super.select(),this.#Ba&&(this.parent?.drawLayer.removeClass(this.#Ba,"hovered"),this.parent?.drawLayer.addClass(this.#Ba,"selected"))}unselect(){super.unselect(),this.#Ba&&(this.parent?.drawLayer.removeClass(this.#Ba,"selected"),this.#Ia||this.#Sa(!1))}get _mustFixPosition(){return!this.#Ia}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#B,t),this.parent.drawLayer.show(this.#Ba,t))}#Da(){return this.#Ia?this.rotation:0}#xa(){if(this.#Ia)return null;const[t,e]=this.pageDimensions,[A,i]=this.pageTranslation,s=this.#na,a=new Float32Array(8*s.length);let n=0;for(const{x:r,y:o,width:g,height:c}of s){const s=r*t+A,h=(1-o-c)*e+i;a[n]=a[n+4]=s,a[n+1]=a[n+3]=h,a[n+2]=a[n+6]=s+g*t,a[n+5]=a[n+7]=h+c*e,n+=8}return a}#Fa(t){return this.#la.serialize(t,this.#Da())}static startHighlighting(t,e,{target:A,x:i,y:s}){const{x:a,y:n,width:r,height:o}=A.getBoundingClientRect(),g=e=>{this.#Ra(t,e)},c=t._signal,h={capture:!0,passive:!1,signal:c},l=t=>{t.preventDefault(),t.stopPropagation()},I=e=>{A.removeEventListener("pointermove",g),window.removeEventListener("blur",I),window.removeEventListener("pointerup",I),window.removeEventListener("pointerdown",l,h),window.removeEventListener("contextmenu",Br),this.#va(t,e)};window.addEventListener("blur",I,{signal:c}),window.addEventListener("pointerup",I,{signal:c}),window.addEventListener("pointerdown",l,h),window.addEventListener("contextmenu",Br,{signal:c}),A.addEventListener("pointermove",g,{signal:c}),this._freeHighlight=new lc({x:i,y:s},[a,n,r,o],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static#Ra(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#va(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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 deserialize(t,e,A){const i=super.deserialize(t,e,A),{rect:[s,a,n,r],color:o,quadPoints:g}=t;i.color=Wn.makeHexColor(...o),i.#Ca=t.opacity;const[c,h]=i.pageDimensions;i.width=(n-s)/c,i.height=(r-a)/h;const l=i.#na=[];for(let t=0;t{this.thickness=t,this.#Va()},A=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#rs(t){const e=t=>{this.color=t,this.#Za()},A=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#ja(t){const e=t=>{this.opacity=t,this.#Za()};t/=100;const A=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,A),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Qn.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(this.#Xa(),this.#za()),this.isAttachedToDOM||(this.parent.add(this),this.#$a()),this.#Va()))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#Ja&&(clearTimeout(this.#Ja),this.#Ja=null),this.#Ka?.disconnect(),this.#Ka=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&null===t&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,A=this.width*t,i=this.height*e;this.setDimensions(A,i)}enableEditMode(){this.#Ya||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#Ha,{signal:this._uiManager._signal}))}disableEditMode(){this.isInEditMode()&&null!==this.canvas&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#Ha))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#tn(){const{parentRotation:t,parentDimensions:[e,A]}=this;switch(t){case 90:return[0,A,A,e];case 180:return[e,A,e,A];case 270:return[e,0,A,e];default:return[0,0,e,A]}}#en(){const{ctx:t,color:e,opacity:A,thickness:i,parentScale:s,scaleFactor:a}=this;t.lineWidth=i*s/a,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${function(t){return Math.round(Math.min(255,Math.max(1,255*t))).toString(16).padStart(2,"0")}(A)}`}#An(t,e){const A=this._uiManager._signal;this.canvas.addEventListener("contextmenu",Br,{signal:A}),this.canvas.addEventListener("pointerleave",this.#La,{signal:A}),this.canvas.addEventListener("pointermove",this.#Ga,{signal:A}),this.canvas.addEventListener("pointerup",this.#Ua,{signal:A}),this.canvas.removeEventListener("pointerdown",this.#Ha),this.isEditing=!0,this.#Pa||(this.#Pa=!0,this.#$a(),this.thickness||=Cc._defaultThickness,this.color||=Cc._defaultColor||Gr._defaultLineColor,this.opacity??=Cc._defaultOpacity),this.currentPath.push([t,e]),this.#Ta=!1,this.#en(),this.#Wa=()=>{this.#in(),this.#Wa&&window.requestAnimationFrame(this.#Wa)},window.requestAnimationFrame(this.#Wa)}#sn(t,e){const[A,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===A&&e===i)return;const s=this.currentPath;let a=this.#_a;if(s.push([t,e]),this.#Ta=!0,s.length<=2)return a.moveTo(...s[0]),void a.lineTo(t,e);3===s.length&&(this.#_a=a=new Path2D,a.moveTo(...s[0])),this.#an(a,...s.at(-3),...s.at(-2),t,e)}#nn(){if(0===this.currentPath.length)return;const t=this.currentPath.at(-1);this.#_a.lineTo(...t)}#rn(t,e){let A;if(this.#Wa=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#sn(t,e),this.#nn(),1!==this.currentPath.length)A=this.#on();else{const i=[t,e];A=[[i,i.slice(),i.slice(),i]]}const i=this.#_a,s=this.currentPath;this.currentPath=[],this.#_a=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(s),this.paths.push(A),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(this.#Xa(),this.#za()),this.#Va())},mustExec:!0})}#in(){if(!this.#Ta)return;this.#Ta=!1;Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),e=t.map((t=>t[0])),A=t.map((t=>t[1])),{ctx:i}=(Math.min(...e),Math.max(...e),Math.min(...A),Math.max(...A),this);i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.bezierPath2D)i.stroke(t);i.stroke(this.#_a),i.restore()}#an(t,e,A,i,s,a,n){const r=(e+i)/2,o=(A+s)/2,g=(i+a)/2,c=(s+n)/2;t.bezierCurveTo(r+2*(i-r)/3,o+2*(s-o)/3,g+2*(i-g)/3,c+2*(s-c)/3,g,c)}#on(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let A,[i,s]=t[0];for(A=1;A{this.#Ja=null,this.canvas.removeEventListener("contextmenu",Br)}),10),this.#rn(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#Xa(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#za(){this.#Ka=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)})),this.#Ka.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#Ka?.disconnect(),this.#Ka=null}),{once:!0})}get isResizable(){return!this.isEmpty()&&this.#Ya}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[A,i,s,a]=this.#tn();if(this.setAt(A,i,0,0),this.setDims(s,a),this.#Xa(),this.width){const[A,i]=this.parentDimensions;this.setAspectRatio(this.width*A,this.height*i),this.setAt(t*A,e*i,this.width*A,this.height*i),this.#Pa=!0,this.#$a(),this.setDims(this.width*A,this.height*i),this.#Za(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#za(),this.div}#$a(){if(!this.#Pa)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#gn()}setDimensions(t,e){const A=Math.round(t),i=Math.round(e);if(this.#qa===A&&this.#Oa===i)return;this.#qa=A,this.#Oa=i,this.canvas.style.visibility="hidden";const[s,a]=this.parentDimensions;this.width=t/s,this.height=e/a,this.fixAndSetPosition(),this.#Ya&&this.#hn(t,e),this.#$a(),this.#Za(),this.canvas.style.visibility="visible",this.fixDims()}#hn(t,e){const A=this.#ln(),i=(t-A)/this.#Ma,s=(e-A)/this.#Na;this.scaleFactor=Math.min(i,s)}#gn(){const t=this.#ln()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#In(t){const e=new Path2D;for(let A=0,i=t.length;A`image/${t}`)))}static get supportedTypesStr(){return Nn(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Bn.STAMP,{bitmapFile:t.getAsFile()})}#xn(t,e=!1){t?(this.#Qn=t.bitmap,e||(this.#En=t.id,this.#kn=t.isSvg),t.file&&(this.#yn=t.file.name),this.#Xa()):this.remove()}#Fn(){this.#fn=null,this._uiManager.enableWaiting(!1),this.#bn&&this.div.focus()}#Rn(){if(this.#En)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#En).then((t=>this.#xn(t,!0))).finally((()=>this.#Fn()));if(this.#pn){const t=this.#pn;return this.#pn=null,this._uiManager.enableWaiting(!0),void(this.#fn=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#xn(t))).finally((()=>this.#Fn())))}if(this.#mn){const t=this.#mn;return this.#mn=null,this._uiManager.enableWaiting(!0),void(this.#fn=this._uiManager.imageManager.getFromFile(t).then((t=>this.#xn(t))).finally((()=>this.#Fn())))}const t=document.createElement("input");t.type="file",t.accept=Bc.supportedTypesStr;const e=this._uiManager._signal;this.#fn=new Promise((A=>{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.#xn(e)}else this.remove();A()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),A()}),{signal:e})})).finally((()=>this.#Fn())),t.click()}remove(){this.#En&&(this.#Qn=null,this._uiManager.imageManager.deleteId(this.#En),this.#bn?.remove(),this.#bn=null,this.#Ka?.disconnect(),this.#Ka=null,this.#Dn&&(clearTimeout(this.#Dn),this.#Dn=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#En&&null===this.#bn&&this.#Rn(),this.isAttachedToDOM||this.parent.add(this))):this.#En&&this.#Rn()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#fn||this.#Qn||this.#pn||this.#mn||this.#En)}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.addAltTextButton(),this.#Qn?this.#Xa():this.#Rn(),this.width){const[A,i]=this.parentDimensions;this.setAt(t*A,e*i,this.width*A,this.height*i)}return this.div}#Xa(){const{div:t}=this;let{width:e,height:A}=this.#Qn;const[i,s]=this.pageDimensions,a=.75;if(this.width)e=this.width*i,A=this.height*s;else if(e>a*i||A>a*s){const t=Math.min(a*i/e,a*s/A);e*=t,A*=t}const[n,r]=this.parentDimensions;this.setDims(e*n/i,A*r/s),this._uiManager.enableWaiting(!1);const o=this.#bn=document.createElement("canvas");t.append(o),t.hidden=!1,this.#vn(e,A),this.#za(),this.#Sn||(this.parent.addUndoableEditor(this),this.#Sn=!0),this._reportTelemetry({action:"inserted_image"}),this.#yn&&o.setAttribute("aria-label",this.#yn)}#Nn(t,e){const[A,i]=this.parentDimensions;this.width=t/A,this.height=e/i,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#Dn&&clearTimeout(this.#Dn),this.#Dn=setTimeout((()=>{this.#Dn=null,this.#vn(t,e)}),200)}#Mn(t,e){const{width:A,height:i}=this.#Qn;let s=A,a=i,n=this.#Qn;for(;s>2*t||a>2*e;){const A=s,i=a;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const r=new OffscreenCanvas(s,a);r.getContext("2d").drawImage(n,0,0,A,i,0,0,s,a),n=r.transferToImageBitmap()}return n}async#Gn(t,e,A){if(this.#wn)return;if(this.#wn=!0,!await this._uiManager.isMLEnabledFor("altText")||this.hasAltText())return;const i=new OffscreenCanvas(e,A).getContext("2d",{willReadFrequently:!0});i.drawImage(t,0,0,t.width,t.height,0,0,e,A);const s=await this._uiManager.mlGuess({service:"moz-image-to-text",request:{data:i.getImageData(0,0,e,A).data,width:e,height:A,channels:4}}),a=s?.output||"";this.parent&&a&&!this.hasAltText()&&(this.altTextData={altText:a,decorative:!1})}#vn(t,e){t=Math.ceil(t),e=Math.ceil(e);const A=this.#bn;if(!A||A.width===t&&A.height===e)return;A.width=t,A.height=e;const i=this.#kn?this.#Qn:this.#Mn(t,e);this.#Gn(i,t,e);const s=A.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(i,0,0,i.width,i.height,0,0,t,e)}getImageForAltText(){return this.#bn}#Ln(t){if(t){if(this.#kn){const t=this._uiManager.imageManager.getSvgUrl(this.#En);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#Qn),t.getContext("2d").drawImage(this.#Qn,0,0),t.toDataURL()}if(this.#kn){const[t,e]=this.pageDimensions,A=Math.round(this.width*t*sr.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*sr.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(A,i);return s.getContext("2d").drawImage(this.#Qn,0,0,this.#Qn.width,this.#Qn.height,0,0,A,i),s.transferToImageBitmap()}return structuredClone(this.#Qn)}#za(){this._uiManager._signal&&(this.#Ka=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.#Nn(e.width,e.height)})),this.#Ka.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#Ka?.disconnect(),this.#Ka=null}),{once:!0}))}static deserialize(t,e,A){if(t instanceof sc)return null;const i=super.deserialize(t,e,A),{rect:s,bitmapUrl:a,bitmapId:n,isSvg:r,accessibilityData:o}=t;n&&A.imageManager.isValidId(n)?i.#En=n:i.#pn=a,i.#kn=r;const[g,c]=i.pageDimensions;return i.width=(s[2]-s[0])/g,i.height=(s[3]-s[1])/c,o&&(i.altTextData=o),i}serialize(t=!1,e=null){if(this.isEmpty())return null;const A={annotationType:Bn.STAMP,bitmapId:this.#En,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#kn,structTreeParentId:this._structTreeParentId};if(t)return A.bitmapUrl=this.#Ln(!0),A.accessibilityData=this.altTextData,A;const{decorative:i,altText:s}=this.altTextData;if(!i&&s&&(A.accessibilityData={type:"Figure",alt:s}),null===e)return A;e.stamps||=new Map;const a=this.#kn?(A.rect[2]-A.rect[0])*(A.rect[3]-A.rect[1]):null;if(e.stamps.has(this.#En)){if(this.#kn){const t=e.stamps.get(this.#En);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Ln(!1))}}else e.stamps.set(this.#En,{area:a,serialized:A}),A.bitmap=this.#Ln(!1);return A}}class Qc{#Wi;#Un=!1;#Hn=null;#Jn=null;#_n=null;#Yn=null;#Tn=null;#Pn=new Map;#Kn=!1;#qn=!1;#On=!1;#Wn=null;#I;static _initialized=!1;static#U=new Map([oc,Cc,Bc,uc].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:A,accessibilityManager:i,annotationLayer:s,drawLayer:a,textLayer:n,viewport:r,l10n:o}){const g=[...Qc.#U.values()];if(!Qc._initialized){Qc._initialized=!0;for(const e of g)e.initialize(o,t)}t.registerEditorTypes(g),this.#I=t,this.pageIndex=e,this.div=A,this.#Wi=i,this.#Hn=s,this.viewport=r,this.#Wn=n,this.drawLayer=a,this.#I.addLayer(this)}get isEmpty(){return 0===this.#Pn.size}get isInvisible(){return this.isEmpty&&this.#I.getMode()===Bn.NONE}updateToolbar(t){this.#I.updateToolbar(t)}updateMode(t=this.#I.getMode()){switch(this.#jn(),t){case Bn.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Bn.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Bn.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 A of Qc.#U.values())e.toggle(`${A._type}Editing`,t===A._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#Wn?.div}addInkEditorIfNeeded(t){if(this.#I.getMode()===Bn.INK){if(!t)for(const t of this.#Pn.values())if(t.isEmpty())return void t.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){this.#I.setEditingState(t)}addCommands(t){this.#I.addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Hn?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#Pn.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#I.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Hn)return;const e=this.#Hn.getEditableAnnotations();for(const A of e){if(A.hide(),this.#I.isDeletedAnnotationElement(A.data.id))continue;if(t.has(A.data.id))continue;const e=this.deserialize(A);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){this.#On=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const A of this.#Pn.values())A.disableEditing(),A.annotationElementId&&(null===A.serialize()?(e.set(A.annotationElementId,A),this.getEditableAnnotation(A.annotationElementId)?.show(),A.remove()):t.set(A.annotationElementId,A));if(this.#Hn){const A=this.#Hn.getEditableAnnotations();for(const i of A){const{id:A}=i.data;if(this.#I.isDeletedAnnotationElement(A))continue;let s=e.get(A);s?(s.resetAnnotationElement(i),s.show(!1),i.show()):(s=t.get(A),s&&(this.#I.addChangedExistingAnnotation(s),s.renderAnnotationElement(i),s.show(!1)),i.show())}}this.#jn(),this.isEmpty&&(this.div.hidden=!0);const{classList:A}=this.div;for(const t of Qc.#U.values())A.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#On=!1}getEditableAnnotation(t){return this.#Hn?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#I.getActive()!==t&&this.#I.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#Wn?.div&&!this.#Yn&&(this.#Yn=this.#Vn.bind(this),this.#Wn.div.addEventListener("pointerdown",this.#Yn,{signal:this.#I._signal}),this.#Wn.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#Wn?.div&&this.#Yn&&(this.#Wn.div.removeEventListener("pointerdown",this.#Yn),this.#Yn=null,this.#Wn.div.classList.remove("highlighting"))}#Vn(t){this.#I.unselectAll();const{target:e}=t;if(e===this.#Wn.div||e.classList.contains("endOfContent")&&this.#Wn.div.contains(e)){const{isMac:e}=qn.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#I.showAllEditors("highlight",!0,!0),this.#Wn.div.classList.add("free"),this.toggleDrawing(),uc.startHighlighting(this,"ltr"===this.#I.direction,t),this.#Wn.div.addEventListener("pointerup",(()=>{this.#Wn.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#I._signal}),t.preventDefault()}}enableClick(){if(this.#_n)return;const t=this.#I._signal;this.#_n=this.pointerdown.bind(this),this.#Jn=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#_n,{signal:t}),this.div.addEventListener("pointerup",this.#Jn,{signal:t})}disableClick(){this.#_n&&(this.div.removeEventListener("pointerdown",this.#_n),this.div.removeEventListener("pointerup",this.#Jn),this.#_n=null,this.#Jn=null)}attach(t){this.#Pn.set(t.id,t);const{annotationElementId:e}=t;e&&this.#I.isDeletedAnnotationElement(e)&&this.#I.removeDeletedAnnotationElement(t)}detach(t){this.#Pn.delete(t.id),this.#Wi?.removePointerInTextLayer(t.contentDiv),!this.#On&&t.annotationElementId&&this.#I.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#I.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#qn||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#I.addDeletedAnnotationElement(t.annotationElementId),Gr.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.#I.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#I.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Tn&&(t._focusEventsAllowed=!1,this.#Tn=setTimeout((()=>{this.#Tn=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#I._signal}),e.focus())}),0)),t._structTreeParentId=this.#Wi?.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.#I.getId()}get#Zn(){return Qc.#U.get(this.#I.getMode())}get _signal(){return this.#I._signal}#Xn(t){const e=this.#Zn;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Zn?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#I.updateToolbar(t),this.#I.updateMode(t);const{offsetX:A,offsetY:i}=this.#zn(),s=this.getNextId(),a=this.#Xn({parent:this,id:s,x:A,y:i,uiManager:this.#I,isCentered:!0,...e});a&&this.add(a)}deserialize(t){return Qc.#U.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#I)||null}createAndAddNewEditor(t,e,A={}){const i=this.getNextId(),s=this.#Xn({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#I,isCentered:e,...A});return s&&this.add(s),s}#zn(){const{x:t,y:e,width:A,height:i}=this.div.getBoundingClientRect(),s=Math.max(0,t),a=Math.max(0,e),n=(s+Math.min(window.innerWidth,t+A))/2-t,r=(a+Math.min(window.innerHeight,e+i))/2-e,[o,g]=this.viewport.rotation%180==0?[n,r]:[r,n];return{offsetX:o,offsetY:g}}addNewEditor(){this.createAndAddNewEditor(this.#zn(),!0)}setSelected(t){this.#I.setSelected(t)}toggleSelected(t){this.#I.toggleSelected(t)}isSelected(t){return this.#I.isSelected(t)}unselect(t){this.#I.unselect(t)}pointerup(t){const{isMac:e}=qn.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#Kn&&(this.#Kn=!1,this.#Un?this.#I.getMode()!==Bn.STAMP?this.createAndAddNewEditor(t,!1):this.#I.unselectAll():this.#Un=!0)}pointerdown(t){if(this.#I.getMode()===Bn.HIGHLIGHT&&this.enableTextSelection(),this.#Kn)return void(this.#Kn=!1);const{isMac:e}=qn.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;this.#Kn=!0;const A=this.#I.getActive();this.#Un=!A||A.isEmpty()}findNewParent(t,e,A){const i=this.#I.findParent(e,A);return null!==i&&i!==this&&(i.changeParent(t),!0)}destroy(){this.#I.getActive()?.parent===this&&(this.#I.commitOrRemove(),this.#I.setActiveEditor(null)),this.#Tn&&(clearTimeout(this.#Tn),this.#Tn=null);for(const t of this.#Pn.values())this.#Wi?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Pn.clear(),this.#I.removeLayer(this)}#jn(){this.#qn=!0;for(const t of this.#Pn.values())t.isEmpty()&&t.remove();this.#qn=!1}render({viewport:t}){this.viewport=t,br(this.div,t);for(const t of this.#I.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#I.commitOrRemove(),this.#jn();const e=this.viewport.rotation,A=t.rotation;if(this.viewport=t,br(this.div,{rotation:A}),e!==A)for(const t of this.#Pn.values())t.rotate(A);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#I.viewParameters.realScale}}class Ec{#ki=null;#B=0;#$n=new Map;#tr=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#ki){if(this.#ki!==t){if(this.#$n.size>0)for(const e of this.#$n.values())e.remove(),t.append(e);this.#ki=t}}else this.#ki=t}static get _svgFactory(){return Nn(this,"_svgFactory",new or)}static#er(t,{x:e=0,y:A=0,width:i=1,height:s=1}={}){const{style:a}=t;a.top=100*A+"%",a.left=100*e+"%",a.width=100*i+"%",a.height=100*s+"%"}#Ar(t){const e=Ec._svgFactory.create(1,1,!0);return this.#ki.append(e),e.setAttribute("aria-hidden",!0),Ec.#er(e,t),e}#ir(t,e){const A=Ec._svgFactory.createElement("clipPath");t.append(A);const i=`clip_${e}`;A.setAttribute("id",i),A.setAttribute("clipPathUnits","objectBoundingBox");const s=Ec._svgFactory.createElement("use");return A.append(s),s.setAttribute("href",`#${e}`),s.classList.add("clip"),i}highlight(t,e,A,i=!1){const s=this.#B++,a=this.#Ar(t.box);a.classList.add("highlight"),t.free&&a.classList.add("free");const n=Ec._svgFactory.createElement("defs");a.append(n);const r=Ec._svgFactory.createElement("path");n.append(r);const o=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",o),r.setAttribute("d",t.toSVGPath()),i&&this.#tr.set(s,r);const g=this.#ir(n,o),c=Ec._svgFactory.createElement("use");return a.append(c),a.setAttribute("fill",e),a.setAttribute("fill-opacity",A),c.setAttribute("href",`#${o}`),this.#$n.set(s,a),{id:s,clipPathId:`url(#${g})`}}highlightOutline(t){const e=this.#B++,A=this.#Ar(t.box);A.classList.add("highlightOutline");const i=Ec._svgFactory.createElement("defs");A.append(i);const s=Ec._svgFactory.createElement("path");i.append(s);const a=`path_p${this.pageIndex}_${e}`;let n;if(s.setAttribute("id",a),s.setAttribute("d",t.toSVGPath()),s.setAttribute("vector-effect","non-scaling-stroke"),t.free){A.classList.add("free");const t=Ec._svgFactory.createElement("mask");i.append(t),n=`mask_p${this.pageIndex}_${e}`,t.setAttribute("id",n),t.setAttribute("maskUnits","objectBoundingBox");const s=Ec._svgFactory.createElement("rect");t.append(s),s.setAttribute("width","1"),s.setAttribute("height","1"),s.setAttribute("fill","white");const r=Ec._svgFactory.createElement("use");t.append(r),r.setAttribute("href",`#${a}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}const r=Ec._svgFactory.createElement("use");A.append(r),r.setAttribute("href",`#${a}`),n&&r.setAttribute("mask",`url(#${n})`);const o=r.cloneNode();return A.append(o),r.classList.add("mainOutline"),o.classList.add("secondaryOutline"),this.#$n.set(e,A),e}finalizeLine(t,e){const A=this.#tr.get(t);this.#tr.delete(t),this.updateBox(t,e.box),A.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#$n.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#tr.delete(t)}updatePath(t,e){this.#tr.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){Ec.#er(this.#$n.get(t),e)}show(t,e){this.#$n.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#$n.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#$n.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#$n.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#$n.get(t).classList.add(e)}removeClass(t,e){this.#$n.get(t).classList.remove(e)}remove(t){null!==this.#ki&&(this.#$n.get(t).remove(),this.#$n.delete(t))}destroy(){this.#ki=null;for(const t of this.#$n.values())t.remove();this.#$n.clear()}}var fc={d:(t,e)=>{for(var A in e)fc.o(e,A)&&!fc.o(t,A)&&Object.defineProperty(t,A,{enumerable:!0,get:e[A]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},pc=globalThis.pdfjsWorker={};fc.d(pc,{WorkerMessageHandler:()=>OF});const mc=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),yc=[1,0,0,1,0,0],bc=[.001,0,0,.001,0,0],wc=1.35,Dc=.25925925925925924,kc="pdfjs_internal_editor_",Sc={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},xc="Group",Fc=8192,Rc=65536,vc={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},Nc={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},Mc={O:"PageOpen",C:"PageClose"},Gc={ERRORS:0,WARNINGS:1,INFOS:5},Lc={NONE:0,BINARY:1},Uc=10,Hc=11,Jc=12,_c=37,Yc=44,Tc=58,Pc=59,Kc=70,qc=71,Oc=83,Wc=85;let jc=Gc.WARNINGS;function Vc(t){jc>=Gc.INFOS&&console.log(`Info: ${t}`)}function Zc(t){jc>=Gc.WARNINGS&&console.log(`Warning: ${t}`)}function Xc(t){throw new Error(t)}function zc(t,e){t||Xc(e)}function $c(t,e=null,A=null){if(!t)return null;try{if(A&&"string"==typeof t){if(A.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(A.tryConvertEncoding)try{t=Qh(t)}catch{}}const i=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}}(i))return i}catch{}return null}function th(t,e,A,i=!1){return Object.defineProperty(t,e,{value:A,enumerable:!i,configurable:!0,writable:!1}),A}const eh=function(){function t(e,A){this.constructor===t&&Xc("Cannot initialize BaseException."),this.message=e,this.name=A}return t.prototype=new Error,t.constructor=t,t}();class Ah extends eh{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ih extends eh{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class sh extends eh{constructor(t){super(t,"InvalidPDFException")}}class ah extends eh{constructor(t){super(t,"MissingPDFException")}}class nh extends eh{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class rh extends eh{constructor(t){super(t,"FormatError")}}class oh extends eh{constructor(t){super(t,"AbortException")}}function gh(t){"object"==typeof t&&void 0!==t?.length||Xc("Invalid argument for bytesToString");const e=t.length,A=8192;if(e>24&255,t>>16&255,t>>8&255,255&t)}function lh(t){return Object.keys(t).length}class Ih{static get isLittleEndian(){return th(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return th(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return th(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?th(this,"platform",{isMac:navigator.platform.includes("Mac")}):th(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return th(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const dh=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class uh{static makeHexColor(t,e,A){return`#${dh[t]}${dh[e]}${dh[A]}`}static scaleMinMax(t,e){let A;t[0]?(t[0]<0&&(A=e[0],e[0]=e[2],e[2]=A),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(A=e[1],e[1]=e[3],e[3]=A),e[1]*=t[3],e[3]*=t[3]):(A=e[0],e[0]=e[1],e[1]=A,A=e[2],e[2]=e[3],e[3]=A,t[1]<0&&(A=e[1],e[1]=e[3],e[3]=A),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(A=e[0],e[0]=e[2],e[2]=A),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 A=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])/A,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/A]}static getAxialAlignedBoundingBox(t,e){const A=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),s=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(A[0],i[0],s[0],a[0]),Math.min(A[1],i[1],s[1],a[1]),Math.max(A[0],i[0],s[0],a[0]),Math.max(A[1],i[1],s[1],a[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]],A=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],s=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],n=(A+a)/2,r=Math.sqrt((A+a)**2-4*(A*a-s*i))/2,o=n+r||1,g=n-r||1;return[Math.sqrt(o),Math.sqrt(g)]}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 A=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(A>i)return null;const s=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return s>a?null:[A,s,i,a]}static#sr(t,e,A,i,s,a,n,r,o,g){if(o<=0||o>=1)return;const c=1-o,h=o*o,l=h*o,I=c*(c*(c*t+3*o*e)+3*h*A)+l*i,d=c*(c*(c*s+3*o*a)+3*h*n)+l*r;g[0]=Math.min(g[0],I),g[1]=Math.min(g[1],d),g[2]=Math.max(g[2],I),g[3]=Math.max(g[3],d)}static#ar(t,e,A,i,s,a,n,r,o,g,c,h){if(Math.abs(o)<1e-12)return void(Math.abs(g)>=1e-12&&this.#sr(t,e,A,i,s,a,n,r,-c/g,h));const l=g**2-4*c*o;if(l<0)return;const I=Math.sqrt(l),d=2*o;this.#sr(t,e,A,i,s,a,n,r,(-g+I)/d,h),this.#sr(t,e,A,i,s,a,n,r,(-g-I)/d,h)}static bezierBoundingBox(t,e,A,i,s,a,n,r,o){return o?(o[0]=Math.min(o[0],t,n),o[1]=Math.min(o[1],e,r),o[2]=Math.max(o[2],t,n),o[3]=Math.max(o[3],e,r)):o=[Math.min(t,n),Math.min(e,r),Math.max(t,n),Math.max(e,r)],this.#ar(t,A,s,n,e,i,a,r,3*(3*(A-s)-t+n),6*(t-2*A+s),3*(A-t),o),this.#ar(t,A,s,n,e,i,a,r,3*(3*(i-a)-e+r),6*(e-2*i+a),3*(i-e),o),o}}const Ch=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function Bh(t){if(t[0]>="ï"){let e;if("þ"===t[0]&&"ÿ"===t[1]?(e="utf-16be",t.length%2==1&&(t=t.slice(0,-1))):"ÿ"===t[0]&&"þ"===t[1]?(e="utf-16le",t.length%2==1&&(t=t.slice(0,-1))):"ï"===t[0]&&"»"===t[1]&&"¿"===t[2]&&(e="utf-8"),e)try{const A=new TextDecoder(e,{fatal:!0}),i=ch(t),s=A.decode(i);return s.includes("")?s.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g,""):s}catch(t){Zc(`stringToPDFString: "${t}".`)}}const e=[];for(let A=0,i=t.length;A{Xc("Should not call `set` on the empty dictionary.")},th(this,"empty",t)}static merge({xref:t,dictArray:e,mergeSubDicts:A=!1}){const i=new vh(t),s=new Map;for(const t of e)if(t instanceof vh)for(const[e,i]of Object.entries(t._map)){let t=s.get(e);if(void 0===t)t=[],s.set(e,t);else if(!(A&&i instanceof vh))continue;t.push(i)}for(const[e,A]of s){if(1===A.length||!(A[0]instanceof vh)){i._map[e]=A[0];continue}const s=new vh(t);for(const t of A)for(const[e,A]of Object.entries(t._map))void 0===s._map[e]&&(s._map[e]=A);s.size>0&&(i._map[e]=s)}return s.clear(),i.size>0?i:vh.empty}clone(){const t=new vh(this.xref);for(const e of this.getKeys())t.set(e,this.getRaw(e));return t}delete(t){delete this._map[t]}}class Nh{constructor(t,e){this.num=t,this.gen=e}toString(){return 0===this.gen?`${this.num}R`:`${this.num}R${this.gen}`}static fromString(t){const e=Sh[t];if(e)return e;const A=/^(\d+)R(\d*)$/.exec(t);return A&&"0"!==A[1]?Sh[t]=new Nh(parseInt(A[1]),A[2]?parseInt(A[2]):0):null}static get(t,e){const A=0===e?`${t}R`:`${t}R${e}`;return Sh[A]||=new Nh(t,e)}}class Mh{constructor(t=null){this._set=new Set(t?._set)}has(t){return this._set.has(t.toString())}put(t){this._set.add(t.toString())}remove(t){this._set.delete(t.toString())}[Symbol.iterator](){return this._set.values()}clear(){this._set.clear()}}class Gh{constructor(){this._map=new Map}get size(){return this._map.size}get(t){return this._map.get(t.toString())}has(t){return this._map.has(t.toString())}put(t,e){this._map.set(t.toString(),e)}putAlias(t,e){this._map.set(t.toString(),this.get(e))}[Symbol.iterator](){return this._map.values()}clear(){this._map.clear()}*items(){for(const[t,e]of this._map)yield[Nh.fromString(t),e]}}function Lh(t,e){return t instanceof xh&&(void 0===e||t.name===e)}function Uh(t,e){return t instanceof Fh&&(void 0===e||t.cmd===e)}function Hh(t,e){return t instanceof vh&&(void 0===e||Lh(t.get("Type"),e))}function Jh(t,e){return t.num===e.num&&t.gen===e.gen}class _h{constructor(){this.constructor===_h&&Xc("Cannot initialize BaseStream.")}get length(){Xc("Abstract getter `length` accessed")}get isEmpty(){Xc("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return th(this,"isDataLoaded",!0)}getByte(){Xc("Abstract method `getByte` called")}getBytes(t){Xc("Abstract method `getBytes` called")}async getImageData(t,e){return this.getBytes(t,e)}async asyncGetBytes(){Xc("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}peekByte(){const t=this.getByte();return-1!==t&&this.pos--,t}peekBytes(t){const e=this.getBytes(t);return this.pos-=e.length,e}getUint16(){const t=this.getByte(),e=this.getByte();return-1===t||-1===e?-1:(t<<8)+e}getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()}getByteRange(t,e){Xc("Abstract method `getByteRange` called")}getString(t){return gh(this.getBytes(t))}skip(t){this.pos+=t||1}reset(){Xc("Abstract method `reset` called")}moveStart(){Xc("Abstract method `moveStart` called")}makeSubStream(t,e,A=null){Xc("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}const Yh=/^[1-9]\.\d$/;function Th(t){let e;return function(){return t&&(e=Object.create(null),t(e),t=null),e}}class Ph extends eh{constructor(t,e){super(`Missing data [${t}, ${e})`,"MissingDataException"),this.begin=t,this.end=e}}class Kh extends eh{constructor(t){super(t,"ParserEOFException")}}class qh extends eh{constructor(t){super(t,"XRefEntryException")}}class Oh extends eh{constructor(t){super(t,"XRefParseException")}}function Wh(t){const e=t.length;if(0===e)return new Uint8Array(0);if(1===e)return new Uint8Array(t[0]);let A=0;for(let i=0;i0,"The number should be a positive integer.");const A=[];let i;for(;t>=1e3;)t-=1e3,A.push("M");i=t/100|0,t%=100,A.push(Vh[i]),i=t/10|0,t%=10,A.push(Vh[10+i]),A.push(Vh[20+t]);const s=A.join("");return e?s.toLowerCase():s}function Xh(t){return t<=0?0:Math.ceil(Math.log2(t))}function zh(t,e){return t[e]<<24>>24}function $h(t,e){return t[e]<<8|t[e+1]}function tl(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function el(t){return 32===t||9===t||13===t||10===t}function Al(t,e){return Array.isArray(t)&&(null===e||t.length===e)&&t.every((t=>"number"==typeof t))}function il(t,e){return Al(t,6)?t:e}function sl(t,e){return Al(t,4)?t:e}function al(t,e){return Al(t,4)?uh.normalizeRect(t):e}function nl(t){const e=/(.+)\[(\d+)\]$/;return t.split(".").map((t=>{const A=t.match(e);return A?{name:A[1],pos:parseInt(A[2],10)}:{name:t,pos:0}}))}function rl(t){const e=[];let A=0;for(let i=0,s=t.length;i126||35===s||40===s||41===s||60===s||62===s||91===s||93===s||123===s||125===s||47===s||37===s)&&(A"\n"===t?"\\n":"\r"===t?"\\r":`\\${t}`))}function gl(t,e,A,i){if(!t)return;let s=null;if(t instanceof Nh){if(i.has(t))return;s=t,i.put(s),t=e.fetch(t)}if(Array.isArray(t))for(const s of t)gl(s,e,A,i);else if(t instanceof vh){if(Lh(t.get("S"),"JavaScript")){const e=t.get("JS");let i;e instanceof _h?i=e.getString():"string"==typeof e&&(i=e),i&&=Bh(i).replaceAll("\0",""),i&&A.push(i)}gl(t.getRaw("Next"),e,A,i)}s&&i.remove(s)}function cl(t,e,A){const i=Object.create(null),s=jh({dict:e,key:"AA",stopWhenFound:!1});if(s)for(let e=s.length-1;e>=0;e--){const a=s[e];if(a instanceof vh)for(const e of a.getKeys()){const s=A[e];if(!s)continue;const n=[];gl(a.getRaw(e),t,n,new Mh),n.length>0&&(i[s]=n)}}if(e.has("A")){const A=[];gl(e.get("A"),t,A,new Mh),A.length>0&&(i.Action=A)}return lh(i)>0?i:null}const hl={60:"<",62:">",38:"&",34:""",39:"'"};function*ll(t){for(let e=0,A=t.length;e55295&&(A<57344||A>65533)&&e++,yield A}}function Il(t){const e=[];let A=0;for(let i=0,s=t.length;i55295&&(s<57344||s>65533)&&i++,A=i+1}return 0===e.length?t:(A: ${t}.`),!1;return!0}function ul(t){const e=new Set(["100","200","300","400","500","600","700","800","900","1000","normal","bold","bolder","lighter"]),{fontFamily:A,fontWeight:i,italicAngle:s}=t;if(!dl(A,!0))return!1;const a=i?i.toString():"";t.fontWeight=e.has(a)?a:"400";const n=parseFloat(s);return t.italicAngle=isNaN(n)||n<-90||n>90?"14":s.toString(),!0}function Cl(t){const e=new RegExp("^\\s*("+["app.launchURL","window.open","xfa.host.gotoURL"].join("|").replaceAll(".","\\.")+")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))","i").exec(t);if(e?.[2]){const t=e[2];let A=!1;return"true"===e[3]&&"app.launchURL"===e[1]&&(A=!0),{url:t,newWindow:A}}return null}function Bl(t){if(Number.isInteger(t))return t.toString();const e=Math.round(100*t);return e%100==0?(e/100).toString():e%10==0?t.toFixed(1):t.toFixed(2)}function Ql(t){if(!t)return null;const e=new Map;for(const[A,i]of t){if(!A.startsWith(kc))continue;let t=e.get(i.pageIndex);t||(t=[],e.set(i.pageIndex,t)),t.push(i)}return e.size>0?e:null}function El(t){return function(t){return/^[\x00-\x7F]*$/.test(t)}(t)?t:pl(t,!0)}function fl(t){const e=[];for(let A=0,i=t.length;A>8&255).toString(16).padStart(2,"0"),(255&i).toString(16).padStart(2,"0"))}return e.join("")}function pl(t,e=!1){const A=[];e&&A.push("þÿ");for(let e=0,i=t.length;e>8&255),String.fromCharCode(255&i))}return A.join("")}function ml(t,e,A){switch(t){case 90:return[0,1,-1,0,e,0];case 180:return[-1,0,0,-1,e,A];case 270:return[0,-1,1,0,0,A];default:throw new Error("Invalid rotation")}}function yl(t){return Math.ceil(Math.ceil(Math.log2(1+t))/8)}class bl extends _h{constructor(t,e,A,i){super(),this.bytes=t instanceof Uint8Array?t:new Uint8Array(t),this.start=e||0,this.pos=this.start,this.end=e+A||this.bytes.length,this.dict=i}get length(){return this.end-this.start}get isEmpty(){return 0===this.length}getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]}getBytes(t){const e=this.bytes,A=this.pos,i=this.end;if(!t)return e.subarray(A,i);let s=A+t;return s>i&&(s=i),this.pos=s,e.subarray(A,s)}getByteRange(t,e){return t<0&&(t=0),e>this.end&&(e=this.end),this.bytes.subarray(t,e)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(t,e,A=null){return new bl(this.bytes.buffer,t,e,A)}}class wl extends bl{constructor(t){super(ch(t))}}class Dl extends bl{constructor(){super(new Uint8Array(0))}}class kl extends bl{constructor(t,e,A){super(new Uint8Array(t),0,t,null),this.chunkSize=e,this._loadedChunks=new Set,this.numChunks=Math.ceil(t/e),this.manager=A,this.progressiveDataLength=0,this.lastSuccessfulEnsureByteChunk=-1}getMissingChunks(){const t=[];for(let e=0,A=this.numChunks;e=this.end?this.numChunks:Math.floor(e/this.chunkSize);for(let t=A;tthis.numChunks)&&e!==this.lastSuccessfulEnsureByteChunk){if(!this._loadedChunks.has(e))throw new Ph(t,t+1);this.lastSuccessfulEnsureByteChunk=e}}ensureRange(t,e){if(t>=e)return;if(e<=this.progressiveDataLength)return;const A=Math.floor(t/this.chunkSize);if(A>this.numChunks)return;const i=Math.min(Math.floor((e-1)/this.chunkSize)+1,this.numChunks);for(let s=A;s=this.end?-1:(t>=this.progressiveDataLength&&this.ensureByte(t),this.bytes[this.pos++])}getBytes(t){const e=this.bytes,A=this.pos,i=this.end;if(!t)return i>this.progressiveDataLength&&this.ensureRange(A,i),e.subarray(A,i);let s=A+t;return s>i&&(s=i),s>this.progressiveDataLength&&this.ensureRange(A,s),this.pos=s,e.subarray(A,s)}getByteRange(t,e){return t<0&&(t=0),e>this.end&&(e=this.end),e>this.progressiveDataLength&&this.ensureRange(t,e),this.bytes.subarray(t,e)}makeSubStream(t,e,A=null){function i(){}e?t+e>this.progressiveDataLength&&this.ensureRange(t,t+e):t>=this.progressiveDataLength&&this.ensureByte(t),i.prototype=Object.create(this),i.prototype.getMissingChunks=function(){const t=this.chunkSize,e=Math.floor(this.start/t),A=Math.floor((this.end-1)/t)+1,i=[];for(let t=e;t{const a=({value:n,done:r})=>{try{if(r){const e=Wh(i);return i=null,void t(e)}s+=n.byteLength,A.isStreamingSupported&&this.onProgress({loaded:s}),i.push(n),A.read().then(a,e)}catch(t){e(t)}};A.read().then(a,e)})).then((e=>{this.aborted||this.onReceiveData({chunk:e,begin:t})}))}requestAllChunks(t=!1){if(!t){const t=this.stream.getMissingChunks();this._requestChunks(t)}return this._loadedStreamCapability.promise}_requestChunks(t){const e=this.currRequestId++,A=new Set;this._chunksNeededByRequest.set(e,A);for(const e of t)this.stream.hasChunk(e)||A.add(e);if(0===A.size)return Promise.resolve();const i=Promise.withResolvers();this._promisesByRequest.set(e,i);const s=[];for(const t of A){let A=this._requestsByChunk.get(t);A||(A=[],this._requestsByChunk.set(t,A),s.push(t)),A.push(e)}if(s.length>0){const t=this.groupChunks(s);for(const e of t){const t=e.beginChunk*this.chunkSize,A=Math.min(e.endChunk*this.chunkSize,this.length);this.sendRequest(t,A).catch(i.reject)}}return i.promise.catch((t=>{if(!this.aborted)throw t}))}getStream(){return this.stream}requestRange(t,e){e=Math.min(e,this.length);const A=this.getBeginChunk(t),i=this.getEndChunk(e),s=[];for(let t=A;t=0&&i+1!==a&&(e.push({beginChunk:A,endChunk:i+1}),A=a),s+1===t.length&&e.push({beginChunk:A,endChunk:a+1}),i=a}return e}onProgress(t){this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize+t.loaded,total:this.length})}onReceiveData(t){const e=t.chunk,A=void 0===t.begin,i=A?this.progressiveDataLength:t.begin,s=i+e.byteLength,a=Math.floor(i/this.chunkSize),n=s0||r.push(A)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let t;if(1===this.stream.numChunksLoaded){const e=this.stream.numChunks-1;this.stream.hasChunk(e)||(t=e)}else t=this.stream.nextEmptyChunk(n);Number.isInteger(t)&&this._requestChunks([t])}for(const t of r){const e=this._promisesByRequest.get(t);this._promisesByRequest.delete(t),e.resolve()}this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize,total:this.length})}onError(t){this._loadedStreamCapability.reject(t)}getBeginChunk(t){return Math.floor(t/this.chunkSize)}getEndChunk(t){return Math.floor((t-1)/this.chunkSize)+1}abort(t){this.aborted=!0,this.pdfNetworkStream?.cancelAllRequests(t);for(const e of this._promisesByRequest.values())e.reject(t)}}class xl{constructor(t,e){this.constructor===xl&&Xc("Cannot initialize ColorSpace."),this.name=t,this.numComps=e}getRgb(t,e){const A=new Uint8ClampedArray(3);return this.getRgbItem(t,e,A,0),A}getRgbItem(t,e,A,i){Xc("Should not call ColorSpace.getRgbItem")}getRgbBuffer(t,e,A,i,s,a,n){Xc("Should not call ColorSpace.getRgbBuffer")}getOutputLength(t,e){Xc("Should not call ColorSpace.getOutputLength")}isPassthrough(t){return!1}isDefaultDecode(t,e){return xl.isDefaultDecode(t,this.numComps)}fillRgb(t,e,A,i,s,a,n,r,o){const g=e*A;let c=null;const h=1<h&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const e=n<=8?new Uint8Array(h):new Uint16Array(h);for(let t=0;t=.99554525?1:this.#Er(0,1,1.055*t**(1/2.4)-.055)}#Er(t,e,A){return Math.max(t,Math.min(e,A))}#fr(t){return t<0?-this.#fr(-t):t>8?((t+16)/116)**3:t*Hl.#dr}#pr(t,e,A){if(0===t[0]&&0===t[1]&&0===t[2])return A[0]=e[0],A[1]=e[1],void(A[2]=e[2]);const i=this.#fr(0),s=(1-i)/(1-this.#fr(t[0])),a=1-s,n=(1-i)/(1-this.#fr(t[1])),r=1-n,o=(1-i)/(1-this.#fr(t[2])),g=1-o;A[0]=e[0]*s+a,A[1]=e[1]*n+r,A[2]=e[2]*o+g}#mr(t,e,A){if(1===t[0]&&1===t[2])return A[0]=e[0],A[1]=e[1],void(A[2]=e[2]);const i=A;this.#ur(Hl.#rr,e,i);const s=Hl.#hr;this.#Cr(t,i,s),this.#ur(Hl.#or,s,A)}#yr(t,e,A){const i=A;this.#ur(Hl.#rr,e,i);const s=Hl.#hr;this.#Br(t,i,s),this.#ur(Hl.#or,s,A)}#nr(t,e,A,i,s){const a=this.#Er(0,1,t[e]*s),n=this.#Er(0,1,t[e+1]*s),r=this.#Er(0,1,t[e+2]*s),o=1===a?1:a**this.GR,g=1===n?1:n**this.GG,c=1===r?1:r**this.GB,h=this.MXA*o+this.MXB*g+this.MXC*c,l=this.MYA*o+this.MYB*g+this.MYC*c,I=this.MZA*o+this.MZB*g+this.MZC*c,d=Hl.#lr;d[0]=h,d[1]=l,d[2]=I;const u=Hl.#Ir;this.#mr(this.whitePoint,d,u);const C=Hl.#lr;this.#pr(this.blackPoint,u,C);const B=Hl.#Ir;this.#yr(Hl.#cr,C,B);const Q=Hl.#lr;this.#ur(Hl.#gr,B,Q),A[i]=255*this.#Qr(Q[0]),A[i+1]=255*this.#Qr(Q[1]),A[i+2]=255*this.#Qr(Q[2])}getRgbItem(t,e,A,i){this.#nr(t,e,A,i,1)}getRgbBuffer(t,e,A,i,s,a,n){const r=1/((1<this.amax||this.bmin>this.bmax)&&(Vc("Invalid Range, falling back to defaults"),this.amin=-100,this.amax=100,this.bmin=-100,this.bmax=100)}#br(t){return t>=6/29?t**3:108/841*(t-4/29)}#wr(t,e,A,i){return A+t*(i-A)/e}#nr(t,e,A,i,s){let a=t[e],n=t[e+1],r=t[e+2];!1!==A&&(a=this.#wr(a,A,0,100),n=this.#wr(n,A,this.amin,this.amax),r=this.#wr(r,A,this.bmin,this.bmax)),n>this.amax?n=this.amax:nthis.bmax?r=this.bmax:r>>0}function Yl(t,e){return 1===e?String.fromCharCode(t[0],t[1]):3===e?String.fromCharCode(t[0],t[1],t[2],t[3]):String.fromCharCode(...t.subarray(0,e+1))}function Tl(t,e,A){let i=0;for(let s=A;s>=0;s--)i+=t[s]+e[s],t[s]=255&i,i>>=8}function Pl(t,e){let A=1;for(let i=e;i>=0&&A>0;i--)A+=t[i],t[i]=255&A,A>>=8}const Kl=16;class ql{constructor(t){this.buffer=t,this.pos=0,this.end=t.length,this.tmpBuf=new Uint8Array(19)}readByte(){return this.pos>=this.end?-1:this.buffer[this.pos++]}readNumber(){let t,e=0;do{const A=this.readByte();if(A<0)throw new rh("unexpected EOF in bcmap");t=!(128&A),e=e<<7|127&A}while(!t);return e}readSigned(){const t=this.readNumber();return 1&t?~(t>>>1):t>>>1}readHex(t,e){t.set(this.buffer.subarray(this.pos,this.pos+e+1)),this.pos+=e+1}readHexNumber(t,e){let A;const i=this.tmpBuf;let s=0;do{const t=this.readByte();if(t<0)throw new rh("unexpected EOF in bcmap");A=!(128&t),i[s++]=127&t}while(!A);let a=e,n=0,r=0;for(;a>=0;){for(;r<8&&i.length>0;)n|=i[--s]<>=8,r-=8}}readHexSigned(t,e){this.readHexNumber(t,e);const A=1&t[e]?255:0;let i=0;for(let s=0;s<=e;s++)i=(1&i)<<8|t[s],t[s]=i>>1^A}readString(){const t=this.readNumber(),e=new Array(t);for(let A=0;A=0;){const t=l>>5;if(7===t){switch(31&l){case 0:i.readString();break;case 1:a=i.readString()}continue}const A=!!(16&l),s=15&l;if(s+1>Kl)throw new Error("BinaryCMapReader.process: Invalid dataSize.");const I=1,d=i.readNumber();switch(t){case 0:i.readHex(n,s),i.readHexNumber(r,s),Tl(r,n,s),e.addCodespaceRange(s+1,_l(n,s),_l(r,s));for(let t=1;ts&&(i=s)}else{for(;!this.eof;)this.readBlock(e);i=this.bufferLength}return this.pos=i,this.buffer.subarray(A,i)}async getImageData(t,e=null){if(!this.canAsyncDecodeImageFromBuffer)return this.getBytes(t,e);const A=await this.stream.asyncGetBytes();return this.decodeImage(A,e)}reset(){this.pos=0}makeSubStream(t,e,A=null){if(void 0===e)for(;!this.eof;)this.readBlock();else{const A=t+e;for(;this.bufferLength<=A&&!this.eof;)this.readBlock()}return new bl(this.buffer,t,e,A)}getBaseStreams(){return this.str?this.str.getBaseStreams():null}}class Vl extends jl{constructor(t,e=null){let A=0;for(const e of t)A+=e instanceof jl?e._rawMinBufferLength:e.length;super(A),this.streams=t,this._onError=e}readBlock(){const t=this.streams;if(0===t.length)return void(this.eof=!0);const e=t.shift();let A;try{A=e.getBytes()}catch(t){if(this._onError)return void this._onError(t,e.dict?.objId);throw t}const i=this.bufferLength,s=i+A.length;this.ensureBuffer(s).set(A,i),this.bufferLength=s}getBaseStreams(){const t=[];for(const e of this.streams){const A=e.getBaseStreams();A&&t.push(...A)}return t.length>0?t:null}}class Zl extends jl{constructor(t,e){e&&(e*=.8),super(e),this.str=t,this.dict=t.dict,this.input=new Uint8Array(5)}readBlock(){const t=this.str;let e=t.getByte();for(;el(e);)e=t.getByte();if(-1===e||126===e)return void(this.eof=!0);const A=this.bufferLength;let i,s;if(122===e){for(i=this.ensureBuffer(A+4),s=0;s<4;++s)i[A+s]=0;this.bufferLength+=4}else{const a=this.input;for(a[0]=e,s=1;s<5;++s){for(e=t.getByte();el(e);)e=t.getByte();if(a[s]=e,-1===e||126===e)break}if(i=this.ensureBuffer(A+s-1),this.bufferLength+=s-1,s<5){for(;s<5;++s)a[s]=117;this.eof=!0}let n=0;for(s=0;s<5;++s)n=85*n+(a[s]-33);for(s=3;s>=0;--s)i[A+s]=255&n,n>>=8}}}class Xl extends jl{constructor(t,e){e&&(e*=.5),super(e),this.str=t,this.dict=t.dict,this.firstDigit=-1}readBlock(){const t=this.str.getBytes(8e3);if(!t.length)return void(this.eof=!0);const e=t.length+1>>1,A=this.ensureBuffer(this.bufferLength+e);let i=this.bufferLength,s=this.firstDigit;for(const e of t){let t;if(e>=48&&e<=57)t=15&e;else{if(!(e>=65&&e<=70||e>=97&&e<=102)){if(62===e){this.eof=!0;break}continue}t=9+(15&e)}s<0?s=t:(A[i++]=s<<4|t,s=-1)}s>=0&&this.eof&&(A[i++]=s<<4,s=-1),this.firstDigit=s,this.bufferLength=i}}const zl=-1,$l=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],tI=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],eI=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],AI=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],iI=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],sI=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];class aI{constructor(t,e={}){if(!t||"function"!=typeof t.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');let A;for(this.source=t,this.eof=!1,this.encoding=e.K||0,this.eoline=e.EndOfLine||!1,this.byteAlign=e.EncodedByteAlign||!1,this.columns=e.Columns||1728,this.rows=e.Rows||0,this.eoblock=e.EndOfBlock??!0,this.black=e.BlackIs1||!1,this.codingLine=new Uint32Array(this.columns+1),this.refLine=new Uint32Array(this.columns+2),this.codingLine[0]=this.columns,this.codingPos=0,this.row=0,this.nextLine2D=this.encoding<0,this.inputBits=0,this.inputBuf=0,this.outputBits=0,this.rowsDone=!1;0===(A=this._lookBits(12));)this._eatBits(1);1===A&&this._eatBits(12),this.encoding>0&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1))}readNextChar(){if(this.eof)return-1;const t=this.refLine,e=this.codingLine,A=this.columns;let i,s,a,n,r;if(0===this.outputBits){if(this.rowsDone&&(this.eof=!0),this.eof)return-1;let a,r,o;if(this.err=!1,this.nextLine2D){for(n=0;e[n]=64);do{r+=o=this._getWhiteCode()}while(o>=64)}else{do{a+=o=this._getWhiteCode()}while(o>=64);do{r+=o=this._getBlackCode()}while(o>=64)}for(this._addPixels(e[this.codingPos]+a,s),e[this.codingPos]0?--i:++i;t[i]<=e[this.codingPos]&&t[i]0?--i:++i;t[i]<=e[this.codingPos]&&t[i]0?--i:++i;t[i]<=e[this.codingPos]&&t[i]=64);else do{a+=o=this._getWhiteCode()}while(o>=64);this._addPixels(e[this.codingPos]+a,s),s^=1}let g=!1;if(this.byteAlign&&(this.inputBits&=-8),this.eoblock||this.row!==this.rows-1){if(a=this._lookBits(12),this.eoline)for(;a!==zl&&1!==a;)this._eatBits(1),a=this._lookBits(12);else for(;0===a;)this._eatBits(1),a=this._lookBits(12);1===a?(this._eatBits(12),g=!0):a===zl&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1)),this.eoblock&&g&&this.byteAlign){if(a=this._lookBits(12),1===a){if(this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1)),this.encoding>=0)for(n=0;n<4;++n)a=this._lookBits(12),1!==a&&Vc("bad rtc code: "+a),this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1));this.eof=!0}}else if(this.err&&this.eoline){for(;;){if(a=this._lookBits(13),a===zl)return this.eof=!0,-1;if(a>>1==1)break;this._eatBits(1)}this._eatBits(12),this.encoding>0&&(this._eatBits(1),this.nextLine2D=!(1&a))}this.outputBits=e[0]>0?e[this.codingPos=0]:e[this.codingPos=1],this.row++}if(this.outputBits>=8)r=1&this.codingPos?0:255,this.outputBits-=8,0===this.outputBits&&e[this.codingPos]a?(r<<=a,1&this.codingPos||(r|=255>>8-a),this.outputBits-=a,a=0):(r<<=this.outputBits,1&this.codingPos||(r|=255>>8-this.outputBits),a-=this.outputBits,this.outputBits=0,e[this.codingPos]0&&(r<<=a,a=0))}while(a)}return this.black&&(r^=255),r}_addPixels(t,e){const A=this.codingLine;let i=this.codingPos;t>A[i]&&(t>this.columns&&(Vc("row is wrong length"),this.err=!0,t=this.columns),1&i^e&&++i,A[i]=t),this.codingPos=i}_addPixelsNeg(t,e){const A=this.codingLine;let i=this.codingPos;if(t>A[i])t>this.columns&&(Vc("row is wrong length"),this.err=!0,t=this.columns),1&i^e&&++i,A[i]=t;else if(t0&&t=s){const e=A[t-s];if(e[0]===i)return this._eatBits(i),[!0,e[1],!0]}}return[!1,0,!1]}_getTwoDimCode(){let t,e=0;if(this.eoblock){if(e=this._lookBits(7),t=$l[e],t?.[0]>0)return this._eatBits(t[0]),t[1]}else{const t=this._findTableCode(1,7,$l);if(t[0]&&t[2])return t[1]}return Vc("Bad two dim code"),zl}_getWhiteCode(){let t,e=0;if(this.eoblock){if(e=this._lookBits(12),e===zl)return 1;if(t=e>>5?eI[e>>3]:tI[e],t[0]>0)return this._eatBits(t[0]),t[1]}else{let t=this._findTableCode(1,9,eI);if(t[0])return t[1];if(t=this._findTableCode(11,12,tI),t[0])return t[1]}return Vc("bad white code"),this._eatBits(1),1}_getBlackCode(){let t,e;if(this.eoblock){if(t=this._lookBits(13),t===zl)return 1;if(e=t>>7?!(t>>9)&&t>>7?iI[(t>>1)-64]:sI[t>>7]:AI[t],e[0]>0)return this._eatBits(e[0]),e[1]}else{let t=this._findTableCode(2,6,sI);if(t[0])return t[1];if(t=this._findTableCode(7,12,iI,64),t[0])return t[1];if(t=this._findTableCode(10,13,AI),t[0])return t[1]}return Vc("bad black code"),this._eatBits(1),1}_lookBits(t){let e;for(;this.inputBits>16-t;this.inputBuf=this.inputBuf<<8|e,this.inputBits+=8}return this.inputBuf>>this.inputBits-t&65535>>16-t}_eatBits(t){(this.inputBits-=t)<0&&(this.inputBits=0)}}class nI extends jl{constructor(t,e,A){super(e),this.str=t,this.dict=t.dict,A instanceof vh||(A=vh.empty);const i={next:()=>t.getByte()};this.ccittFaxDecoder=new aI(i,{K:A.get("K"),EndOfLine:A.get("EndOfLine"),EncodedByteAlign:A.get("EncodedByteAlign"),Columns:A.get("Columns"),Rows:A.get("Rows"),EndOfBlock:A.get("EndOfBlock"),BlackIs1:A.get("BlackIs1")})}readBlock(){for(;!this.eof;){const t=this.ccittFaxDecoder.readNextChar();if(-1===t)return void(this.eof=!0);this.ensureBuffer(this.bufferLength+1),this.buffer[this.bufferLength++]=t}}}const rI=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oI=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),gI=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),cI=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],hI=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];class lI extends jl{constructor(t,e){super(e),this.str=t,this.dict=t.dict;const A=t.getByte(),i=t.getByte();if(-1===A||-1===i)throw new rh(`Invalid header in flate stream: ${A}, ${i}`);if(8!=(15&A))throw new rh(`Unknown compression method in flate stream: ${A}, ${i}`);if(((A<<8)+i)%31!=0)throw new rh(`Bad FCHECK in flate stream: ${A}, ${i}`);if(32&i)throw new rh(`FDICT bit set in flate stream: ${A}, ${i}`);this.codeSize=0,this.codeBuf=0}async getImageData(t,e){const A=await this.asyncGetBytes();return A?.subarray(0,t)||this.getBytes(t)}async asyncGetBytes(){this.str.reset();const t=this.str.getBytes();try{const{readable:e,writable:A}=new DecompressionStream("deflate"),i=A.getWriter();i.write(t),i.close();const s=[];let a=0;for await(const t of e)s.push(t),a+=t.byteLength;const n=new Uint8Array(a);let r=0;for(const t of s)n.set(t,r),r+=t.byteLength;return n}catch{return this.str=new bl(t,2,t.length,this.str.dict),this.reset(),null}}get isAsync(){return!0}getBits(t){const e=this.str;let A,i=this.codeSize,s=this.codeBuf;for(;i>t,this.codeSize=i-=t,A}getCode(t){const e=this.str,A=t[0],i=t[1];let s,a=this.codeSize,n=this.codeBuf;for(;a>16,g=65535&r;if(o<1||a>o,this.codeSize=a-o,g}generateHuffmanTable(t){const e=t.length;let A,i=0;for(A=0;Ai&&(i=t[A]);const s=1<>=1;for(A=t;A>=1,0===e){let e;if(-1===(e=i.getByte()))return void this.#Dr("Bad block header in flate stream");let A=e;if(-1===(e=i.getByte()))return void this.#Dr("Bad block header in flate stream");if(A|=e<<8,-1===(e=i.getByte()))return void this.#Dr("Bad block header in flate stream");let s=e;if(-1===(e=i.getByte()))return void this.#Dr("Bad block header in flate stream");if(s|=e<<8,s!==(65535&~A)&&(0!==A||0!==s))throw new rh("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;const a=this.bufferLength,n=a+A;if(t=this.ensureBuffer(n),this.bufferLength=n,0===A)-1===i.peekByte()&&(this.eof=!0);else{const e=i.getBytes(A);t.set(e,a),e.length0;)c[r++]=I}s=this.generateHuffmanTable(c.subarray(0,t)),a=this.generateHuffmanTable(c.subarray(t,g))}}t=this.buffer;let n=t?t.length:0,r=this.bufferLength;for(;;){let e=this.getCode(s);if(e<256){r+1>=n&&(t=this.ensureBuffer(r+1),n=t.length),t[r++]=e;continue}if(256===e)return void(this.bufferLength=r);e-=257,e=oI[e];let i=e>>16;i>0&&(i=this.getBits(i)),A=(65535&e)+i,e=this.getCode(a),e=gI[e],i=e>>16,i>0&&(i=this.getBits(i));const o=(65535&e)+i;r+A>=n&&(t=this.ensureBuffer(r+A),n=t.length);for(let e=0;e>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}byteIn(){const t=this.data;let e=this.bp;255===t[e]?t[e+1]>143?(this.clow+=65280,this.ct=8):(e++,this.clow+=t[e]<<9,this.ct=7,this.bp=e):(e++,this.clow+=e65535&&(this.chigh+=this.clow>>16,this.clow&=65535)}readBit(t,e){let A=t[e]>>1,i=1&t[e];const s=II[A],a=s.qe;let n,r=this.a-a;if(this.chigh>15&1,this.clow=this.clow<<1&65535,this.ct--}while(!(32768&r));return this.a=r,t[e]=A<<1|i,n}}class uI extends eh{constructor(t){super(t,"Jbig2Error")}}class CI{getContexts(t){return t in this?this[t]:this[t]=new Int8Array(65536)}}class BI{constructor(t,e,A){this.data=t,this.start=e,this.end=A}get decoder(){return th(this,"decoder",new dI(this.data,this.start,this.end))}get contextCache(){return th(this,"contextCache",new CI)}}const QI=2**31-1,EI=-(2**31);function fI(t,e,A){const i=t.getContexts(e);let s=1;function a(t){let e=0;for(let a=0;a>>0}const n=a(1),r=a(1)?a(1)?a(1)?a(1)?a(1)?a(32)+4436:a(12)+340:a(8)+84:a(6)+20:a(4)+4:a(2);let o;return 0===n?o=r:r>0&&(o=-r),o>=EI&&o<=QI?o:null}function pI(t,e,A){const i=t.getContexts("IAID");let s=1;for(let t=0;t=b&&v=w)for(H=H<<1&C,u=0;u=0&&M=0&&(G=x[N][M],G&&(H|=G<=t?g<<=1:g=g<<1|p[r][o];for(I=0;I=E||o<0||o>=Q?g<<=1:g=g<<1|i[r][o];const d=m.readBit(y,g);e[n]=d}}return p}function xI(t,e,A,i,s,a,n,r,o,g,c,h,l,I,d,u,C,B,Q){if(t&&e)throw new uI("refinement with Huffman is not supported");const E=[];let f,p;for(f=0;f1&&(s=t?Q.readBits(B):fI(y,"IAIT",m));const a=n*b+s,w=t?I.symbolIDTable.decode(Q):pI(y,m,o),D=e&&(t?Q.readBit():fI(y,"IARI",m));let k=r[w],S=k[0].length,x=k.length;if(D){const t=fI(y,"IARDW",m),e=fI(y,"IARDH",m);S+=t,x+=e,k=SI(S,x,d,k,(t>>1)+fI(y,"IARDX",m),(e>>1)+fI(y,"IARDY",m),!1,u,C)}let F=0;g?1&h?F=x-1:i+=x-1:h>1?i+=S-1:F=S-1;const R=a-(1&h?0:x-1),v=i-(2&h?S-1:0);let N,M,G;if(g)for(N=0;N>5&7;const o=[31&n];let g=e+6;if(7===n){r=536870911&tl(t,g-1),g+=3;let e=r+7>>3;for(o[0]=t[g++];--e>0;)o.push(t[g++])}else if(5===n||6===n)throw new uI("invalid referred-to flags");A.retainBits=o;let c=4;A.number<=256?c=1:A.number<=65536&&(c=2);const h=[];let l,I;for(l=0;l>>24&255,a[3]=e.height>>16&255,a[4]=e.height>>8&255,a[5]=255&e.height,l=g,I=t.length;l>2&3,t.huffmanDWSelector=e>>4&3,t.bitmapSizeSelector=e>>6&1,t.aggregationInstancesSelector=e>>7&1,t.bitmapCodingContextUsed=!!(256&e),t.bitmapCodingContextRetained=!!(512&e),t.template=e>>10&3,t.refinementTemplate=e>>12&1,g+=2,!t.huffman){for(o=0===t.template?4:1,n=[],r=0;r>2&3,c.stripSize=1<>4&3,c.transposed=!!(64&h),c.combinationOperator=h>>7&3,c.defaultPixelValue=h>>9&1,c.dsOffset=h<<17>>27,c.refinementTemplate=h>>15&1,c.huffman){const t=$h(i,g);g+=2,c.huffmanFS=3&t,c.huffmanDS=t>>2&3,c.huffmanDT=t>>4&3,c.huffmanRefinementDW=t>>6&3,c.huffmanRefinementDH=t>>8&3,c.huffmanRefinementDX=t>>10&3,c.huffmanRefinementDY=t>>12&3,c.huffmanRefinementSizeSelector=!!(16384&t)}if(c.refinement&&!c.refinementTemplate){for(n=[],r=0;r<2;r++)n.push({x:zh(i,g),y:zh(i,g+1)}),g+=2;c.refinementAt=n}c.numberOfSymbolInstances=tl(i,g),g+=4,a=[c,A.referredTo,i,g,s];break;case 16:const l={},I=i[g++];l.mmr=!!(1&I),l.template=I>>1&3,l.patternWidth=i[g++],l.patternHeight=i[g++],l.maxPatternIndex=tl(i,g),g+=4,a=[l,A.number,i,g,s];break;case 22:case 23:const d={};d.info=vI(i,g),g+=NI;const u=i[g++];d.mmr=!!(1&u),d.template=u>>1&3,d.enableSkip=!!(8&u),d.combinationOperator=u>>4&7,d.defaultPixelValue=u>>7&1,d.gridWidth=tl(i,g),g+=4,d.gridHeight=tl(i,g),g+=4,d.gridOffsetX=4294967295&tl(i,g),g+=4,d.gridOffsetY=4294967295&tl(i,g),g+=4,d.gridVectorX=$h(i,g),g+=2,d.gridVectorY=$h(i,g),g+=2,a=[d,A.referredTo,i,g,s];break;case 38:case 39:const C={};C.info=vI(i,g),g+=NI;const B=i[g++];if(C.mmr=!!(1&B),C.template=B>>1&3,C.prediction=!!(8&B),!C.mmr){for(o=0===C.template?4:1,n=[],r=0;r>2&1,Q.combinationOperator=E>>3&3,Q.requiresBuffer=!!(32&E),Q.combinationOperatorOverride=!!(64&E),a=[Q];break;case 49:case 50:case 51:case 62:break;case 53:a=[A.number,i,g,s];break;default:throw new uI(`segment type ${A.typeName}(${A.type}) is not implemented`)}const c="on"+A.typeName;c in e&&e[c].apply(e,a)}function GI(t,e){for(let A=0,i=t.length;A>3,A=new Uint8ClampedArray(e*t.height);t.defaultPixelValue&&A.fill(255),this.buffer=A}drawBitmap(t,e){const A=this.currentPageInfo,i=t.width,s=t.height,a=A.width+7>>3,n=A.combinationOperatorOverride?t.combinationOperator:A.combinationOperator,r=this.buffer,o=128>>(7&t.x);let g,c,h,l,I=t.y*a+(t.x>>3);switch(n){case 0:for(g=0;g>=1,h||(h=128,l++);I+=a}break;case 2:for(g=0;g>=1,h||(h=128,l++);I+=a}break;default:throw new uI(`operator ${n} is not supported`)}}onImmediateGenericRegion(t,e,A,i){const s=t.info,a=new BI(e,A,i),n=kI(t.mmr,s.width,s.height,t.template,t.prediction,null,t.at,a);this.drawBitmap(s,n)}onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion(...arguments)}onSymbolDictionary(t,e,A,i,s,a){let n,r;t.huffman&&(n=function(t,e,A){let i,s,a,n,r=0;switch(t.huffmanDHSelector){case 0:case 1:i=YI(t.huffmanDHSelector+4);break;case 3:i=PI(r,e,A),r++;break;default:throw new uI("invalid Huffman DH selector")}switch(t.huffmanDWSelector){case 0:case 1:s=YI(t.huffmanDWSelector+2);break;case 3:s=PI(r,e,A),r++;break;default:throw new uI("invalid Huffman DW selector")}return t.bitmapSizeSelector?(a=PI(r,e,A),r++):a=YI(1),n=t.aggregationInstancesSelector?PI(r,e,A):YI(1),{tableDeltaHeight:i,tableDeltaWidth:s,tableBitmapSize:a,tableAggregateInstances:n}}(t,A,this.customTables),r=new TI(i,s,a));let o=this.symbols;o||(this.symbols=o={});const g=[];for(const t of A){const e=o[t];e&&g.push(...e)}const c=new BI(i,s,a);o[e]=function(t,e,A,i,s,a,n,r,o,g,c,h){if(t&&e)throw new uI("symbol refinement with Huffman is not supported");const l=[];let I=0,d=Xh(A.length+i);const u=c.decoder,C=c.contextCache;let B,Q;for(t&&(B=YI(1),Q=[],d=Math.max(d,1));l.length1)E=xI(t,e,i,I,0,s,1,A.concat(l),d,0,0,1,0,a,o,g,c,0,h);else{const t=pI(C,u,d),e=fI(C,"IARDX",u),s=fI(C,"IARDY",u);E=SI(i,I,o,t=32){let A,i,n;switch(e){case 32:if(0===t)throw new uI("no previous value in symbol ID table");i=s.readBits(2)+3,A=a[t-1].prefixLength;break;case 33:i=s.readBits(3)+3,A=0;break;case 34:i=s.readBits(7)+11,A=0;break;default:throw new uI("invalid code length in symbol ID table")}for(n=0;n=0;C--)k=t?qI(D,o,g,!0):kI(!1,o,g,A,!1,null,b,d),w[C]=k;for(S=0;S=0;B--)F^=w[B][S][x],R|=F<>8,M=h+S*l-x*I>>8,N>=0&&N+p<=i&&M>=0&&M+m<=s)for(C=0;C=s))for(L=u[e],G=v[C],B=0;B=0&&t>1&7),o=1+(i>>4&7),g=[];let c,h,l=s;do{c=n.readBits(r),h=n.readBits(o),g.push(new UI([l,c,h,0])),l+=1<>e&1;if(e<=0)this.children[A]=new HI(t);else{let i=this.children[A];i||(this.children[A]=i=new HI(null)),i.buildTree(t,e-1)}}decodeNode(t){if(this.isLeaf){if(this.isOOB)return null;const e=t.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-e:e)}const e=this.children[t.readBit()];if(!e)throw new uI("invalid Huffman data");return e.decodeNode(t)}}class JI{constructor(t,e){e||this.assignPrefixCodes(t),this.rootNode=new HI(null);for(let e=0,A=t.length;e0&&this.rootNode.buildTree(A,A.prefixLength-1)}}decode(t){return this.rootNode.decodeNode(t)}assignPrefixCodes(t){const e=t.length;let A=0;for(let i=0;i=this.end)throw new uI("end of data while reading bit");this.currentByte=this.data[this.position++],this.shift=7}const t=this.currentByte>>this.shift&1;return this.shift--,t}readBits(t){let e,A=0;for(e=t-1;e>=0;e--)A|=this.readBit()<=this.end?-1:this.data[this.position++]}}function PI(t,e,A){let i=0;for(let s=0,a=e.length;s>A&1,A--}if(i&&!r){const t=5;for(let e=0;e>3,h=7&i,l=t.length;A=new Uint32Array(A.buffer);let I=0;for(let i=0;i0&&!t[a-1];)a--;const n=[{children:[],index:0}];let r,o=n[0];for(A=0;A0;)o=n.pop();for(o.index++,n.push(o);n.length<=A;)n.push(r={children:[],index:0}),o.children[o.index]=r.children,o=r;s++}A+10)return d--,I>>d&1;if(I=t[e++],255===I){const i=t[e++];if(i){if(220===i&&g){const i=$h(t,e+=2);if(e+=2,i>0&&i!==A.scanLines)throw new ZI("Found DNL marker (0xFFDC) while parsing scan data",i)}else if(217===i){if(g){const t=m*(8===A.precision?8:0);if(t>0&&Math.round(A.scanLines/t)>=5)throw new ZI("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",t)}throw new XI("Found EOI marker (0xFFD9) while parsing scan data")}throw new VI(`unexpected marker ${(I<<8|i).toString(16)}`)}}return d=7,I>>>7}function C(t){let e=t;for(;;){switch(e=e[u()],typeof e){case"number":return e;case"object":continue}throw new VI("invalid huffman sequence")}}function B(t){let e=0;for(;t>0;)e=e<<1|u(),t--;return e}function Q(t){if(1===t)return 1===u()?1:-1;const e=B(t);return e>=1<0)return void f--;let A=a;const i=n;for(;A<=i;){const i=C(t.huffmanTableAC),s=15&i,a=i>>4;if(0===s){if(a<15){f=B(a)+(1<>4,0===s)g<15?(f=B(g)+(1<>4;if(0===i){if(a<15)break;s+=16;continue}s+=a;const n=zI[s];t.blockData[e+n]=Q(i),s++}};let v,N=0;const M=1===w?i[0].blocksPerLine*i[0].blocksPerColumn:c*A.mcusPerColumn;let G,L;for(;N<=M;){const A=s?Math.min(M-N,s):M;if(A>0){for(k=0;k0?"unexpected":"excessive"} MCU data, current marker is: ${v.invalid}`),e=v.offset),!(v.marker>=65488&&v.marker<=65495))break;e+=2}return e-l}function cd(t,e,A){const i=t.quantizationTable,s=t.blockData;let a,n,r,o,g,c,h,l,I,d,u,C,B,Q,E,f,p;if(!i)throw new VI("missing required Quantization Table.");for(let t=0;t<64;t+=8)I=s[e+t],d=s[e+t+1],u=s[e+t+2],C=s[e+t+3],B=s[e+t+4],Q=s[e+t+5],E=s[e+t+6],f=s[e+t+7],I*=i[t],d|u|C|B|Q|E|f?(d*=i[t+1],u*=i[t+2],C*=i[t+3],B*=i[t+4],Q*=i[t+5],E*=i[t+6],f*=i[t+7],a=ad*I+128>>8,n=ad*B+128>>8,r=u,o=E,g=nd*(d-f)+128>>8,l=nd*(d+f)+128>>8,c=C<<4,h=Q<<4,a=a+n+1>>1,n=a-n,p=r*sd+o*id+128>>8,r=r*id-o*sd+128>>8,o=p,g=g+h+1>>1,h=g-h,l=l+c+1>>1,c=l-c,a=a+o+1>>1,o=a-o,n=n+r+1>>1,r=n-r,p=g*Ad+l*ed+2048>>12,g=g*ed-l*Ad+2048>>12,l=p,p=c*td+h*$I+2048>>12,c=c*$I-h*td+2048>>12,h=p,A[t]=a+l,A[t+7]=a-l,A[t+1]=n+h,A[t+6]=n-h,A[t+2]=r+c,A[t+5]=r-c,A[t+3]=o+g,A[t+4]=o-g):(p=ad*I+512>>10,A[t]=p,A[t+1]=p,A[t+2]=p,A[t+3]=p,A[t+4]=p,A[t+5]=p,A[t+6]=p,A[t+7]=p);for(let t=0;t<8;++t)I=A[t],d=A[t+8],u=A[t+16],C=A[t+24],B=A[t+32],Q=A[t+40],E=A[t+48],f=A[t+56],d|u|C|B|Q|E|f?(a=ad*I+2048>>12,n=ad*B+2048>>12,r=u,o=E,g=nd*(d-f)+2048>>12,l=nd*(d+f)+2048>>12,c=C,h=Q,a=4112+(a+n+1>>1),n=a-n,p=r*sd+o*id+2048>>12,r=r*id-o*sd+2048>>12,o=p,g=g+h+1>>1,h=g-h,l=l+c+1>>1,c=l-c,a=a+o+1>>1,o=a-o,n=n+r+1>>1,r=n-r,p=g*Ad+l*ed+2048>>12,g=g*ed-l*Ad+2048>>12,l=p,p=c*td+h*$I+2048>>12,c=c*$I-h*td+2048>>12,h=p,I=a+l,f=a-l,d=n+h,E=n-h,u=r+c,Q=r-c,C=o+g,B=o-g,I<16?I=0:I>=4080?I=255:I>>=4,d<16?d=0:d>=4080?d=255:d>>=4,u<16?u=0:u>=4080?u=255:u>>=4,C<16?C=0:C>=4080?C=255:C>>=4,B<16?B=0:B>=4080?B=255:B>>=4,Q<16?Q=0:Q>=4080?Q=255:Q>>=4,E<16?E=0:E>=4080?E=255:E>>=4,f<16?f=0:f>=4080?f=255:f>>=4,s[e+t]=I,s[e+t+8]=d,s[e+t+16]=u,s[e+t+24]=C,s[e+t+32]=B,s[e+t+40]=Q,s[e+t+48]=E,s[e+t+56]=f):(p=ad*I+8192>>14,p=p<-2040?0:p>=2024?255:p+2056>>4,s[e+t]=p,s[e+t+8]=p,s[e+t+16]=p,s[e+t+24]=p,s[e+t+32]=p,s[e+t+40]=p,s[e+t+48]=p,s[e+t+56]=p)}function hd(t,e){const A=e.blocksPerLine,i=e.blocksPerColumn,s=new Int16Array(64);for(let t=0;t=i)return null;const a=$h(t,e);if(a>=65472&&a<=65534)return{invalid:null,marker:a,offset:e};let n=$h(t,s);for(;!(n>=65472&&n<=65534);){if(++s>=i)return null;n=$h(t,s)}return{invalid:a.toString(16),marker:n,offset:s}}class Id{constructor({decodeTransform:t=null,colorTransform:e=-1}={}){this._decodeTransform=t,this._colorTransform=e}parse(t,{dnlScanLines:e=null}={}){function A(){const e=$h(t,n);n+=2;let A=n+e-2;const i=ld(t,A,n);i?.invalid&&(Zc("readDataBlock - incorrect length, current marker is: "+i.invalid),A=i.offset);const s=t.subarray(n,A);return n+=s.length,s}function i(t){const e=Math.ceil(t.samplesPerLine/8/t.maxH),A=Math.ceil(t.scanLines/8/t.maxV);for(const i of t.components){const s=Math.ceil(Math.ceil(t.samplesPerLine/8)*i.h/t.maxH),a=Math.ceil(Math.ceil(t.scanLines/8)*i.v/t.maxV),n=e*i.h,r=A*i.v*64*(n+1);i.blockData=new Int16Array(r),i.blocksPerLine=s,i.blocksPerColumn=a}t.mcusPerLine=e,t.mcusPerColumn=A}let s,a,n=0,r=null,o=null,g=0;const c=[],h=[],l=[];let I=$h(t,n);if(n+=2,65496!==I)throw new VI("SOI not found");I=$h(t,n),n+=2;t:for(;65497!==I;){let d,u,C;switch(I){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:const B=A();65504===I&&74===B[0]&&70===B[1]&&73===B[2]&&70===B[3]&&0===B[4]&&(r={version:{major:B[5],minor:B[6]},densityUnits:B[7],xDensity:B[8]<<8|B[9],yDensity:B[10]<<8|B[11],thumbWidth:B[12],thumbHeight:B[13],thumbData:B.subarray(14,14+3*B[12]*B[13])}),65518===I&&65===B[0]&&100===B[1]&&111===B[2]&&98===B[3]&&101===B[4]&&(o={version:B[5]<<8|B[6],flags0:B[7]<<8|B[8],flags1:B[9]<<8|B[10],transformCode:B[11]});break;case 65499:const Q=$h(t,n);n+=2;const E=Q+n-2;let f;for(;n>4){if(e>>4!=1)throw new VI("DQT - invalid table spec");for(u=0;u<64;u++)f=zI[u],A[f]=$h(t,n),n+=2}else for(u=0;u<64;u++)f=zI[u],A[f]=t[n++];c[15&e]=A}break;case 65472:case 65473:case 65474:if(s)throw new VI("Only single frame JPEGs supported");n+=2,s={},s.extended=65473===I,s.progressive=65474===I,s.precision=t[n++];const p=$h(t,n);n+=2,s.scanLines=e||p,s.samplesPerLine=$h(t,n),n+=2,s.components=[],s.componentIds={};const m=t[n++];let y=0,b=0;for(d=0;d>4,i=15&t[n+1];y>4?h:l)[15&e]=rd(A,s)}break;case 65501:n+=2,a=$h(t,n),n+=2;break;case 65498:const D=1==++g&&!e;n+=2;const k=t[n++],S=[];for(d=0;d>4],i.huffmanTableAC=h[15&a],S.push(i)}const x=t[n++],F=t[n++],R=t[n++];try{const e=gd(t,n,s,S,a,x,F,R>>4,15&R,D);n+=e}catch(e){if(e instanceof ZI)return Zc(`${e.message} -- attempting to re-parse the JPEG image.`),this.parse(t,{dnlScanLines:e.scanLines});if(e instanceof XI){Zc(`${e.message} -- ignoring the rest of the image data.`);break t}throw e}break;case 65500:n+=4;break;case 65535:255!==t[n]&&n--;break;default:const v=ld(t,n-2,n-3);if(v?.invalid){Zc("JpegImage.parse - unexpected data, current marker is: "+v.invalid),n=v.offset;break}if(!v||n>=t.length-1){Zc("JpegImage.parse - reached the end of the image data without finding an EOI marker (0xFFD9).");break t}throw new VI("JpegImage.parse - unknown marker: "+I.toString(16))}I=$h(t,n),n+=2}if(!s)throw new VI("JpegImage.parse - no frame data found.");this.width=s.samplesPerLine,this.height=s.scanLines,this.jfif=r,this.adobe=o,this.components=[];for(const t of s.components){const e=c[t.quantizationId];e&&(t.quantizationTable=e),this.components.push({index:t.index,output:hd(0,t),scaleX:t.h/s.maxH,scaleY:t.v/s.maxV,blocksPerLine:t.blocksPerLine,blocksPerColumn:t.blocksPerColumn})}this.numComponents=this.components.length}_getLinearizedBlockData(t,e,A=!1){const i=this.width/t,s=this.height/e;let a,n,r,o,g,c,h,l,I,d,u,C=0;const B=this.components.length,Q=t*e*B,E=new Uint8ClampedArray(Q),f=new Uint32Array(t),p=4294967288;let m;for(h=0;h>8)+y[I+1];return E}get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform&&(82!==this.components[0].index||71!==this.components[1].index||66!==this.components[2].index):1===this._colorTransform}_convertYccToRgb(t){let e,A,i;for(let s=0,a=t.length;s4)throw new VI("Unsupported color mode");const a=this._getLinearizedBlockData(t,e,s);if(1===this.numComponents&&(A||i)){const t=a.length*(A?4:3),e=new Uint8ClampedArray(t);let i=0;if(A)!function(t,e){if(Ih.isLittleEndian)for(let A=0,i=t.length;A0&&(t=t.subarray(e));break}const e={decodeTransform:void 0,colorTransform:void 0},A=this.dict.getArray("D","Decode");if((this.forceRGBA||this.forceRGB)&&Array.isArray(A)){const t=this.dict.get("BPC","BitsPerComponent")||8,i=A.length,s=new Int32Array(i);let a=!1;const n=(1<{e=t,A=i})),i.decode=function(t,{numComponents:e=4,isIndexedColormap:A=!1,smaskInData:s=!1}){const a=t.length,n=i._malloc(a);i.HEAPU8.set(t,n);const r=i._jp2_decode(n,a,e>0?e:0,!!A,!!s);if(i._free(n),r){const{errorMessages:t}=i;return t?(delete i.errorMessages,t):"Unknown error"}const{imageData:o}=i;return i.imageData=null,o};var s=Object.assign({},i),a="./this.program",n="";"undefined"!=typeof document&&document.currentScript&&(n=document.currentScript.src),ud&&(n=ud),n=n.startsWith("blob:")?"":n.substr(0,n.replace(/[?#].*/,"").lastIndexOf("/")+1);var r,o,g,c,h,l=i.print||console.log.bind(console),I=i.printErr||console.error.bind(console);function d(){var t=o.buffer;i.HEAP8=g=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAPU8=c=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU32=h=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(a=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(r=i.wasmBinary);var u,C=[],B=[],Q=[],E=0,f=null,p=null,m="data:application/octet-stream;base64,";function y(t,e){var A,i=function(t){if(t==u&&r)return new Uint8Array(r);var e=function(t){if((t=>t.startsWith(m))(t))return function(t){for(var e=atob(t),A=new Uint8Array(e.length),i=0;i{for(;t.length>0;)t.shift()(i)};i.noExitRuntime;var w,D=t=>{var e=(t-o.buffer.byteLength+65535)/65536;try{return o.grow(e),d(),1}catch(t){}},k={},S=()=>{if(!S.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:a||"./this.program"};for(var e in k)void 0===k[e]?delete t[e]:t[e]=k[e];var A=[];for(var e in t)A.push(`${e}=${t[e]}`);S.strings=A}return S.strings},x=[null,[],[]],F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,R=(t,e,A)=>{for(var i=e+A,s=e;t[s]&&!(s>=i);)++s;if(s-e>16&&t.buffer&&F)return F.decode(t.subarray(e,s));for(var a="";e>10,56320|1023&g)}}else a+=String.fromCharCode((31&n)<<6|r)}else a+=String.fromCharCode(n)}return a},v=(t,e)=>{var A=x[t];0===e||10===e?((1===t?l:I)(R(A,0)),A.length=0):A.push(e)},N=(t,e)=>t?R(c,t,e):"",M={c:(t,e,A)=>c.copyWithin(t,e,e+A),g:function(t,e){t>>=2;const A=i.imageData=new Uint8ClampedArray(e),s=i.HEAP32.subarray(t,t+e);A.set(s)},f:function(t,e,A,s){t>>=2,e>>=2,A>>=2;const a=i.imageData=new Uint8ClampedArray(3*s),n=i.HEAP32.subarray(t,t+s),r=i.HEAP32.subarray(e,e+s),o=i.HEAP32.subarray(A,A+s);for(let t=0;t>=2,e>>=2,A>>=2,s>>=2;const n=i.imageData=new Uint8ClampedArray(4*a),r=i.HEAP32.subarray(t,t+a),o=i.HEAP32.subarray(e,e+a),g=i.HEAP32.subarray(A,A+a),c=i.HEAP32.subarray(s,s+a);for(let t=0;t{var e=c.length,A=2147483648;if((t>>>=0)>A)return!1;for(var i,s=1;s<=4;s*=2){var a=e*(1+.2/s);a=Math.min(a,t+100663296);var n=Math.min(A,(i=Math.max(t,a))+(65536-i%65536)%65536);if(D(n))return!0}return!1},l:(t,e)=>{var A=0;return S().forEach(((i,s)=>{var a=e+A;h[t+4*s>>2]=a,((t,e)=>{for(var A=0;A{var A=S();h[t>>2]=A.length;var i=0;return A.forEach((t=>i+=t.length+1)),h[e>>2]=i,0},n:t=>52,j:function(t,e,A,i,s){return 70},b:(t,e,A,i)=>{for(var s=0,a=0;a>2],r=h[e+4>>2];e+=8;for(var o=0;o>2]=s,0},o:function(t,e){t>>=2;const A=i.imageData=new Uint8ClampedArray(4*e),s=i.HEAP32.subarray(t,t+e);for(let t=0;t>=2,e>>=2;const s=i.imageData=new Uint8ClampedArray(4*A),a=i.HEAP32.subarray(t,t+A),n=i.HEAP32.subarray(e,e+A);for(let t=0;t>=2,e>>=2,A>>=2;const a=i.imageData=new Uint8ClampedArray(4*s),n=i.HEAP32.subarray(t,t+s),r=i.HEAP32.subarray(e,e+s),o=i.HEAP32.subarray(A,A+s);for(let t=0;t0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)t=i.preRun.shift(),C.unshift(t);var t;b(C)}(),E>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),t()}),1)):t()))}if(G.q,i._malloc=G.r,i._free=G.s,i._jp2_decode=G.u,p=function t(){w||L(),w||(p=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return L(),i});const Bd=Cd;class Qd extends eh{constructor(t){super(t,"JpxError")}}class Ed{static#kr=null;static decode(t,e){e||={},this.#kr||=Bd({warn:Zc});const A=this.#kr.decode(t,e);if("string"==typeof A)throw new Qd(A);return A}static cleanup(){this.#kr=null}static parseImageProperties(t){let e=t.getByte();for(;e>=0;){const A=e;if(e=t.getByte(),65361==(A<<8|e)){t.skip(4);const e=t.getInt32()>>>0,A=t.getInt32()>>>0,i=t.getInt32()>>>0,s=t.getInt32()>>>0;return t.skip(16),{width:e-i,height:A-s,bitsPerComponent:8,componentsCount:t.getUint16()}}}throw new Qd("No size marker found in JPX stream")}}class fd extends jl{constructor(t,e,A){super(e),this.stream=t,this.dict=t.dict,this.maybeLength=e,this.params=A}get bytes(){return th(this,"bytes",this.stream.getBytes(this.maybeLength))}ensureBuffer(t){}readBlock(t){this.decodeImage(null,t)}decodeImage(t,e){return this.eof||(t||=this.bytes,this.buffer=Ed.decode(t,e),this.bufferLength=this.buffer.length,this.eof=!0),this.buffer}get canAsyncDecodeImageFromBuffer(){return this.stream.isAsync}}class pd extends jl{constructor(t,e,A){super(e),this.str=t,this.dict=t.dict,this.cachedData=0,this.bitsCached=0;const i=4096,s={earlyChange:A,codeLength:9,nextCode:258,dictionaryValues:new Uint8Array(i),dictionaryLengths:new Uint16Array(i),dictionaryPrevCodes:new Uint16Array(i),currentSequence:new Uint8Array(i),currentSequenceLength:0};for(let t=0;t<256;++t)s.dictionaryValues[t]=t,s.dictionaryLengths[t]=1;this.lzwState=s}readBits(t){let e=this.bitsCached,A=this.cachedData;for(;e>>e&(1<0;if(t<256)l[0]=t,I=1;else{if(!(t>=258)){if(256===t){c=9,n=258,I=0;continue}this.eof=!0,delete this.lzwState;break}if(t=0;e--)l[e]=r[A],A=g[A];else l[I++]=l[0]}if(s&&(g[n]=h,o[n]=o[h]+1,r[n]=l[0],n++,c=n+a&n+a-1?c:0|Math.min(Math.log(n+a)/.6931471805599453+1,12)),h=t,d+=I,i15))throw new rh(`Unsupported predictor: ${i}`);this.readBlock=2===i?this.readBlockTiff:this.readBlockPng,this.str=t,this.dict=t.dict;const s=this.colors=A.get("Colors")||1,a=this.bits=A.get("BPC","BitsPerComponent")||8,n=this.columns=A.get("Columns")||1;return this.pixBytes=s*a+7>>3,this.rowBytes=n*s*a+7>>3,this}readBlockTiff(){const t=this.rowBytes,e=this.bufferLength,A=this.ensureBuffer(e+t),i=this.bits,s=this.colors,a=this.str.getBytes(t);if(this.eof=!a.length,this.eof)return;let n,r=0,o=0,g=0,c=0,h=e;if(1===i&&1===s)for(n=0;n>1,t^=t>>2,t^=t>>4,r=(1&t)<<7,A[h++]=t}else if(8===i){for(n=0;n>8&255,A[h++]=255&t}}else{const t=new Uint8Array(s+1),h=(1<>g-i)&h,g-=i,o=o<=8&&(A[I++]=o>>c-8&255,c-=8);c>0&&(A[I++]=(o<<8-c)+(r&(1<<8-c)-1))}this.bufferLength+=t}readBlockPng(){const t=this.rowBytes,e=this.pixBytes,A=this.str.getByte(),i=this.str.getBytes(t);if(this.eof=!i.length,this.eof)return;const s=this.bufferLength,a=this.ensureBuffer(s+t);let n=a.subarray(s-t,s);0===n.length&&(n=new Uint8Array(t));let r,o,g,c=s;switch(A){case 0:for(r=0;r>1)+i[r];for(;r>1)+i[r]&255,c++;break;case 4:for(r=0;r0){const t=this.str.getBytes(i);e.set(t,A),A+=i}}else{i=257-i;const s=t[1];e=this.ensureBuffer(A+i+1);for(let t=0;t>")&&this.buf1!==wh;){if(!(this.buf1 instanceof xh)){Vc("Malformed dictionary: key must be a name object"),this.shift();continue}const e=this.buf1.name;if(this.shift(),this.buf1===wh)break;i.set(e,this.getObj(t))}if(this.buf1===wh){if(this.recoveryMode)return i;throw new Kh("End of file inside dictionary.")}return Uh(this.buf2,"stream")?this.allowStreams?this.makeStream(i,t):i:(this.shift(),i);default:return e}if(Number.isInteger(e)){if(Number.isInteger(this.buf1)&&Uh(this.buf2,"R")){const t=Nh.get(e,this.buf1);return this.shift(),this.shift(),t}return e}return"string"==typeof e&&t?t.decryptString(e):e}findDefaultInlineStreamEnd(t){const{knownCommands:e}=this.lexer,A=t.pos;let i,s,a=0;for(;-1!==(i=t.getByte());)if(0===a)a=69===i?1:0;else if(1===a)a=73===i?2:0;else if(32===i||10===i||13===i){s=t.pos;const A=t.peekBytes(15),n=A.length;if(0===n)break;for(let t=0;t127)){a=0;break}if(2!==a)continue;if(!e){Zc("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");continue}const r=new kd(new bl(A.slice()),e);r._hexStringWarn=()=>{};let o=0;for(;;){const t=r.getObj();if(t===wh){a=0;break}if(t instanceof Fh){const A=e[t.cmd];if(!A){a=0;break}if(A.variableArgs?o<=A.numArgs:o===A.numArgs)break;o=0}else o++}if(2===a)break}else a=0;-1===i&&(Zc("findDefaultInlineStreamEnd: Reached the end of the stream without finding a valid EI marker"),s&&(Zc('... trying to recover by using the last "EI" occurrence.'),t.skip(-(t.pos-s))));let n=4;return t.skip(-n),i=t.peekByte(),t.skip(n),el(i)||n--,t.pos-n-A}findDCTDecodeInlineStreamEnd(t){const e=t.pos;let A,i,s=!1;for(;-1!==(A=t.getByte());)if(255===A){switch(t.getByte()){case 0:break;case 255:t.skip(-1);break;case 217:s=!0;break;case 192:case 193:case 194:case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:i=t.getUint16(),i>2?t.skip(i-2):t.skip(-2)}if(s)break}const a=t.pos-e;return-1===A?(Zc("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead."),t.skip(-a),this.findDefaultInlineStreamEnd(t)):(this.inlineStreamSkipEI(t),a)}findASCII85DecodeInlineStreamEnd(t){const e=t.pos;let A;for(;-1!==(A=t.getByte());)if(126===A){const e=t.pos;for(A=t.peekByte();el(A);)t.skip(),A=t.peekByte();if(62===A){t.skip();break}if(t.pos>e){const e=t.peekBytes(2);if(69===e[0]&&73===e[1])break}}const i=t.pos-e;return-1===A?(Zc("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead."),t.skip(-i),this.findDefaultInlineStreamEnd(t)):(this.inlineStreamSkipEI(t),i)}findASCIIHexDecodeInlineStreamEnd(t){const e=t.pos;let A;for(;-1!==(A=t.getByte())&&62!==A;);const i=t.pos-e;return-1===A?(Zc("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead."),t.skip(-i),this.findDefaultInlineStreamEnd(t)):(this.inlineStreamSkipEI(t),i)}inlineStreamSkipEI(t){let e,A=0;for(;-1!==(e=t.getByte());)if(0===A)A=69===e?1:0;else if(1===A)A=73===e?2:0;else if(2===A)break}makeInlineImage(t){const e=this.lexer,A=e.stream,i=Object.create(null);let s;for(;!Uh(this.buf1,"ID")&&this.buf1!==wh;){if(!(this.buf1 instanceof xh))throw new rh("Dictionary key must be a name object");const e=this.buf1.name;if(this.shift(),this.buf1===wh)break;i[e]=this.getObj(t)}-1!==e.beginInlineImagePos&&(s=A.pos-e.beginInlineImagePos);const a=this.xref.fetchIfRef(i.F||i.Filter);let n;if(a instanceof xh)n=a.name;else if(Array.isArray(a)){const t=this.xref.fetchIfRef(a[0]);t instanceof xh&&(n=t.name)}const r=A.pos;let o,g;switch(n){case"DCT":case"DCTDecode":o=this.findDCTDecodeInlineStreamEnd(A);break;case"A85":case"ASCII85Decode":o=this.findASCII85DecodeInlineStreamEnd(A);break;case"AHx":case"ASCIIHexDecode":o=this.findASCIIHexDecodeInlineStreamEnd(A);break;default:o=this.findDefaultInlineStreamEnd(A)}if(o<1e3&&s>0){const t=A.pos;A.pos=e.beginInlineImagePos,g=function(t){const e=[],A=t.length;let i=0;for(;i=i){let i=!1;for(const t of s){const e=t.length;let s=0;for(;s=a){i=!0;break}if(s>=e){el(n[o+r+s])&&(Vc(`Found "${gh([...A,...t])}" when searching for endstream command.`),i=!0);break}}if(i)return e.pos+=o,e.pos-t}o++}e.pos+=r}return-1}makeStream(t,e){const A=this.lexer;let i=A.stream;A.skipToNextLine();const s=i.pos-1;let a=t.get("Length");if(Number.isInteger(a)||(Vc(`Bad length "${a&&a.toString()}" in stream.`),a=0),i.pos=s+a,A.nextChar(),this.tryShift()&&Uh(this.buf2,"endstream"))this.shift();else{if(a=this.#Sr(s),a<0)throw new rh("Missing endstream command.");A.nextChar(),this.shift(),this.shift()}return this.shift(),i=i.makeSubStream(s,a,t),e&&(i=e.createStream(i,a)),i=this.filter(i,t,a),i.dict=t,i}filter(t,e,A){let i=e.get("F","Filter"),s=e.get("DP","DecodeParms");if(i instanceof xh)return Array.isArray(s)&&Zc("/DecodeParms should not be an Array, when /Filter is a Name."),this.makeFilter(t,i.name,A,s);let a=A;if(Array.isArray(i)){const e=i,A=s;for(let n=0,r=e.length;n=48&&t<=57?15&t:t>=65&&t<=70||t>=97&&t<=102?9+(15&t):-1}class kd{constructor(t,e=null){this.stream=t,this.nextChar(),this.strBuf=[],this.knownCommands=e,this._hexStringNumWarn=0,this.beginInlineImagePos=-1}nextChar(){return this.currentChar=this.stream.getByte()}peekChar(){return this.stream.peekByte()}getNumber(){let t=this.currentChar,e=!1,A=0,i=1;if(45===t?(i=-1,t=this.nextChar(),45===t&&(t=this.nextChar())):43===t&&(t=this.nextChar()),10===t||13===t)do{t=this.nextChar()}while(10===t||13===t);if(46===t&&(A=10,t=this.nextChar()),t<48||t>57){const e=`Invalid number: ${String.fromCharCode(t)} (charCode ${t})`;if(el(t)||-1===t)return Vc(`Lexer.getNumber - "${e}".`),0;throw new rh(e)}let s=t-48,a=0,n=1;for(;(t=this.nextChar())>=0;)if(t>=48&&t<=57){const i=t-48;e?a=10*a+i:(0!==A&&(A*=10),s=10*s+i)}else if(46===t){if(0!==A)break;A=1}else if(45===t)Zc("Badly formatted number: minus sign in the middle");else{if(69!==t&&101!==t)break;if(t=this.peekChar(),43===t||45===t)n=45===t?-1:1,this.nextChar();else if(t<48||t>57)break;e=!0}return 0!==A&&(s/=A),e&&(s*=10**(n*a)),i*s}getString(){let t=1,e=!1;const A=this.strBuf;A.length=0;let i=this.nextChar();for(;;){let s=!1;switch(0|i){case-1:Zc("Unterminated string"),e=!0;break;case 40:++t,A.push("(");break;case 41:0==--t?(this.nextChar(),e=!0):A.push(")");break;case 92:switch(i=this.nextChar(),i){case-1:Zc("Unterminated string"),e=!0;break;case 110:A.push("\n");break;case 114:A.push("\r");break;case 116:A.push("\t");break;case 98:A.push("\b");break;case 102:A.push("\f");break;case 92:case 40:case 41:A.push(String.fromCharCode(i));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:let t=15&i;i=this.nextChar(),s=!0,i>=48&&i<=55&&(t=(t<<3)+(15&i),i=this.nextChar(),i>=48&&i<=55&&(s=!1,t=(t<<3)+(15&i))),A.push(String.fromCharCode(t));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:A.push(String.fromCharCode(i))}break;default:A.push(String.fromCharCode(i))}if(e)break;s||(i=this.nextChar())}return A.join("")}getName(){let t,e;const A=this.strBuf;for(A.length=0;(t=this.nextChar())>=0&&!wd[t];)if(35===t){if(t=this.nextChar(),wd[t]){Zc("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number."),A.push("#");break}const i=Dd(t);if(-1!==i){e=t,t=this.nextChar();const s=Dd(t);if(-1===s){if(Zc(`Lexer_getName: Illegal digit (${String.fromCharCode(t)}) in hexadecimal number.`),A.push("#",String.fromCharCode(e)),wd[t])break;A.push(String.fromCharCode(t));continue}A.push(String.fromCharCode(i<<4|s))}else A.push("#",String.fromCharCode(t))}else A.push(String.fromCharCode(t));return A.length>127&&Zc(`Name token is longer than allowed by the spec: ${A.length}`),xh.get(A.join(""))}_hexStringWarn(t){5!=this._hexStringNumWarn++?this._hexStringNumWarn>5||Zc(`getHexString - ignoring invalid character: ${t}`):Zc("getHexString - ignoring additional invalid characters.")}getHexString(){const t=this.strBuf;t.length=0;let e,A,i=this.currentChar,s=!0;for(this._hexStringNumWarn=0;;){if(i<0){Zc("Unterminated hex string");break}if(62===i){this.nextChar();break}if(1!==wd[i]){if(s){if(e=Dd(i),-1===e){this._hexStringWarn(i),i=this.nextChar();continue}}else{if(A=Dd(i),-1===A){this._hexStringWarn(i),i=this.nextChar();continue}t.push(String.fromCharCode(e<<4|A))}s=!s,i=this.nextChar()}else i=this.nextChar()}return t.join("")}getObj(){let t=!1,e=this.currentChar;for(;;){if(e<0)return wh;if(t)10!==e&&13!==e||(t=!1);else if(37===e)t=!0;else if(1!==wd[e])break;e=this.nextChar()}switch(0|e){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:return this.nextChar(),Fh.get("[");case 93:return this.nextChar(),Fh.get("]");case 60:return e=this.nextChar(),60===e?(this.nextChar(),Fh.get("<<")):this.getHexString();case 62:return e=this.nextChar(),62===e?(this.nextChar(),Fh.get(">>")):Fh.get(">");case 123:return this.nextChar(),Fh.get("{");case 125:return this.nextChar(),Fh.get("}");case 41:throw this.nextChar(),new rh(`Illegal character: ${e}`)}let A=String.fromCharCode(e);if(e<32||e>127){const t=this.peekChar();if(t>=32&&t<=127)return this.nextChar(),Fh.get(A)}const i=this.knownCommands;let s=void 0!==i?.[A];for(;(e=this.nextChar())>=0&&!wd[e];){const t=A+String.fromCharCode(e);if(s&&void 0===i[t])break;if(128===A.length)throw new rh(`Command token too long: ${A.length}`);A=t,s=void 0!==i?.[A]}return"true"===A||"false"!==A&&("null"===A?null:("BI"===A&&(this.beginInlineImagePos=this.stream.pos),Fh.get(A)))}skipToNextLine(){let t=this.currentChar;for(;t>=0;){if(13===t){t=this.nextChar(),10===t&&this.nextChar();break}if(10===t){this.nextChar();break}t=this.nextChar()}}}class Sd{static create(t){function e(t,e,A=!1){const i=t.get(e);if(Number.isInteger(i)&&(A?i>=0:i>0))return i;throw new Error(`The "${e}" parameter in the linearization dictionary is invalid.`)}const A=new bd({lexer:new kd(t),xref:null}),i=A.getObj(),s=A.getObj(),a=A.getObj(),n=A.getObj();let r,o;if(!(Number.isInteger(i)&&Number.isInteger(s)&&Uh(a,"obj")&&n instanceof vh&&"number"==typeof(r=n.get("Linearized"))&&r>0))return null;if((o=e(n,"L"))!==t.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:o,hints:function(t){const e=t.get("H");let A;if(Array.isArray(e)&&(2===(A=e.length)||4===A)){for(let t=0;t0))throw new Error(`Hint (${t}) in the linearization dictionary is invalid.`)}return e}throw new Error("Hint array in the linearization dictionary is invalid.")}(n),objectNumberFirst:e(n,"O"),endFirst:e(n,"E"),numPages:e(n,"N"),mainXRefEntriesOffset:e(n,"T"),pageFirst:n.has("P")?e(n,"P",!0):0}}}const xd=["Adobe-GB1-UCS2","Adobe-CNS1-UCS2","Adobe-Japan1-UCS2","Adobe-Korea1-UCS2","78-EUC-H","78-EUC-V","78-H","78-RKSJ-H","78-RKSJ-V","78-V","78ms-RKSJ-H","78ms-RKSJ-V","83pv-RKSJ-H","90ms-RKSJ-H","90ms-RKSJ-V","90msp-RKSJ-H","90msp-RKSJ-V","90pv-RKSJ-H","90pv-RKSJ-V","Add-H","Add-RKSJ-H","Add-RKSJ-V","Add-V","Adobe-CNS1-0","Adobe-CNS1-1","Adobe-CNS1-2","Adobe-CNS1-3","Adobe-CNS1-4","Adobe-CNS1-5","Adobe-CNS1-6","Adobe-GB1-0","Adobe-GB1-1","Adobe-GB1-2","Adobe-GB1-3","Adobe-GB1-4","Adobe-GB1-5","Adobe-Japan1-0","Adobe-Japan1-1","Adobe-Japan1-2","Adobe-Japan1-3","Adobe-Japan1-4","Adobe-Japan1-5","Adobe-Japan1-6","Adobe-Korea1-0","Adobe-Korea1-1","Adobe-Korea1-2","B5-H","B5-V","B5pc-H","B5pc-V","CNS-EUC-H","CNS-EUC-V","CNS1-H","CNS1-V","CNS2-H","CNS2-V","ETHK-B5-H","ETHK-B5-V","ETen-B5-H","ETen-B5-V","ETenms-B5-H","ETenms-B5-V","EUC-H","EUC-V","Ext-H","Ext-RKSJ-H","Ext-RKSJ-V","Ext-V","GB-EUC-H","GB-EUC-V","GB-H","GB-V","GBK-EUC-H","GBK-EUC-V","GBK2K-H","GBK2K-V","GBKp-EUC-H","GBKp-EUC-V","GBT-EUC-H","GBT-EUC-V","GBT-H","GBT-V","GBTpc-EUC-H","GBTpc-EUC-V","GBpc-EUC-H","GBpc-EUC-V","H","HKdla-B5-H","HKdla-B5-V","HKdlb-B5-H","HKdlb-B5-V","HKgccs-B5-H","HKgccs-B5-V","HKm314-B5-H","HKm314-B5-V","HKm471-B5-H","HKm471-B5-V","HKscs-B5-H","HKscs-B5-V","Hankaku","Hiragana","KSC-EUC-H","KSC-EUC-V","KSC-H","KSC-Johab-H","KSC-Johab-V","KSC-V","KSCms-UHC-H","KSCms-UHC-HW-H","KSCms-UHC-HW-V","KSCms-UHC-V","KSCpc-EUC-H","KSCpc-EUC-V","Katakana","NWP-H","NWP-V","RKSJ-H","RKSJ-V","Roman","UniCNS-UCS2-H","UniCNS-UCS2-V","UniCNS-UTF16-H","UniCNS-UTF16-V","UniCNS-UTF32-H","UniCNS-UTF32-V","UniCNS-UTF8-H","UniCNS-UTF8-V","UniGB-UCS2-H","UniGB-UCS2-V","UniGB-UTF16-H","UniGB-UTF16-V","UniGB-UTF32-H","UniGB-UTF32-V","UniGB-UTF8-H","UniGB-UTF8-V","UniJIS-UCS2-H","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V","UniJIS-UCS2-V","UniJIS-UTF16-H","UniJIS-UTF16-V","UniJIS-UTF32-H","UniJIS-UTF32-V","UniJIS-UTF8-H","UniJIS-UTF8-V","UniJIS2004-UTF16-H","UniJIS2004-UTF16-V","UniJIS2004-UTF32-H","UniJIS2004-UTF32-V","UniJIS2004-UTF8-H","UniJIS2004-UTF8-V","UniJISPro-UCS2-HW-V","UniJISPro-UCS2-V","UniJISPro-UTF8-V","UniJISX0213-UTF32-H","UniJISX0213-UTF32-V","UniJISX02132004-UTF32-H","UniJISX02132004-UTF32-V","UniKS-UCS2-H","UniKS-UCS2-V","UniKS-UTF16-H","UniKS-UTF16-V","UniKS-UTF32-H","UniKS-UTF32-V","UniKS-UTF8-H","UniKS-UTF8-V","V","WP-Symbol"],Fd=2**24-1;class Rd{constructor(t=!1){this.codespaceRanges=[[],[],[],[]],this.numCodespaceRanges=0,this._map=[],this.name="",this.vertical=!1,this.useCMap=null,this.builtInCMap=t}addCodespaceRange(t,e,A){this.codespaceRanges[t-1].push(e,A),this.numCodespaceRanges++}mapCidRange(t,e,A){if(e-t>Fd)throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");for(;t<=e;)this._map[t++]=A++}mapBfRange(t,e,A){if(e-t>Fd)throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");const i=A.length-1;for(;t<=e;){this._map[t++]=A;const e=A.charCodeAt(i)+1;A=e>255?A.substring(0,i-1)+String.fromCharCode(A.charCodeAt(i-1)+1)+"\0":A.substring(0,i)+String.fromCharCode(e)}}mapBfRangeToArray(t,e,A){if(e-t>Fd)throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");const i=A.length;let s=0;for(;t<=e&&s>>0;const n=s[a];for(let t=0,e=n.length;t=e&&i<=s)return A.charcode=i,void(A.length=a+1)}}A.charcode=0,A.length=1}getCharCodeLength(t){const e=this.codespaceRanges;for(let A=0,i=e.length;A=s&&t<=a)return A+1}}return 1}get length(){return this._map.length}get isIdentityCMap(){if("Identity-H"!==this.name&&"Identity-V"!==this.name)return!1;if(65536!==this._map.length)return!1;for(let t=0;t<65536;t++)if(this._map[t]!==t)return!1;return!0}}class vd extends Rd{constructor(t,e){super(),this.vertical=t,this.addCodespaceRange(e,0,65535)}mapCidRange(t,e,A){Xc("should not call mapCidRange")}mapBfRange(t,e,A){Xc("should not call mapBfRange")}mapBfRangeToArray(t,e,A){Xc("should not call mapBfRangeToArray")}mapOne(t,e){Xc("should not call mapCidOne")}lookup(t){return Number.isInteger(t)&&t<=65535?t:void 0}contains(t){return Number.isInteger(t)&&t<=65535}forEach(t){for(let e=0;e<=65535;e++)t(e,e)}charCodeOf(t){return Number.isInteger(t)&&t<=65535?t:-1}getMap(){const t=new Array(65536);for(let e=0;e<=65535;e++)t[e]=e;return t}get length(){return 65536}get isIdentityCMap(){Xc("should not access .isIdentityCMap")}}function Nd(t){let e=0;for(let A=0;A>>0}function Md(t){if("string"!=typeof t)throw new rh("Malformed CMap: expected string.")}function Gd(t){if(!Number.isInteger(t))throw new rh("Malformed CMap: expected int.")}function Ld(t,e){for(;;){let A=e.getObj();if(A===wh)break;if(Uh(A,"endbfchar"))return;Md(A);const i=Nd(A);A=e.getObj(),Md(A);const s=A;t.mapOne(i,s)}}function Ud(t,e){for(;;){let A=e.getObj();if(A===wh)break;if(Uh(A,"endbfrange"))return;Md(A);const i=Nd(A);A=e.getObj(),Md(A);const s=Nd(A);if(A=e.getObj(),Number.isInteger(A)||"string"==typeof A){const e=Number.isInteger(A)?String.fromCharCode(A):A;t.mapBfRange(i,s,e)}else{if(!Uh(A,"["))break;{A=e.getObj();const a=[];for(;!Uh(A,"]")&&A!==wh;)a.push(A),A=e.getObj();t.mapBfRangeToArray(i,s,a)}}}throw new rh("Invalid bf range.")}function Hd(t,e){for(;;){let A=e.getObj();if(A===wh)break;if(Uh(A,"endcidchar"))return;Md(A);const i=Nd(A);A=e.getObj(),Gd(A);const s=A;t.mapOne(i,s)}}function Jd(t,e){for(;;){let A=e.getObj();if(A===wh)break;if(Uh(A,"endcidrange"))return;Md(A);const i=Nd(A);A=e.getObj(),Md(A);const s=Nd(A);A=e.getObj(),Gd(A);const a=A;t.mapCidRange(i,s,a)}}function _d(t,e){for(;;){let A=e.getObj();if(A===wh)break;if(Uh(A,"endcodespacerange"))return;if("string"!=typeof A)break;const i=Nd(A);if(A=e.getObj(),"string"!=typeof A)break;const s=Nd(A);t.addCodespaceRange(A.length,i,s)}throw new rh("Invalid codespace range.")}function Yd(t,e){const A=e.getObj();Number.isInteger(A)&&(t.vertical=!!A)}function Td(t,e){const A=e.getObj();A instanceof xh&&(t.name=A.name)}async function Pd(t,e,A,i){let s,a;t:for(;;)try{const A=e.getObj();if(A===wh)break;if(A instanceof xh)"WMode"===A.name?Yd(t,e):"CMapName"===A.name&&Td(t,e),s=A;else if(A instanceof Fh)switch(A.cmd){case"endcmap":break t;case"usecmap":s instanceof xh&&(a=s.name);break;case"begincodespacerange":_d(t,e);break;case"beginbfchar":Ld(t,e);break;case"begincidchar":Hd(t,e);break;case"beginbfrange":Ud(t,e);break;case"begincidrange":Jd(t,e)}}catch(t){if(t instanceof Ph)throw t;Zc("Invalid cMap data: "+t);continue}return!i&&a&&(i=a),i?Kd(t,A,i):t}async function Kd(t,e,A){if(t.useCMap=await qd(A,e),0===t.numCodespaceRanges){const e=t.useCMap.codespaceRanges;for(let A=0;AKd(s,e,t)));if(i===Lc.NONE){const t=new kd(new bl(A));return Pd(s,t,e,null)}throw new Error(`Invalid CMap "compressionType" value: ${i}`)}class Od{static async create({encoding:t,fetchBuiltInCMap:e,useCMap:A}){if(t instanceof xh)return qd(t.name,e);if(t instanceof _h){const i=await Pd(new Rd,new kd(t),e,A);return i.isIdentityCMap?qd(i.name,e):i}throw new Error("Encoding required.")}}const Wd=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],jd=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Vd=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],Zd=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Xd=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","centoldstyle","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","","threequartersemdash","","questionsmall","","","","","Ethsmall","","","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","","","","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hypheninferior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","asuperior","centsuperior","","","","","Aacutesmall","Agravesmall","Acircumflexsmall","Adieresissmall","Atildesmall","Aringsmall","Ccedillasmall","Eacutesmall","Egravesmall","Ecircumflexsmall","Edieresissmall","Iacutesmall","Igravesmall","Icircumflexsmall","Idieresissmall","Ntildesmall","Oacutesmall","Ogravesmall","Ocircumflexsmall","Odieresissmall","Otildesmall","Uacutesmall","Ugravesmall","Ucircumflexsmall","Udieresissmall","","eightsuperior","fourinferior","threeinferior","sixinferior","eightinferior","seveninferior","Scaronsmall","","centinferior","twoinferior","","Dieresissmall","","Caronsmall","osuperior","fiveinferior","","commainferior","periodinferior","Yacutesmall","","dollarinferior","","","Thornsmall","","nineinferior","zeroinferior","Zcaronsmall","AEsmall","Oslashsmall","questiondownsmall","oneinferior","Lslashsmall","","","","","","","Cedillasmall","","","","","","OEsmall","figuredash","hyphensuperior","","","","","exclamdownsmall","","Ydieresissmall","","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","ninesuperior","zerosuperior","","esuperior","rsuperior","tsuperior","","","isuperior","ssuperior","dsuperior","","","","","","lsuperior","Ogoneksmall","Brevesmall","Macronsmall","bsuperior","nsuperior","msuperior","commasuperior","periodsuperior","Dotaccentsmall","Ringsmall","","","",""],zd=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","space","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron"],$d=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls","","","",""],tu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","bullet","Euro","bullet","quotesinglbase","florin","quotedblbase","ellipsis","dagger","daggerdbl","circumflex","perthousand","Scaron","guilsinglleft","OE","bullet","Zcaron","bullet","bullet","quoteleft","quoteright","quotedblleft","quotedblright","bullet","endash","emdash","tilde","trademark","scaron","guilsinglright","oe","bullet","zcaron","Ydieresis","space","exclamdown","cent","sterling","currency","yen","brokenbar","section","dieresis","copyright","ordfeminine","guillemotleft","logicalnot","hyphen","registered","macron","degree","plusminus","twosuperior","threesuperior","acute","mu","paragraph","periodcentered","cedilla","onesuperior","ordmasculine","guillemotright","onequarter","onehalf","threequarters","questiondown","Agrave","Aacute","Acircumflex","Atilde","Adieresis","Aring","AE","Ccedilla","Egrave","Eacute","Ecircumflex","Edieresis","Igrave","Iacute","Icircumflex","Idieresis","Eth","Ntilde","Ograve","Oacute","Ocircumflex","Otilde","Odieresis","multiply","Oslash","Ugrave","Uacute","Ucircumflex","Udieresis","Yacute","Thorn","germandbls","agrave","aacute","acircumflex","atilde","adieresis","aring","ae","ccedilla","egrave","eacute","ecircumflex","edieresis","igrave","iacute","icircumflex","idieresis","eth","ntilde","ograve","oacute","ocircumflex","otilde","odieresis","divide","oslash","ugrave","uacute","ucircumflex","udieresis","yacute","thorn","ydieresis"],eu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","universal","numbersign","existential","percent","ampersand","suchthat","parenleft","parenright","asteriskmath","plus","comma","minus","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","congruent","Alpha","Beta","Chi","Delta","Epsilon","Phi","Gamma","Eta","Iota","theta1","Kappa","Lambda","Mu","Nu","Omicron","Pi","Theta","Rho","Sigma","Tau","Upsilon","sigma1","Omega","Xi","Psi","Zeta","bracketleft","therefore","bracketright","perpendicular","underscore","radicalex","alpha","beta","chi","delta","epsilon","phi","gamma","eta","iota","phi1","kappa","lambda","mu","nu","omicron","pi","theta","rho","sigma","tau","upsilon","omega1","omega","xi","psi","zeta","braceleft","bar","braceright","similar","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Euro","Upsilon1","minute","lessequal","fraction","infinity","florin","club","diamond","heart","spade","arrowboth","arrowleft","arrowup","arrowright","arrowdown","degree","plusminus","second","greaterequal","multiply","proportional","partialdiff","bullet","divide","notequal","equivalence","approxequal","ellipsis","arrowvertex","arrowhorizex","carriagereturn","aleph","Ifraktur","Rfraktur","weierstrass","circlemultiply","circleplus","emptyset","intersection","union","propersuperset","reflexsuperset","notsubset","propersubset","reflexsubset","element","notelement","angle","gradient","registerserif","copyrightserif","trademarkserif","product","radical","dotmath","logicalnot","logicaland","logicalor","arrowdblboth","arrowdblleft","arrowdblup","arrowdblright","arrowdbldown","lozenge","angleleft","registersans","copyrightsans","trademarksans","summation","parenlefttp","parenleftex","parenleftbt","bracketlefttp","bracketleftex","bracketleftbt","bracelefttp","braceleftmid","braceleftbt","braceex","","angleright","integral","integraltp","integralex","integralbt","parenrighttp","parenrightex","parenrightbt","bracketrighttp","bracketrightex","bracketrightbt","bracerighttp","bracerightmid","bracerightbt",""],Au=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","a1","a2","a202","a3","a4","a5","a119","a118","a117","a11","a12","a13","a14","a15","a16","a105","a17","a18","a19","a20","a21","a22","a23","a24","a25","a26","a27","a28","a6","a7","a8","a9","a10","a29","a30","a31","a32","a33","a34","a35","a36","a37","a38","a39","a40","a41","a42","a43","a44","a45","a46","a47","a48","a49","a50","a51","a52","a53","a54","a55","a56","a57","a58","a59","a60","a61","a62","a63","a64","a65","a66","a67","a68","a69","a70","a71","a72","a73","a74","a203","a75","a204","a76","a77","a78","a79","a81","a82","a83","a84","a97","a98","a99","a100","","a89","a90","a93","a94","a91","a92","a205","a85","a206","a86","a87","a88","a95","a96","","","","","","","","","","","","","","","","","","","","a101","a102","a103","a104","a106","a107","a108","a112","a111","a110","a109","a120","a121","a122","a123","a124","a125","a126","a127","a128","a129","a130","a131","a132","a133","a134","a135","a136","a137","a138","a139","a140","a141","a142","a143","a144","a145","a146","a147","a148","a149","a150","a151","a152","a153","a154","a155","a156","a157","a158","a159","a160","a161","a163","a164","a196","a165","a192","a166","a167","a168","a169","a170","a171","a172","a173","a162","a174","a175","a176","a177","a178","a179","a193","a180","a199","a181","a200","a182","","a201","a183","a184","a197","a185","a194","a198","a186","a195","a187","a188","a189","a190","a191",""];function iu(t){switch(t){case"WinAnsiEncoding":return tu;case"StandardEncoding":return $d;case"MacRomanEncoding":return zd;case"SymbolSetEncoding":return eu;case"ZapfDingbatsEncoding":return Au;case"ExpertEncoding":return Zd;case"MacExpertEncoding":return Xd;default:return null}}const su=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],au=[null,{id:"hstem",min:2,stackClearing:!0,stem:!0},null,{id:"vstem",min:2,stackClearing:!0,stem:!0},{id:"vmoveto",min:1,stackClearing:!0},{id:"rlineto",min:2,resetStack:!0},{id:"hlineto",min:1,resetStack:!0},{id:"vlineto",min:1,resetStack:!0},{id:"rrcurveto",min:6,resetStack:!0},null,{id:"callsubr",min:1,undefStack:!0},{id:"return",min:0,undefStack:!0},null,null,{id:"endchar",min:0,stackClearing:!0},null,null,null,{id:"hstemhm",min:2,stackClearing:!0,stem:!0},{id:"hintmask",min:0,stackClearing:!0},{id:"cntrmask",min:0,stackClearing:!0},{id:"rmoveto",min:2,stackClearing:!0},{id:"hmoveto",min:1,stackClearing:!0},{id:"vstemhm",min:2,stackClearing:!0,stem:!0},{id:"rcurveline",min:8,resetStack:!0},{id:"rlinecurve",min:8,resetStack:!0},{id:"vvcurveto",min:4,resetStack:!0},{id:"hhcurveto",min:4,resetStack:!0},null,{id:"callgsubr",min:1,undefStack:!0},{id:"vhcurveto",min:4,resetStack:!0},{id:"hvcurveto",min:4,resetStack:!0}],nu=[null,null,null,{id:"and",min:2,stackDelta:-1},{id:"or",min:2,stackDelta:-1},{id:"not",min:1,stackDelta:0},null,null,null,{id:"abs",min:1,stackDelta:0},{id:"add",min:2,stackDelta:-1,stackFn(t,e){t[e-2]=t[e-2]+t[e-1]}},{id:"sub",min:2,stackDelta:-1,stackFn(t,e){t[e-2]=t[e-2]-t[e-1]}},{id:"div",min:2,stackDelta:-1,stackFn(t,e){t[e-2]=t[e-2]/t[e-1]}},null,{id:"neg",min:1,stackDelta:0,stackFn(t,e){t[e-1]=-t[e-1]}},{id:"eq",min:2,stackDelta:-1},null,null,{id:"drop",min:1,stackDelta:-1},null,{id:"put",min:2,stackDelta:-2},{id:"get",min:1,stackDelta:0},{id:"ifelse",min:4,stackDelta:-3},{id:"random",min:0,stackDelta:1},{id:"mul",min:2,stackDelta:-1,stackFn(t,e){t[e-2]=t[e-2]*t[e-1]}},null,{id:"sqrt",min:1,stackDelta:0},{id:"dup",min:1,stackDelta:1},{id:"exch",min:2,stackDelta:0},{id:"index",min:2,stackDelta:0},{id:"roll",min:3,stackDelta:-2},null,null,null,{id:"hflex",min:7,resetStack:!0},{id:"flex",min:13,resetStack:!0},{id:"hflex1",min:9,resetStack:!0},{id:"flex1",min:11,resetStack:!0}];class ru{constructor(t,e,A){this.bytes=t.getBytes(),this.properties=e,this.seacAnalysisEnabled=!!A}parse(){const t=this.properties,e=new ou;this.cff=e;const A=this.parseHeader(),i=this.parseIndex(A.endPos),s=this.parseIndex(i.endPos),a=this.parseIndex(s.endPos),n=this.parseIndex(a.endPos),r=this.parseDict(s.obj.get(0)),o=this.createDict(du,r,e.strings);e.header=A.obj,e.names=this.parseNameIndex(i.obj),e.strings=this.parseStringIndex(a.obj),e.topDict=o,e.globalSubrIndex=n.obj,this.parsePrivateDict(e.topDict),e.isCIDFont=o.hasName("ROS");const g=o.getByName("CharStrings"),c=this.parseIndex(g).obj,h=o.getByName("FontMatrix");h&&(t.fontMatrix=h);const l=o.getByName("FontBBox");let I,d;if(l&&(t.ascent=Math.max(l[3],l[1]),t.descent=Math.min(l[1],l[3]),t.ascentScaled=!0),e.isCIDFont){const t=this.parseIndex(o.getByName("FDArray")).obj;for(let A=0,i=t.count;A=e)throw new rh("Invalid CFF header");0!==A&&(Vc("cff data is shifted"),t=t.subarray(A),this.bytes=t);const i=t[0],s=t[1],a=t[2],n=t[3];return{obj:new gu(i,s,a,n),endPos:a}}parseDict(t){let e=0;function A(){let A=t[e++];return 30===A?function(){let A="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"],s=t.length;for(;e>4,n=15&s;if(15===a)break;if(A+=i[a],15===n)break;A+=i[n]}return parseFloat(A)}():28===A?(A=t[e++],A=(A<<24|t[e++]<<16)>>16,A):29===A?(A=t[e++],A=A<<8|t[e++],A=A<<8|t[e++],A=A<<8|t[e++],A):A>=32&&A<=246?A-139:A>=247&&A<=250?256*(A-247)+t[e++]+108:A>=251&&A<=254?-256*(A-251)-t[e++]-108:(Zc('CFFParser_parseDict: "'+A+'" is a reserved command.'),NaN)}let i=[];const s=[];e=0;const a=t.length;for(;e10)return!1;let s=t.stackSize;const a=t.stack;let n=e.length;for(let r=0;r>16,r+=2,s++;else if(14===o){if(s>=4&&(s-=4,this.seacAnalysisEnabled))return t.seac=a.slice(s,s+4),!1;g=au[o]}else if(o>=32&&o<=246)a[s]=o-139,s++;else if(o>=247&&o<=254)a[s]=o<251?(o-247<<8)+e[r]+108:-(o-251<<8)-e[r]-108,r++,s++;else if(255===o)a[s]=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])/65536,r+=4,s++;else if(19===o||20===o){if(t.hints+=s>>1,0===t.hints){e.copyWithin(r-1,r,-1),r-=1,n-=1;continue}r+=t.hints+7>>3,s%=2,g=au[o]}else{if(10===o||29===o){const e=10===o?A:i;if(!e)return g=au[o],Zc("Missing subrsIndex for "+g.id),!1;let n=32768;e.count<1240?n=107:e.count<33900&&(n=1131);const r=a[--s]+n;if(r<0||r>=e.count||isNaN(r))return g=au[o],Zc("Out of bounds subrIndex for "+g.id),!1;if(t.stackSize=s,t.callDepth++,!this.parseCharString(t,e.get(r),A,i))return!1;t.callDepth--,s=t.stackSize;continue}if(11===o)return t.stackSize=s,!0;if(0===o&&r===e.length)e[r-1]=14,g=au[14];else{if(9===o){e.copyWithin(r-1,r,-1),r-=1,n-=1;continue}g=au[o]}}if(g){if(g.stem&&(t.hints+=s>>1,3===o||23===o?t.hasVStems=!0:!t.hasVStems||1!==o&&18!==o||(Zc("CFF stem hints are in wrong order"),e[r-1]=1===o?3:23)),"min"in g&&!t.undefStack&&s=2&&g.stem?s%=2:s>1&&Zc("Found too many parameters for stack-clearing command"),s>0&&(t.width=a[s-1])),"stackDelta"in g?("stackFn"in g&&g.stackFn(a,s),s+=g.stackDelta):g.stackClearing?s=0:g.resetStack?(s=0,t.undefStack=!1):g.undefStack&&(s=0,t.undefStack=!0,t.firstStackClearing=!1)}}return n=s.length&&(Zc("Invalid fd index for glyph index."),h=!1),h&&(I=s[t].privateDict,l=I.subrsIndex)}else e&&(l=e);if(h&&(h=this.parseCharString(c,o,l,A)),null!==c.width){const t=I.getByName("nominalWidthX");r[g]=t+c.width}else{const t=I.getByName("defaultWidthX");r[g]=t}null!==c.seac&&(n[g]=c.seac),h||t.set(g,new Uint8Array([14]))}return{charStrings:t,seacs:n,widths:r}}emptyPrivateDictionary(t){const e=this.createDict(Cu,[],t.strings);t.setByKey(18,[0,0]),t.privateDict=e}parsePrivateDict(t){if(!t.hasName("Private"))return void this.emptyPrivateDictionary(t);const e=t.getByName("Private");if(!Array.isArray(e)||2!==e.length)return void t.removeByName("Private");const A=e[0],i=e[1];if(0===A||i>=this.bytes.length)return void this.emptyPrivateDictionary(t);const s=i+A,a=this.bytes.subarray(i,s),n=this.parseDict(a),r=this.createDict(Cu,n,t.strings);if(t.privateDict=r,0===r.getByName("ExpansionFactor")&&r.setByName("ExpansionFactor",.06),!r.getByName("Subrs"))return;const o=r.getByName("Subrs"),g=i+o;if(0===o||g>=this.bytes.length)return void this.emptyPrivateDictionary(t);const c=this.parseIndex(g);r.subrsIndex=c.obj}parseCharsets(t,e,A,i){if(0===t)return new Qu(!0,Bu.ISO_ADOBE,Wd);if(1===t)return new Qu(!0,Bu.EXPERT,jd);if(2===t)return new Qu(!0,Bu.EXPERT_SUBSET,Vd);const s=this.bytes,a=t,n=s[t++],r=[i?0:".notdef"];let o,g,c;switch(e-=1,n){case 0:for(c=0;c=65535)return void Zc("Not enough space in charstrings to duplicate first glyph.");const t=this.charStrings.get(0);this.charStrings.add(t),this.isCIDFont&&this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0])}hasGlyphId(t){return!(t<0||t>=this.charStrings.count)&&this.charStrings.get(t).length>0}}class gu{constructor(t,e,A,i){this.major=t,this.minor=e,this.hdrSize=A,this.offSize=i}}class cu{constructor(){this.strings=[]}get(t){return t>=0&&t<=390?su[t]:t-391<=this.strings.length?this.strings[t-391]:su[0]}getSID(t){let e=su.indexOf(t);return-1!==e?e:(e=this.strings.indexOf(t),-1!==e?e+391:-1)}add(t){this.strings.push(t)}get count(){return this.strings.length}}class hu{constructor(){this.objects=[],this.length=0}add(t){this.length+=t.length,this.objects.push(t)}set(t,e){this.length+=e.length-this.objects[t].length,this.objects[t]=e}get(t){return this.objects[t]}get count(){return this.objects.length}}class lu{constructor(t,e){this.keyToNameMap=t.keyToNameMap,this.nameToKeyMap=t.nameToKeyMap,this.defaults=t.defaults,this.types=t.types,this.opcodes=t.opcodes,this.order=t.order,this.strings=e,this.values=Object.create(null)}setByKey(t,e){if(!(t in this.keyToNameMap))return!1;if(0===e.length)return!0;for(const A of e)if(isNaN(A))return Zc(`Invalid CFFDict value: "${e}" for key "${t}".`),!0;const A=this.types[t];return"num"!==A&&"sid"!==A&&"offset"!==A||(e=e[0]),this.values[t]=e,!0}setByName(t,e){if(!(t in this.nameToKeyMap))throw new rh(`Invalid dictionary name "${t}"`);this.values[this.nameToKeyMap[t]]=e}hasName(t){return this.nameToKeyMap[t]in this.values}getByName(t){if(!(t in this.nameToKeyMap))throw new rh(`Invalid dictionary name ${t}"`);const e=this.nameToKeyMap[t];return e in this.values?this.values[e]:this.defaults[e]}removeByName(t){delete this.values[this.nameToKeyMap[t]]}static createTables(t){const e={keyToNameMap:{},nameToKeyMap:{},defaults:{},types:{},opcodes:{},order:[]};for(const A of t){const t=Array.isArray(A[0])?(A[0][0]<<8)+A[0][1]:A[0];e.keyToNameMap[t]=A[1],e.nameToKeyMap[A[1]]=t,e.types[t]=A[2],e.defaults[t]=A[3],e.opcodes[t]=Array.isArray(A[0])?A[0]:[A[0]],e.order.push(t)}return e}}const Iu=[[[12,30],"ROS",["sid","sid","num"],null],[[12,20],"SyntheticBase","num",null],[0,"version","sid",null],[1,"Notice","sid",null],[[12,0],"Copyright","sid",null],[2,"FullName","sid",null],[3,"FamilyName","sid",null],[4,"Weight","sid",null],[[12,1],"isFixedPitch","num",0],[[12,2],"ItalicAngle","num",0],[[12,3],"UnderlinePosition","num",-100],[[12,4],"UnderlineThickness","num",50],[[12,5],"PaintType","num",0],[[12,6],"CharstringType","num",2],[[12,7],"FontMatrix",["num","num","num","num","num","num"],[.001,0,0,.001,0,0]],[13,"UniqueID","num",null],[5,"FontBBox",["num","num","num","num"],[0,0,0,0]],[[12,8],"StrokeWidth","num",0],[14,"XUID","array",null],[15,"charset","offset",0],[16,"Encoding","offset",0],[17,"CharStrings","offset",0],[18,"Private",["offset","offset"],null],[[12,21],"PostScript","sid",null],[[12,22],"BaseFontName","sid",null],[[12,23],"BaseFontBlend","delta",null],[[12,31],"CIDFontVersion","num",0],[[12,32],"CIDFontRevision","num",0],[[12,33],"CIDFontType","num",0],[[12,34],"CIDCount","num",8720],[[12,35],"UIDBase","num",null],[[12,37],"FDSelect","offset",null],[[12,36],"FDArray","offset",null],[[12,38],"FontName","sid",null]];class du extends lu{static get tables(){return th(this,"tables",this.createTables(Iu))}constructor(t){super(du.tables,t),this.privateDict=null}}const uu=[[6,"BlueValues","delta",null],[7,"OtherBlues","delta",null],[8,"FamilyBlues","delta",null],[9,"FamilyOtherBlues","delta",null],[[12,9],"BlueScale","num",.039625],[[12,10],"BlueShift","num",7],[[12,11],"BlueFuzz","num",1],[10,"StdHW","num",null],[11,"StdVW","num",null],[[12,12],"StemSnapH","delta",null],[[12,13],"StemSnapV","delta",null],[[12,14],"ForceBold","num",0],[[12,17],"LanguageGroup","num",0],[[12,18],"ExpansionFactor","num",.06],[[12,19],"initialRandomSeed","num",0],[20,"defaultWidthX","num",0],[21,"nominalWidthX","num",0],[19,"Subrs","offset",null]];class Cu extends lu{static get tables(){return th(this,"tables",this.createTables(uu))}constructor(t){super(Cu.tables,t),this.subrsIndex=null}}const Bu={ISO_ADOBE:0,EXPERT:1,EXPERT_SUBSET:2};class Qu{constructor(t,e,A,i){this.predefined=t,this.format=e,this.charset=A,this.raw=i}}class Eu{constructor(t,e,A,i){this.predefined=t,this.format=e,this.encoding=A,this.raw=i}}class fu{constructor(t,e){this.format=t,this.fdSelect=e}getFDIndex(t){return t<0||t>=this.fdSelect.length?-1:this.fdSelect[t]}}class pu{constructor(){this.offsets=Object.create(null)}isTracking(t){return t in this.offsets}track(t,e){if(t in this.offsets)throw new rh(`Already tracking location of ${t}`);this.offsets[t]=e}offset(t){for(const e in this.offsets)this.offsets[e]+=t}setEntryLocation(t,e,A){if(!(t in this.offsets))throw new rh(`Not tracking location of ${t}`);const i=A.data,s=this.offsets[t];for(let t=0,A=e.length;t>24&255,i[n]=g>>16&255,i[r]=g>>8&255,i[o]=255&g}}}class mu{constructor(t){this.cff=t}compile(){const t=this.cff,e={data:[],length:0,add(t){try{this.data.push(...t)}catch{this.data=this.data.concat(t)}this.length=this.data.length}},A=this.compileHeader(t.header);e.add(A);const i=this.compileNameIndex(t.names);if(e.add(i),t.isCIDFont&&t.topDict.hasName("FontMatrix")){const e=t.topDict.getByName("FontMatrix");t.topDict.removeByName("FontMatrix");for(const A of t.fdArray){let t=e.slice(0);A.hasName("FontMatrix")&&(t=uh.transform(t,A.getByName("FontMatrix"))),A.setByName("FontMatrix",t)}}const s=t.topDict.getByName("XUID");s?.length>16&&t.topDict.removeByName("XUID"),t.topDict.setByName("charset",0);let a=this.compileTopDicts([t.topDict],e.length,t.isCIDFont);e.add(a.output);const n=a.trackers[0],r=this.compileStringIndex(t.strings.strings);e.add(r);const o=this.compileIndex(t.globalSubrIndex);if(e.add(o),t.encoding&&t.topDict.hasName("Encoding"))if(t.encoding.predefined)n.setEntryLocation("Encoding",[t.encoding.format],e);else{const A=this.compileEncoding(t.encoding);n.setEntryLocation("Encoding",[e.length],e),e.add(A)}const g=this.compileCharset(t.charset,t.charStrings.count,t.strings,t.isCIDFont);n.setEntryLocation("charset",[e.length],e),e.add(g);const c=this.compileCharStrings(t.charStrings);if(n.setEntryLocation("CharStrings",[e.length],e),e.add(c),t.isCIDFont){n.setEntryLocation("FDSelect",[e.length],e);const A=this.compileFDSelect(t.fdSelect);e.add(A),a=this.compileTopDicts(t.fdArray,e.length,!0),n.setEntryLocation("FDArray",[e.length],e),e.add(a.output);const i=a.trackers;this.compilePrivateDicts(t.fdArray,i,e)}return this.compilePrivateDicts([t.topDict],[n],e),e.add([0]),e.data}encodeNumber(t){return Number.isInteger(t)?this.encodeInteger(t):this.encodeFloat(t)}static get EncodeFloatRegExp(){return th(this,"EncodeFloatRegExp",/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/)}encodeFloat(t){let e=t.toString();const A=mu.EncodeFloatRegExp.exec(e);if(A){const i=parseFloat("1e"+((A[2]?+A[2]:0)+A[1].length));e=(Math.round(t*i)/i).toString()}let i,s,a="";for(i=0,s=e.length;i=-107&&t<=107?[t+139]:t>=108&&t<=1131?[247+((t-=108)>>8),255&t]:t>=-1131&&t<=-108?[251+((t=-t-108)>>8),255&t]:t>=-32768&&t<=32767?[28,t>>8&255,255&t]:[29,t>>24&255,t>>16&255,t>>8&255,255&t],e}compileHeader(t){return[t.major,t.minor,4,t.offSize]}compileNameIndex(t){const e=new hu;for(const A of t){const t=Math.min(A.length,127);let i=new Array(t);for(let e=0;e"~"||"["===t||"]"===t||"("===t||")"===t||"{"===t||"}"===t||"<"===t||">"===t||"/"===t||"%"===t)&&(t="_"),i[e]=t}i=i.join(""),""===i&&(i="Bad_Font_Name"),e.add(ch(i))}return this.compileIndex(e)}compileTopDicts(t,e,A){const i=[];let s=new hu;for(const a of t){A&&(a.removeByName("CIDFontVersion"),a.removeByName("CIDFontRevision"),a.removeByName("CIDFontType"),a.removeByName("CIDCount"),a.removeByName("UIDBase"));const t=new pu,n=this.compileDict(a,t);i.push(t),s.add(n),t.offset(e)}return s=this.compileIndex(s,i),{trackers:i,output:s}}compilePrivateDicts(t,e,A){for(let i=0,s=t.length;i>8&255,255&a]);else{s=new Uint8Array(1+2*a),s[0]=0;let e=0;const i=t.charset.length;let n=!1;for(let a=1;a>8&255,s[a+1]=255&r}}return this.compileTypedArray(s)}compileEncoding(t){return this.compileTypedArray(t.raw)}compileFDSelect(t){const e=t.format;let A,i;switch(e){case 0:for(A=new Uint8Array(1+t.fdSelect.length),A[0]=e,i=0;i>8&255,255&s,a];for(i=1;i>8&255,255&i,e),a=e)}const r=(n.length-3)/3;n[1]=r>>8&255,n[2]=255&r,n.push(i>>8&255,255&i),A=new Uint8Array(n)}return this.compileTypedArray(A)}compileTypedArray(t){return Array.from(t)}compileIndex(t,e=[]){const A=t.objects,i=A.length;if(0===i)return[0,0];const s=[i>>8&255,255&i];let a,n,r=1;for(a=0;a>8&255,255&o):3===n?s.push(o>>16&255,o>>8&255,255&o):s.push(o>>>24&255,o>>16&255,o>>8&255,255&o),A[a]&&(o+=A[a].length);for(a=0;a=5&&e<=7))return-1;i=t.substring(1)}if(i===i.toUpperCase()&&(A=parseInt(i,16),A>=0))return A}return-1}const ku=[[0,127],[128,255],[256,383],[384,591],[592,687,7424,7551,7552,7615],[688,767,42752,42783],[768,879,7616,7679],[880,1023],[11392,11519],[1024,1279,1280,1327,11744,11775,42560,42655],[1328,1423],[1424,1535],[42240,42559],[1536,1791,1872,1919],[1984,2047],[2304,2431],[2432,2559],[2560,2687],[2688,2815],[2816,2943],[2944,3071],[3072,3199],[3200,3327],[3328,3455],[3584,3711],[3712,3839],[4256,4351,11520,11567],[6912,7039],[4352,4607],[7680,7935,11360,11391,42784,43007],[7936,8191],[8192,8303,11776,11903],[8304,8351],[8352,8399],[8400,8447],[8448,8527],[8528,8591],[8592,8703,10224,10239,10496,10623,11008,11263],[8704,8959,10752,11007,10176,10223,10624,10751],[8960,9215],[9216,9279],[9280,9311],[9312,9471],[9472,9599],[9600,9631],[9632,9727],[9728,9983],[9984,10175],[12288,12351],[12352,12447],[12448,12543,12784,12799],[12544,12591,12704,12735],[12592,12687],[43072,43135],[12800,13055],[13056,13311],[44032,55215],[55296,57343],[67840,67871],[19968,40959,11904,12031,12032,12255,12272,12287,13312,19903,131072,173791,12688,12703],[57344,63743],[12736,12783,63744,64255,194560,195103],[64256,64335],[64336,65023],[65056,65071],[65040,65055],[65104,65135],[65136,65279],[65280,65519],[65520,65535],[3840,4095],[1792,1871],[1920,1983],[3456,3583],[4096,4255],[4608,4991,4992,5023,11648,11743],[5024,5119],[5120,5759],[5760,5791],[5792,5887],[6016,6143],[6144,6319],[10240,10495],[40960,42127],[5888,5919,5920,5951,5952,5983,5984,6015],[66304,66351],[66352,66383],[66560,66639],[118784,119039,119040,119295,119296,119375],[119808,120831],[1044480,1048573],[65024,65039,917760,917999],[917504,917631],[6400,6479],[6480,6527],[6528,6623],[6656,6687],[11264,11359],[11568,11647],[19904,19967],[43008,43055],[65536,65663,65664,65791,65792,65855],[65856,65935],[66432,66463],[66464,66527],[66640,66687],[66688,66735],[67584,67647],[68096,68191],[119552,119647],[73728,74751,74752,74879],[119648,119679],[7040,7103],[7168,7247],[7248,7295],[43136,43231],[43264,43311],[43312,43359],[43520,43615],[65936,65999],[66e3,66047],[66208,66271,66176,66207,67872,67903],[127024,127135,126976,127023]];function Su(t,e=-1){if(-1!==e){const A=ku[e];for(let i=0,s=A.length;i=A[i]&&t<=A[i+1])return e}for(let e=0,A=ku.length;e=A[i]&&t<=A[i+1])return e}return-1}const xu=new RegExp("^(\\s)|(\\p{Mn})|(\\p{Cf})$","u"),Fu=new Map,Ru=!0,vu=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function Nu(t,e){if(void 0!==e[t])return t;const A=Du(t,e);if(-1!==A)for(const t in e)if(e[t]===A)return t;return Vc("Unable to recover a standard glyph name for: "+t),t}function Mu(t,e,A){const i=Object.create(null);let s,a,n;const r=!!(4&t.flags);if(t.isInternalFont)for(n=e,a=0;a=0?s:0;else if(t.baseEncodingName)for(n=iu(t.baseEncodingName),a=0;a=0?s:0;else if(r)for(a in e)i[a]=e[a];else for(n=$d,a=0;a=0?s:0;const o=t.differences;let g;if(o)for(a in o){const t=o[a];if(s=A.indexOf(t),-1===s){g||(g=yu());const e=Nu(t,g);e!==t&&(s=A.indexOf(e))}i[a]=s>=0?s:0}return i}function Gu(t){return t.replaceAll(/[,_]/g,"-").replaceAll(/\s/g,"")}const Lu=Th((t=>{t[8211]=65074,t[8212]=65073,t[8229]=65072,t[8230]=65049,t[12289]=65041,t[12290]=65042,t[12296]=65087,t[12297]=65088,t[12298]=65085,t[12299]=65086,t[12300]=65089,t[12301]=65090,t[12302]=65091,t[12303]=65092,t[12304]=65083,t[12305]=65084,t[12308]=65081,t[12309]=65082,t[12310]=65047,t[12311]=65048,t[65103]=65076,t[65281]=65045,t[65288]=65077,t[65289]=65078,t[65292]=65040,t[65306]=65043,t[65307]=65044,t[65311]=65046,t[65339]=65095,t[65341]=65096,t[65343]=65075,t[65371]=65079,t[65373]=65080})),Uu=Th((function(t){t["Times-Roman"]="Times-Roman",t.Helvetica="Helvetica",t.Courier="Courier",t.Symbol="Symbol",t["Times-Bold"]="Times-Bold",t["Helvetica-Bold"]="Helvetica-Bold",t["Courier-Bold"]="Courier-Bold",t.ZapfDingbats="ZapfDingbats",t["Times-Italic"]="Times-Italic",t["Helvetica-Oblique"]="Helvetica-Oblique",t["Courier-Oblique"]="Courier-Oblique",t["Times-BoldItalic"]="Times-BoldItalic",t["Helvetica-BoldOblique"]="Helvetica-BoldOblique",t["Courier-BoldOblique"]="Courier-BoldOblique",t.ArialNarrow="Helvetica",t["ArialNarrow-Bold"]="Helvetica-Bold",t["ArialNarrow-BoldItalic"]="Helvetica-BoldOblique",t["ArialNarrow-Italic"]="Helvetica-Oblique",t.ArialBlack="Helvetica",t["ArialBlack-Bold"]="Helvetica-Bold",t["ArialBlack-BoldItalic"]="Helvetica-BoldOblique",t["ArialBlack-Italic"]="Helvetica-Oblique",t["Arial-Black"]="Helvetica",t["Arial-Black-Bold"]="Helvetica-Bold",t["Arial-Black-BoldItalic"]="Helvetica-BoldOblique",t["Arial-Black-Italic"]="Helvetica-Oblique",t.Arial="Helvetica",t["Arial-Bold"]="Helvetica-Bold",t["Arial-BoldItalic"]="Helvetica-BoldOblique",t["Arial-Italic"]="Helvetica-Oblique",t.ArialMT="Helvetica",t["Arial-BoldItalicMT"]="Helvetica-BoldOblique",t["Arial-BoldMT"]="Helvetica-Bold",t["Arial-ItalicMT"]="Helvetica-Oblique",t["Arial-BoldItalicMT-BoldItalic"]="Helvetica-BoldOblique",t["Arial-BoldMT-Bold"]="Helvetica-Bold",t["Arial-ItalicMT-Italic"]="Helvetica-Oblique",t.ArialUnicodeMS="Helvetica",t["ArialUnicodeMS-Bold"]="Helvetica-Bold",t["ArialUnicodeMS-BoldItalic"]="Helvetica-BoldOblique",t["ArialUnicodeMS-Italic"]="Helvetica-Oblique",t["Courier-BoldItalic"]="Courier-BoldOblique",t["Courier-Italic"]="Courier-Oblique",t.CourierNew="Courier",t["CourierNew-Bold"]="Courier-Bold",t["CourierNew-BoldItalic"]="Courier-BoldOblique",t["CourierNew-Italic"]="Courier-Oblique",t["CourierNewPS-BoldItalicMT"]="Courier-BoldOblique",t["CourierNewPS-BoldMT"]="Courier-Bold",t["CourierNewPS-ItalicMT"]="Courier-Oblique",t.CourierNewPSMT="Courier",t["Helvetica-BoldItalic"]="Helvetica-BoldOblique",t["Helvetica-Italic"]="Helvetica-Oblique",t["Symbol-Bold"]="Symbol",t["Symbol-BoldItalic"]="Symbol",t["Symbol-Italic"]="Symbol",t.TimesNewRoman="Times-Roman",t["TimesNewRoman-Bold"]="Times-Bold",t["TimesNewRoman-BoldItalic"]="Times-BoldItalic",t["TimesNewRoman-Italic"]="Times-Italic",t.TimesNewRomanPS="Times-Roman",t["TimesNewRomanPS-Bold"]="Times-Bold",t["TimesNewRomanPS-BoldItalic"]="Times-BoldItalic",t["TimesNewRomanPS-BoldItalicMT"]="Times-BoldItalic",t["TimesNewRomanPS-BoldMT"]="Times-Bold",t["TimesNewRomanPS-Italic"]="Times-Italic",t["TimesNewRomanPS-ItalicMT"]="Times-Italic",t.TimesNewRomanPSMT="Times-Roman",t["TimesNewRomanPSMT-Bold"]="Times-Bold",t["TimesNewRomanPSMT-BoldItalic"]="Times-BoldItalic",t["TimesNewRomanPSMT-Italic"]="Times-Italic"})),Hu=Th((function(t){t.Courier="FoxitFixed.pfb",t["Courier-Bold"]="FoxitFixedBold.pfb",t["Courier-BoldOblique"]="FoxitFixedBoldItalic.pfb",t["Courier-Oblique"]="FoxitFixedItalic.pfb",t.Helvetica="LiberationSans-Regular.ttf",t["Helvetica-Bold"]="LiberationSans-Bold.ttf",t["Helvetica-BoldOblique"]="LiberationSans-BoldItalic.ttf",t["Helvetica-Oblique"]="LiberationSans-Italic.ttf",t["Times-Roman"]="FoxitSerif.pfb",t["Times-Bold"]="FoxitSerifBold.pfb",t["Times-BoldItalic"]="FoxitSerifBoldItalic.pfb",t["Times-Italic"]="FoxitSerifItalic.pfb",t.Symbol="FoxitSymbol.pfb",t.ZapfDingbats="FoxitDingbats.pfb",t["LiberationSans-Regular"]="LiberationSans-Regular.ttf",t["LiberationSans-Bold"]="LiberationSans-Bold.ttf",t["LiberationSans-Italic"]="LiberationSans-Italic.ttf",t["LiberationSans-BoldItalic"]="LiberationSans-BoldItalic.ttf"})),Ju=Th((function(t){t.Calibri="Helvetica",t["Calibri-Bold"]="Helvetica-Bold",t["Calibri-BoldItalic"]="Helvetica-BoldOblique",t["Calibri-Italic"]="Helvetica-Oblique",t.CenturyGothic="Helvetica",t["CenturyGothic-Bold"]="Helvetica-Bold",t["CenturyGothic-BoldItalic"]="Helvetica-BoldOblique",t["CenturyGothic-Italic"]="Helvetica-Oblique",t.ComicSansMS="Comic Sans MS",t["ComicSansMS-Bold"]="Comic Sans MS-Bold",t["ComicSansMS-BoldItalic"]="Comic Sans MS-BoldItalic",t["ComicSansMS-Italic"]="Comic Sans MS-Italic",t.Impact="Helvetica",t["ItcSymbol-Bold"]="Helvetica-Bold",t["ItcSymbol-BoldItalic"]="Helvetica-BoldOblique",t["ItcSymbol-Book"]="Helvetica",t["ItcSymbol-BookItalic"]="Helvetica-Oblique",t["ItcSymbol-Medium"]="Helvetica",t["ItcSymbol-MediumItalic"]="Helvetica-Oblique",t.LucidaConsole="Courier",t["LucidaConsole-Bold"]="Courier-Bold",t["LucidaConsole-BoldItalic"]="Courier-BoldOblique",t["LucidaConsole-Italic"]="Courier-Oblique",t["LucidaSans-Demi"]="Helvetica-Bold",t["MS-Gothic"]="MS Gothic",t["MS-Gothic-Bold"]="MS Gothic-Bold",t["MS-Gothic-BoldItalic"]="MS Gothic-BoldItalic",t["MS-Gothic-Italic"]="MS Gothic-Italic",t["MS-Mincho"]="MS Mincho",t["MS-Mincho-Bold"]="MS Mincho-Bold",t["MS-Mincho-BoldItalic"]="MS Mincho-BoldItalic",t["MS-Mincho-Italic"]="MS Mincho-Italic",t["MS-PGothic"]="MS PGothic",t["MS-PGothic-Bold"]="MS PGothic-Bold",t["MS-PGothic-BoldItalic"]="MS PGothic-BoldItalic",t["MS-PGothic-Italic"]="MS PGothic-Italic",t["MS-PMincho"]="MS PMincho",t["MS-PMincho-Bold"]="MS PMincho-Bold",t["MS-PMincho-BoldItalic"]="MS PMincho-BoldItalic",t["MS-PMincho-Italic"]="MS PMincho-Italic",t.NuptialScript="Times-Italic",t.SegoeUISymbol="Helvetica"})),_u=Th((function(t){t["Adobe Jenson"]=!0,t["Adobe Text"]=!0,t.Albertus=!0,t.Aldus=!0,t.Alexandria=!0,t.Algerian=!0,t["American Typewriter"]=!0,t.Antiqua=!0,t.Apex=!0,t.Arno=!0,t.Aster=!0,t.Aurora=!0,t.Baskerville=!0,t.Bell=!0,t.Bembo=!0,t["Bembo Schoolbook"]=!0,t.Benguiat=!0,t["Berkeley Old Style"]=!0,t["Bernhard Modern"]=!0,t["Berthold City"]=!0,t.Bodoni=!0,t["Bauer Bodoni"]=!0,t["Book Antiqua"]=!0,t.Bookman=!0,t["Bordeaux Roman"]=!0,t["Californian FB"]=!0,t.Calisto=!0,t.Calvert=!0,t.Capitals=!0,t.Cambria=!0,t.Cartier=!0,t.Caslon=!0,t.Catull=!0,t.Centaur=!0,t["Century Old Style"]=!0,t["Century Schoolbook"]=!0,t.Chaparral=!0,t["Charis SIL"]=!0,t.Cheltenham=!0,t["Cholla Slab"]=!0,t.Clarendon=!0,t.Clearface=!0,t.Cochin=!0,t.Colonna=!0,t["Computer Modern"]=!0,t["Concrete Roman"]=!0,t.Constantia=!0,t["Cooper Black"]=!0,t.Corona=!0,t.Ecotype=!0,t.Egyptienne=!0,t.Elephant=!0,t.Excelsior=!0,t.Fairfield=!0,t["FF Scala"]=!0,t.Folkard=!0,t.Footlight=!0,t.FreeSerif=!0,t["Friz Quadrata"]=!0,t.Garamond=!0,t.Gentium=!0,t.Georgia=!0,t.Gloucester=!0,t["Goudy Old Style"]=!0,t["Goudy Schoolbook"]=!0,t["Goudy Pro Font"]=!0,t.Granjon=!0,t["Guardian Egyptian"]=!0,t.Heather=!0,t.Hercules=!0,t["High Tower Text"]=!0,t.Hiroshige=!0,t["Hoefler Text"]=!0,t["Humana Serif"]=!0,t.Imprint=!0,t["Ionic No. 5"]=!0,t.Janson=!0,t.Joanna=!0,t.Korinna=!0,t.Lexicon=!0,t.LiberationSerif=!0,t["Liberation Serif"]=!0,t["Linux Libertine"]=!0,t.Literaturnaya=!0,t.Lucida=!0,t["Lucida Bright"]=!0,t.Melior=!0,t.Memphis=!0,t.Miller=!0,t.Minion=!0,t.Modern=!0,t["Mona Lisa"]=!0,t["Mrs Eaves"]=!0,t["MS Serif"]=!0,t["Museo Slab"]=!0,t["New York"]=!0,t["Nimbus Roman"]=!0,t["NPS Rawlinson Roadway"]=!0,t.NuptialScript=!0,t.Palatino=!0,t.Perpetua=!0,t.Plantin=!0,t["Plantin Schoolbook"]=!0,t.Playbill=!0,t["Poor Richard"]=!0,t["Rawlinson Roadway"]=!0,t.Renault=!0,t.Requiem=!0,t.Rockwell=!0,t.Roman=!0,t["Rotis Serif"]=!0,t.Sabon=!0,t.Scala=!0,t.Seagull=!0,t.Sistina=!0,t.Souvenir=!0,t.STIX=!0,t["Stone Informal"]=!0,t["Stone Serif"]=!0,t.Sylfaen=!0,t.Times=!0,t.Trajan=!0,t["Trinité"]=!0,t["Trump Mediaeval"]=!0,t.Utopia=!0,t["Vale Type"]=!0,t["Bitstream Vera"]=!0,t["Vera Serif"]=!0,t.Versailles=!0,t.Wanted=!0,t.Weiss=!0,t["Wide Latin"]=!0,t.Windsor=!0,t.XITS=!0})),Yu=Th((function(t){t.Dingbats=!0,t.Symbol=!0,t.ZapfDingbats=!0,t.Wingdings=!0,t["Wingdings-Bold"]=!0,t["Wingdings-Regular"]=!0})),Tu=Th((function(t){t[2]=10,t[3]=32,t[4]=33,t[5]=34,t[6]=35,t[7]=36,t[8]=37,t[9]=38,t[10]=39,t[11]=40,t[12]=41,t[13]=42,t[14]=43,t[15]=44,t[16]=45,t[17]=46,t[18]=47,t[19]=48,t[20]=49,t[21]=50,t[22]=51,t[23]=52,t[24]=53,t[25]=54,t[26]=55,t[27]=56,t[28]=57,t[29]=58,t[30]=894,t[31]=60,t[32]=61,t[33]=62,t[34]=63,t[35]=64,t[36]=65,t[37]=66,t[38]=67,t[39]=68,t[40]=69,t[41]=70,t[42]=71,t[43]=72,t[44]=73,t[45]=74,t[46]=75,t[47]=76,t[48]=77,t[49]=78,t[50]=79,t[51]=80,t[52]=81,t[53]=82,t[54]=83,t[55]=84,t[56]=85,t[57]=86,t[58]=87,t[59]=88,t[60]=89,t[61]=90,t[62]=91,t[63]=92,t[64]=93,t[65]=94,t[66]=95,t[67]=96,t[68]=97,t[69]=98,t[70]=99,t[71]=100,t[72]=101,t[73]=102,t[74]=103,t[75]=104,t[76]=105,t[77]=106,t[78]=107,t[79]=108,t[80]=109,t[81]=110,t[82]=111,t[83]=112,t[84]=113,t[85]=114,t[86]=115,t[87]=116,t[88]=117,t[89]=118,t[90]=119,t[91]=120,t[92]=121,t[93]=122,t[94]=123,t[95]=124,t[96]=125,t[97]=126,t[98]=196,t[99]=197,t[100]=199,t[101]=201,t[102]=209,t[103]=214,t[104]=220,t[105]=225,t[106]=224,t[107]=226,t[108]=228,t[109]=227,t[110]=229,t[111]=231,t[112]=233,t[113]=232,t[114]=234,t[115]=235,t[116]=237,t[117]=236,t[118]=238,t[119]=239,t[120]=241,t[121]=243,t[122]=242,t[123]=244,t[124]=246,t[125]=245,t[126]=250,t[127]=249,t[128]=251,t[129]=252,t[130]=8224,t[131]=176,t[132]=162,t[133]=163,t[134]=167,t[135]=8226,t[136]=182,t[137]=223,t[138]=174,t[139]=169,t[140]=8482,t[141]=180,t[142]=168,t[143]=8800,t[144]=198,t[145]=216,t[146]=8734,t[147]=177,t[148]=8804,t[149]=8805,t[150]=165,t[151]=181,t[152]=8706,t[153]=8721,t[154]=8719,t[156]=8747,t[157]=170,t[158]=186,t[159]=8486,t[160]=230,t[161]=248,t[162]=191,t[163]=161,t[164]=172,t[165]=8730,t[166]=402,t[167]=8776,t[168]=8710,t[169]=171,t[170]=187,t[171]=8230,t[179]=8220,t[180]=8221,t[181]=8216,t[182]=8217,t[200]=193,t[203]=205,t[207]=211,t[210]=218,t[223]=711,t[224]=321,t[225]=322,t[226]=352,t[227]=353,t[228]=381,t[229]=382,t[233]=221,t[234]=253,t[252]=263,t[253]=268,t[254]=269,t[258]=258,t[260]=260,t[261]=261,t[265]=280,t[266]=281,t[267]=282,t[268]=283,t[269]=313,t[275]=323,t[276]=324,t[278]=328,t[283]=344,t[284]=345,t[285]=346,t[286]=347,t[292]=367,t[295]=377,t[296]=378,t[298]=380,t[305]=963,t[306]=964,t[307]=966,t[308]=8215,t[309]=8252,t[310]=8319,t[311]=8359,t[312]=8592,t[313]=8593,t[337]=9552,t[493]=1039,t[494]=1040,t[672]=1488,t[673]=1489,t[674]=1490,t[675]=1491,t[676]=1492,t[677]=1493,t[678]=1494,t[679]=1495,t[680]=1496,t[681]=1497,t[682]=1498,t[683]=1499,t[684]=1500,t[685]=1501,t[686]=1502,t[687]=1503,t[688]=1504,t[689]=1505,t[690]=1506,t[691]=1507,t[692]=1508,t[693]=1509,t[694]=1510,t[695]=1511,t[696]=1512,t[697]=1513,t[698]=1514,t[705]=1524,t[706]=8362,t[710]=64288,t[711]=64298,t[759]=1617,t[761]=1776,t[763]=1778,t[775]=1652,t[777]=1764,t[778]=1780,t[779]=1781,t[780]=1782,t[782]=771,t[783]=64726,t[786]=8363,t[788]=8532,t[790]=768,t[791]=769,t[792]=768,t[795]=803,t[797]=64336,t[798]=64337,t[799]=64342,t[800]=64343,t[801]=64344,t[802]=64345,t[803]=64362,t[804]=64363,t[805]=64364,t[2424]=7821,t[2425]=7822,t[2426]=7823,t[2427]=7824,t[2428]=7825,t[2429]=7826,t[2430]=7827,t[2433]=7682,t[2678]=8045,t[2679]=8046,t[2830]=1552,t[2838]=686,t[2840]=751,t[2842]=753,t[2843]=754,t[2844]=755,t[2846]=757,t[2856]=767,t[2857]=848,t[2858]=849,t[2862]=853,t[2863]=854,t[2864]=855,t[2865]=861,t[2866]=862,t[2906]=7460,t[2908]=7462,t[2909]=7463,t[2910]=7464,t[2912]=7466,t[2913]=7467,t[2914]=7468,t[2916]=7470,t[2917]=7471,t[2918]=7472,t[2920]=7474,t[2921]=7475,t[2922]=7476,t[2924]=7478,t[2925]=7479,t[2926]=7480,t[2928]=7482,t[2929]=7483,t[2930]=7484,t[2932]=7486,t[2933]=7487,t[2934]=7488,t[2936]=7490,t[2937]=7491,t[2938]=7492,t[2940]=7494,t[2941]=7495,t[2942]=7496,t[2944]=7498,t[2946]=7500,t[2948]=7502,t[2950]=7504,t[2951]=7505,t[2952]=7506,t[2954]=7508,t[2955]=7509,t[2956]=7510,t[2958]=7512,t[2959]=7513,t[2960]=7514,t[2962]=7516,t[2963]=7517,t[2964]=7518,t[2966]=7520,t[2967]=7521,t[2968]=7522,t[2970]=7524,t[2971]=7525,t[2972]=7526,t[2974]=7528,t[2975]=7529,t[2976]=7530,t[2978]=1537,t[2979]=1538,t[2980]=1539,t[2982]=1549,t[2983]=1551,t[2984]=1552,t[2986]=1554,t[2987]=1555,t[2988]=1556,t[2990]=1623,t[2991]=1624,t[2995]=1775,t[2999]=1791,t[3002]=64290,t[3003]=64291,t[3004]=64292,t[3006]=64294,t[3007]=64295,t[3008]=64296,t[3011]=1900,t[3014]=8223,t[3015]=8244,t[3017]=7532,t[3018]=7533,t[3019]=7534,t[3075]=7590,t[3076]=7591,t[3079]=7594,t[3080]=7595,t[3083]=7598,t[3084]=7599,t[3087]=7602,t[3088]=7603,t[3091]=7606,t[3092]=7607,t[3095]=7610,t[3096]=7611,t[3099]=7614,t[3100]=7615,t[3103]=7618,t[3104]=7619,t[3107]=8337,t[3108]=8338,t[3116]=1884,t[3119]=1885,t[3120]=1885,t[3123]=1886,t[3124]=1886,t[3127]=1887,t[3128]=1887,t[3131]=1888,t[3132]=1888,t[3135]=1889,t[3136]=1889,t[3139]=1890,t[3140]=1890,t[3143]=1891,t[3144]=1891,t[3147]=1892,t[3148]=1892,t[3153]=580,t[3154]=581,t[3157]=584,t[3158]=585,t[3161]=588,t[3162]=589,t[3165]=891,t[3166]=892,t[3169]=1274,t[3170]=1275,t[3173]=1278,t[3174]=1279,t[3181]=7622,t[3182]=7623,t[3282]=11799,t[3316]=578,t[3379]=42785,t[3393]=1159,t[3416]=8377})),Pu=Th((function(t){t[227]=322,t[264]=261,t[291]=346})),Ku=Th((function(t){t[1]=32,t[4]=65,t[5]=192,t[6]=193,t[9]=196,t[17]=66,t[18]=67,t[21]=268,t[24]=68,t[28]=69,t[29]=200,t[30]=201,t[32]=282,t[38]=70,t[39]=71,t[44]=72,t[47]=73,t[48]=204,t[49]=205,t[58]=74,t[60]=75,t[62]=76,t[68]=77,t[69]=78,t[75]=79,t[76]=210,t[80]=214,t[87]=80,t[89]=81,t[90]=82,t[92]=344,t[94]=83,t[97]=352,t[100]=84,t[104]=85,t[109]=220,t[115]=86,t[116]=87,t[121]=88,t[122]=89,t[124]=221,t[127]=90,t[129]=381,t[258]=97,t[259]=224,t[260]=225,t[263]=228,t[268]=261,t[271]=98,t[272]=99,t[273]=263,t[275]=269,t[282]=100,t[286]=101,t[287]=232,t[288]=233,t[290]=283,t[295]=281,t[296]=102,t[336]=103,t[346]=104,t[349]=105,t[350]=236,t[351]=237,t[361]=106,t[364]=107,t[367]=108,t[371]=322,t[373]=109,t[374]=110,t[381]=111,t[382]=242,t[383]=243,t[386]=246,t[393]=112,t[395]=113,t[396]=114,t[398]=345,t[400]=115,t[401]=347,t[403]=353,t[410]=116,t[437]=117,t[442]=252,t[448]=118,t[449]=119,t[454]=120,t[455]=121,t[457]=253,t[460]=122,t[462]=382,t[463]=380,t[853]=44,t[855]=58,t[856]=46,t[876]=47,t[878]=45,t[882]=45,t[894]=40,t[895]=41,t[896]=91,t[897]=93,t[923]=64,t[1004]=48,t[1005]=49,t[1006]=50,t[1007]=51,t[1008]=52,t[1009]=53,t[1010]=54,t[1011]=55,t[1012]=56,t[1013]=57,t[1081]=37,t[1085]=43,t[1086]=45}));function qu(t){const e=Gu(t);return Uu()[e]}function Ou(t){const e=Gu(t);return!!(Uu()[e]||Ju()[e]||_u()[e]||Yu()[e])}class Wu{constructor(t=[]){this._map=t}get length(){return this._map.length}forEach(t){for(const e in this._map)t(e,this._map[e].charCodeAt(0))}has(t){return void 0!==this._map[t]}get(t){return this._map[t]}charCodeOf(t){const e=this._map;if(e.length<=65536)return e.indexOf(t);for(const A in e)if(e[A]===t)return 0|A;return-1}amend(t){for(const e in t)this._map[e]=t[e]}}class ju{constructor(t,e){this.firstChar=t,this.lastChar=e}get length(){return this.lastChar+1-this.firstChar}forEach(t){for(let e=this.firstChar,A=this.lastChar;e<=A;e++)t(e,e)}has(t){return this.firstChar<=t&&t<=this.lastChar}get(t){if(this.firstChar<=t&&t<=this.lastChar)return String.fromCharCode(t)}charCodeOf(t){return Number.isInteger(t)&&t>=this.firstChar&&t<=this.lastChar?t:-1}amend(t){Xc("Should not call amend()")}}class Vu{constructor(t,e){this.properties=e;const A=new ru(t,e,Ru);this.cff=A.parse(),this.cff.duplicateFirstGlyph();const i=new mu(this.cff);this.seacs=this.cff.seacs;try{this.data=i.compile()}catch{Zc("Failed to compile font "+e.loadedName),this.data=t}this._createBuiltInEncoding()}get numGlyphs(){return this.cff.charStrings.count}getCharset(){return this.cff.charset.charset}getGlyphMapping(){const t=this.cff,e=this.properties,{cidToGidMap:A,cMap:i}=e,s=t.charset.charset;let a,n;if(e.composite){let e,r;if(A?.length>0){e=Object.create(null);for(let t=0,i=A.length;t=0){const i=A[e];i&&(s[t]=i)}}s.length>0&&(this.properties.builtInEncoding=s)}}function Zu(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function Xu(t,e){return t[e]<<8|t[e+1]}function zu(t,e){return(t[e]<<24|t[e+1]<<16)>>16}function $u(t,e){return t[e]<<24>>24}function tC(t,e){return zu(t,e)/16384}function eC(t){const e=t.length;let A=32768;return e<1240?A=107:e<33900&&(A=1131),A}function AC(t,e,A){const i=1===Xu(t,e+2)?Zu(t,e+8):Zu(t,e+16),s=Xu(t,e+i);let a,n,r;if(4===s){Xu(t,e+i+2);const A=Xu(t,e+i+6)>>1;for(n=e+i+14,a=[],r=0;r>1;A0;)I.push({flags:o})}for(A=0;A>1,m=!0;break;case 4:g+=r.pop(),s(o,g),m=!0;break;case 5:for(;r.length>0;)o+=r.shift(),g+=r.shift(),a(o,g);break;case 6:for(;r.length>0&&(o+=r.shift(),a(o,g),0!==r.length);)g+=r.shift(),a(o,g);break;case 7:for(;r.length>0&&(g+=r.shift(),a(o,g),0!==r.length);)o+=r.shift(),a(o,g);break;case 8:for(;r.length>0;)I=o+r.shift(),u=g+r.shift(),d=I+r.shift(),C=u+r.shift(),o=d+r.shift(),g=C+r.shift(),n(I,u,d,C,o,g);break;case 10:if(f=r.pop(),p=null,A.isCFFCIDFont){const t=A.fdSelect.getFDIndex(i);if(t>=0&&tMath.abs(g-e)?o+=r.shift():g+=r.shift(),n(I,u,d,C,o,g);break;default:throw new rh(`unknown operator: 12 ${y}`)}break;case 14:if(r.length>=4){const t=r.pop(),i=r.pop();g=r.pop(),o=r.pop(),e.add(5),e.add(8,[o,g]);let s=sC(A.cmap,String.fromCharCode(A.glyphNameMap[$d[t]]));nC(A.glyphs[s.glyphId],e,A,s.glyphId),e.add(4),s=sC(A.cmap,String.fromCharCode(A.glyphNameMap[$d[i]])),nC(A.glyphs[s.glyphId],e,A,s.glyphId)}return;case 19:case 20:c+=r.length>>1,l+=c+7>>3,m=!0;break;case 21:g+=r.pop(),o+=r.pop(),s(o,g),m=!0;break;case 22:o+=r.pop(),s(o,g),m=!0;break;case 24:for(;r.length>2;)I=o+r.shift(),u=g+r.shift(),d=I+r.shift(),C=u+r.shift(),o=d+r.shift(),g=C+r.shift(),n(I,u,d,C,o,g);o+=r.shift(),g+=r.shift(),a(o,g);break;case 25:for(;r.length>6;)o+=r.shift(),g+=r.shift(),a(o,g);I=o+r.shift(),u=g+r.shift(),d=I+r.shift(),C=u+r.shift(),o=d+r.shift(),g=C+r.shift(),n(I,u,d,C,o,g);break;case 26:for(r.length%2&&(o+=r.shift());r.length>0;)I=o,u=g+r.shift(),d=I+r.shift(),C=u+r.shift(),o=d,g=C+r.shift(),n(I,u,d,C,o,g);break;case 27:for(r.length%2&&(g+=r.shift());r.length>0;)I=o+r.shift(),u=g,d=I+r.shift(),C=u+r.shift(),o=d+r.shift(),g=C,n(I,u,d,C,o,g);break;case 28:r.push((h[l]<<24|h[l+1]<<16)>>16),l+=2;break;case 29:f=r.pop()+A.gsubrsBias,p=A.gsubrs[f],p&&t(p);break;case 30:for(;r.length>0&&(I=o,u=g+r.shift(),d=I+r.shift(),C=u+r.shift(),o=d+r.shift(),g=C+(1===r.length?r.shift():0),n(I,u,d,C,o,g),0!==r.length);)I=o+r.shift(),u=g,d=I+r.shift(),C=u+r.shift(),g=C+r.shift(),o=d+(1===r.length?r.shift():0),n(I,u,d,C,o,g);break;case 31:for(;r.length>0&&(I=o+r.shift(),u=g,d=I+r.shift(),C=u+r.shift(),g=C+r.shift(),o=d+(1===r.length?r.shift():0),n(I,u,d,C,o,g),0!==r.length);)I=o,u=g+r.shift(),d=I+r.shift(),C=u+r.shift(),o=d+r.shift(),g=C+(1===r.length?r.shift():0),n(I,u,d,C,o,g);break;default:if(y<32)throw new rh(`unknown operator: ${y}`);y<247?r.push(y-139):y<251?r.push(256*(y-247)+h[l++]+108):y<255?r.push(256*-(y-251)-h[l++]-108):(r.push((h[l]<<24|h[l+1]<<16|h[l+2]<<8|h[l+3])/65536),l+=4)}m&&(r.length=0)}}(t)}const rC=[];class oC{cmds=[];add(t,e){if(e)if(Al(e,null))this.cmds.push(t,...e);else{Zc(`Commands.add - "${t}" has at least one non-number arg: "${e}".`);const A=e.map((t=>"number"==typeof t?t:0));this.cmds.push(t,...A)}else this.cmds.push(t)}}class gC{constructor(t){this.constructor===gC&&Xc("Cannot initialize CompiledFont."),this.fontMatrix=t,this.compiledGlyphs=Object.create(null),this.compiledCharCodeToGlyphId=Object.create(null)}getPathJs(t){const{charCode:e,glyphId:A}=sC(this.cmap,t);let i,s=this.compiledGlyphs[A];if(!s){try{s=this.compileGlyph(this.glyphs[A],A)}catch(t){s=rC,i=t}this.compiledGlyphs[A]=s}if(this.compiledCharCodeToGlyphId[e]??=A,i)throw i;return s}compileGlyph(t,e){if(!t||0===t.length||14===t[0])return rC;let A=this.fontMatrix;if(this.isCFFCIDFont){const t=this.fdSelect.getFDIndex(e);t>=0&&t2*Xu(t,e));const a=[];let n=s(e,0);for(let A=i;At+(e.getSize()+3&-4)),0)}write(){const t=this.getSize(),e=new DataView(new ArrayBuffer(t)),A=t>131070,i=A?4:2,s=new DataView(new ArrayBuffer((this.glyphs.length+1)*i));A?s.setUint32(0,0):s.setUint16(0,0);let a=0,n=0;for(const t of this.glyphs)a+=t.write(a,e),a=a+3&-4,n+=i,A?s.setUint32(n,a):s.setUint16(n,a>>1);return{isLocationLong:A,loca:new Uint8Array(s.buffer),glyf:new Uint8Array(e.buffer)}}scale(t){for(let e=0,A=this.glyphs.length;et+e.getSize()),0);return this.header.getSize()+t}write(t,e){if(!this.header)return 0;const A=t;if(t+=this.header.write(t,e),this.simple)t+=this.simple.write(t,e);else for(const A of this.composites)t+=A.write(t,e);return t-A}scale(t){if(!this.header)return;const e=(this.header.xMin+this.header.xMax)/2;if(this.header.scale(e,t),this.simple)this.simple.scale(e,t);else for(const A of this.composites)A.scale(e,t)}}class BC{constructor({numberOfContours:t,xMin:e,yMin:A,xMax:i,yMax:s}){this.numberOfContours=t,this.xMin=e,this.yMin=A,this.xMax=i,this.yMax=s}static parse(t,e){return[10,new BC({numberOfContours:e.getInt16(t),xMin:e.getInt16(t+2),yMin:e.getInt16(t+4),xMax:e.getInt16(t+6),yMax:e.getInt16(t+8)})]}getSize(){return 10}write(t,e){return e.setInt16(t,this.numberOfContours),e.setInt16(t+2,this.xMin),e.setInt16(t+4,this.yMin),e.setInt16(t+6,this.xMax),e.setInt16(t+8,this.yMax),10}scale(t,e){this.xMin=Math.round(t+(this.xMin-t)*e),this.xMax=Math.round(t+(this.xMax-t)*e)}}class QC{constructor({flags:t,xCoordinates:e,yCoordinates:A}){this.xCoordinates=e,this.yCoordinates=A,this.flags=t}}class EC{constructor({contours:t,instructions:e}){this.contours=t,this.instructions=e}static parse(t,e,A){const i=[];for(let s=0;s255?t+=2:r>0&&(t+=1),e=a,r=Math.abs(n-A),r>255?t+=2:r>0&&(t+=1),A=n}}return t}write(t,e){const A=t,i=[],s=[],a=[];let n=0,r=0;for(const A of this.contours){for(let t=0,e=A.xCoordinates.length;t=0?18:2,i.push(t)):i.push(g)}n=o;const c=A.yCoordinates[t];if(g=c-r,0===g)e|=32,s.push(0);else{const t=Math.abs(g);t<=255?(e|=g>=0?36:4,s.push(t)):s.push(g)}r=c,a.push(e)}e.setUint16(t,i.length-1),t+=2}e.setUint16(t,this.instructions.length),t+=2,this.instructions.length&&(new Uint8Array(e.buffer,0,e.buffer.byteLength).set(this.instructions,t),t+=this.instructions.length);for(const A of a)e.setUint8(t++,A);for(let A=0,s=i.length;A=-128&&this.argument1<=127&&this.argument2>=-128&&this.argument2<=127||(t+=2):this.argument1>=0&&this.argument1<=255&&this.argument2>=0&&this.argument2<=255||(t+=2),t}write(t,e){const A=t;return 2&this.flags?this.argument1>=-128&&this.argument1<=127&&this.argument2>=-128&&this.argument2<=127||(this.flags|=1):this.argument1>=0&&this.argument1<=255&&this.argument2>=0&&this.argument2<=255||(this.flags|=1),e.setUint16(t,this.flags),e.setUint16(t+2,this.glyphIndex),t+=4,1&this.flags?(2&this.flags?(e.setInt16(t,this.argument1),e.setInt16(t+2,this.argument2)):(e.setUint16(t,this.argument1),e.setUint16(t+2,this.argument2)),t+=4):(e.setUint8(t,this.argument1),e.setUint8(t+1,this.argument2),t+=2),256&this.flags&&(e.setUint16(t,this.instructions.length),t+=2,this.instructions.length&&(new Uint8Array(e.buffer,0,e.buffer.byteLength).set(this.instructions,t),t+=this.instructions.length)),t-A}scale(t,e){}}function pC(t,e,A){t[e]=A>>8&255,t[e+1]=255&A}function mC(t,e,A){t[e]=A>>24&255,t[e+1]=A>>16&255,t[e+2]=A>>8&255,t[e+3]=255&A}function yC(t,e,A){if(A instanceof Uint8Array)t.set(A,e);else if("string"==typeof A)for(let i=0,s=A.length;iA;)A<<=1,i++;const s=A*e;return{range:s,entry:i,rangeShift:e*t-s}}toArray(){let t=this.sfnt;const e=this.tables,A=Object.keys(e);A.sort();const i=A.length;let s,a,n,r,o,g=12+16*i;const c=[g];for(s=0;s>>0,c.push(g);const h=new Uint8Array(g);for(s=0;s>>0;mC(h,g+4,t),mC(h,g+8,c[s]),mC(h,g+12,e[o].length),g+=16}return h}addTable(t,e){if(t in this.tables)throw new Error("Table "+t+" already exists");this.tables[t]=e}}const wC=[4],DC=[5],kC=[6],SC=[7],xC=[8],FC=[12,35],RC=[14],vC=[21],NC=[22],MC=[30],GC=[31];class LC{constructor(){this.width=0,this.lsb=0,this.flexing=!1,this.output=[],this.stack=[]}convert(t,e,A){const i=t.length;let s,a,n,r=!1;for(let o=0;oi)return!0;const s=i-t;for(let t=s;t>8&255,255&e):(e=65536*e|0,this.output.push(255,e>>24&255,e>>16&255,e>>8&255,255&e))}return this.output.push(...e),A?this.stack.splice(s,t):this.stack.length=0,!1}}function UC(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function HC(t,e,A){if(A>=t.length)return new Uint8Array(0);let i,s,a=0|e;for(i=0;i>8,a=52845*(e+a)+22719&65535}return r}function JC(t){return 47===t||91===t||93===t||123===t||125===t||40===t||41===t}class _C{constructor(t,e,A){if(e){const e=t.getBytes(),A=!((UC(e[0])||el(e[0]))&&UC(e[1])&&UC(e[2])&&UC(e[3])&&UC(e[4])&&UC(e[5])&&UC(e[6])&&UC(e[7]));t=new bl(A?HC(e,55665,4):function(t){let e=55665;const A=t.length,i=new Uint8Array(A>>>1);let s,a;for(s=0,a=0;s>8,e=52845*(t+e)+22719&65535}}return i.slice(4,a)}(e))}this.seacAnalysisEnabled=!!A,this.stream=t,this.nextChar()}readNumberArray(){this.getToken();const t=[];for(;;){const e=this.getToken();if(null===e||"]"===e||"}"===e)break;t.push(parseFloat(e||0))}return t}readNumber(){const t=this.getToken();return parseFloat(t||0)}readInt(){const t=this.getToken();return 0|parseInt(t||0,10)}readBoolean(){return"true"===this.getToken()?1:0}nextChar(){return this.currentChar=this.stream.getByte()}prevChar(){return this.stream.skip(-2),this.currentChar=this.stream.getByte()}getToken(){let t=!1,e=this.currentChar;for(;;){if(-1===e)return null;if(t)10!==e&&13!==e||(t=!1);else if(37===e)t=!0;else if(!el(e))break;e=this.nextChar()}if(JC(e))return this.nextChar(),String.fromCharCode(e);let A="";do{A+=String.fromCharCode(e),e=this.nextChar()}while(e>=0&&!el(e)&&!JC(e));return A}readCharStrings(t,e){return-1===e?t:HC(t,4330,e)}extractFontProgram(t){const e=this.stream,A=[],i=[],s=Object.create(null);s.lenIV=4;const a={subrs:[],charstrings:[],properties:{privateData:s}};let n,r,o,g;for(;null!==(n=this.getToken());)if("/"===n)switch(n=this.getToken(),n){case"CharStrings":for(this.getToken(),this.getToken(),this.getToken(),this.getToken();n=this.getToken(),null!==n&&"end"!==n;){if("/"!==n)continue;const t=this.getToken();r=this.readInt(),this.getToken(),o=r>0?e.getBytes(r):new Uint8Array(0),g=a.properties.privateData.lenIV;const A=this.readCharStrings(o,g);this.nextChar(),n=this.getToken(),"noaccess"===n?this.getToken():"/"===n&&this.prevChar(),i.push({glyph:t,encoded:A})}break;case"Subrs":for(this.readInt(),this.getToken();"dup"===this.getToken();){const t=this.readInt();r=this.readInt(),this.getToken(),o=r>0?e.getBytes(r):new Uint8Array(0),g=a.properties.privateData.lenIV;const i=this.readCharStrings(o,g);this.nextChar(),n=this.getToken(),"noaccess"===n&&this.getToken(),A[t]=i}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":const t=this.readNumberArray();t.length>0&&t.length;break;case"StemSnapH":case"StemSnapV":a.properties.privateData[n]=this.readNumberArray();break;case"StdHW":case"StdVW":a.properties.privateData[n]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":a.properties.privateData[n]=this.readNumber();break;case"ExpansionFactor":a.properties.privateData[n]=this.readNumber()||.06;break;case"ForceBold":a.properties.privateData[n]=this.readBoolean()}for(const{encoded:e,glyph:s}of i){const i=new LC,n=i.convert(e,A,this.seacAnalysisEnabled);let r=i.output;n&&(r=[14]);const o={glyphName:s,charstring:r,width:i.width,lsb:i.lsb,seac:i.seac};if(".notdef"===s?a.charstrings.unshift(o):a.charstrings.push(o),t.builtInEncoding){const e=t.builtInEncoding.indexOf(s);e>-1&&void 0===t.widths[e]&&e>=t.firstChar&&e<=t.lastChar&&(t.widths[e]=i.width)}}return a}extractFontHeader(t){let e;for(;null!==(e=this.getToken());)if("/"===e)switch(e=this.getToken(),e){case"FontMatrix":const A=this.readNumberArray();t.fontMatrix=A;break;case"Encoding":const i=this.getToken();let s;if(/^\d+$/.test(i)){s=[];const t=0|parseInt(i,10);this.getToken();for(let A=0;A=s){for(n+=A;n=0&&(i[t]=s)}return Mu(t,i,A)}hasGlyphId(t){return!(t<0||t>=this.numGlyphs)&&(0===t||this.charstrings[t-1].charstring.length>0)}getSeacs(t){const e=[];for(let A=0,i=t.length;A0;t--)e[t]-=e[t-1];I.setByName(t,e)}a.topDict.privateDict=I;const u=new hu;for(c=0,h=i.length;c0&&t.toUnicode.amend(e)}class VC{constructor(t,e,A,i,s,a,n,r,o){this.originalCharCode=t,this.fontChar=e,this.unicode=A,this.accent=i,this.width=s,this.vmetric=a,this.operatorListId=n,this.isSpace=r,this.isInFont=o}get category(){return th(this,"category",function(t){const e=Fu.get(t);if(e)return e;const A=t.match(xu),i={isWhitespace:!!A?.[1],isZeroWidthDiacritic:!!A?.[2],isInvisibleFormatMark:!!A?.[3]};return Fu.set(t,i),i}(this.unicode),!0)}}function ZC(t,e){return(t<<8)+e}function XC(t,e,A){t[e+1]=A,t[e]=A>>>8}function zC(t,e){const A=(t<<8)+e;return 32768&A?A-65536:A}function $C(t){return String.fromCharCode(t>>8&255,255&t)}function tB(t){return t>32767?t=32767:t<-32768&&(t=-32768),String.fromCharCode(t>>8&255,255&t)}function eB(t){return"ttcf"===gh(t.peekBytes(4))}function AB(t,e){for(const A in e)t[+A]=e[A]}function iB(t,e,A){const i=[];let s;for(let A=0,a=t.length;Ac){if(o++,o>=PC.length){Zc("Ran out of space in font private use area.");break}g=PC[o][0],c=PC[o][1]}const d=g++;0===I&&(I=A);let u=i.get(l);"string"==typeof u&&(u=u.codePointAt(0)),!u||(h=u,PC[0][0]<=h&&h<=PC[0][1]||PC[1][0]<=h&&h<=PC[1][1])||r.has(I)||(a.set(u,I),r.add(I)),s[d]=I,n[l]=d}var h;return{toFontChar:n,charCodeToGlyphId:s,toUnicodeExtraMap:a,nextAvailableFontCharCode:g}}function oB(t,e,A){const i=function(t,e,A){const i=[];for(const e in t)t[e]>=A||i.push({fontCharCode:0|e,glyphId:t[e]});if(e)for(const[t,s]of e)s>=A||i.push({fontCharCode:t,glyphId:s});0===i.length&&i.push({fontCharCode:0,glyphId:0}),i.sort((function(t,e){return t.fontCharCode-e.fontCharCode}));const s=[],a=i.length;for(let t=0;t65535?2:1;let a,n,r,o,g="\0\0"+$C(s)+"\0\0"+hh(4+8*s);for(a=i.length-1;a>=0&&!(i[a][0]<=65535);--a);const c=a+1;i[a][0]<65535&&65535===i[a][1]&&(i[a][1]=65534);const h=i[a][1]<65535?1:0,l=c+h,I=bC.getSearchParams(l,2);let d,u,C,B,Q="",E="",f="",p="",m="",y=0;for(a=0,n=c;a0&&(E+="ÿÿ",Q+="ÿÿ",f+="\0",p+="\0\0");const b="\0\0"+$C(2*l)+$C(I.range)+$C(I.entry)+$C(I.rangeShift)+E+"\0\0"+Q+f+p+m;let w="",D="";if(s>1){for(g+="\0\0\n"+hh(4+8*s+4+b.length),w="",a=0,n=i.length;at||!r)&&(r=t),o 123 are reserved for internal usage");n|=1<65535&&(o=65535)}else r=0,o=255;const c=t.bbox||[0,0,0,0],h=A.unitsPerEm||(t.fontMatrix?1/Math.max(...t.fontMatrix.slice(0,4).map(Math.abs)):1e3),l=t.ascentScaled?1:h/KC,I=A.ascent||Math.round(l*(t.ascent||c[3]));let d=A.descent||Math.round(l*(t.descent||c[1]));d>0&&t.descent>0&&c[1]<0&&(d=-d);const u=A.yMax||I,C=-A.yMin||-d;return"\0$ô\0\0\0Š»\0\0\0ŒŠ»\0\0ß\x001\0\0\0\0"+String.fromCharCode(t.fixedPitch?9:0)+"\0\0\0\0\0\0"+hh(i)+hh(s)+hh(a)+hh(n)+"*21*"+$C(t.italicAngle?1:0)+$C(r||t.firstChar)+$C(o||t.lastChar)+$C(I)+$C(d)+"\0d"+$C(u)+$C(C)+"\0\0\0\0\0\0\0\0"+$C(t.xHeight)+$C(t.capHeight)+$C(0)+$C(r||t.firstChar)+"\0"}function cB(t){return"\0\0\0"+hh(Math.floor(65536*t.italicAngle))+"\0\0\0\0"+hh(t.fixedPitch?1:0)+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}function hB(t){return t.replaceAll(/[^\x21-\x7E]|[[\](){}<>/%]/g,"").slice(0,63)}function lB(t,e){e||(e=[[],[]]);const A=[e[0][0]||"Original licence",e[0][1]||t,e[0][2]||"Unknown",e[0][3]||"uniqueID",e[0][4]||t,e[0][5]||"Version 0.11",e[0][6]||hB(t),e[0][7]||"Unknown",e[0][8]||"Unknown",e[0][9]||"Unknown"],i=[];let s,a,n,r,o;for(s=0,a=A.length;s=1&&e[3]>=1&&e[3]<=4}(t)?i?(s="CIDFontType0",a="CIDFontType0C"):(s="MMType1"===e?"MMType1":"Type1",a="Type1C"):(Zc("getFontFileType: Unable to detect correct font file Type/Subtype."),s=e,a=A),[s,a]}(e,A),s===this.type&&a===this.subtype||Vc(`Inconsistent font file Type/SubType, expected: ${this.type}/${this.subtype} but found: ${s}/${a}.`);try{switch(s){case"MMType1":Vc("MMType1 font ("+t+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";const i="Type1C"===a||"CIDFontType0C"===a?new Vu(e,A):new TC(t,e,A);WC(A),r=this.convert(t,i,A);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype",r=this.checkAndRepair(t,e,A),this.isOpenType&&(WC(A),s="OpenType");break;default:throw new rh(`Font ${s} is not supported`)}}catch(t){return Zc(t),void this.fallbackToSystemFont(A)}jC(A),this.data=r,this.type=s,this.subtype=a,this.fontMatrix=A.fontMatrix,this.widths=A.widths,this.defaultWidth=A.defaultWidth,this.toUnicode=A.toUnicode,this.seacMap=A.seacMap}get renderer(){return th(this,"renderer",lC.create(this,Ru))}exportData(t=!1){const e=t?[...qC,...OC]:qC,A=Object.create(null);let i,s;for(i of e)s=this[i],void 0!==s&&(A[i]=s);return A}fallbackToSystemFont(t){this.missingFile=!0;const{name:e,type:A}=this;let i=Gu(e);const s=Uu(),a=Ju(),n=!!s[i],r=!(!a[i]||!s[a[i]]);i=s[i]||a[i]||i;const o=dC()[i];o&&(isNaN(this.ascent)&&(this.ascent=o.ascent/KC),isNaN(this.descent)&&(this.descent=o.descent/KC),isNaN(this.capHeight)&&(this.capHeight=o.capHeight/KC)),this.bold=/bold/gi.test(i),this.italic=/oblique|italic/gi.test(i),this.black=/Black/g.test(e);const g=/Narrow/g.test(e);if(this.remeasure=(!n||g)&&Object.keys(this.widths).length>0,(n||r)&&"CIDFontType2"===A&&this.cidEncoding.startsWith("Identity-")){const A=t.cidToGidMap,i=[];if(AB(i,Tu()),/Arial-?Black/i.test(e)?AB(i,Pu()):/Calibri/i.test(e)&&AB(i,Ku()),A){for(const t in i){const e=i[t];void 0!==A[e]&&(i[+t]=A[e])}A.length!==this.toUnicode.length&&t.hasIncludedToUnicodeMap&&this.toUnicode instanceof ju&&this.toUnicode.forEach((function(t,e){const s=i[t];void 0===A[s]&&(i[+t]=e)}))}this.toUnicode instanceof ju||this.toUnicode.forEach((function(t,e){i[+t]=e})),this.toFontChar=i,this.toUnicode=new Wu(i)}else if(/Symbol/i.test(i))this.toFontChar=iB(eu,yu(),this.differences);else if(/Dingbats/i.test(i))this.toFontChar=iB(Au,bu(),this.differences);else if(n){const t=iB(this.defaultEncoding,yu(),this.differences);"CIDFontType2"!==A||this.cidEncoding.startsWith("Identity-")||this.toUnicode instanceof ju||this.toUnicode.forEach((function(e,A){t[+e]=A})),this.toFontChar=t}else{const t=yu(),A=[];this.toUnicode.forEach(((e,i)=>{if(!this.composite){const A=Du(this.differences[e]||this.defaultEncoding[e],t);-1!==A&&(i=A)}A[+e]=i})),this.composite&&this.toUnicode instanceof ju&&/Tahoma|Verdana/i.test(e)&&AB(A,Tu()),this.toFontChar=A}jC(t),this.loadedName=i.split("-",1)[0]}checkAndRepair(t,e,A){const i=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "];function s(t,e){const A=Object.create(null);A["OS/2"]=null,A.cmap=null,A.head=null,A.hhea=null,A.hmtx=null,A.maxp=null,A.name=null,A.post=null;for(let s=0;s>>0,i=t.getInt32()>>>0,s=t.getInt32()>>>0,a=t.pos;t.pos=t.start||0,t.skip(i);const n=t.getBytes(s);return t.pos=a,"head"===e&&(n[8]=n[9]=n[10]=n[11]=0,n[17]|=32),{tag:e,checksum:A,length:s,offset:i,data:n}}function n(t){return{version:t.getString(4),numTables:t.getUint16(),searchRange:t.getUint16(),entrySelector:t.getUint16(),rangeShift:t.getUint16()}}function r(t,e,A,i,s,a){const n={length:0,sizeOfInstructions:0};if(e<0||e>=t.length||A>t.length||A-e<=12)return n;const r=t.subarray(e,A),o=zC(r[2],r[3]),g=zC(r[4],r[5]),c=zC(r[6],r[7]),h=zC(r[8],r[9]);o>c&&(XC(r,2,c),XC(r,6,o)),g>h&&(XC(r,4,h),XC(r,8,g));const l=zC(r[0],r[1]);if(l<0)return l<-1||(i.set(r,s),n.length=r.length),n;let I,d=10,u=0;for(I=0;Ir.length?n:!a&&B>0?(i.set(r.subarray(0,C),s),i.set([0,0],s+C),i.set(r.subarray(Q,f),s+C+2),f-=B,r.length-f>3&&(f=f+3&-4),n.length=f,n):r.length-f>3?(f=f+3&-4,i.set(r.subarray(0,f),s),n.length=f,n):(i.set(r,s),n.length=r.length,n)}function o(t){const A=(e.start||0)+t.offset;e.pos=A;const i=[[],[]],s=[],a=t.length,n=A+a;if(0!==e.getUint16()||a<6)return[i,s];const r=e.getUint16(),o=e.getUint16();let g,c;for(g=0;gn)continue;e.pos=a;const r=t.name;if(t.encoding){let A="";for(let i=0,s=t.length;i0&&(o+=t-1)}}else(C||Q)&&(Zc("TT: nested FDEFs not allowed"),u=!0),C=!0,h=o,a=l.pop(),e.functionsDefined[a]={data:r,i:o};else if(!C&&!Q)if(a=l.at(-1),isNaN(a))Vc("TT: CALL empty stack (or invalid entry).");else if(e.functionsUsed[a]=!0,a in e.functionsStackDeltas){const t=l.length+e.functionsStackDeltas[a];if(t<0)return Zc("TT: CALL invalid functions stack delta."),void(e.hintsValid=!1);l.length=t}else if(a in e.functionsDefined&&!d.includes(a)){if(I.push({data:r,i:o,stackTop:l.length-1}),d.push(a),n=e.functionsDefined[a],!n)return Zc("TT: CALL non-existent function"),void(e.hintsValid=!1);r=n.data,o=n.i}if(!C&&!Q){let e=0;for(t<=142?e=g[t]:t>=192&&t<=223?e=-1:t>=224&&(e=-2),t>=113&&t<=117&&(i=l.pop(),isNaN(i)||(e=2*-i));e<0&&l.length>0;)l.pop(),e++;for(;e>0;)l.push(NaN),e--}}e.tooComplexToFollowFunctions=u;const E=[r];o>r.length&&E.push(new Uint8Array(o-r.length)),h>c&&(Zc("TT: complementing a missing function tail"),E.push(new Uint8Array([34,45]))),function(t,e){if(e.length>1){let A,i,s=0;for(A=0,i=e.length;A>>0,a=[];for(let e=0;e>>0);const n={ttcTag:e,majorVersion:A,minorVersion:i,numFonts:s,offsetTable:a};switch(A){case 1:return n;case 2:return n.dsigTag=t.getInt32()>>>0,n.dsigLength=t.getInt32()>>>0,n.dsigOffset=t.getInt32()>>>0,n}throw new rh(`Invalid TrueType Collection majorVersion: ${A}.`)}(t),a=e.split("+");let r;for(let g=0;g0||!(A.cMap instanceof vd));if("OTTO"===h.version&&!e||!l.head||!l.hhea||!l.maxp||!l.post)return d=new bl(l["CFF "].data),I=new Vu(d,A),WC(A),this.convert(t,I,A);delete l.glyf,delete l.loca,delete l.fpgm,delete l.prep,delete l["cvt "],this.isOpenType=!0}if(!l.maxp)throw new rh('Required "maxp" table is not found');e.pos=(e.start||0)+l.maxp.offset;let C=e.getInt32();const B=e.getUint16();if(65536!==C&&20480!==C){if(6===l.maxp.length)C=20480;else{if(!(l.maxp.length>=32))throw new rh('"maxp" table has a wrong version number');C=65536}!function(t,e,A){t[3]=255&A,t[2]=A>>>8,t[1]=A>>>16,t[0]=A>>>24}(l.maxp.data,0,C)}if(A.scaleFactors?.length===B&&u){const{scaleFactors:t}=A,e=ZC(l.head.data[50],l.head.data[51]),i=new uC({glyfTable:l.glyf.data,isGlyphLocationsLong:e,locaTable:l.loca.data,numGlyphs:B});i.scale(t);const{glyf:s,loca:a,isLocationLong:n}=i.write();l.glyf.data=s,l.loca.data=a,n!==!!e&&(l.head.data[50]=0,l.head.data[51]=n?1:0);const r=l.hmtx.data;for(let e=0;e>8&255,r[A+1]=255&i,XC(r,A+2,Math.round(t[e]*zC(r[A+2],r[A+3])))}}let Q=B+1,E=!0;Q>65535&&(E=!1,Q=B,Zc("Not enough space in glyfs to duplicate first glyph."));let f=0,p=0;C>=65536&&l.maxp.length>=32&&(e.pos+=8,e.getUint16()>2&&(l.maxp.data[14]=0,l.maxp.data[15]=2),e.pos+=4,f=e.getUint16(),e.pos+=4,p=e.getUint16()),l.maxp.data[4]=Q>>8,l.maxp.data[5]=255&Q;const m=function(t,e,A,i){const s={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};if(t&&c(t,s),e&&c(e,s),t&&function(t,e){if(!t.tooComplexToFollowFunctions)if(t.functionsDefined.length>e)Zc("TT: more functions defined than expected"),t.hintsValid=!1;else for(let A=0,i=t.functionsUsed.length;Ae)return Zc("TT: invalid function id: "+A),void(t.hintsValid=!1);if(t.functionsUsed[A]&&!t.functionsDefined[A])return Zc("TT: undefined function: "+A),void(t.hintsValid=!1)}}(s,i),A&&1&A.length){const t=new Uint8Array(A.length+1);t.set(A.data),A.data=t}return s.hintsValid}(l.fpgm,l.prep,l["cvt "],f);if(m||(delete l.fpgm,delete l.prep,delete l["cvt "]),function(t,e,A,i,s,a){if(!e)return void(A&&(A.data=null));t.pos=(t.start||0)+e.offset,t.pos+=4,t.pos+=2,t.pos+=2,t.pos+=2,t.pos+=2,t.pos+=2,t.pos+=2,t.pos+=2,t.pos+=2,t.pos+=2;const n=t.getUint16();t.pos+=8,t.pos+=2;let r=t.getUint16();0!==n&&(2&ZC(i.data[44],i.data[45])||(e.data[22]=0,e.data[23]=0)),r>s&&(Vc(`The numOfMetrics (${r}) should not be greater than the numGlyphs (${s}).`),r=s,e.data[34]=(65280&r)>>8,e.data[35]=255&r);const o=s-r-(A.length-4*r>>1);if(o>0){const t=new Uint8Array(A.length+2*o);t.set(A.data),a&&(t[A.length]=A.data[2],t[A.length+1]=A.data[3]),A.data=t}}(e,l.hhea,l.hmtx,l.head,Q,E),!l.head)throw new rh('Required "head" table is not found');!function(t,e,A){const i=t.data,s=function(t,e,A,i){return(t<<24)+(e<<16)+(A<<8)+i}(i[0],i[1],i[2],i[3]);s>>16!=1&&(Vc("Attempting to fix invalid version in head table: "+s),i[0]=0,i[1]=1,i[2]=0,i[3]=0);const a=ZC(i[50],i[51]);if(a<0||a>1){Vc("Attempting to fix invalid indexToLocFormat in head table: "+a);const t=e+1;if(A===t<<1)i[50]=0,i[51]=0;else{if(A!==t<<2)throw new rh("Could not fix indexToLocFormat: "+a);i[50]=0,i[51]=1}}}(l.head,B,u?l.loca.length:0);let y=Object.create(null);if(u){const t=ZC(l.head.data[50],l.head.data[51]),e=function(t,e,A,i,s,a,n){let o,g,c;i?(o=4,g=function(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]},c=function(t,e,A){t[e]=A>>>24&255,t[e+1]=A>>16&255,t[e+2]=A>>8&255,t[e+3]=255&A}):(o=2,g=function(t,e){return t[e]<<9|t[e+1]<<1},c=function(t,e,A){t[e]=A>>9&255,t[e+1]=A>>1&255});const h=a?A+1:A,l=o*(1+h),I=new Uint8Array(l);I.set(t.data.subarray(0,l)),t.data=I;const d=e.data,u=d.length,C=new Uint8Array(u);let B,Q;const E=[];for(B=0,Q=0;Bu&&(t=u),E.push({index:B,offset:t,endOffset:0})}for(E.sort(((t,e)=>t.offset-e.offset)),B=0;Bt.index-e.index)),B=0;Bn&&(n=t.sizeOfInstructions),m+=e,c(I,Q,m)}if(0===m){const t=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(B=0,Q=o;BA+m?e.data=C.subarray(0,A+m):(e.data=new Uint8Array(A+m),e.data.set(C.subarray(0,m))),e.data.set(C.subarray(0,A),m),c(t.data,I.length-o,m+A)}else e.data=C.subarray(0,m);return{missingGlyphs:p,maxSizeOfInstructions:n}}(l.loca,l.glyf,B,t,m,E,p);y=e.missingGlyphs,C>=65536&&l.maxp.length>=32&&(l.maxp.data[26]=e.maxSizeOfInstructions>>8,l.maxp.data[27]=255&e.maxSizeOfInstructions)}if(!l.hhea)throw new rh('Required "hhea" table is not found');0===l.hhea.data[10]&&0===l.hhea.data[11]&&(l.hhea.data[10]=255,l.hhea.data[11]=255);const b={unitsPerEm:ZC(l.head.data[18],l.head.data[19]),yMax:zC(l.head.data[42],l.head.data[43]),yMin:zC(l.head.data[38],l.head.data[39]),ascent:zC(l.hhea.data[4],l.hhea.data[5]),descent:zC(l.hhea.data[6],l.hhea.data[7]),lineGap:zC(l.hhea.data[8],l.hhea.data[9])};this.ascent=b.ascent/b.unitsPerEm,this.descent=b.descent/b.unitsPerEm,this.lineGap=b.lineGap/b.unitsPerEm,this.cssFontInfo?.lineHeight?(this.lineHeight=this.cssFontInfo.metrics.lineHeight,this.lineGap=this.cssFontInfo.metrics.lineGap):this.lineHeight=this.ascent-this.descent+this.lineGap,l.post&&function(t,A,i){const s=(e.start||0)+t.offset;e.pos=s;const a=s+t.length,n=e.getInt32();e.skip(28);let r,o,g=!0;switch(n){case 65536:r=vu;break;case 131072:const t=e.getUint16();if(t!==i){g=!1;break}const s=[];for(o=0;o=32768){g=!1;break}s.push(t)}if(!g)break;const c=[],h=[];for(;e.pos65535)throw new rh("Max size of CID is 65,535");let s=-1;e?s=i:void 0!==t[i]&&(s=t[i]),s>=0&&s>>0;let c=!1;if(r?.platformId!==s||r?.encodingId!==a){if(0!==s||0!==a&&1!==a&&3!==a)if(1===s&&0===a)c=!0;else if(3!==s||1!==a||!i&&r){if(A&&3===s&&0===a){c=!0;let A=!0;if(t>3;t.push(i),A=Math.max(i,A)}const i=[];for(let t=0;t<=A;t++)i.push({firstCode:e.getUint16(),entryCount:e.getUint16(),idDelta:zC(e.getByte(),e.getByte()),idRangePos:e.pos+e.getUint16()});for(let A=0;A<256;A++)if(0===t[A])e.pos=i[0].idRangePos+2*A,I=e.getUint16(),h.push({charCode:A,glyphId:I});else{const s=i[t[A]];for(l=0;l>1;e.skip(6);const A=[];let i;for(i=0;i>1)-(t-i),s.offsetIndex=n,r=Math.max(r,n+s.end-s.start+1)):s.offsetIndex=-1}const o=[];for(l=0;l>>0;for(l=0;l>>0,A=e.getInt32()>>>0;let i=e.getInt32()>>>0;for(let e=t;e<=A;e++)h.push({charCode:e,glyphId:i++})}}}h.sort((function(t,e){return t.charCode-e.charCode}));for(let t=1;t=61440&&e<=61695&&(e&=255),w[e]=t.glyphId}else for(const t of a)w[t.charCode]=t.glyphId;if(A.glyphNames&&(n.length||this.differences.length))for(let t=0;t<256;++t){if(!r&&void 0!==w[t])continue;const e=this.differences[t]||n[t];if(!e)continue;const i=A.glyphNames.indexOf(e);i>0&&D(i)&&(w[t]=i)}}0===w.length&&(w[0]=0);let k=Q-1;if(E||(k=0),!A.cssFontInfo){const t=rB(w,D,k,this.toUnicode);this.toFontChar=t.toFontChar,l.cmap={tag:"cmap",data:oB(t.charCodeToGlyphId,t.toUnicodeExtraMap,Q)},l["OS/2"]&&function(t,e){e.pos=(e.start||0)+t.offset;const A=e.getUint16();e.skip(60);const i=e.getUint16();return!(A<4&&768&i||e.getUint16()>e.getUint16()||(e.skip(6),0===e.getUint16()||(t.data[8]=t.data[9]=0,0)))}(l["OS/2"],e)||(l["OS/2"]={tag:"OS/2",data:gB(A,t.charCodeToGlyphId,b)})}if(!u)try{d=new bl(l["CFF "].data),I=new ru(d,A,Ru).parse(),I.duplicateFirstGlyph();const t=new mu(I);l["CFF "].data=t.compile()}catch{Zc("Failed to compile font "+A.loadedName)}if(l.name){const[e,i]=o(l.name);l.name.data=lB(t,e),this.psName=e[0][6]||null,A.composite||function(t,e,A){if(t.isInternalFont)return;if(t.hasIncludedToUnicodeMap)return;if(t.hasEncoding)return;if(t.toUnicode instanceof ju)return;if(!e)return;if(0===A.length)return;if(t.defaultEncoding===tu)return;for(const t of A)if(!aB(t))return;const i=tu,s=[],a=yu();for(const t in i){const e=i[t];if(""===e)continue;const A=a[e];void 0!==A&&(s[t]=String.fromCharCode(A))}s.length>0&&t.toUnicode.amend(s)}(A,this.isSymbolicFont,i)}else l.name={tag:"name",data:lB(this.name)};const S=new bC(h.version);for(const t in l)S.addTable(t,l[t].data);return S.toArray()}convert(t,e,A){A.fixedPitch=!1,A.builtInEncoding&&function(t,e){if(t.isInternalFont)return;if(t.hasIncludedToUnicodeMap)return;if(e===t.defaultEncoding)return;if(t.toUnicode instanceof ju)return;const A=[],i=yu();for(const s in e){if(t.hasEncoding&&(t.baseEncodingName||void 0!==t.differences[s]))continue;const a=Du(e[s],i);-1!==a&&(A[s]=String.fromCharCode(a))}A.length>0&&t.toUnicode.amend(A)}(A,A.builtInEncoding);let i=1;e instanceof Vu&&(i=e.numGlyphs-1);const s=e.getGlyphMapping(A);let a=null,n=s,r=null;A.cssFontInfo||(a=rB(s,e.hasGlyphId.bind(e),i,this.toUnicode),this.toFontChar=a.toFontChar,n=a.charCodeToGlyphId,r=a.toUnicodeExtraMap);const o=e.numGlyphs;function g(t,e){let A=null;for(const i in t)e===t[i]&&(A||=[]).push(0|i);return A}function c(t,e){for(const A in t)if(e===t[A])return 0|A;return a.charCodeToGlyphId[a.nextAvailableFontCharCode]=e,a.nextAvailableFontCharCode++}const h=e.seacs;if(a&&h?.length){const t=A.fontMatrix||bc,i=e.getCharset(),n=Object.create(null);for(let e in h){e|=0;const A=h[e],r=$d[A[2]],o=$d[A[3]],l=i.indexOf(r),I=i.indexOf(o);if(l<0||I<0)continue;const d={x:A[0]*t[0]+A[1]*t[2]+t[4],y:A[0]*t[1]+A[1]*t[3]+t[5]},u=g(s,e);if(u)for(const t of u){const e=a.charCodeToGlyphId,A=c(e,l),i=c(e,I);n[t]={baseFontCharCode:A,accentFontCharCode:i,accentOffset:d}}}A.seacMap=n}const l=A.fontMatrix?1/Math.max(...A.fontMatrix.slice(0,4).map(Math.abs)):1e3,I=new bC("OTTO");return I.addTable("CFF ",e.data),I.addTable("OS/2",gB(A,n)),I.addTable("cmap",oB(n,r,o)),I.addTable("head","\0\0\0\0\0\0\0\0\0\0_<õ\0\0"+tB(l)+"\0\0\0\0ž\v~'\0\0\0\0ž\v~'\0\0"+tB(A.descent)+"ÿ"+tB(A.ascent)+$C(A.italicAngle?2:0)+"\0\0\0\0\0\0\0"),I.addTable("hhea","\0\0\0"+tB(A.ascent)+tB(A.descent)+"\0\0ÿÿ\0\0\0\0\0\0"+tB(A.capHeight)+tB(Math.tan(A.italicAngle)*A.xHeight)+"\0\0\0\0\0\0\0\0\0\0\0\0"+$C(o)),I.addTable("hmtx",function(){const t=e.charstrings,A=e.cff?e.cff.widths:null;let i="\0\0\0\0";for(let e=1,s=o;e=65520&&t<=65535?0:t>=62976&&t<=63743?wu()[t]||t:173===t?45:t}(A)}this.isType3Font&&(s=A);let c=null;if(this.seacMap?.[t]){g=!0;const e=this.seacMap[t];A=e.baseFontCharCode,c={fontChar:String.fromCodePoint(e.accentFontCharCode),offset:e.accentOffset}}let h="";if("number"==typeof A&&(A<=1114111?h=String.fromCodePoint(A):Zc(`charToGlyph - invalid fontCharCode: ${A}`)),this.missingFile&&this.vertical&&1===h.length){const t=Lu()[h.charCodeAt(0)];t&&(h=o=String.fromCharCode(t))}return a=new VC(t,h,o,c,i,r,s,e,g),this._glyphCache[t]=a}charsToGlyphs(t){let e=this._charsCache[t];if(e)return e;if(e=[],this.cMap){const A=Object.create(null),i=t.length;let s=0;for(;se.length%2==1,s=this.toUnicode instanceof ju?t=>this.toUnicode.charCodeOf(t):t=>this.toUnicode.charCodeOf(String.fromCodePoint(t));for(let a=0,n=t.length;a55295&&(n<57344||n>65533)&&a++,this.toUnicode){const t=s(n);if(-1!==t){i()&&(e.push(A.join("")),A.length=0);for(let e=(this.cMap?this.cMap.getCharCodeLength(t):1)-1;e>=0;e--)A.push(String.fromCharCode(t>>8*e&255));continue}}i()||(e.push(A.join("")),A.length=0),A.push(String.fromCodePoint(n))}return e.push(A.join("")),e}}class dB{constructor(t){this.error=t,this.loadedName="g_font_error",this.missingFile=!0}charsToGlyphs(){return[]}encodeString(t){return[t]}exportData(t=!1){return{error:this.error}}}class uB{constructor(){Xc("Cannot initialize Pattern.")}static parseShading(t,e,A,i,s){const a=t instanceof _h?t.dict:t,n=a.get("ShadingType");try{switch(n){case 2:case 3:return new BB(a,e,A,i,s);case 4:case 5:case 6:case 7:return new pB(t,e,A,i,s);default:throw new rh("Unsupported ShadingType: "+n)}}catch(t){if(t instanceof Ph)throw t;return Zc(t),new mB}}}class CB{static SMALL_NUMBER=1e-6;constructor(){this.constructor===CB&&Xc("Cannot initialize BaseShading.")}getIR(){Xc("Abstract method `getIR` called.")}}class BB extends CB{constructor(t,e,A,i,s){super(),this.shadingType=t.get("ShadingType");let a=0;if(2===this.shadingType?a=4:3===this.shadingType&&(a=6),this.coordsArr=t.getArray("Coords"),!Al(this.coordsArr,a))throw new rh("RadialAxialShading: Invalid /Coords array.");const n=xl.parse({cs:t.getRaw("CS")||t.getRaw("ColorSpace"),xref:e,resources:A,pdfFunctionFactory:i,localColorSpaceCache:s});this.bbox=al(t.getArray("BBox"),null);let r=0,o=1;const g=t.getArray("Domain");Al(g,2)&&([r,o]=g);let c=!1,h=!1;const l=t.getArray("Extend");if(function(t){return Array.isArray(t)&&2===t.length&&t.every((t=>"boolean"==typeof t))}(l)&&([c,h]=l),!(3!==this.shadingType||c&&h)){const[t,e,A,i,s,a]=this.coordsArr,n=Math.hypot(t-i,e-s);A<=a+n&&a<=A+n&&Zc("Unsupported radial gradient.")}this.extendStart=c,this.extendEnd=h;const I=t.getRaw("Function"),d=i.createFromArray(I),u=(o-r)/840,C=this.colorStops=[];if(r>=o||u<=0)return void Vc("Bad shading domain.");const B=new Float32Array(n.numComps),Q=new Float32Array(1);let E,f=0;Q[0]=r,d(Q,0,B,0);let p=n.getRgb(B,0);const m=uh.makeHexColor(p[0],p[1],p[2]);C.push([0,m]);let y=1;Q[0]=r+u,d(Q,0,B,0);let b=n.getRgb(B,0),w=b[0]-p[0]+1,D=b[1]-p[1]+1,k=b[2]-p[2]+1,S=b[0]-p[0]-1,x=b[1]-p[1]-1,F=b[2]-p[2]-1;for(let t=2;t<840;t++){Q[0]=r+t*u,d(Q,0,B,0),E=n.getRgb(B,0);const e=t-f;if(w=Math.min(w,(E[0]-p[0]+1)/e),D=Math.min(D,(E[1]-p[1]+1)/e),k=Math.min(k,(E[2]-p[2]+1)/e),S=Math.max(S,(E[0]-p[0]-1)/e),x=Math.max(x,(E[1]-p[1]-1)/e),F=Math.max(F,(E[2]-p[2]-1)/e),!(S<=w&&x<=D&&F<=k)){const t=uh.makeHexColor(b[0],b[1],b[2]);C.push([y/840,t]),w=E[0]-b[0]+1,D=E[1]-b[1]+1,k=E[2]-b[2]+1,S=E[0]-b[0]-1,x=E[1]-b[1]-1,F=E[2]-b[2]-1,f=y,p=b}y=t,b=E}const R=uh.makeHexColor(b[0],b[1],b[2]);C.push([1,R]);let v="transparent";t.has("Background")&&(E=n.getRgb(t.get("Background"),0),v=uh.makeHexColor(E[0],E[1],E[2])),c||(C.unshift([0,v]),C[1][0]+=CB.SMALL_NUMBER),h||(C.at(-1)[0]-=CB.SMALL_NUMBER,C.push([1,v])),this.colorStops=C}getIR(){const{coordsArr:t,shadingType:e}=this;let A,i,s,a,n;return 2===e?(i=[t[0],t[1]],s=[t[2],t[3]],a=null,n=null,A="axial"):3===e?(i=[t[0],t[1]],s=[t[3],t[4]],a=t[2],n=t[5],A="radial"):Xc(`getPattern type unknown: ${e}`),["RadialAxial",A,this.bbox,this.colorStops,i,s,a,n]}}class QB{constructor(t,e){this.stream=t,this.context=e,this.buffer=0,this.bufferLength=0;const A=e.numComps;this.tmpCompsBuf=new Float32Array(A);const i=e.colorSpace.numComps;this.tmpCsCompsBuf=e.colorFn?new Float32Array(i):this.tmpCompsBuf}get hasData(){if(this.stream.end)return this.stream.pos0)return!0;const t=this.stream.getByte();return!(t<0||(this.buffer=t,this.bufferLength=8,0))}readBits(t){let e=this.buffer,A=this.bufferLength;if(32===t){if(0===A)return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0;e=e<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();const t=this.stream.getByte();return this.buffer=t&(1<>A)>>>0}if(8===t&&0===A)return this.stream.getByte();for(;A>A}align(){this.buffer=0,this.bufferLength=0}readFlag(){return this.readBits(this.context.bitsPerFlag)}readCoordinate(){const t=this.context.bitsPerCoordinate,e=this.readBits(t),A=this.readBits(t),i=this.context.decode,s=t<32?1/((1<a?a:t,e=e>n?n:e,A=At*s[e])):A;let n,r=-2;const o=[];for(const[t,e]of i.map(((t,e)=>[t,e])).sort((([t],[e])=>t-e)))-1!==t&&(t===r+1?(n.push(a[e]),r+=1):(r=t,n=[a[e]],o.push(t,n)));return o}(t),A=new vh(null);A.set("BaseFont",xh.get(t)),A.set("Type",xh.get("Font")),A.set("Subtype",xh.get("CIDFontType2")),A.set("Encoding",xh.get("Identity-H")),A.set("CIDToGIDMap",xh.get("Identity")),A.set("W",e),A.set("FirstChar",e[0]),A.set("LastChar",e.at(-2)+e.at(-1).length-1);const i=new vh(null);A.set("FontDescriptor",i);const s=new vh(null);return s.set("Ordering","Identity"),s.set("Registry","Adobe"),s.set("Supplement",0),A.set("CIDSystemInfo",s),A}class IQ{constructor(t){this.lexer=t,this.operators=[],this.token=null,this.prev=null}nextToken(){this.prev=this.token,this.token=this.lexer.getToken()}accept(t){return this.token.type===t&&(this.nextToken(),!0)}expect(t){if(this.accept(t))return!0;throw new rh(`Unexpected symbol: found ${this.token.type} expected ${t}.`)}parse(){return this.nextToken(),this.expect(dQ.LBRACE),this.parseBlock(),this.expect(dQ.RBRACE),this.operators}parseBlock(){for(;;)if(this.accept(dQ.NUMBER))this.operators.push(this.prev.value);else if(this.accept(dQ.OPERATOR))this.operators.push(this.prev.value);else{if(!this.accept(dQ.LBRACE))return;this.parseCondition()}}parseCondition(){const t=this.operators.length;if(this.operators.push(null,null),this.parseBlock(),this.expect(dQ.RBRACE),this.accept(dQ.IF))this.operators[t]=this.operators.length,this.operators[t+1]="jz";else{if(!this.accept(dQ.LBRACE))throw new rh("PS Function: error parsing conditional.");{const e=this.operators.length;this.operators.push(null,null);const A=this.operators.length;this.parseBlock(),this.expect(dQ.RBRACE),this.expect(dQ.IFELSE),this.operators[e]=this.operators.length,this.operators[e+1]="j",this.operators[t]=A,this.operators[t+1]="jz"}}}}const dQ={LBRACE:0,RBRACE:1,NUMBER:2,OPERATOR:3,IF:4,IFELSE:5};class uQ{static get opCache(){return th(this,"opCache",Object.create(null))}constructor(t,e){this.type=t,this.value=e}static getOperator(t){return uQ.opCache[t]||=new uQ(dQ.OPERATOR,t)}static get LBRACE(){return th(this,"LBRACE",new uQ(dQ.LBRACE,"{"))}static get RBRACE(){return th(this,"RBRACE",new uQ(dQ.RBRACE,"}"))}static get IF(){return th(this,"IF",new uQ(dQ.IF,"IF"))}static get IFELSE(){return th(this,"IFELSE",new uQ(dQ.IFELSE,"IFELSE"))}}class CQ{constructor(t){this.stream=t,this.nextChar(),this.strBuf=[]}nextChar(){return this.currentChar=this.stream.getByte()}getToken(){let t=!1,e=this.currentChar;for(;;){if(e<0)return wh;if(t)10!==e&&13!==e||(t=!1);else if(37===e)t=!0;else if(!el(e))break;e=this.nextChar()}switch(0|e){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return new uQ(dQ.NUMBER,this.getNumber());case 123:return this.nextChar(),uQ.LBRACE;case 125:return this.nextChar(),uQ.RBRACE}const A=this.strBuf;for(A.length=0,A[0]=String.fromCharCode(e);(e=this.nextChar())>=0&&(e>=65&&e<=90||e>=97&&e<=122);)A.push(String.fromCharCode(e));const i=A.join("");switch(i.toLowerCase()){case"if":return uQ.IF;case"ifelse":return uQ.IFELSE;default:return uQ.getOperator(i)}}getNumber(){let t=this.currentChar;const e=this.strBuf;for(e.length=0,e[0]=String.fromCharCode(t);(t=this.nextChar())>=0&&(t>=48&&t<=57||45===t||46===t);)e.push(String.fromCharCode(t));const A=parseFloat(e.join(""));if(isNaN(A))throw new rh(`Invalid floating point number: ${A}`);return A}}class BQ{constructor(t){this.constructor===BQ&&Xc("Cannot initialize BaseLocalCache."),this._onlyRefs=!0===t?.onlyRefs,this._onlyRefs||(this._nameRefMap=new Map,this._imageMap=new Map),this._imageCache=new Gh}getByName(t){this._onlyRefs&&Xc("Should not call `getByName` method.");const e=this._nameRefMap.get(t);return e?this.getByRef(e):this._imageMap.get(t)||null}getByRef(t){return this._imageCache.get(t)||null}set(t,e,A){Xc("Abstract method `set` called.")}}class QQ extends BQ{set(t,e=null,A){if("string"!=typeof t)throw new Error('LocalImageCache.set - expected "name" argument.');if(e){if(this._imageCache.has(e))return;this._nameRefMap.set(t,e),this._imageCache.put(e,A)}else this._imageMap.has(t)||this._imageMap.set(t,A)}}class EQ extends BQ{set(t=null,e=null,A){if("string"!=typeof t&&!e)throw new Error('LocalColorSpaceCache.set - expected "name" and/or "ref" argument.');if(e){if(this._imageCache.has(e))return;null!==t&&this._nameRefMap.set(t,e),this._imageCache.put(e,A)}else this._imageMap.has(t)||this._imageMap.set(t,A)}}class fQ extends BQ{constructor(t){super({onlyRefs:!0})}set(t=null,e,A){if(!e)throw new Error('LocalFunctionCache.set - expected "ref" argument.');this._imageCache.has(e)||this._imageCache.put(e,A)}}class pQ extends BQ{set(t,e=null,A){if("string"!=typeof t)throw new Error('LocalGStateCache.set - expected "name" argument.');if(e){if(this._imageCache.has(e))return;this._nameRefMap.set(t,e),this._imageCache.put(e,A)}else this._imageMap.has(t)||this._imageMap.set(t,A)}}class mQ extends BQ{constructor(t){super({onlyRefs:!0})}set(t=null,e,A){if(!e)throw new Error('LocalTilingPatternCache.set - expected "ref" argument.');this._imageCache.has(e)||this._imageCache.put(e,A)}}class yQ extends BQ{constructor(t){super({onlyRefs:!0})}set(t=null,e,A){if(!e)throw new Error('RegionalImageCache.set - expected "ref" argument.');this._imageCache.has(e)||this._imageCache.put(e,A)}}class bQ{static NUM_PAGES_THRESHOLD=2;static MIN_IMAGES_TO_CACHE=10;static MAX_BYTE_SIZE=5e7;#xr=new Mh;constructor(){this._refCache=new Gh,this._imageCache=new Gh}get#Fr(){let t=0;for(const e of this._imageCache)t+=e.byteSize;return t}get#Rr(){return!(this._imageCache.size+t)):null}class kQ{static getSampleArray(t,e,A,i){let s,a,n=1;for(s=0,a=t.length;s>o)*c,g&=(1<A?t=A:t0&&(l=a[h-1]);let I=i[1];h>1,g=s.length>>1,c=new FQ(r),h=Object.create(null);let l=8192;const I=new Float32Array(g);return function(t,e,A,i){let s,n,r="";const d=I;for(s=0;st&&(n=t)),C[s]=n}l>0&&(l--,h[r]=C),A.set(C,i)}}}function SQ(t){let e;if(t instanceof vh)e=t;else{if(!(t instanceof _h))return!1;e=t.dict}return e.has("FunctionType")}class xQ{static MAX_STACK_SIZE=100;constructor(t){this.stack=t?Array.from(t):[]}push(t){if(this.stack.length>=xQ.MAX_STACK_SIZE)throw new Error("PostScript function stack overflow.");this.stack.push(t)}pop(){if(this.stack.length<=0)throw new Error("PostScript function stack underflow.");return this.stack.pop()}copy(t){if(this.stack.length+t>=xQ.MAX_STACK_SIZE)throw new Error("PostScript function stack overflow.");const e=this.stack;for(let A=e.length-t,i=t-1;i>=0;i--,A++)e.push(e[A])}index(t){this.push(this.stack[this.stack.length-t-1])}roll(t,e){const A=this.stack,i=A.length-t,s=A.length-1,a=i+(e-Math.floor(e/t)*t);for(let t=i,e=s;t0?e.push(n<>r);break;case"ceiling":n=e.pop(),e.push(Math.ceil(n));break;case"copy":n=e.pop(),e.copy(n);break;case"cos":n=e.pop(),e.push(Math.cos(n%360/180*Math.PI));break;case"cvi":n=0|e.pop(),e.push(n);break;case"cvr":break;case"div":r=e.pop(),n=e.pop(),e.push(n/r);break;case"dup":e.copy(1);break;case"eq":r=e.pop(),n=e.pop(),e.push(n===r);break;case"exch":e.roll(2,1);break;case"exp":r=e.pop(),n=e.pop(),e.push(n**r);break;case"false":e.push(!1);break;case"floor":n=e.pop(),e.push(Math.floor(n));break;case"ge":r=e.pop(),n=e.pop(),e.push(n>=r);break;case"gt":r=e.pop(),n=e.pop(),e.push(n>r);break;case"idiv":r=e.pop(),n=e.pop(),e.push(n/r|0);break;case"index":n=e.pop(),e.index(n);break;case"le":r=e.pop(),n=e.pop(),e.push(n<=r);break;case"ln":n=e.pop(),e.push(Math.log(n));break;case"log":n=e.pop(),e.push(Math.log10(n));break;case"lt":r=e.pop(),n=e.pop(),e.push(n=e?new NQ(e):t.max<=e?t:new GQ(t,e)}class PQ{compile(t,e,A){const i=[],s=[],a=e.length>>1,n=A.length>>1;let r,o,g,c,h,l,I,d,u=0;for(let t=0;te.min&&(r.unshift("Math.max(",a,", "),r.push(")")),n4?(i=!0,e=0):(i=!1,e=1));const o=[];for(a=0;a=0&&"ET"===$Q[t];--t)$Q[t]="EN";for(let t=a+1;t0&&(e=$Q[a-1]);let A=h;t+1d&&OQ(d)&&(C=d);for(d=u;d>=C;--d){let t=-1;for(a=0,n=o.length;a=0&&(ZQ(zQ,t,a),t=-1):t<0&&(t=a);t>=0&&ZQ(zQ,t,o.length)}for(a=0,n=zQ.length;a"!==t||(zQ[a]="")}return XQ(zQ.join(""),i)}const eE={style:"normal",weight:"normal"},AE={style:"normal",weight:"bold"},iE={style:"italic",weight:"normal"},sE={style:"italic",weight:"bold"},aE=new Map([["Times-Roman",{local:["Times New Roman","Times-Roman","Times","Liberation Serif","Nimbus Roman","Nimbus Roman L","Tinos","Thorndale","TeX Gyre Termes","FreeSerif","Linux Libertine O","Libertinus Serif","DejaVu Serif","Bitstream Vera Serif","Ubuntu"],style:eE,ultimate:"serif"}],["Times-Bold",{alias:"Times-Roman",style:AE,ultimate:"serif"}],["Times-Italic",{alias:"Times-Roman",style:iE,ultimate:"serif"}],["Times-BoldItalic",{alias:"Times-Roman",style:sE,ultimate:"serif"}],["Helvetica",{local:["Helvetica","Helvetica Neue","Arial","Arial Nova","Liberation Sans","Arimo","Nimbus Sans","Nimbus Sans L","A030","TeX Gyre Heros","FreeSans","DejaVu Sans","Albany","Bitstream Vera Sans","Arial Unicode MS","Microsoft Sans Serif","Apple Symbols","Cantarell"],path:"LiberationSans-Regular.ttf",style:eE,ultimate:"sans-serif"}],["Helvetica-Bold",{alias:"Helvetica",path:"LiberationSans-Bold.ttf",style:AE,ultimate:"sans-serif"}],["Helvetica-Oblique",{alias:"Helvetica",path:"LiberationSans-Italic.ttf",style:iE,ultimate:"sans-serif"}],["Helvetica-BoldOblique",{alias:"Helvetica",path:"LiberationSans-BoldItalic.ttf",style:sE,ultimate:"sans-serif"}],["Courier",{local:["Courier","Courier New","Liberation Mono","Nimbus Mono","Nimbus Mono L","Cousine","Cumberland","TeX Gyre Cursor","FreeMono","Linux Libertine Mono O","Libertinus Mono"],style:eE,ultimate:"monospace"}],["Courier-Bold",{alias:"Courier",style:AE,ultimate:"monospace"}],["Courier-Oblique",{alias:"Courier",style:iE,ultimate:"monospace"}],["Courier-BoldOblique",{alias:"Courier",style:sE,ultimate:"monospace"}],["ArialBlack",{local:["Arial Black"],style:{style:"normal",weight:"900"},fallback:"Helvetica-Bold"}],["ArialBlack-Bold",{alias:"ArialBlack"}],["ArialBlack-Italic",{alias:"ArialBlack",style:{style:"italic",weight:"900"},fallback:"Helvetica-BoldOblique"}],["ArialBlack-BoldItalic",{alias:"ArialBlack-Italic"}],["ArialNarrow",{local:["Arial Narrow","Liberation Sans Narrow","Helvetica Condensed","Nimbus Sans Narrow","TeX Gyre Heros Cn"],style:eE,fallback:"Helvetica"}],["ArialNarrow-Bold",{alias:"ArialNarrow",style:AE,fallback:"Helvetica-Bold"}],["ArialNarrow-Italic",{alias:"ArialNarrow",style:iE,fallback:"Helvetica-Oblique"}],["ArialNarrow-BoldItalic",{alias:"ArialNarrow",style:sE,fallback:"Helvetica-BoldOblique"}],["Calibri",{local:["Calibri","Carlito"],style:eE,fallback:"Helvetica"}],["Calibri-Bold",{alias:"Calibri",style:AE,fallback:"Helvetica-Bold"}],["Calibri-Italic",{alias:"Calibri",style:iE,fallback:"Helvetica-Oblique"}],["Calibri-BoldItalic",{alias:"Calibri",style:sE,fallback:"Helvetica-BoldOblique"}],["Wingdings",{local:["Wingdings","URW Dingbats"],style:eE}],["Wingdings-Regular",{alias:"Wingdings"}],["Wingdings-Bold",{alias:"Wingdings"}]]),nE=new Map([["Arial-Black","ArialBlack"]]);function rE(t){const e=new Set(["thin","extralight","ultralight","demilight","semilight","light","book","regular","normal","medium","demibold","semibold","bold","extrabold","ultrabold","black","heavy","extrablack","ultrablack","roman","italic","oblique","ultracondensed","extracondensed","condensed","semicondensed","normal","semiexpanded","expanded","extraexpanded","ultraexpanded","bolditalic"]);return t.split(/[- ,+]+/g).filter((t=>!e.has(t.toLowerCase()))).join(" ")}function oE({alias:t,local:e,path:A,fallback:i,style:s,ultimate:a},n,r,o=!0,g=!0,c=""){const h={style:null,ultimate:null};if(e){const t=c?` ${c}`:"";for(const A of e)n.push(`local(${A}${t})`)}if(t){const e=aE.get(t),a=c||function(t){switch(t){case AE:return"Bold";case iE:return"Italic";case sE:return"Bold Italic";default:if("bold"===t?.weight)return"Bold";if("italic"===t?.style)return"Italic"}return""}(s);Object.assign(h,oE(e,n,r,o&&!i,g&&!A,a))}if(s&&(h.style=s),a&&(h.ultimate=a),o&&i){const t=aE.get(i),{ultimate:e}=oE(t,n,r,o,g&&!A,c);h.ultimate||=e}return g&&A&&r&&n.push(`url(${r}${A})`),h}function gE(t,e,A,i,s,a){if(i.startsWith("InvalidPDFjsFont_"))return null;"TrueType"!==a&&"Type1"!==a||!/^[A-Z]{6}\+/.test(i)||(i=i.slice(7));const n=i=Gu(i);let r=t.get(n);if(r)return r;let o=aE.get(i);if(!o)for(const[t,e]of nE)if(i.startsWith(t)){i=`${e}${i.substring(t.length)}`,o=aE.get(i);break}let g=!1;o||(o=aE.get(s),g=!0);const c=`${e.getDocId()}_s${e.createFontId()}`;if(!o){if(!dl(i))return Zc(`Cannot substitute the font because of its name: ${i}`),t.set(n,null),null;const e=/bold/gi.test(i),A=/oblique|italic/gi.test(i),s=e&&A&&sE||e&&AE||A&&iE||eE;return r={css:`"${rE(i)}",${c}`,guessFallback:!0,loadedName:c,baseFontName:i,src:`local(${i})`,style:s},t.set(n,r),r}const h=[];g&&dl(i)&&h.push(`local(${i})`);const{style:l,ultimate:I}=oE(o,h,A),d=null===I,u=d?"":`,${I}`;return r={css:`"${rE(i)}",${c}${u}`,guessFallback:d,loadedName:c,baseFontName:i,src:h.join(","),style:l},t.set(n,r),r}class cE{constructor(t,e){this._imgData=t,this._isMask=e}static needsToBeResized(t,e){if(t<=this._goodSquareLength&&e<=this._goodSquareLength)return!1;const{MAX_DIM:A}=this;if(t>A||e>A)return!0;const i=t*e;return this._hasMaxArea?i>this.MAX_AREA:!(i(this.MAX_AREA=this._goodSquareLength**2)))}static get MAX_DIM(){return th(this,"MAX_DIM",this._guessMax(2048,65537,0,1))}static get MAX_AREA(){return this._hasMaxArea=!0,th(this,"MAX_AREA",this._guessMax(cE._goodSquareLength,this.MAX_DIM,128,0)**2)}static set MAX_AREA(t){t>=0&&(this._hasMaxArea=!0,th(this,"MAX_AREA",t))}static setMaxArea(t){this._hasMaxArea||(this.MAX_AREA=t>>2)}static _areGoodDims(t,e){try{const A=new OffscreenCanvas(t,e),i=A.getContext("2d");i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data[3];return A.width=A.height=1,0!==s}catch{return!1}}static _guessMax(t,e,A,i){for(;t+A+1>3,n=A+3&-4;if(A!==n){const t=new Uint8Array(n*e);let i=0;for(let a=0,r=e*A;a>>8,e[A++]=255&s)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),A=e.byteLength}const i=A>>2,s=A-4*i,a=new Uint32Array(e.buffer,0,i);let n=0,r=0,o=this.h1,g=this.h2;const c=3432918353,h=461845907,l=11601,I=13715;for(let t=0;t>>17,n=n*h&lE|n*I&IE,o^=n,o=o<<13|o>>>19,o=5*o+3864292196):(r=a[t],r=r*c&lE|r*l&IE,r=r<<15|r>>>17,r=r*h&lE|r*I&IE,g^=r,g=g<<13|g>>>19,g=5*g+3864292196);switch(n=0,s){case 3:n^=e[4*i+2]<<16;case 2:n^=e[4*i+1]<<8;case 1:n^=e[4*i],n=n*c&lE|n*l&IE,n=n<<15|n>>>17,n=n*h&lE|n*I&IE,1&i?o^=n:g^=n}this.h1=o,this.h2=g}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&lE|36045*t&IE,e=4283543511*e&lE|(2950163797*(e<<16|t>>>16)&lE)>>>16,t^=e>>>1,t=444984403*t&lE|60499*t&IE,e=3301882366*e&lE|(3120437893*(e<<16|t>>>16)&lE)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}function uE(t,e,A,i,s){let a=t;for(let t=0,A=e.length-1;t1e3&&(g=Math.max(g,l),I+=h+2,l=0,h=0),c.push({transform:e,x:l,y:I,w:A.width,h:A.height}),l+=A.width+2,h=Math.max(h,A.height)}const d=Math.max(g,l)+1,u=I+h+1,C=new Uint8Array(d*u*4),B=d<<2;for(let t=0;t=0;)e[a-4]=e[a],e[a-3]=e[a+1],e[a-2]=e[a+2],e[a-1]=e[a+3],e[a+A]=e[a+A-4],e[a+A+1]=e[a+A-3],e[a+A+2]=e[a+A-2],e[a+A+3]=e[a+A-1],a-=B}const Q={width:d,height:u};if(t.isOffscreenCanvasSupported){const t=new OffscreenCanvas(d,u);t.getContext("2d").putImageData(new ImageData(new Uint8ClampedArray(C.buffer),d,u),0,0),Q.bitmap=t.transferToImageBitmap(),Q.data=null}else Q.kind=3,Q.data=C;return A.splice(a,4*o,87),i.splice(a,4*o,[Q,c]),a+1})),uE(CE,[Uc,Jc,Oc,Hc],null,(function(t,e){const A=t.fnArray,i=(e-(t.iCurr-3))%4;switch(i){case 0:return A[e]===Uc;case 1:return A[e]===Jc;case 2:return A[e]===Oc;case 3:return A[e]===Hc}throw new Error(`iterateImageMaskGroup - invalid pos: ${i}`)}),(function(t,e){const A=t.fnArray,i=t.argsArray,s=t.iCurr,a=s-3,n=s-2,r=s-1;let o=Math.floor((e-a)/4);if(o<10)return e-(e-a)%4;let g,c,h=!1;const l=i[r][0],I=i[n][0],d=i[n][1],u=i[n][2],C=i[n][3];if(d===u){h=!0,g=n+4;let t=r+4;for(let e=1;e=4&&A[a-4]===A[n]&&A[a-3]===A[r]&&A[a-2]===A[o]&&A[a-1]===A[g]&&i[a-4][0]===c&&i[a-4][1]===h&&(l++,I-=5);let d=I+4;for(let t=1;t=A)break}i=(i||CE)[t[e]],i&&!Array.isArray(i)?(a.iCurr=e,e++,!i.checkFn||(0,i.checkFn)(a)?(s=i,i=null):i=null):e++}this.state=i,this.match=s,this.lastProcessed=e}flush(){for(;this.match;){const t=this.queue.fnArray.length;this.lastProcessed=(0,this.match.processFn)(this.context,t),this.match=null,this.state=null,this._optimize()}}reset(){this.state=null,this.match=null,this.lastProcessed=0}}class EE{static CHUNK_SIZE=1e3;static CHUNK_SIZE_ABOUT=this.CHUNK_SIZE-5;constructor(t=0,e){this._streamSink=e,this.fnArray=[],this.argsArray=[],this.optimizer=!e||256&t?new BE(this):new QE(this),this.dependencies=new Set,this._totalLength=0,this.weight=0,this._resolved=e?null:Promise.resolve()}set isOffscreenCanvasSupported(t){this.optimizer.isOffscreenCanvasSupported=t}get length(){return this.argsArray.length}get ready(){return this._resolved||this._streamSink.ready}get totalLength(){return this._totalLength+this.length}addOp(t,e){this.optimizer.push(t,e),this.weight++,this._streamSink&&(this.weight>=EE.CHUNK_SIZE||this.weight>=EE.CHUNK_SIZE_ABOUT&&(t===Hc||32===t))&&this.flush()}addImageOps(t,e,A){void 0!==A&&this.addOp(Kc,["OC",A]),this.addOp(t,e),void 0!==A&&this.addOp(qc,[])}addDependency(t){this.dependencies.has(t)||(this.dependencies.add(t),this.addOp(1,[t]))}addDependencies(t){for(const e of t)this.addDependency(e)}addOpList(t){if(t instanceof EE){for(const e of t.dependencies)this.dependencies.add(e);for(let e=0,A=t.length;ei&&(t=i),t}function pE(t,e,A,i,s,a){const n=s*a;let r;r=e<=8?new Uint8Array(n):e<=16?new Uint16Array(n):new Uint32Array(n);const o=A/s,g=i/a;let c,h,l,I,d=0;const u=new Uint16Array(s),C=A;for(c=0;c0&&Number.isInteger(A.height)&&A.height>0&&(A.width!==l||A.height!==I)&&(Zc("PDFImage - using the Width/Height of the image data, rather than the image dictionary."),l=A.width,I=A.height),l<1||I<1)throw new rh(`Invalid image width: ${l} or height: ${I}`);this.width=l,this.height=I,this.interpolate=g.get("I","Interpolate"),this.imageMask=g.get("IM","ImageMask")||!1,this.matte=g.get("Matte")||!1;let d=A.bitsPerComponent;if(!d&&(d=g.get("BPC","BitsPerComponent"),!d)){if(!this.imageMask)throw new rh(`Bits per component missing in image: ${this.imageMask}`);d=1}if(this.bpc=d,!this.imageMask){let s=g.getRaw("CS")||g.getRaw("ColorSpace");const a=!!s;if(a)this.jpxDecoderOptions?.smaskInData&&(s=xh.get("DeviceRGBA"));else if(this.jpxDecoderOptions)s=xh.get("DeviceRGBA");else switch(A.numComps){case 1:s=xh.get("DeviceGray");break;case 3:s=xh.get("DeviceRGB");break;case 4:s=xh.get("DeviceCMYK");break;default:throw new Error(`Images with ${A.numComps} color components not supported.`)}this.colorSpace=xl.parse({cs:s,xref:t,resources:i?e:null,pdfFunctionFactory:r,localColorSpaceCache:o}),this.numComps=this.colorSpace.numComps,this.jpxDecoderOptions&&(this.jpxDecoderOptions.numComponents=a?this.numComp:0,this.jpxDecoderOptions.isIndexedColormap="Indexed"===this.colorSpace.name)}if(this.decode=g.getArray("D","Decode"),this.needsDecode=!1,this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode,d)||n&&!xl.isDefaultDecode(this.decode,1))){this.needsDecode=!0;const t=(1<>3)*A,r=t.byteLength;let o,g;if(!i||s&&n!==r?s?(o=new Uint8Array(n),o.set(t),o.fill(255,r)):o=new Uint8Array(t):o=t,s)for(g=0;g>7&1,n[l+1]=h>>6&1,n[l+2]=h>>5&1,n[l+3]=h>>4&1,n[l+4]=h>>3&1,n[l+5]=h>>2&1,n[l+6]=h>>1&1,n[l+7]=1&h,l+=8;if(l>=1}}else{let A=0;for(h=0,l=0,c=a;l>i;s<0?s=0:s>g&&(s=g),n[l]=s,h&=(1<n[i+1]){e=255;break}}r[c]=e}}}if(r)for(c=0,l=3,h=e*i;c>3,c=e&&cE.needsToBeResized(A,i);if("DeviceRGBA"===this.colorSpace.name){s.kind=3;const t=s.data=await this.getImageBytes(r*n*4,{});return e?c?cE.createImage(s,!1):this.createBitmap(3,A,i,t):s}if(!t){let t;if("DeviceGray"===this.colorSpace.name&&1===o?t=1:"DeviceRGB"!==this.colorSpace.name||8!==o||this.needsDecode||(t=2),t&&!this.smask&&!this.mask&&A===n&&i===r){const a=await this.getImageBytes(r*g,{});if(e)return c?cE.createImage({data:a,kind:t,width:A,height:i,interpolate:this.interpolate},this.needsDecode):this.createBitmap(t,n,r,a);if(s.kind=t,s.data=a,this.needsDecode){zc(1===t,"PDFImage.createImageData: The image must be grayscale.");const e=s.data;for(let t=0,A=e.length;t>3,n=await this.getImageBytes(i*a,{internal:!0}),r=this.getComponents(n);let o,g;if(1===s){if(g=A*i,this.needsDecode)for(o=0;o>2,o=new Uint32Array(t.buffer,e,r);if(Ih.isLittleEndian){for(;n>>24|e<<8|4278190080,A[i+2]=e>>>16|s<<16|4278190080,A[i+3]=s>>>8|4278190080}for(let e=4*n,s=t.length;e>>8|255,A[i+2]=e<<16|s>>>16|255,A[i+3]=s<<8|255}for(let e=4*n,s=t.length;e0&&e.args[0].count++}class kE{static TIME_SLOT_DURATION_MS=20;static CHECK_TIME_EVERY=100;constructor(){this.reset()}check(){return!(++this.checkedh){const t="Image exceeded maximum allowed size and was removed.";if(this.options.ignoreErrors)return void Zc(t);throw new Error(t)}let l,I,d;if(r.has("OC")&&(l=await this.parseMarkedContentProps(r.get("OC"),t)),r.get("IM","ImageMask")){const t=r.get("I","Interpolate"),A=g+7>>3,n=e.getBytes(A*c),h=r.getArray("D","Decode");if(this.parsingType3Font){if(I=mE.createRawMask({imgArray:n,width:g,height:c,imageIsFromDecodeStream:e instanceof jl,inverseDecode:h?.[0]>0,interpolate:t}),I.cached=!!s,d=[I],i.addImageOps(Oc,d,l),s){const t={fn:Oc,args:d,optionalContent:l};a.set(s,o,t),o&&this._regionalImageCache.set(null,o,t)}return}if(I=await mE.createMask({imgArray:n,width:g,height:c,imageIsFromDecodeStream:e instanceof jl,inverseDecode:h?.[0]>0,interpolate:t,isOffscreenCanvasSupported:this.options.isOffscreenCanvasSupported}),I.isSingleOpaquePixel){if(i.addImageOps(90,[],l),s){const t={fn:90,args:[],optionalContent:l};a.set(s,o,t),o&&this._regionalImageCache.set(null,o,t)}return}const u=`mask_${this.idFactory.createObjId()}`;if(i.addDependency(u),I.dataLen=I.bitmap?I.width*I.height*4:I.data.length,this._sendImgData(u,I),d=[{data:u,width:I.width,height:I.height,interpolate:I.interpolate,count:1}],i.addImageOps(Oc,d,l),s){const t={objId:u,fn:Oc,args:d,optionalContent:l};a.set(s,o,t),o&&this._regionalImageCache.set(null,o,t)}return}if(A&&g+c<200&&!r.has("SMask")&&!r.has("Mask")){try{const s=new mE({xref:this.xref,res:t,image:e,isInline:A,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:n});I=await s.createImageData(!0,!1),i.isOffscreenCanvasSupported=this.options.isOffscreenCanvasSupported,i.addImageOps(86,[I],l)}catch(t){const e=`Unable to decode inline image: "${t}".`;if(!this.options.ignoreErrors)throw new Error(e);Zc(e)}return}let u=`img_${this.idFactory.createObjId()}`,C=!1;if(this.parsingType3Font?u=`${this.idFactory.getDocId()}_type3_${u}`:s&&o&&(C=this.globalImageCache.shouldCache(o,this.pageIndex),C&&(zc(!A,"Cannot cache an inline image globally."),u=`${this.idFactory.getDocId()}_${u}`)),i.addDependency(u),d=[u,g,c],i.addImageOps(Wc,d,l),C){if(this.globalImageCache.hasDecodeFailed(o))return this.globalImageCache.setData(o,{objId:u,fn:Wc,args:d,optionalContent:l,byteSize:0}),void this._sendImgData(u,null,C);if(g*c>25e4||r.has("SMask")||r.has("Mask")){const t=await this.handler.sendWithPromise("commonobj",[u,"CopyLocalImage",{imageRef:o}]);if(t)return this.globalImageCache.setData(o,{objId:u,fn:Wc,args:d,optionalContent:l,byteSize:0}),void this.globalImageCache.addByteSize(o,t)}}if(mE.buildImage({xref:this.xref,res:t,image:e,isInline:A,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:n}).then((async t=>(I=await t.createImageData(!1,this.options.isOffscreenCanvasSupported),I.dataLen=I.bitmap?I.width*I.height*4:I.data.length,I.ref=o,C&&this.globalImageCache.addByteSize(o,I.dataLen),this._sendImgData(u,I,C)))).catch((t=>(Zc(`Unable to decode image "${u}": "${t}".`),o&&this.globalImageCache.addDecodeFailed(o),this._sendImgData(u,null,C)))),s){const t={objId:u,fn:Wc,args:d,optionalContent:l};a.set(s,o,t),o&&(this._regionalImageCache.set(null,o,t),C&&this.globalImageCache.setData(o,{objId:u,fn:Wc,args:d,optionalContent:l,byteSize:0}))}}handleSMask(t,e,A,i,s,a){const n=t.get("G"),r={subtype:t.get("S").name,backdrop:t.get("BC")},o=t.get("TR");if(SQ(o)){const t=this._pdfFunctionFactory.create(o),e=new Uint8Array(256),A=new Float32Array(1);for(let i=0;i<256;i++)A[0]=i/255,t(A,0,A,0),e[i]=255*A[0]|0;r.transferMap=e}return this.buildFormXObject(e,n,r,A,i,s.state.clone(),a)}handleTransferFunction(t){let e;if(Array.isArray(t))e=t;else{if(!SQ(t))return null;e=[t]}const A=[];let i=0,s=0;for(const t of e){const e=this.xref.fetchIfRef(t);if(i++,Lh(e,"Identity")){A.push(null);continue}if(!SQ(e))return null;const a=this._pdfFunctionFactory.create(e),n=new Uint8Array(256),r=new Float32Array(1);for(let t=0;t<256;t++)r[0]=t/255,a(r,0,r,0),n[t]=255*r[0]|0;A.push(n),s++}return 1!==i&&4!==i||0===s?null:A}handleTilingType(t,e,A,i,s,a,n,r){const o=new EE,g=vh.merge({xref:this.xref,dictArray:[s.get("Resources"),A]});return this.getOperatorList({stream:i,task:n,resources:g,operatorList:o}).then((function(){const A=o.getIR(),i=yB(A,s,e);a.addDependencies(o.dependencies),a.addOp(t,i),s.objId&&r.set(null,s.objId,{operatorListIR:A,dict:s})})).catch((t=>{if(!(t instanceof oh)){if(!this.options.ignoreErrors)throw t;Zc(`handleTilingType - ignoring pattern: "${t}".`)}}))}async handleSetFont(t,e,A,i,s,a,n=null,r=null){const o=e?.[0]instanceof xh?e[0].name:null;let g=await this.loadFont(o,A,t,n,r);if(g.font.isType3Font)try{await g.loadType3Data(this,t,s),i.addDependencies(g.type3Dependencies)}catch(t){g=new xE({loadedName:"g_font_error",font:new dB(`Type3 font load error: ${t}`),dict:g.font,evaluatorOptions:this.options})}return a.font=g.font,g.send(this.handler),g.loadedName}handleText(t,e){const A=e.font,i=A.charsToGlyphs(t);return A.data&&(4&e.textRenderingMode||"Pattern"===e.fillColorSpace.name||A.disableFontFace||this.options.disableFontFace)&&SE.buildFontPaths(A,i,this.handler,this.options),i}ensureStateFont(t){if(t.font)return;const e=new rh("Missing setFont (Tf) operator before text rendering operator.");if(!this.options.ignoreErrors)throw e;Zc(`ensureStateFont: "${e}".`)}async setGState({resources:t,gState:e,operatorList:A,cacheKey:i,task:s,stateManager:a,localGStateCache:n,localColorSpaceCache:r}){const o=e.objId;let g=!0;const c=[];let h=Promise.resolve();for(const i of e.getKeys()){const n=e.get(i);switch(i){case"Type":break;case"LW":case"LC":case"LJ":case"ML":case"D":case"RI":case"FL":case"CA":case"ca":c.push([i,n]);break;case"Font":g=!1,h=h.then((()=>this.handleSetFont(t,null,n[0],A,s,a.state).then((function(t){A.addDependency(t),c.push([i,[t,n[1]]])}))));break;case"BM":c.push([i,wE(n)]);break;case"SMask":if(Lh(n,"None")){c.push([i,!1]);break}n instanceof vh?(g=!1,h=h.then((()=>this.handleSMask(n,t,A,s,a,r))),c.push([i,!0])):Zc("Unsupported SMask type");break;case"TR":const e=this.handleTransferFunction(n);c.push([i,e]);break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":Vc("graphic state operator "+i);break;default:Vc("Unknown graphic state operator "+i)}}await h,c.length>0&&A.addOp(9,[c]),g&&n.set(i,o,c)}loadFont(t,e,A,i=null,s=null){const a=async()=>new xE({loadedName:"g_font_error",font:new dB(`Font "${t}" is not available.`),dict:e,evaluatorOptions:this.options});let n;if(e)e instanceof Nh&&(n=e);else{const e=A.get("Font");e&&(n=e.getRaw(t))}if(n){if(this.type3FontRefs?.has(n))return a();if(this.fontCache.has(n))return this.fontCache.get(n);try{e=this.xref.fetchIfRef(n)}catch(t){Zc(`loadFont - lookup failed: "${t}".`)}}if(!(e instanceof vh)){if(!this.options.ignoreErrors&&!this.parsingType3Font)return Zc(`Font "${t}" is not available.`),a();Zc(`Font "${t}" is not available -- attempting to fallback to a default font.`),e=i||SE.fallbackFontDict}if(e.cacheKey&&this.fontCache.has(e.cacheKey))return this.fontCache.get(e.cacheKey);const{promise:r,resolve:o}=Promise.withResolvers();let g;try{g=this.preEvaluateFont(e),g.cssFontInfo=s}catch(t){return Zc(`loadFont - preEvaluateFont failed: "${t}".`),a()}const{descriptor:c,hash:h}=g,l=n instanceof Nh;let I;if(h&&c instanceof vh){const t=c.fontAliases||=Object.create(null);if(t[h]){const e=t[h].aliasRef;if(l&&e&&this.fontCache.has(e))return this.fontCache.putAlias(n,e),this.fontCache.get(n)}else t[h]={fontID:this.idFactory.createFontId()};l&&(t[h].aliasRef=n),I=t[h].fontID}else I=this.idFactory.createFontId();return zc(I?.startsWith("f"),'The "fontID" must be (correctly) defined.'),l?this.fontCache.put(n,r):(e.cacheKey=`cacheKey_${I}`,this.fontCache.put(e.cacheKey,r)),e.loadedName=`${this.idFactory.getDocId()}_${I}`,this.translateFont(g).then((t=>{o(new xE({loadedName:e.loadedName,font:t,dict:e,evaluatorOptions:this.options}))})).catch((t=>{Zc(`loadFont - translateFont failed: "${t}".`),o(new xE({loadedName:e.loadedName,font:new dB(t instanceof Error?t.message:t),dict:e,evaluatorOptions:this.options}))})),r}buildPath(t,e,A,i=!1){const s=t.length-1;if(A||(A=[]),s<0||91!==t.fnArray[s]){let s;switch(i&&(Zc(`Encountered path operator "${e}" inside of a text object.`),t.addOp(Uc,null)),e){case 19:const t=A[0]+A[2],e=A[1]+A[3];s=[Math.min(A[0],t),Math.min(A[1],e),Math.max(A[0],t),Math.max(A[1],e)];break;case 13:case 14:s=[A[0],A[1],A[0],A[1]];break;default:s=[1/0,1/0,-1/0,-1/0]}t.addOp(91,[[e],A,s]),i&&t.addOp(Hc,null)}else{const i=t.argsArray[s];i[0].push(e),i[1].push(...A);const a=i[2];switch(e){case 19:const t=A[0]+A[2],e=A[1]+A[3];a[0]=Math.min(a[0],A[0],t),a[1]=Math.min(a[1],A[1],e),a[2]=Math.max(a[2],A[0],t),a[3]=Math.max(a[3],A[1],e);break;case 13:case 14:a[0]=Math.min(a[0],A[0]),a[1]=Math.min(a[1],A[1]),a[2]=Math.max(a[2],A[0]),a[3]=Math.max(a[3],A[1])}}}parseColorSpace({cs:t,resources:e,localColorSpaceCache:A}){return xl.parseAsync({cs:t,xref:this.xref,resources:e,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:A}).catch((t=>{if(t instanceof oh)return null;if(this.options.ignoreErrors)return Zc(`parseColorSpace - ignoring ColorSpace: "${t}".`),null;throw t}))}parseShading({shading:t,resources:e,localColorSpaceCache:A,localShadingPatternCache:i}){let s,a=i.get(t);if(a)return a;try{s=uB.parseShading(t,this.xref,e,this._pdfFunctionFactory,A).getIR()}catch(e){if(e instanceof oh)return null;if(this.options.ignoreErrors)return Zc(`parseShading - ignoring shading: "${e}".`),i.set(t,null),null;throw e}return a=`pattern_${this.idFactory.createObjId()}`,this.parsingType3Font&&(a=`${this.idFactory.getDocId()}_type3_${a}`),i.set(t,a),this.parsingType3Font?this.handler.send("commonobj",[a,"Pattern",s]):this.handler.send("obj",[a,this.pageIndex,"Pattern",s]),a}handleColorN(t,e,A,i,s,a,n,r,o,g){const c=A.pop();if(c instanceof xh){const h=s.getRaw(c.name),l=h instanceof Nh&&o.getByRef(h);if(l)try{const s=i.base?i.base.getRgb(A,0):null,a=yB(l.operatorListIR,l.dict,s);return void t.addOp(e,a)}catch{}const I=this.xref.fetchIfRef(h);if(I){const s=I instanceof _h?I.dict:I,c=s.get("PatternType");if(1===c){const r=i.base?i.base.getRgb(A,0):null;return this.handleTilingType(e,r,a,I,s,t,n,o)}if(2===c){const A=s.get("Shading"),i=this.parseShading({shading:A,resources:a,localColorSpaceCache:r,localShadingPatternCache:g});if(i){const A=il(s.getArray("Matrix"),null);t.addOp(e,["Shading",i,A])}return}throw new rh(`Unknown PatternType: ${c}`)}}throw new rh(`Unknown PatternName: ${c}`)}_parseVisibilityExpression(t,e,A){if(++e>10)return void Zc("Visibility expression is too deeply nested");const i=t.length,s=this.xref.fetchIfRef(t[0]);if(!(i<2)&&s instanceof xh){switch(s.name){case"And":case"Or":case"Not":A.push(s.name);break;default:return void Zc(`Invalid operator ${s.name} in visibility expression`)}for(let s=1;s0)return{type:"OCMD",expression:e}}const e=A.get("OCGs");if(Array.isArray(e)||e instanceof vh){const t=[];if(Array.isArray(e))for(const A of e)t.push(A.toString());else t.push(e.objId);return{type:i,ids:t,policy:A.get("P")instanceof xh?A.get("P").name:null,expression:null}}if(e instanceof Nh)return{type:i,id:e.toString()}}return null}getOperatorList({stream:t,task:e,resources:A,operatorList:i,initialState:s=null,fallbackFontDict:a=null}){if(A||=vh.empty,s||=new vE,!i)throw new Error('getOperatorList: missing "operatorList" parameter');const n=this,r=this.xref;let o=!1;const g=new QQ,c=new EQ,h=new pQ,l=new mQ,I=new Map,d=A.get("XObject")||vh.empty,u=A.get("Pattern")||vh.empty,C=new FE(s),B=new NE(t,r,C),Q=new kE;function E(t){for(let t=0,e=B.savedStatesDepth;t0&&i.addOp(9,[e]),t=null;continue}}return void p(new Promise((function(t,s){if(!S)throw new rh("GState must be referred to by name.");const a=A.get("ExtGState");if(!(a instanceof vh))throw new rh("ExtGState should be a dictionary.");const r=a.get(k);if(!(r instanceof vh))throw new rh("GState should be a dictionary.");n.setGState({resources:A,gState:r,operatorList:i,cacheKey:k,task:e,stateManager:C,localGStateCache:h,localColorSpaceCache:c}).then(t,s)})).catch((function(t){if(!(t instanceof oh)){if(!n.options.ignoreErrors)throw t;Zc(`getOperatorList - ignoring ExtGState: "${t}".`)}})));case 13:case 14:case 15:case 16:case 17:case 18:case 19:n.buildPath(i,s,t,o);continue;case 67:case 68:case 72:case 73:continue;case Kc:if(!(t[0]instanceof xh)){Zc(`Expected name for beginMarkedContentProps arg0=${t[0]}`),i.addOp(Kc,["OC",null]);continue}if("OC"===t[0].name)return void p(n.parseMarkedContentProps(t[1],A).then((t=>{i.addOp(Kc,["OC",t])})).catch((t=>{if(!(t instanceof oh)){if(!n.options.ignoreErrors)throw t;Zc(`getOperatorList - ignoring beginMarkedContentProps: "${t}".`),i.addOp(Kc,["OC",null])}})));t=[t[0].name,t[1]instanceof vh?t[1].get("MCID"):null];break;default:if(null!==t){for(b=0,w=t.length;b{if(!(t instanceof oh)){if(!this.options.ignoreErrors)throw t;Zc(`getOperatorList - ignoring errors during "${e.name}" task: "${t}".`),E()}}))}getTextContent({stream:t,task:e,resources:A,stateManager:i=null,includeMarkedContent:s=!1,sink:a,seenStyles:n=new Set,viewBox:r,lang:o=null,markedContentData:g=null,disableNormalization:c=!1,keepWhiteSpace:h=!1}){A||=vh.empty,i||=new FE(new RE),s&&(g||={level:0});const l={items:[],styles:Object.create(null),lang:o},I={initialized:!1,str:[],totalWidth:0,totalHeight:0,width:0,height:0,vertical:!1,prevTransform:null,textAdvanceScale:0,spaceInFlowMin:0,spaceInFlowMax:0,trackingSpaceMin:1/0,negativeSpaceMax:-1/0,notASpace:-1/0,transform:null,fontName:null,hasEOL:!1},d=[" "," "];let u=0;function C(t){const e=(u+1)%2,A=" "!==d[u]&&" "===d[e];return d[u]=t,u=e,!h&&A}function B(){return!h&&" "!==d[u]&&" "===d[(u+1)%2]}function Q(){d[0]=d[1]=" ",u=0}const E=this,f=this.xref,p=[];let m=null;const y=new QQ,b=new pQ,w=new NE(t,f,i);let D;function k({width:t=0,height:e=0,transform:A=I.prevTransform,fontName:i=I.fontName}){l.items.push({str:" ",dir:"ltr",width:t,height:e,transform:A,fontName:i,hasEOL:!1})}function S(){const t=D.font,e=[D.fontSize*D.textHScale,0,0,D.fontSize,0,D.textRise];if(t.isType3Font&&(D.fontSize<=1||t.isCharBBox)&&!fh(D.fontMatrix,bc)){const A=t.bbox[3]-t.bbox[1];A>0&&(e[3]*=A*D.fontMatrix[3])}return uh.transform(D.ctm,uh.transform(D.textMatrix,e))}function x(){if(I.initialized)return I;const{font:t,loadedName:e}=D;if(!n.has(e)&&(n.add(e),l.styles[e]={fontFamily:t.fallbackName,ascent:t.ascent,descent:t.descent,vertical:t.vertical},E.options.fontExtraProperties&&t.systemFontInfo)){const A=l.styles[e];A.fontSubstitution=t.systemFontInfo.css,A.fontSubstitutionLoadedName=t.systemFontInfo.loadedName}I.fontName=e;const A=I.transform=S();t.vertical?(I.width=I.totalWidth=Math.hypot(A[0],A[1]),I.height=I.totalHeight=0,I.vertical=!0):(I.width=I.totalWidth=0,I.height=I.totalHeight=Math.hypot(A[2],A[3]),I.vertical=!1);const i=Math.hypot(D.textLineMatrix[0],D.textLineMatrix[1]),s=Math.hypot(D.ctm[0],D.ctm[1]);I.textAdvanceScale=s*i;const{fontSize:a}=D;return I.trackingSpaceMin=.102*a,I.notASpace=.03*a,I.negativeSpaceMax=-.2*a,I.spaceInFlowMin=.102*a,I.spaceInFlowMax=.6*a,I.hasEOL=!1,I.initialized=!0,I}function F(){if(!I.initialized)return;const t=Math.hypot(D.textLineMatrix[0],D.textLineMatrix[1]),e=Math.hypot(D.ctm[0],D.ctm[1])*t;e!==I.textAdvanceScale&&(I.vertical?(I.totalHeight+=I.height*I.textAdvanceScale,I.height=0):(I.totalWidth+=I.width*I.textAdvanceScale,I.width=0),I.textAdvanceScale=e)}async function R(t,i){const s=await E.loadFont(t,i,A);if(s.font.isType3Font)try{await s.loadType3Data(E,A,e)}catch{}D.loadedName=s.loadedName,D.font=s.font,D.fontMatrix=s.font.fontMatrix||bc}function v(t,e,A){const i=Math.hypot(A[0],A[1]);return[(A[0]*t+A[1]*e)/i,(A[2]*t+A[3]*e)/i]}function N(t){const e=S();let A=e[4],i=e[5];if(D.font?.vertical){if(Ar[2]||i+tr[3])return!1}else if(A+tr[2]||ir[3])return!1;if(!D.font||!I.prevTransform)return!0;let s=I.prevTransform[4],a=I.prevTransform[5];if(s===A&&a===i)return!0;let n=-1;switch(e[0]&&0===e[1]&&0===e[2]?n=e[0]>0?0:180:e[1]&&0===e[0]&&0===e[3]&&(n=e[1]>0?90:270),n){case 0:break;case 90:[A,i]=[i,A],[s,a]=[a,s];break;case 180:[A,i,s,a]=[-A,-i,-s,-a];break;case 270:[A,i]=[-i,-A],[s,a]=[-a,-s];break;default:[A,i]=v(A,i,e),[s,a]=v(s,a,I.prevTransform)}if(D.font.vertical){const t=(a-i)/I.textAdvanceScale,e=A-s,n=Math.sign(I.height);return t.5*I.width?(G(),!0):(Q(),U(),!0):Math.abs(e)>I.width?(G(),!0):(t<=n*I.notASpace&&Q(),t<=n*I.trackingSpaceMin?B()?(Q(),U(),k({height:Math.abs(t)})):I.height+=t:L(t,I.prevTransform,n)||(0===I.str.length?(Q(),k({height:Math.abs(t)})):I.height+=t),Math.abs(e)>.25*I.width&&U(),!0)}const o=(A-s)/I.textAdvanceScale,g=i-a,c=Math.sign(I.width);return o.5*I.height?(G(),!0):(Q(),U(),!0):Math.abs(g)>I.height?(G(),!0):(o<=c*I.notASpace&&Q(),o<=c*I.trackingSpaceMin?B()?(Q(),U(),k({width:Math.abs(o)})):I.width+=o:L(o,I.prevTransform,c)||(0===I.str.length?(Q(),k({width:Math.abs(o)})):I.width+=o),Math.abs(g)>.25*I.height&&U(),!0)}function M({chars:t,extraSpacing:e}){const A=D.font;if(!t){const t=D.charSpacing+e;return t&&(A.vertical?D.translateTextMatrix(0,-t):D.translateTextMatrix(t*D.textHScale,0)),void(h&&N(0))}const i=A.charsToGlyphs(t),s=D.fontMatrix[0]*D.fontSize;for(let t=0,a=i.length;te?e.normalize("NFKC"):yh.get(A)))}(e));const A=tE(e,-1,t.vertical);return{str:A.str,dir:A.dir,width:Math.abs(t.totalWidth),height:Math.abs(t.totalHeight),transform:t.transform,fontName:t.fontName,hasEOL:t.hasEOL}}(I)),I.initialized=!1,I.str.length=0)}function H(t=!1){const e=l.items.length;0===e||t&&e<10||(a.enqueue(l,e),l.items=[],l.styles=Object.create(null))}const J=new kE;return new Promise((function t(I,d){const u=function(e){H(!0),Promise.all([e,a.ready]).then((function(){try{t(I,d)}catch(t){d(t)}}),d)};e.ensureNotTerminated(),J.reset();const C={};let B,Q=[];for(;!(B=J.check())&&(Q.length=0,C.args=Q,w.read(C));){const t=D;D=i.state;const I=C.fn;switch(Q=C.args,0|I){case _c:var k=Q[0].name,S=Q[1];if(D.font&&k===D.fontName&&S===D.fontSize)break;return U(),D.fontName=k,D.fontSize=S,void u(R(k,null));case 39:D.textRise=Q[0];break;case 35:D.textHScale=Q[0]/100;break;case 36:D.leading=Q[0];break;case 40:D.translateTextLineMatrix(Q[0],Q[1]),D.textMatrix=D.textLineMatrix.slice();break;case 41:D.leading=-Q[1],D.translateTextLineMatrix(Q[0],Q[1]),D.textMatrix=D.textLineMatrix.slice();break;case 43:D.carriageReturn();break;case 42:D.setTextMatrix(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]),D.setTextLineMatrix(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]),F();break;case 33:D.charSpacing=Q[0];break;case 34:D.wordSpacing=Q[0];break;case 31:D.textMatrix=yc.slice(),D.textLineMatrix=yc.slice();break;case 45:if(!i.state.font){E.ensureStateFont(i.state);continue}const I=(D.font.vertical?1:-1)*D.fontSize/1e3,d=Q[0];for(let t=0,e=d.length;t0){const t=p.join("");p.length=0,M({chars:t,extraSpacing:0})}break;case Yc:if(!i.state.font){E.ensureStateFont(i.state);continue}M({chars:Q[0],extraSpacing:0});break;case 46:if(!i.state.font){E.ensureStateFont(i.state);continue}D.carriageReturn(),M({chars:Q[0],extraSpacing:0});break;case 47:if(!i.state.font){E.ensureStateFont(i.state);continue}D.wordSpacing=Q[0],D.charSpacing=Q[1],D.carriageReturn(),M({chars:Q[2],extraSpacing:0});break;case 66:U(),m||(m=A.get("XObject")||vh.empty);var x=Q[0]instanceof xh,v=Q[0].name;if(x&&y.getByName(v))break;return void u(new Promise((function(t,l){if(!x)throw new rh("XObject must be referred to by name.");let I=m.getRaw(v);if(I instanceof Nh){if(y.getByRef(I))return void t();if(E.globalImageCache.getData(I,E.pageIndex))return void t();I=f.fetch(I)}if(!(I instanceof _h))throw new rh("XObject should be a stream");const d=I.dict.get("Subtype");if(!(d instanceof xh))throw new rh("XObject should have a Name subtype");if("Form"!==d.name)return y.set(v,I.dict.objId,!0),void t();const u=i.state.clone(),C=new FE(u),B=il(I.dict.getArray("Matrix"),null);B&&C.transform(B),H();const Q={enqueueInvoked:!1,enqueue(t,e){this.enqueueInvoked=!0,a.enqueue(t,e)},get desiredSize(){return a.desiredSize},get ready(){return a.ready}};E.getTextContent({stream:I,task:e,resources:I.dict.get("Resources")||A,stateManager:C,includeMarkedContent:s,sink:Q,seenStyles:n,viewBox:r,lang:o,markedContentData:g,disableNormalization:c,keepWhiteSpace:h}).then((function(){Q.enqueueInvoked||y.set(v,I.dict.objId,!0),t()}),l)})).catch((function(t){if(!(t instanceof oh)){if(!E.options.ignoreErrors)throw t;Zc(`getTextContent - ignoring XObject: "${t}".`)}})));case 9:if(x=Q[0]instanceof xh,v=Q[0].name,x&&b.getByName(v))break;return void u(new Promise((function(t,e){if(!x)throw new rh("GState must be referred to by name.");const i=A.get("ExtGState");if(!(i instanceof vh))throw new rh("ExtGState should be a dictionary.");const s=i.get(v);if(!(s instanceof vh))throw new rh("GState should be a dictionary.");const a=s.get("Font");a?(U(),D.fontName=null,D.fontSize=a[1],R(null,a[0]).then(t,e)):(b.set(v,s.objId,!0),t())})).catch((function(t){if(!(t instanceof oh)){if(!E.options.ignoreErrors)throw t;Zc(`getTextContent - ignoring ExtGState: "${t}".`)}})));case 69:U(),s&&(g.level++,l.items.push({type:"beginMarkedContent",tag:Q[0]instanceof xh?Q[0].name:null}));break;case Kc:if(U(),s){g.level++;let t=null;Q[1]instanceof vh&&(t=Q[1].get("MCID")),l.items.push({type:"beginMarkedContentProps",id:Number.isInteger(t)?`${E.idFactory.getPageObjId()}_mc${t}`:null,tag:Q[0]instanceof xh?Q[0].name:null})}break;case qc:if(U(),s){if(0===g.level)break;g.level--,l.items.push({type:"endMarkedContent"})}break;case Hc:!t||t.font===D.font&&t.fontSize===D.fontSize&&t.fontName===D.fontName||U()}if(l.items.length>=a.desiredSize){B=!0;break}}B?u(bE):(U(),H(),I())})).catch((t=>{if(!(t instanceof oh)){if(!this.options.ignoreErrors)throw t;Zc(`getTextContent - ignoring errors during "${e.name}" task: "${t}".`),U(),H()}}))}async extractDataStructures(t,e){const A=this.xref;let i;const s=this.readToUnicode(e.toUnicode);if(e.composite){const A=t.get("CIDSystemInfo");A instanceof vh&&(e.cidSystemInfo={registry:Bh(A.get("Registry")),ordering:Bh(A.get("Ordering")),supplement:A.get("Supplement")});try{const e=t.get("CIDToGIDMap");e instanceof _h&&(i=e.getBytes())}catch(t){if(!this.options.ignoreErrors)throw t;Zc(`extractDataStructures - ignoring CIDToGIDMap data: "${t}".`)}}const a=[];let n,r=null;if(t.has("Encoding")){if(n=t.get("Encoding"),n instanceof vh){if(r=n.get("BaseEncoding"),r=r instanceof xh?r.name:null,n.has("Differences")){const t=n.get("Differences");let e=0;for(const i of t){const t=A.fetchIfRef(i);if("number"==typeof t)e=t;else{if(!(t instanceof xh))throw new rh(`Invalid entry in 'Differences' array: ${t}`);a[e++]=t.name}}}}else if(n instanceof xh)r=n.name;else{const t="Encoding is not a Name nor a Dict";if(!this.options.ignoreErrors)throw new rh(t);Zc(t)}"MacRomanEncoding"!==r&&"MacExpertEncoding"!==r&&"WinAnsiEncoding"!==r&&(r=null)}const o=!e.file||e.isInternalFont,g=Yu()[e.name];if(r&&o&&g&&(r=null),r)e.defaultEncoding=iu(r);else{const t=!!(4&e.flags),A=!!(32&e.flags);n=$d,"TrueType"!==e.type||A||(n=tu),(t||g)&&(n=zd,o&&(/Symbol/i.test(e.name)?n=eu:/Dingbats/i.test(e.name)?n=Au:/Wingdings/i.test(e.name)&&(n=tu))),e.defaultEncoding=n}e.differences=a,e.baseEncodingName=r,e.hasEncoding=!!r||a.length>0,e.dict=t,e.toUnicode=await s;const c=await this.buildToUnicode(e);return e.toUnicode=c,i&&(e.cidToGidMap=this.readCidToGidMap(i,c)),e}_simpleFontToUnicode(t,e=!1){zc(!t.composite,"Must be a simple font.");const A=[],i=t.defaultEncoding.slice(),s=t.baseEncodingName,a=t.differences;for(const t in a){const e=a[t];".notdef"!==e&&(i[t]=e)}const n=yu();for(const a in i){let r=i[a];if(""===r)continue;let o=n[r];if(void 0!==o){A[a]=String.fromCharCode(o);continue}let g=0;switch(r[0]){case"G":3===r.length&&(g=parseInt(r.substring(1),16));break;case"g":5===r.length&&(g=parseInt(r.substring(1),16));break;case"C":case"c":if(r.length>=3&&r.length<=4){const A=r.substring(1);if(e){g=parseInt(A,16);break}if(g=+A,Number.isNaN(g)&&Number.isInteger(parseInt(A,16)))return this._simpleFontToUnicode(t,!0)}break;case"u":o=Du(r,n),-1!==o&&(g=o);break;default:switch(r){case"f_h":case"f_t":case"T_h":A[a]=r.replaceAll("_","");continue}}if(g>0&&g<=1114111&&Number.isInteger(g)){if(s&&g===+a){const t=iu(s);if(t&&(r=t[a])){A[a]=String.fromCharCode(n[r]);continue}}A[a]=String.fromCodePoint(g)}}return A}async buildToUnicode(t){if(t.hasIncludedToUnicodeMap=t.toUnicode?.length>0,t.hasIncludedToUnicodeMap)return!t.composite&&t.hasEncoding&&(t.fallbackToUnicode=this._simpleFontToUnicode(t)),t.toUnicode;if(!t.composite)return new Wu(this._simpleFontToUnicode(t));if(t.composite&&(t.cMap.builtInCMap&&!(t.cMap instanceof vd)||"Adobe"===t.cidSystemInfo?.registry&&("GB1"===t.cidSystemInfo.ordering||"CNS1"===t.cidSystemInfo.ordering||"Japan1"===t.cidSystemInfo.ordering||"Korea1"===t.cidSystemInfo.ordering))){const{registry:e,ordering:A}=t.cidSystemInfo,i=xh.get(`${e}-${A}-UCS2`),s=await Od.create({encoding:i,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}),a=[],n=[];return t.cMap.forEach((function(t,e){if(e>65535)throw new rh("Max size of CID is 65,535");const A=s.lookup(e);if(A){n.length=0;for(let t=0,e=A.length;t>1;(0!==s||e.has(a))&&(A[a]=s)}return A}extractWidths(t,e,A){const i=this.xref;let s=[],a=0;const n=[];let r;if(A.composite){const e=t.get("DW");a="number"==typeof e?Math.ceil(e):1e3;const o=t.get("W");if(Array.isArray(o))for(let t=0,e=o.length;t{const e=o.get(t),s=new EE;return i.getOperatorList({stream:e,task:A,resources:g,operatorList:s}).then((()=>{49===s.fnArray[0]&&this._removeType3ColorOperators(s,d),c[t]=s.getIR();for(const t of s.dependencies)n.add(t)})).catch((function(e){Zc(`Type3 font resource "${t}" is not available.`);const A=new EE;c[t]=A.getIR()}))}));return this.type3Loaded=r.then((()=>{a.charProcOperatorList=c,this._bbox&&(a.isCharBBox=!0,a.bbox=this._bbox)})),this.type3Loaded}_removeType3ColorOperators(t,e=NaN){const A=uh.normalizeRect(t.argsArray[0].slice(2)),i=A[2]-A[0],s=A[3]-A[1],a=Math.hypot(i,s);0===i||0===s?(t.fnArray.splice(0,1),t.argsArray.splice(0,1)):(0===e||Math.round(a/e)>=10)&&(this._bbox||(this._bbox=[1/0,1/0,-1/0,-1/0]),this._bbox[0]=Math.min(this._bbox[0],A[0]),this._bbox[1]=Math.min(this._bbox[1],A[1]),this._bbox[2]=Math.max(this._bbox[2],A[2]),this._bbox[3]=Math.max(this._bbox[3],A[3]));let n=0,r=t.length;for(;n=13&&a<=28,s.variableArgs)r>n&&Vc(`Command ${i}: expected [0, ${n}] args, but received ${r} args.`);else{if(r!==n){const t=this.nonProcessedArgs;for(;r>n;)t.push(e.shift()),r--;for(;rNE.MAX_INVALID_PATH_OPS)throw new rh(`Invalid ${t}`);Zc(`Skipping ${t}`),null!==e&&(e.length=0);continue}}return this.preprocessCommand(a,e),t.fn=a,t.args=e,!0}if(A===wh)return!1;if(null!==A&&(null===e&&(e=[]),e.push(A),e.length>33))throw new rh("Too many arguments")}}preprocessCommand(t,e){switch(0|t){case Uc:this.stateManager.save();break;case Hc:this.stateManager.restore();break;case Jc:this.stateManager.transform(e)}}}class ME extends NE{constructor(t){super(new wl(t))}parse(){const t={fn:0,args:[]},e={fontSize:0,fontName:"",fontColor:new Uint8ClampedArray(3)};try{for(;t.args.length=0,this.read(t);){if(0!==this.savedStatesDepth)continue;const{fn:A,args:i}=t;switch(0|A){case _c:const[t,A]=i;t instanceof xh&&(e.fontName=t.name),"number"==typeof A&&A>0&&(e.fontSize=A);break;case Pc:xl.singletons.rgb.getRgbItem(i,0,e.fontColor,0);break;case 57:xl.singletons.gray.getRgbItem(i,0,e.fontColor,0);break;case 61:xl.singletons.cmyk.getRgbItem(i,0,e.fontColor,0)}}}catch(t){Zc(`parseDefaultAppearance - ignoring errors: "${t}".`)}return e}}function GE(t){return new ME(t).parse()}class LE extends NE{constructor(t,e,A){super(t),this.stream=t,this.evaluatorOptions=e,this.xref=A,this.resources=t.dict?.get("Resources")}parse(){const t={fn:0,args:[]};let e={scaleFactor:1,fontSize:0,fontName:"",fontColor:new Uint8ClampedArray(3),fillColorSpace:xl.singletons.gray},A=!1;const i=[];try{for(;t.args.length=0,!A&&this.read(t);){const{fn:s,args:a}=t;switch(0|s){case Uc:i.push({scaleFactor:e.scaleFactor,fontSize:e.fontSize,fontName:e.fontName,fontColor:e.fontColor.slice(),fillColorSpace:e.fillColorSpace});break;case Hc:e=i.pop()||e;break;case 42:e.scaleFactor*=Math.hypot(a[0],a[1]);break;case _c:const[t,s]=a;t instanceof xh&&(e.fontName=t.name),"number"==typeof s&&s>0&&(e.fontSize=s*e.scaleFactor);break;case 51:e.fillColorSpace=xl.parse({cs:a[0],xref:this.xref,resources:this.resources,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:this._localColorSpaceCache});break;case 54:e.fillColorSpace.getRgbItem(a,0,e.fontColor,0);break;case Pc:xl.singletons.rgb.getRgbItem(a,0,e.fontColor,0);break;case 57:xl.singletons.gray.getRgbItem(a,0,e.fontColor,0);break;case 61:xl.singletons.cmyk.getRgbItem(a,0,e.fontColor,0);break;case Yc:case 45:case 46:case 47:A=!0}}}catch(t){Zc(`parseAppearanceStream - ignoring errors: "${t}".`)}return this.stream.reset(),delete e.scaleFactor,delete e.fillColorSpace,e}get _localColorSpaceCache(){return th(this,"_localColorSpaceCache",new EQ)}get _pdfFunctionFactory(){return th(this,"_pdfFunctionFactory",new wQ({xref:this.xref,isEvalSupported:this.evaluatorOptions.isEvalSupported}))}}function UE(t,e){return t[0]===t[1]&&t[1]===t[2]?`${Bl(t[0]/255)} ${e?"g":"G"}`:Array.from(t,(t=>Bl(t/255))).join(" ")+" "+(e?"rg":"RG")}class HE{constructor(t,e){this.xref=t,this.widths=null,this.firstChar=1/0,this.lastChar=-1/0,this.fontFamily=e;const A=new OffscreenCanvas(1,1);this.ctxMeasure=A.getContext("2d",{willReadFrequently:!0}),HE._fontNameId||(HE._fontNameId=1),this.fontName=xh.get(`InvalidPDFjsFont_${e}_${HE._fontNameId++}`)}get fontDescriptorRef(){if(!HE._fontDescriptorRef){const t=new vh(this.xref);t.set("Type",xh.get("FontDescriptor")),t.set("FontName",this.fontName),t.set("FontFamily","MyriadPro Regular"),t.set("FontBBox",[0,0,0,0]),t.set("FontStretch",xh.get("Normal")),t.set("FontWeight",400),t.set("ItalicAngle",0),HE._fontDescriptorRef=this.xref.getNewPersistentRef(t)}return HE._fontDescriptorRef}get descendantFontRef(){const t=new vh(this.xref);t.set("BaseFont",this.fontName),t.set("Type",xh.get("Font")),t.set("Subtype",xh.get("CIDFontType0")),t.set("CIDToGIDMap",xh.get("Identity")),t.set("FirstChar",this.firstChar),t.set("LastChar",this.lastChar),t.set("FontDescriptor",this.fontDescriptorRef),t.set("DW",1e3);const e=[],A=[...this.widths.entries()].sort();let i=null,s=null;for(const[t,a]of A)i?t===i+s.length?s.push(a):(e.push(i,s),i=t,s=[a]):(i=t,s=[a]);i&&e.push(i,s),t.set("W",e);const a=new vh(this.xref);return a.set("Ordering","Identity"),a.set("Registry","Adobe"),a.set("Supplement",0),t.set("CIDSystemInfo",a),this.xref.getNewPersistentRef(t)}get baseFontRef(){const t=new vh(this.xref);return t.set("BaseFont",this.fontName),t.set("Type",xh.get("Font")),t.set("Subtype",xh.get("Type0")),t.set("Encoding",xh.get("Identity-H")),t.set("DescendantFonts",[this.descendantFontRef]),t.set("ToUnicode",xh.get("Identity-H")),this.xref.getNewPersistentRef(t)}get resources(){const t=new vh(this.xref),e=new vh(this.xref);return e.set(this.fontName.name,this.baseFontRef),t.set("Font",e),t}_createContext(){return this.widths=new Map,this.ctxMeasure.font=`1000px ${this.fontFamily}`,this.ctxMeasure}createFontResources(t){const e=this._createContext();for(const A of t.split(/\r\n?|\n/))for(const t of A.split("")){const A=t.charCodeAt(0);if(this.widths.has(A))continue;const i=e.measureText(t),s=Math.ceil(i.width);this.widths.set(A,s),this.firstChar=Math.min(A,this.firstChar),this.lastChar=Math.max(A,this.lastChar)}return this.resources}static getFirstPositionInfo(t,e,A){const[i,s,a,n]=t;let r=a-i,o=n-s;e%180!=0&&([r,o]=[o,r]);const g=wc*A;return{coords:[0,o+.35*A-g],bbox:[0,0,r,o],matrix:0!==e?ml(e,o,g):void 0}}createAppearance(t,e,A,i,s,a){const n=this._createContext(),r=[];let o=-1/0;for(const e of t.split(/\r\n?|\n/)){r.push(e);const t=n.measureText(e).width;o=Math.max(o,t);for(const t of ll(e)){const e=String.fromCodePoint(t);let A=this.widths.get(t);if(void 0===A){const i=n.measureText(e);A=Math.ceil(i.width),this.widths.set(t,A),this.firstChar=Math.min(t,this.firstChar),this.lastChar=Math.max(t,this.lastChar)}}}o*=i/1e3;const[g,c,h,l]=e;let I=h-g,d=l-c;A%180!=0&&([I,d]=[d,I]);let u=1;o>I&&(u=I/o);let C=1;const B=wc*i,Q=.35*i,E=B*r.length;E>d&&(C=d/E);const f=i*Math.min(u,C),p=["q",`0 0 ${Bl(I)} ${Bl(d)} re W n`,"BT",`1 0 0 1 0 ${Bl(d+Q)} Tm 0 Tc ${UE(s,!0)}`,`/${this.fontName.name} ${Bl(f)} Tf`],{resources:m}=this;if(1!==(a="number"==typeof a&&a>=0&&a<=1?a:1)){p.push("/R0 gs");const t=new vh(this.xref),e=new vh(this.xref);e.set("ca",a),e.set("CA",a),e.set("Type",xh.get("ExtGState")),t.set("R0",e),m.set("ExtGState",t)}const y=Bl(B);for(const t of r)p.push(`0 -${y} Td <${fl(t)}> Tj`);p.push("ET","Q");const b=p.join("\n"),w=new vh(this.xref);if(w.set("Subtype",xh.get("Form")),w.set("Type",xh.get("XObject")),w.set("BBox",[0,0,I,d]),w.set("Length",b.length),w.set("Resources",m),A){const t=ml(A,I,d);w.set("Matrix",t)}const D=new wl(b);return D.dict=w,D}}class JE{constructor(t,e,A){this.constructor===JE&&Xc("Cannot initialize NameOrNumberTree."),this.root=t,this.xref=e,this._type=A}getAll(){const t=new Map;if(!this.root)return t;const e=this.xref,A=new Mh;A.put(this.root);const i=[this.root];for(;i.length>0;){const s=e.fetchIfRef(i.shift());if(!(s instanceof vh))continue;if(s.has("Kids")){const t=s.get("Kids");if(!Array.isArray(t))continue;for(const e of t){if(A.has(e))throw new rh(`Duplicate entry in "${this._type}" tree.`);i.push(e),A.put(e)}continue}const a=s.get(this._type);if(Array.isArray(a))for(let A=0,i=a.length;A10)return Zc(`Search depth limit reached for "${this._type}" tree.`),null;const s=A.get("Kids");if(!Array.isArray(s))return null;let a=0,n=s.length-1;for(;a<=n;){const i=a+n>>1,r=e.fetchIfRef(s[i]),o=r.get("Limits");if(te.fetchIfRef(o[1]))){A=r;break}a=i+1}}if(a>n)return null}const s=A.get(this._type);if(Array.isArray(s)){let A=0,i=s.length-2;for(;A<=i;){const a=A+i>>1,n=a+(1&a),r=e.fetchIfRef(s[n]);if(tr))return e.fetchIfRef(s[n+1]);A=n+2}}}return null}}class _E extends JE{constructor(t,e){super(t,e,"Names")}}class YE extends JE{constructor(t,e){super(t,e,"Nums")}}function TE(){EB=Object.create(null),Dh=Object.create(null),kh=Object.create(null),Sh=Object.create(null),Fu.clear(),Ed.cleanup()}function PE(t){return t instanceof vh?t.has("UF")?t.get("UF"):t.has("F")?t.get("F"):t.has("Unix")?t.get("Unix"):t.has("Mac")?t.get("Mac"):t.has("DOS")?t.get("DOS"):null:null}class KE{#vr=!1;constructor(t,e,A=!1){t instanceof vh&&(this.xref=e,this.root=t,t.has("FS")&&(this.fs=t.get("FS")),t.has("RF")&&Zc("Related file specifications are not supported"),A||(t.has("EF")?this.#vr=!0:Zc("Non-embedded file specifications are not supported")))}get filename(){let t="";const e=PE(this.root);return e&&"string"==typeof e&&(t=Bh(e).replaceAll("\\\\","\\").replaceAll("\\/","/").replaceAll("\\","/")),th(this,"filename",t||"unnamed")}get content(){if(!this.#vr)return null;this._contentRef||=PE(this.root?.get("EF"));let t=null;if(this._contentRef){const e=this.xref.fetchIfRef(this._contentRef);e instanceof _h?t=e.getBytes():Zc("Embedded file specification points to non-existing/invalid content")}else Zc("Embedded file specification does not have any content");return t}get description(){let t="";const e=this.root?.get("Desc");return e&&"string"==typeof e&&(t=Bh(e)),th(this,"description",t)}get serializable(){return{rawFilename:this.filename,filename:(t=this.filename,t.substring(t.lastIndexOf("/")+1)),content:this.content,description:this.description};var t}}function qE(t,e){const A=t[e];return" "===A||"\n"===A||"\r"===A||"\t"===A}class OE{_resolveEntities(t){return t.replaceAll(/&([^;]+);/g,((t,e)=>{if("#x"===e.substring(0,2))return String.fromCodePoint(parseInt(e.substring(2),16));if("#"===e.substring(0,1))return String.fromCodePoint(parseInt(e.substring(1),10));switch(e){case"lt":return"<";case"gt":return">";case"amp":return"&";case"quot":return'"';case"apos":return"'"}return this.onResolveEntity(e)}))}_parseContent(t,e){const A=[];let i=e;function s(){for(;i"!==t[i]&&"/"!==t[i];)++i;const a=t.substring(e,i);for(s();i"!==t[i]&&"/"!==t[i]&&"?"!==t[i];){s();let e="",a="";for(;i"!==t[A]&&"?"!==t[A]&&"/"!==t[A];)++A;const i=t.substring(e,A);!function(){for(;A"!==t[A+1]);)++A;return{name:i,value:t.substring(s,A),parsed:A-e}}parseXml(t){let e=0;for(;e",A),e<0)return void this.onError(-9);this.onEndElement(t.substring(A,e)),A=e+1;break;case"?":++A;const i=this._parseProcessingInstruction(t,A);if("?>"!==t.substring(A+i.parsed,A+i.parsed+2))return void this.onError(-3);this.onPi(i.name,i.value),A+=i.parsed+2;break;case"!":if("--"===t.substring(A+1,A+3)){if(e=t.indexOf("--\x3e",A+3),e<0)return void this.onError(-5);this.onComment(t.substring(A+3,e)),A=e+3}else if("[CDATA["===t.substring(A+1,A+8)){if(e=t.indexOf("]]>",A+8),e<0)return void this.onError(-2);this.onCdata(t.substring(A+8,e)),A=e+3}else{if("DOCTYPE"!==t.substring(A+1,A+8))return void this.onError(-6);{const i=t.indexOf("[",A+8);let s=!1;if(e=t.indexOf(">",A+8),e<0)return void this.onError(-4);if(i>0&&e>i){if(e=t.indexOf("]>",A+8),e<0)return void this.onError(-4);s=!0}const a=t.substring(A+8,e+(s?1:0));this.onDoctype(a),A=e+(s?2:1)}}break;default:const s=this._parseContent(t,A);if(null===s)return void this.onError(-6);let a=!1;if("/>"===t.substring(A+s.parsed,A+s.parsed+2))a=!0;else if(">"!==t.substring(A+s.parsed,A+s.parsed+1))return void this.onError(-9);this.onBeginElement(s.name,s.attributes,a),A+=s.parsed+(a?2:1)}}else{for(;A0}searchNode(t,e){if(e>=t.length)return this;const A=t[e];if(A.name.startsWith("#")&&e0)i.push([s,0]),s=s.childNodes[0];else{if(0===i.length)return null;for(;0!==i.length;){const[t,e]=i.pop(),A=e+1;if(A");for(const e of this.childNodes)e.dump(t);t.push(``)}else this.nodeValue?t.push(`>${Il(this.nodeValue)}`):t.push("/>")}else t.push(Il(this.nodeValue))}}class jE extends OE{constructor({hasAttributes:t=!1,lowerCaseName:e=!1}){super(),this._currentFragment=null,this._stack=null,this._errorCode=0,this._hasAttributes=t,this._lowerCaseName=e}parseFromString(t){if(this._currentFragment=[],this._stack=[],this._errorCode=0,this.parseXml(t),0!==this._errorCode)return;const[e]=this._currentFragment;return e?{documentElement:e}:void 0}onText(t){if(function(t){for(let e=0,A=t.length;e\\376\\377([^<]+)/g,(function(t,e){const A=e.replaceAll(/\\([0-3])([0-7])([0-7])/g,(function(t,e,A,i){return String.fromCharCode(64*e+8*A+1*i)})).replaceAll(/&(amp|apos|gt|lt|quot);/g,(function(t,e){switch(e){case"amp":return"&";case"apos":return"'";case"gt":return">";case"lt":return"<";case"quot":return'"'}throw new Error(`_repair: ${e} isn't defined.`)})),i=[">"];for(let t=0,e=A.length;t=32&&e<127&&60!==e&&62!==e&&38!==e?i.push(String.fromCharCode(e)):i.push("&#x"+(65536+e).toString(16).substring(1)+";")}return i.join("")}))}_getSequence(t){const e=t.nodeName;return"rdf:bag"!==e&&"rdf:seq"!==e&&"rdf:alt"!==e?null:t.childNodes.filter((t=>"rdf:li"===t.nodeName))}_parseArray(t){if(!t.hasChildNodes())return;const[e]=t.childNodes,A=this._getSequence(e)||[];this._metadataMap.set(t.nodeName,A.map((t=>t.textContent.trim())))}_parse(t){let e=t.documentElement;if("rdf:rdf"!==e.nodeName)for(e=e.firstChild;e&&"rdf:rdf"!==e.nodeName;)e=e.nextSibling;if(e&&"rdf:rdf"===e.nodeName&&e.hasChildNodes())for(const t of e.childNodes)if("rdf:description"===t.nodeName)for(const e of t.childNodes){const t=e.nodeName;switch(t){case"#text":continue;case"dc:creator":case"dc:subject":this._parseArray(e);continue}this._metadataMap.set(t,e.textContent.trim())}}get serializable(){return{parsedData:this._metadataMap,rawData:this._data}}}class ZE extends jl{constructor(t,e,A){super(e),this.str=t,this.dict=t.dict,this.decrypt=A,this.nextChunk=null,this.initialized=!1}readBlock(){let t;if(this.initialized?t=this.nextChunk:(t=this.str.getBytes(512),this.initialized=!0),!t||0===t.length)return void(this.eof=!0);this.nextChunk=this.str.getBytes(512);const e=this.nextChunk?.length>0;t=(0,this.decrypt)(t,!e);const A=this.bufferLength,i=A+t.length;this.ensureBuffer(i).set(t,A),this.bufferLength=i}}class XE{constructor(t){this.a=0,this.b=0;const e=new Uint8Array(256),A=t.length;for(let t=0;t<256;++t)e[t]=t;for(let i=0,s=0;i<256;++i){const a=e[i];s=s+a+t[i%A]&255,e[i]=e[s],e[s]=a}this.s=e}encryptBlock(t){let e=this.a,A=this.b;const i=this.s,s=t.length,a=new Uint8Array(s);for(let n=0;n>5&255,c[h++]=s>>13&255,c[h++]=s>>21&255,c[h++]=s>>>29&255,c[h++]=0,c[h++]=0,c[h++]=0;const d=new Int32Array(16);for(h=0;h>>32-r)|0,s=a}a=a+s|0,n=n+g|0,r=r+I|0,o=o+u|0}return new Uint8Array([255&a,a>>8&255,a>>16&255,a>>>24&255,255&n,n>>8&255,n>>16&255,n>>>24&255,255&r,r>>8&255,r>>16&255,r>>>24&255,255&o,o>>8&255,o>>16&255,o>>>24&255])}}();class $E{constructor(t,e){this.high=0|t,this.low=0|e}and(t){this.high&=t.high,this.low&=t.low}xor(t){this.high^=t.high,this.low^=t.low}or(t){this.high|=t.high,this.low|=t.low}shiftRight(t){t>=32?(this.low=this.high>>>t-32|0,this.high=0):(this.low=this.low>>>t|this.high<<32-t,this.high=this.high>>>t|0)}shiftLeft(t){t>=32?(this.high=this.low<>>32-t,this.low<<=t)}rotateRight(t){let e,A;32&t?(A=this.low,e=this.high):(e=this.low,A=this.high),t&=31,this.low=e>>>t|A<<32-t,this.high=A>>>t|e<<32-t}not(){this.high=~this.high,this.low=~this.low}add(t){const e=(this.low>>>0)+(t.low>>>0);let A=(this.high>>>0)+(t.high>>>0);e>4294967295&&(A+=1),this.low=0|e,this.high=0|A}copyTo(t,e){t[e]=this.high>>>24&255,t[e+1]=this.high>>16&255,t[e+2]=this.high>>8&255,t[e+3]=255&this.high,t[e+4]=this.low>>>24&255,t[e+5]=this.low>>16&255,t[e+6]=this.low>>8&255,t[e+7]=255&this.low}assign(t){this.high=t.high,this.low=t.low}}const tf=function(){function t(t,e){return t>>>e|t<<32-e}function e(t,e,A){return t&e^~t&A}function A(t,e,A){return t&e^t&A^e&A}function i(e){return t(e,2)^t(e,13)^t(e,22)}function s(e){return t(e,6)^t(e,11)^t(e,25)}function a(e){return t(e,7)^t(e,18)^e>>>3}const n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];return function(r,o,g){let c=1779033703,h=3144134277,l=1013904242,I=2773480762,d=1359893119,u=2600822924,C=528734635,B=1541459225;const Q=64*Math.ceil((g+9)/64),E=new Uint8Array(Q);let f,p;for(f=0;f>>29&255,E[f++]=g>>21&255,E[f++]=g>>13&255,E[f++]=g>>5&255,E[f++]=g<<3&255;const y=new Uint32Array(64);for(f=0;f>>10)+y[p-7]+a(y[p-15])+y[p-16]|0;let r,o,g=c,Q=h,m=l,w=I,D=d,k=u,S=C,x=B;for(p=0;p<64;++p)r=x+s(D)+e(D,k,S)+n[p]+y[p],o=i(g)+A(g,Q,m),x=S,S=k,k=D,D=w+r|0,w=m,m=Q,Q=g,g=r+o|0;c=c+g|0,h=h+Q|0,l=l+m|0,I=I+w|0,d=d+D|0,u=u+k|0,C=C+S|0,B=B+x|0}var b;return new Uint8Array([c>>24&255,c>>16&255,c>>8&255,255&c,h>>24&255,h>>16&255,h>>8&255,255&h,l>>24&255,l>>16&255,l>>8&255,255&l,I>>24&255,I>>16&255,I>>8&255,255&I,d>>24&255,d>>16&255,d>>8&255,255&d,u>>24&255,u>>16&255,u>>8&255,255&u,C>>24&255,C>>16&255,C>>8&255,255&C,B>>24&255,B>>16&255,B>>8&255,255&B])}}(),ef=function(){function t(t,e,A,i,s){t.assign(e),t.and(A),s.assign(e),s.not(),s.and(i),t.xor(s)}function e(t,e,A,i,s){t.assign(e),t.and(A),s.assign(e),s.and(i),t.xor(s),s.assign(A),s.and(i),t.xor(s)}function A(t,e,A){t.assign(e),t.rotateRight(28),A.assign(e),A.rotateRight(34),t.xor(A),A.assign(e),A.rotateRight(39),t.xor(A)}function i(t,e,A){t.assign(e),t.rotateRight(14),A.assign(e),A.rotateRight(18),t.xor(A),A.assign(e),A.rotateRight(41),t.xor(A)}function s(t,e,A){t.assign(e),t.rotateRight(1),A.assign(e),A.rotateRight(8),t.xor(A),A.assign(e),A.shiftRight(7),t.xor(A)}function a(t,e,A){t.assign(e),t.rotateRight(19),A.assign(e),A.rotateRight(61),t.xor(A),A.assign(e),A.shiftRight(6),t.xor(A)}const n=[new $E(1116352408,3609767458),new $E(1899447441,602891725),new $E(3049323471,3964484399),new $E(3921009573,2173295548),new $E(961987163,4081628472),new $E(1508970993,3053834265),new $E(2453635748,2937671579),new $E(2870763221,3664609560),new $E(3624381080,2734883394),new $E(310598401,1164996542),new $E(607225278,1323610764),new $E(1426881987,3590304994),new $E(1925078388,4068182383),new $E(2162078206,991336113),new $E(2614888103,633803317),new $E(3248222580,3479774868),new $E(3835390401,2666613458),new $E(4022224774,944711139),new $E(264347078,2341262773),new $E(604807628,2007800933),new $E(770255983,1495990901),new $E(1249150122,1856431235),new $E(1555081692,3175218132),new $E(1996064986,2198950837),new $E(2554220882,3999719339),new $E(2821834349,766784016),new $E(2952996808,2566594879),new $E(3210313671,3203337956),new $E(3336571891,1034457026),new $E(3584528711,2466948901),new $E(113926993,3758326383),new $E(338241895,168717936),new $E(666307205,1188179964),new $E(773529912,1546045734),new $E(1294757372,1522805485),new $E(1396182291,2643833823),new $E(1695183700,2343527390),new $E(1986661051,1014477480),new $E(2177026350,1206759142),new $E(2456956037,344077627),new $E(2730485921,1290863460),new $E(2820302411,3158454273),new $E(3259730800,3505952657),new $E(3345764771,106217008),new $E(3516065817,3606008344),new $E(3600352804,1432725776),new $E(4094571909,1467031594),new $E(275423344,851169720),new $E(430227734,3100823752),new $E(506948616,1363258195),new $E(659060556,3750685593),new $E(883997877,3785050280),new $E(958139571,3318307427),new $E(1322822218,3812723403),new $E(1537002063,2003034995),new $E(1747873779,3602036899),new $E(1955562222,1575990012),new $E(2024104815,1125592928),new $E(2227730452,2716904306),new $E(2361852424,442776044),new $E(2428436474,593698344),new $E(2756734187,3733110249),new $E(3204031479,2999351573),new $E(3329325298,3815920427),new $E(3391569614,3928383900),new $E(3515267271,566280711),new $E(3940187606,3454069534),new $E(4118630271,4000239992),new $E(116418474,1914138554),new $E(174292421,2731055270),new $E(289380356,3203993006),new $E(460393269,320620315),new $E(685471733,587496836),new $E(852142971,1086792851),new $E(1017036298,365543100),new $E(1126000580,2618297676),new $E(1288033470,3409855158),new $E(1501505948,4234509866),new $E(1607167915,987167468),new $E(1816402316,1246189591)];return function(r,o,g,c=!1){let h,l,I,d,u,C,B,Q;c?(h=new $E(3418070365,3238371032),l=new $E(1654270250,914150663),I=new $E(2438529370,812702999),d=new $E(355462360,4144912697),u=new $E(1731405415,4290775857),C=new $E(2394180231,1750603025),B=new $E(3675008525,1694076839),Q=new $E(1203062813,3204075428)):(h=new $E(1779033703,4089235720),l=new $E(3144134277,2227873595),I=new $E(1013904242,4271175723),d=new $E(2773480762,1595750129),u=new $E(1359893119,2917565137),C=new $E(2600822924,725511199),B=new $E(528734635,4215389547),Q=new $E(1541459225,327033209));const E=128*Math.ceil((g+17)/128),f=new Uint8Array(E);let p,m;for(p=0;p>>29&255,f[p++]=g>>21&255,f[p++]=g>>13&255,f[p++]=g>>5&255,f[p++]=g<<3&255;const b=new Array(80);for(p=0;p<80;p++)b[p]=new $E(0,0);let w=new $E(0,0),D=new $E(0,0),k=new $E(0,0),S=new $E(0,0),x=new $E(0,0),F=new $E(0,0),R=new $E(0,0),v=new $E(0,0);const N=new $E(0,0),M=new $E(0,0),G=new $E(0,0),L=new $E(0,0);let U,H;for(p=0;p=1;--t){A=a[13],a[13]=a[9],a[9]=a[5],a[5]=a[1],a[1]=A,A=a[14],i=a[10],a[14]=a[6],a[10]=a[2],a[6]=A,a[2]=i,A=a[15],i=a[11],s=a[7],a[15]=a[3],a[11]=A,a[7]=i,a[3]=s;for(let t=0;t<16;++t)a[t]=this._inv_s[a[t]];for(let A=0,i=16*t;A<16;++A,++i)a[A]^=e[i];for(let t=0;t<16;t+=4){const e=this._mix[a[t]],i=this._mix[a[t+1]],s=this._mix[a[t+2]],n=this._mix[a[t+3]];A=e^i>>>8^i<<24^s>>>16^s<<16^n>>>24^n<<8,a[t]=A>>>24&255,a[t+1]=A>>16&255,a[t+2]=A>>8&255,a[t+3]=255&A}}A=a[13],a[13]=a[9],a[9]=a[5],a[5]=a[1],a[1]=A,A=a[14],i=a[10],a[14]=a[6],a[10]=a[2],a[6]=A,a[2]=i,A=a[15],i=a[11],s=a[7],a[15]=a[3],a[11]=A,a[7]=i,a[3]=s;for(let t=0;t<16;++t)a[t]=this._inv_s[a[t]],a[t]^=e[t];return a}_encrypt(t,e){const A=this._s;let i,s,a;const n=new Uint8Array(16);n.set(t);for(let t=0;t<16;++t)n[t]^=e[t];for(let t=1;t=i;--A)if(t[A]!==e){e=0;break}r-=e,a[a.length-1]=t.subarray(0,16-e)}}const o=new Uint8Array(r);for(let t=0,e=0,A=a.length;t=256&&(r=255&(27^r)));for(let e=0;e<4;++e)A[t]=i^=A[t-32],t++,A[t]=s^=A[t-32],t++,A[t]=a^=A[t-32],t++,A[t]=n^=A[t-32],t++}return A}}class rf{checkOwnerPassword(t,e,A,i){const s=new Uint8Array(t.length+56);return s.set(t,0),s.set(e,t.length),s.set(A,t.length+e.length),fh(tf(s,0,s.length),i)}checkUserPassword(t,e,A){const i=new Uint8Array(t.length+8);return i.set(t,0),i.set(e,t.length),fh(tf(i,0,i.length),A)}getOwnerKey(t,e,A,i){const s=new Uint8Array(t.length+56);s.set(t,0),s.set(e,t.length),s.set(A,t.length+e.length);const a=tf(s,0,s.length);return new nf(a).decryptBlock(i,!1,new Uint8Array(16))}getUserKey(t,e,A){const i=new Uint8Array(t.length+8);i.set(t,0),i.set(e,t.length);const s=tf(i,0,i.length);return new nf(s).decryptBlock(A,!1,new Uint8Array(16))}}class of{_hash(t,e,A){let i=tf(e,0,e.length).subarray(0,32),s=[0],a=0;for(;a<64||s.at(-1)>a-32;){const e=t.length+i.length+A.length,o=new Uint8Array(e);let g=0;o.set(t,g),g+=t.length,o.set(i,g),g+=i.length,o.set(A,g);const c=new Uint8Array(64*e);for(let t=0,A=0;t<64;t++,A+=e)c.set(o,A);s=new af(i.subarray(0,16)).encrypt(c,i.subarray(16,32));const h=s.slice(0,16).reduce(((t,e)=>t+e),0)%3;0===h?i=tf(s,0,s.length):1===h?(n=s,r=s.length,i=ef(n,0,r,!0)):2===h&&(i=ef(s,0,s.length)),a++}var n,r;return i.subarray(0,32)}checkOwnerPassword(t,e,A,i){const s=new Uint8Array(t.length+56);return s.set(t,0),s.set(e,t.length),s.set(A,t.length+e.length),fh(this._hash(t,s,A),i)}checkUserPassword(t,e,A){const i=new Uint8Array(t.length+8);return i.set(t,0),i.set(e,t.length),fh(this._hash(t,i,[]),A)}getOwnerKey(t,e,A,i){const s=new Uint8Array(t.length+56);s.set(t,0),s.set(e,t.length),s.set(A,t.length+e.length);const a=this._hash(t,s,A);return new nf(a).decryptBlock(i,!1,new Uint8Array(16))}getUserKey(t,e,A){const i=new Uint8Array(t.length+8);i.set(t,0),i.set(e,t.length);const s=this._hash(t,i,[]);return new nf(s).decryptBlock(A,!1,new Uint8Array(16))}}class gf{constructor(t,e){this.StringCipherConstructor=t,this.StreamCipherConstructor=e}createStream(t,e){const A=new this.StreamCipherConstructor;return new ZE(t,e,(function(t,e){return A.decryptBlock(t,e)}))}decryptString(t){const e=new this.StringCipherConstructor;let A=ch(t);return A=e.decryptBlock(A,!0),gh(A)}encryptString(t){const e=new this.StringCipherConstructor;if(e instanceof sf){const A=16-t.length%16;t+=String.fromCharCode(A).repeat(A);const i=new Uint8Array(16);if("undefined"!=typeof crypto)crypto.getRandomValues(i);else for(let t=0;t<16;t++)i[t]=Math.floor(256*Math.random());let s=ch(t);s=e.encrypt(s,i);const a=new Uint8Array(16+s.length);return a.set(i),a.set(s,16),gh(a)}let A=ch(t);return A=e.encrypt(A),gh(A)}}class cf{static#Nr=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]);#Mr(t,e,A,i,s,a,n,r,o,g,c,h){if(e){const t=Math.min(127,e.length);e=e.subarray(0,t)}else e=[];const l=6===t?new of:new rf;return l.checkUserPassword(e,r,n)?l.getUserKey(e,o,c):e.length&&l.checkOwnerPassword(e,i,a,A)?l.getOwnerKey(e,s,a,g):null}#Gr(t,e,A,i,s,a,n,r){const o=40+A.length+t.length,g=new Uint8Array(o);let c,h,l=0;if(e)for(h=Math.min(32,e.length);l>8&255,g[l++]=s>>16&255,g[l++]=s>>>24&255,c=0,h=t.length;c=4&&!r&&(g[l++]=255,g[l++]=255,g[l++]=255,g[l++]=255);let I=zE(g,0,l);const d=n>>3;if(a>=3)for(c=0;c<50;++c)I=zE(I,0,d);const u=I.subarray(0,d);let C,B;if(a>=3){for(l=0;l<32;++l)g[l]=cf.#Nr[l];for(c=0,h=t.length;c>3;if(A>=3)for(r=0;r<50;++r)o=zE(o,0,o.length);let c,h;if(A>=3){h=e;const t=new Uint8Array(g);for(r=19;r>=0;r--){for(let e=0;e>8&255,s[n++]=t>>16&255,s[n++]=255&e,s[n++]=e>>8&255,i&&(s[n++]=115,s[n++]=65,s[n++]=108,s[n++]=84),zE(s,0,n).subarray(0,Math.min(A.length+5,16))}#Hr(t,e,A,i,s){if(!(e instanceof xh))throw new rh("Invalid crypt filter name.");const a=this,n=t.get(e.name),r=n?.get("CFM");if(!r||"None"===r.name)return function(){return new Af};if("V2"===r.name)return function(){return new XE(a.#Ur(A,i,s,!1))};if("AESV2"===r.name)return function(){return new af(a.#Ur(A,i,s,!0))};if("AESV3"===r.name)return function(){return new nf(s)};throw new rh("Unknown crypto method")}constructor(t,e,A){const i=t.get("Filter");if(!Lh(i,"Standard"))throw new rh("unknown encryption method");this.filterName=i.name,this.dict=t;const s=t.get("V");if(!Number.isInteger(s)||1!==s&&2!==s&&4!==s&&5!==s)throw new rh("unsupported encryption algorithm");this.algorithm=s;let a=t.get("Length");if(!a)if(s<=3)a=40;else{const e=t.get("CF"),A=t.get("StmF");if(e instanceof vh&&A instanceof xh){e.suppressEncryption=!0;const t=e.get(A.name);a=t?.get("Length")||128,a<40&&(a<<=3)}}if(!Number.isInteger(a)||a<40||a%8!=0)throw new rh("invalid key length");const n=ch(t.get("O")),r=ch(t.get("U")),o=n.subarray(0,32),g=r.subarray(0,32),c=t.get("P"),h=t.get("R"),l=(4===s||5===s)&&!1!==t.get("EncryptMetadata");this.encryptMetadata=l;const I=ch(e);let d,u;if(A){if(6===h)try{A=Eh(A)}catch{Zc("CipherTransformFactory: Unable to convert UTF8 encoded password.")}d=ch(A)}if(5!==s)u=this.#Gr(I,d,o,g,c,h,a,l);else{const e=n.subarray(32,40),A=n.subarray(40,48),i=r.subarray(0,48),s=r.subarray(32,40),a=r.subarray(40,48),c=ch(t.get("OE")),l=ch(t.get("UE")),I=ch(t.get("Perms"));u=this.#Mr(h,d,o,e,A,i,g,s,a,c,l,I)}if(!u&&!A)throw new Ah("No password given",1);if(!u&&A){const t=this.#Lr(d,o,h,a);u=this.#Gr(I,t,o,g,c,h,a,l)}if(!u)throw new Ah("Incorrect Password",2);if(this.encryptionKey=u,s>=4){const e=t.get("CF");e instanceof vh&&(e.suppressEncryption=!0),this.cf=e,this.stmf=t.get("StmF")||xh.get("Identity"),this.strf=t.get("StrF")||xh.get("Identity"),this.eff=t.get("EFF")||this.stmf}}createCipherTransform(t,e){if(4===this.algorithm||5===this.algorithm)return new gf(this.#Hr(this.cf,this.strf,t,e,this.encryptionKey),this.#Hr(this.cf,this.stmf,t,e,this.encryptionKey));const A=this.#Ur(t,e,this.encryptionKey,!1),i=function(){return new XE(A)};return new gf(i,i)}}async function hf(t,e,A,{encrypt:i=null}){const s=i?.createCipherTransform(t.num,t.gen);A.push(`${t.num} ${t.gen} obj\n`),e instanceof vh?await lf(e,A,s):e instanceof _h?await If(e,A,s):(Array.isArray(e)||ArrayBuffer.isView(e))&&await df(e,A,s),A.push("\nendobj\n")}async function lf(t,e,A){e.push("<<");for(const i of t.getKeys())e.push(` /${rl(i)} `),await uf(t.getRaw(i),e,A);e.push(">>")}async function If(t,e,A){let i=t.getBytes();const{dict:s}=t,[a,n]=await Promise.all([s.getAsync("Filter"),s.getAsync("DecodeParms")]),r=Lh(Array.isArray(a)?await s.xref.fetchIfRefAsync(a[0]):a,"FlateDecode");if(i.length>=256||r)try{const t=new CompressionStream("deflate"),e=t.writable.getWriter();e.write(i),e.close();const A=await new Response(t.readable).arrayBuffer();let o,g;i=new Uint8Array(A),a?r||(o=Array.isArray(a)?[xh.get("FlateDecode"),...a]:[xh.get("FlateDecode"),a],n&&(g=Array.isArray(n)?[null,...n]:[null,n])):o=xh.get("FlateDecode"),o&&s.set("Filter",o),g&&s.set("DecodeParms",g)}catch(t){Vc(`writeStream - cannot compress data: "${t}".`)}let o=gh(i);A&&(o=A.encryptString(o)),s.set("Length",o.length),await lf(s,e,A),e.push(" stream\n",o,"\nendstream")}async function df(t,e,A){e.push("[");let i=!0;for(const s of t)i?i=!1:e.push(" "),await uf(s,e,A);e.push("]")}async function uf(t,e,A){t instanceof xh?e.push(`/${rl(t.name)}`):t instanceof Nh?e.push(`${t.num} ${t.gen} R`):Array.isArray(t)||ArrayBuffer.isView(t)?await df(t,e,A):"string"==typeof t?(A&&(t=A.encryptString(t)),e.push(`(${ol(t)})`)):"number"==typeof t?e.push(Bl(t)):"boolean"==typeof t?e.push(t.toString()):t instanceof vh?await lf(t,e,A):t instanceof _h?await If(t,e,A):null===t?e.push("null"):Zc(`Unhandled value in writer: ${typeof t}, please file a bug.`)}function Cf(t,e,A,i){for(let s=e+A-1;s>A-1;s--)i[s]=255&t,t>>=8;return A+e}function Bf(t,e,A){for(let i=0,s=t.length;i0){const i=function(t,e){const A=Math.floor(Date.now()/1e3),i=e.filename||"",s=[A.toString(),i,t.toString()];let a=s.reduce(((t,e)=>t+e.length),0);for(const t of Object.values(e.info))s.push(t),a+=t.length;const n=new Uint8Array(a);let r=0;for(const t of s)Bf(t,r,n),r+=t.length;return gh(zE(n))}(t,e);A.set("ID",[e.fileIds[0],i])}}class ff{constructor(t,e){this.dict=t,this.ref=e instanceof Nh?e:null,this.roleMap=new Map,this.structParentIds=null}init(){this.readRoleMap()}#Jr(t,e,A){if(!(t instanceof Nh)||e<0)return;this.structParentIds||=new Gh;let i=this.structParentIds.get(t);i||(i=[],this.structParentIds.put(t,i)),i.push([e,A])}addAnnotationIdToPage(t,e){this.#Jr(t,e,4)}readRoleMap(){const t=this.dict.get("RoleMap");t instanceof vh&&t.forEach(((t,e)=>{e instanceof xh&&this.roleMap.set(t,e.name)}))}static async canCreateStructureTree({catalogRef:t,pdfManager:e,newAnnotationsByPage:A}){if(!(t instanceof Nh))return Zc("Cannot save the struct tree: no catalog reference."),!1;let i=0,s=!0;for(const[t,a]of A){const{ref:A}=await e.getPage(t);if(!(A instanceof Nh)){Zc(`Cannot save the struct tree: page ${t} has no ref.`),s=!0;break}for(const t of a)t.accessibilityData?.type&&(t.parentTreeId=i++,s=!1)}if(s){for(const t of A.values())for(const e of t)delete e.parentTreeId;return!1}return!0}static async createStructureTree({newAnnotationsByPage:t,xref:e,catalogRef:A,pdfManager:i,newRefs:s}){const a=i.catalog.cloneDict(),n=new Gh;n.put(A,a);const r=e.getNewTemporaryRef();a.set("StructTreeRoot",r);const o=new vh(e);o.set("Type",xh.get("StructTreeRoot"));const g=e.getNewTemporaryRef();o.set("ParentTree",g);const c=[];o.set("K",c),n.put(r,o);const h=new vh(e),l=[];h.set("Nums",l);const I=await this.#_r({newAnnotationsByPage:t,structTreeRootRef:r,kids:c,nums:l,xref:e,pdfManager:i,cache:n});o.set("ParentTreeNextKey",I),n.put(g,h);const d=[];for(const[t,A]of n.items())d.length=0,await hf(t,A,d,e),s.push({ref:t,data:d.join("")})}async canUpdateStructTree({pdfManager:t,xref:e,newAnnotationsByPage:A}){if(!this.ref)return Zc("Cannot update the struct tree: no root reference."),!1;let i=this.dict.get("ParentTreeNextKey");if(!Number.isInteger(i)||i<0)return Zc("Cannot update the struct tree: invalid next key."),!1;const s=this.dict.get("ParentTree");if(!(s instanceof vh))return Zc("Cannot update the struct tree: ParentTree isn't a dict."),!1;const a=s.get("Nums");if(!Array.isArray(a))return Zc("Cannot update the struct tree: nums isn't an array."),!1;const n=new YE(s,e);for(const e of A.keys()){const{pageDict:A}=await t.getPage(e);if(!A.has("StructParents"))continue;const i=A.get("StructParents");if(!Number.isInteger(i)||!Array.isArray(n.get(i)))return Zc(`Cannot save the struct tree: page ${e} has a wrong id.`),!1}let r=!0;for(const[e,s]of A){const{pageDict:A}=await t.getPage(e);ff.#Yr({elements:s,xref:this.dict.xref,pageDict:A,numberTree:n});for(const t of s)t.accessibilityData?.type&&(t.parentTreeId=i++,r=!1)}if(r){for(const t of A.values())for(const e of t)delete e.parentTreeId,delete e.structTreeParent;return!1}return!0}async updateStructureTree({newAnnotationsByPage:t,pdfManager:e,newRefs:A}){const i=this.dict.xref,s=this.dict.clone(),a=this.ref,n=new Gh;n.put(a,s);let r,o=s.getRaw("ParentTree");o instanceof Nh?r=i.fetch(o):(r=o,o=i.getNewTemporaryRef(),s.set("ParentTree",o)),r=r.clone(),n.put(o,r);let g=r.getRaw("Nums"),c=null;g instanceof Nh&&(c=g,g=i.fetch(c)),g=g.slice(),c||r.set("Nums",g);const h=await ff.#_r({newAnnotationsByPage:t,structTreeRootRef:a,kids:null,nums:g,xref:i,pdfManager:e,cache:n});s.set("ParentTreeNextKey",h),c&&n.put(c,g);const l=[];for(const[t,e]of n.items())l.length=0,await hf(t,e,l,i),A.push({ref:t,data:l.join("")})}static async#_r({newAnnotationsByPage:t,structTreeRootRef:e,kids:A,nums:i,xref:s,pdfManager:a,cache:n}){const r=xh.get("OBJR");let o=-1/0;for(const[g,c]of t){const{ref:t}=await a.getPage(g),h=t instanceof Nh;for(const{accessibilityData:a,ref:g,parentTreeId:l,structTreeParent:I}of c){if(!a?.type)continue;const{type:c,title:d,lang:u,alt:C,expanded:B,actualText:Q}=a;o=Math.max(o,l);const E=s.getNewTemporaryRef(),f=new vh(s);f.set("S",xh.get(c)),d&&f.set("T",El(d)),u&&f.set("Lang",u),C&&f.set("Alt",El(C)),B&&f.set("E",El(B)),Q&&f.set("ActualText",El(Q)),await this.#Tr({structTreeParent:I,tagDict:f,newTagRef:E,structTreeRootRef:e,fallbackKids:A,xref:s,cache:n});const p=new vh(s);f.set("K",p),p.set("Type",r),h&&p.set("Pg",t),p.set("Obj",g),n.put(E,f),i.push(l,E)}}return o+1}static#Yr({elements:t,xref:e,pageDict:A,numberTree:i}){const s=new Map;for(const e of t)if(e.structTreeParentId){const t=parseInt(e.structTreeParentId.split("_mc")[1],10);let A=s.get(t);A||(A=[],s.set(t,A)),A.push(e)}const a=A.get("StructParents");if(!Number.isInteger(a))return;const n=i.get(a),r=(t,A,i)=>{const a=s.get(t);if(a){const t=A.getRaw("P"),s=e.fetchIfRef(t);if(t instanceof Nh&&s instanceof vh){const t={ref:i,dict:A};for(const e of a)e.structTreeParent=t}return!0}return!1};for(const t of n){if(!(t instanceof Nh))continue;const A=e.fetch(t),i=A.get("K");if(Number.isInteger(i))r(i,A,t);else if(Array.isArray(i))for(let s of i){if(s=e.fetchIfRef(s),Number.isInteger(s)&&r(s,A,t))break;if(!(s instanceof vh))continue;if(!Lh(s.get("Type"),"MCR"))break;const i=s.get("MCID");if(Number.isInteger(i)&&r(i,A,t))break}}}static async#Tr({structTreeParent:t,tagDict:e,newTagRef:A,structTreeRootRef:i,fallbackKids:s,xref:a,cache:n}){let r,o=null;t?(({ref:o}=t),r=t.dict.getRaw("P")||i):r=i,e.set("P",r);const g=a.fetchIfRef(r);if(!g)return void s.push(A);let c=n.get(r);c||(c=g.clone(),n.put(r,c));const h=c.getRaw("K");let l=h instanceof Nh?n.get(h):null;if(!l){l=a.fetchIfRef(h),l=Array.isArray(l)?l.slice():[h];const t=a.getNewTemporaryRef();c.set("K",t),n.put(t,l)}const I=l.indexOf(o);l.splice(I>=0?I+1:l.length,0,A)}}class pf{constructor(t,e){this.tree=t,this.dict=e,this.kids=[],this.parseKids()}get role(){const t=this.dict.get("S"),e=t instanceof xh?t.name:"",{root:A}=this.tree;return A.roleMap.has(e)?A.roleMap.get(e):e}parseKids(){let t=null;const e=this.dict.getRaw("Pg");e instanceof Nh&&(t=e.toString());const A=this.dict.get("K");if(Array.isArray(A))for(const e of A){const A=this.parseKid(t,e);A&&this.kids.push(A)}else{const e=this.parseKid(t,A);e&&this.kids.push(e)}}parseKid(t,e){if(Number.isInteger(e))return this.tree.pageDict.objId!==t?null:new mf({type:1,mcid:e,pageObjId:t});let A=null;if(e instanceof Nh?A=this.dict.xref.fetch(e):e instanceof vh&&(A=e),!A)return null;const i=A.getRaw("Pg");i instanceof Nh&&(t=i.toString());const s=A.get("Type")instanceof xh?A.get("Type").name:null;if("MCR"===s){if(this.tree.pageDict.objId!==t)return null;const e=A.getRaw("Stm");return new mf({type:2,refObjId:e instanceof Nh?e.toString():null,pageObjId:t,mcid:A.get("MCID")})}if("OBJR"===s){if(this.tree.pageDict.objId!==t)return null;const e=A.getRaw("Obj");return new mf({type:3,refObjId:e instanceof Nh?e.toString():null,pageObjId:t})}return new mf({type:5,dict:A})}}class mf{constructor({type:t,dict:e=null,mcid:A=null,pageObjId:i=null,refObjId:s=null}){this.type=t,this.dict=e,this.mcid=A,this.pageObjId=i,this.refObjId=s,this.parentNode=null}}class yf{constructor(t,e){this.root=t,this.rootDict=t?t.dict:null,this.pageDict=e,this.nodes=[]}parse(t){if(!this.root||!this.rootDict)return;const e=this.rootDict.get("ParentTree");if(!e)return;const A=this.pageDict.get("StructParents"),i=t instanceof Nh&&this.root.structParentIds?.get(t);if(!Number.isInteger(A)&&!i)return;const s=new Map,a=new YE(e,this.rootDict.xref);if(Number.isInteger(A)){const t=a.get(A);if(Array.isArray(t))for(const e of t)e instanceof Nh&&this.addNode(this.rootDict.xref.fetch(e),s)}if(i)for(const[t,e]of i){const A=a.get(t);if(A){const t=this.addNode(this.rootDict.xref.fetchIfRef(A),s);1===t?.kids?.length&&3===t.kids[0].type&&(t.kids[0].type=e)}}}addNode(t,e,A=0){if(A>40)return Zc("StructTree MAX_DEPTH reached."),null;if(e.has(t))return e.get(t);const i=new pf(this,t);e.set(t,i);const s=t.get("P");if(!s||Lh(s.get("Type"),"StructTreeRoot"))return this.addTopLevelNode(t,i)||e.delete(t),i;const a=this.addNode(s,e,A+1);if(!a)return i;let n=!1;for(const e of a.kids)5===e.type&&e.dict===t&&(e.parentNode=i,n=!0);return n||e.delete(t),i}addTopLevelNode(t,e){const A=this.rootDict.get("K");if(!A)return!1;if(A instanceof vh)return A.objId===t.objId&&(this.nodes[0]=e,!0);if(!Array.isArray(A))return!0;let i=!1;for(let s=0;s40)return void Zc("StructTree too deep to be fully serialized.");const s=Object.create(null);s.role=e.role,s.children=[],A.children.push(s);const a=e.dict.get("Alt");"string"==typeof a&&(s.alt=Bh(a));const n=e.dict.get("Lang");"string"==typeof n&&(s.lang=Bh(n));for(const A of e.kids){const e=5===A.type?A.parentNode:null;e?t(e,s,i+1):1===A.type||2===A.type?s.children.push({type:"content",id:`p${A.pageObjId}_mc${A.mcid}`}):3===A.type?s.children.push({type:"object",id:A.refObjId}):4===A.type&&s.children.push({type:"annotation",id:`pdfjs_internal_id_${A.refObjId}`})}}const e=Object.create(null);e.children=[],e.role="Root";for(const A of this.nodes)A&&t(A,e);return e}}function bf(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,A,...i]=t;if(!(e instanceof Nh||Number.isInteger(e)))return!1;if(!(A instanceof xh))return!1;const s=i.length;let a=!0;switch(A.name){case"XYZ":if(s<2||s>3)return!1;break;case"Fit":case"FitB":return 0===s;case"FitH":case"FitBH":case"FitV":case"FitBV":if(s>1)return!1;break;case"FitR":if(4!==s)return!1;a=!1;break;default:return!1}for(const t of i)if(!("number"==typeof t||a&&null===t))return!1;return!0}function wf(t){return t instanceof vh&&(t=t.get("D")),bf(t)?t:null}function Df(t){let e=t.get("D");if(e){if(e instanceof xh&&(e=e.name),"string"==typeof e)return Bh(e);if(bf(e))return JSON.stringify(e)}return null}class kf{constructor(t,e){if(this.pdfManager=t,this.xref=e,this._catDict=e.getCatalogObj(),!(this._catDict instanceof vh))throw new rh("Catalog object is not a dictionary.");this.toplevelPagesDict,this._actualNumPages=null,this.fontCache=new Gh,this.builtInCMapCache=new Map,this.standardFontDataCache=new Map,this.globalImageCache=new bQ,this.pageKidsCountCache=new Gh,this.pageIndexCache=new Gh,this.nonBlendModesSet=new Mh,this.systemFontCache=new Map}cloneDict(){return this._catDict.clone()}get version(){const t=this._catDict.get("Version");if(t instanceof xh){if(Yh.test(t.name))return th(this,"version",t.name);Zc(`Invalid PDF catalog version: ${t.name}`)}return th(this,"version",null)}get lang(){const t=this._catDict.get("Lang");return th(this,"lang",t&&"string"==typeof t?Bh(t):null)}get needsRendering(){const t=this._catDict.get("NeedsRendering");return th(this,"needsRendering","boolean"==typeof t&&t)}get collection(){let t=null;try{const e=this._catDict.get("Collection");e instanceof vh&&e.size>0&&(t=e)}catch(t){if(t instanceof Ph)throw t;Vc("Cannot fetch Collection entry; assuming no collection is present.")}return th(this,"collection",t)}get acroForm(){let t=null;try{const e=this._catDict.get("AcroForm");e instanceof vh&&e.size>0&&(t=e)}catch(t){if(t instanceof Ph)throw t;Vc("Cannot fetch AcroForm entry; assuming no forms are present.")}return th(this,"acroForm",t)}get acroFormRef(){const t=this._catDict.getRaw("AcroForm");return th(this,"acroFormRef",t instanceof Nh?t:null)}get metadata(){const t=this._catDict.getRaw("Metadata");if(!(t instanceof Nh))return th(this,"metadata",null);let e=null;try{const A=this.xref.fetch(t,!this.xref.encrypt?.encryptMetadata);if(A instanceof _h&&A.dict instanceof vh){const t=A.dict.get("Type"),i=A.dict.get("Subtype");if(Lh(t,"Metadata")&&Lh(i,"XML")){const t=Qh(A.getString());t&&(e=new VE(t).serializable)}}}catch(t){if(t instanceof Ph)throw t;Vc(`Skipping invalid Metadata: "${t}".`)}return th(this,"metadata",e)}get markInfo(){let t=null;try{t=this._readMarkInfo()}catch(t){if(t instanceof Ph)throw t;Zc("Unable to read mark info.")}return th(this,"markInfo",t)}_readMarkInfo(){const t=this._catDict.get("MarkInfo");if(!(t instanceof vh))return null;const e={Marked:!1,UserProperties:!1,Suspects:!1};for(const A in e){const i=t.get(A);"boolean"==typeof i&&(e[A]=i)}return e}get structTreeRoot(){let t=null;try{t=this._readStructTreeRoot()}catch(t){if(t instanceof Ph)throw t;Zc("Unable read to structTreeRoot info.")}return th(this,"structTreeRoot",t)}_readStructTreeRoot(){const t=this._catDict.getRaw("StructTreeRoot"),e=this.xref.fetchIfRef(t);if(!(e instanceof vh))return null;const A=new ff(e,t);return A.init(),A}get toplevelPagesDict(){const t=this._catDict.get("Pages");if(!(t instanceof vh))throw new rh("Invalid top-level pages dictionary.");return th(this,"toplevelPagesDict",t)}get documentOutline(){let t=null;try{t=this._readDocumentOutline()}catch(t){if(t instanceof Ph)throw t;Zc("Unable to read document outline.")}return th(this,"documentOutline",t)}_readDocumentOutline(){let t=this._catDict.get("Outlines");if(!(t instanceof vh))return null;if(t=t.getRaw("First"),!(t instanceof Nh))return null;const e={items:[]},A=[{obj:t,parent:e}],i=new Mh;i.put(t);const s=this.xref,a=new Uint8ClampedArray(3);for(;A.length>0;){const e=A.shift(),n=s.fetchIfRef(e.obj);if(null===n)continue;n.has("Title")||Zc("Invalid outline item encountered.");const r={url:null,dest:null,action:null};kf.parseDestDictionary({destDict:n,resultObj:r,docBaseUrl:this.baseUrl,docAttachments:this.attachments});const o=n.get("Title"),g=n.get("F")||0,c=n.getArray("C"),h=n.get("Count");let l=a;!Al(c,3)||0===c[0]&&0===c[1]&&0===c[2]||(l=xl.singletons.rgb.getRgb(c,0));const I={action:r.action,attachment:r.attachment,dest:r.dest,url:r.url,unsafeUrl:r.unsafeUrl,newWindow:r.newWindow,setOCGState:r.setOCGState,title:"string"==typeof o?Bh(o):"",color:l,count:Number.isInteger(h)?h:void 0,bold:!!(2&g),italic:!!(1&g),items:[]};e.parent.items.push(I),t=n.getRaw("First"),t instanceof Nh&&!i.has(t)&&(A.push({obj:t,parent:I}),i.put(t)),t=n.getRaw("Next"),t instanceof Nh&&!i.has(t)&&(A.push({obj:t,parent:e.parent}),i.put(t))}return e.items.length>0?e.items:null}get permissions(){let t=null;try{t=this._readPermissions()}catch(t){if(t instanceof Ph)throw t;Zc("Unable to read permissions.")}return th(this,"permissions",t)}_readPermissions(){const t=this.xref.trailer.get("Encrypt");if(!(t instanceof vh))return null;let e=t.get("P");if("number"!=typeof e)return null;e+=2**32;const A=[];for(const t in Sc){const i=Sc[t];e&i&&A.push(i)}return A}get optionalContentConfig(){let t=null;try{const e=this._catDict.get("OCProperties");if(!e)return th(this,"optionalContentConfig",null);const A=e.get("D");if(!A)return th(this,"optionalContentConfig",null);const i=e.get("OCGs");if(!Array.isArray(i))return th(this,"optionalContentConfig",null);const s=[],a=new Mh;for(const t of i)t instanceof Nh&&!a.has(t)&&(a.put(t),s.push(this.#Pr(t)));t=this.#Kr(A,a),t.groups=s}catch(t){if(t instanceof Ph)throw t;Zc(`Unable to read optional content config: ${t}`)}return th(this,"optionalContentConfig",t)}#Pr(t){const e=this.xref.fetch(t),A={id:t.toString(),name:null,intent:null,usage:{print:null,view:null}},i=e.get("Name");"string"==typeof i&&(A.name=Bh(i));let s=e.getArray("Intent");Array.isArray(s)||(s=[s]),s.every((t=>t instanceof xh))&&(A.intent=s.map((t=>t.name)));const a=e.get("Usage");if(!(a instanceof vh))return A;const n=A.usage,r=a.get("Print");if(r instanceof vh){const t=r.get("PrintState");if(t instanceof xh)switch(t.name){case"ON":case"OFF":n.print={printState:t.name}}}const o=a.get("View");if(o instanceof vh){const t=o.get("ViewState");if(t instanceof xh)switch(t.name){case"ON":case"OFF":n.view={viewState:t.name}}}return A}#Kr(t,e){function A(t){const A=[];if(Array.isArray(t))for(const i of t)i instanceof Nh&&e.has(i)&&A.push(i.toString());return A}function i(t,A=0){if(!Array.isArray(t))return null;const i=[];for(const a of t){if(a instanceof Nh&&e.has(a)){n.put(a),i.push(a.toString());continue}const t=s(a,A);t&&i.push(t)}if(A>0)return i;const a=[];for(const t of e)n.has(t)||a.push(t.toString());return a.length&&i.push({name:null,order:a}),i}function s(t,e){if(++e>r)return Zc("parseNestedOrder - reached MAX_NESTED_LEVELS."),null;const A=a.fetchIfRef(t);if(!Array.isArray(A))return null;const s=a.fetchIfRef(A[0]);if("string"!=typeof s)return null;const n=i(A.slice(1),e);return n&&n.length?{name:Bh(s),order:n}:null}const a=this.xref,n=new Mh,r=10;return{name:"string"==typeof t.get("Name")?Bh(t.get("Name")):null,creator:"string"==typeof t.get("Creator")?Bh(t.get("Creator")):null,baseState:t.get("BaseState")instanceof xh?t.get("BaseState").name:null,on:A(t.get("ON")),off:A(t.get("OFF")),order:i(t.get("Order")),groups:null}}setActualNumPages(t=null){this._actualNumPages=t}get hasActualNumPages(){return null!==this._actualNumPages}get _pagesCount(){const t=this.toplevelPagesDict.get("Count");if(!Number.isInteger(t))throw new rh("Page count in top-level pages dictionary is not an integer.");return th(this,"_pagesCount",t)}get numPages(){return this.hasActualNumPages?this._actualNumPages:this._pagesCount}get destinations(){const t=this._readDests(),e=Object.create(null);if(t instanceof _E)for(const[A,i]of t.getAll()){const t=wf(i);t&&(e[Bh(A)]=t)}else t instanceof vh&&t.forEach((function(t,A){const i=wf(A);i&&(e[t]=i)}));return th(this,"destinations",e)}getDestination(t){const e=this._readDests();if(e instanceof _E){const A=wf(e.get(t));if(A)return A;const i=this.destinations[t];if(i)return Zc(`Found "${t}" at an incorrect position in the NameTree.`),i}else if(e instanceof vh){const A=wf(e.get(t));if(A)return A}return null}_readDests(){const t=this._catDict.get("Names");return t?.has("Dests")?new _E(t.getRaw("Dests"),this.xref):this._catDict.has("Dests")?this._catDict.get("Dests"):void 0}get pageLabels(){let t=null;try{t=this._readPageLabels()}catch(t){if(t instanceof Ph)throw t;Zc("Unable to read page labels.")}return th(this,"pageLabels",t)}_readPageLabels(){const t=this._catDict.getRaw("PageLabels");if(!t)return null;const e=new Array(this.numPages);let A=null,i="";const s=new YE(t,this.xref).getAll();let a="",n=1;for(let t=0,r=this.numPages;t=1))throw new rh("Invalid start in PageLabel dictionary.");n=t}else n=1}switch(A){case"D":a=n;break;case"R":case"r":a=Zh(n,"r"===A);break;case"A":case"a":const t=26,e="a"===A?97:65,i=n-1;a=String.fromCharCode(e+i%t).repeat(Math.floor(i/t)+1);break;default:if(A)throw new rh(`Invalid style "${A}" in PageLabel dictionary.`);a=""}e[t]=i+a,n++}return e}get pageLayout(){const t=this._catDict.get("PageLayout");let e="";if(t instanceof xh)switch(t.name){case"SinglePage":case"OneColumn":case"TwoColumnLeft":case"TwoColumnRight":case"TwoPageLeft":case"TwoPageRight":e=t.name}return th(this,"pageLayout",e)}get pageMode(){const t=this._catDict.get("PageMode");let e="UseNone";if(t instanceof xh)switch(t.name){case"UseNone":case"UseOutlines":case"UseThumbs":case"FullScreen":case"UseOC":case"UseAttachments":e=t.name}return th(this,"pageMode",e)}get viewerPreferences(){const t=this._catDict.get("ViewerPreferences");if(!(t instanceof vh))return th(this,"viewerPreferences",null);let e=null;for(const A of t.getKeys()){const i=t.get(A);let s;switch(A){case"HideToolbar":case"HideMenubar":case"HideWindowUI":case"FitWindow":case"CenterWindow":case"DisplayDocTitle":case"PickTrayByPDFSize":"boolean"==typeof i&&(s=i);break;case"NonFullScreenPageMode":if(i instanceof xh)switch(i.name){case"UseNone":case"UseOutlines":case"UseThumbs":case"UseOC":s=i.name;break;default:s="UseNone"}break;case"Direction":if(i instanceof xh)switch(i.name){case"L2R":case"R2L":s=i.name;break;default:s="L2R"}break;case"ViewArea":case"ViewClip":case"PrintArea":case"PrintClip":if(i instanceof xh)switch(i.name){case"MediaBox":case"CropBox":case"BleedBox":case"TrimBox":case"ArtBox":s=i.name;break;default:s="CropBox"}break;case"PrintScaling":if(i instanceof xh)switch(i.name){case"None":case"AppDefault":s=i.name;break;default:s="AppDefault"}break;case"Duplex":if(i instanceof xh)switch(i.name){case"Simplex":case"DuplexFlipShortEdge":case"DuplexFlipLongEdge":s=i.name;break;default:s="None"}break;case"PrintPageRange":Array.isArray(i)&&i.length%2==0&&i.every(((t,e,A)=>Number.isInteger(t)&&t>0&&(0===e||t>=A[e-1])&&t<=this.numPages))&&(s=i);break;case"NumCopies":Number.isInteger(i)&&i>0&&(s=i);break;default:Zc(`Ignoring non-standard key in ViewerPreferences: ${A}.`);continue}void 0!==s?(e||(e=Object.create(null)),e[A]=s):Zc(`Bad value, for key "${A}", in ViewerPreferences: ${i}.`)}return th(this,"viewerPreferences",e)}get openAction(){const t=this._catDict.get("OpenAction"),e=Object.create(null);if(t instanceof vh){const A=new vh(this.xref);A.set("A",t);const i={url:null,dest:null,action:null};kf.parseDestDictionary({destDict:A,resultObj:i}),Array.isArray(i.dest)?e.dest=i.dest:i.action&&(e.action=i.action)}else Array.isArray(t)&&(e.dest=t);return th(this,"openAction",lh(e)>0?e:null)}get attachments(){const t=this._catDict.get("Names");let e=null;if(t instanceof vh&&t.has("EmbeddedFiles")){const A=new _E(t.getRaw("EmbeddedFiles"),this.xref);for(const[t,i]of A.getAll()){const A=new KE(i,this.xref);e||(e=Object.create(null)),e[Bh(t)]=A.serializable}}return th(this,"attachments",e)}get xfaImages(){const t=this._catDict.get("Names");let e=null;if(t instanceof vh&&t.has("XFAImages")){const A=new _E(t.getRaw("XFAImages"),this.xref);for(const[t,i]of A.getAll())e||(e=new vh(this.xref)),e.set(Bh(t),i)}return th(this,"xfaImages",e)}_collectJavaScript(){const t=this._catDict.get("Names");let e=null;function A(t,A){if(!(A instanceof vh))return;if(!Lh(A.get("S"),"JavaScript"))return;let i=A.get("JS");if(i instanceof _h)i=i.getString();else if("string"!=typeof i)return;i=Bh(i).replaceAll("\0",""),i&&(e||=new Map).set(t,i)}if(t instanceof vh&&t.has("JavaScript")){const e=new _E(t.getRaw("JavaScript"),this.xref);for(const[t,i]of e.getAll())A(Bh(t),i)}const i=this._catDict.get("OpenAction");return i&&A("OpenAction",i),e}get jsActions(){const t=this._collectJavaScript();let e=cl(this.xref,this._catDict,Nc);if(t){e||=Object.create(null);for(const[A,i]of t)A in e?e[A].push(i):e[A]=[i]}return th(this,"jsActions",e)}async fontFallback(t,e){const A=await Promise.all(this.fontCache);for(const i of A)if(i.loadedName===t)return void i.fallback(e)}async cleanup(t=!1){TE(),this.globalImageCache.clear(t),this.pageKidsCountCache.clear(),this.pageIndexCache.clear(),this.nonBlendModesSet.clear();const e=await Promise.all(this.fontCache);for(const{dict:t}of e)delete t.cacheKey;this.fontCache.clear(),this.builtInCMapCache.clear(),this.standardFontDataCache.clear(),this.systemFontCache.clear()}async getPageDict(t){const e=[this.toplevelPagesDict],A=new Mh,i=this._catDict.getRaw("Pages");i instanceof Nh&&A.put(i);const s=this.xref,a=this.pageKidsCountCache,n=this.pageIndexCache;let r=0;for(;e.length;){const i=e.pop();if(i instanceof Nh){const o=a.get(i);if(o>=0&&r+o<=t){r+=o;continue}if(A.has(i))throw new rh("Pages tree contains circular reference.");A.put(i);const g=await s.fetchAsync(i);if(g instanceof vh){let e=g.getRaw("Type");if(e instanceof Nh&&(e=await s.fetchAsync(e)),Lh(e,"Page")||!g.has("Kids")){if(a.has(i)||a.put(i,1),n.has(i)||n.put(i,r),r===t)return[g,i];r++;continue}}e.push(g);continue}if(!(i instanceof vh))throw new rh("Page dictionary kid reference points to wrong type of object.");const{objId:o}=i;let g=i.getRaw("Count");if(g instanceof Nh&&(g=await s.fetchAsync(g)),Number.isInteger(g)&&g>=0&&(o&&!a.has(o)&&a.put(o,g),r+g<=t)){r+=g;continue}let c=i.getRaw("Kids");if(c instanceof Nh&&(c=await s.fetchAsync(c)),!Array.isArray(c)){let e=i.getRaw("Type");if(e instanceof Nh&&(e=await s.fetchAsync(e)),Lh(e,"Page")||!i.has("Kids")){if(r===t)return[i,null];r++;continue}throw new rh("Page dictionary kids object is not an array.")}for(let t=c.length-1;t>=0;t--)e.push(c[t])}throw new Error(`Page index ${t} not found.`)}async getAllPageDicts(t=!1){const{ignoreErrors:e}=this.pdfManager.evaluatorOptions,A=[{currentNode:this.toplevelPagesDict,posInKids:0}],i=new Mh,s=this._catDict.getRaw("Pages");s instanceof Nh&&i.put(s);const a=new Map,n=this.xref,r=this.pageIndexCache;let o=0;function g(t,e){e&&!r.has(e)&&r.put(e,o),a.set(o++,[t,e])}function c(A){if(A instanceof qh&&!t)throw A;t&&e&&0===o&&(Zc(`getAllPageDicts - Skipping invalid first page: "${A}".`),A=vh.empty),a.set(o++,[A,null])}for(;A.length>0;){const e=A.at(-1),{currentNode:s,posInKids:a}=e;let r=s.getRaw("Kids");if(r instanceof Nh)try{r=await n.fetchAsync(r)}catch(t){c(t);break}if(!Array.isArray(r)){c(new rh("Page dictionary kids object is not an array."));break}if(a>=r.length){A.pop();continue}const o=r[a];let h;if(o instanceof Nh){if(i.has(o)){c(new rh("Pages tree contains circular reference."));break}i.put(o);try{h=await n.fetchAsync(o)}catch(t){c(t);break}}else h=o;if(!(h instanceof vh)){c(new rh("Page dictionary kid reference points to wrong type of object."));break}let l=h.getRaw("Type");if(l instanceof Nh)try{l=await n.fetchAsync(l)}catch(t){c(t);break}Lh(l,"Page")||!h.has("Kids")?g(h,o instanceof Nh?o:null):A.push({currentNode:h,posInKids:0}),e.posInKids++}return a}getPageIndex(t){const e=this.pageIndexCache.get(t);if(void 0!==e)return Promise.resolve(e);const A=this.xref;let i=0;const s=e=>function(e){let i,s=0;return A.fetchAsync(e).then((function(A){if(Jh(e,t)&&!Hh(A,"Page")&&!(A instanceof vh&&!A.has("Type")&&A.has("Contents")))throw new rh("The reference does not point to a /Page dictionary.");if(!A)return null;if(!(A instanceof vh))throw new rh("Node must be a dictionary.");return i=A.getRaw("Parent"),A.getAsync("Parent")})).then((function(t){if(!t)return null;if(!(t instanceof vh))throw new rh("Parent must be a dictionary.");return t.getAsync("Kids")})).then((function(t){if(!t)return null;const a=[];let n=!1;for(const i of t){if(!(i instanceof Nh))throw new rh("Kid must be a reference.");if(Jh(i,e)){n=!0;break}a.push(A.fetchAsync(i).then((function(t){if(!(t instanceof vh))throw new rh("Kid node must be a dictionary.");t.has("Count")?s+=t.get("Count"):s++})))}if(!n)throw new rh("Kid reference not found in parent's kids.");return Promise.all(a).then((function(){return[s,i]}))}))}(e).then((e=>{if(!e)return this.pageIndexCache.put(t,i),i;const[A,a]=e;return i+=A,s(a)}));return s(t)}get baseUrl(){const t=this._catDict.get("URI");if(t instanceof vh){const e=t.get("Base");if("string"==typeof e){const t=$c(e,null,{tryConvertEncoding:!0});if(t)return th(this,"baseUrl",t.href)}}return th(this,"baseUrl",this.pdfManager.docBaseUrl)}static parseDestDictionary({destDict:t,resultObj:e,docBaseUrl:A=null,docAttachments:i=null}){if(!(t instanceof vh))return void Zc("parseDestDictionary: `destDict` must be a dictionary.");let s,a,n=t.get("A");if(n instanceof vh||(t.has("Dest")?n=t.get("Dest"):(n=t.get("AA"),n instanceof vh&&(n.has("D")?n=n.get("D"):n.has("U")&&(n=n.get("U"))))),n instanceof vh){const t=n.get("S");if(!(t instanceof xh))return void Zc("parseDestDictionary: Invalid type in Action dictionary.");const A=t.name;switch(A){case"ResetForm":const t=n.get("Flags"),r=!(1&("number"==typeof t?t:0)),o=[],g=[];for(const t of n.get("Fields")||[])t instanceof Nh?g.push(t.toString()):"string"==typeof t&&o.push(Bh(t));e.resetForm={fields:o,refs:g,include:r};break;case"URI":s=n.get("URI"),s instanceof xh&&(s="/"+s.name);break;case"GoTo":a=n.get("D");break;case"Launch":case"GoToR":const c=n.get("F");if(c instanceof vh){const t=new KE(c,null,!0),{rawFilename:e}=t.serializable;s=e}else"string"==typeof c&&(s=c);const h=Df(n);h&&"string"==typeof s&&(s=s.split("#",1)[0]+"#"+h);const l=n.get("NewWindow");"boolean"==typeof l&&(e.newWindow=l);break;case"GoToE":const I=n.get("T");let d;if(i&&I instanceof vh){const t=I.get("R"),e=I.get("N");Lh(t,"C")&&"string"==typeof e&&(d=i[Bh(e)])}if(d){e.attachment=d;const t=Df(n);t&&(e.attachmentDest=t)}else Zc('parseDestDictionary - unimplemented "GoToE" action.');break;case"Named":const u=n.get("N");u instanceof xh&&(e.action=u.name);break;case"SetOCGState":const C=n.get("State"),B=n.get("PreserveRB");if(!Array.isArray(C)||0===C.length)break;const Q=[];for(const t of C)if(t instanceof xh)switch(t.name){case"ON":case"OFF":case"Toggle":Q.push(t.name)}else t instanceof Nh&&Q.push(t.toString());if(Q.length!==C.length)break;e.setOCGState={state:Q,preserveRB:"boolean"!=typeof B||B};break;case"JavaScript":const E=n.get("JS");let f;E instanceof _h?f=E.getString():"string"==typeof E&&(f=E);const p=f&&Cl(Bh(f));if(p){s=p.url,e.newWindow=p.newWindow;break}default:if("JavaScript"===A||"SubmitForm"===A)break;Zc(`parseDestDictionary - unsupported action: "${A}".`)}}else t.has("Dest")&&(a=t.get("Dest"));if("string"==typeof s){const t=$c(s,A,{addDefaultProtocol:!0,tryConvertEncoding:!0});t&&(e.url=t.href),e.unsafeUrl=s}a&&(a instanceof xh&&(a=a.name),"string"==typeof a?e.dest=Bh(a):bf(a)&&(e.dest=a))}}function Sf(t,e){if(t instanceof vh)t=t.getRawValues();else if(t instanceof _h)t=t.dict.getRawValues();else if(!Array.isArray(t))return;for(const i of t)((A=i)instanceof Nh||A instanceof vh||A instanceof _h||Array.isArray(A))&&e.push(i);var A}class xf{constructor(t,e,A){this.dict=t,this.keys=e,this.xref=A,this.refSet=null}async load(){if(this.xref.stream.isDataLoaded)return;const{keys:t,dict:e}=this;this.refSet=new Mh;const A=[];for(const i of t){const t=e.getRaw(i);void 0!==t&&A.push(t)}return this._walk(A)}async _walk(t){const e=[],A=[];for(;t.length;){let i=t.pop();if(i instanceof Nh){if(this.refSet.has(i))continue;try{this.refSet.put(i),i=this.xref.fetch(i)}catch(t){if(!(t instanceof Ph)){Zc(`ObjectLoader._walk - requesting all data: "${t}".`),this.refSet=null;const{manager:e}=this.xref.stream;return e.requestAllChunks()}e.push(i),A.push({begin:t.begin,end:t.end})}}if(i instanceof _h){const t=i.getBaseStreams();if(t){let s=!1;for(const e of t)e.isDataLoaded||(s=!0,A.push({begin:e.start,end:e.end}));s&&e.push(i)}}Sf(i,t)}if(A.length){await this.xref.stream.manager.requestRanges(A);for(const t of e)t instanceof Nh&&this.refSet.remove(t);return this._walk(e)}this.refSet=null}}const Ff=Symbol(),Rf=Symbol(),vf=Symbol(),Nf=Symbol(),Mf=Symbol(),Gf=Symbol(),Lf=Symbol(),Uf=Symbol(),Hf=Symbol(),Jf=Symbol("content"),_f=Symbol("data"),Yf=Symbol(),Tf=Symbol("extra"),Pf=Symbol(),Kf=Symbol(),qf=Symbol(),Of=Symbol(),Wf=Symbol(),jf=Symbol(),Vf=Symbol(),Zf=Symbol(),Xf=Symbol(),zf=Symbol(),$f=Symbol(),tp=Symbol(),ep=Symbol(),Ap=Symbol(),ip=Symbol(),sp=Symbol(),ap=Symbol(),np=Symbol(),rp=Symbol(),op=Symbol(),gp=Symbol(),cp=Symbol(),hp=Symbol(),lp=Symbol(),Ip=Symbol(),dp=Symbol(),up=Symbol(),Cp=Symbol(),Bp=Symbol(),Qp=Symbol(),Ep=Symbol(),fp=Symbol(),pp=Symbol("namespaceId"),mp=Symbol("nodeName"),yp=Symbol(),bp=Symbol(),wp=Symbol(),Dp=Symbol(),kp=Symbol(),Sp=Symbol(),xp=Symbol(),Fp=Symbol(),Rp=Symbol("root"),vp=Symbol(),Np=Symbol(),Mp=Symbol(),Gp=Symbol(),Lp=Symbol(),Up=Symbol(),Hp=Symbol(),Jp=Symbol(),_p=Symbol(),Yp=Symbol(),Tp=Symbol(),Pp=Symbol("uid"),Kp=Symbol(),qp={config:{id:0,check:t=>t.startsWith("http://www.xfa.org/schema/xci/")},connectionSet:{id:1,check:t=>t.startsWith("http://www.xfa.org/schema/xfa-connection-set/")},datasets:{id:2,check:t=>t.startsWith("http://www.xfa.org/schema/xfa-data/")},form:{id:3,check:t=>t.startsWith("http://www.xfa.org/schema/xfa-form/")},localeSet:{id:4,check:t=>t.startsWith("http://www.xfa.org/schema/xfa-locale-set/")},pdf:{id:5,check:t=>"http://ns.adobe.com/xdp/pdf/"===t},signature:{id:6,check:t=>"http://www.w3.org/2000/09/xmldsig#"===t},sourceSet:{id:7,check:t=>t.startsWith("http://www.xfa.org/schema/xfa-source-set/")},stylesheet:{id:8,check:t=>"http://www.w3.org/1999/XSL/Transform"===t},template:{id:9,check:t=>t.startsWith("http://www.xfa.org/schema/xfa-template/")},xdc:{id:10,check:t=>t.startsWith("http://www.xfa.org/schema/xdc/")},xdp:{id:11,check:t=>"http://ns.adobe.com/xdp/"===t},xfdf:{id:12,check:t=>"http://ns.adobe.com/xfdf/"===t},xhtml:{id:13,check:t=>"http://www.w3.org/1999/xhtml"===t},xmpmeta:{id:14,check:t=>"http://ns.adobe.com/xmpmeta/"===t}},Op={pt:t=>t,cm:t=>t/2.54*72,mm:t=>t/25.4*72,in:t=>72*t,px:t=>t},Wp=/([+-]?\d+\.?\d*)(.*)/;function jp(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function Vp({data:t,defaultValue:e,validate:A}){if(!t)return e;t=t.trim();const i=parseInt(t,10);return!isNaN(i)&&A(i)?i:e}function Zp({data:t,defaultValue:e,validate:A}){if(!t)return e;t=t.trim();const i=parseFloat(t);return!isNaN(i)&&A(i)?i:e}function Xp({data:t,defaultValue:e,validate:A}){return t&&A(t=t.trim())?t:e}function zp(t,e){return Xp({data:t,defaultValue:e[0],validate:t=>e.includes(t)})}function $p(t,e="0"){if(e||="0",!t)return $p(e);const A=t.trim().match(Wp);if(!A)return $p(e);const[,i,s]=A,a=parseFloat(i);if(isNaN(a))return $p(e);if(0===a)return 0;const n=Op[s];return n?n(a):a}function tm(t){if(!t)return{num:1,den:1};const e=t.trim().split(/\s*:\s*/).map((t=>parseFloat(t))).filter((t=>!isNaN(t)));if(1===e.length&&e.push(1),0===e.length)return{num:1,den:1};const[A,i]=e;return{num:A,den:i}}function em(t){return t?t.trim().split(/\s+/).map((t=>({excluded:"-"===t[0],viewname:t.substring(1)}))):[]}class Am{static get FAILURE(){return th(this,"FAILURE",new Am(!1,null,null,null))}static get EMPTY(){return th(this,"EMPTY",new Am(!0,null,null,null))}constructor(t,e,A,i){this.success=t,this.html=e,this.bbox=A,this.breakNode=i}isBreak(){return!!this.breakNode}static breakNode(t){return new Am(!1,null,null,t)}static success(t,e=null){return new Am(!0,t,e,null)}}class im{constructor(t){this.fonts=new Map,this.cache=new Map,this.warned=new Set,this.defaultFont=null,this.add(t)}add(t,e=null){for(const e of t)this.addPdfFont(e);for(const t of this.fonts.values())t.regular||(t.regular=t.italic||t.bold||t.bolditalic);if(!e||0===e.size)return;const A=this.fonts.get("PdfJS-Fallback-PdfJS-XFA");for(const t of e)this.fonts.set(t,A)}addPdfFont(t){const e=t.cssFontInfo,A=e.fontFamily;let i=this.fonts.get(A);i||(i=Object.create(null),this.fonts.set(A,i),this.defaultFont||(this.defaultFont=i));let s="";const a=parseFloat(e.fontWeight);0!==parseFloat(e.italicAngle)?s=a>=700?"bolditalic":"italic":a>=700&&(s="bold"),s||((t.name.includes("Bold")||t.psName?.includes("Bold"))&&(s="bold"),(t.name.includes("Italic")||t.name.endsWith("It")||t.psName?.includes("Italic")||t.psName?.endsWith("It"))&&(s+="italic")),s||(s="regular"),i[s]=t}getDefault(){return this.defaultFont}find(t,e=!0){let A=this.fonts.get(t)||this.cache.get(t);if(A)return A;const i=/,|-|_| |bolditalic|bold|italic|regular|it/gi;let s=t.replaceAll(i,"");if(A=this.fonts.get(s),A)return this.cache.set(t,A),A;s=s.toLowerCase();const a=[];for(const[t,e]of this.fonts.entries())t.replaceAll(i,"").toLowerCase().startsWith(s)&&a.push(e);if(0===a.length)for(const[,t]of this.fonts.entries())t.regular.name?.replaceAll(i,"").toLowerCase().startsWith(s)&&a.push(t);if(0===a.length){s=s.replaceAll(/psmt|mt/gi,"");for(const[t,e]of this.fonts.entries())t.replaceAll(i,"").toLowerCase().startsWith(s)&&a.push(e)}if(0===a.length)for(const t of this.fonts.values())t.regular.name?.replaceAll(i,"").toLowerCase().startsWith(s)&&a.push(t);return a.length>=1?(1!==a.length&&e&&Zc(`XFA - Too many choices to guess the correct font: ${t}`),this.cache.set(t,a[0]),a[0]):(e&&!this.warned.has(t)&&(this.warned.add(t),Zc(`XFA - Cannot find the font: ${t}`)),null)}}function sm(t,e){return"italic"===t.posture?"bold"===t.weight?e.bolditalic:e.italic:"bold"===t.weight?e.bold:e.regular}class am{constructor(t,e,A,i){if(this.lineHeight=A,this.paraMargin=e||{top:0,bottom:0,left:0,right:0},!t)return void([this.pdfFont,this.xfaFont]=this.defaultFont(i));this.xfaFont={typeface:t.typeface,posture:t.posture,weight:t.weight,size:t.size,letterSpacing:t.letterSpacing};const s=i.find(t.typeface);s?(this.pdfFont=sm(t,s),this.pdfFont||([this.pdfFont,this.xfaFont]=this.defaultFont(i))):[this.pdfFont,this.xfaFont]=this.defaultFont(i)}defaultFont(t){const e=t.find("Helvetica",!1)||t.find("Myriad Pro",!1)||t.find("Arial",!1)||t.getDefault();if(e?.regular){const t=e.regular;return[t,{typeface:t.cssFontInfo.fontFamily,posture:"normal",weight:"normal",size:10,letterSpacing:0}]}return[null,{typeface:"Courier",posture:"normal",weight:"normal",size:10,letterSpacing:0}]}}class nm{constructor(t,e,A,i){this.fontFinder=i,this.stack=[new am(t,e,A,i)]}pushData(t,e,A){const i=this.stack.at(-1);for(const e of["typeface","posture","weight","size","letterSpacing"])t[e]||(t[e]=i.xfaFont[e]);for(const t of["top","bottom","left","right"])isNaN(e[t])&&(e[t]=i.paraMargin[t]);const s=new am(t,e,A||i.lineHeight,this.fontFinder);s.pdfFont||(s.pdfFont=i.pdfFont),this.stack.push(s)}popFont(){this.stack.pop()}topFont(){return this.stack.at(-1)}}class rm{constructor(t,e,A,i){this.glyphs=[],this.fontSelector=new nm(t,e,A,i),this.extraHeight=0}pushData(t,e,A){this.fontSelector.pushData(t,e,A)}popFont(t){return this.fontSelector.popFont()}addPara(){const t=this.fontSelector.topFont();this.extraHeight+=t.paraMargin.top+t.paraMargin.bottom}addString(t){if(!t)return;const e=this.fontSelector.topFont(),A=e.xfaFont.size;if(e.pdfFont){const i=e.xfaFont.letterSpacing,s=e.pdfFont,a=s.lineHeight||1.2,n=e.lineHeight||Math.max(1.2,a)*A,r=a-(void 0===s.lineGap?.2:s.lineGap),o=Math.max(1,r)*A,g=A/1e3,c=s.defaultWidth||s.charsToGlyphs(" ")[0].width;for(const e of t.split(/[\u2029\n]/)){const t=s.encodeString(e).join(""),A=s.charsToGlyphs(t);for(const t of A){const e=t.width||c;this.glyphs.push([e*g+i,n,o,t.unicode,!1])}this.glyphs.push([0,0,0,"\n",!0])}this.glyphs.pop()}else{for(const e of t.split(/[\u2029\n]/)){for(const t of e.split(""))this.glyphs.push([A,1.2*A,A,t,!1]);this.glyphs.push([0,0,0,"\n",!0])}this.glyphs.pop()}}compute(t){let e=-1,A=0,i=0,s=0,a=0,n=0,r=!1,o=!0;for(let g=0,c=this.glyphs.length;gt?(i=Math.max(i,a),a=0,s+=n,n=C,e=-1,A=0,r=!0,o=!1):(n=Math.max(C,n),A=a,a+=c,e=g):a+c>t?(s+=n,n=C,-1!==e?(g=e,i=Math.max(i,A),a=0,e=-1,A=0):(i=Math.max(i,a),a=c),r=!0,o=!1):(a+=c,n=Math.max(C,n))}return i=Math.max(i,a),s+=n+this.extraHeight,{width:1.02*i,height:s,isBroken:r}}}const om=/^[^.[]+/,gm=/^[^\]]+/,cm={dot:0,dotDot:1,dotHash:2,dotBracket:3,dotParen:4},hm=new Map([["$data",(t,e)=>t.datasets?t.datasets.data:t],["$record",(t,e)=>(t.datasets?t.datasets.data:t)[tp]()[0]],["$template",(t,e)=>t.template],["$connectionSet",(t,e)=>t.connectionSet],["$form",(t,e)=>t.form],["$layout",(t,e)=>t.layout],["$host",(t,e)=>t.host],["$dataWindow",(t,e)=>t.dataWindow],["$event",(t,e)=>t.event],["!",(t,e)=>t.datasets],["$xfa",(t,e)=>t],["xfa",(t,e)=>t],["$",(t,e)=>e]]),lm=new WeakMap;function Im(t,e,A=!0){let i=t.match(om);if(!i)return null;let[s]=i;const a=[{name:s,cacheName:"."+s,index:0,js:null,formCalc:null,operator:cm.dot}];let n=s.length;for(;n0&&c.push(t)}if(0!==c.length||r||0!==o)t=isFinite(g)?c.filter((t=>gt[g])):c.flat();else{const A=e[sp]();if(!(e=A))return null;o=-1,t=[e]}}return 0===t.length?null:t}function um(t,e,A){const i=Im(A);if(!i)return null;if(i.some((t=>t.operator===cm.dotDot)))return null;const s=hm.get(i[0].name);let a=0;s?(t=s(t,e),a=1):t=e||t;for(let e=i.length;at[Hp]())).join("")}get[Qm](){const t=Object.getPrototypeOf(this);if(!t._attributes){const e=t._attributes=new Set;for(const t of Object.getOwnPropertyNames(this)){if(null===this[t]||this[t]instanceof Gm||this[t]instanceof Lm)break;e.add(t)}}return th(this,Qm,t._attributes)}[dp](t){let e=this;for(;e;){if(e===t)return!0;e=e[sp]()}return!1}[sp](){return this[xm]}[ip](){return this[sp]()}[tp](t=null){return t?this[t]:this[Em]}[Yf](){const t=Object.create(null);this[Jf]&&(t.$content=this[Jf]);for(const e of Object.getOwnPropertyNames(this)){const A=this[e];null!==A&&(A instanceof Gm?t[e]=A[Yf]():A instanceof Lm?A.isEmpty()||(t[e]=A.dump()):t[e]=A)}return t}[Tp](){return null}[_p](){return Am.EMPTY}*[ep](){for(const t of this[tp]())yield t}*[ym](t,e){for(const A of this[ep]())if(!t||e===t.has(A[mp])){const t=this[Wf](),e=A[_p](t);e.success||(this[Tf].failingNode=A),yield e}}[Kf](){return null}[Rf](t,e){this[Tf].children.push(t)}[Wf](){}[Nf]({filter:t=null,include:e=!0}){if(this[Tf].generator){const t=this[Wf](),e=this[Tf].failingNode[_p](t);if(!e.success)return e;e.html&&this[Rf](e.html,e.bbox),delete this[Tf].failingNode}else this[Tf].generator=this[ym](t,e);for(;;){const t=this[Tf].generator.next();if(t.done)break;const e=t.value;if(!e.success)return e;e.html&&this[Rf](e.html,e.bbox)}return this[Tf].generator=null,Am.EMPTY}[Gp](t){this[Rm]=new Set(Object.keys(t))}[wm](t){const e=this[Qm],A=this[Rm];return[...t].filter((t=>e.has(t)&&!A.has(t)))}[vp](t,e=new Set){for(const A of this[Em])A[Fm](t,e)}[Fm](t,e){const A=this[bm](t,e);A?this[Cm](A,t,e):this[vp](t,e)}[bm](t,e){const{use:A,usehref:i}=this;if(!A&&!i)return null;let s=null,a=null,n=null,r=A;if(i?(r=i,i.startsWith("#som(")&&i.endsWith(")")?a=i.slice(5,-1):i.startsWith(".#som(")&&i.endsWith(")")?a=i.slice(6,-1):i.startsWith("#")?n=i.slice(1):i.startsWith(".#")&&(n=i.slice(2))):A.startsWith("#")?n=A.slice(1):a=A,this.use=this.usehref="",n?s=t.get(n):(s=dm(t.get(Rp),this,a,!0,!1),s&&(s=s[0])),!s)return Zc(`XFA - Invalid prototype reference: ${r}.`),null;if(s[mp]!==this[mp])return Zc(`XFA - Incompatible prototype: ${s[mp]} !== ${this[mp]}.`),null;if(e.has(s))return Zc("XFA - Cycle detected in prototypes use."),null;e.add(s);const o=s[bm](t,e);return o&&s[Cm](o,t,e),s[vp](t,e),e.delete(s),s}[Cm](t,e,A){if(A.has(t))Zc("XFA - Cycle detected in prototypes use.");else{!this[Jf]&&t[Jf]&&(this[Jf]=t[Jf]),new Set(A).add(t);for(const e of this[wm](t[Rm]))this[e]=t[e],this[Rm]&&this[Rm].add(e);for(const i of Object.getOwnPropertyNames(this)){if(this[Qm].has(i))continue;const s=this[i],a=t[i];if(s instanceof Lm){for(const t of s[Em])t[Fm](e,A);for(let i=s[Em].length,n=a[Em].length;iGm[fm](t))):"object"==typeof t&&null!==t?Object.assign({},t):t}[Uf](){const t=Object.create(Object.getPrototypeOf(this));for(const e of Object.getOwnPropertySymbols(this))try{t[e]=this[e]}catch{th(t,e,this[e])}t[Pp]=`${t[mp]}${Nm++}`,t[Em]=[];for(const e of Object.getOwnPropertyNames(this)){if(this[Qm].has(e)){t[e]=Gm[fm](this[e]);continue}const A=this[e];t[e]=A instanceof Lm?new Lm(A[km]):null}for(const e of this[Em]){const A=e[mp],i=e[Uf]();t[Em].push(i),i[xm]=t,null===t[A]?t[A]=i:t[A][Em].push(i)}return t}[tp](t=null){return t?this[Em].filter((e=>e[mp]===t)):this[Em]}[jf](t){return this[t]}[Vf](t,e,A=!0){return Array.from(this[Zf](t,e,A))}*[Zf](t,e,A=!0){if("parent"!==t){for(const A of this[Em])A[mp]===t&&(yield A),A.name===t&&(yield A),(e||A[Qp]())&&(yield*A[Zf](t,e,!1));A&&this[Qm].has(t)&&(yield new Um(this,t,this[t]))}else yield this[xm]}}class Lm{constructor(t=1/0){this[km]=t,this[Em]=[]}get isXFAObject(){return!1}get isXFAObjectArray(){return!0}push(t){return this[Em].length<=this[km]?(this[Em].push(t),!0):(Zc(`XFA - node "${t[mp]}" accepts no more than ${this[km]} children`),!1)}isEmpty(){return 0===this[Em].length}dump(){return 1===this[Em].length?this[Em][0][Yf]():this[Em].map((t=>t[Yf]()))}[Uf](){const t=new Lm(this[km]);return t[Em]=this[Em].map((t=>t[Uf]())),t}get children(){return this[Em]}clear(){this[Em].length=0}}class Um{constructor(t,e,A){this[xm]=t,this[mp]=e,this[Jf]=A,this[Hf]=!1,this[Pp]="attribute"+Nm++}[sp](){return this[xm]}[Ip](){return!0}[Xf](){return this[Jf].trim()}[Lp](t){t=t.value||"",this[Jf]=t.toString()}[Hp](){return this[Jf]}[dp](t){return this[xm]===t||this[xm][dp](t)}}class Hm extends Gm{constructor(t,e,A={}){if(super(t,e),this[Jf]="",this[pm]=null,"#text"!==e){const t=new Map;this[Bm]=t;for(const[e,i]of Object.entries(A))t.set(e,new Um(this,e,i));if(A.hasOwnProperty(yp)){const t=A[yp].xfa.dataNode;void 0!==t&&("dataGroup"===t?this[pm]=!1:"dataValue"===t&&(this[pm]=!0))}}this[Hf]=!1}[Yp](t){const e=this[mp];if("#text"===e)return void t.push(Il(this[Jf]));const A=Eh(e),i=this[pp]===Mm?"xfa:":"";t.push(`<${i}${A}`);for(const[e,A]of this[Bm].entries()){const i=Eh(e);t.push(` ${i}="${Il(A[Jf])}"`)}if(null!==this[pm]&&(this[pm]?t.push(' xfa:dataNode="dataValue"'):t.push(' xfa:dataNode="dataGroup"')),this[Jf]||0!==this[Em].length){if(t.push(">"),this[Jf])"string"==typeof this[Jf]?t.push(Il(this[Jf])):this[Jf][Yp](t);else for(const e of this[Em])e[Yp](t);t.push(``)}else t.push("/>")}[bp](t){if(this[Jf]){const t=new Hm(this[pp],"#text");this[vf](t),t[Jf]=this[Jf],this[Jf]=""}return this[vf](t),!0}[Dp](t){this[Jf]+=t}[Pf](){if(this[Jf]&&this[Em].length>0){const t=new Hm(this[pp],"#text");this[vf](t),t[Jf]=this[Jf],delete this[Jf]}}[_p](){return"#text"===this[mp]?Am.success({name:"#text",value:this[Jf]}):Am.EMPTY}[tp](t=null){return t?this[Em].filter((e=>e[mp]===t)):this[Em]}[Of](){return this[Bm]}[jf](t){const e=this[Bm].get(t);return void 0!==e?e:this[tp](t)}*[Zf](t,e){const A=this[Bm].get(t);A&&(yield A);for(const A of this[Em])A[mp]===t&&(yield A),e&&(yield*A[Zf](t,e))}*[qf](t,e){const A=this[Bm].get(t);!A||e&&A[Hf]||(yield A);for(const A of this[Em])yield*A[qf](t,e)}*[$f](t,e,A){for(const i of this[Em])i[mp]!==t||A&&i[Hf]||(yield i),e&&(yield*i[$f](t,e,A))}[Ip](){return null===this[pm]?0===this[Em].length||this[Em][0][pp]===qp.xhtml.id:this[pm]}[Xf](){return null===this[pm]?0===this[Em].length?this[Jf].trim():this[Em][0][pp]===qp.xhtml.id?this[Em][0][Hp]().trim():null:this[Jf].trim()}[Lp](t){t=t.value||"",this[Jf]=t.toString()}[Yf](t=!1){const e=Object.create(null);t&&(e.$ns=this[pp]),this[Jf]&&(e.$content=this[Jf]),e.$name=this[mp],e.children=[];for(const A of this[Em])e.children.push(A[Yf](t));e.attributes=Object.create(null);for(const[t,A]of this[Bm])e.attributes[t]=A[Jf];return e}}class Jm extends Gm{constructor(t,e){super(t,e),this[Jf]=""}[Dp](t){this[Jf]+=t}[Pf](){}}class _m extends Jm{constructor(t,e,A){super(t,e),this[Sm]=A}[Pf](){this[Jf]=Xp({data:this[Jf],defaultValue:this[Sm][0],validate:t=>this[Sm].includes(t)})}[Mf](t){super[Mf](t),delete this[Sm]}}class Ym extends Jm{[Pf](){this[Jf]=this[Jf].trim()}}class Tm extends Jm{constructor(t,e,A,i){super(t,e),this[mm]=A,this[vm]=i}[Pf](){this[Jf]=Vp({data:this[Jf],defaultValue:this[mm],validate:this[vm]})}[Mf](t){super[Mf](t),delete this[mm],delete this[vm]}}class Pm extends Tm{constructor(t,e){super(t,e,0,(t=>1===t))}}class Km extends Tm{constructor(t,e){super(t,e,1,(t=>0===t))}}function qm(t){return"string"==typeof t?"0px":Number.isInteger(t)?`${t}px`:`${t.toFixed(2)}px`}const Om={anchorType(t,e){const A=t[ip]();if(A&&(!A.layout||"position"===A.layout))switch("transform"in e||(e.transform=""),t.anchorType){case"bottomCenter":e.transform+="translate(-50%, -100%)";break;case"bottomLeft":e.transform+="translate(0,-100%)";break;case"bottomRight":e.transform+="translate(-100%,-100%)";break;case"middleCenter":e.transform+="translate(-50%,-50%)";break;case"middleLeft":e.transform+="translate(0,-50%)";break;case"middleRight":e.transform+="translate(-100%,-50%)";break;case"topCenter":e.transform+="translate(-50%,0)";break;case"topRight":e.transform+="translate(-100%,0)"}},dimensions(t,e){const A=t[ip]();let i=t.w;const s=t.h;if(A.layout?.includes("row")){const e=A[Tf],s=t.colSpan;let a;-1===s?(a=e.columnWidths.slice(e.currentColumn).reduce(((t,e)=>t+e),0),e.currentColumn=0):(a=e.columnWidths.slice(e.currentColumn,e.currentColumn+s).reduce(((t,e)=>t+e),0),e.currentColumn=(e.currentColumn+t.colSpan)%e.columnWidths.length),isNaN(a)||(i=t.w=a)}e.width=""!==i?qm(i):"auto",e.height=""!==s?qm(s):"auto"},position(t,e){const A=t[ip]();A?.layout&&"position"!==A.layout||(e.position="absolute",e.left=qm(t.x),e.top=qm(t.y))},rotate(t,e){t.rotate&&("transform"in e||(e.transform=""),e.transform+=`rotate(-${t.rotate}deg)`,e.transformOrigin="top left")},presence(t,e){switch(t.presence){case"invisible":e.visibility="hidden";break;case"hidden":case"inactive":e.display="none"}},hAlign(t,e){if("para"===t[mp])switch(t.hAlign){case"justifyAll":e.textAlign="justify-all";break;case"radix":e.textAlign="left";break;default:e.textAlign=t.hAlign}else switch(t.hAlign){case"left":e.alignSelf="start";break;case"center":e.alignSelf="center";break;case"right":e.alignSelf="end"}},margin(t,e){t.margin&&(e.margin=t.margin[Tp]().margin)}};function Wm(t,e){"position"===t[ip]().layout&&(t.minW>0&&(e.minWidth=qm(t.minW)),t.maxW>0&&(e.maxWidth=qm(t.maxW)),t.minH>0&&(e.minHeight=qm(t.minH)),t.maxH>0&&(e.maxHeight=qm(t.maxH)))}function jm(t,e,A,i,s,a){const n=new rm(e,A,i,s);return"string"==typeof t?n.addString(t):t[kp](n),n.compute(a)}function Vm(t,e){let A=null,i=null,s=!1;if((!t.w||!t.h)&&t.value){let a=0,n=0;t.margin&&(a=t.margin.leftInset+t.margin.rightInset,n=t.margin.topInset+t.margin.bottomInset);let r=null,o=null;t.para&&(o=Object.create(null),r=""===t.para.lineHeight?null:t.para.lineHeight,o.top=""===t.para.spaceAbove?0:t.para.spaceAbove,o.bottom=""===t.para.spaceBelow?0:t.para.spaceBelow,o.left=""===t.para.marginLeft?0:t.para.marginLeft,o.right=""===t.para.marginRight?0:t.para.marginRight);let g=t.font;if(!g){const e=t[ap]();let A=t[sp]();for(;A&&A!==e;){if(A.font){g=A.font;break}A=A[sp]()}}const c=(t.w||e.width)-a,h=t[np].fontFinder;if(t.value.exData&&t.value.exData[Jf]&&"text/html"===t.value.exData.contentType){const e=jm(t.value.exData[Jf],g,o,r,h,c);i=e.width,A=e.height,s=e.isBroken}else{const e=t.value[Hp]();if(e){const t=jm(e,g,o,r,h,c);i=t.width,A=t.height,s=t.isBroken}}null===i||t.w||(i+=a),null===A||t.h||(A+=n)}return{w:i,h:A,isBroken:s}}function Zm(t,e,A){let i;if(""!==t.w&&""!==t.h)i=[t.x,t.y,t.w,t.h];else{if(!A)return null;let s=t.w;if(""===s){if(0===t.maxW){const e=t[ip]();s="position"===e.layout&&""!==e.w?0:t.minW}else s=Math.min(t.maxW,A.width);e.attributes.style.width=qm(s)}let a=t.h;if(""===a){if(0===t.maxH){const e=t[ip]();a="position"===e.layout&&""!==e.h?0:t.minH}else a=Math.min(t.maxH,A.height);e.attributes.style.height=qm(a)}i=[t.x,t.y,s,a]}return i}function Xm(t){const e=t[ip]();if(e.layout?.includes("row")){const A=e[Tf],i=t.colSpan;let s;s=-1===i?A.columnWidths.slice(A.currentColumn).reduce(((t,e)=>t+e),0):A.columnWidths.slice(A.currentColumn,A.currentColumn+i).reduce(((t,e)=>t+e),0),isNaN(s)||(t.w=s)}e.layout&&"position"!==e.layout&&(t.x=t.y=0),"table"===t.layout&&""===t.w&&Array.isArray(t.columnWidths)&&(t.w=t.columnWidths.reduce(((t,e)=>t+e),0))}function zm(t){switch(t.layout){case"position":default:return"xfaPosition";case"lr-tb":return"xfaLrTb";case"rl-row":return"xfaRlRow";case"rl-tb":return"xfaRlTb";case"row":return"xfaRow";case"table":return"xfaTable";case"tb":return"xfaTb"}}function $m(t,...e){const A=Object.create(null);for(const i of e){const e=t[i];if(null!==e)if(Om.hasOwnProperty(i))Om[i](t,A);else if(e instanceof Gm){const t=e[Tp]();t?Object.assign(A,t):Zc(`(DEBUG) - XFA - style for ${i} not implemented yet`)}}return A}function ty(t,e){const{attributes:A}=e,{style:i}=A,s={name:"div",attributes:{class:["xfaWrapper"],style:Object.create(null)},children:[]};if(A.class.push("xfaWrapped"),t.border){const{widths:A,insets:a}=t.border[Tf];let n,r,o=a[0],g=a[3];const c=a[0]+a[2],h=a[1]+a[3];switch(t.border.hand){case"even":o-=A[0]/2,g-=A[3]/2,n=`calc(100% + ${(A[1]+A[3])/2-h}px)`,r=`calc(100% + ${(A[0]+A[2])/2-c}px)`;break;case"left":o-=A[0],g-=A[3],n=`calc(100% + ${A[1]+A[3]-h}px)`,r=`calc(100% + ${A[0]+A[2]-c}px)`;break;case"right":n=h?`calc(100% - ${h}px)`:"100%",r=c?`calc(100% - ${c}px)`:"100%"}const l=["xfaBorder"];iy(t.border)&&l.push("xfaPrintOnly");const I={name:"div",attributes:{class:l,style:{top:`${o}px`,left:`${g}px`,width:n,height:r}},children:[]};for(const t of["border","borderWidth","borderColor","borderRadius","borderStyle"])void 0!==i[t]&&(I.attributes.style[t]=i[t],delete i[t]);s.children.push(I,e)}else s.children.push(e);for(const t of["background","backgroundClip","top","left","width","height","minWidth","minHeight","maxWidth","maxHeight","transform","transformOrigin","visibility"])void 0!==i[t]&&(s.attributes.style[t]=i[t],delete i[t]);return s.attributes.style.position="absolute"===i.position?"absolute":"relative",delete i.position,i.alignSelf&&(s.attributes.style.alignSelf=i.alignSelf,delete i.alignSelf),s}function ey(t){const e=$p(t.textIndent,"0px");if(e>=0)return;const A="padding"+("left"==("right"===t.textAlign?"right":"left")?"Left":"Right"),i=$p(t[A],"0px");t[A]=i-e+"px"}function Ay(t,e){switch(t.access){case"nonInteractive":e.push("xfaNonInteractive");break;case"readOnly":e.push("xfaReadOnly");break;case"protected":e.push("xfaDisabled")}}function iy(t){return t.relevant.length>0&&!t.relevant[0].excluded&&"print"===t.relevant[0].viewname}function sy(t){const e=t[ap]()[Tf].paraStack;return e.length?e.at(-1):null}function ay(t,e,A){if(A.attributes.class?.includes("xfaRich")){e&&(""===t.h&&(e.height="auto"),""===t.w&&(e.width="auto"));const i=sy(t);if(i){const t=A.attributes.style;switch(t.display="flex",t.flexDirection="column",i.vAlign){case"top":t.justifyContent="start";break;case"bottom":t.justifyContent="end";break;case"middle":t.justifyContent="center"}const e=i[Tp]();for(const[A,i]of Object.entries(e))A in t||(t[A]=i)}}}function ny(t,e,A,i){if(!A)return void delete i.fontFamily;const s=jp(t.typeface);i.fontFamily=`"${s}"`;const a=A.find(s);if(a){const{fontFamily:A}=a.regular.cssFontInfo;A!==s&&(i.fontFamily=`"${A}"`);const n=sy(e);if(n&&""!==n.lineHeight)return;if(i.lineHeight)return;const r=sm(t,a);r&&(i.lineHeight=Math.max(1.2,r.lineHeight))}}function ry(t){const e=$c(t,null,{addDefaultProtocol:!0,tryConvertEncoding:!0});return e?e.href:null}function oy(t,e){return{name:"div",attributes:{class:["lr-tb"===t.layout?"xfaLr":"xfaRl"]},children:e}}function gy(t){if(!t[Tf])return null;const e={name:"div",attributes:t[Tf].attributes,children:t[Tf].children};if(t[Tf].failingNode){const A=t[Tf].failingNode[Kf]();A&&(t.layout.endsWith("-tb")?e.children.push(oy(t,[A])):e.children.push(A))}return 0===e.children.length?null:e}function cy(t,e,A){const i=t[Tf],s=i.availableSpace,[a,n,r,o]=A;switch(t.layout){case"position":i.width=Math.max(i.width,a+r),i.height=Math.max(i.height,n+o),i.children.push(e);break;case"lr-tb":case"rl-tb":i.line&&1!==i.attempt||(i.line=oy(t,[]),i.children.push(i.line),i.numberInLine=0),i.numberInLine+=1,i.line.children.push(e),0===i.attempt?(i.currentWidth+=r,i.height=Math.max(i.height,i.prevHeight+o)):(i.currentWidth=r,i.prevHeight=i.height,i.height+=o,i.attempt=0),i.width=Math.max(i.width,i.currentWidth);break;case"rl-row":case"row":{i.children.push(e),i.width+=r,i.height=Math.max(i.height,o);const t=qm(i.height);for(const e of i.children)e.attributes.style.height=t;break}case"table":case"tb":i.width=Math.min(s.width,Math.max(i.width,r)),i.height+=o,i.children.push(e)}}function hy(t){const e=t[Tf].availableSpace,A=t.margin?t.margin.topInset+t.margin.bottomInset:0,i=t.margin?t.margin.leftInset+t.margin.rightInset:0;switch(t.layout){case"lr-tb":case"rl-tb":return 0===t[Tf].attempt?{width:e.width-i-t[Tf].currentWidth,height:e.height-A-t[Tf].prevHeight}:{width:e.width-i,height:e.height-A-t[Tf].height};case"rl-row":case"row":return{width:t[Tf].columnWidths.slice(t[Tf].currentColumn).reduce(((t,e)=>t+e)),height:e.height-i};case"table":case"tb":return{width:e.width-i,height:e.height-A-t[Tf].height};default:return e}}function ly(t,e){if(null===t[ap]()[Tf].firstUnsplittable)return!0;if(0===t.w||0===t.h)return!0;const A=t[ip](),i=A[Tf]?.attempt||0,[,s,a,n]=function(t){let e,A,i=""===t.w?NaN:t.w,s=""===t.h?NaN:t.h,[a,n]=[0,0];switch(t.anchorType||""){case"bottomCenter":[a,n]=[i/2,s];break;case"bottomLeft":[a,n]=[0,s];break;case"bottomRight":[a,n]=[i,s];break;case"middleCenter":[a,n]=[i/2,s/2];break;case"middleLeft":[a,n]=[0,s/2];break;case"middleRight":[a,n]=[i,s/2];break;case"topCenter":[a,n]=[i/2,0];break;case"topRight":[a,n]=[i,0]}switch(t.rotate||0){case 0:[e,A]=[-a,-n];break;case 90:[e,A]=[-n,a],[i,s]=[s,-i];break;case 180:[e,A]=[a,n],[i,s]=[-i,-s];break;case 270:[e,A]=[n,-a],[i,s]=[-s,i]}return[t.x+e+Math.min(0,i),t.y+A+Math.min(0,s),Math.abs(i),Math.abs(s)]}(t);switch(A.layout){case"lr-tb":case"rl-tb":return 0===i?t[ap]()[Tf].noLayoutFailure?""!==t.w?Math.round(a-e.width)<=2:e.width>2:!(""!==t.h&&Math.round(n-e.height)>2)&&(""!==t.w?Math.round(a-e.width)<=2||0===A[Tf].numberInLine&&e.height>2:e.width>2):!!t[ap]()[Tf].noLayoutFailure||!(""!==t.h&&Math.round(n-e.height)>2)&&(""===t.w||Math.round(a-e.width)<=2||!A[Bp]())&&e.height>2;case"table":case"tb":return!!t[ap]()[Tf].noLayoutFailure||(""===t.h||t[Cp]()?(""===t.w||Math.round(a-e.width)<=2||!A[Bp]())&&e.height>2:Math.round(n-e.height)<=2);case"position":return!!t[ap]()[Tf].noLayoutFailure||""===t.h||Math.round(n+s-e.height)<=2||n+s>t[ap]()[Tf].currentContentArea.h;case"rl-row":case"row":return!!t[ap]()[Tf].noLayoutFailure||""===t.h||Math.round(n-e.height)<=2;default:return!0}}const Iy=qp.template.id,dy="http://www.w3.org/2000/svg",uy=/^H(\d+)$/,Cy=new Set(["image/gif","image/jpeg","image/jpg","image/pjpeg","image/png","image/apng","image/x-png","image/bmp","image/x-ms-bmp","image/tiff","image/tif","application/octet-stream"]),By=[[[66,77],"image/bmp"],[[255,216,255],"image/jpeg"],[[73,73,42,0],"image/tiff"],[[77,77,0,42],"image/tiff"],[[71,73,70,56,57,97],"image/gif"],[[137,80,78,71,13,10,26,10],"image/png"]];function Qy(t){if(!t||!t.border)return{w:0,h:0};const e=t.border[zf]();return e?{w:e.widths[0]+e.widths[2]+e.insets[0]+e.insets[2],h:e.widths[1]+e.widths[3]+e.insets[1]+e.insets[3]}:{w:0,h:0}}function Ey(t){return t.margin&&(t.margin.topInset||t.margin.rightInset||t.margin.bottomInset||t.margin.leftInset)}function fy(t,e){if(!t.value){const e=new Mw({});t[vf](e),t.value=e}t.value[Lp](e)}function*py(t){for(const e of t[tp]())e instanceof fw?yield*e[ep]():yield e}function my(t){return"error"===t.validate?.nullTest}function yy(t){for(;t;){if(!t.traversal)return void(t[Up]=t[sp]()[Up]);if(t[Up])return;let e=null;for(const A of t.traversal[tp]())if("next"===A.operation){e=A;break}if(!e||!e.ref)return void(t[Up]=t[sp]()[Up]);const A=t[ap]();t[Up]=++A[Up];const i=A[Np](e.ref,t);if(!i)return;t=i[0]}}function by(t,e){const A=t.assist;if(A){const t=A[_p]();t&&(e.title=t);const i=A.role.match(uy);if(i){const t="heading",A=i[1];e.role=t,e["aria-level"]=A}}if("table"===t.layout)e.role="table";else if("row"===t.layout)e.role="row";else{const A=t[sp]();"row"===A.layout&&(e.role="TH"===A.assist?.role?"columnheader":"cell")}}function wy(t){if(!t.assist)return null;const e=t.assist;return e.speak&&""!==e.speak[Jf]?e.speak[Jf]:e.toolTip?e.toolTip[Jf]:null}function Dy(t){return Am.success({name:"div",attributes:{class:["xfaRich"],style:Object.create(null)},children:[{name:"span",attributes:{style:Object.create(null)},value:t}]})}function ky(t){const e=t[ap]();null===e[Tf].firstUnsplittable&&(e[Tf].firstUnsplittable=t,e[Tf].noLayoutFailure=!0)}function Sy(t){const e=t[ap]();e[Tf].firstUnsplittable===t&&(e[Tf].noLayoutFailure=!1)}function xy(t){if(t[Tf])return!1;if(t[Tf]=Object.create(null),"auto"===t.targetType)return!1;const e=t[ap]();let A=null;if(t.target){if(A=e[Np](t.target,t[sp]()),!A)return!1;A=A[0]}const{currentPageArea:i,currentContentArea:s}=e[Tf];if("pageArea"===t.targetType)return A instanceof $b||(A=null),t.startNew?(t[Tf].target=A||i,!0):!(!A||A===i||(t[Tf].target=A,0));A instanceof tb||(A=null);const a=A&&A[sp]();let n,r=a;if(t.startNew)if(A){const t=a.contentArea.children,e=t.indexOf(s),i=t.indexOf(A);-1!==e&&et,i[Tf].noLayoutFailure=!0;const n=e[_p](A);t[Rf](n.html,n.bbox),i[Tf].noLayoutFailure=s,e[ip]=a}class Ry extends Ym{constructor(t){super(Iy,"appearanceFilter"),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||""}}class vy extends Gm{constructor(t){super(Iy,"arc",!0),this.circular=Vp({data:t.circular,defaultValue:0,validate:t=>1===t}),this.hand=zp(t.hand,["even","left","right"]),this.id=t.id||"",this.startAngle=Zp({data:t.startAngle,defaultValue:0,validate:t=>!0}),this.sweepAngle=Zp({data:t.sweepAngle,defaultValue:360,validate:t=>!0}),this.use=t.use||"",this.usehref=t.usehref||"",this.edge=null,this.fill=null}[_p](){const t=this.edge||new hb({}),e=t[Tp](),A=Object.create(null);let i;"visible"===this.fill?.presence?Object.assign(A,this.fill[Tp]()):A.fill="transparent",A.strokeWidth=qm("visible"===t.presence?t.thickness:0),A.stroke=e.color;const s={xmlns:dy,style:{width:"100%",height:"100%",overflow:"visible"}};if(360===this.sweepAngle)i={name:"ellipse",attributes:{xmlns:dy,cx:"50%",cy:"50%",rx:"50%",ry:"50%",style:A}};else{const t=this.startAngle*Math.PI/180,e=this.sweepAngle*Math.PI/180,a=this.sweepAngle>180?1:0,[n,r,o,g]=[50*(1+Math.cos(t)),50*(1-Math.sin(t)),50*(1+Math.cos(t+e)),50*(1-Math.sin(t+e))];i={name:"path",attributes:{xmlns:dy,d:`M ${n} ${r} A 50 50 0 ${a} 0 ${o} ${g}`,vectorEffect:"non-scaling-stroke",style:A}},Object.assign(s,{viewBox:"0 0 100 100",preserveAspectRatio:"none"})}const a={name:"svg",children:[i],attributes:s};return Ey(this[sp]()[sp]())?Am.success({name:"div",attributes:{style:{display:"inline",width:"100%",height:"100%"}},children:[a]}):(a.attributes.style.position="absolute",Am.success(a))}}class Ny extends Gm{constructor(t){super(Iy,"area",!0),this.colSpan=Vp({data:t.colSpan,defaultValue:1,validate:t=>t>=1||-1===t}),this.id=t.id||"",this.name=t.name||"",this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.x=$p(t.x,"0pt"),this.y=$p(t.y,"0pt"),this.desc=null,this.extras=null,this.area=new Lm,this.draw=new Lm,this.exObject=new Lm,this.exclGroup=new Lm,this.field=new Lm,this.subform=new Lm,this.subformSet=new Lm}*[ep](){yield*py(this)}[Qp](){return!0}[lp](){return!0}[Rf](t,e){const[A,i,s,a]=e;this[Tf].width=Math.max(this[Tf].width,A+s),this[Tf].height=Math.max(this[Tf].height,i+a),this[Tf].children.push(t)}[Wf](){return this[Tf].availableSpace}[_p](t){const e=$m(this,"position"),A={style:e,id:this[Pp],class:["xfaArea"]};iy(this)&&A.class.push("xfaPrintOnly"),this.name&&(A.xfaName=this.name);const i=[];this[Tf]={children:i,width:0,height:0,availableSpace:t};const s=this[Nf]({filter:new Set(["area","draw","field","exclGroup","subform","subformSet"]),include:!0});if(!s.success)return s.isBreak()?s:(delete this[Tf],Am.FAILURE);e.width=qm(this[Tf].width),e.height=qm(this[Tf].height);const a={name:"div",attributes:A,children:i},n=[this.x,this.y,this[Tf].width,this[Tf].height];return delete this[Tf],Am.success(a,n)}}class My extends Gm{constructor(t){super(Iy,"assist",!0),this.id=t.id||"",this.role=t.role||"",this.use=t.use||"",this.usehref=t.usehref||"",this.speak=null,this.toolTip=null}[_p](){return this.toolTip?.[Jf]||null}}class Gy extends Gm{constructor(t){super(Iy,"barcode",!0),this.charEncoding=Xp({data:t.charEncoding?t.charEncoding.toLowerCase():"",defaultValue:"",validate:t=>["utf-8","big-five","fontspecific","gbk","gb-18030","gb-2312","ksc-5601","none","shift-jis","ucs-2","utf-16"].includes(t)||t.match(/iso-8859-\d{2}/)}),this.checksum=zp(t.checksum,["none","1mod10","1mod10_1mod11","2mod10","auto"]),this.dataColumnCount=Vp({data:t.dataColumnCount,defaultValue:-1,validate:t=>t>=0}),this.dataLength=Vp({data:t.dataLength,defaultValue:-1,validate:t=>t>=0}),this.dataPrep=zp(t.dataPrep,["none","flateCompress"]),this.dataRowCount=Vp({data:t.dataRowCount,defaultValue:-1,validate:t=>t>=0}),this.endChar=t.endChar||"",this.errorCorrectionLevel=Vp({data:t.errorCorrectionLevel,defaultValue:-1,validate:t=>t>=0&&t<=8}),this.id=t.id||"",this.moduleHeight=$p(t.moduleHeight,"5mm"),this.moduleWidth=$p(t.moduleWidth,"0.25mm"),this.printCheckDigit=Vp({data:t.printCheckDigit,defaultValue:0,validate:t=>1===t}),this.rowColumnRatio=tm(t.rowColumnRatio),this.startChar=t.startChar||"",this.textLocation=zp(t.textLocation,["below","above","aboveEmbedded","belowEmbedded","none"]),this.truncate=Vp({data:t.truncate,defaultValue:0,validate:t=>1===t}),this.type=zp(t.type?t.type.toLowerCase():"",["aztec","codabar","code2of5industrial","code2of5interleaved","code2of5matrix","code2of5standard","code3of9","code3of9extended","code11","code49","code93","code128","code128a","code128b","code128c","code128sscc","datamatrix","ean8","ean8add2","ean8add5","ean13","ean13add2","ean13add5","ean13pwcd","fim","logmars","maxicode","msi","pdf417","pdf417macro","plessey","postauscust2","postauscust3","postausreplypaid","postausstandard","postukrm4scc","postusdpbc","postusimb","postusstandard","postus5zip","qrcode","rfid","rss14","rss14expanded","rss14limited","rss14stacked","rss14stackedomni","rss14truncated","telepen","ucc128","ucc128random","ucc128sscc","upca","upcaadd2","upcaadd5","upcapwcd","upce","upceadd2","upceadd5","upcean2","upcean5","upsmaxicode"]),this.upsMode=zp(t.upsMode,["usCarrier","internationalCarrier","secureSymbol","standardSymbol"]),this.use=t.use||"",this.usehref=t.usehref||"",this.wideNarrowRatio=tm(t.wideNarrowRatio),this.encrypt=null,this.extras=null}}class Ly extends Gm{constructor(t){super(Iy,"bind",!0),this.match=zp(t.match,["once","dataRef","global","none"]),this.ref=t.ref||"",this.picture=null}}class Uy extends Gm{constructor(t){super(Iy,"bindItems"),this.connection=t.connection||"",this.labelRef=t.labelRef||"",this.ref=t.ref||"",this.valueRef=t.valueRef||""}}class Hy extends Gm{constructor(t){super(Iy,"bookend"),this.id=t.id||"",this.leader=t.leader||"",this.trailer=t.trailer||"",this.use=t.use||"",this.usehref=t.usehref||""}}class Jy extends Pm{constructor(t){super(Iy,"boolean"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[_p](t){return Dy(1===this[Jf]?"1":"0")}}class _y extends Gm{constructor(t){super(Iy,"border",!0),this.break=zp(t.break,["close","open"]),this.hand=zp(t.hand,["even","left","right"]),this.id=t.id||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.corner=new Lm(4),this.edge=new Lm(4),this.extras=null,this.fill=null,this.margin=null}[zf](){if(!this[Tf]){const t=this.edge.children.slice();if(t.length<4){const e=t.at(-1)||new hb({});for(let A=t.length;A<4;A++)t.push(e)}const e=t.map((t=>t.thickness)),A=[0,0,0,0];this.margin&&(A[0]=this.margin.topInset,A[1]=this.margin.rightInset,A[2]=this.margin.bottomInset,A[3]=this.margin.leftInset),this[Tf]={widths:e,insets:A,edges:t}}return this[Tf]}[Tp](){const{edges:t}=this[zf](),e=t.map((t=>{const e=t[Tp]();return e.color||="#000000",e})),A=Object.create(null);if(this.margin&&Object.assign(A,this.margin[Tp]()),"visible"===this.fill?.presence&&Object.assign(A,this.fill[Tp]()),this.corner.children.some((t=>0!==t.radius))){const t=this.corner.children.map((t=>t[Tp]()));if(2===t.length||3===t.length){const e=t.at(-1);for(let A=t.length;A<4;A++)t.push(e)}A.borderRadius=t.map((t=>t.radius)).join(" ")}switch(this.presence){case"invisible":case"hidden":A.borderStyle="";break;case"inactive":A.borderStyle="none";break;default:A.borderStyle=e.map((t=>t.style)).join(" ")}return A.borderWidth=e.map((t=>t.width)).join(" "),A.borderColor=e.map((t=>t.color)).join(" "),A}}class Yy extends Gm{constructor(t){super(Iy,"break",!0),this.after=zp(t.after,["auto","contentArea","pageArea","pageEven","pageOdd"]),this.afterTarget=t.afterTarget||"",this.before=zp(t.before,["auto","contentArea","pageArea","pageEven","pageOdd"]),this.beforeTarget=t.beforeTarget||"",this.bookendLeader=t.bookendLeader||"",this.bookendTrailer=t.bookendTrailer||"",this.id=t.id||"",this.overflowLeader=t.overflowLeader||"",this.overflowTarget=t.overflowTarget||"",this.overflowTrailer=t.overflowTrailer||"",this.startNew=Vp({data:t.startNew,defaultValue:0,validate:t=>1===t}),this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}}class Ty extends Gm{constructor(t){super(Iy,"breakAfter",!0),this.id=t.id||"",this.leader=t.leader||"",this.startNew=Vp({data:t.startNew,defaultValue:0,validate:t=>1===t}),this.target=t.target||"",this.targetType=zp(t.targetType,["auto","contentArea","pageArea"]),this.trailer=t.trailer||"",this.use=t.use||"",this.usehref=t.usehref||"",this.script=null}}class Py extends Gm{constructor(t){super(Iy,"breakBefore",!0),this.id=t.id||"",this.leader=t.leader||"",this.startNew=Vp({data:t.startNew,defaultValue:0,validate:t=>1===t}),this.target=t.target||"",this.targetType=zp(t.targetType,["auto","contentArea","pageArea"]),this.trailer=t.trailer||"",this.use=t.use||"",this.usehref=t.usehref||"",this.script=null}[_p](t){return this[Tf]={},Am.FAILURE}}class Ky extends Gm{constructor(t){super(Iy,"button",!0),this.highlight=zp(t.highlight,["inverted","none","outline","push"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}[_p](t){const e=this[sp]()[sp](),A={name:"button",attributes:{id:this[Pp],class:["xfaButton"],style:{}},children:[]};for(const t of e.event.children){if("click"!==t.activity||!t.script)continue;const e=Cl(t.script[Jf]);if(!e)continue;const i=ry(e.url);i&&A.children.push({name:"a",attributes:{id:"link"+this[Pp],href:i,newWindow:e.newWindow,class:["xfaLink"],style:{}},children:[]})}return Am.success(A)}}class qy extends Gm{constructor(t){super(Iy,"calculate",!0),this.id=t.id||"",this.override=zp(t.override,["disabled","error","ignore","warning"]),this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.message=null,this.script=null}}class Oy extends Gm{constructor(t){super(Iy,"caption",!0),this.id=t.id||"",this.placement=zp(t.placement,["left","bottom","inline","right","top"]),this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.reserve=Math.ceil($p(t.reserve)),this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.font=null,this.margin=null,this.para=null,this.value=null}[Lp](t){fy(this,t)}[zf](t){if(!this[Tf]){let{width:e,height:A}=t;switch(this.placement){case"left":case"right":case"inline":e=this.reserve<=0?e:this.reserve;break;case"top":case"bottom":A=this.reserve<=0?A:this.reserve}this[Tf]=Vm(this,{width:e,height:A})}return this[Tf]}[_p](t){if(!this.value)return Am.EMPTY;this[xp]();const e=this.value[_p](t).html;if(!e)return this[Sp](),Am.EMPTY;const A=this.reserve;if(this.reserve<=0){const{w:e,h:A}=this[zf](t);switch(this.placement){case"left":case"right":case"inline":this.reserve=e;break;case"top":case"bottom":this.reserve=A}}const i=[];"string"==typeof e?i.push({name:"#text",value:e}):i.push(e);const s=$m(this,"font","margin","visibility");switch(this.placement){case"left":case"right":this.reserve>0&&(s.width=qm(this.reserve));break;case"top":case"bottom":this.reserve>0&&(s.height=qm(this.reserve))}return ay(this,null,e),this[Sp](),this.reserve=A,Am.success({name:"div",attributes:{style:s,class:["xfaCaption"]},children:i})}}class Wy extends Ym{constructor(t){super(Iy,"certificate"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class jy extends Gm{constructor(t){super(Iy,"certificates",!0),this.credentialServerPolicy=zp(t.credentialServerPolicy,["optional","required"]),this.id=t.id||"",this.url=t.url||"",this.urlPolicy=t.urlPolicy||"",this.use=t.use||"",this.usehref=t.usehref||"",this.encryption=null,this.issuers=null,this.keyUsage=null,this.oids=null,this.signing=null,this.subjectDNs=null}}class Vy extends Gm{constructor(t){super(Iy,"checkButton",!0),this.id=t.id||"",this.mark=zp(t.mark,["default","check","circle","cross","diamond","square","star"]),this.shape=zp(t.shape,["square","round"]),this.size=$p(t.size,"10pt"),this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.extras=null,this.margin=null}[_p](t){const e=$m("margin"),A=qm(this.size);let i,s,a;e.width=e.height=A;const n=this[sp]()[sp](),r=n.items.children.length&&n.items.children[0][_p]().html||[],o={on:(void 0!==r[0]?r[0]:"on").toString(),off:(void 0!==r[1]?r[1]:"off").toString()},g=(n.value?.[Hp]()||"off")===o.on||void 0,c=n[ip](),h=n[Pp];let l;c instanceof mb?(a=c[Pp],i="radio",s="xfaRadio",l=c[_f]?.[Pp]||c[Pp]):(i="checkbox",s="xfaCheckbox",l=n[_f]?.[Pp]||n[Pp]);const I={name:"input",attributes:{class:[s],style:e,fieldId:h,dataId:l,type:i,checked:g,xfaOn:o.on,xfaOff:o.off,"aria-label":wy(n),"aria-required":!1}};return a&&(I.attributes.name=a),my(n)&&(I.attributes["aria-required"]=!0,I.attributes.required=!0),Am.success({name:"label",attributes:{class:["xfaLabel"]},children:[I]})}}class Zy extends Gm{constructor(t){super(Iy,"choiceList",!0),this.commitOn=zp(t.commitOn,["select","exit"]),this.id=t.id||"",this.open=zp(t.open,["userControl","always","multiSelect","onEntry"]),this.textEntry=Vp({data:t.textEntry,defaultValue:0,validate:t=>1===t}),this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.extras=null,this.margin=null}[_p](t){const e=$m(this,"border","margin"),A=this[sp]()[sp](),i={fontSize:`calc(${A.font?.size||10}px * var(--scale-factor))`},s=[];if(A.items.children.length>0){const t=A.items;let e=0,a=0;2===t.children.length&&(e=t.children[0].save,a=1-e);const n=t.children[e][_p]().html,r=t.children[a][_p]().html;let o=!1;const g=A.value?.[Hp]()||"";for(let t=0,e=n.length;tMath.min(Math.max(0,parseInt(t.trim(),10)),255))).map((t=>isNaN(t)?0:t));return a.length<3||([A,i,s]=a),{r:A,g:i,b:s}}(t.value):"",this.extras=null}[rp](){return!1}[Tp](){return this.value?uh.makeHexColor(this.value.r,this.value.g,this.value.b):null}}class zy extends Gm{constructor(t){super(Iy,"comb"),this.id=t.id||"",this.numberOfCells=Vp({data:t.numberOfCells,defaultValue:0,validate:t=>t>=0}),this.use=t.use||"",this.usehref=t.usehref||""}}class $y extends Gm{constructor(t){super(Iy,"connect",!0),this.connection=t.connection||"",this.id=t.id||"",this.ref=t.ref||"",this.usage=zp(t.usage,["exportAndImport","exportOnly","importOnly"]),this.use=t.use||"",this.usehref=t.usehref||"",this.picture=null}}class tb extends Gm{constructor(t){super(Iy,"contentArea",!0),this.h=$p(t.h),this.id=t.id||"",this.name=t.name||"",this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.w=$p(t.w),this.x=$p(t.x,"0pt"),this.y=$p(t.y,"0pt"),this.desc=null,this.extras=null}[_p](t){const e={left:qm(this.x),top:qm(this.y),width:qm(this.w),height:qm(this.h)},A=["xfaContentarea"];return iy(this)&&A.push("xfaPrintOnly"),Am.success({name:"div",children:[],attributes:{style:e,class:A,id:this[Pp]}})}}class eb extends Gm{constructor(t){super(Iy,"corner",!0),this.id=t.id||"",this.inverted=Vp({data:t.inverted,defaultValue:0,validate:t=>1===t}),this.join=zp(t.join,["square","round"]),this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.radius=$p(t.radius),this.stroke=zp(t.stroke,["solid","dashDot","dashDotDot","dashed","dotted","embossed","etched","lowered","raised"]),this.thickness=$p(t.thickness,"0.5pt"),this.use=t.use||"",this.usehref=t.usehref||"",this.color=null,this.extras=null}[Tp](){const t=$m(this,"visibility");return t.radius=qm("square"===this.join?0:this.radius),t}}class Ab extends Jm{constructor(t){super(Iy,"date"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){const t=this[Jf].trim();this[Jf]=t?new Date(t):null}[_p](t){return Dy(this[Jf]?this[Jf].toString():"")}}class ib extends Jm{constructor(t){super(Iy,"dateTime"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){const t=this[Jf].trim();this[Jf]=t?new Date(t):null}[_p](t){return Dy(this[Jf]?this[Jf].toString():"")}}class sb extends Gm{constructor(t){super(Iy,"dateTimeEdit",!0),this.hScrollPolicy=zp(t.hScrollPolicy,["auto","off","on"]),this.id=t.id||"",this.picker=zp(t.picker,["host","none"]),this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.comb=null,this.extras=null,this.margin=null}[_p](t){const e=$m(this,"border","font","margin"),A=this[sp]()[sp](),i={name:"input",attributes:{type:"text",fieldId:A[Pp],dataId:A[_f]?.[Pp]||A[Pp],class:["xfaTextfield"],style:e,"aria-label":wy(A),"aria-required":!1}};return my(A)&&(i.attributes["aria-required"]=!0,i.attributes.required=!0),Am.success({name:"label",attributes:{class:["xfaLabel"]},children:[i]})}}class ab extends Jm{constructor(t){super(Iy,"decimal"),this.fracDigits=Vp({data:t.fracDigits,defaultValue:2,validate:t=>!0}),this.id=t.id||"",this.leadDigits=Vp({data:t.leadDigits,defaultValue:-1,validate:t=>!0}),this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){const t=parseFloat(this[Jf].trim());this[Jf]=isNaN(t)?null:t}[_p](t){return Dy(null!==this[Jf]?this[Jf].toString():"")}}class nb extends Gm{constructor(t){super(Iy,"defaultUi",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}}class rb extends Gm{constructor(t){super(Iy,"desc",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.boolean=new Lm,this.date=new Lm,this.dateTime=new Lm,this.decimal=new Lm,this.exData=new Lm,this.float=new Lm,this.image=new Lm,this.integer=new Lm,this.text=new Lm,this.time=new Lm}}class ob extends _m{constructor(t){super(Iy,"digestMethod",["","SHA1","SHA256","SHA512","RIPEMD160"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||""}}class gb extends Gm{constructor(t){super(Iy,"digestMethods",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.digestMethod=new Lm}}class cb extends Gm{constructor(t){super(Iy,"draw",!0),this.anchorType=zp(t.anchorType,["topLeft","bottomCenter","bottomLeft","bottomRight","middleCenter","middleLeft","middleRight","topCenter","topRight"]),this.colSpan=Vp({data:t.colSpan,defaultValue:1,validate:t=>t>=1||-1===t}),this.h=t.h?$p(t.h):"",this.hAlign=zp(t.hAlign,["left","center","justify","justifyAll","radix","right"]),this.id=t.id||"",this.locale=t.locale||"",this.maxH=$p(t.maxH,"0pt"),this.maxW=$p(t.maxW,"0pt"),this.minH=$p(t.minH,"0pt"),this.minW=$p(t.minW,"0pt"),this.name=t.name||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.relevant=em(t.relevant),this.rotate=Vp({data:t.rotate,defaultValue:0,validate:t=>t%90==0}),this.use=t.use||"",this.usehref=t.usehref||"",this.w=t.w?$p(t.w):"",this.x=$p(t.x,"0pt"),this.y=$p(t.y,"0pt"),this.assist=null,this.border=null,this.caption=null,this.desc=null,this.extras=null,this.font=null,this.keep=null,this.margin=null,this.para=null,this.traversal=null,this.ui=null,this.value=null,this.setProperty=new Lm}[Lp](t){fy(this,t)}[_p](t){if(yy(this),"hidden"===this.presence||"inactive"===this.presence)return Am.EMPTY;Xm(this),this[xp]();const e=this.w,A=this.h,{w:i,h:s,isBroken:a}=Vm(this,t);if(i&&""===this.w){if(a&&this[ip]()[Bp]())return this[Sp](),Am.FAILURE;this.w=i}if(s&&""===this.h&&(this.h=s),ky(this),!ly(this,t))return this.w=e,this.h=A,this[Sp](),Am.FAILURE;Sy(this);const n=$m(this,"font","hAlign","dimensions","position","presence","rotate","anchorType","border","margin");Wm(this,n),n.margin&&(n.padding=n.margin,delete n.margin);const r=["xfaDraw"];this.font&&r.push("xfaFont"),iy(this)&&r.push("xfaPrintOnly");const o={style:n,id:this[Pp],class:r};this.name&&(o.xfaName=this.name);const g={name:"div",attributes:o,children:[]};by(this,o);const c=Zm(this,g,t),h=this.value?this.value[_p](t).html:null;return null===h?(this.w=e,this.h=A,this[Sp](),Am.success(ty(this,g),c)):(g.children.push(h),ay(this,n,h),this.w=e,this.h=A,this[Sp](),Am.success(ty(this,g),c))}}class hb extends Gm{constructor(t){super(Iy,"edge",!0),this.cap=zp(t.cap,["square","butt","round"]),this.id=t.id||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.stroke=zp(t.stroke,["solid","dashDot","dashDotDot","dashed","dotted","embossed","etched","lowered","raised"]),this.thickness=$p(t.thickness,"0.5pt"),this.use=t.use||"",this.usehref=t.usehref||"",this.color=null,this.extras=null}[Tp](){const t=$m(this,"visibility");if(Object.assign(t,{linecap:this.cap,width:qm(this.thickness),color:this.color?this.color[Tp]():"#000000",style:""}),"visible"!==this.presence)t.style="none";else switch(this.stroke){case"solid":t.style="solid";break;case"dashDot":case"dashDotDot":case"dashed":t.style="dashed";break;case"dotted":t.style="dotted";break;case"embossed":t.style="ridge";break;case"etched":t.style="groove";break;case"lowered":t.style="inset";break;case"raised":t.style="outset"}return t}}class lb extends _m{constructor(t){super(Iy,"encoding",["adbe.x509.rsa_sha1","adbe.pkcs7.detached","adbe.pkcs7.sha1"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||""}}class Ib extends Gm{constructor(t){super(Iy,"encodings",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.encoding=new Lm}}class db extends Gm{constructor(t){super(Iy,"encrypt",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.certificate=null}}class ub extends Gm{constructor(t){super(Iy,"encryptData",!0),this.id=t.id||"",this.operation=zp(t.operation,["encrypt","decrypt"]),this.target=t.target||"",this.use=t.use||"",this.usehref=t.usehref||"",this.filter=null,this.manifest=null}}class Cb extends Gm{constructor(t){super(Iy,"encryption",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.certificate=new Lm}}class Bb extends _m{constructor(t){super(Iy,"encryptionMethod",["","AES256-CBC","TRIPLEDES-CBC","AES128-CBC","AES192-CBC"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||""}}class Qb extends Gm{constructor(t){super(Iy,"encryptionMethods",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.encryptionMethod=new Lm}}class Eb extends Gm{constructor(t){super(Iy,"event",!0),this.activity=zp(t.activity,["click","change","docClose","docReady","enter","exit","full","indexChange","initialize","mouseDown","mouseEnter","mouseExit","mouseUp","postExecute","postOpen","postPrint","postSave","postSign","postSubmit","preExecute","preOpen","prePrint","preSave","preSign","preSubmit","ready","validationState"]),this.id=t.id||"",this.listen=zp(t.listen,["refOnly","refAndDescendents"]),this.name=t.name||"",this.ref=t.ref||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.encryptData=null,this.execute=null,this.script=null,this.signData=null,this.submit=null}}class fb extends Jm{constructor(t){super(Iy,"exData"),this.contentType=t.contentType||"",this.href=t.href||"",this.id=t.id||"",this.maxLength=Vp({data:t.maxLength,defaultValue:-1,validate:t=>t>=-1}),this.name=t.name||"",this.rid=t.rid||"",this.transferEncoding=zp(t.transferEncoding,["none","base64","package"]),this.use=t.use||"",this.usehref=t.usehref||""}[hp](){return"text/html"===this.contentType}[bp](t){return("text/html"===this.contentType&&t[pp]===qp.xhtml.id||"text/xml"===this.contentType)&&(this[Jf]=t,!0)}[_p](t){return"text/html"===this.contentType&&this[Jf]?this[Jf][_p](t):Am.EMPTY}}class pb extends Gm{constructor(t){super(Iy,"exObject",!0),this.archive=t.archive||"",this.classId=t.classId||"",this.codeBase=t.codeBase||"",this.codeType=t.codeType||"",this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.boolean=new Lm,this.date=new Lm,this.dateTime=new Lm,this.decimal=new Lm,this.exData=new Lm,this.exObject=new Lm,this.float=new Lm,this.image=new Lm,this.integer=new Lm,this.text=new Lm,this.time=new Lm}}class mb extends Gm{constructor(t){super(Iy,"exclGroup",!0),this.access=zp(t.access,["open","nonInteractive","protected","readOnly"]),this.accessKey=t.accessKey||"",this.anchorType=zp(t.anchorType,["topLeft","bottomCenter","bottomLeft","bottomRight","middleCenter","middleLeft","middleRight","topCenter","topRight"]),this.colSpan=Vp({data:t.colSpan,defaultValue:1,validate:t=>t>=1||-1===t}),this.h=t.h?$p(t.h):"",this.hAlign=zp(t.hAlign,["left","center","justify","justifyAll","radix","right"]),this.id=t.id||"",this.layout=zp(t.layout,["position","lr-tb","rl-row","rl-tb","row","table","tb"]),this.maxH=$p(t.maxH,"0pt"),this.maxW=$p(t.maxW,"0pt"),this.minH=$p(t.minH,"0pt"),this.minW=$p(t.minW,"0pt"),this.name=t.name||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.w=t.w?$p(t.w):"",this.x=$p(t.x,"0pt"),this.y=$p(t.y,"0pt"),this.assist=null,this.bind=null,this.border=null,this.calculate=null,this.caption=null,this.desc=null,this.extras=null,this.margin=null,this.para=null,this.traversal=null,this.validate=null,this.connect=new Lm,this.event=new Lm,this.field=new Lm,this.setProperty=new Lm}[lp](){return!0}[rp](){return!0}[Lp](t){for(const e of this.field.children){if(!e.value){const t=new Mw({});e[vf](t),e.value=t}e.value[Lp](t)}}[Bp](){return this.layout.endsWith("-tb")&&0===this[Tf].attempt&&this[Tf].numberInLine>0||this[sp]()[Bp]()}[Cp](){const t=this[ip]();return!!t[Cp]()&&(void 0!==this[Tf]._isSplittable?this[Tf]._isSplittable:"position"===this.layout||this.layout.includes("row")?(this[Tf]._isSplittable=!1,!1):!(t.layout?.endsWith("-tb")&&0!==t[Tf].numberInLine||(this[Tf]._isSplittable=!0,0)))}[Kf](){return gy(this)}[Rf](t,e){cy(this,t,e)}[Wf](){return hy(this)}[_p](t){if(yy(this),"hidden"===this.presence||"inactive"===this.presence||0===this.h||0===this.w)return Am.EMPTY;Xm(this);const e=[],A={id:this[Pp],class:[]};Ay(this,A.class),this[Tf]||(this[Tf]=Object.create(null)),Object.assign(this[Tf],{children:e,attributes:A,attempt:0,line:null,numberInLine:0,availableSpace:{width:Math.min(this.w||1/0,t.width),height:Math.min(this.h||1/0,t.height)},width:0,height:0,prevHeight:0,currentWidth:0});const i=this[Cp]();if(i||ky(this),!ly(this,t))return Am.FAILURE;const s=new Set(["field"]);if(this.layout.includes("row")){const t=this[ip]().columnWidths;Array.isArray(t)&&t.length>0&&(this[Tf].columnWidths=t,this[Tf].currentColumn=0)}const a=$m(this,"anchorType","dimensions","position","presence","border","margin","hAlign"),n=["xfaExclgroup"],r=zm(this);r&&n.push(r),iy(this)&&n.push("xfaPrintOnly"),A.style=a,A.class=n,this.name&&(A.xfaName=this.name),this[xp]();const o="lr-tb"===this.layout||"rl-tb"===this.layout,g=o?2:1;for(;this[Tf].attemptt>=1||-1===t}),this.h=t.h?$p(t.h):"",this.hAlign=zp(t.hAlign,["left","center","justify","justifyAll","radix","right"]),this.id=t.id||"",this.locale=t.locale||"",this.maxH=$p(t.maxH,"0pt"),this.maxW=$p(t.maxW,"0pt"),this.minH=$p(t.minH,"0pt"),this.minW=$p(t.minW,"0pt"),this.name=t.name||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.relevant=em(t.relevant),this.rotate=Vp({data:t.rotate,defaultValue:0,validate:t=>t%90==0}),this.use=t.use||"",this.usehref=t.usehref||"",this.w=t.w?$p(t.w):"",this.x=$p(t.x,"0pt"),this.y=$p(t.y,"0pt"),this.assist=null,this.bind=null,this.border=null,this.calculate=null,this.caption=null,this.desc=null,this.extras=null,this.font=null,this.format=null,this.items=new Lm(2),this.keep=null,this.margin=null,this.para=null,this.traversal=null,this.ui=null,this.validate=null,this.value=null,this.bindItems=new Lm,this.connect=new Lm,this.event=new Lm,this.setProperty=new Lm}[lp](){return!0}[Lp](t){fy(this,t)}[_p](t){if(yy(this),!this.ui){let t;switch(this.ui=new vw({}),this.ui[np]=this[np],this[vf](this.ui),this.items.children.length){case 0:t=new Dw({}),this.ui.textEdit=t;break;case 1:t=new Vy({}),this.ui.checkButton=t;break;case 2:t=new Zy({}),this.ui.choiceList=t}this.ui[vf](t)}if(!this.ui||"hidden"===this.presence||"inactive"===this.presence||0===this.h||0===this.w)return Am.EMPTY;this.caption&&delete this.caption[Tf],this[xp]();const e=this.caption?this.caption[_p](t).html:null,A=this.w,i=this.h;let s=0,a=0;this.margin&&(s=this.margin.leftInset+this.margin.rightInset,a=this.margin.topInset+this.margin.bottomInset);let n=null;if(""===this.w||""===this.h){let e=null,A=null,i=0,r=0;if(this.ui.checkButton)i=r=this.ui.checkButton.size;else{const{w:e,h:A}=Vm(this,t);null!==e?(i=e,r=A):r=function(t,e=!1){let A=null;if(t){const e=jp(t.typeface),i=t[np].fontFinder.find(e);A=sm(t,i)}if(!A)return{lineHeight:12,lineGap:2,lineNoGap:10};const i=t.size||10,s=A.lineHeight?Math.max(e?0:1.2,A.lineHeight):1.2,a=void 0===A.lineGap?.2:A.lineGap;return{lineHeight:s*i,lineGap:a*i,lineNoGap:Math.max(1,s-a)*i}}(this.font,!0).lineNoGap}if(n=Qy(this.ui[zf]()),i+=n.w,r+=n.h,this.caption){const{w:s,h:a,isBroken:n}=this.caption[zf](t);if(n&&this[ip]()[Bp]())return this[Sp](),Am.FAILURE;switch(e=s,A=a,this.caption.placement){case"left":case"right":case"inline":e+=i;break;case"top":case"bottom":A+=r}}else e=i,A=r;e&&""===this.w&&(e+=s,this.w=Math.min(this.maxW<=0?1/0:this.maxW,this.minW+1t>=1&&t<=5}),this.appearanceFilter=null,this.certificates=null,this.digestMethods=null,this.encodings=null,this.encryptionMethods=null,this.handler=null,this.lockDocument=null,this.mdp=null,this.reasons=null,this.timeStamp=null}}class Sb extends Jm{constructor(t){super(Iy,"float"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){const t=parseFloat(this[Jf].trim());this[Jf]=isNaN(t)?null:t}[_p](t){return Dy(null!==this[Jf]?this[Jf].toString():"")}}class xb extends Gm{constructor(t){super(Iy,"font",!0),this.baselineShift=$p(t.baselineShift),this.fontHorizontalScale=Zp({data:t.fontHorizontalScale,defaultValue:100,validate:t=>t>=0}),this.fontVerticalScale=Zp({data:t.fontVerticalScale,defaultValue:100,validate:t=>t>=0}),this.id=t.id||"",this.kerningMode=zp(t.kerningMode,["none","pair"]),this.letterSpacing=$p(t.letterSpacing,"0"),this.lineThrough=Vp({data:t.lineThrough,defaultValue:0,validate:t=>1===t||2===t}),this.lineThroughPeriod=zp(t.lineThroughPeriod,["all","word"]),this.overline=Vp({data:t.overline,defaultValue:0,validate:t=>1===t||2===t}),this.overlinePeriod=zp(t.overlinePeriod,["all","word"]),this.posture=zp(t.posture,["normal","italic"]),this.size=$p(t.size,"10pt"),this.typeface=t.typeface||"Courier",this.underline=Vp({data:t.underline,defaultValue:0,validate:t=>1===t||2===t}),this.underlinePeriod=zp(t.underlinePeriod,["all","word"]),this.use=t.use||"",this.usehref=t.usehref||"",this.weight=zp(t.weight,["normal","bold"]),this.extras=null,this.fill=null}[Mf](t){super[Mf](t),this[np].usedTypefaces.add(this.typeface)}[Tp](){const t=$m(this,"fill"),e=t.color;return e&&("#000000"===e?delete t.color:e.startsWith("#")||(t.background=e,t.backgroundClip="text",t.color="transparent")),this.baselineShift&&(t.verticalAlign=qm(this.baselineShift)),t.fontKerning="none"===this.kerningMode?"none":"normal",t.letterSpacing=qm(this.letterSpacing),0!==this.lineThrough&&(t.textDecoration="line-through",2===this.lineThrough&&(t.textDecorationStyle="double")),0!==this.overline&&(t.textDecoration="overline",2===this.overline&&(t.textDecorationStyle="double")),t.fontStyle=this.posture,t.fontSize=qm(.99*this.size),ny(this,this,this[np].fontFinder,t),0!==this.underline&&(t.textDecoration="underline",2===this.underline&&(t.textDecorationStyle="double")),t.fontWeight=this.weight,t}}class Fb extends Gm{constructor(t){super(Iy,"format",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.picture=null}}class Rb extends Ym{constructor(t){super(Iy,"handler"),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||""}}class vb extends Gm{constructor(t){super(Iy,"hyphenation"),this.excludeAllCaps=Vp({data:t.excludeAllCaps,defaultValue:0,validate:t=>1===t}),this.excludeInitialCap=Vp({data:t.excludeInitialCap,defaultValue:0,validate:t=>1===t}),this.hyphenate=Vp({data:t.hyphenate,defaultValue:0,validate:t=>1===t}),this.id=t.id||"",this.pushCharacterCount=Vp({data:t.pushCharacterCount,defaultValue:3,validate:t=>t>=0}),this.remainCharacterCount=Vp({data:t.remainCharacterCount,defaultValue:3,validate:t=>t>=0}),this.use=t.use||"",this.usehref=t.usehref||"",this.wordCharacterCount=Vp({data:t.wordCharacterCount,defaultValue:7,validate:t=>t>=0})}}class Nb extends Ym{constructor(t){super(Iy,"image"),this.aspect=zp(t.aspect,["fit","actual","height","none","width"]),this.contentType=t.contentType||"",this.href=t.href||"",this.id=t.id||"",this.name=t.name||"",this.transferEncoding=zp(t.transferEncoding,["base64","none","package"]),this.use=t.use||"",this.usehref=t.usehref||""}[_p](){if(this.contentType&&!Cy.has(this.contentType.toLowerCase()))return Am.EMPTY;let t=this[np].images&&this[np].images.get(this.href);if(!t&&(this.href||!this[Jf]))return Am.EMPTY;if(t||"base64"!==this.transferEncoding||(t=ch(atob(this[Jf]))),!t)return Am.EMPTY;if(!this.contentType){for(const[e,A]of By)if(t.length>e.length&&e.every(((e,A)=>e===t[A]))){this.contentType=A;break}if(!this.contentType)return Am.EMPTY}const e=new Blob([t],{type:this.contentType});let A;switch(this.aspect){case"fit":case"actual":break;case"height":A={height:"100%",objectFit:"fill"};break;case"none":A={width:"100%",height:"100%",objectFit:"fill"};break;case"width":A={width:"100%",objectFit:"fill"}}const i=this[sp]();return Am.success({name:"img",attributes:{class:["xfaImage"],style:A,src:URL.createObjectURL(e),alt:i?wy(i[sp]()):null}})}}class Mb extends Gm{constructor(t){super(Iy,"imageEdit",!0),this.data=zp(t.data,["link","embed"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.extras=null,this.margin=null}[_p](t){return"embed"===this.data?Am.success({name:"div",children:[],attributes:{}}):Am.EMPTY}}class Gb extends Jm{constructor(t){super(Iy,"integer"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){const t=parseInt(this[Jf].trim(),10);this[Jf]=isNaN(t)?null:t}[_p](t){return Dy(null!==this[Jf]?this[Jf].toString():"")}}class Lb extends Gm{constructor(t){super(Iy,"issuers",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.certificate=new Lm}}class Ub extends Gm{constructor(t){super(Iy,"items",!0),this.id=t.id||"",this.name=t.name||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.ref=t.ref||"",this.save=Vp({data:t.save,defaultValue:0,validate:t=>1===t}),this.use=t.use||"",this.usehref=t.usehref||"",this.boolean=new Lm,this.date=new Lm,this.dateTime=new Lm,this.decimal=new Lm,this.exData=new Lm,this.float=new Lm,this.image=new Lm,this.integer=new Lm,this.text=new Lm,this.time=new Lm}[_p](){const t=[];for(const e of this[tp]())t.push(e[Hp]());return Am.success(t)}}class Hb extends Gm{constructor(t){super(Iy,"keep",!0),this.id=t.id||"";const e=["none","contentArea","pageArea"];this.intact=zp(t.intact,e),this.next=zp(t.next,e),this.previous=zp(t.previous,e),this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}}class Jb extends Gm{constructor(t){super(Iy,"keyUsage");const e=["","yes","no"];this.crlSign=zp(t.crlSign,e),this.dataEncipherment=zp(t.dataEncipherment,e),this.decipherOnly=zp(t.decipherOnly,e),this.digitalSignature=zp(t.digitalSignature,e),this.encipherOnly=zp(t.encipherOnly,e),this.id=t.id||"",this.keyAgreement=zp(t.keyAgreement,e),this.keyCertSign=zp(t.keyCertSign,e),this.keyEncipherment=zp(t.keyEncipherment,e),this.nonRepudiation=zp(t.nonRepudiation,e),this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||""}}class _b extends Gm{constructor(t){super(Iy,"line",!0),this.hand=zp(t.hand,["even","left","right"]),this.id=t.id||"",this.slope=zp(t.slope,["\\","/"]),this.use=t.use||"",this.usehref=t.usehref||"",this.edge=null}[_p](){const t=this[sp]()[sp](),e=this.edge||new hb({}),A=e[Tp](),i=Object.create(null),s="visible"===e.presence?e.thickness:0;i.strokeWidth=qm(s),i.stroke=A.color;let a,n,r,o,g="100%",c="100%";t.w<=s?([a,n,r,o]=["50%",0,"50%","100%"],g=i.strokeWidth):t.h<=s?([a,n,r,o]=[0,"50%","100%","50%"],c=i.strokeWidth):"\\"===this.slope?[a,n,r,o]=[0,0,"100%","100%"]:[a,n,r,o]=[0,"100%","100%",0];const h={name:"svg",children:[{name:"line",attributes:{xmlns:dy,x1:a,y1:n,x2:r,y2:o,style:i}}],attributes:{xmlns:dy,width:g,height:c,style:{overflow:"visible"}}};return Ey(t)?Am.success({name:"div",attributes:{style:{display:"inline",width:"100%",height:"100%"}},children:[h]}):(h.attributes.style.position="absolute",Am.success(h))}}class Yb extends Gm{constructor(t){super(Iy,"linear",!0),this.id=t.id||"",this.type=zp(t.type,["toRight","toBottom","toLeft","toTop"]),this.use=t.use||"",this.usehref=t.usehref||"",this.color=null,this.extras=null}[Tp](t){return t=t?t[Tp]():"#FFFFFF",`linear-gradient(${this.type.replace(/([RBLT])/," $1").toLowerCase()}, ${t}, ${this.color?this.color[Tp]():"#000000"})`}}class Tb extends Jm{constructor(t){super(Iy,"lockDocument"),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){this[Jf]=zp(this[Jf],["auto","0","1"])}}class Pb extends Gm{constructor(t){super(Iy,"manifest",!0),this.action=zp(t.action,["include","all","exclude"]),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.ref=new Lm}}class Kb extends Gm{constructor(t){super(Iy,"margin",!0),this.bottomInset=$p(t.bottomInset,"0"),this.id=t.id||"",this.leftInset=$p(t.leftInset,"0"),this.rightInset=$p(t.rightInset,"0"),this.topInset=$p(t.topInset,"0"),this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}[Tp](){return{margin:qm(this.topInset)+" "+qm(this.rightInset)+" "+qm(this.bottomInset)+" "+qm(this.leftInset)}}}class qb extends Gm{constructor(t){super(Iy,"mdp"),this.id=t.id||"",this.permissions=Vp({data:t.permissions,defaultValue:2,validate:t=>1===t||3===t}),this.signatureType=zp(t.signatureType,["filler","author"]),this.use=t.use||"",this.usehref=t.usehref||""}}class Ob extends Gm{constructor(t){super(Iy,"medium"),this.id=t.id||"",this.imagingBBox=function(t){const e=-1;if(!t)return{x:e,y:e,width:e,height:e};const A=t.trim().split(/\s*,\s*/).map((t=>$p(t,"-1")));if(A.length<4||A[2]<0||A[3]<0)return{x:e,y:e,width:e,height:e};const[i,s,a,n]=A;return{x:i,y:s,width:a,height:n}}(t.imagingBBox),this.long=$p(t.long),this.orientation=zp(t.orientation,["portrait","landscape"]),this.short=$p(t.short),this.stock=t.stock||"",this.trayIn=zp(t.trayIn,["auto","delegate","pageFront"]),this.trayOut=zp(t.trayOut,["auto","delegate"]),this.use=t.use||"",this.usehref=t.usehref||""}}class Wb extends Gm{constructor(t){super(Iy,"message",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.text=new Lm}}class jb extends Gm{constructor(t){super(Iy,"numericEdit",!0),this.hScrollPolicy=zp(t.hScrollPolicy,["auto","off","on"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.comb=null,this.extras=null,this.margin=null}[_p](t){const e=$m(this,"border","font","margin"),A=this[sp]()[sp](),i={name:"input",attributes:{type:"text",fieldId:A[Pp],dataId:A[_f]?.[Pp]||A[Pp],class:["xfaTextfield"],style:e,"aria-label":wy(A),"aria-required":!1}};return my(A)&&(i.attributes["aria-required"]=!0,i.attributes.required=!0),Am.success({name:"label",attributes:{class:["xfaLabel"]},children:[i]})}}class Vb extends Gm{constructor(t){super(Iy,"occur",!0),this.id=t.id||"",this.initial=""!==t.initial?Vp({data:t.initial,defaultValue:"",validate:t=>!0}):"",this.max=""!==t.max?Vp({data:t.max,defaultValue:1,validate:t=>!0}):"",this.min=""!==t.min?Vp({data:t.min,defaultValue:1,validate:t=>!0}):"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}[Mf](){const t=this[sp](),e=this.min;""===this.min&&(this.min=t instanceof $b||t instanceof tw?0:1),""===this.max&&(this.max=""===e?t instanceof $b||t instanceof tw?-1:1:this.min),-1!==this.max&&this.max!0}),this.name=t.name||"",this.numbered=Vp({data:t.numbered,defaultValue:1,validate:t=>!0}),this.oddOrEven=zp(t.oddOrEven,["any","even","odd"]),this.pagePosition=zp(t.pagePosition,["any","first","last","only","rest"]),this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.desc=null,this.extras=null,this.medium=null,this.occur=null,this.area=new Lm,this.contentArea=new Lm,this.draw=new Lm,this.exclGroup=new Lm,this.field=new Lm,this.subform=new Lm}[Ep](){return this[Tf]?!this.occur||-1===this.occur.max||this[Tf].numberOfUset.oddOrEven===e&&t.pagePosition===A));return i||(i=this.pageArea.children.find((t=>"any"===t.oddOrEven&&t.pagePosition===A)),i||(i=this.pageArea.children.find((t=>"any"===t.oddOrEven&&"any"===t.pagePosition)),i||this.pageArea.children[0]))}}class ew extends Gm{constructor(t){super(Iy,"para",!0),this.hAlign=zp(t.hAlign,["left","center","justify","justifyAll","radix","right"]),this.id=t.id||"",this.lineHeight=t.lineHeight?$p(t.lineHeight,"0pt"):"",this.marginLeft=t.marginLeft?$p(t.marginLeft,"0pt"):"",this.marginRight=t.marginRight?$p(t.marginRight,"0pt"):"",this.orphans=Vp({data:t.orphans,defaultValue:0,validate:t=>t>=0}),this.preserve=t.preserve||"",this.radixOffset=t.radixOffset?$p(t.radixOffset,"0pt"):"",this.spaceAbove=t.spaceAbove?$p(t.spaceAbove,"0pt"):"",this.spaceBelow=t.spaceBelow?$p(t.spaceBelow,"0pt"):"",this.tabDefault=t.tabDefault?$p(this.tabDefault):"",this.tabStops=(t.tabStops||"").trim().split(/\s+/).map(((t,e)=>e%2==1?$p(t):t)),this.textIndent=t.textIndent?$p(t.textIndent,"0pt"):"",this.use=t.use||"",this.usehref=t.usehref||"",this.vAlign=zp(t.vAlign,["top","bottom","middle"]),this.widows=Vp({data:t.widows,defaultValue:0,validate:t=>t>=0}),this.hyphenation=null}[Tp](){const t=$m(this,"hAlign");return""!==this.marginLeft&&(t.paddingLeft=qm(this.marginLeft)),""!==this.marginRight&&(t.paddingight=qm(this.marginRight)),""!==this.spaceAbove&&(t.paddingTop=qm(this.spaceAbove)),""!==this.spaceBelow&&(t.paddingBottom=qm(this.spaceBelow)),""!==this.textIndent&&(t.textIndent=qm(this.textIndent),ey(t)),this.lineHeight>0&&(t.lineHeight=qm(this.lineHeight)),""!==this.tabDefault&&(t.tabSize=qm(this.tabDefault)),this.tabStops.length,this.hyphenatation&&Object.assign(t,this.hyphenatation[Tp]()),t}}class Aw extends Gm{constructor(t){super(Iy,"passwordEdit",!0),this.hScrollPolicy=zp(t.hScrollPolicy,["auto","off","on"]),this.id=t.id||"",this.passwordChar=t.passwordChar||"*",this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.extras=null,this.margin=null}}class iw extends Gm{constructor(t){super(Iy,"pattern",!0),this.id=t.id||"",this.type=zp(t.type,["crossHatch","crossDiagonal","diagonalLeft","diagonalRight","horizontal","vertical"]),this.use=t.use||"",this.usehref=t.usehref||"",this.color=null,this.extras=null}[Tp](t){t=t?t[Tp]():"#FFFFFF";const e=this.color?this.color[Tp]():"#000000",A="repeating-linear-gradient",i=`${t},${t} 5px,${e} 5px,${e} 10px`;switch(this.type){case"crossHatch":return`${A}(to top,${i}) ${A}(to right,${i})`;case"crossDiagonal":return`${A}(45deg,${i}) ${A}(-45deg,${i})`;case"diagonalLeft":return`${A}(45deg,${i})`;case"diagonalRight":return`${A}(-45deg,${i})`;case"horizontal":return`${A}(to top,${i})`;case"vertical":return`${A}(to right,${i})`}return""}}class sw extends Ym{constructor(t){super(Iy,"picture"),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||""}}class aw extends Gm{constructor(t){super(Iy,"proto",!0),this.appearanceFilter=new Lm,this.arc=new Lm,this.area=new Lm,this.assist=new Lm,this.barcode=new Lm,this.bindItems=new Lm,this.bookend=new Lm,this.boolean=new Lm,this.border=new Lm,this.break=new Lm,this.breakAfter=new Lm,this.breakBefore=new Lm,this.button=new Lm,this.calculate=new Lm,this.caption=new Lm,this.certificate=new Lm,this.certificates=new Lm,this.checkButton=new Lm,this.choiceList=new Lm,this.color=new Lm,this.comb=new Lm,this.connect=new Lm,this.contentArea=new Lm,this.corner=new Lm,this.date=new Lm,this.dateTime=new Lm,this.dateTimeEdit=new Lm,this.decimal=new Lm,this.defaultUi=new Lm,this.desc=new Lm,this.digestMethod=new Lm,this.digestMethods=new Lm,this.draw=new Lm,this.edge=new Lm,this.encoding=new Lm,this.encodings=new Lm,this.encrypt=new Lm,this.encryptData=new Lm,this.encryption=new Lm,this.encryptionMethod=new Lm,this.encryptionMethods=new Lm,this.event=new Lm,this.exData=new Lm,this.exObject=new Lm,this.exclGroup=new Lm,this.execute=new Lm,this.extras=new Lm,this.field=new Lm,this.fill=new Lm,this.filter=new Lm,this.float=new Lm,this.font=new Lm,this.format=new Lm,this.handler=new Lm,this.hyphenation=new Lm,this.image=new Lm,this.imageEdit=new Lm,this.integer=new Lm,this.issuers=new Lm,this.items=new Lm,this.keep=new Lm,this.keyUsage=new Lm,this.line=new Lm,this.linear=new Lm,this.lockDocument=new Lm,this.manifest=new Lm,this.margin=new Lm,this.mdp=new Lm,this.medium=new Lm,this.message=new Lm,this.numericEdit=new Lm,this.occur=new Lm,this.oid=new Lm,this.oids=new Lm,this.overflow=new Lm,this.pageArea=new Lm,this.pageSet=new Lm,this.para=new Lm,this.passwordEdit=new Lm,this.pattern=new Lm,this.picture=new Lm,this.radial=new Lm,this.reason=new Lm,this.reasons=new Lm,this.rectangle=new Lm,this.ref=new Lm,this.script=new Lm,this.setProperty=new Lm,this.signData=new Lm,this.signature=new Lm,this.signing=new Lm,this.solid=new Lm,this.speak=new Lm,this.stipple=new Lm,this.subform=new Lm,this.subformSet=new Lm,this.subjectDN=new Lm,this.subjectDNs=new Lm,this.submit=new Lm,this.text=new Lm,this.textEdit=new Lm,this.time=new Lm,this.timeStamp=new Lm,this.toolTip=new Lm,this.traversal=new Lm,this.traverse=new Lm,this.ui=new Lm,this.validate=new Lm,this.value=new Lm,this.variables=new Lm}}class nw extends Gm{constructor(t){super(Iy,"radial",!0),this.id=t.id||"",this.type=zp(t.type,["toEdge","toCenter"]),this.use=t.use||"",this.usehref=t.usehref||"",this.color=null,this.extras=null}[Tp](t){t=t?t[Tp]():"#FFFFFF";const e=this.color?this.color[Tp]():"#000000";return`radial-gradient(circle at center, ${"toEdge"===this.type?`${t},${e}`:`${e},${t}`})`}}class rw extends Ym{constructor(t){super(Iy,"reason"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class ow extends Gm{constructor(t){super(Iy,"reasons",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.reason=new Lm}}class gw extends Gm{constructor(t){super(Iy,"rectangle",!0),this.hand=zp(t.hand,["even","left","right"]),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.corner=new Lm(4),this.edge=new Lm(4),this.fill=null}[_p](){const t=this.edge.children.length?this.edge.children[0]:new hb({}),e=t[Tp](),A=Object.create(null);"visible"===this.fill?.presence?Object.assign(A,this.fill[Tp]()):A.fill="transparent",A.strokeWidth=qm("visible"===t.presence?t.thickness:0),A.stroke=e.color;const i=(this.corner.children.length?this.corner.children[0]:new eb({}))[Tp](),s={name:"svg",children:[{name:"rect",attributes:{xmlns:dy,width:"100%",height:"100%",x:0,y:0,rx:i.radius,ry:i.radius,style:A}}],attributes:{xmlns:dy,style:{overflow:"visible"},width:"100%",height:"100%"}};return Ey(this[sp]()[sp]())?Am.success({name:"div",attributes:{style:{display:"inline",width:"100%",height:"100%"}},children:[s]}):(s.attributes.style.position="absolute",Am.success(s))}}class cw extends Ym{constructor(t){super(Iy,"ref"),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||""}}class hw extends Ym{constructor(t){super(Iy,"script"),this.binding=t.binding||"",this.contentType=t.contentType||"",this.id=t.id||"",this.name=t.name||"",this.runAt=zp(t.runAt,["client","both","server"]),this.use=t.use||"",this.usehref=t.usehref||""}}class lw extends Gm{constructor(t){super(Iy,"setProperty"),this.connection=t.connection||"",this.ref=t.ref||"",this.target=t.target||""}}class Iw extends Gm{constructor(t){super(Iy,"signData",!0),this.id=t.id||"",this.operation=zp(t.operation,["sign","clear","verify"]),this.ref=t.ref||"",this.target=t.target||"",this.use=t.use||"",this.usehref=t.usehref||"",this.filter=null,this.manifest=null}}class dw extends Gm{constructor(t){super(Iy,"signature",!0),this.id=t.id||"",this.type=zp(t.type,["PDF1.3","PDF1.6"]),this.use=t.use||"",this.usehref=t.usehref||"",this.border=null,this.extras=null,this.filter=null,this.manifest=null,this.margin=null}}class uw extends Gm{constructor(t){super(Iy,"signing",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.certificate=new Lm}}class Cw extends Gm{constructor(t){super(Iy,"solid",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null}[Tp](t){return t?t[Tp]():"#FFFFFF"}}class Bw extends Ym{constructor(t){super(Iy,"speak"),this.disable=Vp({data:t.disable,defaultValue:0,validate:t=>1===t}),this.id=t.id||"",this.priority=zp(t.priority,["custom","caption","name","toolTip"]),this.rid=t.rid||"",this.use=t.use||"",this.usehref=t.usehref||""}}class Qw extends Gm{constructor(t){super(Iy,"stipple",!0),this.id=t.id||"",this.rate=Vp({data:t.rate,defaultValue:50,validate:t=>t>=0&&t<=100}),this.use=t.use||"",this.usehref=t.usehref||"",this.color=null,this.extras=null}[Tp](t){const e=this.rate/100;return uh.makeHexColor(Math.round(t.value.r*(1-e)+this.value.r*e),Math.round(t.value.g*(1-e)+this.value.g*e),Math.round(t.value.b*(1-e)+this.value.b*e))}}class Ew extends Gm{constructor(t){super(Iy,"subform",!0),this.access=zp(t.access,["open","nonInteractive","protected","readOnly"]),this.allowMacro=Vp({data:t.allowMacro,defaultValue:0,validate:t=>1===t}),this.anchorType=zp(t.anchorType,["topLeft","bottomCenter","bottomLeft","bottomRight","middleCenter","middleLeft","middleRight","topCenter","topRight"]),this.colSpan=Vp({data:t.colSpan,defaultValue:1,validate:t=>t>=1||-1===t}),this.columnWidths=(t.columnWidths||"").trim().split(/\s+/).map((t=>"-1"===t?-1:$p(t))),this.h=t.h?$p(t.h):"",this.hAlign=zp(t.hAlign,["left","center","justify","justifyAll","radix","right"]),this.id=t.id||"",this.layout=zp(t.layout,["position","lr-tb","rl-row","rl-tb","row","table","tb"]),this.locale=t.locale||"",this.maxH=$p(t.maxH,"0pt"),this.maxW=$p(t.maxW,"0pt"),this.mergeMode=zp(t.mergeMode,["consumeData","matchTemplate"]),this.minH=$p(t.minH,"0pt"),this.minW=$p(t.minW,"0pt"),this.name=t.name||"",this.presence=zp(t.presence,["visible","hidden","inactive","invisible"]),this.relevant=em(t.relevant),this.restoreState=zp(t.restoreState,["manual","auto"]),this.scope=zp(t.scope,["name","none"]),this.use=t.use||"",this.usehref=t.usehref||"",this.w=t.w?$p(t.w):"",this.x=$p(t.x,"0pt"),this.y=$p(t.y,"0pt"),this.assist=null,this.bind=null,this.bookend=null,this.border=null,this.break=null,this.calculate=null,this.desc=null,this.extras=null,this.keep=null,this.margin=null,this.occur=null,this.overflow=null,this.pageSet=null,this.para=null,this.traversal=null,this.validate=null,this.variables=null,this.area=new Lm,this.breakAfter=new Lm,this.breakBefore=new Lm,this.connect=new Lm,this.draw=new Lm,this.event=new Lm,this.exObject=new Lm,this.exclGroup=new Lm,this.field=new Lm,this.proto=new Lm,this.setProperty=new Lm,this.subform=new Lm,this.subformSet=new Lm}[ip](){const t=this[sp]();return t instanceof fw?t[ip]():t}[lp](){return!0}[Bp](){return this.layout.endsWith("-tb")&&0===this[Tf].attempt&&this[Tf].numberInLine>0||this[sp]()[Bp]()}*[ep](){yield*py(this)}[Kf](){return gy(this)}[Rf](t,e){cy(this,t,e)}[Wf](){return hy(this)}[Cp](){const t=this[ip]();return!!t[Cp]()&&(void 0!==this[Tf]._isSplittable?this[Tf]._isSplittable:"position"===this.layout||this.layout.includes("row")||this.keep&&"none"!==this.keep.intact?(this[Tf]._isSplittable=!1,!1):!(t.layout?.endsWith("-tb")&&0!==t[Tf].numberInLine||(this[Tf]._isSplittable=!0,0)))}[_p](t){if(yy(this),this.break){if("auto"!==this.break.after||""!==this.break.afterTarget){const t=new Ty({targetType:this.break.after,target:this.break.afterTarget,startNew:this.break.startNew.toString()});t[np]=this[np],this[vf](t),this.breakAfter.push(t)}if("auto"!==this.break.before||""!==this.break.beforeTarget){const t=new Py({targetType:this.break.before,target:this.break.beforeTarget,startNew:this.break.startNew.toString()});t[np]=this[np],this[vf](t),this.breakBefore.push(t)}if(""!==this.break.overflowTarget){const t=new zb({target:this.break.overflowTarget,leader:this.break.overflowLeader,trailer:this.break.overflowTrailer});t[np]=this[np],this[vf](t),this.overflow.push(t)}this[Fp](this.break),this.break=null}if("hidden"===this.presence||"inactive"===this.presence)return Am.EMPTY;if((this.breakBefore.children.length>1||this.breakAfter.children.length>1)&&Zc("XFA - Several breakBefore or breakAfter in subforms: please file a bug."),this.breakBefore.children.length>=1){const t=this.breakBefore.children[0];if(xy(t))return Am.breakNode(t)}if(this[Tf]?.afterBreakAfter)return Am.EMPTY;Xm(this);const e=[],A={id:this[Pp],class:[]};Ay(this,A.class),this[Tf]||(this[Tf]=Object.create(null)),Object.assign(this[Tf],{children:e,line:null,attributes:A,attempt:0,numberInLine:0,availableSpace:{width:Math.min(this.w||1/0,t.width),height:Math.min(this.h||1/0,t.height)},width:0,height:0,prevHeight:0,currentWidth:0});const i=this[ap](),s=i[Tf].noLayoutFailure,a=this[Cp]();if(a||ky(this),!ly(this,t))return Am.FAILURE;const n=new Set(["area","draw","exclGroup","field","subform","subformSet"]);if(this.layout.includes("row")){const t=this[ip]().columnWidths;Array.isArray(t)&&t.length>0&&(this[Tf].columnWidths=t,this[Tf].currentColumn=0)}const r=$m(this,"anchorType","dimensions","position","presence","border","margin","hAlign"),o=["xfaSubform"],g=zm(this);if(g&&o.push(g),A.style=r,A.class=o,this.name&&(A.xfaName=this.name),this.overflow){const e=this.overflow[zf]();e.addLeader&&(e.addLeader=!1,Fy(this,e.leader,t))}this[xp]();const c="lr-tb"===this.layout||"rl-tb"===this.layout,h=c?2:1;for(;this[Tf].attempt=1){const t=this.breakAfter.children[0];if(xy(t))return this[Tf].afterBreakAfter=Q,Am.breakNode(t)}return delete this[Tf],Q}}class fw extends Gm{constructor(t){super(Iy,"subformSet",!0),this.id=t.id||"",this.name=t.name||"",this.relation=zp(t.relation,["ordered","choice","unordered"]),this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.bookend=null,this.break=null,this.desc=null,this.extras=null,this.occur=null,this.overflow=null,this.breakAfter=new Lm,this.breakBefore=new Lm,this.subform=new Lm,this.subformSet=new Lm}*[ep](){yield*py(this)}[ip](){let t=this[sp]();for(;!(t instanceof Ew);)t=t[sp]();return t}[lp](){return!0}}class pw extends Jm{constructor(t){super(Iy,"subjectDN"),this.delimiter=t.delimiter||",",this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){this[Jf]=new Map(this[Jf].split(this.delimiter).map((t=>((t=t.split("=",2))[0]=t[0].trim(),t))))}}class mw extends Gm{constructor(t){super(Iy,"subjectDNs",!0),this.id=t.id||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||"",this.subjectDN=new Lm}}class yw extends Gm{constructor(t){super(Iy,"submit",!0),this.embedPDF=Vp({data:t.embedPDF,defaultValue:0,validate:t=>1===t}),this.format=zp(t.format,["xdp","formdata","pdf","urlencoded","xfd","xml"]),this.id=t.id||"",this.target=t.target||"",this.textEncoding=Xp({data:t.textEncoding?t.textEncoding.toLowerCase():"",defaultValue:"",validate:t=>["utf-8","big-five","fontspecific","gbk","gb-18030","gb-2312","ksc-5601","none","shift-jis","ucs-2","utf-16"].includes(t)||t.match(/iso-8859-\d{2}/)}),this.use=t.use||"",this.usehref=t.usehref||"",this.xdpContent=t.xdpContent||"",this.encrypt=null,this.encryptData=new Lm,this.signData=new Lm}}class bw extends Gm{constructor(t){super(Iy,"template",!0),this.baseProfile=zp(t.baseProfile,["full","interactiveForms"]),this.extras=null,this.subform=new Lm}[Pf](){0===this.subform.children.length&&Zc("XFA - No subforms in template node."),this.subform.children.length>=2&&Zc("XFA - Several subforms in template node: please file a bug."),this[Up]=5e3}[Cp](){return!0}[Np](t,e){return t.startsWith("#")?[this[op].get(t.slice(1))]:dm(this,e,t,!0,!0)}*[Jp](){if(!this.subform.children.length)return Am.success({name:"div",children:[]});this[Tf]={overflowNode:null,firstUnsplittable:null,currentContentArea:null,currentPageArea:null,noLayoutFailure:!1,pageNumber:1,pagePosition:"first",oddOrEven:"odd",blankOrNotBlank:"nonBlank",paraStack:[]};const t=this.subform.children[0];t.pageSet[Gf]();const e=t.pageSet.pageArea.children,A={name:"div",children:[]};let i=null,s=null,a=null;if(t.breakBefore.children.length>=1?(s=t.breakBefore.children[0],a=s.target):t.subform.children.length>=1&&t.subform.children[0].breakBefore.children.length>=1?(s=t.subform.children[0].breakBefore.children[0],a=s.target):t.break?.beforeTarget?(s=t.break,a=s.beforeTarget):t.subform.children.length>=1&&t.subform.children[0].break?.beforeTarget&&(s=t.subform.children[0].break,a=s.beforeTarget),s){const t=this[Np](a,s[sp]());t instanceof $b&&(i=t,s[Tf]={})}i||(i=e[0]),i[Tf]={numberOfUse:1};const n=i[sp]();n[Tf]={numberOfUse:1,pageIndex:n.pageArea.children.indexOf(i),pageSetIndex:0};let r,o=null,g=null,c=!0,h=0,l=0;for(;;){if(c)h=0;else if(A.children.pop(),3==++h)return Zc("XFA - Something goes wrong: please file a bug."),A;r=null,this[Tf].currentPageArea=i;const e=i[_p]().html;A.children.push(e),o&&(this[Tf].noLayoutFailure=!0,e.children.push(o[_p](i[Tf].space).html),o=null),g&&(this[Tf].noLayoutFailure=!0,e.children.push(g[_p](i[Tf].space).html),g=null);const s=i.contentArea.children,a=e.children.filter((t=>t.attributes.class.includes("xfaContentarea")));c=!1,this[Tf].firstUnsplittable=null,this[Tf].noLayoutFailure=!1;const n=e=>{const A=t[Kf]();A&&(c||=A.children?.length>0,a[e].children.push(A))};for(let e=l,i=s.length;e0,a[e].children.push(I.html)):!c&&A.children.length>1&&A.children.pop(),A;if(I.isBreak()){const t=I.breakNode;if(n(e),"auto"===t.targetType)continue;t.leader&&(o=this[Np](t.leader,t[sp]()),o=o?o[0]:null),t.trailer&&(g=this[Np](t.trailer,t[sp]()),g=g?g[0]:null),"pageArea"===t.targetType?(r=t[Tf].target,e=1/0):t[Tf].target?(r=t[Tf].target,l=t[Tf].index+1,e=1/0):e=t[Tf].index}else if(this[Tf].overflowNode){const t=this[Tf].overflowNode;this[Tf].overflowNode=null;const A=t[zf](),i=A.target;A.addLeader=null!==A.leader,A.addTrailer=null!==A.trailer,n(e);const a=e;if(e=1/0,i instanceof $b)r=i;else if(i instanceof tb){const t=s.indexOf(i);-1!==t?t>a?e=t-1:l=t:(r=i[sp](),l=r.contentArea.children.indexOf(i))}}else n(e)}this[Tf].pageNumber+=1,r&&(r[Ep]()?r[Tf].numberOfUse+=1:r=null),i=r||i[Ap](),yield null}}}class ww extends Jm{constructor(t){super(Iy,"text"),this.id=t.id||"",this.maxChars=Vp({data:t.maxChars,defaultValue:0,validate:t=>t>=0}),this.name=t.name||"",this.rid=t.rid||"",this.use=t.use||"",this.usehref=t.usehref||""}[Ff](){return!0}[bp](t){return t[pp]===qp.xhtml.id?(this[Jf]=t,!0):(Zc(`XFA - Invalid content in Text: ${t[mp]}.`),!1)}[Dp](t){this[Jf]instanceof Gm||super[Dp](t)}[Pf](){"string"==typeof this[Jf]&&(this[Jf]=this[Jf].replaceAll("\r\n","\n"))}[zf](){return"string"==typeof this[Jf]?this[Jf].split(/[\u2029\u2028\n]/).reduce(((t,e)=>(e&&t.push(e),t)),[]).join("\n"):this[Jf][Hp]()}[_p](t){if("string"==typeof this[Jf]){const t=Dy(this[Jf]).html;return this[Jf].includes("\u2029")?(t.name="div",t.children=[],this[Jf].split("\u2029").map((t=>t.split(/[\u2028\n]/).reduce(((t,e)=>(t.push({name:"span",value:e},{name:"br"}),t)),[]))).forEach((e=>{t.children.push({name:"p",children:e})}))):/[\u2028\n]/.test(this[Jf])&&(t.name="div",t.children=[],this[Jf].split(/[\u2028\n]/).forEach((e=>{t.children.push({name:"span",value:e},{name:"br"})}))),Am.success(t)}return this[Jf][_p](t)}}class Dw extends Gm{constructor(t){super(Iy,"textEdit",!0),this.allowRichText=Vp({data:t.allowRichText,defaultValue:0,validate:t=>1===t}),this.hScrollPolicy=zp(t.hScrollPolicy,["auto","off","on"]),this.id=t.id||"",this.multiLine=Vp({data:t.multiLine,defaultValue:"",validate:t=>0===t||1===t}),this.use=t.use||"",this.usehref=t.usehref||"",this.vScrollPolicy=zp(t.vScrollPolicy,["auto","off","on"]),this.border=null,this.comb=null,this.extras=null,this.margin=null}[_p](t){const e=$m(this,"border","font","margin");let A;const i=this[sp]()[sp]();return""===this.multiLine&&(this.multiLine=i instanceof cb?1:0),A=1===this.multiLine?{name:"textarea",attributes:{dataId:i[_f]?.[Pp]||i[Pp],fieldId:i[Pp],class:["xfaTextfield"],style:e,"aria-label":wy(i),"aria-required":!1}}:{name:"input",attributes:{type:"text",dataId:i[_f]?.[Pp]||i[Pp],fieldId:i[Pp],class:["xfaTextfield"],style:e,"aria-label":wy(i),"aria-required":!1}},my(i)&&(A.attributes["aria-required"]=!0,A.attributes.required=!0),Am.success({name:"label",attributes:{class:["xfaLabel"]},children:[A]})}}class kw extends Ym{constructor(t){super(Iy,"time"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}[Pf](){const t=this[Jf].trim();this[Jf]=t?new Date(t):null}[_p](t){return Dy(this[Jf]?this[Jf].toString():"")}}class Sw extends Gm{constructor(t){super(Iy,"timeStamp"),this.id=t.id||"",this.server=t.server||"",this.type=zp(t.type,["optional","required"]),this.use=t.use||"",this.usehref=t.usehref||""}}class xw extends Ym{constructor(t){super(Iy,"toolTip"),this.id=t.id||"",this.rid=t.rid||"",this.use=t.use||"",this.usehref=t.usehref||""}}class Fw extends Gm{constructor(t){super(Iy,"traversal",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.traverse=new Lm}}class Rw extends Gm{constructor(t){super(Iy,"traverse",!0),this.id=t.id||"",this.operation=zp(t.operation,["next","back","down","first","left","right","up"]),this.ref=t.ref||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.script=null}get name(){return this.operation}[Qp](){return!1}}class vw extends Gm{constructor(t){super(Iy,"ui",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.picture=null,this.barcode=null,this.button=null,this.checkButton=null,this.choiceList=null,this.dateTimeEdit=null,this.defaultUi=null,this.imageEdit=null,this.numericEdit=null,this.passwordEdit=null,this.signature=null,this.textEdit=null}[zf](){if(void 0===this[Tf]){for(const t of Object.getOwnPropertyNames(this)){if("extras"===t||"picture"===t)continue;const e=this[t];if(e instanceof Gm)return this[Tf]=e,e}this[Tf]=null}return this[Tf]}[_p](t){const e=this[zf]();return e?e[_p](t):Am.EMPTY}}class Nw extends Gm{constructor(t){super(Iy,"validate",!0),this.formatTest=zp(t.formatTest,["warning","disabled","error"]),this.id=t.id||"",this.nullTest=zp(t.nullTest,["disabled","error","warning"]),this.scriptTest=zp(t.scriptTest,["error","disabled","warning"]),this.use=t.use||"",this.usehref=t.usehref||"",this.extras=null,this.message=null,this.picture=null,this.script=null}}class Mw extends Gm{constructor(t){super(Iy,"value",!0),this.id=t.id||"",this.override=Vp({data:t.override,defaultValue:0,validate:t=>1===t}),this.relevant=em(t.relevant),this.use=t.use||"",this.usehref=t.usehref||"",this.arc=null,this.boolean=null,this.date=null,this.dateTime=null,this.decimal=null,this.exData=null,this.float=null,this.image=null,this.integer=null,this.line=null,this.rectangle=null,this.text=null,this.time=null}[Lp](t){const e=this[sp]();if(e instanceof wb&&e.ui?.imageEdit)return this.image||(this.image=new Nb({}),this[vf](this.image)),void(this.image[Jf]=t[Jf]);const A=t[mp];if(null===this[A]){for(const t of Object.getOwnPropertyNames(this)){const e=this[t];e instanceof Gm&&(this[t]=null,this[Fp](e))}this[t[mp]]=t,this[vf](t)}else this[A][Jf]=t[Jf]}[Hp](){if(this.exData)return"string"==typeof this.exData[Jf]?this.exData[Jf].trim():this.exData[Jf][Hp]().trim();for(const t of Object.getOwnPropertyNames(this)){if("image"===t)continue;const e=this[t];if(e instanceof Gm)return(e[Jf]||"").toString().trim()}return null}[_p](t){for(const e of Object.getOwnPropertyNames(this)){const A=this[e];if(A instanceof Gm)return A[_p](t)}return Am.EMPTY}}class Gw extends Gm{constructor(t){super(Iy,"variables",!0),this.id=t.id||"",this.use=t.use||"",this.usehref=t.usehref||"",this.boolean=new Lm,this.date=new Lm,this.dateTime=new Lm,this.decimal=new Lm,this.exData=new Lm,this.float=new Lm,this.image=new Lm,this.integer=new Lm,this.manifest=new Lm,this.script=new Lm,this.text=new Lm,this.time=new Lm}[Qp](){return!0}}class Lw{static[Kp](t,e){if(Lw.hasOwnProperty(t)){const A=Lw[t](e);return A[Gp](e),A}}static appearanceFilter(t){return new Ry(t)}static arc(t){return new vy(t)}static area(t){return new Ny(t)}static assist(t){return new My(t)}static barcode(t){return new Gy(t)}static bind(t){return new Ly(t)}static bindItems(t){return new Uy(t)}static bookend(t){return new Hy(t)}static boolean(t){return new Jy(t)}static border(t){return new _y(t)}static break(t){return new Yy(t)}static breakAfter(t){return new Ty(t)}static breakBefore(t){return new Py(t)}static button(t){return new Ky(t)}static calculate(t){return new qy(t)}static caption(t){return new Oy(t)}static certificate(t){return new Wy(t)}static certificates(t){return new jy(t)}static checkButton(t){return new Vy(t)}static choiceList(t){return new Zy(t)}static color(t){return new Xy(t)}static comb(t){return new zy(t)}static connect(t){return new $y(t)}static contentArea(t){return new tb(t)}static corner(t){return new eb(t)}static date(t){return new Ab(t)}static dateTime(t){return new ib(t)}static dateTimeEdit(t){return new sb(t)}static decimal(t){return new ab(t)}static defaultUi(t){return new nb(t)}static desc(t){return new rb(t)}static digestMethod(t){return new ob(t)}static digestMethods(t){return new gb(t)}static draw(t){return new cb(t)}static edge(t){return new hb(t)}static encoding(t){return new lb(t)}static encodings(t){return new Ib(t)}static encrypt(t){return new db(t)}static encryptData(t){return new ub(t)}static encryption(t){return new Cb(t)}static encryptionMethod(t){return new Bb(t)}static encryptionMethods(t){return new Qb(t)}static event(t){return new Eb(t)}static exData(t){return new fb(t)}static exObject(t){return new pb(t)}static exclGroup(t){return new mb(t)}static execute(t){return new yb(t)}static extras(t){return new bb(t)}static field(t){return new wb(t)}static fill(t){return new Db(t)}static filter(t){return new kb(t)}static float(t){return new Sb(t)}static font(t){return new xb(t)}static format(t){return new Fb(t)}static handler(t){return new Rb(t)}static hyphenation(t){return new vb(t)}static image(t){return new Nb(t)}static imageEdit(t){return new Mb(t)}static integer(t){return new Gb(t)}static issuers(t){return new Lb(t)}static items(t){return new Ub(t)}static keep(t){return new Hb(t)}static keyUsage(t){return new Jb(t)}static line(t){return new _b(t)}static linear(t){return new Yb(t)}static lockDocument(t){return new Tb(t)}static manifest(t){return new Pb(t)}static margin(t){return new Kb(t)}static mdp(t){return new qb(t)}static medium(t){return new Ob(t)}static message(t){return new Wb(t)}static numericEdit(t){return new jb(t)}static occur(t){return new Vb(t)}static oid(t){return new Zb(t)}static oids(t){return new Xb(t)}static overflow(t){return new zb(t)}static pageArea(t){return new $b(t)}static pageSet(t){return new tw(t)}static para(t){return new ew(t)}static passwordEdit(t){return new Aw(t)}static pattern(t){return new iw(t)}static picture(t){return new sw(t)}static proto(t){return new aw(t)}static radial(t){return new nw(t)}static reason(t){return new rw(t)}static reasons(t){return new ow(t)}static rectangle(t){return new gw(t)}static ref(t){return new cw(t)}static script(t){return new hw(t)}static setProperty(t){return new lw(t)}static signData(t){return new Iw(t)}static signature(t){return new dw(t)}static signing(t){return new uw(t)}static solid(t){return new Cw(t)}static speak(t){return new Bw(t)}static stipple(t){return new Qw(t)}static subform(t){return new Ew(t)}static subformSet(t){return new fw(t)}static subjectDN(t){return new pw(t)}static subjectDNs(t){return new mw(t)}static submit(t){return new yw(t)}static template(t){return new bw(t)}static text(t){return new ww(t)}static textEdit(t){return new Dw(t)}static time(t){return new kw(t)}static timeStamp(t){return new Sw(t)}static toolTip(t){return new xw(t)}static traversal(t){return new Fw(t)}static traverse(t){return new Rw(t)}static ui(t){return new vw(t)}static validate(t){return new Nw(t)}static value(t){return new Mw(t)}static variables(t){return new Gw(t)}}const Uw=qp.datasets.id;function Hw(t){const e=new ww({});return e[Jf]=t,e}class Jw{constructor(t){this.root=t,this.datasets=t.datasets,this.data=t.datasets?.data||new Hm(qp.datasets.id,"data"),this.emptyMerge=0===this.data[tp]().length,this.root.form=this.form=t.template[Uf]()}_isConsumeData(){return!this.emptyMerge&&this._mergeMode}_isMatchTemplate(){return!this._isConsumeData()}bind(){return this._bindElement(this.form,this.data),this.form}getData(){return this.data}_bindValue(t,e,A){if(t[_f]=e,t[rp]())if(e[Ip]()){const A=e[Xf]();t[Lp](Hw(A))}else if(t instanceof wb&&"multiSelect"===t.ui?.choiceList?.open){const A=e[tp]().map((t=>t[Jf].trim())).join("\n");t[Lp](Hw(A))}else this._isConsumeData()&&Zc("XFA - Nodes haven't the same type.");else!e[Ip]()||this._isMatchTemplate()?this._bindElement(t,e):Zc("XFA - Nodes haven't the same type.")}_findDataByNameToConsume(t,e,A,i){if(!t)return null;let s,a;for(let i=0;i<3;i++){for(s=A[$f](t,!1,!0);a=s.next().value,a;)if(e===a[Ip]())return a;if(A[pp]===qp.datasets.id&&"data"===A[mp])break;A=A[sp]()}return i?(s=this.data[$f](t,!0,!1),a=s.next().value,a||(s=this.data[qf](t,!0),a=s.next().value,a?.[Ip]()?a:null)):null}_setProperties(t,e){if(t.hasOwnProperty("setProperty"))for(const{ref:A,target:i,connection:s}of t.setProperty.children){if(s)continue;if(!A)continue;const a=dm(this.root,e,A,!1,!1);if(!a){Zc(`XFA - Invalid reference: ${A}.`);continue}const[n]=a;if(!n[dp](this.data)){Zc("XFA - Invalid node: must be a data node.");continue}const r=dm(this.root,t,i,!1,!1);if(!r){Zc(`XFA - Invalid target: ${i}.`);continue}const[o]=r;if(!o[dp](t)){Zc("XFA - Invalid target: must be a property or subproperty.");continue}const g=o[sp]();if(o instanceof lw||g instanceof lw){Zc("XFA - Invalid target: cannot be a setProperty or one of its properties.");continue}if(o instanceof Uy||g instanceof Uy){Zc("XFA - Invalid target: cannot be a bindItems or one of its properties.");continue}const c=n[Hp](),h=o[mp];if(o instanceof Um){const t=Object.create(null);t[h]=c;const e=Reflect.construct(Object.getPrototypeOf(g).constructor,[t]);g[h]=e[h]}else o.hasOwnProperty(Jf)?(o[_f]=n,o[Jf]=c,o[Pf]()):Zc("XFA - Invalid node to use in setProperty")}}_bindItems(t,e){if(!t.hasOwnProperty("items")||!t.hasOwnProperty("bindItems")||t.bindItems.isEmpty())return;for(const e of t.items.children)t[Fp](e);t.items.clear();const A=new Ub({}),i=new Ub({});t[vf](A),t.items.push(A),t[vf](i),t.items.push(i);for(const{ref:s,labelRef:a,valueRef:n,connection:r}of t.bindItems.children){if(r)continue;if(!s)continue;const t=dm(this.root,e,s,!1,!1);if(t)for(const e of t){if(!e[dp](this.datasets)){Zc(`XFA - Invalid ref (${s}): must be a datasets child.`);continue}const t=dm(this.root,e,a,!0,!1);if(!t){Zc(`XFA - Invalid label: ${a}.`);continue}const[r]=t;if(!r[dp](this.datasets)){Zc("XFA - Invalid label: must be a datasets child.");continue}const o=dm(this.root,e,n,!0,!1);if(!o){Zc(`XFA - Invalid value: ${n}.`);continue}const[g]=o;if(!g[dp](this.datasets)){Zc("XFA - Invalid value: must be a datasets child.");continue}const c=Hw(r[Hp]()),h=Hw(g[Hp]());A[vf](c),A.text.push(c),i[vf](h),i.text.push(h)}else Zc(`XFA - Invalid reference: ${s}.`)}}_bindOccurrences(t,e,A){let i;if(e.length>1&&(i=t[Uf](),i[Fp](i.occur),i.occur=null),this._bindValue(t,e[0],A),this._setProperties(t,e[0]),this._bindItems(t,e[0]),1===e.length)return;const s=t[sp](),a=t[mp],n=s[gp](t);for(let t=1,r=e.length;te.name===t.name)).length:A[i].children.length;const a=A[gp](t)+1,n=e.initial-s;if(n){const e=t[Uf]();e[Fp](e.occur),e.occur=null,A[i].push(e),A[cp](a,e);for(let t=1;t0)this._bindOccurrences(i,[t[0]],null);else if(this.emptyMerge){const t=e[pp]===Uw?-1:e[pp],A=i[_f]=new Hm(t,i.name||"root");e[vf](A),this._bindElement(i,A)}continue}if(!i[lp]())continue;let t=!1,s=null,a=null,n=null;if(i.bind){switch(i.bind.match){case"none":this._setAndBind(i,e);continue;case"global":t=!0;break;case"dataRef":if(!i.bind.ref){Zc(`XFA - ref is empty in node ${i[mp]}.`),this._setAndBind(i,e);continue}a=i.bind.ref}i.bind.picture&&(s=i.bind.picture[Jf])}const[r,o]=this._getOccurInfo(i);if(a){if(n=dm(this.root,e,a,!0,!1),null===n){if(n=um(this.data,e,a),!n)continue;this._isConsumeData()&&(n[Hf]=!0),this._setAndBind(i,n);continue}this._isConsumeData()&&(n=n.filter((t=>!t[Hf]))),n.length>o?n=n.slice(0,o):0===n.length&&(n=null),n&&this._isConsumeData()&&n.forEach((t=>{t[Hf]=!0}))}else{if(!i.name){this._setAndBind(i,e);continue}if(this._isConsumeData()){const A=[];for(;A.length0?A:null}else{if(n=e[$f](i.name,!1,this.emptyMerge).next().value,!n){if(0===r){A.push(i);continue}const t=e[pp]===Uw?-1:e[pp];n=i[_f]=new Hm(t,i.name),this.emptyMerge&&(n[Hf]=!0),e[vf](n),this._setAndBind(i,n);continue}this.emptyMerge&&(n[Hf]=!0),n=[n]}}n?this._bindOccurrences(i,n,s):r>0?this._setAndBind(i,e):A.push(i)}A.forEach((t=>t[sp]()[Fp](t)))}}class _w{constructor(t,e){this.data=e,this.dataset=t.datasets||null}serialize(t){const e=[[-1,this.data[tp]()]];for(;e.length>0;){const A=e.at(-1),[i,s]=A;if(i+1===s.length){e.pop();continue}const a=s[++A[0]],n=t.get(a[Pp]);if(n)a[Lp](n);else{const e=a[Of]();for(const A of e.values()){const e=t.get(A[Pp]);if(e){A[Lp](e);break}}}const r=a[tp]();r.length>0&&e.push([-1,r])}const A=[''];if(this.dataset)for(const t of this.dataset[tp]())"data"!==t[mp]&&t[Yp](A);return this.data[Yp](A),A.push(""),A.join("")}}const Yw=qp.config.id;class Tw extends Gm{constructor(t){super(Yw,"acrobat",!0),this.acrobat7=null,this.autoSave=null,this.common=null,this.validate=null,this.validateApprovalSignatures=null,this.submitUrl=new Lm}}class Pw extends Gm{constructor(t){super(Yw,"acrobat7",!0),this.dynamicRender=null}}class Kw extends _m{constructor(t){super(Yw,"ADBE_JSConsole",["delegate","Enable","Disable"])}}class qw extends _m{constructor(t){super(Yw,"ADBE_JSDebugger",["delegate","Enable","Disable"])}}class Ow extends Pm{constructor(t){super(Yw,"addSilentPrint")}}class Ww extends Pm{constructor(t){super(Yw,"addViewerPreferences")}}class jw extends Km{constructor(t){super(Yw,"adjustData")}}class Vw extends Tm{constructor(t){super(Yw,"adobeExtensionLevel",0,(t=>t>=1&&t<=8))}}class Zw extends Gm{constructor(t){super(Yw,"agent",!0),this.name=t.name?t.name.trim():"",this.common=new Lm}}class Xw extends Jm{constructor(t){super(Yw,"alwaysEmbed")}}class zw extends Ym{constructor(t){super(Yw,"amd")}}class $w extends Gm{constructor(t){super(Yw,"area"),this.level=Vp({data:t.level,defaultValue:0,validate:t=>t>=1&&t<=3}),this.name=zp(t.name,["","barcode","coreinit","deviceDriver","font","general","layout","merge","script","signature","sourceSet","templateCache"])}}class tD extends _m{constructor(t){super(Yw,"attributes",["preserve","delegate","ignore"])}}class eD extends _m{constructor(t){super(Yw,"autoSave",["disabled","enabled"])}}class AD extends Ym{constructor(t){super(Yw,"base")}}class iD extends Gm{constructor(t){super(Yw,"batchOutput"),this.format=zp(t.format,["none","concat","zip","zipCompress"])}}class sD extends Jm{constructor(t){super(Yw,"behaviorOverride")}[Pf](){this[Jf]=new Map(this[Jf].trim().split(/\s+/).filter((t=>t.includes(":"))).map((t=>t.split(":",2))))}}class aD extends Gm{constructor(t){super(Yw,"cache",!0),this.templateCache=null}}class nD extends Pm{constructor(t){super(Yw,"change")}}class rD extends Gm{constructor(t){super(Yw,"common",!0),this.data=null,this.locale=null,this.localeSet=null,this.messaging=null,this.suppressBanner=null,this.template=null,this.validationMessaging=null,this.versionControl=null,this.log=new Lm}}class oD extends Gm{constructor(t){super(Yw,"compress"),this.scope=zp(t.scope,["imageOnly","document"])}}class gD extends Pm{constructor(t){super(Yw,"compressLogicalStructure")}}class cD extends Km{constructor(t){super(Yw,"compressObjectStream")}}class hD extends Gm{constructor(t){super(Yw,"compression",!0),this.compressLogicalStructure=null,this.compressObjectStream=null,this.level=null,this.type=null}}class lD extends Gm{constructor(t){super(Yw,"config",!0),this.acrobat=null,this.present=null,this.trace=null,this.agent=new Lm}}class ID extends _m{constructor(t){super(Yw,"conformance",["A","B"])}}class dD extends Pm{constructor(t){super(Yw,"contentCopy")}}class uD extends Tm{constructor(t){super(Yw,"copies",1,(t=>t>=1))}}class CD extends Ym{constructor(t){super(Yw,"creator")}}class BD extends Tm{constructor(t){super(Yw,"currentPage",0,(t=>t>=0))}}class QD extends Gm{constructor(t){super(Yw,"data",!0),this.adjustData=null,this.attributes=null,this.incrementalLoad=null,this.outputXSL=null,this.range=null,this.record=null,this.startNode=null,this.uri=null,this.window=null,this.xsl=null,this.excludeNS=new Lm,this.transform=new Lm}}class ED extends Gm{constructor(t){super(Yw,"debug",!0),this.uri=null}}class fD extends Jm{constructor(t){super(Yw,"defaultTypeface"),this.writingScript=zp(t.writingScript,["*","Arabic","Cyrillic","EastEuropeanRoman","Greek","Hebrew","Japanese","Korean","Roman","SimplifiedChinese","Thai","TraditionalChinese","Vietnamese"])}}class pD extends _m{constructor(t){super(Yw,"destination",["pdf","pcl","ps","webClient","zpl"])}}class mD extends Pm{constructor(t){super(Yw,"documentAssembly")}}class yD extends Gm{constructor(t){super(Yw,"driver",!0),this.name=t.name?t.name.trim():"",this.fontInfo=null,this.xdc=null}}class bD extends _m{constructor(t){super(Yw,"duplexOption",["simplex","duplexFlipLongEdge","duplexFlipShortEdge"])}}class wD extends _m{constructor(t){super(Yw,"dynamicRender",["forbidden","required"])}}class DD extends Pm{constructor(t){super(Yw,"embed")}}class kD extends Pm{constructor(t){super(Yw,"encrypt")}}class SD extends Gm{constructor(t){super(Yw,"encryption",!0),this.encrypt=null,this.encryptionLevel=null,this.permissions=null}}class xD extends _m{constructor(t){super(Yw,"encryptionLevel",["40bit","128bit"])}}class FD extends Ym{constructor(t){super(Yw,"enforce")}}class RD extends Gm{constructor(t){super(Yw,"equate"),this.force=Vp({data:t.force,defaultValue:1,validate:t=>0===t}),this.from=t.from||"",this.to=t.to||""}}class vD extends Gm{constructor(t){super(Yw,"equateRange"),this.from=t.from||"",this.to=t.to||"",this._unicodeRange=t.unicodeRange||""}get unicodeRange(){const t=[],e=/U\+([0-9a-fA-F]+)/,A=this._unicodeRange;for(let i of A.split(",").map((t=>t.trim())).filter((t=>!!t)))i=i.split("-",2).map((t=>{const A=t.match(e);return A?parseInt(A[1],16):0})),1===i.length&&i.push(i[0]),t.push(i);return th(this,"unicodeRange",t)}}class ND extends Jm{constructor(t){super(Yw,"exclude")}[Pf](){this[Jf]=this[Jf].trim().split(/\s+/).filter((t=>t&&["calculate","close","enter","exit","initialize","ready","validate"].includes(t)))}}class MD extends Ym{constructor(t){super(Yw,"excludeNS")}}class GD extends _m{constructor(t){super(Yw,"flipLabel",["usePrinterSetting","on","off"])}}class LD extends Gm{constructor(t){super(Yw,"fontInfo",!0),this.embed=null,this.map=null,this.subsetBelow=null,this.alwaysEmbed=new Lm,this.defaultTypeface=new Lm,this.neverEmbed=new Lm}}class UD extends Pm{constructor(t){super(Yw,"formFieldFilling")}}class HD extends Ym{constructor(t){super(Yw,"groupParent")}}class JD extends _m{constructor(t){super(Yw,"ifEmpty",["dataValue","dataGroup","ignore","remove"])}}class _D extends Ym{constructor(t){super(Yw,"includeXDPContent")}}class YD extends _m{constructor(t){super(Yw,"incrementalLoad",["none","forwardOnly"])}}class TD extends Pm{constructor(t){super(Yw,"incrementalMerge")}}class PD extends Pm{constructor(t){super(Yw,"interactive")}}class KD extends _m{constructor(t){super(Yw,"jog",["usePrinterSetting","none","pageSet"])}}class qD extends Gm{constructor(t){super(Yw,"labelPrinter",!0),this.name=zp(t.name,["zpl","dpl","ipl","tcpl"]),this.batchOutput=null,this.flipLabel=null,this.fontInfo=null,this.xdc=null}}class OD extends _m{constructor(t){super(Yw,"layout",["paginate","panel"])}}class WD extends Tm{constructor(t){super(Yw,"level",0,(t=>t>0))}}class jD extends Pm{constructor(t){super(Yw,"linearized")}}class VD extends Ym{constructor(t){super(Yw,"locale")}}class ZD extends Ym{constructor(t){super(Yw,"localeSet")}}class XD extends Gm{constructor(t){super(Yw,"log",!0),this.mode=null,this.threshold=null,this.to=null,this.uri=null}}class zD extends Gm{constructor(t){super(Yw,"map",!0),this.equate=new Lm,this.equateRange=new Lm}}class $D extends Gm{constructor(t){super(Yw,"mediumInfo",!0),this.map=null}}class tk extends Gm{constructor(t){super(Yw,"message",!0),this.msgId=null,this.severity=null}}class ek extends Gm{constructor(t){super(Yw,"messaging",!0),this.message=new Lm}}class Ak extends _m{constructor(t){super(Yw,"mode",["append","overwrite"])}}class ik extends Pm{constructor(t){super(Yw,"modifyAnnots")}}class sk extends Tm{constructor(t){super(Yw,"msgId",1,(t=>t>=1))}}class ak extends Ym{constructor(t){super(Yw,"nameAttr")}}class nk extends Jm{constructor(t){super(Yw,"neverEmbed")}}class rk extends Tm{constructor(t){super(Yw,"numberOfCopies",null,(t=>t>=2&&t<=5))}}class ok extends Gm{constructor(t){super(Yw,"openAction",!0),this.destination=null}}class gk extends Gm{constructor(t){super(Yw,"output",!0),this.to=null,this.type=null,this.uri=null}}class ck extends Ym{constructor(t){super(Yw,"outputBin")}}class hk extends Gm{constructor(t){super(Yw,"outputXSL",!0),this.uri=null}}class lk extends _m{constructor(t){super(Yw,"overprint",["none","both","draw","field"])}}class Ik extends Ym{constructor(t){super(Yw,"packets")}[Pf](){"*"!==this[Jf]&&(this[Jf]=this[Jf].trim().split(/\s+/).filter((t=>["config","datasets","template","xfdf","xslt"].includes(t))))}}class dk extends Gm{constructor(t){super(Yw,"pageOffset"),this.x=Vp({data:t.x,defaultValue:"useXDCSetting",validate:t=>!0}),this.y=Vp({data:t.y,defaultValue:"useXDCSetting",validate:t=>!0})}}class uk extends Ym{constructor(t){super(Yw,"pageRange")}[Pf](){const t=this[Jf].trim().split(/\s+/).map((t=>parseInt(t,10))),e=[];for(let A=0,i=t.length;A!1))}}class Ek extends Gm{constructor(t){super(Yw,"pcl",!0),this.name=t.name||"",this.batchOutput=null,this.fontInfo=null,this.jog=null,this.mediumInfo=null,this.outputBin=null,this.pageOffset=null,this.staple=null,this.xdc=null}}class fk extends Gm{constructor(t){super(Yw,"pdf",!0),this.name=t.name||"",this.adobeExtensionLevel=null,this.batchOutput=null,this.compression=null,this.creator=null,this.encryption=null,this.fontInfo=null,this.interactive=null,this.linearized=null,this.openAction=null,this.pdfa=null,this.producer=null,this.renderPolicy=null,this.scriptModel=null,this.silentPrint=null,this.submitFormat=null,this.tagged=null,this.version=null,this.viewerPreferences=null,this.xdc=null}}class pk extends Gm{constructor(t){super(Yw,"pdfa",!0),this.amd=null,this.conformance=null,this.includeXDPContent=null,this.part=null}}class mk extends Gm{constructor(t){super(Yw,"permissions",!0),this.accessibleContent=null,this.change=null,this.contentCopy=null,this.documentAssembly=null,this.formFieldFilling=null,this.modifyAnnots=null,this.plaintextMetadata=null,this.print=null,this.printHighQuality=null}}class yk extends Pm{constructor(t){super(Yw,"pickTrayByPDFSize")}}class bk extends Ym{constructor(t){super(Yw,"picture")}}class wk extends Pm{constructor(t){super(Yw,"plaintextMetadata")}}class Dk extends _m{constructor(t){super(Yw,"presence",["preserve","dissolve","dissolveStructure","ignore","remove"])}}class kk extends Gm{constructor(t){super(Yw,"present",!0),this.behaviorOverride=null,this.cache=null,this.common=null,this.copies=null,this.destination=null,this.incrementalMerge=null,this.layout=null,this.output=null,this.overprint=null,this.pagination=null,this.paginationOverride=null,this.script=null,this.validate=null,this.xdp=null,this.driver=new Lm,this.labelPrinter=new Lm,this.pcl=new Lm,this.pdf=new Lm,this.ps=new Lm,this.submitUrl=new Lm,this.webClient=new Lm,this.zpl=new Lm}}class Sk extends Pm{constructor(t){super(Yw,"print")}}class xk extends Pm{constructor(t){super(Yw,"printHighQuality")}}class Fk extends _m{constructor(t){super(Yw,"printScaling",["appdefault","noScaling"])}}class Rk extends Ym{constructor(t){super(Yw,"printerName")}}class vk extends Ym{constructor(t){super(Yw,"producer")}}class Nk extends Gm{constructor(t){super(Yw,"ps",!0),this.name=t.name||"",this.batchOutput=null,this.fontInfo=null,this.jog=null,this.mediumInfo=null,this.outputBin=null,this.staple=null,this.xdc=null}}class Mk extends Jm{constructor(t){super(Yw,"range")}[Pf](){this[Jf]=this[Jf].trim().split(/\s*,\s*/,2).map((t=>t.split("-").map((t=>parseInt(t.trim(),10))))).filter((t=>t.every((t=>!isNaN(t))))).map((t=>(1===t.length&&t.push(t[0]),t)))}}class Gk extends Jm{constructor(t){super(Yw,"record")}[Pf](){this[Jf]=this[Jf].trim();const t=parseInt(this[Jf],10);!isNaN(t)&&t>=0&&(this[Jf]=t)}}class Lk extends Jm{constructor(t){super(Yw,"relevant")}[Pf](){this[Jf]=this[Jf].trim().split(/\s+/)}}class Uk extends Jm{constructor(t){super(Yw,"rename")}[Pf](){this[Jf]=this[Jf].trim(),(this[Jf].toLowerCase().startsWith("xml")||new RegExp("[\\p{L}_][\\p{L}\\d._\\p{M}-]*","u").test(this[Jf]))&&Zc("XFA - Rename: invalid XFA name")}}class Hk extends _m{constructor(t){super(Yw,"renderPolicy",["server","client"])}}class Jk extends _m{constructor(t){super(Yw,"runScripts",["both","client","none","server"])}}class _k extends Gm{constructor(t){super(Yw,"script",!0),this.currentPage=null,this.exclude=null,this.runScripts=null}}class Yk extends _m{constructor(t){super(Yw,"scriptModel",["XFA","none"])}}class Tk extends _m{constructor(t){super(Yw,"severity",["ignore","error","information","trace","warning"])}}class Pk extends Gm{constructor(t){super(Yw,"silentPrint",!0),this.addSilentPrint=null,this.printerName=null}}class Kk extends Gm{constructor(t){super(Yw,"staple"),this.mode=zp(t.mode,["usePrinterSetting","on","off"])}}class qk extends Ym{constructor(t){super(Yw,"startNode")}}class Ok extends Tm{constructor(t){super(Yw,"startPage",0,(t=>!0))}}class Wk extends _m{constructor(t){super(Yw,"submitFormat",["html","delegate","fdf","xml","pdf"])}}class jk extends Ym{constructor(t){super(Yw,"submitUrl")}}class Vk extends Tm{constructor(t){super(Yw,"subsetBelow",100,(t=>t>=0&&t<=100))}}class Zk extends Pm{constructor(t){super(Yw,"suppressBanner")}}class Xk extends Pm{constructor(t){super(Yw,"tagged")}}class zk extends Gm{constructor(t){super(Yw,"template",!0),this.base=null,this.relevant=null,this.startPage=null,this.uri=null,this.xsl=null}}class $k extends _m{constructor(t){super(Yw,"threshold",["trace","error","information","warning"])}}class tS extends _m{constructor(t){super(Yw,"to",["null","memory","stderr","stdout","system","uri"])}}class eS extends Gm{constructor(t){super(Yw,"templateCache"),this.maxEntries=Vp({data:t.maxEntries,defaultValue:5,validate:t=>t>=0})}}class AS extends Gm{constructor(t){super(Yw,"trace",!0),this.area=new Lm}}class iS extends Gm{constructor(t){super(Yw,"transform",!0),this.groupParent=null,this.ifEmpty=null,this.nameAttr=null,this.picture=null,this.presence=null,this.rename=null,this.whitespace=null}}class sS extends _m{constructor(t){super(Yw,"type",["none","ascii85","asciiHex","ccittfax","flate","lzw","runLength","native","xdp","mergedXDP"])}}class aS extends Ym{constructor(t){super(Yw,"uri")}}class nS extends _m{constructor(t){super(Yw,"validate",["preSubmit","prePrint","preExecute","preSave"])}}class rS extends Jm{constructor(t){super(Yw,"validateApprovalSignatures")}[Pf](){this[Jf]=this[Jf].trim().split(/\s+/).filter((t=>["docReady","postSign"].includes(t)))}}class oS extends _m{constructor(t){super(Yw,"validationMessaging",["allMessagesIndividually","allMessagesTogether","firstMessageOnly","noMessages"])}}class gS extends _m{constructor(t){super(Yw,"version",["1.7","1.6","1.5","1.4","1.3","1.2"])}}class cS extends Gm{constructor(t){super(Yw,"VersionControl"),this.outputBelow=zp(t.outputBelow,["warn","error","update"]),this.sourceAbove=zp(t.sourceAbove,["warn","error"]),this.sourceBelow=zp(t.sourceBelow,["update","maintain"])}}class hS extends Gm{constructor(t){super(Yw,"viewerPreferences",!0),this.ADBE_JSConsole=null,this.ADBE_JSDebugger=null,this.addViewerPreferences=null,this.duplexOption=null,this.enforce=null,this.numberOfCopies=null,this.pageRange=null,this.pickTrayByPDFSize=null,this.printScaling=null}}class lS extends Gm{constructor(t){super(Yw,"webClient",!0),this.name=t.name?t.name.trim():"",this.fontInfo=null,this.xdc=null}}class IS extends _m{constructor(t){super(Yw,"whitespace",["preserve","ltrim","normalize","rtrim","trim"])}}class dS extends Jm{constructor(t){super(Yw,"window")}[Pf](){const t=this[Jf].trim().split(/\s*,\s*/,2).map((t=>parseInt(t,10)));t.some((t=>isNaN(t)))?this[Jf]=[0,0]:(1===t.length&&t.push(t[0]),this[Jf]=t)}}class uS extends Gm{constructor(t){super(Yw,"xdc",!0),this.uri=new Lm,this.xsl=new Lm}}class CS extends Gm{constructor(t){super(Yw,"xdp",!0),this.packets=null}}class BS extends Gm{constructor(t){super(Yw,"xsl",!0),this.debug=null,this.uri=null}}class QS extends Gm{constructor(t){super(Yw,"zpl",!0),this.name=t.name?t.name.trim():"",this.batchOutput=null,this.flipLabel=null,this.fontInfo=null,this.xdc=null}}class ES{static[Kp](t,e){if(ES.hasOwnProperty(t))return ES[t](e)}static acrobat(t){return new Tw(t)}static acrobat7(t){return new Pw(t)}static ADBE_JSConsole(t){return new Kw(t)}static ADBE_JSDebugger(t){return new qw(t)}static addSilentPrint(t){return new Ow(t)}static addViewerPreferences(t){return new Ww(t)}static adjustData(t){return new jw(t)}static adobeExtensionLevel(t){return new Vw(t)}static agent(t){return new Zw(t)}static alwaysEmbed(t){return new Xw(t)}static amd(t){return new zw(t)}static area(t){return new $w(t)}static attributes(t){return new tD(t)}static autoSave(t){return new eD(t)}static base(t){return new AD(t)}static batchOutput(t){return new iD(t)}static behaviorOverride(t){return new sD(t)}static cache(t){return new aD(t)}static change(t){return new nD(t)}static common(t){return new rD(t)}static compress(t){return new oD(t)}static compressLogicalStructure(t){return new gD(t)}static compressObjectStream(t){return new cD(t)}static compression(t){return new hD(t)}static config(t){return new lD(t)}static conformance(t){return new ID(t)}static contentCopy(t){return new dD(t)}static copies(t){return new uD(t)}static creator(t){return new CD(t)}static currentPage(t){return new BD(t)}static data(t){return new QD(t)}static debug(t){return new ED(t)}static defaultTypeface(t){return new fD(t)}static destination(t){return new pD(t)}static documentAssembly(t){return new mD(t)}static driver(t){return new yD(t)}static duplexOption(t){return new bD(t)}static dynamicRender(t){return new wD(t)}static embed(t){return new DD(t)}static encrypt(t){return new kD(t)}static encryption(t){return new SD(t)}static encryptionLevel(t){return new xD(t)}static enforce(t){return new FD(t)}static equate(t){return new RD(t)}static equateRange(t){return new vD(t)}static exclude(t){return new ND(t)}static excludeNS(t){return new MD(t)}static flipLabel(t){return new GD(t)}static fontInfo(t){return new LD(t)}static formFieldFilling(t){return new UD(t)}static groupParent(t){return new HD(t)}static ifEmpty(t){return new JD(t)}static includeXDPContent(t){return new _D(t)}static incrementalLoad(t){return new YD(t)}static incrementalMerge(t){return new TD(t)}static interactive(t){return new PD(t)}static jog(t){return new KD(t)}static labelPrinter(t){return new qD(t)}static layout(t){return new OD(t)}static level(t){return new WD(t)}static linearized(t){return new jD(t)}static locale(t){return new VD(t)}static localeSet(t){return new ZD(t)}static log(t){return new XD(t)}static map(t){return new zD(t)}static mediumInfo(t){return new $D(t)}static message(t){return new tk(t)}static messaging(t){return new ek(t)}static mode(t){return new Ak(t)}static modifyAnnots(t){return new ik(t)}static msgId(t){return new sk(t)}static nameAttr(t){return new ak(t)}static neverEmbed(t){return new nk(t)}static numberOfCopies(t){return new rk(t)}static openAction(t){return new ok(t)}static output(t){return new gk(t)}static outputBin(t){return new ck(t)}static outputXSL(t){return new hk(t)}static overprint(t){return new lk(t)}static packets(t){return new Ik(t)}static pageOffset(t){return new dk(t)}static pageRange(t){return new uk(t)}static pagination(t){return new Ck(t)}static paginationOverride(t){return new Bk(t)}static part(t){return new Qk(t)}static pcl(t){return new Ek(t)}static pdf(t){return new fk(t)}static pdfa(t){return new pk(t)}static permissions(t){return new mk(t)}static pickTrayByPDFSize(t){return new yk(t)}static picture(t){return new bk(t)}static plaintextMetadata(t){return new wk(t)}static presence(t){return new Dk(t)}static present(t){return new kk(t)}static print(t){return new Sk(t)}static printHighQuality(t){return new xk(t)}static printScaling(t){return new Fk(t)}static printerName(t){return new Rk(t)}static producer(t){return new vk(t)}static ps(t){return new Nk(t)}static range(t){return new Mk(t)}static record(t){return new Gk(t)}static relevant(t){return new Lk(t)}static rename(t){return new Uk(t)}static renderPolicy(t){return new Hk(t)}static runScripts(t){return new Jk(t)}static script(t){return new _k(t)}static scriptModel(t){return new Yk(t)}static severity(t){return new Tk(t)}static silentPrint(t){return new Pk(t)}static staple(t){return new Kk(t)}static startNode(t){return new qk(t)}static startPage(t){return new Ok(t)}static submitFormat(t){return new Wk(t)}static submitUrl(t){return new jk(t)}static subsetBelow(t){return new Vk(t)}static suppressBanner(t){return new Zk(t)}static tagged(t){return new Xk(t)}static template(t){return new zk(t)}static templateCache(t){return new eS(t)}static threshold(t){return new $k(t)}static to(t){return new tS(t)}static trace(t){return new AS(t)}static transform(t){return new iS(t)}static type(t){return new sS(t)}static uri(t){return new aS(t)}static validate(t){return new nS(t)}static validateApprovalSignatures(t){return new rS(t)}static validationMessaging(t){return new oS(t)}static version(t){return new gS(t)}static versionControl(t){return new cS(t)}static viewerPreferences(t){return new hS(t)}static webClient(t){return new lS(t)}static whitespace(t){return new IS(t)}static window(t){return new dS(t)}static xdc(t){return new uS(t)}static xdp(t){return new CS(t)}static xsl(t){return new BS(t)}static zpl(t){return new QS(t)}}const fS=qp.connectionSet.id;class pS extends Gm{constructor(t){super(fS,"connectionSet",!0),this.wsdlConnection=new Lm,this.xmlConnection=new Lm,this.xsdConnection=new Lm}}class mS extends Gm{constructor(t){super(fS,"effectiveInputPolicy"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class yS extends Gm{constructor(t){super(fS,"effectiveOutputPolicy"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class bS extends Ym{constructor(t){super(fS,"operation"),this.id=t.id||"",this.input=t.input||"",this.name=t.name||"",this.output=t.output||"",this.use=t.use||"",this.usehref=t.usehref||""}}class wS extends Ym{constructor(t){super(fS,"rootElement"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class DS extends Ym{constructor(t){super(fS,"soapAction"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class kS extends Ym{constructor(t){super(fS,"soapAddress"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class SS extends Ym{constructor(t){super(fS,"uri"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class xS extends Ym{constructor(t){super(fS,"wsdlAddress"),this.id=t.id||"",this.name=t.name||"",this.use=t.use||"",this.usehref=t.usehref||""}}class FS extends Gm{constructor(t){super(fS,"wsdlConnection",!0),this.dataDescription=t.dataDescription||"",this.name=t.name||"",this.effectiveInputPolicy=null,this.effectiveOutputPolicy=null,this.operation=null,this.soapAction=null,this.soapAddress=null,this.wsdlAddress=null}}class RS extends Gm{constructor(t){super(fS,"xmlConnection",!0),this.dataDescription=t.dataDescription||"",this.name=t.name||"",this.uri=null}}class vS extends Gm{constructor(t){super(fS,"xsdConnection",!0),this.dataDescription=t.dataDescription||"",this.name=t.name||"",this.rootElement=null,this.uri=null}}class NS{static[Kp](t,e){if(NS.hasOwnProperty(t))return NS[t](e)}static connectionSet(t){return new pS(t)}static effectiveInputPolicy(t){return new mS(t)}static effectiveOutputPolicy(t){return new yS(t)}static operation(t){return new bS(t)}static rootElement(t){return new wS(t)}static soapAction(t){return new DS(t)}static soapAddress(t){return new kS(t)}static uri(t){return new SS(t)}static wsdlAddress(t){return new xS(t)}static wsdlConnection(t){return new FS(t)}static xmlConnection(t){return new RS(t)}static xsdConnection(t){return new vS(t)}}const MS=qp.datasets.id;class GS extends Hm{constructor(t){super(MS,"data",t)}[up](){return!0}}class LS extends Gm{constructor(t){super(MS,"datasets",!0),this.data=null,this.Signature=null}[bp](t){const e=t[mp];("data"===e&&t[pp]===MS||"Signature"===e&&t[pp]===qp.signature.id)&&(this[e]=t),this[vf](t)}}class US{static[Kp](t,e){if(US.hasOwnProperty(t))return US[t](e)}static datasets(t){return new LS(t)}static data(t){return new GS(t)}}const HS=qp.localeSet.id;class JS extends Gm{constructor(t){super(HS,"calendarSymbols",!0),this.name="gregorian",this.dayNames=new Lm(2),this.eraNames=null,this.meridiemNames=null,this.monthNames=new Lm(2)}}class _S extends Ym{constructor(t){super(HS,"currencySymbol"),this.name=zp(t.name,["symbol","isoname","decimal"])}}class YS extends Gm{constructor(t){super(HS,"currencySymbols",!0),this.currencySymbol=new Lm(3)}}class TS extends Ym{constructor(t){super(HS,"datePattern"),this.name=zp(t.name,["full","long","med","short"])}}class PS extends Gm{constructor(t){super(HS,"datePatterns",!0),this.datePattern=new Lm(4)}}class KS extends Jm{constructor(t){super(HS,"dateTimeSymbols")}}class qS extends Ym{constructor(t){super(HS,"day")}}class OS extends Gm{constructor(t){super(HS,"dayNames",!0),this.abbr=Vp({data:t.abbr,defaultValue:0,validate:t=>1===t}),this.day=new Lm(7)}}class WS extends Ym{constructor(t){super(HS,"era")}}class jS extends Gm{constructor(t){super(HS,"eraNames",!0),this.era=new Lm(2)}}class VS extends Gm{constructor(t){super(HS,"locale",!0),this.desc=t.desc||"",this.name="isoname",this.calendarSymbols=null,this.currencySymbols=null,this.datePatterns=null,this.dateTimeSymbols=null,this.numberPatterns=null,this.numberSymbols=null,this.timePatterns=null,this.typeFaces=null}}class ZS extends Gm{constructor(t){super(HS,"localeSet",!0),this.locale=new Lm}}class XS extends Ym{constructor(t){super(HS,"meridiem")}}class zS extends Gm{constructor(t){super(HS,"meridiemNames",!0),this.meridiem=new Lm(2)}}class $S extends Ym{constructor(t){super(HS,"month")}}class tx extends Gm{constructor(t){super(HS,"monthNames",!0),this.abbr=Vp({data:t.abbr,defaultValue:0,validate:t=>1===t}),this.month=new Lm(12)}}class ex extends Ym{constructor(t){super(HS,"numberPattern"),this.name=zp(t.name,["full","long","med","short"])}}class Ax extends Gm{constructor(t){super(HS,"numberPatterns",!0),this.numberPattern=new Lm(4)}}class ix extends Ym{constructor(t){super(HS,"numberSymbol"),this.name=zp(t.name,["decimal","grouping","percent","minus","zero"])}}class sx extends Gm{constructor(t){super(HS,"numberSymbols",!0),this.numberSymbol=new Lm(5)}}class ax extends Ym{constructor(t){super(HS,"timePattern"),this.name=zp(t.name,["full","long","med","short"])}}class nx extends Gm{constructor(t){super(HS,"timePatterns",!0),this.timePattern=new Lm(4)}}class rx extends Gm{constructor(t){super(HS,"typeFace",!0),this.name=""|t.name}}class ox extends Gm{constructor(t){super(HS,"typeFaces",!0),this.typeFace=new Lm}}class gx{static[Kp](t,e){if(gx.hasOwnProperty(t))return gx[t](e)}static calendarSymbols(t){return new JS(t)}static currencySymbol(t){return new _S(t)}static currencySymbols(t){return new YS(t)}static datePattern(t){return new TS(t)}static datePatterns(t){return new PS(t)}static dateTimeSymbols(t){return new KS(t)}static day(t){return new qS(t)}static dayNames(t){return new OS(t)}static era(t){return new WS(t)}static eraNames(t){return new jS(t)}static locale(t){return new VS(t)}static localeSet(t){return new ZS(t)}static meridiem(t){return new XS(t)}static meridiemNames(t){return new zS(t)}static month(t){return new $S(t)}static monthNames(t){return new tx(t)}static numberPattern(t){return new ex(t)}static numberPatterns(t){return new Ax(t)}static numberSymbol(t){return new ix(t)}static numberSymbols(t){return new sx(t)}static timePattern(t){return new ax(t)}static timePatterns(t){return new nx(t)}static typeFace(t){return new rx(t)}static typeFaces(t){return new ox(t)}}const cx=qp.signature.id;class hx extends Gm{constructor(t){super(cx,"signature",!0)}}class lx{static[Kp](t,e){if(lx.hasOwnProperty(t))return lx[t](e)}static signature(t){return new hx(t)}}const Ix=qp.stylesheet.id;class dx extends Gm{constructor(t){super(Ix,"stylesheet",!0)}}class ux{static[Kp](t,e){if(ux.hasOwnProperty(t))return ux[t](e)}static stylesheet(t){return new dx(t)}}const Cx=qp.xdp.id;class Bx extends Gm{constructor(t){super(Cx,"xdp",!0),this.uuid=t.uuid||"",this.timeStamp=t.timeStamp||"",this.config=null,this.connectionSet=null,this.datasets=null,this.localeSet=null,this.stylesheet=new Lm,this.template=null}[wp](t){const e=qp[t[mp]];return e&&t[pp]===e.id}}class Qx{static[Kp](t,e){if(Qx.hasOwnProperty(t))return Qx[t](e)}static xdp(t){return new Bx(t)}}const Ex=qp.xhtml.id,fx=Symbol(),px=new Set(["color","font","font-family","font-size","font-stretch","font-style","font-weight","margin","margin-bottom","margin-left","margin-right","margin-top","letter-spacing","line-height","orphans","page-break-after","page-break-before","page-break-inside","tab-interval","tab-stop","text-align","text-decoration","text-indent","vertical-align","widows","kerning-mode","xfa-font-horizontal-scale","xfa-font-vertical-scale","xfa-spacerun","xfa-tab-stops"]),mx=new Map([["page-break-after","breakAfter"],["page-break-before","breakBefore"],["page-break-inside","breakInside"],["kerning-mode",t=>"none"===t?"none":"normal"],["xfa-font-horizontal-scale",t=>`scaleX(${Math.max(0,Math.min(parseInt(t)/100)).toFixed(2)})`],["xfa-font-vertical-scale",t=>`scaleY(${Math.max(0,Math.min(parseInt(t)/100)).toFixed(2)})`],["xfa-spacerun",""],["xfa-tab-stops",""],["font-size",(t,e)=>qm(.99*(t=e.fontSize=$p(t)))],["letter-spacing",t=>qm($p(t))],["line-height",t=>qm($p(t))],["margin",t=>qm($p(t))],["margin-bottom",t=>qm($p(t))],["margin-left",t=>qm($p(t))],["margin-right",t=>qm($p(t))],["margin-top",t=>qm($p(t))],["text-indent",t=>qm($p(t))],["font-family",t=>t],["vertical-align",t=>qm($p(t))]]),yx=/\s+/g,bx=/[\r\n]+/g,wx=/\r\n?/g;function Dx(t,e,A){const i=Object.create(null);if(!t)return i;const s=Object.create(null);for(const[e,A]of t.split(";").map((t=>t.split(":",2)))){const t=mx.get(e);if(""===t)continue;let a=A;t&&(a="string"==typeof t?t:t(A,s)),e.endsWith("scale")?i.transform=i.transform?`${i[e]} ${a}`:a:i[e.replaceAll(/-([a-zA-Z])/g,((t,e)=>e.toUpperCase()))]=a}if(i.fontFamily&&ny({typeface:i.fontFamily,weight:i.fontWeight||"normal",posture:i.fontStyle||"normal",size:s.fontSize||0},e,e[np].fontFinder,i),A&&i.verticalAlign&&"0px"!==i.verticalAlign&&i.fontSize){const t=.583,e=.333,A=$p(i.fontSize);i.fontSize=qm(A*t),i.verticalAlign=qm(Math.sign($p(i.verticalAlign))*A*e)}return A&&i.fontSize&&(i.fontSize=`calc(${i.fontSize} * var(--scale-factor))`),ey(i),i}const kx=new Set(["body","html"]);class Sx extends Hm{constructor(t,e){super(Ex,e),this[fx]=!1,this.style=t.style||""}[Mf](t){super[Mf](t),this.style=function(t){return t.style?t.style.trim().split(/\s*;\s*/).filter((t=>!!t)).map((t=>t.split(/\s*:\s*/,2))).filter((([e,A])=>("font-family"===e&&t[np].usedTypefaces.add(A),px.has(e)))).map((t=>t.join(":"))).join(";"):""}(this)}[Ff](){return!kx.has(this[mp])}[Dp](t,e=!1){e?this[fx]=!0:(t=t.replaceAll(bx,""),this.style.includes("xfa-spacerun:yes")||(t=t.replaceAll(yx," "))),t&&(this[Jf]+=t)}[kp](t,e=!0){const A=Object.create(null),i={top:NaN,bottom:NaN,left:NaN,right:NaN};let s=null;for(const[t,e]of this.style.split(";").map((t=>t.split(":",2))))switch(t){case"font-family":A.typeface=jp(e);break;case"font-size":A.size=$p(e);break;case"font-weight":A.weight=e;break;case"font-style":A.posture=e;break;case"letter-spacing":A.letterSpacing=$p(e);break;case"margin":const t=e.split(/ \t/).map((t=>$p(t)));switch(t.length){case 1:i.top=i.bottom=i.left=i.right=t[0];break;case 2:i.top=i.bottom=t[0],i.left=i.right=t[1];break;case 3:i.top=t[0],i.bottom=t[2],i.left=i.right=t[1];break;case 4:i.top=t[0],i.left=t[1],i.bottom=t[2],i.right=t[3]}break;case"margin-top":i.top=$p(e);break;case"margin-bottom":i.bottom=$p(e);break;case"margin-left":i.left=$p(e);break;case"margin-right":i.right=$p(e);break;case"line-height":s=$p(e)}if(t.pushData(A,i,s),this[Jf])t.addString(this[Jf]);else for(const e of this[tp]())"#text"!==e[mp]?e[kp](t):t.addString(e[Jf]);e&&t.popFont()}[_p](t){const e=[];if(this[Tf]={children:e},this[Nf]({}),0===e.length&&!this[Jf])return Am.EMPTY;let A;return A=this[fx]?this[Jf]?this[Jf].replaceAll(wx,"\n"):void 0:this[Jf]||void 0,Am.success({name:this[mp],attributes:{href:this.href,style:Dx(this.style,this,this[fx])},children:e,value:A})}}class xx extends Sx{constructor(t){super(t,"a"),this.href=ry(t.href)||""}}class Fx extends Sx{constructor(t){super(t,"b")}[kp](t){t.pushFont({weight:"bold"}),super[kp](t),t.popFont()}}class Rx extends Sx{constructor(t){super(t,"body")}[_p](t){const e=super[_p](t),{html:A}=e;return A?(A.name="div",A.attributes.class=["xfaRich"],e):Am.EMPTY}}class vx extends Sx{constructor(t){super(t,"br")}[Hp](){return"\n"}[kp](t){t.addString("\n")}[_p](t){return Am.success({name:"br"})}}class Nx extends Sx{constructor(t){super(t,"html")}[_p](t){const e=[];if(this[Tf]={children:e},this[Nf]({}),0===e.length)return Am.success({name:"div",attributes:{class:["xfaRich"],style:{}},value:this[Jf]||""});if(1===e.length){const t=e[0];if(t.attributes?.class.includes("xfaRich"))return Am.success(t)}return Am.success({name:"div",attributes:{class:["xfaRich"],style:{}},children:e})}}class Mx extends Sx{constructor(t){super(t,"i")}[kp](t){t.pushFont({posture:"italic"}),super[kp](t),t.popFont()}}class Gx extends Sx{constructor(t){super(t,"li")}}class Lx extends Sx{constructor(t){super(t,"ol")}}class Ux extends Sx{constructor(t){super(t,"p")}[kp](t){super[kp](t,!1),t.addString("\n"),t.addPara(),t.popFont()}[Hp](){return this[sp]()[tp]().at(-1)===this?super[Hp]():super[Hp]()+"\n"}}class Hx extends Sx{constructor(t){super(t,"span")}}class Jx extends Sx{constructor(t){super(t,"sub")}}class _x extends Sx{constructor(t){super(t,"sup")}}class Yx extends Sx{constructor(t){super(t,"ul")}}class Tx{static[Kp](t,e){if(Tx.hasOwnProperty(t))return Tx[t](e)}static a(t){return new xx(t)}static b(t){return new Fx(t)}static body(t){return new Rx(t)}static br(t){return new vx(t)}static html(t){return new Nx(t)}static i(t){return new Mx(t)}static li(t){return new Gx(t)}static ol(t){return new Lx(t)}static p(t){return new Ux(t)}static span(t){return new Hx(t)}static sub(t){return new Jx(t)}static sup(t){return new _x(t)}static ul(t){return new Yx(t)}}const Px={config:ES,connection:NS,datasets:US,localeSet:gx,signature:lx,stylesheet:ux,template:Lw,xdp:Qx,xhtml:Tx};class Kx{constructor(t){this.namespaceId=t}[Kp](t,e){return new Hm(this.namespaceId,t,e)}}class qx extends Gm{constructor(t){super(-1,"root",Object.create(null)),this.element=null,this[op]=t}[bp](t){return this.element=t,!0}[Pf](){super[Pf](),this.element.template instanceof bw&&(this[op].set(Rp,this.element),this.element.template[vp](this[op]),this.element.template[op]=this[op])}}class Ox extends Gm{constructor(){super(-1,"",Object.create(null))}[bp](t){return!1}}class Wx{constructor(t=null){this._namespaceStack=[],this._nsAgnosticLevel=0,this._namespacePrefixes=new Map,this._namespaces=new Map,this._nextNsId=Math.max(...Object.values(qp).map((({id:t})=>t))),this._currentNamespace=t||new Kx(++this._nextNsId)}buildRoot(t){return new qx(t)}build({nsPrefix:t,name:e,attributes:A,namespace:i,prefixes:s}){const a=null!==i;if(a&&(this._namespaceStack.push(this._currentNamespace),this._currentNamespace=this._searchNamespace(i)),s&&this._addNamespacePrefix(s),A.hasOwnProperty(yp)){const t=Px.datasets,e=A[yp];let i=null;for(const[A,s]of Object.entries(e))if(this._getNamespaceToUse(A)===t){i={xfa:s};break}i?A[yp]=i:delete A[yp]}const n=this._getNamespaceToUse(t),r=n?.[Kp](e,A)||new Ox;return r[up]()&&this._nsAgnosticLevel++,(a||s||r[up]())&&(r[Lf]={hasNamespace:a,prefixes:s,nsAgnostic:r[up]()}),r}isNsAgnostic(){return this._nsAgnosticLevel>0}_searchNamespace(t){let e=this._namespaces.get(t);if(e)return e;for(const[A,{check:i}]of Object.entries(qp))if(i(t)){if(e=Px[A],e)return this._namespaces.set(t,e),e;break}return e=new Kx(++this._nextNsId),this._namespaces.set(t,e),e}_addNamespacePrefix(t){for(const{prefix:e,value:A}of t){const t=this._searchNamespace(A);let i=this._namespacePrefixes.get(e);i||(i=[],this._namespacePrefixes.set(e,i)),i.push(t)}}_getNamespaceToUse(t){if(!t)return this._currentNamespace;const e=this._namespacePrefixes.get(t);return e?.length>0?e.at(-1):(Zc(`Unknown namespace prefix: ${t}.`),null)}clean(t){const{hasNamespace:e,prefixes:A,nsAgnostic:i}=t;e&&(this._currentNamespace=this._namespaceStack.pop()),A&&A.forEach((({prefix:t})=>{this._namespacePrefixes.get(t).pop()})),i&&this._nsAgnosticLevel--}}class jx extends OE{constructor(t=null,e=!1){super(),this._builder=new Wx(t),this._stack=[],this._globalData={usedTypefaces:new Set},this._ids=new Map,this._current=this._builder.buildRoot(this._ids),this._errorCode=0,this._whiteRegex=/^\s+$/,this._nbsps=/\xa0+/g,this._richText=e}parse(t){if(this.parseXml(t),0===this._errorCode)return this._current[Pf](),this._current.element}onText(t){t=t.replace(this._nbsps,(t=>t.slice(1)+" ")),this._richText||this._current[Ff]()?this._current[Dp](t,this._richText):this._whiteRegex.test(t)||this._current[Dp](t.trim())}onCdata(t){this._current[Dp](t)}_mkAttributes(t,e){let A=null,i=null;const s=Object.create({});for(const{name:a,value:n}of t)if("xmlns"===a)A?Zc(`XFA - multiple namespace definition in <${e}>`):A=n;else if(a.startsWith("xmlns:")){const t=a.substring(6);i||(i=[]),i.push({prefix:t,value:n})}else{const t=a.indexOf(":");if(-1===t)s[a]=n;else{let e=s[yp];e||(e=s[yp]=Object.create(null));const[A,i]=[a.slice(0,t),a.slice(t+1)];(e[A]||=Object.create(null))[i]=n}}return[A,i,s]}_getNameAndPrefix(t,e){const A=t.indexOf(":");return-1===A?[t,null]:[t.substring(A+1),e?"":t.substring(0,A)]}onBeginElement(t,e,A){const[i,s,a]=this._mkAttributes(e,t),[n,r]=this._getNameAndPrefix(t,this._builder.isNsAgnostic()),o=this._builder.build({nsPrefix:r,name:n,attributes:a,namespace:i,prefixes:s});o[np]=this._globalData,A?(o[Pf](),this._current[bp](o)&&o[Mp](this._ids),o[Mf](this._builder)):(this._stack.push(this._current),this._current=o)}onEndElement(t){const e=this._current;if(e[hp]()&&"string"==typeof e[Jf]){const t=new jx;t._globalData=this._globalData;const A=t.parse(e[Jf]);e[Jf]=null,e[bp](A)}e[Pf](),this._current=this._stack.pop(),this._current[bp](e)&&e[Mp](this._ids),e[Mf](this._builder)}onError(t){this._errorCode=t}}class Vx{constructor(t){try{this.root=(new jx).parse(Vx._createDocument(t));const e=new Jw(this.root);this.form=e.bind(),this.dataHandler=new _w(this.root,e.getData()),this.form[np].template=this.form}catch(t){Zc(`XFA - an error occurred during parsing and binding: ${t}`)}}isValid(){return this.root&&this.form}_createPagesHelper(){const t=this.form[Jp]();return new Promise(((e,A)=>{const i=()=>{try{const A=t.next();A.done?e(A.value):setTimeout(i,0)}catch(t){A(t)}};setTimeout(i,0)}))}async _createPages(){try{this.pages=await this._createPagesHelper(),this.dims=this.pages.children.map((t=>{const{width:e,height:A}=t.attributes.style;return[0,0,parseInt(e),parseInt(A)]}))}catch(t){Zc(`XFA - an error occurred during layout: ${t}`)}}getBoundingBox(t){return this.dims[t]}async getNumPages(){return this.pages||await this._createPages(),this.dims.length}setImages(t){this.form[np].images=t}setFonts(t){this.form[np].fontFinder=new im(t);const e=[];for(let t of this.form[np].usedTypefaces)t=jp(t),this.form[np].fontFinder.find(t)||e.push(t);return e.length>0?e:null}appendFonts(t,e){this.form[np].fontFinder.add(t,e)}async getPages(){this.pages||await this._createPages();const t=this.pages;return this.pages=null,t}serializeData(t){return this.dataHandler.serialize(t)}static _createDocument(t){return t["/xdp:xdp"]?Object.values(t).join(""):t["xdp:xdp"]}static getRichTextAsHtml(t){if(!t||"string"!=typeof t)return null;try{let e=new jx(Tx,!0).parse(t);if(!["body","xhtml"].includes(e[mp])){const t=Tx.body({});t[vf](e),e=t}const A=e[_p]();if(!A.success)return null;const{html:i}=A,{attributes:s}=i;return s&&(s.class&&(s.class=s.class.filter((t=>!t.startsWith("xfa")))),s.dir="auto"),{html:i,str:e[Hp]()}}catch(t){Zc(`XFA - an error occurred during parsing of rich text: ${t}`)}return null}}class Zx{static createGlobals(t){return Promise.all([t.ensureCatalog("acroForm"),t.ensureDoc("xfaDatasets"),t.ensureCatalog("structTreeRoot"),t.ensureCatalog("baseUrl"),t.ensureCatalog("attachments")]).then((([e,A,i,s,a])=>({pdfManager:t,acroForm:e instanceof vh?e:vh.empty,xfaDatasets:A,structTreeRoot:i,baseUrl:s,attachments:a})),(t=>(Zc(`createGlobals: "${t}".`),null)))}static async create(t,e,A,i,s,a){const n=s?await this._getPageIndex(t,e,A.pdfManager):null;return A.pdfManager.ensure(this,"_create",[t,e,A,i,s,n,a])}static _create(t,e,A,i,s=!1,a=null,n=null){const r=t.fetchIfRef(e);if(!(r instanceof vh))return;const{acroForm:o,pdfManager:g}=A,c=e instanceof Nh?e.toString():`annot_${i.createObjId()}`;let h=r.get("Subtype");h=h instanceof xh?h.name:null;const l={xref:t,ref:e,dict:r,subtype:h,id:c,annotationGlobals:A,collectFields:s,needAppearances:!s&&!0===o.get("NeedAppearances"),pageIndex:a,evaluatorOptions:g.evaluatorOptions,pageRef:n};switch(h){case"Link":return new cF(l);case"Text":return new gF(l);case"Widget":let t=jh({dict:r,key:"FT"});switch(t=t instanceof xh?t.name:null,t){case"Tx":return new aF(l);case"Btn":return new nF(l);case"Ch":return new rF(l);case"Sig":return new oF(l)}return Zc(`Unimplemented widget field type "${t}", falling back to base field type.`),new sF(l);case"Popup":return new hF(l);case"FreeText":return new lF(l);case"Line":return new IF(l);case"Square":return new dF(l);case"Circle":return new uF(l);case"PolyLine":return new CF(l);case"Polygon":return new BF(l);case"Caret":return new QF(l);case"Ink":return new EF(l);case"Highlight":return new fF(l);case"Underline":return new pF(l);case"Squiggly":return new mF(l);case"StrikeOut":return new yF(l);case"Stamp":return new bF(l);case"FileAttachment":return new wF(l);default:return s||Zc(h?`Unimplemented annotation type "${h}", falling back to base annotation.`:"Annotation is missing the required /Subtype."),new eF(l)}}static async _getPageIndex(t,e,A){try{const i=await t.fetchIfRefAsync(e);if(!(i instanceof vh))return-1;const s=i.getRaw("P");if(s instanceof Nh)try{return await A.ensureCatalog("getPageIndex",[s])}catch(t){Vc(`_getPageIndex -- not a valid page reference: "${t}".`)}if(i.has("Kids"))return-1;const a=await A.ensureDoc("numPages");for(let t=0;tt/255))}function $x(t,e){const A=t.getArray("QuadPoints");if(!Al(A,null)||0===A.length||A.length%8>0)return null;const i=new Float32Array(A.length);for(let t=0,s=A.length;te[2]||de[3]))return null;i.set([l,u,I,u,l,d,I,d],t)}return i}function tF(t,e,A){const[i,s,a,n]=uh.getAxialAlignedBoundingBox(e,A);if(i===a||s===n)return[1,0,0,1,t[0],t[1]];const r=(t[2]-t[0])/(a-i),o=(t[3]-t[1])/(n-s);return[r,0,0,o,t[0]-i*r,t[1]-s*o]}class eF{constructor(t){const{dict:e,xref:A,annotationGlobals:i}=t;this.setTitle(e.get("T")),this.setContents(e.get("Contents")),this.setModificationDate(e.get("M")),this.setFlags(e.get("F")),this.setRectangle(e.getArray("Rect")),this.setColor(e.getArray("C")),this.setBorderStyle(e),this.setAppearance(e),this.setOptionalContent(e);const s=e.get("MK");this.setBorderAndBackgroundColors(s),this.setRotation(s,e),this.ref=t.ref instanceof Nh?t.ref:null,this._streams=[],this.appearance&&this._streams.push(this.appearance);const a=!!(128&this.flags),n=!!(512&this.flags);if(i.structTreeRoot){let A=e.get("StructParent");A=Number.isInteger(A)&&A>=0?A:-1,i.structTreeRoot.addAnnotationIdToPage(t.pageRef,A)}if(this.data={annotationFlags:this.flags,borderStyle:this.borderStyle,color:this.color,backgroundColor:this.backgroundColor,borderColor:this.borderColor,rotation:this.rotation,contentsObj:this._contents,hasAppearance:!!this.appearance,id:t.id,modificationDate:this.modificationDate,rect:this.rectangle,subtype:t.subtype,hasOwnCanvas:!1,noRotate:!!(16&this.flags),noHTML:a&&n,isEditable:!1},t.collectFields){const i=e.get("Kids");if(Array.isArray(i)){const t=[];for(const e of i)e instanceof Nh&&t.push(e.toString());0!==t.length&&(this.data.kidIds=t)}this.data.actions=cl(A,e,vc),this.data.fieldName=this._constructFieldName(e),this.data.pageIndex=t.pageIndex}this._isOffscreenCanvasSupported=t.evaluatorOptions.isOffscreenCanvasSupported,this._fallbackFontDict=null,this._needAppearances=!1}_hasFlag(t,e){return!!(t&e)}_isViewable(t){return!this._hasFlag(t,1)&&!this._hasFlag(t,32)}_isPrintable(t){return this._hasFlag(t,4)&&!this._hasFlag(t,2)&&!this._hasFlag(t,1)}mustBeViewed(t,e){const A=t?.get(this.data.id)?.noView;return void 0!==A?!A:this.viewable&&!this._hasFlag(this.flags,2)}mustBePrinted(t){const e=t?.get(this.data.id)?.noPrint;return void 0!==e?!e:this.printable}mustBeViewedWhenEditing(t,e=null){return t?!this.data.isEditable:!e?.has(this.data.id)}get viewable(){return null!==this.data.quadPoints&&(0===this.flags||this._isViewable(this.flags))}get printable(){return null!==this.data.quadPoints&&0!==this.flags&&this._isPrintable(this.flags)}_parseStringHelper(t){const e="string"==typeof t?Bh(t):"";return{str:e,dir:e&&"rtl"===tE(e).dir?"rtl":"ltr"}}setDefaultAppearance(t){const{dict:e,annotationGlobals:A}=t,i=jh({dict:e,key:"DA"})||A.acroForm.get("DA");this._defaultAppearance="string"==typeof i?i:"",this.data.defaultAppearanceData=GE(this._defaultAppearance)}setTitle(t){this._title=this._parseStringHelper(t)}setContents(t){this._contents=this._parseStringHelper(t)}setModificationDate(t){this.modificationDate="string"==typeof t?t:null}setFlags(t){this.flags=Number.isInteger(t)&&t>0?t:0,1&this.flags&&"Annotation"!==this.constructor.name&&(this.flags^=1)}hasFlag(t){return this._hasFlag(this.flags,t)}setRectangle(t){this.rectangle=al(t,[0,0,0,0])}setColor(t){this.color=Xx(t)}setLineEndings(t){if(this.lineEndings=["None","None"],Array.isArray(t)&&2===t.length)for(let e=0;e<2;e++){const A=t[e];if(A instanceof xh)switch(A.name){case"None":continue;case"Square":case"Circle":case"Diamond":case"OpenArrow":case"ClosedArrow":case"Butt":case"ROpenArrow":case"RClosedArrow":case"Slash":this.lineEndings[e]=A.name;continue}Zc(`Ignoring invalid lineEnding: ${A}`)}}setRotation(t,e){this.rotation=0;let A=t instanceof vh?t.get("R")||0:e.get("Rotate")||0;Number.isInteger(A)&&0!==A&&(A%=360,A<0&&(A+=360),A%90==0&&(this.rotation=A))}setBorderAndBackgroundColors(t){t instanceof vh?(this.borderColor=Xx(t.getArray("BC"),null),this.backgroundColor=Xx(t.getArray("BG"),null)):this.borderColor=this.backgroundColor=null}setBorderStyle(t){if(this.borderStyle=new AF,t instanceof vh)if(t.has("BS")){const e=t.get("BS");if(e instanceof vh){const t=e.get("Type");t&&!Lh(t,"Border")||(this.borderStyle.setWidth(e.get("W"),this.rectangle),this.borderStyle.setStyle(e.get("S")),this.borderStyle.setDashArray(e.getArray("D")))}}else if(t.has("Border")){const e=t.getArray("Border");Array.isArray(e)&&e.length>=3&&(this.borderStyle.setHorizontalCornerRadius(e[0]),this.borderStyle.setVerticalCornerRadius(e[1]),this.borderStyle.setWidth(e[2],this.rectangle),4===e.length&&this.borderStyle.setDashArray(e[3],!0))}else this.borderStyle.setWidth(0)}setAppearance(t){this.appearance=null;const e=t.get("AP");if(!(e instanceof vh))return;const A=e.get("N");if(A instanceof _h)return void(this.appearance=A);if(!(A instanceof vh))return;const i=t.get("AS");if(!(i instanceof xh&&A.has(i.name)))return;const s=A.get(i.name);s instanceof _h&&(this.appearance=s)}setOptionalContent(t){this.oc=null;const e=t.get("OC");e instanceof xh?Zc("setOptionalContent: Support for /Name-entry is not implemented."):e instanceof vh&&(this.oc=e)}loadResources(t,e){return e.dict.getAsync("Resources").then((e=>{if(e)return new xf(e,t,e.xref).load().then((function(){return e}))}))}async getOperatorList(t,e,A,i){const{hasOwnCanvas:s,id:a,rect:n}=this.data;let r=this.appearance;const o=!!(s&&2&A);if(o&&(n[0]===n[2]||n[1]===n[3]))return this.data.hasOwnCanvas=!1,{opList:new EE,separateForm:!1,separateCanvas:!1};if(!r){if(!o)return{opList:new EE,separateForm:!1,separateCanvas:!1};r=new wl(""),r.dict=new vh}const g=r.dict,c=await this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"],r),h=sl(g.getArray("BBox"),[0,0,1,1]),l=il(g.getArray("Matrix"),yc),I=tF(n,h,l),d=new EE;let u;return this.oc&&(u=await t.parseMarkedContentProps(this.oc,null)),void 0!==u&&d.addOp(Kc,["OC",u]),d.addOp(80,[a,n,I,l,o]),await t.getOperatorList({stream:r,task:e,resources:c,operatorList:d,fallbackFontDict:this._fallbackFontDict}),d.addOp(81,[]),void 0!==u&&d.addOp(qc,[]),this.reset(),{opList:d,separateForm:!1,separateCanvas:o}}async save(t,e,A){return null}get hasTextContent(){return!1}async extractTextContent(t,e,A){if(!this.appearance)return;const i=await this.loadResources(["ExtGState","Font","Properties","XObject"],this.appearance),s=[],a=[];let n=null;const r={desiredSize:Math.Infinity,ready:!0,enqueue(t,e){for(const e of t.items)void 0!==e.str&&(n||=e.transform.slice(-2),a.push(e.str),e.hasEOL&&(s.push(a.join("").trimEnd()),a.length=0))}};if(await t.getTextContent({stream:this.appearance,task:e,resources:i,includeMarkedContent:!0,keepWhiteSpace:!0,sink:r,viewBox:A}),this.reset(),a.length&&s.push(a.join("").trimEnd()),s.length>1||s[0]){const t=this.appearance.dict,e=sl(t.getArray("BBox"),null),A=il(t.getArray("Matrix"),null);this.data.textPosition=this._transformPoint(n,e,A),this.data.textContent=s}}_transformPoint(t,e,A){const{rect:i}=this.data;e||=[0,0,1,1],A||=[1,0,0,1,0,0];const s=tF(i,e,A);return s[4]-=i[0],s[5]-=i[1],t=uh.applyTransform(t,s),uh.applyTransform(t,A)}getFieldObject(){return this.data.kidIds?{id:this.data.id,actions:this.data.actions,name:this.data.fieldName,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,type:"",kidIds:this.data.kidIds,page:this.data.pageIndex,rotation:this.rotation}:null}reset(){for(const t of this._streams)t.reset()}_constructFieldName(t){if(!t.has("T")&&!t.has("Parent"))return Zc("Unknown field name, falling back to empty field name."),"";if(!t.has("Parent"))return Bh(t.get("T"));const e=[];t.has("T")&&e.unshift(Bh(t.get("T")));let A=t;const i=new Mh;for(t.objId&&i.put(t.objId);A.has("Parent")&&(A=A.get("Parent"),A instanceof vh&&(!A.objId||!i.has(A.objId)));)A.objId&&i.put(A.objId),A.has("T")&&e.unshift(Bh(A.get("T")));return e.join(".")}}class AF{constructor(){this.width=1,this.style=1,this.dashArray=[3],this.horizontalCornerRadius=0,this.verticalCornerRadius=0}setWidth(t,e=[0,0,0,0]){if(t instanceof xh)this.width=0;else if("number"==typeof t){if(t>0){const A=(e[2]-e[0])/2,i=(e[3]-e[1])/2;A>0&&i>0&&(t>A||t>i)&&(Zc(`AnnotationBorderStyle.setWidth - ignoring width: ${t}`),t=1)}this.width=t}}setStyle(t){if(t instanceof xh)switch(t.name){case"S":this.style=1;break;case"D":this.style=2;break;case"B":this.style=3;break;case"I":this.style=4;break;case"U":this.style=5}}setDashArray(t,e=!1){if(Array.isArray(t)){let A=!0,i=!0;for(const e of t){if(!(+e>=0)){A=!1;break}e>0&&(i=!1)}0===t.length||A&&!i?(this.dashArray=t,e&&this.setStyle(xh.get("D"))):this.width=0}else t&&(this.width=0)}setHorizontalCornerRadius(t){Number.isInteger(t)&&(this.horizontalCornerRadius=t)}setVerticalCornerRadius(t){Number.isInteger(t)&&(this.verticalCornerRadius=t)}}class iF extends eF{constructor(t){super(t);const{dict:e}=t;if(e.has("IRT")){const t=e.getRaw("IRT");this.data.inReplyTo=t instanceof Nh?t.toString():null;const A=e.get("RT");this.data.replyType=A instanceof xh?A.name:"R"}let A=null;if(this.data.replyType===xc){const t=e.get("IRT");this.setTitle(t.get("T")),this.data.titleObj=this._title,this.setContents(t.get("Contents")),this.data.contentsObj=this._contents,t.has("CreationDate")?(this.setCreationDate(t.get("CreationDate")),this.data.creationDate=this.creationDate):this.data.creationDate=null,t.has("M")?(this.setModificationDate(t.get("M")),this.data.modificationDate=this.modificationDate):this.data.modificationDate=null,A=t.getRaw("Popup"),t.has("C")?(this.setColor(t.getArray("C")),this.data.color=this.color):this.data.color=null}else this.data.titleObj=this._title,this.setCreationDate(e.get("CreationDate")),this.data.creationDate=this.creationDate,A=e.getRaw("Popup"),e.has("C")||(this.data.color=null);this.data.popupRef=A instanceof Nh?A.toString():null,e.has("RC")&&(this.data.richText=Vx.getRichTextAsHtml(e.get("RC")))}setCreationDate(t){this.creationDate="string"==typeof t?t:null}_setDefaultAppearance({xref:t,extra:e,strokeColor:A,fillColor:i,blendMode:s,strokeAlpha:a,fillAlpha:n,pointsCallback:r}){let o=Number.MAX_VALUE,g=Number.MAX_VALUE,c=Number.MIN_VALUE,h=Number.MIN_VALUE;const l=["q"];e&&l.push(e),A&&l.push(`${A[0]} ${A[1]} ${A[2]} RG`),i&&l.push(`${i[0]} ${i[1]} ${i[2]} rg`);let I=this.data.quadPoints;I||(I=Float32Array.from([this.rectangle[0],this.rectangle[3],this.rectangle[2],this.rectangle[3],this.rectangle[0],this.rectangle[1],this.rectangle[2],this.rectangle[1]]));for(let t=0,e=I.length;t"string"==typeof t)).map((t=>Bh(t))):t instanceof xh?Bh(t.name):"string"==typeof t?Bh(t):null}hasFieldFlag(t){return!!(this.data.fieldFlags&t)}_isViewable(t){return!0}mustBeViewed(t,e){return e?this.viewable:super.mustBeViewed(t,e)&&!this._hasFlag(this.flags,32)}getRotationMatrix(t){let e=t?.get(this.data.id)?.rotation;return void 0===e&&(e=this.rotation),0===e?yc:ml(e,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1])}getBorderAndBackgroundAppearances(t){let e=t?.get(this.data.id)?.rotation;if(void 0===e&&(e=this.rotation),!this.backgroundColor&&!this.borderColor)return"";const A=this.data.rect[2]-this.data.rect[0],i=this.data.rect[3]-this.data.rect[1],s=0===e||180===e?`0 0 ${A} ${i} re`:`0 0 ${i} ${A} re`;let a="";return this.backgroundColor&&(a=`${UE(this.backgroundColor,!0)} ${s} f `),this.borderColor&&(a+=`${this.borderStyle.width||1} w ${UE(this.borderColor,!1)} ${s} S `),a}async getOperatorList(t,e,A,i){if(16&A&&!(this instanceof oF)&&!this.data.noHTML&&!this.data.hasOwnCanvas)return{opList:new EE,separateForm:!0,separateCanvas:!1};if(!this._hasText)return super.getOperatorList(t,e,A,i);const s=await this._getAppearance(t,e,A,i);if(this.appearance&&null===s)return super.getOperatorList(t,e,A,i);const a=new EE;if(!this._defaultAppearance||null===s)return{opList:a,separateForm:!1,separateCanvas:!1};const n=!!(this.data.hasOwnCanvas&&2&A),r=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],o=tF(this.data.rect,r,[1,0,0,1,0,0]);let g;this.oc&&(g=await t.parseMarkedContentProps(this.oc,null)),void 0!==g&&a.addOp(Kc,["OC",g]),a.addOp(80,[this.data.id,this.data.rect,o,this.getRotationMatrix(i),n]);const c=new wl(s);return await t.getOperatorList({stream:c,task:e,resources:this._fieldResources.mergedResources,operatorList:a}),a.addOp(81,[]),void 0!==g&&a.addOp(qc,[]),{opList:a,separateForm:!1,separateCanvas:n}}_getMKDict(t){const e=new vh(null);return t&&e.set("R",t),this.borderColor&&e.set("BC",zx(this.borderColor)),this.backgroundColor&&e.set("BG",zx(this.backgroundColor)),e.size>0?e:null}amendSavedDict(t,e){}async save(t,e,A){const i=A?.get(this.data.id);let s=i?.value,a=i?.rotation;if(s===this.data.fieldValue||void 0===s){if(!this._hasValueFromXFA&&void 0===a)return null;s||=this.data.fieldValue}if(void 0===a&&!this._hasValueFromXFA&&Array.isArray(s)&&Array.isArray(this.data.fieldValue)&&s.length===this.data.fieldValue.length&&s.every(((t,e)=>t===this.data.fieldValue[e])))return null;void 0===a&&(a=this.rotation);let n=null;if(!this._needAppearances&&(n=await this._getAppearance(t,e,8,A),null===n))return null;let r=!1;n?.needAppearances&&(r=!0,n=null);const{xref:o}=t,g=o.fetchIfRef(this.ref);if(!(g instanceof vh))return null;const c=new vh(o);for(const t of g.getKeys())"AP"!==t&&c.set(t,g.getRaw(t));const h={path:this.data.fieldName,value:s};c.set("V",Array.isArray(s)?s.map(El):El(s)),this.amendSavedDict(A,c);const l=this._getMKDict(a);l&&c.set("MK",l);const I=[],d=[{ref:this.ref,data:"",xfa:h,needAppearances:r}];if(null!==n){const t=o.getNewTemporaryRef(),e=new vh(o);c.set("AP",e),e.set("N",t);const i=this._getSaveFieldResources(o),s=new wl(n),a=s.dict=new vh(o);a.set("Subtype",xh.get("Form")),a.set("Resources",i),a.set("BBox",[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]]);const r=this.getRotationMatrix(A);r!==yc&&a.set("Matrix",r),await hf(t,s,I,o),d.push({ref:t,data:I.join(""),xfa:null,needAppearances:!1}),I.length=0}return c.set("M",`D:${ph()}`),await hf(this.ref,c,I,o),d[0].data=I.join(""),d}async _getAppearance(t,e,A,i){if(this.hasFieldFlag(Fc))return null;const s=i?.get(this.data.id);let a,n;if(s&&(a=s.formattedValue||s.value,n=s.rotation),void 0===n&&void 0===a&&!this._needAppearances&&(!this._hasValueFromXFA||this.appearance))return null;const r=this.getBorderAndBackgroundAppearances(i);if(void 0===a&&(a=this.data.fieldValue,!a))return`/Tx BMC q ${r}Q EMC`;if(Array.isArray(a)&&1===a.length&&(a=a[0]),zc("string"==typeof a,"Expected `value` to be a string."),a=a.trim(),this.data.combo){const t=this.data.options.find((({exportValue:t})=>a===t));a=t?.displayValue||a}if(""===a)return`/Tx BMC q ${r}Q EMC`;void 0===n&&(n=this.rotation);let o,g=-1;this.data.multiLine?(o=a.split(/\r\n?|\n/).map((t=>t.normalize("NFC"))),g=o.length):o=[a.replace(/\r\n?|\n/,"").normalize("NFC")];let c=this.data.rect[3]-this.data.rect[1],h=this.data.rect[2]-this.data.rect[0];90!==n&&270!==n||([h,c]=[c,h]),this._defaultAppearance||(this.data.defaultAppearanceData=GE(this._defaultAppearance="/Helvetica 0 Tf 0 g"));let l,I,d,u=await sF._getFontData(t,e,this.data.defaultAppearanceData,this._fieldResources.mergedResources);const C=[];let B=!1;for(const t of o){const e=u.encodeString(t);e.length>1&&(B=!0),C.push(e.join(""))}if(B&&8&A)return{needAppearances:!0};if(B&&this._isOffscreenCanvasSupported){const A=this.data.comb?"monospace":"sans-serif",i=new HE(t.xref,A),s=i.createFontResources(o.join("")),n=s.getRaw("Font");if(this._fieldResources.mergedResources.has("Font")){const t=this._fieldResources.mergedResources.get("Font");for(const e of n.getKeys())t.set(e,n.getRaw(e))}else this._fieldResources.mergedResources.set("Font",n);const r=i.fontName.name;u=await sF._getFontData(t,e,{fontName:r,fontSize:0},s);for(let t=0,e=C.length;t2?`/Tx BMC q ${r}BT `+l+` 1 0 0 1 ${Bl(2)} ${Bl(p)} Tm (${ol(C[0])}) Tj ET Q EMC`:`/Tx BMC q ${r}BT `+l+` 1 0 0 1 0 0 Tm ${this._renderText(C[0],u,I,h,f,{shift:0},2,p)} ET Q EMC`}static async _getFontData(t,e,A,i){const s=new EE,a={font:null,clone(){return this}},{fontName:n,fontSize:r}=A;return await t.handleSetFont(i,[n&&xh.get(n),r],null,s,e,a,null),a.font}_getTextWidth(t,e){return e.charsToGlyphs(t).reduce(((t,e)=>t+e.width),0)/1e3}_computeFontSize(t,e,A,i,s){let{fontSize:a}=this.data.defaultAppearanceData,n=(a||12)*wc,r=Math.round(t/n);if(!a){const o=t=>Math.floor(100*t)/100;if(-1===s){const s=this._getTextWidth(A,i);a=o(Math.min(t/wc,s>e?e/s:1/0)),r=1}else{const g=A.split(/\r\n?|\n/),c=[];for(const t of g){const e=i.encodeString(t).join(""),A=i.charsToGlyphs(e),s=i.getCharPositions(e);c.push({line:e,glyphs:A,positions:s})}const h=A=>{let s=0;for(const a of c)if(s+=this._splitLine(null,i,A,e,a).length*A,s>t)return!0;return!1};for(r=Math.max(r,s);n=t/r,a=o(n/wc),h(a);)r++}const{fontName:g,fontColor:c}=this.data.defaultAppearanceData;this._defaultAppearance=function({fontSize:t,fontName:e,fontColor:A}){return`/${rl(e)} ${t} Tf ${UE(A,!0)}`}({fontSize:a,fontName:g,fontColor:c})}return[this._defaultAppearance,a,t/r]}_renderText(t,e,A,i,s,a,n,r){let o;o=1===s?(i-this._getTextWidth(t,e)*A)/2:2===s?i-this._getTextWidth(t,e)*A-n:n;const g=Bl(o-a.shift);return a.shift=o,`${g} ${r=Bl(r)} Td (${ol(t)}) Tj`}_getSaveFieldResources(t){const{localResources:e,appearanceResources:A,acroFormResources:i}=this._fieldResources,s=this.data.defaultAppearanceData?.fontName;if(!s)return e||vh.empty;for(const t of[e,A])if(t instanceof vh){const e=t.get("Font");if(e instanceof vh&&e.has(s))return t}if(i instanceof vh){const A=i.get("Font");if(A instanceof vh&&A.has(s)){const i=new vh(t);i.set(s,A.getRaw(s));const a=new vh(t);return a.set("Font",i),vh.merge({xref:t,dictArray:[a,e],mergeSubDicts:!0})}}return e||vh.empty}getFieldObject(){return null}}class aF extends sF{constructor(t){super(t);const{dict:e}=t;e.has("PMD")&&(this.flags|=2,this.data.hidden=!0,Zc("Barcodes are not supported")),this.data.hasOwnCanvas=this.data.readOnly&&!this.data.noHTML,this._hasText=!0,"string"!=typeof this.data.fieldValue&&(this.data.fieldValue="");let A=jh({dict:e,key:"Q"});(!Number.isInteger(A)||A<0||A>2)&&(A=null),this.data.textAlignment=A;let i=jh({dict:e,key:"MaxLen"});(!Number.isInteger(i)||i<0)&&(i=0),this.data.maxLen=i,this.data.multiLine=this.hasFieldFlag(4096),this.data.comb=this.hasFieldFlag(16777216)&&!this.hasFieldFlag(4096)&&!this.hasFieldFlag(Fc)&&!this.hasFieldFlag(1048576)&&0!==this.data.maxLen,this.data.doNotScroll=this.hasFieldFlag(8388608)}get hasTextContent(){return!!this.appearance&&!this._needAppearances}_getCombAppearance(t,e,A,i,s,a,n,r,o,g,c){const h=s/this.data.maxLen,l=this.getBorderAndBackgroundAppearances(c),I=[],d=e.getCharPositions(A);for(const[t,e]of d)I.push(`(${ol(A.substring(t,e))}) Tj`);const u=I.join(` ${Bl(h)} 0 Td `);return`/Tx BMC q ${l}BT `+t+` 1 0 0 1 ${Bl(n)} ${Bl(r+o)} Tm ${u} ET Q EMC`}_getMultilineAppearance(t,e,A,i,s,a,n,r,o,g,c,h){const l=[],I=s-2*r,d={shift:0};for(let t=0,a=e.length;ti?(o.push(t.substring(l,A)),l=A,I=u,g=-1,h=-1):(I+=u,g=A,c=s,h=e):I+u>i?-1!==g?(o.push(t.substring(l,c)),l=c,e=h+1,g=-1,I=0):(o.push(t.substring(l,A)),l=A,I=u):I+=u}return l"Off"!==t));a.length=0,a.push("Off",t)}a.includes(this.data.fieldValue)||(this.data.fieldValue="Off"),this.data.exportValue=a[1];const n=A.get(this.data.exportValue);this.checkedAppearance=n instanceof _h?n:null;const r=A.get("Off");this.uncheckedAppearance=r instanceof _h?r:null,this.checkedAppearance?this._streams.push(this.checkedAppearance):this._getDefaultCheckedAppearance(t,"check"),this.uncheckedAppearance&&this._streams.push(this.uncheckedAppearance),this._fallbackFontDict=this.fallbackFontDict,null===this.data.defaultFieldValue&&(this.data.defaultFieldValue="Off")}_processRadioButton(t){this.data.buttonValue=null;const e=t.dict.get("Parent");if(e instanceof vh){this.parent=t.dict.getRaw("Parent");const A=e.get("V");A instanceof xh&&(this.data.fieldValue=this._decodeFormValue(A))}const A=t.dict.get("AP");if(!(A instanceof vh))return;const i=A.get("N");if(!(i instanceof vh))return;for(const t of i.getKeys())if("Off"!==t){this.data.buttonValue=this._decodeFormValue(t);break}const s=i.get(this.data.buttonValue);this.checkedAppearance=s instanceof _h?s:null;const a=i.get("Off");this.uncheckedAppearance=a instanceof _h?a:null,this.checkedAppearance?this._streams.push(this.checkedAppearance):this._getDefaultCheckedAppearance(t,"disc"),this.uncheckedAppearance&&this._streams.push(this.uncheckedAppearance),this._fallbackFontDict=this.fallbackFontDict,null===this.data.defaultFieldValue&&(this.data.defaultFieldValue="Off")}_processPushButton(t){const{dict:e,annotationGlobals:A}=t;e.has("A")||e.has("AA")||this.data.alternativeText?(this.data.isTooltipOnly=!e.has("A")&&!e.has("AA"),kf.parseDestDictionary({destDict:e,resultObj:this.data,docBaseUrl:A.baseUrl,docAttachments:A.attachments})):Zc("Push buttons without action dictionaries are not supported")}getFieldObject(){let t,e="button";return this.data.checkBox?(e="checkbox",t=this.data.exportValue):this.data.radioButton&&(e="radiobutton",t=this.data.buttonValue),{id:this.data.id,value:this.data.fieldValue||"Off",defaultValue:this.data.defaultFieldValue,exportValues:t,editable:!this.data.readOnly,name:this.data.fieldName,rect:this.data.rect,hidden:this.data.hidden,actions:this.data.actions,page:this.data.pageIndex,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,rotation:this.rotation,type:e}}get fallbackFontDict(){const t=new vh;return t.set("BaseFont",xh.get("ZapfDingbats")),t.set("Type",xh.get("FallbackType")),t.set("Subtype",xh.get("FallbackType")),t.set("Encoding",xh.get("ZapfDingbatsEncoding")),th(this,"fallbackFontDict",t)}}class rF extends sF{constructor(t){super(t);const{dict:e,xref:A}=t;this.indices=e.getArray("I"),this.hasIndices=Array.isArray(this.indices)&&this.indices.length>0,this.data.options=[];const i=jh({dict:e,key:"Opt"});if(Array.isArray(i))for(let t=0,e=i.length;t=0&&e0?this.data.fieldValue[0]:null;return{id:this.data.id,value:e,defaultValue:this.data.defaultFieldValue,editable:!this.data.readOnly,name:this.data.fieldName,rect:this.data.rect,numItems:this.data.fieldValue.length,multipleSelection:this.data.multiSelect,hidden:this.data.hidden,actions:this.data.actions,items:this.data.options,page:this.data.pageIndex,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,rotation:this.rotation,type:t}}amendSavedDict(t,e){if(!this.hasIndices)return;let A=t?.get(this.data.id)?.value;Array.isArray(A)||(A=[A]);const i=[],{options:s}=this.data;for(let t=0,e=0,a=s.length;tA&&(A=i,e=t)}[l,I]=this._computeFontSize(t,o-4,e,h,-1)}const d=I*wc,u=(d-I)/2,C=Math.floor(r/d);let B=0;if(c.length>0){const t=Math.min(...c),e=Math.max(...c);B=Math.max(0,e-C+1),B>t&&(B=t)}const Q=Math.min(B+C+1,g),E=["/Tx BMC q",`1 1 ${o} ${r} re W n`];if(c.length){E.push("0.600006 0.756866 0.854904 rg");for(const t of c)B<=t&&tt.trimEnd()));const{coords:t,bbox:e,matrix:A}=HE.getFirstPositionInfo(this.rectangle,this.rotation,i);this.data.textPosition=this._transformPoint(t,e,A)}if(this._isOffscreenCanvasSupported){const s=t.dict.get("CA"),a=new HE(A,"sans-serif");this.appearance=a.createAppearance(this._contents.str,this.rectangle,this.rotation,i,e,s),this._streams.push(this.appearance)}else Zc("FreeTextAnnotation: OffscreenCanvas is not supported, annotation may not render correctly.")}}get hasTextContent(){return this._hasAppearance}static createNewDict(t,e,{apRef:A,ap:i,oldAnnotation:s}){const{color:a,fontSize:n,rect:r,rotation:o,user:g,value:c}=t,h=s||new vh(e);h.set("Type",xh.get("Annot")),h.set("Subtype",xh.get("FreeText")),s?(h.set("M",`D:${ph()}`),h.delete("RC")):h.set("CreationDate",`D:${ph()}`),h.set("Rect",r);const l=`/Helv ${n} Tf ${UE(a,!0)}`;if(h.set("DA",l),h.set("Contents",El(c)),h.set("F",4),h.set("Border",[0,0,0]),h.set("Rotate",o),g&&h.set("T",El(g)),A||i){const t=new vh(e);h.set("AP",t),A?t.set("N",A):t.set("N",i)}return h}static async createNewAppearanceStream(t,e,A){const{baseFontRef:i,evaluator:s,task:a}=A,{color:n,fontSize:r,rect:o,rotation:g,value:c}=t,h=new vh(e),l=new vh(e);if(i)l.set("Helv",i);else{const t=new vh(e);t.set("BaseFont",xh.get("Helvetica")),t.set("Type",xh.get("Font")),t.set("Subtype",xh.get("Type1")),t.set("Encoding",xh.get("WinAnsiEncoding")),l.set("Helv",t)}h.set("Font",l);const I=await sF._getFontData(s,a,{fontName:"Helv",fontSize:r},h),[d,u,C,B]=o;let Q=C-d,E=B-u;g%180!=0&&([Q,E]=[E,Q]);const f=c.split("\n"),p=r/1e3;let m=-1/0;const y=[];for(let t of f){const e=I.encodeString(t);if(e.length>1)return null;t=e.join(""),y.push(t);let A=0;const i=I.charsToGlyphs(t);for(const t of i)A+=t.width*p;m=Math.max(m,A)}let b=1;m>Q&&(b=Q/m);let w=1;const D=wc*r,k=1*r,S=D*f.length;S>E&&(w=E/S);const x=r*Math.min(b,w);let F,R,v;switch(g){case 0:v=[1,0,0,1],R=[o[0],o[1],Q,E],F=[o[0],o[3]-k];break;case 90:v=[0,1,-1,0],R=[o[1],-o[2],Q,E],F=[o[1],-o[0]-k];break;case 180:v=[-1,0,0,-1],R=[-o[2],-o[3],Q,E],F=[-o[2],-o[1]-k];break;case 270:v=[0,-1,1,0],R=[-o[3],o[0],Q,E],F=[-o[3],o[2]-k]}const N=["q",`${v.join(" ")} 0 0 cm`,`${R.join(" ")} re W n`,"BT",`${UE(n,!0)}`,`0 Tc /Helv ${Bl(x)} Tf`];N.push(`${F.join(" ")} Td (${ol(y[0])}) Tj`);const M=Bl(D);for(let t=1,e=y.length;t(t.push(`${i[0]} ${i[1]} m`,`${i[2]} ${i[3]} l`,"S"),[e[0]-o,e[2]+o,e[7]-o,e[3]+o])})}}}class dF extends iF{constructor(t){super(t);const{dict:e,xref:A}=t;if(this.data.annotationType=5,this.data.hasOwnCanvas=this.data.noRotate,this.data.noHTML=!1,!this.appearance){const t=this.color?zx(this.color):[0,0,0],i=e.get("CA"),s=Xx(e.getArray("IC"),null),a=s?zx(s):null,n=a?i:null;if(0===this.borderStyle.width&&!a)return;this._setDefaultAppearance({xref:A,extra:`${this.borderStyle.width} w`,strokeColor:t,fillColor:a,strokeAlpha:i,fillAlpha:n,pointsCallback:(t,e)=>{const A=e[4]+this.borderStyle.width/2,i=e[5]+this.borderStyle.width/2,s=e[6]-e[4]-this.borderStyle.width,n=e[3]-e[7]-this.borderStyle.width;return t.push(`${A} ${i} ${s} ${n} re`),a?t.push("B"):t.push("S"),[e[0],e[2],e[7],e[3]]}})}}}class uF extends iF{constructor(t){super(t);const{dict:e,xref:A}=t;if(this.data.annotationType=6,!this.appearance){const t=this.color?zx(this.color):[0,0,0],i=e.get("CA"),s=Xx(e.getArray("IC"),null),a=s?zx(s):null,n=a?i:null;if(0===this.borderStyle.width&&!a)return;const r=4/3*Math.tan(Math.PI/8);this._setDefaultAppearance({xref:A,extra:`${this.borderStyle.width} w`,strokeColor:t,fillColor:a,strokeAlpha:i,fillAlpha:n,pointsCallback:(t,e)=>{const A=e[0]+this.borderStyle.width/2,i=e[1]-this.borderStyle.width/2,s=e[6]-this.borderStyle.width/2,n=e[7]+this.borderStyle.width/2,o=A+(s-A)/2,g=i+(n-i)/2,c=(s-A)/2*r,h=(n-i)/2*r;return t.push(`${o} ${n} m`,`${o+c} ${n} ${s} ${g+h} ${s} ${g} c`,`${s} ${g-h} ${o+c} ${i} ${o} ${i} c`,`${o-c} ${i} ${A} ${g-h} ${A} ${g} c`,`${A} ${g+h} ${o-c} ${n} ${o} ${n} c`,"h"),a?t.push("B"):t.push("S"),[e[0],e[2],e[7],e[3]]}})}}}class CF extends iF{constructor(t){super(t);const{dict:e,xref:A}=t;this.data.annotationType=8,this.data.hasOwnCanvas=this.data.noRotate,this.data.noHTML=!1,this.data.vertices=null,this instanceof BF||(this.setLineEndings(e.getArray("LE")),this.data.lineEndings=this.lineEndings);const i=e.getArray("Vertices");if(!Al(i,null))return;const s=this.data.vertices=Float32Array.from(i);if(!this.appearance){const t=this.color?zx(this.color):[0,0,0],i=e.get("CA"),a=this.borderStyle.width||1,n=2*a,r=[1/0,1/0,-1/0,-1/0];for(let t=0,e=s.length;t{for(let e=0,A=s.length;e{for(const e of this.data.inkLists){for(let A=0,i=e.length;At.points))),h.set("F",4),h.set("Rotate",g),r&&h.set("IT",xh.get("InkHighlight"));const l=new vh(e);h.set("BS",l),l.set("W",c),h.set("C",Array.from(s,(t=>t/255))),h.set("CA",a);const I=new vh(e);return h.set("AP",I),A?I.set("N",A):I.set("N",i),h}static async createNewAppearanceStream(t,e,A){if(t.outlines)return this.createNewAppearanceStreamForHighlight(t,e,A);const{color:i,rect:s,paths:a,thickness:n,opacity:r}=t,o=[`${n} w 1 J 1 j`,`${UE(i,!1)}`];1!==r&&o.push("/R0 gs");const g=[];for(const{bezier:t}of a){if(g.length=0,g.push(`${Bl(t[0])} ${Bl(t[1])} m`),2===t.length)g.push(`${Bl(t[0])} ${Bl(t[1])} l S`);else{for(let e=2,A=t.length;e(t.push(`${e[0]} ${e[1]} m`,`${e[2]} ${e[3]} l`,`${e[6]} ${e[7]} l`,`${e[4]} ${e[5]} l`,"f"),[e[0],e[2],e[7],e[3]])})}}else this.data.popupRef=null}static createNewDict(t,e,{apRef:A,ap:i}){const{color:s,opacity:a,rect:n,rotation:r,user:o,quadPoints:g}=t,c=new vh(e);if(c.set("Type",xh.get("Annot")),c.set("Subtype",xh.get("Highlight")),c.set("CreationDate",`D:${ph()}`),c.set("Rect",n),c.set("F",4),c.set("Border",[0,0,0]),c.set("Rotate",r),c.set("QuadPoints",g),c.set("C",Array.from(s,(t=>t/255))),c.set("CA",a),o&&c.set("T",El(o)),A||i){const t=new vh(e);c.set("AP",t),t.set("N",A||i)}return c}static async createNewAppearanceStream(t,e,A){const{color:i,rect:s,outlines:a,opacity:n}=t,r=[`${UE(i,!0)}`,"/R0 gs"],o=[];for(const t of a){o.length=0,o.push(`${Bl(t[0])} ${Bl(t[1])} m`);for(let e=2,A=t.length;e(t.push(`${e[4]} ${e[5]+1.3} m`,`${e[6]} ${e[7]+1.3} l`,"S"),[e[0],e[2],e[7],e[3]])})}}else this.data.popupRef=null}}class mF extends iF{constructor(t){super(t);const{dict:e,xref:A}=t;if(this.data.annotationType=11,this.data.quadPoints=$x(e,null)){if(!this.appearance){const t=this.color?zx(this.color):[0,0,0],i=e.get("CA");this._setDefaultAppearance({xref:A,extra:"[] 0 d 1 w",strokeColor:t,strokeAlpha:i,pointsCallback:(t,e)=>{const A=(e[1]-e[5])/6;let i=A,s=e[4];const a=e[5],n=e[6];t.push(`${s} ${a+i} m`);do{s+=2,i=0===i?A:0,t.push(`${s} ${a+i} l`)}while(s(t.push((e[0]+e[4])/2+" "+(e[1]+e[5])/2+" m",(e[2]+e[6])/2+" "+(e[3]+e[7])/2+" l","S"),[e[0],e[2],e[7],e[3]])})}}else this.data.popupRef=null}}class bF extends iF{constructor(t){super(t),this.data.annotationType=13,this.data.hasOwnCanvas=this.data.noRotate,this.data.noHTML=!1}static async createImage(t,e){const{width:A,height:i}=t,s=new OffscreenCanvas(A,i),a=s.getContext("2d",{alpha:!0});a.drawImage(t,0,0);const n=a.getImageData(0,0,A,i).data,r=new Uint32Array(n.buffer),o=r.some(Ih.isLittleEndian?t=>t>>>24!=255:t=>!!(255&~t));o&&(a.fillStyle="white",a.fillRect(0,0,A,i),a.drawImage(t,0,0));const g=s.convertToBlob({type:"image/jpeg",quality:1}).then((t=>t.arrayBuffer())),c=xh.get("XObject"),h=xh.get("Image"),l=new vh(e);l.set("Type",c),l.set("Subtype",h),l.set("BitsPerComponent",8),l.set("ColorSpace",xh.get("DeviceRGB")),l.set("Filter",xh.get("DCTDecode")),l.set("BBox",[0,0,A,i]),l.set("Width",A),l.set("Height",i);let I=null;if(o){const t=new Uint8Array(r.length);if(Ih.isLittleEndian)for(let e=0,A=r.length;e>>24;else for(let e=0,A=r.length;e=0&&a<=1?a:null}}function DF(t){try{return Qh(t)}catch(e){return Zc(`UTF-8 decoding failed: "${e}".`),t}}class kF extends jE{constructor(t){super(t),this.node=null}onEndElement(t){const e=super.onEndElement(t);if(e&&"xfa:datasets"===t)throw this.node=e,new Error("Aborting DatasetXMLParser.")}}class SF{constructor(t){if(t.datasets)this.node=new jE({hasAttributes:!0}).parseFromString(t.datasets).documentElement;else{const e=new kF({hasAttributes:!0});try{e.parseFromString(t["xdp:xdp"])}catch{}this.node=e.node}}getValue(t){if(!this.node||!t)return"";const e=this.node.searchNode(nl(t),0);if(!e)return"";const A=e.firstChild;return"value"===A?.nodeName?e.children.map((t=>DF(t.textContent))):DF(e.textContent)}}class xF{#qr=null;constructor(t,e){this.stream=t,this.pdfManager=e,this.entries=[],this._xrefStms=new Set,this._cacheMap=new Map,this._pendingRefs=new Mh,this._newPersistentRefNum=null,this._newTemporaryRefNum=null,this._persistentRefsCache=null}getNewPersistentRef(t){null===this._newPersistentRefNum&&(this._newPersistentRefNum=this.entries.length||1);const e=this._newPersistentRefNum++;return this._cacheMap.set(e,t),Nh.get(e,0)}getNewTemporaryRef(){if(null===this._newTemporaryRefNum&&(this._newTemporaryRefNum=this.entries.length||1,this._newPersistentRefNum)){this._persistentRefsCache=new Map;for(let t=this._newTemporaryRefNum;t0;){const[n,r]=a;if(!Number.isInteger(n)||!Number.isInteger(r))throw new rh(`Invalid XRef range fields: ${n}, ${r}`);if(!Number.isInteger(A)||!Number.isInteger(i)||!Number.isInteger(s))throw new rh(`Invalid XRef entry fields length: ${n}, ${r}`);for(let a=e.entryNum;a=t.length);)A+=String.fromCharCode(i),i=t[e];return A}function e(t,e,A){const i=A.length,s=t.length;let a=0;for(;e=i)break;e++,a++}return a}const A=/\b(endobj|\d+\s+\d+\s+obj|xref|trailer\s*<<)\b/g,i=/\b(startxref|\d+\s+\d+\s+obj)\b/g,s=/^(\d+)\s+(\d+)\s+obj\b/,a=new Uint8Array([116,114,97,105,108,101,114]),n=new Uint8Array([115,116,97,114,116,120,114,101,102]),r=new Uint8Array([47,88,82,101,102]);this.entries.length=0,this._cacheMap.clear();const o=this.stream;o.pos=0;const g=o.getBytes(),c=gh(g),h=g.length;let l=o.start;const I=[],d=[];for(;l=h)break;u=g[l]}while(10!==u&&13!==u);continue}const C=t(g,l);let B;if(C.startsWith("xref")&&(4===C.length||/\s/.test(C[4])))l+=e(g,l,a),I.push(l),l+=e(g,l,n);else if(B=s.exec(C)){const t=0|B[1],i=0|B[2],s=l+C.length;let a,n=!1;if(this.entries[t]){if(this.entries[t].gen===i)try{new bd({lexer:new kd(o.makeSubStream(s))}).getObj(),n=!0}catch(A){A instanceof Kh?Zc(`indexObjects -- checking object (${C}): "${A}".`):n=!0}}else n=!0;n&&(this.entries[t]={offset:l-o.start,gen:i,uncompressed:!0}),A.lastIndex=s;const I=A.exec(c);I?(a=A.lastIndex+1-l,"endobj"!==I[1]&&(Zc(`indexObjects: Found "${I[1]}" inside of another "obj", caused by missing "endobj" -- trying to recover.`),a-=I[1].length+1)):a=h-l;const u=g.subarray(l,l+a),Q=e(u,0,r);Q0?Math.max(...this._xrefStms):null)}getEntry(t){const e=this.entries[t];return e&&!e.free&&e.offset?e:null}fetchIfRef(t,e=!1){return t instanceof Nh?this.fetch(t,e):t}fetch(t,e=!1){if(!(t instanceof Nh))throw new Error("ref object is not a reference");const A=t.num,i=this._cacheMap.get(A);if(void 0!==i)return i instanceof vh&&!i.objId&&(i.objId=t.toString()),i;let s=this.getEntry(A);if(null===s)return this._cacheMap.set(A,s),s;if(this._pendingRefs.has(t))return this._pendingRefs.remove(t),Zc(`Ignoring circular reference: ${t}.`),bh;this._pendingRefs.put(t);try{s=s.uncompressed?this.fetchUncompressed(t,s,e):this.fetchCompressed(t,s,e),this._pendingRefs.remove(t)}catch(e){throw this._pendingRefs.remove(t),e}return s instanceof vh?s.objId=t.toString():s instanceof _h&&(s.dict.objId=t.toString()),s}fetchUncompressed(t,e,A=!1){const i=t.gen;let s=t.num;if(e.gen!==i){const a=`Inconsistent generation in XRef: ${t}`;if(this._generationFallback&&e.gen0&&e[3]-e[1]>0)return e;Zc(`Empty, or invalid, /${t} entry.`)}return null}get mediaBox(){return th(this,"mediaBox",this._getBoundingBox("MediaBox")||FF)}get cropBox(){return th(this,"cropBox",this._getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let t=this.pageDict.get("UserUnit");return("number"!=typeof t||t<=0)&&(t=1),th(this,"userUnit",t)}get view(){const{cropBox:t,mediaBox:e}=this;if(t!==e&&!fh(t,e)){const A=uh.intersect(t,e);if(A&&A[2]-A[0]>0&&A[3]-A[1]>0)return th(this,"view",A);Zc("Empty /CropBox and /MediaBox intersection.")}return th(this,"view",e)}get rotate(){let t=this._getInheritableProperty("Rotate")||0;return t%90!=0?t=0:t>=360?t%=360:t<0&&(t=(t%360+360)%360),th(this,"rotate",t)}_onSubStreamError(t,e){if(!this.evaluatorOptions.ignoreErrors)throw t;Zc(`getContentStream - ignoring sub-stream (${e}): "${t}".`)}getContentStream(){return this.pdfManager.ensure(this,"content").then((t=>t instanceof _h?t:Array.isArray(t)?new Vl(t,this._onSubStreamError.bind(this)):new Dl))}get xfaData(){return th(this,"xfaData",this.xfaFactory?{bbox:this.xfaFactory.getBoundingBox(this.pageIndex)}:null)}#Or(t,e,A){for(const i of t)if(i.id){const t=Nh.fromString(i.id);if(!t){Zc(`A non-linked annotation cannot be modified: ${i.id}`);continue}if(i.deleted){e.put(t,t);continue}A?.put(t),i.ref=t,delete i.id}}async saveNewAnnotations(t,e,A,i){if(this.xfaFactory)throw new Error("XFA: Cannot save new annotations.");const s=new SE({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,systemFontCache:this.systemFontCache,options:this.evaluatorOptions}),a=new Gh,n=new Mh;this.#Or(A,a,n);const r=this.pageDict,o=this.annotations.filter((t=>!(t instanceof Nh&&a.has(t)))),g=await Zx.saveNewAnnotations(s,e,A,i);for(const{ref:t}of g.annotations)t instanceof Nh&&!n.has(t)&&o.push(t);const c=r.get("Annots");r.set("Annots",o);const h=[];await hf(this.ref,r,h,this.xref),c&&r.set("Annots",c);const l=g.dependencies;l.push({ref:this.ref,data:h.join("")},...g.annotations);for(const t of a)l.push({ref:t,data:null});return l}save(t,e,A){const i=new SE({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,systemFontCache:this.systemFontCache,options:this.evaluatorOptions});return this._parsedAnnotations.then((function(t){const s=[];for(const a of t)a.mustBePrinted(A)&&s.push(a.save(i,e,A).catch((function(t){return Zc(`save - ignoring annotation data during "${e.name}" task: "${t}".`),null})));return Promise.all(s).then((function(t){return t.filter((t=>!!t))}))}))}loadResources(t){return this.resourcesPromise||=this.pdfManager.ensure(this,"resources"),this.resourcesPromise.then((()=>new xf(this.resources,t,this.xref).load()))}getOperatorList({handler:t,sink:e,task:A,intent:i,cacheKey:s,annotationStorage:a=null,modifiedIds:n=null}){const r=this.getContentStream(),o=this.loadResources(["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"]),g=new SE({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,systemFontCache:this.systemFontCache,options:this.evaluatorOptions}),c=this.xfaFactory?null:Ql(a),h=c?.get(this.pageIndex);let l=Promise.resolve(null),I=null;if(h){const t=this.pdfManager.ensureDoc("annotationGlobals");let e;const i=new Set;for(const{bitmapId:t,bitmap:e}of h)!t||e||i.has(t)||i.add(t);const{isOffscreenCanvasSupported:s}=this.evaluatorOptions;if(i.size>0){const t=h.slice();for(const[e,A]of a)e.startsWith(kc)&&A.bitmap&&i.has(A.bitmapId)&&t.push(A);e=Zx.generateImages(t,this.xref,s)}else e=Zx.generateImages(h,this.xref,s);I=new Mh,this.#Or(h,I,null),l=t.then((t=>t?Zx.printNewAnnotations(t,g,A,h,e):null))}const d=Promise.all([r,o]).then((([a])=>{const n=new EE(i,e);return t.send("StartRenderPage",{transparency:g.hasBlendModes(this.resources,this.nonBlendModesSet),pageIndex:this.pageIndex,cacheKey:s}),g.getOperatorList({stream:a,task:A,resources:this.resources,operatorList:n}).then((function(){return n}))}));return Promise.all([d,this._parsedAnnotations,l]).then((function([t,e,s]){if(s){e=e.filter((t=>!(t.ref&&I.has(t.ref))));for(let t=0,A=s.length;tt.ref&&Jh(t.ref,i.refToReplace)));a>=0&&(e.splice(a,1,i),s.splice(t--,1),A--)}}e=e.concat(s)}if(0===e.length||64&i)return t.flush(!0),{length:t.totalLength};const r=!!(16&i),o=!!(128&i),c=!!(1&i),h=!!(2&i),l=!!(4&i),d=[];for(const t of e)(c||h&&t.mustBeViewed(a,r)&&t.mustBeViewedWhenEditing(o,n)||l&&t.mustBePrinted(a))&&d.push(t.getOperatorList(g,A,i,a).catch((function(t){return Zc(`getOperatorList - ignoring annotation data during "${A.name}" task: "${t}".`),{opList:null,separateForm:!1,separateCanvas:!1}})));return Promise.all(d).then((function(e){let A=!1,i=!1;for(const{opList:s,separateForm:a,separateCanvas:n}of e)t.addOpList(s),A||=a,i||=n;return t.flush(!0,{form:A,canvas:i}),{length:t.totalLength}}))}))}async extractTextContent({handler:t,task:e,includeMarkedContent:A,disableNormalization:i,sink:s}){const a=this.getContentStream(),n=this.loadResources(["ExtGState","Font","Properties","XObject"]),r=this.pdfManager.ensureCatalog("lang"),[o,,g]=await Promise.all([a,n,r]);return new SE({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,systemFontCache:this.systemFontCache,options:this.evaluatorOptions}).getTextContent({stream:o,task:e,resources:this.resources,includeMarkedContent:A,disableNormalization:i,sink:s,viewBox:this.view,lang:g})}async getStructTree(){const t=await this.pdfManager.ensureCatalog("structTreeRoot");return t?(await this._parsedAnnotations,(await this.pdfManager.ensure(this,"_parseStructTree",[t])).serializable):null}_parseStructTree(t){const e=new yf(t,this.pageDict);return e.parse(this.ref),e}async getAnnotationsData(t,e,A){const i=await this._parsedAnnotations;if(0===i.length)return i;const s=[],a=[];let n;const r=!!(1&A),o=!!(2&A),g=!!(4&A);for(const A of i){const i=r||o&&A.viewable;(i||g&&A.printable)&&s.push(A.data),A.hasTextContent&&i&&(n||=new SE({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,systemFontCache:this.systemFontCache,options:this.evaluatorOptions}),a.push(A.extractTextContent(n,e,[-1/0,-1/0,1/0,1/0]).catch((function(t){Zc(`getAnnotationsData - ignoring textContent during "${e.name}" task: "${t}".`)}))))}return await Promise.all(a),s}get annotations(){const t=this._getInheritableProperty("Annots");return th(this,"annotations",Array.isArray(t)?t:[])}get _parsedAnnotations(){return th(this,"_parsedAnnotations",this.pdfManager.ensure(this,"annotations").then((async t=>{if(0===t.length)return t;const e=await this.pdfManager.ensureDoc("annotationGlobals");if(!e)return[];const A=[];for(const i of t)A.push(Zx.create(this.xref,i,e,this._localIdFactory,!1,this.ref).catch((function(t){return Zc(`_parsedAnnotations: "${t}".`),null})));const i=[];let s,a;for(const t of await Promise.all(A))t&&(t instanceof sF?(a||=[]).push(t):t instanceof hF?(s||=[]).push(t):i.push(t));return a&&i.push(...a),s&&i.push(...s),i})))}get jsActions(){return th(this,"jsActions",cl(this.xref,this.pageDict,Mc))}}const vF=new Uint8Array([37,80,68,70,45]),NF=new Uint8Array([115,116,97,114,116,120,114,101,102]),MF=new Uint8Array([101,110,100,111,98,106]);function GF(t,e,A=1024,i=!1){const s=e.length,a=t.peekBytes(A),n=a.length-s;if(n<=0)return!1;if(i){const A=s-1;let i=a.length-1;for(;i>=A;){let n=0;for(;n=s)return t.pos+=i-A,!0;i--}}else{let A=0;for(;A<=n;){let i=0;for(;i=s)return t.pos+=A,!0;A++}}return!1}class LF{constructor(t,e){if(e.length<=0)throw new sh("The PDF file is empty, i.e. its size is zero bytes.");this.pdfManager=t,this.stream=e,this.xref=new xF(e,t),this._pagePromises=new Map,this._version=null;const A={font:0};this._globalIdFactory=class{static getDocId(){return`g_${t.docId}`}static createFontId(){return"f"+ ++A.font}static createObjId(){Xc("Abstract method `createObjId` called.")}static getPageObjId(){Xc("Abstract method `getPageObjId` called.")}}}parse(t){this.xref.parse(t),this.catalog=new kf(this.pdfManager,this.xref)}get linearization(){let t=null;try{t=Sd.create(this.stream)}catch(t){if(t instanceof Ph)throw t;Vc(t)}return th(this,"linearization",t)}get startXRef(){const t=this.stream;let e=0;if(this.linearization){if(t.reset(),GF(t,MF)){t.skip(6);let A=t.peekByte();for(;el(A);)t.pos++,A=t.peekByte();e=t.pos-t.start}}else{const A=1024,i=NF.length;let s=!1,a=t.end;for(;!s&&a>0;)a-=A-i,a<0&&(a=0),t.pos=a,s=GF(t,NF,A,!0);if(s){let A;t.skip(9);do{A=t.getByte()}while(el(A));let i="";for(;A>=32&&A<=57;)i+=String.fromCharCode(A),A=t.getByte();e=parseInt(i,10),isNaN(e)&&(e=0)}}return th(this,"startXRef",e)}checkHeader(){const t=this.stream;if(t.reset(),!GF(t,vF))return;t.moveStart(),t.skip(vF.length);let e,A="";for(;(e=t.getByte())>32&&A.length<7;)A+=String.fromCharCode(e);Yh.test(A)?this._version=A:Zc(`Invalid PDF header version: ${A}`)}parseStartXRef(){this.xref.setStartXRef(this.startXRef)}get numPages(){let t=0;return t=this.catalog.hasActualNumPages?this.catalog.numPages:this.xfaFactory?this.xfaFactory.getNumPages():this.linearization?this.linearization.numPages:this.catalog.numPages,th(this,"numPages",t)}_hasOnlyDocumentSignatures(t,e=0){return!!Array.isArray(t)&&t.every((t=>{if(!((t=this.xref.fetchIfRef(t))instanceof vh))return!1;if(t.has("Kids"))return++e>10?(Zc("_hasOnlyDocumentSignatures: maximum recursion depth reached"),!1):this._hasOnlyDocumentSignatures(t.get("Kids"),e);const A=Lh(t.get("FT"),"Sig"),i=t.get("Rect"),s=Array.isArray(i)&&i.every((t=>0===t));return A&&s}))}get _xfaStreams(){const t=this.catalog.acroForm;if(!t)return null;const e=t.get("XFA"),A={"xdp:xdp":"",template:"",datasets:"",config:"",connectionSet:"",localeSet:"",stylesheet:"","/xdp:xdp":""};if(e instanceof _h&&!e.isEmpty)return A["xdp:xdp"]=e,A;if(!Array.isArray(e)||0===e.length)return null;for(let t=0,i=e.length;t{h.set(t,e)}));const l=[];for(const[t,A]of h){const s=A.get("FontDescriptor");if(!(s instanceof vh))continue;let a=s.get("FontFamily");a=a.replaceAll(/[ ]+(\d)/g,"$1");const n={fontFamily:a,fontWeight:s.get("FontWeight"),italicAngle:-s.get("ItalicAngle")};ul(n)&&l.push(r.handleSetFont(i,[xh.get(t),1],null,o,e,c,null,n).catch((function(t){return Zc(`loadXfaFonts: "${t}".`),null})))}await Promise.all(l);const I=this.xfaFactory.setFonts(g);if(!I)return;n.ignoreErrors=!0,l.length=0,g.length=0;const d=new Set;for(const t of I)hQ(`${t}-Regular`)||d.add(t);d.size&&I.push("PdfJS-Fallback");for(const t of I)if(!d.has(t))for(const A of[{name:"Regular",fontWeight:400,italicAngle:0},{name:"Bold",fontWeight:700,italicAngle:0},{name:"Italic",fontWeight:400,italicAngle:12},{name:"BoldItalic",fontWeight:700,italicAngle:12}]){const s=`${t}-${A.name}`,a=lQ(s);l.push(r.handleSetFont(i,[xh.get(s),1],null,o,e,c,a,{fontFamily:t,fontWeight:A.fontWeight,italicAngle:A.italicAngle}).catch((function(t){return Zc(`loadXfaFonts: "${t}".`),null})))}await Promise.all(l),this.xfaFactory.appendFonts(g,d)}async serializeXfaData(t){return this.xfaFactory?this.xfaFactory.serializeData(t):null}get version(){return this.catalog.version||this._version}get formInfo(){const t={hasFields:!1,hasAcroForm:!1,hasXfa:!1,hasSignatures:!1},e=this.catalog.acroForm;if(!e)return th(this,"formInfo",t);try{const A=e.get("Fields"),i=Array.isArray(A)&&A.length>0;t.hasFields=i;const s=e.get("XFA");t.hasXfa=Array.isArray(s)&&s.length>0||s instanceof _h&&!s.isEmpty;const a=!!(1&e.get("SigFlags")),n=a&&this._hasOnlyDocumentSignatures(A);t.hasAcroForm=i&&!n,t.hasSignatures=a}catch(t){if(t instanceof Ph)throw t;Zc(`Cannot fetch form information: "${t}".`)}return th(this,"formInfo",t)}get documentInfo(){const t={PDFFormatVersion:this.version,Language:this.catalog.lang,EncryptFilterName:this.xref.encrypt?this.xref.encrypt.filterName:null,IsLinearized:!!this.linearization,IsAcroFormPresent:this.formInfo.hasAcroForm,IsXFAPresent:this.formInfo.hasXfa,IsCollectionPresent:!!this.catalog.collection,IsSignaturesPresent:this.formInfo.hasSignatures};let e;try{e=this.xref.trailer.get("Info")}catch(t){if(t instanceof Ph)throw t;Vc("The document information dictionary is invalid.")}if(!(e instanceof vh))return th(this,"documentInfo",t);for(const A of e.getKeys()){const i=e.get(A);switch(A){case"Title":case"Author":case"Subject":case"Keywords":case"Creator":case"Producer":case"CreationDate":case"ModDate":if("string"==typeof i){t[A]=Bh(i);continue}break;case"Trapped":if(i instanceof xh){t[A]=i;continue}break;default:let e;switch(typeof i){case"string":e=Bh(i);break;case"number":case"boolean":e=i;break;default:i instanceof xh&&(e=i)}if(void 0===e){Zc(`Bad value, for custom key "${A}", in Info: ${i}.`);continue}t.Custom||(t.Custom=Object.create(null)),t.Custom[A]=e;continue}Zc(`Bad value, for key "${A}", in Info: ${i}.`)}return th(this,"documentInfo",t)}get fingerprints(){function t(t){return"string"==typeof t&&t.length>0&&"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"!==t}function e(t){const e=[];for(const A of t){const t=A.toString(16);e.push(t.padStart(2,"0"))}return e.join("")}const A=this.xref.trailer.get("ID");let i,s;return Array.isArray(A)&&t(A[0])?(i=ch(A[0]),A[1]!==A[0]&&t(A[1])&&(s=ch(A[1]))):i=zE(this.stream.getByteRange(0,1024),0,1024),th(this,"fingerprints",[e(i),s?e(s):null])}async _getLinearizationPage(t){const{catalog:e,linearization:A,xref:i}=this,s=Nh.get(A.objectNumberFirst,0);try{const t=await i.fetchAsync(s);if(t instanceof vh){let A=t.getRaw("Type");if(A instanceof Nh&&(A=await i.fetchAsync(A)),Lh(A,"Page")||!t.has("Type")&&!t.has("Kids")&&t.has("Contents"))return e.pageKidsCountCache.has(s)||e.pageKidsCountCache.put(s,1),e.pageIndexCache.has(s)||e.pageIndexCache.put(s,0),[t,s]}throw new rh("The Linearization dictionary doesn't point to a valid Page dictionary.")}catch(A){return Zc(`_getLinearizationPage: "${A.message}".`),e.getPageDict(t)}}getPage(t){const e=this._pagePromises.get(t);if(e)return e;const{catalog:A,linearization:i,xfaFactory:s}=this;let a;return a=s?Promise.resolve([vh.empty,null]):i?.pageFirst===t?this._getLinearizationPage(t):A.getPageDict(t),a=a.then((([e,i])=>new RF({pdfManager:this.pdfManager,xref:this.xref,pageIndex:t,pageDict:e,ref:i,globalIdFactory:this._globalIdFactory,fontCache:A.fontCache,builtInCMapCache:A.builtInCMapCache,standardFontDataCache:A.standardFontDataCache,globalImageCache:A.globalImageCache,systemFontCache:A.systemFontCache,nonBlendModesSet:A.nonBlendModesSet,xfaFactory:s}))),this._pagePromises.set(t,a),a}async checkFirstPage(t=!1){if(!t)try{await this.getPage(0)}catch(t){if(t instanceof qh)throw this._pagePromises.delete(0),await this.cleanup(),new Oh}}async checkLastPage(t=!1){const{catalog:e,pdfManager:A}=this;let i;e.setActualNumPages();try{if(await Promise.all([A.ensureDoc("xfaFactory"),A.ensureDoc("linearization"),A.ensureCatalog("numPages")]),this.xfaFactory)return;if(i=this.linearization?this.linearization.numPages:e.numPages,!Number.isInteger(i))throw new rh("Page count is not an integer.");if(i<=1)return;await this.getPage(i-1)}catch(s){if(this._pagePromises.delete(i-1),await this.cleanup(),s instanceof qh&&!t)throw new Oh;let a;Zc(`checkLastPage - invalid /Pages tree /Count: ${i}.`);try{a=await e.getAllPageDicts(t)}catch(A){if(A instanceof qh&&!t)throw new Oh;return void e.setActualNumPages(1)}for(const[t,[i,s]]of a){let a;i instanceof Error?(a=Promise.reject(i),a.catch((()=>{}))):a=Promise.resolve(new RF({pdfManager:A,xref:this.xref,pageIndex:t,pageDict:i,ref:s,globalIdFactory:this._globalIdFactory,fontCache:e.fontCache,builtInCMapCache:e.builtInCMapCache,standardFontDataCache:e.standardFontDataCache,globalImageCache:e.globalImageCache,systemFontCache:e.systemFontCache,nonBlendModesSet:e.nonBlendModesSet,xfaFactory:null})),this._pagePromises.set(t,a)}e.setActualNumPages(a.size)}}fontFallback(t,e){return this.catalog.fontFallback(t,e)}async cleanup(t=!1){return this.catalog?this.catalog.cleanup(t):TE()}async#Wr(t,e,A,i,s){const{xref:a}=this;if(!(e instanceof Nh)||s.has(e))return;s.put(e);const n=await a.fetchAsync(e);if(!(n instanceof vh))return;if(n.has("T")){const e=Bh(await n.getAsync("T"));t=""===t?e:`${t}.${e}`}else{let e=n;for(;;){if(e=e.getRaw("Parent"),e instanceof Nh){if(s.has(e))break;e=await a.fetchAsync(e)}if(!(e instanceof vh))break;if(e.has("T")){const A=Bh(await e.getAsync("T"));t=""===t?A:`${t}.${A}`;break}}}if(A.has(t)||A.set(t,[]),A.get(t).push(Zx.create(a,e,i,null,!0,null).then((t=>t?.getFieldObject())).catch((function(t){return Zc(`#collectFieldObjects: "${t}".`),null}))),!n.has("Kids"))return;const r=await n.getAsync("Kids");if(Array.isArray(r))for(const e of r)await this.#Wr(t,e,A,i,s)}get fieldObjects(){return this.formInfo.hasFields?th(this,"fieldObjects",Promise.all([this.pdfManager.ensureDoc("annotationGlobals"),this.pdfManager.ensureCatalog("acroForm")]).then((async([t,e])=>{if(!t)return null;const A=new Mh,i=Object.create(null),s=new Map;for(const i of await e.getAsync("Fields"))await this.#Wr("",i,s,t,A);const a=[];for(const[t,e]of s)a.push(Promise.all(e).then((e=>{(e=e.filter((t=>!!t))).length>0&&(i[t]=e)})));return await Promise.all(a),i}))):th(this,"fieldObjects",Promise.resolve(null))}get hasJSActions(){return th(this,"hasJSActions",this.pdfManager.ensureDoc("_parseHasJSActions"))}async _parseHasJSActions(){const[t,e]=await Promise.all([this.pdfManager.ensureCatalog("jsActions"),this.pdfManager.ensureDoc("fieldObjects")]);return!!t||!!e&&Object.values(e).some((t=>t.some((t=>null!==t.actions))))}get calculationOrderIds(){const t=this.catalog.acroForm;if(!t?.has("CO"))return th(this,"calculationOrderIds",null);const e=t.get("CO");if(!Array.isArray(e)||0===e.length)return th(this,"calculationOrderIds",null);const A=[];for(const t of e)t instanceof Nh&&A.push(t.toString());return 0===A.length?th(this,"calculationOrderIds",null):th(this,"calculationOrderIds",A)}get annotationGlobals(){return th(this,"annotationGlobals",Zx.createGlobals(this.pdfManager))}}class UF{constructor(t){this.constructor===UF&&Xc("Cannot initialize BasePdfManager."),this._docBaseUrl=function(t){if(t){const e=$c(t);if(e)return e.href;Zc(`Invalid absolute docBaseUrl: "${t}".`)}return null}(t.docBaseUrl),this._docId=t.docId,this._password=t.password,this.enableXfa=t.enableXfa,t.evaluatorOptions.isOffscreenCanvasSupported&&=Ih.isOffscreenCanvasSupported,this.evaluatorOptions=Object.freeze(t.evaluatorOptions)}get docId(){return this._docId}get password(){return this._password}get docBaseUrl(){return this._docBaseUrl}get catalog(){return this.pdfDocument.catalog}ensureDoc(t,e){return this.ensure(this.pdfDocument,t,e)}ensureXRef(t,e){return this.ensure(this.pdfDocument.xref,t,e)}ensureCatalog(t,e){return this.ensure(this.pdfDocument.catalog,t,e)}getPage(t){return this.pdfDocument.getPage(t)}fontFallback(t,e){return this.pdfDocument.fontFallback(t,e)}loadXfaFonts(t,e){return this.pdfDocument.loadXfaFonts(t,e)}loadXfaImages(){return this.pdfDocument.loadXfaImages()}serializeXfaData(t){return this.pdfDocument.serializeXfaData(t)}cleanup(t=!1){return this.pdfDocument.cleanup(t)}async ensure(t,e,A){Xc("Abstract method `ensure` called")}requestRange(t,e){Xc("Abstract method `requestRange` called")}requestLoadedStream(t=!1){Xc("Abstract method `requestLoadedStream` called")}sendProgressiveData(t){Xc("Abstract method `sendProgressiveData` called")}updatePassword(t){this._password=t}terminate(t){Xc("Abstract method `terminate` called")}}class HF extends UF{constructor(t){super(t);const e=new bl(t.source);this.pdfDocument=new LF(this,e),this._loadedStreamPromise=Promise.resolve(e)}async ensure(t,e,A){const i=t[e];return"function"==typeof i?i.apply(t,A):i}requestRange(t,e){return Promise.resolve()}requestLoadedStream(t=!1){return this._loadedStreamPromise}terminate(t){}}class JF extends UF{constructor(t){super(t),this.streamManager=new Sl(t.source,{msgHandler:t.handler,length:t.length,disableAutoFetch:t.disableAutoFetch,rangeChunkSize:t.rangeChunkSize}),this.pdfDocument=new LF(this,this.streamManager.getStream())}async ensure(t,e,A){try{const i=t[e];return"function"==typeof i?i.apply(t,A):i}catch(i){if(!(i instanceof Ph))throw i;return await this.requestRange(i.begin,i.end),this.ensure(t,e,A)}}requestRange(t,e){return this.streamManager.requestRange(t,e)}requestLoadedStream(t=!1){return this.streamManager.requestAllChunks(t)}sendProgressiveData(t){this.streamManager.onReceiveData({chunk:t})}terminate(t){this.streamManager.abort(t)}}function _F(t){switch(t instanceof Error||"object"==typeof t&&null!==t||Xc('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new oh(t.message);case"MissingPDFException":return new ah(t.message);case"PasswordException":return new Ah(t.message,t.code);case"UnexpectedResponseException":return new nh(t.message,t.status);case"UnknownErrorException":return new ih(t.message,t.details);default:return new ih(t.message,t.toString())}}class YF{constructor(t,e,A){this.sourceName=t,this.targetName=e,this.comObj=A,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#jr(e);if(e.callback){const t=e.callbackId,A=this.callbackCapabilities[t];if(!A)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)A.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");A.reject(_F(e.reason))}return}const i=this.actionHandler[e.action];if(!i)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,s=e.sourceName;new Promise((function(t){t(i(e.data))})).then((function(i){A.postMessage({sourceName:t,targetName:s,callback:1,callbackId:e.callbackId,data:i})}),(function(i){A.postMessage({sourceName:t,targetName:s,callback:2,callbackId:e.callbackId,reason:_F(i)})}))}else e.streamId?this.#Vr(e):i(e.data)},A.addEventListener("message",this._onComObjOnMessage)}on(t,e){const A=this.actionHandler;if(A[t])throw new Error(`There is already an actionName called "${t}"`);A[t]=e}send(t,e,A){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},A)}sendWithPromise(t,e,A){const i=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[i]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},A)}catch(t){s.reject(t)}return s.promise}sendWithStream(t,e,A,i){const s=this.streamId++,a=this.sourceName,n=this.targetName,r=this.comObj;return new ReadableStream({start:A=>{const o=Promise.withResolvers();return this.streamControllers[s]={controller:A,startCall:o,pullCall:null,cancelCall:null,isClosed:!1},r.postMessage({sourceName:a,targetName:n,action:t,streamId:s,data:e,desiredSize:A.desiredSize},i),o.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[s].pullCall=e,r.postMessage({sourceName:a,targetName:n,stream:6,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{zc(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[s].cancelCall=e,this.streamControllers[s].isClosed=!0,r.postMessage({sourceName:a,targetName:n,stream:1,streamId:s,reason:_F(t)}),e.promise}},A)}#Vr(t){const e=t.streamId,A=this.sourceName,i=t.sourceName,s=this.comObj,a=this,n=this.actionHandler[t.action],r={enqueue(t,a=1,n){if(this.isCancelled)return;const r=this.desiredSize;this.desiredSize-=a,r>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:A,targetName:i,stream:4,streamId:e,chunk:t},n)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:A,targetName:i,stream:3,streamId:e}),delete a.streamSinks[e])},error(t){zc(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:A,targetName:i,stream:5,streamId:e,reason:_F(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};r.sinkCapability.resolve(),r.ready=r.sinkCapability.promise,this.streamSinks[e]=r,new Promise((function(e){e(n(t.data,r))})).then((function(){s.postMessage({sourceName:A,targetName:i,stream:8,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:A,targetName:i,stream:8,streamId:e,reason:_F(t)})}))}#jr(t){const e=t.streamId,A=this.sourceName,i=t.sourceName,s=this.comObj,a=this.streamControllers[e],n=this.streamSinks[e];switch(t.stream){case 8:t.success?a.startCall.resolve():a.startCall.reject(_F(t.reason));break;case 7:t.success?a.pullCall.resolve():a.pullCall.reject(_F(t.reason));break;case 6:if(!n){s.postMessage({sourceName:A,targetName:i,stream:7,streamId:e,success:!0});break}n.desiredSize<=0&&t.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=t.desiredSize,new Promise((function(t){t(n.onPull?.())})).then((function(){s.postMessage({sourceName:A,targetName:i,stream:7,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:A,targetName:i,stream:7,streamId:e,reason:_F(t)})}));break;case 4:if(zc(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case 3:if(zc(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#Zr(a,e);break;case 5:zc(a,"error should have stream controller"),a.controller.error(_F(t.reason)),this.#Zr(a,e);break;case 2:t.success?a.cancelCall.resolve():a.cancelCall.reject(_F(t.reason)),this.#Zr(a,e);break;case 1:if(!n)break;new Promise((function(e){e(n.onCancel?.(_F(t.reason)))})).then((function(){s.postMessage({sourceName:A,targetName:i,stream:2,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:A,targetName:i,stream:2,streamId:e,reason:_F(t)})})),n.sinkCapability.reject(_F(t.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Zr(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class TF{constructor(t){this._msgHandler=t,this._contentLength=null,this._fullRequestReader=null,this._rangeRequestReaders=[]}getFullReader(){return zc(!this._fullRequestReader,"PDFWorkerStream.getFullReader can only be called once."),this._fullRequestReader=new PF(this._msgHandler),this._fullRequestReader}getRangeReader(t,e){const A=new KF(t,e,this._msgHandler);return this._rangeRequestReaders.push(A),A}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class PF{constructor(t){this._msgHandler=t,this.onProgress=null,this._contentLength=null,this._isRangeSupported=!1,this._isStreamingSupported=!1;const e=this._msgHandler.sendWithStream("GetReader");this._reader=e.getReader(),this._headersReady=this._msgHandler.sendWithPromise("ReaderHeadersReady").then((t=>{this._isStreamingSupported=t.isStreamingSupported,this._isRangeSupported=t.isRangeSupported,this._contentLength=t.contentLength}))}get headersReady(){return this._headersReady}get contentLength(){return this._contentLength}get isStreamingSupported(){return this._isStreamingSupported}get isRangeSupported(){return this._isRangeSupported}async read(){const{value:t,done:e}=await this._reader.read();return e?{value:void 0,done:!0}:{value:t.buffer,done:!1}}cancel(t){this._reader.cancel(t)}}class KF{constructor(t,e,A){this._msgHandler=A,this.onProgress=null;const i=this._msgHandler.sendWithStream("GetRangeReader",{begin:t,end:e});this._reader=i.getReader()}get isStreamingSupported(){return!1}async read(){const{value:t,done:e}=await this._reader.read();return e?{value:void 0,done:!0}:{value:t.buffer,done:!1}}cancel(t){this._reader.cancel(t)}}class qF{constructor(t){this.name=t,this.terminated=!1,this._capability=Promise.withResolvers()}get finished(){return this._capability.promise}finish(){this._capability.resolve()}terminate(){this.terminated=!0}ensureNotTerminated(){if(this.terminated)throw new Error("Worker task was terminated")}}class OF{static setup(t,e){let A=!1;t.on("test",(function(e){A||(A=!0,t.send("test",e instanceof Uint8Array))})),t.on("configure",(function(t){!function(t){Number.isInteger(t)&&(jc=t)}(t.verbosity)})),t.on("GetDocRequest",(function(t){return OF.createDocumentHandler(t,e)}))}static createDocumentHandler(t,e){let A,i=!1,s=null;const a=new Set,n=jc,{docId:r,apiVersion:o}=t,g="4.5.136";if(o!==g)throw new Error(`The API version "${o}" does not match the Worker version "${g}".`);const c=[];for(const t in[])c.push(t);if(c.length)throw new Error("The `Array.prototype` contains unexpected enumerable properties: "+c.join(", ")+"; thus breaking e.g. `for...in` iteration of `Array`s.");const h=r+"_worker";let l=new YF(h,r,e);function I(){if(i)throw new Error("Worker was terminated")}function d(t){a.add(t)}function u(t){t.finish(),a.delete(t)}async function C(t){await A.ensureDoc("checkHeader"),await A.ensureDoc("parseStartXRef"),await A.ensureDoc("parse",[t]),await A.ensureDoc("checkFirstPage",[t]),await A.ensureDoc("checkLastPage",[t]);const e=await A.ensureDoc("isPureXfa");if(e){const t=new qF("loadXfaFonts");d(t),await Promise.all([A.loadXfaFonts(l,t).catch((t=>{})).then((()=>u(t))),A.loadXfaImages()])}const[i,s]=await Promise.all([A.ensureDoc("numPages"),A.ensureDoc("fingerprints")]);return{numPages:i,fingerprints:s,htmlForXfa:e?await A.ensureDoc("htmlForXfa"):null}}return l.on("GetPage",(function(t){return A.getPage(t.pageIndex).then((function(t){return Promise.all([A.ensure(t,"rotate"),A.ensure(t,"ref"),A.ensure(t,"userUnit"),A.ensure(t,"view")]).then((function([t,e,A,i]){return{rotate:t,ref:e,refStr:e?.toString()??null,userUnit:A,view:i}}))}))})),l.on("GetPageIndex",(function(t){const e=Nh.get(t.num,t.gen);return A.ensureCatalog("getPageIndex",[e])})),l.on("GetDestinations",(function(t){return A.ensureCatalog("destinations")})),l.on("GetDestination",(function(t){return A.ensureCatalog("getDestination",[t.id])})),l.on("GetPageLabels",(function(t){return A.ensureCatalog("pageLabels")})),l.on("GetPageLayout",(function(t){return A.ensureCatalog("pageLayout")})),l.on("GetPageMode",(function(t){return A.ensureCatalog("pageMode")})),l.on("GetViewerPreferences",(function(t){return A.ensureCatalog("viewerPreferences")})),l.on("GetOpenAction",(function(t){return A.ensureCatalog("openAction")})),l.on("GetAttachments",(function(t){return A.ensureCatalog("attachments")})),l.on("GetDocJSActions",(function(t){return A.ensureCatalog("jsActions")})),l.on("GetPageJSActions",(function({pageIndex:t}){return A.getPage(t).then((function(t){return A.ensure(t,"jsActions")}))})),l.on("GetOutline",(function(t){return A.ensureCatalog("documentOutline")})),l.on("GetOptionalContentConfig",(function(t){return A.ensureCatalog("optionalContentConfig")})),l.on("GetPermissions",(function(t){return A.ensureCatalog("permissions")})),l.on("GetMetadata",(function(t){return Promise.all([A.ensureDoc("documentInfo"),A.ensureCatalog("metadata")])})),l.on("GetMarkInfo",(function(t){return A.ensureCatalog("markInfo")})),l.on("GetData",(function(t){return A.requestLoadedStream().then((function(t){return t.bytes}))})),l.on("GetAnnotations",(function({pageIndex:t,intent:e}){return A.getPage(t).then((function(A){const i=new qF(`GetAnnotations: page ${t}`);return d(i),A.getAnnotationsData(l,i,e).then((t=>(u(i),t)),(t=>{throw u(i),t}))}))})),l.on("GetFieldObjects",(function(t){return A.ensureDoc("fieldObjects")})),l.on("HasJSActions",(function(t){return A.ensureDoc("hasJSActions")})),l.on("GetCalculationOrderIds",(function(t){return A.ensureDoc("calculationOrderIds")})),l.on("SaveDocument",(async function({isPureXfa:t,numPages:e,annotationStorage:i,filename:s}){const a=[A.requestLoadedStream(),A.ensureCatalog("acroForm"),A.ensureCatalog("acroFormRef"),A.ensureDoc("startXRef"),A.ensureDoc("xref"),A.ensureDoc("linearization"),A.ensureCatalog("structTreeRoot")],n=[],r=t?null:Ql(i),[o,g,c,h,I,d,C]=await Promise.all(a),B=I.trailer.getRaw("Root")||null;let Q;if(r){C?await C.canUpdateStructTree({pdfManager:A,xref:I,newAnnotationsByPage:r})&&(Q=C):await ff.canCreateStructureTree({catalogRef:B,pdfManager:A,newAnnotationsByPage:r})&&(Q=null);const t=Zx.generateImages(i.values(),I,A.evaluatorOptions.isOffscreenCanvasSupported),e=void 0===Q?n:[];for(const[i,s]of r)e.push(A.getPage(i).then((e=>{const A=new qF(`Save (editor): page ${i}`);return e.saveNewAnnotations(l,A,s,t).finally((function(){u(A)}))})));null===Q?n.push(Promise.all(e).then((async t=>(await ff.createStructureTree({newAnnotationsByPage:r,xref:I,catalogRef:B,pdfManager:A,newRefs:t}),t)))):Q&&n.push(Promise.all(e).then((async t=>(await Q.updateStructureTree({newAnnotationsByPage:r,pdfManager:A,newRefs:t}),t))))}if(t)n.push(A.serializeXfaData(i));else for(let t=0;tt.needAppearances)),y=g instanceof vh&&g.get("XFA")||null;let b=null,w=!1;if(Array.isArray(y)){for(let t=0,e=y.length;t{"string"==typeof A&&(t[e]=Bh(A))})),D={rootRef:B,encryptRef:I.trailer.getRaw("Encrypt")||null,newRef:I.getNewTemporaryRef(),infoRef:I.trailer.getRaw("Info")||null,info:t,fileIds:I.trailer.get("ID")||null,startXRef:d?h:I.lastXRefStreamPos??h,filename:s}}return async function({originalData:t,xrefInfo:e,newRefs:A,xref:i=null,hasXfa:s=!1,xfaDatasetsRef:a=null,hasXfaDatasetsEntry:n=!1,needAppearances:r,acroFormRef:o=null,acroForm:g=null,xfaData:c=null,useXrefStream:h=!1}){await async function({xref:t,acroForm:e,acroFormRef:A,hasXfa:i,hasXfaDatasetsEntry:s,xfaDatasetsRef:a,needAppearances:n,newRefs:r}){if(!i||s||a||Zc("XFA - Cannot save it"),!n&&(!i||!a||s))return;const o=e.clone();if(i&&!s){const t=e.get("XFA").slice();t.splice(2,0,"datasets"),t.splice(3,0,a),o.set("XFA",t)}n&&o.set("NeedAppearances",!0);const g=[];await hf(A,o,g,t),r.push({ref:A,data:g.join("")})}({xref:i,acroForm:g,acroFormRef:o,hasXfa:s,hasXfaDatasetsEntry:n,xfaDatasetsRef:a,needAppearances:r,newRefs:A}),s&&function({xfaData:t,xfaDatasetsRef:e,newRefs:A,xref:i}){null===t&&(t=function(t,e){const A=new jE({hasAttributes:!0}).parseFromString(t);for(const{xfa:t}of e){if(!t)continue;const{path:e,value:i}=t;if(!e)continue;const s=nl(e);let a=A.documentElement.searchNode(s,0);!a&&s.length>1&&(a=A.documentElement.searchNode([s.at(-1)],0)),a?a.childNodes=Array.isArray(i)?i.map((t=>new WE("value",t))):[new WE("#text",i)]:Zc(`Node not found for path: ${e}`)}const i=[];return A.documentElement.dump(i),i.join("")}(i.fetchIfRef(e).getString(),A));const s=i.encrypt;s&&(t=s.createCipherTransform(e.num,e.gen).encryptString(t));const a=`${e.num} ${e.gen} obj\n<< /Type /EmbeddedFile /Length ${t.length}>>\nstream\n`+t+"\nendstream\nendobj\n";A.push({ref:e,data:a})}({xfaData:c,xfaDatasetsRef:a,newRefs:A,xref:i});const l=[];let I=t.length;const d=t.at(-1);10!==d&&13!==d&&(l.push("\n"),I+=1);const u=function(t,e,A){const i=new vh(null);i.set("Prev",t.startXRef);const s=t.newRef;return A?(e.push({ref:s,data:""}),i.set("Size",s.num+1),i.set("Type",xh.get("XRef"))):i.set("Size",s.num),null!==t.rootRef&&i.set("Root",t.rootRef),null!==t.infoRef&&i.set("Info",t.infoRef),null!==t.encryptRef&&i.set("Encrypt",t.encryptRef),i}(e,A,h);A=A.sort(((t,e)=>t.ref.num-e.ref.num));for(const{data:t}of A)null!==t&&l.push(t);await(h?async function(t,e,A,i,s){const a=[];let n=0,r=0;for(const{ref:t,data:i}of A){let A;n=Math.max(n,e),null!==i?(A=Math.min(t.gen,65535),a.push([1,e,A]),e+=i.length):(A=Math.min(t.gen+1,65535),a.push([0,0,A])),r=Math.max(r,A)}i.set("Index",Qf(A));const o=[1,yl(n),yl(r)];i.set("W",o),Ef(e,t,i);const g=o.reduce(((t,e)=>t+e),0),c=new Uint8Array(g*a.length),h=new bl(c);h.dict=i;let l=0;for(const[t,e,A]of a)l=Cf(t,o[0],l,c),l=Cf(e,o[1],l,c),l=Cf(A,o[2],l,c);await hf(t.newRef,h,s,{}),s.push("startxref\n",e.toString(),"\n%%EOF\n")}(e,I,A,u,l):async function(t,e,A,i,s){s.push("xref\n");const a=Qf(A);let n=0;for(const{ref:t,data:i}of A)t.num===a[n]&&(s.push(`${a[n]} ${a[n+1]}\n`),n+=2),null!==i?(s.push(`${e.toString().padStart(10,"0")} ${Math.min(t.gen,65535).toString().padStart(5,"0")} n\r\n`),e+=i.length):s.push(`0000000000 ${Math.min(t.gen+1,65535).toString().padStart(5,"0")} f\r\n`);Ef(e,t,i),s.push("trailer\n"),await lf(i,s),s.push("\nstartxref\n",e.toString(),"\n%%EOF\n")}(e,I,A,u,l));const C=l.reduce(((t,e)=>t+e.length),t.length),B=new Uint8Array(C);B.set(t);let Q=t.length;for(const t of l)Bf(t,Q,B),Q+=t.length;return B}({originalData:o.bytes,xrefInfo:D,newRefs:f,xref:I,hasXfa:!!y,xfaDatasetsRef:b,hasXfaDatasetsEntry:w,needAppearances:m,acroFormRef:c,acroForm:g,xfaData:p,useXrefStream:Hh(I.topDict,"XRef")}).finally((()=>{I.resetNewTemporaryRef()}))})),l.on("GetOperatorList",(function(t,e){const i=t.pageIndex;A.getPage(i).then((function(A){const s=new qF(`GetOperatorList: page ${i}`);d(s);const a=n>=Gc.INFOS?Date.now():0;A.getOperatorList({handler:l,sink:e,task:s,intent:t.intent,cacheKey:t.cacheKey,annotationStorage:t.annotationStorage,modifiedIds:t.modifiedIds}).then((function(t){u(s),a&&Vc(`page=${i+1} - getOperatorList: time=${Date.now()-a}ms, len=${t.length}`),e.close()}),(function(t){u(s),s.terminated||e.error(t)}))}))})),l.on("GetTextContent",(function(t,e){const{pageIndex:i,includeMarkedContent:s,disableNormalization:a}=t;A.getPage(i).then((function(t){const A=new qF("GetTextContent: page "+i);d(A);const r=n>=Gc.INFOS?Date.now():0;t.extractTextContent({handler:l,task:A,sink:e,includeMarkedContent:s,disableNormalization:a}).then((function(){u(A),r&&Vc(`page=${i+1} - getTextContent: time=`+(Date.now()-r)+"ms"),e.close()}),(function(t){u(A),A.terminated||e.error(t)}))}))})),l.on("GetStructTree",(function(t){return A.getPage(t.pageIndex).then((function(t){return A.ensure(t,"getStructTree")}))})),l.on("FontFallback",(function(t){return A.fontFallback(t.id,l)})),l.on("Cleanup",(function(t){return A.cleanup(!0)})),l.on("Terminate",(function(t){i=!0;const e=[];if(A){A.terminate(new oh("Worker was terminated."));const t=A.cleanup();e.push(t),A=null}else TE();s&&s(new oh("Worker was terminated."));for(const t of a)e.push(t.finished),t.terminate();return Promise.all(e).then((function(){l.destroy(),l=null}))})),l.on("Ready",(function(e){!function(t){function e(t){I(),l.send("GetDoc",{pdfInfo:t})}function a(t){if(I(),t instanceof Ah){const e=new qF(`PasswordException: response ${t.code}`);d(e),l.sendWithPromise("PasswordRequest",t).then((function({password:t}){u(e),A.updatePassword(t),n()})).catch((function(){u(e),l.send("DocException",t)}))}else t instanceof sh||t instanceof ah||t instanceof nh||t instanceof ih?l.send("DocException",t):l.send("DocException",new ih(t.message,t.toString()))}function n(){I(),C(!1).then(e,(function(t){I(),t instanceof Oh?A.requestLoadedStream().then((function(){I(),C(!0).then(e,a)})):a(t)}))}I(),function({data:t,password:e,disableAutoFetch:A,rangeChunkSize:i,length:a,docBaseUrl:n,enableXfa:o,evaluatorOptions:g}){const c={source:null,disableAutoFetch:A,docBaseUrl:n,docId:r,enableXfa:o,evaluatorOptions:g,handler:l,length:a,password:e,rangeChunkSize:i},h=Promise.withResolvers();let d;if(t){try{c.source=t,d=new HF(c),h.resolve(d)}catch(t){h.reject(t)}return h.promise}let u,C=[];try{u=new TF(l)}catch(t){return h.reject(t),h.promise}const B=u.getFullReader();B.headersReady.then((function(){if(B.isRangeSupported){c.source=u,c.length=B.contentLength,c.disableAutoFetch||=B.isStreamingSupported,d=new JF(c);for(const t of C)d.sendProgressiveData(t);C=[],h.resolve(d),s=null}})).catch((function(t){h.reject(t),s=null}));let Q=0;return new Promise((function(t,e){const A=function({value:t,done:i}){try{if(I(),i)return d||function(){const t=Wh(C);a&&t.length!==a&&Zc("reported HTTP length is different from actual");try{c.source=t,d=new HF(c),h.resolve(d)}catch(t){h.reject(t)}C=[]}(),void(s=null);Q+=t.byteLength,B.isStreamingSupported||l.send("DocProgress",{loaded:Q,total:Math.max(Q,B.contentLength||0)}),d?d.sendProgressiveData(t):C.push(t),B.read().then(A,e)}catch(t){e(t)}};B.read().then(A,e)})).catch((function(t){h.reject(t),s=null})),s=function(t){u.cancelAllRequests(t)},h.promise}(t).then((function(t){if(i)throw t.terminate(new oh("Worker was terminated.")),new Error("Worker was terminated");A=t,A.requestLoadedStream(!0).then((t=>{l.send("DataLoaded",{length:t.bytes.byteLength})}))})).then(n,a)}(t),t=null})),h}static initializeFromPort(t){const e=new YF("worker","main",t);OF.setup(e,t),e.send("ready",null)}}function WF(){document.getElementById("table-div").innerHTML=''}function jF(){document.getElementById("stats-div").innerHTML=''}function VF(t){return Array.isArray?Array.isArray(t):"[object Array]"===eR(t)}"undefined"==typeof window&&!mc&&"undefined"!=typeof self&&function(t){return"function"==typeof t.postMessage&&"onmessage"in t}(self)&&OF.initializeFromPort(self);function ZF(t){return"string"==typeof t}function XF(t){return"number"==typeof t}function zF(t){return"object"==typeof t}function $F(t){return null!=t}function tR(t){return!t.trim().length}function eR(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const AR=t=>`Missing ${t} property in key`,iR=t=>`Property 'weight' in key '${t}' must be a positive integer`,sR=Object.prototype.hasOwnProperty;class aR{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{let A=nR(t);this._keys.push(A),this._keyMap[A.id]=A,e+=A.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function nR(t){let e=null,A=null,i=null,s=1,a=null;if(ZF(t)||VF(t))i=t,e=rR(t),A=oR(t);else{if(!sR.call(t,"name"))throw new Error(AR("name"));const n=t.name;if(i=n,sR.call(t,"weight")&&(s=t.weight,s<=0))throw new Error(iR(n));e=rR(n),A=oR(n),a=t.getFn}return{path:e,id:A,weight:s,src:i,getFn:a}}function rR(t){return VF(t)?t:t.split(".")}function oR(t){return VF(t)?t.join("."):t}const gR={useExtendedSearch:!1,getFn:function(t,e){let A=[],i=!1;const s=(t,e,a)=>{if($F(t))if(e[a]){const n=t[e[a]];if(!$F(n))return;if(a===e.length-1&&(ZF(n)||XF(n)||function(t){return!0===t||!1===t||function(t){return zF(t)&&null!==t}(t)&&"[object Boolean]"==eR(t)}(n)))A.push(function(t){return null==t?"":function(t){if("string"==typeof t)return t;let e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(t)}(n));else if(VF(n)){i=!0;for(let t=0,A=n.length;tt.score===e.score?t.idx{this._keysMap[t.id]=e}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,ZF(this.docs[0])?this.docs.forEach(((t,e)=>{this._addString(t,e)})):this.docs.forEach(((t,e)=>{this._addObject(t,e)})),this.norm.clear())}add(t){const e=this.size();ZF(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,A=this.size();e{let s=e.getFn?e.getFn(t):this.getFn(t,e.path);if($F(s))if(VF(s)){let t=[];const e=[{nestedArrIndex:-1,value:s}];for(;e.length;){const{nestedArrIndex:A,value:i}=e.pop();if($F(i))if(ZF(i)&&!tR(i)){let e={v:i,i:A,n:this.norm.get(i)};t.push(e)}else VF(i)&&i.forEach(((t,A)=>{e.push({nestedArrIndex:A,value:t})}))}A.$[i]=t}else if(ZF(s)&&!tR(s)){let t={v:s,n:this.norm.get(s)};A.$[i]=t}})),this.records.push(A)}toJSON(){return{keys:this.keys,records:this.records}}}function IR(t,e,{getFn:A=cR.getFn,fieldNormWeight:i=cR.fieldNormWeight}={}){const s=new lR({getFn:A,fieldNormWeight:i});return s.setKeys(t.map(nR)),s.setSources(e),s.create(),s}function dR(t,{errors:e=0,currentLocation:A=0,expectedLocation:i=0,distance:s=cR.distance,ignoreLocation:a=cR.ignoreLocation}={}){const n=e/t.length;if(a)return n;const r=Math.abs(i-A);return s?n+r/s:r?1:n}const uR=32;function CR(t){let e={};for(let A=0,i=t.length;A{this.chunks.push({pattern:t,alphabet:CR(t),startIndex:e})},c=this.pattern.length;if(c>uR){let t=0;const e=c%uR,A=c-e;for(;t{const{isMatch:d,score:u,indices:C}=function(t,e,A,{location:i=cR.location,distance:s=cR.distance,threshold:a=cR.threshold,findAllMatches:n=cR.findAllMatches,minMatchCharLength:r=cR.minMatchCharLength,includeMatches:o=cR.includeMatches,ignoreLocation:g=cR.ignoreLocation}={}){if(e.length>uR)throw new Error("Pattern length exceeds max of 32.");const c=e.length,h=t.length,l=Math.max(0,Math.min(i,h));let I=a,d=l;const u=r>1||o,C=u?Array(h):[];let B;for(;(B=t.indexOf(e,d))>-1;){let t=dR(e,{currentLocation:B,expectedLocation:l,distance:s,ignoreLocation:g});if(I=Math.min(t,I),d=B+c,u){let t=0;for(;t=o;a-=1){let n=a-1,r=A[t.charAt(n)];if(u&&(C[n]=+!!r),m[a]=(m[a+1]<<1|1)&r,i&&(m[a]|=(Q[a+1]|Q[a])<<1|1|Q[a+1]),m[a]&p&&(E=dR(e,{errors:i,currentLocation:n,expectedLocation:l,distance:s,ignoreLocation:g}),E<=I)){if(I=E,d=n,d<=l)break;o=Math.max(1,2*l-d)}}if(dR(e,{errors:i+1,currentLocation:l,expectedLocation:l,distance:s,ignoreLocation:g})>I)break;Q=m}const m={isMatch:d>=0,score:Math.max(.001,E)};if(u){const t=function(t=[],e=cR.minMatchCharLength){let A=[],i=-1,s=-1,a=0;for(let n=t.length;a=e&&A.push([i,s]),i=-1)}return t[a-1]&&a-i>=e&&A.push([i,a-1]),A}(C,r);t.length?o&&(m.indices=t):m.isMatch=!1}return m}(t,e,l,{location:i+I,distance:s,threshold:a,findAllMatches:n,minMatchCharLength:r,includeMatches:A,ignoreLocation:o});d&&(h=!0),c+=u,d&&C&&(g=[...g,...C])}));let l={isMatch:h,score:h?c/this.chunks.length:1};return h&&A&&(l.indices=g),l}}class QR{constructor(t){this.pattern=t}static isMultiMatch(t){return ER(t,this.multiRegex)}static isSingleMatch(t){return ER(t,this.singleRegex)}search(){}}function ER(t,e){const A=t.match(e);return A?A[1]:null}class fR extends QR{constructor(t,{location:e=cR.location,threshold:A=cR.threshold,distance:i=cR.distance,includeMatches:s=cR.includeMatches,findAllMatches:a=cR.findAllMatches,minMatchCharLength:n=cR.minMatchCharLength,isCaseSensitive:r=cR.isCaseSensitive,ignoreLocation:o=cR.ignoreLocation}={}){super(t),this._bitapSearch=new BR(t,{location:e,threshold:A,distance:i,includeMatches:s,findAllMatches:a,minMatchCharLength:n,isCaseSensitive:r,ignoreLocation:o})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class pR extends QR{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e,A=0;const i=[],s=this.pattern.length;for(;(e=t.indexOf(this.pattern,A))>-1;)A=e+s,i.push([e,A-1]);const a=!!i.length;return{isMatch:a,score:a?0:1,indices:i}}}const mR=[class extends QR{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},pR,class extends QR{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},class extends QR{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends QR{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends QR{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}},class extends QR{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const e=-1===t.indexOf(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},fR],yR=mR.length,bR=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,wR=new Set([fR.type,pR.type]);const DR=[];function kR(t,e){for(let A=0,i=DR.length;A!(!t[SR]&&!t.$or),RR=t=>({[SR]:Object.keys(t).map((e=>({[e]:t[e]})))});function vR(t,e,{auto:A=!0}={}){const i=t=>{let s=Object.keys(t);const a=(t=>!!t[xR])(t);if(!a&&s.length>1&&!FR(t))return i(RR(t));if((t=>!VF(t)&&zF(t)&&!FR(t))(t)){const i=a?t[xR]:s[0],n=a?t.$val:t[i];if(!ZF(n))throw new Error((t=>`Invalid value for key ${t}`)(i));const r={keyId:oR(i),pattern:n};return A&&(r.searcher=kR(n,e)),r}let n={children:[],operator:s[0]};return s.forEach((e=>{const A=t[e];VF(A)&&A.forEach((t=>{n.children.push(i(t))}))})),n};return FR(t)||(t=RR(t)),i(t)}function NR(t,e){const A=t.matches;e.matches=[],$F(A)&&A.forEach((t=>{if(!$F(t.indices)||!t.indices.length)return;const{indices:A,value:i}=t;let s={indices:A,value:i};t.key&&(s.key=t.key.src),t.idx>-1&&(s.refIndex=t.idx),e.matches.push(s)}))}function MR(t,e){e.score=t.score}class GR{constructor(t,e={},A){this.options={...cR,...e},this.options.useExtendedSearch,this._keyStore=new aR(this.options.keys),this.setCollection(t,A)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof lR))throw new Error("Incorrect 'index' type");this._myIndex=e||IR(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){$F(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let A=0,i=this._docs.length;A{let A=1;t.matches.forEach((({key:t,norm:i,score:s})=>{const a=t?t.weight:null;A*=Math.pow(0===s&&a?Number.EPSILON:s,(a||1)*(e?1:i))})),t.score=A}))}(r,{ignoreFieldNorm:n}),s&&r.sort(a),XF(e)&&e>-1&&(r=r.slice(0,e)),function(t,e,{includeMatches:A=cR.includeMatches,includeScore:i=cR.includeScore}={}){const s=[];return A&&s.push(NR),i&&s.push(MR),t.map((t=>{const{idx:A}=t,i={item:e[A],refIndex:A};return s.length&&s.forEach((e=>{e(t,i)})),i}))}(r,this._docs,{includeMatches:A,includeScore:i})}_searchStringList(t){const e=kR(t,this.options),{records:A}=this._myIndex,i=[];return A.forEach((({v:t,i:A,n:s})=>{if(!$F(t))return;const{isMatch:a,score:n,indices:r}=e.searchIn(t);a&&i.push({item:t,idx:A,matches:[{score:n,value:t,norm:s,indices:r}]})})),i}_searchLogical(t){const e=vR(t,this.options),A=(t,e,i)=>{if(!t.children){const{keyId:A,searcher:s}=t,a=this._findMatches({key:this._keyStore.get(A),value:this._myIndex.getValueForItemAtKeyId(e,A),searcher:s});return a&&a.length?[{idx:i,item:e,matches:a}]:[]}const s=[];for(let a=0,n=t.children.length;a{if($F(t)){let n=A(e,t,i);n.length&&(s[i]||(s[i]={idx:i,item:t,matches:[]},a.push(s[i])),n.forEach((({matches:t})=>{s[i].matches.push(...t)})))}})),a}_searchObjectList(t){const e=kR(t,this.options),{keys:A,records:i}=this._myIndex,s=[];return i.forEach((({$:t,i})=>{if(!$F(t))return;let a=[];A.forEach(((A,i)=>{a.push(...this._findMatches({key:A,value:t[i],searcher:e}))})),a.length&&s.push({idx:i,item:t,matches:a})})),s}_findMatches({key:t,value:e,searcher:A}){if(!$F(e))return[];let i=[];if(VF(e))e.forEach((({v:e,i:s,n:a})=>{if(!$F(e))return;const{isMatch:n,score:r,indices:o}=A.searchIn(e);n&&i.push({score:r,key:t,value:e,idx:s,norm:a,indices:o})}));else{const{v:s,n:a}=e,{isMatch:n,score:r,indices:o}=A.searchIn(s);n&&i.push({score:r,key:t,value:s,norm:a,indices:o})}return i}}GR.version="7.0.0",GR.createIndex=IR,GR.parseIndex=function(t,{getFn:e=cR.getFn,fieldNormWeight:A=cR.fieldNormWeight}={}){const{keys:i,records:s}=t,a=new lR({getFn:e,fieldNormWeight:A});return a.setKeys(i),a.setIndexRecords(s),a},GR.config=cR,GR.parseQuery=vR,function(...t){DR.push(...t)}(class{constructor(t,{isCaseSensitive:e=cR.isCaseSensitive,includeMatches:A=cR.includeMatches,minMatchCharLength:i=cR.minMatchCharLength,ignoreLocation:s=cR.ignoreLocation,findAllMatches:a=cR.findAllMatches,location:n=cR.location,threshold:r=cR.threshold,distance:o=cR.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:A,minMatchCharLength:i,findAllMatches:a,ignoreLocation:s,location:n,threshold:r,distance:o},this.pattern=e?t:t.toLowerCase(),this.query=function(t,e={}){return t.split("|").map((t=>{let A=t.trim().split(bR).filter((t=>t&&!!t.trim())),i=[];for(let t=0,s=A.length;tt.item))}var HR,JR,_R,YR,TR=!1,PR=!1,KR=[],qR=-1;function OR(t){let e=KR.indexOf(t);-1!==e&&e>qR&&KR.splice(e,1)}function WR(){TR=!1,PR=!0;for(let t=0;t{let s=t();JSON.stringify(s),i?A=s:queueMicrotask((()=>{e(s,A),A=s})),i=!1}));return()=>_R(s)}var XR=[],zR=[],$R=[];function tv(t,e){"function"==typeof e?(t._x_cleanups||(t._x_cleanups=[]),t._x_cleanups.push(e)):(e=t,zR.push(e))}function ev(t){XR.push(t)}function Av(t,e,A){t._x_attributeCleanups||(t._x_attributeCleanups={}),t._x_attributeCleanups[e]||(t._x_attributeCleanups[e]=[]),t._x_attributeCleanups[e].push(A)}function iv(t,e){t._x_attributeCleanups&&Object.entries(t._x_attributeCleanups).forEach((([A,i])=>{(void 0===e||e.includes(A))&&(i.forEach((t=>t())),delete t._x_attributeCleanups[A])}))}var sv=new MutationObserver(lv),av=!1;function nv(){sv.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),av=!0}function rv(){!function(){let t=sv.takeRecords();ov.push((()=>t.length>0&&lv(t)));let e=ov.length;queueMicrotask((()=>{if(ov.length===e)for(;ov.length>0;)ov.shift()()}))}(),sv.disconnect(),av=!1}var ov=[];function gv(t){if(!av)return t();rv();let e=t();return nv(),e}var cv=!1,hv=[];function lv(t){if(cv)return void(hv=hv.concat(t));let e=new Set,A=new Set,i=new Map,s=new Map;for(let a=0;a1===t.nodeType&&e.add(t))),t[a].removedNodes.forEach((t=>1===t.nodeType&&A.add(t)))),"attributes"===t[a].type)){let e=t[a].target,A=t[a].attributeName,n=t[a].oldValue,r=()=>{i.has(e)||i.set(e,[]),i.get(e).push({name:A,value:e.getAttribute(A)})},o=()=>{s.has(e)||s.set(e,[]),s.get(e).push(A)};e.hasAttribute(A)&&null===n?r():e.hasAttribute(A)?(o(),r()):o()}s.forEach(((t,e)=>{iv(e,t)})),i.forEach(((t,e)=>{XR.forEach((A=>A(e,t)))}));for(let t of A)e.has(t)||zR.forEach((e=>e(t)));e.forEach((t=>{t._x_ignoreSelf=!0,t._x_ignore=!0}));for(let t of e)A.has(t)||t.isConnected&&(delete t._x_ignoreSelf,delete t._x_ignore,$R.forEach((e=>e(t))),t._x_ignore=!0,t._x_ignoreSelf=!0);e.forEach((t=>{delete t._x_ignoreSelf,delete t._x_ignore})),e=null,A=null,i=null,s=null}function Iv(t){return Cv(uv(t))}function dv(t,e,A){return t._x_dataStack=[e,...uv(A||t)],()=>{t._x_dataStack=t._x_dataStack.filter((t=>t!==e))}}function uv(t){return t._x_dataStack?t._x_dataStack:"function"==typeof ShadowRoot&&t instanceof ShadowRoot?uv(t.host):t.parentNode?uv(t.parentNode):[]}function Cv(t){return new Proxy({objects:t},Bv)}var Bv={ownKeys:({objects:t})=>Array.from(new Set(t.flatMap((t=>Object.keys(t))))),has:({objects:t},e)=>e!=Symbol.unscopables&&t.some((t=>Object.prototype.hasOwnProperty.call(t,e)||Reflect.has(t,e))),get:({objects:t},e,A)=>"toJSON"==e?Qv:Reflect.get(t.find((t=>Reflect.has(t,e)))||{},e,A),set({objects:t},e,A,i){const s=t.find((t=>Object.prototype.hasOwnProperty.call(t,e)))||t[t.length-1],a=Object.getOwnPropertyDescriptor(s,e);return a?.set&&a?.get?a.set.call(i,A)||!0:Reflect.set(s,e,A)}};function Qv(){return Reflect.ownKeys(this).reduce(((t,e)=>(t[e]=Reflect.get(this,e),t)),{})}function Ev(t){let e=(A,i="")=>{Object.entries(Object.getOwnPropertyDescriptors(A)).forEach((([s,{value:a,enumerable:n}])=>{if(!1===n||void 0===a)return;if("object"==typeof a&&null!==a&&a.__v_skip)return;let r=""===i?s:`${i}.${s}`;var o;"object"==typeof a&&null!==a&&a._x_interceptor?A[s]=a.initialize(t,r,s):"object"!=typeof(o=a)||Array.isArray(o)||null===o||a===A||a instanceof Element||e(a,r)}))};return e(t)}function fv(t,e=()=>{}){let A={initialValue:void 0,_x_interceptor:!0,initialize(e,A,i){return t(this.initialValue,(()=>function(t,e){return e.split(".").reduce(((t,e)=>t[e]),t)}(e,A)),(t=>pv(e,A,t)),A,i)}};return e(A),t=>{if("object"==typeof t&&null!==t&&t._x_interceptor){let e=A.initialize.bind(A);A.initialize=(i,s,a)=>{let n=t.initialize(i,s,a);return A.initialValue=n,e(i,s,a)}}else A.initialValue=t;return A}}function pv(t,e,A){if("string"==typeof e&&(e=e.split(".")),1!==e.length){if(0===e.length)throw error;return t[e[0]]||(t[e[0]]={}),pv(t[e[0]],e.slice(1),A)}t[e[0]]=A}var mv={};function yv(t,e){mv[t]=e}function bv(t,e){return Object.entries(mv).forEach((([A,i])=>{let s=null;Object.defineProperty(t,`$${A}`,{get:()=>i(e,function(){if(s)return s;{let[t,A]=Kv(e);return s={interceptor:fv,...t},tv(e,A),s}}()),enumerable:!1})})),t}function wv(t,e,A,...i){try{return A(...i)}catch(A){Dv(A,t,e)}}function Dv(t,e,A=void 0){t=Object.assign(t??{message:"No error message given."},{el:e,expression:A}),console.warn(`Alpine Expression Error: ${t.message}\n\n${A?'Expression: "'+A+'"\n\n':""}`,e),setTimeout((()=>{throw t}),0)}var kv=!0;function Sv(t){let e=kv;kv=!1;let A=t();return kv=e,A}function xv(t,e,A={}){let i;return Fv(t,e)((t=>i=t),A),i}function Fv(...t){return Rv(...t)}var Rv=vv;function vv(t,e){let A={};bv(A,t);let i=[A,...uv(t)],s="function"==typeof e?function(t,e){return(A=()=>{},{scope:i={},params:s=[]}={})=>{Mv(A,e.apply(Cv([i,...t]),s))}}(i,e):function(t,e,A){let i=function(t,e){if(Nv[t])return Nv[t];let A=Object.getPrototypeOf((async function(){})).constructor,i=/^[\n\s]*if.*\(.*\)/.test(t.trim())||/^(let|const)\s/.test(t.trim())?`(async()=>{ ${t} })()`:t;let s=(()=>{try{let e=new A(["__self","scope"],`with (scope) { __self.result = ${i} }; __self.finished = true; return __self.result;`);return Object.defineProperty(e,"name",{value:`[Alpine] ${t}`}),e}catch(A){return Dv(A,e,t),Promise.resolve()}})();return Nv[t]=s,s}(e,A);return(s=()=>{},{scope:a={},params:n=[]}={})=>{i.result=void 0,i.finished=!1;let r=Cv([a,...t]);if("function"==typeof i){let t=i(i,r).catch((t=>Dv(t,A,e)));i.finished?(Mv(s,i.result,r,n,A),i.result=void 0):t.then((t=>{Mv(s,t,r,n,A)})).catch((t=>Dv(t,A,e))).finally((()=>i.result=void 0))}}}(i,e,t);return wv.bind(null,t,e,s)}var Nv={};function Mv(t,e,A,i,s){if(kv&&"function"==typeof e){let a=e.apply(A,i);a instanceof Promise?a.then((e=>Mv(t,e,A,i))).catch((t=>Dv(t,s,e))):t(a)}else"object"==typeof e&&e instanceof Promise?e.then((e=>t(e))):t(e)}var Gv="x-";function Lv(t=""){return Gv+t}var Uv={};function Hv(t,e){return Uv[t]=e,{before(e){if(!Uv[e])return void console.warn(String.raw`Cannot find directive \`${e}\`. \`${t}\` will use the default order of execution`);const A=zv.indexOf(e);zv.splice(A>=0?A:zv.indexOf("DEFAULT"),0,t)}}}function Jv(t,e,A){if(e=Array.from(e),t._x_virtualDirectives){let A=Object.entries(t._x_virtualDirectives).map((([t,e])=>({name:t,value:e}))),i=_v(A);A=A.map((t=>i.find((e=>e.name===t.name))?{name:`x-bind:${t.name}`,value:`"${t.value}"`}:t)),e=e.concat(A)}let i={},s=e.map(Ov(((t,e)=>i[t]=e))).filter(Vv).map(function(t,e){return({name:A,value:i})=>{let s=A.match(Zv()),a=A.match(/:([a-zA-Z0-9\-_:]+)/),n=A.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],r=e||t[A]||A;return{type:s?s[1]:null,value:a?a[1]:null,modifiers:n.map((t=>t.replace(".",""))),expression:i,original:r}}}(i,A)).sort($v);return s.map((e=>function(t,e){let A=Uv[e.type]||(()=>{}),[i,s]=Kv(t);Av(t,e.original,s);let a=()=>{t._x_ignore||t._x_ignoreSelf||(A.inline&&A.inline(t,e,i),A=A.bind(A,t,e,i),Yv?Tv.get(Pv).push(A):A())};return a.runCleanups=s,a}(t,e)))}function _v(t){return Array.from(t).map(Ov()).filter((t=>!Vv(t)))}var Yv=!1,Tv=new Map,Pv=Symbol();function Kv(t){let e=[],[A,i]=function(t){let e=()=>{};return[A=>{let i=JR(A);return t._x_effects||(t._x_effects=new Set,t._x_runEffects=()=>{t._x_effects.forEach((t=>t()))}),t._x_effects.add(i),e=()=>{void 0!==i&&(t._x_effects.delete(i),_R(i))},i},()=>{e()}]}(t);e.push(i);let s={Alpine:VN,effect:A,cleanup:t=>e.push(t),evaluateLater:Fv.bind(Fv,t),evaluate:xv.bind(xv,t)};return[s,()=>e.forEach((t=>t()))]}var qv=(t,e)=>({name:A,value:i})=>(A.startsWith(t)&&(A=A.replace(t,e)),{name:A,value:i});function Ov(t=()=>{}){return({name:e,value:A})=>{let{name:i,value:s}=Wv.reduce(((t,e)=>e(t)),{name:e,value:A});return i!==e&&t(i,e),{name:i,value:s}}}var Wv=[];function jv(t){Wv.push(t)}function Vv({name:t}){return Zv().test(t)}var Zv=()=>new RegExp(`^${Gv}([^:^.]+)\\b`),Xv="DEFAULT",zv=["ignore","ref","data","id","anchor","bind","init","for","model","modelable","transition","show","if",Xv,"teleport"];function $v(t,e){let A=-1===zv.indexOf(t.type)?Xv:t.type,i=-1===zv.indexOf(e.type)?Xv:e.type;return zv.indexOf(A)-zv.indexOf(i)}function tN(t,e,A={}){t.dispatchEvent(new CustomEvent(e,{detail:A,bubbles:!0,composed:!0,cancelable:!0}))}function eN(t,e){if("function"==typeof ShadowRoot&&t instanceof ShadowRoot)return void Array.from(t.children).forEach((t=>eN(t,e)));let A=!1;if(e(t,(()=>A=!0)),A)return;let i=t.firstElementChild;for(;i;)eN(i,e),i=i.nextElementSibling}function AN(t,...e){console.warn(`Alpine Warning: ${t}`,...e)}var iN=!1,sN=[],aN=[];function nN(){return sN.map((t=>t()))}function rN(){return sN.concat(aN).map((t=>t()))}function oN(t){sN.push(t)}function gN(t){aN.push(t)}function cN(t,e=!1){return hN(t,(t=>{if((e?rN():nN()).some((e=>t.matches(e))))return!0}))}function hN(t,e){if(t){if(e(t))return t;if(t._x_teleportBack&&(t=t._x_teleportBack),t.parentElement)return hN(t.parentElement,e)}}var lN=[];function IN(t,e=eN,A=()=>{}){!function(){Yv=!0;let i=Symbol();Pv=i,Tv.set(i,[]);let s=()=>{for(;Tv.get(i).length;)Tv.get(i).shift()();Tv.delete(i)};e(t,((t,e)=>{A(t,e),lN.forEach((A=>A(t,e))),Jv(t,t.attributes).forEach((t=>t())),t._x_ignore&&e()})),Yv=!1,s()}()}function dN(t,e=eN){e(t,(t=>{iv(t),function(t){if(t._x_cleanups)for(;t._x_cleanups.length;)t._x_cleanups.pop()()}(t)}))}var uN=[],CN=!1;function BN(t=()=>{}){return queueMicrotask((()=>{CN||setTimeout((()=>{QN()}))})),new Promise((e=>{uN.push((()=>{t(),e()}))}))}function QN(){for(CN=!1;uN.length;)uN.shift()()}function EN(t,e){return Array.isArray(e)?fN(t,e.join(" ")):"object"==typeof e&&null!==e?function(t,e){let A=t=>t.split(" ").filter(Boolean),i=Object.entries(e).flatMap((([t,e])=>!!e&&A(t))).filter(Boolean),s=Object.entries(e).flatMap((([t,e])=>!e&&A(t))).filter(Boolean),a=[],n=[];return s.forEach((e=>{t.classList.contains(e)&&(t.classList.remove(e),n.push(e))})),i.forEach((e=>{t.classList.contains(e)||(t.classList.add(e),a.push(e))})),()=>{n.forEach((e=>t.classList.add(e))),a.forEach((e=>t.classList.remove(e)))}}(t,e):"function"==typeof e?EN(t,e()):fN(t,e)}function fN(t,e){return e=!0===e?e="":e||"",A=e.split(" ").filter((e=>!t.classList.contains(e))).filter(Boolean),t.classList.add(...A),()=>{t.classList.remove(...A)};var A}function pN(t,e){return"object"==typeof e&&null!==e?function(t,e){let A={};return Object.entries(e).forEach((([e,i])=>{A[e]=t.style[e],e.startsWith("--")||(e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()),t.style.setProperty(e,i)})),setTimeout((()=>{0===t.style.length&&t.removeAttribute("style")})),()=>{pN(t,A)}}(t,e):function(t,e){let A=t.getAttribute("style",e);return t.setAttribute("style",e),()=>{t.setAttribute("style",A||"")}}(t,e)}function mN(t,e=()=>{}){let A=!1;return function(){A?e.apply(this,arguments):(A=!0,t.apply(this,arguments))}}function yN(t,e,A={}){t._x_transition||(t._x_transition={enter:{during:A,start:A,end:A},leave:{during:A,start:A,end:A},in(A=()=>{},i=()=>{}){wN(t,e,{during:this.enter.during,start:this.enter.start,end:this.enter.end},A,i)},out(A=()=>{},i=()=>{}){wN(t,e,{during:this.leave.during,start:this.leave.start,end:this.leave.end},A,i)}})}function bN(t){let e=t.parentNode;if(e)return e._x_hidePromise?e:bN(e)}function wN(t,e,{during:A,start:i,end:s}={},a=()=>{},n=()=>{}){if(t._x_transitioning&&t._x_transitioning.cancel(),0===Object.keys(A).length&&0===Object.keys(i).length&&0===Object.keys(s).length)return a(),void n();let r,o,g;!function(t,e){let A,i,s,a=mN((()=>{gv((()=>{A=!0,i||e.before(),s||(e.end(),QN()),e.after(),t.isConnected&&e.cleanup(),delete t._x_transitioning}))}));t._x_transitioning={beforeCancels:[],beforeCancel(t){this.beforeCancels.push(t)},cancel:mN((function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();a()})),finish:a},gv((()=>{e.start(),e.during()})),CN=!0,requestAnimationFrame((()=>{if(A)return;let a=1e3*Number(getComputedStyle(t).transitionDuration.replace(/,.*/,"").replace("s","")),n=1e3*Number(getComputedStyle(t).transitionDelay.replace(/,.*/,"").replace("s",""));0===a&&(a=1e3*Number(getComputedStyle(t).animationDuration.replace("s",""))),gv((()=>{e.before()})),i=!0,requestAnimationFrame((()=>{A||(gv((()=>{e.end()})),QN(),setTimeout(t._x_transitioning.finish,a+n),s=!0)}))}))}(t,{start(){r=e(t,i)},during(){o=e(t,A)},before:a,end(){r(),g=e(t,s)},after:n,cleanup(){o(),g()}})}function DN(t,e,A){if(-1===t.indexOf(e))return A;const i=t[t.indexOf(e)+1];if(!i)return A;if("scale"===e&&isNaN(i))return A;if("duration"===e||"delay"===e){let t=i.match(/([0-9]+)ms/);if(t)return t[1]}return"origin"===e&&["top","right","left","center","bottom"].includes(t[t.indexOf(e)+2])?[i,t[t.indexOf(e)+2]].join(" "):i}Hv("transition",((t,{value:e,modifiers:A,expression:i},{evaluate:s})=>{"function"==typeof i&&(i=s(i)),!1!==i&&(i&&"boolean"!=typeof i?function(t,e,A){yN(t,EN,""),{enter:e=>{t._x_transition.enter.during=e},"enter-start":e=>{t._x_transition.enter.start=e},"enter-end":e=>{t._x_transition.enter.end=e},leave:e=>{t._x_transition.leave.during=e},"leave-start":e=>{t._x_transition.leave.start=e},"leave-end":e=>{t._x_transition.leave.end=e}}[A](e)}(t,i,e):function(t,e,A){yN(t,pN);let i=!e.includes("in")&&!e.includes("out")&&!A,s=i||e.includes("in")||["enter"].includes(A),a=i||e.includes("out")||["leave"].includes(A);e.includes("in")&&!i&&(e=e.filter(((t,A)=>AA>e.indexOf("out"))));let n=!e.includes("opacity")&&!e.includes("scale"),r=n||e.includes("opacity")?0:1,o=n||e.includes("scale")?DN(e,"scale",95)/100:1,g=DN(e,"delay",0)/1e3,c=DN(e,"origin","center"),h="opacity, transform",l=DN(e,"duration",150)/1e3,I=DN(e,"duration",75)/1e3,d="cubic-bezier(0.4, 0.0, 0.2, 1)";s&&(t._x_transition.enter.during={transformOrigin:c,transitionDelay:`${g}s`,transitionProperty:h,transitionDuration:`${l}s`,transitionTimingFunction:d},t._x_transition.enter.start={opacity:r,transform:`scale(${o})`},t._x_transition.enter.end={opacity:1,transform:"scale(1)"}),a&&(t._x_transition.leave.during={transformOrigin:c,transitionDelay:`${g}s`,transitionProperty:h,transitionDuration:`${I}s`,transitionTimingFunction:d},t._x_transition.leave.start={opacity:1,transform:"scale(1)"},t._x_transition.leave.end={opacity:r,transform:`scale(${o})`})}(t,A,e))})),window.Element.prototype._x_toggleAndCascadeWithTransitions=function(t,e,A,i){const s="visible"===document.visibilityState?requestAnimationFrame:setTimeout;let a=()=>s(A);e?t._x_transition&&(t._x_transition.enter||t._x_transition.leave)?t._x_transition.enter&&(Object.entries(t._x_transition.enter.during).length||Object.entries(t._x_transition.enter.start).length||Object.entries(t._x_transition.enter.end).length)?t._x_transition.in(A):a():t._x_transition?t._x_transition.in(A):a():(t._x_hidePromise=t._x_transition?new Promise(((e,A)=>{t._x_transition.out((()=>{}),(()=>e(i))),t._x_transitioning&&t._x_transitioning.beforeCancel((()=>A({isFromCancelledTransition:!0})))})):Promise.resolve(i),queueMicrotask((()=>{let e=bN(t);e?(e._x_hideChildren||(e._x_hideChildren=[]),e._x_hideChildren.push(t)):s((()=>{let e=t=>{let A=Promise.all([t._x_hidePromise,...(t._x_hideChildren||[]).map(e)]).then((([t])=>t?.()));return delete t._x_hidePromise,delete t._x_hideChildren,A};e(t).catch((t=>{if(!t.isFromCancelledTransition)throw t}))}))})))};var kN=!1;function SN(t,e=()=>{}){return(...A)=>kN?e(...A):t(...A)}var xN=[];function FN(t){xN.push(t)}var RN=!1;function vN(t){let e=JR;VR(((t,A)=>{let i=e(t);return _R(i),()=>{}})),t(),VR(e)}function NN(t,e,A,i=[]){switch(t._x_bindings||(t._x_bindings=HR({})),t._x_bindings[e]=A,e=i.includes("camel")?e.toLowerCase().replace(/-(\w)/g,((t,e)=>e.toUpperCase())):e){case"value":!function(t,e){if("radio"===t.type)void 0===t.attributes.value&&(t.value=e),window.fromModel&&(t.checked="boolean"==typeof e?LN(t.value)===e:GN(t.value,e));else if("checkbox"===t.type)Number.isInteger(e)?t.value=e:Array.isArray(e)||"boolean"==typeof e||[null,void 0].includes(e)?Array.isArray(e)?t.checked=e.some((e=>GN(e,t.value))):t.checked=!!e:t.value=String(e);else if("SELECT"===t.tagName)!function(t,e){const A=[].concat(e).map((t=>t+""));Array.from(t.options).forEach((t=>{t.selected=A.includes(t.value)}))}(t,e);else{if(t.value===e)return;t.value=void 0===e?"":e}}(t,A);break;case"style":!function(t,e){t._x_undoAddedStyles&&t._x_undoAddedStyles(),t._x_undoAddedStyles=pN(t,e)}(t,A);break;case"class":!function(t,e){t._x_undoAddedClasses&&t._x_undoAddedClasses(),t._x_undoAddedClasses=EN(t,e)}(t,A);break;case"selected":case"checked":!function(t,e,A){MN(t,e,A),function(t,e,A){t[e]!==A&&(t[e]=A)}(t,e,A)}(t,e,A);break;default:MN(t,e,A)}}function MN(t,e,A){[null,void 0,!1].includes(A)&&function(t){return!["aria-pressed","aria-checked","aria-expanded","aria-selected"].includes(t)}(e)?t.removeAttribute(e):(UN(e)&&(A=e),function(t,e,A){t.getAttribute(e)!=A&&t.setAttribute(e,A)}(t,e,A))}function GN(t,e){return t==e}function LN(t){return!![1,"1","true","on","yes",!0].includes(t)||![0,"0","false","off","no",!1].includes(t)&&(t?Boolean(t):null)}function UN(t){return["disabled","checked","required","readonly","open","selected","autofocus","itemscope","multiple","novalidate","allowfullscreen","allowpaymentrequest","formnovalidate","autoplay","controls","loop","muted","playsinline","default","ismap","reversed","async","defer","nomodule"].includes(t)}function HN(t,e,A){let i=t.getAttribute(e);return null===i?"function"==typeof A?A():A:""===i||(UN(e)?!![e,"true"].includes(i):i)}function JN(t,e){var A;return function(){var i=this,s=arguments;clearTimeout(A),A=setTimeout((function(){A=null,t.apply(i,s)}),e)}}function _N(t,e){let A;return function(){let i=arguments;A||(t.apply(this,i),A=!0,setTimeout((()=>A=!1),e))}}function YN({get:t,set:e},{get:A,set:i}){let s,a,n=!0,r=JR((()=>{let r=t(),o=A();if(n)i(TN(r)),n=!1;else{let t=JSON.stringify(r),A=JSON.stringify(o);t!==s?i(TN(r)):t!==A&&e(TN(o))}s=JSON.stringify(t()),a=JSON.stringify(A())}));return()=>{_R(r)}}function TN(t){return"object"==typeof t?JSON.parse(JSON.stringify(t)):t}var PN={},KN=!1,qN={};function ON(t,e,A){let i=[];for(;i.length;)i.pop()();let s=Object.entries(e).map((([t,e])=>({name:t,value:e}))),a=_v(s);return s=s.map((t=>a.find((e=>e.name===t.name))?{name:`x-bind:${t.name}`,value:`"${t.value}"`}:t)),Jv(t,s,A).map((t=>{i.push(t.runCleanups),t()})),()=>{for(;i.length;)i.pop()()}}var WN={},jN={get reactive(){return HR},get release(){return _R},get effect(){return JR},get raw(){return YR},version:"3.14.1",flushAndStopDeferringMutations:function(){cv=!1,lv(hv),hv=[]},dontAutoEvaluateFunctions:Sv,disableEffectScheduling:function(t){jR=!1,t(),jR=!0},startObservingMutations:nv,stopObservingMutations:rv,setReactivityEngine:function(t){HR=t.reactive,_R=t.release,JR=e=>t.effect(e,{scheduler:t=>{jR?function(t){var e;e=t,KR.includes(e)||KR.push(e),PR||TR||(TR=!0,queueMicrotask(WR))}(t):t()}}),YR=t.raw},onAttributeRemoved:Av,onAttributesAdded:ev,closestDataStack:uv,skipDuringClone:SN,onlyDuringClone:function(t){return(...e)=>kN&&t(...e)},addRootSelector:oN,addInitSelector:gN,interceptClone:FN,addScopeToNode:dv,deferMutations:function(){cv=!0},mapAttributes:jv,evaluateLater:Fv,interceptInit:function(t){lN.push(t)},setEvaluator:function(t){Rv=t},mergeProxies:Cv,extractProp:function(t,e,A,i=!0){if(t._x_bindings&&void 0!==t._x_bindings[e])return t._x_bindings[e];if(t._x_inlineBindings&&void 0!==t._x_inlineBindings[e]){let A=t._x_inlineBindings[e];return A.extract=i,Sv((()=>xv(t,A.expression)))}return HN(t,e,A)},findClosest:hN,onElRemoved:tv,closestRoot:cN,destroyTree:dN,interceptor:fv,transition:wN,setStyles:pN,mutateDom:gv,directive:Hv,entangle:YN,throttle:_N,debounce:JN,evaluate:xv,initTree:IN,nextTick:BN,prefixed:Lv,prefix:function(t){Gv=t},plugin:function(t){(Array.isArray(t)?t:[t]).forEach((t=>t(VN)))},magic:yv,store:function(t,e){if(KN||(PN=HR(PN),KN=!0),void 0===e)return PN[t];PN[t]=e,"object"==typeof e&&null!==e&&e.hasOwnProperty("init")&&"function"==typeof e.init&&PN[t].init(),Ev(PN[t])},start:function(){iN&&AN("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."),iN=!0,document.body||AN("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's ` + diff --git a/src/file-parse.js b/src/file-parse.js index d77da1d..0a847d8 100644 --- a/src/file-parse.js +++ b/src/file-parse.js @@ -1,12 +1,11 @@ import pdfjsDist from "pdfjs-dist"; -import pdfjsWorker from "pdfjs-dist/build/pdf.worker.min.mjs"; import { clearTableOutput, clearStatsOutput } from "./looks.js"; // upload file handler export function parseFile(event) { return new Promise((resolve, reject) => { // set the worker - pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker; + pdfjsLib.GlobalWorkerOptions.workerSrc = "./pdf.worker.min.mjs"; // get file const file = event.target.files[0]; diff --git a/style.css b/style.css index 60ef3ab..81ce964 100644 --- a/style.css +++ b/style.css @@ -758,6 +758,40 @@ html { --tw-contain-style: ; } +.container { + width: 100%; +} + +@media (min-width: 640px) { + .container { + max-width: 640px; + } +} + +@media (min-width: 768px) { + .container { + max-width: 768px; + } +} + +@media (min-width: 1024px) { + .container { + max-width: 1024px; + } +} + +@media (min-width: 1280px) { + .container { + max-width: 1280px; + } +} + +@media (min-width: 1536px) { + .container { + max-width: 1536px; + } +} + .alert { display: grid; width: 100%; @@ -800,6 +834,15 @@ html { color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); } + .menu li > *:not(ul, .menu-title, details, .btn):active, +.menu li > *:not(ul, .menu-title, details, .btn).active, +.menu li > details > summary:active { + --tw-bg-opacity: 1; + background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity))); + } + .table tr.hover:hover, .table tr.hover:nth-child(even):hover { --tw-bg-opacity: 1; @@ -944,6 +987,66 @@ html { --tw-border-opacity: 0.2; } +.collapse:not(td):not(tr):not(colgroup) { + visibility: visible; +} + +.collapse { + position: relative; + display: grid; + overflow: hidden; + grid-template-rows: auto 0fr; + transition: grid-template-rows 0.2s; + width: 100%; + border-radius: var(--rounded-box, 1rem); +} + +.collapse-title, +.collapse > input[type="checkbox"], +.collapse > input[type="radio"], +.collapse-content { + grid-column-start: 1; + grid-row-start: 1; +} + +.collapse > input[type="checkbox"], +.collapse > input[type="radio"] { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + opacity: 0; +} + +.collapse[open], +.collapse-open, +.collapse:focus:not(.collapse-close) { + grid-template-rows: auto 1fr; +} + +.collapse:not(.collapse-close):has(> input[type="checkbox"]:checked), +.collapse:not(.collapse-close):has(> input[type="radio"]:checked) { + grid-template-rows: auto 1fr; +} + +.collapse[open] > .collapse-content, +.collapse-open > .collapse-content, +.collapse:focus:not(.collapse-close) > .collapse-content, +.collapse:not(.collapse-close) > input[type="checkbox"]:checked ~ .collapse-content, +.collapse:not(.collapse-close) > input[type="radio"]:checked ~ .collapse-content { + visibility: visible; + min-height: -moz-fit-content; + min-height: fit-content; +} + +.diff { + position: relative; + display: grid; + width: 100%; + overflow: hidden; + container-type: inline-size; + grid-template-columns: auto 1fr; +} + .divider { display: flex; flex-direction: row; @@ -965,7 +1068,58 @@ html { background-color: var(--fallback-bc,oklch(var(--bc)/0.1)); } +.dropdown { + position: relative; + display: inline-block; +} + +.dropdown > *:not(summary):focus { + outline: 2px solid transparent; + outline-offset: 2px; +} + +.dropdown .dropdown-content { + position: absolute; +} + +.dropdown:is(:not(details)) .dropdown-content { + visibility: hidden; + opacity: 0; + transform-origin: top; + --tw-scale-x: .95; + --tw-scale-y: .95; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-timing-function: cubic-bezier(0, 0, 0.2, 1); + transition-duration: 200ms; +} + +.dropdown.dropdown-open .dropdown-content, +.dropdown:not(.dropdown-hover):focus .dropdown-content, +.dropdown:focus-within .dropdown-content { + visibility: visible; + opacity: 1; +} + @media (hover: hover) { + .dropdown.dropdown-hover:hover .dropdown-content { + visibility: visible; + opacity: 1; + } + + .btm-nav > *.disabled:hover, + .btm-nav > *[disabled]:hover { + pointer-events: none; + --tw-border-opacity: 0; + background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))); + --tw-bg-opacity: 0.1; + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); + --tw-text-opacity: 0.2; + } + .btn:hover { --tw-border-opacity: 1; border-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-border-opacity))); @@ -1026,6 +1180,16 @@ html { border-color: color-mix(in oklab, var(--fallback-p,oklch(var(--p)/1)) 90%, black); } } + + .dropdown.dropdown-hover:hover .dropdown-content { + --tw-scale-x: 1; + --tw-scale-y: 1; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + } +} + +.dropdown:is(details) summary::-webkit-details-marker { + display: none; } .file-input { @@ -1157,11 +1321,91 @@ html { margin-inline-end: -1rem; } +.join { + display: inline-flex; + align-items: stretch; + border-radius: var(--rounded-btn, 0.5rem); +} + +.join :where(.join-item) { + border-start-end-radius: 0; + border-end-end-radius: 0; + border-end-start-radius: 0; + border-start-start-radius: 0; +} + +.join .join-item:not(:first-child):not(:last-child), + .join *:not(:first-child):not(:last-child) .join-item { + border-start-end-radius: 0; + border-end-end-radius: 0; + border-end-start-radius: 0; + border-start-start-radius: 0; +} + +.join .join-item:first-child:not(:last-child), + .join *:first-child:not(:last-child) .join-item { + border-start-end-radius: 0; + border-end-end-radius: 0; +} + +.join .dropdown .join-item:first-child:not(:last-child), + .join *:first-child:not(:last-child) .dropdown .join-item { + border-start-end-radius: inherit; + border-end-end-radius: inherit; +} + +.join :where(.join-item:first-child:not(:last-child)), + .join :where(*:first-child:not(:last-child) .join-item) { + border-end-start-radius: inherit; + border-start-start-radius: inherit; +} + +.join .join-item:last-child:not(:first-child), + .join *:last-child:not(:first-child) .join-item { + border-end-start-radius: 0; + border-start-start-radius: 0; +} + +.join :where(.join-item:last-child:not(:first-child)), + .join :where(*:last-child:not(:first-child) .join-item) { + border-start-end-radius: inherit; + border-end-end-radius: inherit; +} + +@supports not selector(:has(*)) { + :where(.join *) { + border-radius: inherit; + } +} + +@supports selector(:has(*)) { + :where(.join *:has(.join-item)) { + border-radius: inherit; + } +} + .link { cursor: pointer; text-decoration-line: underline; } +.mask { + -webkit-mask-size: contain; + mask-size: contain; + -webkit-mask-repeat: no-repeat; + mask-repeat: no-repeat; + -webkit-mask-position: center; + mask-position: center; +} + +.menu li.disabled { + cursor: not-allowed; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + color: var(--fallback-bc,oklch(var(--bc)/0.3)); +} + .navbar { display: flex; align-items: center; @@ -1189,6 +1433,111 @@ html { justify-content: flex-end; } +.progress { + position: relative; + width: 100%; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + overflow: hidden; + height: 0.5rem; + border-radius: var(--rounded-box, 1rem); + background-color: var(--fallback-bc,oklch(var(--bc)/0.2)); +} + +.radio { + flex-shrink: 0; + --chkbg: var(--bc); + height: 1.5rem; + width: 1.5rem; + cursor: pointer; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + border-radius: 9999px; + border-width: 1px; + border-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-border-opacity))); + --tw-border-opacity: 0.2; +} + +.range { + height: 1.5rem; + width: 100%; + cursor: pointer; + -moz-appearance: none; + appearance: none; + -webkit-appearance: none; + --range-shdw: var(--fallback-bc,oklch(var(--bc)/1)); + overflow: hidden; + border-radius: var(--rounded-box, 1rem); + background-color: transparent; +} + +.range:focus { + outline: none; +} + +.select { + display: inline-flex; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + height: 3rem; + min-height: 3rem; + padding-inline-start: 1rem; + padding-inline-end: 2.5rem; + font-size: 0.875rem; + line-height: 1.25rem; + line-height: 2; + border-radius: var(--rounded-btn, 0.5rem); + border-width: 1px; + border-color: transparent; + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); + background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), + linear-gradient(135deg, currentColor 50%, transparent 50%); + background-position: calc(100% - 20px) calc(1px + 50%), + calc(100% - 16.1px) calc(1px + 50%); + background-size: 4px 4px, + 4px 4px; + background-repeat: no-repeat; +} + +.select[multiple] { + height: auto; +} + +.stack { + display: inline-grid; + place-items: center; + align-items: flex-end; +} + +.stack > * { + grid-column-start: 1; + grid-row-start: 1; + transform: translateY(10%) scale(0.9); + z-index: 1; + width: 100%; + opacity: 0.6; +} + +.stack > *:nth-child(2) { + transform: translateY(5%) scale(0.95); + z-index: 2; + opacity: 0.8; +} + +.stack > *:nth-child(1) { + transform: translateY(0) scale(1); + z-index: 3; + opacity: 1; +} + .stats { display: inline-grid; border-radius: var(--rounded-box, 1rem); @@ -1203,6 +1552,17 @@ html { overflow-x: auto; } +.steps .step { + display: grid; + grid-template-columns: repeat(1, minmax(0, 1fr)); + grid-template-columns: auto; + grid-template-rows: repeat(2, minmax(0, 1fr)); + grid-template-rows: 40px 1fr; + place-items: center; + text-align: center; + min-width: 4rem; +} + .swap { position: relative; display: inline-grid; @@ -1278,6 +1638,23 @@ html { background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); } +.textarea { + min-height: 3rem; + flex-shrink: 1; + padding-left: 1rem; + padding-right: 1rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + font-size: 0.875rem; + line-height: 1.25rem; + line-height: 2; + border-radius: var(--rounded-btn, 0.5rem); + border-width: 1px; + border-color: transparent; + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); +} + .toggle { flex-shrink: 0; --tglbg: var(--fallback-b1,oklch(var(--b1)/1)); @@ -1302,6 +1679,22 @@ html { var(--togglehandleborder); } +.btm-nav > *:where(.active) { + border-top-width: 2px; + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); +} + +.btm-nav > *.disabled, + .btm-nav > *[disabled] { + pointer-events: none; + --tw-border-opacity: 0; + background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))); + --tw-bg-opacity: 0.1; + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); + --tw-text-opacity: 0.2; +} + .btm-nav > * .label { font-size: 1rem; line-height: 1.5rem; @@ -1498,21 +1891,113 @@ html { } } -.divider:not(:empty) { - gap: 1rem; +details.collapse { + width: 100%; } -.drawer-toggle:focus-visible ~ .drawer-content label.drawer-button { - outline-style: solid; - outline-width: 2px; +details.collapse summary { + position: relative; + display: block; + outline: 2px solid transparent; outline-offset: 2px; } -.file-input-bordered { - --tw-border-opacity: 0.2; +details.collapse summary::-webkit-details-marker { + display: none; } -.file-input:focus { +.collapse:focus-visible { + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; + outline-color: var(--fallback-bc,oklch(var(--bc)/1)); +} + +.collapse:has(.collapse-title:focus-visible), +.collapse:has(> input[type="checkbox"]:focus-visible), +.collapse:has(> input[type="radio"]:focus-visible) { + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; + outline-color: var(--fallback-bc,oklch(var(--bc)/1)); +} + +.collapse:not(.collapse-open):not(.collapse-close) > input[type="checkbox"], +.collapse:not(.collapse-open):not(.collapse-close) > input[type="radio"]:not(:checked), +.collapse:not(.collapse-open):not(.collapse-close) > .collapse-title { + cursor: pointer; +} + +.collapse:focus:not(.collapse-open):not(.collapse-close):not(.collapse[open]) > .collapse-title { + cursor: unset; +} + +:where(.collapse > input[type="checkbox"]), +:where(.collapse > input[type="radio"]) { + z-index: 1; +} + +.collapse-title, +:where(.collapse > input[type="checkbox"]), +:where(.collapse > input[type="radio"]) { + width: 100%; + padding: 1rem; + padding-inline-end: 3rem; + min-height: 3.75rem; + transition: background-color 0.2s ease-out; +} + +.collapse[open] > :where(.collapse-content), +.collapse-open > :where(.collapse-content), +.collapse:focus:not(.collapse-close) > :where(.collapse-content), +.collapse:not(.collapse-close) > :where(input[type="checkbox"]:checked ~ .collapse-content), +.collapse:not(.collapse-close) > :where(input[type="radio"]:checked ~ .collapse-content) { + padding-bottom: 1rem; + transition: padding 0.2s ease-out, + background-color 0.2s ease-out; +} + +.collapse[open].collapse-arrow > .collapse-title:after, +.collapse-open.collapse-arrow > .collapse-title:after, +.collapse-arrow:focus:not(.collapse-close) > .collapse-title:after, +.collapse-arrow:not(.collapse-close) > input[type="checkbox"]:checked ~ .collapse-title:after, +.collapse-arrow:not(.collapse-close) > input[type="radio"]:checked ~ .collapse-title:after { + --tw-translate-y: -50%; + --tw-rotate: 225deg; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); +} + +.collapse[open].collapse-plus > .collapse-title:after, +.collapse-open.collapse-plus > .collapse-title:after, +.collapse-plus:focus:not(.collapse-close) > .collapse-title:after, +.collapse-plus:not(.collapse-close) > input[type="checkbox"]:checked ~ .collapse-title:after, +.collapse-plus:not(.collapse-close) > input[type="radio"]:checked ~ .collapse-title:after { + content: "−"; +} + +.divider:not(:empty) { + gap: 1rem; +} + +.drawer-toggle:focus-visible ~ .drawer-content label.drawer-button { + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; +} + +.dropdown.dropdown-open .dropdown-content, +.dropdown:focus .dropdown-content, +.dropdown:focus-within .dropdown-content { + --tw-scale-x: 1; + --tw-scale-y: 1; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); +} + +.file-input-bordered { + --tw-border-opacity: 0.2; +} + +.file-input:focus { outline-style: solid; outline-width: 2px; outline-offset: 2px; @@ -1635,6 +2120,12 @@ html { text-align: inherit; } +.join > :where(*:not(:first-child)) { + margin-top: 0px; + margin-bottom: 0px; + margin-inline-start: -1px; +} + .join > :where(*:not(:first-child)):is(.btn) { margin-inline-start: calc(var(--border-btn) * -1); } @@ -1674,6 +2165,24 @@ html { width: 2.5rem; } +:where(.menu li:not(.menu-title, .disabled) > *:not(ul, details, .menu-title)):not(summary, .active, .btn).focus, :where(.menu li:not(.menu-title, .disabled) > *:not(ul, details, .menu-title)):not(summary, .active, .btn):focus, :where(.menu li:not(.menu-title, .disabled) > *:not(ul, details, .menu-title)):is(summary):not(.active, .btn):focus-visible, :where(.menu li:not(.menu-title, .disabled) > details > summary:not(.menu-title)):not(summary, .active, .btn).focus, :where(.menu li:not(.menu-title, .disabled) > details > summary:not(.menu-title)):not(summary, .active, .btn):focus, :where(.menu li:not(.menu-title, .disabled) > details > summary:not(.menu-title)):is(summary):not(.active, .btn):focus-visible { + cursor: pointer; + background-color: var(--fallback-bc,oklch(var(--bc)/0.1)); + --tw-text-opacity: 1; + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); + outline: 2px solid transparent; + outline-offset: 2px; +} + +.menu li > *:not(ul, .menu-title, details, .btn):active, +.menu li > *:not(ul, .menu-title, details, .btn).active, +.menu li > details > summary:active { + --tw-bg-opacity: 1; + background-color: var(--fallback-n,oklch(var(--n)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-nc,oklch(var(--nc)/var(--tw-text-opacity))); +} + .mockup-phone .display { overflow: hidden; border-radius: 40px; @@ -1732,12 +2241,83 @@ html { } } +.progress::-moz-progress-bar { + border-radius: var(--rounded-box, 1rem); + --tw-bg-opacity: 1; + background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity))); +} + +.progress:indeterminate { + --progress-color: var(--fallback-bc,oklch(var(--bc)/1)); + background-image: repeating-linear-gradient( + 90deg, + var(--progress-color) -1%, + var(--progress-color) 10%, + transparent 10%, + transparent 90% + ); + background-size: 200%; + background-position-x: 15%; + animation: progress-loading 5s ease-in-out infinite; +} + +.progress::-webkit-progress-bar { + border-radius: var(--rounded-box, 1rem); + background-color: transparent; +} + +.progress::-webkit-progress-value { + border-radius: var(--rounded-box, 1rem); + --tw-bg-opacity: 1; + background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity))); +} + +.progress:indeterminate::-moz-progress-bar { + background-color: transparent; + background-image: repeating-linear-gradient( + 90deg, + var(--progress-color) -1%, + var(--progress-color) 10%, + transparent 10%, + transparent 90% + ); + background-size: 200%; + background-position-x: 15%; + animation: progress-loading 5s ease-in-out infinite; +} + @keyframes progress-loading { 50% { background-position-x: -115%; } } +.radio:focus { + box-shadow: none; +} + +.radio:focus-visible { + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; + outline-color: var(--fallback-bc,oklch(var(--bc)/1)); +} + +.radio:checked, + .radio[aria-checked="true"] { + --tw-bg-opacity: 1; + background-color: var(--fallback-bc,oklch(var(--bc)/var(--tw-bg-opacity))); + background-image: none; + animation: radiomark var(--animation-input, 0.2s) ease-out; + box-shadow: 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset, + 0 0 0 4px var(--fallback-b1,oklch(var(--b1)/1)) inset; +} + +.radio:disabled { + cursor: not-allowed; + opacity: 0.2; +} + @keyframes radiomark { 0% { box-shadow: 0 0 0 12px var(--fallback-b1,oklch(var(--b1)/1)) inset, @@ -1755,6 +2335,65 @@ html { } } +.range:focus-visible::-webkit-slider-thumb { + --focus-shadow: 0 0 0 6px var(--fallback-b1,oklch(var(--b1)/1)) inset, 0 0 0 2rem var(--range-shdw) inset; +} + +.range:focus-visible::-moz-range-thumb { + --focus-shadow: 0 0 0 6px var(--fallback-b1,oklch(var(--b1)/1)) inset, 0 0 0 2rem var(--range-shdw) inset; +} + +.range::-webkit-slider-runnable-track { + height: 0.5rem; + width: 100%; + border-radius: var(--rounded-box, 1rem); + background-color: var(--fallback-bc,oklch(var(--bc)/0.1)); +} + +.range::-moz-range-track { + height: 0.5rem; + width: 100%; + border-radius: var(--rounded-box, 1rem); + background-color: var(--fallback-bc,oklch(var(--bc)/0.1)); +} + +.range::-webkit-slider-thumb { + position: relative; + height: 1.5rem; + width: 1.5rem; + border-radius: var(--rounded-box, 1rem); + border-style: none; + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); + appearance: none; + -webkit-appearance: none; + top: 50%; + color: var(--range-shdw); + transform: translateY(-50%); + --filler-size: 100rem; + --filler-offset: 0.6rem; + box-shadow: 0 0 0 3px var(--range-shdw) inset, + var(--focus-shadow, 0 0), + calc(var(--filler-size) * -1 - var(--filler-offset)) 0 0 var(--filler-size); +} + +.range::-moz-range-thumb { + position: relative; + height: 1.5rem; + width: 1.5rem; + border-radius: var(--rounded-box, 1rem); + border-style: none; + --tw-bg-opacity: 1; + background-color: var(--fallback-b1,oklch(var(--b1)/var(--tw-bg-opacity))); + top: 50%; + color: var(--range-shdw); + --filler-size: 100rem; + --filler-offset: 0.5rem; + box-shadow: 0 0 0 3px var(--range-shdw) inset, + var(--focus-shadow, 0 0), + calc(var(--filler-size) * -1 - var(--filler-offset)) 0 0 var(--filler-size); +} + @keyframes rating-pop { 0% { transform: translateY(-0.125em); @@ -1769,6 +2408,50 @@ html { } } +.select:focus { + box-shadow: none; + border-color: var(--fallback-bc,oklch(var(--bc)/0.2)); + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; + outline-color: var(--fallback-bc,oklch(var(--bc)/0.2)); +} + +.select-disabled, + .select:disabled, + .select[disabled] { + cursor: not-allowed; + --tw-border-opacity: 1; + border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity))); + --tw-bg-opacity: 1; + background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity))); + color: var(--fallback-bc,oklch(var(--bc)/0.4)); +} + +.select-disabled::-moz-placeholder, .select:disabled::-moz-placeholder, .select[disabled]::-moz-placeholder { + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity))); + --tw-placeholder-opacity: 0.2; +} + +.select-disabled::placeholder, + .select:disabled::placeholder, + .select[disabled]::placeholder { + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity))); + --tw-placeholder-opacity: 0.2; +} + +.select-multiple, + .select[multiple], + .select[size].select:not([size="1"]) { + background-image: none; + padding-right: 1rem; +} + +[dir="rtl"] .select { + background-position: calc(0% + 12px) calc(1px + 50%), + calc(0% + 16px) calc(1px + 50%); +} + @keyframes skeleton { from { background-position: 150%; @@ -1792,6 +2475,48 @@ html { --tw-divide-x-reverse: 1; } +.steps .step:before { + top: 0px; + grid-column-start: 1; + grid-row-start: 1; + height: 0.5rem; + width: 100%; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + --tw-bg-opacity: 1; + background-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); + content: ""; + margin-inline-start: -100%; +} + +.steps .step:after { + content: counter(step); + counter-increment: step; + z-index: 1; + position: relative; + grid-column-start: 1; + grid-row-start: 1; + display: grid; + height: 2rem; + width: 2rem; + place-items: center; + place-self: center; + border-radius: 9999px; + --tw-bg-opacity: 1; + background-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-bg-opacity))); + --tw-text-opacity: 1; + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); +} + +.steps .step:first-child:before { + content: none; +} + +.steps .step[data-content]:after { + content: attr(data-content); +} + .swap-rotate .swap-on, .swap-rotate .swap-indeterminate, .swap-rotate input:indeterminate ~ .swap-on { @@ -1854,6 +2579,13 @@ html { background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity))); } +.table-zebra tr.active, + .table-zebra tr.active:nth-child(even), + .table-zebra-zebra tbody tr:nth-child(even) { + --tw-bg-opacity: 1; + background-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-bg-opacity))); +} + .table :where(thead tr, tbody tr:not(:last-child), tbody tr:first-child:last-child) { border-bottom-width: 1px; --tw-border-opacity: 1; @@ -1874,6 +2606,38 @@ html { border-top-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity))); } +.textarea:focus { + box-shadow: none; + border-color: var(--fallback-bc,oklch(var(--bc)/0.2)); + outline-style: solid; + outline-width: 2px; + outline-offset: 2px; + outline-color: var(--fallback-bc,oklch(var(--bc)/0.2)); +} + +.textarea-disabled, + .textarea:disabled, + .textarea[disabled] { + cursor: not-allowed; + --tw-border-opacity: 1; + border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity))); + --tw-bg-opacity: 1; + background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity))); + color: var(--fallback-bc,oklch(var(--bc)/0.4)); +} + +.textarea-disabled::-moz-placeholder, .textarea:disabled::-moz-placeholder, .textarea[disabled]::-moz-placeholder { + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity))); + --tw-placeholder-opacity: 0.2; +} + +.textarea-disabled::placeholder, + .textarea:disabled::placeholder, + .textarea[disabled]::placeholder { + color: var(--fallback-bc,oklch(var(--bc)/var(--tw-placeholder-opacity))); + --tw-placeholder-opacity: 0.2; +} + @keyframes toast-pop { 0% { transform: scale(0.9); @@ -1937,6 +2701,58 @@ html { var(--handleoffsetcalculator) 0 0 3px var(--fallback-bc,oklch(var(--bc)/1)) inset; } +.artboard.phone-1.horizontal, + .artboard.phone-1.artboard-horizontal { + width: 568px; + height: 320px; +} + +.artboard.phone-2.horizontal, + .artboard.phone-2.artboard-horizontal { + width: 667px; + height: 375px; +} + +.artboard.phone-3.horizontal, + .artboard.phone-3.artboard-horizontal { + width: 736px; + height: 414px; +} + +.artboard.phone-4.horizontal, + .artboard.phone-4.artboard-horizontal { + width: 812px; + height: 375px; +} + +.artboard.phone-5.horizontal, + .artboard.phone-5.artboard-horizontal { + width: 896px; + height: 414px; +} + +.artboard.phone-6.horizontal, + .artboard.phone-6.artboard-horizontal { + width: 1024px; + height: 320px; +} + +.btm-nav-xs > *:where(.active) { + border-top-width: 1px; +} + +.btm-nav-sm > *:where(.active) { + border-top-width: 2px; +} + +.btm-nav-md > *:where(.active) { + border-top-width: 2px; +} + +.btm-nav-lg > *:where(.active) { + border-top-width: 4px; +} + .btn-square:where(.btn-xs) { height: 1.5rem; width: 1.5rem; @@ -1975,6 +2791,82 @@ html { width: 0.125rem; } +.join.join-vertical { + flex-direction: column; +} + +.join.join-vertical .join-item:first-child:not(:last-child), + .join.join-vertical *:first-child:not(:last-child) .join-item { + border-end-start-radius: 0; + border-end-end-radius: 0; + border-start-start-radius: inherit; + border-start-end-radius: inherit; +} + +.join.join-vertical .join-item:last-child:not(:first-child), + .join.join-vertical *:last-child:not(:first-child) .join-item { + border-start-start-radius: 0; + border-start-end-radius: 0; + border-end-start-radius: inherit; + border-end-end-radius: inherit; +} + +.join.join-horizontal { + flex-direction: row; +} + +.join.join-horizontal .join-item:first-child:not(:last-child), + .join.join-horizontal *:first-child:not(:last-child) .join-item { + border-end-end-radius: 0; + border-start-end-radius: 0; + border-end-start-radius: inherit; + border-start-start-radius: inherit; +} + +.join.join-horizontal .join-item:last-child:not(:first-child), + .join.join-horizontal *:last-child:not(:first-child) .join-item { + border-end-start-radius: 0; + border-start-start-radius: 0; + border-end-end-radius: inherit; + border-start-end-radius: inherit; +} + +.steps-horizontal .step { + display: grid; + grid-template-columns: repeat(1, minmax(0, 1fr)); + grid-template-rows: repeat(2, minmax(0, 1fr)); + place-items: center; + text-align: center; +} + +.steps-vertical .step { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + grid-template-rows: repeat(1, minmax(0, 1fr)); +} + +.tooltip { + position: relative; + display: inline-block; + --tooltip-offset: calc(100% + 1px + var(--tooltip-tail, 0px)); +} + +.tooltip:before { + position: absolute; + pointer-events: none; + z-index: 1; + content: var(--tw-content); + --tw-content: attr(data-tip); +} + +.tooltip:before, .tooltip-top:before { + transform: translateX(-50%); + top: auto; + left: 50%; + right: auto; + bottom: var(--tooltip-offset); +} + .divider-horizontal { margin-left: 1rem; margin-right: 1rem; @@ -1984,14 +2876,69 @@ html { width: 1rem; } +.join.join-vertical > :where(*:not(:first-child)) { + margin-left: 0px; + margin-right: 0px; + margin-top: -1px; +} + .join.join-vertical > :where(*:not(:first-child)):is(.btn) { margin-top: calc(var(--border-btn) * -1); } +.join.join-horizontal > :where(*:not(:first-child)) { + margin-top: 0px; + margin-bottom: 0px; + margin-inline-start: -1px; +} + .join.join-horizontal > :where(*:not(:first-child)):is(.btn) { margin-inline-start: calc(var(--border-btn) * -1); } +.steps-horizontal .step { + grid-template-rows: 40px 1fr; + grid-template-columns: auto; + min-width: 4rem; +} + +.steps-horizontal .step:before { + height: 0.5rem; + width: 100%; + --tw-translate-x: 0px; + --tw-translate-y: 0px; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + content: ""; + margin-inline-start: -100%; +} + +.steps-horizontal .step:where([dir="rtl"], [dir="rtl"] *):before { + --tw-translate-x: 0px; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); +} + +.steps-vertical .step { + gap: 0.5rem; + grid-template-columns: 40px 1fr; + grid-template-rows: auto; + min-height: 4rem; + justify-items: start; +} + +.steps-vertical .step:before { + height: 100%; + width: 0.5rem; + --tw-translate-x: -50%; + --tw-translate-y: -50%; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); + margin-inline-start: 50%; +} + +.steps-vertical .step:where([dir="rtl"], [dir="rtl"] *):before { + --tw-translate-x: 50%; + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); +} + .table-lg :not(thead):not(tfoot) tr { font-size: 1rem; line-height: 1.5rem; @@ -2004,10 +2951,126 @@ html { padding-bottom: 1rem; } +.tooltip { + position: relative; + display: inline-block; + text-align: center; + --tooltip-tail: 0.1875rem; + --tooltip-color: var(--fallback-n,oklch(var(--n)/1)); + --tooltip-text-color: var(--fallback-nc,oklch(var(--nc)/1)); + --tooltip-tail-offset: calc(100% + 0.0625rem - var(--tooltip-tail)); +} + +.tooltip:before, +.tooltip:after { + opacity: 0; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter; + transition-delay: 100ms; + transition-duration: 200ms; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); +} + +.tooltip:after { + position: absolute; + content: ""; + border-style: solid; + border-width: var(--tooltip-tail, 0); + width: 0; + height: 0; + display: block; +} + +.tooltip:before { + max-width: 20rem; + white-space: normal; + border-radius: 0.25rem; + padding-left: 0.5rem; + padding-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + font-size: 0.875rem; + line-height: 1.25rem; + background-color: var(--tooltip-color); + color: var(--tooltip-text-color); + width: -moz-max-content; + width: max-content; +} + +.tooltip.tooltip-open:before { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip.tooltip-open:after { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:hover:before { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:hover:after { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:has(:focus-visible):after, +.tooltip:has(:focus-visible):before { + opacity: 1; + transition-delay: 75ms; +} + +.tooltip:not([data-tip]):hover:before, +.tooltip:not([data-tip]):hover:after { + visibility: hidden; + opacity: 0; +} + +.tooltip:after, .tooltip-top:after { + transform: translateX(-50%); + border-color: var(--tooltip-color) transparent transparent transparent; + top: auto; + left: 50%; + right: auto; + bottom: var(--tooltip-tail-offset); +} + +.visible { + visibility: visible; +} + +.collapse { + visibility: collapse; +} + +.static { + position: static; +} + +.absolute { + position: absolute; +} + +.end-1 { + inset-inline-end: 0.25rem; +} + +.block { + display: block; +} + .inline-block { display: inline-block; } +.inline { + display: inline; +} + .flex { display: flex; } @@ -2016,6 +3079,10 @@ html { display: table; } +.table-cell { + display: table-cell; +} + .grid { display: grid; } @@ -2080,6 +3147,14 @@ html { flex-grow: 1; } +.transform { + transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); +} + +.resize { + resize: both; +} + .flex-col { flex-direction: column; } @@ -2112,6 +3187,10 @@ html { border-radius: var(--rounded-box, 1rem); } +.border { + border-width: 1px; +} + .border-opacity-50 { --tw-border-opacity: 0.5; } @@ -2155,6 +3234,10 @@ html { text-transform: none; } +.italic { + font-style: italic; +} + .text-base-content { --tw-text-opacity: 1; color: var(--fallback-bc,oklch(var(--bc)/var(--tw-text-opacity))); @@ -2165,6 +3248,10 @@ html { color: var(--fallback-wa,oklch(var(--wa)/var(--tw-text-opacity))); } +.underline { + text-decoration-line: underline; +} + .opacity-0 { opacity: 0; } @@ -2173,10 +3260,33 @@ html { opacity: 0.7; } +.shadow { + --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); + --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color); + box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); +} + +.outline { + outline-style: solid; +} + +.blur { + --tw-blur: blur(8px); + filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow); +} + .filter { filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow); } +.transition { + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-duration: 150ms; +} + html { height: 100%; width: 100%;